Module-level declarations
Types
Allows to discern what was the last action on an account_creation_transfer
.
This differs from pending_transfer_expiration_state
in multiple ways. A pending_transfer_expiration_state
:
is passed by the user in queries, to filter results
refers to a transfer, meaning:
it happened recently enough
it happened too long ago
On the other hand, an account_creation_state
:
is used without user input
is attached to
account_creation_transfer
, meaning:the account was registered
the account was not registered in time, and the transfer has been recalled
neither of the above has happened, awaiting input.
Thus, for a certain transfer, the pending_transfer_expiration_state
can be expired, while the account_creation_state
can be pending if the sender did not claim their assets back.
Additionally, since an account_creation_transfer
has multiple rules associated with it, the same transfer can be considered pending for one rule and expired for another, if their timeout_days
values differ.
Represents a transfer that had a non-existing recipient, for which at least one rule was found that allowed account registration.
Represents an asset's lower limit, below which a transfer is deemed not sufficient for account registration. This struct must contain either of these options:
id
name
andblockchain_rid
If id
and name
are missing or both present, functions using this struct will consider it invalid.
If this value is being parsed from a GTV and name
is present instead of id
, blockchain_rid
is optional. If missing, its value will be this chain's RID.
Represents an asset that will be paid for a new account registration This struct must contain either of these options:
id
name
andblockchain_rid
If id
and name
are missing or both present, functions using this struct will consider it invalid.
If this value is being parsed from a GTV and name
is present instead of id
, blockchain_rid
is optional. If missing, its value will be this chain's RID.
The configuration defined in the chromia.yml
file.
The module_args
for this module accept a list of multiple entries. This represents one of the entries, which define which transfers can be accepted to allow users to register new accounts. This is called a transfer registration rule, and when parsed will be represented by the struct rule
.
A transfer must satisfy all the requirements of a single rule to be accepted.
Status of a transfer that was made to a non-existing account for its creation.
When querying for pending transfers, this can be used to filter responses.
Properties
A starting string for configuration errors
A starting string for configuration errors in strategies using payments
Constant that represent the account type used to store fees charged during account registration. Currently used for both fee
and subscription
strategies.
Constant that represents the account type used to temporarily store assets of transfers that have recipient_id that does not exist, while waiting for the account registration to happen
Used in transfer strategy rules to specify current account for the scenario when transfer rule requires that sender and recipient is the same.
Used in transfer strategy rules config to specify current chain
Functions
Moves the assets from the pool account where they were stored to the newly registered account. Marks the account_creation_transfer
s as done. Does not check if the rules for any strategy have been satisfied.
Can only be called from an operation.
Throws if the transfer cannot be made. Common cases include:
the funds are not in the pool account
an account with ID equal to this blockchain's pool account ID exists, but is not a pool account
Sends all assets that were sent to the pool account for a registration to the actual account that is being registered. Marks the account_creation_transfer
s as done. At least one of those transfers must satisfy strategy
, otherwise this function will throw. Multiple transfers cannot be bundled together to reach the threshold.
Can only be called from an operation.
Throws "MISSING TRANSFER"
if no account_creation_transfer
is found for this account.
Throws "REGISTRATION ERROR"
if none of the transfers satisfied the rule.
Throws if the transfer cannot be made. Common cases include:
the funds are not in the pool account anymore
an account with this blockchain's pool account ID exists, but is not a pool account
Returns the fee account for this chain, creating it if needed.
Can only be called from an operation.
Throws if custom_account_id
is not null, but the account specified does not exist.
Returns the pool account for this chain, creating it if needed.
Can only be called from an operation.
Returns the fee account for a chain, creating it if needed. This function should not normally be used, ensure_chain_fee_account
should be preferred.
Can only be called from an operation.
Throws if custom_account_id
is not null, but the account specified does not exist.
Returns the pool account for a chain, creating it if needed. This function should not normally be used, ensure_chain_pool_account
should be preferred.
Can only be called from an operation.
Utility for get_pending_transfer_strategies
. Returns whether an account_creation_transfer
matches a specific expiration state or not.
Finds all assets that a certain sender on a certain chain can send to the specified account ID to allow its registration.
This function can return that no asset is allowed. This means:
no rule allows account registration for the specified combination of parameters; or
a rule that allows this specific registration is found, but the asset that it requires is not yet registered on this chain.
Returns all rules on this chain that can be used to register an account given the parameters of the transfer.
Retrieves all rules following which a transfer can be used to register a new account.
Throws "CONFIG ERROR"
if the config cannot be parsed. Common cases are:
CURRENT_ACCOUNT_REF
is used in exactly one of sender or recipienttimeout_days
is a negative numbersender or recipient have a list of values, alongside which
CURRENT_ACCOUNT_REF
orANY_REF
are foundsome fields contain unexpected values. For example:
IDs cannot be parsed as hex
byte_array
sasset limits are invalid
Throws if any field is improperly formatted, in such a way that the values cannot be parsed.
Checks whether the transfer has timed out. This means the transfer would have satisfied a certain rule but timeout_days
has elapsed.
Utility function which returns whether a transaction has expired, given the rule it was using to register the account. If a transaction has expired, the account can no longer be registered and the transfer can be recalled to move funds back to the original sender.
Utility function which returns whether a rule allows a certain amount of an asset to be sent to register new accounts.
Utility function which returns whether a rule allows a certain blockchain_rid
as sender.
Utility function which returns whether a rule allows a certain account ID as recipient. Since some rules allow all recipients as long as the sender is the same as the recipient, the sender ID is needed as well.
Utility function which returns whether a rule allows a certain account ID as sender.
Utility function which returns whether a rule allows a certain registration strategy.
Utility function which returns whether a value is allowed by a certain allowlist
. This means the allowlist
is either set to allow all values, or the value is specified in the list of allowed values.
Reads a GTV-encoded moduleArgs field containing a single account ID.
Throws "CONFIG ERROR"
if the ID cannot be parsed as hex byte_array
Reads a GTV-encoded moduleArgs field containing account IDs.
Throws "CONFIG ERROR"
if the config cannot be parsed. Common cases are:
a list of values is received, alongside which
CURRENT_ACCOUNT_REF
orANY_REF
are foundIDs cannot be parsed as hex
byte_array
s
Reads a GTV-encoded moduleArgs field containing asset limits.
Reads a moduleArgs field containing a single asset limit, structured like a dictionary.
Throws "CONFIG ERROR"
if the asset limits are invalid.
Reads a GTV-encoded moduleArgs field containing asset limits.
Throws "CONFIG ERROR"
if the asset limits are invalid.
Throws if the asset limits are improperly formatted.
Reads a GTV-encoded moduleArgs field containing a single blockchain RID.
Throws "CONFIG ERROR"
if the RID cannot be parsed as hex byte_array
Reads a GTV-encoded moduleArgs field containing blockchain RIDs.
Throws "CONFIG ERROR"
if the config cannot be parsed. Common cases are:
a list of values is received, alongside which
ANY_REF
are foundIDs cannot be parsed as hex
byte_array
s
Parses the module_args
for a module, where the value contained is a list of fee_asset
s.
Throws "CONFIG ERROR"
if gtv
is neither a dictionary nor a list of dictionaries.
Throws if any of the assets is not a valid fee_asset
.
This method ensures that a rule exists for the transfer defined by the parameters passed, and creates an account_creation_transfer
entity representing that transfer.
This function does not check that the account does not exist, assuming it has been checked before calling this.
This function does not allow multiple transfers of the same asset to be transferred to the same account, regardless of sender.
Can only be called from an operation.
Throws "TRANSFER NOT ALLOWED"
if:
no rule allows that transfer, or
a pending transfer to the same account ID with the same asset already exists
Creates an account_creation_transfer
entity given its parameters.
Can only be called from an operation.
This function does not check anything. It simply creates the entity, so exceptional care is required if this function is needed. Although this function is provided, it is intended for internal use - no use-case should really require it.
Marks a specific account_creation_transfer
that has expired as recalled. It does not send the assets back to the sender.
Can only be called from an operation.
Throws "RECALL ERROR"
if the transfer cannot be recalled. Common cases include:
no pending transfer is found with the specified details:
the transfer was already completed or recalled
the transfer was never created
too many transfers have the specified details. This should never happen, but it could be caused by one operation creating multiple
account_creation_transfer
sthe transfer was found, but it has not yet timed out
Finds all assets that a certain rule allows for account registration.
Parses a list of fee_asset
s, and returns a map of all the ones that could be mapped to actual assets. This does not throw if an asset has not yet been registered, allowing assets to be added to the config a long time before actually registering them.
This function does not discern when a fee_asset
entry is invalid. This is because it will typically be called after the fee_asset
has been parsed and values have been fixed when possible. If improper input is provided, this function will behave this way:
if
id
is present, other values will be ignoredif
id
is missing,name
andblockchain_rid
must both be present - it will throw otherwise
Queries
Retrieves a list of assets that are allowed for account creation on this chain, given the parameters of the transfer that is going to register one.
Retrieves all account_creation_transfer
s that are pending (that is, not recalled nor completed), optionally filtering them based on whether they expired or not.
Returns a list of rule
s representing all conditions under which assets can be transferred to register a new account. For a transaction to be allowed, it must fulfill all criteria for at least one of the rules.
Throws if any rule found in the chromia.yml
is misconfigured. Common cases of misconfiguration can be found on the API docs for get_config
Returns whether a certain pending account_creation_transfer
exists, which means that a certain sender has sent the specified amount of this asset and the recipient has not yet created that account.