From 64ec1717363784002fe73713d464d8915456e7ad Mon Sep 17 00:00:00 2001 From: Guillaume Roux Date: Mon, 25 Nov 2024 14:07:29 +0100 Subject: [PATCH] Add `sol` to supported currency in `snap_getCurrencyRate` --- .../snaps-rpc-methods/src/permitted/getCurrencyRate.test.ts | 2 +- packages/snaps-rpc-methods/src/permitted/getCurrencyRate.ts | 4 ++-- packages/snaps-sdk/src/types/methods/get-currency-rate.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/snaps-rpc-methods/src/permitted/getCurrencyRate.test.ts b/packages/snaps-rpc-methods/src/permitted/getCurrencyRate.test.ts index da8191fcc4..ec854cb144 100644 --- a/packages/snaps-rpc-methods/src/permitted/getCurrencyRate.test.ts +++ b/packages/snaps-rpc-methods/src/permitted/getCurrencyRate.test.ts @@ -148,7 +148,7 @@ describe('snap_getCurrencyRate', () => { error: { code: -32602, message: - 'Invalid params: At path: currency -- Expected the value to satisfy a union of `literal`, but received: "eth".', + 'Invalid params: At path: currency -- Expected the value to satisfy a union of `literal | literal`, but received: "eth".', stack: expect.any(String), }, id: 1, diff --git a/packages/snaps-rpc-methods/src/permitted/getCurrencyRate.ts b/packages/snaps-rpc-methods/src/permitted/getCurrencyRate.ts index 99b57e721a..e23c104944 100644 --- a/packages/snaps-rpc-methods/src/permitted/getCurrencyRate.ts +++ b/packages/snaps-rpc-methods/src/permitted/getCurrencyRate.ts @@ -21,7 +21,7 @@ const hookNames: MethodHooksObject = { export type GetCurrencyRateMethodHooks = { /** * @param currency - The currency symbol. - * Currently only 'btc' is supported. + * Currently only 'btc' and 'sol' are supported. * @returns The {@link CurrencyRate} object. */ getCurrencyRate: (currency: AvailableCurrency) => CurrencyRate | undefined; @@ -38,7 +38,7 @@ export const getCurrencyRateHandler: PermittedHandlerExport< }; const GetCurrencyRateParametersStruct = object({ - currency: union([currency('btc')]), + currency: union([currency('btc'), currency('sol')]), }); export type GetCurrencyRateParameters = InferMatching< diff --git a/packages/snaps-sdk/src/types/methods/get-currency-rate.ts b/packages/snaps-sdk/src/types/methods/get-currency-rate.ts index bbd75a229e..6af9492283 100644 --- a/packages/snaps-sdk/src/types/methods/get-currency-rate.ts +++ b/packages/snaps-sdk/src/types/methods/get-currency-rate.ts @@ -2,7 +2,7 @@ export type Currency = | Lowercase | Uppercase; -export type AvailableCurrency = Currency<'btc'>; +export type AvailableCurrency = Currency<'btc'> | Currency<'sol'>; /** * The currency rate object.