@dfinity/ledger-icrc 6.0.1-next-2025-11-26 → 6.0.1-next-2025-12-03
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/candid/icrc_index-ng.certified.idl.js +6 -0
- package/dist/candid/icrc_index-ng.d.ts +6 -0
- package/dist/candid/icrc_index-ng.did +8 -1
- package/dist/candid/icrc_index-ng.idl.js +6 -0
- package/dist/candid/icrc_ledger.certified.idl.js +6 -0
- package/dist/candid/icrc_ledger.d.ts +6 -0
- package/dist/candid/icrc_ledger.did +8 -1
- package/dist/candid/icrc_ledger.idl.js +6 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +3 -3
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as topLevelCreateRequire } from 'module';
|
|
2
2
|
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
-
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};
|
|
3
|
+
import{fromNullable as Je,nonNullish as Ke,toNullable as Ie}from"@dfinity/utils";var ft=({owner:e,subaccount:t})=>{let c=Je(t);return{owner:e,...Ke(c)?{subaccount:c}:{}}},he=({owner:e,subaccount:t})=>({owner:e,subaccount:Ie(t)});import{isNullish as Le,toNullable as u}from"@dfinity/utils";var Pe=({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)}),ve=({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)}),Se=({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)}),Ee=({userPreferences:{metadata:{utcOffsetMinutes:e,language:t},deriveSpec:c},...r})=>({...r,user_preferences:{metadata:{language:t,utc_offset_minutes:u(e)},device_spec:Le(c)?u():u("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}},B=class extends Error{constructor(c,r){super();this.message=c;this.error_code=r}},E=class extends Error{},Te=class extends E{},Re=class extends E{},ye=class extends E{},we=e=>"GenericError"in e?new B(e.GenericError.description,e.GenericError.error_code):"InsufficientPayment"in e?new Te(e.InsufficientPayment.description):"UnsupportedCanisterCall"in e?new Re(e.UnsupportedCanisterCall.description):"ConsentMessageUnavailable"in e?new ye(e.ConsentMessageUnavailable.description):new E(`Unknown error type ${JSON.stringify(e)}`),Ve=class extends Error{},Ge=e=>"IndexPrincipalNotSet"in e?new Ve("Index principal is not set for this ledger canister."):new B(e.GenericError.description,e.GenericError.error_code);import{createServices as tt}from"@dfinity/utils";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({ts:e.Opt(e.Nat64),fee_collector:e.Opt(a),caller:e.Opt(e.Principal)}),m=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)}),_=e.Record({burn:e.Opt(f),kind:e.Text,mint:e.Opt(g),approve:e.Opt(x),fee_collector:e.Opt(p),timestamp:e.Nat64,transfer:e.Opt(m)}),y=e.Record({id:n,transaction:_}),T=e.Record({balance:l,transactions:e.Vec(y),oldest_tx_id:e.Opt(n)}),V=e.Record({message:e.Text}),b=e.Variant({Ok:T,Err:V}),A=e.Record({start:e.Nat,length:e.Nat}),F=e.Vec(e.Tuple(e.Text,t));t.fill(e.Variant({Int:e.Int,Map:F,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(t)}));let O=t,R=e.Record({blocks:e.Vec(O),chain_length:e.Nat64}),s=e.Record({ranges:e.Vec(e.Tuple(a,e.Vec(e.Tuple(n,n))))}),k=e.Record({owner:e.Principal,start:e.Opt(i)}),h=e.Record({num_blocks_synced:n});return e.Service({get_account_transactions:e.Func([N],[b],[]),get_blocks:e.Func([A],[R],[]),get_fee_collectors_ranges:e.Func([],[s],[]),icrc1_balance_of:e.Func([a],[l],[]),ledger_id:e.Func([],[e.Principal],[]),list_subaccounts:e.Func([k],[e.Vec(i)],[]),status:e.Func([],[h],["query"])})};var Be=({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({ts:e.Opt(e.Nat64),fee_collector:e.Opt(a),caller:e.Opt(e.Principal)}),m=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)}),_=e.Record({burn:e.Opt(f),kind:e.Text,mint:e.Opt(g),approve:e.Opt(x),fee_collector:e.Opt(p),timestamp:e.Nat64,transfer:e.Opt(m)}),y=e.Record({id:n,transaction:_}),T=e.Record({balance:l,transactions:e.Vec(y),oldest_tx_id:e.Opt(n)}),V=e.Record({message:e.Text}),b=e.Variant({Ok:T,Err:V}),A=e.Record({start:e.Nat,length:e.Nat}),F=e.Vec(e.Tuple(e.Text,t));t.fill(e.Variant({Int:e.Int,Map:F,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(t)}));let O=t,R=e.Record({blocks:e.Vec(O),chain_length:e.Nat64}),s=e.Record({ranges:e.Vec(e.Tuple(a,e.Vec(e.Tuple(n,n))))}),k=e.Record({owner:e.Principal,start:e.Opt(i)}),h=e.Record({num_blocks_synced:n});return e.Service({get_account_transactions:e.Func([N],[b],["query"]),get_blocks:e.Func([A],[R],["query"]),get_fee_collectors_ranges:e.Func([],[s],["query"]),icrc1_balance_of:e.Func([a],[l],["query"]),ledger_id:e.Func([],[e.Principal],["query"]),list_subaccounts:e.Func([k],[e.Vec(i)],["query"]),status:e.Func([],[h],["query"])})};import{Canister as De,toNullable as et}from"@dfinity/utils";var w=class extends De{balance=t=>this.caller({certified:t.certified}).icrc1_balance_of({owner:t.owner,subaccount:et(t.subaccount)})};import{toNullable as qe}from"@dfinity/utils";var q=({account:e,max_results:t,start:c})=>({account:he(e),max_results:t,start:qe(c)}),Me=({owner:e,start:t})=>({owner:e,start:qe(t)});var be=class e extends w{static create(t){let{service:c,certifiedService:r,canisterId:o}=tt({options:t,idlFactory:Be,certifiedIdlFactory:Ce});return new e(o,c,r)}getTransactions=async({certified:t,...c})=>{let r=await this.caller({certified:t}).get_account_transactions(q(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(Me(c))};import{Canister as rt,createServices as ct}from"@dfinity/utils";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],[]),list_subaccounts:e.Func([_],[e.Vec(m)],[])})};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)}),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 Ae=class e extends rt{static create(t){let{service:c,certifiedService:r,canisterId:o}=ct({options:t,idlFactory:ze,certifiedIdlFactory:Ue});return new e(o,c,r)}getTransactions=async t=>{let c=await this.caller({certified:!0}).get_account_transactions(q(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()}};import{createServices as at}from"@dfinity/utils";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],[]),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)}),h=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({ts:e.Opt(e.Nat64),fee_collector:e.Opt(a),caller:e.Opt(e.Principal)}),Q=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)}),G=e.Record({burn:e.Opt(k),kind:e.Text,mint:e.Opt(h),approve:e.Opt(U),fee_collector:e.Opt(z),timestamp:s,transfer:e.Opt(Q)}),$=e.Record({transactions:e.Vec(G)}),H=e.Func([R],[$],[]),W=e.Record({first_index:O,log_length:e.Nat,transactions:e.Vec(G),archived_transactions:e.Vec(e.Record({callback:H,start:O,length:e.Nat}))}),Z=e.Record({take:e.Opt(e.Nat),prev_spender:e.Opt(a),from_account:e.Opt(a)}),X=e.Record({from_account:a,to_spender:a,allowance:e.Nat,expires_at:e.Opt(e.Nat64)}),Y=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),AccessDenied:e.Record({reason:e.Text})}),j=e.Variant({Ok:e.Vec(X),Err:Y}),J=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),IndexPrincipalNotSet:e.Null}),K=e.Variant({Ok:e.Principal,Err:J}),d=e.Nat,I=e.Record({url:e.Text,name:e.Text}),L=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}),D=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})}),ee=e.Variant({Ok:p,Err:D}),C=e.Record({utc_offset_minutes:e.Opt(e.Int16),language:e.Text}),te=e.Record({metadata:C,device_spec:e.Opt(e.Variant({GenericDisplay:e.Null,FieldsDisplay:e.Null}))}),re=e.Record({arg:e.Vec(e.Nat8),method:e.Text,user_preferences:te}),ce=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})}),ae=e.Record({fields:e.Vec(e.Tuple(e.Text,ce)),intent:e.Text}),ne=e.Variant({FieldsDisplayMessage:ae,GenericDisplayMessage:e.Text}),oe=e.Record({metadata:C,consent_message:ne}),P=e.Record({description:e.Text}),se=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),InsufficientPayment:P,UnsupportedCanisterCall:P,ConsentMessageUnavailable:P}),ie=e.Variant({Ok:oe,Err:se}),pe=e.Record({account:a,spender:a}),le=e.Record({allowance:e.Nat,expires_at:e.Opt(s)}),de=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}),_e=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})}),ue=e.Variant({Ok:p,Err:_e}),me=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}),Ne=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})}),fe=e.Variant({Ok:p,Err:Ne}),ge=e.Record({from:e.Opt(e.Principal)}),Oe=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 xe=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],[W],[]),icrc103_get_allowances:e.Func([Z],[j],[]),icrc106_get_index_principal:e.Func([],[K],[]),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(I)],[]),icrc1_symbol:e.Func([],[e.Text],[]),icrc1_total_supply:e.Func([],[d],[]),icrc1_transfer:e.Func([L],[ee],[]),icrc21_canister_call_consent_message:e.Func([re],[ie],[]),icrc2_allowance:e.Func([pe],[le],[]),icrc2_approve:e.Func([de],[ue],[]),icrc2_transfer_from:e.Func([me],[fe],[]),icrc3_get_archives:e.Func([ge],[Oe],[]),icrc3_get_blocks:e.Func([e.Vec(_)],[t],[]),icrc3_get_tip_certificate:e.Func([],[e.Opt(xe)],[]),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 $e=({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)}),h=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({ts:e.Opt(e.Nat64),fee_collector:e.Opt(a),caller:e.Opt(e.Principal)}),Q=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)}),G=e.Record({burn:e.Opt(k),kind:e.Text,mint:e.Opt(h),approve:e.Opt(U),fee_collector:e.Opt(z),timestamp:s,transfer:e.Opt(Q)}),$=e.Record({transactions:e.Vec(G)}),H=e.Func([R],[$],["query"]),W=e.Record({first_index:O,log_length:e.Nat,transactions:e.Vec(G),archived_transactions:e.Vec(e.Record({callback:H,start:O,length:e.Nat}))}),Z=e.Record({take:e.Opt(e.Nat),prev_spender:e.Opt(a),from_account:e.Opt(a)}),X=e.Record({from_account:a,to_spender:a,allowance:e.Nat,expires_at:e.Opt(e.Nat64)}),Y=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),AccessDenied:e.Record({reason:e.Text})}),j=e.Variant({Ok:e.Vec(X),Err:Y}),J=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),IndexPrincipalNotSet:e.Null}),K=e.Variant({Ok:e.Principal,Err:J}),d=e.Nat,I=e.Record({url:e.Text,name:e.Text}),L=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}),D=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})}),ee=e.Variant({Ok:p,Err:D}),C=e.Record({utc_offset_minutes:e.Opt(e.Int16),language:e.Text}),te=e.Record({metadata:C,device_spec:e.Opt(e.Variant({GenericDisplay:e.Null,FieldsDisplay:e.Null}))}),re=e.Record({arg:e.Vec(e.Nat8),method:e.Text,user_preferences:te}),ce=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})}),ae=e.Record({fields:e.Vec(e.Tuple(e.Text,ce)),intent:e.Text}),ne=e.Variant({FieldsDisplayMessage:ae,GenericDisplayMessage:e.Text}),oe=e.Record({metadata:C,consent_message:ne}),P=e.Record({description:e.Text}),se=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),InsufficientPayment:P,UnsupportedCanisterCall:P,ConsentMessageUnavailable:P}),ie=e.Variant({Ok:oe,Err:se}),pe=e.Record({account:a,spender:a}),le=e.Record({allowance:e.Nat,expires_at:e.Opt(s)}),de=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}),_e=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})}),ue=e.Variant({Ok:p,Err:_e}),me=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}),Ne=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})}),fe=e.Variant({Ok:p,Err:Ne}),ge=e.Record({from:e.Opt(e.Principal)}),Oe=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 xe=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],[W],["query"]),icrc103_get_allowances:e.Func([Z],[j],["query"]),icrc106_get_index_principal:e.Func([],[K],["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(I)],["query"]),icrc1_symbol:e.Func([],[e.Text],["query"]),icrc1_total_supply:e.Func([],[d],["query"]),icrc1_transfer:e.Func([L],[ee],[]),icrc21_canister_call_consent_message:e.Func([re],[ie],[]),icrc2_allowance:e.Func([pe],[le],["query"]),icrc2_approve:e.Func([de],[ue],[]),icrc2_transfer_from:e.Func([me],[fe],[]),icrc3_get_archives:e.Func([ge],[Oe],["query"]),icrc3_get_blocks:e.Func([e.Vec(_)],[t],["query"]),icrc3_get_tip_certificate:e.Func([],[e.Opt(xe)],["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 Fe=class e extends w{static create(t){let{service:c,certifiedService:r,canisterId:o}=at({options:t,idlFactory:$e,certifiedIdlFactory:Qe});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(Pe(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(ve(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(Se(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(Ee(t));if("Err"in r)throw we(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 Ge(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 nt,createServices as ot}from"@dfinity/utils";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)],[]),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 We=({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 ke=class e extends nt{static create(t){let{service:c,certifiedService:r,canisterId:o}=ot({options:t,idlFactory:We,certifiedIdlFactory:He});return new e(o,c,r)}collectionMetadata=t=>this.caller(t).icrc7_collection_metadata()};var Ze=(n=>(n.SYMBOL="icrc1:symbol",n.NAME="icrc1:name",n.DECIMALS="icrc1:decimals",n.FEE="icrc1:fee",n.LOGO="icrc1:logo",n))(Ze||{});import{bigEndianCrc32 as st,encodeBase32 as it,hexStringToUint8Array as pt,isNullish as Ye,nonNullish as M,notEmptyString as lt,uint8ArrayToHexString as dt}from"@dfinity/utils";import{Principal as Xe}from"@icp-sdk/core/principal";var _t=64,pr=({owner:e,subaccount:t})=>{if(Ye(t))return e.toText();let r=(o=>o.replace(/^0+/,""))(dt(Uint8Array.from(t)));return r.length===0?e.toText():`${e.toText()}-${je({owner:e,subaccount:t})}.${r}`},je=({owner:e,subaccount:t})=>{let c=st(Uint8Array.from([...e.toUint8Array(),...t]));return it(c)},lr=e=>{let[t,c,...r]=e.split(".");if(!lt(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(Ye(c))return{owner:Xe.fromText(e)};let[o,...n]=t.split("-").reverse(),i=n.reverse().join("-"),a={owner:Xe.fromText(i),subaccount:pt(c.padStart(_t,"0"))};if(je(a)!==o)throw new Error("Invalid account. Invalid checksum.");return a},dr=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=>M(r.symbol)&&M(r.name)&&M(r.fee)&&M(r.decimals))(t))return t};import{isNullish as ut,nonNullish as mt}from"@dfinity/utils";var mr=e=>{let t=/^([a-zA-Z]+):([A-Za-z0-9:\-.]+).*?(?:[?&](?:amount|value)=(\d+(?:\.\d+)?))?$/,c=e.match(t);if(ut(c))return;let[r,o,n,i]=c;return{token:o,identifier:n,...mt(i)&&!isNaN(parseFloat(i))&&{amount:parseFloat(i)}}};export{E as ConsentMessageError,ye as ConsentMessageUnavailableError,B as GenericError,Ae as IcrcIndexCanister,be as IcrcIndexNgCanister,Fe as IcrcLedgerCanister,Ze as IcrcMetadataResponseEntries,ke as IcrcNftLedgerCanister,S as IcrcTransferError,v as IndexError,Ve as IndexPrincipalNotSetError,Te as InsufficientPaymentError,Re as UnsupportedCanisterCallError,lr as decodeIcrcAccount,mr as decodePayment,pr as encodeIcrcAccount,ft as fromCandidAccount,Ge as mapIcrc106GetIndexPrincipalError,we as mapIcrc21ConsentMessageError,dr as mapTokenMetadata,Se as toApproveArgs,he as toCandidAccount,Ee as toIcrc21ConsentMessageArgs,Pe as toTransferArg,ve as toTransferFromArgs};
|
|
4
4
|
//# sourceMappingURL=index.mjs.map
|