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

Ens changes + module changes #41

Merged
merged 50 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
782d0d3
made owner change track func generic
rahul7668gupta Feb 4, 2023
cb71ad4
some pr comments addressed from PR #34
rahul7668gupta Feb 5, 2023
5ea9486
moved is migrated outside module
rahul7668gupta Feb 5, 2023
581bfe0
created air extra for ttl
rahul7668gupta Feb 5, 2023
892ddbc
minor update
rahul7668gupta Feb 5, 2023
9849f83
update domain moduel
rahul7668gupta Feb 5, 2023
c25ac5f
updated unit tests
rahul7668gupta Feb 5, 2023
bfc4202
removed chainId from track funcs
rahul7668gupta Feb 5, 2023
d9fc108
updated module inputs
rahul7668gupta Feb 5, 2023
e5e98cf
addr to resolved address
rahul7668gupta Feb 5, 2023
dc66d3a
updated chain ids for common
rahul7668gupta Feb 5, 2023
d3953a5
updated module with latest changes
rahul7668gupta Feb 5, 2023
856ce80
minor update to eth registrar
rahul7668gupta Feb 5, 2023
d2fe208
removed resolver addresses from yaml file
rahul7668gupta Feb 5, 2023
19dd944
minor update
rahul7668gupta Feb 5, 2023
ade56f8
null cost in registration event
rahul7668gupta Feb 5, 2023
7016b6b
updated unit test
rahul7668gupta Feb 5, 2023
0c72079
updating owner in domain transfer txn
rahul7668gupta Feb 5, 2023
bec8999
updated tests
rahul7668gupta Feb 5, 2023
a6feb4b
moved label to labelHash
rahul7668gupta Feb 5, 2023
1978e6b
domain name module read me
rahul7668gupta Feb 5, 2023
4bd341c
updated docs for nft marketplace
rahul7668gupta Feb 5, 2023
6482870
minor update
rahul7668gupta Feb 5, 2023
abc5b9c
updated readmes
rahul7668gupta Feb 5, 2023
bce8ff8
minor domain module updates
rahul7668gupta Feb 5, 2023
f978a58
integrated module in ens subgraph
rahul7668gupta Feb 5, 2023
607d2e5
Merge pull request #39 from Airstack-xyz/ens-airstack-module-refactor
0xsarvesh Feb 6, 2023
28d6869
moved air account to common, updated modules
rahul7668gupta Feb 6, 2023
7cbd0fb
updated module with domain name changes
rahul7668gupta Feb 6, 2023
f1d5371
updated readme links to main repo
rahul7668gupta Feb 6, 2023
ffd6108
updated trackNameRenewedOrRegistrationByController func and docs
rahul7668gupta Feb 6, 2023
e30d912
Revert "updated trackNameRenewedOrRegistrationByController func and d…
rahul7668gupta Feb 6, 2023
7d32d42
updating domain expiry in renewal from controller event
rahul7668gupta Feb 6, 2023
bc709c0
saving air account after get/create
rahul7668gupta Feb 7, 2023
5c90906
updated module
rahul7668gupta Feb 7, 2023
4c61bd1
updated domain module, ens unit tests, deployed
rahul7668gupta Feb 7, 2023
2af335d
nft marketplace module update, air account
rahul7668gupta Feb 8, 2023
4665f3a
pointing urls to main branch
rahul7668gupta Feb 9, 2023
0b4e5da
module/common name, slug version update
rahul7668gupta Feb 9, 2023
77f5209
requested changes addresses, module integrated
rahul7668gupta Feb 9, 2023
c132f14
process -> get in network and chain id, deployed
rahul7668gupta Feb 9, 2023
af7f30b
updated readme comment from #42
rahul7668gupta Feb 9, 2023
cb6f1f8
saving all entities outside
rahul7668gupta Feb 10, 2023
722add5
removed newOwner account duplication
rahul7668gupta Feb 10, 2023
b74fbb2
refactor
rahul7668gupta Feb 10, 2023
998a1d0
saving domain before
rahul7668gupta Feb 10, 2023
5ef437f
removed domainId in airExtras
rahul7668gupta Feb 10, 2023
319c38a
moved air extras to common code
rahul7668gupta Feb 10, 2023
a927c6f
moved air extras and token into module common
rahul7668gupta Feb 10, 2023
ea2fc5b
addresses pr comments
rahul7668gupta Feb 13, 2023
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
Prev Previous commit
Next Next commit
moved air extras and token into module common
  • Loading branch information
rahul7668gupta committed Feb 10, 2023
commit a927c6f7b232676c2f027d82de72b61e68af232a
18 changes: 12 additions & 6 deletions airstack-modules/graphql/airstack-domain-name-schema.graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ type AirEntityCounter @entity {
lastUpdatedAt: AirBlock!
}

type AirExtra @entity {
id: ID! # Concatenation of domainId and name
name: String!
value: String!
}

type AirAccount @entity {
id: ID!
address: String!
Expand All @@ -40,22 +46,22 @@ type AirDomain @entity {
id: ID! # The namehash of the name
name: String # The human readable name, if known. Unknown portions replaced with hash in square brackets (eg, foo.[1234].eth)
labelName: String # The human readable label name (imported from CSV), if known
labelHash: Bytes # keccak256(labelName)
labelHash: String # keccak256(labelName)
tokenId: String # dec(labelHash)
parent: AirDomain # The namehash (id) of the parent name
subdomains: [AirDomain!]! @derivedFrom(field: "parent") # Can count domains from length of array
subdomainCount: BigInt! # The number of subdomains
resolvedAddress: AirAccount # Address logged from current resolver, if any
owner: AirAccount!
resolver: AirResolver
ttl: BigInt
isPrimary: Boolean! # - NA # Is the primary domain for the resolved address
expiryTimestamp: BigInt!
registrationCost: BigInt! # Cost of domain registration in wei
paymentToken: AirToken # Token used to pay for registration
tokenAddress: AirToken! # Domain (eg: ens) token contract address
createdAt: AirBlock!
lastUpdatedBlock: AirBlock #- NA
extras: [AirExtra!]
}

type AirDomainTransferTransaction implements AirDomainEvent @entity {
Expand Down Expand Up @@ -106,14 +112,14 @@ type AirResolver @entity {
id: ID! # Concatenation of resolver address and namehash
domain: AirDomain
address: AirAccount! # Address of resolver contract
resolvedAddress: AirAccount # Current value of addr record (per events)
resolvedAddress: AirAccount # Current value of resolved address record (per events)
}

type AirAddrChanged implements AirDomainEvent @entity {
type AirResolvedAddressChanged implements AirDomainEvent @entity {
id: ID!
resolver: AirResolver!
previousResolvedAddress: AirAccount # previous addr record
newResolvedAddress: AirAccount! # new addr record
previousResolvedAddress: AirAccount # previous resolved address record
newResolvedAddress: AirAccount! # new resolved address record
block: AirBlock!
transactionHash: String!
tokenId: String # dec(labelhash) - NA
Expand Down
46 changes: 43 additions & 3 deletions airstack-modules/modules/airstack/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {
AirEntityCounter,
AirMeta,
AirAccount,
AirExtra,
AirToken,
} from "../../../generated/schema";

export const AIR_META_ID = "AIR_META";
Expand All @@ -18,9 +20,9 @@ export const BIG_INT_ZERO = BigInt.fromI32(0);

export const SUBGRAPH_SCHEMA_VERSION = "1.0.0";

export const SUBGRAPH_NAME = "ens";
export const SUBGRAPH_VERSION = "v1";
export const SUBGRAPH_SLUG = "ens-v1";
export const SUBGRAPH_NAME = "AIRSTACK_SUBGRAPH";
export const SUBGRAPH_VERSION = "AIRSTACK_SUBGRAPH";
export const SUBGRAPH_SLUG = "AIRSTACK_SUBGRAPH";

const AIR_NETWORK_MAP = new TypedMap<string, string>();
AIR_NETWORK_MAP.set("arbitrum-one", "ARBITRUM_ONE");
Expand Down Expand Up @@ -175,3 +177,41 @@ export function getOrCreateAirAccount(chainId: string, address: string, block: A
}
return entity as AirAccount;
}

/**
* @dev this function does not save the returned entity
* @dev this function creates an air extra entity
* @param name air extra name
* @param value air extra value
* @param extraId air extra entity id
* @returns air extra entity
*/
export function createAirExtra(
name: string,
value: string,
id: string,
): AirExtra {
let entity = AirExtra.load(id);
if (entity == null) {
entity = new AirExtra(id);
entity.name = name;
entity.value = value;
}
return entity as AirExtra;
}

/**
* @dev this function does not save the returned entity
* @dev this function gets or creates a new air token entity
* @param chainID chain id
* @param address token address
* @returns AirToken entity
*/
export function getOrCreateAirToken(chainID: string, address: string): AirToken {
let entity = AirToken.load(chainID + "-" + address);
if (entity == null) {
entity = new AirToken(chainID + "-" + address);
entity.address = address;
}
return entity as AirToken;
}
61 changes: 16 additions & 45 deletions airstack-modules/modules/airstack/domain-name/domain-name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import {
PrimaryDomain,
AirExtra,
} from "../../../generated/schema";
import { AIR_EXTRA_TTL, AIR_SET_PRIMARY_DOMAIN_ENTITY_COUNTER_ID, AIR_DOMAIN_OWNER_CHANGED_ENTITY_COUNTER_ID, AIR_ADDR_CHANGED_ENTITY_COUNTER_ID, AIR_NAME_RENEWED_ENTITY_COUNTER_ID, AIR_NAME_REGISTERED_ENTITY_COUNTER_ID, AIR_DOMAIN_NEW_TTL_ENTITY_COUNTER_ID, AIR_DOMAIN_NEW_RESOLVER_ENTITY_COUNTER_ID, AIR_DOMAIN_TRANSFER_ENTITY_COUNTER_ID, ROOT_NODE, ZERO_ADDRESS, ETHEREUM_MAINNET_ID } from "./utils";
import { BIGINT_ONE, BIG_INT_ZERO, EMPTY_STRING, getChainId, updateAirEntityCounter, getOrCreateAirBlock, getOrCreateAirAccount } from "../common";
import { AIR_EXTRA_TTL, AIR_SET_PRIMARY_DOMAIN_ENTITY_COUNTER_ID, AIR_DOMAIN_OWNER_CHANGED_ENTITY_COUNTER_ID, AIR_ADDR_CHANGED_ENTITY_COUNTER_ID, AIR_NAME_RENEWED_ENTITY_COUNTER_ID, AIR_NAME_REGISTERED_ENTITY_COUNTER_ID, AIR_DOMAIN_NEW_TTL_ENTITY_COUNTER_ID, AIR_DOMAIN_NEW_RESOLVER_ENTITY_COUNTER_ID, AIR_DOMAIN_TRANSFER_ENTITY_COUNTER_ID, ZERO_ADDRESS, ETHEREUM_MAINNET_ID } from "./utils";
import { BIGINT_ONE, BIG_INT_ZERO, EMPTY_STRING, getChainId, updateAirEntityCounter, getOrCreateAirBlock, getOrCreateAirAccount, createAirExtra, getOrCreateAirToken } from "../common";

export namespace domain {
/**
Expand Down Expand Up @@ -81,9 +81,9 @@ export namespace domain {
domain.labelHash = labelHash;
domain.tokenId = tokenId;
domain.lastUpdatedBlock = airBlock.id;
recurseSubdomainCountDecrement(domain, chainId, airBlock, tokenAddress);
parentDomain.save();
domain.save();
recurseSubdomainCountDecrement(domain, chainId, airBlock, tokenAddress);

let txn = getOrCreateAirDomainOwnerChangedTransaction(
airBlock,
Expand Down Expand Up @@ -182,8 +182,8 @@ export namespace domain {
}
// do recursive subdomain count decrement
domain.lastUpdatedBlock = airBlock.id;
recurseSubdomainCountDecrement(domain, chainId, airBlock, tokenAddress);
domain.save();
recurseSubdomainCountDecrement(domain, chainId, airBlock, tokenAddress);

// create new resolver transaction
let tnx = getOrCreateAirDomainNewResolverTransaction(
Expand Down Expand Up @@ -223,16 +223,26 @@ export namespace domain {
// get previous ttl
let oldTTL: BigInt | null = null;
// load extra entity for ttl
let extra = AirExtra.load(domainId.concat("-").concat(AIR_EXTRA_TTL));
let extraId = domainId.concat("-").concat(AIR_EXTRA_TTL);
let extra = AirExtra.load(extraId);
if (extra != null) {
// if exists, assign oldTTL and update value with newTTL
oldTTL = BigInt.fromString(extra.value);
extra.value = newTTL.toString();
} else {
// else create new extra entity for ttl
extra = createAirExtra(AIR_EXTRA_TTL, newTTL.toString(), domainId);
extra = createAirExtra(AIR_EXTRA_TTL, newTTL.toString(), extraId);
}
extra.save();
// update domain extras
let extrasArray = new Array<string>();
if (domain.extras == null) {
extrasArray.push(extra.id);
} else {
extrasArray = domain.extras!;
extrasArray.push(extra.id);
}
domain.extras = extrasArray;
domain.lastUpdatedBlock = airBlock.id;
domain.save();
// create AirDomainNewTTLTransaction
Expand Down Expand Up @@ -581,29 +591,6 @@ export namespace domain {
}

// end of track functions and start of get or create and helper functions
/**
* @dev this function does not save the returned entity
* @dev this function creates an air extra entity
* @param name air extra name
* @param value air extra value
* @param domainId air domain id
* @returns air extra entity
*/
function createAirExtra(
name: string,
value: string,
domainId: string,
): AirExtra {
let id = domainId.concat("-").concat(name);
let entity = AirExtra.load(id);
if (entity == null) {
entity = new AirExtra(id);
entity.name = name;
entity.value = value;
entity.domain = domainId;
}
return entity as AirExtra;
}

/**
* @dev this function does not save the returned entity
Expand Down Expand Up @@ -1070,22 +1057,6 @@ export namespace domain {
return domain.id
}

/**
* @dev this function does not save the returned entity
* @dev this function gets or creates a new air token entity
* @param chainID chain id
* @param address token address
* @returns AirToken entity
*/
function getOrCreateAirToken(chainID: string, address: string): AirToken {
let entity = AirToken.load(chainID + "-" + address);
if (entity == null) {
entity = new AirToken(chainID + "-" + address);
entity.address = address;
}
return entity as AirToken;
}

/**
* @dev this class has all fields required to create a domain entity
* @param id domain id
Expand Down
17 changes: 17 additions & 0 deletions ens/modules/airstack/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
AirMeta,
AirAccount,
AirExtra,
AirToken,
} from "../../../generated/schema";

export const AIR_META_ID = "AIR_META";
Expand Down Expand Up @@ -197,4 +198,20 @@ export function createAirExtra(
entity.value = value;
}
return entity as AirExtra;
}

/**
* @dev this function does not save the returned entity
* @dev this function gets or creates a new air token entity
* @param chainID chain id
* @param address token address
* @returns AirToken entity
*/
export function getOrCreateAirToken(chainID: string, address: string): AirToken {
let entity = AirToken.load(chainID + "-" + address);
if (entity == null) {
entity = new AirToken(chainID + "-" + address);
entity.address = address;
}
return entity as AirToken;
}
18 changes: 1 addition & 17 deletions ens/modules/airstack/domain-name/domain-name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
AirExtra,
} from "../../../generated/schema";
import { AIR_EXTRA_TTL, AIR_SET_PRIMARY_DOMAIN_ENTITY_COUNTER_ID, AIR_DOMAIN_OWNER_CHANGED_ENTITY_COUNTER_ID, AIR_ADDR_CHANGED_ENTITY_COUNTER_ID, AIR_NAME_RENEWED_ENTITY_COUNTER_ID, AIR_NAME_REGISTERED_ENTITY_COUNTER_ID, AIR_DOMAIN_NEW_TTL_ENTITY_COUNTER_ID, AIR_DOMAIN_NEW_RESOLVER_ENTITY_COUNTER_ID, AIR_DOMAIN_TRANSFER_ENTITY_COUNTER_ID, ZERO_ADDRESS, ETHEREUM_MAINNET_ID } from "./utils";
import { BIGINT_ONE, BIG_INT_ZERO, EMPTY_STRING, getChainId, updateAirEntityCounter, getOrCreateAirBlock, getOrCreateAirAccount, createAirExtra } from "../common";
import { BIGINT_ONE, BIG_INT_ZERO, EMPTY_STRING, getChainId, updateAirEntityCounter, getOrCreateAirBlock, getOrCreateAirAccount, createAirExtra, getOrCreateAirToken } from "../common";

export namespace domain {
/**
Expand Down Expand Up @@ -1057,22 +1057,6 @@ export namespace domain {
return domain.id
}

/**
* @dev this function does not save the returned entity
* @dev this function gets or creates a new air token entity
* @param chainID chain id
* @param address token address
* @returns AirToken entity
*/
function getOrCreateAirToken(chainID: string, address: string): AirToken {
let entity = AirToken.load(chainID + "-" + address);
if (entity == null) {
entity = new AirToken(chainID + "-" + address);
entity.address = address;
}
return entity as AirToken;
}

/**
* @dev this class has all fields required to create a domain entity
* @param id domain id
Expand Down
4 changes: 2 additions & 2 deletions ens/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.