Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New fixes #166

Merged
merged 24 commits into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
2 changes: 2 additions & 0 deletions Implementations/Subgraph/daostar/build/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ type RegistrationInstance @entity {
proposalsURI: String
governanceURI: String
activityLogURI: String
managerAddress: String
contractsRegistryURI: String
}

type RegistrationNetwork @entity {
Expand Down
6 changes: 3 additions & 3 deletions Implementations/Subgraph/daostar/build/subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ features:
templates:
- name: EIP4824Registration
kind: ethereum/contract
network: optimism
network: chapel
source:
abi: EIP4824Registration
mapping:
Expand All @@ -25,11 +25,11 @@ templates:
dataSources:
- kind: ethereum
name: EIP4824Index
network: optimism
network: chapel
source:
abi: EIP4824Index
address: "0x18CbB356cd64193b1a0CA49911fc72CB3D02a5E4"
startBlock: 109109991
startBlock: 32947350
mapping:
kind: ethereum/events
apiVersion: 0.0.6
Expand Down
132 changes: 104 additions & 28 deletions Implementations/Subgraph/daostar/generated/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ export class RegistrationInstance extends Entity {
constructor(id: string) {
super();
this.set("id", Value.fromString(id));

this.set("registrationAddress", Value.fromBytes(Bytes.empty()));
this.set("daoAddress", Value.fromBytes(Bytes.empty()));
this.set("daoURI", Value.fromString(""));
this.set("registrationNetwork", Value.fromString(""));
}

save(): void {
Expand All @@ -34,6 +29,12 @@ export class RegistrationInstance extends Entity {
}
}

static loadInBlock(id: string): RegistrationInstance | null {
return changetype<RegistrationInstance | null>(
store.get_in_block("RegistrationInstance", id)
);
}

static load(id: string): RegistrationInstance | null {
return changetype<RegistrationInstance | null>(
store.get("RegistrationInstance", id)
Expand All @@ -42,7 +43,11 @@ export class RegistrationInstance extends Entity {

get id(): string {
let value = this.get("id");
return value!.toString();
if (!value || value.kind == ValueKind.NULL) {
throw new Error("Cannot return null for a required field.");
} else {
return value.toString();
}
}

set id(value: string) {
Expand All @@ -51,7 +56,11 @@ export class RegistrationInstance extends Entity {

get registrationAddress(): Bytes {
let value = this.get("registrationAddress");
return value!.toBytes();
if (!value || value.kind == ValueKind.NULL) {
throw new Error("Cannot return null for a required field.");
} else {
return value.toBytes();
}
}

set registrationAddress(value: Bytes) {
Expand All @@ -60,7 +69,11 @@ export class RegistrationInstance extends Entity {

get daoAddress(): Bytes {
let value = this.get("daoAddress");
return value!.toBytes();
if (!value || value.kind == ValueKind.NULL) {
throw new Error("Cannot return null for a required field.");
} else {
return value.toBytes();
}
}

set daoAddress(value: Bytes) {
Expand All @@ -69,7 +82,11 @@ export class RegistrationInstance extends Entity {

get daoURI(): string {
let value = this.get("daoURI");
return value!.toString();
if (!value || value.kind == ValueKind.NULL) {
throw new Error("Cannot return null for a required field.");
} else {
return value.toString();
}
}

set daoURI(value: string) {
Expand All @@ -95,7 +112,11 @@ export class RegistrationInstance extends Entity {

get registrationNetwork(): string {
let value = this.get("registrationNetwork");
return value!.toString();
if (!value || value.kind == ValueKind.NULL) {
throw new Error("Cannot return null for a required field.");
} else {
return value.toString();
}
}

set registrationNetwork(value: string) {
Expand Down Expand Up @@ -203,14 +224,46 @@ export class RegistrationInstance extends Entity {
this.set("activityLogURI", Value.fromString(<string>value));
}
}

get managerAddress(): string | null {
let value = this.get("managerAddress");
if (!value || value.kind == ValueKind.NULL) {
return null;
} else {
return value.toString();
}
}

set managerAddress(value: string | null) {
if (!value) {
this.unset("managerAddress");
} else {
this.set("managerAddress", Value.fromString(<string>value));
}
}

get contractsRegistryURI(): string | null {
let value = this.get("contractsRegistryURI");
if (!value || value.kind == ValueKind.NULL) {
return null;
} else {
return value.toString();
}
}

set contractsRegistryURI(value: string | null) {
if (!value) {
this.unset("contractsRegistryURI");
} else {
this.set("contractsRegistryURI", Value.fromString(<string>value));
}
}
}

export class RegistrationNetwork extends Entity {
constructor(id: string) {
super();
this.set("id", Value.fromString(id));

this.set("chainId", Value.fromString(""));
}

save(): void {
Expand All @@ -225,6 +278,12 @@ export class RegistrationNetwork extends Entity {
}
}

static loadInBlock(id: string): RegistrationNetwork | null {
return changetype<RegistrationNetwork | null>(
store.get_in_block("RegistrationNetwork", id)
);
}

static load(id: string): RegistrationNetwork | null {
return changetype<RegistrationNetwork | null>(
store.get("RegistrationNetwork", id)
Expand All @@ -233,36 +292,53 @@ export class RegistrationNetwork extends Entity {

get id(): string {
let value = this.get("id");
return value!.toString();
if (!value || value.kind == ValueKind.NULL) {
throw new Error("Cannot return null for a required field.");
} else {
return value.toString();
}
}

set id(value: string) {
this.set("id", Value.fromString(value));
}

get registrations(): Array<string> | null {
let value = this.get("registrations");
get registrations(): RegistrationInstanceLoader {
return new RegistrationInstanceLoader(
"RegistrationNetwork",
this.get("id")!.toString(),
"registrations"
);
}

get chainId(): string {
let value = this.get("chainId");
if (!value || value.kind == ValueKind.NULL) {
return null;
throw new Error("Cannot return null for a required field.");
} else {
return value.toStringArray();
return value.toString();
}
}

set registrations(value: Array<string> | null) {
if (!value) {
this.unset("registrations");
} else {
this.set("registrations", Value.fromStringArray(<Array<string>>value));
}
set chainId(value: string) {
this.set("chainId", Value.fromString(value));
}
}

get chainId(): string {
let value = this.get("chainId");
return value!.toString();
export class RegistrationInstanceLoader extends Entity {
_entity: string;
_field: string;
_id: string;

constructor(entity: string, id: string, field: string) {
super();
this._entity = entity;
this._id = id;
this._field = field;
}

set chainId(value: string) {
this.set("chainId", Value.fromString(value));
load(): RegistrationInstance[] {
let value = store.loadRelated(this._entity, this._id, this._field);
return changetype<RegistrationInstance[]>(value);
}
}
Loading