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

En 7316 add call value sc query #2223

Merged
merged 8 commits into from
Aug 15, 2020

Conversation

bogdan-rosianu
Copy link
Contributor

@bogdan-rosianu bogdan-rosianu commented Aug 13, 2020

Added two optional parameters to API endpoint vm-values (caller and value) and extended the functionality in order to be able to include the the callerAddr and callValue inside the SC query service.

Testing steps:

  1. start a testnet
  2. make a POST request to API endpoint /vm-values/int for example in which you will specify the caller address and the call value. Can be a stake transaction.
  3. you should see the vm output in the response

@bogdan-rosianu bogdan-rosianu added the type:feature New feature or request label Aug 13, 2020
@bogdan-rosianu bogdan-rosianu self-assigned this Aug 13, 2020
@bogdan-rosianu bogdan-rosianu changed the base branch from master to development August 13, 2020 12:37
@@ -69,6 +69,7 @@ type NodeHandler interface {
// ApiResolver defines a structure capable of resolving REST API requests
type ApiResolver interface {
ExecuteSCQuery(query *process.SCQuery) (*vmcommon.VMOutput, error)
ExecuteQueryWithCallerAndValue(query *process.SCQuery, callerAddr []byte, callValue *big.Int) (*vmcommon.VMOutput, error)
Copy link
Contributor

Choose a reason for hiding this comment

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

change the SCQuery data - add callerAddr and callValue inside - no need to change the interface and add these values

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -42,26 +44,57 @@ func NewSCQueryService(

// ExecuteQuery returns the VMOutput resulted upon running the function on the smart contract
func (service *SCQueryService) ExecuteQuery(query *process.SCQuery) (*vmcommon.VMOutput, error) {
if query.ScAddress == nil {
return nil, process.ErrNilScAddress
err := checkQueryFields(query)
Copy link
Contributor

Choose a reason for hiding this comment

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

No need for second function. Use ExecuteQuery and fill the value and callerAddress as they were before if those are empty.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@raduchis raduchis self-requested a review August 14, 2020 14:34
Copy link
Contributor

@LucianMincu LucianMincu left a comment

Choose a reason for hiding this comment

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

System tests passed.

@LucianMincu LucianMincu merged commit 6387503 into development Aug 15, 2020
@LucianMincu LucianMincu deleted the EN-7316-add-call-value-sc-query branch August 15, 2020 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants