-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ark-contracts): add nft contract
- Loading branch information
Showing
12 changed files
with
189 additions
and
20 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -6,3 +6,7 @@ mod crypto { | |
mod hash; | ||
mod signer; | ||
} | ||
|
||
mod tokens { | ||
mod nft; | ||
} |
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 @@ | ||
use starknet::ContractAddress; | ||
|
||
#[starknet::interface] | ||
trait IFreeMint<T> { | ||
fn mint(ref self: T, recipient: ContractAddress, token_id: u256); | ||
} | ||
|
||
#[starknet::contract] | ||
mod FreeMintNFT { | ||
use super::IFreeMint; | ||
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); | ||
|
||
// ERC721 | ||
#[abi(embed_v0)] | ||
impl ERC721Impl = ERC721Component::ERC721Impl<ContractState>; | ||
#[abi(embed_v0)] | ||
impl ERC721MetadataImpl = ERC721Component::ERC721MetadataImpl<ContractState>; | ||
#[abi(embed_v0)] | ||
impl ERC721CamelOnly = ERC721Component::ERC721CamelOnlyImpl<ContractState>; | ||
#[abi(embed_v0)] | ||
impl ERC721MetadataCamelOnly = | ||
ERC721Component::ERC721MetadataCamelOnlyImpl<ContractState>; | ||
impl ERC721InternalImpl = ERC721Component::InternalImpl<ContractState>; | ||
|
||
// SRC5 | ||
#[abi(embed_v0)] | ||
impl SRC5Impl = SRC5Component::SRC5Impl<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, name: felt252, symbol: felt252) { | ||
self.erc721.initializer(name, symbol); | ||
} | ||
|
||
#[external(v0)] | ||
impl ImplFreeMint of IFreeMint<ContractState> { | ||
fn mint(ref self: ContractState, recipient: ContractAddress, token_id: u256) { | ||
self.erc721._mint(recipient, token_id); | ||
// self.erc721._set_token_uri(token_id, 0); | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -5,6 +5,7 @@ version = 1 | |
name = "ark_common" | ||
version = "0.1.0" | ||
dependencies = [ | ||
"openzeppelin", | ||
"snforge_std", | ||
] | ||
|
||
|
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 |
---|---|---|
|
@@ -7,3 +7,4 @@ mod executor; | |
|
||
//mod tests; | ||
|
||
|
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
const ORDER_BOOK_ADDRESS = | ||
export const ORDER_BOOK_ADDRESS = | ||
process.env.ORDERBOOK_CONTRACT || | ||
"0x46ddb3a4b23520a9944ae5213f27660115d5dd24ac47fb95c9f3a799bcdd1ca"; | ||
|
||
export { ORDER_BOOK_ADDRESS }; | ||
export const EVERAI_NFT_ADDRESS = | ||
"0x7a39fd46a05526515cb577a52b45a14818585424b1eff7bbe76601369e580fe"; |
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 @@ | ||
import * as sn from "starknet"; | ||
|
||
import * as common from "./common.js"; | ||
|
||
export async function declareDeploy( | ||
common_artifacts_path, | ||
account, | ||
provider, | ||
name, | ||
symbol | ||
) { | ||
const artifacts = common.load_artifacts( | ||
common_artifacts_path, | ||
"ark_common_FreeMintNFT" | ||
); | ||
|
||
const contractCallData = new sn.CallData(artifacts.sierra.abi); | ||
const contractConstructor = contractCallData.compile("constructor", { | ||
name, | ||
symbol | ||
}); | ||
|
||
const deployR = await account.declareAndDeploy({ | ||
contract: artifacts.sierra, | ||
casm: artifacts.casm, | ||
constructorCalldata: contractConstructor, | ||
salt: 0x7777 | ||
}); | ||
|
||
return new sn.Contract( | ||
artifacts.sierra.abi, | ||
deployR.deploy.contract_address, | ||
provider | ||
); | ||
} |
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