@dfinity/ledger-icrc 2.4.0 → 2.5.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.
package/README.md CHANGED
@@ -275,12 +275,13 @@ Parameters:
275
275
 
276
276
  ### :factory: IcrcIndexCanister
277
277
 
278
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index.canister.ts#L13)
278
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index.canister.ts#L14)
279
279
 
280
280
  #### Methods
281
281
 
282
282
  - [create](#gear-create)
283
283
  - [getTransactions](#gear-gettransactions)
284
+ - [ledgerId](#gear-ledgerid)
284
285
 
285
286
  ##### :gear: create
286
287
 
@@ -288,7 +289,7 @@ Parameters:
288
289
  | -------- | --------------------------------------------------------------------- |
289
290
  | `create` | `(options: IcrcLedgerCanisterOptions<_SERVICE>) => IcrcIndexCanister` |
290
291
 
291
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index.canister.ts#L14)
292
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index.canister.ts#L15)
292
293
 
293
294
  ##### :gear: getTransactions
294
295
 
@@ -303,7 +304,17 @@ Index Canister only holds the transactions ids in state, not the whole transacti
303
304
  | ----------------- | -------------------------------------------------------------------- |
304
305
  | `getTransactions` | `(params: GetAccountTransactionsParams) => Promise<GetTransactions>` |
305
306
 
306
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index.canister.ts#L33)
307
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index.canister.ts#L34)
308
+
309
+ ##### :gear: ledgerId
310
+
311
+ Returns the ledger canister ID related to the index canister.
312
+
313
+ | Method | Type |
314
+ | ---------- | --------------------------------------------- |
315
+ | `ledgerId` | `(params: QueryParams) => Promise<Principal>` |
316
+
317
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/index.canister.ts#L51)
307
318
 
308
319
  ### :factory: IcrcIndexNgCanister
309
320
 
@@ -1,4 +1,4 @@
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
1
+ // Generated from IC repo commit 3d6a76e (2024-08-14 tags: release-2024-08-21_15-36-canister-snapshots) '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 a3831c8 (2024-07-11 tags: release-2024-07-10_23-01-base) 'rs/rosetta-api/icrc1/index/index.did' by import-candid
1
+ // Generated from IC repo commit 3d6a76e (2024-08-14 tags: release-2024-08-21_15-36-canister-snapshots) '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 };
@@ -34,7 +34,6 @@ export const idlFactory = ({ IDL }) => {
34
34
  'token_symbol' : IDL.Opt(IDL.Text),
35
35
  'transfer_fee' : IDL.Opt(IDL.Nat),
36
36
  'metadata' : IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue))),
37
- 'maximum_number_of_accounts' : IDL.Opt(IDL.Nat64),
38
37
  'accounts_overflow_trim_quantity' : IDL.Opt(IDL.Nat64),
39
38
  'change_fee_collector' : IDL.Opt(ChangeFeeCollector),
40
39
  'max_memo_length' : IDL.Opt(IDL.Nat16),
@@ -440,7 +439,6 @@ export const init = ({ IDL }) => {
440
439
  'token_symbol' : IDL.Opt(IDL.Text),
441
440
  'transfer_fee' : IDL.Opt(IDL.Nat),
442
441
  'metadata' : IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue))),
443
- 'maximum_number_of_accounts' : IDL.Opt(IDL.Nat64),
444
442
  'accounts_overflow_trim_quantity' : IDL.Opt(IDL.Nat64),
445
443
  'change_fee_collector' : IDL.Opt(ChangeFeeCollector),
446
444
  'max_memo_length' : IDL.Opt(IDL.Nat16),
@@ -269,7 +269,6 @@ export interface UpgradeArgs {
269
269
  token_symbol: [] | [string];
270
270
  transfer_fee: [] | [bigint];
271
271
  metadata: [] | [Array<[string, MetadataValue]>];
272
- maximum_number_of_accounts: [] | [bigint];
273
272
  accounts_overflow_trim_quantity: [] | [bigint];
274
273
  change_fee_collector: [] | [ChangeFeeCollector];
275
274
  max_memo_length: [] | [number];
@@ -1,4 +1,4 @@
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
1
+ // Generated from IC repo commit 3d6a76e (2024-08-14 tags: release-2024-08-21_15-36-canister-snapshots) '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.
@@ -145,7 +145,6 @@ type UpgradeArgs = record {
145
145
  change_fee_collector : opt ChangeFeeCollector;
146
146
  max_memo_length : opt nat16;
147
147
  feature_flags : opt FeatureFlags;
148
- maximum_number_of_accounts: opt nat64;
149
148
  accounts_overflow_trim_quantity: opt nat64;
150
149
  change_archive_options : opt ChangeArchiveOptions;
151
150
  };
@@ -34,7 +34,6 @@ export const idlFactory = ({ IDL }) => {
34
34
  'token_symbol' : IDL.Opt(IDL.Text),
35
35
  'transfer_fee' : IDL.Opt(IDL.Nat),
36
36
  'metadata' : IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue))),
