@dynamic-labs/global-wallet 4.4.2-preview.0 → 4.4.2-preview.1
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 +7 -7
- package/src/GlobalWalletConnector.cjs +16 -16
- package/src/GlobalWalletConnector.d.ts +2 -2
- package/src/GlobalWalletConnector.js +2 -2
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.4.2-preview.
|
|
3
|
+
"version": "4.4.2-preview.1",
|
|
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",
|
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
},
|
|
19
19
|
"homepage": "https://www.dynamic.xyz/",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@walletconnect/core": "2.
|
|
22
|
-
"@walletconnect/utils": "2.
|
|
23
|
-
"@
|
|
21
|
+
"@walletconnect/core": "2.17.3",
|
|
22
|
+
"@walletconnect/utils": "2.17.3",
|
|
23
|
+
"@reown/walletkit": "1.1.2",
|
|
24
24
|
"jsqr": "1.4.0",
|
|
25
|
-
"@dynamic-labs/assert-package-version": "4.4.2-preview.
|
|
26
|
-
"@dynamic-labs/ethereum-core": "4.4.2-preview.
|
|
27
|
-
"@dynamic-labs/wallet-connector-core": "4.4.2-preview.
|
|
25
|
+
"@dynamic-labs/assert-package-version": "4.4.2-preview.1",
|
|
26
|
+
"@dynamic-labs/ethereum-core": "4.4.2-preview.1",
|
|
27
|
+
"@dynamic-labs/wallet-connector-core": "4.4.2-preview.1"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"viem": "^2.21.55",
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
6
6
|
var _tslib = require('../_virtual/_tslib.cjs');
|
|
7
7
|
var core = require('@walletconnect/core');
|
|
8
8
|
var utils = require('@walletconnect/utils');
|
|
9
|
-
var
|
|
9
|
+
var walletkit = require('@reown/walletkit');
|
|
10
10
|
var jsQR = require('jsqr');
|
|
11
11
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
12
12
|
var ethereumCore = require('@dynamic-labs/ethereum-core');
|
|
@@ -40,7 +40,7 @@ const buildCombinedNamespaces = (params) => {
|
|
|
40
40
|
};
|
|
41
41
|
const GlobalWalletExtension = {
|
|
42
42
|
extend: (connector, settings) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
-
let web3wallet
|
|
43
|
+
let web3wallet;
|
|
44
44
|
let WCListenersOn = false;
|
|
45
45
|
let pendingSessionProposal;
|
|
46
46
|
let signer = (yield connector.getSigner());
|
|
@@ -48,7 +48,7 @@ const GlobalWalletExtension = {
|
|
|
48
48
|
confirmPairing: (confirm) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
49
49
|
const { params, id } = pendingSessionProposal;
|
|
50
50
|
if (!confirm) {
|
|
51
|
-
yield web3wallet
|
|
51
|
+
yield web3wallet.rejectSession({
|
|
52
52
|
id,
|
|
53
53
|
reason: utils.getSdkError('USER_REJECTED'),
|
|
54
54
|
});
|
|
@@ -67,29 +67,29 @@ const GlobalWalletExtension = {
|
|
|
67
67
|
},
|
|
68
68
|
},
|
|
69
69
|
});
|
|
70
|
-
yield web3wallet
|
|
70
|
+
yield web3wallet.approveSession({
|
|
71
71
|
id,
|
|
72
72
|
namespaces: approvedNamespaces,
|
|
73
73
|
});
|
|
74
74
|
}),
|
|
75
75
|
disconnectWCSession: (topic) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
76
|
-
if (web3wallet
|
|
77
|
-
yield web3wallet
|
|
76
|
+
if (web3wallet) {
|
|
77
|
+
yield web3wallet.disconnectSession({
|
|
78
78
|
reason: utils.getSdkError('USER_DISCONNECTED'),
|
|
79
79
|
topic,
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
}),
|
|
83
83
|
// topic => session mapping, with peer metadata in the session
|
|
84
|
-
getConnectedWCSessions: () => _tslib.__awaiter(void 0, void 0, void 0, function* () { return web3wallet
|
|
84
|
+
getConnectedWCSessions: () => _tslib.__awaiter(void 0, void 0, void 0, function* () { return web3wallet.getActiveSessions(); }),
|
|
85
85
|
getPendingPairing: () => pendingSessionProposal,
|
|
86
|
-
getWeb3Wallet: () => web3wallet
|
|
86
|
+
getWeb3Wallet: () => web3wallet,
|
|
87
87
|
initWeb3Wallet: () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
88
|
-
if (!web3wallet
|
|
88
|
+
if (!web3wallet) {
|
|
89
89
|
const core$1 = new core.Core({
|
|
90
90
|
projectId: settings.walletConnectDappProjectId,
|
|
91
91
|
});
|
|
92
|
-
web3wallet
|
|
92
|
+
web3wallet = yield walletkit.WalletKit.init({
|
|
93
93
|
core: core$1,
|
|
94
94
|
metadata: {
|
|
95
95
|
description: 'Dynamic Embedded Wallet',
|
|
@@ -177,21 +177,21 @@ const GlobalWalletExtension = {
|
|
|
177
177
|
response = yield handleEthSendTransaction();
|
|
178
178
|
}
|
|
179
179
|
if (response) {
|
|
180
|
-
yield web3wallet
|
|
180
|
+
yield web3wallet.respondSessionRequest({
|
|
181
181
|
response,
|
|
182
182
|
topic,
|
|
183
183
|
});
|
|
184
184
|
}
|
|
185
185
|
});
|
|
186
186
|
yield globalWallet.initWeb3Wallet();
|
|
187
|
-
web3wallet
|
|
188
|
-
web3wallet
|
|
187
|
+
web3wallet.on('session_proposal', onSessionProposal);
|
|
188
|
+
web3wallet.on('session_request', sessionMessageListener);
|
|
189
189
|
connector.on('chainChange', (_c) => _tslib.__awaiter(void 0, [_c], void 0, function* ({ chain }) {
|
|
190
|
-
const connections = yield web3wallet
|
|
190
|
+
const connections = yield web3wallet.getActiveSessions();
|
|
191
191
|
const connectionTopics = Object.keys(connections !== null && connections !== void 0 ? connections : {});
|
|
192
192
|
// tell all connected dapps that the chain has changed
|
|
193
193
|
yield Promise.all(connectionTopics.map((topic) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
194
|
-
yield web3wallet
|
|
194
|
+
yield web3wallet.emitSessionEvent({
|
|
195
195
|
chainId: `eip155:${chain}`,
|
|
196
196
|
event: {
|
|
197
197
|
data: chain,
|
|
@@ -204,7 +204,7 @@ const GlobalWalletExtension = {
|
|
|
204
204
|
WCListenersOn = true;
|
|
205
205
|
}),
|
|
206
206
|
pairWithWC: (uri) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
207
|
-
yield web3wallet
|
|
207
|
+
yield web3wallet.pair({ uri });
|
|
208
208
|
}),
|
|
209
209
|
qrScanner: (data, width, height, providedOptions) => jsQR__default["default"](data, width, height, providedOptions),
|
|
210
210
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { IWalletKit } from '@reown/walletkit';
|
|
2
2
|
import { Options, QRCode } from 'jsqr';
|
|
3
3
|
import { WalletConnectorExtension } from '@dynamic-labs/wallet-connector-core';
|
|
4
4
|
declare module '@dynamic-labs/wallet-connector-core' {
|
|
@@ -15,7 +15,7 @@ declare module '@dynamic-labs/wallet-connector-core' {
|
|
|
15
15
|
confirmPairing: (confirm: boolean) => Promise<void>;
|
|
16
16
|
getPendingPairing: () => object;
|
|
17
17
|
qrScanner: (data: Uint8ClampedArray, width: number, height: number, providedOptions?: Options) => QRCode | null;
|
|
18
|
-
getWeb3Wallet: () =>
|
|
18
|
+
getWeb3Wallet: () => IWalletKit | undefined;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { __awaiter } from '../_virtual/_tslib.js';
|
|
3
3
|
import { Core } from '@walletconnect/core';
|
|
4
4
|
import { getSdkError, buildApprovedNamespaces } from '@walletconnect/utils';
|
|
5
|
-
import {
|
|
5
|
+
import { WalletKit } from '@reown/walletkit';
|
|
6
6
|
import jsQR from 'jsqr';
|
|
7
7
|
import { logger } from '@dynamic-labs/wallet-connector-core';
|
|
8
8
|
import { unFormatTransaction } from '@dynamic-labs/ethereum-core';
|
|
@@ -81,7 +81,7 @@ const GlobalWalletExtension = {
|
|
|
81
81
|
const core = new Core({
|
|
82
82
|
projectId: settings.walletConnectDappProjectId,
|
|
83
83
|
});
|
|
84
|
-
web3wallet = yield
|
|
84
|
+
web3wallet = yield WalletKit.init({
|
|
85
85
|
core,
|
|
86
86
|
metadata: {
|
|
87
87
|
description: 'Dynamic Embedded Wallet',
|