Skip to content

Commit 9d70836

Browse files
committed
formatting fix
1 parent 547d76f commit 9d70836

File tree

6 files changed

+101
-49
lines changed

6 files changed

+101
-49
lines changed

target_chains/ethereum/contracts/FOUNDRY_ENV_GUIDE.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ This guide shows the **recommended Foundry-native approaches** for reading envir
99
**Use Case:** Arrays of addresses, numbers, or simple types
1010

1111
**Environment Format:**
12+
1213
```bash
1314
# Multiple addresses
1415
INIT_SIGNERS=0x58CC3AE5C097b213cE3c81979e1B9f9570746AA5,0x025ceeba2ab2a27d53d963393999eeebe83dc4ae
@@ -21,11 +22,12 @@ NETWORKS=ethereum,polygon,bsc
2122
```
2223

2324
**Solidity Code:**
25+
2426
```solidity
2527
// Read address array
2628
address[] memory signers = vm.envAddress("INIT_SIGNERS", ",");
2729
28-
// Read uint array
30+
// Read uint array
2931
uint256[] memory chainIds = vm.envUint("CHAIN_IDS", ",");
3032
3133
// Convert addresses to bytes32 if needed
@@ -36,6 +38,7 @@ for (uint i = 0; i < signers.length; i++) {
3638
```
3739

