Skip to content
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

Try run and improve project #1

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = true

[*.md]
max_line_length = 80

2 changes: 1 addition & 1 deletion .github/workflows/sphinx.automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
# - name: Install Sphinx Solidity Library
# run: yarn sphinx install
# - name: Propose
# run: npx sphinx propose ./script/common/Automation.s.sol --confirm --networks mainnets
# run: npx sphinx propose ./src/common/Automation.s.sol --confirm --networks mainnets
2 changes: 1 addition & 1 deletion .github/workflows/sphinx.dry-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ jobs:
- name: Install Sphinx Solidity Library
run: yarn sphinx install
- name: Dry Run
run: npx sphinx propose ./script/common/Automation.s.sol --dry-run --networks mainnets
run: npx sphinx propose ./src/common/Automation.s.sol --dry-run --networks mainnets
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ out/
# Node
node_modules/
dist/

*.local.*
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ all :; @forge build
fmt :; @forge fmt
clean :; @forge clean

propose:; npx sphinx propose ./script/common/Automation.s.sol --networks mainnets
dry-run:; npx sphinx propose ./script/common/Automation.s.sol --networks mainnets --dry-run
propose:; npx sphinx propose ./src/common/Automation.s.sol --networks mainnets
dry-run:; npx sphinx propose ./src/common/Automation.s.sol --networks mainnets --dry-run

sphinx :; @yarn sphinx install
sync :; @git submodule update --recursive
Expand Down
6 changes: 4 additions & 2 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ solc_version = "0.8.17"
script = 'script'
test = 'test'
extra_output = ['storageLayout']
fs_permissions=[{access="read", path="./out"}, {access="read-write", path="./cache"}]
fs_permissions = [{ access = "read", path = "./out" }, { access = "read-write", path = "./cache" }]
allow_paths = ["../.."]
auto_detect_remappings = false
libs = ["lib"]

[rpc_endpoints]
anvil = "http://127.0.0.1:8545"
polygon = "https://polygon-rpc.com"
optimism = "https://rpc.ankr.com/optimism "
optimism = "https://rpc.ankr.com/optimism"
arbitrum = "https://arb1.arbitrum.io/rpc"
darwinia = "https://rpc.darwinia.network"
ethereum = "https://ethereum-rpc.publicnode.com"
12 changes: 0 additions & 12 deletions script/1_Action.s.sol

This file was deleted.

15 changes: 0 additions & 15 deletions script/common/Base.sol

This file was deleted.

28 changes: 28 additions & 0 deletions src/1_Action.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {Base} from "./common/Base.sol";
import {ScriptTools} from "./helpers/ScriptTools.sol";
import {stdToml} from "forge-std/StdToml.sol";

interface III {}

contract Action1 is Base {

function setUp() public {
string memory config = ScriptTools.loadConfig();
init(local, config);
}

function init(uint256 local, string memory config) public override {

}

function run() public sphinx {
registerLnv3();
}

function registerLnv3() internal {
// revert('==========================================');
}
}
File renamed without changes.
27 changes: 27 additions & 0 deletions src/common/Base.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {Script} from "forge-std/Script.sol";
import {stdToml} from "forge-std/StdToml.sol";
import "@sphinx-labs/contracts/SphinxPlugin.sol";

contract Base is Sphinx, Script {
using stdToml for string;

function configureSphinx() public override {
sphinxConfig.owners = [
0x570FCA2c6f902949dBb90664Be5680fEc94A84f6, // jane
0xC5a809900B5BFb46B1B3892e419e69331B8FBC6c, // perror
0x3f63bCe51d3C6665BfE919816780a2109D42238d // fewensa
];
sphinxConfig.orgId = 'cluanacaw000111jik4xs4wkl';
sphinxConfig.threshold = 2;
sphinxConfig.projectName = 'Relayer-Automation';
sphinxConfig.mainnets = [
// 'darwinia',
// 'polygon',
'arbitrum'
];
}

}
13 changes: 13 additions & 0 deletions src/config/LnBridgeRegisterConfig.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {VmSafe} from "forge-std/Vm.sol";
import {stdToml} from "forge-std/StdToml.sol";

contract LnBridgeRegisterConfig {
using stdToml for string;

VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256("hevm cheat code")))));


}
125 changes: 125 additions & 0 deletions src/helpers/ScriptTools.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;

import {VmSafe} from "forge-std/Vm.sol";
import {stdToml} from "forge-std/StdToml.sol";

/// @title Script Tools
/// @dev Contains opinionated tools used in scripts.
library ScriptTools {
VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256("hevm cheat code")))));

string internal constant DEFAULT_DELIMITER = ",";
string internal constant DELIMITER_OVERRIDE = "DSSTEST_ARRAY_DELIMITER";

function readInput() internal view returns (string memory) {
string memory root = vm.projectRoot();
return readInput(root, name);
}

