-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* introduce AbstractOrder * rm setByAIService as it's will be not used * forge fmt * move common parts into AbstractOrder * new devnet deployment
- Loading branch information
Showing
7 changed files
with
191 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"orderFactory": "0x1E1FBD4495Ce5a05BcF9857663a6f2992dF47E04", | ||
"registry": "0x8Fe9EADB851f4122273F34d09A8CA8D1B628E4bF" | ||
"orderFactory": "0xA55973fB4cA5EbBb7e9879C73B2d27D5fe5d6E8a", | ||
"registry": "0xa7f5a0571fd94dC8E48960a9819Bda8C7Ed0e433" | ||
} |
100 changes: 50 additions & 50 deletions
100
solidity/orders/broadcast/Deploy.s.sol/12345/run-latest.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,15 +13,15 @@ | |
}, | ||
"scripts": { | ||
"clean": "rm -rf cache out", | ||
"build": "forge build src", | ||
"build": "forge build src --via-ir", | ||
"lint": "yarn run lint:sol && yarn run prettier:check", | ||
"lint:sol": "forge fmt --check && yarn solhint \"{script,src,test}/**/*.sol\"", | ||
"prettier:check": "prettier --check \"**/*.{json,md,yml}\" --ignore-path \".prettierignore\"", | ||
"prettier:write": "prettier --write \"**/*.{json,md,yml}\" --ignore-path \".prettierignore\"", | ||
"test": "forge test --via-ir", | ||
"test:coverage": "forge coverage", | ||
"test:coverage:report": "forge coverage --report lcov && genhtml lcov.info --branch-coverage --output-dir coverage", | ||
"deploy": "forge script script/Deploy.s.sol:Deploy --chain $CHAIN_ID --rpc-url $RPC_URL --broadcast -vvvv" | ||
"deploy": "forge script script/Deploy.s.sol:Deploy --chain $CHAIN_ID --rpc-url $RPC_URL --broadcast -vvvv --via-ir" | ||
}, | ||
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity >=0.8.25 <0.9.0; | ||
|
||
import { BroadcastType, IWarden, IWARDEN_PRECOMPILE_ADDRESS, KeyResponse } from "precompile-warden/IWarden.sol"; | ||
import { Types as CommonTypes } from "precompile-common/Types.sol"; | ||
import { RLPEncode } from "./RLPEncode.sol"; | ||
import { Types } from "./Types.sol"; | ||
import { ExecutionData } from "./IExecution.sol"; | ||
import { Strings } from "./Strings.sol"; | ||
|
||
error InvalidScheduler(); | ||
error InvalidRegistry(); | ||
error InvalidExpectedApproveExpression(); | ||
error InvalidExpectedRejectExpression(); | ||
error InvalidTxTo(); | ||
|
||
abstract contract AbstractOrder { | ||
using Strings for *; | ||
|
||
IWarden private immutable WARDEN_PRECOMPILE; | ||
address private _keyAddress; | ||
int32 private constant ETHEREUM_ADDRESS_TYPE = 1; | ||
|
||
constructor( | ||
Types.SignRequestData memory signRequestData, | ||
Types.CreatorDefinedTxFields memory creatorDefinedTxFields, | ||
address scheduler, | ||
address registry | ||
) { | ||
if (scheduler == address(0)) { | ||
revert InvalidScheduler(); | ||
} | ||
|
||
if (registry == address(0)) { | ||
revert InvalidRegistry(); | ||
} | ||
|
||
if (bytes(signRequestData.expectedApproveExpression).length == 0) { | ||
revert InvalidExpectedApproveExpression(); | ||
} | ||
|
||
if (bytes(signRequestData.expectedRejectExpression).length == 0) { | ||
revert InvalidExpectedRejectExpression(); | ||
} | ||
|
||
if (creatorDefinedTxFields.to == address(0)) { | ||
revert InvalidTxTo(); | ||
} | ||
|
||
WARDEN_PRECOMPILE = IWarden(IWARDEN_PRECOMPILE_ADDRESS); | ||
int32[] memory addressTypes = new int32[](1); | ||
addressTypes[0] = ETHEREUM_ADDRESS_TYPE; | ||
KeyResponse memory keyResponse = WARDEN_PRECOMPILE.keyById(signRequestData.keyId, addressTypes); | ||
_keyAddress = keyResponse.addresses[0].addressValue.parseAddress(); | ||
} | ||
|
||
function encodeUnsignedEIP1559( | ||
uint256 nonce, | ||
uint256 gas, | ||
uint256 maxPriorityFeePerGas, | ||
uint256 maxFeePerGas, | ||
bytes[] calldata accessList, | ||
Types.CreatorDefinedTxFields calldata creatorDefinedTxFields | ||
) | ||
public | ||
pure | ||
returns (bytes memory unsignedTx, bytes32 txHash) | ||
{ | ||
uint256 txType = 2; // eip1559 tx type | ||
bytes[] memory txArray = new bytes[](9); | ||
txArray[0] = RLPEncode.encodeUint(creatorDefinedTxFields.chainId); | ||
txArray[1] = RLPEncode.encodeUint(nonce); | ||
txArray[2] = RLPEncode.encodeUint(maxPriorityFeePerGas); | ||
txArray[3] = RLPEncode.encodeUint(maxFeePerGas); | ||
txArray[4] = RLPEncode.encodeUint(gas); | ||
txArray[5] = RLPEncode.encodeAddress(creatorDefinedTxFields.to); | ||
txArray[6] = RLPEncode.encodeUint(creatorDefinedTxFields.value); | ||
txArray[7] = RLPEncode.encodeBytes(creatorDefinedTxFields.data); | ||
txArray[8] = RLPEncode.encodeList(accessList); | ||
bytes memory unsignedTxEncoded = RLPEncode.encodeList(txArray); | ||
unsignedTx = RLPEncode.concat(RLPEncode.encodeUint(txType), unsignedTxEncoded); | ||
txHash = keccak256(unsignedTx); | ||
} | ||
|
||
function buildExecutionData(Types.CreatorDefinedTxFields calldata creatorDefinedTxFields) | ||
public | ||
view | ||
returns (ExecutionData memory data) | ||
{ | ||
data = ExecutionData({ | ||
caller: _keyAddress, | ||
to: creatorDefinedTxFields.to, | ||
chainId: creatorDefinedTxFields.chainId, | ||
value: creatorDefinedTxFields.value, | ||
data: creatorDefinedTxFields.data | ||
}); | ||
} | ||
|
||
function createSignRequest( | ||
Types.SignRequestData calldata signRequestData, | ||
bytes calldata signRequestInput, | ||
CommonTypes.Coin[] calldata maxKeychainFees | ||
) | ||
public | ||
returns (bool) | ||
{ | ||
return WARDEN_PRECOMPILE.newSignRequest( | ||
signRequestData.keyId, | ||
signRequestInput, | ||
signRequestData.analyzers, | ||
signRequestData.encryptionKey, | ||
maxKeychainFees, | ||
signRequestData.spaceNonce, | ||
signRequestData.actionTimeoutHeight, | ||
signRequestData.expectedApproveExpression, | ||
signRequestData.expectedRejectExpression, | ||
BroadcastType.Automatic | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters