Skip to content

Commit

Permalink
Merge branch 'dev' into feat/hide-balance
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianocola authored Aug 30, 2024
2 parents d1ba302 + e554376 commit 62e1f0c
Show file tree
Hide file tree
Showing 8 changed files with 385 additions and 46 deletions.
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
## [6.47.0](https://github.com/leather-io/extension/compare/v6.46.0...v6.47.0) (2024-08-28)


### Features

* add link and unlink mono script ([29f2174](https://github.com/leather-io/extension/commit/29f21741fa526358c5533caf4c0532559122f8f4))
* add mono link ui script ([717737c](https://github.com/leather-io/extension/commit/717737caa2d6d99d043f9d961af901a35a2be055))
* mock hiro ft requests ([6987609](https://github.com/leather-io/extension/commit/69876097a566263a25feecadfef24511b3ace0d4))
* mock nfts and txs hiro requests ([318378d](https://github.com/leather-io/extension/commit/318378d5ad0b3e2d6581517da6760de8e653d228))


### Bug Fixes

* disable brc-20 sends, ref leather-io/issues[#5773](https://github.com/leather-io/extension/issues/5773) ([aafd992](https://github.com/leather-io/extension/commit/aafd99216fd161321a35be33c52d50ca8a17768e))
* rename dialog as sheet, closes ref leather-io/issues[#268](https://github.com/leather-io/extension/issues/268) ([ec64755](https://github.com/leather-io/extension/commit/ec64755288ae61b256bfc0f8d3988511d51c3d17))


### Internal

* add open API, ref leather-io/issues[#5800](https://github.com/leather-io/extension/issues/5800) ([3df62f7](https://github.com/leather-io/extension/commit/3df62f72659b172dadef1c0dd89189f285326b3b))
* icons using ui lib svgs, closes leather-io/issues[#123](https://github.com/leather-io/extension/issues/123) ([3e8314e](https://github.com/leather-io/extension/commit/3e8314ea8bfc4b7ce4b2550b23531b42fe3a0f36))
* post-release merge back ([56d021b](https://github.com/leather-io/extension/commit/56d021bbca81ffbc8bfc0156a609a82f07d1ad0d))
* show BRC-20 tokens on ledger, ref [#5797](https://github.com/leather-io/extension/issues/5797) ([bcc40f7](https://github.com/leather-io/extension/commit/bcc40f775338c1c3d7378da1fd7d3ac4cf8ef4f4))

## [6.46.0](https://github.com/leather-io/extension/compare/v6.45.2...v6.46.0) (2024-08-26)


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@leather.io/extension",
"description": "Leather is a browser extension for interacting with Stacks apps",
"private": true,
"version": "6.46.0",
"version": "6.47.0",
"packageManager": "[email protected]",
"author": {
"name": "Leather Wallet LLC"
Expand Down
350 changes: 305 additions & 45 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

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 @@ -7,6 +7,7 @@ import { rpcSignStacksTransaction } from '@background/messaging/rpc-methods/sign

import { getTabIdFromPort } from './messaging-utils';
import { rpcGetAddresses } from './rpc-methods/get-addresses';
import { rpcOpen } from './rpc-methods/open';
import { rpcSendTransfer } from './rpc-methods/send-transfer';
import { rpcSignMessage } from './rpc-methods/sign-message';
import { rpcSignPsbt } from './rpc-methods/sign-psbt';
Expand All @@ -15,6 +16,10 @@ import { rpcSupportedMethods } from './rpc-methods/supported-methods';

export async function rpcMessageHandler(message: WalletRequests, port: chrome.runtime.Port) {
switch (message.method) {
case 'open': {
await rpcOpen(message, port);
break;
}
case 'getAddresses': {
await rpcGetAddresses(message, port);
break;
Expand Down
30 changes: 30 additions & 0 deletions src/background/messaging/rpc-methods/open.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { RpcErrorCode } from '@btckit/types';

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

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

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

listenForPopupClose({
tabId,
id,
response: makeRpcErrorResponse('open', {
id: message.id,
error: {
code: RpcErrorCode.USER_REJECTION,
message: 'User rejected request to open wallet',
},
}),
});
}
4 changes: 4 additions & 0 deletions src/background/messaging/rpc-methods/supported-methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ export function rpcSupportedMethods(message: SupportedMethodsRequest, port: chro
result: {
documentation: 'https://leather.gitbook.io/developers/home/welcome',
methods: [
{
name: 'open',
docsUrl: ['https://leather.gitbook.io/developers/bitcoin/connect-users/open'],
},
{
name: 'getAddresses',
docsUrl: [
Expand Down
14 changes: 14 additions & 0 deletions src/shared/rpc/methods/open.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { DefineRpcMethod, RpcRequest, RpcResponse } from '@btckit/types';
import * as yup from 'yup';

const rpcOpenParamsSchema = yup.object().shape({
url: yup.string(),
});

type OpenRequestParams = yup.InferType<typeof rpcOpenParamsSchema>;

export type OpenRequest = RpcRequest<'open', OpenRequestParams>;

type OpenResponse = RpcResponse<Response>;

export type Open = DefineRpcMethod<OpenRequest, OpenResponse>;
2 changes: 2 additions & 0 deletions src/shared/rpc/rpc-methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import type { ValueOf } from '@leather.io/models';

import { SignStacksTransaction } from '@shared/rpc/methods/sign-stacks-transaction';

import { Open } from './methods/open';
import { SignPsbt } from './methods/sign-psbt';
import { SignStacksMessage } from './methods/sign-stacks-message';
import { SupportedMethods } from './methods/supported-methods';

// Supports BtcKit methods, as well as custom Leather methods
export type WalletMethodMap = BtcKitMethodMap &
Open &
SupportedMethods &
SignPsbt &
SignStacksTransaction &
Expand Down

0 comments on commit 62e1f0c

Please sign in to comment.