Skip to content

Commit

Permalink
fix: add log
Browse files Browse the repository at this point in the history
  • Loading branch information
seven-feng committed Jan 26, 2025
1 parent ec5861d commit 5f84b0f
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions examples/example-web-app/components/RecordMessageButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export default function RecordMessageButton({ children, message }: Props) {
const transactionVersion = supportedTxnVersions?.has(0) ? 0 : 'legacy';
const recordMessageGuarded = useGuardedCallback(
async (messageBuffer: Buffer): Promise<[string | null, RpcResponseAndContext<SignatureResult>]> => {

const {
context,
value: { blockhash, lastValidBlockHeight },
Expand All @@ -46,32 +45,37 @@ export default function RecordMessageButton({ children, message }: Props) {

let memoProgramTransaction: Transaction | VersionedTransaction;

// if the wallet only supports legacy transactions, use the web3.js legacy transaction
// if the wallet only supports legacy transactions, use the web3.js legacy transaction
if (transactionVersion === 'legacy') {
memoProgramTransaction = new Transaction({
blockhash: blockhash,
lastValidBlockHeight: lastValidBlockHeight,
feePayer: publicKey,
}).add(memoInstruction)
}).add(memoInstruction);
} else {
// otherwise, if versioned transactions are supported, use a V0 versioned transaction
let memoProgramMessage = new TransactionMessage({
payerKey: publicKey!,
recentBlockhash: blockhash,
instructions: [ memoInstruction ],
})
memoProgramTransaction = new VersionedTransaction(memoProgramMessage.compileToV0Message())
instructions: [memoInstruction],
});
memoProgramTransaction = new VersionedTransaction(memoProgramMessage.compileToV0Message());
}

const signature = await sendTransaction(memoProgramTransaction, connection, { minContextSlot: context.slot});
enqueueSnackbar('start send transaction...', { variant: 'success' });
const signature = await sendTransaction(memoProgramTransaction, connection, {
minContextSlot: context.slot,
});
// enqueueSnackbar('Funding successful: ' + signature, { variant: 'success' });
// return [signature, await connection.confirmTransaction({ blockhash, lastValidBlockHeight, signature })];
return [signature, {
value: { err: null },
context: {
slot: 0
}
}];
return [
signature,
{
value: { err: null },
context: {
slot: 0,
},
},
];
},
[connection, publicKey, sendTransaction],
);
Expand Down

0 comments on commit 5f84b0f

Please sign in to comment.