Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

fix(graphql): use warp TagParser to properly handle multi contract input tags #64

Merged
merged 4 commits into from
Nov 27, 2023

Conversation

atticusofsparta
Copy link
Collaborator

This uses warp-contract TagsParser to correctly fetch input tags in the event of multi-write interactions, those being smartweave interactions that are performing writes to more than one contract at once.

Currently there is an issue with ar-io.dev where graphql returns incorrectly ordered information in the node interface, specifically the tags interface, resulting in the incorrect interaction being identified in from the tags.

In this pr I set the gateway to arweave.net for testing, to see the differences in interactions fetching compare the following endpoints and to a search for setRecord while running the service locally on localhost:3000 :

You will notice api.arns.app returns references to 'setRecord' - if you take the ID's from those and do a search on localhost you will see the correct inputs for the interactions.

this demonstrates two things, the return difference between ar-io.dev and arweave.net from the graphql endpoint, but also mis-parsed tags.

to directly see the difference in graphql returns you can go to ar-io.dev/graphql and arweave.net/graphql respectively and run the following query:

query {
  transactions(first: 1, sort: HEIGHT_DESC
    ids:["7mQttmhoB4xEuaUX4paR12xgqlYo9Vxmpgk03wAvIUY"]
  )
  {
    
    pageInfo{
     hasNextPage
    }
    
    edges {
      cursor
      node {
        bundledIn {
          id
        }
        block {
          height
        }
        id
        owner {
              address
                }
        tags {
          name
          value
        }
      }
    }
  }
}

@atticusofsparta atticusofsparta requested a review from a team as a code owner November 24, 2023 19:08
@atticusofsparta atticusofsparta changed the title Add multi write support Fix(interactions route): Add multi contract write support Nov 24, 2023
src/api/graphql.ts Outdated Show resolved Hide resolved
@dtfiedler dtfiedler force-pushed the add-multi-write-support branch from 3ca02bb to 26d8b69 Compare November 27, 2023 14:09
@dtfiedler
Copy link
Collaborator

dtfiedler commented Nov 27, 2023

api.dev.arns.app/v1/contract/bLAgYxAdX2Ry-nt6aH2ixgvJXbpsEYm28NgJgyqfs-U with ar-io.dev.

{
"height": 1308614,
"input": {
"function": "setRecord",
"subDomain": "@",
"transactionId": {
"transactionId": "_zaE8Djb71W9YogzH1gMI9nAo0PuHATKcyrJiDhBG5M"
},
"ttlSeconds": 900
},
"owner": "7leENbll3b2aU6bB9rOMLSGLbmWGkMym2Hyz4m_Et2k",
"valid": false,
"error": "No function supplied or function not recognized: \"setRecord\"",
"id": "7mQttmhoB4xEuaUX4paR12xgqlYo9Vxmpgk03wAvIUY"
},

localhost with ar-io.dev:

{
"height": 1308614,
"input": {
"function": "setRecord",
"subDomain": "@",
"transactionId": {
"transactionId": "_zaE8Djb71W9YogzH1gMI9nAo0PuHATKcyrJiDhBG5M"
},
"ttlSeconds": 900
},
"owner": "7leENbll3b2aU6bB9rOMLSGLbmWGkMym2Hyz4m_Et2k",
"valid": false,
"error": "No function supplied or function not recognized: \"setRecord\"",
"id": "7mQttmhoB4xEuaUX4paR12xgqlYo9Vxmpgk03wAvIUY"
},

localhost with arweave.net:

{
"height": 1308614,
"input": {
"function": "setRecord",
"subDomain": "@",
"transactionId": {
"transactionId": "_zaE8Djb71W9YogzH1gMI9nAo0PuHATKcyrJiDhBG5M"
},
"ttlSeconds": 900
},
"owner": "7leENbll3b2aU6bB9rOMLSGLbmWGkMym2Hyz4m_Et2k",
"valid": false,
"id": "7mQttmhoB4xEuaUX4paR12xgqlYo9Vxmpgk03wAvIUY"
},

@atticusofsparta
Copy link
Collaborator Author

atticusofsparta commented Nov 27, 2023

@dtfiedler thats odd, none of the setRecord interactions before were applied - according to the tags, this shouldnt even be getting applied. Actually, this interaction should even been getting left in, our tags parser should pull them out - was that on this branch or another one?

@dtfiedler
Copy link
Collaborator

dtfiedler commented Nov 27, 2023

@atticusofsparta - updated, had to clear the cache and use arweave.net but we should only see the input that warp does evaluate.

@atticusofsparta
Copy link
Collaborator Author

@dtfiedler bizzare - running again myself, something seems off here.

@atticusofsparta
Copy link
Collaborator Author

@dtfiedler i had to update my .env file to point to arweave.net as well, when i do this is what i get for that txid

{
"height": 1308614,
"input": {
"function": "buyRecord",
"name": "lifestory",
"contractTxId": "pFEB75N-TgJtCKWrCjgnPw84-3LB-HXLsSivHfIX1es",
"type": "lease",
"auction": false
},
"owner": "7leENbll3b2aU6bB9rOMLSGLbmWGkMym2Hyz4m_Et2k",
"valid": false,
"id": "7mQttmhoB4xEuaUX4paR12xgqlYo9Vxmpgk03wAvIUY"
}

@dtfiedler
Copy link
Collaborator

ah yes - that was it!

@dtfiedler
Copy link
Collaborator

we can merge this so when the fix to ar-io.dev is put in it'll update with it

@dtfiedler dtfiedler changed the title Fix(interactions route): Add multi contract write support fix(graphql): use warp TagParser to properly handle multi contract input tags Nov 27, 2023
@atticusofsparta atticusofsparta merged commit 841843a into main Nov 27, 2023
6 checks passed
@atticusofsparta atticusofsparta deleted the add-multi-write-support branch November 27, 2023 15:29
@dtfiedler dtfiedler linked an issue Nov 27, 2023 that may be closed by this pull request
@dtfiedler
Copy link
Collaborator

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug(graphql): multiple input tags not processing correctly
2 participants