Zenroom icon indicating copy to clipboard operation
Zenroom copied to clipboard

Move object with CODEC change

Open matteo-cristino opened this issue 2 years ago • 2 comments

As for the append

When I append the 'base58' of 'stuff_in_base58' to 'string'

a statement like

When I move the 'base58' of 'stuff_in_bas58' in 'table'

can be usefull. For example it can be used when creating a post for a restroom api where the data filed have to contain both some strings and some signatures.

Example of the current behaviour:

  • contract:
Scenario 'eddsa': key

Given I have a 'keyring'
and I have a 'string' named 'to_be_signed'

# sign
When I create the eddsa signature of 'to_be_signed'

# prepare post
When I create the 'string dictionary' named 'post'
and I create the 'string dictionary' named 'data'
and I move 'to_be_signed' in 'data'
and I move 'eddsa signature' in 'data'
and I move 'data' in 'post'

Then print the 'post'
  • data:
{
	"keyring": {
		"eddsa": "Cwj9CcqHNoBnXBo8iDfnhFkQeDun4Y4LStd2m3TEAYAg"
	},
	"to_be_signed": "some data to be signed"
}
  • result:
{
   "post": {
      "data": {
         "eddsa_signature": "U���\u0005;�\u0000\u0000�\u0016q�Ddވ�l)w.�E\u0011^d�1\"�\u0010\u0010ٝ\u0006�\u001b̮��\u0012��k]\u001aa��!�\u0005�\u0014�@����\u0014\u0000",
         "to_be_signed": "some data to be signed"
      }
   }
}

matteo-cristino avatar Mar 27 '23 13:03 matteo-cristino

En/coding (schema records in CODEC) should be done only in given and then blocks.

This should be implemented using:

Then I convert '<name>' in '<path>' as '<encoding>'

This also introduces a notion of path that can be . (dot) separated.

To have the path implemented we need to complete the coarse-grained CODEC by using deepmask() image

which is a primitive function already implemented in src/lua/zenroom_common.lua to convert a multi-dimensional table according to another one holding function pointers at same k/v positions.

jaromil avatar Mar 27 '23 14:03 jaromil

Since we want to create this statement now, how should we continue with this? What I see is that we can create

When I move the 'encoding' of 'encoded' in 'string_table'
When I move the 'encoding' of 'encoded' to 'string'

to follow the append statement

When I apend the 'encoding' of 'encoded' to 'string_table'

but they are not intuitive to me when you see it without the data When I move '' of '' in ''.

Another solution can be

When I move 'encoded' in 'string_table' as 'encoding'
When I move 'encoded' to 'string' as 'encoding'

Tha follows more the when I set '' to '' as '' idea

matteo-cristino avatar Mar 11 '24 10:03 matteo-cristino