@dfinity/ledger-icrc 6.0.1-next-2025-11-26 → 6.0.1

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.
@@ -1,4 +1,4 @@
1
- // Generated from IC repo commit 948d5b9 (2025-11-19 tags: release-2025-11-20_03-21-base) 'rs/ledger_suite/icrc1/index-ng/index-ng.did' by import-candid
1
+ // Generated from IC repo commit fa06b0e (2025-11-12 tags: release-2025-11-13_03-24-base) 'rs/ledger_suite/icrc1/index-ng/index-ng.did' by import-candid
2
2
 
3
3
  type Tokens = nat;
4
4
 
@@ -1,4 +1,4 @@
1
- // Generated from IC repo commit 948d5b9 (2025-11-19 tags: release-2025-11-20_03-21-base) 'rs/ledger_suite/icrc1/ledger/ledger.did' by import-candid
1
+ // Generated from IC repo commit fa06b0e (2025-11-12 tags: release-2025-11-13_03-24-base) 'rs/ledger_suite/icrc1/ledger/ledger.did' by import-candid
2
2
 
3
3
  type BlockIndex = nat;
4
4
  type Subaccount = blob;
@@ -1,8 +1,8 @@
1
1
  import { Canister } from "@dfinity/utils";
2
- import type { Tokens } from "./candid/icrc_ledger";
3
- import type { IcrcCanisterService } from "./types/canister.types";
2
+ import type { _SERVICE as IcrcIndexNgService } from "./candid/icrc_index-ng";
3
+ import type { _SERVICE as IcrcLedgerService, Tokens } from "./candid/icrc_ledger";
4
4
  import type { BalanceParams } from "./types/ledger.params";
5
- export declare abstract class IcrcCanister<T extends IcrcCanisterService> extends Canister<T> {
5
+ export declare abstract class IcrcCanister<T extends IcrcLedgerService | IcrcIndexNgService> extends Canister<T> {
6
6
  /**
7
7
  * Returns the balance for a given account provided as owner and with optional subaccount.
8
8
  *
package/dist/index.d.ts CHANGED
@@ -9,7 +9,6 @@ export * from "./errors/ledger.errors";
9
9
  export { IcrcIndexNgCanister } from "./index-ng.canister";
10
10
  export { IcrcIndexCanister } from "./index.canister";
11
11
  export { IcrcLedgerCanister } from "./ledger.canister";
12
- export { IcrcNftLedgerCanister } from "./nft-ledger.canister";
13
12
  export type * from "./types/index-ng.params";
14
13
  export type * from "./types/index-ng.types";
15
14
  export type * from "./types/index.params";
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{fromNullable as je,nonNullish as Je,toNullable as Ke}from"@dfinity/utils";var Nt=({owner:e,subaccount:t})=>{let c=je(t);return{owner:e,...Je(c)?{subaccount:c}:{}}},ke=({owner:e,subaccount:t})=>({owner:e,subaccount:Ke(t)});import{isNullish as Ie,toNullable as u}from"@dfinity/utils";var he=({from_subaccount:e,fee:t,created_at_time:c,memo:r,...o})=>({...o,fee:u(t),memo:u(r),from_subaccount:u(e),created_at_time:u(c)}),Pe=({spender_subaccount:e,fee:t,created_at_time:c,memo:r,...o})=>({...o,fee:u(t),memo:u(r),spender_subaccount:u(e),created_at_time:u(c)}),ve=({fee:e,created_at_time:t,memo:c,from_subaccount:r,expected_allowance:o,expires_at:n,...i})=>({...i,fee:u(e),memo:u(c),from_subaccount:u(r),created_at_time:u(t),expected_allowance:u(o),expires_at:u(n)}),Se=({userPreferences:{metadata:{utcOffsetMinutes:e,language:t},deriveSpec:c},...r})=>({...r,user_preferences:{metadata:{language:t,utc_offset_minutes:u(e)},device_spec:Ie(c)?u():u("GenericDisplay"in c?{GenericDisplay:null}:{FieldsDisplay:null})}});var P=class extends Error{};var v=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{},xe=class extends S{},Te=class extends S{},Re=class extends S{},Ee=e=>"GenericError"in e?new C(e.GenericError.description,e.GenericError.error_code):"InsufficientPayment"in e?new xe(e.InsufficientPayment.description):"UnsupportedCanisterCall"in e?new Te(e.UnsupportedCanisterCall.description):"ConsentMessageUnavailable"in e?new Re(e.ConsentMessageUnavailable.description):new S(`Unknown error type ${JSON.stringify(e)}`),ye=class extends Error{},we=e=>"IndexPrincipalNotSet"in e?new ye("Index principal is not set for this ledger canister."):new C(e.GenericError.description,e.GenericError.error_code);import{createServices as et}from"@dfinity/utils";var Ge=({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,i=e.Vec(e.Nat8),a=e.Record({owner:e.Principal,subaccount:e.Opt(i)}),N=e.Record({max_results:e.Nat,start:e.Opt(n),account:a}),l=e.Nat,f=e.Record({fee:e.Opt(e.Nat),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:l,spender:e.Opt(a)}),g=e.Record({to:a,fee:e.Opt(e.Nat),memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:l}),x=e.Record({fee:e.Opt(l),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:l,expected_allowance:e.Opt(l),expires_at:e.Opt(e.Nat64),spender:a}),p=e.Record({to:a,fee:e.Opt(l),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:l,spender:e.Opt(a)}),m=e.Record({burn:e.Opt(f),kind:e.Text,mint:e.Opt(g),approve:e.Opt(x),timestamp:e.Nat64,transfer:e.Opt(p)}),_=e.Record({id:n,transaction:m}),y=e.Record({balance:l,transactions:e.Vec(_),oldest_tx_id:e.Opt(n)}),T=e.Record({message:e.Text}),V=e.Variant({Ok:y,Err:T}),b=e.Record({start:e.Nat,length:e.Nat}),A=e.Vec(e.Tuple(e.Text,t));t.fill(e.Variant({Int:e.Int,Map:A,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(t)}));let F=t,O=e.Record({blocks:e.Vec(F),chain_length:e.Nat64}),R=e.Record({ranges:e.Vec(e.Tuple(a,e.Vec(e.Tuple(n,n))))}),s=e.Record({owner:e.Principal,start:e.Opt(i)}),k=e.Record({num_blocks_synced:n});return e.Service({get_account_transactions:e.Func([N],[V],[]),get_blocks:e.Func([b],[O],[]),get_fee_collectors_ranges:e.Func([],[R],[]),icrc1_balance_of:e.Func([a],[l],[]),ledger_id:e.Func([],[e.Principal],[]),list_subaccounts:e.Func([s],[e.Vec(i)],[]),status:e.Func([],[k],["query"])})};var Ce=({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,i=e.Vec(e.Nat8),a=e.Record({owner:e.Principal,subaccount:e.Opt(i)}),N=e.Record({max_results:e.Nat,start:e.Opt(n),account:a}),l=e.Nat,f=e.Record({fee:e.Opt(e.Nat),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:l,spender:e.Opt(a)}),g=e.Record({to:a,fee:e.Opt(e.Nat),memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:l}),x=e.Record({fee:e.Opt(l),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:l,expected_allowance:e.Opt(l),expires_at:e.Opt(e.Nat64),spender:a}),p=e.Record({to:a,fee:e.Opt(l),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:l,spender:e.Opt(a)}),m=e.Record({burn:e.Opt(f),kind:e.Text,mint:e.Opt(g),approve:e.Opt(x),timestamp:e.Nat64,transfer:e.Opt(p)}),_=e.Record({id:n,transaction:m}),y=e.Record({balance:l,transactions:e.Vec(_),oldest_tx_id:e.Opt(n)}),T=e.Record({message:e.Text}),V=e.Variant({Ok:y,Err:T}),b=e.Record({start:e.Nat,length:e.Nat}),A=e.Vec(e.Tuple(e.Text,t));t.fill(e.Variant({Int:e.Int,Map:A,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(t)}));let F=t,O=e.Record({blocks:e.Vec(F),chain_length:e.Nat64}),R=e.Record({ranges:e.Vec(e.Tuple(a,e.Vec(e.Tuple(n,n))))}),s=e.Record({owner:e.Principal,start:e.Opt(i)}),k=e.Record({num_blocks_synced:n});return e.Service({get_account_transactions:e.Func([N],[V],["query"]),get_blocks:e.Func([b],[O],["query"]),get_fee_collectors_ranges:e.Func([],[R],["query"]),icrc1_balance_of:e.Func([a],[l],["query"]),ledger_id:e.Func([],[e.Principal],["query"]),list_subaccounts:e.Func([s],[e.Vec(i)],["query"]),status:e.Func([],[k],["query"])})};import{Canister as Le,toNullable as De}from"@dfinity/utils";var E=class extends Le{balance=t=>this.caller({certified:t.certified}).icrc1_balance_of({owner:t.owner,subaccount:De(t.subaccount)})};import{toNullable as Be}from"@dfinity/utils";var B=({account:e,max_results:t,start:c})=>({account:ke(e),max_results:t,start:Be(c)}),qe=({owner:e,start:t})=>({owner:e,start:Be(t)});var Ve=class e extends E{static create(t){let{service:c,certifiedService:r,canisterId:o}=et({options:t,idlFactory:Ce,certifiedIdlFactory:Ge});return new e(o,c,r)}getTransactions=async({certified:t,...c})=>{let r=await this.caller({certified:t}).get_account_transactions(B(c));if("Err"in r)throw new P(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(qe(c))};import{Canister as tt,createServices as rt}from"@dfinity/utils";var Me=({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)}),i=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}),N=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)}),l=e.Record({burn:e.Opt(n),kind:e.Text,mint:e.Opt(i),approve:e.Opt(a),timestamp:e.Nat64,transfer:e.Opt(N)}),f=e.Record({id:c,transaction:l}),g=e.Record({transactions:e.Vec(f),oldest_tx_id:e.Opt(c)}),x=e.Record({message:e.Text}),p=e.Variant({Ok:g,Err:x}),m=e.Vec(e.Nat8),_=e.Record({owner:e.Principal,start:e.Opt(m)});return e.Service({get_account_transactions:e.Func([o],[p],[]),ledger_id:e.Func([],[e.Principal],[]),list_subaccounts:e.Func([_],[e.Vec(m)],[])})};var Ue=({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)}),i=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}),N=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)}),l=e.Record({burn:e.Opt(n),kind:e.Text,mint:e.Opt(i),approve:e.Opt(a),timestamp:e.Nat64,transfer:e.Opt(N)}),f=e.Record({id:c,transaction:l}),g=e.Record({transactions:e.Vec(f),oldest_tx_id:e.Opt(c)}),x=e.Record({message:e.Text}),p=e.Variant({Ok:g,Err:x}),m=e.Vec(e.Nat8),_=e.Record({owner:e.Principal,start:e.Opt(m)});return e.Service({get_account_transactions:e.Func([o],[p],[]),ledger_id:e.Func([],[e.Principal],["query"]),list_subaccounts:e.Func([_],[e.Vec(m)],["query"])})};var be=class e extends tt{static create(t){let{service:c,certifiedService:r,canisterId:o}=rt({options:t,idlFactory:Ue,certifiedIdlFactory:Me});return new e(o,c,r)}getTransactions=async t=>{let c=await this.caller({certified:!0}).get_account_transactions(B(t));if("Err"in c)throw new P(c.Err.message);return c.Ok};ledgerId=t=>{let{ledger_id:c}=this.caller(t);return c()}};import{createServices as ct}from"@dfinity/utils";var ze=({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}),i=e.Vec(e.Nat8),a=e.Record({owner:e.Principal,subaccount:e.Opt(i)}),N=e.Variant({SetTo:a,Unset:e.Null}),l=e.Record({icrc2:e.Bool}),f=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(N),max_memo_length:e.Opt(e.Nat16),index_principal:e.Opt(e.Principal),token_name:e.Opt(e.Text),feature_flags:e.Opt(l)}),g=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(l)}),x=e.Variant({Upgrade:e.Opt(f),Init:g}),p=e.Nat,m=e.Record({block_range_end:p,canister_id:e.Principal,block_range_start:p}),_=e.Record({start:p,length:e.Nat}),y=e.Vec(e.Tuple(e.Text,r));r.fill(e.Variant({Int:e.Int,Map:y,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(r)}));let T=r,V=e.Record({blocks:e.Vec(T)}),b=e.Func([_],[V],[]),A=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),first_index:p,blocks:e.Vec(T),chain_length:e.Nat64,archived_blocks:e.Vec(e.Record({callback:b,start:p,length:e.Nat}))}),F=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),hash_tree:e.Vec(e.Nat8)}),O=e.Nat,R=e.Record({start:O,length:e.Nat}),s=e.Nat64,k=e.Record({fee:e.Opt(e.Nat),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:e.Nat,spender:e.Opt(a)}),M=e.Record({to:a,fee:e.Opt(e.Nat),memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:e.Nat}),U=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}),z=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(k),kind:e.Text,mint:e.Opt(M),approve:e.Opt(U),timestamp:s,transfer:e.Opt(z)}),Q=e.Record({transactions:e.Vec(w)}),$=e.Func([R],[Q],[]),H=e.Record({first_index:O,log_length:e.Nat,transactions:e.Vec(w),archived_transactions:e.Vec(e.Record({callback:$,start:O,length:e.Nat}))}),W=e.Record({take:e.Opt(e.Nat),prev_spender:e.Opt(a),from_account:e.Opt(a)}),Z=e.Record({from_account:a,to_spender:a,allowance:e.Nat,expires_at:e.Opt(e.Nat64)}),X=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),AccessDenied:e.Record({reason:e.Text})}),Y=e.Variant({Ok:e.Vec(Z),Err:X}),j=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),IndexPrincipalNotSet:e.Null}),J=e.Variant({Ok:e.Principal,Err:j}),d=e.Nat,K=e.Record({url:e.Text,name:e.Text}),I=e.Record({to:a,fee:e.Opt(d),memo:e.Opt(e.Vec(e.Nat8)),from_subaccount:e.Opt(i),created_at_time:e.Opt(s),amount:d}),L=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,BadBurn:e.Record({min_burn_amount:d}),Duplicate:e.Record({duplicate_of:p}),BadFee:e.Record({expected_fee:d}),CreatedInFuture:e.Record({ledger_time:s}),TooOld:e.Null,InsufficientFunds:e.Record({balance:d})}),D=e.Variant({Ok:p,Err:L}),G=e.Record({utc_offset_minutes:e.Opt(e.Int16),language:e.Text}),ee=e.Record({metadata:G,device_spec:e.Opt(e.Variant({GenericDisplay:e.Null,FieldsDisplay:e.Null}))}),te=e.Record({arg:e.Vec(e.Nat8),method:e.Text,user_preferences:ee}),re=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})}),ce=e.Record({fields:e.Vec(e.Tuple(e.Text,re)),intent:e.Text}),ae=e.Variant({FieldsDisplayMessage:ce,GenericDisplayMessage:e.Text}),ne=e.Record({metadata:G,consent_message:ae}),h=e.Record({description:e.Text}),oe=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),InsufficientPayment:h,UnsupportedCanisterCall:h,ConsentMessageUnavailable:h}),se=e.Variant({Ok:ne,Err:oe}),ie=e.Record({account:a,spender:a}),pe=e.Record({allowance:e.Nat,expires_at:e.Opt(s)}),le=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}),de=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,Duplicate:e.Record({duplicate_of:p}),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})}),_e=e.Variant({Ok:p,Err:de}),ue=e.Record({to:a,fee:e.Opt(d),spender_subaccount:e.Opt(i),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:d}),me=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,InsufficientAllowance:e.Record({allowance:d}),BadBurn:e.Record({min_burn_amount:d}),Duplicate:e.Record({duplicate_of:p}),BadFee:e.Record({expected_fee:d}),CreatedInFuture:e.Record({ledger_time:s}),TooOld:e.Null,InsufficientFunds:e.Record({balance:d})}),Ne=e.Variant({Ok:p,Err:me}),fe=e.Record({from:e.Opt(e.Principal)}),ge=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(_),callback:e.Func([e.Vec(_)],[t],["query"])}))}));let Oe=e.Record({certificate:e.Vec(e.Nat8),hash_tree:e.Vec(e.Nat8)});return e.Service({archives:e.Func([],[e.Vec(m)],[]),get_blocks:e.Func([_],[A],[]),get_data_certificate:e.Func([],[F],[]),get_transactions:e.Func([R],[H],[]),icrc103_get_allowances:e.Func([W],[Y],[]),icrc106_get_index_principal:e.Func([],[J],[]),icrc10_supported_standards:e.Func([],[e.Vec(e.Record({url:e.Text,name:e.Text}))],[]),icrc1_balance_of:e.Func([a],[d],[]),icrc1_decimals:e.Func([],[e.Nat8],[]),icrc1_fee:e.Func([],[d],[]),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(K)],[]),icrc1_symbol:e.Func([],[e.Text],[]),icrc1_total_supply:e.Func([],[d],[]),icrc1_transfer:e.Func([I],[D],[]),icrc21_canister_call_consent_message:e.Func([te],[se],[]),icrc2_allowance:e.Func([ie],[pe],[]),icrc2_approve:e.Func([le],[_e],[]),icrc2_transfer_from:e.Func([ue],[Ne],[]),icrc3_get_archives:e.Func([fe],[ge],[]),icrc3_get_blocks:e.Func([e.Vec(_)],[t],[]),icrc3_get_tip_certificate:e.Func([],[e.Opt(Oe)],[]),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 Qe=({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}),i=e.Vec(e.Nat8),a=e.Record({owner:e.Principal,subaccount:e.Opt(i)}),N=e.Variant({SetTo:a,Unset:e.Null}),l=e.Record({icrc2:e.Bool}),f=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(N),max_memo_length:e.Opt(e.Nat16),index_principal:e.Opt(e.Principal),token_name:e.Opt(e.Text),feature_flags:e.Opt(l)}),g=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(l)}),x=e.Variant({Upgrade:e.Opt(f),Init:g}),p=e.Nat,m=e.Record({block_range_end:p,canister_id:e.Principal,block_range_start:p}),_=e.Record({start:p,length:e.Nat}),y=e.Vec(e.Tuple(e.Text,r));r.fill(e.Variant({Int:e.Int,Map:y,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(r)}));let T=r,V=e.Record({blocks:e.Vec(T)}),b=e.Func([_],[V],["query"]),A=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),first_index:p,blocks:e.Vec(T),chain_length:e.Nat64,archived_blocks:e.Vec(e.Record({callback:b,start:p,length:e.Nat}))}),F=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),hash_tree:e.Vec(e.Nat8)}),O=e.Nat,R=e.Record({start:O,length:e.Nat}),s=e.Nat64,k=e.Record({fee:e.Opt(e.Nat),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:e.Nat,spender:e.Opt(a)}),M=e.Record({to:a,fee:e.Opt(e.Nat),memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:e.Nat}),U=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}),z=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(k),kind:e.Text,mint:e.Opt(M),approve:e.Opt(U),timestamp:s,transfer:e.Opt(z)}),Q=e.Record({transactions:e.Vec(w)}),$=e.Func([R],[Q],["query"]),H=e.Record({first_index:O,log_length:e.Nat,transactions:e.Vec(w),archived_transactions:e.Vec(e.Record({callback:$,start:O,length:e.Nat}))}),W=e.Record({take:e.Opt(e.Nat),prev_spender:e.Opt(a),from_account:e.Opt(a)}),Z=e.Record({from_account:a,to_spender:a,allowance:e.Nat,expires_at:e.Opt(e.Nat64)}),X=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),AccessDenied:e.Record({reason:e.Text})}),Y=e.Variant({Ok:e.Vec(Z),Err:X}),j=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),IndexPrincipalNotSet:e.Null}),J=e.Variant({Ok:e.Principal,Err:j}),d=e.Nat,K=e.Record({url:e.Text,name:e.Text}),I=e.Record({to:a,fee:e.Opt(d),memo:e.Opt(e.Vec(e.Nat8)),from_subaccount:e.Opt(i),created_at_time:e.Opt(s),amount:d}),L=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,BadBurn:e.Record({min_burn_amount:d}),Duplicate:e.Record({duplicate_of:p}),BadFee:e.Record({expected_fee:d}),CreatedInFuture:e.Record({ledger_time:s}),TooOld:e.Null,InsufficientFunds:e.Record({balance:d})}),D=e.Variant({Ok:p,Err:L}),G=e.Record({utc_offset_minutes:e.Opt(e.Int16),language:e.Text}),ee=e.Record({metadata:G,device_spec:e.Opt(e.Variant({GenericDisplay:e.Null,FieldsDisplay:e.Null}))}),te=e.Record({arg:e.Vec(e.Nat8),method:e.Text,user_preferences:ee}),re=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})}),ce=e.Record({fields:e.Vec(e.Tuple(e.Text,re)),intent:e.Text}),ae=e.Variant({FieldsDisplayMessage:ce,GenericDisplayMessage:e.Text}),ne=e.Record({metadata:G,consent_message:ae}),h=e.Record({description:e.Text}),oe=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),InsufficientPayment:h,UnsupportedCanisterCall:h,ConsentMessageUnavailable:h}),se=e.Variant({Ok:ne,Err:oe}),ie=e.Record({account:a,spender:a}),pe=e.Record({allowance:e.Nat,expires_at:e.Opt(s)}),le=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}),de=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,Duplicate:e.Record({duplicate_of:p}),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})}),_e=e.Variant({Ok:p,Err:de}),ue=e.Record({to:a,fee:e.Opt(d),spender_subaccount:e.Opt(i),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:d}),me=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,InsufficientAllowance:e.Record({allowance:d}),BadBurn:e.Record({min_burn_amount:d}),Duplicate:e.Record({duplicate_of:p}),BadFee:e.Record({expected_fee:d}),CreatedInFuture:e.Record({ledger_time:s}),TooOld:e.Null,InsufficientFunds:e.Record({balance:d})}),Ne=e.Variant({Ok:p,Err:me}),fe=e.Record({from:e.Opt(e.Principal)}),ge=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(_),callback:e.Func([e.Vec(_)],[t],["query"])}))}));let Oe=e.Record({certificate:e.Vec(e.Nat8),hash_tree:e.Vec(e.Nat8)});return e.Service({archives:e.Func([],[e.Vec(m)],["query"]),get_blocks:e.Func([_],[A],["query"]),get_data_certificate:e.Func([],[F],["query"]),get_transactions:e.Func([R],[H],["query"]),icrc103_get_allowances:e.Func([W],[Y],["query"]),icrc106_get_index_principal:e.Func([],[J],["query"]),icrc10_supported_standards:e.Func([],[e.Vec(e.Record({url:e.Text,name:e.Text}))],["query"]),icrc1_balance_of:e.Func([a],[d],["query"]),icrc1_decimals:e.Func([],[e.Nat8],["query"]),icrc1_fee:e.Func([],[d],["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(K)],["query"]),icrc1_symbol:e.Func([],[e.Text],["query"]),icrc1_total_supply:e.Func([],[d],["query"]),icrc1_transfer:e.Func([I],[D],[]),icrc21_canister_call_consent_message:e.Func([te],[se],[]),icrc2_allowance:e.Func([ie],[pe],["query"]),icrc2_approve:e.Func([le],[_e],[]),icrc2_transfer_from:e.Func([ue],[Ne],[]),icrc3_get_archives:e.Func([fe],[ge],["query"]),icrc3_get_blocks:e.Func([e.Vec(_)],[t],["query"]),icrc3_get_tip_certificate:e.Func([],[e.Opt(Oe)],["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 Ae=class e extends E{static create(t){let{service:c,certifiedService:r,canisterId:o}=ct({options:t,idlFactory:Qe,certifiedIdlFactory:ze});return new e(o,c,r)}metadata=t=>this.caller(t).icrc1_metadata();transactionFee=t=>this.caller(t).icrc1_fee();transfer=async t=>{let c=await this.caller({certified:!0}).icrc1_transfer(he(t));if("Err"in c)throw new v({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(Pe(t));if("Err"in c)throw new v({errorType:c.Err,msg:"Failed to transfer from"});return c.Ok};approve=async t=>{let c=await this.caller({certified:!0}).icrc2_approve(ve(t));if("Err"in c)throw new v({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(Se(t));if("Err"in r)throw Ee(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 we(r.Err);return r.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()};import{Canister as at,createServices as nt}from"@dfinity/utils";var $e=({IDL:e})=>{let t=e.Rec(),c=e.Vec(e.Nat8),r=e.Record({owner:e.Principal,subaccount:e.Opt(c)});t.fill(e.Variant({Int:e.Int,Map:e.Vec(e.Tuple(e.Text,t)),Nat:e.Nat,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(t)}));let o=e.Record({to:r,token_id:e.Nat,memo:e.Opt(e.Vec(e.Nat8)),from_subaccount:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64)}),n=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),Duplicate:e.Record({duplicate_of:e.Nat}),NonExistingTokenId:e.Null,Unauthorized:e.Null,CreatedInFuture:e.Record({ledger_time:e.Nat64}),InvalidRecipient:e.Null,GenericBatchError:e.Record({message:e.Text,error_code:e.Nat}),TooOld:e.Null}),i=e.Variant({Ok:e.Nat,Err:n});return e.Service({icrc7_atomic_batch_transfers:e.Func([],[e.Opt(e.Bool)],[]),icrc7_balance_of:e.Func([e.Vec(r)],[e.Vec(e.Nat)],[]),icrc7_collection_metadata:e.Func([],[e.Vec(e.Tuple(e.Text,t))],[]),icrc7_default_take_value:e.Func([],[e.Opt(e.Nat)],[]),icrc7_description:e.Func([],[e.Opt(e.Text)],[]),icrc7_logo:e.Func([],[e.Opt(e.Text)],[]),icrc7_max_memo_size:e.Func([],[e.Opt(e.Nat)],[]),icrc7_max_query_batch_size:e.Func([],[e.Opt(e.Nat)],[]),icrc7_max_take_value:e.Func([],[e.Opt(e.Nat)],[]),icrc7_max_update_batch_size:e.Func([],[e.Opt(e.Nat)],[]),icrc7_name:e.Func([],[e.Text],[]),icrc7_owner_of:e.Func([e.Vec(e.Nat)],[e.Vec(e.Opt(r))],[]),icrc7_permitted_drift:e.Func([],[e.Opt(e.Nat)],[]),icrc7_supply_cap:e.Func([],[e.Opt(e.Nat)],[]),icrc7_symbol:e.Func([],[e.Text],[]),icrc7_token_metadata:e.Func([e.Vec(e.Nat)],[e.Vec(e.Opt(e.Vec(e.Tuple(e.Text,t))))],[]),icrc7_tokens:e.Func([e.Opt(e.Nat),e.Opt(e.Nat)],[e.Vec(e.Nat)],[]),icrc7_tokens_of:e.Func([r,e.Opt(e.Nat),e.Opt(e.Nat)],[e.Vec(e.Nat)],[]),icrc7_total_supply:e.Func([],[e.Nat],[]),icrc7_transfer:e.Func([e.Vec(o)],[e.Vec(e.Opt(i))],[]),icrc7_tx_window:e.Func([],[e.Opt(e.Nat)],[])})};var He=({IDL:e})=>{let t=e.Rec(),c=e.Vec(e.Nat8),r=e.Record({owner:e.Principal,subaccount:e.Opt(c)});t.fill(e.Variant({Int:e.Int,Map:e.Vec(e.Tuple(e.Text,t)),Nat:e.Nat,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(t)}));let o=e.Record({to:r,token_id:e.Nat,memo:e.Opt(e.Vec(e.Nat8)),from_subaccount:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64)}),n=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),Duplicate:e.Record({duplicate_of:e.Nat}),NonExistingTokenId:e.Null,Unauthorized:e.Null,CreatedInFuture:e.Record({ledger_time:e.Nat64}),InvalidRecipient:e.Null,GenericBatchError:e.Record({message:e.Text,error_code:e.Nat}),TooOld:e.Null}),i=e.Variant({Ok:e.Nat,Err:n});return e.Service({icrc7_atomic_batch_transfers:e.Func([],[e.Opt(e.Bool)],["query"]),icrc7_balance_of:e.Func([e.Vec(r)],[e.Vec(e.Nat)],["query"]),icrc7_collection_metadata:e.Func([],[e.Vec(e.Tuple(e.Text,t))],["query"]),icrc7_default_take_value:e.Func([],[e.Opt(e.Nat)],["query"]),icrc7_description:e.Func([],[e.Opt(e.Text)],["query"]),icrc7_logo:e.Func([],[e.Opt(e.Text)],["query"]),icrc7_max_memo_size:e.Func([],[e.Opt(e.Nat)],["query"]),icrc7_max_query_batch_size:e.Func([],[e.Opt(e.Nat)],["query"]),icrc7_max_take_value:e.Func([],[e.Opt(e.Nat)],["query"]),icrc7_max_update_batch_size:e.Func([],[e.Opt(e.Nat)],["query"]),icrc7_name:e.Func([],[e.Text],["query"]),icrc7_owner_of:e.Func([e.Vec(e.Nat)],[e.Vec(e.Opt(r))],["query"]),icrc7_permitted_drift:e.Func([],[e.Opt(e.Nat)],["query"]),icrc7_supply_cap:e.Func([],[e.Opt(e.Nat)],["query"]),icrc7_symbol:e.Func([],[e.Text],["query"]),icrc7_token_metadata:e.Func([e.Vec(e.Nat)],[e.Vec(e.Opt(e.Vec(e.Tuple(e.Text,t))))],["query"]),icrc7_tokens:e.Func([e.Opt(e.Nat),e.Opt(e.Nat)],[e.Vec(e.Nat)],["query"]),icrc7_tokens_of:e.Func([r,e.Opt(e.Nat),e.Opt(e.Nat)],[e.Vec(e.Nat)],["query"]),icrc7_total_supply:e.Func([],[e.Nat],["query"]),icrc7_transfer:e.Func([e.Vec(o)],[e.Vec(e.Opt(i))],[]),icrc7_tx_window:e.Func([],[e.Opt(e.Nat)],["query"])})};var Fe=class e extends at{static create(t){let{service:c,certifiedService:r,canisterId:o}=nt({options:t,idlFactory:He,certifiedIdlFactory:$e});return new e(o,c,r)}collectionMetadata=t=>this.caller(t).icrc7_collection_metadata()};var We=(n=>(n.SYMBOL="icrc1:symbol",n.NAME="icrc1:name",n.DECIMALS="icrc1:decimals",n.FEE="icrc1:fee",n.LOGO="icrc1:logo",n))(We||{});import{bigEndianCrc32 as ot,encodeBase32 as st,hexStringToUint8Array as it,isNullish as Xe,nonNullish as q,notEmptyString as pt,uint8ArrayToHexString as lt}from"@dfinity/utils";import{Principal as Ze}from"@icp-sdk/core/principal";var dt=64,ir=({owner:e,subaccount:t})=>{if(Xe(t))return e.toText();let r=(o=>o.replace(/^0+/,""))(lt(Uint8Array.from(t)));return r.length===0?e.toText():`${e.toText()}-${Ye({owner:e,subaccount:t})}.${r}`},Ye=({owner:e,subaccount:t})=>{let c=ot(Uint8Array.from([...e.toUint8Array(),...t]));return st(c)},pr=e=>{let[t,c,...r]=e.split(".");if(!pt(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(Xe(c))return{owner:Ze.fromText(e)};let[o,...n]=t.split("-").reverse(),i=n.reverse().join("-"),a={owner:Ze.fromText(i),subaccount:it(c.padStart(dt,"0"))};if(Ye(a)!==o)throw new Error("Invalid account. Invalid checksum.");return a},lr=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=>q(r.symbol)&&q(r.name)&&q(r.fee)&&q(r.decimals))(t))return t};import{isNullish as _t,nonNullish as ut}from"@dfinity/utils";var ur=e=>{let t=/^([a-zA-Z]+):([A-Za-z0-9:\-.]+).*?(?:[?&](?:amount|value)=(\d+(?:\.\d+)?))?$/,c=e.match(t);if(_t(c))return;let[r,o,n,i]=c;return{token:o,identifier:n,...ut(i)&&!isNaN(parseFloat(i))&&{amount:parseFloat(i)}}};export{S as ConsentMessageError,Re as ConsentMessageUnavailableError,C as GenericError,be as IcrcIndexCanister,Ve as IcrcIndexNgCanister,Ae as IcrcLedgerCanister,We as IcrcMetadataResponseEntries,Fe as IcrcNftLedgerCanister,v as IcrcTransferError,P as IndexError,ye as IndexPrincipalNotSetError,xe as InsufficientPaymentError,Te as UnsupportedCanisterCallError,pr as decodeIcrcAccount,ur as decodePayment,ir as encodeIcrcAccount,Nt as fromCandidAccount,we as mapIcrc106GetIndexPrincipalError,Ee as mapIcrc21ConsentMessageError,lr as mapTokenMetadata,ve as toApproveArgs,ke as toCandidAccount,Se as toIcrc21ConsentMessageArgs,he as toTransferArg,Pe as toTransferFromArgs};
1
+ import{fromNullable as Ze,nonNullish as Xe,toNullable as Ye}from"@dfinity/utils";var _t=({owner:e,subaccount:t})=>{let c=Ze(t);return{owner:e,...Xe(c)?{subaccount:c}:{}}},ke=({owner:e,subaccount:t})=>({owner:e,subaccount:Ye(t)});import{isNullish as je,toNullable as m}from"@dfinity/utils";var he=({from_subaccount:e,fee:t,created_at_time:c,memo:r,...i})=>({...i,fee:m(t),memo:m(r),from_subaccount:m(e),created_at_time:m(c)}),Fe=({spender_subaccount:e,fee:t,created_at_time:c,memo:r,...i})=>({...i,fee:m(t),memo:m(r),spender_subaccount:m(e),created_at_time:m(c)}),Pe=({fee:e,created_at_time:t,memo:c,from_subaccount:r,expected_allowance:i,expires_at:n,...d})=>({...d,fee:m(e),memo:m(c),from_subaccount:m(r),created_at_time:m(t),expected_allowance:m(i),expires_at:m(n)}),ve=({userPreferences:{metadata:{utcOffsetMinutes:e,language:t},deriveSpec:c},...r})=>({...r,user_preferences:{metadata:{language:t,utc_offset_minutes:m(e)},device_spec:je(c)?m():m("GenericDisplay"in c?{GenericDisplay:null}:{FieldsDisplay:null})}});var P=class extends Error{};var v=class extends Error{errorType;constructor({msg:t,errorType:c}){super(t),this.errorType=c}},w=class extends Error{constructor(c,r){super();this.message=c;this.error_code=r}},G=class extends Error{},xe=class extends G{},Te=class extends G{},Re=class extends G{},Ge=e=>"GenericError"in e?new w(e.GenericError.description,e.GenericError.error_code):"InsufficientPayment"in e?new xe(e.InsufficientPayment.description):"UnsupportedCanisterCall"in e?new Te(e.UnsupportedCanisterCall.description):"ConsentMessageUnavailable"in e?new Re(e.ConsentMessageUnavailable.description):new G(`Unknown error type ${JSON.stringify(e)}`),ye=class extends Error{},Se=e=>"IndexPrincipalNotSet"in e?new ye("Index principal is not set for this ledger canister."):new w(e.GenericError.description,e.GenericError.error_code);import{createServices as Ie}from"@dfinity/utils";var Ee=({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)}),i=e.Variant({Upgrade:c,Init:r}),n=e.Nat,d=e.Vec(e.Nat8),a=e.Record({owner:e.Principal,subaccount:e.Opt(d)}),g=e.Record({max_results:e.Nat,start:e.Opt(n),account:a}),p=e.Nat,f=e.Record({fee:e.Opt(e.Nat),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:p,spender:e.Opt(a)}),N=e.Record({to:a,fee:e.Opt(e.Nat),memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:p}),x=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}),s=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)}),u=e.Record({burn:e.Opt(f),kind:e.Text,mint:e.Opt(N),approve:e.Opt(x),timestamp:e.Nat64,transfer:e.Opt(s)}),_=e.Record({id:n,transaction:u}),y=e.Record({balance:p,transactions:e.Vec(_),oldest_tx_id:e.Opt(n)}),T=e.Record({message:e.Text}),V=e.Variant({Ok:y,Err:T}),b=e.Record({start:e.Nat,length:e.Nat}),A=e.Vec(e.Tuple(e.Text,t));t.fill(e.Variant({Int:e.Int,Map:A,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(t)}));let k=t,O=e.Record({blocks:e.Vec(k),chain_length:e.Nat64}),R=e.Record({ranges:e.Vec(e.Tuple(a,e.Vec(e.Tuple(n,n))))}),o=e.Record({owner:e.Principal,start:e.Opt(d)}),h=e.Record({num_blocks_synced:n});return e.Service({get_account_transactions:e.Func([g],[V],[]),get_blocks:e.Func([b],[O],[]),get_fee_collectors_ranges:e.Func([],[R],[]),icrc1_balance_of:e.Func([a],[p],[]),ledger_id:e.Func([],[e.Principal],[]),list_subaccounts:e.Func([o],[e.Vec(d)],[]),status:e.Func([],[h],["query"])})};var we=({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)}),i=e.Variant({Upgrade:c,Init:r}),n=e.Nat,d=e.Vec(e.Nat8),a=e.Record({owner:e.Principal,subaccount:e.Opt(d)}),g=e.Record({max_results:e.Nat,start:e.Opt(n),account:a}),p=e.Nat,f=e.Record({fee:e.Opt(e.Nat),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:p,spender:e.Opt(a)}),N=e.Record({to:a,fee:e.Opt(e.Nat),memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:p}),x=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}),s=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)}),u=e.Record({burn:e.Opt(f),kind:e.Text,mint:e.Opt(N),approve:e.Opt(x),timestamp:e.Nat64,transfer:e.Opt(s)}),_=e.Record({id:n,transaction:u}),y=e.Record({balance:p,transactions:e.Vec(_),oldest_tx_id:e.Opt(n)}),T=e.Record({message:e.Text}),V=e.Variant({Ok:y,Err:T}),b=e.Record({start:e.Nat,length:e.Nat}),A=e.Vec(e.Tuple(e.Text,t));t.fill(e.Variant({Int:e.Int,Map:A,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(t)}));let k=t,O=e.Record({blocks:e.Vec(k),chain_length:e.Nat64}),R=e.Record({ranges:e.Vec(e.Tuple(a,e.Vec(e.Tuple(n,n))))}),o=e.Record({owner:e.Principal,start:e.Opt(d)}),h=e.Record({num_blocks_synced:n});return e.Service({get_account_transactions:e.Func([g],[V],["query"]),get_blocks:e.Func([b],[O],["query"]),get_fee_collectors_ranges:e.Func([],[R],["query"]),icrc1_balance_of:e.Func([a],[p],["query"]),ledger_id:e.Func([],[e.Principal],["query"]),list_subaccounts:e.Func([o],[e.Vec(d)],["query"]),status:e.Func([],[h],["query"])})};import{Canister as Je,toNullable as Ke}from"@dfinity/utils";var B=class extends Je{balance=t=>this.caller({certified:t.certified}).icrc1_balance_of({owner:t.owner,subaccount:Ke(t.subaccount)})};import{toNullable as Be}from"@dfinity/utils";var C=({account:e,max_results:t,start:c})=>({account:ke(e),max_results:t,start:Be(c)}),Ce=({owner:e,start:t})=>({owner:e,start:Be(t)});var Ve=class e extends B{static create(t){let{service:c,certifiedService:r,canisterId:i}=Ie({options:t,idlFactory:we,certifiedIdlFactory:Ee});return new e(i,c,r)}getTransactions=async({certified:t,...c})=>{let r=await this.caller({certified:t}).get_account_transactions(C(c));if("Err"in r)throw new P(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(Ce(c))};import{Canister as Le,createServices as De}from"@dfinity/utils";var Me=({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))}),i=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}),g=e.Record({to:r,fee:e.Opt(e.Nat),from:r,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,spender:e.Opt(r)}),p=e.Record({burn:e.Opt(n),kind:e.Text,mint:e.Opt(d),approve:e.Opt(a),timestamp:e.Nat64,transfer:e.Opt(g)}),f=e.Record({id:c,transaction:p}),N=e.Record({transactions:e.Vec(f),oldest_tx_id:e.Opt(c)}),x=e.Record({message:e.Text}),s=e.Variant({Ok:N,Err:x}),u=e.Vec(e.Nat8),_=e.Record({owner:e.Principal,start:e.Opt(u)});return e.Service({get_account_transactions:e.Func([i],[s],[]),ledger_id:e.Func([],[e.Principal],[]),list_subaccounts:e.Func([_],[e.Vec(u)],[])})};var qe=({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))}),i=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}),g=e.Record({to:r,fee:e.Opt(e.Nat),from:r,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,spender:e.Opt(r)}),p=e.Record({burn:e.Opt(n),kind:e.Text,mint:e.Opt(d),approve:e.Opt(a),timestamp:e.Nat64,transfer:e.Opt(g)}),f=e.Record({id:c,transaction:p}),N=e.Record({transactions:e.Vec(f),oldest_tx_id:e.Opt(c)}),x=e.Record({message:e.Text}),s=e.Variant({Ok:N,Err:x}),u=e.Vec(e.Nat8),_=e.Record({owner:e.Principal,start:e.Opt(u)});return e.Service({get_account_transactions:e.Func([i],[s],[]),ledger_id:e.Func([],[e.Principal],["query"]),list_subaccounts:e.Func([_],[e.Vec(u)],["query"])})};var be=class e extends Le{static create(t){let{service:c,certifiedService:r,canisterId:i}=De({options:t,idlFactory:qe,certifiedIdlFactory:Me});return new e(i,c,r)}getTransactions=async t=>{let c=await this.caller({certified:!0}).get_account_transactions(C(t));if("Err"in c)throw new P(c.Err.message);return c.Ok};ledgerId=t=>{let{ledger_id:c}=this.caller(t);return c()}};import{Canister as et,createServices as tt,toNullable as rt}from"@dfinity/utils";var Ue=({IDL:e})=>{let t=e.Rec(),c=e.Rec(),r=e.Rec(),i=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)}),g=e.Variant({SetTo:a,Unset:e.Null}),p=e.Record({icrc2:e.Bool}),f=e.Record({change_archive_options:e.Opt(i),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(g),max_memo_length:e.Opt(e.Nat16),index_principal:e.Opt(e.Principal),token_name:e.Opt(e.Text),feature_flags:e.Opt(p)}),N=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)}),x=e.Variant({Upgrade:e.Opt(f),Init:N}),s=e.Nat,u=e.Record({block_range_end:s,canister_id:e.Principal,block_range_start:s}),_=e.Record({start:s,length:e.Nat}),y=e.Vec(e.Tuple(e.Text,r));r.fill(e.Variant({Int:e.Int,Map:y,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(r)}));let T=r,V=e.Record({blocks:e.Vec(T)}),b=e.Func([_],[V],[]),A=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),first_index:s,blocks:e.Vec(T),chain_length:e.Nat64,archived_blocks:e.Vec(e.Record({callback:b,start:s,length:e.Nat}))}),k=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),hash_tree:e.Vec(e.Nat8)}),O=e.Nat,R=e.Record({start:O,length:e.Nat}),o=e.Nat64,h=e.Record({fee:e.Opt(e.Nat),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,spender:e.Opt(a)}),q=e.Record({to:a,fee:e.Opt(e.Nat),memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat}),U=e.Record({fee:e.Opt(e.Nat),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(o),spender:a}),z=e.Record({to:a,fee:e.Opt(e.Nat),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,spender:e.Opt(a)}),S=e.Record({burn:e.Opt(h),kind:e.Text,mint:e.Opt(q),approve:e.Opt(U),timestamp:o,transfer:e.Opt(z)}),Q=e.Record({transactions:e.Vec(S)}),$=e.Func([R],[Q],[]),H=e.Record({first_index:O,log_length:e.Nat,transactions:e.Vec(S),archived_transactions:e.Vec(e.Record({callback:$,start:O,length:e.Nat}))}),W=e.Record({take:e.Opt(e.Nat),prev_spender:e.Opt(a),from_account:e.Opt(a)}),Z=e.Record({from_account:a,to_spender:a,allowance:e.Nat,expires_at:e.Opt(e.Nat64)}),X=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),AccessDenied:e.Record({reason:e.Text})}),Y=e.Variant({Ok:e.Vec(Z),Err:X}),j=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),IndexPrincipalNotSet:e.Null}),J=e.Variant({Ok:e.Principal,Err:j}),l=e.Nat,K=e.Record({url:e.Text,name:e.Text}),I=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(o),amount:l}),L=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:s}),BadFee:e.Record({expected_fee:l}),CreatedInFuture:e.Record({ledger_time:o}),TooOld:e.Null,InsufficientFunds:e.Record({balance:l})}),D=e.Variant({Ok:s,Err:L}),E=e.Record({utc_offset_minutes:e.Opt(e.Int16),language:e.Text}),ee=e.Record({metadata:E,device_spec:e.Opt(e.Variant({GenericDisplay:e.Null,FieldsDisplay:e.Null}))}),te=e.Record({arg:e.Vec(e.Nat8),method:e.Text,user_preferences:ee}),re=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})}),ce=e.Record({fields:e.Vec(e.Tuple(e.Text,re)),intent:e.Text}),ae=e.Variant({FieldsDisplayMessage:ce,GenericDisplayMessage:e.Text}),ne=e.Record({metadata:E,consent_message:ae}),F=e.Record({description:e.Text}),oe=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),InsufficientPayment:F,UnsupportedCanisterCall:F,ConsentMessageUnavailable:F}),se=e.Variant({Ok:ne,Err:oe}),ie=e.Record({account:a,spender:a}),pe=e.Record({allowance:e.Nat,expires_at:e.Opt(o)}),le=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(o),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(o),spender:a}),de=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,Duplicate:e.Record({duplicate_of:s}),BadFee:e.Record({expected_fee:e.Nat}),AllowanceChanged:e.Record({current_allowance:e.Nat}),CreatedInFuture:e.Record({ledger_time:o}),TooOld:e.Null,Expired:e.Record({ledger_time:o}),InsufficientFunds:e.Record({balance:e.Nat})}),_e=e.Variant({Ok:s,Err:de}),me=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(o),amount:l}),ue=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:s}),BadFee:e.Record({expected_fee:l}),CreatedInFuture:e.Record({ledger_time:o}),TooOld:e.Null,InsufficientFunds:e.Record({balance:l})}),ge=e.Variant({Ok:s,Err:ue}),fe=e.Record({from:e.Opt(e.Principal)}),Ne=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(_),callback:e.Func([e.Vec(_)],[t],["query"])}))}));let Oe=e.Record({certificate:e.Vec(e.Nat8),hash_tree:e.Vec(e.Nat8)});return e.Service({archives:e.Func([],[e.Vec(u)],[]),get_blocks:e.Func([_],[A],[]),get_data_certificate:e.Func([],[k],[]),get_transactions:e.Func([R],[H],[]),icrc103_get_allowances:e.Func([W],[Y],[]),icrc106_get_index_principal:e.Func([],[J],[]),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(K)],[]),icrc1_symbol:e.Func([],[e.Text],[]),icrc1_total_supply:e.Func([],[l],[]),icrc1_transfer:e.Func([I],[D],[]),icrc21_canister_call_consent_message:e.Func([te],[se],[]),icrc2_allowance:e.Func([ie],[pe],[]),icrc2_approve:e.Func([le],[_e],[]),icrc2_transfer_from:e.Func([me],[ge],[]),icrc3_get_archives:e.Func([fe],[Ne],[]),icrc3_get_blocks:e.Func([e.Vec(_)],[t],[]),icrc3_get_tip_certificate:e.Func([],[e.Opt(Oe)],[]),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 ze=({IDL:e})=>{let t=e.Rec(),c=e.Rec(),r=e.Rec(),i=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)}),g=e.Variant({SetTo:a,Unset:e.Null}),p=e.Record({icrc2:e.Bool}),f=e.Record({change_archive_options:e.Opt(i),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(g),max_memo_length:e.Opt(e.Nat16),index_principal:e.Opt(e.Principal),token_name:e.Opt(e.Text),feature_flags:e.Opt(p)}),N=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)}),x=e.Variant({Upgrade:e.Opt(f),Init:N}),s=e.Nat,u=e.Record({block_range_end:s,canister_id:e.Principal,block_range_start:s}),_=e.Record({start:s,length:e.Nat}),y=e.Vec(e.Tuple(e.Text,r));r.fill(e.Variant({Int:e.Int,Map:y,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(r)}));let T=r,V=e.Record({blocks:e.Vec(T)}),b=e.Func([_],[V],["query"]),A=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),first_index:s,blocks:e.Vec(T),chain_length:e.Nat64,archived_blocks:e.Vec(e.Record({callback:b,start:s,length:e.Nat}))}),k=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),hash_tree:e.Vec(e.Nat8)}),O=e.Nat,R=e.Record({start:O,length:e.Nat}),o=e.Nat64,h=e.Record({fee:e.Opt(e.Nat),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,spender:e.Opt(a)}),q=e.Record({to:a,fee:e.Opt(e.Nat),memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat}),U=e.Record({fee:e.Opt(e.Nat),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(o),spender:a}),z=e.Record({to:a,fee:e.Opt(e.Nat),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,spender:e.Opt(a)}),S=e.Record({burn:e.Opt(h),kind:e.Text,mint:e.Opt(q),approve:e.Opt(U),timestamp:o,transfer:e.Opt(z)}),Q=e.Record({transactions:e.Vec(S)}),$=e.Func([R],[Q],["query"]),H=e.Record({first_index:O,log_length:e.Nat,transactions:e.Vec(S),archived_transactions:e.Vec(e.Record({callback:$,start:O,length:e.Nat}))}),W=e.Record({take:e.Opt(e.Nat),prev_spender:e.Opt(a),from_account:e.Opt(a)}),Z=e.Record({from_account:a,to_spender:a,allowance:e.Nat,expires_at:e.Opt(e.Nat64)}),X=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),AccessDenied:e.Record({reason:e.Text})}),Y=e.Variant({Ok:e.Vec(Z),Err:X}),j=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),IndexPrincipalNotSet:e.Null}),J=e.Variant({Ok:e.Principal,Err:j}),l=e.Nat,K=e.Record({url:e.Text,name:e.Text}),I=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(o),amount:l}),L=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:s}),BadFee:e.Record({expected_fee:l}),CreatedInFuture:e.Record({ledger_time:o}),TooOld:e.Null,InsufficientFunds:e.Record({balance:l})}),D=e.Variant({Ok:s,Err:L}),E=e.Record({utc_offset_minutes:e.Opt(e.Int16),language:e.Text}),ee=e.Record({metadata:E,device_spec:e.Opt(e.Variant({GenericDisplay:e.Null,FieldsDisplay:e.Null}))}),te=e.Record({arg:e.Vec(e.Nat8),method:e.Text,user_preferences:ee}),re=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})}),ce=e.Record({fields:e.Vec(e.Tuple(e.Text,re)),intent:e.Text}),ae=e.Variant({FieldsDisplayMessage:ce,GenericDisplayMessage:e.Text}),ne=e.Record({metadata:E,consent_message:ae}),F=e.Record({description:e.Text}),oe=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),InsufficientPayment:F,UnsupportedCanisterCall:F,ConsentMessageUnavailable:F}),se=e.Variant({Ok:ne,Err:oe}),ie=e.Record({account:a,spender:a}),pe=e.Record({allowance:e.Nat,expires_at:e.Opt(o)}),le=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(o),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(o),spender:a}),de=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,Duplicate:e.Record({duplicate_of:s}),BadFee:e.Record({expected_fee:e.Nat}),AllowanceChanged:e.Record({current_allowance:e.Nat}),CreatedInFuture:e.Record({ledger_time:o}),TooOld:e.Null,Expired:e.Record({ledger_time:o}),InsufficientFunds:e.Record({balance:e.Nat})}),_e=e.Variant({Ok:s,Err:de}),me=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(o),amount:l}),ue=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:s}),BadFee:e.Record({expected_fee:l}),CreatedInFuture:e.Record({ledger_time:o}),TooOld:e.Null,InsufficientFunds:e.Record({balance:l})}),ge=e.Variant({Ok:s,Err:ue}),fe=e.Record({from:e.Opt(e.Principal)}),Ne=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(_),callback:e.Func([e.Vec(_)],[t],["query"])}))}));let Oe=e.Record({certificate:e.Vec(e.Nat8),hash_tree:e.Vec(e.Nat8)});return e.Service({archives:e.Func([],[e.Vec(u)],["query"]),get_blocks:e.Func([_],[A],["query"]),get_data_certificate:e.Func([],[k],["query"]),get_transactions:e.Func([R],[H],["query"]),icrc103_get_allowances:e.Func([W],[Y],["query"]),icrc106_get_index_principal:e.Func([],[J],["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(K)],["query"]),icrc1_symbol:e.Func([],[e.Text],["query"]),icrc1_total_supply:e.Func([],[l],["query"]),icrc1_transfer:e.Func([I],[D],[]),icrc21_canister_call_consent_message:e.Func([te],[se],[]),icrc2_allowance:e.Func([ie],[pe],["query"]),icrc2_approve:e.Func([le],[_e],[]),icrc2_transfer_from:e.Func([me],[ge],[]),icrc3_get_archives:e.Func([fe],[Ne],["query"]),icrc3_get_blocks:e.Func([e.Vec(_)],[t],["query"]),icrc3_get_tip_certificate:e.Func([],[e.Opt(Oe)],["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 Ae=class e extends et{static create(t){let{service:c,certifiedService:r,canisterId:i}=tt({options:t,idlFactory:ze,certifiedIdlFactory:Ue});return new e(i,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:rt(t.subaccount)});transfer=async t=>{let c=await this.caller({certified:!0}).icrc1_transfer(he(t));if("Err"in c)throw new v({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(Fe(t));if("Err"in c)throw new v({errorType:c.Err,msg:"Failed to transfer from"});return c.Ok};approve=async t=>{let c=await this.caller({certified:!0}).icrc2_approve(Pe(t));if("Err"in c)throw new v({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(ve(t));if("Err"in r)throw Ge(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 Se(r.Err);return r.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 Qe=(n=>(n.SYMBOL="icrc1:symbol",n.NAME="icrc1:name",n.DECIMALS="icrc1:decimals",n.FEE="icrc1:fee",n.LOGO="icrc1:logo",n))(Qe||{});import{bigEndianCrc32 as ct,encodeBase32 as at,hexStringToUint8Array as nt,isNullish as He,nonNullish as M,notEmptyString as ot,uint8ArrayToHexString as st}from"@dfinity/utils";import{Principal as $e}from"@icp-sdk/core/principal";var it=64,Lt=({owner:e,subaccount:t})=>{if(He(t))return e.toText();let r=(i=>i.replace(/^0+/,""))(st(Uint8Array.from(t)));return r.length===0?e.toText():`${e.toText()}-${We({owner:e,subaccount:t})}.${r}`},We=({owner:e,subaccount:t})=>{let c=ct(Uint8Array.from([...e.toUint8Array(),...t]));return at(c)},Dt=e=>{let[t,c,...r]=e.split(".");if(!ot(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(He(c))return{owner:$e.fromText(e)};let[i,...n]=t.split("-").reverse(),d=n.reverse().join("-"),a={owner:$e.fromText(d),subaccount:nt(c.padStart(it,"0"))};if(We(a)!==i)throw new Error("Invalid account. Invalid checksum.");return a},er=e=>{let t=e.reduce((r,[i,n])=>{switch(i){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=>M(r.symbol)&&M(r.name)&&M(r.fee)&&M(r.decimals))(t))return t};import{isNullish as pt,nonNullish as lt}from"@dfinity/utils";var cr=e=>{let t=/^([a-zA-Z]+):([A-Za-z0-9:\-.]+).*?(?:[?&](?:amount|value)=(\d+(?:\.\d+)?))?$/,c=e.match(t);if(pt(c))return;let[r,i,n,d]=c;return{token:i,identifier:n,...lt(d)&&!isNaN(parseFloat(d))&&{amount:parseFloat(d)}}};export{G as ConsentMessageError,Re as ConsentMessageUnavailableError,w as GenericError,be as IcrcIndexCanister,Ve as IcrcIndexNgCanister,Ae as IcrcLedgerCanister,Qe as IcrcMetadataResponseEntries,v as IcrcTransferError,P as IndexError,ye as IndexPrincipalNotSetError,xe as InsufficientPaymentError,Te as UnsupportedCanisterCallError,Dt as decodeIcrcAccount,cr as decodePayment,Lt as encodeIcrcAccount,_t as fromCandidAccount,Se as mapIcrc106GetIndexPrincipalError,Ge as mapIcrc21ConsentMessageError,er as mapTokenMetadata,Pe as toApproveArgs,ke as toCandidAccount,ve as toIcrc21ConsentMessageArgs,he as toTransferArg,Fe as toTransferFromArgs};
2
2
  //# sourceMappingURL=index.js.map