@dfinity/ledger-icrc 2.1.2 → 2.1.3-next-2024-02-21

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
@@ -130,7 +130,6 @@ Parameters:
130
130
  - [create](#gear-create)
131
131
  - [metadata](#gear-metadata)
132
132
  - [transactionFee](#gear-transactionfee)
133
- - [balance](#gear-balance)
134
133
  - [transfer](#gear-transfer)
135
134
  - [totalTokensSupply](#gear-totaltokenssupply)
136
135
  - [transferFrom](#gear-transferfrom)
@@ -165,20 +164,6 @@ The ledger transaction fees.
165
164
 
166
165
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L50)
167
166
 
168
- ##### :gear: balance
169
-
170
- Returns the balance for a given account provided as owner and with optional subaccount.
171
-
172
- | Method | Type |
173
- | --------- | -------------------------------------------- |
174
- | `balance` | `(params: BalanceParams) => Promise<bigint>` |
175
-
176
- Parameters:
177
-
178
- - `params`: The parameters to get the balance of an account.
179
-
180
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L59)
181
-
182
167
  ##### :gear: transfer
183
168
 
184
169
  Transfers tokens from the sender to the given account.
@@ -191,7 +176,7 @@ Parameters:
191
176
 
192
177
  - `params`: The parameters to transfer tokens.
193
178
 
194
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L72)
179
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L60)
195
180
 
196
181
  ##### :gear: totalTokensSupply
197
182
 
@@ -201,7 +186,7 @@ Returns the total supply of tokens.
201
186
  | ------------------- | ------------------------------------------ |
202
187
  | `totalTokensSupply` | `(params: QueryParams) => Promise<bigint>` |
203
188
 
204
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L88)
189
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L76)
205
190
 
206
191
  ##### :gear: transferFrom
207
192
 
@@ -217,7 +202,7 @@ Parameters:
217
202
 
218
203
  - `params`: The parameters to transfer tokens from to.
219
204
 
220
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L101)
205
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L89)
221
206
 
222
207
  ##### :gear: approve
223
208
 
@@ -233,7 +218,7 @@ Parameters:
233
218
 
234
219
  - `params`: The parameters to approve.
235
220
 
236
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L123)
221
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L111)
237
222
 
238
223
  ##### :gear: allowance
239
224
 
@@ -249,11 +234,11 @@ Parameters:
249
234
 
250
235
  - `params`: The parameters to call the allowance.
251
236
 
252
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L145)
237
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L133)
253
238
 
254
239
  ### :factory: IcrcIndexCanister
255
240
 
256
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index.canister.ts#L13)
241
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index.canister.ts#L14)
257
242
 
258
243
  #### Methods
259
244
 
@@ -266,22 +251,21 @@ Parameters:
266
251
  | -------- | --------------------------------------------------------------------- |
267
252
  | `create` | `(options: IcrcLedgerCanisterOptions<_SERVICE>) => IcrcIndexCanister` |
268
253
 
269
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index.canister.ts#L14)
254
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index.canister.ts#L15)
270
255
 
271
256
  ##### :gear: getTransactions
272
257
 
273
- Get the transactions of an account
258
+ Get the transactions of an account.
259
+
260
+ | Method | Type |
261
+ | ----------------- | ------------------------------------------------------------------------------------ |
262
+ | `getTransactions` | `({ certified, ...rest }: GetAccountTransactionsParams) => Promise<GetTransactions>` |
274
263
 
275
- Always certified.
276
- `get_account_transactions` needs to be called with an update
277
- because the index canisters makes a call to the ledger canister to get the transaction data.
278
- Index Canister only holds the transactions ids in state, not the whole transaction data.
264
+ Parameters:
279
265
 
280
- | Method | Type |
281
- | ----------------- | -------------------------------------------------------------------- |
282
- | `getTransactions` | `(params: GetAccountTransactionsParams) => Promise<GetTransactions>` |
266
+ - `params`: The parameters to get the transactions of an account.
283
267
 
284
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index.canister.ts#L33)
268
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index.canister.ts#L40)
285
269
 
286
270
  <!-- TSDOC_END -->
287
271
 
@@ -1,16 +1,21 @@
1
1
  /* Do not edit. Compiled with ./scripts/compile-idl-js from packages/ledger-icrc/candid/icrc_index.did */
2
2
  export const idlFactory = ({ IDL }) => {
3
- const InitArgs = IDL.Record({ 'ledger_id' : IDL.Principal });
4
- const TxId = IDL.Nat;
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);
5
9
  const Account = IDL.Record({
6
10
  'owner' : IDL.Principal,
7
- 'subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),
11
+ 'subaccount' : IDL.Opt(SubAccount),
8
12
  });
9
13
  const GetAccountTransactionsArgs = IDL.Record({
10
14
  'max_results' : IDL.Nat,
11
- 'start' : IDL.Opt(TxId),
15
+ 'start' : IDL.Opt(BlockIndex),
12
16
  'account' : Account,
13
17
  });
