@graphprotocol/graph-cli 0.58.0-alpha-20230918230348-a16f8e3 → 0.58.0-alpha-20230918231341-bb53ed5
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 +1 -1
- package/dist/command-helpers/abi.d.ts +1 -1
- package/dist/command-helpers/abi.js +114 -114
- package/dist/command-helpers/studio.js +33 -33
- package/dist/protocols/index.d.ts +5 -5
- package/dist/protocols/index.js +63 -65
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import ABI from
|
|
1
|
+
import ABI from '../protocols/ethereum/abi';
|
|
2
2
|
export declare const loadAbiFromEtherscan: (ABICtor: typeof ABI, network: string, address: string) => Promise<ABI>;
|
|
3
3
|
export declare const loadStartBlockForContract: (network: string, address: string) => Promise<string>;
|
|
4
4
|
export declare const fetchDeployContractTransactionFromEtherscan: (network: string, address: string) => Promise<string>;
|
|
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.loadAbiFromBlockScout = exports.getStartBlockForContract = exports.fetchTransactionByHashFromRPC = exports.fetchContractCreationHashWithRetry = exports.fetchDeployContractTransactionFromEtherscan = exports.loadStartBlockForContract = exports.loadAbiFromEtherscan = void 0;
|
|
7
|
-
const fetch_1 = require("@whatwg-node/fetch");
|
|
8
7
|
const immutable_1 = __importDefault(require("immutable"));
|
|
8
|
+
const fetch_1 = require("@whatwg-node/fetch");
|
|
9
9
|
const spinner_1 = require("./spinner");
|
|
10
10
|
const loadAbiFromEtherscan = async (ABICtor, network, address) => await (0, spinner_1.withSpinner)(`Fetching ABI from Etherscan`, `Failed to fetch ABI from Etherscan`, `Warnings while fetching ABI from Etherscan`, async () => {
|
|
11
11
|
const scanApiUrl = getEtherscanLikeAPIUrl(network);
|
|
@@ -14,10 +14,10 @@ const loadAbiFromEtherscan = async (ABICtor, network, address) => await (0, spin
|
|
|
14
14
|
// Etherscan returns a JSON object that has a `status`, a `message` and
|
|
15
15
|
// a `result` field. The `status` is '0' in case of errors and '1' in
|
|
16
16
|
// case of success
|
|
17
|
-
if (json.status ===
|
|
18
|
-
return new ABICtor(
|
|
17
|
+
if (json.status === '1') {
|
|
18
|
+
return new ABICtor('Contract', undefined, immutable_1.default.fromJS(JSON.parse(json.result)));
|
|
19
19
|
}
|
|
20
|
-
throw new Error(
|
|
20
|
+
throw new Error('ABI not found, try loading it from a local file');
|
|
21
21
|
});
|
|
22
22
|
exports.loadAbiFromEtherscan = loadAbiFromEtherscan;
|
|
23
23
|
const loadStartBlockForContract = async (network, address) => await (0, spinner_1.withSpinner)(`Fetching Start Block`, `Failed to fetch Start Block`, `Warnings while fetching deploy contract transaction from Etherscan`, async () => {
|
|
@@ -27,7 +27,7 @@ exports.loadStartBlockForContract = loadStartBlockForContract;
|
|
|
27
27
|
const fetchDeployContractTransactionFromEtherscan = async (network, address) => {
|
|
28
28
|
const scanApiUrl = getEtherscanLikeAPIUrl(network);
|
|
29
29
|
const json = await (0, exports.fetchContractCreationHashWithRetry)(`${scanApiUrl}?module=contract&action=getcontractcreation&contractaddresses=${address}`, 5);
|
|
30
|
-
if (json.status ===
|
|
30
|
+
if (json.status === '1') {
|
|
31
31
|
return json.result[0].txHash;
|
|
32
32
|
}
|
|
33
33
|
throw new Error(`Failed to fetch deploy contract transaction`);
|
|
@@ -39,7 +39,7 @@ const fetchContractCreationHashWithRetry = async (url, retryCount) => {
|
|
|
39
39
|
try {
|
|
40
40
|
const result = await (0, fetch_1.fetch)(url);
|
|
41
41
|
json = await result.json();
|
|
42
|
-
if (json.status !==
|
|
42
|
+
if (json.status !== '0') {
|
|
43
43
|
return json;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -58,13 +58,13 @@ const fetchTransactionByHashFromRPC = async (network, transactionHash) => {
|
|
|
58
58
|
if (!RPCURL)
|
|
59
59
|
throw new Error(`Unable to fetch RPC URL for ${network}`);
|
|
60
60
|
const result = await (0, fetch_1.fetch)(String(RPCURL), {
|
|
61
|
-
method:
|
|
61
|
+
method: 'POST',
|
|
62
62
|
headers: {
|
|
63
|
-
|
|
63
|
+
'Content-Type': 'application/json',
|
|
64
64
|
},
|
|
65
65
|
body: JSON.stringify({
|
|
66
|
-
jsonrpc:
|
|
67
|
-
method:
|
|
66
|
+
jsonrpc: '2.0',
|
|
67
|
+
method: 'eth_getTransactionByHash',
|
|
68
68
|
params: [transactionHash],
|
|
69
69
|
id: 1,
|
|
70
70
|
}),
|
|
@@ -73,7 +73,7 @@ const fetchTransactionByHashFromRPC = async (network, transactionHash) => {
|
|
|
73
73
|
return json;
|
|
74
74
|
}
|
|
75
75
|
catch (error) {
|
|
76
|
-
throw new Error(
|
|
76
|
+
throw new Error('Failed to fetch contract creation transaction');
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
79
|
exports.fetchTransactionByHashFromRPC = fetchTransactionByHashFromRPC;
|
|
@@ -89,76 +89,76 @@ const getStartBlockForContract = async (network, address) => {
|
|
|
89
89
|
};
|
|
90
90
|
exports.getStartBlockForContract = getStartBlockForContract;
|
|
91
91
|
const loadAbiFromBlockScout = async (ABICtor, network, address) => await (0, spinner_1.withSpinner)(`Fetching ABI from BlockScout`, `Failed to fetch ABI from BlockScout`, `Warnings while fetching ABI from BlockScout`, async () => {
|
|
92
|
-
const result = await (0, fetch_1.fetch)(`https://blockscout.com/${network.replace(
|
|
92
|
+
const result = await (0, fetch_1.fetch)(`https://blockscout.com/${network.replace('-', '/')}/api?module=contract&action=getabi&address=${address}`);
|
|
93
93
|
const json = await result.json();
|
|
94
94
|
// BlockScout returns a JSON object that has a `status`, a `message` and
|
|
95
95
|
// a `result` field. The `status` is '0' in case of errors and '1' in
|
|
96
96
|
// case of success
|
|
97
|
-
if (json.status ===
|
|
98
|
-
return new ABICtor(
|
|
97
|
+
if (json.status === '1') {
|
|
98
|
+
return new ABICtor('Contract', undefined, immutable_1.default.fromJS(JSON.parse(json.result)));
|
|
99
99
|
}
|
|
100
|
-
throw new Error(
|
|
100
|
+
throw new Error('ABI not found, try loading it from a local file');
|
|
101
101
|
});
|
|
102
102
|
exports.loadAbiFromBlockScout = loadAbiFromBlockScout;
|
|
103
103
|
const getEtherscanLikeAPIUrl = (network) => {
|
|
104
104
|
switch (network) {
|
|
105
|
-
case
|
|
105
|
+
case 'mainnet':
|
|
106
106
|
return `https://api.etherscan.io/api`;
|
|
107
|
-
case
|
|
107
|
+
case 'arbitrum-one':
|
|
108
108
|
return `https://api.arbiscan.io/api`;
|
|
109
|
-
case
|
|
109
|
+
case 'arbitrum-goerli':
|
|
110
110
|
return `https://api-goerli.arbiscan.io/api`;
|
|
111
|
-
case
|
|
111
|
+
case 'bsc':
|
|
112
112
|
return `https://api.bscscan.com/api`;
|
|
113
|
-
case
|
|
113
|
+
case 'base-testnet':
|
|
114
114
|
return `https://api-goerli.basescan.org/api`;
|
|
115
|
-
case
|
|
115
|
+
case 'base':
|
|
116
116
|
return `https://api.basescan.org/api`;
|
|
117
|
-
case
|
|
117
|
+
case 'chapel':
|
|
118
118
|
return `https://api-testnet.bscscan.com/api`;
|
|
119
|
-
case
|
|
119
|
+
case 'matic':
|
|
120
120
|
return `https://api.polygonscan.com/api`;
|
|
121
|
-
case
|
|
121
|
+
case 'mumbai':
|
|
122
122
|
return `https://api-testnet.polygonscan.com/api`;
|
|
123
|
-
case
|
|
123
|
+
case 'aurora':
|
|
124
124
|
return `https://api.aurorascan.dev/api`;
|
|
125
|
-
case
|
|
125
|
+
case 'aurora-testnet':
|
|
126
126
|
return `https://api-testnet.aurorascan.dev/api`;
|
|
127
|
-
case
|
|
127
|
+
case 'optimism-goerli':
|
|
128
128
|
return `https://api-goerli-optimistic.etherscan.io/api`;
|
|
129
|
-
case
|
|
129
|
+
case 'optimism':
|
|
130
130
|
return `https://api-optimistic.etherscan.io/api`;
|
|
131
|
-
case
|
|
131
|
+
case 'moonbeam':
|
|
132
132
|
return `https://api-moonbeam.moonscan.io/api`;
|
|
133
|
-
case
|
|
133
|
+
case 'moonriver':
|
|
134
134
|
return `https://api-moonriver.moonscan.io/api`;
|
|
135
|
-
case
|
|
135
|
+
case 'mbase':
|
|
136
136
|
return `https://api-moonbase.moonscan.io/api`;
|
|
137
|
-
case
|
|
137
|
+
case 'avalanche':
|
|
138
138
|
return `https://api.snowtrace.io/api`;
|
|
139
|
-
case
|
|
139
|
+
case 'fuji':
|
|
140
140
|
return `https://api-testnet.snowtrace.io/api`;
|
|
141
|
-
case
|
|
141
|
+
case 'celo':
|
|
142
142
|
return `https://api.celoscan.io/api`;
|
|
143
|
-
case
|
|
143
|
+
case 'celo-alfajores':
|
|
144
144
|
return `https://alfajores.celoscan.io/api`;
|
|
145
|
-
case
|
|
145
|
+
case 'gnosis':
|
|
146
146
|
return `https://api.gnosisscan.io/api`;
|
|
147
|
-
case
|
|
147
|
+
case 'fantom':
|
|
148
148
|
return `https://api.ftmscan.com/api`;
|
|
149
|
-
case
|
|
149
|
+
case 'fantom-testnet':
|
|
150
150
|
return `https://api-testnet.ftmscan.com/api`;
|
|
151
|
-
case
|
|
151
|
+
case 'zksync-era':
|
|
152
152
|
return `https://block-explorer-api.mainnet.zksync.io/api`;
|
|
153
|
-
case
|
|
153
|
+
case 'zksync-era-testnet':
|
|
154
154
|
return `https://block-explorer-api.testnets.zksync.dev/api`;
|
|
155
|
-
case
|
|
155
|
+
case 'polygon-zkevm-testnet':
|
|
156
156
|
return `https://testnet-zkevm.polygonscan.com/api`;
|
|
157
|
-
case
|
|
157
|
+
case 'polygon-zkevm':
|
|
158
158
|
return `https://zkevm.polygonscan.com/api`;
|
|
159
|
-
case
|
|
159
|
+
case 'sepolia':
|
|
160
160
|
return `https://api-sepolia.etherscan.io/api`;
|
|
161
|
-
case
|
|
161
|
+
case 'scroll-sepolia':
|
|
162
162
|
return `https://sepolia-blockscout.scroll.io/api`;
|
|
163
163
|
default:
|
|
164
164
|
return `https://api-${network}.etherscan.io/api`;
|
|
@@ -166,76 +166,76 @@ const getEtherscanLikeAPIUrl = (network) => {
|
|
|
166
166
|
};
|
|
167
167
|
const getPublicRPCEndpoint = (network) => {
|
|
168
168
|
switch (network) {
|
|
169
|
-
case
|
|
170
|
-
return
|
|
171
|
-
case
|
|
172
|
-
return
|
|
173
|
-
case
|
|
174
|
-
return
|
|
175
|
-
case
|
|
176
|
-
return
|
|
177
|
-
case
|
|
178
|
-
return
|
|
179
|
-
case
|
|
180
|
-
return
|
|
181
|
-
case
|
|
182
|
-
return
|
|
183
|
-
case
|
|
184
|
-
return
|
|
185
|
-
case
|
|
186
|
-
return
|
|
187
|
-
case
|
|
188
|
-
return
|
|
189
|
-
case
|
|
190
|
-
return
|
|
191
|
-
case
|
|
192
|
-
return
|
|
193
|
-
case
|
|
194
|
-
return
|
|
195
|
-
case
|
|
196
|
-
return
|
|
197
|
-
case
|
|
198
|
-
return
|
|
199
|
-
case
|
|
200
|
-
return
|
|
201
|
-
case
|
|
202
|
-
return
|
|
203
|
-
case
|
|
204
|
-
return
|
|
205
|
-
case
|
|
206
|
-
return
|
|
207
|
-
case
|
|
208
|
-
return
|
|
209
|
-
case
|
|
210
|
-
return
|
|
211
|
-
case
|
|
212
|
-
return
|
|
213
|
-
case
|
|
214
|
-
return
|
|
215
|
-
case
|
|
216
|
-
return
|
|
217
|
-
case
|
|
218
|
-
return
|
|
219
|
-
case
|
|
220
|
-
return
|
|
221
|
-
case
|
|
222
|
-
return
|
|
223
|
-
case
|
|
224
|
-
return
|
|
225
|
-
case
|
|
226
|
-
return
|
|
227
|
-
case
|
|
228
|
-
return
|
|
229
|
-
case
|
|
230
|
-
return
|
|
231
|
-
case
|
|
232
|
-
return
|
|
233
|
-
case
|
|
234
|
-
return
|
|
235
|
-
case
|
|
236
|
-
return
|
|
237
|
-
case
|
|
238
|
-
return
|
|
169
|
+
case 'arbitrum-goerli':
|
|
170
|
+
return 'https://goerli-rollup.arbitrum.io/rpc';
|
|
171
|
+
case 'arbitrum-one':
|
|
172
|
+
return 'https://arb1.arbitrum.io/rpc';
|
|
173
|
+
case 'aurora':
|
|
174
|
+
return 'https://rpc.mainnet.aurora.dev';
|
|
175
|
+
case 'aurora-testnet':
|
|
176
|
+
return 'https://rpc.testnet.aurora.dev';
|
|
177
|
+
case 'avalanche':
|
|
178
|
+
return 'https://api.avax.network/ext/bc/C/rpc';
|
|
179
|
+
case 'base-testnet':
|
|
180
|
+
return 'https://goerli.base.org';
|
|
181
|
+
case 'base':
|
|
182
|
+
return 'https://rpc.base.org';
|
|
183
|
+
case 'bsc':
|
|
184
|
+
return 'https://bsc-dataseed.binance.org';
|
|
185
|
+
case 'celo':
|
|
186
|
+
return 'https://forno.celo.org';
|
|
187
|
+
case 'celo-alfajores':
|
|
188
|
+
return 'https://alfajores-forno.celo-testnet.org';
|
|
189
|
+
case 'chapel':
|
|
190
|
+
return 'https://rpc.chapel.dev';
|
|
191
|
+
case 'clover':
|
|
192
|
+
return 'https://rpc.clover.finance';
|
|
193
|
+
case 'fantom':
|
|
194
|
+
return 'https://rpcapi.fantom.network';
|
|
195
|
+
case 'fantom-testnet':
|
|
196
|
+
return 'https://rpc.testnet.fantom.network';
|
|
197
|
+
case 'fuji':
|
|
198
|
+
return 'https://api.avax-test.network/ext/bc/C/rpc';
|
|
199
|
+
case 'fuse':
|
|
200
|
+
return 'https://rpc.fuse.io';
|
|
201
|
+
case 'goerli':
|
|
202
|
+
return 'https://rpc.ankr.com/eth_goerli';
|
|
203
|
+
case 'gnosis':
|
|
204
|
+
return 'https://safe-transaction.gnosis.io';
|
|
205
|
+
case 'mainnet':
|
|
206
|
+
return 'https://rpc.ankr.com/eth';
|
|
207
|
+
case 'matic':
|
|
208
|
+
return 'https://rpc-mainnet.maticvigil.com';
|
|
209
|
+
case 'mbase':
|
|
210
|
+
return 'https://rpc.moonbase.moonbeam.network';
|
|
211
|
+
case 'mumbai':
|
|
212
|
+
return 'https://rpc-mumbai.maticvigil.com';
|
|
213
|
+
case 'moonbeam':
|
|
214
|
+
return 'https://rpc.api.moonbeam.network';
|
|
215
|
+
case 'moonriver':
|
|
216
|
+
return 'https://moonriver.public.blastapi.io';
|
|
217
|
+
case 'optimism':
|
|
218
|
+
return 'https://mainnet.optimism.io';
|
|
219
|
+
case 'optimism-goerli':
|
|
220
|
+
return 'https://goerli.optimism.io';
|
|
221
|
+
case 'poa-core':
|
|
222
|
+
return 'https://core.poa.network';
|
|
223
|
+
case 'poa-sokol':
|
|
224
|
+
return 'https://sokol.poa.network';
|
|
225
|
+
case 'polygon-zkevm-testnet':
|
|
226
|
+
return 'https://rpc.public.zkevm-test.net';
|
|
227
|
+
case 'polygon-zkevm':
|
|
228
|
+
return 'https://zkevm-rpc.com';
|
|
229
|
+
case 'rinkeby':
|
|
230
|
+
return 'https://rpc.ankr.com/eth_rinkeby';
|
|
231
|
+
case 'zksync-era':
|
|
232
|
+
return 'https://mainnet.era.zksync.io';
|
|
233
|
+
case 'zksync-era-testnet':
|
|
234
|
+
return 'https://testnet.era.zksync.dev';
|
|
235
|
+
case 'sepolia':
|
|
236
|
+
return 'https://rpc.ankr.com/eth_sepolia';
|
|
237
|
+
case 'scroll-sepolia':
|
|
238
|
+
return 'https://rpc.ankr.com/scroll_sepolia_testnet';
|
|
239
239
|
default:
|
|
240
240
|
throw new Error(`Unknown network: ${network}`);
|
|
241
241
|
}
|
|
@@ -2,46 +2,46 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.validateStudioNetwork = exports.allowedStudioNetworks = void 0;
|
|
4
4
|
exports.allowedStudioNetworks = [
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
5
|
+
'mainnet',
|
|
6
|
+
'rinkeby',
|
|
7
|
+
'goerli',
|
|
8
|
+
'gnosis',
|
|
9
|
+
'chapel',
|
|
10
|
+
'optimism-goerli',
|
|
11
|
+
'clover',
|
|
12
|
+
'fantom',
|
|
13
|
+
'matic',
|
|
14
|
+
'fantom-testnet',
|
|
15
|
+
'arbitrum-goerli',
|
|
16
|
+
'fuji',
|
|
17
|
+
'celo-alfajores',
|
|
18
|
+
'mumbai',
|
|
19
|
+
'aurora-testnet',
|
|
20
|
+
'near-testnet',
|
|
21
|
+
'optimism',
|
|
22
|
+
'optimism-goerli',
|
|
23
|
+
'theta-testnet-001',
|
|
24
|
+
'osmo-test-4',
|
|
25
|
+
'base-testnet',
|
|
26
|
+
'base',
|
|
27
|
+
'celo',
|
|
28
|
+
'arbitrum-one',
|
|
29
|
+
'avalanche',
|
|
30
|
+
'zksync-era',
|
|
31
|
+
'zksync-era-testnet',
|
|
32
|
+
'sepolia',
|
|
33
|
+
'polygon-zkevm-testnet',
|
|
34
|
+
'polygon-zkevm',
|
|
35
|
+
'scroll-sepolia',
|
|
36
36
|
];
|
|
37
37
|
const validateStudioNetwork = ({ studio, product, network, }) => {
|
|
38
|
-
const isStudio = studio || product ===
|
|
38
|
+
const isStudio = studio || product === 'subgraph-studio';
|
|
39
39
|
const isAllowedNetwork = !network ||
|
|
40
40
|
exports.allowedStudioNetworks.includes(
|
|
41
41
|
// @ts-expect-error we're checking if the network is allowed
|
|
42
42
|
network);
|
|
43
43
|
if (isStudio && !isAllowedNetwork) {
|
|
44
|
-
throw new Error(`The Subgraph Studio only allows subgraphs for these networks: ${exports.allowedStudioNetworks.join(
|
|
44
|
+
throw new Error(`The Subgraph Studio only allows subgraphs for these networks: ${exports.allowedStudioNetworks.join(', ')}`);
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
47
|
exports.validateStudioNetwork = validateStudioNetwork;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import immutable from
|
|
2
|
-
import Subgraph from
|
|
3
|
-
import { ContractCtor } from
|
|
4
|
-
import { SubgraphOptions } from
|
|
1
|
+
import immutable from 'immutable';
|
|
2
|
+
import Subgraph from '../subgraph';
|
|
3
|
+
import { ContractCtor } from './contract';
|
|
4
|
+
import { SubgraphOptions } from './subgraph';
|
|
5
5
|
export default class Protocol {
|
|
6
6
|
static fromDataSources(dataSourcesAndTemplates: any): Protocol;
|
|
7
7
|
name: ProtocolName;
|
|
@@ -25,7 +25,7 @@ export default class Protocol {
|
|
|
25
25
|
getManifestScaffold(): any;
|
|
26
26
|
getMappingScaffold(): any;
|
|
27
27
|
}
|
|
28
|
-
export type ProtocolName =
|
|
28
|
+
export type ProtocolName = 'arweave' | 'ethereum' | 'near' | 'cosmos' | 'substreams';
|
|
29
29
|
export interface ProtocolConfig {
|
|
30
30
|
displayName: string;
|
|
31
31
|
abi?: any;
|
package/dist/protocols/index.js
CHANGED
|
@@ -47,7 +47,7 @@ const NearMappingScaffold = __importStar(require("./near/scaffold/mapping"));
|
|
|
47
47
|
const subgraph_4 = __importDefault(require("./near/subgraph"));
|
|
48
48
|
const SubstreamsManifestScaffold = __importStar(require("./substreams/scaffold/manifest"));
|
|
49
49
|
const subgraph_5 = __importDefault(require("./substreams/subgraph"));
|
|
50
|
-
const protocolDebug = (0, debug_1.default)(
|
|
50
|
+
const protocolDebug = (0, debug_1.default)('graph-cli:protocol');
|
|
51
51
|
class Protocol {
|
|
52
52
|
static fromDataSources(dataSourcesAndTemplates) {
|
|
53
53
|
const firstDataSourceKind = dataSourcesAndTemplates[0].kind;
|
|
@@ -56,19 +56,19 @@ class Protocol {
|
|
|
56
56
|
constructor(name) {
|
|
57
57
|
this.name = Protocol.normalizeName(name);
|
|
58
58
|
switch (this.name) {
|
|
59
|
-
case
|
|
59
|
+
case 'arweave':
|
|
60
60
|
this.config = arweaveProtocol;
|
|
61
61
|
break;
|
|
62
|
-
case
|
|
62
|
+
case 'cosmos':
|
|
63
63
|
this.config = cosmosProtocol;
|
|
64
64
|
break;
|
|
65
|
-
case
|
|
65
|
+
case 'ethereum':
|
|
66
66
|
this.config = ethereumProtocol;
|
|
67
67
|
break;
|
|
68
|
-
case
|
|
68
|
+
case 'near':
|
|
69
69
|
this.config = nearProtocol;
|
|
70
70
|
break;
|
|
71
|
-
case
|
|
71
|
+
case 'substreams':
|
|
72
72
|
this.config = substreamsProtocol;
|
|
73
73
|
break;
|
|
74
74
|
default:
|
|
@@ -80,67 +80,67 @@ class Protocol {
|
|
|
80
80
|
return immutable_1.default.fromJS({
|
|
81
81
|
// `ethereum/contract` is kept for backwards compatibility.
|
|
82
82
|
// New networks (or protocol perhaps) shouldn't have the `/contract` anymore (unless a new case makes use of it).
|
|
83
|
-
arweave: [
|
|
84
|
-
ethereum: [
|
|
85
|
-
near: [
|
|
86
|
-
cosmos: [
|
|
87
|
-
substreams: [
|
|
83
|
+
arweave: ['arweave'],
|
|
84
|
+
ethereum: ['ethereum', 'ethereum/contract'],
|
|
85
|
+
near: ['near'],
|
|
86
|
+
cosmos: ['cosmos'],
|
|
87
|
+
substreams: ['substreams'],
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
90
|
static availableNetworks() {
|
|
91
91
|
return immutable_1.default.fromJS({
|
|
92
|
-
arweave: [
|
|
92
|
+
arweave: ['arweave-mainnet'],
|
|
93
93
|
ethereum: [
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
94
|
+
'mainnet',
|
|
95
|
+
'rinkeby',
|
|
96
|
+
'goerli',
|
|
97
|
+
'poa-core',
|
|
98
|
+
'poa-sokol',
|
|
99
|
+
'gnosis',
|
|
100
|
+
'matic',
|
|
101
|
+
'mumbai',
|
|
102
|
+
'fantom',
|
|
103
|
+
'fantom-testnet',
|
|
104
|
+
'bsc',
|
|
105
|
+
'chapel',
|
|
106
|
+
'clover',
|
|
107
|
+
'avalanche',
|
|
108
|
+
'fuji',
|
|
109
|
+
'celo',
|
|
110
|
+
'celo-alfajores',
|
|
111
|
+
'fuse',
|
|
112
|
+
'moonbeam',
|
|
113
|
+
'moonriver',
|
|
114
|
+
'mbase',
|
|
115
|
+
'arbitrum-one',
|
|
116
|
+
'arbitrum-goerli',
|
|
117
|
+
'optimism',
|
|
118
|
+
'optimism-goerli',
|
|
119
|
+
'aurora',
|
|
120
|
+
'aurora-testnet',
|
|
121
|
+
'base-testnet',
|
|
122
|
+
'base',
|
|
123
|
+
'zksync-era',
|
|
124
|
+
'zksync-era-testnet',
|
|
125
|
+
'sepolia',
|
|
126
|
+
'polygon-zkevm-testnet',
|
|
127
|
+
'polygon-zkevm',
|
|
128
|
+
'scroll-sepolia',
|
|
129
129
|
],
|
|
130
|
-
near: [
|
|
130
|
+
near: ['near-mainnet', 'near-testnet'],
|
|
131
131
|
cosmos: [
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
132
|
+
'cosmoshub-4',
|
|
133
|
+
'theta-testnet-001',
|
|
134
|
+
'osmosis-1',
|
|
135
|
+
'osmo-test-4',
|
|
136
|
+
'juno-1',
|
|
137
|
+
'uni-3', // Juno testnet
|
|
138
138
|
],
|
|
139
|
-
substreams: [
|
|
139
|
+
substreams: ['mainnet'],
|
|
140
140
|
});
|
|
141
141
|
}
|
|
142
142
|
static normalizeName(name) {
|
|
143
|
-
return Protocol.availableProtocols().findKey(
|
|
143
|
+
return Protocol.availableProtocols().findKey(possibleNames => {
|
|
144
144
|
return possibleNames.includes(name);
|
|
145
145
|
});
|
|
146
146
|
}
|
|
@@ -150,9 +150,7 @@ class Protocol {
|
|
|
150
150
|
// Receives a data source kind, and checks if it's valid
|
|
151
151
|
// for the given protocol instance (this).
|
|
152
152
|
isValidKindName(kind) {
|
|
153
|
-
return Protocol.availableProtocols()
|
|
154
|
-
.get(this.name, immutable_1.default.List())
|
|
155
|
-
.includes(kind);
|
|
153
|
+
return Protocol.availableProtocols().get(this.name, immutable_1.default.List()).includes(kind);
|
|
156
154
|
}
|
|
157
155
|
hasABIs() {
|
|
158
156
|
return this.config.abi != null;
|
|
@@ -202,7 +200,7 @@ class Protocol {
|
|
|
202
200
|
}
|
|
203
201
|
exports.default = Protocol;
|
|
204
202
|
const arweaveProtocol = {
|
|
205
|
-
displayName:
|
|
203
|
+
displayName: 'Arweave',
|
|
206
204
|
abi: undefined,
|
|
207
205
|
contract: undefined,
|
|
208
206
|
getTemplateCodeGen: undefined,
|
|
@@ -214,7 +212,7 @@ const arweaveProtocol = {
|
|
|
214
212
|
mappingScaffold: ArweaveMappingScaffold,
|
|
215
213
|
};
|
|
216
214
|
const cosmosProtocol = {
|
|
217
|
-
displayName:
|
|
215
|
+
displayName: 'Cosmos',
|
|
218
216
|
abi: undefined,
|
|
219
217
|
contract: undefined,
|
|
220
218
|
getTemplateCodeGen: undefined,
|
|
@@ -226,7 +224,7 @@ const cosmosProtocol = {
|
|
|
226
224
|
mappingScaffold: CosmosMappingScaffold,
|
|
227
225
|
};
|
|
228
226
|
const ethereumProtocol = {
|
|
229
|
-
displayName:
|
|
227
|
+
displayName: 'Ethereum',
|
|
230
228
|
abi: abi_1.default,
|
|
231
229
|
contract: contract_1.default,
|
|
232
230
|
getTemplateCodeGen(template) {
|
|
@@ -242,7 +240,7 @@ const ethereumProtocol = {
|
|
|
242
240
|
mappingScaffold: EthereumMappingScaffold,
|
|
243
241
|
};
|
|
244
242
|
const nearProtocol = {
|
|
245
|
-
displayName:
|
|
243
|
+
displayName: 'NEAR',
|
|
246
244
|
abi: undefined,
|
|
247
245
|
contract: contract_2.default,
|
|
248
246
|
getTypeGenerator: undefined,
|
|
@@ -254,7 +252,7 @@ const nearProtocol = {
|
|
|
254
252
|
mappingScaffold: NearMappingScaffold,
|
|
255
253
|
};
|
|
256
254
|
const substreamsProtocol = {
|
|
257
|
-
displayName:
|
|
255
|
+
displayName: 'Substreams',
|
|
258
256
|
abi: undefined,
|
|
259
257
|
contract: undefined,
|
|
260
258
|
getTypeGenerator: undefined,
|
|
@@ -265,4 +263,4 @@ const substreamsProtocol = {
|
|
|
265
263
|
manifestScaffold: SubstreamsManifestScaffold,
|
|
266
264
|
mappingScaffold: undefined,
|
|
267
265
|
};
|
|
268
|
-
protocolDebug(
|
|
266
|
+
protocolDebug('Available networks %M', Protocol.availableNetworks());
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED