trader-xyz / nft-swap-sdk

Ethereum's missing p2p NFT and token swap library for web3 developers. Written in TypeScript. Powered by 0x.
https://swapsdk.xyz
MIT License
219 stars 83 forks source link

[v0.32.0] loadApprovalStatusForOrder still forcing user to choose custom spending cap #106

Open tyh-dev opened 1 year ago

tyh-dev commented 1 year ago

I just upgraded to v0.32.0 and read the release notes. I thought it was supposed to now set the minimal viable approval now but I still get MetaMask asking to set a custom spending cap for WETH or choose max.

Screenshot 2023-06-29 at 4 11 18 AM

Here is part of my code for V4 SDK:

const approvalStatusForTaker = await swapSdkV4?.loadApprovalStatusForOrder(order_data, 'TAKER');

if (!approvalStatusForTaker?.contractApproved) {
    const approvalTx = await swapSdkV4?.approveTokenOrNftByAsset(ethToSwapTaker, walletAddressTaker);
    const approvalTxReceipt = await approvalTx?.wait();
}

Is this supposed to happen? It seems the same as the previous release. Thanks!

wizardlabsxyz commented 1 year ago

Facing the same issue here, although i'm using V3 of the SDK. It looks like if the user approves anything other than default i.e. a custom amount or using MAX, the return value from loadApprovalStatus still returns false.

castrolol commented 1 year ago

which ERC20 are you guys using? I had this issue, with USDT, and I notice that they have a different way to manage approval, with a spending cap and the allowance returns a number instead of a flag, for this case I used the contract directly to check the remaining spending cap