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

feat: support arbitrum #194

Merged
merged 3 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@
docs/_build

/node_modules
.idea
.idea
*/**/artifacts
*/**/build
Binary file not shown.
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: chapel
network: arbitrum-one
source:
abi: EIP4824Registration
mapping:
Expand All @@ -25,11 +25,11 @@ templates:
dataSources:
- kind: ethereum
name: EIP4824Index
network: chapel
network: arbitrum-one
source:
abi: EIP4824Index
address: "0x18CbB356cd64193b1a0CA49911fc72CB3D02a5E4"
startBlock: 32947350
startBlock: 171329384
mapping:
kind: ethereum/events
apiVersion: 0.0.6
Expand Down
98 changes: 28 additions & 70 deletions Implementations/Subgraph/daostar/generated/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ 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 @@ -29,12 +34,6 @@ 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 @@ -43,11 +42,7 @@ export class RegistrationInstance extends Entity {

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

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

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

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

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

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

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

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

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

set registrationNetwork(value: string) {
Expand Down Expand Up @@ -264,6 +243,8 @@ export class RegistrationNetwork extends Entity {
constructor(id: string) {
super();
this.set("id", Value.fromString(id));

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

save(): void {
Expand All @@ -278,12 +259,6 @@ 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 @@ -292,53 +267,36 @@ export class RegistrationNetwork extends Entity {

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

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

get registrations(): RegistrationInstanceLoader {
return new RegistrationInstanceLoader(
"RegistrationNetwork",
this.get("id")!.toString(),
"registrations"
);
}

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

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

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;
get chainId(): string {
let value = this.get("chainId");
return value!.toString();
}

load(): RegistrationInstance[] {
let value = store.loadRelated(this._entity, this._id, this._field);
return changetype<RegistrationInstance[]>(value);
set chainId(value: string) {
this.set("chainId", Value.fromString(value));
}
}
6 changes: 6 additions & 0 deletions Implementations/Subgraph/daostar/networks.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,11 @@
"address": "0x18CbB356cd64193b1a0CA49911fc72CB3D02a5E4",
"startBlock": 109109991
}
},
"arbitrum-one": {
"EIP4824Index": {
"address": "0x18CbB356cd64193b1a0CA49911fc72CB3D02a5E4",
"startBlock": 171329384
}
}
}
2 changes: 2 additions & 0 deletions Implementations/Subgraph/daostar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"scripts": {
"build:mainnet": "graph codegen && graph build --network mainnet",
"build:optimism": "graph codegen && graph build --network optimism",
"build:arbitrum": "graph codegen && graph build --network arbitrum-one",
"build:goerli": "graph codegen && graph build --network goerli",
"build:gnosis": "graph codegen && graph build --network gnosis",
"build:optimism-goerli": "graph codegen && graph build --network optimism-goerli",
Expand All @@ -13,6 +14,7 @@
"build": "graph build",
"deploy:mainnet": "graph deploy --node https://api.thegraph.com/deploy/ ipatka/daostar",
"deploy:optimism": "graph deploy --node https://api.thegraph.com/deploy/ crazyyuan/daostar-optimism",
"deploy:arbitrum": "graph deploy --node https://api.thegraph.com/deploy/ crazyyuan/daostar-arbitrum",
"deploy:goerli": "graph deploy --node https://api.thegraph.com/deploy/ ipatka/daostar-goerli",
"deploy:optimism-goerli": "graph deploy --node https://api.thegraph.com/deploy/ rashmi-278/daostar-optimism-goerli",
"deploy:gnosis": "graph deploy --node https://api.thegraph.com/deploy/ rashmi-278/daostar-gnosis",
Expand Down
6 changes: 3 additions & 3 deletions Implementations/Subgraph/daostar/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: chapel
network: arbitrum-one
source:
abi: EIP4824Registration
mapping:
Expand All @@ -25,11 +25,11 @@ templates:
dataSources:
- kind: ethereum
name: EIP4824Index
network: chapel
network: arbitrum-one
source:
abi: EIP4824Index
address: "0x18CbB356cd64193b1a0CA49911fc72CB3D02a5E4"
startBlock: 32947350
startBlock: 171329384
mapping:
kind: ethereum/events
apiVersion: 0.0.6
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ These contracts are used to register on DAOstar website.
* **EIP4824RegistrationSummoner**
* Contract: [0x5C0340AD34f7284f9272E784FF76638E8dDb5dE4](https://optimistic.etherscan.io/address/0x5C0340AD34f7284f9272E784FF76638E8dDb5dE4)
* Version: 1.0.0


#### Arbitrum
* **EIP4824Index**:
* Contract: [0x18CbB356cd64193b1a0CA49911fc72CB3D02a5E4](https://arbiscan.io/address/0x18cbb356cd64193b1a0ca49911fc72cb3d02a5e4)
Expand Down
33 changes: 33 additions & 0 deletions contracts/compiler_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"language": "Solidity",
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"": [
"ast"
],
"*": [
"abi",
"metadata",
"devdoc",
"userdoc",
"storageLayout",
"evm.legacyAssembly",
"evm.bytecode",
"evm.deployedBytecode",
"evm.methodIdentifiers",
"evm.gasEstimates",
"evm.assembly"
]
}
},
"remappings": [
"ds-test/=lib/forge-std/lib/ds-test/src/",
"forge-std/=lib/forge-std/src/"
]
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @crazyyuan , Why do we need this file ?
We already have a file registrations.js

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { gql } from '@apollo/client'

const REGISTRATIONS = gql`
query Registrations($id: String) @api(contextKey: "apiName") {
registrationNetwork(id: $id) {
id
registrations {
id
daoAddress
daoURI
daoName
daoDescription
membersURI
proposalsURI
governanceURI
activityLogURI
registrationAddress
registrationNetwork {
id
}
}
}
}
`

const REGISTRATION = gql`
query Registration($id: String) @api(contextKey: "apiName") {
registrationInstance(id: $id) {
id
daoAddress
daoURI
daoName
daoDescription
membersURI
proposalsURI
governanceURI
activityLogURI
registrationAddress
registrationNetwork {
id
}
}
}
`

export default { REGISTRATIONS, REGISTRATION}