@hyperlane-xyz/utils 9.2.1 → 11.0.0

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.
@@ -0,0 +1,7 @@
1
+ export declare const importRestrictionsPlugin: {
2
+ name: string;
3
+ rules: {
4
+ 'no-restricted-imports-from-exports': import("eslint").Rule.RuleModule;
5
+ };
6
+ };
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/eslint-rules/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,wBAAwB;;;;;CAKpC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import noRestrictedImportsFromExports from './no-restricted-imports-from-exports.js';
2
+ export const importRestrictionsPlugin = {
3
+ name: '@hyperlane/import-restrictions',
4
+ rules: {
5
+ 'no-restricted-imports-from-exports': noRestrictedImportsFromExports,
6
+ },
7
+ };
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/eslint-rules/index.ts"],"names":[],"mappings":"AAAA,OAAO,8BAA8B,MAAM,yCAAyC,CAAC;AAErF,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,IAAI,EAAE,gCAAgC;IACtC,KAAK,EAAE;QACL,oCAAoC,EAAE,8BAA8B;KACrE;CACF,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { Rule } from 'eslint';
2
+ declare const rule: Rule.RuleModule;
3
+ export default rule;
4
+ //# sourceMappingURL=no-restricted-imports-from-exports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-restricted-imports-from-exports.d.ts","sourceRoot":"","sources":["../../src/eslint-rules/no-restricted-imports-from-exports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAgC9B,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,UA8JhB,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -0,0 +1,141 @@
1
+ // eslint-disable-next-line no-restricted-imports
2
+ import fs from 'fs';
3
+ // eslint-disable-next-line no-restricted-imports
4
+ import path from 'path';
5
+ const NODE_BUILTIN_MODULES = [
6
+ 'fs',
7
+ 'path',
8
+ 'child_process',
9
+ 'os',
10
+ 'process',
11
+ 'http',
12
+ 'https',
13
+ 'net',
14
+ 'dgram',
15
+ 'dns',
16
+ 'crypto',
17
+ 'tls',
18
+ 'cluster',
19
+ 'stream',
20
+ 'vm',
21
+ 'readline',
22
+ ];
23
+ const rule = {
24
+ meta: {
25
+ type: 'problem',
26
+ docs: {
27
+ description: 'Disallow client-restricted imports in files exported from specified entry points',
28
+ category: 'Best Practices',
29
+ recommended: true,
30
+ },
31
+ messages: {
32
+ restrictedFsImport: 'Files exported from {{ mainEntry }} should not import "{{ moduleName }}" which is exported from {{ restrictedEntry }}',
33
+ restrictedNodeImport: 'Files exported from {{ mainEntry }} should not import Node.js built-in module "{{ moduleName }}"',
34
+ },
35
+ schema: [
36
+ {
37
+ type: 'object',
38
+ properties: {
39
+ mainEntry: {
40
+ type: 'string',
41
+ default: './src/index.ts',
42
+ },
43
+ restrictedEntry: {
44
+ type: 'string',
45
+ default: './src/index-fs.ts',
46
+ },
47
+ },
48
+ additionalProperties: false,
49
+ },
50
+ ],
51
+ },
52
+ create(context) {
53
+ const options = (context.options[0] || {});
54
+ const mainEntry = options.mainEntry || './src/index.ts';
55
+ const restrictedEntry = options.restrictedEntry || './src/index-fs.ts';
56
+ const resolvePathFromCwd = (relativePath) => path.resolve(context.cwd, relativePath);
57
+ const extractNamedExports = (content) => {
58
+ const exportBlocks = content.match(/export\s+\{[^}]+\}/g) || [];
59
+ const namedExports = exportBlocks.join(' ').match(/[a-zA-Z0-9_]+(?=\s*[,}])/g) || [];
60
+ return namedExports.map((name) => name.trim());
61
+ };
62
+ const extractReExports = (content, basePath) => {
63
+ const reExportMatches = content.match(/export\s+(?:[\s\S]*?)\s+from\s+['"](.+)['"]/g) || [];
64
+ const reExportPaths = reExportMatches
65
+ .map((match) => {
66
+ const pathMatch = match.match(/from\s+['"](.+)['"]/);
67
+ return pathMatch ? pathMatch[1] : null;
68
+ })
69
+ .filter((path) => path !== null && (path.startsWith('./') || path.startsWith('../')));
70
+ return reExportPaths.map((exportPath) => {
71
+ const resolvedPath = exportPath.endsWith('.js')
72
+ ? exportPath.replace(/\.js$/, '.ts')
73
+ : exportPath;
74
+ return path.resolve(path.dirname(basePath), resolvedPath);
75
+ });
76
+ };
77
+ const extractExportsFromFile = (filePath) => {
78
+ try {
79
+ const content = fs.readFileSync(filePath, 'utf8');
80
+ return [
81
+ ...extractNamedExports(content),
82
+ ...extractReExports(content, filePath),
83
+ ];
84
+ }
85
+ catch (_) {
86
+ return [];
87
+ }
88
+ };
89
+ const isPathPartOfExport = (filePath, exportPath) => typeof exportPath === 'string' &&
90
+ exportPath.includes('/') &&
91
+ filePath.includes(exportPath.replace(/\.ts$/, ''));
92
+ const indexTsPath = resolvePathFromCwd(mainEntry);
93
+ const indexFsPath = resolvePathFromCwd(restrictedEntry);
94
+ const indexExports = extractExportsFromFile(indexTsPath);
95
+ const fsIndexExports = extractExportsFromFile(indexFsPath);
96
+ const isFileExportedFromIndex = (filePath) => indexExports.some((exportPath) => isPathPartOfExport(filePath, exportPath));
97
+ const isExportedFromFsIndex = (importPath) => fsIndexExports.some((fsExport) => isPathPartOfExport(importPath, fsExport));
98
+ const isNodeBuiltinModuleOrSubpath = (importSource) => {
99
+ if (NODE_BUILTIN_MODULES.includes(importSource)) {
100
+ return true;
101
+ }
102
+ const parts = importSource.split('/');
103
+ return (NODE_BUILTIN_MODULES.includes(parts[0]) &&
104
+ parts.length > 1);
105
+ };
106
+ return {
107
+ ImportDeclaration(node) {
108
+ const currentFilePath = context.getFilename();
109
+ if (!isFileExportedFromIndex(currentFilePath))
110
+ return;
111
+ const importSource = node.source.value;
112
+ if (isNodeBuiltinModuleOrSubpath(importSource)) {
113
+ context.report({
114
+ node,
115
+ messageId: 'restrictedNodeImport',
116
+ data: {
117
+ moduleName: importSource,
118
+ mainEntry,
119
+ },
120
+ });
121
+ }
122
+ if (typeof importSource === 'string' && importSource.startsWith('.')) {
123
+ const resolvedImportPath = path.resolve(path.dirname(currentFilePath), importSource);
124
+ if (isExportedFromFsIndex(resolvedImportPath)) {
125
+ context.report({
126
+ node,
127
+ messageId: 'restrictedFsImport',
128
+ data: {
129
+ moduleName: importSource,
130
+ mainEntry,
131
+ restrictedEntry,
132
+ },
133
+ });
134
+ }
135
+ }
136
+ },
137
+ };
138
+ },
139
+ };
140
+ export default rule;
141
+ //# sourceMappingURL=no-restricted-imports-from-exports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-restricted-imports-from-exports.js","sourceRoot":"","sources":["../../src/eslint-rules/no-restricted-imports-from-exports.ts"],"names":[],"mappings":"AACA,iDAAiD;AACjD,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,iDAAiD;AACjD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,oBAAoB,GAAG;IAC3B,IAAI;IACJ,MAAM;IACN,eAAe;IACf,IAAI;IACJ,SAAS;IACT,MAAM;IACN,OAAO;IACP,KAAK;IACL,OAAO;IACP,KAAK;IACL,QAAQ;IACR,KAAK;IACL,SAAS;IACT,QAAQ;IACR,IAAI;IACJ,UAAU;CACF,CAAC;AASX,MAAM,IAAI,GAAoB;IAC5B,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EACT,kFAAkF;YACpF,QAAQ,EAAE,gBAAgB;YAC1B,WAAW,EAAE,IAAI;SAClB;QACD,QAAQ,EAAE;YACR,kBAAkB,EAChB,uHAAuH;YACzH,oBAAoB,EAClB,kGAAkG;SACrG;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,SAAS,EAAE;wBACT,IAAI,EAAE,QAAQ;wBACd,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AAI,EAAE;4BACJ,UAAU,EAAE,YAAY;4BACxB,SAAS;yBACV;qBACF,CAAC,CAAC;gBACL,CAAC;gBAED,IAAI,OAAO,YAAY,KAAK,QAAQ,IAAI,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;oBACrE,MAAM,kBAAkB,GAAG,IAAI,CAAC,OAAO,CACrC,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,EAC7B,YAAY,CACb,CAAC;oBAEF,IAAI,qBAAqB,CAAC,kBAAkB,CAAC,EAAE,CAAC;wBAC9C,OAAO,CAAC,MAAM,CAAC;4BACb,IAAI;4BACJ,SAAS,EAAE,oBAAoB;4BAC/B,IAAI,EAAE;gCACJ,UAAU,EAAE,YAAY;gCACxB,SAAS;gCACT,eAAe;6BAChB;yBACF,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=no-restricted-imports-from-exports.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-restricted-imports-from-exports.test.d.ts","sourceRoot":"","sources":["../../src/eslint-rules/no-restricted-imports-from-exports.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,260 @@
1
+ import { expect } from 'chai';
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+ import sinon from 'sinon';
5
+ import rule from './no-restricted-imports-from-exports.js';
6
+ describe('no-restricted-imports-from-exports rule', () => {
7
+ // Mock file contents to simulate index exports
8
+ const exportedFileContents = {
9
+ './src/index.ts': "export { componentA } from './components/componentA';\nexport { componentB } from './components/componentB';",
10
+ './src/index-fs.ts': "export { fileUtil } from './utils/fileUtil';",
11
+ };
12
+ // Path mapping for test fixtures
13
+ const pathMappings = {
14
+ './src/index.ts': './src/index.ts',
15
+ './src/index-fs.ts': './src/index-fs.ts',
16
+ 'components/componentA': './src/components/componentA',
17
+ 'components/componentB': './src/components/componentB',
18
+ 'components/nested/componentA': './src/components/nested/componentA',
19
+ 'utils/fileUtil': './src/utils/fileUtil',
20
+ 'utils/otherUtil': './src/utils/otherUtil',
21
+ };
22
+ function setupStubs() {
23
+ // Stub fs.readFileSync to return mock file contents
24
+ sinon
25
+ .stub(fs, 'readFileSync')
26
+ .callsFake((filePath) => typeof filePath === 'string'
27
+ ? exportedFileContents[filePath] || ''
28
+ : '');
29
+ // Stub path.resolve to simplify path resolution in tests
30
+ sinon
31
+ .stub(path, 'resolve')
32
+ .callsFake(function (...args) {
33
+ const lastArg = args[args.length - 1];
34
+ if (typeof lastArg !== 'string') {
35
+ return String(lastArg);
36
+ }
37
+ for (const [pattern, mapping] of Object.entries(pathMappings)) {
38
+ if (lastArg.includes(pattern)) {
39
+ return mapping;
40
+ }
41
+ }
42
+ return lastArg;
43
+ });
44
+ sinon
45
+ .stub(path, 'dirname')
46
+ .callsFake((filePath) => filePath.substring(0, filePath.lastIndexOf('/') || 0));
47
+ }
48
+ // Helper function to test import validations in different scenarios
49
+ function verifyImport({ sourceFile, importPath, expectedError, shouldPass = false, options = {}, }) {
50
+ const errors = [];
51
+ const context = {
52
+ getFilename: () => sourceFile,
53
+ cwd: () => '.',
54
+ report: (err) => errors.push(err),
55
+ options: [options],
56
+ };
57
+ const ruleInstance = rule.create(context);
58
+ if (ruleInstance?.ImportDeclaration) {
59
+ ruleInstance.ImportDeclaration({
60
+ type: 'ImportDeclaration',
61
+ source: {
62
+ type: 'Literal',
63
+ value: importPath,
64
+ raw: `'${importPath}'`,
65
+ },
66
+ specifiers: [],
67
+ parent: {},
68
+ });
69
+ }
70
+ if (expectedError || !shouldPass) {
71
+ expect(errors.length).to.equal(1, `Import from ${sourceFile} to ${importPath} should report an error`);
72
+ if (expectedError) {
73
+ expect(errors[0].messageId).to.equal(expectedError, `Import should report error type ${expectedError}`);
74
+ }
75
+ }
76
+ else {
77
+ expect(errors.length).to.equal(0, `Import from ${sourceFile} to ${importPath} should not report any errors`);
78
+ }
79
+ }
80
+ beforeEach(() => {
81
+ setupStubs();
82
+ });
83
+ afterEach(() => {
84
+ // Restore all stubs
85
+ sinon.restore();
86
+ });
87
+ describe('Non-exported files - Files not included in index exports', () => {
88
+ it('should allow importing node modules in non-exported files', () => {
89
+ verifyImport({
90
+ sourceFile: './src/other.ts',
91
+ importPath: 'fs',
92
+ shouldPass: true,
93
+ });
94
+ });
95
+ it('should allow importing any modules in non-exported files without restrictions', () => {
96
+ const sourceFile = './src/other.ts';
97
+ verifyImport({
98
+ sourceFile,
99
+ importPath: './components/other',
100
+ shouldPass: true,
101
+ });
102
+ verifyImport({
103
+ sourceFile,
104
+ importPath: './utils/fileUtil',
105
+ shouldPass: true,
106
+ });
107
+ verifyImport({
108
+ sourceFile,
109
+ importPath: 'path',
110
+ shouldPass: true,
111
+ });
112
+ });
113
+ });
114
+ describe('Exported files - Files that are exported through index.ts', () => {
115
+ const exportedComponentFile = './src/components/componentA.ts';
116
+ it('should allow importing regular modules from exported files', () => {
117
+ verifyImport({
118
+ sourceFile: exportedComponentFile,
119
+ importPath: './components/other',
120
+ shouldPass: true,
121
+ });
122
+ });
123
+ it('should disallow importing node modules from exported files to prevent side effects', () => {
124
+ verifyImport({
125
+ sourceFile: exportedComponentFile,
126
+ importPath: 'fs',
127
+ expectedError: 'restrictedNodeImport',
128
+ });
129
+ verifyImport({
130
+ sourceFile: exportedComponentFile,
131
+ importPath: 'path',
132
+ expectedError: 'restrictedNodeImport',
133
+ });
134
+ verifyImport({
135
+ sourceFile: exportedComponentFile,
136
+ importPath: 'crypto',
137
+ expectedError: 'restrictedNodeImport',
138
+ });
139
+ });
140
+ it('should disallow importing from fs-indexed modules in exported components', () => {
141
+ verifyImport({
142
+ sourceFile: exportedComponentFile,
143
+ importPath: './utils/fileUtil',
144
+ expectedError: 'restrictedFsImport',
145
+ });
146
+ });
147
+ it('should handle relative imports correctly and detect restricted fs imports', () => {
148
+ verifyImport({
149
+ sourceFile: exportedComponentFile,
150
+ importPath: '../utils/fileUtil',
151
+ expectedError: 'restrictedFsImport',
152
+ });
153
+ });
154
+ it('should allow importing scoped packages even from exported components', () => {
155
+ verifyImport({
156
+ sourceFile: exportedComponentFile,
157
+ importPath: '@scoped/fs-module',
158
+ shouldPass: true,
159
+ });
160
+ });
161
+ it('should allow files exported from index-fs.ts to import node modules directly', () => {
162
+ const fileUtilPath = './src/utils/fileUtil.ts';
163
+ verifyImport({
164
+ sourceFile: fileUtilPath,
165
+ importPath: 'fs',
166
+ shouldPass: true,
167
+ });
168
+ verifyImport({
169
+ sourceFile: fileUtilPath,
170
+ importPath: 'crypto',
171
+ shouldPass: true,
172
+ });
173
+ });
174
+ });
175
+ describe('Edge cases', () => {
176
+ const exportedComponentFile = './src/components/componentA.ts';
177
+ it('should handle subpaths of node modules correctly and restrict them in exported files', () => {
178
+ verifyImport({
179
+ sourceFile: exportedComponentFile,
180
+ importPath: 'fs/promises',
181
+ expectedError: 'restrictedNodeImport',
182
+ });
183
+ verifyImport({
184
+ sourceFile: exportedComponentFile,
185
+ importPath: 'path/posix',
186
+ expectedError: 'restrictedNodeImport',
187
+ });
188
+ });
189
+ it('should allow similarly named packages that are not actual node modules', () => {
190
+ verifyImport({
191
+ sourceFile: exportedComponentFile,
192
+ importPath: 'fstest',
193
+ shouldPass: true,
194
+ });
195
+ verifyImport({
196
+ sourceFile: exportedComponentFile,
197
+ importPath: 'fs-test',
198
+ shouldPass: true,
199
+ });
200
+ verifyImport({
201
+ sourceFile: exportedComponentFile,
202
+ importPath: 'path-extra',
203
+ shouldPass: true,
204
+ });
205
+ });
206
+ it('should handle non-existent files gracefully without throwing errors', () => {
207
+ verifyImport({
208
+ sourceFile: exportedComponentFile,
209
+ importPath: './non-existent-file',
210
+ shouldPass: true,
211
+ });
212
+ });
213
+ });
214
+ describe('Custom entry points', () => {
215
+ const customExportedFileContents = {
216
+ './src/main.ts': "export { customComponent } from './components/customComponent';",
217
+ './src/restricted.ts': "export { restrictedUtil } from './utils/restrictedUtil';",
218
+ };
219
+ beforeEach(() => {
220
+ // Add custom file contents to the existing exportedFileContents
221
+ Object.assign(exportedFileContents, customExportedFileContents);
222
+ // Add custom path mappings
223
+ Object.assign(pathMappings, {
224
+ './src/main.ts': './src/main.ts',
225
+ './src/restricted.ts': './src/restricted.ts',
226
+ 'components/customComponent': './src/components/customComponent',
227
+ 'utils/restrictedUtil': './src/utils/restrictedUtil',
228
+ });
229
+ });
230
+ it('should respect custom main and restricted entry points', () => {
231
+ const options = {
232
+ mainEntry: './src/main.ts',
233
+ restrictedEntry: './src/restricted.ts',
234
+ };
235
+ // Test with custom entry points
236
+ verifyImport({
237
+ sourceFile: './src/components/customComponent.ts',
238
+ importPath: './utils/restrictedUtil',
239
+ expectedError: 'restrictedFsImport',
240
+ options,
241
+ });
242
+ // Should still work for node modules
243
+ verifyImport({
244
+ sourceFile: './src/components/customComponent.ts',
245
+ importPath: 'fs',
246
+ expectedError: 'restrictedNodeImport',
247
+ options,
248
+ });
249
+ });
250
+ it('should fall back to defaults when no options provided', () => {
251
+ // Test with default entry points
252
+ verifyImport({
253
+ sourceFile: './src/components/componentA.ts',
254
+ importPath: './utils/fileUtil',
255
+ expectedError: 'restrictedFsImport',
256
+ });
257
+ });
258
+ });
259
+ });
260
+ //# sourceMappingURL=no-restricted-imports-from-exports.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-restricted-imports-from-exports.test.js","sourceRoot":"","sources":["../../src/eslint-rules/no-restricted-imports-from-exports.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAE9B,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,IAAI,MAAM,yCAAyC,CAAC;AAkB3D,QAAQ,CAAC,yCAAyC,EAAE,GAAG,EAAE;IACvD,+CAA+C;IAC/C,MAAM,o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;YACvD,eAAe,EACb,iEAAiE;YACnE,qBAAqB,EACnB,0DAA0D;SAC7D,CAAC;QAEF,UAAU,CAAC,GAAG,EAAE;YACd,gEAAgE;YAChE,MAAM,CAAC,MAAM,CAAC,oBAAoB,EAAE,0BAA0B,CAAC,CAAC;YAEhE,2BAA2B;YAC3B,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE;gBAC1B,eAAe,EAAE,eAAe;gBAChC,qBAAqB,EAAE,qBAAqB;gBAC5C,4BAA4B,EAAE,kCAAkC;gBAChE,sBAAsB,EAAE,4BAA4B;aACrD,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,wDAAwD,EAAE,GAAG,EAAE;YAChE,MAAM,OAAO,GAAG;gBACd,SAAS,EAAE,eAAe;gBAC1B,eAAe,EAAE,qBAAqB;aACvC,CAAC;YAEF,gCAAgC;YAChC,YAAY,CAAC;gBACX,UAAU,EAAE,qCAAqC;gBACjD,UAAU,EAAE,wBAAwB;gBACpC,aAAa,EAAE,oBAAoB;gBACnC,OAAO;aACR,CAAC,CAAC;YAEH,qCAAqC;YACrC,YAAY,CAAC;gBACX,UAAU,EAAE,qCAAqC;gBACjD,UAAU,EAAE,IAAI;gBAChB,aAAa,EAAE,sBAAsB;gBACrC,OAAO;aACR,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,uDAAuD,EAAE,GAAG,EAAE;YAC/D,iCAAiC;YACjC,YAAY,CAAC;gBACX,UAAU,EAAE,gCAAgC;gBAC5C,UAAU,EAAE,kBAAkB;gBAC9B,aAAa,EAAE,oBAAoB;aACpC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/dist/types.d.ts CHANGED
@@ -4,6 +4,7 @@ export declare enum ProtocolType {
4
4
  Ethereum = "ethereum",
5
5
  Sealevel = "sealevel",
6
6
  Cosmos = "cosmos",
7
+ CosmosNative = "cosmosnative",
7
8
  Starknet = "starknet"
8
9
  }
9
10
  export type ProtocolTypeValue = `${ProtocolType}`;
@@ -11,6 +12,7 @@ export declare const ProtocolSmallestUnit: {
11
12
  ethereum: string;
12
13
  sealevel: string;
13
14
  cosmos: string;
15
+ cosmosnative: string;
14
16
  starknet: string;
15
17
  };
16
18
  /********* BASIC TYPES *********/
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhD,oBAAY,YAAY;IACtB,QAAQ,aAAa;IACrB,QAAQ,aAAa;IACrB,MAAM,WAAW;IACjB,QAAQ,aAAa;CACtB;AAED,MAAM,MAAM,iBAAiB,GAAG,GAAG,YAAY,EAAE,CAAC;AAElD,eAAO,MAAM,oBAAoB;;;;;CAKhC,CAAC;AAEF,iCAAiC;AACjC,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAC5B,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAChC,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AACtC,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC;AAC7B,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC;AACpC,MAAM,MAAM,YAAY,GAAG,GAAG,MAAM,IAAI,MAAM,EAAE,CAAC;AACjD,MAAM,MAAM,aAAa,GAAG,GAAG,MAAM,IAAI,MAAM,IAAI,MAAM,IAAI,MAAM,EAAE,CAAC;AACtE,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAC/B,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAEjD,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG;IAC/B,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF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CAAC,SAAS,EAAE,CAAC;IAChC,UAAU,EAAE,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;IACrC,UAAU,EAAE,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC"}
package/dist/types.js CHANGED
@@ -3,12 +3,14 @@ export var ProtocolType;
3
3
  ProtocolType["Ethereum"] = "ethereum";
4
4
  ProtocolType["Sealevel"] = "sealevel";
5
5
  ProtocolType["Cosmos"] = "cosmos";
6
+ ProtocolType["CosmosNative"] = "cosmosnative";
6
7
  ProtocolType["Starknet"] = "starknet";
7
8
  })(ProtocolType || (ProtocolType = {}));
