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

Update/core contract v13.2.0 #4

Merged
merged 24 commits into from
Dec 3, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
feat : updated starknet contract build
ocdbytes committed Nov 24, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit d7178f722db649ede30b82923ebe78b563f5cd14
16 changes: 13 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -3,12 +3,12 @@
# Moreover, any project using sandbox as dependency won't build unless
# there's Foundry installed on the machine.

.PHONY: artifacts cairo-lang local-contracts starkgate-contracts-latest starkgate-contracts-old
.PHONY: pilt-over cairo-lang local-contracts starkgate-contracts-latest starkgate-contracts-old l2-artifacts

CAIRO_LANG_COMMIT_HASH="8e11b8cc65ae1d0959328b1b4a40b92df8b58595"
STARKGATE_CONTRACTS_COMMIT_HASH="45941888479663ac93e898cd7f8504fa9066c54c"

artifacts:
pilt-over:
mkdir crates/starknet-proxy-client/src/artifacts || true
mkdir crates/starknet-core-contract-client/src/artifacts || true
forge build
@@ -45,7 +45,6 @@ starkgate-contracts-latest:
./scripts/extract_artifacts.py
# Copying Contracts :
mkdir -p artifacts/starkgate-contracts
cp lib/starkgate-contracts/artifacts/LegacyBridge.json artifacts/starkgate-contracts/LegacyBridge.json
cp lib/starkgate-contracts/artifacts/StarkgateManager.json artifacts/starkgate-contracts/StarkgateManager.json
cp lib/starkgate-contracts/artifacts/StarkgateRegistry.json artifacts/starkgate-contracts/StarkgateRegistry.json
cp lib/starkgate-contracts/artifacts/Proxy.json artifacts/starkgate-contracts/Proxy_5_0_0.json
@@ -57,8 +56,19 @@ starkgate-contracts-old:
solc-select install 0.6.12 && solc-select use 0.6.12
# Building
cp build-artifacts/starkgate-contracts-0.9/foundry.toml lib/starkgate-contracts-0.9/src/starkware/solidity/foundry.toml
cp build-artifacts/starkgate-contracts-0.9/foundry2.toml lib/starkgate-contracts-0.9/src/starkware/foundry.toml
cd lib/starkgate-contracts-0.9/src/starkware/solidity && \
forge build
cd lib/starkgate-contracts-0.9/src/starkware && \
forge build
# Copying Contracts :
mkdir -p artifacts/starkgate-contracts-0.9
cp lib/starkgate-contracts-0.9/src/starkware/solidity/out/Proxy.sol/Proxy.json artifacts/starkgate-contracts-0.9/Proxy_3_0_2.json
cp lib/starkgate-contracts-0.9/src/starkware/out/StarknetEthBridge.sol/StarknetEthBridge.json artifacts/starkgate-contracts-0.9/LegacyBridge.json

l2-artifacts:
make cairo-lang
make local-contracts
make starkgate-contracts-latest
make starkgate-contracts-old
echo "L2 Artifacts built ✅"
10 changes: 10 additions & 0 deletions build-artifacts/starkgate-contracts-0.9/foundry2.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[profile.default]
src = "./starknet"
out = "out"
libs = ["lib"]
solc = "0.6.12"
remappings = [
"contracts/starkware/solidity=./solidity",
"contracts/starkware/starknet=./starknet",
"contracts/starkware/cairo=./cairo"
]
30 changes: 21 additions & 9 deletions crates/l2/starknet-eth-bridge-client/src/interfaces/eth_bridge.rs
Original file line number Diff line number Diff line change
@@ -13,24 +13,25 @@ type Address = H160;

abigen!(
StarknetEthBridge,
"../../../artifacts/starkgate-contracts/LegacyBridge.json",
"../../../artifacts/starkgate-contracts-0.9/LegacyBridge.json",
);

#[async_trait]
pub trait StarknetEthBridgeTrait<M: Middleware> {
async fn set_max_total_balance(
&self,
address: Address,
max_total_balance: U256,
) -> Result<Option<TransactionReceipt>, Error<M>>;

async fn set_max_deposit(
&self,
max_deposit: U256,
) -> Result<Option<TransactionReceipt>, Error<M>>;
async fn set_l2_token_bridge(
&self,
l2_token_bridge: U256,
) -> Result<Option<TransactionReceipt>, Error<M>>;
async fn deposit(
&self,
amount: U256,
l2_recipient: U256,
fee: U256,
) -> Result<Option<TransactionReceipt>, Error<M>>;
@@ -49,11 +50,23 @@ where
{
async fn set_max_total_balance(
&self,
address: Address,
max_total_balance: U256,
) -> Result<Option<TransactionReceipt>, Error<M>> {
self.as_ref()
.set_max_total_balance(address, max_total_balance)
.set_max_total_balance(max_total_balance)
.send()
.await
.map_err(Into::<ContractError<M>>::into)?
.await
.map_err(Into::into)
}

async fn set_max_deposit(
&self,
max_deposit: U256,
) -> Result<Option<TransactionReceipt>, Error<M>> {
self.as_ref()
.set_max_deposit(max_deposit)
.send()
.await
.map_err(Into::<ContractError<M>>::into)?
@@ -76,12 +89,11 @@ where

async fn deposit(
&self,
amount: U256,
l2_recipient: U256,
fee: U256,
) -> Result<Option<TransactionReceipt>, Error<M>> {
self.as_ref()
.deposit(amount, l2_recipient)
.deposit(l2_recipient)
.value(fee)
.send()
.await
@@ -96,7 +108,7 @@ where
l1_recipient: Address,
) -> Result<Option<TransactionReceipt>, Error<M>> {
self.as_ref()
.withdraw_1(amount, l1_recipient)
.withdraw(amount, l1_recipient)
.send()
.await
.map_err(Into::<ContractError<M>>::into)?
2 changes: 1 addition & 1 deletion crates/l2/starknet-eth-bridge-client/src/lib.rs
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ pub mod clients;
pub mod interfaces;

const STARKNET_ETH_BRIDGE: &str =
include_str!("../../../../artifacts/starkgate-contracts/LegacyBridge.json");
include_str!("../../../../artifacts/starkgate-contracts-0.9/LegacyBridge.json");

pub async fn deploy_starknet_eth_bridge_behind_unsafe_proxy(
client: Arc<LocalWalletSignerMiddleware>,
1 change: 0 additions & 1 deletion crates/l2/starknet-proxy-client/src/deploy.rs
Original file line number Diff line number Diff line change
@@ -30,7 +30,6 @@ pub enum Error {
}

const UNSAFE_PROXY: &str = include_str!("../../../../artifacts/UnsafeProxy.json");
// TODO : find the contract in repos
const SAFE_PROXY_3_0_2: &str =
include_str!("../../../../artifacts/starkgate-contracts-0.9/Proxy_3_0_2.json");
const SAFE_PROXY_5_0_0: &str =