@gooddollar/goodprotocol 1.0.7-beta.1 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/artifacts/contracts/DAOStackInterfaces.sol/Avatar.dbg.json +1 -1
  2. package/artifacts/contracts/DAOStackInterfaces.sol/Controller.dbg.json +1 -1
  3. package/artifacts/contracts/DAOStackInterfaces.sol/GlobalConstraintInterface.dbg.json +1 -1
  4. package/artifacts/contracts/DAOStackInterfaces.sol/IntVoteInterface.dbg.json +1 -1
  5. package/artifacts/contracts/DAOStackInterfaces.sol/ReputationInterface.dbg.json +1 -1
  6. package/artifacts/contracts/DAOStackInterfaces.sol/SchemeRegistrar.dbg.json +1 -1
  7. package/artifacts/contracts/Interfaces.sol/AggregatorV3Interface.dbg.json +1 -1
  8. package/artifacts/contracts/Interfaces.sol/ERC20.dbg.json +1 -1
  9. package/artifacts/contracts/Interfaces.sol/IAaveIncentivesController.dbg.json +1 -1
  10. package/artifacts/contracts/Interfaces.sol/IAdminWallet.dbg.json +1 -1
  11. package/artifacts/contracts/Interfaces.sol/IDonationStaking.dbg.json +1 -1
  12. package/artifacts/contracts/Interfaces.sol/IERC2917.dbg.json +1 -1
  13. package/artifacts/contracts/Interfaces.sol/IFirstClaimPool.dbg.json +1 -1
  14. package/artifacts/contracts/Interfaces.sol/IGoodDollar.dbg.json +1 -1
  15. package/artifacts/contracts/Interfaces.sol/IGoodStaking.dbg.json +1 -1
  16. package/artifacts/contracts/Interfaces.sol/IHasRouter.dbg.json +1 -1
  17. package/artifacts/contracts/Interfaces.sol/IIdentity.dbg.json +1 -1
  18. package/artifacts/contracts/Interfaces.sol/ILendingPool.dbg.json +1 -1
  19. package/artifacts/contracts/Interfaces.sol/INameService.dbg.json +1 -1
  20. package/artifacts/contracts/Interfaces.sol/IUBIScheme.dbg.json +1 -1
  21. package/artifacts/contracts/Interfaces.sol/ProxyAdmin.dbg.json +1 -1
  22. package/artifacts/contracts/Interfaces.sol/Reserve.dbg.json +1 -1
  23. package/artifacts/contracts/Interfaces.sol/Staking.dbg.json +1 -1
  24. package/artifacts/contracts/Interfaces.sol/Uniswap.dbg.json +1 -1
  25. package/artifacts/contracts/Interfaces.sol/UniswapFactory.dbg.json +1 -1
  26. package/artifacts/contracts/Interfaces.sol/UniswapPair.dbg.json +1 -1
  27. package/artifacts/contracts/Interfaces.sol/cERC20.dbg.json +1 -1
  28. package/artifacts/contracts/governance/ClaimersDistribution.sol/ClaimersDistribution.dbg.json +1 -1
  29. package/artifacts/contracts/governance/ClaimersDistribution.sol/ClaimersDistribution.json +2 -2
  30. package/artifacts/contracts/governance/CompoundVotingMachine.sol/CompoundVotingMachine.dbg.json +1 -1
  31. package/artifacts/contracts/governance/GReputation.sol/GReputation.dbg.json +1 -1
  32. package/artifacts/contracts/governance/GReputation.sol/GReputation.json +62 -4
  33. package/artifacts/contracts/governance/GovarnanceStaking.sol/GovernanceStaking.dbg.json +1 -1
  34. package/artifacts/contracts/governance/MultiBaseGovernanceShareField.sol/MultiBaseGovernanceShareField.dbg.json +1 -1
  35. package/artifacts/contracts/governance/Reputation.sol/Reputation.dbg.json +1 -1
  36. package/artifacts/contracts/governance/Reputation.sol/Reputation.json +17 -17
  37. package/artifacts/contracts/governance/StakersDistribution.sol/StakersDistribution.dbg.json +1 -1
  38. package/artifacts/contracts/governance/StakersDistribution.sol/StakersDistribution.json +2 -2
  39. package/artifacts/contracts/mocks/AaveMock.sol/AaveMock.dbg.json +1 -1
  40. package/artifacts/contracts/mocks/DAIMock.sol/DAIMock.dbg.json +1 -1
  41. package/artifacts/contracts/mocks/DecimalsMock.sol/DecimalsMock.dbg.json +1 -1
  42. package/artifacts/contracts/mocks/GoodCompoundStakingTest.sol/GoodCompoundStakingTest.dbg.json +1 -1
  43. package/artifacts/contracts/mocks/GoodCompoundStakingTest.sol/GoodCompoundStakingTest.json +6 -6
  44. package/artifacts/contracts/mocks/GoodFundManagerTest.sol/GoodFundManagerTest.dbg.json +1 -1
  45. package/artifacts/contracts/mocks/IncentiveControllerMock.sol/IncentiveControllerMock.dbg.json +1 -1
  46. package/artifacts/contracts/mocks/LendingPoolMock.sol/LendingPoolMock.dbg.json +1 -1
  47. package/artifacts/contracts/mocks/OverMintTester.sol/OverMintTester.dbg.json +1 -1
  48. package/artifacts/contracts/mocks/OverMintTesterRegularStake.sol/OverMintTesterRegularStake.dbg.json +1 -1
  49. package/artifacts/contracts/mocks/OverMintTesterRegularStake.sol/OverMintTesterRegularStake.json +2 -2
  50. package/artifacts/contracts/mocks/SixteenDecimalsTokenMock.sol/SixteenDecimalsTokenMock.dbg.json +1 -1
  51. package/artifacts/contracts/mocks/SwapHelperTest.sol/SwapHelperTest.dbg.json +1 -1
  52. package/artifacts/contracts/mocks/TwentyDecimalsTokenMock.sol/TwentyDecimalsTokenMock.dbg.json +1 -1
  53. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock.dbg.json +1 -1
  54. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock2.dbg.json +1 -1
  55. package/artifacts/contracts/mocks/UsdcMock.sol/USDCMock.dbg.json +1 -1
  56. package/artifacts/contracts/mocks/cBATMock.sol/cBATMock.dbg.json +1 -1
  57. package/artifacts/contracts/mocks/cDAILowWorthMock.sol/cDAILowWorthMock.dbg.json +1 -1
  58. package/artifacts/contracts/mocks/cDAIMock.sol/cDAIMock.dbg.json +1 -1
  59. package/artifacts/contracts/mocks/cDAINonMintableMock.sol/cDAINonMintableMock.dbg.json +1 -1
  60. package/artifacts/contracts/mocks/cDecimalsMock.sol/cDecimalsMock.dbg.json +1 -1
  61. package/artifacts/contracts/mocks/cSDTMock.sol/cSDTMock.dbg.json +1 -1
  62. package/artifacts/contracts/mocks/cUSDCMock.sol/cUSDCMock.dbg.json +1 -1
  63. package/artifacts/contracts/reserve/ExchangeHelper.sol/ExchangeHelper.dbg.json +1 -1
  64. package/artifacts/contracts/reserve/GoodMarketMaker.sol/GoodMarketMaker.dbg.json +1 -1
  65. package/artifacts/contracts/reserve/GoodReserveCDai.sol/ContributionCalc.dbg.json +1 -1
  66. package/artifacts/contracts/reserve/GoodReserveCDai.sol/GoodReserveCDai.dbg.json +1 -1
  67. package/artifacts/contracts/staking/BaseShareField.sol/BaseShareField.dbg.json +1 -1
  68. package/artifacts/contracts/staking/DonationsStaking.sol/DonationsStaking.dbg.json +1 -1
  69. package/artifacts/contracts/staking/DonationsStaking.sol/DonationsStaking.json +2 -2
  70. package/artifacts/contracts/staking/GoodFundManager.sol/GoodFundManager.dbg.json +1 -1
  71. package/artifacts/contracts/staking/SimpleStaking.sol/SimpleStaking.dbg.json +1 -1
  72. package/artifacts/contracts/staking/UniswapV2SwapHelper.sol/UniswapV2SwapHelper.dbg.json +1 -1
  73. package/artifacts/contracts/staking/aave/AaveStakingFactory.sol/AaveStakingFactory.dbg.json +1 -1
  74. package/artifacts/contracts/staking/aave/AaveStakingFactory.sol/AaveStakingFactory.json +3 -3
  75. package/artifacts/contracts/staking/aave/GoodAaveStaking.sol/GoodAaveStaking.dbg.json +1 -1
  76. package/artifacts/contracts/staking/aave/GoodAaveStaking.sol/GoodAaveStaking.json +4 -4
  77. package/artifacts/contracts/staking/compound/CompoundStakingFactory.sol/CompoundStakingFactory.dbg.json +1 -1
  78. package/artifacts/contracts/staking/compound/CompoundStakingFactory.sol/CompoundStakingFactory.json +2 -2
  79. package/artifacts/contracts/staking/compound/GoodCompoundStaking.sol/GoodCompoundStaking.dbg.json +1 -1
  80. package/artifacts/contracts/staking/compound/GoodCompoundStaking.sol/GoodCompoundStaking.json +4 -4
  81. package/artifacts/contracts/ubi/UBIScheme.sol/UBIScheme.dbg.json +1 -1
  82. package/artifacts/contracts/ubi/UBIScheme.sol/UBIScheme.json +2 -2
  83. package/artifacts/contracts/unaudited-foundation/FuseFaucet.sol/FuseFaucet.dbg.json +1 -1
  84. package/artifacts/contracts/unaudited-foundation/InvitesV1.sol/InvitesV1.dbg.json +1 -1
  85. package/artifacts/contracts/utils/BancorFormula.sol/BancorFormula.dbg.json +1 -1
  86. package/artifacts/contracts/utils/DAOContract.sol/DAOContract.dbg.json +1 -1
  87. package/artifacts/contracts/utils/DAOUpgradeableContract.sol/DAOUpgradeableContract.dbg.json +1 -1
  88. package/artifacts/contracts/utils/DSMath.sol/DSMath.dbg.json +1 -1
  89. package/artifacts/contracts/utils/DataTypes.sol/DataTypes.dbg.json +1 -1
  90. package/artifacts/contracts/utils/NameService.sol/NameService.dbg.json +1 -1
  91. package/artifacts/contracts/utils/ProtocolUpgrade.sol/OldMarketMaker.dbg.json +1 -1
  92. package/artifacts/contracts/utils/ProtocolUpgrade.sol/ProtocolUpgrade.dbg.json +1 -1
  93. package/artifacts/contracts/utils/ProtocolUpgradeFuse.sol/ProtocolUpgradeFuse.dbg.json +1 -1
  94. package/artifacts/contracts/utils/ReputationTestHelper.sol/ReputationTestHelper.dbg.json +1 -1
  95. package/artifacts/contracts/utils/ReputationTestHelper.sol/ReputationTestHelper.json +2 -2
  96. package/contracts/governance/GReputation.sol +53 -14
  97. package/contracts/governance/Reputation.sol +13 -25
  98. package/contracts/staking/aave/GoodAaveStaking.sol +4 -3
  99. package/contracts/staking/compound/GoodCompoundStaking.sol +4 -3
  100. package/contracts/ubi/UBIScheme.sol +16 -11
  101. package/package.json +1 -1
  102. package/releases/deployment.json +108 -97
  103. package/releases/olddao.json +1 -406
  104. package/scripts/deployFullDAO.ts +18 -7
  105. package/scripts/misc/goodgiveback.ts +64 -0
  106. package/scripts/verify.ts +60 -47
  107. package/test/governance/ClaimersDistribution.test.ts +5 -5
  108. package/test/governance/CompoundVotingMachine.castvote.test.ts +1 -1
  109. package/test/governance/CompoundVotingMachine.daoscheme.ts +1 -1
  110. package/test/governance/CompoundVotingMachine.guardian.test.ts +1 -1
  111. package/test/governance/GReputation.test.ts +49 -18
  112. package/test/governance/GovernanceStaking.test.ts +71 -47
  113. package/test/governance/Reputation.test.ts +52 -51
  114. package/test/governance/StakersDistribution.test.ts +12 -8
  115. package/truffle-config.js +12 -0
