@dfinity/ckbtc
Advanced tools
Comparing version 0.0.2-next-2023-02-13.1 to 0.0.2-next-2023-02-13.2
@@ -1,2 +0,2 @@ | ||
"use strict";var x=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var k=(e,t)=>{for(var r in t)x(e,r,{get:t[r],enumerable:!0})},O=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of g(t))!T.call(e,a)&&a!==r&&x(e,a,{get:()=>t[a],enumerable:!(n=b(t,a))||n.enumerable});return e};var y=e=>O(x({},"__esModule",{value:!0}),e);var w={};k(w,{CkBTCMinterCanister:()=>i});module.exports=y(w);var o=require("@dfinity/utils");var v=({IDL:e})=>{let t=e.Variant({RestrictedTo:e.Vec(e.Principal),ReadOnly:e.Null,GeneralAvailability:e.Null}),r=e.Variant({Mainnet:e.Null,Regtest:e.Null,Testnet:e.Null}),n=e.Record({ecdsa_key_name:e.Text,mode:t,retrieve_btc_min_amount:e.Nat64,ledger_id:e.Principal,max_time_in_queue_nanos:e.Nat64,btc_network:r,min_confirmations:e.Opt(e.Nat32)}),a=e.Record({owner:e.Principal,subaccount:e.Opt(e.Vec(e.Nat8))}),c=e.Record({height:e.Nat32,value:e.Nat64,outpoint:e.Record({txid:e.Vec(e.Nat8),vout:e.Nat32})}),s=e.Record({mode:e.Opt(t),retrieve_btc_min_amount:e.Opt(e.Nat64),max_time_in_queue_nanos:e.Opt(e.Nat64),min_confirmations:e.Opt(e.Nat32)}),d=e.Variant({p2sh:e.Vec(e.Nat8),p2wpkh_v0:e.Vec(e.Nat8),p2pkh:e.Vec(e.Nat8)}),l=e.Variant({received_utxos:e.Record({to_account:a,utxos:e.Vec(c)}),sent_transaction:e.Record({change_output:e.Opt(e.Record({value:e.Nat64,vout:e.Nat32})),txid:e.Vec(e.Nat8),utxos:e.Vec(c),requests:e.Vec(e.Nat64),submitted_at:e.Nat64}),init:n,upgrade:s,accepted_retrieve_btc_request:e.Record({received_at:e.Nat64,block_index:e.Nat64,address:d,amount:e.Nat64}),removed_retrieve_btc_request:e.Record({block_index:e.Nat64}),confirmed_transaction:e.Record({txid:e.Vec(e.Nat8)})}),u=e.Record({address:e.Text,amount:e.Nat64}),_=e.Record({block_index:e.Nat64}),N=e.Variant({MalformedAddress:e.Text,GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,AlreadyProcessing:e.Null,AmountTooLow:e.Nat64,InsufficientFunds:e.Record({balance:e.Nat64})}),m=e.Variant({Signing:e.Null,Confirmed:e.Record({txid:e.Vec(e.Nat8)}),Sending:e.Record({txid:e.Vec(e.Nat8)}),AmountTooLow:e.Null,Unknown:e.Null,Submitted:e.Record({txid:e.Vec(e.Nat8)}),Pending:e.Null}),p=e.Record({block_index:e.Nat64,amount:e.Nat64}),R=e.Variant({GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,AlreadyProcessing:e.Null,NoNewUtxos:e.Null});return e.Service({get_btc_address:e.Func([e.Record({owner:e.Opt(e.Principal),subaccount:e.Opt(e.Vec(e.Nat8))})],[e.Text],[]),get_events:e.Func([e.Record({start:e.Nat64,length:e.Nat64})],[e.Vec(l)],[]),get_withdrawal_account:e.Func([],[a],[]),retrieve_btc:e.Func([u],[e.Variant({Ok:_,Err:N})],[]),retrieve_btc_status:e.Func([e.Record({block_index:e.Nat64})],[m],[]),update_balance:e.Func([e.Record({owner:e.Opt(e.Principal),subaccount:e.Opt(e.Vec(e.Nat8))})],[e.Variant({Ok:p,Err:R})],[])})};var V=({IDL:e})=>{let t=e.Variant({RestrictedTo:e.Vec(e.Principal),ReadOnly:e.Null,GeneralAvailability:e.Null}),r=e.Variant({Mainnet:e.Null,Regtest:e.Null,Testnet:e.Null}),n=e.Record({ecdsa_key_name:e.Text,mode:t,retrieve_btc_min_amount:e.Nat64,ledger_id:e.Principal,max_time_in_queue_nanos:e.Nat64,btc_network:r,min_confirmations:e.Opt(e.Nat32)}),a=e.Record({owner:e.Principal,subaccount:e.Opt(e.Vec(e.Nat8))}),c=e.Record({height:e.Nat32,value:e.Nat64,outpoint:e.Record({txid:e.Vec(e.Nat8),vout:e.Nat32})}),s=e.Record({mode:e.Opt(t),retrieve_btc_min_amount:e.Opt(e.Nat64),max_time_in_queue_nanos:e.Opt(e.Nat64),min_confirmations:e.Opt(e.Nat32)}),d=e.Variant({p2sh:e.Vec(e.Nat8),p2wpkh_v0:e.Vec(e.Nat8),p2pkh:e.Vec(e.Nat8)}),l=e.Variant({received_utxos:e.Record({to_account:a,utxos:e.Vec(c)}),sent_transaction:e.Record({change_output:e.Opt(e.Record({value:e.Nat64,vout:e.Nat32})),txid:e.Vec(e.Nat8),utxos:e.Vec(c),requests:e.Vec(e.Nat64),submitted_at:e.Nat64}),init:n,upgrade:s,accepted_retrieve_btc_request:e.Record({received_at:e.Nat64,block_index:e.Nat64,address:d,amount:e.Nat64}),removed_retrieve_btc_request:e.Record({block_index:e.Nat64}),confirmed_transaction:e.Record({txid:e.Vec(e.Nat8)})}),u=e.Record({address:e.Text,amount:e.Nat64}),_=e.Record({block_index:e.Nat64}),N=e.Variant({MalformedAddress:e.Text,GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,AlreadyProcessing:e.Null,AmountTooLow:e.Nat64,InsufficientFunds:e.Record({balance:e.Nat64})}),m=e.Variant({Signing:e.Null,Confirmed:e.Record({txid:e.Vec(e.Nat8)}),Sending:e.Record({txid:e.Vec(e.Nat8)}),AmountTooLow:e.Null,Unknown:e.Null,Submitted:e.Record({txid:e.Vec(e.Nat8)}),Pending:e.Null}),p=e.Record({block_index:e.Nat64,amount:e.Nat64}),R=e.Variant({GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,AlreadyProcessing:e.Null,NoNewUtxos:e.Null});return e.Service({get_btc_address:e.Func([e.Record({owner:e.Opt(e.Principal),subaccount:e.Opt(e.Vec(e.Nat8))})],[e.Text],[]),get_events:e.Func([e.Record({start:e.Nat64,length:e.Nat64})],[e.Vec(l)],["query"]),get_withdrawal_account:e.Func([],[a],[]),retrieve_btc:e.Func([u],[e.Variant({Ok:_,Err:N})],[]),retrieve_btc_status:e.Func([e.Record({block_index:e.Nat64})],[m],["query"]),update_balance:e.Func([e.Record({owner:e.Opt(e.Principal),subaccount:e.Opt(e.Vec(e.Nat8))})],[e.Variant({Ok:p,Err:R})],[])})};var i=class extends o.Canister{constructor(){super(...arguments);this.getBtcAddress=r=>this.caller({certified:!0}).get_btc_address({owner:(0,o.toNullable)(r.owner),subaccount:(0,o.toNullable)(r.subaccount)})}static create(r){let{service:n,certifiedService:a,canisterId:c}=(0,o.createServices)({options:r,idlFactory:V,certifiedIdlFactory:v});return new i(c,n,a)}};0&&(module.exports={CkBTCMinterCanister}); | ||
"use strict";var x=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var k=(e,t)=>{for(var r in t)x(e,r,{get:t[r],enumerable:!0})},O=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of g(t))!T.call(e,a)&&a!==r&&x(e,a,{get:()=>t[a],enumerable:!(n=b(t,a))||n.enumerable});return e};var y=e=>O(x({},"__esModule",{value:!0}),e);var B={};k(B,{CkBTCMinterCanister:()=>i});module.exports=y(B);var c=require("@dfinity/utils");var v=({IDL:e})=>{let t=e.Variant({RestrictedTo:e.Vec(e.Principal),ReadOnly:e.Null,GeneralAvailability:e.Null}),r=e.Variant({Mainnet:e.Null,Regtest:e.Null,Testnet:e.Null}),n=e.Record({ecdsa_key_name:e.Text,mode:t,retrieve_btc_min_amount:e.Nat64,ledger_id:e.Principal,max_time_in_queue_nanos:e.Nat64,btc_network:r,min_confirmations:e.Opt(e.Nat32)}),a=e.Record({owner:e.Principal,subaccount:e.Opt(e.Vec(e.Nat8))}),o=e.Record({height:e.Nat32,value:e.Nat64,outpoint:e.Record({txid:e.Vec(e.Nat8),vout:e.Nat32})}),s=e.Record({mode:e.Opt(t),retrieve_btc_min_amount:e.Opt(e.Nat64),max_time_in_queue_nanos:e.Opt(e.Nat64),min_confirmations:e.Opt(e.Nat32)}),d=e.Variant({p2sh:e.Vec(e.Nat8),p2wpkh_v0:e.Vec(e.Nat8),p2pkh:e.Vec(e.Nat8)}),l=e.Variant({received_utxos:e.Record({to_account:a,utxos:e.Vec(o)}),sent_transaction:e.Record({change_output:e.Opt(e.Record({value:e.Nat64,vout:e.Nat32})),txid:e.Vec(e.Nat8),utxos:e.Vec(o),requests:e.Vec(e.Nat64),submitted_at:e.Nat64}),init:n,upgrade:s,accepted_retrieve_btc_request:e.Record({received_at:e.Nat64,block_index:e.Nat64,address:d,amount:e.Nat64}),removed_retrieve_btc_request:e.Record({block_index:e.Nat64}),confirmed_transaction:e.Record({txid:e.Vec(e.Nat8)})}),u=e.Record({address:e.Text,amount:e.Nat64}),_=e.Record({block_index:e.Nat64}),N=e.Variant({MalformedAddress:e.Text,GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,AlreadyProcessing:e.Null,AmountTooLow:e.Nat64,InsufficientFunds:e.Record({balance:e.Nat64})}),p=e.Variant({Signing:e.Null,Confirmed:e.Record({txid:e.Vec(e.Nat8)}),Sending:e.Record({txid:e.Vec(e.Nat8)}),AmountTooLow:e.Null,Unknown:e.Null,Submitted:e.Record({txid:e.Vec(e.Nat8)}),Pending:e.Null}),m=e.Record({block_index:e.Nat64,amount:e.Nat64}),R=e.Variant({GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,AlreadyProcessing:e.Null,NoNewUtxos:e.Null});return e.Service({get_btc_address:e.Func([e.Record({owner:e.Opt(e.Principal),subaccount:e.Opt(e.Vec(e.Nat8))})],[e.Text],[]),get_events:e.Func([e.Record({start:e.Nat64,length:e.Nat64})],[e.Vec(l)],[]),get_withdrawal_account:e.Func([],[a],[]),retrieve_btc:e.Func([u],[e.Variant({Ok:_,Err:N})],[]),retrieve_btc_status:e.Func([e.Record({block_index:e.Nat64})],[p],[]),update_balance:e.Func([e.Record({owner:e.Opt(e.Principal),subaccount:e.Opt(e.Vec(e.Nat8))})],[e.Variant({Ok:m,Err:R})],[])})};var V=({IDL:e})=>{let t=e.Variant({RestrictedTo:e.Vec(e.Principal),ReadOnly:e.Null,GeneralAvailability:e.Null}),r=e.Variant({Mainnet:e.Null,Regtest:e.Null,Testnet:e.Null}),n=e.Record({ecdsa_key_name:e.Text,mode:t,retrieve_btc_min_amount:e.Nat64,ledger_id:e.Principal,max_time_in_queue_nanos:e.Nat64,btc_network:r,min_confirmations:e.Opt(e.Nat32)}),a=e.Record({owner:e.Principal,subaccount:e.Opt(e.Vec(e.Nat8))}),o=e.Record({height:e.Nat32,value:e.Nat64,outpoint:e.Record({txid:e.Vec(e.Nat8),vout:e.Nat32})}),s=e.Record({mode:e.Opt(t),retrieve_btc_min_amount:e.Opt(e.Nat64),max_time_in_queue_nanos:e.Opt(e.Nat64),min_confirmations:e.Opt(e.Nat32)}),d=e.Variant({p2sh:e.Vec(e.Nat8),p2wpkh_v0:e.Vec(e.Nat8),p2pkh:e.Vec(e.Nat8)}),l=e.Variant({received_utxos:e.Record({to_account:a,utxos:e.Vec(o)}),sent_transaction:e.Record({change_output:e.Opt(e.Record({value:e.Nat64,vout:e.Nat32})),txid:e.Vec(e.Nat8),utxos:e.Vec(o),requests:e.Vec(e.Nat64),submitted_at:e.Nat64}),init:n,upgrade:s,accepted_retrieve_btc_request:e.Record({received_at:e.Nat64,block_index:e.Nat64,address:d,amount:e.Nat64}),removed_retrieve_btc_request:e.Record({block_index:e.Nat64}),confirmed_transaction:e.Record({txid:e.Vec(e.Nat8)})}),u=e.Record({address:e.Text,amount:e.Nat64}),_=e.Record({block_index:e.Nat64}),N=e.Variant({MalformedAddress:e.Text,GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,AlreadyProcessing:e.Null,AmountTooLow:e.Nat64,InsufficientFunds:e.Record({balance:e.Nat64})}),p=e.Variant({Signing:e.Null,Confirmed:e.Record({txid:e.Vec(e.Nat8)}),Sending:e.Record({txid:e.Vec(e.Nat8)}),AmountTooLow:e.Null,Unknown:e.Null,Submitted:e.Record({txid:e.Vec(e.Nat8)}),Pending:e.Null}),m=e.Record({block_index:e.Nat64,amount:e.Nat64}),R=e.Variant({GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,AlreadyProcessing:e.Null,NoNewUtxos:e.Null});return e.Service({get_btc_address:e.Func([e.Record({owner:e.Opt(e.Principal),subaccount:e.Opt(e.Vec(e.Nat8))})],[e.Text],[]),get_events:e.Func([e.Record({start:e.Nat64,length:e.Nat64})],[e.Vec(l)],["query"]),get_withdrawal_account:e.Func([],[a],[]),retrieve_btc:e.Func([u],[e.Variant({Ok:_,Err:N})],[]),retrieve_btc_status:e.Func([e.Record({block_index:e.Nat64})],[p],["query"]),update_balance:e.Func([e.Record({owner:e.Opt(e.Principal),subaccount:e.Opt(e.Vec(e.Nat8))})],[e.Variant({Ok:m,Err:R})],[])})};var i=class extends c.Canister{constructor(){super(...arguments);this.getBtcAddress=({owner:r,subaccount:n})=>this.caller({certified:!0}).get_btc_address({owner:(0,c.toNullable)(r),subaccount:(0,c.toNullable)(n)});this.updateBalance=({owner:r,subaccount:n})=>this.caller({certified:!0}).update_balance({owner:(0,c.toNullable)(r),subaccount:(0,c.toNullable)(n)})}static create(r){let{service:n,certifiedService:a,canisterId:o}=(0,c.createServices)({options:r,idlFactory:V,certifiedIdlFactory:v});return new i(o,n,a)}};0&&(module.exports={CkBTCMinterCanister}); | ||
//# sourceMappingURL=index.cjs.js.map |
@@ -1,2 +0,2 @@ | ||
import{a as r}from"./chunk-7LX2K5RL.js";export{r as CkBTCMinterCanister}; | ||
import{a as r}from"./chunk-6FLAEC6Z.js";export{r as CkBTCMinterCanister}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import{a}from"./chunk-7LX2K5RL.js";export{a as CkBTCMinterCanister}; | ||
import{a}from"./chunk-6FLAEC6Z.js";export{a as CkBTCMinterCanister}; | ||
//# sourceMappingURL=minter.canister.js.map |
@@ -0,2 +1,4 @@ | ||
export type { UpdateBalanceError, UpdateBalanceResult } from "../candid/minter"; | ||
export { CkBTCMinterCanister } from "./minter.canister"; | ||
export * from "./types/minter.params"; | ||
export * from "./types/minter.responses"; |
import { Canister } from "@dfinity/utils"; | ||
import type { _SERVICE as CkBTCMinterService } from "../candid/minter"; | ||
import type { CkBTCMinterCanisterOptions } from "./types/canister.options"; | ||
import type { GetBTCAddressParams } from "./types/minter.params"; | ||
import type { GetBTCAddressParams, UpdateBalanceParams } from "./types/minter.params"; | ||
import type { UpdateBalanceResponse } from "./types/minter.responses"; | ||
export declare class CkBTCMinterCanister extends Canister<CkBTCMinterService> { | ||
@@ -17,3 +18,14 @@ static create(options: CkBTCMinterCanisterOptions<CkBTCMinterService>): CkBTCMinterCanister; | ||
*/ | ||
getBtcAddress: (params: GetBTCAddressParams) => Promise<string>; | ||
getBtcAddress: ({ owner, subaccount, }: GetBTCAddressParams) => Promise<string>; | ||
/** | ||
* Notify the minter about the bitcoin transfer. | ||
* | ||
* Upon successful notification, new ckBTC should be available on the targeted address. | ||
* | ||
* @param {UpdateBalanceParams} params The parameters are the address to which bitcoin where transferred. | ||
* @param {Principal} params.owner The owner of the address. If not provided, the `caller` will be use instead. | ||
* @param {Principal} params.subaccount An optional subaccount of the address. | ||
* @returns {Promise<UpdateBalanceParams>} The result (Ok or Error) of the balance update. | ||
*/ | ||
updateBalance: ({ owner, subaccount, }: UpdateBalanceParams) => Promise<UpdateBalanceResponse>; | ||
} |
import type { Subaccount } from "@dfinity/ledger/candid/icrc1_ledger"; | ||
import type { Principal } from "@dfinity/principal"; | ||
import type { QueryParams } from "@dfinity/utils"; | ||
export interface MinterParams extends Omit<QueryParams, "certified"> { | ||
owner?: Principal; | ||
subaccount?: Subaccount; | ||
} | ||
/** | ||
* Params to get a BTC address. | ||
*/ | ||
export interface GetBTCAddressParams extends Omit<QueryParams, "certified"> { | ||
owner?: Principal; | ||
subaccount?: Subaccount; | ||
} | ||
export type GetBTCAddressParams = MinterParams; | ||
/** | ||
* Params to update ckBTC balance after a bitcoin transfer. | ||
*/ | ||
export type UpdateBalanceParams = MinterParams; |
{ | ||
"name": "@dfinity/ckbtc", | ||
"version": "0.0.2-next-2023-02-13.1", | ||
"version": "0.0.2-next-2023-02-13.2", | ||
"description": "A library for interfacing with ckBTC.", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
@@ -66,2 +66,3 @@ # ckbtc-js | ||
- [getBtcAddress](#gear-getbtcaddress) | ||
- [updateBalance](#gear-updatebalance) | ||
@@ -80,5 +81,5 @@ ##### :gear: create | ||
| Method | Type | | ||
| --------------- | -------------------------------------------------- | | ||
| `getBtcAddress` | `(params: GetBTCAddressParams) => Promise<string>` | | ||
| Method | Type | | ||
| --------------- | ----------------------------------------------------------- | | ||
| `getBtcAddress` | `({ owner, subaccount, }: MinterParams) => Promise<string>` | | ||
@@ -91,2 +92,22 @@ Parameters: | ||
##### :gear: updateBalance | ||
Notify the minter about the bitcoin transfer. | ||
Upon successful notification, new ckBTC should be available on the targeted address. | ||
| Method | Type | | ||
| --------------- | -------------------------------------------------------------------------- | | ||
| `updateBalance` | `({ owner, subaccount, }: MinterParams) => Promise<UpdateBalanceResponse>` | | ||
Parameters: | ||
- `params`: The parameters are the address to which bitcoin where transferred. | ||
- `params.owner`: The owner of the address. If not provided, the `caller` will be use instead. | ||
- `params.subaccount`: An optional subaccount of the address. | ||
<!-- TSDOC_END --> | ||
## Resources | ||
- [ckBTC Minter](https://github.com/dfinity/ic/tree/master/rs/bitcoin/ckbtc/minter/) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
95504
24
570
111