@dynamic-labs/bitcoin 4.104.0 → 4.105.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 +12 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +9 -10
- package/src/connectors/DynamicWaasBitcoinConnector/DynamicWaasBitcoinConnector.cjs +4 -1
- package/src/connectors/DynamicWaasBitcoinConnector/DynamicWaasBitcoinConnector.d.ts +3 -0
- package/src/connectors/DynamicWaasBitcoinConnector/DynamicWaasBitcoinConnector.js +4 -1
- package/src/connectors/index.d.ts +0 -1
- package/src/index.cjs +0 -2
- package/src/index.d.ts +2 -2
- package/src/index.js +0 -2
- package/src/services/MempoolApiService.cjs +0 -1
- package/src/services/MempoolApiService.js +0 -1
- package/src/types.d.ts +8 -0
- package/src/utils/fetchSatsConnectConnectors/fetchSatsConnectConnectors.cjs +0 -1
- package/src/utils/fetchSatsConnectConnectors/fetchSatsConnectConnectors.js +0 -1
- package/src/connectors/MagicEdenConnector/MagicEdenConnector.cjs +0 -183
- package/src/connectors/MagicEdenConnector/MagicEdenConnector.d.ts +0 -21
- package/src/connectors/MagicEdenConnector/MagicEdenConnector.js +0 -179
- package/src/connectors/MagicEdenConnector/index.d.ts +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
|
|
2
|
+
## [4.105.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.104.0...v4.105.0) (2026-11-13)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* **bitcoin:** add allowedWitnessScripts to embedded wallet signPsbt [v4] ([#12693](https://github.com/dynamic-labs/dynamic-auth/issues/12693)) ([3804839](https://github.com/dynamic-labs/dynamic-auth/commit/38048395d89896536a03ff3668b46b2ae0e32eef)), closes [#12575](https://github.com/dynamic-labs/dynamic-auth/issues/12575)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* **sdk-react-core:** reject sanctioned wallets on connect in connect-only mode [v4] ([#12756](https://github.com/dynamic-labs/dynamic-auth/issues/12756)) ([1786b49](https://github.com/dynamic-labs/dynamic-auth/commit/1786b498a21489a5bbb35357c336ee96adc03242)), closes [#12754](https://github.com/dynamic-labs/dynamic-auth/issues/12754) [#12754](https://github.com/dynamic-labs/dynamic-auth/issues/12754) [#12754](https://github.com/dynamic-labs/dynamic-auth/issues/12754)
|
|
13
|
+
|
|
2
14
|
## [4.104.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.103.0...v4.104.0) (2026-11-03)
|
|
3
15
|
|
|
4
16
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/bitcoin",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.105.0",
|
|
4
4
|
"description": "A React SDK for implementing wallet web3 authentication and authorization to your website.",
|
|
5
5
|
"author": "Dynamic Labs, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,17 +25,16 @@
|
|
|
25
25
|
"@dynamic-labs/sdk-api-core": "0.142.0",
|
|
26
26
|
"@wallet-standard/app": "1.0.1",
|
|
27
27
|
"@wallet-standard/base": "1.0.1",
|
|
28
|
-
"bitcoinjs-lib": "6.1.
|
|
28
|
+
"bitcoinjs-lib": "6.1.9",
|
|
29
29
|
"ecpair": "2.1.0",
|
|
30
30
|
"sats-connect": "4.2.1",
|
|
31
|
-
"
|
|
32
|
-
"@dynamic-labs/
|
|
33
|
-
"@dynamic-labs/
|
|
34
|
-
"@dynamic-labs/
|
|
35
|
-
"@dynamic-labs/
|
|
36
|
-
"@dynamic-labs/
|
|
37
|
-
"@dynamic-labs/wallet-
|
|
38
|
-
"@dynamic-labs/wallet-connector-core": "4.104.0",
|
|
31
|
+
"@dynamic-labs/assert-package-version": "4.105.0",
|
|
32
|
+
"@dynamic-labs/logger": "4.105.0",
|
|
33
|
+
"@dynamic-labs/types": "4.105.0",
|
|
34
|
+
"@dynamic-labs/utils": "4.105.0",
|
|
35
|
+
"@dynamic-labs/waas": "4.105.0",
|
|
36
|
+
"@dynamic-labs/wallet-book": "4.105.0",
|
|
37
|
+
"@dynamic-labs/wallet-connector-core": "4.105.0",
|
|
39
38
|
"eventemitter3": "5.0.1"
|
|
40
39
|
},
|
|
41
40
|
"peerDependencies": {}
|
|
@@ -15,7 +15,6 @@ var PsbtBuilderService = require('../../services/PsbtBuilderService.cjs');
|
|
|
15
15
|
require('sats-connect');
|
|
16
16
|
var BitcoinWalletConnector = require('../BitcoinWalletConnector.cjs');
|
|
17
17
|
require('@wallet-standard/app');
|
|
18
|
-
require('jsontokens');
|
|
19
18
|
var btcToSatoshis = require('../../utils/btcToSatoshis/btcToSatoshis.cjs');
|
|
20
19
|
var PsbtParser = require('../../utils/psbtParser/PsbtParser.cjs');
|
|
21
20
|
var BitcoinUiTransaction = require('../../utils/BitcoinUiTransaction/BitcoinUiTransaction.cjs');
|
|
@@ -304,6 +303,9 @@ class DynamicWaasBitcoinConnector extends waas.withDynamicWaas(BitcoinWalletConn
|
|
|
304
303
|
* Embedded wallets only support PSBT format and automatically sign all inputs
|
|
305
304
|
* that belong to the wallet address. Always uses SIGHASH_ALL (0x01).
|
|
306
305
|
*
|
|
306
|
+
* P2WSH multisig inputs are signed only when their witnessScript is listed in
|
|
307
|
+
* `allowedWitnessScripts` and the wallet is a Native SegWit wallet.
|
|
308
|
+
*
|
|
307
309
|
* @param request - The PSBT signing request. Only unsignedPsbtBase64 is required.
|
|
308
310
|
* @returns The signed (but not finalized) PSBT response
|
|
309
311
|
* @throws {DynamicError} If active account address is not set
|
|
@@ -331,6 +333,7 @@ class DynamicWaasBitcoinConnector extends waas.withDynamicWaas(BitcoinWalletConn
|
|
|
331
333
|
accountAddress: walletIdentityAddress,
|
|
332
334
|
});
|
|
333
335
|
const signedTransaction = yield walletClient.signTransaction({
|
|
336
|
+
allowedWitnessScripts: request.allowedWitnessScripts,
|
|
334
337
|
authToken: (_d = this.getAuthToken) === null || _d === void 0 ? void 0 : _d.call(this),
|
|
335
338
|
bitcoinConfig: { network: yield this.getBitcoinNetworkEnum() },
|
|
336
339
|
elevatedAccessToken,
|
|
@@ -357,6 +357,9 @@ export declare class DynamicWaasBitcoinConnector extends DynamicWaasBitcoinConne
|
|
|
357
357
|
* Embedded wallets only support PSBT format and automatically sign all inputs
|
|
358
358
|
* that belong to the wallet address. Always uses SIGHASH_ALL (0x01).
|
|
359
359
|
*
|
|
360
|
+
* P2WSH multisig inputs are signed only when their witnessScript is listed in
|
|
361
|
+
* `allowedWitnessScripts` and the wallet is a Native SegWit wallet.
|
|
362
|
+
*
|
|
360
363
|
* @param request - The PSBT signing request. Only unsignedPsbtBase64 is required.
|
|
361
364
|
* @returns The signed (but not finalized) PSBT response
|
|
362
365
|
* @throws {DynamicError} If active account address is not set
|
|
@@ -11,7 +11,6 @@ import { PsbtBuilderService } from '../../services/PsbtBuilderService.js';
|
|
|
11
11
|
import 'sats-connect';
|
|
12
12
|
import { BitcoinWalletConnector } from '../BitcoinWalletConnector.js';
|
|
13
13
|
import '@wallet-standard/app';
|
|
14
|
-
import 'jsontokens';
|
|
15
14
|
import { btcToSatoshis } from '../../utils/btcToSatoshis/btcToSatoshis.js';
|
|
16
15
|
import { PsbtParser } from '../../utils/psbtParser/PsbtParser.js';
|
|
17
16
|
import { BitcoinUiTransaction } from '../../utils/BitcoinUiTransaction/BitcoinUiTransaction.js';
|
|
@@ -300,6 +299,9 @@ class DynamicWaasBitcoinConnector extends withDynamicWaas(BitcoinWalletConnector
|
|
|
300
299
|
* Embedded wallets only support PSBT format and automatically sign all inputs
|
|
301
300
|
* that belong to the wallet address. Always uses SIGHASH_ALL (0x01).
|
|
302
301
|
*
|
|
302
|
+
* P2WSH multisig inputs are signed only when their witnessScript is listed in
|
|
303
|
+
* `allowedWitnessScripts` and the wallet is a Native SegWit wallet.
|
|
304
|
+
*
|
|
303
305
|
* @param request - The PSBT signing request. Only unsignedPsbtBase64 is required.
|
|
304
306
|
* @returns The signed (but not finalized) PSBT response
|
|
305
307
|
* @throws {DynamicError} If active account address is not set
|
|
@@ -327,6 +329,7 @@ class DynamicWaasBitcoinConnector extends withDynamicWaas(BitcoinWalletConnector
|
|
|
327
329
|
accountAddress: walletIdentityAddress,
|
|
328
330
|
});
|
|
329
331
|
const signedTransaction = yield walletClient.signTransaction({
|
|
332
|
+
allowedWitnessScripts: request.allowedWitnessScripts,
|
|
330
333
|
authToken: (_d = this.getAuthToken) === null || _d === void 0 ? void 0 : _d.call(this),
|
|
331
334
|
bitcoinConfig: { network: yield this.getBitcoinNetworkEnum() },
|
|
332
335
|
elevatedAccessToken,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export * from './BitcoinWalletConnector';
|
|
2
2
|
export * from './BitcoinBtcKitConnector';
|
|
3
3
|
export * from './BitcoinSatsConnectConnector';
|
|
4
|
-
export * from './MagicEdenConnector';
|
|
5
4
|
export * from './PhantomConnector';
|
|
6
5
|
export * from './OkxConnector';
|
|
7
6
|
export * from './OneKeyConnector';
|
package/src/index.cjs
CHANGED
|
@@ -12,7 +12,6 @@ require('bitcoinjs-lib');
|
|
|
12
12
|
require('@dynamic-labs/wallet-connector-core');
|
|
13
13
|
require('@dynamic-labs/utils');
|
|
14
14
|
var BitcoinSatsConnectConnector = require('./connectors/BitcoinSatsConnectConnector/BitcoinSatsConnectConnector.cjs');
|
|
15
|
-
var MagicEdenConnector = require('./connectors/MagicEdenConnector/MagicEdenConnector.cjs');
|
|
16
15
|
var PhantomConnector = require('./connectors/PhantomConnector/PhantomConnector.cjs');
|
|
17
16
|
var OkxConnector = require('./connectors/OkxConnector/OkxConnector.cjs');
|
|
18
17
|
var OneKeyConnector = require('./connectors/OneKeyConnector/OneKeyConnector.cjs');
|
|
@@ -41,7 +40,6 @@ assertPackageVersion.assertPackageVersion('@dynamic-labs/bitcoin', _package.vers
|
|
|
41
40
|
const BitcoinWalletConnectors = (props) => [
|
|
42
41
|
...fetchSatsConnectConnectors.fetchSatsConnectConnectors(props),
|
|
43
42
|
...fetchBtcKitConnectors.fetchBtcKitConnectors(props),
|
|
44
|
-
MagicEdenConnector.MagicEdenConnector,
|
|
45
43
|
PhantomConnector.PhantomConnector,
|
|
46
44
|
OkxConnector.OkxConnector,
|
|
47
45
|
OneKeyConnector.OneKeyConnector,
|
package/src/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { OkxConnector } from './connectors';
|
|
1
|
+
import { OkxConnector, DynamicWaasBitcoinConnector } from './connectors';
|
|
2
2
|
export { BitcoinWalletConnector, type BitcoinWalletConnectorOpts, } from './connectors';
|
|
3
3
|
export type { BitcoinTransaction, BitcoinSignProtocol, BitcoinSignPsbtRequest, BitcoinSignPsbtResponse, BitcoinWalletStandardMethods, SignPsbtOptions, EmbeddedWalletSignPsbtRequest, } from './types';
|
|
4
4
|
export * from './utils';
|
|
5
5
|
export * from './wallet';
|
|
6
6
|
export { UnisatConnector, BitcoinSatsConnectConnector, DynamicWaasBitcoinConnector, } from './connectors';
|
|
7
|
-
export declare const BitcoinWalletConnectors: (props: any) => (import("dist/packages/wallet-connector-core/src").WalletConnectorConstructor | typeof OkxConnector)[];
|
|
7
|
+
export declare const BitcoinWalletConnectors: (props: any) => (import("dist/packages/wallet-connector-core/src").WalletConnectorConstructor | typeof OkxConnector | typeof DynamicWaasBitcoinConnector)[];
|
|
8
8
|
export { BitcoinProviderHelper } from './bitcoinProviderHelper';
|
|
9
9
|
export { DUST_LIMIT, HTTP_STATUS_NOT_FOUND, HTTP_STATUS_TOO_MANY_REQUESTS, } from './const';
|
package/src/index.js
CHANGED
|
@@ -8,7 +8,6 @@ import 'bitcoinjs-lib';
|
|
|
8
8
|
import '@dynamic-labs/wallet-connector-core';
|
|
9
9
|
import '@dynamic-labs/utils';
|
|
10
10
|
export { BitcoinSatsConnectConnector } from './connectors/BitcoinSatsConnectConnector/BitcoinSatsConnectConnector.js';
|
|
11
|
-
import { MagicEdenConnector } from './connectors/MagicEdenConnector/MagicEdenConnector.js';
|
|
12
11
|
import { PhantomConnector } from './connectors/PhantomConnector/PhantomConnector.js';
|
|
13
12
|
import { OkxConnector } from './connectors/OkxConnector/OkxConnector.js';
|
|
14
13
|
import { OneKeyConnector } from './connectors/OneKeyConnector/OneKeyConnector.js';
|
|
@@ -41,7 +40,6 @@ assertPackageVersion('@dynamic-labs/bitcoin', version);
|
|
|
41
40
|
const BitcoinWalletConnectors = (props) => [
|
|
42
41
|
...fetchSatsConnectConnectors(props),
|
|
43
42
|
...fetchBtcKitConnectors(props),
|
|
44
|
-
MagicEdenConnector,
|
|
45
43
|
PhantomConnector,
|
|
46
44
|
OkxConnector,
|
|
47
45
|
OneKeyConnector,
|
|
@@ -15,7 +15,6 @@ require('@wallet-standard/app');
|
|
|
15
15
|
var getMempoolApiUrl = require('../utils/getMempoolApiUrl.cjs');
|
|
16
16
|
var _const = require('../const.cjs');
|
|
17
17
|
require('@dynamic-labs/types');
|
|
18
|
-
require('jsontokens');
|
|
19
18
|
require('../connectors/DynamicWaasBitcoinConnector/DynamicWaasBitcoinConnector.cjs');
|
|
20
19
|
|
|
21
20
|
const logger = new logger$1.Logger('MempoolApiService');
|
|
@@ -11,7 +11,6 @@ import '@wallet-standard/app';
|
|
|
11
11
|
import { getMempoolApiUrl } from '../utils/getMempoolApiUrl.js';
|
|
12
12
|
import { VSIZE_OVERHEAD, VSIZE_INPUT_P2WPKH, VSIZE_OUTPUT_P2WPKH, MIN_RELAY_FEE, DEFAULT_FEE_ESTIMATE } from '../const.js';
|
|
13
13
|
import '@dynamic-labs/types';
|
|
14
|
-
import 'jsontokens';
|
|
15
14
|
import '../connectors/DynamicWaasBitcoinConnector/DynamicWaasBitcoinConnector.js';
|
|
16
15
|
|
|
17
16
|
const logger = new Logger('MempoolApiService');
|
package/src/types.d.ts
CHANGED
|
@@ -67,6 +67,14 @@ export type EmbeddedWalletSignPsbtRequest = {
|
|
|
67
67
|
* Embedded wallets only support PSBT format, not raw transaction hex.
|
|
68
68
|
*/
|
|
69
69
|
unsignedPsbtBase64: string;
|
|
70
|
+
/**
|
|
71
|
+
* Optional hex-encoded witnessScripts the wallet may co-sign (P2WSH multisig
|
|
72
|
+
* opt-in). An input is signed only when its witnessScript is in this list,
|
|
73
|
+
* matches the input's scriptPubKey, is a canonical m-of-n multisig and
|
|
74
|
+
* contains the wallet's public key. When omitted, P2WSH inputs are not signed.
|
|
75
|
+
* Only Native SegWit wallets can co-sign P2WSH inputs.
|
|
76
|
+
*/
|
|
77
|
+
allowedWitnessScripts?: string[];
|
|
70
78
|
};
|
|
71
79
|
export type SatsConnectSignTransactionInput = {
|
|
72
80
|
message?: string;
|
|
@@ -14,7 +14,6 @@ var _const = require('../../const.cjs');
|
|
|
14
14
|
require('@dynamic-labs/types');
|
|
15
15
|
require('bitcoinjs-lib');
|
|
16
16
|
var BitcoinSatsConnectConnector = require('../../connectors/BitcoinSatsConnectConnector/BitcoinSatsConnectConnector.cjs');
|
|
17
|
-
require('jsontokens');
|
|
18
17
|
require('../../connectors/DynamicWaasBitcoinConnector/DynamicWaasBitcoinConnector.cjs');
|
|
19
18
|
var hasSatsConnectFeature = require('../hasSatsConnectFeature.cjs');
|
|
20
19
|
|
|
@@ -10,7 +10,6 @@ import { SATSCONNECT_FEATURE } from '../../const.js';
|
|
|
10
10
|
import '@dynamic-labs/types';
|
|
11
11
|
import 'bitcoinjs-lib';
|
|
12
12
|
import { BitcoinSatsConnectConnector } from '../../connectors/BitcoinSatsConnectConnector/BitcoinSatsConnectConnector.js';
|
|
13
|
-
import 'jsontokens';
|
|
14
13
|
import '../../connectors/DynamicWaasBitcoinConnector/DynamicWaasBitcoinConnector.js';
|
|
15
14
|
import { hasSatsConnectFeature } from '../hasSatsConnectFeature.js';
|
|
16
15
|
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
var _tslib = require('../../../_virtual/_tslib.cjs');
|
|
7
|
-
var jsontokens = require('jsontokens');
|
|
8
|
-
var satsConnect = require('sats-connect');
|
|
9
|
-
var utils = require('@dynamic-labs/utils');
|
|
10
|
-
var _const = require('../../const.cjs');
|
|
11
|
-
var BitcoinSatsConnectConnector = require('../BitcoinSatsConnectConnector/BitcoinSatsConnectConnector.cjs');
|
|
12
|
-
var getSatsConnectSigningProtocol = require('../../utils/getSatsConnectSigningProtocol/getSatsConnectSigningProtocol.cjs');
|
|
13
|
-
|
|
14
|
-
class MagicEdenConnector extends BitcoinSatsConnectConnector.BitcoinSatsConnectConnector {
|
|
15
|
-
constructor(opts) {
|
|
16
|
-
super(Object.assign(Object.assign({}, opts), { overrideKey: 'magicedenbtc' }));
|
|
17
|
-
this.name = 'Magic Eden';
|
|
18
|
-
this.overrideKey = 'magicedenbtc';
|
|
19
|
-
this.isLegacy = true;
|
|
20
|
-
}
|
|
21
|
-
getAddress() {
|
|
22
|
-
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
if (this.handleInAppBrowserGetAddress())
|
|
24
|
-
return;
|
|
25
|
-
return new Promise((resolve, reject) => {
|
|
26
|
-
satsConnect.getAddress({
|
|
27
|
-
getProvider: () => _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
var _a, _b;
|
|
29
|
-
return (_b = (_a = this.wallet) === null || _a === void 0 ? void 0 : _a.features[_const.SATSCONNECT_FEATURE]) === null || _b === void 0 ? void 0 : _b.provider;
|
|
30
|
-
}),
|
|
31
|
-
onCancel: () => {
|
|
32
|
-
const error = new Error();
|
|
33
|
-
error.code = '-32000'; // error code for user cancelled
|
|
34
|
-
reject(error);
|
|
35
|
-
},
|
|
36
|
-
onFinish: (response) => _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
var _c;
|
|
38
|
-
const { addresses } = response;
|
|
39
|
-
const ordinalsAccount = addresses === null || addresses === void 0 ? void 0 : addresses.find((address) => address.purpose === satsConnect.AddressPurpose.Ordinals);
|
|
40
|
-
const paymentAccount = addresses === null || addresses === void 0 ? void 0 : addresses.find((address) => address.purpose === satsConnect.AddressPurpose.Payment);
|
|
41
|
-
const mainAddress = (_c = ordinalsAccount === null || ordinalsAccount === void 0 ? void 0 : ordinalsAccount.address) !== null && _c !== void 0 ? _c : paymentAccount === null || paymentAccount === void 0 ? void 0 : paymentAccount.address;
|
|
42
|
-
yield this.setConnectedAccountWithAddresses({
|
|
43
|
-
active: true,
|
|
44
|
-
mainAddress,
|
|
45
|
-
ordinalsAddress: ordinalsAccount,
|
|
46
|
-
paymentAddress: paymentAccount,
|
|
47
|
-
});
|
|
48
|
-
resolve(mainAddress);
|
|
49
|
-
}),
|
|
50
|
-
payload: {
|
|
51
|
-
message: 'Address for receiving Ordinals and payments',
|
|
52
|
-
network: {
|
|
53
|
-
type: this.currentNetwork,
|
|
54
|
-
},
|
|
55
|
-
purposes: [satsConnect.AddressPurpose.Ordinals, satsConnect.AddressPurpose.Payment],
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
signMessage(messageToSign, options) {
|
|
62
|
-
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
const { address, protocol } = options;
|
|
64
|
-
return new Promise((resolve, reject) => {
|
|
65
|
-
satsConnect.signMessage({
|
|
66
|
-
getProvider: () => _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
var _a, _b;
|
|
68
|
-
return (_b = (_a = this.wallet) === null || _a === void 0 ? void 0 : _a.features[_const.SATSCONNECT_FEATURE]) === null || _b === void 0 ? void 0 : _b.provider;
|
|
69
|
-
}),
|
|
70
|
-
onCancel: () => {
|
|
71
|
-
const error = new Error();
|
|
72
|
-
error.code = '-32000'; // error code for user cancelled
|
|
73
|
-
reject(error);
|
|
74
|
-
},
|
|
75
|
-
onFinish: (response) => _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
76
|
-
if (this.isHardwareWalletEnabled) {
|
|
77
|
-
return resolve(JSON.stringify({
|
|
78
|
-
signedTransaction: {
|
|
79
|
-
data: response,
|
|
80
|
-
},
|
|
81
|
-
}));
|
|
82
|
-
}
|
|
83
|
-
resolve(response);
|
|
84
|
-
}),
|
|
85
|
-
payload: {
|
|
86
|
-
address,
|
|
87
|
-
message: messageToSign,
|
|
88
|
-
network: {
|
|
89
|
-
type: this.currentNetwork,
|
|
90
|
-
},
|
|
91
|
-
protocol: getSatsConnectSigningProtocol.getSatsConnectSigningProtocol(protocol),
|
|
92
|
-
},
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
sendBitcoin(transaction) {
|
|
98
|
-
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
99
|
-
var _a;
|
|
100
|
-
const mainAddress = yield this.getAddress();
|
|
101
|
-
const senderAddress = (_a = (yield this.getAdditionalAddresses(mainAddress)).find((address) => address.type === 'payment')) === null || _a === void 0 ? void 0 : _a.address;
|
|
102
|
-
if (!senderAddress) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
return new Promise((resolve, reject) => {
|
|
106
|
-
satsConnect.sendBtcTransaction({
|
|
107
|
-
getProvider: () => _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
108
|
-
var _a, _b;
|
|
109
|
-
return (_b = (_a = this.wallet) === null || _a === void 0 ? void 0 : _a.features[_const.SATSCONNECT_FEATURE]) === null || _b === void 0 ? void 0 : _b.provider;
|
|
110
|
-
}),
|
|
111
|
-
onCancel: () => {
|
|
112
|
-
const error = new Error();
|
|
113
|
-
error.code = '-32000'; // error code for user cancelled
|
|
114
|
-
reject(error);
|
|
115
|
-
},
|
|
116
|
-
onFinish: (response) => {
|
|
117
|
-
resolve(response);
|
|
118
|
-
},
|
|
119
|
-
payload: {
|
|
120
|
-
network: {
|
|
121
|
-
type: this.currentNetwork,
|
|
122
|
-
},
|
|
123
|
-
recipients: [
|
|
124
|
-
{
|
|
125
|
-
address: transaction.recipientAddress,
|
|
126
|
-
amountSats: BigInt(transaction.amount),
|
|
127
|
-
},
|
|
128
|
-
],
|
|
129
|
-
senderAddress,
|
|
130
|
-
},
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
signTransaction(params) {
|
|
136
|
-
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
137
|
-
const { message, psbtBase64, broadcast, inputsToSign } = params;
|
|
138
|
-
return new Promise((resolve, reject) => {
|
|
139
|
-
satsConnect.signTransaction({
|
|
140
|
-
getProvider: () => _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
141
|
-
var _a, _b;
|
|
142
|
-
return (_b = (_a = this.wallet) === null || _a === void 0 ? void 0 : _a.features[_const.SATSCONNECT_FEATURE]) === null || _b === void 0 ? void 0 : _b.provider;
|
|
143
|
-
}),
|
|
144
|
-
onCancel: () => {
|
|
145
|
-
const error = new Error();
|
|
146
|
-
error.code = '-32000'; // error code for user cancelled
|
|
147
|
-
reject(error);
|
|
148
|
-
},
|
|
149
|
-
onFinish: (response) => {
|
|
150
|
-
resolve(response);
|
|
151
|
-
},
|
|
152
|
-
payload: {
|
|
153
|
-
broadcast,
|
|
154
|
-
inputsToSign,
|
|
155
|
-
message: message || 'Sign Transaction',
|
|
156
|
-
network: {
|
|
157
|
-
type: this.currentNetwork,
|
|
158
|
-
},
|
|
159
|
-
psbtBase64,
|
|
160
|
-
},
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Uses the custom Magic Eden signTransactions feature to sign multiple transactions
|
|
167
|
-
*/
|
|
168
|
-
signTransactions(transactions) {
|
|
169
|
-
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
170
|
-
var _a;
|
|
171
|
-
(_a = transactions.message) !== null && _a !== void 0 ? _a : (transactions.message = 'Sign Transaction');
|
|
172
|
-
const request = jsontokens.createUnsecuredToken(transactions);
|
|
173
|
-
// Magic Eden has implemented their own signTransactions feature, and have requested us
|
|
174
|
-
// to ensure we use it rather than the general Sats Connect API for this method
|
|
175
|
-
const provider = this.getProvider();
|
|
176
|
-
if (!provider)
|
|
177
|
-
throw new utils.DynamicError('signTransactions failed: Magic Eden provider not found', 'signtransactions_failed_magic_eden_provider_not');
|
|
178
|
-
return provider.signMultipleTransactions(request);
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
exports.MagicEdenConnector = MagicEdenConnector;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { SignMultipleTransactionsPayload, SignTransactionResponse } from 'sats-connect';
|
|
2
|
-
import { BitcoinSignProtocol, BitcoinTransaction, SatsConnectSignTransactionInput } from '../../types';
|
|
3
|
-
import { BitcoinSatsConnectConnector } from '../BitcoinSatsConnectConnector';
|
|
4
|
-
import { BitcoinWalletConnectorOpts } from '../BitcoinWalletConnector';
|
|
5
|
-
export declare class MagicEdenConnector extends BitcoinSatsConnectConnector {
|
|
6
|
-
name: string;
|
|
7
|
-
overrideKey: string;
|
|
8
|
-
isLegacy: boolean;
|
|
9
|
-
constructor(opts: BitcoinWalletConnectorOpts);
|
|
10
|
-
getAddress(): Promise<string | undefined>;
|
|
11
|
-
signMessage(messageToSign: string, options: {
|
|
12
|
-
address: string;
|
|
13
|
-
protocol?: BitcoinSignProtocol;
|
|
14
|
-
}): Promise<string | undefined>;
|
|
15
|
-
sendBitcoin(transaction: BitcoinTransaction): Promise<string | undefined>;
|
|
16
|
-
signTransaction(params: SatsConnectSignTransactionInput): Promise<SignTransactionResponse | undefined>;
|
|
17
|
-
/**
|
|
18
|
-
* Uses the custom Magic Eden signTransactions feature to sign multiple transactions
|
|
19
|
-
*/
|
|
20
|
-
signTransactions(transactions: SignMultipleTransactionsPayload): Promise<SignTransactionResponse[] | undefined>;
|
|
21
|
-
}
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
import { __awaiter } from '../../../_virtual/_tslib.js';
|
|
3
|
-
import { createUnsecuredToken } from 'jsontokens';
|
|
4
|
-
import { getAddress, AddressPurpose, signMessage, sendBtcTransaction, signTransaction } from 'sats-connect';
|
|
5
|
-
import { DynamicError } from '@dynamic-labs/utils';
|
|
6
|
-
import { SATSCONNECT_FEATURE } from '../../const.js';
|
|
7
|
-
import { BitcoinSatsConnectConnector } from '../BitcoinSatsConnectConnector/BitcoinSatsConnectConnector.js';
|
|
8
|
-
import { getSatsConnectSigningProtocol } from '../../utils/getSatsConnectSigningProtocol/getSatsConnectSigningProtocol.js';
|
|
9
|
-
|
|
10
|
-
class MagicEdenConnector extends BitcoinSatsConnectConnector {
|
|
11
|
-
constructor(opts) {
|
|
12
|
-
super(Object.assign(Object.assign({}, opts), { overrideKey: 'magicedenbtc' }));
|
|
13
|
-
this.name = 'Magic Eden';
|
|
14
|
-
this.overrideKey = 'magicedenbtc';
|
|
15
|
-
this.isLegacy = true;
|
|
16
|
-
}
|
|
17
|
-
getAddress() {
|
|
18
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
if (this.handleInAppBrowserGetAddress())
|
|
20
|
-
return;
|
|
21
|
-
return new Promise((resolve, reject) => {
|
|
22
|
-
getAddress({
|
|
23
|
-
getProvider: () => __awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
var _a, _b;
|
|
25
|
-
return (_b = (_a = this.wallet) === null || _a === void 0 ? void 0 : _a.features[SATSCONNECT_FEATURE]) === null || _b === void 0 ? void 0 : _b.provider;
|
|
26
|
-
}),
|
|
27
|
-
onCancel: () => {
|
|
28
|
-
const error = new Error();
|
|
29
|
-
error.code = '-32000'; // error code for user cancelled
|
|
30
|
-
reject(error);
|
|
31
|
-
},
|
|
32
|
-
onFinish: (response) => __awaiter(this, void 0, void 0, function* () {
|
|
33
|
-
var _c;
|
|
34
|
-
const { addresses } = response;
|
|
35
|
-
const ordinalsAccount = addresses === null || addresses === void 0 ? void 0 : addresses.find((address) => address.purpose === AddressPurpose.Ordinals);
|
|
36
|
-
const paymentAccount = addresses === null || addresses === void 0 ? void 0 : addresses.find((address) => address.purpose === AddressPurpose.Payment);
|
|
37
|
-
const mainAddress = (_c = ordinalsAccount === null || ordinalsAccount === void 0 ? void 0 : ordinalsAccount.address) !== null && _c !== void 0 ? _c : paymentAccount === null || paymentAccount === void 0 ? void 0 : paymentAccount.address;
|
|
38
|
-
yield this.setConnectedAccountWithAddresses({
|
|
39
|
-
active: true,
|
|
40
|
-
mainAddress,
|
|
41
|
-
ordinalsAddress: ordinalsAccount,
|
|
42
|
-
paymentAddress: paymentAccount,
|
|
43
|
-
});
|
|
44
|
-
resolve(mainAddress);
|
|
45
|
-
}),
|
|
46
|
-
payload: {
|
|
47
|
-
message: 'Address for receiving Ordinals and payments',
|
|
48
|
-
network: {
|
|
49
|
-
type: this.currentNetwork,
|
|
50
|
-
},
|
|
51
|
-
purposes: [AddressPurpose.Ordinals, AddressPurpose.Payment],
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
signMessage(messageToSign, options) {
|
|
58
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
const { address, protocol } = options;
|
|
60
|
-
return new Promise((resolve, reject) => {
|
|
61
|
-
signMessage({
|
|
62
|
-
getProvider: () => __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
var _a, _b;
|
|
64
|
-
return (_b = (_a = this.wallet) === null || _a === void 0 ? void 0 : _a.features[SATSCONNECT_FEATURE]) === null || _b === void 0 ? void 0 : _b.provider;
|
|
65
|
-
}),
|
|
66
|
-
onCancel: () => {
|
|
67
|
-
const error = new Error();
|
|
68
|
-
error.code = '-32000'; // error code for user cancelled
|
|
69
|
-
reject(error);
|
|
70
|
-
},
|
|
71
|
-
onFinish: (response) => __awaiter(this, void 0, void 0, function* () {
|
|
72
|
-
if (this.isHardwareWalletEnabled) {
|
|
73
|
-
return resolve(JSON.stringify({
|
|
74
|
-
signedTransaction: {
|
|
75
|
-
data: response,
|
|
76
|
-
},
|
|
77
|
-
}));
|
|
78
|
-
}
|
|
79
|
-
resolve(response);
|
|
80
|
-
}),
|
|
81
|
-
payload: {
|
|
82
|
-
address,
|
|
83
|
-
message: messageToSign,
|
|
84
|
-
network: {
|
|
85
|
-
type: this.currentNetwork,
|
|
86
|
-
},
|
|
87
|
-
protocol: getSatsConnectSigningProtocol(protocol),
|
|
88
|
-
},
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
sendBitcoin(transaction) {
|
|
94
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
-
var _a;
|
|
96
|
-
const mainAddress = yield this.getAddress();
|
|
97
|
-
const senderAddress = (_a = (yield this.getAdditionalAddresses(mainAddress)).find((address) => address.type === 'payment')) === null || _a === void 0 ? void 0 : _a.address;
|
|
98
|
-
if (!senderAddress) {
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
return new Promise((resolve, reject) => {
|
|
102
|
-
sendBtcTransaction({
|
|
103
|
-
getProvider: () => __awaiter(this, void 0, void 0, function* () {
|
|
104
|
-
var _a, _b;
|
|
105
|
-
return (_b = (_a = this.wallet) === null || _a === void 0 ? void 0 : _a.features[SATSCONNECT_FEATURE]) === null || _b === void 0 ? void 0 : _b.provider;
|
|
106
|
-
}),
|
|
107
|
-
onCancel: () => {
|
|
108
|
-
const error = new Error();
|
|
109
|
-
error.code = '-32000'; // error code for user cancelled
|
|
110
|
-
reject(error);
|
|
111
|
-
},
|
|
112
|
-
onFinish: (response) => {
|
|
113
|
-
resolve(response);
|
|
114
|
-
},
|
|
115
|
-
payload: {
|
|
116
|
-
network: {
|
|
117
|
-
type: this.currentNetwork,
|
|
118
|
-
},
|
|
119
|
-
recipients: [
|
|
120
|
-
{
|
|
121
|
-
address: transaction.recipientAddress,
|
|
122
|
-
amountSats: BigInt(transaction.amount),
|
|
123
|
-
},
|
|
124
|
-
],
|
|
125
|
-
senderAddress,
|
|
126
|
-
},
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
signTransaction(params) {
|
|
132
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
133
|
-
const { message, psbtBase64, broadcast, inputsToSign } = params;
|
|
134
|
-
return new Promise((resolve, reject) => {
|
|
135
|
-
signTransaction({
|
|
136
|
-
getProvider: () => __awaiter(this, void 0, void 0, function* () {
|
|
137
|
-
var _a, _b;
|
|
138
|
-
return (_b = (_a = this.wallet) === null || _a === void 0 ? void 0 : _a.features[SATSCONNECT_FEATURE]) === null || _b === void 0 ? void 0 : _b.provider;
|
|
139
|
-
}),
|
|
140
|
-
onCancel: () => {
|
|
141
|
-
const error = new Error();
|
|
142
|
-
error.code = '-32000'; // error code for user cancelled
|
|
143
|
-
reject(error);
|
|
144
|
-
},
|
|
145
|
-
onFinish: (response) => {
|
|
146
|
-
resolve(response);
|
|
147
|
-
},
|
|
148
|
-
payload: {
|
|
149
|
-
broadcast,
|
|
150
|
-
inputsToSign,
|
|
151
|
-
message: message || 'Sign Transaction',
|
|
152
|
-
network: {
|
|
153
|
-
type: this.currentNetwork,
|
|
154
|
-
},
|
|
155
|
-
psbtBase64,
|
|
156
|
-
},
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Uses the custom Magic Eden signTransactions feature to sign multiple transactions
|
|
163
|
-
*/
|
|
164
|
-
signTransactions(transactions) {
|
|
165
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
166
|
-
var _a;
|
|
167
|
-
(_a = transactions.message) !== null && _a !== void 0 ? _a : (transactions.message = 'Sign Transaction');
|
|
168
|
-
const request = createUnsecuredToken(transactions);
|
|
169
|
-
// Magic Eden has implemented their own signTransactions feature, and have requested us
|
|
170
|
-
// to ensure we use it rather than the general Sats Connect API for this method
|
|
171
|
-
const provider = this.getProvider();
|
|
172
|
-
if (!provider)
|
|
173
|
-
throw new DynamicError('signTransactions failed: Magic Eden provider not found', 'signtransactions_failed_magic_eden_provider_not');
|
|
174
|
-
return provider.signMultipleTransactions(request);
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
export { MagicEdenConnector };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { MagicEdenConnector } from './MagicEdenConnector';
|