aeternity / aepp-calldata-js

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

Implement decoding of contract state in state channels #200

Open davidyuk opened 1 year ago

davidyuk commented 1 year ago

https://github.com/aeternity/aepp-sdk-js/blob/9b4cee8636daf28931896ca6744c03e265fa78fb/test/integration/channel.ts#L1096

https://devchat.aeternity.com/channel/javascript-sdk?msg=n7NLQwvHnLSg7jWgq requested by @Kalovelo

davidyuk commented 1 year ago

contractState returned by channels.get.contract looks this way

{
  "ck_AABAf+tK": "cv_LwCs9rhl",
  "ck_AAEYQB5m": "cv_P4fvHVw="
}

for contract

contract Identity =
  entrypoint getArg(x : int) : int = x

I guess that ContractStoreKey (ck_) is an entry name in bytecode and ContractStoreValue (cv_) contains its value in binary form.

Support this should be useful for debugging, but this is out of the scope of sdk. I would redirect this issue to calldata or compiler.

dincho commented 1 year ago

Anyone interested can extend the ApiEncoder indeed.

davidyuk commented 1 year ago

To decode ck/cv into Uint8Arrays is relatively simple, but can we get this contract state in its types or how else can it be decoded?

dincho commented 1 year ago

I've to take a look if cv_ carries some type information