@dfinity/ledger-icrc 4.0.4 → 4.1.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#L42)
188
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L44)
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#L43)
200
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L45)
201
201
 
202
202
  #### Methods
203
203
 
@@ -214,6 +214,7 @@ The balance of the given account.
214
214
  - [getIndexPrincipal](#gear-getindexprincipal)
215
215
  - [icrc1SupportedStandards](#gear-icrc1supportedstandards)
216
216
  - [icrc10SupportedStandards](#gear-icrc10supportedstandards)
217
+ - [getMintingAccount](#gear-getmintingaccount)
217
218
 
218
219
  ##### :gear: metadata
219
220
 
@@ -223,7 +224,7 @@ The token metadata (name, symbol, etc.).
223
224
  | ---------- | ------------------------------------------------------------- |
224
225
  | `metadata` | `(params: QueryParams) => Promise<IcrcTokenMetadataResponse>` |
225
226
 
226
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L57)
227
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L59)
227
228
 
228
229
  ##### :gear: transactionFee
229
230
 
@@ -237,7 +238,7 @@ Returns:
237
238
 
238
239
  The ledger transaction fees in Tokens
239
240
 
240
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L65)
241
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L67)
241
242
 
242
243
  ##### :gear: balance
243
244
 
@@ -255,7 +256,7 @@ Returns:
255
256
 
256
257
  The balance of the given account.
257
258
 
258
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L74)
259
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L76)
259
260
 
260
261
  ##### :gear: transfer
261
262
 
@@ -269,7 +270,7 @@ Parameters:
269
270
 
270
271
  - `params`: The parameters to transfer tokens.
271
272
 
272
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L87)
273
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L89)
273
274
 
274
275
  ##### :gear: totalTokensSupply
275
276
 
@@ -279,7 +280,7 @@ Returns the total supply of tokens.
279
280
  | ------------------- | ------------------------------------------ |
280
281
  | `totalTokensSupply` | `(params: QueryParams) => Promise<bigint>` |
281
282
 
282
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L103)
283
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L105)
283
284
 
284
285
  ##### :gear: transferFrom
285
286
 
@@ -295,7 +296,7 @@ Parameters:
295
296
 
296
297
  - `params`: The parameters to transfer tokens from to.
297
298
 
298
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L115)
299
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L117)
299
300
 
300
301
  ##### :gear: approve
301
302
 
@@ -311,7 +312,7 @@ Parameters:
311
312
 
312
313
  - `params`: The parameters to approve.
313
314
 
314
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L137)
315
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L139)
315
316
 
316
317
  ##### :gear: allowance
317
318
 
@@ -331,7 +332,7 @@ Returns:
331
332
 
332
333
  The token allowance. If there is no active approval, the ledger MUST return `{ allowance = 0; expires_at = null }`.
333
334
 
334
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L159)
335
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L161)
335
336
 
336
337
  ##### :gear: consentMessage
337
338
 
@@ -349,7 +350,7 @@ Returns:
349
350
 
350
351
  - A promise that resolves to the consent message response, which includes the consent message in the specified language and other related information.
351
352
 
352
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L177)
353
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L179)
353
354
 
354
355
  ##### :gear: getBlocks
355
356
 
@@ -367,7 +368,7 @@ Returns:
367
368
 
368
369
  The list of blocks.
369
370
 
370
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L201)
371
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L203)
371
372
 
372
373
  ##### :gear: getIndexPrincipal
373
374
 
@@ -381,7 +382,7 @@ Returns:
381
382
 
382
383
  The principal of the index canister.
383
384
 
384
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L214)
385
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L216)
385
386
 
386
387
  ##### :gear: icrc1SupportedStandards
387
388
 
@@ -395,7 +396,7 @@ Returns:
395
396
 
396
397
  The list of standards.
397
398
 
398
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L233)
399
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L235)
399
400
 
400
401
  ##### :gear: icrc10SupportedStandards
401
402
 
