Splice.TokenStandard.Utils.Internal.Conversions
Internal module implementing conversion functions between v1 and v2 of the token standard.
Import ‘Splice.TokenStandard.Utils’ to get access to the public ones.
Typeclasses
class BackwardCompatible v1 v2 where
A backwards compatible API upgrade from v1 to v2.
- upcast
: v1 -> v2
instance BackwardCompatible (ContractId AllocationInstruction) (ContractId AllocationInstruction)
instance BackwardCompatible (ContractId Allocation) (ContractId Allocation)
instance BackwardCompatible (ContractId Holding) (ContractId Holding)
instance BackwardCompatible (ContractId TransferInstruction) (ContractId TransferInstruction)
instance BackwardCompatible AllocationInstructionResult_Output AllocationInstructionResult_Output
instance BackwardCompatible AllocationSpecification AllocationSpecification
instance BackwardCompatible SettlementInfo SettlementInfo
instance BackwardCompatible HoldingView HoldingView
instance BackwardCompatible InstrumentId InstrumentId
instance BackwardCompatible Lock Lock
instance BackwardCompatible Transfer Transfer
instance BackwardCompatible TransferFactoryView TransferFactoryView
instance BackwardCompatible TransferInstructionResult TransferInstructionResult
instance BackwardCompatible TransferInstructionResult_Output TransferInstructionResult_Output
class ForwardCompatible v1 v2 where
- downcast
: v2 -> v1
instance ForwardCompatible (ContractId Holding) (ContractId Holding)
instance ForwardCompatible (ContractId TransferFactory) (ContractId TransferFactory)
instance ForwardCompatible (ContractId TransferInstruction) (ContractId TransferInstruction)
instance ForwardCompatible AllocationInstructionResult AllocationInstructionResult
instance ForwardCompatible AllocationInstructionResult_Output AllocationInstructionResult_Output
instance ForwardCompatible AllocationRequestView AllocationRequestView
instance ForwardCompatible Reference SettlementInfo
instance ForwardCompatible HoldingView HoldingView
instance ForwardCompatible InstrumentId InstrumentId
instance ForwardCompatible Lock Lock
instance ForwardCompatible Transfer Transfer
instance ForwardCompatible TransferFactoryView TransferFactoryView
instance ForwardCompatible TransferInstructionResult TransferInstructionResult
instance ForwardCompatible TransferInstructionResult_Output TransferInstructionResult_Output
instance ForwardCompatible TransferInstructionView TransferInstructionView
Functions
- fromAnyContractId
: AnyContractId -> ContractId t
- toAnyContractId
: ContractId t -> AnyContractId
- tokenStandardV2Namespace
: Text
Namespace for token standard V2 which is published as CIP-112.
- specialAccountOwnerStubV1
: Party
Party to use for as a stub for special accounts when reporting them through V1 APIs. Minimize the use of this function where possible.
- accountOwnerForV1
: Account -> Party
Owner of an account for V1 APIs that do expect a party to be given. Uses the
specialAccountOwnerStubV1for special accounts.
- accountPrincipal
-
The principal of an account, which is the owner for regular accounts, and the instrument admin for special accounts.
- basicAccount
: Party -> Account
Construct the basic account for an owner.
- isBasicAccount
: Account -> Bool
True if the account is a basic account.
- isRegularAccount
: Account -> Bool
True iff the account is a regular account, i.e., has an owner specified.
- accountParties
-
The principal of an account and the provider, if set.
- regularAccountParties
: Account -> [Party]
Get the account parties of a regular account. Fails if the account is no regular account.
Prefer to use
accountPartieswhere possible, as that function works for both regular and special accounts.
- regularAccountOwner
: Account -> Party
Get the owner of a regular account. Fails the it is not regular account.
- accountToMeta
: Text -> Account -> Metadata -> Metadata
- dropAccountMeta
: Text -> Metadata -> Metadata
- expiresAtToMeta
: Optional Time -> Metadata -> Metadata
Report early expiry of instructions or allocations in the V1 metadata.
- reasonMetaKey
: Text
Short, human-readable reason for the transaction.
- txKindMetaKey
: Text
Kind of the transaction.
- senderMetaKey
: Text
The sender of a transfer.
- receiverMetaKey
: Text
The receiver of a transfer.
Note: this keys is not defined in CIP-56, but matches the sender key, and is useful for transfer metadata, so we add it here for consistency.
- reasonFromMeta
: Metadata -> Text
Extra the transfer reason from the metadata. Returns an empty string if no reason is found.
- reasonToMeta
: Text -> Metadata -> Metadata
Add the given reason to the metadata, if it’s not empty.
- mkMetaTransferFrom
-
Metadata to tag a transfer for V1 transaction history parsing.
- v1HistoryTagAsUnlockV1
: Metadata -> Metadata
Tag a holdings change as an unlock for V1 tx history parsers.
Comments