Skip to content

Commit

Permalink
decode multiple
Browse files Browse the repository at this point in the history
  • Loading branch information
seunlanlege committed Aug 18, 2024
1 parent ff2de07 commit 6b9b9c1
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
http,
parseAbi,
parseEventLogs,
toHex,
} from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { bscTestnet, optimismSepolia } from "viem/chains";
Expand Down Expand Up @@ -111,7 +112,7 @@ async function testPostAndGetRequest() {
dest: OP.state_machine,
nonce: 0n,
from: account.address,
keys: [account.address],
keys: [account.address, opSepoliaIsmpHost.address, opSepoliaHandler.address],
height: BigInt(height), // latest height
timeoutTimestamp: 0n,
},
Expand Down Expand Up @@ -188,11 +189,12 @@ async function testPostAndGetRequest() {

if (event.eventName === "GetResponseReceived") {
// we requested the raw account in the world state, here we decode the response
const { key, value } = event.args.message[0];
console.log({
address: key,
account: Account.fromRlpSerializedAccount(value as any),
});
for (const { key, value } of event.args.message) {
console.log({
address: key,
account: Account.fromRlpSerializedAccount(value as any),
});
}
}
} catch (e) {
console.error("Error self-relaying: ", e);
Expand Down

0 comments on commit 6b9b9c1

Please sign in to comment.