Skip to content

Commit

Permalink
+ hyp_erc721 + fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ametel01 committed Aug 16, 2024
1 parent 6d6e14c commit 5c1d3f6
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub trait IHypErc721<TState> {
}

#[starknet::component]
pub mod HypErc721 {
pub mod HypErc721Component {
use openzeppelin::access::ownable::{
OwnableComponent, OwnableComponent::InternalImpl as OwnableInternalImpl
};
Expand Down
2 changes: 1 addition & 1 deletion cairo/src/contracts/token/components/token_router.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub mod TokenRouterComponent {

#[event]
#[derive(Drop, starknet::Event)]
enum Event {
pub enum Event {
SentTransferRemote: SentTransferRemote,
ReceivedTransferRemote: ReceivedTransferRemote,
}
Expand Down
94 changes: 82 additions & 12 deletions cairo/src/contracts/token/hyp_erc721.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,94 @@ pub trait IHypErc721<TState> {

#[starknet::contract]
pub mod HypErc721 {
#[storage]
struct Storage {}
use hyperlane_starknet::contracts::client::gas_router_component::GasRouterComponent;
use hyperlane_starknet::contracts::client::mailboxclient_component::MailboxclientComponent;
use hyperlane_starknet::contracts::client::router_component::RouterComponent;
use hyperlane_starknet::contracts::token::components::hyp_erc721_component::HypErc721Component;
use hyperlane_starknet::contracts::token::components::token_router::TokenRouterComponent;
use openzeppelin::access::ownable::OwnableComponent;
use openzeppelin::introspection::src5::SRC5Component;
use openzeppelin::token::erc721::{ERC721Component, ERC721HooksEmptyImpl};
use openzeppelin::upgrades::upgradeable::UpgradeableComponent;
use starknet::ContractAddress;

component!(path: ERC721Component, storage: erc721, event: ERC721Event);
component!(path: UpgradeableComponent, storage: upgradeable, event: UpgradeableEvent);
component!(path: HypErc721Component, storage: hyp_erc721, event: HypErc721Event);
component!(path: SRC5Component, storage: src5, event: SRC5Event);
component!(path: OwnableComponent, storage: ownable, event: OwnableEvent);
component!(path: TokenRouterComponent, storage: token_router, event: TokenRouterEvent);
component!(path: MailboxclientComponent, storage: mailboxclient, event: MailboxclientEvent);
component!(path: RouterComponent, storage: router, event: RouterEvent);
component!(path: GasRouterComponent, storage: gas_router, event: GasRouterEvent);
// Ownable
impl OwnableInternalImpl = OwnableComponent::InternalImpl<ContractState>;

// ERC721 Mixin
#[abi(embed_v0)]
impl ERC721MixinImpl = ERC721Component::ERC721MixinImpl<ContractState>;
impl ERC721InternalImpl = ERC721Component::InternalImpl<ContractState>;

// Upgradeable
impl UpgradeableInternalImpl = UpgradeableComponent::InternalImpl<ContractState>;

fn constructor() {}
// HypERC721
#[abi(embed_v0)]
impl HypErc721Impl = HypErc721Component::HypErc721Impl<ContractState>;

impl HypErc721Impl of super::IHypErc721<ContractState> {
fn initialize(ref self: ContractState) {}
// TokenRouter
#[abi(embed_v0)]
impl TokenRouterImpl = TokenRouterComponent::TokenRouterImpl<ContractState>;
impl TokenRouterInternalImpl = TokenRouterComponent::TokenRouterInternalImpl<ContractState>;

fn balance_of(self: @ContractState) -> u256 {
0
}

#[storage]
struct Storage {
#[substorage(v0)]
erc721: ERC721Component::Storage,
#[substorage(v0)]
upgradeable: UpgradeableComponent::Storage,
#[substorage(v0)]
hyp_erc721: HypErc721Component::Storage,
#[substorage(v0)]
src5: SRC5Component::Storage,
#[substorage(v0)]
ownable: OwnableComponent::Storage,
#[substorage(v0)]
token_router: TokenRouterComponent::Storage,
#[substorage(v0)]
mailboxclient: MailboxclientComponent::Storage,
#[substorage(v0)]
router: RouterComponent::Storage,
#[substorage(v0)]
gas_router: GasRouterComponent::Storage
}

#[generate_trait]
impl InternalImpl of InternalTrait {
fn transfer_from_sender(ref self: ContractState, token_id: u256) {}
#[event]
#[derive(Drop, starknet::Event)]
enum Event {
#[flat]
ERC721Event: ERC721Component::Event,
#[flat]
UpgradeableEvent: UpgradeableComponent::Event,
#[flat]
HypErc721Event: HypErc721Component::Event,
#[flat]
SRC5Event: SRC5Component::Event,
#[flat]
OwnableEvent: OwnableComponent::Event,
#[flat]
TokenRouterEvent: TokenRouterComponent::Event,
#[flat]
MailboxclientEvent: MailboxclientComponent::Event,
#[flat]
RouterEvent: RouterComponent::Event,
#[flat]
GasRouterEvent: GasRouterComponent::Event
}

fn transfer_to_recipient(ref self: ContractState, recipient: u256, token_id: u256) {}
fn constructor(ref self: ContractState, mailbox: ContractAddress) {
self.token_router.initialize(mailbox);
}
}

0 comments on commit 5c1d3f6

Please sign in to comment.