@gooddollar/goodprotocol 1.0.29-beta.4 → 1.0.29

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 (297) hide show
  1. package/artifacts/abis/AdminWallet.min.json +1 -1
  2. package/artifacts/abis/GoodDollarMintBurnWrapper.min.json +1 -1
  3. package/artifacts/abis/GoodDollarStaking.min.json +1 -1
  4. package/artifacts/abis/GoodDollarStakingMock.min.json +1 -1
  5. package/artifacts/abis/IGoodDollar.min.json +1 -1
  6. package/artifacts/abis/IIdentity.min.json +1 -1
  7. package/artifacts/abis/UBIScheme.min.json +1 -1
  8. package/artifacts/contracts/DAOStackInterfaces.sol/Avatar.dbg.json +1 -1
  9. package/artifacts/contracts/DAOStackInterfaces.sol/Controller.dbg.json +1 -1
  10. package/artifacts/contracts/DAOStackInterfaces.sol/GlobalConstraintInterface.dbg.json +1 -1
  11. package/artifacts/contracts/DAOStackInterfaces.sol/IntVoteInterface.dbg.json +1 -1
  12. package/artifacts/contracts/DAOStackInterfaces.sol/ReputationInterface.dbg.json +1 -1
  13. package/artifacts/contracts/DAOStackInterfaces.sol/SchemeRegistrar.dbg.json +1 -1
  14. package/artifacts/contracts/Interfaces.sol/AggregatorV3Interface.dbg.json +1 -1
  15. package/artifacts/contracts/Interfaces.sol/ERC20.dbg.json +1 -1
  16. package/artifacts/contracts/Interfaces.sol/IAaveIncentivesController.dbg.json +1 -1
  17. package/artifacts/contracts/Interfaces.sol/IAdminWallet.dbg.json +1 -1
  18. package/artifacts/contracts/Interfaces.sol/IDonationStaking.dbg.json +1 -1
  19. package/artifacts/contracts/Interfaces.sol/IERC2917.dbg.json +1 -1
  20. package/artifacts/contracts/Interfaces.sol/IFirstClaimPool.dbg.json +1 -1
  21. package/artifacts/contracts/Interfaces.sol/IGoodDollar.dbg.json +1 -1
  22. package/artifacts/contracts/Interfaces.sol/IGoodDollar.json +0 -39
  23. package/artifacts/contracts/Interfaces.sol/IGoodStaking.dbg.json +1 -1
  24. package/artifacts/contracts/Interfaces.sol/IHasRouter.dbg.json +1 -1
  25. package/artifacts/contracts/Interfaces.sol/IIdentity.dbg.json +1 -1
  26. package/artifacts/contracts/Interfaces.sol/IIdentity.json +0 -51
  27. package/artifacts/contracts/Interfaces.sol/ILendingPool.dbg.json +1 -1
  28. package/artifacts/contracts/Interfaces.sol/IMultichainRouter.dbg.json +1 -1
  29. package/artifacts/contracts/Interfaces.sol/INameService.dbg.json +1 -1
  30. package/artifacts/contracts/Interfaces.sol/IUBIScheme.dbg.json +1 -1
  31. package/artifacts/contracts/Interfaces.sol/ProxyAdmin.dbg.json +1 -1
  32. package/artifacts/contracts/Interfaces.sol/Reserve.dbg.json +1 -1
  33. package/artifacts/contracts/Interfaces.sol/Staking.dbg.json +1 -1
  34. package/artifacts/contracts/Interfaces.sol/Uniswap.dbg.json +1 -1
  35. package/artifacts/contracts/Interfaces.sol/UniswapFactory.dbg.json +1 -1
  36. package/artifacts/contracts/Interfaces.sol/UniswapPair.dbg.json +1 -1
  37. package/artifacts/contracts/Interfaces.sol/cERC20.dbg.json +1 -1
  38. package/artifacts/contracts/fuseFaucet/FuseFaucet.sol/FuseFaucet.dbg.json +1 -1
  39. package/artifacts/contracts/fuseFaucet/FuseFaucet.sol/FuseFaucet.json +2 -2
  40. package/artifacts/contracts/governance/ClaimersDistribution.sol/ClaimersDistribution.dbg.json +1 -1
  41. package/artifacts/contracts/governance/ClaimersDistribution.sol/ClaimersDistribution.json +2 -2
  42. package/artifacts/contracts/governance/CompoundVotingMachine.sol/CompoundVotingMachine.dbg.json +1 -1
  43. package/artifacts/contracts/governance/CompoundVotingMachine.sol/CompoundVotingMachine.json +2 -2
  44. package/artifacts/contracts/governance/GReputation.sol/GReputation.dbg.json +1 -1
  45. package/artifacts/contracts/governance/GReputation.sol/GReputation.json +2 -2
  46. package/artifacts/contracts/governance/GoodDollarStaking.sol/GoodDollarStaking.dbg.json +1 -1
  47. package/artifacts/contracts/governance/GoodDollarStaking.sol/GoodDollarStaking.json +2 -15
  48. package/artifacts/contracts/governance/GoodDollarStaking.sol/RewardsMinter.dbg.json +1 -1
  49. package/artifacts/contracts/governance/GovernanceStaking.sol/GovernanceStaking.dbg.json +1 -1
  50. package/artifacts/contracts/governance/GovernanceStaking.sol/GovernanceStaking.json +2 -2
  51. package/artifacts/contracts/governance/MultiBaseGovernanceShareField.sol/MultiBaseGovernanceShareField.dbg.json +1 -1
  52. package/artifacts/contracts/governance/Reputation.sol/Reputation.dbg.json +1 -1
  53. package/artifacts/contracts/governance/Reputation.sol/Reputation.json +2 -2
  54. package/artifacts/contracts/governance/StakersDistribution.sol/StakersDistribution.dbg.json +1 -1
  55. package/artifacts/contracts/governance/StakersDistribution.sol/StakersDistribution.json +2 -2
  56. package/artifacts/contracts/invite/InvitesV1.sol/InvitesV1.dbg.json +1 -1
  57. package/artifacts/contracts/invite/InvitesV1.sol/InvitesV1.json +2 -2
  58. package/artifacts/contracts/mocks/AaveMock.sol/AaveMock.dbg.json +1 -1
  59. package/artifacts/contracts/mocks/DAIMock.sol/DAIMock.dbg.json +1 -1
  60. package/artifacts/contracts/mocks/DecimalsMock.sol/DecimalsMock.dbg.json +1 -1
  61. package/artifacts/contracts/mocks/DistributionBridgeMock.sol/DistributionBridgeMock.dbg.json +1 -1
  62. package/artifacts/contracts/mocks/DistributionBridgeMock.sol/DistributionBridgeMock.json +2 -2
  63. package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTest.dbg.json +1 -1
  64. package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTest.json +2 -2
  65. package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTestHelper.dbg.json +1 -1
  66. package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTestHelper.json +2 -2
  67. package/artifacts/contracts/mocks/GoodCompoundStakingTest.sol/GoodCompoundStakingTest.dbg.json +1 -1
  68. package/artifacts/contracts/mocks/GoodCompoundStakingTest.sol/GoodCompoundStakingTest.json +2 -2
  69. package/artifacts/contracts/mocks/GoodDollarStakingMock.sol/GoodDollarStakingMock.dbg.json +1 -1
  70. package/artifacts/contracts/mocks/GoodDollarStakingMock.sol/GoodDollarStakingMock.json +2 -15
  71. package/artifacts/contracts/mocks/GoodFundManagerTest.sol/GoodFundManagerTest.dbg.json +1 -1
  72. package/artifacts/contracts/mocks/GoodFundManagerTest.sol/GoodFundManagerTest.json +2 -2
  73. package/artifacts/contracts/mocks/IncentiveControllerMock.sol/IncentiveControllerMock.dbg.json +1 -1
  74. package/artifacts/contracts/mocks/LendingPoolMock.sol/LendingPoolMock.dbg.json +1 -1
  75. package/artifacts/contracts/mocks/MultichainRouterMock.sol/IWrapper.dbg.json +1 -1
  76. package/artifacts/contracts/mocks/MultichainRouterMock.sol/MultichainRouterMock.dbg.json +1 -1
  77. package/artifacts/contracts/mocks/MultichainRouterMock.sol/MultichainRouterMock.json +2 -2
  78. package/artifacts/contracts/mocks/OverMintTester.sol/IGoodDollarStakingTest.dbg.json +1 -1
  79. package/artifacts/contracts/mocks/OverMintTester.sol/OverMintTester.dbg.json +1 -1
  80. package/artifacts/contracts/mocks/OverMintTester.sol/OverMintTester.json +2 -2
  81. package/artifacts/contracts/mocks/OverMintTesterRegularStake.sol/OverMintTesterRegularStake.dbg.json +1 -1
  82. package/artifacts/contracts/mocks/OverMintTesterRegularStake.sol/OverMintTesterRegularStake.json +2 -2
  83. package/artifacts/contracts/mocks/SixteenDecimalsTokenMock.sol/SixteenDecimalsTokenMock.dbg.json +1 -1
  84. package/artifacts/contracts/mocks/StakingMockFixedAPY.sol/StakingMockFixedAPY.dbg.json +1 -1
  85. package/artifacts/contracts/mocks/SwapHelperTest.sol/SwapHelperTest.dbg.json +1 -1
  86. package/artifacts/contracts/mocks/SwapHelperTest.sol/SwapHelperTest.json +2 -2
  87. package/artifacts/contracts/mocks/TwentyDecimalsTokenMock.sol/TwentyDecimalsTokenMock.dbg.json +1 -1
  88. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock.dbg.json +1 -1
  89. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock.json +2 -2
  90. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock2.dbg.json +1 -1
  91. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock2.json +2 -2
  92. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock3.dbg.json +1 -1
  93. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock3.json +2 -2
  94. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock4.dbg.json +1 -1
  95. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock4.json +2 -2
  96. package/artifacts/contracts/mocks/UsdcMock.sol/USDCMock.dbg.json +1 -1
  97. package/artifacts/contracts/mocks/cBATMock.sol/cBATMock.dbg.json +1 -1
  98. package/artifacts/contracts/mocks/cDAILowWorthMock.sol/cDAILowWorthMock.dbg.json +1 -1
  99. package/artifacts/contracts/mocks/cDAIMock.sol/cDAIMock.dbg.json +1 -1
  100. package/artifacts/contracts/mocks/cDAINonMintableMock.sol/cDAINonMintableMock.dbg.json +1 -1
  101. package/artifacts/contracts/mocks/cDecimalsMock.sol/cDecimalsMock.dbg.json +1 -1
  102. package/artifacts/contracts/mocks/cSDTMock.sol/cSDTMock.dbg.json +1 -1
  103. package/artifacts/contracts/mocks/cUSDCMock.sol/cUSDCMock.dbg.json +1 -1
  104. package/artifacts/contracts/reserve/DistributionHelper.sol/DistributionHelper.dbg.json +1 -1
  105. package/artifacts/contracts/reserve/DistributionHelper.sol/DistributionHelper.json +2 -2
  106. package/artifacts/contracts/reserve/ExchangeHelper.sol/ExchangeHelper.dbg.json +1 -1
  107. package/artifacts/contracts/reserve/ExchangeHelper.sol/ExchangeHelper.json +2 -2
  108. package/artifacts/contracts/reserve/GoodMarketMaker.sol/GoodMarketMaker.dbg.json +1 -1
  109. package/artifacts/contracts/reserve/GoodMarketMaker.sol/GoodMarketMaker.json +2 -2
  110. package/artifacts/contracts/reserve/GoodReserveCDai.sol/ContributionCalc.dbg.json +1 -1
  111. package/artifacts/contracts/reserve/GoodReserveCDai.sol/GoodReserveCDai.dbg.json +1 -1
  112. package/artifacts/contracts/reserve/GoodReserveCDai.sol/GoodReserveCDai.json +2 -2
  113. package/artifacts/contracts/staking/BaseShareField.sol/BaseShareField.dbg.json +1 -1
  114. package/artifacts/contracts/staking/BaseShareField.sol/BaseShareField.json +2 -2
  115. package/artifacts/contracts/staking/BaseShareFieldV2.sol/BaseShareFieldV2.dbg.json +1 -1
  116. package/artifacts/contracts/staking/BaseShareFieldV2.sol/BaseShareFieldV2.json +2 -2
  117. package/artifacts/contracts/staking/DonationsStaking.sol/DonationsStaking.dbg.json +1 -1
  118. package/artifacts/contracts/staking/DonationsStaking.sol/DonationsStaking.json +2 -2
  119. package/artifacts/contracts/staking/FuseStakingV3.sol/FuseStakingV3.dbg.json +1 -1
  120. package/artifacts/contracts/staking/FuseStakingV3.sol/FuseStakingV3.json +2 -2
  121. package/artifacts/contracts/staking/FuseStakingV3.sol/IConsensus.dbg.json +1 -1
  122. package/artifacts/contracts/staking/FuseStakingV3.sol/PegSwap.dbg.json +1 -1
  123. package/artifacts/contracts/staking/GoodFundManager.sol/GoodFundManager.dbg.json +1 -1
  124. package/artifacts/contracts/staking/GoodFundManager.sol/GoodFundManager.json +2 -2
  125. package/artifacts/contracts/staking/SimpleStaking.sol/SimpleStaking.dbg.json +1 -1
  126. package/artifacts/contracts/staking/SimpleStakingV2.sol/SimpleStakingV2.dbg.json +1 -1
  127. package/artifacts/contracts/staking/UniswapV2SwapHelper.sol/UniswapV2SwapHelper.dbg.json +1 -1
  128. package/artifacts/contracts/staking/UniswapV2SwapHelper.sol/UniswapV2SwapHelper.json +2 -2
  129. package/artifacts/contracts/staking/aave/AaveStakingFactory.sol/AaveStakingFactory.dbg.json +1 -1
  130. package/artifacts/contracts/staking/aave/AaveStakingFactory.sol/AaveStakingFactory.json +2 -2
  131. package/artifacts/contracts/staking/aave/GoodAaveStaking.sol/GoodAaveStaking.dbg.json +1 -1
  132. package/artifacts/contracts/staking/aave/GoodAaveStaking.sol/GoodAaveStaking.json +2 -2
  133. package/artifacts/contracts/staking/aave/GoodAaveStakingV2.sol/GoodAaveStakingV2.dbg.json +1 -1
  134. package/artifacts/contracts/staking/aave/GoodAaveStakingV2.sol/GoodAaveStakingV2.json +2 -2
  135. package/artifacts/contracts/staking/compound/CompoundStakingFactory.sol/CompoundStakingFactory.dbg.json +1 -1
  136. package/artifacts/contracts/staking/compound/CompoundStakingFactory.sol/CompoundStakingFactory.json +2 -2
  137. package/artifacts/contracts/staking/compound/GoodCompoundStaking.sol/GoodCompoundStaking.dbg.json +1 -1
  138. package/artifacts/contracts/staking/compound/GoodCompoundStaking.sol/GoodCompoundStaking.json +2 -2
  139. package/artifacts/contracts/staking/compound/GoodCompoundStakingV2.sol/GoodCompoundStakingV2.dbg.json +1 -1
  140. package/artifacts/contracts/staking/compound/GoodCompoundStakingV2.sol/GoodCompoundStakingV2.json +2 -2
  141. package/artifacts/contracts/staking/utils/Math64X64.sol/Math64x64.dbg.json +1 -1
  142. package/artifacts/contracts/staking/utils/StakingRewardsFixedAPY.sol/StakingRewardsFixedAPY.dbg.json +1 -1
  143. package/artifacts/contracts/ubi/UBIScheme.sol/UBIScheme.dbg.json +1 -1
  144. package/artifacts/contracts/ubi/UBIScheme.sol/UBIScheme.json +22 -15
  145. package/artifacts/contracts/utils/AdminWallet.sol/AdminWallet.dbg.json +1 -1
  146. package/artifacts/contracts/utils/AdminWallet.sol/AdminWallet.json +56 -76
  147. package/artifacts/contracts/utils/BancorFormula.sol/BancorFormula.dbg.json +1 -1
  148. package/artifacts/contracts/utils/BulkProof.sol/BulkProof.dbg.json +1 -1
  149. package/artifacts/contracts/utils/BulkProof.sol/BulkProof.json +2 -2
  150. package/artifacts/contracts/utils/DAOContract.sol/DAOContract.dbg.json +1 -1
  151. package/artifacts/contracts/utils/DAOContract.sol/DAOContract.json +2 -2
  152. package/artifacts/contracts/utils/DAOUpgradeableContract.sol/DAOUpgradeableContract.dbg.json +1 -1
  153. package/artifacts/contracts/utils/DAOUpgradeableContract.sol/DAOUpgradeableContract.json +2 -2
  154. package/artifacts/contracts/utils/DSMath.sol/DSMath.dbg.json +1 -1
  155. package/artifacts/contracts/utils/DataTypes.sol/DataTypes.dbg.json +1 -1
  156. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/GoodDollarMintBurnWrapper.dbg.json +1 -1
  157. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/GoodDollarMintBurnWrapper.json +2 -16
  158. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/IRouter.dbg.json +1 -1
  159. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/PausableControl.dbg.json +1 -1
  160. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/TokenOperation.dbg.json +1 -1
  161. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/TokenOperation.json +2 -2
  162. package/artifacts/contracts/utils/MultichainBridgeHelper.sol/MultichainBridgeHelper.dbg.json +1 -1
  163. package/artifacts/contracts/utils/MultichainBridgeHelper.sol/MultichainBridgeHelper.json +2 -2
  164. package/artifacts/contracts/utils/NameService.sol/NameService.dbg.json +1 -1
  165. package/artifacts/contracts/utils/ProtocolUpgrade.sol/OldMarketMaker.dbg.json +1 -1
  166. package/artifacts/contracts/utils/ProtocolUpgrade.sol/ProtocolUpgrade.dbg.json +1 -1
  167. package/artifacts/contracts/utils/ProtocolUpgrade.sol/ProtocolUpgrade.json +2 -2
  168. package/artifacts/contracts/utils/ProtocolUpgradeFuse.sol/ProtocolUpgradeFuse.dbg.json +1 -1
  169. package/artifacts/contracts/utils/ProtocolUpgradeFuse.sol/ProtocolUpgradeFuse.json +2 -2
  170. package/artifacts/contracts/utils/ProtocolUpgradeFuseRecover.sol/ProtocolUpgradeFuseRecover.dbg.json +1 -1
  171. package/artifacts/contracts/utils/ProtocolUpgradeFuseRecover.sol/ProtocolUpgradeFuseRecover.json +2 -2
  172. package/artifacts/contracts/utils/ProtocolUpgradeRecover.sol/ProtocolUpgradeRecover.dbg.json +1 -1
  173. package/artifacts/contracts/utils/ProtocolUpgradeRecover.sol/ProtocolUpgradeRecover.json +2 -2
  174. package/artifacts/contracts/utils/ProxyFactory1967.sol/ERC1967Proxy.dbg.json +1 -1
  175. package/artifacts/contracts/utils/ProxyFactory1967.sol/ProxyFactory1967.dbg.json +1 -1
  176. package/artifacts/contracts/utils/ReputationTestHelper.sol/ReputationTestHelper.dbg.json +1 -1
  177. package/artifacts/contracts/utils/ReputationTestHelper.sol/ReputationTestHelper.json +2 -2
  178. package/contracts/Interfaces.sol +0 -26
  179. package/contracts/governance/GReputation.sol +6 -19
  180. package/contracts/governance/GoodDollarStaking.sol +9 -23
  181. package/contracts/ubi/UBIScheme.sol +40 -45
  182. package/contracts/utils/AdminWallet.sol +11 -42
  183. package/contracts/utils/GoodDollarMintBurnWrapper.sol +3 -13
  184. package/hardhat.config.ts +7 -21
  185. package/package.json +2 -3
  186. package/releases/deploy-settings.json +1 -36
  187. package/releases/deployment.json +53 -98
  188. package/scripts/analytics/gdinflow.ts +56 -0
  189. package/scripts/analytics/tokenInOutStats.ts +50 -0
  190. package/scripts/deployFullDAO.ts +19 -39
  191. package/scripts/multichain-deploy/{1_basicdao-deploy.ts → basicdao-deploy.ts} +52 -56
  192. package/scripts/multichain-deploy/{3_gdSavings-deploy.ts → gdSavings-deploy.ts} +76 -90
  193. package/scripts/multichain-deploy/helpers.ts +1 -0
  194. package/scripts/{upgrades → multichain-deploy}/nonubiDistribution-deploy.ts +5 -2
  195. package/scripts/test/localOldDaoDeploy.ts +3 -10
  196. package/test/helpers.ts +8 -12
  197. package/test/ubi/UBIScheme.test.ts +30 -30
  198. package/test/ubi/UBISchemeCycle.test.ts +7 -9
  199. package/test/utils/AdminWallet.test.ts +11 -33
  200. package/types/AdminWallet.ts +113 -124
  201. package/types/GoodDollarMintBurnWrapper.ts +0 -42
  202. package/types/GoodDollarStaking.ts +0 -34
  203. package/types/GoodDollarStakingMock.ts +0 -34
  204. package/types/IGoodDollar.ts +0 -54
  205. package/types/IIdentity.ts +0 -75
  206. package/types/UBIScheme.ts +40 -19
  207. package/types/factories/AaveStakingFactory__factory.ts +1 -1
  208. package/types/factories/AdminWallet__factory.ts +55 -75
  209. package/types/factories/BaseShareFieldV2__factory.ts +1 -1
  210. package/types/factories/BaseShareField__factory.ts +1 -1
  211. package/types/factories/ClaimersDistribution__factory.ts +1 -1
  212. package/types/factories/CompoundStakingFactory__factory.ts +1 -1
  213. package/types/factories/CompoundVotingMachine__factory.ts +1 -1
  214. package/types/factories/DAOContract__factory.ts +1 -1
  215. package/types/factories/DAOUpgradeableContract__factory.ts +1 -1
  216. package/types/factories/DistributionBridgeMock__factory.ts +1 -1
  217. package/types/factories/DistributionHelperTestHelper__factory.ts +1 -1
  218. package/types/factories/DistributionHelperTest__factory.ts +1 -1
  219. package/types/factories/DistributionHelper__factory.ts +1 -1
  220. package/types/factories/DonationsStaking__factory.ts +1 -1
  221. package/types/factories/ExchangeHelper__factory.ts +1 -1
  222. package/types/factories/FuseFaucet__factory.ts +1 -1
  223. package/types/factories/FuseStakingV3__factory.ts +1 -1
  224. package/types/factories/GReputation__factory.ts +1 -1
  225. package/types/factories/GoodAaveStakingV2__factory.ts +1 -1
  226. package/types/factories/GoodAaveStaking__factory.ts +1 -1
  227. package/types/factories/GoodCompoundStakingTest__factory.ts +1 -1
  228. package/types/factories/GoodCompoundStakingV2__factory.ts +1 -1
  229. package/types/factories/GoodCompoundStaking__factory.ts +1 -1
  230. package/types/factories/GoodDollarMintBurnWrapper__factory.ts +1 -15
  231. package/types/factories/GoodDollarStakingMock__factory.ts +1 -14
  232. package/types/factories/GoodDollarStaking__factory.ts +1 -14
  233. package/types/factories/GoodFundManagerTest__factory.ts +1 -1
  234. package/types/factories/GoodFundManager__factory.ts +1 -1
  235. package/types/factories/GoodMarketMaker__factory.ts +1 -1
  236. package/types/factories/GoodReserveCDai__factory.ts +1 -1
  237. package/types/factories/GovernanceStaking__factory.ts +1 -1
  238. package/types/factories/IGoodDollar__factory.ts +0 -39
  239. package/types/factories/IIdentity__factory.ts +0 -51
  240. package/types/factories/InvitesV1__factory.ts +1 -1
  241. package/types/factories/MultichainBridgeHelper__factory.ts +1 -1
  242. package/types/factories/MultichainRouterMock__factory.ts +1 -1
  243. package/types/factories/OverMintTesterRegularStake__factory.ts +1 -1
  244. package/types/factories/OverMintTester__factory.ts +1 -1
  245. package/types/factories/ProtocolUpgradeFuseRecover__factory.ts +1 -1
  246. package/types/factories/ProtocolUpgradeFuse__factory.ts +1 -1
  247. package/types/factories/ProtocolUpgradeRecover__factory.ts +1 -1
  248. package/types/factories/ProtocolUpgrade__factory.ts +1 -1
  249. package/types/factories/ReputationTestHelper__factory.ts +1 -1
  250. package/types/factories/Reputation__factory.ts +1 -1
  251. package/types/factories/StakersDistribution__factory.ts +1 -1
  252. package/types/factories/SwapHelperTest__factory.ts +1 -1
  253. package/types/factories/UBIScheme__factory.ts +21 -14
  254. package/types/factories/UniswapV2SwapHelper__factory.ts +1 -1
  255. package/types/factories/UpgradableMock2__factory.ts +1 -1
  256. package/types/factories/UpgradableMock3__factory.ts +1 -1
  257. package/types/factories/UpgradableMock4__factory.ts +1 -1
  258. package/types/factories/UpgradableMock__factory.ts +1 -1
  259. package/types/hardhat.d.ts +0 -54
  260. package/types/index.ts +0 -12
  261. package/yarn.lock +4 -4
  262. package/artifacts/abis/Faucet.min.json +0 -1
  263. package/artifacts/abis/IGovernanceStaking.min.json +0 -1
  264. package/artifacts/abis/IIdentityV2.min.json +0 -1
  265. package/artifacts/abis/IdentityV2.min.json +0 -1
  266. package/artifacts/abis/InvitesV2.min.json +0 -1
  267. package/artifacts/contracts/Interfaces.sol/IIdentityV2.dbg.json +0 -4
  268. package/artifacts/contracts/Interfaces.sol/IIdentityV2.json +0 -281
  269. package/artifacts/contracts/fuseFaucet/Faucet.sol/Faucet.dbg.json +0 -4
  270. package/artifacts/contracts/fuseFaucet/Faucet.sol/Faucet.json +0 -684
  271. package/artifacts/contracts/governance/GoodDollarStaking.sol/IGovernanceStaking.dbg.json +0 -4
  272. package/artifacts/contracts/governance/GoodDollarStaking.sol/IGovernanceStaking.json +0 -24
  273. package/artifacts/contracts/identity/IdentityV2.sol/IdentityV2.dbg.json +0 -4
  274. package/artifacts/contracts/identity/IdentityV2.sol/IdentityV2.json +0 -1000
  275. package/artifacts/contracts/invite/InvitesV2.sol/InvitesV2.dbg.json +0 -4
  276. package/artifacts/contracts/invite/InvitesV2.sol/InvitesV2.json +0 -586
  277. package/contracts/fuseFaucet/Faucet.sol +0 -247
  278. package/contracts/identity/IdentityV2.sol +0 -434
  279. package/contracts/invite/InvitesV2.sol +0 -316
  280. package/scripts/multichain-deploy/0_proxyFactory-deploy.ts +0 -45
  281. package/scripts/multichain-deploy/2_helpers-deploy.ts +0 -143
  282. package/scripts/multichain-deploy/4_ubi-deploy.ts +0 -121
  283. package/scripts/multichain-deploy/5_gov-deploy.ts +0 -123
  284. package/scripts/multichain-deploy/verifyEtherscan.ts +0 -112
  285. package/scripts/upgrades/identity-upgrade.ts +0 -153
  286. package/types/Faucet.ts +0 -1014
  287. package/types/IERC1271.ts +0 -109
  288. package/types/IGovernanceStaking.ts +0 -98
  289. package/types/IIdentityV2.ts +0 -526
  290. package/types/IdentityV2.ts +0 -1612
  291. package/types/InvitesV2.ts +0 -933
  292. package/types/factories/Faucet__factory.ts +0 -729
  293. package/types/factories/IERC1271__factory.ts +0 -47
  294. package/types/factories/IGovernanceStaking__factory.ts +0 -39
  295. package/types/factories/IIdentityV2__factory.ts +0 -293
  296. package/types/factories/IdentityV2__factory.ts +0 -1048
  297. package/types/factories/InvitesV2__factory.ts +0 -634
