You can use the getMessages
method to retrieve a list of messages from the blockchain.
const WALLET_A = Wallet.fromPrivateKey(
'0x1ff16505df75735a5bcf4cb4cf839903120c181dd9be6781b82cda23543bd242',
provider
);
const WALLET_B = Wallet.fromPrivateKey(
'0x30bb0bc68f5d2ec3b523cee5a65503031b40679d9c72280cd8088c2cfbc34e38',
provider
);
const EXPECTED_MESSAGES_A: Message[] = [
{
messageId: '0x9ca8b2c626327692c7a865d0bbfe6232503e8dc0f7c442abe0b864ffdcca2da9',
sender: WALLET_B.address,
recipient: WALLET_A.address,
nonce: '0x0101010101010101010101010101010101010101010101010101010101010101',
amount: bn('ffff', 'hex'),
data: arrayify('0x'),
daHeight: bn(0),
},
];
const EXPECTED_MESSAGES_B: Message[] = [
{
messageId: '0x39578ef8c047ae994d0dadce8015559953b32fffa657c25c4c068fe4d6995a4b',
sender: WALLET_A.address,
recipient: WALLET_B.address,
nonce: '0x0e1ef2963832068b0e1ef2963832068b0e1ef2963832068b0e1ef2963832068b',
amount: bn('12704439083013451934'),
data: arrayify('0x'),
daHeight: bn(0),
},
];
const aMessages = await WALLET_A.getMessages();
const bMessages = await WALLET_B.getMessages();
expect(aMessages).toStrictEqual(EXPECTED_MESSAGES_A);
expect(bMessages).toStrictEqual(EXPECTED_MESSAGES_B);
Was this page helpful?