@dynamic-labs/starknet 0.18.12 → 0.18.13

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/CHANGELOG.md CHANGED
@@ -1,4 +1,19 @@
1
1
 
2
+ ### [0.18.13](https://github.com/dynamic-labs/DynamicAuth/compare/v0.18.12...v0.18.13) (2023-08-31)
3
+
4
+
5
+ ### Features
6
+
7
+ * add option to disable the locked wallet view ([#3188](https://github.com/dynamic-labs/DynamicAuth/issues/3188)) ([47ae562](https://github.com/dynamic-labs/DynamicAuth/commit/47ae562e58b38ec704490cdab56a73115cdee184))
8
+ * migrate starknet version to v5 ([#3199](https://github.com/dynamic-labs/DynamicAuth/issues/3199)) ([185beb0](https://github.com/dynamic-labs/DynamicAuth/commit/185beb099d9dcce0935b2d11b49460fc3a5f2608))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * show the multi wallet list when opening the auth flow to authenticated users ([#3163](https://github.com/dynamic-labs/DynamicAuth/issues/3163)) ([25d30cd](https://github.com/dynamic-labs/DynamicAuth/commit/25d30cdebc46a84725d289aab0bb30c3d54a15ab)), closes [#3134](https://github.com/dynamic-labs/DynamicAuth/issues/3134) [#3152](https://github.com/dynamic-labs/DynamicAuth/issues/3152) [#3168](https://github.com/dynamic-labs/DynamicAuth/issues/3168)
14
+ * sign message for embedded wallet when auth mode is connect only ([#3194](https://github.com/dynamic-labs/DynamicAuth/issues/3194)) ([6879aeb](https://github.com/dynamic-labs/DynamicAuth/commit/6879aebb3b22d7476fb06f8d33a0029199bf910f))
15
+ * verify email OTP when email is updated ([#3168](https://github.com/dynamic-labs/DynamicAuth/issues/3168)) ([641eeb6](https://github.com/dynamic-labs/DynamicAuth/commit/641eeb685b0c9d77cc72912f29b137c699c192f0))
16
+
2
17
  ### [0.18.12](https://github.com/dynamic-labs/DynamicAuth/compare/v0.18.11...v0.18.12) (2023-08-30)
3
18
 
4
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/starknet",
3
- "version": "0.18.12",
3
+ "version": "0.18.13",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/dynamic-labs/DynamicAuth.git",
@@ -26,13 +26,13 @@
26
26
  "./package.json": "./package.json"
27
27
  },
28
28
  "dependencies": {
29
- "starknet": "5.14.1",
30
- "get-starknet-core": "3.0.1",
29
+ "starknet": "^5.19.5",
30
+ "get-starknet-core": "^3.2.0",
31
31
  "text-encoding": "0.7.0",
32
32
  "@dynamic-labs/sdk-api": "0.0.270",
33
- "@dynamic-labs/utils": "0.18.12",
34
- "@dynamic-labs/wallet-book": "0.18.12",
35
- "@dynamic-labs/wallet-connector-core": "0.18.12"
33
+ "@dynamic-labs/utils": "0.18.13",
34
+ "@dynamic-labs/wallet-book": "0.18.13",
35
+ "@dynamic-labs/wallet-connector-core": "0.18.13"
36
36
  },
37
37
  "peerDependencies": {}
38
38
  }
@@ -11,6 +11,7 @@ var convertors = require('./utils/convertors.cjs');
11
11
 
12
12
  const ACCOUNT_CHANGED_EVENT_LISTENER = 'accountsChanged';
13
13
  const NETWORK_CHANGED_EVENT_LISTENER = 'networkChanged';
14
+ const STARKNET_VERSION = 'v5';
14
15
  class StarknetWalletConnector extends walletConnectorCore.WalletConnectorBase {
15
16
  constructor(name, windowKey, opts) {
16
17
  super(opts);
@@ -40,9 +41,9 @@ class StarknetWalletConnector extends walletConnectorCore.WalletConnectorBase {
40
41
  return Promise.resolve(undefined);
41
42
  }
42
43
  if (!wallet.isConnected) {
43
- yield wallet.enable();
44
+ yield wallet.enable({ starknetVersion: STARKNET_VERSION });
44
45
  }
45
- return Promise.resolve((_a = wallet.provider) === null || _a === void 0 ? void 0 : _a.chainId);
46
+ return Promise.resolve((_a = wallet.provider) === null || _a === void 0 ? void 0 : _a.getChainId());
46
47
  });
47
48
  }
48
49
  connect() {
@@ -50,7 +51,7 @@ class StarknetWalletConnector extends walletConnectorCore.WalletConnectorBase {
50
51
  const wallet = yield this.getWallet();
51
52
  try {
52
53
  if (wallet && !wallet.isConnected) {
53
- yield wallet.enable();
54
+ yield wallet.enable({ starknetVersion: STARKNET_VERSION });
54
55
  }
55
56
  }
56
57
  catch (err) {
@@ -100,8 +101,7 @@ class StarknetWalletConnector extends walletConnectorCore.WalletConnectorBase {
100
101
  walletConnectorCore.logger.error('Could not fetch wallet address for signing message');
101
102
  return undefined;
102
103
  }
103
- const { provider: { chainId }, } = wallet;
104
- const encodedMessage = convertors.formatTypedDataMessage(messageToSign, chainId);
104
+ const encodedMessage = convertors.formatTypedDataMessage(messageToSign, (yield wallet.provider.getChainId()));
105
105
  const signature = yield wallet.account.signMessage(encodedMessage);
106
106
  return signature === null || signature === void 0 ? void 0 : signature.join(',');
107
107
  });
@@ -117,12 +117,11 @@ class StarknetWalletConnector extends walletConnectorCore.WalletConnectorBase {
117
117
  const contract = new starknet.Contract(ethereumContractAbi, constants.ETH_STARKNET_ADDRESS, provider);
118
118
  try {
119
119
  const { balance } = yield contract.balanceOf(walletAddress);
120
- const gweiBalance = parseInt(starknet.uint256.uint256ToBN(balance).toString(10));
121
120
  /**
122
121
  * Dividing by 1e18 as the returned balance is a Gwei number.
123
122
  * Read more here: https://www.investopedia.com/terms/g/gwei-ethereum.asp#toc-what-is-gwei
124
123
  */
125
- return (gweiBalance / 1e18).toFixed(6);
124
+ return (Number(starknet.cairo.uint256(balance.low).low) / 1e18).toFixed(6);
126
125
  }
127
126
  catch (error) {
128
127
  throw new utils.DynamicError('Something went wrong');
@@ -1,6 +1,6 @@
1
1
  import { __awaiter } from '../_virtual/_tslib.js';
2
2
  import { getStarknet } from 'get-starknet-core';
3
- import { RpcProvider, Contract, uint256, constants } from 'starknet';
3
+ import { RpcProvider, Contract, cairo, constants } from 'starknet';
4
4
  import { WalletConnectorBase, logger } from '@dynamic-labs/wallet-connector-core';
5
5
  import { DynamicError } from '@dynamic-labs/utils';
6
6
  import { ETH_STARKNET_ADDRESS } from './constants.js';
@@ -9,6 +9,7 @@ import { formatTypedDataMessage } from './utils/convertors.js';
9
9
 
10
10
  const ACCOUNT_CHANGED_EVENT_LISTENER = 'accountsChanged';
11
11
  const NETWORK_CHANGED_EVENT_LISTENER = 'networkChanged';
12
+ const STARKNET_VERSION = 'v5';
12
13
  class StarknetWalletConnector extends WalletConnectorBase {
13
14
  constructor(name, windowKey, opts) {
14
15
  super(opts);
@@ -38,9 +39,9 @@ class StarknetWalletConnector extends WalletConnectorBase {
38
39
  return Promise.resolve(undefined);
39
40
  }
40
41
  if (!wallet.isConnected) {
41
- yield wallet.enable();
42
+ yield wallet.enable({ starknetVersion: STARKNET_VERSION });
42
43
  }
43
- return Promise.resolve((_a = wallet.provider) === null || _a === void 0 ? void 0 : _a.chainId);
44
+ return Promise.resolve((_a = wallet.provider) === null || _a === void 0 ? void 0 : _a.getChainId());
44
45
  });
45
46
  }
46
47
  connect() {
@@ -48,7 +49,7 @@ class StarknetWalletConnector extends WalletConnectorBase {
48
49
  const wallet = yield this.getWallet();
49
50
  try {
50
51
  if (wallet && !wallet.isConnected) {
51
- yield wallet.enable();
52
+ yield wallet.enable({ starknetVersion: STARKNET_VERSION });
52
53
  }
53
54
  }
54
55
  catch (err) {
@@ -98,8 +99,7 @@ class StarknetWalletConnector extends WalletConnectorBase {
98
99
  logger.error('Could not fetch wallet address for signing message');
99
100
  return undefined;
100
101
  }
101
- const { provider: { chainId }, } = wallet;
102
- const encodedMessage = formatTypedDataMessage(messageToSign, chainId);
102
+ const encodedMessage = formatTypedDataMessage(messageToSign, (yield wallet.provider.getChainId()));
103
103
  const signature = yield wallet.account.signMessage(encodedMessage);
104
104
  return signature === null || signature === void 0 ? void 0 : signature.join(',');
105
105
  });
@@ -115,12 +115,11 @@ class StarknetWalletConnector extends WalletConnectorBase {
115
115
  const contract = new Contract(ETH_CONTRACT_ABI, ETH_STARKNET_ADDRESS, provider);
116
116
  try {
117
117
  const { balance } = yield contract.balanceOf(walletAddress);
118
- const gweiBalance = parseInt(uint256.uint256ToBN(balance).toString(10));
119
118
  /**
120
119
  * Dividing by 1e18 as the returned balance is a Gwei number.
121
120
  * Read more here: https://www.investopedia.com/terms/g/gwei-ethereum.asp#toc-what-is-gwei
122
121
  */
123
- return (gweiBalance / 1e18).toFixed(6);
122
+ return (Number(cairo.uint256(balance.low).low) / 1e18).toFixed(6);
124
123
  }
125
124
  catch (error) {
126
125
  throw new DynamicError('Something went wrong');