From 21cd6c48d5d2149d7c7f5dc848065db6187c0fe7 Mon Sep 17 00:00:00 2001 From: A5 Pickle Date: Thu, 10 Oct 2024 14:06:56 -0500 Subject: [PATCH 1/3] fix solana sdk deps --- package-lock.json | 305 ++++++++++---------------------------------- solana/package.json | 4 +- 2 files changed, 71 insertions(+), 238 deletions(-) diff --git a/package-lock.json b/package-lock.json index 00c21c97..9c7502ed 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1175,13 +1175,13 @@ } }, "node_modules/@solana/web3.js": { - "version": "1.91.7", - "resolved": "https://registry.npmjs.org/@solana/web3.js/-/web3.js-1.91.7.tgz", - "integrity": "sha512-HqljZKDwk6Z4TajKRGhGLlRsbGK4S8EY27DA7v1z6yakewiUY3J7ZKDZRxcqz2MYV/ZXRrJ6wnnpiHFkPdv0WA==", + "version": "1.95.3", + "resolved": "https://registry.npmjs.org/@solana/web3.js/-/web3.js-1.95.3.tgz", + "integrity": "sha512-O6rPUN0w2fkNqx/Z3QJMB9L225Ex10PRDH8bTaIUPZXMPV0QP8ZpPvjQnXK+upUczlRgzHzd6SjKIha1p+I6og==", "dependencies": { - "@babel/runtime": "^7.23.4", - "@noble/curves": "^1.4.0", - "@noble/hashes": "^1.3.3", + "@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", @@ -1190,16 +1190,54 @@ "bs58": "^4.0.1", "buffer": "6.0.3", "fast-stable-stringify": "^1.0.0", - "jayson": "^4.1.0", + "jayson": "^4.1.1", "node-fetch": "^2.7.0", - "rpc-websockets": "^7.5.1", - "superstruct": "^0.14.2" + "rpc-websockets": "^9.0.2", + "superstruct": "^2.0.2" + } + }, + "node_modules/@solana/web3.js/node_modules/@types/ws": { + "version": "8.5.12", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.12.tgz", + "integrity": "sha512-3tPRkv1EtkDpzlgyKyI8pGsGZAGPEaXeu0DOj5DI25Ja91bdAYddYHbADRYVrZMRbfW+1l5YwXVDKohDJNQxkQ==", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@solana/web3.js/node_modules/eventemitter3": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", + "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==" + }, + "node_modules/@solana/web3.js/node_modules/rpc-websockets": { + "version": "9.0.4", + "resolved": "https://registry.npmjs.org/rpc-websockets/-/rpc-websockets-9.0.4.tgz", + "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" + }, + "funding": { + "type": "paypal", + "url": "https://paypal.me/kozjak" + }, + "optionalDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" } }, "node_modules/@solana/web3.js/node_modules/superstruct": { - "version": "0.14.2", - "resolved": "https://registry.npmjs.org/superstruct/-/superstruct-0.14.2.tgz", - "integrity": "sha512-nPewA6m9mR3d6k7WkZ8N8zpTWfenFH3q9pA2PkuiZxINr9DKB2+40wEQf0ixn8VaGuJ78AB6iWOtStI+/4FKZQ==" + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/superstruct/-/superstruct-2.0.2.tgz", + "integrity": "sha512-uV+TFRZdXsqXTL2pRvujROjdZQ4RAlBUS5BTh9IGm+jTqQntYThciG/qu57Gs69yjnVUSqdxF9YLmSnpupBW9A==", + "engines": { + "node": ">=14.0.0" + } }, "node_modules/@solidity-parser/parser": { "version": "0.17.0", @@ -1363,36 +1401,18 @@ } }, "node_modules/@wormhole-foundation/sdk-connect": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/@wormhole-foundation/sdk-connect/-/sdk-connect-0.7.2.tgz", - "integrity": "sha512-QV6jkiZ2VycEUhraRmaD5QbjI1vT/bzZ/6mwwWVThA9o9jUnazMN1oBGhv5NHho1rCERhD1jA+KDXzoht6Mdcw==", + "version": "0.10.9", + "resolved": "https://registry.npmjs.org/@wormhole-foundation/sdk-connect/-/sdk-connect-0.10.9.tgz", + "integrity": "sha512-UCneSFMDho3p3rUFoxpDV+9zutJWcQJJ78RLLpjya0EivNy2AMTFWbP0sQdx+3kHw0MIJM/JtsUoUhPZZKeD/w==", "dependencies": { - "@wormhole-foundation/sdk-base": "0.7.2", - "@wormhole-foundation/sdk-definitions": "0.7.2", + "@wormhole-foundation/sdk-base": "0.10.9", + "@wormhole-foundation/sdk-definitions": "0.10.9", "axios": "^1.4.0" }, "engines": { "node": ">=16" } }, - "node_modules/@wormhole-foundation/sdk-connect/node_modules/@wormhole-foundation/sdk-base": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/@wormhole-foundation/sdk-base/-/sdk-base-0.7.2.tgz", - "integrity": "sha512-umPhwvEUOJJPQYzyLYDSnuKbdOBd0KH/7ZQDsxtrlKpQcm0AL4LU9k3tM+juCSLPQ6VU0EnXgYQnYxmV1sGsMw==", - "dependencies": { - "@scure/base": "^1.1.3" - } - }, - "node_modules/@wormhole-foundation/sdk-connect/node_modules/@wormhole-foundation/sdk-definitions": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/@wormhole-foundation/sdk-definitions/-/sdk-definitions-0.7.2.tgz", - "integrity": "sha512-oVvE/cSq5eMJPI+f7i3CfZZxrO+llAN0QMTmMzns3OFPU0a0PAy0Cu/lNTXjuqApkpMTQI4iaWks7KL3A5rbgQ==", - "dependencies": { - "@noble/curves": "^1.4.0", - "@noble/hashes": "^1.3.1", - "@wormhole-foundation/sdk-base": "0.7.2" - } - }, "node_modules/@wormhole-foundation/sdk-definitions": { "version": "0.10.9", "resolved": "https://registry.npmjs.org/@wormhole-foundation/sdk-definitions/-/sdk-definitions-0.10.9.tgz", @@ -1442,19 +1462,6 @@ "resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.13.tgz", "integrity": "sha512-N+0kuo9KgrUQ1Sn/ifDXsvg0TTleP7rIy4zOBGECxAljqvqfqpTfzx0Q1NUedOixRMBfe2Whhb056a42cWs26Q==" }, - "node_modules/@wormhole-foundation/sdk-evm/node_modules/@wormhole-foundation/sdk-connect": { - "version": "0.10.9", - "resolved": "https://registry.npmjs.org/@wormhole-foundation/sdk-connect/-/sdk-connect-0.10.9.tgz", - "integrity": "sha512-UCneSFMDho3p3rUFoxpDV+9zutJWcQJJ78RLLpjya0EivNy2AMTFWbP0sQdx+3kHw0MIJM/JtsUoUhPZZKeD/w==", - "dependencies": { - "@wormhole-foundation/sdk-base": "0.10.9", - "@wormhole-foundation/sdk-definitions": "0.10.9", - "axios": "^1.4.0" - }, - "engines": { - "node": ">=16" - } - }, "node_modules/@wormhole-foundation/sdk-evm/node_modules/aes-js": { "version": "4.0.0-beta.5", "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-4.0.0-beta.5.tgz", @@ -1513,30 +1520,31 @@ } }, "node_modules/@wormhole-foundation/sdk-solana": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/@wormhole-foundation/sdk-solana/-/sdk-solana-0.7.2.tgz", - "integrity": "sha512-KvC2gqFI7ph8cZCSP9oN4EKpSWqUOEVIltiWyB8aCpAMELq6KUp/ZC0LgUEMF+VKi5uRDTfXNlqoXuBfOjXZwQ==", + "version": "0.10.9", + "resolved": "https://registry.npmjs.org/@wormhole-foundation/sdk-solana/-/sdk-solana-0.10.9.tgz", + "integrity": "sha512-+dW7jBhTb8sgEcJF7Y2BkfM2QR7OaiL/6m25ungkDt7wFuPIIVGi4NM0Szngg+YyMs910PYdR1lcXd3Ijl/Nrw==", "dependencies": { "@coral-xyz/anchor": "0.29.0", "@coral-xyz/borsh": "0.29.0", "@solana/spl-token": "0.3.9", - "@solana/web3.js": "1.91.7", - "@wormhole-foundation/sdk-connect": "0.7.2" + "@solana/web3.js": "^1.95.2", + "@wormhole-foundation/sdk-connect": "0.10.9", + "rpc-websockets": "^7.10.0" }, "engines": { "node": ">=16" } }, "node_modules/@wormhole-foundation/sdk-solana-core": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/@wormhole-foundation/sdk-solana-core/-/sdk-solana-core-0.7.2.tgz", - "integrity": "sha512-NKAo9NlA26kLY1GCIZrBjyekZ+DdFIgDm4gndCPxHDQ2SGlGjvEg9XveBBR/oaDcJd0PkZsTcR04DHqCWmTyyQ==", + "version": "0.10.9", + "resolved": "https://registry.npmjs.org/@wormhole-foundation/sdk-solana-core/-/sdk-solana-core-0.10.9.tgz", + "integrity": "sha512-M+ZZpiZRwTTlm+bn1ZPYecUlcDI+OUwgX8bgwmgcQSADxXJkYtOFPsAB2R8eOcAmQirhkMK4Mjv//+IHrfaTBw==", "dependencies": { "@coral-xyz/anchor": "0.29.0", "@coral-xyz/borsh": "0.29.0", - "@solana/web3.js": "1.91.7", - "@wormhole-foundation/sdk-connect": "0.7.2", - "@wormhole-foundation/sdk-solana": "0.7.2" + "@solana/web3.js": "^1.95.2", + "@wormhole-foundation/sdk-connect": "0.10.9", + "@wormhole-foundation/sdk-solana": "0.10.9" }, "engines": { "node": ">=16" @@ -4201,8 +4209,8 @@ "@wormhole-foundation/sdk-base": "^0.10.9", "@wormhole-foundation/sdk-definitions": "^0.10.9", "@wormhole-foundation/sdk-evm": "^0.10.9", - "@wormhole-foundation/sdk-solana": "^0.7.2", - "@wormhole-foundation/sdk-solana-core": "^0.7.2", + "@wormhole-foundation/sdk-solana": "^0.10.9", + "@wormhole-foundation/sdk-solana-core": "^0.10.9", "anchor-0.29.0": "npm:@coral-xyz/anchor@^0.29.0", "bn.js": "^5.2.1", "dotenv": "^16.4.1", @@ -4517,71 +4525,6 @@ "@solana/web3.js": "^1.94.0" } }, - "solana/node_modules/@solana/web3.js": { - "version": "1.95.3", - "resolved": "https://registry.npmjs.org/@solana/web3.js/-/web3.js-1.95.3.tgz", - "integrity": "sha512-O6rPUN0w2fkNqx/Z3QJMB9L225Ex10PRDH8bTaIUPZXMPV0QP8ZpPvjQnXK+upUczlRgzHzd6SjKIha1p+I6og==", - "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" - } - }, - "solana/node_modules/@solana/web3.js/node_modules/superstruct": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/superstruct/-/superstruct-2.0.2.tgz", - "integrity": "sha512-uV+TFRZdXsqXTL2pRvujROjdZQ4RAlBUS5BTh9IGm+jTqQntYThciG/qu57Gs69yjnVUSqdxF9YLmSnpupBW9A==", - "engines": { - "node": ">=14.0.0" - } - }, - "solana/node_modules/@types/ws": { - "version": "8.5.12", - "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.12.tgz", - "integrity": "sha512-3tPRkv1EtkDpzlgyKyI8pGsGZAGPEaXeu0DOj5DI25Ja91bdAYddYHbADRYVrZMRbfW+1l5YwXVDKohDJNQxkQ==", - "dependencies": { - "@types/node": "*" - } - }, - "solana/node_modules/rpc-websockets": { - "version": "9.0.4", - "resolved": "https://registry.npmjs.org/rpc-websockets/-/rpc-websockets-9.0.4.tgz", - "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" - }, - "funding": { - "type": "paypal", - "url": "https://paypal.me/kozjak" - }, - "optionalDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": "^5.0.2" - } - }, - "solana/node_modules/rpc-websockets/node_modules/eventemitter3": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", - "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==" - }, "solver": { "name": "@wormhole-foundation/example-liquidity-layer-solver", "version": "0.0.1", @@ -4613,116 +4556,6 @@ "@solana/web3.js": "^1.91.6" } }, - "solver/node_modules/@solana/web3.js": { - "version": "1.95.3", - "resolved": "https://registry.npmjs.org/@solana/web3.js/-/web3.js-1.95.3.tgz", - "integrity": "sha512-O6rPUN0w2fkNqx/Z3QJMB9L225Ex10PRDH8bTaIUPZXMPV0QP8ZpPvjQnXK+upUczlRgzHzd6SjKIha1p+I6og==", - "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" - } - }, - "solver/node_modules/@solana/web3.js/node_modules/rpc-websockets": { - "version": "9.0.4", - "resolved": "https://registry.npmjs.org/rpc-websockets/-/rpc-websockets-9.0.4.tgz", - "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" - }, - "funding": { - "type": "paypal", - "url": "https://paypal.me/kozjak" - }, - "optionalDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": "^5.0.2" - } - }, - "solver/node_modules/@types/ws": { - "version": "8.5.12", - "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.12.tgz", - "integrity": "sha512-3tPRkv1EtkDpzlgyKyI8pGsGZAGPEaXeu0DOj5DI25Ja91bdAYddYHbADRYVrZMRbfW+1l5YwXVDKohDJNQxkQ==", - "dependencies": { - "@types/node": "*" - } - }, - "solver/node_modules/@wormhole-foundation/sdk-connect": { - "version": "0.10.9", - "resolved": "https://registry.npmjs.org/@wormhole-foundation/sdk-connect/-/sdk-connect-0.10.9.tgz", - "integrity": "sha512-UCneSFMDho3p3rUFoxpDV+9zutJWcQJJ78RLLpjya0EivNy2AMTFWbP0sQdx+3kHw0MIJM/JtsUoUhPZZKeD/w==", - "dependencies": { - "@wormhole-foundation/sdk-base": "0.10.9", - "@wormhole-foundation/sdk-definitions": "0.10.9", - "axios": "^1.4.0" - }, - "engines": { - "node": ">=16" - } - }, - "solver/node_modules/@wormhole-foundation/sdk-solana": { - "version": "0.10.9", - "resolved": "https://registry.npmjs.org/@wormhole-foundation/sdk-solana/-/sdk-solana-0.10.9.tgz", - "integrity": "sha512-+dW7jBhTb8sgEcJF7Y2BkfM2QR7OaiL/6m25ungkDt7wFuPIIVGi4NM0Szngg+YyMs910PYdR1lcXd3Ijl/Nrw==", - "dependencies": { - "@coral-xyz/anchor": "0.29.0", - "@coral-xyz/borsh": "0.29.0", - "@solana/spl-token": "0.3.9", - "@solana/web3.js": "^1.95.2", - "@wormhole-foundation/sdk-connect": "0.10.9", - "rpc-websockets": "^7.10.0" - }, - "engines": { - "node": ">=16" - } - }, - "solver/node_modules/@wormhole-foundation/sdk-solana/node_modules/@solana/spl-token": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/@solana/spl-token/-/spl-token-0.3.9.tgz", - "integrity": "sha512-1EXHxKICMnab35MvvY/5DBc/K/uQAOJCYnDZXw83McCAYUAfi+rwq6qfd6MmITmSTEhcfBcl/zYxmW/OSN0RmA==", - "dependencies": { - "@solana/buffer-layout": "^4.0.0", - "@solana/buffer-layout-utils": "^0.2.0", - "buffer": "^6.0.3" - }, - "engines": { - "node": ">=16" - }, - "peerDependencies": { - "@solana/web3.js": "^1.47.4" - } - }, - "solver/node_modules/eventemitter3": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", - "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==" - }, - "solver/node_modules/superstruct": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/superstruct/-/superstruct-2.0.2.tgz", - "integrity": "sha512-uV+TFRZdXsqXTL2pRvujROjdZQ4RAlBUS5BTh9IGm+jTqQntYThciG/qu57Gs69yjnVUSqdxF9YLmSnpupBW9A==", - "engines": { - "node": ">=14.0.0" - } - }, "universal/ts": { "name": "@wormhole-foundation/example-liquidity-layer-definitions", "version": "0.0.1", diff --git a/solana/package.json b/solana/package.json index 0076542d..1f2feb98 100644 --- a/solana/package.json +++ b/solana/package.json @@ -40,8 +40,8 @@ "@wormhole-foundation/sdk-base": "^0.10.9", "@wormhole-foundation/sdk-definitions": "^0.10.9", "@wormhole-foundation/sdk-evm": "^0.10.9", - "@wormhole-foundation/sdk-solana": "^0.7.2", - "@wormhole-foundation/sdk-solana-core": "^0.7.2", + "@wormhole-foundation/sdk-solana": "^0.10.9", + "@wormhole-foundation/sdk-solana-core": "^0.10.9", "anchor-0.29.0": "npm:@coral-xyz/anchor@^0.29.0", "bn.js": "^5.2.1", "dotenv": "^16.4.1", From 6a61d7689ad4c1ae94bd57e516b40f07e3d54d4a Mon Sep 17 00:00:00 2001 From: A5 Pickle Date: Thu, 10 Oct 2024 14:56:03 -0500 Subject: [PATCH 2/3] completely remove ethers --- solana/ts/src/cctp/messages.ts | 10 +++++++--- solana/ts/src/testing/mock.ts | 30 ++++++++++++++---------------- solana/ts/src/wormhole/index.ts | 3 +-- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/solana/ts/src/cctp/messages.ts b/solana/ts/src/cctp/messages.ts index 28894d37..e5ea53f4 100644 --- a/solana/ts/src/cctp/messages.ts +++ b/solana/ts/src/cctp/messages.ts @@ -1,4 +1,4 @@ -import { ethers } from "ethers"; +import { BN } from "@coral-xyz/anchor"; export type Cctp = { version: number; @@ -95,7 +95,9 @@ export class CctpTokenBurnMessage { const version = message.readUInt32BE(0); const burnTokenAddress = Array.from(message.subarray(4, 36)); const mintRecipient = Array.from(message.subarray(36, 68)); - const amount = BigInt(ethers.BigNumber.from(message.subarray(68, 100)).toString()); + + // BN -> bigint conversion is painful. + const amount = BigInt(new BN(message.subarray(68, 100), 10, "be").toString()); const sender = Array.from(message.subarray(100, 132)); return new CctpTokenBurnMessage( @@ -122,7 +124,9 @@ export class CctpTokenBurnMessage { // Special handling w/ uint256. This value will most likely encoded in < 32 bytes, so we // jump ahead by 32 and subtract the length of the encoded value. - const encodedAmount = ethers.utils.arrayify(ethers.BigNumber.from(amount.toString())); + // + // bigint -> Uint8Array conversion is painful. + const encodedAmount = new BN(amount.toString()).toBuffer("be", 32); buf.set(encodedAmount, (offset += 32) - encodedAmount.length); buf.set(sender, offset); diff --git a/solana/ts/src/testing/mock.ts b/solana/ts/src/testing/mock.ts index cc39ffc2..380bb00a 100644 --- a/solana/ts/src/testing/mock.ts +++ b/solana/ts/src/testing/mock.ts @@ -1,12 +1,12 @@ +import { BN } from "@coral-xyz/anchor"; import { Connection, Keypair } from "@solana/web3.js"; -import { ethers } from "ethers"; -import { LiquidityLayerMessage } from "../common"; -import { CORE_BRIDGE_PID, GUARDIAN_KEY } from "./consts"; -import { postVaa, getBlockTime } from "./utils"; +import { Chain } from "@wormhole-foundation/sdk-base"; +import { keccak256, secp256k1, serialize, toUniversal } from "@wormhole-foundation/sdk-definitions"; import { mocks } from "@wormhole-foundation/sdk-definitions/testing"; import { utils as coreUtils } from "@wormhole-foundation/sdk-solana-core"; -import { Chain } from "@wormhole-foundation/sdk-base"; -import { serialize, toUniversal } from "@wormhole-foundation/sdk-definitions"; +import { LiquidityLayerMessage } from "../common"; +import { CORE_BRIDGE_PID, GUARDIAN_KEY } from "./consts"; +import { getBlockTime, postVaa } from "./utils"; // TODO: return VaaAccount, too export async function postLiquidityLayerVaa( @@ -42,24 +42,22 @@ export async function postLiquidityLayerVaa( } export class CircleAttester { - attester: ethers.utils.SigningKey; - - constructor() { - this.attester = new ethers.utils.SigningKey("0x" + GUARDIAN_KEY); - } - createAttestation(message: Buffer | Uint8Array) { - const signature = this.attester.signDigest(ethers.utils.keccak256(message)); + const signature = secp256k1.sign(keccak256(message), GUARDIAN_KEY); const attestation = Buffer.alloc(65); let offset = 0; - attestation.set(ethers.utils.arrayify(signature.r), offset); + + // bigint -> Uint8Array conversion is painful. + attestation.set(new BN(signature.r.toString()).toBuffer("be", 32), offset); offset += 32; - attestation.set(ethers.utils.arrayify(signature.s), offset); + + // bigint -> Uint8Array conversion is painful. + attestation.set(new BN(signature.s.toString()).toBuffer("be", 32), offset); offset += 32; - const recoveryId = signature.recoveryParam; + const recoveryId = signature.recovery; attestation.writeUInt8(recoveryId < 27 ? recoveryId + 27 : recoveryId, offset); offset += 1; diff --git a/solana/ts/src/wormhole/index.ts b/solana/ts/src/wormhole/index.ts index 6b9a9ef3..54602b2b 100644 --- a/solana/ts/src/wormhole/index.ts +++ b/solana/ts/src/wormhole/index.ts @@ -1,7 +1,6 @@ import { Connection, PublicKey } from "@solana/web3.js"; import { ChainId, isChainId, toChainId } from "@wormhole-foundation/sdk-base"; import { deserialize, keccak256 } from "@wormhole-foundation/sdk-definitions"; -import { ethers } from "ethers"; export * from "./spy"; export type EncodedVaa = { @@ -158,7 +157,7 @@ export class VaaAccount { offset = buf.writeUInt8(consistencyLevel, offset); buf.set(payload, offset); - return ethers.utils.arrayify(ethers.utils.keccak256(buf)); + return keccak256(buf); } else { throw new Error("impossible: hash() failed"); } From 6210763d93fd582468a956b6e787f7651e0fd8a4 Mon Sep 17 00:00:00 2001 From: A5 Pickle Date: Thu, 10 Oct 2024 15:09:11 -0500 Subject: [PATCH 3/3] solana: remove comments --- solana/ts/tests/04__interaction.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/solana/ts/tests/04__interaction.ts b/solana/ts/tests/04__interaction.ts index 4769fee5..9706b26c 100644 --- a/solana/ts/tests/04__interaction.ts +++ b/solana/ts/tests/04__interaction.ts @@ -427,9 +427,6 @@ describe("Matching Engine <> Token Router", function () { describe("Settle No Auction (Local)", function () { before("Start Event Listener", async function () { - // listenerId = matchingEngine.onFilledLocalFastOrder((event, slot, signature) => { - // emittedEvents.push({ event, slot, signature }); - // }); listenerId = matchingEngine.onEventCpi((event, slot, signature) => { const { localFastOrderFilled } = event; if (localFastOrderFilled !== undefined) { @@ -470,9 +467,6 @@ describe("Matching Engine <> Token Router", function () { let listenerId: number | undefined; before("Start Event Listener", async function () { - // listenerId = matchingEngine.onFilledLocalFastOrder((event, slot, signature) => { - // emittedEvents.push({ event, slot, signature }); - // }); listenerId = matchingEngine.onEventCpi((event, slot, signature) => { const { localFastOrderFilled } = event; if (localFastOrderFilled !== undefined) {