@stacks/stacking
Advanced tools
Comparing version 1.3.3 to 1.3.4
@@ -6,2 +6,18 @@ # Change Log | ||
## [1.3.4](https://github.com/blockstack/blockstack.js/compare/v1.3.3...v1.3.4) (2021-03-18) | ||
### Features | ||
* export stacking/utils functions ([24c7314](https://github.com/blockstack/blockstack.js/commit/24c73148afafceb5be9e172a8bc325e1ad54a800)) | ||
### Reverts | ||
* Revert "v1.4.0" ([4356ddb](https://github.com/blockstack/blockstack.js/commit/4356ddbc8d83a83c97efaf6d8d1a7abefbc4f6d9)) | ||
## [1.3.3](https://github.com/blockstack/blockstack.js/compare/v1.3.2...v1.3.3) (2021-03-18) | ||
@@ -8,0 +24,0 @@ |
@@ -55,3 +55,101 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { | ||
export { _asyncToGenerator as asyncToGenerator, _extends as extends }; | ||
function _inheritsLoose(subClass, superClass) { | ||
subClass.prototype = Object.create(superClass.prototype); | ||
subClass.prototype.constructor = subClass; | ||
subClass.__proto__ = superClass; | ||
} | ||
function _getPrototypeOf(o) { | ||
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { | ||
return o.__proto__ || Object.getPrototypeOf(o); | ||
}; | ||
return _getPrototypeOf(o); | ||
} | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
function _isNativeReflectConstruct() { | ||
if (typeof Reflect === "undefined" || !Reflect.construct) return false; | ||
if (Reflect.construct.sham) return false; | ||
if (typeof Proxy === "function") return true; | ||
try { | ||
Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
function _construct(Parent, args, Class) { | ||
if (_isNativeReflectConstruct()) { | ||
_construct = Reflect.construct; | ||
} else { | ||
_construct = function _construct(Parent, args, Class) { | ||
var a = [null]; | ||
a.push.apply(a, args); | ||
var Constructor = Function.bind.apply(Parent, a); | ||
var instance = new Constructor(); | ||
if (Class) _setPrototypeOf(instance, Class.prototype); | ||
return instance; | ||
}; | ||
} | ||
return _construct.apply(null, arguments); | ||
} | ||
function _isNativeFunction(fn) { | ||
return Function.toString.call(fn).indexOf("[native code]") !== -1; | ||
} | ||
function _wrapNativeSuper(Class) { | ||
var _cache = typeof Map === "function" ? new Map() : undefined; | ||
_wrapNativeSuper = function _wrapNativeSuper(Class) { | ||
if (Class === null || !_isNativeFunction(Class)) return Class; | ||
if (typeof Class !== "function") { | ||
throw new TypeError("Super expression must either be null or a function"); | ||
} | ||
if (typeof _cache !== "undefined") { | ||
if (_cache.has(Class)) return _cache.get(Class); | ||
_cache.set(Class, Wrapper); | ||
} | ||
function Wrapper() { | ||
return _construct(Class, arguments, _getPrototypeOf(this).constructor); | ||
} | ||
Wrapper.prototype = Object.create(Class.prototype, { | ||
constructor: { | ||
value: Wrapper, | ||
enumerable: false, | ||
writable: true, | ||
configurable: true | ||
} | ||
}); | ||
return _setPrototypeOf(Wrapper, Class); | ||
}; | ||
return _wrapNativeSuper(Class); | ||
} | ||
function _assertThisInitialized(self) { | ||
if (self === void 0) { | ||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); | ||
} | ||
return self; | ||
} | ||
export { _assertThisInitialized as assertThisInitialized, _asyncToGenerator as asyncToGenerator, _construct as construct, _extends as extends, _getPrototypeOf as getPrototypeOf, _inheritsLoose as inheritsLoose, _isNativeFunction as isNativeFunction, _isNativeReflectConstruct as isNativeReflectConstruct, _setPrototypeOf as setPrototypeOf, _wrapNativeSuper as wrapNativeSuper }; | ||
//# sourceMappingURL=_rollupPluginBabelHelpers.js.map |
@@ -8,2 +8,3 @@ import { asyncToGenerator as _asyncToGenerator, extends as _extends } from './_virtual/_rollupPluginBabelHelpers.js'; | ||
import { decodeBtcAddress } from './utils.esm.js'; | ||
export { InvalidAddressError, btcAddressVersionToHashMode, decodeBtcAddress, getAddressHashMode, getBTCAddress, getErrorString } from './utils.esm.js'; | ||
@@ -10,0 +11,0 @@ var StackingClient = /*#__PURE__*/function () { |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@stacks/transactions"),e=require("bn.js"),r=require("@stacks/common"),n=require("bitcoinjs-lib");function o(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var a=o(e);function i(t,e,r,n,o,a,i){try{var c=t[a](i),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,o)}function c(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function c(t){i(a,n,o,c,s,"next",t)}function s(t){i(a,n,o,c,s,"throw",t)}c(void 0)}))}}function s(){return(s=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function u(t,e){return t(e={exports:{}},e.exports),e.exports}var f,h=u((function(t){var e=function(t){var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function s(t,e,r,n){var o=Object.create((e&&e.prototype instanceof h?e:h).prototype),a=new x(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return{value:void 0,done:!0}}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var c=m(i,r);if(c){if(c===f)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var s=u(t,e,r);if("normal"===s.type){if(n=r.done?"completed":"suspendedYield",s.arg===f)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n="completed",r.method="throw",r.arg=s.arg)}}}(t,r,a),o}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;var f={};function h(){}function l(){}function d(){}var p={};p[o]=function(){return this};var v=Object.getPrototypeOf,_=v&&v(v(R([])));_&&_!==e&&r.call(_,o)&&(p=_);var g=d.prototype=h.prototype=Object.create(p);function y(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function E(t,e){var n;this._invoke=function(o,a){function i(){return new e((function(n,i){!function n(o,a,i,c){var s=u(t[o],t,a);if("throw"!==s.type){var f=s.arg,h=f.value;return h&&"object"==typeof h&&r.call(h,"__await")?e.resolve(h.__await).then((function(t){n("next",t,i,c)}),(function(t){n("throw",t,i,c)})):e.resolve(h).then((function(t){f.value=t,i(f)}),(function(t){return n("throw",t,i,c)}))}c(s.arg)}(o,a,n,i)}))}return n=n?n.then(i,i):i()}}function m(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,m(t,e),"throw"===e.method))return f;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,f;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function w(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function x(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function R(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,a=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return a.next=a}}return{next:C}}function C(){return{value:void 0,done:!0}}return l.prototype=g.constructor=d,d.constructor=l,l.displayName=c(d,i,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===l||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,c(t,i,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},y(E.prototype),E.prototype[a]=function(){return this},t.AsyncIterator=E,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new E(s(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},y(g),c(g,i,"Generator"),g[o]=function(){return this},g.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=R,x.prototype={constructor:x,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(w),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return i.type="throw",i.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),s=r.call(a,"finallyLoc");if(c&&s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,f):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),w(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;w(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:R(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}));function l(e){var r=function(e){if(e.startsWith("bc1")||e.startsWith("tb1"))return 32===n.address.fromBech32(e).data.length?t.AddressHashMode.SerializeP2WSH:t.AddressHashMode.SerializeP2WPKH;switch(n.address.fromBase58Check(e).version){case 0:case 111:return t.AddressHashMode.SerializeP2PKH;case 5:case 196:return t.AddressHashMode.SerializeP2SH;default:throw new Error("Invalid pox address version")}}(e);return e.startsWith("bc1")||e.startsWith("tb1")?{hashMode:r,data:n.address.fromBech32(e).data}:{hashMode:r,data:n.address.fromBase58Check(e).hash}}!function(t){t[t.ERR_STACKING_UNREACHABLE=255]="ERR_STACKING_UNREACHABLE",t[t.ERR_STACKING_INSUFFICIENT_FUNDS=1]="ERR_STACKING_INSUFFICIENT_FUNDS",t[t.ERR_STACKING_INVALID_LOCK_PERIOD=2]="ERR_STACKING_INVALID_LOCK_PERIOD",t[t.ERR_STACKING_ALREADY_STACKED=3]="ERR_STACKING_ALREADY_STACKED",t[t.ERR_STACKING_NO_SUCH_PRINCIPAL=4]="ERR_STACKING_NO_SUCH_PRINCIPAL",t[t.ERR_STACKING_EXPIRED=5]="ERR_STACKING_EXPIRED",t[t.ERR_STACKING_STX_LOCKED=6]="ERR_STACKING_STX_LOCKED",t[t.ERR_STACKING_PERMISSION_DENIED=9]="ERR_STACKING_PERMISSION_DENIED",t[t.ERR_STACKING_THRESHOLD_NOT_MET=11]="ERR_STACKING_THRESHOLD_NOT_MET",t[t.ERR_STACKING_POX_ADDRESS_IN_USE=12]="ERR_STACKING_POX_ADDRESS_IN_USE",t[t.ERR_STACKING_INVALID_POX_ADDRESS=13]="ERR_STACKING_INVALID_POX_ADDRESS",t[t.ERR_STACKING_ALREADY_REJECTED=17]="ERR_STACKING_ALREADY_REJECTED",t[t.ERR_STACKING_INVALID_AMOUNT=18]="ERR_STACKING_INVALID_AMOUNT",t[t.ERR_NOT_ALLOWED=19]="ERR_NOT_ALLOWED",t[t.ERR_STACKING_ALREADY_DELEGATED=20]="ERR_STACKING_ALREADY_DELEGATED",t[t.ERR_DELEGATION_EXPIRES_DURING_LOCK=21]="ERR_DELEGATION_EXPIRES_DURING_LOCK",t[t.ERR_DELEGATION_TOO_MUCH_LOCKED=22]="ERR_DELEGATION_TOO_MUCH_LOCKED",t[t.ERR_DELEGATION_POX_ADDR_REQUIRED=23]="ERR_DELEGATION_POX_ADDR_REQUIRED",t[t.ERR_INVALID_START_BURN_HEIGHT=24]="ERR_INVALID_START_BURN_HEIGHT"}(f||(f={})),exports.StackingClient=function(){function e(t,e){this.address=t,this.network=e}var n=e.prototype;return n.getCoreInfo=function(){var t=c(h.mark((function t(){var e;return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.network.getInfoUrl(),t.abrupt("return",r.fetchPrivate(e).then((function(t){return t.json()})));case 2:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.getPoxInfo=function(){var t=c(h.mark((function t(){var e;return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.network.getPoxInfoUrl(),t.abrupt("return",r.fetchPrivate(e).then((function(t){return t.json()})));case 2:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.getTargetBlockTime=function(){var t=c(h.mark((function t(){var e,n;return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.network.getBlockTimeInfoUrl(),t.next=3,r.fetchPrivate(e).then((function(t){return t.json()}));case 3:if(n=t.sent,!this.network.isMainnet()){t.next=8;break}return t.abrupt("return",n.mainnet.target_block_time);case 8:return t.abrupt("return",n.testnet.target_block_time);case 9:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.getAccountStatus=function(){var t=c(h.mark((function t(){var e;return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.network.getAccountApiUrl(this.address),t.abrupt("return",r.fetchPrivate(e).then((function(t){return t.json()})));case 2:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.getAccountBalance=function(){var t=c(h.mark((function t(){return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getAccountStatus().then((function(t){var e=t.balance;return t.balance.startsWith("0x")&&(e=t.balance.substr(2)),new a.default(e,"hex")})));case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.getCycleDuration=function(){var t=c(h.mark((function t(){var e;return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.getPoxInfo(),t.next=3,this.getTargetBlockTime();case 3:return t.abrupt("return",Promise.all([e,t.sent]).then((function(t){return t[0].reward_cycle_length*t[1]})));case 5:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.getSecondsUntilNextCycle=function(){var t=c(h.mark((function t(){var e,r,n;return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.getPoxInfo(),t.next=3,this.getTargetBlockTime();case 3:return r=t.sent,n=this.getCoreInfo(),t.abrupt("return",Promise.all([e,r,n]).then((function(t){var e=t[0];return(e.reward_cycle_length-(t[2].burn_block_height-e.first_burnchain_block_height)%e.reward_cycle_length)*t[1]})));case 6:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.isStackingEnabledNextCycle=function(){var t=c(h.mark((function t(){return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getPoxInfo();case 2:return t.t0=t.sent.rejection_votes_left_required,t.abrupt("return",t.t0>0);case 4:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.hasMinimumStx=function(){var t=c(h.mark((function t(){var e,r;return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getAccountBalance();case 2:return e=t.sent,t.t0=a.default,t.next=6,this.getPoxInfo();case 6:return t.t1=t.sent.min_amount_ustx.toString(),r=new t.t0(t.t1),t.abrupt("return",e.gte(r));case 9:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.canStack=function(){var e=c(h.mark((function e(r){var n,o,i,c,s=this;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.poxAddress,o=r.cycles,i=this.getAccountBalance(),c=this.getPoxInfo(),e.abrupt("return",Promise.all([i,c]).then((function(e){var r=e[0],i=e[1],c=l(n),u=c.data,f=t.bufferCV(new a.default(c.hashMode,10).toArrayLike(Buffer)),h=t.bufferCV(u),d=t.tupleCV({hashbytes:h,version:f}),p=s.parseContractId(i.contract_id);return t.callReadOnlyFunction({network:s.network,contractName:p[1],contractAddress:p[0],functionName:"can-stack-stx",senderAddress:s.address,functionArgs:[d,t.uintCV(r.toString()),t.uintCV(i.reward_cycle_id),t.uintCV(o.toString())]})})).then((function(e){return e.type===t.ClarityType.ResponseOk?{eligible:!0}:{eligible:!1,reason:f[+t.cvToString(e.value)]}})));case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.stack=function(){var e=c(h.mark((function e(r){var n,o,a,i,c,u;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.amountMicroStx,o=r.poxAddress,a=r.cycles,i=r.privateKey,c=r.burnBlockHeight,e.next=3,this.getPoxInfo();case 3:return u=this.getStackOptions({amountMicroStx:n,cycles:a,poxAddress:o,contract:e.sent.contract_id,burnBlockHeight:c}),e.next=8,t.makeContractCall(s({},u,{senderKey:i}));case 8:return e.abrupt("return",t.broadcastTransaction(e.sent,u.network));case 10:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.delegateStx=function(){var e=c(h.mark((function e(r){var n,o,a,i,c,u;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.amountMicroStx,o=r.delegateTo,a=r.untilBurnBlockHeight,i=r.poxAddress,c=r.privateKey,e.next=3,this.getPoxInfo();case 3:return u=this.getDelegateOptions({contract:e.sent.contract_id,amountMicroStx:n,delegateTo:o,untilBurnBlockHeight:a,poxAddress:i}),e.next=8,t.makeContractCall(s({},u,{senderKey:c}));case 8:return e.abrupt("return",t.broadcastTransaction(e.sent,u.network));case 10:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.delegateStackStx=function(){var e=c(h.mark((function e(r){var n,o,a,i,c,u,f,l;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.stacker,o=r.amountMicroStx,a=r.poxAddress,i=r.burnBlockHeight,c=r.cycles,u=r.privateKey,f=r.nonce,e.next=3,this.getPoxInfo();case 3:return l=this.getDelegateStackOptions({contract:e.sent.contract_id,stacker:n,amountMicroStx:o,poxAddress:a,burnBlockHeight:i,cycles:c,nonce:f}),e.next=8,t.makeContractCall(s({},l,{senderKey:u}));case 8:return e.abrupt("return",t.broadcastTransaction(e.sent,l.network));case 10:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.stackAggregationCommit=function(){var e=c(h.mark((function e(r){var n,o,a,i;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.poxAddress,o=r.rewardCycle,a=r.privateKey,e.next=3,this.getPoxInfo();case 3:return i=this.getStackAggregationCommitOptions({contract:e.sent.contract_id,poxAddress:n,rewardCycle:o}),e.next=8,t.makeContractCall(s({},i,{senderKey:a}));case 8:return e.abrupt("return",t.broadcastTransaction(e.sent,i.network));case 10:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.revokeDelegateStx=function(){var e=c(h.mark((function e(r){var n;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPoxInfo();case 2:return n=this.getRevokeDelegateStxOptions(e.sent.contract_id),e.next=7,t.makeContractCall(s({},n,{senderKey:r}));case 7:return e.abrupt("return",t.broadcastTransaction(e.sent,n.network));case 9:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.getStackOptions=function(e){var r=e.amountMicroStx,n=e.cycles,o=e.contract,i=e.burnBlockHeight,c=l(e.poxAddress),s=c.data,u=t.bufferCV(new a.default(c.hashMode,10).toArrayLike(Buffer)),f=t.bufferCV(s),h=t.tupleCV({hashbytes:f,version:u}),d=this.parseContractId(o),p=this.network;return{contractAddress:d[0],contractName:d[1],functionName:"stack-stx",functionArgs:[t.uintCV(r.toString(10)),h,t.uintCV(i),t.uintCV(n)],validateWithAbi:!0,network:p}},n.getDelegateOptions=function(e){var r=e.contract,n=e.amountMicroStx,o=e.delegateTo,i=e.untilBurnBlockHeight,c=e.poxAddress,s=void 0;if(c){var u=l(c),f=u.data,h=t.bufferCV(new a.default(u.hashMode,10).toArrayLike(Buffer)),d=t.bufferCV(f);s=t.someCV(t.tupleCV({hashbytes:d,version:h}))}var p=this.parseContractId(r),v=this.network;return{contractAddress:p[0],contractName:p[1],functionName:"delegate-stx",functionArgs:[t.uintCV(n.toString(10)),t.standardPrincipalCV(o),i?t.someCV(t.uintCV(i)):t.noneCV(),s||t.noneCV()],validateWithAbi:!0,network:v}},n.getDelegateStackOptions=function(e){var r=e.contract,n=e.stacker,o=e.amountMicroStx,i=e.burnBlockHeight,c=e.cycles,s=e.nonce,u=l(e.poxAddress),f=u.data,h=t.bufferCV(new a.default(u.hashMode,10).toArrayLike(Buffer)),d=t.bufferCV(f),p=t.tupleCV({hashbytes:d,version:h}),v=this.parseContractId(r),_=this.network,g={contractAddress:v[0],contractName:v[1],functionName:"delegate-stack-stx",functionArgs:[t.standardPrincipalCV(n),t.uintCV(o.toString(10)),p,t.uintCV(i),t.uintCV(c)],validateWithAbi:!0,network:_};return s&&(g.nonce=s),g},n.getStackAggregationCommitOptions=function(e){var r=e.contract,n=e.rewardCycle,o=l(e.poxAddress),i=o.data,c=t.bufferCV(new a.default(o.hashMode,10).toArrayLike(Buffer)),s=t.bufferCV(i),u=t.tupleCV({hashbytes:s,version:c}),f=this.parseContractId(r),h=this.network;return{contractAddress:f[0],contractName:f[1],functionName:"stack-aggregation-commit",functionArgs:[u,t.uintCV(n)],validateWithAbi:!0,network:h}},n.getRevokeDelegateStxOptions=function(t){var e=this.parseContractId(t);return{contractAddress:e[0],contractName:e[1],functionName:"revoke-delegate-stx",functionArgs:[],validateWithAbi:!0,network:this.network}},n.getStatus=function(){var e=c(h.mark((function e(){var r,n,o,a;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPoxInfo();case 2:return r=this.parseContractId(e.sent.contract_id),n=r[0],o=r[1],e.next=6,this.getAccountStatus();case 6:return a=e.sent,e.abrupt("return",t.callReadOnlyFunction({contractAddress:n,contractName:o,functionName:"get-stacker-info",senderAddress:this.address,functionArgs:[t.standardPrincipalCV(this.address)],network:this.network}).then((function(e){if(e.type===t.ClarityType.OptionalSome){var r=e.value,n=r.data["pox-addr"],o=r.data["first-reward-cycle"],i=r.data["lock-period"],c=n.data.version,s=n.data.hashbytes;return{stacked:!0,details:{amount_microstx:r.data["amount-ustx"].value.toString(),first_reward_cycle:o.value.toNumber(),lock_period:i.value.toNumber(),unlock_height:a.unlock_height,pox_address:{version:c.buffer,hashbytes:s.buffer}}}}if(e.type===t.ClarityType.OptionalNone)return{stacked:!1};throw new Error("Error fetching stacker info")})));case 9:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.modifyLockTxFee=function(e){var r=e.tx,n=e.amountMicroStx,o=r.auth.getFee();return r.payload.functionArgs[0]=t.uintCV(new a.default(n.toString(10),10).sub(o).toArrayLike(Buffer)),r},n.parseContractId=function(e){var r=e.split(".");if(2!==r.length||!t.validateStacksAddress(r[0])||"pox"!==r[1])throw new Error("Stacking contract ID is malformed");return r},e}(); | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@stacks/transactions"),e=require("bn.js"),r=require("@stacks/common"),n=require("bitcoinjs-lib");function o(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var a=o(e);function i(t,e,r,n,o,a,i){try{var c=t[a](i),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,o)}function c(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function c(t){i(a,n,o,c,s,"next",t)}function s(t){i(a,n,o,c,s,"throw",t)}c(void 0)}))}}function s(){return(s=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function f(t,e){return(f=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function l(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function h(t,e,r){return(h=l()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&f(o,r.prototype),o}).apply(null,arguments)}function d(t){var e="function"==typeof Map?new Map:void 0;return(d=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return h(t,arguments,u(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),f(r,t)})(t)}function p(t,e){return t(e={exports:{}},e.exports),e.exports}var _,v=p((function(t){var e=function(t){var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function s(t,e,r,n){var o=Object.create((e&&e.prototype instanceof l?e:l).prototype),a=new S(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return{value:void 0,done:!0}}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var c=R(i,r);if(c){if(c===f)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var s=u(t,e,r);if("normal"===s.type){if(n=r.done?"completed":"suspendedYield",s.arg===f)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n="completed",r.method="throw",r.arg=s.arg)}}}(t,r,a),o}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;var f={};function l(){}function h(){}function d(){}var p={};p[o]=function(){return this};var _=Object.getPrototypeOf,v=_&&_(_(C([])));v&&v!==e&&r.call(v,o)&&(p=v);var E=d.prototype=l.prototype=Object.create(p);function g(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function y(t,e){var n;this._invoke=function(o,a){function i(){return new e((function(n,i){!function n(o,a,i,c){var s=u(t[o],t,a);if("throw"!==s.type){var f=s.arg,l=f.value;return l&&"object"==typeof l&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,i,c)}),(function(t){n("throw",t,i,c)})):e.resolve(l).then((function(t){f.value=t,i(f)}),(function(t){return n("throw",t,i,c)}))}c(s.arg)}(o,a,n,i)}))}return n=n?n.then(i,i):i()}}function R(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,R(t,e),"throw"===e.method))return f;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,f;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function I(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function C(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,a=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return a.next=a}}return{next:m}}function m(){return{value:void 0,done:!0}}return h.prototype=E.constructor=d,d.constructor=h,h.displayName=c(d,i,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,c(t,i,"GeneratorFunction")),t.prototype=Object.create(E),t},t.awrap=function(t){return{__await:t}},g(y.prototype),y.prototype[a]=function(){return this},t.AsyncIterator=y,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new y(s(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},g(E),c(E,i,"Generator"),E[o]=function(){return this},E.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=C,S.prototype={constructor:S,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(I),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return i.type="throw",i.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),s=r.call(a,"finallyLoc");if(c&&s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,f):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),I(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;I(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:C(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}));!function(t){t[t.ERR_STACKING_UNREACHABLE=255]="ERR_STACKING_UNREACHABLE",t[t.ERR_STACKING_INSUFFICIENT_FUNDS=1]="ERR_STACKING_INSUFFICIENT_FUNDS",t[t.ERR_STACKING_INVALID_LOCK_PERIOD=2]="ERR_STACKING_INVALID_LOCK_PERIOD",t[t.ERR_STACKING_ALREADY_STACKED=3]="ERR_STACKING_ALREADY_STACKED",t[t.ERR_STACKING_NO_SUCH_PRINCIPAL=4]="ERR_STACKING_NO_SUCH_PRINCIPAL",t[t.ERR_STACKING_EXPIRED=5]="ERR_STACKING_EXPIRED",t[t.ERR_STACKING_STX_LOCKED=6]="ERR_STACKING_STX_LOCKED",t[t.ERR_STACKING_PERMISSION_DENIED=9]="ERR_STACKING_PERMISSION_DENIED",t[t.ERR_STACKING_THRESHOLD_NOT_MET=11]="ERR_STACKING_THRESHOLD_NOT_MET",t[t.ERR_STACKING_POX_ADDRESS_IN_USE=12]="ERR_STACKING_POX_ADDRESS_IN_USE",t[t.ERR_STACKING_INVALID_POX_ADDRESS=13]="ERR_STACKING_INVALID_POX_ADDRESS",t[t.ERR_STACKING_ALREADY_REJECTED=17]="ERR_STACKING_ALREADY_REJECTED",t[t.ERR_STACKING_INVALID_AMOUNT=18]="ERR_STACKING_INVALID_AMOUNT",t[t.ERR_NOT_ALLOWED=19]="ERR_NOT_ALLOWED",t[t.ERR_STACKING_ALREADY_DELEGATED=20]="ERR_STACKING_ALREADY_DELEGATED",t[t.ERR_DELEGATION_EXPIRES_DURING_LOCK=21]="ERR_DELEGATION_EXPIRES_DURING_LOCK",t[t.ERR_DELEGATION_TOO_MUCH_LOCKED=22]="ERR_DELEGATION_TOO_MUCH_LOCKED",t[t.ERR_DELEGATION_POX_ADDR_REQUIRED=23]="ERR_DELEGATION_POX_ADDR_REQUIRED",t[t.ERR_INVALID_START_BURN_HEIGHT=24]="ERR_INVALID_START_BURN_HEIGHT"}(_||(_={}));var E=function(t){var e,r;function n(e,r){var n,o=e+" is not a valid P2PKH or P2SH address -- native P2WPKH and native P2WSH are not supported in PoX.";return(n=t.call(this,o)||this).message=o,n.name=n.constructor.name,n.innerError=r,Error.captureStackTrace&&Error.captureStackTrace(function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(n),n.constructor),n}return r=t,(e=n).prototype=Object.create(r.prototype),e.prototype.constructor=e,e.__proto__=r,n}(d(Error));function g(e){switch(e){case 0:case 111:return t.AddressHashMode.SerializeP2PKH;case 5:case 196:return t.AddressHashMode.SerializeP2SH;default:throw new Error("Invalid pox address version")}}function y(t){var e;try{e=n.address.fromBase58Check(t)}catch(e){throw new E(t,e)}return{hashMode:g(e.version),data:e.hash}}var R=function(){function e(t,e){this.address=t,this.network=e}var n=e.prototype;return n.getCoreInfo=function(){var t=c(v.mark((function t(){var e;return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.network.getInfoUrl(),t.abrupt("return",r.fetchPrivate(e).then((function(t){return t.json()})));case 2:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.getPoxInfo=function(){var t=c(v.mark((function t(){var e;return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.network.getPoxInfoUrl(),t.abrupt("return",r.fetchPrivate(e).then((function(t){return t.json()})));case 2:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.getTargetBlockTime=function(){var t=c(v.mark((function t(){var e,n;return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.network.getBlockTimeInfoUrl(),t.next=3,r.fetchPrivate(e).then((function(t){return t.json()}));case 3:if(n=t.sent,!this.network.isMainnet()){t.next=8;break}return t.abrupt("return",n.mainnet.target_block_time);case 8:return t.abrupt("return",n.testnet.target_block_time);case 9:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.getAccountStatus=function(){var t=c(v.mark((function t(){var e;return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.network.getAccountApiUrl(this.address),t.abrupt("return",r.fetchPrivate(e).then((function(t){return t.json()})));case 2:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.getAccountBalance=function(){var t=c(v.mark((function t(){return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getAccountStatus().then((function(t){var e=t.balance;return t.balance.startsWith("0x")&&(e=t.balance.substr(2)),new a.default(e,"hex")})));case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.getCycleDuration=function(){var t=c(v.mark((function t(){var e;return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.getPoxInfo(),t.next=3,this.getTargetBlockTime();case 3:return t.abrupt("return",Promise.all([e,t.sent]).then((function(t){return t[0].reward_cycle_length*t[1]})));case 5:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.getSecondsUntilNextCycle=function(){var t=c(v.mark((function t(){var e,r,n;return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.getPoxInfo(),t.next=3,this.getTargetBlockTime();case 3:return r=t.sent,n=this.getCoreInfo(),t.abrupt("return",Promise.all([e,r,n]).then((function(t){var e=t[0];return(e.reward_cycle_length-(t[2].burn_block_height-e.first_burnchain_block_height)%e.reward_cycle_length)*t[1]})));case 6:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.isStackingEnabledNextCycle=function(){var t=c(v.mark((function t(){return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getPoxInfo();case 2:return t.t0=t.sent.rejection_votes_left_required,t.abrupt("return",t.t0>0);case 4:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.hasMinimumStx=function(){var t=c(v.mark((function t(){var e,r;return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getAccountBalance();case 2:return e=t.sent,t.t0=a.default,t.next=6,this.getPoxInfo();case 6:return t.t1=t.sent.min_amount_ustx.toString(),r=new t.t0(t.t1),t.abrupt("return",e.gte(r));case 9:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.canStack=function(){var e=c(v.mark((function e(r){var n,o,i,c,s=this;return v.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.poxAddress,o=r.cycles,i=this.getAccountBalance(),c=this.getPoxInfo(),e.abrupt("return",Promise.all([i,c]).then((function(e){var r=e[0],i=e[1],c=y(n),u=c.data,f=t.bufferCV(new a.default(c.hashMode,10).toArrayLike(Buffer)),l=t.bufferCV(u),h=t.tupleCV({hashbytes:l,version:f}),d=s.parseContractId(i.contract_id);return t.callReadOnlyFunction({network:s.network,contractName:d[1],contractAddress:d[0],functionName:"can-stack-stx",senderAddress:s.address,functionArgs:[h,t.uintCV(r.toString()),t.uintCV(i.reward_cycle_id),t.uintCV(o.toString())]})})).then((function(e){return e.type===t.ClarityType.ResponseOk?{eligible:!0}:{eligible:!1,reason:_[+t.cvToString(e.value)]}})));case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.stack=function(){var e=c(v.mark((function e(r){var n,o,a,i,c,u;return v.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.amountMicroStx,o=r.poxAddress,a=r.cycles,i=r.privateKey,c=r.burnBlockHeight,e.next=3,this.getPoxInfo();case 3:return u=this.getStackOptions({amountMicroStx:n,cycles:a,poxAddress:o,contract:e.sent.contract_id,burnBlockHeight:c}),e.next=8,t.makeContractCall(s({},u,{senderKey:i}));case 8:return e.abrupt("return",t.broadcastTransaction(e.sent,u.network));case 10:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.delegateStx=function(){var e=c(v.mark((function e(r){var n,o,a,i,c,u;return v.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.amountMicroStx,o=r.delegateTo,a=r.untilBurnBlockHeight,i=r.poxAddress,c=r.privateKey,e.next=3,this.getPoxInfo();case 3:return u=this.getDelegateOptions({contract:e.sent.contract_id,amountMicroStx:n,delegateTo:o,untilBurnBlockHeight:a,poxAddress:i}),e.next=8,t.makeContractCall(s({},u,{senderKey:c}));case 8:return e.abrupt("return",t.broadcastTransaction(e.sent,u.network));case 10:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.delegateStackStx=function(){var e=c(v.mark((function e(r){var n,o,a,i,c,u,f,l;return v.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.stacker,o=r.amountMicroStx,a=r.poxAddress,i=r.burnBlockHeight,c=r.cycles,u=r.privateKey,f=r.nonce,e.next=3,this.getPoxInfo();case 3:return l=this.getDelegateStackOptions({contract:e.sent.contract_id,stacker:n,amountMicroStx:o,poxAddress:a,burnBlockHeight:i,cycles:c,nonce:f}),e.next=8,t.makeContractCall(s({},l,{senderKey:u}));case 8:return e.abrupt("return",t.broadcastTransaction(e.sent,l.network));case 10:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.stackAggregationCommit=function(){var e=c(v.mark((function e(r){var n,o,a,i;return v.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.poxAddress,o=r.rewardCycle,a=r.privateKey,e.next=3,this.getPoxInfo();case 3:return i=this.getStackAggregationCommitOptions({contract:e.sent.contract_id,poxAddress:n,rewardCycle:o}),e.next=8,t.makeContractCall(s({},i,{senderKey:a}));case 8:return e.abrupt("return",t.broadcastTransaction(e.sent,i.network));case 10:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.revokeDelegateStx=function(){var e=c(v.mark((function e(r){var n;return v.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPoxInfo();case 2:return n=this.getRevokeDelegateStxOptions(e.sent.contract_id),e.next=7,t.makeContractCall(s({},n,{senderKey:r}));case 7:return e.abrupt("return",t.broadcastTransaction(e.sent,n.network));case 9:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.getStackOptions=function(e){var r=e.amountMicroStx,n=e.cycles,o=e.contract,i=e.burnBlockHeight,c=y(e.poxAddress),s=c.data,u=t.bufferCV(new a.default(c.hashMode,10).toArrayLike(Buffer)),f=t.bufferCV(s),l=t.tupleCV({hashbytes:f,version:u}),h=this.parseContractId(o),d=this.network;return{contractAddress:h[0],contractName:h[1],functionName:"stack-stx",functionArgs:[t.uintCV(r.toString(10)),l,t.uintCV(i),t.uintCV(n)],validateWithAbi:!0,network:d}},n.getDelegateOptions=function(e){var r=e.contract,n=e.amountMicroStx,o=e.delegateTo,i=e.untilBurnBlockHeight,c=e.poxAddress,s=void 0;if(c){var u=y(c),f=u.data,l=t.bufferCV(new a.default(u.hashMode,10).toArrayLike(Buffer)),h=t.bufferCV(f);s=t.someCV(t.tupleCV({hashbytes:h,version:l}))}var d=this.parseContractId(r),p=this.network;return{contractAddress:d[0],contractName:d[1],functionName:"delegate-stx",functionArgs:[t.uintCV(n.toString(10)),t.standardPrincipalCV(o),i?t.someCV(t.uintCV(i)):t.noneCV(),s||t.noneCV()],validateWithAbi:!0,network:p}},n.getDelegateStackOptions=function(e){var r=e.contract,n=e.stacker,o=e.amountMicroStx,i=e.burnBlockHeight,c=e.cycles,s=e.nonce,u=y(e.poxAddress),f=u.data,l=t.bufferCV(new a.default(u.hashMode,10).toArrayLike(Buffer)),h=t.bufferCV(f),d=t.tupleCV({hashbytes:h,version:l}),p=this.parseContractId(r),_=this.network,v={contractAddress:p[0],contractName:p[1],functionName:"delegate-stack-stx",functionArgs:[t.standardPrincipalCV(n),t.uintCV(o.toString(10)),d,t.uintCV(i),t.uintCV(c)],validateWithAbi:!0,network:_};return s&&(v.nonce=s),v},n.getStackAggregationCommitOptions=function(e){var r=e.contract,n=e.rewardCycle,o=y(e.poxAddress),i=o.data,c=t.bufferCV(new a.default(o.hashMode,10).toArrayLike(Buffer)),s=t.bufferCV(i),u=t.tupleCV({hashbytes:s,version:c}),f=this.parseContractId(r),l=this.network;return{contractAddress:f[0],contractName:f[1],functionName:"stack-aggregation-commit",functionArgs:[u,t.uintCV(n)],validateWithAbi:!0,network:l}},n.getRevokeDelegateStxOptions=function(t){var e=this.parseContractId(t);return{contractAddress:e[0],contractName:e[1],functionName:"revoke-delegate-stx",functionArgs:[],validateWithAbi:!0,network:this.network}},n.getStatus=function(){var e=c(v.mark((function e(){var r,n,o,a;return v.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPoxInfo();case 2:return r=this.parseContractId(e.sent.contract_id),n=r[0],o=r[1],e.next=6,this.getAccountStatus();case 6:return a=e.sent,e.abrupt("return",t.callReadOnlyFunction({contractAddress:n,contractName:o,functionName:"get-stacker-info",senderAddress:this.address,functionArgs:[t.standardPrincipalCV(this.address)],network:this.network}).then((function(e){if(e.type===t.ClarityType.OptionalSome){var r=e.value,n=r.data["pox-addr"],o=r.data["first-reward-cycle"],i=r.data["lock-period"],c=n.data.version,s=n.data.hashbytes;return{stacked:!0,details:{amount_microstx:r.data["amount-ustx"].value.toString(),first_reward_cycle:o.value.toNumber(),lock_period:i.value.toNumber(),unlock_height:a.unlock_height,pox_address:{version:c.buffer,hashbytes:s.buffer}}}}if(e.type===t.ClarityType.OptionalNone)return{stacked:!1};throw new Error("Error fetching stacker info")})));case 9:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.modifyLockTxFee=function(e){var r=e.tx,n=e.amountMicroStx,o=r.auth.getFee();return r.payload.functionArgs[0]=t.uintCV(new a.default(n.toString(10),10).sub(o).toArrayLike(Buffer)),r},n.parseContractId=function(e){var r=e.split(".");if(2!==r.length||!t.validateStacksAddress(r[0])||"pox"!==r[1])throw new Error("Stacking contract ID is malformed");return r},e}();exports.InvalidAddressError=E,exports.StackingClient=R,exports.btcAddressVersionToHashMode=g,exports.decodeBtcAddress=y,exports.getAddressHashMode=function(t){try{return g(n.address.fromBase58Check(t).version)}catch(e){throw new E(t,e)}},exports.getBTCAddress=function(t,e){return n.address.toBase58Check(e,new a.default(t).toNumber())},exports.getErrorString=function(t){switch(t){case _.ERR_STACKING_UNREACHABLE:return"Stacking unreachable";case _.ERR_STACKING_INSUFFICIENT_FUNDS:return"Insufficient funds";case _.ERR_STACKING_INVALID_LOCK_PERIOD:return"Invalid lock period";case _.ERR_STACKING_ALREADY_STACKED:return"Account already stacked. Concurrent stacking not allowed.";case _.ERR_STACKING_NO_SUCH_PRINCIPAL:return"Principal does not exist";case _.ERR_STACKING_EXPIRED:return"Stacking expired";case _.ERR_STACKING_STX_LOCKED:return"STX balance is locked";case _.ERR_STACKING_PERMISSION_DENIED:return"Permission denied";case _.ERR_STACKING_THRESHOLD_NOT_MET:return"Stacking threshold not met";case _.ERR_STACKING_POX_ADDRESS_IN_USE:return"PoX address already in use";case _.ERR_STACKING_INVALID_POX_ADDRESS:return"Invalid PoX address";case _.ERR_STACKING_ALREADY_REJECTED:return"Stacking already rejected";case _.ERR_STACKING_INVALID_AMOUNT:return"Invalid amount";case _.ERR_NOT_ALLOWED:return"Stacking not allowed";case _.ERR_STACKING_ALREADY_DELEGATED:return"Already delegated";case _.ERR_DELEGATION_EXPIRES_DURING_LOCK:return"Delegation expires during lock period";case _.ERR_DELEGATION_TOO_MUCH_LOCKED:return"Delegation too much locked";case _.ERR_DELEGATION_POX_ADDR_REQUIRED:return"PoX address required for delegation";case _.ERR_INVALID_START_BURN_HEIGHT:return"Invalid start burn height"}}; | ||
//# sourceMappingURL=stacking.cjs.production.min.js.map |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@stacks/transactions"),require("bn.js"),require("@stacks/common"),require("bitcoinjs-lib")):"function"==typeof define&&define.amd?define(["exports","@stacks/transactions","bn.js","@stacks/common","bitcoinjs-lib"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["@stacks/stacking"]={},t.transactions,t.BN,t.common,t.bitcoinjsLib)}(this,(function(t,e,r,n,o){"use strict";function a(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var i=a(r);function c(t,e,r,n,o,a,i){try{var c=t[a](i),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,o)}function s(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function i(t){c(a,n,o,i,s,"next",t)}function s(t){c(a,n,o,i,s,"throw",t)}i(void 0)}))}}function u(){return(u=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function f(t,e){return t(e={exports:{}},e.exports),e.exports}var h,l=f((function(t){var e=function(t){var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function s(t,e,r,n){var o=Object.create((e&&e.prototype instanceof h?e:h).prototype),a=new w(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return{value:void 0,done:!0}}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var c=E(i,r);if(c){if(c===f)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var s=u(t,e,r);if("normal"===s.type){if(n=r.done?"completed":"suspendedYield",s.arg===f)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n="completed",r.method="throw",r.arg=s.arg)}}}(t,r,a),o}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;var f={};function h(){}function l(){}function d(){}var p={};p[o]=function(){return this};var v=Object.getPrototypeOf,g=v&&v(v(k([])));g&&g!==e&&r.call(g,o)&&(p=g);var _=d.prototype=h.prototype=Object.create(p);function y(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function m(t,e){var n;this._invoke=function(o,a){function i(){return new e((function(n,i){!function n(o,a,i,c){var s=u(t[o],t,a);if("throw"!==s.type){var f=s.arg,h=f.value;return h&&"object"==typeof h&&r.call(h,"__await")?e.resolve(h.__await).then((function(t){n("next",t,i,c)}),(function(t){n("throw",t,i,c)})):e.resolve(h).then((function(t){f.value=t,i(f)}),(function(t){return n("throw",t,i,c)}))}c(s.arg)}(o,a,n,i)}))}return n=n?n.then(i,i):i()}}function E(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method))return f;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,f;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function w(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function k(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,a=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return a.next=a}}return{next:R}}function R(){return{value:void 0,done:!0}}return l.prototype=_.constructor=d,d.constructor=l,l.displayName=c(d,i,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===l||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,c(t,i,"GeneratorFunction")),t.prototype=Object.create(_),t},t.awrap=function(t){return{__await:t}},y(m.prototype),m.prototype[a]=function(){return this},t.AsyncIterator=m,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new m(s(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},y(_),c(_,i,"Generator"),_[o]=function(){return this},_.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=k,w.prototype={constructor:w,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return i.type="throw",i.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),s=r.call(a,"finallyLoc");if(c&&s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,f):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),x(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:k(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}));function d(t){var r=function(t){if(t.startsWith("bc1")||t.startsWith("tb1"))return 32===o.address.fromBech32(t).data.length?e.AddressHashMode.SerializeP2WSH:e.AddressHashMode.SerializeP2WPKH;switch(o.address.fromBase58Check(t).version){case 0:case 111:return e.AddressHashMode.SerializeP2PKH;case 5:case 196:return e.AddressHashMode.SerializeP2SH;default:throw new Error("Invalid pox address version")}}(t);return t.startsWith("bc1")||t.startsWith("tb1")?{hashMode:r,data:o.address.fromBech32(t).data}:{hashMode:r,data:o.address.fromBase58Check(t).hash}}!function(t){t[t.ERR_STACKING_UNREACHABLE=255]="ERR_STACKING_UNREACHABLE",t[t.ERR_STACKING_INSUFFICIENT_FUNDS=1]="ERR_STACKING_INSUFFICIENT_FUNDS",t[t.ERR_STACKING_INVALID_LOCK_PERIOD=2]="ERR_STACKING_INVALID_LOCK_PERIOD",t[t.ERR_STACKING_ALREADY_STACKED=3]="ERR_STACKING_ALREADY_STACKED",t[t.ERR_STACKING_NO_SUCH_PRINCIPAL=4]="ERR_STACKING_NO_SUCH_PRINCIPAL",t[t.ERR_STACKING_EXPIRED=5]="ERR_STACKING_EXPIRED",t[t.ERR_STACKING_STX_LOCKED=6]="ERR_STACKING_STX_LOCKED",t[t.ERR_STACKING_PERMISSION_DENIED=9]="ERR_STACKING_PERMISSION_DENIED",t[t.ERR_STACKING_THRESHOLD_NOT_MET=11]="ERR_STACKING_THRESHOLD_NOT_MET",t[t.ERR_STACKING_POX_ADDRESS_IN_USE=12]="ERR_STACKING_POX_ADDRESS_IN_USE",t[t.ERR_STACKING_INVALID_POX_ADDRESS=13]="ERR_STACKING_INVALID_POX_ADDRESS",t[t.ERR_STACKING_ALREADY_REJECTED=17]="ERR_STACKING_ALREADY_REJECTED",t[t.ERR_STACKING_INVALID_AMOUNT=18]="ERR_STACKING_INVALID_AMOUNT",t[t.ERR_NOT_ALLOWED=19]="ERR_NOT_ALLOWED",t[t.ERR_STACKING_ALREADY_DELEGATED=20]="ERR_STACKING_ALREADY_DELEGATED",t[t.ERR_DELEGATION_EXPIRES_DURING_LOCK=21]="ERR_DELEGATION_EXPIRES_DURING_LOCK",t[t.ERR_DELEGATION_TOO_MUCH_LOCKED=22]="ERR_DELEGATION_TOO_MUCH_LOCKED",t[t.ERR_DELEGATION_POX_ADDR_REQUIRED=23]="ERR_DELEGATION_POX_ADDR_REQUIRED",t[t.ERR_INVALID_START_BURN_HEIGHT=24]="ERR_INVALID_START_BURN_HEIGHT"}(h||(h={})),t.StackingClient=function(){function t(t,e){this.address=t,this.network=e}var r=t.prototype;return r.getCoreInfo=function(){var t=s(l.mark((function t(){var e;return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.network.getInfoUrl(),t.abrupt("return",n.fetchPrivate(e).then((function(t){return t.json()})));case 2:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.getPoxInfo=function(){var t=s(l.mark((function t(){var e;return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.network.getPoxInfoUrl(),t.abrupt("return",n.fetchPrivate(e).then((function(t){return t.json()})));case 2:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.getTargetBlockTime=function(){var t=s(l.mark((function t(){var e,r;return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.network.getBlockTimeInfoUrl(),t.next=3,n.fetchPrivate(e).then((function(t){return t.json()}));case 3:if(r=t.sent,!this.network.isMainnet()){t.next=8;break}return t.abrupt("return",r.mainnet.target_block_time);case 8:return t.abrupt("return",r.testnet.target_block_time);case 9:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.getAccountStatus=function(){var t=s(l.mark((function t(){var e;return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.network.getAccountApiUrl(this.address),t.abrupt("return",n.fetchPrivate(e).then((function(t){return t.json()})));case 2:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.getAccountBalance=function(){var t=s(l.mark((function t(){return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getAccountStatus().then((function(t){var e=t.balance;return t.balance.startsWith("0x")&&(e=t.balance.substr(2)),new i.default(e,"hex")})));case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.getCycleDuration=function(){var t=s(l.mark((function t(){var e;return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.getPoxInfo(),t.next=3,this.getTargetBlockTime();case 3:return t.abrupt("return",Promise.all([e,t.sent]).then((function(t){return t[0].reward_cycle_length*t[1]})));case 5:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.getSecondsUntilNextCycle=function(){var t=s(l.mark((function t(){var e,r,n;return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.getPoxInfo(),t.next=3,this.getTargetBlockTime();case 3:return r=t.sent,n=this.getCoreInfo(),t.abrupt("return",Promise.all([e,r,n]).then((function(t){var e=t[0];return(e.reward_cycle_length-(t[2].burn_block_height-e.first_burnchain_block_height)%e.reward_cycle_length)*t[1]})));case 6:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.isStackingEnabledNextCycle=function(){var t=s(l.mark((function t(){return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getPoxInfo();case 2:return t.t0=t.sent.rejection_votes_left_required,t.abrupt("return",t.t0>0);case 4:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.hasMinimumStx=function(){var t=s(l.mark((function t(){var e,r;return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getAccountBalance();case 2:return e=t.sent,t.t0=i.default,t.next=6,this.getPoxInfo();case 6:return t.t1=t.sent.min_amount_ustx.toString(),r=new t.t0(t.t1),t.abrupt("return",e.gte(r));case 9:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.canStack=function(){var t=s(l.mark((function t(r){var n,o,a,c,s=this;return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.poxAddress,o=r.cycles,a=this.getAccountBalance(),c=this.getPoxInfo(),t.abrupt("return",Promise.all([a,c]).then((function(t){var r=t[0],a=t[1],c=d(n),u=c.data,f=e.bufferCV(new i.default(c.hashMode,10).toArrayLike(Buffer)),h=e.bufferCV(u),l=e.tupleCV({hashbytes:h,version:f}),p=s.parseContractId(a.contract_id);return e.callReadOnlyFunction({network:s.network,contractName:p[1],contractAddress:p[0],functionName:"can-stack-stx",senderAddress:s.address,functionArgs:[l,e.uintCV(r.toString()),e.uintCV(a.reward_cycle_id),e.uintCV(o.toString())]})})).then((function(t){return t.type===e.ClarityType.ResponseOk?{eligible:!0}:{eligible:!1,reason:h[+e.cvToString(t.value)]}})));case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.stack=function(){var t=s(l.mark((function t(r){var n,o,a,i,c,s;return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.amountMicroStx,o=r.poxAddress,a=r.cycles,i=r.privateKey,c=r.burnBlockHeight,t.next=3,this.getPoxInfo();case 3:return s=this.getStackOptions({amountMicroStx:n,cycles:a,poxAddress:o,contract:t.sent.contract_id,burnBlockHeight:c}),t.next=8,e.makeContractCall(u({},s,{senderKey:i}));case 8:return t.abrupt("return",e.broadcastTransaction(t.sent,s.network));case 10:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.delegateStx=function(){var t=s(l.mark((function t(r){var n,o,a,i,c,s;return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.amountMicroStx,o=r.delegateTo,a=r.untilBurnBlockHeight,i=r.poxAddress,c=r.privateKey,t.next=3,this.getPoxInfo();case 3:return s=this.getDelegateOptions({contract:t.sent.contract_id,amountMicroStx:n,delegateTo:o,untilBurnBlockHeight:a,poxAddress:i}),t.next=8,e.makeContractCall(u({},s,{senderKey:c}));case 8:return t.abrupt("return",e.broadcastTransaction(t.sent,s.network));case 10:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.delegateStackStx=function(){var t=s(l.mark((function t(r){var n,o,a,i,c,s,f,h;return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.stacker,o=r.amountMicroStx,a=r.poxAddress,i=r.burnBlockHeight,c=r.cycles,s=r.privateKey,f=r.nonce,t.next=3,this.getPoxInfo();case 3:return h=this.getDelegateStackOptions({contract:t.sent.contract_id,stacker:n,amountMicroStx:o,poxAddress:a,burnBlockHeight:i,cycles:c,nonce:f}),t.next=8,e.makeContractCall(u({},h,{senderKey:s}));case 8:return t.abrupt("return",e.broadcastTransaction(t.sent,h.network));case 10:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.stackAggregationCommit=function(){var t=s(l.mark((function t(r){var n,o,a,i;return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.poxAddress,o=r.rewardCycle,a=r.privateKey,t.next=3,this.getPoxInfo();case 3:return i=this.getStackAggregationCommitOptions({contract:t.sent.contract_id,poxAddress:n,rewardCycle:o}),t.next=8,e.makeContractCall(u({},i,{senderKey:a}));case 8:return t.abrupt("return",e.broadcastTransaction(t.sent,i.network));case 10:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.revokeDelegateStx=function(){var t=s(l.mark((function t(r){var n;return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getPoxInfo();case 2:return n=this.getRevokeDelegateStxOptions(t.sent.contract_id),t.next=7,e.makeContractCall(u({},n,{senderKey:r}));case 7:return t.abrupt("return",e.broadcastTransaction(t.sent,n.network));case 9:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.getStackOptions=function(t){var r=t.amountMicroStx,n=t.cycles,o=t.contract,a=t.burnBlockHeight,c=d(t.poxAddress),s=c.data,u=e.bufferCV(new i.default(c.hashMode,10).toArrayLike(Buffer)),f=e.bufferCV(s),h=e.tupleCV({hashbytes:f,version:u}),l=this.parseContractId(o),p=this.network;return{contractAddress:l[0],contractName:l[1],functionName:"stack-stx",functionArgs:[e.uintCV(r.toString(10)),h,e.uintCV(a),e.uintCV(n)],validateWithAbi:!0,network:p}},r.getDelegateOptions=function(t){var r=t.contract,n=t.amountMicroStx,o=t.delegateTo,a=t.untilBurnBlockHeight,c=t.poxAddress,s=void 0;if(c){var u=d(c),f=u.data,h=e.bufferCV(new i.default(u.hashMode,10).toArrayLike(Buffer)),l=e.bufferCV(f);s=e.someCV(e.tupleCV({hashbytes:l,version:h}))}var p=this.parseContractId(r),v=this.network;return{contractAddress:p[0],contractName:p[1],functionName:"delegate-stx",functionArgs:[e.uintCV(n.toString(10)),e.standardPrincipalCV(o),a?e.someCV(e.uintCV(a)):e.noneCV(),s||e.noneCV()],validateWithAbi:!0,network:v}},r.getDelegateStackOptions=function(t){var r=t.contract,n=t.stacker,o=t.amountMicroStx,a=t.burnBlockHeight,c=t.cycles,s=t.nonce,u=d(t.poxAddress),f=u.data,h=e.bufferCV(new i.default(u.hashMode,10).toArrayLike(Buffer)),l=e.bufferCV(f),p=e.tupleCV({hashbytes:l,version:h}),v=this.parseContractId(r),g=this.network,_={contractAddress:v[0],contractName:v[1],functionName:"delegate-stack-stx",functionArgs:[e.standardPrincipalCV(n),e.uintCV(o.toString(10)),p,e.uintCV(a),e.uintCV(c)],validateWithAbi:!0,network:g};return s&&(_.nonce=s),_},r.getStackAggregationCommitOptions=function(t){var r=t.contract,n=t.rewardCycle,o=d(t.poxAddress),a=o.data,c=e.bufferCV(new i.default(o.hashMode,10).toArrayLike(Buffer)),s=e.bufferCV(a),u=e.tupleCV({hashbytes:s,version:c}),f=this.parseContractId(r),h=this.network;return{contractAddress:f[0],contractName:f[1],functionName:"stack-aggregation-commit",functionArgs:[u,e.uintCV(n)],validateWithAbi:!0,network:h}},r.getRevokeDelegateStxOptions=function(t){var e=this.parseContractId(t);return{contractAddress:e[0],contractName:e[1],functionName:"revoke-delegate-stx",functionArgs:[],validateWithAbi:!0,network:this.network}},r.getStatus=function(){var t=s(l.mark((function t(){var r,n,o,a;return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getPoxInfo();case 2:return r=this.parseContractId(t.sent.contract_id),n=r[0],o=r[1],t.next=6,this.getAccountStatus();case 6:return a=t.sent,t.abrupt("return",e.callReadOnlyFunction({contractAddress:n,contractName:o,functionName:"get-stacker-info",senderAddress:this.address,functionArgs:[e.standardPrincipalCV(this.address)],network:this.network}).then((function(t){if(t.type===e.ClarityType.OptionalSome){var r=t.value,n=r.data["pox-addr"],o=r.data["first-reward-cycle"],i=r.data["lock-period"],c=n.data.version,s=n.data.hashbytes;return{stacked:!0,details:{amount_microstx:r.data["amount-ustx"].value.toString(),first_reward_cycle:o.value.toNumber(),lock_period:i.value.toNumber(),unlock_height:a.unlock_height,pox_address:{version:c.buffer,hashbytes:s.buffer}}}}if(t.type===e.ClarityType.OptionalNone)return{stacked:!1};throw new Error("Error fetching stacker info")})));case 9:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.modifyLockTxFee=function(t){var r=t.tx,n=t.amountMicroStx,o=r.auth.getFee();return r.payload.functionArgs[0]=e.uintCV(new i.default(n.toString(10),10).sub(o).toArrayLike(Buffer)),r},r.parseContractId=function(t){var r=t.split(".");if(2!==r.length||!e.validateStacksAddress(r[0])||"pox"!==r[1])throw new Error("Stacking contract ID is malformed");return r},t}(),Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@stacks/transactions"),require("bn.js"),require("@stacks/common"),require("bitcoinjs-lib")):"function"==typeof define&&define.amd?define(["exports","@stacks/transactions","bn.js","@stacks/common","bitcoinjs-lib"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["@stacks/stacking"]={},t.transactions,t.BN,t.common,t.bitcoinjsLib)}(this,(function(t,e,r,n,o){"use strict";function a(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var i=a(r);function c(t,e,r,n,o,a,i){try{var c=t[a](i),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,o)}function s(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function i(t){c(a,n,o,i,s,"next",t)}function s(t){c(a,n,o,i,s,"throw",t)}i(void 0)}))}}function u(){return(u=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function f(t){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function l(t,e){return(l=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function h(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function d(t,e,r){return(d=h()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&l(o,r.prototype),o}).apply(null,arguments)}function p(t){var e="function"==typeof Map?new Map:void 0;return(p=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return d(t,arguments,f(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),l(r,t)})(t)}function _(t,e){return t(e={exports:{}},e.exports),e.exports}var v,E=_((function(t){var e=function(t){var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function s(t,e,r,n){var o=Object.create((e&&e.prototype instanceof l?e:l).prototype),a=new S(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return{value:void 0,done:!0}}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var c=R(i,r);if(c){if(c===f)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var s=u(t,e,r);if("normal"===s.type){if(n=r.done?"completed":"suspendedYield",s.arg===f)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n="completed",r.method="throw",r.arg=s.arg)}}}(t,r,a),o}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;var f={};function l(){}function h(){}function d(){}var p={};p[o]=function(){return this};var _=Object.getPrototypeOf,v=_&&_(_(m([])));v&&v!==e&&r.call(v,o)&&(p=v);var E=d.prototype=l.prototype=Object.create(p);function g(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function y(t,e){var n;this._invoke=function(o,a){function i(){return new e((function(n,i){!function n(o,a,i,c){var s=u(t[o],t,a);if("throw"!==s.type){var f=s.arg,l=f.value;return l&&"object"==typeof l&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,i,c)}),(function(t){n("throw",t,i,c)})):e.resolve(l).then((function(t){f.value=t,i(f)}),(function(t){return n("throw",t,i,c)}))}c(s.arg)}(o,a,n,i)}))}return n=n?n.then(i,i):i()}}function R(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,R(t,e),"throw"===e.method))return f;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,f;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function I(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function m(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,a=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return a.next=a}}return{next:C}}function C(){return{value:void 0,done:!0}}return h.prototype=E.constructor=d,d.constructor=h,h.displayName=c(d,i,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,c(t,i,"GeneratorFunction")),t.prototype=Object.create(E),t},t.awrap=function(t){return{__await:t}},g(y.prototype),y.prototype[a]=function(){return this},t.AsyncIterator=y,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new y(s(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},g(E),c(E,i,"Generator"),E[o]=function(){return this},E.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=m,S.prototype={constructor:S,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(I),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return i.type="throw",i.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),s=r.call(a,"finallyLoc");if(c&&s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,f):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),I(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;I(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:m(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}));!function(t){t[t.ERR_STACKING_UNREACHABLE=255]="ERR_STACKING_UNREACHABLE",t[t.ERR_STACKING_INSUFFICIENT_FUNDS=1]="ERR_STACKING_INSUFFICIENT_FUNDS",t[t.ERR_STACKING_INVALID_LOCK_PERIOD=2]="ERR_STACKING_INVALID_LOCK_PERIOD",t[t.ERR_STACKING_ALREADY_STACKED=3]="ERR_STACKING_ALREADY_STACKED",t[t.ERR_STACKING_NO_SUCH_PRINCIPAL=4]="ERR_STACKING_NO_SUCH_PRINCIPAL",t[t.ERR_STACKING_EXPIRED=5]="ERR_STACKING_EXPIRED",t[t.ERR_STACKING_STX_LOCKED=6]="ERR_STACKING_STX_LOCKED",t[t.ERR_STACKING_PERMISSION_DENIED=9]="ERR_STACKING_PERMISSION_DENIED",t[t.ERR_STACKING_THRESHOLD_NOT_MET=11]="ERR_STACKING_THRESHOLD_NOT_MET",t[t.ERR_STACKING_POX_ADDRESS_IN_USE=12]="ERR_STACKING_POX_ADDRESS_IN_USE",t[t.ERR_STACKING_INVALID_POX_ADDRESS=13]="ERR_STACKING_INVALID_POX_ADDRESS",t[t.ERR_STACKING_ALREADY_REJECTED=17]="ERR_STACKING_ALREADY_REJECTED",t[t.ERR_STACKING_INVALID_AMOUNT=18]="ERR_STACKING_INVALID_AMOUNT",t[t.ERR_NOT_ALLOWED=19]="ERR_NOT_ALLOWED",t[t.ERR_STACKING_ALREADY_DELEGATED=20]="ERR_STACKING_ALREADY_DELEGATED",t[t.ERR_DELEGATION_EXPIRES_DURING_LOCK=21]="ERR_DELEGATION_EXPIRES_DURING_LOCK",t[t.ERR_DELEGATION_TOO_MUCH_LOCKED=22]="ERR_DELEGATION_TOO_MUCH_LOCKED",t[t.ERR_DELEGATION_POX_ADDR_REQUIRED=23]="ERR_DELEGATION_POX_ADDR_REQUIRED",t[t.ERR_INVALID_START_BURN_HEIGHT=24]="ERR_INVALID_START_BURN_HEIGHT"}(v||(v={}));var g=function(t){var e,r;function n(e,r){var n,o=e+" is not a valid P2PKH or P2SH address -- native P2WPKH and native P2WSH are not supported in PoX.";return(n=t.call(this,o)||this).message=o,n.name=n.constructor.name,n.innerError=r,Error.captureStackTrace&&Error.captureStackTrace(function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(n),n.constructor),n}return r=t,(e=n).prototype=Object.create(r.prototype),e.prototype.constructor=e,e.__proto__=r,n}(p(Error));function y(t){switch(t){case 0:case 111:return e.AddressHashMode.SerializeP2PKH;case 5:case 196:return e.AddressHashMode.SerializeP2SH;default:throw new Error("Invalid pox address version")}}function R(t){var e;try{e=o.address.fromBase58Check(t)}catch(e){throw new g(t,e)}return{hashMode:y(e.version),data:e.hash}}var A=function(){function t(t,e){this.address=t,this.network=e}var r=t.prototype;return r.getCoreInfo=function(){var t=s(E.mark((function t(){var e;return E.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.network.getInfoUrl(),t.abrupt("return",n.fetchPrivate(e).then((function(t){return t.json()})));case 2:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.getPoxInfo=function(){var t=s(E.mark((function t(){var e;return E.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.network.getPoxInfoUrl(),t.abrupt("return",n.fetchPrivate(e).then((function(t){return t.json()})));case 2:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.getTargetBlockTime=function(){var t=s(E.mark((function t(){var e,r;return E.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.network.getBlockTimeInfoUrl(),t.next=3,n.fetchPrivate(e).then((function(t){return t.json()}));case 3:if(r=t.sent,!this.network.isMainnet()){t.next=8;break}return t.abrupt("return",r.mainnet.target_block_time);case 8:return t.abrupt("return",r.testnet.target_block_time);case 9:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.getAccountStatus=function(){var t=s(E.mark((function t(){var e;return E.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.network.getAccountApiUrl(this.address),t.abrupt("return",n.fetchPrivate(e).then((function(t){return t.json()})));case 2:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.getAccountBalance=function(){var t=s(E.mark((function t(){return E.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getAccountStatus().then((function(t){var e=t.balance;return t.balance.startsWith("0x")&&(e=t.balance.substr(2)),new i.default(e,"hex")})));case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.getCycleDuration=function(){var t=s(E.mark((function t(){var e;return E.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.getPoxInfo(),t.next=3,this.getTargetBlockTime();case 3:return t.abrupt("return",Promise.all([e,t.sent]).then((function(t){return t[0].reward_cycle_length*t[1]})));case 5:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.getSecondsUntilNextCycle=function(){var t=s(E.mark((function t(){var e,r,n;return E.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.getPoxInfo(),t.next=3,this.getTargetBlockTime();case 3:return r=t.sent,n=this.getCoreInfo(),t.abrupt("return",Promise.all([e,r,n]).then((function(t){var e=t[0];return(e.reward_cycle_length-(t[2].burn_block_height-e.first_burnchain_block_height)%e.reward_cycle_length)*t[1]})));case 6:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.isStackingEnabledNextCycle=function(){var t=s(E.mark((function t(){return E.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getPoxInfo();case 2:return t.t0=t.sent.rejection_votes_left_required,t.abrupt("return",t.t0>0);case 4:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.hasMinimumStx=function(){var t=s(E.mark((function t(){var e,r;return E.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getAccountBalance();case 2:return e=t.sent,t.t0=i.default,t.next=6,this.getPoxInfo();case 6:return t.t1=t.sent.min_amount_ustx.toString(),r=new t.t0(t.t1),t.abrupt("return",e.gte(r));case 9:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.canStack=function(){var t=s(E.mark((function t(r){var n,o,a,c,s=this;return E.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.poxAddress,o=r.cycles,a=this.getAccountBalance(),c=this.getPoxInfo(),t.abrupt("return",Promise.all([a,c]).then((function(t){var r=t[0],a=t[1],c=R(n),u=c.data,f=e.bufferCV(new i.default(c.hashMode,10).toArrayLike(Buffer)),l=e.bufferCV(u),h=e.tupleCV({hashbytes:l,version:f}),d=s.parseContractId(a.contract_id);return e.callReadOnlyFunction({network:s.network,contractName:d[1],contractAddress:d[0],functionName:"can-stack-stx",senderAddress:s.address,functionArgs:[h,e.uintCV(r.toString()),e.uintCV(a.reward_cycle_id),e.uintCV(o.toString())]})})).then((function(t){return t.type===e.ClarityType.ResponseOk?{eligible:!0}:{eligible:!1,reason:v[+e.cvToString(t.value)]}})));case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.stack=function(){var t=s(E.mark((function t(r){var n,o,a,i,c,s;return E.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.amountMicroStx,o=r.poxAddress,a=r.cycles,i=r.privateKey,c=r.burnBlockHeight,t.next=3,this.getPoxInfo();case 3:return s=this.getStackOptions({amountMicroStx:n,cycles:a,poxAddress:o,contract:t.sent.contract_id,burnBlockHeight:c}),t.next=8,e.makeContractCall(u({},s,{senderKey:i}));case 8:return t.abrupt("return",e.broadcastTransaction(t.sent,s.network));case 10:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.delegateStx=function(){var t=s(E.mark((function t(r){var n,o,a,i,c,s;return E.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.amountMicroStx,o=r.delegateTo,a=r.untilBurnBlockHeight,i=r.poxAddress,c=r.privateKey,t.next=3,this.getPoxInfo();case 3:return s=this.getDelegateOptions({contract:t.sent.contract_id,amountMicroStx:n,delegateTo:o,untilBurnBlockHeight:a,poxAddress:i}),t.next=8,e.makeContractCall(u({},s,{senderKey:c}));case 8:return t.abrupt("return",e.broadcastTransaction(t.sent,s.network));case 10:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.delegateStackStx=function(){var t=s(E.mark((function t(r){var n,o,a,i,c,s,f,l;return E.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.stacker,o=r.amountMicroStx,a=r.poxAddress,i=r.burnBlockHeight,c=r.cycles,s=r.privateKey,f=r.nonce,t.next=3,this.getPoxInfo();case 3:return l=this.getDelegateStackOptions({contract:t.sent.contract_id,stacker:n,amountMicroStx:o,poxAddress:a,burnBlockHeight:i,cycles:c,nonce:f}),t.next=8,e.makeContractCall(u({},l,{senderKey:s}));case 8:return t.abrupt("return",e.broadcastTransaction(t.sent,l.network));case 10:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.stackAggregationCommit=function(){var t=s(E.mark((function t(r){var n,o,a,i;return E.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.poxAddress,o=r.rewardCycle,a=r.privateKey,t.next=3,this.getPoxInfo();case 3:return i=this.getStackAggregationCommitOptions({contract:t.sent.contract_id,poxAddress:n,rewardCycle:o}),t.next=8,e.makeContractCall(u({},i,{senderKey:a}));case 8:return t.abrupt("return",e.broadcastTransaction(t.sent,i.network));case 10:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.revokeDelegateStx=function(){var t=s(E.mark((function t(r){var n;return E.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getPoxInfo();case 2:return n=this.getRevokeDelegateStxOptions(t.sent.contract_id),t.next=7,e.makeContractCall(u({},n,{senderKey:r}));case 7:return t.abrupt("return",e.broadcastTransaction(t.sent,n.network));case 9:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.getStackOptions=function(t){var r=t.amountMicroStx,n=t.cycles,o=t.contract,a=t.burnBlockHeight,c=R(t.poxAddress),s=c.data,u=e.bufferCV(new i.default(c.hashMode,10).toArrayLike(Buffer)),f=e.bufferCV(s),l=e.tupleCV({hashbytes:f,version:u}),h=this.parseContractId(o),d=this.network;return{contractAddress:h[0],contractName:h[1],functionName:"stack-stx",functionArgs:[e.uintCV(r.toString(10)),l,e.uintCV(a),e.uintCV(n)],validateWithAbi:!0,network:d}},r.getDelegateOptions=function(t){var r=t.contract,n=t.amountMicroStx,o=t.delegateTo,a=t.untilBurnBlockHeight,c=t.poxAddress,s=void 0;if(c){var u=R(c),f=u.data,l=e.bufferCV(new i.default(u.hashMode,10).toArrayLike(Buffer)),h=e.bufferCV(f);s=e.someCV(e.tupleCV({hashbytes:h,version:l}))}var d=this.parseContractId(r),p=this.network;return{contractAddress:d[0],contractName:d[1],functionName:"delegate-stx",functionArgs:[e.uintCV(n.toString(10)),e.standardPrincipalCV(o),a?e.someCV(e.uintCV(a)):e.noneCV(),s||e.noneCV()],validateWithAbi:!0,network:p}},r.getDelegateStackOptions=function(t){var r=t.contract,n=t.stacker,o=t.amountMicroStx,a=t.burnBlockHeight,c=t.cycles,s=t.nonce,u=R(t.poxAddress),f=u.data,l=e.bufferCV(new i.default(u.hashMode,10).toArrayLike(Buffer)),h=e.bufferCV(f),d=e.tupleCV({hashbytes:h,version:l}),p=this.parseContractId(r),_=this.network,v={contractAddress:p[0],contractName:p[1],functionName:"delegate-stack-stx",functionArgs:[e.standardPrincipalCV(n),e.uintCV(o.toString(10)),d,e.uintCV(a),e.uintCV(c)],validateWithAbi:!0,network:_};return s&&(v.nonce=s),v},r.getStackAggregationCommitOptions=function(t){var r=t.contract,n=t.rewardCycle,o=R(t.poxAddress),a=o.data,c=e.bufferCV(new i.default(o.hashMode,10).toArrayLike(Buffer)),s=e.bufferCV(a),u=e.tupleCV({hashbytes:s,version:c}),f=this.parseContractId(r),l=this.network;return{contractAddress:f[0],contractName:f[1],functionName:"stack-aggregation-commit",functionArgs:[u,e.uintCV(n)],validateWithAbi:!0,network:l}},r.getRevokeDelegateStxOptions=function(t){var e=this.parseContractId(t);return{contractAddress:e[0],contractName:e[1],functionName:"revoke-delegate-stx",functionArgs:[],validateWithAbi:!0,network:this.network}},r.getStatus=function(){var t=s(E.mark((function t(){var r,n,o,a;return E.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getPoxInfo();case 2:return r=this.parseContractId(t.sent.contract_id),n=r[0],o=r[1],t.next=6,this.getAccountStatus();case 6:return a=t.sent,t.abrupt("return",e.callReadOnlyFunction({contractAddress:n,contractName:o,functionName:"get-stacker-info",senderAddress:this.address,functionArgs:[e.standardPrincipalCV(this.address)],network:this.network}).then((function(t){if(t.type===e.ClarityType.OptionalSome){var r=t.value,n=r.data["pox-addr"],o=r.data["first-reward-cycle"],i=r.data["lock-period"],c=n.data.version,s=n.data.hashbytes;return{stacked:!0,details:{amount_microstx:r.data["amount-ustx"].value.toString(),first_reward_cycle:o.value.toNumber(),lock_period:i.value.toNumber(),unlock_height:a.unlock_height,pox_address:{version:c.buffer,hashbytes:s.buffer}}}}if(t.type===e.ClarityType.OptionalNone)return{stacked:!1};throw new Error("Error fetching stacker info")})));case 9:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.modifyLockTxFee=function(t){var r=t.tx,n=t.amountMicroStx,o=r.auth.getFee();return r.payload.functionArgs[0]=e.uintCV(new i.default(n.toString(10),10).sub(o).toArrayLike(Buffer)),r},r.parseContractId=function(t){var r=t.split(".");if(2!==r.length||!e.validateStacksAddress(r[0])||"pox"!==r[1])throw new Error("Stacking contract ID is malformed");return r},t}();t.InvalidAddressError=g,t.StackingClient=A,t.btcAddressVersionToHashMode=y,t.decodeBtcAddress=R,t.getAddressHashMode=function(t){try{return y(o.address.fromBase58Check(t).version)}catch(e){throw new g(t,e)}},t.getBTCAddress=function(t,e){return o.address.toBase58Check(e,new i.default(t).toNumber())},t.getErrorString=function(t){switch(t){case v.ERR_STACKING_UNREACHABLE:return"Stacking unreachable";case v.ERR_STACKING_INSUFFICIENT_FUNDS:return"Insufficient funds";case v.ERR_STACKING_INVALID_LOCK_PERIOD:return"Invalid lock period";case v.ERR_STACKING_ALREADY_STACKED:return"Account already stacked. Concurrent stacking not allowed.";case v.ERR_STACKING_NO_SUCH_PRINCIPAL:return"Principal does not exist";case v.ERR_STACKING_EXPIRED:return"Stacking expired";case v.ERR_STACKING_STX_LOCKED:return"STX balance is locked";case v.ERR_STACKING_PERMISSION_DENIED:return"Permission denied";case v.ERR_STACKING_THRESHOLD_NOT_MET:return"Stacking threshold not met";case v.ERR_STACKING_POX_ADDRESS_IN_USE:return"PoX address already in use";case v.ERR_STACKING_INVALID_POX_ADDRESS:return"Invalid PoX address";case v.ERR_STACKING_ALREADY_REJECTED:return"Stacking already rejected";case v.ERR_STACKING_INVALID_AMOUNT:return"Invalid amount";case v.ERR_NOT_ALLOWED:return"Stacking not allowed";case v.ERR_STACKING_ALREADY_DELEGATED:return"Already delegated";case v.ERR_DELEGATION_EXPIRES_DURING_LOCK:return"Delegation expires during lock period";case v.ERR_DELEGATION_TOO_MUCH_LOCKED:return"Delegation too much locked";case v.ERR_DELEGATION_POX_ADDR_REQUIRED:return"PoX address required for delegation";case v.ERR_INVALID_START_BURN_HEIGHT:return"Invalid start burn height"}},Object.defineProperty(t,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=stacking.umd.production.min.js.map |
@@ -5,2 +5,3 @@ /// <reference types="node" /> | ||
import BN from 'bn.js'; | ||
export * from './utils'; | ||
export interface PoxInfo { | ||
@@ -7,0 +8,0 @@ contract_id: string; |
/// <reference types="node" /> | ||
import { AddressHashMode } from '@stacks/transactions'; | ||
import { StackingErrors } from './constants'; | ||
export declare class InvalidAddressError extends Error { | ||
innerError?: Error; | ||
constructor(address: string, innerError?: Error); | ||
} | ||
export declare function btcAddressVersionToHashMode(btcAddressVersion: number): AddressHashMode; | ||
export declare function getAddressHashMode(btcAddress: string): AddressHashMode; | ||
@@ -5,0 +10,0 @@ export declare function decodeBtcAddress(btcAddress: string): { |
@@ -0,61 +1,137 @@ | ||
import { inheritsLoose as _inheritsLoose, assertThisInitialized as _assertThisInitialized, wrapNativeSuper as _wrapNativeSuper } from './_virtual/_rollupPluginBabelHelpers.js'; | ||
import { AddressHashMode } from '@stacks/transactions'; | ||
import 'bn.js'; | ||
import './constants.esm.js'; | ||
import BN from 'bn.js'; | ||
import { StackingErrors } from './constants.esm.js'; | ||
import { address } from 'bitcoinjs-lib'; | ||
function getAddressHashMode(btcAddress) { | ||
if (btcAddress.startsWith('bc1') || btcAddress.startsWith('tb1')) { | ||
var _address$fromBech = address.fromBech32(btcAddress), | ||
data = _address$fromBech.data; | ||
var InvalidAddressError = /*#__PURE__*/function (_Error) { | ||
_inheritsLoose(InvalidAddressError, _Error); | ||
if (data.length === 32) { | ||
return AddressHashMode.SerializeP2WSH; | ||
} else { | ||
return AddressHashMode.SerializeP2WPKH; | ||
function InvalidAddressError(address, innerError) { | ||
var _this; | ||
var msg = address + " is not a valid P2PKH or P2SH address -- native P2WPKH and native P2WSH are not supported in PoX."; | ||
_this = _Error.call(this, msg) || this; | ||
_this.message = msg; | ||
_this.name = _this.constructor.name; | ||
_this.innerError = innerError; | ||
if (Error.captureStackTrace) { | ||
Error.captureStackTrace(_assertThisInitialized(_this), _this.constructor); | ||
} | ||
} else { | ||
var _address$fromBase58Ch = address.fromBase58Check(btcAddress), | ||
version = _address$fromBase58Ch.version; | ||
switch (version) { | ||
case 0: | ||
return AddressHashMode.SerializeP2PKH; | ||
return _this; | ||
} | ||
case 111: | ||
return AddressHashMode.SerializeP2PKH; | ||
return InvalidAddressError; | ||
}( /*#__PURE__*/_wrapNativeSuper(Error)); | ||
function btcAddressVersionToHashMode(btcAddressVersion) { | ||
switch (btcAddressVersion) { | ||
case 0: | ||
return AddressHashMode.SerializeP2PKH; | ||
case 5: | ||
return AddressHashMode.SerializeP2SH; | ||
case 111: | ||
return AddressHashMode.SerializeP2PKH; | ||
case 196: | ||
return AddressHashMode.SerializeP2SH; | ||
case 5: | ||
return AddressHashMode.SerializeP2SH; | ||
default: | ||
throw new Error('Invalid pox address version'); | ||
} | ||
case 196: | ||
return AddressHashMode.SerializeP2SH; | ||
default: | ||
throw new Error('Invalid pox address version'); | ||
} | ||
} | ||
function getAddressHashMode(btcAddress) { | ||
try { | ||
var _address$fromBase58Ch = address.fromBase58Check(btcAddress), | ||
version = _address$fromBase58Ch.version; | ||
return btcAddressVersionToHashMode(version); | ||
} catch (error) { | ||
throw new InvalidAddressError(btcAddress, error); | ||
} | ||
} | ||
function decodeBtcAddress(btcAddress) { | ||
var hashMode = getAddressHashMode(btcAddress); | ||
var b58Result; | ||
if (btcAddress.startsWith('bc1') || btcAddress.startsWith('tb1')) { | ||
var _address$fromBech2 = address.fromBech32(btcAddress), | ||
data = _address$fromBech2.data; | ||
try { | ||
b58Result = address.fromBase58Check(btcAddress); | ||
} catch (error) { | ||
throw new InvalidAddressError(btcAddress, error); | ||
} | ||
return { | ||
hashMode: hashMode, | ||
data: data | ||
}; | ||
} else { | ||
var _address$fromBase58Ch2 = address.fromBase58Check(btcAddress), | ||
hash = _address$fromBase58Ch2.hash; | ||
var hashMode = btcAddressVersionToHashMode(b58Result.version); | ||
return { | ||
hashMode: hashMode, | ||
data: b58Result.hash | ||
}; | ||
} | ||
function getBTCAddress(version, checksum) { | ||
var btcAddress = address.toBase58Check(checksum, new BN(version).toNumber()); | ||
return btcAddress; | ||
} | ||
function getErrorString(error) { | ||
switch (error) { | ||
case StackingErrors.ERR_STACKING_UNREACHABLE: | ||
return 'Stacking unreachable'; | ||
return { | ||
hashMode: hashMode, | ||
data: hash | ||
}; | ||
case StackingErrors.ERR_STACKING_INSUFFICIENT_FUNDS: | ||
return 'Insufficient funds'; | ||
case StackingErrors.ERR_STACKING_INVALID_LOCK_PERIOD: | ||
return 'Invalid lock period'; | ||
case StackingErrors.ERR_STACKING_ALREADY_STACKED: | ||
return 'Account already stacked. Concurrent stacking not allowed.'; | ||
case StackingErrors.ERR_STACKING_NO_SUCH_PRINCIPAL: | ||
return 'Principal does not exist'; | ||
case StackingErrors.ERR_STACKING_EXPIRED: | ||
return 'Stacking expired'; | ||
case StackingErrors.ERR_STACKING_STX_LOCKED: | ||
return 'STX balance is locked'; | ||
case StackingErrors.ERR_STACKING_PERMISSION_DENIED: | ||
return 'Permission denied'; | ||
case StackingErrors.ERR_STACKING_THRESHOLD_NOT_MET: | ||
return 'Stacking threshold not met'; | ||
case StackingErrors.ERR_STACKING_POX_ADDRESS_IN_USE: | ||
return 'PoX address already in use'; | ||
case StackingErrors.ERR_STACKING_INVALID_POX_ADDRESS: | ||
return 'Invalid PoX address'; | ||
case StackingErrors.ERR_STACKING_ALREADY_REJECTED: | ||
return 'Stacking already rejected'; | ||
case StackingErrors.ERR_STACKING_INVALID_AMOUNT: | ||
return 'Invalid amount'; | ||
case StackingErrors.ERR_NOT_ALLOWED: | ||
return 'Stacking not allowed'; | ||
case StackingErrors.ERR_STACKING_ALREADY_DELEGATED: | ||
return 'Already delegated'; | ||
case StackingErrors.ERR_DELEGATION_EXPIRES_DURING_LOCK: | ||
return 'Delegation expires during lock period'; | ||
case StackingErrors.ERR_DELEGATION_TOO_MUCH_LOCKED: | ||
return 'Delegation too much locked'; | ||
case StackingErrors.ERR_DELEGATION_POX_ADDR_REQUIRED: | ||
return 'PoX address required for delegation'; | ||
case StackingErrors.ERR_INVALID_START_BURN_HEIGHT: | ||
return 'Invalid start burn height'; | ||
} | ||
} | ||
export { decodeBtcAddress, getAddressHashMode }; | ||
export { InvalidAddressError, btcAddressVersionToHashMode, decodeBtcAddress, getAddressHashMode, getBTCAddress, getErrorString }; | ||
//# sourceMappingURL=utils.esm.js.map |
{ | ||
"name": "@stacks/stacking", | ||
"version": "1.3.3", | ||
"version": "1.3.4", | ||
"description": "Library for Stacking.", | ||
@@ -68,3 +68,3 @@ "keywords": [ | ||
"unpkg": "dist/stacking.cjs.production.min.js", | ||
"gitHead": "38c9cb1ff0a3ddc149d8bc165a50bff1b3586338" | ||
"gitHead": "88af9d42f4df761f40838debeee4eaa89995ad52" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
681836
5094