@dfinity/ledger-icrc 2.1.3 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -0
- package/dist/candid/icrc_index-ng.certified.idl.d.ts +2 -0
- package/dist/candid/icrc_index-ng.certified.idl.js +127 -0
- package/dist/candid/icrc_index-ng.d.ts +117 -0
- package/dist/candid/icrc_index-ng.did +144 -0
- package/dist/candid/icrc_index-ng.idl.d.ts +2 -0
- package/dist/candid/icrc_index-ng.idl.js +127 -0
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/index.cjs.js.map +4 -4
- package/dist/esm/canister.js +2 -0
- package/dist/esm/canister.js.map +7 -0
- package/dist/esm/chunk-42OX77TJ.js +2 -0
- package/dist/esm/chunk-42OX77TJ.js.map +7 -0
- package/dist/esm/chunk-6GLYJI63.js +2 -0
- package/dist/esm/chunk-6GLYJI63.js.map +7 -0
- package/dist/esm/chunk-KSQGVESA.js +2 -0
- package/dist/esm/chunk-KSQGVESA.js.map +7 -0
- package/dist/esm/chunk-O4F4HWON.js +2 -0
- package/dist/esm/{chunk-MJQNXPUY.js.map → chunk-O4F4HWON.js.map} +4 -4
- package/dist/esm/index-ng.canister.js +2 -0
- package/dist/esm/index-ng.canister.js.map +7 -0
- package/dist/esm/index.canister.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/types/canister.d.ts +13 -0
- package/dist/types/index-ng.canister.d.ts +22 -0
- package/dist/types/index.d.ts +5 -2
- package/dist/types/types/index-ng.params.d.ts +8 -0
- package/dist/types/types/index-ng.types.d.ts +1 -0
- package/dist/types/types/index.types.d.ts +1 -0
- package/package.json +1 -1
- package/dist/esm/chunk-MJQNXPUY.js +0 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/index.canister.ts", "../../candid/icrc_index.certified.idl.js", "../../candid/icrc_index.idl.js"
|
|
4
|
-
"sourcesContent": ["import { Canister, createServices } from \"@dfinity/utils\";\nimport type {\n GetTransactions,\n _SERVICE as IcrcIndexService,\n} from \"../candid/icrc_index\";\nimport { idlFactory as certifiedIdlFactory } from \"../candid/icrc_index.certified.idl\";\nimport { idlFactory } from \"../candid/icrc_index.idl\";\nimport { toGetTransactionsArgs } from \"./converters/index.converters\";\nimport { IndexError } from \"./errors/index.errors\";\nimport type { IcrcLedgerCanisterOptions } from \"./types/canister.options\";\nimport type { GetAccountTransactionsParams } from \"./types/index.params\";\n\nexport class IcrcIndexCanister extends Canister<IcrcIndexService> {\n static create(options: IcrcLedgerCanisterOptions<IcrcIndexService>) {\n const { service, certifiedService, canisterId } =\n createServices<IcrcIndexService>({\n options,\n idlFactory,\n certifiedIdlFactory,\n });\n\n return new IcrcIndexCanister(canisterId, service, certifiedService);\n }\n\n /**\n * Get the transactions of an account\n *\n * Always certified.\n * `get_account_transactions` needs to be called with an update\n * because the index canisters makes a call to the ledger canister to get the transaction data.\n * Index Canister only holds the transactions ids in state, not the whole transaction data.\n */\n getTransactions = async (\n params: GetAccountTransactionsParams,\n ): Promise<GetTransactions> => {\n const response = await this.caller({\n certified: true,\n }).get_account_transactions(toGetTransactionsArgs(params));\n\n if (\"Err\" in response) {\n throw new IndexError(response.Err.message);\n }\n\n return response.Ok;\n };\n}\n", "/* Do not edit. Compiled with ./scripts/compile-idl-js from packages/ledger-icrc/candid/icrc_index.did */\nexport const idlFactory = ({ IDL }) => {\n const InitArgs = IDL.Record({ 'ledger_id' : IDL.Principal });\n const TxId = IDL.Nat;\n const Account = IDL.Record({\n 'owner' : IDL.Principal,\n 'subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n });\n const GetAccountTransactionsArgs = IDL.Record({\n 'max_results' : IDL.Nat,\n 'start' : IDL.Opt(TxId),\n 'account' : Account,\n });\n const Burn = IDL.Record({\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n 'spender' : IDL.Opt(Account),\n });\n const Mint = IDL.Record({\n 'to' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n });\n const Approve = IDL.Record({\n 'fee' : IDL.Opt(IDL.Nat),\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n 'expected_allowance' : IDL.Opt(IDL.Nat),\n 'expires_at' : IDL.Opt(IDL.Nat64),\n 'spender' : Account,\n });\n const Transfer = IDL.Record({\n 'to' : Account,\n 'fee' : IDL.Opt(IDL.Nat),\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n 'spender' : IDL.Opt(Account),\n });\n const Transaction = IDL.Record({\n 'burn' : IDL.Opt(Burn),\n 'kind' : IDL.Text,\n 'mint' : IDL.Opt(Mint),\n 'approve' : IDL.Opt(Approve),\n 'timestamp' : IDL.Nat64,\n 'transfer' : IDL.Opt(Transfer),\n });\n const TransactionWithId = IDL.Record({\n 'id' : TxId,\n 'transaction' : Transaction,\n });\n const GetTransactions = IDL.Record({\n 'transactions' : IDL.Vec(TransactionWithId),\n 'oldest_tx_id' : IDL.Opt(TxId),\n });\n const GetTransactionsErr = IDL.Record({ 'message' : IDL.Text });\n const GetTransactionsResult = IDL.Variant({\n 'Ok' : GetTransactions,\n 'Err' : GetTransactionsErr,\n });\n const SubAccount = IDL.Vec(IDL.Nat8);\n const ListSubaccountsArgs = IDL.Record({\n 'owner' : IDL.Principal,\n 'start' : IDL.Opt(SubAccount),\n });\n return IDL.Service({\n 'get_account_transactions' : IDL.Func(\n [GetAccountTransactionsArgs],\n [GetTransactionsResult],\n [],\n ),\n 'ledger_id' : IDL.Func([], [IDL.Principal], []),\n 'list_subaccounts' : IDL.Func(\n [ListSubaccountsArgs],\n [IDL.Vec(SubAccount)],\n [],\n ),\n });\n};\nexport const init = ({ IDL }) => {\n const InitArgs = IDL.Record({ 'ledger_id' : IDL.Principal });\n return [InitArgs];\n};\n", "/* Do not edit. Compiled with ./scripts/compile-idl-js from packages/ledger-icrc/candid/icrc_index.did */\nexport const idlFactory = ({ IDL }) => {\n const InitArgs = IDL.Record({ 'ledger_id' : IDL.Principal });\n const TxId = IDL.Nat;\n const Account = IDL.Record({\n 'owner' : IDL.Principal,\n 'subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n });\n const GetAccountTransactionsArgs = IDL.Record({\n 'max_results' : IDL.Nat,\n 'start' : IDL.Opt(TxId),\n 'account' : Account,\n });\n const Burn = IDL.Record({\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n 'spender' : IDL.Opt(Account),\n });\n const Mint = IDL.Record({\n 'to' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n });\n const Approve = IDL.Record({\n 'fee' : IDL.Opt(IDL.Nat),\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n 'expected_allowance' : IDL.Opt(IDL.Nat),\n 'expires_at' : IDL.Opt(IDL.Nat64),\n 'spender' : Account,\n });\n const Transfer = IDL.Record({\n 'to' : Account,\n 'fee' : IDL.Opt(IDL.Nat),\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n 'spender' : IDL.Opt(Account),\n });\n const Transaction = IDL.Record({\n 'burn' : IDL.Opt(Burn),\n 'kind' : IDL.Text,\n 'mint' : IDL.Opt(Mint),\n 'approve' : IDL.Opt(Approve),\n 'timestamp' : IDL.Nat64,\n 'transfer' : IDL.Opt(Transfer),\n });\n const TransactionWithId = IDL.Record({\n 'id' : TxId,\n 'transaction' : Transaction,\n });\n const GetTransactions = IDL.Record({\n 'transactions' : IDL.Vec(TransactionWithId),\n 'oldest_tx_id' : IDL.Opt(TxId),\n });\n const GetTransactionsErr = IDL.Record({ 'message' : IDL.Text });\n const GetTransactionsResult = IDL.Variant({\n 'Ok' : GetTransactions,\n 'Err' : GetTransactionsErr,\n });\n const SubAccount = IDL.Vec(IDL.Nat8);\n const ListSubaccountsArgs = IDL.Record({\n 'owner' : IDL.Principal,\n 'start' : IDL.Opt(SubAccount),\n });\n return IDL.Service({\n 'get_account_transactions' : IDL.Func(\n [GetAccountTransactionsArgs],\n [GetTransactionsResult],\n [],\n ),\n 'ledger_id' : IDL.Func([], [IDL.Principal], ['query']),\n 'list_subaccounts' : IDL.Func(\n [ListSubaccountsArgs],\n [IDL.Vec(SubAccount)],\n ['query'],\n ),\n });\n};\nexport const init = ({ IDL }) => {\n const InitArgs = IDL.Record({ 'ledger_id' : IDL.Principal });\n return [InitArgs];\n};\n"
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["Canister", "createServices", "idlFactory", "IDL", "InitArgs", "TxId", "Account", "GetAccountTransactionsArgs", "Burn", "Mint", "Approve", "Transfer", "Transaction", "TransactionWithId", "GetTransactions", "GetTransactionsErr", "GetTransactionsResult", "SubAccount", "ListSubaccountsArgs", "idlFactory", "IDL", "InitArgs", "TxId", "Account", "GetAccountTransactionsArgs", "Burn", "Mint", "Approve", "Transfer", "Transaction", "TransactionWithId", "GetTransactions", "GetTransactionsErr", "GetTransactionsResult", "SubAccount", "ListSubaccountsArgs", "
|
|
3
|
+
"sources": ["../../src/index.canister.ts", "../../candid/icrc_index.certified.idl.js", "../../candid/icrc_index.idl.js"],
|
|
4
|
+
"sourcesContent": ["import { Canister, createServices } from \"@dfinity/utils\";\nimport type {\n GetTransactions,\n _SERVICE as IcrcIndexService,\n} from \"../candid/icrc_index\";\nimport { idlFactory as certifiedIdlFactory } from \"../candid/icrc_index.certified.idl\";\nimport { idlFactory } from \"../candid/icrc_index.idl\";\nimport { toGetTransactionsArgs } from \"./converters/index.converters\";\nimport { IndexError } from \"./errors/index.errors\";\nimport type { IcrcLedgerCanisterOptions } from \"./types/canister.options\";\nimport type { GetAccountTransactionsParams } from \"./types/index.params\";\n\nexport class IcrcIndexCanister extends Canister<IcrcIndexService> {\n static create(options: IcrcLedgerCanisterOptions<IcrcIndexService>) {\n const { service, certifiedService, canisterId } =\n createServices<IcrcIndexService>({\n options,\n idlFactory,\n certifiedIdlFactory,\n });\n\n return new IcrcIndexCanister(canisterId, service, certifiedService);\n }\n\n /**\n * Get the transactions of an account\n *\n * Always certified.\n * `get_account_transactions` needs to be called with an update\n * because the index canisters makes a call to the ledger canister to get the transaction data.\n * Index Canister only holds the transactions ids in state, not the whole transaction data.\n */\n getTransactions = async (\n params: GetAccountTransactionsParams,\n ): Promise<GetTransactions> => {\n const response = await this.caller({\n certified: true,\n }).get_account_transactions(toGetTransactionsArgs(params));\n\n if (\"Err\" in response) {\n throw new IndexError(response.Err.message);\n }\n\n return response.Ok;\n };\n}\n", "/* Do not edit. Compiled with ./scripts/compile-idl-js from packages/ledger-icrc/candid/icrc_index.did */\nexport const idlFactory = ({ IDL }) => {\n const InitArgs = IDL.Record({ 'ledger_id' : IDL.Principal });\n const TxId = IDL.Nat;\n const Account = IDL.Record({\n 'owner' : IDL.Principal,\n 'subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n });\n const GetAccountTransactionsArgs = IDL.Record({\n 'max_results' : IDL.Nat,\n 'start' : IDL.Opt(TxId),\n 'account' : Account,\n });\n const Burn = IDL.Record({\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n 'spender' : IDL.Opt(Account),\n });\n const Mint = IDL.Record({\n 'to' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n });\n const Approve = IDL.Record({\n 'fee' : IDL.Opt(IDL.Nat),\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n 'expected_allowance' : IDL.Opt(IDL.Nat),\n 'expires_at' : IDL.Opt(IDL.Nat64),\n 'spender' : Account,\n });\n const Transfer = IDL.Record({\n 'to' : Account,\n 'fee' : IDL.Opt(IDL.Nat),\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n 'spender' : IDL.Opt(Account),\n });\n const Transaction = IDL.Record({\n 'burn' : IDL.Opt(Burn),\n 'kind' : IDL.Text,\n 'mint' : IDL.Opt(Mint),\n 'approve' : IDL.Opt(Approve),\n 'timestamp' : IDL.Nat64,\n 'transfer' : IDL.Opt(Transfer),\n });\n const TransactionWithId = IDL.Record({\n 'id' : TxId,\n 'transaction' : Transaction,\n });\n const GetTransactions = IDL.Record({\n 'transactions' : IDL.Vec(TransactionWithId),\n 'oldest_tx_id' : IDL.Opt(TxId),\n });\n const GetTransactionsErr = IDL.Record({ 'message' : IDL.Text });\n const GetTransactionsResult = IDL.Variant({\n 'Ok' : GetTransactions,\n 'Err' : GetTransactionsErr,\n });\n const SubAccount = IDL.Vec(IDL.Nat8);\n const ListSubaccountsArgs = IDL.Record({\n 'owner' : IDL.Principal,\n 'start' : IDL.Opt(SubAccount),\n });\n return IDL.Service({\n 'get_account_transactions' : IDL.Func(\n [GetAccountTransactionsArgs],\n [GetTransactionsResult],\n [],\n ),\n 'ledger_id' : IDL.Func([], [IDL.Principal], []),\n 'list_subaccounts' : IDL.Func(\n [ListSubaccountsArgs],\n [IDL.Vec(SubAccount)],\n [],\n ),\n });\n};\nexport const init = ({ IDL }) => {\n const InitArgs = IDL.Record({ 'ledger_id' : IDL.Principal });\n return [InitArgs];\n};\n", "/* Do not edit. Compiled with ./scripts/compile-idl-js from packages/ledger-icrc/candid/icrc_index.did */\nexport const idlFactory = ({ IDL }) => {\n const InitArgs = IDL.Record({ 'ledger_id' : IDL.Principal });\n const TxId = IDL.Nat;\n const Account = IDL.Record({\n 'owner' : IDL.Principal,\n 'subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n });\n const GetAccountTransactionsArgs = IDL.Record({\n 'max_results' : IDL.Nat,\n 'start' : IDL.Opt(TxId),\n 'account' : Account,\n });\n const Burn = IDL.Record({\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n 'spender' : IDL.Opt(Account),\n });\n const Mint = IDL.Record({\n 'to' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n });\n const Approve = IDL.Record({\n 'fee' : IDL.Opt(IDL.Nat),\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n 'expected_allowance' : IDL.Opt(IDL.Nat),\n 'expires_at' : IDL.Opt(IDL.Nat64),\n 'spender' : Account,\n });\n const Transfer = IDL.Record({\n 'to' : Account,\n 'fee' : IDL.Opt(IDL.Nat),\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(IDL.Nat64),\n 'amount' : IDL.Nat,\n 'spender' : IDL.Opt(Account),\n });\n const Transaction = IDL.Record({\n 'burn' : IDL.Opt(Burn),\n 'kind' : IDL.Text,\n 'mint' : IDL.Opt(Mint),\n 'approve' : IDL.Opt(Approve),\n 'timestamp' : IDL.Nat64,\n 'transfer' : IDL.Opt(Transfer),\n });\n const TransactionWithId = IDL.Record({\n 'id' : TxId,\n 'transaction' : Transaction,\n });\n const GetTransactions = IDL.Record({\n 'transactions' : IDL.Vec(TransactionWithId),\n 'oldest_tx_id' : IDL.Opt(TxId),\n });\n const GetTransactionsErr = IDL.Record({ 'message' : IDL.Text });\n const GetTransactionsResult = IDL.Variant({\n 'Ok' : GetTransactions,\n 'Err' : GetTransactionsErr,\n });\n const SubAccount = IDL.Vec(IDL.Nat8);\n const ListSubaccountsArgs = IDL.Record({\n 'owner' : IDL.Principal,\n 'start' : IDL.Opt(SubAccount),\n });\n return IDL.Service({\n 'get_account_transactions' : IDL.Func(\n [GetAccountTransactionsArgs],\n [GetTransactionsResult],\n [],\n ),\n 'ledger_id' : IDL.Func([], [IDL.Principal], ['query']),\n 'list_subaccounts' : IDL.Func(\n [ListSubaccountsArgs],\n [IDL.Vec(SubAccount)],\n ['query'],\n ),\n });\n};\nexport const init = ({ IDL }) => {\n const InitArgs = IDL.Record({ 'ledger_id' : IDL.Principal });\n return [InitArgs];\n};\n"],
|
|
5
|
+
"mappings": "+CAAA,OAAS,YAAAA,EAAU,kBAAAC,MAAsB,iBCClC,IAAMC,EAAa,CAAC,CAAE,IAAAC,CAAI,IAAM,CACrC,IAAMC,EAAWD,EAAI,OAAO,CAAE,UAAcA,EAAI,SAAU,CAAC,EACrDE,EAAOF,EAAI,IACXG,EAAUH,EAAI,OAAO,CACzB,MAAUA,EAAI,UACd,WAAeA,EAAI,IAAIA,EAAI,IAAIA,EAAI,IAAI,CAAC,CAC1C,CAAC,EACKI,EAA6BJ,EAAI,OAAO,CAC5C,YAAgBA,EAAI,IACpB,MAAUA,EAAI,IAAIE,CAAI,EACtB,QAAYC,CACd,CAAC,EACKE,EAAOL,EAAI,OAAO,CACtB,KAASG,EACT,KA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I,QAAQ,CACjB,yBAA6BA,EAAI,KAC7B,CAACI,CAA0B,EAC3B,CAACS,CAAqB,EACtB,CAAC,CACH,EACF,UAAcb,EAAI,KAAK,CAAC,EAAG,CAACA,EAAI,SAAS,EAAG,CAAC,OAAO,CAAC,EACrD,iBAAqBA,EAAI,KACrB,CAACe,CAAmB,EACpB,CAACf,EAAI,IAAIc,CAAU,CAAC,EACpB,CAAC,OAAO,CACV,CACJ,CAAC,CACH,EFxEO,IAAME,EAAN,MAAMC,UAA0BC,CAA2B,CAA3D,kCAoBL,qBAAkB,MAChBC,GAC6B,CAC7B,IAAMC,EAAW,MAAM,KAAK,OAAO,CACjC,UAAW,EACb,CAAC,EAAE,yBAAyBC,EAAsBF,CAAM,CAAC,EAEzD,GAAI,QAASC,EACX,MAAM,IAAIE,EAAWF,EAAS,IAAI,OAAO,EAG3C,OAAOA,EAAS,EAClB,EA/BA,OAAO,OAAOG,EAAsD,CAClE,GAAM,CAAE,QAAAC,EAAS,iBAAAC,EAAkB,WAAAC,CAAW,EAC5CC,EAAiC,CAC/B,QAAAJ,EACA,WAAAK,EACA,oBAAAA,CACF,CAAC,EAEH,OAAO,IAAIX,EAAkBS,EAAYF,EAASC,CAAgB,CACpE,CAuBF",
|
|
6
|
+
"names": ["Canister", "createServices", "idlFactory", "IDL", "InitArgs", "TxId", "Account", "GetAccountTransactionsArgs", "Burn", "Mint", "Approve", "Transfer", "Transaction", "TransactionWithId", "GetTransactions", "GetTransactionsErr", "GetTransactionsResult", "SubAccount", "ListSubaccountsArgs", "idlFactory", "IDL", "InitArgs", "TxId", "Account", "GetAccountTransactionsArgs", "Burn", "Mint", "Approve", "Transfer", "Transaction", "TransactionWithId", "GetTransactions", "GetTransactionsErr", "GetTransactionsResult", "SubAccount", "ListSubaccountsArgs", "IcrcIndexCanister", "_IcrcIndexCanister", "Canister", "params", "response", "toGetTransactionsArgs", "IndexError", "options", "service", "certifiedService", "canisterId", "createServices", "idlFactory"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{a}from"./chunk-O4F4HWON.js";import"./chunk-42OX77TJ.js";export{a as IcrcIndexCanister};
|
|
2
2
|
//# sourceMappingURL=index.canister.js.map
|
package/dist/esm/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as m}from"./chunk-KSQGVESA.js";import"./chunk-6GLYJI63.js";import{a as u}from"./chunk-O4F4HWON.js";import{b}from"./chunk-42OX77TJ.js";import{a as k,b as d}from"./chunk-UACBN2PF.js";var f=(t=>(t.SYMBOL="icrc1:symbol",t.NAME="icrc1:name",t.DECIMALS="icrc1:decimals",t.FEE="icrc1:fee",t.LOGO="icrc1:logo",t))(f||{});import{Principal as s}from"@dfinity/principal";import{bigEndianCrc32 as x,encodeBase32 as l,hexStringToUint8Array as g,isNullish as a,notEmptyString as y,uint8ArrayToHexString as A}from"@dfinity/utils";var I=64,E=({owner:r,subaccount:e})=>{if(a(e))return r.toText();let n=(i=>i.replace(/^0+/,""))(A(Uint8Array.from(e)));return n.length===0?r.toText():`${r.toText()}-${p({owner:r,subaccount:e})}.${n}`},p=({owner:r,subaccount:e})=>{let o=x(Uint8Array.from([...r.toUint8Array(),...e]));return l(o)},L=r=>{let[e,o]=r.split(".");if(!y(e))throw new Error("Invalid account. No string provided.");if(a(o))return{owner:s.fromText(r)};let[n,...i]=e.split("-").reverse(),t=i.reverse().join("-"),c={owner:s.fromText(t),subaccount:g(o.padStart(I,"0"))};if(p(c)!==n)throw new Error("Invalid account. Invalid checksum.");return c};import{isNullish as T,nonNullish as h}from"@dfinity/utils";var B=r=>{let e=/^([a-zA-Z]+):([A-Za-z0-9:\-.]+).*?(?:[?&](?:amount|value)=(\d+(?:\.\d+)?))?$/,o=r.match(e);if(T(o))return;let[n,i,t,c]=o;return{token:i,identifier:t,...h(c)&&!isNaN(parseFloat(c))&&{amount:parseFloat(c)}}};export{u as IcrcIndexCanister,m as IcrcIndexNgCanister,d as IcrcLedgerCanister,f as IcrcMetadataResponseEntries,k as IcrcTransferError,b as IndexError,L as decodeIcrcAccount,B as decodePayment,E as encodeIcrcAccount};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/types/ledger.responses.ts", "../../src/utils/ledger.utils.ts", "../../src/utils/payment.utils.ts"],
|
|
4
4
|
"sourcesContent": ["import type { Principal } from \"@dfinity/principal\";\nimport type { Subaccount, Value } from \"../../candid/icrc_ledger\";\n\n// Source: https://github.com/dfinity/icrc-1#standard-metadata-entries\nexport enum IcrcMetadataResponseEntries {\n SYMBOL = \"icrc1:symbol\",\n NAME = \"icrc1:name\",\n DECIMALS = \"icrc1:decimals\",\n FEE = \"icrc1:fee\",\n LOGO = \"icrc1:logo\",\n}\n\nexport type IcrcTokenMetadataResponse = [\n string | IcrcMetadataResponseEntries,\n Value,\n][];\n\nexport interface IcrcAccount {\n owner: Principal;\n subaccount?: Subaccount;\n}\n", "import { Principal } from \"@dfinity/principal\";\nimport {\n bigEndianCrc32,\n encodeBase32,\n hexStringToUint8Array,\n isNullish,\n notEmptyString,\n uint8ArrayToHexString,\n} from \"@dfinity/utils\";\nimport type { IcrcAccount } from \"../types/ledger.responses\";\n\nconst MAX_SUBACCOUNT_HEX_LENGTH = 64;\n\n/**\n * Encodes an Icrc-1 account compatible into a string.\n * Formatting Reference: https://github.com/dfinity/ICRC-1/blob/main/standards/ICRC-1/TextualEncoding.md\n *\n * @param account { owner: Principal, subaccount?: Uint8Array }\n * @returns string\n */\nexport const encodeIcrcAccount = ({\n owner,\n subaccount,\n}: IcrcAccount): string => {\n if (isNullish(subaccount)) {\n return owner.toText();\n }\n\n const removeLeadingZeros = (text: string): string => text.replace(/^0+/, \"\");\n\n const subaccountText = removeLeadingZeros(\n uint8ArrayToHexString(Uint8Array.from(subaccount)),\n );\n\n if (subaccountText.length === 0) {\n return owner.toText();\n }\n\n return `${owner.toText()}-${encodeCrc({\n owner,\n subaccount,\n })}.${subaccountText}`;\n};\n\nconst encodeCrc = ({ owner, subaccount }: Required<IcrcAccount>): string => {\n const crc = bigEndianCrc32(\n Uint8Array.from([...owner.toUint8Array(), ...subaccount]),\n );\n\n return encodeBase32(crc);\n};\n\n/**\n * Decodes a string into an Icrc-1 compatible account.\n * Formatting Reference: https://github.com/dfinity/ICRC-1/blob/main/standards/ICRC-1/TextualEncoding.md\n *\n * @param accountString string\n * @throws Error if the string is not a valid Icrc-1 account\n * @returns IcrcAccount { owner: Principal, subaccount?: Uint8Array }\n */\nexport const decodeIcrcAccount = (accountString: string): IcrcAccount => {\n const [principalAndMaybeCheckSum, subaccountHex] = accountString.split(\".\");\n\n if (!notEmptyString(principalAndMaybeCheckSum)) {\n throw new Error(\"Invalid account. No string provided.\");\n }\n\n if (isNullish(subaccountHex)) {\n return {\n owner: Principal.fromText(accountString),\n };\n }\n\n const [checksum, ...rest] = principalAndMaybeCheckSum.split(\"-\").reverse();\n const principalText = rest.reverse().join(\"-\");\n\n const account = {\n owner: Principal.fromText(principalText),\n subaccount: hexStringToUint8Array(\n subaccountHex.padStart(MAX_SUBACCOUNT_HEX_LENGTH, \"0\"),\n ),\n };\n\n const crcText = encodeCrc(account);\n\n if (crcText !== checksum) {\n throw new Error(\"Invalid account. Invalid checksum.\");\n }\n\n return account;\n};\n", "import { isNullish, nonNullish } from \"@dfinity/utils\";\n\n/**\n * \uD83D\uDC40 This feature is currently in draft. You can find more information about it at https://github.com/dfinity/ICRC/issues/22.\n *\n * A naive implementation of a payment parser. Given a code, the function attempts to extract a token name, account identifier (textual representation), and an optional amount.\n *\n * If the code doesn't match the expected pattern, `undefined` is returned for simplicity.\n * Similarly, if an optional amount is provided but it's not a valid number, the parser will not throw an exception and returns `undefined`.\n *\n * Please note that this function doesn't perform any validity checks on the extracted information.\n * It does not verify if the token is known or if the identifier is a valid address.\n *\n * ```\n * urn = token \":\" address [ \"?\" params]\n * token = [ ckbtc / icp / chat / bitcoin / ethereum ... ]\n * address = STRING\n * params = param [ \"&\" params ]\n * param = [ amountparam ]\n * amountparam = \"amount=\" *digit [ \".\" *digit ]\n * ```\n *\n * @param code string\n * @returns { token: string; identifier: string; amount?: number } | undefined\n */\nexport const decodePayment = (\n code: string,\n): { token: string; identifier: string; amount?: number } | undefined => {\n const regex =\n /^([a-zA-Z]+):([A-Za-z0-9:\\-.]+).*?(?:[?&](?:amount|value)=(\\d+(?:\\.\\d+)?))?$/;\n\n const match = code.match(regex);\n if (isNullish(match)) {\n return undefined;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const [_, token, identifier, amount] = match;\n\n return {\n token,\n identifier,\n ...(nonNullish(amount) &&\n !isNaN(parseFloat(amount)) && { amount: parseFloat(amount) }),\n };\n};\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "8LAIO,IAAKA,OACVA,EAAA,OAAS,eACTA,EAAA,KAAO,aACPA,EAAA,SAAW,iBACXA,EAAA,IAAM,YACNA,EAAA,KAAO,aALGA,OAAA,ICJZ,OAAS,aAAAC,MAAiB,qBAC1B,OACE,kBAAAC,EACA,gBAAAC,EACA,yBAAAC,EACA,aAAAC,EACA,kBAAAC,EACA,yBAAAC,MACK,iBAGP,IAAMC,EAA4B,GASrBC,EAAoB,CAAC,CAChC,MAAAC,EACA,WAAAC,CACF,IAA2B,CACzB,GAAIN,EAAUM,CAAU,EACtB,OAAOD,EAAM,OAAO,EAKtB,IAAME,GAFsBC,GAAyBA,EAAK,QAAQ,MAAO,EAAE,GAGzEN,EAAsB,WAAW,KAAKI,CAAU,CAAC,CACnD,EAEA,OAAIC,EAAe,SAAW,EACrBF,EAAM,OAAO,EAGf,GAAGA,EAAM,OAAO,CAAC,IAAII,EAAU,CACpC,MAAAJ,EACA,WAAAC,CACF,CAAC,CAAC,IAAIC,CAAc,EACtB,EAEME,EAAY,CAAC,CAAE,MAAAJ,EAAO,WAAAC,CAAW,IAAqC,CAC1E,IAAMI,EAAMb,EACV,WAAW,KAAK,CAAC,GAAGQ,EAAM,aAAa,EAAG,GAAGC,CAAU,CAAC,CAC1D,EAEA,OAAOR,EAAaY,CAAG,CACzB,EAUaC,EAAqBC,GAAuC,CACvE,GAAM,CAACC,EAA2BC,CAAa,EAAIF,EAAc,MAAM,GAAG,EAE1E,GAAI,CAACX,EAAeY,CAAyB,EAC3C,MAAM,IAAI,MAAM,sCAAsC,EAGxD,GAAIb,EAAUc,CAAa,EACzB,MAAO,CACL,MAAOlB,EAAU,SAASgB,CAAa,CACzC,EAGF,GAAM,CAACG,EAAU,GAAGC,CAAI,EAAIH,EAA0B,MAAM,GAAG,EAAE,QAAQ,EACnEI,EAAgBD,EAAK,QAAQ,EAAE,KAAK,GAAG,EAEvCE,EAAU,CACd,MAAOtB,EAAU,SAASqB,CAAa,EACvC,WAAYlB,EACVe,EAAc,SAASX,EAA2B,GAAG,CACvD,CACF,EAIA,GAFgBM,EAAUS,CAAO,IAEjBH,EACd,MAAM,IAAI,MAAM,oCAAoC,EAGtD,OAAOG,CACT,EC1FA,OAAS,aAAAC,EAAW,cAAAC,MAAkB,iBAyB/B,IAAMC,EACXC,GACuE,CACvE,IAAMC,EACJ,+EAEIC,EAAQF,EAAK,MAAMC,CAAK,EAC9B,GAAIJ,EAAUK,CAAK,EACjB,OAIF,GAAM,CAACC,EAAGC,EAAOC,EAAYC,CAAM,EAAIJ,EAEvC,MAAO,CACL,MAAAE,EACA,WAAAC,EACA,GAAIP,EAAWQ,CAAM,GACnB,CAAC,MAAM,WAAWA,CAAM,CAAC,GAAK,CAAE,OAAQ,WAAWA,CAAM,CAAE,CAC/D,CACF",
|
|
6
6
|
"names": ["IcrcMetadataResponseEntries", "Principal", "bigEndianCrc32", "encodeBase32", "hexStringToUint8Array", "isNullish", "notEmptyString", "uint8ArrayToHexString", "MAX_SUBACCOUNT_HEX_LENGTH", "encodeIcrcAccount", "owner", "subaccount", "subaccountText", "text", "encodeCrc", "crc", "decodeIcrcAccount", "accountString", "principalAndMaybeCheckSum", "subaccountHex", "checksum", "rest", "principalText", "account", "isNullish", "nonNullish", "decodePayment", "code", "regex", "match", "_", "token", "identifier", "amount"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Canister } from "@dfinity/utils";
|
|
2
|
+
import type { _SERVICE as IcrcIndexNgService } from "../candid/icrc_index-ng";
|
|
3
|
+
import type { _SERVICE as IcrcLedgerService, Tokens } from "../candid/icrc_ledger";
|
|
4
|
+
import type { BalanceParams } from "./types/ledger.params";
|
|
5
|
+
export declare abstract class IcrcCanister<T extends IcrcLedgerService | IcrcIndexNgService> extends Canister<T> {
|
|
6
|
+
/**
|
|
7
|
+
* Returns the balance for a given account provided as owner and with optional subaccount.
|
|
8
|
+
*
|
|
9
|
+
* @param {BalanceParams} params The parameters to get the balance of an account.
|
|
10
|
+
* @returns {Promise<Tokens>} The balance of the given account.
|
|
11
|
+
*/
|
|
12
|
+
balance: (params: BalanceParams) => Promise<Tokens>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { GetTransactions, _SERVICE as IcrcIndexNgService } from "../candid/icrc_index-ng";
|
|
2
|
+
import { IcrcCanister } from "./canister";
|
|
3
|
+
import type { IcrcLedgerCanisterOptions } from "./types/canister.options";
|
|
4
|
+
import type { GetIndexNgAccountTransactionsParams } from "./types/index-ng.params";
|
|
5
|
+
export declare class IcrcIndexNgCanister extends IcrcCanister<IcrcIndexNgService> {
|
|
6
|
+
static create(options: IcrcLedgerCanisterOptions<IcrcIndexNgService>): IcrcIndexNgCanister;
|
|
7
|
+
/**
|
|
8
|
+
* Get the transactions of an account
|
|
9
|
+
*
|
|
10
|
+
* Always certified.
|
|
11
|
+
* `get_account_transactions` needs to be called with an update
|
|
12
|
+
* because the index canisters makes a call to the ledger canister to get the transaction data.
|
|
13
|
+
* Index Canister only holds the transactions ids in state, not the whole transaction data.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Get the transactions of an account.
|
|
17
|
+
*
|
|
18
|
+
* @param {GetAccountTransactionsParams} params The parameters to get the transactions of an account.
|
|
19
|
+
* @returns {Promise<GetTransactions>} The list of transactions and further related information of the given account.
|
|
20
|
+
*/
|
|
21
|
+
getTransactions: ({ certified, ...rest }: GetIndexNgAccountTransactionsParams) => Promise<GetTransactions>;
|
|
22
|
+
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
export type { GetTransactions as IcrcGetTransactions, Transaction as IcrcTransaction, TransactionWithId as IcrcTransactionWithId, TxId as IcrcTxId, } from "../candid/icrc_index";
|
|
2
1
|
export type { BlockIndex as IcrcBlockIndex, Subaccount as IcrcSubaccount, Tokens as IcrcTokens, TransferArg as IcrcTransferArg, TransferError as IcrcTransferVariatError, Value as IcrcValue, } from "../candid/icrc_ledger";
|
|
3
2
|
export * from "./errors/index.errors";
|
|
4
3
|
export * from "./errors/ledger.errors";
|
|
4
|
+
export { IcrcIndexNgCanister } from "./index-ng.canister";
|
|
5
5
|
export { IcrcIndexCanister } from "./index.canister";
|
|
6
6
|
export { IcrcLedgerCanister } from "./ledger.canister";
|
|
7
|
-
export * from "./types/index.params";
|
|
7
|
+
export type * from "./types/index-ng.params";
|
|
8
|
+
export type * from "./types/index-ng.types";
|
|
9
|
+
export type * from "./types/index.params";
|
|
10
|
+
export type * from "./types/index.types";
|
|
8
11
|
export * from "./types/ledger.params";
|
|
9
12
|
export * from "./types/ledger.responses";
|
|
10
13
|
export * from "./utils/ledger.utils";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { QueryParams } from "@dfinity/utils";
|
|
2
|
+
import type { IcrcNgTxId } from "./index-ng.types";
|
|
3
|
+
import type { IcrcAccount } from "./ledger.responses";
|
|
4
|
+
export type GetIndexNgAccountTransactionsParams = {
|
|
5
|
+
max_results: bigint;
|
|
6
|
+
start?: IcrcNgTxId;
|
|
7
|
+
account: IcrcAccount;
|
|
8
|
+
} & QueryParams;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { GetTransactions as IcrcIndexNgGetTransactions, Transaction as IcrcIndexNgTransaction, TransactionWithId as IcrcIndexNgTransactionWithId, BlockIndex as IcrcNgTxId, } from "../../candid/icrc_index-ng";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { GetTransactions as IcrcGetTransactions, Transaction as IcrcTransaction, TransactionWithId as IcrcTransactionWithId, TxId as IcrcTxId, } from "../../candid/icrc_index";
|
package/package.json
CHANGED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{Canister as V,createServices as y}from"@dfinity/utils";var A=({IDL:t})=>{let r=t.Record({ledger_id:t.Principal}),c=t.Nat,e=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),n=t.Record({max_results:t.Nat,start:t.Opt(c),account:e}),a=t.Record({from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,spender:t.Opt(e)}),i=t.Record({to:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat}),p=t.Record({fee:t.Opt(t.Nat),from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,expected_allowance:t.Opt(t.Nat),expires_at:t.Opt(t.Nat64),spender:e}),d=t.Record({to:e,fee:t.Opt(t.Nat),from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,spender:t.Opt(e)}),m=t.Record({burn:t.Opt(a),kind:t.Text,mint:t.Opt(i),approve:t.Opt(p),timestamp:t.Nat64,transfer:t.Opt(d)}),u=t.Record({id:c,transaction:m}),O=t.Record({transactions:t.Vec(u),oldest_tx_id:t.Opt(c)}),N=t.Record({message:t.Text}),_=t.Variant({Ok:O,Err:N}),o=t.Vec(t.Nat8),l=t.Record({owner:t.Principal,start:t.Opt(o)});return t.Service({get_account_transactions:t.Func([n],[_],[]),ledger_id:t.Func([],[t.Principal],[]),list_subaccounts:t.Func([l],[t.Vec(o)],[])})};var T=({IDL:t})=>{let r=t.Record({ledger_id:t.Principal}),c=t.Nat,e=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),n=t.Record({max_results:t.Nat,start:t.Opt(c),account:e}),a=t.Record({from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,spender:t.Opt(e)}),i=t.Record({to:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat}),p=t.Record({fee:t.Opt(t.Nat),from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,expected_allowance:t.Opt(t.Nat),expires_at:t.Opt(t.Nat64),spender:e}),d=t.Record({to:e,fee:t.Opt(t.Nat),from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,spender:t.Opt(e)}),m=t.Record({burn:t.Opt(a),kind:t.Text,mint:t.Opt(i),approve:t.Opt(p),timestamp:t.Nat64,transfer:t.Opt(d)}),u=t.Record({id:c,transaction:m}),O=t.Record({transactions:t.Vec(u),oldest_tx_id:t.Opt(c)}),N=t.Record({message:t.Text}),_=t.Variant({Ok:O,Err:N}),o=t.Vec(t.Nat8),l=t.Record({owner:t.Principal,start:t.Opt(o)});return t.Service({get_account_transactions:t.Func([n],[_],[]),ledger_id:t.Func([],[t.Principal],["query"]),list_subaccounts:t.Func([l],[t.Vec(o)],["query"])})};import{toNullable as f}from"@dfinity/utils";var R=({owner:t,subaccount:r})=>({owner:t,subaccount:f(r)}),g=({account:t,max_results:r,start:c})=>({account:R(t),max_results:r,start:f(c)});var s=class extends Error{};var x=class t extends V{constructor(){super(...arguments);this.getTransactions=async c=>{let e=await this.caller({certified:!0}).get_account_transactions(g(c));if("Err"in e)throw new s(e.Err.message);return e.Ok}}static create(c){let{service:e,certifiedService:n,canisterId:a}=y({options:c,idlFactory:T,certifiedIdlFactory:A});return new t(a,e,n)}};export{s as a,x as b};
|
|
2
|
-
//# sourceMappingURL=chunk-MJQNXPUY.js.map
|