@dfinity/ckbtc 1.0.1 → 1.1.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.
- package/README.md +36 -9
- package/dist/candid/minter.certified.idl.js +68 -0
- package/dist/candid/minter.d.ts +62 -2
- package/dist/candid/minter.did +87 -9
- package/dist/candid/minter.idl.js +68 -0
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/index.cjs.js.map +3 -3
- package/dist/esm/chunk-XGTBIGYK.js +2 -0
- package/dist/esm/chunk-XGTBIGYK.js.map +7 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +3 -3
- package/dist/esm/minter.canister.js +1 -1
- package/dist/types/enums/btc.enums.d.ts +3 -1
- package/dist/types/errors/minter.errors.d.ts +4 -1
- package/dist/types/minter.canister.d.ts +24 -1
- package/dist/types/types/minter.responses.d.ts +6 -1
- package/package.json +1 -1
- package/dist/esm/chunk-WPJD44WU.js +0 -2
- package/dist/esm/chunk-WPJD44WU.js.map +0 -7
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Ee=Object.create;var S=Object.defineProperty;var Pe=Object.getOwnPropertyDescriptor;var Ue=Object.getOwnPropertyNames;var Ce=Object.getPrototypeOf,Fe=Object.prototype.hasOwnProperty;var v=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Me=(e,t)=>{for(var n in t)S(e,n,{get:t[n],enumerable:!0})},de=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ue(t))!Fe.call(e,o)&&o!==n&&S(e,o,{get:()=>t[o],enumerable:!(r=Pe(t,o))||r.enumerable});return e};var ue=(e,t,n)=>(n=e!=null?Ee(Ce(e)):{},de(t||!e||!e.__esModule?S(n,"default",{value:e,enumerable:!0}):n,e)),qe=e=>de(S({},"__esModule",{value:!0}),e);var Y=v((Tt,_e)=>{"use strict";var Je="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";_e.exports=Je});var be=v((Et,me)=>{"use strict";var Qe=Y(),Ke=e=>{if(!e||typeof e!="string")throw new Error(`Expected base58 string but got \u201C${e}\u201D`);if(e.match(/[IOl0]/gmu))throw new Error(`Invalid base58 character \u201C${e.match(/[IOl0]/gmu)}\u201D`);let t=e.match(/^1+/gmu),n=t?t[0].length:0,r=(e.length-n)*(Math.log(58)/Math.log(256))+1>>>0;return new Uint8Array([...new Uint8Array(n),...e.match(/.{1}/gmu).map(o=>Qe.indexOf(o)).reduce((o,s)=>(o=o.map(i=>{let c=i*58+s;return s=c>>8,c}),o),new Uint8Array(r)).reverse().filter((o=>s=>o=o||s)(!1))])};me.exports=Ke});var ge=v((Pt,we)=>{"use strict";var Ne=Y(),Ye=()=>{let e=Array(256).fill(-1);for(let t=0;t<Ne.length;++t)e[Ne.charCodeAt(t)]=t;return e};we.exports=Ye});var ke=v((Ut,Re)=>{"use strict";var ye=Y(),Ze=ge(),Ie=Ze(),Le=e=>{let t=[];for(let n of e){let r=n;for(let o=0;o<t.length;++o){let s=(Ie[t[o]]<<8)+r;t[o]=ye.charCodeAt(s%58),r=s/58|0}for(;r;)t.push(ye.charCodeAt(r%58)),r=r/58|0}for(let n of e){if(n)break;t.push("1".charCodeAt(0))}return t.reverse(),String.fromCharCode(...t)};Re.exports=Le});var ve=v(ce=>{"use strict";ce.base58_to_binary=be();ce.binary_to_base58=ke()});var Be=v(B=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0});B.bech32m=B.bech32=void 0;var Z="qpzry9x8gf2tvdw0s3jn54khce6mua7l",Oe={};for(let e=0;e<Z.length;e++){let t=Z.charAt(e);Oe[t]=e}function V(e){let t=e>>25;return(e&33554431)<<5^-(t>>0&1)&996825010^-(t>>1&1)&642813549^-(t>>2&1)&513874426^-(t>>3&1)&1027748829^-(t>>4&1)&705979059}function Ae(e){let t=1;for(let n=0;n<e.length;++n){let r=e.charCodeAt(n);if(r<33||r>126)return"Invalid prefix ("+e+")";t=V(t)^r>>5}t=V(t);for(let n=0;n<e.length;++n){let r=e.charCodeAt(n);t=V(t)^r&31}return t}function ae(e,t,n,r){let o=0,s=0,i=(1<<n)-1,c=[];for(let d=0;d<e.length;++d)for(o=o<<t|e[d],s+=t;s>=n;)s-=n,c.push(o>>s&i);if(r)s>0&&c.push(o<<n-s&i);else{if(s>=t)return"Excess padding";if(o<<n-s&i)return"Non-zero padding"}return c}function De(e){return ae(e,8,5,!0)}function et(e){let t=ae(e,5,8,!1);if(Array.isArray(t))return t}function tt(e){let t=ae(e,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}function Ve(e){let t;e==="bech32"?t=1:t=734539939;function n(i,c,d){if(d=d||90,i.length+7+c.length>d)throw new TypeError("Exceeds length limit");i=i.toLowerCase();let p=Ae(i);if(typeof p=="string")throw new Error(p);let u=i+"1";for(let a=0;a<c.length;++a){let l=c[a];if(l>>5)throw new Error("Non 5-bit word");p=V(p)^l,u+=Z.charAt(l)}for(let a=0;a<6;++a)p=V(p);p^=t;for(let a=0;a<6;++a){let l=p>>(5-a)*5&31;u+=Z.charAt(l)}return u}function r(i,c){if(c=c||90,i.length<8)return i+" too short";if(i.length>c)return"Exceeds length limit";let d=i.toLowerCase(),p=i.toUpperCase();if(i!==d&&i!==p)return"Mixed-case string "+i;i=d;let u=i.lastIndexOf("1");if(u===-1)return"No separator character for "+i;if(u===0)return"Missing prefix for "+i;let a=i.slice(0,u),l=i.slice(u+1);if(l.length<6)return"Data too short";let f=Ae(a);if(typeof f=="string")return f;let x=[];for(let h=0;h<l.length;++h){let N=l.charAt(h),T=Oe[N];if(T===void 0)return"Unknown character "+N;f=V(f)^T,!(h+6>=l.length)&&x.push(T)}return f!==t?"Invalid checksum for "+i:{prefix:a,words:x}}function o(i,c){let d=r(i,c);if(typeof d=="object")return d}function s(i,c){let d=r(i,c);if(typeof d=="object")return d;throw new Error(d)}return{decodeUnsafe:o,decode:s,encode:n,toWords:De,fromWordsUnsafe:et,fromWords:tt}}B.bech32=Ve("bech32");B.bech32m=Ve("bech32m")});var ut={};Me(ut,{BtcAddressType:()=>L,BtcNetwork:()=>I,CkBTCMinterCanister:()=>X,MinterAlreadyProcessingError:()=>W,MinterAmountTooLowError:()=>j,MinterGenericError:()=>w,MinterInsufficientFundsError:()=>z,MinterMalformedAddressError:()=>H,MinterNoNewUtxosError:()=>$,MinterRetrieveBtcError:()=>k,MinterTemporaryUnavailableError:()=>G,MinterUpdateBalanceError:()=>M,ParseBtcAddressBadWitnessLengthError:()=>P,ParseBtcAddressError:()=>_,ParseBtcAddressInvalidError:()=>A,ParseBtcAddressMalformedAddressError:()=>R,ParseBtcAddressNoDataError:()=>E,ParseBtcAddressUnexpectedHumanReadablePartError:()=>C,ParseBtcAddressUnsupportedAddressTypeError:()=>O,ParseBtcAddressUnsupportedWitnessVersionError:()=>U,ParseBtcAddressWrongNetworkError:()=>F,createRetrieveBtcError:()=>te,createUpdateBalanceError:()=>ee,parseBtcAddress:()=>dt});module.exports=qe(ut);var I=(r=>(r[r.Mainnet=0]="Mainnet",r[r.Regtest=1]="Regtest",r[r.Testnet=2]="Testnet",r))(I||{}),L=(r=>(r[r.P2wpkhV0=0]="P2wpkhV0",r[r.P2pkh=1]="P2pkh",r[r.P2sh=2]="P2sh",r))(L||{});var _=class extends Error{},A=class extends _{},E=class extends _{},O=class extends _{},P=class extends _{},U=class extends _{},C=class extends _{},R=class extends _{},F=class extends _{};var D=require("@dfinity/utils"),w=class extends Error{},G=class extends w{},W=class extends w{},M=class extends w{},$=class extends M{},k=class extends w{},H=class extends k{},j=class extends k{},z=class extends k{},pe=e=>{if("GenericError"in e){let{GenericError:{error_message:t,error_code:n}}=e;return new w(`${t} (${n})`)}if("TemporarilyUnavailable"in e)return new G(e.TemporarilyUnavailable);if("AlreadyProcessing"in e)return new W},ee=e=>{let t=pe(e);return(0,D.nonNullish)(t)?t:"NoNewUtxos"in e?new $:new M(`Unsupported response type in minter.updateBalance ${JSON.stringify(e)}`)},te=e=>{let t=pe(e);return(0,D.nonNullish)(t)?t:"MalformedAddress"in e?new H(e.MalformedAddress):"AmountTooLow"in e?new j(`${e.AmountTooLow}`):"InsufficientFunds"in e?new z(`${e.InsufficientFunds.balance}`):new k(`Unsupported response type in minter.retrieveBtc ${JSON.stringify(e)}`)};var b=require("@dfinity/utils");var le=({IDL:e})=>{let t=e.Variant({RestrictedTo:e.Vec(e.Principal),DepositsRestrictedTo:e.Vec(e.Principal),ReadOnly:e.Null,GeneralAvailability:e.Null}),n=e.Record({kyt_principal:e.Opt(e.Principal),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),kyt_fee:e.Opt(e.Nat64)}),r=e.Variant({Mainnet:e.Null,Regtest:e.Null,Testnet:e.Null}),o=e.Record({kyt_principal:e.Opt(e.Principal),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),kyt_fee:e.Opt(e.Nat64)}),s=e.Variant({Upgrade:e.Opt(n),Init:o}),i=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})}),d=e.Variant({p2sh:e.Vec(e.Nat8),p2wpkh_v0:e.Vec(e.Nat8),p2pkh:e.Vec(e.Nat8)}),p=e.Variant({received_utxos:e.Record({to_account:i,utxos:e.Vec(c)}),sent_transaction:e.Record({fee:e.Opt(e.Nat64),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}),distributed_kyt_fee:e.Record({block_index:e.Nat64,amount:e.Nat64,kyt_provider:e.Principal}),init:o,upgrade:n,retrieve_btc_kyt_failed:e.Record({block_index:e.Nat64,uuid:e.Text,address:e.Text,amount:e.Nat64,kyt_provider:e.Principal}),accepted_retrieve_btc_request:e.Record({received_at:e.Nat64,block_index:e.Nat64,address:d,amount:e.Nat64,kyt_provider:e.Opt(e.Principal)}),checked_utxo:e.Record({clean:e.Bool,utxo:c,uuid:e.Text,kyt_provider:e.Opt(e.Principal)}),removed_retrieve_btc_request:e.Record({block_index:e.Nat64}),confirmed_transaction:e.Record({txid:e.Vec(e.Nat8)}),replaced_transaction:e.Record({fee:e.Nat64,change_output:e.Record({value:e.Nat64,vout:e.Nat32}),old_txid:e.Vec(e.Nat8),new_txid:e.Vec(e.Nat8),submitted_at:e.Nat64}),ignored_utxo:e.Record({utxo:c})}),u=e.Record({retrieve_btc_min_amount:e.Nat64,min_confirmations:e.Nat32,kyt_fee:e.Nat64}),a=e.Record({address:e.Text,amount:e.Nat64}),l=e.Record({block_index:e.Nat64}),f=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})}),x=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}),h=e.Variant({ValueTooSmall:c,Tainted:c,Minted:e.Record({minted_amount:e.Nat64,block_index:e.Nat64,utxo:c}),Checked:c}),N=e.Variant({GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,AlreadyProcessing:e.Null,NoNewUtxos:e.Record({required_confirmations:e.Nat32,current_confirmations:e.Opt(e.Nat32)})});return e.Service({estimate_withdrawal_fee:e.Func([e.Record({amount:e.Opt(e.Nat64)})],[e.Record({minter_fee:e.Nat64,bitcoin_fee:e.Nat64})],[]),get_btc_address:e.Func([e.Record({owner:e.Opt(e.Principal),subaccount:e.Opt(e.Vec(e.Nat8))})],[e.Text],[]),get_deposit_fee:e.Func([],[e.Nat64],[]),get_events:e.Func([e.Record({start:e.Nat64,length:e.Nat64})],[e.Vec(p)],[]),get_minter_info:e.Func([],[u],[]),get_withdrawal_account:e.Func([],[i],[]),retrieve_btc:e.Func([a],[e.Variant({Ok:l,Err:f})],[]),retrieve_btc_status:e.Func([e.Record({block_index:e.Nat64})],[x],[]),update_balance:e.Func([e.Record({owner:e.Opt(e.Principal),subaccount:e.Opt(e.Vec(e.Nat8))})],[e.Variant({Ok:e.Vec(h),Err:N})],[])})};var fe=({IDL:e})=>{let t=e.Variant({RestrictedTo:e.Vec(e.Principal),DepositsRestrictedTo:e.Vec(e.Principal),ReadOnly:e.Null,GeneralAvailability:e.Null}),n=e.Record({kyt_principal:e.Opt(e.Principal),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),kyt_fee:e.Opt(e.Nat64)}),r=e.Variant({Mainnet:e.Null,Regtest:e.Null,Testnet:e.Null}),o=e.Record({kyt_principal:e.Opt(e.Principal),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),kyt_fee:e.Opt(e.Nat64)}),s=e.Variant({Upgrade:e.Opt(n),Init:o}),i=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})}),d=e.Variant({p2sh:e.Vec(e.Nat8),p2wpkh_v0:e.Vec(e.Nat8),p2pkh:e.Vec(e.Nat8)}),p=e.Variant({received_utxos:e.Record({to_account:i,utxos:e.Vec(c)}),sent_transaction:e.Record({fee:e.Opt(e.Nat64),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}),distributed_kyt_fee:e.Record({block_index:e.Nat64,amount:e.Nat64,kyt_provider:e.Principal}),init:o,upgrade:n,retrieve_btc_kyt_failed:e.Record({block_index:e.Nat64,uuid:e.Text,address:e.Text,amount:e.Nat64,kyt_provider:e.Principal}),accepted_retrieve_btc_request:e.Record({received_at:e.Nat64,block_index:e.Nat64,address:d,amount:e.Nat64,kyt_provider:e.Opt(e.Principal)}),checked_utxo:e.Record({clean:e.Bool,utxo:c,uuid:e.Text,kyt_provider:e.Opt(e.Principal)}),removed_retrieve_btc_request:e.Record({block_index:e.Nat64}),confirmed_transaction:e.Record({txid:e.Vec(e.Nat8)}),replaced_transaction:e.Record({fee:e.Nat64,change_output:e.Record({value:e.Nat64,vout:e.Nat32}),old_txid:e.Vec(e.Nat8),new_txid:e.Vec(e.Nat8),submitted_at:e.Nat64}),ignored_utxo:e.Record({utxo:c})}),u=e.Record({retrieve_btc_min_amount:e.Nat64,min_confirmations:e.Nat32,kyt_fee:e.Nat64}),a=e.Record({address:e.Text,amount:e.Nat64}),l=e.Record({block_index:e.Nat64}),f=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})}),x=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}),h=e.Variant({ValueTooSmall:c,Tainted:c,Minted:e.Record({minted_amount:e.Nat64,block_index:e.Nat64,utxo:c}),Checked:c}),N=e.Variant({GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,AlreadyProcessing:e.Null,NoNewUtxos:e.Record({required_confirmations:e.Nat32,current_confirmations:e.Opt(e.Nat32)})});return e.Service({estimate_withdrawal_fee:e.Func([e.Record({amount:e.Opt(e.Nat64)})],[e.Record({minter_fee:e.Nat64,bitcoin_fee:e.Nat64})],["query"]),get_btc_address:e.Func([e.Record({owner:e.Opt(e.Principal),subaccount:e.Opt(e.Vec(e.Nat8))})],[e.Text],[]),get_deposit_fee:e.Func([],[e.Nat64],["query"]),get_events:e.Func([e.Record({start:e.Nat64,length:e.Nat64})],[e.Vec(p)],["query"]),get_minter_info:e.Func([],[u],["query"]),get_withdrawal_account:e.Func([],[i],[]),retrieve_btc:e.Func([a],[e.Variant({Ok:l,Err:f})],[]),retrieve_btc_status:e.Func([e.Record({block_index:e.Nat64})],[x],["query"]),update_balance:e.Func([e.Record({owner:e.Opt(e.Principal),subaccount:e.Opt(e.Vec(e.Nat8))})],[e.Variant({Ok:e.Vec(h),Err:N})],[])})};var X=class e extends b.Canister{constructor(){super(...arguments);this.getBtcAddress=({owner:n,subaccount:r})=>this.caller({certified:!0}).get_btc_address({owner:(0,b.toNullable)(n),subaccount:(0,b.toNullable)(r)});this.updateBalance=async({owner:n,subaccount:r})=>{let o=await this.caller({certified:!0}).update_balance({owner:(0,b.toNullable)(n),subaccount:(0,b.toNullable)(r)});if("Err"in o)throw ee(o.Err);return o.Ok};this.getWithdrawalAccount=()=>this.caller({certified:!0}).get_withdrawal_account();this.retrieveBtc=async n=>{let r=await this.caller({certified:!0}).retrieve_btc(n);if("Err"in r)throw te(r.Err);return r.Ok};this.estimateWithdrawalFee=async({certified:n,amount:r})=>this.caller({certified:n}).estimate_withdrawal_fee({amount:(0,b.toNullable)(r)});this.getMinterInfo=async({certified:n})=>this.caller({certified:n}).get_minter_info()}static create(n){let{service:r,certifiedService:o,canisterId:s}=(0,b.createServices)({options:n,idlFactory:fe,certifiedIdlFactory:le});return new e(s,r,o)}};var se=require("@dfinity/utils");function Se(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function re(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function he(e,t){Se(e);let n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}var Ge=e=>e instanceof Uint8Array;var Q=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),m=(e,t)=>e<<32-t|e>>>t,We=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!We)throw new Error("Non little-endian hardware is not supported");function $e(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function ne(e){if(typeof e=="string"&&(e=$e(e)),!Ge(e))throw new Error(`expected Uint8Array, got ${typeof e}`);return e}var J=class{clone(){return this._cloneInto()}},yt={}.toString;function xe(e){let t=r=>e().update(ne(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function He(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);let o=BigInt(32),s=BigInt(4294967295),i=Number(n>>o&s),c=Number(n&s),d=r?4:0,p=r?0:4;e.setUint32(t+d,i,r),e.setUint32(t+p,c,r)}var K=class extends J{constructor(t,n,r,o){super(),this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Q(this.buffer)}update(t){re(this);let{view:n,buffer:r,blockLen:o}=this;t=ne(t);let s=t.length;for(let i=0;i<s;){let c=Math.min(o-this.pos,s-i);if(c===o){let d=Q(t);for(;o<=s-i;i+=o)this.process(d,i);continue}r.set(t.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===o&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){re(this),he(t,this),this.finished=!0;let{buffer:n,view:r,blockLen:o,isLE:s}=this,{pos:i}=this;n[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(r,0),i=0);for(let a=i;a<o;a++)n[a]=0;He(r,o-8,BigInt(this.length*8),s),this.process(r,0);let c=Q(t),d=this.outputLen;if(d%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let p=d/4,u=this.get();if(p>u.length)throw new Error("_sha2: outputLen bigger than state");for(let a=0;a<p;a++)c.setUint32(4*a,u[a],s)}digest(){let{buffer:t,outputLen:n}=this;this.digestInto(t);let r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:n,buffer:r,length:o,finished:s,destroyed:i,pos:c}=this;return t.length=o,t.pos=c,t.finished=s,t.destroyed=i,o%n&&t.buffer.set(r),t}};var je=(e,t,n)=>e&t^~e&n,ze=(e,t,n)=>e&t^e&n^t&n,Xe=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),g=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),y=new Uint32Array(64),oe=class extends K{constructor(){super(64,32,8,!1),this.A=g[0]|0,this.B=g[1]|0,this.C=g[2]|0,this.D=g[3]|0,this.E=g[4]|0,this.F=g[5]|0,this.G=g[6]|0,this.H=g[7]|0}get(){let{A:t,B:n,C:r,D:o,E:s,F:i,G:c,H:d}=this;return[t,n,r,o,s,i,c,d]}set(t,n,r,o,s,i,c,d){this.A=t|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=c|0,this.H=d|0}process(t,n){for(let a=0;a<16;a++,n+=4)y[a]=t.getUint32(n,!1);for(let a=16;a<64;a++){let l=y[a-15],f=y[a-2],x=m(l,7)^m(l,18)^l>>>3,h=m(f,17)^m(f,19)^f>>>10;y[a]=h+y[a-7]+x+y[a-16]|0}let{A:r,B:o,C:s,D:i,E:c,F:d,G:p,H:u}=this;for(let a=0;a<64;a++){let l=m(c,6)^m(c,11)^m(c,25),f=u+l+je(c,d,p)+Xe[a]+y[a]|0,h=(m(r,2)^m(r,13)^m(r,22))+ze(r,o,s)|0;u=p,p=d,d=c,c=i+f|0,i=s,s=o,o=r,r=f+h|0}r=r+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,c=c+this.E|0,d=d+this.F|0,p=p+this.G|0,u=u+this.H|0,this.set(r,o,s,i,c,d,p,u)}roundClean(){y.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var ie=xe(()=>new oe);var Te=ue(ve()),q=ue(Be());var rt=0,nt=5,ot=111,it=196,ct={[rt]:{type:1,networks:[0]},[ot]:{type:1,networks:[2,1]},[nt]:{type:2,networks:[0]},[it]:{type:2,networks:[2,1]}},at=({address:e,network:t})=>{let r=(u=>{try{return(0,Te.base58_to_binary)(u)}catch{throw new A}})(e),{length:o}=r;if(o!==25)throw new R(`Expected the address to be 25 bytes, got ${o}.`);(u=>{let a=u.slice(o-4,o),l=u.slice(0,o-4),f=ie.create();f.update(l);let x=ie.create();x.update(f.digest());let h=x.digest().slice(0,4);if(a.some((N,T)=>N!==h[T]))throw new R(`Checksum mismatch expected ${a}, got ${h}.`)})(r);let i=r[0],c=ct[i];if((0,se.isNullish)(c))throw new O;let{type:d,networks:p}=c;if(!p.includes(t))throw new F;return{address:e,network:t,type:d,parser:"base58"}},st=({address:e,network:t})=>{let n=u=>{try{return u.startsWith("bc1p")||u.startsWith("tb1p")||u.startsWith("bcrt1p")?q.bech32m.decode(u):q.bech32.decode(u)}catch{throw new R}},{prefix:r,words:o}=n(e),i={bc:0,tb:2,bcrt:1}[r];if((0,se.isNullish)(i))throw new A;if(i!==t)throw new C;let[c,...d]=o;if(c!==0)throw new U;if(q.bech32.fromWords(d).length!==20)throw new P;return{address:e,network:t,type:0,parser:"bip-173"}},dt=({address:e,network:t=0})=>{switch(e.charAt(0)){case"1":case"2":case"3":case"m":case"n":return at({address:e,network:t});case"b":case"B":case"t":case"T":return st({address:e,network:t});case"":throw new E;default:throw new O}};0&&(module.exports={BtcAddressType,BtcNetwork,CkBTCMinterCanister,MinterAlreadyProcessingError,MinterAmountTooLowError,MinterGenericError,MinterInsufficientFundsError,MinterMalformedAddressError,MinterNoNewUtxosError,MinterRetrieveBtcError,MinterTemporaryUnavailableError,MinterUpdateBalanceError,ParseBtcAddressBadWitnessLengthError,ParseBtcAddressError,ParseBtcAddressInvalidError,ParseBtcAddressMalformedAddressError,ParseBtcAddressNoDataError,ParseBtcAddressUnexpectedHumanReadablePartError,ParseBtcAddressUnsupportedAddressTypeError,ParseBtcAddressUnsupportedWitnessVersionError,ParseBtcAddressWrongNetworkError,createRetrieveBtcError,createUpdateBalanceError,parseBtcAddress});
|
|
1
|
+
"use strict";var We=Object.create;var W=Object.defineProperty;var qe=Object.getOwnPropertyDescriptor;var Ge=Object.getOwnPropertyNames;var $e=Object.getPrototypeOf,He=Object.prototype.hasOwnProperty;var A=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),je=(e,t)=>{for(var r in t)W(e,r,{get:t[r],enumerable:!0})},xe=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ge(t))!He.call(e,o)&&o!==r&&W(e,o,{get:()=>t[o],enumerable:!(n=qe(t,o))||n.enumerable});return e};var Ne=(e,t,r)=>(r=e!=null?We($e(e)):{},xe(t||!e||!e.__esModule?W(r,"default",{value:e,enumerable:!0}):r,e)),ze=e=>xe(W({},"__esModule",{value:!0}),e);var L=A((St,Re)=>{"use strict";var De="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";Re.exports=De});var ke=A((Wt,ve)=>{"use strict";var et=L(),tt=e=>{if(!e||typeof e!="string")throw new Error(`Expected base58 string but got \u201C${e}\u201D`);if(e.match(/[IOl0]/gmu))throw new Error(`Invalid base58 character \u201C${e.match(/[IOl0]/gmu)}\u201D`);let t=e.match(/^1+/gmu),r=t?t[0].length:0,n=(e.length-r)*(Math.log(58)/Math.log(256))+1>>>0;return new Uint8Array([...new Uint8Array(r),...e.match(/.{1}/gmu).map(o=>et.indexOf(o)).reduce((o,c)=>(o=o.map(i=>{let a=i*58+c;return c=a>>8,a}),o),new Uint8Array(n)).reverse().filter((o=>c=>o=o||c)(!1))])};ve.exports=tt});var Ve=A((qt,Oe)=>{"use strict";var Ae=L(),rt=()=>{let e=Array(256).fill(-1);for(let t=0;t<Ae.length;++t)e[Ae.charCodeAt(t)]=t;return e};Oe.exports=rt});var Pe=A((Gt,Be)=>{"use strict";var Te=L(),nt=Ve(),ot=nt(),it=e=>{let t=[];for(let r of e){let n=r;for(let o=0;o<t.length;++o){let c=(ot[t[o]]<<8)+n;t[o]=Te.charCodeAt(c%58),n=c/58|0}for(;n;)t.push(Te.charCodeAt(n%58)),n=n/58|0}for(let r of e){if(r)break;t.push("1".charCodeAt(0))}return t.reverse(),String.fromCharCode(...t)};Be.exports=it});var Ee=A(_e=>{"use strict";_e.base58_to_binary=ke();_e.binary_to_base58=Pe()});var Me=A(B=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0});B.bech32m=B.bech32=void 0;var D="qpzry9x8gf2tvdw0s3jn54khce6mua7l",Ce={};for(let e=0;e<D.length;e++){let t=D.charAt(e);Ce[t]=e}function T(e){let t=e>>25;return(e&33554431)<<5^-(t>>0&1)&996825010^-(t>>1&1)&642813549^-(t>>2&1)&513874426^-(t>>3&1)&1027748829^-(t>>4&1)&705979059}function Ue(e){let t=1;for(let r=0;r<e.length;++r){let n=e.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+e+")";t=T(t)^n>>5}t=T(t);for(let r=0;r<e.length;++r){let n=e.charCodeAt(r);t=T(t)^n&31}return t}function he(e,t,r,n){let o=0,c=0,i=(1<<r)-1,a=[];for(let u=0;u<e.length;++u)for(o=o<<t|e[u],c+=t;c>=r;)c-=r,a.push(o>>c&i);if(n)c>0&&a.push(o<<r-c&i);else{if(c>=t)return"Excess padding";if(o<<r-c&i)return"Non-zero padding"}return a}function ct(e){return he(e,8,5,!0)}function at(e){let t=he(e,5,8,!1);if(Array.isArray(t))return t}function st(e){let t=he(e,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}function Fe(e){let t;e==="bech32"?t=1:t=734539939;function r(i,a,u){if(u=u||90,i.length+7+a.length>u)throw new TypeError("Exceeds length limit");i=i.toLowerCase();let l=Ue(i);if(typeof l=="string")throw new Error(l);let d=i+"1";for(let s=0;s<a.length;++s){let p=a[s];if(p>>5)throw new Error("Non 5-bit word");l=T(l)^p,d+=D.charAt(p)}for(let s=0;s<6;++s)l=T(l);l^=t;for(let s=0;s<6;++s){let p=l>>(5-s)*5&31;d+=D.charAt(p)}return d}function n(i,a){if(a=a||90,i.length<8)return i+" too short";if(i.length>a)return"Exceeds length limit";let u=i.toLowerCase(),l=i.toUpperCase();if(i!==u&&i!==l)return"Mixed-case string "+i;i=u;let d=i.lastIndexOf("1");if(d===-1)return"No separator character for "+i;if(d===0)return"Missing prefix for "+i;let s=i.slice(0,d),p=i.slice(d+1);if(p.length<6)return"Data too short";let f=Ue(s);if(typeof f=="string")return f;let h=[];for(let _=0;_<p.length;++_){let b=p.charAt(_),w=Ce[b];if(w===void 0)return"Unknown character "+b;f=T(f)^w,!(_+6>=p.length)&&h.push(w)}return f!==t?"Invalid checksum for "+i:{prefix:s,words:h}}function o(i,a){let u=n(i,a);if(typeof u=="object")return u}function c(i,a){let u=n(i,a);if(typeof u=="object")return u;throw new Error(u)}return{decodeUnsafe:o,decode:c,encode:r,toWords:ct,fromWordsUnsafe:at,fromWords:st}}B.bech32=Fe("bech32");B.bech32m=Fe("bech32m")});var xt={};je(xt,{BtcAddressType:()=>ce,BtcNetwork:()=>ie,CkBTCMinterCanister:()=>K,MinterAlreadyProcessingError:()=>G,MinterAmountTooLowError:()=>j,MinterGenericError:()=>g,MinterInsufficientAllowanceError:()=>X,MinterInsufficientFundsError:()=>z,MinterMalformedAddressError:()=>H,MinterNoNewUtxosError:()=>$,MinterRetrieveBtcError:()=>y,MinterTemporaryUnavailableError:()=>q,MinterUpdateBalanceError:()=>M,ParseBtcAddressBadWitnessLengthError:()=>E,ParseBtcAddressError:()=>m,ParseBtcAddressInvalidError:()=>O,ParseBtcAddressMalformedAddressError:()=>k,ParseBtcAddressNoDataError:()=>P,ParseBtcAddressUnexpectedHumanReadablePartError:()=>C,ParseBtcAddressUnsupportedAddressTypeError:()=>V,ParseBtcAddressUnsupportedWitnessVersionError:()=>U,ParseBtcAddressWrongNetworkError:()=>F,createRetrieveBtcError:()=>Q,createRetrieveBtcWithApprovalError:()=>de,createUpdateBalanceError:()=>se,parseBtcAddress:()=>mt});module.exports=ze(xt);var ie=(n=>(n[n.Mainnet=0]="Mainnet",n[n.Regtest=1]="Regtest",n[n.Testnet=2]="Testnet",n))(ie||{}),ce=(c=>(c[c.P2wpkhV0=0]="P2wpkhV0",c[c.P2pkh=1]="P2pkh",c[c.P2sh=2]="P2sh",c[c.P2wsh=3]="P2wsh",c[c.P2tr=4]="P2tr",c))(ce||{});var m=class extends Error{},O=class extends m{},P=class extends m{},V=class extends m{},E=class extends m{},U=class extends m{},C=class extends m{},k=class extends m{},F=class extends m{};var J=require("@dfinity/utils"),g=class extends Error{},q=class extends g{},G=class extends g{},M=class extends g{},$=class extends M{},y=class extends g{},H=class extends y{},j=class extends y{},z=class extends y{},X=class extends y{},ae=e=>{if("GenericError"in e){let{GenericError:{error_message:t,error_code:r}}=e;return new g(`${t} (${r})`)}if("TemporarilyUnavailable"in e)return new q(e.TemporarilyUnavailable);if("AlreadyProcessing"in e)return new G},se=e=>{let t=ae(e);return(0,J.nonNullish)(t)?t:"NoNewUtxos"in e?new $:new M(`Unsupported response type in minter.updateBalance ${JSON.stringify(e)}`)},Q=e=>{let t=ae(e);return(0,J.nonNullish)(t)?t:"MalformedAddress"in e?new H(e.MalformedAddress):"AmountTooLow"in e?new j(`${e.AmountTooLow}`):"InsufficientFunds"in e?new z(`${e.InsufficientFunds.balance}`):new y(`Unsupported response type in minter.retrieveBtc ${JSON.stringify(e)}`)},de=e=>{let t=ae(e);return(0,J.nonNullish)(t)?t:"InsufficientAllowance"in e?new X(`${e.InsufficientAllowance.allowance}`):Q(e)};var x=require("@dfinity/utils");var be=({IDL:e})=>{let t=e.Variant({RestrictedTo:e.Vec(e.Principal),DepositsRestrictedTo:e.Vec(e.Principal),ReadOnly:e.Null,GeneralAvailability:e.Null}),r=e.Record({kyt_principal:e.Opt(e.Principal),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),kyt_fee:e.Opt(e.Nat64)}),n=e.Variant({Mainnet:e.Null,Regtest:e.Null,Testnet:e.Null}),o=e.Record({kyt_principal:e.Opt(e.Principal),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:n,min_confirmations:e.Opt(e.Nat32),kyt_fee:e.Opt(e.Nat64)}),c=e.Variant({Upgrade:e.Opt(r),Init:o}),i=e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),a=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),memory_allocation:e.Nat,compute_allocation:e.Nat}),u=e.Record({status:i,memory_size:e.Nat,cycles:e.Nat,settings:a,idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8))}),l=e.Record({owner:e.Principal,subaccount:e.Opt(e.Vec(e.Nat8))}),d=e.Record({height:e.Nat32,value:e.Nat64,outpoint:e.Record({txid:e.Vec(e.Nat8),vout:e.Nat32})}),s=e.Variant({CallFailed:e.Null,TaintedDestination:e.Record({kyt_fee:e.Nat64,kyt_provider:e.Principal})}),p=e.Variant({p2wsh_v0:e.Vec(e.Nat8),p2tr_v1:e.Vec(e.Nat8),p2sh:e.Vec(e.Nat8),p2wpkh_v0:e.Vec(e.Nat8),p2pkh:e.Vec(e.Nat8)}),f=e.Variant({received_utxos:e.Record({to_account:l,mint_txid:e.Opt(e.Nat64),utxos:e.Vec(d)}),schedule_deposit_reimbursement:e.Record({burn_block_index:e.Nat64,account:l,amount:e.Nat64,reason:s}),sent_transaction:e.Record({fee:e.Opt(e.Nat64),change_output:e.Opt(e.Record({value:e.Nat64,vout:e.Nat32})),txid:e.Vec(e.Nat8),utxos:e.Vec(d),requests:e.Vec(e.Nat64),submitted_at:e.Nat64}),distributed_kyt_fee:e.Record({block_index:e.Nat64,amount:e.Nat64,kyt_provider:e.Principal}),init:o,upgrade:r,retrieve_btc_kyt_failed:e.Record({block_index:e.Nat64,owner:e.Principal,uuid:e.Text,address:e.Text,amount:e.Nat64,kyt_provider:e.Principal}),accepted_retrieve_btc_request:e.Record({received_at:e.Nat64,block_index:e.Nat64,address:p,amount:e.Nat64,kyt_provider:e.Opt(e.Principal)}),checked_utxo:e.Record({clean:e.Bool,utxo:d,uuid:e.Text,kyt_provider:e.Opt(e.Principal)}),removed_retrieve_btc_request:e.Record({block_index:e.Nat64}),confirmed_transaction:e.Record({txid:e.Vec(e.Nat8)}),replaced_transaction:e.Record({fee:e.Nat64,change_output:e.Record({value:e.Nat64,vout:e.Nat32}),old_txid:e.Vec(e.Nat8),new_txid:e.Vec(e.Nat8),submitted_at:e.Nat64}),ignored_utxo:e.Record({utxo:d}),reimbursed_failed_deposit:e.Record({burn_block_index:e.Nat64,mint_block_index:e.Nat64})}),h=e.Record({retrieve_btc_min_amount:e.Nat64,min_confirmations:e.Nat32,kyt_fee:e.Nat64}),_=e.Record({address:e.Text,amount:e.Nat64}),b=e.Record({block_index:e.Nat64}),w=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})}),ee=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}),te=e.Record({from_subaccount:e.Opt(e.Vec(e.Nat8)),address:e.Text,amount:e.Nat64}),re=e.Variant({MalformedAddress:e.Text,GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,InsufficientAllowance:e.Record({allowance:e.Nat64}),AlreadyProcessing:e.Null,AmountTooLow:e.Nat64,InsufficientFunds:e.Record({balance:e.Nat64})}),ne=e.Variant({ValueTooSmall:d,Tainted:d,Minted:e.Record({minted_amount:e.Nat64,block_index:e.Nat64,utxo:d}),Checked:d}),oe=e.Variant({GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,AlreadyProcessing:e.Null,NoNewUtxos:e.Record({required_confirmations:e.Nat32,current_confirmations:e.Opt(e.Nat32)})});return e.Service({estimate_withdrawal_fee:e.Func([e.Record({amount:e.Opt(e.Nat64)})],[e.Record({minter_fee:e.Nat64,bitcoin_fee:e.Nat64})],[]),get_btc_address:e.Func([e.Record({owner:e.Opt(e.Principal),subaccount:e.Opt(e.Vec(e.Nat8))})],[e.Text],[]),get_canister_status:e.Func([],[u],[]),get_deposit_fee:e.Func([],[e.Nat64],[]),get_events:e.Func([e.Record({start:e.Nat64,length:e.Nat64})],[e.Vec(f)],[]),get_minter_info:e.Func([],[h],[]),get_withdrawal_account:e.Func([],[l],[]),retrieve_btc:e.Func([_],[e.Variant({Ok:b,Err:w})],[]),retrieve_btc_status:e.Func([e.Record({block_index:e.Nat64})],[ee],[]),retrieve_btc_with_approval:e.Func([te],[e.Variant({Ok:b,Err:re})],[]),update_balance:e.Func([e.Record({owner:e.Opt(e.Principal),subaccount:e.Opt(e.Vec(e.Nat8))})],[e.Variant({Ok:e.Vec(ne),Err:oe})],[])})};var we=({IDL:e})=>{let t=e.Variant({RestrictedTo:e.Vec(e.Principal),DepositsRestrictedTo:e.Vec(e.Principal),ReadOnly:e.Null,GeneralAvailability:e.Null}),r=e.Record({kyt_principal:e.Opt(e.Principal),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),kyt_fee:e.Opt(e.Nat64)}),n=e.Variant({Mainnet:e.Null,Regtest:e.Null,Testnet:e.Null}),o=e.Record({kyt_principal:e.Opt(e.Principal),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:n,min_confirmations:e.Opt(e.Nat32),kyt_fee:e.Opt(e.Nat64)}),c=e.Variant({Upgrade:e.Opt(r),Init:o}),i=e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),a=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),memory_allocation:e.Nat,compute_allocation:e.Nat}),u=e.Record({status:i,memory_size:e.Nat,cycles:e.Nat,settings:a,idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8))}),l=e.Record({owner:e.Principal,subaccount:e.Opt(e.Vec(e.Nat8))}),d=e.Record({height:e.Nat32,value:e.Nat64,outpoint:e.Record({txid:e.Vec(e.Nat8),vout:e.Nat32})}),s=e.Variant({CallFailed:e.Null,TaintedDestination:e.Record({kyt_fee:e.Nat64,kyt_provider:e.Principal})}),p=e.Variant({p2wsh_v0:e.Vec(e.Nat8),p2tr_v1:e.Vec(e.Nat8),p2sh:e.Vec(e.Nat8),p2wpkh_v0:e.Vec(e.Nat8),p2pkh:e.Vec(e.Nat8)}),f=e.Variant({received_utxos:e.Record({to_account:l,mint_txid:e.Opt(e.Nat64),utxos:e.Vec(d)}),schedule_deposit_reimbursement:e.Record({burn_block_index:e.Nat64,account:l,amount:e.Nat64,reason:s}),sent_transaction:e.Record({fee:e.Opt(e.Nat64),change_output:e.Opt(e.Record({value:e.Nat64,vout:e.Nat32})),txid:e.Vec(e.Nat8),utxos:e.Vec(d),requests:e.Vec(e.Nat64),submitted_at:e.Nat64}),distributed_kyt_fee:e.Record({block_index:e.Nat64,amount:e.Nat64,kyt_provider:e.Principal}),init:o,upgrade:r,retrieve_btc_kyt_failed:e.Record({block_index:e.Nat64,owner:e.Principal,uuid:e.Text,address:e.Text,amount:e.Nat64,kyt_provider:e.Principal}),accepted_retrieve_btc_request:e.Record({received_at:e.Nat64,block_index:e.Nat64,address:p,amount:e.Nat64,kyt_provider:e.Opt(e.Principal)}),checked_utxo:e.Record({clean:e.Bool,utxo:d,uuid:e.Text,kyt_provider:e.Opt(e.Principal)}),removed_retrieve_btc_request:e.Record({block_index:e.Nat64}),confirmed_transaction:e.Record({txid:e.Vec(e.Nat8)}),replaced_transaction:e.Record({fee:e.Nat64,change_output:e.Record({value:e.Nat64,vout:e.Nat32}),old_txid:e.Vec(e.Nat8),new_txid:e.Vec(e.Nat8),submitted_at:e.Nat64}),ignored_utxo:e.Record({utxo:d}),reimbursed_failed_deposit:e.Record({burn_block_index:e.Nat64,mint_block_index:e.Nat64})}),h=e.Record({retrieve_btc_min_amount:e.Nat64,min_confirmations:e.Nat32,kyt_fee:e.Nat64}),_=e.Record({address:e.Text,amount:e.Nat64}),b=e.Record({block_index:e.Nat64}),w=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})}),ee=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}),te=e.Record({from_subaccount:e.Opt(e.Vec(e.Nat8)),address:e.Text,amount:e.Nat64}),re=e.Variant({MalformedAddress:e.Text,GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,InsufficientAllowance:e.Record({allowance:e.Nat64}),AlreadyProcessing:e.Null,AmountTooLow:e.Nat64,InsufficientFunds:e.Record({balance:e.Nat64})}),ne=e.Variant({ValueTooSmall:d,Tainted:d,Minted:e.Record({minted_amount:e.Nat64,block_index:e.Nat64,utxo:d}),Checked:d}),oe=e.Variant({GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,AlreadyProcessing:e.Null,NoNewUtxos:e.Record({required_confirmations:e.Nat32,current_confirmations:e.Opt(e.Nat32)})});return e.Service({estimate_withdrawal_fee:e.Func([e.Record({amount:e.Opt(e.Nat64)})],[e.Record({minter_fee:e.Nat64,bitcoin_fee:e.Nat64})],["query"]),get_btc_address:e.Func([e.Record({owner:e.Opt(e.Principal),subaccount:e.Opt(e.Vec(e.Nat8))})],[e.Text],[]),get_canister_status:e.Func([],[u],[]),get_deposit_fee:e.Func([],[e.Nat64],["query"]),get_events:e.Func([e.Record({start:e.Nat64,length:e.Nat64})],[e.Vec(f)],["query"]),get_minter_info:e.Func([],[h],["query"]),get_withdrawal_account:e.Func([],[l],[]),retrieve_btc:e.Func([_],[e.Variant({Ok:b,Err:w})],[]),retrieve_btc_status:e.Func([e.Record({block_index:e.Nat64})],[ee],["query"]),retrieve_btc_with_approval:e.Func([te],[e.Variant({Ok:b,Err:re})],[]),update_balance:e.Func([e.Record({owner:e.Opt(e.Principal),subaccount:e.Opt(e.Vec(e.Nat8))})],[e.Variant({Ok:e.Vec(ne),Err:oe})],[])})};var K=class e extends x.Canister{constructor(){super(...arguments);this.getBtcAddress=({owner:r,subaccount:n})=>this.caller({certified:!0}).get_btc_address({owner:(0,x.toNullable)(r),subaccount:(0,x.toNullable)(n)});this.updateBalance=async({owner:r,subaccount:n})=>{let o=await this.caller({certified:!0}).update_balance({owner:(0,x.toNullable)(r),subaccount:(0,x.toNullable)(n)});if("Err"in o)throw se(o.Err);return o.Ok};this.getWithdrawalAccount=()=>this.caller({certified:!0}).get_withdrawal_account();this.retrieveBtc=async r=>{let n=await this.caller({certified:!0}).retrieve_btc(r);if("Err"in n)throw Q(n.Err);return n.Ok};this.retrieveBtcWithApproval=async({address:r,amount:n,fromSubaccount:o})=>{let c=await this.caller({certified:!0}).retrieve_btc_with_approval({address:r,amount:n,from_subaccount:(0,x.toNullable)(o)});if("Err"in c)throw de(c.Err);return c.Ok};this.estimateWithdrawalFee=async({certified:r,amount:n})=>this.caller({certified:r}).estimate_withdrawal_fee({amount:(0,x.toNullable)(n)});this.getMinterInfo=async({certified:r})=>this.caller({certified:r}).get_minter_info()}static create(r){let{service:n,certifiedService:o,canisterId:c}=(0,x.createServices)({options:r,idlFactory:we,certifiedIdlFactory:be});return new e(c,n,o)}};var me=require("@dfinity/utils");function Xe(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function ue(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function ge(e,t){Xe(e);let r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var Je=e=>e instanceof Uint8Array;var Z=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),N=(e,t)=>e<<32-t|e>>>t,Qe=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Qe)throw new Error("Non little-endian hardware is not supported");function Ke(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function le(e){if(typeof e=="string"&&(e=Ke(e)),!Je(e))throw new Error(`expected Uint8Array, got ${typeof e}`);return e}var Y=class{clone(){return this._cloneInto()}},Tt={}.toString;function ye(e){let t=n=>e().update(le(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Ye(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);let o=BigInt(32),c=BigInt(4294967295),i=Number(r>>o&c),a=Number(r&c),u=n?4:0,l=n?0:4;e.setUint32(t+u,i,n),e.setUint32(t+l,a,n)}var I=class extends Y{constructor(t,r,n,o){super(),this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Z(this.buffer)}update(t){ue(this);let{view:r,buffer:n,blockLen:o}=this;t=le(t);let c=t.length;for(let i=0;i<c;){let a=Math.min(o-this.pos,c-i);if(a===o){let u=Z(t);for(;o<=c-i;i+=o)this.process(u,i);continue}n.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){ue(this),ge(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:c}=this,{pos:i}=this;r[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(n,0),i=0);for(let s=i;s<o;s++)r[s]=0;Ye(n,o-8,BigInt(this.length*8),c),this.process(n,0);let a=Z(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=u/4,d=this.get();if(l>d.length)throw new Error("_sha2: outputLen bigger than state");for(let s=0;s<l;s++)a.setUint32(4*s,d[s],c)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:c,destroyed:i,pos:a}=this;return t.length=o,t.pos=a,t.finished=c,t.destroyed=i,o%r&&t.buffer.set(n),t}};var Ze=(e,t,r)=>e&t^~e&r,Ie=(e,t,r)=>e&t^e&r^t&r,Le=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),R=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),v=new Uint32Array(64),pe=class extends I{constructor(){super(64,32,8,!1),this.A=R[0]|0,this.B=R[1]|0,this.C=R[2]|0,this.D=R[3]|0,this.E=R[4]|0,this.F=R[5]|0,this.G=R[6]|0,this.H=R[7]|0}get(){let{A:t,B:r,C:n,D:o,E:c,F:i,G:a,H:u}=this;return[t,r,n,o,c,i,a,u]}set(t,r,n,o,c,i,a,u){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=c|0,this.F=i|0,this.G=a|0,this.H=u|0}process(t,r){for(let s=0;s<16;s++,r+=4)v[s]=t.getUint32(r,!1);for(let s=16;s<64;s++){let p=v[s-15],f=v[s-2],h=N(p,7)^N(p,18)^p>>>3,_=N(f,17)^N(f,19)^f>>>10;v[s]=_+v[s-7]+h+v[s-16]|0}let{A:n,B:o,C:c,D:i,E:a,F:u,G:l,H:d}=this;for(let s=0;s<64;s++){let p=N(a,6)^N(a,11)^N(a,25),f=d+p+Ze(a,u,l)+Le[s]+v[s]|0,_=(N(n,2)^N(n,13)^N(n,22))+Ie(n,o,c)|0;d=l,l=u,u=a,a=i+f|0,i=c,c=o,o=n,n=f+_|0}n=n+this.A|0,o=o+this.B|0,c=c+this.C|0,i=i+this.D|0,a=a+this.E|0,u=u+this.F|0,l=l+this.G|0,d=d+this.H|0,this.set(n,o,c,i,a,u,l,d)}roundClean(){v.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var fe=ye(()=>new pe);var Se=Ne(Ee()),S=Ne(Me());var dt=0,ut=5,lt=111,pt=196,ft={[dt]:{type:1,networks:[0]},[lt]:{type:1,networks:[2,1]},[ut]:{type:2,networks:[0]},[pt]:{type:2,networks:[2,1]}},_t=({address:e,network:t})=>{let n=(d=>{try{return(0,Se.base58_to_binary)(d)}catch{throw new O}})(e),{length:o}=n;if(o!==25)throw new k(`Expected the address to be 25 bytes, got ${o}.`);(d=>{let s=d.slice(o-4,o),p=d.slice(0,o-4),f=fe.create();f.update(p);let h=fe.create();h.update(f.digest());let _=h.digest().slice(0,4);if(s.some((b,w)=>b!==_[w]))throw new k(`Checksum mismatch expected ${s}, got ${_}.`)})(n);let i=n[0],a=ft[i];if((0,me.isNullish)(a))throw new V;let{type:u,networks:l}=a;if(!l.includes(t))throw new F;return{address:e,network:t,type:u,parser:"base58"}},ht=({address:e,network:t})=>{let r=d=>{try{return d.startsWith("bc1p")||d.startsWith("tb1p")||d.startsWith("bcrt1p")?S.bech32m.decode(d):S.bech32.decode(d)}catch{throw new k}},{prefix:n,words:o}=r(e),i={bc:0,tb:2,bcrt:1}[n];if((0,me.isNullish)(i))throw new O;if(i!==t)throw new C;let[a,...u]=o;if(a>1)throw new U;switch(S.bech32.fromWords(u).length){case 20:return{address:e,network:t,type:0,parser:"bip-173"};case 32:return{address:e,network:t,type:a===0?3:4,parser:"bip-173"};default:throw new E}},mt=({address:e,network:t=0})=>{switch(e.charAt(0)){case"1":case"2":case"3":case"m":case"n":return _t({address:e,network:t});case"b":case"B":case"t":case"T":return ht({address:e,network:t});case"":throw new P;default:throw new V}};0&&(module.exports={BtcAddressType,BtcNetwork,CkBTCMinterCanister,MinterAlreadyProcessingError,MinterAmountTooLowError,MinterGenericError,MinterInsufficientAllowanceError,MinterInsufficientFundsError,MinterMalformedAddressError,MinterNoNewUtxosError,MinterRetrieveBtcError,MinterTemporaryUnavailableError,MinterUpdateBalanceError,ParseBtcAddressBadWitnessLengthError,ParseBtcAddressError,ParseBtcAddressInvalidError,ParseBtcAddressMalformedAddressError,ParseBtcAddressNoDataError,ParseBtcAddressUnexpectedHumanReadablePartError,ParseBtcAddressUnsupportedAddressTypeError,ParseBtcAddressUnsupportedWitnessVersionError,ParseBtcAddressWrongNetworkError,createRetrieveBtcError,createRetrieveBtcWithApprovalError,createUpdateBalanceError,parseBtcAddress});
|
|
2
2
|
/*! Bundled license information:
|
|
3
3
|
|
|
4
4
|
@noble/hashes/esm/utils.js:
|