-
Notifications
You must be signed in to change notification settings - Fork 29
Feat/syn bridge unified [SYN-91] #334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
f621f30
3b7545d
2cde3ea
20b104d
285d915
f778571
e9bb701
189b72e
acbcaa8
0f34b97
3407298
84491d9
2d66d69
c314e1d
f9cda06
880b817
82828e5
85d9566
bd94918
f63c26d
ec6948b
4616c2f
2b5e00a
c35907c
18b7fe9
b7fb369
a67c932
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.6.12; | ||
pragma experimental ABIEncoderV2; | ||
|
||
import {SynapseBridge} from "../../contracts/bridge/SynapseBridge.sol"; | ||
|
||
import {BasicSynapseScript, StringUtils} from "../templates/BasicSynapse.s.sol"; | ||
|
||
contract DeploySynapseBridge is BasicSynapseScript { | ||
using StringUtils for string; | ||
|
||
// TODO: mine a create2 salt for this | ||
bytes32 internal salt = 0; | ||
|
||
function run() external { | ||
// Setup the BasicSynapseScript | ||
setUp(); | ||
address bridge = tryGetDeploymentAddress("SynapseBridge"); | ||
if (bridge == address(0)) { | ||
printLog(StringUtils.concat("🟡 Skipping: SynapseBridge is not deployed on ", activeChain)); | ||
return; | ||
} | ||
vm.startBroadcast(); | ||
address predicted = predictAddress(type(SynapseBridge).creationCode, salt); | ||
printLog(StringUtils.concat("Predicted address: ", vm.toString(predicted))); | ||
address deployed = deployAndSaveAs({ | ||
contractName: "SynapseBridge", | ||
contractAlias: "SynapseBridge.Implementation", | ||
constructorArgs: "", | ||
deployCode: deployCreate2 | ||
}); | ||
if (predicted != deployed) { | ||
printLog(TAB.concat("❌ Predicted address mismatch")); | ||
assert(false); | ||
} | ||
vm.stopBroadcast(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
# This script deploys the SynapseBridge implementation on all chains | ||
# Usage: ./script/bridge/deploy-implementation.sh <walletName> [<args...>] | ||
# - <walletName> name of the wallet to use for deployment | ||
|
||
# Colors | ||
RED="\033[0;31m" | ||
NC="\033[0m" # No Color | ||
|
||
WALLET_NAME=$1 | ||
# Get the rest of the args | ||
shift 1 | ||
# Check that all required args exist | ||
if [ -z "$WALLET_NAME" ]; then | ||
echo -e "${RED}Usage: ./script/bridge/deploy-implementation.sh <walletName> [<args...>]${NC}" | ||
exit 1 | ||
fi | ||
|
||
# Make sure the script is run from the root of the project | ||
PROJECT_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../../ && pwd) | ||
cd "$PROJECT_ROOT" || exit 1 | ||
|
||
# Run the script on all chains with SynapseBridge deployment | ||
# Look within deployments/chainName for SynapseBridge.json | ||
for chainName in $(ls deployments); do | ||
if [ -f "deployments/$chainName/SynapseBridge.json" ]; then | ||
./script/run.sh ./script/bridge/DeploySynapseBridge.s.sol "$chainName" "$WALLET_NAME" "$@" | ||
fi | ||
done | ||
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -275,11 +275,11 @@ abstract contract BasicUtils is CommonBase { | |||||||||||||||||||||||||||
string memory pathOutput, | ||||||||||||||||||||||||||||
string memory key | ||||||||||||||||||||||||||||
) internal returns (string memory fullInputData) { | ||||||||||||||||||||||||||||
// Example: jq .abi=$data.abi --argfile data path/to/input.json path/to/output.json | ||||||||||||||||||||||||||||
// Example: jq .abi=$data[0].abi --slurpfile data path/to/input.json path/to/output.json | ||||||||||||||||||||||||||||
string[] memory inputs = new string[](6); | ||||||||||||||||||||||||||||
inputs[0] = "jq"; | ||||||||||||||||||||||||||||
inputs[1] = key.concat(" = $data", key); | ||||||||||||||||||||||||||||
inputs[2] = "--argfile"; | ||||||||||||||||||||||||||||
inputs[1] = key.concat(" = $data[0]", key); | ||||||||||||||||||||||||||||
inputs[2] = "--slurpfile"; | ||||||||||||||||||||||||||||
Comment on lines
+278
to
+282
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainVerify the JSON structure change is consistent across the codebase. The change from 🏁 Script executed: #!/bin/bash
# Verify usage of addJsonKey function and related JSON processing
rg -A 3 -B 3 "addJsonKey|--argfile|--slurpfile" --type sol --type sh Length of output: 98 To ensure we capture all occurrences regardless of file-type mappings, let’s drop the 🏁 Script executed: #!/bin/bash
# Search for JSON key helper usage and jq flags across Solidity and shell scripts
rg -A3 -B3 "addJsonKey|--argfile|--slurpfile" -g '*.sol' -g '*.sh' Length of output: 2567 Inconsistent jq flag usage in The helper in • File: --- a/script/utils/DeployScript.sol
@@ (inside function that builds jq inputs)
- inputs[1] = "--argfile";
+ inputs[1] = "--slurpfile";
inputs[2] = "artifact";
inputs[3] = _artifactPath(contractName);
- inputs[4] = ".abi = $artifact.abi";
+ inputs[4] = ".abi = $artifact[0].abi";
inputs[5] = path; This aligns both scripts to handle the input JSON as an array. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||
inputs[3] = "data"; | ||||||||||||||||||||||||||||
inputs[4] = pathInput; | ||||||||||||||||||||||||||||
inputs[5] = pathOutput; | ||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.6.12; | ||
|
||
// solhint-disable no-empty-blocks, no-unused-vars | ||
contract PoolMock { | ||
/// @notice We include an empty "test" function so that this contract does not appear in the coverage report. | ||
function testPoolMock() external {} | ||
|
||
function calculateSwap( | ||
uint8 tokenIndexFrom, | ||
uint8 tokenIndexTo, | ||
uint256 amount | ||
) external returns (uint256) {} | ||
|
||
function calculateRemoveLiquidityOneToken(uint256 tokenAmount, uint8 tokenIndex) external returns (uint256) {} | ||
} | ||
ChiTimesChi marked this conversation as resolved.
Show resolved
Hide resolved
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Fix: Use robust iteration pattern instead of
ls
output.The current approach of iterating over
ls
output can be fragile with filenames containing spaces or special characters.📝 Committable suggestion
🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 25-25: Iterating over ls output is fragile. Use globs.
(SC2045)
🤖 Prompt for AI Agents