diff --git a/package.json b/package.json index e30db45ab..1f5a6fdd4 100644 --- a/package.json +++ b/package.json @@ -88,7 +88,7 @@ "@haverstack/axios-fetch-adapter": "^0.12.0", "@polkadot/api": "^12.1.1", "@solana/spl-token": "^0.4.6", - "@solana/web3.js": "^1.91.8", + "@solana/web3.js": "^1.98.0", "@ton/core": "^0.59.0", "@ton/crypto": "^3.3.0", "@ton/ton": "^15.1.0", diff --git a/src/solana/SolanaEngine.ts b/src/solana/SolanaEngine.ts index 75c766ec8..3fd3dbbd2 100644 --- a/src/solana/SolanaEngine.ts +++ b/src/solana/SolanaEngine.ts @@ -126,9 +126,11 @@ export class SolanaEngine extends CurrencyEngine< const funcs = rpcNodes.map(serverUrl => async () => { serverUrl = this.tools.rpcWithApiKey(serverUrl) const res = await this.fetch(serverUrl, options) - if (!res.ok) { + const json = await res.json() + if (!res.ok || json.error != null) { + this.log.warn('fetchRpc json', json) throw new Error( - `fetchRpc ${options.method} failed error: ${res.status}` + `fetchRpc ${options.method} failed error: ${json.error ?? res.status}` ) } const out = await res.json() @@ -464,6 +466,7 @@ export class SolanaEngine extends CurrencyEngine< }) } ) + try { const txResponse: Array< TransactionResponse | VersionedTransactionResponse > = await asyncWaterfall(funcs) @@ -511,6 +514,9 @@ export class SolanaEngine extends CurrencyEngine< } } } + } catch (e: any) { + this.error('getTransactions failed with error: ', e) + } } this.walletLocalDataDirty = true diff --git a/src/solana/SolanaTools.ts b/src/solana/SolanaTools.ts index cda491556..8da759df0 100644 --- a/src/solana/SolanaTools.ts +++ b/src/solana/SolanaTools.ts @@ -218,11 +218,19 @@ export class SolanaTools implements EdgeCurrencyTools { } makeConnections(rpcUrls: string[]): Connection[] { - const fetchCorsBypassed: EdgeFetchFunction = async (uri, opts) => - await this.io.fetch(uri, { + const fetchCorsBypassed: EdgeFetchFunction = async (uri, opts) => { + const res = await this.io.fetch(uri, { ...opts, corsBypass: 'always' }) + // Alchemy returns status 200 (ok) for failed requests + const json = await res.json() + if (json.error != null) { + throw new Error(`fetchCorsBypassed: ${json.error}`) + } + + return res + } const connectionConfig: ConnectionConfig = { commitment: this.networkInfo.commitment, fetch: fetchCorsBypassed as FetchFn diff --git a/src/solana/solanaInfo.ts b/src/solana/solanaInfo.ts index 4f7887f02..b23a165e6 100644 --- a/src/solana/solanaInfo.ts +++ b/src/solana/solanaInfo.ts @@ -186,15 +186,16 @@ const builtinTokens: EdgeTokenMap = { const networkInfo: SolanaNetworkInfo = { rpcNodes: [ // 'https://api.mainnet-beta.solana.com', - // 'https://solana-mainnet.rpc.grove.city/v1/{{poktPortalApiKey}}', // fails to return some transactions + // 'https://solana-mainnet.rpc.grove.city/v1/{{poktPortalApiKey}}' // fails to return some transactions 'https://mainnet.helius-rpc.com/?api-key={{heliusApiKey}}' ], rpcNodesArchival: [ // 'https://api.mainnet-beta.solana.com', - // 'https://solana-mainnet.g.alchemy.com/v2/{{alchemyApiKey}}', + // 'https://solana-mainnet.g.alchemy.com/v2/{{alchemyApiKey}}' 'https://mainnet.helius-rpc.com/?api-key={{heliusApiKey}}' ], stakedConnectionRpcNodes: [ + // has some staked solana to broadcast 'https://staked.helius-rpc.com?api-key={{heliusApiKey}}' ], commitment: 'confirmed', // confirmed is faster, finalized is safer. Even faster processed is unsupported for tx querys diff --git a/yarn.lock b/yarn.lock index 4e6e46b4a..15e522501 100644 --- a/yarn.lock +++ b/yarn.lock @@ -163,6 +163,13 @@ dependencies: regenerator-runtime "^0.14.0" +"@babel/runtime@^7.25.0": + version "7.26.0" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.26.0.tgz#8600c2f595f277c60815256418b85356a65173c1" + integrity sha512-FDSOghenHTiToteC/QRlv2q3DhPZ/oOXTBoirfWNx1Cx3TMVcGWQtMMmQcSvb/JjpNeGzx8Pq/b4fKEJuWm1sw== + dependencies: + regenerator-runtime "^0.14.0" + "@babel/template@^7.22.15", "@babel/template@^7.24.0": version "7.24.0" resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.24.0.tgz#c6a524aa93a4a05d66aaf31654258fae69d87d50" @@ -1023,6 +1030,13 @@ dependencies: "@noble/hashes" "1.4.0" +"@noble/curves@^1.4.2": + version "1.7.0" + resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.7.0.tgz#0512360622439256df892f21d25b388f52505e45" + integrity sha512-UTMhXK9SeDhFJVrHeUJ5uZlI6ajXg10O6Ddocf9S6GjbSBVZsJo88HzKwXznNfGpMTRDyJkqMjNDPYgf0qFWnw== + dependencies: + "@noble/hashes" "1.6.0" + "@noble/hashes@1.3.1": version "1.3.1" resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.1.tgz#8831ef002114670c603c458ab8b11328406953a9" @@ -1033,6 +1047,11 @@ resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.4.0.tgz#45814aa329f30e4fe0ba49426f49dfccdd066426" integrity sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg== +"@noble/hashes@1.6.0": + version "1.6.0" + resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.6.0.tgz#d4bfb516ad6e7b5111c216a5cc7075f4cf19e6c5" + integrity sha512-YUULf0Uk4/mAA89w+k3+yUYh6NrEvxZa5T6SY3wlMvE2chHkxFUUIDI8/XW1QSC357iA5pSnqt7XEhvFOqmDyQ== + "@noble/hashes@~1.3.0", "@noble/hashes@~1.3.1": version "1.3.2" resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.2.tgz#6f26dbc8fbc7205873ce3cee2f690eba0d421b39" @@ -1630,7 +1649,7 @@ dependencies: buffer "^6.0.3" -"@solana/web3.js@^1.32.0", "@solana/web3.js@^1.91.8": +"@solana/web3.js@^1.32.0": version "1.91.8" resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.91.8.tgz#0d5eb69626a92c391b53e15bfbb0bad3f6858e51" integrity sha512-USa6OS1jbh8zOapRJ/CBZImZ8Xb7AJjROZl5adql9TpOoBN9BUzyyouS5oPuZHft7S7eB8uJPuXWYjMi6BHgOw== @@ -1651,6 +1670,27 @@ rpc-websockets "^7.11.0" superstruct "^0.14.2" +"@solana/web3.js@^1.98.0": + version "1.98.0" + resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.98.0.tgz#21ecfe8198c10831df6f0cfde7f68370d0405917" + integrity sha512-nz3Q5OeyGFpFCR+erX2f6JPt3sKhzhYcSycBCSPkWjzSVDh/Rr1FqTVMRe58FKO16/ivTUcuJjeS5MyBvpkbzA== + dependencies: + "@babel/runtime" "^7.25.0" + "@noble/curves" "^1.4.2" + "@noble/hashes" "^1.4.0" + "@solana/buffer-layout" "^4.0.1" + agentkeepalive "^4.5.0" + bigint-buffer "^1.1.5" + bn.js "^5.2.1" + borsh "^0.7.0" + bs58 "^4.0.1" + buffer "6.0.3" + fast-stable-stringify "^1.0.0" + jayson "^4.1.1" + node-fetch "^2.7.0" + rpc-websockets "^9.0.2" + superstruct "^2.0.2" + "@substrate/connect-extension-protocol@^2.0.0": version "2.0.0" resolved "https://registry.yarnpkg.com/@substrate/connect-extension-protocol/-/connect-extension-protocol-2.0.0.tgz#badaa6e6b5f7c7d56987d778f4944ddb83cd9ea7" @@ -1696,6 +1736,13 @@ dependencies: loader-utils "^1.1.0" +"@swc/helpers@^0.5.11": + version "0.5.15" + resolved "https://registry.yarnpkg.com/@swc/helpers/-/helpers-0.5.15.tgz#79efab344c5819ecf83a43f3f9f811fc84b516d7" + integrity sha512-JQ5TuMi45Owi4/BIMAJBoSQoOJu12oOk/gADqlcUL9JEdHB8vyjUSsxqeNXnmXHjYKMi2WcYtezGEEhqUI/E2g== + dependencies: + tslib "^2.8.0" + "@ton/core@^0.58.1": version "0.58.1" resolved "https://registry.yarnpkg.com/@ton/core/-/core-0.58.1.tgz#f6f2ecef6a7149bcd23825bfbb454f116d54363f" @@ -1994,6 +2041,11 @@ resolved "https://registry.yarnpkg.com/@types/url-parse/-/url-parse-1.4.8.tgz#c3825047efbca1295b7f1646f38203d9145130d6" integrity sha512-zqqcGKyNWgTLFBxmaexGUKQyWqeG7HjXj20EuQJSJWwXe54BjX0ihIo5cJB9yAQzH8dNugJ9GvkBYMjPXs/PJw== +"@types/uuid@^8.3.4": + version "8.3.4" + resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-8.3.4.tgz#bd86a43617df0594787d38b735f55c805becf1bc" + integrity sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw== + "@types/ws@^7.4.4": version "7.4.7" resolved "https://registry.yarnpkg.com/@types/ws/-/ws-7.4.7.tgz#f7c390a36f7a0679aa69de2d501319f4f8d9b702" @@ -2001,6 +2053,13 @@ dependencies: "@types/node" "*" +"@types/ws@^8.2.2": + version "8.5.13" + resolved "https://registry.yarnpkg.com/@types/ws/-/ws-8.5.13.tgz#6414c280875e2691d0d1e080b05addbf5cb91e20" + integrity sha512-osM/gWBTPKgHV8XkTunnegTRIsvF6owmf5w+JtAfOw472dptdm0dlGv4xCt6GwQRcC2XVOvvRE/0bAoQcL2QkA== + dependencies: + "@types/node" "*" + "@types/ws@^8.5.1": version "8.5.3" resolved "https://registry.yarnpkg.com/@types/ws/-/ws-8.5.3.tgz#7d25a1ffbecd3c4f2d35068d0b283c037003274d" @@ -5790,6 +5849,24 @@ jayson@^4.1.0: uuid "^8.3.2" ws "^7.4.5" +jayson@^4.1.1: + version "4.1.3" + resolved "https://registry.yarnpkg.com/jayson/-/jayson-4.1.3.tgz#db9be2e4287d9fef4fc05b5fe367abe792c2eee8" + integrity sha512-LtXh5aYZodBZ9Fc3j6f2w+MTNcnxteMOrb+QgIouguGOulWi0lieEkOUg+HkjjFs0DGoWDds6bi4E9hpNFLulQ== + dependencies: + "@types/connect" "^3.4.33" + "@types/node" "^12.12.54" + "@types/ws" "^7.4.4" + JSONStream "^1.3.5" + commander "^2.20.3" + delay "^5.0.0" + es6-promisify "^5.0.0" + eyes "^0.1.8" + isomorphic-ws "^4.0.1" + json-stringify-safe "^5.0.1" + uuid "^8.3.2" + ws "^7.5.10" + jest-worker@^27.4.5: version "27.5.1" resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-27.5.1.tgz#8d146f0900e8973b106b6f73cc1e9a8cb86f8db0" @@ -7422,6 +7499,22 @@ rpc-websockets@^7.11.0: bufferutil "^4.0.1" utf-8-validate "^5.0.2" +rpc-websockets@^9.0.2: + version "9.0.4" + resolved "https://registry.yarnpkg.com/rpc-websockets/-/rpc-websockets-9.0.4.tgz#9d8ee82533b5d1e13d9ded729e3e38d0d8fa083f" + integrity sha512-yWZWN0M+bivtoNLnaDbtny4XchdAIF5Q4g/ZsC5UC61Ckbp0QczwO8fg44rV3uYmY4WHd+EZQbn90W1d8ojzqQ== + dependencies: + "@swc/helpers" "^0.5.11" + "@types/uuid" "^8.3.4" + "@types/ws" "^8.2.2" + buffer "^6.0.3" + eventemitter3 "^5.0.1" + uuid "^8.3.2" + ws "^8.5.0" + optionalDependencies: + bufferutil "^4.0.1" + utf-8-validate "^5.0.2" + run-parallel@^1.1.9: version "1.2.0" resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.2.0.tgz#66d1368da7bdf921eb9d95bd1a9229e7f21a43ee" @@ -8128,6 +8221,11 @@ superstruct@^0.14.2: resolved "https://registry.yarnpkg.com/superstruct/-/superstruct-0.14.2.tgz#0dbcdf3d83676588828f1cf5ed35cda02f59025b" integrity sha512-nPewA6m9mR3d6k7WkZ8N8zpTWfenFH3q9pA2PkuiZxINr9DKB2+40wEQf0ixn8VaGuJ78AB6iWOtStI+/4FKZQ== +superstruct@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/superstruct/-/superstruct-2.0.2.tgz#3f6d32fbdc11c357deff127d591a39b996300c54" + integrity sha512-uV+TFRZdXsqXTL2pRvujROjdZQ4RAlBUS5BTh9IGm+jTqQntYThciG/qu57Gs69yjnVUSqdxF9YLmSnpupBW9A== + supports-color@8.1.1, supports-color@^8.0.0: version "8.1.1" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c" @@ -8389,6 +8487,11 @@ tslib@^2.0.3, tslib@^2.1.0, tslib@^2.4.0, tslib@^2.6.1, tslib@^2.6.2: resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.3.tgz#0438f810ad7a9edcde7a241c3d80db693c8cbfe0" integrity sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ== +tslib@^2.8.0: + version "2.8.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f" + integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w== + tsutils@^3.21.0: version "3.21.0" resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623" @@ -8931,6 +9034,11 @@ ws@^7, ws@^7.4.5: resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.9.tgz#54fa7db29f4c7cec68b1ddd3a89de099942bb591" integrity sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q== +ws@^7.5.10: + version "7.5.10" + resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.10.tgz#58b5c20dc281633f6c19113f39b349bd8bd558d9" + integrity sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ== + ws@^8.15.1, ws@^8.18.0, ws@^8.2.2, ws@^8.4.2, ws@^8.5.0, ws@^8.8.1: version "8.18.0" resolved "https://registry.yarnpkg.com/ws/-/ws-8.18.0.tgz#0d7505a6eafe2b0e712d232b42279f53bc289bbc"