Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/core-sdk/src/erc20/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,14 @@ export async function ensureAllowance(args: {
value: BigNumberish;
web3Lib: Web3LibAdapter;
txRequest?: TransactionRequest;
returnTxInfo?: boolean;
}) {
if (args.returnTxInfo) {
return;
}
const allowance = await getAllowance(args);
if (BigNumber.from(allowance).lt(args.value)) {
const approveTx = await approve(args);
const approveTx = await approve({ ...args, returnTxInfo: false });
await approveTx.wait();
}
}
Expand Down
12 changes: 8 additions & 4 deletions packages/core-sdk/src/exchanges/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ export async function commitToOffer(
spender: args.contractAddress,
contractAddress: offer.exchangeToken.address,
value: offer.price,
web3Lib: args.web3Lib
web3Lib: args.web3Lib,
returnTxInfo: args.returnTxInfo
});
}

Expand Down Expand Up @@ -203,7 +204,8 @@ export async function commitToBuyerOffer(
spender: args.contractAddress,
contractAddress: offer.exchangeToken.address,
value: offer.price,
web3Lib: args.web3Lib
web3Lib: args.web3Lib,
returnTxInfo: args.returnTxInfo
});
}

Expand Down Expand Up @@ -263,7 +265,8 @@ export async function commitToConditionalOffer(
spender: args.contractAddress,
contractAddress: offer.exchangeToken.address,
value: offer.price,
web3Lib: args.web3Lib
web3Lib: args.web3Lib,
returnTxInfo: args.returnTxInfo
});
}

Expand Down Expand Up @@ -384,7 +387,8 @@ export async function createOfferAndCommit(args: {
spender: args.contractAddress,
contractAddress: exchangeToken,
value: committerPayment,
web3Lib: args.web3Lib
web3Lib: args.web3Lib,
returnTxInfo: args.returnTxInfo
});
}

Expand Down
9 changes: 6 additions & 3 deletions packages/core-sdk/src/orchestration/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,8 @@ export async function commitToOfferAndRedeemVoucher(args: {
spender: args.contractAddress,
contractAddress: offer.exchangeToken.address,
value: offer.price,
web3Lib: args.web3Lib
web3Lib: args.web3Lib,
returnTxInfo: args.returnTxInfo
});
}

Expand Down Expand Up @@ -647,7 +648,8 @@ export async function commitToConditionalOfferAndRedeemVoucher(args: {
spender: args.contractAddress,
contractAddress: offer.exchangeToken.address,
value: offer.price,
web3Lib: args.web3Lib
web3Lib: args.web3Lib,
returnTxInfo: args.returnTxInfo
});
}

Expand Down Expand Up @@ -758,7 +760,8 @@ export async function createOfferCommitAndRedeem(args: {
spender: args.contractAddress,
contractAddress: exchangeToken,
value: committerPayment,
web3Lib: args.web3Lib
web3Lib: args.web3Lib,
returnTxInfo: args.returnTxInfo
});
}

Expand Down
Loading