aeternity / aepp-calldata-js

Aeternity data serialization library
ISC License
3 stars 4 forks source link

Update aecli to 4.1.0 #149

Closed davidyuk closed 2 years ago

davidyuk commented 2 years ago

depends on https://github.com/aeternity/aepp-cli-js/pull/194 and a new cli release and https://github.com/aeternity/aepp-cli-js/pull/196

dincho commented 2 years ago
➜  aepp-calldata-js git:(update_cli) npx aecli --version
4.1.0
➜  aepp-calldata-js git:(update_cli) bash -x ./tests/contract-call.sh test_empty
+ set -eu -o pipefail
+ CONTRACT_SRC=contracts/Test.aes
+ DESCRIPTOR_SRC=build/contracts/Test.json
+ WALLET_PATH=build/wallet
+ WALLET_PASS=123
+ CALLDATA='[]'
+ npx aecli account address -P 123 build/wallet
+ npx aecli account balance -P 123 build/wallet
+ '[' '!' -f build/contracts/Test.json ']'
+ contract_call test_empty
+ echo -n 'test_empty() -> '
test_empty() -> + npx aecli contract call --networkId ae_uat --password 123 --json --descrPath build/contracts/Test.json build/wallet test_empty
+ jq -r .result.returnValue
file:///Users/dincho/projects/aeternity/aepp-calldata-js/node_modules/@aeternity/aepp-sdk/es/contract/aci.mjs:75
  if (_aci == null) throw new MissingContractDefError();
                          ^

MissingContractDefError: Either ACI or source code is required
    at getContractInstance (file:///Users/dincho/projects/aeternity/aepp-calldata-js/node_modules/@aeternity/aepp-sdk/es/contract/aci.mjs:75:27)
    at AeSdk.methodWrapper [as getContractInstance] (file:///Users/dincho/projects/aeternity/aepp-calldata-js/node_modules/@aeternity/aepp-sdk/es/AeSdkBase.mjs:310:12)
    at Module.call (file:///Users/dincho/projects/aeternity/aepp-calldata-js/node_modules/@aeternity/aepp-cli/bin/actions/contract.mjs:144:30)
    at async Command.parseAsync (/Users/dincho/projects/aeternity/aepp-calldata-js/node_modules/commander/lib/command.js:917:5)
    at async runProgram (file:///Users/dincho/projects/aeternity/aepp-calldata-js/node_modules/@aeternity/aepp-cli/bin/utils/CliError.mjs:10:5)
    at async file:///Users/dincho/projects/aeternity/aepp-calldata-js/node_modules/@aeternity/aepp-cli/bin/aecli-contract.mjs:21:1

Something is not right, I see you started using a descriptor, however in build/contracts/Test.json there is usually an ACI see https://github.com/aeternity/aepp-calldata-js/blob/master/Makefile#L5

dincho commented 2 years ago

what about:

diff --git a/tests/contract-call.sh b/tests/contract-call.sh
index 01ced52..177b2c9 100755
--- a/tests/contract-call.sh
+++ b/tests/contract-call.sh
@@ -7,7 +7,7 @@ set -eu -o pipefail
 # contract-call.sh test_bool "[true, false]"

 CONTRACT_SRC="contracts/Test.aes"
-DESCRIPTOR_SRC="build/${CONTRACT_SRC//.aes/.json}"
+DESCRIPTOR_SRC="build/${CONTRACT_SRC//.aes/.desc.json}"
 WALLET_PATH="build/wallet"
 WALLET_PASS="123"
 # init() calldata
dincho commented 2 years ago

@davidyuk could you please address the above issue or I can take over the PR ?

davidyuk commented 2 years ago

Either ACI or source code is required

I can't reproduce this issue 🤔

$ rm -rf node_modules      
$ git stash --all                                      
$ npm i                   
$ bash -x ./tests/contract-call.sh test_empty           
+ set -eu -o pipefail
+ CONTRACT_SRC=contracts/Test.aes
+ DESCRIPTOR_SRC=build/contracts/Test.desc.json
+ WALLET_PATH=build/wallet
+ WALLET_PASS=123
+ CALLDATA='[]'
+ npx aecli account address -P 123 build/wallet
ENOENT: no such file or directory, open '/.../aepp-calldata-js/build/wallet'
++ npx aecli account create --json -P 123 build/wallet
++ jq -r .publicKey
+ ACCOUNT=ak_BGxKAcgfV5A8stdDatTjbghBqGdvEsSeJ9cw2c8FV3ajnHAha
+ curl -sS -X POST https://faucet.aepps.com/account/ak_BGxKAcgfV5A8stdDatTjbghBqGdvEsSeJ9cw2c8FV3ajnHAha
+ npx aecli account balance -P 123 build/wallet
+ '[' '!' -f build/contracts/Test.desc.json ']'
+ npx aecli contract deploy --json -P 123 --descrPath build/contracts/Test.desc.json --networkId ae_uat build/wallet --contractSource contracts/Test.aes '[]'
+ contract_call test_empty
+ echo -n 'test_empty() -> '
test_empty() -> + npx aecli contract call --networkId ae_uat --password 123 --json --descrPath build/contracts/Test.desc.json build/wallet test_empty
+ jq -r .result.returnValue
cb_AhzDreo=
$ bash -x ./tests/contract-call.sh test_empty 
+ set -eu -o pipefail
+ CONTRACT_SRC=contracts/Test.aes
+ DESCRIPTOR_SRC=build/contracts/Test.desc.json
+ WALLET_PATH=build/wallet
+ WALLET_PASS=123
+ CALLDATA='[]'
+ npx aecli account address -P 123 build/wallet
+ npx aecli account balance -P 123 build/wallet
+ '[' '!' -f build/contracts/Test.desc.json ']'
+ contract_call test_empty
+ echo -n 'test_empty() -> '
test_empty() -> + npx aecli contract call --networkId ae_uat --password 123 --json --descrPath build/contracts/Test.desc.json build/wallet test_empty
+ jq -r .result.returnValue
cb_AhzDreo=

however in build/contracts/Test.json there is usually an ACI

Are you proposing to switch to ACI from contract descriptor?

It is fine to me if you do a fine-tuning of this PR

dincho commented 2 years ago

I can't reproduce this issue

run make first, then the script

davidyuk commented 2 years ago
$ make                                       
./bin/aesophia_cli contracts/Test.aes -o build/contracts/Test.aeb
Compiled successfully!
Output written to: build/contracts/Test.aeb

./bin/aesophia_cli --create_json_aci contracts/Test.aes | jq . > build/contracts/Test.json
$ bash -x ./tests/contract-call.sh test_empty
+ set -eu -o pipefail
+ CONTRACT_SRC=contracts/Test.aes
+ DESCRIPTOR_SRC=build/contracts/Test.desc.json
+ WALLET_PATH=build/wallet
+ WALLET_PASS=123
+ CALLDATA='[]'
+ npx aecli account address -P 123 build/wallet
+ npx aecli account balance -P 123 build/wallet
+ '[' '!' -f build/contracts/Test.desc.json ']'
+ contract_call test_empty
+ echo -n 'test_empty() -> '
test_empty() -> + npx aecli contract call --networkId ae_uat --password 123 --json --descrPath build/contracts/Test.desc.json build/wallet test_empty
+ jq -r .result.returnValue
cb_AhzDreo=

works fine 🤷‍♀️ also I tried to run make tests before script

dincho commented 2 years ago

@davidyuk well, it seems you've updated the makefile and applied my patch to use a .desc suffix, which fixes it :)