Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not ask for local path when adding more contracts in init #1403

Merged
merged 1 commit into from Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/strong-icons-smash.md
@@ -0,0 +1,5 @@
---
'@graphprotocol/graph-cli': patch
---

do not ask for local path when trying to add more contracts during init
33 changes: 10 additions & 23 deletions packages/cli/src/commands/init.ts
Expand Up @@ -100,8 +100,8 @@
summary: 'Network the contract is deployed to.',
dependsOn: ['from-contract'],
options: [
...availableNetworks.get('ethereum')!,

Check warning on line 103 in packages/cli/src/commands/init.ts

View workflow job for this annotation

GitHub Actions / Lint

Forbidden non-null assertion
...availableNetworks.get('near')!,

Check warning on line 104 in packages/cli/src/commands/init.ts

View workflow job for this annotation

GitHub Actions / Lint

Forbidden non-null assertion
...availableNetworks.get('cosmos')!,
],
}),
Expand Down Expand Up @@ -348,7 +348,9 @@
initial: initSubgraphName,
validate: name => {
try {
validateSubgraphName(name, { allowSimpleName: initAllowSimpleName });
validateSubgraphName(name, {
allowSimpleName: initAllowSimpleName,
});
return true;
} catch (e) {
return `${e.message}
Expand Down Expand Up @@ -494,7 +496,9 @@
initial: initSubgraphName,
validate: name => {
try {
validateSubgraphName(name, { allowSimpleName: initAllowSimpleName });
validateSubgraphName(name, {
allowSimpleName: initAllowSimpleName,
});
return true;
} catch (e) {
return `${e.message}
Expand Down Expand Up @@ -1121,7 +1125,10 @@
}

while (addContract) {
addContract = await addAnotherContract.bind(this)({ protocolInstance, directory });
addContract = await addAnotherContract.bind(this)({
protocolInstance,
directory,
});
}
}

Expand All @@ -1145,7 +1152,6 @@
const addContractConfirmation = addContractAnswer.toLowerCase() === 'y';

if (addContractConfirmation) {
let abiFromFile = false;
const ProtocolContract = protocolInstance.getContract()!;

let contract = '';
Expand All @@ -1160,17 +1166,6 @@
this.log(`✖ ${error}`);
}

const localAbi = await ux.prompt('\nProvide local ABI path? (y/n)', {
required: true,
type: 'single',
});
abiFromFile = localAbi.toLowerCase() === 'y';

let abiPath = '';
if (abiFromFile) {
abiPath = await ux.prompt('\nABI file (path)', { required: true });
}

const contractName = await ux.prompt('\nContract Name', {
required: true,
default: 'Contract',
Expand All @@ -1186,14 +1181,6 @@

const commandLine = [contract, '--contract-name', contractName];

if (abiFromFile) {
if (abiPath.includes(directory)) {
commandLine.push('--abi', path.normalize(abiPath.replace(directory, '')));
} else {
commandLine.push('--abi', abiPath);
}
}

await AddCommand.run(commandLine);
} catch (e) {
this.error(e);
Expand Down