Skip to content

Commit 31c25e7

Browse files
handle non-standard Etherscan API responses, i.e. kaia (#1974)
1 parent 84b0d21 commit 31c25e7

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

.changeset/sweet-spoons-accept.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphprotocol/graph-cli': patch
3+
---
4+
5+
handle non-standard Etherscan API responses, i.e. kaia

packages/cli/src/command-helpers/contracts.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,10 @@ export class ContractService {
164164
this.fetchFromEtherscan(
165165
`${url}?module=contract&action=getsourcecode&address=${address}`,
166166
).then(json => {
167-
if (!json?.result?.length) {
167+
if (!json?.result) {
168168
throw new Error(`No result: ${JSON.stringify(json)}`);
169169
}
170-
const { ContractName } = json.result[0];
170+
const { ContractName } = json.result?.[0] ?? json.result ?? {};
171171
if (!ContractName) {
172172
throw new Error('Contract name is empty');
173173
}

packages/cli/src/commands/init.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ async function processInitForm(
859859
type: 'input',
860860
name: 'startBlock',
861861
message: 'Start block',
862-
initial: () => initStartBlock || startBlock || '0',
862+
initial: () => String(initStartBlock || startBlock || 0),
863863
skip: () => initFromExample !== undefined || isSubstreams,
864864
validate: value =>
865865
initFromExample !== undefined ||

0 commit comments

Comments
 (0)