Git Product home page Git Product logo

Comments (2)

saihaj avatar saihaj commented on August 28, 2024

can you share the ABI or the contract address?

from graph-tooling.

Aliceonly avatar Aliceonly commented on August 28, 2024

Thx for reply. Here's the function abi gened by solc 0.8.20:

  {
    "inputs": [
      {
        "internalType": "uint256[]",
        "name": "tokenIds",
        "type": "uint256[]"
      }
    ],
    "name": "getPositionsByTokenIds",
    "outputs": [
      {
        "components": [
          {
            "components": [
              {
                "components": [
                  {
                    "internalType": "uint256",
                    "name": "tokenId",
                    "type": "uint256"
                  },
                  {
                    "internalType": "contract IVault",
                    "name": "collateralTokenVault",
                    "type": "address"
                  },
                  {
                    "internalType": "address",
                    "name": "indexToken",
                    "type": "address"
                  },
                  {
                    "internalType": "bool",
                    "name": "isLong",
                    "type": "bool"
                  },
                  {
                    "internalType": "uint256",
                    "name": "giantTokenId",
                    "type": "uint256"
                  }
                ],
                "internalType": "struct Keys.PositionKeyInfo",
                "name": "keyInfo",
                "type": "tuple"
              },
              {
                "internalType": "uint256",
                "name": "giantTokenId",
                "type": "uint256"
              },
              {
                "internalType": "uint256",
                "name": "size",
                "type": "uint256"
              },
              {
                "internalType": "uint256",
                "name": "collateral",
                "type": "uint256"
              },
              {
                "internalType": "uint256",
                "name": "averagePrice",
                "type": "uint256"
              },
              {
                "internalType": "uint256",
                "name": "fundingPerSize",
                "type": "uint256"
              },
              {
                "internalType": "uint256",
                "name": "claimableFundingPerSize",
                "type": "uint256"
              },
              {
                "internalType": "uint256",
                "name": "accBorrowingRate",
                "type": "uint256"
              },
              {
                "internalType": "int256",
                "name": "realisedPnL",
                "type": "int256"
              },
              {
                "internalType": "uint256",
                "name": "shares",
                "type": "uint256"
              },
              {
                "internalType": "bool",
                "name": "isLong",
                "type": "bool"
              },
              {
                "components": [
                  {
                    "internalType": "uint256",
                    "name": "timestamp",
                    "type": "uint256"
                  },
                  {
                    "components": [
                      {
                        "internalType": "uint256",
                        "name": "min",
                        "type": "uint256"
                      },
                      {
                        "internalType": "uint256",
                        "name": "max",
                        "type": "uint256"
                      },
                      {
                        "internalType": "uint256",
                        "name": "blockNumber",
                        "type": "uint256"
                      },
                      {
                        "internalType": "uint256",
                        "name": "timestamp",
                        "type": "uint256"
                      }
                    ],
                    "internalType": "struct Market.Price",
                    "name": "collateralTokenPrice",
                    "type": "tuple"
                  },
                  {
                    "components": [
                      {
                        "internalType": "uint256",
                        "name": "min",
                        "type": "uint256"
                      },
                      {
                        "internalType": "uint256",
                        "name": "max",
                        "type": "uint256"
                      },
                      {
                        "internalType": "uint256",
                        "name": "blockNumber",
                        "type": "uint256"
                      },
                      {
                        "internalType": "uint256",
                        "name": "timestamp",
                        "type": "uint256"
                      }
                    ],
                    "internalType": "struct Market.Price",
                    "name": "indexTokenPrice",
                    "type": "tuple"
                  }
                ],
                "internalType": "struct Position.UpdateInfo",
                "name": "increasedInfo",
                "type": "tuple"
              },
              {
                "components": [
                  {
                    "internalType": "uint256",
                    "name": "timestamp",
                    "type": "uint256"
                  },
                  {
                    "components": [
                      {
                        "internalType": "uint256",
                        "name": "min",
                        "type": "uint256"
                      },
                      {
                        "internalType": "uint256",
                        "name": "max",
                        "type": "uint256"
                      },
                      {
                        "internalType": "uint256",
                        "name": "blockNumber",
                        "type": "uint256"
                      },
                      {
                        "internalType": "uint256",
                        "name": "timestamp",
                        "type": "uint256"
                      }
                    ],
                    "internalType": "struct Market.Price",
                    "name": "collateralTokenPrice",
                    "type": "tuple"
                  },
                  {
                    "components": [
                      {
                        "internalType": "uint256",
                        "name": "min",
                        "type": "uint256"
                      },
                      {
                        "internalType": "uint256",
                        "name": "max",
                        "type": "uint256"
                      },
                      {
                        "internalType": "uint256",
                        "name": "blockNumber",
                        "type": "uint256"
                      },
                      {
                        "internalType": "uint256",
                        "name": "timestamp",
                        "type": "uint256"
                      }
                    ],
                    "internalType": "struct Market.Price",
                    "name": "indexTokenPrice",
                    "type": "tuple"
                  }
                ],
                "internalType": "struct Position.UpdateInfo",
                "name": "decreasedInfo",
                "type": "tuple"
              }
            ],
            "internalType": "struct Position.Props",
            "name": "position",
            "type": "tuple"
          },
          {
            "internalType": "address",
            "name": "collateralToken",
            "type": "address"
          }
        ],
        "internalType": "struct Position.PositionInfo[][]",
        "name": "",
        "type": "tuple[][]"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },


It gens ts code:

getPositionsByTokenIds(
    tokenIds: Array<BigInt>
  ): Array<Reader__getPositionsByTokenIdsResultValue0Struct> {
    let result = super.call(
      "getPositionsByTokenIds",
      "getPositionsByTokenIds(uint256[]):((((uint256,address,address,bool,uint256),uint256,uint256,uint256,uint256,uint256,uint256,uint256,int256,uint256,bool,(uint256,(uint256,uint256,uint256,uint256),(uint256,uint256,uint256,uint256)),(uint256,(uint256,uint256,uint256,uint256),(uint256,uint256,uint256,uint256))),address)[][])",
      [ethereum.Value.fromUnsignedBigIntArray(tokenIds)]
    );

    return result[0].toTupleMatrix<>();
  }

  try_getPositionsByTokenIds(
    tokenIds: Array<BigInt>
  ): ethereum.CallResult<
    Array<Reader__getPositionsByTokenIdsResultValue0Struct>
  > {
    let result = super.tryCall(
      "getPositionsByTokenIds",
      "getPositionsByTokenIds(uint256[]):((((uint256,address,address,bool,uint256),uint256,uint256,uint256,uint256,uint256,uint256,uint256,int256,uint256,bool,(uint256,(uint256,uint256,uint256,uint256),(uint256,uint256,uint256,uint256)),(uint256,(uint256,uint256,uint256,uint256),(uint256,uint256,uint256,uint256))),address)[][])",
      [ethereum.Value.fromUnsignedBigIntArray(tokenIds)]
    );
    if (result.reverted) {
      return new ethereum.CallResult();
    }
    let value = result.value;
    return ethereum.CallResult.fromValue(value[0].toTupleMatrix<>());
  }

static error in return:

It is not possible to assign type "CallResult<Tuple[][]>" to type "CallResult<Reader__getPositionsByTokenIdsResultValue0Struct[]>". ]>".
  Type "Tuple[][]" cannot be assigned to type "Reader__getPositionsByTokenIdsResultValue0Struct[]". ts(2322)

from graph-tooling.

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.