package/scripts/verify.ts CHANGED
@@ -1,54 +1,67 @@
1
- import fs from "fs"
2
- import { isArray } from "lodash"
1
+ import fs from "fs";
2
+ import { isArray } from "lodash";
3
3
  import type EthersT from "ethers";
4
- import type HreT from "hardhat"
5
- import { HardhatEthersHelpers } from "@nomiclabs/hardhat-ethers/types"
6
- import { execSync } from "child_process"
7
- type Ethers = typeof EthersT.ethers & HardhatEthersHelpers
8
- type HRE = typeof HreT
4
+ import type HreT from "hardhat";
5
+ import { HardhatEthersHelpers } from "@nomiclabs/hardhat-ethers/types";
6
+ import { execSync } from "child_process";
7
+ type Ethers = typeof EthersT.ethers & HardhatEthersHelpers;
8
+ type HRE = typeof HreT;
9
9
 
10
- let ethers:Ethers
10
+ let ethers: Ethers;
11
11
  export const verify = async (hre: HRE) => {
12
- console.log("truffle compiling....")
13
- const Verify = require("truffle-plugin-verify") //not imported because of bug
14
- const truffleOutput = execSync("npx truffle compile").toString("utf8")
15
- console.log({truffleOutput})
16
- ethers = hre.ethers
17
- const deployed = JSON.parse(fs.readFileSync("releases/deployment.json").toString())
18
- const contracts = deployed[hre.network.name]
19
-
20
- const contractPairs = (await Promise.all(Object.entries(contracts).map(async (entry) => {
21
- if(isArray(entry[1]))
22
- return
23
- const addr = await getImplementationAddress(entry[1])
24
- return entry[0]+'@'+addr
25
- }))).filter(_ => _)
12
+ console.log("truffle compiling....");
13
+ const Verify = require("truffle-plugin-verify"); //not imported because of bug
14
+ const truffleOutput = execSync("npx truffle compile").toString("utf8");
15
+ console.log({ truffleOutput });
16
+ ethers = hre.ethers;
17
+ const deployed = JSON.parse(
18
+ fs.readFileSync("releases/deployment.json").toString()
19
+ );
20
+ const contracts = deployed[hre.network.name];
26
21
 
27
- contractPairs.unshift()
22
+ const contractPairs = (
23
+ await Promise.all(
24
+ Object.entries(contracts).map(async entry => {
25
+ if (isArray(entry[1])) return;
26
+ if (
27
+ typeof entry[1] !== "string" ||
28
+ (entry[1] as string).startsWith("0x") === false
29
+ )
30
+ return;
31
+ const addr = await getImplementationAddress(entry[1]);
32
+ return entry[0] + "@" + addr;
33
+ })
34
+ )
35
+ ).filter(_ => _);
28
36
 
29
- const config = {
30
- debug: false,
31
- network_id: hre.network.config.chainId,
32
- api_keys: {
33
- etherscan: hre.config.etherscan.apiKey
34
- },
35
- working_directory: ".",
36
- contracts_build_directory: "build/contracts",
37
- '_':contractPairs
38
- }
39
- return Verify(config)
37
+ contractPairs.unshift();
38
+
39
+ const config = {
40
+ debug: false,
41
+ network_id: hre.network.config.chainId,
42
+ api_keys: {
43
+ etherscan: hre.config.etherscan.apiKey
44
+ },
45
+ working_directory: ".",
46
+ contracts_build_directory: "build/contracts",
47
+ _: contractPairs
48
+ };
49
+ return Verify(config);
40
50
  };
