Skip to content

Commit

Permalink
Upgrade subgraph dependencies
Browse files Browse the repository at this point in the history
Do some initialization required by new version of subgraph packages
  • Loading branch information
aminlatifi committed Jan 10, 2023
1 parent 0dd0260 commit 627984e
Show file tree
Hide file tree
Showing 7 changed files with 739 additions and 127 deletions.
6 changes: 3 additions & 3 deletions networks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ model:
startBlock: 9999999999999

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

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

GIVPower:
address: '0xDAEa66Adc97833781139373DF5B3bcEd3fdda5b1'
Expand Down Expand Up @@ -294,7 +294,7 @@ production-mainnet:
startBlock: 13862852

production-xdai:
network: xdai
network: gnosis

GIVPower:
address: '0xD93d3bDBa18ebcB3317a57119ea44ed2Cf41C2F2'
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 627984e

Please sign in to comment.