diff --git a/I2-code/LICENSE b/I2-code/LICENSE new file mode 100644 index 00000000..100acba5 --- /dev/null +++ b/I2-code/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 Tomi Jaga + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/I2-code/dfx.json b/I2-code/dfx.json new file mode 100644 index 00000000..82ce98fc --- /dev/null +++ b/I2-code/dfx.json @@ -0,0 +1,21 @@ +{ + "version": 1, + "canisters": { + "icrc1": { + "type": "motoko", + "main": "src/ICRC1/Canisters/Token.mo" + }, + "test": { + "type": "motoko", + "main": "tests/ActorTest.mo", + "args": "-v --compacting-gc" + } + }, + "defaults": { + "build": { + "packtool": "mops sources", + "args": "" + } + } + +} diff --git a/I2-code/docs/ICRC1/Account.html b/I2-code/docs/ICRC1/Account.html new file mode 100644 index 00000000..c1860603 --- /dev/null +++ b/I2-code/docs/ICRC1/Account.html @@ -0,0 +1,8 @@ + +
public func validate_subaccount(subaccount : ?T.Subaccount) : Bool
Checks if a subaccount is valid
+public func validate(account : T.Account) : Bool
Checks if an account is valid
+public func encode() : T.EncodedAccount
Implementation of ICRC1's Textual representation of accounts Encoding Standard
+public func decode(encoded : T.EncodedAccount) : ?T.Account
Implementation of ICRC1's Textual representation of accounts Decoding Standard
+public func fromText(encoded : Text) : ?T.Account
Converts an ICRC-1 Account from its Textual representation to the Account
type
public func toText(account : T.Account) : Text
Converts an ICRC-1 Account
to its Textual representation
public func create_canister() : async T.ArchiveInterface
creates a new archive canister
+public func total_txs(archives : T.StableBuffer<T.ArchiveData>) : Nat
Get the total number of archived transactions
+public func append_transactions(token : T.TokenData) : async ()
Moves the transactions from the ICRC1 canister to the archive canister +and returns a boolean that indicates the success of the data transfer
+public func icrc1_name() : async Text
Functions for the ICRC1 token standard
+public func icrc1_symbol() : async Text
public func icrc1_decimals() : async Nat8
public func icrc1_fee() : async ICRC1.Balance
public func icrc1_metadata() : async [ICRC1.MetaDatum]
public func icrc1_total_supply() : async ICRC1.Balance
public func icrc1_minting_account() : async ?ICRC1.Account
public func icrc1_balance_of(args : ICRC1.Account) : async ICRC1.Balance
public func icrc1_supported_standards() : async [ICRC1.SupportedStandard]
public func icrc1_transfer(args : ICRC1.TransferArgs) : async Result.Result<ICRC1.Balance, ICRC1.TransferError>
public func mint(args : ICRC1.Mint) : async Result.Result<ICRC1.Balance, ICRC1.TransferError>
public func burn(args : ICRC1.BurnArgs) : async Result.Result<ICRC1.Balance, ICRC1.TransferError>
public func get_transaction(token_id : Nat) : async ?ICRC1.Transaction
public func get_transactions(req : ICRC1.GetTransactionsRequest) : async ()
public func validate_memo(memo : ?T.Memo) : Bool
Checks if a transaction memo is valid
+public func is_too_old(token : T.TokenData, created_at_time : Nat64) : Bool
Checks if the created_at_time
of a transfer request is before the accepted time range
public func is_in_future(token : T.TokenData, created_at_time : Nat64) : Bool
Checks if the created_at_time
of a transfer request has not been reached yet relative to the canister's time.
public func deduplicate(token : T.TokenData, tx_req : T.TransactionRequest) : Result.Result<(), Nat>
Checks if there is a duplicate transaction that matches the transfer request in the main canister.
+If a duplicate is found, the function returns an error (#err
) with the duplicate transaction's index.
public func validate_fee(token : T.TokenData, opt_fee : ?T.Balance) : Bool
Checks if a transfer fee is valid
+public func validate_request(token : T.TokenData, tx_req : T.TransactionRequest) : Result.Result<(), T.TransferError>
Checks if a transfer request is valid
+Arguments for a transfer operation
+Internal representation of a transaction request
+Interface for the ICRC token canister
+The Interface for the Archive canister
+Initial arguments for the setting up the icrc1 token canister
+InitArgs with optional fields for initializing a token canister
+Additional settings for the InitArgs type during initialization of an icrc1 token canister
+The details of the archive canister
+The state of the token canister
+The type to request a range of transactions from the ledger canister
+Functions supported by the rosetta
+Interface of the ICRC token and Rosetta canister
+public func init_metadata(args : T.InitArgs) : StableBuffer.StableBuffer<T.MetaDatum>
public let default_standard : T.SupportedStandard
public func init_standards() : StableBuffer.StableBuffer<T.SupportedStandard>
public func default_subaccount() : T.Subaccount
public func hash(n : Nat) : Hash.Hash
public func create_transfer_req(
args : T.TransferArgs,
owner : Principal,
tx_kind : T.TxKind
) : T.TransactionRequest
public func kind_to_text(kind : T.TxKind) : Text
public func req_to_tx(tx_req : T.TransactionRequest, index : Nat) : T.Transaction
public func div_ceil(n : Nat, d : Nat) : Nat
public func get_balance(accounts : T.AccountBalances, encoded_account : T.EncodedAccount) : T.Balance
Retrieves the balance of an account
+public func update_balance(
accounts : T.AccountBalances,
encoded_account : T.EncodedAccount,
update : (T.Balance) -> T.Balance
)
Updates the balance of an account
+public func transfer_balance(token : T.TokenData, tx_req : T.TransactionRequest)
public func mint_balance(
token : T.TokenData,
encoded_account : T.EncodedAccount,
amount : T.Balance
)
public func burn_balance(
token : T.TokenData,
encoded_account : T.EncodedAccount,
amount : T.Balance
)
public let SB :
public let MAX_TRANSACTIONS_IN_LEDGER :
public let MAX_TRANSACTION_BYTES : Nat64
public let MAX_TRANSACTIONS_PER_REQUEST :
public func init(args : T.InitArgs) : T.TokenData
Initialize a new ICRC-1 token
+public func name(token : T.TokenData) : Text
Retrieve the name of the token
+public func symbol(token : T.TokenData) : Text
Retrieve the symbol of the token
+public func decimals() : Nat8
Retrieve the number of decimals specified for the token
+public func fee(token : T.TokenData) : T.Balance
Retrieve the fee for each transfer
+public func set_fee(token : T.TokenData, fee : Nat)
Set the fee for each transfer
+public func metadata(token : T.TokenData) : [T.MetaDatum]
Retrieve all the metadata of the token
+public func total_supply(token : T.TokenData) : T.Balance
Returns the total supply of circulating tokens
+public func minted_supply(token : T.TokenData) : T.Balance
Returns the total supply of minted tokens
+public func burned_supply(token : T.TokenData) : T.Balance
Returns the total supply of burned tokens
+public func max_supply(token : T.TokenData) : T.Balance
Returns the maximum supply of tokens
+public func minting_account(token : T.TokenData) : T.Account
Returns the account with the permission to mint tokens
+Note: The minting account can only participate in minting +and burning transactions, so any tokens sent to it will be +considered burned.
+public func supported_standards(token : T.TokenData) : [T.SupportedStandard]
Returns an array of standards supported by this token
+public func balance_from_float(token : T.TokenData, float : Float) : T.Balance
Formats a float to a nat balance and applies the correct number of decimal places
+public func transfer(
token : T.TokenData,
args : T.TransferArgs,
caller : Principal
) : async T.TransferResult
Transfers tokens from one account to another account (minting and burning included)
+public func mint(
token : T.TokenData,
args : T.Mint,
caller : Principal
) : async T.TransferResult
Helper function to mint tokens with minimum args
+public func burn(
token : T.TokenData,
args : T.BurnArgs,
caller : Principal
) : async T.TransferResult
Helper function to burn tokens with minimum args
+public func total_transactions(token : T.TokenData) : Nat
Returns the total number of transactions that have been processed by the given token.
+public func get_transaction(token : T.TokenData, tx_index : T.TxIndex) : async ?T.Transaction
Retrieves the transaction specified by the given tx_index
public func get_transactions(token : T.TokenData, req : T.GetTransactionsRequest) : T.GetTransactionsResponse
Retrieves the transactions specified by the given range
+