sdk/js : add parseSequencesFromLog*
This commit is contained in:
parent
cd56eb08b7
commit
2998031b16
|
@ -1,16 +1,29 @@
|
|||
# Changelog
|
||||
|
||||
## 0.1.6
|
||||
|
||||
### Added
|
||||
|
||||
added parseSequencesFromLog\*
|
||||
|
||||
## 0.1.5
|
||||
|
||||
deprecated postVaaSolana
|
||||
added postVaaSolanaWithRetry, which will retry transactions which failed during processing.
|
||||
added createVerifySignaturesInstructions, createPostVaaInstruction, which allows users to construct the postVaa process for themselves at the instruction level.
|
||||
added chunks and sendAndConfirmTransactionsWithRetry as utility functions.
|
||||
### Added
|
||||
|
||||
added integration tests for postVaaSolanaWithRetry.
|
||||
added postVaaSolanaWithRetry, which will retry transactions which failed during processing
|
||||
|
||||
added createVerifySignaturesInstructions, createPostVaaInstruction, which allows users to construct the postVaa process for themselves at the instruction level
|
||||
|
||||
added chunks and sendAndConfirmTransactionsWithRetry as utility functions
|
||||
|
||||
added integration tests for postVaaSolanaWithRetry
|
||||
|
||||
initial Oasis support
|
||||
|
||||
### Changed
|
||||
|
||||
deprecated postVaaSolana
|
||||
|
||||
## 0.1.4
|
||||
|
||||
initial AVAX testnet support
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@certusone/wormhole-sdk",
|
||||
"version": "0.1.5",
|
||||
"version": "0.1.6",
|
||||
"description": "SDK for interacting with Wormhole",
|
||||
"homepage": "https://wormholenetwork.com",
|
||||
"main": "./lib/cjs/index.js",
|
||||
|
|
|
@ -17,6 +17,22 @@ export function parseSequenceFromLogEth(
|
|||
return sequence.toString();
|
||||
}
|
||||
|
||||
export function parseSequencesFromLogEth(
|
||||
receipt: ContractReceipt,
|
||||
bridgeAddress: string
|
||||
): string[] {
|
||||
// TODO: dangerous!(?)
|
||||
const bridgeLogs = receipt.logs.filter((l) => {
|
||||
return l.address === bridgeAddress;
|
||||
});
|
||||
return bridgeLogs.map((bridgeLog) => {
|
||||
const {
|
||||
args: { sequence },
|
||||
} = Implementation__factory.createInterface().parseLog(bridgeLog);
|
||||
return sequence.toString();
|
||||
});
|
||||
}
|
||||
|
||||
export function parseSequenceFromLogTerra(info: TxInfo): string {
|
||||
// Scan for the Sequence attribute in all the outputs of the transaction.
|
||||
// TODO: Make this not horrible.
|
||||
|
@ -35,6 +51,23 @@ export function parseSequenceFromLogTerra(info: TxInfo): string {
|
|||
return sequence.toString();
|
||||
}
|
||||
|
||||
export function parseSequencesFromLogTerra(info: TxInfo): string[] {
|
||||
// Scan for the Sequence attribute in all the outputs of the transaction.
|
||||
// TODO: Make this not horrible.
|
||||
const sequences: string[] = [];
|
||||
const jsonLog = JSON.parse(info.raw_log);
|
||||
jsonLog.map((row: any) => {
|
||||
row.events.map((event: any) => {
|
||||
event.attributes.map((attribute: any) => {
|
||||
if (attribute.key === "message.sequence") {
|
||||
sequences.push(attribute.value.toString());
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
return sequences;
|
||||
}
|
||||
|
||||
const SOLANA_SEQ_LOG = "Program log: Sequence: ";
|
||||
export function parseSequenceFromLogSolana(info: TransactionResponse) {
|
||||
// TODO: better parsing, safer
|
||||
|
@ -46,3 +79,10 @@ export function parseSequenceFromLogSolana(info: TransactionResponse) {
|
|||
}
|
||||
return sequence.toString();
|
||||
}
|
||||
|
||||
export function parseSequencesFromLogSolana(info: TransactionResponse) {
|
||||
// TODO: better parsing, safer
|
||||
return info.meta?.logMessages
|
||||
?.filter((msg) => msg.startsWith(SOLANA_SEQ_LOG))
|
||||
.map((msg) => msg.replace(SOLANA_SEQ_LOG, ""));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue