-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor TokenHandler Minter setting pattern
- Loading branch information
1 parent
15dc839
commit 3f5d19e
Showing
6 changed files
with
140 additions
and
27 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
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
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
30 changes: 30 additions & 0 deletions
30
cadence/transactions/bridge/admin/set_token_handler_minter.cdc
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,30 @@ | ||
import "EVM" | ||
|
||
import "FlowEVMBridgeHandlerInterfaces" | ||
import "FlowEVMBridgeHandlers" | ||
import "FlowEVMBridgeConfig" | ||
|
||
/// Sets the minter | ||
/// | ||
/// @param vaultIdentifier: The type identifier of the vault to create the TokenHandler for | ||
/// @param minterStoragePath: The type identifier of the TokenMinter implementing resource | ||
/// | ||
transaction(vaultIdentifier: String, minterStoragePath: StoragePath, adminAddress: Address) { | ||
|
||
let configAdmin: &FlowEVMBridgeConfig.Admin | ||
let minter: @{FlowEVMBridgeHandlerInterfaces.TokenMinter} | ||
|
||
prepare(signer: auth(LoadValue) &Account) { | ||
self.configAdmin = getAccount(adminAddress).capabilities.borrow<&FlowEVMBridgeConfig.Admin>( | ||
FlowEVMBridgeConfig.adminPublicPath | ||
) ?? panic("Could not borrow reference to FlowEVMBridgeConfig.Admin") | ||
self.minter <- signer.storage.load<@{FlowEVMBridgeHandlerInterfaces.TokenMinter}>(from: minterStoragePath) | ||
?? panic("No minter found at provided storage path") | ||
} | ||
|
||
execute { | ||
let targetType = CompositeType(vaultIdentifier) | ||
?? panic("Invalid vault identifier") | ||
self.configAdmin.setTokenHandlerMinter(targetType: targetType, minter: <-self.minter) | ||
} | ||
} |