Skip to content

Commit

Permalink
add destroy admin transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
austinkline committed Dec 20, 2023
1 parent 9be1a65 commit 4a85bbd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions contracts/FlowtyWrapped.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,10 @@ pub contract FlowtyWrapped: NonFungibleToken, ViewResolver {
return self.editions[name] ?? panic("no edition found with given name")
}

pub fun getAccountAddress(): Address {
return self.account.address
}

init() {
// Initialize the total supply
self.totalSupply = 0
Expand Down
12 changes: 12 additions & 0 deletions transactions/destroy_admin.cdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import "FlowtyWrapped"

transaction {
prepare(acct: AuthAccount) {
let admin <- acct.load<@AnyResource>(from: FlowtyWrapped.AdminStoragePath)
destroy admin

// borrow the contract admin resource to make sure we haven't destroyed the wrong admin
let publicAdmin = getAccount(FlowtyWrapped.getAccountAddress()).getCapability<&{FlowtyWrapped.AdminPublic}>(FlowtyWrapped.AdminPublicPath)
assert(publicAdmin.check(), message: "admin public isn't configured anymore!")
}
}

0 comments on commit 4a85bbd

Please sign in to comment.