@dynamic-labs/global-wallet 4.25.10 → 4.27.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/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +5 -4
- package/src/GlobalWalletConnector.cjs +2 -16
- package/src/GlobalWalletConnector.js +2 -16
- package/src/errors/MultipleWalletConnectProjectIdsError.cjs +14 -0
- package/src/errors/MultipleWalletConnectProjectIdsError.d.ts +8 -0
- package/src/errors/MultipleWalletConnectProjectIdsError.js +10 -0
- package/src/getWalletKitSingleton/getWalletKitSingleton.cjs +39 -0
- package/src/getWalletKitSingleton/getWalletKitSingleton.d.ts +3 -0
- package/src/getWalletKitSingleton/getWalletKitSingleton.js +35 -0
- package/src/getWalletKitSingleton/index.d.ts +1 -0
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/global-wallet",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.27.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",
|
|
@@ -22,9 +22,10 @@
|
|
|
22
22
|
"@walletconnect/utils": "2.21.5",
|
|
23
23
|
"@reown/walletkit": "1.1.2",
|
|
24
24
|
"jsqr": "1.4.0",
|
|
25
|
-
"@dynamic-labs/assert-package-version": "4.
|
|
26
|
-
"@dynamic-labs/ethereum-core": "4.
|
|
27
|
-
"@dynamic-labs/
|
|
25
|
+
"@dynamic-labs/assert-package-version": "4.27.0",
|
|
26
|
+
"@dynamic-labs/ethereum-core": "4.27.0",
|
|
27
|
+
"@dynamic-labs/utils": "4.27.0",
|
|
28
|
+
"@dynamic-labs/wallet-connector-core": "4.27.0"
|
|
28
29
|
},
|
|
29
30
|
"overrides": {
|
|
30
31
|
"elliptic": "6.6.1"
|
|
@@ -4,12 +4,11 @@
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
6
|
var _tslib = require('../_virtual/_tslib.cjs');
|
|
7
|
-
var core = require('@walletconnect/core');
|
|
8
7
|
var utils = require('@walletconnect/utils');
|
|
9
|
-
var walletkit = require('@reown/walletkit');
|
|
10
8
|
var jsQR = require('jsqr');
|
|
11
9
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
12
10
|
var ethereumCore = require('@dynamic-labs/ethereum-core');
|
|
11
|
+
var getWalletKitSingleton = require('./getWalletKitSingleton/getWalletKitSingleton.cjs');
|
|
13
12
|
|
|
14
13
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
14
|
|
|
@@ -106,20 +105,7 @@ const GlobalWalletExtension = {
|
|
|
106
105
|
getPendingPairing: () => pendingSessionProposal,
|
|
107
106
|
getWeb3Wallet: () => web3wallet,
|
|
108
107
|
initWeb3Wallet: () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
109
|
-
|
|
110
|
-
const core$1 = new core.Core({
|
|
111
|
-
projectId: settings.walletConnectDappProjectId,
|
|
112
|
-
});
|
|
113
|
-
web3wallet = yield walletkit.WalletKit.init({
|
|
114
|
-
core: core$1,
|
|
115
|
-
metadata: {
|
|
116
|
-
description: 'Dynamic Embedded Wallet',
|
|
117
|
-
icons: [],
|
|
118
|
-
name: 'Dynamic',
|
|
119
|
-
url: 'app.dynamic.xyz',
|
|
120
|
-
},
|
|
121
|
-
});
|
|
122
|
-
}
|
|
108
|
+
web3wallet = yield getWalletKitSingleton.getWalletKitSingleton(settings.walletConnectDappProjectId);
|
|
123
109
|
}),
|
|
124
110
|
initializeListeners: () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
125
111
|
if (WCListenersOn)
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../_virtual/_tslib.js';
|
|
3
|
-
import { Core } from '@walletconnect/core';
|
|
4
3
|
import { getSdkError, buildApprovedNamespaces } from '@walletconnect/utils';
|
|
5
|
-
import { WalletKit } from '@reown/walletkit';
|
|
6
4
|
import jsQR from 'jsqr';
|
|
7
5
|
import { logger } from '@dynamic-labs/wallet-connector-core';
|
|
8
6
|
import { unFormatTransaction } from '@dynamic-labs/ethereum-core';
|
|
7
|
+
import { getWalletKitSingleton } from './getWalletKitSingleton/getWalletKitSingleton.js';
|
|
9
8
|
|
|
10
9
|
/* eslint-disable import/no-extraneous-dependencies */
|
|
11
10
|
const buildCombinedNamespaces = (params) => {
|
|
@@ -98,20 +97,7 @@ const GlobalWalletExtension = {
|
|
|
98
97
|
getPendingPairing: () => pendingSessionProposal,
|
|
99
98
|
getWeb3Wallet: () => web3wallet,
|
|
100
99
|
initWeb3Wallet: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
101
|
-
|
|
102
|
-
const core = new Core({
|
|
103
|
-
projectId: settings.walletConnectDappProjectId,
|
|
104
|
-
});
|
|
105
|
-
web3wallet = yield WalletKit.init({
|
|
106
|
-
core,
|
|
107
|
-
metadata: {
|
|
108
|
-
description: 'Dynamic Embedded Wallet',
|
|
109
|
-
icons: [],
|
|
110
|
-
name: 'Dynamic',
|
|
111
|
-
url: 'app.dynamic.xyz',
|
|
112
|
-
},
|
|
113
|
-
});
|
|
114
|
-
}
|
|
100
|
+
web3wallet = yield getWalletKitSingleton(settings.walletConnectDappProjectId);
|
|
115
101
|
}),
|
|
116
102
|
initializeListeners: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
117
103
|
if (WCListenersOn)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
class MultipleWalletConnectProjectIdsError extends Error {
|
|
7
|
+
constructor({ originalProjectId, newProjectId }) {
|
|
8
|
+
super(`Multiple WalletConnect project IDs are not allowed: original was ${originalProjectId}, new is ${newProjectId}`);
|
|
9
|
+
this.name = 'MultipleWalletConnectProjectIdsError';
|
|
10
|
+
this.message = `Multiple WalletConnect project IDs are not allowed: original was ${originalProjectId}, new is ${newProjectId}`;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
exports.MultipleWalletConnectProjectIdsError = MultipleWalletConnectProjectIdsError;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
class MultipleWalletConnectProjectIdsError extends Error {
|
|
3
|
+
constructor({ originalProjectId, newProjectId }) {
|
|
4
|
+
super(`Multiple WalletConnect project IDs are not allowed: original was ${originalProjectId}, new is ${newProjectId}`);
|
|
5
|
+
this.name = 'MultipleWalletConnectProjectIdsError';
|
|
6
|
+
this.message = `Multiple WalletConnect project IDs are not allowed: original was ${originalProjectId}, new is ${newProjectId}`;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { MultipleWalletConnectProjectIdsError };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
7
|
+
var walletkit = require('@reown/walletkit');
|
|
8
|
+
var core = require('@walletconnect/core');
|
|
9
|
+
var MultipleWalletConnectProjectIdsError = require('../errors/MultipleWalletConnectProjectIdsError.cjs');
|
|
10
|
+
|
|
11
|
+
let walletKitWithProjectIdPromise = undefined;
|
|
12
|
+
const getWalletKitSingleton = (projectId) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
13
|
+
if (walletKitWithProjectIdPromise) {
|
|
14
|
+
const valueFromPreviousCall = yield walletKitWithProjectIdPromise;
|
|
15
|
+
if (valueFromPreviousCall.projectId !== projectId) {
|
|
16
|
+
throw new MultipleWalletConnectProjectIdsError.MultipleWalletConnectProjectIdsError({
|
|
17
|
+
newProjectId: projectId,
|
|
18
|
+
originalProjectId: valueFromPreviousCall.projectId,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return valueFromPreviousCall.walletKit;
|
|
22
|
+
}
|
|
23
|
+
const core$1 = new core.Core({ projectId });
|
|
24
|
+
walletKitWithProjectIdPromise = walletkit.WalletKit.init({
|
|
25
|
+
core: core$1,
|
|
26
|
+
metadata: {
|
|
27
|
+
description: 'Dynamic Embedded Wallet',
|
|
28
|
+
icons: [],
|
|
29
|
+
name: 'Dynamic',
|
|
30
|
+
url: 'app.dynamic.xyz',
|
|
31
|
+
},
|
|
32
|
+
}).then((walletKit) => ({
|
|
33
|
+
projectId,
|
|
34
|
+
walletKit,
|
|
35
|
+
}));
|
|
36
|
+
return (yield walletKitWithProjectIdPromise).walletKit;
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
exports.getWalletKitSingleton = getWalletKitSingleton;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
3
|
+
import { WalletKit } from '@reown/walletkit';
|
|
4
|
+
import { Core } from '@walletconnect/core';
|
|
5
|
+
import { MultipleWalletConnectProjectIdsError } from '../errors/MultipleWalletConnectProjectIdsError.js';
|
|
6
|
+
|
|
7
|
+
let walletKitWithProjectIdPromise = undefined;
|
|
8
|
+
const getWalletKitSingleton = (projectId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
9
|
+
if (walletKitWithProjectIdPromise) {
|
|
10
|
+
const valueFromPreviousCall = yield walletKitWithProjectIdPromise;
|
|
11
|
+
if (valueFromPreviousCall.projectId !== projectId) {
|
|
12
|
+
throw new MultipleWalletConnectProjectIdsError({
|
|
13
|
+
newProjectId: projectId,
|
|
14
|
+
originalProjectId: valueFromPreviousCall.projectId,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return valueFromPreviousCall.walletKit;
|
|
18
|
+
}
|
|
19
|
+
const core = new Core({ projectId });
|
|
20
|
+
walletKitWithProjectIdPromise = WalletKit.init({
|
|
21
|
+
core,
|
|
22
|
+
metadata: {
|
|
23
|
+
description: 'Dynamic Embedded Wallet',
|
|
24
|
+
icons: [],
|
|
25
|
+
name: 'Dynamic',
|
|
26
|
+
url: 'app.dynamic.xyz',
|
|
27
|
+
},
|
|
28
|
+
}).then((walletKit) => ({
|
|
29
|
+
projectId,
|
|
30
|
+
walletKit,
|
|
31
|
+
}));
|
|
32
|
+
return (yield walletKitWithProjectIdPromise).walletKit;
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export { getWalletKitSingleton };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './getWalletKitSingleton';
|