@dfinity/ledger-icrc 2.3.0 → 2.3.1

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.
@@ -1,4 +1,4 @@
1
- // Generated from IC repo commit c0dc8b76c4 (2024-03-25) 'rs/rosetta-api/icrc1/index-ng/index-ng.did' by import-candid
1
+ // Generated from IC repo commit 9866a6f (2024-04-24 tags: release-2024-05-09_23-02-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,4 @@
1
- // Generated from IC repo commit c0dc8b76c4 (2024-03-25) 'rs/rosetta-api/icrc1/index/index.did' by import-candid
1
+ // Generated from IC repo commit 9866a6f (2024-04-24 tags: release-2024-05-09_23-02-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))),
@@ -64,6 +64,16 @@ export interface Burn {
64
64
  amount: bigint;
65
65
  spender: [] | [Account];
66
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
+ }
67
77
  export type ChangeFeeCollector = { SetTo: Account } | { Unset: null };
68
78
  export interface DataCertificate {
69
79
  certificate: [] | [Uint8Array | number[]];
@@ -73,6 +83,14 @@ export type Duration = bigint;
73
83
  export interface FeatureFlags {
74
84
  icrc2: boolean;
75
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
+ }>;
76
94
  export interface GetBlocksArgs {
77
95
  start: BlockIndex;
78
96
  length: bigint;
@@ -88,6 +106,14 @@ export interface GetBlocksResponse {
88
106
  length: bigint;
89
107
  }>;
90
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
+ }
91
117
  export interface GetTransactionsRequest {
92
118
  start: TxIndex;
93
119
  length: bigint;
@@ -113,6 +139,17 @@ export interface HttpResponse {
113
139
  headers: Array<[string, string]>;
114
140
  status_code: number;
115
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> };
116
153
  export interface InitArgs {
117
154
  decimals: [] | [number];
118
155
  token_symbol: string;
@@ -228,6 +265,7 @@ export type TransferFromResult =
228
265
  export type TransferResult = { Ok: BlockIndex } | { Err: TransferError };
229
266
  export type TxIndex = bigint;
230
267
  export interface UpgradeArgs {
268
+ change_archive_options: [] | [ChangeArchiveOptions];
231
269
  token_symbol: [] | [string];
232
270
  transfer_fee: [] | [bigint];
233
271
  metadata: [] | [Array<[string, MetadataValue]>];
@@ -267,6 +305,13 @@ export interface _SERVICE {
267
305
  icrc2_allowance: ActorMethod<[AllowanceArgs], Allowance>;
268
306
  icrc2_approve: ActorMethod<[ApproveArgs], ApproveResult>;
269
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
+ >;
270
315
  }
271
316
  export declare const idlFactory: IDL.InterfaceFactory;
272
317
  export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[];
@@ -1,4 +1,4 @@
1
- // Generated from IC repo commit c0dc8b76c4 (2024-03-25) 'rs/rosetta-api/icrc1/ledger/ledger.did' by import-candid
1
+ // Generated from IC repo commit 9866a6f (2024-04-24 tags: release-2024-05-09_23-02-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 gt=Object.getOwnPropertyDescriptor;var Ot=Object.getOwnPropertyNames;var xt=Object.prototype.hasOwnProperty;var Tt=(t,a)=>{for(var e in a)rt(t,e,{get:a[e],enumerable:!0})},Rt=(t,a,e,c)=>{if(a&&typeof a=="object"||typeof a=="function")for(let r of Ot(a))!xt.call(t,r)&&r!==e&&rt(t,r,{get:()=>a[r],enumerable:!(c=gt(a,r))||c.enumerable});return t};var yt=t=>Rt(rt({},"__esModule",{value:!0}),t);var kt={};Tt(kt,{IcrcIndexCanister:()=>q,IcrcIndexNgCanister:()=>C,IcrcLedgerCanister:()=>M,IcrcMetadataResponseEntries:()=>ft,IcrcTransferError:()=>P,IndexError:()=>v,decodeIcrcAccount:()=>Ft,decodePayment:()=>ht,encodeIcrcAccount:()=>bt});module.exports=yt(kt);var v=class extends Error{};var P=class extends Error{constructor({msg:a,errorType:e}){super(a),this.errorType=e}};var st=require("@dfinity/utils");var ot=({IDL:t})=>{let a=t.Rec(),e=t.Record({ledger_id:t.Opt(t.Principal)}),c=t.Record({ledger_id:t.Principal}),r=t.Variant({Upgrade:e,Init:c}),o=t.Nat,d=t.Vec(t.Nat8),s=t.Record({owner:t.Principal,subaccount:t.Opt(d)}),f=t.Record({max_results:t.Nat,start:t.Opt(o),account:s}),N=t.Nat,i=t.Record({from:s,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,spender:t.Opt(s)}),g=t.Record({to:s,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat}),u=t.Record({fee:t.Opt(t.Nat),from:s,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,expected_allowance:t.Opt(t.Nat),expires_at:t.Opt(t.Nat64),spender:s}),O=t.Record({to:s,fee:t.Opt(t.Nat),from:s,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,spender:t.Opt(s)}),l=t.Record({burn:t.Opt(i),kind:t.Text,mint:t.Opt(g),approve:t.Opt(u),timestamp:t.Nat64,transfer:t.Opt(O)}),x=t.Record({id:o,transaction:l}),y=t.Record({balance:N,transactions:t.Vec(x),oldest_tx_id:t.Opt(o)}),V=t.Record({message:t.Text}),A=t.Variant({Ok:y,Err:V}),T=t.Record({start:t.Nat,length:t.Nat}),R=t.Vec(t.Tuple(t.Text,a));a.fill(t.Variant({Int:t.Int,Map:R,Nat:t.Nat,Nat64:t.Nat64,Blob:t.Vec(t.Nat8),Text:t.Text,Array:t.Vec(a)}));let n=a,b=t.Record({blocks:t.Vec(n),chain_length:t.Nat64}),F=t.Record({ranges:t.Vec(t.Tuple(s,t.Vec(t.Tuple(o,o))))}),h=t.Record({owner:t.Principal,start:t.Opt(d)}),k=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([h],[t.Vec(d)],[]),status:t.Func([],[k],[])})};var nt=({IDL:t})=>{let a=t.Rec(),e=t.Record({ledger_id:t.Opt(t.Principal)}),c=t.Record({ledger_id:t.Principal}),r=t.Variant({Upgrade:e,Init:c}),o=t.Nat,d=t.Vec(t.Nat8),s=t.Record({owner:t.Principal,subaccount:t.Opt(d)}),f=t.Record({max_results:t.Nat,start:t.Opt(o),account:s}),N=t.Nat,i=t.Record({from:s,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,spender:t.Opt(s)}),g=t.Record({to:s,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat}),u=t.Record({fee:t.Opt(t.Nat),from:s,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,expected_allowance:t.Opt(t.Nat),expires_at:t.Opt(t.Nat64),spender:s}),O=t.Record({to:s,fee:t.Opt(t.Nat),from:s,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat,spender:t.Opt(s)}),l=t.Record({burn:t.Opt(i),kind:t.Text,mint:t.Opt(g),approve:t.Opt(u),timestamp:t.Nat64,transfer:t.Opt(O)}),x=t.Record({id:o,transaction:l}),y=t.Record({balance:N,transactions:t.Vec(x),oldest_tx_id:t.Opt(o)}),V=t.Record({message:t.Text}),A=t.Variant({Ok:y,Err:V}),T=t.Record({start:t.Nat,length:t.Nat}),R=t.Vec(t.Tuple(t.Text,a));a.fill(t.Variant({Int:t.Int,Map:R,Nat:t.Nat,Nat64:t.Nat64,Blob:t.Vec(t.Nat8),Text:t.Text,Array:t.Vec(a)}));let n=a,b=t.Record({blocks:t.Vec(n),chain_length:t.Nat64}),F=t.Record({ranges:t.Vec(t.Tuple(s,t.Vec(t.Tuple(o,o))))}),h=t.Record({owner:t.Principal,start:t.Opt(d)}),k=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([h],[t.Vec(d)],["query"]),status:t.Func([],[k],["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 ct=require("@dfinity/utils"),Vt=({owner:t,subaccount:a})=>({owner:t,subaccount:(0,ct.toNullable)(a)}),G=({account:t,max_results:a,start:e})=>({account:Vt(t),max_results:a,start:(0,ct.toNullable)(e)});var C=class t extends S{constructor(){super(...arguments);this.getTransactions=async({certified:e,...c})=>{let r=await this.caller({certified:e}).get_account_transactions(G(c));if("Err"in r)throw new v(r.Err.message);return r.Ok};this.ledgerId=e=>{let{ledger_id:c}=this.caller(e);return c()}}static create(e){let{service:c,certifiedService:r,canisterId:o}=(0,st.createServices)({options:e,idlFactory:nt,certifiedIdlFactory:ot});return new t(o,c,r)}};var U=require("@dfinity/utils");var it=({IDL:t})=>{let a=t.Record({ledger_id:t.Principal}),e=t.Nat,c=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),r=t.Record({max_results:t.Nat,start:t.Opt(e),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:e,transaction:N}),g=t.Record({transactions:t.Vec(i),oldest_tx_id:t.Opt(e)}),u=t.Record({message:t.Text}),O=t.Variant({Ok:g,Err:u}),l=t.Vec(t.Nat8),x=t.Record({owner:t.Principal,start:t.Opt(l)});return t.Service({get_account_transactions:t.Func([r],[O],[]),ledger_id:t.Func([],[t.Principal],[]),list_subaccounts:t.Func([x],[t.Vec(l)],[])})};var pt=({IDL:t})=>{let a=t.Record({ledger_id:t.Principal}),e=t.Nat,c=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),r=t.Record({max_results:t.Nat,start:t.Opt(e),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:e,transaction:N}),g=t.Record({transactions:t.Vec(i),oldest_tx_id:t.Opt(e)}),u=t.Record({message:t.Text}),O=t.Variant({Ok:g,Err:u}),l=t.Vec(t.Nat8),x=t.Record({owner:t.Principal,start:t.Opt(l)});return t.Service({get_account_transactions:t.Func([r],[O],[]),ledger_id:t.Func([],[t.Principal],["query"]),list_subaccounts:t.Func([x],[t.Vec(l)],["query"])})};var q=class t extends U.Canister{constructor(){super(...arguments);this.getTransactions=async e=>{let c=await this.caller({certified:!0}).get_account_transactions(G(e));if("Err"in c)throw new v(c.Err.message);return c.Ok}}static create(e){let{service:c,certifiedService:r,canisterId:o}=(0,U.createServices)({options:e,idlFactory:pt,certifiedIdlFactory:it});return new t(o,c,r)}};var w=require("@dfinity/utils");var dt=({IDL:t})=>{let a=t.Rec(),e=t.Variant({Int:t.Int,Nat:t.Nat,Blob:t.Vec(t.Nat8),Text:t.Text}),c=t.Vec(t.Nat8),r=t.Record({owner:t.Principal,subaccount:t.Opt(c)}),o=t.Variant({SetTo:r,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,e))),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,e)),minting_account:r,initial_balances:t.Vec(t.Tuple(r,t.Nat)),maximum_number_of_accounts:t.Opt(t.Nat64),accounts_overflow_trim_quantity:t.Opt(t.Nat64),fee_collector_account:t.Opt(r),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,g=t.Record({block_range_end:i,canister_id:t.Principal,block_range_start:i}),u=t.Record({start:i,length:t.Nat}),O=t.Vec(t.Tuple(t.Text,a));a.fill(t.Variant({Int:t.Int,Map:O,Nat:t.Nat,Nat64:t.Nat64,Blob:t.Vec(t.Nat8),Text:t.Text,Array:t.Vec(a)}));let l=a,x=t.Record({blocks:t.Vec(l)}),y=t.Func([u],[x],[]),V=t.Record({certificate:t.Opt(t.Vec(t.Nat8)),first_index:i,blocks:t.Vec(l),chain_length:t.Nat64,archived_blocks:t.Vec(t.Record({callback:y,start:i,length:t.Nat}))}),A=t.Record({certificate:t.Opt(t.Vec(t.Nat8)),hash_tree:t.Vec(t.Nat8)}),T=t.Nat,R=t.Record({start:T,length:t.Nat}),n=t.Nat64,b=t.Record({from:r,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(n),amount:t.Nat,spender:t.Opt(r)}),F=t.Record({to:r,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(n),amount:t.Nat}),h=t.Record({fee:t.Opt(t.Nat),from:r,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:r}),k=t.Record({to:r,fee:t.Opt(t.Nat),from:r,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(n),amount:t.Nat,spender:t.Opt(r)}),B=t.Record({burn:t.Opt(b),kind:t.Text,mint:t.Opt(F),approve:t.Opt(h),timestamp:n,transfer:t.Opt(k)}),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:r,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:r,spender:r}),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:r}),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:r,fee:t.Opt(p),spender_subaccount:t.Opt(c),from:r,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(n),amount:p}),tt=t.Variant({GenericError:t.Record({message:t.Text,error_code:t.Nat}),TemporarilyUnavailable:t.Null,InsufficientAllowance:t.Record({allowance:p}),BadBurn:t.Record({min_burn_amount:p}),Duplicate:t.Record({duplicate_of:i}),BadFee:t.Record({expected_fee:p}),CreatedInFuture:t.Record({ledger_time:n}),TooOld:t.Null,InsufficientFunds:t.Record({balance:p})}),et=t.Variant({Ok:i,Err:tt});return t.Service({archives:t.Func([],[t.Vec(g)],[]),get_blocks:t.Func([u],[V],[]),get_data_certificate:t.Func([],[A],[]),get_transactions:t.Func([R],[W],[]),icrc1_balance_of:t.Func([r],[p],[]),icrc1_decimals:t.Func([],[t.Nat8],[]),icrc1_fee:t.Func([],[p],[]),icrc1_metadata:t.Func([],[t.Vec(t.Tuple(t.Text,e))],[]),icrc1_minting_account:t.Func([],[t.Opt(r)],[]),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(),e=t.Variant({Int:t.Int,Nat:t.Nat,Blob:t.Vec(t.Nat8),Text:t.Text}),c=t.Vec(t.Nat8),r=t.Record({owner:t.Principal,subaccount:t.Opt(c)}),o=t.Variant({SetTo:r,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,e))),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,e)),minting_account:r,initial_balances:t.Vec(t.Tuple(r,t.Nat)),maximum_number_of_accounts:t.Opt(t.Nat64),accounts_overflow_trim_quantity:t.Opt(t.Nat64),fee_collector_account:t.Opt(r),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,g=t.Record({block_range_end:i,canister_id:t.Principal,block_range_start:i}),u=t.Record({start:i,length:t.Nat}),O=t.Vec(t.Tuple(t.Text,a));a.fill(t.Variant({Int:t.Int,Map:O,Nat:t.Nat,Nat64:t.Nat64,Blob:t.Vec(t.Nat8),Text:t.Text,Array:t.Vec(a)}));let l=a,x=t.Record({blocks:t.Vec(l)}),y=t.Func([u],[x],["query"]),V=t.Record({certificate:t.Opt(t.Vec(t.Nat8)),first_index:i,blocks:t.Vec(l),chain_length:t.Nat64,archived_blocks:t.Vec(t.Record({callback:y,start:i,length:t.Nat}))}),A=t.Record({certificate:t.Opt(t.Vec(t.Nat8)),hash_tree:t.Vec(t.Nat8)}),T=t.Nat,R=t.Record({start:T,length:t.Nat}),n=t.Nat64,b=t.Record({from:r,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(n),amount:t.Nat,spender:t.Opt(r)}),F=t.Record({to:r,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(n),amount:t.Nat}),h=t.Record({fee:t.Opt(t.Nat),from:r,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:r}),k=t.Record({to:r,fee:t.Opt(t.Nat),from:r,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(n),amount:t.Nat,spender:t.Opt(r)}),B=t.Record({burn:t.Opt(b),kind:t.Text,mint:t.Opt(F),approve:t.Opt(h),timestamp:n,transfer:t.Opt(k)}),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:r,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:r,spender:r}),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:r}),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:r,fee:t.Opt(p),spender_subaccount:t.Opt(c),from:r,memo:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(n),amount:p}),tt=t.Variant({GenericError:t.Record({message:t.Text,error_code:t.Nat}),TemporarilyUnavailable:t.Null,InsufficientAllowance:t.Record({allowance:p}),BadBurn:t.Record({min_burn_amount:p}),Duplicate:t.Record({duplicate_of:i}),BadFee:t.Record({expected_fee:p}),CreatedInFuture:t.Record({ledger_time:n}),TooOld:t.Null,InsufficientFunds:t.Record({balance:p})}),et=t.Variant({Ok:i,Err:tt});return t.Service({archives:t.Func([],[t.Vec(g)],["query"]),get_blocks:t.Func([u],[V],["query"]),get_data_certificate:t.Func([],[A],["query"]),get_transactions:t.Func([R],[W],["query"]),icrc1_balance_of:t.Func([r],[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,e))],["query"]),icrc1_minting_account:t.Func([],[t.Opt(r)],["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:e,memo:c,...r})=>({...r,fee:(0,m.toNullable)(a),memo:(0,m.toNullable)(c),from_subaccount:(0,m.toNullable)(t),created_at_time:(0,m.toNullable)(e)}),ut=({spender_subaccount:t,fee:a,created_at_time:e,memo:c,...r})=>({...r,fee:(0,m.toNullable)(a),memo:(0,m.toNullable)(c),spender_subaccount:(0,m.toNullable)(t),created_at_time:(0,m.toNullable)(e)}),_t=({fee:t,created_at_time:a,memo:e,from_subaccount:c,expected_allowance:r,expires_at:o,...d})=>({...d,fee:(0,m.toNullable)(t),memo:(0,m.toNullable)(e),from_subaccount:(0,m.toNullable)(c),created_at_time:(0,m.toNullable)(a),expected_allowance:(0,m.toNullable)(r),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 c=await this.caller({certified:!0}).icrc1_transfer(mt(e));if("Err"in c)throw new P({errorType:c.Err,msg:"Failed to transfer"});return c.Ok};this.totalTokensSupply=e=>this.caller(e).icrc1_total_supply();this.transferFrom=async e=>{let c=await this.caller({certified:!0}).icrc2_transfer_from(ut(e));if("Err"in c)throw new P({errorType:c.Err,msg:"Failed to transfer from"});return c.Ok};this.approve=async e=>{let c=await this.caller({certified:!0}).icrc2_approve(_t(e));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 e=>{let{certified:c,...r}=e;return this.caller({certified:c}).icrc2_allowance({...r})}}static create(e){let{service:c,certifiedService:r,canisterId:o}=(0,w.createServices)({options:e,idlFactory:lt,certifiedIdlFactory:dt});return new t(o,c,r)}};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=(r=>r.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 e=(0,_.bigEndianCrc32)(Uint8Array.from([...t.toUint8Array(),...a]));return(0,_.encodeBase32)(e)},Ft=t=>{let[a,e]=t.split(".");if(!(0,_.notEmptyString)(a))throw new Error("Invalid account. No string provided.");if((0,_.isNullish)(e))return{owner:at.Principal.fromText(t)};let[c,...r]=a.split("-").reverse(),o=r.reverse().join("-"),d={owner:at.Principal.fromText(o),subaccount:(0,_.hexStringToUint8Array)(e.padStart(At,"0"))};if(Nt(d)!==c)throw new Error("Invalid account. Invalid checksum.");return d};var z=require("@dfinity/utils"),ht=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[c,r,o,d]=e;return{token:r,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