feat: add support for getGenesisHash RPC (#19732)
This commit is contained in:
@ -2963,6 +2963,18 @@ export class Connection {
|
|||||||
return res.result;
|
return res.result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch the genesis hash
|
||||||
|
*/
|
||||||
|
async getGenesisHash(): Promise<string> {
|
||||||
|
const unsafeRes = await this._rpcRequest('getGenesisHash', []);
|
||||||
|
const res = create(unsafeRes, jsonRpcResult(string()));
|
||||||
|
if ('error' in res) {
|
||||||
|
throw new Error('failed to get genesis hash: ' + res.error.message);
|
||||||
|
}
|
||||||
|
return res.result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch a processed block from the cluster.
|
* Fetch a processed block from the cluster.
|
||||||
*/
|
*/
|
||||||
|
@ -2668,6 +2668,17 @@ describe('Connection', () => {
|
|||||||
expect(version['solana-core']).to.be.ok;
|
expect(version['solana-core']).to.be.ok;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('getGenesisHash', async () => {
|
||||||
|
await mockRpcResponse({
|
||||||
|
method: 'getGenesisHash',
|
||||||
|
params: [],
|
||||||
|
value: 'GH7ome3EiwEr7tu9JuTh2dpYWBJK3z69Xm1ZE3MEE6JC',
|
||||||
|
});
|
||||||
|
|
||||||
|
const genesisHash = await connection.getGenesisHash();
|
||||||
|
expect(genesisHash).not.to.be.empty;
|
||||||
|
});
|
||||||
|
|
||||||
it('request airdrop', async () => {
|
it('request airdrop', async () => {
|
||||||
const account = Keypair.generate();
|
const account = Keypair.generate();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user