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

feat: Contract read & write #872

Merged
merged 138 commits into from
Sep 2, 2024
Merged

feat: Contract read & write #872

merged 138 commits into from
Sep 2, 2024

Conversation

janmichek
Copy link
Collaborator

@janmichek janmichek commented Jul 31, 2024

Description

resolves #254
resolves #256

Demo

firefox_jVaQW0PNfH.mp4

Checklist:

  • I have read and followed the Contributing Guide
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

Copy link

@janmichek
Copy link
Collaborator Author

Testing notes for @Liubov-crypto

go to https://studio.aepps.com/ and deploy some contracts to testnet
do the verification in this PR preview on testnet. Select 7.4.0
go to verified contract detail, now you can access read actions
write actions cannot be verified, given the current limitations

@janmichek janmichek requested a review from Liubov-crypto July 31, 2024 14:05
@janmichek
Copy link
Collaborator Author

@Liubov-crypto And I found a way to test the write actions. Can you create new Superhero wallet account and send me the seed?

@Liubov-crypto
Copy link

I was getting an issue when tried to verify the smart contract.
For example I've used:
ct_svN4AGuUh2EJK4WfFQvY39Vpzd7awqmEZiFMybNG9t9gaSp98

ver

@janmichek
Copy link
Collaborator Author

I was getting an issue when tried to verify the smart contract. For example I've used: ct_svN4AGuUh2EJK4WfFQvY39Vpzd7awqmEZiFMybNG9t9gaSp98

ver

What was the code of this contract? Is it some sample contract from aestudio?

@Liubov-crypto
Copy link

https://studio.aepps.com/

yes, from aestudio

@janmichek
Copy link
Collaborator Author

https://studio.aepps.com/

yes, from aestudio

None of the contracts from aestudio cannot be verified or just some of them?

@Liubov-crypto
Copy link

https://studio.aepps.com/

yes, from aestudio

None of the contracts from aestudio cannot be verified or just some of them?

I tried a couple but was not working for me

@janmichek
Copy link
Collaborator Author

