增加升级时的地址检查

This commit is contained in:
cebgcontract 2022-02-21 16:40:39 +08:00
parent de5eb4bca8
commit a98b70b133
2 changed files with 13 additions and 2 deletions

View File

@ -58,6 +58,12 @@ contract EvolveProxy is Ownable, Initializable, HasSignature {
tokenIds[0] > 0 && tokenIds[1] > 0, tokenIds[0] > 0 && tokenIds[1] > 0,
"EvolveProxy: hero to evolve and burn can not be 0" "EvolveProxy: hero to evolve and burn can not be 0"
); );
require(
tokenIds[0] != tokenIds[1],
"EvolveProxy: hero to evolve and burn can not be same"
);
require( require(
hero.ownerOf(tokenIds[0]) == msg.sender, hero.ownerOf(tokenIds[0]) == msg.sender,
"EvolveProxy: not owner of this hero now" "EvolveProxy: not owner of this hero now"
@ -97,6 +103,11 @@ contract EvolveProxy is Ownable, Initializable, HasSignature {
"EvolveProxy: equip to evolve and burn can not be 0" "EvolveProxy: equip to evolve and burn can not be 0"
); );
require(
tokenIds[0] != tokenIds[1],
"EvolveProxy: equip to evolve and burn can not be same"
);
require( require(
equip.ownerOf(tokenIds[0]) == msg.sender, equip.ownerOf(tokenIds[0]) == msg.sender,
"EvolveProxy: current address is not owner of this equip now" "EvolveProxy: current address is not owner of this equip now"

View File

@ -92,7 +92,7 @@ contract HasSignature {
address signer, address signer,
bytes32 structHash, bytes32 structHash,
bytes memory signature bytes memory signature
) external view{ ) public view{
bytes32 digest = _hashTypedDataV4(structHash); bytes32 digest = _hashTypedDataV4(structHash);
address recovered = ECDSA.recover(digest, signature); address recovered = ECDSA.recover(digest, signature);
require(recovered == signer, "[BE] invalid signature"); require(recovered == signer, "[BE] invalid signature");
@ -103,7 +103,7 @@ contract HasSignature {
address signer, address signer,
bytes32 hash, bytes32 hash,
bytes memory signature bytes memory signature
) external pure { ) public pure {
require(signature.length == 65, "[BE] invalid signature length"); require(signature.length == 65, "[BE] invalid signature length");
bytes32 ethSignedMessageHash = ECDSA.toEthSignedMessageHash( bytes32 ethSignedMessageHash = ECDSA.toEthSignedMessageHash(
hash hash