Skip to content

Commit 3a0e280

Browse files
committed
feat: output BatcherPaymentService addresses as JSON
1 parent ee2db4f commit 3a0e280

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

contracts/script/deploy/BatcherPaymentServiceDeployer.s.sol

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,15 @@ import "forge-std/Script.sol";
88
import "forge-std/StdJson.sol";
99

1010
contract BatcherPaymentServiceDeployer is Script {
11-
function run(
12-
string memory batcherConfigPath
13-
) external returns (address, address) {
11+
function run(string memory batcherConfigPath, string memory outputPath) external returns (address, address) {
1412
// READ JSON CONFIG DATA
1513
string memory config_data = vm.readFile(batcherConfigPath);
1614

17-
address batcherWallet = stdJson.readAddress(
18-
config_data,
19-
".address.batcherWallet"
20-
);
15+
address batcherWallet = stdJson.readAddress(config_data, ".address.batcherWallet");
2116

22-
address alignedLayerServiceManager = stdJson.readAddress(
23-
config_data,
24-
".address.alignedLayerServiceManager"
25-
);
17+
address alignedLayerServiceManager = stdJson.readAddress(config_data, ".address.alignedLayerServiceManager");
2618

27-
address batcherPaymentServiceOwner = stdJson.readAddress(
28-
config_data,
29-
".permissions.owner"
30-
);
19+
address batcherPaymentServiceOwner = stdJson.readAddress(config_data, ".permissions.owner");
3120

3221
vm.startBroadcast();
3322

@@ -45,6 +34,15 @@ contract BatcherPaymentServiceDeployer is Script {
4534

4635
vm.stopBroadcast();
4736

37+
string memory addresses = "addresses";
38+
vm.serializeAddress(addresses, "batcherPaymentService", address(proxy));
39+
string memory addressesStr =
40+
vm.serializeAddress(addresses, "batcherPaymentServiceImplementation", address(batcherPaymentService));
41+
42+
string memory parentObject = "parent";
43+
string memory finalJson = vm.serializeString(parentObject, "addresses", addressesStr);
44+
vm.writeJson(finalJson, outputPath);
45+
4846
return (address(proxy), address(batcherPaymentService));
4947
}
5048
}

contracts/scripts/anvil/deploy_aligned_contracts.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ forge script ../examples/verify/script/VerifyBatchInclusionCallerDeployer.s.sol
3838
# Deploy Batcher Payments Contract
3939
forge_output=$(forge script script/deploy/BatcherPaymentServiceDeployer.s.sol \
4040
./script/deploy/config/devnet/batcher-payment-service.devnet.config.json \
41+
./script/deploy/output/devnet/batcher_deployment_output.json \
4142
--rpc-url "http://localhost:8545" \
4243
--private-key "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" \
4344
--broadcast \
44-
--sig "run(string batcherConfigPath)")
45+
--sig "run(string batcherConfigPath, string outputPath)")
4546

4647
# Extract the batcher payment service values from the output
4748
# new_aligned_layer_service_manager_implementation=$(echo "$forge_output" | awk '/1: address/ {print $3}')

contracts/scripts/deploy_batcher_payment_service.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,26 @@ cd ../
1010

1111
source scripts/.env
1212

13+
BATCHER_PAYMENT_SERVICE_OUTPUT_PATH=./script/deploy/output/devnet/batcher_deployment_output.json
14+
1315
# Deploy Batcher Payments Contract
1416
forge_output=$(forge script script/deploy/BatcherPaymentServiceDeployer.s.sol \
1517
$BATCHER_PAYMENT_SERVICE_CONFIG_PATH \
18+
$BATCHER_PAYMENT_SERVICE_OUTPUT_PATH \
1619
--rpc-url $RPC_URL \
1720
--private-key $PRIVATE_KEY \
1821
--broadcast \
1922
--legacy \
2023
--verify \
2124
--etherscan-api-key $ETHERSCAN_API_KEY \
22-
--sig "run(string memory batcherConfigPath)")
25+
--sig "run(string memory batcherConfigPath, string memory outputPath)")
2326

2427
echo "$forge_output"
2528

2629
# Extract the batcher payment service values from the output
2730
# new_aligned_layer_service_manager_implementation=$(echo "$forge_output" | awk '/1: address/ {print $3}')
28-
batcher_payment_service_proxy=$(echo "$forge_output" | awk '/0: address/ {print $3}')
29-
batcher_payment_service_implementation=$(echo "$forge_output" | awk '/1: address/ {print $3}')
31+
batcher_payment_service_proxy=$(jq -r '.addresses.batcherPaymentService' $BATCHER_PAYMENT_SERVICE_OUTPUT_PATH)
32+
batcher_payment_service_implementation=$(jq -r '.addresses.batcherPaymentServiceImplementation' $BATCHER_PAYMENT_SERVICE_OUTPUT_PATH)
3033

3134
# Use the extracted value to replace the batcher payment service values in alignedlayer_deployment_output.json and save it to a temporary file
3235
jq --arg batcher_payment_service_proxy "$batcher_payment_service_proxy" '.addresses.batcherPaymentService = $batcher_payment_service_proxy' $OUTPUT_PATH > $OUTPUT_PATH.temp2

0 commit comments

Comments
 (0)