Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Tuple value validation for JSON objects always fail #5321

@nazarhussain

Description

@nazarhussain

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Currently the tuple value validation always return false if we pass a JSON object instead of array format.

Expected Behavior

If the JSON object is valid as per schema it should pass the validation.

Steps to Reproduce

const schema = [
  {
    components: [
      { internalType: 'string', name: 'name', type: 'string' },
      { internalType: 'address', name: 'addr', type: 'address' },
      {
        components: [
          { internalType: 'string', name: 'email', type: 'string' },
          { internalType: 'string', name: 'phone', type: 'string' },
        ],
        internalType: 'struct ABIV2UserDirectory.Contact',
        name: 'contact',
        type: 'tuple',
      },
    ],
    internalType: 'struct ABIV2UserDirectory.User',
    name: 'user',
    type: 'tuple',
  },
];

const data = [
  {
    name: 'Rick Sanchez',
    addr: '0xCB00CDE33a7a0Fba30C63745534F1f7Ae607076b',
    contact: {
      email: 'rick.c137@citadel.cfc',
      phone: '+1 (555) 314-1593',
    },
  },
];

validator.validate(schema, data)

Web3.js Version

4.x

Environment

N/A

Anything Else?

The tuple data format been specified by provider ABI specifications are the nested arrays. e.g. Above schema object can in ABI format should be. Our validator was written fully compliance to it. But in some cases the user can pass on the JSON object notation for the same data.

[['Rick Sanchez', '0xCB00CDE33a7a0Fba30C63745534F1f7Ae607076b', ['rick.c137@citadel.cfc', '+1 (555) 314-1593']]]

Metadata

Metadata

Assignees

Labels

BugAddressing a bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions