@maticnetwork/maticjs-ethers
Advanced tools
Comparing version 1.1.0-beta.1 to 1.1.0-beta.2
@@ -320,3 +320,3 @@ module.exports = | ||
_this.signer = provider; | ||
_this.provider = (provider.provider); | ||
_this.provider = (provider.provider ? provider.provider : provider); | ||
} | ||
@@ -345,3 +345,8 @@ return _this; | ||
EtherWeb3Client.prototype.getChainId = function () { | ||
return this.signer.getChainId(); | ||
if (this.signer.getChainId) { | ||
return this.signer.getChainId(); | ||
} | ||
return this.provider.getNetwork().then(function (res) { | ||
return res.chainId; | ||
}); | ||
}; | ||
@@ -348,0 +353,0 @@ EtherWeb3Client.prototype.getBalance = function (address) { |
@@ -1,2 +0,2 @@ | ||
module.exports=function(t){var n={};function r(e){if(n[e])return n[e].exports;var o=n[e]={i:e,l:!1,exports:{}};return t[e].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=n,r.d=function(t,n,e){r.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:e})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,n){if(1&n&&(t=r(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var e=Object.create(null);if(r.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var o in t)r.d(e,o,function(n){return t[n]}.bind(null,o));return e},r.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(n,"a",n),n},r.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},r.p="",r(r.s=2)}([function(t,n){t.exports=require("ethers")},function(t,n){t.exports=require("@maticnetwork/maticjs")},function(t,n,r){"use strict";r.r(n),r.d(n,"Web3ClientPlugin",(function(){return _})),r.d(n,"EtherWeb3Client",(function(){return b})),r.d(n,"ContractMethod",(function(){return l}));var e,o=r(0),i=r(1),u=function(){},s=function(t){var n=t;return n.gasUsed=t.gasUsed.toNumber(),n.cumulativeGasUsed=t.cumulativeGasUsed.toNumber(),n},a=function(t){var n=t;return n.gasPrice=t.gasPrice.toString(),n.gas=t.gasLimit.toNumber(),n.gasLimit=t.gasLimit.toNumber(),n.value=t.value.toString(),n.transactionHash=t.hash,n},c=(e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var r in n)n.hasOwnProperty(r)&&(t[r]=n[r])})(t,n)},function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}),f=function(t){function n(n){var r=t.call(this)||this;return r.bn_=o.BigNumber.from(n),r}return c(n,t),n.isBN=function(t){return t instanceof n||o.BigNumber.isBigNumber(t)},n.prototype.toString=function(t){if(16===t){var n=this.bn_.toHexString();return 0===(n=o.utils.hexStripZeros(n)).indexOf("0x")?n.slice(2):n}return this.bn_.toString()},n.prototype.toNumber=function(){return this.bn_.toNumber()},n.prototype.toBuffer=function(){return this.bn_.toBuffer()},n.prototype.add=function(t){return new n(this.bn_.add(o.BigNumber.from(t.toString())))},n.prototype.sub=function(t){return new n(this.bn_.sub(o.BigNumber.from(t.toString())))},n.prototype.mul=function(t){return new n(this.bn_.mul(o.BigNumber.from(t.toString())))},n.prototype.div=function(t){return new n(this.bn_.div(o.BigNumber.from(t.toString())))},n.prototype.lte=function(t){return this.bn_.lte(o.BigNumber.from(t.toString()))},n.prototype.lt=function(t){return this.bn_.lt(o.BigNumber.from(t.toString()))},n.prototype.gte=function(t){return this.bn_.gte(o.BigNumber.from(t.toString()))},n.prototype.gt=function(t){return this.bn_.gt(o.BigNumber.from(t.toString()))},n.prototype.eq=function(t){return this.bn_.eq(o.BigNumber.from(t.toString()))},n}(i.BaseBigNumber),p=function(){function t(t){var n=this;this.promise=t,this.onTransactionHash=u,this.onTransactionError=u,t.then((function(t){n.onTransactionHash(t.hash),setTimeout((function(){n.onTransactionReceipt&&t.wait().then((function(t){n.onTransactionReceipt(t)}))}),0)})).catch((function(t){n.onTransactionError(t)}))}return t.prototype.getReceipt=function(){var t=this;return new Promise((function(n,r){t.onTransactionReceipt=n,t.onTransactionError=r})).then((function(t){return s(t)}))},t.prototype.getTransactionHash=function(){var t=this;return new Promise((function(n,r){t.onTransactionHash=n,t.onTransactionError=r}))},t}(),h=function(){var t=function(n,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var r in n)n.hasOwnProperty(r)&&(t[r]=n[r])})(n,r)};return function(n,r){function e(){this.constructor=n}t(n,r),n.prototype=null===r?Object.create(r):(e.prototype=r.prototype,new e)}}(),g=function(){for(var t=0,n=0,r=arguments.length;n<r;n++)t+=arguments[n].length;var e=Array(t),o=0;for(n=0;n<r;n++)for(var i=arguments[n],u=0,s=i.length;u<s;u++,o++)e[o]=i[u];return e},l=function(t){function n(n,r,e,o){var i=t.call(this,n)||this;return i.contract_=r,i.methodName=e,i.args=o,i}return h(n,t),Object.defineProperty(n.prototype,"address",{get:function(){return this.contract_.address},enumerable:!1,configurable:!0}),n.prototype.toBigNumber=function(t){return t?o.BigNumber.from(t):t},n.prototype.toConfig_=function(t){void 0===t&&(t={});var n=this.toBigNumber;return{to:t.to,from:t.from,gasPrice:n(t.gasPrice),gasLimit:n(t.gasLimit),value:n(t.value),nonce:t.nonce,data:t.data,type:t.type,maxFeePerGas:n(t.maxFeePerGas),maxPriorityFeePerGas:n(t.maxPriorityFeePerGas)}},n.prototype.encodeABI=function(){return this.contract_.interface.encodeFunctionData(this.methodName,this.args)},n.prototype.estimateGas=function(t){var n;return void 0===t&&(t={}),(n=this.contract_.estimateGas)[this.methodName].apply(n,g(this.args,[this.toConfig_(t)])).then((function(t){return t.toNumber()}))},n.prototype.read=function(t){return this.logger.log("sending tx with config",t),this.getMethod_(t).then((function(t){return t._isBigNumber&&(t=t.toString()),t}))},n.prototype.getMethod_=function(t){var n;return void 0===t&&(t={}),(n=this.contract_)[this.methodName].apply(n,g(this.args,[this.toConfig_(t)]))},n.prototype.write=function(t){return this.logger.log("sending tx with config",t),new p(this.getMethod_(t))},n}(i.BaseContractMethod),m=function(){var t=function(n,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var r in n)n.hasOwnProperty(r)&&(t[r]=n[r])})(n,r)};return function(n,r){function e(){this.constructor=n}t(n,r),n.prototype=null===r?Object.create(r):(e.prototype=r.prototype,new e)}}(),d=function(t){function n(n,r,e){var o=t.call(this,n,e)||this;return o.contract=r,o}return m(n,t),n.prototype.method=function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];return this.logger.log("args method",arguments),new l(this.logger,this.contract,t,n)},n}(i.BaseContract),y=function(){var t=function(n,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var r in n)n.hasOwnProperty(r)&&(t[r]=n[r])})(n,r)};return function(n,r){function e(){this.constructor=n}t(n,r),n.prototype=null===r?Object.create(r):(e.prototype=r.prototype,new e)}}(),b=function(t){function n(n,r){var e=t.call(this,r)||this;return e.name="ETHER",n._isProvider?(e.provider=n,e.signer=e.provider.getSigner(),e.signer&&e.signer._address||(e.signer=n)):(e.signer=n,e.provider=n.provider),e}return y(n,t),n.prototype.getBlock=function(t){return this.provider.getBlock(t).then((function(t){return t}))},n.prototype.getBlockWithTransaction=function(t){var n=this.provider;return n.send("eth_getBlockByNumber",[o.utils.hexValue(t),!0]).then((function(t){var r=n.formatter.blockWithTransactions(t);return r.stateRoot=n.formatter.hash(t.stateRoot),r.transactionsRoot=n.formatter.hash(t.transactionsRoot),r.receiptsRoot=n.formatter.hash(t.receiptsRoot),r.transactions=r.transactions.map((function(t){return a(t)})),function(t){return t.gasUsed=t.gasUsed.toNumber(),t.gasLimit=t.gasLimit.toNumber(),t.baseFeePerGas&&(t.baseFeePerGas=t.baseFeePerGas.toHexString()),t}(r)}))},n.prototype.getChainId=function(){return this.signer.getChainId()},n.prototype.getBalance=function(t){return this.provider.getBalance(t).then((function(t){return t.toString()}))},n.prototype.getAccounts=function(){return this.signer.getAddress().then((function(t){return[t]}))},n.prototype.ensureTransactionNotNull_=function(t){if(!t)throw{type:"invalid_transaction",message:"Could not retrieve transaction. Either it is invalid or might be in archive node."}},n.prototype.getTransaction=function(t){var n=this;return this.provider.getTransaction(t).then((function(t){return n.ensureTransactionNotNull_(t),a(t)}))},n.prototype.getTransactionCount=function(t,n){return this.provider.getTransactionCount(t,n)},n.prototype.getTransactionReceipt=function(t){var n=this;return this.provider.getTransactionReceipt(t).then((function(t){return n.ensureTransactionNotNull_(t),s(t)}))},n.prototype.getGasPrice=function(){return this.provider.getGasPrice().then((function(t){return t.toString()}))},n.prototype.estimateGas=function(t){return this.provider.estimateGas(this.toEthTxConfig_(t)).then((function(t){return t.toNumber()}))},n.prototype.encodeParameters=function(t,n){return o.utils.defaultAbiCoder.encode(n,t)},n.prototype.toHex=function(t,n){if(o.utils.isAddress(t))return n?"address":"0x"+t.toLowerCase().replace(/^0x/i,"");if("boolean"==typeof t)return n?"bool":t?"0x01":"0x00";if(Buffer.isBuffer(t))return"0x"+t.toString("hex");if("object"==typeof t&&t&&!o.BigNumber.isBigNumber(t))return n?"string":o.utils.hexlify(JSON.stringify(t));if("string"==typeof t){if(0===t.indexOf("-0x")||0===t.indexOf("-0X"))return n?"int256":o.utils.hexlify(t);if(0===t.indexOf("0x")||0===t.indexOf("0X"))return n?"bytes":t;if(!isFinite(t))return n?"string":o.utils.hexlify(t)}return n?t<0?"int256":"uint256":o.utils.hexlify(t)},n.prototype.hexToNumber=function(t){return o.BigNumber.from(t).toNumber()},n.prototype.hexToNumberString=function(t){return o.BigNumber.from(t).toString()},n.prototype.signTypedData=function(t,n){var r=n.domain,e=n.types,o=n.message;return e.EIP712Domain&&delete e.EIP712Domain,this.signer._signTypedData(r,e,o)},n.prototype.etheriumSha3=function(){for(var t=this,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var e=n.map((function(n){return t.toHex(n,!0)}));return o.utils.solidityKeccak256(e,n)},n.prototype.sendRPCRequest=function(t){return this.provider.send(t.method,t.params).then((function(t){return{result:t}}))},n.prototype.toEthTxConfig_=function(t){return{chainId:t.chainId,data:t.data,from:t.from,gasLimit:t.gasLimit,gasPrice:t.gasPrice,nonce:t.nonce,to:t.to,value:t.value}},n.prototype.write=function(t){var n=u,r={getTransactionHash:function(){return new Promise((function(t){n=t}))}};return this.signer.sendTransaction(this.toEthTxConfig_(t)).then((function(t){n(t.hash),r.getReceipt=function(){return t.wait().then((function(t){return s(t)}))}})).catch((function(t){t})),r},n.prototype.read=function(t){return this.signer.call(this.toEthTxConfig_(t))},n.prototype.getContract=function(t,n){return new d(t,new o.Contract(t,n,this.signer),this.logger)},n.prototype.decodeParameters=function(t,n){return o.utils.defaultAbiCoder.decode(n,t)},n}(i.BaseWeb3Client),_=function(){function t(){}return t.prototype.setup=function(t){t.utils.Web3Client=b,t.utils.BN=f,t.utils.isBN=function(t){return o.BigNumber.isBigNumber(t)}},t}();n.default=_}]); | ||
module.exports=function(t){var r={};function n(e){if(r[e])return r[e].exports;var o=r[e]={i:e,l:!1,exports:{}};return t[e].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=r,n.d=function(t,r,e){n.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:e})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,r){if(1&r&&(t=n(t)),8&r)return t;if(4&r&&"object"==typeof t&&t&&t.__esModule)return t;var e=Object.create(null);if(n.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var o in t)n.d(e,o,function(r){return t[r]}.bind(null,o));return e},n.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(r,"a",r),r},n.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},n.p="",n(n.s=2)}([function(t,r){t.exports=require("ethers")},function(t,r){t.exports=require("@maticnetwork/maticjs")},function(t,r,n){"use strict";n.r(r),n.d(r,"Web3ClientPlugin",(function(){return _})),n.d(r,"EtherWeb3Client",(function(){return b})),n.d(r,"ContractMethod",(function(){return l}));var e,o=n(0),i=n(1),u=function(){},s=function(t){var r=t;return r.gasUsed=t.gasUsed.toNumber(),r.cumulativeGasUsed=t.cumulativeGasUsed.toNumber(),r},a=function(t){var r=t;return r.gasPrice=t.gasPrice.toString(),r.gas=t.gasLimit.toNumber(),r.gasLimit=t.gasLimit.toNumber(),r.value=t.value.toString(),r.transactionHash=t.hash,r},c=(e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var n in r)r.hasOwnProperty(n)&&(t[n]=r[n])})(t,r)},function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}),f=function(t){function r(r){var n=t.call(this)||this;return n.bn_=o.BigNumber.from(r),n}return c(r,t),r.isBN=function(t){return t instanceof r||o.BigNumber.isBigNumber(t)},r.prototype.toString=function(t){if(16===t){var r=this.bn_.toHexString();return 0===(r=o.utils.hexStripZeros(r)).indexOf("0x")?r.slice(2):r}return this.bn_.toString()},r.prototype.toNumber=function(){return this.bn_.toNumber()},r.prototype.toBuffer=function(){return this.bn_.toBuffer()},r.prototype.add=function(t){return new r(this.bn_.add(o.BigNumber.from(t.toString())))},r.prototype.sub=function(t){return new r(this.bn_.sub(o.BigNumber.from(t.toString())))},r.prototype.mul=function(t){return new r(this.bn_.mul(o.BigNumber.from(t.toString())))},r.prototype.div=function(t){return new r(this.bn_.div(o.BigNumber.from(t.toString())))},r.prototype.lte=function(t){return this.bn_.lte(o.BigNumber.from(t.toString()))},r.prototype.lt=function(t){return this.bn_.lt(o.BigNumber.from(t.toString()))},r.prototype.gte=function(t){return this.bn_.gte(o.BigNumber.from(t.toString()))},r.prototype.gt=function(t){return this.bn_.gt(o.BigNumber.from(t.toString()))},r.prototype.eq=function(t){return this.bn_.eq(o.BigNumber.from(t.toString()))},r}(i.BaseBigNumber),p=function(){function t(t){var r=this;this.promise=t,this.onTransactionHash=u,this.onTransactionError=u,t.then((function(t){r.onTransactionHash(t.hash),setTimeout((function(){r.onTransactionReceipt&&t.wait().then((function(t){r.onTransactionReceipt(t)}))}),0)})).catch((function(t){r.onTransactionError(t)}))}return t.prototype.getReceipt=function(){var t=this;return new Promise((function(r,n){t.onTransactionReceipt=r,t.onTransactionError=n})).then((function(t){return s(t)}))},t.prototype.getTransactionHash=function(){var t=this;return new Promise((function(r,n){t.onTransactionHash=r,t.onTransactionError=n}))},t}(),h=function(){var t=function(r,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var n in r)r.hasOwnProperty(n)&&(t[n]=r[n])})(r,n)};return function(r,n){function e(){this.constructor=r}t(r,n),r.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}}(),g=function(){for(var t=0,r=0,n=arguments.length;r<n;r++)t+=arguments[r].length;var e=Array(t),o=0;for(r=0;r<n;r++)for(var i=arguments[r],u=0,s=i.length;u<s;u++,o++)e[o]=i[u];return e},l=function(t){function r(r,n,e,o){var i=t.call(this,r)||this;return i.contract_=n,i.methodName=e,i.args=o,i}return h(r,t),Object.defineProperty(r.prototype,"address",{get:function(){return this.contract_.address},enumerable:!1,configurable:!0}),r.prototype.toBigNumber=function(t){return t?o.BigNumber.from(t):t},r.prototype.toConfig_=function(t){void 0===t&&(t={});var r=this.toBigNumber;return{to:t.to,from:t.from,gasPrice:r(t.gasPrice),gasLimit:r(t.gasLimit),value:r(t.value),nonce:t.nonce,data:t.data,type:t.type,maxFeePerGas:r(t.maxFeePerGas),maxPriorityFeePerGas:r(t.maxPriorityFeePerGas)}},r.prototype.encodeABI=function(){return this.contract_.interface.encodeFunctionData(this.methodName,this.args)},r.prototype.estimateGas=function(t){var r;return void 0===t&&(t={}),(r=this.contract_.estimateGas)[this.methodName].apply(r,g(this.args,[this.toConfig_(t)])).then((function(t){return t.toNumber()}))},r.prototype.read=function(t){return this.logger.log("sending tx with config",t),this.getMethod_(t).then((function(t){return t._isBigNumber&&(t=t.toString()),t}))},r.prototype.getMethod_=function(t){var r;return void 0===t&&(t={}),(r=this.contract_)[this.methodName].apply(r,g(this.args,[this.toConfig_(t)]))},r.prototype.write=function(t){return this.logger.log("sending tx with config",t),new p(this.getMethod_(t))},r}(i.BaseContractMethod),d=function(){var t=function(r,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var n in r)r.hasOwnProperty(n)&&(t[n]=r[n])})(r,n)};return function(r,n){function e(){this.constructor=r}t(r,n),r.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}}(),m=function(t){function r(r,n,e){var o=t.call(this,r,e)||this;return o.contract=n,o}return d(r,t),r.prototype.method=function(t){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];return this.logger.log("args method",arguments),new l(this.logger,this.contract,t,r)},r}(i.BaseContract),y=function(){var t=function(r,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var n in r)r.hasOwnProperty(n)&&(t[n]=r[n])})(r,n)};return function(r,n){function e(){this.constructor=r}t(r,n),r.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}}(),b=function(t){function r(r,n){var e=t.call(this,n)||this;return e.name="ETHER",r._isProvider?(e.provider=r,e.signer=e.provider.getSigner(),e.signer&&e.signer._address||(e.signer=r)):(e.signer=r,e.provider=r.provider?r.provider:r),e}return y(r,t),r.prototype.getBlock=function(t){return this.provider.getBlock(t).then((function(t){return t}))},r.prototype.getBlockWithTransaction=function(t){var r=this.provider;return r.send("eth_getBlockByNumber",[o.utils.hexValue(t),!0]).then((function(t){var n=r.formatter.blockWithTransactions(t);return n.stateRoot=r.formatter.hash(t.stateRoot),n.transactionsRoot=r.formatter.hash(t.transactionsRoot),n.receiptsRoot=r.formatter.hash(t.receiptsRoot),n.transactions=n.transactions.map((function(t){return a(t)})),function(t){return t.gasUsed=t.gasUsed.toNumber(),t.gasLimit=t.gasLimit.toNumber(),t.baseFeePerGas&&(t.baseFeePerGas=t.baseFeePerGas.toHexString()),t}(n)}))},r.prototype.getChainId=function(){return this.signer.getChainId?this.signer.getChainId():this.provider.getNetwork().then((function(t){return t.chainId}))},r.prototype.getBalance=function(t){return this.provider.getBalance(t).then((function(t){return t.toString()}))},r.prototype.getAccounts=function(){return this.signer.getAddress().then((function(t){return[t]}))},r.prototype.ensureTransactionNotNull_=function(t){if(!t)throw{type:"invalid_transaction",message:"Could not retrieve transaction. Either it is invalid or might be in archive node."}},r.prototype.getTransaction=function(t){var r=this;return this.provider.getTransaction(t).then((function(t){return r.ensureTransactionNotNull_(t),a(t)}))},r.prototype.getTransactionCount=function(t,r){return this.provider.getTransactionCount(t,r)},r.prototype.getTransactionReceipt=function(t){var r=this;return this.provider.getTransactionReceipt(t).then((function(t){return r.ensureTransactionNotNull_(t),s(t)}))},r.prototype.getGasPrice=function(){return this.provider.getGasPrice().then((function(t){return t.toString()}))},r.prototype.estimateGas=function(t){return this.provider.estimateGas(this.toEthTxConfig_(t)).then((function(t){return t.toNumber()}))},r.prototype.encodeParameters=function(t,r){return o.utils.defaultAbiCoder.encode(r,t)},r.prototype.toHex=function(t,r){if(o.utils.isAddress(t))return r?"address":"0x"+t.toLowerCase().replace(/^0x/i,"");if("boolean"==typeof t)return r?"bool":t?"0x01":"0x00";if(Buffer.isBuffer(t))return"0x"+t.toString("hex");if("object"==typeof t&&t&&!o.BigNumber.isBigNumber(t))return r?"string":o.utils.hexlify(JSON.stringify(t));if("string"==typeof t){if(0===t.indexOf("-0x")||0===t.indexOf("-0X"))return r?"int256":o.utils.hexlify(t);if(0===t.indexOf("0x")||0===t.indexOf("0X"))return r?"bytes":t;if(!isFinite(t))return r?"string":o.utils.hexlify(t)}return r?t<0?"int256":"uint256":o.utils.hexlify(t)},r.prototype.hexToNumber=function(t){return o.BigNumber.from(t).toNumber()},r.prototype.hexToNumberString=function(t){return o.BigNumber.from(t).toString()},r.prototype.signTypedData=function(t,r){var n=r.domain,e=r.types,o=r.message;return e.EIP712Domain&&delete e.EIP712Domain,this.signer._signTypedData(n,e,o)},r.prototype.etheriumSha3=function(){for(var t=this,r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];var e=r.map((function(r){return t.toHex(r,!0)}));return o.utils.solidityKeccak256(e,r)},r.prototype.sendRPCRequest=function(t){return this.provider.send(t.method,t.params).then((function(t){return{result:t}}))},r.prototype.toEthTxConfig_=function(t){return{chainId:t.chainId,data:t.data,from:t.from,gasLimit:t.gasLimit,gasPrice:t.gasPrice,nonce:t.nonce,to:t.to,value:t.value}},r.prototype.write=function(t){var r=u,n={getTransactionHash:function(){return new Promise((function(t){r=t}))}};return this.signer.sendTransaction(this.toEthTxConfig_(t)).then((function(t){r(t.hash),n.getReceipt=function(){return t.wait().then((function(t){return s(t)}))}})).catch((function(t){t})),n},r.prototype.read=function(t){return this.signer.call(this.toEthTxConfig_(t))},r.prototype.getContract=function(t,r){return new m(t,new o.Contract(t,r,this.signer),this.logger)},r.prototype.decodeParameters=function(t,r){return o.utils.defaultAbiCoder.decode(r,t)},r}(i.BaseWeb3Client),_=function(){function t(){}return t.prototype.setup=function(t){t.utils.Web3Client=b,t.utils.BN=f,t.utils.isBN=function(t){return o.BigNumber.isBigNumber(t)}},t}();r.default=_}]); | ||
//# sourceMappingURL=matic-ethers.node.min.js.map |
{ | ||
"name": "@maticnetwork/maticjs-ethers", | ||
"version": "1.1.0-beta.1", | ||
"version": "1.1.0-beta.2", | ||
"description": "ethers plugin for matic.js", | ||
@@ -5,0 +5,0 @@ "main": "dist/npm.export.js", |
@@ -26,3 +26,3 @@ import { providers, Wallet, utils, Contract, ethers, BigNumber } from "ethers"; | ||
this.signer = (provider as any); | ||
this.provider = ((provider as Wallet).provider) as any; | ||
this.provider = ((provider as Wallet).provider ? (provider as Wallet).provider : provider ) as any; | ||
} | ||
@@ -61,3 +61,8 @@ } | ||
getChainId() { | ||
return this.signer.getChainId(); | ||
if (this.signer.getChainId) { | ||
return this.signer.getChainId(); | ||
} | ||
return this.provider.getNetwork().then(function (res) { | ||
return res.chainId; | ||
}); | ||
} | ||
@@ -64,0 +69,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
146347
1481
0