@burstjs/contracts
Advanced tools
Comparing version 0.5.0-alpha.3 to 0.5.0-beta.1
@@ -1,2 +0,2 @@ | ||
var b$contracts=function(e){"use strict";var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function n(e,r){return e(r={exports:{}},r.exports),r.exports}var i=n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertNumberToNQTString=(e=>{if(null==e)throw new Error("Invalid argument");return parseFloat(e.toString()).toFixed(8).replace(".","")})});t(i);i.convertNumberToNQTString;var o=n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertNQTStringToNumber=(e=>{if(null==e||""===e)throw new Error("Invalid argument");return parseFloat(e)/1e8})});t(o);o.convertNQTStringToNumber;var u=n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.GenesisBlockTime=Date.UTC(2014,7,11,2,0,0,0)/1e3,r.initialCodeword=[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],r.gexp=[1,2,4,8,16,5,10,20,13,26,17,7,14,28,29,31,27,19,3,6,12,24,21,15,30,25,23,11,22,9,18,1],r.glog=[0,0,1,18,2,5,19,11,3,29,6,27,20,8,12,23,4,10,30,17,7,22,28,26,21,25,9,16,13,14,24,15],r.cwmap=[3,2,1,0,7,6,5,4,13,14,15,16,12,8,9,10,11],r.alphabet="23456789ABCDEFGHJKLMNPQRSTUVWXYZ".split(""),r.base32Length=13,r.ginv=(e=>r.gexp[31-r.glog[e]]),r.gmult=((e,t)=>{if(0===e||0===t)return 0;const n=(r.glog[e]+r.glog[t])%31;return r.gexp[n]})});t(u);u.GenesisBlockTime,u.initialCodeword,u.gexp,u.glog,u.cwmap,u.alphabet,u.base32Length,u.ginv,u.gmult;var l=n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertNumericIdToAddress=(e=>{if(null==e||0===e.trim().length)return;const r=[],t=u.initialCodeword.slice();let n=0,i=e.length;for(let t=0;t<i;t++)r[t]=e.charCodeAt(t)-"0".charCodeAt(0);let o=0,l=0;do{o=0,l=0;for(let e=0;e<i;e++)(o=10*o+r[e])>=32?(r[l]=o>>5,o&=31,l++):l>0&&(r[l]=0,l++);i=l,t[n]=o,n++}while(i>0);const c=[0,0,0,0];for(let e=u.base32Length-1;e>=0;e--){const r=t[e]^c[3];c[3]=c[2]^u.gmult(30,r),c[2]=c[1]^u.gmult(6,r),c[1]=c[0]^u.gmult(9,r),c[0]=u.gmult(17,r)}t[13]=c[0],t[14]=c[1],t[15]=c[2],t[16]=c[3];let a="BURST-";for(let e=0;e<17;e++)a+=u.alphabet[t[u.cwmap[e]]],3==(3&e)&&e<13&&(a+="-");return a})});t(l);l.convertNumericIdToAddress;var c=n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertBurstTimeToEpochTime=(e=>1e3*(u.GenesisBlockTime+e))});t(c);c.convertBurstTimeToEpochTime;var a=n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertBurstTimeToDate=(e=>new Date(c.convertBurstTimeToEpochTime(e)))});t(a);a.convertBurstTimeToDate;var s=n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertDateToBurstTime=(e=>Math.round(e.getTime()/1e3)-u.GenesisBlockTime)});t(s);s.convertDateToBurstTime;var f=n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.isValid=(e=>{0===e.indexOf("BURST-")&&(e=e.substr(6));const r=u.initialCodeword.slice();let t=0;for(let n=0;n<e.length;n++){const i=u.alphabet.indexOf(e.charAt(n));if(!(i<=-1||i>u.alphabet.length)){if(t>16)return!1;r[u.cwmap[t]]=i,t++}}if(17!==t)return!1;let n=0;for(let e=1;e<5;e++){let t=0;for(let n=0;n<31;n++){if(n>12&&n<27)continue;let i=n;n>26&&(i-=14),t^=u.gmult(r[i],u.gexp[e*n%31])}n|=t}return 0===n}),r.isBurstAddress=(e=>/^BURST\-[A-Z0-9]{4}\-[A-Z0-9]{4}\-[A-Z0-9]{4}\-[A-Z0-9]{5}/i.test(e)&&r.isValid(e))});t(f);f.isValid,f.isBurstAddress;var h=n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertAddressToNumericId=(e=>{if(null==e||0===e.trim().length)return;if(0!==e.indexOf("BURST-"))return;e=e.substr(6);const r=u.initialCodeword.slice();let t=0;for(let n=0;n<e.length;n++){const i=u.alphabet.indexOf(e.charAt(n));if(!(i<=-1||i>u.alphabet.length)){if(t>16)return;r[u.cwmap[t]]=i,t++}}if(!f.isValid(e))return;let n=u.base32Length;const i=[];for(let e=0;e<n;e++)i[e]=r[n-e-1];let o,l="",c=0;do{o=0,c=0;for(let e=0;e<n;e++)(c=32*c+i[e])>=10?(i[o]=Math.floor(c/10),c%=10,o+=1):o>0&&(i[o]=0,o+=1);n=o,l+=c}while(n>0);return l.split("").reverse().join("")})});t(h);h.convertAddressToNumericId;var g=n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.sumNQTStringToNumber=function(...e){return e.reduce((e,r)=>e+o.convertNQTStringToNumber(r),0)}});t(g);g.sumNQTStringToNumber;var p=n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertByteArrayToString=((e,r=0,t=null)=>{if(0===t)return"";let n=e;if(0!==r){const i=null===t?e.length-r:t;!function(e,r,t=0){if(t<0)throw new Error("Start index should not be negative");if(e.length<t+r)throw new Error("Need at least "+r+" bytes to convert to an integer")}(n,i,r),n=e.slice(r,r+i)}return decodeURIComponent(escape(String.fromCharCode.apply(null,Array.from(n))))})});t(p);p.convertByteArrayToString;var d=n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertByteArrayToHexString=((e,r=!1)=>{const t=[];for(let r=0;r<e.length;r++)t.push((e[r]>>>4).toString(16)),t.push((15&e[r]).toString(16));return r?t.join("").toUpperCase():t.join("")})});t(d);d.convertByteArrayToHexString;var v=n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertHexStringToByteArray=(e=>{if(e.length%2)throw new Error(`Invalid Hex String: ${e}`);const r=new Uint8Array(e.length/2);for(let t=0;t<e.length;t+=2){const n=parseInt(e.substr(t,2),16);if(Number.isNaN(n))throw new Error(`Invalid Hex String: ${e}`);r[t/2]=n}return r})});t(v);v.convertHexStringToByteArray;var m=n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertHexStringToDecString=(e=>{const r=[0];let t,n,i;for(t=0;t<e.length;t+=1){for(i=parseInt(e.charAt(t),16),n=0;n<r.length;n+=1)r[n]=16*r[n]+i,i=r[n]/10|0,r[n]%=10;for(;i>0;)r.push(i%10),i=i/10|0}return r.reverse().join("")})});t(m);m.convertHexStringToDecString;var w=n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertHexStringToString=(e=>p.convertByteArrayToString(v.convertHexStringToByteArray(e)))});t(w);w.convertHexStringToString;var y=n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertStringToByteArray=(e=>{const r=unescape(encodeURIComponent(e)),t=new Uint8Array(r.length);for(let e=0;e<r.length;++e)t[e]=r.charCodeAt(e);return t})});t(y);y.convertStringToByteArray;var b=n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertStringToHexString=(e=>d.convertByteArrayToHexString(y.convertStringToByteArray(e)))});t(b);b.convertStringToHexString;var T=n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertHexEndianess=(e=>{let r="";const t=e;for(let e=t.length-1;e>=0;e-=2)r+=t[e-1]+t[e];return r})});t(T);T.convertHexEndianess;var A=n(function(e,r){function t(e){for(var t in e)r.hasOwnProperty(t)||(r[t]=e[t])}Object.defineProperty(r,"__esModule",{value:!0}),t(i),t(o),t(l),t(c),t(a),t(s),t(h),t(f),t(g),t(p),t(d),t(v),t(m),t(w),t(y),t(b),t(T)});t(A);var S=A.convertNumberToNQTString,N=(A.convertNQTStringToNumber,A.convertHexStringToDecString),O=A.convertHexStringToString,E=A.convertHexEndianess;A.convertHexStringToByteArray,A.convertByteArrayToHexString;function _(e,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:16,n=16*r,i=n+t;if(i>e.machineData.length)throw new Error("Insufficient length for variable at position: ".concat(n," (and given length: ").concat(t,")"));if(i%2!=0)throw new Error("Invalid position: ".concat(n," (or given length: ").concat(t,") - must be at least multiple of 2"));return E(e.machineData.substr(n,t))}function x(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function B(e){return function(e){if(Array.isArray(e)){for(var r=0,t=new Array(e.length);r<e.length;r++)t[r]=e[r];return t}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var P=256,D=function(){function e(r){!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e),this._contract=r}var r,t,n;return r=e,(t=[{key:"getContract",value:function(){return this._contract}},{key:"countCodePages",value:function(){return this._contract.machineCode.length/2/P}},{key:"getVariableAsString",value:function(r){var t=this.getHexDataAt(r,e.VARIABLE_LENGTH);return O(t.replace(/00/g,""))}},{key:"getDataBlocksAsString",value:function(r,t){var n=this.getHexDataAt(r,t*e.VARIABLE_LENGTH);return O(n.replace(/00/g,""))}},{key:"getVariableAsDecimal",value:function(e){return N(this.getVariable(e))}},{key:"getVariable",value:function(r){return this.getHexDataAt(r,e.VARIABLE_LENGTH)}},{key:"getHexDataAt",value:function(r,t){var n=t||this._contract.machineData.length-e.VARIABLE_LENGTH*r;return _(this._contract,r,n)}}])&&x(r.prototype,t),n&&x(r,n),e}();function C(e){return Math.ceil(e.length/2/P)}D.VARIABLE_LENGTH=16,String.prototype.padStart||(String.prototype.padStart=function(e,r){return e>>=0,r=String(void 0!==r?r:" "),this.length>=e?String(this):((e-=this.length)>r.length&&(r+=r.repeat(e/r.length)),r.slice(0,e)+String(this))});var M=n(function(e){!function(r){var t,n=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,i=Math.ceil,o=Math.floor,u="[BigNumber Error] ",l=u+"Number primitive has more than 15 significant digits: ",c=1e14,a=14,s=9007199254740991,f=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],h=1e7,g=1e9;function p(e){var r=0|e;return e>0||e===r?r:r-1}function d(e){for(var r,t,n=1,i=e.length,o=e[0]+"";n<i;){for(r=e[n++]+"",t=a-r.length;t--;r="0"+r);o+=r}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function v(e,r){var t,n,i=e.c,o=r.c,u=e.s,l=r.s,c=e.e,a=r.e;if(!u||!l)return null;if(t=i&&!i[0],n=o&&!o[0],t||n)return t?n?0:-l:u;if(u!=l)return u;if(t=u<0,n=c==a,!i||!o)return n?0:!i^t?1:-1;if(!n)return c>a^t?1:-1;for(l=(c=i.length)<(a=o.length)?c:a,u=0;u<l;u++)if(i[u]!=o[u])return i[u]>o[u]^t?1:-1;return c==a?0:c>a^t?1:-1}function m(e,r,t,n){if(e<r||e>t||e!==o(e))throw Error(u+(n||"Argument")+("number"==typeof e?e<r||e>t?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function w(e){var r=e.c.length-1;return p(e.e/a)==r&&e.c[r]%2!=0}function y(e,r){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(r<0?"e":"e+")+r}function b(e,r,t){var n,i;if(r<0){for(i=t+".";++r;i+=t);e=i+e}else if(++r>(n=e.length)){for(i=t,r-=n;--r;i+=t);e+=i}else r<n&&(e=e.slice(0,r)+"."+e.slice(r));return e}(t=function e(r){var t,T,A,S,N,O,E,_,x,B=V.prototype={constructor:V,toString:null,valueOf:null},P=new V(1),D=20,C=4,M=-7,I=21,j=-1e7,H=1e7,L=!1,R=1,U=0,k={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},G="0123456789abcdefghijklmnopqrstuvwxyz";function V(e,r){var t,i,u,c,f,h,g,p,d=this;if(!(d instanceof V))return new V(e,r);if(null==r){if(e&&!0===e._isBigNumber)return d.s=e.s,void(!e.c||e.e>H?d.c=d.e=null:e.e<j?d.c=[d.e=0]:(d.e=e.e,d.c=e.c.slice()));if((h="number"==typeof e)&&0*e==0){if(d.s=1/e<0?(e=-e,-1):1,e===~~e){for(c=0,f=e;f>=10;f/=10,c++);return void(c>H?d.c=d.e=null:(d.e=c,d.c=[e]))}p=String(e)}else{if(!n.test(p=String(e)))return A(d,p,h);d.s=45==p.charCodeAt(0)?(p=p.slice(1),-1):1}(c=p.indexOf("."))>-1&&(p=p.replace(".","")),(f=p.search(/e/i))>0?(c<0&&(c=f),c+=+p.slice(f+1),p=p.substring(0,f)):c<0&&(c=p.length)}else{if(m(r,2,G.length,"Base"),10==r)return Q(d=new V(e),D+d.e+1,C);if(p=String(e),h="number"==typeof e){if(0*e!=0)return A(d,p,h,r);if(d.s=1/e<0?(p=p.slice(1),-1):1,V.DEBUG&&p.replace(/^0\.0*|\./,"").length>15)throw Error(l+e)}else d.s=45===p.charCodeAt(0)?(p=p.slice(1),-1):1;for(t=G.slice(0,r),c=f=0,g=p.length;f<g;f++)if(t.indexOf(i=p.charAt(f))<0){if("."==i){if(f>c){c=g;continue}}else if(!u&&(p==p.toUpperCase()&&(p=p.toLowerCase())||p==p.toLowerCase()&&(p=p.toUpperCase()))){u=!0,f=-1,c=0;continue}return A(d,String(e),h,r)}h=!1,(c=(p=T(p,r,10,d.s)).indexOf("."))>-1?p=p.replace(".",""):c=p.length}for(f=0;48===p.charCodeAt(f);f++);for(g=p.length;48===p.charCodeAt(--g););if(p=p.slice(f,++g)){if(g-=f,h&&V.DEBUG&&g>15&&(e>s||e!==o(e)))throw Error(l+d.s*e);if((c=c-f-1)>H)d.c=d.e=null;else if(c<j)d.c=[d.e=0];else{if(d.e=c,d.c=[],f=(c+1)%a,c<0&&(f+=a),f<g){for(f&&d.c.push(+p.slice(0,f)),g-=a;f<g;)d.c.push(+p.slice(f,f+=a));f=a-(p=p.slice(f)).length}else f-=g;for(;f--;p+="0");d.c.push(+p)}}else d.c=[d.e=0]}function F(e,r,t,n){var i,o,u,l,c;if(null==t?t=C:m(t,0,8),!e.c)return e.toString();if(i=e.c[0],u=e.e,null==r)c=d(e.c),c=1==n||2==n&&(u<=M||u>=I)?y(c,u):b(c,u,"0");else if(o=(e=Q(new V(e),r,t)).e,l=(c=d(e.c)).length,1==n||2==n&&(r<=o||o<=M)){for(;l<r;c+="0",l++);c=y(c,o)}else if(r-=u,c=b(c,o,"0"),o+1>l){if(--r>0)for(c+=".";r--;c+="0");}else if((r+=o-l)>0)for(o+1==l&&(c+=".");r--;c+="0");return e.s<0&&i?"-"+c:c}function $(e,r){for(var t,n=1,i=new V(e[0]);n<e.length;n++){if(!(t=new V(e[n])).s){i=t;break}r.call(i,t)&&(i=t)}return i}function q(e,r,t){for(var n=1,i=r.length;!r[--i];r.pop());for(i=r[0];i>=10;i/=10,n++);return(t=n+t*a-1)>H?e.c=e.e=null:t<j?e.c=[e.e=0]:(e.e=t,e.c=r),e}function Q(e,r,t,n){var u,l,s,h,g,p,d,v=e.c,m=f;if(v){e:{for(u=1,h=v[0];h>=10;h/=10,u++);if((l=r-u)<0)l+=a,s=r,d=(g=v[p=0])/m[u-s-1]%10|0;else if((p=i((l+1)/a))>=v.length){if(!n)break e;for(;v.length<=p;v.push(0));g=d=0,u=1,s=(l%=a)-a+1}else{for(g=h=v[p],u=1;h>=10;h/=10,u++);d=(s=(l%=a)-a+u)<0?0:g/m[u-s-1]%10|0}if(n=n||r<0||null!=v[p+1]||(s<0?g:g%m[u-s-1]),n=t<4?(d||n)&&(0==t||t==(e.s<0?3:2)):d>5||5==d&&(4==t||n||6==t&&(l>0?s>0?g/m[u-s]:0:v[p-1])%10&1||t==(e.s<0?8:7)),r<1||!v[0])return v.length=0,n?(r-=e.e+1,v[0]=m[(a-r%a)%a],e.e=-r||0):v[0]=e.e=0,e;if(0==l?(v.length=p,h=1,p--):(v.length=p+1,h=m[a-l],v[p]=s>0?o(g/m[u-s]%m[s])*h:0),n)for(;;){if(0==p){for(l=1,s=v[0];s>=10;s/=10,l++);for(s=v[0]+=h,h=1;s>=10;s/=10,h++);l!=h&&(e.e++,v[0]==c&&(v[0]=1));break}if(v[p]+=h,v[p]!=c)break;v[p--]=0,h=1}for(l=v.length;0===v[--l];v.pop());}e.e>H?e.c=e.e=null:e.e<j&&(e.c=[e.e=0])}return e}function z(e){var r,t=e.e;return null===t?e.toString():(r=d(e.c),r=t<=M||t>=I?y(r,t):b(r,t,"0"),e.s<0?"-"+r:r)}return V.clone=e,V.ROUND_UP=0,V.ROUND_DOWN=1,V.ROUND_CEIL=2,V.ROUND_FLOOR=3,V.ROUND_HALF_UP=4,V.ROUND_HALF_DOWN=5,V.ROUND_HALF_EVEN=6,V.ROUND_HALF_CEIL=7,V.ROUND_HALF_FLOOR=8,V.EUCLID=9,V.config=V.set=function(e){var r,t;if(null!=e){if("object"!=typeof e)throw Error(u+"Object expected: "+e);if(e.hasOwnProperty(r="DECIMAL_PLACES")&&(m(t=e[r],0,g,r),D=t),e.hasOwnProperty(r="ROUNDING_MODE")&&(m(t=e[r],0,8,r),C=t),e.hasOwnProperty(r="EXPONENTIAL_AT")&&((t=e[r])&&t.pop?(m(t[0],-g,0,r),m(t[1],0,g,r),M=t[0],I=t[1]):(m(t,-g,g,r),M=-(I=t<0?-t:t))),e.hasOwnProperty(r="RANGE"))if((t=e[r])&&t.pop)m(t[0],-g,-1,r),m(t[1],1,g,r),j=t[0],H=t[1];else{if(m(t,-g,g,r),!t)throw Error(u+r+" cannot be zero: "+t);j=-(H=t<0?-t:t)}if(e.hasOwnProperty(r="CRYPTO")){if((t=e[r])!==!!t)throw Error(u+r+" not true or false: "+t);if(t){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw L=!t,Error(u+"crypto unavailable");L=t}else L=t}if(e.hasOwnProperty(r="MODULO_MODE")&&(m(t=e[r],0,9,r),R=t),e.hasOwnProperty(r="POW_PRECISION")&&(m(t=e[r],0,g,r),U=t),e.hasOwnProperty(r="FORMAT")){if("object"!=typeof(t=e[r]))throw Error(u+r+" not an object: "+t);k=t}if(e.hasOwnProperty(r="ALPHABET")){if("string"!=typeof(t=e[r])||/^.$|[+-.\s]|(.).*\1/.test(t))throw Error(u+r+" invalid: "+t);G=t}}return{DECIMAL_PLACES:D,ROUNDING_MODE:C,EXPONENTIAL_AT:[M,I],RANGE:[j,H],CRYPTO:L,MODULO_MODE:R,POW_PRECISION:U,FORMAT:k,ALPHABET:G}},V.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!V.DEBUG)return!0;var r,t,n=e.c,i=e.e,l=e.s;e:if("[object Array]"=={}.toString.call(n)){if((1===l||-1===l)&&i>=-g&&i<=g&&i===o(i)){if(0===n[0]){if(0===i&&1===n.length)return!0;break e}if((r=(i+1)%a)<1&&(r+=a),String(n[0]).length==r){for(r=0;r<n.length;r++)if((t=n[r])<0||t>=c||t!==o(t))break e;if(0!==t)return!0}}}else if(null===n&&null===i&&(null===l||1===l||-1===l))return!0;throw Error(u+"Invalid BigNumber: "+e)},V.maximum=V.max=function(){return $(arguments,B.lt)},V.minimum=V.min=function(){return $(arguments,B.gt)},V.random=(S=9007199254740992*Math.random()&2097151?function(){return o(9007199254740992*Math.random())}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var r,t,n,l,c,s=0,h=[],p=new V(P);if(null==e?e=D:m(e,0,g),l=i(e/a),L)if(crypto.getRandomValues){for(r=crypto.getRandomValues(new Uint32Array(l*=2));s<l;)(c=131072*r[s]+(r[s+1]>>>11))>=9e15?(t=crypto.getRandomValues(new Uint32Array(2)),r[s]=t[0],r[s+1]=t[1]):(h.push(c%1e14),s+=2);s=l/2}else{if(!crypto.randomBytes)throw L=!1,Error(u+"crypto unavailable");for(r=crypto.randomBytes(l*=7);s<l;)(c=281474976710656*(31&r[s])+1099511627776*r[s+1]+4294967296*r[s+2]+16777216*r[s+3]+(r[s+4]<<16)+(r[s+5]<<8)+r[s+6])>=9e15?crypto.randomBytes(7).copy(r,s):(h.push(c%1e14),s+=7);s=l/7}if(!L)for(;s<l;)(c=S())<9e15&&(h[s++]=c%1e14);for(l=h[--s],e%=a,l&&e&&(c=f[a-e],h[s]=o(l/c)*c);0===h[s];h.pop(),s--);if(s<0)h=[n=0];else{for(n=-1;0===h[0];h.splice(0,1),n-=a);for(s=1,c=h[0];c>=10;c/=10,s++);s<a&&(n-=a-s)}return p.e=n,p.c=h,p}),V.sum=function(){for(var e=1,r=arguments,t=new V(r[0]);e<r.length;)t=t.plus(r[e++]);return t},T=function(){function e(e,r,t,n){for(var i,o,u=[0],l=0,c=e.length;l<c;){for(o=u.length;o--;u[o]*=r);for(u[0]+=n.indexOf(e.charAt(l++)),i=0;i<u.length;i++)u[i]>t-1&&(null==u[i+1]&&(u[i+1]=0),u[i+1]+=u[i]/t|0,u[i]%=t)}return u.reverse()}return function(r,n,i,o,u){var l,c,a,s,f,h,g,p,v=r.indexOf("."),m=D,w=C;for(v>=0&&(s=U,U=0,r=r.replace(".",""),h=(p=new V(n)).pow(r.length-v),U=s,p.c=e(b(d(h.c),h.e,"0"),10,i,"0123456789"),p.e=p.c.length),a=s=(g=e(r,n,i,u?(l=G,"0123456789"):(l="0123456789",G))).length;0==g[--s];g.pop());if(!g[0])return l.charAt(0);if(v<0?--a:(h.c=g,h.e=a,h.s=o,g=(h=t(h,p,m,w,i)).c,f=h.r,a=h.e),v=g[c=a+m+1],s=i/2,f=f||c<0||null!=g[c+1],f=w<4?(null!=v||f)&&(0==w||w==(h.s<0?3:2)):v>s||v==s&&(4==w||f||6==w&&1&g[c-1]||w==(h.s<0?8:7)),c<1||!g[0])r=f?b(l.charAt(1),-m,l.charAt(0)):l.charAt(0);else{if(g.length=c,f)for(--i;++g[--c]>i;)g[c]=0,c||(++a,g=[1].concat(g));for(s=g.length;!g[--s];);for(v=0,r="";v<=s;r+=l.charAt(g[v++]));r=b(r,a,l.charAt(0))}return r}}(),t=function(){function e(e,r,t){var n,i,o,u,l=0,c=e.length,a=r%h,s=r/h|0;for(e=e.slice();c--;)l=((i=a*(o=e[c]%h)+(n=s*o+(u=e[c]/h|0)*a)%h*h+l)/t|0)+(n/h|0)+s*u,e[c]=i%t;return l&&(e=[l].concat(e)),e}function r(e,r,t,n){var i,o;if(t!=n)o=t>n?1:-1;else for(i=o=0;i<t;i++)if(e[i]!=r[i]){o=e[i]>r[i]?1:-1;break}return o}function t(e,r,t,n){for(var i=0;t--;)e[t]-=i,i=e[t]<r[t]?1:0,e[t]=i*n+e[t]-r[t];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(n,i,u,l,s){var f,h,g,d,v,m,w,y,b,T,A,S,N,O,E,_,x,B=n.s==i.s?1:-1,P=n.c,D=i.c;if(!(P&&P[0]&&D&&D[0]))return new V(n.s&&i.s&&(P?!D||P[0]!=D[0]:D)?P&&0==P[0]||!D?0*B:B/0:NaN);for(b=(y=new V(B)).c=[],B=u+(h=n.e-i.e)+1,s||(s=c,h=p(n.e/a)-p(i.e/a),B=B/a|0),g=0;D[g]==(P[g]||0);g++);if(D[g]>(P[g]||0)&&h--,B<0)b.push(1),d=!0;else{for(O=P.length,_=D.length,g=0,B+=2,(v=o(s/(D[0]+1)))>1&&(D=e(D,v,s),P=e(P,v,s),_=D.length,O=P.length),N=_,A=(T=P.slice(0,_)).length;A<_;T[A++]=0);x=D.slice(),x=[0].concat(x),E=D[0],D[1]>=s/2&&E++;do{if(v=0,(f=r(D,T,_,A))<0){if(S=T[0],_!=A&&(S=S*s+(T[1]||0)),(v=o(S/E))>1)for(v>=s&&(v=s-1),w=(m=e(D,v,s)).length,A=T.length;1==r(m,T,w,A);)v--,t(m,_<w?x:D,w,s),w=m.length,f=1;else 0==v&&(f=v=1),w=(m=D.slice()).length;if(w<A&&(m=[0].concat(m)),t(T,m,A,s),A=T.length,-1==f)for(;r(D,T,_,A)<1;)v++,t(T,_<A?x:D,A,s),A=T.length}else 0===f&&(v++,T=[0]);b[g++]=v,T[0]?T[A++]=P[N]||0:(T=[P[N]],A=1)}while((N++<O||null!=T[0])&&B--);d=null!=T[0],b[0]||b.splice(0,1)}if(s==c){for(g=1,B=b[0];B>=10;B/=10,g++);Q(y,u+(y.e=g+h*a-1)+1,l,d)}else y.e=h,y.r=+d;return y}}(),N=/^(-?)0([xbo])(?=\w[\w.]*$)/i,O=/^([^.]+)\.$/,E=/^\.([^.]+)$/,_=/^-?(Infinity|NaN)$/,x=/^\s*\+(?=[\w.])|^\s+|\s+$/g,A=function(e,r,t,n){var i,o=t?r:r.replace(x,"");if(_.test(o))e.s=isNaN(o)?null:o<0?-1:1;else{if(!t&&(o=o.replace(N,function(e,r,t){return i="x"==(t=t.toLowerCase())?16:"b"==t?2:8,n&&n!=i?e:r}),n&&(i=n,o=o.replace(O,"$1").replace(E,"0.$1")),r!=o))return new V(o,i);if(V.DEBUG)throw Error(u+"Not a"+(n?" base "+n:"")+" number: "+r);e.s=null}e.c=e.e=null},B.absoluteValue=B.abs=function(){var e=new V(this);return e.s<0&&(e.s=1),e},B.comparedTo=function(e,r){return v(this,new V(e,r))},B.decimalPlaces=B.dp=function(e,r){var t,n,i,o=this;if(null!=e)return m(e,0,g),null==r?r=C:m(r,0,8),Q(new V(o),e+o.e+1,r);if(!(t=o.c))return null;if(n=((i=t.length-1)-p(this.e/a))*a,i=t[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},B.dividedBy=B.div=function(e,r){return t(this,new V(e,r),D,C)},B.dividedToIntegerBy=B.idiv=function(e,r){return t(this,new V(e,r),0,1)},B.exponentiatedBy=B.pow=function(e,r){var t,n,l,c,s,f,h,g,p=this;if((e=new V(e)).c&&!e.isInteger())throw Error(u+"Exponent not an integer: "+z(e));if(null!=r&&(r=new V(r)),s=e.e>14,!p.c||!p.c[0]||1==p.c[0]&&!p.e&&1==p.c.length||!e.c||!e.c[0])return g=new V(Math.pow(+z(p),s?2-w(e):+z(e))),r?g.mod(r):g;if(f=e.s<0,r){if(r.c?!r.c[0]:!r.s)return new V(NaN);(n=!f&&p.isInteger()&&r.isInteger())&&(p=p.mod(r))}else{if(e.e>9&&(p.e>0||p.e<-1||(0==p.e?p.c[0]>1||s&&p.c[1]>=24e7:p.c[0]<8e13||s&&p.c[0]<=9999975e7)))return c=p.s<0&&w(e)?-0:0,p.e>-1&&(c=1/c),new V(f?1/c:c);U&&(c=i(U/a+2))}for(s?(t=new V(.5),f&&(e.s=1),h=w(e)):h=(l=Math.abs(+z(e)))%2,g=new V(P);;){if(h){if(!(g=g.times(p)).c)break;c?g.c.length>c&&(g.c.length=c):n&&(g=g.mod(r))}if(l){if(0===(l=o(l/2)))break;h=l%2}else if(Q(e=e.times(t),e.e+1,1),e.e>14)h=w(e);else{if(0==(l=+z(e)))break;h=l%2}p=p.times(p),c?p.c&&p.c.length>c&&(p.c.length=c):n&&(p=p.mod(r))}return n?g:(f&&(g=P.div(g)),r?g.mod(r):c?Q(g,U,C,void 0):g)},B.integerValue=function(e){var r=new V(this);return null==e?e=C:m(e,0,8),Q(r,r.e+1,e)},B.isEqualTo=B.eq=function(e,r){return 0===v(this,new V(e,r))},B.isFinite=function(){return!!this.c},B.isGreaterThan=B.gt=function(e,r){return v(this,new V(e,r))>0},B.isGreaterThanOrEqualTo=B.gte=function(e,r){return 1===(r=v(this,new V(e,r)))||0===r},B.isInteger=function(){return!!this.c&&p(this.e/a)>this.c.length-2},B.isLessThan=B.lt=function(e,r){return v(this,new V(e,r))<0},B.isLessThanOrEqualTo=B.lte=function(e,r){return-1===(r=v(this,new V(e,r)))||0===r},B.isNaN=function(){return!this.s},B.isNegative=function(){return this.s<0},B.isPositive=function(){return this.s>0},B.isZero=function(){return!!this.c&&0==this.c[0]},B.minus=function(e,r){var t,n,i,o,u=this,l=u.s;if(r=(e=new V(e,r)).s,!l||!r)return new V(NaN);if(l!=r)return e.s=-r,u.plus(e);var s=u.e/a,f=e.e/a,h=u.c,g=e.c;if(!s||!f){if(!h||!g)return h?(e.s=-r,e):new V(g?u:NaN);if(!h[0]||!g[0])return g[0]?(e.s=-r,e):new V(h[0]?u:3==C?-0:0)}if(s=p(s),f=p(f),h=h.slice(),l=s-f){for((o=l<0)?(l=-l,i=h):(f=s,i=g),i.reverse(),r=l;r--;i.push(0));i.reverse()}else for(n=(o=(l=h.length)<(r=g.length))?l:r,l=r=0;r<n;r++)if(h[r]!=g[r]){o=h[r]<g[r];break}if(o&&(i=h,h=g,g=i,e.s=-e.s),(r=(n=g.length)-(t=h.length))>0)for(;r--;h[t++]=0);for(r=c-1;n>l;){if(h[--n]<g[n]){for(t=n;t&&!h[--t];h[t]=r);--h[t],h[n]+=c}h[n]-=g[n]}for(;0==h[0];h.splice(0,1),--f);return h[0]?q(e,h,f):(e.s=3==C?-1:1,e.c=[e.e=0],e)},B.modulo=B.mod=function(e,r){var n,i,o=this;return e=new V(e,r),!o.c||!e.s||e.c&&!e.c[0]?new V(NaN):!e.c||o.c&&!o.c[0]?new V(o):(9==R?(i=e.s,e.s=1,n=t(o,e,0,3),e.s=i,n.s*=i):n=t(o,e,0,R),(e=o.minus(n.times(e))).c[0]||1!=R||(e.s=o.s),e)},B.multipliedBy=B.times=function(e,r){var t,n,i,o,u,l,s,f,g,d,v,m,w,y,b,T=this,A=T.c,S=(e=new V(e,r)).c;if(!(A&&S&&A[0]&&S[0]))return!T.s||!e.s||A&&!A[0]&&!S||S&&!S[0]&&!A?e.c=e.e=e.s=null:(e.s*=T.s,A&&S?(e.c=[0],e.e=0):e.c=e.e=null),e;for(n=p(T.e/a)+p(e.e/a),e.s*=T.s,(s=A.length)<(d=S.length)&&(w=A,A=S,S=w,i=s,s=d,d=i),i=s+d,w=[];i--;w.push(0));for(y=c,b=h,i=d;--i>=0;){for(t=0,v=S[i]%b,m=S[i]/b|0,o=i+(u=s);o>i;)t=((f=v*(f=A[--u]%b)+(l=m*f+(g=A[u]/b|0)*v)%b*b+w[o]+t)/y|0)+(l/b|0)+m*g,w[o--]=f%y;w[o]=t}return t?++n:w.splice(0,1),q(e,w,n)},B.negated=function(){var e=new V(this);return e.s=-e.s||null,e},B.plus=function(e,r){var t,n=this,i=n.s;if(r=(e=new V(e,r)).s,!i||!r)return new V(NaN);if(i!=r)return e.s=-r,n.minus(e);var o=n.e/a,u=e.e/a,l=n.c,s=e.c;if(!o||!u){if(!l||!s)return new V(i/0);if(!l[0]||!s[0])return s[0]?e:new V(l[0]?n:0*i)}if(o=p(o),u=p(u),l=l.slice(),i=o-u){for(i>0?(u=o,t=s):(i=-i,t=l),t.reverse();i--;t.push(0));t.reverse()}for((i=l.length)-(r=s.length)<0&&(t=s,s=l,l=t,r=i),i=0;r;)i=(l[--r]=l[r]+s[r]+i)/c|0,l[r]=c===l[r]?0:l[r]%c;return i&&(l=[i].concat(l),++u),q(e,l,u)},B.precision=B.sd=function(e,r){var t,n,i,o=this;if(null!=e&&e!==!!e)return m(e,1,g),null==r?r=C:m(r,0,8),Q(new V(o),e,r);if(!(t=o.c))return null;if(n=(i=t.length-1)*a+1,i=t[i]){for(;i%10==0;i/=10,n--);for(i=t[0];i>=10;i/=10,n++);}return e&&o.e+1>n&&(n=o.e+1),n},B.shiftedBy=function(e){return m(e,-s,s),this.times("1e"+e)},B.squareRoot=B.sqrt=function(){var e,r,n,i,o,u=this,l=u.c,c=u.s,a=u.e,s=D+4,f=new V("0.5");if(1!==c||!l||!l[0])return new V(!c||c<0&&(!l||l[0])?NaN:l?u:1/0);if(0==(c=Math.sqrt(+z(u)))||c==1/0?(((r=d(l)).length+a)%2==0&&(r+="0"),c=Math.sqrt(+r),a=p((a+1)/2)-(a<0||a%2),n=new V(r=c==1/0?"1e"+a:(r=c.toExponential()).slice(0,r.indexOf("e")+1)+a)):n=new V(c+""),n.c[0])for((c=(a=n.e)+s)<3&&(c=0);;)if(o=n,n=f.times(o.plus(t(u,o,s,1))),d(o.c).slice(0,c)===(r=d(n.c)).slice(0,c)){if(n.e<a&&--c,"9999"!=(r=r.slice(c-3,c+1))&&(i||"4999"!=r)){+r&&(+r.slice(1)||"5"!=r.charAt(0))||(Q(n,n.e+D+2,1),e=!n.times(n).eq(u));break}if(!i&&(Q(o,o.e+D+2,0),o.times(o).eq(u))){n=o;break}s+=4,c+=4,i=1}return Q(n,n.e+D+1,C,e)},B.toExponential=function(e,r){return null!=e&&(m(e,0,g),e++),F(this,e,r,1)},B.toFixed=function(e,r){return null!=e&&(m(e,0,g),e=e+this.e+1),F(this,e,r)},B.toFormat=function(e,r,t){var n,i=this;if(null==t)null!=e&&r&&"object"==typeof r?(t=r,r=null):e&&"object"==typeof e?(t=e,e=r=null):t=k;else if("object"!=typeof t)throw Error(u+"Argument not an object: "+t);if(n=i.toFixed(e,r),i.c){var o,l=n.split("."),c=+t.groupSize,a=+t.secondaryGroupSize,s=t.groupSeparator||"",f=l[0],h=l[1],g=i.s<0,p=g?f.slice(1):f,d=p.length;if(a&&(o=c,c=a,a=o,d-=o),c>0&&d>0){for(o=d%c||c,f=p.substr(0,o);o<d;o+=c)f+=s+p.substr(o,c);a>0&&(f+=s+p.slice(o)),g&&(f="-"+f)}n=h?f+(t.decimalSeparator||"")+((a=+t.fractionGroupSize)?h.replace(new RegExp("\\d{"+a+"}\\B","g"),"$&"+(t.fractionGroupSeparator||"")):h):f}return(t.prefix||"")+n+(t.suffix||"")},B.toFraction=function(e){var r,n,i,o,l,c,s,h,g,p,v,m,w=this,y=w.c;if(null!=e&&(!(s=new V(e)).isInteger()&&(s.c||1!==s.s)||s.lt(P)))throw Error(u+"Argument "+(s.isInteger()?"out of range: ":"not an integer: ")+z(s));if(!y)return new V(w);for(r=new V(P),g=n=new V(P),i=h=new V(P),m=d(y),l=r.e=m.length-w.e-1,r.c[0]=f[(c=l%a)<0?a+c:c],e=!e||s.comparedTo(r)>0?l>0?r:g:s,c=H,H=1/0,s=new V(m),h.c[0]=0;p=t(s,r,0,1),1!=(o=n.plus(p.times(i))).comparedTo(e);)n=i,i=o,g=h.plus(p.times(o=g)),h=o,r=s.minus(p.times(o=r)),s=o;return o=t(e.minus(n),i,0,1),h=h.plus(o.times(g)),n=n.plus(o.times(i)),h.s=g.s=w.s,v=t(g,i,l*=2,C).minus(w).abs().comparedTo(t(h,n,l,C).minus(w).abs())<1?[g,i]:[h,n],H=c,v},B.toNumber=function(){return+z(this)},B.toPrecision=function(e,r){return null!=e&&m(e,1,g),F(this,e,r,2)},B.toString=function(e){var r,t=this,n=t.s,i=t.e;return null===i?n?(r="Infinity",n<0&&(r="-"+r)):r="NaN":(null==e?r=i<=M||i>=I?y(d(t.c),i):b(d(t.c),i,"0"):10===e?r=b(d((t=Q(new V(t),D+i+1,C)).c),t.e,"0"):(m(e,2,G.length,"Base"),r=T(b(d(t.c),i,"0"),10,e,n,!0)),n<0&&t.c[0]&&(r="-"+r)),r},B.valueOf=B.toJSON=function(){return z(this)},B._isBigNumber=!0,null!=r&&V.set(r),V}()).default=t.BigNumber=t,e.exports?e.exports=t:(r||(r="undefined"!=typeof self&&self?self:window),r.BigNumber=t)}(r)}),I=function(e){for(var r=e.multipliedBy(-1).toString(2);r.length%8;)r="0"+r;var t="1"===r[0]&&-1!==r.slice(1).indexOf("1")?"11111111":"";return r=r.split("").map(function(e){return"0"===e?"1":"0"}).join(""),new M(t+r,2).plus(1)},j=function(e){return"boolean"==typeof e?e?"1":"0":"number"==typeof e?"".concat(e):e};return e.CodePageSize=P,e.ContractDataView=D,e.calculateMinimumCreationFee=function(e){return S(2+C(e)+1)},e.countCodePages=C,e.generateMethodCall=function(e){var r=e.methodArgs?[e.methodHash].concat(B(e.methodArgs)):[e.methodHash];if(r.length>4)throw new Error("At maximum ".concat(3," are supported"));return r.map(j).map(function(e){return function(e){var r=new M(e);r.lt(0)&&(r=I(r));var t=r.toString(16);return t.length%2?"0"+t:t}(e).padStart(16,"0")}).map(E).join("")},e.getContractDatablock=_,e}({}); | ||
var b$contracts=function(e){"use strict";var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function n(e,r){return e(r={exports:{}},r.exports),r.exports}var i=n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertNumberToNQTString=(e=>{if(null==e)throw new Error("Invalid argument");return parseFloat(e.toString()).toFixed(8).replace(".","")})});t(i);i.convertNumberToNQTString;var o=n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertNQTStringToNumber=(e=>{if(null==e||""===e)throw new Error("Invalid argument");return parseFloat(e)/1e8})});t(o);o.convertNQTStringToNumber;var u=n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.GenesisBlockTime=Date.UTC(2014,7,11,2,0,0,0)/1e3,r.initialCodeword=[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],r.gexp=[1,2,4,8,16,5,10,20,13,26,17,7,14,28,29,31,27,19,3,6,12,24,21,15,30,25,23,11,22,9,18,1],r.glog=[0,0,1,18,2,5,19,11,3,29,6,27,20,8,12,23,4,10,30,17,7,22,28,26,21,25,9,16,13,14,24,15],r.cwmap=[3,2,1,0,7,6,5,4,13,14,15,16,12,8,9,10,11],r.alphabet="23456789ABCDEFGHJKLMNPQRSTUVWXYZ".split(""),r.base32Length=13,r.ginv=(e=>r.gexp[31-r.glog[e]]),r.gmult=((e,t)=>{if(0===e||0===t)return 0;const n=(r.glog[e]+r.glog[t])%31;return r.gexp[n]})});t(u);u.GenesisBlockTime,u.initialCodeword,u.gexp,u.glog,u.cwmap,u.alphabet,u.base32Length,u.ginv,u.gmult;var l=n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertNumericIdToAddress=(e=>{if(null==e||0===e.trim().length)return;const r=[],t=u.initialCodeword.slice();let n=0,i=e.length;for(let t=0;t<i;t++)r[t]=e.charCodeAt(t)-"0".charCodeAt(0);let o=0,l=0;do{o=0,l=0;for(let e=0;e<i;e++)(o=10*o+r[e])>=32?(r[l]=o>>5,o&=31,l++):l>0&&(r[l]=0,l++);i=l,t[n]=o,n++}while(i>0);const c=[0,0,0,0];for(let e=u.base32Length-1;e>=0;e--){const r=t[e]^c[3];c[3]=c[2]^u.gmult(30,r),c[2]=c[1]^u.gmult(6,r),c[1]=c[0]^u.gmult(9,r),c[0]=u.gmult(17,r)}t[13]=c[0],t[14]=c[1],t[15]=c[2],t[16]=c[3];let a="BURST-";for(let e=0;e<17;e++)a+=u.alphabet[t[u.cwmap[e]]],3==(3&e)&&e<13&&(a+="-");return a})});t(l);l.convertNumericIdToAddress;var c=n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertBurstTimeToEpochTime=(e=>1e3*(u.GenesisBlockTime+e))});t(c);c.convertBurstTimeToEpochTime;var a=n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertBurstTimeToDate=(e=>new Date(c.convertBurstTimeToEpochTime(e)))});t(a);a.convertBurstTimeToDate;var s=n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertDateToBurstTime=(e=>Math.round(e.getTime()/1e3)-u.GenesisBlockTime)});t(s);s.convertDateToBurstTime;var f=n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.isValid=(e=>{0===e.indexOf("BURST-")&&(e=e.substr(6));const r=u.initialCodeword.slice();let t=0;for(let n=0;n<e.length;n++){const i=u.alphabet.indexOf(e.charAt(n));if(!(i<=-1||i>u.alphabet.length)){if(t>16)return!1;r[u.cwmap[t]]=i,t++}}if(17!==t)return!1;let n=0;for(let e=1;e<5;e++){let t=0;for(let n=0;n<31;n++){if(n>12&&n<27)continue;let i=n;n>26&&(i-=14),t^=u.gmult(r[i],u.gexp[e*n%31])}n|=t}return 0===n}),r.isBurstAddress=(e=>/^BURST\-[A-Z0-9]{4}\-[A-Z0-9]{4}\-[A-Z0-9]{4}\-[A-Z0-9]{5}/i.test(e)&&r.isValid(e))});t(f);f.isValid,f.isBurstAddress;var h=n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertAddressToNumericId=(e=>{if(null==e||0===e.trim().length)return;if(0!==e.indexOf("BURST-"))return;e=e.substr(6);const r=u.initialCodeword.slice();let t=0;for(let n=0;n<e.length;n++){const i=u.alphabet.indexOf(e.charAt(n));if(!(i<=-1||i>u.alphabet.length)){if(t>16)return;r[u.cwmap[t]]=i,t++}}if(!f.isValid(e))return;let n=u.base32Length;const i=[];for(let e=0;e<n;e++)i[e]=r[n-e-1];let o,l="",c=0;do{o=0,c=0;for(let e=0;e<n;e++)(c=32*c+i[e])>=10?(i[o]=Math.floor(c/10),c%=10,o+=1):o>0&&(i[o]=0,o+=1);n=o,l+=c}while(n>0);return l.split("").reverse().join("")})});t(h);h.convertAddressToNumericId;var g=n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.sumNQTStringToNumber=function(...e){return e.reduce((e,r)=>e+o.convertNQTStringToNumber(r),0)}});t(g);g.sumNQTStringToNumber;var p=n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertByteArrayToString=((e,r=0,t=null)=>{if(0===t)return"";let n=e;if(0!==r){const i=null===t?e.length-r:t;!function(e,r,t=0){if(t<0)throw new Error("Start index should not be negative");if(e.length<t+r)throw new Error("Need at least "+r+" bytes to convert to an integer")}(n,i,r),n=e.slice(r,r+i)}return decodeURIComponent(escape(String.fromCharCode.apply(null,Array.from(n))))})});t(p);p.convertByteArrayToString;var d=n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertByteArrayToHexString=((e,r=!1)=>{const t=[];for(let r=0;r<e.length;r++)t.push((e[r]>>>4).toString(16)),t.push((15&e[r]).toString(16));return r?t.join("").toUpperCase():t.join("")})});t(d);d.convertByteArrayToHexString;var v=n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertHexStringToByteArray=(e=>{if(e.length%2)throw new Error(`Invalid Hex String: ${e}`);const r=new Uint8Array(e.length/2);for(let t=0;t<e.length;t+=2){const n=parseInt(e.substr(t,2),16);if(Number.isNaN(n))throw new Error(`Invalid Hex String: ${e}`);r[t/2]=n}return r})});t(v);v.convertHexStringToByteArray;var m=n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertHexStringToDecString=(e=>{const r=[0];let t,n,i;for(t=0;t<e.length;t+=1){for(i=parseInt(e.charAt(t),16),n=0;n<r.length;n+=1)r[n]=16*r[n]+i,i=r[n]/10|0,r[n]%=10;for(;i>0;)r.push(i%10),i=i/10|0}return r.reverse().join("")})});t(m);m.convertHexStringToDecString;var w=n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertHexStringToString=(e=>p.convertByteArrayToString(v.convertHexStringToByteArray(e)))});t(w);w.convertHexStringToString;var y=n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertStringToByteArray=(e=>{const r=unescape(encodeURIComponent(e)),t=new Uint8Array(r.length);for(let e=0;e<r.length;++e)t[e]=r.charCodeAt(e);return t})});t(y);y.convertStringToByteArray;var b=n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertStringToHexString=(e=>d.convertByteArrayToHexString(y.convertStringToByteArray(e)))});t(b);b.convertStringToHexString;var T=n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertHexEndianess=(e=>{let r="";const t=e;for(let e=t.length-1;e>=0;e-=2)r+=t[e-1]+t[e];return r})});t(T);T.convertHexEndianess;var S=n(function(e,r){function t(e){for(var t in e)r.hasOwnProperty(t)||(r[t]=e[t])}Object.defineProperty(r,"__esModule",{value:!0}),t(i),t(o),t(l),t(c),t(a),t(s),t(h),t(f),t(g),t(p),t(d),t(v),t(m),t(w),t(y),t(b),t(T)});t(S);var A=S.convertNumberToNQTString,N=(S.convertNQTStringToNumber,S.convertHexStringToDecString),O=S.convertHexStringToString,_=S.convertHexEndianess;S.convertHexStringToByteArray,S.convertByteArrayToHexString;function E(e,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:16,n=16*r,i=n+t;if(i>e.machineData.length)throw new Error("Insufficient length for variable at position: ".concat(n," (and given length: ").concat(t,")"));if(i%2!=0)throw new Error("Invalid position: ".concat(n," (or given length: ").concat(t,") - must be at least multiple of 2"));return _(e.machineData.substr(n,t))}function x(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function B(e){return function(e){if(Array.isArray(e)){for(var r=0,t=new Array(e.length);r<e.length;r++)t[r]=e[r];return t}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var P=256;function D(e){return Math.ceil(e.length/2/P)}var C=function(){function e(r){!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e),this._contract=r}var r,t,n;return r=e,(t=[{key:"getContract",value:function(){return this._contract}},{key:"countCodePages",value:function(){return D(this._contract.machineCode)}},{key:"getVariableAsString",value:function(r){var t=this.getHexDataAt(r,e.VariableLength);return O(t.replace(/00/g,""))}},{key:"getDataBlocksAsString",value:function(r,t){var n=this.getHexDataAt(r,t*e.VariableLength);return O(n.replace(/00/g,""))}},{key:"getVariableAsDecimal",value:function(e){return N(this.getVariable(e))}},{key:"getVariable",value:function(r){return this.getHexDataAt(r,e.VariableLength)}},{key:"getHexDataAt",value:function(r,t){var n=t||this._contract.machineData.length-e.VariableLength*r;return E(this._contract,r,n)}}])&&x(r.prototype,t),n&&x(r,n),e}();C.VariableLength=16,String.prototype.padStart||(String.prototype.padStart=function(e,r){return e>>=0,r=String(void 0!==r?r:" "),this.length>=e?String(this):((e-=this.length)>r.length&&(r+=r.repeat(e/r.length)),r.slice(0,e)+String(this))});var M=n(function(e){!function(r){var t,n=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,i=Math.ceil,o=Math.floor,u="[BigNumber Error] ",l=u+"Number primitive has more than 15 significant digits: ",c=1e14,a=14,s=9007199254740991,f=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],h=1e7,g=1e9;function p(e){var r=0|e;return e>0||e===r?r:r-1}function d(e){for(var r,t,n=1,i=e.length,o=e[0]+"";n<i;){for(r=e[n++]+"",t=a-r.length;t--;r="0"+r);o+=r}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function v(e,r){var t,n,i=e.c,o=r.c,u=e.s,l=r.s,c=e.e,a=r.e;if(!u||!l)return null;if(t=i&&!i[0],n=o&&!o[0],t||n)return t?n?0:-l:u;if(u!=l)return u;if(t=u<0,n=c==a,!i||!o)return n?0:!i^t?1:-1;if(!n)return c>a^t?1:-1;for(l=(c=i.length)<(a=o.length)?c:a,u=0;u<l;u++)if(i[u]!=o[u])return i[u]>o[u]^t?1:-1;return c==a?0:c>a^t?1:-1}function m(e,r,t,n){if(e<r||e>t||e!==o(e))throw Error(u+(n||"Argument")+("number"==typeof e?e<r||e>t?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function w(e){var r=e.c.length-1;return p(e.e/a)==r&&e.c[r]%2!=0}function y(e,r){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(r<0?"e":"e+")+r}function b(e,r,t){var n,i;if(r<0){for(i=t+".";++r;i+=t);e=i+e}else if(++r>(n=e.length)){for(i=t,r-=n;--r;i+=t);e+=i}else r<n&&(e=e.slice(0,r)+"."+e.slice(r));return e}(t=function e(r){var t,T,S,A,N,O,_,E,x,B=G.prototype={constructor:G,toString:null,valueOf:null},P=new G(1),D=20,C=4,M=-7,j=21,I=-1e7,H=1e7,L=!1,U=1,R=0,k={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},V="0123456789abcdefghijklmnopqrstuvwxyz";function G(e,r){var t,i,u,c,f,h,g,p,d=this;if(!(d instanceof G))return new G(e,r);if(null==r){if(e&&!0===e._isBigNumber)return d.s=e.s,void(!e.c||e.e>H?d.c=d.e=null:e.e<I?d.c=[d.e=0]:(d.e=e.e,d.c=e.c.slice()));if((h="number"==typeof e)&&0*e==0){if(d.s=1/e<0?(e=-e,-1):1,e===~~e){for(c=0,f=e;f>=10;f/=10,c++);return void(c>H?d.c=d.e=null:(d.e=c,d.c=[e]))}p=String(e)}else{if(!n.test(p=String(e)))return S(d,p,h);d.s=45==p.charCodeAt(0)?(p=p.slice(1),-1):1}(c=p.indexOf("."))>-1&&(p=p.replace(".","")),(f=p.search(/e/i))>0?(c<0&&(c=f),c+=+p.slice(f+1),p=p.substring(0,f)):c<0&&(c=p.length)}else{if(m(r,2,V.length,"Base"),10==r)return Q(d=new G(e),D+d.e+1,C);if(p=String(e),h="number"==typeof e){if(0*e!=0)return S(d,p,h,r);if(d.s=1/e<0?(p=p.slice(1),-1):1,G.DEBUG&&p.replace(/^0\.0*|\./,"").length>15)throw Error(l+e)}else d.s=45===p.charCodeAt(0)?(p=p.slice(1),-1):1;for(t=V.slice(0,r),c=f=0,g=p.length;f<g;f++)if(t.indexOf(i=p.charAt(f))<0){if("."==i){if(f>c){c=g;continue}}else if(!u&&(p==p.toUpperCase()&&(p=p.toLowerCase())||p==p.toLowerCase()&&(p=p.toUpperCase()))){u=!0,f=-1,c=0;continue}return S(d,String(e),h,r)}h=!1,(c=(p=T(p,r,10,d.s)).indexOf("."))>-1?p=p.replace(".",""):c=p.length}for(f=0;48===p.charCodeAt(f);f++);for(g=p.length;48===p.charCodeAt(--g););if(p=p.slice(f,++g)){if(g-=f,h&&G.DEBUG&&g>15&&(e>s||e!==o(e)))throw Error(l+d.s*e);if((c=c-f-1)>H)d.c=d.e=null;else if(c<I)d.c=[d.e=0];else{if(d.e=c,d.c=[],f=(c+1)%a,c<0&&(f+=a),f<g){for(f&&d.c.push(+p.slice(0,f)),g-=a;f<g;)d.c.push(+p.slice(f,f+=a));f=a-(p=p.slice(f)).length}else f-=g;for(;f--;p+="0");d.c.push(+p)}}else d.c=[d.e=0]}function F(e,r,t,n){var i,o,u,l,c;if(null==t?t=C:m(t,0,8),!e.c)return e.toString();if(i=e.c[0],u=e.e,null==r)c=d(e.c),c=1==n||2==n&&(u<=M||u>=j)?y(c,u):b(c,u,"0");else if(o=(e=Q(new G(e),r,t)).e,l=(c=d(e.c)).length,1==n||2==n&&(r<=o||o<=M)){for(;l<r;c+="0",l++);c=y(c,o)}else if(r-=u,c=b(c,o,"0"),o+1>l){if(--r>0)for(c+=".";r--;c+="0");}else if((r+=o-l)>0)for(o+1==l&&(c+=".");r--;c+="0");return e.s<0&&i?"-"+c:c}function $(e,r){for(var t,n=1,i=new G(e[0]);n<e.length;n++){if(!(t=new G(e[n])).s){i=t;break}r.call(i,t)&&(i=t)}return i}function q(e,r,t){for(var n=1,i=r.length;!r[--i];r.pop());for(i=r[0];i>=10;i/=10,n++);return(t=n+t*a-1)>H?e.c=e.e=null:t<I?e.c=[e.e=0]:(e.e=t,e.c=r),e}function Q(e,r,t,n){var u,l,s,h,g,p,d,v=e.c,m=f;if(v){e:{for(u=1,h=v[0];h>=10;h/=10,u++);if((l=r-u)<0)l+=a,s=r,d=(g=v[p=0])/m[u-s-1]%10|0;else if((p=i((l+1)/a))>=v.length){if(!n)break e;for(;v.length<=p;v.push(0));g=d=0,u=1,s=(l%=a)-a+1}else{for(g=h=v[p],u=1;h>=10;h/=10,u++);d=(s=(l%=a)-a+u)<0?0:g/m[u-s-1]%10|0}if(n=n||r<0||null!=v[p+1]||(s<0?g:g%m[u-s-1]),n=t<4?(d||n)&&(0==t||t==(e.s<0?3:2)):d>5||5==d&&(4==t||n||6==t&&(l>0?s>0?g/m[u-s]:0:v[p-1])%10&1||t==(e.s<0?8:7)),r<1||!v[0])return v.length=0,n?(r-=e.e+1,v[0]=m[(a-r%a)%a],e.e=-r||0):v[0]=e.e=0,e;if(0==l?(v.length=p,h=1,p--):(v.length=p+1,h=m[a-l],v[p]=s>0?o(g/m[u-s]%m[s])*h:0),n)for(;;){if(0==p){for(l=1,s=v[0];s>=10;s/=10,l++);for(s=v[0]+=h,h=1;s>=10;s/=10,h++);l!=h&&(e.e++,v[0]==c&&(v[0]=1));break}if(v[p]+=h,v[p]!=c)break;v[p--]=0,h=1}for(l=v.length;0===v[--l];v.pop());}e.e>H?e.c=e.e=null:e.e<I&&(e.c=[e.e=0])}return e}function z(e){var r,t=e.e;return null===t?e.toString():(r=d(e.c),r=t<=M||t>=j?y(r,t):b(r,t,"0"),e.s<0?"-"+r:r)}return G.clone=e,G.ROUND_UP=0,G.ROUND_DOWN=1,G.ROUND_CEIL=2,G.ROUND_FLOOR=3,G.ROUND_HALF_UP=4,G.ROUND_HALF_DOWN=5,G.ROUND_HALF_EVEN=6,G.ROUND_HALF_CEIL=7,G.ROUND_HALF_FLOOR=8,G.EUCLID=9,G.config=G.set=function(e){var r,t;if(null!=e){if("object"!=typeof e)throw Error(u+"Object expected: "+e);if(e.hasOwnProperty(r="DECIMAL_PLACES")&&(m(t=e[r],0,g,r),D=t),e.hasOwnProperty(r="ROUNDING_MODE")&&(m(t=e[r],0,8,r),C=t),e.hasOwnProperty(r="EXPONENTIAL_AT")&&((t=e[r])&&t.pop?(m(t[0],-g,0,r),m(t[1],0,g,r),M=t[0],j=t[1]):(m(t,-g,g,r),M=-(j=t<0?-t:t))),e.hasOwnProperty(r="RANGE"))if((t=e[r])&&t.pop)m(t[0],-g,-1,r),m(t[1],1,g,r),I=t[0],H=t[1];else{if(m(t,-g,g,r),!t)throw Error(u+r+" cannot be zero: "+t);I=-(H=t<0?-t:t)}if(e.hasOwnProperty(r="CRYPTO")){if((t=e[r])!==!!t)throw Error(u+r+" not true or false: "+t);if(t){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw L=!t,Error(u+"crypto unavailable");L=t}else L=t}if(e.hasOwnProperty(r="MODULO_MODE")&&(m(t=e[r],0,9,r),U=t),e.hasOwnProperty(r="POW_PRECISION")&&(m(t=e[r],0,g,r),R=t),e.hasOwnProperty(r="FORMAT")){if("object"!=typeof(t=e[r]))throw Error(u+r+" not an object: "+t);k=t}if(e.hasOwnProperty(r="ALPHABET")){if("string"!=typeof(t=e[r])||/^.$|[+-.\s]|(.).*\1/.test(t))throw Error(u+r+" invalid: "+t);V=t}}return{DECIMAL_PLACES:D,ROUNDING_MODE:C,EXPONENTIAL_AT:[M,j],RANGE:[I,H],CRYPTO:L,MODULO_MODE:U,POW_PRECISION:R,FORMAT:k,ALPHABET:V}},G.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!G.DEBUG)return!0;var r,t,n=e.c,i=e.e,l=e.s;e:if("[object Array]"=={}.toString.call(n)){if((1===l||-1===l)&&i>=-g&&i<=g&&i===o(i)){if(0===n[0]){if(0===i&&1===n.length)return!0;break e}if((r=(i+1)%a)<1&&(r+=a),String(n[0]).length==r){for(r=0;r<n.length;r++)if((t=n[r])<0||t>=c||t!==o(t))break e;if(0!==t)return!0}}}else if(null===n&&null===i&&(null===l||1===l||-1===l))return!0;throw Error(u+"Invalid BigNumber: "+e)},G.maximum=G.max=function(){return $(arguments,B.lt)},G.minimum=G.min=function(){return $(arguments,B.gt)},G.random=(A=9007199254740992*Math.random()&2097151?function(){return o(9007199254740992*Math.random())}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var r,t,n,l,c,s=0,h=[],p=new G(P);if(null==e?e=D:m(e,0,g),l=i(e/a),L)if(crypto.getRandomValues){for(r=crypto.getRandomValues(new Uint32Array(l*=2));s<l;)(c=131072*r[s]+(r[s+1]>>>11))>=9e15?(t=crypto.getRandomValues(new Uint32Array(2)),r[s]=t[0],r[s+1]=t[1]):(h.push(c%1e14),s+=2);s=l/2}else{if(!crypto.randomBytes)throw L=!1,Error(u+"crypto unavailable");for(r=crypto.randomBytes(l*=7);s<l;)(c=281474976710656*(31&r[s])+1099511627776*r[s+1]+4294967296*r[s+2]+16777216*r[s+3]+(r[s+4]<<16)+(r[s+5]<<8)+r[s+6])>=9e15?crypto.randomBytes(7).copy(r,s):(h.push(c%1e14),s+=7);s=l/7}if(!L)for(;s<l;)(c=A())<9e15&&(h[s++]=c%1e14);for(l=h[--s],e%=a,l&&e&&(c=f[a-e],h[s]=o(l/c)*c);0===h[s];h.pop(),s--);if(s<0)h=[n=0];else{for(n=-1;0===h[0];h.splice(0,1),n-=a);for(s=1,c=h[0];c>=10;c/=10,s++);s<a&&(n-=a-s)}return p.e=n,p.c=h,p}),G.sum=function(){for(var e=1,r=arguments,t=new G(r[0]);e<r.length;)t=t.plus(r[e++]);return t},T=function(){function e(e,r,t,n){for(var i,o,u=[0],l=0,c=e.length;l<c;){for(o=u.length;o--;u[o]*=r);for(u[0]+=n.indexOf(e.charAt(l++)),i=0;i<u.length;i++)u[i]>t-1&&(null==u[i+1]&&(u[i+1]=0),u[i+1]+=u[i]/t|0,u[i]%=t)}return u.reverse()}return function(r,n,i,o,u){var l,c,a,s,f,h,g,p,v=r.indexOf("."),m=D,w=C;for(v>=0&&(s=R,R=0,r=r.replace(".",""),h=(p=new G(n)).pow(r.length-v),R=s,p.c=e(b(d(h.c),h.e,"0"),10,i,"0123456789"),p.e=p.c.length),a=s=(g=e(r,n,i,u?(l=V,"0123456789"):(l="0123456789",V))).length;0==g[--s];g.pop());if(!g[0])return l.charAt(0);if(v<0?--a:(h.c=g,h.e=a,h.s=o,g=(h=t(h,p,m,w,i)).c,f=h.r,a=h.e),v=g[c=a+m+1],s=i/2,f=f||c<0||null!=g[c+1],f=w<4?(null!=v||f)&&(0==w||w==(h.s<0?3:2)):v>s||v==s&&(4==w||f||6==w&&1&g[c-1]||w==(h.s<0?8:7)),c<1||!g[0])r=f?b(l.charAt(1),-m,l.charAt(0)):l.charAt(0);else{if(g.length=c,f)for(--i;++g[--c]>i;)g[c]=0,c||(++a,g=[1].concat(g));for(s=g.length;!g[--s];);for(v=0,r="";v<=s;r+=l.charAt(g[v++]));r=b(r,a,l.charAt(0))}return r}}(),t=function(){function e(e,r,t){var n,i,o,u,l=0,c=e.length,a=r%h,s=r/h|0;for(e=e.slice();c--;)l=((i=a*(o=e[c]%h)+(n=s*o+(u=e[c]/h|0)*a)%h*h+l)/t|0)+(n/h|0)+s*u,e[c]=i%t;return l&&(e=[l].concat(e)),e}function r(e,r,t,n){var i,o;if(t!=n)o=t>n?1:-1;else for(i=o=0;i<t;i++)if(e[i]!=r[i]){o=e[i]>r[i]?1:-1;break}return o}function t(e,r,t,n){for(var i=0;t--;)e[t]-=i,i=e[t]<r[t]?1:0,e[t]=i*n+e[t]-r[t];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(n,i,u,l,s){var f,h,g,d,v,m,w,y,b,T,S,A,N,O,_,E,x,B=n.s==i.s?1:-1,P=n.c,D=i.c;if(!(P&&P[0]&&D&&D[0]))return new G(n.s&&i.s&&(P?!D||P[0]!=D[0]:D)?P&&0==P[0]||!D?0*B:B/0:NaN);for(b=(y=new G(B)).c=[],B=u+(h=n.e-i.e)+1,s||(s=c,h=p(n.e/a)-p(i.e/a),B=B/a|0),g=0;D[g]==(P[g]||0);g++);if(D[g]>(P[g]||0)&&h--,B<0)b.push(1),d=!0;else{for(O=P.length,E=D.length,g=0,B+=2,(v=o(s/(D[0]+1)))>1&&(D=e(D,v,s),P=e(P,v,s),E=D.length,O=P.length),N=E,S=(T=P.slice(0,E)).length;S<E;T[S++]=0);x=D.slice(),x=[0].concat(x),_=D[0],D[1]>=s/2&&_++;do{if(v=0,(f=r(D,T,E,S))<0){if(A=T[0],E!=S&&(A=A*s+(T[1]||0)),(v=o(A/_))>1)for(v>=s&&(v=s-1),w=(m=e(D,v,s)).length,S=T.length;1==r(m,T,w,S);)v--,t(m,E<w?x:D,w,s),w=m.length,f=1;else 0==v&&(f=v=1),w=(m=D.slice()).length;if(w<S&&(m=[0].concat(m)),t(T,m,S,s),S=T.length,-1==f)for(;r(D,T,E,S)<1;)v++,t(T,E<S?x:D,S,s),S=T.length}else 0===f&&(v++,T=[0]);b[g++]=v,T[0]?T[S++]=P[N]||0:(T=[P[N]],S=1)}while((N++<O||null!=T[0])&&B--);d=null!=T[0],b[0]||b.splice(0,1)}if(s==c){for(g=1,B=b[0];B>=10;B/=10,g++);Q(y,u+(y.e=g+h*a-1)+1,l,d)}else y.e=h,y.r=+d;return y}}(),N=/^(-?)0([xbo])(?=\w[\w.]*$)/i,O=/^([^.]+)\.$/,_=/^\.([^.]+)$/,E=/^-?(Infinity|NaN)$/,x=/^\s*\+(?=[\w.])|^\s+|\s+$/g,S=function(e,r,t,n){var i,o=t?r:r.replace(x,"");if(E.test(o))e.s=isNaN(o)?null:o<0?-1:1;else{if(!t&&(o=o.replace(N,function(e,r,t){return i="x"==(t=t.toLowerCase())?16:"b"==t?2:8,n&&n!=i?e:r}),n&&(i=n,o=o.replace(O,"$1").replace(_,"0.$1")),r!=o))return new G(o,i);if(G.DEBUG)throw Error(u+"Not a"+(n?" base "+n:"")+" number: "+r);e.s=null}e.c=e.e=null},B.absoluteValue=B.abs=function(){var e=new G(this);return e.s<0&&(e.s=1),e},B.comparedTo=function(e,r){return v(this,new G(e,r))},B.decimalPlaces=B.dp=function(e,r){var t,n,i,o=this;if(null!=e)return m(e,0,g),null==r?r=C:m(r,0,8),Q(new G(o),e+o.e+1,r);if(!(t=o.c))return null;if(n=((i=t.length-1)-p(this.e/a))*a,i=t[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},B.dividedBy=B.div=function(e,r){return t(this,new G(e,r),D,C)},B.dividedToIntegerBy=B.idiv=function(e,r){return t(this,new G(e,r),0,1)},B.exponentiatedBy=B.pow=function(e,r){var t,n,l,c,s,f,h,g,p=this;if((e=new G(e)).c&&!e.isInteger())throw Error(u+"Exponent not an integer: "+z(e));if(null!=r&&(r=new G(r)),s=e.e>14,!p.c||!p.c[0]||1==p.c[0]&&!p.e&&1==p.c.length||!e.c||!e.c[0])return g=new G(Math.pow(+z(p),s?2-w(e):+z(e))),r?g.mod(r):g;if(f=e.s<0,r){if(r.c?!r.c[0]:!r.s)return new G(NaN);(n=!f&&p.isInteger()&&r.isInteger())&&(p=p.mod(r))}else{if(e.e>9&&(p.e>0||p.e<-1||(0==p.e?p.c[0]>1||s&&p.c[1]>=24e7:p.c[0]<8e13||s&&p.c[0]<=9999975e7)))return c=p.s<0&&w(e)?-0:0,p.e>-1&&(c=1/c),new G(f?1/c:c);R&&(c=i(R/a+2))}for(s?(t=new G(.5),f&&(e.s=1),h=w(e)):h=(l=Math.abs(+z(e)))%2,g=new G(P);;){if(h){if(!(g=g.times(p)).c)break;c?g.c.length>c&&(g.c.length=c):n&&(g=g.mod(r))}if(l){if(0===(l=o(l/2)))break;h=l%2}else if(Q(e=e.times(t),e.e+1,1),e.e>14)h=w(e);else{if(0==(l=+z(e)))break;h=l%2}p=p.times(p),c?p.c&&p.c.length>c&&(p.c.length=c):n&&(p=p.mod(r))}return n?g:(f&&(g=P.div(g)),r?g.mod(r):c?Q(g,R,C,void 0):g)},B.integerValue=function(e){var r=new G(this);return null==e?e=C:m(e,0,8),Q(r,r.e+1,e)},B.isEqualTo=B.eq=function(e,r){return 0===v(this,new G(e,r))},B.isFinite=function(){return!!this.c},B.isGreaterThan=B.gt=function(e,r){return v(this,new G(e,r))>0},B.isGreaterThanOrEqualTo=B.gte=function(e,r){return 1===(r=v(this,new G(e,r)))||0===r},B.isInteger=function(){return!!this.c&&p(this.e/a)>this.c.length-2},B.isLessThan=B.lt=function(e,r){return v(this,new G(e,r))<0},B.isLessThanOrEqualTo=B.lte=function(e,r){return-1===(r=v(this,new G(e,r)))||0===r},B.isNaN=function(){return!this.s},B.isNegative=function(){return this.s<0},B.isPositive=function(){return this.s>0},B.isZero=function(){return!!this.c&&0==this.c[0]},B.minus=function(e,r){var t,n,i,o,u=this,l=u.s;if(r=(e=new G(e,r)).s,!l||!r)return new G(NaN);if(l!=r)return e.s=-r,u.plus(e);var s=u.e/a,f=e.e/a,h=u.c,g=e.c;if(!s||!f){if(!h||!g)return h?(e.s=-r,e):new G(g?u:NaN);if(!h[0]||!g[0])return g[0]?(e.s=-r,e):new G(h[0]?u:3==C?-0:0)}if(s=p(s),f=p(f),h=h.slice(),l=s-f){for((o=l<0)?(l=-l,i=h):(f=s,i=g),i.reverse(),r=l;r--;i.push(0));i.reverse()}else for(n=(o=(l=h.length)<(r=g.length))?l:r,l=r=0;r<n;r++)if(h[r]!=g[r]){o=h[r]<g[r];break}if(o&&(i=h,h=g,g=i,e.s=-e.s),(r=(n=g.length)-(t=h.length))>0)for(;r--;h[t++]=0);for(r=c-1;n>l;){if(h[--n]<g[n]){for(t=n;t&&!h[--t];h[t]=r);--h[t],h[n]+=c}h[n]-=g[n]}for(;0==h[0];h.splice(0,1),--f);return h[0]?q(e,h,f):(e.s=3==C?-1:1,e.c=[e.e=0],e)},B.modulo=B.mod=function(e,r){var n,i,o=this;return e=new G(e,r),!o.c||!e.s||e.c&&!e.c[0]?new G(NaN):!e.c||o.c&&!o.c[0]?new G(o):(9==U?(i=e.s,e.s=1,n=t(o,e,0,3),e.s=i,n.s*=i):n=t(o,e,0,U),(e=o.minus(n.times(e))).c[0]||1!=U||(e.s=o.s),e)},B.multipliedBy=B.times=function(e,r){var t,n,i,o,u,l,s,f,g,d,v,m,w,y,b,T=this,S=T.c,A=(e=new G(e,r)).c;if(!(S&&A&&S[0]&&A[0]))return!T.s||!e.s||S&&!S[0]&&!A||A&&!A[0]&&!S?e.c=e.e=e.s=null:(e.s*=T.s,S&&A?(e.c=[0],e.e=0):e.c=e.e=null),e;for(n=p(T.e/a)+p(e.e/a),e.s*=T.s,(s=S.length)<(d=A.length)&&(w=S,S=A,A=w,i=s,s=d,d=i),i=s+d,w=[];i--;w.push(0));for(y=c,b=h,i=d;--i>=0;){for(t=0,v=A[i]%b,m=A[i]/b|0,o=i+(u=s);o>i;)t=((f=v*(f=S[--u]%b)+(l=m*f+(g=S[u]/b|0)*v)%b*b+w[o]+t)/y|0)+(l/b|0)+m*g,w[o--]=f%y;w[o]=t}return t?++n:w.splice(0,1),q(e,w,n)},B.negated=function(){var e=new G(this);return e.s=-e.s||null,e},B.plus=function(e,r){var t,n=this,i=n.s;if(r=(e=new G(e,r)).s,!i||!r)return new G(NaN);if(i!=r)return e.s=-r,n.minus(e);var o=n.e/a,u=e.e/a,l=n.c,s=e.c;if(!o||!u){if(!l||!s)return new G(i/0);if(!l[0]||!s[0])return s[0]?e:new G(l[0]?n:0*i)}if(o=p(o),u=p(u),l=l.slice(),i=o-u){for(i>0?(u=o,t=s):(i=-i,t=l),t.reverse();i--;t.push(0));t.reverse()}for((i=l.length)-(r=s.length)<0&&(t=s,s=l,l=t,r=i),i=0;r;)i=(l[--r]=l[r]+s[r]+i)/c|0,l[r]=c===l[r]?0:l[r]%c;return i&&(l=[i].concat(l),++u),q(e,l,u)},B.precision=B.sd=function(e,r){var t,n,i,o=this;if(null!=e&&e!==!!e)return m(e,1,g),null==r?r=C:m(r,0,8),Q(new G(o),e,r);if(!(t=o.c))return null;if(n=(i=t.length-1)*a+1,i=t[i]){for(;i%10==0;i/=10,n--);for(i=t[0];i>=10;i/=10,n++);}return e&&o.e+1>n&&(n=o.e+1),n},B.shiftedBy=function(e){return m(e,-s,s),this.times("1e"+e)},B.squareRoot=B.sqrt=function(){var e,r,n,i,o,u=this,l=u.c,c=u.s,a=u.e,s=D+4,f=new G("0.5");if(1!==c||!l||!l[0])return new G(!c||c<0&&(!l||l[0])?NaN:l?u:1/0);if(0==(c=Math.sqrt(+z(u)))||c==1/0?(((r=d(l)).length+a)%2==0&&(r+="0"),c=Math.sqrt(+r),a=p((a+1)/2)-(a<0||a%2),n=new G(r=c==1/0?"1e"+a:(r=c.toExponential()).slice(0,r.indexOf("e")+1)+a)):n=new G(c+""),n.c[0])for((c=(a=n.e)+s)<3&&(c=0);;)if(o=n,n=f.times(o.plus(t(u,o,s,1))),d(o.c).slice(0,c)===(r=d(n.c)).slice(0,c)){if(n.e<a&&--c,"9999"!=(r=r.slice(c-3,c+1))&&(i||"4999"!=r)){+r&&(+r.slice(1)||"5"!=r.charAt(0))||(Q(n,n.e+D+2,1),e=!n.times(n).eq(u));break}if(!i&&(Q(o,o.e+D+2,0),o.times(o).eq(u))){n=o;break}s+=4,c+=4,i=1}return Q(n,n.e+D+1,C,e)},B.toExponential=function(e,r){return null!=e&&(m(e,0,g),e++),F(this,e,r,1)},B.toFixed=function(e,r){return null!=e&&(m(e,0,g),e=e+this.e+1),F(this,e,r)},B.toFormat=function(e,r,t){var n,i=this;if(null==t)null!=e&&r&&"object"==typeof r?(t=r,r=null):e&&"object"==typeof e?(t=e,e=r=null):t=k;else if("object"!=typeof t)throw Error(u+"Argument not an object: "+t);if(n=i.toFixed(e,r),i.c){var o,l=n.split("."),c=+t.groupSize,a=+t.secondaryGroupSize,s=t.groupSeparator||"",f=l[0],h=l[1],g=i.s<0,p=g?f.slice(1):f,d=p.length;if(a&&(o=c,c=a,a=o,d-=o),c>0&&d>0){for(o=d%c||c,f=p.substr(0,o);o<d;o+=c)f+=s+p.substr(o,c);a>0&&(f+=s+p.slice(o)),g&&(f="-"+f)}n=h?f+(t.decimalSeparator||"")+((a=+t.fractionGroupSize)?h.replace(new RegExp("\\d{"+a+"}\\B","g"),"$&"+(t.fractionGroupSeparator||"")):h):f}return(t.prefix||"")+n+(t.suffix||"")},B.toFraction=function(e){var r,n,i,o,l,c,s,h,g,p,v,m,w=this,y=w.c;if(null!=e&&(!(s=new G(e)).isInteger()&&(s.c||1!==s.s)||s.lt(P)))throw Error(u+"Argument "+(s.isInteger()?"out of range: ":"not an integer: ")+z(s));if(!y)return new G(w);for(r=new G(P),g=n=new G(P),i=h=new G(P),m=d(y),l=r.e=m.length-w.e-1,r.c[0]=f[(c=l%a)<0?a+c:c],e=!e||s.comparedTo(r)>0?l>0?r:g:s,c=H,H=1/0,s=new G(m),h.c[0]=0;p=t(s,r,0,1),1!=(o=n.plus(p.times(i))).comparedTo(e);)n=i,i=o,g=h.plus(p.times(o=g)),h=o,r=s.minus(p.times(o=r)),s=o;return o=t(e.minus(n),i,0,1),h=h.plus(o.times(g)),n=n.plus(o.times(i)),h.s=g.s=w.s,v=t(g,i,l*=2,C).minus(w).abs().comparedTo(t(h,n,l,C).minus(w).abs())<1?[g,i]:[h,n],H=c,v},B.toNumber=function(){return+z(this)},B.toPrecision=function(e,r){return null!=e&&m(e,1,g),F(this,e,r,2)},B.toString=function(e){var r,t=this,n=t.s,i=t.e;return null===i?n?(r="Infinity",n<0&&(r="-"+r)):r="NaN":(null==e?r=i<=M||i>=j?y(d(t.c),i):b(d(t.c),i,"0"):10===e?r=b(d((t=Q(new G(t),D+i+1,C)).c),t.e,"0"):(m(e,2,V.length,"Base"),r=T(b(d(t.c),i,"0"),10,e,n,!0)),n<0&&t.c[0]&&(r="-"+r)),r},B.valueOf=B.toJSON=function(){return z(this)},B._isBigNumber=!0,null!=r&&G.set(r),G}()).default=t.BigNumber=t,e.exports?e.exports=t:(r||(r="undefined"!=typeof self&&self?self:window),r.BigNumber=t)}(r)}),j=function(e){for(var r=e.multipliedBy(-1).toString(2);r.length%8;)r="0"+r;var t="1"===r[0]&&-1!==r.slice(1).indexOf("1")?"11111111":"";return r=r.split("").map(function(e){return"0"===e?"1":"0"}).join(""),new M(t+r,2).plus(1)},I=function(e){return"boolean"==typeof e?e?"1":"0":"number"==typeof e?"".concat(e):e};return e.CodePageSize=P,e.ContractDataView=C,e.calculateMinimumCreationFee=function(e){return A(2+D(e)+1)},e.countCodePages=D,e.generateMethodCall=function(e){var r=e.methodArgs?[e.methodHash].concat(B(e.methodArgs)):[e.methodHash];if(r.length>4)throw new Error("At maximum ".concat(3," are supported"));return r.map(I).map(function(e){return function(e){var r=new M(e);r.lt(0)&&(r=j(r));var t=r.toString(16);return t.length%2?"0"+t:t}(e).padStart(16,"0")}).map(_).join("")},e.getContractDatablock=E,e}({}); | ||
//# sourceMappingURL=burstjs.contracts.min.js.map |
import { Contract } from './typings/contract'; | ||
export declare class ContractDataView { | ||
private _contract; | ||
static VARIABLE_LENGTH: number; | ||
static VariableLength: number; | ||
constructor(_contract: Contract); | ||
@@ -6,0 +6,0 @@ getContract(): Contract; |
@@ -7,1 +7,2 @@ export * from './getContractDatablock'; | ||
export * from './generateMethodCall'; | ||
export * from './typings'; |
@@ -1,2 +0,1 @@ | ||
export * from './generateContractArgs'; | ||
export * from './generateMethodCallArgs'; |
import { Contract } from './typings/contract'; | ||
export declare class ContractDataView { | ||
private _contract; | ||
static VARIABLE_LENGTH: number; | ||
static VariableLength: number; | ||
constructor(_contract: Contract); | ||
@@ -6,0 +6,0 @@ getContract(): Contract; |
@@ -5,3 +5,3 @@ "use strict"; | ||
const getContractDatablock_1 = require("./getContractDatablock"); | ||
const constants_1 = require("./constants"); | ||
const countCodePages_1 = require("./countCodePages"); | ||
class ContractDataView { | ||
@@ -15,10 +15,10 @@ constructor(_contract) { | ||
countCodePages() { | ||
return (this._contract.machineCode.length / 2) / constants_1.CodePageSize; | ||
return countCodePages_1.countCodePages(this._contract.machineCode); | ||
} | ||
getVariableAsString(index) { | ||
const hexData = this.getHexDataAt(index, ContractDataView.VARIABLE_LENGTH); | ||
const hexData = this.getHexDataAt(index, ContractDataView.VariableLength); | ||
return util_1.convertHexStringToString(hexData.replace(/00/g, '')); | ||
} | ||
getDataBlocksAsString(index, count) { | ||
const hexData = this.getHexDataAt(index, count * ContractDataView.VARIABLE_LENGTH); | ||
const hexData = this.getHexDataAt(index, count * ContractDataView.VariableLength); | ||
return util_1.convertHexStringToString(hexData.replace(/00/g, '')); | ||
@@ -30,6 +30,6 @@ } | ||
getVariable(index) { | ||
return this.getHexDataAt(index, ContractDataView.VARIABLE_LENGTH); | ||
return this.getHexDataAt(index, ContractDataView.VariableLength); | ||
} | ||
getHexDataAt(index, length) { | ||
const l = length ? length : this._contract.machineData.length - ContractDataView.VARIABLE_LENGTH * index; | ||
const l = length ? length : this._contract.machineData.length - ContractDataView.VariableLength * index; | ||
return getContractDatablock_1.getContractDatablock(this._contract, index, l); | ||
@@ -39,3 +39,3 @@ } | ||
exports.ContractDataView = ContractDataView; | ||
ContractDataView.VARIABLE_LENGTH = 16; | ||
ContractDataView.VariableLength = 16; | ||
//# sourceMappingURL=ContractDataView.js.map |
@@ -7,1 +7,2 @@ export * from './getContractDatablock'; | ||
export * from './generateMethodCall'; | ||
export * from './typings'; |
@@ -1,2 +0,1 @@ | ||
export * from './generateContractArgs'; | ||
export * from './generateMethodCallArgs'; |
{ | ||
"name": "@burstjs/contracts", | ||
"version": "0.5.0-alpha.3", | ||
"version": "0.5.0-beta.1", | ||
"description": "Smart Contracts package for BURST", | ||
@@ -48,3 +48,3 @@ "contributors": [ | ||
"dependencies": { | ||
"@burstjs/util": "^0.5.0-alpha.3", | ||
"@burstjs/util": "^0.5.0-beta.1", | ||
"bignumber.js": "^9.0.0" | ||
@@ -57,3 +57,3 @@ }, | ||
}, | ||
"gitHead": "92c2c5bf2ce352638613fe27ab1f247552d1b376", | ||
"gitHead": "33d6f8370f2bdac3c4730fdd29331625933aadf9", | ||
"publishConfig": { | ||
@@ -60,0 +60,0 @@ "access": "public" |
587
README.md
@@ -55,3 +55,3 @@ # @burstjs/contracts | ||
<dl> | ||
<dt><a href="#module_http">http</a></dt> | ||
<dt><a href="#module_contracts">contracts</a></dt> | ||
<dd></dd> | ||
@@ -63,334 +63,495 @@ </dl> | ||
<dl> | ||
<dt><a href="#HttpImpl">HttpImpl</a></dt> | ||
<dd><p>Generic Http client</p></dd> | ||
<dt><a href="#ContractDataView">ContractDataView</a></dt> | ||
<dd><p>Helper class for contracts</p> | ||
<p>A contract owns additional data, which is split in 8 byte blocks. | ||
The content is encoded in hexadecimal representation and big endianness. | ||
This class facilitates access to these data</p></dd> | ||
</dl> | ||
<a name="module_http"></a> | ||
<a name="module_contracts"></a> | ||
## http | ||
## contracts | ||
* [http](#module_http) | ||
* [~HttpError](#module_http..HttpError) | ||
* [~HttpMock](#module_http..HttpMock) | ||
* [.onGet(endpoint?)](#module_http..HttpMock.onGet) | ||
* [.onPost(endpoint?)](#module_http..HttpMock.onPost) | ||
* [.onPut(endpoint?)](#module_http..HttpMock.onPut) | ||
* [.onDelete(endpoint?)](#module_http..HttpMock.onDelete) | ||
* [.reset()](#module_http..HttpMock.reset) | ||
* [~HttpResponse](#module_http..HttpResponse) | ||
* [contracts](#module_contracts) | ||
* [~CodePageSize](#module_contracts..CodePageSize) | ||
* [~calculateMinimumCreationFee(hexCode)](#module_contracts..calculateMinimumCreationFee) ⇒ | ||
* [~countCodePages(hexCode)](#module_contracts..countCodePages) ⇒ | ||
* [~numericToHex()](#module_contracts..numericToHex) | ||
* [~generateMethodCall(args)](#module_contracts..generateMethodCall) ⇒ | ||
* [~getContractDatablock(contract, position, length)](#module_contracts..getContractDatablock) ⇒ | ||
<a name="module_http..HttpError"></a> | ||
<a name="module_contracts..CodePageSize"></a> | ||
### http~HttpError | ||
<p>HttpError class</p> | ||
<p>Thrown on HTTP errors</p> | ||
### contracts~CodePageSize | ||
<p>Size of Code Pages in bytes</p> | ||
**Kind**: inner class of [<code>http</code>](#module_http) | ||
<a name="module_http..HttpMock"></a> | ||
**Kind**: inner constant of [<code>contracts</code>](#module_contracts) | ||
<a name="module_contracts..calculateMinimumCreationFee"></a> | ||
### http~HttpMock | ||
<p>Http Mocker for easy to http testing using Jest</p> | ||
<p>When using this mocking helper you need to call <code>Http.onGet()</code> | ||
before Http instance is created</p> | ||
### contracts~calculateMinimumCreationFee(hexCode) ⇒ | ||
<p>Calculates the minimum creation fee of the contract</p> | ||
**Kind**: inner class of [<code>http</code>](#module_http) | ||
**Kind**: inner method of [<code>contracts</code>](#module_contracts) | ||
**Returns**: <p>The minimum fee expressed in Planck</p> | ||
* [~HttpMock](#module_http..HttpMock) | ||
* [.onGet(endpoint?)](#module_http..HttpMock.onGet) | ||
* [.onPost(endpoint?)](#module_http..HttpMock.onPost) | ||
* [.onPut(endpoint?)](#module_http..HttpMock.onPut) | ||
* [.onDelete(endpoint?)](#module_http..HttpMock.onDelete) | ||
* [.reset()](#module_http..HttpMock.reset) | ||
| Param | Description | | ||
| --- | --- | | ||
| hexCode | <p>The contracts code in hex form</p> | | ||
<a name="module_http..HttpMock.onGet"></a> | ||
<a name="module_contracts..countCodePages"></a> | ||
#### HttpMock.onGet(endpoint?) | ||
<p>Mocks responses for get methods | ||
You may pass a specific endpoint as parameter to mock only selected endpoints. | ||
This is very useful, when having methods that do several Http requests, | ||
so you can mock them one on one.</p> | ||
<p>The following code returns the same content on <em>every</em> get call</p> | ||
<pre class="prettyprint source"><code> HttpMock.onGet().reply(200, [{login: 'foo'}, {login: 'bar'}]); | ||
</code></pre> | ||
<p>The next code returns the different content depending on the passed endpoint</p> | ||
<pre class="prettyprint source"><code> HttpMock.onGet('/foo').reply(200, {data: 'foo'}); | ||
HttpMock.onGet('/bar').reply(200, {data: 'bar'}); | ||
</code></pre> | ||
### contracts~countCodePages(hexCode) ⇒ | ||
<p>Counts the code pages for given machine code</p> | ||
**Kind**: static method of [<code>HttpMock</code>](#module_http..HttpMock) | ||
**Kind**: inner method of [<code>contracts</code>](#module_contracts) | ||
**Returns**: <p>The number of code pages for the passed code</p> | ||
| Param | Description | | ||
| --- | --- | | ||
| endpoint? | <p>An endpoint, to allow specific behavior on that endpoint</p> | | ||
| hexCode | <p>The contracts code in hex form</p> | | ||
<a name="module_http..HttpMock.onPost"></a> | ||
<a name="module_contracts..numericToHex"></a> | ||
#### HttpMock.onPost(endpoint?) | ||
<p>Mocks responses for post methods</p> | ||
### contracts~numericToHex() | ||
<p>Copyright (c) 2019 Burst Apps Team</p> | ||
<p>Credits to AJ ONeal for the two-complements stuff | ||
https://coolaj86.com/articles/convert-decimal-to-hex-with-js-bigints/</p> | ||
**Kind**: static method of [<code>HttpMock</code>](#module_http..HttpMock) | ||
**Kind**: inner method of [<code>contracts</code>](#module_contracts) | ||
<a name="module_contracts..generateMethodCall"></a> | ||
### contracts~generateMethodCall(args) ⇒ | ||
<p>Generates a method call message of a contracts public method. The message can be sent using for example | ||
[[MessageApi.sendMessage]] with <code>messageIsText = false</code> or [[ContractApi.callMethod]]]</p> | ||
**Kind**: inner method of [<code>contracts</code>](#module_contracts) | ||
**Returns**: <p>A hex string that can be used as contracts transaction message</p> | ||
| Param | Description | | ||
| --- | --- | | ||
| endpoint? | <p>An endpoint, to allow specific behavior on that endpoint</p> | | ||
| args | <p>The argument object</p> | | ||
<a name="module_http..HttpMock.onPut"></a> | ||
<a name="module_contracts..getContractDatablock"></a> | ||
#### HttpMock.onPut(endpoint?) | ||
<p>Mocks responses for put methods</p> | ||
### contracts~getContractDatablock(contract, position, length) ⇒ | ||
<p>Extracts a variables value as hexadecimal string from a contract's machine data</p> | ||
<p>This is a generic function to extract arbitrary data from a contract. It's recommended to use the [[ContractDataView]] class instead</p> | ||
**Kind**: static method of [<code>HttpMock</code>](#module_http..HttpMock) | ||
**Kind**: inner method of [<code>contracts</code>](#module_contracts) | ||
**Returns**: <p>The value as hexadecimal string (already considering endianness)</p> | ||
| Param | Default | Description | | ||
| --- | --- | --- | | ||
| contract | | <p>The contract</p> | | ||
| position | | <p>The variables position</p> | | ||
| length | <code>16</code> | <p>The length of data to be extracted</p> | | ||
<a name="module_contracts"></a> | ||
## contracts | ||
* [contracts](#module_contracts) | ||
* [~CodePageSize](#module_contracts..CodePageSize) | ||
* [~calculateMinimumCreationFee(hexCode)](#module_contracts..calculateMinimumCreationFee) ⇒ | ||
* [~countCodePages(hexCode)](#module_contracts..countCodePages) ⇒ | ||
* [~numericToHex()](#module_contracts..numericToHex) | ||
* [~generateMethodCall(args)](#module_contracts..generateMethodCall) ⇒ | ||
* [~getContractDatablock(contract, position, length)](#module_contracts..getContractDatablock) ⇒ | ||
<a name="module_contracts..CodePageSize"></a> | ||
### contracts~CodePageSize | ||
<p>Size of Code Pages in bytes</p> | ||
**Kind**: inner constant of [<code>contracts</code>](#module_contracts) | ||
<a name="module_contracts..calculateMinimumCreationFee"></a> | ||
### contracts~calculateMinimumCreationFee(hexCode) ⇒ | ||
<p>Calculates the minimum creation fee of the contract</p> | ||
**Kind**: inner method of [<code>contracts</code>](#module_contracts) | ||
**Returns**: <p>The minimum fee expressed in Planck</p> | ||
| Param | Description | | ||
| --- | --- | | ||
| endpoint? | <p>An endpoint, to allow specific behavior on that endpoint</p> | | ||
| hexCode | <p>The contracts code in hex form</p> | | ||
<a name="module_http..HttpMock.onDelete"></a> | ||
<a name="module_contracts..countCodePages"></a> | ||
#### HttpMock.onDelete(endpoint?) | ||
<p>Mocks responses for delete methods</p> | ||
### contracts~countCodePages(hexCode) ⇒ | ||
<p>Counts the code pages for given machine code</p> | ||
**Kind**: static method of [<code>HttpMock</code>](#module_http..HttpMock) | ||
**Kind**: inner method of [<code>contracts</code>](#module_contracts) | ||
**Returns**: <p>The number of code pages for the passed code</p> | ||
| Param | Description | | ||
| --- | --- | | ||
| endpoint? | <p>An endpoint, to allow specific behavior on that endpoint</p> | | ||
| hexCode | <p>The contracts code in hex form</p> | | ||
<a name="module_http..HttpMock.reset"></a> | ||
<a name="module_contracts..numericToHex"></a> | ||
#### HttpMock.reset() | ||
<p>Resets all mocked behavior</p> | ||
### contracts~numericToHex() | ||
<p>Copyright (c) 2019 Burst Apps Team</p> | ||
<p>Credits to AJ ONeal for the two-complements stuff | ||
https://coolaj86.com/articles/convert-decimal-to-hex-with-js-bigints/</p> | ||
**Kind**: static method of [<code>HttpMock</code>](#module_http..HttpMock) | ||
<a name="module_http..HttpResponse"></a> | ||
**Kind**: inner method of [<code>contracts</code>](#module_contracts) | ||
<a name="module_contracts..generateMethodCall"></a> | ||
### http~HttpResponse | ||
<p>Http Response</p> | ||
<p>Returned by Http request</p> | ||
### contracts~generateMethodCall(args) ⇒ | ||
<p>Generates a method call message of a contracts public method. The message can be sent using for example | ||
[[MessageApi.sendMessage]] with <code>messageIsText = false</code> or [[ContractApi.callMethod]]]</p> | ||
**Kind**: inner class of [<code>http</code>](#module_http) | ||
<a name="module_http"></a> | ||
**Kind**: inner method of [<code>contracts</code>](#module_contracts) | ||
**Returns**: <p>A hex string that can be used as contracts transaction message</p> | ||
## http | ||
| Param | Description | | ||
| --- | --- | | ||
| args | <p>The argument object</p> | | ||
* [http](#module_http) | ||
* [~HttpError](#module_http..HttpError) | ||
* [~HttpMock](#module_http..HttpMock) | ||
* [.onGet(endpoint?)](#module_http..HttpMock.onGet) | ||
* [.onPost(endpoint?)](#module_http..HttpMock.onPost) | ||
* [.onPut(endpoint?)](#module_http..HttpMock.onPut) | ||
* [.onDelete(endpoint?)](#module_http..HttpMock.onDelete) | ||
* [.reset()](#module_http..HttpMock.reset) | ||
* [~HttpResponse](#module_http..HttpResponse) | ||
<a name="module_contracts..getContractDatablock"></a> | ||
<a name="module_http..HttpError"></a> | ||
### contracts~getContractDatablock(contract, position, length) ⇒ | ||
<p>Extracts a variables value as hexadecimal string from a contract's machine data</p> | ||
<p>This is a generic function to extract arbitrary data from a contract. It's recommended to use the [[ContractDataView]] class instead</p> | ||
### http~HttpError | ||
<p>HttpError class</p> | ||
<p>Thrown on HTTP errors</p> | ||
**Kind**: inner method of [<code>contracts</code>](#module_contracts) | ||
**Returns**: <p>The value as hexadecimal string (already considering endianness)</p> | ||
**Kind**: inner class of [<code>http</code>](#module_http) | ||
<a name="module_http..HttpMock"></a> | ||
| Param | Default | Description | | ||
| --- | --- | --- | | ||
| contract | | <p>The contract</p> | | ||
| position | | <p>The variables position</p> | | ||
| length | <code>16</code> | <p>The length of data to be extracted</p> | | ||
### http~HttpMock | ||
<p>Http Mocker for easy to http testing using Jest</p> | ||
<p>When using this mocking helper you need to call <code>Http.onGet()</code> | ||
before Http instance is created</p> | ||
<a name="module_contracts"></a> | ||
**Kind**: inner class of [<code>http</code>](#module_http) | ||
## contracts | ||
* [~HttpMock](#module_http..HttpMock) | ||
* [.onGet(endpoint?)](#module_http..HttpMock.onGet) | ||
* [.onPost(endpoint?)](#module_http..HttpMock.onPost) | ||
* [.onPut(endpoint?)](#module_http..HttpMock.onPut) | ||
* [.onDelete(endpoint?)](#module_http..HttpMock.onDelete) | ||
* [.reset()](#module_http..HttpMock.reset) | ||
* [contracts](#module_contracts) | ||
* [~CodePageSize](#module_contracts..CodePageSize) | ||
* [~calculateMinimumCreationFee(hexCode)](#module_contracts..calculateMinimumCreationFee) ⇒ | ||
* [~countCodePages(hexCode)](#module_contracts..countCodePages) ⇒ | ||
* [~numericToHex()](#module_contracts..numericToHex) | ||
* [~generateMethodCall(args)](#module_contracts..generateMethodCall) ⇒ | ||
* [~getContractDatablock(contract, position, length)](#module_contracts..getContractDatablock) ⇒ | ||
<a name="module_http..HttpMock.onGet"></a> | ||
<a name="module_contracts..CodePageSize"></a> | ||
#### HttpMock.onGet(endpoint?) | ||
<p>Mocks responses for get methods | ||
You may pass a specific endpoint as parameter to mock only selected endpoints. | ||
This is very useful, when having methods that do several Http requests, | ||
so you can mock them one on one.</p> | ||
<p>The following code returns the same content on <em>every</em> get call</p> | ||
<pre class="prettyprint source"><code> HttpMock.onGet().reply(200, [{login: 'foo'}, {login: 'bar'}]); | ||
</code></pre> | ||
<p>The next code returns the different content depending on the passed endpoint</p> | ||
<pre class="prettyprint source"><code> HttpMock.onGet('/foo').reply(200, {data: 'foo'}); | ||
HttpMock.onGet('/bar').reply(200, {data: 'bar'}); | ||
</code></pre> | ||
### contracts~CodePageSize | ||
<p>Size of Code Pages in bytes</p> | ||
**Kind**: static method of [<code>HttpMock</code>](#module_http..HttpMock) | ||
**Kind**: inner constant of [<code>contracts</code>](#module_contracts) | ||
<a name="module_contracts..calculateMinimumCreationFee"></a> | ||
### contracts~calculateMinimumCreationFee(hexCode) ⇒ | ||
<p>Calculates the minimum creation fee of the contract</p> | ||
**Kind**: inner method of [<code>contracts</code>](#module_contracts) | ||
**Returns**: <p>The minimum fee expressed in Planck</p> | ||
| Param | Description | | ||
| --- | --- | | ||
| endpoint? | <p>An endpoint, to allow specific behavior on that endpoint</p> | | ||
| hexCode | <p>The contracts code in hex form</p> | | ||
<a name="module_http..HttpMock.onPost"></a> | ||
<a name="module_contracts..countCodePages"></a> | ||
#### HttpMock.onPost(endpoint?) | ||
<p>Mocks responses for post methods</p> | ||
### contracts~countCodePages(hexCode) ⇒ | ||
<p>Counts the code pages for given machine code</p> | ||
**Kind**: static method of [<code>HttpMock</code>](#module_http..HttpMock) | ||
**Kind**: inner method of [<code>contracts</code>](#module_contracts) | ||
**Returns**: <p>The number of code pages for the passed code</p> | ||
| Param | Description | | ||
| --- | --- | | ||
| endpoint? | <p>An endpoint, to allow specific behavior on that endpoint</p> | | ||
| hexCode | <p>The contracts code in hex form</p> | | ||
<a name="module_http..HttpMock.onPut"></a> | ||
<a name="module_contracts..numericToHex"></a> | ||
#### HttpMock.onPut(endpoint?) | ||
<p>Mocks responses for put methods</p> | ||
### contracts~numericToHex() | ||
<p>Copyright (c) 2019 Burst Apps Team</p> | ||
<p>Credits to AJ ONeal for the two-complements stuff | ||
https://coolaj86.com/articles/convert-decimal-to-hex-with-js-bigints/</p> | ||
**Kind**: static method of [<code>HttpMock</code>](#module_http..HttpMock) | ||
**Kind**: inner method of [<code>contracts</code>](#module_contracts) | ||
<a name="module_contracts..generateMethodCall"></a> | ||
### contracts~generateMethodCall(args) ⇒ | ||
<p>Generates a method call message of a contracts public method. The message can be sent using for example | ||
[[MessageApi.sendMessage]] with <code>messageIsText = false</code> or [[ContractApi.callMethod]]]</p> | ||
**Kind**: inner method of [<code>contracts</code>](#module_contracts) | ||
**Returns**: <p>A hex string that can be used as contracts transaction message</p> | ||
| Param | Description | | ||
| --- | --- | | ||
| endpoint? | <p>An endpoint, to allow specific behavior on that endpoint</p> | | ||
| args | <p>The argument object</p> | | ||
<a name="module_http..HttpMock.onDelete"></a> | ||
<a name="module_contracts..getContractDatablock"></a> | ||
#### HttpMock.onDelete(endpoint?) | ||
<p>Mocks responses for delete methods</p> | ||
### contracts~getContractDatablock(contract, position, length) ⇒ | ||
<p>Extracts a variables value as hexadecimal string from a contract's machine data</p> | ||
<p>This is a generic function to extract arbitrary data from a contract. It's recommended to use the [[ContractDataView]] class instead</p> | ||
**Kind**: static method of [<code>HttpMock</code>](#module_http..HttpMock) | ||
**Kind**: inner method of [<code>contracts</code>](#module_contracts) | ||
**Returns**: <p>The value as hexadecimal string (already considering endianness)</p> | ||
| Param | Default | Description | | ||
| --- | --- | --- | | ||
| contract | | <p>The contract</p> | | ||
| position | | <p>The variables position</p> | | ||
| length | <code>16</code> | <p>The length of data to be extracted</p> | | ||
<a name="module_contracts"></a> | ||
## contracts | ||
* [contracts](#module_contracts) | ||
* [~CodePageSize](#module_contracts..CodePageSize) | ||
* [~calculateMinimumCreationFee(hexCode)](#module_contracts..calculateMinimumCreationFee) ⇒ | ||
* [~countCodePages(hexCode)](#module_contracts..countCodePages) ⇒ | ||
* [~numericToHex()](#module_contracts..numericToHex) | ||
* [~generateMethodCall(args)](#module_contracts..generateMethodCall) ⇒ | ||
* [~getContractDatablock(contract, position, length)](#module_contracts..getContractDatablock) ⇒ | ||
<a name="module_contracts..CodePageSize"></a> | ||
### contracts~CodePageSize | ||
<p>Size of Code Pages in bytes</p> | ||
**Kind**: inner constant of [<code>contracts</code>](#module_contracts) | ||
<a name="module_contracts..calculateMinimumCreationFee"></a> | ||
### contracts~calculateMinimumCreationFee(hexCode) ⇒ | ||
<p>Calculates the minimum creation fee of the contract</p> | ||
**Kind**: inner method of [<code>contracts</code>](#module_contracts) | ||
**Returns**: <p>The minimum fee expressed in Planck</p> | ||
| Param | Description | | ||
| --- | --- | | ||
| endpoint? | <p>An endpoint, to allow specific behavior on that endpoint</p> | | ||
| hexCode | <p>The contracts code in hex form</p> | | ||
<a name="module_http..HttpMock.reset"></a> | ||
<a name="module_contracts..countCodePages"></a> | ||
#### HttpMock.reset() | ||
<p>Resets all mocked behavior</p> | ||
### contracts~countCodePages(hexCode) ⇒ | ||
<p>Counts the code pages for given machine code</p> | ||
**Kind**: static method of [<code>HttpMock</code>](#module_http..HttpMock) | ||
<a name="module_http..HttpResponse"></a> | ||
**Kind**: inner method of [<code>contracts</code>](#module_contracts) | ||
**Returns**: <p>The number of code pages for the passed code</p> | ||
### http~HttpResponse | ||
<p>Http Response</p> | ||
<p>Returned by Http request</p> | ||
| Param | Description | | ||
| --- | --- | | ||
| hexCode | <p>The contracts code in hex form</p> | | ||
**Kind**: inner class of [<code>http</code>](#module_http) | ||
<a name="module_http"></a> | ||
<a name="module_contracts..numericToHex"></a> | ||
## http | ||
### contracts~numericToHex() | ||
<p>Copyright (c) 2019 Burst Apps Team</p> | ||
<p>Credits to AJ ONeal for the two-complements stuff | ||
https://coolaj86.com/articles/convert-decimal-to-hex-with-js-bigints/</p> | ||
* [http](#module_http) | ||
* [~HttpError](#module_http..HttpError) | ||
* [~HttpMock](#module_http..HttpMock) | ||
* [.onGet(endpoint?)](#module_http..HttpMock.onGet) | ||
* [.onPost(endpoint?)](#module_http..HttpMock.onPost) | ||
* [.onPut(endpoint?)](#module_http..HttpMock.onPut) | ||
* [.onDelete(endpoint?)](#module_http..HttpMock.onDelete) | ||
* [.reset()](#module_http..HttpMock.reset) | ||
* [~HttpResponse](#module_http..HttpResponse) | ||
**Kind**: inner method of [<code>contracts</code>](#module_contracts) | ||
<a name="module_contracts..generateMethodCall"></a> | ||
<a name="module_http..HttpError"></a> | ||
### contracts~generateMethodCall(args) ⇒ | ||
<p>Generates a method call message of a contracts public method. The message can be sent using for example | ||
[[MessageApi.sendMessage]] with <code>messageIsText = false</code> or [[ContractApi.callMethod]]]</p> | ||
### http~HttpError | ||
<p>HttpError class</p> | ||
<p>Thrown on HTTP errors</p> | ||
**Kind**: inner method of [<code>contracts</code>](#module_contracts) | ||
**Returns**: <p>A hex string that can be used as contracts transaction message</p> | ||
**Kind**: inner class of [<code>http</code>](#module_http) | ||
<a name="module_http..HttpMock"></a> | ||
| Param | Description | | ||
| --- | --- | | ||
| args | <p>The argument object</p> | | ||
### http~HttpMock | ||
<p>Http Mocker for easy to http testing using Jest</p> | ||
<p>When using this mocking helper you need to call <code>Http.onGet()</code> | ||
before Http instance is created</p> | ||
<a name="module_contracts..getContractDatablock"></a> | ||
**Kind**: inner class of [<code>http</code>](#module_http) | ||
### contracts~getContractDatablock(contract, position, length) ⇒ | ||
<p>Extracts a variables value as hexadecimal string from a contract's machine data</p> | ||
<p>This is a generic function to extract arbitrary data from a contract. It's recommended to use the [[ContractDataView]] class instead</p> | ||
* [~HttpMock](#module_http..HttpMock) | ||
* [.onGet(endpoint?)](#module_http..HttpMock.onGet) | ||
* [.onPost(endpoint?)](#module_http..HttpMock.onPost) | ||
* [.onPut(endpoint?)](#module_http..HttpMock.onPut) | ||
* [.onDelete(endpoint?)](#module_http..HttpMock.onDelete) | ||
* [.reset()](#module_http..HttpMock.reset) | ||
**Kind**: inner method of [<code>contracts</code>](#module_contracts) | ||
**Returns**: <p>The value as hexadecimal string (already considering endianness)</p> | ||
<a name="module_http..HttpMock.onGet"></a> | ||
| Param | Default | Description | | ||
| --- | --- | --- | | ||
| contract | | <p>The contract</p> | | ||
| position | | <p>The variables position</p> | | ||
| length | <code>16</code> | <p>The length of data to be extracted</p> | | ||
#### HttpMock.onGet(endpoint?) | ||
<p>Mocks responses for get methods | ||
You may pass a specific endpoint as parameter to mock only selected endpoints. | ||
This is very useful, when having methods that do several Http requests, | ||
so you can mock them one on one.</p> | ||
<p>The following code returns the same content on <em>every</em> get call</p> | ||
<pre class="prettyprint source"><code> HttpMock.onGet().reply(200, [{login: 'foo'}, {login: 'bar'}]); | ||
</code></pre> | ||
<p>The next code returns the different content depending on the passed endpoint</p> | ||
<pre class="prettyprint source"><code> HttpMock.onGet('/foo').reply(200, {data: 'foo'}); | ||
HttpMock.onGet('/bar').reply(200, {data: 'bar'}); | ||
</code></pre> | ||
<a name="module_contracts"></a> | ||
**Kind**: static method of [<code>HttpMock</code>](#module_http..HttpMock) | ||
## contracts | ||
* [contracts](#module_contracts) | ||
* [~CodePageSize](#module_contracts..CodePageSize) | ||
* [~calculateMinimumCreationFee(hexCode)](#module_contracts..calculateMinimumCreationFee) ⇒ | ||
* [~countCodePages(hexCode)](#module_contracts..countCodePages) ⇒ | ||
* [~numericToHex()](#module_contracts..numericToHex) | ||
* [~generateMethodCall(args)](#module_contracts..generateMethodCall) ⇒ | ||
* [~getContractDatablock(contract, position, length)](#module_contracts..getContractDatablock) ⇒ | ||
<a name="module_contracts..CodePageSize"></a> | ||
### contracts~CodePageSize | ||
<p>Size of Code Pages in bytes</p> | ||
**Kind**: inner constant of [<code>contracts</code>](#module_contracts) | ||
<a name="module_contracts..calculateMinimumCreationFee"></a> | ||
### contracts~calculateMinimumCreationFee(hexCode) ⇒ | ||
<p>Calculates the minimum creation fee of the contract</p> | ||
**Kind**: inner method of [<code>contracts</code>](#module_contracts) | ||
**Returns**: <p>The minimum fee expressed in Planck</p> | ||
| Param | Description | | ||
| --- | --- | | ||
| endpoint? | <p>An endpoint, to allow specific behavior on that endpoint</p> | | ||
| hexCode | <p>The contracts code in hex form</p> | | ||
<a name="module_http..HttpMock.onPost"></a> | ||
<a name="module_contracts..countCodePages"></a> | ||
#### HttpMock.onPost(endpoint?) | ||
<p>Mocks responses for post methods</p> | ||
### contracts~countCodePages(hexCode) ⇒ | ||
<p>Counts the code pages for given machine code</p> | ||
**Kind**: static method of [<code>HttpMock</code>](#module_http..HttpMock) | ||
**Kind**: inner method of [<code>contracts</code>](#module_contracts) | ||
**Returns**: <p>The number of code pages for the passed code</p> | ||
| Param | Description | | ||
| --- | --- | | ||
| endpoint? | <p>An endpoint, to allow specific behavior on that endpoint</p> | | ||
| hexCode | <p>The contracts code in hex form</p> | | ||
<a name="module_http..HttpMock.onPut"></a> | ||
<a name="module_contracts..numericToHex"></a> | ||
#### HttpMock.onPut(endpoint?) | ||
<p>Mocks responses for put methods</p> | ||
### contracts~numericToHex() | ||
<p>Copyright (c) 2019 Burst Apps Team</p> | ||
<p>Credits to AJ ONeal for the two-complements stuff | ||
https://coolaj86.com/articles/convert-decimal-to-hex-with-js-bigints/</p> | ||
**Kind**: static method of [<code>HttpMock</code>](#module_http..HttpMock) | ||
**Kind**: inner method of [<code>contracts</code>](#module_contracts) | ||
<a name="module_contracts..generateMethodCall"></a> | ||
### contracts~generateMethodCall(args) ⇒ | ||
<p>Generates a method call message of a contracts public method. The message can be sent using for example | ||
[[MessageApi.sendMessage]] with <code>messageIsText = false</code> or [[ContractApi.callMethod]]]</p> | ||
**Kind**: inner method of [<code>contracts</code>](#module_contracts) | ||
**Returns**: <p>A hex string that can be used as contracts transaction message</p> | ||
| Param | Description | | ||
| --- | --- | | ||
| endpoint? | <p>An endpoint, to allow specific behavior on that endpoint</p> | | ||
| args | <p>The argument object</p> | | ||
<a name="module_http..HttpMock.onDelete"></a> | ||
<a name="module_contracts..getContractDatablock"></a> | ||
#### HttpMock.onDelete(endpoint?) | ||
<p>Mocks responses for delete methods</p> | ||
### contracts~getContractDatablock(contract, position, length) ⇒ | ||
<p>Extracts a variables value as hexadecimal string from a contract's machine data</p> | ||
<p>This is a generic function to extract arbitrary data from a contract. It's recommended to use the [[ContractDataView]] class instead</p> | ||
**Kind**: static method of [<code>HttpMock</code>](#module_http..HttpMock) | ||
**Kind**: inner method of [<code>contracts</code>](#module_contracts) | ||
**Returns**: <p>The value as hexadecimal string (already considering endianness)</p> | ||
| Param | Default | Description | | ||
| --- | --- | --- | | ||
| contract | | <p>The contract</p> | | ||
| position | | <p>The variables position</p> | | ||
| length | <code>16</code> | <p>The length of data to be extracted</p> | | ||
<a name="ContractDataView"></a> | ||
## ContractDataView | ||
<p>Helper class for contracts</p> | ||
<p>A contract owns additional data, which is split in 8 byte blocks. | ||
The content is encoded in hexadecimal representation and big endianness. | ||
This class facilitates access to these data</p> | ||
**Kind**: global class | ||
* [ContractDataView](#ContractDataView) | ||
* [new ContractDataView()](#new_ContractDataView_new) | ||
* [.getContract()](#ContractDataView+getContract) ⇒ | ||
* [.countCodePages()](#ContractDataView+countCodePages) ⇒ | ||
* [.getVariableAsString(index)](#ContractDataView+getVariableAsString) ⇒ | ||
* [.getDataBlocksAsString(index, count)](#ContractDataView+getDataBlocksAsString) ⇒ | ||
* [.getVariableAsDecimal(index)](#ContractDataView+getVariableAsDecimal) ⇒ | ||
* [.getVariable(index)](#ContractDataView+getVariable) ⇒ | ||
* [.getHexDataAt(index, length)](#ContractDataView+getHexDataAt) ⇒ | ||
<a name="new_ContractDataView_new"></a> | ||
### new ContractDataView() | ||
<p>The length of a contracts variable (considering Hex notation)</p> | ||
<a name="ContractDataView+getContract"></a> | ||
### contractDataView.getContract() ⇒ | ||
**Kind**: instance method of [<code>ContractDataView</code>](#ContractDataView) | ||
**Returns**: <p>Get the contract</p> | ||
<a name="ContractDataView+countCodePages"></a> | ||
### contractDataView.countCodePages() ⇒ | ||
**Kind**: instance method of [<code>ContractDataView</code>](#ContractDataView) | ||
**Returns**: <p>The number of code pages</p> | ||
<a name="ContractDataView+getVariableAsString"></a> | ||
### contractDataView.getVariableAsString(index) ⇒ | ||
<p>Get a variable as string</p> | ||
**Kind**: instance method of [<code>ContractDataView</code>](#ContractDataView) | ||
**Returns**: <p>The data as string (Utf-8)</p> | ||
| Param | Description | | ||
| --- | --- | | ||
| endpoint? | <p>An endpoint, to allow specific behavior on that endpoint</p> | | ||
| index | <p>The index of variable (starting at 0)</p> | | ||
<a name="module_http..HttpMock.reset"></a> | ||
<a name="ContractDataView+getDataBlocksAsString"></a> | ||
#### HttpMock.reset() | ||
<p>Resets all mocked behavior</p> | ||
### contractDataView.getDataBlocksAsString(index, count) ⇒ | ||
<p>Get multiple data blocks as string</p> | ||
**Kind**: static method of [<code>HttpMock</code>](#module_http..HttpMock) | ||
<a name="module_http..HttpResponse"></a> | ||
**Kind**: instance method of [<code>ContractDataView</code>](#ContractDataView) | ||
**Returns**: <p>The data as string (Utf-8)</p> | ||
### http~HttpResponse | ||
<p>Http Response</p> | ||
<p>Returned by Http request</p> | ||
| Param | Description | | ||
| --- | --- | | ||
| index | <p>The index of variable (starting at 0)</p> | | ||
| count | <p>Number of blocks</p> | | ||
**Kind**: inner class of [<code>http</code>](#module_http) | ||
<a name="HttpImpl"></a> | ||
<a name="ContractDataView+getVariableAsDecimal"></a> | ||
## HttpImpl | ||
<p>Generic Http client</p> | ||
### contractDataView.getVariableAsDecimal(index) ⇒ | ||
<p>Get a variable as decimal (string)</p> | ||
**Kind**: global class | ||
<a name="new_HttpImpl_new"></a> | ||
**Kind**: instance method of [<code>ContractDataView</code>](#ContractDataView) | ||
**Returns**: <p>The data as a decimal string sequence</p> | ||
### new HttpImpl(baseURL, options) | ||
<p>Creates your Http client</p> | ||
| Param | Description | | ||
| --- | --- | | ||
| index | <p>The index of variable (starting at 0)</p> | | ||
<a name="ContractDataView+getVariable"></a> | ||
### contractDataView.getVariable(index) ⇒ | ||
<p>Get a variable at given position/index</p> | ||
**Kind**: instance method of [<code>ContractDataView</code>](#ContractDataView) | ||
**Returns**: <p>The data as hexadecimal string (in little endianness)</p> | ||
| Param | Description | | ||
| --- | --- | | ||
| baseURL | <p>The baseUrl, i.e host url</p> | | ||
| options | <p>[optional] An options/configurations object applied to all requests The current implementation uses axios, so the options can be found here <a href="https://github.com/axios/axios#request-config">Axios Configuration</a></p> | | ||
| index | <p>The index of variable (starting at 0)</p> | | ||
<a name="ContractDataView+getHexDataAt"></a> | ||
### contractDataView.getHexDataAt(index, length) ⇒ | ||
<p>Get a hexadecimal data block of arbitrary length at given position/index</p> | ||
**Kind**: instance method of [<code>ContractDataView</code>](#ContractDataView) | ||
**Returns**: <p>The data as hexadecimal string (in little endianness)</p> | ||
| Param | Description | | ||
| --- | --- | | ||
| index | <p>The index of variable (starting at 0)</p> | | ||
| length | <p>The length of the data block (must be a multiple of 2)</p> | | ||
@@ -20,10 +20,2 @@ import {generateMethodCall} from '../generateMethodCall'; | ||
}); | ||
it('generates a method call with three arguments', () => { | ||
const message = generateMethodCall({ | ||
methodHash: ContractMethodHash, | ||
methodArgs: [true, 1234, '1234567890'], | ||
}); | ||
expect(message).toBe('17f898a0f498d0900100000000000000d204000000000000d202964900000000'); | ||
}); | ||
}); |
@@ -11,2 +11,3 @@ /** @module contracts */ | ||
import {CodePageSize} from './constants'; | ||
import {countCodePages} from './countCodePages'; | ||
@@ -22,3 +23,6 @@ /** | ||
public static VARIABLE_LENGTH = 16; | ||
/** | ||
* The length of a contracts variable (considering Hex notation) | ||
*/ | ||
public static VariableLength = 16; | ||
@@ -39,3 +43,3 @@ constructor(private _contract: Contract) { | ||
countCodePages() { | ||
return (this._contract.machineCode.length / 2) / CodePageSize | ||
return countCodePages(this._contract.machineCode); | ||
} | ||
@@ -49,3 +53,3 @@ | ||
public getVariableAsString(index: number): string { | ||
const hexData = this.getHexDataAt(index, ContractDataView.VARIABLE_LENGTH); | ||
const hexData = this.getHexDataAt(index, ContractDataView.VariableLength); | ||
return convertHexStringToString(hexData.replace(/00/g, '')); | ||
@@ -61,3 +65,3 @@ } | ||
public getDataBlocksAsString(index: number, count?: number): string { | ||
const hexData = this.getHexDataAt(index, count * ContractDataView.VARIABLE_LENGTH); | ||
const hexData = this.getHexDataAt(index, count * ContractDataView.VariableLength); | ||
return convertHexStringToString(hexData.replace(/00/g, '')); | ||
@@ -81,3 +85,3 @@ } | ||
public getVariable(index: number): string { | ||
return this.getHexDataAt(index, ContractDataView.VARIABLE_LENGTH); | ||
return this.getHexDataAt(index, ContractDataView.VariableLength); | ||
} | ||
@@ -92,3 +96,3 @@ | ||
public getHexDataAt(index: number, length?: number): string { | ||
const l = length ? length : this._contract.machineData.length - ContractDataView.VARIABLE_LENGTH * index; | ||
const l = length ? length : this._contract.machineData.length - ContractDataView.VariableLength * index; | ||
return getContractDatablock(this._contract, index, l); | ||
@@ -95,0 +99,0 @@ } |
@@ -49,3 +49,3 @@ /** @module contracts */ | ||
* Generates a method call message of a contracts public method. The message can be sent using for example | ||
* [[MessageApi.sendMessage]] with `messageIsText = false` or [[ContractApi.callMethod]]] | ||
* [[MessageApi.sendMessage]] with `messageIsText = false` or [[ContractApi.callContractMethod]]] | ||
* @param args The argument object | ||
@@ -52,0 +52,0 @@ * @return A hex string that can be used as contracts transaction message |
@@ -8,1 +8,2 @@ /** @module contracts */ | ||
export * from './generateMethodCall'; | ||
export * from './typings'; |
@@ -7,4 +7,3 @@ /** @module contracts */ | ||
export * from './generateContractArgs'; | ||
export * from './generateMethodCallArgs'; | ||
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
556
392666
76
3805
Updated@burstjs/util@^0.5.0-beta.1