Make preSign compatible with executeTransaction

This commit is contained in:
Amir Bandeali
2019-04-24 18:19:31 -07:00
parent f4b3b69b2f
commit 24906138c7
3 changed files with 9 additions and 34 deletions

View File

@@ -48,30 +48,14 @@ contract MixinSignatureValidator is
// Mapping of signer => order validator => approved
mapping (address => mapping (address => bool)) public allowedOrderValidators;
/// @dev Approves a hash on-chain using any valid signature type.
/// @dev Approves a hash on-chain.
/// After presigning a hash, the preSign signature type will become valid for that hash and signer.
/// @param signerAddress Address that should have signed the given hash.
/// @param signature Proof that the hash has been signed by signer.
function preSign(
bytes32 hash,
address signerAddress,
bytes calldata signature
)
/// @param hash Any 32-byte hash.
function preSign(bytes32 hash)
external
nonReentrant
{
if (signerAddress != msg.sender) {
if (!isValidHashSignature(
hash,
signerAddress,
signature)) {
rrevert(SignatureError(
SignatureErrorCodes.BAD_SIGNATURE,
hash,
signerAddress,
signature
));
}
}
address signerAddress = getCurrentContextAddress();
preSigned[hash][signerAddress] = true;
}

View File

@@ -24,15 +24,10 @@ import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
contract ISignatureValidator {
/// @dev Approves a hash on-chain using any valid signature type.
/// @dev Approves a hash on-chain.
/// After presigning a hash, the preSign signature type will become valid for that hash and signer.
/// @param signerAddress Address that should have signed the given hash.
/// @param signature Proof that the hash has been signed by signer.
function preSign(
bytes32 hash,
address signerAddress,
bytes calldata signature
)
/// @param hash Any 32-byte hash.
function preSign(bytes32 hash)
external;
/// @dev Approves/unnapproves a Validator contract to verify signatures on signer's behalf.

View File

@@ -429,11 +429,7 @@ describe('MixinSignatureValidator', () => {
// Presign hash
const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder);
await web3Wrapper.awaitTransactionSuccessAsync(
await signatureValidator.preSign.sendTransactionAsync(
orderHashHex,
signedOrder.makerAddress,
signedOrder.signature,
),
await signatureValidator.preSign.sendTransactionAsync(orderHashHex, { from: signedOrder.makerAddress }),
constants.AWAIT_TRANSACTION_MINED_MS,
);
// Validate presigned signature