UNPKG

@dfinity/ckbtc

Version:

A library for interfacing with ckBTC.

3 lines (2 loc) 5.55 kB
import{Canister as v,createServices as B}from"@dfinity/utils";var k=({IDL:t})=>{let e=t.Variant({disabled:t.Null,enabled:t.Null}),a=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}),n=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(a),watchdog_canister:t.Opt(t.Opt(t.Principal)),network:t.Opt(n),stability_threshold:t.Opt(t.Nat),syncing:t.Opt(e),burn_cycles:t.Opt(e),disable_api_if_not_fully_synced:t.Opt(e)}),c=t.Text,_=t.Record({network:n,address:c,min_confirmations:t.Opt(t.Nat32)}),i=t.Nat64,s=t.Nat32,p=t.Record({start_height:s,end_height:t.Opt(s),network:n}),u=t.Vec(t.Nat8),d=t.Record({tip_height:s,block_headers:t.Vec(u)}),g=t.Record({network:n}),b=t.Nat64,r=t.Record({network:n,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:c}),m=t.Vec(t.Nat8),N=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),f=t.Record({height:s,value:i,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:n}),h=t.Record({api_access:e,lazily_evaluate_fee_percentiles:e,blocks_source:t.Principal,fees:a,watchdog_canister:t.Opt(t.Principal),network:n,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(a),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([_],[i],[]),bitcoin_get_balance_query:t.Func([_],[i],[]),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}),a=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}),n=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(a),watchdog_canister:t.Opt(t.Opt(t.Principal)),network:t.Opt(n),stability_threshold:t.Opt(t.Nat),syncing:t.Opt(e),burn_cycles:t.Opt(e),disable_api_if_not_fully_synced:t.Opt(e)}),c=t.Text,_=t.Record({network:n,address:c,min_confirmations:t.Opt(t.Nat32)}),i=t.Nat64,s=t.Nat32,p=t.Record({start_height:s,end_height:t.Opt(s),network:n}),u=t.Vec(t.Nat8),d=t.Record({tip_height:s,block_headers:t.Vec(u)}),g=t.Record({network:n}),b=t.Nat64,r=t.Record({network:n,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:c}),m=t.Vec(t.Nat8),N=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),f=t.Record({height:s,value:i,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:n}),h=t.Record({api_access:e,lazily_evaluate_fee_percentiles:e,blocks_source:t.Principal,fees:a,watchdog_canister:t.Opt(t.Principal),network:n,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(a),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([_],[i],[]),bitcoin_get_balance_query:t.Func([_],[i],["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,...a})=>({filter:q(e)?x("minConfirmations"in e?{min_confirmations:e.minConfirmations}:{page:e.page}):x(),network:t==="testnet"?{testnet:null}:{mainnet:null},...a}),P=({network:t,minConfirmations:e,...a})=>({min_confirmations:x(e),network:F[t],...a});var V=class t extends v{constructor(){super(...arguments);this.getUtxosQuery=({...a})=>{let{bitcoin_get_utxos_query:n}=this.caller({certified:!1});return n(R(a))};this.getBalanceQuery=({...a})=>{let{bitcoin_get_balance_query:n}=this.caller({certified:!1});return n(P(a))}}static create(a){let{service:n,certifiedService:l,canisterId:c}=B({options:a,idlFactory:w,certifiedIdlFactory:k});return new t(c,n,l)}};export{R as a,P as b,V as c}; //# sourceMappingURL=chunk-M2DS6MT4.js.map