Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sol to supported currency in snap_getCurrencyRate #2904

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions packages/snaps-rpc-methods/src/permitted/getCurrencyRate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const hookNames: MethodHooksObject<GetCurrencyRateMethodHooks> = {
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;
Expand All @@ -38,7 +38,7 @@ export const getCurrencyRateHandler: PermittedHandlerExport<
};

const GetCurrencyRateParametersStruct = object({
currency: union([currency('btc')]),
currency: union([currency('btc'), currency('sol')]),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does our getCurrencyRate RPC method only support such a limited subset of assets? I would assume we have a lot more rates available?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the RateController is pretty limited :(

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we not be using CAIP-19 for this API already?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can refactor to use CAIP-19 IDs

});

export type GetCurrencyRateParameters = InferMatching<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export type Currency<Value extends string> =
| Lowercase<Value>
| Uppercase<Value>;

export type AvailableCurrency = Currency<'btc'>;
export type AvailableCurrency = Currency<'btc'> | Currency<'sol'>;

/**
* The currency rate object.
Expand Down
Loading