Skip to content

Commit

Permalink
feat(rpc): stx_getAddresses, closes LEA-1958
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranjamie committed Jan 23, 2025
1 parent 5df2687 commit 3179680
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/background/messaging/rpc-message-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ export async function rpcMessageHandler(message: WalletRequests, port: chrome.ru
break;
}

case 'stx_getAddresses': {

Check failure on line 65 in src/background/messaging/rpc-message-handler.ts

View workflow job for this annotation

GitHub Actions / typecheck

Type '"stx_getAddresses"' is not comparable to type '"open" | "signPsbt" | "signMessage" | "getInfo" | "getAddresses" | "sendTransfer" | "stx_signMessage" | "stx_signTransaction" | "openSwap" | "supportedMethods"'.
await rpcGetAddresses(message, port);
break;
}

default:
chrome.tabs.sendMessage(
getTabIdFromPort(port),
Expand Down
32 changes: 32 additions & 0 deletions src/background/messaging/rpc-methods/stx-get-addresses.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { RpcErrorCode, type StxGetAddressesRequest } from '@leather.io/rpc';

Check failure on line 1 in src/background/messaging/rpc-methods/stx-get-addresses.ts

View workflow job for this annotation

GitHub Actions / typecheck

'"@leather.io/rpc"' has no exported member named 'StxGetAddressesRequest'. Did you mean 'GetAddressesRequest'?

import { RouteUrls } from '@shared/route-urls';
import { makeRpcErrorResponse } from '@shared/rpc/rpc-methods';

import {
listenForPopupClose,
makeSearchParamsWithDefaults,
triggerRequestWindowOpen,
} from '../messaging-utils';
import { trackRpcRequestSuccess } from '../rpc-message-handler';

export async function rpcStxGetAddresses(
message: StxGetAddressesRequest,
port: chrome.runtime.Port
) {
const { urlParams, tabId } = makeSearchParamsWithDefaults(port, [['requestId', message.id]]);
const { id } = await triggerRequestWindowOpen(RouteUrls.RpcGetAddresses, urlParams);
void trackRpcRequestSuccess({ endpoint: message.method });

listenForPopupClose({
tabId,
id,
response: makeRpcErrorResponse('stx_getAddresses', {

Check failure on line 24 in src/background/messaging/rpc-methods/stx-get-addresses.ts

View workflow job for this annotation

GitHub Actions / typecheck

Argument of type '"stx_getAddresses"' is not assignable to parameter of type '"open" | "signPsbt" | "signMessage" | "getInfo" | "getAddresses" | "sendTransfer" | "stx_signMessage" | "stx_signTransaction" | "openSwap" | "supportedMethods"'.
id: message.id,
error: {
code: RpcErrorCode.USER_REJECTION,
message: 'User rejected request to get addresses',
},
}),
});
}

0 comments on commit 3179680

Please sign in to comment.