-
Notifications
You must be signed in to change notification settings - Fork 53
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
Outside imports #24
base: main
Are you sure you want to change the base?
Outside imports #24
Conversation
@psiemens :) This will be a small step for Jan's comment from before! If we do this, we can potentially have more complicated account setup steps in the emulator (after deploying the contract!) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this @mwufi! I've left some comments and suggestions
} | ||
|
||
// ReadWithAddresses loads a .cdc file with its addresses | ||
func ReadWithAddresses(filename string, addressMap map[string]string) []byte { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func ReadWithAddresses(filename string, addressMap map[string]string) []byte { | |
func readWithAddresses(filename string, addressMap map[string]string) []byte { |
I don't think this function needs to be exported
SetupAccountTransaction = "transactions/setup_account.cdc" | ||
SellItemTransaction = "transactions/sell_item.cdc" | ||
BuyItemTransaction = "transactions/buy_item.cdc" | ||
RemoveItemTransaction = "transactions/remove_item.cdc" | ||
CleanupItemTransaction = "transactions/cleanup_item.cdc" | ||
GetIDsScript = "scripts/read_storefront_ids.cdc" | ||
GetListingDetailsScript = "scripts/read_listing_details.cdc" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These variables don't need to be exported from the package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh @psiemens it's actually interesting here -- so my intention was to export these names, so that you can load up the scripts later with ReadWithAddresses
! Then you can do something similar to what's currently done in the test package (set up accounts, etc).
What's the idiomatic Flow way of doing that?
if !recognizedAddresses[importFile] { | ||
fmt.Printf("Did you mispell anything? Replacing '%s'...\n", importFile) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the purpose of the recognizedAddresses
map? Does it just check that. addressMap
doesn't contain an address that it doesn't recognize?
IMO you could simplify the code by removing this check -- this function is only called internally and I think it would actually be safer to assign "FungibleToken"
and "NonFungibleToken"
to constants that the top of this file to avoid spelling mistakes.
Co-authored-by: Peter Siemens <[email protected]>
Motivation
This allows NFT storefront code to be imported outside of this repo!
The
contracts
package is intentionally small - rather than relying onemulator
(like the test package here), we only make it so that it can load up the Cadence files. Then, the emulator will decide what to do with them.Test plan
Test loading of contracts
![image](https://user-images.githubusercontent.com/30219253/138167771-1a65d7bc-c7e1-4b51-a459-f00a5130f90f.png)
make test
in thelib/go/contracts
directoryExisting tests (in lib/go/test)
make test
in thelib/go/test
directory