From e8e518d9917892a3bef4088a213ec9e9cc9f9161 Mon Sep 17 00:00:00 2001 From: Mario Micklisch Date: Thu, 12 Sep 2024 09:04:50 +0200 Subject: [PATCH] Add support for sustainability proofs v2 https://github.com/vechain/vebetterdao-contracts/pull/18 --- generated/schema.ts | 237 ++++++++++++++++++++++++++++++-------------- src/RewardsPool.ts | 146 +++++++++++++++++++++------ subgraph.graphql | 87 +++++++++++----- 3 files changed, 342 insertions(+), 128 deletions(-) diff --git a/generated/schema.ts b/generated/schema.ts index d7ec0be..437bc5c 100644 --- a/generated/schema.ts +++ b/generated/schema.ts @@ -7526,6 +7526,32 @@ export class SustainabilityProof extends Entity { } } + get reward(): BigInt { + let value = this.get("reward"); + if (!value || value.kind == ValueKind.NULL) { + throw new Error("Cannot return null for a required field."); + } else { + return value.toBigInt(); + } + } + + set reward(value: BigInt) { + this.set("reward", Value.fromBigInt(value)); + } + + get transaction(): string { + let value = this.get("transaction"); + if (!value || value.kind == ValueKind.NULL) { + throw new Error("Cannot return null for a required field."); + } else { + return value.toString(); + } + } + + set transaction(value: string) { + this.set("transaction", Value.fromString(value)); + } + get carbon(): BigInt { let value = this.get("carbon"); if (!value || value.kind == ValueKind.NULL) { @@ -7578,8 +7604,8 @@ export class SustainabilityProof extends Entity { this.set("wasteMass", Value.fromBigInt(value)); } - get wasteItems(): BigInt { - let value = this.get("wasteItems"); + get plastic(): BigInt { + let value = this.get("plastic"); if (!value || value.kind == ValueKind.NULL) { throw new Error("Cannot return null for a required field."); } else { @@ -7587,12 +7613,12 @@ export class SustainabilityProof extends Entity { } } - set wasteItems(value: BigInt) { - this.set("wasteItems", Value.fromBigInt(value)); + set plastic(value: BigInt) { + this.set("plastic", Value.fromBigInt(value)); } - get people(): BigInt { - let value = this.get("people"); + get timber(): BigInt { + let value = this.get("timber"); if (!value || value.kind == ValueKind.NULL) { throw new Error("Cannot return null for a required field."); } else { @@ -7600,12 +7626,12 @@ export class SustainabilityProof extends Entity { } } - set people(value: BigInt) { - this.set("people", Value.fromBigInt(value)); + set timber(value: BigInt) { + this.set("timber", Value.fromBigInt(value)); } - get biodiversity(): BigInt { - let value = this.get("biodiversity"); + get educationTime(): BigInt { + let value = this.get("educationTime"); if (!value || value.kind == ValueKind.NULL) { throw new Error("Cannot return null for a required field."); } else { @@ -7613,12 +7639,12 @@ export class SustainabilityProof extends Entity { } } - set biodiversity(value: BigInt) { - this.set("biodiversity", Value.fromBigInt(value)); + set educationTime(value: BigInt) { + this.set("educationTime", Value.fromBigInt(value)); } - get plastic(): BigInt { - let value = this.get("plastic"); + get treesPlanted(): BigInt { + let value = this.get("treesPlanted"); if (!value || value.kind == ValueKind.NULL) { throw new Error("Cannot return null for a required field."); } else { @@ -7626,12 +7652,12 @@ export class SustainabilityProof extends Entity { } } - set plastic(value: BigInt) { - this.set("plastic", Value.fromBigInt(value)); + set treesPlanted(value: BigInt) { + this.set("treesPlanted", Value.fromBigInt(value)); } - get timber(): BigInt { - let value = this.get("timber"); + get wasteItems(): BigInt { + let value = this.get("wasteItems"); if (!value || value.kind == ValueKind.NULL) { throw new Error("Cannot return null for a required field."); } else { @@ -7639,12 +7665,12 @@ export class SustainabilityProof extends Entity { } } - set timber(value: BigInt) { - this.set("timber", Value.fromBigInt(value)); + set wasteItems(value: BigInt) { + this.set("wasteItems", Value.fromBigInt(value)); } - get reward(): BigInt { - let value = this.get("reward"); + get people(): BigInt { + let value = this.get("people"); if (!value || value.kind == ValueKind.NULL) { throw new Error("Cannot return null for a required field."); } else { @@ -7652,21 +7678,34 @@ export class SustainabilityProof extends Entity { } } - set reward(value: BigInt) { - this.set("reward", Value.fromBigInt(value)); + set people(value: BigInt) { + this.set("people", Value.fromBigInt(value)); } - get transaction(): string { - let value = this.get("transaction"); + get biodiversity(): BigInt { + let value = this.get("biodiversity"); if (!value || value.kind == ValueKind.NULL) { throw new Error("Cannot return null for a required field."); } else { - return value.toString(); + return value.toBigInt(); } } - set transaction(value: string) { - this.set("transaction", Value.fromString(value)); + set biodiversity(value: BigInt) { + this.set("biodiversity", Value.fromBigInt(value)); + } + + get version(): i32 { + let value = this.get("version"); + if (!value || value.kind == ValueKind.NULL) { + return 0; + } else { + return value.toI32(); + } + } + + set version(value: i32) { + this.set("version", Value.fromI32(value)); } } @@ -7807,8 +7846,8 @@ export class AccountSustainability extends Entity { this.set("wasteMass", Value.fromBigInt(value)); } - get wasteItems(): BigInt { - let value = this.get("wasteItems"); + get plastic(): BigInt { + let value = this.get("plastic"); if (!value || value.kind == ValueKind.NULL) { throw new Error("Cannot return null for a required field."); } else { @@ -7816,12 +7855,12 @@ export class AccountSustainability extends Entity { } } - set wasteItems(value: BigInt) { - this.set("wasteItems", Value.fromBigInt(value)); + set plastic(value: BigInt) { + this.set("plastic", Value.fromBigInt(value)); } - get people(): BigInt { - let value = this.get("people"); + get timber(): BigInt { + let value = this.get("timber"); if (!value || value.kind == ValueKind.NULL) { throw new Error("Cannot return null for a required field."); } else { @@ -7829,12 +7868,12 @@ export class AccountSustainability extends Entity { } } - set people(value: BigInt) { - this.set("people", Value.fromBigInt(value)); + set timber(value: BigInt) { + this.set("timber", Value.fromBigInt(value)); } - get biodiversity(): BigInt { - let value = this.get("biodiversity"); + get educationTime(): BigInt { + let value = this.get("educationTime"); if (!value || value.kind == ValueKind.NULL) { throw new Error("Cannot return null for a required field."); } else { @@ -7842,12 +7881,12 @@ export class AccountSustainability extends Entity { } } - set biodiversity(value: BigInt) { - this.set("biodiversity", Value.fromBigInt(value)); + set educationTime(value: BigInt) { + this.set("educationTime", Value.fromBigInt(value)); } - get plastic(): BigInt { - let value = this.get("plastic"); + get treesPlanted(): BigInt { + let value = this.get("treesPlanted"); if (!value || value.kind == ValueKind.NULL) { throw new Error("Cannot return null for a required field."); } else { @@ -7855,12 +7894,12 @@ export class AccountSustainability extends Entity { } } - set plastic(value: BigInt) { - this.set("plastic", Value.fromBigInt(value)); + set treesPlanted(value: BigInt) { + this.set("treesPlanted", Value.fromBigInt(value)); } - get timber(): BigInt { - let value = this.get("timber"); + get wasteItems(): BigInt { + let value = this.get("wasteItems"); if (!value || value.kind == ValueKind.NULL) { throw new Error("Cannot return null for a required field."); } else { @@ -7868,8 +7907,34 @@ export class AccountSustainability extends Entity { } } - set timber(value: BigInt) { - this.set("timber", Value.fromBigInt(value)); + set wasteItems(value: BigInt) { + this.set("wasteItems", Value.fromBigInt(value)); + } + + get people(): BigInt { + let value = this.get("people"); + if (!value || value.kind == ValueKind.NULL) { + throw new Error("Cannot return null for a required field."); + } else { + return value.toBigInt(); + } + } + + set people(value: BigInt) { + this.set("people", Value.fromBigInt(value)); + } + + get biodiversity(): BigInt { + let value = this.get("biodiversity"); + if (!value || value.kind == ValueKind.NULL) { + throw new Error("Cannot return null for a required field."); + } else { + return value.toBigInt(); + } + } + + set biodiversity(value: BigInt) { + this.set("biodiversity", Value.fromBigInt(value)); } } @@ -7968,6 +8033,19 @@ export class AppSustainability extends Entity { this.set("reward", Value.fromBigInt(value)); } + get participantsCount(): BigInt { + let value = this.get("participantsCount"); + if (!value || value.kind == ValueKind.NULL) { + throw new Error("Cannot return null for a required field."); + } else { + return value.toBigInt(); + } + } + + set participantsCount(value: BigInt) { + this.set("participantsCount", Value.fromBigInt(value)); + } + get carbon(): BigInt { let value = this.get("carbon"); if (!value || value.kind == ValueKind.NULL) { @@ -8020,8 +8098,8 @@ export class AppSustainability extends Entity { this.set("wasteMass", Value.fromBigInt(value)); } - get wasteItems(): BigInt { - let value = this.get("wasteItems"); + get plastic(): BigInt { + let value = this.get("plastic"); if (!value || value.kind == ValueKind.NULL) { throw new Error("Cannot return null for a required field."); } else { @@ -8029,12 +8107,12 @@ export class AppSustainability extends Entity { } } - set wasteItems(value: BigInt) { - this.set("wasteItems", Value.fromBigInt(value)); + set plastic(value: BigInt) { + this.set("plastic", Value.fromBigInt(value)); } - get people(): BigInt { - let value = this.get("people"); + get timber(): BigInt { + let value = this.get("timber"); if (!value || value.kind == ValueKind.NULL) { throw new Error("Cannot return null for a required field."); } else { @@ -8042,12 +8120,12 @@ export class AppSustainability extends Entity { } } - set people(value: BigInt) { - this.set("people", Value.fromBigInt(value)); + set timber(value: BigInt) { + this.set("timber", Value.fromBigInt(value)); } - get biodiversity(): BigInt { - let value = this.get("biodiversity"); + get educationTime(): BigInt { + let value = this.get("educationTime"); if (!value || value.kind == ValueKind.NULL) { throw new Error("Cannot return null for a required field."); } else { @@ -8055,12 +8133,12 @@ export class AppSustainability extends Entity { } } - set biodiversity(value: BigInt) { - this.set("biodiversity", Value.fromBigInt(value)); + set educationTime(value: BigInt) { + this.set("educationTime", Value.fromBigInt(value)); } - get plastic(): BigInt { - let value = this.get("plastic"); + get treesPlanted(): BigInt { + let value = this.get("treesPlanted"); if (!value || value.kind == ValueKind.NULL) { throw new Error("Cannot return null for a required field."); } else { @@ -8068,12 +8146,12 @@ export class AppSustainability extends Entity { } } - set plastic(value: BigInt) { - this.set("plastic", Value.fromBigInt(value)); + set treesPlanted(value: BigInt) { + this.set("treesPlanted", Value.fromBigInt(value)); } - get timber(): BigInt { - let value = this.get("timber"); + get wasteItems(): BigInt { + let value = this.get("wasteItems"); if (!value || value.kind == ValueKind.NULL) { throw new Error("Cannot return null for a required field."); } else { @@ -8081,12 +8159,12 @@ export class AppSustainability extends Entity { } } - set timber(value: BigInt) { - this.set("timber", Value.fromBigInt(value)); + set wasteItems(value: BigInt) { + this.set("wasteItems", Value.fromBigInt(value)); } - get participantsCount(): BigInt { - let value = this.get("participantsCount"); + get people(): BigInt { + let value = this.get("people"); if (!value || value.kind == ValueKind.NULL) { throw new Error("Cannot return null for a required field."); } else { @@ -8094,8 +8172,21 @@ export class AppSustainability extends Entity { } } - set participantsCount(value: BigInt) { - this.set("participantsCount", Value.fromBigInt(value)); + set people(value: BigInt) { + this.set("people", Value.fromBigInt(value)); + } + + get biodiversity(): BigInt { + let value = this.get("biodiversity"); + if (!value || value.kind == ValueKind.NULL) { + throw new Error("Cannot return null for a required field."); + } else { + return value.toBigInt(); + } + } + + set biodiversity(value: BigInt) { + this.set("biodiversity", Value.fromBigInt(value)); } } diff --git a/src/RewardsPool.ts b/src/RewardsPool.ts index 72c6708..ae63904 100644 --- a/src/RewardsPool.ts +++ b/src/RewardsPool.ts @@ -200,38 +200,106 @@ function generateSustainabilityProofFromJson(id: string, proofObject: TypedMap