@dfinity/ckbtc
Version:
A library for interfacing with ckBTC.
3 lines (2 loc) • 5.5 kB
JavaScript
import{Canister as v,createServices as B}from"@dfinity/utils";var k=({IDL:t})=>{let e=t.Variant({disabled:t.Null,enabled:t.Null}),n=t.Record({get_current_fee_percentiles:t.Nat,get_utxos_maximum:t.Nat,get_block_headers_cycles_per_ten_instructions:t.Nat,get_current_fee_percentiles_maximum:t.Nat,send_transaction_per_byte:t.Nat,get_balance:t.Nat,get_utxos_cycles_per_ten_instructions:t.Nat,get_block_headers_base:t.Nat,get_utxos_base:t.Nat,get_balance_maximum:t.Nat,send_transaction_base:t.Nat,get_block_headers_maximum:t.Nat}),a=t.Variant({mainnet:t.Null,regtest:t.Null,testnet:t.Null}),l=t.Record({api_access:t.Opt(e),lazily_evaluate_fee_percentiles:t.Opt(e),blocks_source:t.Opt(t.Principal),fees:t.Opt(n),watchdog_canister:t.Opt(t.Opt(t.Principal)),network:t.Opt(a),stability_threshold:t.Opt(t.Nat),syncing:t.Opt(e),burn_cycles:t.Opt(e),disable_api_if_not_fully_synced:t.Opt(e)}),i=t.Text,_=t.Record({network:a,address:i,min_confirmations:t.Opt(t.Nat32)}),c=t.Nat64,s=t.Nat32,p=t.Record({start_height:s,end_height:t.Opt(s),network:a}),u=t.Vec(t.Nat8),d=t.Record({tip_height:s,block_headers:t.Vec(u)}),g=t.Record({network:a}),b=t.Nat64,r=t.Record({network:a,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:i}),m=t.Vec(t.Nat8),N=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),f=t.Record({height:s,value:c,outpoint:N}),o=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:s,tip_block_hash:m,utxos:t.Vec(f)}),y=t.Record({transaction:t.Vec(t.Nat8),network:a}),h=t.Record({api_access:e,lazily_evaluate_fee_percentiles:e,blocks_source:t.Principal,fees:n,watchdog_canister:t.Opt(t.Principal),network:a,stability_threshold:t.Nat,syncing:e,burn_cycles:e,disable_api_if_not_fully_synced:e}),O=t.Record({api_access:t.Opt(e),lazily_evaluate_fee_percentiles:t.Opt(e),fees:t.Opt(n),watchdog_canister:t.Opt(t.Opt(t.Principal)),stability_threshold:t.Opt(t.Nat),syncing:t.Opt(e),burn_cycles:t.Opt(e),disable_api_if_not_fully_synced:t.Opt(e)});return t.Service({bitcoin_get_balance:t.Func([_],[c],[]),bitcoin_get_balance_query:t.Func([_],[c],[]),bitcoin_get_block_headers:t.Func([p],[d],[]),bitcoin_get_current_fee_percentiles:t.Func([g],[t.Vec(b)],[]),bitcoin_get_utxos:t.Func([r],[o],[]),bitcoin_get_utxos_query:t.Func([r],[o],[]),bitcoin_send_transaction:t.Func([y],[],[]),get_config:t.Func([],[h],[]),set_config:t.Func([O],[],[])})};var w=({IDL:t})=>{let e=t.Variant({disabled:t.Null,enabled:t.Null}),n=t.Record({get_current_fee_percentiles:t.Nat,get_utxos_maximum:t.Nat,get_block_headers_cycles_per_ten_instructions:t.Nat,get_current_fee_percentiles_maximum:t.Nat,send_transaction_per_byte:t.Nat,get_balance:t.Nat,get_utxos_cycles_per_ten_instructions:t.Nat,get_block_headers_base:t.Nat,get_utxos_base:t.Nat,get_balance_maximum:t.Nat,send_transaction_base:t.Nat,get_block_headers_maximum:t.Nat}),a=t.Variant({mainnet:t.Null,regtest:t.Null,testnet:t.Null}),l=t.Record({api_access:t.Opt(e),lazily_evaluate_fee_percentiles:t.Opt(e),blocks_source:t.Opt(t.Principal),fees:t.Opt(n),watchdog_canister:t.Opt(t.Opt(t.Principal)),network:t.Opt(a),stability_threshold:t.Opt(t.Nat),syncing:t.Opt(e),burn_cycles:t.Opt(e),disable_api_if_not_fully_synced:t.Opt(e)}),i=t.Text,_=t.Record({network:a,address:i,min_confirmations:t.Opt(t.Nat32)}),c=t.Nat64,s=t.Nat32,p=t.Record({start_height:s,end_height:t.Opt(s),network:a}),u=t.Vec(t.Nat8),d=t.Record({tip_height:s,block_headers:t.Vec(u)}),g=t.Record({network:a}),b=t.Nat64,r=t.Record({network:a,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:i}),m=t.Vec(t.Nat8),N=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),f=t.Record({height:s,value:c,outpoint:N}),o=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:s,tip_block_hash:m,utxos:t.Vec(f)}),y=t.Record({transaction:t.Vec(t.Nat8),network:a}),h=t.Record({api_access:e,lazily_evaluate_fee_percentiles:e,blocks_source:t.Principal,fees:n,watchdog_canister:t.Opt(t.Principal),network:a,stability_threshold:t.Nat,syncing:e,burn_cycles:e,disable_api_if_not_fully_synced:e}),O=t.Record({api_access:t.Opt(e),lazily_evaluate_fee_percentiles:t.Opt(e),fees:t.Opt(n),watchdog_canister:t.Opt(t.Opt(t.Principal)),stability_threshold:t.Opt(t.Nat),syncing:t.Opt(e),burn_cycles:t.Opt(e),disable_api_if_not_fully_synced:t.Opt(e)});return t.Service({bitcoin_get_balance:t.Func([_],[c],[]),bitcoin_get_balance_query:t.Func([_],[c],["query"]),bitcoin_get_block_headers:t.Func([p],[d],[]),bitcoin_get_current_fee_percentiles:t.Func([g],[t.Vec(b)],[]),bitcoin_get_utxos:t.Func([r],[o],[]),bitcoin_get_utxos_query:t.Func([r],[o],["query"]),bitcoin_send_transaction:t.Func([y],[],[]),get_config:t.Func([],[h],["query"]),set_config:t.Func([O],[],[])})};import{nonNullish as q,toNullable as x}from"@dfinity/utils";var F={mainnet:{mainnet:null},testnet:{testnet:null},regtest:{regtest:null}},R=({network:t,filter:e,...n})=>({filter:q(e)?x("minConfirmations"in e?{min_confirmations:e.minConfirmations}:{page:e.page}):x(),network:t==="testnet"?{testnet:null}:{mainnet:null},...n}),P=({network:t,minConfirmations:e,...n})=>({min_confirmations:x(e),network:F[t],...n});var V=class t extends v{static create(e){let{service:n,certifiedService:a,canisterId:l}=B({options:e,idlFactory:w,certifiedIdlFactory:k});return new t(l,n,a)}getUtxosQuery=({...e})=>{let{bitcoin_get_utxos_query:n}=this.caller({certified:!1});return n(R(e))};getBalanceQuery=({...e})=>{let{bitcoin_get_balance_query:n}=this.caller({certified:!1});return n(P(e))}};export{R as a,P as b,V as c};
//# sourceMappingURL=chunk-ABDCS67G.js.map