Module-level declarations

Types

Link copied to clipboard

The configuration for this module, to be defined in the chromia.yml

Link copied to clipboard

Represents an account's subscription, used to maintain the account active

Properties

Link copied to clipboard
val MODULE_NAME: text = "lib.ft4.core.accounts.strategy.transfer.subscription"

the name of this module, for more readable errors

Functions

Link copied to clipboard

Calculates the account details for the account that will be registered using the ft4.ras_transfer_subscription strategy.

Link copied to clipboard
function free_operations(): set<text>

Returns a list of operations that are considered free on this chain

Link copied to clipboard
@extend(strategy) function (): map<text, _strategy>
Link copied to clipboard
@extend(auth_handler) function (): map<text, _auth_handler>
Link copied to clipboard
@extend(before_authenticate) function (account: account, account_auth_descriptor: account_auth_descriptor)
Link copied to clipboard
Link copied to clipboard

Returns the ID of the account that receives the fee payments, or null for the default one

To get the account, the proper usage is:

val account = transfer.ensure_chain_fee_account(subscription_account_id());
Link copied to clipboard

Returns the assets configured in module_args.asset.

Link copied to clipboard

Returns the number of days a subscription lasts

Link copied to clipboard
function transfer_action(account: account, strategy_params_gtv: gtv)

The action for the subscription _strategy. Transfers the funds to the account, paying the fee and creating a subscription entity for the given account.

Throws "FORBIDDEN ASSET" if the asset:

  • cannot be used to pay the fee, or

  • is not found.

Throws if the transfer cannot be executed. Common cases are:

  • an account with the fee account ID exists, but it's not of transfer.ACCOUNT_TYPE_FEE

Throws if the chain configuration cannot be parsed.

Queries

Link copied to clipboard
@mount("ft4.get_subscription_assets") query get_subscription_assets(): list<(asset_id: byte_array, amount: big_integer)>

Returns a list of assets that can be used to pay for the subscription fee, alongside the amount to be paid.

Link copied to clipboard
@mount("ft4.get_subscription_details") query get_subscription_details(account_id: byte_array): (asset_id: byte_array, period_millis: integer, last_payment: integer)

Returns details about the subscription of the specified account, including the asset ID, the total duration of the subscription and the timestamp of the last payment.

Throws if the account does not exist.

Throws "MISSING SUBSCRIPTION" if no subscription was found for the account.

Link copied to clipboard
@mount("ft4.get_subscription_period_millis") query get_subscription_period_millis(): integer

Returns the number of milliseconds that take for a subscription to expire.

Operations

Link copied to clipboard
@mount("ft4.ras_transfer_subscription") operation ras_transfer_subscription(asset_id: byte_array, main: auth_descriptor, disposable: auth_descriptor?)

The operation that defines this strategy. The subscription strategy allows users to register a new account by paying a recurring fee. It does not grant the account any additional benefits.

Throws if the next operation in the transaction is not accepted by require_register_account_next_operation

Link copied to clipboard
@mount("ft4.renew_subscription") operation renew_subscription(asset_id: byte_array?)

Renews the subscription for an account by paying from that account with the given asset.

Must be signed by an auth descriptor with the accounts.AUTH_FLAG_TRANSFER.

Throws "MISSING SUBSCRIPTION" if the account does not have a subscription.

Throws "INPUT ERROR" if the asset cannot be used to pay the fees.

Throws if the transfer cannot be executed. Common cases are:

  • the account does not have enough funds

  • an account with the fee account ID exists, but it's not of transfer.ACCOUNT_TYPE_FEE