@dynamic-labs/global-wallet 4.0.0-alpha.3 → 4.0.0-alpha.31

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 ADDED
@@ -0,0 +1,8 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var version = "4.0.0-alpha.31";
7
+
8
+ exports.version = version;
package/package.js ADDED
@@ -0,0 +1,4 @@
1
+ 'use client'
2
+ var version = "4.0.0-alpha.31";
3
+
4
+ export { version };
package/package.json CHANGED
@@ -1,16 +1,7 @@
1
1
  {
2
2
  "name": "@dynamic-labs/global-wallet",
3
- "version": "4.0.0-alpha.3",
4
- "repository": {
5
- "type": "git",
6
- "url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
7
- "directory": "packages/global-wallet"
8
- },
3
+ "version": "4.0.0-alpha.31",
9
4
  "description": "A React SDK for implementing wallet web3 authentication and authorization to your website.",
10
- "bugs": {
11
- "url": "https://github.com/dynamic-labs/DynamicAuth/issues"
12
- },
13
- "homepage": "https://github.com/dynamic-labs/DynamicAuth#readme",
14
5
  "author": "Dynamic Labs, Inc.",
15
6
  "license": "MIT",
16
7
  "main": "./index.cjs",
@@ -25,12 +16,15 @@
25
16
  },
26
17
  "./package.json": "./package.json"
27
18
  },
19
+ "homepage": "https://www.dynamic.xyz/",
28
20
  "dependencies": {
29
21
  "@walletconnect/core": "2.13.1",
30
22
  "@walletconnect/utils": "2.13.1",
31
23
  "@walletconnect/web3wallet": "1.12.1",
32
24
  "jsqr": "1.4.0",
33
- "@dynamic-labs/wallet-connector-core": "4.0.0-alpha.3"
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"
34
28
  },
