errors reported as strings not bytes

This commit is contained in:
Tim Olson
2023-10-20 01:09:46 -04:00
parent 718e3f3a36
commit 4cc5d54eb6
2 changed files with 10 additions and 10 deletions

View File

@@ -7,7 +7,7 @@ pragma abicoder v2;
contract Dexorder {
// represents the Dexorder organization
event DexorderExecutions(uint128 indexed id, bytes[] errors);
event DexorderExecutions(bytes16 indexed id, string[] errors);
struct ExecutionRequest {
address payable vault;
@@ -17,29 +17,29 @@ contract Dexorder {
}
function execute( uint128 id, ExecutionRequest memory req ) public returns (bytes memory error) {
function execute( bytes16 id, ExecutionRequest memory req ) public returns (string memory error) {
error = _execute(req);
bytes[] memory errors = new bytes[](1);
string[] memory errors = new string[](1);
errors[0] = error;
emit DexorderExecutions(id, errors);
}
function execute( uint128 id, ExecutionRequest[] memory reqs ) public returns (bytes[] memory errors) {
errors = new bytes[](reqs.length);
function execute( bytes16 id, ExecutionRequest[] memory reqs ) public returns (string[] memory errors) {
errors = new string[](reqs.length);
for( uint8 i=0; i<reqs.length; i++ )
errors[i] = _execute(reqs[i]);
emit DexorderExecutions(id, errors);
}
function _execute( ExecutionRequest memory req ) private returns (bytes memory error) {
function _execute( ExecutionRequest memory req ) private returns (string memory error) {
// single tranche execution
try Vault(req.vault).execute(req.orderIndex, req.trancheIndex, req.proof) {
return '';
error = '';
}
catch (bytes memory reason) {
return reason;
catch Error(string memory reason) {
error = reason;
}
}
}

View File

@@ -10,7 +10,7 @@ library VaultAddress {
// keccak-256 hash of the Vault's bytecode (not the deployed bytecode but the initialization bytecode)
// can paste into:
// https://emn178.github.io/online-tools/keccak_256.html
bytes32 internal constant VAULT_INIT_CODE_HASH = 0x94dd1e2fe4a67770f9295aff1b352fb0792647d2377cd96aa72e4c3a3222aad1;
bytes32 internal constant VAULT_INIT_CODE_HASH = 0xbf7fa358e7e01c60966db5f8298feffb8b7e2aa494a6ba4a0f94a17a817f93ff;
// the contract being constructed must not have any constructor arguments or the determinism will be broken. instead, use a callback to
// get construction arguments