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

Add graph init with --from-example and --from-contract modes #224

Merged
merged 26 commits into from
Mar 14, 2019
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6004a61
commands/init, scaffold: Add subgraph scaffolding using address + Eth…
Feb 22, 2019
9cf69da
commands/init: Make Etherscan ABI download work with testnets
Feb 22, 2019
66680f8
scaffold: Avoid semicolons in the generated mapping
Feb 22, 2019
1c3979e
commands/init: Make output prettier
Feb 22, 2019
281470f
commands/init: Handle ABIs without events
Feb 23, 2019
f8e278b
commands/init: Fix loading ABIs from local files
Feb 23, 2019
48d51ad
scaffold: Handle unnamed event parameters correctly
Feb 23, 2019
611a717
commands/init: Avoid duplicating event counting logic
Feb 23, 2019
8599321
codegen: Implement getting value types from AssemblyScript types
Feb 23, 2019
6e41e2b
scaffold: Handle all Ethereum event parameter types properly
Feb 23, 2019
4d75ed4
commands/init, command-helpers: Add --from-example and --from-contract
Mar 6, 2019
01c15d7
tests/cli: Make testCli more flexible (allow CLI command and cwd to b…
Mar 7, 2019
aebb8f0
tests/cli/validation: Pass 'codegen' command to cliTest
Mar 7, 2019
25fc7e0
NPM, Yarn: Add strip-ansi to development dependencies
Mar 7, 2019
550de17
tests/cli/init: Add positive tests for non-interactive `graph init`
Mar 7, 2019
6ca943d
NPM, Yarn: Add missing node-fetch dependency
Mar 7, 2019
e56d994
NPM, Yarn: Bump jest to v24.3.0
Mar 7, 2019
d20f09f
README: Update commands, refer to the official docs for getting started
Mar 12, 2019
9b3af7c
command-helpers/gluegun: Improve fixParameters and add documentation
Mar 14, 2019
54edc8a
commands/init: Handle fixParameter errors
Mar 14, 2019
6dc67d8
commands: Use fixParameters in all commands where it makes sense
Mar 14, 2019
5987a6c
commands/init: Add comment for when the form is cancelled
Mar 14, 2019
efcf205
commands/init: Don't fail silently in --from-example
Mar 14, 2019
f43024d
scaffold: Remove outdated comment
Mar 14, 2019
1bf7373
commands/init: Add comment for removing .git in --from-example mode
Mar 14, 2019
be125ee
scaffold: Automatically use the latest graph-cli version
Mar 14, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@
"jayson": "^2.0.6",
"js-yaml": "^3.12.0",
"keytar": "^4.3.0",
"node-fetch": "^2.3.0",
"prettier": "^1.13.5",
"request": "^2.88.0"
},
"bin": {
"graph": "bin/graph"
},
"devDependencies": {
"jest": "^23.6.0",
"spawn-command": "^0.0.2-1"
"jest": "^24.3.0",
"spawn-command": "^0.0.2-1",
"strip-ansi": "^5.0.0"
},
"scripts": {
"test": "jest --verbose"
Expand Down
6 changes: 4 additions & 2 deletions src/codegen/types/conversions.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,22 +161,24 @@ const VALUE_TO_ASSEMBLYSCRIPT = [
const ASSEMBLYSCRIPT_TO_VALUE = [
// Arrays

['Array<Address>', '[Bytes]', code => `Value.fromBytesArray(${code})`],
['Array<Bytes>', '[Bytes]', code => `Value.fromBytesArray(${code})`],
['Array<boolean>', '[Boolean]', code => `Value.fromBooleanArray(${code})`],
['Array<i32>', '[Int]', code => `Value.fromI32Array(${code})`],
['Array<BigInt>', '[BigInt]', code => `Value.fromBigIntArray(${code})`],
['Array<string>', '[ID]', code => `Value.fromStringArray(${code})`],
['Array<string>', '[String]', code => `Value.fromStringArray(${code})`],
['Array<string>', '[ID]', code => `Value.fromStringArray(${code})`],
['Array<string>', /\[.*\]/, code => `Value.fromStringArray(${code})`],

// Scalar values

['Address', 'Bytes', code => `Value.fromBytes(${code})`],
['Bytes', 'Bytes', code => `Value.fromBytes(${code})`],
['boolean', 'Boolean', code => `Value.fromBoolean(${code})`],
['i32', 'Int', code => `Value.fromI32(${code})`],
['BigInt', 'BigInt', code => `Value.fromBigInt(${code})`],
['string', 'ID', code => `Value.fromString(${code})`],
['string', 'String', code => `Value.fromString(${code})`],
['string', 'ID', code => `Value.fromString(${code})`],
['string', /.*/, code => `Value.fromString(${code})`],
]

Expand Down
4 changes: 4 additions & 0 deletions src/codegen/types/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ const ethereumValueFromAsc = (code, ethereumType) =>
const ascTypeForValue = valueType =>
findConversionFromType('Value', 'AssemblyScript', valueType).getIn(['to', 'type'])

const valueTypeForAsc = ascType =>
findConversionFromType('AssemblyScript', 'Value', ascType).getIn(['to', 'type'])

const valueToAsc = (code, valueType) =>
findConversionFromType('Value', 'AssemblyScript', valueType).get('convert')(code)

Expand All @@ -107,6 +110,7 @@ module.exports = {

// Value <-> AssemblyScript
ascTypeForValue,
valueTypeForAsc,
valueToAsc,
valueFromAsc,
}
15 changes: 15 additions & 0 deletions src/command-helpers/gluegun.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const fixParameters = (parameters, booleanOptions) => {
let params = parameters.array

Object.keys(booleanOptions).forEach(key => {
if (typeof booleanOptions[key] === 'string') {
params.unshift(booleanOptions[key])
}
})

return params
}

module.exports = {
fixParameters,
}
Loading