Skip to content

Commit 3994613

Browse files
committed
checksum addresses to RPC
1 parent c4d9698 commit 3994613

File tree

6 files changed

+26
-28
lines changed

6 files changed

+26
-28
lines changed

docker-compose.yml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,6 @@ services:
3838
volumes:
3939
- redis_data:/data
4040

41-
bullboard:
42-
container_name: bullboard
43-
image: deadly0/bull-board:3.2.6
44-
restart: always
45-
ports:
46-
- 3333:3000
47-
environment:
48-
REDIS_HOST: redis
49-
REDIS_PORT: 6379
50-
REDIS_USE_TLS: "false"
51-
BULL_PREFIX: bull
52-
depends_on:
53-
- redis
54-
5541
engine:
5642
profiles:
5743
- engine

src/server/routes/transaction/syncRetry.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { getAccount } from "../../../utils/account";
77
import { getBlockNumberish } from "../../../utils/block";
88
import { getChain } from "../../../utils/chain";
99
import { msSince } from "../../../utils/date";
10-
import { maybeBigInt } from "../../../utils/primitiveTypes";
10+
import { getChecksumAddress, maybeBigInt } from "../../../utils/primitiveTypes";
1111
import { thirdwebClient } from "../../../utils/sdk";
1212
import { SentTransaction } from "../../../utils/transaction/types";
1313
import { enqueueTransactionWebhook } from "../../../utils/transaction/webhook";
@@ -82,7 +82,7 @@ export async function syncRetryTransaction(fastify: FastifyInstance) {
8282

8383
// Prepare transaction.
8484
const populatedTransaction = await toSerializableTransaction({
85-
from,
85+
from: getChecksumAddress(from),
8686
transaction: {
8787
client: thirdwebClient,
8888
chain: await getChain(chainId),

src/utils/primitiveTypes.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Address } from "thirdweb";
1+
import { Address, getAddress } from "thirdweb";
22

33
export const maybeBigInt = (val?: string) => (val ? BigInt(val) : undefined);
44

@@ -14,6 +14,17 @@ export function normalizeAddress(
1414
return val ? (val.toLowerCase() as Address) : undefined;
1515
}
1616

17+
export function getChecksumAddress(val: Address): Address;
18+
export function getChecksumAddress(val?: Address): Address | undefined;
19+
export function getChecksumAddress(val: string): Address;
20+
export function getChecksumAddress(val?: string): Address | undefined;
21+
export function getChecksumAddress(val: string | null): undefined;
22+
export function getChecksumAddress(
23+
val?: string | Address | null,
24+
): Address | undefined {
25+
return val ? getAddress(val) : undefined;
26+
}
27+
1728
export function maybeDate(val: number): Date;
1829
export function maybeDate(val?: number): Date | undefined;
1930
export function maybeDate(val?: number): Date | undefined {

src/utils/transaction/cancelTransaction.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Address, toSerializableTransaction } from "thirdweb";
22
import { getAccount } from "../account";
33
import { getChain } from "../chain";
4+
import { getChecksumAddress } from "../primitiveTypes";
45
import { thirdwebClient } from "../sdk";
56

67
interface CancellableTransaction {
@@ -16,7 +17,7 @@ export const sendCancellationTransaction = async (
1617

1718
const chain = await getChain(chainId);
1819
const populatedTransaction = await toSerializableTransaction({
19-
from,
20+
from: getChecksumAddress(from),
2021
transaction: {
2122
client: thirdwebClient,
2223
chain,

src/utils/transaction/insertTransaction.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { randomUUID } from "crypto";
22
import { TransactionDB } from "../../db/transactions/db";
33
import { createCustomError } from "../../server/middleware/error";
44
import { SendTransactionQueue } from "../../worker/queues/sendTransactionQueue";
5-
import { normalizeAddress } from "../primitiveTypes";
5+
import { getChecksumAddress } from "../primitiveTypes";
66
import { reportUsage } from "../usage";
77
import { doSimulateTransaction } from "./simulateQueuedTransaction";
88
import { InsertedTransaction, QueuedTransaction } from "./types";
@@ -42,13 +42,12 @@ export const insertTransaction = async (
4242
queuedAt: new Date(),
4343
resendCount: 0,
4444

45-
// Standardize address formats.
46-
from: normalizeAddress(insertedTransaction.from),
47-
to: normalizeAddress(insertedTransaction.to),
48-
signerAddress: normalizeAddress(insertedTransaction.signerAddress),
49-
accountAddress: normalizeAddress(insertedTransaction.accountAddress),
50-
target: normalizeAddress(insertedTransaction.target),
51-
sender: normalizeAddress(insertedTransaction.sender),
45+
from: getChecksumAddress(insertedTransaction.from),
46+
to: getChecksumAddress(insertedTransaction.to),
47+
signerAddress: getChecksumAddress(insertedTransaction.signerAddress),
48+
accountAddress: getChecksumAddress(insertedTransaction.accountAddress),
49+
target: getChecksumAddress(insertedTransaction.target),
50+
sender: getChecksumAddress(insertedTransaction.sender),
5251
value: insertedTransaction.value ?? 0n,
5352
};
5453

src/worker/tasks/sendTransactionWorker.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
isReplacementGasFeeTooLow,
2424
prettifyError,
2525
} from "../../utils/error";
26+
import { getChecksumAddress } from "../../utils/primitiveTypes";
2627
import { redis } from "../../utils/redis/redis";
2728
import { thirdwebClient } from "../../utils/sdk";
2829
import {
@@ -138,7 +139,7 @@ const _sendTransaction = async (
138139
let populatedTransaction: TransactionSerializable;
139140
try {
140141
populatedTransaction = await toSerializableTransaction({
141-
from,
142+
from: getChecksumAddress(from),
142143
transaction: {
143144
client: thirdwebClient,
144145
chain,
@@ -219,7 +220,7 @@ const _resendTransaction = async (
219220
// Populate the transaction with double gas.
220221
const { chainId, from } = sentTransaction;
221222
const populatedTransaction = await toSerializableTransaction({
222-
from,
223+
from: getChecksumAddress(from),
223224
transaction: {
224225
client: thirdwebClient,
225226
chain: await getChain(chainId),

0 commit comments

Comments
 (0)