@protonprotocol/protonjs
Advanced tools
Comparing version 21.0.18 to 21.0.19
@@ -1,2 +0,2 @@ | ||
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=require("pako"),r=require("hash.js"),n=t(require("ripemd-ts")),i=t(require("bs58")),a=require("elliptic");function o(t,e,r,n,i,a,o){try{var s=t[a](o),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function s(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var a=t.apply(e,r);function s(t){o(a,n,i,s,u,"next",t)}function u(t){o(a,n,i,s,u,"throw",t)}s(void 0)}))}}function u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function c(t,e){return(c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function f(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function h(t,e,r){return(h=f()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var i=new(Function.bind.apply(t,n));return r&&c(i,r.prototype),i}).apply(null,arguments)}function p(t){var e="function"==typeof Map?new Map:void 0;return(p=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return h(t,arguments,u(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),c(r,t)})(t)}function l(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function d(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function y(t,e){var r;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return d(t,void 0);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?d(t,void 0):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=t[Symbol.iterator]()).next.bind(r)}var v,g,b=(function(t){var e=function(t){var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",o=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var i=Object.create((e&&e.prototype instanceof h?e:h).prototype),a=new A(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(i,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw a;return{value:void 0,done:!0}}for(r.method=i,r.arg=a;;){var o=r.delegate;if(o){var s=w(o,r);if(s){if(s===f)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=c(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function c(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var f={};function h(){}function p(){}function l(){}var d={};d[i]=function(){return this};var y=Object.getPrototypeOf,v=y&&y(y(k([])));v&&v!==e&&r.call(v,i)&&(d=v);var g=l.prototype=h.prototype=Object.create(d);function b(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function m(t,e){var n;this._invoke=function(i,a){function o(){return new e((function(n,o){!function n(i,a,o,s){var u=c(t[i],t,a);if("throw"!==u.type){var f=u.arg,h=f.value;return h&&"object"==typeof h&&r.call(h,"__await")?e.resolve(h.__await).then((function(t){n("next",t,o,s)}),(function(t){n("throw",t,o,s)})):e.resolve(h).then((function(t){f.value=t,o(f)}),(function(t){return n("throw",t,o,s)}))}s(u.arg)}(i,a,n,o)}))}return n=n?n.then(o,o):o()}}function w(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return f;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=c(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,f;var i=n.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function _(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(_,this),this.reset(!0)}function k(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,a=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return a.next=a}}return{next:z}}function z(){return{value:void 0,done:!0}}return p.prototype=g.constructor=l,l.constructor=p,p.displayName=s(l,o,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,s(t,o,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},b(m.prototype),m.prototype[a]=function(){return this},t.AsyncIterator=m,t.async=function(e,r,n,i,a){void 0===a&&(a=Promise);var o=new m(u(e,r,n,i),a);return t.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},b(g),s(g,o,"Generator"),g[i]=function(){return this},g.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=k,A.prototype={constructor:A,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return o.type="throw",o.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],o=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var s=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=t,o.arg=e,a?(this.method="next",this.next=a.finallyLoc,f):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),x(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;x(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:k(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}(g={exports:{}}),g.exports),m=n.hash,w="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",_="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",x=function(){for(var t=Array(256).fill(-1),e=0;e<w.length;++e)t[w.charCodeAt(e)]=e;return t}(),A=function(){for(var t=Array(256).fill(-1),e=0;e<_.length;++e)t[_.charCodeAt(e)]=e;return t["=".charCodeAt(0)]=0,t}(),k=function(t){return 0!=(128&t[t.length-1])},z=function(t){for(var e=1,r=0;r<t.length;++r){var n=(255&~t[r])+e;t[r]=n,e=n>>8}},E=function(t,e){for(var r=new Uint8Array(t),n=0;n<e.length;++n){var i=e.charCodeAt(n);if(i<"0".charCodeAt(0)||i>"9".charCodeAt(0))throw new Error("invalid number");for(var a=i-"0".charCodeAt(0),o=0;o<t;++o){var s=10*r[o]+a;r[o]=s,a=s>>8}if(a)throw new Error("number is out of range")}return r},S=function(t,e){var r="-"===e[0];r&&(e=e.substr(1));var n=E(t,e);if(r){if(z(n),!k(n))throw new Error("number is out of range")}else if(k(n))throw new Error("number is out of range");return n},U=function(t,e){void 0===e&&(e=1);for(var r=Array(e).fill("0".charCodeAt(0)),n=t.length-1;n>=0;--n){for(var i=t[n],a=0;a<r.length;++a){var o=(r[a]-"0".charCodeAt(0)<<8)+i;r[a]="0".charCodeAt(0)+o%10,i=o/10|0}for(;i;)r.push("0".charCodeAt(0)+i%10),i=i/10|0}return r.reverse(),String.fromCharCode.apply(String,r)},T=function(t,e){if(void 0===e&&(e=1),k(t)){var r=t.slice();return z(r),"-"+U(r,e)}return U(t,e)},P=function(t,e){if(!t)return function(t){for(var e=[],r=0;r<t.length;++r){var n=x[t.charCodeAt(r)];if(n<0)throw new Error("invalid base-58 value");for(var i=0;i<e.length;++i){var a=58*e[i]+n;e[i]=255&a,n=a>>8}n&&e.push(n)}for(var o,s=y(t);!(o=s()).done&&"1"===o.value;)e.push(0);return e.reverse(),new Uint8Array(e)}(e);for(var r=new Uint8Array(t),n=0;n<e.length;++n){var i=x[e.charCodeAt(n)];if(i<0)throw new Error("invalid base-58 value");for(var a=0;a<t;++a){var o=58*r[a]+i;r[a]=o,i=o>>8}if(i)throw new Error("base-58 value is out of range")}return r.reverse(),r},C=function(t){for(var e,r=[],n=y(t);!(e=n()).done;){for(var i=e.value,a=0;a<r.length;++a){var o=(x[r[a]]<<8)+i;r[a]=w.charCodeAt(o%58),i=o/58|0}for(;i;)r.push(w.charCodeAt(i%58)),i=i/58|0}for(var s,u=y(t);!(s=u()).done&&!s.value;)r.push("1".charCodeAt(0));return r.reverse(),String.fromCharCode.apply(String,r)},O=function(t){var e=t.length;if(1==(3&e)&&"="===t[e-1]&&(e-=1),0!=(3&e))throw new Error("base-64 value is not padded correctly");var r=e>>2,n=3*r;e>0&&"="===t[e-1]&&(n-="="===t[e-2]?2:1);for(var i=new Uint8Array(n),a=0;a<r;++a){var o=A[t.charCodeAt(4*a+0)],s=A[t.charCodeAt(4*a+1)],u=A[t.charCodeAt(4*a+2)],c=A[t.charCodeAt(4*a+3)];i[3*a+0]=o<<2|s>>4,3*a+1<n&&(i[3*a+1]=(15&s)<<4|u>>2),3*a+2<n&&(i[3*a+2]=(3&u)<<6|c)}return i};!function(t){t[t.k1=0]="k1",t[t.r1=1]="r1",t[t.wa=2]="wa"}(v||(v={}));var K=function(t,e){for(var r=new Uint8Array(t.length+e.length),n=0;n<t.length;++n)r[n]=t[n];for(var i=0;i<e.length;++i)r[t.length+i]=e.charCodeAt(i);return m(r)},N=function(t,e,r,n){var i=P(r?r+4:0,t),a={type:e,data:new Uint8Array(i.buffer,0,i.length-4)},o=new Uint8Array(K(a.data,n));if(o[0]!==i[i.length-4]||o[1]!==i[i.length-3]||o[2]!==i[i.length-2]||o[3]!==i[i.length-1])throw new Error("checksum doesn't match");return a},B=function(t,e,r){for(var n=new Uint8Array(K(t.data,e)),i=new Uint8Array(t.data.length+4),a=0;a<t.data.length;++a)i[a]=t.data[a];for(var o=0;o<4;++o)i[o+t.data.length]=n[o];return r+C(i)},j=function(t,e){if(void 0===e&&(e="EOS"),"string"!=typeof t)throw new Error("expected string containing public key");if(t.substr(0,3)===e){for(var r=P(37,t.substr(3)),n={type:v.k1,data:new Uint8Array(33)},i=0;i<33;++i)n.data[i]=r[i];var a=new Uint8Array(m(n.data));if(a[0]!==r[33]||a[1]!==r[34]||a[2]!==r[35]||a[3]!==r[36])throw new Error("checksum doesn't match");return n}if("PUB_K1_"===t.substr(0,7))return N(t.substr(7),v.k1,33,"K1");if("PUB_R1_"===t.substr(0,7))return N(t.substr(7),v.r1,33,"R1");if("PUB_WA_"===t.substr(0,7))return N(t.substr(7),v.wa,0,"WA");throw new Error("unrecognized public key format")},R=function(t,e){if(void 0===e&&(e="EOS"),t.type===v.k1&&33===t.data.length)return B(t,"",e);throw t.type===v.r1||t.type===v.wa?new Error("Key format not supported in legacy conversion"):new Error("unrecognized public key format")},D=function(t){if(t.type===v.k1&&33===t.data.length)return B(t,"K1","PUB_K1_");if(t.type===v.r1&&33===t.data.length)return B(t,"R1","PUB_R1_");if(t.type===v.wa)return B(t,"WA","PUB_WA_");throw new Error("unrecognized public key format")},F=function(t,e){return void 0===e&&(e="EOS"),t.substr(0,3)===e?D(j(t,e)):t},L=function(t,e){return void 0===e&&(e="EOS"),t.map((function(t){return F(t,e)}))},I=function(t){if("string"!=typeof t)throw new Error("expected string containing private key");if("PVT_R1_"===t.substr(0,7))return N(t.substr(7),v.r1,32,"R1");if("PVT_K1_"===t.substr(0,7))return N(t.substr(7),v.k1,32,"K1");var e=P(37,t),r={type:v.k1,data:new Uint8Array(32)};if(128!==e[0])throw new Error("unrecognized private key type");for(var n=0;n<32;++n)r.data[n]=e[n+1];return r},V=function(t){if(t.type===v.k1&&32===t.data.length){var e=[];e.push(128),t.data.forEach((function(t){return e.push(t)}));for(var n=new Uint8Array(r.sha256().update(r.sha256().update(e).digest()).digest()),i=new Uint8Array(37),a=0;a<e.length;a++)i[a]=e[a];for(var o=0;o<4;o++)i[o+e.length]=n[o];return C(i)}throw t.type===v.r1||t.type===v.wa?new Error("Key format not supported in legacy conversion"):new Error("unrecognized public key format")},q=function(t){if(t.type===v.r1)return B(t,"R1","PVT_R1_");if(t.type===v.k1)return B(t,"K1","PVT_K1_");throw new Error("unrecognized private key format")},M=function(t){if("string"!=typeof t)throw new Error("expected string containing signature");if("SIG_K1_"===t.substr(0,7))return N(t.substr(7),v.k1,65,"K1");if("SIG_R1_"===t.substr(0,7))return N(t.substr(7),v.r1,65,"R1");if("SIG_WA_"===t.substr(0,7))return N(t.substr(7),v.wa,0,"WA");throw new Error("unrecognized signature format")},G=function(t){if(t.type===v.k1)return B(t,"K1","SIG_K1_");if(t.type===v.r1)return B(t,"R1","SIG_R1_");if(t.type===v.wa)return B(t,"WA","SIG_WA_");throw new Error("unrecognized signature format")},W={__proto__:null,isNegative:k,negate:z,decimalToBinary:E,signedDecimalToBinary:S,binaryToDecimal:U,signedBinaryToDecimal:T,base58ToBinary:P,binaryToBase58:C,base64ToBinary:O,get KeyType(){return v},publicKeyDataSize:33,privateKeyDataSize:32,signatureDataSize:65,stringToPublicKey:j,publicKeyToLegacyString:R,publicKeyToString:D,convertLegacyPublicKey:F,convertK1ToLegacyPublicKey:function(t,e){if(void 0===e&&(e="EOS"),"PUB_K1_"!==t.substr(0,"PUB_K1_".length))return t;var r=t.substr("PUB_K1_".length),n=i.decode(r),a=n.slice(0,n.length-4),o=Buffer.from(m(a)).slice(0,4),s=Buffer.from([].concat(a,o));return""+e+i.encode(s)},convertLegacyPublicKeys:L,stringToPrivateKey:I,privateKeyToLegacyString:V,privateKeyToString:q,stringToSignature:M,signatureToString:G},H=function(t){void 0===t&&(t={}),this.skippedBinaryExtension=!1,this.options=t},Y=function(){function t(t){var e=(void 0===t?{}:t).array;this.readPos=0,this.textEncoder=new TextEncoder,this.textDecoder=new TextDecoder("utf-8",{fatal:!0}),this.array=e||new Uint8Array(1024),this.length=e?e.length:0}var e=t.prototype;return e.reserve=function(t){if(!(this.length+t<=this.array.length)){for(var e=this.array.length;this.length+t>e;)e=Math.ceil(1.5*e);var r=new Uint8Array(e);r.set(this.array),this.array=r}},e.haveReadData=function(){return this.readPos<this.length},e.restartRead=function(){this.readPos=0},e.asUint8Array=function(){return new Uint8Array(this.array.buffer,this.array.byteOffset,this.length)},e.pushArray=function(t){this.reserve(t.length),this.array.set(t,this.length),this.length+=t.length},e.push=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];this.pushArray(e)},e.get=function(){if(this.readPos<this.length)return this.array[this.readPos++];throw new Error("Read past end of buffer")},e.pushUint8ArrayChecked=function(t,e){if(t.length!==e)throw new Error("Binary data has incorrect size");this.pushArray(t)},e.getUint8Array=function(t){if(this.readPos+t>this.length)throw new Error("Read past end of buffer");var e=new Uint8Array(this.array.buffer,this.array.byteOffset+this.readPos,t);return this.readPos+=t,e},e.skip=function(t){if(this.readPos+t>this.length)throw new Error("Read past end of buffer");this.readPos+=t},e.pushUint16=function(t){this.push(t>>0&255,t>>8&255)},e.getUint16=function(){var t=0;return(t|=this.get()<<0)|this.get()<<8},e.pushUint32=function(t){this.push(t>>0&255,t>>8&255,t>>16&255,t>>24&255)},e.getUint32=function(){var t=0;return t|=this.get()<<0,t|=this.get()<<8,t|=this.get()<<16,(t|=this.get()<<24)>>>0},e.pushNumberAsUint64=function(t){this.pushUint32(t>>>0),this.pushUint32(Math.floor(t/4294967296)>>>0)},e.getUint64AsNumber=function(){var t=this.getUint32();return 4294967296*(this.getUint32()>>>0)+(t>>>0)},e.pushVaruint32=function(t){for(;;){if(!(t>>>7)){this.push(t);break}this.push(128|127&t),t>>>=7}},e.getVaruint32=function(){for(var t=0,e=0;;){var r=this.get();if(t|=(127&r)<<e,e+=7,!(128&r))break}return t>>>0},e.pushVarint32=function(t){this.pushVaruint32(t<<1^t>>31)},e.getVarint32=function(){var t=this.getVaruint32();return 1&t?~t>>1|2147483648:t>>>1},e.pushFloat32=function(t){this.pushArray(new Uint8Array(new Float32Array([t]).buffer))},e.getFloat32=function(){return new Float32Array(this.getUint8Array(4).slice().buffer)[0]},e.pushFloat64=function(t){this.pushArray(new Uint8Array(new Float64Array([t]).buffer))},e.getFloat64=function(){return new Float64Array(this.getUint8Array(8).slice().buffer)[0]},e.pushName=function(t){if("string"!=typeof t)throw new Error("Expected string containing name");if(""!==t&&!new RegExp(/^[.1-5a-z]{1,12}[.1-5a-j]?$/).test(t))throw new Error("Name should be less than 13 characters, or less than 14 if last character is between 1-5 or a-j, and only contain the following symbols .12345abcdefghijklmnopqrstuvwxyz");for(var e=function(t){return t>="a".charCodeAt(0)&&t<="z".charCodeAt(0)?t-"a".charCodeAt(0)+6:t>="1".charCodeAt(0)&&t<="5".charCodeAt(0)?t-"1".charCodeAt(0)+1:0},r=new Uint8Array(8),n=63,i=0;i<t.length;++i){var a=e(t.charCodeAt(i));n<5&&(a<<=1);for(var o=4;o>=0;--o)n>=0&&(r[Math.floor(n/8)]|=(a>>o&1)<<n%8,--n)}this.pushArray(r)},e.getName=function(){for(var t=this.getUint8Array(8),e="",r=63;r>=0;){for(var n=0,i=0;i<5;++i)r>=0&&(n=n<<1|t[Math.floor(r/8)]>>r%8&1,--r);e+=n>=6?String.fromCharCode(n+"a".charCodeAt(0)-6):n>=1?String.fromCharCode(n+"1".charCodeAt(0)-1):"."}for(;e.endsWith(".");)e=e.substr(0,e.length-1);return e},e.pushBytes=function(t){this.pushVaruint32(t.length),this.pushArray(t)},e.getBytes=function(){return this.getUint8Array(this.getVaruint32())},e.pushString=function(t){this.pushBytes(this.textEncoder.encode(t))},e.getString=function(){return this.textDecoder.decode(this.getBytes())},e.pushSymbolCode=function(t){if("string"!=typeof t)throw new Error("Expected string containing symbol_code");var e=[];for(e.push.apply(e,this.textEncoder.encode(t));e.length<8;)e.push(0);this.pushArray(e.slice(0,8))},e.getSymbolCode=function(){var t,e=this.getUint8Array(8);for(t=0;t<e.length&&e[t];++t);return this.textDecoder.decode(new Uint8Array(e.buffer,e.byteOffset,t))},e.pushSymbol=function(t){var e=t.name,r=t.precision;if(!/^[A-Z]{1,7}$/.test(e))throw new Error("Expected symbol to be A-Z and between one and seven characters");var n=[255&r];for(n.push.apply(n,this.textEncoder.encode(e));n.length<8;)n.push(0);this.pushArray(n.slice(0,8))},e.getSymbol=function(){var t,e=this.get(),r=this.getUint8Array(7);for(t=0;t<r.length&&r[t];++t);return{name:this.textDecoder.decode(new Uint8Array(r.buffer,r.byteOffset,t)),precision:e}},e.pushAsset=function(t){if("string"!=typeof t)throw new Error("Expected string containing asset");var e=0,r="",n=0;"-"===(t=t.trim())[e]&&(r+="-",++e);for(var i=!1;e<t.length&&t.charCodeAt(e)>="0".charCodeAt(0)&&t.charCodeAt(e)<="9".charCodeAt(0);)i=!0,r+=t[e],++e;if(!i)throw new Error("Asset must begin with a number");if("."===t[e])for(++e;e<t.length&&t.charCodeAt(e)>="0".charCodeAt(0)&&t.charCodeAt(e)<="9".charCodeAt(0);)r+=t[e],++n,++e;var a=t.substr(e).trim();this.pushArray(S(8,r)),this.pushSymbol({name:a,precision:n})},e.getAsset=function(){var t=this.getUint8Array(8),e=this.getSymbol(),r=e.name,n=e.precision,i=T(t,n+1);return n&&(i=i.substr(0,i.length-n)+"."+i.substr(i.length-n)),i+" "+r},e.pushPublicKey=function(t){var e=j(t);this.push(e.type),this.pushArray(e.data)},e.getPublicKey=function(){var t,e=this.get();if(e===v.wa){var r=this.readPos;this.skip(34),this.skip(this.getVaruint32()),t=new Uint8Array(this.array.buffer,this.array.byteOffset+r,this.readPos-r)}else t=this.getUint8Array(33);return D({type:e,data:t})},e.pushPrivateKey=function(t){var e=I(t);this.push(e.type),this.pushArray(e.data)},e.getPrivateKey=function(){var t=this.get(),e=this.getUint8Array(32);return q({type:t,data:e})},e.pushSignature=function(t){var e=M(t);this.push(e.type),this.pushArray(e.data)},e.getSignature=function(){var t,e=this.get();if(e===v.wa){var r=this.readPos;this.skip(65),this.skip(this.getVaruint32()),this.skip(this.getVaruint32()),t=new Uint8Array(this.array.buffer,this.array.byteOffset+r,this.readPos-r)}else t=this.getUint8Array(65);return G({type:e,data:t})},t}(),Z=function(t){return t.startsWith("eosio::abi/1.")},J=function(t){var e=Date.parse(t);if(Number.isNaN(e))throw new Error("Invalid time format");return e},$=function(t){return Math.round(1e3*J(t+"Z"))},X=function(t){var e=new Date(t/1e3).toISOString();return e.substr(0,e.length-1)},Q=function(t){return Math.round(J(t+"Z")/1e3)},tt=function(t){var e=new Date(1e3*t).toISOString();return e.substr(0,e.length-1)},et=function(t){return Math.round((J(t+"Z")-9466848e5)/500)},rt=function(t){var e=new Date(500*t+9466848e5).toISOString();return e.substr(0,e.length-1)},nt=function(t){if("string"!=typeof t)throw new Error("Expected string containing symbol");var e=t.match(/^([0-9]+),([A-Z]+)$/);if(!e)throw new Error("Invalid symbol");return{name:e[2],precision:+e[1]}},it=function(t){return t.precision+","+t.name},at=function(t){for(var e,r="",n=y(t);!(e=n()).done;)r+=("00"+e.value.toString(16)).slice(-2);return r.toUpperCase()},ot=function(t){if("string"!=typeof t)throw new Error("Expected string containing hex digits");if(t.length%2)throw new Error("Odd number of hex digits");for(var e=t.length/2,r=new Uint8Array(e),n=0;n<e;++n){var i=parseInt(t.substr(2*n,2),16);if(Number.isNaN(i))throw new Error("Expected hex string");r[n]=i}return r};function st(t,e){throw new Error("Don't know how to serialize "+this.name)}function ut(t){throw new Error("Don't know how to deserialize "+this.name)}function ct(t,e,r,n){if(void 0===r&&(r=new H),void 0===n&&(n=!0),"object"!=typeof e)throw new Error("expected object containing data: "+JSON.stringify(e));this.base&&this.base.serialize(t,e,r,n);for(var i,a=y(this.fields);!(i=a()).done;){var o=i.value;if(o.name in e){if(r.skippedBinaryExtension)throw new Error("unexpected "+this.name+"."+o.name);o.type.serialize(t,e[o.name],r,n&&o===this.fields[this.fields.length-1])}else{if(!n||!o.type.extensionOf)throw new Error("missing "+this.name+"."+o.name+" (type="+o.type.name+")");r.skippedBinaryExtension=!0}}}function ft(t,e,r){var n;void 0===e&&(e=new H),void 0===r&&(r=!0),n=this.base?this.base.deserialize(t,e,r):{};for(var i,a=y(this.fields);!(i=a()).done;){var o=i.value;r&&o.type.extensionOf&&!t.haveReadData()?e.skippedBinaryExtension=!0:n[o.name]=o.type.deserialize(t,e,r)}return n}function ht(t,e,r,n){if(!Array.isArray(e)||2!==e.length||"string"!=typeof e[0])throw new Error('expected variant: ["type", value]');var i=this.fields.findIndex((function(t){return t.name===e[0]}));if(i<0)throw new Error('type "'+e[0]+'" is not valid for variant');t.pushVaruint32(i),this.fields[i].type.serialize(t,e[1],r,n)}function pt(t,e,r){var n=t.getVaruint32();if(n>=this.fields.length)throw new Error("type index "+n+" is not valid for variant");var i=this.fields[n];return[i.name,i.type.deserialize(t,e,r)]}function lt(t,e,r){t.pushVaruint32(e.length);for(var n,i=y(e);!(n=i()).done;)this.arrayOf.serialize(t,n.value,r,!1)}function dt(t,e){for(var r=t.getVaruint32(),n=[],i=0;i<r;++i)n.push(this.arrayOf.deserialize(t,e,!1));return n}function yt(t,e,r,n){null==e?t.push(0):(t.push(1),this.optionalOf.serialize(t,e,r,n))}function vt(t,e,r){return t.get()?this.optionalOf.deserialize(t,e,r):null}function gt(t,e,r,n){this.extensionOf.serialize(t,e,r,n)}function bt(t,e,r){return this.extensionOf.deserialize(t,e,r)}var mt=function(t){return Object.assign({name:"<missing name>",aliasOfName:"",arrayOf:void 0,optionalOf:void 0,extensionOf:void 0,baseName:"",base:void 0,fields:[],serialize:st,deserialize:ut},t)},wt=function(t,e){if(Number.isNaN(+t)||Number.isNaN(+e)||"number"!=typeof t&&"string"!=typeof t)throw new Error("Expected number");if(+t!=+e)throw new Error("Number is out of range");return+t},_t=function(){var t=new Map(Object.entries({bool:mt({name:"bool",serialize:function(t,e){if("boolean"!=typeof e&&("number"!=typeof e||1!==e&&0!==e))throw new Error("Expected boolean or number equal to 1 or 0");t.push(e?1:0)},deserialize:function(t){return!!t.get()}}),uint8:mt({name:"uint8",serialize:function(t,e){t.push(wt(e,255&e))},deserialize:function(t){return t.get()}}),int8:mt({name:"int8",serialize:function(t,e){t.push(wt(e,e<<24>>24))},deserialize:function(t){return t.get()<<24>>24}}),uint16:mt({name:"uint16",serialize:function(t,e){t.pushUint16(wt(e,65535&e))},deserialize:function(t){return t.getUint16()}}),int16:mt({name:"int16",serialize:function(t,e){t.pushUint16(wt(e,e<<16>>16))},deserialize:function(t){return t.getUint16()<<16>>16}}),uint32:mt({name:"uint32",serialize:function(t,e){t.pushUint32(wt(e,e>>>0))},deserialize:function(t){return t.getUint32()}}),uint64:mt({name:"uint64",serialize:function(t,e){t.pushArray(E(8,""+e))},deserialize:function(t){return U(t.getUint8Array(8))}}),int64:mt({name:"int64",serialize:function(t,e){t.pushArray(S(8,""+e))},deserialize:function(t){return T(t.getUint8Array(8))}}),int32:mt({name:"int32",serialize:function(t,e){t.pushUint32(wt(e,0|e))},deserialize:function(t){return 0|t.getUint32()}}),varuint32:mt({name:"varuint32",serialize:function(t,e){t.pushVaruint32(wt(e,e>>>0))},deserialize:function(t){return t.getVaruint32()}}),varint32:mt({name:"varint32",serialize:function(t,e){t.pushVarint32(wt(e,0|e))},deserialize:function(t){return t.getVarint32()}}),uint128:mt({name:"uint128",serialize:function(t,e){t.pushArray(E(16,""+e))},deserialize:function(t){return U(t.getUint8Array(16))}}),int128:mt({name:"int128",serialize:function(t,e){t.pushArray(S(16,""+e))},deserialize:function(t){return T(t.getUint8Array(16))}}),float32:mt({name:"float32",serialize:function(t,e){t.pushFloat32(e)},deserialize:function(t){return t.getFloat32()}}),float64:mt({name:"float64",serialize:function(t,e){t.pushFloat64(e)},deserialize:function(t){return t.getFloat64()}}),float128:mt({name:"float128",serialize:function(t,e){t.pushUint8ArrayChecked(ot(e),16)},deserialize:function(t){return at(t.getUint8Array(16))}}),bytes:mt({name:"bytes",serialize:function(t,e){e instanceof Uint8Array||Array.isArray(e)?t.pushBytes(e):t.pushBytes(ot(e))},deserialize:function(t,e){return e&&e.options.bytesAsUint8Array?t.getBytes():at(t.getBytes())}}),string:mt({name:"string",serialize:function(t,e){t.pushString(e)},deserialize:function(t){return t.getString()}}),name:mt({name:"name",serialize:function(t,e){t.pushName(e)},deserialize:function(t){return t.getName()}}),time_point:mt({name:"time_point",serialize:function(t,e){t.pushNumberAsUint64($(e))},deserialize:function(t){return X(t.getUint64AsNumber())}}),time_point_sec:mt({name:"time_point_sec",serialize:function(t,e){t.pushUint32(Q(e))},deserialize:function(t){return tt(t.getUint32())}}),block_timestamp_type:mt({name:"block_timestamp_type",serialize:function(t,e){t.pushUint32(et(e))},deserialize:function(t){return rt(t.getUint32())}}),symbol_code:mt({name:"symbol_code",serialize:function(t,e){t.pushSymbolCode(e)},deserialize:function(t){return t.getSymbolCode()}}),symbol:mt({name:"symbol",serialize:function(t,e){t.pushSymbol(nt(e))},deserialize:function(t){return it(t.getSymbol())}}),asset:mt({name:"asset",serialize:function(t,e){t.pushAsset(e)},deserialize:function(t){return t.getAsset()}}),checksum160:mt({name:"checksum160",serialize:function(t,e){t.pushUint8ArrayChecked(ot(e),20)},deserialize:function(t){return at(t.getUint8Array(20))}}),checksum256:mt({name:"checksum256",serialize:function(t,e){t.pushUint8ArrayChecked(ot(e),32)},deserialize:function(t){return at(t.getUint8Array(32))}}),checksum512:mt({name:"checksum512",serialize:function(t,e){t.pushUint8ArrayChecked(ot(e),64)},deserialize:function(t){return at(t.getUint8Array(64))}}),public_key:mt({name:"public_key",serialize:function(t,e){t.pushPublicKey(e)},deserialize:function(t){return t.getPublicKey()}}),private_key:mt({name:"private_key",serialize:function(t,e){t.pushPrivateKey(e)},deserialize:function(t){return t.getPrivateKey()}}),signature:mt({name:"signature",serialize:function(t,e){t.pushSignature(e)},deserialize:function(t){return t.getSignature()}})}));return t.set("extended_asset",mt({name:"extended_asset",baseName:"",fields:[{name:"quantity",typeName:"asset",type:t.get("asset")},{name:"contract",typeName:"name",type:t.get("name")}],serialize:ct,deserialize:ft})),t},xt=function t(e,r){var n=e.get(r);if(n&&n.aliasOfName)return t(e,n.aliasOfName);if(n)return n;if(r.endsWith("[]"))return mt({name:r,arrayOf:t(e,r.substr(0,r.length-2)),serialize:lt,deserialize:dt});if(r.endsWith("?"))return mt({name:r,optionalOf:t(e,r.substr(0,r.length-1)),serialize:yt,deserialize:vt});if(r.endsWith("$"))return mt({name:r,extensionOf:t(e,r.substr(0,r.length-1)),serialize:gt,deserialize:bt});throw new Error("Unknown type: "+r)},At=function(t,e){var r=new Map(t);if(e.types)for(var n,i=y(e.types);!(n=i()).done;){var a=n.value,o=a.new_type_name;r.set(o,mt({name:o,aliasOfName:a.type}))}if(e.structs)for(var s,u=y(e.structs);!(s=u()).done;){var c=s.value,f=c.name;r.set(f,mt({name:f,baseName:c.base,fields:c.fields.map((function(t){return{name:t.name,typeName:t.type,type:void 0}})),serialize:ct,deserialize:ft}))}if(e.variants)for(var h,p=y(e.variants);!(h=p()).done;){var l=h.value,d=l.name;r.set(d,mt({name:d,fields:l.types.map((function(t){return{name:t,typeName:t,type:void 0}})),serialize:ht,deserialize:pt}))}for(var v,g=y(r);!(v=g()).done;){var b=v.value[1];b.baseName&&(b.base=xt(r,b.baseName));for(var m,w=y(b.fields);!(m=w()).done;){var _=m.value;_.type=xt(r,_.typeName)}}return r},kt=function(t,e){var r,n=t.header?t.header.timestamp:t.timestamp,i=parseInt((r=t.id.substr(16,8)).substr(6,2)+r.substr(4,2)+r.substr(2,2)+r.substr(0,2),16);return{expiration:tt(Q(n)+e),ref_block_num:65535&t.block_num,ref_block_prefix:i}},zt=function(t,e,r,n){var i=t.actions.get(r);if(!i)throw new Error("Unknown action "+r+" in contract "+e);var a=new Y;return i.serialize(a,n),at(a.asUint8Array())},Et=function(t,e,r,n,i){return{account:e,name:r,authorization:n,data:zt(t,e,r,i)}},St=function(t,e,r,n){var i=t.actions.get(r);if("string"==typeof n&&(n=ot(n)),!i)throw new Error("Unknown action "+r+" in contract "+e);var a=new Y;return a.pushArray(n),i.deserialize(a)},Ut=function(t,e,r,n,i){return{account:e,name:r,authorization:n,data:St(t,e,r,i)}},Tt={__proto__:null,SerializerState:H,SerialBuffer:Y,supportedAbiVersion:Z,dateToTimePoint:$,timePointToDate:X,dateToTimePointSec:Q,timePointSecToDate:tt,dateToBlockTimestamp:et,blockTimestampToDate:rt,stringToSymbol:nt,symbolToString:it,arrayToHex:at,hexToUint8Array:ot,createInitialTypes:_t,getType:xt,getTypesFromAbi:At,transactionHeader:kt,serializeActionData:zt,serializeAction:Et,deserializeActionData:St,deserializeAction:Ut},Pt=require("../src/abi.abi.json"),Ct=require("../src/transaction.abi.json"),Ot=function(){function t(t){this.contracts=new Map,this.cachedAbis=new Map,this.rpc=t.rpc,this.authorityProvider=t.authorityProvider||t.rpc,this.abiProvider=t.abiProvider||t.rpc,this.signatureProvider=t.signatureProvider,this.abiTypes=At(_t(),Pt),this.transactionTypes=At(_t(),Ct)}var r=t.prototype;return r.rawAbiToJson=function(t){var e=new Y({array:t});if(!Z(e.getString()))throw new Error("Unsupported abi version");return e.restartRead(),this.abiTypes.get("abi_def").deserialize(e)},r.jsonToRawAbi=function(t){var e=new Y;if(this.abiTypes.get("abi_def").serialize(e,t),!Z(e.getString()))throw new Error("Unsupported abi version");return e.asUint8Array()},r.getCachedAbi=function(){var t=s(b.mark((function t(e,r){var n,i,a;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0===r&&(r=!1),r||!this.cachedAbis.get(e)){t.next=3;break}return t.abrupt("return",this.cachedAbis.get(e));case 3:return t.prev=3,t.next=6,this.abiProvider.getRawAbi(e);case 6:a=this.rawAbiToJson(i=t.sent.abi),n={rawAbi:i,abi:a},t.next=15;break;case 11:throw t.prev=11,t.t0=t.catch(3),t.t0.message="fetching abi for "+e+": "+t.t0.message,t.t0;case 15:if(n){t.next=17;break}throw new Error("Missing abi for "+e);case 17:return this.cachedAbis.set(e,n),t.abrupt("return",n);case 19:case"end":return t.stop()}}),t,this,[[3,11]])})));return function(e,r){return t.apply(this,arguments)}}(),r.getAbi=function(){var t=s(b.mark((function t(e,r){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===r&&(r=!1),t.next=3,this.getCachedAbi(e,r);case 3:return t.abrupt("return",t.sent.abi);case 4:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.getTransactionAbis=function(){var t=s(b.mark((function t(e,r){var n,i,a,o,u=this;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===r&&(r=!1),n=(e.context_free_actions||[]).concat(e.actions),i=n.map((function(t){return t.account})),a=new Set(i),o=Array.from(a).map(function(){var t=s(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,u.getCachedAbi(e,r);case 2:return t.abrupt("return",{accountName:e,abi:t.sent.rawAbi});case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),t.abrupt("return",Promise.all(o));case 6:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),r.getContract=function(){var t=s(b.mark((function t(e,r){var n,i,a,o,s,u,c;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0===r&&(r=!1),r||!this.contracts.get(e)){t.next=3;break}return t.abrupt("return",this.contracts.get(e));case 3:return t.next=5,this.getAbi(e,r);case 5:for(n=t.sent,i=At(_t(),n),a=new Map,o=y(n.actions);!(s=o()).done;)a.set((u=s.value).name,xt(i,u.type));return this.contracts.set(e,c={types:i,actions:a}),t.abrupt("return",c);case 12:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.serialize=function(t,e,r){this.transactionTypes.get(e).serialize(t,r)},r.deserialize=function(t,e){return this.transactionTypes.get(e).deserialize(t)},r.serializeTransaction=function(t){var e=new Y;return this.serialize(e,"transaction",Object.assign({max_net_usage_words:0,max_cpu_usage_ms:0,delay_sec:0,context_free_actions:[],actions:[],transaction_extensions:[]},t)),e.asUint8Array()},r.serializeContextFreeData=function(t){if(t&&t.length){var e=new Y;e.pushVaruint32(t.length);for(var r,n=y(t);!(r=n()).done;)e.pushBytes(r.value);return e.asUint8Array()}},r.deserializeTransaction=function(t){var e=new Y;return e.pushArray(t),this.deserialize(e,"transaction")},r.serializeActions=function(){var t=s(b.mark((function t(e){var r=this;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Promise.all(e.map(function(){var t=s(b.mark((function t(e){var n,i,a,o;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.account,i=e.name,a=e.authorization,o=e.data,t.next=3,r.getContract(n);case 3:return t.abrupt("return",Et(t.sent,n,i,a,o));case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),r.deserializeActions=function(){var t=s(b.mark((function t(e){var r=this;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Promise.all(e.map(function(){var t=s(b.mark((function t(e){var n,i,a,o;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.account,i=e.name,a=e.authorization,o=e.data,t.next=3,r.getContract(n);case 3:return t.abrupt("return",Ut(t.sent,n,i,a,o));case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),r.deserializeActionsSync=function(){var t=s(b.mark((function t(e){var r,n,i,a,o,s,u,c;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=[],n=y(e);case 2:if((i=n()).done){t.next=10;break}return o=(a=i.value).account,s=a.name,u=a.authorization,c=a.data,t.next=6,this.getContract(o);case 6:r.push(Ut(t.sent,o,s,u,c));case 8:t.next=2;break;case 10:return t.abrupt("return",r);case 11:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.deserializeTransactionWithActions=function(){var t=s(b.mark((function t(e){var r,n;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return"string"==typeof e&&(e=ot(e)),r=this.deserializeTransaction(e),t.next=4,this.deserializeActionsSync(r.context_free_actions);case 4:return n=t.sent,t.next=7,this.deserializeActionsSync(r.actions);case 7:return t.abrupt("return",Object.assign({},r,{context_free_actions:n,actions:t.sent}));case 9:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.deflateSerializedArray=function(t){return e.deflate(t,{level:9})},r.inflateSerializedArray=function(t){return e.inflate(t)},r.transact=function(){var t=s(b.mark((function t(e,r){var n,i,a,o,s,u,c,f,h,p,l,d,y,v,g,m,w,_;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=void 0===(i=(n=void 0===r?{}:r).broadcast)||i,s=void 0===(o=n.sign)||o,u=n.compression,c=n.blocksBehind,f=n.useLastIrreversible,h=n.expireSeconds,p=n.requiredKeys,d=void 0===(l=n.transactionHeader)?void 0:l,t.next=3,this.rpc.get_info();case 3:if(y=t.sent,"number"!=typeof c||!f){t.next=7;break}throw new Error("Use either blocksBehind or useLastIrreversible");case 7:if(d){t.next=15;break}if("number"!=typeof c&&!f||!h){t.next=13;break}return t.next=11,this.generateTapos(y,c,f,h);case 11:d=t.sent;case 13:if(this.hasRequiredTaposFields(d)){t.next=15;break}throw new Error("Required configuration or TAPOS fields are not present");case 15:return t.next=17,this.getTransactionAbis(e);case 17:return v=t.sent,t.t0=Object,t.t1={},t.t2=d,t.next=23,this.serializeActions(e.context_free_actions||[]);case 23:return t.t3=t.sent,t.next=26,this.serializeActions(e.actions);case 26:if(t.t4=t.sent,t.t5={context_free_actions:t.t3,actions:t.t4},e=t.t0.assign.call(t.t0,t.t1,t.t2,t.t5),g=this.serializeTransaction(e),m=this.serializeContextFreeData(e.context_free_data),w={serializedTransaction:g,serializedContextFreeData:m,signatures:[]},!s){t.next=43;break}return t.next=35,this.signatureProvider.getAvailableKeys();case 35:if(_=t.sent,p){t.next=40;break}return t.next=39,this.authorityProvider.getRequiredKeys({transaction:e,availableKeys:_});case 39:p=t.sent;case 40:return t.next=42,this.signatureProvider.sign({chainId:y.chain_id,requiredKeys:p,serializedTransaction:g,serializedContextFreeData:m,abis:v});case 42:w=t.sent;case 43:if(!a){t.next=47;break}if(!u){t.next=46;break}return t.abrupt("return",this.pushCompressedSignedTransaction(w));case 46:return t.abrupt("return",this.pushSignedTransaction(w));case 47:return t.abrupt("return",Object.assign({},w,{transactionHeader:d}));case 48:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.pushSignedTransaction=function(){var t=s(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.rpc.push_transaction({signatures:e.signatures,serializedTransaction:e.serializedTransaction,serializedContextFreeData:e.serializedContextFreeData}));case 2:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.pushCompressedSignedTransaction=function(){var t=s(b.mark((function t(e){var r,n,i,a;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.signatures,n=e.serializedContextFreeData,i=this.deflateSerializedArray(e.serializedTransaction),a=this.deflateSerializedArray(n||new Uint8Array(0)),t.abrupt("return",this.rpc.push_transaction({signatures:r,compression:1,serializedTransaction:i,serializedContextFreeData:a}));case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.generateTapos=function(){var t=s(b.mark((function t(e,r,n,i){var a;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e){t.next=4;break}return t.next=3,this.rpc.get_info();case 3:e=t.sent;case 4:if(!((a=n?e.last_irreversible_block_num:e.head_block_num-r)<=e.last_irreversible_block_num)){t.next=11;break}return t.next=8,this.rpc.get_block(a);case 8:t.t0=t.sent,t.next=14;break;case 11:return t.next=13,this.tryGetBlockHeaderState(a);case 13:t.t0=t.sent;case 14:return t.abrupt("return",kt(t.t0,i));case 16:case"end":return t.stop()}}),t,this)})));return function(e,r,n,i){return t.apply(this,arguments)}}(),r.hasRequiredTaposFields=function(t){return!(!t.expiration||"number"!=typeof t.ref_block_num||"number"!=typeof t.ref_block_prefix)},r.tryGetBlockHeaderState=function(){var t=s(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.rpc.get_block_header_state(e);case 3:return t.abrupt("return",t.sent);case 6:return t.prev=6,t.t0=t.catch(0),t.next=10,this.rpc.get_block(e);case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t,this,[[0,6]])})));return function(e){return t.apply(this,arguments)}}(),t}(),Kt=function(t){var e,r;function n(e){var r;return r=e&&e.error&&e.error.details&&e.error.details.length&&e.error.details[0].message?t.call(this,e.error.details[0].message)||this:e&&e.processed&&e.processed.except&&e.processed.except.message?t.call(this,e.processed.except.message)||this:e?t.call(this,e.message)||this:t.call(this,e)||this,Object.setPrototypeOf(l(r),n.prototype),r.json=e,l(r)}return r=t,(e=n).prototype=Object.create(r.prototype),e.prototype.constructor=e,e.__proto__=r,n}(p(Error)),Nt=function(t){for(var e,r="",n=y(t);!(e=n()).done;)r+=("00"+e.value.toString(16)).slice(-2);return r},Bt=function(){function t(t,e){void 0===e&&(e={}),this.maxRetries=3,t=Array.isArray(t)?t:[t],this.endpoints=t.map((function(t){return t.replace(/\/$/,"")})),this.currentEndpoint="",this.nextEndpoint(),this.fetchBuiltin=e.fetch?e.fetch:global.fetch.bind(global)}var e=t.prototype;return e.fetchWithTimeout=function(t,e){return Promise.race([(0,this.fetchBuiltin)(t,e)])},e.nextEndpoint=function(){if(this.endpoints.length){if(this.currentEndpoint){var t=this.endpoints.shift();this.endpoints=this.endpoints.concat(t||[])}this.currentEndpoint=this.endpoints[0],console.log("Switched to API:",this.currentEndpoint)}},e.fetch=function(){var t=s(b.mark((function t(e,r,n){var i,a,o,s,u;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===n&&(n=0),t.prev=1,t.next=4,this.fetchWithTimeout(this.currentEndpoint+e,{body:JSON.stringify(r),method:"POST"});case 4:return i=t.sent,t.next=7,i.json();case 7:if(!(a=t.sent).processed||!a.processed.except){t.next=10;break}throw new Kt(a);case 10:t.next=27;break;case 12:if(t.prev=12,t.t0=t.catch(1),console.log("Error from",this.currentEndpoint,t.t0),console.log("Error response: ",i),console.log("Error json: ",a),console.log("Error body: ",r),t.t0.isFetchError=!0,!(this.endpoints.length>1)){t.next=27;break}if(this.nextEndpoint(),!(n<this.maxRetries)){t.next=26;break}return console.log("Retrying at try:",n),t.abrupt("return",this.fetch(e,r,++n));case 26:throw t.t0;case 27:if(i&&i.ok){t.next=29;break}throw new Kt(a);case 29:if(!a||!a.head_block_time){t.next=40;break}if(o=new Date(a.head_block_time+"Z").getTime(),s=(new Date).getTime(),!((u=(s-o)/1e3)>20&&this.endpoints.length>1)){t.next=40;break}if(console.log("API is SYNCING (behind)",this.currentEndpoint),console.log("Current Time: "+s+", Head Time: "+o+", Seconds Behind: "+u),this.nextEndpoint(),!(n<this.maxRetries)){t.next=40;break}return console.log("Retrying at try:",n),t.abrupt("return",this.fetch(e,r,++n));case 40:return t.abrupt("return",a);case 41:case"end":return t.stop()}}),t,this,[[1,12]])})));return function(e,r,n){return t.apply(this,arguments)}}(),e.get_abi=function(){var t=s(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch("/v1/chain/get_abi",{account_name:e});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.get_account=function(){var t=s(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch("/v1/chain/get_account",{account_name:e});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.get_block_header_state=function(){var t=s(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch("/v1/chain/get_block_header_state",{block_num_or_id:e});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.get_block=function(){var t=s(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch("/v1/chain/get_block",{block_num_or_id:e});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.get_code=function(){var t=s(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch("/v1/chain/get_code",{account_name:e,code_as_wasm:!0});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.get_currency_balance=function(){var t=s(b.mark((function t(e,r,n){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===n&&(n=null),t.next=3,this.fetch("/v1/chain/get_currency_balance",{code:e,account:r,symbol:n});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),e.get_currency_stats=function(){var t=s(b.mark((function t(e,r){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch("/v1/chain/get_currency_stats",{code:e,symbol:r});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.get_info=function(){var t=s(b.mark((function t(){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch("/v1/chain/get_info",{});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.get_producer_schedule=function(){var t=s(b.mark((function t(){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch("/v1/chain/get_producer_schedule",{});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.get_producers=function(){var t=s(b.mark((function t(e,r,n){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===e&&(e=!0),void 0===r&&(r=""),void 0===n&&(n=50),t.next=5,this.fetch("/v1/chain/get_producers",{json:e,lower_bound:r,limit:n});case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),e.get_raw_code_and_abi=function(){var t=s(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch("/v1/chain/get_raw_code_and_abi",{account_name:e});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.get_raw_abi=function(){var t=s(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch("/v1/chain/get_raw_abi",{account_name:e});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.getRawAbi=function(){var t=s(b.mark((function t(e){var r,n;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.get_raw_abi(e);case 2:return n=O((r=t.sent).abi),t.abrupt("return",{accountName:r.account_name,abi:n});case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.get_scheduled_transactions=function(){var t=s(b.mark((function t(e,r,n){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===e&&(e=!0),void 0===r&&(r=""),void 0===n&&(n=50),t.next=5,this.fetch("/v1/chain/get_scheduled_transactions",{json:e,lower_bound:r,limit:n});case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),e.get_activated_protocol_features=function(){var t=s(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===e&&(e=100),t.next=3,this.fetch("/v1/chain/get_activated_protocol_features",{limit:e});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.get_table_rows=function(){var t=s(b.mark((function t(e){var r,n,i,a,o,s,u,c,f,h,p,l,d,y,v,g,m,w,_,x,A;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=void 0===(r=e.json)||r,i=e.code,a=e.scope,o=e.table,u=void 0===(s=e.table_key)?"":s,f=void 0===(c=e.lower_bound)?"":c,p=void 0===(h=e.upper_bound)?"":h,d=void 0===(l=e.index_position)?1:l,v=void 0===(y=e.key_type)?"":y,m=void 0===(g=e.limit)?10:g,_=void 0!==(w=e.reverse)&&w,A=void 0!==(x=e.show_payer)&&x,t.next=3,this.fetch("/v1/chain/get_table_rows",{json:n,code:i,scope:a,table:o,table_key:u,lower_bound:f,upper_bound:p,index_position:d,key_type:v,limit:m,reverse:_,show_payer:A});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.get_table_by_scope=function(){var t=s(b.mark((function t(e){var r,n,i,a,o,s,u,c;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.code,n=e.table,a=void 0===(i=e.lower_bound)?"":i,s=void 0===(o=e.upper_bound)?"":o,c=void 0===(u=e.limit)?10:u,t.next=3,this.fetch("/v1/chain/get_table_by_scope",{code:r,table:n,lower_bound:a,upper_bound:s,limit:c});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.getRequiredKeys=function(){var t=s(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=L,t.next=3,this.fetch("/v1/chain/get_required_keys",{transaction:e.transaction,available_keys:e.availableKeys});case 3:return t.t1=t.sent.required_keys,t.abrupt("return",(0,t.t0)(t.t1));case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.push_transaction=function(){var t=s(b.mark((function t(e){var r,n,i,a,o;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.signatures,i=void 0===(n=e.compression)?0:n,a=e.serializedTransaction,o=e.serializedContextFreeData,t.prev=1,t.next=4,this.fetch("/v1/chain/push_transaction",{signatures:r,compression:i,packed_context_free_data:Nt(o||new Uint8Array(0)),packed_trx:Nt(a)});case 4:return t.abrupt("return",t.sent);case 7:throw t.prev=7,t.t0=t.catch(1),t.t0&&t.t0.json&&t.t0.json.error&&"expired_tx_exception"===t.t0.json.error.name&&(t.t0.json.error.message="Transaction Expired: Try Again",this.nextEndpoint()),t.t0;case 11:case"end":return t.stop()}}),t,this,[[1,7]])})));return function(e){return t.apply(this,arguments)}}(),e.send_transaction=function(){var t=s(b.mark((function t(e){var r,n,i,a,o;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.signatures,i=void 0===(n=e.compression)?0:n,a=e.serializedTransaction,o=e.serializedContextFreeData,t.next=3,this.fetch("/v1/chain/send_transaction",{signatures:r,compression:i,packed_context_free_data:Nt(o||new Uint8Array(0)),packed_trx:Nt(a)});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.db_size_get=function(){var t=s(b.mark((function t(){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch("/v1/db_size/get",{});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.history_get_actions=function(){var t=s(b.mark((function t(e,r,n){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===r&&(r=null),void 0===n&&(n=null),t.next=4,this.fetch("/v1/history/get_actions",{account_name:e,pos:r,offset:n});case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),e.history_get_transaction=function(){var t=s(b.mark((function t(e,r){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===r&&(r=null),t.next=3,this.fetch("/v1/history/get_transaction",{id:e,block_num_hint:r});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.history_get_key_accounts=function(){var t=s(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch("/v1/history/get_key_accounts",{public_key:e});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.history_get_controlled_accounts=function(){var t=s(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch("/v1/history/get_controlled_accounts",{controlling_account:e});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),t}(),jt=function(t){return new a.ec(t===v.k1?"secp256k1":"p256")},Rt=function(){function t(t,e){this.key=t,this.ec=e}t.fromString=function(e,r){var n=j(e);return r||(r=jt(n.type)),new t(n,r)},t.fromElliptic=function(e,r,n){var i=e.getPublic().getX().toArray("be",32),a=e.getPublic().getY().toArray("be",32);return n||(n=jt(r)),new t({type:r,data:new Uint8Array([1&a[31]?3:2].concat(i))},n)};var e=t.prototype;return e.toString=function(){return D(this.key)},e.toLegacyString=function(t){return R(this.key,t)},e.toElliptic=function(){return this.ec.keyPair({pub:Buffer.from(this.key.data)})},e.getType=function(){return this.key.type},e.isValid=function(){try{return this.toElliptic().validate().result}catch(t){return!1}},t}(),Dt=require("bn.js"),Ft=function(){function t(t,e){this.signature=t,this.ec=e}t.fromString=function(e,r){var n=M(e);return r||(r=jt(n.type)),new t(n,r)},t.fromElliptic=function(e,r,n){e.recoveryParam||(e.recoveryParam=0);var i,a=e.r.toArray("be",32),o=e.s.toArray("be",32);r===v.k1||r===v.r1?(i=e.recoveryParam+27,e.recoveryParam<=3&&(i+=4)):r===v.wa&&(i=e.recoveryParam);var s=new Uint8Array([i].concat(a,o));return n||(n=jt(r)),new t({type:r,data:s},n)};var e=t.prototype;return e.toElliptic=function(){var t,e=new Dt(this.signature.data.slice(1,33)),r=new Dt(this.signature.data.slice(33,65));return this.signature.type===v.k1||this.signature.type===v.r1?(t=this.signature.data[0]-27)>3&&(t-=4):t=this.signature.type===v.wa?this.signature.data[0]:0,{r:e,s:r,recoveryParam:3&t}},e.toString=function(){return G(this.signature)},e.toBinary=function(){return this.signature.data},e.getType=function(){return this.signature.type},e.verify=function(t,e,r,n){void 0===r&&(r=!0),void 0===n&&(n="utf8"),r&&("string"==typeof t&&(t=Buffer.from(t,n)),t=this.ec.hash().update(t).digest());var i=this.toElliptic(),a=e.toElliptic();return this.ec.verify(t,i,a,n)},e.recover=function(t,e,r){void 0===e&&(e=!0),void 0===r&&(r="utf8"),e&&("string"==typeof t&&(t=Buffer.from(t,r)),t=this.ec.hash().update(t).digest());var n=this.toElliptic(),i=this.ec.recoverPubKey(t,n,n.recoveryParam,r),a=this.ec.keyFromPublic(i);return Rt.fromElliptic(a,this.getType(),this.ec)},t}(),Lt=function(){function t(t,e){this.key=t,this.ec=e}t.fromElliptic=function(e,r,n){return n||(n=jt(r)),new t({type:r,data:e.getPrivate().toArrayLike(Buffer,"be",32)},n)},t.fromString=function(e,r){var n=I(e);return r||(r=jt(n.type)),new t(n,r)};var e=t.prototype;return e.toElliptic=function(){return this.ec.keyFromPrivate(this.key.data)},e.toLegacyString=function(){return V(this.key)},e.toString=function(){return q(this.key)},e.getType=function(){return this.key.type},e.getPublicKey=function(){var t=this.toElliptic();return Rt.fromElliptic(t,this.getType(),this.ec)},e.sign=function(t,e,r){var n=this;void 0===e&&(e=!0),void 0===r&&(r="utf8"),e&&("string"==typeof t&&(t=Buffer.from(t,r)),t=this.ec.hash().update(t).digest());var i,a,o=0,s=function(e){var r=n.toElliptic().sign(t,e);return Ft.fromElliptic(r,n.getType(),n.ec)};if(this.key.type===v.k1)do{i=s({canonical:!0,pers:[++o]})}while(128&(a=i.toBinary())[1]||0===a[1]&&!(128&a[2])||128&a[33]||!(0!==a[33]||128&a[34]));else i=s({canonical:!0});return i},e.isValid=function(){try{return this.toElliptic().validate().result}catch(t){return!1}},t}(),It={__proto__:null,generateKeyPair:function(t,e){if(void 0===e&&(e={}),!e.secureEnv)throw new Error("Key generation is completely INSECURE in production environments in the browser. If you are absolutely certain this does NOT describe your environment, set `secureEnv` in your options to `true`. If this does describe your environment and you set `secureEnv` to `true`, YOU DO SO AT YOUR OWN RISK AND THE RISK OF YOUR USERS.");var r,n=(r=new a.ec(t===v.k1?"secp256k1":"p256")).genKeyPair(e.ecOptions);return{publicKey:Rt.fromElliptic(n,t,r),privateKey:Lt.fromElliptic(n,t,r)}},PrivateKey:Lt,PublicKey:Rt,Signature:Ft,constructElliptic:jt,sha256:function(t){return r.sha256().update(t).digest()}},Vt=new a.ec("secp256k1"),qt=function(t,e,r,n){void 0===n&&(n=Vt);var i=Buffer.concat([Buffer.from(t,"hex"),Buffer.from(e),Buffer.from(r?new Uint8Array(n.hash().update(r).digest()):new Uint8Array(32))]);return n.hash().update(i).digest()},Mt=function(){function t(t){this.keys=new Map,this.availableKeys=[];for(var e,r=y(t);!(e=r()).done;){var n=Lt.fromString(e.value),i=n.toElliptic(),a=n.getPublicKey().toString();this.keys.set(a,i),this.availableKeys.push(a)}}var e=t.prototype;return e.getAvailableKeys=function(){var t=s(b.mark((function t(){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.availableKeys);case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.sign=function(){var t=s(b.mark((function t(e){var r,n,i,a,o,s,u,c,f,h,p,l;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(r=e.requiredKeys,a=qt(e.chainId,n=e.serializedTransaction,i=e.serializedContextFreeData,Vt),o=[],s=y(r);!(u=s()).done;)f=Rt.fromString(c=u.value),(h=this.keys.get(F(c)))&&(p=Lt.fromElliptic(h,f.getType()),l=p.sign(a,!1),o.push(l.toString()));return t.abrupt("return",{signatures:o,serializedTransaction:n,serializedContextFreeData:i});case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),t}(),Gt=function(){function t(){}return t.prototype.encode=function(t){for(var e=[],r=t.length,n=0;n<r;){var i=t.codePointAt(n),a=0,o=0;for(i<=127?(a=0,o=0):i<=2047?(a=6,o=192):i<=65535?(a=12,o=224):i<=2097151&&(a=18,o=240),e.push(o|i>>a),a-=6;a>=0;)e.push(128|i>>a&63),a-=6;n+=i>=65536?2:1}return new Uint8Array(e)},t}(),Wt=function(){function t(){}return t.prototype.decode=function(t){for(var e="",r=0;r<t.length;){var n=t[r],i=0,a=0;if(n<=127?(i=0,a=255&n):n<=223?(i=1,a=31&n):n<=239?(i=2,a=15&n):n<=244&&(i=3,a=7&n),t.length-r-i>0)for(var o=0;o<i;)a=a<<6|63&(n=t[r+o+1]),o+=1;else a=65533,i=t.length-r;e+=String.fromCodePoint(a),r+=i+1}return e},t}();exports.Api=Ot,exports.ApiInterfaces={__proto__:null},exports.JsSignatureProvider=Mt,exports.JsonRpc=Bt,exports.Key=It,exports.Numeric=W,exports.RpcError=Kt,exports.RpcInterfaces={__proto__:null},exports.Serialize=Tt,exports.TextDecoder=Wt,exports.TextEncoder=Gt; | ||
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=require("pako"),r=require("hash.js"),n=t(require("ripemd-ts")),i=t(require("bs58")),a=require("elliptic");function o(t,e,r,n,i,a,o){try{var s=t[a](o),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function s(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var a=t.apply(e,r);function s(t){o(a,n,i,s,u,"next",t)}function u(t){o(a,n,i,s,u,"throw",t)}s(void 0)}))}}function u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function c(t,e){return(c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function f(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function h(t,e,r){return(h=f()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var i=new(Function.bind.apply(t,n));return r&&c(i,r.prototype),i}).apply(null,arguments)}function p(t){var e="function"==typeof Map?new Map:void 0;return(p=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return h(t,arguments,u(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),c(r,t)})(t)}function l(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function d(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function y(t,e){var r;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return d(t,void 0);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?d(t,void 0):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=t[Symbol.iterator]()).next.bind(r)}var v,g,b=(function(t){var e=function(t){var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",o=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var i=Object.create((e&&e.prototype instanceof h?e:h).prototype),a=new A(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(i,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw a;return{value:void 0,done:!0}}for(r.method=i,r.arg=a;;){var o=r.delegate;if(o){var s=w(o,r);if(s){if(s===f)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=c(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function c(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var f={};function h(){}function p(){}function l(){}var d={};d[i]=function(){return this};var y=Object.getPrototypeOf,v=y&&y(y(k([])));v&&v!==e&&r.call(v,i)&&(d=v);var g=l.prototype=h.prototype=Object.create(d);function b(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function m(t,e){var n;this._invoke=function(i,a){function o(){return new e((function(n,o){!function n(i,a,o,s){var u=c(t[i],t,a);if("throw"!==u.type){var f=u.arg,h=f.value;return h&&"object"==typeof h&&r.call(h,"__await")?e.resolve(h.__await).then((function(t){n("next",t,o,s)}),(function(t){n("throw",t,o,s)})):e.resolve(h).then((function(t){f.value=t,o(f)}),(function(t){return n("throw",t,o,s)}))}s(u.arg)}(i,a,n,o)}))}return n=n?n.then(o,o):o()}}function w(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return f;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=c(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,f;var i=n.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function _(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(_,this),this.reset(!0)}function k(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,a=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return a.next=a}}return{next:z}}function z(){return{value:void 0,done:!0}}return p.prototype=g.constructor=l,l.constructor=p,p.displayName=s(l,o,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,s(t,o,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},b(m.prototype),m.prototype[a]=function(){return this},t.AsyncIterator=m,t.async=function(e,r,n,i,a){void 0===a&&(a=Promise);var o=new m(u(e,r,n,i),a);return t.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},b(g),s(g,o,"Generator"),g[i]=function(){return this},g.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=k,A.prototype={constructor:A,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return o.type="throw",o.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],o=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var s=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=t,o.arg=e,a?(this.method="next",this.next=a.finallyLoc,f):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),x(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;x(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:k(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}(g={exports:{}}),g.exports),m=n.hash,w="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",_="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",x=function(){for(var t=Array(256).fill(-1),e=0;e<w.length;++e)t[w.charCodeAt(e)]=e;return t}(),A=function(){for(var t=Array(256).fill(-1),e=0;e<_.length;++e)t[_.charCodeAt(e)]=e;return t["=".charCodeAt(0)]=0,t}(),k=function(t){return 0!=(128&t[t.length-1])},z=function(t){for(var e=1,r=0;r<t.length;++r){var n=(255&~t[r])+e;t[r]=n,e=n>>8}},E=function(t,e){for(var r=new Uint8Array(t),n=0;n<e.length;++n){var i=e.charCodeAt(n);if(i<"0".charCodeAt(0)||i>"9".charCodeAt(0))throw new Error("invalid number");for(var a=i-"0".charCodeAt(0),o=0;o<t;++o){var s=10*r[o]+a;r[o]=s,a=s>>8}if(a)throw new Error("number is out of range")}return r},S=function(t,e){var r="-"===e[0];r&&(e=e.substr(1));var n=E(t,e);if(r){if(z(n),!k(n))throw new Error("number is out of range")}else if(k(n))throw new Error("number is out of range");return n},U=function(t,e){void 0===e&&(e=1);for(var r=Array(e).fill("0".charCodeAt(0)),n=t.length-1;n>=0;--n){for(var i=t[n],a=0;a<r.length;++a){var o=(r[a]-"0".charCodeAt(0)<<8)+i;r[a]="0".charCodeAt(0)+o%10,i=o/10|0}for(;i;)r.push("0".charCodeAt(0)+i%10),i=i/10|0}return r.reverse(),String.fromCharCode.apply(String,r)},T=function(t,e){if(void 0===e&&(e=1),k(t)){var r=t.slice();return z(r),"-"+U(r,e)}return U(t,e)},P=function(t,e){if(!t)return function(t){for(var e=[],r=0;r<t.length;++r){var n=x[t.charCodeAt(r)];if(n<0)throw new Error("invalid base-58 value");for(var i=0;i<e.length;++i){var a=58*e[i]+n;e[i]=255&a,n=a>>8}n&&e.push(n)}for(var o,s=y(t);!(o=s()).done&&"1"===o.value;)e.push(0);return e.reverse(),new Uint8Array(e)}(e);for(var r=new Uint8Array(t),n=0;n<e.length;++n){var i=x[e.charCodeAt(n)];if(i<0)throw new Error("invalid base-58 value");for(var a=0;a<t;++a){var o=58*r[a]+i;r[a]=o,i=o>>8}if(i)throw new Error("base-58 value is out of range")}return r.reverse(),r},C=function(t){for(var e,r=[],n=y(t);!(e=n()).done;){for(var i=e.value,a=0;a<r.length;++a){var o=(x[r[a]]<<8)+i;r[a]=w.charCodeAt(o%58),i=o/58|0}for(;i;)r.push(w.charCodeAt(i%58)),i=i/58|0}for(var s,u=y(t);!(s=u()).done&&!s.value;)r.push("1".charCodeAt(0));return r.reverse(),String.fromCharCode.apply(String,r)},O=function(t){var e=t.length;if(1==(3&e)&&"="===t[e-1]&&(e-=1),0!=(3&e))throw new Error("base-64 value is not padded correctly");var r=e>>2,n=3*r;e>0&&"="===t[e-1]&&(n-="="===t[e-2]?2:1);for(var i=new Uint8Array(n),a=0;a<r;++a){var o=A[t.charCodeAt(4*a+0)],s=A[t.charCodeAt(4*a+1)],u=A[t.charCodeAt(4*a+2)],c=A[t.charCodeAt(4*a+3)];i[3*a+0]=o<<2|s>>4,3*a+1<n&&(i[3*a+1]=(15&s)<<4|u>>2),3*a+2<n&&(i[3*a+2]=(3&u)<<6|c)}return i};!function(t){t[t.k1=0]="k1",t[t.r1=1]="r1",t[t.wa=2]="wa"}(v||(v={}));var K=function(t,e){for(var r=new Uint8Array(t.length+e.length),n=0;n<t.length;++n)r[n]=t[n];for(var i=0;i<e.length;++i)r[t.length+i]=e.charCodeAt(i);return m(r)},N=function(t,e,r,n){var i=P(r?r+4:0,t),a={type:e,data:new Uint8Array(i.buffer,0,i.length-4)},o=new Uint8Array(K(a.data,n));if(o[0]!==i[i.length-4]||o[1]!==i[i.length-3]||o[2]!==i[i.length-2]||o[3]!==i[i.length-1])throw new Error("checksum doesn't match");return a},B=function(t,e,r){for(var n=new Uint8Array(K(t.data,e)),i=new Uint8Array(t.data.length+4),a=0;a<t.data.length;++a)i[a]=t.data[a];for(var o=0;o<4;++o)i[o+t.data.length]=n[o];return r+C(i)},j=function(t,e){if(void 0===e&&(e="EOS"),"string"!=typeof t)throw new Error("expected string containing public key");if(t.substr(0,3)===e){for(var r=P(37,t.substr(3)),n={type:v.k1,data:new Uint8Array(33)},i=0;i<33;++i)n.data[i]=r[i];var a=new Uint8Array(m(n.data));if(a[0]!==r[33]||a[1]!==r[34]||a[2]!==r[35]||a[3]!==r[36])throw new Error("checksum doesn't match");return n}if("PUB_K1_"===t.substr(0,7))return N(t.substr(7),v.k1,33,"K1");if("PUB_R1_"===t.substr(0,7))return N(t.substr(7),v.r1,33,"R1");if("PUB_WA_"===t.substr(0,7))return N(t.substr(7),v.wa,0,"WA");throw new Error("unrecognized public key format")},R=function(t,e){if(void 0===e&&(e="EOS"),t.type===v.k1&&33===t.data.length)return B(t,"",e);throw t.type===v.r1||t.type===v.wa?new Error("Key format not supported in legacy conversion"):new Error("unrecognized public key format")},D=function(t){if(t.type===v.k1&&33===t.data.length)return B(t,"K1","PUB_K1_");if(t.type===v.r1&&33===t.data.length)return B(t,"R1","PUB_R1_");if(t.type===v.wa)return B(t,"WA","PUB_WA_");throw new Error("unrecognized public key format")},F=function(t,e){return void 0===e&&(e="EOS"),t.substr(0,3)===e?D(j(t,e)):t},L=function(t,e){return void 0===e&&(e="EOS"),t.map((function(t){return F(t,e)}))},I=function(t){if("string"!=typeof t)throw new Error("expected string containing private key");if("PVT_R1_"===t.substr(0,7))return N(t.substr(7),v.r1,32,"R1");if("PVT_K1_"===t.substr(0,7))return N(t.substr(7),v.k1,32,"K1");var e=P(37,t),r={type:v.k1,data:new Uint8Array(32)};if(128!==e[0])throw new Error("unrecognized private key type");for(var n=0;n<32;++n)r.data[n]=e[n+1];return r},V=function(t){if(t.type===v.k1&&32===t.data.length){var e=[];e.push(128),t.data.forEach((function(t){return e.push(t)}));for(var n=new Uint8Array(r.sha256().update(r.sha256().update(e).digest()).digest()),i=new Uint8Array(37),a=0;a<e.length;a++)i[a]=e[a];for(var o=0;o<4;o++)i[o+e.length]=n[o];return C(i)}throw t.type===v.r1||t.type===v.wa?new Error("Key format not supported in legacy conversion"):new Error("unrecognized public key format")},q=function(t){if(t.type===v.r1)return B(t,"R1","PVT_R1_");if(t.type===v.k1)return B(t,"K1","PVT_K1_");throw new Error("unrecognized private key format")},M=function(t){if("string"!=typeof t)throw new Error("expected string containing signature");if("SIG_K1_"===t.substr(0,7))return N(t.substr(7),v.k1,65,"K1");if("SIG_R1_"===t.substr(0,7))return N(t.substr(7),v.r1,65,"R1");if("SIG_WA_"===t.substr(0,7))return N(t.substr(7),v.wa,0,"WA");throw new Error("unrecognized signature format")},G=function(t){if(t.type===v.k1)return B(t,"K1","SIG_K1_");if(t.type===v.r1)return B(t,"R1","SIG_R1_");if(t.type===v.wa)return B(t,"WA","SIG_WA_");throw new Error("unrecognized signature format")},W={__proto__:null,isNegative:k,negate:z,decimalToBinary:E,signedDecimalToBinary:S,binaryToDecimal:U,signedBinaryToDecimal:T,base58ToBinary:P,binaryToBase58:C,base64ToBinary:O,get KeyType(){return v},publicKeyDataSize:33,privateKeyDataSize:32,signatureDataSize:65,stringToPublicKey:j,publicKeyToLegacyString:R,publicKeyToString:D,convertLegacyPublicKey:F,convertK1ToLegacyPublicKey:function(t,e){if(void 0===e&&(e="EOS"),"PUB_K1_"!==t.substr(0,"PUB_K1_".length))return t;var r=t.substr("PUB_K1_".length),n=i.decode(r),a=n.slice(0,n.length-4),o=Buffer.from(m(a)).slice(0,4),s=Buffer.from([].concat(a,o));return""+e+i.encode(s)},convertLegacyPublicKeys:L,stringToPrivateKey:I,privateKeyToLegacyString:V,privateKeyToString:q,stringToSignature:M,signatureToString:G},H=function(t){void 0===t&&(t={}),this.skippedBinaryExtension=!1,this.options=t},Y=function(){function t(t){var e=(void 0===t?{}:t).array;this.readPos=0,this.textEncoder=new TextEncoder,this.textDecoder=new TextDecoder("utf-8",{fatal:!0}),this.array=e||new Uint8Array(1024),this.length=e?e.length:0}var e=t.prototype;return e.reserve=function(t){if(!(this.length+t<=this.array.length)){for(var e=this.array.length;this.length+t>e;)e=Math.ceil(1.5*e);var r=new Uint8Array(e);r.set(this.array),this.array=r}},e.haveReadData=function(){return this.readPos<this.length},e.restartRead=function(){this.readPos=0},e.asUint8Array=function(){return new Uint8Array(this.array.buffer,this.array.byteOffset,this.length)},e.pushArray=function(t){this.reserve(t.length),this.array.set(t,this.length),this.length+=t.length},e.push=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];this.pushArray(e)},e.get=function(){if(this.readPos<this.length)return this.array[this.readPos++];throw new Error("Read past end of buffer")},e.pushUint8ArrayChecked=function(t,e){if(t.length!==e)throw new Error("Binary data has incorrect size");this.pushArray(t)},e.getUint8Array=function(t){if(this.readPos+t>this.length)throw new Error("Read past end of buffer");var e=new Uint8Array(this.array.buffer,this.array.byteOffset+this.readPos,t);return this.readPos+=t,e},e.skip=function(t){if(this.readPos+t>this.length)throw new Error("Read past end of buffer");this.readPos+=t},e.pushUint16=function(t){this.push(t>>0&255,t>>8&255)},e.getUint16=function(){var t=0;return(t|=this.get()<<0)|this.get()<<8},e.pushUint32=function(t){this.push(t>>0&255,t>>8&255,t>>16&255,t>>24&255)},e.getUint32=function(){var t=0;return t|=this.get()<<0,t|=this.get()<<8,t|=this.get()<<16,(t|=this.get()<<24)>>>0},e.pushNumberAsUint64=function(t){this.pushUint32(t>>>0),this.pushUint32(Math.floor(t/4294967296)>>>0)},e.getUint64AsNumber=function(){var t=this.getUint32();return 4294967296*(this.getUint32()>>>0)+(t>>>0)},e.pushVaruint32=function(t){for(;;){if(!(t>>>7)){this.push(t);break}this.push(128|127&t),t>>>=7}},e.getVaruint32=function(){for(var t=0,e=0;;){var r=this.get();if(t|=(127&r)<<e,e+=7,!(128&r))break}return t>>>0},e.pushVarint32=function(t){this.pushVaruint32(t<<1^t>>31)},e.getVarint32=function(){var t=this.getVaruint32();return 1&t?~t>>1|2147483648:t>>>1},e.pushFloat32=function(t){this.pushArray(new Uint8Array(new Float32Array([t]).buffer))},e.getFloat32=function(){return new Float32Array(this.getUint8Array(4).slice().buffer)[0]},e.pushFloat64=function(t){this.pushArray(new Uint8Array(new Float64Array([t]).buffer))},e.getFloat64=function(){return new Float64Array(this.getUint8Array(8).slice().buffer)[0]},e.pushName=function(t){if("string"!=typeof t)throw new Error("Expected string containing name");if(""!==t&&!new RegExp(/^[.1-5a-z]{1,12}[.1-5a-j]?$/).test(t))throw new Error("Name should be less than 13 characters, or less than 14 if last character is between 1-5 or a-j, and only contain the following symbols .12345abcdefghijklmnopqrstuvwxyz");for(var e=function(t){return t>="a".charCodeAt(0)&&t<="z".charCodeAt(0)?t-"a".charCodeAt(0)+6:t>="1".charCodeAt(0)&&t<="5".charCodeAt(0)?t-"1".charCodeAt(0)+1:0},r=new Uint8Array(8),n=63,i=0;i<t.length;++i){var a=e(t.charCodeAt(i));n<5&&(a<<=1);for(var o=4;o>=0;--o)n>=0&&(r[Math.floor(n/8)]|=(a>>o&1)<<n%8,--n)}this.pushArray(r)},e.getName=function(){for(var t=this.getUint8Array(8),e="",r=63;r>=0;){for(var n=0,i=0;i<5;++i)r>=0&&(n=n<<1|t[Math.floor(r/8)]>>r%8&1,--r);e+=n>=6?String.fromCharCode(n+"a".charCodeAt(0)-6):n>=1?String.fromCharCode(n+"1".charCodeAt(0)-1):"."}for(;e.endsWith(".");)e=e.substr(0,e.length-1);return e},e.pushBytes=function(t){this.pushVaruint32(t.length),this.pushArray(t)},e.getBytes=function(){return this.getUint8Array(this.getVaruint32())},e.pushString=function(t){this.pushBytes(this.textEncoder.encode(t))},e.getString=function(){return this.textDecoder.decode(this.getBytes())},e.pushSymbolCode=function(t){if("string"!=typeof t)throw new Error("Expected string containing symbol_code");var e=[];for(e.push.apply(e,this.textEncoder.encode(t));e.length<8;)e.push(0);this.pushArray(e.slice(0,8))},e.getSymbolCode=function(){var t,e=this.getUint8Array(8);for(t=0;t<e.length&&e[t];++t);return this.textDecoder.decode(new Uint8Array(e.buffer,e.byteOffset,t))},e.pushSymbol=function(t){var e=t.name,r=t.precision;if(!/^[A-Z]{1,7}$/.test(e))throw new Error("Expected symbol to be A-Z and between one and seven characters");var n=[255&r];for(n.push.apply(n,this.textEncoder.encode(e));n.length<8;)n.push(0);this.pushArray(n.slice(0,8))},e.getSymbol=function(){var t,e=this.get(),r=this.getUint8Array(7);for(t=0;t<r.length&&r[t];++t);return{name:this.textDecoder.decode(new Uint8Array(r.buffer,r.byteOffset,t)),precision:e}},e.pushAsset=function(t){if("string"!=typeof t)throw new Error("Expected string containing asset");var e=0,r="",n=0;"-"===(t=t.trim())[e]&&(r+="-",++e);for(var i=!1;e<t.length&&t.charCodeAt(e)>="0".charCodeAt(0)&&t.charCodeAt(e)<="9".charCodeAt(0);)i=!0,r+=t[e],++e;if(!i)throw new Error("Asset must begin with a number");if("."===t[e])for(++e;e<t.length&&t.charCodeAt(e)>="0".charCodeAt(0)&&t.charCodeAt(e)<="9".charCodeAt(0);)r+=t[e],++n,++e;var a=t.substr(e).trim();this.pushArray(S(8,r)),this.pushSymbol({name:a,precision:n})},e.getAsset=function(){var t=this.getUint8Array(8),e=this.getSymbol(),r=e.name,n=e.precision,i=T(t,n+1);return n&&(i=i.substr(0,i.length-n)+"."+i.substr(i.length-n)),i+" "+r},e.pushPublicKey=function(t){var e=j(t);this.push(e.type),this.pushArray(e.data)},e.getPublicKey=function(){var t,e=this.get();if(e===v.wa){var r=this.readPos;this.skip(34),this.skip(this.getVaruint32()),t=new Uint8Array(this.array.buffer,this.array.byteOffset+r,this.readPos-r)}else t=this.getUint8Array(33);return D({type:e,data:t})},e.pushPrivateKey=function(t){var e=I(t);this.push(e.type),this.pushArray(e.data)},e.getPrivateKey=function(){var t=this.get(),e=this.getUint8Array(32);return q({type:t,data:e})},e.pushSignature=function(t){var e=M(t);this.push(e.type),this.pushArray(e.data)},e.getSignature=function(){var t,e=this.get();if(e===v.wa){var r=this.readPos;this.skip(65),this.skip(this.getVaruint32()),this.skip(this.getVaruint32()),t=new Uint8Array(this.array.buffer,this.array.byteOffset+r,this.readPos-r)}else t=this.getUint8Array(65);return G({type:e,data:t})},t}(),Z=function(t){return t.startsWith("eosio::abi/1.")},J=function(t){var e=Date.parse(t);if(Number.isNaN(e))throw new Error("Invalid time format");return e},$=function(t){return Math.round(1e3*J(t+"Z"))},X=function(t){var e=new Date(t/1e3).toISOString();return e.substr(0,e.length-1)},Q=function(t){return Math.round(J(t+"Z")/1e3)},tt=function(t){var e=new Date(1e3*t).toISOString();return e.substr(0,e.length-1)},et=function(t){return Math.round((J(t+"Z")-9466848e5)/500)},rt=function(t){var e=new Date(500*t+9466848e5).toISOString();return e.substr(0,e.length-1)},nt=function(t){if("string"!=typeof t)throw new Error("Expected string containing symbol");var e=t.match(/^([0-9]+),([A-Z]+)$/);if(!e)throw new Error("Invalid symbol");return{name:e[2],precision:+e[1]}},it=function(t){return t.precision+","+t.name},at=function(t){for(var e,r="",n=y(t);!(e=n()).done;)r+=("00"+e.value.toString(16)).slice(-2);return r.toUpperCase()},ot=function(t){if("string"!=typeof t)throw new Error("Expected string containing hex digits");if(t.length%2)throw new Error("Odd number of hex digits");for(var e=t.length/2,r=new Uint8Array(e),n=0;n<e;++n){var i=parseInt(t.substr(2*n,2),16);if(Number.isNaN(i))throw new Error("Expected hex string");r[n]=i}return r};function st(t,e){throw new Error("Don't know how to serialize "+this.name)}function ut(t){throw new Error("Don't know how to deserialize "+this.name)}function ct(t,e,r,n){if(void 0===r&&(r=new H),void 0===n&&(n=!0),"object"!=typeof e)throw new Error("expected object containing data: "+JSON.stringify(e));this.base&&this.base.serialize(t,e,r,n);for(var i,a=y(this.fields);!(i=a()).done;){var o=i.value;if(o.name in e){if(r.skippedBinaryExtension)throw new Error("unexpected "+this.name+"."+o.name);o.type.serialize(t,e[o.name],r,n&&o===this.fields[this.fields.length-1])}else{if(!n||!o.type.extensionOf)throw new Error("missing "+this.name+"."+o.name+" (type="+o.type.name+")");r.skippedBinaryExtension=!0}}}function ft(t,e,r){var n;void 0===e&&(e=new H),void 0===r&&(r=!0),n=this.base?this.base.deserialize(t,e,r):{};for(var i,a=y(this.fields);!(i=a()).done;){var o=i.value;r&&o.type.extensionOf&&!t.haveReadData()?e.skippedBinaryExtension=!0:n[o.name]=o.type.deserialize(t,e,r)}return n}function ht(t,e,r,n){if(!Array.isArray(e)||2!==e.length||"string"!=typeof e[0])throw new Error('expected variant: ["type", value]');var i=this.fields.findIndex((function(t){return t.name===e[0]}));if(i<0)throw new Error('type "'+e[0]+'" is not valid for variant');t.pushVaruint32(i),this.fields[i].type.serialize(t,e[1],r,n)}function pt(t,e,r){var n=t.getVaruint32();if(n>=this.fields.length)throw new Error("type index "+n+" is not valid for variant");var i=this.fields[n];return[i.name,i.type.deserialize(t,e,r)]}function lt(t,e,r){t.pushVaruint32(e.length);for(var n,i=y(e);!(n=i()).done;)this.arrayOf.serialize(t,n.value,r,!1)}function dt(t,e){for(var r=t.getVaruint32(),n=[],i=0;i<r;++i)n.push(this.arrayOf.deserialize(t,e,!1));return n}function yt(t,e,r,n){null==e?t.push(0):(t.push(1),this.optionalOf.serialize(t,e,r,n))}function vt(t,e,r){return t.get()?this.optionalOf.deserialize(t,e,r):null}function gt(t,e,r,n){this.extensionOf.serialize(t,e,r,n)}function bt(t,e,r){return this.extensionOf.deserialize(t,e,r)}var mt=function(t){return Object.assign({name:"<missing name>",aliasOfName:"",arrayOf:void 0,optionalOf:void 0,extensionOf:void 0,baseName:"",base:void 0,fields:[],serialize:st,deserialize:ut},t)},wt=function(t,e){if(Number.isNaN(+t)||Number.isNaN(+e)||"number"!=typeof t&&"string"!=typeof t)throw new Error("Expected number");if(+t!=+e)throw new Error("Number is out of range");return+t},_t=function(){var t=new Map(Object.entries({bool:mt({name:"bool",serialize:function(t,e){if("boolean"!=typeof e&&("number"!=typeof e||1!==e&&0!==e))throw new Error("Expected boolean or number equal to 1 or 0");t.push(e?1:0)},deserialize:function(t){return!!t.get()}}),uint8:mt({name:"uint8",serialize:function(t,e){t.push(wt(e,255&e))},deserialize:function(t){return t.get()}}),int8:mt({name:"int8",serialize:function(t,e){t.push(wt(e,e<<24>>24))},deserialize:function(t){return t.get()<<24>>24}}),uint16:mt({name:"uint16",serialize:function(t,e){t.pushUint16(wt(e,65535&e))},deserialize:function(t){return t.getUint16()}}),int16:mt({name:"int16",serialize:function(t,e){t.pushUint16(wt(e,e<<16>>16))},deserialize:function(t){return t.getUint16()<<16>>16}}),uint32:mt({name:"uint32",serialize:function(t,e){t.pushUint32(wt(e,e>>>0))},deserialize:function(t){return t.getUint32()}}),uint64:mt({name:"uint64",serialize:function(t,e){t.pushArray(E(8,""+e))},deserialize:function(t){return U(t.getUint8Array(8))}}),int64:mt({name:"int64",serialize:function(t,e){t.pushArray(S(8,""+e))},deserialize:function(t){return T(t.getUint8Array(8))}}),int32:mt({name:"int32",serialize:function(t,e){t.pushUint32(wt(e,0|e))},deserialize:function(t){return 0|t.getUint32()}}),varuint32:mt({name:"varuint32",serialize:function(t,e){t.pushVaruint32(wt(e,e>>>0))},deserialize:function(t){return t.getVaruint32()}}),varint32:mt({name:"varint32",serialize:function(t,e){t.pushVarint32(wt(e,0|e))},deserialize:function(t){return t.getVarint32()}}),uint128:mt({name:"uint128",serialize:function(t,e){t.pushArray(E(16,""+e))},deserialize:function(t){return U(t.getUint8Array(16))}}),int128:mt({name:"int128",serialize:function(t,e){t.pushArray(S(16,""+e))},deserialize:function(t){return T(t.getUint8Array(16))}}),float32:mt({name:"float32",serialize:function(t,e){t.pushFloat32(e)},deserialize:function(t){return t.getFloat32()}}),float64:mt({name:"float64",serialize:function(t,e){t.pushFloat64(e)},deserialize:function(t){return t.getFloat64()}}),float128:mt({name:"float128",serialize:function(t,e){t.pushUint8ArrayChecked(ot(e),16)},deserialize:function(t){return at(t.getUint8Array(16))}}),bytes:mt({name:"bytes",serialize:function(t,e){e instanceof Uint8Array||Array.isArray(e)?t.pushBytes(e):t.pushBytes(ot(e))},deserialize:function(t,e){return e&&e.options.bytesAsUint8Array?t.getBytes():at(t.getBytes())}}),string:mt({name:"string",serialize:function(t,e){t.pushString(e)},deserialize:function(t){return t.getString()}}),name:mt({name:"name",serialize:function(t,e){t.pushName(e)},deserialize:function(t){return t.getName()}}),time_point:mt({name:"time_point",serialize:function(t,e){t.pushNumberAsUint64($(e))},deserialize:function(t){return X(t.getUint64AsNumber())}}),time_point_sec:mt({name:"time_point_sec",serialize:function(t,e){t.pushUint32(Q(e))},deserialize:function(t){return tt(t.getUint32())}}),block_timestamp_type:mt({name:"block_timestamp_type",serialize:function(t,e){t.pushUint32(et(e))},deserialize:function(t){return rt(t.getUint32())}}),symbol_code:mt({name:"symbol_code",serialize:function(t,e){t.pushSymbolCode(e)},deserialize:function(t){return t.getSymbolCode()}}),symbol:mt({name:"symbol",serialize:function(t,e){t.pushSymbol(nt(e))},deserialize:function(t){return it(t.getSymbol())}}),asset:mt({name:"asset",serialize:function(t,e){t.pushAsset(e)},deserialize:function(t){return t.getAsset()}}),checksum160:mt({name:"checksum160",serialize:function(t,e){t.pushUint8ArrayChecked(ot(e),20)},deserialize:function(t){return at(t.getUint8Array(20))}}),checksum256:mt({name:"checksum256",serialize:function(t,e){t.pushUint8ArrayChecked(ot(e),32)},deserialize:function(t){return at(t.getUint8Array(32))}}),checksum512:mt({name:"checksum512",serialize:function(t,e){t.pushUint8ArrayChecked(ot(e),64)},deserialize:function(t){return at(t.getUint8Array(64))}}),public_key:mt({name:"public_key",serialize:function(t,e){t.pushPublicKey(e)},deserialize:function(t){return t.getPublicKey()}}),private_key:mt({name:"private_key",serialize:function(t,e){t.pushPrivateKey(e)},deserialize:function(t){return t.getPrivateKey()}}),signature:mt({name:"signature",serialize:function(t,e){t.pushSignature(e)},deserialize:function(t){return t.getSignature()}})}));return t.set("extended_asset",mt({name:"extended_asset",baseName:"",fields:[{name:"quantity",typeName:"asset",type:t.get("asset")},{name:"contract",typeName:"name",type:t.get("name")}],serialize:ct,deserialize:ft})),t},xt=function t(e,r){var n=e.get(r);if(n&&n.aliasOfName)return t(e,n.aliasOfName);if(n)return n;if(r.endsWith("[]"))return mt({name:r,arrayOf:t(e,r.substr(0,r.length-2)),serialize:lt,deserialize:dt});if(r.endsWith("?"))return mt({name:r,optionalOf:t(e,r.substr(0,r.length-1)),serialize:yt,deserialize:vt});if(r.endsWith("$"))return mt({name:r,extensionOf:t(e,r.substr(0,r.length-1)),serialize:gt,deserialize:bt});throw new Error("Unknown type: "+r)},At=function(t,e){var r=new Map(t);if(e.types)for(var n,i=y(e.types);!(n=i()).done;){var a=n.value,o=a.new_type_name;r.set(o,mt({name:o,aliasOfName:a.type}))}if(e.structs)for(var s,u=y(e.structs);!(s=u()).done;){var c=s.value,f=c.name;r.set(f,mt({name:f,baseName:c.base,fields:c.fields.map((function(t){return{name:t.name,typeName:t.type,type:void 0}})),serialize:ct,deserialize:ft}))}if(e.variants)for(var h,p=y(e.variants);!(h=p()).done;){var l=h.value,d=l.name;r.set(d,mt({name:d,fields:l.types.map((function(t){return{name:t,typeName:t,type:void 0}})),serialize:ht,deserialize:pt}))}for(var v,g=y(r);!(v=g()).done;){var b=v.value[1];b.baseName&&(b.base=xt(r,b.baseName));for(var m,w=y(b.fields);!(m=w()).done;){var _=m.value;_.type=xt(r,_.typeName)}}return r},kt=function(t,e){var r,n=t.header?t.header.timestamp:t.timestamp,i=parseInt((r=t.id.substr(16,8)).substr(6,2)+r.substr(4,2)+r.substr(2,2)+r.substr(0,2),16);return{expiration:tt(Q(n)+e),ref_block_num:65535&t.block_num,ref_block_prefix:i}},zt=function(t,e,r,n){var i=t.actions.get(r);if(!i)throw new Error("Unknown action "+r+" in contract "+e);var a=new Y;return i.serialize(a,n),at(a.asUint8Array())},Et=function(t,e,r,n,i){return{account:e,name:r,authorization:n,data:zt(t,e,r,i)}},St=function(t,e,r,n){var i=t.actions.get(r);if("string"==typeof n&&(n=ot(n)),!i)throw new Error("Unknown action "+r+" in contract "+e);var a=new Y;return a.pushArray(n),i.deserialize(a)},Ut=function(t,e,r,n,i){return{account:e,name:r,authorization:n,data:St(t,e,r,i)}},Tt={__proto__:null,SerializerState:H,SerialBuffer:Y,supportedAbiVersion:Z,dateToTimePoint:$,timePointToDate:X,dateToTimePointSec:Q,timePointSecToDate:tt,dateToBlockTimestamp:et,blockTimestampToDate:rt,stringToSymbol:nt,symbolToString:it,arrayToHex:at,hexToUint8Array:ot,createInitialTypes:_t,getType:xt,getTypesFromAbi:At,transactionHeader:kt,serializeActionData:zt,serializeAction:Et,deserializeActionData:St,deserializeAction:Ut},Pt=require("./abi.abi.json"),Ct=require("./transaction.abi.json"),Ot=function(){function t(t){this.contracts=new Map,this.cachedAbis=new Map,this.rpc=t.rpc,this.authorityProvider=t.authorityProvider||t.rpc,this.abiProvider=t.abiProvider||t.rpc,this.signatureProvider=t.signatureProvider,this.abiTypes=At(_t(),Pt),this.transactionTypes=At(_t(),Ct)}var r=t.prototype;return r.rawAbiToJson=function(t){var e=new Y({array:t});if(!Z(e.getString()))throw new Error("Unsupported abi version");return e.restartRead(),this.abiTypes.get("abi_def").deserialize(e)},r.jsonToRawAbi=function(t){var e=new Y;if(this.abiTypes.get("abi_def").serialize(e,t),!Z(e.getString()))throw new Error("Unsupported abi version");return e.asUint8Array()},r.getCachedAbi=function(){var t=s(b.mark((function t(e,r){var n,i,a;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0===r&&(r=!1),r||!this.cachedAbis.get(e)){t.next=3;break}return t.abrupt("return",this.cachedAbis.get(e));case 3:return t.prev=3,t.next=6,this.abiProvider.getRawAbi(e);case 6:a=this.rawAbiToJson(i=t.sent.abi),n={rawAbi:i,abi:a},t.next=15;break;case 11:throw t.prev=11,t.t0=t.catch(3),t.t0.message="fetching abi for "+e+": "+t.t0.message,t.t0;case 15:if(n){t.next=17;break}throw new Error("Missing abi for "+e);case 17:return this.cachedAbis.set(e,n),t.abrupt("return",n);case 19:case"end":return t.stop()}}),t,this,[[3,11]])})));return function(e,r){return t.apply(this,arguments)}}(),r.getAbi=function(){var t=s(b.mark((function t(e,r){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===r&&(r=!1),t.next=3,this.getCachedAbi(e,r);case 3:return t.abrupt("return",t.sent.abi);case 4:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.getTransactionAbis=function(){var t=s(b.mark((function t(e,r){var n,i,a,o,u=this;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===r&&(r=!1),n=(e.context_free_actions||[]).concat(e.actions),i=n.map((function(t){return t.account})),a=new Set(i),o=Array.from(a).map(function(){var t=s(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,u.getCachedAbi(e,r);case 2:return t.abrupt("return",{accountName:e,abi:t.sent.rawAbi});case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),t.abrupt("return",Promise.all(o));case 6:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),r.getContract=function(){var t=s(b.mark((function t(e,r){var n,i,a,o,s,u,c;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0===r&&(r=!1),r||!this.contracts.get(e)){t.next=3;break}return t.abrupt("return",this.contracts.get(e));case 3:return t.next=5,this.getAbi(e,r);case 5:for(n=t.sent,i=At(_t(),n),a=new Map,o=y(n.actions);!(s=o()).done;)a.set((u=s.value).name,xt(i,u.type));return this.contracts.set(e,c={types:i,actions:a}),t.abrupt("return",c);case 12:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.serialize=function(t,e,r){this.transactionTypes.get(e).serialize(t,r)},r.deserialize=function(t,e){return this.transactionTypes.get(e).deserialize(t)},r.serializeTransaction=function(t){var e=new Y;return this.serialize(e,"transaction",Object.assign({max_net_usage_words:0,max_cpu_usage_ms:0,delay_sec:0,context_free_actions:[],actions:[],transaction_extensions:[]},t)),e.asUint8Array()},r.serializeContextFreeData=function(t){if(t&&t.length){var e=new Y;e.pushVaruint32(t.length);for(var r,n=y(t);!(r=n()).done;)e.pushBytes(r.value);return e.asUint8Array()}},r.deserializeTransaction=function(t){var e=new Y;return e.pushArray(t),this.deserialize(e,"transaction")},r.serializeActions=function(){var t=s(b.mark((function t(e){var r=this;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Promise.all(e.map(function(){var t=s(b.mark((function t(e){var n,i,a,o;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.account,i=e.name,a=e.authorization,o=e.data,t.next=3,r.getContract(n);case 3:return t.abrupt("return",Et(t.sent,n,i,a,o));case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),r.deserializeActions=function(){var t=s(b.mark((function t(e){var r=this;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Promise.all(e.map(function(){var t=s(b.mark((function t(e){var n,i,a,o;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.account,i=e.name,a=e.authorization,o=e.data,t.next=3,r.getContract(n);case 3:return t.abrupt("return",Ut(t.sent,n,i,a,o));case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),r.deserializeActionsSync=function(){var t=s(b.mark((function t(e){var r,n,i,a,o,s,u,c;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=[],n=y(e);case 2:if((i=n()).done){t.next=10;break}return o=(a=i.value).account,s=a.name,u=a.authorization,c=a.data,t.next=6,this.getContract(o);case 6:r.push(Ut(t.sent,o,s,u,c));case 8:t.next=2;break;case 10:return t.abrupt("return",r);case 11:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.deserializeTransactionWithActions=function(){var t=s(b.mark((function t(e){var r,n;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return"string"==typeof e&&(e=ot(e)),r=this.deserializeTransaction(e),t.next=4,this.deserializeActionsSync(r.context_free_actions);case 4:return n=t.sent,t.next=7,this.deserializeActionsSync(r.actions);case 7:return t.abrupt("return",Object.assign({},r,{context_free_actions:n,actions:t.sent}));case 9:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.deflateSerializedArray=function(t){return e.deflate(t,{level:9})},r.inflateSerializedArray=function(t){return e.inflate(t)},r.transact=function(){var t=s(b.mark((function t(e,r){var n,i,a,o,s,u,c,f,h,p,l,d,y,v,g,m,w,_;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=void 0===(i=(n=void 0===r?{}:r).broadcast)||i,s=void 0===(o=n.sign)||o,u=n.compression,c=n.blocksBehind,f=n.useLastIrreversible,h=n.expireSeconds,p=n.requiredKeys,d=void 0===(l=n.transactionHeader)?void 0:l,t.next=3,this.rpc.get_info();case 3:if(y=t.sent,"number"!=typeof c||!f){t.next=7;break}throw new Error("Use either blocksBehind or useLastIrreversible");case 7:if(d){t.next=15;break}if("number"!=typeof c&&!f||!h){t.next=13;break}return t.next=11,this.generateTapos(y,c,f,h);case 11:d=t.sent;case 13:if(this.hasRequiredTaposFields(d)){t.next=15;break}throw new Error("Required configuration or TAPOS fields are not present");case 15:return t.next=17,this.getTransactionAbis(e);case 17:return v=t.sent,t.t0=Object,t.t1={},t.t2=d,t.next=23,this.serializeActions(e.context_free_actions||[]);case 23:return t.t3=t.sent,t.next=26,this.serializeActions(e.actions);case 26:if(t.t4=t.sent,t.t5={context_free_actions:t.t3,actions:t.t4},e=t.t0.assign.call(t.t0,t.t1,t.t2,t.t5),g=this.serializeTransaction(e),m=this.serializeContextFreeData(e.context_free_data),w={serializedTransaction:g,serializedContextFreeData:m,signatures:[]},!s){t.next=43;break}return t.next=35,this.signatureProvider.getAvailableKeys();case 35:if(_=t.sent,p){t.next=40;break}return t.next=39,this.authorityProvider.getRequiredKeys({transaction:e,availableKeys:_});case 39:p=t.sent;case 40:return t.next=42,this.signatureProvider.sign({chainId:y.chain_id,requiredKeys:p,serializedTransaction:g,serializedContextFreeData:m,abis:v});case 42:w=t.sent;case 43:if(!a){t.next=47;break}if(!u){t.next=46;break}return t.abrupt("return",this.pushCompressedSignedTransaction(w));case 46:return t.abrupt("return",this.pushSignedTransaction(w));case 47:return t.abrupt("return",Object.assign({},w,{transactionHeader:d}));case 48:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.pushSignedTransaction=function(){var t=s(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.rpc.push_transaction({signatures:e.signatures,serializedTransaction:e.serializedTransaction,serializedContextFreeData:e.serializedContextFreeData}));case 2:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.pushCompressedSignedTransaction=function(){var t=s(b.mark((function t(e){var r,n,i,a;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.signatures,n=e.serializedContextFreeData,i=this.deflateSerializedArray(e.serializedTransaction),a=this.deflateSerializedArray(n||new Uint8Array(0)),t.abrupt("return",this.rpc.push_transaction({signatures:r,compression:1,serializedTransaction:i,serializedContextFreeData:a}));case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.generateTapos=function(){var t=s(b.mark((function t(e,r,n,i){var a;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e){t.next=4;break}return t.next=3,this.rpc.get_info();case 3:e=t.sent;case 4:if(!((a=n?e.last_irreversible_block_num:e.head_block_num-r)<=e.last_irreversible_block_num)){t.next=11;break}return t.next=8,this.rpc.get_block(a);case 8:t.t0=t.sent,t.next=14;break;case 11:return t.next=13,this.tryGetBlockHeaderState(a);case 13:t.t0=t.sent;case 14:return t.abrupt("return",kt(t.t0,i));case 16:case"end":return t.stop()}}),t,this)})));return function(e,r,n,i){return t.apply(this,arguments)}}(),r.hasRequiredTaposFields=function(t){return!(!t.expiration||"number"!=typeof t.ref_block_num||"number"!=typeof t.ref_block_prefix)},r.tryGetBlockHeaderState=function(){var t=s(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.rpc.get_block_header_state(e);case 3:return t.abrupt("return",t.sent);case 6:return t.prev=6,t.t0=t.catch(0),t.next=10,this.rpc.get_block(e);case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t,this,[[0,6]])})));return function(e){return t.apply(this,arguments)}}(),t}(),Kt=function(t){var e,r;function n(e){var r;return r=e&&e.error&&e.error.details&&e.error.details.length&&e.error.details[0].message?t.call(this,e.error.details[0].message)||this:e&&e.processed&&e.processed.except&&e.processed.except.message?t.call(this,e.processed.except.message)||this:e?t.call(this,e.message)||this:t.call(this,e)||this,Object.setPrototypeOf(l(r),n.prototype),r.json=e,l(r)}return r=t,(e=n).prototype=Object.create(r.prototype),e.prototype.constructor=e,e.__proto__=r,n}(p(Error)),Nt=function(t){for(var e,r="",n=y(t);!(e=n()).done;)r+=("00"+e.value.toString(16)).slice(-2);return r},Bt=function(){function t(t,e){void 0===e&&(e={}),this.maxRetries=3,t=Array.isArray(t)?t:[t],this.endpoints=t.map((function(t){return t.replace(/\/$/,"")})),this.currentEndpoint="",this.nextEndpoint(),this.fetchBuiltin=e.fetch?e.fetch:global.fetch.bind(global)}var e=t.prototype;return e.fetchWithTimeout=function(t,e){return Promise.race([(0,this.fetchBuiltin)(t,e)])},e.nextEndpoint=function(){if(this.endpoints.length){if(this.currentEndpoint){var t=this.endpoints.shift();this.endpoints=this.endpoints.concat(t||[])}this.currentEndpoint=this.endpoints[0],console.log("Switched to API:",this.currentEndpoint)}},e.fetch=function(){var t=s(b.mark((function t(e,r,n){var i,a,o,s,u;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===n&&(n=0),t.prev=1,t.next=4,this.fetchWithTimeout(this.currentEndpoint+e,{body:JSON.stringify(r),method:"POST"});case 4:return i=t.sent,t.next=7,i.json();case 7:if(!(a=t.sent).processed||!a.processed.except){t.next=10;break}throw new Kt(a);case 10:t.next=27;break;case 12:if(t.prev=12,t.t0=t.catch(1),console.log("Error from",this.currentEndpoint,t.t0),console.log("Error response: ",i),console.log("Error json: ",a),console.log("Error body: ",r),t.t0.isFetchError=!0,!(this.endpoints.length>1)){t.next=27;break}if(this.nextEndpoint(),!(n<this.maxRetries)){t.next=26;break}return console.log("Retrying at try:",n),t.abrupt("return",this.fetch(e,r,++n));case 26:throw t.t0;case 27:if(i&&i.ok){t.next=29;break}throw new Kt(a);case 29:if(!a||!a.head_block_time){t.next=40;break}if(o=new Date(a.head_block_time+"Z").getTime(),s=(new Date).getTime(),!((u=(s-o)/1e3)>20&&this.endpoints.length>1)){t.next=40;break}if(console.log("API is SYNCING (behind)",this.currentEndpoint),console.log("Current Time: "+s+", Head Time: "+o+", Seconds Behind: "+u),this.nextEndpoint(),!(n<this.maxRetries)){t.next=40;break}return console.log("Retrying at try:",n),t.abrupt("return",this.fetch(e,r,++n));case 40:return t.abrupt("return",a);case 41:case"end":return t.stop()}}),t,this,[[1,12]])})));return function(e,r,n){return t.apply(this,arguments)}}(),e.get_abi=function(){var t=s(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch("/v1/chain/get_abi",{account_name:e});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.get_account=function(){var t=s(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch("/v1/chain/get_account",{account_name:e});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.get_block_header_state=function(){var t=s(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch("/v1/chain/get_block_header_state",{block_num_or_id:e});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.get_block=function(){var t=s(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch("/v1/chain/get_block",{block_num_or_id:e});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.get_code=function(){var t=s(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch("/v1/chain/get_code",{account_name:e,code_as_wasm:!0});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.get_currency_balance=function(){var t=s(b.mark((function t(e,r,n){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===n&&(n=null),t.next=3,this.fetch("/v1/chain/get_currency_balance",{code:e,account:r,symbol:n});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),e.get_currency_stats=function(){var t=s(b.mark((function t(e,r){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch("/v1/chain/get_currency_stats",{code:e,symbol:r});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.get_info=function(){var t=s(b.mark((function t(){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch("/v1/chain/get_info",{});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.get_producer_schedule=function(){var t=s(b.mark((function t(){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch("/v1/chain/get_producer_schedule",{});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.get_producers=function(){var t=s(b.mark((function t(e,r,n){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===e&&(e=!0),void 0===r&&(r=""),void 0===n&&(n=50),t.next=5,this.fetch("/v1/chain/get_producers",{json:e,lower_bound:r,limit:n});case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),e.get_raw_code_and_abi=function(){var t=s(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch("/v1/chain/get_raw_code_and_abi",{account_name:e});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.get_raw_abi=function(){var t=s(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch("/v1/chain/get_raw_abi",{account_name:e});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.getRawAbi=function(){var t=s(b.mark((function t(e){var r,n;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.get_raw_abi(e);case 2:return n=O((r=t.sent).abi),t.abrupt("return",{accountName:r.account_name,abi:n});case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.get_scheduled_transactions=function(){var t=s(b.mark((function t(e,r,n){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===e&&(e=!0),void 0===r&&(r=""),void 0===n&&(n=50),t.next=5,this.fetch("/v1/chain/get_scheduled_transactions",{json:e,lower_bound:r,limit:n});case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),e.get_activated_protocol_features=function(){var t=s(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===e&&(e=100),t.next=3,this.fetch("/v1/chain/get_activated_protocol_features",{limit:e});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.get_table_rows=function(){var t=s(b.mark((function t(e){var r,n,i,a,o,s,u,c,f,h,p,l,d,y,v,g,m,w,_,x,A;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=void 0===(r=e.json)||r,i=e.code,a=e.scope,o=e.table,u=void 0===(s=e.table_key)?"":s,f=void 0===(c=e.lower_bound)?"":c,p=void 0===(h=e.upper_bound)?"":h,d=void 0===(l=e.index_position)?1:l,v=void 0===(y=e.key_type)?"":y,m=void 0===(g=e.limit)?10:g,_=void 0!==(w=e.reverse)&&w,A=void 0!==(x=e.show_payer)&&x,t.next=3,this.fetch("/v1/chain/get_table_rows",{json:n,code:i,scope:a,table:o,table_key:u,lower_bound:f,upper_bound:p,index_position:d,key_type:v,limit:m,reverse:_,show_payer:A});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.get_table_by_scope=function(){var t=s(b.mark((function t(e){var r,n,i,a,o,s,u,c;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.code,n=e.table,a=void 0===(i=e.lower_bound)?"":i,s=void 0===(o=e.upper_bound)?"":o,c=void 0===(u=e.limit)?10:u,t.next=3,this.fetch("/v1/chain/get_table_by_scope",{code:r,table:n,lower_bound:a,upper_bound:s,limit:c});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.getRequiredKeys=function(){var t=s(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=L,t.next=3,this.fetch("/v1/chain/get_required_keys",{transaction:e.transaction,available_keys:e.availableKeys});case 3:return t.t1=t.sent.required_keys,t.abrupt("return",(0,t.t0)(t.t1));case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.push_transaction=function(){var t=s(b.mark((function t(e){var r,n,i,a,o;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.signatures,i=void 0===(n=e.compression)?0:n,a=e.serializedTransaction,o=e.serializedContextFreeData,t.prev=1,t.next=4,this.fetch("/v1/chain/push_transaction",{signatures:r,compression:i,packed_context_free_data:Nt(o||new Uint8Array(0)),packed_trx:Nt(a)});case 4:return t.abrupt("return",t.sent);case 7:throw t.prev=7,t.t0=t.catch(1),t.t0&&t.t0.json&&t.t0.json.error&&"expired_tx_exception"===t.t0.json.error.name&&(t.t0.json.error.message="Transaction Expired: Try Again",this.nextEndpoint()),t.t0;case 11:case"end":return t.stop()}}),t,this,[[1,7]])})));return function(e){return t.apply(this,arguments)}}(),e.send_transaction=function(){var t=s(b.mark((function t(e){var r,n,i,a,o;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.signatures,i=void 0===(n=e.compression)?0:n,a=e.serializedTransaction,o=e.serializedContextFreeData,t.next=3,this.fetch("/v1/chain/send_transaction",{signatures:r,compression:i,packed_context_free_data:Nt(o||new Uint8Array(0)),packed_trx:Nt(a)});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.db_size_get=function(){var t=s(b.mark((function t(){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch("/v1/db_size/get",{});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.history_get_actions=function(){var t=s(b.mark((function t(e,r,n){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===r&&(r=null),void 0===n&&(n=null),t.next=4,this.fetch("/v1/history/get_actions",{account_name:e,pos:r,offset:n});case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),e.history_get_transaction=function(){var t=s(b.mark((function t(e,r){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===r&&(r=null),t.next=3,this.fetch("/v1/history/get_transaction",{id:e,block_num_hint:r});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.history_get_key_accounts=function(){var t=s(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch("/v1/history/get_key_accounts",{public_key:e});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.history_get_controlled_accounts=function(){var t=s(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch("/v1/history/get_controlled_accounts",{controlling_account:e});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),t}(),jt=function(t){return new a.ec(t===v.k1?"secp256k1":"p256")},Rt=function(){function t(t,e){this.key=t,this.ec=e}t.fromString=function(e,r){var n=j(e);return r||(r=jt(n.type)),new t(n,r)},t.fromElliptic=function(e,r,n){var i=e.getPublic().getX().toArray("be",32),a=e.getPublic().getY().toArray("be",32);return n||(n=jt(r)),new t({type:r,data:new Uint8Array([1&a[31]?3:2].concat(i))},n)};var e=t.prototype;return e.toString=function(){return D(this.key)},e.toLegacyString=function(t){return R(this.key,t)},e.toElliptic=function(){return this.ec.keyPair({pub:Buffer.from(this.key.data)})},e.getType=function(){return this.key.type},e.isValid=function(){try{return this.toElliptic().validate().result}catch(t){return!1}},t}(),Dt=require("bn.js"),Ft=function(){function t(t,e){this.signature=t,this.ec=e}t.fromString=function(e,r){var n=M(e);return r||(r=jt(n.type)),new t(n,r)},t.fromElliptic=function(e,r,n){e.recoveryParam||(e.recoveryParam=0);var i,a=e.r.toArray("be",32),o=e.s.toArray("be",32);r===v.k1||r===v.r1?(i=e.recoveryParam+27,e.recoveryParam<=3&&(i+=4)):r===v.wa&&(i=e.recoveryParam);var s=new Uint8Array([i].concat(a,o));return n||(n=jt(r)),new t({type:r,data:s},n)};var e=t.prototype;return e.toElliptic=function(){var t,e=new Dt(this.signature.data.slice(1,33)),r=new Dt(this.signature.data.slice(33,65));return this.signature.type===v.k1||this.signature.type===v.r1?(t=this.signature.data[0]-27)>3&&(t-=4):t=this.signature.type===v.wa?this.signature.data[0]:0,{r:e,s:r,recoveryParam:3&t}},e.toString=function(){return G(this.signature)},e.toBinary=function(){return this.signature.data},e.getType=function(){return this.signature.type},e.verify=function(t,e,r,n){void 0===r&&(r=!0),void 0===n&&(n="utf8"),r&&("string"==typeof t&&(t=Buffer.from(t,n)),t=this.ec.hash().update(t).digest());var i=this.toElliptic(),a=e.toElliptic();return this.ec.verify(t,i,a,n)},e.recover=function(t,e,r){void 0===e&&(e=!0),void 0===r&&(r="utf8"),e&&("string"==typeof t&&(t=Buffer.from(t,r)),t=this.ec.hash().update(t).digest());var n=this.toElliptic(),i=this.ec.recoverPubKey(t,n,n.recoveryParam,r),a=this.ec.keyFromPublic(i);return Rt.fromElliptic(a,this.getType(),this.ec)},t}(),Lt=function(){function t(t,e){this.key=t,this.ec=e}t.fromElliptic=function(e,r,n){return n||(n=jt(r)),new t({type:r,data:e.getPrivate().toArrayLike(Buffer,"be",32)},n)},t.fromString=function(e,r){var n=I(e);return r||(r=jt(n.type)),new t(n,r)};var e=t.prototype;return e.toElliptic=function(){return this.ec.keyFromPrivate(this.key.data)},e.toLegacyString=function(){return V(this.key)},e.toString=function(){return q(this.key)},e.getType=function(){return this.key.type},e.getPublicKey=function(){var t=this.toElliptic();return Rt.fromElliptic(t,this.getType(),this.ec)},e.sign=function(t,e,r){var n=this;void 0===e&&(e=!0),void 0===r&&(r="utf8"),e&&("string"==typeof t&&(t=Buffer.from(t,r)),t=this.ec.hash().update(t).digest());var i,a,o=0,s=function(e){var r=n.toElliptic().sign(t,e);return Ft.fromElliptic(r,n.getType(),n.ec)};if(this.key.type===v.k1)do{i=s({canonical:!0,pers:[++o]})}while(128&(a=i.toBinary())[1]||0===a[1]&&!(128&a[2])||128&a[33]||!(0!==a[33]||128&a[34]));else i=s({canonical:!0});return i},e.isValid=function(){try{return this.toElliptic().validate().result}catch(t){return!1}},t}(),It={__proto__:null,generateKeyPair:function(t,e){if(void 0===e&&(e={}),!e.secureEnv)throw new Error("Key generation is completely INSECURE in production environments in the browser. If you are absolutely certain this does NOT describe your environment, set `secureEnv` in your options to `true`. If this does describe your environment and you set `secureEnv` to `true`, YOU DO SO AT YOUR OWN RISK AND THE RISK OF YOUR USERS.");var r,n=(r=new a.ec(t===v.k1?"secp256k1":"p256")).genKeyPair(e.ecOptions);return{publicKey:Rt.fromElliptic(n,t,r),privateKey:Lt.fromElliptic(n,t,r)}},PrivateKey:Lt,PublicKey:Rt,Signature:Ft,constructElliptic:jt,sha256:function(t){return r.sha256().update(t).digest()}},Vt=new a.ec("secp256k1"),qt=function(t,e,r,n){void 0===n&&(n=Vt);var i=Buffer.concat([Buffer.from(t,"hex"),Buffer.from(e),Buffer.from(r?new Uint8Array(n.hash().update(r).digest()):new Uint8Array(32))]);return n.hash().update(i).digest()},Mt=function(){function t(t){this.keys=new Map,this.availableKeys=[];for(var e,r=y(t);!(e=r()).done;){var n=Lt.fromString(e.value),i=n.toElliptic(),a=n.getPublicKey().toString();this.keys.set(a,i),this.availableKeys.push(a)}}var e=t.prototype;return e.getAvailableKeys=function(){var t=s(b.mark((function t(){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.availableKeys);case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.sign=function(){var t=s(b.mark((function t(e){var r,n,i,a,o,s,u,c,f,h,p,l;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(r=e.requiredKeys,a=qt(e.chainId,n=e.serializedTransaction,i=e.serializedContextFreeData,Vt),o=[],s=y(r);!(u=s()).done;)f=Rt.fromString(c=u.value),(h=this.keys.get(F(c)))&&(p=Lt.fromElliptic(h,f.getType()),l=p.sign(a,!1),o.push(l.toString()));return t.abrupt("return",{signatures:o,serializedTransaction:n,serializedContextFreeData:i});case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),t}(),Gt=function(){function t(){}return t.prototype.encode=function(t){for(var e=[],r=t.length,n=0;n<r;){var i=t.codePointAt(n),a=0,o=0;for(i<=127?(a=0,o=0):i<=2047?(a=6,o=192):i<=65535?(a=12,o=224):i<=2097151&&(a=18,o=240),e.push(o|i>>a),a-=6;a>=0;)e.push(128|i>>a&63),a-=6;n+=i>=65536?2:1}return new Uint8Array(e)},t}(),Wt=function(){function t(){}return t.prototype.decode=function(t){for(var e="",r=0;r<t.length;){var n=t[r],i=0,a=0;if(n<=127?(i=0,a=255&n):n<=223?(i=1,a=31&n):n<=239?(i=2,a=15&n):n<=244&&(i=3,a=7&n),t.length-r-i>0)for(var o=0;o<i;)a=a<<6|63&(n=t[r+o+1]),o+=1;else a=65533,i=t.length-r;e+=String.fromCodePoint(a),r+=i+1}return e},t}();exports.Api=Ot,exports.ApiInterfaces={__proto__:null},exports.JsSignatureProvider=Mt,exports.JsonRpc=Bt,exports.Key=It,exports.Numeric=W,exports.RpcError=Kt,exports.RpcInterfaces={__proto__:null},exports.Serialize=Tt,exports.TextDecoder=Wt,exports.TextEncoder=Gt; | ||
//# sourceMappingURL=protonjs.cjs.production.min.js.map |
{ | ||
"name": "@protonprotocol/protonjs", | ||
"version": "21.0.18", | ||
"version": "21.0.19", | ||
"description": "Javascript Interface to the Proton Blockchain", | ||
@@ -19,5 +19,5 @@ "module": "dist/index.js", | ||
"start": "tsdx watch", | ||
"build": "tsdx build", | ||
"build": "tsdx build && cp src/*.json dist", | ||
"test": "tsdx test", | ||
"prepare": "tsdx build", | ||
"prepare": "npm run build", | ||
"build-web": "webpack --config webpack.prod.js && webpack --config webpack.debug.js", | ||
@@ -24,0 +24,0 @@ "build-production": "yarn build && yarn build-web && yarn test-all", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
1157393
30
10920