From 46da6d789c126c6678ece436f098af738c33e27a Mon Sep 17 00:00:00 2001 From: yogurtandjam Date: Mon, 14 Oct 2024 14:34:14 -0400 Subject: [PATCH] feat: useSkipClient hook [OTE-857] --- package.json | 1 + pnpm-lock.yaml | 281 +++++++++++++++++++++++++++++ src/App.tsx | 2 + src/constants/solana.ts | 5 + src/hooks/transfers/skipClient.tsx | 44 +++++ src/lib/wagmi.ts | 31 ++-- 6 files changed, 353 insertions(+), 11 deletions(-) create mode 100644 src/constants/solana.ts create mode 100644 src/hooks/transfers/skipClient.tsx diff --git a/package.json b/package.json index 903f972d2c..a8bf89af8a 100644 --- a/package.json +++ b/package.json @@ -98,6 +98,7 @@ "@scure/bip32": "^1.3.0", "@scure/bip39": "^1.2.0", "@skip-router/core": "^5.1.0", + "@skip-go/client": "0.10.3", "@solana/web3.js": "^1.93.0", "@statsig/js-client": "1.4.0", "@statsig/react-bindings": "1.4.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a35857f0c2..16d387f34a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -149,6 +149,9 @@ dependencies: '@scure/bip39': specifier: ^1.2.0 version: 1.2.1 + '@skip-go/client': + specifier: 0.10.3 + version: 0.10.3(@types/react@18.3.3)(react-dom@18.2.0)(react@18.2.0)(typescript@5.1.3) '@skip-router/core': specifier: ^5.1.0 version: 5.1.0(@types/react@18.3.3)(chain-registry@1.63.9)(react-dom@18.2.0)(react@18.2.0)(typescript@5.1.3) @@ -2335,6 +2338,10 @@ packages: resolution: {integrity: sha512-adtjeJe9mZjNcXGbpjRlYhsJvClvRDcWjcnsOsCP5Sg8GpmPY3qbvtHsmYxcBT2zv46HozceUgI9UBL5fnGYZg==} dev: false + /@chain-registry/types@0.50.0: + resolution: {integrity: sha512-77TY/i3lPPQRQGBl0PFrb8+k3rbjIb4LOSsmK49mlMSPUNeJ3Wcx3Donnm2XvdpQDH5aeCofWOPonZ2/3XoibQ==} + dev: false + /@coinbase/wallet-sdk@3.9.3: resolution: {integrity: sha512-N/A2DRIf0Y3PHc1XAMvbBUu4zisna6qAdqABMZwBMNEfWrXpAwx16pZGkYCLGE+Rvv1edbcB2LYDRnACNcmCiw==} dependencies: @@ -2583,6 +2590,15 @@ packages: '@cosmjs/utils': 0.32.3 dev: false + /@cosmjs/amino@0.32.4: + resolution: {integrity: sha512-zKYOt6hPy8obIFtLie/xtygCkH9ZROiQ12UHfKsOkWaZfPQUvVbtgmu6R4Kn1tFLI/SRkw7eqhaogmW/3NYu/Q==} + dependencies: + '@cosmjs/crypto': 0.32.4 + '@cosmjs/encoding': 0.32.4 + '@cosmjs/math': 0.32.4 + '@cosmjs/utils': 0.32.4 + dev: false + /@cosmjs/cosmwasm-stargate@0.31.3: resolution: {integrity: sha512-Uv9TmCn3650gdFeZm7SEfUZF3uX3lfJfFhXOk6I2ZLr/FrKximnlb+vwAfZaZnWYvlA7qrKtHIjeRNHvT23zcw==} dependencies: @@ -2622,6 +2638,25 @@ packages: - utf-8-validate dev: false + /@cosmjs/cosmwasm-stargate@0.32.4: + resolution: {integrity: sha512-Fuo9BGEiB+POJ5WeRyBGuhyKR1ordvxZGLPuPosFJOH9U0gKMgcjwKMCgAlWFkMlHaTB+tNdA8AifWiHrI7VgA==} + dependencies: + '@cosmjs/amino': 0.32.4 + '@cosmjs/crypto': 0.32.4 + '@cosmjs/encoding': 0.32.4 + '@cosmjs/math': 0.32.4 + '@cosmjs/proto-signing': 0.32.4 + '@cosmjs/stargate': 0.32.4 + '@cosmjs/tendermint-rpc': 0.32.4 + '@cosmjs/utils': 0.32.4 + cosmjs-types: 0.9.0 + pako: 2.1.0 + transitivePeerDependencies: + - bufferutil + - debug + - utf-8-validate + dev: false + /@cosmjs/crypto@0.27.1: resolution: {integrity: sha512-vbcxwSt99tIYJg8Spp00wc3zx72qx+pY3ozGuBN8gAvySnagK9dQ/jHwtWQWdammmdD6oW+75WfIHZ+gNa+Ybg==} dependencies: @@ -2673,6 +2708,18 @@ packages: libsodium-wrappers-sumo: 0.7.11 dev: false + /@cosmjs/crypto@0.32.4: + resolution: {integrity: sha512-zicjGU051LF1V9v7bp8p7ovq+VyC91xlaHdsFOTo2oVry3KQikp8L/81RkXmUIT8FxMwdx1T7DmFwVQikcSDIw==} + dependencies: + '@cosmjs/encoding': 0.32.4 + '@cosmjs/math': 0.32.4 + '@cosmjs/utils': 0.32.4 + '@noble/hashes': 1.4.0 + bn.js: 5.2.1 + elliptic: 6.5.5 + libsodium-wrappers-sumo: 0.7.11 + dev: false + /@cosmjs/encoding@0.27.1: resolution: {integrity: sha512-rayLsA0ojHeniaRfWWcqSsrE/T1rl1gl0OXVNtXlPwLJifKBeLEefGbOUiAQaT0wgJ8VNGBazVtAZBpJidfDhw==} dependencies: @@ -2705,6 +2752,14 @@ packages: readonly-date: 1.0.0 dev: false + /@cosmjs/encoding@0.32.4: + resolution: {integrity: sha512-tjvaEy6ZGxJchiizzTn7HVRiyTg1i4CObRRaTRPknm5EalE13SV+TCHq38gIDfyUeden4fCuaBVEdBR5+ti7Hw==} + dependencies: + base64-js: 1.5.1 + bech32: 1.1.4 + readonly-date: 1.0.0 + dev: false + /@cosmjs/json-rpc@0.31.3: resolution: {integrity: sha512-7LVYerXjnm69qqYR3uA6LGCrBW2EO5/F7lfJxAmY+iII2C7xO3a0vAjMSt5zBBh29PXrJVS6c2qRP22W1Le2Wg==} dependencies: @@ -2726,6 +2781,13 @@ packages: xstream: 11.14.0 dev: false + /@cosmjs/json-rpc@0.32.4: + resolution: {integrity: sha512-/jt4mBl7nYzfJ2J/VJ+r19c92mUKF0Lt0JxM3MXEJl7wlwW5haHAWtzRujHkyYMXOwIR+gBqT2S0vntXVBRyhQ==} + dependencies: + '@cosmjs/stream': 0.32.4 + xstream: 11.14.0 + dev: false + /@cosmjs/launchpad@0.27.1: resolution: {integrity: sha512-DcFwGD/z5PK8CzO2sojDxa+Be9EIEtRZb2YawgVnw2Ht/p5FlNv+OVo8qlishpBdalXEN7FvQ1dVeDFEe9TuJw==} dependencies: @@ -2764,6 +2826,12 @@ packages: bn.js: 5.2.1 dev: false + /@cosmjs/math@0.32.4: + resolution: {integrity: sha512-++dqq2TJkoB8zsPVYCvrt88oJWsy1vMOuSOKcdlnXuOA/ASheTJuYy4+oZlTQ3Fr8eALDLGGPhJI02W2HyAQaw==} + dependencies: + bn.js: 5.2.1 + dev: false + /@cosmjs/proto-signing@0.31.3: resolution: {integrity: sha512-24+10/cGl6lLS4VCrGTCJeDRPQTn1K5JfknzXzDIHOx8THR31JxA7/HV5eWGHqWgAbudA7ccdSvEK08lEHHtLA==} dependencies: @@ -2798,6 +2866,17 @@ packages: cosmjs-types: 0.9.0 dev: false + /@cosmjs/proto-signing@0.32.4: + resolution: {integrity: sha512-QdyQDbezvdRI4xxSlyM1rSVBO2st5sqtbEIl3IX03uJ7YiZIQHyv6vaHVf1V4mapusCqguiHJzm4N4gsFdLBbQ==} + dependencies: + '@cosmjs/amino': 0.32.4 + '@cosmjs/crypto': 0.32.4 + '@cosmjs/encoding': 0.32.4 + '@cosmjs/math': 0.32.4 + '@cosmjs/utils': 0.32.4 + cosmjs-types: 0.9.0 + dev: false + /@cosmjs/socket@0.31.3: resolution: {integrity: sha512-aqrDGGi7os/hsz5p++avI4L0ZushJ+ItnzbqA7C6hamFSCJwgOkXaOUs+K9hXZdX4rhY7rXO4PH9IH8q09JkTw==} dependencies: @@ -2834,6 +2913,18 @@ packages: - utf-8-validate dev: false + /@cosmjs/socket@0.32.4: + resolution: {integrity: sha512-davcyYziBhkzfXQTu1l5NrpDYv0K9GekZCC9apBRvL1dvMc9F/ygM7iemHjUA+z8tJkxKxrt/YPjJ6XNHzLrkw==} + dependencies: + '@cosmjs/stream': 0.32.4 + isomorphic-ws: 4.0.1(ws@7.5.9) + ws: 7.5.9 + xstream: 11.14.0 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + dev: false + /@cosmjs/stargate@0.31.3: resolution: {integrity: sha512-53NxnzmB9FfXpG4KjOUAYAvWLYKdEmZKsutcat/u2BrDXNZ7BN8jim/ENcpwXfs9/Og0K24lEIdvA4gsq3JDQw==} dependencies: @@ -2893,6 +2984,25 @@ packages: - utf-8-validate dev: false + /@cosmjs/stargate@0.32.4: + resolution: {integrity: sha512-usj08LxBSsPRq9sbpCeVdyLx2guEcOHfJS9mHGCLCXpdAPEIEQEtWLDpEUc0LEhWOx6+k/ChXTc5NpFkdrtGUQ==} + dependencies: + '@confio/ics23': 0.6.8 + '@cosmjs/amino': 0.32.4 + '@cosmjs/encoding': 0.32.4 + '@cosmjs/math': 0.32.4 + '@cosmjs/proto-signing': 0.32.4 + '@cosmjs/stream': 0.32.4 + '@cosmjs/tendermint-rpc': 0.32.4 + '@cosmjs/utils': 0.32.4 + cosmjs-types: 0.9.0 + xstream: 11.14.0 + transitivePeerDependencies: + - bufferutil + - debug + - utf-8-validate + dev: false + /@cosmjs/stream@0.31.3: resolution: {integrity: sha512-8keYyI7X0RjsLyVcZuBeNjSv5FA4IHwbFKx7H60NHFXszN8/MvXL6aZbNIvxtcIHHsW7K9QSQos26eoEWlAd+w==} dependencies: @@ -2911,6 +3021,12 @@ packages: xstream: 11.14.0 dev: false + /@cosmjs/stream@0.32.4: + resolution: {integrity: sha512-Gih++NYHEiP+oyD4jNEUxU9antoC0pFSg+33Hpp0JlHwH0wXhtD3OOKnzSfDB7OIoEbrzLJUpEjOgpCp5Z+W3A==} + dependencies: + xstream: 11.14.0 + dev: false + /@cosmjs/tendermint-rpc@0.31.3: resolution: {integrity: sha512-s3TiWkPCW4QceTQjpYqn4xttUJH36mTPqplMl+qyocdqk5+X5mergzExU/pHZRWQ4pbby8bnR7kMvG4OC1aZ8g==} dependencies: @@ -2968,6 +3084,25 @@ packages: - utf-8-validate dev: false + /@cosmjs/tendermint-rpc@0.32.4: + resolution: {integrity: sha512-MWvUUno+4bCb/LmlMIErLypXxy7ckUuzEmpufYYYd9wgbdCXaTaO08SZzyFM5PI8UJ/0S2AmUrgWhldlbxO8mw==} + dependencies: + '@cosmjs/crypto': 0.32.4 + '@cosmjs/encoding': 0.32.4 + '@cosmjs/json-rpc': 0.32.4 + '@cosmjs/math': 0.32.4 + '@cosmjs/socket': 0.32.4 + '@cosmjs/stream': 0.32.4 + '@cosmjs/utils': 0.32.4 + axios: 1.6.7 + readonly-date: 1.0.0 + xstream: 11.14.0 + transitivePeerDependencies: + - bufferutil + - debug + - utf-8-validate + dev: false + /@cosmjs/utils@0.27.1: resolution: {integrity: sha512-VG7QPDiMUzVPxRdJahDV8PXxVdnuAHiIuG56hldV4yPnOz/si/DLNd7VAUUA5923b6jS1Hhev0Hr6AhEkcxBMg==} dev: false @@ -2984,6 +3119,10 @@ packages: resolution: {integrity: sha512-WCZK4yksj2hBDz4w7xFZQTRZQ/RJhBX26uFHmmQFIcNUUVAihrLO+RerqJgk0dZqC42wstM9pEUQGtPmLcIYvg==} dev: false + /@cosmjs/utils@0.32.4: + resolution: {integrity: sha512-D1Yc+Zy8oL/hkUkFUL/bwxvuDBzRGpc4cF7/SkdhxX4iHpSLgdOuTt1mhCh9+kl6NQREy9t7SYZ6xeW5gFe60w==} + dev: false + /@cosmsnap/snapper@0.1.31: resolution: {integrity: sha512-Pf0a78YcAyKh805MCvnsm0cpky9ddvRhf/VF4okv0CiSUSsyE70vcIFVHhEsXN1RhuS0R1d8vn0Kwx8+KJkK5w==} engines: {node: '>=16.0.0'} @@ -3100,6 +3239,14 @@ packages: /@emotion/unitless@0.8.1: resolution: {integrity: sha512-KOEGMu6dmJZtpadb476IsZBclKvILjopjUii3V+7MnXIQCYh8W3NgNcgwo21n9LXZX6EDIKvqfjYxXebDwxKmQ==} + /@ensdomains/ens-validation@0.1.0: + resolution: {integrity: sha512-rbDh2K6GfqXvBcJUISaTTYEt3f079WA4ohTE5Lh4/8EaaPAk/9vk3EisMUQV2UVxeFIZQEEyRCIOmRTpqN0W7A==} + dev: false + + /@ensdomains/eth-ens-namehash@2.0.15: + resolution: {integrity: sha512-JRDFP6+Hczb1E0/HhIg0PONgBYasfGfDheujmfxaZaAv/NAH4jE6Kf48WbqfRZdxt4IZI3jl3Ri7sZ1nP09lgw==} + dev: false + /@esbuild/aix-ppc64@0.19.12: resolution: {integrity: sha512-bmoCYyWdEL3wDQIVbcyzRyeKLgk2WtWLTWz1ZIAZF/EGbNOwSA6ew3PftJ1PqMiOOGu0OyFMzG53L0zqIpPeNA==} engines: {node: '>=12'} @@ -4040,6 +4187,12 @@ packages: zod: 3.23.8 dev: false + /@initia/initia-registry@0.1.16: + resolution: {integrity: sha512-zqVa+fOZXxX0AzsNqIHCYU2sWr0+JICkj5Xaq4vw4kVPSey3mveU8dUFfdCcmfH8CXSeQ34wx8v1OIwQ3Fld6A==} + dependencies: + '@initia/initia-registry-types': 0.0.17 + dev: false + /@initia/initia-registry@0.1.9: resolution: {integrity: sha512-zXIP9Gk0OG4SJkcrileCHJNgZU8LyHzTHdcNO5bjEoxeuvM8mvlhsGQvKeJcefBcvhvIyeX5LOlSBCTeIofngg==} dependencies: @@ -4064,6 +4217,15 @@ packages: rxjs: 7.8.1 dev: false + /@injectivelabs/dmm-proto-ts@1.0.19: + resolution: {integrity: sha512-2FCzCziy1RhzmnkAVIU+Asby/GXAVQqKt5/o1s52j0LJXfJMpiCrV6soLfnjTebj61T+1WvJBPFoZCCiVYBpcw==} + dependencies: + '@injectivelabs/grpc-web': 0.0.1(google-protobuf@3.21.2) + google-protobuf: 3.21.2 + protobufjs: 7.3.2 + rxjs: 7.8.1 + dev: false + /@injectivelabs/dmm-proto-ts@1.0.20: resolution: {integrity: sha512-S9vGOAZbNNa+N5QDW2HcXn7ohvU/4qze6wELA9gF8zu8uWbE+UKWTqzkZ+B4XuG1MkJwoHL7pVcj3M+nC9Qe4A==} dependencies: @@ -4111,6 +4273,15 @@ packages: google-protobuf: 3.21.2 dev: false + /@injectivelabs/indexer-proto-ts@1.11.32: + resolution: {integrity: sha512-gCkbMlBq34MY2xZcauDEsCP0h5l/FgKMwCgJ8aWGaTkh27XBWpl1zvlreuWg/IpSvTPJZBoADW9KqixqyoBdJw==} + dependencies: + '@injectivelabs/grpc-web': 0.0.1(google-protobuf@3.21.2) + google-protobuf: 3.21.2 + protobufjs: 7.3.2 + rxjs: 7.8.1 + dev: false + /@injectivelabs/indexer-proto-ts@1.11.42: resolution: {integrity: sha512-6ejCpcWZWOSsELFIfUf2+xuJPOH+YdiJtwtB3d9x2H7dnrCBjXMxlPCSxoKEUbDH6w/lY2mO6TJm65rNy9piew==} dependencies: @@ -4120,6 +4291,15 @@ packages: rxjs: 7.8.1 dev: false + /@injectivelabs/mito-proto-ts@1.0.55: + resolution: {integrity: sha512-clFKpU/LCYvYiPg5PRjhVJFTxKcfJHzaj5saJHuL32LaOaB3Rd8L3CqP9qUrg78L7eKjjXjyG97U3NdRdZBlWg==} + dependencies: + '@injectivelabs/grpc-web': 0.0.1(google-protobuf@3.21.2) + google-protobuf: 3.21.2 + protobufjs: 7.3.2 + rxjs: 7.8.1 + dev: false + /@injectivelabs/mito-proto-ts@1.0.65: resolution: {integrity: sha512-kceZP68QrgFop387RYyO7tkfJCYxoktuceHTs9DQP3dJceLqj/V2mz0NlpkkacjgE5NhYkQ/zc0Z40hr8tnYqQ==} dependencies: @@ -4194,6 +4374,58 @@ packages: - utf-8-validate dev: false + /@injectivelabs/sdk-ts@1.14.5(@types/react@18.3.3)(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-j/6EcvNgQn563L0P5x80cZDTbYYbsXmHgtIbj8DCzemzgPRadmZLtlMDBjMQZ0ZcMhDSMfVOCINBOB2bBz2qMw==} + requiresBuild: true + dependencies: + '@apollo/client': 3.10.6(@types/react@18.3.3)(graphql@16.8.1)(react-dom@18.2.0)(react@18.2.0) + '@cosmjs/amino': 0.31.3 + '@cosmjs/proto-signing': 0.31.3 + '@cosmjs/stargate': 0.31.3 + '@ensdomains/ens-validation': 0.1.0 + '@ensdomains/eth-ens-namehash': 2.0.15 + '@ethersproject/bytes': 5.7.0 + '@injectivelabs/core-proto-ts': 0.0.21 + '@injectivelabs/dmm-proto-ts': 1.0.19 + '@injectivelabs/exceptions': 1.14.11(google-protobuf@3.21.2) + '@injectivelabs/grpc-web': 0.0.1(google-protobuf@3.21.2) + '@injectivelabs/grpc-web-node-http-transport': 0.0.2(@injectivelabs/grpc-web@0.0.1) + '@injectivelabs/grpc-web-react-native-transport': 0.0.2(@injectivelabs/grpc-web@0.0.1) + '@injectivelabs/indexer-proto-ts': 1.11.32 + '@injectivelabs/mito-proto-ts': 1.0.55 + '@injectivelabs/networks': 1.14.11(google-protobuf@3.21.2) + '@injectivelabs/test-utils': 1.14.5 + '@injectivelabs/token-metadata': 1.14.11(google-protobuf@3.21.2) + '@injectivelabs/ts-types': 1.14.11 + '@injectivelabs/utils': 1.14.11(google-protobuf@3.21.2) + '@metamask/eth-sig-util': 4.0.1 + axios: 0.27.2 + bech32: 2.0.0 + bip39: 3.1.0 + cosmjs-types: 0.7.2 + ethereumjs-util: 7.1.5 + ethers: 5.7.2 + google-protobuf: 3.21.2 + graphql: 16.8.1 + http-status-codes: 2.3.0 + js-sha3: 0.8.0 + jscrypto: 1.0.3 + keccak256: 1.0.6 + link-module-alias: 1.2.0 + secp256k1: 4.0.3 + shx: 0.3.4 + snakecase-keys: 5.5.0 + transitivePeerDependencies: + - '@types/react' + - bufferutil + - debug + - graphql-ws + - react + - react-dom + - subscriptions-transport-ws + - utf-8-validate + dev: false + /@injectivelabs/test-utils@1.14.5: resolution: {integrity: sha512-f34yWpFYXNdqruBJo6cbR7hKW5xn6lWENR49zk/PA3CDiQjs9ywVcVofWGyOGnpKQvAOzfF75yQgRc7tqL71lw==} requiresBuild: true @@ -8797,6 +9029,42 @@ packages: '@sinonjs/commons': 3.0.1 dev: false + /@skip-go/client@0.10.3(@types/react@18.3.3)(react-dom@18.2.0)(react@18.2.0)(typescript@5.1.3): + resolution: {integrity: sha512-7sA4abXuIB8bHYcM/cdUKqWOsduVq3ORrIehRGgZOJdQsztYEnsrUdqGCtN4PLuPc9VIlXhAXueejiaySAGjig==} + dependencies: + '@cosmjs/amino': 0.32.4 + '@cosmjs/cosmwasm-stargate': 0.32.4 + '@cosmjs/encoding': 0.32.4 + '@cosmjs/math': 0.32.4 + '@cosmjs/proto-signing': 0.32.4 + '@cosmjs/stargate': 0.32.4 + '@cosmjs/tendermint-rpc': 0.32.4 + '@initia/initia-registry': 0.1.16 + '@injectivelabs/core-proto-ts': 0.0.21 + '@injectivelabs/sdk-ts': 1.14.5(@types/react@18.3.3)(react-dom@18.2.0)(react@18.2.0) + '@keplr-wallet/unit': 0.12.121 + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.93.2) + '@solana/web3.js': 1.93.2 + axios: 1.6.7 + chain-registry: 1.69.0 + cosmjs-types: 0.8.0 + keccak256: 1.0.6 + kujira.js: 0.9.162 + viem: 2.16.2(typescript@5.1.3) + transitivePeerDependencies: + - '@types/react' + - bufferutil + - debug + - encoding + - graphql-ws + - react + - react-dom + - subscriptions-transport-ws + - typescript + - utf-8-validate + - zod + dev: false + /@skip-router/core@5.1.0(@types/react@18.3.3)(chain-registry@1.63.9)(react-dom@18.2.0)(react@18.2.0)(typescript@5.1.3): resolution: {integrity: sha512-js0ru+Y/taoHs27us25eqqE9kS+mE/0byOXOAt6LIomZnD6th5BGJoKFWSZ/0XGGHi69blnGnLCw8swClbKDqg==} peerDependencies: @@ -12814,6 +13082,12 @@ packages: '@chain-registry/types': 0.45.6 dev: false + /chain-registry@1.69.0: + resolution: {integrity: sha512-jNDHQrtF7qwqvQBF+1FylyKxTkUofD5MD/wVFshlmGciOjLR8Amh4wC0zPzeWrJsOWUihvYFR8qPpjCgT1YvTw==} + dependencies: + '@chain-registry/types': 0.50.0 + dev: false + /chalk@2.4.2: resolution: {integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==} engines: {node: '>=4'} @@ -13327,6 +13601,13 @@ packages: typescript: 5.1.3 dev: true + /cosmjs-types@0.7.2: + resolution: {integrity: sha512-vf2uLyktjr/XVAgEq0DjMxeAWh1yYREe7AMHDKd7EiHVqxBPCaBS+qEEQUkXbR9ndnckqr1sUG8BQhazh4X5lA==} + dependencies: + long: 4.0.0 + protobufjs: 6.11.4 + dev: false + /cosmjs-types@0.8.0: resolution: {integrity: sha512-Q2Mj95Fl0PYMWEhA2LuGEIhipF7mQwd9gTQ85DdP9jjjopeoGaDxvmPa5nakNzsq7FnO1DMTatXTAx6bxMH7Lg==} dependencies: diff --git a/src/App.tsx b/src/App.tsx index 198be0ff77..112decb40c 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -43,6 +43,7 @@ import { config, privyConfig } from '@/lib/wagmi'; import { RestrictionWarning } from './components/RestrictionWarning'; import { ComplianceStates } from './constants/compliance'; import { DialogTypes } from './constants/dialogs'; +import { SkipProvider } from './hooks/transfers/skipClient'; import { useAnalytics } from './hooks/useAnalytics'; import { useBreakpoints } from './hooks/useBreakpoints'; import { useCommandMenu } from './hooks/useCommandMenu'; @@ -199,6 +200,7 @@ const providers = [ wrapProvider(PotentialMarketsProvider), wrapProvider(StyleSheetManager, { shouldForwardProp }), wrapProvider(AppThemeAndColorModeProvider), + wrapProvider(SkipProvider), ]; const App = () => { diff --git a/src/constants/solana.ts b/src/constants/solana.ts new file mode 100644 index 0000000000..0aa4029c61 --- /dev/null +++ b/src/constants/solana.ts @@ -0,0 +1,5 @@ +import { isMainnet } from './networks'; + +export const getSolanaChainId = () => { + return isMainnet ? 'solana' : 'solana-devnet'; +}; diff --git a/src/hooks/transfers/skipClient.tsx b/src/hooks/transfers/skipClient.tsx new file mode 100644 index 0000000000..52f6a63711 --- /dev/null +++ b/src/hooks/transfers/skipClient.tsx @@ -0,0 +1,44 @@ +import { createContext, useContext } from 'react'; + +import { SkipClient } from '@skip-go/client'; + +import { getNeutronChainId, getNobleChainId, getOsmosisChainId } from '@/constants/graz'; +import { getSolanaChainId } from '@/constants/solana'; + +import { getSelectedDydxChainId } from '@/state/appSelectors'; +import { useAppSelector } from '@/state/appTypes'; + +import { RPCUrlsByChainId } from '@/lib/wagmi'; + +import { useEndpointsConfig } from '../useEndpointsConfig'; + +type SkipContextType = ReturnType; +const SkipContext = createContext(undefined); +SkipContext.displayName = 'skipClient'; + +export const SkipProvider = ({ ...props }) => ( + +); + +export const useSkipClient = () => useContext(SkipContext); + +const useSkipClientContext = () => { + const { solanaRpcUrl, nobleValidator, neutronValidator, osmosisValidator, validators } = + useEndpointsConfig(); + const selectedDydxChainId = useAppSelector(getSelectedDydxChainId); + const skipClient = new SkipClient({ + endpointOptions: { + getRpcEndpointForChain: async (chainId: string) => { + if (chainId === getNobleChainId()) return nobleValidator; + if (chainId === getNeutronChainId()) return neutronValidator; + if (chainId === getOsmosisChainId()) return osmosisValidator; + if (chainId === selectedDydxChainId) return validators[0]; + if (chainId === getSolanaChainId()) return solanaRpcUrl; + const evmRpcUrls = RPCUrlsByChainId[chainId]; + if (evmRpcUrls) return evmRpcUrls[0]; + throw new Error(`Error: no rpc endpoint found for chainId: ${chainId}`); + }, + }, + }); + return { skipClient }; +}; diff --git a/src/lib/wagmi.ts b/src/lib/wagmi.ts index a8166bc774..36c72c2663 100644 --- a/src/lib/wagmi.ts +++ b/src/lib/wagmi.ts @@ -1,7 +1,7 @@ // Custom connectors import type { PrivyClientConfig } from '@privy-io/react-auth'; import { createConfig } from '@privy-io/wagmi'; -import { FallbackTransport, Transport, http, type Chain } from 'viem'; +import { fallback, FallbackTransport, http, Transport, type Chain } from 'viem'; import { arbitrum, arbitrumGoerli, @@ -37,7 +37,6 @@ import { scroll, sepolia, } from 'viem/chains'; -import { fallback } from 'wagmi'; import { coinbaseWallet as coinbaseWalletConnector, walletConnect as walletConnectConnector, @@ -107,7 +106,9 @@ enum ChainId { BASE_SEPOLIA = '84532', } -const getAlchemyRPCUrls = (chainId: ChainId, apiKey: string) => { +const getAlchemyRPCUrlForChainId = (chainId: ChainId) => { + const alchemyKey = import.meta.env.VITE_ALCHEMY_API_KEY; + if (!alchemyKey) return undefined; switch (chainId) { case ChainId.ETH_MAINNET: return `https://eth-mainnet.g.alchemy.com/v2/${apiKey}`; @@ -134,16 +135,24 @@ const getAlchemyRPCUrls = (chainId: ChainId, apiKey: string) => { } }; +export const RPCUrlsByChainId = [mainnet, ...WAGMI_SUPPORTED_CHAINS].reduce( + (chainIdToRpcMap, chain) => { + const alchemyRPCUrl = getAlchemyRPCUrlForChainId(chain.id.toString() as ChainId); + const defaultRPCUrl = chain.rpcUrls.default.http[0]; + return { + [chain.id]: [alchemyRPCUrl, defaultRPCUrl].filter(isTruthy), + ...chainIdToRpcMap, + }; + }, + {} as Record +); + const RPCTransports = [mainnet, ...WAGMI_SUPPORTED_CHAINS].reduce( (transports, chain) => { - const alchemyKey = import.meta.env.VITE_ALCHEMY_API_KEY; - const alchemyRPCUrls = - alchemyKey && getAlchemyRPCUrls(chain.id.toString() as ChainId, alchemyKey); - transports[chain.id] = fallback( - [alchemyRPCUrls && http(alchemyRPCUrls), http(chain.rpcUrls.default.http[0]), http()].filter( - isTruthy - ) - ); + const rpcUrls = RPCUrlsByChainId[chain.id]; + const rpcTransports = rpcUrls.map((rpcUrl) => http(rpcUrl)); + const rpcTransportsWithDefault = [...rpcTransports, http()]; + transports[chain.id] = fallback(rpcTransportsWithDefault); return transports; }, {} as Record>