@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 CHANGED
@@ -121,6 +121,28 @@ Parameters:
121
121
 
122
122
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/utils/payment.utils.ts#L26)
123
123
 
124
+ ### :factory: IcrcCanister
125
+
126
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/canister.ts#L9)
127
+
128
+ #### Methods
129
+
130
+ - [balance](#gear-balance)
131
+
132
+ ##### :gear: balance
133
+
134
+ Returns the balance for a given account provided as owner and with optional subaccount.
135
+
136
+ | Method | Type |
137
+ | --------- | -------------------------------------------- |
138
+ | `balance` | `(params: BalanceParams) => Promise<bigint>` |
139
+
140
+ Parameters:
141
+
142
+ - `params`: The parameters to get the balance of an account.
143
+
144
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/canister.ts#L18)
145
+
124
146
  ### :factory: IcrcLedgerCanister
125
147
 
126
148
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L27)
@@ -283,6 +305,37 @@ Index Canister only holds the transactions ids in state, not the whole transacti
283
305
 
284
306
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index.canister.ts#L33)
285
307
 
308
+ ### :factory: IcrcIndexNgCanister
309
+
310
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index-ng.canister.ts#L14)
311
+
312
+ #### Methods
313
+
314
+ - [create](#gear-create)
315
+ - [getTransactions](#gear-gettransactions)
316
+
317
+ ##### :gear: create
318
+
319
+ | Method | Type |
320
+ | -------- | ----------------------------------------------------------------------- |
321
+ | `create` | `(options: IcrcLedgerCanisterOptions<_SERVICE>) => IcrcIndexNgCanister` |
322
+
323
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index-ng.canister.ts#L15)
324
+
325
+ ##### :gear: getTransactions
326
+
327
+ Get the transactions of an account.
328
+
329
+ | Method | Type |
330
+ | ----------------- | ------------------------------------------------------------------------------------------- |
331
+ | `getTransactions` | `({ certified, ...rest }: GetIndexNgAccountTransactionsParams) => Promise<GetTransactions>` |
332
+
333
+ Parameters:
334
+
335
+ - `params`: The parameters to get the transactions of an account.
336
+
337
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index-ng.canister.ts#L40)
338
+
286
339
  <!-- TSDOC_END -->
287
340
 
288
341
  ## Resources
@@ -0,0 +1,2 @@
1
+ import type { IDL } from "@dfinity/candid";
2
+ export const idlFactory: IDL.InterfaceFactory;
@@ -0,0 +1,127 @@
1
+ /* Do not edit. Compiled with ./scripts/compile-idl-js from packages/ledger-icrc/candid/icrc_index.did */
2
+ export const idlFactory = ({ IDL }) => {
3
+ const Value = IDL.Rec();
4
+ const UpgradeArg = IDL.Record({ 'ledger_id' : IDL.Opt(IDL.Principal) });
5
+ const InitArg = IDL.Record({ 'ledger_id' : IDL.Principal });
6
+ const IndexArg = IDL.Variant({ 'Upgrade' : UpgradeArg, 'Init' : InitArg });
7
+ const BlockIndex = IDL.Nat;
8
+ const SubAccount = IDL.Vec(IDL.Nat8);
9
+ const Account = IDL.Record({
10
+ 'owner' : IDL.Principal,
11
+ 'subaccount' : IDL.Opt(SubAccount),
12
+ });
13
+ const GetAccountTransactionsArgs = IDL.Record({
14
+ 'max_results' : IDL.Nat,
15
+ 'start' : IDL.Opt(BlockIndex),
16
+ 'account' : Account,
17
+ });
18
+ const Tokens = IDL.Nat;
19
+ const Burn = IDL.Record({
20
+ 'from' : Account,
21
+ 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
22
+ 'created_at_time' : IDL.Opt(IDL.Nat64),
23
+ 'amount' : IDL.Nat,
24
+ 'spender' : IDL.Opt(Account),
25
+ });
26
+ const Mint = IDL.Record({
27
+ 'to' : Account,
28
+ 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
29
+ 'created_at_time' : IDL.Opt(IDL.Nat64),
30
+ 'amount' : IDL.Nat,
31
+ });
32
+ const Approve = IDL.Record({
33
+ 'fee' : IDL.Opt(IDL.Nat),
34
+ 'from' : Account,
35
+ 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
36
+ 'created_at_time' : IDL.Opt(IDL.Nat64),
37
+ 'amount' : IDL.Nat,
38
+ 'expected_allowance' : IDL.Opt(IDL.Nat),
39
+ 'expires_at' : IDL.Opt(IDL.Nat64),
40
+ 'spender' : Account,
41
+ });
42
+ const Transfer = IDL.Record({
43
+ 'to' : Account,
44
+ 'fee' : IDL.Opt(IDL.Nat),
45
+ 'from' : Account,
46
+ 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
47
+ 'created_at_time' : IDL.Opt(IDL.Nat64),
48
+ 'amount' : IDL.Nat,
49
+ 'spender' : IDL.Opt(Account),
50
+ });
51
+ const Transaction = IDL.Record({
52
+ 'burn' : IDL.Opt(Burn),
53
+ 'kind' : IDL.Text,
54
+ 'mint' : IDL.Opt(Mint),
55
+ 'approve' : IDL.Opt(Approve),
56
+ 'timestamp' : IDL.Nat64,
57
+ 'transfer' : IDL.Opt(Transfer),
58
+ });
59
+ const TransactionWithId = IDL.Record({
60
+ 'id' : BlockIndex,
61
+ 'transaction' : Transaction,
62
+ });
63
+ const GetTransactions = IDL.Record({
64
+ 'balance' : Tokens,
65
+ 'transactions' : IDL.Vec(TransactionWithId),
66
+ 'oldest_tx_id' : IDL.Opt(BlockIndex),
67
+ });
68
+ const GetTransactionsErr = IDL.Record({ 'message' : IDL.Text });
69
+ const GetTransactionsResult = IDL.Variant({
70
+ 'Ok' : GetTransactions,
71
+ 'Err' : GetTransactionsErr,
72
+ });
73
+ const GetBlocksRequest = IDL.Record({
74
+ 'start' : IDL.Nat,
75
+ 'length' : IDL.Nat,
76
+ });
77
+ const Map = IDL.Vec(IDL.Tuple(IDL.Text, Value));
78
+ Value.fill(
79
+ IDL.Variant({
80
+ 'Int' : IDL.Int,
81
+ 'Map' : Map,
82
+ 'Nat' : IDL.Nat,
83
+ 'Nat64' : IDL.Nat64,
84
+ 'Blob' : IDL.Vec(IDL.Nat8),
85
+ 'Text' : IDL.Text,
86
+ 'Array' : IDL.Vec(Value),
87
+ })
88
+ );
89
+ const Block = Value;
90
+ const GetBlocksResponse = IDL.Record({
91
+ 'blocks' : IDL.Vec(Block),
92
+ 'chain_length' : IDL.Nat64,
93
+ });
94
+ const FeeCollectorRanges = IDL.Record({
95
+ 'ranges' : IDL.Vec(
96
+ IDL.Tuple(Account, IDL.Vec(IDL.Tuple(BlockIndex, BlockIndex)))
97
+ ),
98
+ });
99
+ const ListSubaccountsArgs = IDL.Record({
100
+ 'owner' : IDL.Principal,
101
+ 'start' : IDL.Opt(SubAccount),
102
+ });
103
+ const Status = IDL.Record({ 'num_blocks_synced' : BlockIndex });
104
+ return IDL.Service({
105
+ 'get_account_transactions' : IDL.Func(
106
+ [GetAccountTransactionsArgs],
107
+ [GetTransactionsResult],
108
+ [],
109
+ ),
110
+ 'get_blocks' : IDL.Func([GetBlocksRequest], [GetBlocksResponse], []),
111
+ 'get_fee_collectors_ranges' : IDL.Func([], [FeeCollectorRanges], []),
112
+ 'icrc1_balance_of' : IDL.Func([Account], [Tokens], []),
113
+ 'ledger_id' : IDL.Func([], [IDL.Principal], []),
114
+ 'list_subaccounts' : IDL.Func(
115
+ [ListSubaccountsArgs],
116
+ [IDL.Vec(SubAccount)],
117
+ [],
118
+ ),
119
+ 'status' : IDL.Func([], [Status], []),
120
+ });
121
+ };
122
+ export const init = ({ IDL }) => {
123
+ const UpgradeArg = IDL.Record({ 'ledger_id' : IDL.Opt(IDL.Principal) });
124
+ const InitArg = IDL.Record({ 'ledger_id' : IDL.Principal });
125
+ const IndexArg = IDL.Variant({ 'Upgrade' : UpgradeArg, 'Init' : InitArg });
126
+ return [IDL.Opt(IndexArg)];
127
+ };
@@ -0,0 +1,117 @@
1
+ import type { ActorMethod } from "@dfinity/agent";
2
+ import type { Principal } from "@dfinity/principal";
3
+
4
+ export interface Account {
5
+ owner: Principal;
6
+ subaccount: [] | [SubAccount];
7
+ }
8
+ export interface Approve {
9
+ fee: [] | [bigint];
10
+ from: Account;
11
+ memo: [] | [Uint8Array | number[]];
12
+ created_at_time: [] | [bigint];
13
+ amount: bigint;
14
+ expected_allowance: [] | [bigint];
15
+ expires_at: [] | [bigint];
16
+ spender: Account;
17
+ }
18
+ export type Block = Value;
19
+ export type BlockIndex = bigint;
20
+ export interface Burn {
21
+ from: Account;
22
+ memo: [] | [Uint8Array | number[]];
23
+ created_at_time: [] | [bigint];
24
+ amount: bigint;
25
+ spender: [] | [Account];
26
+ }
27
+ export interface FeeCollectorRanges {
28
+ ranges: Array<[Account, Array<[BlockIndex, BlockIndex]>]>;
29
+ }
30
+ export interface GetAccountTransactionsArgs {
31
+ max_results: bigint;
32
+ start: [] | [BlockIndex];
33
+ account: Account;
34
+ }
35
+ export interface GetBlocksRequest {
36
+ start: bigint;
37
+ length: bigint;
38
+ }
39
+ export interface GetBlocksResponse {
40
+ blocks: Array<Block>;
41
+ chain_length: bigint;
42
+ }
43
+ export interface GetTransactions {
44
+ balance: Tokens;
45
+ transactions: Array<TransactionWithId>;
46
+ oldest_tx_id: [] | [BlockIndex];
47
+ }
48
+ export interface GetTransactionsErr {
49
+ message: string;
50
+ }
51
+ export type GetTransactionsResult =
52
+ | { Ok: GetTransactions }
53
+ | { Err: GetTransactionsErr };
54
+ export type IndexArg = { Upgrade: UpgradeArg } | { Init: InitArg };
55
+ export interface InitArg {
56
+ ledger_id: Principal;
57
+ }
58
+ export interface ListSubaccountsArgs {
59
+ owner: Principal;
60
+ start: [] | [SubAccount];
61
+ }
62
+ export type Map = Array<[string, Value]>;
63
+ export interface Mint {
64
+ to: Account;
65
+ memo: [] | [Uint8Array | number[]];
66
+ created_at_time: [] | [bigint];
67
+ amount: bigint;
68
+ }
69
+ export interface Status {
70
+ num_blocks_synced: BlockIndex;
71
+ }
72
+ export type SubAccount = Uint8Array | number[];
73
+ export type Tokens = bigint;
74
+ export interface Transaction {
75
+ burn: [] | [Burn];
76
+ kind: string;
77
+ mint: [] | [Mint];
78
+ approve: [] | [Approve];
79
+ timestamp: bigint;
80
+ transfer: [] | [Transfer];
81
+ }
82
+ export interface TransactionWithId {
83
+ id: BlockIndex;
84
+ transaction: Transaction;
85
+ }
86
+ export interface Transfer {
87
+ to: Account;
88
+ fee: [] | [bigint];
89
+ from: Account;
90
+ memo: [] | [Uint8Array | number[]];
91
+ created_at_time: [] | [bigint];
92
+ amount: bigint;
93
+ spender: [] | [Account];
94
+ }
95
+ export interface UpgradeArg {
96
+ ledger_id: [] | [Principal];
97
+ }
98
+ export type Value =
99
+ | { Int: bigint }
100
+ | { Map: Map }
101
+ | { Nat: bigint }
102
+ | { Nat64: bigint }
103
+ | { Blob: Uint8Array | number[] }
104
+ | { Text: string }
105
+ | { Array: Array<Value> };
106
+ export interface _SERVICE {
107
+ get_account_transactions: ActorMethod<
108
+ [GetAccountTransactionsArgs],
109
+ GetTransactionsResult
110
+ >;
111
+ get_blocks: ActorMethod<[GetBlocksRequest], GetBlocksResponse>;
112
+ get_fee_collectors_ranges: ActorMethod<[], FeeCollectorRanges>;
113
+ icrc1_balance_of: ActorMethod<[Account], Tokens>;
114
+ ledger_id: ActorMethod<[], Principal>;
115
+ list_subaccounts: ActorMethod<[ListSubaccountsArgs], Array<SubAccount>>;
116
+ status: ActorMethod<[], Status>;
117
+ }
@@ -0,0 +1,144 @@
1
+ // Generated from IC repo commit f3198ee10 (2024-01-30) 'rs/rosetta-api/icrc1/index-ng/index-ng.did' by import-candid
2
+ type Tokens = nat;
3
+
4
+ type InitArg = record {
5
+ ledger_id: principal;
6
+ };
7
+
8
+ type UpgradeArg = record {
9
+ ledger_id: opt principal;
10
+ };
11
+
12
+ type IndexArg = variant {
13
+ Init: InitArg;
14
+ Upgrade: UpgradeArg;
15
+ };
16
+
17
+ type GetBlocksRequest = record {
18
+ start : nat;
19
+ length : nat;
20
+ };
21
+
22
+ type Value = variant {
23
+ Blob : blob;
24
+ Text : text;
25
+ Nat : nat;
26
+ Nat64: nat64;
27
+ Int : int;
28
+ Array : vec Value;
29
+ Map : Map;
30
+ };
31
+
32
+ type Map = vec record { text; Value };
33
+
34
+ type Block = Value;
35
+
36
+ type GetBlocksResponse = record {
37
+ chain_length: nat64;
38
+ blocks: vec Block;
39
+ };
40
+
41
+ type BlockIndex = nat;
42
+
43
+ type SubAccount = blob;
44
+
45
+ type Account = record { owner : principal; subaccount : opt SubAccount };
46
+
47
+ type Transaction = record {
48
+ burn : opt Burn;
49
+ kind : text;
50
+ mint : opt Mint;
51
+ approve : opt Approve;
52
+ timestamp : nat64;
53
+ transfer : opt Transfer;
54
+ };
55
+
56
+ type Approve = record {
57
+ fee : opt nat;
58
+ from : Account;
59
+ memo : opt vec nat8;
60
+ created_at_time : opt nat64;
61
+ amount : nat;
62
+ expected_allowance : opt nat;
63
+ expires_at : opt nat64;
64
+ spender : Account;
65
+ };
66
+
67
+ type Burn = record {
68
+ from : Account;
69
+ memo : opt vec nat8;
70
+ created_at_time : opt nat64;
71
+ amount : nat;
72
+ spender : opt Account;
73
+ };
74
+
75
+ type Mint = record {
76
+ to : Account;
77
+ memo : opt vec nat8;
78
+ created_at_time : opt nat64;
79
+ amount : nat;
80
+ };
81
+
82
+ type Transfer = record {
83
+ to : Account;
84
+ fee : opt nat;
85
+ from : Account;
86
+ memo : opt vec nat8;
87
+ created_at_time : opt nat64;
88
+ amount : nat;
89
+ spender : opt Account;
90
+ };
91
+
92
+ type GetAccountTransactionsArgs = record {
93
+ account : Account;
94
+ // The txid of the last transaction seen by the client.
95
+ // If None then the results will start from the most recent
96
+ // txid.
97
+ start : opt BlockIndex;
98
+ // Maximum number of transactions to fetch.
99
+ max_results : nat;
100
+ };
101
+
102
+ type TransactionWithId = record {
103
+ id : BlockIndex;
104
+ transaction : Transaction;
105
+ };
106
+
107
+ type GetTransactions = record {
108
+ balance : Tokens;
109
+ transactions : vec TransactionWithId;
110
+ // The txid of the oldest transaction the account has
111
+ oldest_tx_id : opt BlockIndex;
112
+ };
113
+
114
+ type GetTransactionsErr = record {
115
+ message : text;
116
+ };
117
+
118
+ type GetTransactionsResult = variant {
119
+ Ok : GetTransactions;
120
+ Err : GetTransactionsErr;
121
+ };
122
+
123
+ type ListSubaccountsArgs = record {
124
+ owner: principal;
125
+ start: opt SubAccount;
126
+ };
127
+
128
+ type Status = record {
129
+ num_blocks_synced : BlockIndex;
130
+ };
131
+
132
+ type FeeCollectorRanges = record {
133
+ ranges : vec record { Account; vec record { BlockIndex; BlockIndex } };
134
+ }
135
+
136
+ service : (index_arg: opt IndexArg) -> {
137
+ get_account_transactions : (GetAccountTransactionsArgs) -> (GetTransactionsResult) query;
138
+ get_blocks : (GetBlocksRequest) -> (GetBlocksResponse) query;
139
+ get_fee_collectors_ranges : () -> (FeeCollectorRanges) query;
140
+ icrc1_balance_of : (Account) -> (Tokens) query;
141
+ ledger_id : () -> (principal) query;
142
+ list_subaccounts : (ListSubaccountsArgs) -> (vec SubAccount) query;
143
+ status : () -> (Status) query;
144
+ }
@@ -0,0 +1,2 @@
1
+ import type { IDL } from "@dfinity/candid";
2
+ export const idlFactory: IDL.InterfaceFactory;
@@ -0,0 +1,127 @@
1
+ /* Do not edit. Compiled with ./scripts/compile-idl-js from packages/ledger-icrc/candid/icrc_index.did */
2
+ export const idlFactory = ({ IDL }) => {
3
+ const Value = IDL.Rec();
4
+ const UpgradeArg = IDL.Record({ 'ledger_id' : IDL.Opt(IDL.Principal) });
5
+ const InitArg = IDL.Record({ 'ledger_id' : IDL.Principal });
6
+ const IndexArg = IDL.Variant({ 'Upgrade' : UpgradeArg, 'Init' : InitArg });
7
+ const BlockIndex = IDL.Nat;
8
+ const SubAccount = IDL.Vec(IDL.Nat8);
9
+ const Account = IDL.Record({
10
+ 'owner' : IDL.Principal,
11
+ 'subaccount' : IDL.Opt(SubAccount),
12
+ });
13
+ const GetAccountTransactionsArgs = IDL.Record({
14
+ 'max_results' : IDL.Nat,
15
+ 'start' : IDL.Opt(BlockIndex),
16
+ 'account' : Account,
17
+ });
18
+ const Tokens = IDL.Nat;
19
+ const Burn = IDL.Record({
20
+ 'from' : Account,
21
+ 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
22
+ 'created_at_time' : IDL.Opt(IDL.Nat64),
23
+ 'amount' : IDL.Nat,
24
+ 'spender' : IDL.Opt(Account),
25
+ });
26
+ const Mint = IDL.Record({
27
+ 'to' : Account,
28
+ 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
29
+ 'created_at_time' : IDL.Opt(IDL.Nat64),
30
+ 'amount' : IDL.Nat,
31
+ });
32
+ const Approve = IDL.Record({
33
+ 'fee' : IDL.Opt(IDL.Nat),
34
+ 'from' : Account,
35
+ 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
36
+ 'created_at_time' : IDL.Opt(IDL.Nat64),
37
+ 'amount' : IDL.Nat,
38
+ 'expected_allowance' : IDL.Opt(IDL.Nat),
39
+ 'expires_at' : IDL.Opt(IDL.Nat64),
40
+ 'spender' : Account,
41
+ });
42
+ const Transfer = IDL.Record({
43
+ 'to' : Account,
44
+ 'fee' : IDL.Opt(IDL.Nat),
45
+ 'from' : Account,
46
+ 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
47
+ 'created_at_time' : IDL.Opt(IDL.Nat64),
48
+ 'amount' : IDL.Nat,
49
+ 'spender' : IDL.Opt(Account),
50
+ });
51
+ const Transaction = IDL.Record({
52
+ 'burn' : IDL.Opt(Burn),
53
+ 'kind' : IDL.Text,
54
+ 'mint' : IDL.Opt(Mint),
55
+ 'approve' : IDL.Opt(Approve),
56
+ 'timestamp' : IDL.Nat64,
57
+ 'transfer' : IDL.Opt(Transfer),
58
+ });
59
+ const TransactionWithId = IDL.Record({
60
+ 'id' : BlockIndex,
61
+ 'transaction' : Transaction,
62
+ });
63
+ const GetTransactions = IDL.Record({
64
+ 'balance' : Tokens,
65
+ 'transactions' : IDL.Vec(TransactionWithId),
66
+ 'oldest_tx_id' : IDL.Opt(BlockIndex),
67
+ });
68
+ const GetTransactionsErr = IDL.Record({ 'message' : IDL.Text });
69
+ const GetTransactionsResult = IDL.Variant({
70
+ 'Ok' : GetTransactions,
71
+ 'Err' : GetTransactionsErr,
72
+ });
73
+ const GetBlocksRequest = IDL.Record({
74
+ 'start' : IDL.Nat,
75
+ 'length' : IDL.Nat,
76
+ });
77
+ const Map = IDL.Vec(IDL.Tuple(IDL.Text, Value));
78
+ Value.fill(
79
+ IDL.Variant({
80
+ 'Int' : IDL.Int,
81
+ 'Map' : Map,
82
+ 'Nat' : IDL.Nat,
83
+ 'Nat64' : IDL.Nat64,
84
+ 'Blob' : IDL.Vec(IDL.Nat8),
85
+ 'Text' : IDL.Text,
86
+ 'Array' : IDL.Vec(Value),
87
+ })
88
+ );
89
+ const Block = Value;
90
+ const GetBlocksResponse = IDL.Record({
91
+ 'blocks' : IDL.Vec(Block),
92
+ 'chain_length' : IDL.Nat64,
93
+ });
94
+ const FeeCollectorRanges = IDL.Record({
95
+ 'ranges' : IDL.Vec(
96
+ IDL.Tuple(Account, IDL.Vec(IDL.Tuple(BlockIndex, BlockIndex)))
97
+ ),
98
+ });
99
+ const ListSubaccountsArgs = IDL.Record({
100
+ 'owner' : IDL.Principal,
101
+ 'start' : IDL.Opt(SubAccount),
102
+ });
103
+ const Status = IDL.Record({ 'num_blocks_synced' : BlockIndex });
104
+ return IDL.Service({
105
+ 'get_account_transactions' : IDL.Func(
106
+ [GetAccountTransactionsArgs],
107
+ [GetTransactionsResult],
108
+ ['query'],
109
+ ),
110
+ 'get_blocks' : IDL.Func([GetBlocksRequest], [GetBlocksResponse], ['query']),
111
+ 'get_fee_collectors_ranges' : IDL.Func([], [FeeCollectorRanges], ['query']),
112
+ 'icrc1_balance_of' : IDL.Func([Account], [Tokens], ['query']),
113
+ 'ledger_id' : IDL.Func([], [IDL.Principal], ['query']),
114
+ 'list_subaccounts' : IDL.Func(
115
+ [ListSubaccountsArgs],
116
+ [IDL.Vec(SubAccount)],
117
+ ['query'],
118
+ ),
119
+ 'status' : IDL.Func([], [Status], ['query']),
120
+ });
121
+ };
122
+ export const init = ({ IDL }) => {
123
+ const UpgradeArg = IDL.Record({ 'ledger_id' : IDL.Opt(IDL.Principal) });
124
+ const InitArg = IDL.Record({ 'ledger_id' : IDL.Principal });
125
+ const IndexArg = IDL.Variant({ 'Upgrade' : UpgradeArg, 'Init' : InitArg });
126
+ return [IDL.Opt(IndexArg)];
127
+ };
@@ -1,2 +1,2 @@
1
- "use strict";var L=Object.defineProperty;var mt=Object.getOwnPropertyDescriptor;var dt=Object.getOwnPropertyNames;var ut=Object.prototype.hasOwnProperty;var _t=(t,a)=>{for(var c in a)L(t,c,{get:a[c],enumerable:!0})},ft=(t,a,c,r)=>{if(a&&typeof a=="object"||typeof a=="function")for(let e of dt(a))!ut.call(t,e)&&e!==c&&L(t,e,{get:()=>a[e],enumerable:!(r=mt(a,e))||r.enumerable});return t};var Nt=t=>ft(L({},"__esModule",{value:!0}),t);var yt={};_t(yt,{IcrcIndexCanister:()=>F,IcrcLedgerCanister:()=>v,IcrcMetadataResponseEntries:()=>pt,IcrcTransferError:()=>x,IndexError:()=>b,decodeIcrcAccount:()=>xt,decodePayment:()=>Rt,encodeIcrcAccount:()=>Tt});module.exports=Nt(yt);var b=class extends Error{};var x=class extends Error{constructor({msg:a,errorType:c}){super(a),this.errorType=c}};var h=require("@dfinity/utils");var et=({IDL:t})=>{let a=t.Record({ledger_id:t.Principal}),c=t.Nat,r=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),e=t.Record({max_results:t.Nat,start:t.Opt(c),account:r}),i=t.Record({from:r,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,spender:t.Opt(r)}),p=t.Record({to:r,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat}),_=t.Record({fee:t.Opt(t.Nat),from:r,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:r}),f=t.Record({to:r,fee:t.Opt(t.Nat),from:r,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,spender:t.Opt(r)}),y=t.Record({burn:t.Opt(i),kind:t.Text,mint:t.Opt(p),approve:t.Opt(_),timestamp:t.Nat64,transfer:t.Opt(f)}),s=t.Record({id:c,transaction:y}),N=t.Record({transactions:t.Vec(s),oldest_tx_id:t.Opt(c)}),u=t.Record({message:t.Text}),O=t.Variant({Ok:N,Err:u}),d=t.Vec(t.Nat8),g=t.Record({owner:t.Principal,start:t.Opt(d)});return t.Service({get_account_transactions:t.Func([e],[O],[]),ledger_id:t.Func([],[t.Principal],[]),list_subaccounts:t.Func([g],[t.Vec(d)],[])})};var rt=({IDL:t})=>{let a=t.Record({ledger_id:t.Principal}),c=t.Nat,r=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),e=t.Record({max_results:t.Nat,start:t.Opt(c),account:r}),i=t.Record({from:r,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,spender:t.Opt(r)}),p=t.Record({to:r,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat}),_=t.Record({fee:t.Opt(t.Nat),from:r,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:r}),f=t.Record({to:r,fee:t.Opt(t.Nat),from:r,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,spender:t.Opt(r)}),y=t.Record({burn:t.Opt(i),kind:t.Text,mint:t.Opt(p),approve:t.Opt(_),timestamp:t.Nat64,transfer:t.Opt(f)}),s=t.Record({id:c,transaction:y}),N=t.Record({transactions:t.Vec(s),oldest_tx_id:t.Opt(c)}),u=t.Record({message:t.Text}),O=t.Variant({Ok:N,Err:u}),d=t.Vec(t.Nat8),g=t.Record({owner:t.Principal,start:t.Opt(d)});return t.Service({get_account_transactions:t.Func([e],[O],[]),ledger_id:t.Func([],[t.Principal],["query"]),list_subaccounts:t.Func([g],[t.Vec(d)],["query"])})};var D=require("@dfinity/utils"),Ot=({owner:t,subaccount:a})=>({owner:t,subaccount:(0,D.toNullable)(a)}),ct=({account:t,max_results:a,start:c})=>({account:Ot(t),max_results:a,start:(0,D.toNullable)(c)});var F=class t extends h.Canister{constructor(){super(...arguments);this.getTransactions=async c=>{let r=await this.caller({certified:!0}).get_account_transactions(ct(c));if("Err"in r)throw new b(r.Err.message);return r.Ok}}static create(c){let{service:r,certifiedService:e,canisterId:i}=(0,h.createServices)({options:c,idlFactory:rt,certifiedIdlFactory:et});return new t(i,r,e)}};var R=require("@dfinity/utils");var at=({IDL:t})=>{let a=t.Rec(),c=t.Variant({Int:t.Int,Nat:t.Nat,Blob:t.Vec(t.Nat8),Text:t.Text}),r=t.Vec(t.Nat8),e=t.Record({owner:t.Principal,subaccount:t.Opt(r)}),i=t.Variant({SetTo:e,Unset:t.Null}),p=t.Record({icrc2:t.Bool}),_=t.Record({token_symbol:t.Opt(t.Text),transfer_fee:t.Opt(t.Nat),metadata:t.Opt(t.Vec(t.Tuple(t.Text,c))),maximum_number_of_accounts:t.Opt(t.Nat64),accounts_overflow_trim_quantity:t.Opt(t.Nat64),change_fee_collector:t.Opt(i),max_memo_length:t.Opt(t.Nat16),token_name:t.Opt(t.Text),feature_flags:t.Opt(p)}),f=t.Record({decimals:t.Opt(t.Nat8),token_symbol:t.Text,transfer_fee:t.Nat,metadata:t.Vec(t.Tuple(t.Text,c)),minting_account:e,initial_balances:t.Vec(t.Tuple(e,t.Nat)),maximum_number_of_accounts:t.Opt(t.Nat64),accounts_overflow_trim_quantity:t.Opt(t.Nat64),fee_collector_account:t.Opt(e),archive_options:t.Record({num_blocks_to_archive:t.Nat64,max_transactions_per_response:t.Opt(t.Nat64),trigger_threshold:t.Nat64,max_message_size_bytes:t.Opt(t.Nat64),cycles_for_archive_creation:t.Opt(t.Nat64),node_max_memory_size_bytes:t.Opt(t.Nat64),controller_id:t.Principal}),max_memo_length:t.Opt(t.Nat16),token_name:t.Text,feature_flags:t.Opt(p)}),y=t.Variant({Upgrade:t.Opt(_),Init:f}),s=t.Nat,N=t.Record({block_range_end:s,canister_id:t.Principal,block_range_start:s}),u=t.Record({start:s,length:t.Nat}),O=t.Vec(t.Tuple(t.Text,a));a.fill(t.Variant({Int:t.Int,Map:O,Nat:t.Nat,Nat64:t.Nat64,Blob:t.Vec(t.Nat8),Text:t.Text,Array:t.Vec(a)}));let d=a,g=t.Record({blocks:t.Vec(d)}),w=t.Func([u],[g],[]),P=t.Record({certificate:t.Opt(t.Vec(t.Nat8)),first_index:s,blocks:t.Vec(d),chain_length:t.Nat64,archived_blocks:t.Vec(t.Record({callback:w,start:s,length:t.Nat}))}),B=t.Record({certificate:t.Opt(t.Vec(t.Nat8)),hash_tree:t.Vec(t.Nat8)}),T=t.Nat,A=t.Record({start:T,length:t.Nat}),o=t.Nat64,E=t.Record({from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(o),amount:t.Nat,spender:t.Opt(e)}),S=t.Record({to:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(o),amount:t.Nat}),G=t.Record({fee:t.Opt(t.Nat),from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(o),amount:t.Nat,expected_allowance:t.Opt(t.Nat),expires_at:t.Opt(o),spender:e}),C=t.Record({to:e,fee:t.Opt(t.Nat),from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(o),amount:t.Nat,spender:t.Opt(e)}),V=t.Record({burn:t.Opt(E),kind:t.Text,mint:t.Opt(S),approve:t.Opt(G),timestamp:o,transfer:t.Opt(C)}),q=t.Record({transactions:t.Vec(V)}),U=t.Func([A],[q],[]),M=t.Record({first_index:T,log_length:t.Nat,transactions:t.Vec(V),archived_transactions:t.Vec(t.Record({callback:U,start:T,length:t.Nat}))}),n=t.Nat,z=t.Record({url:t.Text,name:t.Text}),Q=t.Record({to:e,fee:t.Opt(n),memo:t.Opt(t.Vec(t.Nat8)),from_subaccount:t.Opt(r),created_at_time:t.Opt(o),amount:n}),H=t.Variant({GenericError:t.Record({message:t.Text,error_code:t.Nat}),TemporarilyUnavailable:t.Null,BadBurn:t.Record({min_burn_amount:n}),Duplicate:t.Record({duplicate_of:s}),BadFee:t.Record({expected_fee:n}),CreatedInFuture:t.Record({ledger_time:o}),TooOld:t.Null,InsufficientFunds:t.Record({balance:n})}),W=t.Variant({Ok:s,Err:H}),Z=t.Record({account:e,spender:e}),$=t.Record({allowance:t.Nat,expires_at:t.Opt(o)}),X=t.Record({fee:t.Opt(t.Nat),memo:t.Opt(t.Vec(t.Nat8)),from_subaccount:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(o),amount:t.Nat,expected_allowance:t.Opt(t.Nat),expires_at:t.Opt(o),spender:e}),j=t.Variant({GenericError:t.Record({message:t.Text,error_code:t.Nat}),TemporarilyUnavailable:t.Null,Duplicate:t.Record({duplicate_of:s}),BadFee:t.Record({expected_fee:t.Nat}),AllowanceChanged:t.Record({current_allowance:t.Nat}),CreatedInFuture:t.Record({ledger_time:o}),TooOld:t.Null,Expired:t.Record({ledger_time:o}),InsufficientFunds:t.Record({balance:t.Nat})}),Y=t.Variant({Ok:s,Err:j}),J=t.Record({to:e,fee:t.Opt(n),spender_subaccount:t.Opt(r),from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(o),amount:n}),K=t.Variant({GenericError:t.Record({message:t.Text,error_code:t.Nat}),TemporarilyUnavailable:t.Null,InsufficientAllowance:t.Record({allowance:n}),BadBurn:t.Record({min_burn_amount:n}),Duplicate:t.Record({duplicate_of:s}),BadFee:t.Record({expected_fee:n}),CreatedInFuture:t.Record({ledger_time:o}),TooOld:t.Null,InsufficientFunds:t.Record({balance:n})}),I=t.Variant({Ok:s,Err:K});return t.Service({archives:t.Func([],[t.Vec(N)],[]),get_blocks:t.Func([u],[P],[]),get_data_certificate:t.Func([],[B],[]),get_transactions:t.Func([A],[M],[]),icrc1_balance_of:t.Func([e],[n],[]),icrc1_decimals:t.Func([],[t.Nat8],[]),icrc1_fee:t.Func([],[n],[]),icrc1_metadata:t.Func([],[t.Vec(t.Tuple(t.Text,c))],[]),icrc1_minting_account:t.Func([],[t.Opt(e)],[]),icrc1_name:t.Func([],[t.Text],[]),icrc1_supported_standards:t.Func([],[t.Vec(z)],[]),icrc1_symbol:t.Func([],[t.Text],[]),icrc1_total_supply:t.Func([],[n],[]),icrc1_transfer:t.Func([Q],[W],[]),icrc2_allowance:t.Func([Z],[$],[]),icrc2_approve:t.Func([X],[Y],[]),icrc2_transfer_from:t.Func([J],[I],[])})};var ot=({IDL:t})=>{let a=t.Rec(),c=t.Variant({Int:t.Int,Nat:t.Nat,Blob:t.Vec(t.Nat8),Text:t.Text}),r=t.Vec(t.Nat8),e=t.Record({owner:t.Principal,subaccount:t.Opt(r)}),i=t.Variant({SetTo:e,Unset:t.Null}),p=t.Record({icrc2:t.Bool}),_=t.Record({token_symbol:t.Opt(t.Text),transfer_fee:t.Opt(t.Nat),metadata:t.Opt(t.Vec(t.Tuple(t.Text,c))),maximum_number_of_accounts:t.Opt(t.Nat64),accounts_overflow_trim_quantity:t.Opt(t.Nat64),change_fee_collector:t.Opt(i),max_memo_length:t.Opt(t.Nat16),token_name:t.Opt(t.Text),feature_flags:t.Opt(p)}),f=t.Record({decimals:t.Opt(t.Nat8),token_symbol:t.Text,transfer_fee:t.Nat,metadata:t.Vec(t.Tuple(t.Text,c)),minting_account:e,initial_balances:t.Vec(t.Tuple(e,t.Nat)),maximum_number_of_accounts:t.Opt(t.Nat64),accounts_overflow_trim_quantity:t.Opt(t.Nat64),fee_collector_account:t.Opt(e),archive_options:t.Record({num_blocks_to_archive:t.Nat64,max_transactions_per_response:t.Opt(t.Nat64),trigger_threshold:t.Nat64,max_message_size_bytes:t.Opt(t.Nat64),cycles_for_archive_creation:t.Opt(t.Nat64),node_max_memory_size_bytes:t.Opt(t.Nat64),controller_id:t.Principal}),max_memo_length:t.Opt(t.Nat16),token_name:t.Text,feature_flags:t.Opt(p)}),y=t.Variant({Upgrade:t.Opt(_),Init:f}),s=t.Nat,N=t.Record({block_range_end:s,canister_id:t.Principal,block_range_start:s}),u=t.Record({start:s,length:t.Nat}),O=t.Vec(t.Tuple(t.Text,a));a.fill(t.Variant({Int:t.Int,Map:O,Nat:t.Nat,Nat64:t.Nat64,Blob:t.Vec(t.Nat8),Text:t.Text,Array:t.Vec(a)}));let d=a,g=t.Record({blocks:t.Vec(d)}),w=t.Func([u],[g],["query"]),P=t.Record({certificate:t.Opt(t.Vec(t.Nat8)),first_index:s,blocks:t.Vec(d),chain_length:t.Nat64,archived_blocks:t.Vec(t.Record({callback:w,start:s,length:t.Nat}))}),B=t.Record({certificate:t.Opt(t.Vec(t.Nat8)),hash_tree:t.Vec(t.Nat8)}),T=t.Nat,A=t.Record({start:T,length:t.Nat}),o=t.Nat64,E=t.Record({from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(o),amount:t.Nat,spender:t.Opt(e)}),S=t.Record({to:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(o),amount:t.Nat}),G=t.Record({fee:t.Opt(t.Nat),from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(o),amount:t.Nat,expected_allowance:t.Opt(t.Nat),expires_at:t.Opt(o),spender:e}),C=t.Record({to:e,fee:t.Opt(t.Nat),from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(o),amount:t.Nat,spender:t.Opt(e)}),V=t.Record({burn:t.Opt(E),kind:t.Text,mint:t.Opt(S),approve:t.Opt(G),timestamp:o,transfer:t.Opt(C)}),q=t.Record({transactions:t.Vec(V)}),U=t.Func([A],[q],["query"]),M=t.Record({first_index:T,log_length:t.Nat,transactions:t.Vec(V),archived_transactions:t.Vec(t.Record({callback:U,start:T,length:t.Nat}))}),n=t.Nat,z=t.Record({url:t.Text,name:t.Text}),Q=t.Record({to:e,fee:t.Opt(n),memo:t.Opt(t.Vec(t.Nat8)),from_subaccount:t.Opt(r),created_at_time:t.Opt(o),amount:n}),H=t.Variant({GenericError:t.Record({message:t.Text,error_code:t.Nat}),TemporarilyUnavailable:t.Null,BadBurn:t.Record({min_burn_amount:n}),Duplicate:t.Record({duplicate_of:s}),BadFee:t.Record({expected_fee:n}),CreatedInFuture:t.Record({ledger_time:o}),TooOld:t.Null,InsufficientFunds:t.Record({balance:n})}),W=t.Variant({Ok:s,Err:H}),Z=t.Record({account:e,spender:e}),$=t.Record({allowance:t.Nat,expires_at:t.Opt(o)}),X=t.Record({fee:t.Opt(t.Nat),memo:t.Opt(t.Vec(t.Nat8)),from_subaccount:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(o),amount:t.Nat,expected_allowance:t.Opt(t.Nat),expires_at:t.Opt(o),spender:e}),j=t.Variant({GenericError:t.Record({message:t.Text,error_code:t.Nat}),TemporarilyUnavailable:t.Null,Duplicate:t.Record({duplicate_of:s}),BadFee:t.Record({expected_fee:t.Nat}),AllowanceChanged:t.Record({current_allowance:t.Nat}),CreatedInFuture:t.Record({ledger_time:o}),TooOld:t.Null,Expired:t.Record({ledger_time:o}),InsufficientFunds:t.Record({balance:t.Nat})}),Y=t.Variant({Ok:s,Err:j}),J=t.Record({to:e,fee:t.Opt(n),spender_subaccount:t.Opt(r),from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(o),amount:n}),K=t.Variant({GenericError:t.Record({message:t.Text,error_code:t.Nat}),TemporarilyUnavailable:t.Null,InsufficientAllowance:t.Record({allowance:n}),BadBurn:t.Record({min_burn_amount:n}),Duplicate:t.Record({duplicate_of:s}),BadFee:t.Record({expected_fee:n}),CreatedInFuture:t.Record({ledger_time:o}),TooOld:t.Null,InsufficientFunds:t.Record({balance:n})}),I=t.Variant({Ok:s,Err:K});return t.Service({archives:t.Func([],[t.Vec(N)],["query"]),get_blocks:t.Func([u],[P],["query"]),get_data_certificate:t.Func([],[B],["query"]),get_transactions:t.Func([A],[M],["query"]),icrc1_balance_of:t.Func([e],[n],["query"]),icrc1_decimals:t.Func([],[t.Nat8],["query"]),icrc1_fee:t.Func([],[n],["query"]),icrc1_metadata:t.Func([],[t.Vec(t.Tuple(t.Text,c))],["query"]),icrc1_minting_account:t.Func([],[t.Opt(e)],["query"]),icrc1_name:t.Func([],[t.Text],["query"]),icrc1_supported_standards:t.Func([],[t.Vec(z)],["query"]),icrc1_symbol:t.Func([],[t.Text],["query"]),icrc1_total_supply:t.Func([],[n],["query"]),icrc1_transfer:t.Func([Q],[W],[]),icrc2_allowance:t.Func([Z],[$],["query"]),icrc2_approve:t.Func([X],[Y],[]),icrc2_transfer_from:t.Func([J],[I],[])})};var l=require("@dfinity/utils"),nt=({from_subaccount:t,fee:a,created_at_time:c,memo:r,...e})=>({...e,fee:(0,l.toNullable)(a),memo:(0,l.toNullable)(r),from_subaccount:(0,l.toNullable)(t),created_at_time:(0,l.toNullable)(c)}),st=({spender_subaccount:t,fee:a,created_at_time:c,memo:r,...e})=>({...e,fee:(0,l.toNullable)(a),memo:(0,l.toNullable)(r),spender_subaccount:(0,l.toNullable)(t),created_at_time:(0,l.toNullable)(c)}),it=({fee:t,created_at_time:a,memo:c,from_subaccount:r,expected_allowance:e,expires_at:i,...p})=>({...p,fee:(0,l.toNullable)(t),memo:(0,l.toNullable)(c),from_subaccount:(0,l.toNullable)(r),created_at_time:(0,l.toNullable)(a),expected_allowance:(0,l.toNullable)(e),expires_at:(0,l.toNullable)(i)});var v=class t extends R.Canister{constructor(){super(...arguments);this.metadata=c=>this.caller(c).icrc1_metadata();this.transactionFee=c=>this.caller(c).icrc1_fee();this.balance=c=>this.caller({certified:c.certified}).icrc1_balance_of({owner:c.owner,subaccount:(0,R.toNullable)(c.subaccount)});this.transfer=async c=>{let r=await this.caller({certified:!0}).icrc1_transfer(nt(c));if("Err"in r)throw new x({errorType:r.Err,msg:"Failed to transfer"});return r.Ok};this.totalTokensSupply=c=>this.caller(c).icrc1_total_supply();this.transferFrom=async c=>{let r=await this.caller({certified:!0}).icrc2_transfer_from(st(c));if("Err"in r)throw new x({errorType:r.Err,msg:"Failed to transfer from"});return r.Ok};this.approve=async c=>{let r=await this.caller({certified:!0}).icrc2_approve(it(c));if("Err"in r)throw new x({errorType:r.Err,msg:"Failed to entitle the spender to transfer the amount"});return r.Ok};this.allowance=async c=>{let{certified:r,...e}=c;return this.caller({certified:r}).icrc2_allowance({...e})}}static create(c){let{service:r,certifiedService:e,canisterId:i}=(0,R.createServices)({options:c,idlFactory:ot,certifiedIdlFactory:at});return new t(i,r,e)}};var pt=(i=>(i.SYMBOL="icrc1:symbol",i.NAME="icrc1:name",i.DECIMALS="icrc1:decimals",i.FEE="icrc1:fee",i.LOGO="icrc1:logo",i))(pt||{});var tt=require("@dfinity/principal"),m=require("@dfinity/utils"),gt=64,Tt=({owner:t,subaccount:a})=>{if((0,m.isNullish)(a))return t.toText();let r=(e=>e.replace(/^0+/,""))((0,m.uint8ArrayToHexString)(Uint8Array.from(a)));return r.length===0?t.toText():`${t.toText()}-${lt({owner:t,subaccount:a})}.${r}`},lt=({owner:t,subaccount:a})=>{let c=(0,m.bigEndianCrc32)(Uint8Array.from([...t.toUint8Array(),...a]));return(0,m.encodeBase32)(c)},xt=t=>{let[a,c]=t.split(".");if(!(0,m.notEmptyString)(a))throw new Error("Invalid account. No string provided.");if((0,m.isNullish)(c))return{owner:tt.Principal.fromText(t)};let[r,...e]=a.split("-").reverse(),i=e.reverse().join("-"),p={owner:tt.Principal.fromText(i),subaccount:(0,m.hexStringToUint8Array)(c.padStart(gt,"0"))};if(lt(p)!==r)throw new Error("Invalid account. Invalid checksum.");return p};var k=require("@dfinity/utils"),Rt=t=>{let a=/^([a-zA-Z]+):([A-Za-z0-9:\-.]+).*?(?:[?&](?:amount|value)=(\d+(?:\.\d+)?))?$/,c=t.match(a);if((0,k.isNullish)(c))return;let[r,e,i,p]=c;return{token:e,identifier:i,...(0,k.nonNullish)(p)&&!isNaN(parseFloat(p))&&{amount:parseFloat(p)}}};0&&(module.exports={IcrcIndexCanister,IcrcLedgerCanister,IcrcMetadataResponseEntries,IcrcTransferError,IndexError,decodeIcrcAccount,decodePayment,encodeIcrcAccount});
1
+ "use strict";var rt=Object.defineProperty;var gt=Object.getOwnPropertyDescriptor;var Ot=Object.getOwnPropertyNames;var xt=Object.prototype.hasOwnProperty;var Tt=(t,a)=>{for(var r in a)rt(t,r,{get:a[r],enumerable:!0})},Rt=(t,a,r,c)=>{if(a&&typeof a=="object"||typeof a=="function")for(let e of Ot(a))!xt.call(t,e)&&e!==r&&rt(t,e,{get:()=>a[e],enumerable:!(c=gt(a,e))||c.enumerable});return t};var yt=t=>Rt(rt({},"__esModule",{value:!0}),t);var ht={};Tt(ht,{IcrcIndexCanister:()=>q,IcrcIndexNgCanister:()=>C,IcrcLedgerCanister:()=>M,IcrcMetadataResponseEntries:()=>ft,IcrcTransferError:()=>w,IndexError:()=>v,decodeIcrcAccount:()=>Ft,decodePayment:()=>kt,encodeIcrcAccount:()=>bt});module.exports=yt(ht);var v=class extends Error{};var w=class extends Error{constructor({msg:a,errorType:r}){super(a),this.errorType=r}};var st=require("@dfinity/utils");var ot=({IDL:t})=>{let a=t.Rec(),r=t.Record({ledger_id:t.Opt(t.Principal)}),c=t.Record({ledger_id:t.Principal}),e=t.Variant({Upgrade:r,Init:c}),o=t.Nat,d=t.Vec(t.Nat8),s=t.Record({owner:t.Principal,subaccount:t.Opt(d)}),f=t.Record({max_results:t.Nat,start:t.Opt(o),account:s}),N=t.Nat,i=t.Record({from:s,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,spender:t.Opt(s)}),g=t.Record({to:s,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat}),u=t.Record({fee:t.Opt(t.Nat),from:s,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:s}),O=t.Record({to:s,fee:t.Opt(t.Nat),from:s,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,spender:t.Opt(s)}),l=t.Record({burn:t.Opt(i),kind:t.Text,mint:t.Opt(g),approve:t.Opt(u),timestamp:t.Nat64,transfer:t.Opt(O)}),x=t.Record({id:o,transaction:l}),y=t.Record({balance:N,transactions:t.Vec(x),oldest_tx_id:t.Opt(o)}),V=t.Record({message:t.Text}),A=t.Variant({Ok:y,Err:V}),T=t.Record({start:t.Nat,length:t.Nat}),R=t.Vec(t.Tuple(t.Text,a));a.fill(t.Variant({Int:t.Int,Map:R,Nat:t.Nat,Nat64:t.Nat64,Blob:t.Vec(t.Nat8),Text:t.Text,Array:t.Vec(a)}));let n=a,b=t.Record({blocks:t.Vec(n),chain_length:t.Nat64}),F=t.Record({ranges:t.Vec(t.Tuple(s,t.Vec(t.Tuple(o,o))))}),k=t.Record({owner:t.Principal,start:t.Opt(d)}),h=t.Record({num_blocks_synced:o});return t.Service({get_account_transactions:t.Func([f],[A],[]),get_blocks:t.Func([T],[b],[]),get_fee_collectors_ranges:t.Func([],[F],[]),icrc1_balance_of:t.Func([s],[N],[]),ledger_id:t.Func([],[t.Principal],[]),list_subaccounts:t.Func([k],[t.Vec(d)],[]),status:t.Func([],[h],[])})};var nt=({IDL:t})=>{let a=t.Rec(),r=t.Record({ledger_id:t.Opt(t.Principal)}),c=t.Record({ledger_id:t.Principal}),e=t.Variant({Upgrade:r,Init:c}),o=t.Nat,d=t.Vec(t.Nat8),s=t.Record({owner:t.Principal,subaccount:t.Opt(d)}),f=t.Record({max_results:t.Nat,start:t.Opt(o),account:s}),N=t.Nat,i=t.Record({from:s,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,spender:t.Opt(s)}),g=t.Record({to:s,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat}),u=t.Record({fee:t.Opt(t.Nat),from:s,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:s}),O=t.Record({to:s,fee:t.Opt(t.Nat),from:s,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,spender:t.Opt(s)}),l=t.Record({burn:t.Opt(i),kind:t.Text,mint:t.Opt(g),approve:t.Opt(u),timestamp:t.Nat64,transfer:t.Opt(O)}),x=t.Record({id:o,transaction:l}),y=t.Record({balance:N,transactions:t.Vec(x),oldest_tx_id:t.Opt(o)}),V=t.Record({message:t.Text}),A=t.Variant({Ok:y,Err:V}),T=t.Record({start:t.Nat,length:t.Nat}),R=t.Vec(t.Tuple(t.Text,a));a.fill(t.Variant({Int:t.Int,Map:R,Nat:t.Nat,Nat64:t.Nat64,Blob:t.Vec(t.Nat8),Text:t.Text,Array:t.Vec(a)}));let n=a,b=t.Record({blocks:t.Vec(n),chain_length:t.Nat64}),F=t.Record({ranges:t.Vec(t.Tuple(s,t.Vec(t.Tuple(o,o))))}),k=t.Record({owner:t.Principal,start:t.Opt(d)}),h=t.Record({num_blocks_synced:o});return t.Service({get_account_transactions:t.Func([f],[A],["query"]),get_blocks:t.Func([T],[b],["query"]),get_fee_collectors_ranges:t.Func([],[F],["query"]),icrc1_balance_of:t.Func([s],[N],["query"]),ledger_id:t.Func([],[t.Principal],["query"]),list_subaccounts:t.Func([k],[t.Vec(d)],["query"]),status:t.Func([],[h],["query"])})};var E=require("@dfinity/utils"),S=class extends E.Canister{constructor(){super(...arguments);this.balance=r=>this.caller({certified:r.certified}).icrc1_balance_of({owner:r.owner,subaccount:(0,E.toNullable)(r.subaccount)})}};var ct=require("@dfinity/utils"),Vt=({owner:t,subaccount:a})=>({owner:t,subaccount:(0,ct.toNullable)(a)}),G=({account:t,max_results:a,start:r})=>({account:Vt(t),max_results:a,start:(0,ct.toNullable)(r)});var C=class t extends S{constructor(){super(...arguments);this.getTransactions=async({certified:r,...c})=>{let e=await this.caller({certified:r}).get_account_transactions(G(c));if("Err"in e)throw new v(e.Err.message);return e.Ok}}static create(r){let{service:c,certifiedService:e,canisterId:o}=(0,st.createServices)({options:r,idlFactory:nt,certifiedIdlFactory:ot});return new t(o,c,e)}};var U=require("@dfinity/utils");var it=({IDL:t})=>{let a=t.Record({ledger_id:t.Principal}),r=t.Nat,c=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),e=t.Record({max_results:t.Nat,start:t.Opt(r),account:c}),o=t.Record({from:c,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,spender:t.Opt(c)}),d=t.Record({to:c,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat}),s=t.Record({fee:t.Opt(t.Nat),from:c,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:c}),f=t.Record({to:c,fee:t.Opt(t.Nat),from:c,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,spender:t.Opt(c)}),N=t.Record({burn:t.Opt(o),kind:t.Text,mint:t.Opt(d),approve:t.Opt(s),timestamp:t.Nat64,transfer:t.Opt(f)}),i=t.Record({id:r,transaction:N}),g=t.Record({transactions:t.Vec(i),oldest_tx_id:t.Opt(r)}),u=t.Record({message:t.Text}),O=t.Variant({Ok:g,Err:u}),l=t.Vec(t.Nat8),x=t.Record({owner:t.Principal,start:t.Opt(l)});return t.Service({get_account_transactions:t.Func([e],[O],[]),ledger_id:t.Func([],[t.Principal],[]),list_subaccounts:t.Func([x],[t.Vec(l)],[])})};var pt=({IDL:t})=>{let a=t.Record({ledger_id:t.Principal}),r=t.Nat,c=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),e=t.Record({max_results:t.Nat,start:t.Opt(r),account:c}),o=t.Record({from:c,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,spender:t.Opt(c)}),d=t.Record({to:c,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat}),s=t.Record({fee:t.Opt(t.Nat),from:c,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:c}),f=t.Record({to:c,fee:t.Opt(t.Nat),from:c,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,spender:t.Opt(c)}),N=t.Record({burn:t.Opt(o),kind:t.Text,mint:t.Opt(d),approve:t.Opt(s),timestamp:t.Nat64,transfer:t.Opt(f)}),i=t.Record({id:r,transaction:N}),g=t.Record({transactions:t.Vec(i),oldest_tx_id:t.Opt(r)}),u=t.Record({message:t.Text}),O=t.Variant({Ok:g,Err:u}),l=t.Vec(t.Nat8),x=t.Record({owner:t.Principal,start:t.Opt(l)});return t.Service({get_account_transactions:t.Func([e],[O],[]),ledger_id:t.Func([],[t.Principal],["query"]),list_subaccounts:t.Func([x],[t.Vec(l)],["query"])})};var q=class t extends U.Canister{constructor(){super(...arguments);this.getTransactions=async r=>{let c=await this.caller({certified:!0}).get_account_transactions(G(r));if("Err"in c)throw new v(c.Err.message);return c.Ok}}static create(r){let{service:c,certifiedService:e,canisterId:o}=(0,U.createServices)({options:r,idlFactory:pt,certifiedIdlFactory:it});return new t(o,c,e)}};var P=require("@dfinity/utils");var dt=({IDL:t})=>{let a=t.Rec(),r=t.Variant({Int:t.Int,Nat:t.Nat,Blob:t.Vec(t.Nat8),Text:t.Text}),c=t.Vec(t.Nat8),e=t.Record({owner:t.Principal,subaccount:t.Opt(c)}),o=t.Variant({SetTo:e,Unset:t.Null}),d=t.Record({icrc2:t.Bool}),s=t.Record({token_symbol:t.Opt(t.Text),transfer_fee:t.Opt(t.Nat),metadata:t.Opt(t.Vec(t.Tuple(t.Text,r))),maximum_number_of_accounts:t.Opt(t.Nat64),accounts_overflow_trim_quantity:t.Opt(t.Nat64),change_fee_collector:t.Opt(o),max_memo_length:t.Opt(t.Nat16),token_name:t.Opt(t.Text),feature_flags:t.Opt(d)}),f=t.Record({decimals:t.Opt(t.Nat8),token_symbol:t.Text,transfer_fee:t.Nat,metadata:t.Vec(t.Tuple(t.Text,r)),minting_account:e,initial_balances:t.Vec(t.Tuple(e,t.Nat)),maximum_number_of_accounts:t.Opt(t.Nat64),accounts_overflow_trim_quantity:t.Opt(t.Nat64),fee_collector_account:t.Opt(e),archive_options:t.Record({num_blocks_to_archive:t.Nat64,max_transactions_per_response:t.Opt(t.Nat64),trigger_threshold:t.Nat64,max_message_size_bytes:t.Opt(t.Nat64),cycles_for_archive_creation:t.Opt(t.Nat64),node_max_memory_size_bytes:t.Opt(t.Nat64),controller_id:t.Principal}),max_memo_length:t.Opt(t.Nat16),token_name:t.Text,feature_flags:t.Opt(d)}),N=t.Variant({Upgrade:t.Opt(s),Init:f}),i=t.Nat,g=t.Record({block_range_end:i,canister_id:t.Principal,block_range_start:i}),u=t.Record({start:i,length:t.Nat}),O=t.Vec(t.Tuple(t.Text,a));a.fill(t.Variant({Int:t.Int,Map:O,Nat:t.Nat,Nat64:t.Nat64,Blob:t.Vec(t.Nat8),Text:t.Text,Array:t.Vec(a)}));let l=a,x=t.Record({blocks:t.Vec(l)}),y=t.Func([u],[x],[]),V=t.Record({certificate:t.Opt(t.Vec(t.Nat8)),first_index:i,blocks:t.Vec(l),chain_length:t.Nat64,archived_blocks:t.Vec(t.Record({callback:y,start:i,length:t.Nat}))}),A=t.Record({certificate:t.Opt(t.Vec(t.Nat8)),hash_tree:t.Vec(t.Nat8)}),T=t.Nat,R=t.Record({start:T,length:t.Nat}),n=t.Nat64,b=t.Record({from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(n),amount:t.Nat,spender:t.Opt(e)}),F=t.Record({to:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(n),amount:t.Nat}),k=t.Record({fee:t.Opt(t.Nat),from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(n),amount:t.Nat,expected_allowance:t.Opt(t.Nat),expires_at:t.Opt(n),spender:e}),h=t.Record({to:e,fee:t.Opt(t.Nat),from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(n),amount:t.Nat,spender:t.Opt(e)}),B=t.Record({burn:t.Opt(b),kind:t.Text,mint:t.Opt(F),approve:t.Opt(k),timestamp:n,transfer:t.Opt(h)}),Q=t.Record({transactions:t.Vec(B)}),H=t.Func([R],[Q],[]),W=t.Record({first_index:T,log_length:t.Nat,transactions:t.Vec(B),archived_transactions:t.Vec(t.Record({callback:H,start:T,length:t.Nat}))}),p=t.Nat,Z=t.Record({url:t.Text,name:t.Text}),$=t.Record({to:e,fee:t.Opt(p),memo:t.Opt(t.Vec(t.Nat8)),from_subaccount:t.Opt(c),created_at_time:t.Opt(n),amount:p}),X=t.Variant({GenericError:t.Record({message:t.Text,error_code:t.Nat}),TemporarilyUnavailable:t.Null,BadBurn:t.Record({min_burn_amount:p}),Duplicate:t.Record({duplicate_of:i}),BadFee:t.Record({expected_fee:p}),CreatedInFuture:t.Record({ledger_time:n}),TooOld:t.Null,InsufficientFunds:t.Record({balance:p})}),j=t.Variant({Ok:i,Err:X}),Y=t.Record({account:e,spender:e}),J=t.Record({allowance:t.Nat,expires_at:t.Opt(n)}),K=t.Record({fee:t.Opt(t.Nat),memo:t.Opt(t.Vec(t.Nat8)),from_subaccount:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(n),amount:t.Nat,expected_allowance:t.Opt(t.Nat),expires_at:t.Opt(n),spender:e}),I=t.Variant({GenericError:t.Record({message:t.Text,error_code:t.Nat}),TemporarilyUnavailable:t.Null,Duplicate:t.Record({duplicate_of:i}),BadFee:t.Record({expected_fee:t.Nat}),AllowanceChanged:t.Record({current_allowance:t.Nat}),CreatedInFuture:t.Record({ledger_time:n}),TooOld:t.Null,Expired:t.Record({ledger_time:n}),InsufficientFunds:t.Record({balance:t.Nat})}),L=t.Variant({Ok:i,Err:I}),D=t.Record({to:e,fee:t.Opt(p),spender_subaccount:t.Opt(c),from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(n),amount:p}),tt=t.Variant({GenericError:t.Record({message:t.Text,error_code:t.Nat}),TemporarilyUnavailable:t.Null,InsufficientAllowance:t.Record({allowance:p}),BadBurn:t.Record({min_burn_amount:p}),Duplicate:t.Record({duplicate_of:i}),BadFee:t.Record({expected_fee:p}),CreatedInFuture:t.Record({ledger_time:n}),TooOld:t.Null,InsufficientFunds:t.Record({balance:p})}),et=t.Variant({Ok:i,Err:tt});return t.Service({archives:t.Func([],[t.Vec(g)],[]),get_blocks:t.Func([u],[V],[]),get_data_certificate:t.Func([],[A],[]),get_transactions:t.Func([R],[W],[]),icrc1_balance_of:t.Func([e],[p],[]),icrc1_decimals:t.Func([],[t.Nat8],[]),icrc1_fee:t.Func([],[p],[]),icrc1_metadata:t.Func([],[t.Vec(t.Tuple(t.Text,r))],[]),icrc1_minting_account:t.Func([],[t.Opt(e)],[]),icrc1_name:t.Func([],[t.Text],[]),icrc1_supported_standards:t.Func([],[t.Vec(Z)],[]),icrc1_symbol:t.Func([],[t.Text],[]),icrc1_total_supply:t.Func([],[p],[]),icrc1_transfer:t.Func([$],[j],[]),icrc2_allowance:t.Func([Y],[J],[]),icrc2_approve:t.Func([K],[L],[]),icrc2_transfer_from:t.Func([D],[et],[])})};var lt=({IDL:t})=>{let a=t.Rec(),r=t.Variant({Int:t.Int,Nat:t.Nat,Blob:t.Vec(t.Nat8),Text:t.Text}),c=t.Vec(t.Nat8),e=t.Record({owner:t.Principal,subaccount:t.Opt(c)}),o=t.Variant({SetTo:e,Unset:t.Null}),d=t.Record({icrc2:t.Bool}),s=t.Record({token_symbol:t.Opt(t.Text),transfer_fee:t.Opt(t.Nat),metadata:t.Opt(t.Vec(t.Tuple(t.Text,r))),maximum_number_of_accounts:t.Opt(t.Nat64),accounts_overflow_trim_quantity:t.Opt(t.Nat64),change_fee_collector:t.Opt(o),max_memo_length:t.Opt(t.Nat16),token_name:t.Opt(t.Text),feature_flags:t.Opt(d)}),f=t.Record({decimals:t.Opt(t.Nat8),token_symbol:t.Text,transfer_fee:t.Nat,metadata:t.Vec(t.Tuple(t.Text,r)),minting_account:e,initial_balances:t.Vec(t.Tuple(e,t.Nat)),maximum_number_of_accounts:t.Opt(t.Nat64),accounts_overflow_trim_quantity:t.Opt(t.Nat64),fee_collector_account:t.Opt(e),archive_options:t.Record({num_blocks_to_archive:t.Nat64,max_transactions_per_response:t.Opt(t.Nat64),trigger_threshold:t.Nat64,max_message_size_bytes:t.Opt(t.Nat64),cycles_for_archive_creation:t.Opt(t.Nat64),node_max_memory_size_bytes:t.Opt(t.Nat64),controller_id:t.Principal}),max_memo_length:t.Opt(t.Nat16),token_name:t.Text,feature_flags:t.Opt(d)}),N=t.Variant({Upgrade:t.Opt(s),Init:f}),i=t.Nat,g=t.Record({block_range_end:i,canister_id:t.Principal,block_range_start:i}),u=t.Record({start:i,length:t.Nat}),O=t.Vec(t.Tuple(t.Text,a));a.fill(t.Variant({Int:t.Int,Map:O,Nat:t.Nat,Nat64:t.Nat64,Blob:t.Vec(t.Nat8),Text:t.Text,Array:t.Vec(a)}));let l=a,x=t.Record({blocks:t.Vec(l)}),y=t.Func([u],[x],["query"]),V=t.Record({certificate:t.Opt(t.Vec(t.Nat8)),first_index:i,blocks:t.Vec(l),chain_length:t.Nat64,archived_blocks:t.Vec(t.Record({callback:y,start:i,length:t.Nat}))}),A=t.Record({certificate:t.Opt(t.Vec(t.Nat8)),hash_tree:t.Vec(t.Nat8)}),T=t.Nat,R=t.Record({start:T,length:t.Nat}),n=t.Nat64,b=t.Record({from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(n),amount:t.Nat,spender:t.Opt(e)}),F=t.Record({to:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(n),amount:t.Nat}),k=t.Record({fee:t.Opt(t.Nat),from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(n),amount:t.Nat,expected_allowance:t.Opt(t.Nat),expires_at:t.Opt(n),spender:e}),h=t.Record({to:e,fee:t.Opt(t.Nat),from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(n),amount:t.Nat,spender:t.Opt(e)}),B=t.Record({burn:t.Opt(b),kind:t.Text,mint:t.Opt(F),approve:t.Opt(k),timestamp:n,transfer:t.Opt(h)}),Q=t.Record({transactions:t.Vec(B)}),H=t.Func([R],[Q],["query"]),W=t.Record({first_index:T,log_length:t.Nat,transactions:t.Vec(B),archived_transactions:t.Vec(t.Record({callback:H,start:T,length:t.Nat}))}),p=t.Nat,Z=t.Record({url:t.Text,name:t.Text}),$=t.Record({to:e,fee:t.Opt(p),memo:t.Opt(t.Vec(t.Nat8)),from_subaccount:t.Opt(c),created_at_time:t.Opt(n),amount:p}),X=t.Variant({GenericError:t.Record({message:t.Text,error_code:t.Nat}),TemporarilyUnavailable:t.Null,BadBurn:t.Record({min_burn_amount:p}),Duplicate:t.Record({duplicate_of:i}),BadFee:t.Record({expected_fee:p}),CreatedInFuture:t.Record({ledger_time:n}),TooOld:t.Null,InsufficientFunds:t.Record({balance:p})}),j=t.Variant({Ok:i,Err:X}),Y=t.Record({account:e,spender:e}),J=t.Record({allowance:t.Nat,expires_at:t.Opt(n)}),K=t.Record({fee:t.Opt(t.Nat),memo:t.Opt(t.Vec(t.Nat8)),from_subaccount:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(n),amount:t.Nat,expected_allowance:t.Opt(t.Nat),expires_at:t.Opt(n),spender:e}),I=t.Variant({GenericError:t.Record({message:t.Text,error_code:t.Nat}),TemporarilyUnavailable:t.Null,Duplicate:t.Record({duplicate_of:i}),BadFee:t.Record({expected_fee:t.Nat}),AllowanceChanged:t.Record({current_allowance:t.Nat}),CreatedInFuture:t.Record({ledger_time:n}),TooOld:t.Null,Expired:t.Record({ledger_time:n}),InsufficientFunds:t.Record({balance:t.Nat})}),L=t.Variant({Ok:i,Err:I}),D=t.Record({to:e,fee:t.Opt(p),spender_subaccount:t.Opt(c),from:e,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(n),amount:p}),tt=t.Variant({GenericError:t.Record({message:t.Text,error_code:t.Nat}),TemporarilyUnavailable:t.Null,InsufficientAllowance:t.Record({allowance:p}),BadBurn:t.Record({min_burn_amount:p}),Duplicate:t.Record({duplicate_of:i}),BadFee:t.Record({expected_fee:p}),CreatedInFuture:t.Record({ledger_time:n}),TooOld:t.Null,InsufficientFunds:t.Record({balance:p})}),et=t.Variant({Ok:i,Err:tt});return t.Service({archives:t.Func([],[t.Vec(g)],["query"]),get_blocks:t.Func([u],[V],["query"]),get_data_certificate:t.Func([],[A],["query"]),get_transactions:t.Func([R],[W],["query"]),icrc1_balance_of:t.Func([e],[p],["query"]),icrc1_decimals:t.Func([],[t.Nat8],["query"]),icrc1_fee:t.Func([],[p],["query"]),icrc1_metadata:t.Func([],[t.Vec(t.Tuple(t.Text,r))],["query"]),icrc1_minting_account:t.Func([],[t.Opt(e)],["query"]),icrc1_name:t.Func([],[t.Text],["query"]),icrc1_supported_standards:t.Func([],[t.Vec(Z)],["query"]),icrc1_symbol:t.Func([],[t.Text],["query"]),icrc1_total_supply:t.Func([],[p],["query"]),icrc1_transfer:t.Func([$],[j],[]),icrc2_allowance:t.Func([Y],[J],["query"]),icrc2_approve:t.Func([K],[L],[]),icrc2_transfer_from:t.Func([D],[et],[])})};var m=require("@dfinity/utils"),mt=({from_subaccount:t,fee:a,created_at_time:r,memo:c,...e})=>({...e,fee:(0,m.toNullable)(a),memo:(0,m.toNullable)(c),from_subaccount:(0,m.toNullable)(t),created_at_time:(0,m.toNullable)(r)}),ut=({spender_subaccount:t,fee:a,created_at_time:r,memo:c,...e})=>({...e,fee:(0,m.toNullable)(a),memo:(0,m.toNullable)(c),spender_subaccount:(0,m.toNullable)(t),created_at_time:(0,m.toNullable)(r)}),_t=({fee:t,created_at_time:a,memo:r,from_subaccount:c,expected_allowance:e,expires_at:o,...d})=>({...d,fee:(0,m.toNullable)(t),memo:(0,m.toNullable)(r),from_subaccount:(0,m.toNullable)(c),created_at_time:(0,m.toNullable)(a),expected_allowance:(0,m.toNullable)(e),expires_at:(0,m.toNullable)(o)});var M=class t extends P.Canister{constructor(){super(...arguments);this.metadata=r=>this.caller(r).icrc1_metadata();this.transactionFee=r=>this.caller(r).icrc1_fee();this.balance=r=>this.caller({certified:r.certified}).icrc1_balance_of({owner:r.owner,subaccount:(0,P.toNullable)(r.subaccount)});this.transfer=async r=>{let c=await this.caller({certified:!0}).icrc1_transfer(mt(r));if("Err"in c)throw new w({errorType:c.Err,msg:"Failed to transfer"});return c.Ok};this.totalTokensSupply=r=>this.caller(r).icrc1_total_supply();this.transferFrom=async r=>{let c=await this.caller({certified:!0}).icrc2_transfer_from(ut(r));if("Err"in c)throw new w({errorType:c.Err,msg:"Failed to transfer from"});return c.Ok};this.approve=async r=>{let c=await this.caller({certified:!0}).icrc2_approve(_t(r));if("Err"in c)throw new w({errorType:c.Err,msg:"Failed to entitle the spender to transfer the amount"});return c.Ok};this.allowance=async r=>{let{certified:c,...e}=r;return this.caller({certified:c}).icrc2_allowance({...e})}}static create(r){let{service:c,certifiedService:e,canisterId:o}=(0,P.createServices)({options:r,idlFactory:lt,certifiedIdlFactory:dt});return new t(o,c,e)}};var ft=(o=>(o.SYMBOL="icrc1:symbol",o.NAME="icrc1:name",o.DECIMALS="icrc1:decimals",o.FEE="icrc1:fee",o.LOGO="icrc1:logo",o))(ft||{});var at=require("@dfinity/principal"),_=require("@dfinity/utils"),At=64,bt=({owner:t,subaccount:a})=>{if((0,_.isNullish)(a))return t.toText();let c=(e=>e.replace(/^0+/,""))((0,_.uint8ArrayToHexString)(Uint8Array.from(a)));return c.length===0?t.toText():`${t.toText()}-${Nt({owner:t,subaccount:a})}.${c}`},Nt=({owner:t,subaccount:a})=>{let r=(0,_.bigEndianCrc32)(Uint8Array.from([...t.toUint8Array(),...a]));return(0,_.encodeBase32)(r)},Ft=t=>{let[a,r]=t.split(".");if(!(0,_.notEmptyString)(a))throw new Error("Invalid account. No string provided.");if((0,_.isNullish)(r))return{owner:at.Principal.fromText(t)};let[c,...e]=a.split("-").reverse(),o=e.reverse().join("-"),d={owner:at.Principal.fromText(o),subaccount:(0,_.hexStringToUint8Array)(r.padStart(At,"0"))};if(Nt(d)!==c)throw new Error("Invalid account. Invalid checksum.");return d};var z=require("@dfinity/utils"),kt=t=>{let a=/^([a-zA-Z]+):([A-Za-z0-9:\-.]+).*?(?:[?&](?:amount|value)=(\d+(?:\.\d+)?))?$/,r=t.match(a);if((0,z.isNullish)(r))return;let[c,e,o,d]=r;return{token:e,identifier:o,...(0,z.nonNullish)(d)&&!isNaN(parseFloat(d))&&{amount:parseFloat(d)}}};0&&(module.exports={IcrcIndexCanister,IcrcIndexNgCanister,IcrcLedgerCanister,IcrcMetadataResponseEntries,IcrcTransferError,IndexError,decodeIcrcAccount,decodePayment,encodeIcrcAccount});
2
2
  //# sourceMappingURL=index.cjs.js.map