DeploySEALED
~╳$●@●!▪~□▓●░□@!╲▫●█#^◆^^&~~░╱▫~▒╳&*□$■@■░◆~╱╲▓▒@○○%●~!#$#~$░^▓@
Transaction ID
Execution Fee
0.00000574 FLOWTransaction Summary
DeployContract deployment
Contract deployment
Script Arguments
0nameString
DeFiActionsUtils
1codeString
import FungibleToken from 0xf233dcee88fe0abe
/// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/// THIS CONTRACT IS IN BETA AND IS NOT FINALIZED - INTERFACES MAY CHANGE AND/OR PENDING CHANGES MAY REQUIRE REDEPLOYMENT
/// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
///
/// DeFiActionsUtils
///
/// Utility methods commonly used across DeFiActions related contracts
///
access(all) contract DeFiActionsUtils {
/// Checks that the contract defining vaultType conforms to the FungibleToken contract interface. This is required
/// to source empty Vaults in the event inner Capabilities become invalid
///
/// @param vaultType: The Type of the Vault in question
///
/// @return true if the Type a Vault and is defined by a FungibleToken contract, false otherwise
///
access(all) view fun definingContractIsFungibleToken(_ vaultType: Type): Bool {
if !vaultType.isSubtype(of: Type<@{FungibleToken.Vault}>()) {
return false
}
return getAccount(vaultType.address!).contracts.borrow<&{FungibleToken}>(name: vaultType.contractName!) != nil
}
/// Returns an empty Vault of the given Type. Reverts if the provided Type is not defined by a FungibleToken
/// or if the returned Vault is not of the requested Type. Callers can use .definingContractIsFungibleToken()
/// to check the type before calling if they would like to prevent reverting.
///
/// @param vaultType: The Type of the Vault to return as an empty Vault
///
/// @return an empty Vault of the requested Type
///
access(all) fun getEmptyVault(_ vaultType: Type): @{FungibleToken.Vault} {
pre {
self.definingContractIsFungibleToken(vaultType):
"Invalid vault Type \(vaultType.identifier) requested - cannot create an empty Vault of an invalid type"
}
post {
result.getType() == vaultType:
"Invalid Vault returned - expected \(vaultType.identifier) but returned \(result.getType().identifier)"
}
return <- getAccount(vaultType.address!)
.contracts
.borrow<&{FungibleToken}>(name: vaultType.contractName!)!
.createEmptyVault(vaultType: vaultType)
}
}
Cadence Script
1transaction(name: String, code: String ) {
2 prepare(signer: auth(AddContract) &Account) {
3 signer.contracts.add(name: name, code: code.utf8 )
4 }
5 }