Siff
BANNED
- Feb 13, 2024
- 15
- 9
Hoping someone has more of a clue what's going on - I have been playing around with parsing json in foundry but I am facing strange issue.
my json:
"create3factory": "0x9fBB3DF7C40Da2e5A0dE984fFE2CCB7C47cd0ABf",
"swapFee": 500,
"airdropRoot": "0x1b32e214013f5a8553866f276bc7cf128541bb0bc55a59101170493a86781059"
}
solidity code:
I am only able to decode this with incorrect order of params in my struct. I dont understand why it works this way. It's completly unintuitive.
I managed to find this out with cast:
❯ cast abi-decode "f()(bytes32,address,uint256)"
0x10x1b32e214013f5a8553866f276bc7cf128541bb0bc55a59101170493a86781059
0x9fBB3DF7C40Da2e5A0dE984fFE2CCB7C47cd0ABf500
when I try with correct order which would be:
I got a tx revert
my json:
"create3factory": "0x9fBB3DF7C40Da2e5A0dE984fFE2CCB7C47cd0ABf",
"swapFee": 500,
"airdropRoot": "0x1b32e214013f5a8553866f276bc7cf128541bb0bc55a59101170493a86781059"
}
solidity code:
Code:
struct Constant {
bytes32 airdropRoot;
address create3factory;
uint256 swapFee;
}
string memory json = vm.readFile(path);
bytes memory data = vm.parseJson(json);
Constant memory constantData = abi.decode(data, (Constant));
I am only able to decode this with incorrect order of params in my struct. I dont understand why it works this way. It's completly unintuitive.
I managed to find this out with cast:
❯ cast abi-decode "f()(bytes32,address,uint256)"
0x10x1b32e214013f5a8553866f276bc7cf128541bb0bc55a59101170493a86781059
0x9fBB3DF7C40Da2e5A0dE984fFE2CCB7C47cd0ABf500
when I try with correct order which would be:
Code:
struct Constant {
address create3factory;
uint256 swapFee;
bytes32 airdropRoot;
}
I got a tx revert
Last edited: