@gooddollar/goodprotocol 1.0.29-beta.3 → 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.
- package/artifacts/abis/AdminWallet.min.json +1 -1
- package/artifacts/abis/GoodDollarMintBurnWrapper.min.json +1 -1
- package/artifacts/abis/GoodDollarStaking.min.json +1 -1
- package/artifacts/abis/GoodDollarStakingMock.min.json +1 -1
- package/artifacts/abis/IGoodDollar.min.json +1 -1
- package/artifacts/abis/IIdentity.min.json +1 -1
- package/artifacts/abis/UBIScheme.min.json +1 -1
- package/artifacts/contracts/DAOStackInterfaces.sol/Avatar.dbg.json +1 -1
- package/artifacts/contracts/DAOStackInterfaces.sol/Controller.dbg.json +1 -1
- package/artifacts/contracts/DAOStackInterfaces.sol/GlobalConstraintInterface.dbg.json +1 -1
- package/artifacts/contracts/DAOStackInterfaces.sol/IntVoteInterface.dbg.json +1 -1
- package/artifacts/contracts/DAOStackInterfaces.sol/ReputationInterface.dbg.json +1 -1
- package/artifacts/contracts/DAOStackInterfaces.sol/SchemeRegistrar.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/AggregatorV3Interface.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/ERC20.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IAaveIncentivesController.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IAdminWallet.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IDonationStaking.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IERC2917.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IFirstClaimPool.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IGoodDollar.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IGoodDollar.json +0 -39
- package/artifacts/contracts/Interfaces.sol/IGoodStaking.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IHasRouter.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IIdentity.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IIdentity.json +0 -51
- package/artifacts/contracts/Interfaces.sol/ILendingPool.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IMultichainRouter.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/INameService.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IUBIScheme.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/ProxyAdmin.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/Reserve.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/Staking.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/Uniswap.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/UniswapFactory.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/UniswapPair.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/cERC20.dbg.json +1 -1
- package/artifacts/contracts/fuseFaucet/FuseFaucet.sol/FuseFaucet.dbg.json +1 -1
- package/artifacts/contracts/fuseFaucet/FuseFaucet.sol/FuseFaucet.json +2 -2
- package/artifacts/contracts/governance/ClaimersDistribution.sol/ClaimersDistribution.dbg.json +1 -1
- package/artifacts/contracts/governance/ClaimersDistribution.sol/ClaimersDistribution.json +2 -2
- package/artifacts/contracts/governance/CompoundVotingMachine.sol/CompoundVotingMachine.dbg.json +1 -1
- package/artifacts/contracts/governance/CompoundVotingMachine.sol/CompoundVotingMachine.json +2 -2
- package/artifacts/contracts/governance/GReputation.sol/GReputation.dbg.json +1 -1
- package/artifacts/contracts/governance/GReputation.sol/GReputation.json +2 -2
- package/artifacts/contracts/governance/GoodDollarStaking.sol/GoodDollarStaking.dbg.json +1 -1
- package/artifacts/contracts/governance/GoodDollarStaking.sol/GoodDollarStaking.json +2 -15
- package/artifacts/contracts/governance/GoodDollarStaking.sol/RewardsMinter.dbg.json +1 -1
- package/artifacts/contracts/governance/GovernanceStaking.sol/GovernanceStaking.dbg.json +1 -1
- package/artifacts/contracts/governance/GovernanceStaking.sol/GovernanceStaking.json +2 -2
- package/artifacts/contracts/governance/MultiBaseGovernanceShareField.sol/MultiBaseGovernanceShareField.dbg.json +1 -1
- package/artifacts/contracts/governance/Reputation.sol/Reputation.dbg.json +1 -1
- package/artifacts/contracts/governance/Reputation.sol/Reputation.json +2 -2
- package/artifacts/contracts/governance/StakersDistribution.sol/StakersDistribution.dbg.json +1 -1
- package/artifacts/contracts/governance/StakersDistribution.sol/StakersDistribution.json +2 -2
- package/artifacts/contracts/invite/InvitesV1.sol/InvitesV1.dbg.json +1 -1
- package/artifacts/contracts/invite/InvitesV1.sol/InvitesV1.json +2 -2
- package/artifacts/contracts/mocks/AaveMock.sol/AaveMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/DAIMock.sol/DAIMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/DecimalsMock.sol/DecimalsMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/DistributionBridgeMock.sol/DistributionBridgeMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/DistributionBridgeMock.sol/DistributionBridgeMock.json +2 -2
- package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTest.dbg.json +1 -1
- package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTest.json +2 -2
- package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTestHelper.dbg.json +1 -1
- package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTestHelper.json +2 -2
- package/artifacts/contracts/mocks/GoodCompoundStakingTest.sol/GoodCompoundStakingTest.dbg.json +1 -1
- package/artifacts/contracts/mocks/GoodCompoundStakingTest.sol/GoodCompoundStakingTest.json +2 -2
- package/artifacts/contracts/mocks/GoodDollarStakingMock.sol/GoodDollarStakingMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/GoodDollarStakingMock.sol/GoodDollarStakingMock.json +2 -15
- package/artifacts/contracts/mocks/GoodFundManagerTest.sol/GoodFundManagerTest.dbg.json +1 -1
- package/artifacts/contracts/mocks/GoodFundManagerTest.sol/GoodFundManagerTest.json +2 -2
- package/artifacts/contracts/mocks/IncentiveControllerMock.sol/IncentiveControllerMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/LendingPoolMock.sol/LendingPoolMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/MultichainRouterMock.sol/IWrapper.dbg.json +1 -1
- package/artifacts/contracts/mocks/MultichainRouterMock.sol/MultichainRouterMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/MultichainRouterMock.sol/MultichainRouterMock.json +2 -2
- package/artifacts/contracts/mocks/OverMintTester.sol/IGoodDollarStakingTest.dbg.json +1 -1
- package/artifacts/contracts/mocks/OverMintTester.sol/OverMintTester.dbg.json +1 -1
- package/artifacts/contracts/mocks/OverMintTester.sol/OverMintTester.json +2 -2
- package/artifacts/contracts/mocks/OverMintTesterRegularStake.sol/OverMintTesterRegularStake.dbg.json +1 -1
- package/artifacts/contracts/mocks/OverMintTesterRegularStake.sol/OverMintTesterRegularStake.json +2 -2
- package/artifacts/contracts/mocks/SixteenDecimalsTokenMock.sol/SixteenDecimalsTokenMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/StakingMockFixedAPY.sol/StakingMockFixedAPY.dbg.json +1 -1
- package/artifacts/contracts/mocks/SwapHelperTest.sol/SwapHelperTest.dbg.json +1 -1
- package/artifacts/contracts/mocks/SwapHelperTest.sol/SwapHelperTest.json +2 -2
- package/artifacts/contracts/mocks/TwentyDecimalsTokenMock.sol/TwentyDecimalsTokenMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock.json +2 -2
- package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock2.dbg.json +1 -1
- package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock2.json +2 -2
- package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock3.dbg.json +1 -1
- package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock3.json +2 -2
- package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock4.dbg.json +1 -1
- package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock4.json +2 -2
- package/artifacts/contracts/mocks/UsdcMock.sol/USDCMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cBATMock.sol/cBATMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cDAILowWorthMock.sol/cDAILowWorthMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cDAIMock.sol/cDAIMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cDAINonMintableMock.sol/cDAINonMintableMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cDecimalsMock.sol/cDecimalsMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cSDTMock.sol/cSDTMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cUSDCMock.sol/cUSDCMock.dbg.json +1 -1
- package/artifacts/contracts/reserve/DistributionHelper.sol/DistributionHelper.dbg.json +1 -1
- package/artifacts/contracts/reserve/DistributionHelper.sol/DistributionHelper.json +2 -2
- package/artifacts/contracts/reserve/ExchangeHelper.sol/ExchangeHelper.dbg.json +1 -1
- package/artifacts/contracts/reserve/ExchangeHelper.sol/ExchangeHelper.json +2 -2
- package/artifacts/contracts/reserve/GoodMarketMaker.sol/GoodMarketMaker.dbg.json +1 -1
- package/artifacts/contracts/reserve/GoodMarketMaker.sol/GoodMarketMaker.json +2 -2
- package/artifacts/contracts/reserve/GoodReserveCDai.sol/ContributionCalc.dbg.json +1 -1
- package/artifacts/contracts/reserve/GoodReserveCDai.sol/GoodReserveCDai.dbg.json +1 -1
- package/artifacts/contracts/reserve/GoodReserveCDai.sol/GoodReserveCDai.json +2 -2
- package/artifacts/contracts/staking/BaseShareField.sol/BaseShareField.dbg.json +1 -1
- package/artifacts/contracts/staking/BaseShareField.sol/BaseShareField.json +2 -2
- package/artifacts/contracts/staking/BaseShareFieldV2.sol/BaseShareFieldV2.dbg.json +1 -1
- package/artifacts/contracts/staking/BaseShareFieldV2.sol/BaseShareFieldV2.json +2 -2
- package/artifacts/contracts/staking/DonationsStaking.sol/DonationsStaking.dbg.json +1 -1
- package/artifacts/contracts/staking/DonationsStaking.sol/DonationsStaking.json +2 -2
- package/artifacts/contracts/staking/FuseStakingV3.sol/FuseStakingV3.dbg.json +1 -1
- package/artifacts/contracts/staking/FuseStakingV3.sol/FuseStakingV3.json +2 -2
- package/artifacts/contracts/staking/FuseStakingV3.sol/IConsensus.dbg.json +1 -1
- package/artifacts/contracts/staking/FuseStakingV3.sol/PegSwap.dbg.json +1 -1
- package/artifacts/contracts/staking/GoodFundManager.sol/GoodFundManager.dbg.json +1 -1
- package/artifacts/contracts/staking/GoodFundManager.sol/GoodFundManager.json +2 -2
- package/artifacts/contracts/staking/SimpleStaking.sol/SimpleStaking.dbg.json +1 -1
- package/artifacts/contracts/staking/SimpleStakingV2.sol/SimpleStakingV2.dbg.json +1 -1
- package/artifacts/contracts/staking/UniswapV2SwapHelper.sol/UniswapV2SwapHelper.dbg.json +1 -1
- package/artifacts/contracts/staking/UniswapV2SwapHelper.sol/UniswapV2SwapHelper.json +2 -2
- package/artifacts/contracts/staking/aave/AaveStakingFactory.sol/AaveStakingFactory.dbg.json +1 -1
- package/artifacts/contracts/staking/aave/AaveStakingFactory.sol/AaveStakingFactory.json +2 -2
- package/artifacts/contracts/staking/aave/GoodAaveStaking.sol/GoodAaveStaking.dbg.json +1 -1
- package/artifacts/contracts/staking/aave/GoodAaveStaking.sol/GoodAaveStaking.json +2 -2
- package/artifacts/contracts/staking/aave/GoodAaveStakingV2.sol/GoodAaveStakingV2.dbg.json +1 -1
- package/artifacts/contracts/staking/aave/GoodAaveStakingV2.sol/GoodAaveStakingV2.json +2 -2
- package/artifacts/contracts/staking/compound/CompoundStakingFactory.sol/CompoundStakingFactory.dbg.json +1 -1
- package/artifacts/contracts/staking/compound/CompoundStakingFactory.sol/CompoundStakingFactory.json +2 -2
- package/artifacts/contracts/staking/compound/GoodCompoundStaking.sol/GoodCompoundStaking.dbg.json +1 -1
- package/artifacts/contracts/staking/compound/GoodCompoundStaking.sol/GoodCompoundStaking.json +2 -2
- package/artifacts/contracts/staking/compound/GoodCompoundStakingV2.sol/GoodCompoundStakingV2.dbg.json +1 -1
- package/artifacts/contracts/staking/compound/GoodCompoundStakingV2.sol/GoodCompoundStakingV2.json +2 -2
- package/artifacts/contracts/staking/utils/Math64X64.sol/Math64x64.dbg.json +1 -1
- package/artifacts/contracts/staking/utils/StakingRewardsFixedAPY.sol/StakingRewardsFixedAPY.dbg.json +1 -1
- package/artifacts/contracts/ubi/UBIScheme.sol/UBIScheme.dbg.json +1 -1
- package/artifacts/contracts/ubi/UBIScheme.sol/UBIScheme.json +22 -15
- package/artifacts/contracts/utils/AdminWallet.sol/AdminWallet.dbg.json +1 -1
- package/artifacts/contracts/utils/AdminWallet.sol/AdminWallet.json +56 -76
- package/artifacts/contracts/utils/BancorFormula.sol/BancorFormula.dbg.json +1 -1
- package/artifacts/contracts/utils/BulkProof.sol/BulkProof.dbg.json +1 -1
- package/artifacts/contracts/utils/BulkProof.sol/BulkProof.json +2 -2
- package/artifacts/contracts/utils/DAOContract.sol/DAOContract.dbg.json +1 -1
- package/artifacts/contracts/utils/DAOContract.sol/DAOContract.json +2 -2
- package/artifacts/contracts/utils/DAOUpgradeableContract.sol/DAOUpgradeableContract.dbg.json +1 -1
- package/artifacts/contracts/utils/DAOUpgradeableContract.sol/DAOUpgradeableContract.json +2 -2
- package/artifacts/contracts/utils/DSMath.sol/DSMath.dbg.json +1 -1
- package/artifacts/contracts/utils/DataTypes.sol/DataTypes.dbg.json +1 -1
- package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/GoodDollarMintBurnWrapper.dbg.json +1 -1
- package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/GoodDollarMintBurnWrapper.json +2 -16
- package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/IRouter.dbg.json +1 -1
- package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/PausableControl.dbg.json +1 -1
- package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/TokenOperation.dbg.json +1 -1
- package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/TokenOperation.json +2 -2
- package/artifacts/contracts/utils/MultichainBridgeHelper.sol/MultichainBridgeHelper.dbg.json +1 -1
- package/artifacts/contracts/utils/MultichainBridgeHelper.sol/MultichainBridgeHelper.json +2 -2
- package/artifacts/contracts/utils/NameService.sol/NameService.dbg.json +1 -1
- package/artifacts/contracts/utils/ProtocolUpgrade.sol/OldMarketMaker.dbg.json +1 -1
- package/artifacts/contracts/utils/ProtocolUpgrade.sol/ProtocolUpgrade.dbg.json +1 -1
- package/artifacts/contracts/utils/ProtocolUpgrade.sol/ProtocolUpgrade.json +2 -2
- package/artifacts/contracts/utils/ProtocolUpgradeFuse.sol/ProtocolUpgradeFuse.dbg.json +1 -1
- package/artifacts/contracts/utils/ProtocolUpgradeFuse.sol/ProtocolUpgradeFuse.json +2 -2
- package/artifacts/contracts/utils/ProtocolUpgradeFuseRecover.sol/ProtocolUpgradeFuseRecover.dbg.json +1 -1
- package/artifacts/contracts/utils/ProtocolUpgradeFuseRecover.sol/ProtocolUpgradeFuseRecover.json +2 -2
- package/artifacts/contracts/utils/ProtocolUpgradeRecover.sol/ProtocolUpgradeRecover.dbg.json +1 -1
- package/artifacts/contracts/utils/ProtocolUpgradeRecover.sol/ProtocolUpgradeRecover.json +2 -2
- package/artifacts/contracts/utils/ProxyFactory1967.sol/ERC1967Proxy.dbg.json +1 -1
- package/artifacts/contracts/utils/ProxyFactory1967.sol/ProxyFactory1967.dbg.json +1 -1
- package/artifacts/contracts/utils/ReputationTestHelper.sol/ReputationTestHelper.dbg.json +1 -1
- package/artifacts/contracts/utils/ReputationTestHelper.sol/ReputationTestHelper.json +2 -2
- package/contracts/Interfaces.sol +0 -26
- package/contracts/governance/GoodDollarStaking.sol +9 -23
- package/contracts/ubi/UBIScheme.sol +40 -45
- package/contracts/utils/AdminWallet.sol +11 -42
- package/contracts/utils/GoodDollarMintBurnWrapper.sol +3 -13
- package/hardhat.config.ts +7 -21
- package/package.json +2 -3
- package/releases/deploy-settings.json +1 -36
- package/releases/deployment.json +53 -94
- package/scripts/analytics/gdinflow.ts +56 -0
- package/scripts/analytics/tokenInOutStats.ts +50 -0
- package/scripts/deployFullDAO.ts +19 -39
- package/scripts/multichain-deploy/{1_basicdao-deploy.ts → basicdao-deploy.ts} +52 -56
- package/scripts/multichain-deploy/{3_gdSavings-deploy.ts → gdSavings-deploy.ts} +76 -90
- package/scripts/multichain-deploy/helpers.ts +1 -0
- package/scripts/{upgrades → multichain-deploy}/nonubiDistribution-deploy.ts +5 -2
- package/scripts/test/localOldDaoDeploy.ts +3 -10
- package/test/helpers.ts +8 -12
- package/test/ubi/UBIScheme.test.ts +30 -30
- package/test/ubi/UBISchemeCycle.test.ts +7 -9
- package/test/utils/AdminWallet.test.ts +11 -33
- package/types/AdminWallet.ts +113 -124
- package/types/GoodDollarMintBurnWrapper.ts +0 -42
- package/types/GoodDollarStaking.ts +0 -34
- package/types/GoodDollarStakingMock.ts +0 -34
- package/types/IGoodDollar.ts +0 -54
- package/types/IIdentity.ts +0 -75
- package/types/UBIScheme.ts +40 -19
- package/types/factories/AaveStakingFactory__factory.ts +1 -1
- package/types/factories/AdminWallet__factory.ts +55 -75
- package/types/factories/BaseShareFieldV2__factory.ts +1 -1
- package/types/factories/BaseShareField__factory.ts +1 -1
- package/types/factories/ClaimersDistribution__factory.ts +1 -1
- package/types/factories/CompoundStakingFactory__factory.ts +1 -1
- package/types/factories/CompoundVotingMachine__factory.ts +1 -1
- package/types/factories/DAOContract__factory.ts +1 -1
- package/types/factories/DAOUpgradeableContract__factory.ts +1 -1
- package/types/factories/DistributionBridgeMock__factory.ts +1 -1
- package/types/factories/DistributionHelperTestHelper__factory.ts +1 -1
- package/types/factories/DistributionHelperTest__factory.ts +1 -1
- package/types/factories/DistributionHelper__factory.ts +1 -1
- package/types/factories/DonationsStaking__factory.ts +1 -1
- package/types/factories/ExchangeHelper__factory.ts +1 -1
- package/types/factories/FuseFaucet__factory.ts +1 -1
- package/types/factories/FuseStakingV3__factory.ts +1 -1
- package/types/factories/GReputation__factory.ts +1 -1
- package/types/factories/GoodAaveStakingV2__factory.ts +1 -1
- package/types/factories/GoodAaveStaking__factory.ts +1 -1
- package/types/factories/GoodCompoundStakingTest__factory.ts +1 -1
- package/types/factories/GoodCompoundStakingV2__factory.ts +1 -1
- package/types/factories/GoodCompoundStaking__factory.ts +1 -1
- package/types/factories/GoodDollarMintBurnWrapper__factory.ts +1 -15
- package/types/factories/GoodDollarStakingMock__factory.ts +1 -14
- package/types/factories/GoodDollarStaking__factory.ts +1 -14
- package/types/factories/GoodFundManagerTest__factory.ts +1 -1
- package/types/factories/GoodFundManager__factory.ts +1 -1
- package/types/factories/GoodMarketMaker__factory.ts +1 -1
- package/types/factories/GoodReserveCDai__factory.ts +1 -1
- package/types/factories/GovernanceStaking__factory.ts +1 -1
- package/types/factories/IGoodDollar__factory.ts +0 -39
- package/types/factories/IIdentity__factory.ts +0 -51
- package/types/factories/InvitesV1__factory.ts +1 -1
- package/types/factories/MultichainBridgeHelper__factory.ts +1 -1
- package/types/factories/MultichainRouterMock__factory.ts +1 -1
- package/types/factories/OverMintTesterRegularStake__factory.ts +1 -1
- package/types/factories/OverMintTester__factory.ts +1 -1
- package/types/factories/ProtocolUpgradeFuseRecover__factory.ts +1 -1
- package/types/factories/ProtocolUpgradeFuse__factory.ts +1 -1
- package/types/factories/ProtocolUpgradeRecover__factory.ts +1 -1
- package/types/factories/ProtocolUpgrade__factory.ts +1 -1
- package/types/factories/ReputationTestHelper__factory.ts +1 -1
- package/types/factories/Reputation__factory.ts +1 -1
- package/types/factories/StakersDistribution__factory.ts +1 -1
- package/types/factories/SwapHelperTest__factory.ts +1 -1
- package/types/factories/UBIScheme__factory.ts +21 -14
- package/types/factories/UniswapV2SwapHelper__factory.ts +1 -1
- package/types/factories/UpgradableMock2__factory.ts +1 -1
- package/types/factories/UpgradableMock3__factory.ts +1 -1
- package/types/factories/UpgradableMock4__factory.ts +1 -1
- package/types/factories/UpgradableMock__factory.ts +1 -1
- package/types/hardhat.d.ts +0 -54
- package/types/index.ts +0 -12
- package/yarn.lock +4 -4
- package/artifacts/abis/Faucet.min.json +0 -1
- package/artifacts/abis/IGovernanceStaking.min.json +0 -1
- package/artifacts/abis/IIdentityV2.min.json +0 -1
- package/artifacts/abis/IdentityV2.min.json +0 -1
- package/artifacts/abis/InvitesV2.min.json +0 -1
- package/artifacts/contracts/Interfaces.sol/IIdentityV2.dbg.json +0 -4
- package/artifacts/contracts/Interfaces.sol/IIdentityV2.json +0 -281
- package/artifacts/contracts/fuseFaucet/Faucet.sol/Faucet.dbg.json +0 -4
- package/artifacts/contracts/fuseFaucet/Faucet.sol/Faucet.json +0 -684
- package/artifacts/contracts/governance/GoodDollarStaking.sol/IGovernanceStaking.dbg.json +0 -4
- package/artifacts/contracts/governance/GoodDollarStaking.sol/IGovernanceStaking.json +0 -24
- package/artifacts/contracts/identity/IdentityV2.sol/IdentityV2.dbg.json +0 -4
- package/artifacts/contracts/identity/IdentityV2.sol/IdentityV2.json +0 -1000
- package/artifacts/contracts/invite/InvitesV2.sol/InvitesV2.dbg.json +0 -4
- package/artifacts/contracts/invite/InvitesV2.sol/InvitesV2.json +0 -586
- package/contracts/fuseFaucet/Faucet.sol +0 -245
- package/contracts/identity/IdentityV2.sol +0 -434
- package/contracts/invite/InvitesV2.sol +0 -316
- package/scripts/multichain-deploy/0_proxyFactory-deploy.ts +0 -45
- package/scripts/multichain-deploy/2_helpers-deploy.ts +0 -143
- package/scripts/multichain-deploy/4_ubi-deploy.ts +0 -121
- package/scripts/multichain-deploy/5_gov-deploy.ts +0 -123
- package/scripts/multichain-deploy/verifyEtherscan.ts +0 -84
- package/scripts/upgrades/identity-upgrade.ts +0 -153
- package/types/Faucet.ts +0 -1014
- package/types/IERC1271.ts +0 -109
- package/types/IGovernanceStaking.ts +0 -98
- package/types/IIdentityV2.ts +0 -526
- package/types/IdentityV2.ts +0 -1612
- package/types/InvitesV2.ts +0 -933
- package/types/factories/Faucet__factory.ts +0 -729
- package/types/factories/IERC1271__factory.ts +0 -47
- package/types/factories/IGovernanceStaking__factory.ts +0 -39
- package/types/factories/IIdentityV2__factory.ts +0 -293
- package/types/factories/IdentityV2__factory.ts +0 -1048
- package/types/factories/InvitesV2__factory.ts +0 -634
|
@@ -1,245 +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
|
-
address whitelistedRoot = getIdentity().getWhitelistedRoot(_user);
|
|
159
|
-
_user = whitelistedRoot == address(0) ? _user : whitelistedRoot;
|
|
160
|
-
|
|
161
|
-
uint256 _currentDay = (block.timestamp - startTime) / 1 days;
|
|
162
|
-
bool can = (wallets[_user].lastDayTopped != uint128(_currentDay) ||
|
|
163
|
-
wallets[_user].dailyToppingCount < 3) &&
|
|
164
|
-
((notFirstTime[_user] == false &&
|
|
165
|
-
dailyNewWalletsCount < maxDailyNewWallets) ||
|
|
166
|
-
whitelistedRoot != address(0));
|
|
167
|
-
|
|
168
|
-
uint128[7] memory lastWeekToppings = wallets[_user].lastWeekToppings;
|
|
169
|
-
//reset inactive days
|
|
170
|
-
uint256 dayOfWeek = _currentDay % 7;
|
|
171
|
-
uint256 dayDiff = (_currentDay - wallets[_user].lastDayTopped);
|
|
172
|
-
dayDiff = dayDiff > 7 ? 7 : dayDiff;
|
|
173
|
-
dayDiff = dayDiff > dayOfWeek ? dayOfWeek + 1 : dayDiff;
|
|
174
|
-
|
|
175
|
-
for (uint256 day = dayOfWeek + 1 - dayDiff; day <= dayOfWeek; day++) {
|
|
176
|
-
lastWeekToppings[day] = 0;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
uint128 weekTotal = 0;
|
|
180
|
-
for (uint256 i = 0; i <= dayOfWeek; i++) {
|
|
181
|
-
weekTotal += lastWeekToppings[uint256(i)];
|
|
182
|
-
}
|
|
183
|
-
can = can && weekTotal < perDayRoughLimit * maxPerWeekMultiplier;
|
|
184
|
-
return can;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/* @dev Function to top given address with amount of G$ given in constructor
|
|
188
|
-
* can only be done by admin the amount of times specified in constructor per day
|
|
189
|
-
* @param _user The address to transfer to
|
|
190
|
-
*/
|
|
191
|
-
function topWallet(address payable _user)
|
|
192
|
-
public
|
|
193
|
-
reimburseGas
|
|
194
|
-
toppingLimit(_user)
|
|
195
|
-
onlyAuthorized(_user)
|
|
196
|
-
{
|
|
197
|
-
_topWallet(_user);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
function _topWallet(address payable _wallet) internal {
|
|
201
|
-
address payable target = _wallet;
|
|
202
|
-
|
|
203
|
-
//switch wallet to the account we do the accounting for
|
|
204
|
-
address whitelistedRoot = getIdentity().getWhitelistedRoot(_wallet);
|
|
205
|
-
_wallet = whitelistedRoot == address(0)
|
|
206
|
-
? _wallet
|
|
207
|
-
: payable(whitelistedRoot);
|
|
208
|
-
|
|
209
|
-
require(toppingAmount > address(_wallet).balance);
|
|
210
|
-
uint256 toTop = toppingAmount - address(_wallet).balance;
|
|
211
|
-
|
|
212
|
-
uint256 dayOfWeek = currentDay % 7;
|
|
213
|
-
|
|
214
|
-
if (wallets[_wallet].lastDayTopped == uint128(currentDay))
|
|
215
|
-
wallets[_wallet].dailyToppingCount += 1;
|
|
216
|
-
else wallets[_wallet].dailyToppingCount = 1;
|
|
217
|
-
wallets[_wallet].lastDayTopped = uint128(currentDay);
|
|
218
|
-
wallets[_wallet].lastWeekToppings[dayOfWeek] += uint128(toTop);
|
|
219
|
-
|
|
220
|
-
if (notFirstTime[_wallet] == false && whitelistedRoot == address(0)) {
|
|
221
|
-
dailyNewWalletsCount++;
|
|
222
|
-
}
|
|
223
|
-
notFirstTime[_wallet] = true;
|
|
224
|
-
|
|
225
|
-
target.transfer(toTop);
|
|
226
|
-
emit WalletTopped(target, toTop, whitelistedRoot, msg.sender);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
function onTokenTransfer(
|
|
230
|
-
address payable _from,
|
|
231
|
-
uint256 amount,
|
|
232
|
-
bytes calldata data
|
|
233
|
-
) external returns (bool) {
|
|
234
|
-
require(amount <= maxSwapAmount, "slippage");
|
|
235
|
-
address uniswapLike = abi.decode(data, (address));
|
|
236
|
-
Uniswap uniswap = Uniswap(uniswapLike);
|
|
237
|
-
address[] memory path = new address[](2);
|
|
238
|
-
path[0] = address(msg.sender);
|
|
239
|
-
path[1] = uniswap.WETH();
|
|
240
|
-
|
|
241
|
-
cERC20(msg.sender).approve(address(uniswapLike), type(uint256).max);
|
|
242
|
-
uniswap.swapExactTokensForETH(amount, 0, path, _from, block.timestamp);
|
|
243
|
-
return true;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
@@ -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
|
-
}
|