@stacks/bns
Advanced tools
Comparing version 1.4.0-alpha.0 to 1.4.1-alpha.0
@@ -1030,3 +1030,3 @@ 'use strict'; | ||
bnsFunctionName = 'namespace-preorder'; | ||
saltedNamespaceBuffer = Buffer.from("0x" + namespace + salt); | ||
saltedNamespaceBuffer = Buffer.from("" + namespace + salt); | ||
hashedSaltedNamespace = transactions.hash160(saltedNamespaceBuffer); | ||
@@ -1166,3 +1166,3 @@ return _context6.abrupt("return", makeBnsContractCall({ | ||
case 5: | ||
saltedNamesBuffer = Buffer.from("0x" + fullyQualifiedName + salt); | ||
saltedNamesBuffer = Buffer.from("" + fullyQualifiedName + salt); | ||
hashedSaltedName = transactions.hash160(saltedNamesBuffer); | ||
@@ -1169,0 +1169,0 @@ return _context10.abrupt("return", makeBnsContractCall({ |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@stacks/transactions"),r=require("@stacks/common");function t(e,r,t,n,o,a,i){try{var u=e[a](i),c=u.value}catch(e){return void t(e)}u.done?r(c):Promise.resolve(c).then(n,o)}function n(e){return function(){var r=this,n=arguments;return new Promise((function(o,a){var i=e.apply(r,n);function u(e){t(i,o,a,u,c,"next",e)}function c(e){t(i,o,a,u,c,"throw",e)}u(void 0)}))}}function o(e,r){return e(r={exports:{}},r.exports),r.exports}var a=o((function(e){var r=function(e){var r=Object.prototype,t=r.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function u(e,r,t){return Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}),e[r]}try{u({},"")}catch(e){u=function(e,r,t){return e[r]=t}}function c(e,r,t,n){var o=Object.create((r&&r.prototype instanceof p?r:p).prototype),a=new N(n||[]);return o._invoke=function(e,r,t){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(t.method=o,t.arg=a;;){var i=t.delegate;if(i){var u=g(i,t);if(u){if(u===f)continue;return u}}if("next"===t.method)t.sent=t._sent=t.arg;else if("throw"===t.method){if("suspendedStart"===n)throw n="completed",t.arg;t.dispatchException(t.arg)}else"return"===t.method&&t.abrupt("return",t.arg);n="executing";var c=s(e,r,t);if("normal"===c.type){if(n=t.done?"completed":"suspendedYield",c.arg===f)continue;return{value:c.arg,done:t.done}}"throw"===c.type&&(n="completed",t.method="throw",t.arg=c.arg)}}}(e,t,a),o}function s(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var f={};function p(){}function l(){}function h(){}var m={};m[o]=function(){return this};var d=Object.getPrototypeOf,y=d&&d(d(T([])));y&&y!==r&&t.call(y,o)&&(m=y);var v=h.prototype=p.prototype=Object.create(m);function w(e){["next","throw","return"].forEach((function(r){u(e,r,(function(e){return this._invoke(r,e)}))}))}function b(e,r){var n;this._invoke=function(o,a){function i(){return new r((function(n,i){!function n(o,a,i,u){var c=s(e[o],e,a);if("throw"!==c.type){var f=c.arg,p=f.value;return p&&"object"==typeof p&&t.call(p,"__await")?r.resolve(p.__await).then((function(e){n("next",e,i,u)}),(function(e){n("throw",e,i,u)})):r.resolve(p).then((function(e){f.value=e,i(f)}),(function(e){return n("throw",e,i,u)}))}u(c.arg)}(o,a,n,i)}))}return n=n?n.then(i,i):i()}}function g(e,r){var t=e.iterator[r.method];if(void 0===t){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=void 0,g(e,r),"throw"===r.method))return f;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=s(t,e.iterator,r.arg);if("throw"===n.type)return r.method="throw",r.arg=n.arg,r.delegate=null,f;var o=n.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,f):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,f)}function x(e){var r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),this.tryEntries.push(r)}function k(e){var r=e.completion||{};r.type="normal",delete r.arg,e.completion=r}function N(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function T(e){if(e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,a=function r(){for(;++n<e.length;)if(t.call(e,n))return r.value=e[n],r.done=!1,r;return r.value=void 0,r.done=!0,r};return a.next=a}}return{next:E}}function E(){return{value:void 0,done:!0}}return l.prototype=v.constructor=h,h.constructor=l,l.displayName=u(h,i,"GeneratorFunction"),e.isGeneratorFunction=function(e){var r="function"==typeof e&&e.constructor;return!!r&&(r===l||"GeneratorFunction"===(r.displayName||r.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,h):(e.__proto__=h,u(e,i,"GeneratorFunction")),e.prototype=Object.create(v),e},e.awrap=function(e){return{__await:e}},w(b.prototype),b.prototype[a]=function(){return this},e.AsyncIterator=b,e.async=function(r,t,n,o,a){void 0===a&&(a=Promise);var i=new b(c(r,t,n,o),a);return e.isGeneratorFunction(t)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},w(v),u(v,i,"Generator"),v[o]=function(){return this},v.toString=function(){return"[object Generator]"},e.keys=function(e){var r=[];for(var t in e)r.push(t);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=T,N.prototype={constructor:N,reset:function(e){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(k),!e)for(var r in this)"t"===r.charAt(0)&&t.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(t,n){return i.type="throw",i.arg=e,r.next=t,n&&(r.method="next",r.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 u=t.call(a,"catchLoc"),c=t.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(e,r){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&t.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=r&&r<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=r,a?(this.method="next",this.next=a.finallyLoc,f):this.complete(i)},complete:function(e,r){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&r&&(this.next=r),f},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e)return this.complete(t.completion,t.afterLoc),k(t),f}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var n=t.completion;if("throw"===n.type){var o=n.arg;k(t)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,t){return this.delegate={iterator:T(e),resultName:r,nextLoc:t},"next"===this.method&&(this.arg=void 0),f}},e}(e.exports);try{regeneratorRuntime=r}catch(e){Function("r","regeneratorRuntime = r")(r)}}));function i(e){var r=e.split(".");return r.length>2?{subdomain:r[0],name:r[1],namespace:r[2]}:{name:r[0],namespace:r[1]}}var u=function(r){return e.bufferCV(Buffer.from(r))},c=function(r){return e.uintCV(r.toString(10))},s=function(r){return e.hash160(Buffer.from(r))};function f(e){if(e.chainId===r.ChainID.Mainnet)return"SP000000000000000000002Q6VF78";if(e.chainId==r.ChainID.Testnet)return"ST000000000000000000002AMW42H";throw new Error("Unexpected ChainID: "+e.chainId)}function p(e){return l.apply(this,arguments)}function l(){return(l=n(a.mark((function r(t){var n;return a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n={contractAddress:f(t.network),contractName:"bns",functionName:t.functionName,functionArgs:t.functionArgs,publicKey:t.publicKey,validateWithAbi:!1,network:t.network},r.abrupt("return",e.makeUnsignedContractCall(n));case 2:case"end":return r.stop()}}),r)})))).apply(this,arguments)}function h(e){return m.apply(this,arguments)}function m(){return(m=n(a.mark((function r(t){return a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",e.callReadOnlyFunction({contractAddress:f(t.network),contractName:"bns",functionName:t.functionName,senderAddress:t.senderAddress,functionArgs:t.functionArgs,network:t.network}));case 1:case"end":return r.stop()}}),r)})))).apply(this,arguments)}function d(){return(d=n(a.mark((function r(t){var n,o,c,s,f,p,l;return a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(n=t.network,o="can-name-be-registered",c=i(t.fullyQualifiedName),s=c.namespace,f=c.name,!c.subdomain){r.next=5;break}throw new Error("Cannot register a subdomain using registerName");case 5:return p=e.privateKeyToString(e.makeRandomPrivKey()),l=e.getAddressFromPrivateKey(p),r.abrupt("return",h({functionName:o,senderAddress:l,functionArgs:[u(s),u(f)],network:n}).then((function(r){return r.type===e.ClarityType.ResponseOk&&r.value.type===e.ClarityType.BoolTrue})));case 8:case"end":return r.stop()}}),r)})))).apply(this,arguments)}function y(){return(y=n(a.mark((function r(t){var n,o,i,c;return a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n=t.namespace,o=t.network,i=e.privateKeyToString(e.makeRandomPrivKey()),c=e.getAddressFromPrivateKey(i),r.abrupt("return",h({functionName:"get-namespace-price",senderAddress:c,functionArgs:[u(n)],network:o}).then((function(r){if(r.type===e.ClarityType.ResponseOk){if(r.value.type===e.ClarityType.Int||r.value.type===e.ClarityType.UInt)return r.value.value;throw new Error("Response did not contain a number")}throw r.type===e.ClarityType.ResponseErr?new Error(e.cvToString(r.value)):new Error("Unexpected Clarity Value type: "+e.getCVTypeString(r))})));case 5:case"end":return r.stop()}}),r)})))).apply(this,arguments)}function v(){return(v=n(a.mark((function r(t){var n,o,c,s,f,p,l;return a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(n=t.network,o="get-name-price",c=i(t.fullyQualifiedName),s=c.namespace,f=c.name,!c.subdomain){r.next=5;break}throw new Error("Cannot get subdomain name price");case 5:return p=e.privateKeyToString(e.makeRandomPrivKey()),l=e.getAddressFromPrivateKey(p),r.abrupt("return",h({functionName:o,senderAddress:l,functionArgs:[u(s),u(f)],network:n}).then((function(r){if(r.type===e.ClarityType.ResponseOk){if(r.value.type===e.ClarityType.Int||r.value.type===e.ClarityType.UInt)return r.value.value;throw new Error("Response did not contain a number")}throw new Error(e.cvToString(r.value))})));case 8:case"end":return r.stop()}}),r)})))).apply(this,arguments)}function w(){return(w=n(a.mark((function r(t){var n,o,i,u,s;return a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n=t.stxToBurn,o=t.publicKey,i=t.network,u=Buffer.from("0x"+t.namespace+t.salt),s=e.hash160(u),r.abrupt("return",p({functionName:"namespace-preorder",functionArgs:[e.bufferCV(s),c(n)],publicKey:o,network:i}));case 5:case"end":return r.stop()}}),r)})))).apply(this,arguments)}function b(){return(b=n(a.mark((function r(t){var n,o,i,s,f,l;return a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n=t.salt,o=t.priceFunction,i=t.lifetime,s=t.namespaceImportAddress,f=t.publicKey,l=t.network,r.abrupt("return",p({functionName:"namespace-reveal",functionArgs:[u(t.namespace),u(n),c(o.base),c(o.coefficient),c(o.b1),c(o.b2),c(o.b3),c(o.b4),c(o.b5),c(o.b6),c(o.b7),c(o.b8),c(o.b9),c(o.b10),c(o.b11),c(o.b12),c(o.b13),c(o.b14),c(o.b15),c(o.b16),c(o.nonAlphaDiscount),c(o.noVowelDiscount),c(i),e.standardPrincipalCV(s)],publicKey:f,network:l}));case 3:case"end":return r.stop()}}),r)})))).apply(this,arguments)}function g(){return(g=n(a.mark((function r(t){var n,o,i,c,f,l,h;return a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n=t.namespace,o=t.name,i=t.beneficiary,f=t.publicKey,l=t.network,h=s(c=t.zonefile),r.abrupt("return",p({functionName:"name-import",functionArgs:[u(n),u(o),e.standardPrincipalCV(i),e.bufferCV(h)],publicKey:f,network:l,attachment:Buffer.from(c)}));case 4:case"end":return r.stop()}}),r)})))).apply(this,arguments)}function x(){return(x=n(a.mark((function e(r){var t,n;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.publicKey,n=r.network,e.abrupt("return",p({functionName:"namespace-ready",functionArgs:[u(r.namespace)],publicKey:t,network:n}));case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function k(){return(k=n(a.mark((function r(t){var n,o,u,s,f,l,h,m;return a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(o=t.salt,u=t.stxToBurn,s=t.publicKey,f=t.network,l="name-preorder",!i(n=t.fullyQualifiedName).subdomain){r.next=5;break}throw new Error("Cannot preorder a subdomain using preorderName()");case 5:return h=Buffer.from("0x"+n+o),m=e.hash160(h),r.abrupt("return",p({functionName:l,functionArgs:[e.bufferCV(m),c(u)],publicKey:s,network:f}));case 8:case"end":return r.stop()}}),r)})))).apply(this,arguments)}function N(){return(N=n(a.mark((function r(t){var n,o,c,f,l,h,m,d,y;return a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(n=t.salt,o=t.zonefile,c=t.publicKey,f=t.network,l="name-register",h=i(t.fullyQualifiedName),m=h.namespace,d=h.name,!h.subdomain){r.next=5;break}throw new Error("Cannot register a subdomain using registerName()");case 5:return y=s(o),r.abrupt("return",p({functionName:l,functionArgs:[u(m),u(d),u(n),e.bufferCV(y)],network:f,publicKey:c,attachment:Buffer.from(o)}));case 7:case"end":return r.stop()}}),r)})))).apply(this,arguments)}function T(){return(T=n(a.mark((function r(t){var n,o,c,f,l,h,m,d;return a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(n=t.zonefile,o=t.publicKey,c=t.network,f="name-update",l=i(t.fullyQualifiedName),h=l.namespace,m=l.name,!l.subdomain){r.next=5;break}throw new Error("Cannot update a subdomain using updateName()");case 5:return d=s(n),r.abrupt("return",p({functionName:f,functionArgs:[u(h),u(m),e.bufferCV(d)],publicKey:o,network:c,attachment:Buffer.from(n)}));case 7:case"end":return r.stop()}}),r)})))).apply(this,arguments)}function E(){return(E=n(a.mark((function r(t){var n,o,c,f,l,h,m,d,y;return a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(n=t.newOwnerAddress,o=t.zonefile,c=t.publicKey,f=t.network,l="name-transfer",h=i(t.fullyQualifiedName),m=h.namespace,d=h.name,!h.subdomain){r.next=5;break}throw new Error("Cannot transfer a subdomain using transferName()");case 5:return y=[u(m),u(d),u(n)],o&&y.push(e.bufferCV(s(o))),r.abrupt("return",p({functionName:l,functionArgs:y,publicKey:c,network:f,attachment:o?Buffer.from(o):void 0}));case 8:case"end":return r.stop()}}),r)})))).apply(this,arguments)}function A(){return(A=n(a.mark((function e(r){var t,n,o,c,s,f;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=r.publicKey,n=r.network,o="name-revoke",c=i(r.fullyQualifiedName),s=c.namespace,f=c.name,!c.subdomain){e.next=5;break}throw new Error("Cannot revoke a subdomain using revokeName()");case 5:return e.abrupt("return",p({functionName:o,functionArgs:[u(s),u(f)],publicKey:t,network:n}));case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function C(){return(C=n(a.mark((function r(t){var n,o,f,l,h,m,d,y,v,w,b;return a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(n=t.stxToBurn,o=t.newOwnerAddress,f=t.zonefile,l=t.publicKey,h=t.network,m="name-renewal",d=i(t.fullyQualifiedName),y=d.namespace,v=d.name,!d.subdomain){r.next=5;break}throw new Error("Cannot renew a subdomain using renewName()");case 5:return w=[u(y),u(v),c(n)],o&&w.push(u(o)),f&&(b=s(f),w.push(e.bufferCV(b))),r.abrupt("return",p({functionName:m,functionArgs:w,publicKey:l,network:h,attachment:f?Buffer.from(f):void 0}));case 9:case"end":return r.stop()}}),r)})))).apply(this,arguments)}exports.BNS_CONTRACT_NAME="bns",exports.buildImportNameTx=function(e){return g.apply(this,arguments)},exports.buildPreorderNameTx=function(e){return k.apply(this,arguments)},exports.buildPreorderNamespaceTx=function(e){return w.apply(this,arguments)},exports.buildReadyNamespaceTx=function(e){return x.apply(this,arguments)},exports.buildRegisterNameTx=function(e){return N.apply(this,arguments)},exports.buildRenewNameTx=function(e){return C.apply(this,arguments)},exports.buildRevealNamespaceTx=function(e){return b.apply(this,arguments)},exports.buildRevokeNameTx=function(e){return A.apply(this,arguments)},exports.buildTransferNameTx=function(e){return E.apply(this,arguments)},exports.buildUpdateNameTx=function(e){return T.apply(this,arguments)},exports.canRegisterName=function(e){return d.apply(this,arguments)},exports.getNamePrice=function(e){return v.apply(this,arguments)},exports.getNamespacePrice=function(e){return y.apply(this,arguments)}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@stacks/transactions"),r=require("@stacks/common");function t(e,r,t,n,o,a,i){try{var u=e[a](i),c=u.value}catch(e){return void t(e)}u.done?r(c):Promise.resolve(c).then(n,o)}function n(e){return function(){var r=this,n=arguments;return new Promise((function(o,a){var i=e.apply(r,n);function u(e){t(i,o,a,u,c,"next",e)}function c(e){t(i,o,a,u,c,"throw",e)}u(void 0)}))}}function o(e,r){return e(r={exports:{}},r.exports),r.exports}var a=o((function(e){var r=function(e){var r=Object.prototype,t=r.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function u(e,r,t){return Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}),e[r]}try{u({},"")}catch(e){u=function(e,r,t){return e[r]=t}}function c(e,r,t,n){var o=Object.create((r&&r.prototype instanceof p?r:p).prototype),a=new N(n||[]);return o._invoke=function(e,r,t){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(t.method=o,t.arg=a;;){var i=t.delegate;if(i){var u=g(i,t);if(u){if(u===f)continue;return u}}if("next"===t.method)t.sent=t._sent=t.arg;else if("throw"===t.method){if("suspendedStart"===n)throw n="completed",t.arg;t.dispatchException(t.arg)}else"return"===t.method&&t.abrupt("return",t.arg);n="executing";var c=s(e,r,t);if("normal"===c.type){if(n=t.done?"completed":"suspendedYield",c.arg===f)continue;return{value:c.arg,done:t.done}}"throw"===c.type&&(n="completed",t.method="throw",t.arg=c.arg)}}}(e,t,a),o}function s(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var f={};function p(){}function l(){}function h(){}var m={};m[o]=function(){return this};var d=Object.getPrototypeOf,y=d&&d(d(T([])));y&&y!==r&&t.call(y,o)&&(m=y);var v=h.prototype=p.prototype=Object.create(m);function w(e){["next","throw","return"].forEach((function(r){u(e,r,(function(e){return this._invoke(r,e)}))}))}function b(e,r){var n;this._invoke=function(o,a){function i(){return new r((function(n,i){!function n(o,a,i,u){var c=s(e[o],e,a);if("throw"!==c.type){var f=c.arg,p=f.value;return p&&"object"==typeof p&&t.call(p,"__await")?r.resolve(p.__await).then((function(e){n("next",e,i,u)}),(function(e){n("throw",e,i,u)})):r.resolve(p).then((function(e){f.value=e,i(f)}),(function(e){return n("throw",e,i,u)}))}u(c.arg)}(o,a,n,i)}))}return n=n?n.then(i,i):i()}}function g(e,r){var t=e.iterator[r.method];if(void 0===t){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=void 0,g(e,r),"throw"===r.method))return f;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=s(t,e.iterator,r.arg);if("throw"===n.type)return r.method="throw",r.arg=n.arg,r.delegate=null,f;var o=n.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,f):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,f)}function x(e){var r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),this.tryEntries.push(r)}function k(e){var r=e.completion||{};r.type="normal",delete r.arg,e.completion=r}function N(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function T(e){if(e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,a=function r(){for(;++n<e.length;)if(t.call(e,n))return r.value=e[n],r.done=!1,r;return r.value=void 0,r.done=!0,r};return a.next=a}}return{next:E}}function E(){return{value:void 0,done:!0}}return l.prototype=v.constructor=h,h.constructor=l,l.displayName=u(h,i,"GeneratorFunction"),e.isGeneratorFunction=function(e){var r="function"==typeof e&&e.constructor;return!!r&&(r===l||"GeneratorFunction"===(r.displayName||r.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,h):(e.__proto__=h,u(e,i,"GeneratorFunction")),e.prototype=Object.create(v),e},e.awrap=function(e){return{__await:e}},w(b.prototype),b.prototype[a]=function(){return this},e.AsyncIterator=b,e.async=function(r,t,n,o,a){void 0===a&&(a=Promise);var i=new b(c(r,t,n,o),a);return e.isGeneratorFunction(t)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},w(v),u(v,i,"Generator"),v[o]=function(){return this},v.toString=function(){return"[object Generator]"},e.keys=function(e){var r=[];for(var t in e)r.push(t);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=T,N.prototype={constructor:N,reset:function(e){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(k),!e)for(var r in this)"t"===r.charAt(0)&&t.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(t,n){return i.type="throw",i.arg=e,r.next=t,n&&(r.method="next",r.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 u=t.call(a,"catchLoc"),c=t.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(e,r){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&t.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=r&&r<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=r,a?(this.method="next",this.next=a.finallyLoc,f):this.complete(i)},complete:function(e,r){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&r&&(this.next=r),f},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e)return this.complete(t.completion,t.afterLoc),k(t),f}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var n=t.completion;if("throw"===n.type){var o=n.arg;k(t)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,t){return this.delegate={iterator:T(e),resultName:r,nextLoc:t},"next"===this.method&&(this.arg=void 0),f}},e}(e.exports);try{regeneratorRuntime=r}catch(e){Function("r","regeneratorRuntime = r")(r)}}));function i(e){var r=e.split(".");return r.length>2?{subdomain:r[0],name:r[1],namespace:r[2]}:{name:r[0],namespace:r[1]}}var u=function(r){return e.bufferCV(Buffer.from(r))},c=function(r){return e.uintCV(r.toString(10))},s=function(r){return e.hash160(Buffer.from(r))};function f(e){if(e.chainId===r.ChainID.Mainnet)return"SP000000000000000000002Q6VF78";if(e.chainId==r.ChainID.Testnet)return"ST000000000000000000002AMW42H";throw new Error("Unexpected ChainID: "+e.chainId)}function p(e){return l.apply(this,arguments)}function l(){return(l=n(a.mark((function r(t){var n;return a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n={contractAddress:f(t.network),contractName:"bns",functionName:t.functionName,functionArgs:t.functionArgs,publicKey:t.publicKey,validateWithAbi:!1,network:t.network},r.abrupt("return",e.makeUnsignedContractCall(n));case 2:case"end":return r.stop()}}),r)})))).apply(this,arguments)}function h(e){return m.apply(this,arguments)}function m(){return(m=n(a.mark((function r(t){return a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",e.callReadOnlyFunction({contractAddress:f(t.network),contractName:"bns",functionName:t.functionName,senderAddress:t.senderAddress,functionArgs:t.functionArgs,network:t.network}));case 1:case"end":return r.stop()}}),r)})))).apply(this,arguments)}function d(){return(d=n(a.mark((function r(t){var n,o,c,s,f,p,l;return a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(n=t.network,o="can-name-be-registered",c=i(t.fullyQualifiedName),s=c.namespace,f=c.name,!c.subdomain){r.next=5;break}throw new Error("Cannot register a subdomain using registerName");case 5:return p=e.privateKeyToString(e.makeRandomPrivKey()),l=e.getAddressFromPrivateKey(p),r.abrupt("return",h({functionName:o,senderAddress:l,functionArgs:[u(s),u(f)],network:n}).then((function(r){return r.type===e.ClarityType.ResponseOk&&r.value.type===e.ClarityType.BoolTrue})));case 8:case"end":return r.stop()}}),r)})))).apply(this,arguments)}function y(){return(y=n(a.mark((function r(t){var n,o,i,c;return a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n=t.namespace,o=t.network,i=e.privateKeyToString(e.makeRandomPrivKey()),c=e.getAddressFromPrivateKey(i),r.abrupt("return",h({functionName:"get-namespace-price",senderAddress:c,functionArgs:[u(n)],network:o}).then((function(r){if(r.type===e.ClarityType.ResponseOk){if(r.value.type===e.ClarityType.Int||r.value.type===e.ClarityType.UInt)return r.value.value;throw new Error("Response did not contain a number")}throw r.type===e.ClarityType.ResponseErr?new Error(e.cvToString(r.value)):new Error("Unexpected Clarity Value type: "+e.getCVTypeString(r))})));case 5:case"end":return r.stop()}}),r)})))).apply(this,arguments)}function v(){return(v=n(a.mark((function r(t){var n,o,c,s,f,p,l;return a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(n=t.network,o="get-name-price",c=i(t.fullyQualifiedName),s=c.namespace,f=c.name,!c.subdomain){r.next=5;break}throw new Error("Cannot get subdomain name price");case 5:return p=e.privateKeyToString(e.makeRandomPrivKey()),l=e.getAddressFromPrivateKey(p),r.abrupt("return",h({functionName:o,senderAddress:l,functionArgs:[u(s),u(f)],network:n}).then((function(r){if(r.type===e.ClarityType.ResponseOk){if(r.value.type===e.ClarityType.Int||r.value.type===e.ClarityType.UInt)return r.value.value;throw new Error("Response did not contain a number")}throw new Error(e.cvToString(r.value))})));case 8:case"end":return r.stop()}}),r)})))).apply(this,arguments)}function w(){return(w=n(a.mark((function r(t){var n,o,i,u,s;return a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n=t.stxToBurn,o=t.publicKey,i=t.network,u=Buffer.from(""+t.namespace+t.salt),s=e.hash160(u),r.abrupt("return",p({functionName:"namespace-preorder",functionArgs:[e.bufferCV(s),c(n)],publicKey:o,network:i}));case 5:case"end":return r.stop()}}),r)})))).apply(this,arguments)}function b(){return(b=n(a.mark((function r(t){var n,o,i,s,f,l;return a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n=t.salt,o=t.priceFunction,i=t.lifetime,s=t.namespaceImportAddress,f=t.publicKey,l=t.network,r.abrupt("return",p({functionName:"namespace-reveal",functionArgs:[u(t.namespace),u(n),c(o.base),c(o.coefficient),c(o.b1),c(o.b2),c(o.b3),c(o.b4),c(o.b5),c(o.b6),c(o.b7),c(o.b8),c(o.b9),c(o.b10),c(o.b11),c(o.b12),c(o.b13),c(o.b14),c(o.b15),c(o.b16),c(o.nonAlphaDiscount),c(o.noVowelDiscount),c(i),e.standardPrincipalCV(s)],publicKey:f,network:l}));case 3:case"end":return r.stop()}}),r)})))).apply(this,arguments)}function g(){return(g=n(a.mark((function r(t){var n,o,i,c,f,l,h;return a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n=t.namespace,o=t.name,i=t.beneficiary,f=t.publicKey,l=t.network,h=s(c=t.zonefile),r.abrupt("return",p({functionName:"name-import",functionArgs:[u(n),u(o),e.standardPrincipalCV(i),e.bufferCV(h)],publicKey:f,network:l,attachment:Buffer.from(c)}));case 4:case"end":return r.stop()}}),r)})))).apply(this,arguments)}function x(){return(x=n(a.mark((function e(r){var t,n;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.publicKey,n=r.network,e.abrupt("return",p({functionName:"namespace-ready",functionArgs:[u(r.namespace)],publicKey:t,network:n}));case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function k(){return(k=n(a.mark((function r(t){var n,o,u,s,f,l,h,m;return a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(o=t.salt,u=t.stxToBurn,s=t.publicKey,f=t.network,l="name-preorder",!i(n=t.fullyQualifiedName).subdomain){r.next=5;break}throw new Error("Cannot preorder a subdomain using preorderName()");case 5:return h=Buffer.from(""+n+o),m=e.hash160(h),r.abrupt("return",p({functionName:l,functionArgs:[e.bufferCV(m),c(u)],publicKey:s,network:f}));case 8:case"end":return r.stop()}}),r)})))).apply(this,arguments)}function N(){return(N=n(a.mark((function r(t){var n,o,c,f,l,h,m,d,y;return a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(n=t.salt,o=t.zonefile,c=t.publicKey,f=t.network,l="name-register",h=i(t.fullyQualifiedName),m=h.namespace,d=h.name,!h.subdomain){r.next=5;break}throw new Error("Cannot register a subdomain using registerName()");case 5:return y=s(o),r.abrupt("return",p({functionName:l,functionArgs:[u(m),u(d),u(n),e.bufferCV(y)],network:f,publicKey:c,attachment:Buffer.from(o)}));case 7:case"end":return r.stop()}}),r)})))).apply(this,arguments)}function T(){return(T=n(a.mark((function r(t){var n,o,c,f,l,h,m,d;return a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(n=t.zonefile,o=t.publicKey,c=t.network,f="name-update",l=i(t.fullyQualifiedName),h=l.namespace,m=l.name,!l.subdomain){r.next=5;break}throw new Error("Cannot update a subdomain using updateName()");case 5:return d=s(n),r.abrupt("return",p({functionName:f,functionArgs:[u(h),u(m),e.bufferCV(d)],publicKey:o,network:c,attachment:Buffer.from(n)}));case 7:case"end":return r.stop()}}),r)})))).apply(this,arguments)}function E(){return(E=n(a.mark((function r(t){var n,o,c,f,l,h,m,d,y;return a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(n=t.newOwnerAddress,o=t.zonefile,c=t.publicKey,f=t.network,l="name-transfer",h=i(t.fullyQualifiedName),m=h.namespace,d=h.name,!h.subdomain){r.next=5;break}throw new Error("Cannot transfer a subdomain using transferName()");case 5:return y=[u(m),u(d),u(n)],o&&y.push(e.bufferCV(s(o))),r.abrupt("return",p({functionName:l,functionArgs:y,publicKey:c,network:f,attachment:o?Buffer.from(o):void 0}));case 8:case"end":return r.stop()}}),r)})))).apply(this,arguments)}function A(){return(A=n(a.mark((function e(r){var t,n,o,c,s,f;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=r.publicKey,n=r.network,o="name-revoke",c=i(r.fullyQualifiedName),s=c.namespace,f=c.name,!c.subdomain){e.next=5;break}throw new Error("Cannot revoke a subdomain using revokeName()");case 5:return e.abrupt("return",p({functionName:o,functionArgs:[u(s),u(f)],publicKey:t,network:n}));case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function C(){return(C=n(a.mark((function r(t){var n,o,f,l,h,m,d,y,v,w,b;return a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(n=t.stxToBurn,o=t.newOwnerAddress,f=t.zonefile,l=t.publicKey,h=t.network,m="name-renewal",d=i(t.fullyQualifiedName),y=d.namespace,v=d.name,!d.subdomain){r.next=5;break}throw new Error("Cannot renew a subdomain using renewName()");case 5:return w=[u(y),u(v),c(n)],o&&w.push(u(o)),f&&(b=s(f),w.push(e.bufferCV(b))),r.abrupt("return",p({functionName:m,functionArgs:w,publicKey:l,network:h,attachment:f?Buffer.from(f):void 0}));case 9:case"end":return r.stop()}}),r)})))).apply(this,arguments)}exports.BNS_CONTRACT_NAME="bns",exports.buildImportNameTx=function(e){return g.apply(this,arguments)},exports.buildPreorderNameTx=function(e){return k.apply(this,arguments)},exports.buildPreorderNamespaceTx=function(e){return w.apply(this,arguments)},exports.buildReadyNamespaceTx=function(e){return x.apply(this,arguments)},exports.buildRegisterNameTx=function(e){return N.apply(this,arguments)},exports.buildRenewNameTx=function(e){return C.apply(this,arguments)},exports.buildRevealNamespaceTx=function(e){return b.apply(this,arguments)},exports.buildRevokeNameTx=function(e){return A.apply(this,arguments)},exports.buildTransferNameTx=function(e){return E.apply(this,arguments)},exports.buildUpdateNameTx=function(e){return T.apply(this,arguments)},exports.canRegisterName=function(e){return d.apply(this,arguments)},exports.getNamePrice=function(e){return v.apply(this,arguments)},exports.getNamespacePrice=function(e){return y.apply(this,arguments)}; | ||
//# sourceMappingURL=bns.cjs.production.min.js.map |
@@ -1029,3 +1029,3 @@ (function (global, factory) { | ||
bnsFunctionName = 'namespace-preorder'; | ||
saltedNamespaceBuffer = Buffer.from("0x" + namespace + salt); | ||
saltedNamespaceBuffer = Buffer.from("" + namespace + salt); | ||
hashedSaltedNamespace = transactions.hash160(saltedNamespaceBuffer); | ||
@@ -1165,3 +1165,3 @@ return _context6.abrupt("return", makeBnsContractCall({ | ||
case 5: | ||
saltedNamesBuffer = Buffer.from("0x" + fullyQualifiedName + salt); | ||
saltedNamesBuffer = Buffer.from("" + fullyQualifiedName + salt); | ||
hashedSaltedName = transactions.hash160(saltedNamesBuffer); | ||
@@ -1168,0 +1168,0 @@ return _context10.abrupt("return", makeBnsContractCall({ |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@stacks/transactions"),require("@stacks/common")):"function"==typeof define&&define.amd?define(["exports","@stacks/transactions","@stacks/common"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@stacks/bns"]={},e.transactions,e.common)}(this,(function(e,t,r){"use strict";function n(e,t,r,n,a,o,i){try{var u=e[o](i),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,a)}function a(e){return function(){var t=this,r=arguments;return new Promise((function(a,o){var i=e.apply(t,r);function u(e){n(i,a,o,u,c,"next",e)}function c(e){n(i,a,o,u,c,"throw",e)}u(void 0)}))}}function o(e,t){return e(t={exports:{}},t.exports),t.exports}var i=o((function(e){var t=function(e){var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},a=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var a=Object.create((t&&t.prototype instanceof p?t:p).prototype),o=new N(n||[]);return a._invoke=function(e,t,r){var n="suspendedStart";return function(a,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===a)throw o;return{value:void 0,done:!0}}for(r.method=a,r.arg=o;;){var i=r.delegate;if(i){var u=g(i,r);if(u){if(u===f)continue;return u}}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 c=s(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===f)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(e,r,o),a}function s(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var f={};function p(){}function l(){}function h(){}var m={};m[a]=function(){return this};var d=Object.getPrototypeOf,y=d&&d(d(T([])));y&&y!==t&&r.call(y,a)&&(m=y);var v=h.prototype=p.prototype=Object.create(m);function w(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){var n;this._invoke=function(a,o){function i(){return new t((function(n,i){!function n(a,o,i,u){var c=s(e[a],e,o);if("throw"!==c.type){var f=c.arg,p=f.value;return p&&"object"==typeof p&&r.call(p,"__await")?t.resolve(p.__await).then((function(e){n("next",e,i,u)}),(function(e){n("throw",e,i,u)})):t.resolve(p).then((function(e){f.value=e,i(f)}),(function(e){return n("throw",e,i,u)}))}u(c.arg)}(a,o,n,i)}))}return n=n?n.then(i,i):i()}}function g(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,g(e,t),"throw"===t.method))return f;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=s(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,f;var a=n.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function k(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function N(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function T(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:E}}function E(){return{value:void 0,done:!0}}return l.prototype=v.constructor=h,h.constructor=l,l.displayName=u(h,i,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===l||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,h):(e.__proto__=h,u(e,i,"GeneratorFunction")),e.prototype=Object.create(v),e},e.awrap=function(e){return{__await:e}},w(b.prototype),b.prototype[o]=function(){return this},e.AsyncIterator=b,e.async=function(t,r,n,a,o){void 0===o&&(o=Promise);var i=new b(c(t,r,n,a),o);return e.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},w(v),u(v,i,"Generator"),v[a]=function(){return this},v.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=T,N.prototype={constructor:N,reset:function(e){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),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return i.type="throw",i.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var u=r.call(o,"catchLoc"),c=r.call(o,"finallyLoc");if(u&&c){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),x(r),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;x(r)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:T(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}}));function u(e){var t=e.split(".");return t.length>2?{subdomain:t[0],name:t[1],namespace:t[2]}:{name:t[0],namespace:t[1]}}var c=function(e){return t.bufferCV(Buffer.from(e))},s=function(e){return t.uintCV(e.toString(10))},f=function(e){return t.hash160(Buffer.from(e))};function p(e){if(e.chainId===r.ChainID.Mainnet)return"SP000000000000000000002Q6VF78";if(e.chainId==r.ChainID.Testnet)return"ST000000000000000000002AMW42H";throw new Error("Unexpected ChainID: "+e.chainId)}function l(e){return h.apply(this,arguments)}function h(){return(h=a(i.mark((function e(r){var n;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={contractAddress:p(r.network),contractName:"bns",functionName:r.functionName,functionArgs:r.functionArgs,publicKey:r.publicKey,validateWithAbi:!1,network:r.network},e.abrupt("return",t.makeUnsignedContractCall(n));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function m(e){return d.apply(this,arguments)}function d(){return(d=a(i.mark((function e(r){return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t.callReadOnlyFunction({contractAddress:p(r.network),contractName:"bns",functionName:r.functionName,senderAddress:r.senderAddress,functionArgs:r.functionArgs,network:r.network}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function y(){return(y=a(i.mark((function e(r){var n,a,o,s,f,p,l;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=r.network,a="can-name-be-registered",o=u(r.fullyQualifiedName),s=o.namespace,f=o.name,!o.subdomain){e.next=5;break}throw new Error("Cannot register a subdomain using registerName");case 5:return p=t.privateKeyToString(t.makeRandomPrivKey()),l=t.getAddressFromPrivateKey(p),e.abrupt("return",m({functionName:a,senderAddress:l,functionArgs:[c(s),c(f)],network:n}).then((function(e){return e.type===t.ClarityType.ResponseOk&&e.value.type===t.ClarityType.BoolTrue})));case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function v(){return(v=a(i.mark((function e(r){var n,a,o,u;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.namespace,a=r.network,o=t.privateKeyToString(t.makeRandomPrivKey()),u=t.getAddressFromPrivateKey(o),e.abrupt("return",m({functionName:"get-namespace-price",senderAddress:u,functionArgs:[c(n)],network:a}).then((function(e){if(e.type===t.ClarityType.ResponseOk){if(e.value.type===t.ClarityType.Int||e.value.type===t.ClarityType.UInt)return e.value.value;throw new Error("Response did not contain a number")}throw e.type===t.ClarityType.ResponseErr?new Error(t.cvToString(e.value)):new Error("Unexpected Clarity Value type: "+t.getCVTypeString(e))})));case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function w(){return(w=a(i.mark((function e(r){var n,a,o,s,f,p,l;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=r.network,a="get-name-price",o=u(r.fullyQualifiedName),s=o.namespace,f=o.name,!o.subdomain){e.next=5;break}throw new Error("Cannot get subdomain name price");case 5:return p=t.privateKeyToString(t.makeRandomPrivKey()),l=t.getAddressFromPrivateKey(p),e.abrupt("return",m({functionName:a,senderAddress:l,functionArgs:[c(s),c(f)],network:n}).then((function(e){if(e.type===t.ClarityType.ResponseOk){if(e.value.type===t.ClarityType.Int||e.value.type===t.ClarityType.UInt)return e.value.value;throw new Error("Response did not contain a number")}throw new Error(t.cvToString(e.value))})));case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function b(){return(b=a(i.mark((function e(r){var n,a,o,u,c;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.stxToBurn,a=r.publicKey,o=r.network,u=Buffer.from("0x"+r.namespace+r.salt),c=t.hash160(u),e.abrupt("return",l({functionName:"namespace-preorder",functionArgs:[t.bufferCV(c),s(n)],publicKey:a,network:o}));case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function g(){return(g=a(i.mark((function e(r){var n,a,o,u,f,p;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.salt,a=r.priceFunction,o=r.lifetime,u=r.namespaceImportAddress,f=r.publicKey,p=r.network,e.abrupt("return",l({functionName:"namespace-reveal",functionArgs:[c(r.namespace),c(n),s(a.base),s(a.coefficient),s(a.b1),s(a.b2),s(a.b3),s(a.b4),s(a.b5),s(a.b6),s(a.b7),s(a.b8),s(a.b9),s(a.b10),s(a.b11),s(a.b12),s(a.b13),s(a.b14),s(a.b15),s(a.b16),s(a.nonAlphaDiscount),s(a.noVowelDiscount),s(o),t.standardPrincipalCV(u)],publicKey:f,network:p}));case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function k(){return(k=a(i.mark((function e(r){var n,a,o,u,s,p,h;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.namespace,a=r.name,o=r.beneficiary,s=r.publicKey,p=r.network,h=f(u=r.zonefile),e.abrupt("return",l({functionName:"name-import",functionArgs:[c(n),c(a),t.standardPrincipalCV(o),t.bufferCV(h)],publicKey:s,network:p,attachment:Buffer.from(u)}));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function x(){return(x=a(i.mark((function e(t){var r,n;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.publicKey,n=t.network,e.abrupt("return",l({functionName:"namespace-ready",functionArgs:[c(t.namespace)],publicKey:r,network:n}));case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function N(){return(N=a(i.mark((function e(r){var n,a,o,c,f,p,h,m;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=r.salt,o=r.stxToBurn,c=r.publicKey,f=r.network,p="name-preorder",!u(n=r.fullyQualifiedName).subdomain){e.next=5;break}throw new Error("Cannot preorder a subdomain using preorderName()");case 5:return h=Buffer.from("0x"+n+a),m=t.hash160(h),e.abrupt("return",l({functionName:p,functionArgs:[t.bufferCV(m),s(o)],publicKey:c,network:f}));case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function T(){return(T=a(i.mark((function e(r){var n,a,o,s,p,h,m,d,y;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=r.salt,a=r.zonefile,o=r.publicKey,s=r.network,p="name-register",h=u(r.fullyQualifiedName),m=h.namespace,d=h.name,!h.subdomain){e.next=5;break}throw new Error("Cannot register a subdomain using registerName()");case 5:return y=f(a),e.abrupt("return",l({functionName:p,functionArgs:[c(m),c(d),c(n),t.bufferCV(y)],network:s,publicKey:o,attachment:Buffer.from(a)}));case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function E(){return(E=a(i.mark((function e(r){var n,a,o,s,p,h,m,d;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=r.zonefile,a=r.publicKey,o=r.network,s="name-update",p=u(r.fullyQualifiedName),h=p.namespace,m=p.name,!p.subdomain){e.next=5;break}throw new Error("Cannot update a subdomain using updateName()");case 5:return d=f(n),e.abrupt("return",l({functionName:s,functionArgs:[c(h),c(m),t.bufferCV(d)],publicKey:a,network:o,attachment:Buffer.from(n)}));case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function A(){return(A=a(i.mark((function e(r){var n,a,o,s,p,h,m,d,y;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=r.newOwnerAddress,a=r.zonefile,o=r.publicKey,s=r.network,p="name-transfer",h=u(r.fullyQualifiedName),m=h.namespace,d=h.name,!h.subdomain){e.next=5;break}throw new Error("Cannot transfer a subdomain using transferName()");case 5:return y=[c(m),c(d),c(n)],a&&y.push(t.bufferCV(f(a))),e.abrupt("return",l({functionName:p,functionArgs:y,publicKey:o,network:s,attachment:a?Buffer.from(a):void 0}));case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function C(){return(C=a(i.mark((function e(t){var r,n,a,o,s,f;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.publicKey,n=t.network,a="name-revoke",o=u(t.fullyQualifiedName),s=o.namespace,f=o.name,!o.subdomain){e.next=5;break}throw new Error("Cannot revoke a subdomain using revokeName()");case 5:return e.abrupt("return",l({functionName:a,functionArgs:[c(s),c(f)],publicKey:r,network:n}));case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function K(){return(K=a(i.mark((function e(r){var n,a,o,p,h,m,d,y,v,w,b;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=r.stxToBurn,a=r.newOwnerAddress,o=r.zonefile,p=r.publicKey,h=r.network,m="name-renewal",d=u(r.fullyQualifiedName),y=d.namespace,v=d.name,!d.subdomain){e.next=5;break}throw new Error("Cannot renew a subdomain using renewName()");case 5:return w=[c(y),c(v),s(n)],a&&w.push(c(a)),o&&(b=f(o),w.push(t.bufferCV(b))),e.abrupt("return",l({functionName:m,functionArgs:w,publicKey:p,network:h,attachment:o?Buffer.from(o):void 0}));case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}e.BNS_CONTRACT_NAME="bns",e.buildImportNameTx=function(e){return k.apply(this,arguments)},e.buildPreorderNameTx=function(e){return N.apply(this,arguments)},e.buildPreorderNamespaceTx=function(e){return b.apply(this,arguments)},e.buildReadyNamespaceTx=function(e){return x.apply(this,arguments)},e.buildRegisterNameTx=function(e){return T.apply(this,arguments)},e.buildRenewNameTx=function(e){return K.apply(this,arguments)},e.buildRevealNamespaceTx=function(e){return g.apply(this,arguments)},e.buildRevokeNameTx=function(e){return C.apply(this,arguments)},e.buildTransferNameTx=function(e){return A.apply(this,arguments)},e.buildUpdateNameTx=function(e){return E.apply(this,arguments)},e.canRegisterName=function(e){return y.apply(this,arguments)},e.getNamePrice=function(e){return w.apply(this,arguments)},e.getNamespacePrice=function(e){return v.apply(this,arguments)},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@stacks/transactions"),require("@stacks/common")):"function"==typeof define&&define.amd?define(["exports","@stacks/transactions","@stacks/common"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@stacks/bns"]={},e.transactions,e.common)}(this,(function(e,t,r){"use strict";function n(e,t,r,n,a,o,i){try{var u=e[o](i),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,a)}function a(e){return function(){var t=this,r=arguments;return new Promise((function(a,o){var i=e.apply(t,r);function u(e){n(i,a,o,u,c,"next",e)}function c(e){n(i,a,o,u,c,"throw",e)}u(void 0)}))}}function o(e,t){return e(t={exports:{}},t.exports),t.exports}var i=o((function(e){var t=function(e){var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},a=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var a=Object.create((t&&t.prototype instanceof p?t:p).prototype),o=new N(n||[]);return a._invoke=function(e,t,r){var n="suspendedStart";return function(a,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===a)throw o;return{value:void 0,done:!0}}for(r.method=a,r.arg=o;;){var i=r.delegate;if(i){var u=g(i,r);if(u){if(u===f)continue;return u}}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 c=s(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===f)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(e,r,o),a}function s(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var f={};function p(){}function l(){}function h(){}var m={};m[a]=function(){return this};var d=Object.getPrototypeOf,y=d&&d(d(T([])));y&&y!==t&&r.call(y,a)&&(m=y);var v=h.prototype=p.prototype=Object.create(m);function w(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){var n;this._invoke=function(a,o){function i(){return new t((function(n,i){!function n(a,o,i,u){var c=s(e[a],e,o);if("throw"!==c.type){var f=c.arg,p=f.value;return p&&"object"==typeof p&&r.call(p,"__await")?t.resolve(p.__await).then((function(e){n("next",e,i,u)}),(function(e){n("throw",e,i,u)})):t.resolve(p).then((function(e){f.value=e,i(f)}),(function(e){return n("throw",e,i,u)}))}u(c.arg)}(a,o,n,i)}))}return n=n?n.then(i,i):i()}}function g(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,g(e,t),"throw"===t.method))return f;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=s(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,f;var a=n.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function k(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function N(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function T(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:E}}function E(){return{value:void 0,done:!0}}return l.prototype=v.constructor=h,h.constructor=l,l.displayName=u(h,i,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===l||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,h):(e.__proto__=h,u(e,i,"GeneratorFunction")),e.prototype=Object.create(v),e},e.awrap=function(e){return{__await:e}},w(b.prototype),b.prototype[o]=function(){return this},e.AsyncIterator=b,e.async=function(t,r,n,a,o){void 0===o&&(o=Promise);var i=new b(c(t,r,n,a),o);return e.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},w(v),u(v,i,"Generator"),v[a]=function(){return this},v.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=T,N.prototype={constructor:N,reset:function(e){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),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return i.type="throw",i.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var u=r.call(o,"catchLoc"),c=r.call(o,"finallyLoc");if(u&&c){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),x(r),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;x(r)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:T(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}}));function u(e){var t=e.split(".");return t.length>2?{subdomain:t[0],name:t[1],namespace:t[2]}:{name:t[0],namespace:t[1]}}var c=function(e){return t.bufferCV(Buffer.from(e))},s=function(e){return t.uintCV(e.toString(10))},f=function(e){return t.hash160(Buffer.from(e))};function p(e){if(e.chainId===r.ChainID.Mainnet)return"SP000000000000000000002Q6VF78";if(e.chainId==r.ChainID.Testnet)return"ST000000000000000000002AMW42H";throw new Error("Unexpected ChainID: "+e.chainId)}function l(e){return h.apply(this,arguments)}function h(){return(h=a(i.mark((function e(r){var n;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={contractAddress:p(r.network),contractName:"bns",functionName:r.functionName,functionArgs:r.functionArgs,publicKey:r.publicKey,validateWithAbi:!1,network:r.network},e.abrupt("return",t.makeUnsignedContractCall(n));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function m(e){return d.apply(this,arguments)}function d(){return(d=a(i.mark((function e(r){return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t.callReadOnlyFunction({contractAddress:p(r.network),contractName:"bns",functionName:r.functionName,senderAddress:r.senderAddress,functionArgs:r.functionArgs,network:r.network}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function y(){return(y=a(i.mark((function e(r){var n,a,o,s,f,p,l;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=r.network,a="can-name-be-registered",o=u(r.fullyQualifiedName),s=o.namespace,f=o.name,!o.subdomain){e.next=5;break}throw new Error("Cannot register a subdomain using registerName");case 5:return p=t.privateKeyToString(t.makeRandomPrivKey()),l=t.getAddressFromPrivateKey(p),e.abrupt("return",m({functionName:a,senderAddress:l,functionArgs:[c(s),c(f)],network:n}).then((function(e){return e.type===t.ClarityType.ResponseOk&&e.value.type===t.ClarityType.BoolTrue})));case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function v(){return(v=a(i.mark((function e(r){var n,a,o,u;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.namespace,a=r.network,o=t.privateKeyToString(t.makeRandomPrivKey()),u=t.getAddressFromPrivateKey(o),e.abrupt("return",m({functionName:"get-namespace-price",senderAddress:u,functionArgs:[c(n)],network:a}).then((function(e){if(e.type===t.ClarityType.ResponseOk){if(e.value.type===t.ClarityType.Int||e.value.type===t.ClarityType.UInt)return e.value.value;throw new Error("Response did not contain a number")}throw e.type===t.ClarityType.ResponseErr?new Error(t.cvToString(e.value)):new Error("Unexpected Clarity Value type: "+t.getCVTypeString(e))})));case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function w(){return(w=a(i.mark((function e(r){var n,a,o,s,f,p,l;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=r.network,a="get-name-price",o=u(r.fullyQualifiedName),s=o.namespace,f=o.name,!o.subdomain){e.next=5;break}throw new Error("Cannot get subdomain name price");case 5:return p=t.privateKeyToString(t.makeRandomPrivKey()),l=t.getAddressFromPrivateKey(p),e.abrupt("return",m({functionName:a,senderAddress:l,functionArgs:[c(s),c(f)],network:n}).then((function(e){if(e.type===t.ClarityType.ResponseOk){if(e.value.type===t.ClarityType.Int||e.value.type===t.ClarityType.UInt)return e.value.value;throw new Error("Response did not contain a number")}throw new Error(t.cvToString(e.value))})));case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function b(){return(b=a(i.mark((function e(r){var n,a,o,u,c;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.stxToBurn,a=r.publicKey,o=r.network,u=Buffer.from(""+r.namespace+r.salt),c=t.hash160(u),e.abrupt("return",l({functionName:"namespace-preorder",functionArgs:[t.bufferCV(c),s(n)],publicKey:a,network:o}));case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function g(){return(g=a(i.mark((function e(r){var n,a,o,u,f,p;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.salt,a=r.priceFunction,o=r.lifetime,u=r.namespaceImportAddress,f=r.publicKey,p=r.network,e.abrupt("return",l({functionName:"namespace-reveal",functionArgs:[c(r.namespace),c(n),s(a.base),s(a.coefficient),s(a.b1),s(a.b2),s(a.b3),s(a.b4),s(a.b5),s(a.b6),s(a.b7),s(a.b8),s(a.b9),s(a.b10),s(a.b11),s(a.b12),s(a.b13),s(a.b14),s(a.b15),s(a.b16),s(a.nonAlphaDiscount),s(a.noVowelDiscount),s(o),t.standardPrincipalCV(u)],publicKey:f,network:p}));case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function k(){return(k=a(i.mark((function e(r){var n,a,o,u,s,p,h;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.namespace,a=r.name,o=r.beneficiary,s=r.publicKey,p=r.network,h=f(u=r.zonefile),e.abrupt("return",l({functionName:"name-import",functionArgs:[c(n),c(a),t.standardPrincipalCV(o),t.bufferCV(h)],publicKey:s,network:p,attachment:Buffer.from(u)}));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function x(){return(x=a(i.mark((function e(t){var r,n;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.publicKey,n=t.network,e.abrupt("return",l({functionName:"namespace-ready",functionArgs:[c(t.namespace)],publicKey:r,network:n}));case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function N(){return(N=a(i.mark((function e(r){var n,a,o,c,f,p,h,m;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=r.salt,o=r.stxToBurn,c=r.publicKey,f=r.network,p="name-preorder",!u(n=r.fullyQualifiedName).subdomain){e.next=5;break}throw new Error("Cannot preorder a subdomain using preorderName()");case 5:return h=Buffer.from(""+n+a),m=t.hash160(h),e.abrupt("return",l({functionName:p,functionArgs:[t.bufferCV(m),s(o)],publicKey:c,network:f}));case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function T(){return(T=a(i.mark((function e(r){var n,a,o,s,p,h,m,d,y;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=r.salt,a=r.zonefile,o=r.publicKey,s=r.network,p="name-register",h=u(r.fullyQualifiedName),m=h.namespace,d=h.name,!h.subdomain){e.next=5;break}throw new Error("Cannot register a subdomain using registerName()");case 5:return y=f(a),e.abrupt("return",l({functionName:p,functionArgs:[c(m),c(d),c(n),t.bufferCV(y)],network:s,publicKey:o,attachment:Buffer.from(a)}));case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function E(){return(E=a(i.mark((function e(r){var n,a,o,s,p,h,m,d;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=r.zonefile,a=r.publicKey,o=r.network,s="name-update",p=u(r.fullyQualifiedName),h=p.namespace,m=p.name,!p.subdomain){e.next=5;break}throw new Error("Cannot update a subdomain using updateName()");case 5:return d=f(n),e.abrupt("return",l({functionName:s,functionArgs:[c(h),c(m),t.bufferCV(d)],publicKey:a,network:o,attachment:Buffer.from(n)}));case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function A(){return(A=a(i.mark((function e(r){var n,a,o,s,p,h,m,d,y;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=r.newOwnerAddress,a=r.zonefile,o=r.publicKey,s=r.network,p="name-transfer",h=u(r.fullyQualifiedName),m=h.namespace,d=h.name,!h.subdomain){e.next=5;break}throw new Error("Cannot transfer a subdomain using transferName()");case 5:return y=[c(m),c(d),c(n)],a&&y.push(t.bufferCV(f(a))),e.abrupt("return",l({functionName:p,functionArgs:y,publicKey:o,network:s,attachment:a?Buffer.from(a):void 0}));case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function C(){return(C=a(i.mark((function e(t){var r,n,a,o,s,f;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.publicKey,n=t.network,a="name-revoke",o=u(t.fullyQualifiedName),s=o.namespace,f=o.name,!o.subdomain){e.next=5;break}throw new Error("Cannot revoke a subdomain using revokeName()");case 5:return e.abrupt("return",l({functionName:a,functionArgs:[c(s),c(f)],publicKey:r,network:n}));case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function K(){return(K=a(i.mark((function e(r){var n,a,o,p,h,m,d,y,v,w,b;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=r.stxToBurn,a=r.newOwnerAddress,o=r.zonefile,p=r.publicKey,h=r.network,m="name-renewal",d=u(r.fullyQualifiedName),y=d.namespace,v=d.name,!d.subdomain){e.next=5;break}throw new Error("Cannot renew a subdomain using renewName()");case 5:return w=[c(y),c(v),s(n)],a&&w.push(c(a)),o&&(b=f(o),w.push(t.bufferCV(b))),e.abrupt("return",l({functionName:m,functionArgs:w,publicKey:p,network:h,attachment:o?Buffer.from(o):void 0}));case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}e.BNS_CONTRACT_NAME="bns",e.buildImportNameTx=function(e){return k.apply(this,arguments)},e.buildPreorderNameTx=function(e){return N.apply(this,arguments)},e.buildPreorderNamespaceTx=function(e){return b.apply(this,arguments)},e.buildReadyNamespaceTx=function(e){return x.apply(this,arguments)},e.buildRegisterNameTx=function(e){return T.apply(this,arguments)},e.buildRenewNameTx=function(e){return K.apply(this,arguments)},e.buildRevealNamespaceTx=function(e){return g.apply(this,arguments)},e.buildRevokeNameTx=function(e){return C.apply(this,arguments)},e.buildTransferNameTx=function(e){return A.apply(this,arguments)},e.buildUpdateNameTx=function(e){return E.apply(this,arguments)},e.canRegisterName=function(e){return y.apply(this,arguments)},e.getNamePrice=function(e){return w.apply(this,arguments)},e.getNamespacePrice=function(e){return v.apply(this,arguments)},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=bns.umd.production.min.js.map |
@@ -234,3 +234,3 @@ import { asyncToGenerator as _asyncToGenerator } from './_virtual/_rollupPluginBabelHelpers.js'; | ||
bnsFunctionName = 'namespace-preorder'; | ||
saltedNamespaceBuffer = Buffer.from("0x" + namespace + salt); | ||
saltedNamespaceBuffer = Buffer.from("" + namespace + salt); | ||
hashedSaltedNamespace = hash160(saltedNamespaceBuffer); | ||
@@ -370,3 +370,3 @@ return _context6.abrupt("return", makeBnsContractCall({ | ||
case 5: | ||
saltedNamesBuffer = Buffer.from("0x" + fullyQualifiedName + salt); | ||
saltedNamesBuffer = Buffer.from("" + fullyQualifiedName + salt); | ||
hashedSaltedName = hash160(saltedNamesBuffer); | ||
@@ -373,0 +373,0 @@ return _context10.abrupt("return", makeBnsContractCall({ |
{ | ||
"name": "@stacks/bns", | ||
"version": "1.4.0-alpha.0", | ||
"version": "1.4.1-alpha.0", | ||
"description": "Library for working with the Stacks Blockchain Naming System BNS.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
591478