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

brick should allow referencing accounts by name #116

Open
aspiers opened this issue Feb 10, 2020 · 0 comments
Open

brick should allow referencing accounts by name #116

aspiers opened this issue Feb 10, 2020 · 0 comments
Labels
proposal UX Not bugs or features, but areas where the user/developer experience could be better

Comments

@aspiers
Copy link
Contributor

aspiers commented Feb 10, 2020

When testing with brick, it's common to want to create some accounts via inject, and then use those accounts as parameters to call or query, both for invoking the smart contract and for checking the results.

Currently brick seems to rely on the fact that the account hash is deterministically generated from the account name given. So you have to find out the hash by doing getstate <account_name> after the inject, and then manually copy the generated hash into the rest of the .brick file so that it's hardcoded. For example:

inject user1 10000000  
# Now we have to remember user1 has this address:
# Amg25cfD4ibjmjPYbtWnMKocrF147gJJxKy5uuFymEBNF2YiPwzr

deploy user1 0 myContract mycontract.lua

# call addUser with user1 as the first argument
call user1 0 myContract addUser `["Amg25cfD4ibjmjPYbtWnMKocrF147gJJxKy5uuFymEBNF2YiPwzr","User's name","24/10/1990"]`

# query getUserByName and check that it returns user1
query myContract getUserByName `["User's name"]` `{"address":"Amg25cfD4ibjmjPYbtWnMKocrF147gJJxKy5uuFymEBNF2YiPwzr","dateOfBirth":"24/10/1990"}`

If I'm wrong please let me know! If I'm right then this should at least be documented in the README, because it's not completely obvious (IMHO).

However it would be much easier to read and write if the account name identifier could be used instead of the hash, e.g. like this:

inject user1 10000000  # We don't need to know the account address :-)

deploy user1 0 myContract mycontract.lua

# call addUser with user1 as the first argument
call user1 0 myContract addUser `[user1,"User's name","24/10/1990"]`

# query getUserByName and check that it returns user1
query myContract getUserByName `["User's name"]` `{"address":user1,"dateOfBirth":"24/10/1990"}`
@aspiers aspiers added the UX Not bugs or features, but areas where the user/developer experience could be better label Feb 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal UX Not bugs or features, but areas where the user/developer experience could be better
Projects
None yet
Development

No branches or pull requests

1 participant