@dfinity/ledger-icrc 5.0.0 → 5.0.1-next-2025-11-07.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,6 +30,7 @@ export const idlFactory = ({ IDL }) => {
30
30
  });
31
31
  const Tokens = IDL.Nat;
32
32
  const Burn = IDL.Record({
33
+ fee: IDL.Opt(IDL.Nat),
33
34
  from: Account,
34
35
  memo: IDL.Opt(IDL.Vec(IDL.Nat8)),
35
36
  created_at_time: IDL.Opt(IDL.Nat64),
@@ -38,6 +39,7 @@ export const idlFactory = ({ IDL }) => {
38
39
  });
39
40
  const Mint = IDL.Record({
40
41
  to: Account,
42
+ fee: IDL.Opt(IDL.Nat),
41
43
  memo: IDL.Opt(IDL.Vec(IDL.Nat8)),
42
44
  created_at_time: IDL.Opt(IDL.Nat64),
43
45
  amount: Tokens,
@@ -27,6 +27,7 @@ export interface Approve {
27
27
  export type Block = Value;
28
28
  export type BlockIndex = bigint;
29
29
  export interface Burn {
30
+ fee: [] | [bigint];
30
31
  from: Account;
31
32
  memo: [] | [Uint8Array | number[]];
32
33
  created_at_time: [] | [bigint];
@@ -89,6 +90,7 @@ export interface ListSubaccountsArgs {
89
90
  export type Map = Array<[string, Value]>;
90
91
  export interface Mint {
91
92
  to: Account;
93
+ fee: [] | [bigint];
92
94
  memo: [] | [Uint8Array | number[]];
93
95
  created_at_time: [] | [bigint];
94
96
  amount: Tokens;
@@ -1,4 +1,4 @@
1
- // Generated from IC repo commit c211885f7c (2025-10-09) 'rs/ledger_suite/icrc1/index-ng/index-ng.did' by import-candid
1
+ // Generated from IC repo commit 199fb79 (2025-10-29 tags: release-2025-10-30_03-22-base) 'rs/ledger_suite/icrc1/index-ng/index-ng.did' by import-candid
2
2
 
3
3
  type Tokens = nat;
4
4
 
@@ -78,14 +78,16 @@ type Burn = record {
78
78
  memo : opt vec nat8;
79
79
  created_at_time : opt nat64;
80
80
  amount : Tokens;
81
- spender : opt Account
81
+ spender : opt Account;
82
+ fee : opt nat
82
83
  };
83
84
 
84
85
  type Mint = record {
85
86
  to : Account;
86
87
  memo : opt vec nat8;
87
88
  created_at_time : opt nat64;
88
- amount : Tokens
89
+ amount : Tokens;
90
+ fee : opt nat
89
91
  };
90
92
 
91
93
  type Transfer = record {
@@ -30,6 +30,7 @@ export const idlFactory = ({ IDL }) => {
30
30
  });
31
31
  const Tokens = IDL.Nat;
32
32
  const Burn = IDL.Record({
33
+ fee: IDL.Opt(IDL.Nat),
33
34
  from: Account,
34
35
  memo: IDL.Opt(IDL.Vec(IDL.Nat8)),
35
36
  created_at_time: IDL.Opt(IDL.Nat64),
@@ -38,6 +39,7 @@ export const idlFactory = ({ IDL }) => {
38
39
  });
39
40
  const Mint = IDL.Record({
40
41
  to: Account,
42
+ fee: IDL.Opt(IDL.Nat),
41
43
  memo: IDL.Opt(IDL.Vec(IDL.Nat8)),
42
44
  created_at_time: IDL.Opt(IDL.Nat64),
43
45
  amount: Tokens,
@@ -123,6 +123,7 @@ export const idlFactory = ({ IDL }) => {
123
123
  });
124
124
  const Timestamp = IDL.Nat64;
125
125
  const Burn = IDL.Record({
126
+ fee: IDL.Opt(IDL.Nat),
126
127
  from: Account,
127
128
  memo: IDL.Opt(IDL.Vec(IDL.Nat8)),
128
129
  created_at_time: IDL.Opt(Timestamp),
@@ -131,6 +132,7 @@ export const idlFactory = ({ IDL }) => {
131
132
  });
132
133
  const Mint = IDL.Record({
133
134
  to: Account,
135
+ fee: IDL.Opt(IDL.Nat),
134
136
  memo: IDL.Opt(IDL.Vec(IDL.Nat8)),
135
137
  created_at_time: IDL.Opt(Timestamp),
136
138
  amount: IDL.Nat,
@@ -92,6 +92,7 @@ export interface BlockRange {
92
92
  blocks: Array<Block>;
93
93
  }
94
94
  export interface Burn {
95
+ fee: [] | [bigint];
95
96
  from: Account;
96
97
  memo: [] | [Uint8Array | number[]];
97
98
  created_at_time: [] | [Timestamp];
@@ -371,6 +372,7 @@ export type MetadataValue =
371
372
  | { Text: string };
372
373
  export interface Mint {
373
374
  to: Account;
375
+ fee: [] | [bigint];
374
376
  memo: [] | [Uint8Array | number[]];
375
377
  created_at_time: [] | [Timestamp];
376
378
  amount: bigint;
@@ -1,4 +1,4 @@
1
- // Generated from IC repo commit c211885f7c (2025-10-09) 'rs/ledger_suite/icrc1/ledger/ledger.did' by import-candid
1
+ // Generated from IC repo commit 199fb79 (2025-10-29 tags: release-2025-10-30_03-22-base) 'rs/ledger_suite/icrc1/ledger/ledger.did' by import-candid
2
2
 
3
3
  type BlockIndex = nat;
4
4
  type Subaccount = blob;
@@ -235,14 +235,16 @@ type Burn = record {
235
235
  memo : opt blob;
236
236
  created_at_time : opt Timestamp;
237
237
  amount : nat;
238
- spender : opt Account
238
+ spender : opt Account;
239
+ fee : opt nat
239
240
  };
240
241
 
241
242
  type Mint = record {
242
243
  to : Account;
243
244
  memo : opt blob;
244
245
  created_at_time : opt Timestamp;
245
- amount : nat
246
+ amount : nat;
247
+ fee : opt nat
246
248
  };
247
249
 
248
250
  type Transfer = record {
@@ -127,6 +127,7 @@ export const idlFactory = ({ IDL }) => {
127
127
  });
128
128
  const Timestamp = IDL.Nat64;
129
129
  const Burn = IDL.Record({
130
+ fee: IDL.Opt(IDL.Nat),
130
131
  from: Account,
131
132
  memo: IDL.Opt(IDL.Vec(IDL.Nat8)),
132
133
  created_at_time: IDL.Opt(Timestamp),
@@ -135,6 +136,7 @@ export const idlFactory = ({ IDL }) => {
135
136
  });
136
137
  const Mint = IDL.Record({
137
138
  to: Account,
139
+ fee: IDL.Opt(IDL.Nat),
138
140
  memo: IDL.Opt(IDL.Vec(IDL.Nat8)),
139
141
  created_at_time: IDL.Opt(Timestamp),
140
142
  amount: IDL.Nat,
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{fromNullable as Ze,nonNullish as Xe,toNullable as Ye}from"@dfinity/utils";var _t=({owner:e,subaccount:t})=>{let c=Ze(t);return{owner:e,...Xe(c)?{subaccount:c}:{}}},ke=({owner:e,subaccount:t})=>({owner:e,subaccount:Ye(t)});import{isNullish as je,toNullable as m}from"@dfinity/utils";var he=({from_subaccount:e,fee:t,created_at_time:c,memo:r,...i})=>({...i,fee:m(t),memo:m(r),from_subaccount:m(e),created_at_time:m(c)}),Fe=({spender_subaccount:e,fee:t,created_at_time:c,memo:r,...i})=>({...i,fee:m(t),memo:m(r),spender_subaccount:m(e),created_at_time:m(c)}),Pe=({fee:e,created_at_time:t,memo:c,from_subaccount:r,expected_allowance:i,expires_at:n,...d})=>({...d,fee:m(e),memo:m(c),from_subaccount:m(r),created_at_time:m(t),expected_allowance:m(i),expires_at:m(n)}),ve=({userPreferences:{metadata:{utcOffsetMinutes:e,language:t},deriveSpec:c},...r})=>({...r,user_preferences:{metadata:{language:t,utc_offset_minutes:m(e)},device_spec:je(c)?m():m("GenericDisplay"in c?{GenericDisplay:null}:{FieldsDisplay:null})}});var P=class extends Error{};var v=class extends Error{errorType;constructor({msg:t,errorType:c}){super(t),this.errorType=c}},w=class extends Error{constructor(c,r){super();this.message=c;this.error_code=r}},G=class extends Error{},xe=class extends G{},Te=class extends G{},Re=class extends G{},Ge=e=>"GenericError"in e?new w(e.GenericError.description,e.GenericError.error_code):"InsufficientPayment"in e?new xe(e.InsufficientPayment.description):"UnsupportedCanisterCall"in e?new Te(e.UnsupportedCanisterCall.description):"ConsentMessageUnavailable"in e?new Re(e.ConsentMessageUnavailable.description):new G(`Unknown error type ${JSON.stringify(e)}`),ye=class extends Error{},Se=e=>"IndexPrincipalNotSet"in e?new ye("Index principal is not set for this ledger canister."):new w(e.GenericError.description,e.GenericError.error_code);import{createServices as Ie}from"@dfinity/utils";var Ee=({IDL:e})=>{let t=e.Rec(),c=e.Record({ledger_id:e.Opt(e.Principal),retrieve_blocks_from_ledger_interval_seconds:e.Opt(e.Nat64)}),r=e.Record({ledger_id:e.Principal,retrieve_blocks_from_ledger_interval_seconds:e.Opt(e.Nat64)}),i=e.Variant({Upgrade:c,Init:r}),n=e.Nat,d=e.Vec(e.Nat8),a=e.Record({owner:e.Principal,subaccount:e.Opt(d)}),g=e.Record({max_results:e.Nat,start:e.Opt(n),account:a}),p=e.Nat,f=e.Record({from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:p,spender:e.Opt(a)}),N=e.Record({to:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:p}),x=e.Record({fee:e.Opt(p),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:p,expected_allowance:e.Opt(p),expires_at:e.Opt(e.Nat64),spender:a}),s=e.Record({to:a,fee:e.Opt(p),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:p,spender:e.Opt(a)}),u=e.Record({burn:e.Opt(f),kind:e.Text,mint:e.Opt(N),approve:e.Opt(x),timestamp:e.Nat64,transfer:e.Opt(s)}),_=e.Record({id:n,transaction:u}),y=e.Record({balance:p,transactions:e.Vec(_),oldest_tx_id:e.Opt(n)}),T=e.Record({message:e.Text}),V=e.Variant({Ok:y,Err:T}),b=e.Record({start:e.Nat,length:e.Nat}),A=e.Vec(e.Tuple(e.Text,t));t.fill(e.Variant({Int:e.Int,Map:A,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(t)}));let k=t,O=e.Record({blocks:e.Vec(k),chain_length:e.Nat64}),R=e.Record({ranges:e.Vec(e.Tuple(a,e.Vec(e.Tuple(n,n))))}),o=e.Record({owner:e.Principal,start:e.Opt(d)}),h=e.Record({num_blocks_synced:n});return e.Service({get_account_transactions:e.Func([g],[V],[]),get_blocks:e.Func([b],[O],[]),get_fee_collectors_ranges:e.Func([],[R],[]),icrc1_balance_of:e.Func([a],[p],[]),ledger_id:e.Func([],[e.Principal],[]),list_subaccounts:e.Func([o],[e.Vec(d)],[]),status:e.Func([],[h],["query"])})};var we=({IDL:e})=>{let t=e.Rec(),c=e.Record({ledger_id:e.Opt(e.Principal),retrieve_blocks_from_ledger_interval_seconds:e.Opt(e.Nat64)}),r=e.Record({ledger_id:e.Principal,retrieve_blocks_from_ledger_interval_seconds:e.Opt(e.Nat64)}),i=e.Variant({Upgrade:c,Init:r}),n=e.Nat,d=e.Vec(e.Nat8),a=e.Record({owner:e.Principal,subaccount:e.Opt(d)}),g=e.Record({max_results:e.Nat,start:e.Opt(n),account:a}),p=e.Nat,f=e.Record({from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:p,spender:e.Opt(a)}),N=e.Record({to:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:p}),x=e.Record({fee:e.Opt(p),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:p,expected_allowance:e.Opt(p),expires_at:e.Opt(e.Nat64),spender:a}),s=e.Record({to:a,fee:e.Opt(p),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:p,spender:e.Opt(a)}),u=e.Record({burn:e.Opt(f),kind:e.Text,mint:e.Opt(N),approve:e.Opt(x),timestamp:e.Nat64,transfer:e.Opt(s)}),_=e.Record({id:n,transaction:u}),y=e.Record({balance:p,transactions:e.Vec(_),oldest_tx_id:e.Opt(n)}),T=e.Record({message:e.Text}),V=e.Variant({Ok:y,Err:T}),b=e.Record({start:e.Nat,length:e.Nat}),A=e.Vec(e.Tuple(e.Text,t));t.fill(e.Variant({Int:e.Int,Map:A,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(t)}));let k=t,O=e.Record({blocks:e.Vec(k),chain_length:e.Nat64}),R=e.Record({ranges:e.Vec(e.Tuple(a,e.Vec(e.Tuple(n,n))))}),o=e.Record({owner:e.Principal,start:e.Opt(d)}),h=e.Record({num_blocks_synced:n});return e.Service({get_account_transactions:e.Func([g],[V],["query"]),get_blocks:e.Func([b],[O],["query"]),get_fee_collectors_ranges:e.Func([],[R],["query"]),icrc1_balance_of:e.Func([a],[p],["query"]),ledger_id:e.Func([],[e.Principal],["query"]),list_subaccounts:e.Func([o],[e.Vec(d)],["query"]),status:e.Func([],[h],["query"])})};import{Canister as Je,toNullable as Ke}from"@dfinity/utils";var B=class extends Je{balance=t=>this.caller({certified:t.certified}).icrc1_balance_of({owner:t.owner,subaccount:Ke(t.subaccount)})};import{toNullable as Be}from"@dfinity/utils";var C=({account:e,max_results:t,start:c})=>({account:ke(e),max_results:t,start:Be(c)}),Ce=({owner:e,start:t})=>({owner:e,start:Be(t)});var Ve=class e extends B{static create(t){let{service:c,certifiedService:r,canisterId:i}=Ie({options:t,idlFactory:we,certifiedIdlFactory:Ee});return new e(i,c,r)}getTransactions=async({certified:t,...c})=>{let r=await this.caller({certified:t}).get_account_transactions(C(c));if("Err"in r)throw new P(r.Err.message);return r.Ok};ledgerId=t=>{let{ledger_id:c}=this.caller(t);return c()};status=t=>this.caller(t).status();listSubaccounts=({certified:t,...c})=>this.caller({certified:t}).list_subaccounts(Ce(c))};import{Canister as Le,createServices as De}from"@dfinity/utils";var Me=({IDL:e})=>{let t=e.Record({ledger_id:e.Principal}),c=e.Nat,r=e.Record({owner:e.Principal,subaccount:e.Opt(e.Vec(e.Nat8))}),i=e.Record({max_results:e.Nat,start:e.Opt(c),account:r}),n=e.Record({from:r,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,spender:e.Opt(r)}),d=e.Record({to:r,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat}),a=e.Record({fee:e.Opt(e.Nat),from:r,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(e.Nat64),spender:r}),g=e.Record({to:r,fee:e.Opt(e.Nat),from:r,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,spender:e.Opt(r)}),p=e.Record({burn:e.Opt(n),kind:e.Text,mint:e.Opt(d),approve:e.Opt(a),timestamp:e.Nat64,transfer:e.Opt(g)}),f=e.Record({id:c,transaction:p}),N=e.Record({transactions:e.Vec(f),oldest_tx_id:e.Opt(c)}),x=e.Record({message:e.Text}),s=e.Variant({Ok:N,Err:x}),u=e.Vec(e.Nat8),_=e.Record({owner:e.Principal,start:e.Opt(u)});return e.Service({get_account_transactions:e.Func([i],[s],[]),ledger_id:e.Func([],[e.Principal],[]),list_subaccounts:e.Func([_],[e.Vec(u)],[])})};var qe=({IDL:e})=>{let t=e.Record({ledger_id:e.Principal}),c=e.Nat,r=e.Record({owner:e.Principal,subaccount:e.Opt(e.Vec(e.Nat8))}),i=e.Record({max_results:e.Nat,start:e.Opt(c),account:r}),n=e.Record({from:r,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,spender:e.Opt(r)}),d=e.Record({to:r,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat}),a=e.Record({fee:e.Opt(e.Nat),from:r,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(e.Nat64),spender:r}),g=e.Record({to:r,fee:e.Opt(e.Nat),from:r,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,spender:e.Opt(r)}),p=e.Record({burn:e.Opt(n),kind:e.Text,mint:e.Opt(d),approve:e.Opt(a),timestamp:e.Nat64,transfer:e.Opt(g)}),f=e.Record({id:c,transaction:p}),N=e.Record({transactions:e.Vec(f),oldest_tx_id:e.Opt(c)}),x=e.Record({message:e.Text}),s=e.Variant({Ok:N,Err:x}),u=e.Vec(e.Nat8),_=e.Record({owner:e.Principal,start:e.Opt(u)});return e.Service({get_account_transactions:e.Func([i],[s],[]),ledger_id:e.Func([],[e.Principal],["query"]),list_subaccounts:e.Func([_],[e.Vec(u)],["query"])})};var be=class e extends Le{static create(t){let{service:c,certifiedService:r,canisterId:i}=De({options:t,idlFactory:qe,certifiedIdlFactory:Me});return new e(i,c,r)}getTransactions=async t=>{let c=await this.caller({certified:!0}).get_account_transactions(C(t));if("Err"in c)throw new P(c.Err.message);return c.Ok};ledgerId=t=>{let{ledger_id:c}=this.caller(t);return c()}};import{Canister as et,createServices as tt,toNullable as rt}from"@dfinity/utils";var Ue=({IDL:e})=>{let t=e.Rec(),c=e.Rec(),r=e.Rec(),i=e.Record({num_blocks_to_archive:e.Opt(e.Nat64),max_transactions_per_response:e.Opt(e.Nat64),trigger_threshold:e.Opt(e.Nat64),more_controller_ids:e.Opt(e.Vec(e.Principal)),max_message_size_bytes:e.Opt(e.Nat64),cycles_for_archive_creation:e.Opt(e.Nat64),node_max_memory_size_bytes:e.Opt(e.Nat64),controller_id:e.Opt(e.Principal)}),n=e.Variant({Int:e.Int,Nat:e.Nat,Blob:e.Vec(e.Nat8),Text:e.Text}),d=e.Vec(e.Nat8),a=e.Record({owner:e.Principal,subaccount:e.Opt(d)}),g=e.Variant({SetTo:a,Unset:e.Null}),p=e.Record({icrc2:e.Bool}),f=e.Record({change_archive_options:e.Opt(i),token_symbol:e.Opt(e.Text),transfer_fee:e.Opt(e.Nat),metadata:e.Opt(e.Vec(e.Tuple(e.Text,n))),change_fee_collector:e.Opt(g),max_memo_length:e.Opt(e.Nat16),index_principal:e.Opt(e.Principal),token_name:e.Opt(e.Text),feature_flags:e.Opt(p)}),N=e.Record({decimals:e.Opt(e.Nat8),token_symbol:e.Text,transfer_fee:e.Nat,metadata:e.Vec(e.Tuple(e.Text,n)),minting_account:a,initial_balances:e.Vec(e.Tuple(a,e.Nat)),fee_collector_account:e.Opt(a),archive_options:e.Record({num_blocks_to_archive:e.Nat64,max_transactions_per_response:e.Opt(e.Nat64),trigger_threshold:e.Nat64,more_controller_ids:e.Opt(e.Vec(e.Principal)),max_message_size_bytes:e.Opt(e.Nat64),cycles_for_archive_creation:e.Opt(e.Nat64),node_max_memory_size_bytes:e.Opt(e.Nat64),controller_id:e.Principal}),max_memo_length:e.Opt(e.Nat16),index_principal:e.Opt(e.Principal),token_name:e.Text,feature_flags:e.Opt(p)}),x=e.Variant({Upgrade:e.Opt(f),Init:N}),s=e.Nat,u=e.Record({block_range_end:s,canister_id:e.Principal,block_range_start:s}),_=e.Record({start:s,length:e.Nat}),y=e.Vec(e.Tuple(e.Text,r));r.fill(e.Variant({Int:e.Int,Map:y,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(r)}));let T=r,V=e.Record({blocks:e.Vec(T)}),b=e.Func([_],[V],[]),A=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),first_index:s,blocks:e.Vec(T),chain_length:e.Nat64,archived_blocks:e.Vec(e.Record({callback:b,start:s,length:e.Nat}))}),k=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),hash_tree:e.Vec(e.Nat8)}),O=e.Nat,R=e.Record({start:O,length:e.Nat}),o=e.Nat64,h=e.Record({from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,spender:e.Opt(a)}),q=e.Record({to:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat}),U=e.Record({fee:e.Opt(e.Nat),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(o),spender:a}),z=e.Record({to:a,fee:e.Opt(e.Nat),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,spender:e.Opt(a)}),S=e.Record({burn:e.Opt(h),kind:e.Text,mint:e.Opt(q),approve:e.Opt(U),timestamp:o,transfer:e.Opt(z)}),Q=e.Record({transactions:e.Vec(S)}),$=e.Func([R],[Q],[]),H=e.Record({first_index:O,log_length:e.Nat,transactions:e.Vec(S),archived_transactions:e.Vec(e.Record({callback:$,start:O,length:e.Nat}))}),W=e.Record({take:e.Opt(e.Nat),prev_spender:e.Opt(a),from_account:e.Opt(a)}),Z=e.Record({from_account:a,to_spender:a,allowance:e.Nat,expires_at:e.Opt(e.Nat64)}),X=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),AccessDenied:e.Record({reason:e.Text})}),Y=e.Variant({Ok:e.Vec(Z),Err:X}),j=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),IndexPrincipalNotSet:e.Null}),J=e.Variant({Ok:e.Principal,Err:j}),l=e.Nat,K=e.Record({url:e.Text,name:e.Text}),I=e.Record({to:a,fee:e.Opt(l),memo:e.Opt(e.Vec(e.Nat8)),from_subaccount:e.Opt(d),created_at_time:e.Opt(o),amount:l}),L=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,BadBurn:e.Record({min_burn_amount:l}),Duplicate:e.Record({duplicate_of:s}),BadFee:e.Record({expected_fee:l}),CreatedInFuture:e.Record({ledger_time:o}),TooOld:e.Null,InsufficientFunds:e.Record({balance:l})}),D=e.Variant({Ok:s,Err:L}),E=e.Record({utc_offset_minutes:e.Opt(e.Int16),language:e.Text}),ee=e.Record({metadata:E,device_spec:e.Opt(e.Variant({GenericDisplay:e.Null,FieldsDisplay:e.Null}))}),te=e.Record({arg:e.Vec(e.Nat8),method:e.Text,user_preferences:ee}),re=e.Variant({Text:e.Record({content:e.Text}),TokenAmount:e.Record({decimals:e.Nat8,amount:e.Nat64,symbol:e.Text}),TimestampSeconds:e.Record({amount:e.Nat64}),DurationSeconds:e.Record({amount:e.Nat64})}),ce=e.Record({fields:e.Vec(e.Tuple(e.Text,re)),intent:e.Text}),ae=e.Variant({FieldsDisplayMessage:ce,GenericDisplayMessage:e.Text}),ne=e.Record({metadata:E,consent_message:ae}),F=e.Record({description:e.Text}),oe=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),InsufficientPayment:F,UnsupportedCanisterCall:F,ConsentMessageUnavailable:F}),se=e.Variant({Ok:ne,Err:oe}),ie=e.Record({account:a,spender:a}),pe=e.Record({allowance:e.Nat,expires_at:e.Opt(o)}),le=e.Record({fee:e.Opt(e.Nat),memo:e.Opt(e.Vec(e.Nat8)),from_subaccount:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(o),spender:a}),de=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,Duplicate:e.Record({duplicate_of:s}),BadFee:e.Record({expected_fee:e.Nat}),AllowanceChanged:e.Record({current_allowance:e.Nat}),CreatedInFuture:e.Record({ledger_time:o}),TooOld:e.Null,Expired:e.Record({ledger_time:o}),InsufficientFunds:e.Record({balance:e.Nat})}),_e=e.Variant({Ok:s,Err:de}),me=e.Record({to:a,fee:e.Opt(l),spender_subaccount:e.Opt(d),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:l}),ue=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,InsufficientAllowance:e.Record({allowance:l}),BadBurn:e.Record({min_burn_amount:l}),Duplicate:e.Record({duplicate_of:s}),BadFee:e.Record({expected_fee:l}),CreatedInFuture:e.Record({ledger_time:o}),TooOld:e.Null,InsufficientFunds:e.Record({balance:l})}),ge=e.Variant({Ok:s,Err:ue}),fe=e.Record({from:e.Opt(e.Principal)}),Ne=e.Vec(e.Record({end:e.Nat,canister_id:e.Principal,start:e.Nat}));c.fill(e.Variant({Int:e.Int,Map:e.Vec(e.Tuple(e.Text,c)),Nat:e.Nat,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(c)})),t.fill(e.Record({log_length:e.Nat,blocks:e.Vec(e.Record({id:e.Nat,block:c})),archived_blocks:e.Vec(e.Record({args:e.Vec(_),callback:e.Func([e.Vec(_)],[t],["query"])}))}));let Oe=e.Record({certificate:e.Vec(e.Nat8),hash_tree:e.Vec(e.Nat8)});return e.Service({archives:e.Func([],[e.Vec(u)],[]),get_blocks:e.Func([_],[A],[]),get_data_certificate:e.Func([],[k],[]),get_transactions:e.Func([R],[H],[]),icrc103_get_allowances:e.Func([W],[Y],[]),icrc106_get_index_principal:e.Func([],[J],[]),icrc10_supported_standards:e.Func([],[e.Vec(e.Record({url:e.Text,name:e.Text}))],[]),icrc1_balance_of:e.Func([a],[l],[]),icrc1_decimals:e.Func([],[e.Nat8],[]),icrc1_fee:e.Func([],[l],[]),icrc1_metadata:e.Func([],[e.Vec(e.Tuple(e.Text,n))],[]),icrc1_minting_account:e.Func([],[e.Opt(a)],[]),icrc1_name:e.Func([],[e.Text],[]),icrc1_supported_standards:e.Func([],[e.Vec(K)],[]),icrc1_symbol:e.Func([],[e.Text],[]),icrc1_total_supply:e.Func([],[l],[]),icrc1_transfer:e.Func([I],[D],[]),icrc21_canister_call_consent_message:e.Func([te],[se],[]),icrc2_allowance:e.Func([ie],[pe],[]),icrc2_approve:e.Func([le],[_e],[]),icrc2_transfer_from:e.Func([me],[ge],[]),icrc3_get_archives:e.Func([fe],[Ne],[]),icrc3_get_blocks:e.Func([e.Vec(_)],[t],[]),icrc3_get_tip_certificate:e.Func([],[e.Opt(Oe)],[]),icrc3_supported_block_types:e.Func([],[e.Vec(e.Record({url:e.Text,block_type:e.Text}))],[]),is_ledger_ready:e.Func([],[e.Bool],["query"])})};var ze=({IDL:e})=>{let t=e.Rec(),c=e.Rec(),r=e.Rec(),i=e.Record({num_blocks_to_archive:e.Opt(e.Nat64),max_transactions_per_response:e.Opt(e.Nat64),trigger_threshold:e.Opt(e.Nat64),more_controller_ids:e.Opt(e.Vec(e.Principal)),max_message_size_bytes:e.Opt(e.Nat64),cycles_for_archive_creation:e.Opt(e.Nat64),node_max_memory_size_bytes:e.Opt(e.Nat64),controller_id:e.Opt(e.Principal)}),n=e.Variant({Int:e.Int,Nat:e.Nat,Blob:e.Vec(e.Nat8),Text:e.Text}),d=e.Vec(e.Nat8),a=e.Record({owner:e.Principal,subaccount:e.Opt(d)}),g=e.Variant({SetTo:a,Unset:e.Null}),p=e.Record({icrc2:e.Bool}),f=e.Record({change_archive_options:e.Opt(i),token_symbol:e.Opt(e.Text),transfer_fee:e.Opt(e.Nat),metadata:e.Opt(e.Vec(e.Tuple(e.Text,n))),change_fee_collector:e.Opt(g),max_memo_length:e.Opt(e.Nat16),index_principal:e.Opt(e.Principal),token_name:e.Opt(e.Text),feature_flags:e.Opt(p)}),N=e.Record({decimals:e.Opt(e.Nat8),token_symbol:e.Text,transfer_fee:e.Nat,metadata:e.Vec(e.Tuple(e.Text,n)),minting_account:a,initial_balances:e.Vec(e.Tuple(a,e.Nat)),fee_collector_account:e.Opt(a),archive_options:e.Record({num_blocks_to_archive:e.Nat64,max_transactions_per_response:e.Opt(e.Nat64),trigger_threshold:e.Nat64,more_controller_ids:e.Opt(e.Vec(e.Principal)),max_message_size_bytes:e.Opt(e.Nat64),cycles_for_archive_creation:e.Opt(e.Nat64),node_max_memory_size_bytes:e.Opt(e.Nat64),controller_id:e.Principal}),max_memo_length:e.Opt(e.Nat16),index_principal:e.Opt(e.Principal),token_name:e.Text,feature_flags:e.Opt(p)}),x=e.Variant({Upgrade:e.Opt(f),Init:N}),s=e.Nat,u=e.Record({block_range_end:s,canister_id:e.Principal,block_range_start:s}),_=e.Record({start:s,length:e.Nat}),y=e.Vec(e.Tuple(e.Text,r));r.fill(e.Variant({Int:e.Int,Map:y,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(r)}));let T=r,V=e.Record({blocks:e.Vec(T)}),b=e.Func([_],[V],["query"]),A=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),first_index:s,blocks:e.Vec(T),chain_length:e.Nat64,archived_blocks:e.Vec(e.Record({callback:b,start:s,length:e.Nat}))}),k=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),hash_tree:e.Vec(e.Nat8)}),O=e.Nat,R=e.Record({start:O,length:e.Nat}),o=e.Nat64,h=e.Record({from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,spender:e.Opt(a)}),q=e.Record({to:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat}),U=e.Record({fee:e.Opt(e.Nat),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(o),spender:a}),z=e.Record({to:a,fee:e.Opt(e.Nat),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,spender:e.Opt(a)}),S=e.Record({burn:e.Opt(h),kind:e.Text,mint:e.Opt(q),approve:e.Opt(U),timestamp:o,transfer:e.Opt(z)}),Q=e.Record({transactions:e.Vec(S)}),$=e.Func([R],[Q],["query"]),H=e.Record({first_index:O,log_length:e.Nat,transactions:e.Vec(S),archived_transactions:e.Vec(e.Record({callback:$,start:O,length:e.Nat}))}),W=e.Record({take:e.Opt(e.Nat),prev_spender:e.Opt(a),from_account:e.Opt(a)}),Z=e.Record({from_account:a,to_spender:a,allowance:e.Nat,expires_at:e.Opt(e.Nat64)}),X=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),AccessDenied:e.Record({reason:e.Text})}),Y=e.Variant({Ok:e.Vec(Z),Err:X}),j=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),IndexPrincipalNotSet:e.Null}),J=e.Variant({Ok:e.Principal,Err:j}),l=e.Nat,K=e.Record({url:e.Text,name:e.Text}),I=e.Record({to:a,fee:e.Opt(l),memo:e.Opt(e.Vec(e.Nat8)),from_subaccount:e.Opt(d),created_at_time:e.Opt(o),amount:l}),L=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,BadBurn:e.Record({min_burn_amount:l}),Duplicate:e.Record({duplicate_of:s}),BadFee:e.Record({expected_fee:l}),CreatedInFuture:e.Record({ledger_time:o}),TooOld:e.Null,InsufficientFunds:e.Record({balance:l})}),D=e.Variant({Ok:s,Err:L}),E=e.Record({utc_offset_minutes:e.Opt(e.Int16),language:e.Text}),ee=e.Record({metadata:E,device_spec:e.Opt(e.Variant({GenericDisplay:e.Null,FieldsDisplay:e.Null}))}),te=e.Record({arg:e.Vec(e.Nat8),method:e.Text,user_preferences:ee}),re=e.Variant({Text:e.Record({content:e.Text}),TokenAmount:e.Record({decimals:e.Nat8,amount:e.Nat64,symbol:e.Text}),TimestampSeconds:e.Record({amount:e.Nat64}),DurationSeconds:e.Record({amount:e.Nat64})}),ce=e.Record({fields:e.Vec(e.Tuple(e.Text,re)),intent:e.Text}),ae=e.Variant({FieldsDisplayMessage:ce,GenericDisplayMessage:e.Text}),ne=e.Record({metadata:E,consent_message:ae}),F=e.Record({description:e.Text}),oe=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),InsufficientPayment:F,UnsupportedCanisterCall:F,ConsentMessageUnavailable:F}),se=e.Variant({Ok:ne,Err:oe}),ie=e.Record({account:a,spender:a}),pe=e.Record({allowance:e.Nat,expires_at:e.Opt(o)}),le=e.Record({fee:e.Opt(e.Nat),memo:e.Opt(e.Vec(e.Nat8)),from_subaccount:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(o),spender:a}),de=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,Duplicate:e.Record({duplicate_of:s}),BadFee:e.Record({expected_fee:e.Nat}),AllowanceChanged:e.Record({current_allowance:e.Nat}),CreatedInFuture:e.Record({ledger_time:o}),TooOld:e.Null,Expired:e.Record({ledger_time:o}),InsufficientFunds:e.Record({balance:e.Nat})}),_e=e.Variant({Ok:s,Err:de}),me=e.Record({to:a,fee:e.Opt(l),spender_subaccount:e.Opt(d),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:l}),ue=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,InsufficientAllowance:e.Record({allowance:l}),BadBurn:e.Record({min_burn_amount:l}),Duplicate:e.Record({duplicate_of:s}),BadFee:e.Record({expected_fee:l}),CreatedInFuture:e.Record({ledger_time:o}),TooOld:e.Null,InsufficientFunds:e.Record({balance:l})}),ge=e.Variant({Ok:s,Err:ue}),fe=e.Record({from:e.Opt(e.Principal)}),Ne=e.Vec(e.Record({end:e.Nat,canister_id:e.Principal,start:e.Nat}));c.fill(e.Variant({Int:e.Int,Map:e.Vec(e.Tuple(e.Text,c)),Nat:e.Nat,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(c)})),t.fill(e.Record({log_length:e.Nat,blocks:e.Vec(e.Record({id:e.Nat,block:c})),archived_blocks:e.Vec(e.Record({args:e.Vec(_),callback:e.Func([e.Vec(_)],[t],["query"])}))}));let Oe=e.Record({certificate:e.Vec(e.Nat8),hash_tree:e.Vec(e.Nat8)});return e.Service({archives:e.Func([],[e.Vec(u)],["query"]),get_blocks:e.Func([_],[A],["query"]),get_data_certificate:e.Func([],[k],["query"]),get_transactions:e.Func([R],[H],["query"]),icrc103_get_allowances:e.Func([W],[Y],["query"]),icrc106_get_index_principal:e.Func([],[J],["query"]),icrc10_supported_standards:e.Func([],[e.Vec(e.Record({url:e.Text,name:e.Text}))],["query"]),icrc1_balance_of:e.Func([a],[l],["query"]),icrc1_decimals:e.Func([],[e.Nat8],["query"]),icrc1_fee:e.Func([],[l],["query"]),icrc1_metadata:e.Func([],[e.Vec(e.Tuple(e.Text,n))],["query"]),icrc1_minting_account:e.Func([],[e.Opt(a)],["query"]),icrc1_name:e.Func([],[e.Text],["query"]),icrc1_supported_standards:e.Func([],[e.Vec(K)],["query"]),icrc1_symbol:e.Func([],[e.Text],["query"]),icrc1_total_supply:e.Func([],[l],["query"]),icrc1_transfer:e.Func([I],[D],[]),icrc21_canister_call_consent_message:e.Func([te],[se],[]),icrc2_allowance:e.Func([ie],[pe],["query"]),icrc2_approve:e.Func([le],[_e],[]),icrc2_transfer_from:e.Func([me],[ge],[]),icrc3_get_archives:e.Func([fe],[Ne],["query"]),icrc3_get_blocks:e.Func([e.Vec(_)],[t],["query"]),icrc3_get_tip_certificate:e.Func([],[e.Opt(Oe)],["query"]),icrc3_supported_block_types:e.Func([],[e.Vec(e.Record({url:e.Text,block_type:e.Text}))],["query"]),is_ledger_ready:e.Func([],[e.Bool],["query"])})};var Ae=class e extends et{static create(t){let{service:c,certifiedService:r,canisterId:i}=tt({options:t,idlFactory:ze,certifiedIdlFactory:Ue});return new e(i,c,r)}metadata=t=>this.caller(t).icrc1_metadata();transactionFee=t=>this.caller(t).icrc1_fee();balance=t=>this.caller({certified:t.certified}).icrc1_balance_of({owner:t.owner,subaccount:rt(t.subaccount)});transfer=async t=>{let c=await this.caller({certified:!0}).icrc1_transfer(he(t));if("Err"in c)throw new v({errorType:c.Err,msg:"Failed to transfer"});return c.Ok};totalTokensSupply=t=>this.caller(t).icrc1_total_supply();transferFrom=async t=>{let c=await this.caller({certified:!0}).icrc2_transfer_from(Fe(t));if("Err"in c)throw new v({errorType:c.Err,msg:"Failed to transfer from"});return c.Ok};approve=async t=>{let c=await this.caller({certified:!0}).icrc2_approve(Pe(t));if("Err"in c)throw new v({errorType:c.Err,msg:"Failed to entitle the spender to transfer the amount"});return c.Ok};allowance=t=>{let{certified:c,...r}=t;return this.caller({certified:c}).icrc2_allowance({...r})};consentMessage=async t=>{let{icrc21_canister_call_consent_message:c}=this.caller({certified:!0}),r=await c(ve(t));if("Err"in r)throw Ge(r.Err);return r.Ok};getBlocks=t=>this.caller({certified:t.certified}).icrc3_get_blocks(t.args);getIndexPrincipal=async t=>{let{icrc106_get_index_principal:c}=this.caller(t),r=await c();if("Err"in r)throw Se(r.Err);return r.Ok};icrc1SupportedStandards=t=>this.caller(t).icrc1_supported_standards();icrc10SupportedStandards=t=>this.caller(t).icrc10_supported_standards();getMintingAccount=t=>this.caller(t).icrc1_minting_account()};var Qe=(n=>(n.SYMBOL="icrc1:symbol",n.NAME="icrc1:name",n.DECIMALS="icrc1:decimals",n.FEE="icrc1:fee",n.LOGO="icrc1:logo",n))(Qe||{});import{bigEndianCrc32 as ct,encodeBase32 as at,hexStringToUint8Array as nt,isNullish as He,nonNullish as M,notEmptyString as ot,uint8ArrayToHexString as st}from"@dfinity/utils";import{Principal as $e}from"@icp-sdk/core/principal";var it=64,Lt=({owner:e,subaccount:t})=>{if(He(t))return e.toText();let r=(i=>i.replace(/^0+/,""))(st(Uint8Array.from(t)));return r.length===0?e.toText():`${e.toText()}-${We({owner:e,subaccount:t})}.${r}`},We=({owner:e,subaccount:t})=>{let c=ct(Uint8Array.from([...e.toUint8Array(),...t]));return at(c)},Dt=e=>{let[t,c,...r]=e.split(".");if(!ot(t))throw new Error("Invalid account. No string provided.");if(r.length>0)throw new Error("Invalid account string format. Expected at most one '.' separator.");if(He(c))return{owner:$e.fromText(e)};let[i,...n]=t.split("-").reverse(),d=n.reverse().join("-"),a={owner:$e.fromText(d),subaccount:nt(c.padStart(it,"0"))};if(We(a)!==i)throw new Error("Invalid account. Invalid checksum.");return a},er=e=>{let t=e.reduce((r,[i,n])=>{switch(i){case"icrc1:symbol":r={...r,..."Text"in n&&{symbol:n.Text}};break;case"icrc1:name":r={...r,..."Text"in n&&{name:n.Text}};break;case"icrc1:fee":r={...r,..."Nat"in n&&{fee:n.Nat}};break;case"icrc1:decimals":r={...r,..."Nat"in n&&{decimals:Number(n.Nat)}};break;case"icrc1:logo":r={...r,..."Text"in n&&{icon:n.Text}}}return r},{});if((r=>M(r.symbol)&&M(r.name)&&M(r.fee)&&M(r.decimals))(t))return t};import{isNullish as pt,nonNullish as lt}from"@dfinity/utils";var cr=e=>{let t=/^([a-zA-Z]+):([A-Za-z0-9:\-.]+).*?(?:[?&](?:amount|value)=(\d+(?:\.\d+)?))?$/,c=e.match(t);if(pt(c))return;let[r,i,n,d]=c;return{token:i,identifier:n,...lt(d)&&!isNaN(parseFloat(d))&&{amount:parseFloat(d)}}};export{G as ConsentMessageError,Re as ConsentMessageUnavailableError,w as GenericError,be as IcrcIndexCanister,Ve as IcrcIndexNgCanister,Ae as IcrcLedgerCanister,Qe as IcrcMetadataResponseEntries,v as IcrcTransferError,P as IndexError,ye as IndexPrincipalNotSetError,xe as InsufficientPaymentError,Te as UnsupportedCanisterCallError,Dt as decodeIcrcAccount,cr as decodePayment,Lt as encodeIcrcAccount,_t as fromCandidAccount,Se as mapIcrc106GetIndexPrincipalError,Ge as mapIcrc21ConsentMessageError,er as mapTokenMetadata,Pe as toApproveArgs,ke as toCandidAccount,ve as toIcrc21ConsentMessageArgs,he as toTransferArg,Fe as toTransferFromArgs};
1
+ import{fromNullable as Ze,nonNullish as Xe,toNullable as Ye}from"@dfinity/utils";var _t=({owner:e,subaccount:t})=>{let c=Ze(t);return{owner:e,...Xe(c)?{subaccount:c}:{}}},ke=({owner:e,subaccount:t})=>({owner:e,subaccount:Ye(t)});import{isNullish as je,toNullable as m}from"@dfinity/utils";var he=({from_subaccount:e,fee:t,created_at_time:c,memo:r,...i})=>({...i,fee:m(t),memo:m(r),from_subaccount:m(e),created_at_time:m(c)}),Fe=({spender_subaccount:e,fee:t,created_at_time:c,memo:r,...i})=>({...i,fee:m(t),memo:m(r),spender_subaccount:m(e),created_at_time:m(c)}),Pe=({fee:e,created_at_time:t,memo:c,from_subaccount:r,expected_allowance:i,expires_at:n,...d})=>({...d,fee:m(e),memo:m(c),from_subaccount:m(r),created_at_time:m(t),expected_allowance:m(i),expires_at:m(n)}),ve=({userPreferences:{metadata:{utcOffsetMinutes:e,language:t},deriveSpec:c},...r})=>({...r,user_preferences:{metadata:{language:t,utc_offset_minutes:m(e)},device_spec:je(c)?m():m("GenericDisplay"in c?{GenericDisplay:null}:{FieldsDisplay:null})}});var P=class extends Error{};var v=class extends Error{errorType;constructor({msg:t,errorType:c}){super(t),this.errorType=c}},w=class extends Error{constructor(c,r){super();this.message=c;this.error_code=r}},G=class extends Error{},xe=class extends G{},Te=class extends G{},Re=class extends G{},Ge=e=>"GenericError"in e?new w(e.GenericError.description,e.GenericError.error_code):"InsufficientPayment"in e?new xe(e.InsufficientPayment.description):"UnsupportedCanisterCall"in e?new Te(e.UnsupportedCanisterCall.description):"ConsentMessageUnavailable"in e?new Re(e.ConsentMessageUnavailable.description):new G(`Unknown error type ${JSON.stringify(e)}`),ye=class extends Error{},Se=e=>"IndexPrincipalNotSet"in e?new ye("Index principal is not set for this ledger canister."):new w(e.GenericError.description,e.GenericError.error_code);import{createServices as Ie}from"@dfinity/utils";var Ee=({IDL:e})=>{let t=e.Rec(),c=e.Record({ledger_id:e.Opt(e.Principal),retrieve_blocks_from_ledger_interval_seconds:e.Opt(e.Nat64)}),r=e.Record({ledger_id:e.Principal,retrieve_blocks_from_ledger_interval_seconds:e.Opt(e.Nat64)}),i=e.Variant({Upgrade:c,Init:r}),n=e.Nat,d=e.Vec(e.Nat8),a=e.Record({owner:e.Principal,subaccount:e.Opt(d)}),g=e.Record({max_results:e.Nat,start:e.Opt(n),account:a}),p=e.Nat,f=e.Record({fee:e.Opt(e.Nat),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:p,spender:e.Opt(a)}),N=e.Record({to:a,fee:e.Opt(e.Nat),memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:p}),x=e.Record({fee:e.Opt(p),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:p,expected_allowance:e.Opt(p),expires_at:e.Opt(e.Nat64),spender:a}),s=e.Record({to:a,fee:e.Opt(p),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:p,spender:e.Opt(a)}),u=e.Record({burn:e.Opt(f),kind:e.Text,mint:e.Opt(N),approve:e.Opt(x),timestamp:e.Nat64,transfer:e.Opt(s)}),_=e.Record({id:n,transaction:u}),y=e.Record({balance:p,transactions:e.Vec(_),oldest_tx_id:e.Opt(n)}),T=e.Record({message:e.Text}),V=e.Variant({Ok:y,Err:T}),b=e.Record({start:e.Nat,length:e.Nat}),A=e.Vec(e.Tuple(e.Text,t));t.fill(e.Variant({Int:e.Int,Map:A,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(t)}));let k=t,O=e.Record({blocks:e.Vec(k),chain_length:e.Nat64}),R=e.Record({ranges:e.Vec(e.Tuple(a,e.Vec(e.Tuple(n,n))))}),o=e.Record({owner:e.Principal,start:e.Opt(d)}),h=e.Record({num_blocks_synced:n});return e.Service({get_account_transactions:e.Func([g],[V],[]),get_blocks:e.Func([b],[O],[]),get_fee_collectors_ranges:e.Func([],[R],[]),icrc1_balance_of:e.Func([a],[p],[]),ledger_id:e.Func([],[e.Principal],[]),list_subaccounts:e.Func([o],[e.Vec(d)],[]),status:e.Func([],[h],["query"])})};var we=({IDL:e})=>{let t=e.Rec(),c=e.Record({ledger_id:e.Opt(e.Principal),retrieve_blocks_from_ledger_interval_seconds:e.Opt(e.Nat64)}),r=e.Record({ledger_id:e.Principal,retrieve_blocks_from_ledger_interval_seconds:e.Opt(e.Nat64)}),i=e.Variant({Upgrade:c,Init:r}),n=e.Nat,d=e.Vec(e.Nat8),a=e.Record({owner:e.Principal,subaccount:e.Opt(d)}),g=e.Record({max_results:e.Nat,start:e.Opt(n),account:a}),p=e.Nat,f=e.Record({fee:e.Opt(e.Nat),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:p,spender:e.Opt(a)}),N=e.Record({to:a,fee:e.Opt(e.Nat),memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:p}),x=e.Record({fee:e.Opt(p),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:p,expected_allowance:e.Opt(p),expires_at:e.Opt(e.Nat64),spender:a}),s=e.Record({to:a,fee:e.Opt(p),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:p,spender:e.Opt(a)}),u=e.Record({burn:e.Opt(f),kind:e.Text,mint:e.Opt(N),approve:e.Opt(x),timestamp:e.Nat64,transfer:e.Opt(s)}),_=e.Record({id:n,transaction:u}),y=e.Record({balance:p,transactions:e.Vec(_),oldest_tx_id:e.Opt(n)}),T=e.Record({message:e.Text}),V=e.Variant({Ok:y,Err:T}),b=e.Record({start:e.Nat,length:e.Nat}),A=e.Vec(e.Tuple(e.Text,t));t.fill(e.Variant({Int:e.Int,Map:A,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(t)}));let k=t,O=e.Record({blocks:e.Vec(k),chain_length:e.Nat64}),R=e.Record({ranges:e.Vec(e.Tuple(a,e.Vec(e.Tuple(n,n))))}),o=e.Record({owner:e.Principal,start:e.Opt(d)}),h=e.Record({num_blocks_synced:n});return e.Service({get_account_transactions:e.Func([g],[V],["query"]),get_blocks:e.Func([b],[O],["query"]),get_fee_collectors_ranges:e.Func([],[R],["query"]),icrc1_balance_of:e.Func([a],[p],["query"]),ledger_id:e.Func([],[e.Principal],["query"]),list_subaccounts:e.Func([o],[e.Vec(d)],["query"]),status:e.Func([],[h],["query"])})};import{Canister as Je,toNullable as Ke}from"@dfinity/utils";var B=class extends Je{balance=t=>this.caller({certified:t.certified}).icrc1_balance_of({owner:t.owner,subaccount:Ke(t.subaccount)})};import{toNullable as Be}from"@dfinity/utils";var C=({account:e,max_results:t,start:c})=>({account:ke(e),max_results:t,start:Be(c)}),Ce=({owner:e,start:t})=>({owner:e,start:Be(t)});var Ve=class e extends B{static create(t){let{service:c,certifiedService:r,canisterId:i}=Ie({options:t,idlFactory:we,certifiedIdlFactory:Ee});return new e(i,c,r)}getTransactions=async({certified:t,...c})=>{let r=await this.caller({certified:t}).get_account_transactions(C(c));if("Err"in r)throw new P(r.Err.message);return r.Ok};ledgerId=t=>{let{ledger_id:c}=this.caller(t);return c()};status=t=>this.caller(t).status();listSubaccounts=({certified:t,...c})=>this.caller({certified:t}).list_subaccounts(Ce(c))};import{Canister as Le,createServices as De}from"@dfinity/utils";var Me=({IDL:e})=>{let t=e.Record({ledger_id:e.Principal}),c=e.Nat,r=e.Record({owner:e.Principal,subaccount:e.Opt(e.Vec(e.Nat8))}),i=e.Record({max_results:e.Nat,start:e.Opt(c),account:r}),n=e.Record({from:r,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,spender:e.Opt(r)}),d=e.Record({to:r,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat}),a=e.Record({fee:e.Opt(e.Nat),from:r,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(e.Nat64),spender:r}),g=e.Record({to:r,fee:e.Opt(e.Nat),from:r,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,spender:e.Opt(r)}),p=e.Record({burn:e.Opt(n),kind:e.Text,mint:e.Opt(d),approve:e.Opt(a),timestamp:e.Nat64,transfer:e.Opt(g)}),f=e.Record({id:c,transaction:p}),N=e.Record({transactions:e.Vec(f),oldest_tx_id:e.Opt(c)}),x=e.Record({message:e.Text}),s=e.Variant({Ok:N,Err:x}),u=e.Vec(e.Nat8),_=e.Record({owner:e.Principal,start:e.Opt(u)});return e.Service({get_account_transactions:e.Func([i],[s],[]),ledger_id:e.Func([],[e.Principal],[]),list_subaccounts:e.Func([_],[e.Vec(u)],[])})};var qe=({IDL:e})=>{let t=e.Record({ledger_id:e.Principal}),c=e.Nat,r=e.Record({owner:e.Principal,subaccount:e.Opt(e.Vec(e.Nat8))}),i=e.Record({max_results:e.Nat,start:e.Opt(c),account:r}),n=e.Record({from:r,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,spender:e.Opt(r)}),d=e.Record({to:r,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat}),a=e.Record({fee:e.Opt(e.Nat),from:r,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(e.Nat64),spender:r}),g=e.Record({to:r,fee:e.Opt(e.Nat),from:r,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat,spender:e.Opt(r)}),p=e.Record({burn:e.Opt(n),kind:e.Text,mint:e.Opt(d),approve:e.Opt(a),timestamp:e.Nat64,transfer:e.Opt(g)}),f=e.Record({id:c,transaction:p}),N=e.Record({transactions:e.Vec(f),oldest_tx_id:e.Opt(c)}),x=e.Record({message:e.Text}),s=e.Variant({Ok:N,Err:x}),u=e.Vec(e.Nat8),_=e.Record({owner:e.Principal,start:e.Opt(u)});return e.Service({get_account_transactions:e.Func([i],[s],[]),ledger_id:e.Func([],[e.Principal],["query"]),list_subaccounts:e.Func([_],[e.Vec(u)],["query"])})};var be=class e extends Le{static create(t){let{service:c,certifiedService:r,canisterId:i}=De({options:t,idlFactory:qe,certifiedIdlFactory:Me});return new e(i,c,r)}getTransactions=async t=>{let c=await this.caller({certified:!0}).get_account_transactions(C(t));if("Err"in c)throw new P(c.Err.message);return c.Ok};ledgerId=t=>{let{ledger_id:c}=this.caller(t);return c()}};import{Canister as et,createServices as tt,toNullable as rt}from"@dfinity/utils";var Ue=({IDL:e})=>{let t=e.Rec(),c=e.Rec(),r=e.Rec(),i=e.Record({num_blocks_to_archive:e.Opt(e.Nat64),max_transactions_per_response:e.Opt(e.Nat64),trigger_threshold:e.Opt(e.Nat64),more_controller_ids:e.Opt(e.Vec(e.Principal)),max_message_size_bytes:e.Opt(e.Nat64),cycles_for_archive_creation:e.Opt(e.Nat64),node_max_memory_size_bytes:e.Opt(e.Nat64),controller_id:e.Opt(e.Principal)}),n=e.Variant({Int:e.Int,Nat:e.Nat,Blob:e.Vec(e.Nat8),Text:e.Text}),d=e.Vec(e.Nat8),a=e.Record({owner:e.Principal,subaccount:e.Opt(d)}),g=e.Variant({SetTo:a,Unset:e.Null}),p=e.Record({icrc2:e.Bool}),f=e.Record({change_archive_options:e.Opt(i),token_symbol:e.Opt(e.Text),transfer_fee:e.Opt(e.Nat),metadata:e.Opt(e.Vec(e.Tuple(e.Text,n))),change_fee_collector:e.Opt(g),max_memo_length:e.Opt(e.Nat16),index_principal:e.Opt(e.Principal),token_name:e.Opt(e.Text),feature_flags:e.Opt(p)}),N=e.Record({decimals:e.Opt(e.Nat8),token_symbol:e.Text,transfer_fee:e.Nat,metadata:e.Vec(e.Tuple(e.Text,n)),minting_account:a,initial_balances:e.Vec(e.Tuple(a,e.Nat)),fee_collector_account:e.Opt(a),archive_options:e.Record({num_blocks_to_archive:e.Nat64,max_transactions_per_response:e.Opt(e.Nat64),trigger_threshold:e.Nat64,more_controller_ids:e.Opt(e.Vec(e.Principal)),max_message_size_bytes:e.Opt(e.Nat64),cycles_for_archive_creation:e.Opt(e.Nat64),node_max_memory_size_bytes:e.Opt(e.Nat64),controller_id:e.Principal}),max_memo_length:e.Opt(e.Nat16),index_principal:e.Opt(e.Principal),token_name:e.Text,feature_flags:e.Opt(p)}),x=e.Variant({Upgrade:e.Opt(f),Init:N}),s=e.Nat,u=e.Record({block_range_end:s,canister_id:e.Principal,block_range_start:s}),_=e.Record({start:s,length:e.Nat}),y=e.Vec(e.Tuple(e.Text,r));r.fill(e.Variant({Int:e.Int,Map:y,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(r)}));let T=r,V=e.Record({blocks:e.Vec(T)}),b=e.Func([_],[V],[]),A=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),first_index:s,blocks:e.Vec(T),chain_length:e.Nat64,archived_blocks:e.Vec(e.Record({callback:b,start:s,length:e.Nat}))}),k=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),hash_tree:e.Vec(e.Nat8)}),O=e.Nat,R=e.Record({start:O,length:e.Nat}),o=e.Nat64,h=e.Record({fee:e.Opt(e.Nat),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,spender:e.Opt(a)}),q=e.Record({to:a,fee:e.Opt(e.Nat),memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat}),U=e.Record({fee:e.Opt(e.Nat),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(o),spender:a}),z=e.Record({to:a,fee:e.Opt(e.Nat),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,spender:e.Opt(a)}),S=e.Record({burn:e.Opt(h),kind:e.Text,mint:e.Opt(q),approve:e.Opt(U),timestamp:o,transfer:e.Opt(z)}),Q=e.Record({transactions:e.Vec(S)}),$=e.Func([R],[Q],[]),H=e.Record({first_index:O,log_length:e.Nat,transactions:e.Vec(S),archived_transactions:e.Vec(e.Record({callback:$,start:O,length:e.Nat}))}),W=e.Record({take:e.Opt(e.Nat),prev_spender:e.Opt(a),from_account:e.Opt(a)}),Z=e.Record({from_account:a,to_spender:a,allowance:e.Nat,expires_at:e.Opt(e.Nat64)}),X=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),AccessDenied:e.Record({reason:e.Text})}),Y=e.Variant({Ok:e.Vec(Z),Err:X}),j=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),IndexPrincipalNotSet:e.Null}),J=e.Variant({Ok:e.Principal,Err:j}),l=e.Nat,K=e.Record({url:e.Text,name:e.Text}),I=e.Record({to:a,fee:e.Opt(l),memo:e.Opt(e.Vec(e.Nat8)),from_subaccount:e.Opt(d),created_at_time:e.Opt(o),amount:l}),L=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,BadBurn:e.Record({min_burn_amount:l}),Duplicate:e.Record({duplicate_of:s}),BadFee:e.Record({expected_fee:l}),CreatedInFuture:e.Record({ledger_time:o}),TooOld:e.Null,InsufficientFunds:e.Record({balance:l})}),D=e.Variant({Ok:s,Err:L}),E=e.Record({utc_offset_minutes:e.Opt(e.Int16),language:e.Text}),ee=e.Record({metadata:E,device_spec:e.Opt(e.Variant({GenericDisplay:e.Null,FieldsDisplay:e.Null}))}),te=e.Record({arg:e.Vec(e.Nat8),method:e.Text,user_preferences:ee}),re=e.Variant({Text:e.Record({content:e.Text}),TokenAmount:e.Record({decimals:e.Nat8,amount:e.Nat64,symbol:e.Text}),TimestampSeconds:e.Record({amount:e.Nat64}),DurationSeconds:e.Record({amount:e.Nat64})}),ce=e.Record({fields:e.Vec(e.Tuple(e.Text,re)),intent:e.Text}),ae=e.Variant({FieldsDisplayMessage:ce,GenericDisplayMessage:e.Text}),ne=e.Record({metadata:E,consent_message:ae}),F=e.Record({description:e.Text}),oe=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),InsufficientPayment:F,UnsupportedCanisterCall:F,ConsentMessageUnavailable:F}),se=e.Variant({Ok:ne,Err:oe}),ie=e.Record({account:a,spender:a}),pe=e.Record({allowance:e.Nat,expires_at:e.Opt(o)}),le=e.Record({fee:e.Opt(e.Nat),memo:e.Opt(e.Vec(e.Nat8)),from_subaccount:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(o),spender:a}),de=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,Duplicate:e.Record({duplicate_of:s}),BadFee:e.Record({expected_fee:e.Nat}),AllowanceChanged:e.Record({current_allowance:e.Nat}),CreatedInFuture:e.Record({ledger_time:o}),TooOld:e.Null,Expired:e.Record({ledger_time:o}),InsufficientFunds:e.Record({balance:e.Nat})}),_e=e.Variant({Ok:s,Err:de}),me=e.Record({to:a,fee:e.Opt(l),spender_subaccount:e.Opt(d),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:l}),ue=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,InsufficientAllowance:e.Record({allowance:l}),BadBurn:e.Record({min_burn_amount:l}),Duplicate:e.Record({duplicate_of:s}),BadFee:e.Record({expected_fee:l}),CreatedInFuture:e.Record({ledger_time:o}),TooOld:e.Null,InsufficientFunds:e.Record({balance:l})}),ge=e.Variant({Ok:s,Err:ue}),fe=e.Record({from:e.Opt(e.Principal)}),Ne=e.Vec(e.Record({end:e.Nat,canister_id:e.Principal,start:e.Nat}));c.fill(e.Variant({Int:e.Int,Map:e.Vec(e.Tuple(e.Text,c)),Nat:e.Nat,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(c)})),t.fill(e.Record({log_length:e.Nat,blocks:e.Vec(e.Record({id:e.Nat,block:c})),archived_blocks:e.Vec(e.Record({args:e.Vec(_),callback:e.Func([e.Vec(_)],[t],["query"])}))}));let Oe=e.Record({certificate:e.Vec(e.Nat8),hash_tree:e.Vec(e.Nat8)});return e.Service({archives:e.Func([],[e.Vec(u)],[]),get_blocks:e.Func([_],[A],[]),get_data_certificate:e.Func([],[k],[]),get_transactions:e.Func([R],[H],[]),icrc103_get_allowances:e.Func([W],[Y],[]),icrc106_get_index_principal:e.Func([],[J],[]),icrc10_supported_standards:e.Func([],[e.Vec(e.Record({url:e.Text,name:e.Text}))],[]),icrc1_balance_of:e.Func([a],[l],[]),icrc1_decimals:e.Func([],[e.Nat8],[]),icrc1_fee:e.Func([],[l],[]),icrc1_metadata:e.Func([],[e.Vec(e.Tuple(e.Text,n))],[]),icrc1_minting_account:e.Func([],[e.Opt(a)],[]),icrc1_name:e.Func([],[e.Text],[]),icrc1_supported_standards:e.Func([],[e.Vec(K)],[]),icrc1_symbol:e.Func([],[e.Text],[]),icrc1_total_supply:e.Func([],[l],[]),icrc1_transfer:e.Func([I],[D],[]),icrc21_canister_call_consent_message:e.Func([te],[se],[]),icrc2_allowance:e.Func([ie],[pe],[]),icrc2_approve:e.Func([le],[_e],[]),icrc2_transfer_from:e.Func([me],[ge],[]),icrc3_get_archives:e.Func([fe],[Ne],[]),icrc3_get_blocks:e.Func([e.Vec(_)],[t],[]),icrc3_get_tip_certificate:e.Func([],[e.Opt(Oe)],[]),icrc3_supported_block_types:e.Func([],[e.Vec(e.Record({url:e.Text,block_type:e.Text}))],[]),is_ledger_ready:e.Func([],[e.Bool],["query"])})};var ze=({IDL:e})=>{let t=e.Rec(),c=e.Rec(),r=e.Rec(),i=e.Record({num_blocks_to_archive:e.Opt(e.Nat64),max_transactions_per_response:e.Opt(e.Nat64),trigger_threshold:e.Opt(e.Nat64),more_controller_ids:e.Opt(e.Vec(e.Principal)),max_message_size_bytes:e.Opt(e.Nat64),cycles_for_archive_creation:e.Opt(e.Nat64),node_max_memory_size_bytes:e.Opt(e.Nat64),controller_id:e.Opt(e.Principal)}),n=e.Variant({Int:e.Int,Nat:e.Nat,Blob:e.Vec(e.Nat8),Text:e.Text}),d=e.Vec(e.Nat8),a=e.Record({owner:e.Principal,subaccount:e.Opt(d)}),g=e.Variant({SetTo:a,Unset:e.Null}),p=e.Record({icrc2:e.Bool}),f=e.Record({change_archive_options:e.Opt(i),token_symbol:e.Opt(e.Text),transfer_fee:e.Opt(e.Nat),metadata:e.Opt(e.Vec(e.Tuple(e.Text,n))),change_fee_collector:e.Opt(g),max_memo_length:e.Opt(e.Nat16),index_principal:e.Opt(e.Principal),token_name:e.Opt(e.Text),feature_flags:e.Opt(p)}),N=e.Record({decimals:e.Opt(e.Nat8),token_symbol:e.Text,transfer_fee:e.Nat,metadata:e.Vec(e.Tuple(e.Text,n)),minting_account:a,initial_balances:e.Vec(e.Tuple(a,e.Nat)),fee_collector_account:e.Opt(a),archive_options:e.Record({num_blocks_to_archive:e.Nat64,max_transactions_per_response:e.Opt(e.Nat64),trigger_threshold:e.Nat64,more_controller_ids:e.Opt(e.Vec(e.Principal)),max_message_size_bytes:e.Opt(e.Nat64),cycles_for_archive_creation:e.Opt(e.Nat64),node_max_memory_size_bytes:e.Opt(e.Nat64),controller_id:e.Principal}),max_memo_length:e.Opt(e.Nat16),index_principal:e.Opt(e.Principal),token_name:e.Text,feature_flags:e.Opt(p)}),x=e.Variant({Upgrade:e.Opt(f),Init:N}),s=e.Nat,u=e.Record({block_range_end:s,canister_id:e.Principal,block_range_start:s}),_=e.Record({start:s,length:e.Nat}),y=e.Vec(e.Tuple(e.Text,r));r.fill(e.Variant({Int:e.Int,Map:y,Nat:e.Nat,Nat64:e.Nat64,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(r)}));let T=r,V=e.Record({blocks:e.Vec(T)}),b=e.Func([_],[V],["query"]),A=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),first_index:s,blocks:e.Vec(T),chain_length:e.Nat64,archived_blocks:e.Vec(e.Record({callback:b,start:s,length:e.Nat}))}),k=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),hash_tree:e.Vec(e.Nat8)}),O=e.Nat,R=e.Record({start:O,length:e.Nat}),o=e.Nat64,h=e.Record({fee:e.Opt(e.Nat),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,spender:e.Opt(a)}),q=e.Record({to:a,fee:e.Opt(e.Nat),memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat}),U=e.Record({fee:e.Opt(e.Nat),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(o),spender:a}),z=e.Record({to:a,fee:e.Opt(e.Nat),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,spender:e.Opt(a)}),S=e.Record({burn:e.Opt(h),kind:e.Text,mint:e.Opt(q),approve:e.Opt(U),timestamp:o,transfer:e.Opt(z)}),Q=e.Record({transactions:e.Vec(S)}),$=e.Func([R],[Q],["query"]),H=e.Record({first_index:O,log_length:e.Nat,transactions:e.Vec(S),archived_transactions:e.Vec(e.Record({callback:$,start:O,length:e.Nat}))}),W=e.Record({take:e.Opt(e.Nat),prev_spender:e.Opt(a),from_account:e.Opt(a)}),Z=e.Record({from_account:a,to_spender:a,allowance:e.Nat,expires_at:e.Opt(e.Nat64)}),X=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),AccessDenied:e.Record({reason:e.Text})}),Y=e.Variant({Ok:e.Vec(Z),Err:X}),j=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),IndexPrincipalNotSet:e.Null}),J=e.Variant({Ok:e.Principal,Err:j}),l=e.Nat,K=e.Record({url:e.Text,name:e.Text}),I=e.Record({to:a,fee:e.Opt(l),memo:e.Opt(e.Vec(e.Nat8)),from_subaccount:e.Opt(d),created_at_time:e.Opt(o),amount:l}),L=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,BadBurn:e.Record({min_burn_amount:l}),Duplicate:e.Record({duplicate_of:s}),BadFee:e.Record({expected_fee:l}),CreatedInFuture:e.Record({ledger_time:o}),TooOld:e.Null,InsufficientFunds:e.Record({balance:l})}),D=e.Variant({Ok:s,Err:L}),E=e.Record({utc_offset_minutes:e.Opt(e.Int16),language:e.Text}),ee=e.Record({metadata:E,device_spec:e.Opt(e.Variant({GenericDisplay:e.Null,FieldsDisplay:e.Null}))}),te=e.Record({arg:e.Vec(e.Nat8),method:e.Text,user_preferences:ee}),re=e.Variant({Text:e.Record({content:e.Text}),TokenAmount:e.Record({decimals:e.Nat8,amount:e.Nat64,symbol:e.Text}),TimestampSeconds:e.Record({amount:e.Nat64}),DurationSeconds:e.Record({amount:e.Nat64})}),ce=e.Record({fields:e.Vec(e.Tuple(e.Text,re)),intent:e.Text}),ae=e.Variant({FieldsDisplayMessage:ce,GenericDisplayMessage:e.Text}),ne=e.Record({metadata:E,consent_message:ae}),F=e.Record({description:e.Text}),oe=e.Variant({GenericError:e.Record({description:e.Text,error_code:e.Nat}),InsufficientPayment:F,UnsupportedCanisterCall:F,ConsentMessageUnavailable:F}),se=e.Variant({Ok:ne,Err:oe}),ie=e.Record({account:a,spender:a}),pe=e.Record({allowance:e.Nat,expires_at:e.Opt(o)}),le=e.Record({fee:e.Opt(e.Nat),memo:e.Opt(e.Vec(e.Nat8)),from_subaccount:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:e.Nat,expected_allowance:e.Opt(e.Nat),expires_at:e.Opt(o),spender:a}),de=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,Duplicate:e.Record({duplicate_of:s}),BadFee:e.Record({expected_fee:e.Nat}),AllowanceChanged:e.Record({current_allowance:e.Nat}),CreatedInFuture:e.Record({ledger_time:o}),TooOld:e.Null,Expired:e.Record({ledger_time:o}),InsufficientFunds:e.Record({balance:e.Nat})}),_e=e.Variant({Ok:s,Err:de}),me=e.Record({to:a,fee:e.Opt(l),spender_subaccount:e.Opt(d),from:a,memo:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(o),amount:l}),ue=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,InsufficientAllowance:e.Record({allowance:l}),BadBurn:e.Record({min_burn_amount:l}),Duplicate:e.Record({duplicate_of:s}),BadFee:e.Record({expected_fee:l}),CreatedInFuture:e.Record({ledger_time:o}),TooOld:e.Null,InsufficientFunds:e.Record({balance:l})}),ge=e.Variant({Ok:s,Err:ue}),fe=e.Record({from:e.Opt(e.Principal)}),Ne=e.Vec(e.Record({end:e.Nat,canister_id:e.Principal,start:e.Nat}));c.fill(e.Variant({Int:e.Int,Map:e.Vec(e.Tuple(e.Text,c)),Nat:e.Nat,Blob:e.Vec(e.Nat8),Text:e.Text,Array:e.Vec(c)})),t.fill(e.Record({log_length:e.Nat,blocks:e.Vec(e.Record({id:e.Nat,block:c})),archived_blocks:e.Vec(e.Record({args:e.Vec(_),callback:e.Func([e.Vec(_)],[t],["query"])}))}));let Oe=e.Record({certificate:e.Vec(e.Nat8),hash_tree:e.Vec(e.Nat8)});return e.Service({archives:e.Func([],[e.Vec(u)],["query"]),get_blocks:e.Func([_],[A],["query"]),get_data_certificate:e.Func([],[k],["query"]),get_transactions:e.Func([R],[H],["query"]),icrc103_get_allowances:e.Func([W],[Y],["query"]),icrc106_get_index_principal:e.Func([],[J],["query"]),icrc10_supported_standards:e.Func([],[e.Vec(e.Record({url:e.Text,name:e.Text}))],["query"]),icrc1_balance_of:e.Func([a],[l],["query"]),icrc1_decimals:e.Func([],[e.Nat8],["query"]),icrc1_fee:e.Func([],[l],["query"]),icrc1_metadata:e.Func([],[e.Vec(e.Tuple(e.Text,n))],["query"]),icrc1_minting_account:e.Func([],[e.Opt(a)],["query"]),icrc1_name:e.Func([],[e.Text],["query"]),icrc1_supported_standards:e.Func([],[e.Vec(K)],["query"]),icrc1_symbol:e.Func([],[e.Text],["query"]),icrc1_total_supply:e.Func([],[l],["query"]),icrc1_transfer:e.Func([I],[D],[]),icrc21_canister_call_consent_message:e.Func([te],[se],[]),icrc2_allowance:e.Func([ie],[pe],["query"]),icrc2_approve:e.Func([le],[_e],[]),icrc2_transfer_from:e.Func([me],[ge],[]),icrc3_get_archives:e.Func([fe],[Ne],["query"]),icrc3_get_blocks:e.Func([e.Vec(_)],[t],["query"]),icrc3_get_tip_certificate:e.Func([],[e.Opt(Oe)],["query"]),icrc3_supported_block_types:e.Func([],[e.Vec(e.Record({url:e.Text,block_type:e.Text}))],["query"]),is_ledger_ready:e.Func([],[e.Bool],["query"])})};var Ae=class e extends et{static create(t){let{service:c,certifiedService:r,canisterId:i}=tt({options:t,idlFactory:ze,certifiedIdlFactory:Ue});return new e(i,c,r)}metadata=t=>this.caller(t).icrc1_metadata();transactionFee=t=>this.caller(t).icrc1_fee();balance=t=>this.caller({certified:t.certified}).icrc1_balance_of({owner:t.owner,subaccount:rt(t.subaccount)});transfer=async t=>{let c=await this.caller({certified:!0}).icrc1_transfer(he(t));if("Err"in c)throw new v({errorType:c.Err,msg:"Failed to transfer"});return c.Ok};totalTokensSupply=t=>this.caller(t).icrc1_total_supply();transferFrom=async t=>{let c=await this.caller({certified:!0}).icrc2_transfer_from(Fe(t));if("Err"in c)throw new v({errorType:c.Err,msg:"Failed to transfer from"});return c.Ok};approve=async t=>{let c=await this.caller({certified:!0}).icrc2_approve(Pe(t));if("Err"in c)throw new v({errorType:c.Err,msg:"Failed to entitle the spender to transfer the amount"});return c.Ok};allowance=t=>{let{certified:c,...r}=t;return this.caller({certified:c}).icrc2_allowance({...r})};consentMessage=async t=>{let{icrc21_canister_call_consent_message:c}=this.caller({certified:!0}),r=await c(ve(t));if("Err"in r)throw Ge(r.Err);return r.Ok};getBlocks=t=>this.caller({certified:t.certified}).icrc3_get_blocks(t.args);getIndexPrincipal=async t=>{let{icrc106_get_index_principal:c}=this.caller(t),r=await c();if("Err"in r)throw Se(r.Err);return r.Ok};icrc1SupportedStandards=t=>this.caller(t).icrc1_supported_standards();icrc10SupportedStandards=t=>this.caller(t).icrc10_supported_standards();getMintingAccount=t=>this.caller(t).icrc1_minting_account()};var Qe=(n=>(n.SYMBOL="icrc1:symbol",n.NAME="icrc1:name",n.DECIMALS="icrc1:decimals",n.FEE="icrc1:fee",n.LOGO="icrc1:logo",n))(Qe||{});import{bigEndianCrc32 as ct,encodeBase32 as at,hexStringToUint8Array as nt,isNullish as He,nonNullish as M,notEmptyString as ot,uint8ArrayToHexString as st}from"@dfinity/utils";import{Principal as $e}from"@icp-sdk/core/principal";var it=64,Lt=({owner:e,subaccount:t})=>{if(He(t))return e.toText();let r=(i=>i.replace(/^0+/,""))(st(Uint8Array.from(t)));return r.length===0?e.toText():`${e.toText()}-${We({owner:e,subaccount:t})}.${r}`},We=({owner:e,subaccount:t})=>{let c=ct(Uint8Array.from([...e.toUint8Array(),...t]));return at(c)},Dt=e=>{let[t,c,...r]=e.split(".");if(!ot(t))throw new Error("Invalid account. No string provided.");if(r.length>0)throw new Error("Invalid account string format. Expected at most one '.' separator.");if(He(c))return{owner:$e.fromText(e)};let[i,...n]=t.split("-").reverse(),d=n.reverse().join("-"),a={owner:$e.fromText(d),subaccount:nt(c.padStart(it,"0"))};if(We(a)!==i)throw new Error("Invalid account. Invalid checksum.");return a},er=e=>{let t=e.reduce((r,[i,n])=>{switch(i){case"icrc1:symbol":r={...r,..."Text"in n&&{symbol:n.Text}};break;case"icrc1:name":r={...r,..."Text"in n&&{name:n.Text}};break;case"icrc1:fee":r={...r,..."Nat"in n&&{fee:n.Nat}};break;case"icrc1:decimals":r={...r,..."Nat"in n&&{decimals:Number(n.Nat)}};break;case"icrc1:logo":r={...r,..."Text"in n&&{icon:n.Text}}}return r},{});if((r=>M(r.symbol)&&M(r.name)&&M(r.fee)&&M(r.decimals))(t))return t};import{isNullish as pt,nonNullish as lt}from"@dfinity/utils";var cr=e=>{let t=/^([a-zA-Z]+):([A-Za-z0-9:\-.]+).*?(?:[?&](?:amount|value)=(\d+(?:\.\d+)?))?$/,c=e.match(t);if(pt(c))return;let[r,i,n,d]=c;return{token:i,identifier:n,...lt(d)&&!isNaN(parseFloat(d))&&{amount:parseFloat(d)}}};export{G as ConsentMessageError,Re as ConsentMessageUnavailableError,w as GenericError,be as IcrcIndexCanister,Ve as IcrcIndexNgCanister,Ae as IcrcLedgerCanister,Qe as IcrcMetadataResponseEntries,v as IcrcTransferError,P as IndexError,ye as IndexPrincipalNotSetError,xe as InsufficientPaymentError,Te as UnsupportedCanisterCallError,Dt as decodeIcrcAccount,cr as decodePayment,Lt as encodeIcrcAccount,_t as fromCandidAccount,Se as mapIcrc106GetIndexPrincipalError,Ge as mapIcrc21ConsentMessageError,er as mapTokenMetadata,Pe as toApproveArgs,ke as toCandidAccount,ve as toIcrc21ConsentMessageArgs,he as toTransferArg,Fe as toTransferFromArgs};
2
2
  //# sourceMappingURL=index.js.map