Skip to content

Commit

Permalink
Merge pull request #39 from Giveth/feat/subgraph_studio_support
Browse files Browse the repository at this point in the history
Make ready for studio migration
  • Loading branch information
aminlatifi authored Jan 12, 2023
2 parents 0dd0260 + 1339f33 commit 319bc14
Show file tree
Hide file tree
Showing 10 changed files with 753 additions and 141 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/graph-develop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
graph_account: giveth
graph_config_file: subgraph.deployment-7-goerli.yaml

deploy-staging-xdai:
deploy-staging-gnosis:
needs: lint
runs-on: ubuntu-latest
steps:
Expand All @@ -56,4 +56,4 @@ jobs:
graph_access_token: ${{ secrets.GRAPH_ACCESS_TOKEN }}
graph_subgraph_name: giveth-economy-xdai-staging
graph_account: giveth
graph_config_file: subgraph.deployment-7-xdai.yaml
graph_config_file: subgraph.deployment-7-gnosis.yaml
4 changes: 2 additions & 2 deletions .github/workflows/graph-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
graph_account: giveth
graph_config_file: subgraph.production-mainnet.yaml

deploy-xdai:
deploy-gnosis:
needs: lint
runs-on: ubuntu-latest
steps:
Expand All @@ -56,4 +56,4 @@ jobs:
graph_access_token: ${{ secrets.GRAPH_ACCESS_TOKEN }}
graph_subgraph_name: giveth-economy-second-xdai
graph_account: giveth
graph_config_file: subgraph.production-xdai.yaml
graph_config_file: subgraph.production-gnosis.yaml
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ yarn deploy:goerli:develop
**For gnosis**

```bash
yarn deploy:xdai:production
yarn deploy:gnosis:production
```
12 changes: 6 additions & 6 deletions networks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ model:
address: '0x0000000000000000000000000000000000000000'
startBlock: 9999999999999

deployment-6-xdai:
network: xdai
deployment-6-gnosis:
network: gnosis
GIVPower:
address: '0x898Baa558A401e59Cb2aA77bb8b2D89978Cf506F'
startBlock: 23829546
Expand Down Expand Up @@ -111,8 +111,8 @@ deployment-6-kovan:
address: '0x02653cae0cad6b3cd73e7dbc4f7a3ce6693c3ed7'
startBlock: 28895593

deployment-7-xdai:
network: xdai
deployment-7-gnosis:
network: gnosis

GIVPower:
address: '0xDAEa66Adc97833781139373DF5B3bcEd3fdda5b1'
Expand Down Expand Up @@ -293,8 +293,8 @@ production-mainnet:
address: '0x3115e5aAa3D6f742d09fbB649150dfE285a9c2A3'
startBlock: 13862852

production-xdai:
network: xdai
production-gnosis:
network: gnosis