41
51
 
42
- const getImplementationAddress = async (addr) => {
43
- let proxy = await ethers.provider.getStorageAt(addr,"0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc")
44
- let res = addr
45
- if(proxy != ethers.constants.HashZero)
46
- res = "0x"+proxy.slice(-40)
47
- else {
48
- const code = await ethers.getDefaultProvider().getCode(addr)
49
- if(code.startsWith("0x363d3d373d3d3d363d73"))
50
- res = "0x"+code.slice(22,62)
51
- }
52
- console.log("impl address for:",addr,res)
53
- return res
54
- }
52
+ const getImplementationAddress = async addr => {
53
+ console.log("finding impl for:", addr);
54
+ let proxy = await ethers.provider.getStorageAt(
55
+ addr,
56
+ "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc"
57
+ );
58
+ let res = addr;
59
+ if (proxy != ethers.constants.HashZero) res = "0x" + proxy.slice(-40);
60
+ else {
61
+ const code = await ethers.getDefaultProvider().getCode(addr);
62
+ if (code.startsWith("0x363d3d373d3d3d363d73"))
63
+ res = "0x" + code.slice(22, 62);
64
+ }
65
+ console.log("impl address for:", addr, res);
66
+ return res;
67
+ };
@@ -132,7 +132,7 @@ describe("ClaimersDistribution", () => {
132
132
  "GReputation",
133
133
  reputation
134
134
  )) as GReputation;
135
- expect(await rep.balanceOf(claimer2.address)).to.equal(
135
+ expect(await rep.balanceOfLocal(claimer2.address)).to.equal(
136
136
  ethers.utils.parseEther("2000000")
137
137
  ); //half of reputation since he claimed once out of 2 claims
138
138
  });
@@ -149,7 +149,7 @@ describe("ClaimersDistribution", () => {
149
149
  "GReputation",
150
150
  reputation
151
151
  )) as GReputation;
152
- expect(await rep.balanceOf(claimer1.address)).to.equal(
152
+ expect(await rep.balanceOfLocal(claimer1.address)).to.equal(
153
153
  ethers.utils.parseEther("2000000")
154
154
  ); //half of reputation since he claimed once out of 2 claims
155
155
  });
@@ -167,9 +167,9 @@ describe("ClaimersDistribution", () => {
167
167
  "GReputation",
168
168
  reputation
169
169
  )) as GReputation;
170
- const startrep = await rep.balanceOf(claimer1.address);
170
+ const startrep = await rep.balanceOfLocal(claimer1.address);
171
171
  await expect(cd.claimReputation(claimer1.address)).to.not.reverted;
172
- const endrep = await rep.balanceOf(claimer1.address);
172
+ const endrep = await rep.balanceOfLocal(claimer1.address);
173
173
  expect(startrep).to.equal(endrep);
174
174
  });
175
175
 
@@ -183,7 +183,7 @@ describe("ClaimersDistribution", () => {
183
183
  "GReputation",
184
184
  reputation
185
185
  )) as GReputation;
186
- expect(await rep.balanceOf(claimer3.address)).to.equal(0);
186
+ expect(await rep.balanceOfLocal(claimer3.address)).to.equal(0);
187
187
  });
188
188
 
189
189
  it("should be able to claim every day", async () => {
@@ -121,7 +121,7 @@ describe("CompoundVotingMachine#CastVote", () => {
121
121
 
122
122
  await grep.mint(actor.address, ethers.BigNumber.from("100001"));
123
123
  console.log(
124
- await grep.balanceOf(actor.address).then(_ => _.toString())
124
+ await grep.balanceOfLocal(actor.address).then(_ => _.toString())
125
125
  );
126
126
  let tx = await gov
127
127
  .connect(actor)
@@ -249,7 +249,7 @@ describe("CompoundVotingMachine#DAOScheme", () => {
249
249
  expect(states[await gov.state(proposalId)]).to.equal("Executed");
250
250
 
251
251
  //acct should now have 1M after proposal minted rep
252
- expect(await grep.balanceOf(acct.address)).to.equal(
252
+ expect(await grep.balanceOfLocal(acct.address)).to.equal(
253
253
  ethers.BigNumber.from("1000000")
254
254
  );
255
255
  });
@@ -205,7 +205,7 @@ describe("CompoundVotingMachine#Guardian", () => {
205
205
  grep.address,
206
206
  await grep.totalSupply().then(_ => _.toString()),
207
207
  await (await grep.getVotes(root.address)).toString(),
208
- await (await grep.balanceOf(root.address)).toString(),
208
+ await (await grep.balanceOfLocal(root.address)).toString(),
209
209
  await gov.rep()
210
210
  );
211
211
  let targets = [gov.address];
@@ -7,6 +7,7 @@ import { expect } from "chai";
7
7
  import { GReputation } from "../../types";
8
8
  import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signer-with-address";
9
9
  import { advanceBlocks, createDAO, increaseTime } from "../helpers";
10
+ import { TextDecoder } from "util";
10
11
 
11
12
  const BN = ethers.BigNumber;
12
13
  export const NULL_ADDRESS = ethers.constants.AddressZero;
@@ -130,7 +131,7 @@ describe("GReputation", () => {
130
131
  });
131
132
 
132
133
  it("should get balanceOf", async () => {
133
- const repBalance = await grep.balanceOf(founder);
134
+ const repBalance = await grep.balanceOfLocal(founder);
134
135
  expect(repBalance.toNumber()).to.be.equal(0);
135
136
  });
136
137
 
@@ -162,7 +163,7 @@ describe("GReputation", () => {
162
163
  await grep.proveBalanceOfAtBlockchain("rootState", rep1, 1, proof, 1);
163
164
 
164
165
  //root states changes the core balance
165
- const newRep = await grep.balanceOf(rep1);
166
+ const newRep = await grep.balanceOfLocal(rep1);
166
167
  expect(newRep.toNumber()).to.be.equal(1);
167
168
 
168
169
  const newVotes = await grep.getVotes(rep1);
@@ -199,10 +200,12 @@ describe("GReputation", () => {
199
200
 
200
201
  describe("delegation", async () => {
201
202
  it("should allow delegation", async () => {
202
- expect(await grep.balanceOf(rep3)).to.be.eq(BN.from(0));
203
+ expect(await grep.balanceOfLocal(rep3)).to.be.eq(BN.from(0));
203
204
  await grep.connect(signers[2]).delegateTo(rep3); //rep1 -> rep3
204
205
 
205
- expect(await grep.getVotes(rep3)).to.be.eq(await grep.balanceOf(rep1)); //with delegation
206
+ expect(await grep.getVotes(rep3)).to.be.eq(
207
+ await grep.balanceOfLocal(rep1)
208
+ ); //with delegation
206
209
  expect(
207
210
  await grep.getVotes(rep1),
208
211
  "delegator should now have 0 votes"
@@ -238,7 +241,7 @@ describe("GReputation", () => {
238
241
  });
239
242
 
240
243
  it("should allow to change delegate", async () => {
241
- expect(await grep.balanceOf(rep1)).to.be.eq(BN.from(1)); //proof was submitted
244
+ expect(await grep.balanceOfLocal(rep1)).to.be.eq(BN.from(1)); //proof was submitted
242
245
  await grep.connect(signers[3]).delegateTo(rep1); //rep2 -> rep1
243
246
  expect(await grep.getVotes(rep3)).to.be.eq(BN.from(1)); //previous delegate should now be 1 bcause it has only rep1
244
247
  expect(await grep.getVotes(rep1)).to.be.eq(
@@ -251,10 +254,10 @@ describe("GReputation", () => {
251
254
 
252
255
  it("should allow undelegation", async () => {
253
256
  await grep.connect(signers[2]).undelegate(); //rep1 -> remove delegattion to rep3
254
- expect(await grep.balanceOf(rep3)).to.be.eq(BN.from(0));
257
+ expect(await grep.balanceOfLocal(rep3)).to.be.eq(BN.from(0));
255
258
  expect(await grep.getVotes(rep3)).to.be.eq(BN.from(0));
256
259
  expect(await grep.getVotes(rep1)).to.be.eq(BN.from(3)); //rep2 delegating to rep1 + rep1 votes
257
- expect(await grep.balanceOf(rep1)).to.be.eq(BN.from(1));
260
+ expect(await grep.balanceOfLocal(rep1)).to.be.eq(BN.from(1));
258
261
 
259
262
  expect(await grep.delegates(rep1)).to.be.eq(rep1);
260
263
  });
@@ -409,20 +412,30 @@ describe("GReputation", () => {
409
412
  ["fuse", "0x" + merkleRoot.toString("hex"), 200]
410
413
  );
411
414
 
415
+ const totalSupply = await grep.totalSupply();
412
416
  await expect(avatarGenericCall(grep.address, encodedCall)).to.not.be
413
417
  .reverted;
418
+ const totalAfterSupply = await grep.totalSupply();
419
+ expect(totalAfterSupply).to.eq(totalSupply.add(200));
420
+ });
421
+
422
+ it("should modify only local totalSupply on burn mint", async () => {
423
+ const totalSupply = await grep.totalSupply();
424
+ await grepWithOwner["mint(address,uint256)"](founder, 155);
425
+ const totalSupplyAfter = await grep.totalSupply();
426
+ expect(totalSupplyAfter).to.eq(totalSupply.add(155));
414
427
  });
415
428
 
416
429
  it("should not reset core balance", async () => {
417
430
  //before proving new rep in new root balance should be 0
418
- const newRep = await grep.balanceOf(rep1);
431
+ const newRep = await grep.balanceOfLocal(rep1);
419
432
  expect(newRep.toNumber()).to.be.gt(0);
420
- const newRep2 = await grep.balanceOf(rep2);
433
+ const newRep2 = await grep.balanceOfLocal(rep2);
421
434
  expect(newRep2.toNumber()).to.be.gt(0);
422
435
  });
423
436
 
424
437
  it("should prove balance in new state", async () => {
425
- const prevRep = await grep.balanceOf(rep2);
438
+ const prevRep = await grep.balanceOfLocal(rep2);
426
439
  const prevVotes = await grep.getVotes(rep2);
427
440
  const { proof } = getMerkleAndProof(
428
441
  [
@@ -435,17 +448,29 @@ describe("GReputation", () => {
435
448
  );
436
449
 
437
450
  await grep.proveBalanceOfAtBlockchain("fuse", rep2, 200, proof, 2);
438
- const newRep = await grep.balanceOf(rep2);
451
+ const newRep = await grep.balanceOfLocal(rep2);
439
452
  expect(newRep).to.be.equal(prevRep); //core rep should not change
440
453
  const newVotes = await grep.getVotes(rep2);
441
454
 
442
455
  expect(newVotes).to.be.equal(prevVotes.add(200));
443
456
  });
444
457
 
445
- it("should allow delegation of new state balance", async () => {
458
+ it("should keep active votes (local balance) correctly after mint/burn", async () => {
459
+ await grep.connect(signers[3]).undelegate();
460
+ const totalSupply = await grep.getCurrentVotes(rep2);
461
+ const tx = await grepWithOwner["mint(address,uint256)"](rep2, 155);
462
+ const result = await tx.wait();
463
+ const totalSupplyAfter = await grep.getVotes(rep2);
464
+ expect(totalSupplyAfter).to.eq(totalSupply.add(155));
465
+ });
466
+
467
+ it("should only delegate core balance and not new state balance", async () => {
446
468
  expect(await grep.getVotes(rep3)).to.be.eq(BN.from(0));
447
469
  await grep.connect(signers[3]).delegateTo(rep3); //rep2=signers[3]
448
- expect(await grep.getVotes(rep3)).to.be.eq(await grep.balanceOf(rep2));
470
+ expect(await grep.getVotes(rep3)).to.be.eq(
471
+ await grep.balanceOfLocal(rep2)
472
+ );
473
+ expect(await grep.getVotes(rep3)).to.be.lt(await grep.getVotes(rep2));
449
474
  });
450
475
 
451
476
  it("should not effect delegate balance after new state hash", async () => {
@@ -680,12 +705,18 @@ describe("GReputation", () => {
680
705
 
681
706
  it("it should be able to get totalSupply for particular block", async () => {
682
707
  let currentSupply = await grep["totalSupply()"]();
708
+ let localSupply = await grep.totalSupplyLocalAt(
709
+ await ethers.provider.getBlockNumber()
710
+ );
683
711
  await grepWithOwner["mint(address,uint256)"](
684
712
  founder,
685
713
  ethers.utils.parseEther("1")
686
714
  );
687
715
  let currentBlock = await ethers.provider.getBlockNumber();
688
- let totalSupply = await grep.totalSupplyLocal(currentBlock);
716
+ let totalSupply = await grep.totalSupplyAt(currentBlock);
717
+ expect(await grep.totalSupplyLocalAt(currentBlock)).to.equal(
718
+ localSupply.add(ethers.utils.parseEther("1"))
719
+ );
689
720
  expect(
690
721
  totalSupply
691
722
  .sub(currentSupply)
@@ -785,11 +816,11 @@ describe("GReputation", () => {
785
816
  await grep.connect(signers[4]).setReputationRecipient(repTarget);
786
817
  expect(await grep.reputationRecipients(rep3)).to.equal(repTarget);
787
818
  await grepWithOwner.mint(rep3, 111);
788
- expect(await grep.balanceOf(repTarget)).to.equal(111);
819
+ expect(await grep.balanceOfLocal(repTarget)).to.equal(111);
789
820
  });
790
821
 
791
822
  it("user should be able to unset recipient", async () => {
792
- const startBalance = await grep.balanceOf(rep3);
823
+ const startBalance = await grep.balanceOfLocal(rep3);
793
824
  await grep
794
825
  .connect(signers[4])
795
826
  .setReputationRecipient(ethers.constants.AddressZero);
@@ -797,8 +828,8 @@ describe("GReputation", () => {
797
828
  ethers.constants.AddressZero
798
829
  );
799
830
  await grepWithOwner.mint(rep3, 111);
800
- expect(await grep.balanceOf(repTarget)).to.equal(111);
801
- expect(await grep.balanceOf(rep3)).to.equal(startBalance.add(111));
831
+ expect(await grep.balanceOfLocal(repTarget)).to.equal(111);
832
+ expect(await grep.balanceOfLocal(rep3)).to.equal(startBalance.add(111));
802
833
  });
803
834
  });
804
835
  });