@automata-network/conveyor-sdk
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -8,2 +8,15 @@ { | ||
"indexed": false, | ||
"internalType": "bool[]", | ||
"name": "successArr", | ||
"type": "bool[]" | ||
} | ||
], | ||
"name": "BatchedMetaStatus", | ||
"type": "event" | ||
}, | ||
{ | ||
"anonymous": false, | ||
"inputs": [ | ||
{ | ||
"indexed": false, | ||
"internalType": "address", | ||
@@ -105,2 +118,110 @@ "name": "sender", | ||
{ | ||
"components": [ | ||
{ | ||
"internalType": "address", | ||
"name": "from", | ||
"type": "address" | ||
}, | ||
{ | ||
"internalType": "address", | ||
"name": "to", | ||
"type": "address" | ||
}, | ||
{ | ||
"internalType": "address", | ||
"name": "feeToken", | ||
"type": "address" | ||
}, | ||
{ | ||
"internalType": "bool", | ||
"name": "useOraclePriceFeed", | ||
"type": "bool" | ||
}, | ||
{ | ||
"internalType": "uint256", | ||
"name": "maxTokenAmount", | ||
"type": "uint256" | ||
}, | ||
{ | ||
"internalType": "uint256", | ||
"name": "deadline", | ||
"type": "uint256" | ||
}, | ||
{ | ||
"internalType": "uint256", | ||
"name": "nonce", | ||
"type": "uint256" | ||
}, | ||
{ | ||
"internalType": "bytes", | ||
"name": "data", | ||
"type": "bytes" | ||
}, | ||
{ | ||
"internalType": "uint256[]", | ||
"name": "extendCategories", | ||
"type": "uint256[]" | ||
} | ||
], | ||
"internalType": "struct ConveyorTypes.MetaTransaction", | ||
"name": "metatx", | ||
"type": "tuple" | ||
}, | ||
{ | ||
"internalType": "string", | ||
"name": "domainName", | ||
"type": "string" | ||
}, | ||
{ | ||
"internalType": "bool", | ||
"name": "relayerChargeEnabled", | ||
"type": "bool" | ||
}, | ||
{ | ||
"internalType": "uint256", | ||
"name": "tokenPricePerNativeToken", | ||
"type": "uint256" | ||
}, | ||
{ | ||
"internalType": "enum SignatureValidator.SignatureSignerType", | ||
"name": "signerType", | ||
"type": "uint8" | ||
}, | ||
{ | ||
"internalType": "bytes", | ||
"name": "sig", | ||
"type": "bytes" | ||
}, | ||
{ | ||
"internalType": "bytes", | ||
"name": "extendParamData", | ||
"type": "bytes" | ||
} | ||
], | ||
"internalType": "struct ConveyorForwarder.ConveyorTransaction[]", | ||
"name": "conveyorTransactions", | ||
"type": "tuple[]" | ||
} | ||
], | ||
"name": "executeBatchedMetaTx", | ||
"outputs": [ | ||
{ | ||
"internalType": "bool[]", | ||
"name": "", | ||
"type": "bool[]" | ||
}, | ||
{ | ||
"internalType": "bytes[]", | ||
"name": "", | ||
"type": "bytes[]" | ||
} | ||
], | ||
"stateMutability": "payable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"components": [ | ||
{ | ||
"internalType": "address", | ||
@@ -171,22 +292,10 @@ "name": "from", | ||
{ | ||
"components": [ | ||
{ | ||
"internalType": "uint8", | ||
"name": "v", | ||
"type": "uint8" | ||
}, | ||
{ | ||
"internalType": "bytes32", | ||
"name": "r", | ||
"type": "bytes32" | ||
}, | ||
{ | ||
"internalType": "bytes32", | ||
"name": "s", | ||
"type": "bytes32" | ||
} | ||
], | ||
"internalType": "struct ConveyorTypes.Sig", | ||
"internalType": "enum SignatureValidator.SignatureSignerType", | ||
"name": "signerType", | ||
"type": "uint8" | ||
}, | ||
{ | ||
"internalType": "bytes", | ||
"name": "sig", | ||
"type": "tuple" | ||
"type": "bytes" | ||
}, | ||
@@ -199,3 +308,3 @@ { | ||
], | ||
"name": "executeMetaTx", | ||
"name": "executeMetaTxV2", | ||
"outputs": [ | ||
@@ -202,0 +311,0 @@ { |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("ethers"),t=require("bignumber.js"),n=require("@ethersproject/bignumber");function r(e,t,n,r,a,i,s){try{var o=e[i](s),u=o.value}catch(e){return void n(e)}o.done?t(u):Promise.resolve(u).then(r,a)}function a(e){return function(){var t=this,n=arguments;return new Promise((function(a,i){var s=e.apply(t,n);function o(e){r(s,a,i,o,u,"next",e)}function u(e){r(s,a,i,o,u,"throw",e)}o(void 0)}))}}function i(){return(i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function o(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return s(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}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 u,p,c,d,y,l,f,m=(function(e){var t=function(e){var t=Object.prototype,n=t.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},a=r.iterator||"@@iterator",i=r.asyncIterator||"@@asyncIterator",s=r.toStringTag||"@@toStringTag";function o(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{o({},"")}catch(e){o=function(e,t,n){return e[t]=n}}function u(e,t,n,r){var a=Object.create((t&&t.prototype instanceof d?t:d).prototype),i=new E(r||[]);return a._invoke=function(e,t,n){var r="suspendedStart";return function(a,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw i;return{value:void 0,done:!0}}for(n.method=a,n.arg=i;;){var s=n.delegate;if(s){var o=g(s,n);if(o){if(o===c)continue;return o}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=p(e,t,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===c)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}(e,n,i),a}function p(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var c={};function d(){}function y(){}function l(){}var f={};o(f,a,(function(){return this}));var m=Object.getPrototypeOf,h=m&&m(m(N([])));h&&h!==t&&n.call(h,a)&&(f=h);var b=l.prototype=d.prototype=Object.create(f);function v(e){["next","throw","return"].forEach((function(t){o(e,t,(function(e){return this._invoke(t,e)}))}))}function T(e,t){var r;this._invoke=function(a,i){function s(){return new t((function(r,s){!function r(a,i,s,o){var u=p(e[a],e,i);if("throw"!==u.type){var c=u.arg,d=c.value;return d&&"object"==typeof d&&n.call(d,"__await")?t.resolve(d.__await).then((function(e){r("next",e,s,o)}),(function(e){r("throw",e,s,o)})):t.resolve(d).then((function(e){c.value=e,s(c)}),(function(e){return r("throw",e,s,o)}))}o(u.arg)}(a,i,r,s)}))}return r=r?r.then(s,s):s()}}function g(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,g(e,t),"throw"===t.method))return c;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return c}var r=p(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,c;var a=r.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,c):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,c)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function w(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function E(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function N(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,i=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:M}}function M(){return{value:void 0,done:!0}}return y.prototype=l,o(b,"constructor",l),o(l,"constructor",y),y.displayName=o(l,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,o(e,s,"GeneratorFunction")),e.prototype=Object.create(b),e},e.awrap=function(e){return{__await:e}},v(T.prototype),o(T.prototype,i,(function(){return this})),e.AsyncIterator=T,e.async=function(t,n,r,a,i){void 0===i&&(i=Promise);var s=new T(u(t,n,r,a),i);return e.isGeneratorFunction(n)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},v(b),o(b,s,"Generator"),o(b,a,(function(){return this})),o(b,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},e.values=N,E.prototype={constructor:E,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(w),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return s.type="throw",s.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],s=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var o=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(o&&u){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(o){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var i=a;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=e,s.arg=t,i?(this.method="next",this.next=i.finallyLoc,c):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),c},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),w(n),c}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;w(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:N(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),c}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}(f={exports:{}}),f.exports);(u=exports.ChainId||(exports.ChainId={}))[u.MAINNET=1]="MAINNET",u[u.ROPSTEN=3]="ROPSTEN",u[u.RINKEBY=4]="RINKEBY",u[u["GÖRLI"]=5]="GÖRLI",u[u.KOVAN=42]="KOVAN",u[u.MATIC=137]="MATIC",u[u.MATIC_TESTNET=80001]="MATIC_TESTNET",u[u.FANTOM=250]="FANTOM",u[u.FANTOM_TESTNET=4002]="FANTOM_TESTNET",u[u.XDAI=100]="XDAI",u[u.BSC=56]="BSC",u[u.BSC_TESTNET=97]="BSC_TESTNET",u[u.ARBITRUM=42161]="ARBITRUM",u[u.ARBITRUM_TESTNET=79377087078960]="ARBITRUM_TESTNET",u[u.MOONBEAM_TESTNET=1287]="MOONBEAM_TESTNET",u[u.AVALANCHE=43114]="AVALANCHE",u[u.AVALANCHE_TESTNET=43113]="AVALANCHE_TESTNET",u[u.HECO=128]="HECO",u[u.HECO_TESTNET=256]="HECO_TESTNET",u[u.HARMONY=16666e5]="HARMONY",u[u.HARMONY_TESTNET=16667e5]="HARMONY_TESTNET",u[u.OKEX=66]="OKEX",u[u.OKEX_TESTNET=65]="OKEX_TESTNET",u[u.CELO=42220]="CELO",u[u.PALM=11297108109]="PALM",u[u.PALM_TESTNET=11297108099]="PALM_TESTNET",u[u.MOONRIVER=1285]="MOONRIVER",(p=exports.ENVIRONMENT||(exports.ENVIRONMENT={}))[p.TEST=0]="TEST",p[p.PRODUCTION=1]="PRODUCTION";var h,b=((c={})[exports.ENVIRONMENT.TEST]=["https://conveyor-geode-staging.ata.network"],c[exports.ENVIRONMENT.PRODUCTION]=[],c),v=function(e){return(t=b[e])[Math.floor(Math.random()*t.length)];var t},T=((d={})[exports.ChainId.MAINNET]="0x84194C00E190dE7A10180853f6a28502Ad1A1029",d),g=((y={})[exports.ChainId.MAINNET]="0x6B175474E89094C44Da98b954EedeAC495271d0F",y[exports.ChainId.MATIC]="0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",y),x=((l={})[exports.ChainId.MAINNET]="0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",l[exports.ChainId.BSC]="0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",l[exports.ChainId.MATIC]="0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",l),w=((h={})[exports.ChainId.BSC]="https://api.coingecko.com/api/v3/simple/token_price/binance-smart-chain?",h[exports.ChainId.MATIC]="https://api.coingecko.com/api/v3/simple/token_price/polygon-pos?",h[exports.ChainId.MAINNET]="https://api.coingecko.com/api/v3/simple/token_price/ethereum?",h[exports.ChainId.ARBITRUM]="https://api.coingecko.com/api/v3/simple/token_price/arbitrum-one?",h[exports.ChainId.MOONRIVER]="https://api.coingecko.com/api/v3/simple/token_price/moonriver?",h);function E(e,t,n,r,a,i){return N.apply(this,arguments)}function N(){return(N=a(m.mark((function n(r,a,i,s,o,u){var p,c,d,y,l,f,h,b;return m.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(void 0===u&&(u=18),p=w[r]){n.next=4;break}throw new Error("Error: API support for the provided chainId "+r+" is not supported");case 4:return n.next=6,fetch(p+"contract_addresses="+a+"&vs_currencies="+o);case 6:if(c=n.sent.json().then((function(e){if(0===Object.keys(e).length)throw new Error("Error: Unsupported fee token.");return Object.values(e)[0]})),"eth"!==o){n.next=16;break}return n.next=11,c;case 11:d=n.sent.eth,n.next=25;break;case 16:if("bnb"!==o){n.next=24;break}return n.next=19,c;case 19:d=n.sent.bnb,n.next=25;break;case 24:throw new Error("Error: Unsupported native token. Use the calculateFeeOnMatic() method for calculating fees on the Matic network.");case 25:return y=new t.BigNumber(10).pow(u).div(new t.BigNumber(10).pow(i.toString())),l=new t.BigNumber(d).multipliedBy(y),f=new t.BigNumber(s.toString()).div(l),h=f.toFixed(0,2),b=parseInt(h)<1?"1":h,n.abrupt("return",e.BigNumber.from(b));case 31:case"end":return n.stop()}}),n)})))).apply(this,arguments)}function M(e,t,n,r){return A.apply(this,arguments)}function A(){return(A=a(m.mark((function n(r,a,i,s){var o,u,p,c,d,y,l,f,h,b;return m.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:n.t0=r,n.next=n.t0===exports.ChainId.MATIC?3:n.t0===exports.ChainId.MOONRIVER?6:9;break;case 3:return o=w[exports.ChainId.MATIC],u="matic-network",n.abrupt("break",10);case 6:return o=w[exports.ChainId.MOONRIVER],u="moonriver",n.abrupt("break",10);case 9:throw new Error("Error: API support for the provided chainId "+r+" is not supported");case 10:return n.next=12,fetch(o+"contract_addresses="+a+"&vs_currencies=bnb");case 12:return p=n.sent.json().then((function(e){if(0===Object.keys(e).length)throw new Error("Error: Unsupported fee token.");return Object.values(e)[0]})),n.next=16,p;case 16:return c=new t.BigNumber(n.sent.bnb).multipliedBy(new t.BigNumber(10).pow(18)).div(new t.BigNumber(10).pow(i.toString())),d="https://api.coingecko.com/api/v3/simple/price?ids="+u+"&vs_currencies=bnb",n.next=22,fetch(d);case 22:return y=n.sent,n.next=25,y.json();case 25:return l=new t.BigNumber(n.sent[u].bnb),f=new t.BigNumber(s.toString()).div(c.div(l)),h=f.toFixed(0,2),b=parseInt(h)<1?"1":h,n.abrupt("return",e.BigNumber.from(b));case 33:case"end":return n.stop()}}),n)})))).apply(this,arguments)}function C(e,t,n,r,a,i){return O.apply(this,arguments)}function O(){return(O=a(m.mark((function e(t,n,r,a,i,s){return m.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:void 0===s&&(s=18),e.t0=t,e.next=e.t0===exports.ChainId.MATIC?4:e.t0===exports.ChainId.MAINNET?5:e.t0===exports.ChainId.BSC?6:e.t0===exports.ChainId.ARBITRUM?7:e.t0===exports.ChainId.MOONRIVER?8:9;break;case 4:return e.abrupt("return",M(t,n,r,a));case 5:return e.abrupt("return",E(t,n,r,a,"eth",s));case 6:return e.abrupt("return",E(t,n,r,a,"bnb",s));case 7:return e.abrupt("return",E(t,n,r,a,"eth",s));case 8:return e.abrupt("return",M(t,n,r,a));case 9:return e.abrupt("return",E(t,n,r,a,i,s));case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var I=[{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"}],S=[{name:"from",type:"address"},{name:"to",type:"address"},{name:"feeToken",type:"address"},{name:"useOraclePriceFeed",type:"bool"},{name:"maxTokenAmount",type:"uint256"},{name:"deadline",type:"uint256"},{name:"nonce",type:"uint256"},{name:"data",type:"bytes"},{name:"extendCategories",type:"uint256[]"}];function k(e,t,r){return{name:r,version:"1",chainId:n.BigNumber.from(t).toHexString(),verifyingContract:e}}var R=e.utils.Interface;function _(e,t){return B.apply(this,arguments)}function B(){return(B=a(m.mark((function e(t,n){var r,a,s,u,p,c,d,y,l;return m.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=null;case 1:if(null!==r){e.next=7;break}return e.next=4,t.getTransactionReceipt(n.result.txnHash);case 4:r=e.sent,e.next=1;break;case 7:s=o(r.logs);case 9:if((u=s()).done){e.next=21;break}if("0xf624f223d0e1427abaf1ac2d9cf7c8487cad3018f0a93b5dafa867aed96165a3"!==(p=u.value).topics[0]){e.next=19;break}if(c=new R(["event MetaStatus(address sender, bool success, string error)"]),d=c.parseLog(p),l=(y=d.args).error,!1!==y.success){e.next=19;break}return a=i({},n,{result:{txnHash:n.result.txnHash,success:!1,errorMessage:l}}),e.abrupt("return",a);case 19:e.next=9;break;case 21:return e.abrupt("return",n);case 22:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function L(e,t,n){return F.apply(this,arguments)}function F(){return(F=a(m.mark((function t(n,r,a){var i,s,u,p,c,d,y,l,f,h,b,v;return m.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:i=null;case 1:if(null!==i){t.next=7;break}return t.next=4,n.getTransactionReceipt(r);case 4:i=t.sent,t.next=1;break;case 7:for(s=i.logs,u=e.BigNumber.from(0),p=e.BigNumber.from(0),c=o(s);!(d=c()).done;)"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"===(y=d.value).topics[0]&&(l="0x"+y.topics[1].slice(26),f="0x"+y.topics[2].slice(26),l!==f&&(h=new R(["event Transfer(address indexed from, address indexed to, uint256 value)"]),b=h.parseLog(y),v=b.args.value,f===a?u=u.add(v):l===a&&(p=p.add(v))));return t.abrupt("return",u.sub(p));case 12:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var P=[{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"holder",type:"address"}],name:"nonces",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"holder",type:"address"},{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"bool",name:"allowed",type:"bool"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"permit",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"holder",type:"address"},{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"permit",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"}],j=[{inputs:[{internalType:"address",name:"_forwarder",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{inputs:[],name:"conveyorIsEnabled",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"disableConveyorProtection",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"enableConveyorProtection",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"forwarder",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"_forwarder",type:"address"}],name:"isTrustedForwarder",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"_forwarder",type:"address"}],name:"setForwarder",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"}],H=[{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"sender",type:"address"},{indexed:!1,internalType:"bool",name:"success",type:"bool"},{indexed:!1,internalType:"string",name:"error",type:"string"}],name:"MetaStatus",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{inputs:[],name:"DOMAIN_TYPEHASH",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"FORWARDER_TYPEHASH",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"aggregator",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"constantFee",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"address",name:"feeToken",type:"address"},{internalType:"bool",name:"useOraclePriceFeed",type:"bool"},{internalType:"uint256",name:"maxTokenAmount",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"},{internalType:"uint256[]",name:"extendCategories",type:"uint256[]"}],internalType:"struct ConveyorTypes.MetaTransaction",name:"metatx",type:"tuple"},{internalType:"string",name:"domainName",type:"string"},{internalType:"bool",name:"relayerChargeEnabled",type:"bool"},{internalType:"uint256",name:"tokenPricePerNativeToken",type:"uint256"},{components:[{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],internalType:"struct ConveyorTypes.Sig",name:"sig",type:"tuple"},{internalType:"bytes",name:"extendParamData",type:"bytes"}],name:"executeMetaTx",outputs:[{internalType:"bool",name:"success",type:"bool"},{internalType:"bytes",name:"data",type:"bytes"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"nonces",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"relayers",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"_aggregator",type:"address"}],name:"setAggregator",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"_newConstantFee",type:"uint256"}],name:"setConstantFee",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"_relayer",type:"address"},{internalType:"bool",name:"_trusted",type:"bool"}],name:"setRelayer",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"_newTransferFee",type:"uint256"}],name:"setTransferFee",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"transferFee",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"withdraw",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"address",name:"feeReceiver",type:"address"}],name:"withdrawFeeTokens",outputs:[],stateMutability:"nonpayable",type:"function"}],D=e.utils.splitSignature,V=e.utils.verifyTypedData,U=e.constants.AddressZero;function Y(e,t){return G.apply(this,arguments)}function G(){return(G=a(m.mark((function e(t,n){return m.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getCode(n);case 2:return e.abrupt("return",e.sent.length>2);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function K(e,t,n,r,a,i){return X.apply(this,arguments)}function X(){return(X=a(m.mark((function e(t,n,r,a,i,s){var o,u,p,c;return m.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,k(r,n,a);case 2:return u={types:{EIP712Domain:I,Forwarder:S},domain:o=e.sent,primaryType:"Forwarder",message:i},p=JSON.stringify(u),e.next=7,t.send("eth_signTypedData_v4",[s,p]);case 7:return c=e.sent,i.from===s&&J(o,i,c,s),e.abrupt("return",{sig:c,msg:u});case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function q(e,t){return{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",method:e,id:1,params:t})}}function J(e,t,n,r){var a=V(e,{Forwarder:S},t,n);if(a!==r||a===U)throw new Error("Signature verification failed")}exports.Conveyor=function(){function t(e,t){this.provider=e,this.forwarderAddress=(null==t?void 0:t.forwarder)||T[e.network.chainId],this.relayerConfig=(null==t?void 0:t.relayerConfig)||v(exports.ENVIRONMENT.PRODUCTION||(null==t?void 0:t.env))}var n=t.prototype;return n.fetchConveyorStatus=function(){var t=a(m.mark((function t(n){var r;return m.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new e.Contract(n,j,this.provider),t.next=3,r.conveyorIsEnabled();case 3:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),n.toggleConveyorProtection=function(){var t=a(m.mark((function t(n,r){var a,i,s,o;return m.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=new e.Contract(n,j,this.provider),t.next=3,this.provider.getSigner();case 3:if(i=t.sent,!r){t.next=10;break}return t.next=7,a.connect(i).enableConveyorProtection();case 7:s=t.sent,t.next=13;break;case 10:return t.next=12,a.connect(i).disableConveyorProtection();case 12:s=t.sent;case 13:return t.next=15,s.wait();case 15:return t.abrupt("return",{id:1,jsonrpc:"2.0",result:{success:1===(o=t.sent).status,errorMessage:1===o.status?"":"Transaction Reverted",txnHash:o.transactionHash}});case 17:case"end":return t.stop()}}),t,this)})));return function(e,n){return t.apply(this,arguments)}}(),n.erc20ApproveForwarder=function(){var t=a(m.mark((function t(n,r){var a,i,s,o;return m.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=new e.Contract(r,P,this.provider),t.next=3,this.provider.getSigner();case 3:return i=t.sent,t.next=6,a.connect(i).approve(this.forwarderAddress,n);case 6:return s=t.sent,t.next=9,s.wait();case 9:return t.abrupt("return",{id:1,jsonrpc:"2.0",result:{success:1===(o=t.sent).status,errorMessage:1===o.status?"":"Transaction Reverted",txnHash:o.transactionHash}});case 11:case"end":return t.stop()}}),t,this)})));return function(e,n){return t.apply(this,arguments)}}(),n.getFeeFromTxn=function(){var e=a(m.mark((function e(t){return m.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,L(this.provider,t,this.forwarderAddress);case 2:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.submitConveyorTransaction=function(){var t=a(m.mark((function t(n,r,a,i,s,o,u,p,c,d,y){var l,f,h,b,v,T,g,x,w,E,N,M,A,O,I,S,k,R,B,L,F,j,V;return m.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===y&&(y=[]),t.next=3,this.fetchConveyorStatus(p);case 3:if(t.sent){t.next=6;break}return t.abrupt("return",this.submitTransaction(p,c,d,y));case 6:return l=new e.Contract(p,c,this.provider),f=new e.Contract(this.forwarderAddress,H,this.provider),h=l.interface.encodeFunctionData(d,y),t.next=11,this.provider.network.chainId;case 11:return b=t.sent,t.next=14,this.provider.getSigner();case 14:return v=t.sent,t.next=17,v.getAddress();case 17:return T=t.sent,g=e.BigNumber.from(r).mul(e.BigNumber.from(a)),x=new e.Contract(n,P,this.provider),t.next=22,x.decimals();case 22:if(w=t.sent,n!==U){t.next=27;break}t.t0=e.BigNumber.from(0),t.next=30;break;case 27:return t.next=29,C(b,n,w,g);case 29:t.t0=t.sent;case 30:return E=t.t0,t.next=33,f.nonces(T);case 33:return N=t.sent,M=Math.floor(Date.now()/1e3),A=e.BigNumber.from(M).add(e.BigNumber.from(i)),O=u.map((function(t){return e.BigNumber.from(t).toHexString()})),I={from:T,to:p,feeToken:n,useOraclePriceFeed:o,maxTokenAmount:E.toHexString(),deadline:A.toHexString(),nonce:N.toHexString(),data:h,extendCategories:O},t.next=40,K(this.provider,b,this.forwarderAddress,s,I,T);case 40:return k=(S=t.sent).msg,R=D(S.sig),B=[k,R.v.toString(),R.r,R.s],L=q("/v3/metaTx/execute",B),console.log("sending request..."),console.log(L),t.next=50,fetch(this.relayerConfig,L);case 50:return F=t.sent,t.next=53,F.json();case 53:if(V=j=t.sent,!j.result.success){t.next=60;break}return t.next=59,_(this.provider,j);case 59:V=t.sent;case 60:return console.log("response received..."),console.log(V),t.abrupt("return",V);case 63:case"end":return t.stop()}}),t,this)})));return function(e,n,r,a,i,s,o,u,p,c,d){return t.apply(this,arguments)}}(),n.submitMetaTransaction=function(){var t=a(m.mark((function t(n,r,a,i,s,o,u,p,c,d,y,l){var f,h,b,v,T,g,x,w,E,N,M,A,O,I,S,k,R,B,L,F,j,D;return m.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===l&&(l=[]),t.next=3,this.fetchConveyorStatus(c);case 3:if(t.sent){t.next=6;break}return t.abrupt("return",this.submitTransaction(c,d,y,l));case 6:return f=new e.Contract(c,d,this.provider),h=new e.Contract(this.forwarderAddress,H,this.provider),b=f.interface.encodeFunctionData(y,l),t.next=11,this.provider.network.chainId;case 11:return v=t.sent,t.next=14,this.provider.getSigner();case 14:return T=t.sent,t.next=17,T.getAddress();case 17:return g=t.sent,x=e.BigNumber.from(r).mul(e.BigNumber.from(a)),w=new e.Contract(n,P,this.provider),t.next=22,w.decimals();case 22:if(E=t.sent,n!==U){t.next=27;break}t.t0=e.BigNumber.from(0),t.next=30;break;case 27:return t.next=29,C(v,n,E,x);case 29:t.t0=t.sent;case 30:return N=t.t0,t.next=33,h.nonces(g);case 33:return M=t.sent,A=Math.floor(Date.now()/1e3),O=e.BigNumber.from(A).add(e.BigNumber.from(i)),I=u.map((function(t){return e.BigNumber.from(t).toHexString()})),S={from:p,to:c,feeToken:n,useOraclePriceFeed:o,maxTokenAmount:N.toHexString(),deadline:O.toHexString(),nonce:M.toHexString(),data:b,extendCategories:I},t.next=40,K(this.provider,v,this.forwarderAddress,s,S,g);case 40:return R=(k=t.sent).sig,B=k.msg,t.next=45,Y(this.provider,p);case 45:return L=q("/v3/metaTx/executeV2",{signerType:t.sent?"CONTRACT":"EOA",msg:B,sig:R}),console.log("sending request..."),console.log(L),t.next=53,fetch(this.relayerConfig,L);case 53:return F=t.sent,t.next=56,F.json();case 56:if(D=j=t.sent,!j.result.success){t.next=63;break}return t.next=62,_(this.provider,j);case 62:D=t.sent;case 63:return console.log("response received..."),console.log(D),t.abrupt("return",D);case 66:case"end":return t.stop()}}),t,this)})));return function(e,n,r,a,i,s,o,u,p,c,d,y){return t.apply(this,arguments)}}(),n.submitTransaction=function(){var t=a(m.mark((function t(n,r,a,i){var s,o,u,p,c;return m.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===i&&(i=[]),s=new e.Contract(n,r,this.provider),o=s.interface.encodeFunctionData(a,i),t.next=5,this.provider.getSigner();case 5:return u=t.sent,t.next=8,u.sendTransaction({to:n,data:o});case 8:return p=t.sent,t.next=11,p.wait();case 11:return t.abrupt("return",{id:1,jsonrpc:"2.0",result:{success:1===(c=t.sent).status,errorMessage:1===c.status?"":"Transaction Reverted",txnHash:c.transactionHash}});case 13:case"end":return t.stop()}}),t,this)})));return function(e,n,r,a){return t.apply(this,arguments)}}(),t}(),exports.DAI_ADDRESS=g,exports.FORWARDER_ADDRESS=T,exports.RELAYER_ENDPOINT_URL=v,exports.USDC_ADDRESS=x,exports.getFeePrice=C,exports.verifyFee=L,exports.verifyMetaTxnResponse=_; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("ethers"),t=require("bignumber.js"),n=require("@ethersproject/bignumber");function r(e,t,n,r,a,i,s){try{var o=e[i](s),u=o.value}catch(e){return void n(e)}o.done?t(u):Promise.resolve(u).then(r,a)}function a(e){return function(){var t=this,n=arguments;return new Promise((function(a,i){var s=e.apply(t,n);function o(e){r(s,a,i,o,u,"next",e)}function u(e){r(s,a,i,o,u,"throw",e)}o(void 0)}))}}function i(){return(i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function o(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return s(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}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 u,p,c,d,y,l,f,m=(function(e){var t=function(e){var t=Object.prototype,n=t.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},a=r.iterator||"@@iterator",i=r.asyncIterator||"@@asyncIterator",s=r.toStringTag||"@@toStringTag";function o(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{o({},"")}catch(e){o=function(e,t,n){return e[t]=n}}function u(e,t,n,r){var a=Object.create((t&&t.prototype instanceof d?t:d).prototype),i=new E(r||[]);return a._invoke=function(e,t,n){var r="suspendedStart";return function(a,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw i;return{value:void 0,done:!0}}for(n.method=a,n.arg=i;;){var s=n.delegate;if(s){var o=x(s,n);if(o){if(o===c)continue;return o}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=p(e,t,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===c)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}(e,n,i),a}function p(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var c={};function d(){}function y(){}function l(){}var f={};o(f,a,(function(){return this}));var m=Object.getPrototypeOf,h=m&&m(m(N([])));h&&h!==t&&n.call(h,a)&&(f=h);var T=l.prototype=d.prototype=Object.create(f);function b(e){["next","throw","return"].forEach((function(t){o(e,t,(function(e){return this._invoke(t,e)}))}))}function v(e,t){var r;this._invoke=function(a,i){function s(){return new t((function(r,s){!function r(a,i,s,o){var u=p(e[a],e,i);if("throw"!==u.type){var c=u.arg,d=c.value;return d&&"object"==typeof d&&n.call(d,"__await")?t.resolve(d.__await).then((function(e){r("next",e,s,o)}),(function(e){r("throw",e,s,o)})):t.resolve(d).then((function(e){c.value=e,s(c)}),(function(e){return r("throw",e,s,o)}))}o(u.arg)}(a,i,r,s)}))}return r=r?r.then(s,s):s()}}function x(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,x(e,t),"throw"===t.method))return c;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return c}var r=p(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,c;var a=r.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,c):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,c)}function g(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function w(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function E(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(g,this),this.reset(!0)}function N(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,i=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:C}}function C(){return{value:void 0,done:!0}}return y.prototype=l,o(T,"constructor",l),o(l,"constructor",y),y.displayName=o(l,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,o(e,s,"GeneratorFunction")),e.prototype=Object.create(T),e},e.awrap=function(e){return{__await:e}},b(v.prototype),o(v.prototype,i,(function(){return this})),e.AsyncIterator=v,e.async=function(t,n,r,a,i){void 0===i&&(i=Promise);var s=new v(u(t,n,r,a),i);return e.isGeneratorFunction(n)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},b(T),o(T,s,"Generator"),o(T,a,(function(){return this})),o(T,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},e.values=N,E.prototype={constructor:E,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(w),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return s.type="throw",s.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],s=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var o=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(o&&u){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(o){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var i=a;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=e,s.arg=t,i?(this.method="next",this.next=i.finallyLoc,c):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),c},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),w(n),c}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;w(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:N(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),c}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}(f={exports:{}}),f.exports);(u=exports.ChainId||(exports.ChainId={}))[u.MAINNET=1]="MAINNET",u[u.ROPSTEN=3]="ROPSTEN",u[u.RINKEBY=4]="RINKEBY",u[u["GÖRLI"]=5]="GÖRLI",u[u.KOVAN=42]="KOVAN",u[u.MATIC=137]="MATIC",u[u.MATIC_TESTNET=80001]="MATIC_TESTNET",u[u.FANTOM=250]="FANTOM",u[u.FANTOM_TESTNET=4002]="FANTOM_TESTNET",u[u.XDAI=100]="XDAI",u[u.BSC=56]="BSC",u[u.BSC_TESTNET=97]="BSC_TESTNET",u[u.ARBITRUM=42161]="ARBITRUM",u[u.ARBITRUM_TESTNET=79377087078960]="ARBITRUM_TESTNET",u[u.MOONBEAM_TESTNET=1287]="MOONBEAM_TESTNET",u[u.AVALANCHE=43114]="AVALANCHE",u[u.AVALANCHE_TESTNET=43113]="AVALANCHE_TESTNET",u[u.HECO=128]="HECO",u[u.HECO_TESTNET=256]="HECO_TESTNET",u[u.HARMONY=16666e5]="HARMONY",u[u.HARMONY_TESTNET=16667e5]="HARMONY_TESTNET",u[u.OKEX=66]="OKEX",u[u.OKEX_TESTNET=65]="OKEX_TESTNET",u[u.CELO=42220]="CELO",u[u.PALM=11297108109]="PALM",u[u.PALM_TESTNET=11297108099]="PALM_TESTNET",u[u.MOONRIVER=1285]="MOONRIVER",(p=exports.ENVIRONMENT||(exports.ENVIRONMENT={}))[p.TEST=0]="TEST",p[p.PRODUCTION=1]="PRODUCTION";var h,T=((c={})[exports.ENVIRONMENT.TEST]=["https://conveyor-geode-staging.ata.network"],c[exports.ENVIRONMENT.PRODUCTION]=[],c),b=function(e){return(t=T[e])[Math.floor(Math.random()*t.length)];var t},v=((d={})[exports.ChainId.MAINNET]="0x84194C00E190dE7A10180853f6a28502Ad1A1029",d),x=((y={})[exports.ChainId.MAINNET]="0x6B175474E89094C44Da98b954EedeAC495271d0F",y[exports.ChainId.MATIC]="0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",y),g=((l={})[exports.ChainId.MAINNET]="0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",l[exports.ChainId.BSC]="0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",l[exports.ChainId.MATIC]="0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",l),w=((h={})[exports.ChainId.BSC]="https://api.coingecko.com/api/v3/simple/token_price/binance-smart-chain?",h[exports.ChainId.MATIC]="https://api.coingecko.com/api/v3/simple/token_price/polygon-pos?",h[exports.ChainId.MAINNET]="https://api.coingecko.com/api/v3/simple/token_price/ethereum?",h[exports.ChainId.ARBITRUM]="https://api.coingecko.com/api/v3/simple/token_price/arbitrum-one?",h[exports.ChainId.MOONRIVER]="https://api.coingecko.com/api/v3/simple/token_price/moonriver?",h),E=[exports.ChainId.RINKEBY,exports.ChainId.ROPSTEN,exports.ChainId.GÖRLI,exports.ChainId.KOVAN,exports.ChainId.ARBITRUM_TESTNET,exports.ChainId.AVALANCHE_TESTNET,exports.ChainId.HARMONY_TESTNET,exports.ChainId.OKEX_TESTNET,exports.ChainId.BSC_TESTNET,exports.ChainId.PALM_TESTNET,exports.ChainId.MOONBEAM_TESTNET,exports.ChainId.FANTOM_TESTNET,exports.ChainId.MATIC_TESTNET,exports.ChainId.HECO_TESTNET],N=function(e){return E.includes(e)};function C(e,t,n,r,a,i){return M.apply(this,arguments)}function M(){return(M=a(m.mark((function n(r,a,i,s,o,u){var p,c,d,y,l,f,h,T;return m.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(void 0===u&&(u=18),!N(r)){n.next=3;break}return n.abrupt("return",e.BigNumber.from(0));case 3:if(p=w[r]){n.next=6;break}throw new Error("Error: API support for the provided chainId "+r+" is not supported");case 6:return n.next=8,fetch(p+"contract_addresses="+a+"&vs_currencies="+o);case 8:if(c=n.sent.json().then((function(e){if(0===Object.keys(e).length)throw new Error("Error: Unsupported fee token.");return Object.values(e)[0]})),"eth"!==o){n.next=18;break}return n.next=13,c;case 13:d=n.sent.eth,n.next=27;break;case 18:if("bnb"!==o){n.next=26;break}return n.next=21,c;case 21:d=n.sent.bnb,n.next=27;break;case 26:throw new Error("Error: Unsupported native token. Use the calculateFeeOnMatic() method for calculating fees on the Matic network.");case 27:return y=new t.BigNumber(10).pow(u).div(new t.BigNumber(10).pow(i.toString())),l=new t.BigNumber(d).multipliedBy(y),f=new t.BigNumber(s.toString()).div(l),h=f.toFixed(0,2),T=parseInt(h)<1?"1":h,n.abrupt("return",e.BigNumber.from(T));case 33:case"end":return n.stop()}}),n)})))).apply(this,arguments)}function A(e,t,n,r){return O.apply(this,arguments)}function O(){return(O=a(m.mark((function n(r,a,i,s){var o,u,p,c,d,y,l,f,h,T;return m.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:n.t0=r,n.next=n.t0===exports.ChainId.MATIC?3:n.t0===exports.ChainId.MOONRIVER?6:9;break;case 3:return o=w[exports.ChainId.MATIC],u="matic-network",n.abrupt("break",10);case 6:return o=w[exports.ChainId.MOONRIVER],u="moonriver",n.abrupt("break",10);case 9:throw new Error("Error: API support for the provided chainId "+r+" is not supported");case 10:return n.next=12,fetch(o+"contract_addresses="+a+"&vs_currencies=bnb");case 12:return p=n.sent.json().then((function(e){if(0===Object.keys(e).length)throw new Error("Error: Unsupported fee token.");return Object.values(e)[0]})),n.next=16,p;case 16:return c=new t.BigNumber(n.sent.bnb).multipliedBy(new t.BigNumber(10).pow(18)).div(new t.BigNumber(10).pow(i.toString())),d="https://api.coingecko.com/api/v3/simple/price?ids="+u+"&vs_currencies=bnb",n.next=22,fetch(d);case 22:return y=n.sent,n.next=25,y.json();case 25:return l=new t.BigNumber(n.sent[u].bnb),f=new t.BigNumber(s.toString()).div(c.div(l)),h=f.toFixed(0,2),T=parseInt(h)<1?"1":h,n.abrupt("return",e.BigNumber.from(T));case 33:case"end":return n.stop()}}),n)})))).apply(this,arguments)}function I(e,t,n,r,a,i){return S.apply(this,arguments)}function S(){return(S=a(m.mark((function e(t,n,r,a,i,s){return m.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:void 0===s&&(s=18),e.t0=t,e.next=e.t0===exports.ChainId.MATIC?4:e.t0===exports.ChainId.MAINNET?5:e.t0===exports.ChainId.BSC?6:e.t0===exports.ChainId.ARBITRUM?7:e.t0===exports.ChainId.MOONRIVER?8:9;break;case 4:return e.abrupt("return",A(t,n,r,a));case 5:return e.abrupt("return",C(t,n,r,a,"eth",s));case 6:return e.abrupt("return",C(t,n,r,a,"bnb",s));case 7:return e.abrupt("return",C(t,n,r,a,"eth",s));case 8:return e.abrupt("return",A(t,n,r,a));case 9:return e.abrupt("return",C(t,n,r,a,i,s));case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var k=[{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"}],_=[{name:"from",type:"address"},{name:"to",type:"address"},{name:"feeToken",type:"address"},{name:"useOraclePriceFeed",type:"bool"},{name:"maxTokenAmount",type:"uint256"},{name:"deadline",type:"uint256"},{name:"nonce",type:"uint256"},{name:"data",type:"bytes"},{name:"extendCategories",type:"uint256[]"}];function R(e,t,r){return{name:r,version:"1",chainId:n.BigNumber.from(t).toHexString(),verifyingContract:e}}var B=e.utils.Interface;function L(e,t){return P.apply(this,arguments)}function P(){return(P=a(m.mark((function e(t,n){var r,a,s,u,p,c,d,y,l;return m.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=null;case 1:if(null!==r){e.next=7;break}return e.next=4,t.getTransactionReceipt(n.result.txnHash);case 4:r=e.sent,e.next=1;break;case 7:s=o(r.logs);case 9:if((u=s()).done){e.next=21;break}if("0xf624f223d0e1427abaf1ac2d9cf7c8487cad3018f0a93b5dafa867aed96165a3"!==(p=u.value).topics[0]){e.next=19;break}if(c=new B(["event MetaStatus(address sender, bool success, string error)"]),d=c.parseLog(p),l=(y=d.args).error,!1!==y.success){e.next=19;break}return a=i({},n,{result:{txnHash:n.result.txnHash,success:!1,errorMessage:l}}),e.abrupt("return",a);case 19:e.next=9;break;case 21:return e.abrupt("return",n);case 22:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function F(e,t,n){return H.apply(this,arguments)}function H(){return(H=a(m.mark((function t(n,r,a){var i,s,u,p,c,d,y,l,f,h,T,b;return m.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:i=null;case 1:if(null!==i){t.next=7;break}return t.next=4,n.getTransactionReceipt(r);case 4:i=t.sent,t.next=1;break;case 7:for(s=i.logs,u=e.BigNumber.from(0),p=e.BigNumber.from(0),c=o(s);!(d=c()).done;)"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"===(y=d.value).topics[0]&&(l="0x"+y.topics[1].slice(26),f="0x"+y.topics[2].slice(26),l!==f&&(h=new B(["event Transfer(address indexed from, address indexed to, uint256 value)"]),T=h.parseLog(y),b=T.args.value,f===a?u=u.add(b):l===a&&(p=p.add(b))));return t.abrupt("return",u.sub(p));case 12:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var j=[{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"holder",type:"address"}],name:"nonces",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"holder",type:"address"},{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"bool",name:"allowed",type:"bool"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"permit",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"holder",type:"address"},{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"permit",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"}],D=[{inputs:[{internalType:"address",name:"_forwarder",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{inputs:[],name:"conveyorIsEnabled",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"disableConveyorProtection",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"enableConveyorProtection",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"forwarder",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"_forwarder",type:"address"}],name:"isTrustedForwarder",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"_forwarder",type:"address"}],name:"setForwarder",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"}],V=[{anonymous:!1,inputs:[{indexed:!1,internalType:"bool[]",name:"successArr",type:"bool[]"}],name:"BatchedMetaStatus",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"sender",type:"address"},{indexed:!1,internalType:"bool",name:"success",type:"bool"},{indexed:!1,internalType:"string",name:"error",type:"string"}],name:"MetaStatus",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{inputs:[],name:"DOMAIN_TYPEHASH",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"FORWARDER_TYPEHASH",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"aggregator",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"constantFee",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{components:[{components:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"address",name:"feeToken",type:"address"},{internalType:"bool",name:"useOraclePriceFeed",type:"bool"},{internalType:"uint256",name:"maxTokenAmount",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"},{internalType:"uint256[]",name:"extendCategories",type:"uint256[]"}],internalType:"struct ConveyorTypes.MetaTransaction",name:"metatx",type:"tuple"},{internalType:"string",name:"domainName",type:"string"},{internalType:"bool",name:"relayerChargeEnabled",type:"bool"},{internalType:"uint256",name:"tokenPricePerNativeToken",type:"uint256"},{internalType:"enum SignatureValidator.SignatureSignerType",name:"signerType",type:"uint8"},{internalType:"bytes",name:"sig",type:"bytes"},{internalType:"bytes",name:"extendParamData",type:"bytes"}],internalType:"struct ConveyorForwarder.ConveyorTransaction[]",name:"conveyorTransactions",type:"tuple[]"}],name:"executeBatchedMetaTx",outputs:[{internalType:"bool[]",name:"",type:"bool[]"},{internalType:"bytes[]",name:"",type:"bytes[]"}],stateMutability:"payable",type:"function"},{inputs:[{components:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"address",name:"feeToken",type:"address"},{internalType:"bool",name:"useOraclePriceFeed",type:"bool"},{internalType:"uint256",name:"maxTokenAmount",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"},{internalType:"uint256[]",name:"extendCategories",type:"uint256[]"}],internalType:"struct ConveyorTypes.MetaTransaction",name:"metatx",type:"tuple"},{internalType:"string",name:"domainName",type:"string"},{internalType:"bool",name:"relayerChargeEnabled",type:"bool"},{internalType:"uint256",name:"tokenPricePerNativeToken",type:"uint256"},{internalType:"enum SignatureValidator.SignatureSignerType",name:"signerType",type:"uint8"},{internalType:"bytes",name:"sig",type:"bytes"},{internalType:"bytes",name:"extendParamData",type:"bytes"}],name:"executeMetaTxV2",outputs:[{internalType:"bool",name:"success",type:"bool"},{internalType:"bytes",name:"data",type:"bytes"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"nonces",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"relayers",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"_aggregator",type:"address"}],name:"setAggregator",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"_newConstantFee",type:"uint256"}],name:"setConstantFee",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"_relayer",type:"address"},{internalType:"bool",name:"_trusted",type:"bool"}],name:"setRelayer",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"_newTransferFee",type:"uint256"}],name:"setTransferFee",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"transferFee",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"withdraw",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"address",name:"feeReceiver",type:"address"}],name:"withdrawFeeTokens",outputs:[],stateMutability:"nonpayable",type:"function"}],U=e.utils.splitSignature,Y=e.utils.verifyTypedData,G=e.constants.AddressZero;function K(e,t){return X.apply(this,arguments)}function X(){return(X=a(m.mark((function e(t,n){return m.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getCode(n);case 2:return e.abrupt("return",e.sent.length>2);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function q(e,t,n,r,a,i){return J.apply(this,arguments)}function J(){return(J=a(m.mark((function e(t,n,r,a,i,s){var o,u,p,c;return m.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,R(r,n,a);case 2:return u={types:{EIP712Domain:k,Forwarder:_},domain:o=e.sent,primaryType:"Forwarder",message:i},p=JSON.stringify(u),e.next=7,t.send("eth_signTypedData_v4",[s,p]);case 7:return c=e.sent,i.from===s&&Z(o,i,c,s),e.abrupt("return",{sig:c,msg:u});case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function W(e,t){return{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",method:e,id:1,params:t})}}function Z(e,t,n,r){var a=Y(e,{Forwarder:_},t,n);if(a!==r||a===G)throw new Error("Signature verification failed")}exports.Conveyor=function(){function t(e,t){this.provider=e,this.forwarderAddress=(null==t?void 0:t.forwarder)||v[e.network.chainId],this.relayerConfig=(null==t?void 0:t.relayerConfig)||b(exports.ENVIRONMENT.PRODUCTION||(null==t?void 0:t.env))}var n=t.prototype;return n.fetchConveyorStatus=function(){var t=a(m.mark((function t(n){var r;return m.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new e.Contract(n,D,this.provider),t.next=3,r.conveyorIsEnabled();case 3:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),n.toggleConveyorProtection=function(){var t=a(m.mark((function t(n,r){var a,i,s,o;return m.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=new e.Contract(n,D,this.provider),t.next=3,this.provider.getSigner();case 3:if(i=t.sent,!r){t.next=10;break}return t.next=7,a.connect(i).enableConveyorProtection();case 7:s=t.sent,t.next=13;break;case 10:return t.next=12,a.connect(i).disableConveyorProtection();case 12:s=t.sent;case 13:return t.next=15,s.wait();case 15:return t.abrupt("return",{id:1,jsonrpc:"2.0",result:{success:1===(o=t.sent).status,errorMessage:1===o.status?"":"Transaction Reverted",txnHash:o.transactionHash}});case 17:case"end":return t.stop()}}),t,this)})));return function(e,n){return t.apply(this,arguments)}}(),n.erc20ApproveForwarder=function(){var t=a(m.mark((function t(n,r){var a,i,s,o;return m.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=new e.Contract(r,j,this.provider),t.next=3,this.provider.getSigner();case 3:return i=t.sent,t.next=6,a.connect(i).approve(this.forwarderAddress,n);case 6:return s=t.sent,t.next=9,s.wait();case 9:return t.abrupt("return",{id:1,jsonrpc:"2.0",result:{success:1===(o=t.sent).status,errorMessage:1===o.status?"":"Transaction Reverted",txnHash:o.transactionHash}});case 11:case"end":return t.stop()}}),t,this)})));return function(e,n){return t.apply(this,arguments)}}(),n.getFeeFromTxn=function(){var e=a(m.mark((function e(t){return m.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,F(this.provider,t,this.forwarderAddress);case 2:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.submitConveyorTransaction=function(){var t=a(m.mark((function t(n,r,a,i,s,o,u,p,c,d,y){var l,f,h,T,b,v,x,g,w,E,N,C,M,A,O,S,k,_,R,B,P,F,H;return m.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===y&&(y=[]),t.next=3,this.fetchConveyorStatus(p);case 3:if(t.sent){t.next=6;break}return t.abrupt("return",this.submitTransaction(p,c,d,y));case 6:return l=new e.Contract(p,c,this.provider),f=new e.Contract(this.forwarderAddress,V,this.provider),h=l.interface.encodeFunctionData(d,y),t.next=11,this.provider.network.chainId;case 11:return T=t.sent,t.next=14,this.provider.getSigner();case 14:return b=t.sent,t.next=17,b.getAddress();case 17:if(v=t.sent,x=e.BigNumber.from(r).mul(e.BigNumber.from(a)),!(g=n!==G?new e.Contract(n,j,this.provider):void 0)){t.next=26;break}return t.next=23,g.decimals();case 23:t.t0=t.sent,t.next=27;break;case 26:t.t0=void 0;case 27:if(w=t.t0,n===G||null==w){t.next=34;break}return t.next=31,I(T,n,w,x);case 31:t.t1=t.sent,t.next=35;break;case 34:t.t1=e.BigNumber.from(0);case 35:return E=t.t1,t.next=38,f.nonces(v);case 38:return N=t.sent,C=Math.floor(Date.now()/1e3),M=e.BigNumber.from(C).add(e.BigNumber.from(i)),A=u.map((function(t){return e.BigNumber.from(t).toHexString()})),O={from:v,to:p,feeToken:n,useOraclePriceFeed:o,maxTokenAmount:E.toHexString(),deadline:M.toHexString(),nonce:N.toHexString(),data:h,extendCategories:A},t.next=45,q(this.provider,T,this.forwarderAddress,s,O,v);case 45:return k=(S=t.sent).msg,_=U(S.sig),R=[k,_.v.toString(),_.r,_.s],B=W("/v3/metaTx/execute",R),console.log("sending request..."),console.log(B),t.next=55,fetch(this.relayerConfig,B);case 55:return P=t.sent,t.next=58,P.json();case 58:if(H=F=t.sent,!F.result.success){t.next=65;break}return t.next=64,L(this.provider,F);case 64:H=t.sent;case 65:return console.log("response received..."),console.log(H),t.abrupt("return",H);case 68:case"end":return t.stop()}}),t,this)})));return function(e,n,r,a,i,s,o,u,p,c,d){return t.apply(this,arguments)}}(),n.submitMetaTransaction=function(){var t=a(m.mark((function t(n,r,a,i,s,o,u,p,c,d,y,l){var f,h,T,b,v,x,g,w,E,N,C,M,A,O,S,k,_,R,B,P,F,H;return m.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===l&&(l=[]),t.next=3,this.fetchConveyorStatus(c);case 3:if(t.sent){t.next=6;break}return t.abrupt("return",this.submitTransaction(c,d,y,l));case 6:return f=new e.Contract(c,d,this.provider),h=new e.Contract(this.forwarderAddress,V,this.provider),T=f.interface.encodeFunctionData(y,l),t.next=11,this.provider.network.chainId;case 11:return b=t.sent,t.next=14,this.provider.getSigner();case 14:return v=t.sent,t.next=17,v.getAddress();case 17:if(x=t.sent,g=e.BigNumber.from(r).mul(e.BigNumber.from(a)),!(w=n!==G?new e.Contract(n,j,this.provider):void 0)){t.next=26;break}return t.next=23,w.decimals();case 23:t.t0=t.sent,t.next=27;break;case 26:t.t0=void 0;case 27:if(E=t.t0,n===G||null==E){t.next=34;break}return t.next=31,I(b,n,E,g);case 31:t.t1=t.sent,t.next=35;break;case 34:t.t1=e.BigNumber.from(0);case 35:return N=t.t1,t.next=38,h.nonces(x);case 38:return C=t.sent,M=Math.floor(Date.now()/1e3),A=e.BigNumber.from(M).add(e.BigNumber.from(i)),O=u.map((function(t){return e.BigNumber.from(t).toHexString()})),S={from:p,to:c,feeToken:n,useOraclePriceFeed:o,maxTokenAmount:N.toHexString(),deadline:A.toHexString(),nonce:C.toHexString(),data:T,extendCategories:O},t.next=45,q(this.provider,b,this.forwarderAddress,s,S,x);case 45:return _=(k=t.sent).sig,R=k.msg,t.next=50,K(this.provider,p);case 50:return B=W("/v3/metaTx/executeV2",{signerType:t.sent?"CONTRACT":"EOA",msg:R,sig:_}),console.log("sending request..."),console.log(B),t.next=58,fetch(this.relayerConfig,B);case 58:return P=t.sent,t.next=61,P.json();case 61:if(H=F=t.sent,!F.result.success){t.next=68;break}return t.next=67,L(this.provider,F);case 67:H=t.sent;case 68:return console.log("response received..."),console.log(H),t.abrupt("return",H);case 71:case"end":return t.stop()}}),t,this)})));return function(e,n,r,a,i,s,o,u,p,c,d,y){return t.apply(this,arguments)}}(),n.submitTransaction=function(){var t=a(m.mark((function t(n,r,a,i){var s,o,u,p,c;return m.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===i&&(i=[]),s=new e.Contract(n,r,this.provider),o=s.interface.encodeFunctionData(a,i),t.next=5,this.provider.getSigner();case 5:return u=t.sent,t.next=8,u.sendTransaction({to:n,data:o});case 8:return p=t.sent,t.next=11,p.wait();case 11:return t.abrupt("return",{id:1,jsonrpc:"2.0",result:{success:1===(c=t.sent).status,errorMessage:1===c.status?"":"Transaction Reverted",txnHash:c.transactionHash}});case 13:case"end":return t.stop()}}),t,this)})));return function(e,n,r,a){return t.apply(this,arguments)}}(),t}(),exports.DAI_ADDRESS=x,exports.FORWARDER_ADDRESS=v,exports.RELAYER_ENDPOINT_URL=b,exports.USDC_ADDRESS=g,exports.getFeePrice=I,exports.verifyFee=F,exports.verifyMetaTxnResponse=L; | ||
//# sourceMappingURL=conveyor-sdk.cjs.production.min.js.map |
{ | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"license": "MIT", | ||
@@ -4,0 +4,0 @@ "main": "dist/index.js", |
@@ -8,2 +8,15 @@ { | ||
"indexed": false, | ||
"internalType": "bool[]", | ||
"name": "successArr", | ||
"type": "bool[]" | ||
} | ||
], | ||
"name": "BatchedMetaStatus", | ||
"type": "event" | ||
}, | ||
{ | ||
"anonymous": false, | ||
"inputs": [ | ||
{ | ||
"indexed": false, | ||
"internalType": "address", | ||
@@ -105,2 +118,110 @@ "name": "sender", | ||
{ | ||
"components": [ | ||
{ | ||
"internalType": "address", | ||
"name": "from", | ||
"type": "address" | ||
}, | ||
{ | ||
"internalType": "address", | ||
"name": "to", | ||
"type": "address" | ||
}, | ||
{ | ||
"internalType": "address", | ||
"name": "feeToken", | ||
"type": "address" | ||
}, | ||
{ | ||
"internalType": "bool", | ||
"name": "useOraclePriceFeed", | ||
"type": "bool" | ||
}, | ||
{ | ||
"internalType": "uint256", | ||
"name": "maxTokenAmount", | ||
"type": "uint256" | ||
}, | ||
{ | ||
"internalType": "uint256", | ||
"name": "deadline", | ||
"type": "uint256" | ||
}, | ||
{ | ||
"internalType": "uint256", | ||
"name": "nonce", | ||
"type": "uint256" | ||
}, | ||
{ | ||
"internalType": "bytes", | ||
"name": "data", | ||
"type": "bytes" | ||
}, | ||
{ | ||
"internalType": "uint256[]", | ||
"name": "extendCategories", | ||
"type": "uint256[]" | ||
} | ||
], | ||
"internalType": "struct ConveyorTypes.MetaTransaction", | ||
"name": "metatx", | ||
"type": "tuple" | ||
}, | ||
{ | ||
"internalType": "string", | ||
"name": "domainName", | ||
"type": "string" | ||
}, | ||
{ | ||
"internalType": "bool", | ||
"name": "relayerChargeEnabled", | ||
"type": "bool" | ||
}, | ||
{ | ||
"internalType": "uint256", | ||
"name": "tokenPricePerNativeToken", | ||
"type": "uint256" | ||
}, | ||
{ | ||
"internalType": "enum SignatureValidator.SignatureSignerType", | ||
"name": "signerType", | ||
"type": "uint8" | ||
}, | ||
{ | ||
"internalType": "bytes", | ||
"name": "sig", | ||
"type": "bytes" | ||
}, | ||
{ | ||
"internalType": "bytes", | ||
"name": "extendParamData", | ||
"type": "bytes" | ||
} | ||
], | ||
"internalType": "struct ConveyorForwarder.ConveyorTransaction[]", | ||
"name": "conveyorTransactions", | ||
"type": "tuple[]" | ||
} | ||
], | ||
"name": "executeBatchedMetaTx", | ||
"outputs": [ | ||
{ | ||
"internalType": "bool[]", | ||
"name": "", | ||
"type": "bool[]" | ||
}, | ||
{ | ||
"internalType": "bytes[]", | ||
"name": "", | ||
"type": "bytes[]" | ||
} | ||
], | ||
"stateMutability": "payable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"components": [ | ||
{ | ||
"internalType": "address", | ||
@@ -171,22 +292,10 @@ "name": "from", | ||
{ | ||
"components": [ | ||
{ | ||
"internalType": "uint8", | ||
"name": "v", | ||
"type": "uint8" | ||
}, | ||
{ | ||
"internalType": "bytes32", | ||
"name": "r", | ||
"type": "bytes32" | ||
}, | ||
{ | ||
"internalType": "bytes32", | ||
"name": "s", | ||
"type": "bytes32" | ||
} | ||
], | ||
"internalType": "struct ConveyorTypes.Sig", | ||
"internalType": "enum SignatureValidator.SignatureSignerType", | ||
"name": "signerType", | ||
"type": "uint8" | ||
}, | ||
{ | ||
"internalType": "bytes", | ||
"name": "sig", | ||
"type": "tuple" | ||
"type": "bytes" | ||
}, | ||
@@ -199,3 +308,3 @@ { | ||
], | ||
"name": "executeMetaTx", | ||
"name": "executeMetaTxV2", | ||
"outputs": [ | ||
@@ -202,0 +311,0 @@ { |
@@ -171,8 +171,11 @@ import { ENVIRONMENT } from './lib/enums'; | ||
const txnFee = BigNumber.from(gasLimit).mul(BigNumber.from(gasPrice)); | ||
const feeErc20 = new Contract(feeToken, erc20Abi, this.provider); | ||
const feeDecimal = await feeErc20.decimals(); | ||
const feeErc20 = | ||
feeToken !== zeroAddress | ||
? new Contract(feeToken, erc20Abi, this.provider) | ||
: undefined; | ||
const feeDecimal = feeErc20 ? await feeErc20.decimals() : undefined; | ||
const maxTokenAmount = | ||
feeToken === zeroAddress | ||
? BigNumber.from(0) | ||
: await getFeePrice(chainId, feeToken, feeDecimal, txnFee); | ||
feeToken !== zeroAddress && feeDecimal != null | ||
? await getFeePrice(chainId, feeToken, feeDecimal, txnFee) | ||
: BigNumber.from(0); | ||
const nonce = await forwarder.nonces(signerAddress); | ||
@@ -278,8 +281,11 @@ const now = Math.floor(Date.now() / 1000); | ||
const txnFee = BigNumber.from(gasLimit).mul(BigNumber.from(gasPrice)); | ||
const feeErc20 = new Contract(feeToken, erc20Abi, this.provider); | ||
const feeDecimal = await feeErc20.decimals(); | ||
const feeErc20 = | ||
feeToken !== zeroAddress | ||
? new Contract(feeToken, erc20Abi, this.provider) | ||
: undefined; | ||
const feeDecimal = feeErc20 ? await feeErc20.decimals() : undefined; | ||
const maxTokenAmount = | ||
feeToken === zeroAddress | ||
? BigNumber.from(0) | ||
: await getFeePrice(chainId, feeToken, feeDecimal, txnFee); | ||
feeToken !== zeroAddress && feeDecimal != null | ||
? await getFeePrice(chainId, feeToken, feeDecimal, txnFee) | ||
: BigNumber.from(0); | ||
const nonce = await forwarder.nonces(signerAddress); | ||
@@ -286,0 +292,0 @@ const now = Math.floor(Date.now() / 1000); |
@@ -18,2 +18,21 @@ import { BigNumber } from 'ethers'; | ||
const TESTNET = [ | ||
ChainId.RINKEBY, | ||
ChainId.ROPSTEN, | ||
ChainId.GÖRLI, | ||
ChainId.KOVAN, | ||
ChainId.ARBITRUM_TESTNET, | ||
ChainId.AVALANCHE_TESTNET, | ||
ChainId.HARMONY_TESTNET, | ||
ChainId.OKEX_TESTNET, | ||
ChainId.BSC_TESTNET, | ||
ChainId.PALM_TESTNET, | ||
ChainId.MOONBEAM_TESTNET, | ||
ChainId.FANTOM_TESTNET, | ||
ChainId.MATIC_TESTNET, | ||
ChainId.HECO_TESTNET, | ||
]; | ||
const isTestNet = (chainId: ChainId): boolean => TESTNET.includes(chainId); | ||
/** | ||
@@ -37,2 +56,5 @@ * This function converts a transaction fee to the equivalent value of the provided payment token | ||
): Promise<BigNumber> { | ||
if (isTestNet(chainId)) { | ||
return BigNumber.from(0); | ||
} | ||
const priceApiPrefix = PRICE_API_PREFIX[chainId]; | ||
@@ -39,0 +61,0 @@ if (!priceApiPrefix) { |
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
571451
8655