8
9
  export const ProtocolSmallestUnit = {
9
10
  [ProtocolType.Ethereum]: 'wei',
10
11
  [ProtocolType.Sealevel]: 'lamports',
11
12
  [ProtocolType.Cosmos]: 'uATOM',
13
+ [ProtocolType.CosmosNative]: 'uATOM',
12
14
  [ProtocolType.Starknet]: 'fri',
13
15
  };
14
16
  export var MessageStatus;
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,MAAM,CAAN,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,qCAAqB,CAAA;IACrB,qCAAqB,CAAA;IACrB,iCAAiB,CAAA;IACjB,qCAAqB,CAAA;AACvB,CAAC,EALW,YAAY,KAAZ,YAAY,QAKvB;AAID,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,KAAK;IAC9B,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,UAAU;IACnC,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,OAAO;IAC9B,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,KAAK;CAC/B,CAAC;AAqEF,MAAM,CAAN,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,iDAAQ,CAAA;IACR,2DAAS,CAAA;AACX,CAAC,EAHW,aAAa,KAAb,aAAa,QAGxB"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,MAAM,CAAN,IAAY,YAMX;AAND,WAAY,YAAY;IACtB,qCAAqB,CAAA;IACrB,qCAAqB,CAAA;IACrB,iCAAiB,CAAA;IACjB,6CAA6B,CAAA;IAC7B,qCAAqB,CAAA;AACvB,CAAC,EANW,YAAY,KAAZ,YAAY,QAMvB;AAID,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,KAAK;IAC9B,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,UAAU;IACnC,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,OAAO;IAC9B,CAAC,YAAY,CAAC,YAAY,CAAC,EAAE,OAAO;IACpC,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,KAAK;CAC/B,CAAC;AAqEF,MAAM,CAAN,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,iDAAQ,CAAA;IACR,2DAAS,CAAA;AACX,CAAC,EAHW,aAAa,KAAb,aAAa,QAGxB"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hyperlane-xyz/utils",
3
3
  "description": "General utilities and types for the Hyperlane network",
4
- "version": "9.2.1",
4
+ "version": "11.0.0",
5
5
  "dependencies": {
6
6
  "@cosmjs/encoding": "^0.32.4",
7
7
  "@solana/web3.js": "^1.95.4",
@@ -40,7 +40,7 @@
40
40
  "prepublish": "yarn build",
41
41
  "scripts": {
42
42
  "dev": "tsc -w",
43
- "build": "tsc",
43
+ "build": "tsc --excludeFiles \"**/*.test.ts\"",
44
44
  "clean": "rm -rf ./dist",
45
45
  "check": "tsc --noEmit",
46
46
  "lint": "eslint -c ./eslint.config.mjs",
@@ -49,7 +49,10 @@
49
49
  "test:ci": "yarn test"
50
50
  },
51
51
  "type": "module",
52
- "exports": "./dist/index.js",
52
+ "exports": {
53
+ ".": "./dist/index.js",
54
+ "./eslint-rules": "./dist/eslint-rules/index.js"
55
+ },
53
56
  "types": "./dist/index.d.ts",
54
57
  "files": [
55
58
  "/dist"