@dfinity/ledger-icrc 2.8.1-next-2025-04-23 → 2.8.1-next-2025-05-09

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.
Files changed (34) hide show
  1. package/README.md +20 -5
  2. package/dist/candid/icrc_index-ng.certified.idl.js +7 -7
  3. package/dist/candid/icrc_index-ng.d.ts +7 -7
  4. package/dist/candid/icrc_index-ng.did +8 -8
  5. package/dist/candid/icrc_index-ng.idl.js +7 -7
  6. package/dist/candid/icrc_ledger.did +1 -1
  7. package/dist/cjs/index.cjs.js +1 -1
  8. package/dist/cjs/index.cjs.js.map +3 -3
  9. package/dist/esm/canister.js +1 -1
  10. package/dist/esm/chunk-62KIKAXV.js +2 -0
  11. package/dist/esm/{chunk-A77UW7FO.js.map → chunk-62KIKAXV.js.map} +2 -2
  12. package/dist/esm/chunk-F74MWPN7.js +2 -0
  13. package/dist/esm/{chunk-6GLYJI63.js.map → chunk-F74MWPN7.js.map} +1 -1
  14. package/dist/esm/chunk-IHNDUXP4.js +2 -0
  15. package/dist/esm/chunk-IHNDUXP4.js.map +7 -0
  16. package/dist/esm/chunk-OJD6CVD7.js +2 -0
  17. package/dist/esm/chunk-OJD6CVD7.js.map +7 -0
  18. package/dist/esm/chunk-PXRSDY5X.js +2 -0
  19. package/dist/esm/{chunk-RQUD6I43.js.map → chunk-PXRSDY5X.js.map} +2 -2
  20. package/dist/esm/index-ng.canister.js +1 -1
  21. package/dist/esm/index.canister.js +1 -1
  22. package/dist/esm/index.js +1 -1
  23. package/dist/esm/ledger.canister.js +1 -1
  24. package/dist/types/converters/index.converters.d.ts +3 -0
  25. package/dist/types/index-ng.canister.d.ts +9 -1
  26. package/dist/types/types/index-ng.params.d.ts +4 -0
  27. package/package.json +1 -1
  28. package/dist/esm/chunk-42OX77TJ.js +0 -2
  29. package/dist/esm/chunk-42OX77TJ.js.map +0 -7
  30. package/dist/esm/chunk-6GLYJI63.js +0 -2
  31. package/dist/esm/chunk-A77UW7FO.js +0 -2
  32. package/dist/esm/chunk-QSOCC3T6.js +0 -2
  33. package/dist/esm/chunk-QSOCC3T6.js.map +0 -7
  34. package/dist/esm/chunk-RQUD6I43.js +0 -2
package/README.md CHANGED
@@ -374,7 +374,7 @@ Returns the ledger canister ID related to the index canister.
374
374
 
375
375
  ### :factory: IcrcIndexNgCanister
376
376
 
377
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index-ng.canister.ts#L16)
377
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index-ng.canister.ts#L23)
378
378
 
379
379
  #### Static Methods
380
380
 
@@ -386,13 +386,14 @@ Returns the ledger canister ID related to the index canister.
386
386
  | -------- | ----------------------------------------------------------------------- |
387
387
  | `create` | `(options: IcrcLedgerCanisterOptions<_SERVICE>) => IcrcIndexNgCanister` |
388
388
 
389
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index-ng.canister.ts#L17)
389
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index-ng.canister.ts#L24)
390
390
 
391
391
  #### Methods
392
392
 
