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

RPC Query To Get Access Key Info Broken #210

Open
BenKurrek opened this issue Apr 4, 2023 · 2 comments
Open

RPC Query To Get Access Key Info Broken #210

BenKurrek opened this issue Apr 4, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@BenKurrek
Copy link

In the following code snippet, I attempt to get the access key information for the root account test.near but an error is thrown. (Full test here).

const network = 'sandbox';
let networkConfig = {
      networkId: 'localnet',
      viewAccountId: 'test.near',
      nodeUrl: rpcPort,
      walletUrl: `https://wallet.${network}.near.org`,
helperUrl: `https://helper.${network}.near.org`,
};

const keyStore =  new InMemoryKeyStore();
const near = new Near({
    ...networkConfig,
    keyStore,
    headers: {}
});

const signerId = "test.near";
const account = new Account(near.connection, signerId);
const { provider } = account.connection;

const key = await root.getKey();

const queryUrl = `access_key/${signerId}/${key!.getPublicKey().toString()}`;

const accessKey: any = await provider.query(
    queryUrl,
    ""
);
console.log(`accessKey: ${JSON.stringify(accessKey)}`)

This should return the access key information but instead, it throws an error:

Error (TypedError) {
    context: undefined,
    type: 'UntypedError',
    message: '[-32700] Parse error: Failed parsing args: invalid type: sequence, expected struct RpcQueryRequest',
  }

To reproduce this issue:

  1. clone https://github.com/keypom/trial-accounts
  2. checkout ben/workspaces-bug
  3. install deps
  4. run the test command yarn test
@BenKurrek BenKurrek added the bug Something isn't working label Apr 4, 2023
@volovyks
Copy link
Collaborator

volovyks commented Apr 5, 2023

@BenKurrek There is a lot of code that is complex and not relevant to the problem. Can you please write a separate 3 lines test that throws the same error?

@fospring
Copy link
Collaborator

fospring commented Sep 8, 2023

In the following code snippet, I attempt to get the access key information for the root account test.near but an error is thrown. (Full test here).

const network = 'sandbox';
let networkConfig = {
      networkId: 'localnet',
      viewAccountId: 'test.near',
      nodeUrl: rpcPort,
      walletUrl: `https://wallet.${network}.near.org`,
helperUrl: `https://helper.${network}.near.org`,
};

const keyStore =  new InMemoryKeyStore();
const near = new Near({
    ...networkConfig,
    keyStore,
    headers: {}
});

const signerId = "test.near";
const account = new Account(near.connection, signerId);
const { provider } = account.connection;

const key = await root.getKey();

const queryUrl = `access_key/${signerId}/${key!.getPublicKey().toString()}`;

const accessKey: any = await provider.query(
    queryUrl,
    ""
);
console.log(`accessKey: ${JSON.stringify(accessKey)}`)

This should return the access key information but instead, it throws an error:

Error (TypedError) {
    context: undefined,
    type: 'UntypedError',
    message: '[-32700] Parse error: Failed parsing args: invalid type: sequence, expected struct RpcQueryRequest',
  }

To reproduce this issue:

  1. clone https://github.com/keypom/trial-accounts
  2. checkout ben/workspaces-bug
  3. install deps
  4. run the test command yarn test

@BenKurrek I think you could replace

const accessKey: any = await provider.query(
    queryUrl,
    ""
);

to

    const accessKey: any = await provider.query({
        "request_type": "view_access_key",
            "finality": "final",
            "account_id": signerId,
            "public_key": key!.getPublicKey().toString()
        }
    );

according to the near rpc api of access-keys,which will pass the tests

@github-project-automation github-project-automation bot moved this to Backlog 🥶 in DevRel Jun 3, 2024
@thisisjoshford thisisjoshford removed this from DevRel Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants