From ae626a0e5a2d262f658199f8d03bf546de439c81 Mon Sep 17 00:00:00 2001 From: shinji19 Date: Wed, 8 Feb 2023 09:25:32 +0000 Subject: [PATCH 1/4] =?UTF-8?q?evm=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lepus-subql/package.json | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lepus-subql/package.json b/lepus-subql/package.json index 25cb4d2..1981c06 100644 --- a/lepus-subql/package.json +++ b/lepus-subql/package.json @@ -20,13 +20,18 @@ ], "author": "SubQuery Team", "license": "MIT", + "resolutions": { + "ipfs-unixfs": "6.0.6" + }, "devDependencies": { "@polkadot/api": "^9", + "@subql/cli": "latest", + "@subql/frontier-evm-processor": "^0.1.2", "@subql/types": "latest", - "typescript": "^4.1.3", - "@subql/cli": "latest" + "typescript": "^4.1.3" }, "exports": { - "chaintypes": "src/chaintypes.ts" + "frontierEvm": "./node_modules/@subql/frontier-evm-processor/dist/index.js", + "chaintypes": "./src/chaintypes.ts" } } \ No newline at end of file From 31cab136a8437e25f095d3552dea3c9dfb1edec5 Mon Sep 17 00:00:00 2001 From: shinji19 Date: Wed, 8 Feb 2023 09:28:25 +0000 Subject: [PATCH 2/4] =?UTF-8?q?tofuNFT=E3=82=B5=E3=83=B3=E3=83=97=E3=83=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lepus-subql/abis/tofuNFT.abi.json | 1557 +++++++++++++++++ lepus-subql/project.yaml | 24 + lepus-subql/src/index.ts | 1 + .../src/mappings/tofuNFTMappingHandlers.ts | 39 + 4 files changed, 1621 insertions(+) create mode 100644 lepus-subql/abis/tofuNFT.abi.json create mode 100644 lepus-subql/src/mappings/tofuNFTMappingHandlers.ts diff --git a/lepus-subql/abis/tofuNFT.abi.json b/lepus-subql/abis/tofuNFT.abi.json new file mode 100644 index 0000000..eba1dd6 --- /dev/null +++ b/lepus-subql/abis/tofuNFT.abi.json @@ -0,0 +1,1557 @@ +[ + { + "type": "constructor", + "stateMutability": "nonpayable", + "inputs": [ + { + "type": "address", + "name": "weth_", + "internalType": "contract IWETH" + } + ] + }, + { + "type": "event", + "name": "EvAuctionRefund", + "inputs": [ + { + "type": "uint256", + "name": "id", + "internalType": "uint256", + "indexed": true + }, + { + "type": "address", + "name": "bidder", + "internalType": "address", + "indexed": false + }, + { + "type": "uint256", + "name": "refund", + "internalType": "uint256", + "indexed": false + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "EvCouponSpent", + "inputs": [ + { + "type": "uint256", + "name": "id", + "internalType": "uint256", + "indexed": true + }, + { + "type": "uint256", + "name": "couponId", + "internalType": "uint256", + "indexed": true + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "EvInventoryUpdate", + "inputs": [ + { + "type": "uint256", + "name": "id", + "internalType": "uint256", + "indexed": true + }, + { + "type": "tuple", + "name": "inventory", + "internalType": "struct MarketNG.Inventory", + "indexed": false, + "components": [ + { + "type": "address", + "name": "seller", + "internalType": "address" + }, + { + "type": "address", + "name": "buyer", + "internalType": "address" + }, + { + "type": "address", + "name": "currency", + "internalType": "contract IERC20" + }, + { + "type": "uint256", + "name": "price", + "internalType": "uint256" + }, + { + "type": "uint256", + "name": "netPrice", + "internalType": "uint256" + }, + { + "type": "uint256", + "name": "deadline", + "internalType": "uint256" + }, + { + "type": "uint8", + "name": "kind", + "internalType": "uint8" + }, + { + "type": "uint8", + "name": "status", + "internalType": "uint8" + } + ] + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "EvMarketSignerUpdate", + "inputs": [ + { + "type": "address", + "name": "addr", + "internalType": "address", + "indexed": false + }, + { + "type": "bool", + "name": "isRemoval", + "internalType": "bool", + "indexed": false + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "EvSettingsUpdated", + "inputs": [], + "anonymous": false + }, + { + "type": "event", + "name": "EvSwapped", + "inputs": [ + { + "type": "tuple", + "name": "req", + "internalType": "struct MarketNG.Swap", + "indexed": false, + "components": [ + { + "type": "bytes32", + "name": "salt", + "internalType": "bytes32" + }, + { + "type": "address", + "name": "creator", + "internalType": "address" + }, + { + "type": "uint256", + "name": "deadline", + "internalType": "uint256" + }, + { + "type": "tuple[]", + "name": "has", + "internalType": "struct MarketNG.Pair721[]", + "components": [ + { + "type": "address", + "name": "token", + "internalType": "contract IERC721" + }, + { + "type": "uint256", + "name": "tokenId", + "internalType": "uint256" + } + ] + }, + { + "type": "tuple[]", + "name": "wants", + "internalType": "struct MarketNG.Pair721[]", + "components": [ + { + "type": "address", + "name": "token", + "internalType": "contract IERC721" + }, + { + "type": "uint256", + "name": "tokenId", + "internalType": "uint256" + } + ] + } + ] + }, + { + "type": "bytes", + "name": "signature", + "internalType": "bytes", + "indexed": false + }, + { + "type": "address", + "name": "swapper", + "internalType": "address", + "indexed": false + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "OwnershipTransferred", + "inputs": [ + { + "type": "address", + "name": "previousOwner", + "internalType": "address", + "indexed": true + }, + { + "type": "address", + "name": "newOwner", + "internalType": "address", + "indexed": true + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Paused", + "inputs": [ + { + "type": "address", + "name": "account", + "internalType": "address", + "indexed": false + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Unpaused", + "inputs": [ + { + "type": "address", + "name": "account", + "internalType": "address", + "indexed": false + } + ], + "anonymous": false + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "uint8", + "name": "", + "internalType": "uint8" + } + ], + "name": "KIND_AUCTION", + "inputs": [] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "uint8", + "name": "", + "internalType": "uint8" + } + ], + "name": "KIND_BUY", + "inputs": [] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "uint8", + "name": "", + "internalType": "uint8" + } + ], + "name": "KIND_SELL", + "inputs": [] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "uint8", + "name": "", + "internalType": "uint8" + } + ], + "name": "OP_ACCEPT_AUCTION", + "inputs": [] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "uint8", + "name": "", + "internalType": "uint8" + } + ], + "name": "OP_ACCEPT_BUY", + "inputs": [] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "uint8", + "name": "", + "internalType": "uint8" + } + ], + "name": "OP_BID", + "inputs": [] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "uint8", + "name": "", + "internalType": "uint8" + } + ], + "name": "OP_BUY", + "inputs": [] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "uint8", + "name": "", + "internalType": "uint8" + } + ], + "name": "OP_CANCEL_BUY", + "inputs": [] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "uint8", + "name": "", + "internalType": "uint8" + } + ], + "name": "OP_COMPLETE_AUCTION", + "inputs": [] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "uint8", + "name": "", + "internalType": "uint8" + } + ], + "name": "OP_COMPLETE_BUY", + "inputs": [] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "uint8", + "name": "", + "internalType": "uint8" + } + ], + "name": "OP_COMPLETE_SELL", + "inputs": [] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "uint8", + "name": "", + "internalType": "uint8" + } + ], + "name": "OP_MAX", + "inputs": [] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "uint8", + "name": "", + "internalType": "uint8" + } + ], + "name": "OP_MIN", + "inputs": [] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "uint8", + "name": "", + "internalType": "uint8" + } + ], + "name": "OP_REJECT_BUY", + "inputs": [] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "uint256", + "name": "", + "internalType": "uint256" + } + ], + "name": "RATE_BASE", + "inputs": [] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "uint8", + "name": "", + "internalType": "uint8" + } + ], + "name": "STATUS_CANCELLED", + "inputs": [] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "uint8", + "name": "", + "internalType": "uint8" + } + ], + "name": "STATUS_DONE", + "inputs": [] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "uint8", + "name": "", + "internalType": "uint8" + } + ], + "name": "STATUS_OPEN", + "inputs": [] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "uint8", + "name": "", + "internalType": "uint8" + } + ], + "name": "TOKEN_1155", + "inputs": [] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "uint8", + "name": "", + "internalType": "uint8" + } + ], + "name": "TOKEN_721", + "inputs": [] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "uint8", + "name": "", + "internalType": "uint8" + } + ], + "name": "TOKEN_MINT", + "inputs": [] + }, + { + "type": "function", + "stateMutability": "nonpayable", + "outputs": [], + "name": "cancelBuys", + "inputs": [ + { + "type": "uint256[]", + "name": "ids", + "internalType": "uint256[]" + } + ] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "bool", + "name": "", + "internalType": "bool" + } + ], + "name": "couponSpent", + "inputs": [ + { + "type": "uint256", + "name": "", + "internalType": "uint256" + } + ] + }, + { + "type": "function", + "stateMutability": "nonpayable", + "outputs": [], + "name": "emergencyCancelAuction", + "inputs": [ + { + "type": "uint256", + "name": "id", + "internalType": "uint256" + }, + { + "type": "bool", + "name": "noBundle", + "internalType": "bool" + } + ] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "bool", + "name": "", + "internalType": "bool" + } + ], + "name": "hasInv", + "inputs": [ + { + "type": "uint256", + "name": "id", + "internalType": "uint256" + } + ] + }, + { + "type": "function", + "stateMutability": "pure", + "outputs": [ + { + "type": "bool", + "name": "", + "internalType": "bool" + } + ], + "name": "hasSignedIntention", + "inputs": [ + { + "type": "uint8", + "name": "op", + "internalType": "uint8" + } + ] + }, + { + "type": "function", + "stateMutability": "nonpayable", + "outputs": [], + "name": "inCaseMoneyGetsStuck", + "inputs": [ + { + "type": "address", + "name": "to", + "internalType": "address" + }, + { + "type": "address", + "name": "currency", + "internalType": "contract IERC20" + }, + { + "type": "uint256", + "name": "amount", + "internalType": "uint256" + } + ] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "address", + "name": "seller", + "internalType": "address" + }, + { + "type": "address", + "name": "buyer", + "internalType": "address" + }, + { + "type": "address", + "name": "currency", + "internalType": "contract IERC20" + }, + { + "type": "uint256", + "name": "price", + "internalType": "uint256" + }, + { + "type": "uint256", + "name": "netPrice", + "internalType": "uint256" + }, + { + "type": "uint256", + "name": "deadline", + "internalType": "uint256" + }, + { + "type": "uint8", + "name": "kind", + "internalType": "uint8" + }, + { + "type": "uint8", + "name": "status", + "internalType": "uint8" + } + ], + "name": "inventories", + "inputs": [ + { + "type": "uint256", + "name": "", + "internalType": "uint256" + } + ] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "uint256", + "name": "", + "internalType": "uint256" + } + ], + "name": "inventoryTokenCounts", + "inputs": [ + { + "type": "uint256", + "name": "", + "internalType": "uint256" + } + ] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "address", + "name": "token", + "internalType": "address" + }, + { + "type": "uint256", + "name": "tokenId", + "internalType": "uint256" + }, + { + "type": "uint256", + "name": "amount", + "internalType": "uint256" + }, + { + "type": "uint8", + "name": "kind", + "internalType": "uint8" + }, + { + "type": "bytes", + "name": "mintData", + "internalType": "bytes" + } + ], + "name": "inventoryTokens", + "inputs": [ + { + "type": "uint256", + "name": "", + "internalType": "uint256" + }, + { + "type": "uint256", + "name": "", + "internalType": "uint256" + } + ] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "bool", + "name": "", + "internalType": "bool" + } + ], + "name": "isAuction", + "inputs": [ + { + "type": "uint256", + "name": "id", + "internalType": "uint256" + } + ] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "bool", + "name": "", + "internalType": "bool" + } + ], + "name": "isAuctionOpen", + "inputs": [ + { + "type": "uint256", + "name": "id", + "internalType": "uint256" + } + ] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "bool", + "name": "", + "internalType": "bool" + } + ], + "name": "isBundleApproved", + "inputs": [ + { + "type": "uint256", + "name": "invId", + "internalType": "uint256" + }, + { + "type": "address", + "name": "owner", + "internalType": "address" + } + ] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "bool", + "name": "", + "internalType": "bool" + } + ], + "name": "isBuy", + "inputs": [ + { + "type": "uint256", + "name": "id", + "internalType": "uint256" + } + ] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "bool", + "name": "", + "internalType": "bool" + } + ], + "name": "isBuyOpen", + "inputs": [ + { + "type": "uint256", + "name": "id", + "internalType": "uint256" + } + ] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "bool", + "name": "", + "internalType": "bool" + } + ], + "name": "isExpired", + "inputs": [ + { + "type": "uint256", + "name": "id", + "internalType": "uint256" + } + ] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "bool", + "name": "", + "internalType": "bool" + } + ], + "name": "isSell", + "inputs": [ + { + "type": "uint256", + "name": "id", + "internalType": "uint256" + } + ] + }, + { + "type": "function", + "stateMutability": "pure", + "outputs": [ + { + "type": "bool", + "name": "", + "internalType": "bool" + } + ], + "name": "isSignatureValid", + "inputs": [ + { + "type": "bytes", + "name": "signature", + "internalType": "bytes" + }, + { + "type": "bytes32", + "name": "hash", + "internalType": "bytes32" + }, + { + "type": "address", + "name": "signer", + "internalType": "address" + } + ] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "bool", + "name": "", + "internalType": "bool" + } + ], + "name": "isStatusOpen", + "inputs": [ + { + "type": "uint256", + "name": "id", + "internalType": "uint256" + } + ] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "bool", + "name": "", + "internalType": "bool" + } + ], + "name": "marketSigners", + "inputs": [ + { + "type": "address", + "name": "", + "internalType": "address" + } + ] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "uint256", + "name": "", + "internalType": "uint256" + } + ], + "name": "minAuctionDuration", + "inputs": [] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "uint256", + "name": "", + "internalType": "uint256" + } + ], + "name": "minAuctionIncrement", + "inputs": [] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "bytes4", + "name": "", + "internalType": "bytes4" + } + ], + "name": "onERC1155BatchReceived", + "inputs": [ + { + "type": "address", + "name": "operator", + "internalType": "address" + }, + { + "type": "address", + "name": "from", + "internalType": "address" + }, + { + "type": "uint256[]", + "name": "ids", + "internalType": "uint256[]" + }, + { + "type": "uint256[]", + "name": "values", + "internalType": "uint256[]" + }, + { + "type": "bytes", + "name": "data", + "internalType": "bytes" + } + ] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "bytes4", + "name": "", + "internalType": "bytes4" + } + ], + "name": "onERC1155Received", + "inputs": [ + { + "type": "address", + "name": "operator", + "internalType": "address" + }, + { + "type": "address", + "name": "from", + "internalType": "address" + }, + { + "type": "uint256", + "name": "id", + "internalType": "uint256" + }, + { + "type": "uint256", + "name": "value", + "internalType": "uint256" + }, + { + "type": "bytes", + "name": "data", + "internalType": "bytes" + } + ] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "bytes4", + "name": "", + "internalType": "bytes4" + } + ], + "name": "onERC721Received", + "inputs": [ + { + "type": "address", + "name": "operator", + "internalType": "address" + }, + { + "type": "address", + "name": "from", + "internalType": "address" + }, + { + "type": "uint256", + "name": "tokenId", + "internalType": "uint256" + }, + { + "type": "bytes", + "name": "data", + "internalType": "bytes" + } + ] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "address", + "name": "", + "internalType": "address" + } + ], + "name": "owner", + "inputs": [] + }, + { + "type": "function", + "stateMutability": "nonpayable", + "outputs": [], + "name": "pause", + "inputs": [] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "bool", + "name": "", + "internalType": "bool" + } + ], + "name": "paused", + "inputs": [] + }, + { + "type": "function", + "stateMutability": "nonpayable", + "outputs": [], + "name": "renounceOwnership", + "inputs": [] + }, + { + "type": "function", + "stateMutability": "payable", + "outputs": [], + "name": "run", + "inputs": [ + { + "type": "tuple", + "name": "intent", + "internalType": "struct MarketNG.Intention", + "components": [ + { + "type": "address", + "name": "user", + "internalType": "address" + }, + { + "type": "tuple[]", + "name": "bundle", + "internalType": "struct MarketNG.TokenPair[]", + "components": [ + { + "type": "address", + "name": "token", + "internalType": "address" + }, + { + "type": "uint256", + "name": "tokenId", + "internalType": "uint256" + }, + { + "type": "uint256", + "name": "amount", + "internalType": "uint256" + }, + { + "type": "uint8", + "name": "kind", + "internalType": "uint8" + }, + { + "type": "bytes", + "name": "mintData", + "internalType": "bytes" + } + ] + }, + { + "type": "address", + "name": "currency", + "internalType": "contract IERC20" + }, + { + "type": "uint256", + "name": "price", + "internalType": "uint256" + }, + { + "type": "uint256", + "name": "deadline", + "internalType": "uint256" + }, + { + "type": "bytes32", + "name": "salt", + "internalType": "bytes32" + }, + { + "type": "uint8", + "name": "kind", + "internalType": "uint8" + } + ] + }, + { + "type": "tuple", + "name": "detail", + "internalType": "struct MarketNG.Detail", + "components": [ + { + "type": "bytes32", + "name": "intentionHash", + "internalType": "bytes32" + }, + { + "type": "address", + "name": "signer", + "internalType": "address" + }, + { + "type": "uint256", + "name": "txDeadline", + "internalType": "uint256" + }, + { + "type": "bytes32", + "name": "salt", + "internalType": "bytes32" + }, + { + "type": "uint256", + "name": "id", + "internalType": "uint256" + }, + { + "type": "uint8", + "name": "opcode", + "internalType": "uint8" + }, + { + "type": "address", + "name": "caller", + "internalType": "address" + }, + { + "type": "address", + "name": "currency", + "internalType": "contract IERC20" + }, + { + "type": "uint256", + "name": "price", + "internalType": "uint256" + }, + { + "type": "uint256", + "name": "incentiveRate", + "internalType": "uint256" + }, + { + "type": "tuple", + "name": "settlement", + "internalType": "struct MarketNG.Settlement", + "components": [ + { + "type": "uint256[]", + "name": "coupons", + "internalType": "uint256[]" + }, + { + "type": "uint256", + "name": "feeRate", + "internalType": "uint256" + }, + { + "type": "uint256", + "name": "royaltyRate", + "internalType": "uint256" + }, + { + "type": "uint256", + "name": "buyerCashbackRate", + "internalType": "uint256" + }, + { + "type": "address", + "name": "feeAddress", + "internalType": "address" + }, + { + "type": "address", + "name": "royaltyAddress", + "internalType": "address" + } + ] + }, + { + "type": "tuple[]", + "name": "bundle", + "internalType": "struct MarketNG.TokenPair[]", + "components": [ + { + "type": "address", + "name": "token", + "internalType": "address" + }, + { + "type": "uint256", + "name": "tokenId", + "internalType": "uint256" + }, + { + "type": "uint256", + "name": "amount", + "internalType": "uint256" + }, + { + "type": "uint8", + "name": "kind", + "internalType": "uint8" + }, + { + "type": "bytes", + "name": "mintData", + "internalType": "bytes" + } + ] + }, + { + "type": "uint256", + "name": "deadline", + "internalType": "uint256" + } + ] + }, + { + "type": "bytes", + "name": "sigIntent", + "internalType": "bytes" + }, + { + "type": "bytes", + "name": "sigDetail", + "internalType": "bytes" + } + ] + }, + { + "type": "function", + "stateMutability": "nonpayable", + "outputs": [], + "name": "send", + "inputs": [ + { + "type": "address", + "name": "to", + "internalType": "address" + }, + { + "type": "tuple[]", + "name": "tokens", + "internalType": "struct MarketNG.Pair721[]", + "components": [ + { + "type": "address", + "name": "token", + "internalType": "contract IERC721" + }, + { + "type": "uint256", + "name": "tokenId", + "internalType": "uint256" + } + ] + } + ] + }, + { + "type": "function", + "stateMutability": "pure", + "outputs": [ + { + "type": "bool", + "name": "", + "internalType": "bool" + } + ], + "name": "supportsInterface", + "inputs": [ + { + "type": "bytes4", + "name": "interfaceId", + "internalType": "bytes4" + } + ] + }, + { + "type": "function", + "stateMutability": "nonpayable", + "outputs": [], + "name": "swap", + "inputs": [ + { + "type": "tuple", + "name": "req", + "internalType": "struct MarketNG.Swap", + "components": [ + { + "type": "bytes32", + "name": "salt", + "internalType": "bytes32" + }, + { + "type": "address", + "name": "creator", + "internalType": "address" + }, + { + "type": "uint256", + "name": "deadline", + "internalType": "uint256" + }, + { + "type": "tuple[]", + "name": "has", + "internalType": "struct MarketNG.Pair721[]", + "components": [ + { + "type": "address", + "name": "token", + "internalType": "contract IERC721" + }, + { + "type": "uint256", + "name": "tokenId", + "internalType": "uint256" + } + ] + }, + { + "type": "tuple[]", + "name": "wants", + "internalType": "struct MarketNG.Pair721[]", + "components": [ + { + "type": "address", + "name": "token", + "internalType": "contract IERC721" + }, + { + "type": "uint256", + "name": "tokenId", + "internalType": "uint256" + } + ] + } + ] + }, + { + "type": "bytes", + "name": "signature", + "internalType": "bytes" + } + ] + }, + { + "type": "function", + "stateMutability": "nonpayable", + "outputs": [], + "name": "transferOwnership", + "inputs": [ + { + "type": "address", + "name": "newOwner", + "internalType": "address" + } + ] + }, + { + "type": "function", + "stateMutability": "nonpayable", + "outputs": [], + "name": "unpause", + "inputs": [] + }, + { + "type": "function", + "stateMutability": "nonpayable", + "outputs": [], + "name": "updateSettings", + "inputs": [ + { + "type": "uint256", + "name": "minAuctionIncrement_", + "internalType": "uint256" + }, + { + "type": "uint256", + "name": "minAuctionDuration_", + "internalType": "uint256" + } + ] + }, + { + "type": "function", + "stateMutability": "nonpayable", + "outputs": [], + "name": "updateSigner", + "inputs": [ + { + "type": "address", + "name": "addr", + "internalType": "address" + }, + { + "type": "bool", + "name": "remove", + "internalType": "bool" + } + ] + }, + { + "type": "function", + "stateMutability": "view", + "outputs": [ + { + "type": "address", + "name": "", + "internalType": "contract IWETH" + } + ], + "name": "weth", + "inputs": [] + }, + { + "type": "receive", + "stateMutability": "payable" + } +] \ No newline at end of file diff --git a/lepus-subql/project.yaml b/lepus-subql/project.yaml index bc84b16..c435e91 100644 --- a/lepus-subql/project.yaml +++ b/lepus-subql/project.yaml @@ -41,3 +41,27 @@ dataSources: method: Transfer - handler: handleCall kind: substrate/CallHandler + # tofuNFT + - kind: substrate/FrontierEvm + # TODO 本番デプロイするときに直す + startBlock: 2883507 + processor: + file: ./node_modules/@subql/frontier-evm-processor/dist/bundle.js + options: + abi: erc20 + address: "0x7Cae7FeB55349FeADB8f84468F692450D92597bc" + assets: + erc20: + file: ./abis/tofuNFT.abi.json + mapping: + file: ./dist/index.js + handlers: + - handler: handleTofuNFTEvInventoryUpdateFrontierEvmEvent + kind: substrate/FrontierEvmEvent + filter: + topics: + # EvInventoryUpdateイベントだけ処理する + - "0x5beea7b3b87c573953fec05007114d17712e5775d364acc106d8da9e74849033" + - handler: handleTofuNFTFrontierEvmCall + kind: substrate/FrontierEvmCall + diff --git a/lepus-subql/src/index.ts b/lepus-subql/src/index.ts index 5091615..ef98535 100644 --- a/lepus-subql/src/index.ts +++ b/lepus-subql/src/index.ts @@ -1,3 +1,4 @@ //Exports all handler functions export * from "./mappings/mappingHandlers"; +export * from "./mappings/tofuNFTMappingHandlers"; import "@polkadot/api-augment"; diff --git a/lepus-subql/src/mappings/tofuNFTMappingHandlers.ts b/lepus-subql/src/mappings/tofuNFTMappingHandlers.ts new file mode 100644 index 0000000..1e245de --- /dev/null +++ b/lepus-subql/src/mappings/tofuNFTMappingHandlers.ts @@ -0,0 +1,39 @@ +import { + FrontierEvmEvent, + FrontierEvmCall, +} from "@subql/frontier-evm-processor"; +import { BigNumber } from "ethers"; + +// Setup types from ABI +type Inventory = [[string, string, string, BigNumber, BigNumber, BigNumber, Number, Number]] & { + seller: string, + buyer: string, + currency: string, // IERC20 + price: BigNumber, + netPrice: BigNumber, + deadline: BigNumber, + kind: Number, + status: Number, +}; + +type EvInventoryUpdateArgs = [BigNumber, Inventory] & { + id: BigNumber, + inventory: Inventory, +}; + +export async function handleTofuNFTEvInventoryUpdateFrontierEvmEvent( + event: FrontierEvmEvent +): Promise { + logger.info("========== handleTofuNFTEvInventoryUpdateFrontierEvmEvent =========="); + // 中身はabis/tofuNFT.jsonのEvInventoryUpdateを確認 + logger.info(JSON.stringify(event)); + logger.info(event.args.id.toBigInt()); + logger.info(event.args.inventory.price.toBigInt()); +} + +export async function handleTofuNFTFrontierEvmCall( + event: FrontierEvmCall +): Promise { + logger.info("========== handleTofuNFTFrontierEvmCall =========="); + logger.info(JSON.stringify(event)); +} From fcbdf026ac5f7093b55a076442940aac6484a4f4 Mon Sep 17 00:00:00 2001 From: shinji19 Date: Wed, 8 Feb 2023 09:29:06 +0000 Subject: [PATCH 3/4] =?UTF-8?q?tofuNFT=E3=82=92=E3=82=B3=E3=83=A1=E3=83=B3?= =?UTF-8?q?=E3=83=88=E3=82=A2=E3=82=A6=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lepus-subql/project.yaml | 44 ++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/lepus-subql/project.yaml b/lepus-subql/project.yaml index c435e91..ddcaf6f 100644 --- a/lepus-subql/project.yaml +++ b/lepus-subql/project.yaml @@ -42,26 +42,26 @@ dataSources: - handler: handleCall kind: substrate/CallHandler # tofuNFT - - kind: substrate/FrontierEvm - # TODO 本番デプロイするときに直す - startBlock: 2883507 - processor: - file: ./node_modules/@subql/frontier-evm-processor/dist/bundle.js - options: - abi: erc20 - address: "0x7Cae7FeB55349FeADB8f84468F692450D92597bc" - assets: - erc20: - file: ./abis/tofuNFT.abi.json - mapping: - file: ./dist/index.js - handlers: - - handler: handleTofuNFTEvInventoryUpdateFrontierEvmEvent - kind: substrate/FrontierEvmEvent - filter: - topics: - # EvInventoryUpdateイベントだけ処理する - - "0x5beea7b3b87c573953fec05007114d17712e5775d364acc106d8da9e74849033" - - handler: handleTofuNFTFrontierEvmCall - kind: substrate/FrontierEvmCall + # - kind: substrate/FrontierEvm + # # TODO 本番デプロイするときに直す + # startBlock: 2883507 + # processor: + # file: ./node_modules/@subql/frontier-evm-processor/dist/bundle.js + # options: + # abi: erc20 + # address: "0x7Cae7FeB55349FeADB8f84468F692450D92597bc" + # assets: + # erc20: + # file: ./abis/tofuNFT.abi.json + # mapping: + # file: ./dist/index.js + # handlers: + # - handler: handleTofuNFTEvInventoryUpdateFrontierEvmEvent + # kind: substrate/FrontierEvmEvent + # filter: + # topics: + # # EvInventoryUpdateイベントだけ処理する + # - "0x5beea7b3b87c573953fec05007114d17712e5775d364acc106d8da9e74849033" + # - handler: handleTofuNFTFrontierEvmCall + # kind: substrate/FrontierEvmCall From 95e082a7347d92c1aee3086ea182fe70e25e60e6 Mon Sep 17 00:00:00 2001 From: shinji19 Date: Fri, 17 Feb 2023 15:25:29 +0000 Subject: [PATCH 4/4] =?UTF-8?q?NFT=20features=E5=AE=9F=E8=A3=85=20https://?= =?UTF-8?q?github.com/lepus-shinagawa/lepus/issues/3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lepus-subql/project.yaml | 48 +++---- lepus-subql/schema.graphql | 17 ++- .../src/mappings/tofuNFTMappingHandlers.ts | 130 ++++++++++++++---- 3 files changed, 146 insertions(+), 49 deletions(-) diff --git a/lepus-subql/project.yaml b/lepus-subql/project.yaml index ddcaf6f..b46a390 100644 --- a/lepus-subql/project.yaml +++ b/lepus-subql/project.yaml @@ -22,6 +22,7 @@ network: # https://documentation.onfinality.io/support/the-enhanced-api-service # endpoint: "wss://astar.api.onfinality.io/ws?apikey=25d287da-1754-496b-9948-c6af1571a18a" endpoint: "wss://rpc.astar.network" + # endpoint: "wss://astar-rpc.dwellir.com" # Optionally provide the HTTP endpoint of a full chain dictionary to speed up processing dictionary: "https://api.subquery.network/sq/subquery/astar-dictionary" chaintypes: @@ -42,26 +43,27 @@ dataSources: - handler: handleCall kind: substrate/CallHandler # tofuNFT - # - kind: substrate/FrontierEvm - # # TODO 本番デプロイするときに直す - # startBlock: 2883507 - # processor: - # file: ./node_modules/@subql/frontier-evm-processor/dist/bundle.js - # options: - # abi: erc20 - # address: "0x7Cae7FeB55349FeADB8f84468F692450D92597bc" - # assets: - # erc20: - # file: ./abis/tofuNFT.abi.json - # mapping: - # file: ./dist/index.js - # handlers: - # - handler: handleTofuNFTEvInventoryUpdateFrontierEvmEvent - # kind: substrate/FrontierEvmEvent - # filter: - # topics: - # # EvInventoryUpdateイベントだけ処理する - # - "0x5beea7b3b87c573953fec05007114d17712e5775d364acc106d8da9e74849033" - # - handler: handleTofuNFTFrontierEvmCall - # kind: substrate/FrontierEvmCall - + - kind: substrate/FrontierEvm + startBlock: 1 + processor: + file: ./node_modules/@subql/frontier-evm-processor/dist/bundle.js + options: + abi: erc20 + address: "0x7Cae7FeB55349FeADB8f84468F692450D92597bc" + assets: + erc20: + file: ./abis/tofuNFT.abi.json + mapping: + file: ./dist/index.js + handlers: + # EvInventoryUpdateイベントのハンドラ + - handler: handleTofuNFTEvInventoryUpdateFrontierEvmEvent + kind: substrate/FrontierEvmEvent + filter: + topics: + - "0x5beea7b3b87c573953fec05007114d17712e5775d364acc106d8da9e74849033" + # runの実行のハンドラ + - handler: handleTofuNFTRunFrontierEvmCall + kind: substrate/FrontierEvmCall + filter: + function: "0xba847759" diff --git a/lepus-subql/schema.graphql b/lepus-subql/schema.graphql index aba022e..a2bcce3 100644 --- a/lepus-subql/schema.graphql +++ b/lepus-subql/schema.graphql @@ -22,7 +22,18 @@ type Transfer @entity { to: String! # The account that transfers are made to } -type Account @entity{ - id: String! - totalTransferAmount: BigInt! +type Account @entity { + id: ID! + totalTransferAmount: BigInt + nftForesightScore: BigInt +} + +type TofuNFT @entity { + id: ID! + ownerHistoryAccountIds: [ID] +} + +type TofuNFTTransaction @entity { + id: ID! + tokenId: ID } diff --git a/lepus-subql/src/mappings/tofuNFTMappingHandlers.ts b/lepus-subql/src/mappings/tofuNFTMappingHandlers.ts index 1e245de..01b6e0a 100644 --- a/lepus-subql/src/mappings/tofuNFTMappingHandlers.ts +++ b/lepus-subql/src/mappings/tofuNFTMappingHandlers.ts @@ -3,37 +3,121 @@ import { FrontierEvmCall, } from "@subql/frontier-evm-processor"; import { BigNumber } from "ethers"; +import { Account, TofuNFT, TofuNFTTransaction } from "../types"; // Setup types from ABI -type Inventory = [[string, string, string, BigNumber, BigNumber, BigNumber, Number, Number]] & { - seller: string, - buyer: string, - currency: string, // IERC20 - price: BigNumber, - netPrice: BigNumber, - deadline: BigNumber, - kind: Number, - status: Number, -}; - -type EvInventoryUpdateArgs = [BigNumber, Inventory] & { +type TofuNFTEvInventoryUpdateArgs = [] & { id: BigNumber, - inventory: Inventory, + inventory: { + buyer: string, + kind: Number, + status: Number, + }, }; +type TofuNFTRunArgs = [] & { + intent: { + user: string, + bundle: { + tokenId: BigNumber, + }[] + }, + detail: { + signer: string, + opcode: Number, + caller: string, + }, +} + +const Kind = { + KIND_BUY: 2, +} as const; + +const Status = { + Done: 1, +} + +const Opcode = { + COMPLETE_BUY: 2, + ACCEPT_BUY: 4, +} as const; + export async function handleTofuNFTEvInventoryUpdateFrontierEvmEvent( - event: FrontierEvmEvent + event: FrontierEvmEvent ): Promise { - logger.info("========== handleTofuNFTEvInventoryUpdateFrontierEvmEvent =========="); - // 中身はabis/tofuNFT.jsonのEvInventoryUpdateを確認 - logger.info(JSON.stringify(event)); - logger.info(event.args.id.toBigInt()); - logger.info(event.args.inventory.price.toBigInt()); + // logger.info("========== handleTofuNFTEvInventoryUpdateFrontierEvmEvent =========="); + // // 中身はabis/tofuNFT.jsonのEvInventoryUpdateを確認 + // logger.info(JSON.stringify(event)); + // logger.info(event.args.id.toBigInt()); + // logger.info(event.args.inventory.price.toBigInt()); + + // logger.info("=== event ===") + // logger.info(event.transactionHash, event.args.inventory.kind, event.args.inventory.status); + // let count = await store.count( + // `TofuNFT`, `latestTransactionHash`, event.transactionHash); + // if (count == 0) return; + + const isBuyDone = + event.args.inventory.kind == Kind.KIND_BUY + && event.args.inventory.status == Status.Done; + if (!isBuyDone) return; + + // logger.info("=== isBuyDone ===") + // logger.info(event.transactionHash) + + const transaction = await TofuNFTTransaction.get(event.transactionHash); + let tofuNFT = await TofuNFT.get(transaction.tokenId); + if (!tofuNFT) tofuNFT = TofuNFT.create({ id: transaction.tokenId }); + if (!tofuNFT.ownerHistoryAccountIds) + tofuNFT.ownerHistoryAccountIds = []; + + const buyer = event.args.inventory.buyer; + if (tofuNFT.ownerHistoryAccountIds.find(x => x == buyer)) return; + + // logger.info(`token id: ${tofuNFT.id}`); + tofuNFT.ownerHistoryAccountIds.push(buyer); + await tofuNFT.save(); + await Account.create({ id: buyer, nftForesightScore: BigInt(0) }).save(); + // logger.info("saved") + + // logger.info(JSON.stringify(tofuNFT.ownerHistoryAccountIds)); + + let accounts = await store.getByField( + `Account`, `id`, tofuNFT.ownerHistoryAccountIds + ) as Account[]; + + const n = accounts.length; + for (let i = 0; i < n; i++) { + // ((n-2) - i) ** 2 が足し込まれているはずなので、差分だけ足す + accounts[i].nftForesightScore += + BigInt((n - i) ** 2 - ((n - 1) - i) ** 2); + } + + const data = accounts.map(function (x) { + return { + id: x.id, + nftForesightScore: x.nftForesightScore, + } + }); + await store.bulkUpdate("Account", data); } -export async function handleTofuNFTFrontierEvmCall( - event: FrontierEvmCall +export async function handleTofuNFTRunFrontierEvmCall( + event: FrontierEvmCall ): Promise { - logger.info("========== handleTofuNFTFrontierEvmCall =========="); - logger.info(JSON.stringify(event)); + const opcode = event.args.detail.opcode; + if (opcode != Opcode.COMPLETE_BUY && opcode != Opcode.ACCEPT_BUY) return; + + // logger.info(opcode); + const bundle = event.args.intent.bundle; + for (let i = 0; i < bundle.length; i++) { + const tokenId = bundle[i].tokenId.toString(); + const transaction = TofuNFTTransaction.create({ + id: event.hash, tokenId: tokenId + }); + await transaction.save(); + + // logger.info("=== call ===") + // logger.info(JSON.stringify(transaction)); + } }