@graphprotocol/graph-cli 0.27.0 → 0.27.1
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/tendermint.ts +554 -0
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/common/collections.ts +52 -2
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/common/numbers.ts +11 -0
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/common/value.ts +47 -0
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/global/global.ts +150 -1
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/index.ts +2 -0
- 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 +2 -0
- package/examples/basic-event-handlers/node_modules/keccak/build/Makefile +1 -1
- package/examples/basic-event-handlers/node_modules/keccak/build/Release/.deps/Release/obj.target/keccak/src/addon.o.d.raw +16 -16
- package/examples/basic-event-handlers/node_modules/keccak/build/config.gypi +4 -4
- package/examples/basic-event-handlers/node_modules/keccak/build/keccak.target.mk +14 -14
- package/examples/basic-event-handlers/node_modules/websocket/build/Makefile +1 -1
- package/examples/basic-event-handlers/node_modules/websocket/build/Release/.deps/Release/obj.target/bufferutil/src/bufferutil.o.d.raw +16 -16
- package/examples/basic-event-handlers/node_modules/websocket/build/bufferutil.target.mk +14 -14
- package/examples/basic-event-handlers/node_modules/websocket/build/config.gypi +1 -1
- package/examples/basic-event-handlers/node_modules/websocket/build/validation.target.mk +14 -14
- package/package.json +1 -1
- package/src/codegen/schema.js +5 -46
- package/src/codegen/schema.test.js +0 -6
- package/src/codegen/types/conversions.js +19 -19
- package/src/codegen/types/index.js +0 -25
- package/src/codegen/types/index.test.js +0 -22
|
@@ -188,28 +188,28 @@ const VALUE_TO_ASSEMBLYSCRIPT = [
|
|
|
188
188
|
const ASSEMBLYSCRIPT_TO_VALUE = [
|
|
189
189
|
// Arrays
|
|
190
190
|
|
|
191
|
-
['Array<Address>', '[Bytes]', code => `Value.fromBytesArray(${code})
|
|
192
|
-
['Array<Bytes>', '[Bytes]', code => `Value.fromBytesArray(${code})
|
|
193
|
-
['Array<boolean>', '[Boolean]', code => `Value.fromBooleanArray(${code})
|
|
194
|
-
['Array<i32>', '[Int]', code => `Value.fromI32Array(${code})
|
|
195
|
-
['Array<BigInt>', '[BigInt]', code => `Value.fromBigIntArray(${code})
|
|
196
|
-
['Array<string>', '[String]', code => `Value.fromStringArray(${code})
|
|
197
|
-
['Array<string>', '[ID]', code => `Value.fromStringArray(${code})
|
|
198
|
-
['Array<BigDecimal>', '[BigDecimal]', code => `Value.fromBigDecimalArray(${code})
|
|
199
|
-
['Array<string>', /\[.*\]/, code => `Value.fromStringArray(${code})
|
|
200
|
-
['Array<string | null>', null, code => `Value.fromStringArray(${code})
|
|
191
|
+
['Array<Address>', '[Bytes]', code => `Value.fromBytesArray(${code})`],
|
|
192
|
+
['Array<Bytes>', '[Bytes]', code => `Value.fromBytesArray(${code})`],
|
|
193
|
+
['Array<boolean>', '[Boolean]', code => `Value.fromBooleanArray(${code})`],
|
|
194
|
+
['Array<i32>', '[Int]', code => `Value.fromI32Array(${code})`],
|
|
195
|
+
['Array<BigInt>', '[BigInt]', code => `Value.fromBigIntArray(${code})`],
|
|
196
|
+
['Array<string>', '[String]', code => `Value.fromStringArray(${code})`],
|
|
197
|
+
['Array<string>', '[ID]', code => `Value.fromStringArray(${code})`],
|
|
198
|
+
['Array<BigDecimal>', '[BigDecimal]', code => `Value.fromBigDecimalArray(${code})`],
|
|
199
|
+
['Array<string>', /\[.*\]/, code => `Value.fromStringArray(${code})`],
|
|
200
|
+
['Array<string | null>', null, code => `Value.fromStringArray(${code})`],
|
|
201
201
|
|
|
202
202
|
// Scalar values
|
|
203
203
|
|
|
204
|
-
['Address', 'Bytes', code => `Value.fromBytes(${code})
|
|
205
|
-
['Bytes', 'Bytes', code => `Value.fromBytes(${code})
|
|
206
|
-
['boolean', 'Boolean', code => `Value.fromBoolean(${code})
|
|
207
|
-
['i32', 'Int', code => `Value.fromI32(${code})
|
|
208
|
-
['BigInt', 'BigInt', code => `Value.fromBigInt(${code})
|
|
209
|
-
['string', 'String', code => `Value.fromString(${code})
|
|
210
|
-
['string', 'ID', code => `Value.fromString(${code})
|
|
211
|
-
['BigDecimal', 'BigDecimal', code => `Value.fromBigDecimal(${code})
|
|
212
|
-
['string', /.*/, code => `Value.fromString(${code})
|
|
204
|
+
['Address', 'Bytes', code => `Value.fromBytes(${code})`],
|
|
205
|
+
['Bytes', 'Bytes', code => `Value.fromBytes(${code})`],
|
|
206
|
+
['boolean', 'Boolean', code => `Value.fromBoolean(${code})`],
|
|
207
|
+
['i32', 'Int', code => `Value.fromI32(${code})`],
|
|
208
|
+
['BigInt', 'BigInt', code => `Value.fromBigInt(${code})`],
|
|
209
|
+
['string', 'String', code => `Value.fromString(${code})`],
|
|
210
|
+
['string', 'ID', code => `Value.fromString(${code})`],
|
|
211
|
+
['BigDecimal', 'BigDecimal', code => `Value.fromBigDecimal(${code})`],
|
|
212
|
+
['string', /.*/, code => `Value.fromString(${code})`],
|
|
213
213
|
]
|
|
214
214
|
|
|
215
215
|
/**
|
|
@@ -66,27 +66,6 @@ const findConversionToType = (fromTypeSystem, toTypeSystem, toType) => {
|
|
|
66
66
|
return objectifyConversion(fromTypeSystem, toTypeSystem, conversion)
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
const findInitializationForType = (fromTypeSystem, toTypeSystem, ascType) => {
|
|
70
|
-
const conversions = conversionsForTypeSystems(fromTypeSystem, toTypeSystem)
|
|
71
|
-
|
|
72
|
-
const conversion = conversions.find(conversion =>
|
|
73
|
-
typeof conversion.get(0) === 'string'
|
|
74
|
-
? conversion.get(0) === ascType
|
|
75
|
-
: ascType.match(conversion.get(0)),
|
|
76
|
-
)
|
|
77
|
-
|
|
78
|
-
if (conversion === undefined) {
|
|
79
|
-
throw new Error(
|
|
80
|
-
`Conversion from '${fromTypeSystem}' to '${toTypeSystem}' for ` +
|
|
81
|
-
`target type '${ascType}' is not supported`,
|
|
82
|
-
)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const conversionObj = objectifyConversion(fromTypeSystem, toTypeSystem, conversion)
|
|
86
|
-
|
|
87
|
-
return conversionObj.get('convert')(conversion.get(3))
|
|
88
|
-
}
|
|
89
|
-
|
|
90
69
|
// High-level type system API
|
|
91
70
|
|
|
92
71
|
const ascTypeForProtocol = (protocol, protocolType) =>
|
|
@@ -120,9 +99,6 @@ const valueToAsc = (code, valueType) =>
|
|
|
120
99
|
const valueFromAsc = (code, valueType) =>
|
|
121
100
|
findConversionToType('AssemblyScript', 'Value', valueType).get('convert')(code)
|
|
122
101
|
|
|
123
|
-
const initializedValueFromAsc = ascType =>
|
|
124
|
-
findInitializationForType('AssemblyScript', 'Value', ascType)
|
|
125
|
-
|
|
126
102
|
module.exports = {
|
|
127
103
|
// protocol <-> AssemblyScript
|
|
128
104
|
ascTypeForProtocol,
|
|
@@ -138,5 +114,4 @@ module.exports = {
|
|
|
138
114
|
valueTypeForAsc,
|
|
139
115
|
valueToAsc,
|
|
140
116
|
valueFromAsc,
|
|
141
|
-
initializedValueFromAsc,
|
|
142
117
|
}
|
|
@@ -449,26 +449,4 @@ describe('AssemblyScript -> Value', () => {
|
|
|
449
449
|
expect(codegen.valueFromAsc('x', '[String]')).toBe('Value.fromStringArray(x)')
|
|
450
450
|
expect(codegen.valueTypeForAsc('Array<string>')).toBe('[String]')
|
|
451
451
|
})
|
|
452
|
-
|
|
453
|
-
describe('Initialization for zero/empty values', () => {
|
|
454
|
-
test('Array<string>', () => {
|
|
455
|
-
expect(codegen.initializedValueFromAsc('Array<string>')).toBe('Value.fromStringArray(new Array(0))')
|
|
456
|
-
})
|
|
457
|
-
|
|
458
|
-
test('Array<string | null>', () => {
|
|
459
|
-
expect(codegen.initializedValueFromAsc('Array<string | null>')).toBe('Value.fromStringArray(new Array(0))')
|
|
460
|
-
})
|
|
461
|
-
|
|
462
|
-
test('i32', () => {
|
|
463
|
-
expect(codegen.initializedValueFromAsc('i32')).toBe('Value.fromI32(0)')
|
|
464
|
-
})
|
|
465
|
-
|
|
466
|
-
test('string', () => {
|
|
467
|
-
expect(codegen.initializedValueFromAsc('string')).toBe("Value.fromString('')")
|
|
468
|
-
})
|
|
469
|
-
|
|
470
|
-
test('BigInt', () => {
|
|
471
|
-
expect(codegen.initializedValueFromAsc('BigInt')).toBe('Value.fromBigInt(BigInt.zero())')
|
|
472
|
-
})
|
|
473
|
-
})
|
|
474
452
|
})
|