393
393
  - [getTransactions](#gear-gettransactions)
394
394
  - [ledgerId](#gear-ledgerid)
395
395
  - [status](#gear-status)
396
+ - [listSubaccounts](#gear-listsubaccounts)
396
397
 
397
398
  ##### :gear: getTransactions
398
399
 
@@ -406,7 +407,7 @@ Parameters:
406
407
 
407
408
  - `params`: The parameters to get the transactions of an account.
408
409
 
409
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index-ng.canister.ts#L42)
410
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index-ng.canister.ts#L49)
410
411
 
411
412
  ##### :gear: ledgerId
412
413
 
@@ -416,7 +417,7 @@ Returns the ledger canister ID related to the index canister.
416
417
  | ---------- | --------------------------------------------- |
417
418
  | `ledgerId` | `(params: QueryParams) => Promise<Principal>` |
418
419
 
419
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index-ng.canister.ts#L60)
420
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index-ng.canister.ts#L67)
420
421
 
421
422
  ##### :gear: status
422
423
 
@@ -430,7 +431,21 @@ Parameters:
430
431
 
431
432
  - `params`: The parameters to get the status of the index canister.
432
433
 
433
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index-ng.canister.ts#L71)
434
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index-ng.canister.ts#L78)
435
+
436
+ ##### :gear: listSubaccounts
437
+
438
+ Returns the list of subaccounts for a given owner.
439
+
440
+ | Method | Type |
441
+ | ----------------- | -------------------------------------------------------------------------- |
442
+ | `listSubaccounts` | `({ certified, ...rest }: ListSubaccountsParams) => Promise<SubAccount[]>` |
443
+
444
+ Parameters:
445
+
446
+ - `params`: The parameters to get the list of subaccounts.
447
+
448
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index-ng.canister.ts#L87)
434
449
 
435
450
  <!-- TSDOC_END -->
436
451
 
@@ -26,32 +26,32 @@ export const idlFactory = ({ IDL }) => {
26
26
  'from' : Account,
27
27
  'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
28
28
  'created_at_time' : IDL.Opt(IDL.Nat64),
29
- 'amount' : IDL.Nat,
29
+ 'amount' : Tokens,
30
30
  'spender' : IDL.Opt(Account),
31
31
  });
32
32
  const Mint = IDL.Record({
33
33
  'to' : Account,
34
34
  'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
35
35
  'created_at_time' : IDL.Opt(IDL.Nat64),
36
- 'amount' : IDL.Nat,
36
+ 'amount' : Tokens,
37
37
  });
38
38
  const Approve = IDL.Record({
39
- 'fee' : IDL.Opt(IDL.Nat),
39
+ 'fee' : IDL.Opt(Tokens),
40
40
  'from' : Account,
41
41
  'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
42
42
  'created_at_time' : IDL.Opt(IDL.Nat64),
43
- 'amount' : IDL.Nat,
44
- 'expected_allowance' : IDL.Opt(IDL.Nat),
43
+ 'amount' : Tokens,
44
+ 'expected_allowance' : IDL.Opt(Tokens),
45
45
  'expires_at' : IDL.Opt(IDL.Nat64),
46
46
  'spender' : Account,
47
47
  });
48
48
  const Transfer = IDL.Record({
49
49
  'to' : Account,
50
- 'fee' : IDL.Opt(IDL.Nat),
50
+ 'fee' : IDL.Opt(Tokens),
51
51
  'from' : Account,
52
52
  'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
53
53
  'created_at_time' : IDL.Opt(IDL.Nat64),
54
- 'amount' : IDL.Nat,
54
+ 'amount' : Tokens,
55
55
  'spender' : IDL.Opt(Account),
56
56
  });
57
57
  const Transaction = IDL.Record({
@@ -7,12 +7,12 @@ export interface Account {
7
7
  subaccount: [] | [SubAccount];
8
8
  }
9
9
  export interface Approve {
10
- fee: [] | [bigint];
10
+ fee: [] | [Tokens];
11
11
  from: Account;
12
12
  memo: [] | [Uint8Array | number[]];
13
13
  created_at_time: [] | [bigint];
14
- amount: bigint;
15
- expected_allowance: [] | [bigint];
14
+ amount: Tokens;
15
+ expected_allowance: [] | [Tokens];
16
16
  expires_at: [] | [bigint];
17
17
  spender: Account;
18
18
  }
@@ -22,7 +22,7 @@ export interface Burn {
22
22
  from: Account;
23
23
  memo: [] | [Uint8Array | number[]];
24
24
  created_at_time: [] | [bigint];
25
- amount: bigint;
25
+ amount: Tokens;
26
26
  spender: [] | [Account];
27
27
  }
28
28
  export interface FeeCollectorRanges {
@@ -66,7 +66,7 @@ export interface Mint {
66
66
  to: Account;
67
67
  memo: [] | [Uint8Array | number[]];
68
68
  created_at_time: [] | [bigint];
69
- amount: bigint;
69
+ amount: Tokens;
70
70
  }
71
71
  export interface Status {
72
72
  num_blocks_synced: BlockIndex;
@@ -87,11 +87,11 @@ export interface TransactionWithId {
87
87
  }
88
88
  export interface Transfer {
89
89
  to: Account;
90
- fee: [] | [bigint];
90
+ fee: [] | [Tokens];
91
91
  from: Account;
92
92
  memo: [] | [Uint8Array | number[]];
93
93
  created_at_time: [] | [bigint];
94
- amount: bigint;
94
+ amount: Tokens;
95
95
  spender: [] | [Account];
96
96
  }
97
97
  export interface UpgradeArg {
@@ -1,4 +1,4 @@
1
- // Generated from IC repo commit 579b8ba (2025-04-11 tags: release-2025-04-11_13-20-base) 'rs/ledger_suite/icrc1/index-ng/index-ng.did' by import-candid
1
+ // Generated from IC repo commit f195ba7 (2025-04-30 tags: release-2025-05-01_03-23-base) 'rs/ledger_suite/icrc1/index-ng/index-ng.did' by import-candid
2
2
  type Tokens = nat;
3
3
 
4
4
  type InitArg = record {
@@ -62,12 +62,12 @@ type Transaction = record {
62
62
  };
63
63
 
64
64
  type Approve = record {
65
- fee : opt nat;
65
+ fee : opt Tokens;
66
66
  from : Account;
67
67
  memo : opt vec nat8;
68
68
  created_at_time : opt nat64;
69
- amount : nat;
70
- expected_allowance : opt nat;
69
+ amount : Tokens;
70
+ expected_allowance : opt Tokens;
71
71
  expires_at : opt nat64;
72
72
  spender : Account;
73
73
  };
@@ -76,7 +76,7 @@ type Burn = record {
76
76
  from : Account;
77
77
  memo : opt vec nat8;
78
78
  created_at_time : opt nat64;
79
- amount : nat;
79
+ amount : Tokens;
80
80
  spender : opt Account;
81
81
  };
82
82
 
@@ -84,16 +84,16 @@ type Mint = record {
84
84
  to : Account;
85
85
  memo : opt vec nat8;
86
86
  created_at_time : opt nat64;
87
- amount : nat;
87
+ amount : Tokens;
88
88
  };
89
89
 
90
90
  type Transfer = record {
91
91
  to : Account;
92
- fee : opt nat;
92
+ fee : opt Tokens;
93
93
  from : Account;
94
94
  memo : opt vec nat8;
95
95
  created_at_time : opt nat64;
96
- amount : nat;
96
+ amount : Tokens;
97
97
  spender : opt Account;
98
98
  };
99
99
 
@@ -26,32 +26,32 @@ export const idlFactory = ({ IDL }) => {
26
26
  'from' : Account,
27
27
  'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
28
28
  'created_at_time' : IDL.Opt(IDL.Nat64),
29
- 'amount' : IDL.Nat,
29
+ 'amount' : Tokens,
30
30
  'spender' : IDL.Opt(Account),
31
31
  });
32
32
  const Mint = IDL.Record({
33
33
  'to' : Account,
34
34
  'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
35
35
  'created_at_time' : IDL.Opt(IDL.Nat64),
36
- 'amount' : IDL.Nat,
36
+ 'amount' : Tokens,
37
37
  });
38
38
  const Approve = IDL.Record({
39
- 'fee' : IDL.Opt(IDL.Nat),
39
+ 'fee' : IDL.Opt(Tokens),
40
40
  'from' : Account,
41
41
  'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
42
42
  'created_at_time' : IDL.Opt(IDL.Nat64),
43
- 'amount' : IDL.Nat,
44
- 'expected_allowance' : IDL.Opt(IDL.Nat),
43
+ 'amount' : Tokens,
44
+ 'expected_allowance' : IDL.Opt(Tokens),
45
45
  'expires_at' : IDL.Opt(IDL.Nat64),
46
46
  'spender' : Account,
47
47
  });
48
48
  const Transfer = IDL.Record({
49
49
  'to' : Account,
50
- 'fee' : IDL.Opt(IDL.Nat),
50
+ 'fee' : IDL.Opt(Tokens),
51
51
  'from' : Account,
52
52
  'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),
53
53
  'created_at_time' : IDL.Opt(IDL.Nat64),
54
- 'amount' : IDL.Nat,
54
+ 'amount' : Tokens,
55
55
  'spender' : IDL.Opt(Account),
56
56
  });
57
57
  const Transaction = IDL.Record({
@@ -1,4 +1,4 @@
1
- // Generated from IC repo commit 579b8ba (2025-04-11 tags: release-2025-04-11_13-20-base) 'rs/ledger_suite/icrc1/ledger/ledger.did' by import-candid
1
+ // Generated from IC repo commit f195ba7 (2025-04-30 tags: release-2025-05-01_03-23-base) 'rs/ledger_suite/icrc1/ledger/ledger.did' by import-candid
2
2
  type BlockIndex = nat;
3
3
  type Subaccount = blob;
4
4
  // Number of nanoseconds since the UNIX epoch in UTC timezone.
@@ -1,2 +1,2 @@
1
- "use strict";var Re=Object.defineProperty;var qe=Object.getOwnPropertyDescriptor;var Ue=Object.getOwnPropertyNames;var ze=Object.prototype.hasOwnProperty;var Qe=(e,a)=>{for(var r in a)Re(e,r,{get:a[r],enumerable:!0})},$e=(e,a,r,t)=>{if(a&&typeof a=="object"||typeof a=="function")for(let o of Ue(a))!ze.call(e,o)&&o!==r&&Re(e,o,{get:()=>a[o],enumerable:!(t=qe(a,o))||t.enumerable});return e};var He=e=>$e(Re({},"__esModule",{value:!0}),e);var Ke={};Qe(Ke,{ConsentMessageError:()=>C,ConsentMessageUnavailableError:()=>U,GenericError:()=>S,IcrcIndexCanister:()=>W,IcrcIndexNgCanister:()=>H,IcrcLedgerCanister:()=>X,IcrcMetadataResponseEntries:()=>Fe,IcrcTransferError:()=>B,IndexError:()=>P,InsufficientPaymentError:()=>M,UnsupportedCanisterCallError:()=>q,decodeIcrcAccount:()=>Ye,decodePayment:()=>Je,encodeIcrcAccount:()=>Xe,mapIcrc21ConsentMessageError:()=>he,mapTokenMetadata:()=>je,toApproveArgs:()=>be,toIcrc21ConsentMessageArgs:()=>Ae,toTransferArg:()=>ye,toTransferFromArgs:()=>Ve});module.exports=He(Ke);var d=require("@dfinity/utils"),ye=({from_subaccount:e,fee:a,created_at_time:r,memo:t,...o})=>({...o,fee:(0,d.toNullable)(a),memo:(0,d.toNullable)(t),from_subaccount:(0,d.toNullable)(e),created_at_time:(0,d.toNullable)(r)}),Ve=({spender_subaccount:e,fee:a,created_at_time:r,memo:t,...o})=>({...o,fee:(0,d.toNullable)(a),memo:(0,d.toNullable)(t),spender_subaccount:(0,d.toNullable)(e),created_at_time:(0,d.toNullable)(r)}),be=({fee:e,created_at_time:a,memo:r,from_subaccount:t,expected_allowance:o,expires_at:n,...l})=>({...l,fee:(0,d.toNullable)(e),memo:(0,d.toNullable)(r),from_subaccount:(0,d.toNullable)(t),created_at_time:(0,d.toNullable)(a),expected_allowance:(0,d.toNullable)(o),expires_at:(0,d.toNullable)(n)}),Ae=({userPreferences:{metadata:{utcOffsetMinutes:e,language:a},deriveSpec:r},...t})=>({...t,user_preferences:{metadata:{language:a,utc_offset_minutes:(0,d.toNullable)(e)},device_spec:(0,d.isNullish)(r)?(0,d.toNullable)():(0,d.toNullable)("GenericDisplay"in r?{GenericDisplay:null}:{LineDisplay:{characters_per_line:r.LineDisplay.charactersPerLine,lines_per_page:r.LineDisplay.linesPerPage}})}});var P=class extends Error{};var B=class extends Error{constructor({msg:a,errorType:r}){super(a),this.errorType=r}},S=class extends Error{constructor(r,t){super();this.message=r;this.error_code=t}},C=class extends Error{},M=class extends C{},q=class extends C{},U=class extends C{},he=e=>"GenericError"in e?new S(e.GenericError.description,e.GenericError.error_code):"InsufficientPayment"in e?new M(e.InsufficientPayment.description):"UnsupportedCanisterCall"in e?new q(e.UnsupportedCanisterCall.description):"ConsentMessageUnavailable"in e?new U(e.ConsentMessageUnavailable.description):new C(`Unknown error type ${JSON.stringify(e)}`);var Ce=require("@dfinity/utils");var Pe=({IDL:e})=>{let a=e.Rec(),r=e.Record({ledger_id:e.Opt(e.Principal),retrieve_blocks_from_ledger_interval_seconds:e.Opt(e.Nat64)}),t=e.Record({ledger_id:e.Principal,retrieve_blocks_from_ledger_interval_seconds:e.Opt(e.Nat64)}),o=e.Variant({Upgrade:r,Init:t}),n=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(n),account:c}),u=e.Nat,N=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)}),g=e.Record({burn:e.Opt(N),kind:e.Text,mint:e.Opt(O),approve:e.Opt(T),timestamp:e.Nat64,transfer:e.Opt(i)}),_=e.Record({id:n,transaction:g}),V=e.Record({balance:u,transactions:e.Vec(_),oldest_tx_id:e.Opt(n)}),R=e.Record({message:e.Text}),b=e.Variant({Ok:V,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 k=a,x=e.Record({blocks:e.Vec(k),chain_length:e.Nat64}),y=e.Record({ranges:e.Vec(e.Tuple(c,e.Vec(e.Tuple(n,n))))}),s=e.Record({owner:e.Principal,start:e.Opt(l)}),F=e.Record({num_blocks_synced:n});return e.Service({get_account_transactions:e.Func([f],[b],[]),get_blocks:e.Func([A],[x],[]),get_fee_collectors_ranges:e.Func([],[y],[]),icrc1_balance_of:e.Func([c],[u],[]),ledger_id:e.Func([],[e.Principal],[]),list_subaccounts:e.Func([s],[e.Vec(l)],[]),status:e.Func([],[F],[])})};var Be=({IDL:e})=>{let a=e.Rec(),r=e.Record({ledger_id:e.Opt(e.Principal),retrieve_blocks_from_ledger_interval_seconds:e.Opt(e.Nat64)}),t=e.Record({ledger_id:e.Principal,retrieve_blocks_from_ledger_interval_seconds:e.Opt(e.Nat64)}),o=e.Variant({Upgrade:r,Init:t}),n=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(n),account:c}),u=e.Nat,N=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)}),g=e.Record({burn:e.Opt(N),kind:e.Text,mint:e.Opt(O),approve:e.Opt(T),timestamp:e.Nat64,transfer:e.Opt(i)}),_=e.Record({id:n,transaction:g}),V=e.Record({balance:u,transactions:e.Vec(_),oldest_tx_id:e.Opt(n)}),R=e.Record({message:e.Text}),b=e.Variant({Ok:V,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 k=a,x=e.Record({blocks:e.Vec(k),chain_length:e.Nat64}),y=e.Record({ranges:e.Vec(e.Tuple(c,e.Vec(e.Tuple(n,n))))}),s=e.Record({owner:e.Principal,start:e.Opt(l)}),F=e.Record({num_blocks_synced:n});return e.Service({get_account_transactions:e.Func([f],[b],["query"]),get_blocks:e.Func([A],[x],["query"]),get_fee_collectors_ranges:e.Func([],[y],["query"]),icrc1_balance_of:e.Func([c],[u],["query"]),ledger_id:e.Func([],[e.Principal],["query"]),list_subaccounts:e.Func([s],[e.Vec(l)],["query"]),status:e.Func([],[F],["query"])})};var Q=require("@dfinity/utils"),z=class extends Q.Canister{constructor(){super(...arguments);this.balance=r=>this.caller({certified:r.certified}).icrc1_balance_of({owner:r.owner,subaccount:(0,Q.toNullable)(r.subaccount)})}};var ke=require("@dfinity/utils"),We=({owner:e,subaccount:a})=>({owner:e,subaccount:(0,ke.toNullable)(a)}),$=({account:e,max_results:a,start:r})=>({account:We(e),max_results:a,start:(0,ke.toNullable)(r)});var H=class e extends z{constructor(){super(...arguments);this.getTransactions=async({certified:r,...t})=>{let o=await this.caller({certified:r}).get_account_transactions($(t));if("Err"in o)throw new P(o.Err.message);return o.Ok};this.ledgerId=r=>{let{ledger_id:t}=this.caller(r);return t()};this.status=r=>this.caller(r).status()}static create(r){let{service:t,certifiedService:o,canisterId:n}=(0,Ce.createServices)({options:r,idlFactory:Be,certifiedIdlFactory:Pe});return new e(n,t,o)}};var Z=require("@dfinity/utils");var Ge=({IDL:e})=>{let a=e.Record({ledger_id:e.Principal}),r=e.Nat,t=e.Record({owner:e.Principal,subaccount:e.Opt(e.Vec(e.Nat8))}),o=e.Record({max_results:e.Nat,start:e.Opt(r),account:t}),n=e.Record({from:t,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,spender:e.Opt(t)}),l=e.Record({to:t,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:t,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:t}),f=e.Record({to:t,fee:e.Opt(e.Nat),from:t,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,spender:e.Opt(t)}),u=e.Record({burn:e.Opt(n),kind:e.Text,mint:e.Opt(l),approve:e.Opt(c),timestamp:e.Nat64,transfer:e.Opt(f)}),N=e.Record({id:r,transaction:u}),O=e.Record({transactions:e.Vec(N),oldest_tx_id:e.Opt(r)}),T=e.Record({message:e.Text}),i=e.Variant({Ok:O,Err:T}),g=e.Vec(e.Nat8),_=e.Record({owner:e.Principal,start:e.Opt(g)});return e.Service({get_account_transactions:e.Func([o],[i],[]),ledger_id:e.Func([],[e.Principal],[]),list_subaccounts:e.Func([_],[e.Vec(g)],[])})};var we=({IDL:e})=>{let a=e.Record({ledger_id:e.Principal}),r=e.Nat,t=e.Record({owner:e.Principal,subaccount:e.Opt(e.Vec(e.Nat8))}),o=e.Record({max_results:e.Nat,start:e.Opt(r),account:t}),n=e.Record({from:t,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,spender:e.Opt(t)}),l=e.Record({to:t,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:t,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:t}),f=e.Record({to:t,fee:e.Opt(e.Nat),from:t,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,spender:e.Opt(t)}),u=e.Record({burn:e.Opt(n),kind:e.Text,mint:e.Opt(l),approve:e.Opt(c),timestamp:e.Nat64,transfer:e.Opt(f)}),N=e.Record({id:r,transaction:u}),O=e.Record({transactions:e.Vec(N),oldest_tx_id:e.Opt(r)}),T=e.Record({message:e.Text}),i=e.Variant({Ok:O,Err:T}),g=e.Vec(e.Nat8),_=e.Record({owner:e.Principal,start:e.Opt(g)});return e.Service({get_account_transactions:e.Func([o],[i],[]),ledger_id:e.Func([],[e.Principal],["query"]),list_subaccounts:e.Func([_],[e.Vec(g)],["query"])})};var W=class e extends Z.Canister{constructor(){super(...arguments);this.getTransactions=async r=>{let t=await this.caller({certified:!0}).get_account_transactions($(r));if("Err"in t)throw new P(t.Err.message);return t.Ok};this.ledgerId=r=>{let{ledger_id:t}=this.caller(r);return t()}}static create(r){let{service:t,certifiedService:o,canisterId:n}=(0,Z.createServices)({options:r,idlFactory:we,certifiedIdlFactory:Ge});return new e(n,t,o)}};var G=require("@dfinity/utils");var Ee=({IDL:e})=>{let a=e.Rec(),r=e.Rec(),t=e.Rec(),o=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)}),n=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}),u=e.Record({icrc2:e.Bool}),N=e.Record({change_archive_options:e.Opt(o),token_symbol:e.Opt(e.Text),transfer_fee:e.Opt(e.Nat),metadata:e.Opt(e.Vec(e.Tuple(e.Text,n))),change_fee_collector:e.Opt(f),max_memo_length:e.Opt(e.Nat16),token_name:e.Opt(e.Text),feature_flags:e.Opt(u)}),O=e.Record({decimals:e.Opt(e.Nat8),token_symbol:e.Text,transfer_fee:e.Nat,metadata:e.Vec(e.Tuple(e.Text,n)),minting_account:c,initial_balances:e.Vec(e.Tuple(c,e.Nat)),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(u)}),T=e.Variant({Upgrade:e.Opt(N),Init:O}),i=e.Nat,g=e.Record({block_range_end:i,canister_id:e.Principal,block_range_start:i}),_=e.Record({start:i,length:e.Nat}),V=e.Vec(e.Tuple(e.Text,t));t.fill(e.Variant({Int:e.Int,Map:V,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(t)}));let R=t,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}))}),k=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),hash_tree:e.Vec(e.Nat8)}),x=e.Nat,y=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)}),j=e.Record({to:c,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:e.Nat}),J=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}),K=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)}),w=e.Record({burn:e.Opt(F),kind:e.Text,mint:e.Opt(j),approve:e.Opt(J),timestamp:s,transfer:e.Opt(K)}),I=e.Record({transactions:e.Vec(w)}),L=e.Func([y],[I],[]),D=e.Record({first_index:x,log_length:e.Nat,transactions:e.Vec(w),archived_transactions:e.Vec(e.Record({callback:L,start:x,length:e.Nat}))}),p=e.Nat,ee=e.Record({url:e.Text,name:e.Text}),te=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}),re=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})}),ce=e.Variant({Ok:i,Err:re}),E=e.Record({utc_offset_minutes:e.Opt(e.Int16),language:e.Text}),ae=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})}))}),ne=e.Record({arg:e.Vec(e.Nat8),method:e.Text,user_preferences:ae}),oe=e.Variant({LineDisplayMessage:e.Record({pages:e.Vec(e.Record({lines:e.Vec(e.Text)}))}),GenericDisplayMessage:e.Text}),se=e.Record({metadata:E,consent_message:oe}),v=e.Record({description:e.Text}),ie=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),InsufficientPayment:v,UnsupportedCanisterCall:v,ConsentMessageUnavailable:v}),pe=e.Variant({Ok:se,Err:ie}),le=e.Record({account:c,spender:c}),de=e.Record({allowance:e.Nat,expires_at:e.Opt(s)}),_e=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}),me=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})}),ue=e.Variant({Ok:i,Err:me}),ge=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}),fe=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})}),Ne=e.Variant({Ok:i,Err:fe}),Oe=e.Record({from:e.Opt(e.Principal)}),xe=e.Vec(e.Record({end:e.Nat,canister_id:e.Principal,start:e.Nat}));r.fill(e.Variant({Int:e.Int,Map:e.Vec(e.Tuple(e.Text,r)),Nat:e.Nat,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(r)})),a.fill(e.Record({log_length:e.Nat,blocks:e.Vec(e.Record({id:e.Nat,block:r})),archived_blocks:e.Vec(e.Record({args:e.Vec(_),callback:e.Func([e.Vec(_)],[a],[])}))}));let Te=e.Record({certificate:e.Vec(e.Nat8),hash_tree:e.Vec(e.Nat8)});return e.Service({archives:e.Func([],[e.Vec(g)],[]),get_blocks:e.Func([_],[h],[]),get_data_certificate:e.Func([],[k],[]),get_transactions:e.Func([y],[D],[]),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,n))],[]),icrc1_minting_account:e.Func([],[e.Opt(c)],[]),icrc1_name:e.Func([],[e.Text],[]),icrc1_supported_standards:e.Func([],[e.Vec(ee)],[]),icrc1_symbol:e.Func([],[e.Text],[]),icrc1_total_supply:e.Func([],[p],[]),icrc1_transfer:e.Func([te],[ce],[]),icrc21_canister_call_consent_message:e.Func([ne],[pe],[]),icrc2_allowance:e.Func([le],[de],[]),icrc2_approve:e.Func([_e],[ue],[]),icrc2_transfer_from:e.Func([ge],[Ne],[]),icrc3_get_archives:e.Func([Oe],[xe],[]),icrc3_get_blocks:e.Func([e.Vec(_)],[a],[]),icrc3_get_tip_certificate:e.Func([],[e.Opt(Te)],[]),icrc3_supported_block_types:e.Func([],[e.Vec(e.Record({url:e.Text,block_type:e.Text}))],[]),is_ledger_ready:e.Func([],[e.Bool],[])})};var Se=({IDL:e})=>{let a=e.Rec(),r=e.Rec(),t=e.Rec(),o=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)}),n=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}),u=e.Record({icrc2:e.Bool}),N=e.Record({change_archive_options:e.Opt(o),token_symbol:e.Opt(e.Text),transfer_fee:e.Opt(e.Nat),metadata:e.Opt(e.Vec(e.Tuple(e.Text,n))),change_fee_collector:e.Opt(f),max_memo_length:e.Opt(e.Nat16),token_name:e.Opt(e.Text),feature_flags:e.Opt(u)}),O=e.Record({decimals:e.Opt(e.Nat8),token_symbol:e.Text,transfer_fee:e.Nat,metadata:e.Vec(e.Tuple(e.Text,n)),minting_account:c,initial_balances:e.Vec(e.Tuple(c,e.Nat)),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(u)}),T=e.Variant({Upgrade:e.Opt(N),Init:O}),i=e.Nat,g=e.Record({block_range_end:i,canister_id:e.Principal,block_range_start:i}),_=e.Record({start:i,length:e.Nat}),V=e.Vec(e.Tuple(e.Text,t));t.fill(e.Variant({Int:e.Int,Map:V,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(t)}));let R=t,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}))}),k=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),hash_tree:e.Vec(e.Nat8)}),x=e.Nat,y=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)}),j=e.Record({to:c,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:e.Nat}),J=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}),K=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)}),w=e.Record({burn:e.Opt(F),kind:e.Text,mint:e.Opt(j),approve:e.Opt(J),timestamp:s,transfer:e.Opt(K)}),I=e.Record({transactions:e.Vec(w)}),L=e.Func([y],[I],["query"]),D=e.Record({first_index:x,log_length:e.Nat,transactions:e.Vec(w),archived_transactions:e.Vec(e.Record({callback:L,start:x,length:e.Nat}))}),p=e.Nat,ee=e.Record({url:e.Text,name:e.Text}),te=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}),re=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})}),ce=e.Variant({Ok:i,Err:re}),E=e.Record({utc_offset_minutes:e.Opt(e.Int16),language:e.Text}),ae=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})}))}),ne=e.Record({arg:e.Vec(e.Nat8),method:e.Text,user_preferences:ae}),oe=e.Variant({LineDisplayMessage:e.Record({pages:e.Vec(e.Record({lines:e.Vec(e.Text)}))}),GenericDisplayMessage:e.Text}),se=e.Record({metadata:E,consent_message:oe}),v=e.Record({description:e.Text}),ie=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),InsufficientPayment:v,UnsupportedCanisterCall:v,ConsentMessageUnavailable:v}),pe=e.Variant({Ok:se,Err:ie}),le=e.Record({account:c,spender:c}),de=e.Record({allowance:e.Nat,expires_at:e.Opt(s)}),_e=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}),me=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})}),ue=e.Variant({Ok:i,Err:me}),ge=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}),fe=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})}),Ne=e.Variant({Ok:i,Err:fe}),Oe=e.Record({from:e.Opt(e.Principal)}),xe=e.Vec(e.Record({end:e.Nat,canister_id:e.Principal,start:e.Nat}));r.fill(e.Variant({Int:e.Int,Map:e.Vec(e.Tuple(e.Text,r)),Nat:e.Nat,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(r)})),a.fill(e.Record({log_length:e.Nat,blocks:e.Vec(e.Record({id:e.Nat,block:r})),archived_blocks:e.Vec(e.Record({args:e.Vec(_),callback:e.Func([e.Vec(_)],[a],["query"])}))}));let Te=e.Record({certificate:e.Vec(e.Nat8),hash_tree:e.Vec(e.Nat8)});return e.Service({archives:e.Func([],[e.Vec(g)],["query"]),get_blocks:e.Func([_],[h],["query"]),get_data_certificate:e.Func([],[k],["query"]),get_transactions:e.Func([y],[D],["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,n))],["query"]),icrc1_minting_account:e.Func([],[e.Opt(c)],["query"]),icrc1_name:e.Func([],[e.Text],["query"]),icrc1_supported_standards:e.Func([],[e.Vec(ee)],["query"]),icrc1_symbol:e.Func([],[e.Text],["query"]),icrc1_total_supply:e.Func([],[p],["query"]),icrc1_transfer:e.Func([te],[ce],[]),icrc21_canister_call_consent_message:e.Func([ne],[pe],[]),icrc2_allowance:e.Func([le],[de],["query"]),icrc2_approve:e.Func([_e],[ue],[]),icrc2_transfer_from:e.Func([ge],[Ne],[]),icrc3_get_archives:e.Func([Oe],[xe],["query"]),icrc3_get_blocks:e.Func([e.Vec(_)],[a],["query"]),icrc3_get_tip_certificate:e.Func([],[e.Opt(Te)],["query"]),icrc3_supported_block_types:e.Func([],[e.Vec(e.Record({url:e.Text,block_type:e.Text}))],["query"]),is_ledger_ready:e.Func([],[e.Bool],["query"])})};var X=class e extends G.Canister{constructor(){super(...arguments);this.metadata=r=>this.caller(r).icrc1_metadata();this.transactionFee=r=>this.caller(r).icrc1_fee();this.balance=r=>this.caller({certified:r.certified}).icrc1_balance_of({owner:r.owner,subaccount:(0,G.toNullable)(r.subaccount)});this.transfer=async r=>{let t=await this.caller({certified:!0}).icrc1_transfer(ye(r));if("Err"in t)throw new B({errorType:t.Err,msg:"Failed to transfer"});return t.Ok};this.totalTokensSupply=r=>this.caller(r).icrc1_total_supply();this.transferFrom=async r=>{let t=await this.caller({certified:!0}).icrc2_transfer_from(Ve(r));if("Err"in t)throw new B({errorType:t.Err,msg:"Failed to transfer from"});return t.Ok};this.approve=async r=>{let t=await this.caller({certified:!0}).icrc2_approve(be(r));if("Err"in t)throw new B({errorType:t.Err,msg:"Failed to entitle the spender to transfer the amount"});return t.Ok};this.allowance=async r=>{let{certified:t,...o}=r;return this.caller({certified:t}).icrc2_allowance({...o})};this.consentMessage=async r=>{let{icrc21_canister_call_consent_message:t}=this.caller({certified:!0}),o=await t(Ae(r));if("Err"in o)throw he(o.Err);return o.Ok};this.getBlocks=r=>this.caller({certified:r.certified}).icrc3_get_blocks(r.args)}static create(r){let{service:t,certifiedService:o,canisterId:n}=(0,G.createServices)({options:r,idlFactory:Se,certifiedIdlFactory:Ee});return new e(n,t,o)}};var Fe=(n=>(n.SYMBOL="icrc1:symbol",n.NAME="icrc1:name",n.DECIMALS="icrc1:decimals",n.FEE="icrc1:fee",n.LOGO="icrc1:logo",n))(Fe||{});var ve=require("@dfinity/principal"),m=require("@dfinity/utils");var Ze=64,Xe=({owner:e,subaccount:a})=>{if((0,m.isNullish)(a))return e.toText();let t=(o=>o.replace(/^0+/,""))((0,m.uint8ArrayToHexString)(Uint8Array.from(a)));return t.length===0?e.toText():`${e.toText()}-${Me({owner:e,subaccount:a})}.${t}`},Me=({owner:e,subaccount:a})=>{let r=(0,m.bigEndianCrc32)(Uint8Array.from([...e.toUint8Array(),...a]));return(0,m.encodeBase32)(r)},Ye=e=>{let[a,r]=e.split(".");if(!(0,m.notEmptyString)(a))throw new Error("Invalid account. No string provided.");if((0,m.isNullish)(r))return{owner:ve.Principal.fromText(e)};let[t,...o]=a.split("-").reverse(),n=o.reverse().join("-"),l={owner:ve.Principal.fromText(n),subaccount:(0,m.hexStringToUint8Array)(r.padStart(Ze,"0"))};if(Me(l)!==t)throw new Error("Invalid account. Invalid checksum.");return l},je=e=>{let a=e.reduce((t,[o,n])=>{switch(o){case"icrc1:symbol":t={...t,..."Text"in n&&{symbol:n.Text}};break;case"icrc1:name":t={...t,..."Text"in n&&{name:n.Text}};break;case"icrc1:fee":t={...t,..."Nat"in n&&{fee:n.Nat}};break;case"icrc1:decimals":t={...t,..."Nat"in n&&{decimals:Number(n.Nat)}};break;case"icrc1:logo":t={...t,..."Text"in n&&{icon:n.Text}}}return t},{});if((t=>(0,m.nonNullish)(t.symbol)&&(0,m.nonNullish)(t.name)&&(0,m.nonNullish)(t.fee)&&(0,m.nonNullish)(t.decimals))(a))return a};var Y=require("@dfinity/utils"),Je=e=>{let a=/^([a-zA-Z]+):([A-Za-z0-9:\-.]+).*?(?:[?&](?:amount|value)=(\d+(?:\.\d+)?))?$/,r=e.match(a);if((0,Y.isNullish)(r))return;let[t,o,n,l]=r;return{token:o,identifier:n,...(0,Y.nonNullish)(l)&&!isNaN(parseFloat(l))&&{amount:parseFloat(l)}}};0&&(module.exports={ConsentMessageError,ConsentMessageUnavailableError,GenericError,IcrcIndexCanister,IcrcIndexNgCanister,IcrcLedgerCanister,IcrcMetadataResponseEntries,IcrcTransferError,IndexError,InsufficientPaymentError,UnsupportedCanisterCallError,decodeIcrcAccount,decodePayment,encodeIcrcAccount,mapIcrc21ConsentMessageError,mapTokenMetadata,toApproveArgs,toIcrc21ConsentMessageArgs,toTransferArg,toTransferFromArgs});
1
+ "use strict";var ye=Object.defineProperty;var Ue=Object.getOwnPropertyDescriptor;var ze=Object.getOwnPropertyNames;var Qe=Object.prototype.hasOwnProperty;var $e=(e,t)=>{for(var r in t)ye(e,r,{get:t[r],enumerable:!0})},He=(e,t,r,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ze(t))!Qe.call(e,o)&&o!==r&&ye(e,o,{get:()=>t[o],enumerable:!(c=Ue(t,o))||c.enumerable});return e};var We=e=>He(ye({},"__esModule",{value:!0}),e);var Ie={};$e(Ie,{ConsentMessageError:()=>B,ConsentMessageUnavailableError:()=>U,GenericError:()=>E,IcrcIndexCanister:()=>Z,IcrcIndexNgCanister:()=>W,IcrcLedgerCanister:()=>Y,IcrcMetadataResponseEntries:()=>Fe,IcrcTransferError:()=>S,IndexError:()=>P,InsufficientPaymentError:()=>M,UnsupportedCanisterCallError:()=>q,decodeIcrcAccount:()=>je,decodePayment:()=>Ke,encodeIcrcAccount:()=>Ye,mapIcrc21ConsentMessageError:()=>ke,mapTokenMetadata:()=>Je,toApproveArgs:()=>Ae,toIcrc21ConsentMessageArgs:()=>he,toTransferArg:()=>Ve,toTransferFromArgs:()=>be});module.exports=We(Ie);var _=require("@dfinity/utils"),Ve=({from_subaccount:e,fee:t,created_at_time:r,memo:c,...o})=>({...o,fee:(0,_.toNullable)(t),memo:(0,_.toNullable)(c),from_subaccount:(0,_.toNullable)(e),created_at_time:(0,_.toNullable)(r)}),be=({spender_subaccount:e,fee:t,created_at_time:r,memo:c,...o})=>({...o,fee:(0,_.toNullable)(t),memo:(0,_.toNullable)(c),spender_subaccount:(0,_.toNullable)(e),created_at_time:(0,_.toNullable)(r)}),Ae=({fee:e,created_at_time:t,memo:r,from_subaccount:c,expected_allowance:o,expires_at:n,...d})=>({...d,fee:(0,_.toNullable)(e),memo:(0,_.toNullable)(r),from_subaccount:(0,_.toNullable)(c),created_at_time:(0,_.toNullable)(t),expected_allowance:(0,_.toNullable)(o),expires_at:(0,_.toNullable)(n)}),he=({userPreferences:{metadata:{utcOffsetMinutes:e,language:t},deriveSpec:r},...c})=>({...c,user_preferences:{metadata:{language:t,utc_offset_minutes:(0,_.toNullable)(e)},device_spec:(0,_.isNullish)(r)?(0,_.toNullable)():(0,_.toNullable)("GenericDisplay"in r?{GenericDisplay:null}:{LineDisplay:{characters_per_line:r.LineDisplay.charactersPerLine,lines_per_page:r.LineDisplay.linesPerPage}})}});var P=class extends Error{};var S=class extends Error{errorType;constructor({msg:t,errorType:r}){super(t),this.errorType=r}},E=class extends Error{constructor(r,c){super();this.message=r;this.error_code=c}},B=class extends Error{},M=class extends B{},q=class extends B{},U=class extends B{},ke=e=>"GenericError"in e?new E(e.GenericError.description,e.GenericError.error_code):"InsufficientPayment"in e?new M(e.InsufficientPayment.description):"UnsupportedCanisterCall"in e?new q(e.UnsupportedCanisterCall.description):"ConsentMessageUnavailable"in e?new U(e.ConsentMessageUnavailable.description):new B(`Unknown error type ${JSON.stringify(e)}`);var Ce=require("@dfinity/utils");var Pe=({IDL:e})=>{let t=e.Rec(),r=e.Record({ledger_id:e.Opt(e.Principal),retrieve_blocks_from_ledger_interval_seconds:e.Opt(e.Nat64)}),c=e.Record({ledger_id:e.Principal,retrieve_blocks_from_ledger_interval_seconds:e.Opt(e.Nat64)}),o=e.Variant({Upgrade:r,Init:c}),n=e.Nat,d=e.Vec(e.Nat8),a=e.Record({owner:e.Principal,subaccount:e.Opt(d)}),f=e.Record({max_results:e.Nat,start:e.Opt(n),account:a}),p=e.Nat,N=e.Record({from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:p,spender:e.Opt(a)}),O=e.Record({to:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:p}),T=e.Record({fee:e.Opt(p),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:p,expected_allowance:e.Opt(p),expires_at:e.Opt(e.Nat64),spender:a}),i=e.Record({to:a,fee:e.Opt(p),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:p,spender:e.Opt(a)}),g=e.Record({burn:e.Opt(N),kind:e.Text,mint:e.Opt(O),approve:e.Opt(T),timestamp:e.Nat64,transfer:e.Opt(i)}),m=e.Record({id:n,transaction:g}),V=e.Record({balance:p,transactions:e.Vec(m),oldest_tx_id:e.Opt(n)}),R=e.Record({message:e.Text}),b=e.Variant({Ok:V,Err:R}),A=e.Record({start:e.Nat,length:e.Nat}),h=e.Vec(e.Tuple(e.Text,t));t.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(t)}));let k=t,x=e.Record({blocks:e.Vec(k),chain_length:e.Nat64}),y=e.Record({ranges:e.Vec(e.Tuple(a,e.Vec(e.Tuple(n,n))))}),s=e.Record({owner:e.Principal,start:e.Opt(d)}),F=e.Record({num_blocks_synced:n});return e.Service({get_account_transactions:e.Func([f],[b],[]),get_blocks:e.Func([A],[x],[]),get_fee_collectors_ranges:e.Func([],[y],[]),icrc1_balance_of:e.Func([a],[p],[]),ledger_id:e.Func([],[e.Principal],[]),list_subaccounts:e.Func([s],[e.Vec(d)],[]),status:e.Func([],[F],[])})};var Se=({IDL:e})=>{let t=e.Rec(),r=e.Record({ledger_id:e.Opt(e.Principal),retrieve_blocks_from_ledger_interval_seconds:e.Opt(e.Nat64)}),c=e.Record({ledger_id:e.Principal,retrieve_blocks_from_ledger_interval_seconds:e.Opt(e.Nat64)}),o=e.Variant({Upgrade:r,Init:c}),n=e.Nat,d=e.Vec(e.Nat8),a=e.Record({owner:e.Principal,subaccount:e.Opt(d)}),f=e.Record({max_results:e.Nat,start:e.Opt(n),account:a}),p=e.Nat,N=e.Record({from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:p,spender:e.Opt(a)}),O=e.Record({to:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:p}),T=e.Record({fee:e.Opt(p),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:p,expected_allowance:e.Opt(p),expires_at:e.Opt(e.Nat64),spender:a}),i=e.Record({to:a,fee:e.Opt(p),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:p,spender:e.Opt(a)}),g=e.Record({burn:e.Opt(N),kind:e.Text,mint:e.Opt(O),approve:e.Opt(T),timestamp:e.Nat64,transfer:e.Opt(i)}),m=e.Record({id:n,transaction:g}),V=e.Record({balance:p,transactions:e.Vec(m),oldest_tx_id:e.Opt(n)}),R=e.Record({message:e.Text}),b=e.Variant({Ok:V,Err:R}),A=e.Record({start:e.Nat,length:e.Nat}),h=e.Vec(e.Tuple(e.Text,t));t.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(t)}));let k=t,x=e.Record({blocks:e.Vec(k),chain_length:e.Nat64}),y=e.Record({ranges:e.Vec(e.Tuple(a,e.Vec(e.Tuple(n,n))))}),s=e.Record({owner:e.Principal,start:e.Opt(d)}),F=e.Record({num_blocks_synced:n});return e.Service({get_account_transactions:e.Func([f],[b],["query"]),get_blocks:e.Func([A],[x],["query"]),get_fee_collectors_ranges:e.Func([],[y],["query"]),icrc1_balance_of:e.Func([a],[p],["query"]),ledger_id:e.Func([],[e.Principal],["query"]),list_subaccounts:e.Func([s],[e.Vec(d)],["query"]),status:e.Func([],[F],["query"])})};var Q=require("@dfinity/utils"),z=class extends Q.Canister{balance=t=>this.caller({certified:t.certified}).icrc1_balance_of({owner:t.owner,subaccount:(0,Q.toNullable)(t.subaccount)})};var $=require("@dfinity/utils"),Ze=({owner:e,subaccount:t})=>({owner:e,subaccount:(0,$.toNullable)(t)}),H=({account:e,max_results:t,start:r})=>({account:Ze(e),max_results:t,start:(0,$.toNullable)(r)}),Be=({owner:e,start:t})=>({owner:e,start:(0,$.toNullable)(t)});var W=class e extends z{static create(t){let{service:r,certifiedService:c,canisterId:o}=(0,Ce.createServices)({options:t,idlFactory:Se,certifiedIdlFactory:Pe});return new e(o,r,c)}getTransactions=async({certified:t,...r})=>{let c=await this.caller({certified:t}).get_account_transactions(H(r));if("Err"in c)throw new P(c.Err.message);return c.Ok};ledgerId=t=>{let{ledger_id:r}=this.caller(t);return r()};status=t=>this.caller(t).status();listSubaccounts=({certified:t,...r})=>this.caller({certified:t}).list_subaccounts(Be(r))};var X=require("@dfinity/utils");var Ge=({IDL:e})=>{let t=e.Record({ledger_id:e.Principal}),r=e.Nat,c=e.Record({owner:e.Principal,subaccount:e.Opt(e.Vec(e.Nat8))}),o=e.Record({max_results:e.Nat,start:e.Opt(r),account:c}),n=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)}),d=e.Record({to:c,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat}),a=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}),f=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)}),p=e.Record({burn:e.Opt(n),kind:e.Text,mint:e.Opt(d),approve:e.Opt(a),timestamp:e.Nat64,transfer:e.Opt(f)}),N=e.Record({id:r,transaction:p}),O=e.Record({transactions:e.Vec(N),oldest_tx_id:e.Opt(r)}),T=e.Record({message:e.Text}),i=e.Variant({Ok:O,Err:T}),g=e.Vec(e.Nat8),m=e.Record({owner:e.Principal,start:e.Opt(g)});return e.Service({get_account_transactions:e.Func([o],[i],[]),ledger_id:e.Func([],[e.Principal],[]),list_subaccounts:e.Func([m],[e.Vec(g)],[])})};var we=({IDL:e})=>{let t=e.Record({ledger_id:e.Principal}),r=e.Nat,c=e.Record({owner:e.Principal,subaccount:e.Opt(e.Vec(e.Nat8))}),o=e.Record({max_results:e.Nat,start:e.Opt(r),account:c}),n=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)}),d=e.Record({to:c,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat}),a=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}),f=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)}),p=e.Record({burn:e.Opt(n),kind:e.Text,mint:e.Opt(d),approve:e.Opt(a),timestamp:e.Nat64,transfer:e.Opt(f)}),N=e.Record({id:r,transaction:p}),O=e.Record({transactions:e.Vec(N),oldest_tx_id:e.Opt(r)}),T=e.Record({message:e.Text}),i=e.Variant({Ok:O,Err:T}),g=e.Vec(e.Nat8),m=e.Record({owner:e.Principal,start:e.Opt(g)});return e.Service({get_account_transactions:e.Func([o],[i],[]),ledger_id:e.Func([],[e.Principal],["query"]),list_subaccounts:e.Func([m],[e.Vec(g)],["query"])})};var Z=class e extends X.Canister{static create(t){let{service:r,certifiedService:c,canisterId:o}=(0,X.createServices)({options:t,idlFactory:we,certifiedIdlFactory:Ge});return new e(o,r,c)}getTransactions=async t=>{let r=await this.caller({certified:!0}).get_account_transactions(H(t));if("Err"in r)throw new P(r.Err.message);return r.Ok};ledgerId=t=>{let{ledger_id:r}=this.caller(t);return r()}};var C=require("@dfinity/utils");var Ee=({IDL:e})=>{let t=e.Rec(),r=e.Rec(),c=e.Rec(),o=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)}),n=e.Variant({Int:e.Int,Nat:e.Nat,Blob:e.Vec(e.Nat8),Text:e.Text}),d=e.Vec(e.Nat8),a=e.Record({owner:e.Principal,subaccount:e.Opt(d)}),f=e.Variant({SetTo:a,Unset:e.Null}),p=e.Record({icrc2:e.Bool}),N=e.Record({change_archive_options:e.Opt(o),token_symbol:e.Opt(e.Text),transfer_fee:e.Opt(e.Nat),metadata:e.Opt(e.Vec(e.Tuple(e.Text,n))),change_fee_collector:e.Opt(f),max_memo_length:e.Opt(e.Nat16),token_name:e.Opt(e.Text),feature_flags:e.Opt(p)}),O=e.Record({decimals:e.Opt(e.Nat8),token_symbol:e.Text,transfer_fee:e.Nat,metadata:e.Vec(e.Tuple(e.Text,n)),minting_account:a,initial_balances:e.Vec(e.Tuple(a,e.Nat)),fee_collector_account:e.Opt(a),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(p)}),T=e.Variant({Upgrade:e.Opt(N),Init:O}),i=e.Nat,g=e.Record({block_range_end:i,canister_id:e.Principal,block_range_start:i}),m=e.Record({start:i,length:e.Nat}),V=e.Vec(e.Tuple(e.Text,c));c.fill(e.Variant({Int:e.Int,Map:V,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(c)}));let R=c,b=e.Record({blocks:e.Vec(R)}),A=e.Func([m],[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}))}),k=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),hash_tree:e.Vec(e.Nat8)}),x=e.Nat,y=e.Record({start:x,length:e.Nat}),s=e.Nat64,F=e.Record({from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:e.Nat,spender:e.Opt(a)}),J=e.Record({to:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:e.Nat}),K=e.Record({fee:e.Opt(e.Nat),from:a,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:a}),I=e.Record({to:a,fee:e.Opt(e.Nat),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:e.Nat,spender:e.Opt(a)}),G=e.Record({burn:e.Opt(F),kind:e.Text,mint:e.Opt(J),approve:e.Opt(K),timestamp:s,transfer:e.Opt(I)}),L=e.Record({transactions:e.Vec(G)}),D=e.Func([y],[L],[]),ee=e.Record({first_index:x,log_length:e.Nat,transactions:e.Vec(G),archived_transactions:e.Vec(e.Record({callback:D,start:x,length:e.Nat}))}),l=e.Nat,te=e.Record({url:e.Text,name:e.Text}),re=e.Record({to:a,fee:e.Opt(l),memo:e.Opt(e.Vec(e.Nat8)),from_subaccount:e.Opt(d),created_at_time:e.Opt(s),amount:l}),ce=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,BadBurn:e.Record({min_burn_amount:l}),Duplicate:e.Record({duplicate_of:i}),BadFee:e.Record({expected_fee:l}),CreatedInFuture:e.Record({ledger_time:s}),TooOld:e.Null,InsufficientFunds:e.Record({balance:l})}),ae=e.Variant({Ok:i,Err:ce}),w=e.Record({utc_offset_minutes:e.Opt(e.Int16),language:e.Text}),ne=e.Record({metadata:w,device_spec:e.Opt(e.Variant({GenericDisplay:e.Null,LineDisplay:e.Record({characters_per_line:e.Nat16,lines_per_page:e.Nat16})}))}),oe=e.Record({arg:e.Vec(e.Nat8),method:e.Text,user_preferences:ne}),se=e.Variant({LineDisplayMessage:e.Record({pages:e.Vec(e.Record({lines:e.Vec(e.Text)}))}),GenericDisplayMessage:e.Text}),ie=e.Record({metadata:w,consent_message:se}),v=e.Record({description:e.Text}),pe=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),InsufficientPayment:v,UnsupportedCanisterCall:v,ConsentMessageUnavailable:v}),le=e.Variant({Ok:ie,Err:pe}),de=e.Record({account:a,spender:a}),_e=e.Record({allowance:e.Nat,expires_at:e.Opt(s)}),me=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:a}),ue=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})}),ge=e.Variant({Ok:i,Err:ue}),fe=e.Record({to:a,fee:e.Opt(l),spender_subaccount:e.Opt(d),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:l}),Ne=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,InsufficientAllowance:e.Record({allowance:l}),BadBurn:e.Record({min_burn_amount:l}),Duplicate:e.Record({duplicate_of:i}),BadFee:e.Record({expected_fee:l}),CreatedInFuture:e.Record({ledger_time:s}),TooOld:e.Null,InsufficientFunds:e.Record({balance:l})}),Oe=e.Variant({Ok:i,Err:Ne}),xe=e.Record({from:e.Opt(e.Principal)}),Te=e.Vec(e.Record({end:e.Nat,canister_id:e.Principal,start:e.Nat}));r.fill(e.Variant({Int:e.Int,Map:e.Vec(e.Tuple(e.Text,r)),Nat:e.Nat,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(r)})),t.fill(e.Record({log_length:e.Nat,blocks:e.Vec(e.Record({id:e.Nat,block:r})),archived_blocks:e.Vec(e.Record({args:e.Vec(m),callback:e.Func([e.Vec(m)],[t],[])}))}));let Re=e.Record({certificate:e.Vec(e.Nat8),hash_tree:e.Vec(e.Nat8)});return e.Service({archives:e.Func([],[e.Vec(g)],[]),get_blocks:e.Func([m],[h],[]),get_data_certificate:e.Func([],[k],[]),get_transactions:e.Func([y],[ee],[]),icrc10_supported_standards:e.Func([],[e.Vec(e.Record({url:e.Text,name:e.Text}))],[]),icrc1_balance_of:e.Func([a],[l],[]),icrc1_decimals:e.Func([],[e.Nat8],[]),icrc1_fee:e.Func([],[l],[]),icrc1_metadata:e.Func([],[e.Vec(e.Tuple(e.Text,n))],[]),icrc1_minting_account:e.Func([],[e.Opt(a)],[]),icrc1_name:e.Func([],[e.Text],[]),icrc1_supported_standards:e.Func([],[e.Vec(te)],[]),icrc1_symbol:e.Func([],[e.Text],[]),icrc1_total_supply:e.Func([],[l],[]),icrc1_transfer:e.Func([re],[ae],[]),icrc21_canister_call_consent_message:e.Func([oe],[le],[]),icrc2_allowance:e.Func([de],[_e],[]),icrc2_approve:e.Func([me],[ge],[]),icrc2_transfer_from:e.Func([fe],[Oe],[]),icrc3_get_archives:e.Func([xe],[Te],[]),icrc3_get_blocks:e.Func([e.Vec(m)],[t],[]),icrc3_get_tip_certificate:e.Func([],[e.Opt(Re)],[]),icrc3_supported_block_types:e.Func([],[e.Vec(e.Record({url:e.Text,block_type:e.Text}))],[]),is_ledger_ready:e.Func([],[e.Bool],[])})};var Me=({IDL:e})=>{let t=e.Rec(),r=e.Rec(),c=e.Rec(),o=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)}),n=e.Variant({Int:e.Int,Nat:e.Nat,Blob:e.Vec(e.Nat8),Text:e.Text}),d=e.Vec(e.Nat8),a=e.Record({owner:e.Principal,subaccount:e.Opt(d)}),f=e.Variant({SetTo:a,Unset:e.Null}),p=e.Record({icrc2:e.Bool}),N=e.Record({change_archive_options:e.Opt(o),token_symbol:e.Opt(e.Text),transfer_fee:e.Opt(e.Nat),metadata:e.Opt(e.Vec(e.Tuple(e.Text,n))),change_fee_collector:e.Opt(f),max_memo_length:e.Opt(e.Nat16),token_name:e.Opt(e.Text),feature_flags:e.Opt(p)}),O=e.Record({decimals:e.Opt(e.Nat8),token_symbol:e.Text,transfer_fee:e.Nat,metadata:e.Vec(e.Tuple(e.Text,n)),minting_account:a,initial_balances:e.Vec(e.Tuple(a,e.Nat)),fee_collector_account:e.Opt(a),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(p)}),T=e.Variant({Upgrade:e.Opt(N),Init:O}),i=e.Nat,g=e.Record({block_range_end:i,canister_id:e.Principal,block_range_start:i}),m=e.Record({start:i,length:e.Nat}),V=e.Vec(e.Tuple(e.Text,c));c.fill(e.Variant({Int:e.Int,Map:V,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(c)}));let R=c,b=e.Record({blocks:e.Vec(R)}),A=e.Func([m],[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}))}),k=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),hash_tree:e.Vec(e.Nat8)}),x=e.Nat,y=e.Record({start:x,length:e.Nat}),s=e.Nat64,F=e.Record({from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:e.Nat,spender:e.Opt(a)}),J=e.Record({to:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:e.Nat}),K=e.Record({fee:e.Opt(e.Nat),from:a,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:a}),I=e.Record({to:a,fee:e.Opt(e.Nat),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:e.Nat,spender:e.Opt(a)}),G=e.Record({burn:e.Opt(F),kind:e.Text,mint:e.Opt(J),approve:e.Opt(K),timestamp:s,transfer:e.Opt(I)}),L=e.Record({transactions:e.Vec(G)}),D=e.Func([y],[L],["query"]),ee=e.Record({first_index:x,log_length:e.Nat,transactions:e.Vec(G),archived_transactions:e.Vec(e.Record({callback:D,start:x,length:e.Nat}))}),l=e.Nat,te=e.Record({url:e.Text,name:e.Text}),re=e.Record({to:a,fee:e.Opt(l),memo:e.Opt(e.Vec(e.Nat8)),from_subaccount:e.Opt(d),created_at_time:e.Opt(s),amount:l}),ce=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,BadBurn:e.Record({min_burn_amount:l}),Duplicate:e.Record({duplicate_of:i}),BadFee:e.Record({expected_fee:l}),CreatedInFuture:e.Record({ledger_time:s}),TooOld:e.Null,InsufficientFunds:e.Record({balance:l})}),ae=e.Variant({Ok:i,Err:ce}),w=e.Record({utc_offset_minutes:e.Opt(e.Int16),language:e.Text}),ne=e.Record({metadata:w,device_spec:e.Opt(e.Variant({GenericDisplay:e.Null,LineDisplay:e.Record({characters_per_line:e.Nat16,lines_per_page:e.Nat16})}))}),oe=e.Record({arg:e.Vec(e.Nat8),method:e.Text,user_preferences:ne}),se=e.Variant({LineDisplayMessage:e.Record({pages:e.Vec(e.Record({lines:e.Vec(e.Text)}))}),GenericDisplayMessage:e.Text}),ie=e.Record({metadata:w,consent_message:se}),v=e.Record({description:e.Text}),pe=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),InsufficientPayment:v,UnsupportedCanisterCall:v,ConsentMessageUnavailable:v}),le=e.Variant({Ok:ie,Err:pe}),de=e.Record({account:a,spender:a}),_e=e.Record({allowance:e.Nat,expires_at:e.Opt(s)}),me=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:a}),ue=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})}),ge=e.Variant({Ok:i,Err:ue}),fe=e.Record({to:a,fee:e.Opt(l),spender_subaccount:e.Opt(d),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:l}),Ne=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,InsufficientAllowance:e.Record({allowance:l}),BadBurn:e.Record({min_burn_amount:l}),Duplicate:e.Record({duplicate_of:i}),BadFee:e.Record({expected_fee:l}),CreatedInFuture:e.Record({ledger_time:s}),TooOld:e.Null,InsufficientFunds:e.Record({balance:l})}),Oe=e.Variant({Ok:i,Err:Ne}),xe=e.Record({from:e.Opt(e.Principal)}),Te=e.Vec(e.Record({end:e.Nat,canister_id:e.Principal,start:e.Nat}));r.fill(e.Variant({Int:e.Int,Map:e.Vec(e.Tuple(e.Text,r)),Nat:e.Nat,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(r)})),t.fill(e.Record({log_length:e.Nat,blocks:e.Vec(e.Record({id:e.Nat,block:r})),archived_blocks:e.Vec(e.Record({args:e.Vec(m),callback:e.Func([e.Vec(m)],[t],["query"])}))}));let Re=e.Record({certificate:e.Vec(e.Nat8),hash_tree:e.Vec(e.Nat8)});return e.Service({archives:e.Func([],[e.Vec(g)],["query"]),get_blocks:e.Func([m],[h],["query"]),get_data_certificate:e.Func([],[k],["query"]),get_transactions:e.Func([y],[ee],["query"]),icrc10_supported_standards:e.Func([],[e.Vec(e.Record({url:e.Text,name:e.Text}))],["query"]),icrc1_balance_of:e.Func([a],[l],["query"]),icrc1_decimals:e.Func([],[e.Nat8],["query"]),icrc1_fee:e.Func([],[l],["query"]),icrc1_metadata:e.Func([],[e.Vec(e.Tuple(e.Text,n))],["query"]),icrc1_minting_account:e.Func([],[e.Opt(a)],["query"]),icrc1_name:e.Func([],[e.Text],["query"]),icrc1_supported_standards:e.Func([],[e.Vec(te)],["query"]),icrc1_symbol:e.Func([],[e.Text],["query"]),icrc1_total_supply:e.Func([],[l],["query"]),icrc1_transfer:e.Func([re],[ae],[]),icrc21_canister_call_consent_message:e.Func([oe],[le],[]),icrc2_allowance:e.Func([de],[_e],["query"]),icrc2_approve:e.Func([me],[ge],[]),icrc2_transfer_from:e.Func([fe],[Oe],[]),icrc3_get_archives:e.Func([xe],[Te],["query"]),icrc3_get_blocks:e.Func([e.Vec(m)],[t],["query"]),icrc3_get_tip_certificate:e.Func([],[e.Opt(Re)],["query"]),icrc3_supported_block_types:e.Func([],[e.Vec(e.Record({url:e.Text,block_type:e.Text}))],["query"]),is_ledger_ready:e.Func([],[e.Bool],["query"])})};var Y=class e extends C.Canister{static create(t){let{service:r,certifiedService:c,canisterId:o}=(0,C.createServices)({options:t,idlFactory:Me,certifiedIdlFactory:Ee});return new e(o,r,c)}metadata=t=>this.caller(t).icrc1_metadata();transactionFee=t=>this.caller(t).icrc1_fee();balance=t=>this.caller({certified:t.certified}).icrc1_balance_of({owner:t.owner,subaccount:(0,C.toNullable)(t.subaccount)});transfer=async t=>{let r=await this.caller({certified:!0}).icrc1_transfer(Ve(t));if("Err"in r)throw new S({errorType:r.Err,msg:"Failed to transfer"});return r.Ok};totalTokensSupply=t=>this.caller(t).icrc1_total_supply();transferFrom=async t=>{let r=await this.caller({certified:!0}).icrc2_transfer_from(be(t));if("Err"in r)throw new S({errorType:r.Err,msg:"Failed to transfer from"});return r.Ok};approve=async t=>{let r=await this.caller({certified:!0}).icrc2_approve(Ae(t));if("Err"in r)throw new S({errorType:r.Err,msg:"Failed to entitle the spender to transfer the amount"});return r.Ok};allowance=async t=>{let{certified:r,...c}=t;return this.caller({certified:r}).icrc2_allowance({...c})};consentMessage=async t=>{let{icrc21_canister_call_consent_message:r}=this.caller({certified:!0}),c=await r(he(t));if("Err"in c)throw ke(c.Err);return c.Ok};getBlocks=t=>this.caller({certified:t.certified}).icrc3_get_blocks(t.args)};var Fe=(n=>(n.SYMBOL="icrc1:symbol",n.NAME="icrc1:name",n.DECIMALS="icrc1:decimals",n.FEE="icrc1:fee",n.LOGO="icrc1:logo",n))(Fe||{});var ve=require("@dfinity/principal"),u=require("@dfinity/utils");var Xe=64,Ye=({owner:e,subaccount:t})=>{if((0,u.isNullish)(t))return e.toText();let c=(o=>o.replace(/^0+/,""))((0,u.uint8ArrayToHexString)(Uint8Array.from(t)));return c.length===0?e.toText():`${e.toText()}-${qe({owner:e,subaccount:t})}.${c}`},qe=({owner:e,subaccount:t})=>{let r=(0,u.bigEndianCrc32)(Uint8Array.from([...e.toUint8Array(),...t]));return(0,u.encodeBase32)(r)},je=e=>{let[t,r]=e.split(".");if(!(0,u.notEmptyString)(t))throw new Error("Invalid account. No string provided.");if((0,u.isNullish)(r))return{owner:ve.Principal.fromText(e)};let[c,...o]=t.split("-").reverse(),n=o.reverse().join("-"),d={owner:ve.Principal.fromText(n),subaccount:(0,u.hexStringToUint8Array)(r.padStart(Xe,"0"))};if(qe(d)!==c)throw new Error("Invalid account. Invalid checksum.");return d},Je=e=>{let t=e.reduce((c,[o,n])=>{switch(o){case"icrc1:symbol":c={...c,..."Text"in n&&{symbol:n.Text}};break;case"icrc1:name":c={...c,..."Text"in n&&{name:n.Text}};break;case"icrc1:fee":c={...c,..."Nat"in n&&{fee:n.Nat}};break;case"icrc1:decimals":c={...c,..."Nat"in n&&{decimals:Number(n.Nat)}};break;case"icrc1:logo":c={...c,..."Text"in n&&{icon:n.Text}}}return c},{});if((c=>(0,u.nonNullish)(c.symbol)&&(0,u.nonNullish)(c.name)&&(0,u.nonNullish)(c.fee)&&(0,u.nonNullish)(c.decimals))(t))return t};var j=require("@dfinity/utils"),Ke=e=>{let t=/^([a-zA-Z]+):([A-Za-z0-9:\-.]+).*?(?:[?&](?:amount|value)=(\d+(?:\.\d+)?))?$/,r=e.match(t);if((0,j.isNullish)(r))return;let[c,o,n,d]=r;return{token:o,identifier:n,...(0,j.nonNullish)(d)&&!isNaN(parseFloat(d))&&{amount:parseFloat(d)}}};0&&(module.exports={ConsentMessageError,ConsentMessageUnavailableError,GenericError,IcrcIndexCanister,IcrcIndexNgCanister,IcrcLedgerCanister,IcrcMetadataResponseEntries,IcrcTransferError,IndexError,InsufficientPaymentError,UnsupportedCanisterCallError,decodeIcrcAccount,decodePayment,encodeIcrcAccount,mapIcrc21ConsentMessageError,mapTokenMetadata,toApproveArgs,toIcrc21ConsentMessageArgs,toTransferArg,toTransferFromArgs});
2
2
  //# sourceMappingURL=index.cjs.js.map