18
+ const Tokens = IDL.Nat;
14
19
  const Burn = IDL.Record({
15
20
  'from' : Account,
16
21
  'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
@@ -52,38 +57,71 @@ export const idlFactory = ({ IDL }) => {
52
57
  'transfer' : IDL.Opt(Transfer),
53
58
  });
54
59
  const TransactionWithId = IDL.Record({
55
- 'id' : TxId,
60
+ 'id' : BlockIndex,
56
61
  'transaction' : Transaction,
57
62
  });
58
63
  const GetTransactions = IDL.Record({
64
+ 'balance' : Tokens,
59
65
  'transactions' : IDL.Vec(TransactionWithId),
60
- 'oldest_tx_id' : IDL.Opt(TxId),
66
+ 'oldest_tx_id' : IDL.Opt(BlockIndex),
61
67
  });
62
68
  const GetTransactionsErr = IDL.Record({ 'message' : IDL.Text });
63
69
  const GetTransactionsResult = IDL.Variant({
64
70
  'Ok' : GetTransactions,
65
71
  'Err' : GetTransactionsErr,
66
72
  });
67
- const SubAccount = IDL.Vec(IDL.Nat8);
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
+ });
68
99
  const ListSubaccountsArgs = IDL.Record({
69
100
  'owner' : IDL.Principal,
70
101
  'start' : IDL.Opt(SubAccount),
71
102
  });
103
+ const Status = IDL.Record({ 'num_blocks_synced' : BlockIndex });
72
104
  return IDL.Service({
73
105
  'get_account_transactions' : IDL.Func(
74
106
  [GetAccountTransactionsArgs],
75
107
  [GetTransactionsResult],
76
108
  [],
77
109
  ),
110
+ 'get_blocks' : IDL.Func([GetBlocksRequest], [GetBlocksResponse], []),
111
+ 'get_fee_collectors_ranges' : IDL.Func([], [FeeCollectorRanges], []),
112
+ 'icrc1_balance_of' : IDL.Func([Account], [Tokens], []),
78
113
  'ledger_id' : IDL.Func([], [IDL.Principal], []),
79
114
  'list_subaccounts' : IDL.Func(
80
115
  [ListSubaccountsArgs],
81
116
  [IDL.Vec(SubAccount)],
82
117
  [],
83
118
  ),
119
+ 'status' : IDL.Func([], [Status], []),
84
120
  });
85
121
  };
86
122
  export const init = ({ IDL }) => {
87
- const InitArgs = IDL.Record({ 'ledger_id' : IDL.Principal });
88
- return [InitArgs];
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)];
89
127
  };
@@ -3,7 +3,7 @@ import type { Principal } from "@dfinity/principal";
3
3
 
4
4
  export interface Account {
5
5
  owner: Principal;
6
- subaccount: [] | [Uint8Array | number[]];
6
+ subaccount: [] | [SubAccount];
7
7
  }
