@dfinity/ledger-icrc 2.5.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ import{Canister as Re,createServices as Te,toNullable as xe}from"@dfinity/utils";var _e=({IDL:e})=>{let s=e.Rec(),t=e.Rec(),c=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)}),l=e.Variant({Int:e.Int,Nat:e.Nat,Blob:e.Vec(e.Nat8),Text:e.Text}),d=e.Vec(e.Nat8),r=e.Record({owner:e.Principal,subaccount:e.Opt(d)}),V=e.Variant({SetTo:r,Unset:e.Null}),N=e.Record({icrc2:e.Bool}),y=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,l))),accounts_overflow_trim_quantity:e.Opt(e.Nat64),change_fee_collector:e.Opt(V),max_memo_length:e.Opt(e.Nat16),token_name:e.Opt(e.Text),feature_flags:e.Opt(N)}),h=e.Record({decimals:e.Opt(e.Nat8),token_symbol:e.Text,transfer_fee:e.Nat,metadata:e.Vec(e.Tuple(e.Text,l)),minting_account:r,initial_balances:e.Vec(e.Tuple(r,e.Nat)),maximum_number_of_accounts:e.Opt(e.Nat64),accounts_overflow_trim_quantity:e.Opt(e.Nat64),fee_collector_account:e.Opt(r),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),token_name:e.Text,feature_flags:e.Opt(N)}),Ne=e.Variant({Upgrade:e.Opt(y),Init:h}),o=e.Nat,b=e.Record({block_range_end:o,canister_id:e.Principal,block_range_start:o}),p=e.Record({start:o,length:e.Nat}),F=e.Vec(e.Tuple(e.Text,c));c.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(c)}));let O=c,k=e.Record({blocks:e.Vec(O)}),v=e.Func([p],[k],[]),A=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),first_index:o,blocks:e.Vec(O),chain_length:e.Nat64,archived_blocks:e.Vec(e.Record({callback:v,start:o,length:e.Nat}))}),P=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),hash_tree:e.Vec(e.Nat8)}),m=e.Nat,R=e.Record({start:m,length:e.Nat}),a=e.Nat64,C=e.Record({from:r,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(a),amount:e.Nat,spender:e.Opt(r)}),w=e.Record({to:r,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(a),amount:e.Nat}),B=e.Record({fee:e.Opt(e.Nat),from:r,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(a),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(a),spender:r}),q=e.Record({to:r,fee:e.Opt(e.Nat),from:r,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(a),amount:e.Nat,spender:e.Opt(r)}),T=e.Record({burn:e.Opt(C),kind:e.Text,mint:e.Opt(w),approve:e.Opt(B),timestamp:a,transfer:e.Opt(q)}),M=e.Record({transactions:e.Vec(T)}),E=e.Func([R],[M],[]),G=e.Record({first_index:m,log_length:e.Nat,transactions:e.Vec(T),archived_transactions:e.Vec(e.Record({callback:E,start:m,length:e.Nat}))}),n=e.Nat,U=e.Record({url:e.Text,name:e.Text}),S=e.Record({to:r,fee:e.Opt(n),memo:e.Opt(e.Vec(e.Nat8)),from_subaccount:e.Opt(d),created_at_time:e.Opt(a),amount:n}),z=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,BadBurn:e.Record({min_burn_amount:n}),Duplicate:e.Record({duplicate_of:o}),BadFee:e.Record({expected_fee:n}),CreatedInFuture:e.Record({ledger_time:a}),TooOld:e.Null,InsufficientFunds:e.Record({balance:n})}),Q=e.Variant({Ok:o,Err:z}),x=e.Record({utc_offset_minutes:e.Opt(e.Int16),language:e.Text}),J=e.Record({metadata:x,device_spec:e.Opt(e.Variant({GenericDisplay:e.Null,LineDisplay:e.Record({characters_per_line:e.Nat16,lines_per_page:e.Nat16})}))}),$=e.Record({arg:e.Vec(e.Nat8),method:e.Text,user_preferences:J}),j=e.Variant({LineDisplayMessage:e.Record({pages:e.Vec(e.Record({lines:e.Vec(e.Text)}))}),GenericDisplayMessage:e.Text}),H=e.Record({metadata:x,consent_message:j}),u=e.Record({description:e.Text}),K=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),InsufficientPayment:u,UnsupportedCanisterCall:u,ConsentMessageUnavailable:u}),W=e.Variant({Ok:H,Err:K}),X=e.Record({account:r,spender:r}),Y=e.Record({allowance:e.Nat,expires_at:e.Opt(a)}),Z=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(a),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(a),spender:r}),I=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,Duplicate:e.Record({duplicate_of:o}),BadFee:e.Record({expected_fee:e.Nat}),AllowanceChanged:e.Record({current_allowance:e.Nat}),CreatedInFuture:e.Record({ledger_time:a}),TooOld:e.Null,Expired:e.Record({ledger_time:a}),InsufficientFunds:e.Record({balance:e.Nat})}),D=e.Variant({Ok:o,Err:I}),L=e.Record({to:r,fee:e.Opt(n),spender_subaccount:e.Opt(d),from:r,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(a),amount:n}),ee=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,InsufficientAllowance:e.Record({allowance:n}),BadBurn:e.Record({min_burn_amount:n}),Duplicate:e.Record({duplicate_of:o}),BadFee:e.Record({expected_fee:n}),CreatedInFuture:e.Record({ledger_time:a}),TooOld:e.Null,InsufficientFunds:e.Record({balance:n})}),te=e.Variant({Ok:o,Err:ee}),re=e.Record({from:e.Opt(e.Principal)}),ce=e.Vec(e.Record({end:e.Nat,canister_id:e.Principal,start:e.Nat}));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)})),s.fill(e.Record({log_length:e.Nat,blocks:e.Vec(e.Record({id:e.Nat,block:t})),archived_blocks:e.Vec(e.Record({args:e.Vec(p),callback:e.Func([e.Vec(p)],[s],[])}))}));let ae=e.Record({certificate:e.Vec(e.Nat8),hash_tree:e.Vec(e.Nat8)});return e.Service({archives:e.Func([],[e.Vec(b)],[]),get_blocks:e.Func([p],[A],[]),get_data_certificate:e.Func([],[P],[]),get_transactions:e.Func([R],[G],[]),icrc10_supported_standards:e.Func([],[e.Vec(e.Record({url:e.Text,name:e.Text}))],[]),icrc1_balance_of:e.Func([r],[n],[]),icrc1_decimals:e.Func([],[e.Nat8],[]),icrc1_fee:e.Func([],[n],[]),icrc1_metadata:e.Func([],[e.Vec(e.Tuple(e.Text,l))],[]),icrc1_minting_account:e.Func([],[e.Opt(r)],[]),icrc1_name:e.Func([],[e.Text],[]),icrc1_supported_standards:e.Func([],[e.Vec(U)],[]),icrc1_symbol:e.Func([],[e.Text],[]),icrc1_total_supply:e.Func([],[n],[]),icrc1_transfer:e.Func([S],[Q],[]),icrc21_canister_call_consent_message:e.Func([$],[W],[]),icrc2_allowance:e.Func([X],[Y],[]),icrc2_approve:e.Func([Z],[D],[]),icrc2_transfer_from:e.Func([L],[te],[]),icrc3_get_archives:e.Func([re],[ce],[]),icrc3_get_blocks:e.Func([e.Vec(p)],[s],[]),icrc3_get_tip_certificate:e.Func([],[e.Opt(ae)],[]),icrc3_supported_block_types:e.Func([],[e.Vec(e.Record({url:e.Text,block_type:e.Text}))],[])})};var le=({IDL:e})=>{let s=e.Rec(),t=e.Rec(),c=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)}),l=e.Variant({Int:e.Int,Nat:e.Nat,Blob:e.Vec(e.Nat8),Text:e.Text}),d=e.Vec(e.Nat8),r=e.Record({owner:e.Principal,subaccount:e.Opt(d)}),V=e.Variant({SetTo:r,Unset:e.Null}),N=e.Record({icrc2:e.Bool}),y=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,l))),accounts_overflow_trim_quantity:e.Opt(e.Nat64),change_fee_collector:e.Opt(V),max_memo_length:e.Opt(e.Nat16),token_name:e.Opt(e.Text),feature_flags:e.Opt(N)}),h=e.Record({decimals:e.Opt(e.Nat8),token_symbol:e.Text,transfer_fee:e.Nat,metadata:e.Vec(e.Tuple(e.Text,l)),minting_account:r,initial_balances:e.Vec(e.Tuple(r,e.Nat)),maximum_number_of_accounts:e.Opt(e.Nat64),accounts_overflow_trim_quantity:e.Opt(e.Nat64),fee_collector_account:e.Opt(r),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),token_name:e.Text,feature_flags:e.Opt(N)}),Ne=e.Variant({Upgrade:e.Opt(y),Init:h}),o=e.Nat,b=e.Record({block_range_end:o,canister_id:e.Principal,block_range_start:o}),p=e.Record({start:o,length:e.Nat}),F=e.Vec(e.Tuple(e.Text,c));c.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(c)}));let O=c,k=e.Record({blocks:e.Vec(O)}),v=e.Func([p],[k],["query"]),A=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),first_index:o,blocks:e.Vec(O),chain_length:e.Nat64,archived_blocks:e.Vec(e.Record({callback:v,start:o,length:e.Nat}))}),P=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),hash_tree:e.Vec(e.Nat8)}),m=e.Nat,R=e.Record({start:m,length:e.Nat}),a=e.Nat64,C=e.Record({from:r,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(a),amount:e.Nat,spender:e.Opt(r)}),w=e.Record({to:r,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(a),amount:e.Nat}),B=e.Record({fee:e.Opt(e.Nat),from:r,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(a),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(a),spender:r}),q=e.Record({to:r,fee:e.Opt(e.Nat),from:r,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(a),amount:e.Nat,spender:e.Opt(r)}),T=e.Record({burn:e.Opt(C),kind:e.Text,mint:e.Opt(w),approve:e.Opt(B),timestamp:a,transfer:e.Opt(q)}),M=e.Record({transactions:e.Vec(T)}),E=e.Func([R],[M],["query"]),G=e.Record({first_index:m,log_length:e.Nat,transactions:e.Vec(T),archived_transactions:e.Vec(e.Record({callback:E,start:m,length:e.Nat}))}),n=e.Nat,U=e.Record({url:e.Text,name:e.Text}),S=e.Record({to:r,fee:e.Opt(n),memo:e.Opt(e.Vec(e.Nat8)),from_subaccount:e.Opt(d),created_at_time:e.Opt(a),amount:n}),z=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,BadBurn:e.Record({min_burn_amount:n}),Duplicate:e.Record({duplicate_of:o}),BadFee:e.Record({expected_fee:n}),CreatedInFuture:e.Record({ledger_time:a}),TooOld:e.Null,InsufficientFunds:e.Record({balance:n})}),Q=e.Variant({Ok:o,Err:z}),x=e.Record({utc_offset_minutes:e.Opt(e.Int16),language:e.Text}),J=e.Record({metadata:x,device_spec:e.Opt(e.Variant({GenericDisplay:e.Null,LineDisplay:e.Record({characters_per_line:e.Nat16,lines_per_page:e.Nat16})}))}),$=e.Record({arg:e.Vec(e.Nat8),method:e.Text,user_preferences:J}),j=e.Variant({LineDisplayMessage:e.Record({pages:e.Vec(e.Record({lines:e.Vec(e.Text)}))}),GenericDisplayMessage:e.Text}),H=e.Record({metadata:x,consent_message:j}),u=e.Record({description:e.Text}),K=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),InsufficientPayment:u,UnsupportedCanisterCall:u,ConsentMessageUnavailable:u}),W=e.Variant({Ok:H,Err:K}),X=e.Record({account:r,spender:r}),Y=e.Record({allowance:e.Nat,expires_at:e.Opt(a)}),Z=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(a),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(a),spender:r}),I=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,Duplicate:e.Record({duplicate_of:o}),BadFee:e.Record({expected_fee:e.Nat}),AllowanceChanged:e.Record({current_allowance:e.Nat}),CreatedInFuture:e.Record({ledger_time:a}),TooOld:e.Null,Expired:e.Record({ledger_time:a}),InsufficientFunds:e.Record({balance:e.Nat})}),D=e.Variant({Ok:o,Err:I}),L=e.Record({to:r,fee:e.Opt(n),spender_subaccount:e.Opt(d),from:r,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(a),amount:n}),ee=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,InsufficientAllowance:e.Record({allowance:n}),BadBurn:e.Record({min_burn_amount:n}),Duplicate:e.Record({duplicate_of:o}),BadFee:e.Record({expected_fee:n}),CreatedInFuture:e.Record({ledger_time:a}),TooOld:e.Null,InsufficientFunds:e.Record({balance:n})}),te=e.Variant({Ok:o,Err:ee}),re=e.Record({from:e.Opt(e.Principal)}),ce=e.Vec(e.Record({end:e.Nat,canister_id:e.Principal,start:e.Nat}));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)})),s.fill(e.Record({log_length:e.Nat,blocks:e.Vec(e.Record({id:e.Nat,block:t})),archived_blocks:e.Vec(e.Record({args:e.Vec(p),callback:e.Func([e.Vec(p)],[s],["query"])}))}));let ae=e.Record({certificate:e.Vec(e.Nat8),hash_tree:e.Vec(e.Nat8)});return e.Service({archives:e.Func([],[e.Vec(b)],["query"]),get_blocks:e.Func([p],[A],["query"]),get_data_certificate:e.Func([],[P],["query"]),get_transactions:e.Func([R],[G],["query"]),icrc10_supported_standards:e.Func([],[e.Vec(e.Record({url:e.Text,name:e.Text}))],["query"]),icrc1_balance_of:e.Func([r],[n],["query"]),icrc1_decimals:e.Func([],[e.Nat8],["query"]),icrc1_fee:e.Func([],[n],["query"]),icrc1_metadata:e.Func([],[e.Vec(e.Tuple(e.Text,l))],["query"]),icrc1_minting_account:e.Func([],[e.Opt(r)],["query"]),icrc1_name:e.Func([],[e.Text],["query"]),icrc1_supported_standards:e.Func([],[e.Vec(U)],["query"]),icrc1_symbol:e.Func([],[e.Text],["query"]),icrc1_total_supply:e.Func([],[n],["query"]),icrc1_transfer:e.Func([S],[Q],[]),icrc21_canister_call_consent_message:e.Func([$],[W],[]),icrc2_allowance:e.Func([X],[Y],["query"]),icrc2_approve:e.Func([Z],[D],[]),icrc2_transfer_from:e.Func([L],[te],[]),icrc3_get_archives:e.Func([re],[ce],["query"]),icrc3_get_blocks:e.Func([e.Vec(p)],[s],["query"]),icrc3_get_tip_certificate:e.Func([],[e.Opt(ae)],["query"]),icrc3_supported_block_types:e.Func([],[e.Vec(e.Record({url:e.Text,block_type:e.Text}))],["query"])})};import{isNullish as Oe,toNullable as _}from"@dfinity/utils";var pe=({from_subaccount:e,fee:s,created_at_time:t,memo:c,...i})=>({...i,fee:_(s),memo:_(c),from_subaccount:_(e),created_at_time:_(t)}),de=({spender_subaccount:e,fee:s,created_at_time:t,memo:c,...i})=>({...i,fee:_(s),memo:_(c),spender_subaccount:_(e),created_at_time:_(t)}),me=({fee:e,created_at_time:s,memo:t,from_subaccount:c,expected_allowance:i,expires_at:l,...d})=>({...d,fee:_(e),memo:_(t),from_subaccount:_(c),created_at_time:_(s),expected_allowance:_(i),expires_at:_(l)}),ue=({userPreferences:{metadata:{utcOffsetMinutes:e,language:s},deriveSpec:t},...c})=>({...c,user_preferences:{metadata:{language:s,utc_offset_minutes:_(e)},device_spec:Oe(t)?_():_("GenericDisplay"in t?{GenericDisplay:null}:{LineDisplay:{characters_per_line:t.LineDisplay.charactersPerLine,lines_per_page:t.LineDisplay.linesPerPage}})}});var f=class extends Error{constructor({msg:s,errorType:t}){super(s),this.errorType=t}},ne=class extends Error{constructor(t,c){super();this.message=t;this.error_code=c}},g=class extends Error{},oe=class extends g{},se=class extends g{},ie=class extends g{},fe=e=>"GenericError"in e?new ne(e.GenericError.description,e.GenericError.error_code):"InsufficientPayment"in e?new oe(e.InsufficientPayment.description):"UnsupportedCanisterCall"in e?new se(e.UnsupportedCanisterCall.description):"ConsentMessageUnavailable"in e?new ie(e.ConsentMessageUnavailable.description):new g(`Unknown error type ${JSON.stringify(e)}`);var ge=class e extends Re{constructor(){super(...arguments);this.metadata=t=>this.caller(t).icrc1_metadata();this.transactionFee=t=>this.caller(t).icrc1_fee();this.balance=t=>this.caller({certified:t.certified}).icrc1_balance_of({owner:t.owner,subaccount:xe(t.subaccount)});this.transfer=async t=>{let c=await this.caller({certified:!0}).icrc1_transfer(pe(t));if("Err"in c)throw new f({errorType:c.Err,msg:"Failed to transfer"});return c.Ok};this.totalTokensSupply=t=>this.caller(t).icrc1_total_supply();this.transferFrom=async t=>{let c=await this.caller({certified:!0}).icrc2_transfer_from(de(t));if("Err"in c)throw new f({errorType:c.Err,msg:"Failed to transfer from"});return c.Ok};this.approve=async t=>{let c=await this.caller({certified:!0}).icrc2_approve(me(t));if("Err"in c)throw new f({errorType:c.Err,msg:"Failed to entitle the spender to transfer the amount"});return c.Ok};this.allowance=async t=>{let{certified:c,...i}=t;return this.caller({certified:c}).icrc2_allowance({...i})};this.consentMessage=async t=>{let{icrc21_canister_call_consent_message:c}=this.caller({certified:!0}),i=await c(ue(t));if("Err"in i)throw fe(i.Err);return i.Ok}}static create(t){let{service:c,certifiedService:i,canisterId:l}=Te({options:t,idlFactory:le,certifiedIdlFactory:_e});return new e(l,c,i)}};export{pe as a,de as b,me as c,ue as d,f as e,ne as f,g,oe as h,se as i,ie as j,fe as k,ge as l};
2
+ //# sourceMappingURL=chunk-ZI5B523L.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/ledger.canister.ts", "../../candid/icrc_ledger.certified.idl.js", "../../candid/icrc_ledger.idl.js", "../../src/converters/ledger.converters.ts", "../../src/errors/ledger.errors.ts"],
4
+ "sourcesContent": ["import type { QueryParams } from \"@dfinity/utils\";\nimport { Canister, createServices, toNullable } from \"@dfinity/utils\";\nimport type {\n Allowance,\n BlockIndex,\n _SERVICE as IcrcLedgerService,\n Tokens,\n icrc21_consent_info,\n} from \"../candid/icrc_ledger\";\nimport { idlFactory as certifiedIdlFactory } from \"../candid/icrc_ledger.certified.idl\";\nimport { idlFactory } from \"../candid/icrc_ledger.idl\";\nimport {\n toApproveArgs,\n toIcrc21ConsentMessageArgs,\n toTransferArg,\n toTransferFromArgs,\n} from \"./converters/ledger.converters\";\nimport {\n IcrcTransferError,\n mapIcrc21ConsentMessageError,\n} from \"./errors/ledger.errors\";\nimport type { IcrcLedgerCanisterOptions } from \"./types/canister.options\";\nimport type {\n AllowanceParams,\n ApproveParams,\n BalanceParams,\n Icrc21ConsentMessageParams,\n TransferFromParams,\n TransferParams,\n} from \"./types/ledger.params\";\nimport type { IcrcTokenMetadataResponse } from \"./types/ledger.responses\";\n\nexport class IcrcLedgerCanister extends Canister<IcrcLedgerService> {\n static create(options: IcrcLedgerCanisterOptions<IcrcLedgerService>) {\n const { service, certifiedService, canisterId } =\n createServices<IcrcLedgerService>({\n options,\n idlFactory,\n certifiedIdlFactory,\n });\n\n return new IcrcLedgerCanister(canisterId, service, certifiedService);\n }\n\n /**\n * The token metadata (name, symbol, etc.).\n */\n metadata = (params: QueryParams): Promise<IcrcTokenMetadataResponse> =>\n this.caller(params).icrc1_metadata();\n\n /**\n * The ledger transaction fees.\n *\n * @returns {Tokens} The ledger transaction fees in Tokens\n */\n transactionFee = (params: QueryParams): Promise<Tokens> =>\n this.caller(params).icrc1_fee();\n\n /**\n * Returns the balance for a given account provided as owner and with optional subaccount.\n *\n * @param {BalanceParams} params The parameters to get the balance of an account.\n * @returns {Promise<Tokens>} The balance of the given account.\n */\n balance = (params: BalanceParams): Promise<Tokens> =>\n this.caller({ certified: params.certified }).icrc1_balance_of({\n owner: params.owner,\n subaccount: toNullable(params.subaccount),\n });\n\n /**\n * Transfers tokens from the sender to the given account.\n *\n * @param {TransferArg} params The parameters to transfer tokens.\n *\n * @throws {IcrcTransferError} If the transfer fails.\n */\n transfer = async (params: TransferParams): Promise<BlockIndex> => {\n const response = await this.caller({ certified: true }).icrc1_transfer(\n toTransferArg(params),\n );\n if (\"Err\" in response) {\n throw new IcrcTransferError({\n errorType: response.Err,\n msg: \"Failed to transfer\",\n });\n }\n return response.Ok;\n };\n\n /**\n * Returns the total supply of tokens.\n */\n totalTokensSupply = (params: QueryParams): Promise<Tokens> => {\n return this.caller(params).icrc1_total_supply();\n };\n\n /**\n * Transfers a token amount from the `from` account to the `to` account using the allowance of the spender's account (`SpenderAccount = { owner = caller; subaccount = spender_subaccount }`). The ledger draws the fees from the `from` account.\n *\n * Reference: https://github.com/dfinity/ICRC-1/blob/main/standards/ICRC-2/README.md#icrc2_transfer_from\n *\n * @param {TransferFromParams} params The parameters to transfer tokens from to.\n *\n * @throws {IcrcTransferError} If the transfer from fails.\n */\n transferFrom = async (params: TransferFromParams): Promise<BlockIndex> => {\n const response = await this.caller({ certified: true }).icrc2_transfer_from(\n toTransferFromArgs(params),\n );\n if (\"Err\" in response) {\n throw new IcrcTransferError({\n errorType: response.Err,\n msg: \"Failed to transfer from\",\n });\n }\n return response.Ok;\n };\n\n /**\n * This method entitles the `spender` to transfer token `amount` on behalf of the caller from account `{ owner = caller; subaccount = from_subaccount }`.\n *\n * Reference: https://github.com/dfinity/ICRC-1/blob/main/standards/ICRC-2/README.md#icrc2_approve\n *\n * @param {ApproveParams} params The parameters to approve.\n *\n * @throws {IcrcTransferError} If the approval fails.\n */\n approve = async (params: ApproveParams): Promise<BlockIndex> => {\n const response = await this.caller({ certified: true }).icrc2_approve(\n toApproveArgs(params),\n );\n if (\"Err\" in response) {\n throw new IcrcTransferError({\n errorType: response.Err,\n msg: \"Failed to entitle the spender to transfer the amount\",\n });\n }\n return response.Ok;\n };\n\n /**\n * Returns the token allowance that the `spender` account can transfer from the specified `account`, and the expiration time for that allowance, if any.\n *\n * Reference: https://github.com/dfinity/ICRC-1/blob/main/standards/ICRC-2/README.md#icrc2_allowance\n *\n * @param {AllowanceParams} params The parameters to call the allowance.\n *\n * @returns {Allowance} The token allowance. If there is no active approval, the ledger MUST return `{ allowance = 0; expires_at = null }`.\n */\n allowance = async (params: AllowanceParams): Promise<Allowance> => {\n const { certified, ...rest } = params;\n return this.caller({ certified }).icrc2_allowance({ ...rest });\n };\n\n /**\n * Fetches the consent message for a specified canister call, intended to provide a human-readable message that helps users make informed decisions.\n *\n * @link: https://github.com/dfinity/wg-identity-authentication/blob/main/topics/ICRC-21/icrc_21_consent_msg.md\n *\n * @param {Icrc21ConsentMessageParams} params - The request parameters containing the method name, arguments, and consent preferences (e.g., language).\n * @returns {Promise<icrc21_consent_info>} - A promise that resolves to the consent message response, which includes the consent message in the specified language and other related information.\n *\n * @throws {InsufficientPaymentError} - This error is reserved for future use, in case payment extensions are introduced. For example, if consent messages, which are currently free, begin to require payments.\n * @throws {UnsupportedCanisterCallError} - If the specified canister call is not supported.\n * @throws {ConsentMessageUnavailableError} - If there is no consent message available.\n * @throws {GenericError} - For any other generic errors.\n */\n consentMessage = async (\n params: Icrc21ConsentMessageParams,\n ): Promise<icrc21_consent_info> => {\n const { icrc21_canister_call_consent_message } = this.caller({\n certified: true,\n });\n\n const response = await icrc21_canister_call_consent_message(\n toIcrc21ConsentMessageArgs(params),\n );\n\n if (\"Err\" in response) {\n throw mapIcrc21ConsentMessageError(response.Err);\n }\n\n return response.Ok;\n };\n}\n", "/* Do not edit. Compiled with ./scripts/compile-idl-js from packages/ledger-icrc/candid/icrc_ledger.did */\nexport const idlFactory = ({ IDL }) => {\n const GetBlocksResult = IDL.Rec();\n const ICRC3Value = IDL.Rec();\n const Value = IDL.Rec();\n const ChangeArchiveOptions = IDL.Record({\n 'num_blocks_to_archive' : IDL.Opt(IDL.Nat64),\n 'max_transactions_per_response' : IDL.Opt(IDL.Nat64),\n 'trigger_threshold' : IDL.Opt(IDL.Nat64),\n 'more_controller_ids' : IDL.Opt(IDL.Vec(IDL.Principal)),\n 'max_message_size_bytes' : IDL.Opt(IDL.Nat64),\n 'cycles_for_archive_creation' : IDL.Opt(IDL.Nat64),\n 'node_max_memory_size_bytes' : IDL.Opt(IDL.Nat64),\n 'controller_id' : IDL.Opt(IDL.Principal),\n });\n const MetadataValue = IDL.Variant({\n 'Int' : IDL.Int,\n 'Nat' : IDL.Nat,\n 'Blob' : IDL.Vec(IDL.Nat8),\n 'Text' : IDL.Text,\n });\n const Subaccount = IDL.Vec(IDL.Nat8);\n const Account = IDL.Record({\n 'owner' : IDL.Principal,\n 'subaccount' : IDL.Opt(Subaccount),\n });\n const ChangeFeeCollector = IDL.Variant({\n 'SetTo' : Account,\n 'Unset' : IDL.Null,\n });\n const FeatureFlags = IDL.Record({ 'icrc2' : IDL.Bool });\n const UpgradeArgs = IDL.Record({\n 'change_archive_options' : IDL.Opt(ChangeArchiveOptions),\n 'token_symbol' : IDL.Opt(IDL.Text),\n 'transfer_fee' : IDL.Opt(IDL.Nat),\n 'metadata' : IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue))),\n 'accounts_overflow_trim_quantity' : IDL.Opt(IDL.Nat64),\n 'change_fee_collector' : IDL.Opt(ChangeFeeCollector),\n 'max_memo_length' : IDL.Opt(IDL.Nat16),\n 'token_name' : IDL.Opt(IDL.Text),\n 'feature_flags' : IDL.Opt(FeatureFlags),\n });\n const InitArgs = IDL.Record({\n 'decimals' : IDL.Opt(IDL.Nat8),\n 'token_symbol' : IDL.Text,\n 'transfer_fee' : IDL.Nat,\n 'metadata' : IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue)),\n 'minting_account' : Account,\n 'initial_balances' : IDL.Vec(IDL.Tuple(Account, IDL.Nat)),\n 'maximum_number_of_accounts' : IDL.Opt(IDL.Nat64),\n 'accounts_overflow_trim_quantity' : IDL.Opt(IDL.Nat64),\n 'fee_collector_account' : IDL.Opt(Account),\n 'archive_options' : IDL.Record({\n 'num_blocks_to_archive' : IDL.Nat64,\n 'max_transactions_per_response' : IDL.Opt(IDL.Nat64),\n 'trigger_threshold' : IDL.Nat64,\n 'more_controller_ids' : IDL.Opt(IDL.Vec(IDL.Principal)),\n 'max_message_size_bytes' : IDL.Opt(IDL.Nat64),\n 'cycles_for_archive_creation' : IDL.Opt(IDL.Nat64),\n 'node_max_memory_size_bytes' : IDL.Opt(IDL.Nat64),\n 'controller_id' : IDL.Principal,\n }),\n 'max_memo_length' : IDL.Opt(IDL.Nat16),\n 'token_name' : IDL.Text,\n 'feature_flags' : IDL.Opt(FeatureFlags),\n });\n const LedgerArg = IDL.Variant({\n 'Upgrade' : IDL.Opt(UpgradeArgs),\n 'Init' : InitArgs,\n });\n const BlockIndex = IDL.Nat;\n const ArchiveInfo = IDL.Record({\n 'block_range_end' : BlockIndex,\n 'canister_id' : IDL.Principal,\n 'block_range_start' : BlockIndex,\n });\n const GetBlocksArgs = IDL.Record({\n 'start' : BlockIndex,\n 'length' : IDL.Nat,\n });\n const Map = IDL.Vec(IDL.Tuple(IDL.Text, Value));\n Value.fill(\n IDL.Variant({\n 'Int' : IDL.Int,\n 'Map' : Map,\n 'Nat' : IDL.Nat,\n 'Nat64' : IDL.Nat64,\n 'Blob' : IDL.Vec(IDL.Nat8),\n 'Text' : IDL.Text,\n 'Array' : IDL.Vec(Value),\n })\n );\n const Block = Value;\n const BlockRange = IDL.Record({ 'blocks' : IDL.Vec(Block) });\n const QueryBlockArchiveFn = IDL.Func([GetBlocksArgs], [BlockRange], []);\n const GetBlocksResponse = IDL.Record({\n 'certificate' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'first_index' : BlockIndex,\n 'blocks' : IDL.Vec(Block),\n 'chain_length' : IDL.Nat64,\n 'archived_blocks' : IDL.Vec(\n IDL.Record({\n 'callback' : QueryBlockArchiveFn,\n 'start' : BlockIndex,\n 'length' : IDL.Nat,\n })\n ),\n });\n const DataCertificate = IDL.Record({\n 'certificate' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'hash_tree' : IDL.Vec(IDL.Nat8),\n });\n const TxIndex = IDL.Nat;\n const GetTransactionsRequest = IDL.Record({\n 'start' : TxIndex,\n 'length' : IDL.Nat,\n });\n const Timestamp = IDL.Nat64;\n const Burn = IDL.Record({\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(Timestamp),\n 'amount' : IDL.Nat,\n 'spender' : IDL.Opt(Account),\n });\n const Mint = IDL.Record({\n 'to' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(Timestamp),\n 'amount' : IDL.Nat,\n });\n const Approve = IDL.Record({\n 'fee' : IDL.Opt(IDL.Nat),\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(Timestamp),\n 'amount' : IDL.Nat,\n 'expected_allowance' : IDL.Opt(IDL.Nat),\n 'expires_at' : IDL.Opt(Timestamp),\n 'spender' : Account,\n });\n const Transfer = IDL.Record({\n 'to' : Account,\n 'fee' : IDL.Opt(IDL.Nat),\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(Timestamp),\n 'amount' : IDL.Nat,\n 'spender' : IDL.Opt(Account),\n });\n const Transaction = IDL.Record({\n 'burn' : IDL.Opt(Burn),\n 'kind' : IDL.Text,\n 'mint' : IDL.Opt(Mint),\n 'approve' : IDL.Opt(Approve),\n 'timestamp' : Timestamp,\n 'transfer' : IDL.Opt(Transfer),\n });\n const TransactionRange = IDL.Record({\n 'transactions' : IDL.Vec(Transaction),\n });\n const QueryArchiveFn = IDL.Func(\n [GetTransactionsRequest],\n [TransactionRange],\n [],\n );\n const GetTransactionsResponse = IDL.Record({\n 'first_index' : TxIndex,\n 'log_length' : IDL.Nat,\n 'transactions' : IDL.Vec(Transaction),\n 'archived_transactions' : IDL.Vec(\n IDL.Record({\n 'callback' : QueryArchiveFn,\n 'start' : TxIndex,\n 'length' : IDL.Nat,\n })\n ),\n });\n const Tokens = IDL.Nat;\n const StandardRecord = IDL.Record({ 'url' : IDL.Text, 'name' : IDL.Text });\n const TransferArg = IDL.Record({\n 'to' : Account,\n 'fee' : IDL.Opt(Tokens),\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'from_subaccount' : IDL.Opt(Subaccount),\n 'created_at_time' : IDL.Opt(Timestamp),\n 'amount' : Tokens,\n });\n const TransferError = IDL.Variant({\n 'GenericError' : IDL.Record({\n 'message' : IDL.Text,\n 'error_code' : IDL.Nat,\n }),\n 'TemporarilyUnavailable' : IDL.Null,\n 'BadBurn' : IDL.Record({ 'min_burn_amount' : Tokens }),\n 'Duplicate' : IDL.Record({ 'duplicate_of' : BlockIndex }),\n 'BadFee' : IDL.Record({ 'expected_fee' : Tokens }),\n 'CreatedInFuture' : IDL.Record({ 'ledger_time' : Timestamp }),\n 'TooOld' : IDL.Null,\n 'InsufficientFunds' : IDL.Record({ 'balance' : Tokens }),\n });\n const TransferResult = IDL.Variant({\n 'Ok' : BlockIndex,\n 'Err' : TransferError,\n });\n const icrc21_consent_message_metadata = IDL.Record({\n 'utc_offset_minutes' : IDL.Opt(IDL.Int16),\n 'language' : IDL.Text,\n });\n const icrc21_consent_message_spec = IDL.Record({\n 'metadata' : icrc21_consent_message_metadata,\n 'device_spec' : IDL.Opt(\n IDL.Variant({\n 'GenericDisplay' : IDL.Null,\n 'LineDisplay' : IDL.Record({\n 'characters_per_line' : IDL.Nat16,\n 'lines_per_page' : IDL.Nat16,\n }),\n })\n ),\n });\n const icrc21_consent_message_request = IDL.Record({\n 'arg' : IDL.Vec(IDL.Nat8),\n 'method' : IDL.Text,\n 'user_preferences' : icrc21_consent_message_spec,\n });\n const icrc21_consent_message = IDL.Variant({\n 'LineDisplayMessage' : IDL.Record({\n 'pages' : IDL.Vec(IDL.Record({ 'lines' : IDL.Vec(IDL.Text) })),\n }),\n 'GenericDisplayMessage' : IDL.Text,\n });\n const icrc21_consent_info = IDL.Record({\n 'metadata' : icrc21_consent_message_metadata,\n 'consent_message' : icrc21_consent_message,\n });\n const icrc21_error_info = IDL.Record({ 'description' : IDL.Text });\n const icrc21_error = IDL.Variant({\n 'GenericError' : IDL.Record({\n 'description' : IDL.Text,\n 'error_code' : IDL.Nat,\n }),\n 'InsufficientPayment' : icrc21_error_info,\n 'UnsupportedCanisterCall' : icrc21_error_info,\n 'ConsentMessageUnavailable' : icrc21_error_info,\n });\n const icrc21_consent_message_response = IDL.Variant({\n 'Ok' : icrc21_consent_info,\n 'Err' : icrc21_error,\n });\n const AllowanceArgs = IDL.Record({\n 'account' : Account,\n 'spender' : Account,\n });\n const Allowance = IDL.Record({\n 'allowance' : IDL.Nat,\n 'expires_at' : IDL.Opt(Timestamp),\n });\n const ApproveArgs = IDL.Record({\n 'fee' : IDL.Opt(IDL.Nat),\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'from_subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(Timestamp),\n 'amount' : IDL.Nat,\n 'expected_allowance' : IDL.Opt(IDL.Nat),\n 'expires_at' : IDL.Opt(Timestamp),\n 'spender' : Account,\n });\n const ApproveError = IDL.Variant({\n 'GenericError' : IDL.Record({\n 'message' : IDL.Text,\n 'error_code' : IDL.Nat,\n }),\n 'TemporarilyUnavailable' : IDL.Null,\n 'Duplicate' : IDL.Record({ 'duplicate_of' : BlockIndex }),\n 'BadFee' : IDL.Record({ 'expected_fee' : IDL.Nat }),\n 'AllowanceChanged' : IDL.Record({ 'current_allowance' : IDL.Nat }),\n 'CreatedInFuture' : IDL.Record({ 'ledger_time' : Timestamp }),\n 'TooOld' : IDL.Null,\n 'Expired' : IDL.Record({ 'ledger_time' : Timestamp }),\n 'InsufficientFunds' : IDL.Record({ 'balance' : IDL.Nat }),\n });\n const ApproveResult = IDL.Variant({\n 'Ok' : BlockIndex,\n 'Err' : ApproveError,\n });\n const TransferFromArgs = IDL.Record({\n 'to' : Account,\n 'fee' : IDL.Opt(Tokens),\n 'spender_subaccount' : IDL.Opt(Subaccount),\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(Timestamp),\n 'amount' : Tokens,\n });\n const TransferFromError = IDL.Variant({\n 'GenericError' : IDL.Record({\n 'message' : IDL.Text,\n 'error_code' : IDL.Nat,\n }),\n 'TemporarilyUnavailable' : IDL.Null,\n 'InsufficientAllowance' : IDL.Record({ 'allowance' : Tokens }),\n 'BadBurn' : IDL.Record({ 'min_burn_amount' : Tokens }),\n 'Duplicate' : IDL.Record({ 'duplicate_of' : BlockIndex }),\n 'BadFee' : IDL.Record({ 'expected_fee' : Tokens }),\n 'CreatedInFuture' : IDL.Record({ 'ledger_time' : Timestamp }),\n 'TooOld' : IDL.Null,\n 'InsufficientFunds' : IDL.Record({ 'balance' : Tokens }),\n });\n const TransferFromResult = IDL.Variant({\n 'Ok' : BlockIndex,\n 'Err' : TransferFromError,\n });\n const GetArchivesArgs = IDL.Record({ 'from' : IDL.Opt(IDL.Principal) });\n const GetArchivesResult = IDL.Vec(\n IDL.Record({\n 'end' : IDL.Nat,\n 'canister_id' : IDL.Principal,\n 'start' : IDL.Nat,\n })\n );\n ICRC3Value.fill(\n IDL.Variant({\n 'Int' : IDL.Int,\n 'Map' : IDL.Vec(IDL.Tuple(IDL.Text, ICRC3Value)),\n 'Nat' : IDL.Nat,\n 'Blob' : IDL.Vec(IDL.Nat8),\n 'Text' : IDL.Text,\n 'Array' : IDL.Vec(ICRC3Value),\n })\n );\n GetBlocksResult.fill(\n IDL.Record({\n 'log_length' : IDL.Nat,\n 'blocks' : IDL.Vec(IDL.Record({ 'id' : IDL.Nat, 'block' : ICRC3Value })),\n 'archived_blocks' : IDL.Vec(\n IDL.Record({\n 'args' : IDL.Vec(GetBlocksArgs),\n 'callback' : IDL.Func(\n [IDL.Vec(GetBlocksArgs)],\n [GetBlocksResult],\n [],\n ),\n })\n ),\n })\n );\n const ICRC3DataCertificate = IDL.Record({\n 'certificate' : IDL.Vec(IDL.Nat8),\n 'hash_tree' : IDL.Vec(IDL.Nat8),\n });\n return IDL.Service({\n 'archives' : IDL.Func([], [IDL.Vec(ArchiveInfo)], []),\n 'get_blocks' : IDL.Func([GetBlocksArgs], [GetBlocksResponse], []),\n 'get_data_certificate' : IDL.Func([], [DataCertificate], []),\n 'get_transactions' : IDL.Func(\n [GetTransactionsRequest],\n [GetTransactionsResponse],\n [],\n ),\n 'icrc10_supported_standards' : IDL.Func(\n [],\n [IDL.Vec(IDL.Record({ 'url' : IDL.Text, 'name' : IDL.Text }))],\n [],\n ),\n 'icrc1_balance_of' : IDL.Func([Account], [Tokens], []),\n 'icrc1_decimals' : IDL.Func([], [IDL.Nat8], []),\n 'icrc1_fee' : IDL.Func([], [Tokens], []),\n 'icrc1_metadata' : IDL.Func(\n [],\n [IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue))],\n [],\n ),\n 'icrc1_minting_account' : IDL.Func([], [IDL.Opt(Account)], []),\n 'icrc1_name' : IDL.Func([], [IDL.Text], []),\n 'icrc1_supported_standards' : IDL.Func([], [IDL.Vec(StandardRecord)], []),\n 'icrc1_symbol' : IDL.Func([], [IDL.Text], []),\n 'icrc1_total_supply' : IDL.Func([], [Tokens], []),\n 'icrc1_transfer' : IDL.Func([TransferArg], [TransferResult], []),\n 'icrc21_canister_call_consent_message' : IDL.Func(\n [icrc21_consent_message_request],\n [icrc21_consent_message_response],\n [],\n ),\n 'icrc2_allowance' : IDL.Func([AllowanceArgs], [Allowance], []),\n 'icrc2_approve' : IDL.Func([ApproveArgs], [ApproveResult], []),\n 'icrc2_transfer_from' : IDL.Func(\n [TransferFromArgs],\n [TransferFromResult],\n [],\n ),\n 'icrc3_get_archives' : IDL.Func([GetArchivesArgs], [GetArchivesResult], []),\n 'icrc3_get_blocks' : IDL.Func(\n [IDL.Vec(GetBlocksArgs)],\n [GetBlocksResult],\n [],\n ),\n 'icrc3_get_tip_certificate' : IDL.Func(\n [],\n [IDL.Opt(ICRC3DataCertificate)],\n [],\n ),\n 'icrc3_supported_block_types' : IDL.Func(\n [],\n [IDL.Vec(IDL.Record({ 'url' : IDL.Text, 'block_type' : IDL.Text }))],\n [],\n ),\n });\n};\nexport const init = ({ IDL }) => {\n const ChangeArchiveOptions = IDL.Record({\n 'num_blocks_to_archive' : IDL.Opt(IDL.Nat64),\n 'max_transactions_per_response' : IDL.Opt(IDL.Nat64),\n 'trigger_threshold' : IDL.Opt(IDL.Nat64),\n 'more_controller_ids' : IDL.Opt(IDL.Vec(IDL.Principal)),\n 'max_message_size_bytes' : IDL.Opt(IDL.Nat64),\n 'cycles_for_archive_creation' : IDL.Opt(IDL.Nat64),\n 'node_max_memory_size_bytes' : IDL.Opt(IDL.Nat64),\n 'controller_id' : IDL.Opt(IDL.Principal),\n });\n const MetadataValue = IDL.Variant({\n 'Int' : IDL.Int,\n 'Nat' : IDL.Nat,\n 'Blob' : IDL.Vec(IDL.Nat8),\n 'Text' : IDL.Text,\n });\n const Subaccount = IDL.Vec(IDL.Nat8);\n const Account = IDL.Record({\n 'owner' : IDL.Principal,\n 'subaccount' : IDL.Opt(Subaccount),\n });\n const ChangeFeeCollector = IDL.Variant({\n 'SetTo' : Account,\n 'Unset' : IDL.Null,\n });\n const FeatureFlags = IDL.Record({ 'icrc2' : IDL.Bool });\n const UpgradeArgs = IDL.Record({\n 'change_archive_options' : IDL.Opt(ChangeArchiveOptions),\n 'token_symbol' : IDL.Opt(IDL.Text),\n 'transfer_fee' : IDL.Opt(IDL.Nat),\n 'metadata' : IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue))),\n 'accounts_overflow_trim_quantity' : IDL.Opt(IDL.Nat64),\n 'change_fee_collector' : IDL.Opt(ChangeFeeCollector),\n 'max_memo_length' : IDL.Opt(IDL.Nat16),\n 'token_name' : IDL.Opt(IDL.Text),\n 'feature_flags' : IDL.Opt(FeatureFlags),\n });\n const InitArgs = IDL.Record({\n 'decimals' : IDL.Opt(IDL.Nat8),\n 'token_symbol' : IDL.Text,\n 'transfer_fee' : IDL.Nat,\n 'metadata' : IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue)),\n 'minting_account' : Account,\n 'initial_balances' : IDL.Vec(IDL.Tuple(Account, IDL.Nat)),\n 'maximum_number_of_accounts' : IDL.Opt(IDL.Nat64),\n 'accounts_overflow_trim_quantity' : IDL.Opt(IDL.Nat64),\n 'fee_collector_account' : IDL.Opt(Account),\n 'archive_options' : IDL.Record({\n 'num_blocks_to_archive' : IDL.Nat64,\n 'max_transactions_per_response' : IDL.Opt(IDL.Nat64),\n 'trigger_threshold' : IDL.Nat64,\n 'more_controller_ids' : IDL.Opt(IDL.Vec(IDL.Principal)),\n 'max_message_size_bytes' : IDL.Opt(IDL.Nat64),\n 'cycles_for_archive_creation' : IDL.Opt(IDL.Nat64),\n 'node_max_memory_size_bytes' : IDL.Opt(IDL.Nat64),\n 'controller_id' : IDL.Principal,\n }),\n 'max_memo_length' : IDL.Opt(IDL.Nat16),\n 'token_name' : IDL.Text,\n 'feature_flags' : IDL.Opt(FeatureFlags),\n });\n const LedgerArg = IDL.Variant({\n 'Upgrade' : IDL.Opt(UpgradeArgs),\n 'Init' : InitArgs,\n });\n return [LedgerArg];\n};\n", "/* Do not edit. Compiled with ./scripts/compile-idl-js from packages/ledger-icrc/candid/icrc_ledger.did */\nexport const idlFactory = ({ IDL }) => {\n const GetBlocksResult = IDL.Rec();\n const ICRC3Value = IDL.Rec();\n const Value = IDL.Rec();\n const ChangeArchiveOptions = IDL.Record({\n 'num_blocks_to_archive' : IDL.Opt(IDL.Nat64),\n 'max_transactions_per_response' : IDL.Opt(IDL.Nat64),\n 'trigger_threshold' : IDL.Opt(IDL.Nat64),\n 'more_controller_ids' : IDL.Opt(IDL.Vec(IDL.Principal)),\n 'max_message_size_bytes' : IDL.Opt(IDL.Nat64),\n 'cycles_for_archive_creation' : IDL.Opt(IDL.Nat64),\n 'node_max_memory_size_bytes' : IDL.Opt(IDL.Nat64),\n 'controller_id' : IDL.Opt(IDL.Principal),\n });\n const MetadataValue = IDL.Variant({\n 'Int' : IDL.Int,\n 'Nat' : IDL.Nat,\n 'Blob' : IDL.Vec(IDL.Nat8),\n 'Text' : IDL.Text,\n });\n const Subaccount = IDL.Vec(IDL.Nat8);\n const Account = IDL.Record({\n 'owner' : IDL.Principal,\n 'subaccount' : IDL.Opt(Subaccount),\n });\n const ChangeFeeCollector = IDL.Variant({\n 'SetTo' : Account,\n 'Unset' : IDL.Null,\n });\n const FeatureFlags = IDL.Record({ 'icrc2' : IDL.Bool });\n const UpgradeArgs = IDL.Record({\n 'change_archive_options' : IDL.Opt(ChangeArchiveOptions),\n 'token_symbol' : IDL.Opt(IDL.Text),\n 'transfer_fee' : IDL.Opt(IDL.Nat),\n 'metadata' : IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue))),\n 'accounts_overflow_trim_quantity' : IDL.Opt(IDL.Nat64),\n 'change_fee_collector' : IDL.Opt(ChangeFeeCollector),\n 'max_memo_length' : IDL.Opt(IDL.Nat16),\n 'token_name' : IDL.Opt(IDL.Text),\n 'feature_flags' : IDL.Opt(FeatureFlags),\n });\n const InitArgs = IDL.Record({\n 'decimals' : IDL.Opt(IDL.Nat8),\n 'token_symbol' : IDL.Text,\n 'transfer_fee' : IDL.Nat,\n 'metadata' : IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue)),\n 'minting_account' : Account,\n 'initial_balances' : IDL.Vec(IDL.Tuple(Account, IDL.Nat)),\n 'maximum_number_of_accounts' : IDL.Opt(IDL.Nat64),\n 'accounts_overflow_trim_quantity' : IDL.Opt(IDL.Nat64),\n 'fee_collector_account' : IDL.Opt(Account),\n 'archive_options' : IDL.Record({\n 'num_blocks_to_archive' : IDL.Nat64,\n 'max_transactions_per_response' : IDL.Opt(IDL.Nat64),\n 'trigger_threshold' : IDL.Nat64,\n 'more_controller_ids' : IDL.Opt(IDL.Vec(IDL.Principal)),\n 'max_message_size_bytes' : IDL.Opt(IDL.Nat64),\n 'cycles_for_archive_creation' : IDL.Opt(IDL.Nat64),\n 'node_max_memory_size_bytes' : IDL.Opt(IDL.Nat64),\n 'controller_id' : IDL.Principal,\n }),\n 'max_memo_length' : IDL.Opt(IDL.Nat16),\n 'token_name' : IDL.Text,\n 'feature_flags' : IDL.Opt(FeatureFlags),\n });\n const LedgerArg = IDL.Variant({\n 'Upgrade' : IDL.Opt(UpgradeArgs),\n 'Init' : InitArgs,\n });\n const BlockIndex = IDL.Nat;\n const ArchiveInfo = IDL.Record({\n 'block_range_end' : BlockIndex,\n 'canister_id' : IDL.Principal,\n 'block_range_start' : BlockIndex,\n });\n const GetBlocksArgs = IDL.Record({\n 'start' : BlockIndex,\n 'length' : IDL.Nat,\n });\n const Map = IDL.Vec(IDL.Tuple(IDL.Text, Value));\n Value.fill(\n IDL.Variant({\n 'Int' : IDL.Int,\n 'Map' : Map,\n 'Nat' : IDL.Nat,\n 'Nat64' : IDL.Nat64,\n 'Blob' : IDL.Vec(IDL.Nat8),\n 'Text' : IDL.Text,\n 'Array' : IDL.Vec(Value),\n })\n );\n const Block = Value;\n const BlockRange = IDL.Record({ 'blocks' : IDL.Vec(Block) });\n const QueryBlockArchiveFn = IDL.Func(\n [GetBlocksArgs],\n [BlockRange],\n ['query'],\n );\n const GetBlocksResponse = IDL.Record({\n 'certificate' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'first_index' : BlockIndex,\n 'blocks' : IDL.Vec(Block),\n 'chain_length' : IDL.Nat64,\n 'archived_blocks' : IDL.Vec(\n IDL.Record({\n 'callback' : QueryBlockArchiveFn,\n 'start' : BlockIndex,\n 'length' : IDL.Nat,\n })\n ),\n });\n const DataCertificate = IDL.Record({\n 'certificate' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'hash_tree' : IDL.Vec(IDL.Nat8),\n });\n const TxIndex = IDL.Nat;\n const GetTransactionsRequest = IDL.Record({\n 'start' : TxIndex,\n 'length' : IDL.Nat,\n });\n const Timestamp = IDL.Nat64;\n const Burn = IDL.Record({\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(Timestamp),\n 'amount' : IDL.Nat,\n 'spender' : IDL.Opt(Account),\n });\n const Mint = IDL.Record({\n 'to' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(Timestamp),\n 'amount' : IDL.Nat,\n });\n const Approve = IDL.Record({\n 'fee' : IDL.Opt(IDL.Nat),\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(Timestamp),\n 'amount' : IDL.Nat,\n 'expected_allowance' : IDL.Opt(IDL.Nat),\n 'expires_at' : IDL.Opt(Timestamp),\n 'spender' : Account,\n });\n const Transfer = IDL.Record({\n 'to' : Account,\n 'fee' : IDL.Opt(IDL.Nat),\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(Timestamp),\n 'amount' : IDL.Nat,\n 'spender' : IDL.Opt(Account),\n });\n const Transaction = IDL.Record({\n 'burn' : IDL.Opt(Burn),\n 'kind' : IDL.Text,\n 'mint' : IDL.Opt(Mint),\n 'approve' : IDL.Opt(Approve),\n 'timestamp' : Timestamp,\n 'transfer' : IDL.Opt(Transfer),\n });\n const TransactionRange = IDL.Record({\n 'transactions' : IDL.Vec(Transaction),\n });\n const QueryArchiveFn = IDL.Func(\n [GetTransactionsRequest],\n [TransactionRange],\n ['query'],\n );\n const GetTransactionsResponse = IDL.Record({\n 'first_index' : TxIndex,\n 'log_length' : IDL.Nat,\n 'transactions' : IDL.Vec(Transaction),\n 'archived_transactions' : IDL.Vec(\n IDL.Record({\n 'callback' : QueryArchiveFn,\n 'start' : TxIndex,\n 'length' : IDL.Nat,\n })\n ),\n });\n const Tokens = IDL.Nat;\n const StandardRecord = IDL.Record({ 'url' : IDL.Text, 'name' : IDL.Text });\n const TransferArg = IDL.Record({\n 'to' : Account,\n 'fee' : IDL.Opt(Tokens),\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'from_subaccount' : IDL.Opt(Subaccount),\n 'created_at_time' : IDL.Opt(Timestamp),\n 'amount' : Tokens,\n });\n const TransferError = IDL.Variant({\n 'GenericError' : IDL.Record({\n 'message' : IDL.Text,\n 'error_code' : IDL.Nat,\n }),\n 'TemporarilyUnavailable' : IDL.Null,\n 'BadBurn' : IDL.Record({ 'min_burn_amount' : Tokens }),\n 'Duplicate' : IDL.Record({ 'duplicate_of' : BlockIndex }),\n 'BadFee' : IDL.Record({ 'expected_fee' : Tokens }),\n 'CreatedInFuture' : IDL.Record({ 'ledger_time' : Timestamp }),\n 'TooOld' : IDL.Null,\n 'InsufficientFunds' : IDL.Record({ 'balance' : Tokens }),\n });\n const TransferResult = IDL.Variant({\n 'Ok' : BlockIndex,\n 'Err' : TransferError,\n });\n const icrc21_consent_message_metadata = IDL.Record({\n 'utc_offset_minutes' : IDL.Opt(IDL.Int16),\n 'language' : IDL.Text,\n });\n const icrc21_consent_message_spec = IDL.Record({\n 'metadata' : icrc21_consent_message_metadata,\n 'device_spec' : IDL.Opt(\n IDL.Variant({\n 'GenericDisplay' : IDL.Null,\n 'LineDisplay' : IDL.Record({\n 'characters_per_line' : IDL.Nat16,\n 'lines_per_page' : IDL.Nat16,\n }),\n })\n ),\n });\n const icrc21_consent_message_request = IDL.Record({\n 'arg' : IDL.Vec(IDL.Nat8),\n 'method' : IDL.Text,\n 'user_preferences' : icrc21_consent_message_spec,\n });\n const icrc21_consent_message = IDL.Variant({\n 'LineDisplayMessage' : IDL.Record({\n 'pages' : IDL.Vec(IDL.Record({ 'lines' : IDL.Vec(IDL.Text) })),\n }),\n 'GenericDisplayMessage' : IDL.Text,\n });\n const icrc21_consent_info = IDL.Record({\n 'metadata' : icrc21_consent_message_metadata,\n 'consent_message' : icrc21_consent_message,\n });\n const icrc21_error_info = IDL.Record({ 'description' : IDL.Text });\n const icrc21_error = IDL.Variant({\n 'GenericError' : IDL.Record({\n 'description' : IDL.Text,\n 'error_code' : IDL.Nat,\n }),\n 'InsufficientPayment' : icrc21_error_info,\n 'UnsupportedCanisterCall' : icrc21_error_info,\n 'ConsentMessageUnavailable' : icrc21_error_info,\n });\n const icrc21_consent_message_response = IDL.Variant({\n 'Ok' : icrc21_consent_info,\n 'Err' : icrc21_error,\n });\n const AllowanceArgs = IDL.Record({\n 'account' : Account,\n 'spender' : Account,\n });\n const Allowance = IDL.Record({\n 'allowance' : IDL.Nat,\n 'expires_at' : IDL.Opt(Timestamp),\n });\n const ApproveArgs = IDL.Record({\n 'fee' : IDL.Opt(IDL.Nat),\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'from_subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(Timestamp),\n 'amount' : IDL.Nat,\n 'expected_allowance' : IDL.Opt(IDL.Nat),\n 'expires_at' : IDL.Opt(Timestamp),\n 'spender' : Account,\n });\n const ApproveError = IDL.Variant({\n 'GenericError' : IDL.Record({\n 'message' : IDL.Text,\n 'error_code' : IDL.Nat,\n }),\n 'TemporarilyUnavailable' : IDL.Null,\n 'Duplicate' : IDL.Record({ 'duplicate_of' : BlockIndex }),\n 'BadFee' : IDL.Record({ 'expected_fee' : IDL.Nat }),\n 'AllowanceChanged' : IDL.Record({ 'current_allowance' : IDL.Nat }),\n 'CreatedInFuture' : IDL.Record({ 'ledger_time' : Timestamp }),\n 'TooOld' : IDL.Null,\n 'Expired' : IDL.Record({ 'ledger_time' : Timestamp }),\n 'InsufficientFunds' : IDL.Record({ 'balance' : IDL.Nat }),\n });\n const ApproveResult = IDL.Variant({\n 'Ok' : BlockIndex,\n 'Err' : ApproveError,\n });\n const TransferFromArgs = IDL.Record({\n 'to' : Account,\n 'fee' : IDL.Opt(Tokens),\n 'spender_subaccount' : IDL.Opt(Subaccount),\n 'from' : Account,\n 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)),\n 'created_at_time' : IDL.Opt(Timestamp),\n 'amount' : Tokens,\n });\n const TransferFromError = IDL.Variant({\n 'GenericError' : IDL.Record({\n 'message' : IDL.Text,\n 'error_code' : IDL.Nat,\n }),\n 'TemporarilyUnavailable' : IDL.Null,\n 'InsufficientAllowance' : IDL.Record({ 'allowance' : Tokens }),\n 'BadBurn' : IDL.Record({ 'min_burn_amount' : Tokens }),\n 'Duplicate' : IDL.Record({ 'duplicate_of' : BlockIndex }),\n 'BadFee' : IDL.Record({ 'expected_fee' : Tokens }),\n 'CreatedInFuture' : IDL.Record({ 'ledger_time' : Timestamp }),\n 'TooOld' : IDL.Null,\n 'InsufficientFunds' : IDL.Record({ 'balance' : Tokens }),\n });\n const TransferFromResult = IDL.Variant({\n 'Ok' : BlockIndex,\n 'Err' : TransferFromError,\n });\n const GetArchivesArgs = IDL.Record({ 'from' : IDL.Opt(IDL.Principal) });\n const GetArchivesResult = IDL.Vec(\n IDL.Record({\n 'end' : IDL.Nat,\n 'canister_id' : IDL.Principal,\n 'start' : IDL.Nat,\n })\n );\n ICRC3Value.fill(\n IDL.Variant({\n 'Int' : IDL.Int,\n 'Map' : IDL.Vec(IDL.Tuple(IDL.Text, ICRC3Value)),\n 'Nat' : IDL.Nat,\n 'Blob' : IDL.Vec(IDL.Nat8),\n 'Text' : IDL.Text,\n 'Array' : IDL.Vec(ICRC3Value),\n })\n );\n GetBlocksResult.fill(\n IDL.Record({\n 'log_length' : IDL.Nat,\n 'blocks' : IDL.Vec(IDL.Record({ 'id' : IDL.Nat, 'block' : ICRC3Value })),\n 'archived_blocks' : IDL.Vec(\n IDL.Record({\n 'args' : IDL.Vec(GetBlocksArgs),\n 'callback' : IDL.Func(\n [IDL.Vec(GetBlocksArgs)],\n [GetBlocksResult],\n ['query'],\n ),\n })\n ),\n })\n );\n const ICRC3DataCertificate = IDL.Record({\n 'certificate' : IDL.Vec(IDL.Nat8),\n 'hash_tree' : IDL.Vec(IDL.Nat8),\n });\n return IDL.Service({\n 'archives' : IDL.Func([], [IDL.Vec(ArchiveInfo)], ['query']),\n 'get_blocks' : IDL.Func([GetBlocksArgs], [GetBlocksResponse], ['query']),\n 'get_data_certificate' : IDL.Func([], [DataCertificate], ['query']),\n 'get_transactions' : IDL.Func(\n [GetTransactionsRequest],\n [GetTransactionsResponse],\n ['query'],\n ),\n 'icrc10_supported_standards' : IDL.Func(\n [],\n [IDL.Vec(IDL.Record({ 'url' : IDL.Text, 'name' : IDL.Text }))],\n ['query'],\n ),\n 'icrc1_balance_of' : IDL.Func([Account], [Tokens], ['query']),\n 'icrc1_decimals' : IDL.Func([], [IDL.Nat8], ['query']),\n 'icrc1_fee' : IDL.Func([], [Tokens], ['query']),\n 'icrc1_metadata' : IDL.Func(\n [],\n [IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue))],\n ['query'],\n ),\n 'icrc1_minting_account' : IDL.Func([], [IDL.Opt(Account)], ['query']),\n 'icrc1_name' : IDL.Func([], [IDL.Text], ['query']),\n 'icrc1_supported_standards' : IDL.Func(\n [],\n [IDL.Vec(StandardRecord)],\n ['query'],\n ),\n 'icrc1_symbol' : IDL.Func([], [IDL.Text], ['query']),\n 'icrc1_total_supply' : IDL.Func([], [Tokens], ['query']),\n 'icrc1_transfer' : IDL.Func([TransferArg], [TransferResult], []),\n 'icrc21_canister_call_consent_message' : IDL.Func(\n [icrc21_consent_message_request],\n [icrc21_consent_message_response],\n [],\n ),\n 'icrc2_allowance' : IDL.Func([AllowanceArgs], [Allowance], ['query']),\n 'icrc2_approve' : IDL.Func([ApproveArgs], [ApproveResult], []),\n 'icrc2_transfer_from' : IDL.Func(\n [TransferFromArgs],\n [TransferFromResult],\n [],\n ),\n 'icrc3_get_archives' : IDL.Func(\n [GetArchivesArgs],\n [GetArchivesResult],\n ['query'],\n ),\n 'icrc3_get_blocks' : IDL.Func(\n [IDL.Vec(GetBlocksArgs)],\n [GetBlocksResult],\n ['query'],\n ),\n 'icrc3_get_tip_certificate' : IDL.Func(\n [],\n [IDL.Opt(ICRC3DataCertificate)],\n ['query'],\n ),\n 'icrc3_supported_block_types' : IDL.Func(\n [],\n [IDL.Vec(IDL.Record({ 'url' : IDL.Text, 'block_type' : IDL.Text }))],\n ['query'],\n ),\n });\n};\nexport const init = ({ IDL }) => {\n const ChangeArchiveOptions = IDL.Record({\n 'num_blocks_to_archive' : IDL.Opt(IDL.Nat64),\n 'max_transactions_per_response' : IDL.Opt(IDL.Nat64),\n 'trigger_threshold' : IDL.Opt(IDL.Nat64),\n 'more_controller_ids' : IDL.Opt(IDL.Vec(IDL.Principal)),\n 'max_message_size_bytes' : IDL.Opt(IDL.Nat64),\n 'cycles_for_archive_creation' : IDL.Opt(IDL.Nat64),\n 'node_max_memory_size_bytes' : IDL.Opt(IDL.Nat64),\n 'controller_id' : IDL.Opt(IDL.Principal),\n });\n const MetadataValue = IDL.Variant({\n 'Int' : IDL.Int,\n 'Nat' : IDL.Nat,\n 'Blob' : IDL.Vec(IDL.Nat8),\n 'Text' : IDL.Text,\n });\n const Subaccount = IDL.Vec(IDL.Nat8);\n const Account = IDL.Record({\n 'owner' : IDL.Principal,\n 'subaccount' : IDL.Opt(Subaccount),\n });\n const ChangeFeeCollector = IDL.Variant({\n 'SetTo' : Account,\n 'Unset' : IDL.Null,\n });\n const FeatureFlags = IDL.Record({ 'icrc2' : IDL.Bool });\n const UpgradeArgs = IDL.Record({\n 'change_archive_options' : IDL.Opt(ChangeArchiveOptions),\n 'token_symbol' : IDL.Opt(IDL.Text),\n 'transfer_fee' : IDL.Opt(IDL.Nat),\n 'metadata' : IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue))),\n 'accounts_overflow_trim_quantity' : IDL.Opt(IDL.Nat64),\n 'change_fee_collector' : IDL.Opt(ChangeFeeCollector),\n 'max_memo_length' : IDL.Opt(IDL.Nat16),\n 'token_name' : IDL.Opt(IDL.Text),\n 'feature_flags' : IDL.Opt(FeatureFlags),\n });\n const InitArgs = IDL.Record({\n 'decimals' : IDL.Opt(IDL.Nat8),\n 'token_symbol' : IDL.Text,\n 'transfer_fee' : IDL.Nat,\n 'metadata' : IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue)),\n 'minting_account' : Account,\n 'initial_balances' : IDL.Vec(IDL.Tuple(Account, IDL.Nat)),\n 'maximum_number_of_accounts' : IDL.Opt(IDL.Nat64),\n 'accounts_overflow_trim_quantity' : IDL.Opt(IDL.Nat64),\n 'fee_collector_account' : IDL.Opt(Account),\n 'archive_options' : IDL.Record({\n 'num_blocks_to_archive' : IDL.Nat64,\n 'max_transactions_per_response' : IDL.Opt(IDL.Nat64),\n 'trigger_threshold' : IDL.Nat64,\n 'more_controller_ids' : IDL.Opt(IDL.Vec(IDL.Principal)),\n 'max_message_size_bytes' : IDL.Opt(IDL.Nat64),\n 'cycles_for_archive_creation' : IDL.Opt(IDL.Nat64),\n 'node_max_memory_size_bytes' : IDL.Opt(IDL.Nat64),\n 'controller_id' : IDL.Principal,\n }),\n 'max_memo_length' : IDL.Opt(IDL.Nat16),\n 'token_name' : IDL.Text,\n 'feature_flags' : IDL.Opt(FeatureFlags),\n });\n const LedgerArg = IDL.Variant({\n 'Upgrade' : IDL.Opt(UpgradeArgs),\n 'Init' : InitArgs,\n });\n return [LedgerArg];\n};\n", "import { isNullish, toNullable } from \"@dfinity/utils\";\nimport type {\n ApproveArgs,\n icrc21_consent_message_request as ConsentMessageArgs,\n TransferArg,\n TransferFromArgs,\n} from \"../../candid/icrc_ledger\";\nimport type {\n ApproveParams,\n Icrc21ConsentMessageParams,\n TransferFromParams,\n TransferParams,\n} from \"../types/ledger.params\";\n\n// WARNING: When using the ICRC-1 interface of the ICP ledger, there is no\n// relationship between the memo and the icrc1Memo of a transaction. The ICRC-1\n// interface simply cannot set the memo field and the non-ICRC-1 interface\n// cannot set the icrc1Memo field, even though the icrc1Memo field is called\n// just \"memo\" in canister method params.\nexport const toTransferArg = ({\n from_subaccount,\n fee,\n created_at_time,\n memo,\n ...rest\n}: TransferParams): TransferArg => ({\n ...rest,\n fee: toNullable(fee),\n memo: toNullable(memo),\n from_subaccount: toNullable(from_subaccount),\n created_at_time: toNullable(created_at_time),\n});\n\nexport const toTransferFromArgs = ({\n spender_subaccount,\n fee,\n created_at_time,\n memo,\n ...rest\n}: TransferFromParams): TransferFromArgs => ({\n ...rest,\n fee: toNullable(fee),\n memo: toNullable(memo),\n spender_subaccount: toNullable(spender_subaccount),\n created_at_time: toNullable(created_at_time),\n});\n\nexport const toApproveArgs = ({\n fee,\n created_at_time,\n memo,\n from_subaccount,\n expected_allowance,\n expires_at,\n ...rest\n}: ApproveParams): ApproveArgs => ({\n ...rest,\n fee: toNullable(fee),\n memo: toNullable(memo),\n from_subaccount: toNullable(from_subaccount),\n created_at_time: toNullable(created_at_time),\n expected_allowance: toNullable(expected_allowance),\n expires_at: toNullable(expires_at),\n});\n\nexport const toIcrc21ConsentMessageArgs = ({\n userPreferences: {\n metadata: { utcOffsetMinutes, language },\n deriveSpec,\n },\n ...rest\n}: Icrc21ConsentMessageParams): ConsentMessageArgs => ({\n ...rest,\n user_preferences: {\n metadata: {\n language,\n utc_offset_minutes: toNullable(utcOffsetMinutes),\n },\n device_spec: isNullish(deriveSpec)\n ? toNullable()\n : toNullable(\n \"GenericDisplay\" in deriveSpec\n ? { GenericDisplay: null }\n : {\n LineDisplay: {\n characters_per_line: deriveSpec.LineDisplay.charactersPerLine,\n lines_per_page: deriveSpec.LineDisplay.linesPerPage,\n },\n },\n ),\n },\n});\n", "import type { icrc21_error as Icrc21RawError } from \"../../candid/icrc_ledger\";\n\nexport class IcrcTransferError<T> extends Error {\n public errorType: T;\n constructor({ msg, errorType }: { msg?: string; errorType: T }) {\n super(msg);\n this.errorType = errorType;\n }\n}\n\nexport class GenericError extends Error {\n constructor(\n public readonly message: string,\n public readonly error_code: bigint,\n ) {\n super();\n }\n}\n\nexport class ConsentMessageError extends Error {}\n\nexport class InsufficientPaymentError extends ConsentMessageError {}\nexport class UnsupportedCanisterCallError extends ConsentMessageError {}\nexport class ConsentMessageUnavailableError extends ConsentMessageError {}\n\nexport const mapIcrc21ConsentMessageError = (\n rawError: Icrc21RawError,\n): ConsentMessageError => {\n if (\"GenericError\" in rawError) {\n return new GenericError(\n rawError.GenericError.description,\n rawError.GenericError.error_code,\n );\n }\n\n if (\"InsufficientPayment\" in rawError) {\n return new InsufficientPaymentError(\n rawError.InsufficientPayment.description,\n );\n }\n\n if (\"UnsupportedCanisterCall\" in rawError) {\n return new UnsupportedCanisterCallError(\n rawError.UnsupportedCanisterCall.description,\n );\n }\n if (\"ConsentMessageUnavailable\" in rawError) {\n return new ConsentMessageUnavailableError(\n rawError.ConsentMessageUnavailable.description,\n );\n }\n\n // Edge case\n return new ConsentMessageError(\n `Unknown error type ${JSON.stringify(rawError)}`,\n );\n};\n"],
5
+ "mappings": "AACA,OAAS,YAAAA,GAAU,kBAAAC,GAAgB,cAAAC,OAAkB,iBCA9C,IAAMC,GAAa,CAAC,CAAE,IAAAC,CAAI,IAAM,CACrC,IAAMC,EAAkBD,EAAI,IAAI,EAC1BE,EAAaF,EAAI,IAAI,EACrBG,EAAQH,EAAI,IAAI,EAChBI,EAAuBJ,EAAI,OAAO,CACtC,sBAA0BA,EAAI,IAAIA,EAAI,KAAK,EAC3C,8BAAkCA,EAAI,IAAIA,EAAI,KAAK,EACnD,kBAAsBA,EAAI,IAAIA,EAAI,KAAK,EACvC,oBAAwBA,EAAI,IAAIA,EAAI,IAAIA,EAAI,SAAS,CAAC,EACtD,uBAA2BA,EAAI,IAAIA,EAAI,KAAK,EAC5C,4BAAgCA,EAAI,IAAIA,EAAI,KAAK,EACjD,2BAA+BA,EAAI,IAAIA,EAAI,KAAK,EAChD,cAAkBA,EAAI,IAAIA,EAAI,SAAS,CACzC,CAAC,EACKK,EAAgBL,EAAI,QAAQ,CAChC,IAAQA,EAAI,IACZ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S,EAClB,EAvJA,OAAO,OAAOU,EAAuD,CACnE,GAAM,CAAE,QAAAC,EAAS,iBAAAC,EAAkB,WAAAC,CAAW,EAC5CC,GAAkC,CAChC,QAAAJ,EACA,WAAAK,GACA,oBAAAA,EACF,CAAC,EAEH,OAAO,IAAInB,EAAmBiB,EAAYF,EAASC,CAAgB,CACrE,CA+IF",
6
+ "names": ["Canister", "createServices", "toNullable", "idlFactory", "IDL", "GetBlocksResult", "ICRC3Value", "Value", "ChangeArchiveOptions", "MetadataValue", "Subaccount", "Account", "ChangeFeeCollector", "FeatureFlags", "UpgradeArgs", "InitArgs", "LedgerArg", "BlockIndex", "ArchiveInfo", "GetBlocksArgs", "Map", "Block", "BlockRange", "QueryBlockArchiveFn", "GetBlocksResponse", "DataCertificate", "TxIndex", "GetTransactionsRequest", "Timestamp", "Burn", "Mint", "Approve", "Transfer", "Transaction", "TransactionRange", "QueryArchiveFn", "GetTransactionsResponse", "Tokens", "StandardRecord", "TransferArg", "TransferError", "TransferResult", "icrc21_consent_message_metadata", "icrc21_consent_message_spec", "icrc21_consent_message_request", "icrc21_consent_message", "icrc21_consent_info", "icrc21_error_info", "icrc21_error", "icrc21_consent_message_response", "AllowanceArgs", "Allowance", "ApproveArgs", "ApproveError", "ApproveResult", "TransferFromArgs", "TransferFromError", "TransferFromResult", "GetArchivesArgs", "GetArchivesResult", "ICRC3DataCertificate", "idlFactory", "IDL", "GetBlocksResult", "ICRC3Value", "Value", "ChangeArchiveOptions", "MetadataValue", "Subaccount", "Account", "ChangeFeeCollector", "FeatureFlags", "UpgradeArgs", "InitArgs", "LedgerArg", "BlockIndex", "ArchiveInfo", "GetBlocksArgs", "Map", "Block", "BlockRange", "QueryBlockArchiveFn", "GetBlocksResponse", "DataCertificate", "TxIndex", "GetTransactionsRequest", "Timestamp", "Burn", "Mint", "Approve", "Transfer", "Transaction", "TransactionRange", "QueryArchiveFn", "GetTransactionsResponse", "Tokens", "StandardRecord", "TransferArg", "TransferError", "TransferResult", "icrc21_consent_message_metadata", "icrc21_consent_message_spec", "icrc21_consent_message_request", "icrc21_consent_message", "icrc21_consent_info", "icrc21_error_info", "icrc21_error", "icrc21_consent_message_response", "AllowanceArgs", "Allowance", "ApproveArgs", "ApproveError", "ApproveResult", "TransferFromArgs", "TransferFromError", "TransferFromResult", "GetArchivesArgs", "GetArchivesResult", "ICRC3DataCertificate", "isNullish", "toNullable", "toTransferArg", "from_subaccount", "fee", "created_at_time", "memo", "rest", "toTransferFromArgs", "spender_subaccount", "toApproveArgs", "expected_allowance", "expires_at", "toIcrc21ConsentMessageArgs", "utcOffsetMinutes", "language", "deriveSpec", "IcrcTransferError", "msg", "errorType", "GenericError", "message", "error_code", "ConsentMessageError", "InsufficientPaymentError", "UnsupportedCanisterCallError", "ConsentMessageUnavailableError", "mapIcrc21ConsentMessageError", "rawError", "IcrcLedgerCanister", "_IcrcLedgerCanister", "Canister", "params", "toNullable", "response", "toTransferArg", "IcrcTransferError", "toTransferFromArgs", "toApproveArgs", "certified", "rest", "icrc21_canister_call_consent_message", "toIcrc21ConsentMessageArgs", "mapIcrc21ConsentMessageError", "options", "service", "certifiedService", "canisterId", "createServices", "idlFactory"]
7
+ }
package/dist/esm/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{a as m}from"./chunk-ZAZML4GO.js";import"./chunk-6GLYJI63.js";import{a as u}from"./chunk-A77UW7FO.js";import{b}from"./chunk-42OX77TJ.js";import{a as k,b as d}from"./chunk-66L52RDS.js";var f=(t=>(t.SYMBOL="icrc1:symbol",t.NAME="icrc1:name",t.DECIMALS="icrc1:decimals",t.FEE="icrc1:fee",t.LOGO="icrc1:logo",t))(f||{});import{Principal as s}from"@dfinity/principal";import{bigEndianCrc32 as x,encodeBase32 as l,hexStringToUint8Array as g,isNullish as a,notEmptyString as y,uint8ArrayToHexString as A}from"@dfinity/utils";var I=64,E=({owner:r,subaccount:e})=>{if(a(e))return r.toText();let n=(i=>i.replace(/^0+/,""))(A(Uint8Array.from(e)));return n.length===0?r.toText():`${r.toText()}-${p({owner:r,subaccount:e})}.${n}`},p=({owner:r,subaccount:e})=>{let o=x(Uint8Array.from([...r.toUint8Array(),...e]));return l(o)},L=r=>{let[e,o]=r.split(".");if(!y(e))throw new Error("Invalid account. No string provided.");if(a(o))return{owner:s.fromText(r)};let[n,...i]=e.split("-").reverse(),t=i.reverse().join("-"),c={owner:s.fromText(t),subaccount:g(o.padStart(I,"0"))};if(p(c)!==n)throw new Error("Invalid account. Invalid checksum.");return c};import{isNullish as T,nonNullish as h}from"@dfinity/utils";var B=r=>{let e=/^([a-zA-Z]+):([A-Za-z0-9:\-.]+).*?(?:[?&](?:amount|value)=(\d+(?:\.\d+)?))?$/,o=r.match(e);if(T(o))return;let[n,i,t,c]=o;return{token:i,identifier:t,...h(c)&&!isNaN(parseFloat(c))&&{amount:parseFloat(c)}}};export{u as IcrcIndexCanister,m as IcrcIndexNgCanister,d as IcrcLedgerCanister,f as IcrcMetadataResponseEntries,k as IcrcTransferError,b as IndexError,L as decodeIcrcAccount,B as decodePayment,E as encodeIcrcAccount};
1
+ import{a as m}from"./chunk-ZAZML4GO.js";import"./chunk-6GLYJI63.js";import{a as u}from"./chunk-A77UW7FO.js";import{b}from"./chunk-42OX77TJ.js";import{a as k,b as N,c as v,d as C,e as E,f as L,g as U,h as _,i as B,j as V,k as w,l as f}from"./chunk-ZI5B523L.js";var x=(t=>(t.SYMBOL="icrc1:symbol",t.NAME="icrc1:name",t.DECIMALS="icrc1:decimals",t.FEE="icrc1:fee",t.LOGO="icrc1:logo",t))(x||{});import{Principal as s}from"@dfinity/principal";import{bigEndianCrc32 as d,encodeBase32 as l,hexStringToUint8Array as g,isNullish as a,notEmptyString as y,uint8ArrayToHexString as A}from"@dfinity/utils";var I=64,Z=({owner:r,subaccount:e})=>{if(a(e))return r.toText();let n=(i=>i.replace(/^0+/,""))(A(Uint8Array.from(e)));return n.length===0?r.toText():`${r.toText()}-${p({owner:r,subaccount:e})}.${n}`},p=({owner:r,subaccount:e})=>{let o=d(Uint8Array.from([...r.toUint8Array(),...e]));return l(o)},$=r=>{let[e,o]=r.split(".");if(!y(e))throw new Error("Invalid account. No string provided.");if(a(o))return{owner:s.fromText(r)};let[n,...i]=e.split("-").reverse(),t=i.reverse().join("-"),c={owner:s.fromText(t),subaccount:g(o.padStart(I,"0"))};if(p(c)!==n)throw new Error("Invalid account. Invalid checksum.");return c};import{isNullish as T,nonNullish as h}from"@dfinity/utils";var G=r=>{let e=/^([a-zA-Z]+):([A-Za-z0-9:\-.]+).*?(?:[?&](?:amount|value)=(\d+(?:\.\d+)?))?$/,o=r.match(e);if(T(o))return;let[n,i,t,c]=o;return{token:i,identifier:t,...h(c)&&!isNaN(parseFloat(c))&&{amount:parseFloat(c)}}};export{U as ConsentMessageError,V as ConsentMessageUnavailableError,L as GenericError,u as IcrcIndexCanister,m as IcrcIndexNgCanister,f as IcrcLedgerCanister,x as IcrcMetadataResponseEntries,E as IcrcTransferError,b as IndexError,_ as InsufficientPaymentError,B as UnsupportedCanisterCallError,$ as decodeIcrcAccount,G as decodePayment,Z as encodeIcrcAccount,w as mapIcrc21ConsentMessageError,v as toApproveArgs,C as toIcrc21ConsentMessageArgs,k as toTransferArg,N as toTransferFromArgs};
2
2
  //# sourceMappingURL=index.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/types/ledger.responses.ts", "../../src/utils/ledger.utils.ts", "../../src/utils/payment.utils.ts"],
