Skip to content

Commit 9821d6f

Browse files
committed
move burnCallback default implementation to a different interface
1 parent b0f65c5 commit 9821d6f

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

contracts/FungibleToken.cdc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ access(all) contract interface FungibleToken: ViewResolver {
7777
///
7878
access(all) resource interface Balance {
7979
access(all) var balance: UFix64
80+
81+
// This default implementation needs to be in a separate interface
82+
// from the one in `Vault` so that the conditions get enforced
83+
// in the correct one
84+
access(contract) fun burnCallback() {
85+
self.balance = 0.0
86+
}
8087
}
8188

8289
/// Provider
@@ -185,7 +192,6 @@ access(all) contract interface FungibleToken: ViewResolver {
185192
"FungibleToken.Vault.burnCallback: Cannot burn this Vault with Burner.burn(). "
186193
.concat("The balance must be set to zero during the burnCallback method so that it cannot be spammed.")
187194
}
188-
self.balance = 0.0
189195
}
190196

191197
/// getSupportedVaultTypes

0 commit comments

Comments
 (0)