Skip to content

Commit

Permalink
break up the proxy redirect code in order to clarify
Browse files Browse the repository at this point in the history
Signed-off-by: Luke Lee <[email protected]>
  • Loading branch information
lukelee-sl committed Nov 27, 2024
1 parent 7e99e3c commit 3d87889
Showing 1 changed file with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,26 +91,40 @@ public class DispatchingEvmFrameState implements EvmFrameState {

private static final String ADDRESS_BYTECODE_PATTERN = "fefefefefefefefefefefefefefefefefefefefe";

private static final String PROXY_PRE_BYTES = "6080604052348015600f57600080fd5b506000610";
private static final String PROXY_MID_BYTES = "905077";
private static final String PROXY_POST_BYTES =
"fefefefefefefefefefefefefefefefefefefefe600052366000602037600080366018016008845af43d806000803e8160008114605857816000f35b816000fdfea2646970667358221220d8378feed472ba49a0005514ef7087017f707b45fb9bf56bb81bb93ff19a238b64736f6c634300080b0033";

@SuppressWarnings("java:S6418")
// The following hex string is created by compiling the contract defined in HIP-719.
// (https://hips.hedera.com/hip/hip-719). The only exception is that the function selector for `redirectForToken`
// (0x618dc65e)
// has been pre substituted before the ADDRESS_BYTECODE_PATTERN.
private static final String TOKEN_CALL_REDIRECT_CONTRACT_BINARY =
"6080604052348015600f57600080fd5b506000610167905077618dc65efefefefefefefefefefefefefefefefefefefefe600052366000602037600080366018016008845af43d806000803e8160008114605857816000f35b816000fdfea2646970667358221220d8378feed472ba49a0005514ef7087017f707b45fb9bf56bb81bb93ff19a238b64736f6c634300080b0033";
private static final String TOKEN_CALL_REDIRECT_CONTRACT_BINARY = PROXY_PRE_BYTES
+ "167" // System contract address for HTS
+ PROXY_MID_BYTES
+ "618dc65e" // function selector for `redirectForToken`
+ PROXY_POST_BYTES;

// The following byte code is created by compiling the contract defined in HIP-906
// (https://hips.hedera.com/hip/hip-906). The only exception is that the function selector for `redirectForAddress`
// (0xe4cbd3a7)
// has been pre substituted before the ADDRESS_BYTECODE_PATTERN.
private static final String ACCOUNT_CALL_REDIRECT_CONTRACT_BINARY =
"6080604052348015600f57600080fd5b50600061016a905077e4cbd3a7fefefefefefefefefefefefefefefefefefefefe600052366000602037600080366018016008845af43d806000803e8160008114605857816000f35b816000fdfea2646970667358221220d8378feed472ba49a0005514ef7087017f707b45fb9bf56bb81bb93ff19a238b64736f6c634300080b0033";
private static final String ACCOUNT_CALL_REDIRECT_CONTRACT_BINARY = PROXY_PRE_BYTES
+ "16a" // System contract address for HAS
+ PROXY_MID_BYTES
+ "e4cbd3a7" // function selector for `redirectForAddress`
+ PROXY_POST_BYTES;

// The following byte code is copied from the `redirectForToken` and `redirectForAccount` contract defined above.
// The only exception is that the function selector for `redirectForScheduleTxn` (0x5c3889ca)
// has been pre substituted before the ADDRESS_BYTECODE_PATTERN.
private static final String SCHEDULE_CALL_REDIRECT_CONTRACT_BINARY =
"6080604052348015600f57600080fd5b50600061016b9050775c3889cafefefefefefefefefefefefefefefefefefefefe600052366000602037600080366018016008845af43d806000803e8160008114605857816000f35b816000fdfea2646970667358221220d8378feed472ba49a0005514ef7087017f707b45fb9bf56bb81bb93ff19a238b64736f6c634300080b0033";
private static final String SCHEDULE_CALL_REDIRECT_CONTRACT_BINARY = PROXY_PRE_BYTES
+ "16b" // System contract address for HSS
+ PROXY_MID_BYTES
+ "5c3889ca" // function selector for `redirectForScheduleTxn`
+ PROXY_POST_BYTES;

private final HederaNativeOperations nativeOperations;
private final ContractStateStore contractStateStore;
Expand Down

0 comments on commit 3d87889

Please sign in to comment.