增加eip712的验签方式
This commit is contained in:
parent
d5045f0c2d
commit
980398375e
@ -9980,7 +9980,7 @@
|
||||
},
|
||||
"networks": {},
|
||||
"schemaVersion": "3.4.3",
|
||||
"updatedAt": "2022-02-10T08:56:53.475Z",
|
||||
"updatedAt": "2022-02-16T06:21:34.871Z",
|
||||
"devdoc": {
|
||||
"kind": "dev",
|
||||
"methods": {
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -10118,10 +10118,61 @@
|
||||
"transactionHash": "0x679ae298e758c17705d1f3dc06be3031b0533ce67d6dd3dc361ff2ab0f933b80"
|
||||
},
|
||||
"1337": {
|
||||
"events": {},
|
||||
"events": {
|
||||
"0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925": {
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "owner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "spender",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "Approval",
|
||||
"type": "event"
|
||||
},
|
||||
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef": {
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "from",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "Transfer",
|
||||
"type": "event"
|
||||
}
|
||||
},
|
||||
"links": {},
|
||||
"address": "0x22aD50379cf42Ff035940454A33090489E93E189",
|
||||
"transactionHash": "0xb584efc4667c249a8b362f9a106a80abae0892bdc984a957975ba83a20609359"
|
||||
"address": "0xC8d87fdd2896E0a1cAb382322075FDAD7526c8D2",
|
||||
"transactionHash": "0x7ea2b40f8ccb26f9dec9abec8a01f4ca21e8d5cc2621f00d788986c81085f8a2"
|
||||
},
|
||||
"1338": {
|
||||
"events": {
|
||||
@ -10299,10 +10350,16 @@
|
||||
"links": {},
|
||||
"address": "0xbCFC9461B73D7Fb423552d6cd594f406F7B0585D",
|
||||
"transactionHash": "0x38af5374e78a4c39c71fe76d89e22d6b6bbcdff875d0fd921658da9abf139560"
|
||||
},
|
||||
"1644989050832": {
|
||||
"events": {},
|
||||
"links": {},
|
||||
"address": "0x050847ca337e25F030D17892D2F2f8bA567394b4",
|
||||
"transactionHash": "0x81eeb2c5f0325e6b4c2b97424533bcbd95ab12b55df9c89c711cb116300f201e"
|
||||
}
|
||||
},
|
||||
"schemaVersion": "3.4.3",
|
||||
"updatedAt": "2022-02-11T11:16:11.487Z",
|
||||
"updatedAt": "2022-02-18T04:53:59.198Z",
|
||||
"networkType": "ethereum",
|
||||
"devdoc": {
|
||||
"kind": "dev",
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -221,7 +221,8 @@
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
"type": "function",
|
||||
"constant": true
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
@ -234,7 +235,8 @@
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
"type": "function",
|
||||
"constant": true
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
@ -247,7 +249,8 @@
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
"type": "function",
|
||||
"constant": true
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
@ -260,7 +263,8 @@
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
"type": "function",
|
||||
"constant": true
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
@ -273,7 +277,8 @@
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
"type": "function",
|
||||
"constant": true
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
@ -286,7 +291,8 @@
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
"type": "function",
|
||||
"constant": true
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
@ -332,7 +338,8 @@
|
||||
"name": "execute",
|
||||
"outputs": [],
|
||||
"stateMutability": "payable",
|
||||
"type": "function"
|
||||
"type": "function",
|
||||
"payable": true
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
@ -365,7 +372,8 @@
|
||||
"name": "executeBatch",
|
||||
"outputs": [],
|
||||
"stateMutability": "payable",
|
||||
"type": "function"
|
||||
"type": "function",
|
||||
"payable": true
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
@ -384,7 +392,8 @@
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
"type": "function",
|
||||
"constant": true
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
@ -403,7 +412,8 @@
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
"type": "function",
|
||||
"constant": true
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
@ -445,7 +455,8 @@
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
"type": "function",
|
||||
"constant": true
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
@ -484,7 +495,8 @@
|
||||
}
|
||||
],
|
||||
"stateMutability": "pure",
|
||||
"type": "function"
|
||||
"type": "function",
|
||||
"constant": true
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
@ -523,7 +535,8 @@
|
||||
}
|
||||
],
|
||||
"stateMutability": "pure",
|
||||
"type": "function"
|
||||
"type": "function",
|
||||
"constant": true
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
@ -542,7 +555,8 @@
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
"type": "function",
|
||||
"constant": true
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
@ -561,7 +575,8 @@
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
"type": "function",
|
||||
"constant": true
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
@ -580,7 +595,8 @@
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
"type": "function",
|
||||
"constant": true
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
@ -599,7 +615,8 @@
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
"type": "function",
|
||||
"constant": true
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
@ -730,11 +747,13 @@
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
"type": "function",
|
||||
"constant": true
|
||||
},
|
||||
{
|
||||
"stateMutability": "payable",
|
||||
"type": "receive"
|
||||
"type": "receive",
|
||||
"payable": true
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
@ -747,7 +766,8 @@
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
"type": "function",
|
||||
"constant": true
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
@ -24219,6 +24239,206 @@
|
||||
"version": "0.8.10+commit.fc410830.Emscripten.clang"
|
||||
},
|
||||
"networks": {
|
||||
"1337": {
|
||||
"events": {
|
||||
"0xc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b58": {
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "bytes32",
|
||||
"name": "id",
|
||||
"type": "bytes32"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "uint256",
|
||||
"name": "index",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "address",
|
||||
"name": "target",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "value",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "bytes",
|
||||
"name": "data",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"name": "CallExecuted",
|
||||
"type": "event"
|
||||
},
|
||||
"0x4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca": {
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "bytes32",
|
||||
"name": "id",
|
||||
"type": "bytes32"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "uint256",
|
||||
"name": "index",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "address",
|
||||
"name": "target",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "value",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "bytes",
|
||||
"name": "data",
|
||||
"type": "bytes"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "bytes32",
|
||||
"name": "predecessor",
|
||||
"type": "bytes32"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "delay",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "CallScheduled",
|
||||
"type": "event"
|
||||
},
|
||||
"0xbaa1eb22f2a492ba1a5fea61b8df4d27c6c8b5f3971e63bb58fa14ff72eedb70": {
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "bytes32",
|
||||
"name": "id",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "Cancelled",
|
||||
"type": "event"
|
||||
},
|
||||
"0x11c24f4ead16507c69ac467fbd5e4eed5fb5c699626d2cc6d66421df253886d5": {
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "oldDuration",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "newDuration",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "MinDelayChange",
|
||||
"type": "event"
|
||||
},
|
||||
"0xbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff": {
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "bytes32",
|
||||
"name": "role",
|
||||
"type": "bytes32"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "bytes32",
|
||||
"name": "previousAdminRole",
|
||||
"type": "bytes32"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "bytes32",
|
||||
"name": "newAdminRole",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "RoleAdminChanged",
|
||||
"type": "event"
|
||||
},
|
||||
"0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d": {
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "bytes32",
|
||||
"name": "role",
|
||||
"type": "bytes32"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "account",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "sender",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "RoleGranted",
|
||||
"type": "event"
|
||||
},
|
||||
"0xf6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b": {
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "bytes32",
|
||||
"name": "role",
|
||||
"type": "bytes32"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "account",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "sender",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "RoleRevoked",
|
||||
"type": "event"
|
||||
}
|
||||
},
|
||||
"links": {},
|
||||
"address": "0xF2A5e388D9B65823609701690917140e878Ba145",
|
||||
"transactionHash": "0xed76db42da9a24070e7807c6e6e6da3498c1a1177a3abed0fea70f8bd5fb5f54"
|
||||
},
|
||||
"1338": {
|
||||
"events": {
|
||||
"0xc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b58": {
|
||||
@ -24418,10 +24638,17 @@
|
||||
"links": {},
|
||||
"address": "0x6FdB1c9e1a1A8beD2EE22a3d5E62CA330ee88ecb",
|
||||
"transactionHash": "0xc96a4e6a9d83e7cc616eae8ca902b352f019ac8762b870c8a0d2de1728c681bc"
|
||||
},
|
||||
"1644989050832": {
|
||||
"events": {},
|
||||
"links": {},
|
||||
"address": "0xBc884A83df280A1965E5f37769B107E4ceeD2E6e",
|
||||
"transactionHash": "0xc13387ad01f45d9a7c045af16a6eeb7fec49afd74e749083a8545329c3b8845b"
|
||||
}
|
||||
},
|
||||
"schemaVersion": "3.4.3",
|
||||
"updatedAt": "2022-02-11T11:01:27.713Z",
|
||||
"updatedAt": "2022-02-18T04:53:59.154Z",
|
||||
"networkType": "ethereum",
|
||||
"devdoc": {
|
||||
"kind": "dev",
|
||||
"methods": {
|
||||
|
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 one or more lines are too long
File diff suppressed because one or more lines are too long
@ -3152,18 +3152,24 @@
|
||||
"1337": {
|
||||
"events": {},
|
||||
"links": {},
|
||||
"address": "0xBA75742aAf838C118CF5DBA74b3aD9260710fb8B",
|
||||
"transactionHash": "0x941e5e8551e766d16b9b07027d9cd5140bed474ded77a167df25b6926e5b4ba5"
|
||||
"address": "0x0DB24A927FFC3622884B7A3B6f1C694ED8092A01",
|
||||
"transactionHash": "0xd55fa70f0a3993c168eefad5ba7eabde2d17ceb196e768a860f4e6855601830f"
|
||||
},
|
||||
"1338": {
|
||||
"events": {},
|
||||
"links": {},
|
||||
"address": "0xC045C7B6B976d24728872d2117073c893d0B09C2",
|
||||
"transactionHash": "0xa5fd2f908ab9f24480af8560539a06039b4b05ef6c92541844f2e60ba1919285"
|
||||
},
|
||||
"1644989050832": {
|
||||
"events": {},
|
||||
"links": {},
|
||||
"address": "0x6A3277BB4E14264FB02C6A13cc8d781973184Bd8",
|
||||
"transactionHash": "0x2bc5e4698bd27f5a517fc8d7ba426b678cb49a9a51ab5de889cde9ee78a5554a"
|
||||
}
|
||||
},
|
||||
"schemaVersion": "3.4.3",
|
||||
"updatedAt": "2022-02-11T11:24:50.107Z",
|
||||
"updatedAt": "2022-02-18T04:53:59.302Z",
|
||||
"networkType": "ethereum",
|
||||
"devdoc": {
|
||||
"kind": "dev",
|
||||
|
@ -8857,10 +8857,55 @@
|
||||
"transactionHash": "0x55be186130f938b282f7e56d9f176919a1a55ffd71a05304558cb691d04e7f58"
|
||||
},
|
||||
"1337": {
|
||||
"events": {},
|
||||
"events": {
|
||||
"0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0": {
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "previousOwner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "newOwner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "OwnershipTransferred",
|
||||
"type": "event"
|
||||
},
|
||||
"0xdf1b2b09e9800d31c599375056be9f9e4eb37f078102643600c4e149714efaad": {
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "address",
|
||||
"name": "contractAddress",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "address",
|
||||
"name": "to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "uint256",
|
||||
"name": "tokenId",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "TokenMinted",
|
||||
"type": "event"
|
||||
}
|
||||
},
|
||||
"links": {},
|
||||
"address": "0x024982C1740869bC30412a084023D15182E4337E",
|
||||
"transactionHash": "0x4f774d6ba2c59fc24c2fc2536f94a0182ccd494c57738c67fc6e21f90116c2fa"
|
||||
"address": "0x47EF76991DD3C561BaB1504C48C0eB55a6e61025",
|
||||
"transactionHash": "0x2ad34fc738e5dd6fc78eaf168f70c0ad090fd97352856e90600ba9d52d272b68"
|
||||
},
|
||||
"1338": {
|
||||
"events": {
|
||||
@ -8912,10 +8957,16 @@
|
||||
"links": {},
|
||||
"address": "0x9a74f110586971345A396C74228094A04f5A5eA6",
|
||||
"transactionHash": "0x42c222313378ead6c13c77b9ba0fffd4281eb4476a1c4539954c6bf66132f5b4"
|
||||
},
|
||||
"1644989050832": {
|
||||
"events": {},
|
||||
"links": {},
|
||||
"address": "0x149a2Ae9Bf58F06a06a46703eDC1c241D512b7ea",
|
||||
"transactionHash": "0x1f324550ce60e12971357db375242f7329930fad8939e3b8487e72c2c85063de"
|
||||
}
|
||||
},
|
||||
"schemaVersion": "3.4.3",
|
||||
"updatedAt": "2022-02-11T11:22:26.497Z",
|
||||
"updatedAt": "2022-02-18T04:53:59.287Z",
|
||||
"networkType": "ethereum",
|
||||
"devdoc": {
|
||||
"kind": "dev",
|
||||
|
@ -21,7 +21,8 @@ contract BEBoxMall is Ownable, HasSignature, TimelockController{
|
||||
constructor(
|
||||
address[] memory proposers,
|
||||
address[] memory executors)
|
||||
TimelockController(MIN_DELAY, proposers, executors){
|
||||
TimelockController(MIN_DELAY, proposers, executors)
|
||||
HasSignature("BEBoxMall", "1"){
|
||||
_minDelay = MIN_DELAY;
|
||||
address_initialized = false;
|
||||
}
|
||||
@ -79,7 +80,7 @@ contract BEBoxMall is Ownable, HasSignature, TimelockController{
|
||||
saltNonce
|
||||
);
|
||||
|
||||
checkSigner(userAddress, criteriaMessageHash, signature);
|
||||
checkSigner712(userAddress, criteriaMessageHash, signature);
|
||||
|
||||
IERC20 paymentToken = IERC20(paymentErc20);
|
||||
uint256 allowToPayAmount = paymentToken.allowance(
|
||||
@ -101,7 +102,7 @@ contract BEBoxMall is Ownable, HasSignature, TimelockController{
|
||||
emit BEBoxPaid(boxId, userAddress, _type, price, paymentErc20);
|
||||
}
|
||||
|
||||
function getMessageHash(
|
||||
function getMessageHash(
|
||||
uint256 _boxType,
|
||||
address _paymentErc20,
|
||||
uint256 _price,
|
||||
@ -109,7 +110,13 @@ contract BEBoxMall is Ownable, HasSignature, TimelockController{
|
||||
) public pure returns (bytes32) {
|
||||
return
|
||||
keccak256(
|
||||
abi.encodePacked(_boxType, _paymentErc20, _price, _saltNonce)
|
||||
abi.encode(
|
||||
keccak256("set(uint256 item,address token,uint256 amount,uint256 salt)"),
|
||||
_boxType,
|
||||
_paymentErc20,
|
||||
_price,
|
||||
_saltNonce
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,9 @@ contract EvolveProxy is Ownable, Initializable, HasSignature {
|
||||
uint256 chip
|
||||
);
|
||||
|
||||
constructor()
|
||||
HasSignature("EvolveProxy", "1"){
|
||||
}
|
||||
|
||||
function init(address[3] calldata _erc721s) external initializer onlyOwner {
|
||||
hero = IBurnableERC721(_erc721s[0]);
|
||||
|
@ -3,6 +3,101 @@ pragma solidity 0.8.10;
|
||||
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
|
||||
|
||||
contract HasSignature {
|
||||
bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;
|
||||
uint256 private immutable _CACHED_CHAIN_ID;
|
||||
address private immutable _CACHED_THIS;
|
||||
|
||||
bytes32 private immutable _HASHED_NAME;
|
||||
bytes32 private immutable _HASHED_VERSION;
|
||||
bytes32 private immutable _TYPE_HASH;
|
||||
|
||||
constructor(string memory name, string memory version) {
|
||||
bytes32 hashedName = keccak256(bytes(name));
|
||||
bytes32 hashedVersion = keccak256(bytes(version));
|
||||
bytes32 typeHash = keccak256(
|
||||
"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
|
||||
);
|
||||
_HASHED_NAME = hashedName;
|
||||
_HASHED_VERSION = hashedVersion;
|
||||
_CACHED_CHAIN_ID = block.chainid;
|
||||
_CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(
|
||||
typeHash,
|
||||
hashedName,
|
||||
hashedVersion
|
||||
);
|
||||
_CACHED_THIS = address(this);
|
||||
_TYPE_HASH = typeHash;
|
||||
}
|
||||
|
||||
function _buildDomainSeparator(
|
||||
bytes32 typeHash,
|
||||
bytes32 nameHash,
|
||||
bytes32 versionHash
|
||||
) private view returns (bytes32) {
|
||||
return
|
||||
keccak256(
|
||||
abi.encode(
|
||||
typeHash,
|
||||
nameHash,
|
||||
versionHash,
|
||||
block.chainid,
|
||||
address(this)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Returns the domain separator for the current chain.
|
||||
*/
|
||||
function _domainSeparatorV4() internal view returns (bytes32) {
|
||||
if (
|
||||
address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID
|
||||
) {
|
||||
return _CACHED_DOMAIN_SEPARATOR;
|
||||
} else {
|
||||
return
|
||||
_buildDomainSeparator(
|
||||
_TYPE_HASH,
|
||||
_HASHED_NAME,
|
||||
_HASHED_VERSION
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
|
||||
* function returns the hash of the fully encoded EIP712 message for this domain.
|
||||
*
|
||||
* This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
|
||||
*
|
||||
* ```solidity
|
||||
* bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
|
||||
* keccak256("Mail(address to,string contents)"),
|
||||
* mailTo,
|
||||
* keccak256(bytes(mailContents))
|
||||
* )));
|
||||
* address signer = ECDSA.recover(digest, signature);
|
||||
* ```
|
||||
*/
|
||||
function _hashTypedDataV4(bytes32 structHash)
|
||||
internal
|
||||
view
|
||||
virtual
|
||||
returns (bytes32)
|
||||
{
|
||||
return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);
|
||||
}
|
||||
|
||||
function checkSigner712(
|
||||
address signer,
|
||||
bytes32 structHash,
|
||||
bytes memory signature
|
||||
) public view{
|
||||
bytes32 digest = _hashTypedDataV4(structHash);
|
||||
address recovered = ECDSA.recover(digest, signature);
|
||||
require(recovered == signer, "[BE] invalid signature");
|
||||
require(signer != address(0), "ECDSA: invalid signature");
|
||||
}
|
||||
|
||||
function checkSigner(
|
||||
address signer,
|
||||
|
@ -36,6 +36,10 @@ contract MarketPlace is Ownable, HasSignature {
|
||||
uint256 fee
|
||||
);
|
||||
|
||||
constructor()
|
||||
HasSignature("MarketPlace", "1"){
|
||||
}
|
||||
|
||||
function setFeeToAddress(address _feeToAddress) external onlyOwner {
|
||||
require(_feeToAddress != address(0), 'fee received address can not be zero');
|
||||
feeToAddress = _feeToAddress;
|
||||
|
Loading…
x
Reference in New Issue
Block a user