Skip to content

Commit d403d62

Browse files
committed
add fee transfer ix to message example
1 parent c841ed5 commit d403d62

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

platforms/solana/protocols/core/src/core.ts

+3
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ import {
3636
createPostVaaInstruction,
3737
createReadOnlyWormholeProgramInterface,
3838
createVerifySignaturesInstructions,
39+
createBridgeFeeTransferInstruction,
3940
derivePostedVaaKey,
4041
getWormholeBridgeData,
42+
BridgeData,
4143
} from './utils';
4244

4345
const SOLANA_SEQ_LOG = 'Program log: Sequence: ';
@@ -82,6 +84,7 @@ export class SolanaWormholeCore<N extends Network, C extends SolanaChains>
8284
throw new Error(
8385
`Network mismatch for chain ${chain}: ${conf.network} != ${network}`,
8486
);
87+
8588
return new SolanaWormholeCore(
8689
network as N,
8790
chain,

platforms/solana/protocols/tokenBridge/src/tokenBridge.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,12 @@ export class SolanaTokenBridge<N extends Network, C extends SolanaChains>
217217
const nonce = 0;
218218

219219
const msgFee = await this.coreBridge.getMessageFee();
220-
const transferIx = await coreUtils.createBridgeFeeTransferInstruction(
220+
const transferIx = coreUtils.createBridgeFeeTransferInstruction(
221221
this.coreBridge.address,
222222
senderAddress,
223223
msgFee,
224224
);
225+
225226
const messageKey = Keypair.generate();
226227
const attestIx = createAttestTokenInstruction(
227228
this.connection,

platforms/solana/src/platform.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -166,18 +166,17 @@ export class SolanaPlatform<N extends Network> extends PlatformContext<
166166
// recoverable. Currently handles:
167167
// - Blockhash not found (blockhash too new for the node we submitted to)
168168
// - Not enough bytes (storage account not seen yet)
169-
170169
private static async sendWithRetry(
171170
rpc: Connection,
172-
stxns: SignedTx,
171+
stxn: SignedTx,
173172
opts: SendOptions,
174173
retries: number = 3,
175174
): Promise<string> {
176175
// Shouldnt get hit but just in case
177176
if (!retries) throw new Error('Too many retries');
178177

179178
try {
180-
const txid = await rpc.sendRawTransaction(stxns.tx, opts);
179+
const txid = await rpc.sendRawTransaction(stxn, opts);
181180
return txid;
182181
} catch (e) {
183182
retries -= 1;
@@ -195,7 +194,7 @@ export class SolanaPlatform<N extends Network> extends PlatformContext<
195194

196195
// Blockhash not found _yet_
197196
if (emsg.includes('Blockhash not found'))
198-
return this.sendWithRetry(rpc, stxns, opts, retries);
197+
return this.sendWithRetry(rpc, stxn, opts, retries);
199198

200199
// Find the log message with the error details
201200
const loggedErr = e.logs.find((log) =>
@@ -204,7 +203,9 @@ export class SolanaPlatform<N extends Network> extends PlatformContext<
204203

205204
// Probably caused by storage account not seen yet
206205
if (loggedErr && loggedErr.includes('Not enough bytes'))
207-
return this.sendWithRetry(rpc, stxns, opts, retries);
206+
return this.sendWithRetry(rpc, stxn, opts, retries);
207+
208+
throw e;
208209
}
209210
}
210211

0 commit comments

Comments
 (0)