Skip to content

Commit

Permalink
fix marketplace approve erc20
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Sramko committed Aug 16, 2021
1 parent 747711a commit 56196e9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tatumio/tatum",
"version": "1.19.13",
"version": "1.19.14",
"description": "Tatum API client allows browsers and Node.js clients to interact with Tatum API.",
"main": "dist/src/index.js",
"repository": "https://github.com/tatumio/tatum-js",
Expand Down
11 changes: 11 additions & 0 deletions src/nft/marketplace/listing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,5 +272,16 @@ describe('Marketplace Listing tests', () => {
console.log(await polygonBroadcast(txData));
})

it('should approve erc20', async () => {
const approve = new ApproveMarketplaceErc20Spending();
approve.contractAddress = '0x326c977e6efc84e512bb9c30f76e30c160ed06fb';
approve.marketplaceAddress = '0x4153B909f55B0Ec43c11e980dF09b853477D9F79';
approve.chain = Currency.MATIC;
approve.amount = '0.002';
approve.fromPrivateKey = '0xf09110a0aae3dddba3d722c6c629fb08082963d8ed38afaf25cfce084c22e3d2';
const tx = await prepareMarketplaceApproveErc20Spending(true, approve, 'https://rpc-mumbai.matic.today');
expect(tx).toContain('0x');
console.log(await polygonBroadcast(tx));
});
})
})
2 changes: 2 additions & 0 deletions src/nft/marketplace/listing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ export const prepareMarketplaceApproveErc20Spending = async (testnet: boolean, b
throw new Error('Unsupported combination of inputs.')
}
const params = [body.marketplaceAddress, `0x${amount}`]
body.amount = '0';
if (body.chain === Currency.TRON) {
return await prepareSCCall(testnet, body, ApproveTronMarketplaceErc20Spending, 'approve',
[
Expand Down Expand Up @@ -318,6 +319,7 @@ export const prepareMarketplaceCreateListing = async (testnet: boolean, body: Cr
export const prepareMarketplaceBuyListing = async (testnet: boolean, body: InvokeMarketplaceListingOperation | InvokeTronMarketplaceListingOperation, provider?: string) => {
await validateBody(body, body.chain === Currency.TRON ? InvokeTronMarketplaceListingOperation : InvokeMarketplaceListingOperation)
const params = [body.listingId, body.erc20Address || '0x0000000000000000000000000000000000000000']
body.amount = undefined;
if (body.chain === Currency.TRON) {
return await prepareSCCall(testnet, body, InvokeTronMarketplaceListingOperation, 'buyAssetFromListing',
[
Expand Down

0 comments on commit 56196e9

Please sign in to comment.