@dynamic-labs/bitcoin 2.1.0 → 2.1.2-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/package.json +5 -5
- package/src/connectors/BitcoinSatsConnectConnector/BitcoinSatsConnectConnector.cjs +10 -2
- package/src/connectors/BitcoinSatsConnectConnector/BitcoinSatsConnectConnector.d.ts +1 -1
- package/src/connectors/BitcoinSatsConnectConnector/BitcoinSatsConnectConnector.js +10 -2
- package/src/connectors/BitcoinWalletConnector.cjs +12 -6
- package/src/connectors/BitcoinWalletConnector.d.ts +2 -1
- package/src/connectors/BitcoinWalletConnector.js +12 -6
- package/src/index.cjs +1 -0
- package/src/index.js +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
|
|
2
|
+
### [2.1.2-alpha.0](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.1...v2.1.2-alpha.0) (2024-06-07)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* display enabled countries in phone number field ([#5825](https://github.com/dynamic-labs/DynamicAuth/issues/5825)) ([#5868](https://github.com/dynamic-labs/DynamicAuth/issues/5868)) ([640a4a7](https://github.com/dynamic-labs/DynamicAuth/commit/640a4a77c994390ceed759faf186717b38f393a4))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* btc getBalance should use ordinal address if payment not available ([#5883](https://github.com/dynamic-labs/DynamicAuth/issues/5883)) ([bc5ac55](https://github.com/dynamic-labs/DynamicAuth/commit/bc5ac5589e90193d41282d23ce037db360dd23e6))
|
|
13
|
+
* phone number in kyc step ([#5875](https://github.com/dynamic-labs/DynamicAuth/issues/5875)) ([#5879](https://github.com/dynamic-labs/DynamicAuth/issues/5879)) ([3d8a5be](https://github.com/dynamic-labs/DynamicAuth/commit/3d8a5bef35d4a13a1068aaf80d2c39e795b097cd))
|
|
14
|
+
|
|
15
|
+
### [2.1.1](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0...v2.1.1) (2024-06-04)
|
|
16
|
+
|
|
2
17
|
## [2.1.0](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.32...v2.1.0) (2024-06-04)
|
|
3
18
|
|
|
4
19
|
## Features
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/bitcoin",
|
|
3
|
-
"version": "2.1.0",
|
|
3
|
+
"version": "2.1.2-alpha.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
|
|
@@ -27,14 +27,14 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@btckit/types": "0.0.19",
|
|
30
|
-
"@dynamic-labs/sdk-api-core": "0.0.
|
|
30
|
+
"@dynamic-labs/sdk-api-core": "0.0.460",
|
|
31
31
|
"@wallet-standard/app": "1.0.1",
|
|
32
32
|
"@wallet-standard/base": "1.0.1",
|
|
33
33
|
"bitcoinjs-lib": "6.1.5",
|
|
34
34
|
"sats-connect": "2.0.0",
|
|
35
|
-
"@dynamic-labs/utils": "2.1.0",
|
|
36
|
-
"@dynamic-labs/wallet-book": "2.1.0",
|
|
37
|
-
"@dynamic-labs/wallet-connector-core": "2.1.0",
|
|
35
|
+
"@dynamic-labs/utils": "2.1.2-alpha.0",
|
|
36
|
+
"@dynamic-labs/wallet-book": "2.1.2-alpha.0",
|
|
37
|
+
"@dynamic-labs/wallet-connector-core": "2.1.2-alpha.0",
|
|
38
38
|
"stream": "0.0.2"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {}
|
|
@@ -4,12 +4,13 @@
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
6
|
var _tslib = require('../../../_virtual/_tslib.cjs');
|
|
7
|
-
var satsConnect = require('sats-connect');
|
|
8
7
|
var bitcoinjsLib = require('bitcoinjs-lib');
|
|
9
|
-
var
|
|
8
|
+
var satsConnect = require('sats-connect');
|
|
9
|
+
var sdkApiCore = require('@dynamic-labs/sdk-api-core');
|
|
10
10
|
var _const = require('../../const.cjs');
|
|
11
11
|
require('@dynamic-labs/utils');
|
|
12
12
|
require('@dynamic-labs/wallet-connector-core');
|
|
13
|
+
var BitcoinWalletConnector = require('../BitcoinWalletConnector.cjs');
|
|
13
14
|
var validatePsbt = require('../../utils/psbt/validator/validatePsbt.cjs');
|
|
14
15
|
var getSigHashType = require('../../utils/psbt/getSigHashType.cjs');
|
|
15
16
|
var bitcoinNetworkTypeToNetworks = require('../../utils/psbt/bitcoinNetworkTypeToNetworks.cjs');
|
|
@@ -26,6 +27,7 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector.BitcoinWalletCo
|
|
|
26
27
|
}
|
|
27
28
|
getAddress() {
|
|
28
29
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
var _a;
|
|
29
31
|
// xverse doesn't support wallet standard, so we won't have a wallet object,
|
|
30
32
|
// but it's already the default provider for sats-connect, so it's ok
|
|
31
33
|
// for getProvider in getAddress to return undefined
|
|
@@ -34,6 +36,12 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector.BitcoinWalletCo
|
|
|
34
36
|
if (!supportsSatsConnect.supportsSatsConnect(this)) {
|
|
35
37
|
return;
|
|
36
38
|
}
|
|
39
|
+
const cachedActiveAccount = yield this.cache.getActiveAccount();
|
|
40
|
+
if (cachedActiveAccount) {
|
|
41
|
+
const ordinalsAddress = cachedActiveAccount.additionalAddresses.find((address) => address.type === sdkApiCore.WalletAddressType.Ordinals);
|
|
42
|
+
const paymentAddress = cachedActiveAccount.additionalAddresses.find((address) => address.type === sdkApiCore.WalletAddressType.Payment);
|
|
43
|
+
return (_a = ordinalsAddress === null || ordinalsAddress === void 0 ? void 0 : ordinalsAddress.address) !== null && _a !== void 0 ? _a : paymentAddress === null || paymentAddress === void 0 ? void 0 : paymentAddress.address;
|
|
44
|
+
}
|
|
37
45
|
return new Promise((resolve, reject) => {
|
|
38
46
|
satsConnect.getAddress({
|
|
39
47
|
getProvider: () => _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BitcoinNetworkType, SignTransactionResponse } from 'sats-connect';
|
|
2
|
+
import { BitcoinSignPsbtRequest, BitcoinSignPsbtResponse, BitcoinTransaction, SatsConnectSignTransactionInput } from '../../types';
|
|
2
3
|
import { BitcoinWalletConnector, BitcoinWalletConnectorOpts } from '../BitcoinWalletConnector';
|
|
3
|
-
import { BitcoinTransaction, SatsConnectSignTransactionInput, BitcoinSignPsbtRequest, BitcoinSignPsbtResponse } from '../../types';
|
|
4
4
|
export declare abstract class BitcoinSatsConnectConnector extends BitcoinWalletConnector {
|
|
5
5
|
currentNetwork: BitcoinNetworkType;
|
|
6
6
|
canFetchConnectedAccounts: boolean;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../_virtual/_tslib.js';
|
|
3
|
-
import { BitcoinNetworkType, getAddress, AddressPurpose, signMessage, sendBtcTransaction, signTransaction } from 'sats-connect';
|
|
4
3
|
import { Psbt } from 'bitcoinjs-lib';
|
|
5
|
-
import {
|
|
4
|
+
import { BitcoinNetworkType, getAddress, AddressPurpose, signMessage, sendBtcTransaction, signTransaction } from 'sats-connect';
|
|
5
|
+
import { WalletAddressType } from '@dynamic-labs/sdk-api-core';
|
|
6
6
|
import { SATSCONNECT_FEATURE } from '../../const.js';
|
|
7
7
|
import '@dynamic-labs/utils';
|
|
8
8
|
import '@dynamic-labs/wallet-connector-core';
|
|
9
|
+
import { BitcoinWalletConnector } from '../BitcoinWalletConnector.js';
|
|
9
10
|
import { validatePsbt } from '../../utils/psbt/validator/validatePsbt.js';
|
|
10
11
|
import { getSigHashType } from '../../utils/psbt/getSigHashType.js';
|
|
11
12
|
import { convertNetworkTypeForPsbt } from '../../utils/psbt/bitcoinNetworkTypeToNetworks.js';
|
|
@@ -22,6 +23,7 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector {
|
|
|
22
23
|
}
|
|
23
24
|
getAddress() {
|
|
24
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
var _a;
|
|
25
27
|
// xverse doesn't support wallet standard, so we won't have a wallet object,
|
|
26
28
|
// but it's already the default provider for sats-connect, so it's ok
|
|
27
29
|
// for getProvider in getAddress to return undefined
|
|
@@ -30,6 +32,12 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector {
|
|
|
30
32
|
if (!supportsSatsConnect(this)) {
|
|
31
33
|
return;
|
|
32
34
|
}
|
|
35
|
+
const cachedActiveAccount = yield this.cache.getActiveAccount();
|
|
36
|
+
if (cachedActiveAccount) {
|
|
37
|
+
const ordinalsAddress = cachedActiveAccount.additionalAddresses.find((address) => address.type === WalletAddressType.Ordinals);
|
|
38
|
+
const paymentAddress = cachedActiveAccount.additionalAddresses.find((address) => address.type === WalletAddressType.Payment);
|
|
39
|
+
return (_a = ordinalsAddress === null || ordinalsAddress === void 0 ? void 0 : ordinalsAddress.address) !== null && _a !== void 0 ? _a : paymentAddress === null || paymentAddress === void 0 ? void 0 : paymentAddress.address;
|
|
40
|
+
}
|
|
33
41
|
return new Promise((resolve, reject) => {
|
|
34
42
|
getAddress({
|
|
35
43
|
getProvider: () => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -33,6 +33,11 @@ class BitcoinWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
33
33
|
}
|
|
34
34
|
this.cache = new BitcoinLocalStorageCache.BitcoinLocalStorageCache(this.overrideKey);
|
|
35
35
|
}
|
|
36
|
+
clearConnectedAccounts() {
|
|
37
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
yield this.cache.clearConnectedAcccounts();
|
|
39
|
+
});
|
|
40
|
+
}
|
|
36
41
|
canConnectWithHardwareWallet() {
|
|
37
42
|
const wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
|
|
38
43
|
if (!wallet || !wallet.hardwareWallets)
|
|
@@ -48,21 +53,22 @@ class BitcoinWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
48
53
|
}
|
|
49
54
|
endSession() {
|
|
50
55
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
51
|
-
yield
|
|
52
|
-
this.cache.clearConnectedAcccounts(),
|
|
53
|
-
this.cache.clearLastBalance(),
|
|
54
|
-
]);
|
|
56
|
+
yield this.cache.clearLastBalance();
|
|
55
57
|
});
|
|
56
58
|
}
|
|
57
59
|
getBalance() {
|
|
58
60
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
var _a;
|
|
61
|
+
var _a, _b;
|
|
60
62
|
const [connectedAddress] = yield this.getConnectedAccounts();
|
|
61
63
|
if (!connectedAddress) {
|
|
62
64
|
throw new utils.DynamicError('getBalance - No connected address found!');
|
|
63
65
|
}
|
|
64
66
|
const additionalAddresses = yield this.getAdditionalAddresses(connectedAddress);
|
|
65
|
-
const
|
|
67
|
+
const ordinalsAdditionalAddress = (_a = additionalAddresses.find((address) => address.type === sdkApiCore.WalletAddressType.Ordinals)) === null || _a === void 0 ? void 0 : _a.address;
|
|
68
|
+
const paymentAdditionalAddress = (_b = additionalAddresses.find((address) => address.type === sdkApiCore.WalletAddressType.Payment)) === null || _b === void 0 ? void 0 : _b.address;
|
|
69
|
+
// Some BTC wallet connectors only have 1 address type. when this is the case, it would always be `ordinals`
|
|
70
|
+
// if a BTC walletConnector does NOT have a payment address, just use the ordinal address
|
|
71
|
+
const paymentAddress = paymentAdditionalAddress !== null && paymentAdditionalAddress !== void 0 ? paymentAdditionalAddress : ordinalsAdditionalAddress;
|
|
66
72
|
if (!paymentAddress) {
|
|
67
73
|
throw new utils.DynamicError('getBalance - No payment address found!');
|
|
68
74
|
}
|
|
@@ -24,12 +24,13 @@ export declare abstract class BitcoinWalletConnector extends WalletConnectorBase
|
|
|
24
24
|
isHardwareWalletEnabled: boolean;
|
|
25
25
|
verifiedCredentials: JwtVerifiedCredential[];
|
|
26
26
|
constructor(opts: BitcoinWalletConnectorOpts);
|
|
27
|
+
clearConnectedAccounts(): Promise<void>;
|
|
27
28
|
canConnectWithHardwareWallet(): boolean;
|
|
28
29
|
isInstalledOnBrowser(): boolean;
|
|
29
30
|
getDeepLink(): string | undefined;
|
|
30
31
|
endSession(): Promise<void>;
|
|
31
32
|
getBalance(): Promise<string | undefined>;
|
|
32
|
-
|
|
33
|
+
getConnectedAccountsFromCache(): Promise<string[]>;
|
|
33
34
|
getConnectedAccounts(): Promise<string[]>;
|
|
34
35
|
getAdditionalAddresses(mainAddress?: string): Promise<WalletAdditionalAddress[]>;
|
|
35
36
|
setAdditionalAddresses(mainAddress: string, additionalAddresses: WalletAdditionalAddress[]): Promise<void>;
|
|
@@ -29,6 +29,11 @@ class BitcoinWalletConnector extends WalletConnectorBase {
|
|
|
29
29
|
}
|
|
30
30
|
this.cache = new BitcoinLocalStorageCache(this.overrideKey);
|
|
31
31
|
}
|
|
32
|
+
clearConnectedAccounts() {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
yield this.cache.clearConnectedAcccounts();
|
|
35
|
+
});
|
|
36
|
+
}
|
|
32
37
|
canConnectWithHardwareWallet() {
|
|
33
38
|
const wallet = findWalletBookWallet(this.walletBook, this.key);
|
|
34
39
|
if (!wallet || !wallet.hardwareWallets)
|
|
@@ -44,21 +49,22 @@ class BitcoinWalletConnector extends WalletConnectorBase {
|
|
|
44
49
|
}
|
|
45
50
|
endSession() {
|
|
46
51
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
yield
|
|
48
|
-
this.cache.clearConnectedAcccounts(),
|
|
49
|
-
this.cache.clearLastBalance(),
|
|
50
|
-
]);
|
|
52
|
+
yield this.cache.clearLastBalance();
|
|
51
53
|
});
|
|
52
54
|
}
|
|
53
55
|
getBalance() {
|
|
54
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
var _a;
|
|
57
|
+
var _a, _b;
|
|
56
58
|
const [connectedAddress] = yield this.getConnectedAccounts();
|
|
57
59
|
if (!connectedAddress) {
|
|
58
60
|
throw new DynamicError('getBalance - No connected address found!');
|
|
59
61
|
}
|
|
60
62
|
const additionalAddresses = yield this.getAdditionalAddresses(connectedAddress);
|
|
61
|
-
const
|
|
63
|
+
const ordinalsAdditionalAddress = (_a = additionalAddresses.find((address) => address.type === WalletAddressType.Ordinals)) === null || _a === void 0 ? void 0 : _a.address;
|
|
64
|
+
const paymentAdditionalAddress = (_b = additionalAddresses.find((address) => address.type === WalletAddressType.Payment)) === null || _b === void 0 ? void 0 : _b.address;
|
|
65
|
+
// Some BTC wallet connectors only have 1 address type. when this is the case, it would always be `ordinals`
|
|
66
|
+
// if a BTC walletConnector does NOT have a payment address, just use the ordinal address
|
|
67
|
+
const paymentAddress = paymentAdditionalAddress !== null && paymentAdditionalAddress !== void 0 ? paymentAdditionalAddress : ordinalsAdditionalAddress;
|
|
62
68
|
if (!paymentAddress) {
|
|
63
69
|
throw new DynamicError('getBalance - No payment address found!');
|
|
64
70
|
}
|
package/src/index.cjs
CHANGED
|
@@ -9,6 +9,7 @@ require('sats-connect');
|
|
|
9
9
|
require('bitcoinjs-lib');
|
|
10
10
|
require('@dynamic-labs/wallet-connector-core');
|
|
11
11
|
require('@dynamic-labs/utils');
|
|
12
|
+
require('@dynamic-labs/sdk-api-core');
|
|
12
13
|
var fetchBtcKitConnectors = require('./utils/fetchBtcKitConnectors/fetchBtcKitConnectors.cjs');
|
|
13
14
|
var fetchSatsConnectConnectors = require('./utils/fetchSatsConnectConnectors/fetchSatsConnectConnectors.cjs');
|
|
14
15
|
var hasSatsConnectFeature = require('./utils/hasSatsConnectFeature.cjs');
|
package/src/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import 'sats-connect';
|
|
|
5
5
|
import 'bitcoinjs-lib';
|
|
6
6
|
import '@dynamic-labs/wallet-connector-core';
|
|
7
7
|
import '@dynamic-labs/utils';
|
|
8
|
+
import '@dynamic-labs/sdk-api-core';
|
|
8
9
|
import { fetchBtcKitConnectors } from './utils/fetchBtcKitConnectors/fetchBtcKitConnectors.js';
|
|
9
10
|
export { fetchBtcKitConnectors } from './utils/fetchBtcKitConnectors/fetchBtcKitConnectors.js';
|
|
10
11
|
import { fetchSatsConnectConnectors } from './utils/fetchSatsConnectConnectors/fetchSatsConnectConnectors.js';
|