aeternity / aepp-calldata-js

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

Record type parameters is not encoding/decoding properly #155

Closed bogdan-manole closed 2 years ago

bogdan-manole commented 2 years ago

When I'm trying to make a call to a contract entrypoint that expects a parameter of record type, with fields of address type, I get an error complaining about the address format. Instead of the provided address, I get a different unintelligible sequence of UNICODE chars

For example the IAEX9 standard method :

  record allowance_accounts = {from_account : address,for_account : address}
  entrypoint allowance : (allowance_accounts) => option(int)

Calling your function errored: FateTypeError: Address should start with ak_, got �גv��e��Ց��2a�N~�e~S� �j instead

I created this snippet in order to isolate and reproduce the error

https://gist.github.com/bogdan-manole/8cb6db82edd5eca27e46ee31e47838dc

SDK version: 12.1.1 Aepp-calldata-js: 1.2.0 Node-JS: 16.14.2

marc0olo commented 2 years ago

@davidyuk is this calldata-lib problem or sdk problem? anyway, sounds like something we should fix asap 😅

bogdan-manole commented 2 years ago

@davidyuk is this calldata-lib problem or sdk problem? anyway, sounds like something we should fix asap 😅

I really don't know but the exception occurs at the aepp-calldata level. And I also did some debugging and the exception involves some calldata type encoding/deconding code.

Calling your function: allowance
Calling your function errored:  FateTypeError: Address should start with ak_, got �גv��e��Ց��2a�N~�e~S� �j instead
    at InternalMapper.toAddress (/Users/horus/aeternity/dex-contracts-v2/node_modules/@aeternity/aepp-calldata/src/Mapper/InternalMapper.js:48:19)
    at InternalMapper.toInternal (/Users/horus/aeternity/dex-contracts-v2/node_modules/@aeternity/aepp-calldata/src/Mapper/InternalMapper.js:25:25)
    at ExternalDataFactory.create (/Users/horus/aeternity/dex-contracts-v2/node_modules/@aeternity/aepp-calldata/src/ExternalDataFactory.js:11:44)
    at /Users/horus/aeternity/dex-contracts-v2/node_modules/@aeternity/aepp-calldata/src/DataFactory/RecordDataFactory.js:29:38
    at Array.map (<anonymous>)
    at RecordDataFactory.create (/Users/horus/aeternity/dex-contracts-v2/node_modules/@aeternity/aepp-calldata/src/DataFactory/RecordDataFactory.js:27:47)
    at ExternalDataFactory.create (/Users/horus/aeternity/dex-contracts-v2/node_modules/@aeternity/aepp-calldata/src/DataFactory/CompositeDataFactory.js:42:24)
    at ExternalDataFactory.create (/Users/horus/aeternity/dex-contracts-v2/node_modules/@aeternity/aepp-calldata/src/ExternalDataFactory.js:13:22)
    at /Users/horus/aeternity/dex-contracts-v2/node_modules/@aeternity/aepp-calldata/src/DataFactory/CompositeDataFactory.js:35:50
    at Array.map (<anonymous>) {
type: 'account_address'
}
kenodressel commented 2 years ago

@dincho could you have a look at this? :)

We did some additional testing: upgrading the calldata-lib from 1.1.1 to 1.2.0 creates this issue.