@dynamic-labs/bitcoin 3.0.0-alpha.52 → 3.0.0-alpha.53
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 +39 -0
- package/package.json +4 -4
- package/src/connectors/BitcoinSatsConnectConnector/BitcoinSatsConnectConnector.cjs +12 -4
- package/src/connectors/BitcoinSatsConnectConnector/BitcoinSatsConnectConnector.d.ts +1 -0
- package/src/connectors/BitcoinSatsConnectConnector/BitcoinSatsConnectConnector.js +12 -4
- package/src/connectors/BitcoinWalletConnector.cjs +20 -5
- package/src/connectors/BitcoinWalletConnector.d.ts +7 -3
- package/src/connectors/BitcoinWalletConnector.js +20 -5
- package/src/connectors/PhantomConnector/PhantomConnector.cjs +12 -7
- package/src/connectors/PhantomConnector/PhantomConnector.d.ts +1 -0
- package/src/connectors/PhantomConnector/PhantomConnector.js +12 -7
- package/src/index.cjs +4 -0
- package/src/index.d.ts +3 -2
- package/src/index.js +2 -0
- package/src/wallet/BitcoinWallet.cjs +54 -0
- package/src/wallet/BitcoinWallet.d.ts +27 -0
- package/src/wallet/BitcoinWallet.js +50 -0
- package/src/wallet/index.d.ts +2 -0
- package/src/wallet/isBitcoinWallet/index.d.ts +1 -0
- package/src/wallet/isBitcoinWallet/isBitcoinWallet.cjs +8 -0
- package/src/wallet/isBitcoinWallet/isBitcoinWallet.d.ts +3 -0
- package/src/wallet/isBitcoinWallet/isBitcoinWallet.js +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,43 @@
|
|
|
1
1
|
|
|
2
|
+
## [3.0.0-alpha.53](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.52...v3.0.0-alpha.53) (2024-08-29)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### ⚠ BREAKING CHANGES
|
|
6
|
+
|
|
7
|
+
* simplify solana wallet signer types (#6748)
|
|
8
|
+
* deprecate getEoaConnector (#6571)
|
|
9
|
+
* limit methods and props returned by wallet.connector (#6540)
|
|
10
|
+
* move generic solana code to solana-core package (#6701)
|
|
11
|
+
* revamp ether v6 interface (#6548)
|
|
12
|
+
* add ethereum wallet specific methods and intercept to sync when needed (#6662)
|
|
13
|
+
* add solana wallet specific methods and intercept to sync when needed (#6608)
|
|
14
|
+
* don't force primary wallet to be connected (#6128)
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* add bitcoin wallet specific methods and intercept to sync when needed ([#6663](https://github.com/dynamic-labs/DynamicAuth/issues/6663)) ([ed699b1](https://github.com/dynamic-labs/DynamicAuth/commit/ed699b1f8c264755779ec4840d105f89ade5500e))
|
|
19
|
+
* add ethereum wallet specific methods and intercept to sync when needed ([#6662](https://github.com/dynamic-labs/DynamicAuth/issues/6662)) ([372360e](https://github.com/dynamic-labs/DynamicAuth/commit/372360ed7ca395f88811fc62c94b2b494eb59971))
|
|
20
|
+
* add solana wallet specific methods and intercept to sync when needed ([#6608](https://github.com/dynamic-labs/DynamicAuth/issues/6608)) ([565f610](https://github.com/dynamic-labs/DynamicAuth/commit/565f6100340296c267e9706fd263e9bd3f7d3732))
|
|
21
|
+
* add useSmartWallets hook to manage aa wallets ([#6564](https://github.com/dynamic-labs/DynamicAuth/issues/6564)) ([a243d36](https://github.com/dynamic-labs/DynamicAuth/commit/a243d361ce7c368d0f1afda55f9c1fabefd75ba8))
|
|
22
|
+
* don't force primary wallet to be connected ([#6128](https://github.com/dynamic-labs/DynamicAuth/issues/6128)) ([018a6f6](https://github.com/dynamic-labs/DynamicAuth/commit/018a6f66f8725914ab97ea3e2e1c80626266e503))
|
|
23
|
+
* new prop to enable prompt for linking when account change is detected ([#6713](https://github.com/dynamic-labs/DynamicAuth/issues/6713)) ([b5a6321](https://github.com/dynamic-labs/DynamicAuth/commit/b5a63212ae33fae24401f141d5ca2356b446dcff))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Bug Fixes
|
|
27
|
+
|
|
28
|
+
* always sync wagmi client with primary wallet ([#6577](https://github.com/dynamic-labs/DynamicAuth/issues/6577)) ([be22fde](https://github.com/dynamic-labs/DynamicAuth/commit/be22fdea3bb61db79b06ba56cb32da6cd8141b66))
|
|
29
|
+
* cosmos wallet intercepts ([#6720](https://github.com/dynamic-labs/DynamicAuth/issues/6720)) ([cfc9df4](https://github.com/dynamic-labs/DynamicAuth/commit/cfc9df48a8032f7348fec14f77b9e378d2e26a22))
|
|
30
|
+
* magiceden wallet events not working correctly on page refresh ([#6735](https://github.com/dynamic-labs/DynamicAuth/issues/6735)) ([6ed5964](https://github.com/dynamic-labs/DynamicAuth/commit/6ed5964134a2cafd392c19f18eb71e6ca2ce238d))
|
|
31
|
+
* use proxy to intercept solana signer methods ([#6743](https://github.com/dynamic-labs/DynamicAuth/issues/6743)) ([ecbe5ea](https://github.com/dynamic-labs/DynamicAuth/commit/ecbe5ea772592d2c693d8222d85b7642acd151a8))
|
|
32
|
+
* wallet.chain references ([525c1ca](https://github.com/dynamic-labs/DynamicAuth/commit/525c1ca9a8fe6402c06eabe6aebc30e310411d9b))
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
* deprecate getEoaConnector ([#6571](https://github.com/dynamic-labs/DynamicAuth/issues/6571)) ([0226ee5](https://github.com/dynamic-labs/DynamicAuth/commit/0226ee5a13f2418607076ee6f2ec0a579b06dd5d))
|
|
36
|
+
* limit methods and props returned by wallet.connector ([#6540](https://github.com/dynamic-labs/DynamicAuth/issues/6540)) ([9c86e35](https://github.com/dynamic-labs/DynamicAuth/commit/9c86e35c72cd40313bfd19254dd6171ee8f62213))
|
|
37
|
+
* move generic solana code to solana-core package ([#6701](https://github.com/dynamic-labs/DynamicAuth/issues/6701)) ([30815f5](https://github.com/dynamic-labs/DynamicAuth/commit/30815f5d46feeefb2413c1b7d30b43d5370ee032))
|
|
38
|
+
* revamp ether v6 interface ([#6548](https://github.com/dynamic-labs/DynamicAuth/issues/6548)) ([f3b2fb8](https://github.com/dynamic-labs/DynamicAuth/commit/f3b2fb8da7de21f9c58e67fa7f5580166195092a))
|
|
39
|
+
* simplify solana wallet signer types ([#6748](https://github.com/dynamic-labs/DynamicAuth/issues/6748)) ([01d1a42](https://github.com/dynamic-labs/DynamicAuth/commit/01d1a42bc916ab329580b741ba60d706bf6c5491))
|
|
40
|
+
|
|
2
41
|
## [3.0.0-alpha.52](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.51...v3.0.0-alpha.52) (2024-08-28)
|
|
3
42
|
|
|
4
43
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/bitcoin",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.53",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
|
|
@@ -32,9 +32,9 @@
|
|
|
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": "3.0.0-alpha.
|
|
36
|
-
"@dynamic-labs/wallet-book": "3.0.0-alpha.
|
|
37
|
-
"@dynamic-labs/wallet-connector-core": "3.0.0-alpha.
|
|
35
|
+
"@dynamic-labs/utils": "3.0.0-alpha.53",
|
|
36
|
+
"@dynamic-labs/wallet-book": "3.0.0-alpha.53",
|
|
37
|
+
"@dynamic-labs/wallet-connector-core": "3.0.0-alpha.53",
|
|
38
38
|
"stream": "0.0.2"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {}
|
|
@@ -80,10 +80,9 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector.BitcoinWalletCo
|
|
|
80
80
|
});
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
|
-
|
|
83
|
+
signMessageWithAddress(messageToSign, address) {
|
|
84
84
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
85
|
-
|
|
86
|
-
if (!walletAddress || !supportsSatsConnect.supportsSatsConnect(this)) {
|
|
85
|
+
if (!supportsSatsConnect.supportsSatsConnect(this)) {
|
|
87
86
|
return;
|
|
88
87
|
}
|
|
89
88
|
return new Promise((resolve, reject) => {
|
|
@@ -108,7 +107,7 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector.BitcoinWalletCo
|
|
|
108
107
|
resolve(response);
|
|
109
108
|
}),
|
|
110
109
|
payload: {
|
|
111
|
-
address
|
|
110
|
+
address,
|
|
112
111
|
message: messageToSign,
|
|
113
112
|
network: {
|
|
114
113
|
type: this.currentNetwork,
|
|
@@ -118,6 +117,15 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector.BitcoinWalletCo
|
|
|
118
117
|
});
|
|
119
118
|
});
|
|
120
119
|
}
|
|
120
|
+
signMessage(messageToSign) {
|
|
121
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
const [walletAddress] = yield this.getConnectedAccounts();
|
|
123
|
+
if (!walletAddress) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
return this.signMessageWithAddress(messageToSign, walletAddress);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
121
129
|
sendBitcoin(transaction) {
|
|
122
130
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
123
131
|
var _a;
|
|
@@ -5,6 +5,7 @@ export declare abstract class BitcoinSatsConnectConnector extends BitcoinWalletC
|
|
|
5
5
|
currentNetwork: BitcoinNetworkType;
|
|
6
6
|
constructor(opts: BitcoinWalletConnectorOpts);
|
|
7
7
|
getAddress(): Promise<string | undefined>;
|
|
8
|
+
signMessageWithAddress(messageToSign: string, address: string): Promise<string | undefined>;
|
|
8
9
|
signMessage(messageToSign: string): Promise<string | undefined>;
|
|
9
10
|
sendBitcoin(transaction: BitcoinTransaction): Promise<string | undefined>;
|
|
10
11
|
signTransaction(params: SatsConnectSignTransactionInput): Promise<SignTransactionResponse | undefined>;
|
|
@@ -76,10 +76,9 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector {
|
|
|
76
76
|
});
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
|
-
|
|
79
|
+
signMessageWithAddress(messageToSign, address) {
|
|
80
80
|
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
-
|
|
82
|
-
if (!walletAddress || !supportsSatsConnect(this)) {
|
|
81
|
+
if (!supportsSatsConnect(this)) {
|
|
83
82
|
return;
|
|
84
83
|
}
|
|
85
84
|
return new Promise((resolve, reject) => {
|
|
@@ -104,7 +103,7 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector {
|
|
|
104
103
|
resolve(response);
|
|
105
104
|
}),
|
|
106
105
|
payload: {
|
|
107
|
-
address
|
|
106
|
+
address,
|
|
108
107
|
message: messageToSign,
|
|
109
108
|
network: {
|
|
110
109
|
type: this.currentNetwork,
|
|
@@ -114,6 +113,15 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector {
|
|
|
114
113
|
});
|
|
115
114
|
});
|
|
116
115
|
}
|
|
116
|
+
signMessage(messageToSign) {
|
|
117
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
118
|
+
const [walletAddress] = yield this.getConnectedAccounts();
|
|
119
|
+
if (!walletAddress) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
return this.signMessageWithAddress(messageToSign, walletAddress);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
117
125
|
sendBitcoin(transaction) {
|
|
118
126
|
return __awaiter(this, void 0, void 0, function* () {
|
|
119
127
|
var _a;
|
|
@@ -14,11 +14,13 @@ var bitcoinProviderHelper = require('../bitcoinProviderHelper.cjs');
|
|
|
14
14
|
var getMempoolApiUrl = require('../utils/getMempoolApiUrl.cjs');
|
|
15
15
|
var _const = require('../const.cjs');
|
|
16
16
|
var satoshisToBtc = require('../utils/satoshisToBtc/satoshisToBtc.cjs');
|
|
17
|
+
var BitcoinWallet = require('../wallet/BitcoinWallet.cjs');
|
|
17
18
|
|
|
18
19
|
class BitcoinWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
19
20
|
constructor(opts) {
|
|
20
21
|
var _a;
|
|
21
22
|
super(opts);
|
|
23
|
+
this.ChainWallet = BitcoinWallet.BitcoinWallet;
|
|
22
24
|
this.connectedChain = 'BTC';
|
|
23
25
|
this.supportedChains = ['BTC'];
|
|
24
26
|
// some wallets don't support fetching connected accounts without prompting for a connection
|
|
@@ -108,12 +110,12 @@ class BitcoinWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
108
110
|
];
|
|
109
111
|
});
|
|
110
112
|
}
|
|
111
|
-
getConnectedAccounts() {
|
|
113
|
+
getConnectedAccounts(forceFetch) {
|
|
112
114
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
113
115
|
// some wallets like xverse don't support fetching connected accounts
|
|
114
116
|
// without prompting for a connection
|
|
115
117
|
// to avoid this behavior, we cache the connected accounts
|
|
116
|
-
if (!this.canFetchConnectedAccounts) {
|
|
118
|
+
if (!this.canFetchConnectedAccounts && !forceFetch) {
|
|
117
119
|
return this.getConnectedAccountsFromCache();
|
|
118
120
|
}
|
|
119
121
|
// if we decide that is ok to prompt for a connection when fetching connected accounts
|
|
@@ -155,11 +157,12 @@ class BitcoinWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
155
157
|
}
|
|
156
158
|
sendRawTransaction(rawTransaction) {
|
|
157
159
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
158
|
-
if (!rawTransaction)
|
|
159
|
-
|
|
160
|
+
if (!rawTransaction) {
|
|
161
|
+
throw new utils.DynamicError('No transaction specified!');
|
|
162
|
+
}
|
|
160
163
|
const [connectedAddress] = yield this.getConnectedAccounts();
|
|
161
164
|
if (!connectedAddress) {
|
|
162
|
-
throw new utils.DynamicError('
|
|
165
|
+
throw new utils.DynamicError('No connected address found!');
|
|
163
166
|
}
|
|
164
167
|
const API_URL = getMempoolApiUrl.getMempoolApiUrl(connectedAddress);
|
|
165
168
|
const response = yield fetch(`${API_URL}/tx`, {
|
|
@@ -280,6 +283,18 @@ class BitcoinWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
280
283
|
isLedgerAddress(address) {
|
|
281
284
|
return utils.isLedgerAddressViaVerifiedCredentials(address, this.verifiedCredentials);
|
|
282
285
|
}
|
|
286
|
+
proveOwnership(address, messageToSign) {
|
|
287
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
288
|
+
return this.signMessageWithAddress(messageToSign, address);
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
signMessageWithAddress(messageToSign,
|
|
292
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
293
|
+
_address) {
|
|
294
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
295
|
+
return this.signMessage(messageToSign);
|
|
296
|
+
});
|
|
297
|
+
}
|
|
283
298
|
}
|
|
284
299
|
|
|
285
300
|
exports.BitcoinWalletConnector = BitcoinWalletConnector;
|
|
@@ -7,13 +7,15 @@ import { WalletBookSchema, WalletSchema } from '@dynamic-labs/wallet-book';
|
|
|
7
7
|
import { JwtVerifiedCredential, WalletAdditionalAddress } from '@dynamic-labs/sdk-api-core';
|
|
8
8
|
import { IBitcoinSessionCache } from '../BitcoinLocalStorageCache';
|
|
9
9
|
import { BitcoinTransaction, BitcoinSignPsbtRequest, BitcoinSignPsbtResponse, BitcoinWalletStandardMethods, ConnectedAccountWithAddressesProps } from '../types';
|
|
10
|
+
import { BitcoinWallet } from '../wallet';
|
|
10
11
|
export type BitcoinWalletConnectorOpts = {
|
|
11
12
|
walletBook: WalletBookSchema;
|
|
12
13
|
walletData: WalletSchema;
|
|
13
14
|
overrideKey?: string;
|
|
14
15
|
};
|
|
15
|
-
export declare abstract class BitcoinWalletConnector extends WalletConnectorBase implements IBitcoinWalletConnector {
|
|
16
|
+
export declare abstract class BitcoinWalletConnector extends WalletConnectorBase<typeof BitcoinWallet> implements IBitcoinWalletConnector {
|
|
16
17
|
cache: IBitcoinSessionCache;
|
|
18
|
+
ChainWallet: typeof BitcoinWallet;
|
|
17
19
|
connectedChain: Chain;
|
|
18
20
|
supportedChains: Chain[];
|
|
19
21
|
private getAddressPromise;
|
|
@@ -34,10 +36,10 @@ export declare abstract class BitcoinWalletConnector extends WalletConnectorBase
|
|
|
34
36
|
endSession(): Promise<void>;
|
|
35
37
|
getBalance(address: string): Promise<string | undefined>;
|
|
36
38
|
getConnectedAccountsFromCache(): Promise<string[]>;
|
|
37
|
-
getConnectedAccounts(): Promise<string[]>;
|
|
39
|
+
getConnectedAccounts(forceFetch?: boolean): Promise<string[]>;
|
|
38
40
|
getAdditionalAddresses(mainAddress?: string): Promise<WalletAdditionalAddress[]>;
|
|
39
41
|
setAdditionalAddresses(mainAddress: string, additionalAddresses: WalletAdditionalAddress[]): Promise<void>;
|
|
40
|
-
sendRawTransaction(rawTransaction: string): Promise<string
|
|
42
|
+
sendRawTransaction(rawTransaction: string): Promise<string>;
|
|
41
43
|
abstract sendBitcoin(transaction: BitcoinTransaction): Promise<string | undefined>;
|
|
42
44
|
getProvider<T>(): T & EventEmitter;
|
|
43
45
|
abstract signPsbt(request: BitcoinSignPsbtRequest): Promise<BitcoinSignPsbtResponse | undefined>;
|
|
@@ -46,4 +48,6 @@ export declare abstract class BitcoinWalletConnector extends WalletConnectorBase
|
|
|
46
48
|
setupEventListeners(): void;
|
|
47
49
|
setVerifiedCredentials(verifiedCredentials: JwtVerifiedCredential[]): void;
|
|
48
50
|
isLedgerAddress(address: string): boolean;
|
|
51
|
+
proveOwnership(address: string, messageToSign: string): Promise<string | undefined>;
|
|
52
|
+
signMessageWithAddress(messageToSign: string, _address: string): Promise<string | undefined>;
|
|
49
53
|
}
|
|
@@ -10,11 +10,13 @@ import { BitcoinProviderHelper } from '../bitcoinProviderHelper.js';
|
|
|
10
10
|
import { getMempoolApiUrl } from '../utils/getMempoolApiUrl.js';
|
|
11
11
|
import { HTTP_STATUS_TOO_MANY_REQUESTS, HTTP_STATUS_NOT_FOUND } from '../const.js';
|
|
12
12
|
import { satoshisToBtc } from '../utils/satoshisToBtc/satoshisToBtc.js';
|
|
13
|
+
import { BitcoinWallet } from '../wallet/BitcoinWallet.js';
|
|
13
14
|
|
|
14
15
|
class BitcoinWalletConnector extends WalletConnectorBase {
|
|
15
16
|
constructor(opts) {
|
|
16
17
|
var _a;
|
|
17
18
|
super(opts);
|
|
19
|
+
this.ChainWallet = BitcoinWallet;
|
|
18
20
|
this.connectedChain = 'BTC';
|
|
19
21
|
this.supportedChains = ['BTC'];
|
|
20
22
|
// some wallets don't support fetching connected accounts without prompting for a connection
|
|
@@ -104,12 +106,12 @@ class BitcoinWalletConnector extends WalletConnectorBase {
|
|
|
104
106
|
];
|
|
105
107
|
});
|
|
106
108
|
}
|
|
107
|
-
getConnectedAccounts() {
|
|
109
|
+
getConnectedAccounts(forceFetch) {
|
|
108
110
|
return __awaiter(this, void 0, void 0, function* () {
|
|
109
111
|
// some wallets like xverse don't support fetching connected accounts
|
|
110
112
|
// without prompting for a connection
|
|
111
113
|
// to avoid this behavior, we cache the connected accounts
|
|
112
|
-
if (!this.canFetchConnectedAccounts) {
|
|
114
|
+
if (!this.canFetchConnectedAccounts && !forceFetch) {
|
|
113
115
|
return this.getConnectedAccountsFromCache();
|
|
114
116
|
}
|
|
115
117
|
// if we decide that is ok to prompt for a connection when fetching connected accounts
|
|
@@ -151,11 +153,12 @@ class BitcoinWalletConnector extends WalletConnectorBase {
|
|
|
151
153
|
}
|
|
152
154
|
sendRawTransaction(rawTransaction) {
|
|
153
155
|
return __awaiter(this, void 0, void 0, function* () {
|
|
154
|
-
if (!rawTransaction)
|
|
155
|
-
|
|
156
|
+
if (!rawTransaction) {
|
|
157
|
+
throw new DynamicError('No transaction specified!');
|
|
158
|
+
}
|
|
156
159
|
const [connectedAddress] = yield this.getConnectedAccounts();
|
|
157
160
|
if (!connectedAddress) {
|
|
158
|
-
throw new DynamicError('
|
|
161
|
+
throw new DynamicError('No connected address found!');
|
|
159
162
|
}
|
|
160
163
|
const API_URL = getMempoolApiUrl(connectedAddress);
|
|
161
164
|
const response = yield fetch(`${API_URL}/tx`, {
|
|
@@ -276,6 +279,18 @@ class BitcoinWalletConnector extends WalletConnectorBase {
|
|
|
276
279
|
isLedgerAddress(address) {
|
|
277
280
|
return isLedgerAddressViaVerifiedCredentials(address, this.verifiedCredentials);
|
|
278
281
|
}
|
|
282
|
+
proveOwnership(address, messageToSign) {
|
|
283
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
284
|
+
return this.signMessageWithAddress(messageToSign, address);
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
signMessageWithAddress(messageToSign,
|
|
288
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
289
|
+
_address) {
|
|
290
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
291
|
+
return this.signMessage(messageToSign);
|
|
292
|
+
});
|
|
293
|
+
}
|
|
279
294
|
}
|
|
280
295
|
|
|
281
296
|
export { BitcoinWalletConnector };
|
|
@@ -67,17 +67,13 @@ class PhantomConnector extends BitcoinWalletConnector.BitcoinWalletConnector {
|
|
|
67
67
|
return undefined;
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
|
-
|
|
70
|
+
signMessageWithAddress(messageToSign, address) {
|
|
71
71
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
72
72
|
var _a;
|
|
73
|
-
const [walletAddress] = yield this.getConnectedAccounts();
|
|
74
|
-
if (!walletAddress) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
73
|
if ((_a = this.walletMethods) === null || _a === void 0 ? void 0 : _a.signMessage) {
|
|
78
74
|
const [result] = yield this.walletMethods.signMessage({
|
|
79
75
|
// we need to sign with the ordinals account
|
|
80
|
-
account: { address
|
|
76
|
+
account: { address },
|
|
81
77
|
message: new TextEncoder().encode(messageToSign),
|
|
82
78
|
});
|
|
83
79
|
return Buffer.from(result.signature).toString('base64');
|
|
@@ -87,11 +83,20 @@ class PhantomConnector extends BitcoinWalletConnector.BitcoinWalletConnector {
|
|
|
87
83
|
if (!provider) {
|
|
88
84
|
return;
|
|
89
85
|
}
|
|
90
|
-
const result = yield provider.signMessage(
|
|
86
|
+
const result = yield provider.signMessage(address, new TextEncoder().encode(messageToSign));
|
|
91
87
|
return Buffer.from(result.signature).toString('base64');
|
|
92
88
|
}
|
|
93
89
|
});
|
|
94
90
|
}
|
|
91
|
+
signMessage(messageToSign) {
|
|
92
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
const [walletAddress] = yield this.getConnectedAccounts();
|
|
94
|
+
if (!walletAddress) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
return this.signMessageWithAddress(messageToSign, walletAddress);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
95
100
|
sendBitcoin(transaction) {
|
|
96
101
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
97
102
|
walletConnectorCore.logger.debug('sendBitcoin - function not implemented', transaction);
|
|
@@ -5,6 +5,7 @@ export declare class PhantomConnector extends BitcoinWalletConnector {
|
|
|
5
5
|
constructor(opts: BitcoinWalletConnectorOpts);
|
|
6
6
|
private connectWithInstalledExtension;
|
|
7
7
|
getAddress(): Promise<string | undefined>;
|
|
8
|
+
signMessageWithAddress(messageToSign: string, address: string): Promise<string | undefined>;
|
|
8
9
|
signMessage(messageToSign: string): Promise<string | undefined>;
|
|
9
10
|
sendBitcoin(transaction: BitcoinTransaction): Promise<string | undefined>;
|
|
10
11
|
signPsbt(request: BitcoinSignPsbtRequest): Promise<BitcoinSignPsbtResponse | undefined>;
|
|
@@ -63,17 +63,13 @@ class PhantomConnector extends BitcoinWalletConnector {
|
|
|
63
63
|
return undefined;
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
signMessageWithAddress(messageToSign, address) {
|
|
67
67
|
return __awaiter(this, void 0, void 0, function* () {
|
|
68
68
|
var _a;
|
|
69
|
-
const [walletAddress] = yield this.getConnectedAccounts();
|
|
70
|
-
if (!walletAddress) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
69
|
if ((_a = this.walletMethods) === null || _a === void 0 ? void 0 : _a.signMessage) {
|
|
74
70
|
const [result] = yield this.walletMethods.signMessage({
|
|
75
71
|
// we need to sign with the ordinals account
|
|
76
|
-
account: { address
|
|
72
|
+
account: { address },
|
|
77
73
|
message: new TextEncoder().encode(messageToSign),
|
|
78
74
|
});
|
|
79
75
|
return Buffer.from(result.signature).toString('base64');
|
|
@@ -83,11 +79,20 @@ class PhantomConnector extends BitcoinWalletConnector {
|
|
|
83
79
|
if (!provider) {
|
|
84
80
|
return;
|
|
85
81
|
}
|
|
86
|
-
const result = yield provider.signMessage(
|
|
82
|
+
const result = yield provider.signMessage(address, new TextEncoder().encode(messageToSign));
|
|
87
83
|
return Buffer.from(result.signature).toString('base64');
|
|
88
84
|
}
|
|
89
85
|
});
|
|
90
86
|
}
|
|
87
|
+
signMessage(messageToSign) {
|
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
const [walletAddress] = yield this.getConnectedAccounts();
|
|
90
|
+
if (!walletAddress) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
return this.signMessageWithAddress(messageToSign, walletAddress);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
91
96
|
sendBitcoin(transaction) {
|
|
92
97
|
return __awaiter(this, void 0, void 0, function* () {
|
|
93
98
|
logger.debug('sendBitcoin - function not implemented', transaction);
|
package/src/index.cjs
CHANGED
|
@@ -20,6 +20,8 @@ var OkxConnector = require('./connectors/OkxConnector/OkxConnector.cjs');
|
|
|
20
20
|
var UnisatConnector = require('./connectors/UnisatConnector/UnisatConnector.cjs');
|
|
21
21
|
var UnknownInjected = require('./connectors/UnknownInjected/UnknownInjected.cjs');
|
|
22
22
|
var FallbackBitcoinConnector = require('./connectors/FallbackBitcoinConnector/FallbackBitcoinConnector.cjs');
|
|
23
|
+
var BitcoinWallet = require('./wallet/BitcoinWallet.cjs');
|
|
24
|
+
var isBitcoinWallet = require('./wallet/isBitcoinWallet/isBitcoinWallet.cjs');
|
|
23
25
|
|
|
24
26
|
const BitcoinWalletConnectors = (props) => [
|
|
25
27
|
...fetchSatsConnectConnectors.fetchSatsConnectConnectors(props),
|
|
@@ -37,4 +39,6 @@ exports.fetchSatsConnectConnectors = fetchSatsConnectConnectors.fetchSatsConnect
|
|
|
37
39
|
exports.hasSatsConnectFeature = hasSatsConnectFeature.hasSatsConnectFeature;
|
|
38
40
|
exports.supportsSatsConnect = supportsSatsConnect.supportsSatsConnect;
|
|
39
41
|
exports.getMempoolApiUrl = getMempoolApiUrl.getMempoolApiUrl;
|
|
42
|
+
exports.BitcoinWallet = BitcoinWallet.BitcoinWallet;
|
|
43
|
+
exports.isBitcoinWallet = isBitcoinWallet.isBitcoinWallet;
|
|
40
44
|
exports.BitcoinWalletConnectors = BitcoinWalletConnectors;
|
package/src/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { OkxConnector,
|
|
1
|
+
import { OkxConnector, UnknownInjectedConnector, PhantomConnector } from './connectors';
|
|
2
2
|
export { BitcoinWalletConnector } from './connectors';
|
|
3
3
|
export type { BitcoinTransaction } from './types';
|
|
4
4
|
export * from './utils';
|
|
5
|
-
export
|
|
5
|
+
export * from './wallet';
|
|
6
|
+
export declare const BitcoinWalletConnectors: (props: any) => (import("dist/packages/wallet-connector-core/src").WalletConnectorConstructor | typeof PhantomConnector | typeof OkxConnector | typeof UnknownInjectedConnector)[];
|
package/src/index.js
CHANGED
|
@@ -18,6 +18,8 @@ import { OkxConnector } from './connectors/OkxConnector/OkxConnector.js';
|
|
|
18
18
|
import { UnisatConnector } from './connectors/UnisatConnector/UnisatConnector.js';
|
|
19
19
|
import { UnknownInjectedConnector } from './connectors/UnknownInjected/UnknownInjected.js';
|
|
20
20
|
import { FallbackBitcoinConnector } from './connectors/FallbackBitcoinConnector/FallbackBitcoinConnector.js';
|
|
21
|
+
export { BitcoinWallet } from './wallet/BitcoinWallet.js';
|
|
22
|
+
export { isBitcoinWallet } from './wallet/isBitcoinWallet/isBitcoinWallet.js';
|
|
21
23
|
|
|
22
24
|
const BitcoinWalletConnectors = (props) => [
|
|
23
25
|
...fetchSatsConnectConnectors(props),
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
7
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
8
|
+
|
|
9
|
+
class BitcoinWallet extends walletConnectorCore.Wallet {
|
|
10
|
+
/**
|
|
11
|
+
* Sends a raw transaction
|
|
12
|
+
* @returns A promise that resolves to the transaction id
|
|
13
|
+
*/
|
|
14
|
+
sendRawTransaction(rawTransaction) {
|
|
15
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
yield this.sync();
|
|
17
|
+
return this._connector.sendRawTransaction(rawTransaction);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Sends satoshis to a bitcoin address
|
|
22
|
+
* @returns A promise that resolves to the transaction id
|
|
23
|
+
*/
|
|
24
|
+
sendBitcoin(transaction) {
|
|
25
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
yield this.sync();
|
|
27
|
+
return this._connector.sendBitcoin(transaction);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Sings a PSBT
|
|
32
|
+
* @returns A promise that resolves to an object with the signed PSBT
|
|
33
|
+
* or undefined if no provider is available
|
|
34
|
+
*/
|
|
35
|
+
signPsbt(request) {
|
|
36
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
yield this.sync();
|
|
38
|
+
return this._connector.signPsbt(request);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Sings multiple PSBTs
|
|
43
|
+
* @returns A promise that resolves to an array of signed PSBTs in base64
|
|
44
|
+
* or undefined if no provider is available
|
|
45
|
+
*/
|
|
46
|
+
signPsbts(requests) {
|
|
47
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
yield this.sync();
|
|
49
|
+
return this._connector.signPsbts(requests);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
exports.BitcoinWallet = BitcoinWallet;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Wallet } from '@dynamic-labs/wallet-connector-core';
|
|
2
|
+
import { BitcoinWalletConnector } from '../connectors';
|
|
3
|
+
import { BitcoinSignPsbtRequest, BitcoinSignPsbtResponse, BitcoinTransaction } from '../types';
|
|
4
|
+
export declare class BitcoinWallet extends Wallet<BitcoinWalletConnector> {
|
|
5
|
+
/**
|
|
6
|
+
* Sends a raw transaction
|
|
7
|
+
* @returns A promise that resolves to the transaction id
|
|
8
|
+
*/
|
|
9
|
+
sendRawTransaction(rawTransaction: string): Promise<string>;
|
|
10
|
+
/**
|
|
11
|
+
* Sends satoshis to a bitcoin address
|
|
12
|
+
* @returns A promise that resolves to the transaction id
|
|
13
|
+
*/
|
|
14
|
+
sendBitcoin(transaction: BitcoinTransaction): Promise<string | undefined>;
|
|
15
|
+
/**
|
|
16
|
+
* Sings a PSBT
|
|
17
|
+
* @returns A promise that resolves to an object with the signed PSBT
|
|
18
|
+
* or undefined if no provider is available
|
|
19
|
+
*/
|
|
20
|
+
signPsbt(request: BitcoinSignPsbtRequest): Promise<BitcoinSignPsbtResponse | undefined>;
|
|
21
|
+
/**
|
|
22
|
+
* Sings multiple PSBTs
|
|
23
|
+
* @returns A promise that resolves to an array of signed PSBTs in base64
|
|
24
|
+
* or undefined if no provider is available
|
|
25
|
+
*/
|
|
26
|
+
signPsbts(requests: BitcoinSignPsbtRequest[]): Promise<string[] | undefined>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
3
|
+
import { Wallet } from '@dynamic-labs/wallet-connector-core';
|
|
4
|
+
|
|
5
|
+
class BitcoinWallet extends Wallet {
|
|
6
|
+
/**
|
|
7
|
+
* Sends a raw transaction
|
|
8
|
+
* @returns A promise that resolves to the transaction id
|
|
9
|
+
*/
|
|
10
|
+
sendRawTransaction(rawTransaction) {
|
|
11
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
12
|
+
yield this.sync();
|
|
13
|
+
return this._connector.sendRawTransaction(rawTransaction);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Sends satoshis to a bitcoin address
|
|
18
|
+
* @returns A promise that resolves to the transaction id
|
|
19
|
+
*/
|
|
20
|
+
sendBitcoin(transaction) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
yield this.sync();
|
|
23
|
+
return this._connector.sendBitcoin(transaction);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Sings a PSBT
|
|
28
|
+
* @returns A promise that resolves to an object with the signed PSBT
|
|
29
|
+
* or undefined if no provider is available
|
|
30
|
+
*/
|
|
31
|
+
signPsbt(request) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
yield this.sync();
|
|
34
|
+
return this._connector.signPsbt(request);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Sings multiple PSBTs
|
|
39
|
+
* @returns A promise that resolves to an array of signed PSBTs in base64
|
|
40
|
+
* or undefined if no provider is available
|
|
41
|
+
*/
|
|
42
|
+
signPsbts(requests) {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
yield this.sync();
|
|
45
|
+
return this._connector.signPsbts(requests);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { BitcoinWallet };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './isBitcoinWallet';
|