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

The broken example/lib #12

Closed
iokhotnikov opened this issue Oct 16, 2024 · 3 comments
Closed

The broken example/lib #12

iokhotnikov opened this issue Oct 16, 2024 · 3 comments

Comments

@iokhotnikov
Copy link

  1. The example does not work. I guess you should add .send() to each rpc call
  2. It can't find getParsedAccountInfo rpc method

package.json

{
  "name": "solana-stake-scripts",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "description": "",
  "packageManager": "[email protected]+sha512.831cf4c5f8b8374af71521d4d153db49d7086de615c2af7cb5e9d7eb8ba630ddac46fea495d643e552ef2e68a3aa99a3e5e9fbee8696702967504df5c59cb273",
  "dependencies": {
    "@anza-xyz/solana-rpc-get-stake-activation": "^1.0.1",
    "@solana/addresses": "2.0.0-rc.0",
    "@solana/rpc": "2.0.0-rc.0"
  }
}
import { createSolanaRpc } from "@solana/rpc";
import { getStakeActivation } from "@anza-xyz/solana-rpc-get-stake-activation";

const address = "25R5p1Qoe4BWW4ru7MQSNxxAzdiPN7zAunpCuF8q5iTz";

(async () => {
  const rpc = createSolanaRpc("https://api.testnet.solana.com");
  let status = await getStakeActivation(rpc, address);
  console.info(status);
})();

file:///solana-stake-scripts/node_modules/.pnpm/@anza-xyz[email protected]/node_modules/@anza-xyz/solana-rpc-get-stake-activation/dist/src/index.mjs:137
if (parsedData.value === null || parsedData.value.data instanceof Buffer) {
^

TypeError: Cannot read properties of undefined (reading 'data')
at getStakeAccount (file:///solana-stake-scripts/node_modules/.pnpm/@anza-xyz[email protected]/node_modules/@anza-xyz/solana-rpc-get-stake-activation/dist/src/index.mjs:137:53)
at file:///solana-stake-scripts/node_modules/.pnpm/@anza-xyz[email protected]/node_modules/@anza-xyz/solana-rpc-get-stake-activation/dist/src/index.mjs:194:29
at async Promise.all (index 1)
at async getStakeActivation (file:///solana-stake-scripts/node_modules/.pnpm/@anza-xyz[email protected]/node_modules/@anza-xyz/solana-rpc-get-stake-activation/dist/src/index.mjs:187:77)
at async file:///solana-stake-scripts/main.mjs:12:16

getParsedAccountInfo: SolanaError: JSON-RPC error: The method does not exist / is not available (Method not found)

const rpc = createSolanaRpc("https://api.testnet.solana.com");
  const slot = await rpc.getSlot().send();
  console.info(slot);
  const stakeAccountParsed = await rpc.getParsedAccountInfo(address).send();
  console.info(stakeAccountParsed);
joncinque added a commit to joncinque/solana-rpc-client-extensions that referenced this issue Oct 16, 2024
#### Problem

As mentioned at anza-xyz#12, it's unclear how to run the example.

#### Summary of changes

Add a corresponding package.json, making it possible to simply install
dependencies, build, and run the example.
joncinque added a commit to joncinque/solana-rpc-client-extensions that referenced this issue Oct 16, 2024
#### Problem

As mentioned at anza-xyz#12, it's unclear how to run the example.

#### Summary of changes

Add a corresponding package.json, making it possible to simply install
dependencies, build it, and run.
@joncinque
Copy link
Collaborator

The provided code mixes web3.js v1 and v2, so it won't work. Try to use all v1 or all v2, so either:

"dependencies": {
    "@anza-xyz/solana-rpc-get-stake-activation": "^2.0.0",
    "@solana/addresses": "2.0.0-rc.0",
    "@solana/rpc": "2.0.0-rc.0"
  }

With the example at https://github.com/anza-xyz/solana-rpc-client-extensions/tree/main/js/examples

Or

"dependencies": {
    "@anza-xyz/solana-rpc-get-stake-activation": "^1.0.1",
    "@solana/web3.js": "^1.95.3"
  }

With the example at https://github.com/anza-xyz/solana-rpc-client-extensions/blob/main/js-v1/examples/

I've put in some PRs to make the examples clearer to use.

joncinque added a commit that referenced this issue Oct 16, 2024
#### Problem

As mentioned at #12, it's unclear how to run the example.

#### Summary of changes

Add a corresponding package.json, making it possible to simply install
dependencies, build, and run the example.
joncinque added a commit that referenced this issue Oct 16, 2024
#### Problem

As mentioned at #12, it's unclear how to run the example.

#### Summary of changes

Add a corresponding package.json, making it possible to simply install
dependencies, build it, and run.
@iokhotnikov
Copy link
Author

@joncinque thanks!

@joncinque
Copy link
Collaborator

You're very welcome!

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

2 participants