优化1155合约的体积

This commit is contained in:
cebgcontract 2022-08-16 11:07:49 +08:00
parent c215181930
commit f656b07923
24 changed files with 50018 additions and 41297 deletions

File diff suppressed because one or more lines are too long

View File

@ -45116,10 +45116,40 @@
"links": {}, "links": {},
"address": "0x6eD79Aa1c71FD7BdBC515EfdA3Bd4e26394435cC", "address": "0x6eD79Aa1c71FD7BdBC515EfdA3Bd4e26394435cC",
"transactionHash": "0xdba4ae3720ba063fde57a322b23b99eb4efbdd7bd717a490dd5eee3e3011da79" "transactionHash": "0xdba4ae3720ba063fde57a322b23b99eb4efbdd7bd717a490dd5eee3e3011da79"
},
"1660298760149": {
"events": {},
"links": {},
"address": "0x6eD79Aa1c71FD7BdBC515EfdA3Bd4e26394435cC",
"transactionHash": "0x5d617347e554d50b411b37204b01878f8064ed9bbba05b8a42e0f6aecf49a4c8"
},
"1660531431098": {
"events": {},
"links": {},
"address": "0x6eD79Aa1c71FD7BdBC515EfdA3Bd4e26394435cC",
"transactionHash": "0xe8a063f2a1b60b6c6ec1d56b994deb6793e23885e4422184264350cc8ed9d81f"
},
"1660541459153": {
"events": {},
"links": {},
"address": "0x6eD79Aa1c71FD7BdBC515EfdA3Bd4e26394435cC",
"transactionHash": "0xfc375a91ac85a0e86183ebc42df59d35a42a9fe162a710de3f187c1511ddbd54"
},
"1660546107914": {
"events": {},
"links": {},
"address": "0x6eD79Aa1c71FD7BdBC515EfdA3Bd4e26394435cC",
"transactionHash": "0xffd4e86f44fe11afca22cd992f1a67bf548d52f55afd486f86e94969d5da07da"
},
"1660546294490": {
"events": {},
"links": {},
"address": "0x6eD79Aa1c71FD7BdBC515EfdA3Bd4e26394435cC",
"transactionHash": "0xffd4e86f44fe11afca22cd992f1a67bf548d52f55afd486f86e94969d5da07da"
} }
}, },
"schemaVersion": "3.4.4", "schemaVersion": "3.4.4",
"updatedAt": "2022-08-12T08:39:59.302Z", "updatedAt": "2022-08-15T06:52:20.254Z",
"networkType": "ethereum", "networkType": "ethereum",
"devdoc": { "devdoc": {
"kind": "dev", "kind": "dev",

File diff suppressed because one or more lines are too long

View File

@ -9640,10 +9640,40 @@
"links": {}, "links": {},
"address": "0xCfEB869F69431e42cdB54A4F4f105C19C080A601", "address": "0xCfEB869F69431e42cdB54A4F4f105C19C080A601",
"transactionHash": "0x2204250d687161b0ca7a13205946e84000a26e776b23eb5e859e510b524829f3" "transactionHash": "0x2204250d687161b0ca7a13205946e84000a26e776b23eb5e859e510b524829f3"
},
"1660298760149": {
"events": {},
"links": {},
"address": "0xCfEB869F69431e42cdB54A4F4f105C19C080A601",
"transactionHash": "0x2204250d687161b0ca7a13205946e84000a26e776b23eb5e859e510b524829f3"
},
"1660531431098": {
"events": {},
"links": {},
"address": "0xCfEB869F69431e42cdB54A4F4f105C19C080A601",
"transactionHash": "0x2204250d687161b0ca7a13205946e84000a26e776b23eb5e859e510b524829f3"
},
"1660541459153": {
"events": {},
"links": {},
"address": "0xCfEB869F69431e42cdB54A4F4f105C19C080A601",
"transactionHash": "0x2204250d687161b0ca7a13205946e84000a26e776b23eb5e859e510b524829f3"
},
"1660546107914": {
"events": {},
"links": {},
"address": "0xCfEB869F69431e42cdB54A4F4f105C19C080A601",
"transactionHash": "0x2204250d687161b0ca7a13205946e84000a26e776b23eb5e859e510b524829f3"
},
"1660546294490": {
"events": {},
"links": {},
"address": "0xCfEB869F69431e42cdB54A4F4f105C19C080A601",
"transactionHash": "0x2204250d687161b0ca7a13205946e84000a26e776b23eb5e859e510b524829f3"
} }
}, },
"schemaVersion": "3.4.4", "schemaVersion": "3.4.4",
"updatedAt": "2022-08-12T08:39:53.568Z", "updatedAt": "2022-08-15T06:52:13.226Z",
"networkType": "ethereum", "networkType": "ethereum",
"devdoc": { "devdoc": {
"kind": "dev", "kind": "dev",

View File

@ -23879,10 +23879,40 @@
"links": {}, "links": {},
"address": "0x59d3631c86BbE35EF041872d502F218A39FBa150", "address": "0x59d3631c86BbE35EF041872d502F218A39FBa150",
"transactionHash": "0x9da0c311692bec2b672fb1d94511aaf8d2e0fbb0030d45ab4aa461ca230659bc" "transactionHash": "0x9da0c311692bec2b672fb1d94511aaf8d2e0fbb0030d45ab4aa461ca230659bc"
},
"1660298760149": {
"events": {},
"links": {},
"address": "0x59d3631c86BbE35EF041872d502F218A39FBa150",
"transactionHash": "0x9da0c311692bec2b672fb1d94511aaf8d2e0fbb0030d45ab4aa461ca230659bc"
},
"1660531431098": {
"events": {},
"links": {},
"address": "0x59d3631c86BbE35EF041872d502F218A39FBa150",
"transactionHash": "0x9da0c311692bec2b672fb1d94511aaf8d2e0fbb0030d45ab4aa461ca230659bc"
},
"1660541459153": {
"events": {},
"links": {},
"address": "0x59d3631c86BbE35EF041872d502F218A39FBa150",
"transactionHash": "0x9da0c311692bec2b672fb1d94511aaf8d2e0fbb0030d45ab4aa461ca230659bc"
},
"1660546107914": {
"events": {},
"links": {},
"address": "0x59d3631c86BbE35EF041872d502F218A39FBa150",
"transactionHash": "0x9da0c311692bec2b672fb1d94511aaf8d2e0fbb0030d45ab4aa461ca230659bc"
},
"1660546294490": {
"events": {},
"links": {},
"address": "0x59d3631c86BbE35EF041872d502F218A39FBa150",
"transactionHash": "0x9da0c311692bec2b672fb1d94511aaf8d2e0fbb0030d45ab4aa461ca230659bc"
} }
}, },
"schemaVersion": "3.4.4", "schemaVersion": "3.4.4",
"updatedAt": "2022-08-12T08:39:55.597Z", "updatedAt": "2022-08-15T06:52:15.612Z",
"networkType": "ethereum", "networkType": "ethereum",
"devdoc": { "devdoc": {
"kind": "dev", "kind": "dev",

View File

@ -11688,10 +11688,40 @@
"links": {}, "links": {},
"address": "0xC89Ce4735882C9F0f0FE26686c53074E09B0D550", "address": "0xC89Ce4735882C9F0f0FE26686c53074E09B0D550",
"transactionHash": "0x6d2a8e99df9adb00dfa3fda55853cddf2f206987a4c80cb8f0062fa451cb8224" "transactionHash": "0x6d2a8e99df9adb00dfa3fda55853cddf2f206987a4c80cb8f0062fa451cb8224"
},
"1660298760149": {
"events": {},
"links": {},
"address": "0xC89Ce4735882C9F0f0FE26686c53074E09B0D550",
"transactionHash": "0x6d2a8e99df9adb00dfa3fda55853cddf2f206987a4c80cb8f0062fa451cb8224"
},
"1660531431098": {
"events": {},
"links": {},
"address": "0xC89Ce4735882C9F0f0FE26686c53074E09B0D550",
"transactionHash": "0x6d2a8e99df9adb00dfa3fda55853cddf2f206987a4c80cb8f0062fa451cb8224"
},
"1660541459153": {
"events": {},
"links": {},
"address": "0xC89Ce4735882C9F0f0FE26686c53074E09B0D550",
"transactionHash": "0x6d2a8e99df9adb00dfa3fda55853cddf2f206987a4c80cb8f0062fa451cb8224"
},
"1660546107914": {
"events": {},
"links": {},
"address": "0xC89Ce4735882C9F0f0FE26686c53074E09B0D550",
"transactionHash": "0x6d2a8e99df9adb00dfa3fda55853cddf2f206987a4c80cb8f0062fa451cb8224"
},
"1660546294490": {
"events": {},
"links": {},
"address": "0xC89Ce4735882C9F0f0FE26686c53074E09B0D550",
"transactionHash": "0x6d2a8e99df9adb00dfa3fda55853cddf2f206987a4c80cb8f0062fa451cb8224"
} }
}, },
"schemaVersion": "3.4.4", "schemaVersion": "3.4.4",
"updatedAt": "2022-08-12T08:39:54.240Z", "updatedAt": "2022-08-15T06:52:13.989Z",
"networkType": "ethereum", "networkType": "ethereum",
"devdoc": { "devdoc": {
"kind": "dev", "kind": "dev",

View File

@ -23879,10 +23879,40 @@
"links": {}, "links": {},
"address": "0x9561C133DD8580860B6b7E504bC5Aa500f0f06a7", "address": "0x9561C133DD8580860B6b7E504bC5Aa500f0f06a7",
"transactionHash": "0xe08ae1682a58713adaf8e9d6595d87b60d064ea10c23695af8b448ece741fada" "transactionHash": "0xe08ae1682a58713adaf8e9d6595d87b60d064ea10c23695af8b448ece741fada"
},
"1660298760149": {
"events": {},
"links": {},
"address": "0x9561C133DD8580860B6b7E504bC5Aa500f0f06a7",
"transactionHash": "0xe08ae1682a58713adaf8e9d6595d87b60d064ea10c23695af8b448ece741fada"
},
"1660531431098": {
"events": {},
"links": {},
"address": "0x9561C133DD8580860B6b7E504bC5Aa500f0f06a7",
"transactionHash": "0xe08ae1682a58713adaf8e9d6595d87b60d064ea10c23695af8b448ece741fada"
},
"1660541459153": {
"events": {},
"links": {},
"address": "0x9561C133DD8580860B6b7E504bC5Aa500f0f06a7",
"transactionHash": "0xe08ae1682a58713adaf8e9d6595d87b60d064ea10c23695af8b448ece741fada"
},
"1660546107914": {
"events": {},
"links": {},
"address": "0x9561C133DD8580860B6b7E504bC5Aa500f0f06a7",
"transactionHash": "0xe08ae1682a58713adaf8e9d6595d87b60d064ea10c23695af8b448ece741fada"
},
"1660546294490": {
"events": {},
"links": {},
"address": "0x9561C133DD8580860B6b7E504bC5Aa500f0f06a7",
"transactionHash": "0xe08ae1682a58713adaf8e9d6595d87b60d064ea10c23695af8b448ece741fada"
} }
}, },
"schemaVersion": "3.4.4", "schemaVersion": "3.4.4",
"updatedAt": "2022-08-12T08:39:54.916Z", "updatedAt": "2022-08-15T06:52:14.805Z",
"networkType": "ethereum", "networkType": "ethereum",
"devdoc": { "devdoc": {
"kind": "dev", "kind": "dev",

File diff suppressed because one or more lines are too long

View File

@ -25162,10 +25162,40 @@
"links": {}, "links": {},
"address": "0x21a59654176f2689d12E828B77a783072CD26680", "address": "0x21a59654176f2689d12E828B77a783072CD26680",
"transactionHash": "0x69fbc9a88b1d74377d80cc912f3e6739573a0fe0dbe10ee4f9f6dd5cf5f875aa" "transactionHash": "0x69fbc9a88b1d74377d80cc912f3e6739573a0fe0dbe10ee4f9f6dd5cf5f875aa"
},
"1660298760149": {
"events": {},
"links": {},
"address": "0x21a59654176f2689d12E828B77a783072CD26680",
"transactionHash": "0xb9ca36f0882e61f5c114e225ccfb77a2273d12349dfe692ed35cf7edbf759784"
},
"1660531431098": {
"events": {},
"links": {},
"address": "0x21a59654176f2689d12E828B77a783072CD26680",
"transactionHash": "0x33ad563d0b5129743d0cba7bcbedaf5ae825f76e71bfc077e826009e618803c3"
},
"1660541459153": {
"events": {},
"links": {},
"address": "0x21a59654176f2689d12E828B77a783072CD26680",
"transactionHash": "0x6595e64a43db9c4e9468dd4dc3325215c1384f4c5079203cefbf83bb40b9a6ac"
},
"1660546107914": {
"events": {},
"links": {},
"address": "0x21a59654176f2689d12E828B77a783072CD26680",
"transactionHash": "0x4af14eefca13fef07b442e1a04e222abd8def1354259739e7323a6b0cdf1d5f7"
},
"1660546294490": {
"events": {},
"links": {},
"address": "0x21a59654176f2689d12E828B77a783072CD26680",
"transactionHash": "0x4af14eefca13fef07b442e1a04e222abd8def1354259739e7323a6b0cdf1d5f7"
} }
}, },
"schemaVersion": "3.4.4", "schemaVersion": "3.4.4",
"updatedAt": "2022-08-12T08:40:00.586Z", "updatedAt": "2022-08-15T06:52:21.916Z",
"networkType": "ethereum", "networkType": "ethereum",
"devdoc": { "devdoc": {
"kind": "dev", "kind": "dev",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -33513,10 +33513,40 @@
"links": {}, "links": {},
"address": "0xDb56f2e9369E0D7bD191099125a3f6C370F8ed15", "address": "0xDb56f2e9369E0D7bD191099125a3f6C370F8ed15",
"transactionHash": "0x6996e868f4a8b2ede22ac5d344b853260fabd45fcc88a4d8df58e765facc564a" "transactionHash": "0x6996e868f4a8b2ede22ac5d344b853260fabd45fcc88a4d8df58e765facc564a"
},
"1660298760149": {
"events": {},
"links": {},
"address": "0xDb56f2e9369E0D7bD191099125a3f6C370F8ed15",
"transactionHash": "0x2e4f5c557710e0d30a0f5d875eb19ac68aa0e2b119adc181ceb55904a617d28d"
},
"1660531431098": {
"events": {},
"links": {},
"address": "0xDb56f2e9369E0D7bD191099125a3f6C370F8ed15",
"transactionHash": "0x8daa16fcb89ef8bb0c3609ba21eb93f430c581c74febc70b4aae28cc5ca9d39c"
},
"1660541459153": {
"events": {},
"links": {},
"address": "0xDb56f2e9369E0D7bD191099125a3f6C370F8ed15",
"transactionHash": "0x9255708eed0bc2c7954fd046ec5a1300e7d0017cdc3beda3390a36c9c2202d9e"
},
"1660546107914": {
"events": {},
"links": {},
"address": "0xDb56f2e9369E0D7bD191099125a3f6C370F8ed15",
"transactionHash": "0x11a77fbd90b6847b301866ec17d74825797dbaac44b9a9a5f4ed6a55821ae0e7"
},
"1660546294490": {
"events": {},
"links": {},
"address": "0xDb56f2e9369E0D7bD191099125a3f6C370F8ed15",
"transactionHash": "0x11a77fbd90b6847b301866ec17d74825797dbaac44b9a9a5f4ed6a55821ae0e7"
} }
}, },
"schemaVersion": "3.4.4", "schemaVersion": "3.4.4",
"updatedAt": "2022-08-12T08:39:58.469Z", "updatedAt": "2022-08-15T06:52:19.317Z",
"networkType": "ethereum", "networkType": "ethereum",
"devdoc": { "devdoc": {
"kind": "dev", "kind": "dev",

View File

@ -3142,10 +3142,40 @@
"links": {}, "links": {},
"address": "0xe78A0F7E598Cc8b0Bb87894B0F60dD2a88d6a8Ab", "address": "0xe78A0F7E598Cc8b0Bb87894B0F60dD2a88d6a8Ab",
"transactionHash": "0x48bdf23a40832e27b03488c07a3499446ea72de28dfc5da232f940822771f02d" "transactionHash": "0x48bdf23a40832e27b03488c07a3499446ea72de28dfc5da232f940822771f02d"
},
"1660298760149": {
"events": {},
"links": {},
"address": "0xe78A0F7E598Cc8b0Bb87894B0F60dD2a88d6a8Ab",
"transactionHash": "0x48bdf23a40832e27b03488c07a3499446ea72de28dfc5da232f940822771f02d"
},
"1660531431098": {
"events": {},
"links": {},
"address": "0xe78A0F7E598Cc8b0Bb87894B0F60dD2a88d6a8Ab",
"transactionHash": "0x48bdf23a40832e27b03488c07a3499446ea72de28dfc5da232f940822771f02d"
},
"1660541459153": {
"events": {},
"links": {},
"address": "0xe78A0F7E598Cc8b0Bb87894B0F60dD2a88d6a8Ab",
"transactionHash": "0x48bdf23a40832e27b03488c07a3499446ea72de28dfc5da232f940822771f02d"
},
"1660546107914": {
"events": {},
"links": {},
"address": "0xe78A0F7E598Cc8b0Bb87894B0F60dD2a88d6a8Ab",
"transactionHash": "0x48bdf23a40832e27b03488c07a3499446ea72de28dfc5da232f940822771f02d"
},
"1660546294490": {
"events": {},
"links": {},
"address": "0xe78A0F7E598Cc8b0Bb87894B0F60dD2a88d6a8Ab",
"transactionHash": "0x48bdf23a40832e27b03488c07a3499446ea72de28dfc5da232f940822771f02d"
} }
}, },
"schemaVersion": "3.4.4", "schemaVersion": "3.4.4",
"updatedAt": "2022-08-12T08:40:00.592Z", "updatedAt": "2022-08-15T06:52:21.925Z",
"networkType": "ethereum", "networkType": "ethereum",
"devdoc": { "devdoc": {
"kind": "dev", "kind": "dev",

File diff suppressed because one or more lines are too long

731
build/contracts/UInt.json Normal file
View File

@ -0,0 +1,731 @@
{
"contractName": "UInt",
"abi": [],
"metadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"project:/contracts/utils/UInt.sol\":\"UInt\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"project:/contracts/utils/UInt.sol\":{\"keccak256\":\"0x137247f9f248803d3163e93d37120ebc2c848c45af4733b82f417a56b93d1ad2\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://e5e99614dd7cdcce84a664837ed5db44f81e56ddf6f288a905e56c93e7c9a2d5\",\"dweb:/ipfs/QmWhiM1isqnFyvjzSqZD6qs7gYayHEpszG8CV1CUjBdC3u\"]}},\"version\":1}",
"bytecode": "0x60566050600b82828239805160001a6073146043577f4e487b7100000000000000000000000000000000000000000000000000000000600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220ba2c95fc026962092e83d6add832bf3663ad167c96158affa3769e24358a33dd64736f6c634300080a0033",
"deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220ba2c95fc026962092e83d6add832bf3663ad167c96158affa3769e24358a33dd64736f6c634300080a0033",
"immutableReferences": {},
"generatedSources": [],
"deployedGeneratedSources": [],
"sourceMap": "57:197:13:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;",
"deployedSourceMap": "57:197:13:-:0;;;;;;;;",
"source": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.10;\n\nlibrary UInt{\n\n function asSingletonArray(uint256 element) internal pure returns (uint256[] memory) {\n uint256[] memory array = new uint256[](1);\n array[0] = element;\n return array;\n }\n}\n",
"sourcePath": "/Users/zhl/Documents/workspace/game/becrypto/contracts/utils/UInt.sol",
"ast": {
"absolutePath": "project:/contracts/utils/UInt.sol",
"exportedSymbols": {
"UInt": [
2513
]
},
"id": 2514,
"license": "MIT",
"nodeType": "SourceUnit",
"nodes": [
{
"id": 2484,
"literals": [
"solidity",
"0.8",
".10"
],
"nodeType": "PragmaDirective",
"src": "32:23:13"
},
{
"abstract": false,
"baseContracts": [],
"canonicalName": "UInt",
"contractDependencies": [],
"contractKind": "library",
"fullyImplemented": true,
"id": 2513,
"linearizedBaseContracts": [
2513
],
"name": "UInt",
"nameLocation": "65:4:13",
"nodeType": "ContractDefinition",
"nodes": [
{
"body": {
"id": 2511,
"nodeType": "Block",
"src": "158:94:13",
"statements": [
{
"assignments": [
2496
],
"declarations": [
{
"constant": false,
"id": 2496,
"mutability": "mutable",
"name": "array",
"nameLocation": "181:5:13",
"nodeType": "VariableDeclaration",
"scope": 2511,
"src": "164:22:13",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_uint256_$dyn_memory_ptr",
"typeString": "uint256[]"
},
"typeName": {
"baseType": {
"id": 2494,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "164:7:13",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"id": 2495,
"nodeType": "ArrayTypeName",
"src": "164:9:13",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_uint256_$dyn_storage_ptr",
"typeString": "uint256[]"
}
},
"visibility": "internal"
}
],
"id": 2502,
"initialValue": {
"arguments": [
{
"hexValue": "31",
"id": 2500,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "203:1:13",
"typeDescriptions": {
"typeIdentifier": "t_rational_1_by_1",
"typeString": "int_const 1"
},
"value": "1"
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_rational_1_by_1",
"typeString": "int_const 1"
}
],
"id": 2499,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "NewExpression",
"src": "189:13:13",
"typeDescriptions": {
"typeIdentifier": "t_function_objectcreation_pure$_t_uint256_$returns$_t_array$_t_uint256_$dyn_memory_ptr_$",
"typeString": "function (uint256) pure returns (uint256[] memory)"
},
"typeName": {
"baseType": {
"id": 2497,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "193:7:13",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"id": 2498,
"nodeType": "ArrayTypeName",
"src": "193:9:13",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_uint256_$dyn_storage_ptr",
"typeString": "uint256[]"
}
}
},
"id": 2501,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "189:16:13",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_array$_t_uint256_$dyn_memory_ptr",
"typeString": "uint256[] memory"
}
},
"nodeType": "VariableDeclarationStatement",
"src": "164:41:13"
},
{
"expression": {
"id": 2507,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftHandSide": {
"baseExpression": {
"id": 2503,
"name": "array",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2496,
"src": "211:5:13",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_uint256_$dyn_memory_ptr",
"typeString": "uint256[] memory"
}
},
"id": 2505,
"indexExpression": {
"hexValue": "30",
"id": 2504,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "217:1:13",
"typeDescriptions": {
"typeIdentifier": "t_rational_0_by_1",
"typeString": "int_const 0"
},
"value": "0"
},
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": true,
"nodeType": "IndexAccess",
"src": "211:8:13",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "Assignment",
"operator": "=",
"rightHandSide": {
"id": 2506,
"name": "element",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2486,
"src": "222:7:13",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"src": "211:18:13",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"id": 2508,
"nodeType": "ExpressionStatement",
"src": "211:18:13"
},
{
"expression": {
"id": 2509,
"name": "array",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2496,
"src": "242:5:13",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_uint256_$dyn_memory_ptr",
"typeString": "uint256[] memory"
}
},
"functionReturnParameters": 2491,
"id": 2510,
"nodeType": "Return",
"src": "235:12:13"
}
]
},
"id": 2512,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "asSingletonArray",
"nameLocation": "83:16:13",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 2487,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 2486,
"mutability": "mutable",
"name": "element",
"nameLocation": "108:7:13",
"nodeType": "VariableDeclaration",
"scope": 2512,
"src": "100:15:13",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 2485,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "100:7:13",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"visibility": "internal"
}
],
"src": "99:17:13"
},
"returnParameters": {
"id": 2491,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 2490,
"mutability": "mutable",
"name": "",
"nameLocation": "-1:-1:-1",
"nodeType": "VariableDeclaration",
"scope": 2512,
"src": "140:16:13",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_uint256_$dyn_memory_ptr",
"typeString": "uint256[]"
},
"typeName": {
"baseType": {
"id": 2488,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "140:7:13",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"id": 2489,
"nodeType": "ArrayTypeName",
"src": "140:9:13",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_uint256_$dyn_storage_ptr",
"typeString": "uint256[]"
}
},
"visibility": "internal"
}
],
"src": "139:18:13"
},
"scope": 2513,
"src": "74:178:13",
"stateMutability": "pure",
"virtual": false,
"visibility": "internal"
}
],
"scope": 2514,
"src": "57:197:13",
"usedErrors": []
}
],
"src": "32:223:13"
},
"legacyAST": {
"absolutePath": "project:/contracts/utils/UInt.sol",
"exportedSymbols": {
"UInt": [
2513
]
},
"id": 2514,
"license": "MIT",
"nodeType": "SourceUnit",
"nodes": [
{
"id": 2484,
"literals": [
"solidity",
"0.8",
".10"
],
"nodeType": "PragmaDirective",
"src": "32:23:13"
},
{
"abstract": false,
"baseContracts": [],
"canonicalName": "UInt",
"contractDependencies": [],
"contractKind": "library",
"fullyImplemented": true,
"id": 2513,
"linearizedBaseContracts": [
2513
],
"name": "UInt",
"nameLocation": "65:4:13",
"nodeType": "ContractDefinition",
"nodes": [
{
"body": {
"id": 2511,
"nodeType": "Block",
"src": "158:94:13",
"statements": [
{
"assignments": [
2496
],
"declarations": [
{
"constant": false,
"id": 2496,
"mutability": "mutable",
"name": "array",
"nameLocation": "181:5:13",
"nodeType": "VariableDeclaration",
"scope": 2511,
"src": "164:22:13",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_uint256_$dyn_memory_ptr",
"typeString": "uint256[]"
},
"typeName": {
"baseType": {
"id": 2494,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "164:7:13",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"id": 2495,
"nodeType": "ArrayTypeName",
"src": "164:9:13",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_uint256_$dyn_storage_ptr",
"typeString": "uint256[]"
}
},
"visibility": "internal"
}
],
"id": 2502,
"initialValue": {
"arguments": [
{
"hexValue": "31",
"id": 2500,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "203:1:13",
"typeDescriptions": {
"typeIdentifier": "t_rational_1_by_1",
"typeString": "int_const 1"
},
"value": "1"
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_rational_1_by_1",
"typeString": "int_const 1"
}
],
"id": 2499,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "NewExpression",
"src": "189:13:13",
"typeDescriptions": {
"typeIdentifier": "t_function_objectcreation_pure$_t_uint256_$returns$_t_array$_t_uint256_$dyn_memory_ptr_$",
"typeString": "function (uint256) pure returns (uint256[] memory)"
},
"typeName": {
"baseType": {
"id": 2497,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "193:7:13",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"id": 2498,
"nodeType": "ArrayTypeName",
"src": "193:9:13",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_uint256_$dyn_storage_ptr",
"typeString": "uint256[]"
}
}
},
"id": 2501,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "189:16:13",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_array$_t_uint256_$dyn_memory_ptr",
"typeString": "uint256[] memory"
}
},
"nodeType": "VariableDeclarationStatement",
"src": "164:41:13"
},
{
"expression": {
"id": 2507,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftHandSide": {
"baseExpression": {
"id": 2503,
"name": "array",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2496,
"src": "211:5:13",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_uint256_$dyn_memory_ptr",
"typeString": "uint256[] memory"
}
},
"id": 2505,
"indexExpression": {
"hexValue": "30",
"id": 2504,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "217:1:13",
"typeDescriptions": {
"typeIdentifier": "t_rational_0_by_1",
"typeString": "int_const 0"
},
"value": "0"
},
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": true,
"nodeType": "IndexAccess",
"src": "211:8:13",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "Assignment",
"operator": "=",
"rightHandSide": {
"id": 2506,
"name": "element",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2486,
"src": "222:7:13",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"src": "211:18:13",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"id": 2508,
"nodeType": "ExpressionStatement",
"src": "211:18:13"
},
{
"expression": {
"id": 2509,
"name": "array",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2496,
"src": "242:5:13",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_uint256_$dyn_memory_ptr",
"typeString": "uint256[] memory"
}
},
"functionReturnParameters": 2491,
"id": 2510,
"nodeType": "Return",
"src": "235:12:13"
}
]
},
"id": 2512,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "asSingletonArray",
"nameLocation": "83:16:13",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 2487,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 2486,
"mutability": "mutable",
"name": "element",
"nameLocation": "108:7:13",
"nodeType": "VariableDeclaration",
"scope": 2512,
"src": "100:15:13",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 2485,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "100:7:13",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"visibility": "internal"
}
],
"src": "99:17:13"
},
"returnParameters": {
"id": 2491,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 2490,
"mutability": "mutable",
"name": "",
"nameLocation": "-1:-1:-1",
"nodeType": "VariableDeclaration",
"scope": 2512,
"src": "140:16:13",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_uint256_$dyn_memory_ptr",
"typeString": "uint256[]"
},
"typeName": {
"baseType": {
"id": 2488,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "140:7:13",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"id": 2489,
"nodeType": "ArrayTypeName",
"src": "140:9:13",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_uint256_$dyn_storage_ptr",
"typeString": "uint256[]"
}
},
"visibility": "internal"
}
],
"src": "139:18:13"
},
"scope": 2513,
"src": "74:178:13",
"stateMutability": "pure",
"virtual": false,
"visibility": "internal"
}
],
"scope": 2514,
"src": "57:197:13",
"usedErrors": []
}
],
"src": "32:223:13"
},
"compiler": {
"name": "solc",
"version": "0.8.10+commit.fc410830.Emscripten.clang"
},
"networks": {},
"schemaVersion": "3.4.4",
"updatedAt": "2022-08-16T02:56:28.538Z",
"devdoc": {
"kind": "dev",
"methods": {},
"version": 1
},
"userdoc": {
"kind": "user",
"methods": {},
"version": 1
}
}