4
4
  "sourcesContent": ["import type { Principal } from \"@dfinity/principal\";\nimport type { Subaccount, Value } from \"../../candid/icrc_ledger\";\n\n// Source: https://github.com/dfinity/icrc-1#standard-metadata-entries\nexport enum IcrcMetadataResponseEntries {\n SYMBOL = \"icrc1:symbol\",\n NAME = \"icrc1:name\",\n DECIMALS = \"icrc1:decimals\",\n FEE = \"icrc1:fee\",\n LOGO = \"icrc1:logo\",\n}\n\nexport type IcrcTokenMetadataResponse = [\n string | IcrcMetadataResponseEntries,\n Value,\n][];\n\nexport interface IcrcAccount {\n owner: Principal;\n subaccount?: Subaccount;\n}\n", "import { Principal } from \"@dfinity/principal\";\nimport {\n bigEndianCrc32,\n encodeBase32,\n hexStringToUint8Array,\n isNullish,\n notEmptyString,\n uint8ArrayToHexString,\n} from \"@dfinity/utils\";\nimport type { IcrcAccount } from \"../types/ledger.responses\";\n\nconst MAX_SUBACCOUNT_HEX_LENGTH = 64;\n\n/**\n * Encodes an Icrc-1 account compatible into a string.\n * Formatting Reference: https://github.com/dfinity/ICRC-1/blob/main/standards/ICRC-1/TextualEncoding.md\n *\n * @param account { owner: Principal, subaccount?: Uint8Array }\n * @returns string\n */\nexport const encodeIcrcAccount = ({\n owner,\n subaccount,\n}: IcrcAccount): string => {\n if (isNullish(subaccount)) {\n return owner.toText();\n }\n\n const removeLeadingZeros = (text: string): string => text.replace(/^0+/, \"\");\n\n const subaccountText = removeLeadingZeros(\n uint8ArrayToHexString(Uint8Array.from(subaccount)),\n );\n\n if (subaccountText.length === 0) {\n return owner.toText();\n }\n\n return `${owner.toText()}-${encodeCrc({\n owner,\n subaccount,\n })}.${subaccountText}`;\n};\n\nconst encodeCrc = ({ owner, subaccount }: Required<IcrcAccount>): string => {\n const crc = bigEndianCrc32(\n Uint8Array.from([...owner.toUint8Array(), ...subaccount]),\n );\n\n return encodeBase32(crc);\n};\n\n/**\n * Decodes a string into an Icrc-1 compatible account.\n * Formatting Reference: https://github.com/dfinity/ICRC-1/blob/main/standards/ICRC-1/TextualEncoding.md\n *\n * @param accountString string\n * @throws Error if the string is not a valid Icrc-1 account\n * @returns IcrcAccount { owner: Principal, subaccount?: Uint8Array }\n */\nexport const decodeIcrcAccount = (accountString: string): IcrcAccount => {\n const [principalAndMaybeCheckSum, subaccountHex] = accountString.split(\".\");\n\n if (!notEmptyString(principalAndMaybeCheckSum)) {\n throw new Error(\"Invalid account. No string provided.\");\n }\n\n if (isNullish(subaccountHex)) {\n return {\n owner: Principal.fromText(accountString),\n };\n }\n\n const [checksum, ...rest] = principalAndMaybeCheckSum.split(\"-\").reverse();\n const principalText = rest.reverse().join(\"-\");\n\n const account = {\n owner: Principal.fromText(principalText),\n subaccount: hexStringToUint8Array(\n subaccountHex.padStart(MAX_SUBACCOUNT_HEX_LENGTH, \"0\"),\n ),\n };\n\n const crcText = encodeCrc(account);\n\n if (crcText !== checksum) {\n throw new Error(\"Invalid account. Invalid checksum.\");\n }\n\n return account;\n};\n", "import { isNullish, nonNullish } from \"@dfinity/utils\";\n\n/**\n * \uD83D\uDC40 This feature is currently in draft. You can find more information about it at https://github.com/dfinity/ICRC/issues/22.\n *\n * A naive implementation of a payment parser. Given a code, the function attempts to extract a token name, account identifier (textual representation), and an optional amount.\n *\n * If the code doesn't match the expected pattern, `undefined` is returned for simplicity.\n * Similarly, if an optional amount is provided but it's not a valid number, the parser will not throw an exception and returns `undefined`.\n *\n * Please note that this function doesn't perform any validity checks on the extracted information.\n * It does not verify if the token is known or if the identifier is a valid address.\n *\n * ```\n * urn = token \":\" address [ \"?\" params]\n * token = [ ckbtc / icp / chat / bitcoin / ethereum ... ]\n * address = STRING\n * params = param [ \"&\" params ]\n * param = [ amountparam ]\n * amountparam = \"amount=\" *digit [ \".\" *digit ]\n * ```\n *\n * @param code string\n * @returns { token: string; identifier: string; amount?: number } | undefined\n */\nexport const decodePayment = (\n code: string,\n): { token: string; identifier: string; amount?: number } | undefined => {\n const regex =\n /^([a-zA-Z]+):([A-Za-z0-9:\\-.]+).*?(?:[?&](?:amount|value)=(\\d+(?:\\.\\d+)?))?$/;\n\n const match = code.match(regex);\n if (isNullish(match)) {\n return undefined;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const [_, token, identifier, amount] = match;\n\n return {\n token,\n identifier,\n ...(nonNullish(amount) &&\n !isNaN(parseFloat(amount)) && { amount: parseFloat(amount) }),\n };\n};\n"],
