Conversation
| "scripts": { | ||
| "build": "tsc --build" | ||
| "build": "tsc --build", | ||
| "build:solana": "cd ../../src/solana && anchor build", |
There was a problem hiding this comment.
Maybe it's better to use the makefile here instead.
scnale
left a comment
There was a problem hiding this comment.
This is a partial review. I'm still missing looking at the governance client.
There was a problem hiding this comment.
This should be deleted, right?
| "@ledgerhq/hw-transport-node-hid": "^6.28.0", | ||
| "@solana/web3.js": "^1.98.4", | ||
| "@wormhole-foundation/sdk": "^4.5.0", | ||
| "@xlabs-xyz/ledger-ethers-signer": "github:XLabs/ledger-ethers-signer", |
There was a problem hiding this comment.
This is actually published to npm: https://www.npmjs.com/package/@xlabs-xyz/ledger-signer-ethers-v6 and https://www.npmjs.com/package/@xlabs-xyz/ledger-signer-solana
| "@ledgerhq/hw-app-solana": "^7.0.0", | ||
| "@ledgerhq/hw-transport-node-hid": "^6.28.0", |
| "references": [ | ||
| { "path": "../peer-lib" } | ||
| { "path": "../peer-lib" }, | ||
| { "path": "../../src/solana" } |
There was a problem hiding this comment.
The solana tests package is not a dependency so this seems unnecessary.
| // Validate basic structure | ||
| if (!config.Peers || !Array.isArray(config.Peers)) { | ||
| throw new Error('Invalid config: missing or invalid "Peers" array'); | ||
| } |
There was a problem hiding this comment.
We could import the schema definition in peer-lib here, right?
| const message = new (await import("@solana/web3.js")).TransactionMessage({ | ||
| payerKey: PublicKey.default, | ||
| recentBlockhash: blockhash, | ||
| instructions: [ix], | ||
| }).compileToV0Message(); | ||
|
|
||
| const tx = new (await import("@solana/web3.js")).VersionedTransaction(message); |
There was a problem hiding this comment.
Uh, I think using an import in situ is a bit overkill given that we're importing it at the top level :P
|
|
||
| if (result.value.err) { | ||
| const logs = result.value.logs?.join("\n") || "No logs"; | ||
| return { verified: false, error: `Simulation failed: ${JSON.stringify(result.value.err)}\nLogs:\n${logs}` }; |
There was a problem hiding this comment.
I'd prefer using util.inspect here. It's going to be safer if the error description is some crazy object with circular references :P
We might need an import for util.
| return { verified: false, error: `Simulation failed: ${JSON.stringify(result.value.err)}\nLogs:\n${logs}` }; | |
| return { verified: false, error: `Simulation failed: ${util.inspect(result.value.err)}\nLogs:\n${logs}` }; |
| console.log("Sequence:", result.sequence.toString()); | ||
| console.log("Payload Offset:", result.payloadOffset); | ||
| } else { | ||
| console.log("(Solana verify_vaa does not return parsed VAA data)"); |
There was a problem hiding this comment.
| console.log("(Solana verify_vaa does not return parsed VAA data)"); | |
| console.log("(SVM verify_vaa does not return parsed VAA data)"); |
| // Solana verification via simulate | ||
| async function verifyVaaSolana( |
There was a problem hiding this comment.
| // Solana verification via simulate | |
| async function verifyVaaSolana( | |
| // SVM verification via simulate | |
| async function verifyVaaSVM( |
|
|
||
| const VERIFICATION_FAILED_ERROR_SIGNATURE = "0x32629d58"; | ||
|
|
||
| // Default Solana program ID from IDL |
There was a problem hiding this comment.
| // Default Solana program ID from IDL | |
| // TODO: update this to a better default when the contracts are deployed. | |
| // Default Solana program ID from IDL |
| import * as TransportNodeHid from "@ledgerhq/hw-transport-node-hid"; | ||
| import * as SolanaApp from "@ledgerhq/hw-app-solana"; |
There was a problem hiding this comment.
We should use @xlabs-xyz/ledger-signer-solana instead.
| class EvmLedgerSigner { | ||
| private ledgerSigner: EthersSigner; | ||
|
|
||
| private constructor(ledgerSigner: EthersSigner) { | ||
| this.ledgerSigner = ledgerSigner; | ||
| } | ||
|
|
||
| static async create(provider: ethers.Provider): Promise<EvmLedgerSigner> { | ||
| try { | ||
| // Dynamic import using Function constructor to prevent vite from analyzing it | ||
| const importLedger = new Function('specifier', 'return import(specifier)'); | ||
| const ledgerModule = await importLedger("@xlabs-xyz/ledger-ethers-signer"); | ||
| const LedgerSigner = ledgerModule.LedgerSigner || (ledgerModule as any).default?.LedgerSigner || (ledgerModule as any).default; | ||
| const ledgerSigner = new LedgerSigner(provider, "hid"); | ||
| const address = await ledgerSigner.getAddress(); | ||
| console.log(`Using Ledger EVM signer: ${address}`); | ||
| return new EvmLedgerSigner(ledgerSigner); | ||
| } catch (error) { | ||
| console.error(`Failed to initialize Ledger: ${errorMsg(error)}`); | ||
| console.error('Make sure your Ledger device is connected and the Ethereum app is open.'); | ||
| throw error; | ||
| } | ||
| } | ||
|
|
||
| async getAddress(): Promise<string> { | ||
| return await this.ledgerSigner.getAddress(); | ||
| } | ||
|
|
||
| getSigner(): EthersSigner { | ||
| return this.ledgerSigner; | ||
| } | ||
| } |
There was a problem hiding this comment.
Uhhh, this is redundant. You can pass the ethers signer from the library directly to the ethers APIs.
No description provided.