From 7da830661e6adf37785c04b6a8b9e4d3025bcb62 Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Mon, 29 Jan 2024 12:41:44 +0100 Subject: [PATCH] restore send transaction type safety (#2840) --- packages/common/src/allo/backends/allo-v1.ts | 6 ++++-- packages/common/src/allo/transaction-sender.ts | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/common/src/allo/backends/allo-v1.ts b/packages/common/src/allo/backends/allo-v1.ts index 88263989cb..28055c1bc1 100644 --- a/packages/common/src/allo/backends/allo-v1.ts +++ b/packages/common/src/allo/backends/allo-v1.ts @@ -1,4 +1,4 @@ -import { Address, Hex } from "viem"; +import { Address, Hex, hexToBigInt } from "viem"; import { Allo, AlloError, AlloOperation } from "../allo"; import { TransactionReceipt, @@ -137,12 +137,14 @@ export class AlloV1 implements Allo { return ipfsResult; } + const projectIndex = hexToBigInt(args.projectId); + // --- send transaction to update project metadata const txResult = await sendTransaction(this.transactionSender, { address: this.projectRegistryAddress, abi: ProjectRegistryABI, functionName: "updateProjectMetadata", - args: [args.projectId, { protocol: 1n, pointer: ipfsResult.value }], + args: [projectIndex, { protocol: 1n, pointer: ipfsResult.value }], }); emit("transaction", txResult); diff --git a/packages/common/src/allo/transaction-sender.ts b/packages/common/src/allo/transaction-sender.ts index 9a18cb0a8e..4634f99475 100644 --- a/packages/common/src/allo/transaction-sender.ts +++ b/packages/common/src/allo/transaction-sender.ts @@ -235,9 +235,12 @@ export async function sendRawTransaction( } } -export async function sendTransaction( +export async function sendTransaction< + TAbi extends Abi, + TFunctionName extends string, +>( sender: TransactionSender, - args: Parameters[0] & { address: Address } + args: EncodeFunctionDataParameters & { address: Address } ): Promise> { try { const data = encodeFunctionData(args);