@@ -1,247 +0,0 @@
1
- //SPDX-License-Identifier: MIT
2
-
3
- pragma solidity >=0.8.0;
4
-
5
- import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
6
- import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
7
- import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
8
- import "../Interfaces.sol";
9
- import "../utils/NameService.sol";
10
-
11
- /**
12
- * @title DonationStaking contract that receives funds in ETH/DAI
13
- * and stake them in the SimpleStaking contract
14
- */
15
- contract Faucet is Initializable, UUPSUpgradeable, AccessControlUpgradeable {
16
- bytes32 public constant RELAYER_ROLE = keccak256("relayer");
17
-
18
- event WalletTopped(
19
- address indexed account, //address topped
20
- uint256 amount,
21
- address whitelistedRoot, //if account is connected to a whitelisted account, this will be it
22
- address indexed relayerOrWhitelisted //the sender of the tx
23
- );
24
-
25
- uint256 public perDayRoughLimit;
26
- uint256 public toppingAmount;
27
- uint256 public gasRefund;
28
- uint256 public startTime;
29
- uint256 public currentDay;
30
-
31
- NameService public nameService;
32
-
33
- mapping(uint256 => mapping(address => uint256)) public toppings;
34
- mapping(address => bool) public notFirstTime;
35
-
36
- struct Wallet {
37
- uint128 lastDayTopped;
38
- uint32 dailyToppingCount;
39
- uint128[7] lastWeekToppings;
40
- }
41
-
42
- mapping(address => Wallet) public wallets;
43
- uint32 public maxDailyToppings;
44
- uint64 public gasPrice;
45
- uint32 public maxPerWeekMultiplier;
46
- uint32 public maxSwapAmount;
47
- address public goodDollar_unused; //kept because of upgrades
48
- uint64 public maxDailyNewWallets;
49
- uint64 public dailyNewWalletsCount;
50
-
51
- function initialize(
52
- NameService _ns,
53
- uint64 _gasPrice,
54
- address relayer,
55
- address owner
56
- ) public initializer {
57
- __AccessControl_init_unchained();
58
- _setupRole(DEFAULT_ADMIN_ROLE, owner);
59
- if (relayer != address(0)) _setupRole(RELAYER_ROLE, relayer);
60
- gasPrice = _gasPrice;
61
- toppingAmount = 600000 * gasPrice; //0.6M gwei
62
- perDayRoughLimit = 2 * toppingAmount;
63
- maxDailyToppings = 3;
64
- startTime = block.timestamp;
65
- nameService = _ns;
66
- maxPerWeekMultiplier = 2;
67
- maxSwapAmount = 1000;
68
- maxDailyNewWallets = 5000;
69
- }
70
-
71
- function _authorizeUpgrade(address newImplementation)
72
- internal
73
- override
74
- onlyRole(DEFAULT_ADMIN_ROLE)
75
- {}
76
-
77
- function getIdentity() public view returns (IIdentityV2) {
78
- return IIdentityV2(nameService.getAddress("IDENTITY"));
79
- }
80
-
81
- function upgrade() public {
82
- if (maxDailyNewWallets == 0) maxDailyNewWallets = 5000;
83
- }
84
-
85
- modifier reimburseGas() {
86
- uint256 _gasRefund = gasleft();
87
- _;
88
- _gasRefund = _gasRefund - gasleft() + 42000;
89
- payable(msg.sender).transfer(_gasRefund * gasPrice); //gas price assumed 1e9 = 1gwei
90
- }
91
-
92
- receive() external payable {}
93
-
94
- /*
95
- * only whitelisted account or relayer can top non whitelisted accounts
96
- * if target account is whitelisted anyone can top it
97
- */
98
- modifier onlyAuthorized(address toTop) {
99
- require(
100
- getIdentity().getWhitelistedRoot(toTop) != address(0) ||
101
- getIdentity().getWhitelistedRoot(msg.sender) != address(0) ||
102
- hasRole(RELAYER_ROLE, msg.sender)
103
- );
104
- _;
105
- }
106
-
107
- modifier toppingLimit(address _user) {
108
- //switch wallet to the account we do the accounting for
109
- address whitelistedRoot = getIdentity().getWhitelistedRoot(_user);
110
- _user = whitelistedRoot == address(0) ? _user : payable(whitelistedRoot);
111
-
112
- uint256 prevDay = currentDay;
113
-
114
- setDay();
115
- if (currentDay != prevDay) dailyNewWalletsCount = 0;
116
-
117
- require(
118
- wallets[_user].lastDayTopped != uint128(currentDay) ||
119
- wallets[_user].dailyToppingCount < maxDailyToppings,
120
- "max daily toppings"
121
- );
122
-
123
- require(
124
- (notFirstTime[_user] == false &&
125
- dailyNewWalletsCount < maxDailyNewWallets) ||
126
- whitelistedRoot != address(0),
127
- "User not whitelisted or not first time"
128
- );
129
-
130
- //reset inactive days
131
- uint256 dayOfWeek = currentDay % 7;
132
- uint256 dayDiff = (currentDay - wallets[_user].lastDayTopped);
133
- dayDiff = dayDiff > 7 ? 7 : dayDiff;
134
- dayDiff = dayDiff > dayOfWeek ? dayOfWeek + 1 : dayDiff;
135
- for (uint256 day = dayOfWeek + 1 - dayDiff; day <= dayOfWeek; day++) {
136
- wallets[_user].lastWeekToppings[day] = 0;
137
- }
138
-
139
- uint128 weekTotal = 0;
140
- for (uint256 i = 0; i <= dayOfWeek; i++) {
141
- weekTotal += wallets[_user].lastWeekToppings[uint256(i)];
142
- }
143
-
144
- require(
145
- weekTotal < perDayRoughLimit * maxPerWeekMultiplier,
146
- "User wallet has been topped too many times this week"
147
- );
148
- _;
149
- }
150
-
151
- /* @dev Internal function that sets current day
152
- */
153
- function setDay() internal {
154
- currentDay = (block.timestamp - startTime) / 1 days;
155
- }
156
-
157
- function canTop(address _user) external view returns (bool) {
158
- if (toppingAmount < address(_user).balance) return false;
159
-
160
- address whitelistedRoot = getIdentity().getWhitelistedRoot(_user);
161
- _user = whitelistedRoot == address(0) ? _user : whitelistedRoot;
162
-
163
- uint256 _currentDay = (block.timestamp - startTime) / 1 days;
164
- bool can = (wallets[_user].lastDayTopped != uint128(_currentDay) ||
165
- wallets[_user].dailyToppingCount < 3) &&
166
- ((notFirstTime[_user] == false &&
167
- dailyNewWalletsCount < maxDailyNewWallets) ||
168
- whitelistedRoot != address(0));
169
-
170
- uint128[7] memory lastWeekToppings = wallets[_user].lastWeekToppings;
171
- //reset inactive days
172
- uint256 dayOfWeek = _currentDay % 7;
173
- uint256 dayDiff = (_currentDay - wallets[_user].lastDayTopped);
174
- dayDiff = dayDiff > 7 ? 7 : dayDiff;
175
- dayDiff = dayDiff > dayOfWeek ? dayOfWeek + 1 : dayDiff;
176
-
177
- for (uint256 day = dayOfWeek + 1 - dayDiff; day <= dayOfWeek; day++) {
178
- lastWeekToppings[day] = 0;
179
- }
180
-
181
- uint128 weekTotal = 0;
182
- for (uint256 i = 0; i <= dayOfWeek; i++) {
183
- weekTotal += lastWeekToppings[uint256(i)];
184
- }
185
- can = can && weekTotal < perDayRoughLimit * maxPerWeekMultiplier;
186
- return can;
187
- }
188
-
189
- /* @dev Function to top given address with amount of G$ given in constructor
190
- * can only be done by admin the amount of times specified in constructor per day
191
- * @param _user The address to transfer to
192
- */
193
- function topWallet(address payable _user)
194
- public
195
- reimburseGas
196
- toppingLimit(_user)
197
- onlyAuthorized(_user)
198
- {
199
- _topWallet(_user);
200
- }
201
-
202
- function _topWallet(address payable _wallet) internal {
203
- address payable target = _wallet;
204
-
205
- //switch wallet to the account we do the accounting for
206
- address whitelistedRoot = getIdentity().getWhitelistedRoot(_wallet);
207
- _wallet = whitelistedRoot == address(0)
208
- ? _wallet
209
- : payable(whitelistedRoot);
210
-
211
- require(toppingAmount > address(_wallet).balance);
212
- uint256 toTop = toppingAmount - address(_wallet).balance;
213
-
214
- uint256 dayOfWeek = currentDay % 7;
215
-
216
- if (wallets[_wallet].lastDayTopped == uint128(currentDay))
217
- wallets[_wallet].dailyToppingCount += 1;
218
- else wallets[_wallet].dailyToppingCount = 1;
219
- wallets[_wallet].lastDayTopped = uint128(currentDay);
220
- wallets[_wallet].lastWeekToppings[dayOfWeek] += uint128(toTop);
221
-
222
- if (notFirstTime[_wallet] == false && whitelistedRoot == address(0)) {
223
- dailyNewWalletsCount++;
224
- }
225
- notFirstTime[_wallet] = true;
226
-
227
- target.transfer(toTop);
228
- emit WalletTopped(target, toTop, whitelistedRoot, msg.sender);
229
- }
230
-
231
- function onTokenTransfer(
232
- address payable _from,
233
- uint256 amount,
234
- bytes calldata data
235
- ) external returns (bool) {
236
- require(amount <= maxSwapAmount, "slippage");
237
- address uniswapLike = abi.decode(data, (address));
238
- Uniswap uniswap = Uniswap(uniswapLike);
239
- address[] memory path = new address[](2);
240
- path[0] = address(msg.sender);
241
- path[1] = uniswap.WETH();
242
-
243
- cERC20(msg.sender).approve(address(uniswapLike), type(uint256).max);
244
- uniswap.swapExactTokensForETH(amount, 0, path, _from, block.timestamp);
245
- return true;
246
- }
247
- }
@@ -1,434 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity >=0.8.0;
3
-
4
- import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
5
- import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
6
- import "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";
7
-
8
- import "../utils/DAOUpgradeableContract.sol";
9
- import "../utils/NameService.sol";
10
- import "../Interfaces.sol";
11
-
12
- /* @title Identity contract responsible for whitelisting
13
- * and keeping track of amount of whitelisted users
14
- */
15
- contract IdentityV2 is
16
- DAOUpgradeableContract,
17
- AccessControlUpgradeable,
18
- PausableUpgradeable
19
- {
20
- struct Identity {
21
- uint256 dateAuthenticated;
22
- uint256 dateAdded;
23
- string did;
24
- uint256 whitelistedOnChainId;
25
- uint8 status; //0 nothing, 1 whitelisted, 2 daocontract, 255 blacklisted
26
- }
27
-
28
- bytes32 public constant IDENTITY_ADMIN_ROLE = keccak256("identity_admin");
29
- bytes32 public constant PAUSER_ROLE = keccak256("pause_admin");
30
-
31
- uint256 public whitelistedCount;
32
- uint256 public whitelistedContracts;
33
- uint256 public authenticationPeriod;
34
-
35
- mapping(address => Identity) public identities;
36
-
37
- mapping(bytes32 => address) public didHashToAddress;
38
-
39
- mapping(address => address) public connectedAccounts;
40
-
41
- IIdentity public oldIdentity;
42
-
43
- event BlacklistAdded(address indexed account);
44
- event BlacklistRemoved(address indexed account);
45
-
46
- event WhitelistedAdded(address indexed account);
47
- event WhitelistedRemoved(address indexed account);
48
- event WhitelistedAuthenticated(address indexed account, uint256 timestamp);
49
-
50
- event ContractAdded(address indexed account);
51
- event ContractRemoved(address indexed account);
52
-
53
- function initialize(address _owner, IIdentity _oldIdentity)
54
- public
55
- initializer
56
- {
57
- __AccessControl_init_unchained();
58
- __Pausable_init_unchained();
59
- authenticationPeriod = 365 * 3;
60
- _setupRole(DEFAULT_ADMIN_ROLE, avatar);
61
- _setupRole(DEFAULT_ADMIN_ROLE, _owner);
62
- _setupRole(PAUSER_ROLE, avatar);
63
- _setupRole(PAUSER_ROLE, _owner);
64
- _setupRole(IDENTITY_ADMIN_ROLE, _owner);
65
- _setupRole(IDENTITY_ADMIN_ROLE, avatar);
66
-
67
- oldIdentity = _oldIdentity;
68
- }
69
-
70
- function initDAO(address _ns) external onlyRole(DEFAULT_ADMIN_ROLE) {
71
- require(address(nameService) == address(0), "already initialized");
72
- setDAO(INameService(_ns));
73
- _setupRole(DEFAULT_ADMIN_ROLE, avatar);
74
- _setupRole(PAUSER_ROLE, avatar);
75
- _setupRole(IDENTITY_ADMIN_ROLE, avatar);
76
- }
77
-
78
- modifier onlyWhitelisted() {
79
- require(isWhitelisted(msg.sender), "not whitelisted");
80
- _;
81
- }
82
-
83
- /* @dev Sets a new value for authenticationPeriod.
84
- * Can only be called by Identity Administrators.
85
- * @param period new value for authenticationPeriod
86
- */
87
- function setAuthenticationPeriod(uint256 period) external whenNotPaused {
88
- _onlyAvatar();
89
- authenticationPeriod = period;
90
- }
91
-
92
- /* @dev Sets the authentication date of `account`
93
- * to the current time.
94
- * Can only be called by Identity Administrators.
95
- * @param account address to change its auth date
96
- */
97
- function authenticate(address account)
98
- public
99
- onlyRole(IDENTITY_ADMIN_ROLE)
100
- whenNotPaused
101
- {
102
- require(identities[account].status == 1, "not whitelisted");
103
- identities[account].dateAuthenticated = block.timestamp;
104
- emit WhitelistedAuthenticated(account, block.timestamp);
105
- }
106
-
107
- /* @dev Adds an address as whitelisted.
108
- * Can only be called by Identity Administrators.
109
- * @param account address to add as whitelisted
110
- */
111
- function addWhitelisted(address account)
112
- public
113
- onlyRole(IDENTITY_ADMIN_ROLE)
114
- whenNotPaused
115
- {
116
- _addWhitelisted(account, _chainId());
117
- }
118
-
119
- /* @dev Adds an address as whitelisted under a specific ID
120
- * @param account The address to add
121
- * @param did the ID to add account under
122
- */
123
- function addWhitelistedWithDIDAndChain(
124
- address account,
125
- string memory did,
126
- uint256 orgChain,
127
- uint256 dateAuthenticated
128
- ) external onlyRole(IDENTITY_ADMIN_ROLE) whenNotPaused {
129
- _addWhitelistedWithDID(account, did, orgChain);
130
-
131
- //in case we are whitelisting on a new chain an already whitelisted account, we need to make sure it expires at the same time
132
- if (dateAuthenticated > 0) {
133
- identities[account].dateAuthenticated = dateAuthenticated;
134
- }
135
- }
136
-
137
- /* @dev Adds an address as whitelisted under a specific ID
138
- * @param account The address to add
139
- * @param did the ID to add account under
140
- */
141
- function addWhitelistedWithDID(address account, string memory did)
142
- public
143
- onlyRole(IDENTITY_ADMIN_ROLE)
144
- whenNotPaused
145
- {
146
- _addWhitelistedWithDID(account, did, _chainId());
147
- }
148
-
149
- /* @dev Removes an address as whitelisted.
150
- * Can only be called by Identity Administrators.
151
- * @param account address to remove as whitelisted
152
- */
153
- function removeWhitelisted(address account)
154
- public
155
- onlyRole(IDENTITY_ADMIN_ROLE)
156
- whenNotPaused
157
- {
158
- _removeWhitelisted(account);
159
- }
160
-
161
- /* @dev Renounces message sender from whitelisted
162
- */
163
- function renounceWhitelisted() external whenNotPaused {
164
- _removeWhitelisted(msg.sender);
165
- }
166
-
167
- /* @dev Returns true if given address has been added to whitelist
168
- * @param account the address to check
169
- * @return a bool indicating weather the address is present in whitelist
170
- */
171
- function isWhitelisted(address account) public view returns (bool) {
172
- uint256 daysSinceAuthentication = (block.timestamp -
173
- identities[account].dateAuthenticated) / 1 days;
174
- if (
175
- (daysSinceAuthentication <= authenticationPeriod) &&
176
- identities[account].status == 1
177
- ) return true;
178
-
179
- if (address(oldIdentity) != address(0)) {
180
- try oldIdentity.isWhitelisted(account) returns (bool res) {
181
- return res;
182
- } catch {
183
- return false;
184
- }
185
- }
186
- return false;
187
- }
188
-
189
- /* @dev Function that gives the date the given user was added
190
- * @param account The address to check
191
- * @return The date the address was added
192
- */
193
- function lastAuthenticated(address account) external view returns (uint256) {
194
- return identities[account].dateAuthenticated;
195
- }
196
-
197
- /* @dev Adds an address to blacklist.
198
- * Can only be called by Identity Administrators.
199
- * @param account address to add as blacklisted
200
- */
201
- function addBlacklisted(address account)
202
- public
203
- onlyRole(IDENTITY_ADMIN_ROLE)
204
- whenNotPaused
205
- {
206
- identities[account].status = 255;
207
- emit BlacklistAdded(account);
208
- }
209
-
210
- /* @dev Removes an address from blacklist
211
- * Can only be called by Identity Administrators.
212
- * @param account address to remove as blacklisted
213
- */
214
- function removeBlacklisted(address account)
215
- external
216
- onlyRole(IDENTITY_ADMIN_ROLE)
217
- whenNotPaused
218
- {
219
- if (address(oldIdentity) != address(0))
220
- try oldIdentity.removeBlacklisted(account) {} catch {}
221
-
222
- identities[account].status = 0;
223
- emit BlacklistRemoved(account);
224
- }
225
-
226
- /* @dev Function to add a Contract to list of contracts
227
- * @param account The address to add
228
- */
229
- function addContract(address account)
230
- public
231
- onlyRole(IDENTITY_ADMIN_ROLE)
232
- whenNotPaused
233
- {
234
- require(isContract(account), "Given address is not a contract");
235
- _addWhitelisted(account, _chainId());
236
- identities[account].status = 2;
237
-
238
- emit ContractAdded(account);
239
- }
240
-
241
- /* @dev Function to remove a Contract from list of contracts
242
- * @param account The address to add
243
- */
244
- function removeContract(address account)
245
- public
246
- onlyRole(IDENTITY_ADMIN_ROLE)
247
- whenNotPaused
248
- {
249
- _removeWhitelisted(account);
250
-
251
- emit ContractRemoved(account);
252
- }
253
-
254
- /* @dev Function to check if given contract is on list of contracts.
255
- * @param address to check
256
- * @return a bool indicating if address is on list of contracts
257
- */
258
- function isDAOContract(address account) external view returns (bool) {
259
- if (identities[account].status == 2) return true;
260
- if (address(oldIdentity) != address(0)) {
261
- try oldIdentity.isDAOContract(account) returns (bool res) {
262
- return res;
263
- } catch {
264
- return false;
265
- }
266
- }
267
- return false;
268
- }
269
-
270
- /* @dev Internal function to add to whitelisted
271
- * @param account the address to add
272
- */
273
- function _addWhitelisted(address account, uint256 orgChain) internal {
274
- whitelistedCount += 1;
275
- identities[account].status = 1;
276
- identities[account].dateAdded = block.timestamp;
277
- identities[account].dateAuthenticated = block.timestamp;
278
- identities[account].whitelistedOnChainId = orgChain;
279
- connectedAccounts[account] = address(0);
280
-
281
- if (isContract(account)) {
282
- whitelistedContracts += 1;
283
- }
284
-
285
- emit WhitelistedAdded(account);
286
- }
287
-
288
- /* @dev Internal whitelisting with did function.
289
- * @param account the address to add
290
- * @param did the id to register account under
291
- */
292
- function _addWhitelistedWithDID(
293
- address account,
294
- string memory did,
295
- uint256 orgChain
296
- ) internal {
297
- bytes32 pHash = keccak256(bytes(did));
298
- require(didHashToAddress[pHash] == address(0), "DID already registered");
299
-
300
- identities[account].did = did;
301
- didHashToAddress[pHash] = account;
302
-
303
- _addWhitelisted(account, orgChain);
304
- }
305
-
306
- /* @dev Internal function to remove from whitelisted
307
- * @param account the address to add
308
- */
309
- function _removeWhitelisted(address account) internal {
310
- whitelistedCount -= 1;
311
-
312
- if (isContract(account)) {
313
- whitelistedContracts -= 1;
314
- if (address(oldIdentity) != address(0)) {
315
- try oldIdentity.removeContract(account) {} catch {}
316
- }
317
- }
318
- if (address(oldIdentity) != address(0)) {
319
- try oldIdentity.removeWhitelisted(account) {} catch {}
320
- }
321
-
322
- string memory did = identities[account].did;
323
- bytes32 pHash = keccak256(bytes(did));
324
-
325
- delete identities[account];
326
- delete didHashToAddress[pHash];
327
-
328
- emit WhitelistedRemoved(account);
329
- }
330
-
331
- /// @notice helper function to get current chain id
332
- /// @return chainId id
333
- function _chainId() internal view returns (uint256 chainId) {
334
- assembly {
335
- chainId := chainid()
336
- }
337
- }
338
-
339
- /* @dev Returns true if given address has been added to the blacklist
340
- * @param account the address to check
341
- * @return a bool indicating weather the address is present in the blacklist
342
- */
343
- function isBlacklisted(address account) public view returns (bool) {
344
- if (identities[account].status == 255) return true;
345
- if (address(oldIdentity) != address(0)) {
346
- try oldIdentity.isBlacklisted(account) returns (bool res) {
347
- return res;
348
- } catch {
349
- return false;
350
- }
351
- }
352
- }
353
-
354
- /* @dev Function to see if given address is a contract
355
- * @return true if address is a contract
356
- */
357
- function isContract(address _addr) internal view returns (bool) {
358
- uint256 length;
359
- assembly {
360
- length := extcodesize(_addr)
361
- }
362
- return length > 0;
363
- }
364
-
365
- function connectAccount(address _account, bytes memory signature)
366
- external
367
- onlyWhitelisted
368
- {
369
- require(
370
- !isWhitelisted(_account) && !isBlacklisted(_account),
371
- "invalid account"
372
- );
373
- require(connectedAccounts[_account] == address(0x0), "already connected");
374
- //signature ensures the whitelisted (msg.sender) has submited a signature by connected account
375
- //that connects both accounts
376
- require(
377
- SignatureChecker.isValidSignatureNow(
378
- _account,
379
- keccak256(abi.encode(msg.sender, _account)),
380
- signature
381
- ),
382
- "invalid signature"
383
- );
384
- connectedAccounts[_account] = msg.sender;
385
- }
386
-
387
- function getWhitelistedRoot(address _account)
388
- external
389
- view
390
- returns (address whitelisted)
391
- {
392
- if (isWhitelisted(_account)) return _account;
393
- if (isWhitelisted(connectedAccounts[_account]))
394
- return connectedAccounts[_account];
395
-
396
- return address(0x0);
397
- }
398
-
399
- function pause(bool _toPause) external onlyRole(PAUSER_ROLE) {
400
- if (_toPause) _pause();
401
- else _unpause();
402
- }
403
-
404
- function setDID(string calldata did) external onlyWhitelisted {
405
- bytes32 pHash = keccak256(bytes(did));
406
- require(didHashToAddress[pHash] == address(0), "DID already registered");
407
-
408
- bytes32 oldHash = keccak256(bytes(identities[msg.sender].did));
409
- delete didHashToAddress[oldHash];
410
- identities[msg.sender].did = did;
411
- didHashToAddress[pHash] = msg.sender;
412
- }
413
-
414
- function addrToDID(address account)
415
- external
416
- view
417
- returns (string memory did)
418
- {
419
- did = identities[msg.sender].did;
420
- if (bytes(did).length > 0) return did;
421
- try oldIdentity.addrToDID(account) returns (string memory _did) {
422
- return _did;
423
- } catch {
424
- return "";
425
- }
426
- }
427
-
428
- /**
429
- * compatability with IdentityV1 that GoodDollar token checks if the identity contract is registered
430
- */
431
- function isRegistered() external pure returns (bool) {
432
- return true;
433
- }
434
- }