@dfinity/ledger-icrc 2.9.1 → 2.10.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
@@ -185,7 +185,7 @@ The balance of the given account.
185
185
 
186
186
  ### :factory: IcrcLedgerCanister
187
187
 
188
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L41)
188
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L42)
189
189
 
190
190
  #### Static Methods
191
191
 
@@ -197,7 +197,7 @@ The balance of the given account.
197
197
  | -------- | ---------------------------------------------------------------------- |
198
198
  | `create` | `(options: IcrcLedgerCanisterOptions<_SERVICE>) => IcrcLedgerCanister` |
199
199
 
200
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L42)
200
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L43)
201
201
 
202
202
  #### Methods
203
203
 
@@ -212,6 +212,8 @@ The balance of the given account.
212
212
  - [consentMessage](#gear-consentmessage)
213
213
  - [getBlocks](#gear-getblocks)
214
214
  - [getIndexPrincipal](#gear-getindexprincipal)
215
+ - [icrc1SupportedStandards](#gear-icrc1supportedstandards)
216
+ - [icrc10SupportedStandards](#gear-icrc10supportedstandards)
215
217
 
216
218
  ##### :gear: metadata
217
219
 
@@ -221,7 +223,7 @@ The token metadata (name, symbol, etc.).
221
223
  | ---------- | ------------------------------------------------------------- |
222
224
  | `metadata` | `(params: QueryParams) => Promise<IcrcTokenMetadataResponse>` |
223
225
 
224
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L56)
226
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L57)
225
227
 
226
228
  ##### :gear: transactionFee
227
229
 
@@ -235,7 +237,7 @@ Returns:
235
237
 
236
238
  The ledger transaction fees in Tokens
237
239
 
238
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L64)
240
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L65)
239
241
 
240
242
  ##### :gear: balance
241
243
 
@@ -253,7 +255,7 @@ Returns:
253
255
 
254
256
  The balance of the given account.
255
257
 
256
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L73)
258
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L74)
257
259
 
258
260
  ##### :gear: transfer
259
261
 
@@ -267,7 +269,7 @@ Parameters:
267
269
 
268
270
  - `params`: The parameters to transfer tokens.
269
271
 
270
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L86)
272
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L87)
271
273
 
272
274
  ##### :gear: totalTokensSupply
273
275
 
@@ -277,7 +279,7 @@ Returns the total supply of tokens.
277
279
  | ------------------- | ------------------------------------------ |
278
280
  | `totalTokensSupply` | `(params: QueryParams) => Promise<bigint>` |
279
281
 
280
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L102)
282
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L103)
281
283
 
282
284
  ##### :gear: transferFrom
283
285
 
@@ -293,7 +295,7 @@ Parameters:
293
295
 
294
296
  - `params`: The parameters to transfer tokens from to.
295
297
 
296
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L114)
298
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L115)
297
299
 
298
300
  ##### :gear: approve
299
301
 
@@ -309,7 +311,7 @@ Parameters:
309
311
 
310
312
  - `params`: The parameters to approve.
311
313
 
312
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L136)
314
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L137)
313
315
 
314
316
  ##### :gear: allowance
315
317
 
@@ -329,7 +331,7 @@ Returns:
329
331
 
330
332
  The token allowance. If there is no active approval, the ledger MUST return `{ allowance = 0; expires_at = null }`.
331
333
 
332
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L158)
334
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L159)
333
335
 
334
336
  ##### :gear: consentMessage
335
337
 
@@ -347,7 +349,7 @@ Returns:
347
349
 
348
350
  - A promise that resolves to the consent message response, which includes the consent message in the specified language and other related information.
349
351
 
350
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L176)
352
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L177)
351
353
 
352
354
  ##### :gear: getBlocks
353
355
 
@@ -365,7 +367,7 @@ Returns:
365
367
 
366
368
  The list of blocks.
367
369
 
368
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L200)
370
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L201)
369
371
 
370
372
  ##### :gear: getIndexPrincipal
371
373
 
@@ -379,7 +381,35 @@ Returns:
379
381
 
380
382
  The principal of the index canister.
381
383
 
382
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L213)
384
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L214)
385
+
386
+ ##### :gear: icrc1SupportedStandards
387
+
388
+ Returns the list of standards this ledger supports by using icrc1_supported_standards.
389
+
390
+ | Method | Type |
391
+ | ------------------------- | ---------------------------------------------------- |
392
+ | `icrc1SupportedStandards` | `(params: QueryParams) => Promise<StandardRecord[]>` |
393
+
394
+ Returns:
395
+
396
+ The list of standards.
397
+
398
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L233)
399
+
400
+ ##### :gear: icrc10SupportedStandards
401
+
402
+ Returns the list of standards this ledger supports by using icrc10_supported_standards.
403
+
404
+ | Method | Type |
405
+ | -------------------------- | -------------------------------------------------------------------- |
406
+ | `icrc10SupportedStandards` | `(params: QueryParams) => Promise<{ url: string; name: string; }[]>` |
407
+
408
+ Returns:
409
+
410
+ The list of standards.
411
+
412
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L243)
383
413
 
384
414
  ### :factory: IcrcIndexCanister
385
415
 
@@ -1,4 +1,4 @@
1
- // Generated from IC repo commit e915efe (2025-07-02 tags: release-2025-07-03_03-27-base) 'rs/ledger_suite/icrc1/index-ng/index-ng.did' by import-candid
1
+ // Generated from IC repo commit 047925d (2025-08-06 tags: release-2025-08-07_03-33-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 {
@@ -1,4 +1,4 @@
1
- // Generated from IC repo commit e915efe (2025-07-02 tags: release-2025-07-03_03-27-base) 'rs/ledger_suite/icrc1/ledger/ledger.did' by import-candid
1
+ // Generated from IC repo commit 047925d (2025-08-06 tags: release-2025-08-07_03-33-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 Pe=Object.defineProperty;var Ye=Object.getOwnPropertyDescriptor;var je=Object.getOwnPropertyNames;var Je=Object.prototype.hasOwnProperty;var Ke=(e,t)=>{for(var r in t)Pe(e,r,{get:t[r],enumerable:!0})},Ie=(e,t,r,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of je(t))!Je.call(e,o)&&o!==r&&Pe(e,o,{get:()=>t[o],enumerable:!(c=Ye(t,o))||c.enumerable});return e};var Le=e=>Ie(Pe({},"__esModule",{value:!0}),e);var nt={};Ke(nt,{ConsentMessageError:()=>G,ConsentMessageUnavailableError:()=>U,GenericError:()=>C,IcrcIndexCanister:()=>X,IcrcIndexNgCanister:()=>Z,IcrcLedgerCanister:()=>j,IcrcMetadataResponseEntries:()=>Ce,IcrcTransferError:()=>E,IndexError:()=>v,IndexPrincipalNotSetError:()=>z,InsufficientPaymentError:()=>M,UnsupportedCanisterCallError:()=>q,decodeIcrcAccount:()=>rt,decodePayment:()=>at,encodeIcrcAccount:()=>tt,mapIcrc106GetIndexPrincipalError:()=>Be,mapIcrc21ConsentMessageError:()=>Se,mapTokenMetadata:()=>ct,toApproveArgs:()=>Ge,toIcrc21ConsentMessageArgs:()=>we,toTransferArg:()=>ve,toTransferFromArgs:()=>Ee});module.exports=Le(nt);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)}),Ee=({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)}),Ge=({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)}),we=({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 v=class extends Error{};var E=class extends Error{errorType;constructor({msg:t,errorType:r}){super(t),this.errorType=r}},C=class extends Error{constructor(r,c){super();this.message=r;this.error_code=c}},G=class extends Error{},M=class extends G{},q=class extends G{},U=class extends G{},Se=e=>"GenericError"in e?new C(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 G(`Unknown error type ${JSON.stringify(e)}`),z=class extends Error{},Be=e=>"IndexPrincipalNotSet"in e?new z("Index principal is not set for this ledger canister."):new C(e.GenericError.description,e.GenericError.error_code);var Qe=require("@dfinity/utils");var qe=({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 Ue=({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 $=require("@dfinity/utils"),Q=class extends $.Canister{balance=t=>this.caller({certified:t.certified}).icrc1_balance_of({owner:t.owner,subaccount:(0,$.toNullable)(t.subaccount)})};var H=require("@dfinity/utils"),De=({owner:e,subaccount:t})=>({owner:e,subaccount:(0,H.toNullable)(t)}),W=({account:e,max_results:t,start:r})=>({account:De(e),max_results:t,start:(0,H.toNullable)(r)}),ze=({owner:e,start:t})=>({owner:e,start:(0,H.toNullable)(t)});var Z=class e extends Q{static create(t){let{service:r,certifiedService:c,canisterId:o}=(0,Qe.createServices)({options:t,idlFactory:Ue,certifiedIdlFactory:qe});return new e(o,r,c)}getTransactions=async({certified:t,...r})=>{let c=await this.caller({certified:t}).get_account_transactions(W(r));if("Err"in c)throw new v(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(ze(r))};var Y=require("@dfinity/utils");var $e=({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 He=({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 X=class e extends Y.Canister{static create(t){let{service:r,certifiedService:c,canisterId:o}=(0,Y.createServices)({options:t,idlFactory:He,certifiedIdlFactory:$e});return new e(o,r,c)}getTransactions=async t=>{let r=await this.caller({certified:!0}).get_account_transactions(W(t));if("Err"in r)throw new v(r.Err.message);return r.Ok};ledgerId=t=>{let{ledger_id:r}=this.caller(t);return r()}};var w=require("@dfinity/utils");var We=({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),index_principal:e.Opt(e.Principal),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),index_principal:e.Opt(e.Principal),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)}),K=e.Record({to:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:e.Nat}),I=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}),L=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)}),S=e.Record({burn:e.Opt(F),kind:e.Text,mint:e.Opt(K),approve:e.Opt(I),timestamp:s,transfer:e.Opt(L)}),D=e.Record({transactions:e.Vec(S)}),ee=e.Func([y],[D],[]),te=e.Record({first_index:x,log_length:e.Nat,transactions:e.Vec(S),archived_transactions:e.Vec(e.Record({callback:ee,start:x,length:e.Nat}))}),re=e.Record({take:e.Opt(e.Nat),prev_spender:e.Opt(a),from_account:e.Opt(a)}),ce=e.Record({from_account:a,to_spender:a,allowance:e.Nat,expires_at:e.Opt(e.Nat64)}),ae=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),AccessDenied:e.Record({reason:e.Text})}),ne=e.Variant({Ok:e.Vec(ce),Err:ae}),oe=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),IndexPrincipalNotSet:e.Null}),se=e.Variant({Ok:e.Principal,Err:oe}),l=e.Nat,ie=e.Record({url:e.Text,name:e.Text}),pe=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}),le=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})}),de=e.Variant({Ok:i,Err:le}),B=e.Record({utc_offset_minutes:e.Opt(e.Int16),language:e.Text}),_e=e.Record({metadata:B,device_spec:e.Opt(e.Variant({GenericDisplay:e.Null,LineDisplay:e.Record({characters_per_line:e.Nat16,lines_per_page:e.Nat16})}))}),me=e.Record({arg:e.Vec(e.Nat8),method:e.Text,user_preferences:_e}),ue=e.Variant({LineDisplayMessage:e.Record({pages:e.Vec(e.Record({lines:e.Vec(e.Text)}))}),GenericDisplayMessage:e.Text}),ge=e.Record({metadata:B,consent_message:ue}),P=e.Record({description:e.Text}),fe=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),InsufficientPayment:P,UnsupportedCanisterCall:P,ConsentMessageUnavailable:P}),Ne=e.Variant({Ok:ge,Err:fe}),Oe=e.Record({account:a,spender:a}),xe=e.Record({allowance:e.Nat,expires_at:e.Opt(s)}),Te=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}),Re=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})}),ye=e.Variant({Ok:i,Err:Re}),Ve=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}),be=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})}),Ae=e.Variant({Ok:i,Err:be}),he=e.Record({from:e.Opt(e.Principal)}),ke=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 Fe=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],[te],[]),icrc103_get_allowances:e.Func([re],[ne],[]),icrc106_get_index_principal:e.Func([],[se],[]),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(ie)],[]),icrc1_symbol:e.Func([],[e.Text],[]),icrc1_total_supply:e.Func([],[l],[]),icrc1_transfer:e.Func([pe],[de],[]),icrc21_canister_call_consent_message:e.Func([me],[Ne],[]),icrc2_allowance:e.Func([Oe],[xe],[]),icrc2_approve:e.Func([Te],[ye],[]),icrc2_transfer_from:e.Func([Ve],[Ae],[]),icrc3_get_archives:e.Func([he],[ke],[]),icrc3_get_blocks:e.Func([e.Vec(m)],[t],[]),icrc3_get_tip_certificate:e.Func([],[e.Opt(Fe)],[]),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 Ze=({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),index_principal:e.Opt(e.Principal),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),index_principal:e.Opt(e.Principal),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)}),K=e.Record({to:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:e.Nat}),I=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}),L=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)}),S=e.Record({burn:e.Opt(F),kind:e.Text,mint:e.Opt(K),approve:e.Opt(I),timestamp:s,transfer:e.Opt(L)}),D=e.Record({transactions:e.Vec(S)}),ee=e.Func([y],[D],["query"]),te=e.Record({first_index:x,log_length:e.Nat,transactions:e.Vec(S),archived_transactions:e.Vec(e.Record({callback:ee,start:x,length:e.Nat}))}),re=e.Record({take:e.Opt(e.Nat),prev_spender:e.Opt(a),from_account:e.Opt(a)}),ce=e.Record({from_account:a,to_spender:a,allowance:e.Nat,expires_at:e.Opt(e.Nat64)}),ae=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),AccessDenied:e.Record({reason:e.Text})}),ne=e.Variant({Ok:e.Vec(ce),Err:ae}),oe=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),IndexPrincipalNotSet:e.Null}),se=e.Variant({Ok:e.Principal,Err:oe}),l=e.Nat,ie=e.Record({url:e.Text,name:e.Text}),pe=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}),le=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})}),de=e.Variant({Ok:i,Err:le}),B=e.Record({utc_offset_minutes:e.Opt(e.Int16),language:e.Text}),_e=e.Record({metadata:B,device_spec:e.Opt(e.Variant({GenericDisplay:e.Null,LineDisplay:e.Record({characters_per_line:e.Nat16,lines_per_page:e.Nat16})}))}),me=e.Record({arg:e.Vec(e.Nat8),method:e.Text,user_preferences:_e}),ue=e.Variant({LineDisplayMessage:e.Record({pages:e.Vec(e.Record({lines:e.Vec(e.Text)}))}),GenericDisplayMessage:e.Text}),ge=e.Record({metadata:B,consent_message:ue}),P=e.Record({description:e.Text}),fe=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),InsufficientPayment:P,UnsupportedCanisterCall:P,ConsentMessageUnavailable:P}),Ne=e.Variant({Ok:ge,Err:fe}),Oe=e.Record({account:a,spender:a}),xe=e.Record({allowance:e.Nat,expires_at:e.Opt(s)}),Te=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}),Re=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})}),ye=e.Variant({Ok:i,Err:Re}),Ve=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}),be=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})}),Ae=e.Variant({Ok:i,Err:be}),he=e.Record({from:e.Opt(e.Principal)}),ke=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 Fe=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],[te],["query"]),icrc103_get_allowances:e.Func([re],[ne],["query"]),icrc106_get_index_principal:e.Func([],[se],["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(ie)],["query"]),icrc1_symbol:e.Func([],[e.Text],["query"]),icrc1_total_supply:e.Func([],[l],["query"]),icrc1_transfer:e.Func([pe],[de],[]),icrc21_canister_call_consent_message:e.Func([me],[Ne],[]),icrc2_allowance:e.Func([Oe],[xe],["query"]),icrc2_approve:e.Func([Te],[ye],[]),icrc2_transfer_from:e.Func([Ve],[Ae],[]),icrc3_get_archives:e.Func([he],[ke],["query"]),icrc3_get_blocks:e.Func([e.Vec(m)],[t],["query"]),icrc3_get_tip_certificate:e.Func([],[e.Opt(Fe)],["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 j=class e extends w.Canister{static create(t){let{service:r,certifiedService:c,canisterId:o}=(0,w.createServices)({options:t,idlFactory:Ze,certifiedIdlFactory:We});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,w.toNullable)(t.subaccount)});transfer=async t=>{let r=await this.caller({certified:!0}).icrc1_transfer(ve(t));if("Err"in r)throw new E({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(Ee(t));if("Err"in r)throw new E({errorType:r.Err,msg:"Failed to transfer from"});return r.Ok};approve=async t=>{let r=await this.caller({certified:!0}).icrc2_approve(Ge(t));if("Err"in r)throw new E({errorType:r.Err,msg:"Failed to entitle the spender to transfer the amount"});return r.Ok};allowance=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(we(t));if("Err"in c)throw Se(c.Err);return c.Ok};getBlocks=t=>this.caller({certified:t.certified}).icrc3_get_blocks(t.args);getIndexPrincipal=async t=>{let{icrc106_get_index_principal:r}=this.caller(t),c=await r();if("Err"in c)throw Be(c.Err);return c.Ok}};var Ce=(n=>(n.SYMBOL="icrc1:symbol",n.NAME="icrc1:name",n.DECIMALS="icrc1:decimals",n.FEE="icrc1:fee",n.LOGO="icrc1:logo",n))(Ce||{});var Me=require("@dfinity/principal"),u=require("@dfinity/utils");var et=64,tt=({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()}-${Xe({owner:e,subaccount:t})}.${c}`},Xe=({owner:e,subaccount:t})=>{let r=(0,u.bigEndianCrc32)(Uint8Array.from([...e.toUint8Array(),...t]));return(0,u.encodeBase32)(r)},rt=e=>{let[t,r,...c]=e.split(".");if(!(0,u.notEmptyString)(t))throw new Error("Invalid account. No string provided.");if(c.length>0)throw new Error("Invalid account string format. Expected at most one '.' separator.");if((0,u.isNullish)(r))return{owner:Me.Principal.fromText(e)};let[o,...n]=t.split("-").reverse(),d=n.reverse().join("-"),a={owner:Me.Principal.fromText(d),subaccount:(0,u.hexStringToUint8Array)(r.padStart(et,"0"))};if(Xe(a)!==o)throw new Error("Invalid account. Invalid checksum.");return a},ct=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"),at=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,IndexPrincipalNotSetError,InsufficientPaymentError,UnsupportedCanisterCallError,decodeIcrcAccount,decodePayment,encodeIcrcAccount,mapIcrc106GetIndexPrincipalError,mapIcrc21ConsentMessageError,mapTokenMetadata,toApproveArgs,toIcrc21ConsentMessageArgs,toTransferArg,toTransferFromArgs});
1
+ "use strict";var Fe=Object.defineProperty;var Ye=Object.getOwnPropertyDescriptor;var je=Object.getOwnPropertyNames;var Je=Object.prototype.hasOwnProperty;var Ke=(e,t)=>{for(var r in t)Fe(e,r,{get:t[r],enumerable:!0})},Ie=(e,t,r,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of je(t))!Je.call(e,o)&&o!==r&&Fe(e,o,{get:()=>t[o],enumerable:!(c=Ye(t,o))||c.enumerable});return e};var Le=e=>Ie(Fe({},"__esModule",{value:!0}),e);var nt={};Ke(nt,{ConsentMessageError:()=>G,ConsentMessageUnavailableError:()=>U,GenericError:()=>C,IcrcIndexCanister:()=>X,IcrcIndexNgCanister:()=>Z,IcrcLedgerCanister:()=>j,IcrcMetadataResponseEntries:()=>Ce,IcrcTransferError:()=>E,IndexError:()=>v,IndexPrincipalNotSetError:()=>z,InsufficientPaymentError:()=>M,UnsupportedCanisterCallError:()=>q,decodeIcrcAccount:()=>rt,decodePayment:()=>at,encodeIcrcAccount:()=>tt,mapIcrc106GetIndexPrincipalError:()=>Be,mapIcrc21ConsentMessageError:()=>Se,mapTokenMetadata:()=>ct,toApproveArgs:()=>Ge,toIcrc21ConsentMessageArgs:()=>we,toTransferArg:()=>ve,toTransferFromArgs:()=>Ee});module.exports=Le(nt);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)}),Ee=({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)}),Ge=({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)}),we=({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 v=class extends Error{};var E=class extends Error{errorType;constructor({msg:t,errorType:r}){super(t),this.errorType=r}},C=class extends Error{constructor(r,c){super();this.message=r;this.error_code=c}},G=class extends Error{},M=class extends G{},q=class extends G{},U=class extends G{},Se=e=>"GenericError"in e?new C(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 G(`Unknown error type ${JSON.stringify(e)}`),z=class extends Error{},Be=e=>"IndexPrincipalNotSet"in e?new z("Index principal is not set for this ledger canister."):new C(e.GenericError.description,e.GenericError.error_code);var Qe=require("@dfinity/utils");var qe=({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)}),P=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([],[P],[])})};var Ue=({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)}),P=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([],[P],["query"])})};var $=require("@dfinity/utils"),Q=class extends $.Canister{balance=t=>this.caller({certified:t.certified}).icrc1_balance_of({owner:t.owner,subaccount:(0,$.toNullable)(t.subaccount)})};var H=require("@dfinity/utils"),De=({owner:e,subaccount:t})=>({owner:e,subaccount:(0,H.toNullable)(t)}),W=({account:e,max_results:t,start:r})=>({account:De(e),max_results:t,start:(0,H.toNullable)(r)}),ze=({owner:e,start:t})=>({owner:e,start:(0,H.toNullable)(t)});var Z=class e extends Q{static create(t){let{service:r,certifiedService:c,canisterId:o}=(0,Qe.createServices)({options:t,idlFactory:Ue,certifiedIdlFactory:qe});return new e(o,r,c)}getTransactions=async({certified:t,...r})=>{let c=await this.caller({certified:t}).get_account_transactions(W(r));if("Err"in c)throw new v(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(ze(r))};var Y=require("@dfinity/utils");var $e=({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 He=({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 X=class e extends Y.Canister{static create(t){let{service:r,certifiedService:c,canisterId:o}=(0,Y.createServices)({options:t,idlFactory:He,certifiedIdlFactory:$e});return new e(o,r,c)}getTransactions=async t=>{let r=await this.caller({certified:!0}).get_account_transactions(W(t));if("Err"in r)throw new v(r.Err.message);return r.Ok};ledgerId=t=>{let{ledger_id:r}=this.caller(t);return r()}};var w=require("@dfinity/utils");var We=({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),index_principal:e.Opt(e.Principal),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),index_principal:e.Opt(e.Principal),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,P=e.Record({from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:e.Nat,spender:e.Opt(a)}),K=e.Record({to:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:e.Nat}),I=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}),L=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)}),S=e.Record({burn:e.Opt(P),kind:e.Text,mint:e.Opt(K),approve:e.Opt(I),timestamp:s,transfer:e.Opt(L)}),D=e.Record({transactions:e.Vec(S)}),ee=e.Func([y],[D],[]),te=e.Record({first_index:x,log_length:e.Nat,transactions:e.Vec(S),archived_transactions:e.Vec(e.Record({callback:ee,start:x,length:e.Nat}))}),re=e.Record({take:e.Opt(e.Nat),prev_spender:e.Opt(a),from_account:e.Opt(a)}),ce=e.Record({from_account:a,to_spender:a,allowance:e.Nat,expires_at:e.Opt(e.Nat64)}),ae=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),AccessDenied:e.Record({reason:e.Text})}),ne=e.Variant({Ok:e.Vec(ce),Err:ae}),oe=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),IndexPrincipalNotSet:e.Null}),se=e.Variant({Ok:e.Principal,Err:oe}),l=e.Nat,ie=e.Record({url:e.Text,name:e.Text}),pe=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}),le=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})}),de=e.Variant({Ok:i,Err:le}),B=e.Record({utc_offset_minutes:e.Opt(e.Int16),language:e.Text}),_e=e.Record({metadata:B,device_spec:e.Opt(e.Variant({GenericDisplay:e.Null,LineDisplay:e.Record({characters_per_line:e.Nat16,lines_per_page:e.Nat16})}))}),me=e.Record({arg:e.Vec(e.Nat8),method:e.Text,user_preferences:_e}),ue=e.Variant({LineDisplayMessage:e.Record({pages:e.Vec(e.Record({lines:e.Vec(e.Text)}))}),GenericDisplayMessage:e.Text}),ge=e.Record({metadata:B,consent_message:ue}),F=e.Record({description:e.Text}),fe=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),InsufficientPayment:F,UnsupportedCanisterCall:F,ConsentMessageUnavailable:F}),Ne=e.Variant({Ok:ge,Err:fe}),Oe=e.Record({account:a,spender:a}),xe=e.Record({allowance:e.Nat,expires_at:e.Opt(s)}),Te=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}),Re=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})}),ye=e.Variant({Ok:i,Err:Re}),Ve=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}),be=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})}),Ae=e.Variant({Ok:i,Err:be}),he=e.Record({from:e.Opt(e.Principal)}),ke=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 Pe=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],[te],[]),icrc103_get_allowances:e.Func([re],[ne],[]),icrc106_get_index_principal:e.Func([],[se],[]),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(ie)],[]),icrc1_symbol:e.Func([],[e.Text],[]),icrc1_total_supply:e.Func([],[l],[]),icrc1_transfer:e.Func([pe],[de],[]),icrc21_canister_call_consent_message:e.Func([me],[Ne],[]),icrc2_allowance:e.Func([Oe],[xe],[]),icrc2_approve:e.Func([Te],[ye],[]),icrc2_transfer_from:e.Func([Ve],[Ae],[]),icrc3_get_archives:e.Func([he],[ke],[]),icrc3_get_blocks:e.Func([e.Vec(m)],[t],[]),icrc3_get_tip_certificate:e.Func([],[e.Opt(Pe)],[]),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 Ze=({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),index_principal:e.Opt(e.Principal),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),index_principal:e.Opt(e.Principal),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,P=e.Record({from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:e.Nat,spender:e.Opt(a)}),K=e.Record({to:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:e.Nat}),I=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}),L=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)}),S=e.Record({burn:e.Opt(P),kind:e.Text,mint:e.Opt(K),approve:e.Opt(I),timestamp:s,transfer:e.Opt(L)}),D=e.Record({transactions:e.Vec(S)}),ee=e.Func([y],[D],["query"]),te=e.Record({first_index:x,log_length:e.Nat,transactions:e.Vec(S),archived_transactions:e.Vec(e.Record({callback:ee,start:x,length:e.Nat}))}),re=e.Record({take:e.Opt(e.Nat),prev_spender:e.Opt(a),from_account:e.Opt(a)}),ce=e.Record({from_account:a,to_spender:a,allowance:e.Nat,expires_at:e.Opt(e.Nat64)}),ae=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),AccessDenied:e.Record({reason:e.Text})}),ne=e.Variant({Ok:e.Vec(ce),Err:ae}),oe=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),IndexPrincipalNotSet:e.Null}),se=e.Variant({Ok:e.Principal,Err:oe}),l=e.Nat,ie=e.Record({url:e.Text,name:e.Text}),pe=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}),le=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})}),de=e.Variant({Ok:i,Err:le}),B=e.Record({utc_offset_minutes:e.Opt(e.Int16),language:e.Text}),_e=e.Record({metadata:B,device_spec:e.Opt(e.Variant({GenericDisplay:e.Null,LineDisplay:e.Record({characters_per_line:e.Nat16,lines_per_page:e.Nat16})}))}),me=e.Record({arg:e.Vec(e.Nat8),method:e.Text,user_preferences:_e}),ue=e.Variant({LineDisplayMessage:e.Record({pages:e.Vec(e.Record({lines:e.Vec(e.Text)}))}),GenericDisplayMessage:e.Text}),ge=e.Record({metadata:B,consent_message:ue}),F=e.Record({description:e.Text}),fe=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),InsufficientPayment:F,UnsupportedCanisterCall:F,ConsentMessageUnavailable:F}),Ne=e.Variant({Ok:ge,Err:fe}),Oe=e.Record({account:a,spender:a}),xe=e.Record({allowance:e.Nat,expires_at:e.Opt(s)}),Te=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}),Re=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})}),ye=e.Variant({Ok:i,Err:Re}),Ve=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}),be=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})}),Ae=e.Variant({Ok:i,Err:be}),he=e.Record({from:e.Opt(e.Principal)}),ke=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 Pe=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],[te],["query"]),icrc103_get_allowances:e.Func([re],[ne],["query"]),icrc106_get_index_principal:e.Func([],[se],["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(ie)],["query"]),icrc1_symbol:e.Func([],[e.Text],["query"]),icrc1_total_supply:e.Func([],[l],["query"]),icrc1_transfer:e.Func([pe],[de],[]),icrc21_canister_call_consent_message:e.Func([me],[Ne],[]),icrc2_allowance:e.Func([Oe],[xe],["query"]),icrc2_approve:e.Func([Te],[ye],[]),icrc2_transfer_from:e.Func([Ve],[Ae],[]),icrc3_get_archives:e.Func([he],[ke],["query"]),icrc3_get_blocks:e.Func([e.Vec(m)],[t],["query"]),icrc3_get_tip_certificate:e.Func([],[e.Opt(Pe)],["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 j=class e extends w.Canister{static create(t){let{service:r,certifiedService:c,canisterId:o}=(0,w.createServices)({options:t,idlFactory:Ze,certifiedIdlFactory:We});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,w.toNullable)(t.subaccount)});transfer=async t=>{let r=await this.caller({certified:!0}).icrc1_transfer(ve(t));if("Err"in r)throw new E({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(Ee(t));if("Err"in r)throw new E({errorType:r.Err,msg:"Failed to transfer from"});return r.Ok};approve=async t=>{let r=await this.caller({certified:!0}).icrc2_approve(Ge(t));if("Err"in r)throw new E({errorType:r.Err,msg:"Failed to entitle the spender to transfer the amount"});return r.Ok};allowance=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(we(t));if("Err"in c)throw Se(c.Err);return c.Ok};getBlocks=t=>this.caller({certified:t.certified}).icrc3_get_blocks(t.args);getIndexPrincipal=async t=>{let{icrc106_get_index_principal:r}=this.caller(t),c=await r();if("Err"in c)throw Be(c.Err);return c.Ok};icrc1SupportedStandards=t=>this.caller(t).icrc1_supported_standards();icrc10SupportedStandards=t=>this.caller(t).icrc10_supported_standards()};var Ce=(n=>(n.SYMBOL="icrc1:symbol",n.NAME="icrc1:name",n.DECIMALS="icrc1:decimals",n.FEE="icrc1:fee",n.LOGO="icrc1:logo",n))(Ce||{});var Me=require("@dfinity/principal"),u=require("@dfinity/utils");var et=64,tt=({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()}-${Xe({owner:e,subaccount:t})}.${c}`},Xe=({owner:e,subaccount:t})=>{let r=(0,u.bigEndianCrc32)(Uint8Array.from([...e.toUint8Array(),...t]));return(0,u.encodeBase32)(r)},rt=e=>{let[t,r,...c]=e.split(".");if(!(0,u.notEmptyString)(t))throw new Error("Invalid account. No string provided.");if(c.length>0)throw new Error("Invalid account string format. Expected at most one '.' separator.");if((0,u.isNullish)(r))return{owner:Me.Principal.fromText(e)};let[o,...n]=t.split("-").reverse(),d=n.reverse().join("-"),a={owner:Me.Principal.fromText(d),subaccount:(0,u.hexStringToUint8Array)(r.padStart(et,"0"))};if(Xe(a)!==o)throw new Error("Invalid account. Invalid checksum.");return a},ct=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"),at=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,IndexPrincipalNotSetError,InsufficientPaymentError,UnsupportedCanisterCallError,decodeIcrcAccount,decodePayment,encodeIcrcAccount,mapIcrc106GetIndexPrincipalError,mapIcrc21ConsentMessageError,mapTokenMetadata,toApproveArgs,toIcrc21ConsentMessageArgs,toTransferArg,toTransferFromArgs});
2
2
  //# sourceMappingURL=index.cjs.js.map