@graphprotocol/graph-cli 0.30.0-alpha.1 → 0.30.2
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/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/chain/arweave.ts +76 -0
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/chain/cosmos.ts +341 -0
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/chain/ethereum.ts +39 -0
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/global/global.ts +286 -142
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/index.ts +4 -2
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/package.json +2 -1
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/test/test.js +4 -2
- package/examples/basic-event-handlers/node_modules/keccak/build/config.gypi +300 -125
- package/examples/basic-event-handlers/node_modules/websocket/build/config.gypi +292 -15
- package/examples/basic-event-handlers/package.json +1 -1
- package/examples/basic-event-handlers/yarn.lock +4 -4
- package/examples/example-subgraph/package.json +1 -1
- package/examples/example-subgraph/yarn.lock +4 -4
- package/package.json +1 -1
- package/src/codegen/schema.js +5 -1
- package/src/codegen/schema.test.js +102 -0
- package/src/command-helpers/abi.js +69 -0
- package/src/command-helpers/scaffold.js +65 -0
- package/src/commands/add.js +198 -0
- package/src/commands/init.js +23 -72
- package/src/migrations.js +0 -2
- package/src/protocols/arweave/manifest.graphql +57 -0
- package/src/protocols/arweave/scaffold/manifest.js +19 -0
- package/src/protocols/arweave/scaffold/mapping.js +53 -0
- package/src/protocols/arweave/subgraph.js +20 -0
- package/src/protocols/{tendermint → cosmos}/manifest.graphql +6 -0
- package/src/protocols/cosmos/scaffold/manifest.js +16 -0
- package/src/protocols/cosmos/scaffold/mapping.js +39 -0
- package/src/protocols/{tendermint → cosmos}/subgraph.js +2 -1
- package/src/protocols/ethereum/codegen/abi.js +21 -4
- package/src/protocols/ethereum/scaffold/manifest.js +2 -1
- package/src/protocols/index.js +51 -18
- package/src/protocols/near/manifest.graphql +1 -0
- package/src/protocols/near/scaffold/manifest.js +4 -2
- package/src/scaffold/cosmos.test.js +86 -0
- package/src/scaffold/ethereum.test.js +2 -2
- package/src/scaffold/index.js +3 -2
- package/src/scaffold/near.test.js +2 -2
- package/src/validation/schema.js +2 -0
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/chain/tendermint.ts +0 -554
- package/examples/basic-event-handlers/node_modules/keccak/build/Makefile +0 -342
- package/examples/basic-event-handlers/node_modules/keccak/build/Release/.deps/Release/obj.target/keccak/src/addon.o.d.raw +0 -27
- package/examples/basic-event-handlers/node_modules/keccak/build/binding.Makefile +0 -6
- package/examples/basic-event-handlers/node_modules/keccak/build/gyp-mac-tool +0 -615
- package/examples/basic-event-handlers/node_modules/keccak/build/keccak.target.mk +0 -209
- package/examples/basic-event-handlers/node_modules/websocket/build/Makefile +0 -347
- package/examples/basic-event-handlers/node_modules/websocket/build/Release/.deps/Release/obj.target/bufferutil/src/bufferutil.o.d.raw +0 -25
- package/examples/basic-event-handlers/node_modules/websocket/build/binding.Makefile +0 -6
- package/examples/basic-event-handlers/node_modules/websocket/build/bufferutil.target.mk +0 -192
- package/examples/basic-event-handlers/node_modules/websocket/build/gyp-mac-tool +0 -615
- package/examples/basic-event-handlers/node_modules/websocket/build/validation.target.mk +0 -192
- package/src/codegen/types/defaults.js +0 -34
- package/src/migrations/mapping_api_version_0_0_6.js +0 -74
- package/src/migrations/spec_version_0_0_4.js +0 -25
- package/tests/cli/init/ethereum/from-example/.gitattributes +0 -1
- package/tests/cli/init/ethereum/from-example/LICENSE +0 -21
- package/tests/cli/init/ethereum/from-example/README.md +0 -3
- package/tests/cli/init/ethereum/from-example/abis/Gravity.json +0 -1
- package/tests/cli/init/ethereum/from-example/bin/Counter.bin +0 -1
- package/tests/cli/init/ethereum/from-example/contracts/Gravity.sol +0 -63
- package/tests/cli/init/ethereum/from-example/contracts/Migrations.sol +0 -23
- package/tests/cli/init/ethereum/from-example/docker-compose.yml +0 -39
- package/tests/cli/init/ethereum/from-example/migrations/1_initial_migration.js +0 -5
- package/tests/cli/init/ethereum/from-example/migrations/2_deploy_contract.js +0 -5
- package/tests/cli/init/ethereum/from-example/migrations/3_create_gravatars.js +0 -15
- package/tests/cli/init/ethereum/from-example/networks.json +0 -7
- package/tests/cli/init/ethereum/from-example/package.json +0 -23
- package/tests/cli/init/ethereum/from-example/schema.graphql +0 -6
- package/tests/cli/init/ethereum/from-example/src/mapping.ts +0 -22
- package/tests/cli/init/ethereum/from-example/subgraph.yaml +0 -27
- package/tests/cli/init/ethereum/from-example/truffle.js +0 -27
- package/tests/cli/init/ethereum/from-example/yarn.lock +0 -5977
|
@@ -212,11 +212,16 @@ module.exports = class AbiCodeGenerator {
|
|
|
212
212
|
`parameters`,
|
|
213
213
|
)
|
|
214
214
|
paramsClass.addMethod(paramObject.getter)
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
215
|
+
|
|
216
|
+
// Fixture generation
|
|
217
|
+
if (doFixtureCodegen) {
|
|
218
|
+
let ethType = typesCodegen.ethereumTypeForAsc(paramObject.getter.returnType)
|
|
219
|
+
if (typeof ethType === typeof {} && (ethType.test("int256") || ethType.test("uint256"))) {
|
|
220
|
+
ethType = "int32"
|
|
221
|
+
}
|
|
222
|
+
namesAndTypes.push({name: paramObject.getter.name.slice(4), type: ethType})
|
|
218
223
|
}
|
|
219
|
-
|
|
224
|
+
|
|
220
225
|
tupleClasses.push(...paramObject.classes)
|
|
221
226
|
})
|
|
222
227
|
|
|
@@ -497,6 +502,18 @@ module.exports = class AbiCodeGenerator {
|
|
|
497
502
|
),
|
|
498
503
|
)
|
|
499
504
|
.forEach(member => returnType.addMember(member))
|
|
505
|
+
|
|
506
|
+
// Add getters to the type
|
|
507
|
+
outputs
|
|
508
|
+
.map((output, index) =>
|
|
509
|
+
!!output.get('name') && tsCodegen.method(
|
|
510
|
+
`get${output.get('name')[0].toUpperCase()}${output.get('name').slice(1)}`,
|
|
511
|
+
[],
|
|
512
|
+
this._getTupleParamType(output, index, tupleResultParentType),
|
|
513
|
+
`return this.value${index};`
|
|
514
|
+
)
|
|
515
|
+
)
|
|
516
|
+
.forEach(method => !!method && returnType.addMethod(method))
|
|
500
517
|
|
|
501
518
|
// Create types for Tuple outputs
|
|
502
519
|
outputs.forEach((output, index) => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const { abiEvents } = require('../../../scaffold/schema')
|
|
2
|
+
const { strings } = require('gluegun')
|
|
2
3
|
const ABI = require('../abi')
|
|
3
4
|
|
|
4
5
|
const source = ({ contract, contractName }) => `
|
|
@@ -24,7 +25,7 @@ const mapping = ({ abi, contractName }) => `
|
|
|
24
25
|
handler: handle${event.get('_alias')}`,
|
|
25
26
|
)
|
|
26
27
|
.join('')}
|
|
27
|
-
file: ./src
|
|
28
|
+
file: ./src/${strings.kebabCase(contractName)}.ts`
|
|
28
29
|
|
|
29
30
|
module.exports = {
|
|
30
31
|
source,
|
package/src/protocols/index.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
const immutable = require('immutable')
|
|
2
|
+
const ArweaveSubgraph = require('./arweave/subgraph')
|
|
2
3
|
const EthereumTypeGenerator = require('./ethereum/type-generator')
|
|
3
4
|
const EthereumTemplateCodeGen = require('./ethereum/codegen/template')
|
|
4
5
|
const EthereumABI = require('./ethereum/abi')
|
|
5
6
|
const EthereumSubgraph = require('./ethereum/subgraph')
|
|
6
7
|
const NearSubgraph = require('./near/subgraph')
|
|
7
|
-
const
|
|
8
|
+
const CosmosSubgraph = require('./cosmos/subgraph')
|
|
8
9
|
const EthereumContract = require('./ethereum/contract')
|
|
9
10
|
const NearContract = require('./near/contract')
|
|
10
11
|
const EthereumManifestScaffold = require('./ethereum/scaffold/manifest')
|
|
11
12
|
const NearManifestScaffold = require('./near/scaffold/manifest')
|
|
13
|
+
const CosmosManifestScaffold = require('./cosmos/scaffold/manifest')
|
|
14
|
+
const ArweaveMappingScaffold = require('./arweave/scaffold/mapping')
|
|
12
15
|
const EthereumMappingScaffold = require('./ethereum/scaffold/mapping')
|
|
13
16
|
const NearMappingScaffold = require('./near/scaffold/mapping')
|
|
17
|
+
const CosmosMappingScaffold = require('./cosmos/scaffold/mapping')
|
|
14
18
|
|
|
15
19
|
module.exports = class Protocol {
|
|
16
20
|
static fromDataSources(dataSourcesAndTemplates) {
|
|
@@ -26,14 +30,16 @@ module.exports = class Protocol {
|
|
|
26
30
|
return immutable.fromJS({
|
|
27
31
|
// `ethereum/contract` is kept for backwards compatibility.
|
|
28
32
|
// New networks (or protocol perhaps) shouldn't have the `/contract` anymore (unless a new case makes use of it).
|
|
33
|
+
arweave: ['arweave'],
|
|
29
34
|
ethereum: ['ethereum', 'ethereum/contract'],
|
|
30
35
|
near: ['near'],
|
|
31
|
-
|
|
36
|
+
cosmos: ['cosmos']
|
|
32
37
|
})
|
|
33
38
|
}
|
|
34
39
|
|
|
35
40
|
static availableNetworks() {
|
|
36
41
|
return immutable.fromJS({
|
|
42
|
+
arweave: ['arweave-mainnet'],
|
|
37
43
|
ethereum: [
|
|
38
44
|
'mainnet',
|
|
39
45
|
'kovan',
|
|
@@ -63,7 +69,12 @@ module.exports = class Protocol {
|
|
|
63
69
|
'aurora-testnet',
|
|
64
70
|
],
|
|
65
71
|
near: ['near-mainnet', 'near-testnet'],
|
|
66
|
-
|
|
72
|
+
cosmos: [
|
|
73
|
+
'cosmoshub-4',
|
|
74
|
+
'theta-testnet-001',
|
|
75
|
+
'osmosis-1',
|
|
76
|
+
'osmo-test-4'
|
|
77
|
+
],
|
|
67
78
|
})
|
|
68
79
|
}
|
|
69
80
|
|
|
@@ -75,12 +86,14 @@ module.exports = class Protocol {
|
|
|
75
86
|
|
|
76
87
|
displayName() {
|
|
77
88
|
switch (this.name) {
|
|
89
|
+
case 'arweave':
|
|
90
|
+
return 'Arweave'
|
|
78
91
|
case 'ethereum':
|
|
79
92
|
return 'Ethereum'
|
|
80
93
|
case 'near':
|
|
81
94
|
return 'NEAR'
|
|
82
|
-
case '
|
|
83
|
-
return '
|
|
95
|
+
case 'cosmos':
|
|
96
|
+
return 'Cosmos'
|
|
84
97
|
}
|
|
85
98
|
}
|
|
86
99
|
|
|
@@ -94,55 +107,65 @@ module.exports = class Protocol {
|
|
|
94
107
|
|
|
95
108
|
hasABIs() {
|
|
96
109
|
switch (this.name) {
|
|
110
|
+
case 'arweave':
|
|
111
|
+
return false
|
|
97
112
|
case 'ethereum':
|
|
98
113
|
return true
|
|
99
114
|
case 'near':
|
|
100
115
|
return false
|
|
101
|
-
case '
|
|
116
|
+
case 'cosmos':
|
|
102
117
|
return false
|
|
103
118
|
}
|
|
104
119
|
}
|
|
105
120
|
|
|
106
121
|
hasContract() {
|
|
107
122
|
switch (this.name) {
|
|
123
|
+
case 'arweave':
|
|
124
|
+
return false
|
|
108
125
|
case 'ethereum':
|
|
109
126
|
return true
|
|
110
127
|
case 'near':
|
|
111
128
|
return true
|
|
112
|
-
case '
|
|
129
|
+
case 'cosmos':
|
|
113
130
|
return false
|
|
114
131
|
}
|
|
115
132
|
}
|
|
116
133
|
|
|
117
134
|
hasEvents() {
|
|
118
135
|
switch (this.name) {
|
|
136
|
+
case 'arweave':
|
|
137
|
+
return false
|
|
119
138
|
case 'ethereum':
|
|
120
139
|
return true
|
|
121
140
|
case 'near':
|
|
122
141
|
return false
|
|
123
|
-
case '
|
|
142
|
+
case 'cosmos':
|
|
124
143
|
return false
|
|
125
144
|
}
|
|
126
145
|
}
|
|
127
146
|
|
|
128
147
|
hasTemplates() {
|
|
129
148
|
switch (this.name) {
|
|
149
|
+
case 'arweave':
|
|
150
|
+
return false
|
|
130
151
|
case 'ethereum':
|
|
131
152
|
return true
|
|
132
153
|
case 'near':
|
|
133
154
|
return false
|
|
134
|
-
case '
|
|
155
|
+
case 'cosmos':
|
|
135
156
|
return false
|
|
136
157
|
}
|
|
137
158
|
}
|
|
138
159
|
|
|
139
160
|
getTypeGenerator(options) {
|
|
140
161
|
switch (this.name) {
|
|
162
|
+
case 'arweave':
|
|
163
|
+
return null
|
|
141
164
|
case 'ethereum':
|
|
142
165
|
return new EthereumTypeGenerator(options)
|
|
143
166
|
case 'near':
|
|
144
167
|
return null
|
|
145
|
-
case '
|
|
168
|
+
case 'cosmos':
|
|
146
169
|
return null
|
|
147
170
|
}
|
|
148
171
|
}
|
|
@@ -164,11 +187,13 @@ module.exports = class Protocol {
|
|
|
164
187
|
|
|
165
188
|
getABI() {
|
|
166
189
|
switch (this.name) {
|
|
190
|
+
case 'arweave':
|
|
191
|
+
return null
|
|
167
192
|
case 'ethereum':
|
|
168
193
|
return EthereumABI
|
|
169
194
|
case 'near':
|
|
170
195
|
return null
|
|
171
|
-
case '
|
|
196
|
+
case 'cosmos':
|
|
172
197
|
return null
|
|
173
198
|
}
|
|
174
199
|
}
|
|
@@ -177,12 +202,14 @@ module.exports = class Protocol {
|
|
|
177
202
|
const optionsWithProtocol = { ...options, protocol: this }
|
|
178
203
|
|
|
179
204
|
switch (this.name) {
|
|
205
|
+
case 'arweave':
|
|
206
|
+
return new ArweaveSubgraph(optionsWithProtocol)
|
|
180
207
|
case 'ethereum':
|
|
181
208
|
return new EthereumSubgraph(optionsWithProtocol)
|
|
182
209
|
case 'near':
|
|
183
210
|
return new NearSubgraph(optionsWithProtocol)
|
|
184
|
-
case '
|
|
185
|
-
return new
|
|
211
|
+
case 'cosmos':
|
|
212
|
+
return new CosmosSubgraph(optionsWithProtocol)
|
|
186
213
|
default:
|
|
187
214
|
throw new Error(`Data sources with kind '${this.name}' are not supported yet`)
|
|
188
215
|
}
|
|
@@ -190,34 +217,40 @@ module.exports = class Protocol {
|
|
|
190
217
|
|
|
191
218
|
getContract() {
|
|
192
219
|
switch (this.name) {
|
|
220
|
+
case 'arweave':
|
|
221
|
+
return null
|
|
193
222
|
case 'ethereum':
|
|
194
223
|
return EthereumContract
|
|
195
224
|
case 'near':
|
|
196
225
|
return NearContract
|
|
197
|
-
case '
|
|
226
|
+
case 'cosmos':
|
|
198
227
|
return null
|
|
199
228
|
}
|
|
200
229
|
}
|
|
201
230
|
|
|
202
231
|
getManifestScaffold() {
|
|
203
232
|
switch (this.name) {
|
|
233
|
+
case 'arweave':
|
|
234
|
+
return ArweaveMappingScaffold
|
|
204
235
|
case 'ethereum':
|
|
205
236
|
return EthereumManifestScaffold
|
|
206
237
|
case 'near':
|
|
207
238
|
return NearManifestScaffold
|
|
208
|
-
case '
|
|
209
|
-
return
|
|
239
|
+
case 'cosmos':
|
|
240
|
+
return CosmosManifestScaffold
|
|
210
241
|
}
|
|
211
242
|
}
|
|
212
243
|
|
|
213
244
|
getMappingScaffold() {
|
|
214
245
|
switch (this.name) {
|
|
246
|
+
case 'arweave':
|
|
247
|
+
return ArweaveMappingScaffold
|
|
215
248
|
case 'ethereum':
|
|
216
249
|
return EthereumMappingScaffold
|
|
217
250
|
case 'near':
|
|
218
251
|
return NearMappingScaffold
|
|
219
|
-
case '
|
|
220
|
-
return
|
|
252
|
+
case 'cosmos':
|
|
253
|
+
return CosmosMappingScaffold
|
|
221
254
|
}
|
|
222
255
|
}
|
|
223
256
|
}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
+
const { strings } = require('gluegun')
|
|
2
|
+
|
|
1
3
|
const source = ({ contract }) => `
|
|
2
4
|
account: '${contract}'`
|
|
3
5
|
|
|
4
|
-
const mapping = () => `
|
|
6
|
+
const mapping = ({ contractName }) => `
|
|
5
7
|
apiVersion: 0.0.5
|
|
6
8
|
language: wasm/assemblyscript
|
|
7
9
|
entities:
|
|
8
10
|
- ExampleEntity
|
|
9
11
|
receiptHandlers:
|
|
10
12
|
- handler: handleReceipt
|
|
11
|
-
file: ./src
|
|
13
|
+
file: ./src/${strings.kebabCase(contractName)}.ts`
|
|
12
14
|
|
|
13
15
|
module.exports = {
|
|
14
16
|
source,
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
const immutable = require('immutable')
|
|
2
|
+
const Scaffold = require('./')
|
|
3
|
+
const Protocol = require('../protocols')
|
|
4
|
+
|
|
5
|
+
const protocol = new Protocol('cosmos')
|
|
6
|
+
|
|
7
|
+
const scaffoldOptions = {
|
|
8
|
+
protocol,
|
|
9
|
+
network: 'cosmoshub-4',
|
|
10
|
+
contractName: 'CosmosHub'
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const scaffold = new Scaffold(scaffoldOptions)
|
|
14
|
+
|
|
15
|
+
describe('Cosmos subgraph scaffolding', () => {
|
|
16
|
+
test('Manifest', () => {
|
|
17
|
+
expect(
|
|
18
|
+
scaffold.generateManifest(),
|
|
19
|
+
).toEqual(`\
|
|
20
|
+
specVersion: 0.0.1
|
|
21
|
+
schema:
|
|
22
|
+
file: ./schema.graphql
|
|
23
|
+
dataSources:
|
|
24
|
+
- kind: cosmos
|
|
25
|
+
name: CosmosHub
|
|
26
|
+
network: cosmoshub-4
|
|
27
|
+
source:
|
|
28
|
+
startBlock: 0
|
|
29
|
+
mapping:
|
|
30
|
+
apiVersion: 0.0.5
|
|
31
|
+
language: wasm/assemblyscript
|
|
32
|
+
entities:
|
|
33
|
+
- ExampleEntity
|
|
34
|
+
blockHandlers:
|
|
35
|
+
- handler: handleBlock
|
|
36
|
+
file: ./src/contract.ts
|
|
37
|
+
`)
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
test('Schema (default)', () => {
|
|
41
|
+
expect(scaffold.generateSchema()).toEqual(`\
|
|
42
|
+
type ExampleEntity @entity {
|
|
43
|
+
id: ID!
|
|
44
|
+
block: Bytes!
|
|
45
|
+
count: BigInt!
|
|
46
|
+
}
|
|
47
|
+
`)
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
test('Mapping (default)', () => {
|
|
51
|
+
expect(scaffold.generateMapping()).toEqual(`\
|
|
52
|
+
import { cosmos, BigInt } from "@graphprotocol/graph-ts"
|
|
53
|
+
import { ExampleEntity } from "../generated/schema"
|
|
54
|
+
|
|
55
|
+
export function handleBlock(block: cosmos.Block): void {
|
|
56
|
+
// Entities can be loaded from the store using a string ID; this ID
|
|
57
|
+
// needs to be unique across all entities of the same type
|
|
58
|
+
let entity = ExampleEntity.load(block.header.hash.toHex())
|
|
59
|
+
|
|
60
|
+
// Entities only exist after they have been saved to the store;
|
|
61
|
+
// \`null\` checks allow to create entities on demand
|
|
62
|
+
if (!entity) {
|
|
63
|
+
entity = new ExampleEntity(block.header.hash.toHex())
|
|
64
|
+
|
|
65
|
+
// Entity fields can be set using simple assignments
|
|
66
|
+
entity.count = BigInt.fromI32(0)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// BigInt and BigDecimal math are supported
|
|
70
|
+
entity.count = entity.count + BigInt.fromI32(1)
|
|
71
|
+
|
|
72
|
+
// Entity fields can be set based on receipt information
|
|
73
|
+
entity.height = block.header.height
|
|
74
|
+
|
|
75
|
+
// Entities can be written to the store with \`.save()\`
|
|
76
|
+
entity.save()
|
|
77
|
+
|
|
78
|
+
// Note: If a handler doesn't require existing field values, it is faster
|
|
79
|
+
// _not_ to load the entity from the store. Instead, create it fresh with
|
|
80
|
+
// \`new Entity(...)\`, set the fields that should be updated and save the
|
|
81
|
+
// entity back to the store. Fields that were not set or unset remain
|
|
82
|
+
// unchanged, allowing for partial updates to be applied.
|
|
83
|
+
}
|
|
84
|
+
`)
|
|
85
|
+
})
|
|
86
|
+
})
|
|
@@ -76,7 +76,7 @@ const scaffoldOptions = {
|
|
|
76
76
|
abi: TEST_ABI,
|
|
77
77
|
contract: '0xf87e31492faf9a91b02ee0deaad50d51d56d5d4d',
|
|
78
78
|
network: 'kovan',
|
|
79
|
-
contractName: 'Contract'
|
|
79
|
+
contractName: 'Contract'
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
const scaffold = new Scaffold(scaffoldOptions)
|
|
@@ -116,7 +116,7 @@ dataSources:
|
|
|
116
116
|
handler: handleExampleEvent
|
|
117
117
|
- event: ExampleEvent(bytes32)
|
|
118
118
|
handler: handleExampleEvent1
|
|
119
|
-
file: ./src/
|
|
119
|
+
file: ./src/contract.ts
|
|
120
120
|
`)
|
|
121
121
|
})
|
|
122
122
|
|
package/src/scaffold/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const prettier = require('prettier')
|
|
2
2
|
const pkginfo = require('pkginfo')(module)
|
|
3
|
+
const { strings } = require('gluegun')
|
|
3
4
|
|
|
4
5
|
const GRAPH_CLI_VERSION = process.env.GRAPH_CLI_TESTS
|
|
5
6
|
// JSON.stringify should remove this key, we will install the local
|
|
@@ -50,7 +51,7 @@ module.exports = class Scaffold {
|
|
|
50
51
|
},
|
|
51
52
|
dependencies: {
|
|
52
53
|
'@graphprotocol/graph-cli': GRAPH_CLI_VERSION,
|
|
53
|
-
'@graphprotocol/graph-ts': `0.27.0
|
|
54
|
+
'@graphprotocol/graph-ts': `0.27.0`,
|
|
54
55
|
},
|
|
55
56
|
}),
|
|
56
57
|
{ parser: 'json' },
|
|
@@ -142,7 +143,7 @@ dataSources:
|
|
|
142
143
|
'subgraph.yaml': this.generateManifest(),
|
|
143
144
|
'schema.graphql': this.generateSchema(),
|
|
144
145
|
'tsconfig.json': this.generateTsConfig(),
|
|
145
|
-
src: {
|
|
146
|
+
src: { [`${strings.kebabCase(this.contractName)}.ts`]: this.generateMapping() },
|
|
146
147
|
abis: this.generateABIs(),
|
|
147
148
|
}
|
|
148
149
|
}
|
|
@@ -8,7 +8,7 @@ const scaffoldOptions = {
|
|
|
8
8
|
protocol,
|
|
9
9
|
contract: 'abc.def.near',
|
|
10
10
|
network: 'near-mainnet',
|
|
11
|
-
contractName: 'Contract'
|
|
11
|
+
contractName: 'Contract'
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
const scaffold = new Scaffold(scaffoldOptions)
|
|
@@ -34,7 +34,7 @@ dataSources:
|
|
|
34
34
|
- ExampleEntity
|
|
35
35
|
receiptHandlers:
|
|
36
36
|
- handler: handleReceipt
|
|
37
|
-
file: ./src/
|
|
37
|
+
file: ./src/contract.ts
|
|
38
38
|
`)
|
|
39
39
|
})
|
|
40
40
|
|
package/src/validation/schema.js
CHANGED