Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

Following ergotop tutorial does not work as expected #702

Closed
4katie opened this issue Oct 31, 2019 · 2 comments
Closed

Following ergotop tutorial does not work as expected #702

4katie opened this issue Oct 31, 2019 · 2 comments

Comments

@4katie
Copy link

4katie commented Oct 31, 2019

Describe the bug
Calling and instantiating contracts using call and send does not work.

To Reproduce
Follow the instructions:
https://github.com/accordproject/techdocs/blob/master/docs/ergo-cli.md#calling-contracts

Everything until call init() works perfectly fine.

ergo$ call volumediscount(VolumeDiscountRequest{ netAnnualChargeVolume : 0.1 })
returns:

Type error (at line 1 col 0). Function `volumediscount' expected argument `__state' to be of type `AccordContractState' but was given argument of type `Unit'.
call volumediscount(VolumeDiscountRequest{ netAnnualChargeVolume : 0.1 })
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Also,
send VolumeDiscountRequest{ netAnnualChargeVolume : 0.1 }

returns:

Type error (at line 1 col 0). Function `main' expected argument `__state' to be of type `AccordContractState' but was given argument of type `Unit'.
send VolumeDiscountRequest{ netAnnualChargeVolume : 0.1 }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expected behavior
Please see document for expected behavior:
https://github.com/accordproject/techdocs/blob/master/docs/ergo-cli.md#calling-contracts

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Linux
  • Ergotop version 0.20.0-beta.2

Additional context
Flagged in techdocs repo, PR#243 (accordproject/techdocs#243)

@jeromesimeon
Copy link
Member

This is a regression from 0.9.4:

Welcome to ERGOTOP version 0.9.4
ergo$ import org.accordproject.cicero.contract.*
ergo$ import org.accordproject.cicero.runtime.*
ergo$ import org.accordproject.volumediscount.*
ergo$ set contract VolumeDiscount over VolumeDiscountContract {firstVolume: 1.0, secondVolume: 10.0, firstRate: 3.0, secondRate: 2.9, thirdRate: 2.8, contractId: "0", parties: none }
ergo$ return state
Response. unit : Unit
ergo$ call init()
Response. unit : Unit
State. AccordContractState{stateId: "org.accordproject.cicero.contract.AccordContractState#1"} : AccordContractState
ergo$ return state
Response. AccordContractState{stateId: "org.accordproject.cicero.contract.AccordContractState#1"} : AccordContractState
ergo$ call volumediscount(VolumeDiscountRequest{ netAnnualChargeVolume : 0.1 })
Response. VolumeDiscountResponse{discountRate: 3.0} : VolumeDiscountResponse

@jeromesimeon
Copy link
Member

@4katie Thanks for the report.

Fixed in PR #711

Trace:

bash-3.2$ ./bin/ergotop ./examples/volumediscount/model/model.cto ./examples/volumediscount/logic/logic.ergo 
Welcome to ERGOTOP version 0.20.1
ergo$ import org.accordproject.cicero.contract.*
ergo$ import org.accordproject.volumediscount.*
ergo$ set contract VolumeDiscount over VolumeDiscountContract {firstVolume: 1.0, secondVolume: 10.0, firstRate: 3.0, secondRate: 2.9, thirdRate: 2.8, contractId: "0", parties: none }
ergo$ call init()
Response. unit : Unit
State. AccordContractState{stateId: "org.accordproject.cicero.contract.AccordContractState#1"} : AccordContractState
ergo$ call volumediscount(VolumeDiscountRequest{ netAnnualChargeVolume : 10.5 })
Response. VolumeDiscountResponse{discountRate: 2.8} : VolumeDiscountResponse
ergo$ send VolumeDiscountRequest{ netAnnualChargeVolume : 10.5 }
Response. VolumeDiscountResponse{discountRate: 2.8} : VolumeDiscountResponse
ergo$ 

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

No branches or pull requests

2 participants