Here I deployed some contracts:
I deployed the contracts on behalf of your account. (That's why I needed the seed phrase.)
That makes you deployer and owner of those contracts.
And that enables you to do write actions.

hamster
ct_v5cSYQvkaq5oSKK4BTNBMgptRJSUC57DYwSjgEdGP5oi6Y7ia
ct_JHVDvxUwSNiZDiMEqpjSF15gwPVvqRz2xXqf2vqw8aD76noSf

AeForUsers
ct_22MwK52FbUYi82fQoCBP5ZVU2H8fsY5Ujg8YU356o7BuwLTbY
ct_vtmQYHDzdxGigZD6VeXSgu2Df1XviBSVDRVssZz9bBYVKkXbf

AeUnlockOnTime
ct_p8pcM6H8rdMnHUesw9fskRCFSCs428jthdkwjYyf8sPwr8oxp
ct_vwDoPiv8nohvvW6gER1VrEUqaw21U9Mw4xJ2dmXYxQDAvnAcw

scenario:
Only test testnet of this feature.

Switch the wallet for the account to which you send me the seed

Verify contract (ae studio examples + contract ids above)

goto verified contract detail

go to Write tab

connect wallet, follow instructions

execute write actions

  • Another testing scenario is that if you want to access Write actions with connected wallet of the user who is NOT deployer of the contracts, then the Write actions should not be accessible (UI is grayed out) @Liubov-crypto

@Liubov-crypto
Copy link

Got issue with verification again:

2024-08-12.5.59.29.mov

@Liubov-crypto
Copy link

Finally I've managed to verify at least one contract from the list above: ct_JHVDvxUwSNiZDiMEqpjSF15gwPVvqRz2xXqf2vqw8aD76noSf

but when I followed steps attached in video I got an issue: the page became grey and some issues in console, @janmichek could you check it please:

2024-08-13.6.11.12.mov

1
2

3

@janmichek
Copy link
Collaborator Author

Finally I've managed to verify at least one contract from the list above: ct_JHVDvxUwSNiZDiMEqpjSF15gwPVvqRz2xXqf2vqw8aD76noSf

but when I followed steps attached in video I got an issue: the page became grey and some issues in console, @janmichek could you check it please:
2024-08-13.6.11.12.mov

1 2

3

@Liubov-crypto please retry now

@Liubov-crypto
Copy link

@janmichek There are some issues again: UnsupportedVersionError: Unsupported node version 7.1.0. Supported: >= 6.2.0 < 7.0.0, please check it

2024-08-15.4.12.18.mov

err node

@janmichek
Copy link
Collaborator Author

janmichek commented Aug 20, 2024

@janmichek There are some issues again: UnsupportedVersionError: Unsupported node version 7.1.0. Supported: >= 6.2.0 < 7.0.0, please check it
2024-08-15.4.12.18.mov

err node

Fixed. You can go ahead and continue with review. The test is not passing but i will solve it in parallel. @Liubov-crypto

Comment on lines 50 to 51
const connectedAddress = walletSdk ? Object.keys(walletSdk._accounts.current)[0] : null
return !walletSdk || contractDetails.value.createdBy !== connectedAddress
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const connectedAddress = walletSdk ? Object.keys(walletSdk._accounts.current)[0] : null
return !walletSdk || contractDetails.value.createdBy !== connectedAddress
return !walletSdk

This is not an obvious restriction, contract should manage permissions by itself

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

right, fixed

@davidyuk
Copy link
Member

For some reason I can't call init function of ct_HzBhnwxXg2zsPAmpX6ppoJNA5q1oojn8ZL2AsWozRxuBFERWD on testnet
Screenshot 2024-08-28 at 13 06 57

@davidyuk
Copy link
Member

Does it make sense to accept arguments as JSON? I have a contract ct_24UQuk4JbCY2QhxnWvG257CBpirCvoCudXgLFj1MUaedKovUuX on testnet and I can't call its function currently
Screenshot 2024-08-28 at 13 10 04

Consider to combine "read contract" and "write contract" tabs.

@janmichek
Copy link
Collaborator Author

ct_HzBhnwxXg2zsPAmpX6ppoJNA5q1oojn8ZL2AsWozRxuBFERWD

Intereseting, I didn't find such a contract on testnet or mainnet. Could you send me the source code, please? I will verify it

@janmichek
Copy link
Collaborator Author

For some reason I can't call init function of ct_HzBhnwxXg2zsPAmpX6ppoJNA5q1oojn8ZL2AsWozRxuBFERWD on testnet Screenshot 2024-08-28 at 13 06 57

Yeah, I think that the init function should not be on the list at all. I filtered it out

@Liubov-crypto
Copy link

  1. I've verified ct_JHVDvxUwSNiZDiMEqpjSF15gwPVvqRz2xXqf2vqw8aD76noSf and I've putted 11 and 22 into add_test_value
    and 2 and 3 into statefully_add_two.

when I rechecked it on Read contract I got in read_test_value 5 as sum 2 and 3, and 33 in locally_add_two. are these numbers correct for the following fields? for me it looks like they switched.

2024-08-30.6.12.22.mov
  1. also I've verified https://pr-872-aescan-testnet.stg.service.aepps.com/contracts/ct_p8pcM6H8rdMnHUesw9fskRCFSCs428jthdkwjYyf8sPwr8oxp?type=contract-write but can't see read contract fields, also new fields on write contract. is it correct?
2024-08-30.6.27.25.mov
  1. when I switched between contract tabs wallet got disconnected.

@janmichek
Copy link
Collaborator Author

janmichek commented Sep 2, 2024

ct I got in read_test_value 5 as sum 2 and 3, and 33 in locally_add_two. are these numbers correct for the following fields? for me it looks like they switched.

Thanks for the review

  1. It's correct like that. It depends on the order of the actions you run.
  2. also correct, this contract has only writeable entrypoints
  3. interesting. I cannot replicate the issue. Can you send a video to me, please? @Liubov-crypto

Copy link

@Liubov-crypto Liubov-crypto left a comment

Choose a reason for hiding this comment

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

I was not able to reproduce ad 3 today.

The rest is LGTM

@janmichek janmichek merged commit f5a0f80 into develop Sep 2, 2024
4 checks passed
@janmichek janmichek deleted the contract-read branch September 2, 2024 16:37
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.

Smart contract interaction: write Smart Contract interaction: read
4 participants