jcc-ethereum-utils
Version:
Toolkit of crossing chain from Ethereum to SWTC chain
2 lines • 2.1 MB
JavaScript
/*! For license information please see jcc-ethereum-utils.min.js.LICENSE.txt */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.jcc_ethereum_utils=t():e.jcc_ethereum_utils=t()}(self,()=>(()=>{var e={1901(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=[{constant:!1,inputs:[{name:"_spender",type:"address"},{name:"_value",type:"uint256"}],name:"approve",outputs:[{name:"success",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"totalSupply",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transferFrom",outputs:[{name:"success",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"}],name:"balanceOf",outputs:[{name:"balance",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}],type:"function",stateMutability:"view"},{constant:!1,inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transfer",outputs:[{name:"success",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"},{name:"_spender",type:"address"}],name:"allowance",outputs:[{name:"remaining",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{anonymous:!1,inputs:[{indexed:!0,name:"_from",type:"address"},{indexed:!0,name:"_to",type:"address"},{indexed:!1,name:"_value",type:"uint256"}],name:"Transfer",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"_owner",type:"address"},{indexed:!0,name:"_spender",type:"address"},{indexed:!1,name:"_value",type:"uint256"}],name:"Approval",type:"event"}]},2481(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=[{constant:!0,inputs:[{name:"",type:"address"},{name:"",type:"address"},{name:"",type:"uint256"}],name:"tokens",outputs:[{name:"amount",type:"uint256"},{name:"jtaddress",type:"string"},{name:"progress",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"admin",outputs:[{name:"",type:"address"}],payable:!1,stateMutability:"view",type:"function"},{inputs:[{name:"_admin",type:"address"}],payable:!1,stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,name:"_token",type:"address"},{indexed:!0,name:"_caller",type:"address"},{indexed:!0,name:"_user",type:"address"},{indexed:!1,name:"_jtaddress",type:"string"},{indexed:!1,name:"_hash",type:"bytes32"},{indexed:!1,name:"_amount",type:"uint256"},{indexed:!1,name:"state",type:"uint256"}],name:"Deposit",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"_token",type:"address"},{indexed:!0,name:"_user",type:"address"},{indexed:!1,name:"_jthash",type:"bytes32"},{indexed:!1,name:"_amount",type:"uint256"},{indexed:!1,name:"_balance",type:"uint256"}],name:"Withdraw",type:"event"},{constant:!1,inputs:[{name:"_jtaddress",type:"string"}],name:"deposit",outputs:[],payable:!0,stateMutability:"payable",type:"function"},{constant:!1,inputs:[{name:"_jthash",type:"bytes32"},{name:"_address",type:"address"},{name:"_state",type:"uint256"}],name:"depositDone",outputs:[],payable:!0,stateMutability:"payable",type:"function"},{constant:!1,inputs:[{name:"_jthash",type:"bytes32"},{name:"_dest",type:"address"},{name:"_amount",type:"uint256"}],name:"withdraw",outputs:[],payable:!0,stateMutability:"payable",type:"function"},{constant:!1,inputs:[{name:"_jtaddress",type:"string"},{name:"_token",type:"address"},{name:"_amount",type:"uint256"},{name:"_hash",type:"bytes32"}],name:"depositToken",outputs:[],payable:!0,stateMutability:"payable",type:"function"},{constant:!1,inputs:[{name:"_jthash",type:"bytes32"},{name:"_address",type:"address"},{name:"_token",type:"address"},{name:"_state",type:"uint256"}],name:"depositTokenDone",outputs:[],payable:!0,stateMutability:"payable",type:"function"},{constant:!1,inputs:[{name:"_jthash",type:"bytes32"},{name:"_dest",type:"address"},{name:"_token",type:"address"},{name:"_amount",type:"uint256"}],name:"withdrawToken",outputs:[],payable:!0,stateMutability:"payable",type:"function"},{constant:!0,inputs:[],name:"depositTotal",outputs:[{name:"total",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"_token",type:"address"}],name:"depositTokenTotal",outputs:[{name:"total",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"_hash",type:"bytes32"}],name:"depositHistory",outputs:[{name:"state",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"_token",type:"address"},{name:"_user",type:"address"}],name:"depositState",outputs:[{name:"amount",type:"uint256"},{name:"jtaddress",type:"string"},{name:"state",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"}]},7962(e,t,r){"use strict";function n(){var e,t,r="function"==typeof Symbol?Symbol:{},i=r.iterator||"@@iterator",a=r.toStringTag||"@@toStringTag";function u(r,n,i,a){var u=n&&n.prototype instanceof c?n:c,f=Object.create(u.prototype);return o(f,"_invoke",function(r,n,o){var i,a,u,c=0,f=o||[],l=!1,d={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,r){return i=t,a=0,u=e,d.n=r,s}};function p(r,n){for(a=r,u=n,t=0;!l&&c&&!o&&t<f.length;t++){var o,i=f[t],p=d.p,h=i[2];r>3?(o=h===n)&&(u=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=e):i[0]<=p&&((o=r<2&&p<i[1])?(a=0,d.v=n,d.n=i[1]):p<h&&(o=r<3||i[0]>n||n>h)&&(i[4]=r,i[5]=n,d.n=h,a=0))}if(o||r>1)return s;throw l=!0,n}return function(o,f,h){if(c>1)throw TypeError("Generator is already running");for(l&&1===f&&p(f,h),a=f,u=h;(t=a<2?e:u)||!l;){i||(a?a<3?(a>1&&(d.n=-1),p(a,u)):d.n=u:d.v=u);try{if(c=2,i){if(a||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,a<2&&(a=0)}else 1===a&&(t=i.return)&&t.call(i),a<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),a=1);i=e}else if((t=(l=d.n<0)?u:r.call(n,d))!==s)break}catch(t){i=e,a=1,u=t}finally{c=1}}return{value:t,done:l}}}(r,i,a),!0),f}var s={};function c(){}function f(){}function l(){}t=Object.getPrototypeOf;var d=[][i]?t(t([][i]())):(o(t={},i,function(){return this}),t),p=l.prototype=c.prototype=Object.create(d);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,o(e,a,"GeneratorFunction")),e.prototype=Object.create(p),e}return f.prototype=l,o(p,"constructor",l),o(l,"constructor",f),f.displayName="GeneratorFunction",o(l,a,"GeneratorFunction"),o(p),o(p,a,"Generator"),o(p,i,function(){return this}),o(p,"toString",function(){return"[object Generator]"}),(n=function(){return{w:u,m:h}})()}function o(e,t,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}o=function(e,t,r,n){function a(t,r){o(e,t,function(e){return this._invoke(t,r,e)})}t?i?i(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(a("next",0),a("throw",1),a("return",2))},o(e,t,r,n)}function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,a(n.key),n)}}function a(e){var t=function(e,t){if("object"!=p(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=p(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==p(t)?t:t+""}function u(e,t,r){return t=l(t),function(e,t){if(t&&("object"==p(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,s()?Reflect.construct(t,r||[],l(e).constructor):t.apply(e,r))}function s(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(s=function(){return!!e})()}function c(e,t,r,n){var o=f(l(1&n?e.prototype:e),t,r);return 2&n&&"function"==typeof o?function(e){return o.apply(r,e)}:o}function f(){return f="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=l(e)););return e}(e,t);if(n){var o=Object.getOwnPropertyDescriptor(n,t);return o.get?o.get.call(arguments.length<3?e:r):o.value}},f.apply(null,arguments)}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}function d(e,t){return d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},d(e,t)}function p(e){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},p(e)}var h=this&&this.__decorate||function(e,t,r,n){var o,i=arguments.length,a=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"===("undefined"==typeof Reflect?"undefined":p(Reflect))&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var u=e.length-1;u>=0;u--)(o=e[u])&&(a=(i<3?o(a):i>3?o(t,r,a):o(t,r))||a);return i>3&&a&&Object.defineProperty(t,r,a),a},y=this&&this.__param||function(e,t){return function(r,n){t(r,n,e)}},v=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function a(e){try{s(n.next(e))}catch(e){i(e)}}function u(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,u)}s((n=n.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0});var m=r(5163),b=r(1901),g=r(3747),w=r(1763),E=r(8237),O=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),u(this,t)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&d(e,t)}(t,e),r=t,(o=[{key:"init",value:function(e,r){c(t,"init",this,3)([e,r,b.default])}},{key:"destroy",value:function(){c(t,"destroy",this,3)([])}},{key:"decimals",value:function(){var e=this,r=Object.create(null,{callABI:{get:function(){return c(t,"callABI",e,1)}}});return v(this,void 0,void 0,n().m(function e(){var t;return n().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,r.callABI.call(this,"decimals");case 1:return t=e.v,e.a(2,parseInt(t,10))}},e,this)}))}},{key:"balanceOf",value:function(e){var r=this,o=Object.create(null,{callABI:{get:function(){return c(t,"callABI",r,1)}}});return v(this,void 0,void 0,n().m(function t(){var r,i,a;return n().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,o.callABI.call(this,"balanceOf",e);case 1:return r=t.v,t.n=2,this.decimals();case 2:return i=t.v,a=new m.default(r).dividedBy(Math.pow(10,i)).toString(10),t.a(2,a)}},t,this)}))}},{key:"transfer",value:function(e,r,o,i){var a=this,u=Object.create(null,{callABI:{get:function(){return c(t,"callABI",a,1)}}});return v(this,void 0,void 0,n().m(function t(){var a,s,c,f,l,d,p,h,y,v,b;return n().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,this.decimals();case 1:return a=t.v,s=g.default.getAddress(e),c=this.ethereum.getWeb3(),f=c.utils.numberToHex(new m.default(o).multipliedBy(Math.pow(10,a)).toString(10)),t.n=2,this.ethereum.getGasPrice();case 2:if(l=t.v,void 0===i||!new m.default(i).isInteger()){t.n=3;break}b=i,t.n=5;break;case 3:return t.n=4,this.ethereum.getNonce(s);case 4:b=t.v;case 5:return d=b,t.n=6,u.callABI.call(this,"transfer",r,f);case 6:return p=t.v,h=this.ethereum.getTx(s,this.contractAddress,d,9e4,l,"0",p),t.n=7,this.ethereum.signTransaction(h,e);case 7:return y=t.v,t.n=8,this.ethereum.sendSignedTransaction(y);case 8:return v=t.v,t.a(2,v)}},t,this)}))}}])&&i(r.prototype,o),a&&i(r,a),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,o,a}(w.default);h([E.validate,y(0,E.isValidEthereumAddress)],O.prototype,"init",null),h([E.validate,y(0,E.isValidEthereumSecret),y(1,E.isValidEthereumAddress),y(2,E.isValidAmount)],O.prototype,"transfer",null),t.default=O},3747(e,t,r){"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function o(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return i(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,u=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return u=e.done,e},e:function(e){s=!0,a=e},f:function(){try{u||null==r.return||r.return()}finally{if(s)throw a}}}}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function a(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var a=n&&n.prototype instanceof c?n:c,f=Object.create(a.prototype);return u(f,"_invoke",function(r,n,o){var i,a,u,c=0,f=o||[],l=!1,d={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,r){return i=t,a=0,u=e,d.n=r,s}};function p(r,n){for(a=r,u=n,t=0;!l&&c&&!o&&t<f.length;t++){var o,i=f[t],p=d.p,h=i[2];r>3?(o=h===n)&&(u=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=e):i[0]<=p&&((o=r<2&&p<i[1])?(a=0,d.v=n,d.n=i[1]):p<h&&(o=r<3||i[0]>n||n>h)&&(i[4]=r,i[5]=n,d.n=h,a=0))}if(o||r>1)return s;throw l=!0,n}return function(o,f,h){if(c>1)throw TypeError("Generator is already running");for(l&&1===f&&p(f,h),a=f,u=h;(t=a<2?e:u)||!l;){i||(a?a<3?(a>1&&(d.n=-1),p(a,u)):d.n=u:d.v=u);try{if(c=2,i){if(a||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,a<2&&(a=0)}else 1===a&&(t=i.return)&&t.call(i),a<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),a=1);i=e}else if((t=(l=d.n<0)?u:r.call(n,d))!==s)break}catch(t){i=e,a=1,u=t}finally{c=1}}return{value:t,done:l}}}(r,o,i),!0),f}var s={};function c(){}function f(){}function l(){}t=Object.getPrototypeOf;var d=[][n]?t(t([][n]())):(u(t={},n,function(){return this}),t),p=l.prototype=c.prototype=Object.create(d);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,u(e,o,"GeneratorFunction")),e.prototype=Object.create(p),e}return f.prototype=l,u(p,"constructor",l),u(l,"constructor",f),f.displayName="GeneratorFunction",u(l,o,"GeneratorFunction"),u(p),u(p,o,"Generator"),u(p,n,function(){return this}),u(p,"toString",function(){return"[object Generator]"}),(a=function(){return{w:i,m:h}})()}function u(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}u=function(e,t,r,n){function i(t,r){u(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(i("next",0),i("throw",1),i("return",2))},u(e,t,r,n)}function s(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,c(n.key),n)}}function c(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t||"default");if("object"!=n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==n(t)?t:t+""}var f=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function a(e){try{s(n.next(e))}catch(e){i(e)}}function u(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,u)}s((n=n.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0});var l=r(2904),d=r(3772),p=r(5163),h=r(5009).Web3,y=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._web3=null,this._node=t,this._gasLimit=2e5,this._minGasPrice=5*Math.pow(10,9),this._defaultGasPrice=Math.pow(10,10),this._minFeePerGas=5*Math.pow(10,9),this._minPriorityFeePerGas=Math.pow(10,9)}return t=e,n=[{key:"isValidAddress",value:function(e){return l.ethWallet.isValidAddress(e)}},{key:"isValidSecret",value:function(e){return l.ethWallet.isValidSecret(e)}},{key:"getAddress",value:function(e){return l.ethWallet.getAddress(e)}},{key:"createWallet",value:function(){return l.ethWallet.createWallet()}},{key:"prefix0x",value:function(e){return e&&!e.startsWith("0x")&&(e="0x"+e),e}},{key:"filter0x",value:function(e){return"string"!=typeof e?e:e.startsWith("0x")?e.substring(2):e}}],(r=[{key:"gasLimit",get:function(){return this._gasLimit},set:function(e){this._gasLimit=e}},{key:"minGasPrice",get:function(){return this._minGasPrice},set:function(e){this._minGasPrice=e}},{key:"defaultGasPrice",get:function(){return this._defaultGasPrice},set:function(e){this._defaultGasPrice=e}},{key:"minFeePerGas",get:function(){return this._minFeePerGas},set:function(e){this._minFeePerGas=e}},{key:"minPriorityFeePerGas",get:function(){return this._minPriorityFeePerGas},set:function(e){this._minPriorityFeePerGas=e}},{key:"initWeb3",value:function(){if(!this._web3||!this._web3.currentProvider){var e;try{e=new URL(this._node)}catch(e){throw new Error("Invalid node URL: ".concat(this._node))}if(!["http:","https:","ws:","wss:"].includes(e.protocol))throw new Error('Unsupported URL scheme "'.concat(e.protocol,'". Allowed: http, https, ws, wss.'));this._web3=new h(new h.providers.HttpProvider(this._node))}}},{key:"destroyWeb3",value:function(){try{this._web3.setProvider(null)}catch(e){}finally{this._web3=null}}},{key:"getWeb3",value:function(){return this._web3}},{key:"getBlock",value:function(e){return f(this,void 0,void 0,a().m(function t(){var r;return a().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,t.n=1,this._web3.eth.getBlock(e);case 1:r=t.v,t.n=3;break;case 2:t.p=2,t.v,r=null;case 3:return t.a(2,r)}},t,this,[[0,2]])}))}},{key:"getBalance",value:function(e){return f(this,void 0,void 0,a().m(function t(){var r,n;return a().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,this._web3.eth.getBalance(e);case 1:return r=t.v,n=this._web3.utils.fromWei(r,"ether"),t.a(2,n)}},t,this)}))}},{key:"getGasPrice",value:function(){return f(this,void 0,void 0,a().m(function e(){var t,r;return a().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,this._web3.eth.getGasPrice();case 1:return t=e.v,r=new p.BigNumber(t),e.a(2,r.lte(this._minGasPrice)?this._minGasPrice:r.toNumber());case 2:return e.p=2,e.v,e.a(2,this._defaultGasPrice)}},e,this,[[0,2]])}))}},{key:"getFeeData",value:function(){return f(this,void 0,void 0,a().m(function e(){var t,r,n,o;return a().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,this._web3.eth.calculateFeeData();case 1:return t=e.v,r=new p.BigNumber(t.gasPrice),t.gasPrice=r.lte(this._minGasPrice)?this._minGasPrice:r.toNumber(),t.baseFeePerGas&&(n=new p.BigNumber(t.maxFeePerGas),o=new p.BigNumber(t.maxPriorityFeePerGas),t.baseFeePerGas=new p.BigNumber(t.baseFeePerGas).toNumber(),t.maxFeePerGas=n.lte(this._minGasPrice)?this._minGasPrice:n.toNumber(),t.maxPriorityFeePerGas=o.lte(this._minPriorityFeePerGas)?this._minPriorityFeePerGas:o.toNumber()),e.a(2,t);case 2:return e.p=2,e.v,e.a(2,{gasPrice:this._defaultGasPrice})}},e,this,[[0,2]])}))}},{key:"getNonce",value:function(t){return f(this,void 0,void 0,a().m(function r(){var n;return a().w(function(r){for(;;)switch(r.p=r.n){case 0:return t=e.prefix0x(t),r.p=1,r.n=2,this._web3.eth.getTransactionCount(t);case 2:return n=r.v,r.a(2,new p.BigNumber(n).toNumber());case 3:throw r.p=3,r.v;case 4:return r.a(2)}},r,this,[[1,3]])}))}},{key:"hasPendingTransactions",value:function(t){return f(this,void 0,void 0,a().m(function r(){var n,i,u,s,c,f;return a().w(function(r){for(;;)switch(r.p=r.n){case 0:return r.p=0,r.n=1,this._web3.eth.getPendingTransactions();case 1:n=r.v,t=e.prefix0x(t).toLowerCase(),i=!1,u=o(n),r.p=2,u.s();case 3:if((s=u.n()).done){r.n=5;break}if(c=s.value,!t.includes(c.from.toLowerCase())){r.n=4;break}return i=!0,r.a(3,5);case 4:r.n=3;break;case 5:r.n=7;break;case 6:r.p=6,f=r.v,u.e(f);case 7:return r.p=7,u.f(),r.f(7);case 8:return r.a(2,i);case 9:throw r.p=9,r.v;case 10:return r.a(2)}},r,this,[[2,6,7,8],[0,9]])}))}},{key:"hasPendingBlockTransactions",value:function(t){return f(this,void 0,void 0,a().m(function r(){var n,i,u,s,c,f;return a().w(function(r){for(;;)switch(r.p=r.n){case 0:return r.p=0,r.n=1,this._web3.eth.getBlock("pending",!0);case 1:n=r.v,t=e.prefix0x(t).toLowerCase(),i=!1,u=o(n.transactions),r.p=2,u.s();case 3:if((s=u.n()).done){r.n=5;break}if(c=s.value,!t.includes(c.from.toLowerCase())){r.n=4;break}return i=!0,r.a(3,5);case 4:r.n=3;break;case 5:r.n=7;break;case 6:r.p=6,f=r.v,u.e(f);case 7:return r.p=7,u.f(),r.f(7);case 8:return r.a(2,i);case 9:throw r.p=9,r.v;case 10:return r.a(2)}},r,this,[[2,6,7,8],[0,9]])}))}},{key:"getTx",value:function(e,t,r,n,o,i,a){return{data:a||"0x0",from:e,gas:this._web3.utils.numberToHex(n),gasPrice:this._web3.utils.numberToHex(o),nonce:r,to:t,value:(null==i?void 0:i.startsWith("0x"))?i:this._web3.utils.numberToHex(this._web3.utils.toWei(i+"","ether"))}}},{key:"get1559Tx",value:function(e,t,r,n,o,i,a,u){return{from:e,to:t,nonce:r,value:(null==a?void 0:a.startsWith("0x"))?a:this._web3.utils.numberToHex(this._web3.utils.toWei(a+"","ether")),gasLimit:this._web3.utils.numberToHex(n),maxFeePerGas:this._web3.utils.numberToHex(o),maxPriorityFeePerGas:this._web3.utils.numberToHex(i),data:u||"0x0"}}},{key:"signTransaction",value:function(e,t){return f(this,void 0,void 0,a().m(function r(){var n;return a().w(function(r){for(;;)switch(r.n){case 0:return r.n=1,this._web3.eth.accounts.signTransaction(e,t);case 1:return n=r.v,r.a(2,n.rawTransaction)}},r,this)}))}},{key:"sendSignedTransaction",value:function(e){return f(this,void 0,void 0,a().m(function t(){var r;return a().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,t.n=1,this._web3.eth.sendSignedTransaction(e);case 1:if(!1!==(r=t.v).status&&r.status!==BigInt(0)){t.n=2;break}throw new Error("Transaction reverted on-chain: ".concat(r.transactionHash));case 2:return t.a(2,r.transactionHash);case 3:throw t.p=3,t.v;case 4:return t.a(2)}},t,this,[[0,3]])}))}},{key:"getTransaction",value:function(e){return f(this,void 0,void 0,a().m(function t(){var r;return a().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,t.n=1,this._web3.eth.getTransaction(e);case 1:return r=t.v,t.a(2,r);case 2:throw t.p=2,t.v;case 3:return t.a(2)}},t,this,[[0,2]])}))}},{key:"getTransactionReceipt",value:function(e){return f(this,void 0,void 0,a().m(function t(){var r;return a().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,t.n=1,this._web3.eth.getTransactionReceipt(e);case 1:return r=t.v,t.a(2,r);case 2:throw t.p=2,t.v;case 3:return t.a(2)}},t,this,[[0,2]])}))}},{key:"contract",value:function(e,t){return new this._web3.eth.Contract(e,t)}},{key:"contractInitialied",value:function(e,t){return e instanceof d.Contract&&!!e.options.address&&e.options.address.toLowerCase()===t.toLowerCase()}}])&&s(t.prototype,r),n&&s(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r,n}();t.default=y},8138(e,t,r){"use strict";function n(){var e,t,r="function"==typeof Symbol?Symbol:{},i=r.iterator||"@@iterator",a=r.toStringTag||"@@toStringTag";function u(r,n,i,a){var u=n&&n.prototype instanceof c?n:c,f=Object.create(u.prototype);return o(f,"_invoke",function(r,n,o){var i,a,u,c=0,f=o||[],l=!1,d={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,r){return i=t,a=0,u=e,d.n=r,s}};function p(r,n){for(a=r,u=n,t=0;!l&&c&&!o&&t<f.length;t++){var o,i=f[t],p=d.p,h=i[2];r>3?(o=h===n)&&(u=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=e):i[0]<=p&&((o=r<2&&p<i[1])?(a=0,d.v=n,d.n=i[1]):p<h&&(o=r<3||i[0]>n||n>h)&&(i[4]=r,i[5]=n,d.n=h,a=0))}if(o||r>1)return s;throw l=!0,n}return function(o,f,h){if(c>1)throw TypeError("Generator is already running");for(l&&1===f&&p(f,h),a=f,u=h;(t=a<2?e:u)||!l;){i||(a?a<3?(a>1&&(d.n=-1),p(a,u)):d.n=u:d.v=u);try{if(c=2,i){if(a||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,a<2&&(a=0)}else 1===a&&(t=i.return)&&t.call(i),a<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),a=1);i=e}else if((t=(l=d.n<0)?u:r.call(n,d))!==s)break}catch(t){i=e,a=1,u=t}finally{c=1}}return{value:t,done:l}}}(r,i,a),!0),f}var s={};function c(){}function f(){}function l(){}t=Object.getPrototypeOf;var d=[][i]?t(t([][i]())):(o(t={},i,function(){return this}),t),p=l.prototype=c.prototype=Object.create(d);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,o(e,a,"GeneratorFunction")),e.prototype=Object.create(p),e}return f.prototype=l,o(p,"constructor",l),o(l,"constructor",f),f.displayName="GeneratorFunction",o(l,a,"GeneratorFunction"),o(p),o(p,a,"Generator"),o(p,i,function(){return this}),o(p,"toString",function(){return"[object Generator]"}),(n=function(){return{w:u,m:h}})()}function o(e,t,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}o=function(e,t,r,n){function a(t,r){o(e,t,function(e){return this._invoke(t,r,e)})}t?i?i(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(a("next",0),a("throw",1),a("return",2))},o(e,t,r,n)}function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,a(n.key),n)}}function a(e){var t=function(e,t){if("object"!=p(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=p(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==p(t)?t:t+""}function u(e,t,r){return t=l(t),function(e,t){if(t&&("object"==p(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,s()?Reflect.construct(t,r||[],l(e).constructor):t.apply(e,r))}function s(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(s=function(){return!!e})()}function c(e,t,r,n){var o=f(l(1&n?e.prototype:e),t,r);return 2&n&&"function"==typeof o?function(e){return o.apply(r,e)}:o}function f(){return f="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=l(e)););return e}(e,t);if(n){var o=Object.getOwnPropertyDescriptor(n,t);return o.get?o.get.call(arguments.length<3?e:r):o.value}},f.apply(null,arguments)}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}function d(e,t){return d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},d(e,t)}function p(e){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},p(e)}var h=this&&this.__decorate||function(e,t,r,n){var o,i=arguments.length,a=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"===("undefined"==typeof Reflect?"undefined":p(Reflect))&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var u=e.length-1;u>=0;u--)(o=e[u])&&(a=(i<3?o(a):i>3?o(t,r,a):o(t,r))||a);return i>3&&a&&Object.defineProperty(t,r,a),a},y=this&&this.__param||function(e,t){return function(r,n){t(r,n,e)}},v=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function a(e){try{s(n.next(e))}catch(e){i(e)}}function u(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,u)}s((n=n.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0});var m=r(5163),b=r(2481),g=r(3747),w=r(1763),E=r(8237),O=function(e){function t(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(e=u(this,t))._etherGasLimit=15e4,e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&d(e,t)}(t,e),r=t,o=[{key:"etherGasLimit",get:function(){return this._etherGasLimit},set:function(e){this._etherGasLimit=e}},{key:"init",value:function(e,r){c(t,"init",this,3)([e,r,b.default])}},{key:"initErc20",value:function(e){this._erc20=e}},{key:"destroy",value:function(){c(t,"destroy",this,3)([])}},{key:"isPending",value:function(e){return"0"!==e[0].toString(10)||""!==e[1]}},{key:"depositState",value:function(e){var r=this,o=Object.create(null,{callABI:{get:function(){return c(t,"callABI",r,1)}}});return v(this,arguments,void 0,function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"0x0000000000000000000000000000000000000000";return n().m(function i(){var a;return n().w(function(n){for(;;)switch(n.n){case 0:return e=g.default.prefix0x(e),n.n=1,o.callABI.call(t,"depositState",r,e);case 1:return a=n.v,n.a(2,a)}},i)})()})}},{key:"deposit",value:function(e,r,o,i){var a=this,u=Object.create(null,{callABI:{get:function(){return c(t,"callABI",a,1)}}});return v(this,void 0,void 0,n().m(function t(){var a,s,c,f,l,d,p,h;return n().w(function(t){for(;;)switch(t.n){case 0:return a=g.default.getAddress(e),t.n=1,u.callABI.call(this,"deposit",r);case 1:return s=t.v,t.n=2,this.ethereum.getGasPrice();case 2:if(c=t.v,void 0===i||!new m.default(i).isInteger()){t.n=3;break}h=i,t.n=5;break;case 3:return t.n=4,this.ethereum.getNonce(a);case 4:h=t.v;case 5:return f=h,l=this.ethereum.getTx(a,this.contractAddress,f,this.etherGasLimit,c,o,s),t.n=6,this.ethereum.signTransaction(l,e);case 6:return d=t.v,t.n=7,this.ethereum.sendSignedTransaction(d);case 7:return p=t.v,t.a(2,p)}},t,this)}))}},{key:"depositToken",value:function(e,r,o,i,a,u,s){var f=this,l=Object.create(null,{callABI:{get:function(){return c(t,"callABI",f,1)}}});return v(this,void 0,void 0,n().m(function t(){var c,f,d,p,h,y,v,b,w;return n().w(function(t){for(;;)switch(t.n){case 0:if(c=this.ethereum.getWeb3().utils.numberToHex(new m.default(i).multipliedBy(Math.pow(10,o)).toString(10)),f=g.default.getAddress(u),void 0===s||!new m.default(s).isInteger()){t.n=1;break}w=s,t.n=3;break;case 1:return t.n=2,this.ethereum.getNonce(f);case 2:w=t.v;case 3:return d=w,t.n=4,this.ethereum.getGasPrice();case 4:return p=t.v,t.n=5,l.callABI.call(this,"depositToken",e,r,c,a);case 5:return h=t.v,y=this.ethereum.getTx(f,this.contractAddress,d,45e4,p,"0",h),t.n=6,this.ethereum.signTransaction(y,u);case 6:return v=t.v,t.n=7,this.ethereum.sendSignedTransaction(v);case 7:return b=t.v,t.a(2,b)}},t,this)}))}},{key:"depositErc20",value:function(e,r,o,i){var a=this,u=Object.create(null,{callABI:{get:function(){return c(t,"callABI",a,1)}}});return v(this,void 0,void 0,n().m(function t(){var a,s,c,f,l,d,p,h,y,v,b,w,E,O,S,A;return n().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,this._erc20.decimals();case 1:return a=t.v,s=this.ethereum.getWeb3(),c=g.default.getAddress(e),f=s.utils.numberToHex(new m.default(o).multipliedBy(Math.pow(10,a)).toString(10)),t.n=2,this.ethereum.getGasPrice();case 2:if(l=t.v,void 0===i||!new m.default(i).isInteger()){t.n=3;break}A=i,t.n=5;break;case 3:return t.n=4,this.ethereum.getNonce(c);case 4:A=t.v;case 5:return d=A,t.n=6,this._erc20.callABI("transfer",this.contractAddress,f);case 6:return p=t.v,h=this.ethereum.getTx(c,this._erc20.contractAddress,d,9e4,l,"0",p),t.n=7,this.ethereum.signTransaction(h,e);case 7:return y=t.v,v=s.utils.sha3(y),t.n=8,u.callABI.call(this,"depositToken",r,this._erc20.contractAddress,f,v);case 8:return b=t.v,w=this.ethereum.getTx(c,this.contractAddress,new m.default(d).plus(1).toNumber(),45e4,l,"0",b),t.n=9,this.ethereum.signTransaction(w,e);case 9:return E=t.v,(O=new s.BatchRequest).add({jsonrpc:"2.0",id:1,method:"eth_sendRawTransaction",params:[y]}),O.add({jsonrpc:"2.0",id:2,method:"eth_sendRawTransaction",params:[E]}),t.n=10,O.execute();case 10:return S=t.v,t.a(2,S.map(function(e){return e.result}))}},t,this)}))}}],o&&i(r.prototype,o),a&&i(r,a),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,o,a}(w.default);h([E.validate,y(0,E.isValidEthereumAddress)],O.prototype,"init",null),h([E.validate,y(0,E.isValidEthereumAddress),y(1,E.isValidEthereumAddress)],O.prototype,"depositState",null),h([E.validate,y(0,E.isValidEthereumSecret),y(1,E.isValidJingtumAddress),y(2,E.isValidAmount)],O.prototype,"deposit",null),h([E.validate,y(0,E.isValidJingtumAddress),y(1,E.isValidEthereumAddress),y(3,E.isValidAmount),y(4,E.isValidHash),y(5,E.isValidEthereumSecret)],O.prototype,"depositToken",null),h([E.validate,y(0,E.isValidEthereumSecret),y(1,E.isValidJingtumAddress),y(2,E.isValidAmount)],O.prototype,"depositErc20",null),t.default=O},1763(e,t,r){"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function o(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",a=r.toStringTag||"@@toStringTag";function u(r,n,o,a){var u=n&&n.prototype instanceof c?n:c,f=Object.create(u.prototype);return i(f,"_invoke",function(r,n,o){var i,a,u,c=0,f=o||[],l=!1,d={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,r){return i=t,a=0,u=e,d.n=r,s}};function p(r,n){for(a=r,u=n,t=0;!l&&c&&!o&&t<f.length;t++){var o,i=f[t],p=d.p,h=i[2];r>3?(o=h===n)&&(u=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=e):i[0]<=p&&((o=r<2&&p<i[1])?(a=0,d.v=n,d.n=i[1]):p<h&&(o=r<3||i[0]>n||n>h)&&(i[4]=r,i[5]=n,d.n=h,a=0))}if(o||r>1)return s;throw l=!0,n}return function(o,f,h){if(c>1)throw TypeError("Generator is already running");for(l&&1===f&&p(f,h),a=f,u=h;(t=a<2?e:u)||!l;){i||(a?a<3?(a>1&&(d.n=-1),p(a,u)):d.n=u:d.v=u);try{if(c=2,i){if(a||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,a<2&&(a=0)}else 1===a&&(t=i.return)&&t.call(i),a<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),a=1);i=e}else if((t=(l=d.n<0)?u:r.call(n,d))!==s)break}catch(t){i=e,a=1,u=t}finally{c=1}}return{value:t,done:l}}}(r,o,a),!0),f}var s={};function c(){}function f(){}function l(){}t=Object.getPrototypeOf;var d=[][n]?t(t([][n]())):(i(t={},n,function(){return this}),t),p=l.prototype=c.prototype=Object.create(d);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,i(e,a,"GeneratorFunction")),e.prototype=Object.create(p),e}return f.prototype=l,i(p,"constructor",l),i(l,"constructor",f),f.displayName="GeneratorFunction",i(l,a,"GeneratorFunction"),i(p),i(p,a,"Generator"),i(p,n,function(){return this}),i(p,"toString",function(){return"[object Generator]"}),(o=function(){return{w:u,m:h}})()}function i(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}i=function(e,t,r,n){function a(t,r){i(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(a("next",0),a("throw",1),a("return",2))},i(e,t,r,n)}function a(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,u(n.key),n)}}function u(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t||"default");if("object"!=n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==n(t)?t:t+""}var s=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function a(e){try{s(n.next(e))}catch(e){i(e)}}function u(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,u)}s((n=n.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0});var c=r(887),f=function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._contract=null,this._address=null,this._ethereum=null},t=[{key:"ethereum",get:function(){return this._ethereum}},{key:"contract",get:function(){return this._contract}},{key:"contractAddress",get:function(){return this._contract.options.address}},{key:"init",value:function(e,t,r){try{t.contractInitialied(this._contract,e)||(this._address=e,this._ethereum=t,this._abi=r,this._contract=this._ethereum.contract(this._abi,this._address),this.interface=new c.Interface(this._abi))}catch(e){throw e}}},{key:"destroy",value:function(){this._contract=null}},{key:"callABI",value:function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return s(this,void 0,void 0,o().m(function t(){var n,i,a;return o().w(function(t){for(;;)switch(t.n){case 0:if(n=this.interface.getFunction(e)){t.n=1;break}throw new Error("".concat(e," is not defined in the contract ABI."));case 1:if("view"!==(i=n.stateMutability)&&"pure"!==i){t.n=3;break}return t.n=2,(a=this._contract.methods)[e].apply(a,r).call();case 2:case 4:return t.a(2,t.v);case 3:return t.n=4,this.interface.encodeFunctionData(e,r)}},t,this)}))}}],t&&a(e.prototype,t),r&&a(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r}();t.default=f},8237(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validate=t.isValidAmount=t.isValidHash=t.isValidJingtumAddress=t.isValidEthereumSecret=t.isValidEthereumAddress=void 0;var n=r(5163),o=r(2904),i=r(2904),a=Symbol(),u=Symbol(),s=Symbol(),c=Symbol(),f=Symbol(),l=Symbol(),d=function(e,t,r,n){e[a]=e[a]||{},e[a][t]=e[a][t]||{},e[a][t].params=e[a][t].params||[],e[a][t].params[r]=n};t.isValidEthereumAddress=function(e,t,r){d(e,t,r,u)};t.isValidEthereumSecret=function(e,t,r){d(e,t,r,c)};t.isValidJingtumAddress=function(e,t,r){d(e,t,r,s)};t.isValidHash=function(e,t,r){d(e,t,r,f)};t.isValidAmount=function(e,t,r){d(e,t,r,l)};var p=function(e){return String(e).replace(/[\r\n\t]/g," ").substring(0,100)};t.validate=function(e,t,r){var d=r.value;r.value=function(){var r=e[a][t].params;if(Array.isArray(r))for(var h=r.length,y=0;y<h;y++){var v=r[y],m=arguments[y];switch(v){case u:if("depositState"===t&&1===y&&void 0===m&&(m="0x0000000000000000000000000000000000000000"),!o.ethWallet.isValidAddress(m))throw new Error("".concat(p(m)," is invalid ethereum address."));break;case c:if(!o.ethWallet.isValidSecret(m))throw new Error("".concat(p(m)," is invalid ethereum secret."));break;case l:var b=new n.default(m);if(!n.default.isBigNumber(b)||!b.isGreaterThan(0))throw new Error("".concat(p(m)," is invalid amount."));break;case f:if(!/^0x([A-Fa-f0-9]{64})$/.test(m))throw new Error("".concat(p(m)," is invalid hash."));break;case s:if(!i.jtWallet.isValidAddress(m))throw new Error("".concat(p(m)," is invalid jingtum address."))}}return d.apply(this,arguments)}}},7860(e,t){"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function n(e){if(Array.isArray(e)){for(var t=[],r=0,o=0;o<e.length;o++){var i=n(e[o]);t.push(i),r+=i.length}return p.apply(void 0,[a(r,192)].concat(t))}var u=m(e);return 1===u.length&&u[0]<128?u:p(a(u.length,128),u)}function o(e,t,r){if(r>e.length)throw new Error("invalid RLP (safeSlice): end slice of Uint8Array out-of-bounds");return e.slice(t,r)}function i(e){if(0===e[0])throw new Error("invalid RLP: extra zeros");return l(f(e))}function a(e,t){if(e<56)return Uint8Array.from([e+t]);var r=y(e),n=y(t+55+r.length/2);return Uint8Array.from(d(n+r))}function u(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(null==e||0===e.length)return Uint8Array.from([]);var r=s(m(e));if(t)return r;if(0!==r.remainder.length)throw new Error("invalid RLP: remainder must be zero");return r.data}function s(e){var t,r,n,a,u,c=[],f=e[0];if(f<=127)return{data:e.slice(0,1),remainder:e.slice(1)};if(f<=183){if(t=f-127,n=128===f?Uint8Array.from([]):o(e,1,t),2===t&&n[0]<128)throw new Error("invalid RLP encoding: invalid prefix, single byte < 0x80 are not prefixed");return{data:n,remainder:e.slice(t)}}if(f<=191){if(r=f-182,e.length-1<r)throw new Error("invalid RLP: not enough bytes for string length");if((t=i(o(e,1,r)))<=55)throw new Error("invalid RLP: expected string length to be greater than 55");return{data:n=o(e,r,t+r),remainder:e.slice(t+r)}}if(f<=247){for(a=o(e,1,t=f-191);a.length;)u=s(a),c.push(u.data),a=u.remainder;return{data:c,remainder:e.slice(t)}}if((t=i(o(e,1,r=f-246)))<56)throw new Error("invalid RLP: encoded list too short");var l=r+t;if(l>e.length)throw new Error("invalid RLP: total length is larger than the data");for(a=o(e,r,l);a.length;)u=s(a),c.push(u.data),a=u.remainder;return{data:c,remainder:e.slice(l)}}Object.defineProperty(t,"__esModule",{value:!0}),t.RLP=t.utils=t.decode=t.encode=void 0,t.encode=n,t.decode=u;var c=Array.from({length:256},function(e,t){return t.toString(16).padStart(2,"0")});function f(e){for(var t="",r=0;r<e.length;r++)t+=c[e[r]];return t}function l(e){var t=Number.parseInt(e,16);if(Number.isNaN(t))throw new Error("Invalid byte sequence");return t}function d(e){if("string"!=typeof e)throw new TypeError("hexToBytes: expected string, got "+r(e));if(e.length%2)throw new Error("hexToBytes: received invalid unpadded hex");for(var t=new Uint8Array(e.length/2),n=0;n<t.length;n++){var o=2*n;t[n]=l(e.slice(o,o+2))}return t}function p(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];if(1===t.length)return t[0];for(var n=t.reduce(function(e,t){return e+t.length},0),o=new Uint8Array(n),i=0,a=0;i<t.length;i++){var u=t[i];o.set(u,a),a+=u.length}return o}function h(e){return(new TextEncoder).encode(e)}function y(e){if(e<0)throw new Error("Invalid integer as argument, must be unsigned!");var t=e.toString(16);return t.length%2?"0".concat(t):t}function v(e){return e.length>=2&&"0"===e[0]&&"x"===e[1]}function m(e){if(e instanceof Uint8Array)return e;if("string"==typeof e)return v(e)?d((t="string"!=typeof(n=e)?n:v(n)?n.slice(2):n).length%2?"0".concat(t):t):h(e);var t,n;if("number"==typeof e||"bigint"==typeof e)return e?d(y(e)):Uint8Array.from([]);if(null==e)return Uint8Array.from([]);throw new Error("toBytes: received unsupported type "+r(e))}t.utils={bytesToHex:f,concatBytes:p,hexToBytes:d,utf8ToBytes:h},t.RLP={encode:n,decode:u}},887(e,t,r){"use strict";r.r(t),r.d(t,{AbiCoder:()=>tn,ConstructorFragment:()=>_e,ErrorFragment:()=>Pe,EventFragment:()=>Ee,FormatTypes:()=>ve,Fragment:()=>we,FunctionFragment:()=>ke,Indexed:()=>gn,Interface:()=>On,LogDescription:()=>vn,ParamType:()=>be,TransactionDescription:()=>mn,checkResultErrors:()=>Fe,defaultAbiCoder:()=>rn});var n=r(9337),o=r.n(n);function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function a(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,u(n.key),n)}}function u(e){var t=function(e,t){if("object"!=i(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=i(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==i(t)?t:t+""}var s=!1,c=!1,f={debug:1,default:2,info:2,warning:3,error:4,off:5},l=null;var d,p,h=function(){try{var e=[];if(["NFD","NFC","NFKD","NFKC"].forEach(function(t){try{if("test"!=="test".normalize(t))throw new Error("bad normalize")}catch(r){e.push(t)}}),e.length)throw new Error("missing "+e.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(e){return e.message}return null}();!function(e){e.DEBUG="DEBUG",e.INFO="INFO",e.WARNING="WARNING",e.ERROR="ERROR",e.OFF="OFF"}(d||(d={})),function(e){e.UNKNOWN_ERROR="UNKNOWN_ERROR",e.NOT_IMPLEMENTED="NOT_IMPLEMENTED",e.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",e.NETWORK_ERROR="NETWORK_ERROR",e.SERVER_ERROR="SERVER_ERROR",e.TIMEOUT="TIMEOUT",e.BUFFER_OVERRUN="BUFFER_OVERRUN",e.NUMERIC_FAULT="NUMERIC_FAULT",e.MISSING_NEW="MISSING_NEW",e.INVALID_ARGUMENT="INVALID_ARGUMENT",e.MISSING_ARGUMENT="MISSING_ARGUMENT",e.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",e.CALL_EXCEPTION="CALL_EXCEPTION",e.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",e.NONCE_EXPIRED="NONCE_EXPIRED",e.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",e.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",e.TRANSACTION_REPLACED="TRANSACTION_REPLACED",e.ACTION_REJECTED="ACTION_REJECTED"}(p||(p={}));var y="0123456789abcdef",v=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}return t=e,r=[{key:"_log",value:function(e,t){var r=e.toLowerCase();null==f[r]&&this.throwArgumentError("invalid log level name","logLevel",e)}},{key:"debug",value:function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];this._log(e.levels.DEBUG,r)}},{key:"info",value:function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];this._log(e.levels.INFO,r)}},{key:"warn",value:function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];this._log(e.levels.WARNING,r)}},{key:"makeError",value:function(t,r,n){if(c)return this.makeError("censored error",r,{});r||(r=e.errors.UNKNOWN_ERROR),n||(n={});var o=[];Object.keys(n).forEach(function(e){var t=n[e];try{if(t instanceof Uint8Array){for(var r="",i=0;i<t.length;i++)r+=y[t[i]>>4],r+=y[15&t[i]];o.push(e+"=Uint8Array(0x"+r+")")}else o.push(e+"="+JSON.stringify(t))}catch(t){o.push(e+"="+JSON.stringify(n[e].toString()))}}),o.push("code=".concat(r)),o.push("version=".concat(this.version));var i=t,a="";switch(r){case p.NUMERIC_FAULT:a="NUMERIC_FAULT";var u=t;switch(u){case"overflow":case"underflow":case"division-by-zero":a+="-"+u;break;case"negative-power":case"negative-width":a+="-unsupported";break;case"unbound-bitwise-result":a+="-unbound-result"}break;case p.CALL_EXCEPTION:case p.INSUFFICIENT_FUNDS:case p.MISSING_NEW:case p.NONCE_EXPIRED:case p.REPLACEMENT_UNDERPRICED:case p.TRANSACTION_REPLACED:case p.UNPREDICTABLE_GAS_LIMIT:a=r}a&&(t+=" [ See: https://links.ethers.org/v5-errors-"+a+" ]"),o.length&&(t+=" ("+o.join(", ")+")");var s=new Error(t);return s.reason=i,s.code=r,Object.keys(n).forEach(function(e){s[e]=n[e]}),s}},{key:"throwError",value:function(e,t,r){throw this.makeError(e,t,r)}},{key:"throwArgumentError",value:function(t,r,n){return this.throwError(t,e.errors.INVALID_ARGUMENT,{argument:r,value:n})}},{key:"assert",value:function(e,t,r,n){e||this.throwError(t,r,n)}},{key:"assertArgument",value:function(e,t,r,n){e||this.throwArgumentError(t,r,n)}},{key:"checkNormalize",value:function(t){null==t&&(t="platform missing String.prototype.normalize"),h&&this.throwError("platform missing String.prototype.normalize",e.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:h})}},{key:"checkSafeUint53",value:function(t,r){"number"==typeof t&&(null==r&&(r="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(r,e.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(r,e.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}},{key:"checkArgumentCount",value:function(t,r,n){n=n?": "+n:"",t<r&&this.throwError("missing argument"+n,e.errors.MISSING_ARGUMENT,{count:t,expectedCount:r}),t>r&&this.throwError("too many arguments"+n,e.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:r})}},{key:"checkNew",value:function(t,r){t!==Object&&null!=t||this.throwError("missing new",e.errors.MISSING_NEW,{name:r.name})}},{key:"checkAbstract",value:function(t,r){t===r?this.throwError("cannot instantiate abstract class "+JSON.stringify(r.name)+" directly; use a sub-class",e.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",e.errors.MISSING_NEW,{name:r.name})}}],n=[{key:"globalLogger",value:function(){return l||(l=new e("logger/5.8.0")),l}},{key:"setCensorship",value:function(t,r){if(!t&&r&&this.globalLogger().throwError("cannot permanently disable censorship",e.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),s){if(!t)return;this.glob