Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON Parsed Encoding for Transactions #42

Open
kespinola opened this issue Nov 11, 2024 · 1 comment
Open

JSON Parsed Encoding for Transactions #42

kespinola opened this issue Nov 11, 2024 · 1 comment

Comments

@kespinola
Copy link
Collaborator

Goal

Add a catch all parser which mimics the response of getTransaction with jsonParsed.

Example Responses
{
  "jsonrpc": "2.0",
  "result": {
    "blockTime": 1731321264,
    "meta": {
      "computeUnitsConsumed": 11475,
      "err": null,
      "fee": 75200,
      "innerInstructions": [],
      "loadedAddresses": {
        "readonly": [],
        "writable": []
      },
      "logMessages": [
        "Program ComputeBudget111111111111111111111111111111 invoke [1]",
        "Program ComputeBudget111111111111111111111111111111 success",
        "Program SW1TCH7qEPTdLsDHRgPuMQjbQxKdH2aBStViMFnt64f invoke [1]",
        "Program log: Instruction: OracleHeartbeat",
        "Program SW1TCH7qEPTdLsDHRgPuMQjbQxKdH2aBStViMFnt64f consumed 11325 of 199850 compute units",
        "Program SW1TCH7qEPTdLsDHRgPuMQjbQxKdH2aBStViMFnt64f success"
      ],
      "postBalances": [
        2210015606326,
        9723120,
        223666560,
        5317440,
        1,
        1141440,
        3480000,
        147920642800
      ],
      "postTokenBalances": [],
      "preBalances": [
        2210015681526,
        9723120,
        223666560,
        5317440,
        1,
        1141440,
        3480000,
        147920642800
      ],
      "preTokenBalances": [],
      "rewards": [],
      "status": {
        "Ok": null
      }
    },
    "slot": 339285576,
    "transaction": {
      "message": {
        "accountKeys": [
          "2KgowxogBrGqRcgXQEmqFvC3PGtCu66qERNJevYW8Ajh",
          "PeRMnAqNqHQYHUuCBEjhm1XPeVTh4BxjY4t4TPan1pG",
          "dBufSqtKN59Whpq3oeh6pyxJm1yzpf9XJTTubTKVQtf",
          "EHZqEbjNhcdUvCTQCYqFhF6MT2kGbnCnmvJwNGned6eG",
          "ComputeBudget111111111111111111111111111111",
          "SW1TCH7qEPTdLsDHRgPuMQjbQxKdH2aBStViMFnt64f",
          "25EN3mJGXy8GbWYNKA4URZ6bexBVnoMZtRnr3jGAZ16S",
          "AfyPkH7o1QCMoHFgni6rmauyp1J3znzYTCspA2GoTSAr"
        ],
        "header": {
          "numReadonlySignedAccounts": 0,
          "numReadonlyUnsignedAccounts": 4,
          "numRequiredSignatures": 1
        },
        "instructions": [
          {
            "accounts": [],
            "data": "3HXqoEw4DSVM",
            "programIdIndex": 4,
            "stackHeight": null
          },
          {
            "accounts": [
              3,
              0,
              7,
              3,
              1,
              6,
              2
            ],
            "data": "8tcAnHrVvvsG",
            "programIdIndex": 5,
            "stackHeight": null
          }
        ],
        "recentBlockhash": "2aNDCWhroB82862jVZsN7efixLKKdWdCEFodvDufcfM3"
      },
      "signatures": [
        "5X38sZQWQCYpDDiRH7wRd7uqqJySXbptbCYr5NwgNjJq85ncR5JEnRyedZqFh3igzfvWhntWpNU6e8wJ6HsXxFpn"
      ]
    }
  },
  "id": 1
}
{
  "jsonrpc": "2.0",
  "result": {
    "blockTime": 1731321264,
    "meta": {
      "computeUnitsConsumed": 11475,
      "err": null,
      "fee": 75200,
      "innerInstructions": [],
      "logMessages": [
        "Program ComputeBudget111111111111111111111111111111 invoke [1]",
        "Program ComputeBudget111111111111111111111111111111 success",
        "Program SW1TCH7qEPTdLsDHRgPuMQjbQxKdH2aBStViMFnt64f invoke [1]",
        "Program log: Instruction: OracleHeartbeat",
        "Program SW1TCH7qEPTdLsDHRgPuMQjbQxKdH2aBStViMFnt64f consumed 11325 of 199850 compute units",
        "Program SW1TCH7qEPTdLsDHRgPuMQjbQxKdH2aBStViMFnt64f success"
      ],
      "postBalances": [
        2210015606326,
        9723120,
        223666560,
        5317440,
        1,
        1141440,
        3480000,
        147920642800
      ],
      "postTokenBalances": [],
      "preBalances": [
        2210015681526,
        9723120,
        223666560,
        5317440,
        1,
        1141440,
        3480000,
        147920642800
      ],
      "preTokenBalances": [],
      "rewards": [],
      "status": {
        "Ok": null
      }
    },
    "slot": 339285576,
    "transaction": {
      "message": {
        "accountKeys": [
          {
            "pubkey": "2KgowxogBrGqRcgXQEmqFvC3PGtCu66qERNJevYW8Ajh",
            "signer": true,
            "source": "transaction",
            "writable": true
          },
          {
            "pubkey": "PeRMnAqNqHQYHUuCBEjhm1XPeVTh4BxjY4t4TPan1pG",
            "signer": false,
            "source": "transaction",
            "writable": true
          },
          {
            "pubkey": "dBufSqtKN59Whpq3oeh6pyxJm1yzpf9XJTTubTKVQtf",
            "signer": false,
            "source": "transaction",
            "writable": true
          },
          {
            "pubkey": "EHZqEbjNhcdUvCTQCYqFhF6MT2kGbnCnmvJwNGned6eG",
            "signer": false,
            "source": "transaction",
            "writable": true
          },
          {
            "pubkey": "ComputeBudget111111111111111111111111111111",
            "signer": false,
            "source": "transaction",
            "writable": false
          },
          {
            "pubkey": "SW1TCH7qEPTdLsDHRgPuMQjbQxKdH2aBStViMFnt64f",
            "signer": false,
            "source": "transaction",
            "writable": false
          },
          {
            "pubkey": "25EN3mJGXy8GbWYNKA4URZ6bexBVnoMZtRnr3jGAZ16S",
            "signer": false,
            "source": "transaction",
            "writable": false
          },
          {
            "pubkey": "AfyPkH7o1QCMoHFgni6rmauyp1J3znzYTCspA2GoTSAr",
            "signer": false,
            "source": "transaction",
            "writable": false
          }
        ],
        "instructions": [
          {
            "accounts": [],
            "data": "3HXqoEw4DSVM",
            "programId": "ComputeBudget111111111111111111111111111111",
            "stackHeight": null
          },
          {
            "accounts": [
              "EHZqEbjNhcdUvCTQCYqFhF6MT2kGbnCnmvJwNGned6eG",
              "2KgowxogBrGqRcgXQEmqFvC3PGtCu66qERNJevYW8Ajh",
              "AfyPkH7o1QCMoHFgni6rmauyp1J3znzYTCspA2GoTSAr",
              "EHZqEbjNhcdUvCTQCYqFhF6MT2kGbnCnmvJwNGned6eG",
              "PeRMnAqNqHQYHUuCBEjhm1XPeVTh4BxjY4t4TPan1pG",
              "25EN3mJGXy8GbWYNKA4URZ6bexBVnoMZtRnr3jGAZ16S",
              "dBufSqtKN59Whpq3oeh6pyxJm1yzpf9XJTTubTKVQtf"
            ],
            "data": "8tcAnHrVvvsG",
            "programId": "SW1TCH7qEPTdLsDHRgPuMQjbQxKdH2aBStViMFnt64f",
            "stackHeight": null
          }
        ],
        "recentBlockhash": "2aNDCWhroB82862jVZsN7efixLKKdWdCEFodvDufcfM3"
      },
      "signatures": [
        "5X38sZQWQCYpDDiRH7wRd7uqqJySXbptbCYr5NwgNjJq85ncR5JEnRyedZqFh3igzfvWhntWpNU6e8wJ6HsXxFpn"
      ]
    }
  },
  "id": 1
}

Strategy

The parser should trigger for all programs. It should return all the same info user expected from jsonParsed. Since vixen provides instruction callbacks the acount info should be imbedded with the instruction.

    vixen::Runtime::builder()
        .instruction(Pipeline::new(SolanaRPCParser, [Handler]))
        .build(config)
        .run();
@kespinola
Copy link
Collaborator Author

As of now parser program ID is used to form the dragon's mouth subscription. For this parser the programs the user wants to subscribe to aren't known until build or runtime.

Consider expanding config or adding a pre-register phase to allow user to add additional filters to the dragons mouth subscription.

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

No branches or pull requests

1 participant