Skip to content

Commit

Permalink
TestWithdrawFails (#31)
Browse files Browse the repository at this point in the history
Co-authored-by: ash <[email protected]>
  • Loading branch information
web3ashlee and ash authored Dec 20, 2023
1 parent 6f468ea commit 9a11b9d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/FlowtyWrapped_tests.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,19 @@ pub fun testSingleMint() {
txExecutor("mint_flowty_wrapped.cdc", [minterAccount], [acct.address, username, ticket, totalNftsOwned, floatCount, favoriteCollections, collections], "address has already been minted")
}

pub fun testWithdrawFails() {
let acct = Test.createAccount()
let acct2 = Test.createAccount()
setupForMint(acct: acct)

let result = scriptExecutor("get_nft_ids.cdc", [acct.address])

let castedResult = result! as! [UInt64]
var nftID1 = castedResult[0]

txExecutor("withdraw_nft.cdc", [acct], [acct.address, acct2.address, nftID1], "Flowty Wrapped is not transferrable")
}

pub fun registerEdition(rafflesAcct: Test.Account, removeAfterReveal: Bool, start: UInt64, end: UInt64, baseImageUrl: String, baseHtmlUrl: String) {
txExecutor("register_edition.cdc", [rafflesAcct], [removeAfterReveal, start, end, baseImageUrl, baseHtmlUrl], nil)
}
17 changes: 17 additions & 0 deletions transactions/withdraw_nft.cdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import "NonFungibleToken"
import "FlowtyWrapped"

transaction(owner: Address, receiver: Address, withdrawID: UInt64) {

prepare(acct: AuthAccount){

let collectionRef = acct.borrow<&FlowtyWrapped.Collection>(from: FlowtyWrapped.CollectionStoragePath)
?? panic("Could not borrow a reference to the owner's collection")

let nft <- collectionRef.withdraw(withdrawID: 42)

let recipient = getAccount(receiver).getCapability<&{NonFungibleToken.CollectionPublic}>(FlowtyWrapped.CollectionPublicPath).borrow() ?? panic("invalid receiver collection")

recipient.deposit(token: <-nft)
}
}

0 comments on commit 9a11b9d

Please sign in to comment.