@dfinity/ledger-icrc 2.2.1 → 2.3.0-next-2024-05-10

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
@@ -307,12 +307,13 @@ Index Canister only holds the transactions ids in state, not the whole transacti
307
307
 
308
308
  ### :factory: IcrcIndexNgCanister
309
309
 
310
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index-ng.canister.ts#L14)
310
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index-ng.canister.ts#L15)
311
311
 
312
312
  #### Methods
313
313
 
314
314
  - [create](#gear-create)
315
315
  - [getTransactions](#gear-gettransactions)
316
+ - [ledgerId](#gear-ledgerid)
316
317
 
317
318
  ##### :gear: create
318
319
 
@@ -320,7 +321,7 @@ Index Canister only holds the transactions ids in state, not the whole transacti
320
321
  | -------- | ----------------------------------------------------------------------- |
321
322
  | `create` | `(options: IcrcLedgerCanisterOptions<_SERVICE>) => IcrcIndexNgCanister` |
322
323
 
323
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index-ng.canister.ts#L15)
324
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index-ng.canister.ts#L16)
324
325
 
325
326
  ##### :gear: getTransactions
326
327
 
@@ -334,7 +335,17 @@ Parameters:
334
335
 
335
336
  - `params`: The parameters to get the transactions of an account.
336
337
 
337
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index-ng.canister.ts#L40)
338
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index-ng.canister.ts#L41)
339
+
340
+ ##### :gear: ledgerId
341
+
342
+ Returns the ledger canister ID related to the index canister.
343
+
344
+ | Method | Type |
345
+ | ---------- | --------------------------------------------- |
346
+ | `ledgerId` | `(params: QueryParams) => Promise<Principal>` |
347
+
348
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index-ng.canister.ts#L59)
338
349
 
339
350
  <!-- TSDOC_END -->
340
351
 
@@ -1,4 +1,5 @@
1
1
  import type { ActorMethod } from "@dfinity/agent";
2
+ import type { IDL } from "@dfinity/candid";
2
3
  import type { Principal } from "@dfinity/principal";
3
4
 
4
5
  export interface Account {
@@ -115,3 +116,5 @@ export interface _SERVICE {
115
116
  list_subaccounts: ActorMethod<[ListSubaccountsArgs], Array<SubAccount>>;
116
117
  status: ActorMethod<[], Status>;
117
118
  }
119
+ export declare const idlFactory: IDL.InterfaceFactory;
120
+ export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[];
@@ -1,4 +1,4 @@
1
- // Generated from IC repo commit c3c5dc8 (2024-03-15 tags: release-2024-03-14_23-01-p2p) 'rs/rosetta-api/icrc1/index-ng/index-ng.did' by import-candid
1
+ // Generated from IC repo commit f58424c (2024-04-24 tags: release-2024-05-01_23-01-storage-layer) 'rs/rosetta-api/icrc1/index-ng/index-ng.did' by import-candid
2
2
  type Tokens = nat;
3
3
 
4
4
  type InitArg = record {
@@ -1,4 +1,5 @@
1
1
  import type { ActorMethod } from "@dfinity/agent";
2
+ import type { IDL } from "@dfinity/candid";
2
3
  import type { Principal } from "@dfinity/principal";
3
4
 
4
5
  export interface Account {
@@ -81,3 +82,5 @@ export interface _SERVICE {
81
82
  ledger_id: ActorMethod<[], Principal>;
82
83
  list_subaccounts: ActorMethod<[ListSubaccountsArgs], Array<SubAccount>>;
83
84
  }
85
+ export declare const idlFactory: IDL.InterfaceFactory;
86
+ export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[];
@@ -1,4 +1,4 @@
1
- // Generated from IC repo commit c3c5dc8 (2024-03-15 tags: release-2024-03-14_23-01-p2p) 'rs/rosetta-api/icrc1/index/index.did' by import-candid
1
+ // Generated from IC repo commit f58424c (2024-04-24 tags: release-2024-05-01_23-01-storage-layer) 'rs/rosetta-api/icrc1/index/index.did' by import-candid
2
2
  type TxId = nat;
3
3
 
4
4
  type Account = record { owner : principal; subaccount : opt blob };
@@ -1,6 +1,18 @@
1
1
  /* Do not edit. Compiled with ./scripts/compile-idl-js from packages/ledger-icrc/candid/icrc_ledger.did */
2
2
  export const idlFactory = ({ IDL }) => {
3
+ const GetBlocksResult = IDL.Rec();
4
+ const ICRC3Value = IDL.Rec();
3
5
  const Value = IDL.Rec();
6
+ const ChangeArchiveOptions = IDL.Record({
7
+ 'num_blocks_to_archive' : IDL.Opt(IDL.Nat64),
8
+ 'max_transactions_per_response' : IDL.Opt(IDL.Nat64),
9
+ 'trigger_threshold' : IDL.Opt(IDL.Nat64),
10
+ 'more_controller_ids' : IDL.Opt(IDL.Vec(IDL.Principal)),
11
+ 'max_message_size_bytes' : IDL.Opt(IDL.Nat64),
12
+ 'cycles_for_archive_creation' : IDL.Opt(IDL.Nat64),
13
+ 'node_max_memory_size_bytes' : IDL.Opt(IDL.Nat64),
14
+ 'controller_id' : IDL.Opt(IDL.Principal),
15
+ });
4
16
  const MetadataValue = IDL.Variant({
5
17
  'Int' : IDL.Int,
6
18
  'Nat' : IDL.Nat,
@@ -18,6 +30,7 @@ export const idlFactory = ({ IDL }) => {
18
30
  });
19
31
  const FeatureFlags = IDL.Record({ 'icrc2' : IDL.Bool });
20
32
  const UpgradeArgs = IDL.Record({
33
+ 'change_archive_options' : IDL.Opt(ChangeArchiveOptions),
21
34
  'token_symbol' : IDL.Opt(IDL.Text),
22
35
  'transfer_fee' : IDL.Opt(IDL.Nat),
23
36
  'metadata' : IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue))),
@@ -254,6 +267,44 @@ export const idlFactory = ({ IDL }) => {
254
267
  'Ok' : BlockIndex,
255
268
  'Err' : TransferFromError,
256
269
  });
270
+ const GetArchivesArgs = IDL.Record({ 'from' : IDL.Opt(IDL.Principal) });
271
+ const GetArchivesResult = IDL.Vec(
272
+ IDL.Record({
273
+ 'end' : IDL.Nat,
274
+ 'canister_id' : IDL.Principal,
275
+ 'start' : IDL.Nat,
276
+ })
277
+ );
278
+ ICRC3Value.fill(
279
+ IDL.Variant({
280
+ 'Int' : IDL.Int,
281
+ 'Map' : IDL.Vec(IDL.Tuple(IDL.Text, ICRC3Value)),
282
+ 'Nat' : IDL.Nat,
283
+ 'Blob' : IDL.Vec(IDL.Nat8),
284
+ 'Text' : IDL.Text,
285
+ 'Array' : IDL.Vec(ICRC3Value),
286
+ })
287
+ );
288
+ GetBlocksResult.fill(
289
+ IDL.Record({
290
+ 'log_length' : IDL.Nat,
291
+ 'blocks' : IDL.Vec(IDL.Record({ 'id' : IDL.Nat, 'block' : ICRC3Value })),
292
+ 'archived_blocks' : IDL.Vec(
293
+ IDL.Record({
294
+ 'args' : IDL.Vec(GetBlocksArgs),
295
+ 'callback' : IDL.Func(
296
+ [IDL.Vec(GetBlocksArgs)],
297
+ [GetBlocksResult],
298
+ [],
299
+ ),
300
+ })
301
+ ),
302
+ })
303
+ );
304
+ const ICRC3DataCertificate = IDL.Record({
305
+ 'certificate' : IDL.Vec(IDL.Nat8),
306
+ 'hash_tree' : IDL.Vec(IDL.Nat8),
307
+ });
257
308
  return IDL.Service({
258
309
  'archives' : IDL.Func([], [IDL.Vec(ArchiveInfo)], []),
259
310
  'get_blocks' : IDL.Func([GetBlocksArgs], [GetBlocksResponse], []),
@@ -284,9 +335,35 @@ export const idlFactory = ({ IDL }) => {
284
335
  [TransferFromResult],
285
336
  [],
286
337
  ),
338
+ 'icrc3_get_archives' : IDL.Func([GetArchivesArgs], [GetArchivesResult], []),
339
+ 'icrc3_get_blocks' : IDL.Func(
340
+ [IDL.Vec(GetBlocksArgs)],
341
+ [GetBlocksResult],
342
+ [],
343
+ ),
344
+ 'icrc3_get_tip_certificate' : IDL.Func(
345
+ [],
346
+ [IDL.Opt(ICRC3DataCertificate)],
347
+ [],
348
+ ),
349
+ 'icrc3_supported_block_types' : IDL.Func(
350
+ [],
351
+ [IDL.Vec(IDL.Record({ 'url' : IDL.Text, 'block_type' : IDL.Text }))],
352
+ [],
353
+ ),
287
354
  });
288
355
  };
289
356
  export const init = ({ IDL }) => {
357
+ const ChangeArchiveOptions = IDL.Record({
358
+ 'num_blocks_to_archive' : IDL.Opt(IDL.Nat64),
359
+ 'max_transactions_per_response' : IDL.Opt(IDL.Nat64),
360
+ 'trigger_threshold' : IDL.Opt(IDL.Nat64),
361
+ 'more_controller_ids' : IDL.Opt(IDL.Vec(IDL.Principal)),
362
+ 'max_message_size_bytes' : IDL.Opt(IDL.Nat64),
363
+ 'cycles_for_archive_creation' : IDL.Opt(IDL.Nat64),
364
+ 'node_max_memory_size_bytes' : IDL.Opt(IDL.Nat64),
365
+ 'controller_id' : IDL.Opt(IDL.Principal),
366
+ });
290
367
  const MetadataValue = IDL.Variant({
291
368
  'Int' : IDL.Int,
292
369
  'Nat' : IDL.Nat,
@@ -304,6 +381,7 @@ export const init = ({ IDL }) => {
304
381
  });
305
382
  const FeatureFlags = IDL.Record({ 'icrc2' : IDL.Bool });
306
383
  const UpgradeArgs = IDL.Record({
384
+ 'change_archive_options' : IDL.Opt(ChangeArchiveOptions),
307
385
  'token_symbol' : IDL.Opt(IDL.Text),
308
386
  'transfer_fee' : IDL.Opt(IDL.Nat),
309
387
  'metadata' : IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue))),
@@ -1,4 +1,5 @@
1
1
  import type { ActorMethod } from "@dfinity/agent";
2
+ import type { IDL } from "@dfinity/candid";
2
3
  import type { Principal } from "@dfinity/principal";
3
4
 
4
5
  export interface Account {
@@ -63,6 +64,16 @@ export interface Burn {
63
64
  amount: bigint;
64
65
  spender: [] | [Account];
65
66
  }
67
+ export interface ChangeArchiveOptions {
68
+ num_blocks_to_archive: [] | [bigint];
69
+ max_transactions_per_response: [] | [bigint];
70
+ trigger_threshold: [] | [bigint];
71
+ more_controller_ids: [] | [Array<Principal>];
72
+ max_message_size_bytes: [] | [bigint];
73
+ cycles_for_archive_creation: [] | [bigint];
74
+ node_max_memory_size_bytes: [] | [bigint];
75
+ controller_id: [] | [Principal];
76
+ }
66
77
  export type ChangeFeeCollector = { SetTo: Account } | { Unset: null };
67
78
  export interface DataCertificate {
68
79
  certificate: [] | [Uint8Array | number[]];
@@ -72,6 +83,14 @@ export type Duration = bigint;
72
83
  export interface FeatureFlags {
73
84
  icrc2: boolean;
74
85
  }
86
+ export interface GetArchivesArgs {
87
+ from: [] | [Principal];
88
+ }
89
+ export type GetArchivesResult = Array<{
90
+ end: bigint;
91
+ canister_id: Principal;
92
+ start: bigint;
93
+ }>;
75
94
  export interface GetBlocksArgs {
76
95
  start: BlockIndex;
77
96
  length: bigint;
@@ -87,6 +106,14 @@ export interface GetBlocksResponse {
87
106
  length: bigint;
88
107
  }>;
89
108
  }
109
+ export interface GetBlocksResult {
110
+ log_length: bigint;
111
+ blocks: Array<{ id: bigint; block: ICRC3Value }>;
112
+ archived_blocks: Array<{
113
+ args: Array<GetBlocksArgs>;
114
+ callback: [Principal, string];
115
+ }>;
116
+ }
90
117
  export interface GetTransactionsRequest {
91
118
  start: TxIndex;
92
119
  length: bigint;
@@ -112,6 +139,17 @@ export interface HttpResponse {
112
139
  headers: Array<[string, string]>;
113
140
  status_code: number;
114
141
  }
142
+ export interface ICRC3DataCertificate {
143
+ certificate: Uint8Array | number[];
144
+ hash_tree: Uint8Array | number[];
145
+ }
146
+ export type ICRC3Value =
147
+ | { Int: bigint }
148
+ | { Map: Array<[string, ICRC3Value]> }
149
+ | { Nat: bigint }
150
+ | { Blob: Uint8Array | number[] }
151
+ | { Text: string }
152
+ | { Array: Array<ICRC3Value> };
115
153
  export interface InitArgs {
116
154
  decimals: [] | [number];
117
155
  token_symbol: string;
@@ -227,6 +265,7 @@ export type TransferFromResult =
227
265
  export type TransferResult = { Ok: BlockIndex } | { Err: TransferError };
228
266
  export type TxIndex = bigint;
229
267
  export interface UpgradeArgs {
268
+ change_archive_options: [] | [ChangeArchiveOptions];
230
269
  token_symbol: [] | [string];
231
270
  transfer_fee: [] | [bigint];
232
271
  metadata: [] | [Array<[string, MetadataValue]>];
@@ -266,4 +305,13 @@ export interface _SERVICE {
266
305
  icrc2_allowance: ActorMethod<[AllowanceArgs], Allowance>;
267
306
  icrc2_approve: ActorMethod<[ApproveArgs], ApproveResult>;
268
307
  icrc2_transfer_from: ActorMethod<[TransferFromArgs], TransferFromResult>;
308
+ icrc3_get_archives: ActorMethod<[GetArchivesArgs], GetArchivesResult>;
309
+ icrc3_get_blocks: ActorMethod<[Array<GetBlocksArgs>], GetBlocksResult>;
310
+ icrc3_get_tip_certificate: ActorMethod<[], [] | [ICRC3DataCertificate]>;
311
+ icrc3_supported_block_types: ActorMethod<
312
+ [],
313
+ Array<{ url: string; block_type: string }>
314
+ >;
269
315
  }
316
+ export declare const idlFactory: IDL.InterfaceFactory;
317
+ export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[];
@@ -1,4 +1,4 @@
1
- // Generated from IC repo commit c3c5dc8 (2024-03-15 tags: release-2024-03-14_23-01-p2p) 'rs/rosetta-api/icrc1/ledger/ledger.did' by import-candid
1
+ // Generated from IC repo commit f58424c (2024-04-24 tags: release-2024-05-01_23-01-storage-layer) '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.
@@ -126,6 +126,17 @@ type ChangeFeeCollector = variant {
126
126
  Unset; SetTo: Account;
127
127
  };
128
128
 
129
+ type ChangeArchiveOptions = record {
130
+ num_blocks_to_archive : opt nat64;
131
+ max_transactions_per_response : opt nat64;
132
+ trigger_threshold : opt nat64;
133
+ max_message_size_bytes : opt nat64;
134
+ cycles_for_archive_creation : opt nat64;
135
+ node_max_memory_size_bytes : opt nat64;
136
+ controller_id : opt principal;
137
+ more_controller_ids : opt vec principal;
138
+ };
139
+
129
140
  type UpgradeArgs = record {
130
141
  metadata : opt vec record { text; MetadataValue };
131
142
  token_symbol : opt text;
@@ -136,6 +147,7 @@ type UpgradeArgs = record {
136
147
  feature_flags : opt FeatureFlags;
137
148
  maximum_number_of_accounts: opt nat64;
138
149
  accounts_overflow_trim_quantity: opt nat64;
150
+ change_archive_options : opt ChangeArchiveOptions;
139
151
  };
140
152
 
141
153
  type LedgerArg = variant {
@@ -244,14 +256,14 @@ type Transfer = record {
244
256
  spender : opt Account;
245
257
  };
246
258
 
247
- type Value = variant {
248
- Blob : blob;
249
- Text : text;
259
+ type Value = variant {
260
+ Blob : blob;
261
+ Text : text;
250
262
  Nat : nat;
251
- Nat64: nat64;
263
+ Nat64: nat64;
252
264
  Int : int;
253
- Array : vec Value;
254
- Map : Map;
265
+ Array : vec Value;
266
+ Map : Map;
255
267
  };
256
268
 
257
269
  type Map = vec record { text; Value };
@@ -365,11 +377,60 @@ type ArchiveInfo = record {
365
377
  block_range_end: BlockIndex;
366
378
  };
367
379
 
380
+ type ICRC3Value = variant {
381
+ Blob : blob;
382
+ Text : text;
383
+ Nat : nat;
384
+ Int : int;
385
+ Array : vec ICRC3Value;
386
+ Map : vec record { text; ICRC3Value };
387
+ };
388
+
389
+ type GetArchivesArgs = record {
390
+ // The last archive seen by the client.
391
+ // The Ledger will return archives coming
392
+ // after this one if set, otherwise it
393
+ // will return the first archives.
394
+ from : opt principal;
395
+ };
396
+
397
+ type GetArchivesResult = vec record {
398
+ // The id of the archive
399
+ canister_id : principal;
400
+
401
+ // The first block in the archive
402
+ start : nat;
403
+
404
+ // The last block in the archive
405
+ end : nat;
406
+ };
407
+
408
+ type GetBlocksResult = record {
409
+ // Total number of blocks in the
410
+ // block log
411
+ log_length : nat;
412
+
413
+ blocks : vec record { id : nat; block: ICRC3Value };
414
+
415
+ archived_blocks : vec record {
416
+ args : vec GetBlocksArgs;
417
+ callback : func (vec GetBlocksArgs) -> (GetBlocksResult) query;
418
+ };
419
+ };
420
+
421
+ type ICRC3DataCertificate = record {
422
+ // See https://internetcomputer.org/docs/current/references/ic-interface-spec#certification
423
+ certificate : blob;
424
+
425
+ // CBOR encoded hash_tree
426
+ hash_tree : blob;
427
+ };
428
+
368
429
  service : (ledger_arg : LedgerArg) -> {
369
430
  archives : () -> (vec ArchiveInfo) query;
370
431
  get_transactions : (GetTransactionsRequest) -> (GetTransactionsResponse) query;
371
- get_blocks : (GetBlocksArgs) -> (GetBlocksResponse) query;
372
- get_data_certificate : () -> (DataCertificate) query;
432
+ get_blocks : (GetBlocksArgs) -> (GetBlocksResponse) query;
433
+ get_data_certificate : () -> (DataCertificate) query;
373
434
 
374
435
  icrc1_name : () -> (text) query;
375
436
  icrc1_symbol : () -> (text) query;
@@ -381,8 +442,13 @@ service : (ledger_arg : LedgerArg) -> {
381
442
  icrc1_balance_of : (Account) -> (Tokens) query;
382
443
  icrc1_transfer : (TransferArg) -> (TransferResult);
383
444
  icrc1_supported_standards : () -> (vec StandardRecord) query;
384
-
445
+
385
446
  icrc2_approve : (ApproveArgs) -> (ApproveResult);
386
447
  icrc2_allowance : (AllowanceArgs) -> (Allowance) query;
387
448
  icrc2_transfer_from : (TransferFromArgs) -> (TransferFromResult);
449
+
450
+ icrc3_get_archives : (GetArchivesArgs) -> (GetArchivesResult) query;
451
+ icrc3_get_tip_certificate : () -> (opt ICRC3DataCertificate) query;
452
+ icrc3_get_blocks : (vec GetBlocksArgs) -> (GetBlocksResult) query;
453
+ icrc3_supported_block_types : () -> (vec record { block_type : text; url : text }) query;
388
454
  }
@@ -1,6 +1,18 @@
1
1
  /* Do not edit. Compiled with ./scripts/compile-idl-js from packages/ledger-icrc/candid/icrc_ledger.did */
2
2
  export const idlFactory = ({ IDL }) => {
3
+ const GetBlocksResult = IDL.Rec();
4
+ const ICRC3Value = IDL.Rec();
3
5
  const Value = IDL.Rec();
6
+ const ChangeArchiveOptions = IDL.Record({
7
+ 'num_blocks_to_archive' : IDL.Opt(IDL.Nat64),
8
+ 'max_transactions_per_response' : IDL.Opt(IDL.Nat64),
9
+ 'trigger_threshold' : IDL.Opt(IDL.Nat64),
10
+ 'more_controller_ids' : IDL.Opt(IDL.Vec(IDL.Principal)),
11
+ 'max_message_size_bytes' : IDL.Opt(IDL.Nat64),
12
+ 'cycles_for_archive_creation' : IDL.Opt(IDL.Nat64),
13
+ 'node_max_memory_size_bytes' : IDL.Opt(IDL.Nat64),
14
+ 'controller_id' : IDL.Opt(IDL.Principal),
15
+ });
4
16
  const MetadataValue = IDL.Variant({
5
17
  'Int' : IDL.Int,
6
18
  'Nat' : IDL.Nat,
@@ -18,6 +30,7 @@ export const idlFactory = ({ IDL }) => {
18
30
  });
19
31
  const FeatureFlags = IDL.Record({ 'icrc2' : IDL.Bool });
20
32
  const UpgradeArgs = IDL.Record({
33
+ 'change_archive_options' : IDL.Opt(ChangeArchiveOptions),
21
34
  'token_symbol' : IDL.Opt(IDL.Text),
22
35
  'transfer_fee' : IDL.Opt(IDL.Nat),
23
36
  'metadata' : IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue))),
@@ -258,6 +271,44 @@ export const idlFactory = ({ IDL }) => {
258
271
  'Ok' : BlockIndex,
259
272
  'Err' : TransferFromError,
260
273
  });
274
+ const GetArchivesArgs = IDL.Record({ 'from' : IDL.Opt(IDL.Principal) });
275
+ const GetArchivesResult = IDL.Vec(
276
+ IDL.Record({
277
+ 'end' : IDL.Nat,
278
+ 'canister_id' : IDL.Principal,
279
+ 'start' : IDL.Nat,
280
+ })
281
+ );
282
+ ICRC3Value.fill(
283
+ IDL.Variant({
284
+ 'Int' : IDL.Int,
285
+ 'Map' : IDL.Vec(IDL.Tuple(IDL.Text, ICRC3Value)),
286
+ 'Nat' : IDL.Nat,
287
+ 'Blob' : IDL.Vec(IDL.Nat8),
288
+ 'Text' : IDL.Text,
289
+ 'Array' : IDL.Vec(ICRC3Value),
290
+ })
291
+ );
292
+ GetBlocksResult.fill(
293
+ IDL.Record({
294
+ 'log_length' : IDL.Nat,
295
+ 'blocks' : IDL.Vec(IDL.Record({ 'id' : IDL.Nat, 'block' : ICRC3Value })),
296
+ 'archived_blocks' : IDL.Vec(
297
+ IDL.Record({
298
+ 'args' : IDL.Vec(GetBlocksArgs),
299
+ 'callback' : IDL.Func(
300
+ [IDL.Vec(GetBlocksArgs)],
301
+ [GetBlocksResult],
302
+ ['query'],
303
+ ),
304
+ })
305
+ ),
306
+ })
307
+ );
308
+ const ICRC3DataCertificate = IDL.Record({
309
+ 'certificate' : IDL.Vec(IDL.Nat8),
310
+ 'hash_tree' : IDL.Vec(IDL.Nat8),
311
+ });
261
312
  return IDL.Service({
262
313
  'archives' : IDL.Func([], [IDL.Vec(ArchiveInfo)], ['query']),
263
314
  'get_blocks' : IDL.Func([GetBlocksArgs], [GetBlocksResponse], ['query']),
@@ -292,9 +343,39 @@ export const idlFactory = ({ IDL }) => {
292
343
  [TransferFromResult],
293
344
  [],
294
345
  ),
346
+ 'icrc3_get_archives' : IDL.Func(
347
+ [GetArchivesArgs],
348
+ [GetArchivesResult],
349
+ ['query'],
350
+ ),
351
+ 'icrc3_get_blocks' : IDL.Func(
352
+ [IDL.Vec(GetBlocksArgs)],
353
+ [GetBlocksResult],
354
+ ['query'],
355
+ ),
356
+ 'icrc3_get_tip_certificate' : IDL.Func(
357
+ [],
358
+ [IDL.Opt(ICRC3DataCertificate)],
359
+ ['query'],
360
+ ),
361
+ 'icrc3_supported_block_types' : IDL.Func(
362
+ [],
363
+ [IDL.Vec(IDL.Record({ 'url' : IDL.Text, 'block_type' : IDL.Text }))],
364
+ ['query'],
365
+ ),
295
366
  });
296
367
  };
297
368
  export const init = ({ IDL }) => {
369
+ const ChangeArchiveOptions = IDL.Record({
370
+ 'num_blocks_to_archive' : IDL.Opt(IDL.Nat64),
371
+ 'max_transactions_per_response' : IDL.Opt(IDL.Nat64),
372
+ 'trigger_threshold' : IDL.Opt(IDL.Nat64),
373
+ 'more_controller_ids' : IDL.Opt(IDL.Vec(IDL.Principal)),
374
+ 'max_message_size_bytes' : IDL.Opt(IDL.Nat64),
375
+ 'cycles_for_archive_creation' : IDL.Opt(IDL.Nat64),
376
+ 'node_max_memory_size_bytes' : IDL.Opt(IDL.Nat64),
377
+ 'controller_id' : IDL.Opt(IDL.Principal),
378
+ });
298
379
  const MetadataValue = IDL.Variant({
299
380
  'Int' : IDL.Int,
300
381
  'Nat' : IDL.Nat,
@@ -312,6 +393,7 @@ export const init = ({ IDL }) => {
312
393
  });
313
394
  const FeatureFlags = IDL.Record({ 'icrc2' : IDL.Bool });
314
395
  const UpgradeArgs = IDL.Record({
396
+ 'change_archive_options' : IDL.Opt(ChangeArchiveOptions),
315
397
  'token_symbol' : IDL.Opt(IDL.Text),
316
398
  'transfer_fee' : IDL.Opt(IDL.Nat),
317
399
  'metadata' : IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue))),
@@ -1,2 +1,2 @@
1
- "use strict";var rt=Object.defineProperty;var Ot=Object.getOwnPropertyDescriptor;var gt=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 gt(a))!xt.call(t,e)&&e!==r&&rt(t,e,{get:()=>a[e],enumerable:!(c=Ot(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:()=>P,IndexError:()=>v,decodeIcrcAccount:()=>Ft,decodePayment:()=>kt,encodeIcrcAccount:()=>bt});module.exports=yt(ht);var v=class extends Error{};var P=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)}),O=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}),g=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(O),approve:t.Opt(u),timestamp:t.Nat64,transfer:t.Opt(g)}),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)}),O=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}),g=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(O),approve:t.Opt(u),timestamp:t.Nat64,transfer:t.Opt(g)}),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}),O=t.Record({transactions:t.Vec(i),oldest_tx_id:t.Opt(r)}),u=t.Record({message:t.Text}),g=t.Variant({Ok:O,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],[g],[]),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}),O=t.Record({transactions:t.Vec(i),oldest_tx_id:t.Opt(r)}),u=t.Record({message:t.Text}),g=t.Variant({Ok:O,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],[g],[]),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 w=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,more_controller_ids:t.Opt(t.Vec(t.Principal)),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,O=t.Record({block_range_end:i,canister_id:t.Principal,block_range_start:i}),u=t.Record({start:i,length:t.Nat}),g=t.Vec(t.Tuple(t.Text,a));a.fill(t.Variant({Int:t.Int,Map:g,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(O)],[]),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,more_controller_ids:t.Opt(t.Vec(t.Principal)),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,O=t.Record({block_range_end:i,canister_id:t.Principal,block_range_start:i}),u=t.Record({start:i,length:t.Nat}),g=t.Vec(t.Tuple(t.Text,a));a.fill(t.Variant({Int:t.Int,Map:g,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(O)],["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 w.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,w.toNullable)(r.subaccount)});this.transfer=async r=>{let c=await this.caller({certified:!0}).icrc1_transfer(mt(r));if("Err"in c)throw new P({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 P({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 P({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,w.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});
1
+ "use strict";var it=Object.defineProperty;var Vt=Object.getOwnPropertyDescriptor;var bt=Object.getOwnPropertyNames;var At=Object.prototype.hasOwnProperty;var ht=(t,a)=>{for(var e in a)it(t,e,{get:a[e],enumerable:!0})},Ft=(t,a,e,r)=>{if(a&&typeof a=="object"||typeof a=="function")for(let n of bt(a))!At.call(t,n)&&n!==e&&it(t,n,{get:()=>a[n],enumerable:!(r=Vt(a,n))||r.enumerable});return t};var vt=t=>Ft(it({},"__esModule",{value:!0}),t);var Et={};ht(Et,{IcrcIndexCanister:()=>q,IcrcIndexNgCanister:()=>C,IcrcLedgerCanister:()=>M,IcrcMetadataResponseEntries:()=>Rt,IcrcTransferError:()=>P,IndexError:()=>k,decodeIcrcAccount:()=>Bt,decodePayment:()=>St,encodeIcrcAccount:()=>wt});module.exports=vt(Et);var k=class extends Error{};var P=class extends Error{constructor({msg:a,errorType:e}){super(a),this.errorType=e}};var mt=require("@dfinity/utils");var dt=({IDL:t})=>{let a=t.Rec(),e=t.Record({ledger_id:t.Opt(t.Principal)}),r=t.Record({ledger_id:t.Principal}),n=t.Variant({Upgrade:e,Init:r}),o=t.Nat,l=t.Vec(t.Nat8),c=t.Record({owner:t.Principal,subaccount:t.Opt(l)}),f=t.Record({max_results:t.Nat,start:t.Opt(o),account:c}),_=t.Nat,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)}),g=t.Record({to:c,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat}),T=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}),i=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)}),u=t.Record({burn:t.Opt(O),kind:t.Text,mint:t.Opt(g),approve:t.Opt(T),timestamp:t.Nat64,transfer:t.Opt(i)}),d=t.Record({id:o,transaction:u}),V=t.Record({balance:_,transactions:t.Vec(d),oldest_tx_id:t.Opt(o)}),R=t.Record({message:t.Text}),b=t.Variant({Ok:V,Err:R}),A=t.Record({start:t.Nat,length:t.Nat}),h=t.Vec(t.Tuple(t.Text,a));a.fill(t.Variant({Int:t.Int,Map:h,Nat:t.Nat,Nat64:t.Nat64,Blob:t.Vec(t.Nat8),Text:t.Text,Array:t.Vec(a)}));let F=a,x=t.Record({blocks:t.Vec(F),chain_length:t.Nat64}),y=t.Record({ranges:t.Vec(t.Tuple(c,t.Vec(t.Tuple(o,o))))}),s=t.Record({owner:t.Principal,start:t.Opt(l)}),v=t.Record({num_blocks_synced:o});return t.Service({get_account_transactions:t.Func([f],[b],[]),get_blocks:t.Func([A],[x],[]),get_fee_collectors_ranges:t.Func([],[y],[]),icrc1_balance_of:t.Func([c],[_],[]),ledger_id:t.Func([],[t.Principal],[]),list_subaccounts:t.Func([s],[t.Vec(l)],[]),status:t.Func([],[v],[])})};var _t=({IDL:t})=>{let a=t.Rec(),e=t.Record({ledger_id:t.Opt(t.Principal)}),r=t.Record({ledger_id:t.Principal}),n=t.Variant({Upgrade:e,Init:r}),o=t.Nat,l=t.Vec(t.Nat8),c=t.Record({owner:t.Principal,subaccount:t.Opt(l)}),f=t.Record({max_results:t.Nat,start:t.Opt(o),account:c}),_=t.Nat,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)}),g=t.Record({to:c,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat}),T=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}),i=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)}),u=t.Record({burn:t.Opt(O),kind:t.Text,mint:t.Opt(g),approve:t.Opt(T),timestamp:t.Nat64,transfer:t.Opt(i)}),d=t.Record({id:o,transaction:u}),V=t.Record({balance:_,transactions:t.Vec(d),oldest_tx_id:t.Opt(o)}),R=t.Record({message:t.Text}),b=t.Variant({Ok:V,Err:R}),A=t.Record({start:t.Nat,length:t.Nat}),h=t.Vec(t.Tuple(t.Text,a));a.fill(t.Variant({Int:t.Int,Map:h,Nat:t.Nat,Nat64:t.Nat64,Blob:t.Vec(t.Nat8),Text:t.Text,Array:t.Vec(a)}));let F=a,x=t.Record({blocks:t.Vec(F),chain_length:t.Nat64}),y=t.Record({ranges:t.Vec(t.Tuple(c,t.Vec(t.Tuple(o,o))))}),s=t.Record({owner:t.Principal,start:t.Opt(l)}),v=t.Record({num_blocks_synced:o});return t.Service({get_account_transactions:t.Func([f],[b],["query"]),get_blocks:t.Func([A],[x],["query"]),get_fee_collectors_ranges:t.Func([],[y],["query"]),icrc1_balance_of:t.Func([c],[_],["query"]),ledger_id:t.Func([],[t.Principal],["query"]),list_subaccounts:t.Func([s],[t.Vec(l)],["query"]),status:t.Func([],[v],["query"])})};var E=require("@dfinity/utils"),S=class extends E.Canister{constructor(){super(...arguments);this.balance=e=>this.caller({certified:e.certified}).icrc1_balance_of({owner:e.owner,subaccount:(0,E.toNullable)(e.subaccount)})}};var pt=require("@dfinity/utils"),kt=({owner:t,subaccount:a})=>({owner:t,subaccount:(0,pt.toNullable)(a)}),G=({account:t,max_results:a,start:e})=>({account:kt(t),max_results:a,start:(0,pt.toNullable)(e)});var C=class t extends S{constructor(){super(...arguments);this.getTransactions=async({certified:e,...r})=>{let n=await this.caller({certified:e}).get_account_transactions(G(r));if("Err"in n)throw new k(n.Err.message);return n.Ok};this.ledgerId=e=>{let{ledger_id:r}=this.caller(e);return r()}}static create(e){let{service:r,certifiedService:n,canisterId:o}=(0,mt.createServices)({options:e,idlFactory:_t,certifiedIdlFactory:dt});return new t(o,r,n)}};var U=require("@dfinity/utils");var ut=({IDL:t})=>{let a=t.Record({ledger_id:t.Principal}),e=t.Nat,r=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),n=t.Record({max_results:t.Nat,start:t.Opt(e),account:r}),o=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)}),l=t.Record({to:r,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat}),c=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)}),_=t.Record({burn:t.Opt(o),kind:t.Text,mint:t.Opt(l),approve:t.Opt(c),timestamp:t.Nat64,transfer:t.Opt(f)}),O=t.Record({id:e,transaction:_}),g=t.Record({transactions:t.Vec(O),oldest_tx_id:t.Opt(e)}),T=t.Record({message:t.Text}),i=t.Variant({Ok:g,Err:T}),u=t.Vec(t.Nat8),d=t.Record({owner:t.Principal,start:t.Opt(u)});return t.Service({get_account_transactions:t.Func([n],[i],[]),ledger_id:t.Func([],[t.Principal],[]),list_subaccounts:t.Func([d],[t.Vec(u)],[])})};var Nt=({IDL:t})=>{let a=t.Record({ledger_id:t.Principal}),e=t.Nat,r=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),n=t.Record({max_results:t.Nat,start:t.Opt(e),account:r}),o=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)}),l=t.Record({to:r,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat}),c=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)}),_=t.Record({burn:t.Opt(o),kind:t.Text,mint:t.Opt(l),approve:t.Opt(c),timestamp:t.Nat64,transfer:t.Opt(f)}),O=t.Record({id:e,transaction:_}),g=t.Record({transactions:t.Vec(O),oldest_tx_id:t.Opt(e)}),T=t.Record({message:t.Text}),i=t.Variant({Ok:g,Err:T}),u=t.Vec(t.Nat8),d=t.Record({owner:t.Principal,start:t.Opt(u)});return t.Service({get_account_transactions:t.Func([n],[i],[]),ledger_id:t.Func([],[t.Principal],["query"]),list_subaccounts:t.Func([d],[t.Vec(u)],["query"])})};var q=class t extends U.Canister{constructor(){super(...arguments);this.getTransactions=async e=>{let r=await this.caller({certified:!0}).get_account_transactions(G(e));if("Err"in r)throw new k(r.Err.message);return r.Ok}}static create(e){let{service:r,certifiedService:n,canisterId:o}=(0,U.createServices)({options:e,idlFactory:Nt,certifiedIdlFactory:ut});return new t(o,r,n)}};var w=require("@dfinity/utils");var ft=({IDL:t})=>{let a=t.Rec(),e=t.Rec(),r=t.Rec(),n=t.Record({num_blocks_to_archive:t.Opt(t.Nat64),max_transactions_per_response:t.Opt(t.Nat64),trigger_threshold:t.Opt(t.Nat64),more_controller_ids:t.Opt(t.Vec(t.Principal)),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.Opt(t.Principal)}),o=t.Variant({Int:t.Int,Nat:t.Nat,Blob:t.Vec(t.Nat8),Text:t.Text}),l=t.Vec(t.Nat8),c=t.Record({owner:t.Principal,subaccount:t.Opt(l)}),f=t.Variant({SetTo:c,Unset:t.Null}),_=t.Record({icrc2:t.Bool}),O=t.Record({change_archive_options:t.Opt(n),token_symbol:t.Opt(t.Text),transfer_fee:t.Opt(t.Nat),metadata:t.Opt(t.Vec(t.Tuple(t.Text,o))),maximum_number_of_accounts:t.Opt(t.Nat64),accounts_overflow_trim_quantity:t.Opt(t.Nat64),change_fee_collector:t.Opt(f),max_memo_length:t.Opt(t.Nat16),token_name:t.Opt(t.Text),feature_flags:t.Opt(_)}),g=t.Record({decimals:t.Opt(t.Nat8),token_symbol:t.Text,transfer_fee:t.Nat,metadata:t.Vec(t.Tuple(t.Text,o)),minting_account:c,initial_balances:t.Vec(t.Tuple(c,t.Nat)),maximum_number_of_accounts:t.Opt(t.Nat64),accounts_overflow_trim_quantity:t.Opt(t.Nat64),fee_collector_account:t.Opt(c),archive_options:t.Record({num_blocks_to_archive:t.Nat64,max_transactions_per_response:t.Opt(t.Nat64),trigger_threshold:t.Nat64,more_controller_ids:t.Opt(t.Vec(t.Principal)),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(_)}),T=t.Variant({Upgrade:t.Opt(O),Init:g}),i=t.Nat,u=t.Record({block_range_end:i,canister_id:t.Principal,block_range_start:i}),d=t.Record({start:i,length:t.Nat}),V=t.Vec(t.Tuple(t.Text,r));r.fill(t.Variant({Int:t.Int,Map:V,Nat:t.Nat,Nat64:t.Nat64,Blob:t.Vec(t.Nat8),Text:t.Text,Array:t.Vec(r)}));let R=r,b=t.Record({blocks:t.Vec(R)}),A=t.Func([d],[b],[]),h=t.Record({certificate:t.Opt(t.Vec(t.Nat8)),first_index:i,blocks:t.Vec(R),chain_length:t.Nat64,archived_blocks:t.Vec(t.Record({callback:A,start:i,length:t.Nat}))}),F=t.Record({certificate:t.Opt(t.Vec(t.Nat8)),hash_tree:t.Vec(t.Nat8)}),x=t.Nat,y=t.Record({start:x,length:t.Nat}),s=t.Nat64,v=t.Record({from:c,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(s),amount:t.Nat,spender:t.Opt(c)}),Q=t.Record({to:c,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(s),amount:t.Nat}),H=t.Record({fee:t.Opt(t.Nat),from:c,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(s),amount:t.Nat,expected_allowance:t.Opt(t.Nat),expires_at:t.Opt(s),spender:c}),W=t.Record({to:c,fee:t.Opt(t.Nat),from:c,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(s),amount:t.Nat,spender:t.Opt(c)}),B=t.Record({burn:t.Opt(v),kind:t.Text,mint:t.Opt(Q),approve:t.Opt(H),timestamp:s,transfer:t.Opt(W)}),Z=t.Record({transactions:t.Vec(B)}),$=t.Func([y],[Z],[]),X=t.Record({first_index:x,log_length:t.Nat,transactions:t.Vec(B),archived_transactions:t.Vec(t.Record({callback:$,start:x,length:t.Nat}))}),p=t.Nat,j=t.Record({url:t.Text,name:t.Text}),Y=t.Record({to:c,fee:t.Opt(p),memo:t.Opt(t.Vec(t.Nat8)),from_subaccount:t.Opt(l),created_at_time:t.Opt(s),amount:p}),J=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:s}),TooOld:t.Null,InsufficientFunds:t.Record({balance:p})}),K=t.Variant({Ok:i,Err:J}),I=t.Record({account:c,spender:c}),L=t.Record({allowance:t.Nat,expires_at:t.Opt(s)}),D=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(s),amount:t.Nat,expected_allowance:t.Opt(t.Nat),expires_at:t.Opt(s),spender:c}),tt=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:s}),TooOld:t.Null,Expired:t.Record({ledger_time:s}),InsufficientFunds:t.Record({balance:t.Nat})}),et=t.Variant({Ok:i,Err:tt}),rt=t.Record({to:c,fee:t.Opt(p),spender_subaccount:t.Opt(l),from:c,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(s),amount:p}),ct=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:s}),TooOld:t.Null,InsufficientFunds:t.Record({balance:p})}),at=t.Variant({Ok:i,Err:ct}),ot=t.Record({from:t.Opt(t.Principal)}),nt=t.Vec(t.Record({end:t.Nat,canister_id:t.Principal,start:t.Nat}));e.fill(t.Variant({Int:t.Int,Map:t.Vec(t.Tuple(t.Text,e)),Nat:t.Nat,Blob:t.Vec(t.Nat8),Text:t.Text,Array:t.Vec(e)})),a.fill(t.Record({log_length:t.Nat,blocks:t.Vec(t.Record({id:t.Nat,block:e})),archived_blocks:t.Vec(t.Record({args:t.Vec(d),callback:t.Func([t.Vec(d)],[a],[])}))}));let st=t.Record({certificate:t.Vec(t.Nat8),hash_tree:t.Vec(t.Nat8)});return t.Service({archives:t.Func([],[t.Vec(u)],[]),get_blocks:t.Func([d],[h],[]),get_data_certificate:t.Func([],[F],[]),get_transactions:t.Func([y],[X],[]),icrc1_balance_of:t.Func([c],[p],[]),icrc1_decimals:t.Func([],[t.Nat8],[]),icrc1_fee:t.Func([],[p],[]),icrc1_metadata:t.Func([],[t.Vec(t.Tuple(t.Text,o))],[]),icrc1_minting_account:t.Func([],[t.Opt(c)],[]),icrc1_name:t.Func([],[t.Text],[]),icrc1_supported_standards:t.Func([],[t.Vec(j)],[]),icrc1_symbol:t.Func([],[t.Text],[]),icrc1_total_supply:t.Func([],[p],[]),icrc1_transfer:t.Func([Y],[K],[]),icrc2_allowance:t.Func([I],[L],[]),icrc2_approve:t.Func([D],[et],[]),icrc2_transfer_from:t.Func([rt],[at],[]),icrc3_get_archives:t.Func([ot],[nt],[]),icrc3_get_blocks:t.Func([t.Vec(d)],[a],[]),icrc3_get_tip_certificate:t.Func([],[t.Opt(st)],[]),icrc3_supported_block_types:t.Func([],[t.Vec(t.Record({url:t.Text,block_type:t.Text}))],[])})};var Ot=({IDL:t})=>{let a=t.Rec(),e=t.Rec(),r=t.Rec(),n=t.Record({num_blocks_to_archive:t.Opt(t.Nat64),max_transactions_per_response:t.Opt(t.Nat64),trigger_threshold:t.Opt(t.Nat64),more_controller_ids:t.Opt(t.Vec(t.Principal)),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.Opt(t.Principal)}),o=t.Variant({Int:t.Int,Nat:t.Nat,Blob:t.Vec(t.Nat8),Text:t.Text}),l=t.Vec(t.Nat8),c=t.Record({owner:t.Principal,subaccount:t.Opt(l)}),f=t.Variant({SetTo:c,Unset:t.Null}),_=t.Record({icrc2:t.Bool}),O=t.Record({change_archive_options:t.Opt(n),token_symbol:t.Opt(t.Text),transfer_fee:t.Opt(t.Nat),metadata:t.Opt(t.Vec(t.Tuple(t.Text,o))),maximum_number_of_accounts:t.Opt(t.Nat64),accounts_overflow_trim_quantity:t.Opt(t.Nat64),change_fee_collector:t.Opt(f),max_memo_length:t.Opt(t.Nat16),token_name:t.Opt(t.Text),feature_flags:t.Opt(_)}),g=t.Record({decimals:t.Opt(t.Nat8),token_symbol:t.Text,transfer_fee:t.Nat,metadata:t.Vec(t.Tuple(t.Text,o)),minting_account:c,initial_balances:t.Vec(t.Tuple(c,t.Nat)),maximum_number_of_accounts:t.Opt(t.Nat64),accounts_overflow_trim_quantity:t.Opt(t.Nat64),fee_collector_account:t.Opt(c),archive_options:t.Record({num_blocks_to_archive:t.Nat64,max_transactions_per_response:t.Opt(t.Nat64),trigger_threshold:t.Nat64,more_controller_ids:t.Opt(t.Vec(t.Principal)),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(_)}),T=t.Variant({Upgrade:t.Opt(O),Init:g}),i=t.Nat,u=t.Record({block_range_end:i,canister_id:t.Principal,block_range_start:i}),d=t.Record({start:i,length:t.Nat}),V=t.Vec(t.Tuple(t.Text,r));r.fill(t.Variant({Int:t.Int,Map:V,Nat:t.Nat,Nat64:t.Nat64,Blob:t.Vec(t.Nat8),Text:t.Text,Array:t.Vec(r)}));let R=r,b=t.Record({blocks:t.Vec(R)}),A=t.Func([d],[b],["query"]),h=t.Record({certificate:t.Opt(t.Vec(t.Nat8)),first_index:i,blocks:t.Vec(R),chain_length:t.Nat64,archived_blocks:t.Vec(t.Record({callback:A,start:i,length:t.Nat}))}),F=t.Record({certificate:t.Opt(t.Vec(t.Nat8)),hash_tree:t.Vec(t.Nat8)}),x=t.Nat,y=t.Record({start:x,length:t.Nat}),s=t.Nat64,v=t.Record({from:c,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(s),amount:t.Nat,spender:t.Opt(c)}),Q=t.Record({to:c,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(s),amount:t.Nat}),H=t.Record({fee:t.Opt(t.Nat),from:c,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(s),amount:t.Nat,expected_allowance:t.Opt(t.Nat),expires_at:t.Opt(s),spender:c}),W=t.Record({to:c,fee:t.Opt(t.Nat),from:c,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(s),amount:t.Nat,spender:t.Opt(c)}),B=t.Record({burn:t.Opt(v),kind:t.Text,mint:t.Opt(Q),approve:t.Opt(H),timestamp:s,transfer:t.Opt(W)}),Z=t.Record({transactions:t.Vec(B)}),$=t.Func([y],[Z],["query"]),X=t.Record({first_index:x,log_length:t.Nat,transactions:t.Vec(B),archived_transactions:t.Vec(t.Record({callback:$,start:x,length:t.Nat}))}),p=t.Nat,j=t.Record({url:t.Text,name:t.Text}),Y=t.Record({to:c,fee:t.Opt(p),memo:t.Opt(t.Vec(t.Nat8)),from_subaccount:t.Opt(l),created_at_time:t.Opt(s),amount:p}),J=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:s}),TooOld:t.Null,InsufficientFunds:t.Record({balance:p})}),K=t.Variant({Ok:i,Err:J}),I=t.Record({account:c,spender:c}),L=t.Record({allowance:t.Nat,expires_at:t.Opt(s)}),D=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(s),amount:t.Nat,expected_allowance:t.Opt(t.Nat),expires_at:t.Opt(s),spender:c}),tt=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:s}),TooOld:t.Null,Expired:t.Record({ledger_time:s}),InsufficientFunds:t.Record({balance:t.Nat})}),et=t.Variant({Ok:i,Err:tt}),rt=t.Record({to:c,fee:t.Opt(p),spender_subaccount:t.Opt(l),from:c,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(s),amount:p}),ct=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:s}),TooOld:t.Null,InsufficientFunds:t.Record({balance:p})}),at=t.Variant({Ok:i,Err:ct}),ot=t.Record({from:t.Opt(t.Principal)}),nt=t.Vec(t.Record({end:t.Nat,canister_id:t.Principal,start:t.Nat}));e.fill(t.Variant({Int:t.Int,Map:t.Vec(t.Tuple(t.Text,e)),Nat:t.Nat,Blob:t.Vec(t.Nat8),Text:t.Text,Array:t.Vec(e)})),a.fill(t.Record({log_length:t.Nat,blocks:t.Vec(t.Record({id:t.Nat,block:e})),archived_blocks:t.Vec(t.Record({args:t.Vec(d),callback:t.Func([t.Vec(d)],[a],["query"])}))}));let st=t.Record({certificate:t.Vec(t.Nat8),hash_tree:t.Vec(t.Nat8)});return t.Service({archives:t.Func([],[t.Vec(u)],["query"]),get_blocks:t.Func([d],[h],["query"]),get_data_certificate:t.Func([],[F],["query"]),get_transactions:t.Func([y],[X],["query"]),icrc1_balance_of:t.Func([c],[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,o))],["query"]),icrc1_minting_account:t.Func([],[t.Opt(c)],["query"]),icrc1_name:t.Func([],[t.Text],["query"]),icrc1_supported_standards:t.Func([],[t.Vec(j)],["query"]),icrc1_symbol:t.Func([],[t.Text],["query"]),icrc1_total_supply:t.Func([],[p],["query"]),icrc1_transfer:t.Func([Y],[K],[]),icrc2_allowance:t.Func([I],[L],["query"]),icrc2_approve:t.Func([D],[et],[]),icrc2_transfer_from:t.Func([rt],[at],[]),icrc3_get_archives:t.Func([ot],[nt],["query"]),icrc3_get_blocks:t.Func([t.Vec(d)],[a],["query"]),icrc3_get_tip_certificate:t.Func([],[t.Opt(st)],["query"]),icrc3_supported_block_types:t.Func([],[t.Vec(t.Record({url:t.Text,block_type:t.Text}))],["query"])})};var m=require("@dfinity/utils"),gt=({from_subaccount:t,fee:a,created_at_time:e,memo:r,...n})=>({...n,fee:(0,m.toNullable)(a),memo:(0,m.toNullable)(r),from_subaccount:(0,m.toNullable)(t),created_at_time:(0,m.toNullable)(e)}),xt=({spender_subaccount:t,fee:a,created_at_time:e,memo:r,...n})=>({...n,fee:(0,m.toNullable)(a),memo:(0,m.toNullable)(r),spender_subaccount:(0,m.toNullable)(t),created_at_time:(0,m.toNullable)(e)}),Tt=({fee:t,created_at_time:a,memo:e,from_subaccount:r,expected_allowance:n,expires_at:o,...l})=>({...l,fee:(0,m.toNullable)(t),memo:(0,m.toNullable)(e),from_subaccount:(0,m.toNullable)(r),created_at_time:(0,m.toNullable)(a),expected_allowance:(0,m.toNullable)(n),expires_at:(0,m.toNullable)(o)});var M=class t extends w.Canister{constructor(){super(...arguments);this.metadata=e=>this.caller(e).icrc1_metadata();this.transactionFee=e=>this.caller(e).icrc1_fee();this.balance=e=>this.caller({certified:e.certified}).icrc1_balance_of({owner:e.owner,subaccount:(0,w.toNullable)(e.subaccount)});this.transfer=async e=>{let r=await this.caller({certified:!0}).icrc1_transfer(gt(e));if("Err"in r)throw new P({errorType:r.Err,msg:"Failed to transfer"});return r.Ok};this.totalTokensSupply=e=>this.caller(e).icrc1_total_supply();this.transferFrom=async e=>{let r=await this.caller({certified:!0}).icrc2_transfer_from(xt(e));if("Err"in r)throw new P({errorType:r.Err,msg:"Failed to transfer from"});return r.Ok};this.approve=async e=>{let r=await this.caller({certified:!0}).icrc2_approve(Tt(e));if("Err"in r)throw new P({errorType:r.Err,msg:"Failed to entitle the spender to transfer the amount"});return r.Ok};this.allowance=async e=>{let{certified:r,...n}=e;return this.caller({certified:r}).icrc2_allowance({...n})}}static create(e){let{service:r,certifiedService:n,canisterId:o}=(0,w.createServices)({options:e,idlFactory:Ot,certifiedIdlFactory:ft});return new t(o,r,n)}};var Rt=(o=>(o.SYMBOL="icrc1:symbol",o.NAME="icrc1:name",o.DECIMALS="icrc1:decimals",o.FEE="icrc1:fee",o.LOGO="icrc1:logo",o))(Rt||{});var lt=require("@dfinity/principal"),N=require("@dfinity/utils"),Pt=64,wt=({owner:t,subaccount:a})=>{if((0,N.isNullish)(a))return t.toText();let r=(n=>n.replace(/^0+/,""))((0,N.uint8ArrayToHexString)(Uint8Array.from(a)));return r.length===0?t.toText():`${t.toText()}-${yt({owner:t,subaccount:a})}.${r}`},yt=({owner:t,subaccount:a})=>{let e=(0,N.bigEndianCrc32)(Uint8Array.from([...t.toUint8Array(),...a]));return(0,N.encodeBase32)(e)},Bt=t=>{let[a,e]=t.split(".");if(!(0,N.notEmptyString)(a))throw new Error("Invalid account. No string provided.");if((0,N.isNullish)(e))return{owner:lt.Principal.fromText(t)};let[r,...n]=a.split("-").reverse(),o=n.reverse().join("-"),l={owner:lt.Principal.fromText(o),subaccount:(0,N.hexStringToUint8Array)(e.padStart(Pt,"0"))};if(yt(l)!==r)throw new Error("Invalid account. Invalid checksum.");return l};var z=require("@dfinity/utils"),St=t=>{let a=/^([a-zA-Z]+):([A-Za-z0-9:\-.]+).*?(?:[?&](?:amount|value)=(\d+(?:\.\d+)?))?$/,e=t.match(a);if((0,z.isNullish)(e))return;let[r,n,o,l]=e;return{token:n,identifier:o,...(0,z.nonNullish)(l)&&!isNaN(parseFloat(l))&&{amount:parseFloat(l)}}};0&&(module.exports={IcrcIndexCanister,IcrcIndexNgCanister,IcrcLedgerCanister,IcrcMetadataResponseEntries,IcrcTransferError,IndexError,decodeIcrcAccount,decodePayment,encodeIcrcAccount});
2
2
  //# sourceMappingURL=index.cjs.js.map