@reown/appkit-cdn 1.8.15-e95f0d61c614677233e13ea9f055d3f75fcdba81.0 → 1.8.15-viem-upgrade.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +10 -10
- package/dist/ConstantsUtil-C2Ed2H2U.js +0 -24
- package/dist/ConstantsUtil-C2Ed2H2U.js.map +0 -1
- package/dist/ExchangeController-h_95bqSB.js +0 -265
- package/dist/ExchangeController-h_95bqSB.js.map +0 -1
- package/dist/HelpersUtil-xYeUfp1A.js +0 -141
- package/dist/HelpersUtil-xYeUfp1A.js.map +0 -1
- package/dist/NavigationUtil-Ci15WS4K.js +0 -9
- package/dist/NavigationUtil-Ci15WS4K.js.map +0 -1
- package/dist/PhArrowCircleDown-B41iUlWV.js +0 -74
- package/dist/PhArrowCircleDown-B41iUlWV.js.map +0 -1
- package/dist/PhArrowClockwise-BY8u5n41.js +0 -74
- package/dist/PhArrowClockwise-BY8u5n41.js.map +0 -1
- package/dist/PhArrowDown-ClD8GZ65.js +0 -74
- package/dist/PhArrowDown-ClD8GZ65.js.map +0 -1
- package/dist/PhArrowLeft-B8MXUz60.js +0 -74
- package/dist/PhArrowLeft-B8MXUz60.js.map +0 -1
- package/dist/PhArrowRight-Cewa_Slb.js +0 -74
- package/dist/PhArrowRight-Cewa_Slb.js.map +0 -1
- package/dist/PhArrowSquareOut-whgWh-lD.js +0 -74
- package/dist/PhArrowSquareOut-whgWh-lD.js.map +0 -1
- package/dist/PhArrowUp-B1HXBxie.js +0 -74
- package/dist/PhArrowUp-B1HXBxie.js.map +0 -1
- package/dist/PhArrowUpRight-CfFYe4FP.js +0 -74
- package/dist/PhArrowUpRight-CfFYe4FP.js.map +0 -1
- package/dist/PhArrowsClockwise-gL1Gkrtx.js +0 -74
- package/dist/PhArrowsClockwise-gL1Gkrtx.js.map +0 -1
- package/dist/PhArrowsDownUp-BqUEdUQr.js +0 -74
- package/dist/PhArrowsDownUp-BqUEdUQr.js.map +0 -1
- package/dist/PhArrowsLeftRight-BlZU63eY.js +0 -74
- package/dist/PhArrowsLeftRight-BlZU63eY.js.map +0 -1
- package/dist/PhBank-gbg_jlI7.js +0 -74
- package/dist/PhBank-gbg_jlI7.js.map +0 -1
- package/dist/PhBrowser-CMlD-YJw.js +0 -74
- package/dist/PhBrowser-CMlD-YJw.js.map +0 -1
- package/dist/PhCaretDown-3agTO8Jp.js +0 -74
- package/dist/PhCaretDown-3agTO8Jp.js.map +0 -1
- package/dist/PhCaretLeft-_MTni7Z5.js +0 -74
- package/dist/PhCaretLeft-_MTni7Z5.js.map +0 -1
- package/dist/PhCaretRight-Ci9fAHPG.js +0 -74
- package/dist/PhCaretRight-Ci9fAHPG.js.map +0 -1
- package/dist/PhCaretUp-vFG4Fame.js +0 -74
- package/dist/PhCaretUp-vFG4Fame.js.map +0 -1
- package/dist/PhCheck-mChGK6K_.js +0 -74
- package/dist/PhCheck-mChGK6K_.js.map +0 -1
- package/dist/PhCircleHalf-DZ7-vfxf.js +0 -74
- package/dist/PhCircleHalf-DZ7-vfxf.js.map +0 -1
- package/dist/PhClock-Bc5XWXb6.js +0 -74
- package/dist/PhClock-Bc5XWXb6.js.map +0 -1
- package/dist/PhCompass-Cu2MB-55.js +0 -74
- package/dist/PhCompass-Cu2MB-55.js.map +0 -1
- package/dist/PhCopy-BGUjyTts.js +0 -74
- package/dist/PhCopy-BGUjyTts.js.map +0 -1
- package/dist/PhCreditCard-vxFWID4B.js +0 -74
- package/dist/PhCreditCard-vxFWID4B.js.map +0 -1
- package/dist/PhCurrencyDollar-BfOoDhJr.js +0 -74
- package/dist/PhCurrencyDollar-BfOoDhJr.js.map +0 -1
- package/dist/PhDesktop-Cq6jwzbS.js +0 -74
- package/dist/PhDesktop-Cq6jwzbS.js.map +0 -1
- package/dist/PhDeviceMobile-BCtTp6jj.js +0 -74
- package/dist/PhDeviceMobile-BCtTp6jj.js.map +0 -1
- package/dist/PhDotsThree-BGgD-WIO.js +0 -74
- package/dist/PhDotsThree-BGgD-WIO.js.map +0 -1
- package/dist/PhEnvelope-CQiV0-zG.js +0 -74
- package/dist/PhEnvelope-CQiV0-zG.js.map +0 -1
- package/dist/PhFunnelSimple-BHGtxTNf.js +0 -74
- package/dist/PhFunnelSimple-BHGtxTNf.js.map +0 -1
- package/dist/PhGlobe-Q8oVkf6X.js +0 -74
- package/dist/PhGlobe-Q8oVkf6X.js.map +0 -1
- package/dist/PhIdentificationCard-Cz9LzvVR.js +0 -74
- package/dist/PhIdentificationCard-Cz9LzvVR.js.map +0 -1
- package/dist/PhImage-CP5_qKk-.js +0 -74
- package/dist/PhImage-CP5_qKk-.js.map +0 -1
- package/dist/PhInfo-CTlE1X9Z.js +0 -74
- package/dist/PhInfo-CTlE1X9Z.js.map +0 -1
- package/dist/PhLightbulb-CcLpnAAb.js +0 -74
- package/dist/PhLightbulb-CcLpnAAb.js.map +0 -1
- package/dist/PhMagnifyingGlass-n58GUAck.js +0 -74
- package/dist/PhMagnifyingGlass-n58GUAck.js.map +0 -1
- package/dist/PhPaperPlaneRight-C0sf2XV8.js +0 -74
- package/dist/PhPaperPlaneRight-C0sf2XV8.js.map +0 -1
- package/dist/PhPlus-BJxvt7Uc.js +0 -74
- package/dist/PhPlus-BJxvt7Uc.js.map +0 -1
- package/dist/PhPower-BvktxO2-.js +0 -74
- package/dist/PhPower-BvktxO2-.js.map +0 -1
- package/dist/PhPuzzlePiece-CDDyUPYo.js +0 -74
- package/dist/PhPuzzlePiece-CDDyUPYo.js.map +0 -1
- package/dist/PhQrCode-BlGI8529.js +0 -74
- package/dist/PhQrCode-BlGI8529.js.map +0 -1
- package/dist/PhQuestion-DGZj6iDZ.js +0 -74
- package/dist/PhQuestion-DGZj6iDZ.js.map +0 -1
- package/dist/PhQuestionMark-CTmeI7MQ.js +0 -74
- package/dist/PhQuestionMark-CTmeI7MQ.js.map +0 -1
- package/dist/PhSealCheck-BSlqkxnH.js +0 -74
- package/dist/PhSealCheck-BSlqkxnH.js.map +0 -1
- package/dist/PhSignOut-CEXxlRk3.js +0 -74
- package/dist/PhSignOut-CEXxlRk3.js.map +0 -1
- package/dist/PhSpinner-Do1pY8fG.js +0 -74
- package/dist/PhSpinner-Do1pY8fG.js.map +0 -1
- package/dist/PhTrash-JNKavmpg.js +0 -74
- package/dist/PhTrash-JNKavmpg.js.map +0 -1
- package/dist/PhUser-BW7E-xYg.js +0 -74
- package/dist/PhUser-BW7E-xYg.js.map +0 -1
- package/dist/PhVault-mzxUgBYN.js +0 -74
- package/dist/PhVault-mzxUgBYN.js.map +0 -1
- package/dist/PhWallet-BR9JThKU.js +0 -74
- package/dist/PhWallet-BR9JThKU.js.map +0 -1
- package/dist/PhWarning-DxuQ70WM.js +0 -74
- package/dist/PhWarning-DxuQ70WM.js.map +0 -1
- package/dist/PhWarningCircle-DCI0JC1F.js +0 -74
- package/dist/PhWarningCircle-DCI0JC1F.js.map +0 -1
- package/dist/PhX-CWNXqpGn.js +0 -74
- package/dist/PhX-CWNXqpGn.js.map +0 -1
- package/dist/SwapController-CwWMKLPL.js +0 -684
- package/dist/SwapController-CwWMKLPL.js.map +0 -1
- package/dist/WebCryptoP256-B0F1BoHd.js +0 -3299
- package/dist/WebCryptoP256-B0F1BoHd.js.map +0 -1
- package/dist/add-emiZFWKE.js +0 -20
- package/dist/add-emiZFWKE.js.map +0 -1
- package/dist/all-wallets-BsUQMPgW.js +0 -11
- package/dist/all-wallets-BsUQMPgW.js.map +0 -1
- package/dist/app-store-C_L7BoYc.js +0 -22
- package/dist/app-store-C_L7BoYc.js.map +0 -1
- package/dist/appkit-DY7XpK4K.js +0 -118074
- package/dist/appkit-DY7XpK4K.js.map +0 -1
- package/dist/appkit.js +0 -11
- package/dist/appkit.js.map +0 -1
- package/dist/apple-c3IhsqlY.js +0 -23
- package/dist/apple-c3IhsqlY.js.map +0 -1
- package/dist/arrow-bottom-BZnD_9In.js +0 -13
- package/dist/arrow-bottom-BZnD_9In.js.map +0 -1
- package/dist/arrow-bottom-circle-C9HRc3sW.js +0 -16
- package/dist/arrow-bottom-circle-C9HRc3sW.js.map +0 -1
- package/dist/arrow-left-DFlXkOXB.js +0 -13
- package/dist/arrow-left-DFlXkOXB.js.map +0 -1
- package/dist/arrow-right-_EPGORWI.js +0 -13
- package/dist/arrow-right-_EPGORWI.js.map +0 -1
- package/dist/arrow-top-CrBCvUsj.js +0 -13
- package/dist/arrow-top-CrBCvUsj.js.map +0 -1
- package/dist/async-directive-CEBoIWb8.js +0 -73
- package/dist/async-directive-CEBoIWb8.js.map +0 -1
- package/dist/bank-IrtkQnW0.js +0 -19
- package/dist/bank-IrtkQnW0.js.map +0 -1
- package/dist/basic-CCVK4Xb-.js +0 -4914
- package/dist/basic-CCVK4Xb-.js.map +0 -1
- package/dist/browser-5XoTmr4n.js +0 -1991
- package/dist/browser-5XoTmr4n.js.map +0 -1
- package/dist/browser-DGJ1T57R.js +0 -19
- package/dist/browser-DGJ1T57R.js.map +0 -1
- package/dist/card-euIrImBb.js +0 -19
- package/dist/card-euIrImBb.js.map +0 -1
- package/dist/ccip-BnHcw2Q9.js +0 -164
- package/dist/ccip-BnHcw2Q9.js.map +0 -1
- package/dist/checkmark-DOfVZz7v.js +0 -16
- package/dist/checkmark-DOfVZz7v.js.map +0 -1
- package/dist/checkmark-bold-CBk9rneH.js +0 -13
- package/dist/checkmark-bold-CBk9rneH.js.map +0 -1
- package/dist/chevron-bottom-DqxWxVi0.js +0 -13
- package/dist/chevron-bottom-DqxWxVi0.js.map +0 -1
- package/dist/chevron-left-JKsYvrX0.js +0 -13
- package/dist/chevron-left-JKsYvrX0.js.map +0 -1
- package/dist/chevron-right-0IHVmnlN.js +0 -13
- package/dist/chevron-right-0IHVmnlN.js.map +0 -1
- package/dist/chevron-top-q1UXuE7C.js +0 -13
- package/dist/chevron-top-q1UXuE7C.js.map +0 -1
- package/dist/chrome-store-C1gUHLGC.js +0 -66
- package/dist/chrome-store-C1gUHLGC.js.map +0 -1
- package/dist/class-map-CqyLxUs0.js +0 -101
- package/dist/class-map-CqyLxUs0.js.map +0 -1
- package/dist/clock-CRgBEN3N.js +0 -13
- package/dist/clock-CRgBEN3N.js.map +0 -1
- package/dist/close-DqwtanuV.js +0 -13
- package/dist/close-DqwtanuV.js.map +0 -1
- package/dist/clsx.m-D57qXwfE.js +0 -21
- package/dist/clsx.m-D57qXwfE.js.map +0 -1
- package/dist/coinPlaceholder-DGuEyon3.js +0 -13
- package/dist/coinPlaceholder-DGuEyon3.js.map +0 -1
- package/dist/compass-D3Lk_JmD.js +0 -13
- package/dist/compass-D3Lk_JmD.js.map +0 -1
- package/dist/copy-0bHy8N_r.js +0 -20
- package/dist/copy-0bHy8N_r.js.map +0 -1
- package/dist/core-C111yg8v.js +0 -16288
- package/dist/core-C111yg8v.js.map +0 -1
- package/dist/cursor-Bnlh8YKu.js +0 -8
- package/dist/cursor-Bnlh8YKu.js.map +0 -1
- package/dist/cursor-transparent-BqTVTA3D.js +0 -17
- package/dist/cursor-transparent-BqTVTA3D.js.map +0 -1
- package/dist/data-capture-BtdmOx65.js +0 -549
- package/dist/data-capture-BtdmOx65.js.map +0 -1
- package/dist/desktop-BKaI6I0c.js +0 -14
- package/dist/desktop-BKaI6I0c.js.map +0 -1
- package/dist/disconnect-CJtwIHdJ.js +0 -13
- package/dist/disconnect-CJtwIHdJ.js.map +0 -1
- package/dist/discord-oHqb6ClE.js +0 -22
- package/dist/discord-oHqb6ClE.js.map +0 -1
- package/dist/email-9QNGgeQQ.js +0 -421
- package/dist/email-9QNGgeQQ.js.map +0 -1
- package/dist/embedded-wallet-C_CLs-ZL.js +0 -952
- package/dist/embedded-wallet-C_CLs-ZL.js.map +0 -1
- package/dist/etherscan-Dkkz1Mfh.js +0 -11
- package/dist/etherscan-Dkkz1Mfh.js.map +0 -1
- package/dist/exclamation-triangle-BQbUCEhi.js +0 -9
- package/dist/exclamation-triangle-BQbUCEhi.js.map +0 -1
- package/dist/extension-C2hKzEZZ.js +0 -13
- package/dist/extension-C2hKzEZZ.js.map +0 -1
- package/dist/external-link-CIjsnb3X.js +0 -13
- package/dist/external-link-CIjsnb3X.js.map +0 -1
- package/dist/facebook-1Hufe3sI.js +0 -31
- package/dist/facebook-1Hufe3sI.js.map +0 -1
- package/dist/farcaster-DlSxA8AD.js +0 -17
- package/dist/farcaster-DlSxA8AD.js.map +0 -1
- package/dist/features-CubAsZN1.js +0 -319
- package/dist/features-CubAsZN1.js.map +0 -1
- package/dist/filters-Bx5zOyri.js +0 -13
- package/dist/filters-Bx5zOyri.js.map +0 -1
- package/dist/github-CT_NtR6h.js +0 -23
- package/dist/github-CT_NtR6h.js.map +0 -1
- package/dist/google-Dkv0ZPY6.js +0 -23
- package/dist/google-Dkv0ZPY6.js.map +0 -1
- package/dist/hashTypedData-Q6QDIxse.js +0 -262
- package/dist/hashTypedData-Q6QDIxse.js.map +0 -1
- package/dist/help-circle-Dh0SYux9.js +0 -17
- package/dist/help-circle-Dh0SYux9.js.map +0 -1
- package/dist/id-Dc_gfIHE.js +0 -17
- package/dist/id-Dc_gfIHE.js.map +0 -1
- package/dist/if-defined-B5CxFQec.js +0 -11
- package/dist/if-defined-B5CxFQec.js.map +0 -1
- package/dist/image-DPwaTi09.js +0 -9
- package/dist/image-DPwaTi09.js.map +0 -1
- package/dist/index-AsDH-m9e.js +0 -456
- package/dist/index-AsDH-m9e.js.map +0 -1
- package/dist/index-B-AePZns.js +0 -1514
- package/dist/index-B-AePZns.js.map +0 -1
- package/dist/index-B0nuzWGd.js +0 -153
- package/dist/index-B0nuzWGd.js.map +0 -1
- package/dist/index-BFK8rn8f.js +0 -985
- package/dist/index-BFK8rn8f.js.map +0 -1
- package/dist/index-BGtDVhOX.js +0 -218
- package/dist/index-BGtDVhOX.js.map +0 -1
- package/dist/index-BXRoNn9X.js +0 -147
- package/dist/index-BXRoNn9X.js.map +0 -1
- package/dist/index-BYnWTIsP.js +0 -257
- package/dist/index-BYnWTIsP.js.map +0 -1
- package/dist/index-B_yrV2-r.js +0 -7258
- package/dist/index-B_yrV2-r.js.map +0 -1
- package/dist/index-BcCvzVg5.js +0 -716
- package/dist/index-BcCvzVg5.js.map +0 -1
- package/dist/index-BeSFhM_p.js +0 -120
- package/dist/index-BeSFhM_p.js.map +0 -1
- package/dist/index-BgnNrRDq.js +0 -967
- package/dist/index-BgnNrRDq.js.map +0 -1
- package/dist/index-BqpTTobE.js +0 -984
- package/dist/index-BqpTTobE.js.map +0 -1
- package/dist/index-BxPoDEMu.js +0 -7481
- package/dist/index-BxPoDEMu.js.map +0 -1
- package/dist/index-ByLuz3My.js +0 -182
- package/dist/index-ByLuz3My.js.map +0 -1
- package/dist/index-BzPjzg08.js +0 -62
- package/dist/index-BzPjzg08.js.map +0 -1
- package/dist/index-C2E-8AS5.js +0 -249
- package/dist/index-C2E-8AS5.js.map +0 -1
- package/dist/index-C4icMnjM.js +0 -521
- package/dist/index-C4icMnjM.js.map +0 -1
- package/dist/index-C8av2G6v.js +0 -136
- package/dist/index-C8av2G6v.js.map +0 -1
- package/dist/index-CE9D5nR3.js +0 -441
- package/dist/index-CE9D5nR3.js.map +0 -1
- package/dist/index-CI83C2eb.js +0 -124
- package/dist/index-CI83C2eb.js.map +0 -1
- package/dist/index-CK8vtUMI.js +0 -181
- package/dist/index-CK8vtUMI.js.map +0 -1
- package/dist/index-CY_gr4c7.js +0 -286
- package/dist/index-CY_gr4c7.js.map +0 -1
- package/dist/index-CZmyXVNe.js +0 -198
- package/dist/index-CZmyXVNe.js.map +0 -1
- package/dist/index-CemyBXIP.js +0 -8825
- package/dist/index-CemyBXIP.js.map +0 -1
- package/dist/index-CkrKEace.js +0 -180
- package/dist/index-CkrKEace.js.map +0 -1
- package/dist/index-Cl94CXn7.js +0 -110
- package/dist/index-Cl94CXn7.js.map +0 -1
- package/dist/index-CwK6o8Hz.js +0 -18322
- package/dist/index-CwK6o8Hz.js.map +0 -1
- package/dist/index-Cy1DAN6W.js +0 -542
- package/dist/index-Cy1DAN6W.js.map +0 -1
- package/dist/index-CziMS40-.js +0 -281
- package/dist/index-CziMS40-.js.map +0 -1
- package/dist/index-D6qUKJRD.js +0 -1178
- package/dist/index-D6qUKJRD.js.map +0 -1
- package/dist/index-DDYN4XOm.js +0 -211
- package/dist/index-DDYN4XOm.js.map +0 -1
- package/dist/index-DHcBAN0Q.js +0 -9350
- package/dist/index-DHcBAN0Q.js.map +0 -1
- package/dist/index-DPEv06yg.js +0 -520
- package/dist/index-DPEv06yg.js.map +0 -1
- package/dist/index-DShG1B5f.js +0 -131
- package/dist/index-DShG1B5f.js.map +0 -1
- package/dist/index-DTOiAL1i.js +0 -52
- package/dist/index-DTOiAL1i.js.map +0 -1
- package/dist/index-DVyI9O5i.js +0 -92
- package/dist/index-DVyI9O5i.js.map +0 -1
- package/dist/index-DvXemhcG.js +0 -611
- package/dist/index-DvXemhcG.js.map +0 -1
- package/dist/index-Fvw4sbfL.js +0 -198
- package/dist/index-Fvw4sbfL.js.map +0 -1
- package/dist/index-PiXpeN5n.js +0 -3987
- package/dist/index-PiXpeN5n.js.map +0 -1
- package/dist/index-btvyw5xW.js +0 -126
- package/dist/index-btvyw5xW.js.map +0 -1
- package/dist/index-dsKNiJml.js +0 -70
- package/dist/index-dsKNiJml.js.map +0 -1
- package/dist/index-gEaD8hfK.js +0 -109
- package/dist/index-gEaD8hfK.js.map +0 -1
- package/dist/index-isOxTzum.js +0 -147
- package/dist/index-isOxTzum.js.map +0 -1
- package/dist/index-nWSgWKaF.js +0 -2277
- package/dist/index-nWSgWKaF.js.map +0 -1
- package/dist/index-qQiVpif7.js +0 -1372
- package/dist/index-qQiVpif7.js.map +0 -1
- package/dist/index-tv-dalA1.js +0 -73
- package/dist/index-tv-dalA1.js.map +0 -1
- package/dist/index.es-BzCqYMc8.js +0 -8391
- package/dist/index.es-BzCqYMc8.js.map +0 -1
- package/dist/info-4ssFoXJS.js +0 -8
- package/dist/info-4ssFoXJS.js.map +0 -1
- package/dist/info-circle-BnqHwvcX.js +0 -17
- package/dist/info-circle-BnqHwvcX.js.map +0 -1
- package/dist/jsxRuntime.module-CWsrm3KZ.js +0 -14
- package/dist/jsxRuntime.module-CWsrm3KZ.js.map +0 -1
- package/dist/lightbulb-BEEbBBZQ.js +0 -8
- package/dist/lightbulb-BEEbBBZQ.js.map +0 -1
- package/dist/localBatchGatewayRequest-Dryp85EG.js +0 -103
- package/dist/localBatchGatewayRequest-Dryp85EG.js.map +0 -1
- package/dist/mail-CJLCh290.js +0 -13
- package/dist/mail-CJLCh290.js.map +0 -1
- package/dist/metamask-sdk-4u4X6Xn3.js +0 -16699
- package/dist/metamask-sdk-4u4X6Xn3.js.map +0 -1
- package/dist/mobile-Deau0Za4.js +0 -14
- package/dist/mobile-Deau0Za4.js.map +0 -1
- package/dist/more-BeXo-Pwn.js +0 -16
- package/dist/more-BeXo-Pwn.js.map +0 -1
- package/dist/native-DOlbMZnh.js +0 -17
- package/dist/native-DOlbMZnh.js.map +0 -1
- package/dist/network-placeholder-BoityKSt.js +0 -19
- package/dist/network-placeholder-BoityKSt.js.map +0 -1
- package/dist/nftPlaceholder-PTHT5Ulj.js +0 -13
- package/dist/nftPlaceholder-PTHT5Ulj.js.map +0 -1
- package/dist/off-BWWypY2E.js +0 -13
- package/dist/off-BWWypY2E.js.map +0 -1
- package/dist/onramp-DnL6ChSq.js +0 -979
- package/dist/onramp-DnL6ChSq.js.map +0 -1
- package/dist/parseAbiParameters-DfJcIE_w.js +0 -757
- package/dist/parseAbiParameters-DfJcIE_w.js.map +0 -1
- package/dist/parseSignature-CxTkG24t.js +0 -4690
- package/dist/parseSignature-CxTkG24t.js.map +0 -1
- package/dist/pay-with-exchange-CpuGLivJ.js +0 -603
- package/dist/pay-with-exchange-CpuGLivJ.js.map +0 -1
- package/dist/play-store-DkxQRJyA.js +0 -37
- package/dist/play-store-DkxQRJyA.js.map +0 -1
- package/dist/plus-DaGtBhNd.js +0 -18
- package/dist/plus-DaGtBhNd.js.map +0 -1
- package/dist/property-8UcTqffH.js +0 -623
- package/dist/property-8UcTqffH.js.map +0 -1
- package/dist/qr-code-DGvMTPaF.js +0 -11
- package/dist/qr-code-DGvMTPaF.js.map +0 -1
- package/dist/receive-CVWmkRpl.js +0 -262
- package/dist/receive-CVWmkRpl.js.map +0 -1
- package/dist/recycle-horizontal-DDVEtj7J.js +0 -14
- package/dist/recycle-horizontal-DDVEtj7J.js.map +0 -1
- package/dist/ref-DAjgVrGH.js +0 -43
- package/dist/ref-DAjgVrGH.js.map +0 -1
- package/dist/refresh-BmNFE8Pg.js +0 -13
- package/dist/refresh-BmNFE8Pg.js.map +0 -1
- package/dist/reown-logo-B-UO-SeO.js +0 -17
- package/dist/reown-logo-B-UO-SeO.js.map +0 -1
- package/dist/search-DR_B_4SQ.js +0 -13
- package/dist/search-DR_B_4SQ.js.map +0 -1
- package/dist/secp256k1-DnXqhCKw.js +0 -2031
- package/dist/secp256k1-DnXqhCKw.js.map +0 -1
- package/dist/send-BNU8VrfM.js +0 -20
- package/dist/send-BNU8VrfM.js.map +0 -1
- package/dist/send-DHzM4I8V.js +0 -1365
- package/dist/send-DHzM4I8V.js.map +0 -1
- package/dist/socials-DsoFf1B8.js +0 -796
- package/dist/socials-DsoFf1B8.js.map +0 -1
- package/dist/swapHorizontal-BQOjfwRW.js +0 -13
- package/dist/swapHorizontal-BQOjfwRW.js.map +0 -1
- package/dist/swapHorizontalBold-DMKR9Zys.js +0 -13
- package/dist/swapHorizontalBold-DMKR9Zys.js.map +0 -1
- package/dist/swapHorizontalMedium-DVsqt18q.js +0 -21
- package/dist/swapHorizontalMedium-DVsqt18q.js.map +0 -1
- package/dist/swapHorizontalRoundedBold-CM5U-o8X.js +0 -13
- package/dist/swapHorizontalRoundedBold-CM5U-o8X.js.map +0 -1
- package/dist/swapVertical-P9UnfCR-.js +0 -13
- package/dist/swapVertical-P9UnfCR-.js.map +0 -1
- package/dist/swaps-F0roy6mK.js +0 -2121
- package/dist/swaps-F0roy6mK.js.map +0 -1
- package/dist/telegram-Bd4DGbnk.js +0 -21
- package/dist/telegram-Bd4DGbnk.js.map +0 -1
- package/dist/three-dots-M94oc7-3.js +0 -10
- package/dist/three-dots-M94oc7-3.js.map +0 -1
- package/dist/transactions-DwtZvXx1.js +0 -38
- package/dist/transactions-DwtZvXx1.js.map +0 -1
- package/dist/twitch--lJ-X_Y6.js +0 -23
- package/dist/twitch--lJ-X_Y6.js.map +0 -1
- package/dist/twitterIcon-DDp_lnzc.js +0 -11
- package/dist/twitterIcon-DDp_lnzc.js.map +0 -1
- package/dist/vanilla-CgG5xMJO.js +0 -448
- package/dist/vanilla-CgG5xMJO.js.map +0 -1
- package/dist/verify-Doojt-tK.js +0 -13
- package/dist/verify-Doojt-tK.js.map +0 -1
- package/dist/verify-filled-EHdbo2B7.js +0 -13
- package/dist/verify-filled-EHdbo2B7.js.map +0 -1
- package/dist/w3m-modal-CVsid-gN.js +0 -1725
- package/dist/w3m-modal-CVsid-gN.js.map +0 -1
- package/dist/w3m-modal-CZ4s4A2R.js +0 -2008
- package/dist/w3m-modal-CZ4s4A2R.js.map +0 -1
- package/dist/wallet-CowxEORz.js +0 -13
- package/dist/wallet-CowxEORz.js.map +0 -1
- package/dist/wallet-placeholder-B7p7Oae2.js +0 -19
- package/dist/wallet-placeholder-B7p7Oae2.js.map +0 -1
- package/dist/wallet-standard-BUMbKbZo.js +0 -523
- package/dist/wallet-standard-BUMbKbZo.js.map +0 -1
- package/dist/walletconnect-CKMr88Pk.js +0 -39
- package/dist/walletconnect-CKMr88Pk.js.map +0 -1
- package/dist/warning-circle-CjIPgJnm.js +0 -17
- package/dist/warning-circle-CjIPgJnm.js.map +0 -1
- package/dist/x-CaxhfhgU.js +0 -17
- package/dist/x-CaxhfhgU.js.map +0 -1
|
@@ -1,4690 +0,0 @@
|
|
|
1
|
-
import { T as BaseError, ae as getAbiItem, cJ as AbiEventNotFoundError, ab as formatAbiItem, cK as toEventSelector, aF as keccak256$1, cL as toBytes, a0 as encodeAbiParameters, cM as createFilterRequestScope, K as numberToHex, b4 as encodeFunctionData, cN as getAction, cO as estimateGas, cP as parseAccount, cQ as getContractError, cR as formatLog, cS as parseEventLogs, cT as assertSize$1, cU as padRight$1, cV as BaseError$1, cW as fromBytes$2, cX as toNumber$1, cY as toBigInt$1, cZ as stringify, _ as call, c_ as decodeFunctionResult, X as stringify$1, c$ as observe, d0 as poll, d1 as getFilterChanges, d2 as getBlockNumber, d3 as InvalidInputRpcError, d4 as uninstallFilter, d5 as decodeEventLog, d6 as DecodeLogDataMismatch, d7 as DecodeLogTopicsMismatch, $ as concat, d8 as UnsupportedNonOptionalCapabilityError, d9 as AtomicityNotSupportedError, da as sendTransaction, db as hexToBigInt, dc as getTransactionError, dd as hexToNumber, de as receiptStatuses, df as trim$1, dg as sliceHex, dh as withResolvers, di as withRetry, dj as ContractFunctionRevertedError, a2 as isHex, aD as bytesToHex, dk as stringToBytes, dl as getChainContractAddress, dm as addressResolverAbi, aL as toHex$1, dn as universalResolverResolveAbi, dp as readContract, dq as textResolverAbi, dr as universalResolverReverseAbi, ds as assertRequest, dt as formatTransactionRequest, du as extract$1, dv as getCallError, dw as AbiEncodingLengthMismatchError, ah as concatHex, aH as isAddress, aI as InvalidAddressError$1, dx as pad$1, aC as stringToHex, dy as boolToHex, aG as integerRegex$1, aJ as bytesRegex$1, aK as BytesSizeMismatchError$1, dz as arrayRegex$1, dA as UnsupportedPackedAbiType, Z as isAddressEqual, dB as recoverAuthorizationAddress, H as getAddress, dC as LruMap$1, dD as getTransactionCount, L as withTimeout, dE as TimeoutError, a1 as HttpRequestError, dF as keccak_256, dG as concat$1, dH as fromNumber, dI as validate$4, dJ as slice$1, dK as size$1, dL as from$a, dM as padLeft, dN as fromBoolean, dO as IntegerOutOfRangeError, dP as fromString$1, dQ as trimLeft$1, dR as secp256k1, dS as hexToBytes, dT as getTransaction, dU as toRpc, dV as serializeStateOverride, dW as formatBlock, dX as AbiDecodingZeroDataError, dY as RawContractError, dZ as getNodeError, d_ as UnknownNodeError, d$ as deploylessCallViaBytecodeBytecode, e0 as recoverAddress$1, e1 as multicall3Abi, e2 as multicall3Bytecode, e3 as erc1271Abi, e4 as erc6492SignatureValidatorAbi, e5 as encodeDeployData, e6 as erc6492SignatureValidatorByteCode, e7 as CallExecutionError, e8 as hexToBool, e9 as ContractFunctionExecutionError, ea as getBlock, eb as watchPendingTransactions, ec as watchBlockNumber, ed as waitForTransactionReceipt, ee as sendRawTransaction, ef as prepareTransactionRequest, eg as multicall, eh as getTransactionReceipt, ei as estimateMaxPriorityFeePerGas, ej as getGasPrice, ek as estimateFeesPerGas, el as getChainId, em as getBalance, en as createPendingTransactionFilter, eo as createClient, ep as AccountNotFoundError, eq as createTransport, er as createBatchScheduler, es as RpcRequestError } from "./appkit-DY7XpK4K.js";
|
|
2
|
-
import { l as localBatchGatewayUrl } from "./localBatchGatewayRequest-Dryp85EG.js";
|
|
3
|
-
import { p as parseAbiParameters, f as formatAbiParameters, a as parseAbiItem, b as formatAbiItem$1 } from "./parseAbiParameters-DfJcIE_w.js";
|
|
4
|
-
import { h as hashMessage, a as hashTypedData } from "./hashTypedData-Q6QDIxse.js";
|
|
5
|
-
class FilterTypeNotSupportedError extends BaseError {
|
|
6
|
-
constructor(type) {
|
|
7
|
-
super(`Filter type "${type}" is not supported.`, {
|
|
8
|
-
name: "FilterTypeNotSupportedError"
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
const docsPath = "/docs/contract/encodeEventTopics";
|
|
13
|
-
function encodeEventTopics(parameters) {
|
|
14
|
-
var _a;
|
|
15
|
-
const { abi: abi2, eventName, args } = parameters;
|
|
16
|
-
let abiItem = abi2[0];
|
|
17
|
-
if (eventName) {
|
|
18
|
-
const item = getAbiItem({ abi: abi2, name: eventName });
|
|
19
|
-
if (!item)
|
|
20
|
-
throw new AbiEventNotFoundError(eventName, { docsPath });
|
|
21
|
-
abiItem = item;
|
|
22
|
-
}
|
|
23
|
-
if (abiItem.type !== "event")
|
|
24
|
-
throw new AbiEventNotFoundError(void 0, { docsPath });
|
|
25
|
-
const definition = formatAbiItem(abiItem);
|
|
26
|
-
const signature = toEventSelector(definition);
|
|
27
|
-
let topics = [];
|
|
28
|
-
if (args && "inputs" in abiItem) {
|
|
29
|
-
const indexedInputs = (_a = abiItem.inputs) == null ? void 0 : _a.filter((param) => "indexed" in param && param.indexed);
|
|
30
|
-
const args_ = Array.isArray(args) ? args : Object.values(args).length > 0 ? (indexedInputs == null ? void 0 : indexedInputs.map((x) => args[x.name])) ?? [] : [];
|
|
31
|
-
if (args_.length > 0) {
|
|
32
|
-
topics = (indexedInputs == null ? void 0 : indexedInputs.map((param, i) => {
|
|
33
|
-
if (Array.isArray(args_[i]))
|
|
34
|
-
return args_[i].map((_, j) => encodeArg({ param, value: args_[i][j] }));
|
|
35
|
-
return typeof args_[i] !== "undefined" && args_[i] !== null ? encodeArg({ param, value: args_[i] }) : null;
|
|
36
|
-
})) ?? [];
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return [signature, ...topics];
|
|
40
|
-
}
|
|
41
|
-
function encodeArg({ param, value }) {
|
|
42
|
-
if (param.type === "string" || param.type === "bytes")
|
|
43
|
-
return keccak256$1(toBytes(value));
|
|
44
|
-
if (param.type === "tuple" || param.type.match(/^(.*)\[(\d+)?\]$/))
|
|
45
|
-
throw new FilterTypeNotSupportedError(param.type);
|
|
46
|
-
return encodeAbiParameters([param], [value]);
|
|
47
|
-
}
|
|
48
|
-
async function createContractEventFilter(client, parameters) {
|
|
49
|
-
const { address, abi: abi2, args, eventName, fromBlock, strict, toBlock } = parameters;
|
|
50
|
-
const getRequest = createFilterRequestScope(client, {
|
|
51
|
-
method: "eth_newFilter"
|
|
52
|
-
});
|
|
53
|
-
const topics = eventName ? encodeEventTopics({
|
|
54
|
-
abi: abi2,
|
|
55
|
-
args,
|
|
56
|
-
eventName
|
|
57
|
-
}) : void 0;
|
|
58
|
-
const id = await client.request({
|
|
59
|
-
method: "eth_newFilter",
|
|
60
|
-
params: [
|
|
61
|
-
{
|
|
62
|
-
address,
|
|
63
|
-
fromBlock: typeof fromBlock === "bigint" ? numberToHex(fromBlock) : fromBlock,
|
|
64
|
-
toBlock: typeof toBlock === "bigint" ? numberToHex(toBlock) : toBlock,
|
|
65
|
-
topics
|
|
66
|
-
}
|
|
67
|
-
]
|
|
68
|
-
});
|
|
69
|
-
return {
|
|
70
|
-
abi: abi2,
|
|
71
|
-
args,
|
|
72
|
-
eventName,
|
|
73
|
-
id,
|
|
74
|
-
request: getRequest(id),
|
|
75
|
-
strict: Boolean(strict),
|
|
76
|
-
type: "event"
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
async function estimateContractGas(client, parameters) {
|
|
80
|
-
const { abi: abi2, address, args, functionName, dataSuffix, ...request } = parameters;
|
|
81
|
-
const data = encodeFunctionData({
|
|
82
|
-
abi: abi2,
|
|
83
|
-
args,
|
|
84
|
-
functionName
|
|
85
|
-
});
|
|
86
|
-
try {
|
|
87
|
-
const gas = await getAction(client, estimateGas, "estimateGas")({
|
|
88
|
-
data: `${data}${dataSuffix ? dataSuffix.replace("0x", "") : ""}`,
|
|
89
|
-
to: address,
|
|
90
|
-
...request
|
|
91
|
-
});
|
|
92
|
-
return gas;
|
|
93
|
-
} catch (error) {
|
|
94
|
-
const account = request.account ? parseAccount(request.account) : void 0;
|
|
95
|
-
throw getContractError(error, {
|
|
96
|
-
abi: abi2,
|
|
97
|
-
address,
|
|
98
|
-
args,
|
|
99
|
-
docsPath: "/docs/contract/estimateContractGas",
|
|
100
|
-
functionName,
|
|
101
|
-
sender: account == null ? void 0 : account.address
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
async function getLogs(client, { address, blockHash, fromBlock, toBlock, event, events: events_, args, strict: strict_ } = {}) {
|
|
106
|
-
const strict = strict_ ?? false;
|
|
107
|
-
const events = events_ ?? (event ? [event] : void 0);
|
|
108
|
-
let topics = [];
|
|
109
|
-
if (events) {
|
|
110
|
-
const encoded = events.flatMap((event2) => encodeEventTopics({
|
|
111
|
-
abi: [event2],
|
|
112
|
-
eventName: event2.name,
|
|
113
|
-
args: events_ ? void 0 : args
|
|
114
|
-
}));
|
|
115
|
-
topics = [encoded];
|
|
116
|
-
if (event)
|
|
117
|
-
topics = topics[0];
|
|
118
|
-
}
|
|
119
|
-
let logs;
|
|
120
|
-
if (blockHash) {
|
|
121
|
-
logs = await client.request({
|
|
122
|
-
method: "eth_getLogs",
|
|
123
|
-
params: [{ address, topics, blockHash }]
|
|
124
|
-
});
|
|
125
|
-
} else {
|
|
126
|
-
logs = await client.request({
|
|
127
|
-
method: "eth_getLogs",
|
|
128
|
-
params: [
|
|
129
|
-
{
|
|
130
|
-
address,
|
|
131
|
-
topics,
|
|
132
|
-
fromBlock: typeof fromBlock === "bigint" ? numberToHex(fromBlock) : fromBlock,
|
|
133
|
-
toBlock: typeof toBlock === "bigint" ? numberToHex(toBlock) : toBlock
|
|
134
|
-
}
|
|
135
|
-
]
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
const formattedLogs = logs.map((log) => formatLog(log));
|
|
139
|
-
if (!events)
|
|
140
|
-
return formattedLogs;
|
|
141
|
-
return parseEventLogs({
|
|
142
|
-
abi: events,
|
|
143
|
-
args,
|
|
144
|
-
logs: formattedLogs,
|
|
145
|
-
strict
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
async function getContractEvents(client, parameters) {
|
|
149
|
-
const { abi: abi2, address, args, blockHash, eventName, fromBlock, toBlock, strict } = parameters;
|
|
150
|
-
const event = eventName ? getAbiItem({ abi: abi2, name: eventName }) : void 0;
|
|
151
|
-
const events = !event ? abi2.filter((x) => x.type === "event") : void 0;
|
|
152
|
-
return getAction(client, getLogs, "getLogs")({
|
|
153
|
-
address,
|
|
154
|
-
args,
|
|
155
|
-
blockHash,
|
|
156
|
-
event,
|
|
157
|
-
events,
|
|
158
|
-
fromBlock,
|
|
159
|
-
toBlock,
|
|
160
|
-
strict
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
function assertSize(bytes, size_) {
|
|
164
|
-
if (size(bytes) > size_)
|
|
165
|
-
throw new SizeOverflowError({
|
|
166
|
-
givenSize: size(bytes),
|
|
167
|
-
maxSize: size_
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
const charCodeMap = {
|
|
171
|
-
zero: 48,
|
|
172
|
-
nine: 57,
|
|
173
|
-
A: 65,
|
|
174
|
-
F: 70,
|
|
175
|
-
a: 97,
|
|
176
|
-
f: 102
|
|
177
|
-
};
|
|
178
|
-
function charCodeToBase16(char) {
|
|
179
|
-
if (char >= charCodeMap.zero && char <= charCodeMap.nine)
|
|
180
|
-
return char - charCodeMap.zero;
|
|
181
|
-
if (char >= charCodeMap.A && char <= charCodeMap.F)
|
|
182
|
-
return char - (charCodeMap.A - 10);
|
|
183
|
-
if (char >= charCodeMap.a && char <= charCodeMap.f)
|
|
184
|
-
return char - (charCodeMap.a - 10);
|
|
185
|
-
return void 0;
|
|
186
|
-
}
|
|
187
|
-
function pad(bytes, options = {}) {
|
|
188
|
-
const { dir, size: size2 = 32 } = options;
|
|
189
|
-
if (size2 === 0)
|
|
190
|
-
return bytes;
|
|
191
|
-
if (bytes.length > size2)
|
|
192
|
-
throw new SizeExceedsPaddingSizeError({
|
|
193
|
-
size: bytes.length,
|
|
194
|
-
targetSize: size2,
|
|
195
|
-
type: "Bytes"
|
|
196
|
-
});
|
|
197
|
-
const paddedBytes = new Uint8Array(size2);
|
|
198
|
-
for (let i = 0; i < size2; i++) {
|
|
199
|
-
const padEnd = dir === "right";
|
|
200
|
-
paddedBytes[padEnd ? i : size2 - i - 1] = bytes[padEnd ? i : bytes.length - i - 1];
|
|
201
|
-
}
|
|
202
|
-
return paddedBytes;
|
|
203
|
-
}
|
|
204
|
-
function trim(value, options = {}) {
|
|
205
|
-
const { dir = "left" } = options;
|
|
206
|
-
let data = value;
|
|
207
|
-
let sliceLength = 0;
|
|
208
|
-
for (let i = 0; i < data.length - 1; i++) {
|
|
209
|
-
if (data[dir === "left" ? i : data.length - i - 1].toString() === "0")
|
|
210
|
-
sliceLength++;
|
|
211
|
-
else
|
|
212
|
-
break;
|
|
213
|
-
}
|
|
214
|
-
data = dir === "left" ? data.slice(sliceLength) : data.slice(0, data.length - sliceLength);
|
|
215
|
-
return data;
|
|
216
|
-
}
|
|
217
|
-
const decoder = /* @__PURE__ */ new TextDecoder();
|
|
218
|
-
const encoder = /* @__PURE__ */ new TextEncoder();
|
|
219
|
-
function assert$5(value) {
|
|
220
|
-
if (value instanceof Uint8Array)
|
|
221
|
-
return;
|
|
222
|
-
if (!value)
|
|
223
|
-
throw new InvalidBytesTypeError(value);
|
|
224
|
-
if (typeof value !== "object")
|
|
225
|
-
throw new InvalidBytesTypeError(value);
|
|
226
|
-
if (!("BYTES_PER_ELEMENT" in value))
|
|
227
|
-
throw new InvalidBytesTypeError(value);
|
|
228
|
-
if (value.BYTES_PER_ELEMENT !== 1 || value.constructor.name !== "Uint8Array")
|
|
229
|
-
throw new InvalidBytesTypeError(value);
|
|
230
|
-
}
|
|
231
|
-
function from$9(value) {
|
|
232
|
-
if (value instanceof Uint8Array)
|
|
233
|
-
return value;
|
|
234
|
-
if (typeof value === "string")
|
|
235
|
-
return fromHex$3(value);
|
|
236
|
-
return fromArray(value);
|
|
237
|
-
}
|
|
238
|
-
function fromArray(value) {
|
|
239
|
-
return value instanceof Uint8Array ? value : new Uint8Array(value);
|
|
240
|
-
}
|
|
241
|
-
function fromHex$3(value, options = {}) {
|
|
242
|
-
const { size: size2 } = options;
|
|
243
|
-
let hex = value;
|
|
244
|
-
if (size2) {
|
|
245
|
-
assertSize$1(value, size2);
|
|
246
|
-
hex = padRight$1(value, size2);
|
|
247
|
-
}
|
|
248
|
-
let hexString = hex.slice(2);
|
|
249
|
-
if (hexString.length % 2)
|
|
250
|
-
hexString = `0${hexString}`;
|
|
251
|
-
const length = hexString.length / 2;
|
|
252
|
-
const bytes = new Uint8Array(length);
|
|
253
|
-
for (let index = 0, j = 0; index < length; index++) {
|
|
254
|
-
const nibbleLeft = charCodeToBase16(hexString.charCodeAt(j++));
|
|
255
|
-
const nibbleRight = charCodeToBase16(hexString.charCodeAt(j++));
|
|
256
|
-
if (nibbleLeft === void 0 || nibbleRight === void 0) {
|
|
257
|
-
throw new BaseError$1(`Invalid byte sequence ("${hexString[j - 2]}${hexString[j - 1]}" in "${hexString}").`);
|
|
258
|
-
}
|
|
259
|
-
bytes[index] = nibbleLeft * 16 + nibbleRight;
|
|
260
|
-
}
|
|
261
|
-
return bytes;
|
|
262
|
-
}
|
|
263
|
-
function fromString(value, options = {}) {
|
|
264
|
-
const { size: size2 } = options;
|
|
265
|
-
const bytes = encoder.encode(value);
|
|
266
|
-
if (typeof size2 === "number") {
|
|
267
|
-
assertSize(bytes, size2);
|
|
268
|
-
return padRight(bytes, size2);
|
|
269
|
-
}
|
|
270
|
-
return bytes;
|
|
271
|
-
}
|
|
272
|
-
function padRight(value, size2) {
|
|
273
|
-
return pad(value, { dir: "right", size: size2 });
|
|
274
|
-
}
|
|
275
|
-
function size(value) {
|
|
276
|
-
return value.length;
|
|
277
|
-
}
|
|
278
|
-
function slice(value, start, end, options = {}) {
|
|
279
|
-
const { strict } = options;
|
|
280
|
-
const value_ = value.slice(start, end);
|
|
281
|
-
return value_;
|
|
282
|
-
}
|
|
283
|
-
function toBigInt(bytes, options = {}) {
|
|
284
|
-
const { size: size2 } = options;
|
|
285
|
-
if (typeof size2 !== "undefined")
|
|
286
|
-
assertSize(bytes, size2);
|
|
287
|
-
const hex = fromBytes$2(bytes, options);
|
|
288
|
-
return toBigInt$1(hex, options);
|
|
289
|
-
}
|
|
290
|
-
function toBoolean(bytes, options = {}) {
|
|
291
|
-
const { size: size2 } = options;
|
|
292
|
-
let bytes_ = bytes;
|
|
293
|
-
if (typeof size2 !== "undefined") {
|
|
294
|
-
assertSize(bytes_, size2);
|
|
295
|
-
bytes_ = trimLeft(bytes_);
|
|
296
|
-
}
|
|
297
|
-
if (bytes_.length > 1 || bytes_[0] > 1)
|
|
298
|
-
throw new InvalidBytesBooleanError(bytes_);
|
|
299
|
-
return Boolean(bytes_[0]);
|
|
300
|
-
}
|
|
301
|
-
function toNumber(bytes, options = {}) {
|
|
302
|
-
const { size: size2 } = options;
|
|
303
|
-
if (typeof size2 !== "undefined")
|
|
304
|
-
assertSize(bytes, size2);
|
|
305
|
-
const hex = fromBytes$2(bytes, options);
|
|
306
|
-
return toNumber$1(hex, options);
|
|
307
|
-
}
|
|
308
|
-
function toString(bytes, options = {}) {
|
|
309
|
-
const { size: size2 } = options;
|
|
310
|
-
let bytes_ = bytes;
|
|
311
|
-
if (typeof size2 !== "undefined") {
|
|
312
|
-
assertSize(bytes_, size2);
|
|
313
|
-
bytes_ = trimRight(bytes_);
|
|
314
|
-
}
|
|
315
|
-
return decoder.decode(bytes_);
|
|
316
|
-
}
|
|
317
|
-
function trimLeft(value) {
|
|
318
|
-
return trim(value, { dir: "left" });
|
|
319
|
-
}
|
|
320
|
-
function trimRight(value) {
|
|
321
|
-
return trim(value, { dir: "right" });
|
|
322
|
-
}
|
|
323
|
-
function validate$3(value) {
|
|
324
|
-
try {
|
|
325
|
-
assert$5(value);
|
|
326
|
-
return true;
|
|
327
|
-
} catch {
|
|
328
|
-
return false;
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
class InvalidBytesBooleanError extends BaseError$1 {
|
|
332
|
-
constructor(bytes) {
|
|
333
|
-
super(`Bytes value \`${bytes}\` is not a valid boolean.`, {
|
|
334
|
-
metaMessages: [
|
|
335
|
-
"The bytes array must contain a single byte of either a `0` or `1` value."
|
|
336
|
-
]
|
|
337
|
-
});
|
|
338
|
-
Object.defineProperty(this, "name", {
|
|
339
|
-
enumerable: true,
|
|
340
|
-
configurable: true,
|
|
341
|
-
writable: true,
|
|
342
|
-
value: "Bytes.InvalidBytesBooleanError"
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
class InvalidBytesTypeError extends BaseError$1 {
|
|
347
|
-
constructor(value) {
|
|
348
|
-
super(`Value \`${typeof value === "object" ? stringify(value) : value}\` of type \`${typeof value}\` is an invalid Bytes value.`, {
|
|
349
|
-
metaMessages: ["Bytes values must be of type `Bytes`."]
|
|
350
|
-
});
|
|
351
|
-
Object.defineProperty(this, "name", {
|
|
352
|
-
enumerable: true,
|
|
353
|
-
configurable: true,
|
|
354
|
-
writable: true,
|
|
355
|
-
value: "Bytes.InvalidBytesTypeError"
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
class SizeOverflowError extends BaseError$1 {
|
|
360
|
-
constructor({ givenSize, maxSize }) {
|
|
361
|
-
super(`Size cannot exceed \`${maxSize}\` bytes. Given size: \`${givenSize}\` bytes.`);
|
|
362
|
-
Object.defineProperty(this, "name", {
|
|
363
|
-
enumerable: true,
|
|
364
|
-
configurable: true,
|
|
365
|
-
writable: true,
|
|
366
|
-
value: "Bytes.SizeOverflowError"
|
|
367
|
-
});
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
class SizeExceedsPaddingSizeError extends BaseError$1 {
|
|
371
|
-
constructor({ size: size2, targetSize, type }) {
|
|
372
|
-
super(`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} size (\`${size2}\`) exceeds padding size (\`${targetSize}\`).`);
|
|
373
|
-
Object.defineProperty(this, "name", {
|
|
374
|
-
enumerable: true,
|
|
375
|
-
configurable: true,
|
|
376
|
-
writable: true,
|
|
377
|
-
value: "Bytes.SizeExceedsPaddingSizeError"
|
|
378
|
-
});
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
async function simulateContract(client, parameters) {
|
|
382
|
-
const { abi: abi2, address, args, dataSuffix, functionName, ...callRequest } = parameters;
|
|
383
|
-
const account = callRequest.account ? parseAccount(callRequest.account) : client.account;
|
|
384
|
-
const calldata = encodeFunctionData({ abi: abi2, args, functionName });
|
|
385
|
-
try {
|
|
386
|
-
const { data } = await getAction(client, call, "call")({
|
|
387
|
-
batch: false,
|
|
388
|
-
data: `${calldata}${dataSuffix ? dataSuffix.replace("0x", "") : ""}`,
|
|
389
|
-
to: address,
|
|
390
|
-
...callRequest,
|
|
391
|
-
account
|
|
392
|
-
});
|
|
393
|
-
const result = decodeFunctionResult({
|
|
394
|
-
abi: abi2,
|
|
395
|
-
args,
|
|
396
|
-
functionName,
|
|
397
|
-
data: data || "0x"
|
|
398
|
-
});
|
|
399
|
-
const minimizedAbi = abi2.filter((abiItem) => "name" in abiItem && abiItem.name === parameters.functionName);
|
|
400
|
-
return {
|
|
401
|
-
result,
|
|
402
|
-
request: {
|
|
403
|
-
abi: minimizedAbi,
|
|
404
|
-
address,
|
|
405
|
-
args,
|
|
406
|
-
dataSuffix,
|
|
407
|
-
functionName,
|
|
408
|
-
...callRequest,
|
|
409
|
-
account
|
|
410
|
-
}
|
|
411
|
-
};
|
|
412
|
-
} catch (error) {
|
|
413
|
-
throw getContractError(error, {
|
|
414
|
-
abi: abi2,
|
|
415
|
-
address,
|
|
416
|
-
args,
|
|
417
|
-
docsPath: "/docs/contract/simulateContract",
|
|
418
|
-
functionName,
|
|
419
|
-
sender: account == null ? void 0 : account.address
|
|
420
|
-
});
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
function watchContractEvent(client, parameters) {
|
|
424
|
-
const { abi: abi2, address, args, batch = true, eventName, fromBlock, onError, onLogs, poll: poll_, pollingInterval = client.pollingInterval, strict: strict_ } = parameters;
|
|
425
|
-
const enablePolling = (() => {
|
|
426
|
-
if (typeof poll_ !== "undefined")
|
|
427
|
-
return poll_;
|
|
428
|
-
if (typeof fromBlock === "bigint")
|
|
429
|
-
return true;
|
|
430
|
-
if (client.transport.type === "webSocket" || client.transport.type === "ipc")
|
|
431
|
-
return false;
|
|
432
|
-
if (client.transport.type === "fallback" && (client.transport.transports[0].config.type === "webSocket" || client.transport.transports[0].config.type === "ipc"))
|
|
433
|
-
return false;
|
|
434
|
-
return true;
|
|
435
|
-
})();
|
|
436
|
-
const pollContractEvent = () => {
|
|
437
|
-
const strict = strict_ ?? false;
|
|
438
|
-
const observerId = stringify$1([
|
|
439
|
-
"watchContractEvent",
|
|
440
|
-
address,
|
|
441
|
-
args,
|
|
442
|
-
batch,
|
|
443
|
-
client.uid,
|
|
444
|
-
eventName,
|
|
445
|
-
pollingInterval,
|
|
446
|
-
strict,
|
|
447
|
-
fromBlock
|
|
448
|
-
]);
|
|
449
|
-
return observe(observerId, { onLogs, onError }, (emit) => {
|
|
450
|
-
let previousBlockNumber;
|
|
451
|
-
if (fromBlock !== void 0)
|
|
452
|
-
previousBlockNumber = fromBlock - 1n;
|
|
453
|
-
let filter;
|
|
454
|
-
let initialized = false;
|
|
455
|
-
const unwatch = poll(async () => {
|
|
456
|
-
var _a;
|
|
457
|
-
if (!initialized) {
|
|
458
|
-
try {
|
|
459
|
-
filter = await getAction(client, createContractEventFilter, "createContractEventFilter")({
|
|
460
|
-
abi: abi2,
|
|
461
|
-
address,
|
|
462
|
-
args,
|
|
463
|
-
eventName,
|
|
464
|
-
strict,
|
|
465
|
-
fromBlock
|
|
466
|
-
});
|
|
467
|
-
} catch {
|
|
468
|
-
}
|
|
469
|
-
initialized = true;
|
|
470
|
-
return;
|
|
471
|
-
}
|
|
472
|
-
try {
|
|
473
|
-
let logs;
|
|
474
|
-
if (filter) {
|
|
475
|
-
logs = await getAction(client, getFilterChanges, "getFilterChanges")({ filter });
|
|
476
|
-
} else {
|
|
477
|
-
const blockNumber = await getAction(client, getBlockNumber, "getBlockNumber")({});
|
|
478
|
-
if (previousBlockNumber && previousBlockNumber < blockNumber) {
|
|
479
|
-
logs = await getAction(client, getContractEvents, "getContractEvents")({
|
|
480
|
-
abi: abi2,
|
|
481
|
-
address,
|
|
482
|
-
args,
|
|
483
|
-
eventName,
|
|
484
|
-
fromBlock: previousBlockNumber + 1n,
|
|
485
|
-
toBlock: blockNumber,
|
|
486
|
-
strict
|
|
487
|
-
});
|
|
488
|
-
} else {
|
|
489
|
-
logs = [];
|
|
490
|
-
}
|
|
491
|
-
previousBlockNumber = blockNumber;
|
|
492
|
-
}
|
|
493
|
-
if (logs.length === 0)
|
|
494
|
-
return;
|
|
495
|
-
if (batch)
|
|
496
|
-
emit.onLogs(logs);
|
|
497
|
-
else
|
|
498
|
-
for (const log of logs)
|
|
499
|
-
emit.onLogs([log]);
|
|
500
|
-
} catch (err) {
|
|
501
|
-
if (filter && err instanceof InvalidInputRpcError)
|
|
502
|
-
initialized = false;
|
|
503
|
-
(_a = emit.onError) == null ? void 0 : _a.call(emit, err);
|
|
504
|
-
}
|
|
505
|
-
}, {
|
|
506
|
-
emitOnBegin: true,
|
|
507
|
-
interval: pollingInterval
|
|
508
|
-
});
|
|
509
|
-
return async () => {
|
|
510
|
-
if (filter)
|
|
511
|
-
await getAction(client, uninstallFilter, "uninstallFilter")({ filter });
|
|
512
|
-
unwatch();
|
|
513
|
-
};
|
|
514
|
-
});
|
|
515
|
-
};
|
|
516
|
-
const subscribeContractEvent = () => {
|
|
517
|
-
const strict = strict_ ?? false;
|
|
518
|
-
const observerId = stringify$1([
|
|
519
|
-
"watchContractEvent",
|
|
520
|
-
address,
|
|
521
|
-
args,
|
|
522
|
-
batch,
|
|
523
|
-
client.uid,
|
|
524
|
-
eventName,
|
|
525
|
-
pollingInterval,
|
|
526
|
-
strict
|
|
527
|
-
]);
|
|
528
|
-
let active = true;
|
|
529
|
-
let unsubscribe = () => active = false;
|
|
530
|
-
return observe(observerId, { onLogs, onError }, (emit) => {
|
|
531
|
-
(async () => {
|
|
532
|
-
try {
|
|
533
|
-
const transport = (() => {
|
|
534
|
-
if (client.transport.type === "fallback") {
|
|
535
|
-
const transport2 = client.transport.transports.find((transport3) => transport3.config.type === "webSocket" || transport3.config.type === "ipc");
|
|
536
|
-
if (!transport2)
|
|
537
|
-
return client.transport;
|
|
538
|
-
return transport2.value;
|
|
539
|
-
}
|
|
540
|
-
return client.transport;
|
|
541
|
-
})();
|
|
542
|
-
const topics = eventName ? encodeEventTopics({
|
|
543
|
-
abi: abi2,
|
|
544
|
-
eventName,
|
|
545
|
-
args
|
|
546
|
-
}) : [];
|
|
547
|
-
const { unsubscribe: unsubscribe_ } = await transport.subscribe({
|
|
548
|
-
params: ["logs", { address, topics }],
|
|
549
|
-
onData(data) {
|
|
550
|
-
var _a;
|
|
551
|
-
if (!active)
|
|
552
|
-
return;
|
|
553
|
-
const log = data.result;
|
|
554
|
-
try {
|
|
555
|
-
const { eventName: eventName2, args: args2 } = decodeEventLog({
|
|
556
|
-
abi: abi2,
|
|
557
|
-
data: log.data,
|
|
558
|
-
topics: log.topics,
|
|
559
|
-
strict: strict_
|
|
560
|
-
});
|
|
561
|
-
const formatted = formatLog(log, {
|
|
562
|
-
args: args2,
|
|
563
|
-
eventName: eventName2
|
|
564
|
-
});
|
|
565
|
-
emit.onLogs([formatted]);
|
|
566
|
-
} catch (err) {
|
|
567
|
-
let eventName2;
|
|
568
|
-
let isUnnamed;
|
|
569
|
-
if (err instanceof DecodeLogDataMismatch || err instanceof DecodeLogTopicsMismatch) {
|
|
570
|
-
if (strict_)
|
|
571
|
-
return;
|
|
572
|
-
eventName2 = err.abiItem.name;
|
|
573
|
-
isUnnamed = (_a = err.abiItem.inputs) == null ? void 0 : _a.some((x) => !("name" in x && x.name));
|
|
574
|
-
}
|
|
575
|
-
const formatted = formatLog(log, {
|
|
576
|
-
args: isUnnamed ? [] : {},
|
|
577
|
-
eventName: eventName2
|
|
578
|
-
});
|
|
579
|
-
emit.onLogs([formatted]);
|
|
580
|
-
}
|
|
581
|
-
},
|
|
582
|
-
onError(error) {
|
|
583
|
-
var _a;
|
|
584
|
-
(_a = emit.onError) == null ? void 0 : _a.call(emit, error);
|
|
585
|
-
}
|
|
586
|
-
});
|
|
587
|
-
unsubscribe = unsubscribe_;
|
|
588
|
-
if (!active)
|
|
589
|
-
unsubscribe();
|
|
590
|
-
} catch (err) {
|
|
591
|
-
onError == null ? void 0 : onError(err);
|
|
592
|
-
}
|
|
593
|
-
})();
|
|
594
|
-
return () => unsubscribe();
|
|
595
|
-
});
|
|
596
|
-
};
|
|
597
|
-
return enablePolling ? pollContractEvent() : subscribeContractEvent();
|
|
598
|
-
}
|
|
599
|
-
class BundleFailedError extends BaseError {
|
|
600
|
-
constructor(result) {
|
|
601
|
-
super(`Call bundle failed with status: ${result.statusCode}`, {
|
|
602
|
-
name: "BundleFailedError"
|
|
603
|
-
});
|
|
604
|
-
Object.defineProperty(this, "result", {
|
|
605
|
-
enumerable: true,
|
|
606
|
-
configurable: true,
|
|
607
|
-
writable: true,
|
|
608
|
-
value: void 0
|
|
609
|
-
});
|
|
610
|
-
this.result = result;
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
const fallbackMagicIdentifier = "0x5792579257925792579257925792579257925792579257925792579257925792";
|
|
614
|
-
const fallbackTransactionErrorMagicIdentifier = numberToHex(0, {
|
|
615
|
-
size: 32
|
|
616
|
-
});
|
|
617
|
-
async function sendCalls(client, parameters) {
|
|
618
|
-
const { account: account_ = client.account, capabilities, chain = client.chain, experimental_fallback, experimental_fallbackDelay = 32, forceAtomic = false, id, version = "2.0.0" } = parameters;
|
|
619
|
-
const account = account_ ? parseAccount(account_) : null;
|
|
620
|
-
const calls = parameters.calls.map((call_) => {
|
|
621
|
-
const call2 = call_;
|
|
622
|
-
const data = call2.abi ? encodeFunctionData({
|
|
623
|
-
abi: call2.abi,
|
|
624
|
-
functionName: call2.functionName,
|
|
625
|
-
args: call2.args
|
|
626
|
-
}) : call2.data;
|
|
627
|
-
return {
|
|
628
|
-
data: call2.dataSuffix && data ? concat([data, call2.dataSuffix]) : data,
|
|
629
|
-
to: call2.to,
|
|
630
|
-
value: call2.value ? numberToHex(call2.value) : void 0
|
|
631
|
-
};
|
|
632
|
-
});
|
|
633
|
-
try {
|
|
634
|
-
const response = await client.request({
|
|
635
|
-
method: "wallet_sendCalls",
|
|
636
|
-
params: [
|
|
637
|
-
{
|
|
638
|
-
atomicRequired: forceAtomic,
|
|
639
|
-
calls,
|
|
640
|
-
capabilities,
|
|
641
|
-
chainId: numberToHex(chain.id),
|
|
642
|
-
from: account == null ? void 0 : account.address,
|
|
643
|
-
id,
|
|
644
|
-
version
|
|
645
|
-
}
|
|
646
|
-
]
|
|
647
|
-
}, { retryCount: 0 });
|
|
648
|
-
if (typeof response === "string")
|
|
649
|
-
return { id: response };
|
|
650
|
-
return response;
|
|
651
|
-
} catch (err) {
|
|
652
|
-
const error = err;
|
|
653
|
-
if (experimental_fallback && (error.name === "MethodNotFoundRpcError" || error.name === "MethodNotSupportedRpcError" || error.name === "UnknownRpcError" || error.details.toLowerCase().includes("does not exist / is not available") || error.details.toLowerCase().includes("missing or invalid. request()") || error.details.toLowerCase().includes("did not match any variant of untagged enum") || error.details.toLowerCase().includes("account upgraded to unsupported contract") || error.details.toLowerCase().includes("eip-7702 not supported") || error.details.toLowerCase().includes("unsupported wc_ method") || error.details.toLowerCase().includes("feature toggled misconfigured"))) {
|
|
654
|
-
if (capabilities) {
|
|
655
|
-
const hasNonOptionalCapability = Object.values(capabilities).some((capability) => !capability.optional);
|
|
656
|
-
if (hasNonOptionalCapability) {
|
|
657
|
-
const message = "non-optional `capabilities` are not supported on fallback to `eth_sendTransaction`.";
|
|
658
|
-
throw new UnsupportedNonOptionalCapabilityError(new BaseError(message, {
|
|
659
|
-
details: message
|
|
660
|
-
}));
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
if (forceAtomic && calls.length > 1) {
|
|
664
|
-
const message = "`forceAtomic` is not supported on fallback to `eth_sendTransaction`.";
|
|
665
|
-
throw new AtomicityNotSupportedError(new BaseError(message, {
|
|
666
|
-
details: message
|
|
667
|
-
}));
|
|
668
|
-
}
|
|
669
|
-
const promises = [];
|
|
670
|
-
for (const call2 of calls) {
|
|
671
|
-
const promise = sendTransaction(client, {
|
|
672
|
-
account,
|
|
673
|
-
chain,
|
|
674
|
-
data: call2.data,
|
|
675
|
-
to: call2.to,
|
|
676
|
-
value: call2.value ? hexToBigInt(call2.value) : void 0
|
|
677
|
-
});
|
|
678
|
-
promises.push(promise);
|
|
679
|
-
if (experimental_fallbackDelay > 0)
|
|
680
|
-
await new Promise((resolve) => setTimeout(resolve, experimental_fallbackDelay));
|
|
681
|
-
}
|
|
682
|
-
const results = await Promise.allSettled(promises);
|
|
683
|
-
if (results.every((r) => r.status === "rejected"))
|
|
684
|
-
throw results[0].reason;
|
|
685
|
-
const hashes = results.map((result) => {
|
|
686
|
-
if (result.status === "fulfilled")
|
|
687
|
-
return result.value;
|
|
688
|
-
return fallbackTransactionErrorMagicIdentifier;
|
|
689
|
-
});
|
|
690
|
-
return {
|
|
691
|
-
id: concat([
|
|
692
|
-
...hashes,
|
|
693
|
-
numberToHex(chain.id, { size: 32 }),
|
|
694
|
-
fallbackMagicIdentifier
|
|
695
|
-
])
|
|
696
|
-
};
|
|
697
|
-
}
|
|
698
|
-
throw getTransactionError(err, {
|
|
699
|
-
...parameters,
|
|
700
|
-
account,
|
|
701
|
-
chain: parameters.chain
|
|
702
|
-
});
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
async function getCallsStatus(client, parameters) {
|
|
706
|
-
async function getStatus(id) {
|
|
707
|
-
const isTransactions = id.endsWith(fallbackMagicIdentifier.slice(2));
|
|
708
|
-
if (isTransactions) {
|
|
709
|
-
const chainId2 = trim$1(sliceHex(id, -64, -32));
|
|
710
|
-
const hashes = sliceHex(id, 0, -64).slice(2).match(/.{1,64}/g);
|
|
711
|
-
const receipts2 = await Promise.all(hashes.map((hash2) => fallbackTransactionErrorMagicIdentifier.slice(2) !== hash2 ? client.request({
|
|
712
|
-
method: "eth_getTransactionReceipt",
|
|
713
|
-
params: [`0x${hash2}`]
|
|
714
|
-
}, { dedupe: true }) : void 0));
|
|
715
|
-
const status2 = (() => {
|
|
716
|
-
if (receipts2.some((r) => r === null))
|
|
717
|
-
return 100;
|
|
718
|
-
if (receipts2.every((r) => (r == null ? void 0 : r.status) === "0x1"))
|
|
719
|
-
return 200;
|
|
720
|
-
if (receipts2.every((r) => (r == null ? void 0 : r.status) === "0x0"))
|
|
721
|
-
return 500;
|
|
722
|
-
return 600;
|
|
723
|
-
})();
|
|
724
|
-
return {
|
|
725
|
-
atomic: false,
|
|
726
|
-
chainId: hexToNumber(chainId2),
|
|
727
|
-
receipts: receipts2.filter(Boolean),
|
|
728
|
-
status: status2,
|
|
729
|
-
version: "2.0.0"
|
|
730
|
-
};
|
|
731
|
-
}
|
|
732
|
-
return client.request({
|
|
733
|
-
method: "wallet_getCallsStatus",
|
|
734
|
-
params: [id]
|
|
735
|
-
});
|
|
736
|
-
}
|
|
737
|
-
const { atomic = false, chainId, receipts, version = "2.0.0", ...response } = await getStatus(parameters.id);
|
|
738
|
-
const [status, statusCode] = (() => {
|
|
739
|
-
const statusCode2 = response.status;
|
|
740
|
-
if (statusCode2 >= 100 && statusCode2 < 200)
|
|
741
|
-
return ["pending", statusCode2];
|
|
742
|
-
if (statusCode2 >= 200 && statusCode2 < 300)
|
|
743
|
-
return ["success", statusCode2];
|
|
744
|
-
if (statusCode2 >= 300 && statusCode2 < 700)
|
|
745
|
-
return ["failure", statusCode2];
|
|
746
|
-
if (statusCode2 === "CONFIRMED")
|
|
747
|
-
return ["success", 200];
|
|
748
|
-
if (statusCode2 === "PENDING")
|
|
749
|
-
return ["pending", 100];
|
|
750
|
-
return [void 0, statusCode2];
|
|
751
|
-
})();
|
|
752
|
-
return {
|
|
753
|
-
...response,
|
|
754
|
-
atomic,
|
|
755
|
-
// @ts-expect-error: for backwards compatibility
|
|
756
|
-
chainId: chainId ? hexToNumber(chainId) : void 0,
|
|
757
|
-
receipts: (receipts == null ? void 0 : receipts.map((receipt) => ({
|
|
758
|
-
...receipt,
|
|
759
|
-
blockNumber: hexToBigInt(receipt.blockNumber),
|
|
760
|
-
gasUsed: hexToBigInt(receipt.gasUsed),
|
|
761
|
-
status: receiptStatuses[receipt.status]
|
|
762
|
-
}))) ?? [],
|
|
763
|
-
statusCode,
|
|
764
|
-
status,
|
|
765
|
-
version
|
|
766
|
-
};
|
|
767
|
-
}
|
|
768
|
-
async function waitForCallsStatus(client, parameters) {
|
|
769
|
-
const {
|
|
770
|
-
id,
|
|
771
|
-
pollingInterval = client.pollingInterval,
|
|
772
|
-
status = ({ statusCode }) => statusCode === 200 || statusCode >= 300,
|
|
773
|
-
retryCount = 4,
|
|
774
|
-
retryDelay = ({ count }) => ~~(1 << count) * 200,
|
|
775
|
-
// exponential backoff
|
|
776
|
-
timeout = 6e4,
|
|
777
|
-
throwOnFailure = false
|
|
778
|
-
} = parameters;
|
|
779
|
-
const observerId = stringify$1(["waitForCallsStatus", client.uid, id]);
|
|
780
|
-
const { promise, resolve, reject } = withResolvers();
|
|
781
|
-
let timer;
|
|
782
|
-
const unobserve = observe(observerId, { resolve, reject }, (emit) => {
|
|
783
|
-
const unpoll = poll(async () => {
|
|
784
|
-
const done = (fn) => {
|
|
785
|
-
clearTimeout(timer);
|
|
786
|
-
unpoll();
|
|
787
|
-
fn();
|
|
788
|
-
unobserve();
|
|
789
|
-
};
|
|
790
|
-
try {
|
|
791
|
-
const result = await withRetry(async () => {
|
|
792
|
-
const result2 = await getAction(client, getCallsStatus, "getCallsStatus")({ id });
|
|
793
|
-
if (throwOnFailure && result2.status === "failure")
|
|
794
|
-
throw new BundleFailedError(result2);
|
|
795
|
-
return result2;
|
|
796
|
-
}, {
|
|
797
|
-
retryCount,
|
|
798
|
-
delay: retryDelay
|
|
799
|
-
});
|
|
800
|
-
if (!status(result))
|
|
801
|
-
return;
|
|
802
|
-
done(() => emit.resolve(result));
|
|
803
|
-
} catch (error) {
|
|
804
|
-
done(() => emit.reject(error));
|
|
805
|
-
}
|
|
806
|
-
}, {
|
|
807
|
-
interval: pollingInterval,
|
|
808
|
-
emitOnBegin: true
|
|
809
|
-
});
|
|
810
|
-
return unpoll;
|
|
811
|
-
});
|
|
812
|
-
timer = timeout ? setTimeout(() => {
|
|
813
|
-
unobserve();
|
|
814
|
-
clearTimeout(timer);
|
|
815
|
-
reject(new WaitForCallsStatusTimeoutError({ id }));
|
|
816
|
-
}, timeout) : void 0;
|
|
817
|
-
return await promise;
|
|
818
|
-
}
|
|
819
|
-
class WaitForCallsStatusTimeoutError extends BaseError {
|
|
820
|
-
constructor({ id }) {
|
|
821
|
-
super(`Timed out while waiting for call bundle with id "${id}" to be confirmed.`, { name: "WaitForCallsStatusTimeoutError" });
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
|
-
function isNullUniversalResolverError(err) {
|
|
825
|
-
var _a, _b, _c, _d, _e, _f;
|
|
826
|
-
if (!(err instanceof BaseError))
|
|
827
|
-
return false;
|
|
828
|
-
const cause = err.walk((e) => e instanceof ContractFunctionRevertedError);
|
|
829
|
-
if (!(cause instanceof ContractFunctionRevertedError))
|
|
830
|
-
return false;
|
|
831
|
-
if (((_a = cause.data) == null ? void 0 : _a.errorName) === "HttpError")
|
|
832
|
-
return true;
|
|
833
|
-
if (((_b = cause.data) == null ? void 0 : _b.errorName) === "ResolverError")
|
|
834
|
-
return true;
|
|
835
|
-
if (((_c = cause.data) == null ? void 0 : _c.errorName) === "ResolverNotContract")
|
|
836
|
-
return true;
|
|
837
|
-
if (((_d = cause.data) == null ? void 0 : _d.errorName) === "ResolverNotFound")
|
|
838
|
-
return true;
|
|
839
|
-
if (((_e = cause.data) == null ? void 0 : _e.errorName) === "ReverseAddressMismatch")
|
|
840
|
-
return true;
|
|
841
|
-
if (((_f = cause.data) == null ? void 0 : _f.errorName) === "UnsupportedResolverProfile")
|
|
842
|
-
return true;
|
|
843
|
-
return false;
|
|
844
|
-
}
|
|
845
|
-
function encodedLabelToLabelhash(label) {
|
|
846
|
-
if (label.length !== 66)
|
|
847
|
-
return null;
|
|
848
|
-
if (label.indexOf("[") !== 0)
|
|
849
|
-
return null;
|
|
850
|
-
if (label.indexOf("]") !== 65)
|
|
851
|
-
return null;
|
|
852
|
-
const hash2 = `0x${label.slice(1, 65)}`;
|
|
853
|
-
if (!isHex(hash2))
|
|
854
|
-
return null;
|
|
855
|
-
return hash2;
|
|
856
|
-
}
|
|
857
|
-
function namehash(name) {
|
|
858
|
-
let result = new Uint8Array(32).fill(0);
|
|
859
|
-
if (!name)
|
|
860
|
-
return bytesToHex(result);
|
|
861
|
-
const labels = name.split(".");
|
|
862
|
-
for (let i = labels.length - 1; i >= 0; i -= 1) {
|
|
863
|
-
const hashFromEncodedLabel = encodedLabelToLabelhash(labels[i]);
|
|
864
|
-
const hashed = hashFromEncodedLabel ? toBytes(hashFromEncodedLabel) : keccak256$1(stringToBytes(labels[i]), "bytes");
|
|
865
|
-
result = keccak256$1(concat([result, hashed]), "bytes");
|
|
866
|
-
}
|
|
867
|
-
return bytesToHex(result);
|
|
868
|
-
}
|
|
869
|
-
function encodeLabelhash(hash2) {
|
|
870
|
-
return `[${hash2.slice(2)}]`;
|
|
871
|
-
}
|
|
872
|
-
function labelhash(label) {
|
|
873
|
-
const result = new Uint8Array(32).fill(0);
|
|
874
|
-
if (!label)
|
|
875
|
-
return bytesToHex(result);
|
|
876
|
-
return encodedLabelToLabelhash(label) || keccak256$1(stringToBytes(label));
|
|
877
|
-
}
|
|
878
|
-
function packetToBytes(packet) {
|
|
879
|
-
const value = packet.replace(/^\.|\.$/gm, "");
|
|
880
|
-
if (value.length === 0)
|
|
881
|
-
return new Uint8Array(1);
|
|
882
|
-
const bytes = new Uint8Array(stringToBytes(value).byteLength + 2);
|
|
883
|
-
let offset = 0;
|
|
884
|
-
const list = value.split(".");
|
|
885
|
-
for (let i = 0; i < list.length; i++) {
|
|
886
|
-
let encoded = stringToBytes(list[i]);
|
|
887
|
-
if (encoded.byteLength > 255)
|
|
888
|
-
encoded = stringToBytes(encodeLabelhash(labelhash(list[i])));
|
|
889
|
-
bytes[offset] = encoded.length;
|
|
890
|
-
bytes.set(encoded, offset + 1);
|
|
891
|
-
offset += encoded.length + 1;
|
|
892
|
-
}
|
|
893
|
-
if (bytes.byteLength !== offset + 1)
|
|
894
|
-
return bytes.slice(0, offset + 1);
|
|
895
|
-
return bytes;
|
|
896
|
-
}
|
|
897
|
-
async function getEnsAddress(client, parameters) {
|
|
898
|
-
const { blockNumber, blockTag, coinType, name, gatewayUrls, strict } = parameters;
|
|
899
|
-
const { chain } = client;
|
|
900
|
-
const universalResolverAddress = (() => {
|
|
901
|
-
if (parameters.universalResolverAddress)
|
|
902
|
-
return parameters.universalResolverAddress;
|
|
903
|
-
if (!chain)
|
|
904
|
-
throw new Error("client chain not configured. universalResolverAddress is required.");
|
|
905
|
-
return getChainContractAddress({
|
|
906
|
-
blockNumber,
|
|
907
|
-
chain,
|
|
908
|
-
contract: "ensUniversalResolver"
|
|
909
|
-
});
|
|
910
|
-
})();
|
|
911
|
-
const tlds = chain == null ? void 0 : chain.ensTlds;
|
|
912
|
-
if (tlds && !tlds.some((tld) => name.endsWith(tld)))
|
|
913
|
-
return null;
|
|
914
|
-
const args = (() => {
|
|
915
|
-
if (coinType != null)
|
|
916
|
-
return [namehash(name), BigInt(coinType)];
|
|
917
|
-
return [namehash(name)];
|
|
918
|
-
})();
|
|
919
|
-
try {
|
|
920
|
-
const functionData = encodeFunctionData({
|
|
921
|
-
abi: addressResolverAbi,
|
|
922
|
-
functionName: "addr",
|
|
923
|
-
args
|
|
924
|
-
});
|
|
925
|
-
const readContractParameters = {
|
|
926
|
-
address: universalResolverAddress,
|
|
927
|
-
abi: universalResolverResolveAbi,
|
|
928
|
-
functionName: "resolveWithGateways",
|
|
929
|
-
args: [
|
|
930
|
-
toHex$1(packetToBytes(name)),
|
|
931
|
-
functionData,
|
|
932
|
-
gatewayUrls ?? [localBatchGatewayUrl]
|
|
933
|
-
],
|
|
934
|
-
blockNumber,
|
|
935
|
-
blockTag
|
|
936
|
-
};
|
|
937
|
-
const readContractAction = getAction(client, readContract, "readContract");
|
|
938
|
-
const res = await readContractAction(readContractParameters);
|
|
939
|
-
if (res[0] === "0x")
|
|
940
|
-
return null;
|
|
941
|
-
const address = decodeFunctionResult({
|
|
942
|
-
abi: addressResolverAbi,
|
|
943
|
-
args,
|
|
944
|
-
functionName: "addr",
|
|
945
|
-
data: res[0]
|
|
946
|
-
});
|
|
947
|
-
if (address === "0x")
|
|
948
|
-
return null;
|
|
949
|
-
if (trim$1(address) === "0x00")
|
|
950
|
-
return null;
|
|
951
|
-
return address;
|
|
952
|
-
} catch (err) {
|
|
953
|
-
if (strict)
|
|
954
|
-
throw err;
|
|
955
|
-
if (isNullUniversalResolverError(err))
|
|
956
|
-
return null;
|
|
957
|
-
throw err;
|
|
958
|
-
}
|
|
959
|
-
}
|
|
960
|
-
class EnsAvatarInvalidMetadataError extends BaseError {
|
|
961
|
-
constructor({ data }) {
|
|
962
|
-
super("Unable to extract image from metadata. The metadata may be malformed or invalid.", {
|
|
963
|
-
metaMessages: [
|
|
964
|
-
"- Metadata must be a JSON object with at least an `image`, `image_url` or `image_data` property.",
|
|
965
|
-
"",
|
|
966
|
-
`Provided data: ${JSON.stringify(data)}`
|
|
967
|
-
],
|
|
968
|
-
name: "EnsAvatarInvalidMetadataError"
|
|
969
|
-
});
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
class EnsAvatarInvalidNftUriError extends BaseError {
|
|
973
|
-
constructor({ reason }) {
|
|
974
|
-
super(`ENS NFT avatar URI is invalid. ${reason}`, {
|
|
975
|
-
name: "EnsAvatarInvalidNftUriError"
|
|
976
|
-
});
|
|
977
|
-
}
|
|
978
|
-
}
|
|
979
|
-
class EnsAvatarUriResolutionError extends BaseError {
|
|
980
|
-
constructor({ uri }) {
|
|
981
|
-
super(`Unable to resolve ENS avatar URI "${uri}". The URI may be malformed, invalid, or does not respond with a valid image.`, { name: "EnsAvatarUriResolutionError" });
|
|
982
|
-
}
|
|
983
|
-
}
|
|
984
|
-
class EnsAvatarUnsupportedNamespaceError extends BaseError {
|
|
985
|
-
constructor({ namespace }) {
|
|
986
|
-
super(`ENS NFT avatar namespace "${namespace}" is not supported. Must be "erc721" or "erc1155".`, { name: "EnsAvatarUnsupportedNamespaceError" });
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
|
-
class EnsInvalidChainIdError extends BaseError {
|
|
990
|
-
constructor({ chainId }) {
|
|
991
|
-
super(`Invalid ENSIP-11 chainId: ${chainId}. Must be between 0 and 0x7fffffff, or 1.`, {
|
|
992
|
-
name: "EnsInvalidChainIdError"
|
|
993
|
-
});
|
|
994
|
-
}
|
|
995
|
-
}
|
|
996
|
-
const networkRegex = /(?<protocol>https?:\/\/[^/]*|ipfs:\/|ipns:\/|ar:\/)?(?<root>\/)?(?<subpath>ipfs\/|ipns\/)?(?<target>[\w\-.]+)(?<subtarget>\/.*)?/;
|
|
997
|
-
const ipfsHashRegex = /^(Qm[1-9A-HJ-NP-Za-km-z]{44,}|b[A-Za-z2-7]{58,}|B[A-Z2-7]{58,}|z[1-9A-HJ-NP-Za-km-z]{48,}|F[0-9A-F]{50,})(\/(?<target>[\w\-.]+))?(?<subtarget>\/.*)?$/;
|
|
998
|
-
const base64Regex = /^data:([a-zA-Z\-/+]*);base64,([^"].*)/;
|
|
999
|
-
const dataURIRegex = /^data:([a-zA-Z\-/+]*)?(;[a-zA-Z0-9].*?)?(,)/;
|
|
1000
|
-
async function isImageUri(uri) {
|
|
1001
|
-
try {
|
|
1002
|
-
const res = await fetch(uri, { method: "HEAD" });
|
|
1003
|
-
if (res.status === 200) {
|
|
1004
|
-
const contentType = res.headers.get("content-type");
|
|
1005
|
-
return contentType == null ? void 0 : contentType.startsWith("image/");
|
|
1006
|
-
}
|
|
1007
|
-
return false;
|
|
1008
|
-
} catch (error) {
|
|
1009
|
-
if (typeof error === "object" && typeof error.response !== "undefined") {
|
|
1010
|
-
return false;
|
|
1011
|
-
}
|
|
1012
|
-
if (!Object.hasOwn(globalThis, "Image"))
|
|
1013
|
-
return false;
|
|
1014
|
-
return new Promise((resolve) => {
|
|
1015
|
-
const img = new Image();
|
|
1016
|
-
img.onload = () => {
|
|
1017
|
-
resolve(true);
|
|
1018
|
-
};
|
|
1019
|
-
img.onerror = () => {
|
|
1020
|
-
resolve(false);
|
|
1021
|
-
};
|
|
1022
|
-
img.src = uri;
|
|
1023
|
-
});
|
|
1024
|
-
}
|
|
1025
|
-
}
|
|
1026
|
-
function getGateway(custom, defaultGateway) {
|
|
1027
|
-
if (!custom)
|
|
1028
|
-
return defaultGateway;
|
|
1029
|
-
if (custom.endsWith("/"))
|
|
1030
|
-
return custom.slice(0, -1);
|
|
1031
|
-
return custom;
|
|
1032
|
-
}
|
|
1033
|
-
function resolveAvatarUri({ uri, gatewayUrls }) {
|
|
1034
|
-
const isEncoded = base64Regex.test(uri);
|
|
1035
|
-
if (isEncoded)
|
|
1036
|
-
return { uri, isOnChain: true, isEncoded };
|
|
1037
|
-
const ipfsGateway = getGateway(gatewayUrls == null ? void 0 : gatewayUrls.ipfs, "https://ipfs.io");
|
|
1038
|
-
const arweaveGateway = getGateway(gatewayUrls == null ? void 0 : gatewayUrls.arweave, "https://arweave.net");
|
|
1039
|
-
const networkRegexMatch = uri.match(networkRegex);
|
|
1040
|
-
const { protocol, subpath, target, subtarget = "" } = (networkRegexMatch == null ? void 0 : networkRegexMatch.groups) || {};
|
|
1041
|
-
const isIPNS = protocol === "ipns:/" || subpath === "ipns/";
|
|
1042
|
-
const isIPFS = protocol === "ipfs:/" || subpath === "ipfs/" || ipfsHashRegex.test(uri);
|
|
1043
|
-
if (uri.startsWith("http") && !isIPNS && !isIPFS) {
|
|
1044
|
-
let replacedUri = uri;
|
|
1045
|
-
if (gatewayUrls == null ? void 0 : gatewayUrls.arweave)
|
|
1046
|
-
replacedUri = uri.replace(/https:\/\/arweave.net/g, gatewayUrls == null ? void 0 : gatewayUrls.arweave);
|
|
1047
|
-
return { uri: replacedUri, isOnChain: false, isEncoded: false };
|
|
1048
|
-
}
|
|
1049
|
-
if ((isIPNS || isIPFS) && target) {
|
|
1050
|
-
return {
|
|
1051
|
-
uri: `${ipfsGateway}/${isIPNS ? "ipns" : "ipfs"}/${target}${subtarget}`,
|
|
1052
|
-
isOnChain: false,
|
|
1053
|
-
isEncoded: false
|
|
1054
|
-
};
|
|
1055
|
-
}
|
|
1056
|
-
if (protocol === "ar:/" && target) {
|
|
1057
|
-
return {
|
|
1058
|
-
uri: `${arweaveGateway}/${target}${subtarget || ""}`,
|
|
1059
|
-
isOnChain: false,
|
|
1060
|
-
isEncoded: false
|
|
1061
|
-
};
|
|
1062
|
-
}
|
|
1063
|
-
let parsedUri = uri.replace(dataURIRegex, "");
|
|
1064
|
-
if (parsedUri.startsWith("<svg")) {
|
|
1065
|
-
parsedUri = `data:image/svg+xml;base64,${btoa(parsedUri)}`;
|
|
1066
|
-
}
|
|
1067
|
-
if (parsedUri.startsWith("data:") || parsedUri.startsWith("{")) {
|
|
1068
|
-
return {
|
|
1069
|
-
uri: parsedUri,
|
|
1070
|
-
isOnChain: true,
|
|
1071
|
-
isEncoded: false
|
|
1072
|
-
};
|
|
1073
|
-
}
|
|
1074
|
-
throw new EnsAvatarUriResolutionError({ uri });
|
|
1075
|
-
}
|
|
1076
|
-
function getJsonImage(data) {
|
|
1077
|
-
if (typeof data !== "object" || !("image" in data) && !("image_url" in data) && !("image_data" in data)) {
|
|
1078
|
-
throw new EnsAvatarInvalidMetadataError({ data });
|
|
1079
|
-
}
|
|
1080
|
-
return data.image || data.image_url || data.image_data;
|
|
1081
|
-
}
|
|
1082
|
-
async function getMetadataAvatarUri({ gatewayUrls, uri }) {
|
|
1083
|
-
try {
|
|
1084
|
-
const res = await fetch(uri).then((res2) => res2.json());
|
|
1085
|
-
const image = await parseAvatarUri({
|
|
1086
|
-
gatewayUrls,
|
|
1087
|
-
uri: getJsonImage(res)
|
|
1088
|
-
});
|
|
1089
|
-
return image;
|
|
1090
|
-
} catch {
|
|
1091
|
-
throw new EnsAvatarUriResolutionError({ uri });
|
|
1092
|
-
}
|
|
1093
|
-
}
|
|
1094
|
-
async function parseAvatarUri({ gatewayUrls, uri }) {
|
|
1095
|
-
const { uri: resolvedURI, isOnChain } = resolveAvatarUri({ uri, gatewayUrls });
|
|
1096
|
-
if (isOnChain)
|
|
1097
|
-
return resolvedURI;
|
|
1098
|
-
const isImage = await isImageUri(resolvedURI);
|
|
1099
|
-
if (isImage)
|
|
1100
|
-
return resolvedURI;
|
|
1101
|
-
throw new EnsAvatarUriResolutionError({ uri });
|
|
1102
|
-
}
|
|
1103
|
-
function parseNftUri(uri_) {
|
|
1104
|
-
let uri = uri_;
|
|
1105
|
-
if (uri.startsWith("did:nft:")) {
|
|
1106
|
-
uri = uri.replace("did:nft:", "").replace(/_/g, "/");
|
|
1107
|
-
}
|
|
1108
|
-
const [reference, asset_namespace, tokenID] = uri.split("/");
|
|
1109
|
-
const [eip_namespace, chainID] = reference.split(":");
|
|
1110
|
-
const [erc_namespace, contractAddress] = asset_namespace.split(":");
|
|
1111
|
-
if (!eip_namespace || eip_namespace.toLowerCase() !== "eip155")
|
|
1112
|
-
throw new EnsAvatarInvalidNftUriError({ reason: "Only EIP-155 supported" });
|
|
1113
|
-
if (!chainID)
|
|
1114
|
-
throw new EnsAvatarInvalidNftUriError({ reason: "Chain ID not found" });
|
|
1115
|
-
if (!contractAddress)
|
|
1116
|
-
throw new EnsAvatarInvalidNftUriError({
|
|
1117
|
-
reason: "Contract address not found"
|
|
1118
|
-
});
|
|
1119
|
-
if (!tokenID)
|
|
1120
|
-
throw new EnsAvatarInvalidNftUriError({ reason: "Token ID not found" });
|
|
1121
|
-
if (!erc_namespace)
|
|
1122
|
-
throw new EnsAvatarInvalidNftUriError({ reason: "ERC namespace not found" });
|
|
1123
|
-
return {
|
|
1124
|
-
chainID: Number.parseInt(chainID, 10),
|
|
1125
|
-
namespace: erc_namespace.toLowerCase(),
|
|
1126
|
-
contractAddress,
|
|
1127
|
-
tokenID
|
|
1128
|
-
};
|
|
1129
|
-
}
|
|
1130
|
-
async function getNftTokenUri(client, { nft }) {
|
|
1131
|
-
if (nft.namespace === "erc721") {
|
|
1132
|
-
return readContract(client, {
|
|
1133
|
-
address: nft.contractAddress,
|
|
1134
|
-
abi: [
|
|
1135
|
-
{
|
|
1136
|
-
name: "tokenURI",
|
|
1137
|
-
type: "function",
|
|
1138
|
-
stateMutability: "view",
|
|
1139
|
-
inputs: [{ name: "tokenId", type: "uint256" }],
|
|
1140
|
-
outputs: [{ name: "", type: "string" }]
|
|
1141
|
-
}
|
|
1142
|
-
],
|
|
1143
|
-
functionName: "tokenURI",
|
|
1144
|
-
args: [BigInt(nft.tokenID)]
|
|
1145
|
-
});
|
|
1146
|
-
}
|
|
1147
|
-
if (nft.namespace === "erc1155") {
|
|
1148
|
-
return readContract(client, {
|
|
1149
|
-
address: nft.contractAddress,
|
|
1150
|
-
abi: [
|
|
1151
|
-
{
|
|
1152
|
-
name: "uri",
|
|
1153
|
-
type: "function",
|
|
1154
|
-
stateMutability: "view",
|
|
1155
|
-
inputs: [{ name: "_id", type: "uint256" }],
|
|
1156
|
-
outputs: [{ name: "", type: "string" }]
|
|
1157
|
-
}
|
|
1158
|
-
],
|
|
1159
|
-
functionName: "uri",
|
|
1160
|
-
args: [BigInt(nft.tokenID)]
|
|
1161
|
-
});
|
|
1162
|
-
}
|
|
1163
|
-
throw new EnsAvatarUnsupportedNamespaceError({ namespace: nft.namespace });
|
|
1164
|
-
}
|
|
1165
|
-
async function parseAvatarRecord(client, { gatewayUrls, record }) {
|
|
1166
|
-
if (/eip155:/i.test(record))
|
|
1167
|
-
return parseNftAvatarUri(client, { gatewayUrls, record });
|
|
1168
|
-
return parseAvatarUri({ uri: record, gatewayUrls });
|
|
1169
|
-
}
|
|
1170
|
-
async function parseNftAvatarUri(client, { gatewayUrls, record }) {
|
|
1171
|
-
const nft = parseNftUri(record);
|
|
1172
|
-
const nftUri = await getNftTokenUri(client, { nft });
|
|
1173
|
-
const { uri: resolvedNftUri, isOnChain, isEncoded } = resolveAvatarUri({ uri: nftUri, gatewayUrls });
|
|
1174
|
-
if (isOnChain && (resolvedNftUri.includes("data:application/json;base64,") || resolvedNftUri.startsWith("{"))) {
|
|
1175
|
-
const encodedJson = isEncoded ? (
|
|
1176
|
-
// if it is encoded, decode it
|
|
1177
|
-
atob(resolvedNftUri.replace("data:application/json;base64,", ""))
|
|
1178
|
-
) : (
|
|
1179
|
-
// if it isn't encoded assume it is a JSON string, but it could be anything (it will error if it is)
|
|
1180
|
-
resolvedNftUri
|
|
1181
|
-
);
|
|
1182
|
-
const decoded = JSON.parse(encodedJson);
|
|
1183
|
-
return parseAvatarUri({ uri: getJsonImage(decoded), gatewayUrls });
|
|
1184
|
-
}
|
|
1185
|
-
let uriTokenId = nft.tokenID;
|
|
1186
|
-
if (nft.namespace === "erc1155")
|
|
1187
|
-
uriTokenId = uriTokenId.replace("0x", "").padStart(64, "0");
|
|
1188
|
-
return getMetadataAvatarUri({
|
|
1189
|
-
gatewayUrls,
|
|
1190
|
-
uri: resolvedNftUri.replace(/(?:0x)?{id}/, uriTokenId)
|
|
1191
|
-
});
|
|
1192
|
-
}
|
|
1193
|
-
async function getEnsText(client, parameters) {
|
|
1194
|
-
const { blockNumber, blockTag, key, name, gatewayUrls, strict } = parameters;
|
|
1195
|
-
const { chain } = client;
|
|
1196
|
-
const universalResolverAddress = (() => {
|
|
1197
|
-
if (parameters.universalResolverAddress)
|
|
1198
|
-
return parameters.universalResolverAddress;
|
|
1199
|
-
if (!chain)
|
|
1200
|
-
throw new Error("client chain not configured. universalResolverAddress is required.");
|
|
1201
|
-
return getChainContractAddress({
|
|
1202
|
-
blockNumber,
|
|
1203
|
-
chain,
|
|
1204
|
-
contract: "ensUniversalResolver"
|
|
1205
|
-
});
|
|
1206
|
-
})();
|
|
1207
|
-
const tlds = chain == null ? void 0 : chain.ensTlds;
|
|
1208
|
-
if (tlds && !tlds.some((tld) => name.endsWith(tld)))
|
|
1209
|
-
return null;
|
|
1210
|
-
try {
|
|
1211
|
-
const readContractParameters = {
|
|
1212
|
-
address: universalResolverAddress,
|
|
1213
|
-
abi: universalResolverResolveAbi,
|
|
1214
|
-
args: [
|
|
1215
|
-
toHex$1(packetToBytes(name)),
|
|
1216
|
-
encodeFunctionData({
|
|
1217
|
-
abi: textResolverAbi,
|
|
1218
|
-
functionName: "text",
|
|
1219
|
-
args: [namehash(name), key]
|
|
1220
|
-
}),
|
|
1221
|
-
gatewayUrls ?? [localBatchGatewayUrl]
|
|
1222
|
-
],
|
|
1223
|
-
functionName: "resolveWithGateways",
|
|
1224
|
-
blockNumber,
|
|
1225
|
-
blockTag
|
|
1226
|
-
};
|
|
1227
|
-
const readContractAction = getAction(client, readContract, "readContract");
|
|
1228
|
-
const res = await readContractAction(readContractParameters);
|
|
1229
|
-
if (res[0] === "0x")
|
|
1230
|
-
return null;
|
|
1231
|
-
const record = decodeFunctionResult({
|
|
1232
|
-
abi: textResolverAbi,
|
|
1233
|
-
functionName: "text",
|
|
1234
|
-
data: res[0]
|
|
1235
|
-
});
|
|
1236
|
-
return record === "" ? null : record;
|
|
1237
|
-
} catch (err) {
|
|
1238
|
-
if (strict)
|
|
1239
|
-
throw err;
|
|
1240
|
-
if (isNullUniversalResolverError(err))
|
|
1241
|
-
return null;
|
|
1242
|
-
throw err;
|
|
1243
|
-
}
|
|
1244
|
-
}
|
|
1245
|
-
async function getEnsAvatar(client, { blockNumber, blockTag, assetGatewayUrls, name, gatewayUrls, strict, universalResolverAddress }) {
|
|
1246
|
-
const record = await getAction(client, getEnsText, "getEnsText")({
|
|
1247
|
-
blockNumber,
|
|
1248
|
-
blockTag,
|
|
1249
|
-
key: "avatar",
|
|
1250
|
-
name,
|
|
1251
|
-
universalResolverAddress,
|
|
1252
|
-
gatewayUrls,
|
|
1253
|
-
strict
|
|
1254
|
-
});
|
|
1255
|
-
if (!record)
|
|
1256
|
-
return null;
|
|
1257
|
-
try {
|
|
1258
|
-
return await parseAvatarRecord(client, {
|
|
1259
|
-
record,
|
|
1260
|
-
gatewayUrls: assetGatewayUrls
|
|
1261
|
-
});
|
|
1262
|
-
} catch {
|
|
1263
|
-
return null;
|
|
1264
|
-
}
|
|
1265
|
-
}
|
|
1266
|
-
async function getEnsName(client, parameters) {
|
|
1267
|
-
const { address, blockNumber, blockTag, coinType = 60n, gatewayUrls, strict } = parameters;
|
|
1268
|
-
const { chain } = client;
|
|
1269
|
-
const universalResolverAddress = (() => {
|
|
1270
|
-
if (parameters.universalResolverAddress)
|
|
1271
|
-
return parameters.universalResolverAddress;
|
|
1272
|
-
if (!chain)
|
|
1273
|
-
throw new Error("client chain not configured. universalResolverAddress is required.");
|
|
1274
|
-
return getChainContractAddress({
|
|
1275
|
-
blockNumber,
|
|
1276
|
-
chain,
|
|
1277
|
-
contract: "ensUniversalResolver"
|
|
1278
|
-
});
|
|
1279
|
-
})();
|
|
1280
|
-
try {
|
|
1281
|
-
const readContractParameters = {
|
|
1282
|
-
address: universalResolverAddress,
|
|
1283
|
-
abi: universalResolverReverseAbi,
|
|
1284
|
-
args: [address, coinType, gatewayUrls ?? [localBatchGatewayUrl]],
|
|
1285
|
-
functionName: "reverseWithGateways",
|
|
1286
|
-
blockNumber,
|
|
1287
|
-
blockTag
|
|
1288
|
-
};
|
|
1289
|
-
const readContractAction = getAction(client, readContract, "readContract");
|
|
1290
|
-
const [name] = await readContractAction(readContractParameters);
|
|
1291
|
-
return name || null;
|
|
1292
|
-
} catch (err) {
|
|
1293
|
-
if (strict)
|
|
1294
|
-
throw err;
|
|
1295
|
-
if (isNullUniversalResolverError(err))
|
|
1296
|
-
return null;
|
|
1297
|
-
throw err;
|
|
1298
|
-
}
|
|
1299
|
-
}
|
|
1300
|
-
async function getEnsResolver(client, parameters) {
|
|
1301
|
-
const { blockNumber, blockTag, name } = parameters;
|
|
1302
|
-
const { chain } = client;
|
|
1303
|
-
const universalResolverAddress = (() => {
|
|
1304
|
-
if (parameters.universalResolverAddress)
|
|
1305
|
-
return parameters.universalResolverAddress;
|
|
1306
|
-
if (!chain)
|
|
1307
|
-
throw new Error("client chain not configured. universalResolverAddress is required.");
|
|
1308
|
-
return getChainContractAddress({
|
|
1309
|
-
blockNumber,
|
|
1310
|
-
chain,
|
|
1311
|
-
contract: "ensUniversalResolver"
|
|
1312
|
-
});
|
|
1313
|
-
})();
|
|
1314
|
-
const tlds = chain == null ? void 0 : chain.ensTlds;
|
|
1315
|
-
if (tlds && !tlds.some((tld) => name.endsWith(tld)))
|
|
1316
|
-
throw new Error(`${name} is not a valid ENS TLD (${tlds == null ? void 0 : tlds.join(", ")}) for chain "${chain.name}" (id: ${chain.id}).`);
|
|
1317
|
-
const [resolverAddress] = await getAction(client, readContract, "readContract")({
|
|
1318
|
-
address: universalResolverAddress,
|
|
1319
|
-
abi: [
|
|
1320
|
-
{
|
|
1321
|
-
inputs: [{ type: "bytes" }],
|
|
1322
|
-
name: "findResolver",
|
|
1323
|
-
outputs: [
|
|
1324
|
-
{ type: "address" },
|
|
1325
|
-
{ type: "bytes32" },
|
|
1326
|
-
{ type: "uint256" }
|
|
1327
|
-
],
|
|
1328
|
-
stateMutability: "view",
|
|
1329
|
-
type: "function"
|
|
1330
|
-
}
|
|
1331
|
-
],
|
|
1332
|
-
functionName: "findResolver",
|
|
1333
|
-
args: [toHex$1(packetToBytes(name))],
|
|
1334
|
-
blockNumber,
|
|
1335
|
-
blockTag
|
|
1336
|
-
});
|
|
1337
|
-
return resolverAddress;
|
|
1338
|
-
}
|
|
1339
|
-
async function createAccessList(client, args) {
|
|
1340
|
-
var _a, _b, _c;
|
|
1341
|
-
const { account: account_ = client.account, blockNumber, blockTag = "latest", blobs, data, gas, gasPrice, maxFeePerBlobGas, maxFeePerGas, maxPriorityFeePerGas, to, value, ...rest } = args;
|
|
1342
|
-
const account = account_ ? parseAccount(account_) : void 0;
|
|
1343
|
-
try {
|
|
1344
|
-
assertRequest(args);
|
|
1345
|
-
const blockNumberHex = typeof blockNumber === "bigint" ? numberToHex(blockNumber) : void 0;
|
|
1346
|
-
const block = blockNumberHex || blockTag;
|
|
1347
|
-
const chainFormat = (_c = (_b = (_a = client.chain) == null ? void 0 : _a.formatters) == null ? void 0 : _b.transactionRequest) == null ? void 0 : _c.format;
|
|
1348
|
-
const format = chainFormat || formatTransactionRequest;
|
|
1349
|
-
const request = format({
|
|
1350
|
-
// Pick out extra data that might exist on the chain's transaction request type.
|
|
1351
|
-
...extract$1(rest, { format: chainFormat }),
|
|
1352
|
-
from: account == null ? void 0 : account.address,
|
|
1353
|
-
blobs,
|
|
1354
|
-
data,
|
|
1355
|
-
gas,
|
|
1356
|
-
gasPrice,
|
|
1357
|
-
maxFeePerBlobGas,
|
|
1358
|
-
maxFeePerGas,
|
|
1359
|
-
maxPriorityFeePerGas,
|
|
1360
|
-
to,
|
|
1361
|
-
value
|
|
1362
|
-
});
|
|
1363
|
-
const response = await client.request({
|
|
1364
|
-
method: "eth_createAccessList",
|
|
1365
|
-
params: [request, block]
|
|
1366
|
-
});
|
|
1367
|
-
return {
|
|
1368
|
-
accessList: response.accessList,
|
|
1369
|
-
gasUsed: BigInt(response.gasUsed)
|
|
1370
|
-
};
|
|
1371
|
-
} catch (err) {
|
|
1372
|
-
throw getCallError(err, {
|
|
1373
|
-
...args,
|
|
1374
|
-
account,
|
|
1375
|
-
chain: client.chain
|
|
1376
|
-
});
|
|
1377
|
-
}
|
|
1378
|
-
}
|
|
1379
|
-
async function createBlockFilter(client) {
|
|
1380
|
-
const getRequest = createFilterRequestScope(client, {
|
|
1381
|
-
method: "eth_newBlockFilter"
|
|
1382
|
-
});
|
|
1383
|
-
const id = await client.request({
|
|
1384
|
-
method: "eth_newBlockFilter"
|
|
1385
|
-
});
|
|
1386
|
-
return { id, request: getRequest(id), type: "block" };
|
|
1387
|
-
}
|
|
1388
|
-
async function createEventFilter(client, { address, args, event, events: events_, fromBlock, strict, toBlock } = {}) {
|
|
1389
|
-
const events = events_ ?? (event ? [event] : void 0);
|
|
1390
|
-
const getRequest = createFilterRequestScope(client, {
|
|
1391
|
-
method: "eth_newFilter"
|
|
1392
|
-
});
|
|
1393
|
-
let topics = [];
|
|
1394
|
-
if (events) {
|
|
1395
|
-
const encoded = events.flatMap((event2) => encodeEventTopics({
|
|
1396
|
-
abi: [event2],
|
|
1397
|
-
eventName: event2.name,
|
|
1398
|
-
args
|
|
1399
|
-
}));
|
|
1400
|
-
topics = [encoded];
|
|
1401
|
-
if (event)
|
|
1402
|
-
topics = topics[0];
|
|
1403
|
-
}
|
|
1404
|
-
const id = await client.request({
|
|
1405
|
-
method: "eth_newFilter",
|
|
1406
|
-
params: [
|
|
1407
|
-
{
|
|
1408
|
-
address,
|
|
1409
|
-
fromBlock: typeof fromBlock === "bigint" ? numberToHex(fromBlock) : fromBlock,
|
|
1410
|
-
toBlock: typeof toBlock === "bigint" ? numberToHex(toBlock) : toBlock,
|
|
1411
|
-
...topics.length ? { topics } : {}
|
|
1412
|
-
}
|
|
1413
|
-
]
|
|
1414
|
-
});
|
|
1415
|
-
return {
|
|
1416
|
-
abi: events,
|
|
1417
|
-
args,
|
|
1418
|
-
eventName: event ? event.name : void 0,
|
|
1419
|
-
fromBlock,
|
|
1420
|
-
id,
|
|
1421
|
-
request: getRequest(id),
|
|
1422
|
-
strict: Boolean(strict),
|
|
1423
|
-
toBlock,
|
|
1424
|
-
type: "event"
|
|
1425
|
-
};
|
|
1426
|
-
}
|
|
1427
|
-
async function getBlobBaseFee(client) {
|
|
1428
|
-
const baseFee = await client.request({
|
|
1429
|
-
method: "eth_blobBaseFee"
|
|
1430
|
-
});
|
|
1431
|
-
return BigInt(baseFee);
|
|
1432
|
-
}
|
|
1433
|
-
async function getBlockTransactionCount(client, { blockHash, blockNumber, blockTag = "latest" } = {}) {
|
|
1434
|
-
const blockNumberHex = blockNumber !== void 0 ? numberToHex(blockNumber) : void 0;
|
|
1435
|
-
let count;
|
|
1436
|
-
if (blockHash) {
|
|
1437
|
-
count = await client.request({
|
|
1438
|
-
method: "eth_getBlockTransactionCountByHash",
|
|
1439
|
-
params: [blockHash]
|
|
1440
|
-
}, { dedupe: true });
|
|
1441
|
-
} else {
|
|
1442
|
-
count = await client.request({
|
|
1443
|
-
method: "eth_getBlockTransactionCountByNumber",
|
|
1444
|
-
params: [blockNumberHex || blockTag]
|
|
1445
|
-
}, { dedupe: Boolean(blockNumberHex) });
|
|
1446
|
-
}
|
|
1447
|
-
return hexToNumber(count);
|
|
1448
|
-
}
|
|
1449
|
-
async function getCode(client, { address, blockNumber, blockTag = "latest" }) {
|
|
1450
|
-
const blockNumberHex = blockNumber !== void 0 ? numberToHex(blockNumber) : void 0;
|
|
1451
|
-
const hex = await client.request({
|
|
1452
|
-
method: "eth_getCode",
|
|
1453
|
-
params: [address, blockNumberHex || blockTag]
|
|
1454
|
-
}, { dedupe: Boolean(blockNumberHex) });
|
|
1455
|
-
if (hex === "0x")
|
|
1456
|
-
return void 0;
|
|
1457
|
-
return hex;
|
|
1458
|
-
}
|
|
1459
|
-
class Eip712DomainNotFoundError extends BaseError {
|
|
1460
|
-
constructor({ address }) {
|
|
1461
|
-
super(`No EIP-712 domain found on contract "${address}".`, {
|
|
1462
|
-
metaMessages: [
|
|
1463
|
-
"Ensure that:",
|
|
1464
|
-
`- The contract is deployed at the address "${address}".`,
|
|
1465
|
-
"- `eip712Domain()` function exists on the contract.",
|
|
1466
|
-
"- `eip712Domain()` function matches signature to ERC-5267 specification."
|
|
1467
|
-
],
|
|
1468
|
-
name: "Eip712DomainNotFoundError"
|
|
1469
|
-
});
|
|
1470
|
-
}
|
|
1471
|
-
}
|
|
1472
|
-
async function getEip712Domain(client, parameters) {
|
|
1473
|
-
const { address, factory, factoryData } = parameters;
|
|
1474
|
-
try {
|
|
1475
|
-
const [fields, name, version, chainId, verifyingContract, salt, extensions] = await getAction(client, readContract, "readContract")({
|
|
1476
|
-
abi,
|
|
1477
|
-
address,
|
|
1478
|
-
functionName: "eip712Domain",
|
|
1479
|
-
factory,
|
|
1480
|
-
factoryData
|
|
1481
|
-
});
|
|
1482
|
-
return {
|
|
1483
|
-
domain: {
|
|
1484
|
-
name,
|
|
1485
|
-
version,
|
|
1486
|
-
chainId: Number(chainId),
|
|
1487
|
-
verifyingContract,
|
|
1488
|
-
salt
|
|
1489
|
-
},
|
|
1490
|
-
extensions,
|
|
1491
|
-
fields
|
|
1492
|
-
};
|
|
1493
|
-
} catch (e) {
|
|
1494
|
-
const error = e;
|
|
1495
|
-
if (error.name === "ContractFunctionExecutionError" && error.cause.name === "ContractFunctionZeroDataError") {
|
|
1496
|
-
throw new Eip712DomainNotFoundError({ address });
|
|
1497
|
-
}
|
|
1498
|
-
throw error;
|
|
1499
|
-
}
|
|
1500
|
-
}
|
|
1501
|
-
const abi = [
|
|
1502
|
-
{
|
|
1503
|
-
inputs: [],
|
|
1504
|
-
name: "eip712Domain",
|
|
1505
|
-
outputs: [
|
|
1506
|
-
{ name: "fields", type: "bytes1" },
|
|
1507
|
-
{ name: "name", type: "string" },
|
|
1508
|
-
{ name: "version", type: "string" },
|
|
1509
|
-
{ name: "chainId", type: "uint256" },
|
|
1510
|
-
{ name: "verifyingContract", type: "address" },
|
|
1511
|
-
{ name: "salt", type: "bytes32" },
|
|
1512
|
-
{ name: "extensions", type: "uint256[]" }
|
|
1513
|
-
],
|
|
1514
|
-
stateMutability: "view",
|
|
1515
|
-
type: "function"
|
|
1516
|
-
}
|
|
1517
|
-
];
|
|
1518
|
-
function formatFeeHistory(feeHistory) {
|
|
1519
|
-
var _a;
|
|
1520
|
-
return {
|
|
1521
|
-
baseFeePerGas: feeHistory.baseFeePerGas.map((value) => BigInt(value)),
|
|
1522
|
-
gasUsedRatio: feeHistory.gasUsedRatio,
|
|
1523
|
-
oldestBlock: BigInt(feeHistory.oldestBlock),
|
|
1524
|
-
reward: (_a = feeHistory.reward) == null ? void 0 : _a.map((reward) => reward.map((value) => BigInt(value)))
|
|
1525
|
-
};
|
|
1526
|
-
}
|
|
1527
|
-
async function getFeeHistory(client, { blockCount, blockNumber, blockTag = "latest", rewardPercentiles }) {
|
|
1528
|
-
const blockNumberHex = typeof blockNumber === "bigint" ? numberToHex(blockNumber) : void 0;
|
|
1529
|
-
const feeHistory = await client.request({
|
|
1530
|
-
method: "eth_feeHistory",
|
|
1531
|
-
params: [
|
|
1532
|
-
numberToHex(blockCount),
|
|
1533
|
-
blockNumberHex || blockTag,
|
|
1534
|
-
rewardPercentiles
|
|
1535
|
-
]
|
|
1536
|
-
}, { dedupe: Boolean(blockNumberHex) });
|
|
1537
|
-
return formatFeeHistory(feeHistory);
|
|
1538
|
-
}
|
|
1539
|
-
async function getFilterLogs(_client, { filter }) {
|
|
1540
|
-
const strict = filter.strict ?? false;
|
|
1541
|
-
const logs = await filter.request({
|
|
1542
|
-
method: "eth_getFilterLogs",
|
|
1543
|
-
params: [filter.id]
|
|
1544
|
-
});
|
|
1545
|
-
const formattedLogs = logs.map((log) => formatLog(log));
|
|
1546
|
-
if (!filter.abi)
|
|
1547
|
-
return formattedLogs;
|
|
1548
|
-
return parseEventLogs({
|
|
1549
|
-
abi: filter.abi,
|
|
1550
|
-
logs: formattedLogs,
|
|
1551
|
-
strict
|
|
1552
|
-
});
|
|
1553
|
-
}
|
|
1554
|
-
function encodePacked$1(types, values) {
|
|
1555
|
-
if (types.length !== values.length)
|
|
1556
|
-
throw new AbiEncodingLengthMismatchError({
|
|
1557
|
-
expectedLength: types.length,
|
|
1558
|
-
givenLength: values.length
|
|
1559
|
-
});
|
|
1560
|
-
const data = [];
|
|
1561
|
-
for (let i = 0; i < types.length; i++) {
|
|
1562
|
-
const type = types[i];
|
|
1563
|
-
const value = values[i];
|
|
1564
|
-
data.push(encode$3(type, value));
|
|
1565
|
-
}
|
|
1566
|
-
return concatHex(data);
|
|
1567
|
-
}
|
|
1568
|
-
function encode$3(type, value, isArray = false) {
|
|
1569
|
-
if (type === "address") {
|
|
1570
|
-
const address = value;
|
|
1571
|
-
if (!isAddress(address))
|
|
1572
|
-
throw new InvalidAddressError$1({ address });
|
|
1573
|
-
return pad$1(address.toLowerCase(), {
|
|
1574
|
-
size: isArray ? 32 : null
|
|
1575
|
-
});
|
|
1576
|
-
}
|
|
1577
|
-
if (type === "string")
|
|
1578
|
-
return stringToHex(value);
|
|
1579
|
-
if (type === "bytes")
|
|
1580
|
-
return value;
|
|
1581
|
-
if (type === "bool")
|
|
1582
|
-
return pad$1(boolToHex(value), { size: isArray ? 32 : 1 });
|
|
1583
|
-
const intMatch = type.match(integerRegex$1);
|
|
1584
|
-
if (intMatch) {
|
|
1585
|
-
const [_type, baseType, bits = "256"] = intMatch;
|
|
1586
|
-
const size2 = Number.parseInt(bits, 10) / 8;
|
|
1587
|
-
return numberToHex(value, {
|
|
1588
|
-
size: isArray ? 32 : size2,
|
|
1589
|
-
signed: baseType === "int"
|
|
1590
|
-
});
|
|
1591
|
-
}
|
|
1592
|
-
const bytesMatch = type.match(bytesRegex$1);
|
|
1593
|
-
if (bytesMatch) {
|
|
1594
|
-
const [_type, size2] = bytesMatch;
|
|
1595
|
-
if (Number.parseInt(size2, 10) !== (value.length - 2) / 2)
|
|
1596
|
-
throw new BytesSizeMismatchError$1({
|
|
1597
|
-
expectedSize: Number.parseInt(size2, 10),
|
|
1598
|
-
givenSize: (value.length - 2) / 2
|
|
1599
|
-
});
|
|
1600
|
-
return pad$1(value, { dir: "right", size: isArray ? 32 : null });
|
|
1601
|
-
}
|
|
1602
|
-
const arrayMatch = type.match(arrayRegex$1);
|
|
1603
|
-
if (arrayMatch && Array.isArray(value)) {
|
|
1604
|
-
const [_type, childType] = arrayMatch;
|
|
1605
|
-
const data = [];
|
|
1606
|
-
for (let i = 0; i < value.length; i++) {
|
|
1607
|
-
data.push(encode$3(childType, value[i], true));
|
|
1608
|
-
}
|
|
1609
|
-
if (data.length === 0)
|
|
1610
|
-
return "0x";
|
|
1611
|
-
return concatHex(data);
|
|
1612
|
-
}
|
|
1613
|
-
throw new UnsupportedPackedAbiType(type);
|
|
1614
|
-
}
|
|
1615
|
-
async function verifyAuthorization({ address, authorization, signature }) {
|
|
1616
|
-
return isAddressEqual(getAddress(address), await recoverAuthorizationAddress({
|
|
1617
|
-
authorization,
|
|
1618
|
-
signature
|
|
1619
|
-
}));
|
|
1620
|
-
}
|
|
1621
|
-
function createNonceManager(parameters) {
|
|
1622
|
-
const { source } = parameters;
|
|
1623
|
-
const deltaMap = /* @__PURE__ */ new Map();
|
|
1624
|
-
const nonceMap = new LruMap$1(8192);
|
|
1625
|
-
const promiseMap = /* @__PURE__ */ new Map();
|
|
1626
|
-
const getKey = ({ address, chainId }) => `${address}.${chainId}`;
|
|
1627
|
-
return {
|
|
1628
|
-
async consume({ address, chainId, client }) {
|
|
1629
|
-
const key = getKey({ address, chainId });
|
|
1630
|
-
const promise = this.get({ address, chainId, client });
|
|
1631
|
-
this.increment({ address, chainId });
|
|
1632
|
-
const nonce = await promise;
|
|
1633
|
-
await source.set({ address, chainId }, nonce);
|
|
1634
|
-
nonceMap.set(key, nonce);
|
|
1635
|
-
return nonce;
|
|
1636
|
-
},
|
|
1637
|
-
async increment({ address, chainId }) {
|
|
1638
|
-
const key = getKey({ address, chainId });
|
|
1639
|
-
const delta = deltaMap.get(key) ?? 0;
|
|
1640
|
-
deltaMap.set(key, delta + 1);
|
|
1641
|
-
},
|
|
1642
|
-
async get({ address, chainId, client }) {
|
|
1643
|
-
const key = getKey({ address, chainId });
|
|
1644
|
-
let promise = promiseMap.get(key);
|
|
1645
|
-
if (!promise) {
|
|
1646
|
-
promise = (async () => {
|
|
1647
|
-
try {
|
|
1648
|
-
const nonce = await source.get({ address, chainId, client });
|
|
1649
|
-
const previousNonce = nonceMap.get(key) ?? 0;
|
|
1650
|
-
if (previousNonce > 0 && nonce <= previousNonce)
|
|
1651
|
-
return previousNonce + 1;
|
|
1652
|
-
nonceMap.delete(key);
|
|
1653
|
-
return nonce;
|
|
1654
|
-
} finally {
|
|
1655
|
-
this.reset({ address, chainId });
|
|
1656
|
-
}
|
|
1657
|
-
})();
|
|
1658
|
-
promiseMap.set(key, promise);
|
|
1659
|
-
}
|
|
1660
|
-
const delta = deltaMap.get(key) ?? 0;
|
|
1661
|
-
return delta + await promise;
|
|
1662
|
-
},
|
|
1663
|
-
reset({ address, chainId }) {
|
|
1664
|
-
const key = getKey({ address, chainId });
|
|
1665
|
-
deltaMap.delete(key);
|
|
1666
|
-
promiseMap.delete(key);
|
|
1667
|
-
}
|
|
1668
|
-
};
|
|
1669
|
-
}
|
|
1670
|
-
function jsonRpc() {
|
|
1671
|
-
return {
|
|
1672
|
-
async get(parameters) {
|
|
1673
|
-
const { address, client } = parameters;
|
|
1674
|
-
return getTransactionCount(client, {
|
|
1675
|
-
address,
|
|
1676
|
-
blockTag: "pending"
|
|
1677
|
-
});
|
|
1678
|
-
},
|
|
1679
|
-
set() {
|
|
1680
|
-
}
|
|
1681
|
-
};
|
|
1682
|
-
}
|
|
1683
|
-
const nonceManager = /* @__PURE__ */ createNonceManager({
|
|
1684
|
-
source: jsonRpc()
|
|
1685
|
-
});
|
|
1686
|
-
function createIdStore() {
|
|
1687
|
-
return {
|
|
1688
|
-
current: 0,
|
|
1689
|
-
take() {
|
|
1690
|
-
return this.current++;
|
|
1691
|
-
},
|
|
1692
|
-
reset() {
|
|
1693
|
-
this.current = 0;
|
|
1694
|
-
}
|
|
1695
|
-
};
|
|
1696
|
-
}
|
|
1697
|
-
const idCache = /* @__PURE__ */ createIdStore();
|
|
1698
|
-
function getHttpRpcClient(url, options = {}) {
|
|
1699
|
-
return {
|
|
1700
|
-
async request(params) {
|
|
1701
|
-
var _a;
|
|
1702
|
-
const { body, fetchFn = options.fetchFn ?? fetch, onRequest = options.onRequest, onResponse = options.onResponse, timeout = options.timeout ?? 1e4 } = params;
|
|
1703
|
-
const fetchOptions = {
|
|
1704
|
-
...options.fetchOptions ?? {},
|
|
1705
|
-
...params.fetchOptions ?? {}
|
|
1706
|
-
};
|
|
1707
|
-
const { headers, method, signal: signal_ } = fetchOptions;
|
|
1708
|
-
try {
|
|
1709
|
-
const response = await withTimeout(async ({ signal }) => {
|
|
1710
|
-
const init = {
|
|
1711
|
-
...fetchOptions,
|
|
1712
|
-
body: Array.isArray(body) ? stringify$1(body.map((body2) => ({
|
|
1713
|
-
jsonrpc: "2.0",
|
|
1714
|
-
id: body2.id ?? idCache.take(),
|
|
1715
|
-
...body2
|
|
1716
|
-
}))) : stringify$1({
|
|
1717
|
-
jsonrpc: "2.0",
|
|
1718
|
-
id: body.id ?? idCache.take(),
|
|
1719
|
-
...body
|
|
1720
|
-
}),
|
|
1721
|
-
headers: {
|
|
1722
|
-
"Content-Type": "application/json",
|
|
1723
|
-
...headers
|
|
1724
|
-
},
|
|
1725
|
-
method: method || "POST",
|
|
1726
|
-
signal: signal_ || (timeout > 0 ? signal : null)
|
|
1727
|
-
};
|
|
1728
|
-
const request = new Request(url, init);
|
|
1729
|
-
const args = await (onRequest == null ? void 0 : onRequest(request, init)) ?? { ...init, url };
|
|
1730
|
-
const response2 = await fetchFn(args.url ?? url, args);
|
|
1731
|
-
return response2;
|
|
1732
|
-
}, {
|
|
1733
|
-
errorInstance: new TimeoutError({ body, url }),
|
|
1734
|
-
timeout,
|
|
1735
|
-
signal: true
|
|
1736
|
-
});
|
|
1737
|
-
if (onResponse)
|
|
1738
|
-
await onResponse(response);
|
|
1739
|
-
let data;
|
|
1740
|
-
if ((_a = response.headers.get("Content-Type")) == null ? void 0 : _a.startsWith("application/json"))
|
|
1741
|
-
data = await response.json();
|
|
1742
|
-
else {
|
|
1743
|
-
data = await response.text();
|
|
1744
|
-
try {
|
|
1745
|
-
data = JSON.parse(data || "{}");
|
|
1746
|
-
} catch (err) {
|
|
1747
|
-
if (response.ok)
|
|
1748
|
-
throw err;
|
|
1749
|
-
data = { error: data };
|
|
1750
|
-
}
|
|
1751
|
-
}
|
|
1752
|
-
if (!response.ok) {
|
|
1753
|
-
throw new HttpRequestError({
|
|
1754
|
-
body,
|
|
1755
|
-
details: stringify$1(data.error) || response.statusText,
|
|
1756
|
-
headers: response.headers,
|
|
1757
|
-
status: response.status,
|
|
1758
|
-
url
|
|
1759
|
-
});
|
|
1760
|
-
}
|
|
1761
|
-
return data;
|
|
1762
|
-
} catch (err) {
|
|
1763
|
-
if (err instanceof HttpRequestError)
|
|
1764
|
-
throw err;
|
|
1765
|
-
if (err instanceof TimeoutError)
|
|
1766
|
-
throw err;
|
|
1767
|
-
throw new HttpRequestError({
|
|
1768
|
-
body,
|
|
1769
|
-
cause: err,
|
|
1770
|
-
url
|
|
1771
|
-
});
|
|
1772
|
-
}
|
|
1773
|
-
}
|
|
1774
|
-
};
|
|
1775
|
-
}
|
|
1776
|
-
const erc6492MagicBytes = "0x6492649264926492649264926492649264926492649264926492649264926492";
|
|
1777
|
-
const zeroHash = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
1778
|
-
class LruMap extends Map {
|
|
1779
|
-
constructor(size2) {
|
|
1780
|
-
super();
|
|
1781
|
-
Object.defineProperty(this, "maxSize", {
|
|
1782
|
-
enumerable: true,
|
|
1783
|
-
configurable: true,
|
|
1784
|
-
writable: true,
|
|
1785
|
-
value: void 0
|
|
1786
|
-
});
|
|
1787
|
-
this.maxSize = size2;
|
|
1788
|
-
}
|
|
1789
|
-
get(key) {
|
|
1790
|
-
const value = super.get(key);
|
|
1791
|
-
if (super.has(key) && value !== void 0) {
|
|
1792
|
-
this.delete(key);
|
|
1793
|
-
super.set(key, value);
|
|
1794
|
-
}
|
|
1795
|
-
return value;
|
|
1796
|
-
}
|
|
1797
|
-
set(key, value) {
|
|
1798
|
-
super.set(key, value);
|
|
1799
|
-
if (this.maxSize && this.size > this.maxSize) {
|
|
1800
|
-
const firstKey = this.keys().next().value;
|
|
1801
|
-
if (firstKey)
|
|
1802
|
-
this.delete(firstKey);
|
|
1803
|
-
}
|
|
1804
|
-
return this;
|
|
1805
|
-
}
|
|
1806
|
-
}
|
|
1807
|
-
const caches = {
|
|
1808
|
-
checksum: /* @__PURE__ */ new LruMap(8192)
|
|
1809
|
-
};
|
|
1810
|
-
const checksum$1 = caches.checksum;
|
|
1811
|
-
function keccak256(value, options = {}) {
|
|
1812
|
-
const { as = typeof value === "string" ? "Hex" : "Bytes" } = options;
|
|
1813
|
-
const bytes = keccak_256(from$9(value));
|
|
1814
|
-
if (as === "Bytes")
|
|
1815
|
-
return bytes;
|
|
1816
|
-
return fromBytes$2(bytes);
|
|
1817
|
-
}
|
|
1818
|
-
function assert$4(publicKey, options = {}) {
|
|
1819
|
-
const { compressed } = options;
|
|
1820
|
-
const { prefix, x, y } = publicKey;
|
|
1821
|
-
if (compressed === false || typeof x === "bigint" && typeof y === "bigint") {
|
|
1822
|
-
if (prefix !== 4)
|
|
1823
|
-
throw new InvalidPrefixError({
|
|
1824
|
-
prefix,
|
|
1825
|
-
cause: new InvalidUncompressedPrefixError()
|
|
1826
|
-
});
|
|
1827
|
-
return;
|
|
1828
|
-
}
|
|
1829
|
-
if (compressed === true || typeof x === "bigint" && typeof y === "undefined") {
|
|
1830
|
-
if (prefix !== 3 && prefix !== 2)
|
|
1831
|
-
throw new InvalidPrefixError({
|
|
1832
|
-
prefix,
|
|
1833
|
-
cause: new InvalidCompressedPrefixError()
|
|
1834
|
-
});
|
|
1835
|
-
return;
|
|
1836
|
-
}
|
|
1837
|
-
throw new InvalidError({ publicKey });
|
|
1838
|
-
}
|
|
1839
|
-
function from$8(value) {
|
|
1840
|
-
const publicKey = (() => {
|
|
1841
|
-
if (validate$4(value))
|
|
1842
|
-
return fromHex$2(value);
|
|
1843
|
-
if (validate$3(value))
|
|
1844
|
-
return fromBytes$1(value);
|
|
1845
|
-
const { prefix, x, y } = value;
|
|
1846
|
-
if (typeof x === "bigint" && typeof y === "bigint")
|
|
1847
|
-
return { prefix: prefix ?? 4, x, y };
|
|
1848
|
-
return { prefix, x };
|
|
1849
|
-
})();
|
|
1850
|
-
assert$4(publicKey);
|
|
1851
|
-
return publicKey;
|
|
1852
|
-
}
|
|
1853
|
-
function fromBytes$1(publicKey) {
|
|
1854
|
-
return fromHex$2(fromBytes$2(publicKey));
|
|
1855
|
-
}
|
|
1856
|
-
function fromHex$2(publicKey) {
|
|
1857
|
-
if (publicKey.length !== 132 && publicKey.length !== 130 && publicKey.length !== 68)
|
|
1858
|
-
throw new InvalidSerializedSizeError$1({ publicKey });
|
|
1859
|
-
if (publicKey.length === 130) {
|
|
1860
|
-
const x2 = BigInt(slice$1(publicKey, 0, 32));
|
|
1861
|
-
const y = BigInt(slice$1(publicKey, 32, 64));
|
|
1862
|
-
return {
|
|
1863
|
-
prefix: 4,
|
|
1864
|
-
x: x2,
|
|
1865
|
-
y
|
|
1866
|
-
};
|
|
1867
|
-
}
|
|
1868
|
-
if (publicKey.length === 132) {
|
|
1869
|
-
const prefix2 = Number(slice$1(publicKey, 0, 1));
|
|
1870
|
-
const x2 = BigInt(slice$1(publicKey, 1, 33));
|
|
1871
|
-
const y = BigInt(slice$1(publicKey, 33, 65));
|
|
1872
|
-
return {
|
|
1873
|
-
prefix: prefix2,
|
|
1874
|
-
x: x2,
|
|
1875
|
-
y
|
|
1876
|
-
};
|
|
1877
|
-
}
|
|
1878
|
-
const prefix = Number(slice$1(publicKey, 0, 1));
|
|
1879
|
-
const x = BigInt(slice$1(publicKey, 1, 33));
|
|
1880
|
-
return {
|
|
1881
|
-
prefix,
|
|
1882
|
-
x
|
|
1883
|
-
};
|
|
1884
|
-
}
|
|
1885
|
-
function toHex(publicKey, options = {}) {
|
|
1886
|
-
assert$4(publicKey);
|
|
1887
|
-
const { prefix, x, y } = publicKey;
|
|
1888
|
-
const { includePrefix = true } = options;
|
|
1889
|
-
const publicKey_ = concat$1(
|
|
1890
|
-
includePrefix ? fromNumber(prefix, { size: 1 }) : "0x",
|
|
1891
|
-
fromNumber(x, { size: 32 }),
|
|
1892
|
-
// If the public key is not compressed, add the y coordinate.
|
|
1893
|
-
typeof y === "bigint" ? fromNumber(y, { size: 32 }) : "0x"
|
|
1894
|
-
);
|
|
1895
|
-
return publicKey_;
|
|
1896
|
-
}
|
|
1897
|
-
class InvalidError extends BaseError$1 {
|
|
1898
|
-
constructor({ publicKey }) {
|
|
1899
|
-
super(`Value \`${stringify(publicKey)}\` is not a valid public key.`, {
|
|
1900
|
-
metaMessages: [
|
|
1901
|
-
"Public key must contain:",
|
|
1902
|
-
"- an `x` and `prefix` value (compressed)",
|
|
1903
|
-
"- an `x`, `y`, and `prefix` value (uncompressed)"
|
|
1904
|
-
]
|
|
1905
|
-
});
|
|
1906
|
-
Object.defineProperty(this, "name", {
|
|
1907
|
-
enumerable: true,
|
|
1908
|
-
configurable: true,
|
|
1909
|
-
writable: true,
|
|
1910
|
-
value: "PublicKey.InvalidError"
|
|
1911
|
-
});
|
|
1912
|
-
}
|
|
1913
|
-
}
|
|
1914
|
-
class InvalidPrefixError extends BaseError$1 {
|
|
1915
|
-
constructor({ prefix, cause }) {
|
|
1916
|
-
super(`Prefix "${prefix}" is invalid.`, {
|
|
1917
|
-
cause
|
|
1918
|
-
});
|
|
1919
|
-
Object.defineProperty(this, "name", {
|
|
1920
|
-
enumerable: true,
|
|
1921
|
-
configurable: true,
|
|
1922
|
-
writable: true,
|
|
1923
|
-
value: "PublicKey.InvalidPrefixError"
|
|
1924
|
-
});
|
|
1925
|
-
}
|
|
1926
|
-
}
|
|
1927
|
-
class InvalidCompressedPrefixError extends BaseError$1 {
|
|
1928
|
-
constructor() {
|
|
1929
|
-
super("Prefix must be 2 or 3 for compressed public keys.");
|
|
1930
|
-
Object.defineProperty(this, "name", {
|
|
1931
|
-
enumerable: true,
|
|
1932
|
-
configurable: true,
|
|
1933
|
-
writable: true,
|
|
1934
|
-
value: "PublicKey.InvalidCompressedPrefixError"
|
|
1935
|
-
});
|
|
1936
|
-
}
|
|
1937
|
-
}
|
|
1938
|
-
class InvalidUncompressedPrefixError extends BaseError$1 {
|
|
1939
|
-
constructor() {
|
|
1940
|
-
super("Prefix must be 4 for uncompressed public keys.");
|
|
1941
|
-
Object.defineProperty(this, "name", {
|
|
1942
|
-
enumerable: true,
|
|
1943
|
-
configurable: true,
|
|
1944
|
-
writable: true,
|
|
1945
|
-
value: "PublicKey.InvalidUncompressedPrefixError"
|
|
1946
|
-
});
|
|
1947
|
-
}
|
|
1948
|
-
}
|
|
1949
|
-
let InvalidSerializedSizeError$1 = class InvalidSerializedSizeError extends BaseError$1 {
|
|
1950
|
-
constructor({ publicKey }) {
|
|
1951
|
-
super(`Value \`${publicKey}\` is an invalid public key size.`, {
|
|
1952
|
-
metaMessages: [
|
|
1953
|
-
"Expected: 33 bytes (compressed + prefix), 64 bytes (uncompressed) or 65 bytes (uncompressed + prefix).",
|
|
1954
|
-
`Received ${size$1(from$a(publicKey))} bytes.`
|
|
1955
|
-
]
|
|
1956
|
-
});
|
|
1957
|
-
Object.defineProperty(this, "name", {
|
|
1958
|
-
enumerable: true,
|
|
1959
|
-
configurable: true,
|
|
1960
|
-
writable: true,
|
|
1961
|
-
value: "PublicKey.InvalidSerializedSizeError"
|
|
1962
|
-
});
|
|
1963
|
-
}
|
|
1964
|
-
};
|
|
1965
|
-
const addressRegex = /^0x[a-fA-F0-9]{40}$/;
|
|
1966
|
-
function assert$3(value, options = {}) {
|
|
1967
|
-
const { strict = true } = options;
|
|
1968
|
-
if (!addressRegex.test(value))
|
|
1969
|
-
throw new InvalidAddressError({
|
|
1970
|
-
address: value,
|
|
1971
|
-
cause: new InvalidInputError()
|
|
1972
|
-
});
|
|
1973
|
-
if (strict) {
|
|
1974
|
-
if (value.toLowerCase() === value)
|
|
1975
|
-
return;
|
|
1976
|
-
if (checksum(value) !== value)
|
|
1977
|
-
throw new InvalidAddressError({
|
|
1978
|
-
address: value,
|
|
1979
|
-
cause: new InvalidChecksumError()
|
|
1980
|
-
});
|
|
1981
|
-
}
|
|
1982
|
-
}
|
|
1983
|
-
function checksum(address) {
|
|
1984
|
-
if (checksum$1.has(address))
|
|
1985
|
-
return checksum$1.get(address);
|
|
1986
|
-
assert$3(address, { strict: false });
|
|
1987
|
-
const hexAddress = address.substring(2).toLowerCase();
|
|
1988
|
-
const hash2 = keccak256(fromString(hexAddress), { as: "Bytes" });
|
|
1989
|
-
const characters = hexAddress.split("");
|
|
1990
|
-
for (let i = 0; i < 40; i += 2) {
|
|
1991
|
-
if (hash2[i >> 1] >> 4 >= 8 && characters[i]) {
|
|
1992
|
-
characters[i] = characters[i].toUpperCase();
|
|
1993
|
-
}
|
|
1994
|
-
if ((hash2[i >> 1] & 15) >= 8 && characters[i + 1]) {
|
|
1995
|
-
characters[i + 1] = characters[i + 1].toUpperCase();
|
|
1996
|
-
}
|
|
1997
|
-
}
|
|
1998
|
-
const result = `0x${characters.join("")}`;
|
|
1999
|
-
checksum$1.set(address, result);
|
|
2000
|
-
return result;
|
|
2001
|
-
}
|
|
2002
|
-
function from$7(address, options = {}) {
|
|
2003
|
-
const { checksum: checksumVal = false } = options;
|
|
2004
|
-
assert$3(address);
|
|
2005
|
-
if (checksumVal)
|
|
2006
|
-
return checksum(address);
|
|
2007
|
-
return address;
|
|
2008
|
-
}
|
|
2009
|
-
function fromPublicKey(publicKey, options = {}) {
|
|
2010
|
-
const address = keccak256(`0x${toHex(publicKey).slice(4)}`).substring(26);
|
|
2011
|
-
return from$7(`0x${address}`, options);
|
|
2012
|
-
}
|
|
2013
|
-
function validate$2(address, options = {}) {
|
|
2014
|
-
const { strict = true } = options ?? {};
|
|
2015
|
-
try {
|
|
2016
|
-
assert$3(address, { strict });
|
|
2017
|
-
return true;
|
|
2018
|
-
} catch {
|
|
2019
|
-
return false;
|
|
2020
|
-
}
|
|
2021
|
-
}
|
|
2022
|
-
class InvalidAddressError extends BaseError$1 {
|
|
2023
|
-
constructor({ address, cause }) {
|
|
2024
|
-
super(`Address "${address}" is invalid.`, {
|
|
2025
|
-
cause
|
|
2026
|
-
});
|
|
2027
|
-
Object.defineProperty(this, "name", {
|
|
2028
|
-
enumerable: true,
|
|
2029
|
-
configurable: true,
|
|
2030
|
-
writable: true,
|
|
2031
|
-
value: "Address.InvalidAddressError"
|
|
2032
|
-
});
|
|
2033
|
-
}
|
|
2034
|
-
}
|
|
2035
|
-
class InvalidInputError extends BaseError$1 {
|
|
2036
|
-
constructor() {
|
|
2037
|
-
super("Address is not a 20 byte (40 hexadecimal character) value.");
|
|
2038
|
-
Object.defineProperty(this, "name", {
|
|
2039
|
-
enumerable: true,
|
|
2040
|
-
configurable: true,
|
|
2041
|
-
writable: true,
|
|
2042
|
-
value: "Address.InvalidInputError"
|
|
2043
|
-
});
|
|
2044
|
-
}
|
|
2045
|
-
}
|
|
2046
|
-
class InvalidChecksumError extends BaseError$1 {
|
|
2047
|
-
constructor() {
|
|
2048
|
-
super("Address does not match its checksum counterpart.");
|
|
2049
|
-
Object.defineProperty(this, "name", {
|
|
2050
|
-
enumerable: true,
|
|
2051
|
-
configurable: true,
|
|
2052
|
-
writable: true,
|
|
2053
|
-
value: "Address.InvalidChecksumError"
|
|
2054
|
-
});
|
|
2055
|
-
}
|
|
2056
|
-
}
|
|
2057
|
-
const arrayRegex = /^(.*)\[([0-9]*)\]$/;
|
|
2058
|
-
const bytesRegex = /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/;
|
|
2059
|
-
const integerRegex = /^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;
|
|
2060
|
-
const maxUint256 = 2n ** 256n - 1n;
|
|
2061
|
-
function decodeParameter(cursor, param, options) {
|
|
2062
|
-
const { checksumAddress, staticPosition } = options;
|
|
2063
|
-
const arrayComponents = getArrayComponents(param.type);
|
|
2064
|
-
if (arrayComponents) {
|
|
2065
|
-
const [length, type] = arrayComponents;
|
|
2066
|
-
return decodeArray(cursor, { ...param, type }, { checksumAddress, length, staticPosition });
|
|
2067
|
-
}
|
|
2068
|
-
if (param.type === "tuple")
|
|
2069
|
-
return decodeTuple(cursor, param, {
|
|
2070
|
-
checksumAddress,
|
|
2071
|
-
staticPosition
|
|
2072
|
-
});
|
|
2073
|
-
if (param.type === "address")
|
|
2074
|
-
return decodeAddress(cursor, { checksum: checksumAddress });
|
|
2075
|
-
if (param.type === "bool")
|
|
2076
|
-
return decodeBool(cursor);
|
|
2077
|
-
if (param.type.startsWith("bytes"))
|
|
2078
|
-
return decodeBytes(cursor, param, { staticPosition });
|
|
2079
|
-
if (param.type.startsWith("uint") || param.type.startsWith("int"))
|
|
2080
|
-
return decodeNumber(cursor, param);
|
|
2081
|
-
if (param.type === "string")
|
|
2082
|
-
return decodeString(cursor, { staticPosition });
|
|
2083
|
-
throw new InvalidTypeError(param.type);
|
|
2084
|
-
}
|
|
2085
|
-
const sizeOfLength = 32;
|
|
2086
|
-
const sizeOfOffset = 32;
|
|
2087
|
-
function decodeAddress(cursor, options = {}) {
|
|
2088
|
-
const { checksum: checksum$12 = false } = options;
|
|
2089
|
-
const value = cursor.readBytes(32);
|
|
2090
|
-
const wrap2 = (address) => checksum$12 ? checksum(address) : address;
|
|
2091
|
-
return [wrap2(fromBytes$2(slice(value, -20))), 32];
|
|
2092
|
-
}
|
|
2093
|
-
function decodeArray(cursor, param, options) {
|
|
2094
|
-
const { checksumAddress, length, staticPosition } = options;
|
|
2095
|
-
if (!length) {
|
|
2096
|
-
const offset = toNumber(cursor.readBytes(sizeOfOffset));
|
|
2097
|
-
const start = staticPosition + offset;
|
|
2098
|
-
const startOfData = start + sizeOfLength;
|
|
2099
|
-
cursor.setPosition(start);
|
|
2100
|
-
const length2 = toNumber(cursor.readBytes(sizeOfLength));
|
|
2101
|
-
const dynamicChild = hasDynamicChild(param);
|
|
2102
|
-
let consumed2 = 0;
|
|
2103
|
-
const value2 = [];
|
|
2104
|
-
for (let i = 0; i < length2; ++i) {
|
|
2105
|
-
cursor.setPosition(startOfData + (dynamicChild ? i * 32 : consumed2));
|
|
2106
|
-
const [data, consumed_] = decodeParameter(cursor, param, {
|
|
2107
|
-
checksumAddress,
|
|
2108
|
-
staticPosition: startOfData
|
|
2109
|
-
});
|
|
2110
|
-
consumed2 += consumed_;
|
|
2111
|
-
value2.push(data);
|
|
2112
|
-
}
|
|
2113
|
-
cursor.setPosition(staticPosition + 32);
|
|
2114
|
-
return [value2, 32];
|
|
2115
|
-
}
|
|
2116
|
-
if (hasDynamicChild(param)) {
|
|
2117
|
-
const offset = toNumber(cursor.readBytes(sizeOfOffset));
|
|
2118
|
-
const start = staticPosition + offset;
|
|
2119
|
-
const value2 = [];
|
|
2120
|
-
for (let i = 0; i < length; ++i) {
|
|
2121
|
-
cursor.setPosition(start + i * 32);
|
|
2122
|
-
const [data] = decodeParameter(cursor, param, {
|
|
2123
|
-
checksumAddress,
|
|
2124
|
-
staticPosition: start
|
|
2125
|
-
});
|
|
2126
|
-
value2.push(data);
|
|
2127
|
-
}
|
|
2128
|
-
cursor.setPosition(staticPosition + 32);
|
|
2129
|
-
return [value2, 32];
|
|
2130
|
-
}
|
|
2131
|
-
let consumed = 0;
|
|
2132
|
-
const value = [];
|
|
2133
|
-
for (let i = 0; i < length; ++i) {
|
|
2134
|
-
const [data, consumed_] = decodeParameter(cursor, param, {
|
|
2135
|
-
checksumAddress,
|
|
2136
|
-
staticPosition: staticPosition + consumed
|
|
2137
|
-
});
|
|
2138
|
-
consumed += consumed_;
|
|
2139
|
-
value.push(data);
|
|
2140
|
-
}
|
|
2141
|
-
return [value, consumed];
|
|
2142
|
-
}
|
|
2143
|
-
function decodeBool(cursor) {
|
|
2144
|
-
return [toBoolean(cursor.readBytes(32), { size: 32 }), 32];
|
|
2145
|
-
}
|
|
2146
|
-
function decodeBytes(cursor, param, { staticPosition }) {
|
|
2147
|
-
const [_, size2] = param.type.split("bytes");
|
|
2148
|
-
if (!size2) {
|
|
2149
|
-
const offset = toNumber(cursor.readBytes(32));
|
|
2150
|
-
cursor.setPosition(staticPosition + offset);
|
|
2151
|
-
const length = toNumber(cursor.readBytes(32));
|
|
2152
|
-
if (length === 0) {
|
|
2153
|
-
cursor.setPosition(staticPosition + 32);
|
|
2154
|
-
return ["0x", 32];
|
|
2155
|
-
}
|
|
2156
|
-
const data = cursor.readBytes(length);
|
|
2157
|
-
cursor.setPosition(staticPosition + 32);
|
|
2158
|
-
return [fromBytes$2(data), 32];
|
|
2159
|
-
}
|
|
2160
|
-
const value = fromBytes$2(cursor.readBytes(Number.parseInt(size2, 10), 32));
|
|
2161
|
-
return [value, 32];
|
|
2162
|
-
}
|
|
2163
|
-
function decodeNumber(cursor, param) {
|
|
2164
|
-
const signed = param.type.startsWith("int");
|
|
2165
|
-
const size2 = Number.parseInt(param.type.split("int")[1] || "256", 10);
|
|
2166
|
-
const value = cursor.readBytes(32);
|
|
2167
|
-
return [
|
|
2168
|
-
size2 > 48 ? toBigInt(value, { signed }) : toNumber(value, { signed }),
|
|
2169
|
-
32
|
|
2170
|
-
];
|
|
2171
|
-
}
|
|
2172
|
-
function decodeTuple(cursor, param, options) {
|
|
2173
|
-
const { checksumAddress, staticPosition } = options;
|
|
2174
|
-
const hasUnnamedChild = param.components.length === 0 || param.components.some(({ name }) => !name);
|
|
2175
|
-
const value = hasUnnamedChild ? [] : {};
|
|
2176
|
-
let consumed = 0;
|
|
2177
|
-
if (hasDynamicChild(param)) {
|
|
2178
|
-
const offset = toNumber(cursor.readBytes(sizeOfOffset));
|
|
2179
|
-
const start = staticPosition + offset;
|
|
2180
|
-
for (let i = 0; i < param.components.length; ++i) {
|
|
2181
|
-
const component = param.components[i];
|
|
2182
|
-
cursor.setPosition(start + consumed);
|
|
2183
|
-
const [data, consumed_] = decodeParameter(cursor, component, {
|
|
2184
|
-
checksumAddress,
|
|
2185
|
-
staticPosition: start
|
|
2186
|
-
});
|
|
2187
|
-
consumed += consumed_;
|
|
2188
|
-
value[hasUnnamedChild ? i : component == null ? void 0 : component.name] = data;
|
|
2189
|
-
}
|
|
2190
|
-
cursor.setPosition(staticPosition + 32);
|
|
2191
|
-
return [value, 32];
|
|
2192
|
-
}
|
|
2193
|
-
for (let i = 0; i < param.components.length; ++i) {
|
|
2194
|
-
const component = param.components[i];
|
|
2195
|
-
const [data, consumed_] = decodeParameter(cursor, component, {
|
|
2196
|
-
checksumAddress,
|
|
2197
|
-
staticPosition
|
|
2198
|
-
});
|
|
2199
|
-
value[hasUnnamedChild ? i : component == null ? void 0 : component.name] = data;
|
|
2200
|
-
consumed += consumed_;
|
|
2201
|
-
}
|
|
2202
|
-
return [value, consumed];
|
|
2203
|
-
}
|
|
2204
|
-
function decodeString(cursor, { staticPosition }) {
|
|
2205
|
-
const offset = toNumber(cursor.readBytes(32));
|
|
2206
|
-
const start = staticPosition + offset;
|
|
2207
|
-
cursor.setPosition(start);
|
|
2208
|
-
const length = toNumber(cursor.readBytes(32));
|
|
2209
|
-
if (length === 0) {
|
|
2210
|
-
cursor.setPosition(staticPosition + 32);
|
|
2211
|
-
return ["", 32];
|
|
2212
|
-
}
|
|
2213
|
-
const data = cursor.readBytes(length, 32);
|
|
2214
|
-
const value = toString(trimLeft(data));
|
|
2215
|
-
cursor.setPosition(staticPosition + 32);
|
|
2216
|
-
return [value, 32];
|
|
2217
|
-
}
|
|
2218
|
-
function prepareParameters({ checksumAddress, parameters, values }) {
|
|
2219
|
-
const preparedParameters = [];
|
|
2220
|
-
for (let i = 0; i < parameters.length; i++) {
|
|
2221
|
-
preparedParameters.push(prepareParameter({
|
|
2222
|
-
checksumAddress,
|
|
2223
|
-
parameter: parameters[i],
|
|
2224
|
-
value: values[i]
|
|
2225
|
-
}));
|
|
2226
|
-
}
|
|
2227
|
-
return preparedParameters;
|
|
2228
|
-
}
|
|
2229
|
-
function prepareParameter({ checksumAddress = false, parameter: parameter_, value }) {
|
|
2230
|
-
const parameter = parameter_;
|
|
2231
|
-
const arrayComponents = getArrayComponents(parameter.type);
|
|
2232
|
-
if (arrayComponents) {
|
|
2233
|
-
const [length, type] = arrayComponents;
|
|
2234
|
-
return encodeArray(value, {
|
|
2235
|
-
checksumAddress,
|
|
2236
|
-
length,
|
|
2237
|
-
parameter: {
|
|
2238
|
-
...parameter,
|
|
2239
|
-
type
|
|
2240
|
-
}
|
|
2241
|
-
});
|
|
2242
|
-
}
|
|
2243
|
-
if (parameter.type === "tuple") {
|
|
2244
|
-
return encodeTuple(value, {
|
|
2245
|
-
checksumAddress,
|
|
2246
|
-
parameter
|
|
2247
|
-
});
|
|
2248
|
-
}
|
|
2249
|
-
if (parameter.type === "address") {
|
|
2250
|
-
return encodeAddress(value, {
|
|
2251
|
-
checksum: checksumAddress
|
|
2252
|
-
});
|
|
2253
|
-
}
|
|
2254
|
-
if (parameter.type === "bool") {
|
|
2255
|
-
return encodeBoolean(value);
|
|
2256
|
-
}
|
|
2257
|
-
if (parameter.type.startsWith("uint") || parameter.type.startsWith("int")) {
|
|
2258
|
-
const signed = parameter.type.startsWith("int");
|
|
2259
|
-
const [, , size2 = "256"] = integerRegex.exec(parameter.type) ?? [];
|
|
2260
|
-
return encodeNumber(value, {
|
|
2261
|
-
signed,
|
|
2262
|
-
size: Number(size2)
|
|
2263
|
-
});
|
|
2264
|
-
}
|
|
2265
|
-
if (parameter.type.startsWith("bytes")) {
|
|
2266
|
-
return encodeBytes(value, { type: parameter.type });
|
|
2267
|
-
}
|
|
2268
|
-
if (parameter.type === "string") {
|
|
2269
|
-
return encodeString(value);
|
|
2270
|
-
}
|
|
2271
|
-
throw new InvalidTypeError(parameter.type);
|
|
2272
|
-
}
|
|
2273
|
-
function encode$2(preparedParameters) {
|
|
2274
|
-
let staticSize = 0;
|
|
2275
|
-
for (let i = 0; i < preparedParameters.length; i++) {
|
|
2276
|
-
const { dynamic, encoded } = preparedParameters[i];
|
|
2277
|
-
if (dynamic)
|
|
2278
|
-
staticSize += 32;
|
|
2279
|
-
else
|
|
2280
|
-
staticSize += size$1(encoded);
|
|
2281
|
-
}
|
|
2282
|
-
const staticParameters = [];
|
|
2283
|
-
const dynamicParameters = [];
|
|
2284
|
-
let dynamicSize = 0;
|
|
2285
|
-
for (let i = 0; i < preparedParameters.length; i++) {
|
|
2286
|
-
const { dynamic, encoded } = preparedParameters[i];
|
|
2287
|
-
if (dynamic) {
|
|
2288
|
-
staticParameters.push(fromNumber(staticSize + dynamicSize, { size: 32 }));
|
|
2289
|
-
dynamicParameters.push(encoded);
|
|
2290
|
-
dynamicSize += size$1(encoded);
|
|
2291
|
-
} else {
|
|
2292
|
-
staticParameters.push(encoded);
|
|
2293
|
-
}
|
|
2294
|
-
}
|
|
2295
|
-
return concat$1(...staticParameters, ...dynamicParameters);
|
|
2296
|
-
}
|
|
2297
|
-
function encodeAddress(value, options) {
|
|
2298
|
-
const { checksum: checksum2 = false } = options;
|
|
2299
|
-
assert$3(value, { strict: checksum2 });
|
|
2300
|
-
return {
|
|
2301
|
-
dynamic: false,
|
|
2302
|
-
encoded: padLeft(value.toLowerCase())
|
|
2303
|
-
};
|
|
2304
|
-
}
|
|
2305
|
-
function encodeArray(value, options) {
|
|
2306
|
-
const { checksumAddress, length, parameter } = options;
|
|
2307
|
-
const dynamic = length === null;
|
|
2308
|
-
if (!Array.isArray(value))
|
|
2309
|
-
throw new InvalidArrayError(value);
|
|
2310
|
-
if (!dynamic && value.length !== length)
|
|
2311
|
-
throw new ArrayLengthMismatchError({
|
|
2312
|
-
expectedLength: length,
|
|
2313
|
-
givenLength: value.length,
|
|
2314
|
-
type: `${parameter.type}[${length}]`
|
|
2315
|
-
});
|
|
2316
|
-
let dynamicChild = false;
|
|
2317
|
-
const preparedParameters = [];
|
|
2318
|
-
for (let i = 0; i < value.length; i++) {
|
|
2319
|
-
const preparedParam = prepareParameter({
|
|
2320
|
-
checksumAddress,
|
|
2321
|
-
parameter,
|
|
2322
|
-
value: value[i]
|
|
2323
|
-
});
|
|
2324
|
-
if (preparedParam.dynamic)
|
|
2325
|
-
dynamicChild = true;
|
|
2326
|
-
preparedParameters.push(preparedParam);
|
|
2327
|
-
}
|
|
2328
|
-
if (dynamic || dynamicChild) {
|
|
2329
|
-
const data = encode$2(preparedParameters);
|
|
2330
|
-
if (dynamic) {
|
|
2331
|
-
const length2 = fromNumber(preparedParameters.length, { size: 32 });
|
|
2332
|
-
return {
|
|
2333
|
-
dynamic: true,
|
|
2334
|
-
encoded: preparedParameters.length > 0 ? concat$1(length2, data) : length2
|
|
2335
|
-
};
|
|
2336
|
-
}
|
|
2337
|
-
if (dynamicChild)
|
|
2338
|
-
return { dynamic: true, encoded: data };
|
|
2339
|
-
}
|
|
2340
|
-
return {
|
|
2341
|
-
dynamic: false,
|
|
2342
|
-
encoded: concat$1(...preparedParameters.map(({ encoded }) => encoded))
|
|
2343
|
-
};
|
|
2344
|
-
}
|
|
2345
|
-
function encodeBytes(value, { type }) {
|
|
2346
|
-
const [, parametersize] = type.split("bytes");
|
|
2347
|
-
const bytesSize = size$1(value);
|
|
2348
|
-
if (!parametersize) {
|
|
2349
|
-
let value_ = value;
|
|
2350
|
-
if (bytesSize % 32 !== 0)
|
|
2351
|
-
value_ = padRight$1(value_, Math.ceil((value.length - 2) / 2 / 32) * 32);
|
|
2352
|
-
return {
|
|
2353
|
-
dynamic: true,
|
|
2354
|
-
encoded: concat$1(padLeft(fromNumber(bytesSize, { size: 32 })), value_)
|
|
2355
|
-
};
|
|
2356
|
-
}
|
|
2357
|
-
if (bytesSize !== Number.parseInt(parametersize, 10))
|
|
2358
|
-
throw new BytesSizeMismatchError({
|
|
2359
|
-
expectedSize: Number.parseInt(parametersize, 10),
|
|
2360
|
-
value
|
|
2361
|
-
});
|
|
2362
|
-
return { dynamic: false, encoded: padRight$1(value) };
|
|
2363
|
-
}
|
|
2364
|
-
function encodeBoolean(value) {
|
|
2365
|
-
if (typeof value !== "boolean")
|
|
2366
|
-
throw new BaseError$1(`Invalid boolean value: "${value}" (type: ${typeof value}). Expected: \`true\` or \`false\`.`);
|
|
2367
|
-
return { dynamic: false, encoded: padLeft(fromBoolean(value)) };
|
|
2368
|
-
}
|
|
2369
|
-
function encodeNumber(value, { signed, size: size2 }) {
|
|
2370
|
-
if (typeof size2 === "number") {
|
|
2371
|
-
const max = 2n ** (BigInt(size2) - (signed ? 1n : 0n)) - 1n;
|
|
2372
|
-
const min = signed ? -max - 1n : 0n;
|
|
2373
|
-
if (value > max || value < min)
|
|
2374
|
-
throw new IntegerOutOfRangeError({
|
|
2375
|
-
max: max.toString(),
|
|
2376
|
-
min: min.toString(),
|
|
2377
|
-
signed,
|
|
2378
|
-
size: size2 / 8,
|
|
2379
|
-
value: value.toString()
|
|
2380
|
-
});
|
|
2381
|
-
}
|
|
2382
|
-
return {
|
|
2383
|
-
dynamic: false,
|
|
2384
|
-
encoded: fromNumber(value, {
|
|
2385
|
-
size: 32,
|
|
2386
|
-
signed
|
|
2387
|
-
})
|
|
2388
|
-
};
|
|
2389
|
-
}
|
|
2390
|
-
function encodeString(value) {
|
|
2391
|
-
const hexValue = fromString$1(value);
|
|
2392
|
-
const partsLength = Math.ceil(size$1(hexValue) / 32);
|
|
2393
|
-
const parts = [];
|
|
2394
|
-
for (let i = 0; i < partsLength; i++) {
|
|
2395
|
-
parts.push(padRight$1(slice$1(hexValue, i * 32, (i + 1) * 32)));
|
|
2396
|
-
}
|
|
2397
|
-
return {
|
|
2398
|
-
dynamic: true,
|
|
2399
|
-
encoded: concat$1(padRight$1(fromNumber(size$1(hexValue), { size: 32 })), ...parts)
|
|
2400
|
-
};
|
|
2401
|
-
}
|
|
2402
|
-
function encodeTuple(value, options) {
|
|
2403
|
-
const { checksumAddress, parameter } = options;
|
|
2404
|
-
let dynamic = false;
|
|
2405
|
-
const preparedParameters = [];
|
|
2406
|
-
for (let i = 0; i < parameter.components.length; i++) {
|
|
2407
|
-
const param_ = parameter.components[i];
|
|
2408
|
-
const index = Array.isArray(value) ? i : param_.name;
|
|
2409
|
-
const preparedParam = prepareParameter({
|
|
2410
|
-
checksumAddress,
|
|
2411
|
-
parameter: param_,
|
|
2412
|
-
value: value[index]
|
|
2413
|
-
});
|
|
2414
|
-
preparedParameters.push(preparedParam);
|
|
2415
|
-
if (preparedParam.dynamic)
|
|
2416
|
-
dynamic = true;
|
|
2417
|
-
}
|
|
2418
|
-
return {
|
|
2419
|
-
dynamic,
|
|
2420
|
-
encoded: dynamic ? encode$2(preparedParameters) : concat$1(...preparedParameters.map(({ encoded }) => encoded))
|
|
2421
|
-
};
|
|
2422
|
-
}
|
|
2423
|
-
function getArrayComponents(type) {
|
|
2424
|
-
const matches = type.match(/^(.*)\[(\d+)?\]$/);
|
|
2425
|
-
return matches ? (
|
|
2426
|
-
// Return `null` if the array is dynamic.
|
|
2427
|
-
[matches[2] ? Number(matches[2]) : null, matches[1]]
|
|
2428
|
-
) : void 0;
|
|
2429
|
-
}
|
|
2430
|
-
function hasDynamicChild(param) {
|
|
2431
|
-
var _a;
|
|
2432
|
-
const { type } = param;
|
|
2433
|
-
if (type === "string")
|
|
2434
|
-
return true;
|
|
2435
|
-
if (type === "bytes")
|
|
2436
|
-
return true;
|
|
2437
|
-
if (type.endsWith("[]"))
|
|
2438
|
-
return true;
|
|
2439
|
-
if (type === "tuple")
|
|
2440
|
-
return (_a = param.components) == null ? void 0 : _a.some(hasDynamicChild);
|
|
2441
|
-
const arrayComponents = getArrayComponents(param.type);
|
|
2442
|
-
if (arrayComponents && hasDynamicChild({
|
|
2443
|
-
...param,
|
|
2444
|
-
type: arrayComponents[1]
|
|
2445
|
-
}))
|
|
2446
|
-
return true;
|
|
2447
|
-
return false;
|
|
2448
|
-
}
|
|
2449
|
-
const staticCursor = {
|
|
2450
|
-
bytes: new Uint8Array(),
|
|
2451
|
-
dataView: new DataView(new ArrayBuffer(0)),
|
|
2452
|
-
position: 0,
|
|
2453
|
-
positionReadCount: /* @__PURE__ */ new Map(),
|
|
2454
|
-
recursiveReadCount: 0,
|
|
2455
|
-
recursiveReadLimit: Number.POSITIVE_INFINITY,
|
|
2456
|
-
assertReadLimit() {
|
|
2457
|
-
if (this.recursiveReadCount >= this.recursiveReadLimit)
|
|
2458
|
-
throw new RecursiveReadLimitExceededError({
|
|
2459
|
-
count: this.recursiveReadCount + 1,
|
|
2460
|
-
limit: this.recursiveReadLimit
|
|
2461
|
-
});
|
|
2462
|
-
},
|
|
2463
|
-
assertPosition(position) {
|
|
2464
|
-
if (position < 0 || position > this.bytes.length - 1)
|
|
2465
|
-
throw new PositionOutOfBoundsError({
|
|
2466
|
-
length: this.bytes.length,
|
|
2467
|
-
position
|
|
2468
|
-
});
|
|
2469
|
-
},
|
|
2470
|
-
decrementPosition(offset) {
|
|
2471
|
-
if (offset < 0)
|
|
2472
|
-
throw new NegativeOffsetError({ offset });
|
|
2473
|
-
const position = this.position - offset;
|
|
2474
|
-
this.assertPosition(position);
|
|
2475
|
-
this.position = position;
|
|
2476
|
-
},
|
|
2477
|
-
getReadCount(position) {
|
|
2478
|
-
return this.positionReadCount.get(position || this.position) || 0;
|
|
2479
|
-
},
|
|
2480
|
-
incrementPosition(offset) {
|
|
2481
|
-
if (offset < 0)
|
|
2482
|
-
throw new NegativeOffsetError({ offset });
|
|
2483
|
-
const position = this.position + offset;
|
|
2484
|
-
this.assertPosition(position);
|
|
2485
|
-
this.position = position;
|
|
2486
|
-
},
|
|
2487
|
-
inspectByte(position_) {
|
|
2488
|
-
const position = position_ ?? this.position;
|
|
2489
|
-
this.assertPosition(position);
|
|
2490
|
-
return this.bytes[position];
|
|
2491
|
-
},
|
|
2492
|
-
inspectBytes(length, position_) {
|
|
2493
|
-
const position = position_ ?? this.position;
|
|
2494
|
-
this.assertPosition(position + length - 1);
|
|
2495
|
-
return this.bytes.subarray(position, position + length);
|
|
2496
|
-
},
|
|
2497
|
-
inspectUint8(position_) {
|
|
2498
|
-
const position = position_ ?? this.position;
|
|
2499
|
-
this.assertPosition(position);
|
|
2500
|
-
return this.bytes[position];
|
|
2501
|
-
},
|
|
2502
|
-
inspectUint16(position_) {
|
|
2503
|
-
const position = position_ ?? this.position;
|
|
2504
|
-
this.assertPosition(position + 1);
|
|
2505
|
-
return this.dataView.getUint16(position);
|
|
2506
|
-
},
|
|
2507
|
-
inspectUint24(position_) {
|
|
2508
|
-
const position = position_ ?? this.position;
|
|
2509
|
-
this.assertPosition(position + 2);
|
|
2510
|
-
return (this.dataView.getUint16(position) << 8) + this.dataView.getUint8(position + 2);
|
|
2511
|
-
},
|
|
2512
|
-
inspectUint32(position_) {
|
|
2513
|
-
const position = position_ ?? this.position;
|
|
2514
|
-
this.assertPosition(position + 3);
|
|
2515
|
-
return this.dataView.getUint32(position);
|
|
2516
|
-
},
|
|
2517
|
-
pushByte(byte) {
|
|
2518
|
-
this.assertPosition(this.position);
|
|
2519
|
-
this.bytes[this.position] = byte;
|
|
2520
|
-
this.position++;
|
|
2521
|
-
},
|
|
2522
|
-
pushBytes(bytes) {
|
|
2523
|
-
this.assertPosition(this.position + bytes.length - 1);
|
|
2524
|
-
this.bytes.set(bytes, this.position);
|
|
2525
|
-
this.position += bytes.length;
|
|
2526
|
-
},
|
|
2527
|
-
pushUint8(value) {
|
|
2528
|
-
this.assertPosition(this.position);
|
|
2529
|
-
this.bytes[this.position] = value;
|
|
2530
|
-
this.position++;
|
|
2531
|
-
},
|
|
2532
|
-
pushUint16(value) {
|
|
2533
|
-
this.assertPosition(this.position + 1);
|
|
2534
|
-
this.dataView.setUint16(this.position, value);
|
|
2535
|
-
this.position += 2;
|
|
2536
|
-
},
|
|
2537
|
-
pushUint24(value) {
|
|
2538
|
-
this.assertPosition(this.position + 2);
|
|
2539
|
-
this.dataView.setUint16(this.position, value >> 8);
|
|
2540
|
-
this.dataView.setUint8(this.position + 2, value & 255);
|
|
2541
|
-
this.position += 3;
|
|
2542
|
-
},
|
|
2543
|
-
pushUint32(value) {
|
|
2544
|
-
this.assertPosition(this.position + 3);
|
|
2545
|
-
this.dataView.setUint32(this.position, value);
|
|
2546
|
-
this.position += 4;
|
|
2547
|
-
},
|
|
2548
|
-
readByte() {
|
|
2549
|
-
this.assertReadLimit();
|
|
2550
|
-
this._touch();
|
|
2551
|
-
const value = this.inspectByte();
|
|
2552
|
-
this.position++;
|
|
2553
|
-
return value;
|
|
2554
|
-
},
|
|
2555
|
-
readBytes(length, size2) {
|
|
2556
|
-
this.assertReadLimit();
|
|
2557
|
-
this._touch();
|
|
2558
|
-
const value = this.inspectBytes(length);
|
|
2559
|
-
this.position += size2 ?? length;
|
|
2560
|
-
return value;
|
|
2561
|
-
},
|
|
2562
|
-
readUint8() {
|
|
2563
|
-
this.assertReadLimit();
|
|
2564
|
-
this._touch();
|
|
2565
|
-
const value = this.inspectUint8();
|
|
2566
|
-
this.position += 1;
|
|
2567
|
-
return value;
|
|
2568
|
-
},
|
|
2569
|
-
readUint16() {
|
|
2570
|
-
this.assertReadLimit();
|
|
2571
|
-
this._touch();
|
|
2572
|
-
const value = this.inspectUint16();
|
|
2573
|
-
this.position += 2;
|
|
2574
|
-
return value;
|
|
2575
|
-
},
|
|
2576
|
-
readUint24() {
|
|
2577
|
-
this.assertReadLimit();
|
|
2578
|
-
this._touch();
|
|
2579
|
-
const value = this.inspectUint24();
|
|
2580
|
-
this.position += 3;
|
|
2581
|
-
return value;
|
|
2582
|
-
},
|
|
2583
|
-
readUint32() {
|
|
2584
|
-
this.assertReadLimit();
|
|
2585
|
-
this._touch();
|
|
2586
|
-
const value = this.inspectUint32();
|
|
2587
|
-
this.position += 4;
|
|
2588
|
-
return value;
|
|
2589
|
-
},
|
|
2590
|
-
get remaining() {
|
|
2591
|
-
return this.bytes.length - this.position;
|
|
2592
|
-
},
|
|
2593
|
-
setPosition(position) {
|
|
2594
|
-
const oldPosition = this.position;
|
|
2595
|
-
this.assertPosition(position);
|
|
2596
|
-
this.position = position;
|
|
2597
|
-
return () => this.position = oldPosition;
|
|
2598
|
-
},
|
|
2599
|
-
_touch() {
|
|
2600
|
-
if (this.recursiveReadLimit === Number.POSITIVE_INFINITY)
|
|
2601
|
-
return;
|
|
2602
|
-
const count = this.getReadCount();
|
|
2603
|
-
this.positionReadCount.set(this.position, count + 1);
|
|
2604
|
-
if (count > 0)
|
|
2605
|
-
this.recursiveReadCount++;
|
|
2606
|
-
}
|
|
2607
|
-
};
|
|
2608
|
-
function create(bytes, { recursiveReadLimit = 8192 } = {}) {
|
|
2609
|
-
const cursor = Object.create(staticCursor);
|
|
2610
|
-
cursor.bytes = bytes;
|
|
2611
|
-
cursor.dataView = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
2612
|
-
cursor.positionReadCount = /* @__PURE__ */ new Map();
|
|
2613
|
-
cursor.recursiveReadLimit = recursiveReadLimit;
|
|
2614
|
-
return cursor;
|
|
2615
|
-
}
|
|
2616
|
-
class NegativeOffsetError extends BaseError$1 {
|
|
2617
|
-
constructor({ offset }) {
|
|
2618
|
-
super(`Offset \`${offset}\` cannot be negative.`);
|
|
2619
|
-
Object.defineProperty(this, "name", {
|
|
2620
|
-
enumerable: true,
|
|
2621
|
-
configurable: true,
|
|
2622
|
-
writable: true,
|
|
2623
|
-
value: "Cursor.NegativeOffsetError"
|
|
2624
|
-
});
|
|
2625
|
-
}
|
|
2626
|
-
}
|
|
2627
|
-
class PositionOutOfBoundsError extends BaseError$1 {
|
|
2628
|
-
constructor({ length, position }) {
|
|
2629
|
-
super(`Position \`${position}\` is out of bounds (\`0 < position < ${length}\`).`);
|
|
2630
|
-
Object.defineProperty(this, "name", {
|
|
2631
|
-
enumerable: true,
|
|
2632
|
-
configurable: true,
|
|
2633
|
-
writable: true,
|
|
2634
|
-
value: "Cursor.PositionOutOfBoundsError"
|
|
2635
|
-
});
|
|
2636
|
-
}
|
|
2637
|
-
}
|
|
2638
|
-
class RecursiveReadLimitExceededError extends BaseError$1 {
|
|
2639
|
-
constructor({ count, limit }) {
|
|
2640
|
-
super(`Recursive read limit of \`${limit}\` exceeded (recursive read count: \`${count}\`).`);
|
|
2641
|
-
Object.defineProperty(this, "name", {
|
|
2642
|
-
enumerable: true,
|
|
2643
|
-
configurable: true,
|
|
2644
|
-
writable: true,
|
|
2645
|
-
value: "Cursor.RecursiveReadLimitExceededError"
|
|
2646
|
-
});
|
|
2647
|
-
}
|
|
2648
|
-
}
|
|
2649
|
-
function decode(parameters, data, options = {}) {
|
|
2650
|
-
const { as = "Array", checksumAddress = false } = options;
|
|
2651
|
-
const bytes = typeof data === "string" ? fromHex$3(data) : data;
|
|
2652
|
-
const cursor = create(bytes);
|
|
2653
|
-
if (size(bytes) === 0 && parameters.length > 0)
|
|
2654
|
-
throw new ZeroDataError();
|
|
2655
|
-
if (size(bytes) && size(bytes) < 32)
|
|
2656
|
-
throw new DataSizeTooSmallError({
|
|
2657
|
-
data: typeof data === "string" ? data : fromBytes$2(data),
|
|
2658
|
-
parameters,
|
|
2659
|
-
size: size(bytes)
|
|
2660
|
-
});
|
|
2661
|
-
let consumed = 0;
|
|
2662
|
-
const values = as === "Array" ? [] : {};
|
|
2663
|
-
for (let i = 0; i < parameters.length; ++i) {
|
|
2664
|
-
const param = parameters[i];
|
|
2665
|
-
cursor.setPosition(consumed);
|
|
2666
|
-
const [data2, consumed_] = decodeParameter(cursor, param, {
|
|
2667
|
-
checksumAddress,
|
|
2668
|
-
staticPosition: 0
|
|
2669
|
-
});
|
|
2670
|
-
consumed += consumed_;
|
|
2671
|
-
if (as === "Array")
|
|
2672
|
-
values.push(data2);
|
|
2673
|
-
else
|
|
2674
|
-
values[param.name ?? i] = data2;
|
|
2675
|
-
}
|
|
2676
|
-
return values;
|
|
2677
|
-
}
|
|
2678
|
-
function encode$1(parameters, values, options) {
|
|
2679
|
-
const { checksumAddress = false } = {};
|
|
2680
|
-
if (parameters.length !== values.length)
|
|
2681
|
-
throw new LengthMismatchError({
|
|
2682
|
-
expectedLength: parameters.length,
|
|
2683
|
-
givenLength: values.length
|
|
2684
|
-
});
|
|
2685
|
-
const preparedParameters = prepareParameters({
|
|
2686
|
-
checksumAddress,
|
|
2687
|
-
parameters,
|
|
2688
|
-
values
|
|
2689
|
-
});
|
|
2690
|
-
const data = encode$2(preparedParameters);
|
|
2691
|
-
if (data.length === 0)
|
|
2692
|
-
return "0x";
|
|
2693
|
-
return data;
|
|
2694
|
-
}
|
|
2695
|
-
function encodePacked(types, values) {
|
|
2696
|
-
if (types.length !== values.length)
|
|
2697
|
-
throw new LengthMismatchError({
|
|
2698
|
-
expectedLength: types.length,
|
|
2699
|
-
givenLength: values.length
|
|
2700
|
-
});
|
|
2701
|
-
const data = [];
|
|
2702
|
-
for (let i = 0; i < types.length; i++) {
|
|
2703
|
-
const type = types[i];
|
|
2704
|
-
const value = values[i];
|
|
2705
|
-
data.push(encodePacked.encode(type, value));
|
|
2706
|
-
}
|
|
2707
|
-
return concat$1(...data);
|
|
2708
|
-
}
|
|
2709
|
-
(function(encodePacked2) {
|
|
2710
|
-
function encode2(type, value, isArray = false) {
|
|
2711
|
-
if (type === "address") {
|
|
2712
|
-
const address = value;
|
|
2713
|
-
assert$3(address);
|
|
2714
|
-
return padLeft(address.toLowerCase(), isArray ? 32 : 0);
|
|
2715
|
-
}
|
|
2716
|
-
if (type === "string")
|
|
2717
|
-
return fromString$1(value);
|
|
2718
|
-
if (type === "bytes")
|
|
2719
|
-
return value;
|
|
2720
|
-
if (type === "bool")
|
|
2721
|
-
return padLeft(fromBoolean(value), isArray ? 32 : 1);
|
|
2722
|
-
const intMatch = type.match(integerRegex);
|
|
2723
|
-
if (intMatch) {
|
|
2724
|
-
const [_type, baseType, bits = "256"] = intMatch;
|
|
2725
|
-
const size2 = Number.parseInt(bits, 10) / 8;
|
|
2726
|
-
return fromNumber(value, {
|
|
2727
|
-
size: isArray ? 32 : size2,
|
|
2728
|
-
signed: baseType === "int"
|
|
2729
|
-
});
|
|
2730
|
-
}
|
|
2731
|
-
const bytesMatch = type.match(bytesRegex);
|
|
2732
|
-
if (bytesMatch) {
|
|
2733
|
-
const [_type, size2] = bytesMatch;
|
|
2734
|
-
if (Number.parseInt(size2, 10) !== (value.length - 2) / 2)
|
|
2735
|
-
throw new BytesSizeMismatchError({
|
|
2736
|
-
expectedSize: Number.parseInt(size2, 10),
|
|
2737
|
-
value
|
|
2738
|
-
});
|
|
2739
|
-
return padRight$1(value, isArray ? 32 : 0);
|
|
2740
|
-
}
|
|
2741
|
-
const arrayMatch = type.match(arrayRegex);
|
|
2742
|
-
if (arrayMatch && Array.isArray(value)) {
|
|
2743
|
-
const [_type, childType] = arrayMatch;
|
|
2744
|
-
const data = [];
|
|
2745
|
-
for (let i = 0; i < value.length; i++) {
|
|
2746
|
-
data.push(encode2(childType, value[i], true));
|
|
2747
|
-
}
|
|
2748
|
-
if (data.length === 0)
|
|
2749
|
-
return "0x";
|
|
2750
|
-
return concat$1(...data);
|
|
2751
|
-
}
|
|
2752
|
-
throw new InvalidTypeError(type);
|
|
2753
|
-
}
|
|
2754
|
-
encodePacked2.encode = encode2;
|
|
2755
|
-
})(encodePacked || (encodePacked = {}));
|
|
2756
|
-
function from$6(parameters) {
|
|
2757
|
-
if (Array.isArray(parameters) && typeof parameters[0] === "string")
|
|
2758
|
-
return parseAbiParameters(parameters);
|
|
2759
|
-
if (typeof parameters === "string")
|
|
2760
|
-
return parseAbiParameters(parameters);
|
|
2761
|
-
return parameters;
|
|
2762
|
-
}
|
|
2763
|
-
class DataSizeTooSmallError extends BaseError$1 {
|
|
2764
|
-
constructor({ data, parameters, size: size2 }) {
|
|
2765
|
-
super(`Data size of ${size2} bytes is too small for given parameters.`, {
|
|
2766
|
-
metaMessages: [
|
|
2767
|
-
`Params: (${formatAbiParameters(parameters)})`,
|
|
2768
|
-
`Data: ${data} (${size2} bytes)`
|
|
2769
|
-
]
|
|
2770
|
-
});
|
|
2771
|
-
Object.defineProperty(this, "name", {
|
|
2772
|
-
enumerable: true,
|
|
2773
|
-
configurable: true,
|
|
2774
|
-
writable: true,
|
|
2775
|
-
value: "AbiParameters.DataSizeTooSmallError"
|
|
2776
|
-
});
|
|
2777
|
-
}
|
|
2778
|
-
}
|
|
2779
|
-
class ZeroDataError extends BaseError$1 {
|
|
2780
|
-
constructor() {
|
|
2781
|
-
super('Cannot decode zero data ("0x") with ABI parameters.');
|
|
2782
|
-
Object.defineProperty(this, "name", {
|
|
2783
|
-
enumerable: true,
|
|
2784
|
-
configurable: true,
|
|
2785
|
-
writable: true,
|
|
2786
|
-
value: "AbiParameters.ZeroDataError"
|
|
2787
|
-
});
|
|
2788
|
-
}
|
|
2789
|
-
}
|
|
2790
|
-
class ArrayLengthMismatchError extends BaseError$1 {
|
|
2791
|
-
constructor({ expectedLength, givenLength, type }) {
|
|
2792
|
-
super(`Array length mismatch for type \`${type}\`. Expected: \`${expectedLength}\`. Given: \`${givenLength}\`.`);
|
|
2793
|
-
Object.defineProperty(this, "name", {
|
|
2794
|
-
enumerable: true,
|
|
2795
|
-
configurable: true,
|
|
2796
|
-
writable: true,
|
|
2797
|
-
value: "AbiParameters.ArrayLengthMismatchError"
|
|
2798
|
-
});
|
|
2799
|
-
}
|
|
2800
|
-
}
|
|
2801
|
-
class BytesSizeMismatchError extends BaseError$1 {
|
|
2802
|
-
constructor({ expectedSize, value }) {
|
|
2803
|
-
super(`Size of bytes "${value}" (bytes${size$1(value)}) does not match expected size (bytes${expectedSize}).`);
|
|
2804
|
-
Object.defineProperty(this, "name", {
|
|
2805
|
-
enumerable: true,
|
|
2806
|
-
configurable: true,
|
|
2807
|
-
writable: true,
|
|
2808
|
-
value: "AbiParameters.BytesSizeMismatchError"
|
|
2809
|
-
});
|
|
2810
|
-
}
|
|
2811
|
-
}
|
|
2812
|
-
class LengthMismatchError extends BaseError$1 {
|
|
2813
|
-
constructor({ expectedLength, givenLength }) {
|
|
2814
|
-
super([
|
|
2815
|
-
"ABI encoding parameters/values length mismatch.",
|
|
2816
|
-
`Expected length (parameters): ${expectedLength}`,
|
|
2817
|
-
`Given length (values): ${givenLength}`
|
|
2818
|
-
].join("\n"));
|
|
2819
|
-
Object.defineProperty(this, "name", {
|
|
2820
|
-
enumerable: true,
|
|
2821
|
-
configurable: true,
|
|
2822
|
-
writable: true,
|
|
2823
|
-
value: "AbiParameters.LengthMismatchError"
|
|
2824
|
-
});
|
|
2825
|
-
}
|
|
2826
|
-
}
|
|
2827
|
-
class InvalidArrayError extends BaseError$1 {
|
|
2828
|
-
constructor(value) {
|
|
2829
|
-
super(`Value \`${value}\` is not a valid array.`);
|
|
2830
|
-
Object.defineProperty(this, "name", {
|
|
2831
|
-
enumerable: true,
|
|
2832
|
-
configurable: true,
|
|
2833
|
-
writable: true,
|
|
2834
|
-
value: "AbiParameters.InvalidArrayError"
|
|
2835
|
-
});
|
|
2836
|
-
}
|
|
2837
|
-
}
|
|
2838
|
-
class InvalidTypeError extends BaseError$1 {
|
|
2839
|
-
constructor(type) {
|
|
2840
|
-
super(`Type \`${type}\` is not a valid ABI Type.`);
|
|
2841
|
-
Object.defineProperty(this, "name", {
|
|
2842
|
-
enumerable: true,
|
|
2843
|
-
configurable: true,
|
|
2844
|
-
writable: true,
|
|
2845
|
-
value: "AbiParameters.InvalidTypeError"
|
|
2846
|
-
});
|
|
2847
|
-
}
|
|
2848
|
-
}
|
|
2849
|
-
function from$5(value, options) {
|
|
2850
|
-
const { as } = options;
|
|
2851
|
-
const encodable = getEncodable(value);
|
|
2852
|
-
const cursor = create(new Uint8Array(encodable.length));
|
|
2853
|
-
encodable.encode(cursor);
|
|
2854
|
-
if (as === "Hex")
|
|
2855
|
-
return fromBytes$2(cursor.bytes);
|
|
2856
|
-
return cursor.bytes;
|
|
2857
|
-
}
|
|
2858
|
-
function fromHex$1(hex, options = {}) {
|
|
2859
|
-
const { as = "Hex" } = options;
|
|
2860
|
-
return from$5(hex, { as });
|
|
2861
|
-
}
|
|
2862
|
-
function getEncodable(bytes) {
|
|
2863
|
-
if (Array.isArray(bytes))
|
|
2864
|
-
return getEncodableList(bytes.map((x) => getEncodable(x)));
|
|
2865
|
-
return getEncodableBytes(bytes);
|
|
2866
|
-
}
|
|
2867
|
-
function getEncodableList(list) {
|
|
2868
|
-
const bodyLength = list.reduce((acc, x) => acc + x.length, 0);
|
|
2869
|
-
const sizeOfBodyLength = getSizeOfLength(bodyLength);
|
|
2870
|
-
const length = (() => {
|
|
2871
|
-
if (bodyLength <= 55)
|
|
2872
|
-
return 1 + bodyLength;
|
|
2873
|
-
return 1 + sizeOfBodyLength + bodyLength;
|
|
2874
|
-
})();
|
|
2875
|
-
return {
|
|
2876
|
-
length,
|
|
2877
|
-
encode(cursor) {
|
|
2878
|
-
if (bodyLength <= 55) {
|
|
2879
|
-
cursor.pushByte(192 + bodyLength);
|
|
2880
|
-
} else {
|
|
2881
|
-
cursor.pushByte(192 + 55 + sizeOfBodyLength);
|
|
2882
|
-
if (sizeOfBodyLength === 1)
|
|
2883
|
-
cursor.pushUint8(bodyLength);
|
|
2884
|
-
else if (sizeOfBodyLength === 2)
|
|
2885
|
-
cursor.pushUint16(bodyLength);
|
|
2886
|
-
else if (sizeOfBodyLength === 3)
|
|
2887
|
-
cursor.pushUint24(bodyLength);
|
|
2888
|
-
else
|
|
2889
|
-
cursor.pushUint32(bodyLength);
|
|
2890
|
-
}
|
|
2891
|
-
for (const { encode: encode2 } of list) {
|
|
2892
|
-
encode2(cursor);
|
|
2893
|
-
}
|
|
2894
|
-
}
|
|
2895
|
-
};
|
|
2896
|
-
}
|
|
2897
|
-
function getEncodableBytes(bytesOrHex) {
|
|
2898
|
-
const bytes = typeof bytesOrHex === "string" ? fromHex$3(bytesOrHex) : bytesOrHex;
|
|
2899
|
-
const sizeOfBytesLength = getSizeOfLength(bytes.length);
|
|
2900
|
-
const length = (() => {
|
|
2901
|
-
if (bytes.length === 1 && bytes[0] < 128)
|
|
2902
|
-
return 1;
|
|
2903
|
-
if (bytes.length <= 55)
|
|
2904
|
-
return 1 + bytes.length;
|
|
2905
|
-
return 1 + sizeOfBytesLength + bytes.length;
|
|
2906
|
-
})();
|
|
2907
|
-
return {
|
|
2908
|
-
length,
|
|
2909
|
-
encode(cursor) {
|
|
2910
|
-
if (bytes.length === 1 && bytes[0] < 128) {
|
|
2911
|
-
cursor.pushBytes(bytes);
|
|
2912
|
-
} else if (bytes.length <= 55) {
|
|
2913
|
-
cursor.pushByte(128 + bytes.length);
|
|
2914
|
-
cursor.pushBytes(bytes);
|
|
2915
|
-
} else {
|
|
2916
|
-
cursor.pushByte(128 + 55 + sizeOfBytesLength);
|
|
2917
|
-
if (sizeOfBytesLength === 1)
|
|
2918
|
-
cursor.pushUint8(bytes.length);
|
|
2919
|
-
else if (sizeOfBytesLength === 2)
|
|
2920
|
-
cursor.pushUint16(bytes.length);
|
|
2921
|
-
else if (sizeOfBytesLength === 3)
|
|
2922
|
-
cursor.pushUint24(bytes.length);
|
|
2923
|
-
else
|
|
2924
|
-
cursor.pushUint32(bytes.length);
|
|
2925
|
-
cursor.pushBytes(bytes);
|
|
2926
|
-
}
|
|
2927
|
-
}
|
|
2928
|
-
};
|
|
2929
|
-
}
|
|
2930
|
-
function getSizeOfLength(length) {
|
|
2931
|
-
if (length < 2 ** 8)
|
|
2932
|
-
return 1;
|
|
2933
|
-
if (length < 2 ** 16)
|
|
2934
|
-
return 2;
|
|
2935
|
-
if (length < 2 ** 24)
|
|
2936
|
-
return 3;
|
|
2937
|
-
if (length < 2 ** 32)
|
|
2938
|
-
return 4;
|
|
2939
|
-
throw new BaseError$1("Length is too large.");
|
|
2940
|
-
}
|
|
2941
|
-
function assert$2(signature, options = {}) {
|
|
2942
|
-
const { recovered } = options;
|
|
2943
|
-
if (typeof signature.r === "undefined")
|
|
2944
|
-
throw new MissingPropertiesError({ signature });
|
|
2945
|
-
if (typeof signature.s === "undefined")
|
|
2946
|
-
throw new MissingPropertiesError({ signature });
|
|
2947
|
-
if (recovered && typeof signature.yParity === "undefined")
|
|
2948
|
-
throw new MissingPropertiesError({ signature });
|
|
2949
|
-
if (signature.r < 0n || signature.r > maxUint256)
|
|
2950
|
-
throw new InvalidRError({ value: signature.r });
|
|
2951
|
-
if (signature.s < 0n || signature.s > maxUint256)
|
|
2952
|
-
throw new InvalidSError({ value: signature.s });
|
|
2953
|
-
if (typeof signature.yParity === "number" && signature.yParity !== 0 && signature.yParity !== 1)
|
|
2954
|
-
throw new InvalidYParityError({ value: signature.yParity });
|
|
2955
|
-
}
|
|
2956
|
-
function fromBytes(signature) {
|
|
2957
|
-
return fromHex(fromBytes$2(signature));
|
|
2958
|
-
}
|
|
2959
|
-
function fromHex(signature) {
|
|
2960
|
-
if (signature.length !== 130 && signature.length !== 132)
|
|
2961
|
-
throw new InvalidSerializedSizeError2({ signature });
|
|
2962
|
-
const r = BigInt(slice$1(signature, 0, 32));
|
|
2963
|
-
const s = BigInt(slice$1(signature, 32, 64));
|
|
2964
|
-
const yParity = (() => {
|
|
2965
|
-
const yParity2 = Number(`0x${signature.slice(130)}`);
|
|
2966
|
-
if (Number.isNaN(yParity2))
|
|
2967
|
-
return void 0;
|
|
2968
|
-
try {
|
|
2969
|
-
return vToYParity(yParity2);
|
|
2970
|
-
} catch {
|
|
2971
|
-
throw new InvalidYParityError({ value: yParity2 });
|
|
2972
|
-
}
|
|
2973
|
-
})();
|
|
2974
|
-
if (typeof yParity === "undefined")
|
|
2975
|
-
return {
|
|
2976
|
-
r,
|
|
2977
|
-
s
|
|
2978
|
-
};
|
|
2979
|
-
return {
|
|
2980
|
-
r,
|
|
2981
|
-
s,
|
|
2982
|
-
yParity
|
|
2983
|
-
};
|
|
2984
|
-
}
|
|
2985
|
-
function extract(value) {
|
|
2986
|
-
if (typeof value.r === "undefined")
|
|
2987
|
-
return void 0;
|
|
2988
|
-
if (typeof value.s === "undefined")
|
|
2989
|
-
return void 0;
|
|
2990
|
-
return from$4(value);
|
|
2991
|
-
}
|
|
2992
|
-
function from$4(signature) {
|
|
2993
|
-
const signature_ = (() => {
|
|
2994
|
-
if (typeof signature === "string")
|
|
2995
|
-
return fromHex(signature);
|
|
2996
|
-
if (signature instanceof Uint8Array)
|
|
2997
|
-
return fromBytes(signature);
|
|
2998
|
-
if (typeof signature.r === "string")
|
|
2999
|
-
return fromRpc$1(signature);
|
|
3000
|
-
if (signature.v)
|
|
3001
|
-
return fromLegacy(signature);
|
|
3002
|
-
return {
|
|
3003
|
-
r: signature.r,
|
|
3004
|
-
s: signature.s,
|
|
3005
|
-
...typeof signature.yParity !== "undefined" ? { yParity: signature.yParity } : {}
|
|
3006
|
-
};
|
|
3007
|
-
})();
|
|
3008
|
-
assert$2(signature_);
|
|
3009
|
-
return signature_;
|
|
3010
|
-
}
|
|
3011
|
-
function fromLegacy(signature) {
|
|
3012
|
-
return {
|
|
3013
|
-
r: signature.r,
|
|
3014
|
-
s: signature.s,
|
|
3015
|
-
yParity: vToYParity(signature.v)
|
|
3016
|
-
};
|
|
3017
|
-
}
|
|
3018
|
-
function fromRpc$1(signature) {
|
|
3019
|
-
const yParity = (() => {
|
|
3020
|
-
const v = signature.v ? Number(signature.v) : void 0;
|
|
3021
|
-
let yParity2 = signature.yParity ? Number(signature.yParity) : void 0;
|
|
3022
|
-
if (typeof v === "number" && typeof yParity2 !== "number")
|
|
3023
|
-
yParity2 = vToYParity(v);
|
|
3024
|
-
if (typeof yParity2 !== "number")
|
|
3025
|
-
throw new InvalidYParityError({ value: signature.yParity });
|
|
3026
|
-
return yParity2;
|
|
3027
|
-
})();
|
|
3028
|
-
return {
|
|
3029
|
-
r: BigInt(signature.r),
|
|
3030
|
-
s: BigInt(signature.s),
|
|
3031
|
-
yParity
|
|
3032
|
-
};
|
|
3033
|
-
}
|
|
3034
|
-
function toTuple$1(signature) {
|
|
3035
|
-
const { r, s, yParity } = signature;
|
|
3036
|
-
return [
|
|
3037
|
-
yParity ? "0x01" : "0x",
|
|
3038
|
-
r === 0n ? "0x" : trimLeft$1(fromNumber(r)),
|
|
3039
|
-
s === 0n ? "0x" : trimLeft$1(fromNumber(s))
|
|
3040
|
-
];
|
|
3041
|
-
}
|
|
3042
|
-
function vToYParity(v) {
|
|
3043
|
-
if (v === 0 || v === 27)
|
|
3044
|
-
return 0;
|
|
3045
|
-
if (v === 1 || v === 28)
|
|
3046
|
-
return 1;
|
|
3047
|
-
if (v >= 35)
|
|
3048
|
-
return v % 2 === 0 ? 1 : 0;
|
|
3049
|
-
throw new InvalidVError({ value: v });
|
|
3050
|
-
}
|
|
3051
|
-
class InvalidSerializedSizeError2 extends BaseError$1 {
|
|
3052
|
-
constructor({ signature }) {
|
|
3053
|
-
super(`Value \`${signature}\` is an invalid signature size.`, {
|
|
3054
|
-
metaMessages: [
|
|
3055
|
-
"Expected: 64 bytes or 65 bytes.",
|
|
3056
|
-
`Received ${size$1(from$a(signature))} bytes.`
|
|
3057
|
-
]
|
|
3058
|
-
});
|
|
3059
|
-
Object.defineProperty(this, "name", {
|
|
3060
|
-
enumerable: true,
|
|
3061
|
-
configurable: true,
|
|
3062
|
-
writable: true,
|
|
3063
|
-
value: "Signature.InvalidSerializedSizeError"
|
|
3064
|
-
});
|
|
3065
|
-
}
|
|
3066
|
-
}
|
|
3067
|
-
class MissingPropertiesError extends BaseError$1 {
|
|
3068
|
-
constructor({ signature }) {
|
|
3069
|
-
super(`Signature \`${stringify(signature)}\` is missing either an \`r\`, \`s\`, or \`yParity\` property.`);
|
|
3070
|
-
Object.defineProperty(this, "name", {
|
|
3071
|
-
enumerable: true,
|
|
3072
|
-
configurable: true,
|
|
3073
|
-
writable: true,
|
|
3074
|
-
value: "Signature.MissingPropertiesError"
|
|
3075
|
-
});
|
|
3076
|
-
}
|
|
3077
|
-
}
|
|
3078
|
-
class InvalidRError extends BaseError$1 {
|
|
3079
|
-
constructor({ value }) {
|
|
3080
|
-
super(`Value \`${value}\` is an invalid r value. r must be a positive integer less than 2^256.`);
|
|
3081
|
-
Object.defineProperty(this, "name", {
|
|
3082
|
-
enumerable: true,
|
|
3083
|
-
configurable: true,
|
|
3084
|
-
writable: true,
|
|
3085
|
-
value: "Signature.InvalidRError"
|
|
3086
|
-
});
|
|
3087
|
-
}
|
|
3088
|
-
}
|
|
3089
|
-
class InvalidSError extends BaseError$1 {
|
|
3090
|
-
constructor({ value }) {
|
|
3091
|
-
super(`Value \`${value}\` is an invalid s value. s must be a positive integer less than 2^256.`);
|
|
3092
|
-
Object.defineProperty(this, "name", {
|
|
3093
|
-
enumerable: true,
|
|
3094
|
-
configurable: true,
|
|
3095
|
-
writable: true,
|
|
3096
|
-
value: "Signature.InvalidSError"
|
|
3097
|
-
});
|
|
3098
|
-
}
|
|
3099
|
-
}
|
|
3100
|
-
class InvalidYParityError extends BaseError$1 {
|
|
3101
|
-
constructor({ value }) {
|
|
3102
|
-
super(`Value \`${value}\` is an invalid y-parity value. Y-parity must be 0 or 1.`);
|
|
3103
|
-
Object.defineProperty(this, "name", {
|
|
3104
|
-
enumerable: true,
|
|
3105
|
-
configurable: true,
|
|
3106
|
-
writable: true,
|
|
3107
|
-
value: "Signature.InvalidYParityError"
|
|
3108
|
-
});
|
|
3109
|
-
}
|
|
3110
|
-
}
|
|
3111
|
-
class InvalidVError extends BaseError$1 {
|
|
3112
|
-
constructor({ value }) {
|
|
3113
|
-
super(`Value \`${value}\` is an invalid v value. v must be 27, 28 or >=35.`);
|
|
3114
|
-
Object.defineProperty(this, "name", {
|
|
3115
|
-
enumerable: true,
|
|
3116
|
-
configurable: true,
|
|
3117
|
-
writable: true,
|
|
3118
|
-
value: "Signature.InvalidVError"
|
|
3119
|
-
});
|
|
3120
|
-
}
|
|
3121
|
-
}
|
|
3122
|
-
function from$3(authorization, options = {}) {
|
|
3123
|
-
if (typeof authorization.chainId === "string")
|
|
3124
|
-
return fromRpc(authorization);
|
|
3125
|
-
return { ...authorization, ...options.signature };
|
|
3126
|
-
}
|
|
3127
|
-
function fromRpc(authorization) {
|
|
3128
|
-
const { address, chainId, nonce } = authorization;
|
|
3129
|
-
const signature = extract(authorization);
|
|
3130
|
-
return {
|
|
3131
|
-
address,
|
|
3132
|
-
chainId: Number(chainId),
|
|
3133
|
-
nonce: BigInt(nonce),
|
|
3134
|
-
...signature
|
|
3135
|
-
};
|
|
3136
|
-
}
|
|
3137
|
-
function getSignPayload(authorization) {
|
|
3138
|
-
return hash(authorization, { presign: true });
|
|
3139
|
-
}
|
|
3140
|
-
function hash(authorization, options = {}) {
|
|
3141
|
-
const { presign } = options;
|
|
3142
|
-
return keccak256(concat$1("0x05", fromHex$1(toTuple(presign ? {
|
|
3143
|
-
address: authorization.address,
|
|
3144
|
-
chainId: authorization.chainId,
|
|
3145
|
-
nonce: authorization.nonce
|
|
3146
|
-
} : authorization))));
|
|
3147
|
-
}
|
|
3148
|
-
function toTuple(authorization) {
|
|
3149
|
-
const { address, chainId, nonce } = authorization;
|
|
3150
|
-
const signature = extract(authorization);
|
|
3151
|
-
return [
|
|
3152
|
-
chainId ? fromNumber(chainId) : "0x",
|
|
3153
|
-
address,
|
|
3154
|
-
nonce ? fromNumber(nonce) : "0x",
|
|
3155
|
-
...signature ? toTuple$1(signature) : []
|
|
3156
|
-
];
|
|
3157
|
-
}
|
|
3158
|
-
function recoverAddress(options) {
|
|
3159
|
-
return fromPublicKey(recoverPublicKey(options));
|
|
3160
|
-
}
|
|
3161
|
-
function recoverPublicKey(options) {
|
|
3162
|
-
const { payload, signature } = options;
|
|
3163
|
-
const { r, s, yParity } = signature;
|
|
3164
|
-
const signature_ = new secp256k1.Signature(BigInt(r), BigInt(s)).addRecoveryBit(yParity);
|
|
3165
|
-
const point = signature_.recoverPublicKey(from$a(payload).substring(2));
|
|
3166
|
-
return from$8(point);
|
|
3167
|
-
}
|
|
3168
|
-
const magicBytes$1 = "0x8010801080108010801080108010801080108010801080108010801080108010";
|
|
3169
|
-
const suffixParameters = from$6("(uint256 chainId, address delegation, uint256 nonce, uint8 yParity, uint256 r, uint256 s), address to, bytes data");
|
|
3170
|
-
function assert$1(value) {
|
|
3171
|
-
if (typeof value === "string") {
|
|
3172
|
-
if (slice$1(value, -32) !== magicBytes$1)
|
|
3173
|
-
throw new InvalidWrappedSignatureError$1(value);
|
|
3174
|
-
} else
|
|
3175
|
-
assert$2(value.authorization);
|
|
3176
|
-
}
|
|
3177
|
-
function unwrap(wrapped) {
|
|
3178
|
-
assert$1(wrapped);
|
|
3179
|
-
const suffixLength = toNumber$1(slice$1(wrapped, -64, -32));
|
|
3180
|
-
const suffix = slice$1(wrapped, -suffixLength - 64, -64);
|
|
3181
|
-
const signature = slice$1(wrapped, 0, -suffixLength - 64);
|
|
3182
|
-
const [auth, to, data] = decode(suffixParameters, suffix);
|
|
3183
|
-
const authorization = from$3({
|
|
3184
|
-
address: auth.delegation,
|
|
3185
|
-
chainId: Number(auth.chainId),
|
|
3186
|
-
nonce: auth.nonce,
|
|
3187
|
-
yParity: auth.yParity,
|
|
3188
|
-
r: auth.r,
|
|
3189
|
-
s: auth.s
|
|
3190
|
-
});
|
|
3191
|
-
return {
|
|
3192
|
-
authorization,
|
|
3193
|
-
signature,
|
|
3194
|
-
...data && data !== "0x" ? { data, to } : {}
|
|
3195
|
-
};
|
|
3196
|
-
}
|
|
3197
|
-
function wrap$1(value) {
|
|
3198
|
-
const { data, signature } = value;
|
|
3199
|
-
assert$1(value);
|
|
3200
|
-
const self = recoverAddress({
|
|
3201
|
-
payload: getSignPayload(value.authorization),
|
|
3202
|
-
signature: from$4(value.authorization)
|
|
3203
|
-
});
|
|
3204
|
-
const suffix = encode$1(suffixParameters, [
|
|
3205
|
-
{
|
|
3206
|
-
...value.authorization,
|
|
3207
|
-
delegation: value.authorization.address,
|
|
3208
|
-
chainId: BigInt(value.authorization.chainId)
|
|
3209
|
-
},
|
|
3210
|
-
value.to ?? self,
|
|
3211
|
-
data ?? "0x"
|
|
3212
|
-
]);
|
|
3213
|
-
const suffixLength = fromNumber(size$1(suffix), { size: 32 });
|
|
3214
|
-
return concat$1(signature, suffix, suffixLength, magicBytes$1);
|
|
3215
|
-
}
|
|
3216
|
-
function validate$1(value) {
|
|
3217
|
-
try {
|
|
3218
|
-
assert$1(value);
|
|
3219
|
-
return true;
|
|
3220
|
-
} catch {
|
|
3221
|
-
return false;
|
|
3222
|
-
}
|
|
3223
|
-
}
|
|
3224
|
-
let InvalidWrappedSignatureError$1 = class InvalidWrappedSignatureError extends BaseError$1 {
|
|
3225
|
-
constructor(wrapped) {
|
|
3226
|
-
super(`Value \`${wrapped}\` is an invalid ERC-8010 wrapped signature.`);
|
|
3227
|
-
Object.defineProperty(this, "name", {
|
|
3228
|
-
enumerable: true,
|
|
3229
|
-
configurable: true,
|
|
3230
|
-
writable: true,
|
|
3231
|
-
value: "SignatureErc8010.InvalidWrappedSignatureError"
|
|
3232
|
-
});
|
|
3233
|
-
}
|
|
3234
|
-
};
|
|
3235
|
-
function serializeErc6492Signature(parameters) {
|
|
3236
|
-
const { address, data, signature, to = "hex" } = parameters;
|
|
3237
|
-
const signature_ = concatHex([
|
|
3238
|
-
encodeAbiParameters([{ type: "address" }, { type: "bytes" }, { type: "bytes" }], [address, data, signature]),
|
|
3239
|
-
erc6492MagicBytes
|
|
3240
|
-
]);
|
|
3241
|
-
if (to === "hex")
|
|
3242
|
-
return signature_;
|
|
3243
|
-
return hexToBytes(signature_);
|
|
3244
|
-
}
|
|
3245
|
-
function formatStorageProof(storageProof) {
|
|
3246
|
-
return storageProof.map((proof) => ({
|
|
3247
|
-
...proof,
|
|
3248
|
-
value: BigInt(proof.value)
|
|
3249
|
-
}));
|
|
3250
|
-
}
|
|
3251
|
-
function formatProof(proof) {
|
|
3252
|
-
return {
|
|
3253
|
-
...proof,
|
|
3254
|
-
balance: proof.balance ? BigInt(proof.balance) : void 0,
|
|
3255
|
-
nonce: proof.nonce ? hexToNumber(proof.nonce) : void 0,
|
|
3256
|
-
storageProof: proof.storageProof ? formatStorageProof(proof.storageProof) : void 0
|
|
3257
|
-
};
|
|
3258
|
-
}
|
|
3259
|
-
async function getProof(client, { address, blockNumber, blockTag: blockTag_, storageKeys }) {
|
|
3260
|
-
const blockTag = blockTag_ ?? "latest";
|
|
3261
|
-
const blockNumberHex = blockNumber !== void 0 ? numberToHex(blockNumber) : void 0;
|
|
3262
|
-
const proof = await client.request({
|
|
3263
|
-
method: "eth_getProof",
|
|
3264
|
-
params: [address, storageKeys, blockNumberHex || blockTag]
|
|
3265
|
-
});
|
|
3266
|
-
return formatProof(proof);
|
|
3267
|
-
}
|
|
3268
|
-
async function getStorageAt(client, { address, blockNumber, blockTag = "latest", slot }) {
|
|
3269
|
-
const blockNumberHex = blockNumber !== void 0 ? numberToHex(blockNumber) : void 0;
|
|
3270
|
-
const data = await client.request({
|
|
3271
|
-
method: "eth_getStorageAt",
|
|
3272
|
-
params: [address, slot, blockNumberHex || blockTag]
|
|
3273
|
-
});
|
|
3274
|
-
return data;
|
|
3275
|
-
}
|
|
3276
|
-
async function getTransactionConfirmations(client, { hash: hash2, transactionReceipt }) {
|
|
3277
|
-
const [blockNumber, transaction] = await Promise.all([
|
|
3278
|
-
getAction(client, getBlockNumber, "getBlockNumber")({}),
|
|
3279
|
-
hash2 ? getAction(client, getTransaction, "getTransaction")({ hash: hash2 }) : void 0
|
|
3280
|
-
]);
|
|
3281
|
-
const transactionBlockNumber = (transactionReceipt == null ? void 0 : transactionReceipt.blockNumber) || (transaction == null ? void 0 : transaction.blockNumber);
|
|
3282
|
-
if (!transactionBlockNumber)
|
|
3283
|
-
return 0n;
|
|
3284
|
-
return blockNumber - transactionBlockNumber + 1n;
|
|
3285
|
-
}
|
|
3286
|
-
async function simulateBlocks(client, parameters) {
|
|
3287
|
-
const { blockNumber, blockTag = client.experimental_blockTag ?? "latest", blocks, returnFullTransactions, traceTransfers, validation } = parameters;
|
|
3288
|
-
try {
|
|
3289
|
-
const blockStateCalls = [];
|
|
3290
|
-
for (const block2 of blocks) {
|
|
3291
|
-
const blockOverrides = block2.blockOverrides ? toRpc(block2.blockOverrides) : void 0;
|
|
3292
|
-
const calls = block2.calls.map((call_) => {
|
|
3293
|
-
const call2 = call_;
|
|
3294
|
-
const account = call2.account ? parseAccount(call2.account) : void 0;
|
|
3295
|
-
const data = call2.abi ? encodeFunctionData(call2) : call2.data;
|
|
3296
|
-
const request = {
|
|
3297
|
-
...call2,
|
|
3298
|
-
data: call2.dataSuffix ? concat([data || "0x", call2.dataSuffix]) : data,
|
|
3299
|
-
from: call2.from ?? (account == null ? void 0 : account.address)
|
|
3300
|
-
};
|
|
3301
|
-
assertRequest(request);
|
|
3302
|
-
return formatTransactionRequest(request);
|
|
3303
|
-
});
|
|
3304
|
-
const stateOverrides = block2.stateOverrides ? serializeStateOverride(block2.stateOverrides) : void 0;
|
|
3305
|
-
blockStateCalls.push({
|
|
3306
|
-
blockOverrides,
|
|
3307
|
-
calls,
|
|
3308
|
-
stateOverrides
|
|
3309
|
-
});
|
|
3310
|
-
}
|
|
3311
|
-
const blockNumberHex = typeof blockNumber === "bigint" ? numberToHex(blockNumber) : void 0;
|
|
3312
|
-
const block = blockNumberHex || blockTag;
|
|
3313
|
-
const result = await client.request({
|
|
3314
|
-
method: "eth_simulateV1",
|
|
3315
|
-
params: [
|
|
3316
|
-
{ blockStateCalls, returnFullTransactions, traceTransfers, validation },
|
|
3317
|
-
block
|
|
3318
|
-
]
|
|
3319
|
-
});
|
|
3320
|
-
return result.map((block2, i) => ({
|
|
3321
|
-
...formatBlock(block2),
|
|
3322
|
-
calls: block2.calls.map((call2, j) => {
|
|
3323
|
-
var _a, _b;
|
|
3324
|
-
const { abi: abi2, args, functionName, to } = blocks[i].calls[j];
|
|
3325
|
-
const data = ((_a = call2.error) == null ? void 0 : _a.data) ?? call2.returnData;
|
|
3326
|
-
const gasUsed = BigInt(call2.gasUsed);
|
|
3327
|
-
const logs = (_b = call2.logs) == null ? void 0 : _b.map((log) => formatLog(log));
|
|
3328
|
-
const status = call2.status === "0x1" ? "success" : "failure";
|
|
3329
|
-
const result2 = abi2 && status === "success" && data !== "0x" ? decodeFunctionResult({
|
|
3330
|
-
abi: abi2,
|
|
3331
|
-
data,
|
|
3332
|
-
functionName
|
|
3333
|
-
}) : null;
|
|
3334
|
-
const error = (() => {
|
|
3335
|
-
var _a2;
|
|
3336
|
-
if (status === "success")
|
|
3337
|
-
return void 0;
|
|
3338
|
-
let error2;
|
|
3339
|
-
if (((_a2 = call2.error) == null ? void 0 : _a2.data) === "0x")
|
|
3340
|
-
error2 = new AbiDecodingZeroDataError();
|
|
3341
|
-
else if (call2.error)
|
|
3342
|
-
error2 = new RawContractError(call2.error);
|
|
3343
|
-
if (!error2)
|
|
3344
|
-
return void 0;
|
|
3345
|
-
return getContractError(error2, {
|
|
3346
|
-
abi: abi2 ?? [],
|
|
3347
|
-
address: to ?? "0x",
|
|
3348
|
-
args,
|
|
3349
|
-
functionName: functionName ?? "<unknown>"
|
|
3350
|
-
});
|
|
3351
|
-
})();
|
|
3352
|
-
return {
|
|
3353
|
-
data,
|
|
3354
|
-
gasUsed,
|
|
3355
|
-
logs,
|
|
3356
|
-
status,
|
|
3357
|
-
...status === "success" ? {
|
|
3358
|
-
result: result2
|
|
3359
|
-
} : {
|
|
3360
|
-
error
|
|
3361
|
-
}
|
|
3362
|
-
};
|
|
3363
|
-
})
|
|
3364
|
-
}));
|
|
3365
|
-
} catch (e) {
|
|
3366
|
-
const cause = e;
|
|
3367
|
-
const error = getNodeError(cause, {});
|
|
3368
|
-
if (error instanceof UnknownNodeError)
|
|
3369
|
-
throw cause;
|
|
3370
|
-
throw error;
|
|
3371
|
-
}
|
|
3372
|
-
}
|
|
3373
|
-
function normalizeSignature(signature) {
|
|
3374
|
-
let active = true;
|
|
3375
|
-
let current = "";
|
|
3376
|
-
let level = 0;
|
|
3377
|
-
let result = "";
|
|
3378
|
-
let valid = false;
|
|
3379
|
-
for (let i = 0; i < signature.length; i++) {
|
|
3380
|
-
const char = signature[i];
|
|
3381
|
-
if (["(", ")", ","].includes(char))
|
|
3382
|
-
active = true;
|
|
3383
|
-
if (char === "(")
|
|
3384
|
-
level++;
|
|
3385
|
-
if (char === ")")
|
|
3386
|
-
level--;
|
|
3387
|
-
if (!active)
|
|
3388
|
-
continue;
|
|
3389
|
-
if (level === 0) {
|
|
3390
|
-
if (char === " " && ["event", "function", "error", ""].includes(result))
|
|
3391
|
-
result = "";
|
|
3392
|
-
else {
|
|
3393
|
-
result += char;
|
|
3394
|
-
if (char === ")") {
|
|
3395
|
-
valid = true;
|
|
3396
|
-
break;
|
|
3397
|
-
}
|
|
3398
|
-
}
|
|
3399
|
-
continue;
|
|
3400
|
-
}
|
|
3401
|
-
if (char === " ") {
|
|
3402
|
-
if (signature[i - 1] !== "," && current !== "," && current !== ",(") {
|
|
3403
|
-
current = "";
|
|
3404
|
-
active = false;
|
|
3405
|
-
}
|
|
3406
|
-
continue;
|
|
3407
|
-
}
|
|
3408
|
-
result += char;
|
|
3409
|
-
current += char;
|
|
3410
|
-
}
|
|
3411
|
-
if (!valid)
|
|
3412
|
-
throw new BaseError$1("Unable to normalize signature.");
|
|
3413
|
-
return result;
|
|
3414
|
-
}
|
|
3415
|
-
function isArgOfType(arg, abiParameter) {
|
|
3416
|
-
const argType = typeof arg;
|
|
3417
|
-
const abiParameterType = abiParameter.type;
|
|
3418
|
-
switch (abiParameterType) {
|
|
3419
|
-
case "address":
|
|
3420
|
-
return validate$2(arg, { strict: false });
|
|
3421
|
-
case "bool":
|
|
3422
|
-
return argType === "boolean";
|
|
3423
|
-
case "function":
|
|
3424
|
-
return argType === "string";
|
|
3425
|
-
case "string":
|
|
3426
|
-
return argType === "string";
|
|
3427
|
-
default: {
|
|
3428
|
-
if (abiParameterType === "tuple" && "components" in abiParameter)
|
|
3429
|
-
return Object.values(abiParameter.components).every((component, index) => {
|
|
3430
|
-
return isArgOfType(Object.values(arg)[index], component);
|
|
3431
|
-
});
|
|
3432
|
-
if (/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(abiParameterType))
|
|
3433
|
-
return argType === "number" || argType === "bigint";
|
|
3434
|
-
if (/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(abiParameterType))
|
|
3435
|
-
return argType === "string" || arg instanceof Uint8Array;
|
|
3436
|
-
if (/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(abiParameterType)) {
|
|
3437
|
-
return Array.isArray(arg) && arg.every((x) => isArgOfType(x, {
|
|
3438
|
-
...abiParameter,
|
|
3439
|
-
// Pop off `[]` or `[M]` from end of type
|
|
3440
|
-
type: abiParameterType.replace(/(\[[0-9]{0,}\])$/, "")
|
|
3441
|
-
}));
|
|
3442
|
-
}
|
|
3443
|
-
return false;
|
|
3444
|
-
}
|
|
3445
|
-
}
|
|
3446
|
-
}
|
|
3447
|
-
function getAmbiguousTypes(sourceParameters, targetParameters, args) {
|
|
3448
|
-
for (const parameterIndex in sourceParameters) {
|
|
3449
|
-
const sourceParameter = sourceParameters[parameterIndex];
|
|
3450
|
-
const targetParameter = targetParameters[parameterIndex];
|
|
3451
|
-
if (sourceParameter.type === "tuple" && targetParameter.type === "tuple" && "components" in sourceParameter && "components" in targetParameter)
|
|
3452
|
-
return getAmbiguousTypes(sourceParameter.components, targetParameter.components, args[parameterIndex]);
|
|
3453
|
-
const types = [sourceParameter.type, targetParameter.type];
|
|
3454
|
-
const ambiguous = (() => {
|
|
3455
|
-
if (types.includes("address") && types.includes("bytes20"))
|
|
3456
|
-
return true;
|
|
3457
|
-
if (types.includes("address") && types.includes("string"))
|
|
3458
|
-
return validate$2(args[parameterIndex], {
|
|
3459
|
-
strict: false
|
|
3460
|
-
});
|
|
3461
|
-
if (types.includes("address") && types.includes("bytes"))
|
|
3462
|
-
return validate$2(args[parameterIndex], {
|
|
3463
|
-
strict: false
|
|
3464
|
-
});
|
|
3465
|
-
return false;
|
|
3466
|
-
})();
|
|
3467
|
-
if (ambiguous)
|
|
3468
|
-
return types;
|
|
3469
|
-
}
|
|
3470
|
-
return;
|
|
3471
|
-
}
|
|
3472
|
-
function from$2(abiItem, options = {}) {
|
|
3473
|
-
const { prepare = true } = options;
|
|
3474
|
-
const item = (() => {
|
|
3475
|
-
if (Array.isArray(abiItem))
|
|
3476
|
-
return parseAbiItem(abiItem);
|
|
3477
|
-
if (typeof abiItem === "string")
|
|
3478
|
-
return parseAbiItem(abiItem);
|
|
3479
|
-
return abiItem;
|
|
3480
|
-
})();
|
|
3481
|
-
return {
|
|
3482
|
-
...item,
|
|
3483
|
-
...prepare ? { hash: getSignatureHash(item) } : {}
|
|
3484
|
-
};
|
|
3485
|
-
}
|
|
3486
|
-
function fromAbi$2(abi2, name, options) {
|
|
3487
|
-
const { args = [], prepare = true } = options ?? {};
|
|
3488
|
-
const isSelector = validate$4(name, { strict: false });
|
|
3489
|
-
const abiItems = abi2.filter((abiItem2) => {
|
|
3490
|
-
if (isSelector) {
|
|
3491
|
-
if (abiItem2.type === "function" || abiItem2.type === "error")
|
|
3492
|
-
return getSelector$1(abiItem2) === slice$1(name, 0, 4);
|
|
3493
|
-
if (abiItem2.type === "event")
|
|
3494
|
-
return getSignatureHash(abiItem2) === name;
|
|
3495
|
-
return false;
|
|
3496
|
-
}
|
|
3497
|
-
return "name" in abiItem2 && abiItem2.name === name;
|
|
3498
|
-
});
|
|
3499
|
-
if (abiItems.length === 0)
|
|
3500
|
-
throw new NotFoundError({ name });
|
|
3501
|
-
if (abiItems.length === 1)
|
|
3502
|
-
return {
|
|
3503
|
-
...abiItems[0],
|
|
3504
|
-
...prepare ? { hash: getSignatureHash(abiItems[0]) } : {}
|
|
3505
|
-
};
|
|
3506
|
-
let matchedAbiItem;
|
|
3507
|
-
for (const abiItem2 of abiItems) {
|
|
3508
|
-
if (!("inputs" in abiItem2))
|
|
3509
|
-
continue;
|
|
3510
|
-
if (!args || args.length === 0) {
|
|
3511
|
-
if (!abiItem2.inputs || abiItem2.inputs.length === 0)
|
|
3512
|
-
return {
|
|
3513
|
-
...abiItem2,
|
|
3514
|
-
...prepare ? { hash: getSignatureHash(abiItem2) } : {}
|
|
3515
|
-
};
|
|
3516
|
-
continue;
|
|
3517
|
-
}
|
|
3518
|
-
if (!abiItem2.inputs)
|
|
3519
|
-
continue;
|
|
3520
|
-
if (abiItem2.inputs.length === 0)
|
|
3521
|
-
continue;
|
|
3522
|
-
if (abiItem2.inputs.length !== args.length)
|
|
3523
|
-
continue;
|
|
3524
|
-
const matched = args.every((arg, index) => {
|
|
3525
|
-
const abiParameter = "inputs" in abiItem2 && abiItem2.inputs[index];
|
|
3526
|
-
if (!abiParameter)
|
|
3527
|
-
return false;
|
|
3528
|
-
return isArgOfType(arg, abiParameter);
|
|
3529
|
-
});
|
|
3530
|
-
if (matched) {
|
|
3531
|
-
if (matchedAbiItem && "inputs" in matchedAbiItem && matchedAbiItem.inputs) {
|
|
3532
|
-
const ambiguousTypes = getAmbiguousTypes(abiItem2.inputs, matchedAbiItem.inputs, args);
|
|
3533
|
-
if (ambiguousTypes)
|
|
3534
|
-
throw new AmbiguityError({
|
|
3535
|
-
abiItem: abiItem2,
|
|
3536
|
-
type: ambiguousTypes[0]
|
|
3537
|
-
}, {
|
|
3538
|
-
abiItem: matchedAbiItem,
|
|
3539
|
-
type: ambiguousTypes[1]
|
|
3540
|
-
});
|
|
3541
|
-
}
|
|
3542
|
-
matchedAbiItem = abiItem2;
|
|
3543
|
-
}
|
|
3544
|
-
}
|
|
3545
|
-
const abiItem = (() => {
|
|
3546
|
-
if (matchedAbiItem)
|
|
3547
|
-
return matchedAbiItem;
|
|
3548
|
-
const [abiItem2, ...overloads] = abiItems;
|
|
3549
|
-
return { ...abiItem2, overloads };
|
|
3550
|
-
})();
|
|
3551
|
-
if (!abiItem)
|
|
3552
|
-
throw new NotFoundError({ name });
|
|
3553
|
-
return {
|
|
3554
|
-
...abiItem,
|
|
3555
|
-
...prepare ? { hash: getSignatureHash(abiItem) } : {}
|
|
3556
|
-
};
|
|
3557
|
-
}
|
|
3558
|
-
function getSelector$1(...parameters) {
|
|
3559
|
-
const abiItem = (() => {
|
|
3560
|
-
if (Array.isArray(parameters[0])) {
|
|
3561
|
-
const [abi2, name] = parameters;
|
|
3562
|
-
return fromAbi$2(abi2, name);
|
|
3563
|
-
}
|
|
3564
|
-
return parameters[0];
|
|
3565
|
-
})();
|
|
3566
|
-
return slice$1(getSignatureHash(abiItem), 0, 4);
|
|
3567
|
-
}
|
|
3568
|
-
function getSignature(...parameters) {
|
|
3569
|
-
const abiItem = (() => {
|
|
3570
|
-
if (Array.isArray(parameters[0])) {
|
|
3571
|
-
const [abi2, name] = parameters;
|
|
3572
|
-
return fromAbi$2(abi2, name);
|
|
3573
|
-
}
|
|
3574
|
-
return parameters[0];
|
|
3575
|
-
})();
|
|
3576
|
-
const signature = (() => {
|
|
3577
|
-
if (typeof abiItem === "string")
|
|
3578
|
-
return abiItem;
|
|
3579
|
-
return formatAbiItem$1(abiItem);
|
|
3580
|
-
})();
|
|
3581
|
-
return normalizeSignature(signature);
|
|
3582
|
-
}
|
|
3583
|
-
function getSignatureHash(...parameters) {
|
|
3584
|
-
const abiItem = (() => {
|
|
3585
|
-
if (Array.isArray(parameters[0])) {
|
|
3586
|
-
const [abi2, name] = parameters;
|
|
3587
|
-
return fromAbi$2(abi2, name);
|
|
3588
|
-
}
|
|
3589
|
-
return parameters[0];
|
|
3590
|
-
})();
|
|
3591
|
-
if (typeof abiItem !== "string" && "hash" in abiItem && abiItem.hash)
|
|
3592
|
-
return abiItem.hash;
|
|
3593
|
-
return keccak256(fromString$1(getSignature(abiItem)));
|
|
3594
|
-
}
|
|
3595
|
-
class AmbiguityError extends BaseError$1 {
|
|
3596
|
-
constructor(x, y) {
|
|
3597
|
-
super("Found ambiguous types in overloaded ABI Items.", {
|
|
3598
|
-
metaMessages: [
|
|
3599
|
-
// TODO: abitype to add support for signature-formatted ABI items.
|
|
3600
|
-
`\`${x.type}\` in \`${normalizeSignature(formatAbiItem$1(x.abiItem))}\`, and`,
|
|
3601
|
-
`\`${y.type}\` in \`${normalizeSignature(formatAbiItem$1(y.abiItem))}\``,
|
|
3602
|
-
"",
|
|
3603
|
-
"These types encode differently and cannot be distinguished at runtime.",
|
|
3604
|
-
"Remove one of the ambiguous items in the ABI."
|
|
3605
|
-
]
|
|
3606
|
-
});
|
|
3607
|
-
Object.defineProperty(this, "name", {
|
|
3608
|
-
enumerable: true,
|
|
3609
|
-
configurable: true,
|
|
3610
|
-
writable: true,
|
|
3611
|
-
value: "AbiItem.AmbiguityError"
|
|
3612
|
-
});
|
|
3613
|
-
}
|
|
3614
|
-
}
|
|
3615
|
-
class NotFoundError extends BaseError$1 {
|
|
3616
|
-
constructor({ name, data, type = "item" }) {
|
|
3617
|
-
const selector = (() => {
|
|
3618
|
-
if (name)
|
|
3619
|
-
return ` with name "${name}"`;
|
|
3620
|
-
if (data)
|
|
3621
|
-
return ` with data "${data}"`;
|
|
3622
|
-
return "";
|
|
3623
|
-
})();
|
|
3624
|
-
super(`ABI ${type}${selector} not found.`);
|
|
3625
|
-
Object.defineProperty(this, "name", {
|
|
3626
|
-
enumerable: true,
|
|
3627
|
-
configurable: true,
|
|
3628
|
-
writable: true,
|
|
3629
|
-
value: "AbiItem.NotFoundError"
|
|
3630
|
-
});
|
|
3631
|
-
}
|
|
3632
|
-
}
|
|
3633
|
-
function encode(...parameters) {
|
|
3634
|
-
var _a;
|
|
3635
|
-
const [abiConstructor, options] = (() => {
|
|
3636
|
-
if (Array.isArray(parameters[0])) {
|
|
3637
|
-
const [abi2, options2] = parameters;
|
|
3638
|
-
return [fromAbi$1(abi2), options2];
|
|
3639
|
-
}
|
|
3640
|
-
return parameters;
|
|
3641
|
-
})();
|
|
3642
|
-
const { bytecode, args } = options;
|
|
3643
|
-
return concat$1(bytecode, ((_a = abiConstructor.inputs) == null ? void 0 : _a.length) && (args == null ? void 0 : args.length) ? encode$1(abiConstructor.inputs, args) : "0x");
|
|
3644
|
-
}
|
|
3645
|
-
function from$1(abiConstructor) {
|
|
3646
|
-
return from$2(abiConstructor);
|
|
3647
|
-
}
|
|
3648
|
-
function fromAbi$1(abi2) {
|
|
3649
|
-
const item = abi2.find((item2) => item2.type === "constructor");
|
|
3650
|
-
if (!item)
|
|
3651
|
-
throw new NotFoundError({ name: "constructor" });
|
|
3652
|
-
return item;
|
|
3653
|
-
}
|
|
3654
|
-
function encodeData(...parameters) {
|
|
3655
|
-
const [abiFunction, args = []] = (() => {
|
|
3656
|
-
if (Array.isArray(parameters[0])) {
|
|
3657
|
-
const [abi2, name, args3] = parameters;
|
|
3658
|
-
return [fromAbi(abi2, name, { args: args3 }), args3];
|
|
3659
|
-
}
|
|
3660
|
-
const [abiFunction2, args2] = parameters;
|
|
3661
|
-
return [abiFunction2, args2];
|
|
3662
|
-
})();
|
|
3663
|
-
const { overloads } = abiFunction;
|
|
3664
|
-
const item = overloads ? fromAbi([abiFunction, ...overloads], abiFunction.name, {
|
|
3665
|
-
args
|
|
3666
|
-
}) : abiFunction;
|
|
3667
|
-
const selector = getSelector(item);
|
|
3668
|
-
const data = args.length > 0 ? encode$1(item.inputs, args) : void 0;
|
|
3669
|
-
return data ? concat$1(selector, data) : selector;
|
|
3670
|
-
}
|
|
3671
|
-
function from(abiFunction, options = {}) {
|
|
3672
|
-
return from$2(abiFunction, options);
|
|
3673
|
-
}
|
|
3674
|
-
function fromAbi(abi2, name, options) {
|
|
3675
|
-
const item = fromAbi$2(abi2, name, options);
|
|
3676
|
-
if (item.type !== "function")
|
|
3677
|
-
throw new NotFoundError({ name, type: "function" });
|
|
3678
|
-
return item;
|
|
3679
|
-
}
|
|
3680
|
-
function getSelector(abiItem) {
|
|
3681
|
-
return getSelector$1(abiItem);
|
|
3682
|
-
}
|
|
3683
|
-
const ethAddress = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
3684
|
-
const zeroAddress = "0x0000000000000000000000000000000000000000";
|
|
3685
|
-
const getBalanceCode = "0x6080604052348015600e575f80fd5b5061016d8061001c5f395ff3fe608060405234801561000f575f80fd5b5060043610610029575f3560e01c8063f8b2cb4f1461002d575b5f80fd5b610047600480360381019061004291906100db565b61005d565b604051610054919061011e565b60405180910390f35b5f8173ffffffffffffffffffffffffffffffffffffffff16319050919050565b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100aa82610081565b9050919050565b6100ba816100a0565b81146100c4575f80fd5b50565b5f813590506100d5816100b1565b92915050565b5f602082840312156100f0576100ef61007d565b5b5f6100fd848285016100c7565b91505092915050565b5f819050919050565b61011881610106565b82525050565b5f6020820190506101315f83018461010f565b9291505056fea26469706673582212203b9fe929fe995c7cf9887f0bdba8a36dd78e8b73f149b17d2d9ad7cd09d2dc6264736f6c634300081a0033";
|
|
3686
|
-
async function simulateCalls(client, parameters) {
|
|
3687
|
-
const { blockNumber, blockTag, calls, stateOverrides, traceAssetChanges, traceTransfers, validation } = parameters;
|
|
3688
|
-
const account = parameters.account ? parseAccount(parameters.account) : void 0;
|
|
3689
|
-
if (traceAssetChanges && !account)
|
|
3690
|
-
throw new BaseError("`account` is required when `traceAssetChanges` is true");
|
|
3691
|
-
const getBalanceData = account ? encode(from$1("constructor(bytes, bytes)"), {
|
|
3692
|
-
bytecode: deploylessCallViaBytecodeBytecode,
|
|
3693
|
-
args: [
|
|
3694
|
-
getBalanceCode,
|
|
3695
|
-
encodeData(from("function getBalance(address)"), [account.address])
|
|
3696
|
-
]
|
|
3697
|
-
}) : void 0;
|
|
3698
|
-
const assetAddresses = traceAssetChanges ? await Promise.all(parameters.calls.map(async (call2) => {
|
|
3699
|
-
if (!call2.data && !call2.abi)
|
|
3700
|
-
return;
|
|
3701
|
-
const { accessList } = await createAccessList(client, {
|
|
3702
|
-
account: account.address,
|
|
3703
|
-
...call2,
|
|
3704
|
-
data: call2.abi ? encodeFunctionData(call2) : call2.data
|
|
3705
|
-
});
|
|
3706
|
-
return accessList.map(({ address, storageKeys }) => storageKeys.length > 0 ? address : null);
|
|
3707
|
-
})).then((x) => x.flat().filter(Boolean)) : [];
|
|
3708
|
-
const blocks = await simulateBlocks(client, {
|
|
3709
|
-
blockNumber,
|
|
3710
|
-
blockTag,
|
|
3711
|
-
blocks: [
|
|
3712
|
-
...traceAssetChanges ? [
|
|
3713
|
-
// ETH pre balances
|
|
3714
|
-
{
|
|
3715
|
-
calls: [{ data: getBalanceData }],
|
|
3716
|
-
stateOverrides
|
|
3717
|
-
},
|
|
3718
|
-
// Asset pre balances
|
|
3719
|
-
{
|
|
3720
|
-
calls: assetAddresses.map((address, i) => ({
|
|
3721
|
-
abi: [
|
|
3722
|
-
from("function balanceOf(address) returns (uint256)")
|
|
3723
|
-
],
|
|
3724
|
-
functionName: "balanceOf",
|
|
3725
|
-
args: [account.address],
|
|
3726
|
-
to: address,
|
|
3727
|
-
from: zeroAddress,
|
|
3728
|
-
nonce: i
|
|
3729
|
-
})),
|
|
3730
|
-
stateOverrides: [
|
|
3731
|
-
{
|
|
3732
|
-
address: zeroAddress,
|
|
3733
|
-
nonce: 0
|
|
3734
|
-
}
|
|
3735
|
-
]
|
|
3736
|
-
}
|
|
3737
|
-
] : [],
|
|
3738
|
-
{
|
|
3739
|
-
calls: [...calls, {}].map((call2) => ({
|
|
3740
|
-
...call2,
|
|
3741
|
-
from: account == null ? void 0 : account.address
|
|
3742
|
-
})),
|
|
3743
|
-
stateOverrides
|
|
3744
|
-
},
|
|
3745
|
-
...traceAssetChanges ? [
|
|
3746
|
-
// ETH post balances
|
|
3747
|
-
{
|
|
3748
|
-
calls: [{ data: getBalanceData }]
|
|
3749
|
-
},
|
|
3750
|
-
// Asset post balances
|
|
3751
|
-
{
|
|
3752
|
-
calls: assetAddresses.map((address, i) => ({
|
|
3753
|
-
abi: [
|
|
3754
|
-
from("function balanceOf(address) returns (uint256)")
|
|
3755
|
-
],
|
|
3756
|
-
functionName: "balanceOf",
|
|
3757
|
-
args: [account.address],
|
|
3758
|
-
to: address,
|
|
3759
|
-
from: zeroAddress,
|
|
3760
|
-
nonce: i
|
|
3761
|
-
})),
|
|
3762
|
-
stateOverrides: [
|
|
3763
|
-
{
|
|
3764
|
-
address: zeroAddress,
|
|
3765
|
-
nonce: 0
|
|
3766
|
-
}
|
|
3767
|
-
]
|
|
3768
|
-
},
|
|
3769
|
-
// Decimals
|
|
3770
|
-
{
|
|
3771
|
-
calls: assetAddresses.map((address, i) => ({
|
|
3772
|
-
to: address,
|
|
3773
|
-
abi: [
|
|
3774
|
-
from("function decimals() returns (uint256)")
|
|
3775
|
-
],
|
|
3776
|
-
functionName: "decimals",
|
|
3777
|
-
from: zeroAddress,
|
|
3778
|
-
nonce: i
|
|
3779
|
-
})),
|
|
3780
|
-
stateOverrides: [
|
|
3781
|
-
{
|
|
3782
|
-
address: zeroAddress,
|
|
3783
|
-
nonce: 0
|
|
3784
|
-
}
|
|
3785
|
-
]
|
|
3786
|
-
},
|
|
3787
|
-
// Token URI
|
|
3788
|
-
{
|
|
3789
|
-
calls: assetAddresses.map((address, i) => ({
|
|
3790
|
-
to: address,
|
|
3791
|
-
abi: [
|
|
3792
|
-
from("function tokenURI(uint256) returns (string)")
|
|
3793
|
-
],
|
|
3794
|
-
functionName: "tokenURI",
|
|
3795
|
-
args: [0n],
|
|
3796
|
-
from: zeroAddress,
|
|
3797
|
-
nonce: i
|
|
3798
|
-
})),
|
|
3799
|
-
stateOverrides: [
|
|
3800
|
-
{
|
|
3801
|
-
address: zeroAddress,
|
|
3802
|
-
nonce: 0
|
|
3803
|
-
}
|
|
3804
|
-
]
|
|
3805
|
-
},
|
|
3806
|
-
// Symbols
|
|
3807
|
-
{
|
|
3808
|
-
calls: assetAddresses.map((address, i) => ({
|
|
3809
|
-
to: address,
|
|
3810
|
-
abi: [from("function symbol() returns (string)")],
|
|
3811
|
-
functionName: "symbol",
|
|
3812
|
-
from: zeroAddress,
|
|
3813
|
-
nonce: i
|
|
3814
|
-
})),
|
|
3815
|
-
stateOverrides: [
|
|
3816
|
-
{
|
|
3817
|
-
address: zeroAddress,
|
|
3818
|
-
nonce: 0
|
|
3819
|
-
}
|
|
3820
|
-
]
|
|
3821
|
-
}
|
|
3822
|
-
] : []
|
|
3823
|
-
],
|
|
3824
|
-
traceTransfers,
|
|
3825
|
-
validation
|
|
3826
|
-
});
|
|
3827
|
-
const block_results = traceAssetChanges ? blocks[2] : blocks[0];
|
|
3828
|
-
const [block_ethPre, block_assetsPre, , block_ethPost, block_assetsPost, block_decimals, block_tokenURI, block_symbols] = traceAssetChanges ? blocks : [];
|
|
3829
|
-
const { calls: block_calls, ...block } = block_results;
|
|
3830
|
-
const results = block_calls.slice(0, -1) ?? [];
|
|
3831
|
-
const ethPre = (block_ethPre == null ? void 0 : block_ethPre.calls) ?? [];
|
|
3832
|
-
const assetsPre = (block_assetsPre == null ? void 0 : block_assetsPre.calls) ?? [];
|
|
3833
|
-
const balancesPre = [...ethPre, ...assetsPre].map((call2) => call2.status === "success" ? hexToBigInt(call2.data) : null);
|
|
3834
|
-
const ethPost = (block_ethPost == null ? void 0 : block_ethPost.calls) ?? [];
|
|
3835
|
-
const assetsPost = (block_assetsPost == null ? void 0 : block_assetsPost.calls) ?? [];
|
|
3836
|
-
const balancesPost = [...ethPost, ...assetsPost].map((call2) => call2.status === "success" ? hexToBigInt(call2.data) : null);
|
|
3837
|
-
const decimals = ((block_decimals == null ? void 0 : block_decimals.calls) ?? []).map((x) => x.status === "success" ? x.result : null);
|
|
3838
|
-
const symbols = ((block_symbols == null ? void 0 : block_symbols.calls) ?? []).map((x) => x.status === "success" ? x.result : null);
|
|
3839
|
-
const tokenURI = ((block_tokenURI == null ? void 0 : block_tokenURI.calls) ?? []).map((x) => x.status === "success" ? x.result : null);
|
|
3840
|
-
const changes = [];
|
|
3841
|
-
for (const [i, balancePost] of balancesPost.entries()) {
|
|
3842
|
-
const balancePre = balancesPre[i];
|
|
3843
|
-
if (typeof balancePost !== "bigint")
|
|
3844
|
-
continue;
|
|
3845
|
-
if (typeof balancePre !== "bigint")
|
|
3846
|
-
continue;
|
|
3847
|
-
const decimals_ = decimals[i - 1];
|
|
3848
|
-
const symbol_ = symbols[i - 1];
|
|
3849
|
-
const tokenURI_ = tokenURI[i - 1];
|
|
3850
|
-
const token = (() => {
|
|
3851
|
-
if (i === 0)
|
|
3852
|
-
return {
|
|
3853
|
-
address: ethAddress,
|
|
3854
|
-
decimals: 18,
|
|
3855
|
-
symbol: "ETH"
|
|
3856
|
-
};
|
|
3857
|
-
return {
|
|
3858
|
-
address: assetAddresses[i - 1],
|
|
3859
|
-
decimals: tokenURI_ || decimals_ ? Number(decimals_ ?? 1) : void 0,
|
|
3860
|
-
symbol: symbol_ ?? void 0
|
|
3861
|
-
};
|
|
3862
|
-
})();
|
|
3863
|
-
if (changes.some((change) => change.token.address === token.address))
|
|
3864
|
-
continue;
|
|
3865
|
-
changes.push({
|
|
3866
|
-
token,
|
|
3867
|
-
value: {
|
|
3868
|
-
pre: balancePre,
|
|
3869
|
-
post: balancePost,
|
|
3870
|
-
diff: balancePost - balancePre
|
|
3871
|
-
}
|
|
3872
|
-
});
|
|
3873
|
-
}
|
|
3874
|
-
return {
|
|
3875
|
-
assetChanges: changes,
|
|
3876
|
-
block,
|
|
3877
|
-
results
|
|
3878
|
-
};
|
|
3879
|
-
}
|
|
3880
|
-
const magicBytes = "0x6492649264926492649264926492649264926492649264926492649264926492";
|
|
3881
|
-
function assert(wrapped) {
|
|
3882
|
-
if (slice$1(wrapped, -32) !== magicBytes)
|
|
3883
|
-
throw new InvalidWrappedSignatureError2(wrapped);
|
|
3884
|
-
}
|
|
3885
|
-
function wrap(value) {
|
|
3886
|
-
const { data, signature, to } = value;
|
|
3887
|
-
return concat$1(encode$1(from$6("address, bytes, bytes"), [
|
|
3888
|
-
to,
|
|
3889
|
-
data,
|
|
3890
|
-
signature
|
|
3891
|
-
]), magicBytes);
|
|
3892
|
-
}
|
|
3893
|
-
function validate(wrapped) {
|
|
3894
|
-
try {
|
|
3895
|
-
assert(wrapped);
|
|
3896
|
-
return true;
|
|
3897
|
-
} catch {
|
|
3898
|
-
return false;
|
|
3899
|
-
}
|
|
3900
|
-
}
|
|
3901
|
-
class InvalidWrappedSignatureError2 extends BaseError$1 {
|
|
3902
|
-
constructor(wrapped) {
|
|
3903
|
-
super(`Value \`${wrapped}\` is an invalid ERC-6492 wrapped signature.`);
|
|
3904
|
-
Object.defineProperty(this, "name", {
|
|
3905
|
-
enumerable: true,
|
|
3906
|
-
configurable: true,
|
|
3907
|
-
writable: true,
|
|
3908
|
-
value: "SignatureErc6492.InvalidWrappedSignatureError"
|
|
3909
|
-
});
|
|
3910
|
-
}
|
|
3911
|
-
}
|
|
3912
|
-
function serializeSignature({ r, s, to = "hex", v, yParity }) {
|
|
3913
|
-
const yParity_ = (() => {
|
|
3914
|
-
if (yParity === 0 || yParity === 1)
|
|
3915
|
-
return yParity;
|
|
3916
|
-
if (v && (v === 27n || v === 28n || v >= 35n))
|
|
3917
|
-
return v % 2n === 0n ? 1 : 0;
|
|
3918
|
-
throw new Error("Invalid `v` or `yParity` value");
|
|
3919
|
-
})();
|
|
3920
|
-
const signature = `0x${new secp256k1.Signature(hexToBigInt(r), hexToBigInt(s)).toCompactHex()}${yParity_ === 0 ? "1b" : "1c"}`;
|
|
3921
|
-
if (to === "hex")
|
|
3922
|
-
return signature;
|
|
3923
|
-
return hexToBytes(signature);
|
|
3924
|
-
}
|
|
3925
|
-
async function verifyHash(client, parameters) {
|
|
3926
|
-
var _a, _b, _c, _d, _e, _f;
|
|
3927
|
-
const { address, hash: hash2, erc6492VerifierAddress: verifierAddress = parameters.universalSignatureVerifierAddress ?? ((_c = (_b = (_a = client.chain) == null ? void 0 : _a.contracts) == null ? void 0 : _b.erc6492Verifier) == null ? void 0 : _c.address), multicallAddress = parameters.multicallAddress ?? ((_f = (_e = (_d = client.chain) == null ? void 0 : _d.contracts) == null ? void 0 : _e.multicall3) == null ? void 0 : _f.address) } = parameters;
|
|
3928
|
-
const signature = (() => {
|
|
3929
|
-
const signature2 = parameters.signature;
|
|
3930
|
-
if (isHex(signature2))
|
|
3931
|
-
return signature2;
|
|
3932
|
-
if (typeof signature2 === "object" && "r" in signature2 && "s" in signature2)
|
|
3933
|
-
return serializeSignature(signature2);
|
|
3934
|
-
return bytesToHex(signature2);
|
|
3935
|
-
})();
|
|
3936
|
-
try {
|
|
3937
|
-
if (validate$1(signature))
|
|
3938
|
-
return await verifyErc8010(client, {
|
|
3939
|
-
...parameters,
|
|
3940
|
-
multicallAddress,
|
|
3941
|
-
signature
|
|
3942
|
-
});
|
|
3943
|
-
return await verifyErc6492(client, {
|
|
3944
|
-
...parameters,
|
|
3945
|
-
verifierAddress,
|
|
3946
|
-
signature
|
|
3947
|
-
});
|
|
3948
|
-
} catch (error) {
|
|
3949
|
-
try {
|
|
3950
|
-
const verified = isAddressEqual(getAddress(address), await recoverAddress$1({ hash: hash2, signature }));
|
|
3951
|
-
if (verified)
|
|
3952
|
-
return true;
|
|
3953
|
-
} catch {
|
|
3954
|
-
}
|
|
3955
|
-
if (error instanceof VerificationError) {
|
|
3956
|
-
return false;
|
|
3957
|
-
}
|
|
3958
|
-
throw error;
|
|
3959
|
-
}
|
|
3960
|
-
}
|
|
3961
|
-
async function verifyErc8010(client, parameters) {
|
|
3962
|
-
var _a;
|
|
3963
|
-
const { address, blockNumber, blockTag, hash: hash2, multicallAddress } = parameters;
|
|
3964
|
-
const { authorization: authorization_ox, data: initData, signature, to } = unwrap(parameters.signature);
|
|
3965
|
-
const code = await getCode(client, {
|
|
3966
|
-
address,
|
|
3967
|
-
blockNumber,
|
|
3968
|
-
blockTag
|
|
3969
|
-
});
|
|
3970
|
-
if (code === concatHex(["0xef0100", authorization_ox.address]))
|
|
3971
|
-
return await verifyErc1271(client, {
|
|
3972
|
-
address,
|
|
3973
|
-
blockNumber,
|
|
3974
|
-
blockTag,
|
|
3975
|
-
hash: hash2,
|
|
3976
|
-
signature
|
|
3977
|
-
});
|
|
3978
|
-
const authorization = {
|
|
3979
|
-
address: authorization_ox.address,
|
|
3980
|
-
chainId: Number(authorization_ox.chainId),
|
|
3981
|
-
nonce: Number(authorization_ox.nonce),
|
|
3982
|
-
r: numberToHex(authorization_ox.r, { size: 32 }),
|
|
3983
|
-
s: numberToHex(authorization_ox.s, { size: 32 }),
|
|
3984
|
-
yParity: authorization_ox.yParity
|
|
3985
|
-
};
|
|
3986
|
-
const valid = await verifyAuthorization({
|
|
3987
|
-
address,
|
|
3988
|
-
authorization
|
|
3989
|
-
});
|
|
3990
|
-
if (!valid)
|
|
3991
|
-
throw new VerificationError();
|
|
3992
|
-
const results = await getAction(client, readContract, "readContract")({
|
|
3993
|
-
...multicallAddress ? { address: multicallAddress } : { code: multicall3Bytecode },
|
|
3994
|
-
authorizationList: [authorization],
|
|
3995
|
-
abi: multicall3Abi,
|
|
3996
|
-
blockNumber,
|
|
3997
|
-
blockTag: "pending",
|
|
3998
|
-
functionName: "aggregate3",
|
|
3999
|
-
args: [
|
|
4000
|
-
[
|
|
4001
|
-
...initData ? [
|
|
4002
|
-
{
|
|
4003
|
-
allowFailure: true,
|
|
4004
|
-
target: to ?? address,
|
|
4005
|
-
callData: initData
|
|
4006
|
-
}
|
|
4007
|
-
] : [],
|
|
4008
|
-
{
|
|
4009
|
-
allowFailure: true,
|
|
4010
|
-
target: address,
|
|
4011
|
-
callData: encodeFunctionData({
|
|
4012
|
-
abi: erc1271Abi,
|
|
4013
|
-
functionName: "isValidSignature",
|
|
4014
|
-
args: [hash2, signature]
|
|
4015
|
-
})
|
|
4016
|
-
}
|
|
4017
|
-
]
|
|
4018
|
-
]
|
|
4019
|
-
});
|
|
4020
|
-
const data = (_a = results[results.length - 1]) == null ? void 0 : _a.returnData;
|
|
4021
|
-
if (data == null ? void 0 : data.startsWith("0x1626ba7e"))
|
|
4022
|
-
return true;
|
|
4023
|
-
throw new VerificationError();
|
|
4024
|
-
}
|
|
4025
|
-
async function verifyErc6492(client, parameters) {
|
|
4026
|
-
const { address, factory, factoryData, hash: hash2, signature, verifierAddress, ...rest } = parameters;
|
|
4027
|
-
const wrappedSignature = await (async () => {
|
|
4028
|
-
if (!factory && !factoryData)
|
|
4029
|
-
return signature;
|
|
4030
|
-
if (validate(signature))
|
|
4031
|
-
return signature;
|
|
4032
|
-
return wrap({
|
|
4033
|
-
data: factoryData,
|
|
4034
|
-
signature,
|
|
4035
|
-
to: factory
|
|
4036
|
-
});
|
|
4037
|
-
})();
|
|
4038
|
-
const args = verifierAddress ? {
|
|
4039
|
-
to: verifierAddress,
|
|
4040
|
-
data: encodeFunctionData({
|
|
4041
|
-
abi: erc6492SignatureValidatorAbi,
|
|
4042
|
-
functionName: "isValidSig",
|
|
4043
|
-
args: [address, hash2, wrappedSignature]
|
|
4044
|
-
}),
|
|
4045
|
-
...rest
|
|
4046
|
-
} : {
|
|
4047
|
-
data: encodeDeployData({
|
|
4048
|
-
abi: erc6492SignatureValidatorAbi,
|
|
4049
|
-
args: [address, hash2, wrappedSignature],
|
|
4050
|
-
bytecode: erc6492SignatureValidatorByteCode
|
|
4051
|
-
}),
|
|
4052
|
-
...rest
|
|
4053
|
-
};
|
|
4054
|
-
const { data } = await getAction(client, call, "call")(args).catch((error) => {
|
|
4055
|
-
if (error instanceof CallExecutionError)
|
|
4056
|
-
throw new VerificationError();
|
|
4057
|
-
throw error;
|
|
4058
|
-
});
|
|
4059
|
-
if (hexToBool(data ?? "0x0"))
|
|
4060
|
-
return true;
|
|
4061
|
-
throw new VerificationError();
|
|
4062
|
-
}
|
|
4063
|
-
async function verifyErc1271(client, parameters) {
|
|
4064
|
-
const { address, blockNumber, blockTag, hash: hash2, signature } = parameters;
|
|
4065
|
-
const result = await getAction(client, readContract, "readContract")({
|
|
4066
|
-
address,
|
|
4067
|
-
abi: erc1271Abi,
|
|
4068
|
-
args: [hash2, signature],
|
|
4069
|
-
blockNumber,
|
|
4070
|
-
blockTag,
|
|
4071
|
-
functionName: "isValidSignature"
|
|
4072
|
-
}).catch((error) => {
|
|
4073
|
-
if (error instanceof ContractFunctionExecutionError)
|
|
4074
|
-
throw new VerificationError();
|
|
4075
|
-
throw error;
|
|
4076
|
-
});
|
|
4077
|
-
if (result.startsWith("0x1626ba7e"))
|
|
4078
|
-
return true;
|
|
4079
|
-
throw new VerificationError();
|
|
4080
|
-
}
|
|
4081
|
-
class VerificationError extends Error {
|
|
4082
|
-
}
|
|
4083
|
-
async function verifyMessage(client, { address, message, factory, factoryData, signature, ...callRequest }) {
|
|
4084
|
-
const hash2 = hashMessage(message);
|
|
4085
|
-
return verifyHash(client, {
|
|
4086
|
-
address,
|
|
4087
|
-
factory,
|
|
4088
|
-
factoryData,
|
|
4089
|
-
hash: hash2,
|
|
4090
|
-
signature,
|
|
4091
|
-
...callRequest
|
|
4092
|
-
});
|
|
4093
|
-
}
|
|
4094
|
-
async function verifyTypedData(client, parameters) {
|
|
4095
|
-
const { address, factory, factoryData, signature, message, primaryType, types, domain, ...callRequest } = parameters;
|
|
4096
|
-
const hash2 = hashTypedData({ message, primaryType, types, domain });
|
|
4097
|
-
return verifyHash(client, {
|
|
4098
|
-
address,
|
|
4099
|
-
factory,
|
|
4100
|
-
factoryData,
|
|
4101
|
-
hash: hash2,
|
|
4102
|
-
signature,
|
|
4103
|
-
...callRequest
|
|
4104
|
-
});
|
|
4105
|
-
}
|
|
4106
|
-
function watchBlocks(client, { blockTag = client.experimental_blockTag ?? "latest", emitMissed = false, emitOnBegin = false, onBlock, onError, includeTransactions: includeTransactions_, poll: poll_, pollingInterval = client.pollingInterval }) {
|
|
4107
|
-
const enablePolling = (() => {
|
|
4108
|
-
if (typeof poll_ !== "undefined")
|
|
4109
|
-
return poll_;
|
|
4110
|
-
if (client.transport.type === "webSocket" || client.transport.type === "ipc")
|
|
4111
|
-
return false;
|
|
4112
|
-
if (client.transport.type === "fallback" && (client.transport.transports[0].config.type === "webSocket" || client.transport.transports[0].config.type === "ipc"))
|
|
4113
|
-
return false;
|
|
4114
|
-
return true;
|
|
4115
|
-
})();
|
|
4116
|
-
const includeTransactions = includeTransactions_ ?? false;
|
|
4117
|
-
let prevBlock;
|
|
4118
|
-
const pollBlocks = () => {
|
|
4119
|
-
const observerId = stringify$1([
|
|
4120
|
-
"watchBlocks",
|
|
4121
|
-
client.uid,
|
|
4122
|
-
blockTag,
|
|
4123
|
-
emitMissed,
|
|
4124
|
-
emitOnBegin,
|
|
4125
|
-
includeTransactions,
|
|
4126
|
-
pollingInterval
|
|
4127
|
-
]);
|
|
4128
|
-
return observe(observerId, { onBlock, onError }, (emit) => poll(async () => {
|
|
4129
|
-
var _a;
|
|
4130
|
-
try {
|
|
4131
|
-
const block = await getAction(client, getBlock, "getBlock")({
|
|
4132
|
-
blockTag,
|
|
4133
|
-
includeTransactions
|
|
4134
|
-
});
|
|
4135
|
-
if (block.number !== null && (prevBlock == null ? void 0 : prevBlock.number) != null) {
|
|
4136
|
-
if (block.number === prevBlock.number)
|
|
4137
|
-
return;
|
|
4138
|
-
if (block.number - prevBlock.number > 1 && emitMissed) {
|
|
4139
|
-
for (let i = (prevBlock == null ? void 0 : prevBlock.number) + 1n; i < block.number; i++) {
|
|
4140
|
-
const block2 = await getAction(client, getBlock, "getBlock")({
|
|
4141
|
-
blockNumber: i,
|
|
4142
|
-
includeTransactions
|
|
4143
|
-
});
|
|
4144
|
-
emit.onBlock(block2, prevBlock);
|
|
4145
|
-
prevBlock = block2;
|
|
4146
|
-
}
|
|
4147
|
-
}
|
|
4148
|
-
}
|
|
4149
|
-
if (
|
|
4150
|
-
// If no previous block exists, emit.
|
|
4151
|
-
(prevBlock == null ? void 0 : prevBlock.number) == null || // If the block tag is "pending" with no block number, emit.
|
|
4152
|
-
blockTag === "pending" && (block == null ? void 0 : block.number) == null || // If the next block number is greater than the previous block number, emit.
|
|
4153
|
-
// We don't want to emit blocks in the past.
|
|
4154
|
-
block.number !== null && block.number > prevBlock.number
|
|
4155
|
-
) {
|
|
4156
|
-
emit.onBlock(block, prevBlock);
|
|
4157
|
-
prevBlock = block;
|
|
4158
|
-
}
|
|
4159
|
-
} catch (err) {
|
|
4160
|
-
(_a = emit.onError) == null ? void 0 : _a.call(emit, err);
|
|
4161
|
-
}
|
|
4162
|
-
}, {
|
|
4163
|
-
emitOnBegin,
|
|
4164
|
-
interval: pollingInterval
|
|
4165
|
-
}));
|
|
4166
|
-
};
|
|
4167
|
-
const subscribeBlocks = () => {
|
|
4168
|
-
let active = true;
|
|
4169
|
-
let emitFetched = true;
|
|
4170
|
-
let unsubscribe = () => active = false;
|
|
4171
|
-
(async () => {
|
|
4172
|
-
try {
|
|
4173
|
-
if (emitOnBegin) {
|
|
4174
|
-
getAction(client, getBlock, "getBlock")({
|
|
4175
|
-
blockTag,
|
|
4176
|
-
includeTransactions
|
|
4177
|
-
}).then((block) => {
|
|
4178
|
-
if (!active)
|
|
4179
|
-
return;
|
|
4180
|
-
if (!emitFetched)
|
|
4181
|
-
return;
|
|
4182
|
-
onBlock(block, void 0);
|
|
4183
|
-
emitFetched = false;
|
|
4184
|
-
}).catch(onError);
|
|
4185
|
-
}
|
|
4186
|
-
const transport = (() => {
|
|
4187
|
-
if (client.transport.type === "fallback") {
|
|
4188
|
-
const transport2 = client.transport.transports.find((transport3) => transport3.config.type === "webSocket" || transport3.config.type === "ipc");
|
|
4189
|
-
if (!transport2)
|
|
4190
|
-
return client.transport;
|
|
4191
|
-
return transport2.value;
|
|
4192
|
-
}
|
|
4193
|
-
return client.transport;
|
|
4194
|
-
})();
|
|
4195
|
-
const { unsubscribe: unsubscribe_ } = await transport.subscribe({
|
|
4196
|
-
params: ["newHeads"],
|
|
4197
|
-
async onData(data) {
|
|
4198
|
-
var _a;
|
|
4199
|
-
if (!active)
|
|
4200
|
-
return;
|
|
4201
|
-
const block = await getAction(client, getBlock, "getBlock")({
|
|
4202
|
-
blockNumber: (_a = data.result) == null ? void 0 : _a.number,
|
|
4203
|
-
includeTransactions
|
|
4204
|
-
}).catch(() => {
|
|
4205
|
-
});
|
|
4206
|
-
if (!active)
|
|
4207
|
-
return;
|
|
4208
|
-
onBlock(block, prevBlock);
|
|
4209
|
-
emitFetched = false;
|
|
4210
|
-
prevBlock = block;
|
|
4211
|
-
},
|
|
4212
|
-
onError(error) {
|
|
4213
|
-
onError == null ? void 0 : onError(error);
|
|
4214
|
-
}
|
|
4215
|
-
});
|
|
4216
|
-
unsubscribe = unsubscribe_;
|
|
4217
|
-
if (!active)
|
|
4218
|
-
unsubscribe();
|
|
4219
|
-
} catch (err) {
|
|
4220
|
-
onError == null ? void 0 : onError(err);
|
|
4221
|
-
}
|
|
4222
|
-
})();
|
|
4223
|
-
return () => unsubscribe();
|
|
4224
|
-
};
|
|
4225
|
-
return enablePolling ? pollBlocks() : subscribeBlocks();
|
|
4226
|
-
}
|
|
4227
|
-
function watchEvent(client, { address, args, batch = true, event, events, fromBlock, onError, onLogs, poll: poll_, pollingInterval = client.pollingInterval, strict: strict_ }) {
|
|
4228
|
-
const enablePolling = (() => {
|
|
4229
|
-
if (typeof poll_ !== "undefined")
|
|
4230
|
-
return poll_;
|
|
4231
|
-
if (typeof fromBlock === "bigint")
|
|
4232
|
-
return true;
|
|
4233
|
-
if (client.transport.type === "webSocket" || client.transport.type === "ipc")
|
|
4234
|
-
return false;
|
|
4235
|
-
if (client.transport.type === "fallback" && (client.transport.transports[0].config.type === "webSocket" || client.transport.transports[0].config.type === "ipc"))
|
|
4236
|
-
return false;
|
|
4237
|
-
return true;
|
|
4238
|
-
})();
|
|
4239
|
-
const strict = strict_ ?? false;
|
|
4240
|
-
const pollEvent = () => {
|
|
4241
|
-
const observerId = stringify$1([
|
|
4242
|
-
"watchEvent",
|
|
4243
|
-
address,
|
|
4244
|
-
args,
|
|
4245
|
-
batch,
|
|
4246
|
-
client.uid,
|
|
4247
|
-
event,
|
|
4248
|
-
pollingInterval,
|
|
4249
|
-
fromBlock
|
|
4250
|
-
]);
|
|
4251
|
-
return observe(observerId, { onLogs, onError }, (emit) => {
|
|
4252
|
-
let previousBlockNumber;
|
|
4253
|
-
if (fromBlock !== void 0)
|
|
4254
|
-
previousBlockNumber = fromBlock - 1n;
|
|
4255
|
-
let filter;
|
|
4256
|
-
let initialized = false;
|
|
4257
|
-
const unwatch = poll(async () => {
|
|
4258
|
-
var _a;
|
|
4259
|
-
if (!initialized) {
|
|
4260
|
-
try {
|
|
4261
|
-
filter = await getAction(client, createEventFilter, "createEventFilter")({
|
|
4262
|
-
address,
|
|
4263
|
-
args,
|
|
4264
|
-
event,
|
|
4265
|
-
events,
|
|
4266
|
-
strict,
|
|
4267
|
-
fromBlock
|
|
4268
|
-
});
|
|
4269
|
-
} catch {
|
|
4270
|
-
}
|
|
4271
|
-
initialized = true;
|
|
4272
|
-
return;
|
|
4273
|
-
}
|
|
4274
|
-
try {
|
|
4275
|
-
let logs;
|
|
4276
|
-
if (filter) {
|
|
4277
|
-
logs = await getAction(client, getFilterChanges, "getFilterChanges")({ filter });
|
|
4278
|
-
} else {
|
|
4279
|
-
const blockNumber = await getAction(client, getBlockNumber, "getBlockNumber")({});
|
|
4280
|
-
if (previousBlockNumber && previousBlockNumber !== blockNumber) {
|
|
4281
|
-
logs = await getAction(client, getLogs, "getLogs")({
|
|
4282
|
-
address,
|
|
4283
|
-
args,
|
|
4284
|
-
event,
|
|
4285
|
-
events,
|
|
4286
|
-
fromBlock: previousBlockNumber + 1n,
|
|
4287
|
-
toBlock: blockNumber
|
|
4288
|
-
});
|
|
4289
|
-
} else {
|
|
4290
|
-
logs = [];
|
|
4291
|
-
}
|
|
4292
|
-
previousBlockNumber = blockNumber;
|
|
4293
|
-
}
|
|
4294
|
-
if (logs.length === 0)
|
|
4295
|
-
return;
|
|
4296
|
-
if (batch)
|
|
4297
|
-
emit.onLogs(logs);
|
|
4298
|
-
else
|
|
4299
|
-
for (const log of logs)
|
|
4300
|
-
emit.onLogs([log]);
|
|
4301
|
-
} catch (err) {
|
|
4302
|
-
if (filter && err instanceof InvalidInputRpcError)
|
|
4303
|
-
initialized = false;
|
|
4304
|
-
(_a = emit.onError) == null ? void 0 : _a.call(emit, err);
|
|
4305
|
-
}
|
|
4306
|
-
}, {
|
|
4307
|
-
emitOnBegin: true,
|
|
4308
|
-
interval: pollingInterval
|
|
4309
|
-
});
|
|
4310
|
-
return async () => {
|
|
4311
|
-
if (filter)
|
|
4312
|
-
await getAction(client, uninstallFilter, "uninstallFilter")({ filter });
|
|
4313
|
-
unwatch();
|
|
4314
|
-
};
|
|
4315
|
-
});
|
|
4316
|
-
};
|
|
4317
|
-
const subscribeEvent = () => {
|
|
4318
|
-
let active = true;
|
|
4319
|
-
let unsubscribe = () => active = false;
|
|
4320
|
-
(async () => {
|
|
4321
|
-
try {
|
|
4322
|
-
const transport = (() => {
|
|
4323
|
-
if (client.transport.type === "fallback") {
|
|
4324
|
-
const transport2 = client.transport.transports.find((transport3) => transport3.config.type === "webSocket" || transport3.config.type === "ipc");
|
|
4325
|
-
if (!transport2)
|
|
4326
|
-
return client.transport;
|
|
4327
|
-
return transport2.value;
|
|
4328
|
-
}
|
|
4329
|
-
return client.transport;
|
|
4330
|
-
})();
|
|
4331
|
-
const events_ = events ?? (event ? [event] : void 0);
|
|
4332
|
-
let topics = [];
|
|
4333
|
-
if (events_) {
|
|
4334
|
-
const encoded = events_.flatMap((event2) => encodeEventTopics({
|
|
4335
|
-
abi: [event2],
|
|
4336
|
-
eventName: event2.name,
|
|
4337
|
-
args
|
|
4338
|
-
}));
|
|
4339
|
-
topics = [encoded];
|
|
4340
|
-
if (event)
|
|
4341
|
-
topics = topics[0];
|
|
4342
|
-
}
|
|
4343
|
-
const { unsubscribe: unsubscribe_ } = await transport.subscribe({
|
|
4344
|
-
params: ["logs", { address, topics }],
|
|
4345
|
-
onData(data) {
|
|
4346
|
-
var _a;
|
|
4347
|
-
if (!active)
|
|
4348
|
-
return;
|
|
4349
|
-
const log = data.result;
|
|
4350
|
-
try {
|
|
4351
|
-
const { eventName, args: args2 } = decodeEventLog({
|
|
4352
|
-
abi: events_ ?? [],
|
|
4353
|
-
data: log.data,
|
|
4354
|
-
topics: log.topics,
|
|
4355
|
-
strict
|
|
4356
|
-
});
|
|
4357
|
-
const formatted = formatLog(log, { args: args2, eventName });
|
|
4358
|
-
onLogs([formatted]);
|
|
4359
|
-
} catch (err) {
|
|
4360
|
-
let eventName;
|
|
4361
|
-
let isUnnamed;
|
|
4362
|
-
if (err instanceof DecodeLogDataMismatch || err instanceof DecodeLogTopicsMismatch) {
|
|
4363
|
-
if (strict_)
|
|
4364
|
-
return;
|
|
4365
|
-
eventName = err.abiItem.name;
|
|
4366
|
-
isUnnamed = (_a = err.abiItem.inputs) == null ? void 0 : _a.some((x) => !("name" in x && x.name));
|
|
4367
|
-
}
|
|
4368
|
-
const formatted = formatLog(log, {
|
|
4369
|
-
args: isUnnamed ? [] : {},
|
|
4370
|
-
eventName
|
|
4371
|
-
});
|
|
4372
|
-
onLogs([formatted]);
|
|
4373
|
-
}
|
|
4374
|
-
},
|
|
4375
|
-
onError(error) {
|
|
4376
|
-
onError == null ? void 0 : onError(error);
|
|
4377
|
-
}
|
|
4378
|
-
});
|
|
4379
|
-
unsubscribe = unsubscribe_;
|
|
4380
|
-
if (!active)
|
|
4381
|
-
unsubscribe();
|
|
4382
|
-
} catch (err) {
|
|
4383
|
-
onError == null ? void 0 : onError(err);
|
|
4384
|
-
}
|
|
4385
|
-
})();
|
|
4386
|
-
return () => unsubscribe();
|
|
4387
|
-
};
|
|
4388
|
-
return enablePolling ? pollEvent() : subscribeEvent();
|
|
4389
|
-
}
|
|
4390
|
-
function parseSiweMessage(message) {
|
|
4391
|
-
var _a, _b, _c;
|
|
4392
|
-
const { scheme, statement, ...prefix } = ((_a = message.match(prefixRegex)) == null ? void 0 : _a.groups) ?? {};
|
|
4393
|
-
const { chainId, expirationTime, issuedAt, notBefore, requestId, ...suffix } = ((_b = message.match(suffixRegex)) == null ? void 0 : _b.groups) ?? {};
|
|
4394
|
-
const resources = (_c = message.split("Resources:")[1]) == null ? void 0 : _c.split("\n- ").slice(1);
|
|
4395
|
-
return {
|
|
4396
|
-
...prefix,
|
|
4397
|
-
...suffix,
|
|
4398
|
-
...chainId ? { chainId: Number(chainId) } : {},
|
|
4399
|
-
...expirationTime ? { expirationTime: new Date(expirationTime) } : {},
|
|
4400
|
-
...issuedAt ? { issuedAt: new Date(issuedAt) } : {},
|
|
4401
|
-
...notBefore ? { notBefore: new Date(notBefore) } : {},
|
|
4402
|
-
...requestId ? { requestId } : {},
|
|
4403
|
-
...resources ? { resources } : {},
|
|
4404
|
-
...scheme ? { scheme } : {},
|
|
4405
|
-
...statement ? { statement } : {}
|
|
4406
|
-
};
|
|
4407
|
-
}
|
|
4408
|
-
const prefixRegex = /^(?:(?<scheme>[a-zA-Z][a-zA-Z0-9+-.]*):\/\/)?(?<domain>[a-zA-Z0-9+-.]*(?::[0-9]{1,5})?) (?:wants you to sign in with your Ethereum account:\n)(?<address>0x[a-fA-F0-9]{40})\n\n(?:(?<statement>.*)\n\n)?/;
|
|
4409
|
-
const suffixRegex = /(?:URI: (?<uri>.+))\n(?:Version: (?<version>.+))\n(?:Chain ID: (?<chainId>\d+))\n(?:Nonce: (?<nonce>[a-zA-Z0-9]+))\n(?:Issued At: (?<issuedAt>.+))(?:\nExpiration Time: (?<expirationTime>.+))?(?:\nNot Before: (?<notBefore>.+))?(?:\nRequest ID: (?<requestId>.+))?/;
|
|
4410
|
-
function validateSiweMessage(parameters) {
|
|
4411
|
-
const { address, domain, message, nonce, scheme, time = /* @__PURE__ */ new Date() } = parameters;
|
|
4412
|
-
if (domain && message.domain !== domain)
|
|
4413
|
-
return false;
|
|
4414
|
-
if (nonce && message.nonce !== nonce)
|
|
4415
|
-
return false;
|
|
4416
|
-
if (scheme && message.scheme !== scheme)
|
|
4417
|
-
return false;
|
|
4418
|
-
if (message.expirationTime && time >= message.expirationTime)
|
|
4419
|
-
return false;
|
|
4420
|
-
if (message.notBefore && time < message.notBefore)
|
|
4421
|
-
return false;
|
|
4422
|
-
try {
|
|
4423
|
-
if (!message.address)
|
|
4424
|
-
return false;
|
|
4425
|
-
if (!isAddress(message.address, { strict: false }))
|
|
4426
|
-
return false;
|
|
4427
|
-
if (address && !isAddressEqual(message.address, address))
|
|
4428
|
-
return false;
|
|
4429
|
-
} catch {
|
|
4430
|
-
return false;
|
|
4431
|
-
}
|
|
4432
|
-
return true;
|
|
4433
|
-
}
|
|
4434
|
-
async function verifySiweMessage(client, parameters) {
|
|
4435
|
-
const { address, domain, message, nonce, scheme, signature, time = /* @__PURE__ */ new Date(), ...callRequest } = parameters;
|
|
4436
|
-
const parsed = parseSiweMessage(message);
|
|
4437
|
-
if (!parsed.address)
|
|
4438
|
-
return false;
|
|
4439
|
-
const isValid = validateSiweMessage({
|
|
4440
|
-
address,
|
|
4441
|
-
domain,
|
|
4442
|
-
message: parsed,
|
|
4443
|
-
nonce,
|
|
4444
|
-
scheme,
|
|
4445
|
-
time
|
|
4446
|
-
});
|
|
4447
|
-
if (!isValid)
|
|
4448
|
-
return false;
|
|
4449
|
-
const hash2 = hashMessage(message);
|
|
4450
|
-
return verifyHash(client, {
|
|
4451
|
-
address: parsed.address,
|
|
4452
|
-
hash: hash2,
|
|
4453
|
-
signature,
|
|
4454
|
-
...callRequest
|
|
4455
|
-
});
|
|
4456
|
-
}
|
|
4457
|
-
function publicActions(client) {
|
|
4458
|
-
return {
|
|
4459
|
-
call: (args) => call(client, args),
|
|
4460
|
-
createAccessList: (args) => createAccessList(client, args),
|
|
4461
|
-
createBlockFilter: () => createBlockFilter(client),
|
|
4462
|
-
createContractEventFilter: (args) => createContractEventFilter(client, args),
|
|
4463
|
-
createEventFilter: (args) => createEventFilter(client, args),
|
|
4464
|
-
createPendingTransactionFilter: () => createPendingTransactionFilter(client),
|
|
4465
|
-
estimateContractGas: (args) => estimateContractGas(client, args),
|
|
4466
|
-
estimateGas: (args) => estimateGas(client, args),
|
|
4467
|
-
getBalance: (args) => getBalance(client, args),
|
|
4468
|
-
getBlobBaseFee: () => getBlobBaseFee(client),
|
|
4469
|
-
getBlock: (args) => getBlock(client, args),
|
|
4470
|
-
getBlockNumber: (args) => getBlockNumber(client, args),
|
|
4471
|
-
getBlockTransactionCount: (args) => getBlockTransactionCount(client, args),
|
|
4472
|
-
getBytecode: (args) => getCode(client, args),
|
|
4473
|
-
getChainId: () => getChainId(client),
|
|
4474
|
-
getCode: (args) => getCode(client, args),
|
|
4475
|
-
getContractEvents: (args) => getContractEvents(client, args),
|
|
4476
|
-
getEip712Domain: (args) => getEip712Domain(client, args),
|
|
4477
|
-
getEnsAddress: (args) => getEnsAddress(client, args),
|
|
4478
|
-
getEnsAvatar: (args) => getEnsAvatar(client, args),
|
|
4479
|
-
getEnsName: (args) => getEnsName(client, args),
|
|
4480
|
-
getEnsResolver: (args) => getEnsResolver(client, args),
|
|
4481
|
-
getEnsText: (args) => getEnsText(client, args),
|
|
4482
|
-
getFeeHistory: (args) => getFeeHistory(client, args),
|
|
4483
|
-
estimateFeesPerGas: (args) => estimateFeesPerGas(client, args),
|
|
4484
|
-
getFilterChanges: (args) => getFilterChanges(client, args),
|
|
4485
|
-
getFilterLogs: (args) => getFilterLogs(client, args),
|
|
4486
|
-
getGasPrice: () => getGasPrice(client),
|
|
4487
|
-
getLogs: (args) => getLogs(client, args),
|
|
4488
|
-
getProof: (args) => getProof(client, args),
|
|
4489
|
-
estimateMaxPriorityFeePerGas: (args) => estimateMaxPriorityFeePerGas(client, args),
|
|
4490
|
-
getStorageAt: (args) => getStorageAt(client, args),
|
|
4491
|
-
getTransaction: (args) => getTransaction(client, args),
|
|
4492
|
-
getTransactionConfirmations: (args) => getTransactionConfirmations(client, args),
|
|
4493
|
-
getTransactionCount: (args) => getTransactionCount(client, args),
|
|
4494
|
-
getTransactionReceipt: (args) => getTransactionReceipt(client, args),
|
|
4495
|
-
multicall: (args) => multicall(client, args),
|
|
4496
|
-
prepareTransactionRequest: (args) => prepareTransactionRequest(client, args),
|
|
4497
|
-
readContract: (args) => readContract(client, args),
|
|
4498
|
-
sendRawTransaction: (args) => sendRawTransaction(client, args),
|
|
4499
|
-
simulate: (args) => simulateBlocks(client, args),
|
|
4500
|
-
simulateBlocks: (args) => simulateBlocks(client, args),
|
|
4501
|
-
simulateCalls: (args) => simulateCalls(client, args),
|
|
4502
|
-
simulateContract: (args) => simulateContract(client, args),
|
|
4503
|
-
verifyHash: (args) => verifyHash(client, args),
|
|
4504
|
-
verifyMessage: (args) => verifyMessage(client, args),
|
|
4505
|
-
verifySiweMessage: (args) => verifySiweMessage(client, args),
|
|
4506
|
-
verifyTypedData: (args) => verifyTypedData(client, args),
|
|
4507
|
-
uninstallFilter: (args) => uninstallFilter(client, args),
|
|
4508
|
-
waitForTransactionReceipt: (args) => waitForTransactionReceipt(client, args),
|
|
4509
|
-
watchBlocks: (args) => watchBlocks(client, args),
|
|
4510
|
-
watchBlockNumber: (args) => watchBlockNumber(client, args),
|
|
4511
|
-
watchContractEvent: (args) => watchContractEvent(client, args),
|
|
4512
|
-
watchEvent: (args) => watchEvent(client, args),
|
|
4513
|
-
watchPendingTransactions: (args) => watchPendingTransactions(client, args)
|
|
4514
|
-
};
|
|
4515
|
-
}
|
|
4516
|
-
function createPublicClient(parameters) {
|
|
4517
|
-
const { key = "public", name = "Public Client" } = parameters;
|
|
4518
|
-
const client = createClient({
|
|
4519
|
-
...parameters,
|
|
4520
|
-
key,
|
|
4521
|
-
name,
|
|
4522
|
-
type: "publicClient"
|
|
4523
|
-
});
|
|
4524
|
-
return client.extend(publicActions);
|
|
4525
|
-
}
|
|
4526
|
-
async function prepareAuthorization(client, parameters) {
|
|
4527
|
-
var _a;
|
|
4528
|
-
const { account: account_ = client.account, chainId, nonce } = parameters;
|
|
4529
|
-
if (!account_)
|
|
4530
|
-
throw new AccountNotFoundError({
|
|
4531
|
-
docsPath: "/docs/eip7702/prepareAuthorization"
|
|
4532
|
-
});
|
|
4533
|
-
const account = parseAccount(account_);
|
|
4534
|
-
const executor = (() => {
|
|
4535
|
-
if (!parameters.executor)
|
|
4536
|
-
return void 0;
|
|
4537
|
-
if (parameters.executor === "self")
|
|
4538
|
-
return parameters.executor;
|
|
4539
|
-
return parseAccount(parameters.executor);
|
|
4540
|
-
})();
|
|
4541
|
-
const authorization = {
|
|
4542
|
-
address: parameters.contractAddress ?? parameters.address,
|
|
4543
|
-
chainId,
|
|
4544
|
-
nonce
|
|
4545
|
-
};
|
|
4546
|
-
if (typeof authorization.chainId === "undefined")
|
|
4547
|
-
authorization.chainId = ((_a = client.chain) == null ? void 0 : _a.id) ?? await getAction(client, getChainId, "getChainId")({});
|
|
4548
|
-
if (typeof authorization.nonce === "undefined") {
|
|
4549
|
-
authorization.nonce = await getAction(client, getTransactionCount, "getTransactionCount")({
|
|
4550
|
-
address: account.address,
|
|
4551
|
-
blockTag: "pending"
|
|
4552
|
-
});
|
|
4553
|
-
if (executor === "self" || (executor == null ? void 0 : executor.address) && isAddressEqual(executor.address, account.address))
|
|
4554
|
-
authorization.nonce += 1;
|
|
4555
|
-
}
|
|
4556
|
-
return authorization;
|
|
4557
|
-
}
|
|
4558
|
-
class UrlRequiredError extends BaseError {
|
|
4559
|
-
constructor() {
|
|
4560
|
-
super("No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.", {
|
|
4561
|
-
docsPath: "/docs/clients/intro",
|
|
4562
|
-
name: "UrlRequiredError"
|
|
4563
|
-
});
|
|
4564
|
-
}
|
|
4565
|
-
}
|
|
4566
|
-
function http(url, config = {}) {
|
|
4567
|
-
const { batch, fetchFn, fetchOptions, key = "http", methods, name = "HTTP JSON-RPC", onFetchRequest, onFetchResponse, retryDelay, raw } = config;
|
|
4568
|
-
return ({ chain, retryCount: retryCount_, timeout: timeout_ }) => {
|
|
4569
|
-
const { batchSize = 1e3, wait = 0 } = typeof batch === "object" ? batch : {};
|
|
4570
|
-
const retryCount = config.retryCount ?? retryCount_;
|
|
4571
|
-
const timeout = timeout_ ?? config.timeout ?? 1e4;
|
|
4572
|
-
const url_ = url || (chain == null ? void 0 : chain.rpcUrls.default.http[0]);
|
|
4573
|
-
if (!url_)
|
|
4574
|
-
throw new UrlRequiredError();
|
|
4575
|
-
const rpcClient = getHttpRpcClient(url_, {
|
|
4576
|
-
fetchFn,
|
|
4577
|
-
fetchOptions,
|
|
4578
|
-
onRequest: onFetchRequest,
|
|
4579
|
-
onResponse: onFetchResponse,
|
|
4580
|
-
timeout
|
|
4581
|
-
});
|
|
4582
|
-
return createTransport({
|
|
4583
|
-
key,
|
|
4584
|
-
methods,
|
|
4585
|
-
name,
|
|
4586
|
-
async request({ method, params }) {
|
|
4587
|
-
const body = { method, params };
|
|
4588
|
-
const { schedule } = createBatchScheduler({
|
|
4589
|
-
id: url_,
|
|
4590
|
-
wait,
|
|
4591
|
-
shouldSplitBatch(requests) {
|
|
4592
|
-
return requests.length > batchSize;
|
|
4593
|
-
},
|
|
4594
|
-
fn: (body2) => rpcClient.request({
|
|
4595
|
-
body: body2
|
|
4596
|
-
}),
|
|
4597
|
-
sort: (a, b) => a.id - b.id
|
|
4598
|
-
});
|
|
4599
|
-
const fn = async (body2) => batch ? schedule(body2) : [
|
|
4600
|
-
await rpcClient.request({
|
|
4601
|
-
body: body2
|
|
4602
|
-
})
|
|
4603
|
-
];
|
|
4604
|
-
const [{ error, result }] = await fn(body);
|
|
4605
|
-
if (raw)
|
|
4606
|
-
return { error, result };
|
|
4607
|
-
if (error)
|
|
4608
|
-
throw new RpcRequestError({
|
|
4609
|
-
body,
|
|
4610
|
-
error,
|
|
4611
|
-
url: url_
|
|
4612
|
-
});
|
|
4613
|
-
return result;
|
|
4614
|
-
},
|
|
4615
|
-
retryCount,
|
|
4616
|
-
retryDelay,
|
|
4617
|
-
timeout,
|
|
4618
|
-
type: "http"
|
|
4619
|
-
}, {
|
|
4620
|
-
fetchOptions,
|
|
4621
|
-
url: url_
|
|
4622
|
-
});
|
|
4623
|
-
};
|
|
4624
|
-
}
|
|
4625
|
-
function parseSignature(signatureHex) {
|
|
4626
|
-
const { r, s } = secp256k1.Signature.fromCompact(signatureHex.slice(2, 130));
|
|
4627
|
-
const yParityOrV = Number(`0x${signatureHex.slice(130)}`);
|
|
4628
|
-
const [v, yParity] = (() => {
|
|
4629
|
-
if (yParityOrV === 0 || yParityOrV === 1)
|
|
4630
|
-
return [void 0, yParityOrV];
|
|
4631
|
-
if (yParityOrV === 27)
|
|
4632
|
-
return [BigInt(yParityOrV), 0];
|
|
4633
|
-
if (yParityOrV === 28)
|
|
4634
|
-
return [BigInt(yParityOrV), 1];
|
|
4635
|
-
throw new Error("Invalid yParityOrV value");
|
|
4636
|
-
})();
|
|
4637
|
-
if (typeof v !== "undefined")
|
|
4638
|
-
return {
|
|
4639
|
-
r: numberToHex(r, { size: 32 }),
|
|
4640
|
-
s: numberToHex(s, { size: 32 }),
|
|
4641
|
-
v,
|
|
4642
|
-
yParity
|
|
4643
|
-
};
|
|
4644
|
-
return {
|
|
4645
|
-
r: numberToHex(r, { size: 32 }),
|
|
4646
|
-
s: numberToHex(s, { size: 32 }),
|
|
4647
|
-
yParity
|
|
4648
|
-
};
|
|
4649
|
-
}
|
|
4650
|
-
export {
|
|
4651
|
-
nonceManager as A,
|
|
4652
|
-
BundleFailedError as B,
|
|
4653
|
-
publicActions as C,
|
|
4654
|
-
serializeErc6492Signature as D,
|
|
4655
|
-
EnsInvalidChainIdError as E,
|
|
4656
|
-
FilterTypeNotSupportedError as F,
|
|
4657
|
-
serializeSignature as G,
|
|
4658
|
-
zeroAddress as H,
|
|
4659
|
-
zeroHash as I,
|
|
4660
|
-
getCode as J,
|
|
4661
|
-
UrlRequiredError as U,
|
|
4662
|
-
WaitForCallsStatusTimeoutError as W,
|
|
4663
|
-
erc6492MagicBytes as a,
|
|
4664
|
-
wrap$1 as b,
|
|
4665
|
-
createContractEventFilter as c,
|
|
4666
|
-
waitForCallsStatus as d,
|
|
4667
|
-
estimateContractGas as e,
|
|
4668
|
-
sendCalls as f,
|
|
4669
|
-
getContractEvents as g,
|
|
4670
|
-
getCallsStatus as h,
|
|
4671
|
-
idCache as i,
|
|
4672
|
-
EnsAvatarInvalidNftUriError as j,
|
|
4673
|
-
EnsAvatarUnsupportedNamespaceError as k,
|
|
4674
|
-
EnsAvatarUriResolutionError as l,
|
|
4675
|
-
createNonceManager as m,
|
|
4676
|
-
createPublicClient as n,
|
|
4677
|
-
encodeEventTopics as o,
|
|
4678
|
-
prepareAuthorization as p,
|
|
4679
|
-
encodePacked$1 as q,
|
|
4680
|
-
ethAddress as r,
|
|
4681
|
-
simulateContract as s,
|
|
4682
|
-
parseSignature as t,
|
|
4683
|
-
unwrap as u,
|
|
4684
|
-
validate$1 as v,
|
|
4685
|
-
watchContractEvent as w,
|
|
4686
|
-
http as x,
|
|
4687
|
-
labelhash as y,
|
|
4688
|
-
namehash as z
|
|
4689
|
-
};
|
|
4690
|
-
//# sourceMappingURL=parseSignature-CxTkG24t.js.map
|