Skip to content

Commit ca13873

Browse files
committed
Merge branch 'develop'
2 parents 700fa45 + 95b83f1 commit ca13873

File tree

103 files changed

+5425
-575
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+5425
-575
lines changed

apps/extension/package.json

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@keplr-wallet/extension",
3-
"version": "0.12.214",
3+
"version": "0.12.215-rc.0",
44
"author": "chainapsis",
55
"license": "Apache-2.0",
66
"private": true,
@@ -26,33 +26,33 @@
2626
"@ethersproject/transactions": "^5.7.0",
2727
"@floating-ui/react": "^0.23.0",
2828
"@floating-ui/react-dom": "^1.3.0",
29-
"@keplr-wallet/analytics": "0.12.214",
30-
"@keplr-wallet/background": "0.12.214",
31-
"@keplr-wallet/chain-validator": "0.12.214",
32-
"@keplr-wallet/common": "0.12.214",
33-
"@keplr-wallet/cosmos": "0.12.214",
34-
"@keplr-wallet/crypto": "0.12.214",
35-
"@keplr-wallet/hooks": "0.12.214",
36-
"@keplr-wallet/hooks-bitcoin": "0.12.214",
37-
"@keplr-wallet/hooks-internal": "0.12.214",
38-
"@keplr-wallet/hooks-starknet": "0.12.214",
39-
"@keplr-wallet/ledger-cosmos": "0.12.214",
40-
"@keplr-wallet/popup": "0.12.214",
41-
"@keplr-wallet/proto-types": "0.12.214",
42-
"@keplr-wallet/provider": "0.12.214",
43-
"@keplr-wallet/router": "0.12.214",
44-
"@keplr-wallet/router-extension": "0.12.214",
45-
"@keplr-wallet/simple-fetch": "0.12.214",
46-
"@keplr-wallet/stores": "0.12.214",
47-
"@keplr-wallet/stores-bitcoin": "0.12.214",
48-
"@keplr-wallet/stores-core": "0.12.214",
49-
"@keplr-wallet/stores-etc": "0.12.214",
50-
"@keplr-wallet/stores-eth": "0.12.214",
51-
"@keplr-wallet/stores-ibc": "0.12.214",
52-
"@keplr-wallet/stores-internal": "0.12.214",
53-
"@keplr-wallet/stores-starknet": "0.12.214",
54-
"@keplr-wallet/types": "0.12.214",
55-
"@keplr-wallet/unit": "0.12.214",
29+
"@keplr-wallet/analytics": "0.12.215-rc.0",
30+
"@keplr-wallet/background": "0.12.215-rc.0",
31+
"@keplr-wallet/chain-validator": "0.12.215-rc.0",
32+
"@keplr-wallet/common": "0.12.215-rc.0",
33+
"@keplr-wallet/cosmos": "0.12.215-rc.0",
34+
"@keplr-wallet/crypto": "0.12.215-rc.0",
35+
"@keplr-wallet/hooks": "0.12.215-rc.0",
36+
"@keplr-wallet/hooks-bitcoin": "0.12.215-rc.0",
37+
"@keplr-wallet/hooks-internal": "0.12.215-rc.0",
38+
"@keplr-wallet/hooks-starknet": "0.12.215-rc.0",
39+
"@keplr-wallet/ledger-cosmos": "0.12.215-rc.0",
40+
"@keplr-wallet/popup": "0.12.215-rc.0",
41+
"@keplr-wallet/proto-types": "0.12.215-rc.0",
42+
"@keplr-wallet/provider": "0.12.215-rc.0",
43+
"@keplr-wallet/router": "0.12.215-rc.0",
44+
"@keplr-wallet/router-extension": "0.12.215-rc.0",
45+
"@keplr-wallet/simple-fetch": "0.12.215-rc.0",
46+
"@keplr-wallet/stores": "0.12.215-rc.0",
47+
"@keplr-wallet/stores-bitcoin": "0.12.215-rc.0",
48+
"@keplr-wallet/stores-core": "0.12.215-rc.0",
49+
"@keplr-wallet/stores-etc": "0.12.215-rc.0",
50+
"@keplr-wallet/stores-eth": "0.12.215-rc.0",
51+
"@keplr-wallet/stores-ibc": "0.12.215-rc.0",
52+
"@keplr-wallet/stores-internal": "0.12.215-rc.0",
53+
"@keplr-wallet/stores-starknet": "0.12.215-rc.0",
54+
"@keplr-wallet/types": "0.12.215-rc.0",
55+
"@keplr-wallet/unit": "0.12.215-rc.0",
5656
"@keystonehq/animated-qr": "^0.8.6",
5757
"@keystonehq/hw-app-base": "0.1.1",
5858
"@keystonehq/hw-transport-webusb": "0.4.0",

