@dynamic-labs/bitcoin 4.0.0-alpha.3 → 4.0.0-alpha.31
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 +261 -0
- package/package.cjs +8 -0
- package/package.js +4 -0
- package/package.json +10 -16
- package/src/connectors/BitcoinSatsConnectConnector/BitcoinSatsConnectConnector.cjs +65 -15
- package/src/connectors/BitcoinSatsConnectConnector/BitcoinSatsConnectConnector.d.ts +8 -0
- package/src/connectors/BitcoinSatsConnectConnector/BitcoinSatsConnectConnector.js +67 -17
- package/src/connectors/BitcoinWalletConnector.cjs +9 -1
- package/src/connectors/BitcoinWalletConnector.d.ts +5 -6
- package/src/connectors/BitcoinWalletConnector.js +11 -3
- package/src/connectors/{BitcoinSatsConnectLegacyConnector/BitcoinSatsConnectLegacyConnector.cjs → MagicEdenConnector/MagicEdenConnector.cjs} +21 -48
- package/src/connectors/{BitcoinSatsConnectLegacyConnector/BitcoinSatsConnectLegacyConnector.d.ts → MagicEdenConnector/MagicEdenConnector.d.ts} +8 -1
- package/src/connectors/{BitcoinSatsConnectLegacyConnector/BitcoinSatsConnectLegacyConnector.js → MagicEdenConnector/MagicEdenConnector.js} +23 -50
- package/src/connectors/MagicEdenConnector/index.d.ts +1 -0
- package/src/connectors/OkxConnector/OkxConnector.cjs +3 -6
- package/src/connectors/OkxConnector/OkxConnector.d.ts +0 -1
- package/src/connectors/OkxConnector/OkxConnector.js +3 -6
- package/src/connectors/OylConnector/OylConnector.cjs +68 -0
- package/src/connectors/OylConnector/OylConnector.d.ts +10 -0
- package/src/connectors/OylConnector/OylConnector.js +64 -0
- package/src/connectors/OylConnector/index.d.ts +1 -0
- package/src/connectors/PhantomConnector/PhantomConnector.cjs +1 -7
- package/src/connectors/PhantomConnector/PhantomConnector.d.ts +1 -2
- package/src/connectors/PhantomConnector/PhantomConnector.js +1 -7
- package/src/connectors/index.d.ts +2 -1
- package/src/index.cjs +12 -6
- package/src/index.d.ts +2 -2
- package/src/index.js +12 -6
- package/src/utils/fetchSatsConnectConnectors/fetchSatsConnectConnectors.cjs +7 -17
- package/src/utils/fetchSatsConnectConnectors/fetchSatsConnectConnectors.d.ts +1 -1
- package/src/utils/fetchSatsConnectConnectors/fetchSatsConnectConnectors.js +7 -17
- package/src/utils/supportsSatsConnect.cjs +1 -0
- package/src/utils/supportsSatsConnect.js +1 -0
- package/src/connectors/BitcoinSatsConnectLegacyConnector/index.d.ts +0 -1
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import { EventEmitter } from 'stream';
|
|
1
|
+
import { type EventEmitter } from 'eventemitter3';
|
|
4
2
|
import type { Wallet } from '@wallet-standard/base';
|
|
5
|
-
import { Chain, IBitcoinWalletConnector, WalletConnectorBase } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
+
import { Chain, IBitcoinWalletConnector, WalletConnectorBase, WalletMetadata } from '@dynamic-labs/wallet-connector-core';
|
|
6
4
|
import { WalletBookSchema, WalletSchema } from '@dynamic-labs/wallet-book';
|
|
7
5
|
import { JwtVerifiedCredential, WalletAdditionalAddress } from '@dynamic-labs/sdk-api-core';
|
|
8
6
|
import { IBitcoinSessionCache } from '../BitcoinLocalStorageCache';
|
|
@@ -12,6 +10,7 @@ export type BitcoinWalletConnectorOpts = {
|
|
|
12
10
|
walletBook: WalletBookSchema;
|
|
13
11
|
walletData: WalletSchema;
|
|
14
12
|
overrideKey?: string;
|
|
13
|
+
metadata?: WalletMetadata;
|
|
15
14
|
};
|
|
16
15
|
export declare abstract class BitcoinWalletConnector extends WalletConnectorBase<typeof BitcoinWallet> implements IBitcoinWalletConnector {
|
|
17
16
|
cache: IBitcoinSessionCache;
|
|
@@ -40,8 +39,8 @@ export declare abstract class BitcoinWalletConnector extends WalletConnectorBase
|
|
|
40
39
|
getAdditionalAddresses(mainAddress?: string): Promise<WalletAdditionalAddress[]>;
|
|
41
40
|
setAdditionalAddresses(mainAddress: string, additionalAddresses: WalletAdditionalAddress[]): Promise<void>;
|
|
42
41
|
sendRawTransaction(rawTransaction: string): Promise<string>;
|
|
43
|
-
|
|
44
|
-
getProvider<T>(): T & EventEmitter
|
|
42
|
+
sendBitcoin(transaction: BitcoinTransaction): Promise<string | undefined>;
|
|
43
|
+
getProvider<T>(): T & EventEmitter<string | symbol, any>;
|
|
45
44
|
abstract signPsbt(request: BitcoinSignPsbtRequest): Promise<BitcoinSignPsbtResponse | undefined>;
|
|
46
45
|
signPsbts(requests: BitcoinSignPsbtRequest[]): Promise<string[] | undefined>;
|
|
47
46
|
setConnectedAccountWithAddresses({ mainAddress, ordinalsAddress, paymentAddress, active, }: ConnectedAccountWithAddressesProps): Promise<void>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
3
3
|
import { AddressPurpose } from 'sats-connect';
|
|
4
|
-
import { WalletConnectorBase, eventListenerHandlers, logger } from '@dynamic-labs/wallet-connector-core';
|
|
5
|
-
import { getWalletBookWallet,
|
|
4
|
+
import { WalletConnectorBase, isConnectorMethodSupported, eventListenerHandlers, logger } from '@dynamic-labs/wallet-connector-core';
|
|
5
|
+
import { getWalletBookWallet, findWalletBookWallet } from '@dynamic-labs/wallet-book';
|
|
6
6
|
import { isLedgerAddressViaVerifiedCredentials, DynamicError } from '@dynamic-labs/utils';
|
|
7
7
|
import { WalletAddressType } from '@dynamic-labs/sdk-api-core';
|
|
8
8
|
import { BitcoinLocalStorageCache } from '../BitcoinLocalStorageCache.js';
|
|
@@ -32,7 +32,7 @@ class BitcoinWalletConnector extends WalletConnectorBase {
|
|
|
32
32
|
this.walletMethods = this.bitcoinProviderHelper.getWalletMethods(this.wallet);
|
|
33
33
|
}
|
|
34
34
|
this.cache = new BitcoinLocalStorageCache(this.overrideKey);
|
|
35
|
-
this.canFetchConnectedAccounts =
|
|
35
|
+
this.canFetchConnectedAccounts = isConnectorMethodSupported(this, 'getConnectedAccounts', 'browserExtension');
|
|
36
36
|
}
|
|
37
37
|
isSameAccountChangeRequest(to) {
|
|
38
38
|
return this.lastAccountChange === to;
|
|
@@ -180,6 +180,14 @@ class BitcoinWalletConnector extends WalletConnectorBase {
|
|
|
180
180
|
return response.text();
|
|
181
181
|
});
|
|
182
182
|
}
|
|
183
|
+
// not all wallets support sendBitcoin method
|
|
184
|
+
// so we have a default implementation that returns undefined
|
|
185
|
+
sendBitcoin(transaction) {
|
|
186
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
187
|
+
logger.debug('sendBitcoin - function not implemented', transaction);
|
|
188
|
+
return undefined;
|
|
189
|
+
});
|
|
190
|
+
}
|
|
183
191
|
getProvider() {
|
|
184
192
|
var _a;
|
|
185
193
|
return (_a = this.bitcoinProviderHelper) === null || _a === void 0 ? void 0 : _a.getProvider();
|
|
@@ -4,46 +4,29 @@
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
6
|
var _tslib = require('../../../_virtual/_tslib.cjs');
|
|
7
|
+
var jsontokens = require('jsontokens');
|
|
7
8
|
var satsConnect = require('sats-connect');
|
|
8
9
|
var utils = require('@dynamic-labs/utils');
|
|
9
|
-
var walletBook = require('@dynamic-labs/wallet-book');
|
|
10
10
|
var _const = require('../../const.cjs');
|
|
11
11
|
require('bitcoinjs-lib');
|
|
12
12
|
require('@dynamic-labs/wallet-connector-core');
|
|
13
|
+
require('@dynamic-labs/wallet-book');
|
|
13
14
|
require('@dynamic-labs/sdk-api-core');
|
|
14
15
|
require('@wallet-standard/app');
|
|
15
16
|
var BitcoinSatsConnectConnector = require('../BitcoinSatsConnectConnector/BitcoinSatsConnectConnector.cjs');
|
|
16
17
|
var supportsSatsConnect = require('../../utils/supportsSatsConnect.cjs');
|
|
17
18
|
|
|
18
|
-
class
|
|
19
|
-
constructor() {
|
|
20
|
-
super(
|
|
19
|
+
class MagicEdenConnector extends BitcoinSatsConnectConnector.BitcoinSatsConnectConnector {
|
|
20
|
+
constructor(opts) {
|
|
21
|
+
super(Object.assign(Object.assign({}, opts), { overrideKey: 'magicedenbtc' }));
|
|
22
|
+
this.name = 'Magic Eden';
|
|
23
|
+
this.overrideKey = 'magicedenbtc';
|
|
21
24
|
this.isLegacy = true;
|
|
22
25
|
}
|
|
23
26
|
getAddress() {
|
|
24
27
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
|
|
26
|
-
// xverse doesn't support wallet standard, so we won't have a wallet object,
|
|
27
|
-
// but it's already the default provider for sats-connect, so it's ok
|
|
28
|
-
// for getProvider in getAddress to return undefined
|
|
29
|
-
// if we're not using xverse, we need to check if there is a wallet and
|
|
30
|
-
// that it has the satsconnect feature to return the correct provider to use
|
|
31
|
-
if (!supportsSatsConnect.supportsSatsConnect(this)) {
|
|
28
|
+
if (this.handleInAppBrowserGetAddress())
|
|
32
29
|
return;
|
|
33
|
-
}
|
|
34
|
-
const wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
|
|
35
|
-
const inAppBrowserUrl = (_a = wallet === null || wallet === void 0 ? void 0 : wallet.mobile) === null || _a === void 0 ? void 0 : _a.inAppBrowser;
|
|
36
|
-
if (utils.isMobile() &&
|
|
37
|
-
!this.isInstalledOnBrowser() &&
|
|
38
|
-
inAppBrowserUrl &&
|
|
39
|
-
this.mobileExperience === 'in-app-browser') {
|
|
40
|
-
const inAppBrowserTemplate = utils.template(inAppBrowserUrl);
|
|
41
|
-
const deepLink = inAppBrowserTemplate({
|
|
42
|
-
encodedDappURI: encodeURIComponent(window.location.toString()),
|
|
43
|
-
});
|
|
44
|
-
window.location.href = deepLink;
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
30
|
return new Promise((resolve, reject) => {
|
|
48
31
|
satsConnect.getAddress({
|
|
49
32
|
getProvider: () => _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
@@ -185,32 +168,22 @@ class BitcoinSatsConnectLegacyConnector extends BitcoinSatsConnectConnector.Bitc
|
|
|
185
168
|
});
|
|
186
169
|
});
|
|
187
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Uses the custom Magic Eden signTransactions feature to sign multiple transactions
|
|
173
|
+
*/
|
|
188
174
|
signTransactions(transactions) {
|
|
189
175
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
error.code = '-32000'; // error code for user cancelled
|
|
200
|
-
reject(error);
|
|
201
|
-
},
|
|
202
|
-
onFinish: (response) => {
|
|
203
|
-
resolve(response);
|
|
204
|
-
},
|
|
205
|
-
payload: {
|
|
206
|
-
message: message || 'Sign Transaction',
|
|
207
|
-
network,
|
|
208
|
-
psbts,
|
|
209
|
-
},
|
|
210
|
-
});
|
|
211
|
-
});
|
|
176
|
+
var _a;
|
|
177
|
+
(_a = transactions.message) !== null && _a !== void 0 ? _a : (transactions.message = 'Sign Transaction');
|
|
178
|
+
const request = jsontokens.createUnsecuredToken(transactions);
|
|
179
|
+
// Magic Eden has implemented their own signTransactions feature, and have requested us
|
|
180
|
+
// to ensure we use it rather than the general Sats Connect API for this method
|
|
181
|
+
const provider = this.getProvider();
|
|
182
|
+
if (!provider)
|
|
183
|
+
throw new utils.DynamicError('signTransactions failed: Magic Eden provider not found');
|
|
184
|
+
return provider.signMultipleTransactions(request);
|
|
212
185
|
});
|
|
213
186
|
}
|
|
214
187
|
}
|
|
215
188
|
|
|
216
|
-
exports.
|
|
189
|
+
exports.MagicEdenConnector = MagicEdenConnector;
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { SignMultipleTransactionsPayload, SignTransactionResponse } from 'sats-connect';
|
|
2
2
|
import { BitcoinTransaction, SatsConnectSignTransactionInput } from '../../types';
|
|
3
3
|
import { BitcoinSatsConnectConnector } from '../BitcoinSatsConnectConnector';
|
|
4
|
-
|
|
4
|
+
import { BitcoinWalletConnectorOpts } from '../BitcoinWalletConnector';
|
|
5
|
+
export declare class MagicEdenConnector extends BitcoinSatsConnectConnector {
|
|
6
|
+
name: string;
|
|
7
|
+
overrideKey: string;
|
|
5
8
|
isLegacy: boolean;
|
|
9
|
+
constructor(opts: BitcoinWalletConnectorOpts);
|
|
6
10
|
getAddress(): Promise<string | undefined>;
|
|
7
11
|
signMessage(messageToSign: string, withAddress: string): Promise<string | undefined>;
|
|
8
12
|
sendBitcoin(transaction: BitcoinTransaction): Promise<string | undefined>;
|
|
9
13
|
signTransaction(params: SatsConnectSignTransactionInput): Promise<SignTransactionResponse | undefined>;
|
|
14
|
+
/**
|
|
15
|
+
* Uses the custom Magic Eden signTransactions feature to sign multiple transactions
|
|
16
|
+
*/
|
|
10
17
|
signTransactions(transactions: SignMultipleTransactionsPayload): Promise<SignTransactionResponse[] | undefined>;
|
|
11
18
|
}
|
|
@@ -1,45 +1,28 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../_virtual/_tslib.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { createUnsecuredToken } from 'jsontokens';
|
|
4
|
+
import { getAddress, AddressPurpose, signMessage, sendBtcTransaction, signTransaction } from 'sats-connect';
|
|
5
|
+
import { DynamicError } from '@dynamic-labs/utils';
|
|
6
6
|
import { SATSCONNECT_FEATURE } from '../../const.js';
|
|
7
7
|
import 'bitcoinjs-lib';
|
|
8
8
|
import '@dynamic-labs/wallet-connector-core';
|
|
9
|
+
import '@dynamic-labs/wallet-book';
|
|
9
10
|
import '@dynamic-labs/sdk-api-core';
|
|
10
11
|
import '@wallet-standard/app';
|
|
11
12
|
import { BitcoinSatsConnectConnector } from '../BitcoinSatsConnectConnector/BitcoinSatsConnectConnector.js';
|
|
12
13
|
import { supportsSatsConnect } from '../../utils/supportsSatsConnect.js';
|
|
13
14
|
|
|
14
|
-
class
|
|
15
|
-
constructor() {
|
|
16
|
-
super(
|
|
15
|
+
class MagicEdenConnector extends BitcoinSatsConnectConnector {
|
|
16
|
+
constructor(opts) {
|
|
17
|
+
super(Object.assign(Object.assign({}, opts), { overrideKey: 'magicedenbtc' }));
|
|
18
|
+
this.name = 'Magic Eden';
|
|
19
|
+
this.overrideKey = 'magicedenbtc';
|
|
17
20
|
this.isLegacy = true;
|
|
18
21
|
}
|
|
19
22
|
getAddress() {
|
|
20
23
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
|
|
22
|
-
// xverse doesn't support wallet standard, so we won't have a wallet object,
|
|
23
|
-
// but it's already the default provider for sats-connect, so it's ok
|
|
24
|
-
// for getProvider in getAddress to return undefined
|
|
25
|
-
// if we're not using xverse, we need to check if there is a wallet and
|
|
26
|
-
// that it has the satsconnect feature to return the correct provider to use
|
|
27
|
-
if (!supportsSatsConnect(this)) {
|
|
24
|
+
if (this.handleInAppBrowserGetAddress())
|
|
28
25
|
return;
|
|
29
|
-
}
|
|
30
|
-
const wallet = findWalletBookWallet(this.walletBook, this.key);
|
|
31
|
-
const inAppBrowserUrl = (_a = wallet === null || wallet === void 0 ? void 0 : wallet.mobile) === null || _a === void 0 ? void 0 : _a.inAppBrowser;
|
|
32
|
-
if (isMobile() &&
|
|
33
|
-
!this.isInstalledOnBrowser() &&
|
|
34
|
-
inAppBrowserUrl &&
|
|
35
|
-
this.mobileExperience === 'in-app-browser') {
|
|
36
|
-
const inAppBrowserTemplate = template(inAppBrowserUrl);
|
|
37
|
-
const deepLink = inAppBrowserTemplate({
|
|
38
|
-
encodedDappURI: encodeURIComponent(window.location.toString()),
|
|
39
|
-
});
|
|
40
|
-
window.location.href = deepLink;
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
26
|
return new Promise((resolve, reject) => {
|
|
44
27
|
getAddress({
|
|
45
28
|
getProvider: () => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -181,32 +164,22 @@ class BitcoinSatsConnectLegacyConnector extends BitcoinSatsConnectConnector {
|
|
|
181
164
|
});
|
|
182
165
|
});
|
|
183
166
|
}
|
|
167
|
+
/**
|
|
168
|
+
* Uses the custom Magic Eden signTransactions feature to sign multiple transactions
|
|
169
|
+
*/
|
|
184
170
|
signTransactions(transactions) {
|
|
185
171
|
return __awaiter(this, void 0, void 0, function* () {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
error.code = '-32000'; // error code for user cancelled
|
|
196
|
-
reject(error);
|
|
197
|
-
},
|
|
198
|
-
onFinish: (response) => {
|
|
199
|
-
resolve(response);
|
|
200
|
-
},
|
|
201
|
-
payload: {
|
|
202
|
-
message: message || 'Sign Transaction',
|
|
203
|
-
network,
|
|
204
|
-
psbts,
|
|
205
|
-
},
|
|
206
|
-
});
|
|
207
|
-
});
|
|
172
|
+
var _a;
|
|
173
|
+
(_a = transactions.message) !== null && _a !== void 0 ? _a : (transactions.message = 'Sign Transaction');
|
|
174
|
+
const request = createUnsecuredToken(transactions);
|
|
175
|
+
// Magic Eden has implemented their own signTransactions feature, and have requested us
|
|
176
|
+
// to ensure we use it rather than the general Sats Connect API for this method
|
|
177
|
+
const provider = this.getProvider();
|
|
178
|
+
if (!provider)
|
|
179
|
+
throw new DynamicError('signTransactions failed: Magic Eden provider not found');
|
|
180
|
+
return provider.signMultipleTransactions(request);
|
|
208
181
|
});
|
|
209
182
|
}
|
|
210
183
|
}
|
|
211
184
|
|
|
212
|
-
export {
|
|
185
|
+
export { MagicEdenConnector };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MagicEdenConnector } from './MagicEdenConnector';
|
|
@@ -14,17 +14,14 @@ class OkxConnector extends BitcoinWalletConnector.BitcoinWalletConnector {
|
|
|
14
14
|
super(Object.assign(Object.assign({}, opts), { overrideKey: 'okxwalletbtc' }));
|
|
15
15
|
this.name = 'OKX Wallet';
|
|
16
16
|
}
|
|
17
|
-
get walletBookWallet() {
|
|
18
|
-
return this.walletBook.wallets[this.key];
|
|
19
|
-
}
|
|
20
17
|
getAddress() {
|
|
21
18
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
var _a;
|
|
22
20
|
if (!this.isInstalledOnBrowser() &&
|
|
23
21
|
utils.isMobile() &&
|
|
24
|
-
this.
|
|
25
|
-
this.walletBookWallet.mobile.inAppBrowser &&
|
|
22
|
+
((_a = this.metadata) === null || _a === void 0 ? void 0 : _a.inAppBrowserUrl) &&
|
|
26
23
|
this.mobileExperience === 'in-app-browser') {
|
|
27
|
-
const inAppBrowserCompiledTemplate = utils.template(this.
|
|
24
|
+
const inAppBrowserCompiledTemplate = utils.template(this.metadata.inAppBrowserUrl);
|
|
28
25
|
const deepLink = inAppBrowserCompiledTemplate({
|
|
29
26
|
encodedDappURI: encodeURIComponent(window.location.toString()),
|
|
30
27
|
});
|
|
@@ -3,7 +3,6 @@ import { BitcoinTransaction, BitcoinSignPsbtRequest, BitcoinSignPsbtResponse } f
|
|
|
3
3
|
export declare class OkxConnector extends BitcoinWalletConnector {
|
|
4
4
|
name: string;
|
|
5
5
|
constructor(opts: BitcoinWalletConnectorOpts);
|
|
6
|
-
private get walletBookWallet();
|
|
7
6
|
getAddress(): Promise<string | undefined>;
|
|
8
7
|
signMessage(messageToSign: string): Promise<string | undefined>;
|
|
9
8
|
sendBitcoin(transaction: BitcoinTransaction): Promise<string | undefined>;
|
|
@@ -10,17 +10,14 @@ class OkxConnector extends BitcoinWalletConnector {
|
|
|
10
10
|
super(Object.assign(Object.assign({}, opts), { overrideKey: 'okxwalletbtc' }));
|
|
11
11
|
this.name = 'OKX Wallet';
|
|
12
12
|
}
|
|
13
|
-
get walletBookWallet() {
|
|
14
|
-
return this.walletBook.wallets[this.key];
|
|
15
|
-
}
|
|
16
13
|
getAddress() {
|
|
17
14
|
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
var _a;
|
|
18
16
|
if (!this.isInstalledOnBrowser() &&
|
|
19
17
|
isMobile() &&
|
|
20
|
-
this.
|
|
21
|
-
this.walletBookWallet.mobile.inAppBrowser &&
|
|
18
|
+
((_a = this.metadata) === null || _a === void 0 ? void 0 : _a.inAppBrowserUrl) &&
|
|
22
19
|
this.mobileExperience === 'in-app-browser') {
|
|
23
|
-
const inAppBrowserCompiledTemplate = template(this.
|
|
20
|
+
const inAppBrowserCompiledTemplate = template(this.metadata.inAppBrowserUrl);
|
|
24
21
|
const deepLink = inAppBrowserCompiledTemplate({
|
|
25
22
|
encodedDappURI: encodeURIComponent(window.location.toString()),
|
|
26
23
|
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../_virtual/_tslib.cjs');
|
|
7
|
+
var bitcoinjsLib = require('bitcoinjs-lib');
|
|
8
|
+
var BitcoinWalletConnector = require('../BitcoinWalletConnector.cjs');
|
|
9
|
+
var createSignPsbtOptions = require('../../utils/psbt/createSignPsbtOptions.cjs');
|
|
10
|
+
|
|
11
|
+
class OylConnector extends BitcoinWalletConnector.BitcoinWalletConnector {
|
|
12
|
+
constructor(opts) {
|
|
13
|
+
super(Object.assign(Object.assign({}, opts), { overrideKey: 'oylwallet' }));
|
|
14
|
+
this.name = 'Oyl Wallet';
|
|
15
|
+
this.overrideKey = 'oylwallet';
|
|
16
|
+
}
|
|
17
|
+
getAddress() {
|
|
18
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
var _a;
|
|
20
|
+
const provider = this.getProvider();
|
|
21
|
+
if (!provider) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const addresses = yield provider.getAddresses();
|
|
25
|
+
const ordinalsAddress = addresses.taproot;
|
|
26
|
+
const paymentAddress = addresses.nativeSegwit;
|
|
27
|
+
const mainAddress = (_a = ordinalsAddress === null || ordinalsAddress === void 0 ? void 0 : ordinalsAddress.address) !== null && _a !== void 0 ? _a : paymentAddress === null || paymentAddress === void 0 ? void 0 : paymentAddress.address;
|
|
28
|
+
yield this.setConnectedAccountWithAddresses({
|
|
29
|
+
active: true,
|
|
30
|
+
mainAddress,
|
|
31
|
+
ordinalsAddress,
|
|
32
|
+
paymentAddress,
|
|
33
|
+
});
|
|
34
|
+
return mainAddress;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
signMessage(messageToSign, withAddress) {
|
|
38
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const provider = this.getProvider();
|
|
40
|
+
if (!provider) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const { signature } = yield provider.signMessage({
|
|
44
|
+
address: withAddress,
|
|
45
|
+
message: messageToSign,
|
|
46
|
+
});
|
|
47
|
+
return signature;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
signPsbt(request) {
|
|
51
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
const provider = this.getProvider();
|
|
53
|
+
if (!provider) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const psbtFromBase64 = bitcoinjsLib.Psbt.fromBase64(request.unsignedPsbtBase64);
|
|
57
|
+
const options = createSignPsbtOptions.createPsbtOptions(psbtFromBase64, request);
|
|
58
|
+
const { psbt: signedPsbtHex } = yield provider.signPsbt({
|
|
59
|
+
broadcast: false,
|
|
60
|
+
finalize: options.autoFinalized,
|
|
61
|
+
psbt: psbtFromBase64.toHex(),
|
|
62
|
+
});
|
|
63
|
+
return { signedPsbt: bitcoinjsLib.Psbt.fromHex(signedPsbtHex).toBase64() };
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
exports.OylConnector = OylConnector;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BitcoinWalletConnector, BitcoinWalletConnectorOpts } from '../BitcoinWalletConnector';
|
|
2
|
+
import { BitcoinSignPsbtRequest, BitcoinSignPsbtResponse } from '../../types';
|
|
3
|
+
export declare class OylConnector extends BitcoinWalletConnector {
|
|
4
|
+
name: string;
|
|
5
|
+
overrideKey: string;
|
|
6
|
+
constructor(opts: BitcoinWalletConnectorOpts);
|
|
7
|
+
getAddress(): Promise<string | undefined>;
|
|
8
|
+
signMessage(messageToSign: string, withAddress: string): Promise<string | undefined>;
|
|
9
|
+
signPsbt(request: BitcoinSignPsbtRequest): Promise<BitcoinSignPsbtResponse | undefined>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../_virtual/_tslib.js';
|
|
3
|
+
import { Psbt } from 'bitcoinjs-lib';
|
|
4
|
+
import { BitcoinWalletConnector } from '../BitcoinWalletConnector.js';
|
|
5
|
+
import { createPsbtOptions } from '../../utils/psbt/createSignPsbtOptions.js';
|
|
6
|
+
|
|
7
|
+
class OylConnector extends BitcoinWalletConnector {
|
|
8
|
+
constructor(opts) {
|
|
9
|
+
super(Object.assign(Object.assign({}, opts), { overrideKey: 'oylwallet' }));
|
|
10
|
+
this.name = 'Oyl Wallet';
|
|
11
|
+
this.overrideKey = 'oylwallet';
|
|
12
|
+
}
|
|
13
|
+
getAddress() {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
var _a;
|
|
16
|
+
const provider = this.getProvider();
|
|
17
|
+
if (!provider) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const addresses = yield provider.getAddresses();
|
|
21
|
+
const ordinalsAddress = addresses.taproot;
|
|
22
|
+
const paymentAddress = addresses.nativeSegwit;
|
|
23
|
+
const mainAddress = (_a = ordinalsAddress === null || ordinalsAddress === void 0 ? void 0 : ordinalsAddress.address) !== null && _a !== void 0 ? _a : paymentAddress === null || paymentAddress === void 0 ? void 0 : paymentAddress.address;
|
|
24
|
+
yield this.setConnectedAccountWithAddresses({
|
|
25
|
+
active: true,
|
|
26
|
+
mainAddress,
|
|
27
|
+
ordinalsAddress,
|
|
28
|
+
paymentAddress,
|
|
29
|
+
});
|
|
30
|
+
return mainAddress;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
signMessage(messageToSign, withAddress) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const provider = this.getProvider();
|
|
36
|
+
if (!provider) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const { signature } = yield provider.signMessage({
|
|
40
|
+
address: withAddress,
|
|
41
|
+
message: messageToSign,
|
|
42
|
+
});
|
|
43
|
+
return signature;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
signPsbt(request) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
const provider = this.getProvider();
|
|
49
|
+
if (!provider) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const psbtFromBase64 = Psbt.fromBase64(request.unsignedPsbtBase64);
|
|
53
|
+
const options = createPsbtOptions(psbtFromBase64, request);
|
|
54
|
+
const { psbt: signedPsbtHex } = yield provider.signPsbt({
|
|
55
|
+
broadcast: false,
|
|
56
|
+
finalize: options.autoFinalized,
|
|
57
|
+
psbt: psbtFromBase64.toHex(),
|
|
58
|
+
});
|
|
59
|
+
return { signedPsbt: Psbt.fromHex(signedPsbtHex).toBase64() };
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export { OylConnector };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { OylConnector } from './OylConnector';
|
|
@@ -5,10 +5,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
var _tslib = require('../../../_virtual/_tslib.cjs');
|
|
7
7
|
var bitcoinjsLib = require('bitcoinjs-lib');
|
|
8
|
-
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
9
8
|
var utils = require('@dynamic-labs/utils');
|
|
10
9
|
var BitcoinWalletConnector = require('../BitcoinWalletConnector.cjs');
|
|
11
10
|
var createSignPsbtOptions = require('../../utils/psbt/createSignPsbtOptions.cjs');
|
|
11
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
12
12
|
require('sats-connect');
|
|
13
13
|
var sighashNumberToString = require('../../utils/psbt/sighashNumberToString.cjs');
|
|
14
14
|
var base64 = require('../../utils/base64.cjs');
|
|
@@ -88,12 +88,6 @@ class PhantomConnector extends BitcoinWalletConnector.BitcoinWalletConnector {
|
|
|
88
88
|
}
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
|
-
sendBitcoin(transaction) {
|
|
92
|
-
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
walletConnectorCore.logger.debug('sendBitcoin - function not implemented', transaction);
|
|
94
|
-
return undefined;
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
91
|
signPsbt(request) {
|
|
98
92
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
99
93
|
var _a, _b, _c, _d, _e;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BitcoinSignPsbtRequest, BitcoinSignPsbtResponse } from '../../types';
|
|
2
2
|
import { BitcoinWalletConnector, BitcoinWalletConnectorOpts } from '../BitcoinWalletConnector';
|
|
3
3
|
export declare class PhantomConnector extends BitcoinWalletConnector {
|
|
4
4
|
name: string;
|
|
@@ -6,6 +6,5 @@ export declare class PhantomConnector extends BitcoinWalletConnector {
|
|
|
6
6
|
private connectWithInstalledExtension;
|
|
7
7
|
getAddress(): Promise<string | undefined>;
|
|
8
8
|
signMessage(messageToSign: string, withAddress: string): Promise<string | undefined>;
|
|
9
|
-
sendBitcoin(transaction: BitcoinTransaction): Promise<string | undefined>;
|
|
10
9
|
signPsbt(request: BitcoinSignPsbtRequest): Promise<BitcoinSignPsbtResponse | undefined>;
|
|
11
10
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../_virtual/_tslib.js';
|
|
3
3
|
import { Psbt } from 'bitcoinjs-lib';
|
|
4
|
-
import { logger } from '@dynamic-labs/wallet-connector-core';
|
|
5
4
|
import { isMobile, handleMobileWalletRedirect } from '@dynamic-labs/utils';
|
|
6
5
|
import { BitcoinWalletConnector } from '../BitcoinWalletConnector.js';
|
|
7
6
|
import { createPsbtOptions } from '../../utils/psbt/createSignPsbtOptions.js';
|
|
7
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
8
8
|
import 'sats-connect';
|
|
9
9
|
import { sighashNumberToString } from '../../utils/psbt/sighashNumberToString.js';
|
|
10
10
|
import { decodeBase64, encodeBase64 } from '../../utils/base64.js';
|
|
@@ -84,12 +84,6 @@ class PhantomConnector extends BitcoinWalletConnector {
|
|
|
84
84
|
}
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
|
-
sendBitcoin(transaction) {
|
|
88
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
-
logger.debug('sendBitcoin - function not implemented', transaction);
|
|
90
|
-
return undefined;
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
87
|
signPsbt(request) {
|
|
94
88
|
return __awaiter(this, void 0, void 0, function* () {
|
|
95
89
|
var _a, _b, _c, _d, _e;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export * from './BitcoinWalletConnector';
|
|
2
2
|
export * from './BitcoinBtcKitConnector';
|
|
3
3
|
export * from './BitcoinSatsConnectConnector';
|
|
4
|
-
export * from './
|
|
4
|
+
export * from './MagicEdenConnector';
|
|
5
5
|
export * from './PhantomConnector';
|
|
6
6
|
export * from './OkxConnector';
|
|
7
|
+
export * from './OylConnector';
|
|
7
8
|
export * from './UnisatConnector';
|
|
8
9
|
export * from './UnknownInjected';
|
|
9
10
|
export * from './FallbackBitcoinConnector';
|
package/src/index.cjs
CHANGED
|
@@ -3,31 +3,37 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
+
var assertPackageVersion = require('@dynamic-labs/assert-package-version');
|
|
7
|
+
var _package = require('../package.cjs');
|
|
6
8
|
var BitcoinWalletConnector = require('./connectors/BitcoinWalletConnector.cjs');
|
|
7
9
|
require('../_virtual/_tslib.cjs');
|
|
8
10
|
require('sats-connect');
|
|
9
11
|
require('bitcoinjs-lib');
|
|
10
12
|
require('@dynamic-labs/wallet-connector-core');
|
|
11
13
|
require('@dynamic-labs/utils');
|
|
12
|
-
require('
|
|
13
|
-
var fetchBtcKitConnectors = require('./utils/fetchBtcKitConnectors/fetchBtcKitConnectors.cjs');
|
|
14
|
-
var fetchSatsConnectConnectors = require('./utils/fetchSatsConnectConnectors/fetchSatsConnectConnectors.cjs');
|
|
15
|
-
var hasSatsConnectFeature = require('./utils/hasSatsConnectFeature.cjs');
|
|
16
|
-
var supportsSatsConnect = require('./utils/supportsSatsConnect.cjs');
|
|
17
|
-
var getMempoolApiUrl = require('./utils/getMempoolApiUrl.cjs');
|
|
14
|
+
var MagicEdenConnector = require('./connectors/MagicEdenConnector/MagicEdenConnector.cjs');
|
|
18
15
|
var PhantomConnector = require('./connectors/PhantomConnector/PhantomConnector.cjs');
|
|
19
16
|
var OkxConnector = require('./connectors/OkxConnector/OkxConnector.cjs');
|
|
17
|
+
var OylConnector = require('./connectors/OylConnector/OylConnector.cjs');
|
|
20
18
|
var UnisatConnector = require('./connectors/UnisatConnector/UnisatConnector.cjs');
|
|
21
19
|
var UnknownInjected = require('./connectors/UnknownInjected/UnknownInjected.cjs');
|
|
22
20
|
var FallbackBitcoinConnector = require('./connectors/FallbackBitcoinConnector/FallbackBitcoinConnector.cjs');
|
|
21
|
+
var fetchBtcKitConnectors = require('./utils/fetchBtcKitConnectors/fetchBtcKitConnectors.cjs');
|
|
22
|
+
var fetchSatsConnectConnectors = require('./utils/fetchSatsConnectConnectors/fetchSatsConnectConnectors.cjs');
|
|
23
|
+
var hasSatsConnectFeature = require('./utils/hasSatsConnectFeature.cjs');
|
|
24
|
+
var supportsSatsConnect = require('./utils/supportsSatsConnect.cjs');
|
|
25
|
+
var getMempoolApiUrl = require('./utils/getMempoolApiUrl.cjs');
|
|
23
26
|
var BitcoinWallet = require('./wallet/BitcoinWallet.cjs');
|
|
24
27
|
var isBitcoinWallet = require('./wallet/isBitcoinWallet/isBitcoinWallet.cjs');
|
|
25
28
|
|
|
29
|
+
assertPackageVersion.assertPackageVersion('@dynamic-labs/bitcoin', _package.version);
|
|
26
30
|
const BitcoinWalletConnectors = (props) => [
|
|
27
31
|
...fetchSatsConnectConnectors.fetchSatsConnectConnectors(props),
|
|
28
32
|
...fetchBtcKitConnectors.fetchBtcKitConnectors(props),
|
|
33
|
+
MagicEdenConnector.MagicEdenConnector,
|
|
29
34
|
PhantomConnector.PhantomConnector,
|
|
30
35
|
OkxConnector.OkxConnector,
|
|
36
|
+
OylConnector.OylConnector,
|
|
31
37
|
UnisatConnector.UnisatConnector,
|
|
32
38
|
UnknownInjected.UnknownInjectedConnector,
|
|
33
39
|
FallbackBitcoinConnector.FallbackBitcoinConnector,
|
package/src/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { OkxConnector,
|
|
1
|
+
import { OkxConnector, OylConnector, PhantomConnector } from './connectors';
|
|
2
2
|
export { BitcoinWalletConnector } from './connectors';
|
|
3
3
|
export type { BitcoinTransaction } from './types';
|
|
4
4
|
export * from './utils';
|
|
5
5
|
export * from './wallet';
|
|
6
|
-
export declare const BitcoinWalletConnectors: (props: any) => (import("dist/packages/wallet-connector-core/src").WalletConnectorConstructor | typeof PhantomConnector | typeof OkxConnector | typeof
|
|
6
|
+
export declare const BitcoinWalletConnectors: (props: any) => (import("dist/packages/wallet-connector-core/src").WalletConnectorConstructor | typeof PhantomConnector | typeof OkxConnector | typeof OylConnector)[];
|