fix: rename getFinality to getConfirmationTime
This commit is contained in:
		@@ -60,7 +60,7 @@ declare module '@solana/web3.js' {
 | 
			
		||||
    ): Promise<SignatureStatus>;
 | 
			
		||||
    getTransactionCount(): Promise<number>;
 | 
			
		||||
    getLastId(): Promise<TransactionId>;
 | 
			
		||||
    getFinality(): Promise<number>;
 | 
			
		||||
    getConfirmationTime(): Promise<number>;
 | 
			
		||||
    requestAirdrop(
 | 
			
		||||
      to: PublicKey,
 | 
			
		||||
      amount: number,
 | 
			
		||||
 
 | 
			
		||||
@@ -130,9 +130,9 @@ const GetTransactionCountRpcResult = jsonRpcResult('number');
 | 
			
		||||
const GetLastId = jsonRpcResult('string');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Expected JSON RPC response for the "getFinality" message
 | 
			
		||||
 * Expected JSON RPC response for the "getConfirmationTime" message
 | 
			
		||||
 */
 | 
			
		||||
const GetFinalityRpcResult = jsonRpcResult('number');
 | 
			
		||||
const GetConfirmationTimeRpcResult = jsonRpcResult('number');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Expected JSON RPC response for the "requestAirdrop" message
 | 
			
		||||
@@ -333,11 +333,11 @@ export class Connection {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Return the current network finality time in millliseconds
 | 
			
		||||
   * Return the current cluster confirmation time in millliseconds
 | 
			
		||||
   */
 | 
			
		||||
  async getFinality(): Promise<number> {
 | 
			
		||||
    const unsafeRes = await this._rpcRequest('getFinality', []);
 | 
			
		||||
    const res = GetFinalityRpcResult(unsafeRes);
 | 
			
		||||
  async getConfirmationTime(): Promise<number> {
 | 
			
		||||
    const unsafeRes = await this._rpcRequest('getConfirmationTime', []);
 | 
			
		||||
    const res = GetConfirmationTimeRpcResult(unsafeRes);
 | 
			
		||||
    if (res.error) {
 | 
			
		||||
      throw new Error(res.error.message);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -123,13 +123,13 @@ test('get last Id', async () => {
 | 
			
		||||
  expect(lastId.length).toBeGreaterThanOrEqual(43);
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
test('get finality', async () => {
 | 
			
		||||
test('get confirmation time', async () => {
 | 
			
		||||
  const connection = new Connection(url);
 | 
			
		||||
 | 
			
		||||
  mockRpc.push([
 | 
			
		||||
    url,
 | 
			
		||||
    {
 | 
			
		||||
      method: 'getFinality',
 | 
			
		||||
      method: 'getConfirmationTime',
 | 
			
		||||
      params: [],
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
@@ -138,7 +138,7 @@ test('get finality', async () => {
 | 
			
		||||
    },
 | 
			
		||||
  ]);
 | 
			
		||||
 | 
			
		||||
  const finality = await connection.getFinality();
 | 
			
		||||
  const finality = await connection.getConfirmationTime();
 | 
			
		||||
  expect(finality).toBeGreaterThanOrEqual(0);
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user