Skip to content

Commit

Permalink
feat: add L2 token contract
Browse files Browse the repository at this point in the history
  • Loading branch information
xJonathanLEI committed Mar 7, 2024
1 parent d5bbb2b commit b847776
Show file tree
Hide file tree
Showing 14 changed files with 1,138 additions and 2 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/artifacts-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ jobs:
with:
version: "nightly"

- name: "Build contracts"
- name: "Build L1 contracts"
run: |
forge build
- name: "Build L2 contracts"
run: |
./scripts/compile_l2_with_docker.sh
- name: "Set up deploy key for artifacts repo"
uses: "webfactory/ssh-agent@v0.7.0"
with:
Expand All @@ -38,6 +42,7 @@ jobs:
cp ./out/TokenEscrow.sol/TokenEscrow.json ./artifacts/zend-token/$COMMIT_HASH/
cp ./out/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy.json ./artifacts/zend-token/$COMMIT_HASH/
cp ./out/ProxyAdmin.sol/ProxyAdmin.json ./artifacts/zend-token/$COMMIT_HASH/
cp ./build/ERC20.json ./artifacts/zend-token/$COMMIT_HASH/StarknetERC20.json
(cd ./artifacts/zend-token/ && rm -rf ./latest && ln -s ./$COMMIT_HASH ./latest)
cd ./artifacts
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/artifacts-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ jobs:
with:
version: "nightly"

- name: "Build contracts"
- name: "Build L1 contracts"
run: |
forge build
- name: "Build L2 contracts"
run: |
./scripts/compile_l2_with_docker.sh
- name: "Set up deploy key for artifacts repo"
uses: "webfactory/ssh-agent@v0.7.0"
with:
Expand All @@ -38,6 +42,7 @@ jobs:
cp ./out/TokenEscrow.sol/TokenEscrow.json ./artifacts/zend-token/$COMMIT_HASH/
cp ./out/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy.json ./artifacts/zend-token/$COMMIT_HASH/
cp ./out/ProxyAdmin.sol/ProxyAdmin.json ./artifacts/zend-token/$COMMIT_HASH/
cp ./build/ERC20.json ./artifacts/zend-token/$COMMIT_HASH/StarknetERC20.json
(cd ./artifacts/zend-token/ && rm -rf ./latest && ln -s ./$COMMIT_HASH ./latest)
cd ./artifacts
Expand Down
1 change: 1 addition & 0 deletions l2/openzeppelin/lib.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mod token;
2 changes: 2 additions & 0 deletions l2/openzeppelin/token.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mod erc20;
mod erc20_v070;
1 change: 1 addition & 0 deletions l2/openzeppelin/token/erc20.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mod interface;
79 changes: 79 additions & 0 deletions l2/openzeppelin/token/erc20/interface.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts for Cairo v0.8.0-beta.1 (token/erc20/interface.cairo)

use starknet::ContractAddress;

#[starknet::interface]
trait IERC20<TState> {
fn name(self: @TState) -> felt252;
fn symbol(self: @TState) -> felt252;
fn decimals(self: @TState) -> u8;
fn total_supply(self: @TState) -> u256;
fn balance_of(self: @TState, account: ContractAddress) -> u256;
fn allowance(self: @TState, owner: ContractAddress, spender: ContractAddress) -> u256;
fn transfer(ref self: TState, recipient: ContractAddress, amount: u256) -> bool;
fn transfer_from(
ref self: TState, sender: ContractAddress, recipient: ContractAddress, amount: u256
) -> bool;
fn approve(ref self: TState, spender: ContractAddress, amount: u256) -> bool;
}

#[starknet::interface]
trait IERC20Camel<TState> {
fn name(self: @TState) -> felt252;
fn symbol(self: @TState) -> felt252;
fn decimals(self: @TState) -> u8;
fn totalSupply(self: @TState) -> u256;
fn balanceOf(self: @TState, account: ContractAddress) -> u256;
fn allowance(self: @TState, owner: ContractAddress, spender: ContractAddress) -> u256;
fn transfer(ref self: TState, recipient: ContractAddress, amount: u256) -> bool;
fn transferFrom(
ref self: TState, sender: ContractAddress, recipient: ContractAddress, amount: u256
) -> bool;
fn approve(ref self: TState, spender: ContractAddress, amount: u256) -> bool;
}

#[starknet::interface]
trait IERC20CamelOnly<TState> {
fn totalSupply(self: @TState) -> u256;
fn balanceOf(self: @TState, account: ContractAddress) -> u256;
fn transferFrom(
ref self: TState, sender: ContractAddress, recipient: ContractAddress, amount: u256
) -> bool;
}

#[starknet::interface]
trait ERC20ABI<TState> {
fn name(self: @TState) -> felt252;
fn symbol(self: @TState) -> felt252;
fn decimals(self: @TState) -> u8;
fn total_supply(self: @TState) -> u256;
fn balance_of(self: @TState, account: ContractAddress) -> u256;
fn allowance(self: @TState, owner: ContractAddress, spender: ContractAddress) -> u256;
fn transfer(ref self: TState, recipient: ContractAddress, amount: u256) -> bool;
fn transfer_from(
ref self: TState, sender: ContractAddress, recipient: ContractAddress, amount: u256
) -> bool;
fn approve(ref self: TState, spender: ContractAddress, amount: u256) -> bool;
fn increase_allowance(ref self: TState, spender: ContractAddress, added_value: u256) -> bool;
fn decrease_allowance(
ref self: TState, spender: ContractAddress, subtracted_value: u256
) -> bool;
}

#[starknet::interface]
trait ERC20CamelABI<TState> {
fn name(self: @TState) -> felt252;
fn symbol(self: @TState) -> felt252;
fn decimals(self: @TState) -> u8;
fn totalSupply(self: @TState) -> u256;
fn balanceOf(self: @TState, account: ContractAddress) -> u256;
fn allowance(self: @TState, owner: ContractAddress, spender: ContractAddress) -> u256;
fn transfer(ref self: TState, recipient: ContractAddress, amount: u256) -> bool;
fn transferFrom(
ref self: TState, sender: ContractAddress, recipient: ContractAddress, amount: u256
) -> bool;
fn approve(ref self: TState, spender: ContractAddress, amount: u256) -> bool;
fn increaseAllowance(ref self: TState, spender: ContractAddress, addedValue: u256) -> bool;
fn decreaseAllowance(ref self: TState, spender: ContractAddress, subtractedValue: u256) -> bool;
}
1 change: 1 addition & 0 deletions l2/openzeppelin/token/erc20_v070.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mod erc20;
Loading

0 comments on commit b847776

Please sign in to comment.