3840
**✅ Advantages:**
41+
3942
- Native Foundry support
4043
- Clean, readable format
4144
- No parsing needed
@@ -46,6 +49,7 @@ for (uint i = 0; i < signers.length; i++) {
4649
**Use Case:** Complex nested data structures
4750

4851
**Environment Format:**
52+
4953
```bash
5054
# Simple array
5155
INIT_SIGNERS='["0x58CC3AE5C097b213cE3c81979e1B9f9570746AA5","0x025ceeba2ab2a27d53d963393999eeebe83dc4ae"]'
@@ -55,6 +59,7 @@ CONFIG='{"guardians":["0x..."],"chainId":1,"enabled":true}'
5559
```
5660

5761
**Solidity Code:**
62+
5863
```solidity
5964
// Simple array
6065
string memory signersJson = vm.envString("INIT_SIGNERS");
@@ -68,6 +73,7 @@ bool enabled = abi.decode(vm.parseJson(configJson, ".enabled"), (bool));
6873
```
6974

7075
**⚠️ Requirements:**
76+
7177
- JSON must be properly formatted
7278
- Use single quotes in .env files to prevent shell parsing issues
7379
- May need escaping for complex nested structures
@@ -77,13 +83,15 @@ bool enabled = abi.decode(vm.parseJson(configJson, ".enabled"), (bool));
7783
**Use Case:** When you have a known, small number of values
7884

7985
**Environment Format:**
86+
8087
```bash
8188
GUARDIAN_1=0x58CC3AE5C097b213cE3c81979e1B9f9570746AA5
8289
GUARDIAN_2=0x025ceeba2ab2a27d53d963393999eeebe83dc4ae
8390
GUARDIAN_COUNT=2
8491
```
8592

8693
**Solidity Code:**
94+
8795
```solidity
8896
uint256 guardianCount = vm.envUint("GUARDIAN_COUNT");
8997
bytes32[] memory guardians = new bytes32[](guardianCount);
@@ -96,6 +104,7 @@ for (uint i = 0; i < guardianCount; i++) {
96104
```
97105

98106
**✅ Advantages:**
107+
99108
- Most reliable
100109
- Easy to debug
101110
- No parsing issues
@@ -106,7 +115,7 @@ for (uint i = 0; i < guardianCount; i++) {
106115
```solidity
107116
// Basic types
108117
vm.envString("KEY") // string
109-
vm.envAddress("KEY") // address
118+
vm.envAddress("KEY") // address
110119
vm.envUint("KEY") // uint256
111120
vm.envInt("KEY") // int256
112121
vm.envBytes32("KEY") // bytes32
@@ -144,6 +153,7 @@ for (uint i = 0; i < signerAddresses.length; i++) {
144153
```
145154

146155
**Environment Format:**
156+
147157
```bash
148158
INIT_SIGNERS=0x58CC3AE5C097b213cE3c81979e1B9f9570746AA5,0x025ceeba2ab2a27d53d963393999eeebe83dc4ae
149159
```

target_chains/ethereum/contracts/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ npm run deploy
6363
```
6464

6565
The deployment script will:
66+
6667
- Deploy the Wormhole contracts (Setup, Implementation, and Wormhole proxy)
6768
- Deploy the Pyth contracts (PythUpgradable with ERC1967 proxy)
6869
- Configure all necessary parameters from environment variables
@@ -90,6 +91,7 @@ GOVERNANCE_DATA=0x... npm run create-governance-vaa
9091
```
9192

9293
This script creates a properly signed governance VAA for local testing. You can customize it with environment variables:
94+
9395
- `TIMESTAMP` - VAA timestamp (defaults to current block timestamp)
9496
- `NONCE` - VAA nonce (defaults to 0)
9597
- `EMITTER_CHAIN_ID` - Chain ID of the emitter (defaults to 1)

target_chains/ethereum/contracts/script/CreateLocalnetGovernanceVaa.s.sol

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,33 @@ import "forge-std/console.sol";
66

77
contract CreateLocalnetGovernanceVaaScript is Script {
88
// Test signer private key (same as in the JS version)
9-
uint256 constant TEST_SIGNER_PK = 0xcfb12303a19cde580bb4dd771639b0d26bc68353645571a8cff516ab2ee113a0;
10-
9+
uint256 constant TEST_SIGNER_PK =
10+
0xcfb12303a19cde580bb4dd771639b0d26bc68353645571a8cff516ab2ee113a0;
11+
1112
uint16 constant TEST_GOVERNANCE_CHAIN = 1; // ethereum
12-
bytes32 constant TEST_GOVERNANCE_EMITTER = 0x0000000000000000000000000000000000000000000000000000000000001234;
13+
bytes32 constant TEST_GOVERNANCE_EMITTER =
14+
0x0000000000000000000000000000000000000000000000000000000000001234;
1315

1416
function run() external view {
15-
uint32 timestamp = uint32(vm.envOr("TIMESTAMP", uint256(block.timestamp)));
17+
uint32 timestamp = uint32(
18+
vm.envOr("TIMESTAMP", uint256(block.timestamp))
19+
);
1620
uint32 nonce = uint32(vm.envOr("NONCE", uint256(0)));
17-
uint16 emitterChainId = uint16(vm.envOr("EMITTER_CHAIN_ID", uint256(TEST_GOVERNANCE_CHAIN)));
18-
bytes32 emitterAddress = vm.envOr("EMITTER_ADDRESS", TEST_GOVERNANCE_EMITTER);
21+
uint16 emitterChainId = uint16(
22+
vm.envOr("EMITTER_CHAIN_ID", uint256(TEST_GOVERNANCE_CHAIN))
23+
);
24+
bytes32 emitterAddress = vm.envOr(
25+
"EMITTER_ADDRESS",
26+
TEST_GOVERNANCE_EMITTER
27+
);
1928
uint64 sequence = uint64(vm.envOr("SEQUENCE", uint256(0)));
2029
bytes memory data = vm.envBytes("GOVERNANCE_DATA");
21-
uint32 guardianSetIndex = uint32(vm.envOr("GUARDIAN_SET_INDEX", uint256(0)));
22-
uint8 consistencyLevel = uint8(vm.envOr("CONSISTENCY_LEVEL", uint256(32)));
30+
uint32 guardianSetIndex = uint32(
31+
vm.envOr("GUARDIAN_SET_INDEX", uint256(0))
32+
);
33+
uint8 consistencyLevel = uint8(
34+
vm.envOr("CONSISTENCY_LEVEL", uint256(32))
35+
);
2336

2437
console.log("Creating localnet governance VAA with parameters:");
2538
console.log("Timestamp:", timestamp);
@@ -44,25 +57,25 @@ contract CreateLocalnetGovernanceVaaScript is Script {
4457

4558
// Hash the body for signing
4659
bytes32 bodyHash = keccak256(abi.encodePacked(keccak256(body)));
47-
60+
4861
// Sign with test private key
4962
(uint8 v, bytes32 r, bytes32 s) = vm.sign(TEST_SIGNER_PK, bodyHash);
50-
63+
5164
// Create signature structure (guardian index 0, signature)
5265
bytes memory signature = abi.encodePacked(uint8(0), r, s, v);
53-
66+
5467
// Create complete VAA
5568
bytes memory vaa = abi.encodePacked(
56-
uint8(1), // version
57-
guardianSetIndex, // guardian set index
58-
uint8(1), // number of signatures
59-
signature, // signatures
60-
body // body
69+
uint8(1), // version
70+
guardianSetIndex, // guardian set index
71+
uint8(1), // number of signatures
72+
signature, // signatures
73+
body // body
6174
);
6275

6376
console.log("Generated VAA (hex):");
6477
console.logBytes(vaa);
65-
78+
6679
// Also log as a string for easy copying
6780
string memory vaaHex = vm.toString(vaa);
6881
console.log("VAA hex string:", vaaHex);

target_chains/ethereum/contracts/script/Deploy.s.sol

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ contract DeployScript is Script {
5959

6060
// Deploy Wormhole proxy
6161
Wormhole wormhole = new Wormhole(address(setup), initData);
62-
62+
6363
return address(wormhole);
6464
}
6565

@@ -69,8 +69,12 @@ contract DeployScript is Script {
6969
bytes32 pyth2WormholeEmitter = vm.envBytes32("SOLANA_EMITTER");
7070
uint16 governanceChainId = uint16(vm.envUint("GOVERNANCE_CHAIN_ID"));
7171
bytes32 governanceEmitter = vm.envBytes32("GOVERNANCE_EMITTER");
72-
uint64 governanceInitialSequence = uint64(vm.envOr("GOVERNANCE_INITIAL_SEQUENCE", uint256(0)));
73-
uint256 validTimePeriodSeconds = vm.envUint("VALID_TIME_PERIOD_SECONDS");
72+
uint64 governanceInitialSequence = uint64(
73+
vm.envOr("GOVERNANCE_INITIAL_SEQUENCE", uint256(0))
74+
);
75+
uint256 validTimePeriodSeconds = vm.envUint(
76+
"VALID_TIME_PERIOD_SECONDS"
77+
);
7478
uint256 singleUpdateFeeInWei = vm.envUint("SINGLE_UPDATE_FEE_IN_WEI");
7579

7680
console.log("pyth2WormholeChainId:", pyth2WormholeChainId);
@@ -83,12 +87,15 @@ contract DeployScript is Script {
8387

8488
// Deploy PythUpgradable implementation
8589
PythUpgradable pythImpl = new PythUpgradable();
86-
console.log("PythUpgradable implementation deployed at:", address(pythImpl));
90+
console.log(
91+
"PythUpgradable implementation deployed at:",
92+
address(pythImpl)
93+
);
8794

8895
// Prepare initialization data
8996
uint16[] memory dataSourceChainIds = new uint16[](1);
9097
dataSourceChainIds[0] = pyth2WormholeChainId;
91-
98+
9299
bytes32[] memory dataSourceEmitterAddresses = new bytes32[](1);
93100
dataSourceEmitterAddresses[0] = pyth2WormholeEmitter;
94101

@@ -105,9 +112,11 @@ contract DeployScript is Script {
105112
);
106113

107114
// Deploy ERC1967 proxy
108-
ERC1967Proxy pythProxy = new ERC1967Proxy(address(pythImpl), pythInitData);
109-
115+
ERC1967Proxy pythProxy = new ERC1967Proxy(
116+
address(pythImpl),
117+
pythInitData
118+
);
119+
110120
return address(pythProxy);
111121
}
112-
113122
}

target_chains/ethereum/contracts/script/SyncGuardianSets.s.sol

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@ contract SyncGuardianSetsScript is Script {
2020
function run() external {
2121
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
2222
address wormholeAddress = vm.envAddress("WORMHOLE_ADDRESS");
23-
23+
2424
vm.startBroadcast(deployerPrivateKey);
2525

26-
console.log("Syncing guardian sets for Wormhole contract at:", wormholeAddress);
27-
26+
console.log(
27+
"Syncing guardian sets for Wormhole contract at:",
28+
wormholeAddress
29+
);
30+
2831
// Get the current guardian set index before syncing
2932
IWormhole wormholeReader = IWormhole(wormholeAddress);
3033
Governance wormholeGov = Governance(wormholeAddress);
@@ -33,7 +36,12 @@ contract SyncGuardianSetsScript is Script {
3336

3437
// Submit each guardian set upgrade VAA starting from the current index
3538
for (uint i = initialIndex; i < MAINNET_UPGRADE_VAAS.length; i++) {
36-
console.log("Submitting guardian set upgrade VAA", i + 1, "of", MAINNET_UPGRADE_VAAS.length);
39+
console.log(
40+
"Submitting guardian set upgrade VAA",
41+
i + 1,
42+
"of",
43+
MAINNET_UPGRADE_VAAS.length
44+
);
3745
bytes memory vaaBytes = vm.parseBytes(MAINNET_UPGRADE_VAAS[i]);
3846
wormholeGov.submitNewGuardianSet(vaaBytes);
3947
console.log("Successfully submitted VAA", i + 1);
@@ -42,13 +50,18 @@ contract SyncGuardianSetsScript is Script {
4250
// Check the final guardian set index
4351
uint32 finalIndex = wormholeReader.getCurrentGuardianSetIndex();
4452
console.log("Final guardian set index:", finalIndex);
45-
53+
4654
if (finalIndex > initialIndex) {
47-
console.log("Successfully updated guardian set from index", initialIndex, "to", finalIndex);
55+
console.log(
56+
"Successfully updated guardian set from index",
57+
initialIndex,
58+
"to",
59+
finalIndex
60+
);
4861
} else {
4962
console.log("Guardian set was already up to date");
5063
}
5164

5265
vm.stopBroadcast();
5366
}
54-
}
67+
}

target_chains/ethereum/contracts/script/utils/VaaUtils.sol

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,54 +9,59 @@ library VaaUtils {
99
* @param vaaBytes The VAA bytes to check
1010
* @param expectedPayload The expected payload bytes
1111
*/
12-
function assertVaaPayloadEquals(bytes memory vaaBytes, bytes memory expectedPayload) internal pure {
12+
function assertVaaPayloadEquals(
13+
bytes memory vaaBytes,
14+
bytes memory expectedPayload
15+
) internal pure {
1316
// VAA structure: version (1) + guardianSetIndex (4) + signaturesLength (1) + signatures + body
1417
// Body structure: timestamp (4) + nonce (4) + emitterChainId (2) + emitterAddress (32) + sequence (8) + consistencyLevel (1) + payload
15-
18+
1619
require(vaaBytes.length >= 51, "VAA too short"); // Minimum VAA length
17-
20+
1821
uint256 offset = 6; // Skip version (1) + guardianSetIndex (4) + signaturesLength (1)
19-
22+
2023
// Skip signatures (each signature is 66 bytes: guardianIndex (1) + r (32) + s (32) + v (1))
2124
uint8 signaturesLength = uint8(vaaBytes[5]);
2225
offset += signaturesLength * 66;
23-
26+
2427
// Skip to payload (skip timestamp (4) + nonce (4) + emitterChainId (2) + emitterAddress (32) + sequence (8) + consistencyLevel (1))
2528
offset += 51;
26-
29+
2730
require(offset < vaaBytes.length, "Invalid VAA structure");
28-
31+
2932
// Extract payload
3033
bytes memory actualPayload = new bytes(vaaBytes.length - offset);
3134
for (uint256 i = 0; i < actualPayload.length; i++) {
3235
actualPayload[i] = vaaBytes[offset + i];
3336
}
34-
37+
3538
require(
3639
keccak256(actualPayload) == keccak256(expectedPayload),
3740
"VAA payload does not match expected payload"
3841
);
3942
}
40-
43+
4144
/**
4245
* @dev Extract payload from VAA bytes
4346
* @param vaaBytes The VAA bytes
4447
* @return payload The extracted payload
4548
*/
46-
function extractPayload(bytes memory vaaBytes) internal pure returns (bytes memory payload) {
49+
function extractPayload(
50+
bytes memory vaaBytes
51+
) internal pure returns (bytes memory payload) {
4752
require(vaaBytes.length >= 51, "VAA too short");
48-
53+
4954
uint256 offset = 6; // Skip version (1) + guardianSetIndex (4) + signaturesLength (1)
50-
55+
5156
// Skip signatures
5257
uint8 signaturesLength = uint8(vaaBytes[5]);
5358
offset += signaturesLength * 66;
54-
59+
5560
// Skip to payload
5661
offset += 51;
57-
62+
5863
require(offset < vaaBytes.length, "Invalid VAA structure");
59-
64+
6065
payload = new bytes(vaaBytes.length - offset);
6166
for (uint256 i = 0; i < payload.length; i++) {
6267
payload[i] = vaaBytes[offset + i];

0 commit comments

Comments
 (0)