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

Feature/artifacts for fe deployment #536

Open
wants to merge 13 commits into
base: eth-rollup-develop
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "utils/frontend/contracts.sol/lib/forge-std"]
path = utils/frontend/contracts.sol/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "utils/frontend/contracts.sol/lib/openzeppelin-contracts"]
path = utils/frontend/contracts.sol/lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
6 changes: 5 additions & 1 deletion cliTool/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import {
getPolkAddress,
create10sequencers,
closeL1Item,
sendUpdateToL1,
sendUpdateToL1, calculateBuyPrice
} from "../utils/setupsOnTheGo";
import {
findErrorMetadata,
Expand Down Expand Up @@ -135,10 +135,14 @@ async function app(): Promise<any> {
"Close All L1 items",
"1000 withdrawals",
"sync updates",
"calculateBuyPrice",
],
})
.then(async (answers: { option: string | string[] }) => {
console.log("Answers::: " + JSON.stringify(answers, null, " "));
if (answers.option.includes("calculateBuyPrice")){
await calculateBuyPrice();
}
if (answers.option.includes("sync updates")) {
await sendUpdateToL1();
}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
"ethers": "^5.4.7",
"exec-sh": "^0.4.0",
"express": "^4.18.2",
"gasp-sdk": "0.0.2-feature-rolldown-on-idle-hook.0",
"gasp-types": "0.0.2-feature-rolldown-on-idle-hook.0",
"gasp-sdk": "0.0.2-feature-stable-pool-mgx-1307.18",
"gasp-types": "0.0.2-feature-stable-pool-mgx-1307.24",
"get-port-please": "^3.0.1",
"guid-typescript": "^1.0.9",
"jest-docblock": "^29.7.0",
Expand Down
14 changes: 14 additions & 0 deletions utils/frontend/contracts.sol/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Compiler files
cache/
out/

# Ignores development broadcast logs
!/broadcast
/broadcast/*/31337/
/broadcast/**/dry-run/

# Docs
docs/

# Dotenv file
.env
77 changes: 77 additions & 0 deletions utils/frontend/contracts.sol/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
## Foundry

**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.**

Foundry consists of:

- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools).
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network.
- **Chisel**: Fast, utilitarian, and verbose solidity REPL.

## Documentation

https://book.getfoundry.sh/

## Usage

### Build

```shell
$ forge build
```

### Test

```shell
$ forge test
```

### Format

```shell
$ forge fmt
```

### Gas Snapshots

```shell
$ forge snapshot
```

### Anvil

```shell
$ anvil
```

### Deploy

```shell
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>
```

### Cast

```shell
$ cast <subcommand>
```

### Help

```shell
$ forge --help
$ anvil --help
$ cast --help
```


# Howto
foundryup

forge install OpenZeppelin/openzeppelin-contracts

forge build

export PRIVATE_KEY=0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97 ; forge script --rpc-url=https://evm-node-arb-frontend.gasp.xyz script/deploycontracts.sol --broadcast

8 changes: 8 additions & 0 deletions utils/frontend/contracts.sol/foundry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[profile.default]
src = "src"
out = "out"
libs = ["lib"]

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
[remappings]
openzeppelin-contracts="lib/openzeppelin-contracts"
1 change: 1 addition & 0 deletions utils/frontend/contracts.sol/lib/forge-std
Submodule forge-std added at 1eea5b
1 change: 1 addition & 0 deletions utils/frontend/contracts.sol/lib/openzeppelin-contracts
Submodule openzeppelin-contracts added at 69c8de
20 changes: 20 additions & 0 deletions utils/frontend/contracts.sol/script/deploycontracts.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "forge-std/Script.sol";
import {USDC} from "../src/USDC.sol";

contract DeployTokens is Script {
function run() external {
// Fetch the deployer's private key from environment variables
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");

// Start broadcast for transactions
vm.startBroadcast(deployerPrivateKey);

// Deploy TestERC20
USDC testERC20 = new USDC("Test USDC", "USDC");
console.log("USDC deployed to:", address(testERC20));

vm.stopBroadcast();
}
}
22 changes: 22 additions & 0 deletions utils/frontend/contracts.sol/src/USDC.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract USDC is ERC20 {
constructor(
string memory name,
string memory symbol
) ERC20(name, symbol) {
// Mint initial tokens
_mint(msg.sender, 1_000_000_000 * 10**decimals());
}

function decimals() public pure override returns (uint8) {
return 6;
}

function mint(address to, uint256 amount) external {
_mint(to, amount);
}
}
10 changes: 10 additions & 0 deletions utils/setupsOnTheGo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ export async function setupPoolWithRewardsForDefaultUsers() {
amount.divn(10),
token2,
amount.divn(10),
"Xyk",
),
),
);
Expand Down Expand Up @@ -475,6 +476,15 @@ export async function setupTokenWithRewardsForDefaultUsers() {
return { users, liqId, sudo, token2 };
}

