Skip to content

Commit

Permalink
fix: cast as WriteContractParameters
Browse files Browse the repository at this point in the history
  • Loading branch information
kinrezC committed Dec 9, 2024
1 parent 7f92d69 commit 00baa03
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions packages/drift-viem/src/ViemReadWriteAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,22 @@ export class ViemReadWriteAdapter<
}) as FunctionReturn<TAbi, TFunctionName>;
}

async write<
TAbi extends Abi,
TFunctionName extends FunctionName<TAbi, "nonpayable" | "payable">,
>(params: AdapterWriteParams<TAbi, TFunctionName>) {
const writePromise = this.walletClient.writeContract(
params
);
async write<TAbi extends Abi, TFunctionName extends FunctionName<TAbi, "nonpayable" | "payable">>(
params: AdapterWriteParams<TAbi, TFunctionName>
) {
const writeParams = {
...params,
functionName: params.fn,
chain: null,
account: await this.getSignerAddress(),
} as WriteContractParameters;

const hash = await this.walletClient.writeContract(writeParams);

if (params.onMined) {
writePromise.then((hash) => {
this.waitForTransaction({ hash }).then(params.onMined);
return hash;
});
await this.waitForTransaction({ hash }).then(params.onMined);
}

return writePromise;
return hash;
}
}

0 comments on commit 00baa03

Please sign in to comment.