Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add template quest contract and check is_claimable #61

Merged

Conversation

mubarak23
Copy link
Contributor

  • issue #29
  • follows contribution guide
  • code change includes tests
  • breaking change
  • create template quest contract that implement IQuest trait
  • check the creator on templateMeta is equal to the user on is_claimable function

@mubarak23 mubarak23 requested a review from b-j-roberts as a code owner April 18, 2024 16:04
Copy link
Contributor

@b-j-roberts b-j-roberts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work so far, left some further thoughts.

If you can make those changes, get it to build, and then create a test for it, that would be awesome!


#[storage]
struct Storage {
art_peace: IArtPeaceDispatcher,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be better to store this as a ContractAddress and have a separate storage slot for ITemplateStoreDispatcher since you won't be using the IArtPeaceDispatcher for anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean having art_peace: ContractAddress ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's right

onchain/src/quests/template_quest.cairo Show resolved Hide resolved
onchain/src/quests/template_quest.cairo Outdated Show resolved Hide resolved
@mubarak23
Copy link
Contributor Author

if this contract is fine, i can proceed to start working on the test

@b-j-roberts
Copy link
Contributor

There may be some bugs or things, but yeah, I'd say the idea is there. You can go ahead with the tests 👍

Thanks!

@mubarak23
Copy link
Contributor Author

from my test, this line
self.art_peace.write( ITemplateStoreDispatcher { contract_address: init_params.art_peace });
returning error of "Type not found."

@mubarak23
Copy link
Contributor Author

mubarak23 commented Apr 20, 2024

is_claimable function accept calldata of type Span<felt252>, if we pull out templateId let template_id = calldata[0]; it is going to be of type felt252 and our self.templates.get_template(template_id); expect a type of u32, there is a mismatch here, should i refactor our template to collect felt252 @b-j-roberts

@mubarak23
Copy link
Contributor Author

should templates: LegacyMap::<u32, TemplateMetadata>, of TemplateStoreComponent Storage change to templates: LegacyMap::<felt252, TemplateMetadata>,

@mubarak23
Copy link
Contributor Author

from my test, this line self.art_peace.write( ITemplateStoreDispatcher { contract_address: init_params.art_peace }); returning error of "Type not found."

i was able to solved this by using Declare component! syntax

@mubarak23
Copy link
Contributor Author

mubarak23 commented Apr 20, 2024

from this context

let template_id_felt = calldata[0];

           let template_id: u32 = template_id_felt.try_into().unwrap();

           let template = self.templates.get_template(template_id);

template_id_felt is still throwing an error

Unexpected argument type. Expected: "core::integer::u32", found: "@core::felt252".

@b-j-roberts
Copy link
Contributor

b-j-roberts commented Apr 22, 2024

I'd prefer to keep template_id as u32. Try this let template_id_felt = *calldata.at(0); instead of calldata[0]

@mubarak23
Copy link
Contributor Author

this let template_id_felt = *calldata.at(0); work

@mubarak23
Copy link
Contributor Author

@b-j-roberts kindly review the test cases

@b-j-roberts b-j-roberts force-pushed the ft_add_template_quest branch from ce19dd8 to 5fdb074 Compare April 23, 2024 13:43
@b-j-roberts b-j-roberts merged commit 2dc9e5b into keep-starknet-strange:main Apr 23, 2024
3 checks passed
@b-j-roberts
Copy link
Contributor

Thank you for the work!

@mubarak23
Copy link
Contributor Author

Really, i learn a lot from this issue, looking forward to contributing to the project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants