@graphprotocol/graph-cli 0.64.0-alpha-20231215205836-6d9a26b → 0.64.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.
@@ -1,20 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const vitest_1 = require("vitest");
4
3
  const util_1 = require("./util");
5
- vitest_1.describe.concurrent('Codegen utilities', () => {
6
- (0, vitest_1.test)('Name disambiguation', () => {
7
- (0, vitest_1.expect)((0, util_1.disambiguateNames)({
4
+ describe('Codegen utilities', () => {
5
+ test('Name disambiguation', () => {
6
+ expect((0, util_1.disambiguateNames)({
8
7
  values: ['a', 'b', 'c'],
9
8
  getName: x => x,
10
9
  setName: (_x, name) => name,
11
10
  })).toEqual(['a', 'b', 'c']);
12
- (0, vitest_1.expect)((0, util_1.disambiguateNames)({
11
+ expect((0, util_1.disambiguateNames)({
13
12
  values: ['a', 'a', 'a'],
14
13
  getName: x => x,
15
14
  setName: (_x, name) => name,
16
15
  })).toEqual(['a', 'a1', 'a2']);
17
- (0, vitest_1.expect)((0, util_1.disambiguateNames)({
16
+ expect((0, util_1.disambiguateNames)({
18
17
  values: [
19
18
  { name: 'ExampleEvent', inputs: [] },
20
19
  { name: 'ExampleEvent', inputs: [{ type: 'uint256' }] },
@@ -31,13 +30,13 @@ vitest_1.describe.concurrent('Codegen utilities', () => {
31
30
  { name: 'ExampleEvent2', inputs: [{ type: 'uint96' }] },
32
31
  ]);
33
32
  });
34
- (0, vitest_1.test)('Tuple unrolling', () => {
35
- (0, vitest_1.expect)((0, util_1.unrollTuple)({
33
+ test('Tuple unrolling', () => {
34
+ expect((0, util_1.unrollTuple)({
36
35
  value: { type: 'tuple', name: 'value', components: [] },
37
36
  path: ['value'],
38
37
  index: 0,
39
38
  })).toEqual([]);
40
- (0, vitest_1.expect)((0, util_1.unrollTuple)({
39
+ expect((0, util_1.unrollTuple)({
41
40
  value: {
42
41
  type: 'tuple',
43
42
  name: 'value',
@@ -46,7 +45,7 @@ vitest_1.describe.concurrent('Codegen utilities', () => {
46
45
  path: ['value'],
47
46
  index: 0,
48
47
  })).toEqual([{ path: ['value', 'a'], type: 'string' }]);
49
- (0, vitest_1.expect)((0, util_1.unrollTuple)({
48
+ expect((0, util_1.unrollTuple)({
50
49
  value: {
51
50
  type: 'tuple',
52
51
  name: 'value',
@@ -61,7 +60,7 @@ vitest_1.describe.concurrent('Codegen utilities', () => {
61
60
  { path: ['value', 'a'], type: 'string' },
62
61
  { path: ['value', 'b'], type: 'uint256' },
63
62
  ]);
64
- (0, vitest_1.expect)((0, util_1.unrollTuple)({
63
+ expect((0, util_1.unrollTuple)({
65
64
  value: {
66
65
  type: 'tuple',
67
66
  name: 'value',
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const vitest_1 = require("vitest");
4
3
  const abi_1 = require("./abi");
5
4
  // An object with some test cases for contract deployment block numbers
6
5
  const TEST_CONTRACT_START_BLOCKS = {
@@ -83,13 +82,13 @@ const TEST_CONTRACT_START_BLOCKS = {
83
82
  // },
84
83
  };
85
84
  // skip this test since its time consuming
86
- vitest_1.describe.skip('getStartBlockForContract', () => {
85
+ describe.skip('getStartBlockForContract', () => {
87
86
  for (const [network, contracts] of Object.entries(TEST_CONTRACT_START_BLOCKS)) {
88
87
  for (const [contract, startBlockExp] of Object.entries(contracts)) {
89
- (0, vitest_1.test)(`Returns the start block ${network} ${contract} ${startBlockExp}`, async () => {
88
+ test(`Returns the start block ${network} ${contract} ${startBlockExp}`, async () => {
90
89
  //loop through the TEST_CONTRACT_START_BLOCKS object and test each network
91
90
  const startBlock = await (0, abi_1.getStartBlockForContract)(network, contract);
92
- (0, vitest_1.expect)(startBlock).toBe(startBlockExp);
91
+ expect(startBlock).toBe(startBlockExp);
93
92
  });
94
93
  }
95
94
  }
@@ -1,27 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const vitest_1 = require("vitest");
4
3
  const compiler_1 = require("./compiler");
5
- vitest_1.describe.concurrent('appendApiVersionForGraph', () => {
6
- (0, vitest_1.it)('append /api/v0 to Prod URL with trailing slash', () => {
7
- (0, vitest_1.expect)((0, compiler_1.appendApiVersionForGraph)('https://api.thegraph.com/ipfs/')).toBe('https://api.thegraph.com/ipfs/api/v0');
4
+ describe('appendApiVersionForGraph', () => {
5
+ it('append /api/v0 to Prod URL with trailing slash', () => {
6
+ expect((0, compiler_1.appendApiVersionForGraph)('https://api.thegraph.com/ipfs/')).toBe('https://api.thegraph.com/ipfs/api/v0');
8
7
  });
9
- (0, vitest_1.it)('append /api/v0 to Prod URL without trailing slash', () => {
10
- (0, vitest_1.expect)((0, compiler_1.appendApiVersionForGraph)('https://api.thegraph.com/ipfs')).toBe('https://api.thegraph.com/ipfs/api/v0');
8
+ it('append /api/v0 to Prod URL without trailing slash', () => {
9
+ expect((0, compiler_1.appendApiVersionForGraph)('https://api.thegraph.com/ipfs')).toBe('https://api.thegraph.com/ipfs/api/v0');
11
10
  });
12
- (0, vitest_1.it)('append /api/v0 to Staging URL without trailing slash', () => {
13
- (0, vitest_1.expect)((0, compiler_1.appendApiVersionForGraph)('https://staging.api.thegraph.com/ipfs')).toBe('https://staging.api.thegraph.com/ipfs/api/v0');
11
+ it('append /api/v0 to Staging URL without trailing slash', () => {
12
+ expect((0, compiler_1.appendApiVersionForGraph)('https://staging.api.thegraph.com/ipfs')).toBe('https://staging.api.thegraph.com/ipfs/api/v0');
14
13
  });
15
- (0, vitest_1.it)('do nothing if Prod URL has /api/v0', () => {
16
- (0, vitest_1.expect)((0, compiler_1.appendApiVersionForGraph)('https://api.thegraph.com/ipfs/api/v0')).toBe('https://api.thegraph.com/ipfs/api/v0');
14
+ it('do nothing if Prod URL has /api/v0', () => {
15
+ expect((0, compiler_1.appendApiVersionForGraph)('https://api.thegraph.com/ipfs/api/v0')).toBe('https://api.thegraph.com/ipfs/api/v0');
17
16
  });
18
- (0, vitest_1.it)('do nothing if Prod URL has no /ipfs', () => {
19
- (0, vitest_1.expect)((0, compiler_1.appendApiVersionForGraph)('https://api.thegraph.com')).toBe('https://api.thegraph.com');
17
+ it('do nothing if Prod URL has no /ipfs', () => {
18
+ expect((0, compiler_1.appendApiVersionForGraph)('https://api.thegraph.com')).toBe('https://api.thegraph.com');
20
19
  });
21
- (0, vitest_1.it)('do nothing for non-graph endpoint', () => {
22
- (0, vitest_1.expect)((0, compiler_1.appendApiVersionForGraph)('https://ipfs.saihaj.dev/')).toBe('https://ipfs.saihaj.dev/');
20
+ it('do nothing for non-graph endpoint', () => {
21
+ expect((0, compiler_1.appendApiVersionForGraph)('https://ipfs.saihaj.dev/')).toBe('https://ipfs.saihaj.dev/');
23
22
  });
24
- (0, vitest_1.it)('do nothing for non-graph endpoint ending with /ipfs', () => {
25
- (0, vitest_1.expect)((0, compiler_1.appendApiVersionForGraph)('https://ipfs.saihaj.dev/ipfs/')).toBe('https://ipfs.saihaj.dev/ipfs/');
23
+ it('do nothing for non-graph endpoint ending with /ipfs', () => {
24
+ expect((0, compiler_1.appendApiVersionForGraph)('https://ipfs.saihaj.dev/ipfs/')).toBe('https://ipfs.saihaj.dev/ipfs/');
26
25
  });
27
26
  });
@@ -28,21 +28,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  const path_1 = __importDefault(require("path"));
30
30
  const toolbox = __importStar(require("gluegun"));
31
- const vitest_1 = require("vitest");
32
31
  const yaml_1 = __importDefault(require("yaml"));
33
32
  const network_1 = require("./network");
34
33
  const SUBGRAPH_PATH_BASE = path_1.default.join(__dirname, '..', '..', '..', '..', 'examples', 'example-subgraph');
35
- vitest_1.describe.concurrent('initNetworksConfig', () => {
36
- (0, vitest_1.beforeAll)(async () => {
34
+ describe('initNetworksConfig', () => {
35
+ beforeAll(async () => {
37
36
  await (0, network_1.initNetworksConfig)(SUBGRAPH_PATH_BASE, 'address');
38
37
  });
39
- (0, vitest_1.afterAll)(async () => {
38
+ afterAll(async () => {
40
39
  toolbox.filesystem.remove(`${SUBGRAPH_PATH_BASE}/networks.json`);
41
40
  });
42
- (0, vitest_1.test)('generates networks.json from subgraph.yaml', () => {
43
- (0, vitest_1.expect)(toolbox.filesystem.exists(`${SUBGRAPH_PATH_BASE}/networks.json`)).toBe('file');
41
+ test('generates networks.json from subgraph.yaml', () => {
42
+ expect(toolbox.filesystem.exists(`${SUBGRAPH_PATH_BASE}/networks.json`)).toBe('file');
44
43
  });
45
- (0, vitest_1.test)('Populates the networks.json file with the data from subgraph.yaml', async () => {
44
+ test('Populates the networks.json file with the data from subgraph.yaml', async () => {
46
45
  const networksStr = toolbox.filesystem.read(`${SUBGRAPH_PATH_BASE}/networks.json`);
47
46
  const networks = JSON.parse(networksStr);
48
47
  const expected = {
@@ -50,11 +49,11 @@ vitest_1.describe.concurrent('initNetworksConfig', () => {
50
49
  ExampleSubgraph: { address: '0x22843e74c59580b3eaf6c233fa67d8b7c561a835' },
51
50
  },
52
51
  };
53
- (0, vitest_1.expect)(networks).toStrictEqual(expected);
52
+ expect(networks).toStrictEqual(expected);
54
53
  });
55
54
  });
56
- vitest_1.describe.concurrent('updateSubgraphNetwork', () => {
57
- (0, vitest_1.beforeAll)(async () => {
55
+ describe('updateSubgraphNetwork', () => {
56
+ beforeAll(async () => {
58
57
  const content = {
59
58
  optimism: {
60
59
  ExampleSubgraph: { address: '0x12345...' },
@@ -63,25 +62,25 @@ vitest_1.describe.concurrent('updateSubgraphNetwork', () => {
63
62
  toolbox.filesystem.write(`${SUBGRAPH_PATH_BASE}/networks.json`, content);
64
63
  toolbox.filesystem.copy(`${SUBGRAPH_PATH_BASE}/subgraph.yaml`, `${SUBGRAPH_PATH_BASE}/subgraph_copy.yaml`);
65
64
  });
66
- (0, vitest_1.afterAll)(async () => {
65
+ afterAll(async () => {
67
66
  toolbox.filesystem.remove(`${SUBGRAPH_PATH_BASE}/networks.json`);
68
67
  toolbox.filesystem.remove(`${SUBGRAPH_PATH_BASE}/subgraph_copy.yaml`);
69
68
  });
70
- (0, vitest_1.test)('Updates subgraph.yaml', async () => {
69
+ test('Updates subgraph.yaml', async () => {
71
70
  const manifest = `${SUBGRAPH_PATH_BASE}/subgraph_copy.yaml`;
72
71
  const networksFie = `${SUBGRAPH_PATH_BASE}/networks.json`;
73
72
  let subgraph = toolbox.filesystem.read(manifest);
74
73
  let subgraphObj = yaml_1.default.parse(subgraph);
75
74
  let network = subgraphObj.dataSources[0].network;
76
75
  let address = subgraphObj.dataSources[0].source.address;
77
- (0, vitest_1.expect)(network).toBe('mainnet');
78
- (0, vitest_1.expect)(address).toBe('0x22843e74c59580b3eaf6c233fa67d8b7c561a835');
76
+ expect(network).toBe('mainnet');
77
+ expect(address).toBe('0x22843e74c59580b3eaf6c233fa67d8b7c561a835');
79
78
  await (0, network_1.updateSubgraphNetwork)(manifest, 'optimism', networksFie, 'address');
80
79
  subgraph = toolbox.filesystem.read(manifest);
81
80
  subgraphObj = yaml_1.default.parse(subgraph);
82
81
  network = subgraphObj.dataSources[0].network;
83
82
  address = subgraphObj.dataSources[0].source.address;
84
- (0, vitest_1.expect)(network).toBe('optimism');
85
- (0, vitest_1.expect)(address).toBe('0x12345...');
83
+ expect(network).toBe('optimism');
84
+ expect(address).toBe('0x12345...');
86
85
  });
87
86
  });
@@ -15,26 +15,26 @@ export declare const generateScaffold: ({ protocolInstance, abi, contract, netwo
15
15
  node?: string | undefined;
16
16
  spkgPath?: string | undefined;
17
17
  }, spinner: Spinner) => Promise<{
18
- 'subgraph.yaml': string;
19
- 'schema.graphql': string;
20
- 'package.json': string;
18
+ 'subgraph.yaml': Promise<string>;
19
+ 'schema.graphql': Promise<string>;
20
+ 'package.json': Promise<string>;
21
21
  'tsconfig.json'?: undefined;
22
22
  src?: undefined;
23
23
  abis?: undefined;
24
24
  tests?: undefined;
25
25
  } | {
26
- 'package.json': string;
27
- 'subgraph.yaml': string;
28
- 'schema.graphql': string;
29
- 'tsconfig.json': string;
26
+ 'package.json': Promise<string>;
27
+ 'subgraph.yaml': Promise<string>;
28
+ 'schema.graphql': Promise<string>;
29
+ 'tsconfig.json': Promise<string>;
30
30
  src: {
31
- [x: string]: string;
31
+ [x: string]: Promise<string>;
32
32
  } | undefined;
33
33
  abis: {
34
- [x: string]: string;
34
+ [x: string]: Promise<string>;
35
35
  } | undefined;
36
36
  tests: {
37
- [x: string]: string;
37
+ [x: string]: Promise<string>;
38
38
  } | undefined;
39
39
  }>;
40
40
  export declare const writeScaffold: (scaffold: any, directory: string, spinner: Spinner) => Promise<void>;
@@ -42,7 +42,7 @@ const generateScaffold = async ({ protocolInstance, abi, contract, network, subg
42
42
  node,
43
43
  spkgPath,
44
44
  });
45
- return await scaffold.generate();
45
+ return scaffold.generate();
46
46
  };
47
47
  exports.generateScaffold = generateScaffold;
48
48
  const writeScaffoldDirectory = async (scaffold, directory, spinner) => {
@@ -70,7 +70,7 @@ const writeScaffold = async (scaffold, directory, spinner) => {
70
70
  };
71
71
  exports.writeScaffold = writeScaffold;
72
72
  const writeABI = async (abi, contractName) => {
73
- const data = await prettier_1.default.format(JSON.stringify(abi.data), {
73
+ const data = prettier_1.default.format(JSON.stringify(abi.data), {
74
74
  parser: 'json',
75
75
  });
76
76
  await fs_extra_1.default.writeFile(`./abis/${contractName}.json`, data, 'utf-8');
@@ -82,7 +82,7 @@ const writeSchema = async (abi, protocol, schemaPath, entities, contractName) =>
82
82
  .filter(event => !entities.includes(event.get('name')))
83
83
  .toJS()
84
84
  : [];
85
- const data = await prettier_1.default.format(events.map(event => (0, schema_1.generateEventType)(event, protocol.name, contractName)).join('\n\n'), {
85
+ const data = prettier_1.default.format(events.map(event => (0, schema_1.generateEventType)(event, protocol.name, contractName)).join('\n\n'), {
86
86
  parser: 'graphql',
87
87
  });
88
88
  await fs_extra_1.default.appendFile(schemaPath, data, { encoding: 'utf-8' });
@@ -94,7 +94,7 @@ const writeMapping = async (abi, protocol, contractName, entities) => {
94
94
  .filter(event => !entities.includes(event.get('name')))
95
95
  .toJS()
96
96
  : [];
97
- const mapping = await prettier_1.default.format((0, mapping_1.generateEventIndexingHandlers)(events, contractName), {
97
+ const mapping = prettier_1.default.format((0, mapping_1.generateEventIndexingHandlers)(events, contractName), {
98
98
  parser: 'typescript',
99
99
  semi: false,
100
100
  });
@@ -107,7 +107,7 @@ const writeTestsFiles = async (abi, protocol, contractName) => {
107
107
  if (events.length > 0) {
108
108
  // If a contract is added to a subgraph that has no tests folder
109
109
  await fs_extra_1.default.ensureDir('./tests/');
110
- const testsFiles = await (0, tests_1.generateTestsFiles)(contractName, events, true);
110
+ const testsFiles = (0, tests_1.generateTestsFiles)(contractName, events, true);
111
111
  for (const [fileName, content] of Object.entries(testsFiles)) {
112
112
  await fs_extra_1.default.writeFile(`./tests/${fileName}`, content, 'utf-8');
113
113
  }
@@ -23,53 +23,53 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- const vitest_1 = require("vitest");
27
- const loadManifestUtils = __importStar(require("../migrations/util/load-manifest"));
26
+ const loadManifestUtil = __importStar(require("../migrations/util/load-manifest"));
28
27
  const graphTsUtil = __importStar(require("../migrations/util/versions"));
29
28
  const version_1 = require("./version");
30
- vitest_1.describe.concurrent('Version Command Helpers', () => {
31
- (0, vitest_1.beforeEach)(() => {
32
- vitest_1.vi.resetModules();
33
- });
34
- (0, vitest_1.describe)('assertManifestApiVersion', () => {
29
+ describe('Version Command Helpers', () => {
30
+ describe('assertManifestApiVersion', () => {
35
31
  const fakeManifestPath = 'fake/manifest/path';
36
32
  const minimumApiVersion = '0.0.5';
37
- (0, vitest_1.describe)('With just dataSources', () => {
38
- (0, vitest_1.test)('When all of them are less than minimum apiVersion', async () => {
39
- vitest_1.vi.spyOn(loadManifestUtils, 'loadManifest').mockImplementation(() => Promise.resolve({
33
+ describe('With just dataSources', () => {
34
+ test('When all of them are less than minimum apiVersion', async () => {
35
+ // @ts-expect-error TODO: dont pollute the globals
36
+ loadManifestUtil.loadManifest = jest.fn().mockImplementation(() => Promise.resolve({
40
37
  dataSources: [
41
38
  { mapping: { apiVersion: '0.0.1' } },
42
39
  { mapping: { apiVersion: '0.0.2' } },
43
40
  { mapping: { apiVersion: '0.0.3' } },
44
41
  ],
45
42
  }));
46
- await (0, vitest_1.expect)((0, version_1.assertManifestApiVersion)(fakeManifestPath, minimumApiVersion)).rejects.toThrow(new Error(`The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`));
43
+ await expect((0, version_1.assertManifestApiVersion)(fakeManifestPath, minimumApiVersion)).rejects.toThrow(new Error(`The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`));
47
44
  });
48
- (0, vitest_1.test)('When one of them is less than minimum apiVersion', async () => {
49
- vitest_1.vi.spyOn(loadManifestUtils, 'loadManifest').mockImplementation(() => Promise.resolve({
45
+ test('When one of them is less than minimum apiVersion', async () => {
46
+ // @ts-expect-error TODO: dont pollute the globals
47
+ loadManifestUtil.loadManifest = jest.fn().mockImplementation(() => Promise.resolve({
50
48
  dataSources: [
51
49
  { mapping: { apiVersion: '0.0.5' } },
52
50
  { mapping: { apiVersion: '0.0.2' } },
53
51
  { mapping: { apiVersion: '0.0.5' } },
54
52
  ],
55
53
  }));
56
- await (0, vitest_1.expect)((0, version_1.assertManifestApiVersion)(fakeManifestPath, minimumApiVersion)).rejects.toThrow(new Error(`The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`));
54
+ await expect((0, version_1.assertManifestApiVersion)(fakeManifestPath, minimumApiVersion)).rejects.toThrow(new Error(`The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`));
57
55
  });
58
- (0, vitest_1.test)('When none of them are less than minimum apiVersion', async () => {
59
- vitest_1.vi.spyOn(loadManifestUtils, 'loadManifest').mockImplementation(() => Promise.resolve({
56
+ test('When none of them are less than minimum apiVersion', async () => {
57
+ // @ts-expect-error TODO: dont pollute the globals
58
+ loadManifestUtil.loadManifest = jest.fn().mockImplementation(() => Promise.resolve({
60
59
  dataSources: [
61
60
  { mapping: { apiVersion: '0.0.5' } },
62
61
  { mapping: { apiVersion: '0.0.6' } },
63
62
  { mapping: { apiVersion: '0.0.5' } },
64
63
  ],
65
64
  }));
66
- await (0, vitest_1.expect)((0, version_1.assertManifestApiVersion)(fakeManifestPath, minimumApiVersion)).resolves.toBe(undefined);
65
+ await expect((0, version_1.assertManifestApiVersion)(fakeManifestPath, minimumApiVersion)).resolves.toBe(undefined);
67
66
  });
68
67
  });
69
- (0, vitest_1.describe)('With dataSources and templates', () => {
70
- (0, vitest_1.describe)('And the dataSources have a lower apiVersion', () => {
71
- (0, vitest_1.test)('When all of the templates are less than minimum apiVersion', async () => {
72
- vitest_1.vi.spyOn(loadManifestUtils, 'loadManifest').mockImplementation(() => Promise.resolve({
68
+ describe('With dataSources and templates', () => {
69
+ describe('And the dataSources have a lower apiVersion', () => {
70
+ test('When all of the templates are less than minimum apiVersion', async () => {
71
+ // @ts-expect-error TODO: dont pollute the globals
72
+ loadManifestUtil.loadManifest = jest.fn().mockImplementation(() => Promise.resolve({
73
73
  dataSources: [
74
74
  { mapping: { apiVersion: '0.0.5' } },
75
75
  { mapping: { apiVersion: '0.0.5' } },
@@ -81,10 +81,11 @@ vitest_1.describe.concurrent('Version Command Helpers', () => {
81
81
  { mapping: { apiVersion: '0.0.3' } },
82
82
  ],
83
83
  }));
84
- await (0, vitest_1.expect)((0, version_1.assertManifestApiVersion)(fakeManifestPath, minimumApiVersion)).rejects.toThrow(new Error(`The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`));
84
+ await expect((0, version_1.assertManifestApiVersion)(fakeManifestPath, minimumApiVersion)).rejects.toThrow(new Error(`The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`));
85
85
  });
86
- (0, vitest_1.test)('When one of the templates is less than minimum apiVersion', async () => {
87
- vitest_1.vi.spyOn(loadManifestUtils, 'loadManifest').mockImplementation(() => Promise.resolve({
86
+ test('When one of the templates is less than minimum apiVersion', async () => {
87
+ // @ts-expect-error TODO: dont pollute the globals
88
+ loadManifestUtil.loadManifest = jest.fn().mockImplementation(() => Promise.resolve({
88
89
  dataSources: [
89
90
  { mapping: { apiVersion: '0.0.5' } },
90
91
  { mapping: { apiVersion: '0.0.5' } },
@@ -96,10 +97,11 @@ vitest_1.describe.concurrent('Version Command Helpers', () => {
96
97
  { mapping: { apiVersion: '0.0.5' } },
97
98
  ],
98
99
  }));
99
- await (0, vitest_1.expect)((0, version_1.assertManifestApiVersion)(fakeManifestPath, minimumApiVersion)).rejects.toThrow(new Error(`The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`));
100
+ await expect((0, version_1.assertManifestApiVersion)(fakeManifestPath, minimumApiVersion)).rejects.toThrow(new Error(`The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`));
100
101
  });
101
- (0, vitest_1.test)('When none of the templates are less than minimum apiVersion', async () => {
102
- vitest_1.vi.spyOn(loadManifestUtils, 'loadManifest').mockImplementation(() => Promise.resolve({
102
+ test('When none of the templates are less than minimum apiVersion', async () => {
103
+ // @ts-expect-error TODO: dont pollute the globals
104
+ loadManifestUtil.loadManifest = jest.fn().mockImplementation(() => Promise.resolve({
103
105
  dataSources: [
104
106
  { mapping: { apiVersion: '0.0.5' } },
105
107
  { mapping: { apiVersion: '0.0.5' } },
@@ -111,12 +113,13 @@ vitest_1.describe.concurrent('Version Command Helpers', () => {
111
113
  { mapping: { apiVersion: '0.0.5' } },
112
114
  ],
113
115
  }));
114
- await (0, vitest_1.expect)((0, version_1.assertManifestApiVersion)(fakeManifestPath, minimumApiVersion)).rejects.toThrow(new Error(`The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`));
116
+ await expect((0, version_1.assertManifestApiVersion)(fakeManifestPath, minimumApiVersion)).rejects.toThrow(new Error(`The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`));
115
117
  });
116
118
  });
117
- (0, vitest_1.describe)('And the dataSources do NOT have a lower apiVersion', () => {
118
- (0, vitest_1.test)('When all of the templates are less than minimum apiVersion', async () => {
119
- vitest_1.vi.spyOn(loadManifestUtils, 'loadManifest').mockImplementation(() => Promise.resolve({
119
+ describe('And the dataSources do NOT have a lower apiVersion', () => {
120
+ test('When all of the templates are less than minimum apiVersion', async () => {
121
+ // @ts-expect-error TODO: dont pollute the globals
122
+ loadManifestUtil.loadManifest = jest.fn().mockImplementation(() => Promise.resolve({
120
123
  dataSources: [
121
124
  { mapping: { apiVersion: '0.0.5' } },
122
125
  { mapping: { apiVersion: '0.0.5' } },
@@ -128,10 +131,11 @@ vitest_1.describe.concurrent('Version Command Helpers', () => {
128
131
  { mapping: { apiVersion: '0.0.3' } },
129
132
  ],
130
133
  }));
131
- await (0, vitest_1.expect)((0, version_1.assertManifestApiVersion)(fakeManifestPath, minimumApiVersion)).rejects.toThrow(new Error(`The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`));
134
+ await expect((0, version_1.assertManifestApiVersion)(fakeManifestPath, minimumApiVersion)).rejects.toThrow(new Error(`The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`));
132
135
  });
133
- (0, vitest_1.test)('When one of the templates is less than minimum apiVersion', async () => {
134
- vitest_1.vi.spyOn(loadManifestUtils, 'loadManifest').mockImplementation(() => Promise.resolve({
136
+ test('When one of the templates is less than minimum apiVersion', async () => {
137
+ // @ts-expect-error TODO: dont pollute the globals
138
+ loadManifestUtil.loadManifest = jest.fn().mockImplementation(() => Promise.resolve({
135
139
  dataSources: [
136
140
  { mapping: { apiVersion: '0.0.5' } },
137
141
  { mapping: { apiVersion: '0.0.5' } },
@@ -143,10 +147,11 @@ vitest_1.describe.concurrent('Version Command Helpers', () => {
143
147
  { mapping: { apiVersion: '0.0.5' } },
144
148
  ],
145
149
  }));
146
- await (0, vitest_1.expect)((0, version_1.assertManifestApiVersion)(fakeManifestPath, minimumApiVersion)).rejects.toThrow(new Error(`The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`));
150
+ await expect((0, version_1.assertManifestApiVersion)(fakeManifestPath, minimumApiVersion)).rejects.toThrow(new Error(`The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`));
147
151
  });
148
- (0, vitest_1.test)('When none of the templates are less than minimum apiVersion', async () => {
149
- vitest_1.vi.spyOn(loadManifestUtils, 'loadManifest').mockImplementation(() => Promise.resolve({
152
+ test('When none of the templates are less than minimum apiVersion', async () => {
153
+ // @ts-expect-error TODO: dont pollute the globals
154
+ loadManifestUtil.loadManifest = jest.fn().mockImplementation(() => Promise.resolve({
150
155
  dataSources: [
151
156
  { mapping: { apiVersion: '0.0.5' } },
152
157
  { mapping: { apiVersion: '0.0.5' } },
@@ -158,22 +163,24 @@ vitest_1.describe.concurrent('Version Command Helpers', () => {
158
163
  { mapping: { apiVersion: '0.0.5' } },
159
164
  ],
160
165
  }));
161
- await (0, vitest_1.expect)((0, version_1.assertManifestApiVersion)(fakeManifestPath, minimumApiVersion)).resolves.toBe(undefined);
166
+ await expect((0, version_1.assertManifestApiVersion)(fakeManifestPath, minimumApiVersion)).resolves.toBe(undefined);
162
167
  });
163
168
  });
164
169
  });
165
170
  });
166
- (0, vitest_1.describe)('assertGraphTsVersion', () => {
171
+ describe('assertGraphTsVersion', () => {
167
172
  const fakeNodeModulesDir = 'fake/path/to/node/modules';
168
173
  const minimumGraphTsVersion = '0.22.0';
169
- (0, vitest_1.test)("When the installed graph-ts version is less than what's supported", async () => {
170
- vitest_1.vi.spyOn(graphTsUtil, 'getGraphTsVersion').mockImplementation(() => Promise.resolve('0.19.0'));
171
- await (0, vitest_1.expect)((0, version_1.assertGraphTsVersion)(fakeNodeModulesDir, minimumGraphTsVersion)).rejects.toThrow(new Error(`To use this version of the graph-cli you must upgrade the graph-ts dependency to a version greater than or equal to ${minimumGraphTsVersion}
174
+ test("When the installed graph-ts version is less than what's supported", async () => {
175
+ // @ts-expect-error TODO: dont pollute the globals
176
+ graphTsUtil.getGraphTsVersion = jest.fn().mockImplementation(() => Promise.resolve('0.19.0'));
177
+ await expect((0, version_1.assertGraphTsVersion)(fakeNodeModulesDir, minimumGraphTsVersion)).rejects.toThrow(new Error(`To use this version of the graph-cli you must upgrade the graph-ts dependency to a version greater than or equal to ${minimumGraphTsVersion}
172
178
  Also, you'll probably need to take a look at our AssemblyScript migration guide because of language breaking changes: https://thegraph.com/docs/developer/assemblyscript-migration-guide`));
173
179
  });
174
- (0, vitest_1.test)('When the installed graph-ts version is a supported one', async () => {
175
- vitest_1.vi.spyOn(graphTsUtil, 'getGraphTsVersion').mockImplementation(() => Promise.resolve('0.22.0'));
176
- await (0, vitest_1.expect)((0, version_1.assertGraphTsVersion)(fakeNodeModulesDir, minimumGraphTsVersion)).resolves.toBe(undefined);
180
+ test('When the installed graph-ts version is a supported one', async () => {
181
+ // @ts-expect-error TODO: dont pollute the globals
182
+ graphTsUtil.getGraphTsVersion = jest.fn().mockImplementation(() => Promise.resolve('0.22.0'));
183
+ await expect((0, version_1.assertGraphTsVersion)(fakeNodeModulesDir, minimumGraphTsVersion)).resolves.toBe(undefined);
177
184
  });
178
185
  });
179
186
  });
@@ -29,15 +29,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
29
29
  const path_1 = __importDefault(require("path"));
30
30
  const fs_extra_1 = __importDefault(require("fs-extra"));
31
31
  const immutable_1 = __importDefault(require("immutable"));
32
- const vitest_1 = require("vitest");
33
32
  const ts = __importStar(require("../../../codegen/typescript"));
34
33
  const abi_1 = __importDefault(require("../abi"));
35
34
  const abi_2 = __importDefault(require("./abi"));
36
35
  let tempdir;
37
36
  let abi;
38
37
  let generatedTypes;
39
- vitest_1.describe.concurrent('ABI code generation', () => {
40
- (0, vitest_1.beforeAll)(async () => {
38
+ describe('ABI code generation', () => {
39
+ beforeAll(async () => {
41
40
  tempdir = await fs_extra_1.default.mkdtemp('abi-codegen');
42
41
  try {
43
42
  const filename = path_1.default.join(tempdir, 'ABI.json');
@@ -195,12 +194,12 @@ vitest_1.describe.concurrent('ABI code generation', () => {
195
194
  await fs_extra_1.default.remove(tempdir);
196
195
  }
197
196
  });
198
- (0, vitest_1.afterAll)(async () => {
197
+ afterAll(async () => {
199
198
  await fs_extra_1.default.remove(tempdir);
200
199
  });
201
- (0, vitest_1.describe)('Generated types', () => {
202
- (0, vitest_1.test)('All expected types are generated', () => {
203
- (0, vitest_1.expect)(generatedTypes.map(type => type.name)).toEqual([
200
+ describe('Generated types', () => {
201
+ test('All expected types are generated', () => {
202
+ expect(generatedTypes.map(type => type.name)).toEqual([
204
203
  'Contract__getProposalResultValue0Struct',
205
204
  'Contract__getProposalInputParam1Struct',
206
205
  'Contract__getProposalInputParam1BarStruct',
@@ -210,27 +209,27 @@ vitest_1.describe.concurrent('ABI code generation', () => {
210
209
  ]);
211
210
  });
212
211
  });
213
- (0, vitest_1.describe)('Contract class', () => {
214
- (0, vitest_1.test)('Exists', () => {
215
- (0, vitest_1.expect)(generatedTypes.find(type => type.name === 'Contract')).toBeDefined();
212
+ describe('Contract class', () => {
213
+ test('Exists', () => {
214
+ expect(generatedTypes.find(type => type.name === 'Contract')).toBeDefined();
216
215
  });
217
- (0, vitest_1.test)('Has methods', () => {
216
+ test('Has methods', () => {
218
217
  const contract = generatedTypes.find(type => type.name === 'Contract');
219
- (0, vitest_1.expect)(contract.methods).toBeInstanceOf(Array);
218
+ expect(contract.methods).toBeInstanceOf(Array);
220
219
  });
221
- (0, vitest_1.test)('Has `bind` method', () => {
220
+ test('Has `bind` method', () => {
222
221
  const contract = generatedTypes.find(type => type.name === 'Contract');
223
- (0, vitest_1.expect)(contract.methods.find((method) => method.name === 'bind')).toBeDefined();
222
+ expect(contract.methods.find((method) => method.name === 'bind')).toBeDefined();
224
223
  });
225
- (0, vitest_1.test)('Has methods for all callable functions', () => {
224
+ test('Has methods for all callable functions', () => {
226
225
  const contract = generatedTypes.find(type => type.name === 'Contract');
227
- (0, vitest_1.expect)(contract.methods.map((method) => method.name)).toContain('getProposal');
226
+ expect(contract.methods.map((method) => method.name)).toContain('getProposal');
228
227
  });
229
228
  });
230
- (0, vitest_1.describe)('Methods for callable functions', () => {
231
- (0, vitest_1.test)('Have correct parameters', () => {
229
+ describe('Methods for callable functions', () => {
230
+ test('Have correct parameters', () => {
232
231
  const contract = generatedTypes.find(type => type.name === 'Contract');
233
- (0, vitest_1.expect)(contract.methods.map((method) => [method.name, method.params])).toEqual([
232
+ expect(contract.methods.map((method) => [method.name, method.params])).toEqual([
234
233
  ['bind', immutable_1.default.List([ts.param('address', 'Address')])],
235
234
  ['read', immutable_1.default.List()],
236
235
  ['try_read', immutable_1.default.List()],
@@ -258,9 +257,9 @@ vitest_1.describe.concurrent('ABI code generation', () => {
258
257
  ['try_overloaded2', immutable_1.default.List([ts.param('param0', 'Bytes')])],
259
258
  ]);
260
259
  });
261
- (0, vitest_1.test)('Have correct return types', () => {
260
+ test('Have correct return types', () => {
262
261
  const contract = generatedTypes.find(type => type.name === 'Contract');
263
- (0, vitest_1.expect)(contract.methods.map((method) => [method.name, method.returnType])).toEqual([
262
+ expect(contract.methods.map((method) => [method.name, method.returnType])).toEqual([
264
263
  ['bind', ts.namedType('Contract')],
265
264
  ['read', ts.namedType('Bytes')],
266
265
  ['try_read', 'ethereum.CallResult<Bytes>'],
@@ -277,34 +276,34 @@ vitest_1.describe.concurrent('ABI code generation', () => {
277
276
  ]);
278
277
  });
279
278
  });
280
- (0, vitest_1.describe)('Tuples', () => {
281
- (0, vitest_1.test)('Tuple types exist for function parameters', () => {
279
+ describe('Tuples', () => {
280
+ test('Tuple types exist for function parameters', () => {
282
281
  let tupleType = generatedTypes.find(type => type.name === 'Contract__getProposalInputParam1Struct');
283
282
  // Verify that the tuple type has methods
284
- (0, vitest_1.expect)(tupleType.methods).toBeDefined();
283
+ expect(tupleType.methods).toBeDefined();
285
284
  // Verify that the tuple type has getters for all tuple fields with
286
285
  // the right return types
287
- (0, vitest_1.expect)(tupleType.methods.map((method) => [method.name, method.returnType])).toEqual([
286
+ expect(tupleType.methods.map((method) => [method.name, method.returnType])).toEqual([
288
287
  ['get foo', 'i32'],
289
288
  ['get bar', 'Contract__getProposalInputParam1BarStruct'],
290
289
  ]);
291
290
  // Inner tuple:
292
291
  tupleType = generatedTypes.find(type => type.name === 'Contract__getProposalInputParam1BarStruct');
293
292
  // Verify that the tuple type has methods
294
- (0, vitest_1.expect)(tupleType.methods).toBeDefined();
293
+ expect(tupleType.methods).toBeDefined();
295
294
  // Verify that the tuple type has getters for all tuple fields with
296
295
  // the right return types
297
- (0, vitest_1.expect)(tupleType.methods.map((method) => [method.name, method.returnType])).toEqual([
296
+ expect(tupleType.methods.map((method) => [method.name, method.returnType])).toEqual([
298
297
  ['get baz', 'Address'],
299
298
  ]);
300
299
  });
301
- (0, vitest_1.test)('Tuple types exist for function return values', () => {
300
+ test('Tuple types exist for function return values', () => {
302
301
  const tupleType = generatedTypes.find(type => type.name === 'Contract__getProposalResultValue0Struct');
303
302
  // Verify that the tuple type has methods
304
- (0, vitest_1.expect)(tupleType.methods).toBeDefined();
303
+ expect(tupleType.methods).toBeDefined();
305
304
  // Verify that the tuple type has getters for all tuple fields with
306
305
  // the right return types
307
- (0, vitest_1.expect)(tupleType.methods.map((method) => [method.name, method.returnType])).toEqual([
306
+ expect(tupleType.methods.map((method) => [method.name, method.returnType])).toEqual([
308
307
  ['get result', 'i32'],
309
308
  ['get target', 'Address'],
310
309
  ['get data', 'Bytes'],
@@ -316,11 +315,11 @@ vitest_1.describe.concurrent('ABI code generation', () => {
316
315
  ['get noCount', 'BigInt'],
317
316
  ]);
318
317
  });
319
- (0, vitest_1.test)('Function bodies are generated correctly for tuple arrays', () => {
318
+ test('Function bodies are generated correctly for tuple arrays', () => {
320
319
  const contract = generatedTypes.find(type => type.name === 'Contract');
321
320
  const getter = contract.methods.find((method) => method.name === 'getProposals');
322
- (0, vitest_1.expect)(getter.body).not.toContain('toTupleArray<undefined>');
323
- (0, vitest_1.expect)(getter.body).toContain('result[1].toTupleArray<Contract__getProposalsResultValue1Struct>()');
321
+ expect(getter.body).not.toContain('toTupleArray<undefined>');
322
+ expect(getter.body).toContain('result[1].toTupleArray<Contract__getProposalsResultValue1Struct>()');
324
323
  });
325
324
  });
326
325
  });