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

use #[abi(embed_v0)] #35

Merged
merged 1 commit into from
Jan 12, 2024
Merged
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
2 changes: 1 addition & 1 deletion examples/chess/src/actions.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ mod actions {
use chess::models::game::{Game, GameTurn, GameTurnTrait};
use super::{ContractAddress, IActions, Vec2};

#[external(v0)]
#[abi(embed_v0)]
impl IActionsImpl of IActions<ContractState> {
fn spawn(
self: @ContractState, white_address: ContractAddress, black_address: ContractAddress
Expand Down
2 changes: 1 addition & 1 deletion examples/hex_map/src/actions.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ mod actions {
new_position
}

#[external(v0)]
#[abi(embed_v0)]
impl ActionsImpl of IActions<ContractState> {
// ContractState is defined by system decorator expansion
fn spawn(self: @ContractState) { // Access the world dispatcher for reading.
Expand Down
2 changes: 1 addition & 1 deletion examples/market/src/systems/liquidity.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ mod Liquidity {
use super::Fixed;
use super::ILiquidity;

#[external(v0)]
#[abi(embed_v0)]
impl LiquidityImpl of ILiquidity<ContractState> {
fn add(
self: @ContractState,
Expand Down
2 changes: 1 addition & 1 deletion examples/market/src/systems/trade.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ mod Trade {

use super::ITrade;

#[external(v0)]
#[abi(embed_v0)]
impl TradeImpl of ITrade<ContractState> {
fn buy(self: @ContractState, world: IWorldDispatcher, item_id: u32, quantity: u128) {
let player = starknet::get_caller_address();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ mod erc20_balance_mock {
ERC20BalanceEvent: erc20_balance_component::Event,
}

#[external(v0)]
#[abi(embed_v0)]
#[generate_trait]
impl InitializerImpl of InitializerTrait {
fn initializer(ref self: ContractState, initial_supply: u256, recipient: ContractAddress,) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ mod erc20_bridgeable_mock {
// Initializer
//

#[external(v0)]
#[abi(embed_v0)]
#[generate_trait]
impl ERC20InitializerImpl of ERC20InitializerTrait {
fn initializer(
Expand Down
6 changes: 3 additions & 3 deletions token/src/erc1155/erc1155.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ mod ERC1155 {
self.initializer(name, symbol, base_uri);
}

#[external(v0)]
#[abi(embed_v0)]
impl ERC1155MetadataImpl of interface::IERC1155Metadata<ContractState> {
fn name(self: @ContractState) -> felt252 {
self.get_meta().name
Expand All @@ -91,7 +91,7 @@ mod ERC1155 {
}


#[external(v0)]
#[abi(embed_v0)]
impl ERC1155Impl of interface::IERC1155<ContractState> {
fn balance_of(self: @ContractState, account: ContractAddress, id: u256) -> u256 {
assert(account.is_non_zero(), Errors::INVALID_ACCOUNT);
Expand Down Expand Up @@ -161,7 +161,7 @@ mod ERC1155 {
}
}

#[external(v0)]
#[abi(embed_v0)]
impl ERC1155CamelOnlyImpl of interface::IERC1155CamelOnly<ContractState> {
fn balanceOf(self: @ContractState, account: ContractAddress, id: u256) -> u256 {
ERC1155Impl::balance_of(self, account, id)
Expand Down
14 changes: 7 additions & 7 deletions token/src/erc20/erc20.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ mod ERC20 {
// External
//

#[external(v0)]
#[abi(embed_v0)]
impl ERC20MetadataImpl of interface::IERC20Metadata<ContractState> {
fn name(self: @ContractState) -> felt252 {
self.get_meta().name
Expand All @@ -77,7 +77,7 @@ mod ERC20 {
}
}

#[external(v0)]
#[abi(embed_v0)]
impl ERC20Impl of interface::IERC20<ContractState> {
fn total_supply(self: @ContractState) -> u256 {
self.get_meta().total_supply
Expand Down Expand Up @@ -121,7 +121,7 @@ mod ERC20 {
}
}

#[external(v0)]
#[abi(embed_v0)]
impl ERC20CamelOnlyImpl of interface::IERC20CamelOnly<ContractState> {
fn totalSupply(self: @ContractState) -> u256 {
ERC20Impl::total_supply(self)
Expand All @@ -141,30 +141,30 @@ mod ERC20 {
}
}

#[external(v0)]
#[abi(embed_v0)]
fn increase_allowance(
ref self: ContractState, spender: ContractAddress, added_value: u256
) -> bool {
self.update_allowance(get_caller_address(), spender, 0, added_value);
true
}

#[external(v0)]
#[abi(embed_v0)]
fn increaseAllowance(
ref self: ContractState, spender: ContractAddress, addedValue: u256
) -> bool {
increase_allowance(ref self, spender, addedValue)
}

#[external(v0)]
#[abi(embed_v0)]
fn decrease_allowance(
ref self: ContractState, spender: ContractAddress, subtracted_value: u256
) -> bool {
self.update_allowance(get_caller_address(), spender, subtracted_value, 0);
true
}

#[external(v0)]
#[abi(embed_v0)]
fn decreaseAllowance(
ref self: ContractState, spender: ContractAddress, subtractedValue: u256
) -> bool {
Expand Down
8 changes: 4 additions & 4 deletions token/src/erc721/erc721.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ mod ERC721 {
self._mint(recipient, token_id);
}

#[external(v0)]
#[abi(embed_v0)]
impl ERC721MetadataImpl of interface::IERC721Metadata<ContractState> {
fn name(self: @ContractState) -> felt252 {
self.get_meta().name
Expand All @@ -90,15 +90,15 @@ mod ERC721 {
}
}

#[external(v0)]
#[abi(embed_v0)]
impl ERC721MetadataCamelOnlyImpl of interface::IERC721MetadataCamelOnly<ContractState> {
fn tokenURI(self: @ContractState, tokenId: u256) -> felt252 {
assert(self._exists(tokenId), Errors::INVALID_TOKEN_ID);
self.get_uri(tokenId)
}
}

#[external(v0)]
#[abi(embed_v0)]
impl ERC721Impl of interface::IERC721<ContractState> {
fn balance_of(self: @ContractState, account: ContractAddress) -> u256 {
assert(account.is_non_zero(), Errors::INVALID_ACCOUNT);
Expand Down Expand Up @@ -160,7 +160,7 @@ mod ERC721 {
}
}

#[external(v0)]
#[abi(embed_v0)]
impl ERC721CamelOnlyImpl of interface::IERC721CamelOnly<ContractState> {
fn balanceOf(self: @ContractState, account: ContractAddress) -> u256 {
ERC721Impl::balance_of(self, account)
Expand Down
2 changes: 1 addition & 1 deletion token/src/presets/erc20/bridgeable.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ mod ERC20Bridgeable {
// Initializer
//

#[external(v0)]
#[abi(embed_v0)]
#[generate_trait]
impl ERC20InitializerImpl of ERC20InitializerTrait {
fn initializer(
Expand Down