@dynamic-labs/global-wallet 4.0.0-alpha.31 → 4.0.0-alpha.33
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 +4 -4
- package/src/GlobalWalletConnector.cjs +22 -9
- package/src/GlobalWalletConnector.js +22 -9
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.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.33",
|
|
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,9 @@
|
|
|
22
22
|
"@walletconnect/utils": "2.13.1",
|
|
23
23
|
"@walletconnect/web3wallet": "1.12.1",
|
|
24
24
|
"jsqr": "1.4.0",
|
|
25
|
-
"@dynamic-labs/assert-package-version": "4.0.0-alpha.
|
|
26
|
-
"@dynamic-labs/ethereum-core": "4.0.0-alpha.
|
|
27
|
-
"@dynamic-labs/wallet-connector-core": "4.0.0-alpha.
|
|
25
|
+
"@dynamic-labs/assert-package-version": "4.0.0-alpha.33",
|
|
26
|
+
"@dynamic-labs/ethereum-core": "4.0.0-alpha.33",
|
|
27
|
+
"@dynamic-labs/wallet-connector-core": "4.0.0-alpha.33"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"viem": "^2.7.6",
|
|
@@ -43,7 +43,7 @@ const GlobalWalletExtension = {
|
|
|
43
43
|
let web3wallet$1;
|
|
44
44
|
let WCListenersOn = false;
|
|
45
45
|
let pendingSessionProposal;
|
|
46
|
-
|
|
46
|
+
let signer = (yield connector.getSigner());
|
|
47
47
|
const globalWallet = {
|
|
48
48
|
confirmPairing: (confirm) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
49
49
|
const { params, id } = pendingSessionProposal;
|
|
@@ -136,22 +136,26 @@ const GlobalWalletExtension = {
|
|
|
136
136
|
return response;
|
|
137
137
|
});
|
|
138
138
|
let response;
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
const handleEthSignTypedDataV4 = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
140
|
+
return handleRequest(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
141
141
|
return signer.signTypedData(Object.assign(Object.assign({}, JSON.parse(typedDataToSign)), { account: requestParamsMessage }));
|
|
142
142
|
}));
|
|
143
|
-
}
|
|
144
|
-
|
|
143
|
+
});
|
|
144
|
+
const handlePersonalSign = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
145
145
|
const message = Buffer.from(requestParamsMessage.slice(2), 'hex').toString('utf8');
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
|
|
146
|
+
return handleRequest(() => connector.signMessage(message));
|
|
147
|
+
});
|
|
148
|
+
const handleEthSendTransaction = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
149
149
|
if (chainId) {
|
|
150
150
|
yield connector.switchNetwork({
|
|
151
151
|
networkChainId: chainId.split(':')[1],
|
|
152
152
|
});
|
|
153
153
|
}
|
|
154
|
-
|
|
154
|
+
// sometimes the signer is undefined at initialization
|
|
155
|
+
if (!signer) {
|
|
156
|
+
signer = (yield connector.getSigner());
|
|
157
|
+
}
|
|
158
|
+
return handleRequest(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
155
159
|
const estimatedFeesPerGas = yield (yield connector.getPublicClient()).estimateFeesPerGas();
|
|
156
160
|
const type = (estimatedFeesPerGas === null || estimatedFeesPerGas === void 0 ? void 0 : estimatedFeesPerGas.maxFeePerGas)
|
|
157
161
|
? 'eip1559'
|
|
@@ -162,6 +166,15 @@ const GlobalWalletExtension = {
|
|
|
162
166
|
? undefined
|
|
163
167
|
: requestParamsMessage.gasPrice, type, value: requestParamsMessage.value })));
|
|
164
168
|
}));
|
|
169
|
+
});
|
|
170
|
+
if (request.method === 'eth_signTypedData_v4') {
|
|
171
|
+
response = yield handleEthSignTypedDataV4();
|
|
172
|
+
}
|
|
173
|
+
else if (request.method === 'personal_sign') {
|
|
174
|
+
response = yield handlePersonalSign();
|
|
175
|
+
}
|
|
176
|
+
else if (request.method === 'eth_sendTransaction') {
|
|
177
|
+
response = yield handleEthSendTransaction();
|
|
165
178
|
}
|
|
166
179
|
if (response) {
|
|
167
180
|
yield web3wallet$1.respondSessionRequest({
|
|
@@ -35,7 +35,7 @@ const GlobalWalletExtension = {
|
|
|
35
35
|
let web3wallet;
|
|
36
36
|
let WCListenersOn = false;
|
|
37
37
|
let pendingSessionProposal;
|
|
38
|
-
|
|
38
|
+
let signer = (yield connector.getSigner());
|
|
39
39
|
const globalWallet = {
|
|
40
40
|
confirmPairing: (confirm) => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
41
|
const { params, id } = pendingSessionProposal;
|
|
@@ -128,22 +128,26 @@ const GlobalWalletExtension = {
|
|
|
128
128
|
return response;
|
|
129
129
|
});
|
|
130
130
|
let response;
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
const handleEthSignTypedDataV4 = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
132
|
+
return handleRequest(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
133
133
|
return signer.signTypedData(Object.assign(Object.assign({}, JSON.parse(typedDataToSign)), { account: requestParamsMessage }));
|
|
134
134
|
}));
|
|
135
|
-
}
|
|
136
|
-
|
|
135
|
+
});
|
|
136
|
+
const handlePersonalSign = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
137
137
|
const message = Buffer.from(requestParamsMessage.slice(2), 'hex').toString('utf8');
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
|
|
138
|
+
return handleRequest(() => connector.signMessage(message));
|
|
139
|
+
});
|
|
140
|
+
const handleEthSendTransaction = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
141
141
|
if (chainId) {
|
|
142
142
|
yield connector.switchNetwork({
|
|
143
143
|
networkChainId: chainId.split(':')[1],
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
|
-
|
|
146
|
+
// sometimes the signer is undefined at initialization
|
|
147
|
+
if (!signer) {
|
|
148
|
+
signer = (yield connector.getSigner());
|
|
149
|
+
}
|
|
150
|
+
return handleRequest(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
147
151
|
const estimatedFeesPerGas = yield (yield connector.getPublicClient()).estimateFeesPerGas();
|
|
148
152
|
const type = (estimatedFeesPerGas === null || estimatedFeesPerGas === void 0 ? void 0 : estimatedFeesPerGas.maxFeePerGas)
|
|
149
153
|
? 'eip1559'
|
|
@@ -154,6 +158,15 @@ const GlobalWalletExtension = {
|
|
|
154
158
|
? undefined
|
|
155
159
|
: requestParamsMessage.gasPrice, type, value: requestParamsMessage.value })));
|
|
156
160
|
}));
|
|
161
|
+
});
|
|
162
|
+
if (request.method === 'eth_signTypedData_v4') {
|
|
163
|
+
response = yield handleEthSignTypedDataV4();
|
|
164
|
+
}
|
|
165
|
+
else if (request.method === 'personal_sign') {
|
|
166
|
+
response = yield handlePersonalSign();
|
|
167
|
+
}
|
|
168
|
+
else if (request.method === 'eth_sendTransaction') {
|
|
169
|
+
response = yield handleEthSendTransaction();
|
|
157
170
|
}
|
|
158
171
|
if (response) {
|
|
159
172
|
yield web3wallet.respondSessionRequest({
|