From ba6ce857e87375d30f67741ba976a1a31e2c3774 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CF=87=C2=B2?= <88190723+ChiTimesChi@users.noreply.github.com> Date: Thu, 14 Dec 2023 16:43:46 +0000 Subject: [PATCH 01/29] Fix/update wagmi main (#1665) * Update wagmi to 1.4.12 * yarn install --- packages/synapse-interface/package.json | 2 +- yarn.lock | 554 +++++++++++++++++++++--- 2 files changed, 484 insertions(+), 72 deletions(-) diff --git a/packages/synapse-interface/package.json b/packages/synapse-interface/package.json index 782a78bcce..bcc5149fa8 100644 --- a/packages/synapse-interface/package.json +++ b/packages/synapse-interface/package.json @@ -93,7 +93,7 @@ "use-persisted-state": "^0.3.3", "use-window-focus": "^1.4.2", "viem": "^1.18.1", - "wagmi": "^1.4.5", + "wagmi": "^1.4.12", "yarn": "^1.22.19" }, "browserslist": { diff --git a/yarn.lock b/yarn.lock index 822c343a3b..d09cff403d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3708,6 +3708,11 @@ resolved "https://registry.yarnpkg.com/@hutson/parse-repository-url/-/parse-repository-url-3.0.2.tgz#98c23c950a3d9b6c8f0daed06da6c3af06981340" integrity sha512-H9XAx3hc0BQHY6l+IFSWHDySypcXsvsuLhgYLUGywmJ5pswRVQJUHpOsobnLYp2ZUaUlKiKDrgWWhosOwAEM8Q== +"@ioredis/commands@^1.1.1": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@ioredis/commands/-/commands-1.2.0.tgz#6d61b3097470af1fdbbe622795b8921d42018e11" + integrity sha512-Sx1pU8EM64o2BrqNpEO1CNLtKQwyhuXuqyfH7oGKCk+1a33d2r5saW8zNwm3j6BTExtjrv2BxTgzzkMwts6vGg== + "@istanbuljs/load-nyc-config@^1.0.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz#fd3db1d59ecf7cf121e80650bb86712f9b55eced" @@ -4194,11 +4199,6 @@ "@jridgewell/resolve-uri" "3.1.0" "@jridgewell/sourcemap-codec" "1.4.14" -"@ledgerhq/connect-kit-loader@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@ledgerhq/connect-kit-loader/-/connect-kit-loader-1.1.0.tgz#10343b78ef13436818bf3453568a559c0eeb9d48" - integrity sha512-HUy12FEczoWY2FPubnsm1uOA8tkVWc0j90i47suThV3C9NL2xx69ZAIEU3Ytzs2bwLek9S1Q2S1VQJvA+3Ygkg== - "@leichtgewicht/ip-codec@^2.0.1": version "2.0.4" resolved "https://registry.yarnpkg.com/@leichtgewicht/ip-codec/-/ip-codec-2.0.4.tgz#b2ac626d6cb9c8718ab459166d4bb405b8ffa78b" @@ -5520,6 +5520,98 @@ resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.9.3.tgz#00d7a8cf35a475b160b3f0293a6403c511099364" integrity sha512-He3LieZ1pP2TNt5JbkPA4PNT9WC3gOTOlDcFGJW4Le4QKqwmiNJCRt44APfxMxvq7OugU/cqYuPcSBzOw38DAg== +"@parcel/watcher-android-arm64@2.3.0": + version "2.3.0" + resolved "https://registry.yarnpkg.com/@parcel/watcher-android-arm64/-/watcher-android-arm64-2.3.0.tgz#d82e74bb564ebd4d8a88791d273a3d2bd61e27ab" + integrity sha512-f4o9eA3dgk0XRT3XhB0UWpWpLnKgrh1IwNJKJ7UJek7eTYccQ8LR7XUWFKqw6aEq5KUNlCcGvSzKqSX/vtWVVA== + +"@parcel/watcher-darwin-arm64@2.3.0": + version "2.3.0" + resolved "https://registry.yarnpkg.com/@parcel/watcher-darwin-arm64/-/watcher-darwin-arm64-2.3.0.tgz#c9cd03f8f233d512fcfc873d5b4e23f1569a82ad" + integrity sha512-mKY+oijI4ahBMc/GygVGvEdOq0L4DxhYgwQqYAz/7yPzuGi79oXrZG52WdpGA1wLBPrYb0T8uBaGFo7I6rvSKw== + +"@parcel/watcher-darwin-x64@2.3.0": + version "2.3.0" + resolved "https://registry.yarnpkg.com/@parcel/watcher-darwin-x64/-/watcher-darwin-x64-2.3.0.tgz#83c902994a2a49b9e1ab5050dba24876fdc2c219" + integrity sha512-20oBj8LcEOnLE3mgpy6zuOq8AplPu9NcSSSfyVKgfOhNAc4eF4ob3ldj0xWjGGbOF7Dcy1Tvm6ytvgdjlfUeow== + +"@parcel/watcher-freebsd-x64@2.3.0": + version "2.3.0" + resolved "https://registry.yarnpkg.com/@parcel/watcher-freebsd-x64/-/watcher-freebsd-x64-2.3.0.tgz#7a0f4593a887e2752b706aff2dae509aef430cf6" + integrity sha512-7LftKlaHunueAEiojhCn+Ef2CTXWsLgTl4hq0pkhkTBFI3ssj2bJXmH2L67mKpiAD5dz66JYk4zS66qzdnIOgw== + +"@parcel/watcher-linux-arm-glibc@2.3.0": + version "2.3.0" + resolved "https://registry.yarnpkg.com/@parcel/watcher-linux-arm-glibc/-/watcher-linux-arm-glibc-2.3.0.tgz#3fc90c3ebe67de3648ed2f138068722f9b1d47da" + integrity sha512-1apPw5cD2xBv1XIHPUlq0cO6iAaEUQ3BcY0ysSyD9Kuyw4MoWm1DV+W9mneWI+1g6OeP6dhikiFE6BlU+AToTQ== + +"@parcel/watcher-linux-arm64-glibc@2.3.0": + version "2.3.0" + resolved "https://registry.yarnpkg.com/@parcel/watcher-linux-arm64-glibc/-/watcher-linux-arm64-glibc-2.3.0.tgz#f7bbbf2497d85fd11e4c9e9c26ace8f10ea9bcbc" + integrity sha512-mQ0gBSQEiq1k/MMkgcSB0Ic47UORZBmWoAWlMrTW6nbAGoLZP+h7AtUM7H3oDu34TBFFvjy4JCGP43JlylkTQA== + +"@parcel/watcher-linux-arm64-musl@2.3.0": + version "2.3.0" + resolved "https://registry.yarnpkg.com/@parcel/watcher-linux-arm64-musl/-/watcher-linux-arm64-musl-2.3.0.tgz#de131a9fcbe1fa0854e9cbf4c55bed3b35bcff43" + integrity sha512-LXZAExpepJew0Gp8ZkJ+xDZaTQjLHv48h0p0Vw2VMFQ8A+RKrAvpFuPVCVwKJCr5SE+zvaG+Etg56qXvTDIedw== + +"@parcel/watcher-linux-x64-glibc@2.3.0": + version "2.3.0" + resolved "https://registry.yarnpkg.com/@parcel/watcher-linux-x64-glibc/-/watcher-linux-x64-glibc-2.3.0.tgz#193dd1c798003cdb5a1e59470ff26300f418a943" + integrity sha512-P7Wo91lKSeSgMTtG7CnBS6WrA5otr1K7shhSjKHNePVmfBHDoAOHYRXgUmhiNfbcGk0uMCHVcdbfxtuiZCHVow== + +"@parcel/watcher-linux-x64-musl@2.3.0": + version "2.3.0" + resolved "https://registry.yarnpkg.com/@parcel/watcher-linux-x64-musl/-/watcher-linux-x64-musl-2.3.0.tgz#6dbdb86d96e955ab0fe4a4b60734ec0025a689dd" + integrity sha512-+kiRE1JIq8QdxzwoYY+wzBs9YbJ34guBweTK8nlzLKimn5EQ2b2FSC+tAOpq302BuIMjyuUGvBiUhEcLIGMQ5g== + +"@parcel/watcher-wasm@2.3.0": + version "2.3.0" + resolved "https://registry.yarnpkg.com/@parcel/watcher-wasm/-/watcher-wasm-2.3.0.tgz#73b66c6fbd2a3326ae86a1ec77eab7139d0dd725" + integrity sha512-ejBAX8H0ZGsD8lSICDNyMbSEtPMWgDL0WFCt/0z7hyf5v8Imz4rAM8xY379mBsECkq/Wdqa5WEDLqtjZ+6NxfA== + dependencies: + is-glob "^4.0.3" + micromatch "^4.0.5" + napi-wasm "^1.1.0" + +"@parcel/watcher-win32-arm64@2.3.0": + version "2.3.0" + resolved "https://registry.yarnpkg.com/@parcel/watcher-win32-arm64/-/watcher-win32-arm64-2.3.0.tgz#59da26a431da946e6c74fa6b0f30b120ea6650b6" + integrity sha512-35gXCnaz1AqIXpG42evcoP2+sNL62gZTMZne3IackM+6QlfMcJLy3DrjuL6Iks7Czpd3j4xRBzez3ADCj1l7Aw== + +"@parcel/watcher-win32-ia32@2.3.0": + version "2.3.0" + resolved "https://registry.yarnpkg.com/@parcel/watcher-win32-ia32/-/watcher-win32-ia32-2.3.0.tgz#3ee6a18b08929cd3b788e8cc9547fd9a540c013a" + integrity sha512-FJS/IBQHhRpZ6PiCjFt1UAcPr0YmCLHRbTc00IBTrelEjlmmgIVLeOx4MSXzx2HFEy5Jo5YdhGpxCuqCyDJ5ow== + +"@parcel/watcher-win32-x64@2.3.0": + version "2.3.0" + resolved "https://registry.yarnpkg.com/@parcel/watcher-win32-x64/-/watcher-win32-x64-2.3.0.tgz#14e7246289861acc589fd608de39fe5d8b4bb0a7" + integrity sha512-dLx+0XRdMnVI62kU3wbXvbIRhLck4aE28bIGKbRGS7BJNt54IIj9+c/Dkqb+7DJEbHUZAX1bwaoM8PqVlHJmCA== + +"@parcel/watcher@^2.3.0": + version "2.3.0" + resolved "https://registry.yarnpkg.com/@parcel/watcher/-/watcher-2.3.0.tgz#803517abbc3981a1a1221791d9f59dc0590d50f9" + integrity sha512-pW7QaFiL11O0BphO+bq3MgqeX/INAk9jgBldVDYjlQPO4VddoZnF22TcF9onMhnLVHuNqBJeRf+Fj7eezi/+rQ== + dependencies: + detect-libc "^1.0.3" + is-glob "^4.0.3" + micromatch "^4.0.5" + node-addon-api "^7.0.0" + optionalDependencies: + "@parcel/watcher-android-arm64" "2.3.0" + "@parcel/watcher-darwin-arm64" "2.3.0" + "@parcel/watcher-darwin-x64" "2.3.0" + "@parcel/watcher-freebsd-x64" "2.3.0" + "@parcel/watcher-linux-arm-glibc" "2.3.0" + "@parcel/watcher-linux-arm64-glibc" "2.3.0" + "@parcel/watcher-linux-arm64-musl" "2.3.0" + "@parcel/watcher-linux-x64-glibc" "2.3.0" + "@parcel/watcher-linux-x64-musl" "2.3.0" + "@parcel/watcher-win32-arm64" "2.3.0" + "@parcel/watcher-win32-ia32" "2.3.0" + "@parcel/watcher-win32-x64" "2.3.0" + "@peculiar/asn1-schema@^2.3.6": version "2.3.6" resolved "https://registry.yarnpkg.com/@peculiar/asn1-schema/-/asn1-schema-2.3.6.tgz#3dd3c2ade7f702a9a94dfb395c192f5fa5d6b922" @@ -5762,18 +5854,18 @@ resolved "https://registry.yarnpkg.com/@rushstack/eslint-patch/-/eslint-patch-1.5.1.tgz#5f1b518ec5fa54437c0b7c4a821546c64fed6922" integrity sha512-6i/8UoL0P5y4leBIGzvkZdS85RDMG9y1ihZzmTZQ5LdHUYmZ7pKFoj8X0236s3lusPs1Fa5HTQUpwI+UfTcmeA== -"@safe-global/safe-apps-provider@^0.17.1": - version "0.17.1" - resolved "https://registry.yarnpkg.com/@safe-global/safe-apps-provider/-/safe-apps-provider-0.17.1.tgz#72df2a66be5343940ed505efe594ed3b0f2f7015" - integrity sha512-lYfRqrbbK1aKU1/UGkYWc/X7PgySYcumXKc5FB2uuwAs2Ghj8uETuW5BrwPqyjBknRxutFbTv+gth/JzjxAhdQ== +"@safe-global/safe-apps-provider@^0.18.1": + version "0.18.1" + resolved "https://registry.yarnpkg.com/@safe-global/safe-apps-provider/-/safe-apps-provider-0.18.1.tgz#287b5a1e2ef3be630dacde54279409df3ced8202" + integrity sha512-V4a05A3EgJcriqtDoJklDz1BOinWhC6P0hjUSxshA4KOZM7rGPCTto/usXs09zr1vvL28evl/NldSTv97j2bmg== dependencies: - "@safe-global/safe-apps-sdk" "8.0.0" + "@safe-global/safe-apps-sdk" "^8.1.0" events "^3.3.0" -"@safe-global/safe-apps-sdk@8.0.0", "@safe-global/safe-apps-sdk@^8.0.0": - version "8.0.0" - resolved "https://registry.yarnpkg.com/@safe-global/safe-apps-sdk/-/safe-apps-sdk-8.0.0.tgz#9bdfe0e0d85e1b2d279bb840f40c4b930aaf8bc1" - integrity sha512-gYw0ki/EAuV1oSyMxpqandHjnthZjYYy+YWpTAzf8BqfXM3ItcZLpjxfg+3+mXW8HIO+3jw6T9iiqEXsqHaMMw== +"@safe-global/safe-apps-sdk@^8.1.0": + version "8.1.0" + resolved "https://registry.yarnpkg.com/@safe-global/safe-apps-sdk/-/safe-apps-sdk-8.1.0.tgz#d1d0c69cd2bf4eef8a79c5d677d16971926aa64a" + integrity sha512-XJbEPuaVc7b9n23MqlF6c+ToYIS3f7P2Sel8f3cSBQ9WORE4xrSuvhMpK9fDSFqJ7by/brc+rmJR/5HViRr0/w== dependencies: "@safe-global/safe-gateway-typescript-sdk" "^3.5.3" viem "^1.0.0" @@ -9636,50 +9728,49 @@ resolved "https://registry.yarnpkg.com/@wagmi/chains/-/chains-1.6.0.tgz#eb992ad28dbaaab729b5bcab3e5b461e8a035656" integrity sha512-5FRlVxse5P4ZaHG3GTvxwVANSmYJas1eQrTBHhjxVtqXoorm0aLmCHbhmN8Xo1yu09PaWKlleEvfE98yH4AgIw== -"@wagmi/connectors@3.1.3": - version "3.1.3" - resolved "https://registry.yarnpkg.com/@wagmi/connectors/-/connectors-3.1.3.tgz#112aad63a8042ce4a5a3dc4db9eaa4da0fbcf0fc" - integrity sha512-UgwsQKQDFObJVJMf9pDfFoXTv710o4zrTHyhIWKBTMMkLpCMsMxN5+ZaDhBYt/BgoRinfRYQo8uwuwLhxE6Log== +"@wagmi/connectors@3.1.10": + version "3.1.10" + resolved "https://registry.yarnpkg.com/@wagmi/connectors/-/connectors-3.1.10.tgz#830cd788579ef56a2526574914481f2d3aabc9f7" + integrity sha512-ZLJC1QaeiZarkF07Cr9mOlVjPO1Lf5TBx+JKBms2y5fUIXlKrxCfQgO/gDCureboI+Us2X3IRI659+XacSGpbA== dependencies: "@coinbase/wallet-sdk" "^3.6.6" - "@ledgerhq/connect-kit-loader" "^1.1.0" - "@safe-global/safe-apps-provider" "^0.17.1" - "@safe-global/safe-apps-sdk" "^8.0.0" - "@walletconnect/ethereum-provider" "2.10.2" + "@safe-global/safe-apps-provider" "^0.18.1" + "@safe-global/safe-apps-sdk" "^8.1.0" + "@walletconnect/ethereum-provider" "2.10.6" "@walletconnect/legacy-provider" "^2.0.0" "@walletconnect/modal" "2.6.2" "@walletconnect/utils" "2.10.2" abitype "0.8.7" eventemitter3 "^4.0.7" -"@wagmi/core@1.4.5", "@wagmi/core@^1.4.5": - version "1.4.5" - resolved "https://registry.yarnpkg.com/@wagmi/core/-/core-1.4.5.tgz#bab215bfc1e028bc720b772d8d69dd12ae0c0ebf" - integrity sha512-N9luRb1Uk4tBN9kaYcQSWKE9AsRt/rvZaFt5IZech4JPzNN2sQlfhKd9GEjOXYRDqEPHdDvos7qyBKiDNTz4GA== +"@wagmi/core@1.4.12", "@wagmi/core@^1.4.12": + version "1.4.12" + resolved "https://registry.yarnpkg.com/@wagmi/core/-/core-1.4.12.tgz#84558d1af746b2bcef02337dc3c46108242b1dd7" + integrity sha512-bLcYmmGgjtl3jAGo8X3Sm6oUwsdjbVxFMu9SWnwHdE4S9JdYeWM57dEhQgq8SYul2yQ7yY2/gimBf1Or0Ky3dQ== dependencies: - "@wagmi/connectors" "3.1.3" + "@wagmi/connectors" "3.1.10" abitype "0.8.7" eventemitter3 "^4.0.7" zustand "^4.3.1" -"@walletconnect/core@2.10.2": - version "2.10.2" - resolved "https://registry.yarnpkg.com/@walletconnect/core/-/core-2.10.2.tgz#a1bf6e3e87b33f9df795ce0970d8ddd400fdc8a3" - integrity sha512-JQz/xp3SLEpTeRQctdck2ugSBVEpMxoSE+lFi2voJkZop1hv6P+uqr6E4PzjFluAjeAnKlT1xvra0aFWjPWVcw== +"@walletconnect/core@2.10.6": + version "2.10.6" + resolved "https://registry.yarnpkg.com/@walletconnect/core/-/core-2.10.6.tgz#786b0d2e2045c210c917e29bfa0498bbc210be20" + integrity sha512-Z4vh4ZdfcoQjgPEOxeuF9HUZCVLtV3MgRbS/awLIj/omDrFnOwlBhxi5Syr4Y8muVGC0ocRetQYHae0/gX5crQ== dependencies: "@walletconnect/heartbeat" "1.2.1" "@walletconnect/jsonrpc-provider" "1.0.13" "@walletconnect/jsonrpc-types" "1.0.3" "@walletconnect/jsonrpc-utils" "1.0.8" - "@walletconnect/jsonrpc-ws-connection" "1.0.13" - "@walletconnect/keyvaluestorage" "^1.0.2" + "@walletconnect/jsonrpc-ws-connection" "1.0.14" + "@walletconnect/keyvaluestorage" "^1.1.1" "@walletconnect/logger" "^2.0.1" "@walletconnect/relay-api" "^1.0.9" "@walletconnect/relay-auth" "^1.0.4" "@walletconnect/safe-json" "^1.0.2" "@walletconnect/time" "^1.0.2" - "@walletconnect/types" "2.10.2" - "@walletconnect/utils" "2.10.2" + "@walletconnect/types" "2.10.6" + "@walletconnect/utils" "2.10.6" events "^3.3.0" lodash.isequal "4.5.0" uint8arrays "^3.1.0" @@ -9712,19 +9803,20 @@ dependencies: tslib "1.14.1" -"@walletconnect/ethereum-provider@2.10.2": - version "2.10.2" - resolved "https://registry.yarnpkg.com/@walletconnect/ethereum-provider/-/ethereum-provider-2.10.2.tgz#d5aca538fbcbbf7dd771bceb2430de30f06411de" - integrity sha512-QMYFZ6+rVq2CJLdIPdKK0j1Qm66UA27oQU5V2SrL8EVwl7wFfm0Bq7fnL+qAWeDpn612dNeNErpk/ROa1zWlWg== +"@walletconnect/ethereum-provider@2.10.6": + version "2.10.6" + resolved "https://registry.yarnpkg.com/@walletconnect/ethereum-provider/-/ethereum-provider-2.10.6.tgz#53720771cc2d6accd452916a853ac927f26acbaa" + integrity sha512-bBQ+yUfxLv8VxNttgNKY7nED35gSVayO/BnLHbNKvyV1gpvSCla5mWB9MsXuQs70MK0g+/qtgRVSrOtdSubaNQ== dependencies: "@walletconnect/jsonrpc-http-connection" "^1.0.7" "@walletconnect/jsonrpc-provider" "^1.0.13" "@walletconnect/jsonrpc-types" "^1.0.3" "@walletconnect/jsonrpc-utils" "^1.0.8" - "@walletconnect/sign-client" "2.10.2" - "@walletconnect/types" "2.10.2" - "@walletconnect/universal-provider" "2.10.2" - "@walletconnect/utils" "2.10.2" + "@walletconnect/modal" "^2.4.3" + "@walletconnect/sign-client" "2.10.6" + "@walletconnect/types" "2.10.6" + "@walletconnect/universal-provider" "2.10.6" + "@walletconnect/utils" "2.10.6" events "^3.3.0" "@walletconnect/events@^1.0.1": @@ -9780,15 +9872,14 @@ "@walletconnect/jsonrpc-types" "^1.0.3" tslib "1.14.1" -"@walletconnect/jsonrpc-ws-connection@1.0.13": - version "1.0.13" - resolved "https://registry.yarnpkg.com/@walletconnect/jsonrpc-ws-connection/-/jsonrpc-ws-connection-1.0.13.tgz#23b0cdd899801bfbb44a6556936ec2b93ef2adf4" - integrity sha512-mfOM7uFH4lGtQxG+XklYuFBj6dwVvseTt5/ahOkkmpcAEgz2umuzu7fTR+h5EmjQBdrmYyEBOWADbeaFNxdySg== +"@walletconnect/jsonrpc-ws-connection@1.0.14": + version "1.0.14" + resolved "https://registry.yarnpkg.com/@walletconnect/jsonrpc-ws-connection/-/jsonrpc-ws-connection-1.0.14.tgz#eec700e74766c7887de2bd76c91a0206628732aa" + integrity sha512-Jsl6fC55AYcbkNVkwNM6Jo+ufsuCQRqViOQ8ZBPH9pRREHH9welbBiszuTLqEJiQcO/6XfFDl6bzCJIkrEi8XA== dependencies: "@walletconnect/jsonrpc-utils" "^1.0.6" "@walletconnect/safe-json" "^1.0.2" events "^3.3.0" - tslib "1.14.1" ws "^7.5.1" "@walletconnect/keyvaluestorage@^1.0.2": @@ -9799,6 +9890,15 @@ safe-json-utils "^1.1.1" tslib "1.14.1" +"@walletconnect/keyvaluestorage@^1.1.1": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@walletconnect/keyvaluestorage/-/keyvaluestorage-1.1.1.tgz#dd2caddabfbaf80f6b8993a0704d8b83115a1842" + integrity sha512-V7ZQq2+mSxAq7MrRqDxanTzu2RcElfK1PfNYiaVnJgJ7Q7G7hTVwF8voIBx92qsRyGHZihrwNPHuZd1aKkd0rA== + dependencies: + "@walletconnect/safe-json" "^1.0.1" + idb-keyval "^6.2.1" + unstorage "^1.9.0" + "@walletconnect/legacy-client@^2.0.0": version "2.0.0" resolved "https://registry.yarnpkg.com/@walletconnect/legacy-client/-/legacy-client-2.0.0.tgz#9f2c09694789fd4b6c5d68d6423b44bac55aed30" @@ -9884,7 +9984,7 @@ motion "10.16.2" qrcode "1.5.3" -"@walletconnect/modal@2.6.2": +"@walletconnect/modal@2.6.2", "@walletconnect/modal@^2.4.3": version "2.6.2" resolved "https://registry.yarnpkg.com/@walletconnect/modal/-/modal-2.6.2.tgz#4b534a836f5039eeb3268b80be7217a94dd12651" integrity sha512-eFopgKi8AjKf/0U4SemvcYw9zlLpx9njVN8sf6DAkowC2Md0gPU/UNEbH1Wwj407pEKnEds98pKWib1NN1ACoA== @@ -9929,19 +10029,19 @@ dependencies: tslib "1.14.1" -"@walletconnect/sign-client@2.10.2": - version "2.10.2" - resolved "https://registry.yarnpkg.com/@walletconnect/sign-client/-/sign-client-2.10.2.tgz#33300a9cfe42487473f66b73c99535f6b26f8c54" - integrity sha512-vviSLV3f92I0bReX+OLr1HmbH0uIzYEQQFd1MzIfDk9PkfFT/LLAHhUnDaIAMkIdippqDcJia+5QEtT4JihL3Q== +"@walletconnect/sign-client@2.10.6": + version "2.10.6" + resolved "https://registry.yarnpkg.com/@walletconnect/sign-client/-/sign-client-2.10.6.tgz#722d2c2844565e2826dce6a6d3a36c9b3ca1ea91" + integrity sha512-EvUWjaZBQu2yKnH5/5F2qzbuiIuUN9ZgrNKgvXkw5z1Dq5RJCks0S9/MFlKH/ZSGqXnLl7uAzBXtoX4sMgbCMA== dependencies: - "@walletconnect/core" "2.10.2" + "@walletconnect/core" "2.10.6" "@walletconnect/events" "^1.0.1" "@walletconnect/heartbeat" "1.2.1" "@walletconnect/jsonrpc-utils" "1.0.8" "@walletconnect/logger" "^2.0.1" "@walletconnect/time" "^1.0.2" - "@walletconnect/types" "2.10.2" - "@walletconnect/utils" "2.10.2" + "@walletconnect/types" "2.10.6" + "@walletconnect/utils" "2.10.6" events "^3.3.0" "@walletconnect/time@^1.0.2": @@ -9963,19 +10063,31 @@ "@walletconnect/logger" "^2.0.1" events "^3.3.0" -"@walletconnect/universal-provider@2.10.2": - version "2.10.2" - resolved "https://registry.yarnpkg.com/@walletconnect/universal-provider/-/universal-provider-2.10.2.tgz#85c8da39f65da8fe33f65f62689e703607b5ddc5" - integrity sha512-wFgI0LbQ3D56sgaUMsgOHCM5m8WLxiC71BGuCKQfApgsbNMVKugYVy2zWHyUyi8sqTQHI+uSaVpDev4UHq9LEw== +"@walletconnect/types@2.10.6": + version "2.10.6" + resolved "https://registry.yarnpkg.com/@walletconnect/types/-/types-2.10.6.tgz#d9920ed4fd0113e0addbda8e7e73a5176a3163fd" + integrity sha512-WgHfiTG1yakmxheaBRiXhUdEmgxwrvsAdOIWaMf/spvrzVKYh6sHI3oyEEky5qj5jjiMiyQBeB57QamzCotbcQ== + dependencies: + "@walletconnect/events" "^1.0.1" + "@walletconnect/heartbeat" "1.2.1" + "@walletconnect/jsonrpc-types" "1.0.3" + "@walletconnect/keyvaluestorage" "^1.1.1" + "@walletconnect/logger" "^2.0.1" + events "^3.3.0" + +"@walletconnect/universal-provider@2.10.6": + version "2.10.6" + resolved "https://registry.yarnpkg.com/@walletconnect/universal-provider/-/universal-provider-2.10.6.tgz#1a6c42517581f11ce275474bc70d0eb4f1044525" + integrity sha512-CEivusqqoD31BhCTKp08DnrccfGjwD9MFjZs5BNRorDteRFE8zVm9LmP6DSiNJCw82ZajGlZThggLQ/BAATfwA== dependencies: "@walletconnect/jsonrpc-http-connection" "^1.0.7" "@walletconnect/jsonrpc-provider" "1.0.13" "@walletconnect/jsonrpc-types" "^1.0.2" "@walletconnect/jsonrpc-utils" "^1.0.7" "@walletconnect/logger" "^2.0.1" - "@walletconnect/sign-client" "2.10.2" - "@walletconnect/types" "2.10.2" - "@walletconnect/utils" "2.10.2" + "@walletconnect/sign-client" "2.10.6" + "@walletconnect/types" "2.10.6" + "@walletconnect/utils" "2.10.6" events "^3.3.0" "@walletconnect/utils@2.10.2": @@ -9998,6 +10110,26 @@ query-string "7.1.3" uint8arrays "^3.1.0" +"@walletconnect/utils@2.10.6": + version "2.10.6" + resolved "https://registry.yarnpkg.com/@walletconnect/utils/-/utils-2.10.6.tgz#749b37d14e291e346862e7027ec7548463350226" + integrity sha512-oRsWWhN2+hi3aiDXrQEOfysz6FHQJGXLsNQPVt+WIBJplO6Szmdau9dbleD88u1iiT4GKPqE0R9FOYvvPm1H/w== + dependencies: + "@stablelib/chacha20poly1305" "1.0.1" + "@stablelib/hkdf" "1.0.1" + "@stablelib/random" "^1.0.2" + "@stablelib/sha256" "1.0.1" + "@stablelib/x25519" "^1.0.3" + "@walletconnect/relay-api" "^1.0.9" + "@walletconnect/safe-json" "^1.0.2" + "@walletconnect/time" "^1.0.2" + "@walletconnect/types" "2.10.6" + "@walletconnect/window-getters" "^1.0.1" + "@walletconnect/window-metadata" "^1.0.1" + detect-browser "5.3.0" + query-string "7.1.3" + uint8arrays "^3.1.0" + "@walletconnect/window-getters@^1.0.1": version "1.0.1" resolved "https://registry.yarnpkg.com/@walletconnect/window-getters/-/window-getters-1.0.1.tgz#f36d1c72558a7f6b87ecc4451fc8bd44f63cbbdc" @@ -10514,6 +10646,11 @@ acorn@^8.0.4, acorn@^8.1.0, acorn@^8.4.1, acorn@^8.7.1, acorn@^8.8.0, acorn@^8.8 resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.10.0.tgz#8be5b3907a67221a81ab23c7889c4c5526b62ec5" integrity sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw== +acorn@^8.10.0: + version "8.11.2" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.11.2.tgz#ca0d78b51895be5390a5903c5b3bdcdaf78ae40b" + integrity sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w== + add-stream@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/add-stream/-/add-stream-1.0.0.tgz#6a7990437ca736d5e1288db92bd3266d5f5cb2aa" @@ -10809,7 +10946,7 @@ anymatch@^2.0.0: micromatch "^3.1.4" normalize-path "^2.1.1" -anymatch@^3.0.0, anymatch@^3.0.3, anymatch@~3.1.1, anymatch@~3.1.2: +anymatch@^3.0.0, anymatch@^3.0.3, anymatch@^3.1.3, anymatch@~3.1.1, anymatch@~3.1.2: version "3.1.3" resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.3.tgz#790c58b19ba1720a84205b57c618d5ad8524973e" integrity sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw== @@ -12762,6 +12899,13 @@ cipher-base@^1.0.0, cipher-base@^1.0.1, cipher-base@^1.0.3: inherits "^2.0.1" safe-buffer "^5.0.1" +citty@^0.1.3, citty@^0.1.4: + version "0.1.5" + resolved "https://registry.yarnpkg.com/citty/-/citty-0.1.5.tgz#fe37ceae5dc764af75eb2fece99d2bf527ea4e50" + integrity sha512-AS7n5NSc0OQVMV9v6wt3ByujNIrne0/cTjiC2MYqhvao57VNfiuVksTSr2p17nVOhEr2KtqiAkGwHcgMC/qUuQ== + dependencies: + consola "^3.2.3" + cjs-module-lexer@^1.0.0: version "1.2.3" resolved "https://registry.yarnpkg.com/cjs-module-lexer/-/cjs-module-lexer-1.2.3.tgz#6c370ab19f8a3394e318fe682686ec0ac684d107" @@ -12879,6 +13023,15 @@ client-only@0.0.1, client-only@^0.0.1: resolved "https://registry.yarnpkg.com/client-only/-/client-only-0.0.1.tgz#38bba5d403c41ab150bff64a95c85013cf73bca1" integrity sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA== +clipboardy@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/clipboardy/-/clipboardy-3.0.0.tgz#f3876247404d334c9ed01b6f269c11d09a5e3092" + integrity sha512-Su+uU5sr1jkUy1sGRpLKjKrvEOVXgSgiSInwa/qeID6aJ07yh+5NWc3h2QfjHjBnfX4LhtFcuAWKUsJ3r+fjbg== + dependencies: + arch "^2.2.0" + execa "^5.1.1" + is-wsl "^2.2.0" + cliui@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/cliui/-/cliui-6.0.0.tgz#511d702c0c4e41ca156d7d0e96021f23e13225b1" @@ -12942,6 +13095,11 @@ clsx@^1.0.4, clsx@^1.1.0, clsx@^1.2.1: resolved "https://registry.yarnpkg.com/clsx/-/clsx-1.2.1.tgz#0ddc4a20a549b59c93a4116bb26f5294ca17dc12" integrity sha512-EcR6r5a8bj6pu3ycsa/E/cKVGuTgZJZdsyUYHOksG/UHIiKfjxzRxYJpyVBwYaQeOvghal9fcc4PidlgzugAQg== +cluster-key-slot@^1.1.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/cluster-key-slot/-/cluster-key-slot-1.1.2.tgz#88ddaa46906e303b5de30d3153b7d9fe0a0c19ac" + integrity sha512-RMr0FhtfXemyinomL4hrWcYJxmX6deFdCxpJzhDttxgO1+bcCnkk+9drydLVDmAMG7NE6aN/fl4F7ucU/90gAA== + cmd-shim@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/cmd-shim/-/cmd-shim-4.1.0.tgz#b3a904a6743e9fede4148c6f3800bf2a08135bdd" @@ -13284,6 +13442,11 @@ consola@^2.15.3: resolved "https://registry.yarnpkg.com/consola/-/consola-2.15.3.tgz#2e11f98d6a4be71ff72e0bdf07bd23e12cb61550" integrity sha512-9vAdYbHj6x2fLKC4+oPH0kFzY/orMZyG2Aj+kNylHxKGJ/Ed4dpNyAQYwJOdqO4zdM7XpVHmyejQDcQHrnuXbw== +consola@^3.2.3: + version "3.2.3" + resolved "https://registry.yarnpkg.com/consola/-/consola-3.2.3.tgz#0741857aa88cfa0d6fd53f1cff0375136e98502f" + integrity sha512-I5qxpzLv+sJhTVEoLYNcTW+bThDCPsit0vLNKShZx6rLtpilNpmmeTPaeqJb9ZE9dV3DGaeby6Vuhrw38WjeyQ== + console-browserify@^1.1.0: version "1.2.0" resolved "https://registry.yarnpkg.com/console-browserify/-/console-browserify-1.2.0.tgz#67063cef57ceb6cf4993a2ab3a55840ae8c49336" @@ -13426,6 +13589,11 @@ convert-source-map@^2.0.0: resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-2.0.0.tgz#4b560f649fc4e918dd0ab75cf4961e8bc882d82a" integrity sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg== +cookie-es@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/cookie-es/-/cookie-es-1.0.0.tgz#4759684af168dfc54365b2c2dda0a8d7ee1e4865" + integrity sha512-mWYvfOLrfEc996hlKcdABeIiPHUPC6DM2QYZdGGOvhOTbA3tjm2eBwqlJpoFdjC89NI4Qt6h0Pu06Mp+1Pj5OQ== + cookie-signature@1.0.6: version "1.0.6" resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.0.6.tgz#e303a882b342cc3ee8ca513a79999734dab3ae2c" @@ -14447,6 +14615,11 @@ define-property@^2.0.2: is-descriptor "^1.0.2" isobject "^3.0.1" +defu@^6.1.2, defu@^6.1.3: + version "6.1.3" + resolved "https://registry.yarnpkg.com/defu/-/defu-6.1.3.tgz#6d7f56bc61668e844f9f593ace66fd67ef1205fd" + integrity sha512-Vy2wmG3NTkmHNg/kzpuvHhkqeIx3ODWqasgCRbKtbXEN0G+HpEEv9BtJLp7ZG1CZloFaC41Ah3ZFbq7aqCqMeQ== + del@^6.1.1: version "6.1.1" resolved "https://registry.yarnpkg.com/del/-/del-6.1.1.tgz#3b70314f1ec0aa325c6b14eb36b95786671edb7a" @@ -14483,6 +14656,11 @@ delegates@^1.0.0: resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" integrity sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ== +denque@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/denque/-/denque-2.1.0.tgz#e93e1a6569fb5e66f16a3c2a2964617d349d6ab1" + integrity sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw== + depcheck@^1.4.3: version "1.4.3" resolved "https://registry.yarnpkg.com/depcheck/-/depcheck-1.4.3.tgz#faa4c143921f3fe25d5a7a633f9864327c250843" @@ -14550,6 +14728,11 @@ des.js@^1.0.0: inherits "^2.0.1" minimalistic-assert "^1.0.0" +destr@^2.0.1, destr@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/destr/-/destr-2.0.2.tgz#8d3c0ee4ec0a76df54bc8b819bca215592a8c218" + integrity sha512-65AlobnZMiCET00KaFFjUefxDX0khFA/E4myqZ7a6Sq1yZtR8+FVIvilVX66vF2uobSumxooYZChiRPCKNqhmg== + destroy@1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.2.0.tgz#4803735509ad8be552934c67df614f94e66fa015" @@ -14577,6 +14760,11 @@ detect-indent@^6.0.0: resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-6.1.0.tgz#592485ebbbf6b3b1ab2be175c8393d04ca0d57e6" integrity sha512-reYkTUJAZb9gUuZ2RvVCNhVHdg62RHnJ7WJl8ftMi4diZ6NWlciOzQN88pUhSELEwflJht4oQDv0F0BMlwaYtA== +detect-libc@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b" + integrity sha512-pGjwhsmsp4kL2RTz08wcOlGN83otlqHeD/Z5T8GXZB+/YcpQ/dgo+lbU8ZsGxV0HIvqqxo9l7mqYwyYMD9bKDg== + detect-libc@^2.0.0, detect-libc@^2.0.1: version "2.0.2" resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-2.0.2.tgz#8ccf2ba9315350e1241b88d0ac3b0e1fbd99605d" @@ -17437,6 +17625,11 @@ get-pkg-repo@^4.0.0: through2 "^2.0.0" yargs "^16.2.0" +get-port-please@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/get-port-please/-/get-port-please-3.1.1.tgz#2556623cddb4801d823c0a6a15eec038abb483be" + integrity sha512-3UBAyM3u4ZBVYDsxOQfJDxEa6XTbpBDrOjp4mf7ExFRt5BKs/QywQQiJsh2B+hxcZLSapWqCRvElUe8DnKcFHA== + get-port@^5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/get-port/-/get-port-5.1.1.tgz#0469ed07563479de6efb986baf053dcd7d4e3193" @@ -17969,6 +18162,20 @@ gzip-size@^6.0.0: dependencies: duplexer "^0.1.2" +h3@^1.8.1, h3@^1.8.2: + version "1.9.0" + resolved "https://registry.yarnpkg.com/h3/-/h3-1.9.0.tgz#c5f512a93026df9837db6f30c9ef51135dd46752" + integrity sha512-+F3ZqrNV/CFXXfZ2lXBINHi+rM4Xw3CDC5z2CDK3NMPocjonKipGLLDSkrqY9DOrioZNPTIdDMWfQKm//3X2DA== + dependencies: + cookie-es "^1.0.0" + defu "^6.1.3" + destr "^2.0.2" + iron-webcrypto "^1.0.0" + radix3 "^1.1.0" + ufo "^1.3.2" + uncrypto "^0.1.3" + unenv "^1.7.4" + handle-thing@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/handle-thing/-/handle-thing-2.0.1.tgz#857f79ce359580c340d43081cc648970d0bb234e" @@ -18546,6 +18753,11 @@ http-proxy@^1.18.1: follow-redirects "^1.0.0" requires-port "^1.0.0" +http-shutdown@^1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/http-shutdown/-/http-shutdown-1.2.2.tgz#41bc78fc767637c4c95179bc492f312c0ae64c5f" + integrity sha512-S9wWkJ/VSY9/k4qcjG318bqJNruzE4HySUhFYknwmu6LBP97KLLfwNf+n4V1BHurvFNkSKLFnK/RsuUnRTf9Vw== + http-signature@~1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1" @@ -18659,6 +18871,11 @@ icss-utils@^5.0.0, icss-utils@^5.1.0: resolved "https://registry.yarnpkg.com/icss-utils/-/icss-utils-5.1.0.tgz#c6be6858abd013d768e98366ae47e25d5887b1ae" integrity sha512-soFhflCVWLfRNOPU3iv5Z9VUdT44xFRbzjLsEzSr5AQmgqPMTHdU3PMT1Cf1ssx8fLNJDA1juftYl+PUcv3MqA== +idb-keyval@^6.2.1: + version "6.2.1" + resolved "https://registry.yarnpkg.com/idb-keyval/-/idb-keyval-6.2.1.tgz#94516d625346d16f56f3b33855da11bfded2db33" + integrity sha512-8Sb3veuYCyrZL+VBt9LJfZjLUPWVvqn8tG28VqYNFCo43KHcKuq+b4EiXGeuaLAQWL2YmyDgMp2aSpH9JHsEQg== + idna-uts46-hx@^2.3.1: version "2.3.1" resolved "https://registry.yarnpkg.com/idna-uts46-hx/-/idna-uts46-hx-2.3.1.tgz#a1dc5c4df37eee522bf66d969cc980e00e8711f9" @@ -18939,6 +19156,21 @@ io-ts@1.10.4: dependencies: fp-ts "^1.0.0" +ioredis@^5.3.2: + version "5.3.2" + resolved "https://registry.yarnpkg.com/ioredis/-/ioredis-5.3.2.tgz#9139f596f62fc9c72d873353ac5395bcf05709f7" + integrity sha512-1DKMMzlIHM02eBBVOFQ1+AolGjs6+xEcM4PDL7NqOS6szq7H9jSaEkIUH6/a5Hl241LzW6JLSiAbNvTQjUupUA== + dependencies: + "@ioredis/commands" "^1.1.1" + cluster-key-slot "^1.1.0" + debug "^4.3.4" + denque "^2.1.0" + lodash.defaults "^4.2.0" + lodash.isarguments "^3.1.0" + redis-errors "^1.2.0" + redis-parser "^3.0.0" + standard-as-callback "^2.1.0" + ip-regex@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/ip-regex/-/ip-regex-2.1.0.tgz#fa78bf5d2e6913c911ce9f819ee5146bb6d844e9" @@ -18959,6 +19191,11 @@ ipaddr.js@^2.0.1: resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-2.1.0.tgz#2119bc447ff8c257753b196fc5f1ce08a4cdf39f" integrity sha512-LlbxQ7xKzfBusov6UMi4MFpEg0m+mAm9xyNGEduwXMEDuf4WfzB/RZwMVYEd7IKGvh4IUkEXYxtAVu9T3OelJQ== +iron-webcrypto@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/iron-webcrypto/-/iron-webcrypto-1.0.0.tgz#e3b689c0c61b434a0a4cb82d0aeabbc8b672a867" + integrity sha512-anOK1Mktt8U1Xi7fCM3RELTuYbnFikQY5VtrDj7kPgpejV7d43tWKhzgioO0zpkazLEL/j/iayRqnJhrGfqUsg== + is-absolute-url@^3.0.0: version "3.0.3" resolved "https://registry.yarnpkg.com/is-absolute-url/-/is-absolute-url-3.0.3.tgz#96c6a22b6a23929b11ea0afb1836c36ad4a5d698" @@ -20607,6 +20844,11 @@ jiti@^1.17.1, jiti@^1.18.2: resolved "https://registry.yarnpkg.com/jiti/-/jiti-1.19.1.tgz#fa99e4b76a23053e0e7cde098efe1704a14c16f1" integrity sha512-oVhqoRDaBXf7sjkll95LHVS6Myyyb1zaunVwk4Z0+WPSW4gjS0pl01zYKHScTuyEhQsFxV5L4DR5r+YqSyqyyg== +jiti@^1.20.0: + version "1.21.0" + resolved "https://registry.yarnpkg.com/jiti/-/jiti-1.21.0.tgz#7c97f8fe045724e136a397f7340475244156105d" + integrity sha512-gFqAIbuKyyso/3G2qhiO2OM6shY6EPP/R0+mkDbyspxKazh8BXDC5FiFsUjlczgdNz/vfra0da2y+aHrusLG/Q== + joi@^17.6.0, joi@^17.7.0: version "17.9.2" resolved "https://registry.yarnpkg.com/joi/-/joi-17.9.2.tgz#8b2e4724188369f55451aebd1d0b1d9482470690" @@ -21224,6 +21466,29 @@ lint-staged@11.0.0: string-argv "0.3.1" stringify-object "^3.3.0" +listhen@^1.5.5: + version "1.5.5" + resolved "https://registry.yarnpkg.com/listhen/-/listhen-1.5.5.tgz#58915512af70f770aa3e9fb19367adf479bb58c4" + integrity sha512-LXe8Xlyh3gnxdv4tSjTjscD1vpr/2PRpzq8YIaMJgyKzRG8wdISlWVWnGThJfHnlJ6hmLt2wq1yeeix0TEbuoA== + dependencies: + "@parcel/watcher" "^2.3.0" + "@parcel/watcher-wasm" "2.3.0" + citty "^0.1.4" + clipboardy "^3.0.0" + consola "^3.2.3" + defu "^6.1.2" + get-port-please "^3.1.1" + h3 "^1.8.1" + http-shutdown "^1.2.2" + jiti "^1.20.0" + mlly "^1.4.2" + node-forge "^1.3.1" + pathe "^1.1.1" + std-env "^3.4.3" + ufo "^1.3.0" + untun "^0.1.2" + uqr "^0.1.2" + listr2@^3.8.2, listr2@^3.8.3: version "3.14.0" resolved "https://registry.yarnpkg.com/listr2/-/listr2-3.14.0.tgz#23101cc62e1375fd5836b248276d1d2b51fdbe9e" @@ -21413,6 +21678,11 @@ lodash.debounce@^4.0.8: resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af" integrity sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow== +lodash.defaults@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-4.2.0.tgz#d09178716ffea4dde9e5fb7b37f6f0802274580c" + integrity sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ== + lodash.flattendeep@^4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz#fb030917f86a3134e5bc9bec0d69e0013ddfedb2" @@ -21423,6 +21693,11 @@ lodash.flow@^3.3.0: resolved "https://registry.yarnpkg.com/lodash.flow/-/lodash.flow-3.5.0.tgz#87bf40292b8cf83e4e8ce1a3ae4209e20071675a" integrity sha512-ff3BX/tSioo+XojX4MOsOMhJw0nZoUEF011LX8g8d3gvjVbxd89cCio4BCXronjxcTUIJUoqKEUA+n4CqvvRPw== +lodash.isarguments@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz#2f573d85c6a24289ff00663b491c1d338ff3458a" + integrity sha512-chi4NHZlZqZD18a0imDHnZPrDeBbTtVN7GXMwuGdRH9qotxAjYs3aVLKc7zNOG9eddR5Ksd8rvFEBc9SsggPpg== + lodash.isequal@4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0" @@ -21592,6 +21867,11 @@ lowercase-keys@^3.0.0: resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-3.0.0.tgz#c5e7d442e37ead247ae9db117a9d0a467c89d4f2" integrity sha512-ozCC6gdQ+glXOQsveKD0YsDy8DSQFjDTz4zyzEHNV5+JP5D62LmfDZ6o1cycFx9ouG940M5dE8C8CTewdj2YWQ== +lru-cache@^10.0.2: + version "10.1.0" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.1.0.tgz#2098d41c2dc56500e6c88584aa656c84de7d0484" + integrity sha512-/1clY/ui8CzjKFyjdvwPWJUYKiFVXG2I2cY0ssG7h4+hwk+XOIX7ZSG9Q7TW8TW3Kp3BUSqgFWBLgL4PJ+Blag== + lru-cache@^4.0.1: version "4.1.5" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.5.tgz#8bbe50ea85bed59bc9e33dcab8235ee9bcf443cd" @@ -22294,6 +22574,11 @@ mime@2.6.0, mime@^2.4.4: resolved "https://registry.yarnpkg.com/mime/-/mime-2.6.0.tgz#a2a682a95cd4d0cb1d6257e28f83da7e35800367" integrity sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg== +mime@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/mime/-/mime-3.0.0.tgz#b374550dca3a0c18443b0c950a6a58f1931cf7a7" + integrity sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A== + mimic-fn@^1.0.0: version "1.2.0" resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022" @@ -22558,6 +22843,16 @@ mkdirp@^1.0.3, mkdirp@^1.0.4: resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== +mlly@^1.2.0, mlly@^1.4.2: + version "1.4.2" + resolved "https://registry.yarnpkg.com/mlly/-/mlly-1.4.2.tgz#7cf406aa319ff6563d25da6b36610a93f2a8007e" + integrity sha512-i/Ykufi2t1EZ6NaPLdfnZk2AX8cs0d+mTzVKuPfqPKPatxLApaBoxJQ9x1/uckXtrS/U5oisPMDkNs0yQTaBRg== + dependencies: + acorn "^8.10.0" + pathe "^1.1.1" + pkg-types "^1.0.3" + ufo "^1.3.0" + mnemonist@^0.38.0: version "0.38.5" resolved "https://registry.yarnpkg.com/mnemonist/-/mnemonist-0.38.5.tgz#4adc7f4200491237fe0fa689ac0b86539685cade" @@ -22660,7 +22955,7 @@ move-concurrently@^1.0.1: rimraf "^2.5.4" run-queue "^1.0.3" -mri@^1.1.0: +mri@^1.1.0, mri@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/mri/-/mri-1.2.0.tgz#6721480fec2a11a4889861115a48b6cbe7cc8f0b" integrity sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA== @@ -22827,6 +23122,11 @@ napi-build-utils@^1.0.1: resolved "https://registry.yarnpkg.com/napi-build-utils/-/napi-build-utils-1.0.2.tgz#b1fddc0b2c46e380a0b7a76f984dd47c41a13806" integrity sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg== +napi-wasm@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/napi-wasm/-/napi-wasm-1.1.0.tgz#bbe617823765ae9c1bc12ff5942370eae7b2ba4e" + integrity sha512-lHwIAJbmLSjF9VDRm9GoVOy9AGp3aIvkjv+Kvz9h16QR3uSVYH78PNQUnT2U4X53mhlnV2M7wrhibQ3GHicDmg== + natural-compare-lite@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz#17b09581988979fddafe0201e931ba933c96cbb4" @@ -22947,6 +23247,11 @@ node-addon-api@^5.0.0: resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-5.1.0.tgz#49da1ca055e109a23d537e9de43c09cca21eb762" integrity sha512-eh0GgfEkpnoWDq+VY8OyvYhFEzBk6jIYbRKdIlyTiAXIVJ8PyBaKb0rp7oDtoddbdoHWhq8wwr+XZ81F1rpNdA== +node-addon-api@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-7.0.0.tgz#8136add2f510997b3b94814f4af1cce0b0e3962e" + integrity sha512-vgbBJTS4m5/KkE16t5Ly0WW9hz46swAstv0hYYwMtbG7AznRhNyfLRe8HZAiWIpcHzoO7HxhLuBQj9rJ/Ho0ZA== + node-dir@^0.1.10: version "0.1.17" resolved "https://registry.yarnpkg.com/node-dir/-/node-dir-0.1.17.tgz#5f5665d93351335caabef8f1c554516cf5f1e4e5" @@ -22961,6 +23266,11 @@ node-emoji@^1.10.0: dependencies: lodash "^4.17.21" +node-fetch-native@^1.4.0, node-fetch-native@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/node-fetch-native/-/node-fetch-native-1.4.1.tgz#5a336e55b4e1b1e72b9927da09fecd2b374c9be5" + integrity sha512-NsXBU0UgBxo2rQLOeWNZqS3fvflWePMECr8CoSWoSTqCqGbVVsvl9vZu1HfQicYN0g5piV9Gh8RTEvo/uP752w== + node-fetch@^2.6.1, node-fetch@^2.6.12, node-fetch@^2.6.7: version "2.6.12" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.12.tgz#02eb8e22074018e3d5a83016649d04df0e348fba" @@ -22968,7 +23278,7 @@ node-fetch@^2.6.1, node-fetch@^2.6.12, node-fetch@^2.6.7: dependencies: whatwg-url "^5.0.0" -node-forge@^1: +node-forge@^1, node-forge@^1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-1.3.1.tgz#be8da2af243b2417d5f646a770663a92b7e9ded3" integrity sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA== @@ -23550,6 +23860,15 @@ obuf@^1.0.0, obuf@^1.1.2: resolved "https://registry.yarnpkg.com/obuf/-/obuf-1.1.2.tgz#09bea3343d41859ebd446292d11c9d4db619084e" integrity sha512-PX1wu0AmAdPqOL1mWhqmlOd8kOIZQwGZw6rh7uby9fTc5lhaOWFLX3I6R1hrF9k3zUY40e6igsLGkDXK92LJNg== +ofetch@^1.3.3: + version "1.3.3" + resolved "https://registry.yarnpkg.com/ofetch/-/ofetch-1.3.3.tgz#588cb806a28e5c66c2c47dd8994f9059a036d8c0" + integrity sha512-s1ZCMmQWXy4b5K/TW9i/DtiN8Ku+xCiHcjQ6/J/nDdssirrQNOoB165Zu8EqLMA2lln1JUth9a0aW9Ap2ctrUg== + dependencies: + destr "^2.0.1" + node-fetch-native "^1.4.0" + ufo "^1.3.0" + on-exit-leak-free@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/on-exit-leak-free/-/on-exit-leak-free-0.2.0.tgz#b39c9e3bf7690d890f4861558b0d7b90a442d209" @@ -24223,6 +24542,11 @@ path@^0.12.7: process "^0.11.1" util "^0.10.3" +pathe@^1.1.0, pathe@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/pathe/-/pathe-1.1.1.tgz#1dd31d382b974ba69809adc9a7a347e65d84829a" + integrity sha512-d+RQGp0MAYTIaDBIMmOfMwz3E+LOZnxx1HZd5R18mmCZY0QBlK0LDZfPc8FW8Ed2DlvsuE6PRjroDY+wg4+j/Q== + pathval@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.1.tgz#8534e77a77ce7ac5a2512ea21e0fdb8fcf6c3d8d" @@ -24364,6 +24688,15 @@ pkg-dir@^5.0.0: dependencies: find-up "^5.0.0" +pkg-types@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/pkg-types/-/pkg-types-1.0.3.tgz#988b42ab19254c01614d13f4f65a2cfc7880f868" + integrity sha512-nN7pYi0AQqJnoLPC9eHFQ8AcyaixBUOwvqc5TDnIKCMEE6I0y8P7OKA7fPexsXGCGxQDl/cmrLAp26LhcwxZ4A== + dependencies: + jsonc-parser "^3.2.0" + mlly "^1.2.0" + pathe "^1.1.0" + pkg-up@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/pkg-up/-/pkg-up-3.1.0.tgz#100ec235cc150e4fd42519412596a28512a0def5" @@ -25364,6 +25697,11 @@ quick-lru@^5.1.1: resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-5.1.1.tgz#366493e6b3e42a3a6885e2e99d18f80fb7a8c932" integrity sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA== +radix3@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/radix3/-/radix3-1.1.0.tgz#9745df67a49c522e94a33d0a93cf743f104b6e0d" + integrity sha512-pNsHDxbGORSvuSScqNJ+3Km6QAVqk8CfsCBIEoDgpqLrkD2f3QM4I7d1ozJJ172OmIcoUcerZaNWqtLkRXTV3A== + ramda@^0.28.0: version "0.28.0" resolved "https://registry.yarnpkg.com/ramda/-/ramda-0.28.0.tgz#acd785690100337e8b063cab3470019be427cc97" @@ -26046,6 +26384,18 @@ redent@^3.0.0: indent-string "^4.0.0" strip-indent "^3.0.0" +redis-errors@^1.0.0, redis-errors@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/redis-errors/-/redis-errors-1.2.0.tgz#eb62d2adb15e4eaf4610c04afe1529384250abad" + integrity sha512-1qny3OExCf0UvUV/5wpYKf2YwPcOqXzkwKKSmKHiE6ZMQs5heeE/c8eXK+PNllPvmjgAbfnsbpkGZWy8cBpn9w== + +redis-parser@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/redis-parser/-/redis-parser-3.0.0.tgz#b66d828cdcafe6b4b8a428a7def4c6bcac31c8b4" + integrity sha512-DJnGAeenTdpMEH6uAJRK/uiyEIH9WVsUmoLwzudwGJUwZPp80PDBWPHXSAGNPwNvIXAbe7MSUB1zQFugFml66A== + dependencies: + redis-errors "^1.0.0" + reduce-css-calc@^2.1.8: version "2.1.8" resolved "https://registry.yarnpkg.com/reduce-css-calc/-/reduce-css-calc-2.1.8.tgz#7ef8761a28d614980dc0c982f772c93f7a99de03" @@ -27963,6 +28313,11 @@ stacktrace-parser@^0.1.10: dependencies: type-fest "^0.7.1" +standard-as-callback@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/standard-as-callback/-/standard-as-callback-2.1.0.tgz#8953fc05359868a77b5b9739a665c5977bb7df45" + integrity sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A== + start-server-and-test@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/start-server-and-test/-/start-server-and-test-2.0.0.tgz#0644809d63036a8a001efb70582f3e37ebfdd33d" @@ -28005,6 +28360,11 @@ std-env@^3.0.1: resolved "https://registry.yarnpkg.com/std-env/-/std-env-3.3.3.tgz#a54f06eb245fdcfef53d56f3c0251f1d5c3d01fe" integrity sha512-Rz6yejtVyWnVjC1RFvNmYL10kgjC49EOghxWn0RFqlCHGFpQx+Xe7yW3I4ceK1SGrWIGMjD5Kbue8W/udkbMJg== +std-env@^3.4.3: + version "3.6.0" + resolved "https://registry.yarnpkg.com/std-env/-/std-env-3.6.0.tgz#94807562bddc68fa90f2e02c5fd5b6865bb4e98e" + integrity sha512-aFZ19IgVmhdB2uX599ve2kE6BIE3YMnQ6Gp6BURhW/oIzpXGKr878TQfAQZn1+i0Flcc/UKUy1gOlcfaUBCryg== + stealthy-require@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/stealthy-require/-/stealthy-require-1.1.1.tgz#35b09875b4ff49f26a777e509b3090a3226bf24b" @@ -29641,6 +30001,11 @@ uc.micro@^1.0.1, uc.micro@^1.0.5: resolved "https://registry.yarnpkg.com/uc.micro/-/uc.micro-1.0.6.tgz#9c411a802a409a91fc6cf74081baba34b24499ac" integrity sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA== +ufo@^1.3.0, ufo@^1.3.1, ufo@^1.3.2: + version "1.3.2" + resolved "https://registry.yarnpkg.com/ufo/-/ufo-1.3.2.tgz#c7d719d0628a1c80c006d2240e0d169f6e3c0496" + integrity sha512-o+ORpgGwaYQXgqGDwd+hkS4PuZ3QnmqMMxRuajK/a38L6fTpcE5GPIfrf+L/KemFzfUpeUQc1rRS1iDBozvnFA== + uglify-js@^3.1.4: version "3.17.4" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.17.4.tgz#61678cf5fa3f5b7eb789bb345df29afb8257c22c" @@ -29683,6 +30048,11 @@ unc-path-regex@^0.1.2: resolved "https://registry.yarnpkg.com/unc-path-regex/-/unc-path-regex-0.1.2.tgz#e73dd3d7b0d7c5ed86fbac6b0ae7d8c6a69d50fa" integrity sha512-eXL4nmJT7oCpkZsHZUOJo8hcX3GbsiDOa0Qu9F646fi8dT3XuSVopVqAcEiVzSKKH7UoDti23wNX3qGFxcW5Qg== +uncrypto@^0.1.3: + version "0.1.3" + resolved "https://registry.yarnpkg.com/uncrypto/-/uncrypto-0.1.3.tgz#e1288d609226f2d02d8d69ee861fa20d8348ef2b" + integrity sha512-Ql87qFHB3s/De2ClA9e0gsnS6zXG27SkTiSJwjCc9MebbfapQfuPzumMIUMi38ezPZVNFcHI9sUIepeQfw8J8Q== + undefsafe@^2.0.5: version "2.0.5" resolved "https://registry.yarnpkg.com/undefsafe/-/undefsafe-2.0.5.tgz#38733b9327bdcd226db889fb723a6efd162e6e2c" @@ -29698,6 +30068,17 @@ undici@^4.14.1: resolved "https://registry.yarnpkg.com/undici/-/undici-4.16.0.tgz#469bb87b3b918818d3d7843d91a1d08da357d5ff" integrity sha512-tkZSECUYi+/T1i4u+4+lwZmQgLXd4BLGlrc7KZPcLIW7Jpq99+Xpc30ONv7nS6F5UNOxp/HBZSSL9MafUrvJbw== +unenv@^1.7.4: + version "1.8.0" + resolved "https://registry.yarnpkg.com/unenv/-/unenv-1.8.0.tgz#0f860d5278405700bd95d47b23bc01f3a735d68c" + integrity sha512-uIGbdCWZfhRRmyKj1UioCepQ0jpq638j/Cf0xFTn4zD1nGJ2lSdzYHLzfdXN791oo/0juUiSWW1fBklXMTsuqg== + dependencies: + consola "^3.2.3" + defu "^6.1.3" + mime "^3.0.0" + node-fetch-native "^1.4.1" + pathe "^1.1.1" + unescape@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/unescape/-/unescape-1.0.1.tgz#956e430f61cad8a4d57d82c518f5e6cc5d0dda96" @@ -29899,6 +30280,23 @@ unset-value@^1.0.0: has-value "^0.3.1" isobject "^3.0.0" +unstorage@^1.9.0: + version "1.10.1" + resolved "https://registry.yarnpkg.com/unstorage/-/unstorage-1.10.1.tgz#bf8cc00a406e40a6293e893da9807057d95875b0" + integrity sha512-rWQvLRfZNBpF+x8D3/gda5nUCQL2PgXy2jNG4U7/Rc9BGEv9+CAJd0YyGCROUBKs9v49Hg8huw3aih5Bf5TAVw== + dependencies: + anymatch "^3.1.3" + chokidar "^3.5.3" + destr "^2.0.2" + h3 "^1.8.2" + ioredis "^5.3.2" + listhen "^1.5.5" + lru-cache "^10.0.2" + mri "^1.2.0" + node-fetch-native "^1.4.1" + ofetch "^1.3.3" + ufo "^1.3.1" + untildify@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/untildify/-/untildify-2.1.0.tgz#17eb2807987f76952e9c0485fc311d06a826a2e0" @@ -29911,6 +30309,15 @@ untildify@^4.0.0: resolved "https://registry.yarnpkg.com/untildify/-/untildify-4.0.0.tgz#2bc947b953652487e4600949fb091e3ae8cd919b" integrity sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw== +untun@^0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/untun/-/untun-0.1.2.tgz#fa42a62ae24c1c5c6f3209692a2b0e1f573f1353" + integrity sha512-wLAMWvxfqyTiBODA1lg3IXHQtjggYLeTK7RnSfqtOXixWJ3bAa2kK/HHmOOg19upteqO3muLvN6O/icbyQY33Q== + dependencies: + citty "^0.1.3" + consola "^3.2.3" + pathe "^1.1.1" + upath@^1.1.1: version "1.2.0" resolved "https://registry.yarnpkg.com/upath/-/upath-1.2.0.tgz#8f66dbcd55a883acdae4408af8b035a5044c1894" @@ -29968,6 +30375,11 @@ upper-case@^2.0.2: dependencies: tslib "^2.0.3" +uqr@^0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/uqr/-/uqr-0.1.2.tgz#5c6cd5dcff9581f9bb35b982cb89e2c483a41d7d" + integrity sha512-MJu7ypHq6QasgF5YRTjqscSzQp/W11zoUk6kvmlH+fmWEs63Y0Eib13hYFwAzagRJcVY8WVnlV+eBDUGMJ5IbA== + uri-js@^4.2.2: version "4.4.1" resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e" @@ -30392,15 +30804,15 @@ w3c-xmlserializer@^4.0.0: dependencies: xml-name-validator "^4.0.0" -wagmi@^1.4.5: - version "1.4.5" - resolved "https://registry.yarnpkg.com/wagmi/-/wagmi-1.4.5.tgz#65ccf763e17892871196b6e5b188e29f0b08d3df" - integrity sha512-Ph62E6cO5n2Z8Z5LTyZrkaNprxTsbC4w0qZJT4OJdXrEELziI8z/b4FO6amVFXdu2rDp/wpvF56e4mhKC8/Kdw== +wagmi@^1.4.12: + version "1.4.12" + resolved "https://registry.yarnpkg.com/wagmi/-/wagmi-1.4.12.tgz#e5d31c6d7621ecd9e32eded6c7b1041201223127" + integrity sha512-QRxpjhdMlZmbYTfn9VQkQMKq+l3kwA1O7tF10vaykPrjbGX+IIlyn72ib9oqW9BfQO7n/Sf/mnVz1zbxRhGPWA== dependencies: "@tanstack/query-sync-storage-persister" "^4.27.1" "@tanstack/react-query" "^4.28.0" "@tanstack/react-query-persist-client" "^4.28.0" - "@wagmi/core" "1.4.5" + "@wagmi/core" "1.4.12" abitype "0.8.7" use-sync-external-store "^1.2.0" From ef037adae11028b44d547ec8d0f49bfc5faac643 Mon Sep 17 00:00:00 2001 From: ChiTimesChi Date: Thu, 14 Dec 2023 16:46:54 +0000 Subject: [PATCH 02/29] Publish - @synapsecns/synapse-interface@0.1.208 --- packages/synapse-interface/CHANGELOG.md | 8 ++++++++ packages/synapse-interface/package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/synapse-interface/CHANGELOG.md b/packages/synapse-interface/CHANGELOG.md index 8596c8f198..38b4f82a17 100644 --- a/packages/synapse-interface/CHANGELOG.md +++ b/packages/synapse-interface/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.1.208](https://github.com/synapsecns/sanguine/compare/@synapsecns/synapse-interface@0.1.207...@synapsecns/synapse-interface@0.1.208) (2023-12-14) + +**Note:** Version bump only for package @synapsecns/synapse-interface + + + + + ## [0.1.207](https://github.com/synapsecns/sanguine/compare/@synapsecns/synapse-interface@0.1.206...@synapsecns/synapse-interface@0.1.207) (2023-12-14) **Note:** Version bump only for package @synapsecns/synapse-interface diff --git a/packages/synapse-interface/package.json b/packages/synapse-interface/package.json index bcc5149fa8..b506fab28b 100644 --- a/packages/synapse-interface/package.json +++ b/packages/synapse-interface/package.json @@ -1,6 +1,6 @@ { "name": "@synapsecns/synapse-interface", - "version": "0.1.207", + "version": "0.1.208", "private": true, "engines": { "node": ">=16.0.0" From 2e9e93fa1ba1b7df80f7b84c201697d798c38b4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CF=87=C2=B2?= <88190723+ChiTimesChi@users.noreply.github.com> Date: Mon, 18 Dec 2023 21:52:45 +0300 Subject: [PATCH 03/29] Sdk: expose bridge tx status (#1658) * Add placeholder logic for new functions * Chore: fix spelling * Add tests with expected behavior * Generalize bridgeModule -> RouterSet retrieval * Add skeleton for the end implementation * Implement ID / status for SynapseBridge * CCTP status check * Define behavior for destination CCTP tx * SynapseCCTP: getBridgeID * Add test for incorrect tx hash * Check that transaction receipt is not null * Tests for generalized "incorrect origin tx" behavior * Generalized tool for log extraction * Adapt synapseCCTP, add check to synapseBridge * Chore: bridgeId -> synapseTxId * Extra coverage to keep Code Rabbi happy --- packages/sdk-router/src/abi/SynapseCCTP.json | 767 ++++++++++++++++++ packages/sdk-router/src/operations/bridge.ts | 74 +- packages/sdk-router/src/router/router.ts | 19 + packages/sdk-router/src/router/routerSet.ts | 25 + .../src/router/synapseCCTPRouter.ts | 44 + .../src/router/synapseCCTPRouterSet.ts | 20 + .../sdk-router/src/router/synapseRouter.ts | 36 + .../sdk-router/src/router/synapseRouterSet.ts | 20 + packages/sdk-router/src/sdk.test.ts | 295 +++++++ packages/sdk-router/src/sdk.ts | 2 + packages/sdk-router/src/utils/logs.ts | 52 ++ 11 files changed, 1345 insertions(+), 9 deletions(-) create mode 100644 packages/sdk-router/src/abi/SynapseCCTP.json create mode 100644 packages/sdk-router/src/utils/logs.ts diff --git a/packages/sdk-router/src/abi/SynapseCCTP.json b/packages/sdk-router/src/abi/SynapseCCTP.json new file mode 100644 index 0000000000..b3034a7d88 --- /dev/null +++ b/packages/sdk-router/src/abi/SynapseCCTP.json @@ -0,0 +1,767 @@ +[ + { + "inputs": [ + { + "internalType": "contract ITokenMessenger", + "name": "tokenMessenger_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { "inputs": [], "name": "CCTPGasRescueFailed", "type": "error" }, + { "inputs": [], "name": "CCTPIncorrectChainId", "type": "error" }, + { "inputs": [], "name": "CCTPIncorrectConfig", "type": "error" }, + { "inputs": [], "name": "CCTPIncorrectDomain", "type": "error" }, + { "inputs": [], "name": "CCTPIncorrectGasAmount", "type": "error" }, + { "inputs": [], "name": "CCTPIncorrectProtocolFee", "type": "error" }, + { "inputs": [], "name": "CCTPIncorrectTokenAmount", "type": "error" }, + { "inputs": [], "name": "CCTPInsufficientAmount", "type": "error" }, + { "inputs": [], "name": "CCTPMessageNotReceived", "type": "error" }, + { "inputs": [], "name": "CCTPSymbolAlreadyAdded", "type": "error" }, + { "inputs": [], "name": "CCTPSymbolIncorrect", "type": "error" }, + { "inputs": [], "name": "CCTPTokenAlreadyAdded", "type": "error" }, + { "inputs": [], "name": "CCTPTokenNotFound", "type": "error" }, + { "inputs": [], "name": "CCTPZeroAddress", "type": "error" }, + { "inputs": [], "name": "CCTPZeroAmount", "type": "error" }, + { "inputs": [], "name": "CastOverflow", "type": "error" }, + { "inputs": [], "name": "ForwarderDeploymentFailed", "type": "error" }, + { "inputs": [], "name": "IncorrectRequestLength", "type": "error" }, + { "inputs": [], "name": "RemoteCCTPDeploymentNotSet", "type": "error" }, + { "inputs": [], "name": "UnknownRequestVersion", "type": "error" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "ChainGasAirdropped", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "chainGasAmount", + "type": "uint256" + } + ], + "name": "ChainGasAmountUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint32", + "name": "originDomain", + "type": "uint32" + }, + { + "indexed": true, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "mintToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "fee", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "requestID", + "type": "bytes32" + } + ], + "name": "CircleRequestFulfilled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "chainId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "nonce", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "requestVersion", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "formattedRequest", + "type": "bytes" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "requestID", + "type": "bytes32" + } + ], + "name": "CircleRequestSent", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "CircleTokenPoolSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "feeCollector", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "relayerFeeAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "protocolFeeAmount", + "type": "uint256" + } + ], + "name": "FeeCollected", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "relayer", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "oldFeeCollector", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newFeeCollector", + "type": "address" + } + ], + "name": "FeeCollectorUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "FeesWithdrawn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "newProtocolFee", + "type": "uint256" + } + ], + "name": "ProtocolFeeUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "remoteChainId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "remoteDomain", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "address", + "name": "remoteSynapseCCTP", + "type": "address" + } + ], + "name": "RemoteDomainConfigSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "TokenAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "relayerFee", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "minBaseFee", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "minSwapFee", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "maxFee", + "type": "uint256" + } + ], + "name": "TokenFeeSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "TokenRemoved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "inputs": [ + { "internalType": "address", "name": "", "type": "address" }, + { "internalType": "address", "name": "", "type": "address" } + ], + "name": "accumulatedFees", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "string", "name": "symbol", "type": "string" }, + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "relayerFee", "type": "uint256" }, + { "internalType": "uint256", "name": "minBaseFee", "type": "uint256" }, + { "internalType": "uint256", "name": "minSwapFee", "type": "uint256" }, + { "internalType": "uint256", "name": "maxFee", "type": "uint256" } + ], + "name": "addToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" }, + { "internalType": "bool", "name": "isSwap", "type": "bool" } + ], + "name": "calculateFeeAmount", + "outputs": [ + { "internalType": "uint256", "name": "fee", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "chainGasAmount", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "circleTokenPool", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "feeStructures", + "outputs": [ + { "internalType": "uint40", "name": "relayerFee", "type": "uint40" }, + { "internalType": "uint72", "name": "minBaseFee", "type": "uint72" }, + { "internalType": "uint72", "name": "minSwapFee", "type": "uint72" }, + { "internalType": "uint72", "name": "maxFee", "type": "uint72" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBridgeTokens", + "outputs": [ + { + "components": [ + { "internalType": "string", "name": "symbol", "type": "string" }, + { "internalType": "address", "name": "token", "type": "address" } + ], + "internalType": "struct BridgeToken[]", + "name": "bridgeTokens", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint32", "name": "remoteDomain", "type": "uint32" }, + { "internalType": "address", "name": "remoteToken", "type": "address" } + ], + "name": "getLocalToken", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "owner_", "type": "address" } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "requestID", "type": "bytes32" } + ], + "name": "isRequestFulfilled", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "localDomain", + "outputs": [{ "internalType": "uint32", "name": "", "type": "uint32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "messageTransmitter", + "outputs": [ + { + "internalType": "contract IMessageTransmitter", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pauseSending", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "protocolFee", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes", "name": "message", "type": "bytes" }, + { "internalType": "bytes", "name": "signature", "type": "bytes" }, + { "internalType": "uint32", "name": "requestVersion", "type": "uint32" }, + { "internalType": "bytes", "name": "formattedRequest", "type": "bytes" } + ], + "name": "receiveCircleToken", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "relayerFeeCollectors", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "name": "remoteDomainConfig", + "outputs": [ + { "internalType": "uint32", "name": "domain", "type": "uint32" }, + { "internalType": "address", "name": "synapseCCTP", "type": "address" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" } + ], + "name": "removeToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "rescueGas", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "recipient", "type": "address" }, + { "internalType": "uint256", "name": "chainId", "type": "uint256" }, + { "internalType": "address", "name": "burnToken", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" }, + { "internalType": "uint32", "name": "requestVersion", "type": "uint32" }, + { "internalType": "bytes", "name": "swapParams", "type": "bytes" } + ], + "name": "sendCircleToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "newChainGasAmount", + "type": "uint256" + } + ], + "name": "setChainGasAmount", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "circleToken", "type": "address" }, + { "internalType": "address", "name": "pool", "type": "address" } + ], + "name": "setCircleTokenPool", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "feeCollector", "type": "address" } + ], + "name": "setFeeCollector", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "newProtocolFee", "type": "uint256" } + ], + "name": "setProtocolFee", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "remoteChainId", "type": "uint256" }, + { "internalType": "uint32", "name": "remoteDomain", "type": "uint32" }, + { + "internalType": "address", + "name": "remoteSynapseCCTP", + "type": "address" + } + ], + "name": "setRemoteDomainConfig", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "relayerFee", "type": "uint256" }, + { "internalType": "uint256", "name": "minBaseFee", "type": "uint256" }, + { "internalType": "uint256", "name": "minSwapFee", "type": "uint256" }, + { "internalType": "uint256", "name": "maxFee", "type": "uint256" } + ], + "name": "setTokenFee", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "string", "name": "", "type": "string" }], + "name": "symbolToToken", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "tokenMessenger", + "outputs": [ + { + "internalType": "contract ITokenMessenger", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "tokenToSymbol", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "newOwner", "type": "address" } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "unpauseSending", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" } + ], + "name": "withdrawProtocolFees", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" } + ], + "name": "withdrawRelayerFees", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/packages/sdk-router/src/operations/bridge.ts b/packages/sdk-router/src/operations/bridge.ts index 77d402220b..3aea7cd4a6 100644 --- a/packages/sdk-router/src/operations/bridge.ts +++ b/packages/sdk-router/src/operations/bridge.ts @@ -117,6 +117,46 @@ export async function bridgeQuote( return bestSet.finalizeBridgeRoute(bestRoute, deadline) } +/** + * Gets the unique Synapse txId for a bridge operation that happened within a given transaction. + * Synapse txId is known as "kappa" for SynapseBridge contract and "requestID" for SynapseCCTP contract. + * This function is meant to abstract away the differences between the two bridge modules. + * + * @param originChainId - The ID of the origin chain. + * @param bridgeModuleName - The name of the bridge module. + * @param txHash - The transaction hash of the bridge operation on the origin chain. + * @returns A promise that resolves to the unique Synapse txId of the bridge operation. + */ +export async function getSynapseTxId( + this: SynapseSDK, + originChainId: number, + bridgeModuleName: string, + txHash: string +): Promise { + return getRouterSet + .call(this, bridgeModuleName) + .getSynapseTxId(originChainId, txHash) +} + +/** + * Checks whether a bridge operation has been completed on the destination chain. + * + * @param destChainId - The ID of the destination chain. + * @param bridgeModuleName - The name of the bridge module. + * @param synapseTxId - The unique Synapse txId of the bridge operation. + * @returns A promise that resolves to a boolean indicating whether the bridge operation has been completed. + */ +export async function getBridgeTxStatus( + this: SynapseSDK, + destChainId: number, + bridgeModuleName: string, + synapseTxId: string +): Promise { + return getRouterSet + .call(this, bridgeModuleName) + .getBridgeTxStatus(destChainId, synapseTxId) +} + /** * Returns the name of the bridge module that emits the given event. * This will be either SynapseBridge or SynapseCCTP. @@ -143,22 +183,18 @@ export function getBridgeModuleName( * or the bridge token. * * @param originChainId - The ID of the origin chain. - * @param bridgeNoduleName - The name of the bridge module. + * @param bridgeModuleName - The name of the bridge module. * @returns - The estimated time for a bridge operation, in seconds. * @throws - Will throw an error if the bridge module is unknown for the given chain. */ export function getEstimatedTime( this: SynapseSDK, originChainId: number, - bridgeNoduleName: string + bridgeModuleName: string ): number { - if (this.synapseRouterSet.bridgeModuleName === bridgeNoduleName) { - return this.synapseRouterSet.getEstimatedTime(originChainId) - } - if (this.synapseCCTPRouterSet.bridgeModuleName === bridgeNoduleName) { - return this.synapseCCTPRouterSet.getEstimatedTime(originChainId) - } - throw new Error('Unknown bridge module') + return getRouterSet + .call(this, bridgeModuleName) + .getEstimatedTime(originChainId) } /** @@ -174,3 +210,23 @@ export async function getBridgeGas( ): Promise { return this.synapseRouterSet.getSynapseRouter(chainId).chainGasAmount() } + +/** + * Extracts the RouterSet from the SynapseSDK based on the given bridge module name. + * + * @param bridgeModuleName - The name of the bridge module, SynapseBridge or SynapseCCTP. + * @returns The corresponding RouterSet. + * @throws Will throw an error if the bridge module is unknown. + */ +export function getRouterSet( + this: SynapseSDK, + bridgeModuleName: string +): RouterSet { + if (this.synapseRouterSet.bridgeModuleName === bridgeModuleName) { + return this.synapseRouterSet + } + if (this.synapseCCTPRouterSet.bridgeModuleName === bridgeModuleName) { + return this.synapseCCTPRouterSet + } + throw new Error('Unknown bridge module') +} diff --git a/packages/sdk-router/src/router/router.ts b/packages/sdk-router/src/router/router.ts index f2bbc6ca19..29d42ff79d 100644 --- a/packages/sdk-router/src/router/router.ts +++ b/packages/sdk-router/src/router/router.ts @@ -61,6 +61,25 @@ export abstract class Router { destQuery: Query ): Promise + /** + * Returns the Synapse transaction ID for a given transaction hash on the current chain. + * This is used to track the status of a bridge transaction originating from the current chain. + * + * @param txHash - The transaction hash of the bridge transaction. + * @returns A promise that resolves to the Synapse transaction ID. + */ + abstract getSynapseTxId(txHash: string): Promise + + /** + * Checks whether a bridge transaction has been completed on the current chain. + * This is used to track the status of a bridge transaction originating from another chain, having + * current chain as the destination chain. + * + * @param synapseTxId - The unique Synapse txId of the bridge transaction. + * @returns A promise that resolves to a boolean indicating whether the bridge transaction has been completed. + */ + abstract getBridgeTxStatus(synapseTxId: string): Promise + /** * Fetches bridge tokens for a destination chain and output token. * diff --git a/packages/sdk-router/src/router/routerSet.ts b/packages/sdk-router/src/router/routerSet.ts index c5e6329ade..0ff81da1fb 100644 --- a/packages/sdk-router/src/router/routerSet.ts +++ b/packages/sdk-router/src/router/routerSet.ts @@ -71,6 +71,31 @@ export abstract class RouterSet { */ abstract getEstimatedTime(chainId: number): number + /** + * Returns the Synapse transaction ID for a given transaction hash on a given chain. + * This is used to track the status of a bridge transaction. + * + * @param originChainId - The ID of the origin chain. + * @param txHash - The transaction hash of the bridge transaction. + * @returns A promise that resolves to the Synapse transaction ID. + */ + abstract getSynapseTxId( + originChainId: number, + txHash: string + ): Promise + + /** + * Checks whether a bridge transaction has been completed on the destination chain. + * + * @param destChainId - The ID of the destination chain. + * @param synapseTxId - The unique Synapse txId of the bridge transaction. + * @returns A promise that resolves to a boolean indicating whether the bridge transaction has been completed. + */ + abstract getBridgeTxStatus( + destChainId: number, + synapseTxId: string + ): Promise + /** * Returns the existing Router instance for the given address on the given chain. * If the router address is not valid, it will return undefined. diff --git a/packages/sdk-router/src/router/synapseCCTPRouter.ts b/packages/sdk-router/src/router/synapseCCTPRouter.ts index 6e789dcdce..a25b3882ed 100644 --- a/packages/sdk-router/src/router/synapseCCTPRouter.ts +++ b/packages/sdk-router/src/router/synapseCCTPRouter.ts @@ -8,6 +8,8 @@ import cctpRouterAbi from '../abi/SynapseCCTPRouter.json' import { SynapseCCTPRouter as SynapseCCTPRouterContract } from '../typechain/SynapseCCTPRouter' import { Router } from './router' import { Query, narrowToCCTPRouterQuery, reduceToQuery } from './query' +import cctpAbi from '../abi/SynapseCCTP.json' +import { getMatchingTxLog } from '../utils/logs' import { BigintIsh } from '../constants' import { BridgeToken, @@ -27,6 +29,10 @@ export class SynapseCCTPRouter extends Router { public readonly address: string private readonly routerContract: SynapseCCTPRouterContract + private cctpContractCache: Contract | undefined + + // All possible events emitted by the SynapseCCTP contract in the origin transaction + private readonly originEvents = ['CircleRequestSent'] constructor(chainId: number, provider: Provider, address: string) { // Parent constructor throws if chainId or provider are undefined @@ -114,4 +120,42 @@ export class SynapseCCTPRouter extends Router { narrowToCCTPRouterQuery(destQuery) ) } + + /** + * @inheritdoc Router.getSynapseTxId + */ + public async getSynapseTxId(txHash: string): Promise { + const cctpContract = await this.getCctpContract() + const cctpLog = await getMatchingTxLog( + this.provider, + txHash, + cctpContract, + this.originEvents + ) + // RequestID always exists in the log as we are using the correct ABI + const parsedLog = cctpContract.interface.parseLog(cctpLog) + return parsedLog.args.requestID + } + + /** + * @inheritdoc Router.getBridgeTxStatus + */ + public async getBridgeTxStatus(synapseTxId: string): Promise { + const cctpContract = await this.getCctpContract() + return cctpContract.isRequestFulfilled(synapseTxId) + } + + private async getCctpContract(): Promise { + // Populate the cache if necessary + if (!this.cctpContractCache) { + const cctpAddress = await this.routerContract.synapseCCTP() + this.cctpContractCache = new Contract( + cctpAddress, + new Interface(cctpAbi), + this.provider + ) + } + // Return the cached contract + return this.cctpContractCache + } } diff --git a/packages/sdk-router/src/router/synapseCCTPRouterSet.ts b/packages/sdk-router/src/router/synapseCCTPRouterSet.ts index b6252c7d1b..5f2498d9c6 100644 --- a/packages/sdk-router/src/router/synapseCCTPRouterSet.ts +++ b/packages/sdk-router/src/router/synapseCCTPRouterSet.ts @@ -28,6 +28,26 @@ export class SynapseCCTPRouterSet extends RouterSet { return medianTime } + /** + * @inheritdoc RouterSet.getSynapseTxId + */ + public async getSynapseTxId( + originChainId: number, + txHash: string + ): Promise { + return this.getSynapseCCTPRouter(originChainId).getSynapseTxId(txHash) + } + + /** + * @inheritdoc RouterSet.getBridgeTxStatus + */ + public async getBridgeTxStatus( + destChainId: number, + synapseTxId: string + ): Promise { + return this.getSynapseCCTPRouter(destChainId).getBridgeTxStatus(synapseTxId) + } + /** * Returns the existing SynapseCCTPRouter instance for the given chain. * diff --git a/packages/sdk-router/src/router/synapseRouter.ts b/packages/sdk-router/src/router/synapseRouter.ts index d32eb83999..bde39244df 100644 --- a/packages/sdk-router/src/router/synapseRouter.ts +++ b/packages/sdk-router/src/router/synapseRouter.ts @@ -3,6 +3,7 @@ import invariant from 'tiny-invariant' import { Contract, PopulatedTransaction } from '@ethersproject/contracts' import { Interface } from '@ethersproject/abi' import { BigNumber } from '@ethersproject/bignumber' +import { solidityKeccak256 } from 'ethers/lib/utils' import routerAbi from '../abi/SynapseRouter.json' import { @@ -24,6 +25,7 @@ import { reduceToFeeConfig, reduceToPoolToken, } from './types' +import { getMatchingTxLog } from '../utils/logs' /** * Wraps [tokens, lpToken] returned by the SynapseRouter contract into a PoolInfo object. @@ -59,6 +61,16 @@ export class SynapseRouter extends Router { private readonly routerContract: SynapseRouterContract private bridgeContractCache: Contract | undefined + // All possible events emitted by the SynapseBridge contract in the origin transaction (in alphabetical order) + private readonly originEvents = [ + 'TokenDeposit', + 'TokenDepositAndSwap', + 'TokenRedeem', + 'TokenRedeemAndRemove', + 'TokenRedeemAndSwap', + 'TokenRedeemV2', + ] + constructor(chainId: number, provider: Provider, address: string) { // Parent constructor throws if chainId or provider are undefined super(chainId, provider) @@ -137,6 +149,30 @@ export class SynapseRouter extends Router { ) } + /** + * @inheritdoc Router.getSynapseTxId + */ + public async getSynapseTxId(txHash: string): Promise { + // Check that the transaction hash refers to an origin transaction + const bridgeContract = await this.getBridgeContract() + await getMatchingTxLog( + this.provider, + txHash, + bridgeContract, + this.originEvents + ) + // Once we know the transaction is an origin transaction, we can calculate the Synapse txId + return solidityKeccak256(['string'], [txHash]) + } + + /** + * @inheritdoc Router.getBridgeTxStatus + */ + public async getBridgeTxStatus(synapseTxId: string): Promise { + const bridgeContract = await this.getBridgeContract() + return bridgeContract.kappaExists(synapseTxId) + } + // ═════════════════════════════════════════ SYNAPSE ROUTER (V1) ONLY ══════════════════════════════════════════════ private async getBridgeContract(): Promise { diff --git a/packages/sdk-router/src/router/synapseRouterSet.ts b/packages/sdk-router/src/router/synapseRouterSet.ts index 8d0209bcfd..b84f21b7e2 100644 --- a/packages/sdk-router/src/router/synapseRouterSet.ts +++ b/packages/sdk-router/src/router/synapseRouterSet.ts @@ -36,6 +36,26 @@ export class SynapseRouterSet extends RouterSet { return medianTime } + /** + * @inheritdoc RouterSet.getSynapseTxId + */ + public async getSynapseTxId( + originChainId: number, + txHash: string + ): Promise { + return this.getSynapseRouter(originChainId).getSynapseTxId(txHash) + } + + /** + * @inheritdoc RouterSet.getBridgeTxStatus + */ + public async getBridgeTxStatus( + destChainId: number, + synapseTxId: string + ): Promise { + return this.getSynapseRouter(destChainId).getBridgeTxStatus(synapseTxId) + } + /** * Returns the existing SynapseRouter instance for the given chain. * diff --git a/packages/sdk-router/src/sdk.test.ts b/packages/sdk-router/src/sdk.test.ts index 1df69d660b..e8fce8bb2e 100644 --- a/packages/sdk-router/src/sdk.test.ts +++ b/packages/sdk-router/src/sdk.test.ts @@ -29,6 +29,7 @@ import { SupportedChainId, } from './constants' import { BridgeQuote, FeeConfig, RouterQuery, SwapQuote } from './router' +import * as operations from './operations' const expectCorrectFeeConfig = (feeConfig: FeeConfig) => { expect(feeConfig).toBeDefined() @@ -693,6 +694,276 @@ describe('SynapseSDK', () => { ) }) + describe('Bridge Tx Status', () => { + const synapse = new SynapseSDK( + [SupportedChainId.ARBITRUM, SupportedChainId.ETH], + [arbProvider, ethProvider] + ) + + // https://etherscan.io/tx/0xe3f0f0c1d139c48730492c900f9978449d70c0939c654d5abbfd6b191f9c7b3d + // https://arbiscan.io/tx/0xb13d5c9156e2d88662fa2f252bd2e1d77d768f0de9d27ca60a79e40b493f6ef2 + const bridgeEthToArbTx = { + txHash: + '0xe3f0f0c1d139c48730492c900f9978449d70c0939c654d5abbfd6b191f9c7b3d', + synapseTxId: + '0x2f223fb1509f04f777b5c9dd2287931b6e63d994a6a697db7a08cfbe784b5e90', + } + + // https://arbiscan.io/tx/0xe226c7e38e4b83072aa9d947e533be32c8bb38120bbdd8f490c5c6a5894e62c9 + // https://etherscan.io/tx/0xb88feb2a92690448b840851dff41dbc7cdc975c1fb740f0523b5c2e407ac9f38 + const bridgeArbToEthTx = { + txHash: + '0xe226c7e38e4b83072aa9d947e533be32c8bb38120bbdd8f490c5c6a5894e62c9', + synapseTxId: + '0xf7b8085d96b1ea3f6bf7a07ad93d1861b8fcd551ef56665d6a22c9fb7633a097', + } + + // https://etherscan.io/tx/0x1a25b0dfde1e2cc43f1dc659ba60f2b8e7ff8177555773fea0c4fba2d6e9c393 + // https://arbiscan.io/tx/0x0166c1e99b0ec8942ed10527cd7ac9003111ee697e0c0519312228e669a61378 + const cctpEthToArbTx = { + txHash: + '0x1a25b0dfde1e2cc43f1dc659ba60f2b8e7ff8177555773fea0c4fba2d6e9c393', + synapseTxId: + '0x492b923b5a0ace2715a8d0a80fb93c094bf6d35b142a010bdc3761b8613439fc', + } + + // https://arbiscan.io/tx/0x2a6d04ba5a48331454f00d136b3666869d03f004395fea25d97d42715c119096 + // https://etherscan.io/tx/0xefb946d2acf8343ac5526de66de498e0d5f70ae73c81b833181616ee058a22d7 + const cctpArbToEthTx = { + txHash: + '0x2a6d04ba5a48331454f00d136b3666869d03f004395fea25d97d42715c119096', + synapseTxId: + '0xed98b02f712c940d3b37a1aa9005a5986ecefa5cdbb4505118a22ae65d4903af', + } + + describe('getSynapseTxId', () => { + describe('SynapseBridge', () => { + const ethSynBridge = '0x2796317b0fF8538F253012862c06787Adfb8cEb6' + const events = + 'TokenDeposit, TokenDepositAndSwap, TokenRedeem, TokenRedeemAndRemove, TokenRedeemAndSwap, TokenRedeemV2' + + it('ETH -> ARB', async () => { + const synapseTxId = await synapse.getSynapseTxId( + SupportedChainId.ETH, + 'SynapseBridge', + bridgeEthToArbTx.txHash + ) + expect(synapseTxId).toEqual(bridgeEthToArbTx.synapseTxId) + }) + + it('ARB -> ETH', async () => { + const synapseTxId = await synapse.getSynapseTxId( + SupportedChainId.ARBITRUM, + 'SynapseBridge', + bridgeArbToEthTx.txHash + ) + expect(synapseTxId).toEqual(bridgeArbToEthTx.synapseTxId) + }) + + it('Throws when given a txHash that does not exist', async () => { + // Use txHash for another chain + await expect( + synapse.getSynapseTxId( + SupportedChainId.ETH, + 'SynapseBridge', + bridgeArbToEthTx.txHash + ) + ).rejects.toThrow('Failed to get transaction receipt') + }) + + it('Throws when origin tx does not refer to SynapseBridge', async () => { + const errorMsg = + `Contract ${ethSynBridge} in transaction ${cctpEthToArbTx.txHash}` + + ` did not emit any of the expected events: ${events}` + await expect( + synapse.getSynapseTxId( + SupportedChainId.ETH, + 'SynapseBridge', + cctpEthToArbTx.txHash + ) + ).rejects.toThrow(errorMsg) + }) + + it('Throws when given a destination tx', async () => { + // Destination tx hash for ARB -> ETH + const txHash = + '0xefb946d2acf8343ac5526de66de498e0d5f70ae73c81b833181616ee058a22d7' + const errorMsg = + `Contract ${ethSynBridge} in transaction ${txHash}` + + ` did not emit any of the expected events: ${events}` + await expect( + synapse.getSynapseTxId( + SupportedChainId.ETH, + 'SynapseBridge', + txHash + ) + ).rejects.toThrow(errorMsg) + }) + }) + + describe('SynapseCCTP', () => { + const ethSynCCTP = '0x12715a66773BD9C54534a01aBF01d05F6B4Bd35E' + const events = 'CircleRequestSent' + + it('ETH -> ARB', async () => { + const synapseTxId = await synapse.getSynapseTxId( + SupportedChainId.ETH, + 'SynapseCCTP', + cctpEthToArbTx.txHash + ) + expect(synapseTxId).toEqual(cctpEthToArbTx.synapseTxId) + }) + + it('ARB -> ETH', async () => { + const synapseTxId = await synapse.getSynapseTxId( + SupportedChainId.ARBITRUM, + 'SynapseCCTP', + cctpArbToEthTx.txHash + ) + expect(synapseTxId).toEqual(cctpArbToEthTx.synapseTxId) + }) + + it('Throws when given a txHash that does not exist', async () => { + // Use txHash for another chain + await expect( + synapse.getSynapseTxId( + SupportedChainId.ETH, + 'SynapseCCTP', + cctpArbToEthTx.txHash + ) + ).rejects.toThrow('Failed to get transaction receipt') + }) + + it('Throws when origin tx does not refer to SynapseCCTP', async () => { + const errorMsg = + `Contract ${ethSynCCTP} in transaction ${bridgeEthToArbTx.txHash}` + + ` did not emit any of the expected events: ${events}` + await expect( + synapse.getSynapseTxId( + SupportedChainId.ETH, + 'SynapseCCTP', + bridgeEthToArbTx.txHash + ) + ).rejects.toThrow(errorMsg) + }) + + it('Throws when given a destination tx', async () => { + // Destination tx hash for ARB -> ETH + const txHash = + '0xefb946d2acf8343ac5526de66de498e0d5f70ae73c81b833181616ee058a22d7' + const errorMsg = + `Contract ${ethSynCCTP} in transaction ${txHash}` + + ` did not emit any of the expected events: ${events}` + await expect( + synapse.getSynapseTxId(SupportedChainId.ETH, 'SynapseCCTP', txHash) + ).rejects.toThrow(errorMsg) + }) + }) + + it('Throws when bridge module name is invalid', async () => { + await expect( + synapse.getSynapseTxId( + SupportedChainId.ETH, + 'SynapseSynapse', + bridgeEthToArbTx.txHash + ) + ).rejects.toThrow('Unknown bridge module') + }) + }) + + describe('getBridgeTxStatus', () => { + describe('SynapseBridge', () => { + it('ETH -> ARB', async () => { + const txStatus = await synapse.getBridgeTxStatus( + SupportedChainId.ARBITRUM, + 'SynapseBridge', + bridgeEthToArbTx.synapseTxId + ) + expect(txStatus).toBe(true) + }) + + it('ARB -> ETH', async () => { + const txStatus = await synapse.getBridgeTxStatus( + SupportedChainId.ETH, + 'SynapseBridge', + bridgeArbToEthTx.synapseTxId + ) + expect(txStatus).toBe(true) + }) + + it('Returns false when unknown synapseTxId', async () => { + // Using txHash instead of synapseTxId + const txStatus = await synapse.getBridgeTxStatus( + SupportedChainId.ETH, + 'SynapseBridge', + bridgeArbToEthTx.txHash + ) + expect(txStatus).toBe(false) + }) + + it('Returns false when origin chain is used instead of destination', async () => { + // First argument should be destination chainId + const txStatus = await synapse.getBridgeTxStatus( + SupportedChainId.ETH, + 'SynapseBridge', + bridgeEthToArbTx.synapseTxId + ) + expect(txStatus).toBe(false) + }) + }) + + describe('SynapseCCTP', () => { + it('ETH -> ARB', async () => { + const txStatus = await synapse.getBridgeTxStatus( + SupportedChainId.ARBITRUM, + 'SynapseCCTP', + cctpEthToArbTx.synapseTxId + ) + expect(txStatus).toBe(true) + }) + + it('ARB -> ETH', async () => { + const txStatus = await synapse.getBridgeTxStatus( + SupportedChainId.ETH, + 'SynapseCCTP', + cctpArbToEthTx.synapseTxId + ) + expect(txStatus).toBe(true) + }) + + it('Returns false when unknown synapseTxId', async () => { + // Using txHash instead of synapseTxId + const txStatus = await synapse.getBridgeTxStatus( + SupportedChainId.ETH, + 'SynapseCCTP', + cctpArbToEthTx.txHash + ) + expect(txStatus).toBe(false) + }) + + it('Returns false when origin chain is used instead of destination', async () => { + // First argument should be destination chainId + const txStatus = await synapse.getBridgeTxStatus( + SupportedChainId.ETH, + 'SynapseCCTP', + cctpEthToArbTx.synapseTxId + ) + expect(txStatus).toBe(false) + }) + }) + + it('Throws when bridge module name is invalid', async () => { + await expect( + synapse.getBridgeTxStatus( + SupportedChainId.ETH, + 'SynapseSynapse', + bridgeEthToArbTx.txHash + ) + ).rejects.toThrow('Unknown bridge module') + }) + }) + }) + describe('getBridgeModuleName', () => { const synapse = new SynapseSDK([], []) @@ -1022,4 +1293,28 @@ describe('SynapseSDK', () => { ) }) }) + + describe('Internal functions', () => { + const synapse = new SynapseSDK( + [SupportedChainId.ARBITRUM, SupportedChainId.ETH], + [arbProvider, ethProvider] + ) + describe('getRouterSet', () => { + it('Returns correct set for SynapseBridge', () => { + const routerSet = operations.getRouterSet.call(synapse, 'SynapseBridge') + expect(routerSet).toEqual(synapse.synapseRouterSet) + }) + + it('Returns correct set for SynapseCCTP', () => { + const routerSet = operations.getRouterSet.call(synapse, 'SynapseCCTP') + expect(routerSet).toEqual(synapse.synapseCCTPRouterSet) + }) + + it('Throws when bridge module name is invalid', () => { + expect(() => + operations.getRouterSet.call(synapse, 'SynapseSynapse') + ).toThrow('Unknown bridge module') + }) + }) + }) }) diff --git a/packages/sdk-router/src/sdk.ts b/packages/sdk-router/src/sdk.ts index 7cd4a0153e..dfde1e2a55 100644 --- a/packages/sdk-router/src/sdk.ts +++ b/packages/sdk-router/src/sdk.ts @@ -48,6 +48,8 @@ class SynapseSDK { public bridgeQuote = operations.bridgeQuote public getBridgeModuleName = operations.getBridgeModuleName public getEstimatedTime = operations.getEstimatedTime + public getSynapseTxId = operations.getSynapseTxId + public getBridgeTxStatus = operations.getBridgeTxStatus public getBridgeGas = operations.getBridgeGas diff --git a/packages/sdk-router/src/utils/logs.ts b/packages/sdk-router/src/utils/logs.ts new file mode 100644 index 0000000000..2b8c2f1e4e --- /dev/null +++ b/packages/sdk-router/src/utils/logs.ts @@ -0,0 +1,52 @@ +import { Log, Provider } from '@ethersproject/abstract-provider' +import { Contract } from '@ethersproject/contracts' +import { Interface } from '@ethersproject/abi' + +/** + * Extracts the first log from a transaction receipt that matches + * the provided contract and any of the provided event names. + * + * @param provider - Ethers provider for the network + * @param txHash - Transaction hash + * @param contract - Contract that should have emitted the event + * @param eventNames - Names of the events that could have been emitted + * @returns The first log that matches the contract and any of the event names + * @throws If the transaction receipt cannot be retrieved, or if no matching log is found + */ +export const getMatchingTxLog = async ( + provider: Provider, + txHash: string, + contract: Contract, + eventNames: string[] +): Promise => { + const txReceipt = await provider.getTransactionReceipt(txHash) + if (!txReceipt) { + throw new Error('Failed to get transaction receipt') + } + const topics = getEventTopics(contract.interface, eventNames) + // Find the log with the correct contract address and topic matching any of the provided topics + const matchingLog = txReceipt.logs.find((log) => { + return log.address === contract.address && topics.includes(log.topics[0]) + }) + if (!matchingLog) { + // Throw an error and include the event names in the message + throw new Error( + `Contract ${ + contract.address + } in transaction ${txHash} did not emit any of the expected events: ${eventNames.join( + ', ' + )}` + ) + } + return matchingLog +} + +const getEventTopics = ( + contractInterface: Interface, + eventNames: string[] +): string[] => { + // Filter events that match the provided event names and map them to their topics + return Object.values(contractInterface.events) + .filter((event) => eventNames.includes(event.name)) + .map((event) => contractInterface.getEventTopic(event)) +} From 77e6efbcaf6c0ec7f10962b4995e5301878d8a0e Mon Sep 17 00:00:00 2001 From: ChiTimesChi Date: Mon, 18 Dec 2023 18:55:53 +0000 Subject: [PATCH 04/29] Publish - @synapsecns/rest-api@1.0.28 - @synapsecns/sdk-router@0.3.1 - @synapsecns/synapse-interface@0.1.209 --- packages/rest-api/CHANGELOG.md | 8 ++++++++ packages/rest-api/package.json | 4 ++-- packages/sdk-router/CHANGELOG.md | 8 ++++++++ packages/sdk-router/package.json | 2 +- packages/synapse-interface/CHANGELOG.md | 8 ++++++++ packages/synapse-interface/package.json | 4 ++-- 6 files changed, 29 insertions(+), 5 deletions(-) diff --git a/packages/rest-api/CHANGELOG.md b/packages/rest-api/CHANGELOG.md index beb2746464..3fbe07e202 100644 --- a/packages/rest-api/CHANGELOG.md +++ b/packages/rest-api/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.28](https://github.com/synapsecns/sanguine/compare/@synapsecns/rest-api@1.0.27...@synapsecns/rest-api@1.0.28) (2023-12-18) + +**Note:** Version bump only for package @synapsecns/rest-api + + + + + ## [1.0.27](https://github.com/synapsecns/sanguine/compare/@synapsecns/rest-api@1.0.26...@synapsecns/rest-api@1.0.27) (2023-12-12) **Note:** Version bump only for package @synapsecns/rest-api diff --git a/packages/rest-api/package.json b/packages/rest-api/package.json index b6ba5cb264..6eb4225106 100644 --- a/packages/rest-api/package.json +++ b/packages/rest-api/package.json @@ -1,6 +1,6 @@ { "name": "@synapsecns/rest-api", - "version": "1.0.27", + "version": "1.0.28", "private": "true", "engines": { "node": ">=16.0.0" @@ -23,7 +23,7 @@ "@ethersproject/bignumber": "^5.7.0", "@ethersproject/providers": "^5.7.2", "@ethersproject/units": "5.7.0", - "@synapsecns/sdk-router": "^0.3.0", + "@synapsecns/sdk-router": "^0.3.1", "bignumber": "^1.1.0", "ethers": "5.7.2", "express": "^4.18.2", diff --git a/packages/sdk-router/CHANGELOG.md b/packages/sdk-router/CHANGELOG.md index e0c0de4307..a9de2dd6cc 100644 --- a/packages/sdk-router/CHANGELOG.md +++ b/packages/sdk-router/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.3.1](https://github.com/synapsecns/sanguine/compare/@synapsecns/sdk-router@0.3.0...@synapsecns/sdk-router@0.3.1) (2023-12-18) + +**Note:** Version bump only for package @synapsecns/sdk-router + + + + + # [0.3.0](https://github.com/synapsecns/sanguine/compare/@synapsecns/sdk-router@0.2.24...@synapsecns/sdk-router@0.3.0) (2023-12-12) diff --git a/packages/sdk-router/package.json b/packages/sdk-router/package.json index d9daf86230..594e10938f 100644 --- a/packages/sdk-router/package.json +++ b/packages/sdk-router/package.json @@ -1,7 +1,7 @@ { "name": "@synapsecns/sdk-router", "description": "An SDK for interacting with the Synapse Protocol", - "version": "0.3.0", + "version": "0.3.1", "license": "MIT", "main": "dist/index.js", "typings": "dist/index.d.ts", diff --git a/packages/synapse-interface/CHANGELOG.md b/packages/synapse-interface/CHANGELOG.md index 38b4f82a17..a5708f9d8d 100644 --- a/packages/synapse-interface/CHANGELOG.md +++ b/packages/synapse-interface/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.1.209](https://github.com/synapsecns/sanguine/compare/@synapsecns/synapse-interface@0.1.208...@synapsecns/synapse-interface@0.1.209) (2023-12-18) + +**Note:** Version bump only for package @synapsecns/synapse-interface + + + + + ## [0.1.208](https://github.com/synapsecns/sanguine/compare/@synapsecns/synapse-interface@0.1.207...@synapsecns/synapse-interface@0.1.208) (2023-12-14) **Note:** Version bump only for package @synapsecns/synapse-interface diff --git a/packages/synapse-interface/package.json b/packages/synapse-interface/package.json index b506fab28b..5c79242cf1 100644 --- a/packages/synapse-interface/package.json +++ b/packages/synapse-interface/package.json @@ -1,6 +1,6 @@ { "name": "@synapsecns/synapse-interface", - "version": "0.1.208", + "version": "0.1.209", "private": true, "engines": { "node": ">=16.0.0" @@ -42,7 +42,7 @@ "@reduxjs/toolkit": "^1.9.5", "@rtk-query/graphql-request-base-query": "^2.2.0", "@segment/analytics-next": "^1.53.0", - "@synapsecns/sdk-router": "^0.3.0", + "@synapsecns/sdk-router": "^0.3.1", "@tailwindcss/aspect-ratio": "^0.4.2", "@tailwindcss/forms": "^0.5.3", "@tailwindcss/line-clamp": "^0.4.2", From 530cf510712abdbd83ebd442ea4c60d6c898a8ca Mon Sep 17 00:00:00 2001 From: trajan0x <83933037+trajan0x@users.noreply.github.com> Date: Wed, 20 Dec 2023 20:24:31 +0100 Subject: [PATCH 05/29] Updates Submitter w/ Oracle fallback (#1671) --------- Co-authored-by: Trajan0x Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- agents/go.mod | 4 +- agents/go.sum | 7 +- agents/types/utils.go | 8 +- contrib/promexporter/config/config.go | 2 +- contrib/terraform-provider-helmproxy/go.mod | 2 +- contrib/terraform-provider-helmproxy/go.sum | 4 +- ethergo/backends/anvil/anvil.go | 89 ++++----- ethergo/backends/base/base.go | 1 + ethergo/backends/simulated/chain.go | 1 + ethergo/chain/chain_impl.go | 1 + ethergo/client/client.go | 30 +++ ethergo/go.mod | 2 +- ethergo/go.sum | 3 +- ethergo/submitter/chain_queue.go | 63 +++++-- ethergo/submitter/export_test.go | 80 +++----- ethergo/submitter/submitter.go | 97 +++++++++- ethergo/submitter/suite_test.go | 14 ++ ethergo/submitter/util.go | 99 +--------- ethergo/submitter/util_test.go | 187 +------------------ ethergo/util/export_test.go | 38 +++- ethergo/util/transactor.go | 97 ++++++++++ ethergo/util/transactor_test.go | 194 ++++++++++++++++++++ services/cctp-relayer/go.mod | 4 +- services/cctp-relayer/go.sum | 7 +- services/omnirpc/go.mod | 4 +- services/omnirpc/go.sum | 7 +- services/scribe/go.mod | 4 +- services/scribe/go.sum | 7 +- services/sinner/go.mod | 4 +- services/sinner/go.sum | 7 +- 30 files changed, 628 insertions(+), 439 deletions(-) create mode 100644 ethergo/util/transactor.go create mode 100644 ethergo/util/transactor_test.go diff --git a/agents/go.mod b/agents/go.mod index b4151a6627..e2d2956519 100644 --- a/agents/go.mod +++ b/agents/go.mod @@ -74,7 +74,7 @@ require ( github.com/acomagu/bufpipe v1.0.4 // indirect github.com/agnivade/levenshtein v1.1.1 // indirect github.com/alecthomas/chroma v0.7.1 // indirect - github.com/andybalholm/brotli v1.0.4 // indirect + github.com/andybalholm/brotli v1.0.5 // indirect github.com/aws/aws-sdk-go-v2 v1.18.0 // indirect github.com/aws/aws-sdk-go-v2/config v1.18.21 // indirect github.com/aws/aws-sdk-go-v2/credentials v1.13.20 // indirect @@ -194,7 +194,7 @@ require ( github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a // indirect github.com/keep-network/keep-common v1.7.1-0.20211012131917-7102d7b9c6a0 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect - github.com/klauspost/compress v1.15.12 // indirect + github.com/klauspost/compress v1.16.0 // indirect github.com/klauspost/cpuid/v2 v2.2.4 // indirect github.com/kyokomi/emoji/v2 v2.2.8 // indirect github.com/leodido/go-urn v1.2.4 // indirect diff --git a/agents/go.sum b/agents/go.sum index 2f426f6973..0e9b3250a2 100644 --- a/agents/go.sum +++ b/agents/go.sum @@ -148,8 +148,9 @@ github.com/allegro/bigcache v1.2.1 h1:hg1sY1raCwic3Vnsvje6TT7/pnZba83LeFck5NrFKS github.com/allegro/bigcache v1.2.1/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= -github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY= github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= +github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= +github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= @@ -815,8 +816,8 @@ github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6 github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.15.0/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= -github.com/klauspost/compress v1.15.12 h1:YClS/PImqYbn+UILDnqxQCZ3RehC9N318SU3kElDUEM= -github.com/klauspost/compress v1.15.12/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= +github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= +github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= diff --git a/agents/types/utils.go b/agents/types/utils.go index 0c789f48b6..1213d68fb0 100644 --- a/agents/types/utils.go +++ b/agents/types/utils.go @@ -3,6 +3,7 @@ package types import ( "context" "fmt" + "math/big" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" @@ -27,9 +28,12 @@ func signEncoder(ctx context.Context, signer signer.Signer, encoder Encoder, sal } // Sign the message. - signature, err := signer.SignMessage(ctx, core.BytesToSlice(hashedDigest), false) + sig, err := signer.SignMessage(ctx, core.BytesToSlice(hashedDigest), false) if err != nil { return nil, nil, common.Hash{}, fmt.Errorf("could not sign: %w", err) } - return signature, encoded, hashedDigest, nil + + sig = NewSignature(new(big.Int).Add(big.NewInt(27), sig.V()), sig.R(), sig.S()) + + return sig, encoded, hashedDigest, nil } diff --git a/contrib/promexporter/config/config.go b/contrib/promexporter/config/config.go index bfd938e83e..3e32546a33 100644 --- a/contrib/promexporter/config/config.go +++ b/contrib/promexporter/config/config.go @@ -99,7 +99,7 @@ func DecodeConfig(filePath string) (_ Config, err error) { Name: "messenger", }, { - Address: "0x0a1e1d0eb6a1cef79e46f0e2d35b7bf2e958a26a", + Address: "0x49357ba0Ef3a8daC25903472eEe45C41221D4F9a", Name: "cctp", ChainIDs: types.ToInts(types.ETH, types.ARBITRUM, types.AVALANCHE, types.OPTIMISM), }, diff --git a/contrib/terraform-provider-helmproxy/go.mod b/contrib/terraform-provider-helmproxy/go.mod index 1dda73cba5..96caf9d0e4 100644 --- a/contrib/terraform-provider-helmproxy/go.mod +++ b/contrib/terraform-provider-helmproxy/go.mod @@ -127,7 +127,7 @@ require ( github.com/json-iterator/go v1.1.12 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect github.com/kirsle/configdir v0.0.0-20170128060238-e45d2f54772f // indirect - github.com/klauspost/compress v1.15.12 // indirect + github.com/klauspost/compress v1.16.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect diff --git a/contrib/terraform-provider-helmproxy/go.sum b/contrib/terraform-provider-helmproxy/go.sum index 2c53448f70..d646b52ae2 100644 --- a/contrib/terraform-provider-helmproxy/go.sum +++ b/contrib/terraform-provider-helmproxy/go.sum @@ -764,8 +764,8 @@ github.com/kisielk/errcheck v1.6.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.10.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.0/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= -github.com/klauspost/compress v1.15.12 h1:YClS/PImqYbn+UILDnqxQCZ3RehC9N318SU3kElDUEM= -github.com/klauspost/compress v1.15.12/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= +github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= +github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= diff --git a/ethergo/backends/anvil/anvil.go b/ethergo/backends/anvil/anvil.go index f12803f1d5..89f08a3b24 100644 --- a/ethergo/backends/anvil/anvil.go +++ b/ethergo/backends/anvil/anvil.go @@ -135,6 +135,7 @@ func NewAnvilBackend(ctx context.Context, t *testing.T, args *OptionBuilder) *Ba return fmt.Errorf("failed to connect") } + // nolint: staticcheck res, err := rpcClient.ChainID(ctx) if err != nil { return fmt.Errorf("failed to get chain id: %w", err) @@ -263,7 +264,7 @@ func setupOtterscan(ctx context.Context, tb testing.TB, pool *dockertest.Pool, a var logger = log.Logger("anvil-docker") // storeWallets stores preseeded wallets w/ balances. -func (f *Backend) storeWallets(args *OptionBuilder) error { +func (b *Backend) storeWallets(args *OptionBuilder) error { derivationPath := args.GetDerivationPath() derivIter := accounts.DefaultIterator(derivationPath) maxAccounts := args.GetAccounts() @@ -275,7 +276,7 @@ func (f *Backend) storeWallets(args *OptionBuilder) error { return fmt.Errorf("could not get seed phrase: %w", err) } - f.store.Store(walletToKey(f.Backend.T(), wall)) + b.store.Store(walletToKey(b.Backend.T(), wall)) } return nil } @@ -299,31 +300,31 @@ func walletToKey(tb testing.TB, wall wallet.Wallet) *keystore.Key { } // ChainConfig gets the chain config. -func (f *Backend) ChainConfig() *params.ChainConfig { - return f.chainConfig +func (b *Backend) ChainConfig() *params.ChainConfig { + return b.chainConfig } // Signer gets the signer for the chain. -func (f *Backend) Signer() types.Signer { - latestBlock, err := f.BlockNumber(f.Context()) - require.Nil(f.T(), err) +func (b *Backend) Signer() types.Signer { + latestBlock, err := b.BlockNumber(b.Context()) + require.Nil(b.T(), err) - return types.MakeSigner(f.ChainConfig(), new(big.Int).SetUint64(latestBlock)) + return types.MakeSigner(b.ChainConfig(), new(big.Int).SetUint64(latestBlock)) } // FundAccount funds an account with the given amount. -func (f *Backend) FundAccount(ctx context.Context, address common.Address, amount big.Int) { - ctx, cancel := onecontext.Merge(ctx, f.Context()) +func (b *Backend) FundAccount(ctx context.Context, address common.Address, amount big.Int) { + ctx, cancel := onecontext.Merge(ctx, b.Context()) defer cancel() - anvilClient, err := Dial(ctx, f.RPCAddress()) - require.Nilf(f.T(), err, "failed to dial anvil client on chain %d: %v", f.GetChainID(), err) + anvilClient, err := Dial(ctx, b.RPCAddress()) + require.Nilf(b.T(), err, "failed to dial anvil client on chain %d: %v", b.GetChainID(), err) - unlocker := f.fundingMux.Lock(address) + unlocker := b.fundingMux.Lock(address) defer unlocker.Unlock() - prevBalance, err := f.Backend.BalanceAt(ctx, address, nil) - require.Nil(f.T(), err) + prevBalance, err := b.Backend.BalanceAt(ctx, address, nil) + require.Nil(b.T(), err) newBal := new(big.Int).Add(prevBalance, &amount) @@ -338,13 +339,13 @@ func (f *Backend) FundAccount(ctx context.Context, address common.Address, amoun // TODO: this may cause issues when newBal overflows uint64 err = anvilClient.SetBalance(ctx, address, newBal.Uint64()) - require.Nil(f.T(), err) + require.Nil(b.T(), err) } // WaitForConfirmation checks confirmation if the transaction is signed. // nolint: cyclop -func (f *Backend) WaitForConfirmation(ctx context.Context, tx *types.Transaction) { - require.NotNil(f.T(), tx, "tx is nil") +func (b *Backend) WaitForConfirmation(ctx context.Context, tx *types.Transaction) { + require.NotNil(b.T(), tx, "tx is nil") v, r, s := tx.RawSignatureValues() isUnsigned := isZero(v) && isZero(r) && isZero(s) if isUnsigned { @@ -354,7 +355,7 @@ func (f *Backend) WaitForConfirmation(ctx context.Context, tx *types.Transaction return } - f.Backend.WaitForConfirmation(ctx, tx) + b.Backend.WaitForConfirmation(ctx, tx) } func isZero(val *big.Int) bool { @@ -362,40 +363,40 @@ func isZero(val *big.Int) bool { } // GetFundedAccount gets a funded account. -func (f *Backend) GetFundedAccount(ctx context.Context, requestBalance *big.Int) *keystore.Key { - key := f.MockAccount() +func (b *Backend) GetFundedAccount(ctx context.Context, requestBalance *big.Int) *keystore.Key { + key := b.MockAccount() - f.store.Store(key) + b.store.Store(key) - f.FundAccount(ctx, key.Address, *requestBalance) + b.FundAccount(ctx, key.Address, *requestBalance) return key } // GetTxContext gets the tx context for the given address. // TODO: dedupe w/ geth. -func (f *Backend) GetTxContext(ctx context.Context, address *common.Address) (res backends.AuthType) { - ctx, cancel := onecontext.Merge(ctx, f.Context()) +func (b *Backend) GetTxContext(ctx context.Context, address *common.Address) (res backends.AuthType) { + ctx, cancel := onecontext.Merge(ctx, b.Context()) defer cancel() var acct *keystore.Key // TODO handle storing accounts to conform to get tx context if address != nil { - acct = f.store.GetAccount(*address) + acct = b.store.GetAccount(*address) if acct == nil { - f.T().Errorf("could not get account %s", address.String()) + b.T().Errorf("could not get account %s", address.String()) return res } } else { - acct = f.GetFundedAccount(ctx, new(big.Int).SetUint64(math.MaxUint64)) - f.store.Store(acct) + acct = b.GetFundedAccount(ctx, new(big.Int).SetUint64(math.MaxUint64)) + b.store.Store(acct) } - auth, err := f.NewKeyedTransactorFromKey(acct.PrivateKey) - require.Nilf(f.T(), err, "could not get transactor for chain %d: %v", f.GetChainID(), err) + auth, err := b.NewKeyedTransactorFromKey(acct.PrivateKey) + require.Nilf(b.T(), err, "could not get transactor for chain %d: %v", b.GetChainID(), err) - auth.GasPrice, err = f.SuggestGasPrice(ctx) - require.Nilf(f.T(), err, "could not get gas price for chain %d: %v", f.GetChainID(), err) + auth.GasPrice, err = b.SuggestGasPrice(ctx) + require.Nilf(b.T(), err, "could not get gas price for chain %d: %v", b.GetChainID(), err) auth.GasLimit = gasLimit @@ -412,21 +413,21 @@ func (f *Backend) GetTxContext(ctx context.Context, address *common.Address) (re // in the meantime, this may cause race conditions. // // We also print a warning message to the console as an added precaution. -func (f *Backend) ImpersonateAccount(ctx context.Context, address common.Address, transact func(opts *bind.TransactOpts) *types.Transaction) error { - f.impersonationMux.Lock() - defer f.impersonationMux.Unlock() +func (b *Backend) ImpersonateAccount(ctx context.Context, address common.Address, transact func(opts *bind.TransactOpts) *types.Transaction) error { + b.impersonationMux.Lock() + defer b.impersonationMux.Unlock() - f.warnImpersonation() + b.warnImpersonation() - anvilClient, err := Dial(ctx, f.RPCAddress()) - require.Nilf(f.T(), err, "could not dial anvil client rpc at %s for chain %d: %v", f.RPCAddress(), f.GetChainID(), err) + anvilClient, err := Dial(ctx, b.RPCAddress()) + require.Nilf(b.T(), err, "could not dial anvil client rpc at %s for chain %d: %v", b.RPCAddress(), b.GetChainID(), err) err = anvilClient.ImpersonateAccount(ctx, address) - require.Nilf(f.T(), err, "could not impersonate account %s for chain %d: %v", address.String(), f.GetChainID(), err) + require.Nilf(b.T(), err, "could not impersonate account %s for chain %d: %v", address.String(), b.GetChainID(), err) defer func() { err = anvilClient.StopImpersonatingAccount(ctx, address) - require.Nilf(f.T(), err, "could not stop impersonating account %s for chain %d: %v", address.String(), f.GetChainID(), err) + require.Nilf(b.T(), err, "could not stop impersonating account %s for chain %d: %v", address.String(), b.GetChainID(), err) }() tx := transact(&bind.TransactOpts{ @@ -439,14 +440,14 @@ func (f *Backend) ImpersonateAccount(ctx context.Context, address common.Address // TODO: test both legacy and dynamic tx types err = anvilClient.SendUnsignedTransaction(ctx, address, tx) - require.Nilf(f.T(), err, "could not send unsigned transaction for chain %d: %v from %s", f.GetChainID(), err, address.String()) + require.Nilf(b.T(), err, "could not send unsigned transaction for chain %d: %v from %s", b.GetChainID(), err, address.String()) return nil } -func (f *Backend) warnImpersonation() { +func (b *Backend) warnImpersonation() { warnImpersonationOnce.Do(func() { - f.T().Logf(` + b.T().Logf(` Using Account Impersonation. WARNING: This cannot be called concurrently with other impersonation calls. Please make sure your callers are concurrency safe against account impersonation. diff --git a/ethergo/backends/base/base.go b/ethergo/backends/base/base.go index fc3ca85857..e206e152a1 100644 --- a/ethergo/backends/base/base.go +++ b/ethergo/backends/base/base.go @@ -103,6 +103,7 @@ func (b *Backend) EnableTenderly() bool { } // Client fetches an eth client fro the backend. +// nolint: staticcheck func (b *Backend) Client() client.EVMClient { return b.Chain } diff --git a/ethergo/backends/simulated/chain.go b/ethergo/backends/simulated/chain.go index 12ccd7b516..20ff09ba17 100644 --- a/ethergo/backends/simulated/chain.go +++ b/ethergo/backends/simulated/chain.go @@ -134,4 +134,5 @@ func (s Client) SuggestGasPrice(ctx context.Context) (gasPrice *big.Int, err err return big.NewInt(0).Add(estimatedPrice, baseFee), nil } +// nolint: staticcheck var _ client.EVMClient = &Client{} diff --git a/ethergo/chain/chain_impl.go b/ethergo/chain/chain_impl.go index 1f8a5c9229..7d5f62638c 100644 --- a/ethergo/chain/chain_impl.go +++ b/ethergo/chain/chain_impl.go @@ -140,6 +140,7 @@ func NewFromURL(ctx context.Context, url string) (Chain, error) { } // NewFromClient gets a chain from client. +// nolint: staticcheck func NewFromClient(ctx context.Context, config *client.Config, evmClient client.EVMClient) (chain Chain, err error) { rpcURL := "" if len(config.RPCUrl) > 0 { diff --git a/ethergo/client/client.go b/ethergo/client/client.go index 44ff0a9d6b..dce5454319 100644 --- a/ethergo/client/client.go +++ b/ethergo/client/client.go @@ -2,6 +2,8 @@ package client import ( "context" + "encoding/json" + "errors" "fmt" "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi/bind" @@ -96,13 +98,41 @@ func (c *clientImpl) getW3Client() *w3.Client { // BatchWithContext batches multiple w3 calls. func (c *clientImpl) BatchWithContext(ctx context.Context, calls ...w3types.Caller) (err error) { + // Do not create an even if there are no calls + if len(calls) == 0 { + return nil + } + ctx, span := c.tracing.Tracer().Start(ctx, batchAttribute) span.SetAttributes(parseCalls(calls)) span.SetAttributes(attribute.String(endpointAttribute, c.endpoint)) defer func() { + if errors.Is(err, w3.CallErrors{}) { + var batchErr w3.CallErrors + _ = errors.As(err, &batchErr) + for i, callErr := range batchErr { + rawReq, err := calls[i].CreateRequest() + // this already happened, so it can't be failing now. + // just error. + if err != nil { + fmt.Println("could not create request: this should never happen", err) + continue + } + + params, err := json.Marshal(rawReq.Args) + if err != nil { + fmt.Println("could not marshal params: this should never happen", err) + continue + } + span.RecordError(callErr, trace.WithAttributes(attribute.String("method", rawReq.Method), attribute.String("params", string(params)))) + } + metrics.EndSpan(span) + return + } metrics.EndSpanWithErr(span, err) }() + //nolint: wrapcheck return c.getW3Client().CallCtx(ctx, calls...) } diff --git a/ethergo/go.mod b/ethergo/go.mod index 52ccc59ede..7ae67148e3 100644 --- a/ethergo/go.mod +++ b/ethergo/go.mod @@ -117,7 +117,7 @@ require ( github.com/docker/docker v20.10.23+incompatible // indirect github.com/docker/go-connections v0.4.0 // indirect github.com/docker/go-units v0.5.0 // indirect - github.com/dustin/go-humanize v1.0.0 // indirect + github.com/dustin/go-humanize v1.0.1 // indirect github.com/edsrzf/mmap-go v1.0.0 // indirect github.com/emirpasic/gods v1.18.1 // indirect github.com/fatih/color v1.13.0 // indirect diff --git a/ethergo/go.sum b/ethergo/go.sum index dec7a90b79..6e02f1d93d 100644 --- a/ethergo/go.sum +++ b/ethergo/go.sum @@ -329,8 +329,9 @@ github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4 github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dop251/goja v0.0.0-20200219165308-d1232e640a87/go.mod h1:Mw6PkjjMXWbTj+nnj4s3QPXq1jaT0s5pC0iFD4+BOAA= github.com/dop251/goja v0.0.0-20200721192441-a695b0cdd498/go.mod h1:Mw6PkjjMXWbTj+nnj4s3QPXq1jaT0s5pC0iFD4+BOAA= -github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= +github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/dvyukov/go-fuzz v0.0.0-20200318091601-be3528f3a813/go.mod h1:11Gm+ccJnvAhCNLlf5+cS9KjtbaD5I5zaZpFMsTHWTw= github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= diff --git a/ethergo/submitter/chain_queue.go b/ethergo/submitter/chain_queue.go index 503d061315..fd2d5a1e16 100644 --- a/ethergo/submitter/chain_queue.go +++ b/ethergo/submitter/chain_queue.go @@ -2,15 +2,18 @@ package submitter import ( "context" + "errors" "fmt" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/lmittmann/w3" "github.com/lmittmann/w3/module/eth" "github.com/lmittmann/w3/w3types" "github.com/synapsecns/sanguine/core" "github.com/synapsecns/sanguine/core/metrics" "github.com/synapsecns/sanguine/ethergo/client" "github.com/synapsecns/sanguine/ethergo/submitter/db" + "github.com/synapsecns/sanguine/ethergo/util" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" "golang.org/x/sync/errgroup" @@ -44,6 +47,10 @@ func (c *chainQueue) chainIDInt() int { } func (t *txSubmitterImpl) chainPendingQueue(parentCtx context.Context, chainID *big.Int, txes []db.TX) (err error) { + if len(txes) == 0 { + return nil + } + ctx, span := t.metrics.Tracer().Start(parentCtx, "submitter.ChainQueue") defer func() { metrics.EndSpanWithErr(span, err) @@ -85,30 +92,41 @@ func (t *txSubmitterImpl) chainPendingQueue(parentCtx context.Context, chainID * cq.bumpTX(gCtx, tx) } - cq.updateOldTxStatuses(gCtx) + cq.updateOldTxStatuses(gCtx) err = cq.g.Wait() if err != nil { return fmt.Errorf("error in chainPendingQueue: %w", err) } - sort.Slice(cq.reprocessQueue, func(i, j int) bool { - return cq.reprocessQueue[i].Nonce() < cq.reprocessQueue[j].Nonce() - }) - - calls := make([]w3types.Caller, len(cq.reprocessQueue)) - txHashes := make([]common.Hash, len(cq.reprocessQueue)) - for i, tx := range cq.reprocessQueue { - calls[i] = eth.SendTx(tx.Transaction).Returns(&txHashes[i]) - } - - cq.storeAndSubmit(ctx, calls, span) + cq.storeAndSubmit(ctx, span) return nil } // storeAndSubmit stores the txes in the database and submits them to the chain. -func (c *chainQueue) storeAndSubmit(ctx context.Context, calls []w3types.Caller, span trace.Span) { +func (c *chainQueue) storeAndSubmit(ctx context.Context, parentSpan trace.Span) { + sort.Slice(c.reprocessQueue, func(i, j int) bool { + return c.reprocessQueue[i].Nonce() < c.reprocessQueue[j].Nonce() + }) + + calls := make([]w3types.Caller, len(c.reprocessQueue)) + txHashes := make([]common.Hash, len(c.reprocessQueue)) + spanners := make([]trace.Span, len(c.reprocessQueue)) + + for i, tx := range c.reprocessQueue { + _, span := c.metrics.Tracer().Start(ctx, "chainPendingQueue.submit", trace.WithAttributes(util.TxToAttributes(tx.Transaction)...)) + spanners[i] = span + defer func() { + // in case this span doesn't get ended automatically below, end it here. + if span.IsRecording() { + metrics.EndSpan(span) + } + }() + + calls[i] = eth.SendTx(tx.Transaction).Returns(&txHashes[i]) + } + var wg sync.WaitGroup wg.Add(2) @@ -118,25 +136,38 @@ func (c *chainQueue) storeAndSubmit(ctx context.Context, calls []w3types.Caller, defer wg.Done() err := c.db.PutTXS(storeCtx, c.reprocessQueue...) if err != nil { - span.AddEvent("could not store txes", trace.WithAttributes(attribute.String("error", err.Error()))) + parentSpan.AddEvent("could not store txes", trace.WithAttributes(attribute.String("error", err.Error()))) } }() go func() { defer wg.Done() err := c.client.BatchWithContext(ctx, calls...) + + // Optimistically store all transactions as pending in the first goroutine. + // The call is made concurrently in the second goroutine. + // If the second goroutine finishes first, updating the status, + // there's no need to store them as pending, hence the context is canceled early. cancelStore() for i := range c.reprocessQueue { + span := spanners[i] if err != nil { c.reprocessQueue[i].Status = db.FailedSubmit + //nolint: errorlint, forcetypeassert + if callErrs, ok := err.(w3.CallErrors); ok && len(callErrs) > i { + span.RecordError(errors.New(callErrs[i].Error())) + } else if err != nil { + span.RecordError(err) + } } else { c.reprocessQueue[i].Status = db.Submitted } + span.End() } err = c.db.PutTXS(ctx, c.reprocessQueue...) if err != nil { - span.AddEvent("could not store txes", trace.WithAttributes(attribute.String("error", err.Error()))) + parentSpan.AddEvent("could not store txes", trace.WithAttributes(attribute.String("error", err.Error()))) } }() wg.Wait() @@ -209,7 +240,7 @@ func (c *chainQueue) bumpTX(parentCtx context.Context, ogTx db.TX) { return fmt.Errorf("could not sign tx: %w", err) } - span.AddEvent("add to reprocess queue", trace.WithAttributes(txToAttributes(tx)...)) + span.AddEvent("add to reprocess queue", trace.WithAttributes(util.TxToAttributes(tx)...)) c.addToReprocessQueue(db.TX{ Transaction: tx, diff --git a/ethergo/submitter/export_test.go b/ethergo/submitter/export_test.go index 5cdcf3142d..7b768a32d3 100644 --- a/ethergo/submitter/export_test.go +++ b/ethergo/submitter/export_test.go @@ -12,65 +12,6 @@ import ( "github.com/synapsecns/sanguine/ethergo/signer/signer" "github.com/synapsecns/sanguine/ethergo/submitter/config" "github.com/synapsecns/sanguine/ethergo/submitter/db" - "go.opentelemetry.io/otel/attribute" -) - -// CopyTransactOpts exports copyTransactOpts for testing. -func CopyTransactOpts(opts *bind.TransactOpts) *bind.TransactOpts { - return copyTransactOpts(opts) -} - -// NullFieldAttribute is a constant used to test the null field attribute. -// it exports the underlying constant for testing. -const NullFieldAttribute = nullFieldAttribute - -func AddressPtrToString(address *common.Address) string { - return addressPtrToString(address) -} - -// BigPtrToString converts a big.Int pointer to a string. -func BigPtrToString(num *big.Int) string { - return bigPtrToString(num) -} - -// TxToAttributes exports txToAttributes for testing. -func TxToAttributes(transaction *types.Transaction) []attribute.KeyValue { - return txToAttributes(transaction) -} - -// SortTxes exports sortTxesByChainID for testing. -func SortTxes(txs []db.TX) map[uint64][]db.TX { - return sortTxesByChainID(txs) -} - -// GroupTxesByNonce exports groupTxesByNonce for testing. -func GroupTxesByNonce(txs []db.TX) map[uint64][]db.TX { - return groupTxesByNonce(txs) -} - -const ( - // HashAttr exports hashAttr for testing. - HashAttr = hashAttr - // FromAttr exports fromAttr for testing. - FromAttr = fromAttr - // ToAttr exports toAttr for testing. - ToAttr = toAttr - // DataAttr exports dataAttr for testing. - DataAttr = dataAttr - // ValueAttr exports valueAttr for testing. - ValueAttr = valueAttr - // NonceAttr exports nonceAttr for testing. - NonceAttr = nonceAttr - // GasLimitAttr exports gasLimitAttr for testing. - GasLimitAttr = gasLimitAttr - // ChainIDAttr exports chainIDAttr for testing. - ChainIDAttr = chainIDAttr - // GasPriceAttr exports gasPriceAttr for testing. - GasPriceAttr = gasPriceAttr - // GasFeeCapAttr exports gasFeeCapAttr for testing. - GasFeeCapAttr = gasFeeCapAttr - // GasTipCapAttr exports gasTipCapAttr for testing. - GasTipCapAttr = gasTipCapAttr ) // NewTestTransactionSubmitter wraps TestTransactionSubmitter in a TransactionSubmitter interface. @@ -114,3 +55,24 @@ func (t *txSubmitterImpl) GetNonce(parentCtx context.Context, chainID *big.Int, func (t *txSubmitterImpl) CheckAndSetConfirmation(ctx context.Context, chainClient client.EVM, txes []db.TX) error { return t.checkAndSetConfirmation(ctx, chainClient, txes) } + +// SortTxes exports sortTxesByChainID for testing. +func SortTxes(txs []db.TX) map[uint64][]db.TX { + return sortTxesByChainID(txs) +} + +// GroupTxesByNonce exports groupTxesByNonce for testing. +func GroupTxesByNonce(txs []db.TX) map[uint64][]db.TX { + return groupTxesByNonce(txs) +} + +// SetForceNoFallback exports setForceNoFallback for testing. +func SetForceNoFallback(val bool) { + forceNoFallbackIfZero = val +} + +// export for testing +// Warning! Changing this value will not change the underlying value! +// htis is exported for testing to allow a return to underlying value after the test +// TODO: consider doing a SetForTest +var ForceNoFallbackIfZero = forceNoFallbackIfZero diff --git a/ethergo/submitter/submitter.go b/ethergo/submitter/submitter.go index 03b23291c8..11af4adc5d 100644 --- a/ethergo/submitter/submitter.go +++ b/ethergo/submitter/submitter.go @@ -4,7 +4,10 @@ import ( "context" "errors" "fmt" + "github.com/ethereum/go-ethereum/params" "github.com/puzpuzpuz/xsync/v2" + "github.com/synapsecns/sanguine/ethergo/chain/gas/backend" + "github.com/synapsecns/sanguine/ethergo/chain/gas/london" "math" "math/big" "reflect" @@ -213,7 +216,7 @@ func (t *txSubmitterImpl) getNonce(parentCtx context.Context, chainID *big.Int, func (t *txSubmitterImpl) storeTX(ctx context.Context, tx *types.Transaction, status db.Status) (err error) { ctx, span := t.metrics.Tracer().Start(ctx, "submitter.StoreTX", trace.WithAttributes( - append(txToAttributes(tx), attribute.String("status", status.String()))...)) + append(util.TxToAttributes(tx), attribute.String("status", status.String()))...)) defer func() { metrics.EndSpanWithErr(span, err) @@ -271,7 +274,7 @@ func (t *txSubmitterImpl) SubmitTransaction(parentCtx context.Context, chainID * } // then we copy the transactor, this is the one we'll modify w/ no send. - transactor := copyTransactOpts(parentTransactor) + transactor := util.CopyTransactOpts(parentTransactor) var locker mapmutex.Unlocker @@ -362,7 +365,8 @@ func (t *txSubmitterImpl) setGasPrice(ctx context.Context, client client.EVM, if t.config.SupportsEIP1559(int(bigChainID.Uint64())) { transactor.GasFeeCap = t.config.GetMaxGasPrice(chainID) - transactor.GasTipCap, err = client.SuggestGasTipCap(ctx) + // only use fallback if no previous tx + transactor.GasTipCap, err = t.SuggestGasTipCap(ctx, client, chainID, prevTx != nil) if err != nil { return fmt.Errorf("could not get gas tip cap: %w", err) } @@ -419,7 +423,7 @@ func (t *txSubmitterImpl) getGasBlock(ctx context.Context, chainClient client.EV if ok { span.AddEvent("could not get gas block; using cached value", trace.WithAttributes( attribute.String("error", err.Error()), - attribute.String("blockNumber", bigPtrToString(gasBlock.Number)), + attribute.String("blockNumber", util.BigPtrToString(gasBlock.Number)), )) } else { return nil, fmt.Errorf("could not get gas block: %w", err) @@ -467,4 +471,89 @@ func (t *txSubmitterImpl) getGasEstimate(ctx context.Context, chainClient client return gasEstimate, nil } +// forceNoFallbackIfZero is used to force no fallback if the tip cap is 0. +var forceNoFallbackIfZero = false + +// TODO: test oracle fallback. +func (t *txSubmitterImpl) SuggestGasTipCap(ctx context.Context, client client.EVM, chainID int, fallbackIfZero bool) (tipCap *big.Int, err error) { + tipCap, err = client.SuggestGasTipCap(ctx) + if err != nil { + return nil, fmt.Errorf("could not get gas tip cap: %w", err) + } + + // note: these ifs can be combined, but I've found the largic hard to parse if they are. + // if tip cap is not zero return + if big.NewInt(0).Cmp(tipCap) != 0 { + return tipCap, nil + } + + // past this point tip cap is 0. + + // if we should force no fallback, return + // this is set for testing. + if forceNoFallbackIfZero { + return tipCap, nil + } + + // if we shouldn't fallback, return + if !fallbackIfZero { + return tipCap, nil + } + + blockHeight, err := client.BlockNumber(ctx) + if err != nil { + return nil, fmt.Errorf("could not get block number: %w", err) + } + + // if on the other hand, fee is 0 we should fallback to our pricer + oracleConfig := gas.GetConfig() + oracleConfig.MaxPrice = core.CopyBigInt(t.config.GetMaxGasPrice(chainID)) + + feeOracle := london.NewFeeOracle(wrappedLondonClient{client, chainID}, blockHeight, oracleConfig) + tipCap, err = feeOracle.SuggestTipCap(ctx) + if err != nil { + return nil, fmt.Errorf("could not get tip cap: %w", err) + } + return tipCap, nil +} + +type wrappedLondonClient struct { + client.EVM + chainID int +} + +// ChainConfig is a fake chain config. +// since wrapped client is only used for makeSigner +// and on london, we just enable everything. +func (w wrappedLondonClient) ChainConfig() *params.ChainConfig { + return ¶ms.ChainConfig{ + ChainID: big.NewInt(int64(w.chainID)), + HomesteadBlock: big.NewInt(0), + DAOForkBlock: big.NewInt(0), + DAOForkSupport: false, + EIP150Block: big.NewInt(0), + EIP150Hash: common.Hash{}, + EIP155Block: big.NewInt(0), + EIP158Block: big.NewInt(0), + ByzantiumBlock: big.NewInt(0), + ConstantinopleBlock: big.NewInt(0), + PetersburgBlock: big.NewInt(0), + IstanbulBlock: big.NewInt(0), + MuirGlacierBlock: big.NewInt(0), + BerlinBlock: big.NewInt(0), + LondonBlock: big.NewInt(0), + ArrowGlacierBlock: big.NewInt(0), + GrayGlacierBlock: big.NewInt(0), + MergeNetsplitBlock: big.NewInt(0), + ShanghaiBlock: big.NewInt(0), + CancunBlock: big.NewInt(0), + TerminalTotalDifficulty: big.NewInt(0), + TerminalTotalDifficultyPassed: false, + Ethash: nil, + Clique: nil, + } +} + +var _ backend.OracleBackendChain = &wrappedLondonClient{} + var _ TransactionSubmitter = &txSubmitterImpl{} diff --git a/ethergo/submitter/suite_test.go b/ethergo/submitter/suite_test.go index d49f25ba8a..01727e1f1e 100644 --- a/ethergo/submitter/suite_test.go +++ b/ethergo/submitter/suite_test.go @@ -119,6 +119,14 @@ func (s *SubmitterSuite) SetupSuite() { }(i, chainID) } wg.Wait() + + // fallback is currently untested. For now we disable it in tests. + // TODO: this should be fixed, or ideally, fallback can be removed. + og := submitter.ForceNoFallbackIfZero + submitter.SetForceNoFallback(true) + s.T().Cleanup(func() { + submitter.SetForceNoFallback(og) + }) } // SetupTest sets up the signer and funds the account with 10 eth on each backend. @@ -201,6 +209,12 @@ func (t *TXSubmitterDBSuite) SetupSuite() { var err error t.metrics, err = metrics.NewByType(t.GetSuiteContext(), buildInfo, metricsHandler) t.Require().NoError(err) + + og := submitter.ForceNoFallbackIfZero + submitter.SetForceNoFallback(true) + t.T().Cleanup(func() { + submitter.SetForceNoFallback(og) + }) } func (t *TXSubmitterDBSuite) SetupTest() { diff --git a/ethergo/submitter/util.go b/ethergo/submitter/util.go index 1df2e13ff8..2ecdf08e5b 100644 --- a/ethergo/submitter/util.go +++ b/ethergo/submitter/util.go @@ -1,108 +1,15 @@ package submitter import ( - "fmt" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/synapsecns/sanguine/core" "github.com/synapsecns/sanguine/ethergo/chain/gas" "github.com/synapsecns/sanguine/ethergo/submitter/db" - "github.com/synapsecns/sanguine/ethergo/util" - "go.opentelemetry.io/otel/attribute" - "math/big" "sort" ) -// copyTransactOpts creates a deep copy of the given TransactOpts struct -// with big ints wrapped in core.CopyBigInt(). -func copyTransactOpts(opts *bind.TransactOpts) *bind.TransactOpts { - copyOpts := &bind.TransactOpts{ - From: opts.From, - Nonce: core.CopyBigInt(opts.Nonce), - Signer: opts.Signer, - Value: core.CopyBigInt(opts.Value), - GasPrice: core.CopyBigInt(opts.GasPrice), - GasFeeCap: core.CopyBigInt(opts.GasFeeCap), - GasTipCap: core.CopyBigInt(opts.GasTipCap), - GasLimit: opts.GasLimit, - Context: opts.Context, - NoSend: opts.NoSend, - } - return copyOpts -} - -const ( - hashAttr = "tx.Hash" - fromAttr = "tx.From" - toAttr = "tx.To" - dataAttr = "tx.Data" - valueAttr = "tx.Value" - nonceAttr = "tx.Nonce" - gasLimitAttr = "tx.GasLimit" - chainIDAttr = "tx.ChainID" - gasPriceAttr = "tx.GasPrice" - gasFeeCapAttr = "tx.GasFeeCap" - gasTipCapAttr = "tx.GasTipCap" -) - -// txToAttributes converts a transaction to a slice of attribute.KeyValue. -func txToAttributes(transaction *types.Transaction) []attribute.KeyValue { - var from string - call, err := util.TxToCall(transaction) - if err != nil { - from = fmt.Sprintf("could not be detected: %v", err) - } else { - from = call.From.Hex() - } - var attributes = []attribute.KeyValue{ - attribute.String(hashAttr, transaction.Hash().Hex()), - attribute.String(fromAttr, from), - attribute.String(toAttr, addressPtrToString(transaction.To())), - attribute.String(dataAttr, fmt.Sprintf("%x", transaction.Data())), - attribute.String(valueAttr, bigPtrToString(transaction.Value())), - // TODO: this could be downcast to int64, but it's unclear how we should handle overflows. - // since this is only for tracing, we can probably ignore it for now. - attribute.Int64(nonceAttr, int64(transaction.Nonce())), - attribute.Int64(gasLimitAttr, int64(transaction.Gas())), - attribute.String(chainIDAttr, bigPtrToString(transaction.ChainId())), - } - - if transaction.Type() == types.LegacyTxType && transaction.GasPrice() != nil { - attributes = append(attributes, attribute.String(gasPriceAttr, bigPtrToString(transaction.GasPrice()))) - } - - if transaction.Type() == types.DynamicFeeTxType && transaction.GasFeeCap() != nil { - attributes = append(attributes, attribute.String(gasFeeCapAttr, bigPtrToString(transaction.GasFeeCap()))) - } - - if transaction.Type() == types.DynamicFeeTxType && transaction.GasTipCap() != nil { - attributes = append(attributes, attribute.String(gasTipCapAttr, bigPtrToString(transaction.GasTipCap()))) - } - - return attributes -} - -const nullFieldAttribute = "null" - -func addressPtrToString(address *common.Address) string { - if address == nil { - return nullFieldAttribute - } - return address.Hex() -} - -func bigPtrToString(num *big.Int) string { - if num == nil { - return nullFieldAttribute - } - return num.String() -} - -// sortTxesByChainID sorts a slice of transactions by nonce. +// sortTxesByChainID sorts a slice of transactions by chain ID and then by nonce within each chain ID group. func sortTxesByChainID(txs []db.TX) map[uint64][]db.TX { - txesByChainID := make(map[uint64][]db.TX) - // put the transactions in a map by chain id + txesByChainID := make(map[uint64][]db.TX) // put the transactions in a map by chain id + for _, t := range txs { txesByChainID[t.ChainId().Uint64()] = append(txesByChainID[t.ChainId().Uint64()], t) } diff --git a/ethergo/submitter/util_test.go b/ethergo/submitter/util_test.go index dc4b0a4d99..d722b98260 100644 --- a/ethergo/submitter/util_test.go +++ b/ethergo/submitter/util_test.go @@ -1,197 +1,21 @@ package submitter_test import ( - "context" "fmt" - "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/accounts/keystore" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/google/go-cmp/cmp" - "github.com/synapsecns/sanguine/core" - "github.com/synapsecns/sanguine/core/testsuite" + "github.com/stretchr/testify/assert" "github.com/synapsecns/sanguine/ethergo/backends/simulated" "github.com/synapsecns/sanguine/ethergo/mocks" "github.com/synapsecns/sanguine/ethergo/submitter" "github.com/synapsecns/sanguine/ethergo/submitter/db" "github.com/synapsecns/sanguine/ethergo/util" - "go.opentelemetry.io/otel/attribute" - "gotest.tools/assert" "math/big" "math/rand" "sync" - "testing" "time" ) -func TestCopyTransactOpts(t *testing.T) { - // Test case 1: All fields populated - opts1 := &bind.TransactOpts{ - From: common.HexToAddress("0x1234567890123456789012345678901234567890"), - Nonce: big.NewInt(1), - Signer: nil, - Value: big.NewInt(100), - GasPrice: big.NewInt(200), - GasFeeCap: big.NewInt(300), - GasTipCap: big.NewInt(400), - GasLimit: 500, - Context: context.Background(), - NoSend: true, - } - - copyOpts1 := submitter.CopyTransactOpts(opts1) - assertTransactOptsEquality(t, opts1, copyOpts1) - - // Test case 2: Some fields populated, others nil - opts2 := &bind.TransactOpts{ - Nonce: nil, - Signer: nil, - Value: nil, - GasPrice: nil, - GasFeeCap: big.NewInt(300), - GasTipCap: big.NewInt(400), - GasLimit: 500, - Context: context.Background(), - NoSend: true, - } - - copyOpts2 := submitter.CopyTransactOpts(opts2) - assertTransactOptsEquality(t, opts2, copyOpts2) - - // Test case 3: All fields nil - opts3 := &bind.TransactOpts{ - Nonce: nil, - Signer: nil, - Value: nil, - GasPrice: nil, - GasFeeCap: nil, - GasTipCap: nil, - GasLimit: 0, - Context: nil, - NoSend: true, - } - - copyOpts3 := submitter.CopyTransactOpts(opts3) - assertTransactOptsEquality(t, opts3, copyOpts3) -} - -func assertTransactOptsEquality(tb testing.TB, toA, toB *bind.TransactOpts) { - tb.Helper() - // Check that the pointer values of the big integer fields are different - assertBigIntsCopiedEqual(tb, toA.Nonce, toB.Nonce, "Nonce") - assertBigIntsCopiedEqual(tb, toA.Value, toB.Value, "Value") - assertBigIntsCopiedEqual(tb, toA.GasPrice, toB.GasPrice, "GasPrice") - assertBigIntsCopiedEqual(tb, toA.GasFeeCap, toB.GasFeeCap, "GasFeeCap") - assertBigIntsCopiedEqual(tb, toA.GasTipCap, toB.GasTipCap, "GasFeeCap") - assert.DeepEqual(tb, toA, toB, testsuite.BigIntComparer(), cmp.AllowUnexported(context.Background())) -} - -// assertBigIntsCopiedEqual checks that the given big.Ints are equal and that -// they have different pointers. -func assertBigIntsCopiedEqual(tb testing.TB, original *big.Int, newVal *big.Int, fieldName string) { - tb.Helper() - if original == nil && newVal == nil { - return - } - - if core.ArePointersEqual(original, newVal) { - tb.Errorf("%s has same pointer as original", fieldName) - } - - if original.Cmp(newVal) != 0 { - tb.Errorf("%s is not equal", fieldName) - } -} - -func TestAddressPtrToString(t *testing.T) { - // Test case 1: Address is nil - var address *common.Address - assert.Equal(t, submitter.AddressPtrToString(address), submitter.NullFieldAttribute) - - // Test case 2: Address is not nil - address = core.PtrTo[common.Address](common.HexToAddress("0x1234567890123456789012345678901234567890")) - assert.Equal(t, submitter.AddressPtrToString(address), "0x1234567890123456789012345678901234567890") -} - -func TestBigPtrToString(t *testing.T) { - // Test case: num is nil - var num *big.Int - expected := submitter.NullFieldAttribute - result := submitter.BigPtrToString(num) - if result != expected { - t.Errorf("bigPtrToString(nil) = %q; want %q", result, expected) - } - - // Test case: num is an integer - num = big.NewInt(123) - expected = "123" - result = submitter.BigPtrToString(num) - if result != expected { - t.Errorf("bigPtrToString(123) = %q; want %q", result, expected) - } -} - -func (s *SubmitterSuite) TestTxToAttributesNullFields() { - s.checkEmptyTx(types.NewTx(&types.DynamicFeeTx{})) - s.checkEmptyTx(types.NewTx(&types.LegacyTx{})) -} - -func (s *SubmitterSuite) checkEmptyTx(rawTx *types.Transaction) { - tx := makeAttrMap(rawTx) - - s.Require().Equal(tx[submitter.HashAttr].AsString(), rawTx.Hash().Hex()) - s.Require().Equal(tx[submitter.NonceAttr].AsInt64(), int64(0)) - s.Require().Equal(tx[submitter.GasLimitAttr].AsInt64(), int64(0)) - s.Require().Equal(tx[submitter.ToAttr].AsString(), submitter.NullFieldAttribute) - s.Require().Equal(tx[submitter.ValueAttr].AsString(), "0") - s.Require().Equal(tx[submitter.DataAttr].AsString(), "") - - if rawTx.Type() == types.DynamicFeeTxType { - s.Require().Equal(tx[submitter.GasTipCapAttr].AsString(), "0") - s.Require().Equal(tx[submitter.GasFeeCapAttr].AsString(), "0") - } - if rawTx.Type() == types.LegacyTxType { - s.Require().Equal(tx[submitter.GasPriceAttr].AsString(), "0") - } -} - -func (s *SubmitterSuite) TestTxToAttributesLegacyTX() { - mockTX := mocks.GetMockTxes(s.GetTestContext(), s.T(), 1, types.LegacyTxType)[0] - mapAttr := makeAttrMap(mockTX) - - s.Require().Equal(mapAttr[submitter.HashAttr].AsString(), mockTX.Hash().String()) - s.Require().Equal(mapAttr[submitter.NonceAttr].AsInt64(), int64(mockTX.Nonce())) - s.Require().Equal(mapAttr[submitter.GasLimitAttr].AsInt64(), int64(mockTX.Gas())) - s.Require().Equal(mapAttr[submitter.ToAttr].AsString(), mockTX.To().String()) - s.Require().Equal(mapAttr[submitter.ValueAttr].AsString(), mockTX.Value().String()) - s.Require().Equal(mapAttr[submitter.DataAttr].AsString(), "") - - s.Require().Equal(mapAttr[submitter.GasPriceAttr].AsString(), mockTX.GasPrice().String()) - _, hasFeeCap := mapAttr[submitter.GasFeeCapAttr] - _, hasTipCap := mapAttr[submitter.GasTipCapAttr] - s.Require().False(hasFeeCap) - s.Require().False(hasTipCap) - s.Require().NotNil(mapAttr[submitter.FromAttr]) -} - -func (s *SubmitterSuite) TestTxToAttributesDynamicTX() { - mockTX := mocks.GetMockTxes(s.GetTestContext(), s.T(), 1, types.DynamicFeeTxType)[0] - mapAttr := makeAttrMap(mockTX) - - s.Require().Equal(mapAttr[submitter.HashAttr].AsString(), mockTX.Hash().String()) - s.Require().Equal(mapAttr[submitter.NonceAttr].AsInt64(), int64(mockTX.Nonce())) - s.Require().Equal(mapAttr[submitter.GasLimitAttr].AsInt64(), int64(mockTX.Gas())) - s.Require().Equal(mapAttr[submitter.ToAttr].AsString(), mockTX.To().String()) - s.Require().Equal(mapAttr[submitter.ValueAttr].AsString(), mockTX.Value().String()) - s.Require().Equal(mapAttr[submitter.DataAttr].AsString(), "") - - s.Require().Equal(mapAttr[submitter.GasFeeCapAttr].AsString(), mockTX.GasFeeCap().String()) - s.Require().Equal(mapAttr[submitter.GasTipCapAttr].AsString(), mockTX.GasTipCap().String()) - _, hasGasPrice := mapAttr[submitter.GasPriceAttr] - s.Require().False(hasGasPrice) - s.Require().NotNil(mapAttr[submitter.FromAttr]) -} - func (s *SubmitterSuite) TestSortTxes() { expected := make(map[uint64][]*types.Transaction) var allTxes []db.TX @@ -274,12 +98,3 @@ func (s *SubmitterSuite) TestGroupTxesByNonce() { } } } - -func makeAttrMap(tx *types.Transaction) map[string]attribute.Value { - mapAttr := make(map[string]attribute.Value) - attr := submitter.TxToAttributes(tx) - for _, a := range attr { - mapAttr[string(a.Key)] = a.Value - } - return mapAttr -} diff --git a/ethergo/util/export_test.go b/ethergo/util/export_test.go index cb7255c762..fc357be3ab 100644 --- a/ethergo/util/export_test.go +++ b/ethergo/util/export_test.go @@ -1,6 +1,9 @@ package util -import "math/big" +import ( + "github.com/ethereum/go-ethereum/common" + "math/big" +) func MakeOptions(options ...CopyOption) TestCopyOptions { return makeOptions(options...) @@ -37,3 +40,36 @@ func (c copyOptions) GasTipCap() *big.Int { func (c copyOptions) TxType() *uint8 { return c.txType } + +// NullFieldAttribute is a constant used to test the null field attribute. +// it exports the underlying constant for testing. +const NullFieldAttribute = nullFieldAttribute + +func AddressPtrToString(address *common.Address) string { + return addressPtrToString(address) +} + +const ( + // HashAttr exports hashAttr for testing. + HashAttr = hashAttr + // FromAttr exports fromAttr for testing. + FromAttr = fromAttr + // ToAttr exports toAttr for testing. + ToAttr = toAttr + // DataAttr exports dataAttr for testing. + DataAttr = dataAttr + // ValueAttr exports valueAttr for testing. + ValueAttr = valueAttr + // NonceAttr exports nonceAttr for testing. + NonceAttr = nonceAttr + // GasLimitAttr exports gasLimitAttr for testing. + GasLimitAttr = gasLimitAttr + // ChainIDAttr exports chainIDAttr for testing. + ChainIDAttr = chainIDAttr + // GasPriceAttr exports gasPriceAttr for testing. + GasPriceAttr = gasPriceAttr + // GasFeeCapAttr exports gasFeeCapAttr for testing. + GasFeeCapAttr = gasFeeCapAttr + // GasTipCapAttr exports gasTipCapAttr for testing. + GasTipCapAttr = gasTipCapAttr +) diff --git a/ethergo/util/transactor.go b/ethergo/util/transactor.go new file mode 100644 index 0000000000..7aaf7902e2 --- /dev/null +++ b/ethergo/util/transactor.go @@ -0,0 +1,97 @@ +package util + +import ( + "fmt" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/synapsecns/sanguine/core" + "go.opentelemetry.io/otel/attribute" + "math/big" +) + +// CopyTransactOpts creates a deep copy of the given TransactOpts struct +// with big ints wrapped in core.CopyBigInt(). +func CopyTransactOpts(opts *bind.TransactOpts) *bind.TransactOpts { + copyOpts := &bind.TransactOpts{ + From: opts.From, + Nonce: core.CopyBigInt(opts.Nonce), + Signer: opts.Signer, + Value: core.CopyBigInt(opts.Value), + GasPrice: core.CopyBigInt(opts.GasPrice), + GasFeeCap: core.CopyBigInt(opts.GasFeeCap), + GasTipCap: core.CopyBigInt(opts.GasTipCap), + GasLimit: opts.GasLimit, + Context: opts.Context, + NoSend: opts.NoSend, + } + return copyOpts +} + +const ( + hashAttr = "tx.Hash" + fromAttr = "tx.From" + toAttr = "tx.To" + dataAttr = "tx.Data" + valueAttr = "tx.Value" + nonceAttr = "tx.Nonce" + gasLimitAttr = "tx.GasLimit" + chainIDAttr = "tx.ChainID" + gasPriceAttr = "tx.GasPrice" + gasFeeCapAttr = "tx.GasFeeCap" + gasTipCapAttr = "tx.GasTipCap" +) + +// TxToAttributes converts a transaction to a slice of attribute.KeyValue. +func TxToAttributes(transaction *types.Transaction) []attribute.KeyValue { + var from string + call, err := TxToCall(transaction) + if err != nil { + from = fmt.Sprintf("could not be detected: %v", err) + } else { + from = call.From.Hex() + } + var attributes = []attribute.KeyValue{ + attribute.String(hashAttr, transaction.Hash().Hex()), + attribute.String(fromAttr, from), + attribute.String(toAttr, addressPtrToString(transaction.To())), + attribute.String(dataAttr, fmt.Sprintf("%x", transaction.Data())), + attribute.String(valueAttr, BigPtrToString(transaction.Value())), + // TODO: this could be downcast to int64, but it's unclear how we should handle overflows. + // since this is only for tracing, we can probably ignore it for now. + attribute.Int64(nonceAttr, int64(transaction.Nonce())), + attribute.Int64(gasLimitAttr, int64(transaction.Gas())), + attribute.String(chainIDAttr, BigPtrToString(transaction.ChainId())), + } + + if transaction.Type() == types.LegacyTxType && transaction.GasPrice() != nil { + attributes = append(attributes, attribute.String(gasPriceAttr, BigPtrToString(transaction.GasPrice()))) + } + + if transaction.Type() == types.DynamicFeeTxType && transaction.GasFeeCap() != nil { + attributes = append(attributes, attribute.String(gasFeeCapAttr, BigPtrToString(transaction.GasFeeCap()))) + } + + if transaction.Type() == types.DynamicFeeTxType && transaction.GasTipCap() != nil { + attributes = append(attributes, attribute.String(gasTipCapAttr, BigPtrToString(transaction.GasTipCap()))) + } + + return attributes +} + +const nullFieldAttribute = "null" + +func addressPtrToString(address *common.Address) string { + if address == nil { + return nullFieldAttribute + } + return address.Hex() +} + +// BigPtrToString converts a big.Int pointer to a string. +func BigPtrToString(num *big.Int) string { + if num == nil { + return nullFieldAttribute + } + return num.String() +} diff --git a/ethergo/util/transactor_test.go b/ethergo/util/transactor_test.go new file mode 100644 index 0000000000..9b370cd0be --- /dev/null +++ b/ethergo/util/transactor_test.go @@ -0,0 +1,194 @@ +package util_test + +import ( + "context" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/google/go-cmp/cmp" + "github.com/synapsecns/sanguine/core" + "github.com/synapsecns/sanguine/core/testsuite" + "github.com/synapsecns/sanguine/ethergo/mocks" + "github.com/synapsecns/sanguine/ethergo/util" + "go.opentelemetry.io/otel/attribute" + "gotest.tools/assert" + "math/big" + "testing" +) + +func TestCopyTransactOpts(t *testing.T) { + // Test case 1: All fields populated + opts1 := &bind.TransactOpts{ + From: common.HexToAddress("0x1234567890123456789012345678901234567890"), + Nonce: big.NewInt(1), + Signer: nil, + Value: big.NewInt(100), + GasPrice: big.NewInt(200), + GasFeeCap: big.NewInt(300), + GasTipCap: big.NewInt(400), + GasLimit: 500, + Context: context.Background(), + NoSend: true, + } + + copyOpts1 := util.CopyTransactOpts(opts1) + assertTransactOptsEquality(t, opts1, copyOpts1) + + // Test case 2: Some fields populated, others nil + opts2 := &bind.TransactOpts{ + Nonce: nil, + Signer: nil, + Value: nil, + GasPrice: nil, + GasFeeCap: big.NewInt(300), + GasTipCap: big.NewInt(400), + GasLimit: 500, + Context: context.Background(), + NoSend: true, + } + + copyOpts2 := util.CopyTransactOpts(opts2) + assertTransactOptsEquality(t, opts2, copyOpts2) + + // Test case 3: All fields nil + opts3 := &bind.TransactOpts{ + Nonce: nil, + Signer: nil, + Value: nil, + GasPrice: nil, + GasFeeCap: nil, + GasTipCap: nil, + GasLimit: 0, + Context: nil, + NoSend: true, + } + + copyOpts3 := util.CopyTransactOpts(opts3) + assertTransactOptsEquality(t, opts3, copyOpts3) +} + +func assertTransactOptsEquality(tb testing.TB, toA, toB *bind.TransactOpts) { + tb.Helper() + // Check that the pointer values of the big integer fields are different + assertBigIntsCopiedEqual(tb, toA.Nonce, toB.Nonce, "Nonce") + assertBigIntsCopiedEqual(tb, toA.Value, toB.Value, "Value") + assertBigIntsCopiedEqual(tb, toA.GasPrice, toB.GasPrice, "GasPrice") + assertBigIntsCopiedEqual(tb, toA.GasFeeCap, toB.GasFeeCap, "GasFeeCap") + assertBigIntsCopiedEqual(tb, toA.GasTipCap, toB.GasTipCap, "GasTipCap") + assert.DeepEqual(tb, toA, toB, testsuite.BigIntComparer(), cmp.AllowUnexported(context.Background())) +} + +// assertBigIntsCopiedEqual checks that the given big.Ints are equal and that +// they have different pointers. +func assertBigIntsCopiedEqual(tb testing.TB, original *big.Int, newVal *big.Int, fieldName string) { + tb.Helper() + if original == nil && newVal == nil { + return + } + + if core.ArePointersEqual(original, newVal) { + tb.Errorf("%s has same pointer as original", fieldName) + } + + if original.Cmp(newVal) != 0 { + tb.Errorf("%s is not equal", fieldName) + } +} + +func TestAddressPtrToString(t *testing.T) { + // Test case 1: Address is nil + var address *common.Address + assert.Equal(t, util.AddressPtrToString(address), util.NullFieldAttribute) + + // Test case 2: Address is not nil + address = core.PtrTo[common.Address](common.HexToAddress("0x1234567890123456789012345678901234567890")) + assert.Equal(t, util.AddressPtrToString(address), "0x1234567890123456789012345678901234567890") +} + +func TestBigPtrToString(t *testing.T) { + // Test case: num is nil + var num *big.Int + expected := util.NullFieldAttribute + result := util.BigPtrToString(num) + if result != expected { + t.Errorf("BigPtrToString(nil) = %q; want %q", result, expected) + } + + // Test case: num is an integer + num = big.NewInt(123) + expected = "123" + result = util.BigPtrToString(num) + if result != expected { + t.Errorf("BigPtrToString(123) = %q; want %q", result, expected) + } +} + +func (s *UtilSuite) TestTxToAttributesNullFields() { + s.checkEmptyTx(types.NewTx(&types.DynamicFeeTx{})) + s.checkEmptyTx(types.NewTx(&types.LegacyTx{})) +} + +func (s *UtilSuite) checkEmptyTx(rawTx *types.Transaction) { + tx := makeAttrMap(rawTx) + + s.Require().Equal(tx[util.HashAttr].AsString(), rawTx.Hash().Hex()) + s.Require().Equal(tx[util.NonceAttr].AsInt64(), int64(0)) + s.Require().Equal(tx[util.GasLimitAttr].AsInt64(), int64(0)) + s.Require().Equal(tx[util.ToAttr].AsString(), util.NullFieldAttribute) + s.Require().Equal(tx[util.ValueAttr].AsString(), "0") + s.Require().Equal(tx[util.DataAttr].AsString(), "") + + if rawTx.Type() == types.DynamicFeeTxType { + s.Require().Equal(tx[util.GasTipCapAttr].AsString(), "0") + s.Require().Equal(tx[util.GasFeeCapAttr].AsString(), "0") + } + if rawTx.Type() == types.LegacyTxType { + s.Require().Equal(tx[util.GasPriceAttr].AsString(), "0") + } +} + +func (s *UtilSuite) TestTxToAttributesLegacyTX() { + mockTX := mocks.GetMockTxes(s.GetTestContext(), s.T(), 1, types.LegacyTxType)[0] + mapAttr := makeAttrMap(mockTX) + + s.Require().Equal(mapAttr[util.HashAttr].AsString(), mockTX.Hash().String()) + s.Require().Equal(mapAttr[util.NonceAttr].AsInt64(), int64(mockTX.Nonce())) + s.Require().Equal(mapAttr[util.GasLimitAttr].AsInt64(), int64(mockTX.Gas())) + s.Require().Equal(mapAttr[util.ToAttr].AsString(), mockTX.To().String()) + s.Require().Equal(mapAttr[util.ValueAttr].AsString(), mockTX.Value().String()) + s.Require().Equal(mapAttr[util.DataAttr].AsString(), "") + + s.Require().Equal(mapAttr[util.GasPriceAttr].AsString(), mockTX.GasPrice().String()) + _, hasFeeCap := mapAttr[util.GasFeeCapAttr] + _, hasTipCap := mapAttr[util.GasTipCapAttr] + s.Require().False(hasFeeCap) + s.Require().False(hasTipCap) + s.Require().NotNil(mapAttr[util.FromAttr]) +} + +func (s *UtilSuite) TestTxToAttributesDynamicTX() { + mockTX := mocks.GetMockTxes(s.GetTestContext(), s.T(), 1, types.DynamicFeeTxType)[0] + mapAttr := makeAttrMap(mockTX) + + s.Require().Equal(mapAttr[util.HashAttr].AsString(), mockTX.Hash().String()) + s.Require().Equal(mapAttr[util.NonceAttr].AsInt64(), int64(mockTX.Nonce())) + s.Require().Equal(mapAttr[util.GasLimitAttr].AsInt64(), int64(mockTX.Gas())) + s.Require().Equal(mapAttr[util.ToAttr].AsString(), mockTX.To().String()) + s.Require().Equal(mapAttr[util.ValueAttr].AsString(), mockTX.Value().String()) + s.Require().Equal(mapAttr[util.DataAttr].AsString(), "") + + s.Require().Equal(mapAttr[util.GasFeeCapAttr].AsString(), mockTX.GasFeeCap().String()) + s.Require().Equal(mapAttr[util.GasTipCapAttr].AsString(), mockTX.GasTipCap().String()) + _, hasGasPrice := mapAttr[util.GasPriceAttr] + s.Require().False(hasGasPrice) + s.Require().NotNil(mapAttr[util.FromAttr]) +} + +func makeAttrMap(tx *types.Transaction) map[string]attribute.Value { + mapAttr := make(map[string]attribute.Value) + attr := util.TxToAttributes(tx) + for _, a := range attr { + mapAttr[string(a.Key)] = a.Value + } + return mapAttr +} diff --git a/services/cctp-relayer/go.mod b/services/cctp-relayer/go.mod index acbf3a3e2f..eb96f3af01 100644 --- a/services/cctp-relayer/go.mod +++ b/services/cctp-relayer/go.mod @@ -47,7 +47,7 @@ require ( github.com/VictoriaMetrics/fastcache v1.6.0 // indirect github.com/acomagu/bufpipe v1.0.4 // indirect github.com/agnivade/levenshtein v1.1.1 // indirect - github.com/andybalholm/brotli v1.0.4 // indirect + github.com/andybalholm/brotli v1.0.5 // indirect github.com/aws/aws-sdk-go-v2 v1.18.0 // indirect github.com/aws/aws-sdk-go-v2/config v1.18.21 // indirect github.com/aws/aws-sdk-go-v2/credentials v1.13.20 // indirect @@ -168,7 +168,7 @@ require ( github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a // indirect github.com/keep-network/keep-common v1.7.1-0.20211012131917-7102d7b9c6a0 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect - github.com/klauspost/compress v1.15.12 // indirect + github.com/klauspost/compress v1.16.0 // indirect github.com/klauspost/cpuid/v2 v2.2.4 // indirect github.com/leodido/go-urn v1.2.4 // indirect github.com/lmittmann/w3 v0.10.0 // indirect diff --git a/services/cctp-relayer/go.sum b/services/cctp-relayer/go.sum index 95cb711ae1..c8bbce7d91 100644 --- a/services/cctp-relayer/go.sum +++ b/services/cctp-relayer/go.sum @@ -134,8 +134,9 @@ github.com/allegro/bigcache v1.2.1 h1:hg1sY1raCwic3Vnsvje6TT7/pnZba83LeFck5NrFKS github.com/allegro/bigcache v1.2.1/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= -github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY= github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= +github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= +github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= @@ -774,8 +775,8 @@ github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6 github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.15.0/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= -github.com/klauspost/compress v1.15.12 h1:YClS/PImqYbn+UILDnqxQCZ3RehC9N318SU3kElDUEM= -github.com/klauspost/compress v1.15.12/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= +github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= +github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= diff --git a/services/omnirpc/go.mod b/services/omnirpc/go.mod index 0bc01d8863..fa2aaf3f6c 100644 --- a/services/omnirpc/go.mod +++ b/services/omnirpc/go.mod @@ -59,7 +59,7 @@ require ( github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95 // indirect github.com/VictoriaMetrics/fastcache v1.6.0 // indirect github.com/acomagu/bufpipe v1.0.4 // indirect - github.com/andybalholm/brotli v1.0.4 // indirect + github.com/andybalholm/brotli v1.0.5 // indirect github.com/badoux/checkmail v0.0.0-20181210160741-9661bd69e9ad // indirect github.com/benbjohnson/immutable v0.4.3 // indirect github.com/beorn7/perks v1.0.1 // indirect @@ -150,7 +150,7 @@ require ( github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a // indirect github.com/keep-network/keep-common v1.7.1-0.20211012131917-7102d7b9c6a0 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect - github.com/klauspost/compress v1.15.12 // indirect + github.com/klauspost/compress v1.16.0 // indirect github.com/klauspost/cpuid/v2 v2.2.4 // indirect github.com/leodido/go-urn v1.2.4 // indirect github.com/logrusorgru/aurora v2.0.3+incompatible // indirect diff --git a/services/omnirpc/go.sum b/services/omnirpc/go.sum index e9cff36b12..2fa4cdfdca 100644 --- a/services/omnirpc/go.sum +++ b/services/omnirpc/go.sum @@ -116,8 +116,9 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax github.com/allegro/bigcache v1.2.1 h1:hg1sY1raCwic3Vnsvje6TT7/pnZba83LeFck5NrFKSc= github.com/allegro/bigcache v1.2.1/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= -github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY= github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= +github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= +github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= @@ -706,8 +707,8 @@ github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6 github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.15.0/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= -github.com/klauspost/compress v1.15.12 h1:YClS/PImqYbn+UILDnqxQCZ3RehC9N318SU3kElDUEM= -github.com/klauspost/compress v1.15.12/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= +github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= +github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= diff --git a/services/scribe/go.mod b/services/scribe/go.mod index ba81b355da..51d7e2b236 100644 --- a/services/scribe/go.mod +++ b/services/scribe/go.mod @@ -83,7 +83,7 @@ require ( github.com/acomagu/bufpipe v1.0.4 // indirect github.com/agnivade/levenshtein v1.1.1 // indirect github.com/alecthomas/chroma v0.7.1 // indirect - github.com/andybalholm/brotli v1.0.4 // indirect + github.com/andybalholm/brotli v1.0.5 // indirect github.com/badoux/checkmail v0.0.0-20181210160741-9661bd69e9ad // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/briandowns/spinner v1.6.1 // indirect @@ -185,7 +185,7 @@ require ( github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a // indirect github.com/keep-network/keep-common v1.7.1-0.20211012131917-7102d7b9c6a0 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect - github.com/klauspost/compress v1.15.12 // indirect + github.com/klauspost/compress v1.16.0 // indirect github.com/klauspost/cpuid/v2 v2.2.4 // indirect github.com/kyokomi/emoji/v2 v2.2.8 // indirect github.com/leodido/go-urn v1.2.4 // indirect diff --git a/services/scribe/go.sum b/services/scribe/go.sum index cc7aa9b484..faeba00347 100644 --- a/services/scribe/go.sum +++ b/services/scribe/go.sum @@ -139,8 +139,9 @@ github.com/allegro/bigcache v1.2.1 h1:hg1sY1raCwic3Vnsvje6TT7/pnZba83LeFck5NrFKS github.com/allegro/bigcache v1.2.1/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= -github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY= github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= +github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= +github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= @@ -752,8 +753,8 @@ github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6 github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.15.0/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= -github.com/klauspost/compress v1.15.12 h1:YClS/PImqYbn+UILDnqxQCZ3RehC9N318SU3kElDUEM= -github.com/klauspost/compress v1.15.12/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= +github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= +github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= diff --git a/services/sinner/go.mod b/services/sinner/go.mod index 2786cbfb24..1d44c975a0 100644 --- a/services/sinner/go.mod +++ b/services/sinner/go.mod @@ -71,7 +71,7 @@ require ( github.com/alecthomas/chroma v0.7.1 // indirect github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721 // indirect github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897 // indirect - github.com/andybalholm/brotli v1.0.4 // indirect + github.com/andybalholm/brotli v1.0.5 // indirect github.com/aws/aws-sdk-go-v2 v1.18.0 // indirect github.com/aws/aws-sdk-go-v2/config v1.18.21 // indirect github.com/aws/aws-sdk-go-v2/credentials v1.13.20 // indirect @@ -195,7 +195,7 @@ require ( github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a // indirect github.com/keep-network/keep-common v1.7.1-0.20211012131917-7102d7b9c6a0 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect - github.com/klauspost/compress v1.15.12 // indirect + github.com/klauspost/compress v1.16.0 // indirect github.com/klauspost/cpuid/v2 v2.2.4 // indirect github.com/kyokomi/emoji/v2 v2.2.8 // indirect github.com/leodido/go-urn v1.2.4 // indirect diff --git a/services/sinner/go.sum b/services/sinner/go.sum index e891a409b9..46a5e3e5a2 100644 --- a/services/sinner/go.sum +++ b/services/sinner/go.sum @@ -146,8 +146,9 @@ github.com/allegro/bigcache v1.2.1 h1:hg1sY1raCwic3Vnsvje6TT7/pnZba83LeFck5NrFKS github.com/allegro/bigcache v1.2.1/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= -github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY= github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= +github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= +github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= @@ -809,8 +810,8 @@ github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6 github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.15.0/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= -github.com/klauspost/compress v1.15.12 h1:YClS/PImqYbn+UILDnqxQCZ3RehC9N318SU3kElDUEM= -github.com/klauspost/compress v1.15.12/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= +github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= +github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= From 09bd330a40a18ab80d534d2a462a25a6daabdc78 Mon Sep 17 00:00:00 2001 From: trajan0x <83933037+trajan0x@users.noreply.github.com> Date: Thu, 21 Dec 2023 07:55:54 +0100 Subject: [PATCH 06/29] remove tunnel functionality (#1688) Co-authored-by: Trajan0x --- core/go.mod | 6 +- core/go.sum | 8 - core/tunnel/internal/check.go | 41 ----- core/tunnel/internal/internal.go | 2 - core/tunnel/internal/proxy.go | 44 ----- core/tunnel/internal/proxy_test.go | 7 - core/tunnel/moe/doc.go | 8 - core/tunnel/moe/export_test.go | 14 -- core/tunnel/moe/moe.go | 110 ------------- core/tunnel/moe/ssh.go | 255 ----------------------------- core/tunnel/moe/ssh_test.go | 57 ------- core/tunnel/ngrok/doc.go | 2 - core/tunnel/ngrok/ngrok.go | 85 ---------- core/tunnel/options.go | 51 ------ core/tunnel/provider.go | 13 -- core/tunnel/provider_string.go | 25 --- core/tunnel/suite_test.go | 86 ---------- core/tunnel/tunnel.go | 32 ---- core/tunnel/tunnel_test.go | 84 ---------- core/tunnel/types/provider.go | 12 -- 20 files changed, 1 insertion(+), 941 deletions(-) delete mode 100644 core/tunnel/internal/check.go delete mode 100644 core/tunnel/internal/internal.go delete mode 100644 core/tunnel/internal/proxy.go delete mode 100644 core/tunnel/internal/proxy_test.go delete mode 100644 core/tunnel/moe/doc.go delete mode 100644 core/tunnel/moe/export_test.go delete mode 100644 core/tunnel/moe/moe.go delete mode 100644 core/tunnel/moe/ssh.go delete mode 100644 core/tunnel/moe/ssh_test.go delete mode 100644 core/tunnel/ngrok/doc.go delete mode 100644 core/tunnel/ngrok/ngrok.go delete mode 100644 core/tunnel/options.go delete mode 100644 core/tunnel/provider.go delete mode 100644 core/tunnel/provider_string.go delete mode 100644 core/tunnel/suite_test.go delete mode 100644 core/tunnel/tunnel.go delete mode 100644 core/tunnel/tunnel_test.go delete mode 100644 core/tunnel/types/provider.go diff --git a/core/go.mod b/core/go.mod index c60d1ea638..f9e7e2f65b 100644 --- a/core/go.mod +++ b/core/go.mod @@ -53,8 +53,6 @@ require ( go.opentelemetry.io/otel/sdk/metric v0.39.0 go.opentelemetry.io/otel/trace v1.16.0 go.uber.org/zap v1.25.0 - golang.ngrok.com/ngrok v1.0.0 - golang.org/x/crypto v0.11.0 golang.org/x/sync v0.3.0 gorm.io/driver/sqlite v1.5.3 gorm.io/gorm v1.25.2-0.20230530020048-26663ab9bf55 @@ -107,8 +105,6 @@ require ( github.com/gorilla/websocket v1.5.0 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 // indirect github.com/imdario/mergo v0.3.13 // indirect - github.com/inconshreveable/log15 v3.0.0-testing.3+incompatible // indirect - github.com/inconshreveable/log15/v3 v3.0.0-testing.5 // indirect github.com/ipfs/go-log/v2 v2.1.3 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/jinzhu/inflection v1.0.0 // indirect @@ -163,10 +159,10 @@ require ( go.opentelemetry.io/proto/otlp v0.19.0 // indirect go.uber.org/multierr v1.10.0 // indirect golang.org/x/arch v0.3.0 // indirect + golang.org/x/crypto v0.11.0 // indirect golang.org/x/mod v0.10.0 // indirect golang.org/x/net v0.12.0 // indirect golang.org/x/sys v0.10.0 // indirect - golang.org/x/term v0.10.0 // indirect golang.org/x/text v0.11.0 // indirect golang.org/x/tools v0.9.3 // indirect google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect diff --git a/core/go.sum b/core/go.sum index 0ef03cca63..fbf47ceae8 100644 --- a/core/go.sum +++ b/core/go.sum @@ -294,15 +294,10 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 h1:lLT7ZLSzGLI08vc9cpd+tYmNWjd github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3/go.mod h1:o//XUCC/F+yRGJoPO/VU0GSB0f8Nhgmxx0VIRUvaC0w= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= -github.com/inconshreveable/log15 v3.0.0-testing.3+incompatible h1:zaX5fYT98jX5j4UhO/WbfY8T1HkgVrydiDMC9PWqGCo= -github.com/inconshreveable/log15 v3.0.0-testing.3+incompatible/go.mod h1:cOaXtrgN4ScfRrD9Bre7U1thNq5RtJ8ZoP4iXVGRj6o= -github.com/inconshreveable/log15/v3 v3.0.0-testing.5 h1:h4e0f3kjgg+RJBlKOabrohjHe47D3bbAB9BgMrc3DYA= -github.com/inconshreveable/log15/v3 v3.0.0-testing.5/go.mod h1:3GQg1SVrLoWGfRv/kAZMsdyU5cp8eFc1P3cw+Wwku94= github.com/integralist/go-findroot v0.0.0-20160518114804-ac90681525dc h1:4IZpk3M4m6ypx0IlRoEyEyY1gAdicWLMQ0NcG/gBnnA= github.com/integralist/go-findroot v0.0.0-20160518114804-ac90681525dc/go.mod h1:UlaC6ndby46IJz9m/03cZPKKkR9ykeIVBBDE3UDBdJk= github.com/ipfs/go-log v1.0.5 h1:2dOuUCB1Z7uoczMWgAyDck5JLb72zHzrMnGnCNNbvY8= @@ -565,8 +560,6 @@ go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ= go.uber.org/zap v1.23.0/go.mod h1:D+nX8jyLsMHMYrln8A0rJjFt/T/9/bGgIhAqxv5URuY= go.uber.org/zap v1.25.0 h1:4Hvk6GtkucQ790dqmj7l1eEnRdKm3k3ZUrUMS2d5+5c= go.uber.org/zap v1.25.0/go.mod h1:JIAUzQIH94IC4fOJQm7gMmBJP5k7wQfdcnYdPoEXJYk= -golang.ngrok.com/ngrok v1.0.0 h1:36xgYK8C05D4V/KslXc+Nm6E+qorNLv8zZiQCHO+FB4= -golang.ngrok.com/ngrok v1.0.0/go.mod h1:h0SmDbrHimeTrjlMgUWh21Ni3e4s5SQZm2nMJZe3XHI= golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k= golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= @@ -758,7 +751,6 @@ golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/term v0.10.0 h1:3R7pNqamzBraeqj/Tj8qt1aQ2HpmlC+Cx/qL/7hn4/c= -golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/core/tunnel/internal/check.go b/core/tunnel/internal/check.go deleted file mode 100644 index b306c24ce8..0000000000 --- a/core/tunnel/internal/check.go +++ /dev/null @@ -1,41 +0,0 @@ -package internal - -import ( - "context" - "fmt" - "net" - "net/http" -) - -// CheckPathFunc is called when the checkPath is hit. -type CheckPathFunc func() - -// VerifiableProxy is a proxy that has an overidable path. The path calls checkFunc when hit. -// this is used to make sure a proxy has started. -func VerifiableProxy(ctx context.Context, backendURL, checkPath string, listener net.Listener, pathFunc CheckPathFunc) (_ <-chan error) { - errChan := make(chan error, 1) - - proxy, err := newCheckableProxy(backendURL, checkPath, pathFunc) - if err != nil { - select { - case <-ctx.Done(): - return errChan - case errChan <- err: - return errChan - } - } - - go func() { - err = http.Serve(listener, proxy) - if err != nil { - select { - case errChan <- fmt.Errorf("could not serve ngrok: %w", err): - return - case <-ctx.Done(): - return - } - } - }() - - return errChan -} diff --git a/core/tunnel/internal/internal.go b/core/tunnel/internal/internal.go deleted file mode 100644 index 073cf677ed..0000000000 --- a/core/tunnel/internal/internal.go +++ /dev/null @@ -1,2 +0,0 @@ -// Package internal provides the internal tunnel implementation. -package internal diff --git a/core/tunnel/internal/proxy.go b/core/tunnel/internal/proxy.go deleted file mode 100644 index 089f832772..0000000000 --- a/core/tunnel/internal/proxy.go +++ /dev/null @@ -1,44 +0,0 @@ -package internal - -import ( - "fmt" - "net/http" - "net/http/httputil" - "net/url" -) - -func newCheckableProxy(backendURL string, checkPath string, checkFunc CheckPathFunc) (*checkableProxy, error) { - parsedURL, err := url.Parse(backendURL) - if err != nil { - return nil, fmt.Errorf("could not parse backend URL: %w", err) - } - - proxy := httputil.NewSingleHostReverseProxy(parsedURL) - - return &checkableProxy{ - proxy: proxy, - checkPath: checkPath, - checkFunc: checkFunc, - }, nil -} - -type checkableProxy struct { - // proxy is the underlying proxy. - proxy *httputil.ReverseProxy - // checkPath is the checkPath - checkPath string - // checkFunc is called when checkPath is hit - checkFunc CheckPathFunc -} - -func (c checkableProxy) ServeHTTP(writer http.ResponseWriter, request *http.Request) { - if c.checkPath == request.URL.Path { - c.checkFunc() - writer.WriteHeader(http.StatusOK) - return - } - - c.proxy.ServeHTTP(writer, request) -} - -var _ http.Handler = &checkableProxy{} diff --git a/core/tunnel/internal/proxy_test.go b/core/tunnel/internal/proxy_test.go deleted file mode 100644 index 2d2bbc41f7..0000000000 --- a/core/tunnel/internal/proxy_test.go +++ /dev/null @@ -1,7 +0,0 @@ -package internal_test - -import "testing" - -func TestVerifiableProxy(t *testing.T) { - t.Skip("this test is in the tunnel/suite_test.go file") -} diff --git a/core/tunnel/moe/doc.go b/core/tunnel/moe/doc.go deleted file mode 100644 index 3eece70710..0000000000 --- a/core/tunnel/moe/doc.go +++ /dev/null @@ -1,8 +0,0 @@ -// Package moe provides a tunnel that uses the Moe protocol. -// this module is currently broken due to an issue with moe. -// this is caused by two issues: -// 1. Moe returns localhost as the hostname: https://github.com/fasmide/remotemoe/blob/13a9ba0f5ddadffdf4fb395ebff7c366b88a0745/ssh/session.go#L363 -// 2. Go assumes the response returned by forwarded-tcpip is a tcp address: https://github.com/golang/crypto/blob/master/ssh/tcpip.go#L211 -// A PR has been made to fix this: https://github.com/fasmide/remotemoe/pull/18 and this module will be ready when that's merged -// should the PR be unmergable for an extended period of time, we can intercept the requests in the net.Conn through a reverse ssh proxy -package moe diff --git a/core/tunnel/moe/export_test.go b/core/tunnel/moe/export_test.go deleted file mode 100644 index 22fad055b6..0000000000 --- a/core/tunnel/moe/export_test.go +++ /dev/null @@ -1,14 +0,0 @@ -package moe - -import ( - "context" - "io" -) - -// Export for testing. -const MoeServer = moeServer - -// ConsumeBufferUntilURL exports consumeBufferUntilURL for testing. -func ConsumeBufferUntilURL(ctx context.Context, reader io.Reader) (host string, err error) { - return consumeBufferUntilURL(ctx, reader) -} diff --git a/core/tunnel/moe/moe.go b/core/tunnel/moe/moe.go deleted file mode 100644 index 7800da25a4..0000000000 --- a/core/tunnel/moe/moe.go +++ /dev/null @@ -1,110 +0,0 @@ -package moe - -import ( - "context" - "fmt" - "github.com/brianvoe/gofakeit/v6" - "github.com/ipfs/go-log" - "github.com/jpillora/backoff" - "github.com/phayes/freeport" - "github.com/synapsecns/sanguine/core/tunnel/internal" - "github.com/synapsecns/sanguine/core/tunnel/types" - "net" - "net/http" - "time" -) - -var logger = log.Logger("moe") - -type moeProvider struct { - // checkPath is a path we override the backend with to check if the tunnel is up. - checkPath string - // checkChan is a channel that is closed when the checkPath is hit. - checkChan chan bool -} - -// New returns a new moe provider. -func New() types.Provider { - return &moeProvider{ - checkPath: fmt.Sprintf("/%s", gofakeit.UUID()), - checkChan: make(chan bool, 1), - } -} - -type hostInfo struct { - hostname string - port int -} - -// makeListener returns the hostname and port of a listener. -func (m *moeProvider) makeListener() hostInfo { - port := freeport.GetPort() - return hostInfo{ - port: port, - hostname: fmt.Sprintf("localhost:%d", port), - } -} - -// moeServer is the remote moe server. -const moeServer = "remote.moe" -const remotePort = 80 - -// nolint: cyclop -func (m *moeProvider) Start(ctx context.Context, backendURL string) (_ string, err error) { - var lc net.ListenConfig - - // make the verifiable proxy and listener - verifiableProxy := m.makeListener() - vpListener, err := lc.Listen(ctx, "tcp", verifiableProxy.hostname) - if err != nil { - return "", fmt.Errorf("could not start moe: %w", err) - } - - errChan := internal.VerifiableProxy(ctx, backendURL, m.checkPath, vpListener, func() { - m.checkChan <- true - }) - - // make the backend proxy and listener - host, err := createTunnel(context.Background(), moeServer, verifiableProxy.port, remotePort) - if err != nil { - return "", fmt.Errorf("could not get tunnel") - } - - // TODO: this needs to be deduped w/ moe - timeout := &backoff.Backoff{ - Factor: 2, - Jitter: true, - Min: 200 * time.Millisecond, - Max: time.Second, - } - - // give the server a max of 30 seconds to start - ctx, cancel := context.WithTimeout(ctx, time.Second*30) - defer cancel() - duration := time.Duration(0) - for { - select { - case <-ctx.Done(): - return "", nil - case err := <-errChan: - return "", fmt.Errorf("could not serve ngrok: %w", err) - case <-time.After(duration): - req, err := http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf("%s%s", host, m.checkPath), nil) - if err != nil { - return "", fmt.Errorf("could not create request: %w", err) - } - - resp, err := http.DefaultClient.Do(req) - if err != nil { - duration = timeout.Duration() - continue - } - - if resp != nil { - _ = resp.Body.Close() - } - case <-m.checkChan: - return backendURL, nil - } - } -} diff --git a/core/tunnel/moe/ssh.go b/core/tunnel/moe/ssh.go deleted file mode 100644 index 8fba34389c..0000000000 --- a/core/tunnel/moe/ssh.go +++ /dev/null @@ -1,255 +0,0 @@ -package moe - -import ( - "bufio" - "context" - "crypto/rand" - "crypto/rsa" - "crypto/x509" - "encoding/pem" - "fmt" - "golang.org/x/crypto/ssh" - "io" - "net" - "os" - "regexp" - "strings" - "time" -) - -// Get private key for ssh authentication. -func generatePrivateKey() (ssh.Signer, error) { - privateKey, err := rsa.GenerateKey(rand.Reader, 2048) - if err != nil { - return nil, fmt.Errorf("failed to generate private key: %w", err) - } - - privateKeyBytes := pem.EncodeToMemory(&pem.Block{ - Type: "RSA PRIVATE KEY", - Bytes: x509.MarshalPKCS1PrivateKey(privateKey), - }) - - sshPrivateKey, err := ssh.ParseRawPrivateKey(privateKeyBytes) - if err != nil { - return nil, fmt.Errorf("failed to parse private key: %w", err) - } - signer, err := ssh.NewSignerFromKey(sshPrivateKey) - if err != nil { - return nil, fmt.Errorf("failed to create signer: %w", err) - } - return signer, nil -} - -// Get ssh client config for our connection -// SSH config will use 2 authentication strategies: by key and by password. -func makeSSHConfig() (*ssh.ClientConfig, error) { - key, err := generatePrivateKey() - if err != nil { - return nil, err - } - - config := ssh.ClientConfig{ - Auth: []ssh.AuthMethod{ - ssh.PublicKeys(key), - }, - //nolint: gosec - HostKeyCallback: ssh.InsecureIgnoreHostKey(), - } - - return &config, nil -} - -// From https://sosedoff.com/2015/05/25/ssh-port-forwarding-with-go.html -// Handle local client connections and tunnel data to the remote server -// Will use io.Copy - http://golang.org/pkg/io/#Copy -func handleClient(client net.Conn, remote net.Conn) { - defer func() { - _ = client.Close() - }() - chDone := make(chan bool) - - // Start remote -> local data transfer - go func() { - _, err := io.Copy(client, remote) - if err != nil { - logger.Debugf("error while copy remote->local: %w", err) - } - chDone <- true - }() - - // Start local -> remote data transfer - go func() { - _, err := io.Copy(remote, client) - if err != nil { - logger.Debugf("error while copy local->remote: %w", err) - } - chDone <- true - }() - - <-chDone -} - -func createTunnel(ctx context.Context, sshAddr string, localPort, remotePort int) (host string, err error) { - errChan := make(chan error, 1) - hostChan := make(chan string, 1) - - go func() { - startReverseSSHTunnel(ctx, sshAddr, localPort, remotePort, errChan, hostChan) - }() - - select { - case <-ctx.Done(): - return "", fmt.Errorf("context canceled: %w", ctx.Err()) - case host := <-hostChan: - // after this point, we'll need to consume and log the errors since we can't tell the client anything - go func() { - select { - case <-ctx.Done(): - return - case err := <-errChan: - logger.Warn(err) - } - }() - return host, nil - case err := <-errChan: - return "", fmt.Errorf("could not start proxy: %w", err) - } -} - -// appendToErrChan appends the error to the error channel if the context is not done. -func appendToErrChan(ctx context.Context, err error, errChan chan<- error) { - select { - case <-ctx.Done(): - case errChan <- err: - } -} - -// appendToHostChan adds the host to the host chan. -func appendToHostChan(ctx context.Context, host string, hostChan chan<- string) { - select { - case <-ctx.Done(): - case hostChan <- host: - } -} - -// nolint: cyclop -func startReverseSSHTunnel(ctx context.Context, sshAddr string, localPort, remotePort int, errChan chan<- error, hostChan chan<- string) { - // Build SSH client configuration - cfg, err := makeSSHConfig() - if err != nil { - appendToErrChan(ctx, fmt.Errorf("failed to make ssh config: %w", err), errChan) - return - } - - // Connect to SSH remote server using serverEndpoint - serverConn, err := ssh.Dial("tcp", net.JoinHostPort(sshAddr, "22"), cfg) - if err != nil { - appendToErrChan(ctx, fmt.Errorf("failed to make ssh config: %w", err), errChan) - return - } - - // Listen on remote server port - listener, err := serverConn.Listen("tcp", fmt.Sprintf("127.0.01:%d", remotePort)) - if err != nil { - appendToErrChan(ctx, fmt.Errorf("listen open port ON remote server error: %w", err), errChan) - return - } - - defer func() { - _ = listener.Close() - }() - - // Create a new session - session, err := serverConn.NewSession() - if err != nil { - appendToErrChan(ctx, fmt.Errorf("listen open port ON remote server error: %w", err), errChan) - return - } - - defer func() { - _ = session.Close() - }() - - session.Stderr = os.Stderr - stdOut, err := session.StdoutPipe() - if err != nil { - appendToErrChan(ctx, fmt.Errorf("failed to make ssh config: %w", err), errChan) - return - } - - err = session.RequestPty("xterm", 80, 40, ssh.TerminalModes{ - ssh.ECHO: 1, // enable echoing - ssh.TTY_OP_ISPEED: 14400, - ssh.TTY_OP_OSPEED: 14400, - }) - if err != nil { - appendToErrChan(ctx, fmt.Errorf("could not request pty: %w", err), errChan) - return - } - - err = session.Shell() - if err != nil { - appendToErrChan(ctx, fmt.Errorf("failed to start: %w", err), errChan) - return - } - - // wait for the banner - consumeCtx, cancel := context.WithTimeout(ctx, time.Second*30) - defer cancel() - - var host string - host, err = consumeBufferUntilURL(ctx, stdOut) - if err != nil { - appendToErrChan(consumeCtx, fmt.Errorf("could not request pty: %w", err), errChan) - return - } - appendToHostChan(ctx, host, hostChan) - - // handle incoming connections on reverse forwarded tunnel - for { - // Open a (local) connection to localEndpoint whose content will be forwarded to serverEndpoint - local, err := net.Dial("tcp", fmt.Sprintf(":%d", localPort)) - if err != nil { - appendToErrChan(ctx, fmt.Errorf("dial INTO local service error: %w", err), errChan) - return - } - - client, err := listener.Accept() - if err != nil { - appendToErrChan(ctx, fmt.Errorf("could not accept connection: %w", err), errChan) - return - } - - handleClient(client, local) - } -} - -var re = regexp.MustCompile(`https?://[^\s]+`) - -// nolint: nestif -func consumeBufferUntilURL(ctx context.Context, reader io.Reader) (host string, err error) { - scanner := bufio.NewScanner(reader) - var buffer string - for { - select { - case <-ctx.Done(): - return "", fmt.Errorf("context canceled before string was found") - default: - if scanner.Scan() { - buffer += scanner.Text() - if strings.Contains(buffer, moeServer) { - matches := re.FindStringSubmatch(buffer) - if len(matches) == 0 { - return "", fmt.Errorf("could not parse %s from %s", re.String(), buffer) - } - return matches[0], nil - } - } else { - if err := scanner.Err(); err != nil { - return "", fmt.Errorf("could not scan: %w", err) - } - return "", fmt.Errorf("EOF before string was found") - } - } - } -} diff --git a/core/tunnel/moe/ssh_test.go b/core/tunnel/moe/ssh_test.go deleted file mode 100644 index 79c20ad5ac..0000000000 --- a/core/tunnel/moe/ssh_test.go +++ /dev/null @@ -1,57 +0,0 @@ -package moe_test - -import ( - "context" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "github.com/synapsecns/sanguine/core/tunnel/moe" - "strings" - "testing" -) - -func TestConsumeBufferUntilURL(t *testing.T) { - testCases := []struct { - name string - input string - want string - wantErr bool - }{ - { - name: "url found", - input: "some text http://example.com/ some more text " + moe.MoeServer, - want: "http://example.com/", - wantErr: false, - }, - { - name: "url not found", - input: "some text" + moe.MoeServer + "some more text", - want: "", - wantErr: true, - }, - { - name: "context canceled", - input: "some text", - want: "", - wantErr: true, - }, - } - - for i := range testCases { - tc := testCases[i] // capture range variable - t.Run(tc.name, func(t *testing.T) { - reader := strings.NewReader(tc.input) - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - got, err := moe.ConsumeBufferUntilURL(ctx, reader) - - if tc.wantErr { - require.Error(t, err) - } else { - require.NoError(t, err) - } - - assert.Equal(t, tc.want, got) - }) - } -} diff --git a/core/tunnel/ngrok/doc.go b/core/tunnel/ngrok/doc.go deleted file mode 100644 index 763510da7a..0000000000 --- a/core/tunnel/ngrok/doc.go +++ /dev/null @@ -1,2 +0,0 @@ -// Package ngrok provides a tunnel that uses ngrok to expose a local port to the internet. -package ngrok diff --git a/core/tunnel/ngrok/ngrok.go b/core/tunnel/ngrok/ngrok.go deleted file mode 100644 index fd2311bb04..0000000000 --- a/core/tunnel/ngrok/ngrok.go +++ /dev/null @@ -1,85 +0,0 @@ -package ngrok - -import ( - "context" - "fmt" - "github.com/brianvoe/gofakeit/v6" - "github.com/jpillora/backoff" - "github.com/synapsecns/sanguine/core/tunnel/internal" - "github.com/synapsecns/sanguine/core/tunnel/types" - "golang.ngrok.com/ngrok" - grokconfig "golang.ngrok.com/ngrok/config" - "net/http" - "time" -) - -type ngrokProvider struct { - options []ngrok.ConnectOption - // checkPath is a path we override the backend with to check if the tunnel is up. - checkPath string - // checkChan is a channel that is closed when the checkPath is hit. - checkChan chan bool -} - -// New returns a new ngrok provider. -func New(opts ...ngrok.ConnectOption) types.Provider { - return &ngrokProvider{ - options: opts, - checkPath: fmt.Sprintf("/%s", gofakeit.UUID()), - checkChan: make(chan bool, 1), - } -} - -func (n *ngrokProvider) Start(ctx context.Context, backendURL string) (_ string, err error) { - // add the default options - ngrokOptions := append([]ngrok.ConnectOption{ - ngrok.WithAuthtokenFromEnv(), - }, n.options...) - - listener, err := ngrok.Listen(ctx, grokconfig.HTTPEndpoint(), ngrokOptions...) - if err != nil { - return "", fmt.Errorf("could not start ngrok: %w", err) - } - - errChan := internal.VerifiableProxy(ctx, backendURL, n.checkPath, listener, func() { - n.checkChan <- true - }) - - // TODO: this needs to be deduped w/ moe - timeout := &backoff.Backoff{ - Factor: 2, - Jitter: true, - Min: 200 * time.Millisecond, - Max: time.Second, - } - - // give the server a max of 30 seconds to start - ctx, cancel := context.WithTimeout(ctx, time.Second*30) - defer cancel() - duration := time.Duration(0) - for { - select { - case <-ctx.Done(): - return "", nil - case err := <-errChan: - return "", fmt.Errorf("could not serve ngrok: %w", err) - case <-time.After(duration): - req, err := http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf("%s%s", listener.URL(), n.checkPath), nil) - if err != nil { - return "", fmt.Errorf("could not create request: %w", err) - } - - resp, err := http.DefaultClient.Do(req) - if err != nil { - duration = timeout.Duration() - continue - } - - if resp != nil { - _ = resp.Body.Close() - } - case <-n.checkChan: - return backendURL, nil - } - } -} diff --git a/core/tunnel/options.go b/core/tunnel/options.go deleted file mode 100644 index 2f46c0719f..0000000000 --- a/core/tunnel/options.go +++ /dev/null @@ -1,51 +0,0 @@ -package tunnel - -import ( - "fmt" - "golang.ngrok.com/ngrok" -) - -type config struct { - provider Provider - ngrokOptions []ngrok.ConnectOption -} - -func (c *config) Validate() error { - if len(c.ngrokOptions) != 0 && c.provider != Ngrok { - return fmt.Errorf("ngrok options are only valid for ngrok provider") - } - return nil -} - -// Option is a tunnel option. -type Option func(*config) - -// WithNgrokOptions sets the ngrok options to use when using the ngrok provider. -func WithNgrokOptions(opts ...ngrok.ConnectOption) Option { - return func(c *config) { - c.ngrokOptions = opts - } -} - -// WithProvider sets the provider to use. -func WithProvider(provider Provider) Option { - return func(c *config) { - c.provider = provider - } -} - -func makeConfig(opts []Option) (*config, error) { - c := &config{ - // TODO: switch to moe once it's ready - provider: Ngrok, - } - for _, opt := range opts { - opt(c) - } - - err := c.Validate() - if err != nil { - return nil, fmt.Errorf("invalid options: %w", err) - } - return c, nil -} diff --git a/core/tunnel/provider.go b/core/tunnel/provider.go deleted file mode 100644 index 5014a3015b..0000000000 --- a/core/tunnel/provider.go +++ /dev/null @@ -1,13 +0,0 @@ -package tunnel - -// Provider is a tunnel provider. -// -//go:generate go run golang.org/x/tools/cmd/stringer -type=Provider -linecomment -type Provider uint8 - -const ( - // Moe is the moe provider: https://github.com/fasmide/remotemoe - Moe Provider = iota + 1 - // Ngrok is the ngrok provider: https://ngrok.com/ - Ngrok -) diff --git a/core/tunnel/provider_string.go b/core/tunnel/provider_string.go deleted file mode 100644 index 4bcbab0da9..0000000000 --- a/core/tunnel/provider_string.go +++ /dev/null @@ -1,25 +0,0 @@ -// Code generated by "stringer -type=Provider -linecomment"; DO NOT EDIT. - -package tunnel - -import "strconv" - -func _() { - // An "invalid array index" compiler error signifies that the constant values have changed. - // Re-run the stringer command to generate them again. - var x [1]struct{} - _ = x[Moe-1] - _ = x[Ngrok-2] -} - -const _Provider_name = "MoeNgrok" - -var _Provider_index = [...]uint8{0, 3, 8} - -func (i Provider) String() string { - i -= 1 - if i >= Provider(len(_Provider_index)-1) { - return "Provider(" + strconv.FormatInt(int64(i+1), 10) + ")" - } - return _Provider_name[_Provider_index[i]:_Provider_index[i+1]] -} diff --git a/core/tunnel/suite_test.go b/core/tunnel/suite_test.go deleted file mode 100644 index a9c5dced45..0000000000 --- a/core/tunnel/suite_test.go +++ /dev/null @@ -1,86 +0,0 @@ -package tunnel_test - -import ( - "context" - "errors" - "fmt" - "github.com/ipfs/go-log" - "github.com/phayes/freeport" - "github.com/stretchr/testify/suite" - "github.com/synapsecns/sanguine/core/ginhelper" - "github.com/synapsecns/sanguine/core/retry" - baseServer "github.com/synapsecns/sanguine/core/server" - "github.com/synapsecns/sanguine/core/testsuite" - "net/http" - "testing" - "time" -) - -// TunnelSuite defines the basic test suite. -type TunnelSuite struct { - *testsuite.TestSuite - // testServer is the url of the local server to test on. - testServer string - logger *log.ZapEventLogger -} - -// NewTestSuite creates a new test suite and performs some basic checks afterward. -// Every test suite in the synapse library should inherit from this suite and override where necessary. -func NewTunnelSuite(tb testing.TB) *TunnelSuite { - tb.Helper() - return &TunnelSuite{ - TestSuite: testsuite.NewTestSuite(tb), - } -} - -func (n *TunnelSuite) SetupTest() { - n.TestSuite.SetupTest() - n.logger = log.Logger(fmt.Sprintf("test-%d-logger", n.GetTestID())) - n.startServer(n.GetTestContext()) -} - -// startServer starts the test server and sets the testServer field. -func (n *TunnelSuite) startServer(ctx context.Context) { - testServer := ginhelper.New(n.logger) - freePort, err := freeport.GetFreePort() - n.Require().NoError(err) - - n.testServer = fmt.Sprintf("http://localhost:%d", freePort) - - go func() { - connection := baseServer.Server{} - err = connection.ListenAndServe(ctx, fmt.Sprintf(":%d", freePort), testServer) - // we expect context cancellation errors at the end of the test - if !errors.Is(err, context.Canceled) { - n.Require().NoError(err) - } - }() - - // make sure the server is running - - err = retry.WithBackoff(ctx, func(ctx context.Context) error { - req, err := http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf("%s%s", n.testServer, ginhelper.HealthCheck), nil) - if err != nil { - return fmt.Errorf("could not create request: %w", err) - } - resp, err := http.DefaultClient.Do(req) - if err != nil { - return fmt.Errorf("could not send request: %w", err) - } - if resp.StatusCode != http.StatusOK { - return fmt.Errorf("unexpected status code: %d", resp.StatusCode) - } - - if resp.Body != nil { - _ = resp.Body.Close() - } - - return nil - }, retry.WithMin(time.Millisecond), retry.WithMax(time.Second), retry.WithMaxAttemptTime(time.Second*30)) - - n.Require().NoError(err) -} - -func TestTunnelSuite(t *testing.T) { - suite.Run(t, NewTunnelSuite(t)) -} diff --git a/core/tunnel/tunnel.go b/core/tunnel/tunnel.go deleted file mode 100644 index 4251aaa895..0000000000 --- a/core/tunnel/tunnel.go +++ /dev/null @@ -1,32 +0,0 @@ -// Package tunnel provides a simple interface to start a tunnel to a backend URL. -package tunnel - -import ( - "context" - "fmt" - "github.com/synapsecns/sanguine/core/tunnel/moe" - ngrok "github.com/synapsecns/sanguine/core/tunnel/ngrok" - "github.com/synapsecns/sanguine/core/tunnel/types" -) - -// StartTunnel starts a tunnel to the backend URL. -func StartTunnel(ctx context.Context, backendURL string, opts ...Option) (string, error) { - cfg, err := makeConfig(opts) - if err != nil { - return "", err - } - - var provider types.Provider - - switch cfg.provider { - case Moe: - provider = moe.New() - case Ngrok: - provider = ngrok.New(cfg.ngrokOptions...) - } - tunnelURL, err := provider.Start(ctx, backendURL) - if err != nil { - return "", fmt.Errorf("could not start tunnel: %w", err) - } - return tunnelURL, nil -} diff --git a/core/tunnel/tunnel_test.go b/core/tunnel/tunnel_test.go deleted file mode 100644 index fbebb17921..0000000000 --- a/core/tunnel/tunnel_test.go +++ /dev/null @@ -1,84 +0,0 @@ -package tunnel_test - -import ( - "context" - "fmt" - "github.com/brianvoe/gofakeit/v6" - "github.com/phayes/freeport" - "github.com/synapsecns/sanguine/core/ginhelper" - "github.com/synapsecns/sanguine/core/tunnel" - "github.com/synapsecns/sanguine/core/tunnel/internal" - "net" - "net/http" - "time" -) - -// this module is currently broken due to an issue with moe. -// this is caused by two issues: -// 1. Moe returns localhost as the hostname: https://github.com/fasmide/remotemoe/blob/13a9ba0f5ddadffdf4fb395ebff7c366b88a0745/ssh/session.go#L363 -// 2. Go assumes the response returned by forwarded-tcpip is a tcp address: https://github.com/golang/crypto/blob/master/ssh/tcpip.go#L211 -// A PR has been made to fix this: https://github.com/fasmide/remotemoe/pull/18 and this module will be ready when that's merged -// should the PR be unmergable for an extended period of time, we can intercept the requests in the net.Conn through a reverse ssh proxy. -func (n *TunnelSuite) TestMoe() { - n.T().Skip("moe is currently broken, waiting on https://github.com/fasmide/remotemoe/pull/18") - remoteURL, err := tunnel.StartTunnel(n.GetTestContext(), n.testServer, tunnel.WithProvider(tunnel.Moe)) - time.Sleep(time.Hour) - n.Require().NoError(err) - - n.checkTunnel(n.GetTestContext(), remoteURL) -} - -func (n *TunnelSuite) TestNgrok() { - remoteURL, err := tunnel.StartTunnel(n.GetTestContext(), n.testServer, tunnel.WithNgrokOptions(), tunnel.WithProvider(tunnel.Ngrok)) - n.Require().NoError(err) - - n.checkTunnel(n.GetTestContext(), remoteURL) -} - -func (n *TunnelSuite) checkTunnel(ctx context.Context, remoteURL string) { - req, err := http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf("%s%s", remoteURL, ginhelper.HealthCheck), nil) - n.Require().NoError(err) - - resp, err := http.DefaultClient.Do(req) - n.Require().NoError(err) - n.Require().Equal(http.StatusOK, resp.StatusCode) - - if resp.Body != nil { - _ = resp.Body.Close() - } -} - -func (n *TunnelSuite) TestVerifiableProxy() { - var lc net.ListenConfig - port := freeport.GetPort() - - hostname := fmt.Sprintf("localhost:%d", port) - listener, err := lc.Listen(n.GetTestContext(), "tcp", hostname) - n.Require().NoError(err) - - checkPath := fmt.Sprintf("/%s", gofakeit.Word()) - - pathChan := make(chan bool, 1) - errChan := internal.VerifiableProxy(n.GetTestContext(), n.testServer, checkPath, listener, func() { - pathChan <- true - }) - - req, err := http.NewRequestWithContext(n.GetTestContext(), http.MethodGet, fmt.Sprintf("http://%s%s", hostname, checkPath), nil) - n.Require().NoError(err) - - resp, err := http.DefaultClient.Do(req) - n.Require().NoError(err) - - if resp.Body != nil { - _ = resp.Body.Close() - } - - select { - case <-n.GetTestContext().Done(): - n.Require().NoError(n.GetTestContext().Err()) - case err := <-errChan: - n.Require().NoError(err) - case <-pathChan: - return - } -} diff --git a/core/tunnel/types/provider.go b/core/tunnel/types/provider.go deleted file mode 100644 index 8e1f8ca284..0000000000 --- a/core/tunnel/types/provider.go +++ /dev/null @@ -1,12 +0,0 @@ -// Package types provides common types to avoid circular dependencies. -package types - -import ( - "context" -) - -// Provider is a tunnel provider. -type Provider interface { - // Start starts the tunnel provider and returns the URL of the tunnel. - Start(ctx context.Context, backendURL string) (_ string, err error) -} From 8c7ea4474c5a777d1aa3a0826d0902db2dfbf2db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CF=87=C2=B2?= <88190723+ChiTimesChi@users.noreply.github.com> Date: Thu, 21 Dec 2023 15:14:15 +0300 Subject: [PATCH 07/29] Fix failing test (not enough pool liquidity) (#1690) --- packages/sdk-router/src/sdk.test.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/sdk-router/src/sdk.test.ts b/packages/sdk-router/src/sdk.test.ts index e8fce8bb2e..649f56bd35 100644 --- a/packages/sdk-router/src/sdk.test.ts +++ b/packages/sdk-router/src/sdk.test.ts @@ -237,15 +237,15 @@ describe('SynapseSDK', () => { ) }) - describe('ETH USDC -> ARB USDC.e (excludeCCTP flag omitted)', () => { - // Try to find ETH USDC -> ARB USDC.e quote for 1M USDC, + describe('ETH USDC -> ARB USDT (excludeCCTP flag omitted)', () => { + // Try to find ETH USDC -> ARB USDT quote for 1M USDC, // which by default is routed through USDC const amount = BigNumber.from(10).pow(12) const resultPromise: Promise = synapse.bridgeQuote( SupportedChainId.ETH, SupportedChainId.ARBITRUM, ETH_USDC, - ARB_USDC_E, + ARB_USDT, amount ) @@ -274,15 +274,15 @@ describe('SynapseSDK', () => { }) }) - describe('ETH USDC -> ARB USDC.e (excludeCCTP flag off)', () => { - // Try to find ETH USDC -> ARB USDC.e quote for 1M USDC, + describe('ETH USDC -> ARB USDT (excludeCCTP flag off)', () => { + // Try to find ETH USDC -> ARB USDT quote for 1M USDC, // which by default is routed through USDC const amount = BigNumber.from(10).pow(12) const resultPromise: Promise = synapse.bridgeQuote( SupportedChainId.ETH, SupportedChainId.ARBITRUM, ETH_USDC, - ARB_USDC_E, + ARB_USDT, amount, undefined, false @@ -313,15 +313,15 @@ describe('SynapseSDK', () => { }) }) - describe('ETH USDC -> ARB USDC.e (excludeCCTP flag on)', () => { - // Try to find ETH USDC -> ARB USDC.e quote for 1M USDC, + describe('ETH USDC -> ARB USDT (excludeCCTP flag on)', () => { + // Try to find ETH USDC -> ARB USDT quote for 1M USDC, // which by default is routed through USDC const amount = BigNumber.from(10).pow(12) const resultPromise: Promise = synapse.bridgeQuote( SupportedChainId.ETH, SupportedChainId.ARBITRUM, ETH_USDC, - ARB_USDC_E, + ARB_USDT, amount, undefined, true From c305a20bcb71569dc6f1cbf0ff8739042eff904d Mon Sep 17 00:00:00 2001 From: ChiTimesChi Date: Thu, 21 Dec 2023 12:17:21 +0000 Subject: [PATCH 08/29] Publish - @synapsecns/rest-api@1.0.29 - @synapsecns/sdk-router@0.3.2 - @synapsecns/synapse-interface@0.1.210 --- packages/rest-api/CHANGELOG.md | 8 ++++++++ packages/rest-api/package.json | 4 ++-- packages/sdk-router/CHANGELOG.md | 8 ++++++++ packages/sdk-router/package.json | 2 +- packages/synapse-interface/CHANGELOG.md | 8 ++++++++ packages/synapse-interface/package.json | 4 ++-- 6 files changed, 29 insertions(+), 5 deletions(-) diff --git a/packages/rest-api/CHANGELOG.md b/packages/rest-api/CHANGELOG.md index 3fbe07e202..2bb914b380 100644 --- a/packages/rest-api/CHANGELOG.md +++ b/packages/rest-api/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.29](https://github.com/synapsecns/sanguine/compare/@synapsecns/rest-api@1.0.28...@synapsecns/rest-api@1.0.29) (2023-12-21) + +**Note:** Version bump only for package @synapsecns/rest-api + + + + + ## [1.0.28](https://github.com/synapsecns/sanguine/compare/@synapsecns/rest-api@1.0.27...@synapsecns/rest-api@1.0.28) (2023-12-18) **Note:** Version bump only for package @synapsecns/rest-api diff --git a/packages/rest-api/package.json b/packages/rest-api/package.json index 6eb4225106..383d4619e7 100644 --- a/packages/rest-api/package.json +++ b/packages/rest-api/package.json @@ -1,6 +1,6 @@ { "name": "@synapsecns/rest-api", - "version": "1.0.28", + "version": "1.0.29", "private": "true", "engines": { "node": ">=16.0.0" @@ -23,7 +23,7 @@ "@ethersproject/bignumber": "^5.7.0", "@ethersproject/providers": "^5.7.2", "@ethersproject/units": "5.7.0", - "@synapsecns/sdk-router": "^0.3.1", + "@synapsecns/sdk-router": "^0.3.2", "bignumber": "^1.1.0", "ethers": "5.7.2", "express": "^4.18.2", diff --git a/packages/sdk-router/CHANGELOG.md b/packages/sdk-router/CHANGELOG.md index a9de2dd6cc..bbec231af9 100644 --- a/packages/sdk-router/CHANGELOG.md +++ b/packages/sdk-router/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.3.2](https://github.com/synapsecns/sanguine/compare/@synapsecns/sdk-router@0.3.1...@synapsecns/sdk-router@0.3.2) (2023-12-21) + +**Note:** Version bump only for package @synapsecns/sdk-router + + + + + ## [0.3.1](https://github.com/synapsecns/sanguine/compare/@synapsecns/sdk-router@0.3.0...@synapsecns/sdk-router@0.3.1) (2023-12-18) **Note:** Version bump only for package @synapsecns/sdk-router diff --git a/packages/sdk-router/package.json b/packages/sdk-router/package.json index 594e10938f..892c8d7187 100644 --- a/packages/sdk-router/package.json +++ b/packages/sdk-router/package.json @@ -1,7 +1,7 @@ { "name": "@synapsecns/sdk-router", "description": "An SDK for interacting with the Synapse Protocol", - "version": "0.3.1", + "version": "0.3.2", "license": "MIT", "main": "dist/index.js", "typings": "dist/index.d.ts", diff --git a/packages/synapse-interface/CHANGELOG.md b/packages/synapse-interface/CHANGELOG.md index a5708f9d8d..4b8a412d30 100644 --- a/packages/synapse-interface/CHANGELOG.md +++ b/packages/synapse-interface/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.1.210](https://github.com/synapsecns/sanguine/compare/@synapsecns/synapse-interface@0.1.209...@synapsecns/synapse-interface@0.1.210) (2023-12-21) + +**Note:** Version bump only for package @synapsecns/synapse-interface + + + + + ## [0.1.209](https://github.com/synapsecns/sanguine/compare/@synapsecns/synapse-interface@0.1.208...@synapsecns/synapse-interface@0.1.209) (2023-12-18) **Note:** Version bump only for package @synapsecns/synapse-interface diff --git a/packages/synapse-interface/package.json b/packages/synapse-interface/package.json index 5c79242cf1..32945244f2 100644 --- a/packages/synapse-interface/package.json +++ b/packages/synapse-interface/package.json @@ -1,6 +1,6 @@ { "name": "@synapsecns/synapse-interface", - "version": "0.1.209", + "version": "0.1.210", "private": true, "engines": { "node": ">=16.0.0" @@ -42,7 +42,7 @@ "@reduxjs/toolkit": "^1.9.5", "@rtk-query/graphql-request-base-query": "^2.2.0", "@segment/analytics-next": "^1.53.0", - "@synapsecns/sdk-router": "^0.3.1", + "@synapsecns/sdk-router": "^0.3.2", "@tailwindcss/aspect-ratio": "^0.4.2", "@tailwindcss/forms": "^0.5.3", "@tailwindcss/line-clamp": "^0.4.2", From 4720c5d4652f30a3e08a2bf3488d169dd69b2d30 Mon Sep 17 00:00:00 2001 From: trajan0x <83933037+trajan0x@users.noreply.github.com> Date: Thu, 21 Dec 2023 17:16:03 +0100 Subject: [PATCH 09/29] remove tunnel from readme (#1692) Co-authored-by: Trajan0x --- core/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/core/README.md b/core/README.md index 8e6e984717..07f36b0fc4 100644 --- a/core/README.md +++ b/core/README.md @@ -26,7 +26,6 @@ root ├── server: Provides a context-safe server that can be used to start/stop a server. ├── testsuite: Provides a wrapper around testify/suite. ├── threaditer: Provides a thread-safe generic iterator for a slice. -├── tunnel: Reverse tunneling service for debugging services in ci. From 9238568d2d711cdf2dbb1f7dbb631cc1cb447ea1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CF=87=C2=B2?= <88190723+ChiTimesChi@users.noreply.github.com> Date: Thu, 21 Dec 2023 20:03:27 +0300 Subject: [PATCH 10/29] SDK: fix native value (#1683) * Check returned message value * Add tests for bridging native gas tokens * Fix: correct tx.value in `bridge()` and `swap()` * Chore: cleanup --- .../sdk-router/src/constants/testValues.ts | 2 + .../src/router/synapseCCTPRouter.ts | 20 ++- .../sdk-router/src/router/synapseRouter.ts | 35 ++++-- packages/sdk-router/src/sdk.test.ts | 117 ++++++++++++++---- .../sdk-router/src/utils/handleNativeToken.ts | 27 +++- 5 files changed, 162 insertions(+), 39 deletions(-) diff --git a/packages/sdk-router/src/constants/testValues.ts b/packages/sdk-router/src/constants/testValues.ts index 8abf54ea75..05fc00fed2 100644 --- a/packages/sdk-router/src/constants/testValues.ts +++ b/packages/sdk-router/src/constants/testValues.ts @@ -10,6 +10,8 @@ export const getTestProviderUrl = (chainId: number): string => { return `${sdkRpcUrl}${chainId}` } +export const NATIVE_ADDRESS = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE' + // Token addresses on Ethereum mainnet export const ETH_DAI = '0x6B175474E89094C44Da98b954EedeAC495271d0F' export const ETH_NUSD = '0x1B84765dE8B7566e4cEAF4D0fD3c5aF52D3DdE4F' diff --git a/packages/sdk-router/src/router/synapseCCTPRouter.ts b/packages/sdk-router/src/router/synapseCCTPRouter.ts index a25b3882ed..366214ebe6 100644 --- a/packages/sdk-router/src/router/synapseCCTPRouter.ts +++ b/packages/sdk-router/src/router/synapseCCTPRouter.ts @@ -9,6 +9,7 @@ import { SynapseCCTPRouter as SynapseCCTPRouterContract } from '../typechain/Syn import { Router } from './router' import { Query, narrowToCCTPRouterQuery, reduceToQuery } from './query' import cctpAbi from '../abi/SynapseCCTP.json' +import { adjustValueIfNative } from '../utils/handleNativeToken' import { getMatchingTxLog } from '../utils/logs' import { BigintIsh } from '../constants' import { @@ -111,13 +112,20 @@ export class SynapseCCTPRouter extends Router { originQuery: Query, destQuery: Query ): Promise { - return this.routerContract.populateTransaction.bridge( - to, - chainId, + const populatedTransaction = + await this.routerContract.populateTransaction.bridge( + to, + chainId, + token, + amount, + narrowToCCTPRouterQuery(originQuery), + narrowToCCTPRouterQuery(destQuery) + ) + // Adjust the tx.value if the token is native + return adjustValueIfNative( + populatedTransaction, token, - amount, - narrowToCCTPRouterQuery(originQuery), - narrowToCCTPRouterQuery(destQuery) + BigNumber.from(amount) ) } diff --git a/packages/sdk-router/src/router/synapseRouter.ts b/packages/sdk-router/src/router/synapseRouter.ts index bde39244df..c34477de03 100644 --- a/packages/sdk-router/src/router/synapseRouter.ts +++ b/packages/sdk-router/src/router/synapseRouter.ts @@ -25,6 +25,7 @@ import { reduceToFeeConfig, reduceToPoolToken, } from './types' +import { adjustValueIfNative } from '../utils/handleNativeToken' import { getMatchingTxLog } from '../utils/logs' /** @@ -139,13 +140,20 @@ export class SynapseRouter extends Router { originQuery: Query, destQuery: Query ): Promise { - return this.routerContract.populateTransaction.bridge( - to, - chainId, + const populatedTransaction = + await this.routerContract.populateTransaction.bridge( + to, + chainId, + token, + amount, + narrowToRouterQuery(originQuery), + narrowToRouterQuery(destQuery) + ) + // Adjust the tx.value if the initial token is native + return adjustValueIfNative( + populatedTransaction, token, - amount, - narrowToRouterQuery(originQuery), - narrowToRouterQuery(destQuery) + BigNumber.from(amount) ) } @@ -250,11 +258,18 @@ export class SynapseRouter extends Router { amount: BigintIsh, query: Query ): Promise { - return this.routerContract.populateTransaction.swap( - to, + const populatedTransaction = + await this.routerContract.populateTransaction.swap( + to, + token, + amount, + narrowToRouterQuery(query) + ) + // Adjust the tx.value if the initial token is native + return adjustValueIfNative( + populatedTransaction, token, - amount, - narrowToRouterQuery(query) + BigNumber.from(amount) ) } } diff --git a/packages/sdk-router/src/sdk.test.ts b/packages/sdk-router/src/sdk.test.ts index 649f56bd35..d904d3f455 100644 --- a/packages/sdk-router/src/sdk.test.ts +++ b/packages/sdk-router/src/sdk.test.ts @@ -24,6 +24,7 @@ import { ETH_USDT, MEDIAN_TIME_BRIDGE, MEDIAN_TIME_CCTP, + NATIVE_ADDRESS, ROUTER_ADDRESS_MAP, getTestProviderUrl, SupportedChainId, @@ -49,11 +50,13 @@ const expectCorrectBridgeQuote = (bridgeQuote: BridgeQuote) => { } const expectCorrectPopulatedTransaction = ( - populatedTransaction: PopulatedTransaction + populatedTransaction: PopulatedTransaction, + expectedValue: BigNumber = Zero ) => { expect(populatedTransaction).toBeDefined() expect(populatedTransaction.data?.length).toBeGreaterThan(0) expect(populatedTransaction.to?.length).toBeGreaterThan(0) + expect(populatedTransaction.value).toEqual(expectedValue) } const createBridgeQuoteTests = ( @@ -74,18 +77,18 @@ const createBridgeQuoteTests = ( }) it('Could be used for bridging', async () => { - synapse - .bridge( - '0x0000000000000000000000000000000000001337', - result.routerAddress, - originChainId, - destChainId, - token, - amount, - result.originQuery, - result.destQuery - ) - .then(expectCorrectPopulatedTransaction) + const expectedValue = token === NATIVE_ADDRESS ? amount : Zero + const data = await synapse.bridge( + '0x0000000000000000000000000000000000001337', + result.routerAddress, + originChainId, + destChainId, + token, + amount, + result.originQuery, + result.destQuery + ) + expectCorrectPopulatedTransaction(data, expectedValue) }) } @@ -109,15 +112,15 @@ const createSwapQuoteTests = ( }) it('Could be used for swapping', async () => { - synapse - .swap( - chainId, - '0x0000000000000000000000000000000000001337', - token, - amount, - result.query - ) - .then(expectCorrectPopulatedTransaction) + const expectedValue = token === NATIVE_ADDRESS ? amount : Zero + const data = await synapse.swap( + chainId, + '0x0000000000000000000000000000000000001337', + token, + amount, + result.query + ) + expectCorrectPopulatedTransaction(data, expectedValue) }) } @@ -351,6 +354,41 @@ describe('SynapseSDK', () => { }) }) }) + + describe('ETH Native -> ARB Native', () => { + const amount = BigNumber.from(10).pow(18) + const resultPromise: Promise = synapse.bridgeQuote( + SupportedChainId.ETH, + SupportedChainId.ARBITRUM, + NATIVE_ADDRESS, + NATIVE_ADDRESS, + amount + ) + + createBridgeQuoteTests( + synapse, + SupportedChainId.ETH, + SupportedChainId.ARBITRUM, + NATIVE_ADDRESS, + amount, + resultPromise + ) + + it('Fetches a Synapse bridge quote', async () => { + resultPromise.then((result) => { + expect(result.routerAddress).toEqual( + ROUTER_ADDRESS_MAP[SupportedChainId.ETH] + ) + // SynapseRouterQuery has swapAdapter property + expect(result.originQuery.swapAdapter).toBeDefined() + // Estimated time must match the SynapseBridge median time + expect(result.estimatedTime).toEqual( + MEDIAN_TIME_BRIDGE[SupportedChainId.ETH] + ) + expect(result.bridgeModuleName).toEqual('SynapseBridge') + }) + }) + }) }) describe('Bridging: AVAX -> BSC', () => { @@ -505,6 +543,41 @@ describe('SynapseSDK', () => { }) }) }) + + describe('ARB Native -> ETH Native', () => { + const amount = BigNumber.from(10).pow(18) + const resultPromise: Promise = synapse.bridgeQuote( + SupportedChainId.ARBITRUM, + SupportedChainId.ETH, + NATIVE_ADDRESS, + NATIVE_ADDRESS, + amount + ) + + createBridgeQuoteTests( + synapse, + SupportedChainId.ETH, + SupportedChainId.ARBITRUM, + NATIVE_ADDRESS, + amount, + resultPromise + ) + + it('Fetches a Synapse bridge quote', async () => { + resultPromise.then((result) => { + expect(result.routerAddress).toEqual( + ROUTER_ADDRESS_MAP[SupportedChainId.ARBITRUM] + ) + // SynapseRouterQuery has swapAdapter property + expect(result.originQuery.swapAdapter).toBeDefined() + // Estimated time must match the SynapseBridge median time + expect(result.estimatedTime).toEqual( + MEDIAN_TIME_BRIDGE[SupportedChainId.ARBITRUM] + ) + expect(result.bridgeModuleName).toEqual('SynapseBridge') + }) + }) + }) }) describe('Bridging: BSC -> AVAX', () => { diff --git a/packages/sdk-router/src/utils/handleNativeToken.ts b/packages/sdk-router/src/utils/handleNativeToken.ts index c530c5e80b..4a4eec3407 100644 --- a/packages/sdk-router/src/utils/handleNativeToken.ts +++ b/packages/sdk-router/src/utils/handleNativeToken.ts @@ -1,4 +1,6 @@ -import { AddressZero } from '@ethersproject/constants' +import { AddressZero, Zero } from '@ethersproject/constants' +import { BigNumber } from '@ethersproject/bignumber' +import { PopulatedTransaction } from '@ethersproject/contracts' export const ETH_NATIVE_TOKEN_ADDRESS = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE' @@ -8,3 +10,26 @@ export const handleNativeToken = (tokenAddr: string) => { ? ETH_NATIVE_TOKEN_ADDRESS : tokenAddr } + +export const isNativeToken = (tokenAddr: string): boolean => { + return tokenAddr.toLowerCase() === ETH_NATIVE_TOKEN_ADDRESS.toLowerCase() +} + +/** + * Sets the tx.value to the amount if the token is native, otherwise sets it to 0. + * + * @param tx - The transaction to adjust. + * @param tokenAddr - The address of the token to check for being native. + * @param amountNative - The amount to set if the token is native. + * @param amountOther - The amount to set if the token is not native (optional, defaults to 0). + * @returns The adjusted populated transaction. + */ +export const adjustValueIfNative = ( + tx: PopulatedTransaction, + tokenAddr: string, + amountNative: BigNumber, + amountOther: BigNumber = Zero +): PopulatedTransaction => { + tx.value = isNativeToken(tokenAddr) ? amountNative : amountOther + return tx +} From 68e84958aa62f6b20d1fa3ab8ff60d2dcfc6f920 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CF=87=C2=B2?= <88190723+ChiTimesChi@users.noreply.github.com> Date: Thu, 21 Dec 2023 20:03:55 +0300 Subject: [PATCH 11/29] SDK: generalize modules (#1691) * Module: generalize Bridge/CCTP/RFQ * ModuleSet: generalize Bridge/CCTP/RFQ sets * Generalize chainId -> Module mapping * Move tx status functions to ModuleSet * Use bridgeModuleName in internal BridgeRoute * Move types around --- packages/sdk-router/src/module/index.ts | 6 + .../src/{router => module}/query.test.ts | 0 .../src/{router => module}/query.ts | 0 .../sdk-router/src/module/synapseModule.ts | 47 +++++++ .../sdk-router/src/module/synapseModuleSet.ts | 121 ++++++++++++++++++ packages/sdk-router/src/module/types.ts | 89 +++++++++++++ packages/sdk-router/src/operations/bridge.ts | 20 +-- packages/sdk-router/src/operations/swap.ts | 2 +- packages/sdk-router/src/router/index.ts | 2 - packages/sdk-router/src/router/router.ts | 23 ++-- packages/sdk-router/src/router/routerSet.ts | 96 +++----------- .../src/router/synapseCCTPRouter.test.ts | 4 +- .../src/router/synapseCCTPRouter.ts | 16 ++- .../src/router/synapseCCTPRouterSet.test.ts | 12 +- .../src/router/synapseCCTPRouterSet.ts | 26 +--- .../src/router/synapseRouter.test.ts | 4 +- .../sdk-router/src/router/synapseRouter.ts | 14 +- .../src/router/synapseRouterSet.test.ts | 10 +- .../sdk-router/src/router/synapseRouterSet.ts | 26 +--- packages/sdk-router/src/router/types.ts | 87 ------------- packages/sdk-router/src/sdk.test.ts | 2 +- packages/sdk-router/src/sdk.ts | 2 +- 22 files changed, 342 insertions(+), 267 deletions(-) create mode 100644 packages/sdk-router/src/module/index.ts rename packages/sdk-router/src/{router => module}/query.test.ts (100%) rename packages/sdk-router/src/{router => module}/query.ts (100%) create mode 100644 packages/sdk-router/src/module/synapseModule.ts create mode 100644 packages/sdk-router/src/module/synapseModuleSet.ts create mode 100644 packages/sdk-router/src/module/types.ts diff --git a/packages/sdk-router/src/module/index.ts b/packages/sdk-router/src/module/index.ts new file mode 100644 index 0000000000..fe108e894f --- /dev/null +++ b/packages/sdk-router/src/module/index.ts @@ -0,0 +1,6 @@ +export * from './query' + +export * from './synapseModule' +export * from './synapseModuleSet' + +export * from './types' diff --git a/packages/sdk-router/src/router/query.test.ts b/packages/sdk-router/src/module/query.test.ts similarity index 100% rename from packages/sdk-router/src/router/query.test.ts rename to packages/sdk-router/src/module/query.test.ts diff --git a/packages/sdk-router/src/router/query.ts b/packages/sdk-router/src/module/query.ts similarity index 100% rename from packages/sdk-router/src/router/query.ts rename to packages/sdk-router/src/module/query.ts diff --git a/packages/sdk-router/src/module/synapseModule.ts b/packages/sdk-router/src/module/synapseModule.ts new file mode 100644 index 0000000000..0a7ef2b728 --- /dev/null +++ b/packages/sdk-router/src/module/synapseModule.ts @@ -0,0 +1,47 @@ +import { PopulatedTransaction } from '@ethersproject/contracts' + +import { Query } from './query' +import { BigintIsh } from '../constants' + +export interface SynapseModule { + readonly address: string + + /** + * Populates the transaction data for a bridge transaction. + * + * @param to - The address to send the bridged tokens to. + * @param destChainId - The ID of the destination chain. + * @param token - The address of the token to bridge. + * @param amount - The amount of tokens to bridge. + * @param originQuery - The Query struct with the information about swap to be executed on the origin chain. + * @param destQuery - The Query struct with the information about swap to be executed on the destination chain. + * @returns A promise that resolves to the populated transaction data. + */ + bridge( + to: string, + destChainId: number, + token: string, + amount: BigintIsh, + originQuery: Query, + destQuery: Query + ): Promise + + /** + * Returns the Synapse transaction ID for a given transaction hash on the current chain. + * This is used to track the status of a bridge transaction originating from the current chain. + * + * @param txHash - The transaction hash of the bridge transaction. + * @returns A promise that resolves to the Synapse transaction ID. + */ + getSynapseTxId(txHash: string): Promise + + /** + * Checks whether a bridge transaction has been completed on the current chain. + * This is used to track the status of a bridge transaction originating from another chain, having + * current chain as the destination chain. + * + * @param synapseTxId - The unique Synapse txId of the bridge transaction. + * @returns A promise that resolves to a boolean indicating whether the bridge transaction has been completed. + */ + getBridgeTxStatus(synapseTxId: string): Promise +} diff --git a/packages/sdk-router/src/module/synapseModuleSet.ts b/packages/sdk-router/src/module/synapseModuleSet.ts new file mode 100644 index 0000000000..6d65b53a85 --- /dev/null +++ b/packages/sdk-router/src/module/synapseModuleSet.ts @@ -0,0 +1,121 @@ +import { BigNumber } from '@ethersproject/bignumber' + +import { BigintIsh } from '../constants' +import { BridgeQuote, BridgeRoute } from './types' +import { SynapseModule } from './synapseModule' + +export abstract class SynapseModuleSet { + abstract readonly bridgeModuleName: string + abstract readonly allEvents: string[] + + /** + * Returns the estimated time for a bridge transaction to be completed, + * when the transaction is sent from the given chain. + * + * @param originChainId - The ID of the origin chain. + * @returns The estimated time in seconds. + * @throws Will throw an error if the chain ID is not supported. + */ + abstract getEstimatedTime(originChainId: number): number + + /** + * Returns the Synapse transaction ID for a given transaction hash on a given chain. + * This is used to track the status of a bridge transaction. + * + * @param originChainId - The ID of the origin chain. + * @param txHash - The transaction hash of the bridge transaction. + * @returns A promise that resolves to the Synapse transaction ID. + */ + getSynapseTxId(originChainId: number, txHash: string): Promise { + return this.getExistingModule(originChainId).getSynapseTxId(txHash) + } + + /** + * Checks whether a bridge transaction has been completed on the destination chain. + * + * @param destChainId - The ID of the destination chain. + * @param synapseTxId - The unique Synapse txId of the bridge transaction. + * @returns A promise that resolves to a boolean indicating whether the bridge transaction has been completed. + */ + getBridgeTxStatus( + destChainId: number, + synapseTxId: string + ): Promise { + return this.getExistingModule(destChainId).getBridgeTxStatus(synapseTxId) + } + + /** + * Returns the existing Module instance on the given chain. + * Returns undefined if a Module instance does not exist on the given chain. + * + * @param chainId - The ID of the chain. + * @returns The Module instance, or undefined if it does not exist. + */ + abstract getModule(chainId: number): SynapseModule | undefined + + /** + * Returns the existing Module instance for the given address on the given chain. + * If the module address is not valid, it will return undefined. + * + * @param chainId - The ID of the chain. + * @param moduleAddress - The address of the module. + * @returns The Module instance, or undefined if the module address is not valid. + */ + getModuleWithAddress( + chainId: number, + moduleAddress: string + ): SynapseModule | undefined { + const module = this.getModule(chainId) + if (module?.address.toLowerCase() === moduleAddress.toLowerCase()) { + return module + } + return undefined + } + + /** + * Returns the existing Module instance for the given chain. + * + * @param chainId - The ID of the chain. + * @returns The Module instance. + * @throws Will throw an error if the module does not exist. + */ + getExistingModule(chainId: number): SynapseModule { + const module = this.getModule(chainId) + if (!module) { + throw new Error(`No module found for chain ${chainId}`) + } + return module + } + + /** + * This method find all possible routes for a bridge transaction between two chains. + * + * @param originChainId - The ID of the original chain. + * @param destChainId - The ID of the destination chain. + * @param tokenIn - The input token. + * @param tokenOut - The output token. + * @param amountIn - The amount of input token. + * + * @returns - A list of BridgeRoute objects with the found routes. + */ + abstract getBridgeRoutes( + originChainId: number, + destChainId: number, + tokenIn: string, + tokenOut: string, + amountIn: BigintIsh + ): Promise + + /** + * Finalizes the bridge route by getting fee data and setting default deadlines. + * + * @param destChainId - The ID of the destination chain. + * @param bridgeRoute - Bridge route to finalize. + * @param deadline - The deadline to use on the origin chain (default 10 mins). + * @returns The finalized quote with fee data and deadlines. + */ + abstract finalizeBridgeRoute( + bridgeRoute: BridgeRoute, + deadline?: BigNumber + ): Promise +} diff --git a/packages/sdk-router/src/module/types.ts b/packages/sdk-router/src/module/types.ts new file mode 100644 index 0000000000..bcb6f823ba --- /dev/null +++ b/packages/sdk-router/src/module/types.ts @@ -0,0 +1,89 @@ +import { BigNumber } from '@ethersproject/bignumber' + +import { Query } from './query' + +/** + * Matches BridgeToken returned by SynapseRouter (V1) and SynapseCCTPRouter. + */ +export type BridgeToken = { + symbol: string + token: string +} + +/** + * Reduces the object to contain only the keys that are present in the BridgeToken type. + */ +export const reduceToBridgeToken = (bridgeToken: BridgeToken): BridgeToken => { + return { + symbol: bridgeToken.symbol, + token: bridgeToken.token, + } +} + +/** + * Fee configuration for a bridge token used in SynapseRouter (V1) and SynapseCCTPRouter. + */ +export type FeeConfig = { + bridgeFee: number + minFee: BigNumber + maxFee: BigNumber +} + +/** + * Reduces the object to contain only the keys that are present in the FeeConfig type. + */ +export const reduceToFeeConfig = (feeConfig: FeeConfig): FeeConfig => { + return { + bridgeFee: feeConfig.bridgeFee, + minFee: feeConfig.minFee, + maxFee: feeConfig.maxFee, + } +} + +/** + * Quote for a swap transaction for SynapseRouter (V1). + * Returned by SDK to the consumer. + */ +export type SwapQuote = { + routerAddress: string + maxAmountOut: BigNumber + query: Query +} + +/** + * Quote for a bridge transaction for SynapseRouter (V1) and SynapseCCTPRouter. + * Returned by SDK to the consumer. + */ +export type BridgeQuote = { + feeAmount: BigNumber + feeConfig: FeeConfig + routerAddress: string + maxAmountOut: BigNumber + originQuery: Query + destQuery: Query + estimatedTime: number + bridgeModuleName: string +} + +/** + * Internal representation of a found bridge route for SynapseRouter (V1) and SynapseCCTPRouter. + */ +export type BridgeRoute = { + originChainId: number + destChainId: number + originQuery: Query + destQuery: Query + bridgeToken: BridgeToken + bridgeModuleName: string +} + +/** + * Finds the best route: the one with the maximum amount out in the destination query. + */ +export const findBestRoute = (bridgeRoutes: BridgeRoute[]): BridgeRoute => { + return bridgeRoutes.reduce((best, current) => { + return current.destQuery.minAmountOut.gt(best.destQuery.minAmountOut) + ? current + : best + }) +} diff --git a/packages/sdk-router/src/operations/bridge.ts b/packages/sdk-router/src/operations/bridge.ts index 3aea7cd4a6..e297674fbd 100644 --- a/packages/sdk-router/src/operations/bridge.ts +++ b/packages/sdk-router/src/operations/bridge.ts @@ -4,7 +4,8 @@ import { BigNumber, PopulatedTransaction } from 'ethers' import { BigintIsh } from '../constants' import { SynapseSDK } from '../sdk' import { handleNativeToken } from '../utils/handleNativeToken' -import { BridgeQuote, Query, RouterSet, findBestRoute } from '../router' +import { BridgeQuote, Query, findBestRoute } from '../module' +import { RouterSet } from '../router' /** * Executes a bridge operation between two different chains. Depending on the origin router address, the operation @@ -42,8 +43,14 @@ export async function bridge( token = handleNativeToken(token) // Get Router instance for given chain and address const router = - this.synapseRouterSet.getRouter(originChainId, originRouterAddress) ?? - this.synapseCCTPRouterSet.getRouter(originChainId, originRouterAddress) + this.synapseRouterSet.getModuleWithAddress( + originChainId, + originRouterAddress + ) ?? + this.synapseCCTPRouterSet.getModuleWithAddress( + originChainId, + originRouterAddress + ) // Throw if Router is not found invariant(router, 'Invalid router address') // Ask the Router to populate the bridge transaction @@ -107,12 +114,7 @@ export async function bridgeQuote( invariant(allRoutes.length > 0, 'No route found') const bestRoute = findBestRoute(allRoutes) // Find the Router Set that yielded the best route - const bestSet: RouterSet = this.synapseRouterSet.getRouter( - originChainId, - bestRoute.originRouterAddress - ) - ? this.synapseRouterSet - : this.synapseCCTPRouterSet + const bestSet: RouterSet = getRouterSet.call(this, bestRoute.bridgeModuleName) // Finalize the Bridge Route return bestSet.finalizeBridgeRoute(bestRoute, deadline) } diff --git a/packages/sdk-router/src/operations/swap.ts b/packages/sdk-router/src/operations/swap.ts index 808bdea9b1..7f74947077 100644 --- a/packages/sdk-router/src/operations/swap.ts +++ b/packages/sdk-router/src/operations/swap.ts @@ -2,7 +2,7 @@ import { PopulatedTransaction } from '@ethersproject/contracts' import { BigNumber } from '@ethersproject/bignumber' import { BigintIsh } from '../constants' -import { Query, SwapQuote } from '../router' +import { Query, SwapQuote } from '../module' import { handleNativeToken } from '../utils/handleNativeToken' import { SynapseSDK } from '../sdk' import { getOriginDeadline } from '../utils/deadlines' diff --git a/packages/sdk-router/src/router/index.ts b/packages/sdk-router/src/router/index.ts index 885ae47029..0a20365d06 100644 --- a/packages/sdk-router/src/router/index.ts +++ b/packages/sdk-router/src/router/index.ts @@ -1,5 +1,3 @@ -export * from './query' - export * from './router' export * from './routerSet' diff --git a/packages/sdk-router/src/router/router.ts b/packages/sdk-router/src/router/router.ts index 29d42ff79d..8432fd534c 100644 --- a/packages/sdk-router/src/router/router.ts +++ b/packages/sdk-router/src/router/router.ts @@ -5,8 +5,9 @@ import invariant from 'tiny-invariant' import { AddressZero } from '@ethersproject/constants' import { BigintIsh } from '../constants' -import { Query } from './query' -import { BridgeToken, DestRequest, FeeConfig } from './types' +import { Query } from '../module/query' +import { DestRequest } from './types' +import { BridgeToken, FeeConfig, SynapseModule } from '../module' /** * Abstract class for a router contract deployed on a chain. @@ -19,7 +20,7 @@ import { BridgeToken, DestRequest, FeeConfig } from './types' * @property chainId The chain ID of chain the router is deployed on. * @property provider The provider used to interact with the chain router is deployed on. */ -export abstract class Router { +export abstract class Router implements SynapseModule { abstract readonly address: string public readonly chainId: number public readonly provider: Provider @@ -52,6 +53,9 @@ export abstract class Router { isSwap: boolean ): Promise<{ feeAmount: BigNumber; feeConfig: FeeConfig }> + /** + * @inheritdoc SynapseModule.bridge + */ abstract bridge( to: string, chainId: number, @@ -62,21 +66,12 @@ export abstract class Router { ): Promise /** - * Returns the Synapse transaction ID for a given transaction hash on the current chain. - * This is used to track the status of a bridge transaction originating from the current chain. - * - * @param txHash - The transaction hash of the bridge transaction. - * @returns A promise that resolves to the Synapse transaction ID. + * @inheritdoc SynapseModule.getSynapseTxId */ abstract getSynapseTxId(txHash: string): Promise /** - * Checks whether a bridge transaction has been completed on the current chain. - * This is used to track the status of a bridge transaction originating from another chain, having - * current chain as the destination chain. - * - * @param synapseTxId - The unique Synapse txId of the bridge transaction. - * @returns A promise that resolves to a boolean indicating whether the bridge transaction has been completed. + * @inheritdoc SynapseModule.getBridgeTxStatus */ abstract getBridgeTxStatus(synapseTxId: string): Promise diff --git a/packages/sdk-router/src/router/routerSet.ts b/packages/sdk-router/src/router/routerSet.ts index 0ff81da1fb..363033f341 100644 --- a/packages/sdk-router/src/router/routerSet.ts +++ b/packages/sdk-router/src/router/routerSet.ts @@ -4,9 +4,15 @@ import invariant from 'tiny-invariant' import { Router } from './router' import { AddressMap, BigintIsh } from '../constants' -import { BridgeQuote, BridgeRoute, DestRequest } from './types' +import { DestRequest } from './types' import { ONE_WEEK, TEN_MINUTES, calculateDeadline } from '../utils/deadlines' -import { hasComplexBridgeAction } from './query' +import { + BridgeQuote, + BridgeRoute, + SynapseModule, + SynapseModuleSet, +} from '../module' +import { hasComplexBridgeAction } from '../module/query' export type ChainProvider = { chainId: number @@ -29,10 +35,7 @@ export type RouterConstructor = new ( * @property routers Collection of Router instances indexed by chainId. * @property providers Collection of Provider instances indexed by chainId. */ -export abstract class RouterSet { - abstract readonly bridgeModuleName: string - abstract readonly allEvents: string[] - +export abstract class RouterSet extends SynapseModuleSet { public routers: { [chainId: number]: Router } @@ -49,6 +52,7 @@ export abstract class RouterSet { addressMap: AddressMap, ctor: RouterConstructor ) { + super() this.routers = {} this.providers = {} chains.forEach(({ chainId, provider }) => { @@ -62,71 +66,14 @@ export abstract class RouterSet { } /** - * Returns the estimated time for a bridge transaction to be completed, - * when the transaction is sent from the given chain. - * - * @param chainId - The ID of the origin chain. - * @returns The estimated time in seconds. - * @throws Will throw an error if the chain ID is not supported. - */ - abstract getEstimatedTime(chainId: number): number - - /** - * Returns the Synapse transaction ID for a given transaction hash on a given chain. - * This is used to track the status of a bridge transaction. - * - * @param originChainId - The ID of the origin chain. - * @param txHash - The transaction hash of the bridge transaction. - * @returns A promise that resolves to the Synapse transaction ID. - */ - abstract getSynapseTxId( - originChainId: number, - txHash: string - ): Promise - - /** - * Checks whether a bridge transaction has been completed on the destination chain. - * - * @param destChainId - The ID of the destination chain. - * @param synapseTxId - The unique Synapse txId of the bridge transaction. - * @returns A promise that resolves to a boolean indicating whether the bridge transaction has been completed. + * @inheritdoc SynapseModuleSet.getModule */ - abstract getBridgeTxStatus( - destChainId: number, - synapseTxId: string - ): Promise - - /** - * Returns the existing Router instance for the given address on the given chain. - * If the router address is not valid, it will return undefined. - * - * @param chainId - The ID of the chain. - * @param routerAddress - The address of the router. - * @returns The Router instance, or undefined if the router address is not valid. - */ - public getRouter(chainId: number, routerAddress: string): Router | undefined { - const router = this.routers[chainId] - // Check if router exists on chain and that router address matches - if (router?.address.toLowerCase() === routerAddress.toLowerCase()) { - return router - } else { - return undefined - } + public getModule(chainId: number): SynapseModule | undefined { + return this.routers[chainId] } /** - * This method find all possible routes for a bridge transaction between two chains. - * It fetches the list of bridge symbols that could be used to complete the bridge transaction. - * For each bridge symbol, it calculates the amount of output token that would be received. - * It then returns all quotes that have a non-zero amount of output token. - * - * @param originChainId - The ID of the original chain. - * @param destChainId - The ID of the destination chain. - * @param tokenIn - The input token. - * @param tokenOut - The output token. - * @param amountIn - The amount of input token. - * - * @returns - A promise that resolves to the best bridge quote, or undefined if no best quote could be determined. + * @inheritdoc SynapseModuleSet.getBridgeRoutes */ public async getBridgeRoutes( originChainId: number, @@ -181,7 +128,7 @@ export abstract class RouterSet { originQuery: originRoute.originQuery, destQuery: destQueries[index], bridgeToken: originRoute.bridgeToken, - originRouterAddress: originRouter.address, + bridgeModuleName: this.bridgeModuleName, }) ) // Return routes with non-zero minAmountOut @@ -198,12 +145,7 @@ export abstract class RouterSet { } /** - * Finalizes the bridge route by getting fee data and setting default deadlines. - * - * @param destChainId - The ID of the destination chain. - * @param bridgeRoute - Bridge route to finalize. - * @param deadline - The deadline to use on the origin chain (default 10 mins). - * @returns The finalized quote with fee data and deadlines. + * @inheritdoc SynapseModuleSet.finalizeBridgeRoute */ public async finalizeBridgeRoute( bridgeRoute: BridgeRoute, @@ -212,6 +154,10 @@ export abstract class RouterSet { const originRouter = this.routers[bridgeRoute.originChainId] const destRouter = this.routers[bridgeRoute.destChainId] invariant(originRouter && destRouter, 'Route not supported') + invariant( + bridgeRoute.bridgeModuleName === this.bridgeModuleName, + 'Invalid bridge module name' + ) const { originQuery, destQuery, bridgeToken } = bridgeRoute // Set origin deadline to 10 mins if not provided originQuery.deadline = deadline ?? calculateDeadline(TEN_MINUTES) @@ -232,7 +178,7 @@ export abstract class RouterSet { originQuery, destQuery, estimatedTime, - bridgeModuleName: this.bridgeModuleName, + bridgeModuleName: bridgeRoute.bridgeModuleName, } } } diff --git a/packages/sdk-router/src/router/synapseCCTPRouter.test.ts b/packages/sdk-router/src/router/synapseCCTPRouter.test.ts index 0a261ed82a..40d33d6dd0 100644 --- a/packages/sdk-router/src/router/synapseCCTPRouter.test.ts +++ b/packages/sdk-router/src/router/synapseCCTPRouter.test.ts @@ -9,8 +9,8 @@ import { ETH_USDC, } from '../constants' import { SynapseCCTPRouter } from './synapseCCTPRouter' -import { CCTPRouterQuery } from './query' -import { BridgeToken, DestRequest } from './types' +import { BridgeToken, CCTPRouterQuery } from '../module' +import { DestRequest } from './types' describe('SynapseCCTPRouter', () => { const ethAddress = CCTP_ROUTER_ADDRESS_MAP[SupportedChainId.ETH] diff --git a/packages/sdk-router/src/router/synapseCCTPRouter.ts b/packages/sdk-router/src/router/synapseCCTPRouter.ts index 366214ebe6..857afa0c38 100644 --- a/packages/sdk-router/src/router/synapseCCTPRouter.ts +++ b/packages/sdk-router/src/router/synapseCCTPRouter.ts @@ -7,17 +7,19 @@ import { BigNumber } from '@ethersproject/bignumber' import cctpRouterAbi from '../abi/SynapseCCTPRouter.json' import { SynapseCCTPRouter as SynapseCCTPRouterContract } from '../typechain/SynapseCCTPRouter' import { Router } from './router' -import { Query, narrowToCCTPRouterQuery, reduceToQuery } from './query' -import cctpAbi from '../abi/SynapseCCTP.json' -import { adjustValueIfNative } from '../utils/handleNativeToken' -import { getMatchingTxLog } from '../utils/logs' -import { BigintIsh } from '../constants' import { BridgeToken, - DestRequest, FeeConfig, + Query, + narrowToCCTPRouterQuery, reduceToBridgeToken, -} from './types' + reduceToQuery, +} from '../module' +import cctpAbi from '../abi/SynapseCCTP.json' +import { adjustValueIfNative } from '../utils/handleNativeToken' +import { getMatchingTxLog } from '../utils/logs' +import { BigintIsh } from '../constants' +import { DestRequest } from './types' /** * Wrapper class for interacting with a SynapseCCTPRouter contract. diff --git a/packages/sdk-router/src/router/synapseCCTPRouterSet.test.ts b/packages/sdk-router/src/router/synapseCCTPRouterSet.test.ts index 9631f779fd..efbacd9047 100644 --- a/packages/sdk-router/src/router/synapseCCTPRouterSet.test.ts +++ b/packages/sdk-router/src/router/synapseCCTPRouterSet.test.ts @@ -95,10 +95,10 @@ describe('SynapseCCTPRouterSet', () => { }) }) - describe('getRouter', () => { + describe('getModuleWithAddress', () => { it('Returns the correct router given correct address', () => { expect( - routerSet.getRouter( + routerSet.getModuleWithAddress( SupportedChainId.ETH, CCTP_ROUTER_ADDRESS_MAP[SupportedChainId.ETH] ) @@ -107,7 +107,7 @@ describe('SynapseCCTPRouterSet', () => { it('Returns undefined given incorrect address', () => { expect( - routerSet.getRouter( + routerSet.getModuleWithAddress( SupportedChainId.ETH, ROUTER_ADDRESS_MAP[SupportedChainId.ETH] ) @@ -116,7 +116,7 @@ describe('SynapseCCTPRouterSet', () => { it('Returns undefined given unknown chainId', () => { expect( - routerSet.getRouter( + routerSet.getModuleWithAddress( SupportedChainId.AVALANCHE, ROUTER_ADDRESS_MAP[SupportedChainId.ETH] ) @@ -125,7 +125,7 @@ describe('SynapseCCTPRouterSet', () => { it('Returns undefined given chainId without CCTP', () => { expect( - routerSet.getRouter( + routerSet.getModuleWithAddress( SupportedChainId.MOONBEAM, CCTP_ROUTER_ADDRESS_MAP[SupportedChainId.ETH] ) @@ -143,7 +143,7 @@ describe('SynapseCCTPRouterSet', () => { it('Throws error for unsupported chain', () => { expect(() => routerSet.getSynapseCCTPRouter(SupportedChainId.AVALANCHE) - ).toThrow('No SynapseCCTPRouter deployed on chain 43114') + ).toThrow('No module found for chain 43114') }) }) diff --git a/packages/sdk-router/src/router/synapseCCTPRouterSet.ts b/packages/sdk-router/src/router/synapseCCTPRouterSet.ts index 5f2498d9c6..65cd4374f9 100644 --- a/packages/sdk-router/src/router/synapseCCTPRouterSet.ts +++ b/packages/sdk-router/src/router/synapseCCTPRouterSet.ts @@ -28,36 +28,12 @@ export class SynapseCCTPRouterSet extends RouterSet { return medianTime } - /** - * @inheritdoc RouterSet.getSynapseTxId - */ - public async getSynapseTxId( - originChainId: number, - txHash: string - ): Promise { - return this.getSynapseCCTPRouter(originChainId).getSynapseTxId(txHash) - } - - /** - * @inheritdoc RouterSet.getBridgeTxStatus - */ - public async getBridgeTxStatus( - destChainId: number, - synapseTxId: string - ): Promise { - return this.getSynapseCCTPRouter(destChainId).getBridgeTxStatus(synapseTxId) - } - /** * Returns the existing SynapseCCTPRouter instance for the given chain. * * @throws Will throw an error if SynapseCCTPRouter is not deployed on the given chain. */ public getSynapseCCTPRouter(chainId: number): SynapseCCTPRouter { - invariant( - this.routers[chainId], - `No SynapseCCTPRouter deployed on chain ${chainId}` - ) - return this.routers[chainId] as SynapseCCTPRouter + return this.getExistingModule(chainId) as SynapseCCTPRouter } } diff --git a/packages/sdk-router/src/router/synapseRouter.test.ts b/packages/sdk-router/src/router/synapseRouter.test.ts index 50597cde04..1ccb5fcd59 100644 --- a/packages/sdk-router/src/router/synapseRouter.test.ts +++ b/packages/sdk-router/src/router/synapseRouter.test.ts @@ -10,8 +10,8 @@ import { SupportedChainId, } from '../constants' import { SynapseRouter } from './synapseRouter' -import { RouterQuery } from './query' -import { BridgeToken, DestRequest } from './types' +import { BridgeToken, RouterQuery } from '../module' +import { DestRequest } from './types' describe('SynapseRouter', () => { const ethAddress = ROUTER_ADDRESS_MAP[SupportedChainId.ETH] diff --git a/packages/sdk-router/src/router/synapseRouter.ts b/packages/sdk-router/src/router/synapseRouter.ts index c34477de03..1b23875e49 100644 --- a/packages/sdk-router/src/router/synapseRouter.ts +++ b/packages/sdk-router/src/router/synapseRouter.ts @@ -11,18 +11,22 @@ import { PoolStructOutput, } from '../typechain/SynapseRouter' import { Router } from './router' -import { Query, narrowToRouterQuery, reduceToQuery } from './query' +import { + BridgeToken, + FeeConfig, + Query, + narrowToRouterQuery, + reduceToBridgeToken, + reduceToFeeConfig, + reduceToQuery, +} from '../module' import bridgeAbi from '../abi/SynapseBridge.json' import { BigintIsh } from '../constants' import { - BridgeToken, DestRequest, - FeeConfig, Pool, PoolInfo, PoolToken, - reduceToBridgeToken, - reduceToFeeConfig, reduceToPoolToken, } from './types' import { adjustValueIfNative } from '../utils/handleNativeToken' diff --git a/packages/sdk-router/src/router/synapseRouterSet.test.ts b/packages/sdk-router/src/router/synapseRouterSet.test.ts index 20806b31a4..3de5ae0363 100644 --- a/packages/sdk-router/src/router/synapseRouterSet.test.ts +++ b/packages/sdk-router/src/router/synapseRouterSet.test.ts @@ -76,10 +76,10 @@ describe('SynapseRouterSet', () => { }) }) - describe('getRouter', () => { + describe('getModuleWithAddress', () => { it('Returns the correct router given correct address', () => { expect( - routerSet.getRouter( + routerSet.getModuleWithAddress( SupportedChainId.ETH, ROUTER_ADDRESS_MAP[SupportedChainId.ETH] ) @@ -88,7 +88,7 @@ describe('SynapseRouterSet', () => { it('Returns undefined given incorrect address', () => { expect( - routerSet.getRouter( + routerSet.getModuleWithAddress( SupportedChainId.ETH, CCTP_ROUTER_ADDRESS_MAP[SupportedChainId.ETH] ) @@ -97,7 +97,7 @@ describe('SynapseRouterSet', () => { it('Returns undefined given unknown chainId', () => { expect( - routerSet.getRouter( + routerSet.getModuleWithAddress( SupportedChainId.AVALANCHE, ROUTER_ADDRESS_MAP[SupportedChainId.ETH] ) @@ -115,7 +115,7 @@ describe('SynapseRouterSet', () => { it('Throws error for unsupported chain', () => { expect(() => routerSet.getSynapseRouter(SupportedChainId.AVALANCHE) - ).toThrow('No SynapseRouter deployed on chain 43114') + ).toThrow('No module found for chain 43114') }) }) diff --git a/packages/sdk-router/src/router/synapseRouterSet.ts b/packages/sdk-router/src/router/synapseRouterSet.ts index b84f21b7e2..7ea8c2bef0 100644 --- a/packages/sdk-router/src/router/synapseRouterSet.ts +++ b/packages/sdk-router/src/router/synapseRouterSet.ts @@ -36,36 +36,12 @@ export class SynapseRouterSet extends RouterSet { return medianTime } - /** - * @inheritdoc RouterSet.getSynapseTxId - */ - public async getSynapseTxId( - originChainId: number, - txHash: string - ): Promise { - return this.getSynapseRouter(originChainId).getSynapseTxId(txHash) - } - - /** - * @inheritdoc RouterSet.getBridgeTxStatus - */ - public async getBridgeTxStatus( - destChainId: number, - synapseTxId: string - ): Promise { - return this.getSynapseRouter(destChainId).getBridgeTxStatus(synapseTxId) - } - /** * Returns the existing SynapseRouter instance for the given chain. * * @throws Will throw an error if SynapseRouter is not deployed on the given chain. */ public getSynapseRouter(chainId: number): SynapseRouter { - invariant( - this.routers[chainId], - `No SynapseRouter deployed on chain ${chainId}` - ) - return this.routers[chainId] as SynapseRouter + return this.getExistingModule(chainId) as SynapseRouter } } diff --git a/packages/sdk-router/src/router/types.ts b/packages/sdk-router/src/router/types.ts index d1ef975872..e3c9d358b2 100644 --- a/packages/sdk-router/src/router/types.ts +++ b/packages/sdk-router/src/router/types.ts @@ -1,25 +1,6 @@ import { BigNumber } from '@ethersproject/bignumber' import { BigintIsh } from '../constants' -import { Query } from './query' - -/** - * Matches BridgeToken returned by SynapseRouter (V1) and SynapseCCTPRouter. - */ -export type BridgeToken = { - symbol: string - token: string -} - -/** - * Reduces the object to contain only the keys that are present in the BridgeToken type. - */ -export const reduceToBridgeToken = (bridgeToken: BridgeToken): BridgeToken => { - return { - symbol: bridgeToken.symbol, - token: bridgeToken.token, - } -} /** * Matches DestRequest passed to SynapseRouter (V1) and SynapseCCTPRouter. @@ -29,74 +10,6 @@ export type DestRequest = { amountIn: BigintIsh } -/** - * Fee configuration for a bridge token used in SynapseRouter (V1) and SynapseCCTPRouter. - */ -export type FeeConfig = { - bridgeFee: number - minFee: BigNumber - maxFee: BigNumber -} - -/** - * Reduces the object to contain only the keys that are present in the FeeConfig type. - */ -export const reduceToFeeConfig = (feeConfig: FeeConfig): FeeConfig => { - return { - bridgeFee: feeConfig.bridgeFee, - minFee: feeConfig.minFee, - maxFee: feeConfig.maxFee, - } -} - -/** - * Quote for a swap transaction for SynapseRouter (V1). - * Returned by SDK to the consumer. - */ -export type SwapQuote = { - routerAddress: string - maxAmountOut: BigNumber - query: Query -} - -/** - * Quote for a bridge transaction for SynapseRouter (V1) and SynapseCCTPRouter. - * Returned by SDK to the consumer. - */ -export type BridgeQuote = { - feeAmount: BigNumber - feeConfig: FeeConfig - routerAddress: string - maxAmountOut: BigNumber - originQuery: Query - destQuery: Query - estimatedTime: number - bridgeModuleName: string -} - -/** - * Internal representation of a found bridge route for SynapseRouter (V1) and SynapseCCTPRouter. - */ -export type BridgeRoute = { - originChainId: number - destChainId: number - originQuery: Query - destQuery: Query - bridgeToken: BridgeToken - originRouterAddress: string -} - -/** - * Finds the best route: the one with the maximum amount out in the destination query. - */ -export const findBestRoute = (bridgeRoutes: BridgeRoute[]): BridgeRoute => { - return bridgeRoutes.reduce((best, current) => { - return current.destQuery.minAmountOut.gt(best.destQuery.minAmountOut) - ? current - : best - }) -} - export type PoolToken = { isWeth: boolean; token: string } /** diff --git a/packages/sdk-router/src/sdk.test.ts b/packages/sdk-router/src/sdk.test.ts index d904d3f455..32e8597fed 100644 --- a/packages/sdk-router/src/sdk.test.ts +++ b/packages/sdk-router/src/sdk.test.ts @@ -29,7 +29,7 @@ import { getTestProviderUrl, SupportedChainId, } from './constants' -import { BridgeQuote, FeeConfig, RouterQuery, SwapQuote } from './router' +import { BridgeQuote, FeeConfig, RouterQuery, SwapQuote } from './module' import * as operations from './operations' const expectCorrectFeeConfig = (feeConfig: FeeConfig) => { diff --git a/packages/sdk-router/src/sdk.ts b/packages/sdk-router/src/sdk.ts index dfde1e2a55..a6de2bee64 100644 --- a/packages/sdk-router/src/sdk.ts +++ b/packages/sdk-router/src/sdk.ts @@ -5,11 +5,11 @@ import { SynapseRouterSet, SynapseCCTPRouterSet, ChainProvider, - Query, PoolToken, } from './router' import * as operations from './operations' import { ETH_NATIVE_TOKEN_ADDRESS } from './utils/handleNativeToken' +import { Query } from './module' class SynapseSDK { public synapseRouterSet: SynapseRouterSet From 1ed8c432022daa8b819019273cf6d6005a9def95 Mon Sep 17 00:00:00 2001 From: ChiTimesChi Date: Thu, 21 Dec 2023 17:06:20 +0000 Subject: [PATCH 12/29] Publish - @synapsecns/rest-api@1.0.30 - @synapsecns/sdk-router@0.3.3 - @synapsecns/synapse-interface@0.1.211 --- packages/rest-api/CHANGELOG.md | 8 ++++++++ packages/rest-api/package.json | 4 ++-- packages/sdk-router/CHANGELOG.md | 8 ++++++++ packages/sdk-router/package.json | 2 +- packages/synapse-interface/CHANGELOG.md | 8 ++++++++ packages/synapse-interface/package.json | 4 ++-- 6 files changed, 29 insertions(+), 5 deletions(-) diff --git a/packages/rest-api/CHANGELOG.md b/packages/rest-api/CHANGELOG.md index 2bb914b380..11308bf911 100644 --- a/packages/rest-api/CHANGELOG.md +++ b/packages/rest-api/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.30](https://github.com/synapsecns/sanguine/compare/@synapsecns/rest-api@1.0.29...@synapsecns/rest-api@1.0.30) (2023-12-21) + +**Note:** Version bump only for package @synapsecns/rest-api + + + + + ## [1.0.29](https://github.com/synapsecns/sanguine/compare/@synapsecns/rest-api@1.0.28...@synapsecns/rest-api@1.0.29) (2023-12-21) **Note:** Version bump only for package @synapsecns/rest-api diff --git a/packages/rest-api/package.json b/packages/rest-api/package.json index 383d4619e7..4e5e036f04 100644 --- a/packages/rest-api/package.json +++ b/packages/rest-api/package.json @@ -1,6 +1,6 @@ { "name": "@synapsecns/rest-api", - "version": "1.0.29", + "version": "1.0.30", "private": "true", "engines": { "node": ">=16.0.0" @@ -23,7 +23,7 @@ "@ethersproject/bignumber": "^5.7.0", "@ethersproject/providers": "^5.7.2", "@ethersproject/units": "5.7.0", - "@synapsecns/sdk-router": "^0.3.2", + "@synapsecns/sdk-router": "^0.3.3", "bignumber": "^1.1.0", "ethers": "5.7.2", "express": "^4.18.2", diff --git a/packages/sdk-router/CHANGELOG.md b/packages/sdk-router/CHANGELOG.md index bbec231af9..443a0d8488 100644 --- a/packages/sdk-router/CHANGELOG.md +++ b/packages/sdk-router/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.3.3](https://github.com/synapsecns/sanguine/compare/@synapsecns/sdk-router@0.3.2...@synapsecns/sdk-router@0.3.3) (2023-12-21) + +**Note:** Version bump only for package @synapsecns/sdk-router + + + + + ## [0.3.2](https://github.com/synapsecns/sanguine/compare/@synapsecns/sdk-router@0.3.1...@synapsecns/sdk-router@0.3.2) (2023-12-21) **Note:** Version bump only for package @synapsecns/sdk-router diff --git a/packages/sdk-router/package.json b/packages/sdk-router/package.json index 892c8d7187..1c066ca020 100644 --- a/packages/sdk-router/package.json +++ b/packages/sdk-router/package.json @@ -1,7 +1,7 @@ { "name": "@synapsecns/sdk-router", "description": "An SDK for interacting with the Synapse Protocol", - "version": "0.3.2", + "version": "0.3.3", "license": "MIT", "main": "dist/index.js", "typings": "dist/index.d.ts", diff --git a/packages/synapse-interface/CHANGELOG.md b/packages/synapse-interface/CHANGELOG.md index 4b8a412d30..89c0438166 100644 --- a/packages/synapse-interface/CHANGELOG.md +++ b/packages/synapse-interface/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.1.211](https://github.com/synapsecns/sanguine/compare/@synapsecns/synapse-interface@0.1.210...@synapsecns/synapse-interface@0.1.211) (2023-12-21) + +**Note:** Version bump only for package @synapsecns/synapse-interface + + + + + ## [0.1.210](https://github.com/synapsecns/sanguine/compare/@synapsecns/synapse-interface@0.1.209...@synapsecns/synapse-interface@0.1.210) (2023-12-21) **Note:** Version bump only for package @synapsecns/synapse-interface diff --git a/packages/synapse-interface/package.json b/packages/synapse-interface/package.json index 32945244f2..a1539112af 100644 --- a/packages/synapse-interface/package.json +++ b/packages/synapse-interface/package.json @@ -1,6 +1,6 @@ { "name": "@synapsecns/synapse-interface", - "version": "0.1.210", + "version": "0.1.211", "private": true, "engines": { "node": ">=16.0.0" @@ -42,7 +42,7 @@ "@reduxjs/toolkit": "^1.9.5", "@rtk-query/graphql-request-base-query": "^2.2.0", "@segment/analytics-next": "^1.53.0", - "@synapsecns/sdk-router": "^0.3.2", + "@synapsecns/sdk-router": "^0.3.3", "@tailwindcss/aspect-ratio": "^0.4.2", "@tailwindcss/forms": "^0.5.3", "@tailwindcss/line-clamp": "^0.4.2", From 61947fe1cb43715f28f4fc48e5d0b6df0a69cc14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CF=87=C2=B2?= <88190723+ChiTimesChi@users.noreply.github.com> Date: Fri, 22 Dec 2023 14:04:30 +0300 Subject: [PATCH 13/29] SDK: fix exclude cctp tests (#1702) * Chore: clean up promise resolution * Fix excludeCCTP flag tests --- packages/sdk-router/src/sdk.test.ts | 388 ++++++++++++++-------------- 1 file changed, 188 insertions(+), 200 deletions(-) diff --git a/packages/sdk-router/src/sdk.test.ts b/packages/sdk-router/src/sdk.test.ts index 32e8597fed..80efc869ca 100644 --- a/packages/sdk-router/src/sdk.test.ts +++ b/packages/sdk-router/src/sdk.test.ts @@ -240,121 +240,6 @@ describe('SynapseSDK', () => { ) }) - describe('ETH USDC -> ARB USDT (excludeCCTP flag omitted)', () => { - // Try to find ETH USDC -> ARB USDT quote for 1M USDC, - // which by default is routed through USDC - const amount = BigNumber.from(10).pow(12) - const resultPromise: Promise = synapse.bridgeQuote( - SupportedChainId.ETH, - SupportedChainId.ARBITRUM, - ETH_USDC, - ARB_USDT, - amount - ) - - createBridgeQuoteTests( - synapse, - SupportedChainId.ETH, - SupportedChainId.ARBITRUM, - ETH_USDC, - amount, - resultPromise - ) - - it('Fetches a CCTP bridge quote', async () => { - resultPromise.then((result) => { - expect(result.routerAddress).toEqual( - CCTP_ROUTER_ADDRESS_MAP[SupportedChainId.ETH] - ) - // SynapseCCTPRouterQuery has routerAdapter property - expect(result.originQuery.routerAdapter).toBeDefined() - // Estimated time must match the SynapseCCTP median time - expect(result.estimatedTime).toEqual( - MEDIAN_TIME_CCTP[SupportedChainId.ETH] - ) - expect(result.bridgeModuleName).toEqual('SynapseCCTP') - }) - }) - }) - - describe('ETH USDC -> ARB USDT (excludeCCTP flag off)', () => { - // Try to find ETH USDC -> ARB USDT quote for 1M USDC, - // which by default is routed through USDC - const amount = BigNumber.from(10).pow(12) - const resultPromise: Promise = synapse.bridgeQuote( - SupportedChainId.ETH, - SupportedChainId.ARBITRUM, - ETH_USDC, - ARB_USDT, - amount, - undefined, - false - ) - - createBridgeQuoteTests( - synapse, - SupportedChainId.ETH, - SupportedChainId.ARBITRUM, - ETH_USDC, - amount, - resultPromise - ) - - it('Fetches a CCTP bridge quote', async () => { - resultPromise.then((result) => { - expect(result.routerAddress).toEqual( - CCTP_ROUTER_ADDRESS_MAP[SupportedChainId.ETH] - ) - // SynapseCCTPRouterQuery has routerAdapter property - expect(result.originQuery.routerAdapter).toBeDefined() - // Estimated time must match the SynapseCCTP median time - expect(result.estimatedTime).toEqual( - MEDIAN_TIME_CCTP[SupportedChainId.ETH] - ) - expect(result.bridgeModuleName).toEqual('SynapseCCTP') - }) - }) - }) - - describe('ETH USDC -> ARB USDT (excludeCCTP flag on)', () => { - // Try to find ETH USDC -> ARB USDT quote for 1M USDC, - // which by default is routed through USDC - const amount = BigNumber.from(10).pow(12) - const resultPromise: Promise = synapse.bridgeQuote( - SupportedChainId.ETH, - SupportedChainId.ARBITRUM, - ETH_USDC, - ARB_USDT, - amount, - undefined, - true - ) - - createBridgeQuoteTests( - synapse, - SupportedChainId.ETH, - SupportedChainId.ARBITRUM, - ETH_USDC, - amount, - resultPromise - ) - - it('Fetches a Synapse bridge quote', async () => { - resultPromise.then((result) => { - expect(result.routerAddress).toEqual( - ROUTER_ADDRESS_MAP[SupportedChainId.ETH] - ) - // SynapseRouterQuery has swapAdapter property - expect(result.originQuery.swapAdapter).toBeDefined() - // Estimated time must match the SynapseBridge median time - expect(result.estimatedTime).toEqual( - MEDIAN_TIME_BRIDGE[SupportedChainId.ETH] - ) - expect(result.bridgeModuleName).toEqual('SynapseBridge') - }) - }) - }) - describe('ETH Native -> ARB Native', () => { const amount = BigNumber.from(10).pow(18) const resultPromise: Promise = synapse.bridgeQuote( @@ -375,18 +260,17 @@ describe('SynapseSDK', () => { ) it('Fetches a Synapse bridge quote', async () => { - resultPromise.then((result) => { - expect(result.routerAddress).toEqual( - ROUTER_ADDRESS_MAP[SupportedChainId.ETH] - ) - // SynapseRouterQuery has swapAdapter property - expect(result.originQuery.swapAdapter).toBeDefined() - // Estimated time must match the SynapseBridge median time - expect(result.estimatedTime).toEqual( - MEDIAN_TIME_BRIDGE[SupportedChainId.ETH] - ) - expect(result.bridgeModuleName).toEqual('SynapseBridge') - }) + const result = await resultPromise + expect(result.routerAddress).toEqual( + ROUTER_ADDRESS_MAP[SupportedChainId.ETH] + ) + // SynapseRouterQuery has swapAdapter property + expect(result.originQuery.swapAdapter).toBeDefined() + // Estimated time must match the SynapseBridge median time + expect(result.estimatedTime).toEqual( + MEDIAN_TIME_BRIDGE[SupportedChainId.ETH] + ) + expect(result.bridgeModuleName).toEqual('SynapseBridge') }) }) }) @@ -417,18 +301,17 @@ describe('SynapseSDK', () => { ) it('Fetches a Synapse bridge quote', async () => { - resultPromise.then((result) => { - expect(result.routerAddress).toEqual( - ROUTER_ADDRESS_MAP[SupportedChainId.AVALANCHE] - ) - // SynapseRouterQuery has swapAdapter property - expect(result.originQuery.swapAdapter).toBeDefined() - // Estimated time must match the SynapseBridge median time - expect(result.estimatedTime).toEqual( - MEDIAN_TIME_BRIDGE[SupportedChainId.AVALANCHE] - ) - expect(result.bridgeModuleName).toEqual('SynapseBridge') - }) + const result = await resultPromise + expect(result.routerAddress).toEqual( + ROUTER_ADDRESS_MAP[SupportedChainId.AVALANCHE] + ) + // SynapseRouterQuery has swapAdapter property + expect(result.originQuery.swapAdapter).toBeDefined() + // Estimated time must match the SynapseBridge median time + expect(result.estimatedTime).toEqual( + MEDIAN_TIME_BRIDGE[SupportedChainId.AVALANCHE] + ) + expect(result.bridgeModuleName).toEqual('SynapseBridge') }) }) @@ -452,18 +335,17 @@ describe('SynapseSDK', () => { ) it('Fetches a Synapse bridge quote', async () => { - resultPromise.then((result) => { - expect(result.routerAddress).toEqual( - ROUTER_ADDRESS_MAP[SupportedChainId.AVALANCHE] - ) - // SynapseRouterQuery has swapAdapter property - expect(result.originQuery.swapAdapter).toBeDefined() - // Estimated time must match the SynapseBridge median time - expect(result.estimatedTime).toEqual( - MEDIAN_TIME_BRIDGE[SupportedChainId.AVALANCHE] - ) - expect(result.bridgeModuleName).toEqual('SynapseBridge') - }) + const result = await resultPromise + expect(result.routerAddress).toEqual( + ROUTER_ADDRESS_MAP[SupportedChainId.AVALANCHE] + ) + // SynapseRouterQuery has swapAdapter property + expect(result.originQuery.swapAdapter).toBeDefined() + // Estimated time must match the SynapseBridge median time + expect(result.estimatedTime).toEqual( + MEDIAN_TIME_BRIDGE[SupportedChainId.AVALANCHE] + ) + expect(result.bridgeModuleName).toEqual('SynapseBridge') }) }) }) @@ -494,18 +376,17 @@ describe('SynapseSDK', () => { ) it('Fetches a Synapse bridge quote', async () => { - resultPromise.then((result) => { - expect(result.routerAddress).toEqual( - ROUTER_ADDRESS_MAP[SupportedChainId.ARBITRUM] - ) - // SynapseRouterQuery has swapAdapter property - expect(result.originQuery.swapAdapter).toBeDefined() - // Estimated time must match the SynapseBridge median time - expect(result.estimatedTime).toEqual( - MEDIAN_TIME_BRIDGE[SupportedChainId.ARBITRUM] - ) - expect(result.bridgeModuleName).toEqual('SynapseBridge') - }) + const result = await resultPromise + expect(result.routerAddress).toEqual( + ROUTER_ADDRESS_MAP[SupportedChainId.ARBITRUM] + ) + // SynapseRouterQuery has swapAdapter property + expect(result.originQuery.swapAdapter).toBeDefined() + // Estimated time must match the SynapseBridge median time + expect(result.estimatedTime).toEqual( + MEDIAN_TIME_BRIDGE[SupportedChainId.ARBITRUM] + ) + expect(result.bridgeModuleName).toEqual('SynapseBridge') }) }) @@ -529,7 +410,82 @@ describe('SynapseSDK', () => { ) it('Fetches a CCTP bridge quote', async () => { - resultPromise.then((result) => { + const result = await resultPromise + expect(result.routerAddress).toEqual( + CCTP_ROUTER_ADDRESS_MAP[SupportedChainId.ARBITRUM] + ) + // SynapseCCTPRouterQuery has routerAdapter property + expect(result.originQuery.routerAdapter).toBeDefined() + // Estimated time must match the SynapseCCTP median time + expect(result.estimatedTime).toEqual( + MEDIAN_TIME_CCTP[SupportedChainId.ARBITRUM] + ) + expect(result.bridgeModuleName).toEqual('SynapseCCTP') + }) + }) + + describe('ARB USDT -> ETH USDC (excludeCCTP flag tests)', () => { + // Use $1000 USDT as amount. SynapseCCTP requires less gas on Ethereum to be completed, + // when USDC is used as a tokenOut (compared to SynapseBridge route). + // Therefore we can expect that the min fees would be lower. Meaning for amount this low, + // we should get a CCTP quote unless we explicitly exclude CCTP. + const amount = BigNumber.from(10).pow(9) + + describe('excludeCCTP flag omitted', () => { + const resultPromise: Promise = synapse.bridgeQuote( + SupportedChainId.ARBITRUM, + SupportedChainId.ETH, + ARB_USDT, + ETH_USDC, + amount + ) + + createBridgeQuoteTests( + synapse, + SupportedChainId.ETH, + SupportedChainId.ARBITRUM, + ETH_USDC, + amount, + resultPromise + ) + + it('Fetches a CCTP bridge quote', async () => { + const result = await resultPromise + expect(result.routerAddress).toEqual( + CCTP_ROUTER_ADDRESS_MAP[SupportedChainId.ARBITRUM] + ) + // SynapseCCTPRouterQuery has routerAdapter property + expect(result.originQuery.routerAdapter).toBeDefined() + // Estimated time must match the SynapseCCTP median time + expect(result.estimatedTime).toEqual( + MEDIAN_TIME_CCTP[SupportedChainId.ARBITRUM] + ) + expect(result.bridgeModuleName).toEqual('SynapseCCTP') + }) + }) + + describe('excludeCCTP flag off', () => { + const resultPromise: Promise = synapse.bridgeQuote( + SupportedChainId.ARBITRUM, + SupportedChainId.ETH, + ARB_USDT, + ETH_USDC, + amount, + undefined, + false + ) + + createBridgeQuoteTests( + synapse, + SupportedChainId.ETH, + SupportedChainId.ARBITRUM, + ETH_USDC, + amount, + resultPromise + ) + + it('Fetches a CCTP bridge quote', async () => { + const result = await resultPromise expect(result.routerAddress).toEqual( CCTP_ROUTER_ADDRESS_MAP[SupportedChainId.ARBITRUM] ) @@ -542,6 +498,41 @@ describe('SynapseSDK', () => { expect(result.bridgeModuleName).toEqual('SynapseCCTP') }) }) + + describe('excludeCCTP flag on', () => { + const resultPromise: Promise = synapse.bridgeQuote( + SupportedChainId.ARBITRUM, + SupportedChainId.ETH, + ARB_USDT, + ETH_USDC, + amount, + undefined, + true + ) + + createBridgeQuoteTests( + synapse, + SupportedChainId.ETH, + SupportedChainId.ARBITRUM, + ETH_USDC, + amount, + resultPromise + ) + + it('Fetches a Synapse bridge quote', async () => { + const result = await resultPromise + expect(result.routerAddress).toEqual( + ROUTER_ADDRESS_MAP[SupportedChainId.ARBITRUM] + ) + // SynapseRouterQuery has swapAdapter property + expect(result.originQuery.swapAdapter).toBeDefined() + // Estimated time must match the SynapseBridge median time + expect(result.estimatedTime).toEqual( + MEDIAN_TIME_BRIDGE[SupportedChainId.ARBITRUM] + ) + expect(result.bridgeModuleName).toEqual('SynapseBridge') + }) + }) }) describe('ARB Native -> ETH Native', () => { @@ -564,18 +555,17 @@ describe('SynapseSDK', () => { ) it('Fetches a Synapse bridge quote', async () => { - resultPromise.then((result) => { - expect(result.routerAddress).toEqual( - ROUTER_ADDRESS_MAP[SupportedChainId.ARBITRUM] - ) - // SynapseRouterQuery has swapAdapter property - expect(result.originQuery.swapAdapter).toBeDefined() - // Estimated time must match the SynapseBridge median time - expect(result.estimatedTime).toEqual( - MEDIAN_TIME_BRIDGE[SupportedChainId.ARBITRUM] - ) - expect(result.bridgeModuleName).toEqual('SynapseBridge') - }) + const result = await resultPromise + expect(result.routerAddress).toEqual( + ROUTER_ADDRESS_MAP[SupportedChainId.ARBITRUM] + ) + // SynapseRouterQuery has swapAdapter property + expect(result.originQuery.swapAdapter).toBeDefined() + // Estimated time must match the SynapseBridge median time + expect(result.estimatedTime).toEqual( + MEDIAN_TIME_BRIDGE[SupportedChainId.ARBITRUM] + ) + expect(result.bridgeModuleName).toEqual('SynapseBridge') }) }) }) @@ -607,18 +597,17 @@ describe('SynapseSDK', () => { ) it('Fetches a Synapse bridge quote', async () => { - resultPromise.then((result) => { - expect(result.routerAddress).toEqual( - ROUTER_ADDRESS_MAP[SupportedChainId.BSC] - ) - // SynapseRouterQuery has swapAdapter property - expect(result.originQuery.swapAdapter).toBeDefined() - // Estimated time must match the SynapseBridge median time - expect(result.estimatedTime).toEqual( - MEDIAN_TIME_BRIDGE[SupportedChainId.BSC] - ) - expect(result.bridgeModuleName).toEqual('SynapseBridge') - }) + const result = await resultPromise + expect(result.routerAddress).toEqual( + ROUTER_ADDRESS_MAP[SupportedChainId.BSC] + ) + // SynapseRouterQuery has swapAdapter property + expect(result.originQuery.swapAdapter).toBeDefined() + // Estimated time must match the SynapseBridge median time + expect(result.estimatedTime).toEqual( + MEDIAN_TIME_BRIDGE[SupportedChainId.BSC] + ) + expect(result.bridgeModuleName).toEqual('SynapseBridge') }) }) @@ -642,18 +631,17 @@ describe('SynapseSDK', () => { ) it('Fetches a Synapse bridge quote', async () => { - resultPromise.then((result) => { - expect(result.routerAddress).toEqual( - ROUTER_ADDRESS_MAP[SupportedChainId.BSC] - ) - // SynapseRouterQuery has swapAdapter property - expect(result.originQuery.swapAdapter).toBeDefined() - // Estimated time must match the SynapseBridge median time - expect(result.estimatedTime).toEqual( - MEDIAN_TIME_BRIDGE[SupportedChainId.BSC] - ) - expect(result.bridgeModuleName).toEqual('SynapseBridge') - }) + const result = await resultPromise + expect(result.routerAddress).toEqual( + ROUTER_ADDRESS_MAP[SupportedChainId.BSC] + ) + // SynapseRouterQuery has swapAdapter property + expect(result.originQuery.swapAdapter).toBeDefined() + // Estimated time must match the SynapseBridge median time + expect(result.estimatedTime).toEqual( + MEDIAN_TIME_BRIDGE[SupportedChainId.BSC] + ) + expect(result.bridgeModuleName).toEqual('SynapseBridge') }) }) }) From d5aff40429dbe5d14c2f7dedae1241d9c828961d Mon Sep 17 00:00:00 2001 From: ChiTimesChi Date: Fri, 22 Dec 2023 11:07:36 +0000 Subject: [PATCH 14/29] Publish - @synapsecns/rest-api@1.0.31 - @synapsecns/sdk-router@0.3.4 - @synapsecns/synapse-interface@0.1.212 --- packages/rest-api/CHANGELOG.md | 8 ++++++++ packages/rest-api/package.json | 4 ++-- packages/sdk-router/CHANGELOG.md | 8 ++++++++ packages/sdk-router/package.json | 2 +- packages/synapse-interface/CHANGELOG.md | 8 ++++++++ packages/synapse-interface/package.json | 4 ++-- 6 files changed, 29 insertions(+), 5 deletions(-) diff --git a/packages/rest-api/CHANGELOG.md b/packages/rest-api/CHANGELOG.md index 11308bf911..7f913d4791 100644 --- a/packages/rest-api/CHANGELOG.md +++ b/packages/rest-api/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.31](https://github.com/synapsecns/sanguine/compare/@synapsecns/rest-api@1.0.30...@synapsecns/rest-api@1.0.31) (2023-12-22) + +**Note:** Version bump only for package @synapsecns/rest-api + + + + + ## [1.0.30](https://github.com/synapsecns/sanguine/compare/@synapsecns/rest-api@1.0.29...@synapsecns/rest-api@1.0.30) (2023-12-21) **Note:** Version bump only for package @synapsecns/rest-api diff --git a/packages/rest-api/package.json b/packages/rest-api/package.json index 4e5e036f04..86c34e398b 100644 --- a/packages/rest-api/package.json +++ b/packages/rest-api/package.json @@ -1,6 +1,6 @@ { "name": "@synapsecns/rest-api", - "version": "1.0.30", + "version": "1.0.31", "private": "true", "engines": { "node": ">=16.0.0" @@ -23,7 +23,7 @@ "@ethersproject/bignumber": "^5.7.0", "@ethersproject/providers": "^5.7.2", "@ethersproject/units": "5.7.0", - "@synapsecns/sdk-router": "^0.3.3", + "@synapsecns/sdk-router": "^0.3.4", "bignumber": "^1.1.0", "ethers": "5.7.2", "express": "^4.18.2", diff --git a/packages/sdk-router/CHANGELOG.md b/packages/sdk-router/CHANGELOG.md index 443a0d8488..9d05464f29 100644 --- a/packages/sdk-router/CHANGELOG.md +++ b/packages/sdk-router/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.3.4](https://github.com/synapsecns/sanguine/compare/@synapsecns/sdk-router@0.3.3...@synapsecns/sdk-router@0.3.4) (2023-12-22) + +**Note:** Version bump only for package @synapsecns/sdk-router + + + + + ## [0.3.3](https://github.com/synapsecns/sanguine/compare/@synapsecns/sdk-router@0.3.2...@synapsecns/sdk-router@0.3.3) (2023-12-21) **Note:** Version bump only for package @synapsecns/sdk-router diff --git a/packages/sdk-router/package.json b/packages/sdk-router/package.json index 1c066ca020..46a1b2b055 100644 --- a/packages/sdk-router/package.json +++ b/packages/sdk-router/package.json @@ -1,7 +1,7 @@ { "name": "@synapsecns/sdk-router", "description": "An SDK for interacting with the Synapse Protocol", - "version": "0.3.3", + "version": "0.3.4", "license": "MIT", "main": "dist/index.js", "typings": "dist/index.d.ts", diff --git a/packages/synapse-interface/CHANGELOG.md b/packages/synapse-interface/CHANGELOG.md index 89c0438166..072282c913 100644 --- a/packages/synapse-interface/CHANGELOG.md +++ b/packages/synapse-interface/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.1.212](https://github.com/synapsecns/sanguine/compare/@synapsecns/synapse-interface@0.1.211...@synapsecns/synapse-interface@0.1.212) (2023-12-22) + +**Note:** Version bump only for package @synapsecns/synapse-interface + + + + + ## [0.1.211](https://github.com/synapsecns/sanguine/compare/@synapsecns/synapse-interface@0.1.210...@synapsecns/synapse-interface@0.1.211) (2023-12-21) **Note:** Version bump only for package @synapsecns/synapse-interface diff --git a/packages/synapse-interface/package.json b/packages/synapse-interface/package.json index a1539112af..536d4f423c 100644 --- a/packages/synapse-interface/package.json +++ b/packages/synapse-interface/package.json @@ -1,6 +1,6 @@ { "name": "@synapsecns/synapse-interface", - "version": "0.1.211", + "version": "0.1.212", "private": true, "engines": { "node": ">=16.0.0" @@ -42,7 +42,7 @@ "@reduxjs/toolkit": "^1.9.5", "@rtk-query/graphql-request-base-query": "^2.2.0", "@segment/analytics-next": "^1.53.0", - "@synapsecns/sdk-router": "^0.3.3", + "@synapsecns/sdk-router": "^0.3.4", "@tailwindcss/aspect-ratio": "^0.4.2", "@tailwindcss/forms": "^0.5.3", "@tailwindcss/line-clamp": "^0.4.2", From f14a22ae21b67c7f4decec10956577fe2ec22259 Mon Sep 17 00:00:00 2001 From: bigboydiamonds <57741810+bigboydiamonds@users.noreply.github.com> Date: Fri, 22 Dec 2023 04:06:46 -0800 Subject: [PATCH 15/29] Move dotenv to dev deps (#1696) * Move dotenv to dev deps * Don't expose test values in ./constants * Update imports * [REVERT IN PROD] use local SDK * Revert "[REVERT IN PROD] use local SDK" This reverts commit be9f0c0be3a0f5cbd648b03cb667cdda6d53b169. --------- Co-authored-by: ChiTimesChi <88190723+ChiTimesChi@users.noreply.github.com> --- packages/sdk-router/package.json | 2 +- packages/sdk-router/src/constants/index.ts | 1 - packages/sdk-router/src/router/synapseCCTPRouter.test.ts | 8 ++------ .../sdk-router/src/router/synapseCCTPRouterSet.test.ts | 2 +- packages/sdk-router/src/router/synapseRouter.test.ts | 9 ++------- packages/sdk-router/src/router/synapseRouterSet.test.ts | 2 +- packages/sdk-router/src/sdk.test.ts | 8 +++++--- 7 files changed, 12 insertions(+), 20 deletions(-) diff --git a/packages/sdk-router/package.json b/packages/sdk-router/package.json index 46a1b2b055..f8c79e1386 100644 --- a/packages/sdk-router/package.json +++ b/packages/sdk-router/package.json @@ -45,6 +45,7 @@ "devDependencies": { "@types/big.js": "^4.0.5", "@types/jest": "^24.0.25", + "dotenv": "^16.3.1", "husky": "^8.0.1", "size-limit": "^8.1.0", "tsdx": "^0.14.1", @@ -63,7 +64,6 @@ "babel-jest": "^29.4.1", "big.js": "^5.2.2", "decimal.js-light": "^2.5.1", - "dotenv": "^16.3.1", "ethers": "^5.7.2", "jsbi": "^4.3.0", "tiny-invariant": "^1.2.0", diff --git a/packages/sdk-router/src/constants/index.ts b/packages/sdk-router/src/constants/index.ts index 5ccd633126..94adaff573 100644 --- a/packages/sdk-router/src/constants/index.ts +++ b/packages/sdk-router/src/constants/index.ts @@ -4,7 +4,6 @@ import { BigNumber } from '@ethersproject/bignumber' export * from './addresses' export * from './chainIds' export * from './medianTime' -export * from './testValues' // exports for external consumption export type BigintIsh = JSBI | BigNumber | string | number diff --git a/packages/sdk-router/src/router/synapseCCTPRouter.test.ts b/packages/sdk-router/src/router/synapseCCTPRouter.test.ts index 40d33d6dd0..9573125389 100644 --- a/packages/sdk-router/src/router/synapseCCTPRouter.test.ts +++ b/packages/sdk-router/src/router/synapseCCTPRouter.test.ts @@ -2,12 +2,8 @@ import { Provider } from '@ethersproject/abstract-provider' import { BigNumber, providers } from 'ethers' import { AddressZero } from '@ethersproject/constants' -import { - getTestProviderUrl, - CCTP_ROUTER_ADDRESS_MAP, - SupportedChainId, - ETH_USDC, -} from '../constants' +import { getTestProviderUrl, ETH_USDC } from '../constants/testValues' +import { CCTP_ROUTER_ADDRESS_MAP, SupportedChainId } from '../constants' import { SynapseCCTPRouter } from './synapseCCTPRouter' import { BridgeToken, CCTPRouterQuery } from '../module' import { DestRequest } from './types' diff --git a/packages/sdk-router/src/router/synapseCCTPRouterSet.test.ts b/packages/sdk-router/src/router/synapseCCTPRouterSet.test.ts index efbacd9047..252df8ce23 100644 --- a/packages/sdk-router/src/router/synapseCCTPRouterSet.test.ts +++ b/packages/sdk-router/src/router/synapseCCTPRouterSet.test.ts @@ -1,8 +1,8 @@ import { Provider } from '@ethersproject/abstract-provider' import { providers } from 'ethers' +import { getTestProviderUrl } from '../constants/testValues' import { - getTestProviderUrl, ROUTER_ADDRESS_MAP, CCTP_ROUTER_ADDRESS_MAP, MEDIAN_TIME_CCTP, diff --git a/packages/sdk-router/src/router/synapseRouter.test.ts b/packages/sdk-router/src/router/synapseRouter.test.ts index 1ccb5fcd59..068ddf2523 100644 --- a/packages/sdk-router/src/router/synapseRouter.test.ts +++ b/packages/sdk-router/src/router/synapseRouter.test.ts @@ -2,13 +2,8 @@ import { Provider } from '@ethersproject/abstract-provider' import { BigNumber, providers } from 'ethers' import { AddressZero } from '@ethersproject/constants' -import { - ETH_NUSD, - ETH_USDC, - getTestProviderUrl, - ROUTER_ADDRESS_MAP, - SupportedChainId, -} from '../constants' +import { ETH_NUSD, ETH_USDC, getTestProviderUrl } from '../constants/testValues' +import { ROUTER_ADDRESS_MAP, SupportedChainId } from '../constants' import { SynapseRouter } from './synapseRouter' import { BridgeToken, RouterQuery } from '../module' import { DestRequest } from './types' diff --git a/packages/sdk-router/src/router/synapseRouterSet.test.ts b/packages/sdk-router/src/router/synapseRouterSet.test.ts index 3de5ae0363..b74a472722 100644 --- a/packages/sdk-router/src/router/synapseRouterSet.test.ts +++ b/packages/sdk-router/src/router/synapseRouterSet.test.ts @@ -1,8 +1,8 @@ import { Provider } from '@ethersproject/abstract-provider' import { providers } from 'ethers' +import { getTestProviderUrl } from '../constants/testValues' import { - getTestProviderUrl, ROUTER_ADDRESS_MAP, CCTP_ROUTER_ADDRESS_MAP, MEDIAN_TIME_BRIDGE, diff --git a/packages/sdk-router/src/sdk.test.ts b/packages/sdk-router/src/sdk.test.ts index 80efc869ca..8e460a1509 100644 --- a/packages/sdk-router/src/sdk.test.ts +++ b/packages/sdk-router/src/sdk.test.ts @@ -17,16 +17,18 @@ import { AVAX_USDC_E, BSC_GOHM, BSC_USDC, - CCTP_ROUTER_ADDRESS_MAP, ETH_DAI, ETH_POOL_NUSD, ETH_USDC, ETH_USDT, + NATIVE_ADDRESS, + getTestProviderUrl, +} from './constants/testValues' +import { + CCTP_ROUTER_ADDRESS_MAP, MEDIAN_TIME_BRIDGE, MEDIAN_TIME_CCTP, - NATIVE_ADDRESS, ROUTER_ADDRESS_MAP, - getTestProviderUrl, SupportedChainId, } from './constants' import { BridgeQuote, FeeConfig, RouterQuery, SwapQuote } from './module' From 9a5ef7e3045635258f0341ef9368aead89e662ce Mon Sep 17 00:00:00 2001 From: ChiTimesChi Date: Fri, 22 Dec 2023 12:09:56 +0000 Subject: [PATCH 16/29] Publish - @synapsecns/rest-api@1.0.32 - @synapsecns/sdk-router@0.3.5 - @synapsecns/synapse-interface@0.1.213 --- packages/rest-api/CHANGELOG.md | 8 ++++++++ packages/rest-api/package.json | 4 ++-- packages/sdk-router/CHANGELOG.md | 8 ++++++++ packages/sdk-router/package.json | 2 +- packages/synapse-interface/CHANGELOG.md | 8 ++++++++ packages/synapse-interface/package.json | 4 ++-- 6 files changed, 29 insertions(+), 5 deletions(-) diff --git a/packages/rest-api/CHANGELOG.md b/packages/rest-api/CHANGELOG.md index 7f913d4791..299644a197 100644 --- a/packages/rest-api/CHANGELOG.md +++ b/packages/rest-api/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.32](https://github.com/synapsecns/sanguine/compare/@synapsecns/rest-api@1.0.31...@synapsecns/rest-api@1.0.32) (2023-12-22) + +**Note:** Version bump only for package @synapsecns/rest-api + + + + + ## [1.0.31](https://github.com/synapsecns/sanguine/compare/@synapsecns/rest-api@1.0.30...@synapsecns/rest-api@1.0.31) (2023-12-22) **Note:** Version bump only for package @synapsecns/rest-api diff --git a/packages/rest-api/package.json b/packages/rest-api/package.json index 86c34e398b..d66f992f12 100644 --- a/packages/rest-api/package.json +++ b/packages/rest-api/package.json @@ -1,6 +1,6 @@ { "name": "@synapsecns/rest-api", - "version": "1.0.31", + "version": "1.0.32", "private": "true", "engines": { "node": ">=16.0.0" @@ -23,7 +23,7 @@ "@ethersproject/bignumber": "^5.7.0", "@ethersproject/providers": "^5.7.2", "@ethersproject/units": "5.7.0", - "@synapsecns/sdk-router": "^0.3.4", + "@synapsecns/sdk-router": "^0.3.5", "bignumber": "^1.1.0", "ethers": "5.7.2", "express": "^4.18.2", diff --git a/packages/sdk-router/CHANGELOG.md b/packages/sdk-router/CHANGELOG.md index 9d05464f29..054aad371f 100644 --- a/packages/sdk-router/CHANGELOG.md +++ b/packages/sdk-router/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.3.5](https://github.com/synapsecns/sanguine/compare/@synapsecns/sdk-router@0.3.4...@synapsecns/sdk-router@0.3.5) (2023-12-22) + +**Note:** Version bump only for package @synapsecns/sdk-router + + + + + ## [0.3.4](https://github.com/synapsecns/sanguine/compare/@synapsecns/sdk-router@0.3.3...@synapsecns/sdk-router@0.3.4) (2023-12-22) **Note:** Version bump only for package @synapsecns/sdk-router diff --git a/packages/sdk-router/package.json b/packages/sdk-router/package.json index f8c79e1386..75126ff5ed 100644 --- a/packages/sdk-router/package.json +++ b/packages/sdk-router/package.json @@ -1,7 +1,7 @@ { "name": "@synapsecns/sdk-router", "description": "An SDK for interacting with the Synapse Protocol", - "version": "0.3.4", + "version": "0.3.5", "license": "MIT", "main": "dist/index.js", "typings": "dist/index.d.ts", diff --git a/packages/synapse-interface/CHANGELOG.md b/packages/synapse-interface/CHANGELOG.md index 072282c913..819bbe7cc0 100644 --- a/packages/synapse-interface/CHANGELOG.md +++ b/packages/synapse-interface/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.1.213](https://github.com/synapsecns/sanguine/compare/@synapsecns/synapse-interface@0.1.212...@synapsecns/synapse-interface@0.1.213) (2023-12-22) + +**Note:** Version bump only for package @synapsecns/synapse-interface + + + + + ## [0.1.212](https://github.com/synapsecns/sanguine/compare/@synapsecns/synapse-interface@0.1.211...@synapsecns/synapse-interface@0.1.212) (2023-12-22) **Note:** Version bump only for package @synapsecns/synapse-interface diff --git a/packages/synapse-interface/package.json b/packages/synapse-interface/package.json index 536d4f423c..6cad913757 100644 --- a/packages/synapse-interface/package.json +++ b/packages/synapse-interface/package.json @@ -1,6 +1,6 @@ { "name": "@synapsecns/synapse-interface", - "version": "0.1.212", + "version": "0.1.213", "private": true, "engines": { "node": ">=16.0.0" @@ -42,7 +42,7 @@ "@reduxjs/toolkit": "^1.9.5", "@rtk-query/graphql-request-base-query": "^2.2.0", "@segment/analytics-next": "^1.53.0", - "@synapsecns/sdk-router": "^0.3.4", + "@synapsecns/sdk-router": "^0.3.5", "@tailwindcss/aspect-ratio": "^0.4.2", "@tailwindcss/forms": "^0.5.3", "@tailwindcss/line-clamp": "^0.4.2", From 5d3d3873315f40fe9f6b599bc9f6a4bfa80dffd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CF=87=C2=B2?= <88190723+ChiTimesChi@users.noreply.github.com> Date: Fri, 22 Dec 2023 19:02:09 +0300 Subject: [PATCH 17/29] SDK: update bindings (#1706) * Generate bindings using latest TypeChain * Add FastBridge ABI --- packages/sdk-router/src/abi/FastBridge.json | 864 ++++++++ .../sdk-router/src/typechain/FastBridge.ts | 1628 +++++++++++++++ .../sdk-router/src/typechain/SynapseBridge.ts | 1826 +++++++++++++++-- .../src/typechain/SynapseCCTPRouter.ts | 950 ++++----- .../sdk-router/src/typechain/SynapseRouter.ts | 981 +++++---- packages/sdk-router/src/typechain/common.ts | 26 +- 6 files changed, 5092 insertions(+), 1183 deletions(-) create mode 100644 packages/sdk-router/src/abi/FastBridge.json create mode 100644 packages/sdk-router/src/typechain/FastBridge.ts diff --git a/packages/sdk-router/src/abi/FastBridge.json b/packages/sdk-router/src/abi/FastBridge.json new file mode 100644 index 0000000000..2b008da14e --- /dev/null +++ b/packages/sdk-router/src/abi/FastBridge.json @@ -0,0 +1,864 @@ +[ + { + "inputs": [ + { "internalType": "address", "name": "_owner", "type": "address" } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { "inputs": [], "name": "AccessControlBadConfirmation", "type": "error" }, + { + "inputs": [ + { "internalType": "address", "name": "account", "type": "address" }, + { "internalType": "bytes32", "name": "neededRole", "type": "bytes32" } + ], + "name": "AccessControlUnauthorizedAccount", + "type": "error" + }, + { + "inputs": [ + { "internalType": "address", "name": "target", "type": "address" } + ], + "name": "AddressEmptyCode", + "type": "error" + }, + { + "inputs": [ + { "internalType": "address", "name": "account", "type": "address" } + ], + "name": "AddressInsufficientBalance", + "type": "error" + }, + { "inputs": [], "name": "AmountIncorrect", "type": "error" }, + { "inputs": [], "name": "ChainIncorrect", "type": "error" }, + { "inputs": [], "name": "DeadlineExceeded", "type": "error" }, + { "inputs": [], "name": "DeadlineNotExceeded", "type": "error" }, + { "inputs": [], "name": "DeadlineTooShort", "type": "error" }, + { "inputs": [], "name": "DisputePeriodNotPassed", "type": "error" }, + { "inputs": [], "name": "DisputePeriodPassed", "type": "error" }, + { "inputs": [], "name": "FailedInnerCall", "type": "error" }, + { "inputs": [], "name": "MsgValueIncorrect", "type": "error" }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" } + ], + "name": "SafeERC20FailedOperation", + "type": "error" + }, + { "inputs": [], "name": "SenderIncorrect", "type": "error" }, + { "inputs": [], "name": "StatusIncorrect", "type": "error" }, + { "inputs": [], "name": "TokenNotContract", "type": "error" }, + { "inputs": [], "name": "TransactionRelayed", "type": "error" }, + { "inputs": [], "name": "ZeroAddress", "type": "error" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "transactionId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "address", + "name": "relayer", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "BridgeDepositClaimed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "transactionId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "BridgeDepositRefunded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "transactionId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "address", + "name": "relayer", + "type": "address" + } + ], + "name": "BridgeProofDisputed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "transactionId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "address", + "name": "relayer", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "transactionHash", + "type": "bytes32" + } + ], + "name": "BridgeProofProvided", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "transactionId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "address", + "name": "relayer", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "chainGasAmount", + "type": "uint256" + } + ], + "name": "BridgeRelayed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "transactionId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "request", + "type": "bytes" + } + ], + "name": "BridgeRequested", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldChainGasAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newChainGasAmount", + "type": "uint256" + } + ], + "name": "ChainGasAmountUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldFeeRate", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newFeeRate", + "type": "uint256" + } + ], + "name": "FeeRateUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "FeesSwept", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "governor", + "type": "address" + } + ], + "name": "GovernorAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "governor", + "type": "address" + } + ], + "name": "GovernorRemoved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "guard", + "type": "address" + } + ], + "name": "GuardAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "guard", + "type": "address" + } + ], + "name": "GuardRemoved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "relayer", + "type": "address" + } + ], + "name": "RelayerAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "relayer", + "type": "address" + } + ], + "name": "RelayerRemoved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "previousAdminRole", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "newAdminRole", + "type": "bytes32" + } + ], + "name": "RoleAdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleGranted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleRevoked", + "type": "event" + }, + { + "inputs": [], + "name": "DEFAULT_ADMIN_ROLE", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "DISPUTE_PERIOD", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "FEE_BPS", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "FEE_RATE_MAX", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "GOVERNOR_ROLE", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "GUARD_ROLE", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MIN_DEADLINE_PERIOD", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RELAYER_ROLE", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_governor", "type": "address" } + ], + "name": "addGovernor", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_guard", "type": "address" } + ], + "name": "addGuard", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_relayer", "type": "address" } + ], + "name": "addRelayer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { "internalType": "uint32", "name": "dstChainId", "type": "uint32" }, + { "internalType": "address", "name": "to", "type": "address" }, + { + "internalType": "address", + "name": "originToken", + "type": "address" + }, + { "internalType": "address", "name": "destToken", "type": "address" }, + { + "internalType": "uint256", + "name": "originAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "destAmount", + "type": "uint256" + }, + { "internalType": "bool", "name": "sendChainGas", "type": "bool" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "internalType": "struct IFastBridge.BridgeParams", + "name": "params", + "type": "tuple" + } + ], + "name": "bridge", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "name": "bridgeProofs", + "outputs": [ + { "internalType": "uint96", "name": "timestamp", "type": "uint96" }, + { "internalType": "address", "name": "relayer", "type": "address" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "name": "bridgeRelays", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "name": "bridgeStatuses", + "outputs": [ + { + "internalType": "enum FastBridge.BridgeStatus", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "transactionId", "type": "bytes32" }, + { "internalType": "address", "name": "relayer", "type": "address" } + ], + "name": "canClaim", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "chainGasAmount", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes", "name": "request", "type": "bytes" }, + { "internalType": "address", "name": "to", "type": "address" } + ], + "name": "claim", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "deployBlock", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "transactionId", "type": "bytes32" } + ], + "name": "dispute", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "bytes", "name": "request", "type": "bytes" }], + "name": "getBridgeTransaction", + "outputs": [ + { + "components": [ + { + "internalType": "uint32", + "name": "originChainId", + "type": "uint32" + }, + { "internalType": "uint32", "name": "destChainId", "type": "uint32" }, + { + "internalType": "address", + "name": "originSender", + "type": "address" + }, + { + "internalType": "address", + "name": "destRecipient", + "type": "address" + }, + { + "internalType": "address", + "name": "originToken", + "type": "address" + }, + { "internalType": "address", "name": "destToken", "type": "address" }, + { + "internalType": "uint256", + "name": "originAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "destAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "originFeeAmount", + "type": "uint256" + }, + { "internalType": "bool", "name": "sendChainGas", "type": "bool" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" }, + { "internalType": "uint256", "name": "nonce", "type": "uint256" } + ], + "internalType": "struct IFastBridge.BridgeTransaction", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "role", "type": "bytes32" } + ], + "name": "getRoleAdmin", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "role", "type": "bytes32" }, + { "internalType": "address", "name": "account", "type": "address" } + ], + "name": "grantRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "role", "type": "bytes32" }, + { "internalType": "address", "name": "account", "type": "address" } + ], + "name": "hasRole", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "nonce", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "protocolFeeRate", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "protocolFees", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes", "name": "request", "type": "bytes" }, + { "internalType": "bytes32", "name": "destTxHash", "type": "bytes32" } + ], + "name": "prove", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes", "name": "request", "type": "bytes" }, + { "internalType": "address", "name": "to", "type": "address" } + ], + "name": "refund", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "bytes", "name": "request", "type": "bytes" }], + "name": "relay", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_governor", "type": "address" } + ], + "name": "removeGovernor", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_guard", "type": "address" } + ], + "name": "removeGuard", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_relayer", "type": "address" } + ], + "name": "removeRelayer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "role", "type": "bytes32" }, + { + "internalType": "address", + "name": "callerConfirmation", + "type": "address" + } + ], + "name": "renounceRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "role", "type": "bytes32" }, + { "internalType": "address", "name": "account", "type": "address" } + ], + "name": "revokeRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "newChainGasAmount", + "type": "uint256" + } + ], + "name": "setChainGasAmount", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "newFeeRate", "type": "uint256" } + ], + "name": "setProtocolFeeRate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes4", "name": "interfaceId", "type": "bytes4" } + ], + "name": "supportsInterface", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "address", "name": "recipient", "type": "address" } + ], + "name": "sweepProtocolFees", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/packages/sdk-router/src/typechain/FastBridge.ts b/packages/sdk-router/src/typechain/FastBridge.ts new file mode 100644 index 0000000000..67ec5f621e --- /dev/null +++ b/packages/sdk-router/src/typechain/FastBridge.ts @@ -0,0 +1,1628 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumber, + BigNumberish, + BytesLike, + CallOverrides, + ContractTransaction, + Overrides, + PayableOverrides, + PopulatedTransaction, + Signer, + utils, +} from 'ethers' +import type { + FunctionFragment, + Result, + EventFragment, +} from '@ethersproject/abi' +import type { Listener, Provider } from '@ethersproject/providers' +import type { + TypedEventFilter, + TypedEvent, + TypedListener, + OnEvent, +} from './common' + +export declare namespace IFastBridge { + export type BridgeParamsStruct = { + dstChainId: BigNumberish + to: string + originToken: string + destToken: string + originAmount: BigNumberish + destAmount: BigNumberish + sendChainGas: boolean + deadline: BigNumberish + } + + export type BridgeParamsStructOutput = [ + number, + string, + string, + string, + BigNumber, + BigNumber, + boolean, + BigNumber + ] & { + dstChainId: number + to: string + originToken: string + destToken: string + originAmount: BigNumber + destAmount: BigNumber + sendChainGas: boolean + deadline: BigNumber + } + + export type BridgeTransactionStruct = { + originChainId: BigNumberish + destChainId: BigNumberish + originSender: string + destRecipient: string + originToken: string + destToken: string + originAmount: BigNumberish + destAmount: BigNumberish + originFeeAmount: BigNumberish + sendChainGas: boolean + deadline: BigNumberish + nonce: BigNumberish + } + + export type BridgeTransactionStructOutput = [ + number, + number, + string, + string, + string, + string, + BigNumber, + BigNumber, + BigNumber, + boolean, + BigNumber, + BigNumber + ] & { + originChainId: number + destChainId: number + originSender: string + destRecipient: string + originToken: string + destToken: string + originAmount: BigNumber + destAmount: BigNumber + originFeeAmount: BigNumber + sendChainGas: boolean + deadline: BigNumber + nonce: BigNumber + } +} + +export interface FastBridgeInterface extends utils.Interface { + functions: { + 'DEFAULT_ADMIN_ROLE()': FunctionFragment + 'DISPUTE_PERIOD()': FunctionFragment + 'FEE_BPS()': FunctionFragment + 'FEE_RATE_MAX()': FunctionFragment + 'GOVERNOR_ROLE()': FunctionFragment + 'GUARD_ROLE()': FunctionFragment + 'MIN_DEADLINE_PERIOD()': FunctionFragment + 'RELAYER_ROLE()': FunctionFragment + 'addGovernor(address)': FunctionFragment + 'addGuard(address)': FunctionFragment + 'addRelayer(address)': FunctionFragment + 'bridge((uint32,address,address,address,uint256,uint256,bool,uint256))': FunctionFragment + 'bridgeProofs(bytes32)': FunctionFragment + 'bridgeRelays(bytes32)': FunctionFragment + 'bridgeStatuses(bytes32)': FunctionFragment + 'canClaim(bytes32,address)': FunctionFragment + 'chainGasAmount()': FunctionFragment + 'claim(bytes,address)': FunctionFragment + 'deployBlock()': FunctionFragment + 'dispute(bytes32)': FunctionFragment + 'getBridgeTransaction(bytes)': FunctionFragment + 'getRoleAdmin(bytes32)': FunctionFragment + 'grantRole(bytes32,address)': FunctionFragment + 'hasRole(bytes32,address)': FunctionFragment + 'nonce()': FunctionFragment + 'protocolFeeRate()': FunctionFragment + 'protocolFees(address)': FunctionFragment + 'prove(bytes,bytes32)': FunctionFragment + 'refund(bytes,address)': FunctionFragment + 'relay(bytes)': FunctionFragment + 'removeGovernor(address)': FunctionFragment + 'removeGuard(address)': FunctionFragment + 'removeRelayer(address)': FunctionFragment + 'renounceRole(bytes32,address)': FunctionFragment + 'revokeRole(bytes32,address)': FunctionFragment + 'setChainGasAmount(uint256)': FunctionFragment + 'setProtocolFeeRate(uint256)': FunctionFragment + 'supportsInterface(bytes4)': FunctionFragment + 'sweepProtocolFees(address,address)': FunctionFragment + } + + getFunction( + nameOrSignatureOrTopic: + | 'DEFAULT_ADMIN_ROLE' + | 'DISPUTE_PERIOD' + | 'FEE_BPS' + | 'FEE_RATE_MAX' + | 'GOVERNOR_ROLE' + | 'GUARD_ROLE' + | 'MIN_DEADLINE_PERIOD' + | 'RELAYER_ROLE' + | 'addGovernor' + | 'addGuard' + | 'addRelayer' + | 'bridge' + | 'bridgeProofs' + | 'bridgeRelays' + | 'bridgeStatuses' + | 'canClaim' + | 'chainGasAmount' + | 'claim' + | 'deployBlock' + | 'dispute' + | 'getBridgeTransaction' + | 'getRoleAdmin' + | 'grantRole' + | 'hasRole' + | 'nonce' + | 'protocolFeeRate' + | 'protocolFees' + | 'prove' + | 'refund' + | 'relay' + | 'removeGovernor' + | 'removeGuard' + | 'removeRelayer' + | 'renounceRole' + | 'revokeRole' + | 'setChainGasAmount' + | 'setProtocolFeeRate' + | 'supportsInterface' + | 'sweepProtocolFees' + ): FunctionFragment + + encodeFunctionData( + functionFragment: 'DEFAULT_ADMIN_ROLE', + values?: undefined + ): string + encodeFunctionData( + functionFragment: 'DISPUTE_PERIOD', + values?: undefined + ): string + encodeFunctionData(functionFragment: 'FEE_BPS', values?: undefined): string + encodeFunctionData( + functionFragment: 'FEE_RATE_MAX', + values?: undefined + ): string + encodeFunctionData( + functionFragment: 'GOVERNOR_ROLE', + values?: undefined + ): string + encodeFunctionData(functionFragment: 'GUARD_ROLE', values?: undefined): string + encodeFunctionData( + functionFragment: 'MIN_DEADLINE_PERIOD', + values?: undefined + ): string + encodeFunctionData( + functionFragment: 'RELAYER_ROLE', + values?: undefined + ): string + encodeFunctionData(functionFragment: 'addGovernor', values: [string]): string + encodeFunctionData(functionFragment: 'addGuard', values: [string]): string + encodeFunctionData(functionFragment: 'addRelayer', values: [string]): string + encodeFunctionData( + functionFragment: 'bridge', + values: [IFastBridge.BridgeParamsStruct] + ): string + encodeFunctionData( + functionFragment: 'bridgeProofs', + values: [BytesLike] + ): string + encodeFunctionData( + functionFragment: 'bridgeRelays', + values: [BytesLike] + ): string + encodeFunctionData( + functionFragment: 'bridgeStatuses', + values: [BytesLike] + ): string + encodeFunctionData( + functionFragment: 'canClaim', + values: [BytesLike, string] + ): string + encodeFunctionData( + functionFragment: 'chainGasAmount', + values?: undefined + ): string + encodeFunctionData( + functionFragment: 'claim', + values: [BytesLike, string] + ): string + encodeFunctionData( + functionFragment: 'deployBlock', + values?: undefined + ): string + encodeFunctionData(functionFragment: 'dispute', values: [BytesLike]): string + encodeFunctionData( + functionFragment: 'getBridgeTransaction', + values: [BytesLike] + ): string + encodeFunctionData( + functionFragment: 'getRoleAdmin', + values: [BytesLike] + ): string + encodeFunctionData( + functionFragment: 'grantRole', + values: [BytesLike, string] + ): string + encodeFunctionData( + functionFragment: 'hasRole', + values: [BytesLike, string] + ): string + encodeFunctionData(functionFragment: 'nonce', values?: undefined): string + encodeFunctionData( + functionFragment: 'protocolFeeRate', + values?: undefined + ): string + encodeFunctionData(functionFragment: 'protocolFees', values: [string]): string + encodeFunctionData( + functionFragment: 'prove', + values: [BytesLike, BytesLike] + ): string + encodeFunctionData( + functionFragment: 'refund', + values: [BytesLike, string] + ): string + encodeFunctionData(functionFragment: 'relay', values: [BytesLike]): string + encodeFunctionData( + functionFragment: 'removeGovernor', + values: [string] + ): string + encodeFunctionData(functionFragment: 'removeGuard', values: [string]): string + encodeFunctionData( + functionFragment: 'removeRelayer', + values: [string] + ): string + encodeFunctionData( + functionFragment: 'renounceRole', + values: [BytesLike, string] + ): string + encodeFunctionData( + functionFragment: 'revokeRole', + values: [BytesLike, string] + ): string + encodeFunctionData( + functionFragment: 'setChainGasAmount', + values: [BigNumberish] + ): string + encodeFunctionData( + functionFragment: 'setProtocolFeeRate', + values: [BigNumberish] + ): string + encodeFunctionData( + functionFragment: 'supportsInterface', + values: [BytesLike] + ): string + encodeFunctionData( + functionFragment: 'sweepProtocolFees', + values: [string, string] + ): string + + decodeFunctionResult( + functionFragment: 'DEFAULT_ADMIN_ROLE', + data: BytesLike + ): Result + decodeFunctionResult( + functionFragment: 'DISPUTE_PERIOD', + data: BytesLike + ): Result + decodeFunctionResult(functionFragment: 'FEE_BPS', data: BytesLike): Result + decodeFunctionResult( + functionFragment: 'FEE_RATE_MAX', + data: BytesLike + ): Result + decodeFunctionResult( + functionFragment: 'GOVERNOR_ROLE', + data: BytesLike + ): Result + decodeFunctionResult(functionFragment: 'GUARD_ROLE', data: BytesLike): Result + decodeFunctionResult( + functionFragment: 'MIN_DEADLINE_PERIOD', + data: BytesLike + ): Result + decodeFunctionResult( + functionFragment: 'RELAYER_ROLE', + data: BytesLike + ): Result + decodeFunctionResult(functionFragment: 'addGovernor', data: BytesLike): Result + decodeFunctionResult(functionFragment: 'addGuard', data: BytesLike): Result + decodeFunctionResult(functionFragment: 'addRelayer', data: BytesLike): Result + decodeFunctionResult(functionFragment: 'bridge', data: BytesLike): Result + decodeFunctionResult( + functionFragment: 'bridgeProofs', + data: BytesLike + ): Result + decodeFunctionResult( + functionFragment: 'bridgeRelays', + data: BytesLike + ): Result + decodeFunctionResult( + functionFragment: 'bridgeStatuses', + data: BytesLike + ): Result + decodeFunctionResult(functionFragment: 'canClaim', data: BytesLike): Result + decodeFunctionResult( + functionFragment: 'chainGasAmount', + data: BytesLike + ): Result + decodeFunctionResult(functionFragment: 'claim', data: BytesLike): Result + decodeFunctionResult(functionFragment: 'deployBlock', data: BytesLike): Result + decodeFunctionResult(functionFragment: 'dispute', data: BytesLike): Result + decodeFunctionResult( + functionFragment: 'getBridgeTransaction', + data: BytesLike + ): Result + decodeFunctionResult( + functionFragment: 'getRoleAdmin', + data: BytesLike + ): Result + decodeFunctionResult(functionFragment: 'grantRole', data: BytesLike): Result + decodeFunctionResult(functionFragment: 'hasRole', data: BytesLike): Result + decodeFunctionResult(functionFragment: 'nonce', data: BytesLike): Result + decodeFunctionResult( + functionFragment: 'protocolFeeRate', + data: BytesLike + ): Result + decodeFunctionResult( + functionFragment: 'protocolFees', + data: BytesLike + ): Result + decodeFunctionResult(functionFragment: 'prove', data: BytesLike): Result + decodeFunctionResult(functionFragment: 'refund', data: BytesLike): Result + decodeFunctionResult(functionFragment: 'relay', data: BytesLike): Result + decodeFunctionResult( + functionFragment: 'removeGovernor', + data: BytesLike + ): Result + decodeFunctionResult(functionFragment: 'removeGuard', data: BytesLike): Result + decodeFunctionResult( + functionFragment: 'removeRelayer', + data: BytesLike + ): Result + decodeFunctionResult( + functionFragment: 'renounceRole', + data: BytesLike + ): Result + decodeFunctionResult(functionFragment: 'revokeRole', data: BytesLike): Result + decodeFunctionResult( + functionFragment: 'setChainGasAmount', + data: BytesLike + ): Result + decodeFunctionResult( + functionFragment: 'setProtocolFeeRate', + data: BytesLike + ): Result + decodeFunctionResult( + functionFragment: 'supportsInterface', + data: BytesLike + ): Result + decodeFunctionResult( + functionFragment: 'sweepProtocolFees', + data: BytesLike + ): Result + + events: { + 'BridgeDepositClaimed(bytes32,address,address,address,uint256)': EventFragment + 'BridgeDepositRefunded(bytes32,address,address,uint256)': EventFragment + 'BridgeProofDisputed(bytes32,address)': EventFragment + 'BridgeProofProvided(bytes32,address,bytes32)': EventFragment + 'BridgeRelayed(bytes32,address,address,address,uint256,uint256)': EventFragment + 'BridgeRequested(bytes32,address,bytes)': EventFragment + 'ChainGasAmountUpdated(uint256,uint256)': EventFragment + 'FeeRateUpdated(uint256,uint256)': EventFragment + 'FeesSwept(address,address,uint256)': EventFragment + 'GovernorAdded(address)': EventFragment + 'GovernorRemoved(address)': EventFragment + 'GuardAdded(address)': EventFragment + 'GuardRemoved(address)': EventFragment + 'RelayerAdded(address)': EventFragment + 'RelayerRemoved(address)': EventFragment + 'RoleAdminChanged(bytes32,bytes32,bytes32)': EventFragment + 'RoleGranted(bytes32,address,address)': EventFragment + 'RoleRevoked(bytes32,address,address)': EventFragment + } + + getEvent(nameOrSignatureOrTopic: 'BridgeDepositClaimed'): EventFragment + getEvent(nameOrSignatureOrTopic: 'BridgeDepositRefunded'): EventFragment + getEvent(nameOrSignatureOrTopic: 'BridgeProofDisputed'): EventFragment + getEvent(nameOrSignatureOrTopic: 'BridgeProofProvided'): EventFragment + getEvent(nameOrSignatureOrTopic: 'BridgeRelayed'): EventFragment + getEvent(nameOrSignatureOrTopic: 'BridgeRequested'): EventFragment + getEvent(nameOrSignatureOrTopic: 'ChainGasAmountUpdated'): EventFragment + getEvent(nameOrSignatureOrTopic: 'FeeRateUpdated'): EventFragment + getEvent(nameOrSignatureOrTopic: 'FeesSwept'): EventFragment + getEvent(nameOrSignatureOrTopic: 'GovernorAdded'): EventFragment + getEvent(nameOrSignatureOrTopic: 'GovernorRemoved'): EventFragment + getEvent(nameOrSignatureOrTopic: 'GuardAdded'): EventFragment + getEvent(nameOrSignatureOrTopic: 'GuardRemoved'): EventFragment + getEvent(nameOrSignatureOrTopic: 'RelayerAdded'): EventFragment + getEvent(nameOrSignatureOrTopic: 'RelayerRemoved'): EventFragment + getEvent(nameOrSignatureOrTopic: 'RoleAdminChanged'): EventFragment + getEvent(nameOrSignatureOrTopic: 'RoleGranted'): EventFragment + getEvent(nameOrSignatureOrTopic: 'RoleRevoked'): EventFragment +} + +export interface BridgeDepositClaimedEventObject { + transactionId: string + relayer: string + to: string + token: string + amount: BigNumber +} +export type BridgeDepositClaimedEvent = TypedEvent< + [string, string, string, string, BigNumber], + BridgeDepositClaimedEventObject +> + +export type BridgeDepositClaimedEventFilter = + TypedEventFilter + +export interface BridgeDepositRefundedEventObject { + transactionId: string + to: string + token: string + amount: BigNumber +} +export type BridgeDepositRefundedEvent = TypedEvent< + [string, string, string, BigNumber], + BridgeDepositRefundedEventObject +> + +export type BridgeDepositRefundedEventFilter = + TypedEventFilter + +export interface BridgeProofDisputedEventObject { + transactionId: string + relayer: string +} +export type BridgeProofDisputedEvent = TypedEvent< + [string, string], + BridgeProofDisputedEventObject +> + +export type BridgeProofDisputedEventFilter = + TypedEventFilter + +export interface BridgeProofProvidedEventObject { + transactionId: string + relayer: string + transactionHash: string +} +export type BridgeProofProvidedEvent = TypedEvent< + [string, string, string], + BridgeProofProvidedEventObject +> + +export type BridgeProofProvidedEventFilter = + TypedEventFilter + +export interface BridgeRelayedEventObject { + transactionId: string + relayer: string + to: string + token: string + amount: BigNumber + chainGasAmount: BigNumber +} +export type BridgeRelayedEvent = TypedEvent< + [string, string, string, string, BigNumber, BigNumber], + BridgeRelayedEventObject +> + +export type BridgeRelayedEventFilter = TypedEventFilter + +export interface BridgeRequestedEventObject { + transactionId: string + sender: string + request: string +} +export type BridgeRequestedEvent = TypedEvent< + [string, string, string], + BridgeRequestedEventObject +> + +export type BridgeRequestedEventFilter = TypedEventFilter + +export interface ChainGasAmountUpdatedEventObject { + oldChainGasAmount: BigNumber + newChainGasAmount: BigNumber +} +export type ChainGasAmountUpdatedEvent = TypedEvent< + [BigNumber, BigNumber], + ChainGasAmountUpdatedEventObject +> + +export type ChainGasAmountUpdatedEventFilter = + TypedEventFilter + +export interface FeeRateUpdatedEventObject { + oldFeeRate: BigNumber + newFeeRate: BigNumber +} +export type FeeRateUpdatedEvent = TypedEvent< + [BigNumber, BigNumber], + FeeRateUpdatedEventObject +> + +export type FeeRateUpdatedEventFilter = TypedEventFilter + +export interface FeesSweptEventObject { + token: string + recipient: string + amount: BigNumber +} +export type FeesSweptEvent = TypedEvent< + [string, string, BigNumber], + FeesSweptEventObject +> + +export type FeesSweptEventFilter = TypedEventFilter + +export interface GovernorAddedEventObject { + governor: string +} +export type GovernorAddedEvent = TypedEvent<[string], GovernorAddedEventObject> + +export type GovernorAddedEventFilter = TypedEventFilter + +export interface GovernorRemovedEventObject { + governor: string +} +export type GovernorRemovedEvent = TypedEvent< + [string], + GovernorRemovedEventObject +> + +export type GovernorRemovedEventFilter = TypedEventFilter + +export interface GuardAddedEventObject { + guard: string +} +export type GuardAddedEvent = TypedEvent<[string], GuardAddedEventObject> + +export type GuardAddedEventFilter = TypedEventFilter + +export interface GuardRemovedEventObject { + guard: string +} +export type GuardRemovedEvent = TypedEvent<[string], GuardRemovedEventObject> + +export type GuardRemovedEventFilter = TypedEventFilter + +export interface RelayerAddedEventObject { + relayer: string +} +export type RelayerAddedEvent = TypedEvent<[string], RelayerAddedEventObject> + +export type RelayerAddedEventFilter = TypedEventFilter + +export interface RelayerRemovedEventObject { + relayer: string +} +export type RelayerRemovedEvent = TypedEvent< + [string], + RelayerRemovedEventObject +> + +export type RelayerRemovedEventFilter = TypedEventFilter + +export interface RoleAdminChangedEventObject { + role: string + previousAdminRole: string + newAdminRole: string +} +export type RoleAdminChangedEvent = TypedEvent< + [string, string, string], + RoleAdminChangedEventObject +> + +export type RoleAdminChangedEventFilter = + TypedEventFilter + +export interface RoleGrantedEventObject { + role: string + account: string + sender: string +} +export type RoleGrantedEvent = TypedEvent< + [string, string, string], + RoleGrantedEventObject +> + +export type RoleGrantedEventFilter = TypedEventFilter + +export interface RoleRevokedEventObject { + role: string + account: string + sender: string +} +export type RoleRevokedEvent = TypedEvent< + [string, string, string], + RoleRevokedEventObject +> + +export type RoleRevokedEventFilter = TypedEventFilter + +export interface FastBridge extends BaseContract { + connect(signerOrProvider: Signer | Provider | string): this + attach(addressOrName: string): this + deployed(): Promise + + interface: FastBridgeInterface + + queryFilter( + event: TypedEventFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise> + + listeners( + eventFilter?: TypedEventFilter + ): Array> + listeners(eventName?: string): Array + removeAllListeners( + eventFilter: TypedEventFilter + ): this + removeAllListeners(eventName?: string): this + off: OnEvent + on: OnEvent + once: OnEvent + removeListener: OnEvent + + functions: { + DEFAULT_ADMIN_ROLE(overrides?: CallOverrides): Promise<[string]> + + DISPUTE_PERIOD(overrides?: CallOverrides): Promise<[BigNumber]> + + FEE_BPS(overrides?: CallOverrides): Promise<[BigNumber]> + + FEE_RATE_MAX(overrides?: CallOverrides): Promise<[BigNumber]> + + GOVERNOR_ROLE(overrides?: CallOverrides): Promise<[string]> + + GUARD_ROLE(overrides?: CallOverrides): Promise<[string]> + + MIN_DEADLINE_PERIOD(overrides?: CallOverrides): Promise<[BigNumber]> + + RELAYER_ROLE(overrides?: CallOverrides): Promise<[string]> + + addGovernor( + _governor: string, + overrides?: Overrides & { from?: string } + ): Promise + + addGuard( + _guard: string, + overrides?: Overrides & { from?: string } + ): Promise + + addRelayer( + _relayer: string, + overrides?: Overrides & { from?: string } + ): Promise + + bridge( + params: IFastBridge.BridgeParamsStruct, + overrides?: PayableOverrides & { from?: string } + ): Promise + + bridgeProofs( + arg0: BytesLike, + overrides?: CallOverrides + ): Promise<[BigNumber, string] & { timestamp: BigNumber; relayer: string }> + + bridgeRelays(arg0: BytesLike, overrides?: CallOverrides): Promise<[boolean]> + + bridgeStatuses( + arg0: BytesLike, + overrides?: CallOverrides + ): Promise<[number]> + + canClaim( + transactionId: BytesLike, + relayer: string, + overrides?: CallOverrides + ): Promise<[boolean]> + + chainGasAmount(overrides?: CallOverrides): Promise<[BigNumber]> + + claim( + request: BytesLike, + to: string, + overrides?: Overrides & { from?: string } + ): Promise + + deployBlock(overrides?: CallOverrides): Promise<[BigNumber]> + + dispute( + transactionId: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise + + getBridgeTransaction( + request: BytesLike, + overrides?: CallOverrides + ): Promise<[IFastBridge.BridgeTransactionStructOutput]> + + getRoleAdmin(role: BytesLike, overrides?: CallOverrides): Promise<[string]> + + grantRole( + role: BytesLike, + account: string, + overrides?: Overrides & { from?: string } + ): Promise + + hasRole( + role: BytesLike, + account: string, + overrides?: CallOverrides + ): Promise<[boolean]> + + nonce(overrides?: CallOverrides): Promise<[BigNumber]> + + protocolFeeRate(overrides?: CallOverrides): Promise<[BigNumber]> + + protocolFees(arg0: string, overrides?: CallOverrides): Promise<[BigNumber]> + + prove( + request: BytesLike, + destTxHash: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise + + refund( + request: BytesLike, + to: string, + overrides?: Overrides & { from?: string } + ): Promise + + relay( + request: BytesLike, + overrides?: PayableOverrides & { from?: string } + ): Promise + + removeGovernor( + _governor: string, + overrides?: Overrides & { from?: string } + ): Promise + + removeGuard( + _guard: string, + overrides?: Overrides & { from?: string } + ): Promise + + removeRelayer( + _relayer: string, + overrides?: Overrides & { from?: string } + ): Promise + + renounceRole( + role: BytesLike, + callerConfirmation: string, + overrides?: Overrides & { from?: string } + ): Promise + + revokeRole( + role: BytesLike, + account: string, + overrides?: Overrides & { from?: string } + ): Promise + + setChainGasAmount( + newChainGasAmount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise + + setProtocolFeeRate( + newFeeRate: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise + + supportsInterface( + interfaceId: BytesLike, + overrides?: CallOverrides + ): Promise<[boolean]> + + sweepProtocolFees( + token: string, + recipient: string, + overrides?: Overrides & { from?: string } + ): Promise + } + + DEFAULT_ADMIN_ROLE(overrides?: CallOverrides): Promise + + DISPUTE_PERIOD(overrides?: CallOverrides): Promise + + FEE_BPS(overrides?: CallOverrides): Promise + + FEE_RATE_MAX(overrides?: CallOverrides): Promise + + GOVERNOR_ROLE(overrides?: CallOverrides): Promise + + GUARD_ROLE(overrides?: CallOverrides): Promise + + MIN_DEADLINE_PERIOD(overrides?: CallOverrides): Promise + + RELAYER_ROLE(overrides?: CallOverrides): Promise + + addGovernor( + _governor: string, + overrides?: Overrides & { from?: string } + ): Promise + + addGuard( + _guard: string, + overrides?: Overrides & { from?: string } + ): Promise + + addRelayer( + _relayer: string, + overrides?: Overrides & { from?: string } + ): Promise + + bridge( + params: IFastBridge.BridgeParamsStruct, + overrides?: PayableOverrides & { from?: string } + ): Promise + + bridgeProofs( + arg0: BytesLike, + overrides?: CallOverrides + ): Promise<[BigNumber, string] & { timestamp: BigNumber; relayer: string }> + + bridgeRelays(arg0: BytesLike, overrides?: CallOverrides): Promise + + bridgeStatuses(arg0: BytesLike, overrides?: CallOverrides): Promise + + canClaim( + transactionId: BytesLike, + relayer: string, + overrides?: CallOverrides + ): Promise + + chainGasAmount(overrides?: CallOverrides): Promise + + claim( + request: BytesLike, + to: string, + overrides?: Overrides & { from?: string } + ): Promise + + deployBlock(overrides?: CallOverrides): Promise + + dispute( + transactionId: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise + + getBridgeTransaction( + request: BytesLike, + overrides?: CallOverrides + ): Promise + + getRoleAdmin(role: BytesLike, overrides?: CallOverrides): Promise + + grantRole( + role: BytesLike, + account: string, + overrides?: Overrides & { from?: string } + ): Promise + + hasRole( + role: BytesLike, + account: string, + overrides?: CallOverrides + ): Promise + + nonce(overrides?: CallOverrides): Promise + + protocolFeeRate(overrides?: CallOverrides): Promise + + protocolFees(arg0: string, overrides?: CallOverrides): Promise + + prove( + request: BytesLike, + destTxHash: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise + + refund( + request: BytesLike, + to: string, + overrides?: Overrides & { from?: string } + ): Promise + + relay( + request: BytesLike, + overrides?: PayableOverrides & { from?: string } + ): Promise + + removeGovernor( + _governor: string, + overrides?: Overrides & { from?: string } + ): Promise + + removeGuard( + _guard: string, + overrides?: Overrides & { from?: string } + ): Promise + + removeRelayer( + _relayer: string, + overrides?: Overrides & { from?: string } + ): Promise + + renounceRole( + role: BytesLike, + callerConfirmation: string, + overrides?: Overrides & { from?: string } + ): Promise + + revokeRole( + role: BytesLike, + account: string, + overrides?: Overrides & { from?: string } + ): Promise + + setChainGasAmount( + newChainGasAmount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise + + setProtocolFeeRate( + newFeeRate: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise + + supportsInterface( + interfaceId: BytesLike, + overrides?: CallOverrides + ): Promise + + sweepProtocolFees( + token: string, + recipient: string, + overrides?: Overrides & { from?: string } + ): Promise + + callStatic: { + DEFAULT_ADMIN_ROLE(overrides?: CallOverrides): Promise + + DISPUTE_PERIOD(overrides?: CallOverrides): Promise + + FEE_BPS(overrides?: CallOverrides): Promise + + FEE_RATE_MAX(overrides?: CallOverrides): Promise + + GOVERNOR_ROLE(overrides?: CallOverrides): Promise + + GUARD_ROLE(overrides?: CallOverrides): Promise + + MIN_DEADLINE_PERIOD(overrides?: CallOverrides): Promise + + RELAYER_ROLE(overrides?: CallOverrides): Promise + + addGovernor(_governor: string, overrides?: CallOverrides): Promise + + addGuard(_guard: string, overrides?: CallOverrides): Promise + + addRelayer(_relayer: string, overrides?: CallOverrides): Promise + + bridge( + params: IFastBridge.BridgeParamsStruct, + overrides?: CallOverrides + ): Promise + + bridgeProofs( + arg0: BytesLike, + overrides?: CallOverrides + ): Promise<[BigNumber, string] & { timestamp: BigNumber; relayer: string }> + + bridgeRelays(arg0: BytesLike, overrides?: CallOverrides): Promise + + bridgeStatuses(arg0: BytesLike, overrides?: CallOverrides): Promise + + canClaim( + transactionId: BytesLike, + relayer: string, + overrides?: CallOverrides + ): Promise + + chainGasAmount(overrides?: CallOverrides): Promise + + claim( + request: BytesLike, + to: string, + overrides?: CallOverrides + ): Promise + + deployBlock(overrides?: CallOverrides): Promise + + dispute(transactionId: BytesLike, overrides?: CallOverrides): Promise + + getBridgeTransaction( + request: BytesLike, + overrides?: CallOverrides + ): Promise + + getRoleAdmin(role: BytesLike, overrides?: CallOverrides): Promise + + grantRole( + role: BytesLike, + account: string, + overrides?: CallOverrides + ): Promise + + hasRole( + role: BytesLike, + account: string, + overrides?: CallOverrides + ): Promise + + nonce(overrides?: CallOverrides): Promise + + protocolFeeRate(overrides?: CallOverrides): Promise + + protocolFees(arg0: string, overrides?: CallOverrides): Promise + + prove( + request: BytesLike, + destTxHash: BytesLike, + overrides?: CallOverrides + ): Promise + + refund( + request: BytesLike, + to: string, + overrides?: CallOverrides + ): Promise + + relay(request: BytesLike, overrides?: CallOverrides): Promise + + removeGovernor(_governor: string, overrides?: CallOverrides): Promise + + removeGuard(_guard: string, overrides?: CallOverrides): Promise + + removeRelayer(_relayer: string, overrides?: CallOverrides): Promise + + renounceRole( + role: BytesLike, + callerConfirmation: string, + overrides?: CallOverrides + ): Promise + + revokeRole( + role: BytesLike, + account: string, + overrides?: CallOverrides + ): Promise + + setChainGasAmount( + newChainGasAmount: BigNumberish, + overrides?: CallOverrides + ): Promise + + setProtocolFeeRate( + newFeeRate: BigNumberish, + overrides?: CallOverrides + ): Promise + + supportsInterface( + interfaceId: BytesLike, + overrides?: CallOverrides + ): Promise + + sweepProtocolFees( + token: string, + recipient: string, + overrides?: CallOverrides + ): Promise + } + + filters: { + 'BridgeDepositClaimed(bytes32,address,address,address,uint256)'( + transactionId?: null, + relayer?: null, + to?: null, + token?: null, + amount?: null + ): BridgeDepositClaimedEventFilter + BridgeDepositClaimed( + transactionId?: null, + relayer?: null, + to?: null, + token?: null, + amount?: null + ): BridgeDepositClaimedEventFilter + + 'BridgeDepositRefunded(bytes32,address,address,uint256)'( + transactionId?: null, + to?: null, + token?: null, + amount?: null + ): BridgeDepositRefundedEventFilter + BridgeDepositRefunded( + transactionId?: null, + to?: null, + token?: null, + amount?: null + ): BridgeDepositRefundedEventFilter + + 'BridgeProofDisputed(bytes32,address)'( + transactionId?: null, + relayer?: null + ): BridgeProofDisputedEventFilter + BridgeProofDisputed( + transactionId?: null, + relayer?: null + ): BridgeProofDisputedEventFilter + + 'BridgeProofProvided(bytes32,address,bytes32)'( + transactionId?: null, + relayer?: null, + transactionHash?: null + ): BridgeProofProvidedEventFilter + BridgeProofProvided( + transactionId?: null, + relayer?: null, + transactionHash?: null + ): BridgeProofProvidedEventFilter + + 'BridgeRelayed(bytes32,address,address,address,uint256,uint256)'( + transactionId?: null, + relayer?: null, + to?: null, + token?: null, + amount?: null, + chainGasAmount?: null + ): BridgeRelayedEventFilter + BridgeRelayed( + transactionId?: null, + relayer?: null, + to?: null, + token?: null, + amount?: null, + chainGasAmount?: null + ): BridgeRelayedEventFilter + + 'BridgeRequested(bytes32,address,bytes)'( + transactionId?: null, + sender?: null, + request?: null + ): BridgeRequestedEventFilter + BridgeRequested( + transactionId?: null, + sender?: null, + request?: null + ): BridgeRequestedEventFilter + + 'ChainGasAmountUpdated(uint256,uint256)'( + oldChainGasAmount?: null, + newChainGasAmount?: null + ): ChainGasAmountUpdatedEventFilter + ChainGasAmountUpdated( + oldChainGasAmount?: null, + newChainGasAmount?: null + ): ChainGasAmountUpdatedEventFilter + + 'FeeRateUpdated(uint256,uint256)'( + oldFeeRate?: null, + newFeeRate?: null + ): FeeRateUpdatedEventFilter + FeeRateUpdated( + oldFeeRate?: null, + newFeeRate?: null + ): FeeRateUpdatedEventFilter + + 'FeesSwept(address,address,uint256)'( + token?: null, + recipient?: null, + amount?: null + ): FeesSweptEventFilter + FeesSwept( + token?: null, + recipient?: null, + amount?: null + ): FeesSweptEventFilter + + 'GovernorAdded(address)'(governor?: null): GovernorAddedEventFilter + GovernorAdded(governor?: null): GovernorAddedEventFilter + + 'GovernorRemoved(address)'(governor?: null): GovernorRemovedEventFilter + GovernorRemoved(governor?: null): GovernorRemovedEventFilter + + 'GuardAdded(address)'(guard?: null): GuardAddedEventFilter + GuardAdded(guard?: null): GuardAddedEventFilter + + 'GuardRemoved(address)'(guard?: null): GuardRemovedEventFilter + GuardRemoved(guard?: null): GuardRemovedEventFilter + + 'RelayerAdded(address)'(relayer?: null): RelayerAddedEventFilter + RelayerAdded(relayer?: null): RelayerAddedEventFilter + + 'RelayerRemoved(address)'(relayer?: null): RelayerRemovedEventFilter + RelayerRemoved(relayer?: null): RelayerRemovedEventFilter + + 'RoleAdminChanged(bytes32,bytes32,bytes32)'( + role?: BytesLike | null, + previousAdminRole?: BytesLike | null, + newAdminRole?: BytesLike | null + ): RoleAdminChangedEventFilter + RoleAdminChanged( + role?: BytesLike | null, + previousAdminRole?: BytesLike | null, + newAdminRole?: BytesLike | null + ): RoleAdminChangedEventFilter + + 'RoleGranted(bytes32,address,address)'( + role?: BytesLike | null, + account?: string | null, + sender?: string | null + ): RoleGrantedEventFilter + RoleGranted( + role?: BytesLike | null, + account?: string | null, + sender?: string | null + ): RoleGrantedEventFilter + + 'RoleRevoked(bytes32,address,address)'( + role?: BytesLike | null, + account?: string | null, + sender?: string | null + ): RoleRevokedEventFilter + RoleRevoked( + role?: BytesLike | null, + account?: string | null, + sender?: string | null + ): RoleRevokedEventFilter + } + + estimateGas: { + DEFAULT_ADMIN_ROLE(overrides?: CallOverrides): Promise + + DISPUTE_PERIOD(overrides?: CallOverrides): Promise + + FEE_BPS(overrides?: CallOverrides): Promise + + FEE_RATE_MAX(overrides?: CallOverrides): Promise + + GOVERNOR_ROLE(overrides?: CallOverrides): Promise + + GUARD_ROLE(overrides?: CallOverrides): Promise + + MIN_DEADLINE_PERIOD(overrides?: CallOverrides): Promise + + RELAYER_ROLE(overrides?: CallOverrides): Promise + + addGovernor( + _governor: string, + overrides?: Overrides & { from?: string } + ): Promise + + addGuard( + _guard: string, + overrides?: Overrides & { from?: string } + ): Promise + + addRelayer( + _relayer: string, + overrides?: Overrides & { from?: string } + ): Promise + + bridge( + params: IFastBridge.BridgeParamsStruct, + overrides?: PayableOverrides & { from?: string } + ): Promise + + bridgeProofs(arg0: BytesLike, overrides?: CallOverrides): Promise + + bridgeRelays(arg0: BytesLike, overrides?: CallOverrides): Promise + + bridgeStatuses( + arg0: BytesLike, + overrides?: CallOverrides + ): Promise + + canClaim( + transactionId: BytesLike, + relayer: string, + overrides?: CallOverrides + ): Promise + + chainGasAmount(overrides?: CallOverrides): Promise + + claim( + request: BytesLike, + to: string, + overrides?: Overrides & { from?: string } + ): Promise + + deployBlock(overrides?: CallOverrides): Promise + + dispute( + transactionId: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise + + getBridgeTransaction( + request: BytesLike, + overrides?: CallOverrides + ): Promise + + getRoleAdmin(role: BytesLike, overrides?: CallOverrides): Promise + + grantRole( + role: BytesLike, + account: string, + overrides?: Overrides & { from?: string } + ): Promise + + hasRole( + role: BytesLike, + account: string, + overrides?: CallOverrides + ): Promise + + nonce(overrides?: CallOverrides): Promise + + protocolFeeRate(overrides?: CallOverrides): Promise + + protocolFees(arg0: string, overrides?: CallOverrides): Promise + + prove( + request: BytesLike, + destTxHash: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise + + refund( + request: BytesLike, + to: string, + overrides?: Overrides & { from?: string } + ): Promise + + relay( + request: BytesLike, + overrides?: PayableOverrides & { from?: string } + ): Promise + + removeGovernor( + _governor: string, + overrides?: Overrides & { from?: string } + ): Promise + + removeGuard( + _guard: string, + overrides?: Overrides & { from?: string } + ): Promise + + removeRelayer( + _relayer: string, + overrides?: Overrides & { from?: string } + ): Promise + + renounceRole( + role: BytesLike, + callerConfirmation: string, + overrides?: Overrides & { from?: string } + ): Promise + + revokeRole( + role: BytesLike, + account: string, + overrides?: Overrides & { from?: string } + ): Promise + + setChainGasAmount( + newChainGasAmount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise + + setProtocolFeeRate( + newFeeRate: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise + + supportsInterface( + interfaceId: BytesLike, + overrides?: CallOverrides + ): Promise + + sweepProtocolFees( + token: string, + recipient: string, + overrides?: Overrides & { from?: string } + ): Promise + } + + populateTransaction: { + DEFAULT_ADMIN_ROLE(overrides?: CallOverrides): Promise + + DISPUTE_PERIOD(overrides?: CallOverrides): Promise + + FEE_BPS(overrides?: CallOverrides): Promise + + FEE_RATE_MAX(overrides?: CallOverrides): Promise + + GOVERNOR_ROLE(overrides?: CallOverrides): Promise + + GUARD_ROLE(overrides?: CallOverrides): Promise + + MIN_DEADLINE_PERIOD( + overrides?: CallOverrides + ): Promise + + RELAYER_ROLE(overrides?: CallOverrides): Promise + + addGovernor( + _governor: string, + overrides?: Overrides & { from?: string } + ): Promise + + addGuard( + _guard: string, + overrides?: Overrides & { from?: string } + ): Promise + + addRelayer( + _relayer: string, + overrides?: Overrides & { from?: string } + ): Promise + + bridge( + params: IFastBridge.BridgeParamsStruct, + overrides?: PayableOverrides & { from?: string } + ): Promise + + bridgeProofs( + arg0: BytesLike, + overrides?: CallOverrides + ): Promise + + bridgeRelays( + arg0: BytesLike, + overrides?: CallOverrides + ): Promise + + bridgeStatuses( + arg0: BytesLike, + overrides?: CallOverrides + ): Promise + + canClaim( + transactionId: BytesLike, + relayer: string, + overrides?: CallOverrides + ): Promise + + chainGasAmount(overrides?: CallOverrides): Promise + + claim( + request: BytesLike, + to: string, + overrides?: Overrides & { from?: string } + ): Promise + + deployBlock(overrides?: CallOverrides): Promise + + dispute( + transactionId: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise + + getBridgeTransaction( + request: BytesLike, + overrides?: CallOverrides + ): Promise + + getRoleAdmin( + role: BytesLike, + overrides?: CallOverrides + ): Promise + + grantRole( + role: BytesLike, + account: string, + overrides?: Overrides & { from?: string } + ): Promise + + hasRole( + role: BytesLike, + account: string, + overrides?: CallOverrides + ): Promise + + nonce(overrides?: CallOverrides): Promise + + protocolFeeRate(overrides?: CallOverrides): Promise + + protocolFees( + arg0: string, + overrides?: CallOverrides + ): Promise + + prove( + request: BytesLike, + destTxHash: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise + + refund( + request: BytesLike, + to: string, + overrides?: Overrides & { from?: string } + ): Promise + + relay( + request: BytesLike, + overrides?: PayableOverrides & { from?: string } + ): Promise + + removeGovernor( + _governor: string, + overrides?: Overrides & { from?: string } + ): Promise + + removeGuard( + _guard: string, + overrides?: Overrides & { from?: string } + ): Promise + + removeRelayer( + _relayer: string, + overrides?: Overrides & { from?: string } + ): Promise + + renounceRole( + role: BytesLike, + callerConfirmation: string, + overrides?: Overrides & { from?: string } + ): Promise + + revokeRole( + role: BytesLike, + account: string, + overrides?: Overrides & { from?: string } + ): Promise + + setChainGasAmount( + newChainGasAmount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise + + setProtocolFeeRate( + newFeeRate: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise + + supportsInterface( + interfaceId: BytesLike, + overrides?: CallOverrides + ): Promise + + sweepProtocolFees( + token: string, + recipient: string, + overrides?: Overrides & { from?: string } + ): Promise + } +} diff --git a/packages/sdk-router/src/typechain/SynapseBridge.ts b/packages/sdk-router/src/typechain/SynapseBridge.ts index 7d66a8534a..0b141e44aa 100644 --- a/packages/sdk-router/src/typechain/SynapseBridge.ts +++ b/packages/sdk-router/src/typechain/SynapseBridge.ts @@ -4,11 +4,11 @@ import type { BaseContract, BigNumber, + BigNumberish, BytesLike, CallOverrides, ContractTransaction, Overrides, - PayableOverrides, PopulatedTransaction, Signer, utils, @@ -24,83 +24,613 @@ import type { TypedEvent, TypedListener, OnEvent, - PromiseOrValue, } from './common' export interface SynapseBridgeInterface extends utils.Interface { functions: { - 'admin()': FunctionFragment - 'changeAdmin(address)': FunctionFragment - 'implementation()': FunctionFragment - 'upgradeTo(address)': FunctionFragment - 'upgradeToAndCall(address,bytes)': FunctionFragment + 'DEFAULT_ADMIN_ROLE()': FunctionFragment + 'GOVERNANCE_ROLE()': FunctionFragment + 'NODEGROUP_ROLE()': FunctionFragment + 'WETH_ADDRESS()': FunctionFragment + 'addKappas(bytes32[])': FunctionFragment + 'bridgeVersion()': FunctionFragment + 'chainGasAmount()': FunctionFragment + 'deposit(address,uint256,address,uint256)': FunctionFragment + 'depositAndSwap(address,uint256,address,uint256,uint8,uint8,uint256,uint256)': FunctionFragment + 'getFeeBalance(address)': FunctionFragment + 'getRoleAdmin(bytes32)': FunctionFragment + 'getRoleMember(bytes32,uint256)': FunctionFragment + 'getRoleMemberCount(bytes32)': FunctionFragment + 'grantRole(bytes32,address)': FunctionFragment + 'hasRole(bytes32,address)': FunctionFragment + 'initialize()': FunctionFragment + 'kappaExists(bytes32)': FunctionFragment + 'mint(address,address,uint256,uint256,bytes32)': FunctionFragment + 'mintAndSwap(address,address,uint256,uint256,address,uint8,uint8,uint256,uint256,bytes32)': FunctionFragment + 'pause()': FunctionFragment + 'paused()': FunctionFragment + 'redeem(address,uint256,address,uint256)': FunctionFragment + 'redeemAndRemove(address,uint256,address,uint256,uint8,uint256,uint256)': FunctionFragment + 'redeemAndSwap(address,uint256,address,uint256,uint8,uint8,uint256,uint256)': FunctionFragment + 'redeemV2(bytes32,uint256,address,uint256)': FunctionFragment + 'renounceRole(bytes32,address)': FunctionFragment + 'revokeRole(bytes32,address)': FunctionFragment + 'setChainGasAmount(uint256)': FunctionFragment + 'setWethAddress(address)': FunctionFragment + 'startBlockNumber()': FunctionFragment + 'unpause()': FunctionFragment + 'withdraw(address,address,uint256,uint256,bytes32)': FunctionFragment + 'withdrawAndRemove(address,address,uint256,uint256,address,uint8,uint256,uint256,bytes32)': FunctionFragment + 'withdrawFees(address,address)': FunctionFragment } getFunction( nameOrSignatureOrTopic: - | 'admin' - | 'changeAdmin' - | 'implementation' - | 'upgradeTo' - | 'upgradeToAndCall' + | 'DEFAULT_ADMIN_ROLE' + | 'GOVERNANCE_ROLE' + | 'NODEGROUP_ROLE' + | 'WETH_ADDRESS' + | 'addKappas' + | 'bridgeVersion' + | 'chainGasAmount' + | 'deposit' + | 'depositAndSwap' + | 'getFeeBalance' + | 'getRoleAdmin' + | 'getRoleMember' + | 'getRoleMemberCount' + | 'grantRole' + | 'hasRole' + | 'initialize' + | 'kappaExists' + | 'mint' + | 'mintAndSwap' + | 'pause' + | 'paused' + | 'redeem' + | 'redeemAndRemove' + | 'redeemAndSwap' + | 'redeemV2' + | 'renounceRole' + | 'revokeRole' + | 'setChainGasAmount' + | 'setWethAddress' + | 'startBlockNumber' + | 'unpause' + | 'withdraw' + | 'withdrawAndRemove' + | 'withdrawFees' ): FunctionFragment - encodeFunctionData(functionFragment: 'admin', values?: undefined): string encodeFunctionData( - functionFragment: 'changeAdmin', - values: [PromiseOrValue] + functionFragment: 'DEFAULT_ADMIN_ROLE', + values?: undefined + ): string + encodeFunctionData( + functionFragment: 'GOVERNANCE_ROLE', + values?: undefined + ): string + encodeFunctionData( + functionFragment: 'NODEGROUP_ROLE', + values?: undefined + ): string + encodeFunctionData( + functionFragment: 'WETH_ADDRESS', + values?: undefined + ): string + encodeFunctionData( + functionFragment: 'addKappas', + values: [BytesLike[]] + ): string + encodeFunctionData( + functionFragment: 'bridgeVersion', + values?: undefined + ): string + encodeFunctionData( + functionFragment: 'chainGasAmount', + values?: undefined + ): string + encodeFunctionData( + functionFragment: 'deposit', + values: [string, BigNumberish, string, BigNumberish] + ): string + encodeFunctionData( + functionFragment: 'depositAndSwap', + values: [ + string, + BigNumberish, + string, + BigNumberish, + BigNumberish, + BigNumberish, + BigNumberish, + BigNumberish + ] + ): string + encodeFunctionData( + functionFragment: 'getFeeBalance', + values: [string] + ): string + encodeFunctionData( + functionFragment: 'getRoleAdmin', + values: [BytesLike] + ): string + encodeFunctionData( + functionFragment: 'getRoleMember', + values: [BytesLike, BigNumberish] + ): string + encodeFunctionData( + functionFragment: 'getRoleMemberCount', + values: [BytesLike] + ): string + encodeFunctionData( + functionFragment: 'grantRole', + values: [BytesLike, string] + ): string + encodeFunctionData( + functionFragment: 'hasRole', + values: [BytesLike, string] + ): string + encodeFunctionData(functionFragment: 'initialize', values?: undefined): string + encodeFunctionData( + functionFragment: 'kappaExists', + values: [BytesLike] + ): string + encodeFunctionData( + functionFragment: 'mint', + values: [string, string, BigNumberish, BigNumberish, BytesLike] + ): string + encodeFunctionData( + functionFragment: 'mintAndSwap', + values: [ + string, + string, + BigNumberish, + BigNumberish, + string, + BigNumberish, + BigNumberish, + BigNumberish, + BigNumberish, + BytesLike + ] + ): string + encodeFunctionData(functionFragment: 'pause', values?: undefined): string + encodeFunctionData(functionFragment: 'paused', values?: undefined): string + encodeFunctionData( + functionFragment: 'redeem', + values: [string, BigNumberish, string, BigNumberish] + ): string + encodeFunctionData( + functionFragment: 'redeemAndRemove', + values: [ + string, + BigNumberish, + string, + BigNumberish, + BigNumberish, + BigNumberish, + BigNumberish + ] + ): string + encodeFunctionData( + functionFragment: 'redeemAndSwap', + values: [ + string, + BigNumberish, + string, + BigNumberish, + BigNumberish, + BigNumberish, + BigNumberish, + BigNumberish + ] + ): string + encodeFunctionData( + functionFragment: 'redeemV2', + values: [BytesLike, BigNumberish, string, BigNumberish] + ): string + encodeFunctionData( + functionFragment: 'renounceRole', + values: [BytesLike, string] + ): string + encodeFunctionData( + functionFragment: 'revokeRole', + values: [BytesLike, string] + ): string + encodeFunctionData( + functionFragment: 'setChainGasAmount', + values: [BigNumberish] ): string encodeFunctionData( - functionFragment: 'implementation', + functionFragment: 'setWethAddress', + values: [string] + ): string + encodeFunctionData( + functionFragment: 'startBlockNumber', values?: undefined ): string + encodeFunctionData(functionFragment: 'unpause', values?: undefined): string + encodeFunctionData( + functionFragment: 'withdraw', + values: [string, string, BigNumberish, BigNumberish, BytesLike] + ): string encodeFunctionData( - functionFragment: 'upgradeTo', - values: [PromiseOrValue] + functionFragment: 'withdrawAndRemove', + values: [ + string, + string, + BigNumberish, + BigNumberish, + string, + BigNumberish, + BigNumberish, + BigNumberish, + BytesLike + ] ): string encodeFunctionData( - functionFragment: 'upgradeToAndCall', - values: [PromiseOrValue, PromiseOrValue] + functionFragment: 'withdrawFees', + values: [string, string] ): string - decodeFunctionResult(functionFragment: 'admin', data: BytesLike): Result - decodeFunctionResult(functionFragment: 'changeAdmin', data: BytesLike): Result decodeFunctionResult( - functionFragment: 'implementation', + functionFragment: 'DEFAULT_ADMIN_ROLE', + data: BytesLike + ): Result + decodeFunctionResult( + functionFragment: 'GOVERNANCE_ROLE', + data: BytesLike + ): Result + decodeFunctionResult( + functionFragment: 'NODEGROUP_ROLE', + data: BytesLike + ): Result + decodeFunctionResult( + functionFragment: 'WETH_ADDRESS', + data: BytesLike + ): Result + decodeFunctionResult(functionFragment: 'addKappas', data: BytesLike): Result + decodeFunctionResult( + functionFragment: 'bridgeVersion', + data: BytesLike + ): Result + decodeFunctionResult( + functionFragment: 'chainGasAmount', + data: BytesLike + ): Result + decodeFunctionResult(functionFragment: 'deposit', data: BytesLike): Result + decodeFunctionResult( + functionFragment: 'depositAndSwap', + data: BytesLike + ): Result + decodeFunctionResult( + functionFragment: 'getFeeBalance', + data: BytesLike + ): Result + decodeFunctionResult( + functionFragment: 'getRoleAdmin', + data: BytesLike + ): Result + decodeFunctionResult( + functionFragment: 'getRoleMember', + data: BytesLike + ): Result + decodeFunctionResult( + functionFragment: 'getRoleMemberCount', + data: BytesLike + ): Result + decodeFunctionResult(functionFragment: 'grantRole', data: BytesLike): Result + decodeFunctionResult(functionFragment: 'hasRole', data: BytesLike): Result + decodeFunctionResult(functionFragment: 'initialize', data: BytesLike): Result + decodeFunctionResult(functionFragment: 'kappaExists', data: BytesLike): Result + decodeFunctionResult(functionFragment: 'mint', data: BytesLike): Result + decodeFunctionResult(functionFragment: 'mintAndSwap', data: BytesLike): Result + decodeFunctionResult(functionFragment: 'pause', data: BytesLike): Result + decodeFunctionResult(functionFragment: 'paused', data: BytesLike): Result + decodeFunctionResult(functionFragment: 'redeem', data: BytesLike): Result + decodeFunctionResult( + functionFragment: 'redeemAndRemove', + data: BytesLike + ): Result + decodeFunctionResult( + functionFragment: 'redeemAndSwap', + data: BytesLike + ): Result + decodeFunctionResult(functionFragment: 'redeemV2', data: BytesLike): Result + decodeFunctionResult( + functionFragment: 'renounceRole', + data: BytesLike + ): Result + decodeFunctionResult(functionFragment: 'revokeRole', data: BytesLike): Result + decodeFunctionResult( + functionFragment: 'setChainGasAmount', + data: BytesLike + ): Result + decodeFunctionResult( + functionFragment: 'setWethAddress', + data: BytesLike + ): Result + decodeFunctionResult( + functionFragment: 'startBlockNumber', + data: BytesLike + ): Result + decodeFunctionResult(functionFragment: 'unpause', data: BytesLike): Result + decodeFunctionResult(functionFragment: 'withdraw', data: BytesLike): Result + decodeFunctionResult( + functionFragment: 'withdrawAndRemove', data: BytesLike ): Result - decodeFunctionResult(functionFragment: 'upgradeTo', data: BytesLike): Result decodeFunctionResult( - functionFragment: 'upgradeToAndCall', + functionFragment: 'withdrawFees', data: BytesLike ): Result events: { - 'AdminChanged(address,address)': EventFragment - 'Upgraded(address)': EventFragment + 'Paused(address)': EventFragment + 'RoleAdminChanged(bytes32,bytes32,bytes32)': EventFragment + 'RoleGranted(bytes32,address,address)': EventFragment + 'RoleRevoked(bytes32,address,address)': EventFragment + 'TokenDeposit(address,uint256,address,uint256)': EventFragment + 'TokenDepositAndSwap(address,uint256,address,uint256,uint8,uint8,uint256,uint256)': EventFragment + 'TokenMint(address,address,uint256,uint256,bytes32)': EventFragment + 'TokenMintAndSwap(address,address,uint256,uint256,uint8,uint8,uint256,uint256,bool,bytes32)': EventFragment + 'TokenRedeem(address,uint256,address,uint256)': EventFragment + 'TokenRedeemAndRemove(address,uint256,address,uint256,uint8,uint256,uint256)': EventFragment + 'TokenRedeemAndSwap(address,uint256,address,uint256,uint8,uint8,uint256,uint256)': EventFragment + 'TokenRedeemV2(bytes32,uint256,address,uint256)': EventFragment + 'TokenWithdraw(address,address,uint256,uint256,bytes32)': EventFragment + 'TokenWithdrawAndRemove(address,address,uint256,uint256,uint8,uint256,uint256,bool,bytes32)': EventFragment + 'Unpaused(address)': EventFragment } - getEvent(nameOrSignatureOrTopic: 'AdminChanged'): EventFragment - getEvent(nameOrSignatureOrTopic: 'Upgraded'): EventFragment + getEvent(nameOrSignatureOrTopic: 'Paused'): EventFragment + getEvent(nameOrSignatureOrTopic: 'RoleAdminChanged'): EventFragment + getEvent(nameOrSignatureOrTopic: 'RoleGranted'): EventFragment + getEvent(nameOrSignatureOrTopic: 'RoleRevoked'): EventFragment + getEvent(nameOrSignatureOrTopic: 'TokenDeposit'): EventFragment + getEvent(nameOrSignatureOrTopic: 'TokenDepositAndSwap'): EventFragment + getEvent(nameOrSignatureOrTopic: 'TokenMint'): EventFragment + getEvent(nameOrSignatureOrTopic: 'TokenMintAndSwap'): EventFragment + getEvent(nameOrSignatureOrTopic: 'TokenRedeem'): EventFragment + getEvent(nameOrSignatureOrTopic: 'TokenRedeemAndRemove'): EventFragment + getEvent(nameOrSignatureOrTopic: 'TokenRedeemAndSwap'): EventFragment + getEvent(nameOrSignatureOrTopic: 'TokenRedeemV2'): EventFragment + getEvent(nameOrSignatureOrTopic: 'TokenWithdraw'): EventFragment + getEvent(nameOrSignatureOrTopic: 'TokenWithdrawAndRemove'): EventFragment + getEvent(nameOrSignatureOrTopic: 'Unpaused'): EventFragment +} + +export interface PausedEventObject { + account: string +} +export type PausedEvent = TypedEvent<[string], PausedEventObject> + +export type PausedEventFilter = TypedEventFilter + +export interface RoleAdminChangedEventObject { + role: string + previousAdminRole: string + newAdminRole: string +} +export type RoleAdminChangedEvent = TypedEvent< + [string, string, string], + RoleAdminChangedEventObject +> + +export type RoleAdminChangedEventFilter = + TypedEventFilter + +export interface RoleGrantedEventObject { + role: string + account: string + sender: string +} +export type RoleGrantedEvent = TypedEvent< + [string, string, string], + RoleGrantedEventObject +> + +export type RoleGrantedEventFilter = TypedEventFilter + +export interface RoleRevokedEventObject { + role: string + account: string + sender: string +} +export type RoleRevokedEvent = TypedEvent< + [string, string, string], + RoleRevokedEventObject +> + +export type RoleRevokedEventFilter = TypedEventFilter + +export interface TokenDepositEventObject { + to: string + chainId: BigNumber + token: string + amount: BigNumber +} +export type TokenDepositEvent = TypedEvent< + [string, BigNumber, string, BigNumber], + TokenDepositEventObject +> + +export type TokenDepositEventFilter = TypedEventFilter + +export interface TokenDepositAndSwapEventObject { + to: string + chainId: BigNumber + token: string + amount: BigNumber + tokenIndexFrom: number + tokenIndexTo: number + minDy: BigNumber + deadline: BigNumber +} +export type TokenDepositAndSwapEvent = TypedEvent< + [string, BigNumber, string, BigNumber, number, number, BigNumber, BigNumber], + TokenDepositAndSwapEventObject +> + +export type TokenDepositAndSwapEventFilter = + TypedEventFilter + +export interface TokenMintEventObject { + to: string + token: string + amount: BigNumber + fee: BigNumber + kappa: string +} +export type TokenMintEvent = TypedEvent< + [string, string, BigNumber, BigNumber, string], + TokenMintEventObject +> + +export type TokenMintEventFilter = TypedEventFilter + +export interface TokenMintAndSwapEventObject { + to: string + token: string + amount: BigNumber + fee: BigNumber + tokenIndexFrom: number + tokenIndexTo: number + minDy: BigNumber + deadline: BigNumber + swapSuccess: boolean + kappa: string +} +export type TokenMintAndSwapEvent = TypedEvent< + [ + string, + string, + BigNumber, + BigNumber, + number, + number, + BigNumber, + BigNumber, + boolean, + string + ], + TokenMintAndSwapEventObject +> + +export type TokenMintAndSwapEventFilter = + TypedEventFilter + +export interface TokenRedeemEventObject { + to: string + chainId: BigNumber + token: string + amount: BigNumber } +export type TokenRedeemEvent = TypedEvent< + [string, BigNumber, string, BigNumber], + TokenRedeemEventObject +> + +export type TokenRedeemEventFilter = TypedEventFilter -export interface AdminChangedEventObject { - previousAdmin: string - newAdmin: string +export interface TokenRedeemAndRemoveEventObject { + to: string + chainId: BigNumber + token: string + amount: BigNumber + swapTokenIndex: number + swapMinAmount: BigNumber + swapDeadline: BigNumber } -export type AdminChangedEvent = TypedEvent< - [string, string], - AdminChangedEventObject +export type TokenRedeemAndRemoveEvent = TypedEvent< + [string, BigNumber, string, BigNumber, number, BigNumber, BigNumber], + TokenRedeemAndRemoveEventObject > -export type AdminChangedEventFilter = TypedEventFilter +export type TokenRedeemAndRemoveEventFilter = + TypedEventFilter -export interface UpgradedEventObject { - implementation: string +export interface TokenRedeemAndSwapEventObject { + to: string + chainId: BigNumber + token: string + amount: BigNumber + tokenIndexFrom: number + tokenIndexTo: number + minDy: BigNumber + deadline: BigNumber } -export type UpgradedEvent = TypedEvent<[string], UpgradedEventObject> +export type TokenRedeemAndSwapEvent = TypedEvent< + [string, BigNumber, string, BigNumber, number, number, BigNumber, BigNumber], + TokenRedeemAndSwapEventObject +> + +export type TokenRedeemAndSwapEventFilter = + TypedEventFilter + +export interface TokenRedeemV2EventObject { + to: string + chainId: BigNumber + token: string + amount: BigNumber +} +export type TokenRedeemV2Event = TypedEvent< + [string, BigNumber, string, BigNumber], + TokenRedeemV2EventObject +> -export type UpgradedEventFilter = TypedEventFilter +export type TokenRedeemV2EventFilter = TypedEventFilter + +export interface TokenWithdrawEventObject { + to: string + token: string + amount: BigNumber + fee: BigNumber + kappa: string +} +export type TokenWithdrawEvent = TypedEvent< + [string, string, BigNumber, BigNumber, string], + TokenWithdrawEventObject +> + +export type TokenWithdrawEventFilter = TypedEventFilter + +export interface TokenWithdrawAndRemoveEventObject { + to: string + token: string + amount: BigNumber + fee: BigNumber + swapTokenIndex: number + swapMinAmount: BigNumber + swapDeadline: BigNumber + swapSuccess: boolean + kappa: string +} +export type TokenWithdrawAndRemoveEvent = TypedEvent< + [ + string, + string, + BigNumber, + BigNumber, + number, + BigNumber, + BigNumber, + boolean, + string + ], + TokenWithdrawAndRemoveEventObject +> + +export type TokenWithdrawAndRemoveEventFilter = + TypedEventFilter + +export interface UnpausedEventObject { + account: string +} +export type UnpausedEvent = TypedEvent<[string], UnpausedEventObject> + +export type UnpausedEventFilter = TypedEventFilter export interface SynapseBridge extends BaseContract { connect(signerOrProvider: Signer | Provider | string): this @@ -129,141 +659,1203 @@ export interface SynapseBridge extends BaseContract { removeListener: OnEvent functions: { - admin( - overrides?: Overrides & { from?: PromiseOrValue } + DEFAULT_ADMIN_ROLE(overrides?: CallOverrides): Promise<[string]> + + GOVERNANCE_ROLE(overrides?: CallOverrides): Promise<[string]> + + NODEGROUP_ROLE(overrides?: CallOverrides): Promise<[string]> + + WETH_ADDRESS(overrides?: CallOverrides): Promise<[string]> + + addKappas( + kappas: BytesLike[], + overrides?: Overrides & { from?: string } + ): Promise + + bridgeVersion(overrides?: CallOverrides): Promise<[BigNumber]> + + chainGasAmount(overrides?: CallOverrides): Promise<[BigNumber]> + + deposit( + to: string, + chainId: BigNumberish, + token: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise + + depositAndSwap( + to: string, + chainId: BigNumberish, + token: string, + amount: BigNumberish, + tokenIndexFrom: BigNumberish, + tokenIndexTo: BigNumberish, + minDy: BigNumberish, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise + + getFeeBalance( + tokenAddress: string, + overrides?: CallOverrides + ): Promise<[BigNumber]> + + getRoleAdmin(role: BytesLike, overrides?: CallOverrides): Promise<[string]> + + getRoleMember( + role: BytesLike, + index: BigNumberish, + overrides?: CallOverrides + ): Promise<[string]> + + getRoleMemberCount( + role: BytesLike, + overrides?: CallOverrides + ): Promise<[BigNumber]> + + grantRole( + role: BytesLike, + account: string, + overrides?: Overrides & { from?: string } + ): Promise + + hasRole( + role: BytesLike, + account: string, + overrides?: CallOverrides + ): Promise<[boolean]> + + initialize( + overrides?: Overrides & { from?: string } + ): Promise + + kappaExists(kappa: BytesLike, overrides?: CallOverrides): Promise<[boolean]> + + mint( + to: string, + token: string, + amount: BigNumberish, + fee: BigNumberish, + kappa: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise + + mintAndSwap( + to: string, + token: string, + amount: BigNumberish, + fee: BigNumberish, + pool: string, + tokenIndexFrom: BigNumberish, + tokenIndexTo: BigNumberish, + minDy: BigNumberish, + deadline: BigNumberish, + kappa: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise + + pause( + overrides?: Overrides & { from?: string } + ): Promise + + paused(overrides?: CallOverrides): Promise<[boolean]> + + redeem( + to: string, + chainId: BigNumberish, + token: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise + + redeemAndRemove( + to: string, + chainId: BigNumberish, + token: string, + amount: BigNumberish, + swapTokenIndex: BigNumberish, + swapMinAmount: BigNumberish, + swapDeadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise + + redeemAndSwap( + to: string, + chainId: BigNumberish, + token: string, + amount: BigNumberish, + tokenIndexFrom: BigNumberish, + tokenIndexTo: BigNumberish, + minDy: BigNumberish, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise + + redeemV2( + to: BytesLike, + chainId: BigNumberish, + token: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } ): Promise - changeAdmin( - newAdmin: PromiseOrValue, - overrides?: Overrides & { from?: PromiseOrValue } + renounceRole( + role: BytesLike, + account: string, + overrides?: Overrides & { from?: string } ): Promise - implementation( - overrides?: Overrides & { from?: PromiseOrValue } + revokeRole( + role: BytesLike, + account: string, + overrides?: Overrides & { from?: string } ): Promise - upgradeTo( - newImplementation: PromiseOrValue, - overrides?: Overrides & { from?: PromiseOrValue } + setChainGasAmount( + amount: BigNumberish, + overrides?: Overrides & { from?: string } ): Promise - upgradeToAndCall( - newImplementation: PromiseOrValue, - data: PromiseOrValue, - overrides?: PayableOverrides & { from?: PromiseOrValue } + setWethAddress( + _wethAddress: string, + overrides?: Overrides & { from?: string } + ): Promise + + startBlockNumber(overrides?: CallOverrides): Promise<[BigNumber]> + + unpause( + overrides?: Overrides & { from?: string } + ): Promise + + withdraw( + to: string, + token: string, + amount: BigNumberish, + fee: BigNumberish, + kappa: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise + + withdrawAndRemove( + to: string, + token: string, + amount: BigNumberish, + fee: BigNumberish, + pool: string, + swapTokenIndex: BigNumberish, + swapMinAmount: BigNumberish, + swapDeadline: BigNumberish, + kappa: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise + + withdrawFees( + token: string, + to: string, + overrides?: Overrides & { from?: string } ): Promise } - admin( - overrides?: Overrides & { from?: PromiseOrValue } + DEFAULT_ADMIN_ROLE(overrides?: CallOverrides): Promise + + GOVERNANCE_ROLE(overrides?: CallOverrides): Promise + + NODEGROUP_ROLE(overrides?: CallOverrides): Promise + + WETH_ADDRESS(overrides?: CallOverrides): Promise + + addKappas( + kappas: BytesLike[], + overrides?: Overrides & { from?: string } ): Promise - changeAdmin( - newAdmin: PromiseOrValue, - overrides?: Overrides & { from?: PromiseOrValue } + bridgeVersion(overrides?: CallOverrides): Promise + + chainGasAmount(overrides?: CallOverrides): Promise + + deposit( + to: string, + chainId: BigNumberish, + token: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } ): Promise - implementation( - overrides?: Overrides & { from?: PromiseOrValue } + depositAndSwap( + to: string, + chainId: BigNumberish, + token: string, + amount: BigNumberish, + tokenIndexFrom: BigNumberish, + tokenIndexTo: BigNumberish, + minDy: BigNumberish, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } ): Promise - upgradeTo( - newImplementation: PromiseOrValue, - overrides?: Overrides & { from?: PromiseOrValue } + getFeeBalance( + tokenAddress: string, + overrides?: CallOverrides + ): Promise + + getRoleAdmin(role: BytesLike, overrides?: CallOverrides): Promise + + getRoleMember( + role: BytesLike, + index: BigNumberish, + overrides?: CallOverrides + ): Promise + + getRoleMemberCount( + role: BytesLike, + overrides?: CallOverrides + ): Promise + + grantRole( + role: BytesLike, + account: string, + overrides?: Overrides & { from?: string } + ): Promise + + hasRole( + role: BytesLike, + account: string, + overrides?: CallOverrides + ): Promise + + initialize( + overrides?: Overrides & { from?: string } + ): Promise + + kappaExists(kappa: BytesLike, overrides?: CallOverrides): Promise + + mint( + to: string, + token: string, + amount: BigNumberish, + fee: BigNumberish, + kappa: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise + + mintAndSwap( + to: string, + token: string, + amount: BigNumberish, + fee: BigNumberish, + pool: string, + tokenIndexFrom: BigNumberish, + tokenIndexTo: BigNumberish, + minDy: BigNumberish, + deadline: BigNumberish, + kappa: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise + + pause(overrides?: Overrides & { from?: string }): Promise + + paused(overrides?: CallOverrides): Promise + + redeem( + to: string, + chainId: BigNumberish, + token: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise + + redeemAndRemove( + to: string, + chainId: BigNumberish, + token: string, + amount: BigNumberish, + swapTokenIndex: BigNumberish, + swapMinAmount: BigNumberish, + swapDeadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise + + redeemAndSwap( + to: string, + chainId: BigNumberish, + token: string, + amount: BigNumberish, + tokenIndexFrom: BigNumberish, + tokenIndexTo: BigNumberish, + minDy: BigNumberish, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise + + redeemV2( + to: BytesLike, + chainId: BigNumberish, + token: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise + + renounceRole( + role: BytesLike, + account: string, + overrides?: Overrides & { from?: string } + ): Promise + + revokeRole( + role: BytesLike, + account: string, + overrides?: Overrides & { from?: string } + ): Promise + + setChainGasAmount( + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise + + setWethAddress( + _wethAddress: string, + overrides?: Overrides & { from?: string } + ): Promise + + startBlockNumber(overrides?: CallOverrides): Promise + + unpause( + overrides?: Overrides & { from?: string } + ): Promise + + withdraw( + to: string, + token: string, + amount: BigNumberish, + fee: BigNumberish, + kappa: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise + + withdrawAndRemove( + to: string, + token: string, + amount: BigNumberish, + fee: BigNumberish, + pool: string, + swapTokenIndex: BigNumberish, + swapMinAmount: BigNumberish, + swapDeadline: BigNumberish, + kappa: BytesLike, + overrides?: Overrides & { from?: string } ): Promise - upgradeToAndCall( - newImplementation: PromiseOrValue, - data: PromiseOrValue, - overrides?: PayableOverrides & { from?: PromiseOrValue } + withdrawFees( + token: string, + to: string, + overrides?: Overrides & { from?: string } ): Promise callStatic: { - admin(overrides?: CallOverrides): Promise + DEFAULT_ADMIN_ROLE(overrides?: CallOverrides): Promise + + GOVERNANCE_ROLE(overrides?: CallOverrides): Promise + + NODEGROUP_ROLE(overrides?: CallOverrides): Promise + + WETH_ADDRESS(overrides?: CallOverrides): Promise + + addKappas(kappas: BytesLike[], overrides?: CallOverrides): Promise + + bridgeVersion(overrides?: CallOverrides): Promise + + chainGasAmount(overrides?: CallOverrides): Promise + + deposit( + to: string, + chainId: BigNumberish, + token: string, + amount: BigNumberish, + overrides?: CallOverrides + ): Promise + + depositAndSwap( + to: string, + chainId: BigNumberish, + token: string, + amount: BigNumberish, + tokenIndexFrom: BigNumberish, + tokenIndexTo: BigNumberish, + minDy: BigNumberish, + deadline: BigNumberish, + overrides?: CallOverrides + ): Promise + + getFeeBalance( + tokenAddress: string, + overrides?: CallOverrides + ): Promise + + getRoleAdmin(role: BytesLike, overrides?: CallOverrides): Promise + + getRoleMember( + role: BytesLike, + index: BigNumberish, + overrides?: CallOverrides + ): Promise + + getRoleMemberCount( + role: BytesLike, + overrides?: CallOverrides + ): Promise + + grantRole( + role: BytesLike, + account: string, + overrides?: CallOverrides + ): Promise + + hasRole( + role: BytesLike, + account: string, + overrides?: CallOverrides + ): Promise + + initialize(overrides?: CallOverrides): Promise + + kappaExists(kappa: BytesLike, overrides?: CallOverrides): Promise + + mint( + to: string, + token: string, + amount: BigNumberish, + fee: BigNumberish, + kappa: BytesLike, + overrides?: CallOverrides + ): Promise + + mintAndSwap( + to: string, + token: string, + amount: BigNumberish, + fee: BigNumberish, + pool: string, + tokenIndexFrom: BigNumberish, + tokenIndexTo: BigNumberish, + minDy: BigNumberish, + deadline: BigNumberish, + kappa: BytesLike, + overrides?: CallOverrides + ): Promise + + pause(overrides?: CallOverrides): Promise + + paused(overrides?: CallOverrides): Promise + + redeem( + to: string, + chainId: BigNumberish, + token: string, + amount: BigNumberish, + overrides?: CallOverrides + ): Promise + + redeemAndRemove( + to: string, + chainId: BigNumberish, + token: string, + amount: BigNumberish, + swapTokenIndex: BigNumberish, + swapMinAmount: BigNumberish, + swapDeadline: BigNumberish, + overrides?: CallOverrides + ): Promise + + redeemAndSwap( + to: string, + chainId: BigNumberish, + token: string, + amount: BigNumberish, + tokenIndexFrom: BigNumberish, + tokenIndexTo: BigNumberish, + minDy: BigNumberish, + deadline: BigNumberish, + overrides?: CallOverrides + ): Promise + + redeemV2( + to: BytesLike, + chainId: BigNumberish, + token: string, + amount: BigNumberish, + overrides?: CallOverrides + ): Promise + + renounceRole( + role: BytesLike, + account: string, + overrides?: CallOverrides + ): Promise + + revokeRole( + role: BytesLike, + account: string, + overrides?: CallOverrides + ): Promise + + setChainGasAmount( + amount: BigNumberish, + overrides?: CallOverrides + ): Promise - changeAdmin( - newAdmin: PromiseOrValue, + setWethAddress( + _wethAddress: string, overrides?: CallOverrides ): Promise - implementation(overrides?: CallOverrides): Promise + startBlockNumber(overrides?: CallOverrides): Promise - upgradeTo( - newImplementation: PromiseOrValue, + unpause(overrides?: CallOverrides): Promise + + withdraw( + to: string, + token: string, + amount: BigNumberish, + fee: BigNumberish, + kappa: BytesLike, overrides?: CallOverrides ): Promise - upgradeToAndCall( - newImplementation: PromiseOrValue, - data: PromiseOrValue, + withdrawAndRemove( + to: string, + token: string, + amount: BigNumberish, + fee: BigNumberish, + pool: string, + swapTokenIndex: BigNumberish, + swapMinAmount: BigNumberish, + swapDeadline: BigNumberish, + kappa: BytesLike, + overrides?: CallOverrides + ): Promise + + withdrawFees( + token: string, + to: string, overrides?: CallOverrides ): Promise } filters: { - 'AdminChanged(address,address)'( - previousAdmin?: null, - newAdmin?: null - ): AdminChangedEventFilter - AdminChanged(previousAdmin?: null, newAdmin?: null): AdminChangedEventFilter - - 'Upgraded(address)'( - implementation?: PromiseOrValue | null - ): UpgradedEventFilter - Upgraded( - implementation?: PromiseOrValue | null - ): UpgradedEventFilter + 'Paused(address)'(account?: null): PausedEventFilter + Paused(account?: null): PausedEventFilter + + 'RoleAdminChanged(bytes32,bytes32,bytes32)'( + role?: BytesLike | null, + previousAdminRole?: BytesLike | null, + newAdminRole?: BytesLike | null + ): RoleAdminChangedEventFilter + RoleAdminChanged( + role?: BytesLike | null, + previousAdminRole?: BytesLike | null, + newAdminRole?: BytesLike | null + ): RoleAdminChangedEventFilter + + 'RoleGranted(bytes32,address,address)'( + role?: BytesLike | null, + account?: string | null, + sender?: string | null + ): RoleGrantedEventFilter + RoleGranted( + role?: BytesLike | null, + account?: string | null, + sender?: string | null + ): RoleGrantedEventFilter + + 'RoleRevoked(bytes32,address,address)'( + role?: BytesLike | null, + account?: string | null, + sender?: string | null + ): RoleRevokedEventFilter + RoleRevoked( + role?: BytesLike | null, + account?: string | null, + sender?: string | null + ): RoleRevokedEventFilter + + 'TokenDeposit(address,uint256,address,uint256)'( + to?: string | null, + chainId?: null, + token?: null, + amount?: null + ): TokenDepositEventFilter + TokenDeposit( + to?: string | null, + chainId?: null, + token?: null, + amount?: null + ): TokenDepositEventFilter + + 'TokenDepositAndSwap(address,uint256,address,uint256,uint8,uint8,uint256,uint256)'( + to?: string | null, + chainId?: null, + token?: null, + amount?: null, + tokenIndexFrom?: null, + tokenIndexTo?: null, + minDy?: null, + deadline?: null + ): TokenDepositAndSwapEventFilter + TokenDepositAndSwap( + to?: string | null, + chainId?: null, + token?: null, + amount?: null, + tokenIndexFrom?: null, + tokenIndexTo?: null, + minDy?: null, + deadline?: null + ): TokenDepositAndSwapEventFilter + + 'TokenMint(address,address,uint256,uint256,bytes32)'( + to?: string | null, + token?: null, + amount?: null, + fee?: null, + kappa?: BytesLike | null + ): TokenMintEventFilter + TokenMint( + to?: string | null, + token?: null, + amount?: null, + fee?: null, + kappa?: BytesLike | null + ): TokenMintEventFilter + + 'TokenMintAndSwap(address,address,uint256,uint256,uint8,uint8,uint256,uint256,bool,bytes32)'( + to?: string | null, + token?: null, + amount?: null, + fee?: null, + tokenIndexFrom?: null, + tokenIndexTo?: null, + minDy?: null, + deadline?: null, + swapSuccess?: null, + kappa?: BytesLike | null + ): TokenMintAndSwapEventFilter + TokenMintAndSwap( + to?: string | null, + token?: null, + amount?: null, + fee?: null, + tokenIndexFrom?: null, + tokenIndexTo?: null, + minDy?: null, + deadline?: null, + swapSuccess?: null, + kappa?: BytesLike | null + ): TokenMintAndSwapEventFilter + + 'TokenRedeem(address,uint256,address,uint256)'( + to?: string | null, + chainId?: null, + token?: null, + amount?: null + ): TokenRedeemEventFilter + TokenRedeem( + to?: string | null, + chainId?: null, + token?: null, + amount?: null + ): TokenRedeemEventFilter + + 'TokenRedeemAndRemove(address,uint256,address,uint256,uint8,uint256,uint256)'( + to?: string | null, + chainId?: null, + token?: null, + amount?: null, + swapTokenIndex?: null, + swapMinAmount?: null, + swapDeadline?: null + ): TokenRedeemAndRemoveEventFilter + TokenRedeemAndRemove( + to?: string | null, + chainId?: null, + token?: null, + amount?: null, + swapTokenIndex?: null, + swapMinAmount?: null, + swapDeadline?: null + ): TokenRedeemAndRemoveEventFilter + + 'TokenRedeemAndSwap(address,uint256,address,uint256,uint8,uint8,uint256,uint256)'( + to?: string | null, + chainId?: null, + token?: null, + amount?: null, + tokenIndexFrom?: null, + tokenIndexTo?: null, + minDy?: null, + deadline?: null + ): TokenRedeemAndSwapEventFilter + TokenRedeemAndSwap( + to?: string | null, + chainId?: null, + token?: null, + amount?: null, + tokenIndexFrom?: null, + tokenIndexTo?: null, + minDy?: null, + deadline?: null + ): TokenRedeemAndSwapEventFilter + + 'TokenRedeemV2(bytes32,uint256,address,uint256)'( + to?: BytesLike | null, + chainId?: null, + token?: null, + amount?: null + ): TokenRedeemV2EventFilter + TokenRedeemV2( + to?: BytesLike | null, + chainId?: null, + token?: null, + amount?: null + ): TokenRedeemV2EventFilter + + 'TokenWithdraw(address,address,uint256,uint256,bytes32)'( + to?: string | null, + token?: null, + amount?: null, + fee?: null, + kappa?: BytesLike | null + ): TokenWithdrawEventFilter + TokenWithdraw( + to?: string | null, + token?: null, + amount?: null, + fee?: null, + kappa?: BytesLike | null + ): TokenWithdrawEventFilter + + 'TokenWithdrawAndRemove(address,address,uint256,uint256,uint8,uint256,uint256,bool,bytes32)'( + to?: string | null, + token?: null, + amount?: null, + fee?: null, + swapTokenIndex?: null, + swapMinAmount?: null, + swapDeadline?: null, + swapSuccess?: null, + kappa?: BytesLike | null + ): TokenWithdrawAndRemoveEventFilter + TokenWithdrawAndRemove( + to?: string | null, + token?: null, + amount?: null, + fee?: null, + swapTokenIndex?: null, + swapMinAmount?: null, + swapDeadline?: null, + swapSuccess?: null, + kappa?: BytesLike | null + ): TokenWithdrawAndRemoveEventFilter + + 'Unpaused(address)'(account?: null): UnpausedEventFilter + Unpaused(account?: null): UnpausedEventFilter } estimateGas: { - admin( - overrides?: Overrides & { from?: PromiseOrValue } + DEFAULT_ADMIN_ROLE(overrides?: CallOverrides): Promise + + GOVERNANCE_ROLE(overrides?: CallOverrides): Promise + + NODEGROUP_ROLE(overrides?: CallOverrides): Promise + + WETH_ADDRESS(overrides?: CallOverrides): Promise + + addKappas( + kappas: BytesLike[], + overrides?: Overrides & { from?: string } + ): Promise + + bridgeVersion(overrides?: CallOverrides): Promise + + chainGasAmount(overrides?: CallOverrides): Promise + + deposit( + to: string, + chainId: BigNumberish, + token: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise + + depositAndSwap( + to: string, + chainId: BigNumberish, + token: string, + amount: BigNumberish, + tokenIndexFrom: BigNumberish, + tokenIndexTo: BigNumberish, + minDy: BigNumberish, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise + + getFeeBalance( + tokenAddress: string, + overrides?: CallOverrides + ): Promise + + getRoleAdmin(role: BytesLike, overrides?: CallOverrides): Promise + + getRoleMember( + role: BytesLike, + index: BigNumberish, + overrides?: CallOverrides + ): Promise + + getRoleMemberCount( + role: BytesLike, + overrides?: CallOverrides + ): Promise + + grantRole( + role: BytesLike, + account: string, + overrides?: Overrides & { from?: string } + ): Promise + + hasRole( + role: BytesLike, + account: string, + overrides?: CallOverrides ): Promise - changeAdmin( - newAdmin: PromiseOrValue, - overrides?: Overrides & { from?: PromiseOrValue } + initialize(overrides?: Overrides & { from?: string }): Promise + + kappaExists(kappa: BytesLike, overrides?: CallOverrides): Promise + + mint( + to: string, + token: string, + amount: BigNumberish, + fee: BigNumberish, + kappa: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise + + mintAndSwap( + to: string, + token: string, + amount: BigNumberish, + fee: BigNumberish, + pool: string, + tokenIndexFrom: BigNumberish, + tokenIndexTo: BigNumberish, + minDy: BigNumberish, + deadline: BigNumberish, + kappa: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise + + pause(overrides?: Overrides & { from?: string }): Promise + + paused(overrides?: CallOverrides): Promise + + redeem( + to: string, + chainId: BigNumberish, + token: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise + + redeemAndRemove( + to: string, + chainId: BigNumberish, + token: string, + amount: BigNumberish, + swapTokenIndex: BigNumberish, + swapMinAmount: BigNumberish, + swapDeadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise + + redeemAndSwap( + to: string, + chainId: BigNumberish, + token: string, + amount: BigNumberish, + tokenIndexFrom: BigNumberish, + tokenIndexTo: BigNumberish, + minDy: BigNumberish, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise + + redeemV2( + to: BytesLike, + chainId: BigNumberish, + token: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } ): Promise - implementation( - overrides?: Overrides & { from?: PromiseOrValue } + renounceRole( + role: BytesLike, + account: string, + overrides?: Overrides & { from?: string } ): Promise - upgradeTo( - newImplementation: PromiseOrValue, - overrides?: Overrides & { from?: PromiseOrValue } + revokeRole( + role: BytesLike, + account: string, + overrides?: Overrides & { from?: string } ): Promise - upgradeToAndCall( - newImplementation: PromiseOrValue, - data: PromiseOrValue, - overrides?: PayableOverrides & { from?: PromiseOrValue } + setChainGasAmount( + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise + + setWethAddress( + _wethAddress: string, + overrides?: Overrides & { from?: string } + ): Promise + + startBlockNumber(overrides?: CallOverrides): Promise + + unpause(overrides?: Overrides & { from?: string }): Promise + + withdraw( + to: string, + token: string, + amount: BigNumberish, + fee: BigNumberish, + kappa: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise + + withdrawAndRemove( + to: string, + token: string, + amount: BigNumberish, + fee: BigNumberish, + pool: string, + swapTokenIndex: BigNumberish, + swapMinAmount: BigNumberish, + swapDeadline: BigNumberish, + kappa: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise + + withdrawFees( + token: string, + to: string, + overrides?: Overrides & { from?: string } ): Promise } populateTransaction: { - admin( - overrides?: Overrides & { from?: PromiseOrValue } + DEFAULT_ADMIN_ROLE(overrides?: CallOverrides): Promise + + GOVERNANCE_ROLE(overrides?: CallOverrides): Promise + + NODEGROUP_ROLE(overrides?: CallOverrides): Promise + + WETH_ADDRESS(overrides?: CallOverrides): Promise + + addKappas( + kappas: BytesLike[], + overrides?: Overrides & { from?: string } + ): Promise + + bridgeVersion(overrides?: CallOverrides): Promise + + chainGasAmount(overrides?: CallOverrides): Promise + + deposit( + to: string, + chainId: BigNumberish, + token: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise + + depositAndSwap( + to: string, + chainId: BigNumberish, + token: string, + amount: BigNumberish, + tokenIndexFrom: BigNumberish, + tokenIndexTo: BigNumberish, + minDy: BigNumberish, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } ): Promise - changeAdmin( - newAdmin: PromiseOrValue, - overrides?: Overrides & { from?: PromiseOrValue } + getFeeBalance( + tokenAddress: string, + overrides?: CallOverrides + ): Promise + + getRoleAdmin( + role: BytesLike, + overrides?: CallOverrides + ): Promise + + getRoleMember( + role: BytesLike, + index: BigNumberish, + overrides?: CallOverrides + ): Promise + + getRoleMemberCount( + role: BytesLike, + overrides?: CallOverrides + ): Promise + + grantRole( + role: BytesLike, + account: string, + overrides?: Overrides & { from?: string } + ): Promise + + hasRole( + role: BytesLike, + account: string, + overrides?: CallOverrides + ): Promise + + initialize( + overrides?: Overrides & { from?: string } + ): Promise + + kappaExists( + kappa: BytesLike, + overrides?: CallOverrides + ): Promise + + mint( + to: string, + token: string, + amount: BigNumberish, + fee: BigNumberish, + kappa: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise + + mintAndSwap( + to: string, + token: string, + amount: BigNumberish, + fee: BigNumberish, + pool: string, + tokenIndexFrom: BigNumberish, + tokenIndexTo: BigNumberish, + minDy: BigNumberish, + deadline: BigNumberish, + kappa: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise + + pause( + overrides?: Overrides & { from?: string } + ): Promise + + paused(overrides?: CallOverrides): Promise + + redeem( + to: string, + chainId: BigNumberish, + token: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise + + redeemAndRemove( + to: string, + chainId: BigNumberish, + token: string, + amount: BigNumberish, + swapTokenIndex: BigNumberish, + swapMinAmount: BigNumberish, + swapDeadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise + + redeemAndSwap( + to: string, + chainId: BigNumberish, + token: string, + amount: BigNumberish, + tokenIndexFrom: BigNumberish, + tokenIndexTo: BigNumberish, + minDy: BigNumberish, + deadline: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise + + redeemV2( + to: BytesLike, + chainId: BigNumberish, + token: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise + + renounceRole( + role: BytesLike, + account: string, + overrides?: Overrides & { from?: string } + ): Promise + + revokeRole( + role: BytesLike, + account: string, + overrides?: Overrides & { from?: string } + ): Promise + + setChainGasAmount( + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise + + setWethAddress( + _wethAddress: string, + overrides?: Overrides & { from?: string } + ): Promise + + startBlockNumber(overrides?: CallOverrides): Promise + + unpause( + overrides?: Overrides & { from?: string } ): Promise - implementation( - overrides?: Overrides & { from?: PromiseOrValue } + withdraw( + to: string, + token: string, + amount: BigNumberish, + fee: BigNumberish, + kappa: BytesLike, + overrides?: Overrides & { from?: string } ): Promise - upgradeTo( - newImplementation: PromiseOrValue, - overrides?: Overrides & { from?: PromiseOrValue } + withdrawAndRemove( + to: string, + token: string, + amount: BigNumberish, + fee: BigNumberish, + pool: string, + swapTokenIndex: BigNumberish, + swapMinAmount: BigNumberish, + swapDeadline: BigNumberish, + kappa: BytesLike, + overrides?: Overrides & { from?: string } ): Promise - upgradeToAndCall( - newImplementation: PromiseOrValue, - data: PromiseOrValue, - overrides?: PayableOverrides & { from?: PromiseOrValue } + withdrawFees( + token: string, + to: string, + overrides?: Overrides & { from?: string } ): Promise } } diff --git a/packages/sdk-router/src/typechain/SynapseCCTPRouter.ts b/packages/sdk-router/src/typechain/SynapseCCTPRouter.ts index ce99912041..07bc5cb485 100644 --- a/packages/sdk-router/src/typechain/SynapseCCTPRouter.ts +++ b/packages/sdk-router/src/typechain/SynapseCCTPRouter.ts @@ -1,344 +1,233 @@ /* Autogenerated file. Do not edit manually. */ /* tslint:disable */ /* eslint-disable */ - -import { - ethers, - EventFilter, - Signer, - BigNumber, - BigNumberish, - PopulatedTransaction, - BaseContract, - ContractTransaction, - PayableOverrides, - CallOverrides, - } from "ethers"; - import { BytesLike } from "@ethersproject/bytes"; - import { Listener, Provider } from "@ethersproject/providers"; - import { FunctionFragment, EventFragment, Result } from "@ethersproject/abi"; - import type { TypedEventFilter, TypedEvent, TypedListener } from "./common"; - - interface SynapseCCTPRouterInterface extends ethers.utils.Interface { - functions: { - "adapterSwap(address,address,uint256,address,bytes)": FunctionFragment; - "bridge(address,uint256,address,uint256,(address,address,uint256,uint256,bytes),(address,address,uint256,uint256,bytes))": FunctionFragment; - "calculateFeeAmount(address,uint256,bool)": FunctionFragment; - "feeStructures(address)": FunctionFragment; - "getConnectedBridgeTokens(address)": FunctionFragment; - "getDestinationAmountOut(tuple[],address)": FunctionFragment; - "getOriginAmountOut(address,string[],uint256)": FunctionFragment; - "synapseCCTP()": FunctionFragment; - }; - - encodeFunctionData( - functionFragment: "adapterSwap", - values: [string, string, BigNumberish, string, BytesLike] - ): string; - encodeFunctionData( - functionFragment: "bridge", - values: [ - string, - BigNumberish, - string, - BigNumberish, - { - routerAdapter: string; - tokenOut: string; - minAmountOut: BigNumberish; - deadline: BigNumberish; - rawParams: BytesLike; - }, - { - routerAdapter: string; - tokenOut: string; - minAmountOut: BigNumberish; - deadline: BigNumberish; - rawParams: BytesLike; - } - ] - ): string; - encodeFunctionData( - functionFragment: "calculateFeeAmount", - values: [string, BigNumberish, boolean] - ): string; - encodeFunctionData( - functionFragment: "feeStructures", - values: [string] - ): string; - encodeFunctionData( - functionFragment: "getConnectedBridgeTokens", - values: [string] - ): string; - encodeFunctionData( - functionFragment: "getDestinationAmountOut", - values: [{ symbol: string; amountIn: BigNumberish }[], string] - ): string; - encodeFunctionData( - functionFragment: "getOriginAmountOut", - values: [string, string[], BigNumberish] - ): string; - encodeFunctionData( - functionFragment: "synapseCCTP", - values?: undefined - ): string; - - decodeFunctionResult( - functionFragment: "adapterSwap", - data: BytesLike - ): Result; - decodeFunctionResult(functionFragment: "bridge", data: BytesLike): Result; - decodeFunctionResult( - functionFragment: "calculateFeeAmount", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "feeStructures", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "getConnectedBridgeTokens", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "getDestinationAmountOut", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "getOriginAmountOut", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "synapseCCTP", - data: BytesLike - ): Result; - - events: {}; +import type { + BaseContract, + BigNumber, + BigNumberish, + BytesLike, + CallOverrides, + ContractTransaction, + PayableOverrides, + PopulatedTransaction, + Signer, + utils, +} from 'ethers' +import type { FunctionFragment, Result } from '@ethersproject/abi' +import type { Listener, Provider } from '@ethersproject/providers' +import type { + TypedEventFilter, + TypedEvent, + TypedListener, + OnEvent, +} from './common' + +export type SwapQueryStruct = { + routerAdapter: string + tokenOut: string + minAmountOut: BigNumberish + deadline: BigNumberish + rawParams: BytesLike +} + +export type SwapQueryStructOutput = [ + string, + string, + BigNumber, + BigNumber, + string +] & { + routerAdapter: string + tokenOut: string + minAmountOut: BigNumber + deadline: BigNumber + rawParams: string +} + +export type BridgeTokenStruct = { symbol: string; token: string } + +export type BridgeTokenStructOutput = [string, string] & { + symbol: string + token: string +} + +export type DestRequestStruct = { symbol: string; amountIn: BigNumberish } + +export type DestRequestStructOutput = [string, BigNumber] & { + symbol: string + amountIn: BigNumber +} + +export interface SynapseCCTPRouterInterface extends utils.Interface { + functions: { + 'adapterSwap(address,address,uint256,address,bytes)': FunctionFragment + 'bridge(address,uint256,address,uint256,(address,address,uint256,uint256,bytes),(address,address,uint256,uint256,bytes))': FunctionFragment + 'calculateFeeAmount(address,uint256,bool)': FunctionFragment + 'feeStructures(address)': FunctionFragment + 'getConnectedBridgeTokens(address)': FunctionFragment + 'getDestinationAmountOut((string,uint256)[],address)': FunctionFragment + 'getOriginAmountOut(address,string[],uint256)': FunctionFragment + 'synapseCCTP()': FunctionFragment } - export class SynapseCCTPRouter extends BaseContract { - connect(signerOrProvider: Signer | Provider | string): this; - attach(addressOrName: string): this; - deployed(): Promise; - - listeners, EventArgsObject>( - eventFilter?: TypedEventFilter - ): Array>; - off, EventArgsObject>( - eventFilter: TypedEventFilter, - listener: TypedListener - ): this; - on, EventArgsObject>( - eventFilter: TypedEventFilter, - listener: TypedListener - ): this; - once, EventArgsObject>( - eventFilter: TypedEventFilter, - listener: TypedListener - ): this; - removeListener, EventArgsObject>( - eventFilter: TypedEventFilter, - listener: TypedListener - ): this; - removeAllListeners, EventArgsObject>( - eventFilter: TypedEventFilter - ): this; - - listeners(eventName?: string): Array; - off(eventName: string, listener: Listener): this; - on(eventName: string, listener: Listener): this; - once(eventName: string, listener: Listener): this; - removeListener(eventName: string, listener: Listener): this; - removeAllListeners(eventName?: string): this; - - queryFilter, EventArgsObject>( - event: TypedEventFilter, - fromBlockOrBlockhash?: string | number | undefined, - toBlock?: string | number | undefined - ): Promise>>; - - interface: SynapseCCTPRouterInterface; - - functions: { - adapterSwap( - recipient: string, - tokenIn: string, - amountIn: BigNumberish, - tokenOut: string, - rawParams: BytesLike, - overrides?: PayableOverrides & { from?: string | Promise } - ): Promise; - - bridge( - recipient: string, - chainId: BigNumberish, - token: string, - amount: BigNumberish, - originQuery: { - routerAdapter: string; - tokenOut: string; - minAmountOut: BigNumberish; - deadline: BigNumberish; - rawParams: BytesLike; - }, - destQuery: { - routerAdapter: string; - tokenOut: string; - minAmountOut: BigNumberish; - deadline: BigNumberish; - rawParams: BytesLike; - }, - overrides?: PayableOverrides & { from?: string | Promise } - ): Promise; - - calculateFeeAmount( - token: string, - amount: BigNumberish, - isSwap: boolean, - overrides?: CallOverrides - ): Promise<[BigNumber] & { fee: BigNumber }>; - - feeStructures( - token: string, - overrides?: CallOverrides - ): Promise< - [number, BigNumber, BigNumber, BigNumber] & { - relayerFee: number; - minBaseFee: BigNumber; - minSwapFee: BigNumber; - maxFee: BigNumber; - } - >; - - getConnectedBridgeTokens( - tokenOut: string, - overrides?: CallOverrides - ): Promise< - [([string, string] & { symbol: string; token: string })[]] & { - tokens: ([string, string] & { symbol: string; token: string })[]; - } - >; - - getDestinationAmountOut( - requests: { symbol: string; amountIn: BigNumberish }[], - tokenOut: string, - overrides?: CallOverrides - ): Promise< - [ - ([string, string, BigNumber, BigNumber, string] & { - routerAdapter: string; - tokenOut: string; - minAmountOut: BigNumber; - deadline: BigNumber; - rawParams: string; - })[] - ] & { - destQueries: ([string, string, BigNumber, BigNumber, string] & { - routerAdapter: string; - tokenOut: string; - minAmountOut: BigNumber; - deadline: BigNumber; - rawParams: string; - })[]; - } - >; - - getOriginAmountOut( - tokenIn: string, - tokenSymbols: string[], - amountIn: BigNumberish, - overrides?: CallOverrides - ): Promise< - [ - ([string, string, BigNumber, BigNumber, string] & { - routerAdapter: string; - tokenOut: string; - minAmountOut: BigNumber; - deadline: BigNumber; - rawParams: string; - })[] - ] & { - originQueries: ([string, string, BigNumber, BigNumber, string] & { - routerAdapter: string; - tokenOut: string; - minAmountOut: BigNumber; - deadline: BigNumber; - rawParams: string; - })[]; - } - >; - - synapseCCTP(overrides?: CallOverrides): Promise<[string]>; - }; - + getFunction( + nameOrSignatureOrTopic: + | 'adapterSwap' + | 'bridge' + | 'calculateFeeAmount' + | 'feeStructures' + | 'getConnectedBridgeTokens' + | 'getDestinationAmountOut' + | 'getOriginAmountOut' + | 'synapseCCTP' + ): FunctionFragment + + encodeFunctionData( + functionFragment: 'adapterSwap', + values: [string, string, BigNumberish, string, BytesLike] + ): string + encodeFunctionData( + functionFragment: 'bridge', + values: [ + string, + BigNumberish, + string, + BigNumberish, + SwapQueryStruct, + SwapQueryStruct + ] + ): string + encodeFunctionData( + functionFragment: 'calculateFeeAmount', + values: [string, BigNumberish, boolean] + ): string + encodeFunctionData( + functionFragment: 'feeStructures', + values: [string] + ): string + encodeFunctionData( + functionFragment: 'getConnectedBridgeTokens', + values: [string] + ): string + encodeFunctionData( + functionFragment: 'getDestinationAmountOut', + values: [DestRequestStruct[], string] + ): string + encodeFunctionData( + functionFragment: 'getOriginAmountOut', + values: [string, string[], BigNumberish] + ): string + encodeFunctionData( + functionFragment: 'synapseCCTP', + values?: undefined + ): string + + decodeFunctionResult(functionFragment: 'adapterSwap', data: BytesLike): Result + decodeFunctionResult(functionFragment: 'bridge', data: BytesLike): Result + decodeFunctionResult( + functionFragment: 'calculateFeeAmount', + data: BytesLike + ): Result + decodeFunctionResult( + functionFragment: 'feeStructures', + data: BytesLike + ): Result + decodeFunctionResult( + functionFragment: 'getConnectedBridgeTokens', + data: BytesLike + ): Result + decodeFunctionResult( + functionFragment: 'getDestinationAmountOut', + data: BytesLike + ): Result + decodeFunctionResult( + functionFragment: 'getOriginAmountOut', + data: BytesLike + ): Result + decodeFunctionResult(functionFragment: 'synapseCCTP', data: BytesLike): Result + + events: {} +} + +export interface SynapseCCTPRouter extends BaseContract { + connect(signerOrProvider: Signer | Provider | string): this + attach(addressOrName: string): this + deployed(): Promise + + interface: SynapseCCTPRouterInterface + + queryFilter( + event: TypedEventFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise> + + listeners( + eventFilter?: TypedEventFilter + ): Array> + listeners(eventName?: string): Array + removeAllListeners( + eventFilter: TypedEventFilter + ): this + removeAllListeners(eventName?: string): this + off: OnEvent + on: OnEvent + once: OnEvent + removeListener: OnEvent + + functions: { adapterSwap( recipient: string, tokenIn: string, amountIn: BigNumberish, tokenOut: string, rawParams: BytesLike, - overrides?: PayableOverrides & { from?: string | Promise } - ): Promise; + overrides?: PayableOverrides & { from?: string } + ): Promise bridge( recipient: string, chainId: BigNumberish, token: string, amount: BigNumberish, - originQuery: { - routerAdapter: string; - tokenOut: string; - minAmountOut: BigNumberish; - deadline: BigNumberish; - rawParams: BytesLike; - }, - destQuery: { - routerAdapter: string; - tokenOut: string; - minAmountOut: BigNumberish; - deadline: BigNumberish; - rawParams: BytesLike; - }, - overrides?: PayableOverrides & { from?: string | Promise } - ): Promise; + originQuery: SwapQueryStruct, + destQuery: SwapQueryStruct, + overrides?: PayableOverrides & { from?: string } + ): Promise calculateFeeAmount( token: string, amount: BigNumberish, isSwap: boolean, overrides?: CallOverrides - ): Promise; + ): Promise<[BigNumber] & { fee: BigNumber }> feeStructures( token: string, overrides?: CallOverrides ): Promise< [number, BigNumber, BigNumber, BigNumber] & { - relayerFee: number; - minBaseFee: BigNumber; - minSwapFee: BigNumber; - maxFee: BigNumber; + relayerFee: number + minBaseFee: BigNumber + minSwapFee: BigNumber + maxFee: BigNumber } - >; + > getConnectedBridgeTokens( tokenOut: string, overrides?: CallOverrides - ): Promise<([string, string] & { symbol: string; token: string })[]>; + ): Promise< + [BridgeTokenStructOutput[]] & { tokens: BridgeTokenStructOutput[] } + > getDestinationAmountOut( - requests: { symbol: string; amountIn: BigNumberish }[], + requests: DestRequestStruct[], tokenOut: string, overrides?: CallOverrides ): Promise< - ([string, string, BigNumber, BigNumber, string] & { - routerAdapter: string; - tokenOut: string; - minAmountOut: BigNumber; - deadline: BigNumber; - rawParams: string; - })[] - >; + [SwapQueryStructOutput[]] & { destQueries: SwapQueryStructOutput[] } + > getOriginAmountOut( tokenIn: string, @@ -346,231 +235,232 @@ import { amountIn: BigNumberish, overrides?: CallOverrides ): Promise< - ([string, string, BigNumber, BigNumber, string] & { - routerAdapter: string; - tokenOut: string; - minAmountOut: BigNumber; - deadline: BigNumber; - rawParams: string; - })[] - >; - - synapseCCTP(overrides?: CallOverrides): Promise; - - callStatic: { - adapterSwap( - recipient: string, - tokenIn: string, - amountIn: BigNumberish, - tokenOut: string, - rawParams: BytesLike, - overrides?: CallOverrides - ): Promise; - - bridge( - recipient: string, - chainId: BigNumberish, - token: string, - amount: BigNumberish, - originQuery: { - routerAdapter: string; - tokenOut: string; - minAmountOut: BigNumberish; - deadline: BigNumberish; - rawParams: BytesLike; - }, - destQuery: { - routerAdapter: string; - tokenOut: string; - minAmountOut: BigNumberish; - deadline: BigNumberish; - rawParams: BytesLike; - }, - overrides?: CallOverrides - ): Promise; - - calculateFeeAmount( - token: string, - amount: BigNumberish, - isSwap: boolean, - overrides?: CallOverrides - ): Promise; - - feeStructures( - token: string, - overrides?: CallOverrides - ): Promise< - [number, BigNumber, BigNumber, BigNumber] & { - relayerFee: number; - minBaseFee: BigNumber; - minSwapFee: BigNumber; - maxFee: BigNumber; - } - >; - - getConnectedBridgeTokens( - tokenOut: string, - overrides?: CallOverrides - ): Promise<([string, string] & { symbol: string; token: string })[]>; - - getDestinationAmountOut( - requests: { symbol: string; amountIn: BigNumberish }[], - tokenOut: string, - overrides?: CallOverrides - ): Promise< - ([string, string, BigNumber, BigNumber, string] & { - routerAdapter: string; - tokenOut: string; - minAmountOut: BigNumber; - deadline: BigNumber; - rawParams: string; - })[] - >; - - getOriginAmountOut( - tokenIn: string, - tokenSymbols: string[], - amountIn: BigNumberish, - overrides?: CallOverrides - ): Promise< - ([string, string, BigNumber, BigNumber, string] & { - routerAdapter: string; - tokenOut: string; - minAmountOut: BigNumber; - deadline: BigNumber; - rawParams: string; - })[] - >; - - synapseCCTP(overrides?: CallOverrides): Promise; - }; - - filters: {}; - - estimateGas: { - adapterSwap( - recipient: string, - tokenIn: string, - amountIn: BigNumberish, - tokenOut: string, - rawParams: BytesLike, - overrides?: PayableOverrides & { from?: string | Promise } - ): Promise; - - bridge( - recipient: string, - chainId: BigNumberish, - token: string, - amount: BigNumberish, - originQuery: { - routerAdapter: string; - tokenOut: string; - minAmountOut: BigNumberish; - deadline: BigNumberish; - rawParams: BytesLike; - }, - destQuery: { - routerAdapter: string; - tokenOut: string; - minAmountOut: BigNumberish; - deadline: BigNumberish; - rawParams: BytesLike; - }, - overrides?: PayableOverrides & { from?: string | Promise } - ): Promise; - - calculateFeeAmount( - token: string, - amount: BigNumberish, - isSwap: boolean, - overrides?: CallOverrides - ): Promise; - - feeStructures(token: string, overrides?: CallOverrides): Promise; - - getConnectedBridgeTokens( - tokenOut: string, - overrides?: CallOverrides - ): Promise; - - getDestinationAmountOut( - requests: { symbol: string; amountIn: BigNumberish }[], - tokenOut: string, - overrides?: CallOverrides - ): Promise; - - getOriginAmountOut( - tokenIn: string, - tokenSymbols: string[], - amountIn: BigNumberish, - overrides?: CallOverrides - ): Promise; - - synapseCCTP(overrides?: CallOverrides): Promise; - }; - - populateTransaction: { - adapterSwap( - recipient: string, - tokenIn: string, - amountIn: BigNumberish, - tokenOut: string, - rawParams: BytesLike, - overrides?: PayableOverrides & { from?: string | Promise } - ): Promise; - - bridge( - recipient: string, - chainId: BigNumberish, - token: string, - amount: BigNumberish, - originQuery: { - routerAdapter: string; - tokenOut: string; - minAmountOut: BigNumberish; - deadline: BigNumberish; - rawParams: BytesLike; - }, - destQuery: { - routerAdapter: string; - tokenOut: string; - minAmountOut: BigNumberish; - deadline: BigNumberish; - rawParams: BytesLike; - }, - overrides?: PayableOverrides & { from?: string | Promise } - ): Promise; - - calculateFeeAmount( - token: string, - amount: BigNumberish, - isSwap: boolean, - overrides?: CallOverrides - ): Promise; - - feeStructures( - token: string, - overrides?: CallOverrides - ): Promise; - - getConnectedBridgeTokens( - tokenOut: string, - overrides?: CallOverrides - ): Promise; - - getDestinationAmountOut( - requests: { symbol: string; amountIn: BigNumberish }[], - tokenOut: string, - overrides?: CallOverrides - ): Promise; - - getOriginAmountOut( - tokenIn: string, - tokenSymbols: string[], - amountIn: BigNumberish, - overrides?: CallOverrides - ): Promise; - - synapseCCTP(overrides?: CallOverrides): Promise; - }; - } \ No newline at end of file + [SwapQueryStructOutput[]] & { originQueries: SwapQueryStructOutput[] } + > + + synapseCCTP(overrides?: CallOverrides): Promise<[string]> + } + + adapterSwap( + recipient: string, + tokenIn: string, + amountIn: BigNumberish, + tokenOut: string, + rawParams: BytesLike, + overrides?: PayableOverrides & { from?: string } + ): Promise + + bridge( + recipient: string, + chainId: BigNumberish, + token: string, + amount: BigNumberish, + originQuery: SwapQueryStruct, + destQuery: SwapQueryStruct, + overrides?: PayableOverrides & { from?: string } + ): Promise + + calculateFeeAmount( + token: string, + amount: BigNumberish, + isSwap: boolean, + overrides?: CallOverrides + ): Promise + + feeStructures( + token: string, + overrides?: CallOverrides + ): Promise< + [number, BigNumber, BigNumber, BigNumber] & { + relayerFee: number + minBaseFee: BigNumber + minSwapFee: BigNumber + maxFee: BigNumber + } + > + + getConnectedBridgeTokens( + tokenOut: string, + overrides?: CallOverrides + ): Promise + + getDestinationAmountOut( + requests: DestRequestStruct[], + tokenOut: string, + overrides?: CallOverrides + ): Promise + + getOriginAmountOut( + tokenIn: string, + tokenSymbols: string[], + amountIn: BigNumberish, + overrides?: CallOverrides + ): Promise + + synapseCCTP(overrides?: CallOverrides): Promise + + callStatic: { + adapterSwap( + recipient: string, + tokenIn: string, + amountIn: BigNumberish, + tokenOut: string, + rawParams: BytesLike, + overrides?: CallOverrides + ): Promise + + bridge( + recipient: string, + chainId: BigNumberish, + token: string, + amount: BigNumberish, + originQuery: SwapQueryStruct, + destQuery: SwapQueryStruct, + overrides?: CallOverrides + ): Promise + + calculateFeeAmount( + token: string, + amount: BigNumberish, + isSwap: boolean, + overrides?: CallOverrides + ): Promise + + feeStructures( + token: string, + overrides?: CallOverrides + ): Promise< + [number, BigNumber, BigNumber, BigNumber] & { + relayerFee: number + minBaseFee: BigNumber + minSwapFee: BigNumber + maxFee: BigNumber + } + > + + getConnectedBridgeTokens( + tokenOut: string, + overrides?: CallOverrides + ): Promise + + getDestinationAmountOut( + requests: DestRequestStruct[], + tokenOut: string, + overrides?: CallOverrides + ): Promise + + getOriginAmountOut( + tokenIn: string, + tokenSymbols: string[], + amountIn: BigNumberish, + overrides?: CallOverrides + ): Promise + + synapseCCTP(overrides?: CallOverrides): Promise + } + + filters: {} + + estimateGas: { + adapterSwap( + recipient: string, + tokenIn: string, + amountIn: BigNumberish, + tokenOut: string, + rawParams: BytesLike, + overrides?: PayableOverrides & { from?: string } + ): Promise + + bridge( + recipient: string, + chainId: BigNumberish, + token: string, + amount: BigNumberish, + originQuery: SwapQueryStruct, + destQuery: SwapQueryStruct, + overrides?: PayableOverrides & { from?: string } + ): Promise + + calculateFeeAmount( + token: string, + amount: BigNumberish, + isSwap: boolean, + overrides?: CallOverrides + ): Promise + + feeStructures(token: string, overrides?: CallOverrides): Promise + + getConnectedBridgeTokens( + tokenOut: string, + overrides?: CallOverrides + ): Promise + + getDestinationAmountOut( + requests: DestRequestStruct[], + tokenOut: string, + overrides?: CallOverrides + ): Promise + + getOriginAmountOut( + tokenIn: string, + tokenSymbols: string[], + amountIn: BigNumberish, + overrides?: CallOverrides + ): Promise + + synapseCCTP(overrides?: CallOverrides): Promise + } + + populateTransaction: { + adapterSwap( + recipient: string, + tokenIn: string, + amountIn: BigNumberish, + tokenOut: string, + rawParams: BytesLike, + overrides?: PayableOverrides & { from?: string } + ): Promise + + bridge( + recipient: string, + chainId: BigNumberish, + token: string, + amount: BigNumberish, + originQuery: SwapQueryStruct, + destQuery: SwapQueryStruct, + overrides?: PayableOverrides & { from?: string } + ): Promise + + calculateFeeAmount( + token: string, + amount: BigNumberish, + isSwap: boolean, + overrides?: CallOverrides + ): Promise + + feeStructures( + token: string, + overrides?: CallOverrides + ): Promise + + getConnectedBridgeTokens( + tokenOut: string, + overrides?: CallOverrides + ): Promise + + getDestinationAmountOut( + requests: DestRequestStruct[], + tokenOut: string, + overrides?: CallOverrides + ): Promise + + getOriginAmountOut( + tokenIn: string, + tokenSymbols: string[], + amountIn: BigNumberish, + overrides?: CallOverrides + ): Promise + + synapseCCTP(overrides?: CallOverrides): Promise + } +} diff --git a/packages/sdk-router/src/typechain/SynapseRouter.ts b/packages/sdk-router/src/typechain/SynapseRouter.ts index fef9e60b4e..ef1ee58fc1 100644 --- a/packages/sdk-router/src/typechain/SynapseRouter.ts +++ b/packages/sdk-router/src/typechain/SynapseRouter.ts @@ -25,13 +25,9 @@ import type { TypedEvent, TypedListener, OnEvent, - PromiseOrValue, } from './common' -export type PoolTokenStruct = { - isWeth: PromiseOrValue - token: PromiseOrValue -} +export type PoolTokenStruct = { isWeth: boolean; token: string } export type PoolTokenStructOutput = [boolean, string] & { isWeth: boolean @@ -39,8 +35,8 @@ export type PoolTokenStructOutput = [boolean, string] & { } export type PoolStruct = { - pool: PromiseOrValue - lpToken: PromiseOrValue + pool: string + lpToken: string tokens: PoolTokenStruct[] } @@ -51,11 +47,11 @@ export type PoolStructOutput = [string, string, PoolTokenStructOutput[]] & { } export type SwapQueryStruct = { - swapAdapter: PromiseOrValue - tokenOut: PromiseOrValue - minAmountOut: PromiseOrValue - deadline: PromiseOrValue - rawParams: PromiseOrValue + swapAdapter: string + tokenOut: string + minAmountOut: BigNumberish + deadline: BigNumberish + rawParams: BytesLike } export type SwapQueryStructOutput = [ @@ -72,20 +68,14 @@ export type SwapQueryStructOutput = [ rawParams: string } -export type BridgeTokenStruct = { - symbol: PromiseOrValue - token: PromiseOrValue -} +export type BridgeTokenStruct = { symbol: string; token: string } export type BridgeTokenStructOutput = [string, string] & { symbol: string token: string } -export type DestRequestStruct = { - symbol: PromiseOrValue - amountIn: PromiseOrValue -} +export type DestRequestStruct = { symbol: string; amountIn: BigNumberish } export type DestRequestStructOutput = [string, BigNumber] & { symbol: string @@ -94,18 +84,20 @@ export type DestRequestStructOutput = [string, BigNumber] & { export declare namespace LocalBridgeConfig { export type BridgeTokenConfigStruct = { - id: PromiseOrValue - token: PromiseOrValue - tokenType: PromiseOrValue - bridgeToken: PromiseOrValue - bridgeFee: PromiseOrValue - minFee: PromiseOrValue - maxFee: PromiseOrValue + id: string + token: string + decimals: BigNumberish + tokenType: BigNumberish + bridgeToken: string + bridgeFee: BigNumberish + minFee: BigNumberish + maxFee: BigNumberish } export type BridgeTokenConfigStructOutput = [ string, string, + BigNumber, number, string, BigNumber, @@ -114,6 +106,7 @@ export declare namespace LocalBridgeConfig { ] & { id: string token: string + decimals: BigNumber tokenType: number bridgeToken: string bridgeFee: BigNumber @@ -122,11 +115,20 @@ export declare namespace LocalBridgeConfig { } } +export declare namespace MulticallView { + export type ResultStruct = { success: boolean; returnData: BytesLike } + + export type ResultStructOutput = [boolean, string] & { + success: boolean + returnData: string + } +} + export interface SynapseRouterInterface extends utils.Interface { functions: { 'adapterSwap(address,address,uint256,address,bytes)': FunctionFragment 'addToken(string,address,uint8,address,uint256,uint256,uint256)': FunctionFragment - 'addTokens((string,address,uint8,address,uint256,uint256,uint256)[])': FunctionFragment + 'addTokens((string,address,uint256,uint8,address,uint256,uint256,uint256)[])': FunctionFragment 'allPools()': FunctionFragment 'bridge(address,uint256,address,uint256,(address,address,uint256,uint256,bytes),(address,address,uint256,uint256,bytes))': FunctionFragment 'bridgeTokens()': FunctionFragment @@ -142,6 +144,7 @@ export interface SynapseRouterInterface extends utils.Interface { 'getConnectedBridgeTokens(address)': FunctionFragment 'getDestinationAmountOut((string,uint256)[],address)': FunctionFragment 'getOriginAmountOut(address,string[],uint256)': FunctionFragment + 'multicallView(bytes[])': FunctionFragment 'owner()': FunctionFragment 'poolInfo(address)': FunctionFragment 'poolTokens(address)': FunctionFragment @@ -181,6 +184,7 @@ export interface SynapseRouterInterface extends utils.Interface { | 'getConnectedBridgeTokens' | 'getDestinationAmountOut' | 'getOriginAmountOut' + | 'multicallView' | 'owner' | 'poolInfo' | 'poolTokens' @@ -202,24 +206,18 @@ export interface SynapseRouterInterface extends utils.Interface { encodeFunctionData( functionFragment: 'adapterSwap', - values: [ - PromiseOrValue, - PromiseOrValue, - PromiseOrValue, - PromiseOrValue, - PromiseOrValue - ] + values: [string, string, BigNumberish, string, BytesLike] ): string encodeFunctionData( functionFragment: 'addToken', values: [ - PromiseOrValue, - PromiseOrValue, - PromiseOrValue, - PromiseOrValue, - PromiseOrValue, - PromiseOrValue, - PromiseOrValue + string, + string, + BigNumberish, + string, + BigNumberish, + BigNumberish, + BigNumberish ] ): string encodeFunctionData( @@ -230,10 +228,10 @@ export interface SynapseRouterInterface extends utils.Interface { encodeFunctionData( functionFragment: 'bridge', values: [ - PromiseOrValue, - PromiseOrValue, - PromiseOrValue, - PromiseOrValue, + string, + BigNumberish, + string, + BigNumberish, SwapQueryStruct, SwapQueryStruct ] @@ -248,85 +246,57 @@ export interface SynapseRouterInterface extends utils.Interface { ): string encodeFunctionData( functionFragment: 'calculateAddLiquidity', - values: [PromiseOrValue, PromiseOrValue[]] + values: [string, BigNumberish[]] ): string encodeFunctionData( functionFragment: 'calculateBridgeFee', - values: [PromiseOrValue, PromiseOrValue] + values: [string, BigNumberish] ): string encodeFunctionData( functionFragment: 'calculateRemoveLiquidity', - values: [PromiseOrValue, PromiseOrValue] + values: [string, BigNumberish] ): string encodeFunctionData( functionFragment: 'calculateSwap', - values: [ - PromiseOrValue, - PromiseOrValue, - PromiseOrValue, - PromiseOrValue - ] + values: [string, BigNumberish, BigNumberish, BigNumberish] ): string encodeFunctionData( functionFragment: 'calculateWithdrawOneToken', - values: [ - PromiseOrValue, - PromiseOrValue, - PromiseOrValue - ] - ): string - encodeFunctionData( - functionFragment: 'config', - values: [PromiseOrValue] - ): string - encodeFunctionData( - functionFragment: 'fee', - values: [PromiseOrValue] + values: [string, BigNumberish, BigNumberish] ): string + encodeFunctionData(functionFragment: 'config', values: [string]): string + encodeFunctionData(functionFragment: 'fee', values: [string]): string encodeFunctionData( functionFragment: 'getAmountOut', - values: [ - PromiseOrValue, - PromiseOrValue, - PromiseOrValue - ] + values: [string, string, BigNumberish] ): string encodeFunctionData( functionFragment: 'getConnectedBridgeTokens', - values: [PromiseOrValue] + values: [string] ): string encodeFunctionData( functionFragment: 'getDestinationAmountOut', - values: [DestRequestStruct[], PromiseOrValue] + values: [DestRequestStruct[], string] ): string encodeFunctionData( functionFragment: 'getOriginAmountOut', - values: [ - PromiseOrValue, - PromiseOrValue[], - PromiseOrValue - ] + values: [string, string[], BigNumberish] ): string - encodeFunctionData(functionFragment: 'owner', values?: undefined): string encodeFunctionData( - functionFragment: 'poolInfo', - values: [PromiseOrValue] - ): string - encodeFunctionData( - functionFragment: 'poolTokens', - values: [PromiseOrValue] + functionFragment: 'multicallView', + values: [BytesLike[]] ): string + encodeFunctionData(functionFragment: 'owner', values?: undefined): string + encodeFunctionData(functionFragment: 'poolInfo', values: [string]): string + encodeFunctionData(functionFragment: 'poolTokens', values: [string]): string encodeFunctionData( functionFragment: 'poolsAmount', values?: undefined ): string - encodeFunctionData( - functionFragment: 'removeToken', - values: [PromiseOrValue] - ): string + encodeFunctionData(functionFragment: 'removeToken', values: [string]): string encodeFunctionData( functionFragment: 'removeTokens', - values: [PromiseOrValue[]] + values: [string[]] ): string encodeFunctionData( functionFragment: 'renounceOwnership', @@ -334,46 +304,28 @@ export interface SynapseRouterInterface extends utils.Interface { ): string encodeFunctionData( functionFragment: 'setAllowance', - values: [ - PromiseOrValue, - PromiseOrValue, - PromiseOrValue - ] + values: [string, string, BigNumberish] ): string encodeFunctionData( functionFragment: 'setSwapQuoter', - values: [PromiseOrValue] + values: [string] ): string encodeFunctionData( functionFragment: 'setTokenConfig', - values: [ - PromiseOrValue, - PromiseOrValue, - PromiseOrValue - ] + values: [string, BigNumberish, string] ): string encodeFunctionData( functionFragment: 'setTokenFee', - values: [ - PromiseOrValue, - PromiseOrValue, - PromiseOrValue, - PromiseOrValue - ] + values: [string, BigNumberish, BigNumberish, BigNumberish] ): string encodeFunctionData( functionFragment: 'swap', - values: [ - PromiseOrValue, - PromiseOrValue, - PromiseOrValue, - SwapQueryStruct - ] + values: [string, string, BigNumberish, SwapQueryStruct] ): string encodeFunctionData(functionFragment: 'swapQuoter', values?: undefined): string encodeFunctionData( functionFragment: 'symbolToToken', - values: [PromiseOrValue] + values: [string] ): string encodeFunctionData( functionFragment: 'synapseBridge', @@ -381,11 +333,11 @@ export interface SynapseRouterInterface extends utils.Interface { ): string encodeFunctionData( functionFragment: 'tokenToSymbol', - values: [PromiseOrValue] + values: [string] ): string encodeFunctionData( functionFragment: 'transferOwnership', - values: [PromiseOrValue] + values: [string] ): string decodeFunctionResult(functionFragment: 'adapterSwap', data: BytesLike): Result @@ -439,6 +391,10 @@ export interface SynapseRouterInterface extends utils.Interface { functionFragment: 'getOriginAmountOut', data: BytesLike ): Result + decodeFunctionResult( + functionFragment: 'multicallView', + data: BytesLike + ): Result decodeFunctionResult(functionFragment: 'owner', data: BytesLike): Result decodeFunctionResult(functionFragment: 'poolInfo', data: BytesLike): Result decodeFunctionResult(functionFragment: 'poolTokens', data: BytesLike): Result @@ -531,28 +487,28 @@ export interface SynapseRouter extends BaseContract { functions: { adapterSwap( - to: PromiseOrValue, - tokenIn: PromiseOrValue, - amountIn: PromiseOrValue, - tokenOut: PromiseOrValue, - rawParams: PromiseOrValue, - overrides?: PayableOverrides & { from?: PromiseOrValue } + to: string, + tokenIn: string, + amountIn: BigNumberish, + tokenOut: string, + rawParams: BytesLike, + overrides?: PayableOverrides & { from?: string } ): Promise addToken( - symbol: PromiseOrValue, - token: PromiseOrValue, - tokenType: PromiseOrValue, - bridgeToken: PromiseOrValue, - bridgeFee: PromiseOrValue, - minFee: PromiseOrValue, - maxFee: PromiseOrValue, - overrides?: Overrides & { from?: PromiseOrValue } + symbol: string, + token: string, + tokenType: BigNumberish, + bridgeToken: string, + bridgeFee: BigNumberish, + minFee: BigNumberish, + maxFee: BigNumberish, + overrides?: Overrides & { from?: string } ): Promise addTokens( tokens: LocalBridgeConfig.BridgeTokenConfigStruct[], - overrides?: Overrides & { from?: PromiseOrValue } + overrides?: Overrides & { from?: string } ): Promise allPools( @@ -560,13 +516,13 @@ export interface SynapseRouter extends BaseContract { ): Promise<[PoolStructOutput[]] & { pools: PoolStructOutput[] }> bridge( - to: PromiseOrValue, - chainId: PromiseOrValue, - token: PromiseOrValue, - amount: PromiseOrValue, + to: string, + chainId: BigNumberish, + token: string, + amount: BigNumberish, originQuery: SwapQueryStruct, destQuery: SwapQueryStruct, - overrides?: PayableOverrides & { from?: PromiseOrValue } + overrides?: PayableOverrides & { from?: string } ): Promise bridgeTokens( @@ -578,45 +534,45 @@ export interface SynapseRouter extends BaseContract { ): Promise<[BigNumber] & { amount: BigNumber }> calculateAddLiquidity( - pool: PromiseOrValue, - amounts: PromiseOrValue[], + pool: string, + amounts: BigNumberish[], overrides?: CallOverrides ): Promise<[BigNumber]> calculateBridgeFee( - token: PromiseOrValue, - amount: PromiseOrValue, + token: string, + amount: BigNumberish, overrides?: CallOverrides ): Promise<[BigNumber] & { feeAmount: BigNumber }> calculateRemoveLiquidity( - pool: PromiseOrValue, - amount: PromiseOrValue, + pool: string, + amount: BigNumberish, overrides?: CallOverrides ): Promise<[BigNumber[]] & { amountsOut: BigNumber[] }> calculateSwap( - pool: PromiseOrValue, - tokenIndexFrom: PromiseOrValue, - tokenIndexTo: PromiseOrValue, - dx: PromiseOrValue, + pool: string, + tokenIndexFrom: BigNumberish, + tokenIndexTo: BigNumberish, + dx: BigNumberish, overrides?: CallOverrides ): Promise<[BigNumber] & { amountOut: BigNumber }> calculateWithdrawOneToken( - pool: PromiseOrValue, - tokenAmount: PromiseOrValue, - tokenIndex: PromiseOrValue, + pool: string, + tokenAmount: BigNumberish, + tokenIndex: BigNumberish, overrides?: CallOverrides ): Promise<[BigNumber] & { amountOut: BigNumber }> config( - arg0: PromiseOrValue, + arg0: string, overrides?: CallOverrides ): Promise<[number, string] & { tokenType: number; bridgeToken: string }> fee( - arg0: PromiseOrValue, + arg0: string, overrides?: CallOverrides ): Promise< [number, BigNumber, BigNumber] & { @@ -627,14 +583,14 @@ export interface SynapseRouter extends BaseContract { > getAmountOut( - tokenIn: PromiseOrValue, - tokenOut: PromiseOrValue, - amountIn: PromiseOrValue, + tokenIn: string, + tokenOut: string, + amountIn: BigNumberish, overrides?: CallOverrides ): Promise<[SwapQueryStructOutput]> getConnectedBridgeTokens( - tokenOut: PromiseOrValue, + tokenOut: string, overrides?: CallOverrides ): Promise< [BridgeTokenStructOutput[]] & { tokens: BridgeTokenStructOutput[] } @@ -642,30 +598,39 @@ export interface SynapseRouter extends BaseContract { getDestinationAmountOut( requests: DestRequestStruct[], - tokenOut: PromiseOrValue, + tokenOut: string, overrides?: CallOverrides ): Promise< [SwapQueryStructOutput[]] & { destQueries: SwapQueryStructOutput[] } > getOriginAmountOut( - tokenIn: PromiseOrValue, - tokenSymbols: PromiseOrValue[], - amountIn: PromiseOrValue, + tokenIn: string, + tokenSymbols: string[], + amountIn: BigNumberish, overrides?: CallOverrides ): Promise< [SwapQueryStructOutput[]] & { originQueries: SwapQueryStructOutput[] } > + multicallView( + data: BytesLike[], + overrides?: CallOverrides + ): Promise< + [MulticallView.ResultStructOutput[]] & { + callResults: MulticallView.ResultStructOutput[] + } + > + owner(overrides?: CallOverrides): Promise<[string]> poolInfo( - pool: PromiseOrValue, + pool: string, overrides?: CallOverrides ): Promise<[BigNumber, string]> poolTokens( - pool: PromiseOrValue, + pool: string, overrides?: CallOverrides ): Promise<[PoolTokenStructOutput[]] & { tokens: PoolTokenStructOutput[] }> @@ -674,109 +639,103 @@ export interface SynapseRouter extends BaseContract { ): Promise<[BigNumber] & { amount: BigNumber }> removeToken( - token: PromiseOrValue, - overrides?: Overrides & { from?: PromiseOrValue } + token: string, + overrides?: Overrides & { from?: string } ): Promise removeTokens( - tokens: PromiseOrValue[], - overrides?: Overrides & { from?: PromiseOrValue } + tokens: string[], + overrides?: Overrides & { from?: string } ): Promise renounceOwnership( - overrides?: Overrides & { from?: PromiseOrValue } + overrides?: Overrides & { from?: string } ): Promise setAllowance( - token: PromiseOrValue, - spender: PromiseOrValue, - amount: PromiseOrValue, - overrides?: Overrides & { from?: PromiseOrValue } + token: string, + spender: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } ): Promise setSwapQuoter( - _swapQuoter: PromiseOrValue, - overrides?: Overrides & { from?: PromiseOrValue } + _swapQuoter: string, + overrides?: Overrides & { from?: string } ): Promise setTokenConfig( - token: PromiseOrValue, - tokenType: PromiseOrValue, - bridgeToken: PromiseOrValue, - overrides?: Overrides & { from?: PromiseOrValue } + token: string, + tokenType: BigNumberish, + bridgeToken: string, + overrides?: Overrides & { from?: string } ): Promise setTokenFee( - token: PromiseOrValue, - bridgeFee: PromiseOrValue, - minFee: PromiseOrValue, - maxFee: PromiseOrValue, - overrides?: Overrides & { from?: PromiseOrValue } + token: string, + bridgeFee: BigNumberish, + minFee: BigNumberish, + maxFee: BigNumberish, + overrides?: Overrides & { from?: string } ): Promise swap( - to: PromiseOrValue, - token: PromiseOrValue, - amount: PromiseOrValue, + to: string, + token: string, + amount: BigNumberish, query: SwapQueryStruct, - overrides?: PayableOverrides & { from?: PromiseOrValue } + overrides?: PayableOverrides & { from?: string } ): Promise swapQuoter(overrides?: CallOverrides): Promise<[string]> - symbolToToken( - arg0: PromiseOrValue, - overrides?: CallOverrides - ): Promise<[string]> + symbolToToken(arg0: string, overrides?: CallOverrides): Promise<[string]> synapseBridge(overrides?: CallOverrides): Promise<[string]> - tokenToSymbol( - arg0: PromiseOrValue, - overrides?: CallOverrides - ): Promise<[string]> + tokenToSymbol(arg0: string, overrides?: CallOverrides): Promise<[string]> transferOwnership( - newOwner: PromiseOrValue, - overrides?: Overrides & { from?: PromiseOrValue } + newOwner: string, + overrides?: Overrides & { from?: string } ): Promise } adapterSwap( - to: PromiseOrValue, - tokenIn: PromiseOrValue, - amountIn: PromiseOrValue, - tokenOut: PromiseOrValue, - rawParams: PromiseOrValue, - overrides?: PayableOverrides & { from?: PromiseOrValue } + to: string, + tokenIn: string, + amountIn: BigNumberish, + tokenOut: string, + rawParams: BytesLike, + overrides?: PayableOverrides & { from?: string } ): Promise addToken( - symbol: PromiseOrValue, - token: PromiseOrValue, - tokenType: PromiseOrValue, - bridgeToken: PromiseOrValue, - bridgeFee: PromiseOrValue, - minFee: PromiseOrValue, - maxFee: PromiseOrValue, - overrides?: Overrides & { from?: PromiseOrValue } + symbol: string, + token: string, + tokenType: BigNumberish, + bridgeToken: string, + bridgeFee: BigNumberish, + minFee: BigNumberish, + maxFee: BigNumberish, + overrides?: Overrides & { from?: string } ): Promise addTokens( tokens: LocalBridgeConfig.BridgeTokenConfigStruct[], - overrides?: Overrides & { from?: PromiseOrValue } + overrides?: Overrides & { from?: string } ): Promise allPools(overrides?: CallOverrides): Promise bridge( - to: PromiseOrValue, - chainId: PromiseOrValue, - token: PromiseOrValue, - amount: PromiseOrValue, + to: string, + chainId: BigNumberish, + token: string, + amount: BigNumberish, originQuery: SwapQueryStruct, destQuery: SwapQueryStruct, - overrides?: PayableOverrides & { from?: PromiseOrValue } + overrides?: PayableOverrides & { from?: string } ): Promise bridgeTokens(overrides?: CallOverrides): Promise @@ -784,45 +743,45 @@ export interface SynapseRouter extends BaseContract { bridgeTokensAmount(overrides?: CallOverrides): Promise calculateAddLiquidity( - pool: PromiseOrValue, - amounts: PromiseOrValue[], + pool: string, + amounts: BigNumberish[], overrides?: CallOverrides ): Promise calculateBridgeFee( - token: PromiseOrValue, - amount: PromiseOrValue, + token: string, + amount: BigNumberish, overrides?: CallOverrides ): Promise calculateRemoveLiquidity( - pool: PromiseOrValue, - amount: PromiseOrValue, + pool: string, + amount: BigNumberish, overrides?: CallOverrides ): Promise calculateSwap( - pool: PromiseOrValue, - tokenIndexFrom: PromiseOrValue, - tokenIndexTo: PromiseOrValue, - dx: PromiseOrValue, + pool: string, + tokenIndexFrom: BigNumberish, + tokenIndexTo: BigNumberish, + dx: BigNumberish, overrides?: CallOverrides ): Promise calculateWithdrawOneToken( - pool: PromiseOrValue, - tokenAmount: PromiseOrValue, - tokenIndex: PromiseOrValue, + pool: string, + tokenAmount: BigNumberish, + tokenIndex: BigNumberish, overrides?: CallOverrides ): Promise config( - arg0: PromiseOrValue, + arg0: string, overrides?: CallOverrides ): Promise<[number, string] & { tokenType: number; bridgeToken: string }> fee( - arg0: PromiseOrValue, + arg0: string, overrides?: CallOverrides ): Promise< [number, BigNumber, BigNumber] & { @@ -833,130 +792,129 @@ export interface SynapseRouter extends BaseContract { > getAmountOut( - tokenIn: PromiseOrValue, - tokenOut: PromiseOrValue, - amountIn: PromiseOrValue, + tokenIn: string, + tokenOut: string, + amountIn: BigNumberish, overrides?: CallOverrides ): Promise getConnectedBridgeTokens( - tokenOut: PromiseOrValue, + tokenOut: string, overrides?: CallOverrides ): Promise getDestinationAmountOut( requests: DestRequestStruct[], - tokenOut: PromiseOrValue, + tokenOut: string, overrides?: CallOverrides ): Promise getOriginAmountOut( - tokenIn: PromiseOrValue, - tokenSymbols: PromiseOrValue[], - amountIn: PromiseOrValue, + tokenIn: string, + tokenSymbols: string[], + amountIn: BigNumberish, overrides?: CallOverrides ): Promise + multicallView( + data: BytesLike[], + overrides?: CallOverrides + ): Promise + owner(overrides?: CallOverrides): Promise poolInfo( - pool: PromiseOrValue, + pool: string, overrides?: CallOverrides ): Promise<[BigNumber, string]> poolTokens( - pool: PromiseOrValue, + pool: string, overrides?: CallOverrides ): Promise poolsAmount(overrides?: CallOverrides): Promise removeToken( - token: PromiseOrValue, - overrides?: Overrides & { from?: PromiseOrValue } + token: string, + overrides?: Overrides & { from?: string } ): Promise removeTokens( - tokens: PromiseOrValue[], - overrides?: Overrides & { from?: PromiseOrValue } + tokens: string[], + overrides?: Overrides & { from?: string } ): Promise renounceOwnership( - overrides?: Overrides & { from?: PromiseOrValue } + overrides?: Overrides & { from?: string } ): Promise setAllowance( - token: PromiseOrValue, - spender: PromiseOrValue, - amount: PromiseOrValue, - overrides?: Overrides & { from?: PromiseOrValue } + token: string, + spender: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } ): Promise setSwapQuoter( - _swapQuoter: PromiseOrValue, - overrides?: Overrides & { from?: PromiseOrValue } + _swapQuoter: string, + overrides?: Overrides & { from?: string } ): Promise setTokenConfig( - token: PromiseOrValue, - tokenType: PromiseOrValue, - bridgeToken: PromiseOrValue, - overrides?: Overrides & { from?: PromiseOrValue } + token: string, + tokenType: BigNumberish, + bridgeToken: string, + overrides?: Overrides & { from?: string } ): Promise setTokenFee( - token: PromiseOrValue, - bridgeFee: PromiseOrValue, - minFee: PromiseOrValue, - maxFee: PromiseOrValue, - overrides?: Overrides & { from?: PromiseOrValue } + token: string, + bridgeFee: BigNumberish, + minFee: BigNumberish, + maxFee: BigNumberish, + overrides?: Overrides & { from?: string } ): Promise swap( - to: PromiseOrValue, - token: PromiseOrValue, - amount: PromiseOrValue, + to: string, + token: string, + amount: BigNumberish, query: SwapQueryStruct, - overrides?: PayableOverrides & { from?: PromiseOrValue } + overrides?: PayableOverrides & { from?: string } ): Promise swapQuoter(overrides?: CallOverrides): Promise - symbolToToken( - arg0: PromiseOrValue, - overrides?: CallOverrides - ): Promise + symbolToToken(arg0: string, overrides?: CallOverrides): Promise synapseBridge(overrides?: CallOverrides): Promise - tokenToSymbol( - arg0: PromiseOrValue, - overrides?: CallOverrides - ): Promise + tokenToSymbol(arg0: string, overrides?: CallOverrides): Promise transferOwnership( - newOwner: PromiseOrValue, - overrides?: Overrides & { from?: PromiseOrValue } + newOwner: string, + overrides?: Overrides & { from?: string } ): Promise callStatic: { adapterSwap( - to: PromiseOrValue, - tokenIn: PromiseOrValue, - amountIn: PromiseOrValue, - tokenOut: PromiseOrValue, - rawParams: PromiseOrValue, + to: string, + tokenIn: string, + amountIn: BigNumberish, + tokenOut: string, + rawParams: BytesLike, overrides?: CallOverrides ): Promise addToken( - symbol: PromiseOrValue, - token: PromiseOrValue, - tokenType: PromiseOrValue, - bridgeToken: PromiseOrValue, - bridgeFee: PromiseOrValue, - minFee: PromiseOrValue, - maxFee: PromiseOrValue, + symbol: string, + token: string, + tokenType: BigNumberish, + bridgeToken: string, + bridgeFee: BigNumberish, + minFee: BigNumberish, + maxFee: BigNumberish, overrides?: CallOverrides ): Promise @@ -968,10 +926,10 @@ export interface SynapseRouter extends BaseContract { allPools(overrides?: CallOverrides): Promise bridge( - to: PromiseOrValue, - chainId: PromiseOrValue, - token: PromiseOrValue, - amount: PromiseOrValue, + to: string, + chainId: BigNumberish, + token: string, + amount: BigNumberish, originQuery: SwapQueryStruct, destQuery: SwapQueryStruct, overrides?: CallOverrides @@ -982,45 +940,45 @@ export interface SynapseRouter extends BaseContract { bridgeTokensAmount(overrides?: CallOverrides): Promise calculateAddLiquidity( - pool: PromiseOrValue, - amounts: PromiseOrValue[], + pool: string, + amounts: BigNumberish[], overrides?: CallOverrides ): Promise calculateBridgeFee( - token: PromiseOrValue, - amount: PromiseOrValue, + token: string, + amount: BigNumberish, overrides?: CallOverrides ): Promise calculateRemoveLiquidity( - pool: PromiseOrValue, - amount: PromiseOrValue, + pool: string, + amount: BigNumberish, overrides?: CallOverrides ): Promise calculateSwap( - pool: PromiseOrValue, - tokenIndexFrom: PromiseOrValue, - tokenIndexTo: PromiseOrValue, - dx: PromiseOrValue, + pool: string, + tokenIndexFrom: BigNumberish, + tokenIndexTo: BigNumberish, + dx: BigNumberish, overrides?: CallOverrides ): Promise calculateWithdrawOneToken( - pool: PromiseOrValue, - tokenAmount: PromiseOrValue, - tokenIndex: PromiseOrValue, + pool: string, + tokenAmount: BigNumberish, + tokenIndex: BigNumberish, overrides?: CallOverrides ): Promise config( - arg0: PromiseOrValue, + arg0: string, overrides?: CallOverrides ): Promise<[number, string] & { tokenType: number; bridgeToken: string }> fee( - arg0: PromiseOrValue, + arg0: string, overrides?: CallOverrides ): Promise< [number, BigNumber, BigNumber] & { @@ -1031,158 +989,148 @@ export interface SynapseRouter extends BaseContract { > getAmountOut( - tokenIn: PromiseOrValue, - tokenOut: PromiseOrValue, - amountIn: PromiseOrValue, + tokenIn: string, + tokenOut: string, + amountIn: BigNumberish, overrides?: CallOverrides ): Promise getConnectedBridgeTokens( - tokenOut: PromiseOrValue, + tokenOut: string, overrides?: CallOverrides ): Promise getDestinationAmountOut( requests: DestRequestStruct[], - tokenOut: PromiseOrValue, + tokenOut: string, overrides?: CallOverrides ): Promise getOriginAmountOut( - tokenIn: PromiseOrValue, - tokenSymbols: PromiseOrValue[], - amountIn: PromiseOrValue, + tokenIn: string, + tokenSymbols: string[], + amountIn: BigNumberish, overrides?: CallOverrides ): Promise + multicallView( + data: BytesLike[], + overrides?: CallOverrides + ): Promise + owner(overrides?: CallOverrides): Promise poolInfo( - pool: PromiseOrValue, + pool: string, overrides?: CallOverrides ): Promise<[BigNumber, string]> poolTokens( - pool: PromiseOrValue, + pool: string, overrides?: CallOverrides ): Promise poolsAmount(overrides?: CallOverrides): Promise - removeToken( - token: PromiseOrValue, - overrides?: CallOverrides - ): Promise + removeToken(token: string, overrides?: CallOverrides): Promise - removeTokens( - tokens: PromiseOrValue[], - overrides?: CallOverrides - ): Promise + removeTokens(tokens: string[], overrides?: CallOverrides): Promise renounceOwnership(overrides?: CallOverrides): Promise setAllowance( - token: PromiseOrValue, - spender: PromiseOrValue, - amount: PromiseOrValue, + token: string, + spender: string, + amount: BigNumberish, overrides?: CallOverrides ): Promise - setSwapQuoter( - _swapQuoter: PromiseOrValue, - overrides?: CallOverrides - ): Promise + setSwapQuoter(_swapQuoter: string, overrides?: CallOverrides): Promise setTokenConfig( - token: PromiseOrValue, - tokenType: PromiseOrValue, - bridgeToken: PromiseOrValue, + token: string, + tokenType: BigNumberish, + bridgeToken: string, overrides?: CallOverrides ): Promise setTokenFee( - token: PromiseOrValue, - bridgeFee: PromiseOrValue, - minFee: PromiseOrValue, - maxFee: PromiseOrValue, + token: string, + bridgeFee: BigNumberish, + minFee: BigNumberish, + maxFee: BigNumberish, overrides?: CallOverrides ): Promise swap( - to: PromiseOrValue, - token: PromiseOrValue, - amount: PromiseOrValue, + to: string, + token: string, + amount: BigNumberish, query: SwapQueryStruct, overrides?: CallOverrides ): Promise swapQuoter(overrides?: CallOverrides): Promise - symbolToToken( - arg0: PromiseOrValue, - overrides?: CallOverrides - ): Promise + symbolToToken(arg0: string, overrides?: CallOverrides): Promise synapseBridge(overrides?: CallOverrides): Promise - tokenToSymbol( - arg0: PromiseOrValue, - overrides?: CallOverrides - ): Promise + tokenToSymbol(arg0: string, overrides?: CallOverrides): Promise transferOwnership( - newOwner: PromiseOrValue, + newOwner: string, overrides?: CallOverrides ): Promise } filters: { 'OwnershipTransferred(address,address)'( - previousOwner?: PromiseOrValue | null, - newOwner?: PromiseOrValue | null + previousOwner?: string | null, + newOwner?: string | null ): OwnershipTransferredEventFilter OwnershipTransferred( - previousOwner?: PromiseOrValue | null, - newOwner?: PromiseOrValue | null + previousOwner?: string | null, + newOwner?: string | null ): OwnershipTransferredEventFilter } estimateGas: { adapterSwap( - to: PromiseOrValue, - tokenIn: PromiseOrValue, - amountIn: PromiseOrValue, - tokenOut: PromiseOrValue, - rawParams: PromiseOrValue, - overrides?: PayableOverrides & { from?: PromiseOrValue } + to: string, + tokenIn: string, + amountIn: BigNumberish, + tokenOut: string, + rawParams: BytesLike, + overrides?: PayableOverrides & { from?: string } ): Promise addToken( - symbol: PromiseOrValue, - token: PromiseOrValue, - tokenType: PromiseOrValue, - bridgeToken: PromiseOrValue, - bridgeFee: PromiseOrValue, - minFee: PromiseOrValue, - maxFee: PromiseOrValue, - overrides?: Overrides & { from?: PromiseOrValue } + symbol: string, + token: string, + tokenType: BigNumberish, + bridgeToken: string, + bridgeFee: BigNumberish, + minFee: BigNumberish, + maxFee: BigNumberish, + overrides?: Overrides & { from?: string } ): Promise addTokens( tokens: LocalBridgeConfig.BridgeTokenConfigStruct[], - overrides?: Overrides & { from?: PromiseOrValue } + overrides?: Overrides & { from?: string } ): Promise allPools(overrides?: CallOverrides): Promise bridge( - to: PromiseOrValue, - chainId: PromiseOrValue, - token: PromiseOrValue, - amount: PromiseOrValue, + to: string, + chainId: BigNumberish, + token: string, + amount: BigNumberish, originQuery: SwapQueryStruct, destQuery: SwapQueryStruct, - overrides?: PayableOverrides & { from?: PromiseOrValue } + overrides?: PayableOverrides & { from?: string } ): Promise bridgeTokens(overrides?: CallOverrides): Promise @@ -1190,192 +1138,179 @@ export interface SynapseRouter extends BaseContract { bridgeTokensAmount(overrides?: CallOverrides): Promise calculateAddLiquidity( - pool: PromiseOrValue, - amounts: PromiseOrValue[], + pool: string, + amounts: BigNumberish[], overrides?: CallOverrides ): Promise calculateBridgeFee( - token: PromiseOrValue, - amount: PromiseOrValue, + token: string, + amount: BigNumberish, overrides?: CallOverrides ): Promise calculateRemoveLiquidity( - pool: PromiseOrValue, - amount: PromiseOrValue, + pool: string, + amount: BigNumberish, overrides?: CallOverrides ): Promise calculateSwap( - pool: PromiseOrValue, - tokenIndexFrom: PromiseOrValue, - tokenIndexTo: PromiseOrValue, - dx: PromiseOrValue, + pool: string, + tokenIndexFrom: BigNumberish, + tokenIndexTo: BigNumberish, + dx: BigNumberish, overrides?: CallOverrides ): Promise calculateWithdrawOneToken( - pool: PromiseOrValue, - tokenAmount: PromiseOrValue, - tokenIndex: PromiseOrValue, + pool: string, + tokenAmount: BigNumberish, + tokenIndex: BigNumberish, overrides?: CallOverrides ): Promise - config( - arg0: PromiseOrValue, - overrides?: CallOverrides - ): Promise + config(arg0: string, overrides?: CallOverrides): Promise - fee( - arg0: PromiseOrValue, - overrides?: CallOverrides - ): Promise + fee(arg0: string, overrides?: CallOverrides): Promise getAmountOut( - tokenIn: PromiseOrValue, - tokenOut: PromiseOrValue, - amountIn: PromiseOrValue, + tokenIn: string, + tokenOut: string, + amountIn: BigNumberish, overrides?: CallOverrides ): Promise getConnectedBridgeTokens( - tokenOut: PromiseOrValue, + tokenOut: string, overrides?: CallOverrides ): Promise getDestinationAmountOut( requests: DestRequestStruct[], - tokenOut: PromiseOrValue, + tokenOut: string, overrides?: CallOverrides ): Promise getOriginAmountOut( - tokenIn: PromiseOrValue, - tokenSymbols: PromiseOrValue[], - amountIn: PromiseOrValue, + tokenIn: string, + tokenSymbols: string[], + amountIn: BigNumberish, overrides?: CallOverrides ): Promise - owner(overrides?: CallOverrides): Promise - - poolInfo( - pool: PromiseOrValue, + multicallView( + data: BytesLike[], overrides?: CallOverrides ): Promise - poolTokens( - pool: PromiseOrValue, - overrides?: CallOverrides - ): Promise + owner(overrides?: CallOverrides): Promise + + poolInfo(pool: string, overrides?: CallOverrides): Promise + + poolTokens(pool: string, overrides?: CallOverrides): Promise poolsAmount(overrides?: CallOverrides): Promise removeToken( - token: PromiseOrValue, - overrides?: Overrides & { from?: PromiseOrValue } + token: string, + overrides?: Overrides & { from?: string } ): Promise removeTokens( - tokens: PromiseOrValue[], - overrides?: Overrides & { from?: PromiseOrValue } + tokens: string[], + overrides?: Overrides & { from?: string } ): Promise renounceOwnership( - overrides?: Overrides & { from?: PromiseOrValue } + overrides?: Overrides & { from?: string } ): Promise setAllowance( - token: PromiseOrValue, - spender: PromiseOrValue, - amount: PromiseOrValue, - overrides?: Overrides & { from?: PromiseOrValue } + token: string, + spender: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } ): Promise setSwapQuoter( - _swapQuoter: PromiseOrValue, - overrides?: Overrides & { from?: PromiseOrValue } + _swapQuoter: string, + overrides?: Overrides & { from?: string } ): Promise setTokenConfig( - token: PromiseOrValue, - tokenType: PromiseOrValue, - bridgeToken: PromiseOrValue, - overrides?: Overrides & { from?: PromiseOrValue } + token: string, + tokenType: BigNumberish, + bridgeToken: string, + overrides?: Overrides & { from?: string } ): Promise setTokenFee( - token: PromiseOrValue, - bridgeFee: PromiseOrValue, - minFee: PromiseOrValue, - maxFee: PromiseOrValue, - overrides?: Overrides & { from?: PromiseOrValue } + token: string, + bridgeFee: BigNumberish, + minFee: BigNumberish, + maxFee: BigNumberish, + overrides?: Overrides & { from?: string } ): Promise swap( - to: PromiseOrValue, - token: PromiseOrValue, - amount: PromiseOrValue, + to: string, + token: string, + amount: BigNumberish, query: SwapQueryStruct, - overrides?: PayableOverrides & { from?: PromiseOrValue } + overrides?: PayableOverrides & { from?: string } ): Promise swapQuoter(overrides?: CallOverrides): Promise - symbolToToken( - arg0: PromiseOrValue, - overrides?: CallOverrides - ): Promise + symbolToToken(arg0: string, overrides?: CallOverrides): Promise synapseBridge(overrides?: CallOverrides): Promise - tokenToSymbol( - arg0: PromiseOrValue, - overrides?: CallOverrides - ): Promise + tokenToSymbol(arg0: string, overrides?: CallOverrides): Promise transferOwnership( - newOwner: PromiseOrValue, - overrides?: Overrides & { from?: PromiseOrValue } + newOwner: string, + overrides?: Overrides & { from?: string } ): Promise } populateTransaction: { adapterSwap( - to: PromiseOrValue, - tokenIn: PromiseOrValue, - amountIn: PromiseOrValue, - tokenOut: PromiseOrValue, - rawParams: PromiseOrValue, - overrides?: PayableOverrides & { from?: PromiseOrValue } + to: string, + tokenIn: string, + amountIn: BigNumberish, + tokenOut: string, + rawParams: BytesLike, + overrides?: PayableOverrides & { from?: string } ): Promise addToken( - symbol: PromiseOrValue, - token: PromiseOrValue, - tokenType: PromiseOrValue, - bridgeToken: PromiseOrValue, - bridgeFee: PromiseOrValue, - minFee: PromiseOrValue, - maxFee: PromiseOrValue, - overrides?: Overrides & { from?: PromiseOrValue } + symbol: string, + token: string, + tokenType: BigNumberish, + bridgeToken: string, + bridgeFee: BigNumberish, + minFee: BigNumberish, + maxFee: BigNumberish, + overrides?: Overrides & { from?: string } ): Promise addTokens( tokens: LocalBridgeConfig.BridgeTokenConfigStruct[], - overrides?: Overrides & { from?: PromiseOrValue } + overrides?: Overrides & { from?: string } ): Promise allPools(overrides?: CallOverrides): Promise bridge( - to: PromiseOrValue, - chainId: PromiseOrValue, - token: PromiseOrValue, - amount: PromiseOrValue, + to: string, + chainId: BigNumberish, + token: string, + amount: BigNumberish, originQuery: SwapQueryStruct, destQuery: SwapQueryStruct, - overrides?: PayableOverrides & { from?: PromiseOrValue } + overrides?: PayableOverrides & { from?: string } ): Promise bridgeTokens(overrides?: CallOverrides): Promise @@ -1383,153 +1318,155 @@ export interface SynapseRouter extends BaseContract { bridgeTokensAmount(overrides?: CallOverrides): Promise calculateAddLiquidity( - pool: PromiseOrValue, - amounts: PromiseOrValue[], + pool: string, + amounts: BigNumberish[], overrides?: CallOverrides ): Promise calculateBridgeFee( - token: PromiseOrValue, - amount: PromiseOrValue, + token: string, + amount: BigNumberish, overrides?: CallOverrides ): Promise calculateRemoveLiquidity( - pool: PromiseOrValue, - amount: PromiseOrValue, + pool: string, + amount: BigNumberish, overrides?: CallOverrides ): Promise calculateSwap( - pool: PromiseOrValue, - tokenIndexFrom: PromiseOrValue, - tokenIndexTo: PromiseOrValue, - dx: PromiseOrValue, + pool: string, + tokenIndexFrom: BigNumberish, + tokenIndexTo: BigNumberish, + dx: BigNumberish, overrides?: CallOverrides ): Promise calculateWithdrawOneToken( - pool: PromiseOrValue, - tokenAmount: PromiseOrValue, - tokenIndex: PromiseOrValue, + pool: string, + tokenAmount: BigNumberish, + tokenIndex: BigNumberish, overrides?: CallOverrides ): Promise config( - arg0: PromiseOrValue, + arg0: string, overrides?: CallOverrides ): Promise - fee( - arg0: PromiseOrValue, - overrides?: CallOverrides - ): Promise + fee(arg0: string, overrides?: CallOverrides): Promise getAmountOut( - tokenIn: PromiseOrValue, - tokenOut: PromiseOrValue, - amountIn: PromiseOrValue, + tokenIn: string, + tokenOut: string, + amountIn: BigNumberish, overrides?: CallOverrides ): Promise getConnectedBridgeTokens( - tokenOut: PromiseOrValue, + tokenOut: string, overrides?: CallOverrides ): Promise getDestinationAmountOut( requests: DestRequestStruct[], - tokenOut: PromiseOrValue, + tokenOut: string, overrides?: CallOverrides ): Promise getOriginAmountOut( - tokenIn: PromiseOrValue, - tokenSymbols: PromiseOrValue[], - amountIn: PromiseOrValue, + tokenIn: string, + tokenSymbols: string[], + amountIn: BigNumberish, + overrides?: CallOverrides + ): Promise + + multicallView( + data: BytesLike[], overrides?: CallOverrides ): Promise owner(overrides?: CallOverrides): Promise poolInfo( - pool: PromiseOrValue, + pool: string, overrides?: CallOverrides ): Promise poolTokens( - pool: PromiseOrValue, + pool: string, overrides?: CallOverrides ): Promise poolsAmount(overrides?: CallOverrides): Promise removeToken( - token: PromiseOrValue, - overrides?: Overrides & { from?: PromiseOrValue } + token: string, + overrides?: Overrides & { from?: string } ): Promise removeTokens( - tokens: PromiseOrValue[], - overrides?: Overrides & { from?: PromiseOrValue } + tokens: string[], + overrides?: Overrides & { from?: string } ): Promise renounceOwnership( - overrides?: Overrides & { from?: PromiseOrValue } + overrides?: Overrides & { from?: string } ): Promise setAllowance( - token: PromiseOrValue, - spender: PromiseOrValue, - amount: PromiseOrValue, - overrides?: Overrides & { from?: PromiseOrValue } + token: string, + spender: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } ): Promise setSwapQuoter( - _swapQuoter: PromiseOrValue, - overrides?: Overrides & { from?: PromiseOrValue } + _swapQuoter: string, + overrides?: Overrides & { from?: string } ): Promise setTokenConfig( - token: PromiseOrValue, - tokenType: PromiseOrValue, - bridgeToken: PromiseOrValue, - overrides?: Overrides & { from?: PromiseOrValue } + token: string, + tokenType: BigNumberish, + bridgeToken: string, + overrides?: Overrides & { from?: string } ): Promise setTokenFee( - token: PromiseOrValue, - bridgeFee: PromiseOrValue, - minFee: PromiseOrValue, - maxFee: PromiseOrValue, - overrides?: Overrides & { from?: PromiseOrValue } + token: string, + bridgeFee: BigNumberish, + minFee: BigNumberish, + maxFee: BigNumberish, + overrides?: Overrides & { from?: string } ): Promise swap( - to: PromiseOrValue, - token: PromiseOrValue, - amount: PromiseOrValue, + to: string, + token: string, + amount: BigNumberish, query: SwapQueryStruct, - overrides?: PayableOverrides & { from?: PromiseOrValue } + overrides?: PayableOverrides & { from?: string } ): Promise swapQuoter(overrides?: CallOverrides): Promise symbolToToken( - arg0: PromiseOrValue, + arg0: string, overrides?: CallOverrides ): Promise synapseBridge(overrides?: CallOverrides): Promise tokenToSymbol( - arg0: PromiseOrValue, + arg0: string, overrides?: CallOverrides ): Promise transferOwnership( - newOwner: PromiseOrValue, - overrides?: Overrides & { from?: PromiseOrValue } + newOwner: string, + overrides?: Overrides & { from?: string } ): Promise } } diff --git a/packages/sdk-router/src/typechain/common.ts b/packages/sdk-router/src/typechain/common.ts index 4c90b08bb4..bce91ad87e 100644 --- a/packages/sdk-router/src/typechain/common.ts +++ b/packages/sdk-router/src/typechain/common.ts @@ -1,46 +1,44 @@ /* Autogenerated file. Do not edit manually. */ /* tslint:disable */ /* eslint-disable */ -import type { Listener } from "@ethersproject/providers"; -import type { Event, EventFilter } from "ethers"; +import type { Listener } from '@ethersproject/providers' +import type { Event, EventFilter } from 'ethers' export interface TypedEvent< TArgsArray extends Array = any, TArgsObject = any > extends Event { - args: TArgsArray & TArgsObject; + args: TArgsArray & TArgsObject } export interface TypedEventFilter<_TEvent extends TypedEvent> extends EventFilter {} export interface TypedListener { - (...listenerArg: [...__TypechainArgsArray, TEvent]): void; + (...listenerArg: [...__TypechainArgsArray, TEvent]): void } -type __TypechainArgsArray = T extends TypedEvent ? U : never; +type __TypechainArgsArray = T extends TypedEvent ? U : never export interface OnEvent { ( eventFilter: TypedEventFilter, listener: TypedListener - ): TRes; - (eventName: string, listener: Listener): TRes; + ): TRes + (eventName: string, listener: Listener): TRes } export type MinEthersFactory = { - deploy(...a: ARGS[]): Promise; -}; + deploy(...a: ARGS[]): Promise +} export type GetContractTypeFromFactory = F extends MinEthersFactory< infer C, any > ? C - : never; + : never export type GetARGsTypeFromFactory = F extends MinEthersFactory - ? Parameters - : never; - -export type PromiseOrValue = T | Promise; + ? Parameters + : never From 45ab6d68931094bac0c9e2267ad73bd6542a79a2 Mon Sep 17 00:00:00 2001 From: ChiTimesChi Date: Fri, 22 Dec 2023 16:05:15 +0000 Subject: [PATCH 18/29] Publish - @synapsecns/rest-api@1.0.33 - @synapsecns/sdk-router@0.3.6 - @synapsecns/synapse-interface@0.1.214 --- packages/rest-api/CHANGELOG.md | 8 ++++++++ packages/rest-api/package.json | 4 ++-- packages/sdk-router/CHANGELOG.md | 8 ++++++++ packages/sdk-router/package.json | 2 +- packages/synapse-interface/CHANGELOG.md | 8 ++++++++ packages/synapse-interface/package.json | 4 ++-- 6 files changed, 29 insertions(+), 5 deletions(-) diff --git a/packages/rest-api/CHANGELOG.md b/packages/rest-api/CHANGELOG.md index 299644a197..cb2e913690 100644 --- a/packages/rest-api/CHANGELOG.md +++ b/packages/rest-api/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.33](https://github.com/synapsecns/sanguine/compare/@synapsecns/rest-api@1.0.32...@synapsecns/rest-api@1.0.33) (2023-12-22) + +**Note:** Version bump only for package @synapsecns/rest-api + + + + + ## [1.0.32](https://github.com/synapsecns/sanguine/compare/@synapsecns/rest-api@1.0.31...@synapsecns/rest-api@1.0.32) (2023-12-22) **Note:** Version bump only for package @synapsecns/rest-api diff --git a/packages/rest-api/package.json b/packages/rest-api/package.json index d66f992f12..ccdbd7a3f3 100644 --- a/packages/rest-api/package.json +++ b/packages/rest-api/package.json @@ -1,6 +1,6 @@ { "name": "@synapsecns/rest-api", - "version": "1.0.32", + "version": "1.0.33", "private": "true", "engines": { "node": ">=16.0.0" @@ -23,7 +23,7 @@ "@ethersproject/bignumber": "^5.7.0", "@ethersproject/providers": "^5.7.2", "@ethersproject/units": "5.7.0", - "@synapsecns/sdk-router": "^0.3.5", + "@synapsecns/sdk-router": "^0.3.6", "bignumber": "^1.1.0", "ethers": "5.7.2", "express": "^4.18.2", diff --git a/packages/sdk-router/CHANGELOG.md b/packages/sdk-router/CHANGELOG.md index 054aad371f..ece9f6bff4 100644 --- a/packages/sdk-router/CHANGELOG.md +++ b/packages/sdk-router/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.3.6](https://github.com/synapsecns/sanguine/compare/@synapsecns/sdk-router@0.3.5...@synapsecns/sdk-router@0.3.6) (2023-12-22) + +**Note:** Version bump only for package @synapsecns/sdk-router + + + + + ## [0.3.5](https://github.com/synapsecns/sanguine/compare/@synapsecns/sdk-router@0.3.4...@synapsecns/sdk-router@0.3.5) (2023-12-22) **Note:** Version bump only for package @synapsecns/sdk-router diff --git a/packages/sdk-router/package.json b/packages/sdk-router/package.json index 75126ff5ed..be75147e12 100644 --- a/packages/sdk-router/package.json +++ b/packages/sdk-router/package.json @@ -1,7 +1,7 @@ { "name": "@synapsecns/sdk-router", "description": "An SDK for interacting with the Synapse Protocol", - "version": "0.3.5", + "version": "0.3.6", "license": "MIT", "main": "dist/index.js", "typings": "dist/index.d.ts", diff --git a/packages/synapse-interface/CHANGELOG.md b/packages/synapse-interface/CHANGELOG.md index 819bbe7cc0..6a82745518 100644 --- a/packages/synapse-interface/CHANGELOG.md +++ b/packages/synapse-interface/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.1.214](https://github.com/synapsecns/sanguine/compare/@synapsecns/synapse-interface@0.1.213...@synapsecns/synapse-interface@0.1.214) (2023-12-22) + +**Note:** Version bump only for package @synapsecns/synapse-interface + + + + + ## [0.1.213](https://github.com/synapsecns/sanguine/compare/@synapsecns/synapse-interface@0.1.212...@synapsecns/synapse-interface@0.1.213) (2023-12-22) **Note:** Version bump only for package @synapsecns/synapse-interface diff --git a/packages/synapse-interface/package.json b/packages/synapse-interface/package.json index 6cad913757..d63e177777 100644 --- a/packages/synapse-interface/package.json +++ b/packages/synapse-interface/package.json @@ -1,6 +1,6 @@ { "name": "@synapsecns/synapse-interface", - "version": "0.1.213", + "version": "0.1.214", "private": true, "engines": { "node": ">=16.0.0" @@ -42,7 +42,7 @@ "@reduxjs/toolkit": "^1.9.5", "@rtk-query/graphql-request-base-query": "^2.2.0", "@segment/analytics-next": "^1.53.0", - "@synapsecns/sdk-router": "^0.3.5", + "@synapsecns/sdk-router": "^0.3.6", "@tailwindcss/aspect-ratio": "^0.4.2", "@tailwindcss/forms": "^0.5.3", "@tailwindcss/line-clamp": "^0.4.2", From ef79e78e1dd35fc78dc135cc893978ae4e1d4bcd Mon Sep 17 00:00:00 2001 From: Borislav Grigorov Date: Sat, 23 Dec 2023 04:27:40 -0800 Subject: [PATCH 19/29] Updated explorer indexer for migration (#1685) --- services/explorer/config/indexer/config.go | 2 - .../explorer/consumer/parser/cctpparser.go | 16 +++- .../consumer/parser/tokendata/cache.go | 82 +++++++++++++++++++ .../explorer/static/tokenIDToCoinGeckoID.yaml | 2 + .../static/tokenSymbolToCoinGeckoID.yaml | 2 + .../explorer/static/tokenSymbolToTokenID.yaml | 2 + 6 files changed, 102 insertions(+), 4 deletions(-) diff --git a/services/explorer/config/indexer/config.go b/services/explorer/config/indexer/config.go index d7b5d77422..04d73125cc 100644 --- a/services/explorer/config/indexer/config.go +++ b/services/explorer/config/indexer/config.go @@ -127,8 +127,6 @@ func (c ChainConfig) IsValid() error { switch { case c.ChainID == 0: return fmt.Errorf("chain_id, %w", config.ErrRequiredGlobalField) - case c.RPCURL == "": - return fmt.Errorf("rpc_url, %w", config.ErrRequiredGlobalField) case c.MaxGoroutines == 0: return fmt.Errorf("max_goroutines, %w", config.ErrRequiredGlobalField) } diff --git a/services/explorer/consumer/parser/cctpparser.go b/services/explorer/consumer/parser/cctpparser.go index b1ccaf726d..0e885175fe 100644 --- a/services/explorer/consumer/parser/cctpparser.go +++ b/services/explorer/consumer/parser/cctpparser.go @@ -114,7 +114,19 @@ func (c *CCTPParser) MatureLogs(ctx context.Context, cctpEvent *model.CCTPEvent, return nil, fmt.Errorf("could not get pool token data: %w", err) } decimals := uint8(usdcDecimals) + // Hotfix + if chainID == 8453 &&(cctpEvent.Token == "0x417Ac0e078398C154EdFadD9Ef675d30Be60Af93" || cctpEvent.Token == "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb") { + decimals = 18 + } cctpEvent.TokenSymbol = tokenData.TokenID() + if (cctpEvent.Token == "0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1") { + decimals = 18 + cctpEvent.TokenSymbol = "DAI" + } + if chainID == 10 && (cctpEvent.Token == "0x8c6f28f2F1A3C87F0f938b96d27520d9751ec8d9") { + decimals = 18 + cctpEvent.TokenSymbol = "sUSD" + } cctpEvent.TokenDecimal = &decimals c.applyPriceData(ctx, cctpEvent, usdcCoinGeckoID) @@ -156,13 +168,13 @@ func (c *CCTPParser) applyPriceData(ctx context.Context, cctpEvent *model.CCTPEv } if cctpEvent.Amount != nil { - amountUSD := GetAmountUSD(cctpEvent.Amount, usdcDecimals, tokenPrice) + amountUSD := GetAmountUSD(cctpEvent.Amount, *cctpEvent.TokenDecimal, tokenPrice) if amountUSD != nil { cctpEvent.AmountUSD = *amountUSD } } if cctpEvent.Fee != nil { - cctpEvent.FeeUSD = GetAmountUSD(cctpEvent.Fee, usdcDecimals, tokenPrice) + cctpEvent.FeeUSD = GetAmountUSD(cctpEvent.Fee, *cctpEvent.TokenDecimal, tokenPrice) } } diff --git a/services/explorer/consumer/parser/tokendata/cache.go b/services/explorer/consumer/parser/tokendata/cache.go index bda59631bf..14317ab928 100644 --- a/services/explorer/consumer/parser/tokendata/cache.go +++ b/services/explorer/consumer/parser/tokendata/cache.go @@ -57,6 +57,38 @@ func NewTokenDataService(service fetcher.Service, tokenSymbolToIDs map[string]st // GetTokenData attempts to get token data from the cache otherwise it is fetched from the bridge config. func (t *tokenDataServiceImpl) GetTokenData(ctx context.Context, chainID uint32, token common.Address) (ImmutableTokenData, error) { + // Hotfix for tokens not on bridge config. + // Handle CRVUSDC + if chainID == 8453 && token.String() == "0x417Ac0e078398C154EdFadD9Ef675d30Be60Af93" { + return immutableTokenImpl{ + tokenID: "crvUSD", + decimals: 18, + tokenAddress: "0x417Ac0e078398C154EdFadD9Ef675d30Be60Af93", + }, nil + } + + // Handle USDbC + if chainID == 8453 && token.String() == "0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA" { + return immutableTokenImpl{ + tokenID: "USDbC", + decimals: 6, + tokenAddress: "0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA", + }, nil + } + if chainID == 8453 && token.String() == "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb" { + return immutableTokenImpl{ + tokenID: "DAI", + decimals: 18, + tokenAddress: "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb", + }, nil + } + if chainID == 10 && token.String() == "0x8c6f28f2F1A3C87F0f938b96d27520d9751ec8d9" { + return immutableTokenImpl{ + tokenID: "sUSD", + decimals: 18, + tokenAddress: "0x8c6f28f2F1A3C87F0f938b96d27520d9751ec8d9", + }, nil + } key := fmt.Sprintf("token_%d_%s", chainID, token.Hex()) if data, ok := t.tokenCache.Get(key); ok { return data, nil @@ -74,6 +106,31 @@ func (t *tokenDataServiceImpl) GetTokenData(ctx context.Context, chainID uint32, // GetPoolTokenData attempts to get pool token data from the cache otherwise it is fetched from the erc20 interface for that token. func (t *tokenDataServiceImpl) GetPoolTokenData(ctx context.Context, chainID uint32, token common.Address, swapService fetcher.SwapService) (ImmutableTokenData, error) { + // Hotfix for tokens not on bridge config. + // Handle CRVUSDC + if chainID == 8453 && token.String() == "0x417Ac0e078398C154EdFadD9Ef675d30Be60Af93" { + return immutableTokenImpl{ + tokenID: "crvUSD", + decimals: 18, + tokenAddress: "0x417Ac0e078398C154EdFadD9Ef675d30Be60Af93", + }, nil + } + + // Handle USDbC + if chainID == 8453 && token.String() == "0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA" { + return immutableTokenImpl{ + tokenID: "USDbC", + decimals: 6, + tokenAddress: "0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA", + }, nil + } + if chainID == 8453 && token.String() == "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb" { + return immutableTokenImpl{ + tokenID: "DAI", + decimals: 18, + tokenAddress: "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb", + }, nil + } key := fmt.Sprintf("token_%d_%s", chainID, token.Hex()) if data, ok := t.tokenCache.Get(key); ok { return data, nil @@ -91,6 +148,31 @@ func (t *tokenDataServiceImpl) GetPoolTokenData(ctx context.Context, chainID uin // GetCCTPTokenData attempts to get cctp token data from the cache otherwise it is fetched using the cctp ref. func (t *tokenDataServiceImpl) GetCCTPTokenData(ctx context.Context, chainID uint32, token common.Address, cctpService fetcher.CCTPService) (ImmutableTokenData, error) { + // Hotfix for tokens not on bridge config. + // Handle CRVUSDC + if chainID == 8453 && token.String() == "0x417Ac0e078398C154EdFadD9Ef675d30Be60Af93" { + return immutableTokenImpl{ + tokenID: "crvUSD", + decimals: 18, + tokenAddress: "0x417Ac0e078398C154EdFadD9Ef675d30Be60Af93", + }, nil + } + + // Handle USDbC + if chainID == 8453 && token.String() == "0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA" { + return immutableTokenImpl{ + tokenID: "USDbC", + decimals: 6, + tokenAddress: "0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA", + }, nil + } + if chainID == 8453 && token.String() == "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb" { + return immutableTokenImpl{ + tokenID: "DAI", + decimals: 18, + tokenAddress: "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb", + }, nil + } key := fmt.Sprintf("token_%d_%s", chainID, token.Hex()) if data, ok := t.tokenCache.Get(key); ok { return data, nil diff --git a/services/explorer/static/tokenIDToCoinGeckoID.yaml b/services/explorer/static/tokenIDToCoinGeckoID.yaml index 92d2c7ddf8..5b5e3c46a2 100644 --- a/services/explorer/static/tokenIDToCoinGeckoID.yaml +++ b/services/explorer/static/tokenIDToCoinGeckoID.yaml @@ -36,3 +36,5 @@ PLS: 'plutusdao' NOTE: 'note' PEPE: 'pepe' UNIDX: 'unidex' +USDbC: 'usd-coin' +crvUSD: 'usd-coin' diff --git a/services/explorer/static/tokenSymbolToCoinGeckoID.yaml b/services/explorer/static/tokenSymbolToCoinGeckoID.yaml index e9930a1c19..68efb2a350 100644 --- a/services/explorer/static/tokenSymbolToCoinGeckoID.yaml +++ b/services/explorer/static/tokenSymbolToCoinGeckoID.yaml @@ -36,3 +36,5 @@ nusd: 'usd-coin' m.usdc: 'usd-coin' pepe: 'pepe' unidx: 'unidex' +usdbc: 'usd-coin' +crvusd: 'usd-coin' diff --git a/services/explorer/static/tokenSymbolToTokenID.yaml b/services/explorer/static/tokenSymbolToTokenID.yaml index d9aeb1bc59..ac77800db2 100644 --- a/services/explorer/static/tokenSymbolToTokenID.yaml +++ b/services/explorer/static/tokenSymbolToTokenID.yaml @@ -38,3 +38,5 @@ dai.e: 'DAI' note: 'NOTE' pepe: 'PEPE' unidx: 'UNIDX' +usdbc: 'usd-coin' +crvusd: 'usd-coin' From 66e4c25d694fbb2eba07bdddaa3564b93fe2fbb0 Mon Sep 17 00:00:00 2001 From: trajan0x <83933037+trajan0x@users.noreply.github.com> Date: Sun, 24 Dec 2023 09:35:13 -0500 Subject: [PATCH 20/29] Revert "Updates Submitter w/ Oracle fallback (#1671)" (#1709) This reverts commit 530cf510712abdbd83ebd442ea4c60d6c898a8ca. --- agents/go.mod | 4 +- agents/go.sum | 7 +- agents/types/utils.go | 8 +- contrib/promexporter/config/config.go | 2 +- contrib/terraform-provider-helmproxy/go.mod | 2 +- contrib/terraform-provider-helmproxy/go.sum | 4 +- ethergo/backends/anvil/anvil.go | 89 +++++---- ethergo/backends/base/base.go | 1 - ethergo/backends/simulated/chain.go | 1 - ethergo/chain/chain_impl.go | 1 - ethergo/client/client.go | 30 --- ethergo/go.mod | 2 +- ethergo/go.sum | 3 +- ethergo/submitter/chain_queue.go | 63 ++----- ethergo/submitter/export_test.go | 80 +++++--- ethergo/submitter/submitter.go | 97 +--------- ethergo/submitter/suite_test.go | 14 -- ethergo/submitter/util.go | 99 +++++++++- ethergo/submitter/util_test.go | 187 ++++++++++++++++++- ethergo/util/export_test.go | 38 +--- ethergo/util/transactor.go | 97 ---------- ethergo/util/transactor_test.go | 194 -------------------- services/cctp-relayer/go.mod | 4 +- services/cctp-relayer/go.sum | 7 +- services/omnirpc/go.mod | 4 +- services/omnirpc/go.sum | 7 +- services/scribe/go.mod | 4 +- services/scribe/go.sum | 7 +- services/sinner/go.mod | 4 +- services/sinner/go.sum | 7 +- 30 files changed, 439 insertions(+), 628 deletions(-) delete mode 100644 ethergo/util/transactor.go delete mode 100644 ethergo/util/transactor_test.go diff --git a/agents/go.mod b/agents/go.mod index e2d2956519..b4151a6627 100644 --- a/agents/go.mod +++ b/agents/go.mod @@ -74,7 +74,7 @@ require ( github.com/acomagu/bufpipe v1.0.4 // indirect github.com/agnivade/levenshtein v1.1.1 // indirect github.com/alecthomas/chroma v0.7.1 // indirect - github.com/andybalholm/brotli v1.0.5 // indirect + github.com/andybalholm/brotli v1.0.4 // indirect github.com/aws/aws-sdk-go-v2 v1.18.0 // indirect github.com/aws/aws-sdk-go-v2/config v1.18.21 // indirect github.com/aws/aws-sdk-go-v2/credentials v1.13.20 // indirect @@ -194,7 +194,7 @@ require ( github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a // indirect github.com/keep-network/keep-common v1.7.1-0.20211012131917-7102d7b9c6a0 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect - github.com/klauspost/compress v1.16.0 // indirect + github.com/klauspost/compress v1.15.12 // indirect github.com/klauspost/cpuid/v2 v2.2.4 // indirect github.com/kyokomi/emoji/v2 v2.2.8 // indirect github.com/leodido/go-urn v1.2.4 // indirect diff --git a/agents/go.sum b/agents/go.sum index 0e9b3250a2..2f426f6973 100644 --- a/agents/go.sum +++ b/agents/go.sum @@ -148,9 +148,8 @@ github.com/allegro/bigcache v1.2.1 h1:hg1sY1raCwic3Vnsvje6TT7/pnZba83LeFck5NrFKS github.com/allegro/bigcache v1.2.1/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= +github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY= github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= -github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= -github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= @@ -816,8 +815,8 @@ github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6 github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.15.0/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= -github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= -github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/compress v1.15.12 h1:YClS/PImqYbn+UILDnqxQCZ3RehC9N318SU3kElDUEM= +github.com/klauspost/compress v1.15.12/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= diff --git a/agents/types/utils.go b/agents/types/utils.go index 1213d68fb0..0c789f48b6 100644 --- a/agents/types/utils.go +++ b/agents/types/utils.go @@ -3,7 +3,6 @@ package types import ( "context" "fmt" - "math/big" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" @@ -28,12 +27,9 @@ func signEncoder(ctx context.Context, signer signer.Signer, encoder Encoder, sal } // Sign the message. - sig, err := signer.SignMessage(ctx, core.BytesToSlice(hashedDigest), false) + signature, err := signer.SignMessage(ctx, core.BytesToSlice(hashedDigest), false) if err != nil { return nil, nil, common.Hash{}, fmt.Errorf("could not sign: %w", err) } - - sig = NewSignature(new(big.Int).Add(big.NewInt(27), sig.V()), sig.R(), sig.S()) - - return sig, encoded, hashedDigest, nil + return signature, encoded, hashedDigest, nil } diff --git a/contrib/promexporter/config/config.go b/contrib/promexporter/config/config.go index 3e32546a33..bfd938e83e 100644 --- a/contrib/promexporter/config/config.go +++ b/contrib/promexporter/config/config.go @@ -99,7 +99,7 @@ func DecodeConfig(filePath string) (_ Config, err error) { Name: "messenger", }, { - Address: "0x49357ba0Ef3a8daC25903472eEe45C41221D4F9a", + Address: "0x0a1e1d0eb6a1cef79e46f0e2d35b7bf2e958a26a", Name: "cctp", ChainIDs: types.ToInts(types.ETH, types.ARBITRUM, types.AVALANCHE, types.OPTIMISM), }, diff --git a/contrib/terraform-provider-helmproxy/go.mod b/contrib/terraform-provider-helmproxy/go.mod index 96caf9d0e4..1dda73cba5 100644 --- a/contrib/terraform-provider-helmproxy/go.mod +++ b/contrib/terraform-provider-helmproxy/go.mod @@ -127,7 +127,7 @@ require ( github.com/json-iterator/go v1.1.12 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect github.com/kirsle/configdir v0.0.0-20170128060238-e45d2f54772f // indirect - github.com/klauspost/compress v1.16.0 // indirect + github.com/klauspost/compress v1.15.12 // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect diff --git a/contrib/terraform-provider-helmproxy/go.sum b/contrib/terraform-provider-helmproxy/go.sum index d646b52ae2..2c53448f70 100644 --- a/contrib/terraform-provider-helmproxy/go.sum +++ b/contrib/terraform-provider-helmproxy/go.sum @@ -764,8 +764,8 @@ github.com/kisielk/errcheck v1.6.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.10.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.0/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= -github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= -github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/compress v1.15.12 h1:YClS/PImqYbn+UILDnqxQCZ3RehC9N318SU3kElDUEM= +github.com/klauspost/compress v1.15.12/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= diff --git a/ethergo/backends/anvil/anvil.go b/ethergo/backends/anvil/anvil.go index 89f08a3b24..f12803f1d5 100644 --- a/ethergo/backends/anvil/anvil.go +++ b/ethergo/backends/anvil/anvil.go @@ -135,7 +135,6 @@ func NewAnvilBackend(ctx context.Context, t *testing.T, args *OptionBuilder) *Ba return fmt.Errorf("failed to connect") } - // nolint: staticcheck res, err := rpcClient.ChainID(ctx) if err != nil { return fmt.Errorf("failed to get chain id: %w", err) @@ -264,7 +263,7 @@ func setupOtterscan(ctx context.Context, tb testing.TB, pool *dockertest.Pool, a var logger = log.Logger("anvil-docker") // storeWallets stores preseeded wallets w/ balances. -func (b *Backend) storeWallets(args *OptionBuilder) error { +func (f *Backend) storeWallets(args *OptionBuilder) error { derivationPath := args.GetDerivationPath() derivIter := accounts.DefaultIterator(derivationPath) maxAccounts := args.GetAccounts() @@ -276,7 +275,7 @@ func (b *Backend) storeWallets(args *OptionBuilder) error { return fmt.Errorf("could not get seed phrase: %w", err) } - b.store.Store(walletToKey(b.Backend.T(), wall)) + f.store.Store(walletToKey(f.Backend.T(), wall)) } return nil } @@ -300,31 +299,31 @@ func walletToKey(tb testing.TB, wall wallet.Wallet) *keystore.Key { } // ChainConfig gets the chain config. -func (b *Backend) ChainConfig() *params.ChainConfig { - return b.chainConfig +func (f *Backend) ChainConfig() *params.ChainConfig { + return f.chainConfig } // Signer gets the signer for the chain. -func (b *Backend) Signer() types.Signer { - latestBlock, err := b.BlockNumber(b.Context()) - require.Nil(b.T(), err) +func (f *Backend) Signer() types.Signer { + latestBlock, err := f.BlockNumber(f.Context()) + require.Nil(f.T(), err) - return types.MakeSigner(b.ChainConfig(), new(big.Int).SetUint64(latestBlock)) + return types.MakeSigner(f.ChainConfig(), new(big.Int).SetUint64(latestBlock)) } // FundAccount funds an account with the given amount. -func (b *Backend) FundAccount(ctx context.Context, address common.Address, amount big.Int) { - ctx, cancel := onecontext.Merge(ctx, b.Context()) +func (f *Backend) FundAccount(ctx context.Context, address common.Address, amount big.Int) { + ctx, cancel := onecontext.Merge(ctx, f.Context()) defer cancel() - anvilClient, err := Dial(ctx, b.RPCAddress()) - require.Nilf(b.T(), err, "failed to dial anvil client on chain %d: %v", b.GetChainID(), err) + anvilClient, err := Dial(ctx, f.RPCAddress()) + require.Nilf(f.T(), err, "failed to dial anvil client on chain %d: %v", f.GetChainID(), err) - unlocker := b.fundingMux.Lock(address) + unlocker := f.fundingMux.Lock(address) defer unlocker.Unlock() - prevBalance, err := b.Backend.BalanceAt(ctx, address, nil) - require.Nil(b.T(), err) + prevBalance, err := f.Backend.BalanceAt(ctx, address, nil) + require.Nil(f.T(), err) newBal := new(big.Int).Add(prevBalance, &amount) @@ -339,13 +338,13 @@ func (b *Backend) FundAccount(ctx context.Context, address common.Address, amoun // TODO: this may cause issues when newBal overflows uint64 err = anvilClient.SetBalance(ctx, address, newBal.Uint64()) - require.Nil(b.T(), err) + require.Nil(f.T(), err) } // WaitForConfirmation checks confirmation if the transaction is signed. // nolint: cyclop -func (b *Backend) WaitForConfirmation(ctx context.Context, tx *types.Transaction) { - require.NotNil(b.T(), tx, "tx is nil") +func (f *Backend) WaitForConfirmation(ctx context.Context, tx *types.Transaction) { + require.NotNil(f.T(), tx, "tx is nil") v, r, s := tx.RawSignatureValues() isUnsigned := isZero(v) && isZero(r) && isZero(s) if isUnsigned { @@ -355,7 +354,7 @@ func (b *Backend) WaitForConfirmation(ctx context.Context, tx *types.Transaction return } - b.Backend.WaitForConfirmation(ctx, tx) + f.Backend.WaitForConfirmation(ctx, tx) } func isZero(val *big.Int) bool { @@ -363,40 +362,40 @@ func isZero(val *big.Int) bool { } // GetFundedAccount gets a funded account. -func (b *Backend) GetFundedAccount(ctx context.Context, requestBalance *big.Int) *keystore.Key { - key := b.MockAccount() +func (f *Backend) GetFundedAccount(ctx context.Context, requestBalance *big.Int) *keystore.Key { + key := f.MockAccount() - b.store.Store(key) + f.store.Store(key) - b.FundAccount(ctx, key.Address, *requestBalance) + f.FundAccount(ctx, key.Address, *requestBalance) return key } // GetTxContext gets the tx context for the given address. // TODO: dedupe w/ geth. -func (b *Backend) GetTxContext(ctx context.Context, address *common.Address) (res backends.AuthType) { - ctx, cancel := onecontext.Merge(ctx, b.Context()) +func (f *Backend) GetTxContext(ctx context.Context, address *common.Address) (res backends.AuthType) { + ctx, cancel := onecontext.Merge(ctx, f.Context()) defer cancel() var acct *keystore.Key // TODO handle storing accounts to conform to get tx context if address != nil { - acct = b.store.GetAccount(*address) + acct = f.store.GetAccount(*address) if acct == nil { - b.T().Errorf("could not get account %s", address.String()) + f.T().Errorf("could not get account %s", address.String()) return res } } else { - acct = b.GetFundedAccount(ctx, new(big.Int).SetUint64(math.MaxUint64)) - b.store.Store(acct) + acct = f.GetFundedAccount(ctx, new(big.Int).SetUint64(math.MaxUint64)) + f.store.Store(acct) } - auth, err := b.NewKeyedTransactorFromKey(acct.PrivateKey) - require.Nilf(b.T(), err, "could not get transactor for chain %d: %v", b.GetChainID(), err) + auth, err := f.NewKeyedTransactorFromKey(acct.PrivateKey) + require.Nilf(f.T(), err, "could not get transactor for chain %d: %v", f.GetChainID(), err) - auth.GasPrice, err = b.SuggestGasPrice(ctx) - require.Nilf(b.T(), err, "could not get gas price for chain %d: %v", b.GetChainID(), err) + auth.GasPrice, err = f.SuggestGasPrice(ctx) + require.Nilf(f.T(), err, "could not get gas price for chain %d: %v", f.GetChainID(), err) auth.GasLimit = gasLimit @@ -413,21 +412,21 @@ func (b *Backend) GetTxContext(ctx context.Context, address *common.Address) (re // in the meantime, this may cause race conditions. // // We also print a warning message to the console as an added precaution. -func (b *Backend) ImpersonateAccount(ctx context.Context, address common.Address, transact func(opts *bind.TransactOpts) *types.Transaction) error { - b.impersonationMux.Lock() - defer b.impersonationMux.Unlock() +func (f *Backend) ImpersonateAccount(ctx context.Context, address common.Address, transact func(opts *bind.TransactOpts) *types.Transaction) error { + f.impersonationMux.Lock() + defer f.impersonationMux.Unlock() - b.warnImpersonation() + f.warnImpersonation() - anvilClient, err := Dial(ctx, b.RPCAddress()) - require.Nilf(b.T(), err, "could not dial anvil client rpc at %s for chain %d: %v", b.RPCAddress(), b.GetChainID(), err) + anvilClient, err := Dial(ctx, f.RPCAddress()) + require.Nilf(f.T(), err, "could not dial anvil client rpc at %s for chain %d: %v", f.RPCAddress(), f.GetChainID(), err) err = anvilClient.ImpersonateAccount(ctx, address) - require.Nilf(b.T(), err, "could not impersonate account %s for chain %d: %v", address.String(), b.GetChainID(), err) + require.Nilf(f.T(), err, "could not impersonate account %s for chain %d: %v", address.String(), f.GetChainID(), err) defer func() { err = anvilClient.StopImpersonatingAccount(ctx, address) - require.Nilf(b.T(), err, "could not stop impersonating account %s for chain %d: %v", address.String(), b.GetChainID(), err) + require.Nilf(f.T(), err, "could not stop impersonating account %s for chain %d: %v", address.String(), f.GetChainID(), err) }() tx := transact(&bind.TransactOpts{ @@ -440,14 +439,14 @@ func (b *Backend) ImpersonateAccount(ctx context.Context, address common.Address // TODO: test both legacy and dynamic tx types err = anvilClient.SendUnsignedTransaction(ctx, address, tx) - require.Nilf(b.T(), err, "could not send unsigned transaction for chain %d: %v from %s", b.GetChainID(), err, address.String()) + require.Nilf(f.T(), err, "could not send unsigned transaction for chain %d: %v from %s", f.GetChainID(), err, address.String()) return nil } -func (b *Backend) warnImpersonation() { +func (f *Backend) warnImpersonation() { warnImpersonationOnce.Do(func() { - b.T().Logf(` + f.T().Logf(` Using Account Impersonation. WARNING: This cannot be called concurrently with other impersonation calls. Please make sure your callers are concurrency safe against account impersonation. diff --git a/ethergo/backends/base/base.go b/ethergo/backends/base/base.go index e206e152a1..fc3ca85857 100644 --- a/ethergo/backends/base/base.go +++ b/ethergo/backends/base/base.go @@ -103,7 +103,6 @@ func (b *Backend) EnableTenderly() bool { } // Client fetches an eth client fro the backend. -// nolint: staticcheck func (b *Backend) Client() client.EVMClient { return b.Chain } diff --git a/ethergo/backends/simulated/chain.go b/ethergo/backends/simulated/chain.go index 20ff09ba17..12ccd7b516 100644 --- a/ethergo/backends/simulated/chain.go +++ b/ethergo/backends/simulated/chain.go @@ -134,5 +134,4 @@ func (s Client) SuggestGasPrice(ctx context.Context) (gasPrice *big.Int, err err return big.NewInt(0).Add(estimatedPrice, baseFee), nil } -// nolint: staticcheck var _ client.EVMClient = &Client{} diff --git a/ethergo/chain/chain_impl.go b/ethergo/chain/chain_impl.go index 7d5f62638c..1f8a5c9229 100644 --- a/ethergo/chain/chain_impl.go +++ b/ethergo/chain/chain_impl.go @@ -140,7 +140,6 @@ func NewFromURL(ctx context.Context, url string) (Chain, error) { } // NewFromClient gets a chain from client. -// nolint: staticcheck func NewFromClient(ctx context.Context, config *client.Config, evmClient client.EVMClient) (chain Chain, err error) { rpcURL := "" if len(config.RPCUrl) > 0 { diff --git a/ethergo/client/client.go b/ethergo/client/client.go index dce5454319..44ff0a9d6b 100644 --- a/ethergo/client/client.go +++ b/ethergo/client/client.go @@ -2,8 +2,6 @@ package client import ( "context" - "encoding/json" - "errors" "fmt" "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi/bind" @@ -98,41 +96,13 @@ func (c *clientImpl) getW3Client() *w3.Client { // BatchWithContext batches multiple w3 calls. func (c *clientImpl) BatchWithContext(ctx context.Context, calls ...w3types.Caller) (err error) { - // Do not create an even if there are no calls - if len(calls) == 0 { - return nil - } - ctx, span := c.tracing.Tracer().Start(ctx, batchAttribute) span.SetAttributes(parseCalls(calls)) span.SetAttributes(attribute.String(endpointAttribute, c.endpoint)) defer func() { - if errors.Is(err, w3.CallErrors{}) { - var batchErr w3.CallErrors - _ = errors.As(err, &batchErr) - for i, callErr := range batchErr { - rawReq, err := calls[i].CreateRequest() - // this already happened, so it can't be failing now. - // just error. - if err != nil { - fmt.Println("could not create request: this should never happen", err) - continue - } - - params, err := json.Marshal(rawReq.Args) - if err != nil { - fmt.Println("could not marshal params: this should never happen", err) - continue - } - span.RecordError(callErr, trace.WithAttributes(attribute.String("method", rawReq.Method), attribute.String("params", string(params)))) - } - metrics.EndSpan(span) - return - } metrics.EndSpanWithErr(span, err) }() - //nolint: wrapcheck return c.getW3Client().CallCtx(ctx, calls...) } diff --git a/ethergo/go.mod b/ethergo/go.mod index 7ae67148e3..52ccc59ede 100644 --- a/ethergo/go.mod +++ b/ethergo/go.mod @@ -117,7 +117,7 @@ require ( github.com/docker/docker v20.10.23+incompatible // indirect github.com/docker/go-connections v0.4.0 // indirect github.com/docker/go-units v0.5.0 // indirect - github.com/dustin/go-humanize v1.0.1 // indirect + github.com/dustin/go-humanize v1.0.0 // indirect github.com/edsrzf/mmap-go v1.0.0 // indirect github.com/emirpasic/gods v1.18.1 // indirect github.com/fatih/color v1.13.0 // indirect diff --git a/ethergo/go.sum b/ethergo/go.sum index 6e02f1d93d..dec7a90b79 100644 --- a/ethergo/go.sum +++ b/ethergo/go.sum @@ -329,9 +329,8 @@ github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4 github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dop251/goja v0.0.0-20200219165308-d1232e640a87/go.mod h1:Mw6PkjjMXWbTj+nnj4s3QPXq1jaT0s5pC0iFD4+BOAA= github.com/dop251/goja v0.0.0-20200721192441-a695b0cdd498/go.mod h1:Mw6PkjjMXWbTj+nnj4s3QPXq1jaT0s5pC0iFD4+BOAA= +github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= -github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/dvyukov/go-fuzz v0.0.0-20200318091601-be3528f3a813/go.mod h1:11Gm+ccJnvAhCNLlf5+cS9KjtbaD5I5zaZpFMsTHWTw= github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= diff --git a/ethergo/submitter/chain_queue.go b/ethergo/submitter/chain_queue.go index fd2d5a1e16..503d061315 100644 --- a/ethergo/submitter/chain_queue.go +++ b/ethergo/submitter/chain_queue.go @@ -2,18 +2,15 @@ package submitter import ( "context" - "errors" "fmt" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/lmittmann/w3" "github.com/lmittmann/w3/module/eth" "github.com/lmittmann/w3/w3types" "github.com/synapsecns/sanguine/core" "github.com/synapsecns/sanguine/core/metrics" "github.com/synapsecns/sanguine/ethergo/client" "github.com/synapsecns/sanguine/ethergo/submitter/db" - "github.com/synapsecns/sanguine/ethergo/util" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" "golang.org/x/sync/errgroup" @@ -47,10 +44,6 @@ func (c *chainQueue) chainIDInt() int { } func (t *txSubmitterImpl) chainPendingQueue(parentCtx context.Context, chainID *big.Int, txes []db.TX) (err error) { - if len(txes) == 0 { - return nil - } - ctx, span := t.metrics.Tracer().Start(parentCtx, "submitter.ChainQueue") defer func() { metrics.EndSpanWithErr(span, err) @@ -92,41 +85,30 @@ func (t *txSubmitterImpl) chainPendingQueue(parentCtx context.Context, chainID * cq.bumpTX(gCtx, tx) } - cq.updateOldTxStatuses(gCtx) + cq.updateOldTxStatuses(gCtx) err = cq.g.Wait() if err != nil { return fmt.Errorf("error in chainPendingQueue: %w", err) } - cq.storeAndSubmit(ctx, span) - - return nil -} - -// storeAndSubmit stores the txes in the database and submits them to the chain. -func (c *chainQueue) storeAndSubmit(ctx context.Context, parentSpan trace.Span) { - sort.Slice(c.reprocessQueue, func(i, j int) bool { - return c.reprocessQueue[i].Nonce() < c.reprocessQueue[j].Nonce() + sort.Slice(cq.reprocessQueue, func(i, j int) bool { + return cq.reprocessQueue[i].Nonce() < cq.reprocessQueue[j].Nonce() }) - calls := make([]w3types.Caller, len(c.reprocessQueue)) - txHashes := make([]common.Hash, len(c.reprocessQueue)) - spanners := make([]trace.Span, len(c.reprocessQueue)) - - for i, tx := range c.reprocessQueue { - _, span := c.metrics.Tracer().Start(ctx, "chainPendingQueue.submit", trace.WithAttributes(util.TxToAttributes(tx.Transaction)...)) - spanners[i] = span - defer func() { - // in case this span doesn't get ended automatically below, end it here. - if span.IsRecording() { - metrics.EndSpan(span) - } - }() - + calls := make([]w3types.Caller, len(cq.reprocessQueue)) + txHashes := make([]common.Hash, len(cq.reprocessQueue)) + for i, tx := range cq.reprocessQueue { calls[i] = eth.SendTx(tx.Transaction).Returns(&txHashes[i]) } + cq.storeAndSubmit(ctx, calls, span) + + return nil +} + +// storeAndSubmit stores the txes in the database and submits them to the chain. +func (c *chainQueue) storeAndSubmit(ctx context.Context, calls []w3types.Caller, span trace.Span) { var wg sync.WaitGroup wg.Add(2) @@ -136,38 +118,25 @@ func (c *chainQueue) storeAndSubmit(ctx context.Context, parentSpan trace.Span) defer wg.Done() err := c.db.PutTXS(storeCtx, c.reprocessQueue...) if err != nil { - parentSpan.AddEvent("could not store txes", trace.WithAttributes(attribute.String("error", err.Error()))) + span.AddEvent("could not store txes", trace.WithAttributes(attribute.String("error", err.Error()))) } }() go func() { defer wg.Done() err := c.client.BatchWithContext(ctx, calls...) - - // Optimistically store all transactions as pending in the first goroutine. - // The call is made concurrently in the second goroutine. - // If the second goroutine finishes first, updating the status, - // there's no need to store them as pending, hence the context is canceled early. cancelStore() for i := range c.reprocessQueue { - span := spanners[i] if err != nil { c.reprocessQueue[i].Status = db.FailedSubmit - //nolint: errorlint, forcetypeassert - if callErrs, ok := err.(w3.CallErrors); ok && len(callErrs) > i { - span.RecordError(errors.New(callErrs[i].Error())) - } else if err != nil { - span.RecordError(err) - } } else { c.reprocessQueue[i].Status = db.Submitted } - span.End() } err = c.db.PutTXS(ctx, c.reprocessQueue...) if err != nil { - parentSpan.AddEvent("could not store txes", trace.WithAttributes(attribute.String("error", err.Error()))) + span.AddEvent("could not store txes", trace.WithAttributes(attribute.String("error", err.Error()))) } }() wg.Wait() @@ -240,7 +209,7 @@ func (c *chainQueue) bumpTX(parentCtx context.Context, ogTx db.TX) { return fmt.Errorf("could not sign tx: %w", err) } - span.AddEvent("add to reprocess queue", trace.WithAttributes(util.TxToAttributes(tx)...)) + span.AddEvent("add to reprocess queue", trace.WithAttributes(txToAttributes(tx)...)) c.addToReprocessQueue(db.TX{ Transaction: tx, diff --git a/ethergo/submitter/export_test.go b/ethergo/submitter/export_test.go index 7b768a32d3..5cdcf3142d 100644 --- a/ethergo/submitter/export_test.go +++ b/ethergo/submitter/export_test.go @@ -12,6 +12,65 @@ import ( "github.com/synapsecns/sanguine/ethergo/signer/signer" "github.com/synapsecns/sanguine/ethergo/submitter/config" "github.com/synapsecns/sanguine/ethergo/submitter/db" + "go.opentelemetry.io/otel/attribute" +) + +// CopyTransactOpts exports copyTransactOpts for testing. +func CopyTransactOpts(opts *bind.TransactOpts) *bind.TransactOpts { + return copyTransactOpts(opts) +} + +// NullFieldAttribute is a constant used to test the null field attribute. +// it exports the underlying constant for testing. +const NullFieldAttribute = nullFieldAttribute + +func AddressPtrToString(address *common.Address) string { + return addressPtrToString(address) +} + +// BigPtrToString converts a big.Int pointer to a string. +func BigPtrToString(num *big.Int) string { + return bigPtrToString(num) +} + +// TxToAttributes exports txToAttributes for testing. +func TxToAttributes(transaction *types.Transaction) []attribute.KeyValue { + return txToAttributes(transaction) +} + +// SortTxes exports sortTxesByChainID for testing. +func SortTxes(txs []db.TX) map[uint64][]db.TX { + return sortTxesByChainID(txs) +} + +// GroupTxesByNonce exports groupTxesByNonce for testing. +func GroupTxesByNonce(txs []db.TX) map[uint64][]db.TX { + return groupTxesByNonce(txs) +} + +const ( + // HashAttr exports hashAttr for testing. + HashAttr = hashAttr + // FromAttr exports fromAttr for testing. + FromAttr = fromAttr + // ToAttr exports toAttr for testing. + ToAttr = toAttr + // DataAttr exports dataAttr for testing. + DataAttr = dataAttr + // ValueAttr exports valueAttr for testing. + ValueAttr = valueAttr + // NonceAttr exports nonceAttr for testing. + NonceAttr = nonceAttr + // GasLimitAttr exports gasLimitAttr for testing. + GasLimitAttr = gasLimitAttr + // ChainIDAttr exports chainIDAttr for testing. + ChainIDAttr = chainIDAttr + // GasPriceAttr exports gasPriceAttr for testing. + GasPriceAttr = gasPriceAttr + // GasFeeCapAttr exports gasFeeCapAttr for testing. + GasFeeCapAttr = gasFeeCapAttr + // GasTipCapAttr exports gasTipCapAttr for testing. + GasTipCapAttr = gasTipCapAttr ) // NewTestTransactionSubmitter wraps TestTransactionSubmitter in a TransactionSubmitter interface. @@ -55,24 +114,3 @@ func (t *txSubmitterImpl) GetNonce(parentCtx context.Context, chainID *big.Int, func (t *txSubmitterImpl) CheckAndSetConfirmation(ctx context.Context, chainClient client.EVM, txes []db.TX) error { return t.checkAndSetConfirmation(ctx, chainClient, txes) } - -// SortTxes exports sortTxesByChainID for testing. -func SortTxes(txs []db.TX) map[uint64][]db.TX { - return sortTxesByChainID(txs) -} - -// GroupTxesByNonce exports groupTxesByNonce for testing. -func GroupTxesByNonce(txs []db.TX) map[uint64][]db.TX { - return groupTxesByNonce(txs) -} - -// SetForceNoFallback exports setForceNoFallback for testing. -func SetForceNoFallback(val bool) { - forceNoFallbackIfZero = val -} - -// export for testing -// Warning! Changing this value will not change the underlying value! -// htis is exported for testing to allow a return to underlying value after the test -// TODO: consider doing a SetForTest -var ForceNoFallbackIfZero = forceNoFallbackIfZero diff --git a/ethergo/submitter/submitter.go b/ethergo/submitter/submitter.go index 11af4adc5d..03b23291c8 100644 --- a/ethergo/submitter/submitter.go +++ b/ethergo/submitter/submitter.go @@ -4,10 +4,7 @@ import ( "context" "errors" "fmt" - "github.com/ethereum/go-ethereum/params" "github.com/puzpuzpuz/xsync/v2" - "github.com/synapsecns/sanguine/ethergo/chain/gas/backend" - "github.com/synapsecns/sanguine/ethergo/chain/gas/london" "math" "math/big" "reflect" @@ -216,7 +213,7 @@ func (t *txSubmitterImpl) getNonce(parentCtx context.Context, chainID *big.Int, func (t *txSubmitterImpl) storeTX(ctx context.Context, tx *types.Transaction, status db.Status) (err error) { ctx, span := t.metrics.Tracer().Start(ctx, "submitter.StoreTX", trace.WithAttributes( - append(util.TxToAttributes(tx), attribute.String("status", status.String()))...)) + append(txToAttributes(tx), attribute.String("status", status.String()))...)) defer func() { metrics.EndSpanWithErr(span, err) @@ -274,7 +271,7 @@ func (t *txSubmitterImpl) SubmitTransaction(parentCtx context.Context, chainID * } // then we copy the transactor, this is the one we'll modify w/ no send. - transactor := util.CopyTransactOpts(parentTransactor) + transactor := copyTransactOpts(parentTransactor) var locker mapmutex.Unlocker @@ -365,8 +362,7 @@ func (t *txSubmitterImpl) setGasPrice(ctx context.Context, client client.EVM, if t.config.SupportsEIP1559(int(bigChainID.Uint64())) { transactor.GasFeeCap = t.config.GetMaxGasPrice(chainID) - // only use fallback if no previous tx - transactor.GasTipCap, err = t.SuggestGasTipCap(ctx, client, chainID, prevTx != nil) + transactor.GasTipCap, err = client.SuggestGasTipCap(ctx) if err != nil { return fmt.Errorf("could not get gas tip cap: %w", err) } @@ -423,7 +419,7 @@ func (t *txSubmitterImpl) getGasBlock(ctx context.Context, chainClient client.EV if ok { span.AddEvent("could not get gas block; using cached value", trace.WithAttributes( attribute.String("error", err.Error()), - attribute.String("blockNumber", util.BigPtrToString(gasBlock.Number)), + attribute.String("blockNumber", bigPtrToString(gasBlock.Number)), )) } else { return nil, fmt.Errorf("could not get gas block: %w", err) @@ -471,89 +467,4 @@ func (t *txSubmitterImpl) getGasEstimate(ctx context.Context, chainClient client return gasEstimate, nil } -// forceNoFallbackIfZero is used to force no fallback if the tip cap is 0. -var forceNoFallbackIfZero = false - -// TODO: test oracle fallback. -func (t *txSubmitterImpl) SuggestGasTipCap(ctx context.Context, client client.EVM, chainID int, fallbackIfZero bool) (tipCap *big.Int, err error) { - tipCap, err = client.SuggestGasTipCap(ctx) - if err != nil { - return nil, fmt.Errorf("could not get gas tip cap: %w", err) - } - - // note: these ifs can be combined, but I've found the largic hard to parse if they are. - // if tip cap is not zero return - if big.NewInt(0).Cmp(tipCap) != 0 { - return tipCap, nil - } - - // past this point tip cap is 0. - - // if we should force no fallback, return - // this is set for testing. - if forceNoFallbackIfZero { - return tipCap, nil - } - - // if we shouldn't fallback, return - if !fallbackIfZero { - return tipCap, nil - } - - blockHeight, err := client.BlockNumber(ctx) - if err != nil { - return nil, fmt.Errorf("could not get block number: %w", err) - } - - // if on the other hand, fee is 0 we should fallback to our pricer - oracleConfig := gas.GetConfig() - oracleConfig.MaxPrice = core.CopyBigInt(t.config.GetMaxGasPrice(chainID)) - - feeOracle := london.NewFeeOracle(wrappedLondonClient{client, chainID}, blockHeight, oracleConfig) - tipCap, err = feeOracle.SuggestTipCap(ctx) - if err != nil { - return nil, fmt.Errorf("could not get tip cap: %w", err) - } - return tipCap, nil -} - -type wrappedLondonClient struct { - client.EVM - chainID int -} - -// ChainConfig is a fake chain config. -// since wrapped client is only used for makeSigner -// and on london, we just enable everything. -func (w wrappedLondonClient) ChainConfig() *params.ChainConfig { - return ¶ms.ChainConfig{ - ChainID: big.NewInt(int64(w.chainID)), - HomesteadBlock: big.NewInt(0), - DAOForkBlock: big.NewInt(0), - DAOForkSupport: false, - EIP150Block: big.NewInt(0), - EIP150Hash: common.Hash{}, - EIP155Block: big.NewInt(0), - EIP158Block: big.NewInt(0), - ByzantiumBlock: big.NewInt(0), - ConstantinopleBlock: big.NewInt(0), - PetersburgBlock: big.NewInt(0), - IstanbulBlock: big.NewInt(0), - MuirGlacierBlock: big.NewInt(0), - BerlinBlock: big.NewInt(0), - LondonBlock: big.NewInt(0), - ArrowGlacierBlock: big.NewInt(0), - GrayGlacierBlock: big.NewInt(0), - MergeNetsplitBlock: big.NewInt(0), - ShanghaiBlock: big.NewInt(0), - CancunBlock: big.NewInt(0), - TerminalTotalDifficulty: big.NewInt(0), - TerminalTotalDifficultyPassed: false, - Ethash: nil, - Clique: nil, - } -} - -var _ backend.OracleBackendChain = &wrappedLondonClient{} - var _ TransactionSubmitter = &txSubmitterImpl{} diff --git a/ethergo/submitter/suite_test.go b/ethergo/submitter/suite_test.go index 01727e1f1e..d49f25ba8a 100644 --- a/ethergo/submitter/suite_test.go +++ b/ethergo/submitter/suite_test.go @@ -119,14 +119,6 @@ func (s *SubmitterSuite) SetupSuite() { }(i, chainID) } wg.Wait() - - // fallback is currently untested. For now we disable it in tests. - // TODO: this should be fixed, or ideally, fallback can be removed. - og := submitter.ForceNoFallbackIfZero - submitter.SetForceNoFallback(true) - s.T().Cleanup(func() { - submitter.SetForceNoFallback(og) - }) } // SetupTest sets up the signer and funds the account with 10 eth on each backend. @@ -209,12 +201,6 @@ func (t *TXSubmitterDBSuite) SetupSuite() { var err error t.metrics, err = metrics.NewByType(t.GetSuiteContext(), buildInfo, metricsHandler) t.Require().NoError(err) - - og := submitter.ForceNoFallbackIfZero - submitter.SetForceNoFallback(true) - t.T().Cleanup(func() { - submitter.SetForceNoFallback(og) - }) } func (t *TXSubmitterDBSuite) SetupTest() { diff --git a/ethergo/submitter/util.go b/ethergo/submitter/util.go index 2ecdf08e5b..1df2e13ff8 100644 --- a/ethergo/submitter/util.go +++ b/ethergo/submitter/util.go @@ -1,15 +1,108 @@ package submitter import ( + "fmt" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/synapsecns/sanguine/core" "github.com/synapsecns/sanguine/ethergo/chain/gas" "github.com/synapsecns/sanguine/ethergo/submitter/db" + "github.com/synapsecns/sanguine/ethergo/util" + "go.opentelemetry.io/otel/attribute" + "math/big" "sort" ) -// sortTxesByChainID sorts a slice of transactions by chain ID and then by nonce within each chain ID group. -func sortTxesByChainID(txs []db.TX) map[uint64][]db.TX { - txesByChainID := make(map[uint64][]db.TX) // put the transactions in a map by chain id +// copyTransactOpts creates a deep copy of the given TransactOpts struct +// with big ints wrapped in core.CopyBigInt(). +func copyTransactOpts(opts *bind.TransactOpts) *bind.TransactOpts { + copyOpts := &bind.TransactOpts{ + From: opts.From, + Nonce: core.CopyBigInt(opts.Nonce), + Signer: opts.Signer, + Value: core.CopyBigInt(opts.Value), + GasPrice: core.CopyBigInt(opts.GasPrice), + GasFeeCap: core.CopyBigInt(opts.GasFeeCap), + GasTipCap: core.CopyBigInt(opts.GasTipCap), + GasLimit: opts.GasLimit, + Context: opts.Context, + NoSend: opts.NoSend, + } + return copyOpts +} + +const ( + hashAttr = "tx.Hash" + fromAttr = "tx.From" + toAttr = "tx.To" + dataAttr = "tx.Data" + valueAttr = "tx.Value" + nonceAttr = "tx.Nonce" + gasLimitAttr = "tx.GasLimit" + chainIDAttr = "tx.ChainID" + gasPriceAttr = "tx.GasPrice" + gasFeeCapAttr = "tx.GasFeeCap" + gasTipCapAttr = "tx.GasTipCap" +) + +// txToAttributes converts a transaction to a slice of attribute.KeyValue. +func txToAttributes(transaction *types.Transaction) []attribute.KeyValue { + var from string + call, err := util.TxToCall(transaction) + if err != nil { + from = fmt.Sprintf("could not be detected: %v", err) + } else { + from = call.From.Hex() + } + var attributes = []attribute.KeyValue{ + attribute.String(hashAttr, transaction.Hash().Hex()), + attribute.String(fromAttr, from), + attribute.String(toAttr, addressPtrToString(transaction.To())), + attribute.String(dataAttr, fmt.Sprintf("%x", transaction.Data())), + attribute.String(valueAttr, bigPtrToString(transaction.Value())), + // TODO: this could be downcast to int64, but it's unclear how we should handle overflows. + // since this is only for tracing, we can probably ignore it for now. + attribute.Int64(nonceAttr, int64(transaction.Nonce())), + attribute.Int64(gasLimitAttr, int64(transaction.Gas())), + attribute.String(chainIDAttr, bigPtrToString(transaction.ChainId())), + } + + if transaction.Type() == types.LegacyTxType && transaction.GasPrice() != nil { + attributes = append(attributes, attribute.String(gasPriceAttr, bigPtrToString(transaction.GasPrice()))) + } + + if transaction.Type() == types.DynamicFeeTxType && transaction.GasFeeCap() != nil { + attributes = append(attributes, attribute.String(gasFeeCapAttr, bigPtrToString(transaction.GasFeeCap()))) + } + if transaction.Type() == types.DynamicFeeTxType && transaction.GasTipCap() != nil { + attributes = append(attributes, attribute.String(gasTipCapAttr, bigPtrToString(transaction.GasTipCap()))) + } + + return attributes +} + +const nullFieldAttribute = "null" + +func addressPtrToString(address *common.Address) string { + if address == nil { + return nullFieldAttribute + } + return address.Hex() +} + +func bigPtrToString(num *big.Int) string { + if num == nil { + return nullFieldAttribute + } + return num.String() +} + +// sortTxesByChainID sorts a slice of transactions by nonce. +func sortTxesByChainID(txs []db.TX) map[uint64][]db.TX { + txesByChainID := make(map[uint64][]db.TX) + // put the transactions in a map by chain id for _, t := range txs { txesByChainID[t.ChainId().Uint64()] = append(txesByChainID[t.ChainId().Uint64()], t) } diff --git a/ethergo/submitter/util_test.go b/ethergo/submitter/util_test.go index d722b98260..dc4b0a4d99 100644 --- a/ethergo/submitter/util_test.go +++ b/ethergo/submitter/util_test.go @@ -1,21 +1,197 @@ package submitter_test import ( + "context" "fmt" + "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/accounts/keystore" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/stretchr/testify/assert" + "github.com/google/go-cmp/cmp" + "github.com/synapsecns/sanguine/core" + "github.com/synapsecns/sanguine/core/testsuite" "github.com/synapsecns/sanguine/ethergo/backends/simulated" "github.com/synapsecns/sanguine/ethergo/mocks" "github.com/synapsecns/sanguine/ethergo/submitter" "github.com/synapsecns/sanguine/ethergo/submitter/db" "github.com/synapsecns/sanguine/ethergo/util" + "go.opentelemetry.io/otel/attribute" + "gotest.tools/assert" "math/big" "math/rand" "sync" + "testing" "time" ) +func TestCopyTransactOpts(t *testing.T) { + // Test case 1: All fields populated + opts1 := &bind.TransactOpts{ + From: common.HexToAddress("0x1234567890123456789012345678901234567890"), + Nonce: big.NewInt(1), + Signer: nil, + Value: big.NewInt(100), + GasPrice: big.NewInt(200), + GasFeeCap: big.NewInt(300), + GasTipCap: big.NewInt(400), + GasLimit: 500, + Context: context.Background(), + NoSend: true, + } + + copyOpts1 := submitter.CopyTransactOpts(opts1) + assertTransactOptsEquality(t, opts1, copyOpts1) + + // Test case 2: Some fields populated, others nil + opts2 := &bind.TransactOpts{ + Nonce: nil, + Signer: nil, + Value: nil, + GasPrice: nil, + GasFeeCap: big.NewInt(300), + GasTipCap: big.NewInt(400), + GasLimit: 500, + Context: context.Background(), + NoSend: true, + } + + copyOpts2 := submitter.CopyTransactOpts(opts2) + assertTransactOptsEquality(t, opts2, copyOpts2) + + // Test case 3: All fields nil + opts3 := &bind.TransactOpts{ + Nonce: nil, + Signer: nil, + Value: nil, + GasPrice: nil, + GasFeeCap: nil, + GasTipCap: nil, + GasLimit: 0, + Context: nil, + NoSend: true, + } + + copyOpts3 := submitter.CopyTransactOpts(opts3) + assertTransactOptsEquality(t, opts3, copyOpts3) +} + +func assertTransactOptsEquality(tb testing.TB, toA, toB *bind.TransactOpts) { + tb.Helper() + // Check that the pointer values of the big integer fields are different + assertBigIntsCopiedEqual(tb, toA.Nonce, toB.Nonce, "Nonce") + assertBigIntsCopiedEqual(tb, toA.Value, toB.Value, "Value") + assertBigIntsCopiedEqual(tb, toA.GasPrice, toB.GasPrice, "GasPrice") + assertBigIntsCopiedEqual(tb, toA.GasFeeCap, toB.GasFeeCap, "GasFeeCap") + assertBigIntsCopiedEqual(tb, toA.GasTipCap, toB.GasTipCap, "GasFeeCap") + assert.DeepEqual(tb, toA, toB, testsuite.BigIntComparer(), cmp.AllowUnexported(context.Background())) +} + +// assertBigIntsCopiedEqual checks that the given big.Ints are equal and that +// they have different pointers. +func assertBigIntsCopiedEqual(tb testing.TB, original *big.Int, newVal *big.Int, fieldName string) { + tb.Helper() + if original == nil && newVal == nil { + return + } + + if core.ArePointersEqual(original, newVal) { + tb.Errorf("%s has same pointer as original", fieldName) + } + + if original.Cmp(newVal) != 0 { + tb.Errorf("%s is not equal", fieldName) + } +} + +func TestAddressPtrToString(t *testing.T) { + // Test case 1: Address is nil + var address *common.Address + assert.Equal(t, submitter.AddressPtrToString(address), submitter.NullFieldAttribute) + + // Test case 2: Address is not nil + address = core.PtrTo[common.Address](common.HexToAddress("0x1234567890123456789012345678901234567890")) + assert.Equal(t, submitter.AddressPtrToString(address), "0x1234567890123456789012345678901234567890") +} + +func TestBigPtrToString(t *testing.T) { + // Test case: num is nil + var num *big.Int + expected := submitter.NullFieldAttribute + result := submitter.BigPtrToString(num) + if result != expected { + t.Errorf("bigPtrToString(nil) = %q; want %q", result, expected) + } + + // Test case: num is an integer + num = big.NewInt(123) + expected = "123" + result = submitter.BigPtrToString(num) + if result != expected { + t.Errorf("bigPtrToString(123) = %q; want %q", result, expected) + } +} + +func (s *SubmitterSuite) TestTxToAttributesNullFields() { + s.checkEmptyTx(types.NewTx(&types.DynamicFeeTx{})) + s.checkEmptyTx(types.NewTx(&types.LegacyTx{})) +} + +func (s *SubmitterSuite) checkEmptyTx(rawTx *types.Transaction) { + tx := makeAttrMap(rawTx) + + s.Require().Equal(tx[submitter.HashAttr].AsString(), rawTx.Hash().Hex()) + s.Require().Equal(tx[submitter.NonceAttr].AsInt64(), int64(0)) + s.Require().Equal(tx[submitter.GasLimitAttr].AsInt64(), int64(0)) + s.Require().Equal(tx[submitter.ToAttr].AsString(), submitter.NullFieldAttribute) + s.Require().Equal(tx[submitter.ValueAttr].AsString(), "0") + s.Require().Equal(tx[submitter.DataAttr].AsString(), "") + + if rawTx.Type() == types.DynamicFeeTxType { + s.Require().Equal(tx[submitter.GasTipCapAttr].AsString(), "0") + s.Require().Equal(tx[submitter.GasFeeCapAttr].AsString(), "0") + } + if rawTx.Type() == types.LegacyTxType { + s.Require().Equal(tx[submitter.GasPriceAttr].AsString(), "0") + } +} + +func (s *SubmitterSuite) TestTxToAttributesLegacyTX() { + mockTX := mocks.GetMockTxes(s.GetTestContext(), s.T(), 1, types.LegacyTxType)[0] + mapAttr := makeAttrMap(mockTX) + + s.Require().Equal(mapAttr[submitter.HashAttr].AsString(), mockTX.Hash().String()) + s.Require().Equal(mapAttr[submitter.NonceAttr].AsInt64(), int64(mockTX.Nonce())) + s.Require().Equal(mapAttr[submitter.GasLimitAttr].AsInt64(), int64(mockTX.Gas())) + s.Require().Equal(mapAttr[submitter.ToAttr].AsString(), mockTX.To().String()) + s.Require().Equal(mapAttr[submitter.ValueAttr].AsString(), mockTX.Value().String()) + s.Require().Equal(mapAttr[submitter.DataAttr].AsString(), "") + + s.Require().Equal(mapAttr[submitter.GasPriceAttr].AsString(), mockTX.GasPrice().String()) + _, hasFeeCap := mapAttr[submitter.GasFeeCapAttr] + _, hasTipCap := mapAttr[submitter.GasTipCapAttr] + s.Require().False(hasFeeCap) + s.Require().False(hasTipCap) + s.Require().NotNil(mapAttr[submitter.FromAttr]) +} + +func (s *SubmitterSuite) TestTxToAttributesDynamicTX() { + mockTX := mocks.GetMockTxes(s.GetTestContext(), s.T(), 1, types.DynamicFeeTxType)[0] + mapAttr := makeAttrMap(mockTX) + + s.Require().Equal(mapAttr[submitter.HashAttr].AsString(), mockTX.Hash().String()) + s.Require().Equal(mapAttr[submitter.NonceAttr].AsInt64(), int64(mockTX.Nonce())) + s.Require().Equal(mapAttr[submitter.GasLimitAttr].AsInt64(), int64(mockTX.Gas())) + s.Require().Equal(mapAttr[submitter.ToAttr].AsString(), mockTX.To().String()) + s.Require().Equal(mapAttr[submitter.ValueAttr].AsString(), mockTX.Value().String()) + s.Require().Equal(mapAttr[submitter.DataAttr].AsString(), "") + + s.Require().Equal(mapAttr[submitter.GasFeeCapAttr].AsString(), mockTX.GasFeeCap().String()) + s.Require().Equal(mapAttr[submitter.GasTipCapAttr].AsString(), mockTX.GasTipCap().String()) + _, hasGasPrice := mapAttr[submitter.GasPriceAttr] + s.Require().False(hasGasPrice) + s.Require().NotNil(mapAttr[submitter.FromAttr]) +} + func (s *SubmitterSuite) TestSortTxes() { expected := make(map[uint64][]*types.Transaction) var allTxes []db.TX @@ -98,3 +274,12 @@ func (s *SubmitterSuite) TestGroupTxesByNonce() { } } } + +func makeAttrMap(tx *types.Transaction) map[string]attribute.Value { + mapAttr := make(map[string]attribute.Value) + attr := submitter.TxToAttributes(tx) + for _, a := range attr { + mapAttr[string(a.Key)] = a.Value + } + return mapAttr +} diff --git a/ethergo/util/export_test.go b/ethergo/util/export_test.go index fc357be3ab..cb7255c762 100644 --- a/ethergo/util/export_test.go +++ b/ethergo/util/export_test.go @@ -1,9 +1,6 @@ package util -import ( - "github.com/ethereum/go-ethereum/common" - "math/big" -) +import "math/big" func MakeOptions(options ...CopyOption) TestCopyOptions { return makeOptions(options...) @@ -40,36 +37,3 @@ func (c copyOptions) GasTipCap() *big.Int { func (c copyOptions) TxType() *uint8 { return c.txType } - -// NullFieldAttribute is a constant used to test the null field attribute. -// it exports the underlying constant for testing. -const NullFieldAttribute = nullFieldAttribute - -func AddressPtrToString(address *common.Address) string { - return addressPtrToString(address) -} - -const ( - // HashAttr exports hashAttr for testing. - HashAttr = hashAttr - // FromAttr exports fromAttr for testing. - FromAttr = fromAttr - // ToAttr exports toAttr for testing. - ToAttr = toAttr - // DataAttr exports dataAttr for testing. - DataAttr = dataAttr - // ValueAttr exports valueAttr for testing. - ValueAttr = valueAttr - // NonceAttr exports nonceAttr for testing. - NonceAttr = nonceAttr - // GasLimitAttr exports gasLimitAttr for testing. - GasLimitAttr = gasLimitAttr - // ChainIDAttr exports chainIDAttr for testing. - ChainIDAttr = chainIDAttr - // GasPriceAttr exports gasPriceAttr for testing. - GasPriceAttr = gasPriceAttr - // GasFeeCapAttr exports gasFeeCapAttr for testing. - GasFeeCapAttr = gasFeeCapAttr - // GasTipCapAttr exports gasTipCapAttr for testing. - GasTipCapAttr = gasTipCapAttr -) diff --git a/ethergo/util/transactor.go b/ethergo/util/transactor.go deleted file mode 100644 index 7aaf7902e2..0000000000 --- a/ethergo/util/transactor.go +++ /dev/null @@ -1,97 +0,0 @@ -package util - -import ( - "fmt" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/synapsecns/sanguine/core" - "go.opentelemetry.io/otel/attribute" - "math/big" -) - -// CopyTransactOpts creates a deep copy of the given TransactOpts struct -// with big ints wrapped in core.CopyBigInt(). -func CopyTransactOpts(opts *bind.TransactOpts) *bind.TransactOpts { - copyOpts := &bind.TransactOpts{ - From: opts.From, - Nonce: core.CopyBigInt(opts.Nonce), - Signer: opts.Signer, - Value: core.CopyBigInt(opts.Value), - GasPrice: core.CopyBigInt(opts.GasPrice), - GasFeeCap: core.CopyBigInt(opts.GasFeeCap), - GasTipCap: core.CopyBigInt(opts.GasTipCap), - GasLimit: opts.GasLimit, - Context: opts.Context, - NoSend: opts.NoSend, - } - return copyOpts -} - -const ( - hashAttr = "tx.Hash" - fromAttr = "tx.From" - toAttr = "tx.To" - dataAttr = "tx.Data" - valueAttr = "tx.Value" - nonceAttr = "tx.Nonce" - gasLimitAttr = "tx.GasLimit" - chainIDAttr = "tx.ChainID" - gasPriceAttr = "tx.GasPrice" - gasFeeCapAttr = "tx.GasFeeCap" - gasTipCapAttr = "tx.GasTipCap" -) - -// TxToAttributes converts a transaction to a slice of attribute.KeyValue. -func TxToAttributes(transaction *types.Transaction) []attribute.KeyValue { - var from string - call, err := TxToCall(transaction) - if err != nil { - from = fmt.Sprintf("could not be detected: %v", err) - } else { - from = call.From.Hex() - } - var attributes = []attribute.KeyValue{ - attribute.String(hashAttr, transaction.Hash().Hex()), - attribute.String(fromAttr, from), - attribute.String(toAttr, addressPtrToString(transaction.To())), - attribute.String(dataAttr, fmt.Sprintf("%x", transaction.Data())), - attribute.String(valueAttr, BigPtrToString(transaction.Value())), - // TODO: this could be downcast to int64, but it's unclear how we should handle overflows. - // since this is only for tracing, we can probably ignore it for now. - attribute.Int64(nonceAttr, int64(transaction.Nonce())), - attribute.Int64(gasLimitAttr, int64(transaction.Gas())), - attribute.String(chainIDAttr, BigPtrToString(transaction.ChainId())), - } - - if transaction.Type() == types.LegacyTxType && transaction.GasPrice() != nil { - attributes = append(attributes, attribute.String(gasPriceAttr, BigPtrToString(transaction.GasPrice()))) - } - - if transaction.Type() == types.DynamicFeeTxType && transaction.GasFeeCap() != nil { - attributes = append(attributes, attribute.String(gasFeeCapAttr, BigPtrToString(transaction.GasFeeCap()))) - } - - if transaction.Type() == types.DynamicFeeTxType && transaction.GasTipCap() != nil { - attributes = append(attributes, attribute.String(gasTipCapAttr, BigPtrToString(transaction.GasTipCap()))) - } - - return attributes -} - -const nullFieldAttribute = "null" - -func addressPtrToString(address *common.Address) string { - if address == nil { - return nullFieldAttribute - } - return address.Hex() -} - -// BigPtrToString converts a big.Int pointer to a string. -func BigPtrToString(num *big.Int) string { - if num == nil { - return nullFieldAttribute - } - return num.String() -} diff --git a/ethergo/util/transactor_test.go b/ethergo/util/transactor_test.go deleted file mode 100644 index 9b370cd0be..0000000000 --- a/ethergo/util/transactor_test.go +++ /dev/null @@ -1,194 +0,0 @@ -package util_test - -import ( - "context" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/google/go-cmp/cmp" - "github.com/synapsecns/sanguine/core" - "github.com/synapsecns/sanguine/core/testsuite" - "github.com/synapsecns/sanguine/ethergo/mocks" - "github.com/synapsecns/sanguine/ethergo/util" - "go.opentelemetry.io/otel/attribute" - "gotest.tools/assert" - "math/big" - "testing" -) - -func TestCopyTransactOpts(t *testing.T) { - // Test case 1: All fields populated - opts1 := &bind.TransactOpts{ - From: common.HexToAddress("0x1234567890123456789012345678901234567890"), - Nonce: big.NewInt(1), - Signer: nil, - Value: big.NewInt(100), - GasPrice: big.NewInt(200), - GasFeeCap: big.NewInt(300), - GasTipCap: big.NewInt(400), - GasLimit: 500, - Context: context.Background(), - NoSend: true, - } - - copyOpts1 := util.CopyTransactOpts(opts1) - assertTransactOptsEquality(t, opts1, copyOpts1) - - // Test case 2: Some fields populated, others nil - opts2 := &bind.TransactOpts{ - Nonce: nil, - Signer: nil, - Value: nil, - GasPrice: nil, - GasFeeCap: big.NewInt(300), - GasTipCap: big.NewInt(400), - GasLimit: 500, - Context: context.Background(), - NoSend: true, - } - - copyOpts2 := util.CopyTransactOpts(opts2) - assertTransactOptsEquality(t, opts2, copyOpts2) - - // Test case 3: All fields nil - opts3 := &bind.TransactOpts{ - Nonce: nil, - Signer: nil, - Value: nil, - GasPrice: nil, - GasFeeCap: nil, - GasTipCap: nil, - GasLimit: 0, - Context: nil, - NoSend: true, - } - - copyOpts3 := util.CopyTransactOpts(opts3) - assertTransactOptsEquality(t, opts3, copyOpts3) -} - -func assertTransactOptsEquality(tb testing.TB, toA, toB *bind.TransactOpts) { - tb.Helper() - // Check that the pointer values of the big integer fields are different - assertBigIntsCopiedEqual(tb, toA.Nonce, toB.Nonce, "Nonce") - assertBigIntsCopiedEqual(tb, toA.Value, toB.Value, "Value") - assertBigIntsCopiedEqual(tb, toA.GasPrice, toB.GasPrice, "GasPrice") - assertBigIntsCopiedEqual(tb, toA.GasFeeCap, toB.GasFeeCap, "GasFeeCap") - assertBigIntsCopiedEqual(tb, toA.GasTipCap, toB.GasTipCap, "GasTipCap") - assert.DeepEqual(tb, toA, toB, testsuite.BigIntComparer(), cmp.AllowUnexported(context.Background())) -} - -// assertBigIntsCopiedEqual checks that the given big.Ints are equal and that -// they have different pointers. -func assertBigIntsCopiedEqual(tb testing.TB, original *big.Int, newVal *big.Int, fieldName string) { - tb.Helper() - if original == nil && newVal == nil { - return - } - - if core.ArePointersEqual(original, newVal) { - tb.Errorf("%s has same pointer as original", fieldName) - } - - if original.Cmp(newVal) != 0 { - tb.Errorf("%s is not equal", fieldName) - } -} - -func TestAddressPtrToString(t *testing.T) { - // Test case 1: Address is nil - var address *common.Address - assert.Equal(t, util.AddressPtrToString(address), util.NullFieldAttribute) - - // Test case 2: Address is not nil - address = core.PtrTo[common.Address](common.HexToAddress("0x1234567890123456789012345678901234567890")) - assert.Equal(t, util.AddressPtrToString(address), "0x1234567890123456789012345678901234567890") -} - -func TestBigPtrToString(t *testing.T) { - // Test case: num is nil - var num *big.Int - expected := util.NullFieldAttribute - result := util.BigPtrToString(num) - if result != expected { - t.Errorf("BigPtrToString(nil) = %q; want %q", result, expected) - } - - // Test case: num is an integer - num = big.NewInt(123) - expected = "123" - result = util.BigPtrToString(num) - if result != expected { - t.Errorf("BigPtrToString(123) = %q; want %q", result, expected) - } -} - -func (s *UtilSuite) TestTxToAttributesNullFields() { - s.checkEmptyTx(types.NewTx(&types.DynamicFeeTx{})) - s.checkEmptyTx(types.NewTx(&types.LegacyTx{})) -} - -func (s *UtilSuite) checkEmptyTx(rawTx *types.Transaction) { - tx := makeAttrMap(rawTx) - - s.Require().Equal(tx[util.HashAttr].AsString(), rawTx.Hash().Hex()) - s.Require().Equal(tx[util.NonceAttr].AsInt64(), int64(0)) - s.Require().Equal(tx[util.GasLimitAttr].AsInt64(), int64(0)) - s.Require().Equal(tx[util.ToAttr].AsString(), util.NullFieldAttribute) - s.Require().Equal(tx[util.ValueAttr].AsString(), "0") - s.Require().Equal(tx[util.DataAttr].AsString(), "") - - if rawTx.Type() == types.DynamicFeeTxType { - s.Require().Equal(tx[util.GasTipCapAttr].AsString(), "0") - s.Require().Equal(tx[util.GasFeeCapAttr].AsString(), "0") - } - if rawTx.Type() == types.LegacyTxType { - s.Require().Equal(tx[util.GasPriceAttr].AsString(), "0") - } -} - -func (s *UtilSuite) TestTxToAttributesLegacyTX() { - mockTX := mocks.GetMockTxes(s.GetTestContext(), s.T(), 1, types.LegacyTxType)[0] - mapAttr := makeAttrMap(mockTX) - - s.Require().Equal(mapAttr[util.HashAttr].AsString(), mockTX.Hash().String()) - s.Require().Equal(mapAttr[util.NonceAttr].AsInt64(), int64(mockTX.Nonce())) - s.Require().Equal(mapAttr[util.GasLimitAttr].AsInt64(), int64(mockTX.Gas())) - s.Require().Equal(mapAttr[util.ToAttr].AsString(), mockTX.To().String()) - s.Require().Equal(mapAttr[util.ValueAttr].AsString(), mockTX.Value().String()) - s.Require().Equal(mapAttr[util.DataAttr].AsString(), "") - - s.Require().Equal(mapAttr[util.GasPriceAttr].AsString(), mockTX.GasPrice().String()) - _, hasFeeCap := mapAttr[util.GasFeeCapAttr] - _, hasTipCap := mapAttr[util.GasTipCapAttr] - s.Require().False(hasFeeCap) - s.Require().False(hasTipCap) - s.Require().NotNil(mapAttr[util.FromAttr]) -} - -func (s *UtilSuite) TestTxToAttributesDynamicTX() { - mockTX := mocks.GetMockTxes(s.GetTestContext(), s.T(), 1, types.DynamicFeeTxType)[0] - mapAttr := makeAttrMap(mockTX) - - s.Require().Equal(mapAttr[util.HashAttr].AsString(), mockTX.Hash().String()) - s.Require().Equal(mapAttr[util.NonceAttr].AsInt64(), int64(mockTX.Nonce())) - s.Require().Equal(mapAttr[util.GasLimitAttr].AsInt64(), int64(mockTX.Gas())) - s.Require().Equal(mapAttr[util.ToAttr].AsString(), mockTX.To().String()) - s.Require().Equal(mapAttr[util.ValueAttr].AsString(), mockTX.Value().String()) - s.Require().Equal(mapAttr[util.DataAttr].AsString(), "") - - s.Require().Equal(mapAttr[util.GasFeeCapAttr].AsString(), mockTX.GasFeeCap().String()) - s.Require().Equal(mapAttr[util.GasTipCapAttr].AsString(), mockTX.GasTipCap().String()) - _, hasGasPrice := mapAttr[util.GasPriceAttr] - s.Require().False(hasGasPrice) - s.Require().NotNil(mapAttr[util.FromAttr]) -} - -func makeAttrMap(tx *types.Transaction) map[string]attribute.Value { - mapAttr := make(map[string]attribute.Value) - attr := util.TxToAttributes(tx) - for _, a := range attr { - mapAttr[string(a.Key)] = a.Value - } - return mapAttr -} diff --git a/services/cctp-relayer/go.mod b/services/cctp-relayer/go.mod index eb96f3af01..acbf3a3e2f 100644 --- a/services/cctp-relayer/go.mod +++ b/services/cctp-relayer/go.mod @@ -47,7 +47,7 @@ require ( github.com/VictoriaMetrics/fastcache v1.6.0 // indirect github.com/acomagu/bufpipe v1.0.4 // indirect github.com/agnivade/levenshtein v1.1.1 // indirect - github.com/andybalholm/brotli v1.0.5 // indirect + github.com/andybalholm/brotli v1.0.4 // indirect github.com/aws/aws-sdk-go-v2 v1.18.0 // indirect github.com/aws/aws-sdk-go-v2/config v1.18.21 // indirect github.com/aws/aws-sdk-go-v2/credentials v1.13.20 // indirect @@ -168,7 +168,7 @@ require ( github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a // indirect github.com/keep-network/keep-common v1.7.1-0.20211012131917-7102d7b9c6a0 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect - github.com/klauspost/compress v1.16.0 // indirect + github.com/klauspost/compress v1.15.12 // indirect github.com/klauspost/cpuid/v2 v2.2.4 // indirect github.com/leodido/go-urn v1.2.4 // indirect github.com/lmittmann/w3 v0.10.0 // indirect diff --git a/services/cctp-relayer/go.sum b/services/cctp-relayer/go.sum index c8bbce7d91..95cb711ae1 100644 --- a/services/cctp-relayer/go.sum +++ b/services/cctp-relayer/go.sum @@ -134,9 +134,8 @@ github.com/allegro/bigcache v1.2.1 h1:hg1sY1raCwic3Vnsvje6TT7/pnZba83LeFck5NrFKS github.com/allegro/bigcache v1.2.1/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= +github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY= github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= -github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= -github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= @@ -775,8 +774,8 @@ github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6 github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.15.0/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= -github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= -github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/compress v1.15.12 h1:YClS/PImqYbn+UILDnqxQCZ3RehC9N318SU3kElDUEM= +github.com/klauspost/compress v1.15.12/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= diff --git a/services/omnirpc/go.mod b/services/omnirpc/go.mod index fa2aaf3f6c..0bc01d8863 100644 --- a/services/omnirpc/go.mod +++ b/services/omnirpc/go.mod @@ -59,7 +59,7 @@ require ( github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95 // indirect github.com/VictoriaMetrics/fastcache v1.6.0 // indirect github.com/acomagu/bufpipe v1.0.4 // indirect - github.com/andybalholm/brotli v1.0.5 // indirect + github.com/andybalholm/brotli v1.0.4 // indirect github.com/badoux/checkmail v0.0.0-20181210160741-9661bd69e9ad // indirect github.com/benbjohnson/immutable v0.4.3 // indirect github.com/beorn7/perks v1.0.1 // indirect @@ -150,7 +150,7 @@ require ( github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a // indirect github.com/keep-network/keep-common v1.7.1-0.20211012131917-7102d7b9c6a0 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect - github.com/klauspost/compress v1.16.0 // indirect + github.com/klauspost/compress v1.15.12 // indirect github.com/klauspost/cpuid/v2 v2.2.4 // indirect github.com/leodido/go-urn v1.2.4 // indirect github.com/logrusorgru/aurora v2.0.3+incompatible // indirect diff --git a/services/omnirpc/go.sum b/services/omnirpc/go.sum index 2fa4cdfdca..e9cff36b12 100644 --- a/services/omnirpc/go.sum +++ b/services/omnirpc/go.sum @@ -116,9 +116,8 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax github.com/allegro/bigcache v1.2.1 h1:hg1sY1raCwic3Vnsvje6TT7/pnZba83LeFck5NrFKSc= github.com/allegro/bigcache v1.2.1/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= +github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY= github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= -github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= -github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= @@ -707,8 +706,8 @@ github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6 github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.15.0/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= -github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= -github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/compress v1.15.12 h1:YClS/PImqYbn+UILDnqxQCZ3RehC9N318SU3kElDUEM= +github.com/klauspost/compress v1.15.12/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= diff --git a/services/scribe/go.mod b/services/scribe/go.mod index 51d7e2b236..ba81b355da 100644 --- a/services/scribe/go.mod +++ b/services/scribe/go.mod @@ -83,7 +83,7 @@ require ( github.com/acomagu/bufpipe v1.0.4 // indirect github.com/agnivade/levenshtein v1.1.1 // indirect github.com/alecthomas/chroma v0.7.1 // indirect - github.com/andybalholm/brotli v1.0.5 // indirect + github.com/andybalholm/brotli v1.0.4 // indirect github.com/badoux/checkmail v0.0.0-20181210160741-9661bd69e9ad // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/briandowns/spinner v1.6.1 // indirect @@ -185,7 +185,7 @@ require ( github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a // indirect github.com/keep-network/keep-common v1.7.1-0.20211012131917-7102d7b9c6a0 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect - github.com/klauspost/compress v1.16.0 // indirect + github.com/klauspost/compress v1.15.12 // indirect github.com/klauspost/cpuid/v2 v2.2.4 // indirect github.com/kyokomi/emoji/v2 v2.2.8 // indirect github.com/leodido/go-urn v1.2.4 // indirect diff --git a/services/scribe/go.sum b/services/scribe/go.sum index faeba00347..cc7aa9b484 100644 --- a/services/scribe/go.sum +++ b/services/scribe/go.sum @@ -139,9 +139,8 @@ github.com/allegro/bigcache v1.2.1 h1:hg1sY1raCwic3Vnsvje6TT7/pnZba83LeFck5NrFKS github.com/allegro/bigcache v1.2.1/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= +github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY= github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= -github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= -github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= @@ -753,8 +752,8 @@ github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6 github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.15.0/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= -github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= -github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/compress v1.15.12 h1:YClS/PImqYbn+UILDnqxQCZ3RehC9N318SU3kElDUEM= +github.com/klauspost/compress v1.15.12/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= diff --git a/services/sinner/go.mod b/services/sinner/go.mod index 1d44c975a0..2786cbfb24 100644 --- a/services/sinner/go.mod +++ b/services/sinner/go.mod @@ -71,7 +71,7 @@ require ( github.com/alecthomas/chroma v0.7.1 // indirect github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721 // indirect github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897 // indirect - github.com/andybalholm/brotli v1.0.5 // indirect + github.com/andybalholm/brotli v1.0.4 // indirect github.com/aws/aws-sdk-go-v2 v1.18.0 // indirect github.com/aws/aws-sdk-go-v2/config v1.18.21 // indirect github.com/aws/aws-sdk-go-v2/credentials v1.13.20 // indirect @@ -195,7 +195,7 @@ require ( github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a // indirect github.com/keep-network/keep-common v1.7.1-0.20211012131917-7102d7b9c6a0 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect - github.com/klauspost/compress v1.16.0 // indirect + github.com/klauspost/compress v1.15.12 // indirect github.com/klauspost/cpuid/v2 v2.2.4 // indirect github.com/kyokomi/emoji/v2 v2.2.8 // indirect github.com/leodido/go-urn v1.2.4 // indirect diff --git a/services/sinner/go.sum b/services/sinner/go.sum index 46a5e3e5a2..e891a409b9 100644 --- a/services/sinner/go.sum +++ b/services/sinner/go.sum @@ -146,9 +146,8 @@ github.com/allegro/bigcache v1.2.1 h1:hg1sY1raCwic3Vnsvje6TT7/pnZba83LeFck5NrFKS github.com/allegro/bigcache v1.2.1/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= +github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY= github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= -github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= -github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= @@ -810,8 +809,8 @@ github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6 github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.15.0/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= -github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= -github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/compress v1.15.12 h1:YClS/PImqYbn+UILDnqxQCZ3RehC9N318SU3kElDUEM= +github.com/klauspost/compress v1.15.12/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= From a96ebb3ed749cb2019a2b6ab94cddad5c9fcc4ab Mon Sep 17 00:00:00 2001 From: aureliusbtc <82057759+aureliusbtc@users.noreply.github.com> Date: Mon, 25 Dec 2023 14:59:48 +0100 Subject: [PATCH 21/29] update --- packages/synapse-interface/constants/blacklist.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/synapse-interface/constants/blacklist.ts b/packages/synapse-interface/constants/blacklist.ts index d2e855a1f9..b13e89f06b 100644 --- a/packages/synapse-interface/constants/blacklist.ts +++ b/packages/synapse-interface/constants/blacklist.ts @@ -402,4 +402,5 @@ export const EXCLUDED_ADDRESSES = [ '0xEBe400Ad38000F1E11697e994D7EAC50516E6a61', '0xF893D865a21D52C0a3ea714F6bb53C0CFa252fC5', '0xe0FC7A6223309A0bBA8218AbD54F2953122E6b6A', + '0xa423c7be031e988b25fb7ec39b7906582f6858c6' ] From 977cbb49562ba9cd3d4e8b94258e979ee0c0c5dd Mon Sep 17 00:00:00 2001 From: aureliusbtc Date: Mon, 25 Dec 2023 14:04:32 +0000 Subject: [PATCH 22/29] Publish - @synapsecns/synapse-interface@0.1.215 --- packages/synapse-interface/CHANGELOG.md | 8 ++++++++ packages/synapse-interface/package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/synapse-interface/CHANGELOG.md b/packages/synapse-interface/CHANGELOG.md index 6a82745518..c76918e3f8 100644 --- a/packages/synapse-interface/CHANGELOG.md +++ b/packages/synapse-interface/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.1.215](https://github.com/synapsecns/sanguine/compare/@synapsecns/synapse-interface@0.1.214...@synapsecns/synapse-interface@0.1.215) (2023-12-25) + +**Note:** Version bump only for package @synapsecns/synapse-interface + + + + + ## [0.1.214](https://github.com/synapsecns/sanguine/compare/@synapsecns/synapse-interface@0.1.213...@synapsecns/synapse-interface@0.1.214) (2023-12-22) **Note:** Version bump only for package @synapsecns/synapse-interface diff --git a/packages/synapse-interface/package.json b/packages/synapse-interface/package.json index d63e177777..583faf0b77 100644 --- a/packages/synapse-interface/package.json +++ b/packages/synapse-interface/package.json @@ -1,6 +1,6 @@ { "name": "@synapsecns/synapse-interface", - "version": "0.1.214", + "version": "0.1.215", "private": true, "engines": { "node": ">=16.0.0" From e7cfd5da41b79b2da013e0872e80a6b2725d7809 Mon Sep 17 00:00:00 2001 From: trajan0x <83933037+trajan0x@users.noreply.github.com> Date: Tue, 26 Dec 2023 09:40:04 -0500 Subject: [PATCH 23/29] lint fix (#1715) Co-authored-by: Trajan0x --- packages/synapse-interface/constants/blacklist.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/synapse-interface/constants/blacklist.ts b/packages/synapse-interface/constants/blacklist.ts index b13e89f06b..92e687328b 100644 --- a/packages/synapse-interface/constants/blacklist.ts +++ b/packages/synapse-interface/constants/blacklist.ts @@ -402,5 +402,5 @@ export const EXCLUDED_ADDRESSES = [ '0xEBe400Ad38000F1E11697e994D7EAC50516E6a61', '0xF893D865a21D52C0a3ea714F6bb53C0CFa252fC5', '0xe0FC7A6223309A0bBA8218AbD54F2953122E6b6A', - '0xa423c7be031e988b25fb7ec39b7906582f6858c6' + '0xa423c7be031e988b25fb7ec39b7906582f6858c6', ] From 225e70aa9e67b6f3384531189505c746bbea254e Mon Sep 17 00:00:00 2001 From: trajan0x Date: Tue, 26 Dec 2023 14:43:11 +0000 Subject: [PATCH 24/29] Publish - @synapsecns/synapse-interface@0.1.216 --- packages/synapse-interface/CHANGELOG.md | 8 ++++++++ packages/synapse-interface/package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/synapse-interface/CHANGELOG.md b/packages/synapse-interface/CHANGELOG.md index c76918e3f8..d195a89029 100644 --- a/packages/synapse-interface/CHANGELOG.md +++ b/packages/synapse-interface/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.1.216](https://github.com/synapsecns/sanguine/compare/@synapsecns/synapse-interface@0.1.215...@synapsecns/synapse-interface@0.1.216) (2023-12-26) + +**Note:** Version bump only for package @synapsecns/synapse-interface + + + + + ## [0.1.215](https://github.com/synapsecns/sanguine/compare/@synapsecns/synapse-interface@0.1.214...@synapsecns/synapse-interface@0.1.215) (2023-12-25) **Note:** Version bump only for package @synapsecns/synapse-interface diff --git a/packages/synapse-interface/package.json b/packages/synapse-interface/package.json index 583faf0b77..0ee1d420c7 100644 --- a/packages/synapse-interface/package.json +++ b/packages/synapse-interface/package.json @@ -1,6 +1,6 @@ { "name": "@synapsecns/synapse-interface", - "version": "0.1.215", + "version": "0.1.216", "private": true, "engines": { "node": ">=16.0.0" From b5bf2b58e3a7219a6d7f8c3d3ac32ffec5a49ec4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CF=87=C2=B2?= <88190723+ChiTimesChi@users.noreply.github.com> Date: Wed, 27 Dec 2023 14:17:39 +0300 Subject: [PATCH 25/29] SDK: all quotes, Query modifications (#1716) * Add `modifyDeadline()` for Query * Add `applySlippage()` for Query * Add `allBridgeQuotes` * Add tests for `allBridgeQuotes` * Sort `allBridgeQuotes` by amountOut * Simplify `bridgeQuote()` * Add `applySlippageInBips` * Expose "apply slippage" funcs * Add tests for "apply slippage" not modifying the passed object * Fix: don't modify `query` in test setups --- packages/sdk-router/src/module/query.test.ts | 308 +++++++++++++++++++ packages/sdk-router/src/module/query.ts | 64 ++++ packages/sdk-router/src/module/types.ts | 11 - packages/sdk-router/src/operations/bridge.ts | 88 ++++-- packages/sdk-router/src/sdk.test.ts | 49 +++ packages/sdk-router/src/sdk.ts | 16 +- 6 files changed, 499 insertions(+), 37 deletions(-) diff --git a/packages/sdk-router/src/module/query.test.ts b/packages/sdk-router/src/module/query.test.ts index 8ba4a757ea..811986a44e 100644 --- a/packages/sdk-router/src/module/query.test.ts +++ b/packages/sdk-router/src/module/query.test.ts @@ -7,6 +7,9 @@ import { reduceToQuery, narrowToRouterQuery, narrowToCCTPRouterQuery, + modifyDeadline, + applySlippage, + applySlippageInBips, } from './query' describe('#query', () => { @@ -72,4 +75,309 @@ describe('#query', () => { ) }) }) + + describe('modifyDeadline', () => { + describe('RouterQuery', () => { + it('modifies the deadline', () => { + const query = modifyDeadline(routerQuery, BigNumber.from(42)) + expect(query).toEqual({ + swapAdapter: '1', + tokenOut: '2', + minAmountOut: BigNumber.from(3), + deadline: BigNumber.from(42), + rawParams: '5', + }) + }) + + it('does not modify the original query', () => { + modifyDeadline(routerQuery, BigNumber.from(42)) + expect(routerQuery).toEqual({ + swapAdapter: '1', + tokenOut: '2', + minAmountOut: BigNumber.from(3), + deadline: BigNumber.from(4), + rawParams: '5', + }) + }) + }) + + describe('CCTPRouterQuery', () => { + it('modifies the deadline', () => { + const query = modifyDeadline(cctpRouterQuery, BigNumber.from(42)) + expect(query).toEqual({ + routerAdapter: '6', + tokenOut: '7', + minAmountOut: BigNumber.from(8), + deadline: BigNumber.from(42), + rawParams: '10', + }) + }) + + it('does not modify the original query', () => { + modifyDeadline(cctpRouterQuery, BigNumber.from(42)) + expect(cctpRouterQuery).toEqual({ + routerAdapter: '6', + tokenOut: '7', + minAmountOut: BigNumber.from(8), + deadline: BigNumber.from(9), + rawParams: '10', + }) + }) + }) + }) + + describe('applySlippage', () => { + describe('RouterQuery', () => { + // 1M in 18 decimals + const query: RouterQuery = { + swapAdapter: '1', + tokenOut: '2', + minAmountOut: BigNumber.from(10).pow(18).mul(1_000_000), + deadline: BigNumber.from(4), + rawParams: '5', + } + + it('applies 0% slippage', () => { + const newQuery = applySlippage(query, 0, 10000) + expect(newQuery).toEqual({ + swapAdapter: '1', + tokenOut: '2', + minAmountOut: BigNumber.from(10).pow(18).mul(1_000_000), + deadline: BigNumber.from(4), + rawParams: '5', + }) + }) + + it('applies 0.5% slippage', () => { + // 50 bips + const newQuery = applySlippage(query, 50, 10000) + expect(newQuery).toEqual({ + swapAdapter: '1', + tokenOut: '2', + minAmountOut: BigNumber.from(10).pow(18).mul(995_000), + deadline: BigNumber.from(4), + rawParams: '5', + }) + }) + + it('applies 10% slippage', () => { + const newQuery = applySlippage(query, 10, 100) + expect(newQuery).toEqual({ + swapAdapter: '1', + tokenOut: '2', + minAmountOut: BigNumber.from(10).pow(18).mul(900_000), + deadline: BigNumber.from(4), + rawParams: '5', + }) + }) + + it('applies 100% slippage', () => { + const newQuery = applySlippage(query, 1, 1) + expect(newQuery).toEqual({ + swapAdapter: '1', + tokenOut: '2', + minAmountOut: BigNumber.from(0), + deadline: BigNumber.from(4), + rawParams: '5', + }) + }) + + it('rounds down', () => { + const queryPlusOne = { + ...query, + minAmountOut: query.minAmountOut.add(1), + } + const newQuery = applySlippage(queryPlusOne, 50, 10000) + expect(newQuery).toEqual({ + swapAdapter: '1', + tokenOut: '2', + minAmountOut: BigNumber.from(10).pow(18).mul(995_000).add(1), + deadline: BigNumber.from(4), + rawParams: '5', + }) + }) + + it('does not modify the original query', () => { + applySlippage(query, 50, 10000) + expect(query).toEqual({ + swapAdapter: '1', + tokenOut: '2', + minAmountOut: BigNumber.from(10).pow(18).mul(1_000_000), + deadline: BigNumber.from(4), + rawParams: '5', + }) + }) + }) + + describe('CCTPRouterQuery', () => { + // 1M in 6 decimals + const query: CCTPRouterQuery = { + routerAdapter: '1', + tokenOut: '2', + minAmountOut: BigNumber.from(10).pow(6).mul(1_000_000), + deadline: BigNumber.from(4), + rawParams: '5', + } + + it('applies 0% slippage', () => { + const newQuery = applySlippage(query, 0, 10000) + expect(newQuery).toEqual({ + routerAdapter: '1', + tokenOut: '2', + minAmountOut: BigNumber.from(10).pow(6).mul(1_000_000), + deadline: BigNumber.from(4), + rawParams: '5', + }) + }) + + it('applies 0.5% slippage', () => { + // 50 bips + const newQuery = applySlippage(query, 50, 10000) + expect(newQuery).toEqual({ + routerAdapter: '1', + tokenOut: '2', + minAmountOut: BigNumber.from(10).pow(6).mul(995_000), + deadline: BigNumber.from(4), + rawParams: '5', + }) + }) + + it('applies 10% slippage', () => { + const newQuery = applySlippage(query, 10, 100) + expect(newQuery).toEqual({ + routerAdapter: '1', + tokenOut: '2', + minAmountOut: BigNumber.from(10).pow(6).mul(900_000), + deadline: BigNumber.from(4), + rawParams: '5', + }) + }) + + it('applies 100% slippage', () => { + const newQuery = applySlippage(query, 1, 1) + expect(newQuery).toEqual({ + routerAdapter: '1', + tokenOut: '2', + minAmountOut: BigNumber.from(0), + deadline: BigNumber.from(4), + rawParams: '5', + }) + }) + + it('rounds down', () => { + const queryPlusOne = { + ...query, + minAmountOut: query.minAmountOut.add(1), + } + const newQuery = applySlippage(queryPlusOne, 50, 10000) + expect(newQuery).toEqual({ + routerAdapter: '1', + tokenOut: '2', + minAmountOut: BigNumber.from(10).pow(6).mul(995_000).add(1), + deadline: BigNumber.from(4), + rawParams: '5', + }) + }) + + it('does not modify the original query', () => { + applySlippage(query, 50, 10000) + expect(query).toEqual({ + routerAdapter: '1', + tokenOut: '2', + minAmountOut: BigNumber.from(10).pow(6).mul(1_000_000), + deadline: BigNumber.from(4), + rawParams: '5', + }) + }) + }) + + describe('errors', () => { + it('throws if slippage denominator is zero', () => { + expect(() => applySlippage(routerQuery, 1, 0)).toThrow( + 'Slippage denominator cannot be zero' + ) + }) + + it('throws if slippage numerator is negative', () => { + expect(() => applySlippage(routerQuery, -1, 1)).toThrow( + 'Slippage numerator cannot be negative' + ) + }) + + it('throws if slippage numerator is greater than denominator', () => { + expect(() => applySlippage(routerQuery, 2, 1)).toThrow( + 'Slippage cannot be greater than 1' + ) + }) + }) + }) + + describe('applySlippageInBips parity', () => { + // 1M in 18 decimals + const query: RouterQuery = { + swapAdapter: '1', + tokenOut: '2', + minAmountOut: BigNumber.from(10).pow(18).mul(1_000_000), + deadline: BigNumber.from(4), + rawParams: '5', + } + + it('applies 0% slippage', () => { + const newQuery = applySlippage(query, 0, 10000) + const newQueryInBips = applySlippageInBips(query, 0) + expect(newQuery).toEqual(newQueryInBips) + }) + + it('applies 0.5% slippage', () => { + // 50 bips + const newQuery = applySlippage(query, 50, 10000) + const newQueryInBips = applySlippageInBips(query, 50) + expect(newQuery).toEqual(newQueryInBips) + }) + + it('applies 10% slippage', () => { + const newQuery = applySlippage(query, 10, 100) + const newQueryInBips = applySlippageInBips(query, 1000) + expect(newQuery).toEqual(newQueryInBips) + }) + + it('applies 100% slippage', () => { + const newQuery = applySlippage(query, 1, 1) + const newQueryInBips = applySlippageInBips(query, 10000) + expect(newQuery).toEqual(newQueryInBips) + }) + + it('rounds down', () => { + const queryPlusOne = { + ...query, + minAmountOut: query.minAmountOut.add(1), + } + const newQuery = applySlippage(queryPlusOne, 50, 10000) + const newQueryInBips = applySlippageInBips(queryPlusOne, 50) + expect(newQuery).toEqual(newQueryInBips) + }) + + it('does not modify the original query', () => { + applySlippageInBips(query, 50) + expect(query).toEqual({ + swapAdapter: '1', + tokenOut: '2', + minAmountOut: BigNumber.from(10).pow(18).mul(1_000_000), + deadline: BigNumber.from(4), + rawParams: '5', + }) + }) + + it('throws if basis points are negative', () => { + expect(() => applySlippageInBips(routerQuery, -1)).toThrow( + 'Slippage numerator cannot be negative' + ) + }) + + it('throws if basis points are greater than 10000', () => { + expect(() => applySlippageInBips(routerQuery, 10001)).toThrow( + 'Slippage cannot be greater than 1' + ) + }) + }) }) diff --git a/packages/sdk-router/src/module/query.ts b/packages/sdk-router/src/module/query.ts index 5719fa168a..02b2476f45 100644 --- a/packages/sdk-router/src/module/query.ts +++ b/packages/sdk-router/src/module/query.ts @@ -101,3 +101,67 @@ export const hasComplexBridgeAction = (destQuery: Query): boolean => { destQuery.tokenOut !== ETH_NATIVE_TOKEN_ADDRESS ) } + +/** + * Modifies the deadline of the query and returns the modified query. + * Note: the original query is preserved unchanged. + * + * @param query - The query to modify. + * @param deadline - The new deadline. + * @returns The modified query with the new deadline. + */ +export const modifyDeadline = (query: Query, deadline: BigNumber): Query => { + return { + ...query, + deadline, + } +} + +/** + * Applies the slippage to the query's minAmountOut (rounded down), and returns the modified query + * with the reduced minAmountOut. + * Note: the original query is preserved unchanged. + * + * @param query - The query to modify. + * @param slipNumerator - The numerator of the slippage. + * @param slipDenominator - The denominator of the slippage. + * @returns The modified query with the reduced minAmountOut. + * @throws If the slippage fraction is invalid (<0, >1, or NaN) + */ +export const applySlippage = ( + query: Query, + slipNumerator: number, + slipDenominator: number +): Query => { + invariant(slipDenominator > 0, 'Slippage denominator cannot be zero') + invariant(slipNumerator >= 0, 'Slippage numerator cannot be negative') + invariant( + slipNumerator <= slipDenominator, + 'Slippage cannot be greater than 1' + ) + const slippageAmount = query.minAmountOut + .mul(slipNumerator) + .div(slipDenominator) + return { + ...query, + minAmountOut: query.minAmountOut.sub(slippageAmount), + } +} + +/** + * Applies the slippage (in basis points) to the query's minAmountOut (rounded down), and returns the modified query + * with the reduced minAmountOut. + * Note: the original query is preserved unchanged. + * Note: the slippage is applied as a fraction of 10000, e.g. 100 bips = 1%. + * + * @param query - The query to modify. + * @param slipBasisPoints - The slippage in basis points. + * @returns The modified query with the reduced minAmountOut. + * @throws If the basis points are invalid (<0, >10000) + */ +export const applySlippageInBips = ( + query: Query, + slipBasisPoints: number +): Query => { + return applySlippage(query, slipBasisPoints, 10000) +} diff --git a/packages/sdk-router/src/module/types.ts b/packages/sdk-router/src/module/types.ts index bcb6f823ba..6b9f66712f 100644 --- a/packages/sdk-router/src/module/types.ts +++ b/packages/sdk-router/src/module/types.ts @@ -76,14 +76,3 @@ export type BridgeRoute = { bridgeToken: BridgeToken bridgeModuleName: string } - -/** - * Finds the best route: the one with the maximum amount out in the destination query. - */ -export const findBestRoute = (bridgeRoutes: BridgeRoute[]): BridgeRoute => { - return bridgeRoutes.reduce((best, current) => { - return current.destQuery.minAmountOut.gt(best.destQuery.minAmountOut) - ? current - : best - }) -} diff --git a/packages/sdk-router/src/operations/bridge.ts b/packages/sdk-router/src/operations/bridge.ts index e297674fbd..3bbe789d3a 100644 --- a/packages/sdk-router/src/operations/bridge.ts +++ b/packages/sdk-router/src/operations/bridge.ts @@ -4,7 +4,7 @@ import { BigNumber, PopulatedTransaction } from 'ethers' import { BigintIsh } from '../constants' import { SynapseSDK } from '../sdk' import { handleNativeToken } from '../utils/handleNativeToken' -import { BridgeQuote, Query, findBestRoute } from '../module' +import { BridgeQuote, Query } from '../module' import { RouterSet } from '../router' /** @@ -86,37 +86,75 @@ export async function bridgeQuote( deadline?: BigNumber, excludeCCTP: boolean = false ): Promise { + // Get the quotes sorted by maxAmountOut + const allQuotes = await allBridgeQuotes.call( + this, + originChainId, + destChainId, + tokenIn, + tokenOut, + amountIn, + deadline + ) + // Get the first quote that is not excluded + const bestQuote = allQuotes.find( + (quote) => + !excludeCCTP || + quote.bridgeModuleName !== this.synapseCCTPRouterSet.bridgeModuleName + ) + if (!bestQuote) { + throw new Error('No route found') + } + return bestQuote +} + +/** + * This method tries to fetch all available quotes from all available bridge modules. + * + * @param originChainId - The ID of the original chain. + * @param destChainId - The ID of the destination chain. + * @param tokenIn - The input token. + * @param tokenOut - The output token. + * @param amountIn - The amount of input token. + * @param deadline - The transaction deadline, optional. + * @returns - A promise that resolves to an array of bridge quotes. + */ +export async function allBridgeQuotes( + this: SynapseSDK, + originChainId: number, + destChainId: number, + tokenIn: string, + tokenOut: string, + amountIn: BigintIsh, + deadline?: BigNumber +): Promise { invariant( originChainId !== destChainId, 'Origin chainId cannot be equal to destination chainId' ) tokenOut = handleNativeToken(tokenOut) tokenIn = handleNativeToken(tokenIn) - // Construct objects for both types of routers - const allSets: { set: RouterSet; exclude: boolean }[] = [ - { set: this.synapseRouterSet, exclude: false }, - { set: this.synapseCCTPRouterSet, exclude: excludeCCTP }, - ] - // Fetch bridge routes from both types of routers - const allRoutesPromises = allSets.map(({ set, exclude }) => - exclude - ? Promise.resolve([]) - : set.getBridgeRoutes( - originChainId, - destChainId, - tokenIn, - tokenOut, - amountIn - ) + const allQuotes: BridgeQuote[][] = await Promise.all( + this.allRouterSets.map(async (routerSet) => { + const routes = await routerSet.getBridgeRoutes( + originChainId, + destChainId, + tokenIn, + tokenOut, + amountIn + ) + // Filter out routes with zero minAmountOut and finalize the rest + return Promise.all( + routes + .filter((route) => route.destQuery.minAmountOut.gt(0)) + .map((route) => routerSet.finalizeBridgeRoute(route, deadline)) + ) + }) ) - // Wait for all quotes to resolve and flatten the result - const allRoutes = (await Promise.all(allRoutesPromises)).flat() - invariant(allRoutes.length > 0, 'No route found') - const bestRoute = findBestRoute(allRoutes) - // Find the Router Set that yielded the best route - const bestSet: RouterSet = getRouterSet.call(this, bestRoute.bridgeModuleName) - // Finalize the Bridge Route - return bestSet.finalizeBridgeRoute(bestRoute, deadline) + // Flatten the result and sort by maxAmountOut in descending order + return allQuotes + .flat() + .sort((a, b) => (a.maxAmountOut.gt(b.maxAmountOut) ? -1 : 1)) } /** diff --git a/packages/sdk-router/src/sdk.test.ts b/packages/sdk-router/src/sdk.test.ts index 8e460a1509..0bd32477e6 100644 --- a/packages/sdk-router/src/sdk.test.ts +++ b/packages/sdk-router/src/sdk.test.ts @@ -648,6 +648,55 @@ describe('SynapseSDK', () => { }) }) + describe('allBridgeQuotes', () => { + const synapse = new SynapseSDK( + [SupportedChainId.ETH, SupportedChainId.ARBITRUM], + [ethProvider, arbProvider] + ) + + it('Fetches SynapseBridge and SynapseCCTP quotes for USDC', async () => { + const allQuotes = await synapse.allBridgeQuotes( + SupportedChainId.ETH, + SupportedChainId.ARBITRUM, + ETH_USDC, + ARB_USDT, + BigNumber.from(10).pow(9) + ) + expect(allQuotes.length).toEqual(2) + expectCorrectBridgeQuote(allQuotes[0]) + expectCorrectBridgeQuote(allQuotes[1]) + // First quote should have better quote + expect(allQuotes[0].maxAmountOut.gte(allQuotes[1].maxAmountOut)).toBe( + true + ) + // One should be SynapseBridge and the other SynapseCCTP + expect(allQuotes[0].bridgeModuleName).not.toEqual( + allQuotes[1].bridgeModuleName + ) + expect( + allQuotes[0].bridgeModuleName === 'SynapseBridge' || + allQuotes[1].bridgeModuleName === 'SynapseBridge' + ).toBe(true) + expect( + allQuotes[0].bridgeModuleName === 'SynapseCCTP' || + allQuotes[1].bridgeModuleName === 'SynapseCCTP' + ).toBe(true) + }) + + it('Fetches only SynapseBridge quotes for ETH', async () => { + const allQuotes = await synapse.allBridgeQuotes( + SupportedChainId.ETH, + SupportedChainId.ARBITRUM, + NATIVE_ADDRESS, + NATIVE_ADDRESS, + BigNumber.from(10).pow(18) + ) + expect(allQuotes.length).toEqual(1) + expectCorrectBridgeQuote(allQuotes[0]) + expect(allQuotes[0].bridgeModuleName).toEqual('SynapseBridge') + }) + }) + describe('Errors', () => { const synapse = new SynapseSDK( [SupportedChainId.ETH, SupportedChainId.BSC], diff --git a/packages/sdk-router/src/sdk.ts b/packages/sdk-router/src/sdk.ts index a6de2bee64..c2ef87a802 100644 --- a/packages/sdk-router/src/sdk.ts +++ b/packages/sdk-router/src/sdk.ts @@ -2,6 +2,7 @@ import { Provider } from '@ethersproject/abstract-provider' import invariant from 'tiny-invariant' import { + RouterSet, SynapseRouterSet, SynapseCCTPRouterSet, ChainProvider, @@ -9,9 +10,15 @@ import { } from './router' import * as operations from './operations' import { ETH_NATIVE_TOKEN_ADDRESS } from './utils/handleNativeToken' -import { Query } from './module' +import { + Query, + applySlippage, + applySlippageInBips, + modifyDeadline, +} from './module' class SynapseSDK { + public allRouterSets: RouterSet[] public synapseRouterSet: SynapseRouterSet public synapseCCTPRouterSet: SynapseCCTPRouterSet public providers: { [chainId: number]: Provider } @@ -41,11 +48,13 @@ class SynapseSDK { // Initialize SynapseRouterSet and SynapseCCTPRouterSet this.synapseRouterSet = new SynapseRouterSet(chainProviders) this.synapseCCTPRouterSet = new SynapseCCTPRouterSet(chainProviders) + this.allRouterSets = [this.synapseRouterSet, this.synapseCCTPRouterSet] } // Define Bridge operations public bridge = operations.bridge public bridgeQuote = operations.bridgeQuote + public allBridgeQuotes = operations.allBridgeQuotes public getBridgeModuleName = operations.getBridgeModuleName public getEstimatedTime = operations.getEstimatedTime public getSynapseTxId = operations.getSynapseTxId @@ -65,6 +74,11 @@ class SynapseSDK { // Define Swap operations public swap = operations.swap public swapQuote = operations.swapQuote + + // Define Query operations + public applySlippage = applySlippage + public applySlippageInBips = applySlippageInBips + public modifyDeadline = modifyDeadline } export { SynapseSDK, ETH_NATIVE_TOKEN_ADDRESS, Query, PoolToken } From 8d765e565f744681cbf2e0574b5a2266b3251a9a Mon Sep 17 00:00:00 2001 From: ChiTimesChi Date: Wed, 27 Dec 2023 11:20:44 +0000 Subject: [PATCH 26/29] Publish - @synapsecns/rest-api@1.0.34 - @synapsecns/sdk-router@0.3.7 - @synapsecns/synapse-interface@0.1.217 --- packages/rest-api/CHANGELOG.md | 8 ++++++++ packages/rest-api/package.json | 4 ++-- packages/sdk-router/CHANGELOG.md | 8 ++++++++ packages/sdk-router/package.json | 2 +- packages/synapse-interface/CHANGELOG.md | 8 ++++++++ packages/synapse-interface/package.json | 4 ++-- 6 files changed, 29 insertions(+), 5 deletions(-) diff --git a/packages/rest-api/CHANGELOG.md b/packages/rest-api/CHANGELOG.md index cb2e913690..8ef2ef2c93 100644 --- a/packages/rest-api/CHANGELOG.md +++ b/packages/rest-api/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.34](https://github.com/synapsecns/sanguine/compare/@synapsecns/rest-api@1.0.33...@synapsecns/rest-api@1.0.34) (2023-12-27) + +**Note:** Version bump only for package @synapsecns/rest-api + + + + + ## [1.0.33](https://github.com/synapsecns/sanguine/compare/@synapsecns/rest-api@1.0.32...@synapsecns/rest-api@1.0.33) (2023-12-22) **Note:** Version bump only for package @synapsecns/rest-api diff --git a/packages/rest-api/package.json b/packages/rest-api/package.json index ccdbd7a3f3..9b46a079b0 100644 --- a/packages/rest-api/package.json +++ b/packages/rest-api/package.json @@ -1,6 +1,6 @@ { "name": "@synapsecns/rest-api", - "version": "1.0.33", + "version": "1.0.34", "private": "true", "engines": { "node": ">=16.0.0" @@ -23,7 +23,7 @@ "@ethersproject/bignumber": "^5.7.0", "@ethersproject/providers": "^5.7.2", "@ethersproject/units": "5.7.0", - "@synapsecns/sdk-router": "^0.3.6", + "@synapsecns/sdk-router": "^0.3.7", "bignumber": "^1.1.0", "ethers": "5.7.2", "express": "^4.18.2", diff --git a/packages/sdk-router/CHANGELOG.md b/packages/sdk-router/CHANGELOG.md index ece9f6bff4..055b6bd60a 100644 --- a/packages/sdk-router/CHANGELOG.md +++ b/packages/sdk-router/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.3.7](https://github.com/synapsecns/sanguine/compare/@synapsecns/sdk-router@0.3.6...@synapsecns/sdk-router@0.3.7) (2023-12-27) + +**Note:** Version bump only for package @synapsecns/sdk-router + + + + + ## [0.3.6](https://github.com/synapsecns/sanguine/compare/@synapsecns/sdk-router@0.3.5...@synapsecns/sdk-router@0.3.6) (2023-12-22) **Note:** Version bump only for package @synapsecns/sdk-router diff --git a/packages/sdk-router/package.json b/packages/sdk-router/package.json index be75147e12..2d11897066 100644 --- a/packages/sdk-router/package.json +++ b/packages/sdk-router/package.json @@ -1,7 +1,7 @@ { "name": "@synapsecns/sdk-router", "description": "An SDK for interacting with the Synapse Protocol", - "version": "0.3.6", + "version": "0.3.7", "license": "MIT", "main": "dist/index.js", "typings": "dist/index.d.ts", diff --git a/packages/synapse-interface/CHANGELOG.md b/packages/synapse-interface/CHANGELOG.md index d195a89029..97889cc1fc 100644 --- a/packages/synapse-interface/CHANGELOG.md +++ b/packages/synapse-interface/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.1.217](https://github.com/synapsecns/sanguine/compare/@synapsecns/synapse-interface@0.1.216...@synapsecns/synapse-interface@0.1.217) (2023-12-27) + +**Note:** Version bump only for package @synapsecns/synapse-interface + + + + + ## [0.1.216](https://github.com/synapsecns/sanguine/compare/@synapsecns/synapse-interface@0.1.215...@synapsecns/synapse-interface@0.1.216) (2023-12-26) **Note:** Version bump only for package @synapsecns/synapse-interface diff --git a/packages/synapse-interface/package.json b/packages/synapse-interface/package.json index 0ee1d420c7..9b8ea182ae 100644 --- a/packages/synapse-interface/package.json +++ b/packages/synapse-interface/package.json @@ -1,6 +1,6 @@ { "name": "@synapsecns/synapse-interface", - "version": "0.1.216", + "version": "0.1.217", "private": true, "engines": { "node": ">=16.0.0" @@ -42,7 +42,7 @@ "@reduxjs/toolkit": "^1.9.5", "@rtk-query/graphql-request-base-query": "^2.2.0", "@segment/analytics-next": "^1.53.0", - "@synapsecns/sdk-router": "^0.3.6", + "@synapsecns/sdk-router": "^0.3.7", "@tailwindcss/aspect-ratio": "^0.4.2", "@tailwindcss/forms": "^0.5.3", "@tailwindcss/line-clamp": "^0.4.2", From 513723b97fc9028a7ac89dd5d526344c41ba81b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CF=87=C2=B2?= <88190723+ChiTimesChi@users.noreply.github.com> Date: Wed, 27 Dec 2023 19:51:38 +0300 Subject: [PATCH 27/29] SDK: further generalize modules (#1717) * allRouterSets -> allModuleSets * Use `.find()` for getting the Module Set * Simplify routerAddress -> module mapping * Move `finalizeBridgeRoute` to `ModuleSet` * calculateDeadline -> applyOptionalDeadline * Use different default periods for modules --- .../sdk-router/src/module/synapseModuleSet.ts | 58 ++++++++++++++-- packages/sdk-router/src/operations/bridge.ts | 69 +++++++++---------- packages/sdk-router/src/operations/swap.ts | 4 +- packages/sdk-router/src/router/routerSet.ts | 55 +++++++-------- packages/sdk-router/src/sdk.test.ts | 8 +-- packages/sdk-router/src/sdk.ts | 6 +- .../sdk-router/src/utils/deadlines.test.ts | 37 +++------- packages/sdk-router/src/utils/deadlines.ts | 11 ++- 8 files changed, 133 insertions(+), 115 deletions(-) diff --git a/packages/sdk-router/src/module/synapseModuleSet.ts b/packages/sdk-router/src/module/synapseModuleSet.ts index 6d65b53a85..a0937bd5b6 100644 --- a/packages/sdk-router/src/module/synapseModuleSet.ts +++ b/packages/sdk-router/src/module/synapseModuleSet.ts @@ -1,8 +1,10 @@ import { BigNumber } from '@ethersproject/bignumber' +import invariant from 'tiny-invariant' import { BigintIsh } from '../constants' -import { BridgeQuote, BridgeRoute } from './types' +import { BridgeQuote, BridgeRoute, FeeConfig } from './types' import { SynapseModule } from './synapseModule' +import { applyOptionalDeadline } from '../utils/deadlines' export abstract class SynapseModuleSet { abstract readonly bridgeModuleName: string @@ -106,16 +108,62 @@ export abstract class SynapseModuleSet { amountIn: BigintIsh ): Promise + /** + * Retrieves the fee data for a given bridge route. + * + * @param bridgeRoute - The bridge route to get fee data for. + * @returns A promise that resolves to the fee data. + */ + abstract getFeeData(bridgeRoute: BridgeRoute): Promise<{ + feeAmount: BigNumber + feeConfig: FeeConfig + }> + + /** + * Returns the default deadline periods for this bridge module. + * + * @returns The default deadline periods. + */ + abstract getDefaultPeriods(): { + originPeriod: number + destPeriod: number + } + /** * Finalizes the bridge route by getting fee data and setting default deadlines. * * @param destChainId - The ID of the destination chain. * @param bridgeRoute - Bridge route to finalize. - * @param deadline - The deadline to use on the origin chain (default 10 mins). + * @param originDeadline - The deadline to use on the origin chain (default depends on the module). + * @param destDeadline - The deadline to use on the destination chain (default depends on the module). * @returns The finalized quote with fee data and deadlines. */ - abstract finalizeBridgeRoute( + async finalizeBridgeRoute( bridgeRoute: BridgeRoute, - deadline?: BigNumber - ): Promise + originDeadline?: BigNumber, + destDeadline?: BigNumber + ): Promise { + // Check that route is supported on both chains + const originModule = this.getExistingModule(bridgeRoute.originChainId) + this.getExistingModule(bridgeRoute.destChainId) + invariant( + bridgeRoute.bridgeModuleName === this.bridgeModuleName, + 'Invalid bridge module name' + ) + const { originQuery, destQuery } = bridgeRoute + const { originPeriod, destPeriod } = this.getDefaultPeriods() + originQuery.deadline = applyOptionalDeadline(originDeadline, originPeriod) + destQuery.deadline = applyOptionalDeadline(destDeadline, destPeriod) + const { feeAmount, feeConfig } = await this.getFeeData(bridgeRoute) + return { + feeAmount, + feeConfig, + routerAddress: originModule.address, + maxAmountOut: destQuery.minAmountOut, + originQuery, + destQuery, + estimatedTime: this.getEstimatedTime(bridgeRoute.originChainId), + bridgeModuleName: bridgeRoute.bridgeModuleName, + } + } } diff --git a/packages/sdk-router/src/operations/bridge.ts b/packages/sdk-router/src/operations/bridge.ts index 3bbe789d3a..09058dd4ab 100644 --- a/packages/sdk-router/src/operations/bridge.ts +++ b/packages/sdk-router/src/operations/bridge.ts @@ -4,8 +4,7 @@ import { BigNumber, PopulatedTransaction } from 'ethers' import { BigintIsh } from '../constants' import { SynapseSDK } from '../sdk' import { handleNativeToken } from '../utils/handleNativeToken' -import { BridgeQuote, Query } from '../module' -import { RouterSet } from '../router' +import { BridgeQuote, SynapseModuleSet, Query } from '../module' /** * Executes a bridge operation between two different chains. Depending on the origin router address, the operation @@ -41,20 +40,14 @@ export async function bridge( 'Origin chainId cannot be equal to destination chainId' ) token = handleNativeToken(token) - // Get Router instance for given chain and address - const router = - this.synapseRouterSet.getModuleWithAddress( - originChainId, - originRouterAddress - ) ?? - this.synapseCCTPRouterSet.getModuleWithAddress( - originChainId, - originRouterAddress - ) - // Throw if Router is not found - invariant(router, 'Invalid router address') - // Ask the Router to populate the bridge transaction - return router.bridge(to, destChainId, token, amount, originQuery, destQuery) + // Find the module that is using the given router address + const module = this.allModuleSets + .map((set) => set.getModuleWithAddress(originChainId, originRouterAddress)) + .find(Boolean) + if (!module) { + throw new Error('Invalid router address') + } + return module.bridge(to, destChainId, token, amount, originQuery, destQuery) } /** @@ -135,8 +128,8 @@ export async function allBridgeQuotes( tokenOut = handleNativeToken(tokenOut) tokenIn = handleNativeToken(tokenIn) const allQuotes: BridgeQuote[][] = await Promise.all( - this.allRouterSets.map(async (routerSet) => { - const routes = await routerSet.getBridgeRoutes( + this.allModuleSets.map(async (moduleSet) => { + const routes = await moduleSet.getBridgeRoutes( originChainId, destChainId, tokenIn, @@ -147,7 +140,7 @@ export async function allBridgeQuotes( return Promise.all( routes .filter((route) => route.destQuery.minAmountOut.gt(0)) - .map((route) => routerSet.finalizeBridgeRoute(route, deadline)) + .map((route) => moduleSet.finalizeBridgeRoute(route, deadline)) ) }) ) @@ -173,7 +166,7 @@ export async function getSynapseTxId( bridgeModuleName: string, txHash: string ): Promise { - return getRouterSet + return getModuleSet .call(this, bridgeModuleName) .getSynapseTxId(originChainId, txHash) } @@ -192,7 +185,7 @@ export async function getBridgeTxStatus( bridgeModuleName: string, synapseTxId: string ): Promise { - return getRouterSet + return getModuleSet .call(this, bridgeModuleName) .getBridgeTxStatus(destChainId, synapseTxId) } @@ -208,13 +201,13 @@ export function getBridgeModuleName( this: SynapseSDK, eventName: string ): string { - if (this.synapseRouterSet.allEvents.includes(eventName)) { - return this.synapseRouterSet.bridgeModuleName - } - if (this.synapseCCTPRouterSet.allEvents.includes(eventName)) { - return this.synapseCCTPRouterSet.bridgeModuleName + const moduleSet = this.allModuleSets.find((set) => + set.allEvents.includes(eventName) + ) + if (!moduleSet) { + throw new Error('Unknown event') } - throw new Error('Unknown event') + return moduleSet.bridgeModuleName } /** @@ -232,7 +225,7 @@ export function getEstimatedTime( originChainId: number, bridgeModuleName: string ): number { - return getRouterSet + return getModuleSet .call(this, bridgeModuleName) .getEstimatedTime(originChainId) } @@ -252,21 +245,21 @@ export async function getBridgeGas( } /** - * Extracts the RouterSet from the SynapseSDK based on the given bridge module name. + * Extracts the SynapseModuleSet from the SynapseSDK based on the given bridge module name. * * @param bridgeModuleName - The name of the bridge module, SynapseBridge or SynapseCCTP. - * @returns The corresponding RouterSet. + * @returns The corresponding SynapseModuleSet. * @throws Will throw an error if the bridge module is unknown. */ -export function getRouterSet( +export function getModuleSet( this: SynapseSDK, bridgeModuleName: string -): RouterSet { - if (this.synapseRouterSet.bridgeModuleName === bridgeModuleName) { - return this.synapseRouterSet - } - if (this.synapseCCTPRouterSet.bridgeModuleName === bridgeModuleName) { - return this.synapseCCTPRouterSet +): SynapseModuleSet { + const moduleSet = this.allModuleSets.find( + (set) => set.bridgeModuleName === bridgeModuleName + ) + if (!moduleSet) { + throw new Error('Unknown bridge module') } - throw new Error('Unknown bridge module') + return moduleSet } diff --git a/packages/sdk-router/src/operations/swap.ts b/packages/sdk-router/src/operations/swap.ts index 7f74947077..4f6e59b3b9 100644 --- a/packages/sdk-router/src/operations/swap.ts +++ b/packages/sdk-router/src/operations/swap.ts @@ -5,7 +5,7 @@ import { BigintIsh } from '../constants' import { Query, SwapQuote } from '../module' import { handleNativeToken } from '../utils/handleNativeToken' import { SynapseSDK } from '../sdk' -import { getOriginDeadline } from '../utils/deadlines' +import { TEN_MINUTES, applyOptionalDeadline } from '../utils/deadlines' /** * Performs a swap through a Synapse Router. @@ -61,6 +61,6 @@ export async function swapQuote( if (query.minAmountOut.isZero()) { throw Error('No queries found for this route') } - query.deadline = getOriginDeadline(deadline) + query.deadline = applyOptionalDeadline(deadline, TEN_MINUTES) return { routerAddress, maxAmountOut, query } } diff --git a/packages/sdk-router/src/router/routerSet.ts b/packages/sdk-router/src/router/routerSet.ts index 363033f341..b3282961d5 100644 --- a/packages/sdk-router/src/router/routerSet.ts +++ b/packages/sdk-router/src/router/routerSet.ts @@ -5,14 +5,14 @@ import invariant from 'tiny-invariant' import { Router } from './router' import { AddressMap, BigintIsh } from '../constants' import { DestRequest } from './types' -import { ONE_WEEK, TEN_MINUTES, calculateDeadline } from '../utils/deadlines' import { - BridgeQuote, BridgeRoute, + FeeConfig, SynapseModule, SynapseModuleSet, } from '../module' import { hasComplexBridgeAction } from '../module/query' +import { ONE_WEEK, TEN_MINUTES } from '../utils/deadlines' export type ChainProvider = { chainId: number @@ -145,40 +145,33 @@ export abstract class RouterSet extends SynapseModuleSet { } /** - * @inheritdoc SynapseModuleSet.finalizeBridgeRoute + * @inheritdoc SynapseModuleSet.getFeeData */ - public async finalizeBridgeRoute( - bridgeRoute: BridgeRoute, - deadline?: BigNumber - ): Promise { - const originRouter = this.routers[bridgeRoute.originChainId] + async getFeeData(bridgeRoute: BridgeRoute): Promise<{ + feeAmount: BigNumber + feeConfig: FeeConfig + }> { const destRouter = this.routers[bridgeRoute.destChainId] - invariant(originRouter && destRouter, 'Route not supported') - invariant( - bridgeRoute.bridgeModuleName === this.bridgeModuleName, - 'Invalid bridge module name' - ) - const { originQuery, destQuery, bridgeToken } = bridgeRoute - // Set origin deadline to 10 mins if not provided - originQuery.deadline = deadline ?? calculateDeadline(TEN_MINUTES) - // Destination deadline is always 1 week - destQuery.deadline = calculateDeadline(ONE_WEEK) + invariant(destRouter, 'Router not found') // Get fee data: for some Bridge contracts it will depend on the complexity of the bridge action - const { feeAmount, feeConfig } = await destRouter.getBridgeFees( - bridgeToken.token, - originQuery.minAmountOut, - hasComplexBridgeAction(destQuery) + return destRouter.getBridgeFees( + bridgeRoute.bridgeToken.token, + bridgeRoute.originQuery.minAmountOut, + hasComplexBridgeAction(bridgeRoute.destQuery) ) - const estimatedTime = this.getEstimatedTime(bridgeRoute.originChainId) + } + + /** + * @inheritdoc SynapseModuleSet.getDefaultPeriods + */ + getDefaultPeriods(): { + originPeriod: number + destPeriod: number + } { + // Use the same default periods for SynapseBridge and SynapseCCTP modules return { - feeAmount, - feeConfig, - routerAddress: originRouter.address, - maxAmountOut: destQuery.minAmountOut, - originQuery, - destQuery, - estimatedTime, - bridgeModuleName: bridgeRoute.bridgeModuleName, + originPeriod: TEN_MINUTES, + destPeriod: ONE_WEEK, } } } diff --git a/packages/sdk-router/src/sdk.test.ts b/packages/sdk-router/src/sdk.test.ts index 0bd32477e6..c22c929d44 100644 --- a/packages/sdk-router/src/sdk.test.ts +++ b/packages/sdk-router/src/sdk.test.ts @@ -1411,20 +1411,20 @@ describe('SynapseSDK', () => { [SupportedChainId.ARBITRUM, SupportedChainId.ETH], [arbProvider, ethProvider] ) - describe('getRouterSet', () => { + describe('getModuleSet', () => { it('Returns correct set for SynapseBridge', () => { - const routerSet = operations.getRouterSet.call(synapse, 'SynapseBridge') + const routerSet = operations.getModuleSet.call(synapse, 'SynapseBridge') expect(routerSet).toEqual(synapse.synapseRouterSet) }) it('Returns correct set for SynapseCCTP', () => { - const routerSet = operations.getRouterSet.call(synapse, 'SynapseCCTP') + const routerSet = operations.getModuleSet.call(synapse, 'SynapseCCTP') expect(routerSet).toEqual(synapse.synapseCCTPRouterSet) }) it('Throws when bridge module name is invalid', () => { expect(() => - operations.getRouterSet.call(synapse, 'SynapseSynapse') + operations.getModuleSet.call(synapse, 'SynapseSynapse') ).toThrow('Unknown bridge module') }) }) diff --git a/packages/sdk-router/src/sdk.ts b/packages/sdk-router/src/sdk.ts index c2ef87a802..59ad531b02 100644 --- a/packages/sdk-router/src/sdk.ts +++ b/packages/sdk-router/src/sdk.ts @@ -2,7 +2,6 @@ import { Provider } from '@ethersproject/abstract-provider' import invariant from 'tiny-invariant' import { - RouterSet, SynapseRouterSet, SynapseCCTPRouterSet, ChainProvider, @@ -11,6 +10,7 @@ import { import * as operations from './operations' import { ETH_NATIVE_TOKEN_ADDRESS } from './utils/handleNativeToken' import { + SynapseModuleSet, Query, applySlippage, applySlippageInBips, @@ -18,7 +18,7 @@ import { } from './module' class SynapseSDK { - public allRouterSets: RouterSet[] + public allModuleSets: SynapseModuleSet[] public synapseRouterSet: SynapseRouterSet public synapseCCTPRouterSet: SynapseCCTPRouterSet public providers: { [chainId: number]: Provider } @@ -48,7 +48,7 @@ class SynapseSDK { // Initialize SynapseRouterSet and SynapseCCTPRouterSet this.synapseRouterSet = new SynapseRouterSet(chainProviders) this.synapseCCTPRouterSet = new SynapseCCTPRouterSet(chainProviders) - this.allRouterSets = [this.synapseRouterSet, this.synapseCCTPRouterSet] + this.allModuleSets = [this.synapseRouterSet, this.synapseCCTPRouterSet] } // Define Bridge operations diff --git a/packages/sdk-router/src/utils/deadlines.test.ts b/packages/sdk-router/src/utils/deadlines.test.ts index 52bcc506bb..f9418f4231 100644 --- a/packages/sdk-router/src/utils/deadlines.test.ts +++ b/packages/sdk-router/src/utils/deadlines.test.ts @@ -1,45 +1,30 @@ import { BigNumber } from '@ethersproject/bignumber' -import { - calculateDeadline, - getDestinationDeadline, - getOriginDeadline, -} from './deadlines' +import { applyOptionalDeadline, calculateDeadline } from './deadlines' describe('deadlines', () => { // Something good happened on this day Date.now = jest.fn(() => Date.parse('2021-08-29')) - it('calculates correct deadlines', () => { - const seconds = 1337 - const deadline = calculateDeadline(seconds) - const now = Math.floor(Date.now() / 1000) - expect(deadline.toNumber()).toBe(now + seconds) - }) - - describe('getOriginDeadline', () => { - it('returns the deadline if it is defined', () => { - const deadline = BigNumber.from(1337) - expect(getOriginDeadline(deadline)).toBe(deadline) - }) - - it('Uses 10 minutes if deadline is undefined', () => { - const deadline = getOriginDeadline() + describe('calculateDeadline', () => { + it('calculates correct deadlines', () => { + const seconds = 1337 + const deadline = calculateDeadline(seconds) const now = Math.floor(Date.now() / 1000) - expect(deadline.toNumber()).toBe(now + 10 * 60) + expect(deadline.toNumber()).toBe(now + seconds) }) }) - describe('getDestinationDeadline', () => { + describe('applyOptionalDeadline', () => { it('returns the deadline if it is defined', () => { const deadline = BigNumber.from(1337) - expect(getDestinationDeadline(deadline)).toBe(deadline) + expect(applyOptionalDeadline(deadline, 1234)).toBe(deadline) }) - it('Uses 1 week if deadline is undefined', () => { - const deadline = getDestinationDeadline() + it('applies the default period if the deadline is undefined', () => { + const deadline = applyOptionalDeadline(undefined, 1234) const now = Math.floor(Date.now() / 1000) - expect(deadline.toNumber()).toBe(now + 7 * 24 * 60 * 60) + expect(deadline.toNumber()).toBe(now + 1234) }) }) }) diff --git a/packages/sdk-router/src/utils/deadlines.ts b/packages/sdk-router/src/utils/deadlines.ts index f2e77f3682..2723b080a0 100644 --- a/packages/sdk-router/src/utils/deadlines.ts +++ b/packages/sdk-router/src/utils/deadlines.ts @@ -8,10 +8,9 @@ export const calculateDeadline = (seconds: number) => { return BigNumber.from(Math.floor(Date.now() / 1000) + seconds) } -export const getOriginDeadline = (deadline?: BigNumber) => { - return deadline ?? calculateDeadline(TEN_MINUTES) -} - -export const getDestinationDeadline = (deadline?: BigNumber) => { - return deadline ?? calculateDeadline(ONE_WEEK) +export const applyOptionalDeadline = ( + deadline: BigNumber | undefined, + defaultPeriod: number +): BigNumber => { + return deadline ?? calculateDeadline(defaultPeriod) } From f14f58a3d9802e34084bf4441b87bf5e57200fdc Mon Sep 17 00:00:00 2001 From: ChiTimesChi Date: Wed, 27 Dec 2023 16:55:01 +0000 Subject: [PATCH 28/29] Publish - @synapsecns/rest-api@1.0.35 - @synapsecns/sdk-router@0.3.8 - @synapsecns/synapse-interface@0.1.218 --- packages/rest-api/CHANGELOG.md | 8 ++++++++ packages/rest-api/package.json | 4 ++-- packages/sdk-router/CHANGELOG.md | 8 ++++++++ packages/sdk-router/package.json | 2 +- packages/synapse-interface/CHANGELOG.md | 8 ++++++++ packages/synapse-interface/package.json | 4 ++-- 6 files changed, 29 insertions(+), 5 deletions(-) diff --git a/packages/rest-api/CHANGELOG.md b/packages/rest-api/CHANGELOG.md index 8ef2ef2c93..ba00656b19 100644 --- a/packages/rest-api/CHANGELOG.md +++ b/packages/rest-api/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.35](https://github.com/synapsecns/sanguine/compare/@synapsecns/rest-api@1.0.34...@synapsecns/rest-api@1.0.35) (2023-12-27) + +**Note:** Version bump only for package @synapsecns/rest-api + + + + + ## [1.0.34](https://github.com/synapsecns/sanguine/compare/@synapsecns/rest-api@1.0.33...@synapsecns/rest-api@1.0.34) (2023-12-27) **Note:** Version bump only for package @synapsecns/rest-api diff --git a/packages/rest-api/package.json b/packages/rest-api/package.json index 9b46a079b0..6408b32028 100644 --- a/packages/rest-api/package.json +++ b/packages/rest-api/package.json @@ -1,6 +1,6 @@ { "name": "@synapsecns/rest-api", - "version": "1.0.34", + "version": "1.0.35", "private": "true", "engines": { "node": ">=16.0.0" @@ -23,7 +23,7 @@ "@ethersproject/bignumber": "^5.7.0", "@ethersproject/providers": "^5.7.2", "@ethersproject/units": "5.7.0", - "@synapsecns/sdk-router": "^0.3.7", + "@synapsecns/sdk-router": "^0.3.8", "bignumber": "^1.1.0", "ethers": "5.7.2", "express": "^4.18.2", diff --git a/packages/sdk-router/CHANGELOG.md b/packages/sdk-router/CHANGELOG.md index 055b6bd60a..d991e23146 100644 --- a/packages/sdk-router/CHANGELOG.md +++ b/packages/sdk-router/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.3.8](https://github.com/synapsecns/sanguine/compare/@synapsecns/sdk-router@0.3.7...@synapsecns/sdk-router@0.3.8) (2023-12-27) + +**Note:** Version bump only for package @synapsecns/sdk-router + + + + + ## [0.3.7](https://github.com/synapsecns/sanguine/compare/@synapsecns/sdk-router@0.3.6...@synapsecns/sdk-router@0.3.7) (2023-12-27) **Note:** Version bump only for package @synapsecns/sdk-router diff --git a/packages/sdk-router/package.json b/packages/sdk-router/package.json index 2d11897066..4ac74732e1 100644 --- a/packages/sdk-router/package.json +++ b/packages/sdk-router/package.json @@ -1,7 +1,7 @@ { "name": "@synapsecns/sdk-router", "description": "An SDK for interacting with the Synapse Protocol", - "version": "0.3.7", + "version": "0.3.8", "license": "MIT", "main": "dist/index.js", "typings": "dist/index.d.ts", diff --git a/packages/synapse-interface/CHANGELOG.md b/packages/synapse-interface/CHANGELOG.md index 97889cc1fc..af0c98f4db 100644 --- a/packages/synapse-interface/CHANGELOG.md +++ b/packages/synapse-interface/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.1.218](https://github.com/synapsecns/sanguine/compare/@synapsecns/synapse-interface@0.1.217...@synapsecns/synapse-interface@0.1.218) (2023-12-27) + +**Note:** Version bump only for package @synapsecns/synapse-interface + + + + + ## [0.1.217](https://github.com/synapsecns/sanguine/compare/@synapsecns/synapse-interface@0.1.216...@synapsecns/synapse-interface@0.1.217) (2023-12-27) **Note:** Version bump only for package @synapsecns/synapse-interface diff --git a/packages/synapse-interface/package.json b/packages/synapse-interface/package.json index 9b8ea182ae..f7818f00c4 100644 --- a/packages/synapse-interface/package.json +++ b/packages/synapse-interface/package.json @@ -1,6 +1,6 @@ { "name": "@synapsecns/synapse-interface", - "version": "0.1.217", + "version": "0.1.218", "private": true, "engines": { "node": ">=16.0.0" @@ -42,7 +42,7 @@ "@reduxjs/toolkit": "^1.9.5", "@rtk-query/graphql-request-base-query": "^2.2.0", "@segment/analytics-next": "^1.53.0", - "@synapsecns/sdk-router": "^0.3.7", + "@synapsecns/sdk-router": "^0.3.8", "@tailwindcss/aspect-ratio": "^0.4.2", "@tailwindcss/forms": "^0.5.3", "@tailwindcss/line-clamp": "^0.4.2", From b6d2349214baa2e13ae132e1d6fc6aeb5fae94f3 Mon Sep 17 00:00:00 2001 From: dwasse Date: Thu, 28 Dec 2023 14:53:56 -0600 Subject: [PATCH 29/29] Fix: attempt to fix v+27 (#1720) --- agents/types/utils.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/agents/types/utils.go b/agents/types/utils.go index 0c789f48b6..9825a4be57 100644 --- a/agents/types/utils.go +++ b/agents/types/utils.go @@ -3,6 +3,7 @@ package types import ( "context" "fmt" + "math/big" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" @@ -27,9 +28,11 @@ func signEncoder(ctx context.Context, signer signer.Signer, encoder Encoder, sal } // Sign the message. - signature, err := signer.SignMessage(ctx, core.BytesToSlice(hashedDigest), false) + sig, err := signer.SignMessage(ctx, core.BytesToSlice(hashedDigest), false) if err != nil { return nil, nil, common.Hash{}, fmt.Errorf("could not sign: %w", err) } - return signature, encoded, hashedDigest, nil + + sig = NewSignature(new(big.Int).Add(big.NewInt(27), sig.V()), sig.R(), sig.S()) + return sig, encoded, hashedDigest, nil }