Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(crypto-transaction): add letter capitalization for recipient address (EIP-55) #835

Merged
merged 3 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/crypto-block/test/fixtures/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const blockDataWithTransactions: Contracts.Crypto.BlockData = {
network: 30,
nonce: BigNumber.ZERO,
r: "880618343e206a7518fd970c4232440546b77d991976acb4c6a7040e10d668de",
recipientAddress: "0xbe89811e15f611c1db12e59679b6f3dc1f430155",
recipientAddress: "0xBe89811e15f611C1db12e59679b6F3DC1F430155",
s: "5dd454bd405a43d530826e9223882bcb42bd9134a57e429617f15b130216bb31",
senderAddress: "0xd1AD6bfA3540F25E21e6be808FB7F12562111CE5",
senderPublicKey: "03dc6981461d4b82df3e7db49b20a674745cef0dc5e7165168fe26490f5a24895a",
Expand All @@ -83,7 +83,7 @@ export const blockDataWithTransactions: Contracts.Crypto.BlockData = {
network: 30,
nonce: BigNumber.ONE,
r: "9867329ee177952b05c56471d94dcf3a2fcd63b1164d1698ac50beb9793c5687",
recipientAddress: "0xbe89811e15f611c1db12e59679b6f3dc1f430155",
recipientAddress: "0xBe89811e15f611C1db12e59679b6F3DC1F430155",
s: "2e27a586b3a935255d8f57eae63c97aef430f3c55a6a63db7185c0d8ff5c6a2c",
senderAddress: "0xd1AD6bfA3540F25E21e6be808FB7F12562111CE5",
senderPublicKey: "03dc6981461d4b82df3e7db49b20a674745cef0dc5e7165168fe26490f5a24895a",
Expand Down Expand Up @@ -120,7 +120,7 @@ export const blockDataWithTransactionsJson: Contracts.Crypto.BlockJson = {
network: 30,
nonce: "0",
r: "880618343e206a7518fd970c4232440546b77d991976acb4c6a7040e10d668de",
recipientAddress: "0xbe89811e15f611c1db12e59679b6f3dc1f430155",
recipientAddress: "0xBe89811e15f611C1db12e59679b6F3DC1F430155",
s: "5dd454bd405a43d530826e9223882bcb42bd9134a57e429617f15b130216bb31",
senderAddress: "0xd1AD6bfA3540F25E21e6be808FB7F12562111CE5",
senderPublicKey: "03dc6981461d4b82df3e7db49b20a674745cef0dc5e7165168fe26490f5a24895a",
Expand All @@ -137,7 +137,7 @@ export const blockDataWithTransactionsJson: Contracts.Crypto.BlockJson = {
network: 30,
nonce: "1",
r: "9867329ee177952b05c56471d94dcf3a2fcd63b1164d1698ac50beb9793c5687",
recipientAddress: "0xbe89811e15f611c1db12e59679b6f3dc1f430155",
recipientAddress: "0xBe89811e15f611C1db12e59679b6F3DC1F430155",
s: "2e27a586b3a935255d8f57eae63c97aef430f3c55a6a63db7185c0d8ff5c6a2c",
senderAddress: "0xd1AD6bfA3540F25E21e6be808FB7F12562111CE5",
senderPublicKey: "03dc6981461d4b82df3e7db49b20a674745cef0dc5e7165168fe26490f5a24895a",
Expand Down
6 changes: 4 additions & 2 deletions packages/crypto-transaction/source/deserializer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { inject, injectable } from "@mainsail/container";
import { Contracts, Identifiers } from "@mainsail/contracts";
import { BigNumber } from "@mainsail/utils";
import { decodeRlp, ethers } from "ethers";
import { decodeRlp, ethers, getAddress } from "ethers";

@injectable()
export class Deserializer implements Contracts.Crypto.TransactionDeserializer {
Expand All @@ -16,11 +16,13 @@ export class Deserializer implements Contracts.Crypto.TransactionDeserializer {

const decoded = decodeRlp(encodedRlp);

const recipientAddressRaw = this.#parseAddress(decoded[5].toString());

data.network = Number(decoded[0]);
data.nonce = BigNumber.make(this.#parseNumber(decoded[1].toString()));
data.gasPrice = this.#parseNumber(decoded[3].toString());
data.gasLimit = this.#parseNumber(decoded[4].toString());
data.recipientAddress = this.#parseAddress(decoded[5].toString());
data.recipientAddress = recipientAddressRaw ? getAddress(recipientAddressRaw) : undefined;
data.value = this.#parseBigNumber(decoded[6].toString());
data.data = this.#parseData(decoded[7].toString());

Expand Down
2 changes: 1 addition & 1 deletion packages/test-framework/source/internal/signer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ describe<{
assert.defined(entity.data.v);
assert.defined(entity.data.r);
assert.defined(entity.data.s);
assert.equal(entity.data.recipientAddress, "0xd3d80a3df661414a76aad7738a136a8d7aaa1666");
assert.equal(entity.data.recipientAddress, "0xD3D80a3Df661414a76aAd7738a136A8d7aAa1666");
assert.equal(entity.data.gasLimit, 21_000);
assert.equal(
entity.data.data,
Expand Down
Loading