Skip to content

Commit

Permalink
fix(core): make interface similar to viem writeContract
Browse files Browse the repository at this point in the history
  • Loading branch information
extg3 committed Jul 7, 2024
1 parent 94e7b59 commit 5978473
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions examples/sandbox/src/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,9 @@ export function App() {
// ),
new CustomContractCall(
{
contract: '0xD152f549545093347A162Dce210e7293f1452150',
address: '0xD152f549545093347A162Dce210e7293f1452150',
abi: disperseAbi,
method: 'disperseEther',
functionName: 'disperseEther',
args: [
recepients.map(([to]) => to),
recepients.map(([, amount]) => parseUnits(amount)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
import { Address } from '../../../types';

type ActionConfig = {
contract: Address;
method: string;
address: Address;
functionName: string;
abi: any;
args: any[];
value?: bigint; // native amount to send with the call
Expand All @@ -30,20 +30,20 @@ export class CustomContractCall implements CallDataBuilder {
public async build(): Promise<CallDataBuilderReturnData> {
const callData = new Set<CallData>();

if (!this.config.contract || !this.config.method || !this.config.abi) {
if (!this.config.address || !this.config.functionName || !this.config.abi) {
throw new Error("Invalid configuration");
}

const contractInterface = this.commonCallDataBuilderConfig.provider
.getContractFactory()
.getContractInterface(JSON.stringify(this.config.abi));

const functionCallData = contractInterface.encodeFunctionData(this.config.method, this.config.args);
const functionCallData = contractInterface.encodeFunctionData(this.config.address, this.config.args);

callData.add({
to: this.commonCallDataBuilderConfig.vaultAddress,
callData: this.vaultInterface.encodeFunctionData("execute", [
this.config.contract,
this.config.address,
this.config.value ? String(this.config.value) : "0",
functionCallData,
]),
Expand Down

0 comments on commit 5978473

Please sign in to comment.