Skip to content

Commit

Permalink
fix transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
judezhu committed Jun 6, 2024
1 parent 7e00bb7 commit 3474ff3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
24 changes: 14 additions & 10 deletions pds/transactions/flowTokens/transfer_flow_tokens_emulator.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -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<FungibleTokenMetadataViews.FTVaultData>()) 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<auth(FungibleToken.Withdraw) &FlowToken.Vault>(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)
Expand All @@ -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)
}
}
}
4 changes: 2 additions & 2 deletions pds/transactions/pds/mint_packNFT.cdc
Original file line number Diff line number Diff line change
@@ -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")
Expand Down

0 comments on commit 3474ff3

Please sign in to comment.