Skip to content

Commit 385fe3d

Browse files
committed
fix: bugs
fix: bugs
1 parent afb7f7e commit 385fe3d

File tree

9 files changed

+23
-27
lines changed

9 files changed

+23
-27
lines changed

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@
221221
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
222222
"@notionhq/client": "^1.0.4",
223223
"@trivago/prettier-plugin-sort-imports": "^4.0.0",
224-
"@types/bitcore-lib": "^0.15.6",
225224
"@types/less": "^3.0.3",
226225
"@types/lodash": "^4.14.182",
227226
"@types/node-sass": "^4.11.2",

src/background/controller/provider/controller.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ class ProviderController extends BaseController {
181181
req.data.params.psbtHex = formatPsbtHex(psbtHex);
182182
}])
183183
signPsbt = async ({ data: { params: { psbtHex, options } }, approvalRes }) => {
184-
if (approvalRes?.signedPsbtHex) {
185-
return approvalRes.signedPsbtHex
184+
if (approvalRes && approvalRes.signed==true) {
185+
return approvalRes.psbtHex
186186
}
187187
const networkType = wallet.getNetworkType()
188188
const psbtNetwork = toPsbtNetwork(networkType)

src/background/controller/wallet.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ export class WalletController extends BaseController {
595595
signMessage = async (text: string) => {
596596
const account = preferenceService.getCurrentAccount();
597597
if (!account) throw new Error('no current account');
598-
return keyringService.signMessage(account.pubkey, text);
598+
return keyringService.signMessage(account.pubkey, account.type, text);
599599
};
600600

601601
signBIP322Simple = async (text: string) => {

src/background/service/keyring/index.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -570,8 +570,8 @@ class KeyringService extends EventEmitter {
570570
*
571571
* Attempts to sign the provided message parameters.
572572
*/
573-
signMessage = async (address: string, data: string) => {
574-
const keyring = await this.getKeyringForAccount(address);
573+
signMessage = async (address: string, keyringType: string, data: string) => {
574+
const keyring = await this.getKeyringForAccount(address, keyringType);
575575
const sig = await keyring.signMessage(address, data);
576576
return sig;
577577
};
@@ -861,6 +861,7 @@ class KeyringService extends EventEmitter {
861861
clearKeyrings = async (): Promise<void> => {
862862
// clear keyrings from memory
863863
this.keyrings = [];
864+
this.addressTypes = [];
864865
this.memStore.updateState({
865866
keyrings: []
866867
});

src/ui/pages/Account/CreateKeystoneWalletScreen.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,11 @@ function Step3({
133133
const navigate = useNavigate();
134134
const wallet = useWallet();
135135
const tools = useTools();
136-
const [addressType, setAddressType] = useState(AddressType.P2PKH);
136+
const [addressType, setAddressType] = useState(AddressType.P2WPKH);
137137
const addressTypes = useMemo(() => {
138-
return ADDRESS_TYPES.filter((item) => item.displayIndex < 4);
138+
return ADDRESS_TYPES.filter((item) => item.displayIndex < 4).sort((a, b) => a.displayIndex - b.displayIndex);
139139
}, []);
140+
140141
const [groups, setGroups] = useState<
141142
{ type: AddressType; address_arr: string[]; pubkey_arr: string[]; satoshis_arr: number[] }[]
142143
>([]);

src/ui/pages/Approval/components/SignPsbt/index.tsx

+7-7
Original file line numberDiff line numberDiff line change
@@ -588,14 +588,14 @@ export default function SignPsbt({
588588

589589
if (!handleConfirm) {
590590
handleConfirm = (res) => {
591-
if (res) {
592-
resolveApproval({
593-
// signed by hardware wallet
594-
signedPsbtHex: res.psbtHex
595-
});
596-
} else {
597-
resolveApproval();
591+
let signed = true;
592+
if (type === TxType.SIGN_TX && currentAccount.type !== KEYRING_TYPE.KeystoneKeyring) {
593+
signed = false;
598594
}
595+
resolveApproval({
596+
psbtHex: (res ?? txInfo).psbtHex,
597+
signed
598+
});
599599
};
600600
}
601601

src/ui/pages/BRC20/BRC20SendScreen.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,8 @@ function Step3({
410410
options: { autoFinalized: false }
411411
}
412412
}}
413-
handleConfirm={() => {
414-
pushOrdinalsTx(contextData.rawTxInfo.rawtx).then(({ success, txid, error }) => {
413+
handleConfirm={(res) => {
414+
pushOrdinalsTx(res ? res.rawtx : contextData.rawTxInfo.rawtx).then(({ success, txid, error }) => {
415415
if (success) {
416416
navigate('TxSuccessScreen', { txid });
417417
} else {

src/ui/state/transactions/hooks.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { useCallback, useMemo } from 'react';
22

3+
import { KEYRING_TYPE } from '@/shared/constant';
34
import { RawTxInfo, ToAddressInfo } from '@/shared/types';
45
import { useTools } from '@/ui/components/ActionComponent';
56
import { satoshisToAmount, satoshisToBTC, sleep, useWallet } from '@/ui/utils';
67
import { UnspentOutput } from '@unisat/wallet-sdk';
78
import { bitcoin } from '@unisat/wallet-sdk/lib/bitcoin-core';
89

9-
import { KEYRING_TYPE } from '@/shared/constant';
1010
import { AppState } from '..';
1111
import { useAccountAddress, useCurrentAccount } from '../accounts/hooks';
1212
import { accountActions } from '../accounts/reducer';
@@ -629,6 +629,7 @@ export function usePrepareSendRunesCallback() {
629629
const fetchUtxos = useFetchUtxosCallback();
630630
const assetUtxosRunes = useAssetUtxosRunes();
631631
const fetchAssetUtxosRunes = useFetchAssetUtxosRunesCallback();
632+
const account = useCurrentAccount();
632633
return useCallback(
633634
async ({
634635
toAddressInfo,
@@ -666,7 +667,8 @@ export function usePrepareSendRunesCallback() {
666667
assetUtxos
667668
});
668669
const psbt = bitcoin.Psbt.fromHex(psbtHex);
669-
const rawtx = psbt.extractTransaction().toHex();
670+
671+
const rawtx = account.type === KEYRING_TYPE.KeystoneKeyring ? '' : psbt.extractTransaction().toHex();
670672
dispatch(
671673
transactionsActions.updateRunesTx({
672674
rawtx,
@@ -686,7 +688,7 @@ export function usePrepareSendRunesCallback() {
686688
};
687689
return rawTxInfo;
688690
},
689-
[dispatch, wallet, fromAddress, utxos, assetUtxosRunes, fetchAssetUtxosRunes]
691+
[dispatch, wallet, fromAddress, utxos, assetUtxosRunes, fetchAssetUtxosRunes, account]
690692
);
691693
}
692694

yarn.lock

-7
Original file line numberDiff line numberDiff line change
@@ -2435,13 +2435,6 @@
24352435
dependencies:
24362436
bignumber.js "*"
24372437

2438-
"@types/bitcore-lib@^0.15.6":
2439-
version "0.15.6"
2440-
resolved "https://registry.yarnpkg.com/@types/bitcore-lib/-/bitcore-lib-0.15.6.tgz#6cbb5889e7fdb49e26d2a7e4e522275b1d03d449"
2441-
integrity sha512-CtKDBgSBubPXZ0wFeCiUCSdzH+cuy6nFya3FboOqf44evi+OmkQPqEg3ASMpmPDYE8vkcxV302Iu8lZqCjYieg==
2442-
dependencies:
2443-
"@types/node" "*"
2444-
24452438
"@types/bn.js@^5.1.0":
24462439
version "5.1.5"
24472440
resolved "https://registry.yarnpkg.com/@types/bn.js/-/bn.js-5.1.5.tgz#2e0dacdcce2c0f16b905d20ff87aedbc6f7b4bf0"

0 commit comments

Comments
 (0)