Skip to content

Commit

Permalink
Factory: PreTransfer: Add spender argument
Browse files Browse the repository at this point in the history
  • Loading branch information
rsbkmr committed Jun 15, 2024
1 parent 77e5070 commit 03ce84c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/chains/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export interface PreTransfer<Signer, GasArgs> {
preTransfer: (
signer: Signer,
token: string,
spender: string,
amount: bigint,
gasArgs: GasArgs,
) => Promise<string>;
Expand Down
4 changes: 2 additions & 2 deletions src/chains/web3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ export async function web3Helper({
},
nativeCoin: () => nativeCoin,
chainName: () => chainName,
preTransfer: async (signer, tid, amt, gasArgs) => {
preTransfer: async (signer, tid, spender, amt, gasArgs) => {
const erc = WrappedERC20__factory.connect(tid, signer);
const preTransferGas = await erc.approve.estimateGas(bridge, amt);
const approved = await erc.approve(bridge, amt, {
const approved = await erc.approve(spender, amt, {
...gasArgs,
gasLimit: preTransferGas,
});
Expand Down
6 changes: 4 additions & 2 deletions src/factory/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ export function ChainFactoryBuilder(

return {
inner,
preTransfer: async (chain, signer, tid, amt, ga) => {
const pt = await chain.preTransfer(signer, tid, amt, ga);
preTransfer: async (chain, signer, tid, spender, amt, ga) => {
const pt = await chain.preTransfer(signer, tid, spender, amt, ga);
return pt;
},
getTxCount() {
Expand Down Expand Up @@ -141,6 +141,8 @@ export function ChainFactoryBuilder(
uniqueUser: tx.uniqueUsers,
};
},
// async stakeTokenForPool(chain, signer, tokenSymbol, amount) {},
// async withdrawTokenForPool(chain, signer, tokenSymbol, amount) {},
sendInstallment: async (
chain,
signer,
Expand Down
1 change: 1 addition & 0 deletions src/factory/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export interface ChainFactory {
chain: PreTransfer<Signer, GasArgs>,
signer: Signer,
tid: string,
spender: string,
amount: bigint,
gasArgs: GasArgs,
) => Promise<string>;
Expand Down

0 comments on commit 03ce84c

Please sign in to comment.