forked from Scaffold-Stark/scaffold-stark-2
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into rejected-tx
# Conflicts: # packages/nextjs/scaffold.config.ts
- Loading branch information
Showing
11 changed files
with
872 additions
and
36 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#[starknet::contract] | ||
mod Challenge0 { | ||
use openzeppelin::introspection::src5::SRC5Component; | ||
use openzeppelin::token::erc721::ERC721Component; | ||
use starknet::ContractAddress; | ||
|
||
component!(path: ERC721Component, storage: erc721, event: ERC721Event); | ||
component!(path: SRC5Component, storage: src5, event: SRC5Event); | ||
|
||
// ERC721Mixin | ||
#[abi(embed_v0)] | ||
impl ERC721MixinImpl = ERC721Component::ERC721MixinImpl<ContractState>; | ||
impl ERC721InternalImpl = ERC721Component::InternalImpl<ContractState>; | ||
|
||
#[storage] | ||
struct Storage { | ||
#[substorage(v0)] | ||
erc721: ERC721Component::Storage, | ||
#[substorage(v0)] | ||
src5: SRC5Component::Storage | ||
} | ||
|
||
#[event] | ||
#[derive(Drop, starknet::Event)] | ||
enum Event { | ||
#[flat] | ||
ERC721Event: ERC721Component::Event, | ||
#[flat] | ||
SRC5Event: SRC5Component::Event | ||
} | ||
|
||
#[constructor] | ||
fn constructor( | ||
ref self: ContractState, | ||
recipient: felt252 | ||
) { | ||
//let arr = array![1, 2, 3]; | ||
let name:ByteArray = "YourCollectible"; | ||
let symbol:ByteArray = "YCB"; | ||
let base_uri:ByteArray = "https://ipfs.io/ipfs/QmfVMAmNM1kDEBYrC2TPzQDoCRFH6F5tE1e9Mr4FkkR5Xr"; // bison nft | ||
//let token_id = arr.span(); | ||
|
||
self.erc721.initializer(name, symbol, base_uri); | ||
//self._mint_assets(recipient, token_id); | ||
} | ||
|
||
#[generate_trait] | ||
impl InternalImpl of InternalTrait { | ||
/// Mints `token_ids` to `recipient`. | ||
fn _mint_assets( | ||
ref self: ContractState, recipient: ContractAddress, mut token_ids: Span<u256> | ||
) { | ||
loop { | ||
if token_ids.len() == 0 { | ||
break; | ||
} | ||
let id = *token_ids.pop_front().unwrap(); | ||
|
||
self.erc721._mint(recipient, id); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#[starknet::contract] | ||
mod Challenge1 { | ||
use openzeppelin::token::erc20::ERC20Component; | ||
use starknet::ContractAddress; | ||
|
||
component!(path: ERC20Component, storage: erc20, event: ERC20Event); | ||
|
||
// ERC20Mixin | ||
#[abi(embed_v0)] | ||
impl ERC20MixinImpl = ERC20Component::ERC20MixinImpl<ContractState>; | ||
impl InternalImpl = ERC20Component::InternalImpl<ContractState>; | ||
|
||
#[storage] | ||
struct Storage { | ||
#[substorage(v0)] | ||
erc20: ERC20Component::Storage | ||
} | ||
|
||
#[event] | ||
#[derive(Drop, starknet::Event)] | ||
enum Event { | ||
#[flat] | ||
ERC20Event: ERC20Component::Event | ||
} | ||
|
||
/// Sets the token `name` and `symbol`. | ||
/// Mints `fixed_supply` tokens to `recipient`. | ||
#[constructor] | ||
fn constructor( | ||
ref self: ContractState, | ||
name: ByteArray, | ||
symbol: ByteArray, | ||
fixed_supply: u256, | ||
recipient: ContractAddress | ||
) { | ||
self.erc20.initializer(name, symbol); | ||
self.erc20._mint(recipient, fixed_supply); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#[starknet::contract] | ||
mod Challenge2 { | ||
use openzeppelin::introspection::src5::SRC5Component; | ||
use openzeppelin::token::erc1155::ERC1155Component; | ||
use starknet::ContractAddress; | ||
|
||
component!(path: ERC1155Component, storage: erc1155, event: ERC1155Event); | ||
component!(path: SRC5Component, storage: src5, event: SRC5Event); | ||
|
||
// ERC1155 | ||
#[abi(embed_v0)] | ||
impl ERC1155Impl = ERC1155Component::ERC1155Impl<ContractState>; | ||
#[abi(embed_v0)] | ||
impl ERC1155MetadataURIImpl = | ||
ERC1155Component::ERC1155MetadataURIImpl<ContractState>; | ||
#[abi(embed_v0)] | ||
impl ERC1155Camel = ERC1155Component::ERC1155CamelImpl<ContractState>; | ||
impl ERC1155InternalImpl = ERC1155Component::InternalImpl<ContractState>; | ||
|
||
// SRC5 | ||
#[abi(embed_v0)] | ||
impl SRC5Impl = SRC5Component::SRC5Impl<ContractState>; | ||
|
||
#[storage] | ||
struct Storage { | ||
#[substorage(v0)] | ||
erc1155: ERC1155Component::Storage, | ||
#[substorage(v0)] | ||
src5: SRC5Component::Storage | ||
} | ||
|
||
#[event] | ||
#[derive(Drop, starknet::Event)] | ||
enum Event { | ||
#[flat] | ||
ERC1155Event: ERC1155Component::Event, | ||
#[flat] | ||
SRC5Event: SRC5Component::Event | ||
} | ||
|
||
#[constructor] | ||
fn constructor( | ||
ref self: ContractState, | ||
base_uri: ByteArray, | ||
recipient: ContractAddress, | ||
token_ids: Span<u256>, | ||
values: Span<u256> | ||
) { | ||
self.erc1155.initializer(base_uri); | ||
self | ||
.erc1155 | ||
.batch_mint_with_acceptance_check(recipient, token_ids, values, array![].span()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#[starknet::contract(account)] | ||
mod Challenge3 { | ||
use openzeppelin::account::AccountComponent; | ||
use openzeppelin::introspection::src5::SRC5Component; | ||
|
||
component!(path: AccountComponent, storage: account, event: AccountEvent); | ||
component!(path: SRC5Component, storage: src5, event: SRC5Event); | ||
|
||
// AccountMixin | ||
#[abi(embed_v0)] | ||
impl AccountMixinImpl = AccountComponent::AccountMixinImpl<ContractState>; | ||
impl AccountInternalImpl = AccountComponent::InternalImpl<ContractState>; | ||
|
||
#[storage] | ||
struct Storage { | ||
#[substorage(v0)] | ||
account: AccountComponent::Storage, | ||
#[substorage(v0)] | ||
src5: SRC5Component::Storage | ||
} | ||
|
||
#[event] | ||
#[derive(Drop, starknet::Event)] | ||
enum Event { | ||
#[flat] | ||
AccountEvent: AccountComponent::Event, | ||
#[flat] | ||
SRC5Event: SRC5Component::Event | ||
} | ||
|
||
#[constructor] | ||
fn constructor(ref self: ContractState, public_key: felt252) { | ||
self.account.initializer(public_key); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters