@dfinity/ledger-icrc 2.3.3 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- // Generated from IC repo commit d19fa44 (2024-06-05 tags: release-2024-06-05_23-01-base) 'rs/rosetta-api/icrc1/index-ng/index-ng.did' by import-candid
1
+ // Generated from IC repo commit a3831c8 (2024-07-11 tags: release-2024-07-10_23-01-base) '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 d19fa44 (2024-06-05 tags: release-2024-06-05_23-01-base) 'rs/rosetta-api/icrc1/index/index.did' by import-candid
1
+ // Generated from IC repo commit a3831c8 (2024-07-11 tags: release-2024-07-10_23-01-base) '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 };
@@ -204,6 +204,51 @@ export const idlFactory = ({ IDL }) => {
204
204
  'Ok' : BlockIndex,
205
205
  'Err' : TransferError,
206
206
  });
207
+ const icrc21_consent_message_metadata = IDL.Record({
208
+ 'utc_offset_minutes' : IDL.Opt(IDL.Int16),
209
+ 'language' : IDL.Text,
210
+ });
211
+ const icrc21_consent_message_spec = IDL.Record({
212
+ 'metadata' : icrc21_consent_message_metadata,
213
+ 'device_spec' : IDL.Opt(
214
+ IDL.Variant({
215
+ 'GenericDisplay' : IDL.Null,
216
+ 'LineDisplay' : IDL.Record({
217
+ 'characters_per_line' : IDL.Nat16,
218
+ 'lines_per_page' : IDL.Nat16,
219
+ }),
220
+ })
221
+ ),
222
+ });
223
+ const icrc21_consent_message_request = IDL.Record({
224
+ 'arg' : IDL.Vec(IDL.Nat8),
225
+ 'method' : IDL.Text,
226
+ 'user_preferences' : icrc21_consent_message_spec,
227
+ });
228
+ const icrc21_consent_message = IDL.Variant({
229
+ 'LineDisplayMessage' : IDL.Record({
230
+ 'pages' : IDL.Vec(IDL.Record({ 'lines' : IDL.Vec(IDL.Text) })),
231
+ }),
232
+ 'GenericDisplayMessage' : IDL.Text,
233
+ });
234
+ const icrc21_consent_info = IDL.Record({
235
+ 'metadata' : icrc21_consent_message_metadata,
236
+ 'consent_message' : icrc21_consent_message,
237
+ });
238
+ const icrc21_error_info = IDL.Record({ 'description' : IDL.Text });
239
+ const icrc21_error = IDL.Variant({
240
+ 'GenericError' : IDL.Record({
241
+ 'description' : IDL.Text,
242
+ 'error_code' : IDL.Nat,
243
+ }),
244
+ 'InsufficientPayment' : icrc21_error_info,
245
+ 'UnsupportedCanisterCall' : icrc21_error_info,
246
+ 'ConsentMessageUnavailable' : icrc21_error_info,
247
+ });
248
+ const icrc21_consent_message_response = IDL.Variant({
249
+ 'Ok' : icrc21_consent_info,
250
+ 'Err' : icrc21_error,
251
+ });
207
252
  const AllowanceArgs = IDL.Record({
208
253
  'account' : Account,
209
254
  'spender' : Account,
@@ -314,6 +359,11 @@ export const idlFactory = ({ IDL }) => {
314
359
  [GetTransactionsResponse],
315
360
  [],
316
361
  ),
362
+ 'icrc10_supported_standards' : IDL.Func(
363
+ [],
364
+ [IDL.Vec(IDL.Record({ 'url' : IDL.Text, 'name' : IDL.Text }))],
365
+ [],
366
+ ),
317
367
  'icrc1_balance_of' : IDL.Func([Account], [Tokens], []),
318
368
  'icrc1_decimals' : IDL.Func([], [IDL.Nat8], []),
319
369
  'icrc1_fee' : IDL.Func([], [Tokens], []),
@@ -328,6 +378,11 @@ export const idlFactory = ({ IDL }) => {
328
378
  'icrc1_symbol' : IDL.Func([], [IDL.Text], []),
329
379
  'icrc1_total_supply' : IDL.Func([], [Tokens], []),
330
380
  'icrc1_transfer' : IDL.Func([TransferArg], [TransferResult], []),
381
+ 'icrc21_canister_call_consent_message' : IDL.Func(
382
+ [icrc21_consent_message_request],
383
+ [icrc21_consent_message_response],
384
+ [],
385
+ ),
331
386
  'icrc2_allowance' : IDL.Func([AllowanceArgs], [Allowance], []),
332
387
  'icrc2_approve' : IDL.Func([ApproveArgs], [ApproveResult], []),
333
388
  'icrc2_transfer_from' : IDL.Func(
@@ -284,6 +284,51 @@ export type Value =
284
284
  | { Blob: Uint8Array | number[] }
285
285
  | { Text: string }
286
286
  | { Array: Array<Value> };
287
+ export interface icrc21_consent_info {
288
+ metadata: icrc21_consent_message_metadata;
289
+ consent_message: icrc21_consent_message;
290
+ }
291
+ export type icrc21_consent_message =
292
+ | {
293
+ LineDisplayMessage: { pages: Array<{ lines: Array<string> }> };
294
+ }
295
+ | { GenericDisplayMessage: string };
296
+ export interface icrc21_consent_message_metadata {
297
+ utc_offset_minutes: [] | [number];
298
+ language: string;
299
+ }
300
+ export interface icrc21_consent_message_request {
301
+ arg: Uint8Array | number[];
302
+ method: string;
303
+ user_preferences: icrc21_consent_message_spec;
304
+ }
305
+ export type icrc21_consent_message_response =
306
+ | { Ok: icrc21_consent_info }
307
+ | { Err: icrc21_error };
308
+ export interface icrc21_consent_message_spec {
309
+ metadata: icrc21_consent_message_metadata;
310
+ device_spec:
311
+ | []
312
+ | [
313
+ | { GenericDisplay: null }
314
+ | {
315
+ LineDisplay: {
316
+ characters_per_line: number;
317
+ lines_per_page: number;
318
+ };
319
+ },
320
+ ];
321
+ }
322
+ export type icrc21_error =
323
+ | {
324
+ GenericError: { description: string; error_code: bigint };
325
+ }
326
+ | { InsufficientPayment: icrc21_error_info }
327
+ | { UnsupportedCanisterCall: icrc21_error_info }
328
+ | { ConsentMessageUnavailable: icrc21_error_info };
329
+ export interface icrc21_error_info {
330
+ description: string;
331
+ }
287
332
  export interface _SERVICE {
288
333
  archives: ActorMethod<[], Array<ArchiveInfo>>;
289
334
  get_blocks: ActorMethod<[GetBlocksArgs], GetBlocksResponse>;
@@ -292,6 +337,10 @@ export interface _SERVICE {
292
337
  [GetTransactionsRequest],
293
338
  GetTransactionsResponse
294
339
  >;
340
+ icrc10_supported_standards: ActorMethod<
341
+ [],
342
+ Array<{ url: string; name: string }>
343
+ >;
295
344
  icrc1_balance_of: ActorMethod<[Account], Tokens>;
296
345
  icrc1_decimals: ActorMethod<[], number>;
297
346
  icrc1_fee: ActorMethod<[], Tokens>;
@@ -302,6 +351,10 @@ export interface _SERVICE {
302
351
  icrc1_symbol: ActorMethod<[], string>;
303
352
  icrc1_total_supply: ActorMethod<[], Tokens>;
304
353
  icrc1_transfer: ActorMethod<[TransferArg], TransferResult>;
354
+ icrc21_canister_call_consent_message: ActorMethod<
355
+ [icrc21_consent_message_request],
356
+ icrc21_consent_message_response
357
+ >;
305
358
  icrc2_allowance: ActorMethod<[AllowanceArgs], Allowance>;
306
359
  icrc2_approve: ActorMethod<[ApproveArgs], ApproveResult>;
307
360
  icrc2_transfer_from: ActorMethod<[TransferFromArgs], TransferFromResult>;
@@ -1,4 +1,4 @@
1
- // Generated from IC repo commit d19fa44 (2024-06-05 tags: release-2024-06-05_23-01-base) 'rs/rosetta-api/icrc1/ledger/ledger.did' by import-candid
1
+ // Generated from IC repo commit a3831c8 (2024-07-11 tags: release-2024-07-10_23-01-base) '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.
@@ -426,6 +426,63 @@ type ICRC3DataCertificate = record {
426
426
  hash_tree : blob;
427
427
  };
428
428
 
429
+ type icrc21_consent_message_metadata = record {
430
+ language: text;
431
+ utc_offset_minutes: opt int16;
432
+ };
433
+
434
+ type icrc21_consent_message_spec = record {
435
+ metadata: icrc21_consent_message_metadata;
436
+ device_spec: opt variant {
437
+ GenericDisplay;
438
+ LineDisplay: record {
439
+ characters_per_line: nat16;
440
+ lines_per_page: nat16;
441
+ };
442
+ };
443
+ };
444
+
445
+ type icrc21_consent_message_request = record {
446
+ method: text;
447
+ arg: blob;
448
+ user_preferences: icrc21_consent_message_spec;
449
+ };
450
+
451
+ type icrc21_consent_message = variant {
452
+ GenericDisplayMessage: text;
453
+ LineDisplayMessage: record {
454
+ pages: vec record {
455
+ lines: vec text;
456
+ };
457
+ };
458
+ };
459
+
460
+ type icrc21_consent_info = record {
461
+ consent_message: icrc21_consent_message;
462
+ metadata: icrc21_consent_message_metadata;
463
+ };
464
+
465
+ type icrc21_error_info = record {
466
+ description: text;
467
+ };
468
+
469
+ type icrc21_error = variant {
470
+ UnsupportedCanisterCall: icrc21_error_info;
471
+ ConsentMessageUnavailable: icrc21_error_info;
472
+ InsufficientPayment: icrc21_error_info;
473
+
474
+ // Any error not covered by the above variants.
475
+ GenericError: record {
476
+ error_code: nat;
477
+ description: text;
478
+ };
479
+ };
480
+
481
+ type icrc21_consent_message_response = variant {
482
+ Ok: icrc21_consent_info;
483
+ Err: icrc21_error;
484
+ };
485
+
429
486
  service : (ledger_arg : LedgerArg) -> {
430
487
  archives : () -> (vec ArchiveInfo) query;
431
488
  get_transactions : (GetTransactionsRequest) -> (GetTransactionsResponse) query;
@@ -451,4 +508,7 @@ service : (ledger_arg : LedgerArg) -> {
451
508
  icrc3_get_tip_certificate : () -> (opt ICRC3DataCertificate) query;
452
509
  icrc3_get_blocks : (vec GetBlocksArgs) -> (GetBlocksResult) query;
453
510
  icrc3_supported_block_types : () -> (vec record { block_type : text; url : text }) query;
511
+
512
+ icrc21_canister_call_consent_message: (icrc21_consent_message_request) -> (icrc21_consent_message_response);
513
+ icrc10_supported_standards : () -> (vec record { name : text; url : text }) query;
454
514
  }
@@ -208,6 +208,51 @@ export const idlFactory = ({ IDL }) => {
208
208
  'Ok' : BlockIndex,
209
209
  'Err' : TransferError,
210
210
  });
211
+ const icrc21_consent_message_metadata = IDL.Record({
212
+ 'utc_offset_minutes' : IDL.Opt(IDL.Int16),
213
+ 'language' : IDL.Text,
214
+ });
215
+ const icrc21_consent_message_spec = IDL.Record({
216
+ 'metadata' : icrc21_consent_message_metadata,
217
+ 'device_spec' : IDL.Opt(
218
+ IDL.Variant({
219
+ 'GenericDisplay' : IDL.Null,
220
+ 'LineDisplay' : IDL.Record({
221
+ 'characters_per_line' : IDL.Nat16,
222
+ 'lines_per_page' : IDL.Nat16,
223
+ }),
224
+ })
225
+ ),
226
+ });
227
+ const icrc21_consent_message_request = IDL.Record({
228
+ 'arg' : IDL.Vec(IDL.Nat8),
229
+ 'method' : IDL.Text,
230
+ 'user_preferences' : icrc21_consent_message_spec,
231
+ });
232
+ const icrc21_consent_message = IDL.Variant({
233
+ 'LineDisplayMessage' : IDL.Record({
234
+ 'pages' : IDL.Vec(IDL.Record({ 'lines' : IDL.Vec(IDL.Text) })),
235
+ }),
236
+ 'GenericDisplayMessage' : IDL.Text,
237
+ });
238
+ const icrc21_consent_info = IDL.Record({
239
+ 'metadata' : icrc21_consent_message_metadata,
240
+ 'consent_message' : icrc21_consent_message,
241
+ });
242
+ const icrc21_error_info = IDL.Record({ 'description' : IDL.Text });
243
+ const icrc21_error = IDL.Variant({
244
+ 'GenericError' : IDL.Record({
245
+ 'description' : IDL.Text,
246
+ 'error_code' : IDL.Nat,
247
+ }),
248
+ 'InsufficientPayment' : icrc21_error_info,
249
+ 'UnsupportedCanisterCall' : icrc21_error_info,
250
+ 'ConsentMessageUnavailable' : icrc21_error_info,
251
+ });
252
+ const icrc21_consent_message_response = IDL.Variant({
253
+ 'Ok' : icrc21_consent_info,
254
+ 'Err' : icrc21_error,
255
+ });
211
256
  const AllowanceArgs = IDL.Record({
212
257
  'account' : Account,
213
258
  'spender' : Account,
@@ -318,6 +363,11 @@ export const idlFactory = ({ IDL }) => {
318
363
  [GetTransactionsResponse],
319
364
  ['query'],
320
365
  ),
366
+ 'icrc10_supported_standards' : IDL.Func(
367
+ [],
368
+ [IDL.Vec(IDL.Record({ 'url' : IDL.Text, 'name' : IDL.Text }))],
369
+ ['query'],
370
+ ),
321
371
  'icrc1_balance_of' : IDL.Func([Account], [Tokens], ['query']),
322
372
  'icrc1_decimals' : IDL.Func([], [IDL.Nat8], ['query']),
323
373
  'icrc1_fee' : IDL.Func([], [Tokens], ['query']),
@@ -336,6 +386,11 @@ export const idlFactory = ({ IDL }) => {
336
386
  'icrc1_symbol' : IDL.Func([], [IDL.Text], ['query']),
337
387
  'icrc1_total_supply' : IDL.Func([], [Tokens], ['query']),
338
388
  'icrc1_transfer' : IDL.Func([TransferArg], [TransferResult], []),
389
+ 'icrc21_canister_call_consent_message' : IDL.Func(
390
+ [icrc21_consent_message_request],
391
+ [icrc21_consent_message_response],
392
+ [],
393
+ ),
339
394
  'icrc2_allowance' : IDL.Func([AllowanceArgs], [Allowance], ['query']),
340
395
  'icrc2_approve' : IDL.Func([ApproveArgs], [ApproveResult], []),
341
396
  'icrc2_transfer_from' : IDL.Func(
@@ -1,2 +1,2 @@
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})},vt=(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 Ft=t=>vt(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=Ft(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),retrieve_blocks_from_ledger_interval_seconds:t.Opt(t.Nat64)}),r=t.Record({ledger_id:t.Principal,retrieve_blocks_from_ledger_interval_seconds:t.Opt(t.Nat64)}),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 v=a,x=t.Record({blocks:t.Vec(v),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)}),F=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([],[F],[])})};var _t=({IDL:t})=>{let a=t.Rec(),e=t.Record({ledger_id:t.Opt(t.Principal),retrieve_blocks_from_ledger_interval_seconds:t.Opt(t.Nat64)}),r=t.Record({ledger_id:t.Principal,retrieve_blocks_from_ledger_interval_seconds:t.Opt(t.Nat64)}),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 v=a,x=t.Record({blocks:t.Vec(v),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)}),F=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([],[F],["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}))}),v=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,F=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(F),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([],[v],[]),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}))}),v=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,F=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(F),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([],[v],["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});
1
+ "use strict";var fe=Object.defineProperty;var we=Object.getOwnPropertyDescriptor;var Be=Object.getOwnPropertyNames;var Se=Object.prototype.hasOwnProperty;var Ee=(e,a)=>{for(var t in a)fe(e,t,{get:a[t],enumerable:!0})},Ge=(e,a,t,r)=>{if(a&&typeof a=="object"||typeof a=="function")for(let n of Be(a))!Se.call(e,n)&&n!==t&&fe(e,n,{get:()=>a[n],enumerable:!(r=we(a,n))||r.enumerable});return e};var Ce=e=>Ge(fe({},"__esModule",{value:!0}),e);var He={};Ee(He,{IcrcIndexCanister:()=>M,IcrcIndexNgCanister:()=>U,IcrcLedgerCanister:()=>Q,IcrcMetadataResponseEntries:()=>ke,IcrcTransferError:()=>w,IndexError:()=>P,decodeIcrcAccount:()=>ze,decodePayment:()=>Qe,encodeIcrcAccount:()=>Me});module.exports=Ce(He);var P=class extends Error{};var w=class extends Error{constructor({msg:a,errorType:t}){super(a),this.errorType=t}};var Re=require("@dfinity/utils");var xe=({IDL:e})=>{let a=e.Rec(),t=e.Record({ledger_id:e.Opt(e.Principal),retrieve_blocks_from_ledger_interval_seconds:e.Opt(e.Nat64)}),r=e.Record({ledger_id:e.Principal,retrieve_blocks_from_ledger_interval_seconds:e.Opt(e.Nat64)}),n=e.Variant({Upgrade:t,Init:r}),o=e.Nat,l=e.Vec(e.Nat8),c=e.Record({owner:e.Principal,subaccount:e.Opt(l)}),f=e.Record({max_results:e.Nat,start:e.Opt(o),account:c}),d=e.Nat,g=e.Record({from:c,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,spender:e.Opt(c)}),O=e.Record({to:c,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat}),T=e.Record({fee:e.Opt(e.Nat),from:c,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(e.Nat64),spender:c}),i=e.Record({to:c,fee:e.Opt(e.Nat),from:c,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,spender:e.Opt(c)}),u=e.Record({burn:e.Opt(g),kind:e.Text,mint:e.Opt(O),approve:e.Opt(T),timestamp:e.Nat64,transfer:e.Opt(i)}),_=e.Record({id:o,transaction:u}),y=e.Record({balance:d,transactions:e.Vec(_),oldest_tx_id:e.Opt(o)}),R=e.Record({message:e.Text}),b=e.Variant({Ok:y,Err:R}),A=e.Record({start:e.Nat,length:e.Nat}),h=e.Vec(e.Tuple(e.Text,a));a.fill(e.Variant({Int:e.Int,Map:h,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(a)}));let v=a,x=e.Record({blocks:e.Vec(v),chain_length:e.Nat64}),V=e.Record({ranges:e.Vec(e.Tuple(c,e.Vec(e.Tuple(o,o))))}),s=e.Record({owner:e.Principal,start:e.Opt(l)}),F=e.Record({num_blocks_synced:o});return e.Service({get_account_transactions:e.Func([f],[b],[]),get_blocks:e.Func([A],[x],[]),get_fee_collectors_ranges:e.Func([],[V],[]),icrc1_balance_of:e.Func([c],[d],[]),ledger_id:e.Func([],[e.Principal],[]),list_subaccounts:e.Func([s],[e.Vec(l)],[]),status:e.Func([],[F],[])})};var Te=({IDL:e})=>{let a=e.Rec(),t=e.Record({ledger_id:e.Opt(e.Principal),retrieve_blocks_from_ledger_interval_seconds:e.Opt(e.Nat64)}),r=e.Record({ledger_id:e.Principal,retrieve_blocks_from_ledger_interval_seconds:e.Opt(e.Nat64)}),n=e.Variant({Upgrade:t,Init:r}),o=e.Nat,l=e.Vec(e.Nat8),c=e.Record({owner:e.Principal,subaccount:e.Opt(l)}),f=e.Record({max_results:e.Nat,start:e.Opt(o),account:c}),d=e.Nat,g=e.Record({from:c,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,spender:e.Opt(c)}),O=e.Record({to:c,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat}),T=e.Record({fee:e.Opt(e.Nat),from:c,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(e.Nat64),spender:c}),i=e.Record({to:c,fee:e.Opt(e.Nat),from:c,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,spender:e.Opt(c)}),u=e.Record({burn:e.Opt(g),kind:e.Text,mint:e.Opt(O),approve:e.Opt(T),timestamp:e.Nat64,transfer:e.Opt(i)}),_=e.Record({id:o,transaction:u}),y=e.Record({balance:d,transactions:e.Vec(_),oldest_tx_id:e.Opt(o)}),R=e.Record({message:e.Text}),b=e.Variant({Ok:y,Err:R}),A=e.Record({start:e.Nat,length:e.Nat}),h=e.Vec(e.Tuple(e.Text,a));a.fill(e.Variant({Int:e.Int,Map:h,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(a)}));let v=a,x=e.Record({blocks:e.Vec(v),chain_length:e.Nat64}),V=e.Record({ranges:e.Vec(e.Tuple(c,e.Vec(e.Tuple(o,o))))}),s=e.Record({owner:e.Principal,start:e.Opt(l)}),F=e.Record({num_blocks_synced:o});return e.Service({get_account_transactions:e.Func([f],[b],["query"]),get_blocks:e.Func([A],[x],["query"]),get_fee_collectors_ranges:e.Func([],[V],["query"]),icrc1_balance_of:e.Func([c],[d],["query"]),ledger_id:e.Func([],[e.Principal],["query"]),list_subaccounts:e.Func([s],[e.Vec(l)],["query"]),status:e.Func([],[F],["query"])})};var C=require("@dfinity/utils"),G=class extends C.Canister{constructor(){super(...arguments);this.balance=t=>this.caller({certified:t.certified}).icrc1_balance_of({owner:t.owner,subaccount:(0,C.toNullable)(t.subaccount)})}};var ge=require("@dfinity/utils"),qe=({owner:e,subaccount:a})=>({owner:e,subaccount:(0,ge.toNullable)(a)}),q=({account:e,max_results:a,start:t})=>({account:qe(e),max_results:a,start:(0,ge.toNullable)(t)});var U=class e extends G{constructor(){super(...arguments);this.getTransactions=async({certified:t,...r})=>{let n=await this.caller({certified:t}).get_account_transactions(q(r));if("Err"in n)throw new P(n.Err.message);return n.Ok};this.ledgerId=t=>{let{ledger_id:r}=this.caller(t);return r()}}static create(t){let{service:r,certifiedService:n,canisterId:o}=(0,Re.createServices)({options:t,idlFactory:Te,certifiedIdlFactory:xe});return new e(o,r,n)}};var z=require("@dfinity/utils");var Ve=({IDL:e})=>{let a=e.Record({ledger_id:e.Principal}),t=e.Nat,r=e.Record({owner:e.Principal,subaccount:e.Opt(e.Vec(e.Nat8))}),n=e.Record({max_results:e.Nat,start:e.Opt(t),account:r}),o=e.Record({from:r,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,spender:e.Opt(r)}),l=e.Record({to:r,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat}),c=e.Record({fee:e.Opt(e.Nat),from:r,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(e.Nat64),spender:r}),f=e.Record({to:r,fee:e.Opt(e.Nat),from:r,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,spender:e.Opt(r)}),d=e.Record({burn:e.Opt(o),kind:e.Text,mint:e.Opt(l),approve:e.Opt(c),timestamp:e.Nat64,transfer:e.Opt(f)}),g=e.Record({id:t,transaction:d}),O=e.Record({transactions:e.Vec(g),oldest_tx_id:e.Opt(t)}),T=e.Record({message:e.Text}),i=e.Variant({Ok:O,Err:T}),u=e.Vec(e.Nat8),_=e.Record({owner:e.Principal,start:e.Opt(u)});return e.Service({get_account_transactions:e.Func([n],[i],[]),ledger_id:e.Func([],[e.Principal],[]),list_subaccounts:e.Func([_],[e.Vec(u)],[])})};var ye=({IDL:e})=>{let a=e.Record({ledger_id:e.Principal}),t=e.Nat,r=e.Record({owner:e.Principal,subaccount:e.Opt(e.Vec(e.Nat8))}),n=e.Record({max_results:e.Nat,start:e.Opt(t),account:r}),o=e.Record({from:r,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,spender:e.Opt(r)}),l=e.Record({to:r,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat}),c=e.Record({fee:e.Opt(e.Nat),from:r,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(e.Nat64),spender:r}),f=e.Record({to:r,fee:e.Opt(e.Nat),from:r,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,spender:e.Opt(r)}),d=e.Record({burn:e.Opt(o),kind:e.Text,mint:e.Opt(l),approve:e.Opt(c),timestamp:e.Nat64,transfer:e.Opt(f)}),g=e.Record({id:t,transaction:d}),O=e.Record({transactions:e.Vec(g),oldest_tx_id:e.Opt(t)}),T=e.Record({message:e.Text}),i=e.Variant({Ok:O,Err:T}),u=e.Vec(e.Nat8),_=e.Record({owner:e.Principal,start:e.Opt(u)});return e.Service({get_account_transactions:e.Func([n],[i],[]),ledger_id:e.Func([],[e.Principal],["query"]),list_subaccounts:e.Func([_],[e.Vec(u)],["query"])})};var M=class e extends z.Canister{constructor(){super(...arguments);this.getTransactions=async t=>{let r=await this.caller({certified:!0}).get_account_transactions(q(t));if("Err"in r)throw new P(r.Err.message);return r.Ok}}static create(t){let{service:r,certifiedService:n,canisterId:o}=(0,z.createServices)({options:t,idlFactory:ye,certifiedIdlFactory:Ve});return new e(o,r,n)}};var B=require("@dfinity/utils");var be=({IDL:e})=>{let a=e.Rec(),t=e.Rec(),r=e.Rec(),n=e.Record({num_blocks_to_archive:e.Opt(e.Nat64),max_transactions_per_response:e.Opt(e.Nat64),trigger_threshold:e.Opt(e.Nat64),more_controller_ids:e.Opt(e.Vec(e.Principal)),max_message_size_bytes:e.Opt(e.Nat64),cycles_for_archive_creation:e.Opt(e.Nat64),node_max_memory_size_bytes:e.Opt(e.Nat64),controller_id:e.Opt(e.Principal)}),o=e.Variant({Int:e.Int,Nat:e.Nat,Blob:e.Vec(e.Nat8),Text:e.Text}),l=e.Vec(e.Nat8),c=e.Record({owner:e.Principal,subaccount:e.Opt(l)}),f=e.Variant({SetTo:c,Unset:e.Null}),d=e.Record({icrc2:e.Bool}),g=e.Record({change_archive_options:e.Opt(n),token_symbol:e.Opt(e.Text),transfer_fee:e.Opt(e.Nat),metadata:e.Opt(e.Vec(e.Tuple(e.Text,o))),maximum_number_of_accounts:e.Opt(e.Nat64),accounts_overflow_trim_quantity:e.Opt(e.Nat64),change_fee_collector:e.Opt(f),max_memo_length:e.Opt(e.Nat16),token_name:e.Opt(e.Text),feature_flags:e.Opt(d)}),O=e.Record({decimals:e.Opt(e.Nat8),token_symbol:e.Text,transfer_fee:e.Nat,metadata:e.Vec(e.Tuple(e.Text,o)),minting_account:c,initial_balances:e.Vec(e.Tuple(c,e.Nat)),maximum_number_of_accounts:e.Opt(e.Nat64),accounts_overflow_trim_quantity:e.Opt(e.Nat64),fee_collector_account:e.Opt(c),archive_options:e.Record({num_blocks_to_archive:e.Nat64,max_transactions_per_response:e.Opt(e.Nat64),trigger_threshold:e.Nat64,more_controller_ids:e.Opt(e.Vec(e.Principal)),max_message_size_bytes:e.Opt(e.Nat64),cycles_for_archive_creation:e.Opt(e.Nat64),node_max_memory_size_bytes:e.Opt(e.Nat64),controller_id:e.Principal}),max_memo_length:e.Opt(e.Nat16),token_name:e.Text,feature_flags:e.Opt(d)}),T=e.Variant({Upgrade:e.Opt(g),Init:O}),i=e.Nat,u=e.Record({block_range_end:i,canister_id:e.Principal,block_range_start:i}),_=e.Record({start:i,length:e.Nat}),y=e.Vec(e.Tuple(e.Text,r));r.fill(e.Variant({Int:e.Int,Map:y,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(r)}));let R=r,b=e.Record({blocks:e.Vec(R)}),A=e.Func([_],[b],[]),h=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),first_index:i,blocks:e.Vec(R),chain_length:e.Nat64,archived_blocks:e.Vec(e.Record({callback:A,start:i,length:e.Nat}))}),v=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),hash_tree:e.Vec(e.Nat8)}),x=e.Nat,V=e.Record({start:x,length:e.Nat}),s=e.Nat64,F=e.Record({from:c,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:e.Nat,spender:e.Opt(c)}),W=e.Record({to:c,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:e.Nat}),Z=e.Record({fee:e.Opt(e.Nat),from:c,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(s),spender:c}),$=e.Record({to:c,fee:e.Opt(e.Nat),from:c,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:e.Nat,spender:e.Opt(c)}),S=e.Record({burn:e.Opt(F),kind:e.Text,mint:e.Opt(W),approve:e.Opt(Z),timestamp:s,transfer:e.Opt($)}),X=e.Record({transactions:e.Vec(S)}),j=e.Func([V],[X],[]),Y=e.Record({first_index:x,log_length:e.Nat,transactions:e.Vec(S),archived_transactions:e.Vec(e.Record({callback:j,start:x,length:e.Nat}))}),p=e.Nat,J=e.Record({url:e.Text,name:e.Text}),K=e.Record({to:c,fee:e.Opt(p),memo:e.Opt(e.Vec(e.Nat8)),from_subaccount:e.Opt(l),created_at_time:e.Opt(s),amount:p}),I=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,BadBurn:e.Record({min_burn_amount:p}),Duplicate:e.Record({duplicate_of:i}),BadFee:e.Record({expected_fee:p}),CreatedInFuture:e.Record({ledger_time:s}),TooOld:e.Null,InsufficientFunds:e.Record({balance:p})}),L=e.Variant({Ok:i,Err:I}),E=e.Record({utc_offset_minutes:e.Opt(e.Int16),language:e.Text}),D=e.Record({metadata:E,device_spec:e.Opt(e.Variant({GenericDisplay:e.Null,LineDisplay:e.Record({characters_per_line:e.Nat16,lines_per_page:e.Nat16})}))}),ee=e.Record({arg:e.Vec(e.Nat8),method:e.Text,user_preferences:D}),te=e.Variant({LineDisplayMessage:e.Record({pages:e.Vec(e.Record({lines:e.Vec(e.Text)}))}),GenericDisplayMessage:e.Text}),re=e.Record({metadata:E,consent_message:te}),k=e.Record({description:e.Text}),ce=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),InsufficientPayment:k,UnsupportedCanisterCall:k,ConsentMessageUnavailable:k}),ae=e.Variant({Ok:re,Err:ce}),oe=e.Record({account:c,spender:c}),ne=e.Record({allowance:e.Nat,expires_at:e.Opt(s)}),se=e.Record({fee:e.Opt(e.Nat),memo:e.Opt(e.Vec(e.Nat8)),from_subaccount:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(s),spender:c}),ie=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,Duplicate:e.Record({duplicate_of:i}),BadFee:e.Record({expected_fee:e.Nat}),AllowanceChanged:e.Record({current_allowance:e.Nat}),CreatedInFuture:e.Record({ledger_time:s}),TooOld:e.Null,Expired:e.Record({ledger_time:s}),InsufficientFunds:e.Record({balance:e.Nat})}),pe=e.Variant({Ok:i,Err:ie}),le=e.Record({to:c,fee:e.Opt(p),spender_subaccount:e.Opt(l),from:c,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:p}),_e=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,InsufficientAllowance:e.Record({allowance:p}),BadBurn:e.Record({min_burn_amount:p}),Duplicate:e.Record({duplicate_of:i}),BadFee:e.Record({expected_fee:p}),CreatedInFuture:e.Record({ledger_time:s}),TooOld:e.Null,InsufficientFunds:e.Record({balance:p})}),de=e.Variant({Ok:i,Err:_e}),me=e.Record({from:e.Opt(e.Principal)}),ue=e.Vec(e.Record({end:e.Nat,canister_id:e.Principal,start:e.Nat}));t.fill(e.Variant({Int:e.Int,Map:e.Vec(e.Tuple(e.Text,t)),Nat:e.Nat,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(t)})),a.fill(e.Record({log_length:e.Nat,blocks:e.Vec(e.Record({id:e.Nat,block:t})),archived_blocks:e.Vec(e.Record({args:e.Vec(_),callback:e.Func([e.Vec(_)],[a],[])}))}));let Ne=e.Record({certificate:e.Vec(e.Nat8),hash_tree:e.Vec(e.Nat8)});return e.Service({archives:e.Func([],[e.Vec(u)],[]),get_blocks:e.Func([_],[h],[]),get_data_certificate:e.Func([],[v],[]),get_transactions:e.Func([V],[Y],[]),icrc10_supported_standards:e.Func([],[e.Vec(e.Record({url:e.Text,name:e.Text}))],[]),icrc1_balance_of:e.Func([c],[p],[]),icrc1_decimals:e.Func([],[e.Nat8],[]),icrc1_fee:e.Func([],[p],[]),icrc1_metadata:e.Func([],[e.Vec(e.Tuple(e.Text,o))],[]),icrc1_minting_account:e.Func([],[e.Opt(c)],[]),icrc1_name:e.Func([],[e.Text],[]),icrc1_supported_standards:e.Func([],[e.Vec(J)],[]),icrc1_symbol:e.Func([],[e.Text],[]),icrc1_total_supply:e.Func([],[p],[]),icrc1_transfer:e.Func([K],[L],[]),icrc21_canister_call_consent_message:e.Func([ee],[ae],[]),icrc2_allowance:e.Func([oe],[ne],[]),icrc2_approve:e.Func([se],[pe],[]),icrc2_transfer_from:e.Func([le],[de],[]),icrc3_get_archives:e.Func([me],[ue],[]),icrc3_get_blocks:e.Func([e.Vec(_)],[a],[]),icrc3_get_tip_certificate:e.Func([],[e.Opt(Ne)],[]),icrc3_supported_block_types:e.Func([],[e.Vec(e.Record({url:e.Text,block_type:e.Text}))],[])})};var Ae=({IDL:e})=>{let a=e.Rec(),t=e.Rec(),r=e.Rec(),n=e.Record({num_blocks_to_archive:e.Opt(e.Nat64),max_transactions_per_response:e.Opt(e.Nat64),trigger_threshold:e.Opt(e.Nat64),more_controller_ids:e.Opt(e.Vec(e.Principal)),max_message_size_bytes:e.Opt(e.Nat64),cycles_for_archive_creation:e.Opt(e.Nat64),node_max_memory_size_bytes:e.Opt(e.Nat64),controller_id:e.Opt(e.Principal)}),o=e.Variant({Int:e.Int,Nat:e.Nat,Blob:e.Vec(e.Nat8),Text:e.Text}),l=e.Vec(e.Nat8),c=e.Record({owner:e.Principal,subaccount:e.Opt(l)}),f=e.Variant({SetTo:c,Unset:e.Null}),d=e.Record({icrc2:e.Bool}),g=e.Record({change_archive_options:e.Opt(n),token_symbol:e.Opt(e.Text),transfer_fee:e.Opt(e.Nat),metadata:e.Opt(e.Vec(e.Tuple(e.Text,o))),maximum_number_of_accounts:e.Opt(e.Nat64),accounts_overflow_trim_quantity:e.Opt(e.Nat64),change_fee_collector:e.Opt(f),max_memo_length:e.Opt(e.Nat16),token_name:e.Opt(e.Text),feature_flags:e.Opt(d)}),O=e.Record({decimals:e.Opt(e.Nat8),token_symbol:e.Text,transfer_fee:e.Nat,metadata:e.Vec(e.Tuple(e.Text,o)),minting_account:c,initial_balances:e.Vec(e.Tuple(c,e.Nat)),maximum_number_of_accounts:e.Opt(e.Nat64),accounts_overflow_trim_quantity:e.Opt(e.Nat64),fee_collector_account:e.Opt(c),archive_options:e.Record({num_blocks_to_archive:e.Nat64,max_transactions_per_response:e.Opt(e.Nat64),trigger_threshold:e.Nat64,more_controller_ids:e.Opt(e.Vec(e.Principal)),max_message_size_bytes:e.Opt(e.Nat64),cycles_for_archive_creation:e.Opt(e.Nat64),node_max_memory_size_bytes:e.Opt(e.Nat64),controller_id:e.Principal}),max_memo_length:e.Opt(e.Nat16),token_name:e.Text,feature_flags:e.Opt(d)}),T=e.Variant({Upgrade:e.Opt(g),Init:O}),i=e.Nat,u=e.Record({block_range_end:i,canister_id:e.Principal,block_range_start:i}),_=e.Record({start:i,length:e.Nat}),y=e.Vec(e.Tuple(e.Text,r));r.fill(e.Variant({Int:e.Int,Map:y,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(r)}));let R=r,b=e.Record({blocks:e.Vec(R)}),A=e.Func([_],[b],["query"]),h=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),first_index:i,blocks:e.Vec(R),chain_length:e.Nat64,archived_blocks:e.Vec(e.Record({callback:A,start:i,length:e.Nat}))}),v=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),hash_tree:e.Vec(e.Nat8)}),x=e.Nat,V=e.Record({start:x,length:e.Nat}),s=e.Nat64,F=e.Record({from:c,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:e.Nat,spender:e.Opt(c)}),W=e.Record({to:c,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:e.Nat}),Z=e.Record({fee:e.Opt(e.Nat),from:c,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(s),spender:c}),$=e.Record({to:c,fee:e.Opt(e.Nat),from:c,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:e.Nat,spender:e.Opt(c)}),S=e.Record({burn:e.Opt(F),kind:e.Text,mint:e.Opt(W),approve:e.Opt(Z),timestamp:s,transfer:e.Opt($)}),X=e.Record({transactions:e.Vec(S)}),j=e.Func([V],[X],["query"]),Y=e.Record({first_index:x,log_length:e.Nat,transactions:e.Vec(S),archived_transactions:e.Vec(e.Record({callback:j,start:x,length:e.Nat}))}),p=e.Nat,J=e.Record({url:e.Text,name:e.Text}),K=e.Record({to:c,fee:e.Opt(p),memo:e.Opt(e.Vec(e.Nat8)),from_subaccount:e.Opt(l),created_at_time:e.Opt(s),amount:p}),I=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,BadBurn:e.Record({min_burn_amount:p}),Duplicate:e.Record({duplicate_of:i}),BadFee:e.Record({expected_fee:p}),CreatedInFuture:e.Record({ledger_time:s}),TooOld:e.Null,InsufficientFunds:e.Record({balance:p})}),L=e.Variant({Ok:i,Err:I}),E=e.Record({utc_offset_minutes:e.Opt(e.Int16),language:e.Text}),D=e.Record({metadata:E,device_spec:e.Opt(e.Variant({GenericDisplay:e.Null,LineDisplay:e.Record({characters_per_line:e.Nat16,lines_per_page:e.Nat16})}))}),ee=e.Record({arg:e.Vec(e.Nat8),method:e.Text,user_preferences:D}),te=e.Variant({LineDisplayMessage:e.Record({pages:e.Vec(e.Record({lines:e.Vec(e.Text)}))}),GenericDisplayMessage:e.Text}),re=e.Record({metadata:E,consent_message:te}),k=e.Record({description:e.Text}),ce=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),InsufficientPayment:k,UnsupportedCanisterCall:k,ConsentMessageUnavailable:k}),ae=e.Variant({Ok:re,Err:ce}),oe=e.Record({account:c,spender:c}),ne=e.Record({allowance:e.Nat,expires_at:e.Opt(s)}),se=e.Record({fee:e.Opt(e.Nat),memo:e.Opt(e.Vec(e.Nat8)),from_subaccount:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(s),spender:c}),ie=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,Duplicate:e.Record({duplicate_of:i}),BadFee:e.Record({expected_fee:e.Nat}),AllowanceChanged:e.Record({current_allowance:e.Nat}),CreatedInFuture:e.Record({ledger_time:s}),TooOld:e.Null,Expired:e.Record({ledger_time:s}),InsufficientFunds:e.Record({balance:e.Nat})}),pe=e.Variant({Ok:i,Err:ie}),le=e.Record({to:c,fee:e.Opt(p),spender_subaccount:e.Opt(l),from:c,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:p}),_e=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,InsufficientAllowance:e.Record({allowance:p}),BadBurn:e.Record({min_burn_amount:p}),Duplicate:e.Record({duplicate_of:i}),BadFee:e.Record({expected_fee:p}),CreatedInFuture:e.Record({ledger_time:s}),TooOld:e.Null,InsufficientFunds:e.Record({balance:p})}),de=e.Variant({Ok:i,Err:_e}),me=e.Record({from:e.Opt(e.Principal)}),ue=e.Vec(e.Record({end:e.Nat,canister_id:e.Principal,start:e.Nat}));t.fill(e.Variant({Int:e.Int,Map:e.Vec(e.Tuple(e.Text,t)),Nat:e.Nat,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(t)})),a.fill(e.Record({log_length:e.Nat,blocks:e.Vec(e.Record({id:e.Nat,block:t})),archived_blocks:e.Vec(e.Record({args:e.Vec(_),callback:e.Func([e.Vec(_)],[a],["query"])}))}));let Ne=e.Record({certificate:e.Vec(e.Nat8),hash_tree:e.Vec(e.Nat8)});return e.Service({archives:e.Func([],[e.Vec(u)],["query"]),get_blocks:e.Func([_],[h],["query"]),get_data_certificate:e.Func([],[v],["query"]),get_transactions:e.Func([V],[Y],["query"]),icrc10_supported_standards:e.Func([],[e.Vec(e.Record({url:e.Text,name:e.Text}))],["query"]),icrc1_balance_of:e.Func([c],[p],["query"]),icrc1_decimals:e.Func([],[e.Nat8],["query"]),icrc1_fee:e.Func([],[p],["query"]),icrc1_metadata:e.Func([],[e.Vec(e.Tuple(e.Text,o))],["query"]),icrc1_minting_account:e.Func([],[e.Opt(c)],["query"]),icrc1_name:e.Func([],[e.Text],["query"]),icrc1_supported_standards:e.Func([],[e.Vec(J)],["query"]),icrc1_symbol:e.Func([],[e.Text],["query"]),icrc1_total_supply:e.Func([],[p],["query"]),icrc1_transfer:e.Func([K],[L],[]),icrc21_canister_call_consent_message:e.Func([ee],[ae],[]),icrc2_allowance:e.Func([oe],[ne],["query"]),icrc2_approve:e.Func([se],[pe],[]),icrc2_transfer_from:e.Func([le],[de],[]),icrc3_get_archives:e.Func([me],[ue],["query"]),icrc3_get_blocks:e.Func([e.Vec(_)],[a],["query"]),icrc3_get_tip_certificate:e.Func([],[e.Opt(Ne)],["query"]),icrc3_supported_block_types:e.Func([],[e.Vec(e.Record({url:e.Text,block_type:e.Text}))],["query"])})};var m=require("@dfinity/utils"),he=({from_subaccount:e,fee:a,created_at_time:t,memo:r,...n})=>({...n,fee:(0,m.toNullable)(a),memo:(0,m.toNullable)(r),from_subaccount:(0,m.toNullable)(e),created_at_time:(0,m.toNullable)(t)}),ve=({spender_subaccount:e,fee:a,created_at_time:t,memo:r,...n})=>({...n,fee:(0,m.toNullable)(a),memo:(0,m.toNullable)(r),spender_subaccount:(0,m.toNullable)(e),created_at_time:(0,m.toNullable)(t)}),Fe=({fee:e,created_at_time:a,memo:t,from_subaccount:r,expected_allowance:n,expires_at:o,...l})=>({...l,fee:(0,m.toNullable)(e),memo:(0,m.toNullable)(t),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 Q=class e extends B.Canister{constructor(){super(...arguments);this.metadata=t=>this.caller(t).icrc1_metadata();this.transactionFee=t=>this.caller(t).icrc1_fee();this.balance=t=>this.caller({certified:t.certified}).icrc1_balance_of({owner:t.owner,subaccount:(0,B.toNullable)(t.subaccount)});this.transfer=async t=>{let r=await this.caller({certified:!0}).icrc1_transfer(he(t));if("Err"in r)throw new w({errorType:r.Err,msg:"Failed to transfer"});return r.Ok};this.totalTokensSupply=t=>this.caller(t).icrc1_total_supply();this.transferFrom=async t=>{let r=await this.caller({certified:!0}).icrc2_transfer_from(ve(t));if("Err"in r)throw new w({errorType:r.Err,msg:"Failed to transfer from"});return r.Ok};this.approve=async t=>{let r=await this.caller({certified:!0}).icrc2_approve(Fe(t));if("Err"in r)throw new w({errorType:r.Err,msg:"Failed to entitle the spender to transfer the amount"});return r.Ok};this.allowance=async t=>{let{certified:r,...n}=t;return this.caller({certified:r}).icrc2_allowance({...n})}}static create(t){let{service:r,certifiedService:n,canisterId:o}=(0,B.createServices)({options:t,idlFactory:Ae,certifiedIdlFactory:be});return new e(o,r,n)}};var ke=(o=>(o.SYMBOL="icrc1:symbol",o.NAME="icrc1:name",o.DECIMALS="icrc1:decimals",o.FEE="icrc1:fee",o.LOGO="icrc1:logo",o))(ke||{});var Oe=require("@dfinity/principal"),N=require("@dfinity/utils"),Ue=64,Me=({owner:e,subaccount:a})=>{if((0,N.isNullish)(a))return e.toText();let r=(n=>n.replace(/^0+/,""))((0,N.uint8ArrayToHexString)(Uint8Array.from(a)));return r.length===0?e.toText():`${e.toText()}-${Pe({owner:e,subaccount:a})}.${r}`},Pe=({owner:e,subaccount:a})=>{let t=(0,N.bigEndianCrc32)(Uint8Array.from([...e.toUint8Array(),...a]));return(0,N.encodeBase32)(t)},ze=e=>{let[a,t]=e.split(".");if(!(0,N.notEmptyString)(a))throw new Error("Invalid account. No string provided.");if((0,N.isNullish)(t))return{owner:Oe.Principal.fromText(e)};let[r,...n]=a.split("-").reverse(),o=n.reverse().join("-"),l={owner:Oe.Principal.fromText(o),subaccount:(0,N.hexStringToUint8Array)(t.padStart(Ue,"0"))};if(Pe(l)!==r)throw new Error("Invalid account. Invalid checksum.");return l};var H=require("@dfinity/utils"),Qe=e=>{let a=/^([a-zA-Z]+):([A-Za-z0-9:\-.]+).*?(?:[?&](?:amount|value)=(\d+(?:\.\d+)?))?$/,t=e.match(a);if((0,H.isNullish)(t))return;let[r,n,o,l]=t;return{token:n,identifier:o,...(0,H.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