UNPKG

@venly/web3-provider

Version:

Venly enabled Web3 Provider for the web

2 lines 736 kB
/*! For license information please see index.js.LICENSE.txt */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.VenlyProvider=t():e.VenlyProvider=t()}(this,(()=>(()=>{var __webpack_modules__={2122:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.createFetchConfigFromReq=t.createFetchMiddleware=void 0;const o=r(7467),i=r(9428),s=r(9128),a=["Gateway timeout","ETIMEDOUT","failed to parse response body","Failed to fetch"];function u(e){switch(e.status){case 405:throw i.rpcErrors.methodNotFound();case 418:throw i.rpcErrors.internal({message:"Request is being rate limited."});case 503:case 504:throw function(){let e="Gateway timeout. The request took too long to process. ";return e+="This can happen when querying logs over too wide a block range.",i.rpcErrors.internal({message:"Gateway timeout. The request took too long to process. This can happen when querying logs over too wide a block range."})}()}}function c(e,t){if(200!==e.status)throw i.rpcErrors.internal({message:`Non-200 status code: '${e.status}'`,data:t});if(t.error)throw i.rpcErrors.internal({data:t.error});return t.result}function l({btoa:e,req:t,rpcUrl:r,originHttpHeaderKey:n}){const o=new URL(r),i=function(e){let t="";return t+=e.protocol,t+=`//${e.hostname}`,e.port&&(t+=`:${e.port}`),t+=`${e.pathname}`,t+=`${e.search}`,t}(o),s={id:t.id,jsonrpc:t.jsonrpc,method:t.method,params:t.params},a=t.origin,u={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(s)};if(o.username&&o.password){const t=e(`${o.username}:${o.password}`);u.headers.Authorization=`Basic ${t}`}return n&&a&&(u.headers[n]=a),{fetchUrl:i,fetchParams:u}}t.createFetchMiddleware=function({btoa:e,fetch:t,rpcUrl:r,originHttpHeaderKey:i,venlyConnect:f}){return(0,o.createAsyncMiddleware)(((o,h,d)=>n(this,void 0,void 0,(function*(){const{fetchUrl:n,fetchParams:d}=l({btoa:e,req:o,rpcUrl:r,originHttpHeaderKey:i});for(let e=0;e<5;e++){try{d.headers.Authorization=`Bearer ${f.auth.token}`;const e=yield t(n,d);u(e);const r=yield e.text();let o;try{o=JSON.parse(r)}catch(e){throw new Error(`FetchMiddleware - failed to parse response body: "${r}"`)}const i=c(e,o);return void(h.result=i)}catch(e){const t=e.toString();if(!a.some((e=>t.includes(e))))throw e}yield(0,s.timeout)(1e3)}}))))},t.createFetchConfigFromReq=l},8819:function(e,t,r){"use strict";this&&this.__awaiter,Object.defineProperty(t,"__esModule",{value:!0});const n=r(7467),o=r(1692),i=r(2122),s=r(3261),a=r(6842);function u(e){return(t,r,n,o)=>"eth_chainId"===t.method?(r.result=e,o()):n()}t.default=function({rpcUrl:e,chainId:t,venlyConnect:r}){const c=(0,i.createFetchMiddleware)({btoa,fetch,rpcUrl:e,venlyConnect:r}),l=(0,s.providerFromMiddleware)(c),f=new a.PollingBlockTracker(Object.assign(Object.assign({},{}),{provider:l}));return{networkMiddleware:(0,n.mergeMiddleware)([u(t),(0,o.createBlockRefRewriteMiddleware)({blockTracker:f}),(0,o.createBlockCacheMiddleware)({blockTracker:f}),(0,o.createInflightCacheMiddleware)(),(0,o.createBlockTrackerInspectorMiddleware)({blockTracker:f}),c]),blockTracker:f}}},5590:function(e,t,r){"use strict";var n,o,i,s=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},a=this&&this.__classPrivateFieldGet||function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)},u=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.VenlyProvider=t.CHAIN_CONFIGS=t.WindowMode=t.SecretType=void 0;const c=r(7085),l=r(2176),f=r(880),h=r(7467),d=r(3261),p=u(r(9832)),y=u(r(8628)),g=u(r(8819)),m=u(r(8406)),v=u(r(8961));var b=r(7085);Object.defineProperty(t,"SecretType",{enumerable:!0,get:function(){return b.SecretType}}),Object.defineProperty(t,"WindowMode",{enumerable:!0,get:function(){return b.WindowMode}});var w=r(880);Object.defineProperty(t,"CHAIN_CONFIGS",{enumerable:!0,get:function(){return w.CHAIN_CONFIGS}});class _{constructor(){n.add(this)}get connect(){var e;return null===(e=this.venlyController)||void 0===e?void 0:e.venlyConnect}changeSecretType(e=c.SecretType.ETHEREUM,t){return s(this,void 0,void 0,(function*(){if(!this._provider)throw new Error("Please initialise provider first (Venly.createProvider)");const r=Object.assign(Object.assign(Object.assign({},this.venlyController.options),{secretType:e}),t&&{environment:f.CHAIN_CONFIGS[Number(t)].env});return this._provider.engine=a(this,n,"m",i).call(this,r),this._provider.emit("chainChanged",null!=t?t:f.CHAIN_IDS[e][this.venlyController.options.environment]),this._provider.emit("accountsChanged",yield this.venlyController.getAccounts()),this._provider}))}checkAuthenticated(){return s(this,void 0,void 0,(function*(){if(!this._provider)throw new Error("Please initialise provider first (Venly.createProvider)");return this.venlyController.checkAuthenticated()}))}authenticate(e){return s(this,void 0,void 0,(function*(){if(!this._provider)throw new Error("Please initialise provider first (Venly.createProvider)");return this.venlyController.authenticate(e)}))}logout(){return s(this,void 0,void 0,(function*(){if(!this._provider)throw new Error("Please initialise provider first (Venly.createProvider)");yield this.venlyController.logout(),this._provider.emit("disconnect",{message:"disconnect",code:1e3})}))}createProvider(e){var t,r,o,u;return s(this,void 0,void 0,(function*(){null!==(t=e.environment)&&void 0!==t||(e.environment="production"),"prod"===e.environment&&(e.environment="production"),null!==(r=e.windowMode)&&void 0!==r||(e.windowMode=c.WindowMode.POPUP),null!==(o=e.secretType)&&void 0!==o||(e.secretType=c.SecretType.ETHEREUM),null!==(u=e.skipAuthentication)&&void 0!==u||(e.skipAuthentication=!1);const s=a(this,n,"m",i).call(this,e),l=(0,p.default)(s);return this._provider=l,e.skipAuthentication||(yield this.venlyController.getAccounts()),this._provider}))}}t.VenlyProvider=_,n=new WeakSet,o=function(e){let t=e.environment.replace("-local","qa");const r=parseInt(f.CHAIN_IDS[e.secretType][t]);return t.startsWith("prod")?`https://evm-node.venly.io/chains/${r}`:`https://evm-node-${t}.venly.io/chains/${r}`},i=function(e){var t;this.venlyController&&this.venlyController.options.environment==e.environment?(this.venlyController.options=e,this.venlyController.resetWallets()):this.venlyController=new l.VenlyController(e);const r=new h.JsonRpcEngine,i=(0,y.default)({getAccounts:this.venlyController.getAccounts.bind(this.venlyController),processTransaction:this.venlyController.processTransaction.bind(this.venlyController),processSignTransaction:this.venlyController.processSignTransaction.bind(this.venlyController),processEthSignMessage:this.venlyController.processEthSignMessage.bind(this.venlyController),processTypedMessage:this.venlyController.processTypedMessage.bind(this.venlyController),processTypedMessageV3:this.venlyController.processTypedMessage.bind(this.venlyController),processTypedMessageV4:this.venlyController.processTypedMessage.bind(this.venlyController),processPersonalMessage:this.venlyController.processPersonalMessage.bind(this.venlyController),getTransactionByHash:this.venlyController.getTransactionByHash.bind(this.venlyController),getPendingTransactions:this.venlyController.getPendingTransactions.bind(this.venlyController),getPendingNonce:this.venlyController.getPendingNonce.bind(this.venlyController),changeSecretType:this.changeSecretType.bind(this)});r.push(i);const s=a(this,n,"m",o).call(this,e),u=null!==(t=f.CHAIN_IDS[e.secretType][e.environment])&&void 0!==t?t:f.CHAIN_IDS[e.secretType].production;if(!u)throw new Error(`Unable to determine chainId for secretType: ${e.secretType} and environment: ${e.environment}`);const{networkMiddleware:c,blockTracker:p}=(0,g.default)({rpcUrl:s,chainId:u,venlyConnect:this.venlyController.venlyConnect});this._blockTracker=p;const b=(0,d.providerFromMiddleware)(c),w=(0,m.default)({provider:b,blockTracker:p}),_=(0,v.default)({provider:b,blockTracker:p});return _.events.on("notification",(e=>r.emit("notification",e))),r.push(w),r.push(_.middleware),r.push(c),r},globalThis.Venly=new _},8667:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.createSwitchEthereumChainMiddleware=t.createRequestAccountsMiddleware=void 0;const o=r(8625),i=r(880);t.createRequestAccountsMiddleware=function({getAccounts:e}){return(0,o.createAsyncMiddleware)(((t,r,o)=>n(this,void 0,void 0,(function*(){"eth_requestAccounts"===t.method?r.result=yield e():o()}))))},t.createSwitchEthereumChainMiddleware=function({changeSecretType:e}){return(0,o.createAsyncMiddleware)(((t,r,o)=>n(this,void 0,void 0,(function*(){var n;if("wallet_switchEthereumChain"!==t.method)return void o();const s=null===(n=t.params[0])||void 0===n?void 0:n.chainId,a=i.CHAIN_CONFIGS[Number(s)];a&&(yield e(a.secretType,s))?r.result=null:r.error={code:-32602,message:"Chain not supported"}}))))}},8628:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(7467),o=r(1692),i=r(523),s=r(8667);t.default=function({getAccounts:e,processDecryptMessage:t,processEncryptionPublicKey:r,processEthSignMessage:a,processPersonalMessage:u,processTransaction:c,processSignTransaction:l,processTypedMessage:f,processTypedMessageV3:h,processTypedMessageV4:d,getPendingNonce:p,getTransactionByHash:y,getPendingTransactions:g,changeSecretType:m}){return(0,n.mergeMiddleware)([(0,n.createScaffoldMiddleware)({web3_clientVersion:"VenlyProvider/v3.0.0",eth_hashrate:"0x00",eth_mining:!1,eth_syncing:!1}),(0,o.createWalletMiddleware)({getAccounts:e,processDecryptMessage:t,processEncryptionPublicKey:r,processEthSignMessage:a,processPersonalMessage:u,processTransaction:c,processSignTransaction:l,processTypedMessage:f,processTypedMessageV3:h,processTypedMessageV4:d}),(0,s.createRequestAccountsMiddleware)({getAccounts:e}),(0,i.createPendingNonceMiddleware)({getPendingNonce:p}),(0,i.createTransactionByHashMiddleware)({getTransactionByHash:y}),(0,i.createPendingTransactionsMiddleware)({getPendingTransactions:g}),(0,s.createSwitchEthereumChainMiddleware)({changeSecretType:m})])}},523:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.createPendingTransactionsMiddleware=t.createTransactionByHashMiddleware=t.createPendingNonceMiddleware=void 0;const o=r(8625);t.createPendingNonceMiddleware=function({getPendingNonce:e}){return(0,o.createAsyncMiddleware)(((e,t,r)=>n(this,void 0,void 0,(function*(){const{method:t,params:n}=e;if("eth_getTransactionCount"!==t)return void r();const[o,i]=n;"pending"===i?yield r():r()}))))},t.createTransactionByHashMiddleware=function({getTransactionByHash:e}){return(0,o.createAsyncMiddleware)(((t,r,o)=>n(this,void 0,void 0,(function*(){const{method:n,params:i}=t;if("eth_getTransactionByHash"!==n)return void o();const[s]=i;r.result=yield e(s)}))))},t.createPendingTransactionsMiddleware=function({getPendingTransactions:e}){return(0,o.createAsyncMiddleware)(((t,r,o)=>n(this,void 0,void 0,(function*(){"eth_pendingTransactions"===t.method?r.result=yield e():o()}))))}},9832:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(9394));t.default=function(e){return new i({engine:e})};class i extends o.default{constructor({engine:e}){super(),this.request=e=>new Promise(((t,r)=>{this.sendAsync(e,((e,n)=>{e?r(n.error):t(n.result)}))})),this.sendAsync=(e,t)=>{this.engine.handle(e,t)},this.send=(e,t)=>{if("function"!=typeof t)throw new Error('Must provide callback to "send" method.');this.engine.handle(e,t)},this.engine=e,e.on&&e.on("notification",(e=>{this.emit("data",null,e)}))}}},880:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.REQUEST_TYPES=t.CHAIN_CONFIGS=t.CHAIN_IDS=void 0,t.CHAIN_IDS={AVAC:{production:"0xA86A",sandbox:"0xA869",staging:"0xA869",qa:"0xA869"},BSC:{production:"0x38",sandbox:"0x61",staging:"0x61",qa:"0x61"},ETHEREUM:{production:"0x1",sandbox:"0xaa36a7",staging:"0xaa36a7",qa:"0xaa36a7"},GOCHAIN:{production:"0x3c",sandbox:"0x7a69",staging:"0x7a69",qa:"0x7a69"},MATIC:{production:"0x89",sandbox:"0x13882",staging:"0x13882",qa:"0x13882"},ARBITRUM:{production:"0xa4b1",sandbox:"0x66eee",staging:"0x66eee",qa:"0x66eee"}},t.CHAIN_CONFIGS={43114:{env:"production",secretType:"AVAC"},43113:{env:"sandbox",secretType:"AVAC"},56:{env:"production",secretType:"BSC"},97:{env:"sandbox",secretType:"BSC"},1:{env:"production",secretType:"ETHEREUM"},11155111:{env:"sandbox",secretType:"ETHEREUM"},60:{env:"production",secretType:"GOCHAIN"},31337:{env:"sandbox",secretType:"GOCHAIN"},137:{env:"production",secretType:"MATIC"},80001:{env:"sandbox",secretType:"MATIC"},42161:{env:"production",secretType:"ARBITRUM"},421614:{env:"sandbox",secretType:"ARBITRUM"}},t.REQUEST_TYPES={AVAC:{transaction:"AVAC_TRANSACTION",signature:"AVAC_TRANSACTION"},BSC:{transaction:"BSC_TRANSACTION",signature:"BSC_TRANSACTION"},ETHEREUM:{transaction:"ETH_TRANSACTION",signature:"ETHEREUM_TRANSACTION"},GOCHAIN:{transaction:"GO_TRANSACTION",signature:"GOCHAIN_TRANSACTION"},MATIC:{transaction:"MATIC_TRANSACTION",signature:"MATIC_TRANSACTION"},ARBITRUM:{transaction:"ARBITRUM_TRANSACTION",signature:"ARBITRUM_TRANSACTION"}}},9128:function(e,t){"use strict";var r=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.timeout=t.formatTxMetaForRpcResult=void 0;t.formatTxMetaForRpcResult=function(e){const{r:t,s:r,v:n,hash:o,txReceipt:i,txParams:s}=e,{to:a,data:u,nonce:c,gas:l,from:f,value:h,gasPrice:d,accessList:p,maxFeePerGas:y,maxPriorityFeePerGas:g}=s,m={v:n,r:t,s:r,to:a,gas:l,from:f,hash:o,nonce:c,input:u||"0x",value:h||"0x0",accessList:p||null,blockHash:(null==i?void 0:i.blockHash)||null,blockNumber:(null==i?void 0:i.blockNumber)||null,transactionIndex:(null==i?void 0:i.transactionIndex)||null};return y&&g?(m.gasPrice=y,m.maxFeePerGas=y,m.maxPriorityFeePerGas=g,m.type="0x2"):(m.gasPrice=d,m.type="0x0"),m},t.timeout=function(e){return r(this,void 0,void 0,(function*(){return new Promise((t=>setTimeout(t,e)))}))}},2176:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.VenlyController=void 0;const i=r(7085),s=r(880),a=r(6261);t.VenlyController=class{constructor(e){this.wallets=[],this.options=e,this.venlyConnect=new i.VenlyConnect(e.clientId,{environment:e.environment,windowMode:e.windowMode,bearerTokenProvider:e.bearerTokenProvider,useOverlayWithPopup:!1})}resetWallets(){this.lastWalletsFetch=void 0,this.wallets=[]}authenticate(e){return n(this,void 0,void 0,(function*(){return this.authResult&&this.authResult.isAuthenticated||(this.authResult=yield this.venlyConnect.flows.authenticate(Object.assign(Object.assign({},e),{forcePopup:!0}))),this.authResult}))}checkAuthenticated(){return n(this,void 0,void 0,(function*(){return this.authResult=yield this.venlyConnect.checkAuthenticated()}))}logout(){return n(this,void 0,void 0,(function*(){this.authResult=yield this.venlyConnect.logout()}))}getAccounts(){return n(this,void 0,void 0,(function*(){return this.authResult&&this.authResult.isAuthenticated?yield this.refreshWallets():this.authResult=yield this.startGetAccountFlow(this.options.authenticationOptions),this.wallets.map((e=>e.address))}))}processTransaction(e,t){var r,o;return n(this,void 0,void 0,(function*(){const e=t.params[0],n=this.venlyConnect.createSigner(),u=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({walletId:this.getWalletIdFrom(e.from),type:s.REQUEST_TYPES[this.options.secretType].transaction},e.to&&{to:e.to}),e.data&&{data:e.data}),e.value&&{value:a.BigNumber.from(e.value).toString()}),e.gas&&{gas:a.BigNumber.from(e.gas).toString()}),e.gasPrice&&{gasPrice:a.BigNumber.from(e.gasPrice).toString()}),e.nonce&&{nonce:a.BigNumber.from(e.nonce).toString()}),c=yield n.executeNativeTransaction(u);if(this.options.windowMode==i.WindowMode.REDIRECT)return yield new Promise((()=>{}));if("SUCCESS"===c.status)return null===(r=c.result)||void 0===r?void 0:r.transactionHash;throw new Error(null===(o=c.errors)||void 0===o?void 0:o.join(", "))}))}processSignTransaction(e,t){var r,o;return n(this,void 0,void 0,(function*(){const e=t.params[0],n=this.venlyConnect.createSigner(),u=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({walletId:this.getWalletIdFrom(e.from),type:s.REQUEST_TYPES[this.options.secretType].signature},e.to&&{to:e.to}),e.data&&{data:e.data}),e.value&&{value:a.BigNumber.from(e.value).toString()}),e.gas&&{gas:a.BigNumber.from(e.gas).toString()}),e.gasPrice&&{gasPrice:a.BigNumber.from(e.gasPrice).toString()}),e.nonce&&{nonce:a.BigNumber.from(e.nonce).toString()}),c=yield n.sign(u);if(this.options.windowMode==i.WindowMode.REDIRECT)return yield new Promise((()=>{}));if("SUCCESS"===c.status)return null===(r=c.result)||void 0===r?void 0:r.signedTransaction;throw new Error(null===(o=c.errors)||void 0===o?void 0:o.join(", "))}))}processEthSignMessage(e,t){var r,o;return n(this,void 0,void 0,(function*(){const t=this.venlyConnect.createSigner(),n=yield t.signMessage({walletId:this.getWalletIdFrom(e.from),secretType:this.options.secretType,data:e.data});if(this.options.windowMode==i.WindowMode.REDIRECT)return yield new Promise((()=>{}));if("SUCCESS"===n.status)return null===(r=n.result)||void 0===r?void 0:r.signature;throw new Error(null===(o=n.errors)||void 0===o?void 0:o.join(", "))}))}processTypedMessage(e,t,r){var o,s,u;return n(this,void 0,void 0,(function*(){const t=this.venlyConnect.createSigner();try{var r=JSON.parse(e.data)}catch(t){r=e.data}(null===(o=null==r?void 0:r.domain)||void 0===o?void 0:o.chainId)&&(r.domain.chainId=a.BigNumber.from(r.domain.chainId).toString());const n=yield t.signEip712({walletId:this.getWalletIdFrom(e.from),secretType:this.options.secretType,data:r});if(this.options.windowMode==i.WindowMode.REDIRECT)return yield new Promise((()=>{}));if("SUCCESS"===n.status)return null===(s=n.result)||void 0===s?void 0:s.signature;throw new Error(null===(u=n.errors)||void 0===u?void 0:u.join(", "))}))}processPersonalMessage(e,t){var r,o;return n(this,void 0,void 0,(function*(){const t=this.venlyConnect.createSigner(),n=yield t.signMessage({walletId:this.getWalletIdFrom(e.from),secretType:this.options.secretType,data:e.data});if(this.options.windowMode==i.WindowMode.REDIRECT)return yield new Promise((()=>{}));if("SUCCESS"===n.status)return null===(r=n.result)||void 0===r?void 0:r.signature;throw new Error(null===(o=n.errors)||void 0===o?void 0:o.join(", "))}))}getTransactionByHash(e){return n(this,void 0,void 0,(function*(){const t=yield this.venlyConnect.api.getTransactionStatus(e,this.options.secretType);if("SUCCEEDED"==(null==t?void 0:t.status)){t.value=a.BigNumber.from(t.rawValue).toString(),t.data||(t.data="0x");const{rawValue:e}=t;return o(t,["rawValue"])}return null}))}getPendingTransactions(){return n(this,void 0,void 0,(function*(){return(yield this.venlyConnect.api.getPendingTransactions()).map((e=>{const t=e.transactionRequest,{rawValue:r,type:n}=t,i=o(t,["rawValue","type"]);return i.value=a.BigNumber.from(i.value).toString(),i}))}))}getPendingNonce(e){return n(this,void 0,void 0,(function*(){const t=yield this.venlyConnect.api.getPendingTransactions();return"0x"+(Number(e)+t.length).toString(16)}))}refreshWallets(){return n(this,void 0,void 0,(function*(){if(!this.lastWalletsFetch||Date.now()-this.lastWalletsFetch>5e3){let e=yield this.venlyConnect.api.getWallets({secretType:this.options.secretType,includeBalance:!1});(!e||e.length<1)&&(e=(yield this.venlyConnect.flows.getAccount(this.options.secretType,this.options.authenticationOptions)).wallets),this.wallets=e}return this.lastWalletsFetch=Date.now(),this.wallets}))}startGetAccountFlow(e){return n(this,void 0,void 0,(function*(){return e&&(this.options.authenticationOptions=e),this.venlyConnect.flows.getAccount(this.options.secretType,this.options.authenticationOptions).then((e=>n(this,void 0,void 0,(function*(){return yield new Promise(((t,r)=>{e.isAuthenticated?e.wallets&&e.wallets.length<=0?r("no-wallet-linked"):(this.wallets=e.wallets,this.lastWalletsFetch=Date.now(),t(e)):r("not-authenticated")}))}))))}))}getWalletIdFrom(e){let t=this.wallets.find((t=>{var r;return(null===(r=t.address)||void 0===r?void 0:r.toLowerCase())===(null==e?void 0:e.toLowerCase())}));return(null==t?void 0:t.id)||""}}},5507:(e,t)=>{"use strict";function r(e){if(Array.isArray(e)){const t=[];let n=0;for(let o=0;o<e.length;o++){const i=r(e[o]);t.push(i),n+=i.length}return h(i(n,192),...t)}const t=g(e);return 1===t.length&&t[0]<128?t:h(i(t.length,128),t)}function n(e,t,r){if(r>e.length)throw new Error("invalid RLP (safeSlice): end slice of Uint8Array out-of-bounds");return e.slice(t,r)}function o(e){if(0===e[0])throw new Error("invalid RLP: extra zeros");return l(c(e))}function i(e,t){if(e<56)return Uint8Array.from([e+t]);const r=p(e),n=p(t+55+r.length/2);return Uint8Array.from(f(n+r))}function s(e,t=!1){if(null==e||0===e.length)return Uint8Array.from([]);const r=a(g(e));if(t)return r;if(0!==r.remainder.length)throw new Error("invalid RLP: remainder must be zero");return r.data}function a(e){let t,r,i,s,u;const c=[],l=e[0];if(l<=127)return{data:e.slice(0,1),remainder:e.slice(1)};if(l<=183){if(t=l-127,i=128===l?Uint8Array.from([]):n(e,1,t),2===t&&i[0]<128)throw new Error("invalid RLP encoding: invalid prefix, single byte < 0x80 are not prefixed");return{data:i,remainder:e.slice(t)}}if(l<=191){if(r=l-182,e.length-1<r)throw new Error("invalid RLP: not enough bytes for string length");if(t=o(n(e,1,r)),t<=55)throw new Error("invalid RLP: expected string length to be greater than 55");return i=n(e,r,t+r),{data:i,remainder:e.slice(t+r)}}if(l<=247){for(t=l-191,s=n(e,1,t);s.length;)u=a(s),c.push(u.data),s=u.remainder;return{data:c,remainder:e.slice(t)}}{if(r=l-246,t=o(n(e,1,r)),t<56)throw new Error("invalid RLP: encoded list too short");const i=r+t;if(i>e.length)throw new Error("invalid RLP: total length is larger than the data");for(s=n(e,r,i);s.length;)u=a(s),c.push(u.data),s=u.remainder;return{data:c,remainder:e.slice(i)}}}Object.defineProperty(t,"__esModule",{value:!0}),t.RLP=t.utils=t.decode=t.encode=void 0,t.encode=r,t.decode=s;const u=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function c(e){let t="";for(let r=0;r<e.length;r++)t+=u[e[r]];return t}function l(e){const t=Number.parseInt(e,16);if(Number.isNaN(t))throw new Error("Invalid byte sequence");return t}function f(e){if("string"!=typeof e)throw new TypeError("hexToBytes: expected string, got "+typeof e);if(e.length%2)throw new Error("hexToBytes: received invalid unpadded hex");const t=new Uint8Array(e.length/2);for(let r=0;r<t.length;r++){const n=2*r;t[r]=l(e.slice(n,n+2))}return t}function h(...e){if(1===e.length)return e[0];const t=e.reduce(((e,t)=>e+t.length),0),r=new Uint8Array(t);for(let t=0,n=0;t<e.length;t++){const o=e[t];r.set(o,n),n+=o.length}return r}function d(e){return(new TextEncoder).encode(e)}function p(e){if(e<0)throw new Error("Invalid integer as argument, must be unsigned!");const t=e.toString(16);return t.length%2?`0${t}`:t}function y(e){return e.length>=2&&"0"===e[0]&&"x"===e[1]}function g(e){if(e instanceof Uint8Array)return e;if("string"==typeof e)return y(e)?f((t="string"!=typeof(r=e)?r:y(r)?r.slice(2):r).length%2?`0${t}`:t):d(e);var t,r;if("number"==typeof e||"bigint"==typeof e)return e?f(p(e)):Uint8Array.from([]);if(null==e)return Uint8Array.from([]);throw new Error("toBytes: received unsupported type "+typeof e)}t.utils={bytesToHex:c,concatBytes:h,hexToBytes:f,utf8ToBytes:d},t.RLP={encode:r,decode:s}},8e3:(e,t,r)=>{"use strict";var n=r(8764).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.accountBodyToRLP=t.accountBodyToSlim=t.accountBodyFromSlim=t.isZeroAddress=t.zeroAddress=t.importPublic=t.privateToAddress=t.privateToPublic=t.publicToAddress=t.pubToAddress=t.isValidPublic=t.isValidPrivate=t.generateAddress2=t.generateAddress=t.isValidChecksumAddress=t.toChecksumAddress=t.isValidAddress=t.Account=void 0;const o=r(5507),i=r(2192),s=r(5053),a=r(8040),u=r(8289),c=r(6219),l=r(8480),f=r(4712),h=BigInt(0);class d{constructor(e=h,t=h,r=c.KECCAK256_RLP,n=c.KECCAK256_NULL){this.nonce=e,this.balance=t,this.storageRoot=r,this.codeHash=n,this._validate()}static fromAccountData(e){const{nonce:t,balance:r,storageRoot:n,codeHash:o}=e;return new d(void 0!==t?(0,u.bufferToBigInt)((0,u.toBuffer)(t)):void 0,void 0!==r?(0,u.bufferToBigInt)((0,u.toBuffer)(r)):void 0,void 0!==n?(0,u.toBuffer)(n):void 0,void 0!==o?(0,u.toBuffer)(o):void 0)}static fromRlpSerializedAccount(e){const t=(0,u.arrToBufArr)(o.RLP.decode(Uint8Array.from(e)));if(!Array.isArray(t))throw new Error("Invalid serialized account input. Must be array");return this.fromValuesArray(t)}static fromValuesArray(e){const[t,r,n,o]=e;return new d((0,u.bufferToBigInt)(t),(0,u.bufferToBigInt)(r),n,o)}_validate(){if(this.nonce<h)throw new Error("nonce must be greater than zero");if(this.balance<h)throw new Error("balance must be greater than zero");if(32!==this.storageRoot.length)throw new Error("storageRoot must have a length of 32");if(32!==this.codeHash.length)throw new Error("codeHash must have a length of 32")}raw(){return[(0,u.bigIntToUnpaddedBuffer)(this.nonce),(0,u.bigIntToUnpaddedBuffer)(this.balance),this.storageRoot,this.codeHash]}serialize(){return n.from(o.RLP.encode((0,u.bufArrToArr)(this.raw())))}isContract(){return!this.codeHash.equals(c.KECCAK256_NULL)}isEmpty(){return this.balance===h&&this.nonce===h&&this.codeHash.equals(c.KECCAK256_NULL)}}function p(e){const[t,r,n,o]=e;return[t,r,0===(0,u.arrToBufArr)(n).length?c.KECCAK256_RLP:n,0===(0,u.arrToBufArr)(o).length?c.KECCAK256_NULL:o]}t.Account=d,t.isValidAddress=function(e){try{(0,l.assertIsString)(e)}catch(e){return!1}return/^0x[0-9a-fA-F]{40}$/.test(e)},t.toChecksumAddress=function(e,t){(0,l.assertIsHexString)(e);const r=(0,f.stripHexPrefix)(e).toLowerCase();let o="";void 0!==t&&(o=(0,u.bufferToBigInt)((0,u.toBuffer)(t)).toString()+"0x");const s=n.from(o+r,"utf8"),c=(0,a.bytesToHex)((0,i.keccak256)(s));let h="0x";for(let e=0;e<r.length;e++)parseInt(c[e],16)>=8?h+=r[e].toUpperCase():h+=r[e];return h},t.isValidChecksumAddress=function(e,r){return(0,t.isValidAddress)(e)&&(0,t.toChecksumAddress)(e,r)===e},t.generateAddress=function(e,t){return(0,l.assertIsBuffer)(e),(0,l.assertIsBuffer)(t),(0,u.bufferToBigInt)(t)===BigInt(0)?n.from((0,i.keccak256)(o.RLP.encode((0,u.bufArrToArr)([e,null])))).slice(-20):n.from((0,i.keccak256)(o.RLP.encode((0,u.bufArrToArr)([e,t])))).slice(-20)},t.generateAddress2=function(e,t,r){if((0,l.assertIsBuffer)(e),(0,l.assertIsBuffer)(t),(0,l.assertIsBuffer)(r),20!==e.length)throw new Error("Expected from to be of length 20");if(32!==t.length)throw new Error("Expected salt to be of length 32");const o=(0,i.keccak256)(n.concat([n.from("ff","hex"),e,t,(0,i.keccak256)(r)]));return(0,u.toBuffer)(o).slice(-20)},t.isValidPrivate=function(e){return s.secp256k1.utils.isValidPrivateKey(e)},t.isValidPublic=function(e,t=!1){if((0,l.assertIsBuffer)(e),64===e.length)try{return s.secp256k1.ProjectivePoint.fromHex(n.concat([n.from([4]),e])),!0}catch(e){return!1}if(!t)return!1;try{return s.secp256k1.ProjectivePoint.fromHex(e),!0}catch(e){return!1}},t.pubToAddress=function(e,t=!1){if((0,l.assertIsBuffer)(e),t&&64!==e.length&&(e=n.from(s.secp256k1.ProjectivePoint.fromHex(e).toRawBytes(!1).slice(1))),64!==e.length)throw new Error("Expected pubKey to be of length 64");return n.from((0,i.keccak256)(e)).slice(-20)},t.publicToAddress=t.pubToAddress,t.privateToPublic=function(e){return(0,l.assertIsBuffer)(e),n.from(s.secp256k1.ProjectivePoint.fromPrivateKey(e).toRawBytes(!1).slice(1))},t.privateToAddress=function(e){return(0,t.publicToAddress)((0,t.privateToPublic)(e))},t.importPublic=function(e){return(0,l.assertIsBuffer)(e),64!==e.length&&(e=n.from(s.secp256k1.ProjectivePoint.fromHex(e).toRawBytes(!1).slice(1))),e},t.zeroAddress=function(){const e=(0,u.zeros)(20);return(0,u.bufferToHex)(e)},t.isZeroAddress=function(e){try{(0,l.assertIsString)(e)}catch(e){return!1}return(0,t.zeroAddress)()===e},t.accountBodyFromSlim=p;const y=new Uint8Array(0);t.accountBodyToSlim=function(e){const[t,r,n,o]=e;return[t,r,(0,u.arrToBufArr)(n).equals(c.KECCAK256_RLP)?y:n,(0,u.arrToBufArr)(o).equals(c.KECCAK256_NULL)?y:o]},t.accountBodyToRLP=function(e,t=!0){const r=t?p(e):e;return(0,u.arrToBufArr)(o.RLP.encode(r))}},3415:(e,t,r)=>{"use strict";var n=r(8764).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.Address=void 0;const o=r(8e3),i=r(8289);class s{constructor(e){if(20!==e.length)throw new Error("Invalid address length");this.buf=e}static zero(){return new s((0,i.zeros)(20))}static fromString(e){if(!(0,o.isValidAddress)(e))throw new Error("Invalid address");return new s((0,i.toBuffer)(e))}static fromPublicKey(e){if(!n.isBuffer(e))throw new Error("Public key should be Buffer");const t=(0,o.pubToAddress)(e);return new s(t)}static fromPrivateKey(e){if(!n.isBuffer(e))throw new Error("Private key should be Buffer");const t=(0,o.privateToAddress)(e);return new s(t)}static generate(e,t){if("bigint"!=typeof t)throw new Error("Expected nonce to be a bigint");return new s((0,o.generateAddress)(e.buf,(0,i.bigIntToBuffer)(t)))}static generate2(e,t,r){if(!n.isBuffer(t))throw new Error("Expected salt to be a Buffer");if(!n.isBuffer(r))throw new Error("Expected initCode to be a Buffer");return new s((0,o.generateAddress2)(e.buf,t,r))}equals(e){return this.buf.equals(e.buf)}isZero(){return this.equals(s.zero())}isPrecompileOrSystemAddress(){const e=(0,i.bufferToBigInt)(this.buf),t=BigInt(0),r=BigInt("0xffff");return e>=t&&e<=r}toString(){return"0x"+this.buf.toString("hex")}toBuffer(){return n.from(this.buf)}}t.Address=s},7285:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AsyncEventEmitter=void 0;const n=r(7187);class o extends n.EventEmitter{emit(e,...t){let[r,n]=t;const o=this;let i=o._events[e]??[];return void 0===n&&"function"==typeof r&&(n=r,r=void 0),"newListener"!==e&&"removeListener"!==e||(r={event:r,fn:n},n=void 0),i=Array.isArray(i)?i:[i],async function(e,t,r){let n;for await(const o of t)try{o.length<2?o.call(e,r):await new Promise(((t,n)=>{o.call(e,r,(e=>{e?n(e):t()}))}))}catch(e){n=e}if(n)throw n}(o,i.slice(),r).then(n).catch(n),o.listenerCount(e)>0}once(e,t){const r=this;let n;if("function"!=typeof t)throw new TypeError("listener must be a function");return n=t.length>=2?function(o,i){r.removeListener(e,n),t(o,i)}:function(o){r.removeListener(e,n),t(o,n)},r.on(e,n),r}first(e,t){let r=this._events[e]??[];if("function"!=typeof t)throw new TypeError("listener must be a function");return Array.isArray(r)||(this._events[e]=r=[r]),r.unshift(t),this}before(e,t,r){return this.beforeOrAfter(e,t,r)}after(e,t,r){return this.beforeOrAfter(e,t,r,"after")}beforeOrAfter(e,t,r,n){let o,i,s=this._events[e]??[];const a="after"===n?1:0;if("function"!=typeof r)throw new TypeError("listener must be a function");if("function"!=typeof t)throw new TypeError("target must be a function");for(Array.isArray(s)||(this._events[e]=s=[s]),i=s.length,o=s.length;o--;)if(s[o]===t){i=o+a;break}return s.splice(i,0,r),this}on(e,t){return super.on(e,t)}addListener(e,t){return super.addListener(e,t)}prependListener(e,t){return super.prependListener(e,t)}prependOnceListener(e,t){return super.prependOnceListener(e,t)}removeAllListeners(e){return super.removeAllListeners(e)}removeListener(e,t){return super.removeListener(e,t)}eventNames(){return super.eventNames()}listeners(e){return super.listeners(e)}listenerCount(e){return super.listenerCount(e)}getMaxListeners(){return super.getMaxListeners()}setMaxListeners(e){return super.setMaxListeners(e)}}t.AsyncEventEmitter=o},8289:(e,t,r)=>{"use strict";var n=r(8764).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.intToUnpaddedBuffer=t.bigIntToUnpaddedBuffer=t.bigIntToHex=t.bufArrToArr=t.arrToBufArr=t.validateNoLeadingZeroes=t.baToJSON=t.toUtf8=t.short=t.addHexPrefix=t.toUnsigned=t.fromSigned=t.bufferToInt=t.bigIntToBuffer=t.bufferToBigInt=t.bufferToHex=t.toBuffer=t.unpadHexString=t.unpadArray=t.unpadBuffer=t.setLengthRight=t.setLengthLeft=t.zeros=t.intToBuffer=t.intToHex=void 0;const o=r(8480),i=r(4712);t.intToHex=function(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Received an invalid integer type: ${e}`);return`0x${e.toString(16)}`},t.intToBuffer=function(e){const r=(0,t.intToHex)(e);return n.from((0,i.padToEven)(r.slice(2)),"hex")},t.zeros=function(e){return n.allocUnsafe(e).fill(0)};const s=function(e,r,n){const o=(0,t.zeros)(r);return n?e.length<r?(e.copy(o),o):e.slice(0,r):e.length<r?(e.copy(o,r-e.length),o):e.slice(-r)};t.setLengthLeft=function(e,t){return(0,o.assertIsBuffer)(e),s(e,t,!1)},t.setLengthRight=function(e,t){return(0,o.assertIsBuffer)(e),s(e,t,!0)};const a=function(e){let t=e[0];for(;e.length>0&&"0"===t.toString();)t=(e=e.slice(1))[0];return e};function u(e){const r=(0,t.bufferToHex)(e);return"0x"===r?BigInt(0):BigInt(r)}function c(e){return(0,t.toBuffer)("0x"+e.toString(16))}t.unpadBuffer=function(e){return(0,o.assertIsBuffer)(e),a(e)},t.unpadArray=function(e){return(0,o.assertIsArray)(e),a(e)},t.unpadHexString=function(e){return(0,o.assertIsHexString)(e),e=(0,i.stripHexPrefix)(e),"0x"+a(e)},t.toBuffer=function(e){if(null==e)return n.allocUnsafe(0);if(n.isBuffer(e))return n.from(e);if(Array.isArray(e)||e instanceof Uint8Array)return n.from(e);if("string"==typeof e){if(!(0,i.isHexString)(e))throw new Error(`Cannot convert string to buffer. toBuffer only supports 0x-prefixed hex strings and this string was given: ${e}`);return n.from((0,i.padToEven)((0,i.stripHexPrefix)(e)),"hex")}if("number"==typeof e)return(0,t.intToBuffer)(e);if("bigint"==typeof e){if(e<BigInt(0))throw new Error(`Cannot convert negative bigint to buffer. Given: ${e}`);let t=e.toString(16);return t.length%2&&(t="0"+t),n.from(t,"hex")}if(e.toArray)return n.from(e.toArray());if(e.toBuffer)return n.from(e.toBuffer());throw new Error("invalid type")},t.bufferToHex=function(e){return"0x"+(e=(0,t.toBuffer)(e)).toString("hex")},t.bufferToBigInt=u,t.bigIntToBuffer=c,t.bufferToInt=function(e){const t=Number(u(e));if(!Number.isSafeInteger(t))throw new Error("Number exceeds 53 bits");return t},t.fromSigned=function(e){return BigInt.asIntN(256,u(e))},t.toUnsigned=function(e){return c(BigInt.asUintN(256,e))},t.addHexPrefix=function(e){return"string"!=typeof e||(0,i.isHexPrefixed)(e)?e:"0x"+e},t.short=function(e,t=50){const r=n.isBuffer(e)?e.toString("hex"):e;return r.length<=t?r:r.slice(0,t)+"…"},t.toUtf8=function(e){if((e=(0,i.stripHexPrefix)(e)).length%2!=0)throw new Error("Invalid non-even hex string input for toUtf8() provided");return n.from(e.replace(/^(00)+|(00)+$/g,""),"hex").toString("utf8")},t.baToJSON=function(e){if(n.isBuffer(e))return`0x${e.toString("hex")}`;if(e instanceof Array){const r=[];for(let n=0;n<e.length;n++)r.push((0,t.baToJSON)(e[n]));return r}},t.validateNoLeadingZeroes=function(e){for(const[t,r]of Object.entries(e))if(void 0!==r&&r.length>0&&0===r[0])throw new Error(`${t} cannot have leading zeroes, received: ${r.toString("hex")}`)},t.arrToBufArr=function e(t){return Array.isArray(t)?t.map((t=>e(t))):n.from(t)},t.bufArrToArr=function e(t){return Array.isArray(t)?t.map((t=>e(t))):Uint8Array.from(t??[])},t.bigIntToHex=e=>"0x"+e.toString(16),t.bigIntToUnpaddedBuffer=function(e){return(0,t.unpadBuffer)(c(e))},t.intToUnpaddedBuffer=function(e){return(0,t.unpadBuffer)((0,t.intToBuffer)(e))}},6219:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MAX_WITHDRAWALS_PER_PAYLOAD=t.RLP_EMPTY_STRING=t.KECCAK256_RLP=t.KECCAK256_RLP_S=t.KECCAK256_RLP_ARRAY=t.KECCAK256_RLP_ARRAY_S=t.KECCAK256_NULL=t.KECCAK256_NULL_S=t.TWO_POW256=t.SECP256K1_ORDER_DIV_2=t.SECP256K1_ORDER=t.MAX_INTEGER_BIGINT=t.MAX_INTEGER=t.MAX_UINT64=void 0;const n=r(8764),o=r(5053);t.MAX_UINT64=BigInt("0xffffffffffffffff"),t.MAX_INTEGER=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),t.MAX_INTEGER_BIGINT=BigInt("115792089237316195423570985008687907853269984665640564039457584007913129639935"),t.SECP256K1_ORDER=o.secp256k1.CURVE.n,t.SECP256K1_ORDER_DIV_2=o.secp256k1.CURVE.n/BigInt(2),t.TWO_POW256=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000"),t.KECCAK256_NULL_S="c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",t.KECCAK256_NULL=n.Buffer.from(t.KECCAK256_NULL_S,"hex"),t.KECCAK256_RLP_ARRAY_S="1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",t.KECCAK256_RLP_ARRAY=n.Buffer.from(t.KECCAK256_RLP_ARRAY_S,"hex"),t.KECCAK256_RLP_S="56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",t.KECCAK256_RLP=n.Buffer.from(t.KECCAK256_RLP_S,"hex"),t.RLP_EMPTY_STRING=n.Buffer.from([128]),t.MAX_WITHDRAWALS_PER_PAYLOAD=16},3791:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.compactBytesToNibbles=t.bytesToNibbles=t.nibblesToCompactBytes=t.nibblesToBytes=t.hasTerminator=void 0,t.hasTerminator=e=>e.length>0&&16===e[e.length-1],t.nibblesToBytes=(e,t)=>{for(let r=0,n=0;n<e.length;r+=1,n+=2)t[r]=e[n]<<4|e[n+1]},t.nibblesToCompactBytes=e=>{let r=0;(0,t.hasTerminator)(e)&&(r=1,e=e.subarray(0,e.length-1));const n=new Uint8Array(e.length/2+1);return n[0]=r<<5,1==(1&e.length)&&(n[0]|=16,n[0]|=e[0],e=e.subarray(1)),(0,t.nibblesToBytes)(e,n.subarray(1)),n},t.bytesToNibbles=e=>{const t=2*e.length+1,r=new Uint8Array(t);for(let t=0;t<e.length;t++){const n=e[t];r[2*t]=n/16,r[2*t+1]=n%16}return r[t-1]=16,r},t.compactBytesToNibbles=e=>{if(0===e.length)return e;let r=(0,t.bytesToNibbles)(e);r[0]<2&&(r=r.subarray(0,r.length-1));const n=2-(1&r[0]);return r.subarray(n)}},8480:(e,t,r)=>{"use strict";var n=r(8764).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.assertIsString=t.assertIsArray=t.assertIsBuffer=t.assertIsHexString=void 0;const o=r(4712);t.assertIsHexString=function(e){if(!(0,o.isHexString)(e))throw new Error(`This method only supports 0x-prefixed hex strings but input was: ${e}`)},t.assertIsBuffer=function(e){if(!n.isBuffer(e))throw new Error(`This method only supports Buffer but input was: ${e}`)},t.assertIsArray=function(e){if(!Array.isArray(e))throw new Error(`This method only supports number arrays but input was: ${e}`)},t.assertIsString=function(e){if("string"!=typeof e)throw new Error(`This method only supports strings but input was: ${e}`)}},2730:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.toAscii=t.stripHexPrefix=t.padToEven=t.isHexString=t.isHexPrefixed=t.getKeys=t.getBinarySize=t.fromUtf8=t.fromAscii=t.arrayContainsArray=void 0,o(r(6219),t),o(r(4554),t),o(r(8e3),t),o(r(3415),t),o(r(4683),t),o(r(5026),t),o(r(8289),t),o(r(1200),t),o(r(3791),t),o(r(7285),t);var i=r(4712);Object.defineProperty(t,"arrayContainsArray",{enumerable:!0,get:function(){return i.arrayContainsArray}}),Object.defineProperty(t,"fromAscii",{enumerable:!0,get:function(){return i.fromAscii}}),Object.defineProperty(t,"fromUtf8",{enumerable:!0,get:function(){return i.fromUtf8}}),Object.defineProperty(t,"getBinarySize",{enumerable:!0,get:function(){return i.getBinarySize}}),Object.defineProperty(t,"getKeys",{enumerable:!0,get:function(){return i.getKeys}}),Object.defineProperty(t,"isHexPrefixed",{enumerable:!0,get:function(){return i.isHexPrefixed}}),Object.defineProperty(t,"isHexString",{enumerable:!0,get:function(){return i.isHexString}}),Object.defineProperty(t,"padToEven",{enumerable:!0,get:function(){return i.padToEven}}),Object.defineProperty(t,"stripHexPrefix",{enumerable:!0,get:function(){return i.stripHexPrefix}}),Object.defineProperty(t,"toAscii",{enumerable:!0,get:function(){return i.toAscii}}),o(r(3543),t),o(r(438),t)},4712:(e,t,r)=>{"use strict";var n=r(8764).Buffer;function o(e){if("string"!=typeof e)throw new Error("[isHexPrefixed] input must be type 'string', received type "+typeof e);return"0"===e[0]&&"x"===e[1]}function i(e){let t=e;if("string"!=typeof t)throw new Error("[padToEven] value must be type 'string', received "+typeof t);return t.length%2&&(t=`0${t}`),t}Object.defineProperty(t,"__esModule",{value:!0}),t.isHexString=t.getKeys=t.fromAscii=t.fromUtf8=t.toAscii=t.arrayContainsArray=t.getBinarySize=t.padToEven=t.stripHexPrefix=t.isHexPrefixed=void 0,t.isHexPrefixed=o,t.stripHexPrefix=e=>{if("string"!=typeof e)throw new Error("[stripHexPrefix] input must be type 'string', received "+typeof e);return o(e)?e.slice(2):e},t.padToEven=i,t.getBinarySize=function(e){if("string"!=typeof e)throw new Error("[getBinarySize] method requires input type 'string', received "+typeof e);return n.byteLength(e,"utf8")},t.arrayContainsArray=function(e,t,r){if(!0!==Array.isArray(e))throw new Error(`[arrayContainsArray] method requires input 'superset' to be an array, got type '${typeof e}'`);if(!0!==Array.isArray(t))throw new Error(`[arrayContainsArray] method requires input 'subset' to be an array, got type '${typeof t}'`);return t[!0===r?"some":"every"]((t=>e.indexOf(t)>=0))},t.toAscii=function(e){let t="",r=0;const n=e.length;for("0x"===e.substring(0,2)&&(r=2);r<n;r+=2){const n=parseInt(e.substr(r,2),16);t+=String.fromCharCode(n)}return t},t.fromUtf8=function(e){return`0x${i(n.from(e,"utf8").toString("hex")).replace(/^0+|0+$/g,"")}`},t.fromAscii=function(e){let t="";for(let r=0;r<e.length;r++){const n=e.charCodeAt(r).toString(16);t+=n.length<2?`0${n}`:n}return`0x${t}`},t.getKeys=function(e,t,r){if(!Array.isArray(e))throw new Error("[getKeys] method expects input 'params' to be an array, got "+typeof e);if("string"!=typeof t)throw new Error("[getKeys] method expects input 'key' to be type 'string', got "+typeof e);const n=[];for(let o=0;o<e.length;o++){let i=e[o][t];if(!0!==r||i){if("string"!=typeof i)throw new Error("invalid abi - expected type 'string', received "+typeof i)}else i="";n.push(i)}return n},t.isHexString=function(e,t){return!("string"!=typeof e||!e.match(/^0x[0-9A-Fa-f]*$/)||void 0!==t&&t>0&&e.length!==2+2*t)}},3543:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Lock=void 0,t.Lock=class{constructor(){this.permits=1,this.promiseResolverQueue=[]}async acquire(){return this.permits>0?(this.permits-=1,Promise.resolve(!0)):new Promise((e=>this.promiseResolverQueue.push(e)))}release(){if(this.permits+=1,this.permits>1&&this.promiseResolverQueue.length>0)console.warn("Lock.permits should never be > 0 when there is someone waiting.");else if(1===this.permits&&this.promiseResolverQueue.length>0){this.permits-=1;const e=this.promiseResolverQueue.shift();e&&e(!0)}}}},438:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getProvider=t.fetchFromProvider=void 0;const n=r(4898);t.fetchFromProvider=async(e,t)=>(await(0,n.default)(e,{headers:{"content-type":"application/json"},type:"json",data:{method:t.method,params:t.params,jsonrpc:"2.0",id:1}})).result,t.getProvider=e=>{if("string"==typeof e)return e;if(void 0!==e?.connection?.url)return e.connection.url;throw new Error("Must provide valid provider URL or Web3Provider")}},5026:(e,t,r)=>{"use strict";var n=r(8764).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.hashPersonalMessage=t.isValidSignature=t.fromRpcSig=t.toCompactSig=t.toRpcSig=t.ecrecover=t.ecsign=void 0;const o=r(2192),i=r(5053),s=r(8289),a=r(6219),u=r(8480);function c(e,t){return e===BigInt(0)||e===BigInt(1)?e:void 0===t?e-BigInt(27):e-(t*BigInt(2)+BigInt(35))}function l(e){return e===BigInt(0)||e===BigInt(1)}t.ecsign=function(e,t,r){const o=i.secp256k1.sign(e,t),s=o.toCompactRawBytes();return{r:n.from(s.slice(0,32)),s:n.from(s.slice(32,64)),v:void 0===r?BigInt(o.recovery+27):BigInt(o.recovery+35)+BigInt(r)*BigInt(2)}},t.ecrecover=function(e,t,r,o,a){const u=n.concat([(0,s.setLengthLeft)(r,32),(0,s.setLengthLeft)(o,32)],64),f=c(t,a);if(!l(f))throw new Error("Invalid signature v value");const h=i.secp256k1.Signature.fromCompact(u).addRecoveryBit(Number(f)).recoverPublicKey(e);return n.from(h.toRawBytes(!1).slice(1))},t.toRpcSig=function(e,t,r,o){if(!l(c(e,o)))throw new Error("Invalid signature v value");return(0,s.bufferToHex)(n.concat([(0,s.setLengthLeft)(t,32),(0,s.setLengthLeft)(r,32),(0,s.toBuffer)(e)]))},t.toCompactSig=function(e,t,r,o){if(!l(c(e,o)))throw new Error("Invalid signature v value");let i=r;return(e>BigInt(28)&&e%BigInt(2)===BigInt(1)||e===BigInt(1)||e===BigInt(28))&&(i=n.from(r),i[0]|=128),(0,s.bufferToHex)(n.concat([(0,s.setLengthLeft)(t,32),(0,s.setLengthLeft)(i,32)]))},t.fromRpcSig=function(e){const t=(0,s.toBuffer)(e);let r,n,o;if(t.length>=65)r=t.slice(0,32),n=t.slice(32,64),o=(0,s.bufferToBigInt)(t.slice(64));else{if(64!==t.length)throw new Error("Invalid signature length");r=t.slice(0,32),n=t.slice(32,64),o=BigInt((0,s.bufferToInt)(t.slice(32,33))>>7),n[0]&=127}return o<27&&(o+=BigInt(27)),{v:o,r,s:n}},t.isValidSignature=function(e,t,r,n=!0,o){if(32!==t.length||32!==r.length)return!1;if(!l(c(e,o)))return!1;const i=(0,s.bufferToBigInt)(t),u=(0,s.bufferToBigInt)(r);return!(i===BigInt(0)||i>=a.SECP256K1_ORDER||u===BigInt(0)||u>=a.SECP256K1_ORDER||n&&u>=a.SECP256K1_ORDER_DIV_2)},t.hashPersonalMessage=function(e){(0,u.assertIsBuffer)(e);const t=n.from(`Ethereum Signed Message:\n${e.length}`,"utf-8");return n.from((0,o.keccak256)(n.concat([t,e])))}},1200:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toType=t.TypeOutput=void 0;const n=r(8289),o=r(4712);var i;!function(e){e[e.Number=0]="Number",e[e.BigInt=1]="BigInt",e[e.Buffer=2]="Buffer",e[e.PrefixedHexString=3]="PrefixedHexString"}(i=t.TypeOutput||(t.TypeOutput={})),t.toType=function(e,t){if(null===e)return null;if(void 0===e)return;if("string"==typeof e&&!(0,o.isHexString)(e))throw new Error(`A string must be provided with a 0x-prefix, given: ${e}`);if("number"==typeof e&&!Number.isSafeInteger(e))throw new Error("The provided number is greater than MAX_SAFE_INTEGER (please use an alternative input type)");const r=(0,n.toBuffer)(e);switch(t){case i.Buffer:return r;case i.BigInt:return(0,n.bufferToBigInt)(r);case i.Number:{const e=(0,n.bufferToBigInt)(r);if(e>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("The provided number is greater than MAX_SAFE_INTEGER (please use an alternative output type)");return Number(e)}case i.PrefixedHexString:return(0,n.bufferToHex)(r);default:throw new Error("unknown outputType")}}},4554:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GWEI_TO_WEI=void 0,t.GWEI_TO_WEI=BigInt(1e9)},4683:(e,t,r)=>{"use strict";var n=r(8764).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.Withdrawal=void 0;const o=r(3415),i=r(8289),s=r(1200);class a{constructor(e,t,r,n){this.index=e,this.validatorIndex=t,this.address=r,this.amount=n}static fromWithdrawalData(e){const{index:t,validatorIndex:r,address:n,amount:i}=e,u=(0,s.toType)(t,s.TypeOutput.BigInt),c=(0,s.toType)(r,s.TypeOutput.BigInt),l=new o.Address((0,s.toType)(n,s.TypeOutput.Buffer)),f=(0,s.toType)(i,s.TypeOutput.BigInt);return new a(u,c,l,f)}static fromValuesArray(e){if(4!==e.length)throw Error(`Invalid withdrawalArray length expected=4 actual=${e.length}`);const[t,r,n,o]=e;return a.fromWithdrawalData({index: