@dynamic-labs/bitcoin 1.4.6 → 1.4.8
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 +18 -0
- package/package.json +9 -9
- package/src/BitcoinBtcKitConnector.cjs +4 -3
- package/src/BitcoinBtcKitConnector.js +4 -3
- package/src/BitcoinSatsConnectConnector.cjs +2 -2
- package/src/BitcoinSatsConnectConnector.js +2 -2
- package/src/BitcoinWalletConnector.cjs +9 -3
- package/src/BitcoinWalletConnector.d.ts +1 -0
- package/src/BitcoinWalletConnector.js +9 -3
- package/src/OkxConnector.cjs +1 -1
- package/src/OkxConnector.js +1 -1
- package/src/UnisatConnector.cjs +1 -1
- package/src/UnisatConnector.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
|
|
2
|
+
### [1.4.8](https://github.com/dynamic-labs/DynamicAuth/compare/v1.4.7...v1.4.8) (2024-04-18)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* copy and ui fixes ([#5382](https://github.com/dynamic-labs/DynamicAuth/issues/5382)) ([210a52c](https://github.com/dynamic-labs/DynamicAuth/commit/210a52ce85a9812fe20c41445873b3a8b8dc44c2)), closes [#5325](https://github.com/dynamic-labs/DynamicAuth/issues/5325) ([#5339](https://github.com/dynamic-labs/DynamicAuth/issues/5339)) ([c1fde6b](https://github.com/dynamic-labs/DynamicAuth/commit/c1fde6beb1fa2666d71a4ffaed84adb3302665d4))
|
|
8
|
+
* bitcoin connector improvements
|
|
9
|
+
|
|
10
|
+
### [1.4.7](https://github.com/dynamic-labs/DynamicAuth/compare/v1.4.6...v1.4.7) (2024-04-12)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* ui and layout improvements ([#5269](https://github.com/dynamic-labs/DynamicAuth/issues/5269)) ([#5296](https://github.com/dynamic-labs/DynamicAuth/issues/5296)) ([a1f7204](https://github.com/dynamic-labs/DynamicAuth/commit/a1f7204e44b4ae1650f86b76663c0802530935cb)) ([#5270](https://github.com/dynamic-labs/DynamicAuth/issues/5270)) ([#5278](https://github.com/dynamic-labs/DynamicAuth/issues/5278)) ([5f262f5](https://github.com/dynamic-labs/DynamicAuth/commit/5f262f54bba8eb2fa6346040478dd0417f42d2d1))
|
|
16
|
+
* callback trigger fixes ([#5310](https://github.com/dynamic-labs/DynamicAuth/issues/5310)) ([e6f7720](https://github.com/dynamic-labs/DynamicAuth/commit/e6f7720781a68b9d36448e4edea834e6478e7263))
|
|
17
|
+
* improve bridge connect experience on mobile ([#5284](https://github.com/dynamic-labs/DynamicAuth/issues/5284)) ([c8eab02](https://github.com/dynamic-labs/DynamicAuth/commit/c8eab0243ca5752d365fd907fde36b7c08669d5e))
|
|
18
|
+
* improve integration with i18n ([#5267](https://github.com/dynamic-labs/DynamicAuth/issues/5267)) ([#5313](https://github.com/dynamic-labs/DynamicAuth/issues/5313)) ([5f02f72](https://github.com/dynamic-labs/DynamicAuth/commit/5f02f72fe547e93d59a2545ffcce62c20fb22dbe))
|
|
19
|
+
|
|
2
20
|
### [1.4.6](https://github.com/dynamic-labs/DynamicAuth/compare/v1.4.5...v1.4.6) (2024-04-09)
|
|
3
21
|
|
|
4
22
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/bitcoin",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.8",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
@@ -26,15 +26,15 @@
|
|
|
26
26
|
"./package.json": "./package.json"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@btckit/types": "
|
|
29
|
+
"@btckit/types": "0.0.19",
|
|
30
30
|
"@dynamic-labs/sdk-api": "0.0.387",
|
|
31
|
-
"@wallet-standard/app": "
|
|
32
|
-
"@wallet-standard/base": "
|
|
33
|
-
"bitcoinjs-lib": "
|
|
34
|
-
"sats-connect": "
|
|
35
|
-
"@dynamic-labs/utils": "1.4.
|
|
36
|
-
"@dynamic-labs/wallet-book": "1.4.
|
|
37
|
-
"@dynamic-labs/wallet-connector-core": "1.4.
|
|
31
|
+
"@wallet-standard/app": "1.0.1",
|
|
32
|
+
"@wallet-standard/base": "1.0.1",
|
|
33
|
+
"bitcoinjs-lib": "6.1.5",
|
|
34
|
+
"sats-connect": "2.0.0",
|
|
35
|
+
"@dynamic-labs/utils": "1.4.8",
|
|
36
|
+
"@dynamic-labs/wallet-book": "1.4.8",
|
|
37
|
+
"@dynamic-labs/wallet-connector-core": "1.4.8",
|
|
38
38
|
"stream": "0.0.2"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {}
|
|
@@ -17,8 +17,8 @@ class BitcoinBtcKitConnector extends BitcoinWalletConnector.BitcoinWalletConnect
|
|
|
17
17
|
this.btcKit = btcKit;
|
|
18
18
|
}
|
|
19
19
|
fetchPublicAddress() {
|
|
20
|
-
var _a;
|
|
21
20
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
var _a;
|
|
22
22
|
const [connectedAccount] = yield this.getConnectedAccounts();
|
|
23
23
|
if (connectedAccount) {
|
|
24
24
|
return connectedAccount;
|
|
@@ -65,7 +65,8 @@ class BitcoinBtcKitConnector extends BitcoinWalletConnector.BitcoinWalletConnect
|
|
|
65
65
|
}
|
|
66
66
|
const response = yield this.btcKit.request('sendTransfer', {
|
|
67
67
|
address: transaction.recipientAddress,
|
|
68
|
-
amount: transaction.amount,
|
|
68
|
+
amount: transaction.amount.toString(),
|
|
69
|
+
network: this.convertNetworkTypeToNetworkMode(),
|
|
69
70
|
});
|
|
70
71
|
if (!('result' in response)) {
|
|
71
72
|
walletConnectorCore.logger.error('Transaction error', response);
|
|
@@ -80,8 +81,8 @@ class BitcoinBtcKitConnector extends BitcoinWalletConnector.BitcoinWalletConnect
|
|
|
80
81
|
: 'testnet';
|
|
81
82
|
}
|
|
82
83
|
signPsbt(request) {
|
|
83
|
-
var _a, _b;
|
|
84
84
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
var _a, _b;
|
|
85
86
|
const connectedAddress = yield this.fetchPublicAddress();
|
|
86
87
|
if (!connectedAddress || !this.btcKit) {
|
|
87
88
|
return;
|
|
@@ -13,8 +13,8 @@ class BitcoinBtcKitConnector extends BitcoinWalletConnector {
|
|
|
13
13
|
this.btcKit = btcKit;
|
|
14
14
|
}
|
|
15
15
|
fetchPublicAddress() {
|
|
16
|
-
var _a;
|
|
17
16
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
var _a;
|
|
18
18
|
const [connectedAccount] = yield this.getConnectedAccounts();
|
|
19
19
|
if (connectedAccount) {
|
|
20
20
|
return connectedAccount;
|
|
@@ -61,7 +61,8 @@ class BitcoinBtcKitConnector extends BitcoinWalletConnector {
|
|
|
61
61
|
}
|
|
62
62
|
const response = yield this.btcKit.request('sendTransfer', {
|
|
63
63
|
address: transaction.recipientAddress,
|
|
64
|
-
amount: transaction.amount,
|
|
64
|
+
amount: transaction.amount.toString(),
|
|
65
|
+
network: this.convertNetworkTypeToNetworkMode(),
|
|
65
66
|
});
|
|
66
67
|
if (!('result' in response)) {
|
|
67
68
|
logger.error('Transaction error', response);
|
|
@@ -76,8 +77,8 @@ class BitcoinBtcKitConnector extends BitcoinWalletConnector {
|
|
|
76
77
|
: 'testnet';
|
|
77
78
|
}
|
|
78
79
|
signPsbt(request) {
|
|
79
|
-
var _a, _b;
|
|
80
80
|
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
var _a, _b;
|
|
81
82
|
const connectedAddress = yield this.fetchPublicAddress();
|
|
82
83
|
if (!connectedAddress || !this.btcKit) {
|
|
83
84
|
return;
|
|
@@ -96,8 +96,8 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector.BitcoinWalletCo
|
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
98
|
sendBitcoin(transaction) {
|
|
99
|
-
var _a;
|
|
100
99
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
100
|
+
var _a;
|
|
101
101
|
const mainAddress = yield this.fetchPublicAddress();
|
|
102
102
|
const senderAddress = (_a = (yield this.getAdditionalAddresses(mainAddress)).find((address) => address.type === 'payment')) === null || _a === void 0 ? void 0 : _a.address;
|
|
103
103
|
if (!senderAddress || !supportsSatsConnect.supportsSatsConnect(this)) {
|
|
@@ -164,8 +164,8 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector.BitcoinWalletCo
|
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
166
|
signPsbt(request) {
|
|
167
|
-
var _a, _b, _c, _d;
|
|
168
167
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
168
|
+
var _a, _b, _c, _d;
|
|
169
169
|
if (!((_a = request.allowedSighash) === null || _a === void 0 ? void 0 : _a.length))
|
|
170
170
|
throw new Error('allowedSighash cannot be an empty array');
|
|
171
171
|
const network = bitcoinNetworkTypeToNetworks.convertNetworkTypeForPsbt(this.currentNetwork);
|
|
@@ -92,8 +92,8 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector {
|
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
sendBitcoin(transaction) {
|
|
95
|
-
var _a;
|
|
96
95
|
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
var _a;
|
|
97
97
|
const mainAddress = yield this.fetchPublicAddress();
|
|
98
98
|
const senderAddress = (_a = (yield this.getAdditionalAddresses(mainAddress)).find((address) => address.type === 'payment')) === null || _a === void 0 ? void 0 : _a.address;
|
|
99
99
|
if (!senderAddress || !supportsSatsConnect(this)) {
|
|
@@ -160,8 +160,8 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector {
|
|
|
160
160
|
});
|
|
161
161
|
}
|
|
162
162
|
signPsbt(request) {
|
|
163
|
-
var _a, _b, _c, _d;
|
|
164
163
|
return __awaiter(this, void 0, void 0, function* () {
|
|
164
|
+
var _a, _b, _c, _d;
|
|
165
165
|
if (!((_a = request.allowedSighash) === null || _a === void 0 ? void 0 : _a.length))
|
|
166
166
|
throw new Error('allowedSighash cannot be an empty array');
|
|
167
167
|
const network = convertNetworkTypeForPsbt(this.currentNetwork);
|
|
@@ -43,12 +43,18 @@ class BitcoinWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
43
43
|
}
|
|
44
44
|
getBalance() {
|
|
45
45
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
var _a;
|
|
46
47
|
const [connectedAddress] = yield this.getConnectedAccounts();
|
|
47
48
|
if (!connectedAddress) {
|
|
48
49
|
throw new utils.DynamicError('getBalance - No connected address found!');
|
|
49
50
|
}
|
|
50
|
-
const
|
|
51
|
-
const
|
|
51
|
+
const additionalAddresses = yield this.getAdditionalAddresses(connectedAddress);
|
|
52
|
+
const paymentAddress = (_a = additionalAddresses.find((address) => address.type === sdkApi.WalletAddressType.Payment)) === null || _a === void 0 ? void 0 : _a.address;
|
|
53
|
+
if (!paymentAddress) {
|
|
54
|
+
throw new utils.DynamicError('getBalance - No payment address found!');
|
|
55
|
+
}
|
|
56
|
+
const API_URL = getMempoolApiUrl.getMempoolApiUrl(paymentAddress);
|
|
57
|
+
const response = yield fetch(`${API_URL}/address/${paymentAddress}`);
|
|
52
58
|
if (!response.ok) {
|
|
53
59
|
// if the request fails due to rate limits, return cached value
|
|
54
60
|
if (response.status === _const.HTTP_STATUS_TOO_MANY_REQUESTS) {
|
|
@@ -72,8 +78,8 @@ class BitcoinWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
72
78
|
});
|
|
73
79
|
}
|
|
74
80
|
getConnectedAccountsFromCache() {
|
|
75
|
-
var _a;
|
|
76
81
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
var _a;
|
|
77
83
|
const currentAccount = yield this.cache.getActiveAccount();
|
|
78
84
|
const allAccounts = yield this.cache.getConnectedAccounts();
|
|
79
85
|
const allConnectedAddresses = (_a = Object.keys(allAccounts || {})) !== null && _a !== void 0 ? _a : [];
|
|
@@ -39,12 +39,18 @@ class BitcoinWalletConnector extends WalletConnectorBase {
|
|
|
39
39
|
}
|
|
40
40
|
getBalance() {
|
|
41
41
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
var _a;
|
|
42
43
|
const [connectedAddress] = yield this.getConnectedAccounts();
|
|
43
44
|
if (!connectedAddress) {
|
|
44
45
|
throw new DynamicError('getBalance - No connected address found!');
|
|
45
46
|
}
|
|
46
|
-
const
|
|
47
|
-
const
|
|
47
|
+
const additionalAddresses = yield this.getAdditionalAddresses(connectedAddress);
|
|
48
|
+
const paymentAddress = (_a = additionalAddresses.find((address) => address.type === WalletAddressType.Payment)) === null || _a === void 0 ? void 0 : _a.address;
|
|
49
|
+
if (!paymentAddress) {
|
|
50
|
+
throw new DynamicError('getBalance - No payment address found!');
|
|
51
|
+
}
|
|
52
|
+
const API_URL = getMempoolApiUrl(paymentAddress);
|
|
53
|
+
const response = yield fetch(`${API_URL}/address/${paymentAddress}`);
|
|
48
54
|
if (!response.ok) {
|
|
49
55
|
// if the request fails due to rate limits, return cached value
|
|
50
56
|
if (response.status === HTTP_STATUS_TOO_MANY_REQUESTS) {
|
|
@@ -68,8 +74,8 @@ class BitcoinWalletConnector extends WalletConnectorBase {
|
|
|
68
74
|
});
|
|
69
75
|
}
|
|
70
76
|
getConnectedAccountsFromCache() {
|
|
71
|
-
var _a;
|
|
72
77
|
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
var _a;
|
|
73
79
|
const currentAccount = yield this.cache.getActiveAccount();
|
|
74
80
|
const allAccounts = yield this.cache.getConnectedAccounts();
|
|
75
81
|
const allConnectedAddresses = (_a = Object.keys(allAccounts || {})) !== null && _a !== void 0 ? _a : [];
|
package/src/OkxConnector.cjs
CHANGED
|
@@ -44,7 +44,7 @@ class OkxConnector extends BitcoinWalletConnector.BitcoinWalletConnector {
|
|
|
44
44
|
if (!connectedAddress || !provider) {
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
|
-
return provider.sendBitcoin(transaction.recipientAddress, transaction.amount);
|
|
47
|
+
return provider.sendBitcoin(transaction.recipientAddress, transaction.amount.toString());
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
signPsbt(request) {
|
package/src/OkxConnector.js
CHANGED
|
@@ -40,7 +40,7 @@ class OkxConnector extends BitcoinWalletConnector {
|
|
|
40
40
|
if (!connectedAddress || !provider) {
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
|
-
return provider.sendBitcoin(transaction.recipientAddress, transaction.amount);
|
|
43
|
+
return provider.sendBitcoin(transaction.recipientAddress, transaction.amount.toString());
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
signPsbt(request) {
|
package/src/UnisatConnector.cjs
CHANGED
|
@@ -45,7 +45,7 @@ class UnisatConnector extends BitcoinWalletConnector.BitcoinWalletConnector {
|
|
|
45
45
|
if (!connectedAddress || !provider) {
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
|
-
return provider.sendBitcoin(transaction.recipientAddress, transaction.amount);
|
|
48
|
+
return provider.sendBitcoin(transaction.recipientAddress, transaction.amount.toString());
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
signPsbt(request) {
|
package/src/UnisatConnector.js
CHANGED
|
@@ -41,7 +41,7 @@ class UnisatConnector extends BitcoinWalletConnector {
|
|
|
41
41
|
if (!connectedAddress || !provider) {
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
|
-
return provider.sendBitcoin(transaction.recipientAddress, transaction.amount);
|
|
44
|
+
return provider.sendBitcoin(transaction.recipientAddress, transaction.amount.toString());
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
signPsbt(request) {
|