Skip to content

Latest commit

 

History

History
271 lines (185 loc) · 7.18 KB

Types.md

File metadata and controls

271 lines (185 loc) · 7.18 KB

ICRC1/Types

Type Value

type Value = {#Nat : Nat; #Int : Int; #Blob : Blob; #Text : Text}

Type BlockIndex

type BlockIndex = Nat

Type Subaccount

type Subaccount = Blob

Type Balance

type Balance = Nat

Type StableBuffer

type StableBuffer<T> = StableBuffer.StableBuffer<T>

Type StableTrieMap

type StableTrieMap<K, V> = STMap.StableTrieMap<K, V>

Type Account

type Account = { owner : Principal; subaccount : ?Subaccount }

Type EncodedAccount

type EncodedAccount = Blob

Type SupportedStandard

type SupportedStandard = { name : Text; url : Text }

Type Memo

type Memo = Blob

Type Timestamp

type Timestamp = Nat64

Type Duration

type Duration = Nat64

Type TxIndex

type TxIndex = Nat

Type TxLog

type TxLog = StableBuffer<Transaction>

Type MetaDatum

type MetaDatum = (Text, Value)

Type MetaData

type MetaData = [MetaDatum]

Type TxKind

type TxKind = {#mint; #burn; #transfer}

Type Mint

type Mint = { to : Account; amount : Balance; memo : ?Blob; created_at_time : ?Nat64 }

Type BurnArgs

type BurnArgs = { from_subaccount : ?Subaccount; amount : Balance; memo : ?Blob; created_at_time : ?Nat64 }

Type Burn

type Burn = { from : Account; amount : Balance; memo : ?Blob; created_at_time : ?Nat64 }

Type TransferArgs

type TransferArgs = { from_subaccount : ?Subaccount; to : Account; amount : Balance; fee : ?Balance; memo : ?Blob; created_at_time : ?Nat64 }

Arguments for a transfer operation

Type Transfer

type Transfer = { from : Account; to : Account; amount : Balance; fee : ?Balance; memo : ?Blob; created_at_time : ?Nat64 }

Type TransactionRequest

type TransactionRequest = { kind : TxKind; from : Account; to : Account; amount : Balance; fee : ?Balance; memo : ?Blob; created_at_time : ?Nat64; encoded : { from : EncodedAccount; to : EncodedAccount } }

Internal representation of a transaction request

Type Transaction

type Transaction = { kind : Text; mint : ?Mint; burn : ?Burn; transfer : ?Transfer; index : TxIndex; timestamp : Timestamp }

Type TimeError

type TimeError = {#TooOld; #CreatedInFuture : { ledger_time : Timestamp }}

Type TransferError

type TransferError = TimeError or {#BadFee : { expected_fee : Balance }; #BadBurn : { min_burn_amount : Balance }; #InsufficientFunds : { balance : Balance }; #Duplicate : { duplicate_of : TxIndex }; #TemporarilyUnavailable; #GenericError : { error_code : Nat; message : Text }}

Type TransferResult

type TransferResult = {#Ok : TxIndex; #Err : TransferError}

Type TokenInterface

type TokenInterface = actor { icrc1_name : shared query () -> async Text; icrc1_symbol : shared query () -> async Text; icrc1_decimals : shared query () -> async Nat8; icrc1_fee : shared query () -> async Balance; icrc1_metadata : shared query () -> async MetaData; icrc1_total_supply : shared query () -> async Balance; icrc1_minting_account : shared query () -> async ?Account; icrc1_balance_of : shared query (Account) -> async Balance; icrc1_transfer : shared (TransferArgs) -> async TransferResult; icrc1_supported_standards : shared query () -> async [SupportedStandard] }

Interface for the ICRC token canister

Type TxCandidBlob

type TxCandidBlob = Blob

Type ArchiveInterface

type ArchiveInterface = actor { append_transactions : shared ([Transaction]) -> async Result.Result<(), Text>; total_transactions : shared query () -> async Nat; get_transaction : shared query (TxIndex) -> async ?Transaction; get_transactions : shared query (GetTransactionsRequest) -> async TransactionRange; remaining_capacity : shared query () -> async Nat }

The Interface for the Archive canister

Type InitArgs

type InitArgs = { name : Text; symbol : Text; decimals : Nat8; fee : Balance; minting_account : Account; max_supply : Balance; initial_balances : [(Account, Balance)]; min_burn_amount : Balance; advanced_settings : ?AdvancedSettings }

Initial arguments for the setting up the icrc1 token canister

Type TokenInitArgs

type TokenInitArgs = { name : Text; symbol : Text; decimals : Nat8; fee : Balance; max_supply : Balance; initial_balances : [(Account, Balance)]; min_burn_amount : Balance; minting_account : ?Account; advanced_settings : ?AdvancedSettings }

InitArgs with optional fields for initializing a token canister

Type AdvancedSettings

type AdvancedSettings = { burned_tokens : Balance; transaction_window : Timestamp; permitted_drift : Timestamp }

Additional settings for the InitArgs type during initialization of an icrc1 token canister

Type AccountBalances

type AccountBalances = StableTrieMap<EncodedAccount, Balance>

Type ArchiveData

type ArchiveData = { var canister : ArchiveInterface; var stored_txs : Nat }

The details of the archive canister

Type TokenData

type TokenData = { name : Text; symbol : Text; decimals : Nat8; var _fee : Balance; max_supply : Balance; var _minted_tokens : Balance; var _burned_tokens : Balance; minting_account : Account; accounts : AccountBalances; metadata : StableBuffer<MetaDatum>; supported_standards : StableBuffer<SupportedStandard>; transaction_window : Nat; min_burn_amount : Balance; permitted_drift : Nat; transactions : StableBuffer<Transaction>; archive : ArchiveData }

The state of the token canister

Type GetTransactionsRequest

type GetTransactionsRequest = { start : TxIndex; length : Nat }

The type to request a range of transactions from the ledger canister

Type TransactionRange

type TransactionRange = { transactions : [Transaction] }

Type QueryArchiveFn

type QueryArchiveFn = shared query (GetTransactionsRequest) -> async TransactionRange

Type ArchivedTransaction

type ArchivedTransaction = { start : TxIndex; length : Nat; callback : QueryArchiveFn }

Type GetTransactionsResponse

type GetTransactionsResponse = { log_length : Nat; first_index : TxIndex; transactions : [Transaction]; archived_transactions : [ArchivedTransaction] }

Type RosettaInterface

type RosettaInterface = actor { get_transactions : shared query (GetTransactionsRequest) -> async GetTransactionsResponse }

Functions supported by the rosetta

Type FullInterface

type FullInterface = TokenInterface and RosettaInterface

Interface of the ICRC token and Rosetta canister