37
- 'maximum_number_of_accounts' : IDL.Opt(IDL.Nat64),
38
37
  'accounts_overflow_trim_quantity' : IDL.Opt(IDL.Nat64),
39
38
  'change_fee_collector' : IDL.Opt(ChangeFeeCollector),
40
39
  'max_memo_length' : IDL.Opt(IDL.Nat16),
@@ -452,7 +451,6 @@ export const init = ({ IDL }) => {
452
451
  'token_symbol' : IDL.Opt(IDL.Text),
453
452
  'transfer_fee' : IDL.Opt(IDL.Nat),
454
453
  'metadata' : IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue))),
455
- 'maximum_number_of_accounts' : IDL.Opt(IDL.Nat64),
456
454
  'accounts_overflow_trim_quantity' : IDL.Opt(IDL.Nat64),
457
455
  'change_fee_collector' : IDL.Opt(ChangeFeeCollector),
458
456
  'max_memo_length' : IDL.Opt(IDL.Nat16),
@@ -1,2 +1,2 @@
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});
1
+ "use strict";var ge=Object.defineProperty;var we=Object.getOwnPropertyDescriptor;var Be=Object.getOwnPropertyNames;var Se=Object.prototype.hasOwnProperty;var Ee=(e,a)=>{for(var t in a)ge(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&&ge(e,n,{get:()=>a[n],enumerable:!(r=we(a,n))||r.enumerable});return e};var Ce=e=>Ge(ge({},"__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)}),g=e.Record({max_results:e.Nat,start:e.Opt(o),account:c}),d=e.Nat,f=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(f),kind:e.Text,mint:e.Opt(O),approve:e.Opt(T),timestamp:e.Nat64,transfer:e.Opt(i)}),_=e.Record({id:o,transaction:u}),V=e.Record({balance:d,transactions:e.Vec(_),oldest_tx_id:e.Opt(o)}),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 v=a,x=e.Record({blocks:e.Vec(v),chain_length:e.Nat64}),y=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([g],[b],[]),get_blocks:e.Func([A],[x],[]),get_fee_collectors_ranges:e.Func([],[y],[]),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)}),g=e.Record({max_results:e.Nat,start:e.Opt(o),account:c}),d=e.Nat,f=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(f),kind:e.Text,mint:e.Opt(O),approve:e.Opt(T),timestamp:e.Nat64,transfer:e.Opt(i)}),_=e.Record({id:o,transaction:u}),V=e.Record({balance:d,transactions:e.Vec(_),oldest_tx_id:e.Opt(o)}),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 v=a,x=e.Record({blocks:e.Vec(v),chain_length:e.Nat64}),y=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([g],[b],["query"]),get_blocks:e.Func([A],[x],["query"]),get_fee_collectors_ranges:e.Func([],[y],["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 fe=require("@dfinity/utils"),qe=({owner:e,subaccount:a})=>({owner:e,subaccount:(0,fe.toNullable)(a)}),q=({account:e,max_results:a,start:t})=>({account:qe(e),max_results:a,start:(0,fe.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 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}),g=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(g)}),f=e.Record({id:t,transaction:d}),O=e.Record({transactions:e.Vec(f),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 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}),g=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(g)}),f=e.Record({id:t,transaction:d}),O=e.Record({transactions:e.Vec(f),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};this.ledgerId=t=>{let{ledger_id:r}=this.caller(t);return r()}}static create(t){let{service:r,certifiedService:n,canisterId:o}=(0,z.createServices)({options:t,idlFactory:Ve,certifiedIdlFactory:ye});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)}),g=e.Variant({SetTo:c,Unset:e.Null}),d=e.Record({icrc2:e.Bool}),f=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))),accounts_overflow_trim_quantity:e.Opt(e.Nat64),change_fee_collector:e.Opt(g),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(f),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}),V=e.Vec(e.Tuple(e.Text,r));r.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(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,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)}),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([y],[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([y],[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)}),g=e.Variant({SetTo:c,Unset:e.Null}),d=e.Record({icrc2:e.Bool}),f=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))),accounts_overflow_trim_quantity:e.Opt(e.Nat64),change_fee_collector:e.Opt(g),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(f),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}),V=e.Vec(e.Tuple(e.Text,r));r.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(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,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)}),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([y],[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([y],[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