Utility.Credential.App.V0.Types

Data Types

data BalanceState

The state of the balances on the credential. All accounting is done in CC.

BalanceState

Field

Type

Description

currentDepositAmountCc

Decimal

Current amount of locked CC held as part of the credential.

totalCredentialFeesPaidCc

Decimal

Total credential fees charged on this credential and paid to the issuer.

totalDistributedCc

Decimal

Total distribution to the user (includes deposit top ups).

totalPaidOutCc

Decimal

Total distribution paid out to the user.

totalUserDepositCc

Decimal

Total amount deposited by the user.

data BillingContext

Context retrieved from the ledger to be used for executing a billing cycle.

BillingContext

Field

Type

Description

now

Time

Time as of which the billing cycle is executed.

amuletRulesCid

ContractId AmuletRules

The contract-id of the amulet rules to use for billing.

openRoundCid

ContractId OpenMiningRound

The contract-id of the open round to user for billing.

openRound

OpenMiningRound

The data of the open round used for billing. Mostly used to fetch the coin price.

featuredTransferContext

AppTransferContext

Transfer context to use for making a CC transfer as a featured app.

unfeaturedTransferContext

AppTransferContext

Transfer context to use for making a CC transfer as an unfeatured app. Used for CC transfers not considered to be eligible as featured transfers by the SVs.

feeComputationContext

TransferContext

Context to use when computing fees.

data BillingCycleParams

Parameters that determine the execution of a specific billing cycle.

BillingCycleParams

Field

Type

Description

amuletPrice

Decimal

Price of the CC in USD at the time of the billing cycle.

credentialFeeCc

Decimal

Amount of CC to be charged as the credential fee.

newBilledUntil

Time

The time until which the credential will be paid for.

depositExpiresAt

Time

Time when the lock on the deposit expires.

data BillingParams

Configuration for the credential billing.

BillingParams

Field

Type

Description

feePerDayUsd

RatePerDay

The daily fee for the credential in USD.

billingPeriodMinutes

Int

Duration between the times where the credential fee is charged on a pro-rata basis (expressed in minutes).

depositTargetAmountUsd

Decimal

Target deposit amount (in USD). This is used when the user tops up their deposit, and when the issuer distributes coin and adjusts the holder’s deposit.

data BillingState

Information about the state of the billing process.

BillingState

Field

Type

Description

createdAt

Time

When this credential was created.

status

BillingStatus

The current status of the billing operation.

lastBilledAt

Time

Ledger time when this credential was last billed. This is mostly used for reference, not for the calculation of the actual billing amount.

billedUntil

Time

The time until which the credential is paid for. A credential is billed in integer multiples of the billing period, i.e., billedUntil = createdAt + N x billingPeriod.

lastBilledInRound

Round

The CC round that was used for the last billing.

totalCcFeesPaidIssuerCc

Decimal

Total amount of CC holding and transfer fees paid by the issuer for this credential.

totalCcFeesPaidHolderCc

Decimal

Total amount of CC holding and transfer fees paid by the holder for this credential.

data BillingStatus

The status of a billing operation.

Success

The billing operation was successful.

Failure

The billing operation failed.

Field

Type

Description

reason

Text

The reason for the failure, expected to be communicated to involved parties in the billing operation.

context

Text

Additional information on why the billing failed.

data RatePerDay

A rate per day.

RatePerDay

Field

Type

Description

rate

Decimal

The daily rate.

Functions

validateBillingParams

: BillingParams -> Bool

Validate the billing parameters.