@graphprotocol/graph-cli 0.70.0 → 0.71.0-alpha-20240423051530-6bf79b9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/command-helpers/abi.js +16 -0
- package/dist/command-helpers/sort.d.ts +17 -0
- package/dist/command-helpers/sort.js +41 -0
- package/dist/command-helpers/sort.test.d.ts +1 -0
- package/dist/command-helpers/sort.test.js +33 -0
- package/dist/commands/init.js +4 -2
- package/dist/protocols/ethereum/manifest.graphql +3 -0
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @graphprotocol/graph-cli
|
|
2
2
|
|
|
3
|
+
## 0.71.0-alpha-20240423051530-6bf79b9
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#1598](https://github.com/graphprotocol/graph-tooling/pull/1598)
|
|
8
|
+
[`7d4208a`](https://github.com/graphprotocol/graph-tooling/commit/7d4208aa1a1d376d7b230df7d86d9ec5864e18a8)
|
|
9
|
+
Thanks [@incrypto32](https://github.com/incrypto32)! - Allow topic filters in event handlers
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#1634](https://github.com/graphprotocol/graph-tooling/pull/1634)
|
|
14
|
+
[`f256475`](https://github.com/graphprotocol/graph-tooling/commit/f2564757ba8007025f8745c9162ba4143ff58548)
|
|
15
|
+
Thanks [@joshuanazareth97](https://github.com/joshuanazareth97)! - Order list of evm chains in
|
|
16
|
+
graph init command
|
|
17
|
+
|
|
3
18
|
## 0.70.0
|
|
4
19
|
|
|
5
20
|
### Minor Changes
|
|
@@ -192,6 +192,14 @@ const getEtherscanLikeAPIUrl = (network) => {
|
|
|
192
192
|
return `https://api.routescan.io/v2/network/mainnet/evm/81457/etherscan/api`;
|
|
193
193
|
case 'etherlink-testnet':
|
|
194
194
|
return `https://testnet-explorer.etherlink.com/api`;
|
|
195
|
+
case 'polygon-amoy':
|
|
196
|
+
return `https://api-amoy.polygonscan.com/api`;
|
|
197
|
+
case 'gnosis-chiado':
|
|
198
|
+
return `https://gnosis-chiado.blockscout.com/api`;
|
|
199
|
+
case 'mode-mainnet':
|
|
200
|
+
return `https://explorer.mode.network/api`;
|
|
201
|
+
case 'mode-sepolia':
|
|
202
|
+
return `https://sepolia.explorer.mode.network/api`;
|
|
195
203
|
default:
|
|
196
204
|
return `https://api-${network}.etherscan.io/api`;
|
|
197
205
|
}
|
|
@@ -288,6 +296,14 @@ const getPublicRPCEndpoint = (network) => {
|
|
|
288
296
|
return 'https://sepolia.optimism.io';
|
|
289
297
|
case 'etherlink-testnet':
|
|
290
298
|
return `https://node.ghostnet.etherlink.com`;
|
|
299
|
+
case 'polygon-amoy':
|
|
300
|
+
return `https://rpc-amoy.polygon.technology`;
|
|
301
|
+
case 'gnosis-chiado':
|
|
302
|
+
return `https://rpc.chiadochain.net`;
|
|
303
|
+
case 'mode-mainnet':
|
|
304
|
+
return `https://mainnet.mode.network`;
|
|
305
|
+
case 'mode-sepolia':
|
|
306
|
+
return `https://sepolia.mode.network`;
|
|
291
307
|
default:
|
|
292
308
|
throw new Error(`Unknown network: ${network}`);
|
|
293
309
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sorts an array with specified elements given priority.
|
|
3
|
+
* Use a predicate function, or provide an array to prioritise elements.
|
|
4
|
+
* If no compare function is provided, default JS sorting (ascending) behaviour prevails.
|
|
5
|
+
*
|
|
6
|
+
* @param {T[]} array - The array to be sorted.
|
|
7
|
+
* @param {((element: T) => boolean) | T[]} prioritySpecifier - A function that returns true if an element should be prioritized, or an array of elements to be prioritized.
|
|
8
|
+
* @param {(a: T, b: T) => number} [compareFunction] - An optional comparison function to sort the elements of the array. If omitted, the array is sorted in default order.
|
|
9
|
+
* @returns {T[]} The sorted array with priority elements first.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const numbers = [5, 3, 9, 1, 4];
|
|
13
|
+
* sortWithPriority(numbers, x => x > 5); // [9, 1, 3, 4, 5]
|
|
14
|
+
* sortWithPriority(numbers, [9, 1]); // [1, 9, 3, 4, 5]
|
|
15
|
+
*/
|
|
16
|
+
declare function sortWithPriority<T>(array: T[], prioritySpecifier?: ((element: T) => boolean) | T[], compareFunction?: (a: T, b: T) => number): T[];
|
|
17
|
+
export { sortWithPriority };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sortWithPriority = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Sorts an array with specified elements given priority.
|
|
6
|
+
* Use a predicate function, or provide an array to prioritise elements.
|
|
7
|
+
* If no compare function is provided, default JS sorting (ascending) behaviour prevails.
|
|
8
|
+
*
|
|
9
|
+
* @param {T[]} array - The array to be sorted.
|
|
10
|
+
* @param {((element: T) => boolean) | T[]} prioritySpecifier - A function that returns true if an element should be prioritized, or an array of elements to be prioritized.
|
|
11
|
+
* @param {(a: T, b: T) => number} [compareFunction] - An optional comparison function to sort the elements of the array. If omitted, the array is sorted in default order.
|
|
12
|
+
* @returns {T[]} The sorted array with priority elements first.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const numbers = [5, 3, 9, 1, 4];
|
|
16
|
+
* sortWithPriority(numbers, x => x > 5); // [9, 1, 3, 4, 5]
|
|
17
|
+
* sortWithPriority(numbers, [9, 1]); // [1, 9, 3, 4, 5]
|
|
18
|
+
*/
|
|
19
|
+
function sortWithPriority(array, prioritySpecifier, compareFunction) {
|
|
20
|
+
// prioritySpecifier can be an array or a function so handle each case
|
|
21
|
+
let isPriorityElement;
|
|
22
|
+
if (Array.isArray(prioritySpecifier) || !prioritySpecifier) {
|
|
23
|
+
const prioritySet = new Set(prioritySpecifier ?? []);
|
|
24
|
+
isPriorityElement = (element) => prioritySet.has(element);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
isPriorityElement = prioritySpecifier;
|
|
28
|
+
}
|
|
29
|
+
const priorityArray = array.filter(isPriorityElement);
|
|
30
|
+
const regularArray = array.filter(item => !isPriorityElement(item));
|
|
31
|
+
if (compareFunction) {
|
|
32
|
+
priorityArray.sort(compareFunction);
|
|
33
|
+
regularArray.sort(compareFunction);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
priorityArray.sort();
|
|
37
|
+
regularArray.sort();
|
|
38
|
+
}
|
|
39
|
+
return priorityArray.concat(regularArray);
|
|
40
|
+
}
|
|
41
|
+
exports.sortWithPriority = sortWithPriority;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const sort_1 = require("./sort"); // adjust the import based on your file structure
|
|
5
|
+
(0, vitest_1.describe)('sortWithPriority', () => {
|
|
6
|
+
(0, vitest_1.it)('should sort numbers with specific priority elements', () => {
|
|
7
|
+
const numbers = [5, 3, 9, 1, 4];
|
|
8
|
+
const priorityNumbers = [9, 1];
|
|
9
|
+
const result = (0, sort_1.sortWithPriority)(numbers, priorityNumbers);
|
|
10
|
+
(0, vitest_1.expect)(result).toEqual([1, 9, 3, 4, 5]);
|
|
11
|
+
});
|
|
12
|
+
(0, vitest_1.it)('should default sort numbers if no priority specifier', () => {
|
|
13
|
+
const numbers = [5, 3, 9, 1, 4];
|
|
14
|
+
const result = (0, sort_1.sortWithPriority)(numbers);
|
|
15
|
+
(0, vitest_1.expect)(result).toEqual([1, 3, 4, 5, 9]);
|
|
16
|
+
});
|
|
17
|
+
(0, vitest_1.it)('should sort strings with priority determined by a function', () => {
|
|
18
|
+
const fruits = ['apple', 'orange', 'banana', 'mango', 'kiwi', 'melon'];
|
|
19
|
+
const sortedFruits = (0, sort_1.sortWithPriority)(fruits, fruit => fruit.startsWith('m'));
|
|
20
|
+
(0, vitest_1.expect)(sortedFruits).toEqual(['mango', 'melon', 'apple', 'banana', 'kiwi', 'orange']);
|
|
21
|
+
});
|
|
22
|
+
(0, vitest_1.it)('should handle an empty array', () => {
|
|
23
|
+
const emptyArray = [];
|
|
24
|
+
const result = (0, sort_1.sortWithPriority)(emptyArray, x => x > 3);
|
|
25
|
+
(0, vitest_1.expect)(result).toEqual([]);
|
|
26
|
+
});
|
|
27
|
+
(0, vitest_1.it)('should sort using a custom compare function', () => {
|
|
28
|
+
const numbers = [5, 3, 9, 1, 4];
|
|
29
|
+
const priorityNumbers = [9, 1];
|
|
30
|
+
const result = (0, sort_1.sortWithPriority)(numbers, priorityNumbers, (a, b) => a - b);
|
|
31
|
+
(0, vitest_1.expect)(result).toEqual([1, 9, 3, 4, 5]);
|
|
32
|
+
});
|
|
33
|
+
});
|
package/dist/commands/init.js
CHANGED
|
@@ -29,13 +29,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
const fs_1 = __importDefault(require("fs"));
|
|
30
30
|
const os_1 = __importDefault(require("os"));
|
|
31
31
|
const path_1 = __importDefault(require("path"));
|
|
32
|
-
const gluegun_1 = require("gluegun");
|
|
33
32
|
const toolbox = __importStar(require("gluegun"));
|
|
33
|
+
const gluegun_1 = require("gluegun");
|
|
34
34
|
const core_1 = require("@oclif/core");
|
|
35
35
|
const abi_1 = require("../command-helpers/abi");
|
|
36
36
|
const network_1 = require("../command-helpers/network");
|
|
37
37
|
const node_1 = require("../command-helpers/node");
|
|
38
38
|
const scaffold_1 = require("../command-helpers/scaffold");
|
|
39
|
+
const sort_1 = require("../command-helpers/sort");
|
|
39
40
|
const spinner_1 = require("../command-helpers/spinner");
|
|
40
41
|
const subgraph_1 = require("../command-helpers/subgraph");
|
|
41
42
|
const constants_1 = require("../constants");
|
|
@@ -501,10 +502,11 @@ async function processInitForm({ protocol: initProtocol, product: initProduct, s
|
|
|
501
502
|
: true,
|
|
502
503
|
},
|
|
503
504
|
]);
|
|
504
|
-
|
|
505
|
+
let choices = (await AVAILABLE_NETWORKS())?.[product === 'subgraph-studio' ? 'studio' : 'hostedService'];
|
|
505
506
|
if (!choices) {
|
|
506
507
|
this.error('Unable to fetch available networks from API. Please report this issue. As a workaround you can pass `--network` flag from the available networks: https://thegraph.com/docs/en/developing/supported-networks', { exit: 1 });
|
|
507
508
|
}
|
|
509
|
+
choices = (0, sort_1.sortWithPriority)(choices, ['mainnet']);
|
|
508
510
|
const { network } = await gluegun_1.prompt.ask([
|
|
509
511
|
{
|
|
510
512
|
type: 'select',
|
package/oclif.manifest.json
CHANGED