From 588fcf27e04351898c2ba54c9fbf9b60facb84a0 Mon Sep 17 00:00:00 2001 From: Jude Zhu Date: Wed, 22 May 2024 16:05:10 -0700 Subject: [PATCH 01/19] added embed --- go.mod | 3 +++ go.sum | 0 pds/embed.go | 14 ++++++++++++++ 3 files changed, 17 insertions(+) create mode 100644 go.mod create mode 100644 go.sum create mode 100644 pds/embed.go diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..554be83 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/dapperlabs/studio-platform-smart-contracts + +go 1.20 diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..e69de29 diff --git a/pds/embed.go b/pds/embed.go new file mode 100644 index 0000000..2f652df --- /dev/null +++ b/pds/embed.go @@ -0,0 +1,14 @@ +package pds + +import ( + "embed" +) + +//go:embed transactions/* +var Transaction embed.FS + +//go:embed scripts/* +var Scripts embed.FS + +//go:embed contracts/* +var Contracts embed.FS From 1b1309b8eda7d753d6b1d4e6ede07769ba727bc5 Mon Sep 17 00:00:00 2001 From: Jude Zhu Date: Wed, 22 May 2024 17:09:46 -0700 Subject: [PATCH 02/19] added replacer --- common/utils.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 common/utils.go diff --git a/common/utils.go b/common/utils.go new file mode 100644 index 0000000..62ac64e --- /dev/null +++ b/common/utils.go @@ -0,0 +1,36 @@ +package common + +import "regexp" + +var ( + placeholderNonFungibleToken = regexp.MustCompile(`"[^"\s].*/NonFungibleToken.cdc"`) + placeholderExampleNFT = regexp.MustCompile(`"[^"\s].*/ExampleNFT.cdc"`) + placeholderMetadataViews = regexp.MustCompile(`"[^"\s].*/MetadataViews.cdc"`) + placeholderFungibleToken = regexp.MustCompile(`"[^"\s].*/FungibleToken.cdc"`) +) + +type Replacer map[AddressName]*regexp.Regexp + +type AddressName string + +const ( + NonFungibleTokenAddr AddressName = "NonFungibleToken" +) + +var replacer Replacer + +func init() { + replacer = map[AddressName]*regexp.Regexp{ + "placeholderNonFungibleToken": placeholderNonFungibleToken, + "placeholderExampleNFT": placeholderExampleNFT, + "placeholderMetadataViews": placeholderMetadataViews, + "placeholderFungibleToken": placeholderFungibleToken, + } +} + +func (r Replacer) replaceAddresses(code string, addr map[AddressName]string) string { + for key, value := range addr { + code = r[key].ReplaceAllString(code, "0x"+value) + } + return code +} From c87e38e14b9920bba8830f863f05afc0bf42c566 Mon Sep 17 00:00:00 2001 From: Jude Zhu Date: Wed, 22 May 2024 17:13:29 -0700 Subject: [PATCH 03/19] export placer --- common/utils.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/utils.go b/common/utils.go index 62ac64e..21782ef 100644 --- a/common/utils.go +++ b/common/utils.go @@ -17,10 +17,10 @@ const ( NonFungibleTokenAddr AddressName = "NonFungibleToken" ) -var replacer Replacer +var NewReplacer Replacer func init() { - replacer = map[AddressName]*regexp.Regexp{ + NewReplacer = map[AddressName]*regexp.Regexp{ "placeholderNonFungibleToken": placeholderNonFungibleToken, "placeholderExampleNFT": placeholderExampleNFT, "placeholderMetadataViews": placeholderMetadataViews, From cd4df8ea44000657a417b9413f9399e145818919 Mon Sep 17 00:00:00 2001 From: Jude Zhu Date: Thu, 23 May 2024 09:53:20 -0700 Subject: [PATCH 04/19] added utils --- common/utils.go | 51 +++++++++++++++++++++++++++++--------------- common/utils_test.go | 32 +++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 17 deletions(-) create mode 100644 common/utils_test.go diff --git a/common/utils.go b/common/utils.go index 21782ef..d7db527 100644 --- a/common/utils.go +++ b/common/utils.go @@ -1,12 +1,16 @@ package common -import "regexp" +import ( + "fmt" + "reflect" + "regexp" +) var ( - placeholderNonFungibleToken = regexp.MustCompile(`"[^"\s].*/NonFungibleToken.cdc"`) - placeholderExampleNFT = regexp.MustCompile(`"[^"\s].*/ExampleNFT.cdc"`) - placeholderMetadataViews = regexp.MustCompile(`"[^"\s].*/MetadataViews.cdc"`) - placeholderFungibleToken = regexp.MustCompile(`"[^"\s].*/FungibleToken.cdc"`) + placeholderNonFungibleToken = regexp.MustCompile(`"[^"\s]?.*NonFungibleToken(\.cdc)?"`) + placeholderExampleNFT = regexp.MustCompile(`"[^"\s].*ExampleNFT.cdc"`) + placeholderMetadataViews = regexp.MustCompile(`"[^"\s].*MetadataViews.cdc"`) + placeholderFungibleToken = regexp.MustCompile(`"[^"\s].*FungibleToken.cdc"`) ) type Replacer map[AddressName]*regexp.Regexp @@ -17,20 +21,33 @@ const ( NonFungibleTokenAddr AddressName = "NonFungibleToken" ) -var NewReplacer Replacer - -func init() { - NewReplacer = map[AddressName]*regexp.Regexp{ - "placeholderNonFungibleToken": placeholderNonFungibleToken, - "placeholderExampleNFT": placeholderExampleNFT, - "placeholderMetadataViews": placeholderMetadataViews, - "placeholderFungibleToken": placeholderFungibleToken, +func NewReplacer() Replacer { + xxx := map[AddressName]*regexp.Regexp{ + NonFungibleTokenAddr: placeholderNonFungibleToken, } + return xxx } -func (r Replacer) replaceAddresses(code string, addr map[AddressName]string) string { - for key, value := range addr { - code = r[key].ReplaceAllString(code, "0x"+value) +func (r Replacer) ReplaceAddresses(code string, data interface{}) (string, error) { + + val := reflect.ValueOf(data) + if val.Kind() != reflect.Struct { + return "", fmt.Errorf("data must be a struct") + } + + var code1 = code + for i := 0; i < val.NumField(); i++ { + field := val.Type().Field(i) + fieldName := field.Name + fieldValue := val.Field(i).String() + + placeholder := AddressName(fieldName) + if r[placeholder] == nil { + return "", fmt.Errorf("no placeholder found for %s", placeholder) + } + + code1 = r[placeholder].ReplaceAllString(code1, "0x"+fieldValue) + fmt.Printf(`"%s %s"\n`, fieldName, fieldValue) } - return code + return code1, nil } diff --git a/common/utils_test.go b/common/utils_test.go new file mode 100644 index 0000000..9816da7 --- /dev/null +++ b/common/utils_test.go @@ -0,0 +1,32 @@ +package common + +import ( + "github.com/dapperlabs/studio-platform-smart-contracts/pds" + "testing" +) + +func TestGetUserOwnedEditionToMomentMap_Transaction(t *testing.T) { + script, err := pds.Transaction.ReadFile("transactions/deploy/deploy-packNFT-with-auth.cdc") + if err != nil { + t.Fatal(err) + } + t.Log(string(script)) +} + +func TestGetUserOwnedEditionToMomentMap_Script(t *testing.T) { + script, err := pds.Scripts.ReadFile("scripts/packNFT/balance_packNFT.cdc") + if err != nil { + t.Fatal(err) + } + t.Log(string(script)) + dddd := NewReplacer() + aaa, err := dddd.ReplaceAddresses(string(script), struct { + NonFungibleToken string + }{ + "0x1", + }) + if err != nil { + t.Fatal(err) + } + t.Log(aaa) +} From f92ed3a3a90c0f1f38678a6f194e951815fcc7e8 Mon Sep 17 00:00:00 2001 From: Jude Zhu Date: Thu, 30 May 2024 11:01:04 -0700 Subject: [PATCH 05/19] updated transaction --- pds/transactions/pds/mint_packNFT.cdc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pds/transactions/pds/mint_packNFT.cdc b/pds/transactions/pds/mint_packNFT.cdc index c009cd7..67e6a85 100644 --- a/pds/transactions/pds/mint_packNFT.cdc +++ b/pds/transactions/pds/mint_packNFT.cdc @@ -1,11 +1,11 @@ import PDS from "PDS" -import {{.PackNFTName}} from "PackNFT" +import "PackNFTName" from "PackNFT" import NonFungibleToken from "NonFungibleToken" transaction (distId: UInt64, commitHashes: [String], issuer: Address ) { prepare(pds: auth(BorrowValue) &Account) { let recvAcct = getAccount(issuer) - let recv = recvAcct.capabilities.borrow<&{NonFungibleToken.CollectionPublic}>({{.PackNFTName}}.CollectionPublicPath) + let recv = recvAcct.capabilities.borrow<&{NonFungibleToken.CollectionPublic}>("PackNFTName".CollectionPublicPath) ?? panic("Unable to borrow Collection Public reference for recipient") let cap = pds.storage.borrow<&PDS.DistributionManager>(from: PDS.DistManagerStoragePath) ?? panic("pds does not have Dist manager") From 405954993133e0ddf8a4eb4e1f959c9303b3bfdd Mon Sep 17 00:00:00 2001 From: Jude Zhu Date: Mon, 3 Jun 2024 07:51:15 -0700 Subject: [PATCH 06/19] updated set pack nft new collection --- .../packNFT/create_new_packNFT_collection.cdc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pds/transactions/packNFT/create_new_packNFT_collection.cdc b/pds/transactions/packNFT/create_new_packNFT_collection.cdc index 8df1cd9..c984096 100644 --- a/pds/transactions/packNFT/create_new_packNFT_collection.cdc +++ b/pds/transactions/packNFT/create_new_packNFT_collection.cdc @@ -2,15 +2,18 @@ import PackNFT from "PackNFT" import NonFungibleToken from "NonFungibleToken" transaction() { - prepare (issuer: AuthAccount) { + prepare (issuer: auth(Storage, Capabilities) &Account) { // Check if account already have a PackIssuer resource, if so destroy it - if issuer.borrow<&PackNFT.Collection>(from: PackNFT.CollectionStoragePath) == nil { - issuer.save(<- PackNFT.createEmptyCollection(), to: PackNFT.CollectionStoragePath); - issuer.link<&{NonFungibleToken.CollectionPublic}>(PackNFT.CollectionPublicPath, target: PackNFT.CollectionStoragePath) - ?? panic("Could not link Collection Pub Path"); - } + if issuer.storage.borrow<&PackNFT.Collection>(from: PackNFT.CollectionStoragePath) == nil { + let collection <- PackNFT.createEmptyCollection(nftType: Type<@PackNFT.NFT>()) + issuer.storage.save(<- collection, to: PackNFT.CollectionStoragePath); + issuer.capabilities.publish( + signer.capabilities.storage.issue<&PackNFT.Collection>(PackNFT.CollectionStoragePath), + at: PackNFT.CollectionPublicPath + ) ?? panic("Could not link Collection Pub Path"); + } } } From 47f6c3a4cf27ccdc830e4787e1a0cc481016b3f1 Mon Sep 17 00:00:00 2001 From: Jude Zhu Date: Mon, 3 Jun 2024 07:55:01 -0700 Subject: [PATCH 07/19] update --- pds/transactions/packNFT/create_new_packNFT_collection.cdc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pds/transactions/packNFT/create_new_packNFT_collection.cdc b/pds/transactions/packNFT/create_new_packNFT_collection.cdc index c984096..9fbdfd0 100644 --- a/pds/transactions/packNFT/create_new_packNFT_collection.cdc +++ b/pds/transactions/packNFT/create_new_packNFT_collection.cdc @@ -10,7 +10,7 @@ transaction() { issuer.storage.save(<- collection, to: PackNFT.CollectionStoragePath); issuer.capabilities.publish( - signer.capabilities.storage.issue<&PackNFT.Collection>(PackNFT.CollectionStoragePath), + issuer.capabilities.storage.issue<&PackNFT.Collection>(PackNFT.CollectionStoragePath), at: PackNFT.CollectionPublicPath ) ?? panic("Could not link Collection Pub Path"); } From 9ca744668375f8f88a5d567991832376ea273d09 Mon Sep 17 00:00:00 2001 From: Jude Zhu Date: Mon, 3 Jun 2024 07:57:45 -0700 Subject: [PATCH 08/19] update --- pds/transactions/packNFT/create_new_packNFT_collection.cdc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pds/transactions/packNFT/create_new_packNFT_collection.cdc b/pds/transactions/packNFT/create_new_packNFT_collection.cdc index 9fbdfd0..4c82fe9 100644 --- a/pds/transactions/packNFT/create_new_packNFT_collection.cdc +++ b/pds/transactions/packNFT/create_new_packNFT_collection.cdc @@ -12,7 +12,7 @@ transaction() { issuer.capabilities.publish( issuer.capabilities.storage.issue<&PackNFT.Collection>(PackNFT.CollectionStoragePath), at: PackNFT.CollectionPublicPath - ) ?? panic("Could not link Collection Pub Path"); + ) } } } From 24de4b53c0373d8ce2e197b2231b7f565620f1c8 Mon Sep 17 00:00:00 2001 From: Jude Zhu Date: Mon, 3 Jun 2024 09:05:52 -0700 Subject: [PATCH 09/19] update link tx --- .../dapperSport/link_providerCap_dapperSport.cdc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pds/transactions/dapperSport/link_providerCap_dapperSport.cdc b/pds/transactions/dapperSport/link_providerCap_dapperSport.cdc index c68b425..9ac0505 100644 --- a/pds/transactions/dapperSport/link_providerCap_dapperSport.cdc +++ b/pds/transactions/dapperSport/link_providerCap_dapperSport.cdc @@ -1,14 +1,16 @@ -import NonFungibleToken from 0x{{.NonFungibleToken}} -import {{.DapperSportContract}} from 0x{{.DapperSportAddress}} +import NonFungibleToken from "NonFungibleToken" +import DapperSport from "DapperSport" transaction(NFTProviderPath: PrivatePath) { - prepare(signer: AuthAccount) { + prepare(signer: auth(Capabilities) &Account) { if signer.getCapability<&{NonFungibleToken.Provider}>(NFTProviderPath).check() { return } + let cap = signer.capabilities.storage.issue<&{NonFungibleToken.Provider}>(target: DapperSport.CollectionStoragePath) + // This needs to be used to allow for PDS to withdraw - signer.link<&{NonFungibleToken.Provider}>( NFTProviderPath, target: {{.DapperSportContract}}.CollectionStoragePath) + signer.capabilities.publish(cap, at: NFTProviderPath) } } From 44de38b963b95135e8b01dd10ef97556cc79ac99 Mon Sep 17 00:00:00 2001 From: Jude Zhu Date: Mon, 3 Jun 2024 09:15:15 -0700 Subject: [PATCH 10/19] update tx --- pds/transactions/dapperSport/link_providerCap_dapperSport.cdc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pds/transactions/dapperSport/link_providerCap_dapperSport.cdc b/pds/transactions/dapperSport/link_providerCap_dapperSport.cdc index 9ac0505..10d9b39 100644 --- a/pds/transactions/dapperSport/link_providerCap_dapperSport.cdc +++ b/pds/transactions/dapperSport/link_providerCap_dapperSport.cdc @@ -4,7 +4,7 @@ import DapperSport from "DapperSport" transaction(NFTProviderPath: PrivatePath) { prepare(signer: auth(Capabilities) &Account) { - if signer.getCapability<&{NonFungibleToken.Provider}>(NFTProviderPath).check() { + if signer.capabilities.get<&{NonFungibleToken.Provider}>(at: NFTProviderPath).check() { return } let cap = signer.capabilities.storage.issue<&{NonFungibleToken.Provider}>(target: DapperSport.CollectionStoragePath) From 6a4cb326e08c7e5720ffc7539212d915d6a77622 Mon Sep 17 00:00:00 2001 From: Jude Zhu Date: Wed, 5 Jun 2024 15:24:15 -0700 Subject: [PATCH 11/19] update distribution --- pds/transactions/pds/create_distribution.cdc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pds/transactions/pds/create_distribution.cdc b/pds/transactions/pds/create_distribution.cdc index 94fdc96..a89ce36 100644 --- a/pds/transactions/pds/create_distribution.cdc +++ b/pds/transactions/pds/create_distribution.cdc @@ -1,17 +1,17 @@ import PDS from "PDS" -import {{.PackNFTName}} from "PackNFT" +import PackNFT from "PackNFT" import IPackNFT from "IPackNFT" import NonFungibleToken from "NonFungibleToken" -transaction(title: String, metadata: {String: String}) { +transaction(NFTProviderPathIdentifier: string, title: String, metadata: {String: String}) { prepare (issuer: auth(BorrowValue, Capabilities) &Account) { let i = issuer.storage.borrow(from: PDS.PackIssuerStoragePath) ?? panic ("issuer does not have PackIssuer resource") // issuer must have a PackNFT collection - let withdrawCap = issuer.capabilities.storage.issue(StoragePath(identifier: "cadenceExampleNFTCollection")!); - let operatorCap = issuer.capabilities.storage.issue({{.PackNFTName}}.OperatorStoragePath); + let withdrawCap = issuer.capabilities.storage.issue(StoragePath(identifier: NFTProviderPathIdentifier)!); + let operatorCap = issuer.capabilities.storage.issue(PackNFT.OperatorStoragePath); assert(withdrawCap.check(), message: "cannot borrow withdraw capability") assert(operatorCap.check(), message: "cannot borrow operator capability") From e0725764e0282910e97e7b75eedbd9f83756fd0f Mon Sep 17 00:00:00 2001 From: Jude Zhu Date: Wed, 5 Jun 2024 15:56:33 -0700 Subject: [PATCH 12/19] fix string --- pds/transactions/pds/create_distribution.cdc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pds/transactions/pds/create_distribution.cdc b/pds/transactions/pds/create_distribution.cdc index a89ce36..3a5193e 100644 --- a/pds/transactions/pds/create_distribution.cdc +++ b/pds/transactions/pds/create_distribution.cdc @@ -3,7 +3,7 @@ import PackNFT from "PackNFT" import IPackNFT from "IPackNFT" import NonFungibleToken from "NonFungibleToken" -transaction(NFTProviderPathIdentifier: string, title: String, metadata: {String: String}) { +transaction(NFTProviderPathIdentifier: String, title: String, metadata: {String: String}) { prepare (issuer: auth(BorrowValue, Capabilities) &Account) { let i = issuer.storage.borrow(from: PDS.PackIssuerStoragePath) From 7e00bb75af8388fda7be4fd3548f65e0724f641d Mon Sep 17 00:00:00 2001 From: Jude Zhu Date: Wed, 5 Jun 2024 18:19:49 -0700 Subject: [PATCH 13/19] added path --- pds/transactions/pds/settle.cdc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pds/transactions/pds/settle.cdc b/pds/transactions/pds/settle.cdc index bc2bae6..5862402 100644 --- a/pds/transactions/pds/settle.cdc +++ b/pds/transactions/pds/settle.cdc @@ -1,14 +1,14 @@ import PDS from "PDS" import ExampleNFT from "ExampleNFT" -transaction (distId: UInt64, nftIDs: [UInt64]) { +transaction (NFTProviderPath: String, distId: UInt64, nftIDs: [UInt64]) { prepare(pds: auth(BorrowValue) &Account) { let cap = pds.storage.borrow<&PDS.DistributionManager>(from: PDS.DistManagerStoragePath) ?? panic("pds does not have Dist manager") cap.withdraw( distId: distId, nftIDs: nftIDs, - escrowCollectionPublic: PublicPath(identifier: "cadenceExampleNFTCollection")!, + escrowCollectionPublic: PublicPath(identifier: NFTProviderPath)!, ) } } From 3474ff3c373dac76b5b6fdf5dd5ee3090bec65bc Mon Sep 17 00:00:00 2001 From: Jude Zhu Date: Thu, 6 Jun 2024 15:16:14 -0700 Subject: [PATCH 14/19] fix transactions --- .../transfer_flow_tokens_emulator.cdc | 24 +++++++++++-------- pds/transactions/pds/mint_packNFT.cdc | 4 ++-- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/pds/transactions/flowTokens/transfer_flow_tokens_emulator.cdc b/pds/transactions/flowTokens/transfer_flow_tokens_emulator.cdc index 51b8c70..8b4e2e7 100644 --- a/pds/transactions/flowTokens/transfer_flow_tokens_emulator.cdc +++ b/pds/transactions/flowTokens/transfer_flow_tokens_emulator.cdc @@ -9,19 +9,24 @@ // This is required because the newly created account requires // balance for the deployment of the FiatToken contract. -import FungibleToken from 0xee82856bf20e2aa6 -import FlowToken from 0x0ae53cb6e3f42a79 +import FungibleToken from "FungibleToken" +import FlowToken from "FlowToken" +import FungibleTokenMetadataViews from "FungibleTokenMetadataViews" transaction(amount: UFix64, to: Address) { // The Vault resource that holds the tokens that are being transferred - let sentVault: @FungibleToken.Vault + /// FTVaultData metadata view for the token being used + let vaultData: FungibleTokenMetadataViews.FTVaultData + let sentVault: @{FungibleToken.Vault} - prepare(signer: AuthAccount) { + prepare(signer: auth(BorrowValue) &Account) { + self.vaultData = FlowToken.resolveContractView(resourceType: nil, viewType: Type()) as! FungibleTokenMetadataViews.FTVaultData? + ?? panic("ViewResolver does not resolve FTVaultData view") // Get a reference to he signer's stored vault - let vaultRef = signer.borrow<&FlowToken.Vault>(from: /storage/flowTokenVault) - ?? panic("Could not borrow reference to the owner's Vault!") + let vaultRef = signer.storage.borrow(from: self.vaultData.storagePath) + ?? panic("Could not borrow reference to the owner's Vault!") // Withdraw tokens from the signer's stored vault self.sentVault <- vaultRef.withdraw(amount: amount) @@ -30,11 +35,10 @@ transaction(amount: UFix64, to: Address) { execute { // Get a reference to the recipient's Receiver let receiverRef = getAccount(to) - .getCapability(/public/flowTokenReceiver) - .borrow<&{FungibleToken.Receiver}>() - ?? panic("Could not borrow receiver reference to the recipient's Vault") + .capabilities.borrow<&{FungibleToken.Receiver}>(self.vaultData.receiverPath) + ?? panic("Could not borrow receiver reference to the recipient's Vault") // Deposit the withdrawn tokens in the recipient's receiver receiverRef.deposit(from: <-self.sentVault) } -} +} \ No newline at end of file diff --git a/pds/transactions/pds/mint_packNFT.cdc b/pds/transactions/pds/mint_packNFT.cdc index 67e6a85..812928f 100644 --- a/pds/transactions/pds/mint_packNFT.cdc +++ b/pds/transactions/pds/mint_packNFT.cdc @@ -1,11 +1,11 @@ import PDS from "PDS" -import "PackNFTName" from "PackNFT" +import PackNFT from "PackNFT" import NonFungibleToken from "NonFungibleToken" transaction (distId: UInt64, commitHashes: [String], issuer: Address ) { prepare(pds: auth(BorrowValue) &Account) { let recvAcct = getAccount(issuer) - let recv = recvAcct.capabilities.borrow<&{NonFungibleToken.CollectionPublic}>("PackNFTName".CollectionPublicPath) + let recv = recvAcct.capabilities.borrow<&{NonFungibleToken.CollectionPublic}>(PackNFT.CollectionPublicPath) ?? panic("Unable to borrow Collection Public reference for recipient") let cap = pds.storage.borrow<&PDS.DistributionManager>(from: PDS.DistManagerStoragePath) ?? panic("pds does not have Dist manager") From 928e416469ce1dc354c8a0b46818c50c9d7601c7 Mon Sep 17 00:00:00 2001 From: Jude Zhu Date: Tue, 11 Jun 2024 09:38:57 -0700 Subject: [PATCH 15/19] fix reveal request tx --- pds/embed.go | 2 +- pds/transactions/packNFT/reveal_request.cdc | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pds/embed.go b/pds/embed.go index 2f652df..eeea43f 100644 --- a/pds/embed.go +++ b/pds/embed.go @@ -5,7 +5,7 @@ import ( ) //go:embed transactions/* -var Transaction embed.FS +var Transactions embed.FS //go:embed scripts/* var Scripts embed.FS diff --git a/pds/transactions/packNFT/reveal_request.cdc b/pds/transactions/packNFT/reveal_request.cdc index 855deb8..aecafc7 100644 --- a/pds/transactions/packNFT/reveal_request.cdc +++ b/pds/transactions/packNFT/reveal_request.cdc @@ -1,10 +1,12 @@ import PackNFT from "PackNFT" import IPackNFT from "IPackNFT" +import NonFungibleToken from "NonFungibleToken" + transaction(revealID: UInt64, openRequest: Bool) { prepare(owner: auth(BorrowValue) &Account) { let collectionRef = owner.storage.borrow<&PackNFT.Collection>(from: PackNFT.CollectionStoragePath)! - let packNFT = collectionRef.borrowNFT(id: revealID) as! &{IPackNFT.NFT}! + let packNFT = collectionRef.borrowNFT(id: revealID) as! auth(NonFungibleToken.Update) &{IPackNFT.NFT}! packNFT.reveal(openRequest: openRequest) } } From 673085e7be88cd7c23f7493797d7f279c6fc4912 Mon Sep 17 00:00:00 2001 From: Jude Zhu Date: Tue, 11 Jun 2024 10:38:42 -0700 Subject: [PATCH 16/19] fix tx --- pds/transactions/packNFT/reveal_request.cdc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pds/transactions/packNFT/reveal_request.cdc b/pds/transactions/packNFT/reveal_request.cdc index aecafc7..a67ba1e 100644 --- a/pds/transactions/packNFT/reveal_request.cdc +++ b/pds/transactions/packNFT/reveal_request.cdc @@ -6,7 +6,7 @@ import NonFungibleToken from "NonFungibleToken" transaction(revealID: UInt64, openRequest: Bool) { prepare(owner: auth(BorrowValue) &Account) { let collectionRef = owner.storage.borrow<&PackNFT.Collection>(from: PackNFT.CollectionStoragePath)! - let packNFT = collectionRef.borrowNFT(id: revealID) as! auth(NonFungibleToken.Update) &{IPackNFT.NFT}! + let packNFT = collectionRef.borrowNFT(revealID) as! auth(NonFungibleToken.Update) &{IPackNFT.NFT}! packNFT.reveal(openRequest: openRequest) } } From e17243e988c62f1aed72755ed6321d5ce7bb882e Mon Sep 17 00:00:00 2001 From: Jude Zhu Date: Tue, 11 Jun 2024 11:19:58 -0700 Subject: [PATCH 17/19] updated tx --- pds/transactions/packNFT/reveal_request.cdc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pds/transactions/packNFT/reveal_request.cdc b/pds/transactions/packNFT/reveal_request.cdc index a67ba1e..88676f1 100644 --- a/pds/transactions/packNFT/reveal_request.cdc +++ b/pds/transactions/packNFT/reveal_request.cdc @@ -6,7 +6,7 @@ import NonFungibleToken from "NonFungibleToken" transaction(revealID: UInt64, openRequest: Bool) { prepare(owner: auth(BorrowValue) &Account) { let collectionRef = owner.storage.borrow<&PackNFT.Collection>(from: PackNFT.CollectionStoragePath)! - let packNFT = collectionRef.borrowNFT(revealID) as! auth(NonFungibleToken.Update) &{IPackNFT.NFT}! + let packNFT = collectionRef.borrowNFT(revealID) as! auth(NonFungibleToken.Update) &{PackNFT.NFT}! packNFT.reveal(openRequest: openRequest) } } From d7e230a644eaa31b5625545309c72650e7ecbdf9 Mon Sep 17 00:00:00 2001 From: Jude Zhu Date: Tue, 11 Jun 2024 15:12:25 -0700 Subject: [PATCH 18/19] fix tx --- pds/transactions/packNFT/reveal_request.cdc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pds/transactions/packNFT/reveal_request.cdc b/pds/transactions/packNFT/reveal_request.cdc index 88676f1..6d224e1 100644 --- a/pds/transactions/packNFT/reveal_request.cdc +++ b/pds/transactions/packNFT/reveal_request.cdc @@ -6,7 +6,8 @@ import NonFungibleToken from "NonFungibleToken" transaction(revealID: UInt64, openRequest: Bool) { prepare(owner: auth(BorrowValue) &Account) { let collectionRef = owner.storage.borrow<&PackNFT.Collection>(from: PackNFT.CollectionStoragePath)! - let packNFT = collectionRef.borrowNFT(revealID) as! auth(NonFungibleToken.Update) &{PackNFT.NFT}! + let packNFT = collectionRef.borrowNFT(revealID) as! auth(NonFungibleToken.Update) &PackNFT.NFT + ?? panic("NFT not valid") packNFT.reveal(openRequest: openRequest) } } From 5197c2bebbbdff79707c795ba884037d4643a5f6 Mon Sep 17 00:00:00 2001 From: Jude Zhu Date: Tue, 11 Jun 2024 15:37:42 -0700 Subject: [PATCH 19/19] update tx --- pds/transactions/packNFT/reveal_request.cdc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pds/transactions/packNFT/reveal_request.cdc b/pds/transactions/packNFT/reveal_request.cdc index 6d224e1..6dd067d 100644 --- a/pds/transactions/packNFT/reveal_request.cdc +++ b/pds/transactions/packNFT/reveal_request.cdc @@ -6,7 +6,7 @@ import NonFungibleToken from "NonFungibleToken" transaction(revealID: UInt64, openRequest: Bool) { prepare(owner: auth(BorrowValue) &Account) { let collectionRef = owner.storage.borrow<&PackNFT.Collection>(from: PackNFT.CollectionStoragePath)! - let packNFT = collectionRef.borrowNFT(revealID) as! auth(NonFungibleToken.Update) &PackNFT.NFT + let packNFT = collectionRef.borrowNFT(revealID) as? auth(NonFungibleToken.Update) &PackNFT.NFT ?? panic("NFT not valid") packNFT.reveal(openRequest: openRequest) }