-
Notifications
You must be signed in to change notification settings - Fork 2
Add txs for NFTStorefrontV2 / TopShotMarketV3 #95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 5 commits
bf43f53
e6f872c
c429789
49e23a7
82d3e1c
22e7218
7c68190
70d8823
3377b92
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| package atlas | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "strings" | ||
| "testing" | ||
| ) | ||
|
|
@@ -36,3 +37,54 @@ func TestBuildFlowTxScript_EmptyParamsError(t *testing.T) { | |
| t.Errorf("expected empty tx string for error case, got: %s", tx) | ||
| } | ||
| } | ||
|
|
||
| func TestDelistNFTStorefrontOutput(t *testing.T) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these tests are not actually testing anything. It just logs stuff
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know, it helps see what is getting inputted |
||
| params := DelistNFTStorefrontTxScriptParams{ | ||
| NFTStorefrontAddress: "123", | ||
| ListingResourceIDs: []uint64{123, 456, 789}, | ||
| } | ||
|
|
||
| tx, err := DelistNFTStorefrontTxScript(params) | ||
| if err != nil { | ||
| t.Fatalf("unexpected error: %v", err) | ||
| } | ||
|
|
||
| fmt.Println("Generated transaction script:") | ||
| fmt.Println(tx) | ||
| t.Logf("Generated output:\n%s", tx) | ||
| } | ||
|
|
||
| func TestDelistTopShotMarketV3Output(t *testing.T) { | ||
| params := DelistTopShotMarketV3ScriptParams{ | ||
| TopShotContractAddress: "TOPSHOT", | ||
| TopShotMarketContractAddress: "MARKET", | ||
| NonFungibleTokenContractAddress: "NFT", | ||
| NftIds: []uint64{123, 456, 789}, | ||
| } | ||
|
|
||
| tx, err := DelistTopShotMarketV3Script(params) | ||
| if err != nil { | ||
| t.Fatalf("unexpected error: %v", err) | ||
| } | ||
|
|
||
| fmt.Println("Generated transaction script:") | ||
| fmt.Println(tx) | ||
| t.Logf("Generated output:\n%s", tx) | ||
| } | ||
|
|
||
| func TestDelistNFTStorefrontV2Output(t *testing.T) { | ||
| // Test what Go's text/template outputs when given a []uint64 | ||
| params := DelistNFTStorefrontV2TxScriptParams{ | ||
| NFTStorefrontV2Address: "123", | ||
| ListingResourceIDs: []uint64{123, 456, 789}, | ||
| } | ||
|
|
||
| tx, err := DelistNFTStorefrontV2TxScript(params) | ||
| if err != nil { | ||
| t.Fatalf("unexpected error: %v", err) | ||
| } | ||
|
|
||
| fmt.Println("Generated transaction script:") | ||
| fmt.Println(tx) | ||
| t.Logf("Generated output:\n%s", tx) | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -10,7 +10,7 @@ transaction() { | |||
| } | ||||
|
|
||||
| execute { | ||||
| let listingResourceIDs: [Uint64] = [{{.listingResourceIDs}}] | ||||
| let listingResourceIDs: [Uint64] = {{.ListingResourceIDs}} | ||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why are you removing the array?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. because I'm passing in an array, not a string with ids.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||
| for resourceID in listingResourceIDs { | ||||
| self.storefront.removeListing(listingResourceID: resourceID) | ||||
| } | ||||
|
|
||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,7 @@ transaction() { | |
| } | ||
|
|
||
| execute { | ||
| let listingResourceIDs: [Uint64] = [{{.listingResourceIDs}}] | ||
| let listingResourceIDs: [Uint64] = {{.ListingResourceIDs}} | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above |
||
| for resourceID in listingResourceIDs { | ||
| self.storefront.removeListing(listingResourceID: resourceID) | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,42 @@ | ||||||||
| import TopShot from 0x{{.TopShotContractAddress}} | ||||||||
| import Market from 0x{{.TopShotMarketContractAddress}} | ||||||||
| import TopShotMarketV3 from 0x{{.TopShotMarketContractAddress}} | ||||||||
| import NonFungibleToken from 0x{{.NonFungibleTokenContractAddress}} | ||||||||
|
|
||||||||
| // This transaction is for a user to stop a moment sale in their account | ||||||||
|
|
||||||||
| // Parameters | ||||||||
| // | ||||||||
| // tokenID: the ID of the moment whose sale is to be delisted | ||||||||
|
|
||||||||
| transaction() { | ||||||||
|
|
||||||||
| let nftIds: [UInt64] | ||||||||
|
|
||||||||
| prepare(acct: auth(Storage, Capabilities) &Account) { | ||||||||
| self.nftIds = {{.NftIds}} | ||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Even though I'm passing in a []uint64? same as above? Or would you rather it be a connected list of ids in a string?
|
||||||||
|
|
||||||||
| // borrow a reference to the owner's sale collection | ||||||||
| if let topshotSaleV3Collection = acct.storage.borrow<auth(TopShotMarketV3.Cancel) &TopShotMarketV3.SaleCollection>(from: TopShotMarketV3.marketStoragePath) { | ||||||||
|
|
||||||||
| // cancel the moments from the sale, thereby de-listing it | ||||||||
| for nftId in self.nftIds { | ||||||||
| topshotSaleV3Collection.cancelSale(tokenID: nftId) | ||||||||
| } | ||||||||
|
|
||||||||
| } else if let topshotSaleCollection = acct.storage.borrow<auth(NonFungibleToken.Withdraw) &Market.SaleCollection>(from: /storage/topshotSaleCollection) { | ||||||||
| // Borrow a reference to the NFT collection in the signers account | ||||||||
| let collectionRef = acct.storage.borrow<&TopShot.Collection>(from: /storage/MomentCollection) | ||||||||
| ?? panic("Could not borrow from MomentCollection in storage") | ||||||||
|
|
||||||||
| // withdraw the moments from the sale, thereby de-listing it | ||||||||
| for nftId in self.nftIds { | ||||||||
| let token <- topshotSaleCollection.withdraw(tokenID: nftId) | ||||||||
|
|
||||||||
| // deposit the moment into the owner's collection | ||||||||
| collectionRef.deposit(token: <-token) | ||||||||
| } | ||||||||
|
|
||||||||
| } | ||||||||
| } | ||||||||
| } | ||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be an array of uint64, you do the conversion to comma-separated string in ListNFTStorefrontV2TxScript. Same with the prices below. should be an array of integers(price in cents) and you do the conversion in the same function. SaleCommissionAmount should also be an integer(price in cent)