5
- "mappings": "8LAIO,IAAKA,OACVA,EAAA,OAAS,eACTA,EAAA,KAAO,aACPA,EAAA,SAAW,iBACXA,EAAA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EAAqBC,GAAuC,CACvE,GAAM,CAACC,EAA2BC,CAAa,EAAIF,EAAc,MAAM,GAAG,EAE1E,GAAI,CAACX,EAAeY,CAAyB,EAC3C,MAAM,IAAI,MAAM,sCAAsC,EAGxD,GAAIb,EAAUc,CAAa,EACzB,MAAO,CACL,MAAOlB,EAAU,SAASgB,CAAa,CACzC,EAGF,GAAM,CAACG,EAAU,GAAGC,CAAI,EAAIH,EAA0B,MAAM,GAAG,EAAE,QAAQ,EACnEI,EAAgBD,EAAK,QAAQ,EAAE,KAAK,GAAG,EAEvCE,EAAU,CACd,MAAOtB,EAAU,SAASqB,CAAa,EACvC,WAAYlB,EACVe,EAAc,SAASX,EAA2B,GAAG,CACvD,CACF,EAIA,GAFgBM,EAAUS,CAAO,IAEjBH,EACd,MAAM,IAAI,MAAM,oCAAoC,EAGtD,OAAOG,CACT,EC1FA,OAAS,aAAAC,EAAW,cAAAC,MAAkB,iBAyB/B,IAAMC,EACXC,GACuE,CACvE,IAAMC,EACJ,+EAEIC,EAAQF,EAAK,MAAMC,CAAK,EAC9B,GAAIJ,EAAUK,CAAK,EACjB,OAIF,GAAM,CAACC,EAAGC,EAAOC,EAAYC,CAAM,EAAIJ,EAEvC,MAAO,CACL,MAAAE,EACA,WAAAC,EACA,GAAIP,EAAWQ,CAAM,GACnB,CAAC,MAAM,WAAWA,CAAM,CAAC,GAAK,CAAE,OAAQ,WAAWA,CAAM,CAAE,CAC/D,CACF",
6
6
  "names": ["IcrcMetadataResponseEntries", "Principal", "bigEndianCrc32", "encodeBase32", "hexStringToUint8Array", "isNullish", "notEmptyString", "uint8ArrayToHexString", "MAX_SUBACCOUNT_HEX_LENGTH", "encodeIcrcAccount", "owner", "subaccount", "subaccountText", "text", "encodeCrc", "crc", "decodeIcrcAccount", "accountString", "principalAndMaybeCheckSum", "subaccountHex", "checksum", "rest", "principalText", "account", "isNullish", "nonNullish", "decodePayment", "code", "regex", "match", "_", "token", "identifier", "amount"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{b as a}from"./chunk-66L52RDS.js";export{a as IcrcLedgerCanister};
1
+ import{l as a}from"./chunk-ZI5B523L.js";export{a as IcrcLedgerCanister};
2
2
  //# sourceMappingURL=ledger.canister.js.map
@@ -1,5 +1,6 @@
1
- import type { ApproveArgs, TransferArg, TransferFromArgs } from "../../candid/icrc_ledger";
2
- import type { ApproveParams, TransferFromParams, TransferParams } from "../types/ledger.params";
1
+ import type { ApproveArgs, icrc21_consent_message_request as ConsentMessageArgs, TransferArg, TransferFromArgs } from "../../candid/icrc_ledger";
2
+ import type { ApproveParams, Icrc21ConsentMessageParams, TransferFromParams, TransferParams } from "../types/ledger.params";
3
3
  export declare const toTransferArg: ({ from_subaccount, fee, created_at_time, memo, ...rest }: TransferParams) => TransferArg;
4
4
  export declare const toTransferFromArgs: ({ spender_subaccount, fee, created_at_time, memo, ...rest }: TransferFromParams) => TransferFromArgs;
5
5
  export declare const toApproveArgs: ({ fee, created_at_time, memo, from_subaccount, expected_allowance, expires_at, ...rest }: ApproveParams) => ApproveArgs;
6
+ export declare const toIcrc21ConsentMessageArgs: ({ userPreferences: { metadata: { utcOffsetMinutes, language }, deriveSpec, }, ...rest }: Icrc21ConsentMessageParams) => ConsentMessageArgs;
@@ -1,3 +1,4 @@
1
+ import type { icrc21_error as Icrc21RawError } from "../../candid/icrc_ledger";
1
2
  export declare class IcrcTransferError<T> extends Error {
2
3
  errorType: T;
3
4
  constructor({ msg, errorType }: {
@@ -5,3 +6,17 @@ export declare class IcrcTransferError<T> extends Error {
5
6
  errorType: T;
6
7
  });
7
8
  }
9
+ export declare class GenericError extends Error {
10
+ readonly message: string;
11
+ readonly error_code: bigint;
12
+ constructor(message: string, error_code: bigint);
13
+ }
14
+ export declare class ConsentMessageError extends Error {
15
+ }
16
+ export declare class InsufficientPaymentError extends ConsentMessageError {
17
+ }
18
+ export declare class UnsupportedCanisterCallError extends ConsentMessageError {
19
+ }
20
+ export declare class ConsentMessageUnavailableError extends ConsentMessageError {
21
+ }
22
+ export declare const mapIcrc21ConsentMessageError: (rawError: Icrc21RawError) => ConsentMessageError;
@@ -1,4 +1,5 @@
1
1
  export type { BlockIndex as IcrcBlockIndex, Subaccount as IcrcSubaccount, Tokens as IcrcTokens, TransferArg as IcrcTransferArg, TransferError as IcrcTransferVariatError, Value as IcrcValue, } from "../candid/icrc_ledger";
2
+ export * from "./converters/ledger.converters";
2
3
  export * from "./errors/index.errors";
3
4
  export * from "./errors/ledger.errors";
4
5
  export { IcrcIndexNgCanister } from "./index-ng.canister";
@@ -1,8 +1,8 @@
1
1
  import type { QueryParams } from "@dfinity/utils";
2
2
  import { Canister } from "@dfinity/utils";
3
- import type { Allowance, BlockIndex, _SERVICE as IcrcLedgerService, Tokens } from "../candid/icrc_ledger";
3
+ import type { Allowance, BlockIndex, _SERVICE as IcrcLedgerService, Tokens, icrc21_consent_info } from "../candid/icrc_ledger";
4
4
  import type { IcrcLedgerCanisterOptions } from "./types/canister.options";
5
- import type { AllowanceParams, ApproveParams, BalanceParams, TransferFromParams, TransferParams } from "./types/ledger.params";
5
+ import type { AllowanceParams, ApproveParams, BalanceParams, Icrc21ConsentMessageParams, TransferFromParams, TransferParams } from "./types/ledger.params";
6
6
  import type { IcrcTokenMetadataResponse } from "./types/ledger.responses";
7
7
  export declare class IcrcLedgerCanister extends Canister<IcrcLedgerService> {
8
8
  static create(options: IcrcLedgerCanisterOptions<IcrcLedgerService>): IcrcLedgerCanister;
@@ -65,4 +65,18 @@ export declare class IcrcLedgerCanister extends Canister<IcrcLedgerService> {
65
65
  * @returns {Allowance} The token allowance. If there is no active approval, the ledger MUST return `{ allowance = 0; expires_at = null }`.
66
66
  */
67
67
  allowance: (params: AllowanceParams) => Promise<Allowance>;
68
+ /**
69
+ * Fetches the consent message for a specified canister call, intended to provide a human-readable message that helps users make informed decisions.
70
+ *
71
+ * @link: https://github.com/dfinity/wg-identity-authentication/blob/main/topics/ICRC-21/icrc_21_consent_msg.md
72
+ *
73
+ * @param {Icrc21ConsentMessageParams} params - The request parameters containing the method name, arguments, and consent preferences (e.g., language).
74
+ * @returns {Promise<icrc21_consent_info>} - A promise that resolves to the consent message response, which includes the consent message in the specified language and other related information.
75
+ *
76
+ * @throws {InsufficientPaymentError} - This error is reserved for future use, in case payment extensions are introduced. For example, if consent messages, which are currently free, begin to require payments.
77
+ * @throws {UnsupportedCanisterCallError} - If the specified canister call is not supported.
78
+ * @throws {ConsentMessageUnavailableError} - If there is no consent message available.
79
+ * @throws {GenericError} - For any other generic errors.
80
+ */
81
+ consentMessage: (params: Icrc21ConsentMessageParams) => Promise<icrc21_consent_info>;
68
82
  }
@@ -1,5 +1,5 @@
1
1
  import type { QueryParams } from "@dfinity/utils";
2
- import type { Account, AllowanceArgs, Subaccount, Timestamp, Tokens } from "../../candid/icrc_ledger";
2
+ import type { Account, AllowanceArgs, icrc21_consent_message_request as ConsentMessageArgs, Subaccount, Timestamp, Tokens } from "../../candid/icrc_ledger";
3
3
  import type { IcrcAccount } from "./ledger.responses";
4
4
  /**
5
5
  * Params to get the balance of an ICRC-1 account.
@@ -61,3 +61,48 @@ export type ApproveParams = Omit<TransferParams, "to"> & {
61
61
  * Params to get the token allowance that the spender account can transfer from the specified account
62
62
  */
63
63
  export type AllowanceParams = AllowanceArgs & QueryParams;
64
+ /**
65
+ * Metadata for the consent message in ICRC-21 specification.
66
+ * @param {number} [utcOffsetMinutes] - The user's local timezone offset in minutes from UTC. If absent, the default is UTC.
67
+ * @param {string} language - BCP-47 language tag. See https://www.rfc-editor.org/rfc/bcp/bcp47.txt
68
+ */
69
+ export type Icrc21ConsentMessageMetadata = {
70
+ utcOffsetMinutes?: number;
71
+ language: string;
72
+ };
73
+ /**
74
+ * Device specification for displaying the consent message.
75
+ *
76
+ * @param {null} [GenericDisplay] - A generic display able to handle large documents and do line wrapping and pagination / scrolling. Text must be Markdown formatted, no external resources (e.g. images) are allowed.
77
+ * @param {Object} [LineDisplay] - Simple display able to handle lines of text with a maximum number of characters per line.
78
+ * @param {number} LineDisplay.charactersPerLine - Maximum number of characters that can be displayed per line.
79
+ * @param {number} LineDisplay.linesPerPage - Maximum number of lines that can be displayed at once on a single page.
80
+ */
81
+ export type Icrc21ConsentMessageDeviceSpec = {
82
+ GenericDisplay: null;
83
+ } | {
84
+ LineDisplay: {
85
+ charactersPerLine: number;
86
+ linesPerPage: number;
87
+ };
88
+ };
89
+ /**
90
+ * Specification for the consent message, including metadata and device preferences.
91
+ *
92
+ * @param {Icrc21ConsentMessageMetadata} metadata - Metadata of the consent message.
93
+ * @param {Icrc21ConsentMessageDeviceSpec} [deviceSpec] - Information about the device responsible for presenting the consent message to the user.
94
+ */
95
+ export type Icrc21ConsentMessageSpec = {
96
+ metadata: Icrc21ConsentMessageMetadata;
97
+ deriveSpec?: Icrc21ConsentMessageDeviceSpec;
98
+ };
99
+ /**
100
+ * Parameters for the consent message request.
101
+ *
102
+ * @param {string} method - Method name of the canister call.
103
+ * @param {Uint8Array} arg - Argument of the canister call.
104
+ * @param {Icrc21ConsentMessageSpec} userPreferences - User preferences with regards to the consent message presented to the end-user.
105
+ */
106
+ export type Icrc21ConsentMessageParams = Omit<ConsentMessageArgs, "user_preferences"> & {
107
+ userPreferences: Icrc21ConsentMessageSpec;
108
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dfinity/ledger-icrc",
3
- "version": "2.5.0",
3
+ "version": "2.6.0",
4
4
  "description": "A library for interfacing with ICRC ledgers on the Internet Computer.",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/cjs/index.cjs.js",
@@ -37,9 +37,9 @@
37
37
  ],
38
38
  "homepage": "https://github.com/dfinity/ic-js#readme",
39
39
  "peerDependencies": {
40
- "@dfinity/agent": "^2.0.0",
41
- "@dfinity/candid": "^2.0.0",
42
- "@dfinity/principal": "^2.0.0",
43
- "@dfinity/utils": "^2.5.0"
40
+ "@dfinity/agent": "^2.1.2",
41
+ "@dfinity/candid": "^2.1.2",
42
+ "@dfinity/principal": "^2.1.2",
43
+ "@dfinity/utils": "^2.5.1"
44
44
  }
45
45
  }
@@ -1,2 +0,0 @@
1
- import{Canister as pe,createServices as de,toNullable as me}from"@dfinity/utils";var ae=({IDL:e})=>{let s=e.Rec(),r=e.Rec(),c=e.Rec(),_=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)}),l=e.Variant({Int:e.Int,Nat:e.Nat,Blob:e.Vec(e.Nat8),Text:e.Text}),d=e.Vec(e.Nat8),t=e.Record({owner:e.Principal,subaccount:e.Opt(d)}),x=e.Variant({SetTo:t,Unset:e.Null}),N=e.Record({icrc2:e.Bool}),V=e.Record({change_archive_options:e.Opt(_),token_symbol:e.Opt(e.Text),transfer_fee:e.Opt(e.Nat),metadata:e.Opt(e.Vec(e.Tuple(e.Text,l))),accounts_overflow_trim_quantity:e.Opt(e.Nat64),change_fee_collector:e.Opt(x),max_memo_length:e.Opt(e.Nat16),token_name:e.Opt(e.Text),feature_flags:e.Opt(N)}),y=e.Record({decimals:e.Opt(e.Nat8),token_symbol:e.Text,transfer_fee:e.Nat,metadata:e.Vec(e.Tuple(e.Text,l)),minting_account:t,initial_balances:e.Vec(e.Tuple(t,e.Nat)),maximum_number_of_accounts:e.Opt(e.Nat64),accounts_overflow_trim_quantity:e.Opt(e.Nat64),fee_collector_account:e.Opt(t),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),token_name:e.Text,feature_flags:e.Opt(N)}),le=e.Variant({Upgrade:e.Opt(V),Init:y}),n=e.Nat,h=e.Record({block_range_end:n,canister_id:e.Principal,block_range_start:n}),p=e.Record({start:n,length:e.Nat}),b=e.Vec(e.Tuple(e.Text,c));c.fill(e.Variant({Int:e.Int,Map:b,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(c)}));let O=c,F=e.Record({blocks:e.Vec(O)}),v=e.Func([p],[F],[]),k=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),first_index:n,blocks:e.Vec(O),chain_length:e.Nat64,archived_blocks:e.Vec(e.Record({callback:v,start:n,length:e.Nat}))}),A=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),hash_tree:e.Vec(e.Nat8)}),m=e.Nat,g=e.Record({start:m,length:e.Nat}),a=e.Nat64,P=e.Record({from:t,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(a),amount:e.Nat,spender:e.Opt(t)}),w=e.Record({to:t,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(a),amount:e.Nat}),B=e.Record({fee:e.Opt(e.Nat),from:t,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(a),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(a),spender:t}),C=e.Record({to:t,fee:e.Opt(e.Nat),from:t,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(a),amount:e.Nat,spender:e.Opt(t)}),T=e.Record({burn:e.Opt(P),kind:e.Text,mint:e.Opt(w),approve:e.Opt(B),timestamp:a,transfer:e.Opt(C)}),q=e.Record({transactions:e.Vec(T)}),E=e.Func([g],[q],[]),G=e.Record({first_index:m,log_length:e.Nat,transactions:e.Vec(T),archived_transactions:e.Vec(e.Record({callback:E,start:m,length:e.Nat}))}),o=e.Nat,U=e.Record({url:e.Text,name:e.Text}),M=e.Record({to:t,fee:e.Opt(o),memo:e.Opt(e.Vec(e.Nat8)),from_subaccount:e.Opt(d),created_at_time:e.Opt(a),amount:o}),S=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,BadBurn:e.Record({min_burn_amount:o}),Duplicate:e.Record({duplicate_of:n}),BadFee:e.Record({expected_fee:o}),CreatedInFuture:e.Record({ledger_time:a}),TooOld:e.Null,InsufficientFunds:e.Record({balance:o})}),z=e.Variant({Ok:n,Err:S}),R=e.Record({utc_offset_minutes:e.Opt(e.Int16),language:e.Text}),Q=e.Record({metadata:R,device_spec:e.Opt(e.Variant({GenericDisplay:e.Null,LineDisplay:e.Record({characters_per_line:e.Nat16,lines_per_page:e.Nat16})}))}),j=e.Record({arg:e.Vec(e.Nat8),method:e.Text,user_preferences:Q}),H=e.Variant({LineDisplayMessage:e.Record({pages:e.Vec(e.Record({lines:e.Vec(e.Text)}))}),GenericDisplayMessage:e.Text}),J=e.Record({metadata:R,consent_message:H}),u=e.Record({description:e.Text}),K=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),InsufficientPayment:u,UnsupportedCanisterCall:u,ConsentMessageUnavailable:u}),W=e.Variant({Ok:J,Err:K}),X=e.Record({account:t,spender:t}),Y=e.Record({allowance:e.Nat,expires_at:e.Opt(a)}),Z=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(a),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(a),spender:t}),$=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,Duplicate:e.Record({duplicate_of:n}),BadFee:e.Record({expected_fee:e.Nat}),AllowanceChanged:e.Record({current_allowance:e.Nat}),CreatedInFuture:e.Record({ledger_time:a}),TooOld:e.Null,Expired:e.Record({ledger_time:a}),InsufficientFunds:e.Record({balance:e.Nat})}),I=e.Variant({Ok:n,Err:$}),D=e.Record({to:t,fee:e.Opt(o),spender_subaccount:e.Opt(d),from:t,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(a),amount:o}),L=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,InsufficientAllowance:e.Record({allowance:o}),BadBurn:e.Record({min_burn_amount:o}),Duplicate:e.Record({duplicate_of:n}),BadFee:e.Record({expected_fee:o}),CreatedInFuture:e.Record({ledger_time:a}),TooOld:e.Null,InsufficientFunds:e.Record({balance:o})}),ee=e.Variant({Ok:n,Err:L}),te=e.Record({from:e.Opt(e.Principal)}),re=e.Vec(e.Record({end:e.Nat,canister_id:e.Principal,start:e.Nat}));r.fill(e.Variant({Int:e.Int,Map:e.Vec(e.Tuple(e.Text,r)),Nat:e.Nat,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(r)})),s.fill(e.Record({log_length:e.Nat,blocks:e.Vec(e.Record({id:e.Nat,block:r})),archived_blocks:e.Vec(e.Record({args:e.Vec(p),callback:e.Func([e.Vec(p)],[s],[])}))}));let ce=e.Record({certificate:e.Vec(e.Nat8),hash_tree:e.Vec(e.Nat8)});return e.Service({archives:e.Func([],[e.Vec(h)],[]),get_blocks:e.Func([p],[k],[]),get_data_certificate:e.Func([],[A],[]),get_transactions:e.Func([g],[G],[]),icrc10_supported_standards:e.Func([],[e.Vec(e.Record({url:e.Text,name:e.Text}))],[]),icrc1_balance_of:e.Func([t],[o],[]),icrc1_decimals:e.Func([],[e.Nat8],[]),icrc1_fee:e.Func([],[o],[]),icrc1_metadata:e.Func([],[e.Vec(e.Tuple(e.Text,l))],[]),icrc1_minting_account:e.Func([],[e.Opt(t)],[]),icrc1_name:e.Func([],[e.Text],[]),icrc1_supported_standards:e.Func([],[e.Vec(U)],[]),icrc1_symbol:e.Func([],[e.Text],[]),icrc1_total_supply:e.Func([],[o],[]),icrc1_transfer:e.Func([M],[z],[]),icrc21_canister_call_consent_message:e.Func([j],[W],[]),icrc2_allowance:e.Func([X],[Y],[]),icrc2_approve:e.Func([Z],[I],[]),icrc2_transfer_from:e.Func([D],[ee],[]),icrc3_get_archives:e.Func([te],[re],[]),icrc3_get_blocks:e.Func([e.Vec(p)],[s],[]),icrc3_get_tip_certificate:e.Func([],[e.Opt(ce)],[]),icrc3_supported_block_types:e.Func([],[e.Vec(e.Record({url:e.Text,block_type:e.Text}))],[])})};var oe=({IDL:e})=>{let s=e.Rec(),r=e.Rec(),c=e.Rec(),_=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)}),l=e.Variant({Int:e.Int,Nat:e.Nat,Blob:e.Vec(e.Nat8),Text:e.Text}),d=e.Vec(e.Nat8),t=e.Record({owner:e.Principal,subaccount:e.Opt(d)}),x=e.Variant({SetTo:t,Unset:e.Null}),N=e.Record({icrc2:e.Bool}),V=e.Record({change_archive_options:e.Opt(_),token_symbol:e.Opt(e.Text),transfer_fee:e.Opt(e.Nat),metadata:e.Opt(e.Vec(e.Tuple(e.Text,l))),accounts_overflow_trim_quantity:e.Opt(e.Nat64),change_fee_collector:e.Opt(x),max_memo_length:e.Opt(e.Nat16),token_name:e.Opt(e.Text),feature_flags:e.Opt(N)}),y=e.Record({decimals:e.Opt(e.Nat8),token_symbol:e.Text,transfer_fee:e.Nat,metadata:e.Vec(e.Tuple(e.Text,l)),minting_account:t,initial_balances:e.Vec(e.Tuple(t,e.Nat)),maximum_number_of_accounts:e.Opt(e.Nat64),accounts_overflow_trim_quantity:e.Opt(e.Nat64),fee_collector_account:e.Opt(t),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),token_name:e.Text,feature_flags:e.Opt(N)}),le=e.Variant({Upgrade:e.Opt(V),Init:y}),n=e.Nat,h=e.Record({block_range_end:n,canister_id:e.Principal,block_range_start:n}),p=e.Record({start:n,length:e.Nat}),b=e.Vec(e.Tuple(e.Text,c));c.fill(e.Variant({Int:e.Int,Map:b,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(c)}));let O=c,F=e.Record({blocks:e.Vec(O)}),v=e.Func([p],[F],["query"]),k=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),first_index:n,blocks:e.Vec(O),chain_length:e.Nat64,archived_blocks:e.Vec(e.Record({callback:v,start:n,length:e.Nat}))}),A=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),hash_tree:e.Vec(e.Nat8)}),m=e.Nat,g=e.Record({start:m,length:e.Nat}),a=e.Nat64,P=e.Record({from:t,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(a),amount:e.Nat,spender:e.Opt(t)}),w=e.Record({to:t,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(a),amount:e.Nat}),B=e.Record({fee:e.Opt(e.Nat),from:t,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(a),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(a),spender:t}),C=e.Record({to:t,fee:e.Opt(e.Nat),from:t,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(a),amount:e.Nat,spender:e.Opt(t)}),T=e.Record({burn:e.Opt(P),kind:e.Text,mint:e.Opt(w),approve:e.Opt(B),timestamp:a,transfer:e.Opt(C)}),q=e.Record({transactions:e.Vec(T)}),E=e.Func([g],[q],["query"]),G=e.Record({first_index:m,log_length:e.Nat,transactions:e.Vec(T),archived_transactions:e.Vec(e.Record({callback:E,start:m,length:e.Nat}))}),o=e.Nat,U=e.Record({url:e.Text,name:e.Text}),M=e.Record({to:t,fee:e.Opt(o),memo:e.Opt(e.Vec(e.Nat8)),from_subaccount:e.Opt(d),created_at_time:e.Opt(a),amount:o}),S=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,BadBurn:e.Record({min_burn_amount:o}),Duplicate:e.Record({duplicate_of:n}),BadFee:e.Record({expected_fee:o}),CreatedInFuture:e.Record({ledger_time:a}),TooOld:e.Null,InsufficientFunds:e.Record({balance:o})}),z=e.Variant({Ok:n,Err:S}),R=e.Record({utc_offset_minutes:e.Opt(e.Int16),language:e.Text}),Q=e.Record({metadata:R,device_spec:e.Opt(e.Variant({GenericDisplay:e.Null,LineDisplay:e.Record({characters_per_line:e.Nat16,lines_per_page:e.Nat16})}))}),j=e.Record({arg:e.Vec(e.Nat8),method:e.Text,user_preferences:Q}),H=e.Variant({LineDisplayMessage:e.Record({pages:e.Vec(e.Record({lines:e.Vec(e.Text)}))}),GenericDisplayMessage:e.Text}),J=e.Record({metadata:R,consent_message:H}),u=e.Record({description:e.Text}),K=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),InsufficientPayment:u,UnsupportedCanisterCall:u,ConsentMessageUnavailable:u}),W=e.Variant({Ok:J,Err:K}),X=e.Record({account:t,spender:t}),Y=e.Record({allowance:e.Nat,expires_at:e.Opt(a)}),Z=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(a),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(a),spender:t}),$=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,Duplicate:e.Record({duplicate_of:n}),BadFee:e.Record({expected_fee:e.Nat}),AllowanceChanged:e.Record({current_allowance:e.Nat}),CreatedInFuture:e.Record({ledger_time:a}),TooOld:e.Null,Expired:e.Record({ledger_time:a}),InsufficientFunds:e.Record({balance:e.Nat})}),I=e.Variant({Ok:n,Err:$}),D=e.Record({to:t,fee:e.Opt(o),spender_subaccount:e.Opt(d),from:t,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(a),amount:o}),L=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,InsufficientAllowance:e.Record({allowance:o}),BadBurn:e.Record({min_burn_amount:o}),Duplicate:e.Record({duplicate_of:n}),BadFee:e.Record({expected_fee:o}),CreatedInFuture:e.Record({ledger_time:a}),TooOld:e.Null,InsufficientFunds:e.Record({balance:o})}),ee=e.Variant({Ok:n,Err:L}),te=e.Record({from:e.Opt(e.Principal)}),re=e.Vec(e.Record({end:e.Nat,canister_id:e.Principal,start:e.Nat}));r.fill(e.Variant({Int:e.Int,Map:e.Vec(e.Tuple(e.Text,r)),Nat:e.Nat,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(r)})),s.fill(e.Record({log_length:e.Nat,blocks:e.Vec(e.Record({id:e.Nat,block:r})),archived_blocks:e.Vec(e.Record({args:e.Vec(p),callback:e.Func([e.Vec(p)],[s],["query"])}))}));let ce=e.Record({certificate:e.Vec(e.Nat8),hash_tree:e.Vec(e.Nat8)});return e.Service({archives:e.Func([],[e.Vec(h)],["query"]),get_blocks:e.Func([p],[k],["query"]),get_data_certificate:e.Func([],[A],["query"]),get_transactions:e.Func([g],[G],["query"]),icrc10_supported_standards:e.Func([],[e.Vec(e.Record({url:e.Text,name:e.Text}))],["query"]),icrc1_balance_of:e.Func([t],[o],["query"]),icrc1_decimals:e.Func([],[e.Nat8],["query"]),icrc1_fee:e.Func([],[o],["query"]),icrc1_metadata:e.Func([],[e.Vec(e.Tuple(e.Text,l))],["query"]),icrc1_minting_account:e.Func([],[e.Opt(t)],["query"]),icrc1_name:e.Func([],[e.Text],["query"]),icrc1_supported_standards:e.Func([],[e.Vec(U)],["query"]),icrc1_symbol:e.Func([],[e.Text],["query"]),icrc1_total_supply:e.Func([],[o],["query"]),icrc1_transfer:e.Func([M],[z],[]),icrc21_canister_call_consent_message:e.Func([j],[W],[]),icrc2_allowance:e.Func([X],[Y],["query"]),icrc2_approve:e.Func([Z],[I],[]),icrc2_transfer_from:e.Func([D],[ee],[]),icrc3_get_archives:e.Func([te],[re],["query"]),icrc3_get_blocks:e.Func([e.Vec(p)],[s],["query"]),icrc3_get_tip_certificate:e.Func([],[e.Opt(ce)],["query"]),icrc3_supported_block_types:e.Func([],[e.Vec(e.Record({url:e.Text,block_type:e.Text}))],["query"])})};import{toNullable as i}from"@dfinity/utils";var ne=({from_subaccount:e,fee:s,created_at_time:r,memo:c,..._})=>({..._,fee:i(s),memo:i(c),from_subaccount:i(e),created_at_time:i(r)}),se=({spender_subaccount:e,fee:s,created_at_time:r,memo:c,..._})=>({..._,fee:i(s),memo:i(c),spender_subaccount:i(e),created_at_time:i(r)}),ie=({fee:e,created_at_time:s,memo:r,from_subaccount:c,expected_allowance:_,expires_at:l,...d})=>({...d,fee:i(e),memo:i(r),from_subaccount:i(c),created_at_time:i(s),expected_allowance:i(_),expires_at:i(l)});var f=class extends Error{constructor({msg:s,errorType:r}){super(s),this.errorType=r}};var _e=class e extends pe{constructor(){super(...arguments);this.metadata=r=>this.caller(r).icrc1_metadata();this.transactionFee=r=>this.caller(r).icrc1_fee();this.balance=r=>this.caller({certified:r.certified}).icrc1_balance_of({owner:r.owner,subaccount:me(r.subaccount)});this.transfer=async r=>{let c=await this.caller({certified:!0}).icrc1_transfer(ne(r));if("Err"in c)throw new f({errorType:c.Err,msg:"Failed to transfer"});return c.Ok};this.totalTokensSupply=r=>this.caller(r).icrc1_total_supply();this.transferFrom=async r=>{let c=await this.caller({certified:!0}).icrc2_transfer_from(se(r));if("Err"in c)throw new f({errorType:c.Err,msg:"Failed to transfer from"});return c.Ok};this.approve=async r=>{let c=await this.caller({certified:!0}).icrc2_approve(ie(r));if("Err"in c)throw new f({errorType:c.Err,msg:"Failed to entitle the spender to transfer the amount"});return c.Ok};this.allowance=async r=>{let{certified:c,..._}=r;return this.caller({certified:c}).icrc2_allowance({..._})}}static create(r){let{service:c,certifiedService:_,canisterId:l}=de({options:r,idlFactory:oe,certifiedIdlFactory:ae});return new e(l,c,_)}};export{f as a,_e as b};
2
- //# sourceMappingURL=chunk-66L52RDS.js.map