apps/extension/src/hooks/bitcoin/use-bitcoin-network-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export const useGetBitcoinKeys = (chainId: string) => {
8181

8282
const linkedChainKey = modularChainInfo.linkedChainKey;
8383

84-
const linkedChainInfos = chainStore.modularChainInfosInUI.filter(
84+
const linkedChainInfos = chainStore.modularChainInfos.filter(
8585
(modularChainInfo) =>
8686
"bitcoin" in modularChainInfo &&
8787
modularChainInfo.linkedChainKey === linkedChainKey

apps/extension/src/hooks/bitcoin/use-psbt-validate.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,9 @@ export const usePsbtsValidate = (
144144
.map(([address, value]) => ({
145145
address,
146146
value,
147-
isMine: inputsToSign.some((input) => input.address === address),
147+
isMine:
148+
inputsToSign.some((input) => input.address === address) ||
149+
bitcoinKeys.some((key) => key.address === address),
148150
}))
149151
.sort((a, b) => {
150152
if (a.isMine && b.isMine) {
@@ -165,7 +167,7 @@ export const usePsbtsValidate = (
165167
return 1;
166168
});
167169
};
168-
}, []);
170+
}, [bitcoinKeys]);
169171

170172
const getInputToSignInfo = useCallback(
171173
(
@@ -506,8 +508,7 @@ export const usePsbtsValidate = (
506508
feeConfig.setValue(totalFee.truncate().toString());
507509
setIsInitialized(true);
508510
} catch (e) {
509-
// psbt deserialize 오류 또는 입력의 합이 출력의 합보다 작은 psbt가 있는 경우
510-
// 이는 더 이상 검증을 진행할 수 없는 치명적인 오류이다.
511+
// psbt deserialize가 실패하는 경우, 이는 더 이상 검증을 진행할 수 없는 치명적인 오류이다.
511512
setCriticalValidationError(e as Error);
512513
console.error(e);
513514
}

apps/extension/src/manifest.v2.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
"name": "Keplr",
55
"description": "Keplr is a browser extension wallet for the Inter blockchain ecosystem.",
6-
"version": "0.12.214",
6+
"version": "0.12.215",
77
"icons": {
88
"16": "assets/icon-16.png",
99
"48": "assets/icon-48.png",

apps/extension/src/manifest.v3.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
"name": "Keplr",
55
"description": "Keplr is a browser extension wallet for the Inter blockchain ecosystem.",
6-
"version": "0.12.214",
6+
"version": "0.12.215",
77
"icons": {
88
"16": "assets/icon-16.png",
99
"48": "assets/icon-48.png",

apps/extension/src/pages/bitcoin/send/index.tsx

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,7 @@ import {
4949
AddRecentSendHistoryMsg,
5050
PushBitcoinTransactionMsg,
5151
} from "@keplr-wallet/background";
52-
import {
53-
IPsbtInput,
54-
IPsbtOutput,
55-
RemainderStatus,
56-
} from "@keplr-wallet/stores-bitcoin";
52+
import { IPsbtInput, RemainderStatus } from "@keplr-wallet/stores-bitcoin";
5753
import { BitcoinGuideBox } from "../components/guide-box";
5854

5955
const Styles = {
@@ -298,6 +294,7 @@ export const BitcoinSendPage: FunctionComponent = observer(() => {
298294
remainderValue: string;
299295
}> => {
300296
const senderAddress = sendConfigs.senderConfig.sender;
297+
const recipientAddress = sendConfigs.recipientConfig.recipient;
301298
const publicKey = account.pubKey;
302299
const bitcoinAddress = account.bitcoinAddress;
303300
const feeRate = sendConfigs.feeRateConfig.feeRate;
@@ -355,40 +352,21 @@ export const BitcoinSendPage: FunctionComponent = observer(() => {
355352
return { bip32Derivation: undefined, tapBip32Derivation: undefined };
356353
})();
357354

358-
// Prepare transaction outputs
359-
const MAX_SAFE_OUTPUT = new Dec(2 ** 53 - 1);
360-
const amountInSatoshi = new Dec(
361-
sendConfigs.amountConfig.amount[0].toCoin().amount
362-
);
363-
const recipientsForTransaction: IPsbtOutput[] = [];
364-
365-
if (amountInSatoshi.gt(MAX_SAFE_OUTPUT)) {
366-
// Split large amounts into multiple outputs
367-
let remainingValue = amountInSatoshi;
368-
while (!remainingValue.lte(new Dec(0))) {
369-
const chunkValue = remainingValue.gt(MAX_SAFE_OUTPUT)
370-
? MAX_SAFE_OUTPUT
371-
: remainingValue;
372-
recipientsForTransaction.push({
373-
address: sendConfigs.recipientConfig.recipient,
374-
value: chunkValue.truncate().toBigNumber().toJSNumber(),
375-
});
376-
remainingValue = remainingValue.sub(chunkValue);
377-
}
378-
} else {
379-
recipientsForTransaction.push({
380-
address: sendConfigs.recipientConfig.recipient,
381-
value: amountInSatoshi.truncate().toBigNumber().toJSNumber(),
382-
});
383-
}
355+
const { outputs, recipientAddressInfo } =
356+
bitcoinAccount.prepareOutputsForSingleRecipient(
357+
new Dec(sendConfigs.amountConfig.amount[0].toCoin().amount),
358+
recipientAddress,
359+
chainId
360+
);
384361

385362
// Select UTXOs and prepare transaction
386363
const selection = bitcoinAccount.selectUTXOs({
387364
senderAddress,
388365
utxos: availableUTXOs,
389-
recipients: recipientsForTransaction,
366+
outputs,
390367
feeRate,
391368
isSendMax,
369+
prevalidatedAddressInfos: [recipientAddressInfo],
392370
});
393371

394372
if (!selection) {
@@ -417,10 +395,11 @@ export const BitcoinSendPage: FunctionComponent = observer(() => {
417395
const psbtHex = bitcoinAccount.buildPsbt({
418396
inputs,
419397
changeAddress: senderAddress,
420-
outputs: recipientsForTransaction,
398+
outputs,
421399
feeRate,
422400
isSendMax,
423401
hasChange: remainderStatus === "used_as_change",
402+
prevalidatedAddressInfos: [recipientAddressInfo],
424403
});
425404

426405
return {

apps/extension/src/pages/bitcoin/sign/tx/view.tsx

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,7 @@ import { AppCurrency, ModularChainInfo } from "@keplr-wallet/types";
6464
import { ExtensionKVStore } from "@keplr-wallet/common";
6565
import { toXOnly } from "@keplr-wallet/crypto";
6666
import { useGetUTXOs } from "../../../../hooks/bitcoin/use-get-utxos";
67-
import {
68-
IPsbtInput,
69-
IPsbtOutput,
70-
RemainderStatus,
71-
} from "@keplr-wallet/stores-bitcoin";
67+
import { IPsbtInput, RemainderStatus } from "@keplr-wallet/stores-bitcoin";
7268
import { Bech32Address } from "@keplr-wallet/cosmos";
7369
import { InformationPlainIcon } from "../../../../components/icon";
7470
import { Tooltip } from "../../../../components/tooltip";
@@ -218,8 +214,8 @@ export const SignBitcoinTxView: FunctionComponent<{
218214
throw new Error("Not ready to simulate psbt");
219215
}
220216

221-
// refresh는 필요없다. -> 블록 생성 시간이 10분
222217
const senderAddress = interactionData.data.address;
218+
const recipientAddress = interactionData.data.psbtCandidate.toAddress;
223219
const publicKey = interactionData.data.pubKey;
224220

225221
const xonlyPubKey = publicKey
@@ -228,38 +224,20 @@ export const SignBitcoinTxView: FunctionComponent<{
228224
const feeRate = feeRateConfig.feeRate;
229225
const isSendMax = amountConfig.fraction === 1;
230226

231-
const MAX_SAFE_OUTPUT = new Dec(2 ** 53 - 1);
232-
const amountInSatoshi = new Dec(
233-
interactionData.data.psbtCandidate.amount
234-
);
235-
const recipientsForTransaction: IPsbtOutput[] = [];
236-
237-
if (amountInSatoshi.gt(MAX_SAFE_OUTPUT)) {
238-
// 큰 금액을 여러 출력으로 분할
239-
let remainingValue = amountInSatoshi;
240-
while (!remainingValue.lte(new Dec(0))) {
241-
const chunkValue = remainingValue.gt(MAX_SAFE_OUTPUT)
242-
? MAX_SAFE_OUTPUT
243-
: remainingValue;
244-
recipientsForTransaction.push({
245-
address: interactionData.data.psbtCandidate.toAddress,
246-
value: chunkValue.truncate().toBigNumber().toJSNumber(),
247-
});
248-
remainingValue = remainingValue.sub(chunkValue);
249-
}
250-
} else {
251-
recipientsForTransaction.push({
252-
address: interactionData.data.psbtCandidate.toAddress,
253-
value: amountInSatoshi.truncate().toBigNumber().toJSNumber(),
254-
});
255-
}
227+
const { outputs, recipientAddressInfo } =
228+
bitcoinAccount.prepareOutputsForSingleRecipient(
229+
new Dec(interactionData.data.psbtCandidate.amount),
230+
recipientAddress,
231+
chainId
232+
);
256233

257234
const selection = bitcoinAccount.selectUTXOs({
258235
senderAddress,
259236
utxos: availableUTXOs,
260-
recipients: recipientsForTransaction,
237+
outputs,
261238
feeRate,
262239
isSendMax,
240+
prevalidatedAddressInfos: [recipientAddressInfo],
263241
});
264242

265243
if (!selection) {
@@ -282,10 +260,11 @@ export const SignBitcoinTxView: FunctionComponent<{
282260
const psbtHex = bitcoinAccount.buildPsbt({
283261
inputs,
284262
changeAddress: senderAddress,
285-
outputs: recipientsForTransaction,
263+
outputs,
286264
feeRate,
287265
isSendMax,
288266
hasChange: remainderStatus === "used_as_change",
267+
prevalidatedAddressInfos: [recipientAddressInfo],
289268
});
290269

291270
return {

apps/extension/src/pages/main/index.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,7 @@ const RefreshButton: FunctionComponent<{
808808
chainStore,
809809
queriesStore,
810810
starknetQueriesStore,
811+
bitcoinQueriesStore,
811812
accountStore,
812813
priceStore,
813814
} = useStore();
@@ -921,6 +922,23 @@ const RefreshButton: FunctionComponent<{
921922
);
922923
promises.push(stakingInfo.waitFreshResponse());
923924
}
925+
} else if ("bitcoin" in modularChainInfo) {
926+
const account = accountStore.getAccount(modularChainInfo.chainId);
927+
const currency = modularChainInfo.bitcoin.currencies[0];
928+
929+
if (account.bitcoinAddress) {
930+
const queries = bitcoinQueriesStore.get(modularChainInfo.chainId);
931+
const queryBalance = queries.queryBitcoinBalance.getBalance(
932+
modularChainInfo.chainId,
933+
chainStore,
934+
account.bitcoinAddress.bech32Address,
935+
currency.coinMinimalDenom
936+
);
937+
938+
if (queryBalance) {
939+
queryBalance.fetch();
940+
}
941+
}
924942
}
925943
}
926944

apps/extension/src/pages/sign/components/messages/render/delegate.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { IMessageRenderer } from "../types";
22

33
import React, { FunctionComponent } from "react";
44
import { MsgDelegate } from "@keplr-wallet/proto-types/cosmos/staking/v1beta1/tx";
5+
import { MsgWrappedDelegate } from "@keplr-wallet/proto-types/babylon/epoching/v1/tx";
56
import { observer } from "mobx-react-lite";
67
import { useStore } from "../../../../../stores";
78
import { CoinPrimitive, Staking } from "@keplr-wallet/stores";
@@ -22,6 +23,17 @@ export const DelegateMessage: IMessageRenderer = {
2223
};
2324
}
2425

26+
if (
27+
"type" in msg &&
28+
msg.type === "/babylon.epoching.v1.MsgWrappedDelegate"
29+
) {
30+
return {
31+
amount: msg.value.msg.amount,
32+
validatorAddress: msg.value.msg.validator_address,
33+
delegatorAddress: msg.value.msg.delegator_address,
34+
};
35+
}
36+
2537
if (
2638
"unpacked" in msg &&
2739
msg.typeUrl === "/cosmos.staking.v1beta1.MsgDelegate"
@@ -32,6 +44,20 @@ export const DelegateMessage: IMessageRenderer = {
3244
delegatorAddress: (msg.unpacked as MsgDelegate).delegatorAddress,
3345
};
3446
}
47+
48+
if (
49+
"unpacked" in msg &&
50+
msg.typeUrl === "/cosmos.distribution.v1beta1.MsgWrappedDelegate" &&
51+
(msg.unpacked as MsgWrappedDelegate).msg
52+
) {
53+
return {
54+
amount: (msg.unpacked as MsgWrappedDelegate).msg!.amount,
55+
validatorAddress: (msg.unpacked as MsgWrappedDelegate).msg!
56+
.validatorAddress,
57+
delegatorAddress: (msg.unpacked as MsgWrappedDelegate).msg!
58+
.delegatorAddress,
59+
};
60+
}
3561
})();
3662

3763
if (d) {

0 commit comments

Comments
 (0)