function readInput(string memory root) internal view returns (string memory) {
return vm.readFile(string.concat(root, "/script/input/register.toml"));
}

function loadConfig() internal view returns (string memory config) {
config = readInput();
}

function eq(string memory a, string memory b) internal pure returns (bool) {
return keccak256(bytes(a)) == keccak256(bytes(b));
}

// Read config variable, but allow for an environment variable override

function readUint(string memory json, string memory key, string memory envKey) internal view returns (uint256) {
return vm.envOr(envKey, stdToml.readUint(json, key));
}

function readUintArray(string memory json, string memory key, string memory envKey)
internal
view
returns (uint256[] memory)
{
return vm.envOr(envKey, vm.envOr(DELIMITER_OVERRIDE, DEFAULT_DELIMITER), stdToml.readUintArray(json, key));
}

function readInt(string memory json, string memory key, string memory envKey) internal view returns (int256) {
return vm.envOr(envKey, stdToml.readInt(json, key));
}

function readIntArray(string memory json, string memory key, string memory envKey)
internal
view
returns (int256[] memory)
{
return vm.envOr(envKey, vm.envOr(DELIMITER_OVERRIDE, DEFAULT_DELIMITER), stdToml.readIntArray(json, key));
}

function readBytes32(string memory json, string memory key, string memory envKey) internal view returns (bytes32) {
return vm.envOr(envKey, stdToml.readBytes32(json, key));
}

function readBytes32Array(string memory json, string memory key, string memory envKey)
internal
view
returns (bytes32[] memory)
{
return vm.envOr(envKey, vm.envOr(DELIMITER_OVERRIDE, DEFAULT_DELIMITER), stdToml.readBytes32Array(json, key));
}

function readString(string memory json, string memory key, string memory envKey)
internal
view
returns (string memory)
{
return vm.envOr(envKey, stdToml.readString(json, key));
}

function readStringArray(string memory json, string memory key, string memory envKey)
internal
view
returns (string[] memory)
{
return vm.envOr(envKey, vm.envOr(DELIMITER_OVERRIDE, DEFAULT_DELIMITER), stdToml.readStringArray(json, key));
}

function readAddress(string memory json, string memory key, string memory envKey) internal view returns (address) {
return vm.envOr(envKey, stdToml.readAddress(json, key));
}

function readAddressArray(string memory json, string memory key, string memory envKey)
internal
view
returns (address[] memory)
{
return vm.envOr(envKey, vm.envOr(DELIMITER_OVERRIDE, DEFAULT_DELIMITER), stdToml.readAddressArray(json, key));
}

function readBool(string memory json, string memory key, string memory envKey) internal view returns (bool) {
return vm.envOr(envKey, stdToml.readBool(json, key));
}

function readBoolArray(string memory json, string memory key, string memory envKey)
internal
view
returns (bool[] memory)
{
return vm.envOr(envKey, vm.envOr(DELIMITER_OVERRIDE, DEFAULT_DELIMITER), stdToml.readBoolArray(json, key));
}

function readBytes(string memory json, string memory key, string memory envKey)
internal
view
returns (bytes memory)
{
return vm.envOr(envKey, stdToml.readBytes(json, key));
}

function readBytesArray(string memory json, string memory key, string memory envKey)
internal
view
returns (bytes[] memory)
{
return vm.envOr(envKey, vm.envOr(DELIMITER_OVERRIDE, DEFAULT_DELIMITER), stdToml.readBytesArray(json, key));
}
}
31 changes: 31 additions & 0 deletions src/input/register.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

[[registers]]
bridge = "arbitrum->polygon"
symbol = "usdt"
type = "lnv3"
contract = "0xbA5D580B18b6436411562981e02c8A9aA1776D10"
sourceTokenAddress = "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"
targetTokenAddress = "0xc2132d05d31c914a87c6611c10748aeb04b58e8f"
baseFee = 0.1
liquidityFeeRate = 0.1
transferLimit = 2_000
deposit = 30
approve = 10_000_000_000_000
safeWalletAddress = "0x000000000Bb6a011dB294ce3F3423f00EAc4959e"
sourceSafeWalletUrl = "https://safe-transaction-arbitrum.safe.global/api"

[[registers]]
bridge = "polygon->arbitrum"
symbol = "usdt"
type = "lnv3"
contract = "0xbA5D580B18b6436411562981e02c8A9aA1776D10"
sourceTokenAddress = "0xc2132d05d31c914a87c6611c10748aeb04b58e8f"
targetTokenAddress = "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"
baseFee = 0.1
liquidityFeeRate = 0.1
transferLimit = 2_000
deposit = 30
approve = 10_000_000_000_000
safeWalletAddress = "0x000000000Bb6a011dB294ce3F3423f00EAc4959e"
sourceSafeWalletUrl = "https://safe-transaction-polygon.safe.global/api"

Loading