@dfinity/ledger-icrc 3.0.0 → 4.0.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.
@@ -246,13 +246,7 @@ export const idlFactory = ({ IDL }) => {
246
246
  const icrc21_consent_message_spec = IDL.Record({
247
247
  'metadata' : icrc21_consent_message_metadata,
248
248
  'device_spec' : IDL.Opt(
249
- IDL.Variant({
250
- 'GenericDisplay' : IDL.Null,
251
- 'LineDisplay' : IDL.Record({
252
- 'characters_per_line' : IDL.Nat16,
253
- 'lines_per_page' : IDL.Nat16,
254
- }),
255
- })
249
+ IDL.Variant({ 'GenericDisplay' : IDL.Null, 'FieldsDisplay' : IDL.Null })
256
250
  ),
257
251
  });
258
252
  const icrc21_consent_message_request = IDL.Record({
@@ -260,10 +254,22 @@ export const idlFactory = ({ IDL }) => {
260
254
  'method' : IDL.Text,
261
255
  'user_preferences' : icrc21_consent_message_spec,
262
256
  });
263
- const icrc21_consent_message = IDL.Variant({
264
- 'LineDisplayMessage' : IDL.Record({
265
- 'pages' : IDL.Vec(IDL.Record({ 'lines' : IDL.Vec(IDL.Text) })),
257
+ const Icrc21Value = IDL.Variant({
258
+ 'Text' : IDL.Record({ 'content' : IDL.Text }),
259
+ 'TokenAmount' : IDL.Record({
260
+ 'decimals' : IDL.Nat8,
261
+ 'amount' : IDL.Nat64,
262
+ 'symbol' : IDL.Text,
266
263
  }),
264
+ 'TimestampSeconds' : IDL.Record({ 'amount' : IDL.Nat64 }),
265
+ 'DurationSeconds' : IDL.Record({ 'amount' : IDL.Nat64 }),
266
+ });
267
+ const FieldsDisplay = IDL.Record({
268
+ 'fields' : IDL.Vec(IDL.Tuple(IDL.Text, Icrc21Value)),
269
+ 'intent' : IDL.Text,
270
+ });
271
+ const icrc21_consent_message = IDL.Variant({
272
+ 'FieldsDisplayMessage' : FieldsDisplay,
267
273
  'GenericDisplayMessage' : IDL.Text,
268
274
  });
269
275
  const icrc21_consent_info = IDL.Record({
@@ -1,2 +1,2 @@
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});
1
+ "use strict";var Se=Object.defineProperty;var Je=Object.getOwnPropertyDescriptor;var Ke=Object.getOwnPropertyNames;var Ie=Object.prototype.hasOwnProperty;var Le=(e,t)=>{for(var c in t)Se(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&&Se(e,o,{get:()=>t[o],enumerable:!(r=Je(t,o))||r.enumerable});return e};var et=e=>De(Se({},"__esModule",{value:!0}),e);var st={};Le(st,{ConsentMessageError:()=>E,ConsentMessageUnavailableError:()=>U,GenericError:()=>C,IcrcIndexCanister:()=>X,IcrcIndexNgCanister:()=>Z,IcrcLedgerCanister:()=>j,IcrcMetadataResponseEntries:()=>qe,IcrcTransferError:()=>S,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:()=>Ee,toTransferFromArgs:()=>Ge});module.exports=et(st);var _=require("@dfinity/utils"),Ee=({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)}),Ge=({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 S=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}},E=class extends Error{},M=class extends E{},q=class extends E{},U=class extends E{},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 E(`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}),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 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}),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"),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 G=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],[]),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)}),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}),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}));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],[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 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"]),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)}),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}),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}));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],[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 G.Canister{static create(t){let{service:c,certifiedService:r,canisterId:o}=(0,G.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,G.toNullable)(t.subaccount)});transfer=async t=>{let c=await this.caller({certified:!0}).icrc1_transfer(Ee(t));if("Err"in c)throw new S({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(Ge(t));if("Err"in c)throw new S({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 S({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});
2
2
  //# sourceMappingURL=index.cjs.js.map