Git Product home page Git Product logo

Comments (4)

3Nigma avatar 3Nigma commented on July 29, 2024

Also, when writing the above-suggested test, make sure the return is as expected. We might have some parsing issues on the receiving end.

from hashgraph-venin-js.

3Nigma avatar 3Nigma commented on July 29, 2024

Augmenting test to include a more urgent structure that we need to support:

struct NftBurn {
  address collectionAddress;
  int64[] serialNumbers;
}

with its reflection function to be tested:

function reflectNftBurns(NftBurn[] memory _nftBurns) public pure returns (NftBurn[] memory) {
  return _nftBurns;
}

mapping input param _nftBurns to JSON:

[
  {
    "name": "_nftBurns",
    "type": "tuple[]",
    "indexed": null,
    "components": [
      {
        "name": "collectionAddress",
        "type": "address",
        "indexed": null,
        "components": null,
        "arrayLength": null,
        "arrayChildren": null,
        "baseType": "address",
        "_isParamType": true
      },
      {
        "name": "serialNumbers",
        "type": "int64[]",
        "indexed": null,
        "components": null,
        "arrayLength": -1,
        "arrayChildren": {
          "name": null,
          "type": "int64",
          "indexed": null,
          "components": null,
          "arrayLength": null,
          "arrayChildren": null,
          "baseType": "int64",
          "_isParamType": true
        },
        "baseType": "array",
        "_isParamType": true
      }
    ],
    "arrayLength": -1,
    "arrayChildren": {
      "name": null,
      "type": "tuple",
      "indexed": null,
      "components": [
        {
          "name": "collectionAddress",
          "type": "address",
          "indexed": null,
          "components": null,
          "arrayLength": null,
          "arrayChildren": null,
          "baseType": "address",
          "_isParamType": true
        },
        {
          "name": "serialNumbers",
          "type": "int64[]",
          "indexed": null,
          "components": null,
          "arrayLength": -1,
          "arrayChildren": {
            "name": null,
            "type": "int64",
            "indexed": null,
            "components": null,
            "arrayLength": null,
            "arrayChildren": null,
            "baseType": "int64",
            "_isParamType": true
          },
          "baseType": "array",
          "_isParamType": true
        }
      ],
      "arrayLength": null,
      "arrayChildren": null,
      "baseType": "tuple",
      "_isParamType": true
    },
    "baseType": "array",
    "_isParamType": true
  }
]

and associated jest test:

it("calling a live-contract function with complex objects that have addresses as leafs should be permitted", async () => {
    const { liveContract } = await load("complex_struct_args");
    const nftBurns = [{
      collectionAddress: "",
      serialNumbers: [1, 3, 5, 10],
    }];

    await expect(liveContract.reflectNftBurns(nftBurns)).resolves.toEqual(
      nftBurns
    );
});

from hashgraph-venin-js.

3Nigma avatar 3Nigma commented on July 29, 2024

Things to pay attention to:

  • If input-param is of type 'address' and argument is solidity-addressable, try to use that if it's not solidity-addressable, use the argument as is
  • if input-param is of type 'bytes', yet arg is not Uint8Array, try to transform it (via 'arrayify')
  • if input-param is of a numeric type that exceeds 64, then try to convert it to BigNumber if it isn't already converted

from hashgraph-venin-js.

3Nigma avatar 3Nigma commented on July 29, 2024

Also, when writing the above-suggested test, make sure the return is as expected. We might have some parsing issues on the receiving end.

Will be handled by #96 . This ticket (#73) is only concerned with passing deep-nested object as smart contract method arguments.

from hashgraph-venin-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.