@dynamic-labs/starknet 1.0.0-alpha.0 → 1.0.0-alpha.1

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,52 @@
1
1
 
2
+ ## [1.0.0-alpha.1](https://github.com/dynamic-labs/DynamicAuth/compare/v1.0.0-alpha.0...v1.0.0-alpha.1) (2023-11-22)
3
+
4
+
5
+ ### Features
6
+
7
+ * add basic zerodev connector ([#3782](https://github.com/dynamic-labs/DynamicAuth/issues/3782)) ([3f8debd](https://github.com/dynamic-labs/DynamicAuth/commit/3f8debddb1bff325389193e0348128ebb9ba59b9))
8
+ * add hcaptcha to dynamic signin methods ([#3853](https://github.com/dynamic-labs/DynamicAuth/issues/3853)) ([a4a9ad3](https://github.com/dynamic-labs/DynamicAuth/commit/a4a9ad3b048e33acc5b885cd797697ca4f41995e))
9
+ * add hcaptcha to magic login methods ([#3894](https://github.com/dynamic-labs/DynamicAuth/issues/3894)) ([c76b750](https://github.com/dynamic-labs/DynamicAuth/commit/c76b750351557ad9cf5bbcc39bd7fd0970b66312))
10
+ * add need help section to sign message modal ([#3847](https://github.com/dynamic-labs/DynamicAuth/issues/3847)) ([4f90617](https://github.com/dynamic-labs/DynamicAuth/commit/4f90617bcf400a7171062435c731d95c6bbf41c7))
11
+ * add perawallet to wallet book ([#3868](https://github.com/dynamic-labs/DynamicAuth/issues/3868)) ([5f4e79d](https://github.com/dynamic-labs/DynamicAuth/commit/5f4e79df202b02088b15c5dfab7feee5789e9ece))
12
+ * add serialization to allow sending events callbacks and wallet connectors used by customers ([0077eb0](https://github.com/dynamic-labs/DynamicAuth/commit/0077eb0af05feb765d0c61911a48d5e98554760a))
13
+ * add support for dynamic domains for starknet signatures ([#3927](https://github.com/dynamic-labs/DynamicAuth/issues/3927)) ([52797ce](https://github.com/dynamic-labs/DynamicAuth/commit/52797ce867c956049bfa5021cf5b1c562e771a2e))
14
+ * add support for Pera Wallet ([#3866](https://github.com/dynamic-labs/DynamicAuth/issues/3866)) ([cb99ae7](https://github.com/dynamic-labs/DynamicAuth/commit/cb99ae77605d913932a77bf2ea565b7e7baf781a))
15
+ * add support for private starknet rpc providers ([#3881](https://github.com/dynamic-labs/DynamicAuth/issues/3881)) ([8fd5ef9](https://github.com/dynamic-labs/DynamicAuth/commit/8fd5ef902d48ef828b1cb89d0e462ea5b54f4e42))
16
+ * add zerodev to wallet book and render generic wallet icon ([#3822](https://github.com/dynamic-labs/DynamicAuth/issues/3822)) ([9c5768d](https://github.com/dynamic-labs/DynamicAuth/commit/9c5768d0fc1169c62927926c0e436b6a448d5656))
17
+ * allow updating evmNetworks in real time ([#3877](https://github.com/dynamic-labs/DynamicAuth/issues/3877)) ([b4a2521](https://github.com/dynamic-labs/DynamicAuth/commit/b4a2521830b859a129d70bad2ae1213db075550d))
18
+ * editable copies as typed data ([#3784](https://github.com/dynamic-labs/DynamicAuth/issues/3784)) ([d6c6d74](https://github.com/dynamic-labs/DynamicAuth/commit/d6c6d74e60c9c9d459414c452fbd780d3f6bc2f9))
19
+ * email inputs now use email keyboard ([#3843](https://github.com/dynamic-labs/DynamicAuth/issues/3843)) ([76926e2](https://github.com/dynamic-labs/DynamicAuth/commit/76926e26b6a188d9d8e3bba2512340610e218e9f))
20
+ * hide unlink if disabled in dashboard ([#3825](https://github.com/dynamic-labs/DynamicAuth/issues/3825)) ([a0625e6](https://github.com/dynamic-labs/DynamicAuth/commit/a0625e6fd01aa5b57e6b8542efe04e280e0c6830))
21
+ * initialize smart wallet from verified credentials ([#3790](https://github.com/dynamic-labs/DynamicAuth/issues/3790)) ([1fc5890](https://github.com/dynamic-labs/DynamicAuth/commit/1fc5890f2e0ef458bfb59d38d536c41d183bc2a2))
22
+ * set smart wallet as primary when owner is an embedded wallet ([#3898](https://github.com/dynamic-labs/DynamicAuth/issues/3898)) ([ec40172](https://github.com/dynamic-labs/DynamicAuth/commit/ec401729f38d946d5431bbbb15c5c1cdc66acb73))
23
+ * support forced network validation via DynamicContext setting ([#3879](https://github.com/dynamic-labs/DynamicAuth/issues/3879)) ([a7993b9](https://github.com/dynamic-labs/DynamicAuth/commit/a7993b9b6bdd739bcb4e66e46d14e7f8623bed66))
24
+ * **transaction:** add sponsored gas transaction ([#3869](https://github.com/dynamic-labs/DynamicAuth/issues/3869)) ([ccceb24](https://github.com/dynamic-labs/DynamicAuth/commit/ccceb2421e029dc60e53912e404b574324d6772f))
25
+
26
+
27
+ ### Bug Fixes
28
+
29
+ * **account-abstraction:** set verified credentials before setting EOA to wallet connector ([#3941](https://github.com/dynamic-labs/DynamicAuth/issues/3941)) ([7475c46](https://github.com/dynamic-labs/DynamicAuth/commit/7475c465f5ddf9e27d0b05d23e58d9b474fa8fd4))
30
+ * add brand to zerodev object ([#3828](https://github.com/dynamic-labs/DynamicAuth/issues/3828)) ([81cb237](https://github.com/dynamic-labs/DynamicAuth/commit/81cb237df4def8e1c53b4ae145afafccf3b04683))
31
+ * add spriteId to zerodev ([#3829](https://github.com/dynamic-labs/DynamicAuth/issues/3829)) ([6b87c5c](https://github.com/dynamic-labs/DynamicAuth/commit/6b87c5c3d5869f6cd15a7534fb0260932845fbb1))
32
+ * allow metadata to be updated in updateUser hook ([#3928](https://github.com/dynamic-labs/DynamicAuth/issues/3928)) ([4f39fbd](https://github.com/dynamic-labs/DynamicAuth/commit/4f39fbd757b4e816dd60651252575c1f7e4d80aa))
33
+ * blocto flow connect only infinite recursion ([#3883](https://github.com/dynamic-labs/DynamicAuth/issues/3883)) ([6c6f5ba](https://github.com/dynamic-labs/DynamicAuth/commit/6c6f5ba5dc0657cc7ffdc82a4ea7935f65686088))
34
+ * clear project settings on page refresh ([#3826](https://github.com/dynamic-labs/DynamicAuth/issues/3826)) ([da5b8f0](https://github.com/dynamic-labs/DynamicAuth/commit/da5b8f0a99bf913ea11314954e5f08c2b019f50f))
35
+ * don't call computeConnectedStateForWallets too often to avoid infinite loops ([#3946](https://github.com/dynamic-labs/DynamicAuth/issues/3946)) ([de4e61a](https://github.com/dynamic-labs/DynamicAuth/commit/de4e61a3fcdc9c25cbe030c3c25cbc2c04929a93))
36
+ * don't call disconnect multiple times ([#3940](https://github.com/dynamic-labs/DynamicAuth/issues/3940)) ([3ea8623](https://github.com/dynamic-labs/DynamicAuth/commit/3ea86233d8d07dfb3c751a5fec45d5df84e9e143))
37
+ * **embedded wallet:** stop overriding primary wallet selection ([#3796](https://github.com/dynamic-labs/DynamicAuth/issues/3796)) ([75b81e7](https://github.com/dynamic-labs/DynamicAuth/commit/75b81e74d472ce8cc493646b441d2b4fe3962373))
38
+ * exodusevm wallet connect and mobile deep linking ([#3855](https://github.com/dynamic-labs/DynamicAuth/issues/3855)) ([cf0b3f0](https://github.com/dynamic-labs/DynamicAuth/commit/cf0b3f077f935eab32ce45947f62e73342d6c169))
39
+ * handle errors properly when engaging captcha ([#3896](https://github.com/dynamic-labs/DynamicAuth/issues/3896)) ([2596315](https://github.com/dynamic-labs/DynamicAuth/commit/25963153d699b26c6e04ea38b267446d3a3af13b))
40
+ * null safe check to window object ([#3882](https://github.com/dynamic-labs/DynamicAuth/issues/3882)) ([8856b5a](https://github.com/dynamic-labs/DynamicAuth/commit/8856b5ae40d43285eac667401387971b9e3f077d))
41
+ * pass correct wallet connector onLinkSuccess ([#3904](https://github.com/dynamic-labs/DynamicAuth/issues/3904)) ([79cca69](https://github.com/dynamic-labs/DynamicAuth/commit/79cca69ed53a5ef2c4e4d712ce0934e1a4c11459))
42
+ * remove extra captcha context provider instantiation causing unecessary rerenderings ([#3914](https://github.com/dynamic-labs/DynamicAuth/issues/3914)) ([14120a6](https://github.com/dynamic-labs/DynamicAuth/commit/14120a6ac0415f9a59608b376e88de6c729d4e5d))
43
+ * remove the coming soon label ([#3860](https://github.com/dynamic-labs/DynamicAuth/issues/3860)) ([1effb7f](https://github.com/dynamic-labs/DynamicAuth/commit/1effb7f124bda66aae3e8991b5386a1cee28fd99))
44
+ * Revert "chore: fix vite build ([#3849](https://github.com/dynamic-labs/DynamicAuth/issues/3849))" ([#3870](https://github.com/dynamic-labs/DynamicAuth/issues/3870)) ([13bc424](https://github.com/dynamic-labs/DynamicAuth/commit/13bc42483bcb9338babd46eae00988acada83578))
45
+ * **single-wallet:** prompt user to select correct wallet ([#3742](https://github.com/dynamic-labs/DynamicAuth/issues/3742)) ([ccfdd3c](https://github.com/dynamic-labs/DynamicAuth/commit/ccfdd3cc6a4ac7f3b1ea13be92e58982ecfb1c59))
46
+ * update walletconnect.json and walletconnect source schema ([#3854](https://github.com/dynamic-labs/DynamicAuth/issues/3854)) ([88ee546](https://github.com/dynamic-labs/DynamicAuth/commit/88ee5468db0130b19c6637a5632e64e0bb5197ba))
47
+ * useEmailProvider not checking for enabled providers properly ([7c16edc](https://github.com/dynamic-labs/DynamicAuth/commit/7c16edc3785ba10d69762b174f054b0d10b8a072))
48
+ * **wagmi:** ensure chain is defined on wallet client ([#3888](https://github.com/dynamic-labs/DynamicAuth/issues/3888)) ([0e145f6](https://github.com/dynamic-labs/DynamicAuth/commit/0e145f6ac42f55df7a020716d4ddc023554d72f9))
49
+
2
50
  ## [1.0.0-alpha.0](https://github.com/dynamic-labs/DynamicAuth/compare/v0.19.0...v1.0.0-alpha.0) (2023-10-31)
3
51
 
4
52
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/starknet",
3
- "version": "1.0.0-alpha.0",
3
+ "version": "1.0.0-alpha.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/dynamic-labs/DynamicAuth.git",
@@ -29,10 +29,12 @@
29
29
  "starknet": "^5.19.5",
30
30
  "get-starknet-core": "^3.2.0",
31
31
  "text-encoding": "0.7.0",
32
- "@dynamic-labs/sdk-api": "0.0.292",
33
- "@dynamic-labs/utils": "1.0.0-alpha.0",
34
- "@dynamic-labs/wallet-book": "1.0.0-alpha.0",
35
- "@dynamic-labs/wallet-connector-core": "1.0.0-alpha.0"
32
+ "@dynamic-labs/sdk-api": "0.0.307",
33
+ "@dynamic-labs/rpc-providers": "1.0.0-alpha.1",
34
+ "@dynamic-labs/types": "1.0.0-alpha.1",
35
+ "@dynamic-labs/utils": "1.0.0-alpha.1",
36
+ "@dynamic-labs/wallet-book": "1.0.0-alpha.1",
37
+ "@dynamic-labs/wallet-connector-core": "1.0.0-alpha.1"
36
38
  },
37
39
  "peerDependencies": {}
38
40
  }
package/src/constants.cjs CHANGED
@@ -3,12 +3,5 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const ETH_STARKNET_ADDRESS = '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7';
6
- const DEFAULT_STARKNET_TYPED_DATA_DOMAIN = {
7
- domain: {
8
- name: 'Dynamic Sample dApp',
9
- version: '0.0.1',
10
- },
11
- };
12
6
 
13
- exports.DEFAULT_STARKNET_TYPED_DATA_DOMAIN = DEFAULT_STARKNET_TYPED_DATA_DOMAIN;
14
7
  exports.ETH_STARKNET_ADDRESS = ETH_STARKNET_ADDRESS;
@@ -1,3 +1 @@
1
- import { TypedData } from 'starknet';
2
1
  export declare const ETH_STARKNET_ADDRESS = "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7";
3
- export declare const DEFAULT_STARKNET_TYPED_DATA_DOMAIN: Partial<TypedData>;
package/src/constants.js CHANGED
@@ -1,9 +1,3 @@
1
1
  const ETH_STARKNET_ADDRESS = '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7';
2
- const DEFAULT_STARKNET_TYPED_DATA_DOMAIN = {
3
- domain: {
4
- name: 'Dynamic Sample dApp',
5
- version: '0.0.1',
6
- },
7
- };
8
2
 
9
- export { DEFAULT_STARKNET_TYPED_DATA_DOMAIN, ETH_STARKNET_ADDRESS };
3
+ export { ETH_STARKNET_ADDRESS };
@@ -7,6 +7,7 @@ var getStarknetCore = require('get-starknet-core');
7
7
  var starknet = require('starknet');
8
8
  var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
9
9
  var utils = require('@dynamic-labs/utils');
10
+ var rpcProviders = require('@dynamic-labs/rpc-providers');
10
11
  var constants = require('./constants.cjs');
11
12
  var ethereumContractAbi = require('./ethereumContractAbi.cjs');
12
13
  var convertors = require('./utils/convertors.cjs');
@@ -16,6 +17,7 @@ const NETWORK_CHANGED_EVENT_LISTENER = 'networkChanged';
16
17
  const STARKNET_VERSION = 'v5';
17
18
  class StarknetWalletConnector extends walletConnectorCore.WalletConnectorBase {
18
19
  constructor(name, windowKey, opts) {
20
+ var _a;
19
21
  super(opts);
20
22
  this.connectedChain = 'STARK';
21
23
  this.supportedChains = ['STARK'];
@@ -23,14 +25,44 @@ class StarknetWalletConnector extends walletConnectorCore.WalletConnectorBase {
23
25
  this.name = name;
24
26
  this.windowKey = windowKey;
25
27
  this.starknetNetworks = opts.starknetNetworks;
28
+ this.chainRpcProviders = opts.chainRpcProviders;
29
+ (_a = this.chainRpcProviders) === null || _a === void 0 ? void 0 : _a.registerChainProviders(rpcProviders.ProviderChain.STARKNET, (config) => {
30
+ const rpcProviders = {};
31
+ if (config === null || config === void 0 ? void 0 : config.starknet) {
32
+ const networks = config.starknet;
33
+ rpcProviders.starknet = this.createProviderFromConfig(networks);
34
+ }
35
+ return rpcProviders.starknet;
36
+ });
37
+ }
38
+ createProviderFromConfig(networks) {
39
+ return networks.map((network) => {
40
+ var _a;
41
+ const rpcUrl = ((_a = network.privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a[0]) || network.rpcUrls[0];
42
+ const provider = new starknet.RpcProvider({ nodeUrl: rpcUrl });
43
+ return {
44
+ chainId: network.chainId.toString(),
45
+ chainName: network.name,
46
+ provider,
47
+ };
48
+ });
26
49
  }
27
50
  getPublicClient() {
28
- var _a, _b;
29
- const nodeUrl = (_b = (_a = this.starknetNetworks) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.rpcUrls[0];
30
- if (!nodeUrl) {
31
- throw new utils.DynamicError('RPC URL has not been found.');
32
- }
33
- return Promise.resolve(new starknet.RpcProvider({ nodeUrl }));
51
+ var _a;
52
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
53
+ if (this.starknetNetworks === undefined ||
54
+ this.starknetNetworks.length === 0)
55
+ return;
56
+ const configurations = {
57
+ cosmos: [],
58
+ evm: undefined,
59
+ solana: undefined,
60
+ starknet: this.starknetNetworks,
61
+ };
62
+ const chainId = yield this.getNetwork();
63
+ const starknetRpcProvider = (_a = this.chainRpcProviders) === null || _a === void 0 ? void 0 : _a.getStarknetRpcProviderByChainId(configurations, chainId);
64
+ return starknetRpcProvider === null || starknetRpcProvider === void 0 ? void 0 : starknetRpcProvider.provider;
65
+ });
34
66
  }
35
67
  /**
36
68
  * returns stakrnet wallet network id
@@ -3,6 +3,8 @@ import { ProviderInterface, constants, AccountInterface, RpcProvider } from 'sta
3
3
  import { Chain, WalletConnectorBase } from '@dynamic-labs/wallet-connector-core';
4
4
  import { NetworkConfiguration } from '@dynamic-labs/sdk-api';
5
5
  import { WalletBookSchema } from '@dynamic-labs/wallet-book';
6
+ import { ChainRpcProviders, StarknetRpcProvider } from '@dynamic-labs/rpc-providers';
7
+ import { GenericNetwork } from '@dynamic-labs/types';
6
8
  import { StarknetWalletKey } from './types';
7
9
  type AccountChangeEventHandler = (address: {
8
10
  toString(): string;
@@ -23,10 +25,12 @@ declare abstract class StarknetWalletConnector extends WalletConnectorBase {
23
25
  switchNetworkOnlyFromWallet: boolean;
24
26
  starknetNetworks: NetworkConfiguration[];
25
27
  constructor(name: string, windowKey: StarknetWalletKey, opts: {
28
+ chainRpcProviders: typeof ChainRpcProviders;
26
29
  starknetNetworks: NetworkConfiguration[];
27
30
  walletBook: WalletBookSchema;
28
31
  });
29
- getPublicClient(): Promise<RpcProvider>;
32
+ createProviderFromConfig(networks: GenericNetwork[]): StarknetRpcProvider[];
33
+ getPublicClient(): Promise<RpcProvider | undefined>;
30
34
  /**
31
35
  * returns stakrnet wallet network id
32
36
  */
@@ -3,6 +3,7 @@ import { getStarknet } from 'get-starknet-core';
3
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
+ import { ProviderChain } from '@dynamic-labs/rpc-providers';
6
7
  import { ETH_STARKNET_ADDRESS } from './constants.js';
7
8
  import ETH_CONTRACT_ABI from './ethereumContractAbi.js';
8
9
  import { formatTypedDataMessage } from './utils/convertors.js';
@@ -12,6 +13,7 @@ const NETWORK_CHANGED_EVENT_LISTENER = 'networkChanged';
12
13
  const STARKNET_VERSION = 'v5';
13
14
  class StarknetWalletConnector extends WalletConnectorBase {
14
15
  constructor(name, windowKey, opts) {
16
+ var _a;
15
17
  super(opts);
16
18
  this.connectedChain = 'STARK';
17
19
  this.supportedChains = ['STARK'];
@@ -19,14 +21,44 @@ class StarknetWalletConnector extends WalletConnectorBase {
19
21
  this.name = name;
20
22
  this.windowKey = windowKey;
21
23
  this.starknetNetworks = opts.starknetNetworks;
24
+ this.chainRpcProviders = opts.chainRpcProviders;
25
+ (_a = this.chainRpcProviders) === null || _a === void 0 ? void 0 : _a.registerChainProviders(ProviderChain.STARKNET, (config) => {
26
+ const rpcProviders = {};
27
+ if (config === null || config === void 0 ? void 0 : config.starknet) {
28
+ const networks = config.starknet;
29
+ rpcProviders.starknet = this.createProviderFromConfig(networks);
30
+ }
31
+ return rpcProviders.starknet;
32
+ });
33
+ }
34
+ createProviderFromConfig(networks) {
35
+ return networks.map((network) => {
36
+ var _a;
37
+ const rpcUrl = ((_a = network.privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a[0]) || network.rpcUrls[0];
38
+ const provider = new RpcProvider({ nodeUrl: rpcUrl });
39
+ return {
40
+ chainId: network.chainId.toString(),
41
+ chainName: network.name,
42
+ provider,
43
+ };
44
+ });
22
45
  }
23
46
  getPublicClient() {
24
- var _a, _b;
25
- const nodeUrl = (_b = (_a = this.starknetNetworks) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.rpcUrls[0];
26
- if (!nodeUrl) {
27
- throw new DynamicError('RPC URL has not been found.');
28
- }
29
- return Promise.resolve(new RpcProvider({ nodeUrl }));
47
+ var _a;
48
+ return __awaiter(this, void 0, void 0, function* () {
49
+ if (this.starknetNetworks === undefined ||
50
+ this.starknetNetworks.length === 0)
51
+ return;
52
+ const configurations = {
53
+ cosmos: [],
54
+ evm: undefined,
55
+ solana: undefined,
56
+ starknet: this.starknetNetworks,
57
+ };
58
+ const chainId = yield this.getNetwork();
59
+ const starknetRpcProvider = (_a = this.chainRpcProviders) === null || _a === void 0 ? void 0 : _a.getStarknetRpcProviderByChainId(configurations, chainId);
60
+ return starknetRpcProvider === null || starknetRpcProvider === void 0 ? void 0 : starknetRpcProvider.provider;
61
+ });
30
62
  }
31
63
  /**
32
64
  * returns stakrnet wallet network id
@@ -3,9 +3,10 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var starknet = require('starknet');
6
- var constants = require('../constants.cjs');
7
6
 
8
- const defaultTypedData = Object.assign(Object.assign({}, constants.DEFAULT_STARKNET_TYPED_DATA_DOMAIN), { primaryType: 'Message', types: {
7
+ const defaultTypedData = {
8
+ primaryType: 'Message',
9
+ types: {
9
10
  Message: [
10
11
  {
11
12
  name: 'message',
@@ -26,12 +27,18 @@ const defaultTypedData = Object.assign(Object.assign({}, constants.DEFAULT_STARK
26
27
  type: 'felt',
27
28
  },
28
29
  ],
29
- } });
30
+ },
31
+ };
30
32
  const formatTypedDataMessage = (inputMessage, chainId = starknet.constants.NetworkName.SN_MAIN) => {
33
+ const { nonce, domain } = JSON.parse(inputMessage);
31
34
  const message = {
32
- message: inputMessage.substring(0, 31),
35
+ message: nonce.substring(0, 31),
33
36
  };
34
- return Object.assign(Object.assign({}, defaultTypedData), { domain: Object.assign(Object.assign({}, defaultTypedData.domain), { chainId }), message });
37
+ return Object.assign(Object.assign({}, defaultTypedData), { domain: {
38
+ chainId,
39
+ name: domain,
40
+ version: '0.0.1',
41
+ }, message });
35
42
  };
36
43
 
37
44
  exports.formatTypedDataMessage = formatTypedDataMessage;
@@ -1,7 +1,8 @@
1
1
  import { constants } from 'starknet';
2
- import { DEFAULT_STARKNET_TYPED_DATA_DOMAIN } from '../constants.js';
3
2
 
4
- const defaultTypedData = Object.assign(Object.assign({}, DEFAULT_STARKNET_TYPED_DATA_DOMAIN), { primaryType: 'Message', types: {
3
+ const defaultTypedData = {
4
+ primaryType: 'Message',
5
+ types: {
5
6
  Message: [
6
7
  {
7
8
  name: 'message',
@@ -22,12 +23,18 @@ const defaultTypedData = Object.assign(Object.assign({}, DEFAULT_STARKNET_TYPED_
22
23
  type: 'felt',
23
24
  },
24
25
  ],
25
- } });
26
+ },
27
+ };
26
28
  const formatTypedDataMessage = (inputMessage, chainId = constants.NetworkName.SN_MAIN) => {
29
+ const { nonce, domain } = JSON.parse(inputMessage);
27
30
  const message = {
28
- message: inputMessage.substring(0, 31),
31
+ message: nonce.substring(0, 31),
29
32
  };
30
- return Object.assign(Object.assign({}, defaultTypedData), { domain: Object.assign(Object.assign({}, defaultTypedData.domain), { chainId }), message });
33
+ return Object.assign(Object.assign({}, defaultTypedData), { domain: {
34
+ chainId,
35
+ name: domain,
36
+ version: '0.0.1',
37
+ }, message });
31
38
  };
32
39
 
33
40
  export { formatTypedDataMessage };