fix: clean up unnecessary nullable validations

This commit is contained in:
Justin Starry
2021-03-15 10:52:04 +08:00
committed by Justin Starry
parent 672e9c640f
commit d40dc06d6a

View File

@ -408,15 +408,20 @@ const SignatureStatusResult = pick({
err: TransactionErrorResult, err: TransactionErrorResult,
}); });
type Version = {
'solana-core': string,
'feature-set'?: number,
};
/** /**
* Version info for a node * Version info for a node
* *
* @typedef {Object} Version * @typedef {Object} Version
* @property {string} solana-core Version of solana-core * @property {string} solana-core Version of solana-core
*/ */
const Version = pick({ const VersionResult = pick({
'solana-core': string(), 'solana-core': string(),
'feature-set': optional(nullable(number())), 'feature-set': optional(number()),
}); });
type SimulatedTransactionResponse = { type SimulatedTransactionResponse = {
@ -777,7 +782,7 @@ const TokenAmountResult = pick({
amount: string(), amount: string(),
uiAmount: nullable(number()), uiAmount: nullable(number()),
decimals: number(), decimals: number(),
uiAmountString: optional(nullable(string())), uiAmountString: optional(string()),
}); });
/** /**
@ -808,7 +813,7 @@ const GetTokenLargestAccountsResult = jsonRpcResultAndContext(
amount: string(), amount: string(),
uiAmount: nullable(number()), uiAmount: nullable(number()),
decimals: number(), decimals: number(),
uiAmountString: optional(nullable(string())), uiAmountString: optional(string()),
}), }),
), ),
); );
@ -2375,7 +2380,7 @@ export class Connection {
*/ */
async getVersion(): Promise<Version> { async getVersion(): Promise<Version> {
const unsafeRes = await this._rpcRequest('getVersion', []); const unsafeRes = await this._rpcRequest('getVersion', []);
const res = create(unsafeRes, jsonRpcResult(Version)); const res = create(unsafeRes, jsonRpcResult(VersionResult));
if (res.error) { if (res.error) {
throw new Error('failed to get version: ' + res.error.message); throw new Error('failed to get version: ' + res.error.message);
} }