@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 CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.0.0-alpha.31";
6
+ var version = "4.0.0-alpha.33";
7
7
 
8
8
  exports.version = version;
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client'
2
- var version = "4.0.0-alpha.31";
2
+ var version = "4.0.0-alpha.33";
3
3
 
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/global-wallet",
3
- "version": "4.0.0-alpha.31",
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.31",
26
- "@dynamic-labs/ethereum-core": "4.0.0-alpha.31",
27
- "@dynamic-labs/wallet-connector-core": "4.0.0-alpha.31"
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
- const signer = (yield connector.getSigner());
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
- if (request.method === 'eth_signTypedData_v4') {
140
- response = yield handleRequest(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
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
- else if (request.method === 'personal_sign') {
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
- response = yield handleRequest(() => connector.signMessage(message));
147
- }
148
- else if (request.method === 'eth_sendTransaction') {
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
- response = yield handleRequest(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
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
- const signer = (yield connector.getSigner());
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
- if (request.method === 'eth_signTypedData_v4') {
132
- response = yield handleRequest(() => __awaiter(void 0, void 0, void 0, function* () {
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
- else if (request.method === 'personal_sign') {
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
- response = yield handleRequest(() => connector.signMessage(message));
139
- }
140
- else if (request.method === 'eth_sendTransaction') {
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
- response = yield handleRequest(() => __awaiter(void 0, void 0, void 0, function* () {
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({