@graphprotocol/graph-cli 0.37.1 → 0.37.2-alpha-20221219142030-0cf2a37
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 +7 -0
- package/package.json +1 -2
- package/src/codegen/schema.js +49 -58
- package/src/codegen/schema.test.js +32 -27
- package/src/codegen/template.js +1 -2
- package/src/codegen/types/conversions.js +43 -14
- package/src/codegen/types/index.js +20 -23
- package/src/codegen/typescript.js +0 -3
- package/src/command-helpers/abi.js +2 -3
- package/src/command-helpers/data-sources.js +3 -4
- package/src/command-helpers/scaffold.js +18 -14
- package/src/command-helpers/spinner.js +0 -1
- package/src/commands/add.js +42 -25
- package/src/compiler/index.js +12 -13
- package/src/protocols/arweave/subgraph.js +2 -7
- package/src/protocols/cosmos/subgraph.js +2 -9
- package/src/protocols/ethereum/abi.js +6 -7
- package/src/protocols/ethereum/codegen/abi.js +217 -223
- package/src/protocols/ethereum/codegen/abi.test.js +15 -16
- package/src/protocols/ethereum/subgraph.js +55 -67
- package/src/protocols/ethereum/type-generator.js +16 -25
- package/src/protocols/index.js +5 -6
- package/src/protocols/near/subgraph.js +3 -5
- package/src/protocols/substreams/subgraph.js +2 -4
- package/src/scaffold/cosmos.test.js +0 -1
- package/src/scaffold/ethereum.test.js +2 -3
- package/src/scaffold/near.test.js +0 -1
- package/src/schema.js +1 -2
- package/src/subgraph.js +44 -53
- package/src/type-generator.js +6 -7
- package/src/validation/contract.js +6 -11
- package/src/validation/manifest.js +77 -84
- package/src/validation/schema.js +284 -294
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const { withSpinner } = require('./spinner')
|
|
2
2
|
const fetch = require('node-fetch')
|
|
3
|
-
const immutable = require('immutable')
|
|
4
3
|
|
|
5
4
|
const loadAbiFromEtherscan = async (ABI, network, address) =>
|
|
6
5
|
await withSpinner(
|
|
@@ -18,7 +17,7 @@ const loadAbiFromEtherscan = async (ABI, network, address) =>
|
|
|
18
17
|
// a `result` field. The `status` is '0' in case of errors and '1' in
|
|
19
18
|
// case of success
|
|
20
19
|
if (json.status === '1') {
|
|
21
|
-
return new ABI('Contract', undefined,
|
|
20
|
+
return new ABI('Contract', undefined, JSON.parse(json.result))
|
|
22
21
|
} else {
|
|
23
22
|
throw new Error('ABI not found, try loading it from a local file')
|
|
24
23
|
}
|
|
@@ -42,7 +41,7 @@ const loadAbiFromBlockScout = async (ABI, network, address) =>
|
|
|
42
41
|
// a `result` field. The `status` is '0' in case of errors and '1' in
|
|
43
42
|
// case of success
|
|
44
43
|
if (json.status === '1') {
|
|
45
|
-
return new ABI('Contract', undefined,
|
|
44
|
+
return new ABI('Contract', undefined, JSON.parse(json.result))
|
|
46
45
|
} else {
|
|
47
46
|
throw new Error('ABI not found, try loading it from a local file')
|
|
48
47
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const immutable = require('immutable')
|
|
2
1
|
const { loadManifest } = require('../migrations/util/load-manifest')
|
|
3
2
|
|
|
4
3
|
// Loads manifest from file path and returns all:
|
|
@@ -13,15 +12,15 @@ const fromFilePath = async manifestPath => {
|
|
|
13
12
|
|
|
14
13
|
const extractDataSourceByType = (manifest, dataSourceType, protocol) =>
|
|
15
14
|
manifest
|
|
16
|
-
.get(dataSourceType,
|
|
15
|
+
.get(dataSourceType, [])
|
|
17
16
|
.reduce(
|
|
18
17
|
(dataSources, dataSource, dataSourceIndex) =>
|
|
19
18
|
protocol.isValidKindName(dataSource.get('kind'))
|
|
20
19
|
? dataSources.push(
|
|
21
|
-
|
|
20
|
+
{ path: [dataSourceType, dataSourceIndex], dataSource },
|
|
22
21
|
)
|
|
23
22
|
: dataSources,
|
|
24
|
-
|
|
23
|
+
[]
|
|
25
24
|
)
|
|
26
25
|
|
|
27
26
|
// Extracts data sources and templates from a immutable manifest data structure
|
|
@@ -9,7 +9,6 @@ const { generateEventIndexingHandlers } = require('../scaffold/mapping')
|
|
|
9
9
|
const { generateEventType, abiEvents } = require('../scaffold/schema')
|
|
10
10
|
const { generateTestsFiles } = require('../scaffold/tests')
|
|
11
11
|
const { strings } = require('gluegun')
|
|
12
|
-
const { Map } = require('immutable')
|
|
13
12
|
|
|
14
13
|
const generateDataSource = async (
|
|
15
14
|
protocol,
|
|
@@ -20,15 +19,22 @@ const generateDataSource = async (
|
|
|
20
19
|
) => {
|
|
21
20
|
const protocolManifest = protocol.getManifestScaffold()
|
|
22
21
|
|
|
23
|
-
return
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
return {
|
|
23
|
+
kind: protocol.name,
|
|
24
|
+
name: contractName,
|
|
25
|
+
network: network,
|
|
26
|
+
source: yaml.parse(
|
|
27
|
+
prettier.format(
|
|
28
|
+
protocolManifest.source({ contract: contractAddress, contractName }),
|
|
29
|
+
{ parser: 'yaml' },
|
|
30
|
+
),
|
|
31
|
+
),
|
|
32
|
+
mapping: yaml.parse(
|
|
33
|
+
prettier.format(protocolManifest.mapping({ abi, contractName }), {
|
|
34
|
+
parser: 'yaml',
|
|
35
|
+
}),
|
|
36
|
+
),
|
|
37
|
+
}
|
|
32
38
|
}
|
|
33
39
|
|
|
34
40
|
const generateScaffold = async (
|
|
@@ -130,11 +136,9 @@ const writeMapping = async (abi, protocol, contractName, entities) => {
|
|
|
130
136
|
|
|
131
137
|
const writeTestsFiles = async (abi, protocol, contractName) => {
|
|
132
138
|
const hasEvents = protocol.hasEvents()
|
|
133
|
-
const events = hasEvents
|
|
134
|
-
? abiEvents(abi).toJS()
|
|
135
|
-
: []
|
|
139
|
+
const events = hasEvents ? abiEvents(abi).toJS() : []
|
|
136
140
|
|
|
137
|
-
if(events.length > 0) {
|
|
141
|
+
if (events.length > 0) {
|
|
138
142
|
// If a contract is added to a subgraph that has no tests folder
|
|
139
143
|
await fs.ensureDir('./tests/')
|
|
140
144
|
|
package/src/commands/add.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
const chalk = require('chalk')
|
|
2
2
|
const toolbox = require('gluegun/toolbox')
|
|
3
|
-
const immutable = require('immutable')
|
|
4
3
|
const { withSpinner } = require('../command-helpers/spinner')
|
|
5
4
|
const Subgraph = require('../subgraph')
|
|
6
5
|
const Protocol = require('../protocols')
|
|
7
6
|
const DataSourcesExtractor = require('../command-helpers/data-sources')
|
|
8
|
-
const {
|
|
7
|
+
const {
|
|
8
|
+
generateDataSource,
|
|
9
|
+
writeABI,
|
|
10
|
+
writeSchema,
|
|
11
|
+
writeMapping,
|
|
12
|
+
writeTestsFiles,
|
|
13
|
+
} = require('../command-helpers/scaffold')
|
|
9
14
|
const { loadAbiFromEtherscan, loadAbiFromBlockScout } = require('../command-helpers/abi')
|
|
10
15
|
const EthereumABI = require('../protocols/ethereum/abi')
|
|
11
16
|
const { fixParameters } = require('../command-helpers/gluegun')
|
|
@@ -36,7 +41,7 @@ module.exports = {
|
|
|
36
41
|
h,
|
|
37
42
|
help,
|
|
38
43
|
mergeEntities,
|
|
39
|
-
networkFile
|
|
44
|
+
networkFile,
|
|
40
45
|
} = toolbox.parameters.options
|
|
41
46
|
|
|
42
47
|
contractName = contractName || 'Contract'
|
|
@@ -54,7 +59,8 @@ module.exports = {
|
|
|
54
59
|
}
|
|
55
60
|
|
|
56
61
|
let address = toolbox.parameters.first || toolbox.parameters.array[0]
|
|
57
|
-
let manifestPath =
|
|
62
|
+
let manifestPath =
|
|
63
|
+
toolbox.parameters.second || toolbox.parameters.array[1] || './subgraph.yaml'
|
|
58
64
|
|
|
59
65
|
// Show help text if requested
|
|
60
66
|
if (help || h) {
|
|
@@ -72,7 +78,10 @@ module.exports = {
|
|
|
72
78
|
const dataSourcesAndTemplates = await DataSourcesExtractor.fromFilePath(manifestPath)
|
|
73
79
|
let protocol = Protocol.fromDataSources(dataSourcesAndTemplates)
|
|
74
80
|
let manifest = await Subgraph.load(manifestPath, { protocol })
|
|
75
|
-
let network = manifest.result
|
|
81
|
+
let network = manifest.result
|
|
82
|
+
.get('dataSources')
|
|
83
|
+
.get(0)
|
|
84
|
+
.get('network')
|
|
76
85
|
let result = manifest.result.asMutable()
|
|
77
86
|
|
|
78
87
|
let entities = getEntities(manifest)
|
|
@@ -96,17 +105,27 @@ module.exports = {
|
|
|
96
105
|
}
|
|
97
106
|
}
|
|
98
107
|
|
|
99
|
-
let { collisionEntities, onlyCollisions, abiData } = updateEventNamesOnCollision(
|
|
108
|
+
let { collisionEntities, onlyCollisions, abiData } = updateEventNamesOnCollision(
|
|
109
|
+
ethabi,
|
|
110
|
+
entities,
|
|
111
|
+
contractName,
|
|
112
|
+
mergeEntities,
|
|
113
|
+
)
|
|
100
114
|
ethabi.data = abiData
|
|
101
115
|
|
|
102
116
|
await writeABI(ethabi, contractName)
|
|
103
|
-
await writeSchema(ethabi, protocol, result.
|
|
117
|
+
await writeSchema(ethabi, protocol, result.schema?.file, collisionEntities)
|
|
104
118
|
await writeMapping(ethabi, protocol, contractName, collisionEntities)
|
|
105
119
|
await writeTestsFiles(ethabi, protocol, contractName)
|
|
106
120
|
|
|
107
121
|
let dataSources = result.get('dataSources')
|
|
108
|
-
let dataSource = await generateDataSource(
|
|
109
|
-
|
|
122
|
+
let dataSource = await generateDataSource(
|
|
123
|
+
protocol,
|
|
124
|
+
contractName,
|
|
125
|
+
network,
|
|
126
|
+
address,
|
|
127
|
+
ethabi,
|
|
128
|
+
)
|
|
110
129
|
|
|
111
130
|
// Handle the collisions edge case by copying another data source yaml data
|
|
112
131
|
if (mergeEntities && onlyCollisions) {
|
|
@@ -126,7 +145,7 @@ module.exports = {
|
|
|
126
145
|
await Subgraph.write(result, manifestPath)
|
|
127
146
|
|
|
128
147
|
// Update networks.json
|
|
129
|
-
const networksFile = networkFile ||
|
|
148
|
+
const networksFile = networkFile || './networks.json'
|
|
130
149
|
await updateNetworksFile(toolbox, network, contractName, address, networksFile)
|
|
131
150
|
|
|
132
151
|
// Detect Yarn and/or NPM
|
|
@@ -146,28 +165,26 @@ module.exports = {
|
|
|
146
165
|
'Warning during codegen',
|
|
147
166
|
async spinner => {
|
|
148
167
|
await system.run(yarn ? 'yarn codegen' : 'npm run codegen')
|
|
149
|
-
}
|
|
168
|
+
},
|
|
150
169
|
)
|
|
151
|
-
}
|
|
170
|
+
},
|
|
152
171
|
}
|
|
153
172
|
|
|
154
|
-
const getEntities =
|
|
155
|
-
let dataSources = manifest.result.get('dataSources',
|
|
156
|
-
let templates = manifest.result.get('templates',
|
|
173
|
+
const getEntities = manifest => {
|
|
174
|
+
let dataSources = manifest.result.get('dataSources', [])
|
|
175
|
+
let templates = manifest.result.get('templates', [])
|
|
157
176
|
|
|
158
177
|
return dataSources
|
|
159
178
|
.concat(templates)
|
|
160
|
-
.map(dataSource => dataSource.
|
|
179
|
+
.map(dataSource => dataSource.mapping?.entities)
|
|
161
180
|
.flatten()
|
|
162
181
|
}
|
|
163
182
|
|
|
164
|
-
const getContractNames =
|
|
165
|
-
let dataSources = manifest.result.get('dataSources',
|
|
166
|
-
let templates = manifest.result.get('templates',
|
|
183
|
+
const getContractNames = manifest => {
|
|
184
|
+
let dataSources = manifest.result.get('dataSources', [])
|
|
185
|
+
let templates = manifest.result.get('templates', [])
|
|
167
186
|
|
|
168
|
-
return dataSources
|
|
169
|
-
.concat(templates)
|
|
170
|
-
.map(dataSource => dataSource.get('name'))
|
|
187
|
+
return dataSources.concat(templates).map(dataSource => dataSource.get('name'))
|
|
171
188
|
}
|
|
172
189
|
|
|
173
190
|
const updateEventNamesOnCollision = (ethabi, entities, contractName, mergeEntities) => {
|
|
@@ -179,7 +196,7 @@ const updateEventNamesOnCollision = (ethabi, entities, contractName, mergeEntiti
|
|
|
179
196
|
for (let i = 0; i < abiData.size; i++) {
|
|
180
197
|
let dataRow = abiData.get(i).asMutable()
|
|
181
198
|
|
|
182
|
-
if (dataRow.get('type') === 'event'){
|
|
199
|
+
if (dataRow.get('type') === 'event') {
|
|
183
200
|
if (entities.indexOf(dataRow.get('name')) !== -1) {
|
|
184
201
|
if (entities.indexOf(`${contractName}${dataRow.get('name')}`) !== -1) {
|
|
185
202
|
print.error(`Contract name ('${contractName}')
|
|
@@ -190,7 +207,7 @@ const updateEventNamesOnCollision = (ethabi, entities, contractName, mergeEntiti
|
|
|
190
207
|
|
|
191
208
|
if (mergeEntities) {
|
|
192
209
|
collisionEntities.push(dataRow.get('name'))
|
|
193
|
-
abiData = abiData.
|
|
210
|
+
abiData = abiData.delete(i)
|
|
194
211
|
i-- // deletion also shifts values to the left
|
|
195
212
|
continue
|
|
196
213
|
} else {
|
|
@@ -200,7 +217,7 @@ const updateEventNamesOnCollision = (ethabi, entities, contractName, mergeEntiti
|
|
|
200
217
|
onlyCollisions = false
|
|
201
218
|
}
|
|
202
219
|
}
|
|
203
|
-
abiData = abiData.
|
|
220
|
+
abiData = abiData.set(i, dataRow)
|
|
204
221
|
}
|
|
205
222
|
|
|
206
223
|
return { abiData, collisionEntities, onlyCollisions }
|
package/src/compiler/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const chalk = require('chalk')
|
|
2
2
|
const crypto = require('crypto')
|
|
3
3
|
const fs = require('fs-extra')
|
|
4
|
-
const immutable = require('immutable')
|
|
5
4
|
const path = require('path')
|
|
6
5
|
const yaml = require('js-yaml')
|
|
7
6
|
const toolbox = require('gluegun/toolbox')
|
|
@@ -141,12 +140,12 @@ class Compiler {
|
|
|
141
140
|
files.push(this.options.subgraphManifest)
|
|
142
141
|
|
|
143
142
|
// Add all file paths specified in manifest
|
|
144
|
-
files.push(path.resolve(subgraph.
|
|
143
|
+
files.push(path.resolve(subgraph.schema?.file))
|
|
145
144
|
subgraph.get('dataSources').map(dataSource => {
|
|
146
|
-
files.push(dataSource.
|
|
145
|
+
files.push(dataSource.mapping?.file)
|
|
147
146
|
// Only watch ABI related files if the target protocol has support/need for them.
|
|
148
147
|
if (this.protocol.hasABIs()) {
|
|
149
|
-
dataSource.
|
|
148
|
+
dataSource.mapping?.abis.map(abi => {
|
|
150
149
|
files.push(abi.get('file'))
|
|
151
150
|
})
|
|
152
151
|
}
|
|
@@ -258,7 +257,7 @@ class Compiler {
|
|
|
258
257
|
}
|
|
259
258
|
|
|
260
259
|
try {
|
|
261
|
-
let dataSourceName = dataSource.
|
|
260
|
+
let dataSourceName = dataSource.name
|
|
262
261
|
|
|
263
262
|
let baseDir = this.sourceDir
|
|
264
263
|
let absoluteMappingPath = path.resolve(baseDir, mappingPath)
|
|
@@ -552,7 +551,7 @@ class Compiler {
|
|
|
552
551
|
updates.push({
|
|
553
552
|
keyPath: ['schema', 'file'],
|
|
554
553
|
value: await this._uploadFileToIPFS(
|
|
555
|
-
subgraph.
|
|
554
|
+
subgraph.schema?.file,
|
|
556
555
|
uploadedFiles,
|
|
557
556
|
spinner,
|
|
558
557
|
),
|
|
@@ -560,7 +559,7 @@ class Compiler {
|
|
|
560
559
|
|
|
561
560
|
if (this.protocol.hasABIs()) {
|
|
562
561
|
for (let [i, dataSource] of subgraph.get('dataSources').entries()) {
|
|
563
|
-
for (let [j, abi] of dataSource.
|
|
562
|
+
for (let [j, abi] of dataSource.mapping?.abis.entries()) {
|
|
564
563
|
updates.push({
|
|
565
564
|
keyPath: ['dataSources', i, 'mapping', 'abis', j, 'file'],
|
|
566
565
|
value: await this._uploadFileToIPFS(
|
|
@@ -579,7 +578,7 @@ class Compiler {
|
|
|
579
578
|
updates.push({
|
|
580
579
|
keyPath: ['dataSources', i, 'mapping', 'file'],
|
|
581
580
|
value: await this._uploadFileToIPFS(
|
|
582
|
-
dataSource.
|
|
581
|
+
dataSource.mapping?.file,
|
|
583
582
|
uploadedFiles,
|
|
584
583
|
spinner,
|
|
585
584
|
),
|
|
@@ -590,7 +589,7 @@ class Compiler {
|
|
|
590
589
|
updates.push({
|
|
591
590
|
keyPath: ['dataSources', i, 'source', 'package', 'file'],
|
|
592
591
|
value: await this._uploadFileToIPFS(
|
|
593
|
-
dataSource.
|
|
592
|
+
dataSource.source', 'package?.file,
|
|
594
593
|
uploadedFiles,
|
|
595
594
|
spinner,
|
|
596
595
|
),
|
|
@@ -598,9 +597,9 @@ class Compiler {
|
|
|
598
597
|
}
|
|
599
598
|
}
|
|
600
599
|
|
|
601
|
-
for (let [i, template] of subgraph.get('templates',
|
|
600
|
+
for (let [i, template] of subgraph.get('templates', []).entries()) {
|
|
602
601
|
if (this.protocol.hasABIs()) {
|
|
603
|
-
for (let [j, abi] of template.
|
|
602
|
+
for (let [j, abi] of template.mapping?.abis.entries()) {
|
|
604
603
|
updates.push({
|
|
605
604
|
keyPath: ['templates', i, 'mapping', 'abis', j, 'file'],
|
|
606
605
|
value: await this._uploadFileToIPFS(
|
|
@@ -615,7 +614,7 @@ class Compiler {
|
|
|
615
614
|
updates.push({
|
|
616
615
|
keyPath: ['templates', i, 'mapping', 'file'],
|
|
617
616
|
value: await this._uploadFileToIPFS(
|
|
618
|
-
template.
|
|
617
|
+
template.mapping?.file,
|
|
619
618
|
uploadedFiles,
|
|
620
619
|
spinner,
|
|
621
620
|
),
|
|
@@ -661,7 +660,7 @@ class Compiler {
|
|
|
661
660
|
' ..',
|
|
662
661
|
`${hash}${alreadyUploaded ? ' (already uploaded)' : ''}`,
|
|
663
662
|
)
|
|
664
|
-
return
|
|
663
|
+
return { '/': `/ipfs/${hash}` }
|
|
665
664
|
}
|
|
666
665
|
|
|
667
666
|
async _uploadSubgraphDefinitionToIPFS(subgraph) {
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
const immutable = require('immutable')
|
|
2
|
-
|
|
3
1
|
module.exports = class ArweaveSubgraph {
|
|
4
2
|
constructor(options = {}) {
|
|
5
3
|
this.manifest = options.manifest
|
|
@@ -8,13 +6,10 @@ module.exports = class ArweaveSubgraph {
|
|
|
8
6
|
}
|
|
9
7
|
|
|
10
8
|
validateManifest() {
|
|
11
|
-
return
|
|
9
|
+
return []
|
|
12
10
|
}
|
|
13
11
|
|
|
14
12
|
handlerTypes() {
|
|
15
|
-
return
|
|
16
|
-
'blockHandlers',
|
|
17
|
-
'transactionHandlers',
|
|
18
|
-
])
|
|
13
|
+
return ['blockHandlers', 'transactionHandlers']
|
|
19
14
|
}
|
|
20
15
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
const immutable = require('immutable')
|
|
2
|
-
|
|
3
1
|
module.exports = class CosmosSubgraph {
|
|
4
2
|
constructor(options = {}) {
|
|
5
3
|
this.manifest = options.manifest
|
|
@@ -8,15 +6,10 @@ module.exports = class CosmosSubgraph {
|
|
|
8
6
|
}
|
|
9
7
|
|
|
10
8
|
validateManifest() {
|
|
11
|
-
return
|
|
9
|
+
return []
|
|
12
10
|
}
|
|
13
11
|
|
|
14
12
|
handlerTypes() {
|
|
15
|
-
return
|
|
16
|
-
'blockHandlers',
|
|
17
|
-
'eventHandlers',
|
|
18
|
-
'transactionHandlers',
|
|
19
|
-
'messageHandlers',
|
|
20
|
-
])
|
|
13
|
+
return ['blockHandlers', 'eventHandlers', 'transactionHandlers', 'messageHandlers']
|
|
21
14
|
}
|
|
22
15
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const fs = require('fs-extra')
|
|
2
|
-
const immutable = require('immutable')
|
|
3
2
|
const path = require('path')
|
|
4
3
|
|
|
5
4
|
const AbiCodeGenerator = require('./codegen/abi')
|
|
@@ -104,17 +103,17 @@ module.exports = class ABI {
|
|
|
104
103
|
callFunctions() {
|
|
105
104
|
// An entry is a function if its type is not set or if it is one of
|
|
106
105
|
// 'constructor', 'function' or 'fallback'
|
|
107
|
-
let functionTypes =
|
|
106
|
+
let functionTypes = new Set(['constructor', 'function', 'fallback'])
|
|
108
107
|
let functions = this.data.filter(
|
|
109
|
-
entry => !entry.has('type') || functionTypes.
|
|
108
|
+
entry => !entry.has('type') || functionTypes.has(entry.get('type')),
|
|
110
109
|
)
|
|
111
110
|
|
|
112
111
|
// A function is a call function if it is nonpayable, payable or
|
|
113
112
|
// not constant
|
|
114
|
-
let mutabilityTypes =
|
|
113
|
+
let mutabilityTypes =new Set(['nonpayable', 'payable'])
|
|
115
114
|
return functions.filter(
|
|
116
115
|
entry =>
|
|
117
|
-
mutabilityTypes.
|
|
116
|
+
mutabilityTypes.has(entry.get('stateMutability')) ||
|
|
118
117
|
entry.get('constant') === false,
|
|
119
118
|
)
|
|
120
119
|
}
|
|
@@ -125,7 +124,7 @@ module.exports = class ABI {
|
|
|
125
124
|
.map(entry => {
|
|
126
125
|
const name = entry.get('name', '<default>')
|
|
127
126
|
const inputs = entry
|
|
128
|
-
.get('inputs',
|
|
127
|
+
.get('inputs', [])
|
|
129
128
|
.map(input => buildSignatureParameter(input))
|
|
130
129
|
|
|
131
130
|
return `${name}(${inputs.join(',')})`
|
|
@@ -155,6 +154,6 @@ module.exports = class ABI {
|
|
|
155
154
|
throw Error(`No valid ABI in file: ${path.relative(process.cwd(), file)}`)
|
|
156
155
|
}
|
|
157
156
|
|
|
158
|
-
return new ABI(name, file,
|
|
157
|
+
return new ABI(name, file, abi)
|
|
159
158
|
}
|
|
160
159
|
}
|