35
29
  "peerDependencies": {
36
30
  "viem": "^2.7.6",
@@ -7,8 +7,9 @@ var _tslib = require('../_virtual/_tslib.cjs');
7
7
  var core = require('@walletconnect/core');
8
8
  var utils = require('@walletconnect/utils');
9
9
  var web3wallet = require('@walletconnect/web3wallet');
10
- var viem = require('viem');
11
10
  var jsQR = require('jsqr');
11
+ var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
12
+ var ethereumCore = require('@dynamic-labs/ethereum-core');
12
13
 
13
14
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
14
15
 
@@ -42,6 +43,7 @@ const GlobalWalletExtension = {
42
43
  let web3wallet$1;
43
44
  let WCListenersOn = false;
44
45
  let pendingSessionProposal;
46
+ const signer = (yield connector.getSigner());
45
47
  const globalWallet = {
46
48
  confirmPairing: (confirm) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
47
49
  const { params, id } = pendingSessionProposal;
@@ -108,16 +110,18 @@ const GlobalWalletExtension = {
108
110
  const { request, chainId } = params;
109
111
  // since we cant listen to chain events from the dapp, just change when a request comes in
110
112
  const [requestParamsMessage, typedDataToSign] = request.params;
111
- const signer = (yield connector.getSigner());
112
113
  const handleRequest = (handler) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
114
+ let response;
113
115
  try {
116
+ // tell wallet ui utils that the transaction is coming from global connectivity
117
+ // so we can force the confirmation ui to be on
114
118
  connector.isGlobalTransaction = true;
115
119
  const result = yield handler();
116
- connector.isGlobalTransaction = false;
117
- return { id, jsonrpc: '2.0', result };
120
+ response = { id, jsonrpc: '2.0', result };
118
121
  }
119
122
  catch (e) {
120
- return {
123
+ walletConnectorCore.logger.error('Error listening to session request', e);
124
+ response = {
121
125
  error: {
122
126
  code: 5000,
123
127
  message: 'User rejected.',
@@ -126,6 +130,10 @@ const GlobalWalletExtension = {
126
130
  jsonrpc: '2.0',
127
131
  };
128
132
  }
133
+ finally {
134
+ connector.isGlobalTransaction = false;
135
+ }
136
+ return response;
129
137
  });
130
138
  let response;
131
139
  if (request.method === 'eth_signTypedData_v4') {
@@ -144,9 +152,15 @@ const GlobalWalletExtension = {
144
152
  });
145
153
  }
146
154
  response = yield handleRequest(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
147
- return signer.sendTransaction(Object.assign(Object.assign({}, requestParamsMessage), { gas: viem.fromHex(requestParamsMessage.gas, 'bigint'), value: requestParamsMessage.value
148
- ? viem.fromHex(requestParamsMessage.value, 'bigint')
149
- : BigInt(0) }));
155
+ const estimatedFeesPerGas = yield (yield connector.getPublicClient()).estimateFeesPerGas();
156
+ const type = (estimatedFeesPerGas === null || estimatedFeesPerGas === void 0 ? void 0 : estimatedFeesPerGas.maxFeePerGas)
157
+ ? 'eip1559'
158
+ : 'legacy';
159
+ return signer.sendTransaction(ethereumCore.unFormatTransaction(Object.assign(Object.assign({}, requestParamsMessage), {
160
+ // strip the gasPrice if it should be a eip1559 tx or tx will fail
161
+ gasPrice: estimatedFeesPerGas && estimatedFeesPerGas.maxFeePerGas
162
+ ? undefined
163
+ : requestParamsMessage.gasPrice, type, value: requestParamsMessage.value })));
150
164
  }));
151
165
  }
152
166
  if (response) {
@@ -3,8 +3,9 @@ import { __awaiter } from '../_virtual/_tslib.js';
3
3
  import { Core } from '@walletconnect/core';
4
4
  import { getSdkError, buildApprovedNamespaces } from '@walletconnect/utils';
5
5
  import { Web3Wallet } from '@walletconnect/web3wallet';
6
- import { fromHex } from 'viem';
7
6
  import jsQR from 'jsqr';
7
+ import { logger } from '@dynamic-labs/wallet-connector-core';
8
+ import { unFormatTransaction } from '@dynamic-labs/ethereum-core';
8
9
 
9
10
  /* eslint-disable import/no-extraneous-dependencies */
10
11
  const buildCombinedNamespaces = (params) => {
@@ -34,6 +35,7 @@ const GlobalWalletExtension = {
34
35
  let web3wallet;
35
36
  let WCListenersOn = false;
36
37
  let pendingSessionProposal;
38
+ const signer = (yield connector.getSigner());
37
39
  const globalWallet = {
38
40
  confirmPairing: (confirm) => __awaiter(void 0, void 0, void 0, function* () {
39
41
  const { params, id } = pendingSessionProposal;
@@ -100,16 +102,18 @@ const GlobalWalletExtension = {
100
102
  const { request, chainId } = params;
101
103
  // since we cant listen to chain events from the dapp, just change when a request comes in
102
104
  const [requestParamsMessage, typedDataToSign] = request.params;
103
- const signer = (yield connector.getSigner());
104
105
  const handleRequest = (handler) => __awaiter(void 0, void 0, void 0, function* () {
106
+ let response;
105
107
  try {
108
+ // tell wallet ui utils that the transaction is coming from global connectivity
109
+ // so we can force the confirmation ui to be on
106
110
  connector.isGlobalTransaction = true;
107
111
  const result = yield handler();
108
- connector.isGlobalTransaction = false;
109
- return { id, jsonrpc: '2.0', result };
112
+ response = { id, jsonrpc: '2.0', result };
110
113
  }
111
114
  catch (e) {
112
- return {
115
+ logger.error('Error listening to session request', e);
116
+ response = {
113
117
  error: {
114
118
  code: 5000,
115
119
  message: 'User rejected.',
@@ -118,6 +122,10 @@ const GlobalWalletExtension = {
118
122
  jsonrpc: '2.0',
119
123
  };
120
124
  }
125
+ finally {
126
+ connector.isGlobalTransaction = false;
127
+ }
128
+ return response;
121
129
  });
122
130
  let response;
123
131
  if (request.method === 'eth_signTypedData_v4') {
@@ -136,9 +144,15 @@ const GlobalWalletExtension = {
136
144
  });
137
145
  }
138
146
  response = yield handleRequest(() => __awaiter(void 0, void 0, void 0, function* () {
139
- return signer.sendTransaction(Object.assign(Object.assign({}, requestParamsMessage), { gas: fromHex(requestParamsMessage.gas, 'bigint'), value: requestParamsMessage.value
140
- ? fromHex(requestParamsMessage.value, 'bigint')
141
- : BigInt(0) }));
147
+ const estimatedFeesPerGas = yield (yield connector.getPublicClient()).estimateFeesPerGas();
148
+ const type = (estimatedFeesPerGas === null || estimatedFeesPerGas === void 0 ? void 0 : estimatedFeesPerGas.maxFeePerGas)
149
+ ? 'eip1559'
150
+ : 'legacy';
151
+ return signer.sendTransaction(unFormatTransaction(Object.assign(Object.assign({}, requestParamsMessage), {
152
+ // strip the gasPrice if it should be a eip1559 tx or tx will fail
153
+ gasPrice: estimatedFeesPerGas && estimatedFeesPerGas.maxFeePerGas
154
+ ? undefined
155
+ : requestParamsMessage.gasPrice, type, value: requestParamsMessage.value })));
142
156
  }));
143
157
  }
144
158
  if (response) {
package/src/index.cjs CHANGED
@@ -3,9 +3,11 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
+ var assertPackageVersion = require('@dynamic-labs/assert-package-version');
7
+ var _package = require('../package.cjs');
6
8
  var GlobalWalletConnector = require('./GlobalWalletConnector.cjs');
7
9
 
8
-
10
+ assertPackageVersion.assertPackageVersion('@dynamic-labs/global-wallet', _package.version);
9
11
 
10
12
  exports.GlobalWalletExtension = GlobalWalletConnector.GlobalWalletExtension;
11
13
  exports.buildCombinedNamespaces = GlobalWalletConnector.buildCombinedNamespaces;
package/src/index.js CHANGED
@@ -1,2 +1,6 @@
1
1
  'use client'
2
+ import { assertPackageVersion } from '@dynamic-labs/assert-package-version';
3
+ import { version } from '../package.js';
2
4
  export { GlobalWalletExtension, buildCombinedNamespaces } from './GlobalWalletConnector.js';
5
+
6
+ assertPackageVersion('@dynamic-labs/global-wallet', version);