export async function calculateBuyPrice() {
await setupUsers();
await setupApi();
const api = await getApi();
//@ts-ignore
const value = await api.rpc.market.get_pools(3);
//@ts-ignore
testLog.getLog().info(JSON.stringify(value.toHuman()));
}
export async function printAllTxsDoneByUser(userAddress: string) {
await setupUsers();
await setupApi();
Expand Down
26 changes: 13 additions & 13 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9559,27 +9559,27 @@ ganache@7.9.1:
bufferutil "4.0.5"
utf-8-validate "5.0.7"

gasp-sdk@0.0.2-feature-rolldown-on-idle-hook.0:
version "0.0.2-feature-rolldown-on-idle-hook.0"
resolved "https://registry.yarnpkg.com/gasp-sdk/-/gasp-sdk-0.0.2-feature-rolldown-on-idle-hook.0.tgz#17693211576b6a679df72dbedae12abfeb23a2a6"
integrity sha512-h08qiBKXhDgrGWojgepdOAk+Lumaq/EEro1KAlFhf+MfR+fHzH1Mm8UVONUrN2Xp/xmaVUam/0HBoLcNo+Q03A==
gasp-sdk@0.0.2-feature-stable-pool-mgx-1307.18:
version "0.0.2-feature-stable-pool-mgx-1307.18"
resolved "https://registry.yarnpkg.com/gasp-sdk/-/gasp-sdk-0.0.2-feature-stable-pool-mgx-1307.18.tgz#7e576c7ca5255ac53d492ee4a7e8ff5801785285"
integrity sha512-7RHw82pBQ2FR1Cybg2bXDbupRBZz+EV7SYgcGAK8F568rhWX3maiYQH34L4OoGHAtWo/LCrnZtpZObbo/bez8g==
dependencies:
big.js "6.2.1"
gasp-type-definitions "0.0.2-feature-rolldown-on-idle-hook.0"
gasp-type-definitions "0.0.2-feature-stable-pool-mgx-1307.24"
tslib "^2.3.0"
tslog "4.8.2"
viem "^2.17.4"
wagmi "^2.10.10"

gasp-type-definitions@0.0.2-feature-rolldown-on-idle-hook.0:
version "0.0.2-feature-rolldown-on-idle-hook.0"
resolved "https://registry.yarnpkg.com/gasp-type-definitions/-/gasp-type-definitions-0.0.2-feature-rolldown-on-idle-hook.0.tgz#823400703966ac0042c3e2017877810e1fbb4269"
integrity sha512-unRXCS2OUbeSSzYSKWeVpTcyEoZq8/TB+Fb7JaNO+CQ+kVOghEjatHhUtfzxkkBjdpCnB8BprLmgZm9pVLU4Sw==
gasp-type-definitions@0.0.2-feature-stable-pool-mgx-1307.24:
version "0.0.2-feature-stable-pool-mgx-1307.24"
resolved "https://registry.yarnpkg.com/gasp-type-definitions/-/gasp-type-definitions-0.0.2-feature-stable-pool-mgx-1307.24.tgz#9b227cc62ae5625dd11e250db336133f6d86edb4"
integrity sha512-AFgQMA7CsIB2K8zFyVseHKEVXlrWhtMNikLfHF15dfxP23uApnd7mMR72WKv7qYBMuxCGFI05QdatGgGQigxDA==

gasp-types@0.0.2-feature-rolldown-on-idle-hook.0:
version "0.0.2-feature-rolldown-on-idle-hook.0"
resolved "https://registry.yarnpkg.com/gasp-types/-/gasp-types-0.0.2-feature-rolldown-on-idle-hook.0.tgz#6952414f82bb2bece10a8e26f104682cf8d04145"
integrity sha512-P0VFssv/HGfJuRu9biW2DRQv2fHjc0E0L3B6M8dS2741J24ZBPi3MlCkgXQeYVyNjXT7SAdt53qZeES7CUQLug==
gasp-types@0.0.2-feature-stable-pool-mgx-1307.24:
version "0.0.2-feature-stable-pool-mgx-1307.24"
resolved "https://registry.yarnpkg.com/gasp-types/-/gasp-types-0.0.2-feature-stable-pool-mgx-1307.24.tgz#6cbf4ff7dd71460b3525c8632f2c832bfb52f165"
integrity sha512-86iMzX4ZiyxwdNAriljIqQLYmvyO4beczY+QKrqYW6k309EEp9P39VZYzWmKPKhjpF+5n2x2n2iXmXnywjKK3g==

gauge@^4.0.3:
version "4.0.4"
Expand Down