ecadlabs / taquito

A library for building dApps on the Tezos Blockchain - JavaScript / TypeScript
https://taquito.io
Apache License 2.0
298 stars 116 forks source link

Error when setting the initial storage with annotation for a contract to be originated #1101

Closed claudebarde closed 2 years ago

claudebarde commented 3 years ago

When trying to originate this contract using Taquito, the expected formatting for pairs doesn't work: complex is a pair of type (pair nat string) whose fields are not annotated. One would expect the pair to be rendered as an array ([1, "test"]) or an object ({ 0: 1, 1: "test" }) but it doesn't work and produce an error. ExtractSchema returns the following:

{
  "simple": "int",
  "complex": {
    "1": "nat",
    "2": "string"
  },
  "optional": {
    "2": {
      "int": "int",
      "string": "string"
    },
    "3": {
      "int": "int",
      "string": "string"
    }
  },
  "last_checked_sig": {
    "msg": "bytes",
    "sender": "address",
    "sig_": "signature"
  }
}
michaelkernaghan commented 2 years ago

The link to the contract no longer works as BCD does not host granadanet anymore. It is available here: https://granadanet.tzkt.io/KT1T836HqhBu9waqmknStVDCXu2WogZtzsNz/code

michaelkernaghan commented 2 years ago

The contract exists on Hangzhounet: https://better-call.dev/hangzhou2net/KT1T2gL26SwYMxpkR5SZT1pHRBF84knfw8Cg/operations (

michaelkernaghan commented 2 years ago

the workaround was to add annotations, but the bug is about the behaviour when there are no annotations.

roxaneletourneau commented 2 years ago

The indexes returned by the extractSchema method were wrong. They did not match what was expected by the encodeObject method. It should have been:

...
"optional": {
    "3": {
      "int": "int",
      "string": "string"
    },
    "4": {
      "int": "int",
      "string": "string"
    }
  }
...