File diff suppressed because one or more lines are too long

View File

@ -11,19 +11,6 @@ interface IBEERC1155 is IERC1155 {
bytes memory data bytes memory data
) external; ) external;
function mint(
address to,
uint256 id,
uint256 amount,
bytes memory data
) external;
function burn(
address owner,
uint256 tokenId,
uint256 amount
) external;
function burnBatch( function burnBatch(
address owner, address owner,
uint256[] memory ids, uint256[] memory ids,

View File

@ -4,6 +4,8 @@ import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "../interfaces/IBEERC721.sol"; import "../interfaces/IBEERC721.sol";
import "../interfaces/IBEERC1155.sol";
import "../utils/UInt.sol";
import "../core/HasSignature.sol"; import "../core/HasSignature.sol";
// this contract will transfer ownership to BETimelockController after deployed // this contract will transfer ownership to BETimelockController after deployed
@ -11,9 +13,10 @@ import "../core/HasSignature.sol";
contract EvolveProxy is Ownable, Initializable, HasSignature { contract EvolveProxy is Ownable, Initializable, HasSignature {
using UInt for uint256;
IBEERC721 public hero; IBEERC721 public hero;
IBEERC721 public equip; IBEERC721 public equip;
IBEERC721 public chip; IBEERC1155 public chip;
mapping(bytes => bool) public usedSignatures; mapping(bytes => bool) public usedSignatures;
@ -34,7 +37,7 @@ contract EvolveProxy is Ownable, Initializable, HasSignature {
function init(address[3] calldata _erc721s) external initializer onlyOwner { function init(address[3] calldata _erc721s) external initializer onlyOwner {
hero = IBEERC721(_erc721s[0]); hero = IBEERC721(_erc721s[0]);
equip = IBEERC721(_erc721s[1]); equip = IBEERC721(_erc721s[1]);
chip = IBEERC721(_erc721s[2]); chip = IBEERC1155(_erc721s[2]);
} }
/** /**
@ -84,7 +87,10 @@ contract EvolveProxy is Ownable, Initializable, HasSignature {
checkSigner(executor, criteriaMessageHash, signature); checkSigner(executor, criteriaMessageHash, signature);
hero.burn(msg.sender, tokenIds[1]); hero.burn(msg.sender, tokenIds[1]);
if (tokenIds[2] > 0) { if (tokenIds[2] > 0) {
chip.burn(msg.sender, tokenIds[2]); uint256 amount = 1;
chip.burnBatch(msg.sender,
tokenIds[2].asSingletonArray(),
amount.asSingletonArray());
} }
usedSignatures[signature] = true; usedSignatures[signature] = true;
emit TokenEvolved(evolveEventId, msg.sender, tokenIds[0], tokenIds[1], tokenIds[2]); emit TokenEvolved(evolveEventId, msg.sender, tokenIds[0], tokenIds[1], tokenIds[2]);
@ -129,7 +135,10 @@ contract EvolveProxy is Ownable, Initializable, HasSignature {
checkSigner(executor, criteriaMessageHash, signature); checkSigner(executor, criteriaMessageHash, signature);
equip.burn(msg.sender, tokenIds[1]); equip.burn(msg.sender, tokenIds[1]);
if (tokenIds[2] > 0) { if (tokenIds[2] > 0) {
chip.burn(msg.sender, tokenIds[2]); uint256 amount = 1;
chip.burnBatch(msg.sender,
tokenIds[2].asSingletonArray(),
amount.asSingletonArray());
} }
usedSignatures[signature] = true; usedSignatures[signature] = true;
emit TokenEvolved(evolveEventId, msg.sender, tokenIds[0], tokenIds[1], tokenIds[2]); emit TokenEvolved(evolveEventId, msg.sender, tokenIds[0], tokenIds[1], tokenIds[2]);

View File

@ -5,9 +5,11 @@ import "@openzeppelin/contracts/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "../interfaces/IBEERC721.sol"; import "../interfaces/IBEERC721.sol";
import "../interfaces/IBEERC1155.sol"; import "../interfaces/IBEERC1155.sol";
import "../utils/UInt.sol";
import "../core/HasSignature.sol"; import "../core/HasSignature.sol";
contract MinterFactory is Ownable, Initializable, HasSignature { contract MinterFactory is Ownable, Initializable, HasSignature {
using UInt for uint256;
address public executor; address public executor;
// NFT contract // NFT contract
IBEERC721 public hero; IBEERC721 public hero;
@ -228,7 +230,7 @@ contract MinterFactory is Ownable, Initializable, HasSignature {
IBEERC1155 nft IBEERC1155 nft
) internal { ) internal {
require(to != address(0), "MinterFactory: to address can not be zero"); require(to != address(0), "MinterFactory: to address can not be zero");
nft.mint(to, id, amount, ""); nft.mintBatch(to, id.asSingletonArray(), amount.asSingletonArray(), "");
emit TokenMinted(address(chip), to, id); emit TokenMinted(address(chip), to, id);
} }

View File

@ -6,7 +6,7 @@ import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/access/AccessControl.sol";
abstract contract BEBase1155 is ERC1155, AccessControl { abstract contract BEBase1155 is ERC1155, Ownable, AccessControl {
using Strings for uint256; using Strings for uint256;
bytes32 public constant URI_SETTER_ROLE = keccak256("URI_SETTER_ROLE"); bytes32 public constant URI_SETTER_ROLE = keccak256("URI_SETTER_ROLE");
@ -38,15 +38,6 @@ abstract contract BEBase1155 is ERC1155, AccessControl {
_setURI(newuri); _setURI(newuri);
} }
function mint(
address account,
uint256 id,
uint256 amount,
bytes memory data
) external onlyRole(MINTER_ROLE) {
_mint(account, id, amount, data);
}
function mintBatch( function mintBatch(
address to, address to,
uint256[] memory ids, uint256[] memory ids,
@ -56,13 +47,6 @@ abstract contract BEBase1155 is ERC1155, AccessControl {
_mintBatch(to, ids, amounts, data); _mintBatch(to, ids, amounts, data);
} }
function burn(
address account,
uint256 id,
uint256 value
) external onlyRole(BURN_ROLE) {
_burn(account, id, value);
}
function burnBatch( function burnBatch(
address account, address account,
@ -88,7 +72,7 @@ abstract contract BEBase1155 is ERC1155, AccessControl {
*/ */
function setMintFactory(address factory) function setMintFactory(address factory)
external external
onlyRole(DEFAULT_ADMIN_ROLE) onlyOwner
{ {
_grantRole(MINTER_ROLE, factory); _grantRole(MINTER_ROLE, factory);
_grantRole(BURN_ROLE, factory); _grantRole(BURN_ROLE, factory);
@ -99,7 +83,7 @@ abstract contract BEBase1155 is ERC1155, AccessControl {
*/ */
function removeMintFactory(address factory) function removeMintFactory(address factory)
external external
onlyRole(DEFAULT_ADMIN_ROLE) onlyOwner
{ {
_revokeRole(MINTER_ROLE, factory); _revokeRole(MINTER_ROLE, factory);
_revokeRole(BURN_ROLE, factory); _revokeRole(BURN_ROLE, factory);
@ -126,14 +110,14 @@ abstract contract BEBase1155 is ERC1155, AccessControl {
function grantLockRole(address account) function grantLockRole(address account)
external external
onlyRole(DEFAULT_ADMIN_ROLE) onlyOwner
{ {
_grantRole(LOCK_ROLE, account); _grantRole(LOCK_ROLE, account);
} }
function revokeLockRole(address account) function revokeLockRole(address account)
external external
onlyRole(DEFAULT_ADMIN_ROLE) onlyOwner
{ {
_revokeRole(LOCK_ROLE, account); _revokeRole(LOCK_ROLE, account);
} }
@ -262,9 +246,10 @@ abstract contract BEBase1155 is ERC1155, AccessControl {
uint256 tokenIndex = _ownedTokensIndex[from][tokenId] - 1; uint256 tokenIndex = _ownedTokensIndex[from][tokenId] - 1;
uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];
// Move the last token to the slot of the to-delete token
_ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokens[from][tokenIndex] = lastTokenId;
_ownedTokensIndex[from][lastTokenId] = tokenIndex + 1; // Update the moved token's index // Update the moved token's index
_ownedTokensIndex[from][lastTokenId] = tokenIndex + 1;
// This also deletes the contents at the last position of the array // This also deletes the contents at the last position of the array
delete _ownedTokensIndex[from][tokenId]; delete _ownedTokensIndex[from][tokenId];

View File

@ -1,9 +1,6 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity 0.8.10; pragma solidity 0.8.10;
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "./BEBase1155.sol"; import "./BEBase1155.sol";
contract BEChip1155 is BEBase1155 { contract BEChip1155 is BEBase1155 {

View File

@ -1,9 +1,6 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity 0.8.10; pragma solidity 0.8.10;
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "./BEBase1155.sol"; import "./BEBase1155.sol";
/** /**
* for Hero and Weapon shard * for Hero and Weapon shard

11
contracts/utils/UInt.sol Normal file
View File

@ -0,0 +1,11 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.10;
library UInt{
function asSingletonArray(uint256 element) internal pure returns (uint256[] memory) {
uint256[] memory array = new uint256[](1);
array[0] = element;
return array;
}
}