From 2e1c76976dbb80264c190dd46ad7b46f8aa2636f Mon Sep 17 00:00:00 2001 From: CounterFire2023 <136581895+CounterFire2023@users.noreply.github.com> Date: Mon, 3 Jul 2023 13:31:35 +0800 Subject: [PATCH] market buy add price --- src/abis/abiMarket.ts | 933 ++++++++++++++++++----------------- src/config/cfg_421613_dev.js | 2 +- src/standards/JCStandard.ts | 31 +- 3 files changed, 511 insertions(+), 455 deletions(-) diff --git a/src/abis/abiMarket.ts b/src/abis/abiMarket.ts index 2b4f9ce..0a6f9bb 100644 --- a/src/abis/abiMarket.ts +++ b/src/abis/abiMarket.ts @@ -1,4 +1,4 @@ -import { AbiItem } from "web3-utils"; +import { AbiItem } from 'web3-utils'; export let abiMarket: AbiItem[] = [ { @@ -6,930 +6,973 @@ export let abiMarket: AbiItem[] = [ inputs: [ { indexed: false, - internalType: "address", - name: "erc20", - type: "address", + internalType: 'address', + name: 'erc20', + type: 'address', }, ], - name: "AddERC20Suppout", - type: "event", + name: 'AddERC20Suppout', + type: 'event', }, { anonymous: false, inputs: [ { indexed: false, - internalType: "address", - name: "nftToken", - type: "address", + internalType: 'address', + name: 'nftToken', + type: 'address', }, ], - name: "AddNFTSuppout", - type: "event", + name: 'AddNFTSuppout', + type: 'event', }, { anonymous: false, inputs: [ { indexed: true, - internalType: "uint256", - name: "tokenId", - type: "uint256", + internalType: 'uint256', + name: 'tokenId', + type: 'uint256', }, { indexed: false, - internalType: "uint256", - name: "orderId", - type: "uint256", + internalType: 'uint256', + name: 'orderId', + type: 'uint256', }, { indexed: false, - internalType: "address", - name: "nftToken", - type: "address", + internalType: 'address', + name: 'nftToken', + type: 'address', }, { indexed: false, - internalType: "uint256", - name: "amount", - type: "uint256", + internalType: 'uint256', + name: 'amount', + type: 'uint256', }, { indexed: false, - internalType: "address", - name: "seller", - type: "address", + internalType: 'address', + name: 'seller', + type: 'address', }, { indexed: false, - internalType: "address", - name: "buyer", - type: "address", + internalType: 'address', + name: 'buyer', + type: 'address', }, { indexed: false, - internalType: "address", - name: "erc20", - type: "address", + internalType: 'address', + name: 'erc20', + type: 'address', }, { indexed: false, - internalType: "uint256", - name: "price", - type: "uint256", + internalType: 'uint256', + name: 'price', + type: 'uint256', }, ], - name: "BuyOrder", - type: "event", + name: 'BuyOrder', + type: 'event', }, { anonymous: false, inputs: [ { indexed: true, - internalType: "uint256", - name: "orderId", - type: "uint256", + internalType: 'uint256', + name: 'orderId', + type: 'uint256', }, { indexed: true, - internalType: "address", - name: "nftToken", - type: "address", + internalType: 'address', + name: 'nftToken', + type: 'address', }, { indexed: true, - internalType: "uint256", - name: "tokenId", - type: "uint256", + internalType: 'uint256', + name: 'tokenId', + type: 'uint256', }, ], - name: "CancelOrder", - type: "event", + name: 'CancelOrder', + type: 'event', }, { anonymous: false, inputs: [ { indexed: true, - internalType: "address", - name: "previousOwner", - type: "address", + internalType: 'address', + name: 'previousOwner', + type: 'address', }, { indexed: true, - internalType: "address", - name: "newOwner", - type: "address", + internalType: 'address', + name: 'newOwner', + type: 'address', }, ], - name: "OwnershipTransferred", - type: "event", + name: 'OwnershipTransferred', + type: 'event', }, { anonymous: false, inputs: [ { indexed: true, - internalType: "uint256", - name: "orderId", - type: "uint256", + internalType: 'uint256', + name: 'orderId', + type: 'uint256', }, { indexed: true, - internalType: "address", - name: "nftToken", - type: "address", + internalType: 'address', + name: 'nftToken', + type: 'address', }, { indexed: true, - internalType: "uint256", - name: "tokenId", - type: "uint256", + internalType: 'uint256', + name: 'tokenId', + type: 'uint256', }, { indexed: false, - internalType: "uint256", - name: "priceOld", - type: "uint256", + internalType: 'uint256', + name: 'priceOld', + type: 'uint256', }, { indexed: false, - internalType: "uint256", - name: "price", - type: "uint256", + internalType: 'uint256', + name: 'price', + type: 'uint256', }, ], - name: "PriceUpdate", - type: "event", + name: 'PriceUpdate', + type: 'event', }, { anonymous: false, inputs: [ { indexed: false, - internalType: "address", - name: "erc20", - type: "address", + internalType: 'address', + name: 'erc20', + type: 'address', }, ], - name: "RemoveERC20Suppout", - type: "event", + name: 'RemoveERC20Suppout', + type: 'event', }, { anonymous: false, inputs: [ { indexed: false, - internalType: "address", - name: "nftToken", - type: "address", + internalType: 'address', + name: 'nftToken', + type: 'address', }, ], - name: "RemoveNFTSuppout", - type: "event", + name: 'RemoveNFTSuppout', + type: 'event', }, { anonymous: false, inputs: [ { indexed: true, - internalType: "uint256", - name: "tokenId", - type: "uint256", + internalType: 'uint256', + name: 'tokenId', + type: 'uint256', }, { indexed: true, - internalType: "address", - name: "owner", - type: "address", + internalType: 'address', + name: 'owner', + type: 'address', }, { indexed: true, - internalType: "address", - name: "nftToken", - type: "address", + internalType: 'address', + name: 'nftToken', + type: 'address', }, { indexed: false, - internalType: "uint256", - name: "amount", - type: "uint256", + internalType: 'uint256', + name: 'amount', + type: 'uint256', }, { indexed: false, - internalType: "uint256", - name: "orderId", - type: "uint256", + internalType: 'uint256', + name: 'orderId', + type: 'uint256', }, { indexed: false, - internalType: "address", - name: "currency", - type: "address", + internalType: 'address', + name: 'currency', + type: 'address', }, { indexed: false, - internalType: "uint256", - name: "price", - type: "uint256", + internalType: 'uint256', + name: 'price', + type: 'uint256', }, ], - name: "SellOrder", - type: "event", + name: 'SellOrder', + type: 'event', }, { inputs: [], - name: "MAX_TRANSACTION_FEE", + name: 'MAX_TRANSACTION_FEE', outputs: [ { - internalType: "uint256", - name: "", - type: "uint256", + internalType: 'uint256', + name: '', + type: 'uint256', }, ], - stateMutability: "view", - type: "function", + stateMutability: 'view', + type: 'function', }, { inputs: [], - name: "MAX_TRANSACTION_TAX", + name: 'MAX_TRANSACTION_TAX', outputs: [ { - internalType: "uint256", - name: "", - type: "uint256", + internalType: 'uint256', + name: '', + type: 'uint256', }, ], - stateMutability: "view", - type: "function", + stateMutability: 'view', + type: 'function', }, { inputs: [], - name: "MIN_TRANSACTION_FEE", + name: 'MIN_TRANSACTION_FEE', outputs: [ { - internalType: "uint256", - name: "", - type: "uint256", + internalType: 'uint256', + name: '', + type: 'uint256', }, ], - stateMutability: "view", - type: "function", + stateMutability: 'view', + type: 'function', }, { inputs: [], - name: "MIN_TRANSACTION_TAX", + name: 'MIN_TRANSACTION_TAX', outputs: [ { - internalType: "uint256", - name: "", - type: "uint256", + internalType: 'uint256', + name: '', + type: 'uint256', }, ], - stateMutability: "view", - type: "function", + stateMutability: 'view', + type: 'function', }, { inputs: [ { - internalType: "address", - name: "", - type: "address", + internalType: 'address', + name: '', + type: 'address', }, ], - name: "erc1155Supported", + name: 'erc1155Supported', outputs: [ { - internalType: "bool", - name: "", - type: "bool", + internalType: 'bool', + name: '', + type: 'bool', }, ], - stateMutability: "view", - type: "function", + stateMutability: 'view', + type: 'function', }, { inputs: [ { - internalType: "address", - name: "", - type: "address", + internalType: 'address', + name: '', + type: 'address', }, ], - name: "erc20Supported", + name: 'erc1155SupportedHistory', outputs: [ { - internalType: "bool", - name: "", - type: "bool", + internalType: 'bool', + name: '', + type: 'bool', }, ], - stateMutability: "view", - type: "function", + stateMutability: 'view', + type: 'function', }, { inputs: [ { - internalType: "address", - name: "", - type: "address", + internalType: 'address', + name: '', + type: 'address', }, ], - name: "erc721Supported", + name: 'erc20Supported', outputs: [ { - internalType: "bool", - name: "", - type: "bool", + internalType: 'bool', + name: '', + type: 'bool', }, ], - stateMutability: "view", - type: "function", + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + name: 'erc721Supported', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + name: 'erc721SupportedHistory', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'view', + type: 'function', }, { inputs: [], - name: "feeToAddress", + name: 'feeToAddress', outputs: [ { - internalType: "address", - name: "", - type: "address", + internalType: 'address', + name: '', + type: 'address', }, ], - stateMutability: "view", - type: "function", + stateMutability: 'view', + type: 'function', }, { inputs: [], - name: "incrId", + name: 'incrId', outputs: [ { - internalType: "uint256", - name: "", - type: "uint256", + internalType: 'uint256', + name: '', + type: 'uint256', }, ], - stateMutability: "view", - type: "function", + stateMutability: 'view', + type: 'function', }, { inputs: [ { - internalType: "address", - name: "", - type: "address", + internalType: 'address', + name: '', + type: 'address', }, ], - name: "nftPriceMaxLimit", + name: 'nftPriceMaxLimit', outputs: [ { - internalType: "uint256", - name: "", - type: "uint256", + internalType: 'uint256', + name: '', + type: 'uint256', }, ], - stateMutability: "view", - type: "function", + stateMutability: 'view', + type: 'function', }, { inputs: [ { - internalType: "address", - name: "", - type: "address", + internalType: 'address', + name: '', + type: 'address', }, ], - name: "nftPriceMinLimit", + name: 'nftPriceMinLimit', outputs: [ { - internalType: "uint256", - name: "", - type: "uint256", + internalType: 'uint256', + name: '', + type: 'uint256', }, ], - stateMutability: "view", - type: "function", + stateMutability: 'view', + type: 'function', }, { inputs: [ { - internalType: "address", - name: "", - type: "address", + internalType: 'address', + name: '', + type: 'address', }, { - internalType: "address", - name: "", - type: "address", + internalType: 'address', + name: '', + type: 'address', }, { - internalType: "uint256[]", - name: "", - type: "uint256[]", + internalType: 'uint256[]', + name: '', + type: 'uint256[]', }, { - internalType: "uint256[]", - name: "", - type: "uint256[]", + internalType: 'uint256[]', + name: '', + type: 'uint256[]', }, { - internalType: "bytes", - name: "", - type: "bytes", + internalType: 'bytes', + name: '', + type: 'bytes', }, ], - name: "onERC1155BatchReceived", + name: 'onERC1155BatchReceived', outputs: [ { - internalType: "bytes4", - name: "", - type: "bytes4", + internalType: 'bytes4', + name: '', + type: 'bytes4', }, ], - stateMutability: "nonpayable", - type: "function", + stateMutability: 'nonpayable', + type: 'function', }, { inputs: [ { - internalType: "address", - name: "", - type: "address", + internalType: 'address', + name: '', + type: 'address', }, { - internalType: "address", - name: "", - type: "address", + internalType: 'address', + name: '', + type: 'address', }, { - internalType: "uint256", - name: "", - type: "uint256", + internalType: 'uint256', + name: '', + type: 'uint256', }, { - internalType: "uint256", - name: "", - type: "uint256", + internalType: 'uint256', + name: '', + type: 'uint256', }, { - internalType: "bytes", - name: "", - type: "bytes", + internalType: 'bytes', + name: '', + type: 'bytes', }, ], - name: "onERC1155Received", + name: 'onERC1155Received', outputs: [ { - internalType: "bytes4", - name: "", - type: "bytes4", + internalType: 'bytes4', + name: '', + type: 'bytes4', }, ], - stateMutability: "nonpayable", - type: "function", + stateMutability: 'nonpayable', + type: 'function', }, { inputs: [ { - internalType: "address", - name: "", - type: "address", + internalType: 'address', + name: '', + type: 'address', }, { - internalType: "address", - name: "", - type: "address", + internalType: 'address', + name: '', + type: 'address', }, { - internalType: "uint256", - name: "", - type: "uint256", + internalType: 'uint256', + name: '', + type: 'uint256', }, { - internalType: "bytes", - name: "", - type: "bytes", + internalType: 'bytes', + name: '', + type: 'bytes', }, ], - name: "onERC721Received", + name: 'onERC721Received', outputs: [ { - internalType: "bytes4", - name: "", - type: "bytes4", + internalType: 'bytes4', + name: '', + type: 'bytes4', }, ], - stateMutability: "nonpayable", - type: "function", + stateMutability: 'nonpayable', + type: 'function', }, { inputs: [ { - internalType: "uint256", - name: "", - type: "uint256", + internalType: 'uint256', + name: '', + type: 'uint256', }, ], - name: "orderInfos", + name: 'orderInfos', outputs: [ { - internalType: "uint256", - name: "orderId", - type: "uint256", + internalType: 'uint256', + name: 'orderId', + type: 'uint256', }, { - internalType: "uint256", - name: "tokenId", - type: "uint256", + internalType: 'uint256', + name: 'tokenId', + type: 'uint256', }, { - internalType: "uint256", - name: "amount", - type: "uint256", + internalType: 'uint256', + name: 'amount', + type: 'uint256', }, { - internalType: "address", - name: "owner", - type: "address", + internalType: 'address', + name: 'owner', + type: 'address', }, { - internalType: "uint256", - name: "price", - type: "uint256", + internalType: 'uint256', + name: 'price', + type: 'uint256', }, { - internalType: "address", - name: "nftToken", - type: "address", + internalType: 'address', + name: 'nftToken', + type: 'address', }, { - internalType: "address", - name: "currency", - type: "address", + internalType: 'address', + name: 'currency', + type: 'address', }, ], - stateMutability: "view", - type: "function", + stateMutability: 'view', + type: 'function', }, { inputs: [], - name: "owner", + name: 'owner', outputs: [ { - internalType: "address", - name: "", - type: "address", + internalType: 'address', + name: '', + type: 'address', }, ], - stateMutability: "view", - type: "function", + stateMutability: 'view', + type: 'function', }, { inputs: [], - name: "renounceOwnership", + name: 'renounceOwnership', outputs: [], - stateMutability: "nonpayable", - type: "function", + stateMutability: 'nonpayable', + type: 'function', }, { inputs: [ { - internalType: "bytes4", - name: "interfaceId", - type: "bytes4", + internalType: 'bytes4', + name: 'interfaceId', + type: 'bytes4', }, ], - name: "supportsInterface", + name: 'supportsInterface', outputs: [ { - internalType: "bool", - name: "", - type: "bool", + internalType: 'bool', + name: '', + type: 'bool', }, ], - stateMutability: "view", - type: "function", + stateMutability: 'view', + type: 'function', }, { inputs: [], - name: "taxToAddress", + name: 'taxToAddress', outputs: [ { - internalType: "address", - name: "", - type: "address", + internalType: 'address', + name: '', + type: 'address', }, ], - stateMutability: "view", - type: "function", + stateMutability: 'view', + type: 'function', }, { inputs: [], - name: "tranFeeTotal", + name: 'tranFeeTotal', outputs: [ { - internalType: "uint256", - name: "", - type: "uint256", + internalType: 'uint256', + name: '', + type: 'uint256', }, ], - stateMutability: "view", - type: "function", + stateMutability: 'view', + type: 'function', }, { inputs: [], - name: "tranTaxTotal", + name: 'tranTaxTotal', outputs: [ { - internalType: "uint256", - name: "", - type: "uint256", + internalType: 'uint256', + name: '', + type: 'uint256', }, ], - stateMutability: "view", - type: "function", + stateMutability: 'view', + type: 'function', }, { inputs: [], - name: "transactionFee", + name: 'transactionFee', outputs: [ { - internalType: "uint256", - name: "", - type: "uint256", + internalType: 'uint256', + name: '', + type: 'uint256', }, ], - stateMutability: "view", - type: "function", + stateMutability: 'view', + type: 'function', }, { inputs: [], - name: "transactionTax", + name: 'transactionTax', outputs: [ { - internalType: "uint256", - name: "", - type: "uint256", + internalType: 'uint256', + name: '', + type: 'uint256', }, ], - stateMutability: "view", - type: "function", + stateMutability: 'view', + type: 'function', }, { inputs: [ { - internalType: "address", - name: "newOwner", - type: "address", + internalType: 'address', + name: 'newOwner', + type: 'address', }, ], - name: "transferOwnership", + name: 'transferOwnership', outputs: [], - stateMutability: "nonpayable", - type: "function", + stateMutability: 'nonpayable', + type: 'function', }, { inputs: [ { - internalType: "address", - name: "nftToken", - type: "address", + internalType: 'address', + name: 'nftToken', + type: 'address', }, { - internalType: "address", - name: "currency", - type: "address", + internalType: 'address', + name: 'currency', + type: 'address', }, { - internalType: "uint256", - name: "tokenId", - type: "uint256", + internalType: 'uint256', + name: 'tokenId', + type: 'uint256', }, { - internalType: "uint256", - name: "price", - type: "uint256", + internalType: 'uint256', + name: 'price', + type: 'uint256', }, { - internalType: "uint256", - name: "amount", - type: "uint256", + internalType: 'uint256', + name: 'amount', + type: 'uint256', }, ], - name: "sell", + name: 'sell', outputs: [], - stateMutability: "nonpayable", - type: "function", + stateMutability: 'nonpayable', + type: 'function', }, { inputs: [ { - internalType: "uint256", - name: "orderId", - type: "uint256", + internalType: 'uint256', + name: 'orderId', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'price', + type: 'uint256', }, ], - name: "buy", + name: 'buy', outputs: [], - stateMutability: "nonpayable", - type: "function", + stateMutability: 'nonpayable', + type: 'function', }, { inputs: [ { - internalType: "uint256", - name: "orderId", - type: "uint256", + internalType: 'uint256', + name: 'orderId', + type: 'uint256', }, ], - name: "cancelOrder", + name: 'cancelOrder', outputs: [], - stateMutability: "nonpayable", - type: "function", + stateMutability: 'nonpayable', + type: 'function', }, { inputs: [ { - internalType: "uint256", - name: "orderId", - type: "uint256", + internalType: 'uint256', + name: 'orderId', + type: 'uint256', }, { - internalType: "uint256", - name: "price", - type: "uint256", + internalType: 'uint256', + name: 'price', + type: 'uint256', }, ], - name: "updatePrice", + name: 'updatePrice', outputs: [], - stateMutability: "nonpayable", - type: "function", + stateMutability: 'nonpayable', + type: 'function', }, { inputs: [ { - internalType: "address", - name: "nftToken", - type: "address", + internalType: 'address', + name: 'nftToken', + type: 'address', }, ], - name: "addERC721Support", + name: 'addERC721Support', outputs: [], - stateMutability: "nonpayable", - type: "function", + stateMutability: 'nonpayable', + type: 'function', }, { inputs: [ { - internalType: "address", - name: "nftToken", - type: "address", + internalType: 'address', + name: 'nftToken', + type: 'address', }, ], - name: "removeERC721Support", + name: 'removeERC721Support', outputs: [], - stateMutability: "nonpayable", - type: "function", + stateMutability: 'nonpayable', + type: 'function', }, { inputs: [ { - internalType: "address", - name: "nftToken", - type: "address", + internalType: 'address', + name: 'nftToken', + type: 'address', }, ], - name: "addERC1155Support", + name: 'addERC1155Support', outputs: [], - stateMutability: "nonpayable", - type: "function", + stateMutability: 'nonpayable', + type: 'function', }, { inputs: [ { - internalType: "address", - name: "nftToken", - type: "address", + internalType: 'address', + name: 'nftToken', + type: 'address', }, ], - name: "removeERC1155Support", + name: 'removeERC1155Support', outputs: [], - stateMutability: "nonpayable", - type: "function", + stateMutability: 'nonpayable', + type: 'function', }, { inputs: [ { - internalType: "address", - name: "erc20", - type: "address", + internalType: 'address', + name: 'erc20', + type: 'address', }, ], - name: "addERC20Support", + name: 'addERC20Support', outputs: [], - stateMutability: "nonpayable", - type: "function", + stateMutability: 'nonpayable', + type: 'function', }, { inputs: [ { - internalType: "address", - name: "erc20", - type: "address", + internalType: 'address', + name: 'erc20', + type: 'address', }, ], - name: "removeERC20Support", + name: 'removeERC20Support', outputs: [], - stateMutability: "nonpayable", - type: "function", + stateMutability: 'nonpayable', + type: 'function', }, { inputs: [ { - internalType: "address", - name: "nftToken", - type: "address", + internalType: 'address', + name: 'nftToken', + type: 'address', }, { - internalType: "uint256", - name: "maxLimit", - type: "uint256", + internalType: 'uint256', + name: 'maxLimit', + type: 'uint256', }, ], - name: "setNFTPriceMaxLimit", + name: 'setNFTPriceMaxLimit', outputs: [], - stateMutability: "nonpayable", - type: "function", + stateMutability: 'nonpayable', + type: 'function', }, { inputs: [ { - internalType: "address", - name: "nftToken", - type: "address", + internalType: 'address', + name: 'nftToken', + type: 'address', }, { - internalType: "uint256", - name: "minLimit", - type: "uint256", + internalType: 'uint256', + name: 'minLimit', + type: 'uint256', }, ], - name: "setNFTPriceMinLimit", + name: 'setNFTPriceMinLimit', outputs: [], - stateMutability: "nonpayable", - type: "function", + stateMutability: 'nonpayable', + type: 'function', }, { inputs: [ { - internalType: "uint256", - name: "_transactionFee", - type: "uint256", + internalType: 'uint256', + name: '_transactionFee', + type: 'uint256', }, ], - name: "setTransactionFee", + name: 'setTransactionFee', outputs: [], - stateMutability: "nonpayable", - type: "function", + stateMutability: 'nonpayable', + type: 'function', }, { inputs: [ { - internalType: "address", - name: "_feeToAddress", - type: "address", + internalType: 'address', + name: '_feeToAddress', + type: 'address', }, ], - name: "setFeeToAddress", + name: 'setFeeToAddress', outputs: [], - stateMutability: "nonpayable", - type: "function", + stateMutability: 'nonpayable', + type: 'function', }, { inputs: [ { - internalType: "uint256", - name: "_transactionTax", - type: "uint256", + internalType: 'uint256', + name: '_transactionTax', + type: 'uint256', }, ], - name: "setTransactionTax", + name: 'setTransactionTax', outputs: [], - stateMutability: "nonpayable", - type: "function", + stateMutability: 'nonpayable', + type: 'function', }, { inputs: [ { - internalType: "address", - name: "_taxToAddress", - type: "address", + internalType: 'address', + name: '_taxToAddress', + type: 'address', }, ], - name: "setTaxToAddress", + name: 'setTaxToAddress', outputs: [], - stateMutability: "nonpayable", - type: "function", + stateMutability: 'nonpayable', + type: 'function', }, ]; diff --git a/src/config/cfg_421613_dev.js b/src/config/cfg_421613_dev.js index b5dc5b8..bb6d014 100644 --- a/src/config/cfg_421613_dev.js +++ b/src/config/cfg_421613_dev.js @@ -36,7 +36,7 @@ module.exports = { ], contracts: { minterFactory: '0x1A27515c35a92Fb276c2670fa27C85ffAd75D094', - nftmarket: '0x28cd862Baa826e65a0c0F1179B9A3423dF4d366A', + nftmarket: '0xB9720d2c9D01FE36a1aA1224cbB06BF8e436812E', nftmall: '0x4d71dE0428328112A78D402A6fdd7ceD1C96B71e', gamemarket: '0x46e2C612756b702b3d68d89F97c88FFa725F6fab', gamemall: '0x1D058c7c7451c34BbfF9c0dF1C16b95C5d171d64', diff --git a/src/standards/JCStandard.ts b/src/standards/JCStandard.ts index fbd3474..d6823ea 100644 --- a/src/standards/JCStandard.ts +++ b/src/standards/JCStandard.ts @@ -9,6 +9,7 @@ import { abiGameMall } from '../abis/abiGameMall'; import { ZError } from '../common/ZError'; import { abiERC20 } from '../abis/abiERC20'; import { abiERC721 } from '../abis/abiERC721'; +import { toBN } from '../util/number.util'; export class JCStandard { private web3: Web3; @@ -234,7 +235,17 @@ export class JCStandard { return universalChainCb(logData, contract.methods.cancelOrder(orderId).send({ gas, gasPrice })); } - async marketBuy({ orderId, gas, estimate }: { orderId: string; gas?: number; estimate: number }) { + async marketBuy({ + orderId, + gas, + price, + estimate, + }: { + orderId: string; + price: string; + gas?: number; + estimate: number; + }) { const cfg = jc.wallet.currentChainCfg; estimate = parseInt(estimate + ''); const addressMarket = cfg.contracts.nftmarket; @@ -247,6 +258,9 @@ export class JCStandard { if (!orderInfo.orderId) { throw new ZError(100, `order info with id: ${orderId} not found`); } + if (!toBN(price).eq(toBN(orderInfo.price))) { + throw new ZError(101, `price must equal to ${orderInfo.price}`); + } const tokenInstance = new this.web3.eth.Contract(abiERC20, orderInfo.currency, { //@ts-ignore from: jc.wallet.currentAccAddr, @@ -255,10 +269,10 @@ export class JCStandard { console.log('approved:: ', approved); let gasApprove = 0; let gasPrice = await jc.wallet.fetchGasPrice(); - if (approved < orderInfo.price) { - gasApprove = await tokenInstance.methods.approve(addressMarket, orderInfo.price).estimateGas(); + if (toBN(approved).lt(toBN(price))) { + gasApprove = await tokenInstance.methods.approve(addressMarket, price).estimateGas(); gasApprove = (gasApprove * GAS_BOOST) | 1; - await tokenInstance.methods.approve(addressMarket, orderInfo.price).send({ gas: gasApprove, gasPrice }); + await tokenInstance.methods.approve(addressMarket, price).send({ gas: gasApprove, gasPrice }); } if (!gas) { gas = await contract.methods.buy(orderId).estimateGas(); @@ -269,7 +283,6 @@ export class JCStandard { if (estimate) { return jc.wallet.generateGasShow(gas + gasApprove); } - //TODO:: 记录详细的转账记录, -> seller, -> txFeeAddress, -> txTaxAddress let details = [ { address: addressMarket, @@ -295,7 +308,7 @@ export class JCStandard { title: 'market_buy', details: details, }; - return universalChainCb(logData, contract.methods.buy(orderId).send({ gas, gasPrice })); + return universalChainCb(logData, contract.methods.buy(orderId, price).send({ gas, gasPrice })); } async marketOrderInfo(orderId: string) { @@ -347,7 +360,7 @@ export class JCStandard { console.log('approved:: ', approved); let gasApprove = 0; let gasPrice = await jc.wallet.fetchGasPrice(); - if (approved < price) { + if (toBN(approved).lt(toBN(price))) { gasApprove = await tokenInstance.methods.approve(addressGameMall, price).estimateGas(); gasApprove = (gasApprove * GAS_BOOST) | 1; console.log('gasApprove:: ', gasApprove); @@ -426,7 +439,7 @@ export class JCStandard { console.log('approved:: ', approved); let gasApprove = 0; let gasPrice = await jc.wallet.fetchGasPrice(); - if (approved < price) { + if (toBN(approved).lt(toBN(price))) { gasApprove = await tokenInstance.methods.approve(addressGameMarket, price).estimateGas(); gasApprove = (gasApprove * GAS_BOOST) | 1; await tokenInstance.methods.approve(addressGameMarket, price).send({ gas: gasApprove, gasPrice }); @@ -508,7 +521,7 @@ export class JCStandard { let gasPrice = await jc.wallet.fetchGasPrice(); console.log('gas price: ' + gasPrice); let gasApprove = 0; - if (approved < values[1]) { + if (toBN(approved).lt(toBN(values[1]))) { gasApprove = await tokenInstance.methods.approve(addressMall, values[1]).estimateGas(); gasApprove = (gasApprove * GAS_BOOST) | 1; await tokenInstance.methods.approve(addressMall, values[1]).send({ gas: gasApprove, gasPrice });