-
Notifications
You must be signed in to change notification settings - Fork 51
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 ft_add_template_quest
- Loading branch information
Showing
13 changed files
with
293 additions
and
13 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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"canvas": { | ||
"width": 35, | ||
"height": 24 | ||
"width": 256, | ||
"height": 256 | ||
}, | ||
"colors": [ | ||
"010001", | ||
|
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
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,7 +1,7 @@ | ||
{ | ||
"canvas": { | ||
"width": 35, | ||
"height": 24 | ||
"width": 256, | ||
"height": 256 | ||
}, | ||
"colors": [ | ||
"010001", | ||
|
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,52 @@ | ||
// | ||
// https://github.com/OpenZeppelin/cairo-contracts/blob/main/src/tests/mocks/erc20_mocks.cairo | ||
// | ||
|
||
#[starknet::contract] | ||
pub mod UnruggableMock { | ||
use art_peace::quests::interfaces::IUnruggableMemecoin; | ||
use openzeppelin::token::erc20::ERC20Component; | ||
use starknet::ContractAddress; | ||
|
||
component!(path: ERC20Component, storage: erc20, event: ERC20Event); | ||
|
||
#[abi(embed_v0)] | ||
impl ERC20Impl = ERC20Component::ERC20Impl<ContractState>; | ||
#[abi(embed_v0)] | ||
impl ERC20MetadataImpl = ERC20Component::ERC20MetadataImpl<ContractState>; | ||
impl InternalImpl = ERC20Component::InternalImpl<ContractState>; | ||
|
||
#[storage] | ||
struct Storage { | ||
is_launched: bool, | ||
owner: ContractAddress, | ||
#[substorage(v0)] | ||
erc20: ERC20Component::Storage | ||
} | ||
|
||
#[event] | ||
#[derive(Drop, starknet::Event)] | ||
enum Event { | ||
#[flat] | ||
ERC20Event: ERC20Component::Event | ||
} | ||
|
||
#[constructor] | ||
fn constructor( | ||
ref self: ContractState, name: ByteArray, symbol: ByteArray, owner: ContractAddress | ||
) { | ||
self.erc20.initializer(name, symbol); | ||
self.owner.write(owner); | ||
self.is_launched.write(true); | ||
} | ||
|
||
#[abi(embed_v0)] | ||
impl UnruggableImpl of IUnruggableMemecoin<ContractState> { | ||
fn owner(self: @ContractState) -> ContractAddress { | ||
self.owner.read() | ||
} | ||
fn is_launched(self: @ContractState) -> bool { | ||
self.is_launched.read() | ||
} | ||
} | ||
} |
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,84 @@ | ||
#[starknet::contract] | ||
pub mod UnruggableQuest { | ||
use starknet::{ContractAddress, get_caller_address}; | ||
use art_peace::{IArtPeaceDispatcher, IArtPeaceDispatcherTrait}; | ||
use art_peace::quests::{ | ||
IQuest, IUnruggableQuest, IUnruggableMemecoinDispatcher, IUnruggableMemecoinDispatcherTrait, | ||
QuestClaimed | ||
}; | ||
|
||
#[storage] | ||
struct Storage { | ||
art_peace: ContractAddress, | ||
reward: u32, | ||
claimed: LegacyMap<ContractAddress, bool>, | ||
} | ||
|
||
#[event] | ||
#[derive(Drop, starknet::Event)] | ||
enum Event { | ||
QuestClaimed: QuestClaimed, | ||
} | ||
|
||
#[derive(Drop, Serde)] | ||
pub struct UnruggableQuestInitParams { | ||
pub art_peace: ContractAddress, | ||
pub reward: u32, | ||
} | ||
|
||
#[constructor] | ||
fn constructor(ref self: ContractState, init_params: UnruggableQuestInitParams) { | ||
self.art_peace.write(init_params.art_peace); | ||
self.reward.write(init_params.reward); | ||
} | ||
|
||
#[abi(embed_v0)] | ||
impl UnruggableQuestImpl of IUnruggableQuest<ContractState> { | ||
fn is_claimed(self: @ContractState, user: ContractAddress) -> bool { | ||
self.claimed.read(user) | ||
} | ||
} | ||
|
||
#[abi(embed_v0)] | ||
impl UnruggableQuest of IQuest<ContractState> { | ||
fn get_reward(self: @ContractState) -> u32 { | ||
self.reward.read() | ||
} | ||
|
||
fn is_claimable( | ||
self: @ContractState, user: ContractAddress, calldata: Span<felt252> | ||
) -> bool { | ||
if self.claimed.read(user) { | ||
return false; | ||
} | ||
|
||
let coin_address_as_felt252: felt252 = *calldata.at(0); | ||
let coin = IUnruggableMemecoinDispatcher { | ||
contract_address: coin_address_as_felt252.try_into().unwrap() | ||
}; | ||
|
||
if coin.owner() != user { | ||
return false; | ||
} | ||
|
||
if coin.is_launched() != true { | ||
return false; | ||
} | ||
|
||
true | ||
} | ||
|
||
fn claim(ref self: ContractState, user: ContractAddress, calldata: Span<felt252>) -> u32 { | ||
assert(get_caller_address() == self.art_peace.read(), 'Only ArtPeace can claim quests'); | ||
|
||
assert(self.is_claimable(user, calldata), 'quest not claimable'); | ||
|
||
self.claimed.write(user, true); | ||
let reward = self.reward.read(); | ||
self.emit(QuestClaimed { user, reward, calldata }); | ||
|
||
reward | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.