Resource Switchboard
_10resource Switchboard {_10_10 receiverCapabilities: {Type: Capability<&{FungibleToken.Receiver}>}_10}
The resource that stores the multiple fungible token receiver capabilities, allowing the owner to add and remove them and anyone to deposit any fungible token among the available types.
Implemented Interfaces:
FungibleToken.Receiver
SwitchboardPublic
Initializer
_10func init()
Functions
fun addNewVault()
_10func addNewVault(capability Capability<&{FungibleToken.Receiver}>)
Adds a new fungible token receiver capability to the switchboard resource.
token vault deposit function through {FungibleToken.Receiver}
that
will be added to the switchboard.
Parameters:
- capability : The capability to expose a certain fungible
fun addNewVaultsByPath()
_10func addNewVaultsByPath(paths [PublicPath], address Address)
Adds a number of new fungible token receiver capabilities by using the paths where they are stored.
Parameters:
- paths : The paths where the public capabilities are stored.
- address : The address of the owner of the capabilities.
fun addNewVaultWrapper()
_10func addNewVaultWrapper(capability Capability<&{FungibleToken.Receiver}>, type Type)
Adds a new fungible token receiver capability to the switchboard
resource specifying which Type
of @FungibleToken.Vault
can be
deposited to it. Use it to include in your switchboard "wrapper"
receivers such as a @TokenForwarding.Forwarder
. It can also be
used to overwrite the type attached to a certain capability without
having to remove that capability first.
token vault deposit function through {FungibleToken.Receiver}
that
will be added to the switchboard.
capability, rather than the Type
from the reference borrowed from
said capability
Parameters:
- capability : The capability to expose a certain fungible
- type : The type of fungible token that can be deposited to that
fun removeVault()
_10func removeVault(capability Capability<&{FungibleToken.Receiver}>)
Removes a fungible token receiver capability from the switchboard resource.
removed from the switchboard.
Parameters:
- capability : The capability to a fungible token vault to be
fun deposit()
_10func deposit(from FungibleToken.Vault)
Takes a fungible token vault and routes it to the proper fungible token receiver capability for depositing it.
Parameters:
- from : The deposited fungible token vault resource.
fun safeDeposit()
_10func safeDeposit(from FungibleToken.Vault): FungibleToken.Vault?
Takes a fungible token vault and tries to route it to the proper fungible token receiver capability for depositing the funds, avoiding panicking if the vault is not available.
deposited.
funds if the deposit was successful, or still containing the funds if the reference to the needed vault was not found.
Parameters:
- vaultType : The type of the ft vault that wants to be
Returns: The deposited fungible token vault resource, without the
fun getVaultTypes()
_10func getVaultTypes(): [Type]
A getter function to know which tokens a certain switchboard resource is prepared to receive.
{FungibleToken.Receiver}
capabilities that can be effectively
borrowed.
Returns: The keys from the dictionary of stored