@dynamic-labs/starknet 4.0.0-alpha.42 → 4.0.0-alpha.44

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,31 @@
1
1
 
2
+ ## [4.0.0-alpha.44](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.43...v4.0.0-alpha.44) (2024-12-09)
3
+
4
+
5
+ ### ⚠ BREAKING CHANGES
6
+
7
+ * Removes the `eventsCallbacks` prop which has been deprecated for a while. Use the `events` prop instead.
8
+
9
+ ### Features
10
+
11
+ * allows changing the storage postfix ([#7558](https://github.com/dynamic-labs/dynamic-auth/issues/7558)) ([f0aac70](https://github.com/dynamic-labs/dynamic-auth/commit/f0aac703732a69615f11876023684509ad87af62))
12
+ * allows filtering tokens ([#7561](https://github.com/dynamic-labs/dynamic-auth/issues/7561)) ([e73b56c](https://github.com/dynamic-labs/dynamic-auth/commit/e73b56cd41ead7e4f693d19ccb2670602d1107c5))
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * fetch and store public key for onekey btc wallet ([#7577](https://github.com/dynamic-labs/dynamic-auth/issues/7577)) ([634e7ac](https://github.com/dynamic-labs/dynamic-auth/commit/634e7ac40dcbe6780f7b52f2aaf6b0a90f1e7325))
18
+
19
+
20
+ * remove eventsCallbacks ([#7571](https://github.com/dynamic-labs/dynamic-auth/issues/7571)) ([7006db3](https://github.com/dynamic-labs/dynamic-auth/commit/7006db3f23ee87b23b075941e16d216d1b8bc356))
21
+
22
+ ## [4.0.0-alpha.43](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.42...v4.0.0-alpha.43) (2024-12-09)
23
+
24
+
25
+ ### Features
26
+
27
+ * add support for OneKey BTC ([#7557](https://github.com/dynamic-labs/dynamic-auth/issues/7557)) ([00f1363](https://github.com/dynamic-labs/dynamic-auth/commit/00f136330bd89ecbd510750641497974b494b149))
28
+
2
29
  ## [4.0.0-alpha.42](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.41...v4.0.0-alpha.42) (2024-12-06)
3
30
 
4
31
 
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.42";
6
+ var version = "4.0.0-alpha.44";
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.42";
2
+ var version = "4.0.0-alpha.44";
3
3
 
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/starknet",
3
- "version": "4.0.0-alpha.42",
3
+ "version": "4.0.0-alpha.44",
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,19 +18,19 @@
18
18
  },
19
19
  "homepage": "https://www.dynamic.xyz/",
20
20
  "dependencies": {
21
+ "@starknet-io/get-starknet-core": "4.0.5",
21
22
  "@starknet-io/types-js": "0.7.7",
22
23
  "starknet": "6.11.0",
23
24
  "starknetkit": "2.3.3",
24
25
  "text-encoding": "0.7.0",
25
26
  "@dynamic-labs/sdk-api-core": "0.0.570",
26
- "@module-federation/runtime": "0.1.18",
27
- "@dynamic-labs/assert-package-version": "4.0.0-alpha.42",
28
- "@dynamic-labs/logger": "4.0.0-alpha.42",
29
- "@dynamic-labs/rpc-providers": "4.0.0-alpha.42",
30
- "@dynamic-labs/starknet-core": "4.0.0-alpha.42",
31
- "@dynamic-labs/utils": "4.0.0-alpha.42",
32
- "@dynamic-labs/wallet-book": "4.0.0-alpha.42",
33
- "@dynamic-labs/wallet-connector-core": "4.0.0-alpha.42",
27
+ "@dynamic-labs/assert-package-version": "4.0.0-alpha.44",
28
+ "@dynamic-labs/logger": "4.0.0-alpha.44",
29
+ "@dynamic-labs/rpc-providers": "4.0.0-alpha.44",
30
+ "@dynamic-labs/starknet-core": "4.0.0-alpha.44",
31
+ "@dynamic-labs/utils": "4.0.0-alpha.44",
32
+ "@dynamic-labs/wallet-book": "4.0.0-alpha.44",
33
+ "@dynamic-labs/wallet-connector-core": "4.0.0-alpha.44",
34
34
  "assert": "2.1.0"
35
35
  },
36
36
  "peerDependencies": {}
package/src/index.cjs CHANGED
@@ -8,6 +8,7 @@ var _package = require('../package.cjs');
8
8
  var argentx = require('./wallets/argent/injected/argentx.cjs');
9
9
  var argentMobile = require('./wallets/argent/argentMobile/argentMobile.cjs');
10
10
  var webwallet = require('./wallets/argent/webwallet/webwallet.cjs');
11
+ var metamask = require('./wallets/injected/metamask.cjs');
11
12
  var fetchStarknetInjectedWalletConnectors = require('./wallets/injected/fetchStarknetInjectedWalletConnectors.cjs');
12
13
  require('@dynamic-labs/starknet-core');
13
14
  var StarknetWallet = require('./wallet/StarknetWallet.cjs');
@@ -22,8 +23,7 @@ const StarknetWalletConnectors = (props) => [
22
23
  argentx.ArgentX,
23
24
  argentMobile.ArgentMobile,
24
25
  webwallet.WebWallet,
25
- // TODO(starknet-v6): Add these back once they support v6
26
- // MetaMask,
26
+ metamask.MetaMask,
27
27
  ];
28
28
 
29
29
  exports.StarknetWallet = StarknetWallet.StarknetWallet;
package/src/index.js CHANGED
@@ -4,6 +4,7 @@ import { version } from '../package.js';
4
4
  import { ArgentX } from './wallets/argent/injected/argentx.js';
5
5
  import { ArgentMobile } from './wallets/argent/argentMobile/argentMobile.js';
6
6
  import { WebWallet } from './wallets/argent/webwallet/webwallet.js';
7
+ import { MetaMask } from './wallets/injected/metamask.js';
7
8
  import { fetchStarknetInjectedWalletConnectors } from './wallets/injected/fetchStarknetInjectedWalletConnectors.js';
8
9
  import '@dynamic-labs/starknet-core';
9
10
  export { StarknetWallet } from './wallet/StarknetWallet.js';
@@ -18,8 +19,7 @@ const StarknetWalletConnectors = (props) => [
18
19
  ArgentX,
19
20
  ArgentMobile,
20
21
  WebWallet,
21
- // TODO(starknet-v6): Add these back once they support v6
22
- // MetaMask,
22
+ MetaMask,
23
23
  ];
24
24
 
25
25
  export { StarknetWalletConnectors };
@@ -0,0 +1,111 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var _tslib = require('../../../_virtual/_tslib.cjs');
7
+ var starknet = require('@starknet-io/get-starknet-core');
8
+ var logger$1 = require('@dynamic-labs/logger');
9
+ var injected = require('./injected.cjs');
10
+
11
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
12
+
13
+ var starknet__default = /*#__PURE__*/_interopDefaultLegacy(starknet);
14
+
15
+ const logger = new logger$1.Logger('MetaMask Starknet Snap', logger$1.LogLevel.INFO);
16
+ class MetaMask extends injected.Injected {
17
+ constructor(opts) {
18
+ super('MetaMask Starknet', 'metamask', opts);
19
+ this.overrideKey = 'metamaskstarknet';
20
+ starknet__default["default"].discoverVirtualWallets().then(() => {
21
+ starknet__default["default"].getAvailableWallets().then((wallets) => {
22
+ const metaMaskProvider = wallets.find((wallet) => wallet.id === 'metamask');
23
+ if (metaMaskProvider) {
24
+ // Justification: Checked with the Snap team, the provider is available on the window object
25
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
26
+ this.provider = metaMaskProvider.provider;
27
+ }
28
+ });
29
+ });
30
+ }
31
+ getNetwork() {
32
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
33
+ if (!this.provider) {
34
+ logger.error('[getNetwork] - No provider found, returning undefined');
35
+ return undefined;
36
+ }
37
+ try {
38
+ logger.info('[getNetwork] - trying to fetch network using provider');
39
+ // we are using this method to get the network so that we always "see" the absolute
40
+ // active network in the companion site. when using the snap wrapper to get the network,
41
+ // we don't "see" the actual active network in the companion site – instead we see the
42
+ // network that was active at the time of the snap initialization
43
+ const result = yield this.provider.request({
44
+ method: 'wallet_invokeSnap',
45
+ params: {
46
+ request: {
47
+ method: 'starkNet_getCurrentNetwork',
48
+ params: {},
49
+ },
50
+ snapId: 'npm:@consensys/starknet-snap',
51
+ },
52
+ });
53
+ if (!('chainId' in result) || typeof result.chainId !== 'string') {
54
+ logger.error(`[getNetwork] - result.chainId should be a string, but got: ${
55
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
56
+ result.chainId}`);
57
+ return undefined;
58
+ }
59
+ if (result.chainId !== this.currentChainId) {
60
+ const resultChainName = this.mapChainIdToNetworkName(result.chainId);
61
+ const currentChainName = this.currentChainId
62
+ ? this.mapChainIdToNetworkName(this.currentChainId)
63
+ : undefined;
64
+ logger.info(`[getNetwork] - emitting chainChange event. got chainId: ${result.chainId} (${resultChainName}). current chainId: ${this.currentChainId} (${currentChainName})`);
65
+ this.emit('chainChange', { chain: result.chainId });
66
+ }
67
+ this.currentChainId = result.chainId;
68
+ return this.currentChainId;
69
+ }
70
+ catch (e) {
71
+ logger.error('[getNetwork] - network fetch request failed, returning undefined', e);
72
+ return undefined;
73
+ }
74
+ });
75
+ }
76
+ setupEventListeners() {
77
+ if (this.intervalId) {
78
+ return;
79
+ }
80
+ this.intervalId = setInterval(() => {
81
+ this.getNetwork().then((chainId) => {
82
+ if (!chainId) {
83
+ return;
84
+ }
85
+ const resultChainName = this.mapChainIdToNetworkName(chainId);
86
+ const currentChainName = this.currentChainId
87
+ ? this.mapChainIdToNetworkName(this.currentChainId)
88
+ : undefined;
89
+ logger.info(`[setupEventListeners] - got network: ${chainId} (${resultChainName}). current network: ${this.currentChainId} (${currentChainName})`);
90
+ if (chainId !== this.currentChainId) {
91
+ logger.info(`[setupEventListeners] - emitting chainChange event: ${chainId}`);
92
+ this.emit('chainChange', { chain: chainId });
93
+ this.currentChainId = chainId;
94
+ }
95
+ });
96
+ }, 5000);
97
+ }
98
+ teardownEventListeners() {
99
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
100
+ clearInterval(this.intervalId);
101
+ this.intervalId = undefined;
102
+ });
103
+ }
104
+ endSession() {
105
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
106
+ this.teardownEventListeners();
107
+ });
108
+ }
109
+ }
110
+
111
+ exports.MetaMask = MetaMask;
@@ -0,0 +1,103 @@
1
+ 'use client'
2
+ import { __awaiter } from '../../../_virtual/_tslib.js';
3
+ import starknet from '@starknet-io/get-starknet-core';
4
+ import { Logger, LogLevel } from '@dynamic-labs/logger';
5
+ import { Injected } from './injected.js';
6
+
7
+ const logger = new Logger('MetaMask Starknet Snap', LogLevel.INFO);
8
+ class MetaMask extends Injected {
9
+ constructor(opts) {
10
+ super('MetaMask Starknet', 'metamask', opts);
11
+ this.overrideKey = 'metamaskstarknet';
12
+ starknet.discoverVirtualWallets().then(() => {
13
+ starknet.getAvailableWallets().then((wallets) => {
14
+ const metaMaskProvider = wallets.find((wallet) => wallet.id === 'metamask');
15
+ if (metaMaskProvider) {
16
+ // Justification: Checked with the Snap team, the provider is available on the window object
17
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
+ this.provider = metaMaskProvider.provider;
19
+ }
20
+ });
21
+ });
22
+ }
23
+ getNetwork() {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ if (!this.provider) {
26
+ logger.error('[getNetwork] - No provider found, returning undefined');
27
+ return undefined;
28
+ }
29
+ try {
30
+ logger.info('[getNetwork] - trying to fetch network using provider');
31
+ // we are using this method to get the network so that we always "see" the absolute
32
+ // active network in the companion site. when using the snap wrapper to get the network,
33
+ // we don't "see" the actual active network in the companion site – instead we see the
34
+ // network that was active at the time of the snap initialization
35
+ const result = yield this.provider.request({
36
+ method: 'wallet_invokeSnap',
37
+ params: {
38
+ request: {
39
+ method: 'starkNet_getCurrentNetwork',
40
+ params: {},
41
+ },
42
+ snapId: 'npm:@consensys/starknet-snap',
43
+ },
44
+ });
45
+ if (!('chainId' in result) || typeof result.chainId !== 'string') {
46
+ logger.error(`[getNetwork] - result.chainId should be a string, but got: ${
47
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
+ result.chainId}`);
49
+ return undefined;
50
+ }
51
+ if (result.chainId !== this.currentChainId) {
52
+ const resultChainName = this.mapChainIdToNetworkName(result.chainId);
53
+ const currentChainName = this.currentChainId
54
+ ? this.mapChainIdToNetworkName(this.currentChainId)
55
+ : undefined;
56
+ logger.info(`[getNetwork] - emitting chainChange event. got chainId: ${result.chainId} (${resultChainName}). current chainId: ${this.currentChainId} (${currentChainName})`);
57
+ this.emit('chainChange', { chain: result.chainId });
58
+ }
59
+ this.currentChainId = result.chainId;
60
+ return this.currentChainId;
61
+ }
62
+ catch (e) {
63
+ logger.error('[getNetwork] - network fetch request failed, returning undefined', e);
64
+ return undefined;
65
+ }
66
+ });
67
+ }
68
+ setupEventListeners() {
69
+ if (this.intervalId) {
70
+ return;
71
+ }
72
+ this.intervalId = setInterval(() => {
73
+ this.getNetwork().then((chainId) => {
74
+ if (!chainId) {
75
+ return;
76
+ }
77
+ const resultChainName = this.mapChainIdToNetworkName(chainId);
78
+ const currentChainName = this.currentChainId
79
+ ? this.mapChainIdToNetworkName(this.currentChainId)
80
+ : undefined;
81
+ logger.info(`[setupEventListeners] - got network: ${chainId} (${resultChainName}). current network: ${this.currentChainId} (${currentChainName})`);
82
+ if (chainId !== this.currentChainId) {
83
+ logger.info(`[setupEventListeners] - emitting chainChange event: ${chainId}`);
84
+ this.emit('chainChange', { chain: chainId });
85
+ this.currentChainId = chainId;
86
+ }
87
+ });
88
+ }, 5000);
89
+ }
90
+ teardownEventListeners() {
91
+ return __awaiter(this, void 0, void 0, function* () {
92
+ clearInterval(this.intervalId);
93
+ this.intervalId = undefined;
94
+ });
95
+ }
96
+ endSession() {
97
+ return __awaiter(this, void 0, void 0, function* () {
98
+ this.teardownEventListeners();
99
+ });
100
+ }
101
+ }
102
+
103
+ export { MetaMask };
@@ -1,8 +0,0 @@
1
- import { StarknetWindowObject } from '@starknet-io/types-js';
2
- import { IEthereum } from '@dynamic-labs/utils';
3
- /**
4
- *
5
- * @param {IEthereum} provider the metamask window provider object
6
- * @returns {StarknetWindowObject} the metamask provider wrapper formed into starknet window object
7
- */
8
- export declare const createMetaMaskProviderWrapper: (provider: IEthereum) => Promise<StarknetWindowObject | undefined>;