@graphprotocol/graph-cli 0.47.0-alpha-20230413171255-6070c2c → 0.47.0-alpha-20230413212655-9de232e

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.
Files changed (100) hide show
  1. package/CHANGELOG.md +4 -6
  2. package/dist/bin.d.ts +2 -0
  3. package/dist/codegen/schema.d.ts +43 -0
  4. package/dist/codegen/schema.js +1 -8
  5. package/dist/codegen/schema.test.d.ts +1 -0
  6. package/dist/codegen/schema.test.js +33 -81
  7. package/dist/codegen/template.d.ts +11 -0
  8. package/dist/codegen/types/conversions.d.ts +6 -0
  9. package/dist/codegen/types/index.d.ts +9 -0
  10. package/dist/codegen/types/index.test.d.ts +1 -0
  11. package/dist/codegen/typescript.d.ts +78 -0
  12. package/dist/codegen/typescript.js +0 -30
  13. package/dist/codegen/util.d.ts +14 -0
  14. package/dist/codegen/util.test.d.ts +1 -0
  15. package/dist/command-helpers/abi.d.ts +8 -0
  16. package/dist/command-helpers/abi.test.d.ts +1 -0
  17. package/dist/command-helpers/auth.d.ts +2 -0
  18. package/dist/command-helpers/compiler.d.ts +13 -0
  19. package/dist/command-helpers/data-sources.d.ts +4 -0
  20. package/dist/command-helpers/fs.d.ts +2 -0
  21. package/dist/command-helpers/ipfs.d.ts +2 -0
  22. package/dist/command-helpers/jsonrpc.d.ts +2 -0
  23. package/dist/command-helpers/network.d.ts +3 -0
  24. package/dist/command-helpers/network.test.d.ts +1 -0
  25. package/dist/command-helpers/node.d.ts +13 -0
  26. package/dist/command-helpers/scaffold.d.ts +35 -0
  27. package/dist/command-helpers/spinner.d.ts +4 -0
  28. package/dist/command-helpers/studio.d.ts +6 -0
  29. package/dist/command-helpers/studio.test.d.ts +1 -0
  30. package/dist/command-helpers/subgraph.d.ts +4 -0
  31. package/dist/command-helpers/version.d.ts +2 -0
  32. package/dist/command-helpers/version.test.d.ts +1 -0
  33. package/dist/commands/add.d.ts +17 -0
  34. package/dist/commands/auth.d.ts +14 -0
  35. package/dist/commands/build.d.ts +18 -0
  36. package/dist/commands/codegen.d.ts +16 -0
  37. package/dist/commands/create.d.ts +13 -0
  38. package/dist/commands/deploy.d.ts +26 -0
  39. package/dist/commands/init.d.ts +24 -0
  40. package/dist/commands/local.d.ts +21 -0
  41. package/dist/commands/remove.d.ts +13 -0
  42. package/dist/commands/test.d.ts +17 -0
  43. package/dist/compiler/asc.d.ts +9 -0
  44. package/dist/compiler/index.d.ts +53 -0
  45. package/dist/debug.d.ts +2 -0
  46. package/dist/index.d.ts +1 -0
  47. package/dist/migrations/mapping_api_version_0_0_1.d.ts +11 -0
  48. package/dist/migrations/mapping_api_version_0_0_2.d.ts +11 -0
  49. package/dist/migrations/mapping_api_version_0_0_3.d.ts +11 -0
  50. package/dist/migrations/mapping_api_version_0_0_4.d.ts +11 -0
  51. package/dist/migrations/mapping_api_version_0_0_5.d.ts +11 -0
  52. package/dist/migrations/spec_version_0_0_2.d.ts +10 -0
  53. package/dist/migrations/spec_version_0_0_3.d.ts +10 -0
  54. package/dist/migrations/util/load-manifest.d.ts +1 -0
  55. package/dist/migrations/util/versions.d.ts +1 -0
  56. package/dist/migrations.d.ts +4 -0
  57. package/dist/protocols/arweave/scaffold/manifest.d.ts +4 -0
  58. package/dist/protocols/arweave/scaffold/mapping.d.ts +1 -0
  59. package/dist/protocols/arweave/subgraph.d.ts +10 -0
  60. package/dist/protocols/contract.d.ts +10 -0
  61. package/dist/protocols/cosmos/scaffold/manifest.d.ts +2 -0
  62. package/dist/protocols/cosmos/scaffold/mapping.d.ts +1 -0
  63. package/dist/protocols/cosmos/subgraph.d.ts +10 -0
  64. package/dist/protocols/ethereum/abi.d.ts +30 -0
  65. package/dist/protocols/ethereum/codegen/abi.d.ts +30 -0
  66. package/dist/protocols/ethereum/codegen/abi.test.d.ts +1 -0
  67. package/dist/protocols/ethereum/codegen/template.d.ts +9 -0
  68. package/dist/protocols/ethereum/contract.d.ts +10 -0
  69. package/dist/protocols/ethereum/scaffold/manifest.d.ts +10 -0
  70. package/dist/protocols/ethereum/scaffold/mapping.d.ts +6 -0
  71. package/dist/protocols/ethereum/subgraph.d.ts +15 -0
  72. package/dist/protocols/ethereum/type-generator.d.ts +23 -0
  73. package/dist/protocols/index.d.ts +38 -0
  74. package/dist/protocols/ipfs/codegen/file_template.d.ts +9 -0
  75. package/dist/protocols/near/contract.d.ts +15 -0
  76. package/dist/protocols/near/scaffold/manifest.d.ts +6 -0
  77. package/dist/protocols/near/scaffold/mapping.d.ts +1 -0
  78. package/dist/protocols/near/subgraph.d.ts +10 -0
  79. package/dist/protocols/subgraph.d.ts +10 -0
  80. package/dist/protocols/substreams/scaffold/manifest.d.ts +2 -0
  81. package/dist/protocols/substreams/subgraph.d.ts +10 -0
  82. package/dist/scaffold/cosmos.test.d.ts +1 -0
  83. package/dist/scaffold/ethereum.test.d.ts +1 -0
  84. package/dist/scaffold/index.d.ts +54 -0
  85. package/dist/scaffold/mapping.d.ts +15 -0
  86. package/dist/scaffold/near.test.d.ts +1 -0
  87. package/dist/scaffold/schema.d.ts +18 -0
  88. package/dist/scaffold/tests.d.ts +3 -0
  89. package/dist/schema.d.ts +10 -0
  90. package/dist/subgraph.d.ts +27 -0
  91. package/dist/type-generator.d.ts +29 -0
  92. package/dist/validation/contract.d.ts +11 -0
  93. package/dist/validation/index.d.ts +3 -0
  94. package/dist/validation/manifest.d.ts +4 -0
  95. package/dist/validation/schema.d.ts +7 -0
  96. package/dist/validation/schema.test.d.ts +1 -0
  97. package/dist/version.d.ts +1 -0
  98. package/dist/watcher.d.ts +15 -0
  99. package/oclif.manifest.json +1 -1
  100. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,14 +1,12 @@
1
1
  # @graphprotocol/graph-cli
2
2
 
3
- ## 0.47.0-alpha-20230413171255-6070c2c
3
+ ## 0.47.0-alpha-20230413212655-9de232e
4
4
 
5
5
  ### Minor Changes
6
6
 
7
- - [#1284](https://github.com/graphprotocol/graph-tooling/pull/1284)
8
- [`74e7bac`](https://github.com/graphprotocol/graph-tooling/commit/74e7bacbcb48b4b663cfd0e7b137f57394347174)
9
- Thanks [@saihaj](https://github.com/saihaj)! - Changing code generation so we reduce the non-null
10
- assertions for primitive types. This way we can return null for primitive types and still have the
11
- generated code compile.
7
+ - [#1293](https://github.com/graphprotocol/graph-tooling/pull/1293)
8
+ [`9de232e`](https://github.com/graphprotocol/graph-tooling/commit/9de232e144a8c78479a103443e4b4e39a18e171b)
9
+ Thanks [@enisdenjo](https://github.com/enisdenjo)! - Include declaration files
12
10
 
13
11
  ### Patch Changes
14
12
 
package/dist/bin.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,43 @@
1
+ import Schema from '../schema';
2
+ import * as tsCodegen from './typescript';
3
+ import type { DefinitionNode, FieldDefinitionNode, InterfaceTypeDefinitionNode, NamedTypeNode, ObjectTypeDefinitionNode, TypeNode } from 'graphql/language';
4
+ declare class IdField {
5
+ static BYTES: symbol;
6
+ static STRING: symbol;
7
+ private kind;
8
+ constructor(idField: FieldDefinitionNode | undefined);
9
+ typeName(): "string" | "Bytes";
10
+ gqlTypeName(): "Bytes" | "String";
11
+ tsNamedType(): tsCodegen.NamedType;
12
+ tsValueFrom(): "Value.fromBytes(id)" | "Value.fromString(id)";
13
+ tsValueKind(): "ValueKind.BYTES" | "ValueKind.STRING";
14
+ tsValueToString(): "id.toBytes().toHexString()" | "id.toString()";
15
+ tsToString(): "id.toHexString()" | "id";
16
+ static fromFields(fields: readonly FieldDefinitionNode[] | undefined): IdField;
17
+ static fromTypeDef(def: ObjectTypeDefinitionNode | InterfaceTypeDefinitionNode): IdField;
18
+ }
19
+ export default class SchemaCodeGenerator {
20
+ private schema;
21
+ constructor(schema: Schema);
22
+ generateModuleImports(): tsCodegen.ModuleImports[];
23
+ generateTypes(): Array<tsCodegen.Class>;
24
+ _isEntityTypeDefinition(def: DefinitionNode): def is ObjectTypeDefinitionNode;
25
+ _isInterfaceDefinition(def: DefinitionNode): def is InterfaceTypeDefinitionNode;
26
+ _generateEntityType(def: ObjectTypeDefinitionNode): tsCodegen.Class;
27
+ _generateConstructor(_entityName: string, fields: readonly FieldDefinitionNode[] | undefined): tsCodegen.Method;
28
+ _generateStoreMethods(entityName: string, idField: IdField): Array<tsCodegen.Method | tsCodegen.StaticMethod>;
29
+ _generateEntityFieldMethods(entityDef: ObjectTypeDefinitionNode, fieldDef: FieldDefinitionNode): Array<tsCodegen.Method>;
30
+ _generateEntityFieldGetter(_entityDef: ObjectTypeDefinitionNode, fieldDef: FieldDefinitionNode): tsCodegen.Method;
31
+ _generateEntityFieldSetter(_entityDef: ObjectTypeDefinitionNode, fieldDef: FieldDefinitionNode): tsCodegen.Method | null;
32
+ _resolveFieldType(gqlType: NamedTypeNode): string;
33
+ /** Return the type that values for this field must have. For scalar
34
+ * types, that's the type from the subgraph schema. For references to
35
+ * other entity types, this is the same as the type of the id of the
36
+ * referred type, i.e., `string` or `Bytes`*/
37
+ _valueTypeFromGraphQl(gqlType: TypeNode): string;
38
+ /** Determine the base type of `gqlType` by removing any non-null
39
+ * constraints and using the type of elements of lists */
40
+ _baseType(gqlType: TypeNode): string;
41
+ _typeFromGraphQl(gqlType: TypeNode, nullable?: boolean): tsCodegen.ArrayType | tsCodegen.NullableType | tsCodegen.NamedType;
42
+ }
43
+ export {};
@@ -158,14 +158,7 @@ class SchemaCodeGenerator {
158
158
  const fieldValueType = this._valueTypeFromGraphQl(gqlType);
159
159
  const returnType = this._typeFromGraphQl(gqlType);
160
160
  const isNullable = returnType instanceof tsCodegen.NullableType;
161
- const primitiveDefault = returnType instanceof tsCodegen.NamedType ? returnType.getPrimitiveDefault() : null;
162
- const getNonNullable = `if (!value || value.kind == ValueKind.NULL) {
163
- ${primitiveDefault === null
164
- ? "throw new Error('Cannot return null for a required field.')"
165
- : `return ${primitiveDefault}`}
166
- } else {
167
- return ${typesCodegen.valueToAsc('value', fieldValueType)}
168
- }`;
161
+ const getNonNullable = `return ${typesCodegen.valueToAsc('value!', fieldValueType)}`;
169
162
  const getNullable = `if (!value || value.kind == ValueKind.NULL) {
170
163
  return null
171
164
  } else {
@@ -0,0 +1 @@
1
+ export {};
@@ -82,7 +82,6 @@ describe('Schema code generator', () => {
82
82
  # two primitive types (i32)
83
83
  age: Int
84
84
  count: Int!
85
- isActive: Boolean
86
85
 
87
86
  # derivedFrom
88
87
  wallets: [Wallet!] @derivedFrom(field: "account")
@@ -143,12 +142,9 @@ describe('Schema code generator', () => {
143
142
  name: 'get id',
144
143
  params: [],
145
144
  returnType: new typescript_1.NamedType('string'),
146
- body: `let value = this.get('id')
147
- if (!value || value.kind == ValueKind.NULL) {
148
- throw new Error("Cannot return null for a required field.")
149
- } else {
150
- return value.toString()
151
- }
145
+ body: `
146
+ let value = this.get('id')
147
+ return value!.toString()
152
148
  `,
153
149
  },
154
150
  {
@@ -188,12 +184,9 @@ describe('Schema code generator', () => {
188
184
  name: 'get name',
189
185
  params: [],
190
186
  returnType: new typescript_1.NamedType('string'),
191
- body: `let value = this.get('name')
192
- if (!value || value.kind == ValueKind.NULL) {
193
- throw new Error("Cannot return null for a required field.")
194
- } else {
195
- return value.toString()
196
- }
187
+ body: `
188
+ let value = this.get('name')
189
+ return value!.toString()
197
190
  `,
198
191
  },
199
192
  {
@@ -208,12 +201,9 @@ describe('Schema code generator', () => {
208
201
  name: 'get age',
209
202
  params: [],
210
203
  returnType: new typescript_1.NamedType('i32'),
211
- body: `let value = this.get('age')
212
- if (!value || value.kind == ValueKind.NULL) {
213
- return 0
214
- } else {
215
- return value.toI32()
216
- }
204
+ body: `
205
+ let value = this.get('age')
206
+ return value!.toI32()
217
207
  `,
218
208
  },
219
209
  {
@@ -228,12 +218,9 @@ describe('Schema code generator', () => {
228
218
  name: 'get count',
229
219
  params: [],
230
220
  returnType: new typescript_1.NamedType('i32'),
231
- body: `let value = this.get('count')
232
- if (!value || value.kind == ValueKind.NULL) {
233
- return 0
234
- } else {
235
- return value.toI32()
236
- }
221
+ body: `
222
+ let value = this.get('count')
223
+ return value!.toI32()
237
224
  `,
238
225
  },
239
226
  {
@@ -242,26 +229,6 @@ describe('Schema code generator', () => {
242
229
  returnType: undefined,
243
230
  body: `
244
231
  this.set('count', Value.fromI32(value))
245
- `,
246
- },
247
- {
248
- name: 'get isActive',
249
- params: [],
250
- returnType: new typescript_1.NamedType('boolean'),
251
- body: `let value = this.get('isActive')
252
- if (!value || value.kind == ValueKind.NULL) {
253
- return false
254
- } else {
255
- return value.toBoolean()
256
- }
257
- `,
258
- },
259
- {
260
- name: 'set isActive',
261
- params: [new typescript_1.Param('value', new typescript_1.NamedType('boolean'))],
262
- returnType: undefined,
263
- body: `
264
- this.set('isActive', Value.fromBoolean(value))
265
232
  `,
266
233
  },
267
234
  {
@@ -322,12 +289,9 @@ describe('Schema code generator', () => {
322
289
  name: 'get id',
323
290
  params: [],
324
291
  returnType: new typescript_1.NamedType('string'),
325
- body: `let value = this.get('id')
326
- if (!value || value.kind == ValueKind.NULL) {
327
- throw new Error("Cannot return null for a required field.")
328
- } else {
329
- return value.toString()
330
- }
292
+ body: `
293
+ let value = this.get('id')
294
+ return value!.toString()
331
295
  `,
332
296
  },
333
297
  {
@@ -342,12 +306,9 @@ describe('Schema code generator', () => {
342
306
  name: 'get amount',
343
307
  params: [],
344
308
  returnType: new typescript_1.NamedType('BigInt'),
345
- body: `let value = this.get('amount')
346
- if (!value || value.kind == ValueKind.NULL) {
347
- throw new Error("Cannot return null for a required field.")
348
- } else {
349
- return value.toBigInt()
350
- }
309
+ body: `
310
+ let value = this.get('amount')
311
+ return value!.toBigInt()
351
312
  `,
352
313
  },
353
314
  {
@@ -362,12 +323,9 @@ describe('Schema code generator', () => {
362
323
  name: 'get account',
363
324
  params: [],
364
325
  returnType: new typescript_1.NamedType('string'),
365
- body: `let value = this.get('account')
366
- if (!value || value.kind == ValueKind.NULL) {
367
- throw new Error("Cannot return null for a required field.")
368
- } else {
369
- return value.toString()
370
- }
326
+ body: `
327
+ let value = this.get('account')
328
+ return value!.toString()
371
329
  `,
372
330
  },
373
331
  {
@@ -438,12 +396,10 @@ describe('Schema code generator', () => {
438
396
  name: 'get id',
439
397
  params: [],
440
398
  returnType: new typescript_1.NamedType('Bytes'),
441
- body: `let value = this.get("id")
442
- if (!value || value.kind == ValueKind.NULL) {
443
- throw new Error("Cannot return null for a required field.")
444
- } else {
445
- return value.toBytes()
446
- }`,
399
+ body: '\n' +
400
+ " let value = this.get('id')\n" +
401
+ ' return value!.toBytes()\n' +
402
+ ' ',
447
403
  },
448
404
  {
449
405
  name: 'set id',
@@ -455,12 +411,10 @@ describe('Schema code generator', () => {
455
411
  name: 'get employee',
456
412
  params: [],
457
413
  returnType: new typescript_1.NamedType('Bytes'),
458
- body: `let value = this.get('employee')
459
- if (!value || value.kind == ValueKind.NULL) {
460
- throw new Error("Cannot return null for a required field.")
461
- } else {
462
- return value.toBytes()
463
- }`,
414
+ body: '\n' +
415
+ " let value = this.get('employee')\n" +
416
+ ' return value!.toBytes()\n' +
417
+ ' ',
464
418
  },
465
419
  {
466
420
  name: 'set employee',
@@ -472,12 +426,10 @@ describe('Schema code generator', () => {
472
426
  name: 'get worker',
473
427
  params: [],
474
428
  returnType: new typescript_1.NamedType('Bytes'),
475
- body: `let value = this.get('worker')
476
- if (!value || value.kind == ValueKind.NULL) {
477
- throw new Error("Cannot return null for a required field.")
478
- } else {
479
- return value.toBytes()
480
- }`,
429
+ body: '\n' +
430
+ " let value = this.get('worker')\n" +
431
+ ' return value!.toBytes()\n' +
432
+ ' ',
481
433
  },
482
434
  {
483
435
  name: 'set worker',
@@ -0,0 +1,11 @@
1
+ import immutable from 'immutable';
2
+ import Protocol from '../protocols';
3
+ import * as tsCodegen from './typescript';
4
+ export default class DataSourceTemplateCodeGenerator {
5
+ template: immutable.Map<any, any>;
6
+ protocolTemplateCodeGen: any;
7
+ constructor(template: immutable.Map<any, any>, protocol: Protocol);
8
+ generateModuleImports(): tsCodegen.ModuleImports[];
9
+ generateTypes(): immutable.List<tsCodegen.Class>;
10
+ _generateTemplateType(): tsCodegen.Class;
11
+ }
@@ -0,0 +1,6 @@
1
+ import immutable from 'immutable';
2
+ /**
3
+ * Type conversions
4
+ */
5
+ declare const _default: immutable.Collection<unknown, unknown>;
6
+ export default _default;
@@ -0,0 +1,9 @@
1
+ export declare const ascTypeForProtocol: (protocol: string, protocolType: string) => string;
2
+ export declare const ascTypeForEthereum: (ethereumType: string) => string;
3
+ export declare const ethereumTypeForAsc: (ascType: string) => string | RegExp;
4
+ export declare const ethereumToAsc: (code: string, ethereumType: string, internalType?: string) => any;
5
+ export declare const ethereumFromAsc: (code: string, ethereumType: string) => any;
6
+ export declare const ascTypeForValue: (valueType: string) => unknown;
7
+ export declare const valueTypeForAsc: (ascType: string) => unknown;
8
+ export declare const valueToAsc: (code: string, valueType: string) => any;
9
+ export declare const valueFromAsc: (code: string, valueType: string) => any;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,78 @@
1
+ declare class Param {
2
+ name: string;
3
+ type: string | NamedType | ArrayType | NullableType;
4
+ constructor(name: string, type: string | NamedType | ArrayType | NullableType);
5
+ toString(): string;
6
+ }
7
+ declare class Method {
8
+ name: string;
9
+ params: Param[];
10
+ returnType: string | NamedType | ArrayType | NullableType | null | undefined;
11
+ body: string;
12
+ constructor(name: string, params: Param[], returnType: string | NamedType | ArrayType | NullableType | null | undefined, body: string);
13
+ toString(): string;
14
+ }
15
+ declare class StaticMethod {
16
+ name: string;
17
+ params: Param[];
18
+ returnType: NamedType | NullableType;
19
+ body: string;
20
+ constructor(name: string, params: Param[], returnType: NamedType | NullableType, body: string);
21
+ toString(): string;
22
+ }
23
+ interface ClassOptions {
24
+ extends?: string;
25
+ export?: boolean;
26
+ }
27
+ declare class Class {
28
+ name: string;
29
+ extends: string | undefined;
30
+ methods: string[];
31
+ members: any[];
32
+ export: boolean;
33
+ constructor(name: string, options: ClassOptions);
34
+ addMember(member: any): void;
35
+ addMethod(method: any): void;
36
+ toString(): string;
37
+ }
38
+ declare class ClassMember {
39
+ name: string;
40
+ type: string;
41
+ constructor(name: string, type: string);
42
+ toString(): string;
43
+ }
44
+ declare class NamedType {
45
+ name: string;
46
+ constructor(name: string);
47
+ toString(): string;
48
+ capitalize(): this;
49
+ isPrimitive(): boolean;
50
+ }
51
+ declare class ArrayType {
52
+ inner: NamedType;
53
+ name: string;
54
+ constructor(inner: NamedType);
55
+ toString(): string;
56
+ }
57
+ declare class NullableType {
58
+ inner: NamedType | ArrayType;
59
+ constructor(inner: NamedType | ArrayType);
60
+ toString(): string;
61
+ }
62
+ declare class ModuleImports {
63
+ nameOrNames: string | string[];
64
+ module: string;
65
+ constructor(nameOrNames: string | string[], module: string);
66
+ toString(): string;
67
+ }
68
+ declare const namedType: (name: string) => NamedType;
69
+ declare const arrayType: (name: NamedType) => ArrayType;
70
+ declare const param: (name: string, type: string | NamedType | ArrayType | NullableType) => Param;
71
+ declare const method: (name: string, params: Param[], returnType: string | NamedType | ArrayType | NullableType | null | undefined, body: string) => Method;
72
+ declare const staticMethod: (name: string, params: Param[], returnType: NamedType | NullableType, body: string) => StaticMethod;
73
+ declare const klass: (name: string, options: ClassOptions) => Class;
74
+ declare const klassMember: (name: string, type: string) => ClassMember;
75
+ declare const nullableType: (type: NamedType | ArrayType) => NullableType;
76
+ declare const moduleImports: (nameOrNames: string | string[], module: string) => ModuleImports;
77
+ declare const GENERATED_FILE_NOTE = "\n// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.\n";
78
+ export { ArrayType, arrayType, Class, ClassMember, GENERATED_FILE_NOTE, klass, klassMember, Method, method, ModuleImports, moduleImports, NamedType, namedType, NullableType, nullableType, Param, param, StaticMethod, staticMethod, };
@@ -100,36 +100,6 @@ class NamedType {
100
100
  this.name = this.name.charAt(0).toUpperCase() + this.name.slice(1);
101
101
  return this;
102
102
  }
103
- /**
104
- * Returns the default value for the type, or null if the type is not a primitive
105
- *
106
- * Learn more: https://www.assemblyscript.org/types.html
107
- */
108
- getPrimitiveDefault() {
109
- const isPrimitive = this.isPrimitive();
110
- if (isPrimitive) {
111
- switch (this.name) {
112
- case 'boolean':
113
- return false;
114
- case 'u8':
115
- case 'i8':
116
- case 'u16':
117
- case 'i16':
118
- case 'u32':
119
- case 'i32':
120
- case 'u64':
121
- case 'i64':
122
- case 'f32':
123
- case 'f64':
124
- case 'usize':
125
- case 'isize':
126
- return 0;
127
- default:
128
- throw new Error(`Unknown primitive type: ${this.name}`);
129
- }
130
- }
131
- return null;
132
- }
133
103
  isPrimitive() {
134
104
  const primitives = [
135
105
  'boolean',
@@ -0,0 +1,14 @@
1
+ export declare function disambiguateNames<T>({ values, getName, setName, }: {
2
+ values: T[];
3
+ getName: (value: T, index: number) => string;
4
+ setName: (value: T, name: string) => void;
5
+ }): void[];
6
+ export declare function isTupleType(t: string): boolean;
7
+ export declare function containsTupleType(t: string): true | RegExpMatchArray | null;
8
+ export declare function isTupleArrayType(t: string): RegExpMatchArray | null;
9
+ export declare function isTupleMatrixType(t: string): RegExpMatchArray | null;
10
+ export declare const unrollTuple: ({ path, value, }: {
11
+ path: string[];
12
+ index: number;
13
+ value: any;
14
+ }) => any;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import ABI from '../protocols/ethereum/abi';
2
+ export declare const loadAbiFromEtherscan: (ABICtor: typeof ABI, network: string, address: string) => Promise<ABI>;
3
+ export declare const loadStartBlockForContract: (network: string, address: string) => Promise<string>;
4
+ export declare const fetchDeployContractTransactionFromEtherscan: (network: string, address: string) => Promise<string>;
5
+ export declare const fetchContractCreationHashWithRetry: (url: string, retryCount: number) => Promise<any>;
6
+ export declare const fetchTransactionByHashFromRPC: (network: string, transactionHash: string) => Promise<any>;
7
+ export declare const getStartBlockForContract: (network: string, address: string) => Promise<number>;
8
+ export declare const loadAbiFromBlockScout: (ABICtor: typeof ABI, network: string, address: string) => Promise<any>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export declare const identifyDeployKey: (node: string, deployKey: string | undefined) => Promise<any>;
2
+ export declare const saveDeployKey: (node: string, deployKey: string) => Promise<void>;
@@ -0,0 +1,13 @@
1
+ import Compiler from '../compiler';
2
+ import Protocol from '../protocols';
3
+ interface CreateCompilerOptions {
4
+ ipfs: any;
5
+ headers?: any;
6
+ outputDir: string;
7
+ outputFormat: string;
8
+ skipMigrations: boolean;
9
+ blockIpfsMethods?: RegExpMatchArray;
10
+ protocol: Protocol;
11
+ }
12
+ export declare function createCompiler(manifest: string, { ipfs, headers, outputDir, outputFormat, skipMigrations, blockIpfsMethods, protocol, }: CreateCompilerOptions): Compiler | null;
13
+ export {};
@@ -0,0 +1,4 @@
1
+ import immutable from 'immutable';
2
+ import Protocol from '../protocols';
3
+ export declare const fromFilePath: (manifestPath: string) => Promise<any>;
4
+ export declare const fromManifest: (manifest: immutable.Map<any, any>, protocol: Protocol) => any;
@@ -0,0 +1,2 @@
1
+ declare const displayPath: (p: string) => string;
2
+ export { displayPath };
@@ -0,0 +1,2 @@
1
+ declare const DEFAULT_IPFS_URL: "https://api.thegraph.com/ipfs/api/v0";
2
+ export { DEFAULT_IPFS_URL };
@@ -0,0 +1,2 @@
1
+ import jayson from 'jayson';
2
+ export declare function createJsonRpcClient(url: URL): jayson.Client | null;
@@ -0,0 +1,3 @@
1
+ export declare const updateSubgraphNetwork: (manifest: any, network: string, networksFile: string, identifierName: string) => Promise<any>;
2
+ export declare const initNetworksConfig: (directory: string, identifierName: string) => Promise<any>;
3
+ export declare function updateNetworksFile(network: string, dataSource: any, address: string, networksFile: string): Promise<void>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ /// <reference types="node" />
2
+ import { URL } from 'url';
3
+ export declare const validateNodeUrl: (node: string) => URL;
4
+ export declare const normalizeNodeUrl: (node: string) => string;
5
+ export declare function chooseNodeUrl({ product, studio, node, allowSimpleName, }: {
6
+ product: string | undefined;
7
+ studio: boolean | undefined;
8
+ node?: string;
9
+ allowSimpleName?: boolean;
10
+ }): {
11
+ node: string | undefined;
12
+ allowSimpleName: boolean | undefined;
13
+ };
@@ -0,0 +1,35 @@
1
+ import { Map } from 'immutable';
2
+ import Protocol from '../protocols';
3
+ import ABI from '../protocols/ethereum/abi';
4
+ import { Spinner } from './spinner';
5
+ export declare const generateDataSource: (protocol: Protocol, contractName: string, network: string, contractAddress: string, abi: ABI, startBlock?: string) => Promise<Map<unknown, unknown>>;
6
+ export declare const generateScaffold: ({ protocolInstance, abi, contract, network, subgraphName, indexEvents, contractName, startBlock, node, }: {
7
+ protocolInstance: Protocol;
8
+ abi: ABI;
9
+ contract: string;
10
+ network: string;
11
+ subgraphName: string;
12
+ indexEvents: boolean;
13
+ contractName?: string | undefined;
14
+ startBlock?: string | undefined;
15
+ node?: string | undefined;
16
+ }, spinner: Spinner) => Promise<{
17
+ 'package.json': string;
18
+ 'subgraph.yaml': string;
19
+ 'schema.graphql': string;
20
+ 'tsconfig.json': string;
21
+ src: {
22
+ [x: string]: string;
23
+ } | undefined;
24
+ abis: {
25
+ [x: string]: string;
26
+ } | undefined;
27
+ tests: {
28
+ [x: string]: string;
29
+ } | undefined;
30
+ }>;
31
+ export declare const writeScaffold: (scaffold: any, directory: string, spinner: Spinner) => Promise<void>;
32
+ export declare const writeABI: (abi: ABI, contractName: string) => Promise<void>;
33
+ export declare const writeSchema: (abi: ABI, protocol: Protocol, schemaPath: string, entities: any, contractName: string) => Promise<void>;
34
+ export declare const writeMapping: (abi: ABI, protocol: Protocol, contractName: string, entities: any) => Promise<void>;
35
+ export declare const writeTestsFiles: (abi: ABI, protocol: Protocol, contractName: string) => Promise<void>;
@@ -0,0 +1,4 @@
1
+ import { GluegunPrint } from 'gluegun';
2
+ export type Spinner = ReturnType<GluegunPrint['spin']>;
3
+ export declare const step: (spinner: Spinner, subject: string, text?: string) => Spinner;
4
+ export declare const withSpinner: (text: string, errorText: string, warningText: string, f: (spinner: Spinner) => Promise<any> | any) => Promise<any>;
@@ -0,0 +1,6 @@
1
+ export declare const allowedStudioNetworks: readonly ["mainnet", "rinkeby", "goerli", "gnosis", "chapel", "optimism-goerli", "clover", "fantom-testnet", "arbitrum-goerli", "fuji", "celo-alfajores", "mumbai", "aurora-testnet", "near-testnet", "theta-testnet-001", "osmo-test-4", "base-testnet", "celo", "arbitrum-one", "avalanche", "zksync-era", "sepolia", "polygon-zkevm-testnet", "polygon-zkevm"];
2
+ export declare const validateStudioNetwork: ({ studio, product, network, }: {
3
+ studio?: string | boolean | undefined;
4
+ product?: string | undefined;
5
+ network?: string | undefined;
6
+ }) => void;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export declare const validateSubgraphName: (name: string, { allowSimpleName }: {
2
+ allowSimpleName?: boolean | undefined;
3
+ }) => string | undefined;
4
+ export declare const getSubgraphBasename: (name: string) => string;
@@ -0,0 +1,2 @@
1
+ export declare const assertManifestApiVersion: (manifestPath: string, minimumApiVersion: string) => Promise<void>;
2
+ export declare const assertGraphTsVersion: (sourceDir: string, minimumGraphTsVersion: string) => Promise<void>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class AddCommand extends Command {
3
+ static description: string;
4
+ static args: {
5
+ address: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
6
+ 'subgraph-manifest': import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
7
+ };
8
+ static flags: {
9
+ help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
10
+ abi: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
11
+ 'start-block': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
12
+ 'contract-name': import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
13
+ 'merge-entities': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
14
+ 'network-file': import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
15
+ };
16
+ run(): Promise<void>;
17
+ }
@@ -0,0 +1,14 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class AuthCommand extends Command {
3
+ static description: string;
4
+ static args: {
5
+ node: import("@oclif/core/lib/interfaces/parser").Arg<string | undefined, Record<string, unknown>>;
6
+ 'deploy-key': import("@oclif/core/lib/interfaces/parser").Arg<string | undefined, Record<string, unknown>>;
7
+ };
8
+ static flags: {
9
+ help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
10
+ product: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
11
+ studio: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
12
+ };
13
+ run(): Promise<void>;
14
+ }