Skip to content

Commit 7124036

Browse files
committed
export solana signer for use by helpers.ts
1 parent 1240a0c commit 7124036

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

solana/ts/scripts/env.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ if (!process.env.ENV) {
1212

1313
const env = process.env.ENV;
1414

15-
interface SolanaSigner {
15+
export interface SolanaSigner {
1616
getAddress(): Promise<Buffer>;
1717
signMessage(message: Buffer): Promise<Buffer>;
1818
signTransaction(transaction: Buffer): Promise<Buffer>;

solana/ts/scripts/helpers.ts

+18-11
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,43 @@
11
import {
2-
Transaction,
3-
TransactionInstruction,
42
Keypair,
53
PublicKey,
4+
Transaction,
5+
TransactionInstruction,
66
} from "@solana/web3.js";
77

8-
import { SolanaLedgerSigner } from "@xlabs-xyz/ledger-signer-solana";
9-
import { connection, getSigner } from "./env";
8+
import { SolanaSigner, connection, getSigner } from "./env";
109

11-
export async function ledgerSignAndSend(instructions: TransactionInstruction[], signers: Keypair[]) {
10+
export async function ledgerSignAndSend(
11+
instructions: TransactionInstruction[],
12+
signers: Keypair[]
13+
) {
1214
const deployerSigner = await getSigner();
1315
const deployerPk = new PublicKey(await deployerSigner.getAddress());
1416

1517
const tx = new Transaction();
1618
tx.add(...instructions);
1719

1820
const recentBlockHash = await connection.getRecentBlockhash();
19-
21+
2022
tx.recentBlockhash = recentBlockHash.blockhash;
2123
tx.feePayer = deployerPk;
22-
24+
2325
signers.forEach((signer) => tx.partialSign(signer));
2426

2527
await addLedgerSignature(tx, deployerSigner, deployerPk);
2628

2729
return connection.sendRawTransaction(tx.serialize(), {
2830
skipPreflight: true,
29-
3031
});
3132
}
3233

33-
export async function addLedgerSignature(tx: Transaction, signer: SolanaLedgerSigner, signerPk: PublicKey) {
34-
const signedByPayer = await signer.signTransaction(tx.compileMessage().serialize());
34+
export async function addLedgerSignature(
35+
tx: Transaction,
36+
signer: SolanaSigner,
37+
signerPk: PublicKey
38+
) {
39+
const signedByPayer = await signer.signTransaction(
40+
tx.compileMessage().serialize()
41+
);
3542
tx.addSignature(signerPk, signedByPayer);
36-
}
43+
}

0 commit comments

Comments
 (0)