@metamask-previews/controller-utils 11.2.0-preview-cf09c0a → 11.2.0-preview-09a2ffd5
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/dist/chunk-DBJSLKNR.js +9 -0
- package/dist/chunk-DBJSLKNR.js.map +1 -0
- package/dist/chunk-HL2W4XJY.js +147 -0
- package/dist/chunk-HL2W4XJY.js.map +1 -0
- package/dist/chunk-IPGJBD5N.mjs +306 -0
- package/dist/chunk-IPGJBD5N.mjs.map +1 -0
- package/dist/chunk-M6G3ISXG.js +86 -0
- package/dist/chunk-M6G3ISXG.js.map +1 -0
- package/dist/chunk-OA7K6K6E.js +85 -0
- package/dist/chunk-OA7K6K6E.js.map +1 -0
- package/dist/chunk-QZDAFEVW.mjs +147 -0
- package/dist/chunk-QZDAFEVW.mjs.map +1 -0
- package/dist/chunk-RZFCNKW4.mjs +9 -0
- package/dist/chunk-RZFCNKW4.mjs.map +1 -0
- package/dist/chunk-UQHQI6IV.mjs +85 -0
- package/dist/chunk-UQHQI6IV.mjs.map +1 -0
- package/dist/chunk-VDEIYYE4.mjs +86 -0
- package/dist/chunk-VDEIYYE4.mjs.map +1 -0
- package/dist/chunk-YIBQE73N.js +306 -0
- package/dist/chunk-YIBQE73N.js.map +1 -0
- package/dist/constants.js +56 -0
- package/dist/constants.js.map +1 -0
- package/dist/constants.mjs +54 -133
- package/dist/constants.mjs.map +1 -1
- package/dist/index.js +138 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +137 -4
- package/dist/index.mjs.map +1 -1
- package/dist/logger.js +9 -0
- package/dist/logger.js.map +1 -0
- package/dist/logger.mjs +8 -3
- package/dist/logger.mjs.map +1 -1
- package/dist/siwe.js +12 -0
- package/dist/siwe.js.map +1 -0
- package/dist/siwe.mjs +10 -120
- package/dist/siwe.mjs.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/{constants.d.mts → types/constants.d.ts} +2 -2
- package/dist/types/constants.d.ts.map +1 -0
- package/dist/{index.d.cts → types/index.d.ts} +6 -6
- package/dist/types/index.d.ts.map +1 -0
- package/dist/{logger.d.cts → types/logger.d.ts} +2 -2
- package/dist/types/logger.d.ts.map +1 -0
- package/dist/{siwe.d.mts → types/siwe.d.ts} +2 -2
- package/dist/types/siwe.d.ts.map +1 -0
- package/dist/{types.d.cts → types/types.d.ts} +1 -29
- package/dist/types/types.d.ts.map +1 -0
- package/dist/{util.d.cts → types/util.d.ts} +4 -4
- package/dist/types/util.d.ts.map +1 -0
- package/dist/types.js +23 -0
- package/dist/types.js.map +1 -0
- package/dist/types.mjs +21 -100
- package/dist/types.mjs.map +1 -1
- package/dist/util.js +61 -0
- package/dist/util.js.map +1 -0
- package/dist/util.mjs +59 -488
- package/dist/util.mjs.map +1 -1
- package/package.json +7 -12
- package/dist/constants.cjs +0 -138
- package/dist/constants.cjs.map +0 -1
- package/dist/constants.d.cts +0 -117
- package/dist/constants.d.cts.map +0 -1
- package/dist/constants.d.mts.map +0 -1
- package/dist/index.cjs +0 -48
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts +0 -6
- package/dist/index.d.mts.map +0 -1
- package/dist/logger.cjs +0 -7
- package/dist/logger.cjs.map +0 -1
- package/dist/logger.d.cts.map +0 -1
- package/dist/logger.d.mts +0 -5
- package/dist/logger.d.mts.map +0 -1
- package/dist/siwe.cjs +0 -128
- package/dist/siwe.cjs.map +0 -1
- package/dist/siwe.d.cts +0 -68
- package/dist/siwe.d.cts.map +0 -1
- package/dist/siwe.d.mts.map +0 -1
- package/dist/types.cjs +0 -107
- package/dist/types.cjs.map +0 -1
- package/dist/types.d.cts.map +0 -1
- package/dist/types.d.mts +0 -132
- package/dist/types.d.mts.map +0 -1
- package/dist/util.cjs +0 -512
- package/dist/util.cjs.map +0 -1
- package/dist/util.d.cts.map +0 -1
- package/dist/util.d.mts +0 -243
- package/dist/util.d.mts.map +0 -1
package/dist/constants.cjs
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CHAIN_ID_TO_ETHERS_NETWORK_NAME_MAP = exports.ApprovalType = exports.ORIGIN_METAMASK = exports.NFT_API_TIMEOUT = exports.NFT_API_VERSION = exports.NFT_API_BASE_URL = exports.OPENSEA_PROXY_URL = exports.BUILT_IN_NETWORKS = exports.TESTNET_TICKER_SYMBOLS = exports.ASSET_TYPES = exports.GWEI = exports.ERC1155_TOKEN_RECEIVER_INTERFACE_ID = exports.ERC1155_METADATA_URI_INTERFACE_ID = exports.ERC1155_INTERFACE_ID = exports.ERC721_ENUMERABLE_INTERFACE_ID = exports.ERC721_METADATA_INTERFACE_ID = exports.ERC721_INTERFACE_ID = exports.ERC20 = exports.ERC1155 = exports.ERC721 = exports.MAX_SAFE_CHAIN_ID = exports.GANACHE_CHAIN_ID = exports.IPFS_DEFAULT_GATEWAY_URL = exports.FALL_BACK_VS_CURRENCY = exports.RPC = void 0;
|
|
4
|
-
const types_1 = require("./types.cjs");
|
|
5
|
-
exports.RPC = 'rpc';
|
|
6
|
-
exports.FALL_BACK_VS_CURRENCY = 'ETH';
|
|
7
|
-
exports.IPFS_DEFAULT_GATEWAY_URL = 'https://cloudflare-ipfs.com/ipfs/';
|
|
8
|
-
// NETWORKS ID
|
|
9
|
-
// `toHex` not invoked to avoid cyclic dependency
|
|
10
|
-
exports.GANACHE_CHAIN_ID = '0x539'; // toHex(1337)
|
|
11
|
-
/**
|
|
12
|
-
* The largest possible chain ID we can handle.
|
|
13
|
-
* Explanation: https://gist.github.com/rekmarks/a47bd5f2525936c4b8eee31a16345553
|
|
14
|
-
*/
|
|
15
|
-
exports.MAX_SAFE_CHAIN_ID = 4503599627370476;
|
|
16
|
-
// TOKEN STANDARDS
|
|
17
|
-
exports.ERC721 = 'ERC721';
|
|
18
|
-
exports.ERC1155 = 'ERC1155';
|
|
19
|
-
exports.ERC20 = 'ERC20';
|
|
20
|
-
// TOKEN INTERFACE IDS
|
|
21
|
-
exports.ERC721_INTERFACE_ID = '0x80ac58cd';
|
|
22
|
-
exports.ERC721_METADATA_INTERFACE_ID = '0x5b5e139f';
|
|
23
|
-
exports.ERC721_ENUMERABLE_INTERFACE_ID = '0x780e9d63';
|
|
24
|
-
exports.ERC1155_INTERFACE_ID = '0xd9b67a26';
|
|
25
|
-
exports.ERC1155_METADATA_URI_INTERFACE_ID = '0x0e89341c';
|
|
26
|
-
exports.ERC1155_TOKEN_RECEIVER_INTERFACE_ID = '0x4e2312e0';
|
|
27
|
-
// UNITS
|
|
28
|
-
exports.GWEI = 'gwei';
|
|
29
|
-
// ASSET TYPES
|
|
30
|
-
exports.ASSET_TYPES = {
|
|
31
|
-
NATIVE: 'NATIVE',
|
|
32
|
-
TOKEN: 'TOKEN',
|
|
33
|
-
NFT: 'NFT',
|
|
34
|
-
UNKNOWN: 'UNKNOWN',
|
|
35
|
-
};
|
|
36
|
-
// TICKER SYMBOLS
|
|
37
|
-
exports.TESTNET_TICKER_SYMBOLS = {
|
|
38
|
-
GOERLI: 'GoerliETH',
|
|
39
|
-
SEPOLIA: 'SepoliaETH',
|
|
40
|
-
LINEA_GOERLI: 'LineaETH',
|
|
41
|
-
LINEA_SEPOLIA: 'LineaETH',
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* Map of all build-in Infura networks to their network, ticker and chain IDs.
|
|
45
|
-
*/
|
|
46
|
-
exports.BUILT_IN_NETWORKS = {
|
|
47
|
-
[types_1.NetworkType.goerli]: {
|
|
48
|
-
chainId: types_1.ChainId.goerli,
|
|
49
|
-
ticker: types_1.NetworksTicker.goerli,
|
|
50
|
-
rpcPrefs: {
|
|
51
|
-
blockExplorerUrl: `https://${types_1.NetworkType.goerli}.etherscan.io`,
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
[types_1.NetworkType.sepolia]: {
|
|
55
|
-
chainId: types_1.ChainId.sepolia,
|
|
56
|
-
ticker: types_1.NetworksTicker.sepolia,
|
|
57
|
-
rpcPrefs: {
|
|
58
|
-
blockExplorerUrl: `https://${types_1.NetworkType.sepolia}.etherscan.io`,
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
[types_1.NetworkType.mainnet]: {
|
|
62
|
-
chainId: types_1.ChainId.mainnet,
|
|
63
|
-
ticker: types_1.NetworksTicker.mainnet,
|
|
64
|
-
rpcPrefs: {
|
|
65
|
-
blockExplorerUrl: 'https://etherscan.io',
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
[types_1.NetworkType['linea-goerli']]: {
|
|
69
|
-
chainId: types_1.ChainId['linea-goerli'],
|
|
70
|
-
ticker: types_1.NetworksTicker['linea-goerli'],
|
|
71
|
-
rpcPrefs: {
|
|
72
|
-
blockExplorerUrl: 'https://goerli.lineascan.build',
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
[types_1.NetworkType['linea-sepolia']]: {
|
|
76
|
-
chainId: types_1.ChainId['linea-sepolia'],
|
|
77
|
-
ticker: types_1.NetworksTicker['linea-sepolia'],
|
|
78
|
-
rpcPrefs: {
|
|
79
|
-
blockExplorerUrl: 'https://sepolia.lineascan.build',
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
[types_1.NetworkType['linea-mainnet']]: {
|
|
83
|
-
chainId: types_1.ChainId['linea-mainnet'],
|
|
84
|
-
ticker: types_1.NetworksTicker['linea-mainnet'],
|
|
85
|
-
rpcPrefs: {
|
|
86
|
-
blockExplorerUrl: 'https://lineascan.build',
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
[types_1.NetworkType.rpc]: {
|
|
90
|
-
chainId: undefined,
|
|
91
|
-
blockExplorerUrl: undefined,
|
|
92
|
-
ticker: undefined,
|
|
93
|
-
rpcPrefs: undefined,
|
|
94
|
-
},
|
|
95
|
-
};
|
|
96
|
-
// APIs
|
|
97
|
-
exports.OPENSEA_PROXY_URL = 'https://proxy.api.cx.metamask.io/opensea/v1/api/v2';
|
|
98
|
-
exports.NFT_API_BASE_URL = 'https://nft.api.cx.metamask.io';
|
|
99
|
-
exports.NFT_API_VERSION = '1';
|
|
100
|
-
exports.NFT_API_TIMEOUT = 15000;
|
|
101
|
-
// Default origin for controllers
|
|
102
|
-
exports.ORIGIN_METAMASK = 'metamask';
|
|
103
|
-
/**
|
|
104
|
-
* Approval request types for various operations.
|
|
105
|
-
* These types are used by different controllers to create and manage
|
|
106
|
-
* approval requests consistently.
|
|
107
|
-
*/
|
|
108
|
-
var ApprovalType;
|
|
109
|
-
(function (ApprovalType) {
|
|
110
|
-
ApprovalType["AddEthereumChain"] = "wallet_addEthereumChain";
|
|
111
|
-
ApprovalType["ConnectAccounts"] = "connect_accounts";
|
|
112
|
-
ApprovalType["EthDecrypt"] = "eth_decrypt";
|
|
113
|
-
ApprovalType["EthGetEncryptionPublicKey"] = "eth_getEncryptionPublicKey";
|
|
114
|
-
ApprovalType["EthSignTypedData"] = "eth_signTypedData";
|
|
115
|
-
ApprovalType["PersonalSign"] = "personal_sign";
|
|
116
|
-
ApprovalType["ResultError"] = "result_error";
|
|
117
|
-
ApprovalType["ResultSuccess"] = "result_success";
|
|
118
|
-
ApprovalType["SnapDialogAlert"] = "snap_dialog:alert";
|
|
119
|
-
ApprovalType["SnapDialogConfirmation"] = "snap_dialog:confirmation";
|
|
120
|
-
ApprovalType["SnapDialogPrompt"] = "snap_dialog:prompt";
|
|
121
|
-
ApprovalType["SnapDialogDefault"] = "snap_dialog";
|
|
122
|
-
ApprovalType["SwitchEthereumChain"] = "wallet_switchEthereumChain";
|
|
123
|
-
ApprovalType["Transaction"] = "transaction";
|
|
124
|
-
ApprovalType["Unlock"] = "unlock";
|
|
125
|
-
ApprovalType["WalletConnect"] = "wallet_connect";
|
|
126
|
-
ApprovalType["WalletRequestPermissions"] = "wallet_requestPermissions";
|
|
127
|
-
ApprovalType["WatchAsset"] = "wallet_watchAsset";
|
|
128
|
-
})(ApprovalType || (exports.ApprovalType = ApprovalType = {}));
|
|
129
|
-
exports.CHAIN_ID_TO_ETHERS_NETWORK_NAME_MAP = {
|
|
130
|
-
[types_1.ChainId.goerli]: types_1.BuiltInNetworkName.Goerli,
|
|
131
|
-
[types_1.ChainId.sepolia]: types_1.BuiltInNetworkName.Sepolia,
|
|
132
|
-
[types_1.ChainId.mainnet]: types_1.BuiltInNetworkName.Mainnet,
|
|
133
|
-
[types_1.ChainId['linea-goerli']]: types_1.BuiltInNetworkName.LineaGoerli,
|
|
134
|
-
[types_1.ChainId['linea-sepolia']]: types_1.BuiltInNetworkName.LineaSepolia,
|
|
135
|
-
[types_1.ChainId['linea-mainnet']]: types_1.BuiltInNetworkName.LineaMainnet,
|
|
136
|
-
[types_1.ChainId.aurora]: types_1.BuiltInNetworkName.Aurora,
|
|
137
|
-
};
|
|
138
|
-
//# sourceMappingURL=constants.cjs.map
|
package/dist/constants.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.cjs","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAA,uCAKiB;AAEJ,QAAA,GAAG,GAAG,KAAK,CAAC;AACZ,QAAA,qBAAqB,GAAG,KAAK,CAAC;AAC9B,QAAA,wBAAwB,GAAG,mCAAmC,CAAC;AAE5E,cAAc;AACd,iDAAiD;AACpC,QAAA,gBAAgB,GAAG,OAAO,CAAC,CAAC,cAAc;AACvD;;;GAGG;AACU,QAAA,iBAAiB,GAAG,gBAAgB,CAAC;AAElD,kBAAkB;AACL,QAAA,MAAM,GAAG,QAAQ,CAAC;AAClB,QAAA,OAAO,GAAG,SAAS,CAAC;AACpB,QAAA,KAAK,GAAG,OAAO,CAAC;AAE7B,sBAAsB;AACT,QAAA,mBAAmB,GAAG,YAAY,CAAC;AACnC,QAAA,4BAA4B,GAAG,YAAY,CAAC;AAC5C,QAAA,8BAA8B,GAAG,YAAY,CAAC;AAC9C,QAAA,oBAAoB,GAAG,YAAY,CA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mBvB;AAEY,QAAA,mCAAmC,GAG5C;IACF,CAAC,eAAO,CAAC,MAAM,CAAC,EAAE,0BAAkB,CAAC,MAAM;IAC3C,CAAC,eAAO,CAAC,OAAO,CAAC,EAAE,0BAAkB,CAAC,OAAO;IAC7C,CAAC,eAAO,CAAC,OAAO,CAAC,EAAE,0BAAkB,CAAC,OAAO;IAC7C,CAAC,eAAO,CAAC,cAAc,CAAC,CAAC,EAAE,0BAAkB,CAAC,WAAW;IACzD,CAAC,eAAO,CAAC,eAAe,CAAC,CAAC,EAAE,0BAAkB,CAAC,YAAY;IAC3D,CAAC,eAAO,CAAC,eAAe,CAAC,CAAC,EAAE,0BAAkB,CAAC,YAAY;IAC3D,CAAC,eAAO,CAAC,MAAM,CAAC,EAAE,0BAAkB,CAAC,MAAM;CAC5C,CAAC","sourcesContent":["import {\n NetworkType,\n NetworksTicker,\n ChainId,\n BuiltInNetworkName,\n} from './types';\n\nexport const RPC = 'rpc';\nexport const FALL_BACK_VS_CURRENCY = 'ETH';\nexport const IPFS_DEFAULT_GATEWAY_URL = 'https://cloudflare-ipfs.com/ipfs/';\n\n// NETWORKS ID\n// `toHex` not invoked to avoid cyclic dependency\nexport const GANACHE_CHAIN_ID = '0x539'; // toHex(1337)\n/**\n * The largest possible chain ID we can handle.\n * Explanation: https://gist.github.com/rekmarks/a47bd5f2525936c4b8eee31a16345553\n */\nexport const MAX_SAFE_CHAIN_ID = 4503599627370476;\n\n// TOKEN STANDARDS\nexport const ERC721 = 'ERC721';\nexport const ERC1155 = 'ERC1155';\nexport const ERC20 = 'ERC20';\n\n// TOKEN INTERFACE IDS\nexport const ERC721_INTERFACE_ID = '0x80ac58cd';\nexport const ERC721_METADATA_INTERFACE_ID = '0x5b5e139f';\nexport const ERC721_ENUMERABLE_INTERFACE_ID = '0x780e9d63';\nexport const ERC1155_INTERFACE_ID = '0xd9b67a26';\nexport const ERC1155_METADATA_URI_INTERFACE_ID = '0x0e89341c';\nexport const ERC1155_TOKEN_RECEIVER_INTERFACE_ID = '0x4e2312e0';\n\n// UNITS\nexport const GWEI = 'gwei';\n\n// ASSET TYPES\nexport const ASSET_TYPES = {\n NATIVE: 'NATIVE',\n TOKEN: 'TOKEN',\n NFT: 'NFT',\n UNKNOWN: 'UNKNOWN',\n};\n\n// TICKER SYMBOLS\nexport const TESTNET_TICKER_SYMBOLS = {\n GOERLI: 'GoerliETH',\n SEPOLIA: 'SepoliaETH',\n LINEA_GOERLI: 'LineaETH',\n LINEA_SEPOLIA: 'LineaETH',\n};\n\n/**\n * Map of all build-in Infura networks to their network, ticker and chain IDs.\n */\nexport const BUILT_IN_NETWORKS = {\n [NetworkType.goerli]: {\n chainId: ChainId.goerli,\n ticker: NetworksTicker.goerli,\n rpcPrefs: {\n blockExplorerUrl: `https://${NetworkType.goerli}.etherscan.io`,\n },\n },\n [NetworkType.sepolia]: {\n chainId: ChainId.sepolia,\n ticker: NetworksTicker.sepolia,\n rpcPrefs: {\n blockExplorerUrl: `https://${NetworkType.sepolia}.etherscan.io`,\n },\n },\n [NetworkType.mainnet]: {\n chainId: ChainId.mainnet,\n ticker: NetworksTicker.mainnet,\n rpcPrefs: {\n blockExplorerUrl: 'https://etherscan.io',\n },\n },\n [NetworkType['linea-goerli']]: {\n chainId: ChainId['linea-goerli'],\n ticker: NetworksTicker['linea-goerli'],\n rpcPrefs: {\n blockExplorerUrl: 'https://goerli.lineascan.build',\n },\n },\n [NetworkType['linea-sepolia']]: {\n chainId: ChainId['linea-sepolia'],\n ticker: NetworksTicker['linea-sepolia'],\n rpcPrefs: {\n blockExplorerUrl: 'https://sepolia.lineascan.build',\n },\n },\n [NetworkType['linea-mainnet']]: {\n chainId: ChainId['linea-mainnet'],\n ticker: NetworksTicker['linea-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: 'https://lineascan.build',\n },\n },\n [NetworkType.rpc]: {\n chainId: undefined,\n blockExplorerUrl: undefined,\n ticker: undefined,\n rpcPrefs: undefined,\n },\n} as const;\n\n// APIs\nexport const OPENSEA_PROXY_URL =\n 'https://proxy.api.cx.metamask.io/opensea/v1/api/v2';\n\nexport const NFT_API_BASE_URL = 'https://nft.api.cx.metamask.io';\n\nexport const NFT_API_VERSION = '1';\n\nexport const NFT_API_TIMEOUT = 15000;\n\n// Default origin for controllers\nexport const ORIGIN_METAMASK = 'metamask';\n\n/**\n * Approval request types for various operations.\n * These types are used by different controllers to create and manage\n * approval requests consistently.\n */\nexport enum ApprovalType {\n AddEthereumChain = 'wallet_addEthereumChain',\n ConnectAccounts = 'connect_accounts',\n EthDecrypt = 'eth_decrypt',\n EthGetEncryptionPublicKey = 'eth_getEncryptionPublicKey',\n EthSignTypedData = 'eth_signTypedData',\n PersonalSign = 'personal_sign',\n ResultError = 'result_error',\n ResultSuccess = 'result_success',\n SnapDialogAlert = 'snap_dialog:alert',\n SnapDialogConfirmation = 'snap_dialog:confirmation',\n SnapDialogPrompt = 'snap_dialog:prompt',\n SnapDialogDefault = 'snap_dialog',\n SwitchEthereumChain = 'wallet_switchEthereumChain',\n Transaction = 'transaction',\n Unlock = 'unlock',\n WalletConnect = 'wallet_connect',\n WalletRequestPermissions = 'wallet_requestPermissions',\n WatchAsset = 'wallet_watchAsset',\n}\n\nexport const CHAIN_ID_TO_ETHERS_NETWORK_NAME_MAP: Record<\n ChainId,\n BuiltInNetworkName\n> = {\n [ChainId.goerli]: BuiltInNetworkName.Goerli,\n [ChainId.sepolia]: BuiltInNetworkName.Sepolia,\n [ChainId.mainnet]: BuiltInNetworkName.Mainnet,\n [ChainId['linea-goerli']]: BuiltInNetworkName.LineaGoerli,\n [ChainId['linea-sepolia']]: BuiltInNetworkName.LineaSepolia,\n [ChainId['linea-mainnet']]: BuiltInNetworkName.LineaMainnet,\n [ChainId.aurora]: BuiltInNetworkName.Aurora,\n};\n"]}
|
package/dist/constants.d.cts
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { NetworksTicker, ChainId, BuiltInNetworkName } from "./types.cjs";
|
|
2
|
-
export declare const RPC = "rpc";
|
|
3
|
-
export declare const FALL_BACK_VS_CURRENCY = "ETH";
|
|
4
|
-
export declare const IPFS_DEFAULT_GATEWAY_URL = "https://cloudflare-ipfs.com/ipfs/";
|
|
5
|
-
export declare const GANACHE_CHAIN_ID = "0x539";
|
|
6
|
-
/**
|
|
7
|
-
* The largest possible chain ID we can handle.
|
|
8
|
-
* Explanation: https://gist.github.com/rekmarks/a47bd5f2525936c4b8eee31a16345553
|
|
9
|
-
*/
|
|
10
|
-
export declare const MAX_SAFE_CHAIN_ID = 4503599627370476;
|
|
11
|
-
export declare const ERC721 = "ERC721";
|
|
12
|
-
export declare const ERC1155 = "ERC1155";
|
|
13
|
-
export declare const ERC20 = "ERC20";
|
|
14
|
-
export declare const ERC721_INTERFACE_ID = "0x80ac58cd";
|
|
15
|
-
export declare const ERC721_METADATA_INTERFACE_ID = "0x5b5e139f";
|
|
16
|
-
export declare const ERC721_ENUMERABLE_INTERFACE_ID = "0x780e9d63";
|
|
17
|
-
export declare const ERC1155_INTERFACE_ID = "0xd9b67a26";
|
|
18
|
-
export declare const ERC1155_METADATA_URI_INTERFACE_ID = "0x0e89341c";
|
|
19
|
-
export declare const ERC1155_TOKEN_RECEIVER_INTERFACE_ID = "0x4e2312e0";
|
|
20
|
-
export declare const GWEI = "gwei";
|
|
21
|
-
export declare const ASSET_TYPES: {
|
|
22
|
-
NATIVE: string;
|
|
23
|
-
TOKEN: string;
|
|
24
|
-
NFT: string;
|
|
25
|
-
UNKNOWN: string;
|
|
26
|
-
};
|
|
27
|
-
export declare const TESTNET_TICKER_SYMBOLS: {
|
|
28
|
-
GOERLI: string;
|
|
29
|
-
SEPOLIA: string;
|
|
30
|
-
LINEA_GOERLI: string;
|
|
31
|
-
LINEA_SEPOLIA: string;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* Map of all build-in Infura networks to their network, ticker and chain IDs.
|
|
35
|
-
*/
|
|
36
|
-
export declare const BUILT_IN_NETWORKS: {
|
|
37
|
-
readonly goerli: {
|
|
38
|
-
readonly chainId: "0x5";
|
|
39
|
-
readonly ticker: NetworksTicker.goerli;
|
|
40
|
-
readonly rpcPrefs: {
|
|
41
|
-
readonly blockExplorerUrl: "https://goerli.etherscan.io";
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
readonly sepolia: {
|
|
45
|
-
readonly chainId: "0xaa36a7";
|
|
46
|
-
readonly ticker: NetworksTicker.sepolia;
|
|
47
|
-
readonly rpcPrefs: {
|
|
48
|
-
readonly blockExplorerUrl: "https://sepolia.etherscan.io";
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
readonly mainnet: {
|
|
52
|
-
readonly chainId: "0x1";
|
|
53
|
-
readonly ticker: NetworksTicker.mainnet;
|
|
54
|
-
readonly rpcPrefs: {
|
|
55
|
-
readonly blockExplorerUrl: "https://etherscan.io";
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
readonly "linea-goerli": {
|
|
59
|
-
readonly chainId: "0xe704";
|
|
60
|
-
readonly ticker: (typeof NetworksTicker)["linea-goerli"];
|
|
61
|
-
readonly rpcPrefs: {
|
|
62
|
-
readonly blockExplorerUrl: "https://goerli.lineascan.build";
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
readonly "linea-sepolia": {
|
|
66
|
-
readonly chainId: "0xe705";
|
|
67
|
-
readonly ticker: (typeof NetworksTicker)["linea-goerli"];
|
|
68
|
-
readonly rpcPrefs: {
|
|
69
|
-
readonly blockExplorerUrl: "https://sepolia.lineascan.build";
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
readonly "linea-mainnet": {
|
|
73
|
-
readonly chainId: "0xe708";
|
|
74
|
-
readonly ticker: NetworksTicker.mainnet;
|
|
75
|
-
readonly rpcPrefs: {
|
|
76
|
-
readonly blockExplorerUrl: "https://lineascan.build";
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
readonly rpc: {
|
|
80
|
-
readonly chainId: undefined;
|
|
81
|
-
readonly blockExplorerUrl: undefined;
|
|
82
|
-
readonly ticker: undefined;
|
|
83
|
-
readonly rpcPrefs: undefined;
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
export declare const OPENSEA_PROXY_URL = "https://proxy.api.cx.metamask.io/opensea/v1/api/v2";
|
|
87
|
-
export declare const NFT_API_BASE_URL = "https://nft.api.cx.metamask.io";
|
|
88
|
-
export declare const NFT_API_VERSION = "1";
|
|
89
|
-
export declare const NFT_API_TIMEOUT = 15000;
|
|
90
|
-
export declare const ORIGIN_METAMASK = "metamask";
|
|
91
|
-
/**
|
|
92
|
-
* Approval request types for various operations.
|
|
93
|
-
* These types are used by different controllers to create and manage
|
|
94
|
-
* approval requests consistently.
|
|
95
|
-
*/
|
|
96
|
-
export declare enum ApprovalType {
|
|
97
|
-
AddEthereumChain = "wallet_addEthereumChain",
|
|
98
|
-
ConnectAccounts = "connect_accounts",
|
|
99
|
-
EthDecrypt = "eth_decrypt",
|
|
100
|
-
EthGetEncryptionPublicKey = "eth_getEncryptionPublicKey",
|
|
101
|
-
EthSignTypedData = "eth_signTypedData",
|
|
102
|
-
PersonalSign = "personal_sign",
|
|
103
|
-
ResultError = "result_error",
|
|
104
|
-
ResultSuccess = "result_success",
|
|
105
|
-
SnapDialogAlert = "snap_dialog:alert",
|
|
106
|
-
SnapDialogConfirmation = "snap_dialog:confirmation",
|
|
107
|
-
SnapDialogPrompt = "snap_dialog:prompt",
|
|
108
|
-
SnapDialogDefault = "snap_dialog",
|
|
109
|
-
SwitchEthereumChain = "wallet_switchEthereumChain",
|
|
110
|
-
Transaction = "transaction",
|
|
111
|
-
Unlock = "unlock",
|
|
112
|
-
WalletConnect = "wallet_connect",
|
|
113
|
-
WalletRequestPermissions = "wallet_requestPermissions",
|
|
114
|
-
WatchAsset = "wallet_watchAsset"
|
|
115
|
-
}
|
|
116
|
-
export declare const CHAIN_ID_TO_ETHERS_NETWORK_NAME_MAP: Record<ChainId, BuiltInNetworkName>;
|
|
117
|
-
//# sourceMappingURL=constants.d.cts.map
|
package/dist/constants.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.cts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EACd,OAAO,EACP,kBAAkB,EACnB,oBAAgB;AAEjB,eAAO,MAAM,GAAG,QAAQ,CAAC;AACzB,eAAO,MAAM,qBAAqB,QAAQ,CAAC;AAC3C,eAAO,MAAM,wBAAwB,sCAAsC,CAAC;AAI5E,eAAO,MAAM,gBAAgB,UAAU,CAAC;AACxC;;;GAGG;AACH,eAAO,MAAM,iBAAiB,mBAAmB,CAAC;AAGlD,eAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,eAAO,MAAM,OAAO,YAAY,CAAC;AACjC,eAAO,MAAM,KAAK,UAAU,CAAC;AAG7B,eAAO,MAAM,mBAAmB,eAAe,CAAC;AAChD,eAAO,MAAM,4BAA4B,eAAe,CAAC;AACzD,eAAO,MAAM,8BAA8B,eAAe,CAAC;AAC3D,eAAO,MAAM,oBAAoB,eAAe,CAAC;AACjD,eAAO,MAAM,iCAAiC,eAAe,CAAC;AAC9D,eAAO,MAAM,mCAAmC,eAAe,CAAC;AAGhE,eAAO,MAAM,IAAI,SAAS,CAAC;AAG3B,eAAO,MAAM,WAAW;;;;;CAKvB,CAAC;AAGF,eAAO,MAAM,sBAAsB;;;;;CAKlC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiDpB,CAAC;AAGX,eAAO,MAAM,iBAAiB,uDACwB,CAAC;AAEvD,eAAO,MAAM,gBAAgB,mCAAmC,CAAC;AAEjE,eAAO,MAAM,eAAe,MAAM,CAAC;AAEnC,eAAO,MAAM,eAAe,QAAQ,CAAC;AAGrC,eAAO,MAAM,eAAe,aAAa,CAAC;AAE1C;;;;GAIG;AACH,oBAAY,YAAY;IACtB,gBAAgB,4BAA4B;IAC5C,eAAe,qBAAqB;IACpC,UAAU,gBAAgB;IAC1B,yBAAyB,+BAA+B;IACxD,gBAAgB,sBAAsB;IACtC,YAAY,kBAAkB;IAC9B,WAAW,iBAAiB;IAC5B,aAAa,mBAAmB;IAChC,eAAe,sBAAsB;IACrC,sBAAsB,6BAA6B;IACnD,gBAAgB,uBAAuB;IACvC,iBAAiB,gBAAgB;IACjC,mBAAmB,+BAA+B;IAClD,WAAW,gBAAgB;IAC3B,MAAM,WAAW;IACjB,aAAa,mBAAmB;IAChC,wBAAwB,8BAA8B;IACtD,UAAU,sBAAsB;CACjC;AAED,eAAO,MAAM,mCAAmC,EAAE,MAAM,CACtD,OAAO,EACP,kBAAkB,CASnB,CAAC"}
|
package/dist/constants.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EACd,OAAO,EACP,kBAAkB,EACnB,oBAAgB;AAEjB,eAAO,MAAM,GAAG,QAAQ,CAAC;AACzB,eAAO,MAAM,qBAAqB,QAAQ,CAAC;AAC3C,eAAO,MAAM,wBAAwB,sCAAsC,CAAC;AAI5E,eAAO,MAAM,gBAAgB,UAAU,CAAC;AACxC;;;GAGG;AACH,eAAO,MAAM,iBAAiB,mBAAmB,CAAC;AAGlD,eAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,eAAO,MAAM,OAAO,YAAY,CAAC;AACjC,eAAO,MAAM,KAAK,UAAU,CAAC;AAG7B,eAAO,MAAM,mBAAmB,eAAe,CAAC;AAChD,eAAO,MAAM,4BAA4B,eAAe,CAAC;AACzD,eAAO,MAAM,8BAA8B,eAAe,CAAC;AAC3D,eAAO,MAAM,oBAAoB,eAAe,CAAC;AACjD,eAAO,MAAM,iCAAiC,eAAe,CAAC;AAC9D,eAAO,MAAM,mCAAmC,eAAe,CAAC;AAGhE,eAAO,MAAM,IAAI,SAAS,CAAC;AAG3B,eAAO,MAAM,WAAW;;;;;CAKvB,CAAC;AAGF,eAAO,MAAM,sBAAsB;;;;;CAKlC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiDpB,CAAC;AAGX,eAAO,MAAM,iBAAiB,uDACwB,CAAC;AAEvD,eAAO,MAAM,gBAAgB,mCAAmC,CAAC;AAEjE,eAAO,MAAM,eAAe,MAAM,CAAC;AAEnC,eAAO,MAAM,eAAe,QAAQ,CAAC;AAGrC,eAAO,MAAM,eAAe,aAAa,CAAC;AAE1C;;;;GAIG;AACH,oBAAY,YAAY;IACtB,gBAAgB,4BAA4B;IAC5C,eAAe,qBAAqB;IACpC,UAAU,gBAAgB;IAC1B,yBAAyB,+BAA+B;IACxD,gBAAgB,sBAAsB;IACtC,YAAY,kBAAkB;IAC9B,WAAW,iBAAiB;IAC5B,aAAa,mBAAmB;IAChC,eAAe,sBAAsB;IACrC,sBAAsB,6BAA6B;IACnD,gBAAgB,uBAAuB;IACvC,iBAAiB,gBAAgB;IACjC,mBAAmB,+BAA+B;IAClD,WAAW,gBAAgB;IAC3B,MAAM,WAAW;IACjB,aAAa,mBAAmB;IAChC,wBAAwB,8BAA8B;IACtD,UAAU,sBAAsB;CACjC;AAED,eAAO,MAAM,mCAAmC,EAAE,MAAM,CACtD,OAAO,EACP,kBAAkB,CASnB,CAAC"}
|
package/dist/index.cjs
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.weiHexToGweiDec = exports.toHex = exports.toChecksumHexAddress = exports.timeoutFetch = exports.successfulFetch = exports.safelyExecuteWithTimeout = exports.safelyExecute = exports.query = exports.normalizeEnsName = exports.isValidHexAddress = exports.isValidJson = exports.isSmartContractCode = exports.isSafeDynamicKey = exports.isSafeChainId = exports.isPlainObject = exports.isNonEmptyArray = exports.hexToText = exports.hexToBN = exports.handleFetch = exports.gweiDecToWEIBN = exports.getBuyURL = exports.fromHex = exports.fractionBN = exports.fetchWithErrorHandling = exports.convertHexToDecimal = exports.BNToHex = void 0;
|
|
18
|
-
__exportStar(require("./constants.cjs"), exports);
|
|
19
|
-
var util_1 = require("./util.cjs");
|
|
20
|
-
Object.defineProperty(exports, "BNToHex", { enumerable: true, get: function () { return util_1.BNToHex; } });
|
|
21
|
-
Object.defineProperty(exports, "convertHexToDecimal", { enumerable: true, get: function () { return util_1.convertHexToDecimal; } });
|
|
22
|
-
Object.defineProperty(exports, "fetchWithErrorHandling", { enumerable: true, get: function () { return util_1.fetchWithErrorHandling; } });
|
|
23
|
-
Object.defineProperty(exports, "fractionBN", { enumerable: true, get: function () { return util_1.fractionBN; } });
|
|
24
|
-
Object.defineProperty(exports, "fromHex", { enumerable: true, get: function () { return util_1.fromHex; } });
|
|
25
|
-
Object.defineProperty(exports, "getBuyURL", { enumerable: true, get: function () { return util_1.getBuyURL; } });
|
|
26
|
-
Object.defineProperty(exports, "gweiDecToWEIBN", { enumerable: true, get: function () { return util_1.gweiDecToWEIBN; } });
|
|
27
|
-
Object.defineProperty(exports, "handleFetch", { enumerable: true, get: function () { return util_1.handleFetch; } });
|
|
28
|
-
Object.defineProperty(exports, "hexToBN", { enumerable: true, get: function () { return util_1.hexToBN; } });
|
|
29
|
-
Object.defineProperty(exports, "hexToText", { enumerable: true, get: function () { return util_1.hexToText; } });
|
|
30
|
-
Object.defineProperty(exports, "isNonEmptyArray", { enumerable: true, get: function () { return util_1.isNonEmptyArray; } });
|
|
31
|
-
Object.defineProperty(exports, "isPlainObject", { enumerable: true, get: function () { return util_1.isPlainObject; } });
|
|
32
|
-
Object.defineProperty(exports, "isSafeChainId", { enumerable: true, get: function () { return util_1.isSafeChainId; } });
|
|
33
|
-
Object.defineProperty(exports, "isSafeDynamicKey", { enumerable: true, get: function () { return util_1.isSafeDynamicKey; } });
|
|
34
|
-
Object.defineProperty(exports, "isSmartContractCode", { enumerable: true, get: function () { return util_1.isSmartContractCode; } });
|
|
35
|
-
Object.defineProperty(exports, "isValidJson", { enumerable: true, get: function () { return util_1.isValidJson; } });
|
|
36
|
-
Object.defineProperty(exports, "isValidHexAddress", { enumerable: true, get: function () { return util_1.isValidHexAddress; } });
|
|
37
|
-
Object.defineProperty(exports, "normalizeEnsName", { enumerable: true, get: function () { return util_1.normalizeEnsName; } });
|
|
38
|
-
Object.defineProperty(exports, "query", { enumerable: true, get: function () { return util_1.query; } });
|
|
39
|
-
Object.defineProperty(exports, "safelyExecute", { enumerable: true, get: function () { return util_1.safelyExecute; } });
|
|
40
|
-
Object.defineProperty(exports, "safelyExecuteWithTimeout", { enumerable: true, get: function () { return util_1.safelyExecuteWithTimeout; } });
|
|
41
|
-
Object.defineProperty(exports, "successfulFetch", { enumerable: true, get: function () { return util_1.successfulFetch; } });
|
|
42
|
-
Object.defineProperty(exports, "timeoutFetch", { enumerable: true, get: function () { return util_1.timeoutFetch; } });
|
|
43
|
-
Object.defineProperty(exports, "toChecksumHexAddress", { enumerable: true, get: function () { return util_1.toChecksumHexAddress; } });
|
|
44
|
-
Object.defineProperty(exports, "toHex", { enumerable: true, get: function () { return util_1.toHex; } });
|
|
45
|
-
Object.defineProperty(exports, "weiHexToGweiDec", { enumerable: true, get: function () { return util_1.weiHexToGweiDec; } });
|
|
46
|
-
__exportStar(require("./types.cjs"), exports);
|
|
47
|
-
__exportStar(require("./siwe.cjs"), exports);
|
|
48
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,kDAA4B;AAE5B,mCA2BgB;AA1Bd,+FAAA,OAAO,OAAA;AACP,2GAAA,mBAAmB,OAAA;AACnB,8GAAA,sBAAsB,OAAA;AACtB,kGAAA,UAAU,OAAA;AACV,+FAAA,OAAO,OAAA;AACP,iGAAA,SAAS,OAAA;AACT,sGAAA,cAAc,OAAA;AACd,mGAAA,WAAW,OAAA;AACX,+FAAA,OAAO,OAAA;AACP,iGAAA,SAAS,OAAA;AACT,uGAAA,eAAe,OAAA;AACf,qGAAA,aAAa,OAAA;AACb,qGAAA,aAAa,OAAA;AACb,wGAAA,gBAAgB,OAAA;AAChB,2GAAA,mBAAmB,OAAA;AACnB,mGAAA,WAAW,OAAA;AACX,yGAAA,iBAAiB,OAAA;AACjB,wGAAA,gBAAgB,OAAA;AAChB,6FAAA,KAAK,OAAA;AACL,qGAAA,aAAa,OAAA;AACb,gHAAA,wBAAwB,OAAA;AACxB,uGAAA,eAAe,OAAA;AACf,oGAAA,YAAY,OAAA;AACZ,4GAAA,oBAAoB,OAAA;AACpB,6FAAA,KAAK,OAAA;AACL,uGAAA,eAAe,OAAA;AAEjB,8CAAwB;AACxB,6CAAuB","sourcesContent":["export * from './constants';\nexport type { NonEmptyArray } from './util';\nexport {\n BNToHex,\n convertHexToDecimal,\n fetchWithErrorHandling,\n fractionBN,\n fromHex,\n getBuyURL,\n gweiDecToWEIBN,\n handleFetch,\n hexToBN,\n hexToText,\n isNonEmptyArray,\n isPlainObject,\n isSafeChainId,\n isSafeDynamicKey,\n isSmartContractCode,\n isValidJson,\n isValidHexAddress,\n normalizeEnsName,\n query,\n safelyExecute,\n safelyExecuteWithTimeout,\n successfulFetch,\n timeoutFetch,\n toChecksumHexAddress,\n toHex,\n weiHexToGweiDec,\n} from './util';\nexport * from './types';\nexport * from './siwe';\n"]}
|
package/dist/index.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gCAA4B;AAC5B,YAAY,EAAE,aAAa,EAAE,mBAAe;AAC5C,OAAO,EACL,OAAO,EACP,mBAAmB,EACnB,sBAAsB,EACtB,UAAU,EACV,OAAO,EACP,SAAS,EACT,cAAc,EACd,WAAW,EACX,OAAO,EACP,SAAS,EACT,eAAe,EACf,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,EACL,aAAa,EACb,wBAAwB,EACxB,eAAe,EACf,YAAY,EACZ,oBAAoB,EACpB,KAAK,EACL,eAAe,GAChB,mBAAe;AAChB,4BAAwB;AACxB,2BAAuB"}
|
package/dist/index.d.mts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export * from "./constants.mjs";
|
|
2
|
-
export type { NonEmptyArray } from "./util.mjs";
|
|
3
|
-
export { BNToHex, convertHexToDecimal, fetchWithErrorHandling, fractionBN, fromHex, getBuyURL, gweiDecToWEIBN, handleFetch, hexToBN, hexToText, isNonEmptyArray, isPlainObject, isSafeChainId, isSafeDynamicKey, isSmartContractCode, isValidJson, isValidHexAddress, normalizeEnsName, query, safelyExecute, safelyExecuteWithTimeout, successfulFetch, timeoutFetch, toChecksumHexAddress, toHex, weiHexToGweiDec, } from "./util.mjs";
|
|
4
|
-
export * from "./types.mjs";
|
|
5
|
-
export * from "./siwe.mjs";
|
|
6
|
-
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gCAA4B;AAC5B,YAAY,EAAE,aAAa,EAAE,mBAAe;AAC5C,OAAO,EACL,OAAO,EACP,mBAAmB,EACnB,sBAAsB,EACtB,UAAU,EACV,OAAO,EACP,SAAS,EACT,cAAc,EACd,WAAW,EACX,OAAO,EACP,SAAS,EACT,eAAe,EACf,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,EACL,aAAa,EACb,wBAAwB,EACxB,eAAe,EACf,YAAY,EACZ,oBAAoB,EACpB,KAAK,EACL,eAAe,GAChB,mBAAe;AAChB,4BAAwB;AACxB,2BAAuB"}
|
package/dist/logger.cjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createModuleLogger = exports.projectLogger = void 0;
|
|
4
|
-
const utils_1 = require("@metamask/utils");
|
|
5
|
-
Object.defineProperty(exports, "createModuleLogger", { enumerable: true, get: function () { return utils_1.createModuleLogger; } });
|
|
6
|
-
exports.projectLogger = (0, utils_1.createProjectLogger)('controller-utils');
|
|
7
|
-
//# sourceMappingURL=logger.cjs.map
|
package/dist/logger.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.cjs","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";;;AAAA,2CAA0E;AAIjE,mGAJqB,0BAAkB,OAIrB;AAFd,QAAA,aAAa,GAAG,IAAA,2BAAmB,EAAC,kBAAkB,CAAC,CAAC","sourcesContent":["import { createProjectLogger, createModuleLogger } from '@metamask/utils';\n\nexport const projectLogger = createProjectLogger('controller-utils');\n\nexport { createModuleLogger };\n"]}
|
package/dist/logger.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.cts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";AAAA,OAAO,EAAuB,kBAAkB,EAAE,wBAAwB;AAE1E,eAAO,MAAM,aAAa,0BAA0C,CAAC;AAErE,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
package/dist/logger.d.mts
DELETED
package/dist/logger.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.mts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";AAAA,OAAO,EAAuB,kBAAkB,EAAE,wBAAwB;AAE1E,eAAO,MAAM,aAAa,0BAA0C,CAAC;AAErE,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
package/dist/siwe.cjs
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.detectSIWE = exports.isValidSIWEOrigin = exports.parseDomainParts = void 0;
|
|
4
|
-
const utils_1 = require("@metamask/utils");
|
|
5
|
-
const siwe_parser_1 = require("@spruceid/siwe-parser");
|
|
6
|
-
const logger_1 = require("./logger.cjs");
|
|
7
|
-
const log = (0, logger_1.createModuleLogger)(logger_1.projectLogger, 'detect-siwe');
|
|
8
|
-
/**
|
|
9
|
-
* This function strips the hex prefix from a string if it has one.
|
|
10
|
-
* If the input is not a string, return it unmodified.
|
|
11
|
-
*
|
|
12
|
-
* @param str - The string to check
|
|
13
|
-
* @returns The string without the hex prefix
|
|
14
|
-
*/
|
|
15
|
-
function safeStripHexPrefix(str) {
|
|
16
|
-
if (typeof str !== 'string') {
|
|
17
|
-
return str;
|
|
18
|
-
}
|
|
19
|
-
return (0, utils_1.remove0x)(str);
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* This function converts a hex string to text if it's not a 32 byte hex string.
|
|
23
|
-
*
|
|
24
|
-
* @param hex - The hex string to convert to text
|
|
25
|
-
* @returns The text representation of the hex string
|
|
26
|
-
*/
|
|
27
|
-
function msgHexToText(hex) {
|
|
28
|
-
try {
|
|
29
|
-
const stripped = safeStripHexPrefix(hex);
|
|
30
|
-
const buff = Buffer.from(stripped, 'hex');
|
|
31
|
-
return buff.length === 32 ? hex : buff.toString('utf8');
|
|
32
|
-
}
|
|
33
|
-
catch (e) {
|
|
34
|
-
log(e);
|
|
35
|
-
return hex;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
const DEFAULT_PORTS_BY_PROTOCOL = {
|
|
39
|
-
'http:': '80',
|
|
40
|
-
'https:': '443',
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Parses parts from RFC 3986 authority from EIP-4361 `domain` field.
|
|
44
|
-
*
|
|
45
|
-
* @param domain - input string
|
|
46
|
-
* @param originProtocol - implied protocol from origin
|
|
47
|
-
* @returns parsed parts
|
|
48
|
-
*/
|
|
49
|
-
const parseDomainParts = (domain, originProtocol) => {
|
|
50
|
-
if (domain.match(/^[^/:]*:\/\//u)) {
|
|
51
|
-
return new URL(domain);
|
|
52
|
-
}
|
|
53
|
-
return new URL(`${originProtocol}//${domain}`);
|
|
54
|
-
};
|
|
55
|
-
exports.parseDomainParts = parseDomainParts;
|
|
56
|
-
/**
|
|
57
|
-
* Validates origin of a Sign-In With Ethereum (SIWE)(EIP-4361) request.
|
|
58
|
-
* As per spec:
|
|
59
|
-
* hostname must match.
|
|
60
|
-
* port and username must match iff specified.
|
|
61
|
-
* Protocol binding and full same-origin are currently not performed.
|
|
62
|
-
*
|
|
63
|
-
* @param req - Signature request
|
|
64
|
-
* @returns true if origin matches domain; false otherwise
|
|
65
|
-
*/
|
|
66
|
-
const isValidSIWEOrigin = (req) => {
|
|
67
|
-
try {
|
|
68
|
-
const { origin, siwe } = req;
|
|
69
|
-
// origin = scheme://[user[:password]@]domain[:port]
|
|
70
|
-
// origin is supplied by environment and must match domain claim in message
|
|
71
|
-
if (!origin || !siwe?.parsedMessage?.domain) {
|
|
72
|
-
return false;
|
|
73
|
-
}
|
|
74
|
-
const originParts = new URL(origin);
|
|
75
|
-
const domainParts = (0, exports.parseDomainParts)(siwe.parsedMessage.domain, originParts.protocol);
|
|
76
|
-
if (domainParts.hostname.localeCompare(originParts.hostname, undefined, {
|
|
77
|
-
sensitivity: 'accent',
|
|
78
|
-
}) !== 0) {
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
if (domainParts.port !== '' && domainParts.port !== originParts.port) {
|
|
82
|
-
// If origin port is not specified, protocol default is implied
|
|
83
|
-
return (originParts.port === '' &&
|
|
84
|
-
domainParts.port === DEFAULT_PORTS_BY_PROTOCOL[originParts.protocol]);
|
|
85
|
-
}
|
|
86
|
-
if (domainParts.username !== '' &&
|
|
87
|
-
domainParts.username !== originParts.username) {
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
return true;
|
|
91
|
-
}
|
|
92
|
-
catch (e) {
|
|
93
|
-
log(e);
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
exports.isValidSIWEOrigin = isValidSIWEOrigin;
|
|
98
|
-
/**
|
|
99
|
-
* This function intercepts a sign message, detects if it's a
|
|
100
|
-
* Sign-In With Ethereum (SIWE)(EIP-4361) message, and returns an object with
|
|
101
|
-
* relevant SIWE data.
|
|
102
|
-
*
|
|
103
|
-
* {@see {@link https://eips.ethereum.org/EIPS/eip-4361}}
|
|
104
|
-
*
|
|
105
|
-
* @param msgParams - The params of the message to sign
|
|
106
|
-
* @param msgParams.data - The data of the message to sign
|
|
107
|
-
* @returns An object with the relevant SIWE data
|
|
108
|
-
*/
|
|
109
|
-
const detectSIWE = (msgParams) => {
|
|
110
|
-
try {
|
|
111
|
-
const { data } = msgParams;
|
|
112
|
-
const message = msgHexToText(data);
|
|
113
|
-
const parsedMessage = new siwe_parser_1.ParsedMessage(message);
|
|
114
|
-
return {
|
|
115
|
-
isSIWEMessage: true,
|
|
116
|
-
parsedMessage,
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
catch (error) {
|
|
120
|
-
// ignore error, it's not a valid SIWE message
|
|
121
|
-
return {
|
|
122
|
-
isSIWEMessage: false,
|
|
123
|
-
parsedMessage: null,
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
exports.detectSIWE = detectSIWE;
|
|
128
|
-
//# sourceMappingURL=siwe.cjs.map
|
package/dist/siwe.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"siwe.cjs","sourceRoot":"","sources":["../src/siwe.ts"],"names":[],"mappings":";;;AAAA,2CAA2C;AAC3C,uDAAsD;AAEtD,yCAA6D;AAE7D,MAAM,GAAG,GAAG,IAAA,2BAAkB,EAAC,sBAAa,EAAE,aAAa,CAAC,CAAC;AAE7D;;;;;;GAMG;AACH,SAAS,kBAAkB,CAAC,GAAW;IACrC,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;QAC3B,OAAO,GAAG,CAAC;KACZ;IACD,OAAO,IAAA,gBAAQ,EAAC,GAAG,CAAC,CAAC;AACvB,CAAC;AAED;;;;;GAKG;AACH,SAAS,YAAY,CAAC,GAAW;IAC/B,IAAI;QACF,MAAM,QAAQ,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;QACzC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QAC1C,OAAO,IAAI,CAAC,MAAM,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;KACzD;IAAC,OAAO,CAAC,EAAE;QACV,GAAG,CAAC,CAAC,CAAC,CAAC;QACP,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AAyB,CAAC,WAAW,CAAC,QAAQ,CAAC,CACrE,CAAC;SACH;QAED,IACE,WAAW,CAAC,QAAQ,KAAK,EAAE;YAC3B,WAAW,CAAC,QAAQ,KAAK,WAAW,CAAC,QAAQ,EAC7C;YACA,OAAO,KAAK,CAAC;SACd;QAED,OAAO,IAAI,CAAC;KACb;IAAC,OAAO,CAAC,EAAE;QACV,GAAG,CAAC,CAAC,CAAC,CAAC;QACP,OAAO,KAAK,CAAC;KACd;AACH,CAAC,CAAC;AA5CW,QAAA,iBAAiB,qBA4C5B;AAaF;;;;;;;;;;GAUG;AACI,MAAM,UAAU,GAAG,CAAC,SAA2B,EAAe,EAAE;IACrE,IAAI;QACF,MAAM,EAAE,IAAI,EAAE,GAAG,SAAS,CAAC;QAC3B,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;QACnC,MAAM,aAAa,GAAG,IAAI,2BAAa,CAAC,OAAO,CAAC,CAAC;QAEjD,OAAO;YACL,aAAa,EAAE,IAAI;YACnB,aAAa;SACd,CAAC;KACH;IAAC,OAAO,KAAK,EAAE;QACd,8CAA8C;QAC9C,OAAO;YACL,aAAa,EAAE,KAAK;YACpB,aAAa,EAAE,IAAI;SACpB,CAAC;KACH;AACH,CAAC,CAAC;AAjBW,QAAA,UAAU,cAiBrB","sourcesContent":["import { remove0x } from '@metamask/utils';\nimport { ParsedMessage } from '@spruceid/siwe-parser';\n\nimport { projectLogger, createModuleLogger } from './logger';\n\nconst log = createModuleLogger(projectLogger, 'detect-siwe');\n\n/**\n * This function strips the hex prefix from a string if it has one.\n * If the input is not a string, return it unmodified.\n *\n * @param str - The string to check\n * @returns The string without the hex prefix\n */\nfunction safeStripHexPrefix(str: string) {\n if (typeof str !== 'string') {\n return str;\n }\n return remove0x(str);\n}\n\n/**\n * This function converts a hex string to text if it's not a 32 byte hex string.\n *\n * @param hex - The hex string to convert to text\n * @returns The text representation of the hex string\n */\nfunction msgHexToText(hex: string): string {\n try {\n const stripped = safeStripHexPrefix(hex);\n const buff = Buffer.from(stripped, 'hex');\n return buff.length === 32 ? hex : buff.toString('utf8');\n } catch (e) {\n log(e);\n return hex;\n }\n}\n\n/**\n * @type WrappedSIWERequest\n *\n * Sign-In With Ethereum (SIWE)(EIP-4361) message with request metadata\n * @property {string} from - Subject account address\n * @property {string} origin - The RFC 3986 originating authority of the signing request, including scheme\n * @property {ParsedMessage} siwe - The data parsed from the message\n */\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface WrappedSIWERequest {\n from: string;\n origin: string;\n siwe: SIWEMessage;\n}\n\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\ninterface DomainParts {\n username?: string;\n hostname: string;\n port?: string;\n}\n\nconst DEFAULT_PORTS_BY_PROTOCOL = {\n 'http:': '80',\n 'https:': '443',\n} as Record<string, string>;\n\n/**\n * Parses parts from RFC 3986 authority from EIP-4361 `domain` field.\n *\n * @param domain - input string\n * @param originProtocol - implied protocol from origin\n * @returns parsed parts\n */\nexport const parseDomainParts = (\n domain: string,\n originProtocol: string,\n): DomainParts => {\n if (domain.match(/^[^/:]*:\\/\\//u)) {\n return new URL(domain);\n }\n return new URL(`${originProtocol}//${domain}`);\n};\n\n/**\n * Validates origin of a Sign-In With Ethereum (SIWE)(EIP-4361) request.\n * As per spec:\n * hostname must match.\n * port and username must match iff specified.\n * Protocol binding and full same-origin are currently not performed.\n *\n * @param req - Signature request\n * @returns true if origin matches domain; false otherwise\n */\nexport const isValidSIWEOrigin = (req: WrappedSIWERequest): boolean => {\n try {\n const { origin, siwe } = req;\n\n // origin = scheme://[user[:password]@]domain[:port]\n // origin is supplied by environment and must match domain claim in message\n if (!origin || !siwe?.parsedMessage?.domain) {\n return false;\n }\n\n const originParts = new URL(origin);\n const domainParts = parseDomainParts(\n siwe.parsedMessage.domain,\n originParts.protocol,\n );\n\n if (\n domainParts.hostname.localeCompare(originParts.hostname, undefined, {\n sensitivity: 'accent',\n }) !== 0\n ) {\n return false;\n }\n\n if (domainParts.port !== '' && domainParts.port !== originParts.port) {\n // If origin port is not specified, protocol default is implied\n return (\n originParts.port === '' &&\n domainParts.port === DEFAULT_PORTS_BY_PROTOCOL[originParts.protocol]\n );\n }\n\n if (\n domainParts.username !== '' &&\n domainParts.username !== originParts.username\n ) {\n return false;\n }\n\n return true;\n } catch (e) {\n log(e);\n return false;\n }\n};\n\n/**\n * A locally defined object used to provide data to identify a Sign-In With Ethereum (SIWE)(EIP-4361) message and provide the parsed message\n *\n * @typedef SIWEMessage\n * @param {boolean} isSIWEMessage - Does the intercepted message conform to the SIWE specification?\n * @param {ParsedMessage} parsedMessage - The data parsed out of the message\n */\nexport type SIWEMessage =\n | { isSIWEMessage: true; parsedMessage: ParsedMessage }\n | { isSIWEMessage: false; parsedMessage: null };\n\n/**\n * This function intercepts a sign message, detects if it's a\n * Sign-In With Ethereum (SIWE)(EIP-4361) message, and returns an object with\n * relevant SIWE data.\n *\n * {@see {@link https://eips.ethereum.org/EIPS/eip-4361}}\n *\n * @param msgParams - The params of the message to sign\n * @param msgParams.data - The data of the message to sign\n * @returns An object with the relevant SIWE data\n */\nexport const detectSIWE = (msgParams: { data: string }): SIWEMessage => {\n try {\n const { data } = msgParams;\n const message = msgHexToText(data);\n const parsedMessage = new ParsedMessage(message);\n\n return {\n isSIWEMessage: true,\n parsedMessage,\n };\n } catch (error) {\n // ignore error, it's not a valid SIWE message\n return {\n isSIWEMessage: false,\n parsedMessage: null,\n };\n }\n};\n"]}
|
package/dist/siwe.d.cts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { ParsedMessage } from "@spruceid/siwe-parser";
|
|
2
|
-
/**
|
|
3
|
-
* @type WrappedSIWERequest
|
|
4
|
-
*
|
|
5
|
-
* Sign-In With Ethereum (SIWE)(EIP-4361) message with request metadata
|
|
6
|
-
* @property {string} from - Subject account address
|
|
7
|
-
* @property {string} origin - The RFC 3986 originating authority of the signing request, including scheme
|
|
8
|
-
* @property {ParsedMessage} siwe - The data parsed from the message
|
|
9
|
-
*/
|
|
10
|
-
export interface WrappedSIWERequest {
|
|
11
|
-
from: string;
|
|
12
|
-
origin: string;
|
|
13
|
-
siwe: SIWEMessage;
|
|
14
|
-
}
|
|
15
|
-
interface DomainParts {
|
|
16
|
-
username?: string;
|
|
17
|
-
hostname: string;
|
|
18
|
-
port?: string;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Parses parts from RFC 3986 authority from EIP-4361 `domain` field.
|
|
22
|
-
*
|
|
23
|
-
* @param domain - input string
|
|
24
|
-
* @param originProtocol - implied protocol from origin
|
|
25
|
-
* @returns parsed parts
|
|
26
|
-
*/
|
|
27
|
-
export declare const parseDomainParts: (domain: string, originProtocol: string) => DomainParts;
|
|
28
|
-
/**
|
|
29
|
-
* Validates origin of a Sign-In With Ethereum (SIWE)(EIP-4361) request.
|
|
30
|
-
* As per spec:
|
|
31
|
-
* hostname must match.
|
|
32
|
-
* port and username must match iff specified.
|
|
33
|
-
* Protocol binding and full same-origin are currently not performed.
|
|
34
|
-
*
|
|
35
|
-
* @param req - Signature request
|
|
36
|
-
* @returns true if origin matches domain; false otherwise
|
|
37
|
-
*/
|
|
38
|
-
export declare const isValidSIWEOrigin: (req: WrappedSIWERequest) => boolean;
|
|
39
|
-
/**
|
|
40
|
-
* A locally defined object used to provide data to identify a Sign-In With Ethereum (SIWE)(EIP-4361) message and provide the parsed message
|
|
41
|
-
*
|
|
42
|
-
* @typedef SIWEMessage
|
|
43
|
-
* @param {boolean} isSIWEMessage - Does the intercepted message conform to the SIWE specification?
|
|
44
|
-
* @param {ParsedMessage} parsedMessage - The data parsed out of the message
|
|
45
|
-
*/
|
|
46
|
-
export type SIWEMessage = {
|
|
47
|
-
isSIWEMessage: true;
|
|
48
|
-
parsedMessage: ParsedMessage;
|
|
49
|
-
} | {
|
|
50
|
-
isSIWEMessage: false;
|
|
51
|
-
parsedMessage: null;
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* This function intercepts a sign message, detects if it's a
|
|
55
|
-
* Sign-In With Ethereum (SIWE)(EIP-4361) message, and returns an object with
|
|
56
|
-
* relevant SIWE data.
|
|
57
|
-
*
|
|
58
|
-
* {@see {@link https://eips.ethereum.org/EIPS/eip-4361}}
|
|
59
|
-
*
|
|
60
|
-
* @param msgParams - The params of the message to sign
|
|
61
|
-
* @param msgParams.data - The data of the message to sign
|
|
62
|
-
* @returns An object with the relevant SIWE data
|
|
63
|
-
*/
|
|
64
|
-
export declare const detectSIWE: (msgParams: {
|
|
65
|
-
data: string;
|
|
66
|
-
}) => SIWEMessage;
|
|
67
|
-
export {};
|
|
68
|
-
//# sourceMappingURL=siwe.d.cts.map
|
package/dist/siwe.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"siwe.d.cts","sourceRoot":"","sources":["../src/siwe.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,8BAA8B;AAqCtD;;;;;;;GAOG;AAIH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,WAAW,CAAC;CACnB;AAKD,UAAU,WAAW;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAOD;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,WACnB,MAAM,kBACE,MAAM,KACrB,WAKF,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,QAAS,kBAAkB,KAAG,OA4C3D,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GACnB;IAAE,aAAa,EAAE,IAAI,CAAC;IAAC,aAAa,EAAE,aAAa,CAAA;CAAE,GACrD;IAAE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