Skip to content

Commit

Permalink
Merge pull request #1 from karnotxyz/enroll-token
Browse files Browse the repository at this point in the history
Enroll token
  • Loading branch information
apoorvsadana authored Jul 30, 2024
2 parents 9735743 + c84b86f commit 20dab01
Show file tree
Hide file tree
Showing 17 changed files with 1,262 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
target
.DS_Store
.snfoundry_cache/
2 changes: 2 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
scarb 2.6.5
starknet-foundry 0.26.0
29 changes: 29 additions & 0 deletions Scarb.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Code generated by scarb DO NOT EDIT.
version = 1

[[package]]
name = "openzeppelin"
version = "0.14.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.14.0#f091c4f51ddeb10297db984acae965328c5a4e5b"

[[package]]
name = "piltover"
version = "0.1.0"
source = "git+https://github.com/byteZorvin/piltover?branch=bridge-testing#a4021a0bb5e1638e3aebf634f5810ebb17da6a38"
dependencies = [
"openzeppelin",
]

[[package]]
name = "snforge_std"
version = "0.26.0"
source = "git+https://github.com/foundry-rs/starknet-foundry?tag=v0.26.0#50eb589db65e113efe4f09241feb59b574228c7e"

[[package]]
name = "starknet_bridge"
version = "0.1.0"
dependencies = [
"openzeppelin",
"piltover",
"snforge_std",
]
21 changes: 21 additions & 0 deletions Scarb.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "starknet_bridge"
version = "0.1.0"
edition = "2023_11"

# See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html

[dependencies]
openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v0.14.0" }
starknet = "2.6.4"
piltover = { git = "https://github.com/byteZorvin/piltover", branch="bridge-testing"}

[dev-dependencies]
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry", tag = "v0.26.0" }

[[target.starknet-contract]]
casm = true
build-external-contracts = ["piltover::appchain::appchain"]

[scripts]
test = "snforge test"
14 changes: 14 additions & 0 deletions scripts/my_script/Scarb.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Code generated by scarb DO NOT EDIT.
version = 1

[[package]]
name = "my_script"
version = "0.1.0"
dependencies = [
"sncast_std",
]

[[package]]
name = "sncast_std"
version = "0.26.0"
source = "git+https://github.com/foundry-rs/starknet-foundry?tag=v0.26.0#50eb589db65e113efe4f09241feb59b574228c7e"
10 changes: 10 additions & 0 deletions scripts/my_script/Scarb.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "my_script"
version = "0.1.0"
edition = "2023_11"

# See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html

[dependencies]
sncast_std = { git = "https://github.com/foundry-rs/starknet-foundry", tag = "v0.26.0" }
starknet = ">=2.6.4"
1 change: 1 addition & 0 deletions scripts/my_script/src/lib.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mod my_script;
82 changes: 82 additions & 0 deletions src/bridge/interface.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
use starknet::ContractAddress;
use starknet_bridge::bridge::types::{TokenStatus, TokenSettings};

#[starknet::interface]
pub trait ITokenBridgeAdmin<TContractState> {
fn set_appchain_token_bridge(ref self: TContractState, appchain_bridge: ContractAddress);
fn block_token(ref self: TContractState, token: ContractAddress);
fn deactivate_token(ref self: TContractState, token: ContractAddress);
fn enable_withdrawal_limit(ref self: TContractState, token: ContractAddress);
fn disable_withdrawal_limit(ref self: TContractState, token: ContractAddress);
fn set_max_total_balance(
ref self: TContractState, token: ContractAddress, max_total_balance: u256
);
}

#[starknet::interface]
pub trait ITokenBridge<TContractState> {
fn appchain_bridge(self: @TContractState) -> ContractAddress;
fn get_identity(self: @TContractState) -> felt252;
fn get_version(self: @TContractState) -> felt252;
fn get_status(self: @TContractState, token: ContractAddress) -> TokenStatus;
fn is_servicing_token(self: @TContractState, token: ContractAddress) -> bool;

fn enroll_token(ref self: TContractState, token: ContractAddress);
fn check_deployment_status(ref self: TContractState, token: ContractAddress);

fn deposit(
ref self: TContractState,
token: ContractAddress,
amount: u256,
appchain_recipient: ContractAddress
);
fn deposit_with_message(
ref self: TContractState,
token: ContractAddress,
amount: u256,
appchain_recipient: ContractAddress,
message: Span<felt252>
);

fn withdraw(
ref self: TContractState, token: ContractAddress, amount: u256, recipient: ContractAddress
);

fn deposit_cancel_request(
ref self: TContractState,
token: ContractAddress,
amount: u256,
appchain_recipient: ContractAddress,
nonce: felt252
);
fn deposit_with_message_cancel_request(
ref self: TContractState,
token: ContractAddress,
amount: u256,
appchain_recipient: ContractAddress,
message: Span<felt252>,
nonce: felt252
);

fn deposit_with_message_reclaim(
ref self: TContractState,
token: ContractAddress,
amount: u256,
appchain_recipient: ContractAddress,
message: Span<felt252>,
nonce: felt252
);
fn deposit_reclaim(
ref self: TContractState,
token: ContractAddress,
amount: u256,
appchain_recipient: ContractAddress,
nonce: felt252
);
fn get_remaining_intraday_allowance(self: @TContractState, token: ContractAddress) -> u256;
}

#[starknet::interface]
pub trait IWithdrawalLimitStatus<TContractState> {
fn is_withdrawal_limit_applied(self: @TContractState, token: ContractAddress) -> bool;
}
Loading

0 comments on commit 20dab01

Please sign in to comment.