-
Notifications
You must be signed in to change notification settings - Fork 0
/
8369.26679a8f600da27f6e07.js
1 lines (1 loc) · 9.6 KB
/
8369.26679a8f600da27f6e07.js
1
"use strict";(self.webpackChunktimeless_frontend=self.webpackChunktimeless_frontend||[]).push([[8369],{78369:(k,c,m)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.SafeAppProvider=void 0;var p=m(29941);Object.defineProperty(c,"SafeAppProvider",{enumerable:!0,get:function(){return p.SafeAppProvider}})},29941:(k,c,m)=>{var p=m(31325).default;Object.defineProperty(c,"__esModule",{value:!0}),c.SafeAppProvider=void 0;const T=m(93105),w=m(95884);c.SafeAppProvider=class extends T.EventEmitter{constructor(h,i){super(),this.submittedTxs=new Map,this.safe=h,this.sdk=i}connect(){var h=this;return p(function*(){h.emit("connect",{chainId:h.chainId})})()}disconnect(){return p(function*(){})()}get chainId(){return this.safe.chainId}request(h){var i=this;return p(function*(){const{method:L,params:u=[]}=h;switch(L){case"eth_accounts":return[i.safe.safeAddress];case"net_version":case"eth_chainId":return`0x${i.chainId.toString(16)}`;case"personal_sign":{const[d,l]=u;if(i.safe.safeAddress.toLowerCase()!==l.toLowerCase())throw new Error("The address or message hash is invalid");const _=yield i.sdk.txs.signMessage(d);return("signature"in _?_.signature:void 0)||"0x"}case"eth_sign":{const[d,l]=u;if(i.safe.safeAddress.toLowerCase()!==d.toLowerCase()||!l.startsWith("0x"))throw new Error("The address or message hash is invalid");const _=yield i.sdk.txs.signMessage(l);return("signature"in _?_.signature:void 0)||"0x"}case"eth_signTypedData":case"eth_signTypedData_v4":{const[d,l]=u,_="string"==typeof l?JSON.parse(l):l;if(i.safe.safeAddress.toLowerCase()!==d.toLowerCase())throw new Error("The address is invalid");const x=yield i.sdk.txs.signTypedMessage(_);return("signature"in x?x.signature:void 0)||"0x"}case"eth_sendTransaction":const v=Object.assign({value:"0",data:"0x"},u[0]);"string"==typeof v.gas&&v.gas.startsWith("0x")&&(v.gas=parseInt(v.gas,16));const b=yield i.sdk.txs.send({txs:[v],params:{safeTxGas:v.gas}});return i.submittedTxs.set(b.safeTxHash,{from:i.safe.safeAddress,hash:b.safeTxHash,gas:0,gasPrice:"0x00",nonce:0,input:v.data,value:v.value,to:v.to,blockHash:null,blockNumber:null,transactionIndex:null}),b.safeTxHash;case"eth_blockNumber":return(yield i.sdk.eth.getBlockByNumber(["latest"])).number;case"eth_getBalance":return i.sdk.eth.getBalance([(0,w.getLowerCase)(u[0]),u[1]]);case"eth_getCode":return i.sdk.eth.getCode([(0,w.getLowerCase)(u[0]),u[1]]);case"eth_getTransactionCount":return i.sdk.eth.getTransactionCount([(0,w.getLowerCase)(u[0]),u[1]]);case"eth_getStorageAt":return i.sdk.eth.getStorageAt([(0,w.getLowerCase)(u[0]),u[1],u[2]]);case"eth_getBlockByNumber":return i.sdk.eth.getBlockByNumber([u[0],u[1]]);case"eth_getBlockByHash":return i.sdk.eth.getBlockByHash([u[0],u[1]]);case"eth_getTransactionByHash":let y=u[0];try{y=(yield i.sdk.txs.getBySafeTxHash(y)).txHash||y}catch{}return i.submittedTxs.has(y)?i.submittedTxs.get(y):i.sdk.eth.getTransactionByHash([y]).then(d=>(d&&(d.hash=u[0]),d));case"eth_getTransactionReceipt":{let d=u[0];try{d=(yield i.sdk.txs.getBySafeTxHash(d)).txHash||d}catch{}return i.sdk.eth.getTransactionReceipt([d]).then(l=>(l&&(l.transactionHash=u[0]),l))}case"eth_estimateGas":return i.sdk.eth.getEstimateGas(u[0]);case"eth_call":return i.sdk.eth.call([u[0],u[1]]);case"eth_getLogs":return i.sdk.eth.getPastLogs([u[0]]);case"eth_gasPrice":return i.sdk.eth.getGasPrice();case"wallet_getPermissions":return i.sdk.wallet.getPermissions();case"wallet_requestPermissions":return i.sdk.wallet.requestPermissions(u[0]);case"safe_setSettings":return i.sdk.eth.setSafeSettings([u[0]]);default:throw Error(`"${h.method}" not implemented`)}})()}send(h,i){h||i("Undefined request"),this.request(h).then(L=>i(null,{jsonrpc:"2.0",id:h.id,result:L})).catch(L=>i(L,null))}}},95884:(k,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.getLowerCase=void 0,c.getLowerCase=function(p){return p&&p.toLowerCase()}},93105:k=>{var p,c="object"==typeof Reflect?Reflect:null,m=c&&"function"==typeof c.apply?c.apply:function(e,n,s){return Function.prototype.apply.call(e,n,s)};p=c&&"function"==typeof c.ownKeys?c.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var w=Number.isNaN||function(e){return e!=e};function a(){a.init.call(this)}k.exports=a,k.exports.once=function(t,e){return new Promise(function(n,s){function r(o){t.removeListener(e,f),s(o)}function f(){"function"==typeof t.removeListener&&t.removeListener("error",r),n([].slice.call(arguments))}P(t,e,f,{once:!0}),"error"!==e&&function(t,e,n){"function"==typeof t.on&&P(t,"error",e,{once:!0})}(t,r)})},a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var E=10;function h(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function i(t){return void 0===t._maxListeners?a.defaultMaxListeners:t._maxListeners}function L(t,e,n,s){var r,f,o;if(h(n),void 0===(f=t._events)?(f=t._events=Object.create(null),t._eventsCount=0):(void 0!==f.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),f=t._events),o=f[e]),void 0===o)o=f[e]=n,++t._eventsCount;else if("function"==typeof o?o=f[e]=s?[n,o]:[o,n]:s?o.unshift(n):o.push(n),(r=i(t))>0&&o.length>r&&!o.warned){o.warned=!0;var g=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");g.name="MaxListenersExceededWarning",g.emitter=t,g.type=e,g.count=o.length,function(t){console&&console.warn&&console.warn(t)}(g)}return t}function u(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function v(t,e,n){var s={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},r=u.bind(s);return r.listener=n,s.wrapFn=r,r}function b(t,e,n){var s=t._events;if(void 0===s)return[];var r=s[e];return void 0===r?[]:"function"==typeof r?n?[r.listener||r]:[r]:n?function(t){for(var e=new Array(t.length),n=0;n<e.length;++n)e[n]=t[n].listener||t[n];return e}(r):y(r,r.length)}function O(t){var e=this._events;if(void 0!==e){var n=e[t];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function y(t,e){for(var n=new Array(e),s=0;s<e;++s)n[s]=t[s];return n}function P(t,e,n,s){if("function"==typeof t.on)s.once?t.once(e,n):t.on(e,n);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,function r(f){s.once&&t.removeEventListener(e,r),n(f)})}}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return E},set:function(t){if("number"!=typeof t||t<0||w(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");E=t}}),a.init=function(){(void 0===this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},a.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||w(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},a.prototype.getMaxListeners=function(){return i(this)},a.prototype.emit=function(e){for(var n=[],s=1;s<arguments.length;s++)n.push(arguments[s]);var r="error"===e,f=this._events;if(void 0!==f)r=r&&void 0===f.error;else if(!r)return!1;if(r){var o;if(n.length>0&&(o=n[0]),o instanceof Error)throw o;var g=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw g.context=o,g}var C=f[e];if(void 0===C)return!1;if("function"==typeof C)m(C,this,n);else{var A=C.length,j=y(C,A);for(s=0;s<A;++s)m(j[s],this,n)}return!0},a.prototype.on=a.prototype.addListener=function(e,n){return L(this,e,n,!1)},a.prototype.prependListener=function(e,n){return L(this,e,n,!0)},a.prototype.once=function(e,n){return h(n),this.on(e,v(this,e,n)),this},a.prototype.prependOnceListener=function(e,n){return h(n),this.prependListener(e,v(this,e,n)),this},a.prototype.off=a.prototype.removeListener=function(e,n){var s,r,f,o,g;if(h(n),void 0===(r=this._events))return this;if(void 0===(s=r[e]))return this;if(s===n||s.listener===n)0==--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,s.listener||n));else if("function"!=typeof s){for(f=-1,o=s.length-1;o>=0;o--)if(s[o]===n||s[o].listener===n){g=s[o].listener,f=o;break}if(f<0)return this;0===f?s.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(s,f),1===s.length&&(r[e]=s[0]),void 0!==r.removeListener&&this.emit("removeListener",e,g||n)}return this},a.prototype.removeAllListeners=function(e){var n,s,r;if(void 0===(s=this._events))return this;if(void 0===s.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==s[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete s[e]),this;if(0===arguments.length){var o,f=Object.keys(s);for(r=0;r<f.length;++r)"removeListener"!==(o=f[r])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(n=s[e]))this.removeListener(e,n);else if(void 0!==n)for(r=n.length-1;r>=0;r--)this.removeListener(e,n[r]);return this},a.prototype.listeners=function(e){return b(this,e,!0)},a.prototype.rawListeners=function(e){return b(this,e,!1)},a.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):O.call(t,e)},a.prototype.listenerCount=O,a.prototype.eventNames=function(){return this._eventsCount>0?p(this._events):[]}}}]);