-
Notifications
You must be signed in to change notification settings - Fork 2
/
8369.074e63106008030af0f6.js
1 lines (1 loc) · 3.78 KB
/
8369.074e63106008030af0f6.js
1
"use strict";(self.webpackChunktimeless_frontend=self.webpackChunktimeless_frontend||[]).push([[8369],{78369:(p,r,d)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.SafeAppProvider=void 0;var i=d(29941);Object.defineProperty(r,"SafeAppProvider",{enumerable:!0,get:function(){return i.SafeAppProvider}})},29941:(p,r,d)=>{var i=d(31325).default;Object.defineProperty(r,"__esModule",{value:!0}),r.SafeAppProvider=void 0;const _=d(93105),g=d(95884);r.SafeAppProvider=class extends _.EventEmitter{constructor(n,e){super(),this.submittedTxs=new Map,this.safe=n,this.sdk=e}connect(){var n=this;return i(function*(){n.emit("connect",{chainId:n.chainId})})()}disconnect(){return i(function*(){})()}get chainId(){return this.safe.chainId}request(n){var e=this;return i(function*(){const{method:h,params:s=[]}=n;switch(h){case"eth_accounts":return[e.safe.safeAddress];case"net_version":case"eth_chainId":return`0x${e.chainId.toString(16)}`;case"personal_sign":{const[t,a]=s;if(e.safe.safeAddress.toLowerCase()!==a.toLowerCase())throw new Error("The address or message hash is invalid");const c=yield e.sdk.txs.signMessage(t);return("signature"in c?c.signature:void 0)||"0x"}case"eth_sign":{const[t,a]=s;if(e.safe.safeAddress.toLowerCase()!==t.toLowerCase()||!a.startsWith("0x"))throw new Error("The address or message hash is invalid");const c=yield e.sdk.txs.signMessage(a);return("signature"in c?c.signature:void 0)||"0x"}case"eth_signTypedData":case"eth_signTypedData_v4":{const[t,a]=s,c="string"==typeof a?JSON.parse(a):a;if(e.safe.safeAddress.toLowerCase()!==t.toLowerCase())throw new Error("The address is invalid");const l=yield e.sdk.txs.signTypedMessage(c);return("signature"in l?l.signature:void 0)||"0x"}case"eth_sendTransaction":const o=Object.assign({value:"0",data:"0x"},s[0]);"string"==typeof o.gas&&o.gas.startsWith("0x")&&(o.gas=parseInt(o.gas,16));const f=yield e.sdk.txs.send({txs:[o],params:{safeTxGas:o.gas}});return e.submittedTxs.set(f.safeTxHash,{from:e.safe.safeAddress,hash:f.safeTxHash,gas:0,gasPrice:"0x00",nonce:0,input:o.data,value:o.value,to:o.to,blockHash:null,blockNumber:null,transactionIndex:null}),f.safeTxHash;case"eth_blockNumber":return(yield e.sdk.eth.getBlockByNumber(["latest"])).number;case"eth_getBalance":return e.sdk.eth.getBalance([(0,g.getLowerCase)(s[0]),s[1]]);case"eth_getCode":return e.sdk.eth.getCode([(0,g.getLowerCase)(s[0]),s[1]]);case"eth_getTransactionCount":return e.sdk.eth.getTransactionCount([(0,g.getLowerCase)(s[0]),s[1]]);case"eth_getStorageAt":return e.sdk.eth.getStorageAt([(0,g.getLowerCase)(s[0]),s[1],s[2]]);case"eth_getBlockByNumber":return e.sdk.eth.getBlockByNumber([s[0],s[1]]);case"eth_getBlockByHash":return e.sdk.eth.getBlockByHash([s[0],s[1]]);case"eth_getTransactionByHash":let u=s[0];try{u=(yield e.sdk.txs.getBySafeTxHash(u)).txHash||u}catch{}return e.submittedTxs.has(u)?e.submittedTxs.get(u):e.sdk.eth.getTransactionByHash([u]).then(t=>(t&&(t.hash=s[0]),t));case"eth_getTransactionReceipt":{let t=s[0];try{t=(yield e.sdk.txs.getBySafeTxHash(t)).txHash||t}catch{}return e.sdk.eth.getTransactionReceipt([t]).then(a=>(a&&(a.transactionHash=s[0]),a))}case"eth_estimateGas":return e.sdk.eth.getEstimateGas(s[0]);case"eth_call":return e.sdk.eth.call([s[0],s[1]]);case"eth_getLogs":return e.sdk.eth.getPastLogs([s[0]]);case"eth_gasPrice":return e.sdk.eth.getGasPrice();case"wallet_getPermissions":return e.sdk.wallet.getPermissions();case"wallet_requestPermissions":return e.sdk.wallet.requestPermissions(s[0]);case"safe_setSettings":return e.sdk.eth.setSafeSettings([s[0]]);default:throw Error(`"${n.method}" not implemented`)}})()}send(n,e){n||e("Undefined request"),this.request(n).then(h=>e(null,{jsonrpc:"2.0",id:n.id,result:h})).catch(h=>e(h,null))}}},95884:(p,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.getLowerCase=void 0,r.getLowerCase=function(i){return i&&i.toLowerCase()}}}]);