Skip to content

Commit bb6cf87

Browse files
committed
handle non-standard Etherscan API responses, i.e. kaia
1 parent 9c69575 commit bb6cf87

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
@@ -854,7 +854,7 @@ async function processInitForm(
854854
type: 'input',
855855
name: 'startBlock',
856856
message: 'Start block',
857-
initial: () => initStartBlock || startBlock || '0',
857+
initial: () => String(initStartBlock || startBlock || 0),
858858
skip: () => initFromExample !== undefined || isSubstreams,
859859
validate: value =>
860860
initFromExample !== undefined ||

0 commit comments

Comments
 (0)