Zilliqa / marketplace-contracts

GNU General Public License v3.0
2 stars 4 forks source link

[RIAL-117] feat/batch-sell #41

Closed teye closed 2 years ago

teye commented 2 years ago

Add batch sell to the fixed price and auction.

Note the arguments uses ADT.

Custom ADT is possible in parameters; the trick is to insert the contract address in the constructor param so that the blockchain can referenced to it. This is the workaround for ADT not found message.

See https://viewblock.io/zilliqa/tx/0x6845932e791c8a7df3d8a3dff8008db815c342c87bf6882824a1bbbfb215fd8d?network=testnet

Example:

function createOrderRecord(marketplace, tokenAddress, tokenId, paymentTokenAddress, salePrice, side, expirationBnum) {
  return {
    constructor: `${marketplace}.OrderRecord`,
    argtypes: [],
    arguments: [
        `${tokenAddress}`,
        `${tokenId}`,
        `${paymentTokenAddress}`,
        `${salePrice}`,
        `${side}`,
        `${expirationBnum}`,
    ]
  }
}
      const order_list = [];

      const orderItem1 = createOrderRecord(
          `${marketplace}`,
          "0x37f4f2b21b69b70e0a8dadf7c403acda99947d2e",
          "1",
          "0x0000000000000000000000000000000000000000",
          "11000000000000",
          "0",
          "5269463"
      );

      const orderItem2 = createOrderRecord(
          `${marketplace}`,
          "0x37f4f2b21b69b70e0a8dadf7c403acda99947d2e",
          "2",
          "0x0000000000000000000000000000000000000000",
          "22000000000000",
          "0",
          "5269463"
      );

      order_list.push(orderItem1);
      order_list.push(orderItem2);

        const callTx = await contract.call(
            'SetBatchOrder',
            [
                {
                    vname: "order_list",
                    type: `List ${marketplace}.OrderRecord`,
                    value: order_list,
                },
            ],
            {
                version: VERSION,
                amount: new BN(0),
                gasPrice: myGasPrice,
                gasLimit: Long.fromNumber(10000),
            },
            33,
            1000,
            true
        );