fix: correct return type of getFeeForMessage (#30004)

* fix: correct return type of getFeeForMessage

* chore: get rid of useless typecast
This commit is contained in:
Steven Luscher 2023-01-30 23:10:38 -08:00 committed by GitHub
parent 6489c20de5
commit 1064bcbf72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -4452,7 +4452,7 @@ export class Connection {
async getFeeForMessage( async getFeeForMessage(
message: VersionedMessage, message: VersionedMessage,
commitment?: Commitment, commitment?: Commitment,
): Promise<RpcResponseAndContext<number>> { ): Promise<RpcResponseAndContext<number | null>> {
const wireMessage = toBuffer(message.serialize()).toString('base64'); const wireMessage = toBuffer(message.serialize()).toString('base64');
const args = this._buildArgs([wireMessage], commitment); const args = this._buildArgs([wireMessage], commitment);
const unsafeRes = await this._rpcRequest('getFeeForMessage', args); const unsafeRes = await this._rpcRequest('getFeeForMessage', args);
@ -4464,7 +4464,7 @@ export class Connection {
if (res.result === null) { if (res.result === null) {
throw new Error('invalid blockhash'); throw new Error('invalid blockhash');
} }
return res.result as unknown as RpcResponseAndContext<number>; return res.result;
} }
/** /**

View File

@ -585,7 +585,7 @@ export class Transaction {
/** /**
* Get the estimated fee associated with a transaction * Get the estimated fee associated with a transaction
*/ */
async getEstimatedFee(connection: Connection): Promise<number> { async getEstimatedFee(connection: Connection): Promise<number | null> {
return (await connection.getFeeForMessage(this.compileMessage())).value; return (await connection.getFeeForMessage(this.compileMessage())).value;
} }