-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update Burner for optional resources and add tests
- Loading branch information
1 parent
a31032a
commit a684e5e
Showing
7 changed files
with
244 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import "FungibleToken" | ||
import "ExampleToken" | ||
import "FungibleTokenMetadataViews" | ||
import "Burner" | ||
|
||
/// This transaction is for testing burning an array of Vaults | ||
/// | ||
transaction(amountPerIndex: UFix64, numIndicies: Int) { | ||
|
||
/// Vault resource that holds the tokens that are being burned | ||
let burnVaults: @[ExampleToken.Vault] | ||
|
||
prepare(signer: auth(BorrowValue) &Account) { | ||
|
||
let vaultData = ExampleToken.resolveContractView(resourceType: nil, viewType: Type<FungibleTokenMetadataViews.FTVaultData>()) as! FungibleTokenMetadataViews.FTVaultData? | ||
?? panic("Could not get vault data view for the contract") | ||
|
||
// Withdraw tokens from the signer's vault in storage | ||
let sourceVault = signer.storage.borrow<auth(FungibleToken.Withdraw) &ExampleToken.Vault>( | ||
from: vaultData.storagePath | ||
) ?? panic("Could not borrow a reference to the signer's ExampleToken vault") | ||
|
||
self.burnVaults <- [] | ||
var i = 0 | ||
while i < numIndicies { | ||
let vault <- sourceVault.withdraw(amount: amountPerIndex) as! @ExampleToken.Vault | ||
self.burnVaults.append(<-vault) | ||
i = i + 1 | ||
} | ||
} | ||
|
||
execute { | ||
|
||
Burner.burn(<-self.burnVaults) | ||
|
||
} | ||
} |
Oops, something went wrong.