Skip to content
This repository was archived by the owner on Jun 16, 2025. It is now read-only.

Commit 3804864

Browse files
authored
solana/ts: make original hash available in VaaAccount (#179)
1 parent c7abb1b commit 3804864

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

solana/ts/src/wormhole/index.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Connection, PublicKey } from "@solana/web3.js";
2-
import { ChainId, toChainId, isChainId } from "@wormhole-foundation/sdk-base";
2+
import { ChainId, isChainId, toChainId } from "@wormhole-foundation/sdk-base";
33
import { deserialize, keccak256 } from "@wormhole-foundation/sdk-definitions";
44
import { ethers } from "ethers";
55
export * from "./spy";
@@ -133,9 +133,9 @@ export class VaaAccount {
133133
}
134134
}
135135

136-
digest(): Uint8Array {
136+
hash(): Uint8Array {
137137
if (this._encodedVaa !== undefined) {
138-
return keccak256(deserialize("Uint8Array", this._encodedVaa.buf).hash);
138+
return deserialize("Uint8Array", this._encodedVaa.buf).hash;
139139
} else if (this._postedVaaV1 !== undefined) {
140140
const {
141141
consistencyLevel,
@@ -158,12 +158,16 @@ export class VaaAccount {
158158
offset = buf.writeUInt8(consistencyLevel, offset);
159159
buf.set(payload, offset);
160160

161-
return ethers.utils.arrayify(ethers.utils.keccak256(ethers.utils.keccak256(buf)));
161+
return ethers.utils.arrayify(ethers.utils.keccak256(buf));
162162
} else {
163-
throw new Error("impossible: digest() failed");
163+
throw new Error("impossible: hash() failed");
164164
}
165165
}
166166

167+
digest(): Uint8Array {
168+
return keccak256(this.hash());
169+
}
170+
167171
get encodedVaa(): EncodedVaa {
168172
if (this._encodedVaa === undefined) {
169173
throw new Error("VaaAccount does not have encodedVaa");

0 commit comments

Comments
 (0)