@@ -409,7 +410,21 @@ Returns:
409
410
 
410
411
  The list of standards.
411
412
 
412
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L243)
413
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L245)
414
+
415
+ ##### :gear: getMintingAccount
416
+
417
+ Returns the minting account of the Ledger canister.
418
+
419
+ | Method | Type |
420
+ | ------------------- | ----------------------------------------------------- |
421
+ | `getMintingAccount` | `(params: QueryParams) => Promise<Nullable<Account>>` |
422
+
423
+ Returns:
424
+
425
+ The minting account as a Nullable object.
426
+
427
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icrc/src/ledger.canister.ts#L257)
413
428
 
414
429
  ### :factory: IcrcIndexCanister
415
430
 
@@ -1,2 +1,2 @@
1
- "use strict";var Ge=Object.defineProperty;var Je=Object.getOwnPropertyDescriptor;var Ke=Object.getOwnPropertyNames;var Ie=Object.prototype.hasOwnProperty;var Le=(e,t)=>{for(var c in t)Ge(e,c,{get:t[c],enumerable:!0})},De=(e,t,c,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ke(t))!Ie.call(e,o)&&o!==c&&Ge(e,o,{get:()=>t[o],enumerable:!(r=Je(t,o))||r.enumerable});return e};var et=e=>De(Ge({},"__esModule",{value:!0}),e);var st={};Le(st,{ConsentMessageError:()=>S,ConsentMessageUnavailableError:()=>U,GenericError:()=>C,IcrcIndexCanister:()=>X,IcrcIndexNgCanister:()=>Z,IcrcLedgerCanister:()=>j,IcrcMetadataResponseEntries:()=>qe,IcrcTransferError:()=>G,IndexError:()=>v,IndexPrincipalNotSetError:()=>z,InsufficientPaymentError:()=>M,UnsupportedCanisterCallError:()=>q,decodeIcrcAccount:()=>at,decodePayment:()=>ot,encodeIcrcAccount:()=>ct,mapIcrc106GetIndexPrincipalError:()=>Me,mapIcrc21ConsentMessageError:()=>Ce,mapTokenMetadata:()=>nt,toApproveArgs:()=>we,toIcrc21ConsentMessageArgs:()=>Be,toTransferArg:()=>Se,toTransferFromArgs:()=>Ee});module.exports=et(st);var _=require("@dfinity/utils"),Se=({from_subaccount:e,fee:t,created_at_time:c,memo:r,...o})=>({...o,fee:(0,_.toNullable)(t),memo:(0,_.toNullable)(r),from_subaccount:(0,_.toNullable)(e),created_at_time:(0,_.toNullable)(c)}),Ee=({spender_subaccount:e,fee:t,created_at_time:c,memo:r,...o})=>({...o,fee:(0,_.toNullable)(t),memo:(0,_.toNullable)(r),spender_subaccount:(0,_.toNullable)(e),created_at_time:(0,_.toNullable)(c)}),we=({fee:e,created_at_time:t,memo:c,from_subaccount:r,expected_allowance:o,expires_at:n,...d})=>({...d,fee:(0,_.toNullable)(e),memo:(0,_.toNullable)(c),from_subaccount:(0,_.toNullable)(r),created_at_time:(0,_.toNullable)(t),expected_allowance:(0,_.toNullable)(o),expires_at:(0,_.toNullable)(n)}),Be=({userPreferences:{metadata:{utcOffsetMinutes:e,language:t},deriveSpec:c},...r})=>({...r,user_preferences:{metadata:{language:t,utc_offset_minutes:(0,_.toNullable)(e)},device_spec:(0,_.isNullish)(c)?(0,_.toNullable)():(0,_.toNullable)("GenericDisplay"in c?{GenericDisplay:null}:{FieldsDisplay:null})}});var v=class extends Error{};var G=class extends Error{errorType;constructor({msg:t,errorType:c}){super(t),this.errorType=c}},C=class extends Error{constructor(c,r){super();this.message=c;this.error_code=r}},S=class extends Error{},M=class extends S{},q=class extends S{},U=class extends S{},Ce=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 S(`Unknown error type ${JSON.stringify(e)}`),z=class extends Error{},Me=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 He=require("@dfinity/utils");var ze=({IDL:e})=>{let t=e.Rec(),c=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)}),o=e.Variant({Upgrade:c,Init:r}),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}),k=e.Vec(e.Tuple(e.Text,t));t.fill(e.Variant({Int:e.Int,Map:k,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(t)}));let h=t,x=e.Record({blocks:e.Vec(h),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],["query"])})};var Qe=({IDL:e})=>{let t=e.Rec(),c=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)}),o=e.Variant({Upgrade:c,Init:r}),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}),k=e.Vec(e.Tuple(e.Text,t));t.fill(e.Variant({Int:e.Int,Map:k,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(t)}));let h=t,x=e.Record({blocks:e.Vec(h),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"),tt=({owner:e,subaccount:t})=>({owner:e,subaccount:(0,H.toNullable)(t)}),W=({account:e,max_results:t,start:c})=>({account:tt(e),max_results:t,start:(0,H.toNullable)(c)}),$e=({owner:e,start:t})=>({owner:e,start:(0,H.toNullable)(t)});var Z=class e extends Q{static create(t){let{service:c,certifiedService:r,canisterId:o}=(0,He.createServices)({options:t,idlFactory:Qe,certifiedIdlFactory:ze});return new e(o,c,r)}getTransactions=async({certified:t,...c})=>{let r=await this.caller({certified:t}).get_account_transactions(W(c));if("Err"in r)throw new v(r.Err.message);return r.Ok};ledgerId=t=>{let{ledger_id:c}=this.caller(t);return c()};status=t=>this.caller(t).status();listSubaccounts=({certified:t,...c})=>this.caller({certified:t}).list_subaccounts($e(c))};var Y=require("@dfinity/utils");var We=({IDL:e})=>{let t=e.Record({ledger_id:e.Principal}),c=e.Nat,r=e.Record({owner:e.Principal,subaccount:e.Opt(e.Vec(e.Nat8))}),o=e.Record({max_results:e.Nat,start:e.Opt(c),account:r}),n=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)}),d=e.Record({to:r,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: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)}),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:c,transaction:p}),O=e.Record({transactions:e.Vec(N),oldest_tx_id:e.Opt(c)}),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 Ze=({IDL:e})=>{let t=e.Record({ledger_id:e.Principal}),c=e.Nat,r=e.Record({owner:e.Principal,subaccount:e.Opt(e.Vec(e.Nat8))}),o=e.Record({max_results:e.Nat,start:e.Opt(c),account:r}),n=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)}),d=e.Record({to:r,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: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)}),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:c,transaction:p}),O=e.Record({transactions:e.Vec(N),oldest_tx_id:e.Opt(c)}),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:c,certifiedService:r,canisterId:o}=(0,Y.createServices)({options:t,idlFactory:Ze,certifiedIdlFactory:We});return new e(o,c,r)}getTransactions=async t=>{let c=await this.caller({certified:!0}).get_account_transactions(W(t));if("Err"in c)throw new v(c.Err.message);return c.Ok};ledgerId=t=>{let{ledger_id:c}=this.caller(t);return c()}};var E=require("@dfinity/utils");var Xe=({IDL:e})=>{let t=e.Rec(),c=e.Rec(),r=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,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([m],[b],[]),k=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}))}),h=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)}),w=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(w)}),ee=e.Func([y],[D],[]),te=e.Record({first_index:x,log_length:e.Nat,transactions:e.Vec(w),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,FieldsDisplay:e.Null}))}),me=e.Record({arg:e.Vec(e.Nat8),method:e.Text,user_preferences:_e}),ue=e.Variant({Text:e.Record({content:e.Text}),TokenAmount:e.Record({decimals:e.Nat8,amount:e.Nat64,symbol:e.Text}),TimestampSeconds:e.Record({amount:e.Nat64}),DurationSeconds:e.Record({amount:e.Nat64})}),ge=e.Record({fields:e.Vec(e.Tuple(e.Text,ue)),intent:e.Text}),fe=e.Variant({FieldsDisplayMessage:ge,GenericDisplayMessage:e.Text}),Ne=e.Record({metadata:B,consent_message:fe}),P=e.Record({description:e.Text}),Oe=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),InsufficientPayment:P,UnsupportedCanisterCall:P,ConsentMessageUnavailable:P}),xe=e.Variant({Ok:Ne,Err:Oe}),Te=e.Record({account:a,spender:a}),Re=e.Record({allowance:e.Nat,expires_at:e.Opt(s)}),ye=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}),Ve=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})}),be=e.Variant({Ok:i,Err:Ve}),Ae=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}),ke=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})}),he=e.Variant({Ok:i,Err:ke}),Fe=e.Record({from:e.Opt(e.Principal)}),Pe=e.Vec(e.Record({end:e.Nat,canister_id:e.Principal,start:e.Nat}));c.fill(e.Variant({Int:e.Int,Map:e.Vec(e.Tuple(e.Text,c)),Nat:e.Nat,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(c)})),t.fill(e.Record({log_length:e.Nat,blocks:e.Vec(e.Record({id:e.Nat,block:c})),archived_blocks:e.Vec(e.Record({args:e.Vec(m),callback:e.Func([e.Vec(m)],[t],["query"])}))}));let ve=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],[k],[]),get_data_certificate:e.Func([],[h],[]),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],[xe],[]),icrc2_allowance:e.Func([Te],[Re],[]),icrc2_approve:e.Func([ye],[be],[]),icrc2_transfer_from:e.Func([Ae],[he],[]),icrc3_get_archives:e.Func([Fe],[Pe],[]),icrc3_get_blocks:e.Func([e.Vec(m)],[t],[]),icrc3_get_tip_certificate:e.Func([],[e.Opt(ve)],[]),icrc3_supported_block_types:e.Func([],[e.Vec(e.Record({url:e.Text,block_type:e.Text}))],[]),is_ledger_ready:e.Func([],[e.Bool],["query"])})};var Ye=({IDL:e})=>{let t=e.Rec(),c=e.Rec(),r=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,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([m],[b],["query"]),k=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}))}),h=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)}),w=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(w)}),ee=e.Func([y],[D],["query"]),te=e.Record({first_index:x,log_length:e.Nat,transactions:e.Vec(w),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,FieldsDisplay:e.Null}))}),me=e.Record({arg:e.Vec(e.Nat8),method:e.Text,user_preferences:_e}),ue=e.Variant({Text:e.Record({content:e.Text}),TokenAmount:e.Record({decimals:e.Nat8,amount:e.Nat64,symbol:e.Text}),TimestampSeconds:e.Record({amount:e.Nat64}),DurationSeconds:e.Record({amount:e.Nat64})}),ge=e.Record({fields:e.Vec(e.Tuple(e.Text,ue)),intent:e.Text}),fe=e.Variant({FieldsDisplayMessage:ge,GenericDisplayMessage:e.Text}),Ne=e.Record({metadata:B,consent_message:fe}),P=e.Record({description:e.Text}),Oe=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),InsufficientPayment:P,UnsupportedCanisterCall:P,ConsentMessageUnavailable:P}),xe=e.Variant({Ok:Ne,Err:Oe}),Te=e.Record({account:a,spender:a}),Re=e.Record({allowance:e.Nat,expires_at:e.Opt(s)}),ye=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}),Ve=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})}),be=e.Variant({Ok:i,Err:Ve}),Ae=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}),ke=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})}),he=e.Variant({Ok:i,Err:ke}),Fe=e.Record({from:e.Opt(e.Principal)}),Pe=e.Vec(e.Record({end:e.Nat,canister_id:e.Principal,start:e.Nat}));c.fill(e.Variant({Int:e.Int,Map:e.Vec(e.Tuple(e.Text,c)),Nat:e.Nat,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(c)})),t.fill(e.Record({log_length:e.Nat,blocks:e.Vec(e.Record({id:e.Nat,block:c})),archived_blocks:e.Vec(e.Record({args:e.Vec(m),callback:e.Func([e.Vec(m)],[t],["query"])}))}));let ve=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],[k],["query"]),get_data_certificate:e.Func([],[h],["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],[xe],[]),icrc2_allowance:e.Func([Te],[Re],["query"]),icrc2_approve:e.Func([ye],[be],[]),icrc2_transfer_from:e.Func([Ae],[he],[]),icrc3_get_archives:e.Func([Fe],[Pe],["query"]),icrc3_get_blocks:e.Func([e.Vec(m)],[t],["query"]),icrc3_get_tip_certificate:e.Func([],[e.Opt(ve)],["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 E.Canister{static create(t){let{service:c,certifiedService:r,canisterId:o}=(0,E.createServices)({options:t,idlFactory:Ye,certifiedIdlFactory:Xe});return new e(o,c,r)}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,E.toNullable)(t.subaccount)});transfer=async t=>{let c=await this.caller({certified:!0}).icrc1_transfer(Se(t));if("Err"in c)throw new G({errorType:c.Err,msg:"Failed to transfer"});return c.Ok};totalTokensSupply=t=>this.caller(t).icrc1_total_supply();transferFrom=async t=>{let c=await this.caller({certified:!0}).icrc2_transfer_from(Ee(t));if("Err"in c)throw new G({errorType:c.Err,msg:"Failed to transfer from"});return c.Ok};approve=async t=>{let c=await this.caller({certified:!0}).icrc2_approve(we(t));if("Err"in c)throw new G({errorType:c.Err,msg:"Failed to entitle the spender to transfer the amount"});return c.Ok};allowance=t=>{let{certified:c,...r}=t;return this.caller({certified:c}).icrc2_allowance({...r})};consentMessage=async t=>{let{icrc21_canister_call_consent_message:c}=this.caller({certified:!0}),r=await c(Be(t));if("Err"in r)throw Ce(r.Err);return r.Ok};getBlocks=t=>this.caller({certified:t.certified}).icrc3_get_blocks(t.args);getIndexPrincipal=async t=>{let{icrc106_get_index_principal:c}=this.caller(t),r=await c();if("Err"in r)throw Me(r.Err);return r.Ok};icrc1SupportedStandards=t=>this.caller(t).icrc1_supported_standards();icrc10SupportedStandards=t=>this.caller(t).icrc10_supported_standards()};var qe=(n=>(n.SYMBOL="icrc1:symbol",n.NAME="icrc1:name",n.DECIMALS="icrc1:decimals",n.FEE="icrc1:fee",n.LOGO="icrc1:logo",n))(qe||{});var Ue=require("@dfinity/principal"),u=require("@dfinity/utils");var rt=64,ct=({owner:e,subaccount:t})=>{if((0,u.isNullish)(t))return e.toText();let r=(o=>o.replace(/^0+/,""))((0,u.uint8ArrayToHexString)(Uint8Array.from(t)));return r.length===0?e.toText():`${e.toText()}-${je({owner:e,subaccount:t})}.${r}`},je=({owner:e,subaccount:t})=>{let c=(0,u.bigEndianCrc32)(Uint8Array.from([...e.toUint8Array(),...t]));return(0,u.encodeBase32)(c)},at=e=>{let[t,c,...r]=e.split(".");if(!(0,u.notEmptyString)(t))throw new Error("Invalid account. No string provided.");if(r.length>0)throw new Error("Invalid account string format. Expected at most one '.' separator.");if((0,u.isNullish)(c))return{owner:Ue.Principal.fromText(e)};let[o,...n]=t.split("-").reverse(),d=n.reverse().join("-"),a={owner:Ue.Principal.fromText(d),subaccount:(0,u.hexStringToUint8Array)(c.padStart(rt,"0"))};if(je(a)!==o)throw new Error("Invalid account. Invalid checksum.");return a},nt=e=>{let t=e.reduce((r,[o,n])=>{switch(o){case"icrc1:symbol":r={...r,..."Text"in n&&{symbol:n.Text}};break;case"icrc1:name":r={...r,..."Text"in n&&{name:n.Text}};break;case"icrc1:fee":r={...r,..."Nat"in n&&{fee:n.Nat}};break;case"icrc1:decimals":r={...r,..."Nat"in n&&{decimals:Number(n.Nat)}};break;case"icrc1:logo":r={...r,..."Text"in n&&{icon:n.Text}}}return r},{});if((r=>(0,u.nonNullish)(r.symbol)&&(0,u.nonNullish)(r.name)&&(0,u.nonNullish)(r.fee)&&(0,u.nonNullish)(r.decimals))(t))return t};var J=require("@dfinity/utils"),ot=e=>{let t=/^([a-zA-Z]+):([A-Za-z0-9:\-.]+).*?(?:[?&](?:amount|value)=(\d+(?:\.\d+)?))?$/,c=e.match(t);if((0,J.isNullish)(c))return;let[r,o,n,d]=c;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 Ge=Object.defineProperty;var Ie=Object.getOwnPropertyDescriptor;var Le=Object.getOwnPropertyNames;var De=Object.prototype.hasOwnProperty;var et=(e,t)=>{for(var r in t)Ge(e,r,{get:t[r],enumerable:!0})},tt=(e,t,r,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Le(t))!De.call(e,o)&&o!==r&&Ge(e,o,{get:()=>t[o],enumerable:!(c=Ie(t,o))||c.enumerable});return e};var rt=e=>tt(Ge({},"__esModule",{value:!0}),e);var pt={};et(pt,{ConsentMessageError:()=>S,ConsentMessageUnavailableError:()=>z,GenericError:()=>M,IcrcIndexCanister:()=>X,IcrcIndexNgCanister:()=>Z,IcrcLedgerCanister:()=>j,IcrcMetadataResponseEntries:()=>ze,IcrcTransferError:()=>G,IndexError:()=>v,IndexPrincipalNotSetError:()=>Q,InsufficientPaymentError:()=>q,UnsupportedCanisterCallError:()=>U,decodeIcrcAccount:()=>ot,decodePayment:()=>it,encodeIcrcAccount:()=>nt,fromCandidAccount:()=>ct,mapIcrc106GetIndexPrincipalError:()=>qe,mapIcrc21ConsentMessageError:()=>Me,mapTokenMetadata:()=>st,toApproveArgs:()=>Be,toCandidAccount:()=>Se,toIcrc21ConsentMessageArgs:()=>Ce,toTransferArg:()=>Ee,toTransferFromArgs:()=>we});module.exports=rt(pt);var E=require("@dfinity/utils"),ct=({owner:e,subaccount:t})=>{let r=(0,E.fromNullable)(t);return{owner:e,...(0,E.nonNullish)(r)?{subaccount:r}:{}}},Se=({owner:e,subaccount:t})=>({owner:e,subaccount:(0,E.toNullable)(t)});var _=require("@dfinity/utils"),Ee=({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)}),we=({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)}),Be=({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)}),Ce=({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}:{FieldsDisplay:null})}});var v=class extends Error{};var G=class extends Error{errorType;constructor({msg:t,errorType:r}){super(t),this.errorType=r}},M=class extends Error{constructor(r,c){super();this.message=r;this.error_code=c}},S=class extends Error{},q=class extends S{},U=class extends S{},z=class extends S{},Me=e=>"GenericError"in e?new M(e.GenericError.description,e.GenericError.error_code):"InsufficientPayment"in e?new q(e.InsufficientPayment.description):"UnsupportedCanisterCall"in e?new U(e.UnsupportedCanisterCall.description):"ConsentMessageUnavailable"in e?new z(e.ConsentMessageUnavailable.description):new S(`Unknown error type ${JSON.stringify(e)}`),Q=class extends Error{},qe=e=>"IndexPrincipalNotSet"in e?new Q("Index principal is not set for this ledger canister."):new M(e.GenericError.description,e.GenericError.error_code);var Ze=require("@dfinity/utils");var $e=({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],["query"])})};var He=({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 H=require("@dfinity/utils"),$=class extends H.Canister{balance=t=>this.caller({certified:t.certified}).icrc1_balance_of({owner:t.owner,subaccount:(0,H.toNullable)(t.subaccount)})};var Ue=require("@dfinity/utils");var W=({account:e,max_results:t,start:r})=>({account:Se(e),max_results:t,start:(0,Ue.toNullable)(r)}),We=({owner:e,start:t})=>({owner:e,start:(0,Ue.toNullable)(t)});var Z=class e extends ${static create(t){let{service:r,certifiedService:c,canisterId:o}=(0,Ze.createServices)({options:t,idlFactory:He,certifiedIdlFactory:$e});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(We(r))};var Y=require("@dfinity/utils");var Xe=({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 Ye=({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:Ye,certifiedIdlFactory:Xe});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 je=({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)}),B=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(B)}),ee=e.Func([y],[D],[]),te=e.Record({first_index:x,log_length:e.Nat,transactions:e.Vec(B),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}),C=e.Record({utc_offset_minutes:e.Opt(e.Int16),language:e.Text}),_e=e.Record({metadata:C,device_spec:e.Opt(e.Variant({GenericDisplay:e.Null,FieldsDisplay:e.Null}))}),me=e.Record({arg:e.Vec(e.Nat8),method:e.Text,user_preferences:_e}),ue=e.Variant({Text:e.Record({content:e.Text}),TokenAmount:e.Record({decimals:e.Nat8,amount:e.Nat64,symbol:e.Text}),TimestampSeconds:e.Record({amount:e.Nat64}),DurationSeconds:e.Record({amount:e.Nat64})}),ge=e.Record({fields:e.Vec(e.Tuple(e.Text,ue)),intent:e.Text}),fe=e.Variant({FieldsDisplayMessage:ge,GenericDisplayMessage:e.Text}),Ne=e.Record({metadata:C,consent_message:fe}),P=e.Record({description:e.Text}),Oe=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),InsufficientPayment:P,UnsupportedCanisterCall:P,ConsentMessageUnavailable:P}),xe=e.Variant({Ok:Ne,Err:Oe}),Te=e.Record({account:a,spender:a}),Re=e.Record({allowance:e.Nat,expires_at:e.Opt(s)}),ye=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}),Ve=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})}),be=e.Variant({Ok:i,Err:Ve}),Ae=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}),he=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})}),ke=e.Variant({Ok:i,Err:he}),Fe=e.Record({from:e.Opt(e.Principal)}),Pe=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 ve=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],[xe],[]),icrc2_allowance:e.Func([Te],[Re],[]),icrc2_approve:e.Func([ye],[be],[]),icrc2_transfer_from:e.Func([Ae],[ke],[]),icrc3_get_archives:e.Func([Fe],[Pe],[]),icrc3_get_blocks:e.Func([e.Vec(m)],[t],[]),icrc3_get_tip_certificate:e.Func([],[e.Opt(ve)],[]),icrc3_supported_block_types:e.Func([],[e.Vec(e.Record({url:e.Text,block_type:e.Text}))],[]),is_ledger_ready:e.Func([],[e.Bool],["query"])})};var Je=({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)}),B=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(B)}),ee=e.Func([y],[D],["query"]),te=e.Record({first_index:x,log_length:e.Nat,transactions:e.Vec(B),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}),C=e.Record({utc_offset_minutes:e.Opt(e.Int16),language:e.Text}),_e=e.Record({metadata:C,device_spec:e.Opt(e.Variant({GenericDisplay:e.Null,FieldsDisplay:e.Null}))}),me=e.Record({arg:e.Vec(e.Nat8),method:e.Text,user_preferences:_e}),ue=e.Variant({Text:e.Record({content:e.Text}),TokenAmount:e.Record({decimals:e.Nat8,amount:e.Nat64,symbol:e.Text}),TimestampSeconds:e.Record({amount:e.Nat64}),DurationSeconds:e.Record({amount:e.Nat64})}),ge=e.Record({fields:e.Vec(e.Tuple(e.Text,ue)),intent:e.Text}),fe=e.Variant({FieldsDisplayMessage:ge,GenericDisplayMessage:e.Text}),Ne=e.Record({metadata:C,consent_message:fe}),P=e.Record({description:e.Text}),Oe=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),InsufficientPayment:P,UnsupportedCanisterCall:P,ConsentMessageUnavailable:P}),xe=e.Variant({Ok:Ne,Err:Oe}),Te=e.Record({account:a,spender:a}),Re=e.Record({allowance:e.Nat,expires_at:e.Opt(s)}),ye=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}),Ve=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})}),be=e.Variant({Ok:i,Err:Ve}),Ae=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}),he=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})}),ke=e.Variant({Ok:i,Err:he}),Fe=e.Record({from:e.Opt(e.Principal)}),Pe=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 ve=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],[xe],[]),icrc2_allowance:e.Func([Te],[Re],["query"]),icrc2_approve:e.Func([ye],[be],[]),icrc2_transfer_from:e.Func([Ae],[ke],[]),icrc3_get_archives:e.Func([Fe],[Pe],["query"]),icrc3_get_blocks:e.Func([e.Vec(m)],[t],["query"]),icrc3_get_tip_certificate:e.Func([],[e.Opt(ve)],["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:Je,certifiedIdlFactory:je});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(Ee(t));if("Err"in r)throw new G({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(we(t));if("Err"in r)throw new G({errorType:r.Err,msg:"Failed to transfer from"});return r.Ok};approve=async t=>{let r=await this.caller({certified:!0}).icrc2_approve(Be(t));if("Err"in r)throw new G({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(Ce(t));if("Err"in c)throw Me(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 qe(c.Err);return c.Ok};icrc1SupportedStandards=t=>this.caller(t).icrc1_supported_standards();icrc10SupportedStandards=t=>this.caller(t).icrc10_supported_standards();getMintingAccount=t=>this.caller(t).icrc1_minting_account()};var ze=(n=>(n.SYMBOL="icrc1:symbol",n.NAME="icrc1:name",n.DECIMALS="icrc1:decimals",n.FEE="icrc1:fee",n.LOGO="icrc1:logo",n))(ze||{});var Qe=require("@dfinity/principal"),u=require("@dfinity/utils");var at=64,nt=({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()}-${Ke({owner:e,subaccount:t})}.${c}`},Ke=({owner:e,subaccount:t})=>{let r=(0,u.bigEndianCrc32)(Uint8Array.from([...e.toUint8Array(),...t]));return(0,u.encodeBase32)(r)},ot=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:Qe.Principal.fromText(e)};let[o,...n]=t.split("-").reverse(),d=n.reverse().join("-"),a={owner:Qe.Principal.fromText(d),subaccount:(0,u.hexStringToUint8Array)(r.padStart(at,"0"))};if(Ke(a)!==o)throw new Error("Invalid account. Invalid checksum.");return a},st=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"),it=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,fromCandidAccount,mapIcrc106GetIndexPrincipalError,mapIcrc21ConsentMessageError,mapTokenMetadata,toApproveArgs,toCandidAccount,toIcrc21ConsentMessageArgs,toTransferArg,toTransferFromArgs});
2
2
  //# sourceMappingURL=index.cjs.js.map