Skip to content

Commit

Permalink
restore send transaction type safety (#2840)
Browse files Browse the repository at this point in the history
  • Loading branch information
boudra authored Jan 29, 2024
1 parent 3e01054 commit 7da8306
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions packages/common/src/allo/backends/allo-v1.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Address, Hex } from "viem";
import { Address, Hex, hexToBigInt } from "viem";
import { Allo, AlloError, AlloOperation } from "../allo";
import {
TransactionReceipt,
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 5 additions & 2 deletions packages/common/src/allo/transaction-sender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof encodeFunctionData>[0] & { address: Address }
args: EncodeFunctionDataParameters<TAbi, TFunctionName> & { address: Address }
): Promise<Result<Hex>> {
try {
const data = encodeFunctionData(args);
Expand Down

0 comments on commit 7da8306

Please sign in to comment.