-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add ERC1155 module, dual and interface * Implement ERC1155 and update token_id variable names * Add ERC1155 receiver mocks and test dual1155 receiver * apply linter * Update token_uri variable and remove IERC1155MetadataCamelOnly support * Add ERC1155 mocks and tests and add ERC1155 preset * update CHANGELOG * adding PR number (#852) * reset changlog * Update ERC1155Component Event and add batch_burn * Add batch minting functions for ERC1155 tokens * Refactor code for better readability Update error testing and remove tests failing from erc1155 * feat: finish first version with 2.5.3 * feat: apply review updates * feat: add tests * feat: bump version and add entry to CHANGELOG * feat: add more tests * fix: remove print * feat: add preset tests * fix: format * feat: uncomment test * refactor: shortening test names * feat: move assertion * Update src/token/erc1155/erc1155.cairo Co-authored-by: Martín Triay <[email protected]> * fix: comments * featL apply review updates * feat: remove IAccount --------- Co-authored-by: Arn0d <[email protected]> Co-authored-by: Martín Triay <[email protected]>
- Loading branch information
1 parent
e47c5fb
commit ca11b87
Showing
29 changed files
with
4,478 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
mod account; | ||
mod erc1155; | ||
mod erc20; | ||
mod erc721; | ||
mod eth_account; | ||
|
||
use account::Account; | ||
use erc1155::ERC1155; | ||
use erc20::ERC20; | ||
use erc721::ERC721; | ||
use eth_account::EthAccountUpgradeable; |
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,72 @@ | ||
// SPDX-License-Identifier: MIT | ||
// OpenZeppelin Contracts for Cairo v0.9.0 (presets/erc1155.cairo) | ||
|
||
/// # ERC1155 Preset | ||
/// | ||
/// The ERC1155 contract offers a batch-mint mechanism that | ||
/// can only be executed once upon contract construction. | ||
/// | ||
/// For more complex or custom contracts, use Wizard for Cairo | ||
/// https://wizard.openzeppelin.com/cairo | ||
#[starknet::contract] | ||
mod ERC1155 { | ||
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 | ||
} | ||
|
||
/// Sets the `token_uri`. | ||
/// Mints the `values` for `token_ids` tokens to `recipient`. | ||
/// | ||
/// Requirements: | ||
/// | ||
/// - `to` is either an account contract (supporting ISRC6) or | ||
/// supports the `IERC1155Receiver` interface. | ||
/// - `token_ids` and `values` must have the same length. | ||
#[constructor] | ||
fn constructor( | ||
ref self: ContractState, | ||
token_uri: ByteArray, | ||
recipient: ContractAddress, | ||
token_ids: Span<u256>, | ||
values: Span<u256> | ||
) { | ||
self.erc1155.initializer(token_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
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
Oops, something went wrong.