@amxx/graphprotocol-utils
Advanced tools
Comparing version
@@ -19,2 +19,6 @@ // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
this.set("id", Value.fromString(id)); | ||
this.set("value", Value.fromBigDecimal(BigDecimal.zero())); | ||
this.set("exact", Value.fromBigInt(BigInt.zero())); | ||
this.set("decimals", Value.fromI32(0)); | ||
} | ||
@@ -24,13 +28,15 @@ | ||
let id = this.get("id"); | ||
assert(id !== null, "Cannot save DecimalValue entity without an ID"); | ||
assert( | ||
id.kind == ValueKind.STRING, | ||
"Cannot save DecimalValue entity with non-string ID. " + | ||
'Considering using .toHex() to convert the "id" to a string.' | ||
); | ||
store.set("DecimalValue", id.toString(), this); | ||
assert(id != null, "Cannot save DecimalValue entity without an ID"); | ||
if (id) { | ||
assert( | ||
id.kind == ValueKind.STRING, | ||
"Cannot save DecimalValue entity with non-string ID. " + | ||
'Considering using .toHex() to convert the "id" to a string.' | ||
); | ||
store.set("DecimalValue", id.toString(), this); | ||
} | ||
} | ||
static load(id: string): DecimalValue | null { | ||
return store.get("DecimalValue", id) as DecimalValue | null; | ||
return changetype<DecimalValue | null>(store.get("DecimalValue", id)); | ||
} | ||
@@ -40,3 +46,3 @@ | ||
let value = this.get("id"); | ||
return value.toString(); | ||
return value!.toString(); | ||
} | ||
@@ -50,3 +56,3 @@ | ||
let value = this.get("value"); | ||
return value.toBigDecimal(); | ||
return value!.toBigDecimal(); | ||
} | ||
@@ -60,3 +66,3 @@ | ||
let value = this.get("exact"); | ||
return value.toBigInt(); | ||
return value!.toBigInt(); | ||
} | ||
@@ -70,3 +76,3 @@ | ||
let value = this.get("decimals"); | ||
return value.toI32(); | ||
return value!.toI32(); | ||
} | ||
@@ -83,2 +89,5 @@ | ||
this.set("id", Value.fromString(id)); | ||
this.set("timestamp", Value.fromBigInt(BigInt.zero())); | ||
this.set("blockNumber", Value.fromBigInt(BigInt.zero())); | ||
} | ||
@@ -88,13 +97,15 @@ | ||
let id = this.get("id"); | ||
assert(id !== null, "Cannot save Transaction entity without an ID"); | ||
assert( | ||
id.kind == ValueKind.STRING, | ||
"Cannot save Transaction entity with non-string ID. " + | ||
'Considering using .toHex() to convert the "id" to a string.' | ||
); | ||
store.set("Transaction", id.toString(), this); | ||
assert(id != null, "Cannot save Transaction entity without an ID"); | ||
if (id) { | ||
assert( | ||
id.kind == ValueKind.STRING, | ||
"Cannot save Transaction entity with non-string ID. " + | ||
'Considering using .toHex() to convert the "id" to a string.' | ||
); | ||
store.set("Transaction", id.toString(), this); | ||
} | ||
} | ||
static load(id: string): Transaction | null { | ||
return store.get("Transaction", id) as Transaction | null; | ||
return changetype<Transaction | null>(store.get("Transaction", id)); | ||
} | ||
@@ -104,3 +115,3 @@ | ||
let value = this.get("id"); | ||
return value.toString(); | ||
return value!.toString(); | ||
} | ||
@@ -114,3 +125,3 @@ | ||
let value = this.get("timestamp"); | ||
return value.toBigInt(); | ||
return value!.toBigInt(); | ||
} | ||
@@ -124,3 +135,3 @@ | ||
let value = this.get("blockNumber"); | ||
return value.toBigInt(); | ||
return value!.toBigInt(); | ||
} | ||
@@ -134,3 +145,3 @@ | ||
let value = this.get("events"); | ||
return value.toStringArray(); | ||
return value!.toStringArray(); | ||
} | ||
@@ -147,2 +158,4 @@ | ||
this.set("id", Value.fromString(id)); | ||
this.set("value", Value.fromString("")); | ||
} | ||
@@ -152,13 +165,17 @@ | ||
let id = this.get("id"); | ||
assert(id !== null, "Cannot save PersistentString entity without an ID"); | ||
assert( | ||
id.kind == ValueKind.STRING, | ||
"Cannot save PersistentString entity with non-string ID. " + | ||
'Considering using .toHex() to convert the "id" to a string.' | ||
); | ||
store.set("PersistentString", id.toString(), this); | ||
assert(id != null, "Cannot save PersistentString entity without an ID"); | ||
if (id) { | ||
assert( | ||
id.kind == ValueKind.STRING, | ||
"Cannot save PersistentString entity with non-string ID. " + | ||
'Considering using .toHex() to convert the "id" to a string.' | ||
); | ||
store.set("PersistentString", id.toString(), this); | ||
} | ||
} | ||
static load(id: string): PersistentString | null { | ||
return store.get("PersistentString", id) as PersistentString | null; | ||
return changetype<PersistentString | null>( | ||
store.get("PersistentString", id) | ||
); | ||
} | ||
@@ -168,3 +185,3 @@ | ||
let value = this.get("id"); | ||
return value.toString(); | ||
return value!.toString(); | ||
} | ||
@@ -178,3 +195,3 @@ | ||
let value = this.get("value"); | ||
return value.toString(); | ||
return value!.toString(); | ||
} | ||
@@ -191,2 +208,4 @@ | ||
this.set("id", Value.fromString(id)); | ||
this.set("values", Value.fromStringArray(new Array(0))); | ||
} | ||
@@ -197,18 +216,19 @@ | ||
assert( | ||
id !== null, | ||
id != null, | ||
"Cannot save PersistentStringArray entity without an ID" | ||
); | ||
assert( | ||
id.kind == ValueKind.STRING, | ||
"Cannot save PersistentStringArray entity with non-string ID. " + | ||
'Considering using .toHex() to convert the "id" to a string.' | ||
); | ||
store.set("PersistentStringArray", id.toString(), this); | ||
if (id) { | ||
assert( | ||
id.kind == ValueKind.STRING, | ||
"Cannot save PersistentStringArray entity with non-string ID. " + | ||
'Considering using .toHex() to convert the "id" to a string.' | ||
); | ||
store.set("PersistentStringArray", id.toString(), this); | ||
} | ||
} | ||
static load(id: string): PersistentStringArray | null { | ||
return store.get( | ||
"PersistentStringArray", | ||
id | ||
) as PersistentStringArray | null; | ||
return changetype<PersistentStringArray | null>( | ||
store.get("PersistentStringArray", id) | ||
); | ||
} | ||
@@ -218,3 +238,3 @@ | ||
let value = this.get("id"); | ||
return value.toString(); | ||
return value!.toString(); | ||
} | ||
@@ -228,3 +248,3 @@ | ||
let value = this.get("values"); | ||
return value.toStringArray(); | ||
return value!.toStringArray(); | ||
} | ||
@@ -231,0 +251,0 @@ |
{ | ||
"name": "@amxx/graphprotocol-utils", | ||
"version": "1.0.0-alpha.12", | ||
"version": "1.1.0-alpha.0", | ||
"description": "Tooling for graphprotocol subgraph construction", | ||
@@ -27,8 +27,8 @@ "author": "Hadrien Croubois (@Amxx)", | ||
"dependencies": { | ||
"@graphprotocol/graph-ts": "^0.20.0", | ||
"yargs": "^17.0.1" | ||
"@graphprotocol/graph-ts": "^0.22.1", | ||
"yargs": "^17.2.1" | ||
}, | ||
"devDependencies": { | ||
"@graphprotocol/graph-cli": "^0.20.0" | ||
"@graphprotocol/graph-cli": "^0.22.1" | ||
} | ||
} |
@@ -7,4 +7,5 @@ import { BigDecimal, BigInt } from '@graphprotocol/graph-ts' | ||
export let BIGDECIMAL_ZERO = new BigDecimal(constants.BIGINT_ZERO) | ||
export let BIGDECIMAL_ONE = new BigDecimal(constants.BIGINT_ONE) | ||
export const ADDRESS_ZERO = '0x0000000000000000000000000000000000000000' | ||
export const BYTES32_ZERO = '0x0000000000000000000000000000000000000000000000000000000000000000' | ||
} |
@@ -26,3 +26,3 @@ import { | ||
export class Value { | ||
_entry: DecimalValue | ||
_entry!: DecimalValue; | ||
@@ -37,3 +37,3 @@ constructor(id: string, decimal: i32 = decimals.DEFAULT_DECIMALS) { | ||
} else { | ||
this._entry = entry as DecimalValue | ||
this._entry = entry | ||
} | ||
@@ -40,0 +40,0 @@ } |
@@ -33,4 +33,4 @@ import { | ||
this.load() | ||
this._buffer.value = value; | ||
this._buffer.save(); | ||
this._buffer!.value = value; | ||
this._buffer!.save(); | ||
} | ||
@@ -37,0 +37,0 @@ |
@@ -23,3 +23,3 @@ import { | ||
this._buffer = new PersistentStringArray(this._id); | ||
this._buffer.values = []; | ||
this._buffer!.values = []; | ||
return this._buffer; | ||
@@ -30,6 +30,6 @@ } | ||
this.load() | ||
let array = this._buffer.values | ||
let array = this._buffer!.values | ||
array.push(value) | ||
this._buffer.values = array | ||
this._buffer.save() | ||
this._buffer!.values = array | ||
this._buffer!.save() | ||
} | ||
@@ -39,6 +39,6 @@ | ||
this.load() | ||
let array = this._buffer.values | ||
let array = this._buffer!.values | ||
array.unshift(value) | ||
this._buffer.values = array | ||
this._buffer.save() | ||
this._buffer!.values = array | ||
this._buffer!.save() | ||
} | ||
@@ -45,0 +45,0 @@ |
25208
2.61%828
2.1%+ Added
+ Added
+ Added
+ Added
- Removed
Updated