8
8
  export interface Approve {
9
9
  fee: [] | [bigint];
@@ -15,6 +15,8 @@ export interface Approve {
15
15
  expires_at: [] | [bigint];
16
16
  spender: Account;
17
17
  }
18
+ export type Block = Value;
19
+ export type BlockIndex = bigint;
18
20
  export interface Burn {
19
21
  from: Account;
20
22
  memo: [] | [Uint8Array | number[]];
@@ -22,14 +24,26 @@ export interface Burn {
22
24
  amount: bigint;
23
25
  spender: [] | [Account];
24
26
  }
27
+ export interface FeeCollectorRanges {
28
+ ranges: Array<[Account, Array<[BlockIndex, BlockIndex]>]>;
29
+ }
25
30
  export interface GetAccountTransactionsArgs {
26
31
  max_results: bigint;
27
- start: [] | [TxId];
32
+ start: [] | [BlockIndex];
28
33
  account: Account;
29
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
+ }
30
43
  export interface GetTransactions {
44
+ balance: Tokens;
31
45
  transactions: Array<TransactionWithId>;
32
- oldest_tx_id: [] | [TxId];
46
+ oldest_tx_id: [] | [BlockIndex];
33
47
  }
34
48
  export interface GetTransactionsErr {
35
49
  message: string;
@@ -37,20 +51,26 @@ export interface GetTransactionsErr {
37
51
  export type GetTransactionsResult =
38
52
  | { Ok: GetTransactions }
39
53
  | { Err: GetTransactionsErr };
40
- export interface InitArgs {
54
+ export type IndexArg = { Upgrade: UpgradeArg } | { Init: InitArg };
55
+ export interface InitArg {
41
56
  ledger_id: Principal;
42
57
  }
43
58
  export interface ListSubaccountsArgs {
44
59
  owner: Principal;
45
60
  start: [] | [SubAccount];
46
61
  }
62
+ export type Map = Array<[string, Value]>;
47
63
  export interface Mint {
48
64
  to: Account;
49
65
  memo: [] | [Uint8Array | number[]];
50
66
  created_at_time: [] | [bigint];
51
67
  amount: bigint;
52
68
  }
69
+ export interface Status {
70
+ num_blocks_synced: BlockIndex;
71
+ }
53
72
  export type SubAccount = Uint8Array | number[];
73
+ export type Tokens = bigint;
54
74
  export interface Transaction {
55
75
  burn: [] | [Burn];
56
76
  kind: string;
@@ -60,7 +80,7 @@ export interface Transaction {
60
80
  transfer: [] | [Transfer];
61
81
  }
62
82
  export interface TransactionWithId {
63
- id: TxId;
83
+ id: BlockIndex;
64
84
  transaction: Transaction;
65
85
  }
66
86
  export interface Transfer {
@@ -72,12 +92,26 @@ export interface Transfer {
72
92
  amount: bigint;
73
93
  spender: [] | [Account];
74
94
  }
75
- export type TxId = bigint;
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> };
76
106
  export interface _SERVICE {
77
107
  get_account_transactions: ActorMethod<
78
108
  [GetAccountTransactionsArgs],
79
109
  GetTransactionsResult
80
110
  >;
111
+ get_blocks: ActorMethod<[GetBlocksRequest], GetBlocksResponse>;
112
+ get_fee_collectors_ranges: ActorMethod<[], FeeCollectorRanges>;
113
+ icrc1_balance_of: ActorMethod<[Account], Tokens>;
81
114
  ledger_id: ActorMethod<[], Principal>;
82
115
  list_subaccounts: ActorMethod<[ListSubaccountsArgs], Array<SubAccount>>;
116
+ status: ActorMethod<[], Status>;
83
117
  }
@@ -1,10 +1,49 @@
1
- // Generated from IC repo commit 044cfd5 (2024-01-25 tags: release-2024-01-25_14-09+p2p-con) 'rs/rosetta-api/icrc1/index/index.did' by import-candid
2
- type TxId = nat;
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
3
 
4
- type Account = record { owner : principal; subaccount : opt blob };
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;
5
42
 
6
43
  type SubAccount = blob;
7
44
 
45
+ type Account = record { owner : principal; subaccount : opt SubAccount };
46
+
8
47
  type Transaction = record {
9
48
  burn : opt Burn;
10
49
  kind : text;
@@ -55,20 +94,21 @@ type GetAccountTransactionsArgs = record {
55
94
  // The txid of the last transaction seen by the client.
56
95
  // If None then the results will start from the most recent
57
96
  // txid.
58
- start : opt TxId;
97
+ start : opt BlockIndex;
59
98
  // Maximum number of transactions to fetch.
60
99
  max_results : nat;
61
100
  };
62
101
 
63
102
  type TransactionWithId = record {
64
- id : TxId;
103
+ id : BlockIndex;
65
104
  transaction : Transaction;
66
105
  };
67
106
 
68
107
  type GetTransactions = record {
108
+ balance : Tokens;
69
109
  transactions : vec TransactionWithId;
70
110
  // The txid of the oldest transaction the account has
71
- oldest_tx_id : opt TxId;
111
+ oldest_tx_id : opt BlockIndex;
72
112
  };
73
113
 
74
114
  type GetTransactionsErr = record {
@@ -85,13 +125,20 @@ type ListSubaccountsArgs = record {
85
125
  start: opt SubAccount;
86
126
  };
87
127
 
88
- // The initialization parameters of the Index canister.
89
- type InitArgs = record {
90
- ledger_id : principal;
128
+ type Status = record {
129
+ num_blocks_synced : BlockIndex;
91
130
  };
92
131
 
93
- service : (InitArgs) -> {
94
- get_account_transactions : (GetAccountTransactionsArgs) -> (GetTransactionsResult);
95
- ledger_id : () -> (principal) query;
96
- list_subaccounts : (ListSubaccountsArgs) -> (vec SubAccount) query;
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;
97
144
  }
@@ -1,16 +1,21 @@
1
1
  /* Do not edit. Compiled with ./scripts/compile-idl-js from packages/ledger-icrc/candid/icrc_index.did */
2
2
  export const idlFactory = ({ IDL }) => {
3
- const InitArgs = IDL.Record({ 'ledger_id' : IDL.Principal });
4
- const TxId = IDL.Nat;
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);
5
9
  const Account = IDL.Record({
6
10
  'owner' : IDL.Principal,
7
- 'subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),
11
+ 'subaccount' : IDL.Opt(SubAccount),
8
12
  });
9
13
  const GetAccountTransactionsArgs = IDL.Record({
10
14
  'max_results' : IDL.Nat,
11
- 'start' : IDL.Opt(TxId),
15
+ 'start' : IDL.Opt(BlockIndex),
12
16
  'account' : Account,
13
17
  });
18
+ const Tokens = IDL.Nat;
14
19
  const Burn = IDL.Record({
15
20
  'from' : Account,
16
21
  'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
@@ -52,38 +57,71 @@ export const idlFactory = ({ IDL }) => {
52
57
  'transfer' : IDL.Opt(Transfer),
53
58
  });
54
59
  const TransactionWithId = IDL.Record({
55
- 'id' : TxId,
60
+ 'id' : BlockIndex,
56
61
  'transaction' : Transaction,
57
62
  });
58
63
  const GetTransactions = IDL.Record({
64
+ 'balance' : Tokens,
59
65
  'transactions' : IDL.Vec(TransactionWithId),
60
- 'oldest_tx_id' : IDL.Opt(TxId),
66
+ 'oldest_tx_id' : IDL.Opt(BlockIndex),
61
67
  });
62
68
  const GetTransactionsErr = IDL.Record({ 'message' : IDL.Text });
63
69
  const GetTransactionsResult = IDL.Variant({
64
70
  'Ok' : GetTransactions,
65
71
  'Err' : GetTransactionsErr,
66
72
  });
67
- const SubAccount = IDL.Vec(IDL.Nat8);
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
+ });
68
99
  const ListSubaccountsArgs = IDL.Record({
69
100
  'owner' : IDL.Principal,
70
101
  'start' : IDL.Opt(SubAccount),
71
102
  });
103
+ const Status = IDL.Record({ 'num_blocks_synced' : BlockIndex });
72
104
  return IDL.Service({
73
105
  'get_account_transactions' : IDL.Func(
74
106
  [GetAccountTransactionsArgs],
75
107
  [GetTransactionsResult],
76
- [],
108
+ ['query'],
77
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']),
78
113
  'ledger_id' : IDL.Func([], [IDL.Principal], ['query']),
79
114
  'list_subaccounts' : IDL.Func(
80
115
  [ListSubaccountsArgs],
81
116
  [IDL.Vec(SubAccount)],
82
117
  ['query'],
83
118
  ),
119
+ 'status' : IDL.Func([], [Status], ['query']),
84
120
  });
85
121
  };
86
122
  export const init = ({ IDL }) => {
87
- const InitArgs = IDL.Record({ 'ledger_id' : IDL.Principal });
88
- return [InitArgs];
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)];
89
127
  };
@@ -1,4 +1,4 @@
1
- // Generated from IC repo commit 044cfd5 (2024-01-25 tags: release-2024-01-25_14-09+p2p-con) 'rs/rosetta-api/icrc1/ledger/ledger.did' by import-candid
1
+ // Generated from IC repo commit f3198ee10 (2024-01-30) 'rs/rosetta-api/icrc1/ledger/ledger.did' by import-candid
2
2
  type BlockIndex = nat;
3
3
  type Subaccount = blob;
4
4
  // Number of nanoseconds since the UNIX epoch in UTC timezone.
@@ -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 L=Object.defineProperty;var ue=Object.getOwnPropertyDescriptor;var _e=Object.getOwnPropertyNames;var fe=Object.prototype.hasOwnProperty;var Ne=(e,c)=>{for(var r in c)L(e,r,{get:c[r],enumerable:!0})},ge=(e,c,r,a)=>{if(c&&typeof c=="object"||typeof c=="function")for(let t of _e(c))!fe.call(e,t)&&t!==r&&L(e,t,{get:()=>c[t],enumerable:!(a=ue(c,t))||a.enumerable});return e};var Oe=e=>ge(L({},"__esModule",{value:!0}),e);var Ae={};Ne(Ae,{IcrcIndexCanister:()=>E,IcrcLedgerCanister:()=>G,IcrcMetadataResponseEntries:()=>de,IcrcTransferError:()=>v,IndexError:()=>P,decodeIcrcAccount:()=>ye,decodePayment:()=>Ve,encodeIcrcAccount:()=>Re});module.exports=Oe(Ae);var P=class extends Error{};var v=class extends Error{constructor({msg:c,errorType:r}){super(c),this.errorType=r}};var ae=require("@dfinity/utils");var te=({IDL:e})=>{let c=e.Rec(),r=e.Record({ledger_id:e.Opt(e.Principal)}),a=e.Record({ledger_id:e.Principal}),t=e.Variant({Upgrade:r,Init:a}),n=e.Nat,l=e.Vec(e.Nat8),i=e.Record({owner:e.Principal,subaccount:e.Opt(l)}),g=e.Record({max_results:e.Nat,start:e.Opt(n),account:i}),O=e.Nat,p=e.Record({from:i,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,spender:e.Opt(i)}),T=e.Record({to:i,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat}),_=e.Record({fee:e.Opt(e.Nat),from:i,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(e.Nat64),spender:i}),x=e.Record({to:i,fee:e.Opt(e.Nat),from:i,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,spender:e.Opt(i)}),f=e.Record({burn:e.Opt(p),kind:e.Text,mint:e.Opt(T),approve:e.Opt(_),timestamp:e.Nat64,transfer:e.Opt(x)}),R=e.Record({id:n,transaction:f}),y=e.Record({balance:O,transactions:e.Vec(R),oldest_tx_id:e.Opt(n)}),V=e.Record({message:e.Text}),A=e.Variant({Ok:y,Err:V}),u=e.Record({start:e.Nat,length:e.Nat}),N=e.Vec(e.Tuple(e.Text,c));c.fill(e.Variant({Int:e.Int,Map:N,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(c)}));let o=c,b=e.Record({blocks:e.Vec(o),chain_length:e.Nat64}),F=e.Record({ranges:e.Vec(e.Tuple(i,e.Vec(e.Tuple(n,n))))}),h=e.Record({owner:e.Principal,start:e.Opt(l)}),k=e.Record({num_blocks_synced:n});return e.Service({get_account_transactions:e.Func([g],[A],[]),get_blocks:e.Func([u],[b],[]),get_fee_collectors_ranges:e.Func([],[F],[]),icrc1_balance_of:e.Func([i],[O],[]),ledger_id:e.Func([],[e.Principal],[]),list_subaccounts:e.Func([h],[e.Vec(l)],[]),status:e.Func([],[k],[])})};var re=({IDL:e})=>{let c=e.Rec(),r=e.Record({ledger_id:e.Opt(e.Principal)}),a=e.Record({ledger_id:e.Principal}),t=e.Variant({Upgrade:r,Init:a}),n=e.Nat,l=e.Vec(e.Nat8),i=e.Record({owner:e.Principal,subaccount:e.Opt(l)}),g=e.Record({max_results:e.Nat,start:e.Opt(n),account:i}),O=e.Nat,p=e.Record({from:i,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,spender:e.Opt(i)}),T=e.Record({to:i,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat}),_=e.Record({fee:e.Opt(e.Nat),from:i,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(e.Nat64),spender:i}),x=e.Record({to:i,fee:e.Opt(e.Nat),from:i,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,spender:e.Opt(i)}),f=e.Record({burn:e.Opt(p),kind:e.Text,mint:e.Opt(T),approve:e.Opt(_),timestamp:e.Nat64,transfer:e.Opt(x)}),R=e.Record({id:n,transaction:f}),y=e.Record({balance:O,transactions:e.Vec(R),oldest_tx_id:e.Opt(n)}),V=e.Record({message:e.Text}),A=e.Variant({Ok:y,Err:V}),u=e.Record({start:e.Nat,length:e.Nat}),N=e.Vec(e.Tuple(e.Text,c));c.fill(e.Variant({Int:e.Int,Map:N,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(c)}));let o=c,b=e.Record({blocks:e.Vec(o),chain_length:e.Nat64}),F=e.Record({ranges:e.Vec(e.Tuple(i,e.Vec(e.Tuple(n,n))))}),h=e.Record({owner:e.Principal,start:e.Opt(l)}),k=e.Record({num_blocks_synced:n});return e.Service({get_account_transactions:e.Func([g],[A],["query"]),get_blocks:e.Func([u],[b],["query"]),get_fee_collectors_ranges:e.Func([],[F],["query"]),icrc1_balance_of:e.Func([i],[O],["query"]),ledger_id:e.Func([],[e.Principal],["query"]),list_subaccounts:e.Func([h],[e.Vec(l)],["query"]),status:e.Func([],[k],["query"])})};var S=require("@dfinity/utils"),w=class extends S.Canister{constructor(){super(...arguments);this.balance=r=>this.caller({certified:r.certified}).icrc1_balance_of({owner:r.owner,subaccount:(0,S.toNullable)(r.subaccount)})}};var D=require("@dfinity/utils"),Te=({owner:e,subaccount:c})=>({owner:e,subaccount:(0,D.toNullable)(c)}),ce=({account:e,max_results:c,start:r})=>({account:Te(e),max_results:c,start:(0,D.toNullable)(r)});var E=class e extends w{constructor(){super(...arguments);this.getTransactions=async({certified:r,...a})=>{let t=await this.caller({certified:r}).get_account_transactions(ce(a));if("Err"in t)throw new P(t.Err.message);return t.Ok}}static create(r){let{service:a,certifiedService:t,canisterId:n}=(0,ae.createServices)({options:r,idlFactory:re,certifiedIdlFactory:te});return new e(n,a,t)}};var le=require("@dfinity/utils");var oe=({IDL:e})=>{let c=e.Rec(),r=e.Variant({Int:e.Int,Nat:e.Nat,Blob:e.Vec(e.Nat8),Text:e.Text}),a=e.Vec(e.Nat8),t=e.Record({owner:e.Principal,subaccount:e.Opt(a)}),n=e.Variant({SetTo:t,Unset:e.Null}),l=e.Record({icrc2:e.Bool}),i=e.Record({token_symbol:e.Opt(e.Text),transfer_fee:e.Opt(e.Nat),metadata:e.Opt(e.Vec(e.Tuple(e.Text,r))),maximum_number_of_accounts:e.Opt(e.Nat64),accounts_overflow_trim_quantity:e.Opt(e.Nat64),change_fee_collector:e.Opt(n),max_memo_length:e.Opt(e.Nat16),token_name:e.Opt(e.Text),feature_flags:e.Opt(l)}),g=e.Record({decimals:e.Opt(e.Nat8),token_symbol:e.Text,transfer_fee:e.Nat,metadata:e.Vec(e.Tuple(e.Text,r)),minting_account:t,initial_balances:e.Vec(e.Tuple(t,e.Nat)),maximum_number_of_accounts:e.Opt(e.Nat64),accounts_overflow_trim_quantity:e.Opt(e.Nat64),fee_collector_account:e.Opt(t),archive_options:e.Record({num_blocks_to_archive:e.Nat64,max_transactions_per_response:e.Opt(e.Nat64),trigger_threshold:e.Nat64,max_message_size_bytes:e.Opt(e.Nat64),cycles_for_archive_creation:e.Opt(e.Nat64),node_max_memory_size_bytes:e.Opt(e.Nat64),controller_id:e.Principal}),max_memo_length:e.Opt(e.Nat16),token_name:e.Text,feature_flags:e.Opt(l)}),O=e.Variant({Upgrade:e.Opt(i),Init:g}),p=e.Nat,T=e.Record({block_range_end:p,canister_id:e.Principal,block_range_start:p}),_=e.Record({start:p,length:e.Nat}),x=e.Vec(e.Tuple(e.Text,c));c.fill(e.Variant({Int:e.Int,Map:x,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(c)}));let f=c,R=e.Record({blocks:e.Vec(f)}),y=e.Func([_],[R],[]),V=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),first_index:p,blocks:e.Vec(f),chain_length:e.Nat64,archived_blocks:e.Vec(e.Record({callback:y,start:p,length:e.Nat}))}),A=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),hash_tree:e.Vec(e.Nat8)}),u=e.Nat,N=e.Record({start:u,length:e.Nat}),o=e.Nat64,b=e.Record({from:t,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,spender:e.Opt(t)}),F=e.Record({to:t,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat}),h=e.Record({fee:e.Opt(e.Nat),from:t,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(o),spender:t}),k=e.Record({to:t,fee:e.Opt(e.Nat),from:t,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,spender:e.Opt(t)}),B=e.Record({burn:e.Opt(b),kind:e.Text,mint:e.Opt(F),approve:e.Opt(h),timestamp:o,transfer:e.Opt(k)}),q=e.Record({transactions:e.Vec(B)}),U=e.Func([N],[q],[]),M=e.Record({first_index:u,log_length:e.Nat,transactions:e.Vec(B),archived_transactions:e.Vec(e.Record({callback:U,start:u,length:e.Nat}))}),s=e.Nat,z=e.Record({url:e.Text,name:e.Text}),Q=e.Record({to:t,fee:e.Opt(s),memo:e.Opt(e.Vec(e.Nat8)),from_subaccount:e.Opt(a),created_at_time:e.Opt(o),amount:s}),H=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,BadBurn:e.Record({min_burn_amount:s}),Duplicate:e.Record({duplicate_of:p}),BadFee:e.Record({expected_fee:s}),CreatedInFuture:e.Record({ledger_time:o}),TooOld:e.Null,InsufficientFunds:e.Record({balance:s})}),Z=e.Variant({Ok:p,Err:H}),$=e.Record({account:t,spender:t}),W=e.Record({allowance:e.Nat,expires_at:e.Opt(o)}),X=e.Record({fee:e.Opt(e.Nat),memo:e.Opt(e.Vec(e.Nat8)),from_subaccount:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(o),spender:t}),j=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,Duplicate:e.Record({duplicate_of:p}),BadFee:e.Record({expected_fee:e.Nat}),AllowanceChanged:e.Record({current_allowance:e.Nat}),CreatedInFuture:e.Record({ledger_time:o}),TooOld:e.Null,Expired:e.Record({ledger_time:o}),InsufficientFunds:e.Record({balance:e.Nat})}),Y=e.Variant({Ok:p,Err:j}),J=e.Record({to:t,fee:e.Opt(s),spender_subaccount:e.Opt(a),from:t,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:s}),K=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,InsufficientAllowance:e.Record({allowance:s}),BadBurn:e.Record({min_burn_amount:s}),Duplicate:e.Record({duplicate_of:p}),BadFee:e.Record({expected_fee:s}),CreatedInFuture:e.Record({ledger_time:o}),TooOld:e.Null,InsufficientFunds:e.Record({balance:s})}),I=e.Variant({Ok:p,Err:K});return e.Service({archives:e.Func([],[e.Vec(T)],[]),get_blocks:e.Func([_],[V],[]),get_data_certificate:e.Func([],[A],[]),get_transactions:e.Func([N],[M],[]),icrc1_balance_of:e.Func([t],[s],[]),icrc1_decimals:e.Func([],[e.Nat8],[]),icrc1_fee:e.Func([],[s],[]),icrc1_metadata:e.Func([],[e.Vec(e.Tuple(e.Text,r))],[]),icrc1_minting_account:e.Func([],[e.Opt(t)],[]),icrc1_name:e.Func([],[e.Text],[]),icrc1_supported_standards:e.Func([],[e.Vec(z)],[]),icrc1_symbol:e.Func([],[e.Text],[]),icrc1_total_supply:e.Func([],[s],[]),icrc1_transfer:e.Func([Q],[Z],[]),icrc2_allowance:e.Func([$],[W],[]),icrc2_approve:e.Func([X],[Y],[]),icrc2_transfer_from:e.Func([J],[I],[])})};var ne=({IDL:e})=>{let c=e.Rec(),r=e.Variant({Int:e.Int,Nat:e.Nat,Blob:e.Vec(e.Nat8),Text:e.Text}),a=e.Vec(e.Nat8),t=e.Record({owner:e.Principal,subaccount:e.Opt(a)}),n=e.Variant({SetTo:t,Unset:e.Null}),l=e.Record({icrc2:e.Bool}),i=e.Record({token_symbol:e.Opt(e.Text),transfer_fee:e.Opt(e.Nat),metadata:e.Opt(e.Vec(e.Tuple(e.Text,r))),maximum_number_of_accounts:e.Opt(e.Nat64),accounts_overflow_trim_quantity:e.Opt(e.Nat64),change_fee_collector:e.Opt(n),max_memo_length:e.Opt(e.Nat16),token_name:e.Opt(e.Text),feature_flags:e.Opt(l)}),g=e.Record({decimals:e.Opt(e.Nat8),token_symbol:e.Text,transfer_fee:e.Nat,metadata:e.Vec(e.Tuple(e.Text,r)),minting_account:t,initial_balances:e.Vec(e.Tuple(t,e.Nat)),maximum_number_of_accounts:e.Opt(e.Nat64),accounts_overflow_trim_quantity:e.Opt(e.Nat64),fee_collector_account:e.Opt(t),archive_options:e.Record({num_blocks_to_archive:e.Nat64,max_transactions_per_response:e.Opt(e.Nat64),trigger_threshold:e.Nat64,max_message_size_bytes:e.Opt(e.Nat64),cycles_for_archive_creation:e.Opt(e.Nat64),node_max_memory_size_bytes:e.Opt(e.Nat64),controller_id:e.Principal}),max_memo_length:e.Opt(e.Nat16),token_name:e.Text,feature_flags:e.Opt(l)}),O=e.Variant({Upgrade:e.Opt(i),Init:g}),p=e.Nat,T=e.Record({block_range_end:p,canister_id:e.Principal,block_range_start:p}),_=e.Record({start:p,length:e.Nat}),x=e.Vec(e.Tuple(e.Text,c));c.fill(e.Variant({Int:e.Int,Map:x,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(c)}));let f=c,R=e.Record({blocks:e.Vec(f)}),y=e.Func([_],[R],["query"]),V=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),first_index:p,blocks:e.Vec(f),chain_length:e.Nat64,archived_blocks:e.Vec(e.Record({callback:y,start:p,length:e.Nat}))}),A=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),hash_tree:e.Vec(e.Nat8)}),u=e.Nat,N=e.Record({start:u,length:e.Nat}),o=e.Nat64,b=e.Record({from:t,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,spender:e.Opt(t)}),F=e.Record({to:t,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat}),h=e.Record({fee:e.Opt(e.Nat),from:t,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(o),spender:t}),k=e.Record({to:t,fee:e.Opt(e.Nat),from:t,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,spender:e.Opt(t)}),B=e.Record({burn:e.Opt(b),kind:e.Text,mint:e.Opt(F),approve:e.Opt(h),timestamp:o,transfer:e.Opt(k)}),q=e.Record({transactions:e.Vec(B)}),U=e.Func([N],[q],["query"]),M=e.Record({first_index:u,log_length:e.Nat,transactions:e.Vec(B),archived_transactions:e.Vec(e.Record({callback:U,start:u,length:e.Nat}))}),s=e.Nat,z=e.Record({url:e.Text,name:e.Text}),Q=e.Record({to:t,fee:e.Opt(s),memo:e.Opt(e.Vec(e.Nat8)),from_subaccount:e.Opt(a),created_at_time:e.Opt(o),amount:s}),H=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,BadBurn:e.Record({min_burn_amount:s}),Duplicate:e.Record({duplicate_of:p}),BadFee:e.Record({expected_fee:s}),CreatedInFuture:e.Record({ledger_time:o}),TooOld:e.Null,InsufficientFunds:e.Record({balance:s})}),Z=e.Variant({Ok:p,Err:H}),$=e.Record({account:t,spender:t}),W=e.Record({allowance:e.Nat,expires_at:e.Opt(o)}),X=e.Record({fee:e.Opt(e.Nat),memo:e.Opt(e.Vec(e.Nat8)),from_subaccount:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(o),spender:t}),j=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,Duplicate:e.Record({duplicate_of:p}),BadFee:e.Record({expected_fee:e.Nat}),AllowanceChanged:e.Record({current_allowance:e.Nat}),CreatedInFuture:e.Record({ledger_time:o}),TooOld:e.Null,Expired:e.Record({ledger_time:o}),InsufficientFunds:e.Record({balance:e.Nat})}),Y=e.Variant({Ok:p,Err:j}),J=e.Record({to:t,fee:e.Opt(s),spender_subaccount:e.Opt(a),from:t,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:s}),K=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,InsufficientAllowance:e.Record({allowance:s}),BadBurn:e.Record({min_burn_amount:s}),Duplicate:e.Record({duplicate_of:p}),BadFee:e.Record({expected_fee:s}),CreatedInFuture:e.Record({ledger_time:o}),TooOld:e.Null,InsufficientFunds:e.Record({balance:s})}),I=e.Variant({Ok:p,Err:K});return e.Service({archives:e.Func([],[e.Vec(T)],["query"]),get_blocks:e.Func([_],[V],["query"]),get_data_certificate:e.Func([],[A],["query"]),get_transactions:e.Func([N],[M],["query"]),icrc1_balance_of:e.Func([t],[s],["query"]),icrc1_decimals:e.Func([],[e.Nat8],["query"]),icrc1_fee:e.Func([],[s],["query"]),icrc1_metadata:e.Func([],[e.Vec(e.Tuple(e.Text,r))],["query"]),icrc1_minting_account:e.Func([],[e.Opt(t)],["query"]),icrc1_name:e.Func([],[e.Text],["query"]),icrc1_supported_standards:e.Func([],[e.Vec(z)],["query"]),icrc1_symbol:e.Func([],[e.Text],["query"]),icrc1_total_supply:e.Func([],[s],["query"]),icrc1_transfer:e.Func([Q],[Z],[]),icrc2_allowance:e.Func([$],[W],["query"]),icrc2_approve:e.Func([X],[Y],[]),icrc2_transfer_from:e.Func([J],[I],[])})};var d=require("@dfinity/utils"),se=({from_subaccount:e,fee:c,created_at_time:r,memo:a,...t})=>({...t,fee:(0,d.toNullable)(c),memo:(0,d.toNullable)(a),from_subaccount:(0,d.toNullable)(e),created_at_time:(0,d.toNullable)(r)}),ie=({spender_subaccount:e,fee:c,created_at_time:r,memo:a,...t})=>({...t,fee:(0,d.toNullable)(c),memo:(0,d.toNullable)(a),spender_subaccount:(0,d.toNullable)(e),created_at_time:(0,d.toNullable)(r)}),pe=({fee:e,created_at_time:c,memo:r,from_subaccount:a,expected_allowance:t,expires_at:n,...l})=>({...l,fee:(0,d.toNullable)(e),memo:(0,d.toNullable)(r),from_subaccount:(0,d.toNullable)(a),created_at_time:(0,d.toNullable)(c),expected_allowance:(0,d.toNullable)(t),expires_at:(0,d.toNullable)(n)});var G=class e extends w{constructor(){super(...arguments);this.metadata=r=>this.caller(r).icrc1_metadata();this.transactionFee=r=>this.caller(r).icrc1_fee();this.transfer=async r=>{let a=await this.caller({certified:!0}).icrc1_transfer(se(r));if("Err"in a)throw new v({errorType:a.Err,msg:"Failed to transfer"});return a.Ok};this.totalTokensSupply=r=>this.caller(r).icrc1_total_supply();this.transferFrom=async r=>{let a=await this.caller({certified:!0}).icrc2_transfer_from(ie(r));if("Err"in a)throw new v({errorType:a.Err,msg:"Failed to transfer from"});return a.Ok};this.approve=async r=>{let a=await this.caller({certified:!0}).icrc2_approve(pe(r));if("Err"in a)throw new v({errorType:a.Err,msg:"Failed to entitle the spender to transfer the amount"});return a.Ok};this.allowance=async r=>{let{certified:a,...t}=r;return this.caller({certified:a}).icrc2_allowance({...t})}}static create(r){let{service:a,certifiedService:t,canisterId:n}=(0,le.createServices)({options:r,idlFactory:ne,certifiedIdlFactory:oe});return new e(n,a,t)}};var de=(n=>(n.SYMBOL="icrc1:symbol",n.NAME="icrc1:name",n.DECIMALS="icrc1:decimals",n.FEE="icrc1:fee",n.LOGO="icrc1:logo",n))(de||{});var ee=require("@dfinity/principal"),m=require("@dfinity/utils"),xe=64,Re=({owner:e,subaccount:c})=>{if((0,m.isNullish)(c))return e.toText();let a=(t=>t.replace(/^0+/,""))((0,m.uint8ArrayToHexString)(Uint8Array.from(c)));return a.length===0?e.toText():`${e.toText()}-${me({owner:e,subaccount:c})}.${a}`},me=({owner:e,subaccount:c})=>{let r=(0,m.bigEndianCrc32)(Uint8Array.from([...e.toUint8Array(),...c]));return(0,m.encodeBase32)(r)},ye=e=>{let[c,r]=e.split(".");if(!(0,m.notEmptyString)(c))throw new Error("Invalid account. No string provided.");if((0,m.isNullish)(r))return{owner:ee.Principal.fromText(e)};let[a,...t]=c.split("-").reverse(),n=t.reverse().join("-"),l={owner:ee.Principal.fromText(n),subaccount:(0,m.hexStringToUint8Array)(r.padStart(xe,"0"))};if(me(l)!==a)throw new Error("Invalid account. Invalid checksum.");return l};var C=require("@dfinity/utils"),Ve=e=>{let c=/^([a-zA-Z]+):([A-Za-z0-9:\-.]+).*?(?:[?&](?:amount|value)=(\d+(?:\.\d+)?))?$/,r=e.match(c);if((0,C.isNullish)(r))return;let[a,t,n,l]=r;return{token:t,identifier:n,...(0,C.nonNullish)(l)&&!isNaN(parseFloat(l))&&{amount:parseFloat(l)}}};0&&(module.exports={IcrcIndexCanister,IcrcLedgerCanister,IcrcMetadataResponseEntries,IcrcTransferError,IndexError,decodeIcrcAccount,decodePayment,encodeIcrcAccount});
2
2
  //# sourceMappingURL=index.cjs.js.map