GIVPower:
address: '0xD93d3bDBa18ebcB3317a57119ea44ed2Cf41C2F2'
Expand Down
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
"auth": "graph auth https://api.thegraph.com/deploy/",
"lint": "eslint ./src",
"deploy:mateo": "yarn generate-manifests && graph deploy --product hosted-service mateodaza/givpower-subgraph subgraph.deployment-7.yaml",
"deploy:xdai:deployment-6:amin": "yarn generate-manifests && graph deploy --product hosted-service aminlatifi/givpower-deployment-six subgraph.deployment-6-xdai.yaml",
"deploy:gnosis:deployment-6:amin": "yarn generate-manifests && graph deploy --product hosted-service aminlatifi/givpower-deployment-six subgraph.deployment-6-gnosis.yaml",
"deploy:kovan:deployment-6:amin": "yarn generate-manifests && graph deploy --product hosted-service aminlatifi/givpower-deployment-six-kovan subgraph.deployment-6-kovan.yaml",
"deploy:deployment-7": "yarn generate-manifests && graph deploy --product hosted-service mateodaza/givpower-subgraph subgraph.deployment-7.yaml",
"deploy:xdai:deployment-7": "yarn generate-manifests && graph deploy --product hosted-service aminlatifi/giveconomy-xdai-deployment-seven subgraph.deployment-7-xdai.yaml",
"deploy:xdai:develop": "yarn generate-manifests && graph deploy --product hosted-service giveth/giveth-economy-second-xdai-staging subgraph.deployment-7-xdai.yaml",
"deploy:gnosis:deployment-7": "yarn generate-manifests && graph deploy --product hosted-service aminlatifi/giveconomy-xdai-deployment-seven subgraph.deployment-7-gnosis.yaml",
"deploy:gnosis:develop": "yarn generate-manifests && graph deploy --product hosted-service giveth/giveth-economy-second-xdai-staging subgraph.deployment-7-gnosis.yaml",
"deploy:kovan:develop": "yarn generate-manifests && graph deploy --product hosted-service giveth/giveth-economy-second-kovan-staging subgraph.deployment-7-kovan.yaml",
"deploy:kovan:deployment-7:mohammad": "yarn generate-manifests && graph deploy --product hosted-service mohammadranjbarz/giv-economy-kovan subgraph.deployment-7-kovan.yaml",
"deploy:goerli:develop": "yarn generate-manifests && graph deploy --product hosted-service giveth/giveth-economy-goerli-staging subgraph.deployment-7-goerli.yaml",
"deploy:xdai:production": "yarn generate-manifests && graph deploy --product hosted-service giveth/giveth-economy-second-xdai subgraph.production-xdai.yaml",
"deploy:xdai:production-mateo": "yarn generate-manifests && graph deploy --product hosted-service mateodaza/giveth-economy-second-xdai subgraph.production-xdai.yaml",
"deploy:gnosis:production": "yarn generate-manifests && graph deploy --product hosted-service giveth/giveth-economy-second-xdai subgraph.production-gnosis.yaml",
"deploy:gnosis:production-mateo": "yarn generate-manifests && graph deploy --product hosted-service mateodaza/giveth-economy-second-xdai subgraph.production-gnosis.yaml",
"deploy:mainnet:production": "yarn generate-manifests && graph deploy --product hosted-service giveth/giveth-economy-second-mainnet subgraph.production-mainnet.yaml",
"deploy:mainnet:production-mateo": "yarn generate-manifests && graph deploy --product hosted-service mateodaza/giveth-economy-second-mainnet subgraph.production-mainnet.yaml",
"deploy:mainnet": "yarn deploy ORGANISATION/SUBGRAPH",
"codegen:deployment-6": "yarn generate-manifests && graph codegen subgraph.deployment-6.yaml --output-dir src/types/",
"codegen:deployment-7": "yarn generate-manifests && graph codegen subgraph.deployment-7-xdai.yaml --output-dir src/types/",
"codegen:deployment-7": "yarn generate-manifests && graph codegen subgraph.deployment-7-gnosis.yaml --output-dir src/types/",
"build:deployment-6": "yarn generate-manifests && graph build subgraph.deployment-6.yaml",
"build:deployment-7": "yarn generate-manifests && graph build subgraph.deployment-7.yaml",
"build:deployment-mainnet": "yarn generate-manifests && graph build subgraph.production-mainnet.yaml",
Expand All @@ -47,13 +47,13 @@
},
"homepage": "https://github.com/TomAFrench/subgraph-template#readme",
"dependencies": {
"@graphprotocol/graph-ts": "^0.24.1",
"js-yaml": "^4.1.0",
"@graphprotocol/graph-cli": "^0.37.2",
"@graphprotocol/graph-ts": "^0.29.1",
"fs-extra": "^8.1.0",
"handlebars": "^4.7.6",
"fs-extra": "^8.1.0"
"js-yaml": "^4.1.0"
},
"devDependencies": {
"@graphprotocol/graph-cli": "0.26.0",
"@types/fs-extra": "^9.0.2",
"@types/js-yaml": "^4.0.5",
"@types/node": "^14.14.37",
Expand Down
2 changes: 2 additions & 0 deletions src/mappings/gardenUnipool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ function updateSnapshot(
newSnapshot = new UserGivPowerSnapshot(newSnapshotId);
newSnapshot.user = userAddress.toHex();
newSnapshot.timestamp = currentTimestamp;
newSnapshot.givPowerAmount = BigInt.zero();
newSnapshot.cumulativeGivPowerAmount = BigInt.zero();
}
const lastSnapshotTimestamp = user.lastGivPowerUpdateTime;

Expand Down
1 change: 1 addition & 0 deletions src/mappings/givPower.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export function handleTokenLocked(event: TokenLocked): void {
if (tokenLock == null) {
tokenLock = new TokenLock(lockId);
tokenLock.user = userAddress.toHex();
tokenLock.amount = BigInt.zero();
tokenLock.untilRound = untilRound;
tokenLock.rounds = rounds;
tokenLock.unlocked = false;
Expand Down
5 changes: 5 additions & 0 deletions src/utils/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export function getUserEntity(userAddress: Address): User {

if (user == null) {
user = new User(userAddress.toHex());
user.givLocked = BigInt.zero();
user.lastGivPowerUpdateTime = BigInt.zero();
user.save();
}

Expand All @@ -35,6 +37,7 @@ export function getGIVPower(givPowerAddress: Address): GIVPower {
givpower.initialDate = initialDate;
givpower.roundDuration = roundDuration;
givpower.locksCreated = 0;
givpower.totalGIVLocked = BigInt.zero();
givpower.save();
}

Expand Down Expand Up @@ -81,6 +84,7 @@ export function getUserTokenBalance(
tokenBalance = new TokenBalance(id);
tokenBalance.token = tokenAddress.toHex();
tokenBalance.user = userAddress.toHex();
tokenBalance.balance = BigInt.zero();
tokenBalance.save();
}

Expand All @@ -101,6 +105,7 @@ export function getUserUnipoolBalance(
unipoolBalance = new UnipoolBalance(id);
unipoolBalance.unipool = unipoolAddress.toHex();
unipoolBalance.user = userAddress.toHex();
unipoolBalance.balance = BigInt.zero();
unipoolBalance.rewards = BigInt.zero();
unipoolBalance.rewardPerTokenPaid = BigInt.zero();
unipoolBalance.save();
Expand Down
9 changes: 7 additions & 2 deletions src/utils/tokenDistroHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export function saveTokenAllocation(
let transactionTokenAllocations = TransactionTokenAllocation.load(txHash);
if (!transactionTokenAllocations) {
transactionTokenAllocations = new TransactionTokenAllocation(txHash);
transactionTokenAllocations.tokenAllocationIds = [];
}
const tokenAllocationIds =
transactionTokenAllocations.tokenAllocationIds || [];
const tokenAllocationIds = transactionTokenAllocations.tokenAllocationIds;
const entityId = `${txHash}-${logIndex}`;
const entity = new TokenAllocation(entityId);
entity.amount = amount;
Expand All @@ -42,6 +42,11 @@ export function getTokenDistroBalance(
if (!tokenDistroBalance) {
tokenDistroBalance = new TokenDistroBalance(id);
tokenDistroBalance.user = userAddress;
tokenDistroBalance.allocatedTokens = BigInt.zero();
tokenDistroBalance.allocationCount = BigInt.zero();
tokenDistroBalance.claimed = BigInt.zero();
tokenDistroBalance.givback = BigInt.zero();
tokenDistroBalance.givbackLiquidPart = BigInt.zero();
tokenDistroBalance.tokenDistroAddress = tokenDistro;
tokenDistroBalance.save();
}
Expand Down
Loading

0 comments on commit 319bc14

Please sign in to comment.