@gooddollar/goodprotocol 2.1.4 → 2.2.0-beta.1
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/IdentityV4.min.json +1 -0
- 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/IUniswapV3.sol/INonfungiblePositionManager.dbg.json +1 -1
- package/artifacts/contracts/IUniswapV3.sol/IUniswapV3Pool.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/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/IIdentityV2.dbg.json +1 -1
- 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/IQuoterV2.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/ISwapRouter.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/MentoInterfaces.sol/IBancorExchangeProvider.dbg.json +1 -1
- package/artifacts/contracts/MentoInterfaces.sol/IBroker.dbg.json +1 -1
- package/artifacts/contracts/MentoInterfaces.sol/IGoodDollarExchangeProvider.dbg.json +1 -1
- package/artifacts/contracts/MentoInterfaces.sol/IGoodDollarExpansionController.dbg.json +1 -1
- package/artifacts/contracts/MentoInterfaces.sol/IMentoReserve.dbg.json +1 -1
- package/artifacts/contracts/MentoInterfaces.sol/ITradingLimits.dbg.json +1 -1
- package/artifacts/contracts/fuseFaucet/Faucet.sol/Faucet.dbg.json +1 -1
- package/artifacts/contracts/fuseFaucet/FuseFaucet.sol/FuseFaucet.dbg.json +1 -1
- package/artifacts/contracts/fuseFaucet/FuseFaucetV2.sol/FuseFaucetV2.dbg.json +1 -1
- package/artifacts/contracts/fuseFaucet/SuperfluidFacuet.sol/SuperfluidFaucet.dbg.json +1 -1
- package/artifacts/contracts/governance/ClaimersDistribution.sol/ClaimersDistribution.dbg.json +1 -1
- package/artifacts/contracts/governance/CompoundVotingMachine.sol/CompoundVotingMachine.dbg.json +1 -1
- package/artifacts/contracts/governance/GReputation.sol/GReputation.dbg.json +1 -1
- package/artifacts/contracts/governance/GovernanceStaking.sol/GovernanceStaking.dbg.json +1 -1
- 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/StakersDistribution.sol/StakersDistribution.dbg.json +1 -1
- package/artifacts/contracts/identity/IdentityV2.sol/IdentityV2.dbg.json +1 -1
- package/artifacts/contracts/identity/IdentityV3.sol/IdentityV3.dbg.json +1 -1
- package/artifacts/contracts/identity/IdentityV3.sol/IdentityV3.json +2 -2
- package/artifacts/contracts/identity/IdentityV4.sol/IdentityV4.dbg.json +4 -0
- package/artifacts/contracts/identity/IdentityV4.sol/IdentityV4.json +1162 -0
- package/artifacts/contracts/invite/InvitesFuseV2.sol/InvitesFuseV2.dbg.json +1 -1
- package/artifacts/contracts/invite/InvitesV1.sol/InvitesV1.dbg.json +1 -1
- package/artifacts/contracts/invite/InvitesV2.sol/InvitesV2.dbg.json +1 -1
- package/artifacts/contracts/invite/OneTimeReward.sol/OneTimeReward.dbg.json +1 -1
- package/artifacts/contracts/mocks/AaveMock.sol/AaveMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/AaveUSDMockOracle.sol/AaveUSDMockOracle.dbg.json +1 -1
- package/artifacts/contracts/mocks/BatUSDMockOracle.sol/BatUSDMockOracle.dbg.json +1 -1
- package/artifacts/contracts/mocks/CeloDistributionHelperTest.sol/CeloDistributionHelperTest.dbg.json +1 -1
- package/artifacts/contracts/mocks/CeloDistributionHelperTest.sol/CeloDistributionHelperTestHelper.dbg.json +1 -1
- package/artifacts/contracts/mocks/CompUsdMockOracle.sol/CompUSDMockOracle.dbg.json +1 -1
- package/artifacts/contracts/mocks/DAIMock.sol/DAIMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/DaiEthPriceMockOracle.sol/DaiEthPriceMockOracle.dbg.json +1 -1
- package/artifacts/contracts/mocks/DecimalsMock.sol/DecimalsMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTest.dbg.json +1 -1
- package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTestHelper.dbg.json +1 -1
- package/artifacts/contracts/mocks/EthUSDMockOracle.sol/EthUSDMockOracle.dbg.json +1 -1
- package/artifacts/contracts/mocks/FeesFormularMock.sol/FeesFormulaMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/GasPriceMockOracle.sol/GasPriceMockOracle.dbg.json +1 -1
- package/artifacts/contracts/mocks/GenericDistributionHelperTest.sol/GenericDistributionHelperTest.dbg.json +1 -1
- package/artifacts/contracts/mocks/GenericDistributionHelperTest.sol/GenericDistributionHelperTestHelper.dbg.json +1 -1
- package/artifacts/contracts/mocks/GoodCompoundStakingTest.sol/GoodCompoundStakingTest.dbg.json +1 -1
- package/artifacts/contracts/mocks/GoodFundManagerTest.sol/GoodFundManagerTest.dbg.json +1 -1
- package/artifacts/contracts/mocks/IdentityMock.sol/IdentityMock.dbg.json +1 -1
- 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/OverMintTester.sol/IGoodDollarStakingTest.dbg.json +1 -1
- package/artifacts/contracts/mocks/OverMintTester.sol/OverMintTester.dbg.json +1 -1
- package/artifacts/contracts/mocks/OverMintTesterRegularStake.sol/OverMintTesterRegularStake.dbg.json +1 -1
- package/artifacts/contracts/mocks/PayableMock.sol/PayableMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/SixteenDecimalsTokenMock.sol/SixteenDecimalsTokenMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/SwapHelperTest.sol/SwapHelperTest.dbg.json +1 -1
- 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/UpgradableMock2.dbg.json +1 -1
- package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock3.dbg.json +1 -1
- package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock4.dbg.json +1 -1
- 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/CeloDistributionHelper.sol/CeloDistributionHelper.dbg.json +1 -1
- package/artifacts/contracts/reserve/DistributionHelper.sol/DistributionHelper.dbg.json +1 -1
- package/artifacts/contracts/reserve/ExchangeHelper.sol/ExchangeHelper.dbg.json +1 -1
- package/artifacts/contracts/reserve/GenericDistributionHelper.sol/GenericDistributionHelper.dbg.json +1 -1
- package/artifacts/contracts/reserve/GoodMarketMaker.sol/GoodMarketMaker.dbg.json +1 -1
- 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/staking/BaseShareField.sol/BaseShareField.dbg.json +1 -1
- package/artifacts/contracts/staking/BaseShareFieldV2.sol/BaseShareFieldV2.dbg.json +1 -1
- package/artifacts/contracts/staking/DonationsStaking.sol/DonationsStaking.dbg.json +1 -1
- package/artifacts/contracts/staking/FuseStakingV3.sol/FuseStakingV3.dbg.json +1 -1
- 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/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/aave/AaveStakingFactory.sol/AaveStakingFactory.dbg.json +1 -1
- package/artifacts/contracts/staking/aave/GoodAaveStaking.sol/GoodAaveStaking.dbg.json +1 -1
- package/artifacts/contracts/staking/aave/GoodAaveStakingV2.sol/GoodAaveStakingV2.dbg.json +1 -1
- package/artifacts/contracts/staking/compound/CompoundStakingFactory.sol/CompoundStakingFactory.dbg.json +1 -1
- package/artifacts/contracts/staking/compound/GoodCompoundStaking.sol/GoodCompoundStaking.dbg.json +1 -1
- package/artifacts/contracts/staking/compound/GoodCompoundStakingV2.sol/GoodCompoundStakingV2.dbg.json +1 -1
- package/artifacts/contracts/staking/utils/Math64X64.sol/Math64x64.dbg.json +1 -1
- package/artifacts/contracts/token/ERC20PresetMinterPauserUpgradeable.sol/ERC20PresetMinterPauserUpgradeable.dbg.json +1 -1
- package/artifacts/contracts/token/ERC677.sol/ERC677.dbg.json +1 -1
- package/artifacts/contracts/token/ERC677.sol/ERC677Receiver.dbg.json +1 -1
- package/artifacts/contracts/token/GoodDollar.sol/GoodDollar.dbg.json +1 -1
- package/artifacts/contracts/token/GoodDollar2.sol/GoodDollar2.dbg.json +1 -1
- package/artifacts/contracts/token/IFeesFormula.sol/IFeesFormula.dbg.json +1 -1
- package/artifacts/contracts/token/MultichainFeeFormula.sol/MultichainFeeFormula.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/ERC20Permit.sol/ERC20Permit.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/ERC20Permit.sol/SelfApprove.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/ISuperGoodDollar.sol/IGoodDollarCustom.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/ISuperGoodDollar.sol/ISuperGoodDollar.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/ISuperToken.sol/ISuperToken.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/SuperGoodDollar.sol/SuperGoodDollar.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/SuperToken.sol/SuperToken.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/SuperfluidToken.sol/SuperfluidToken.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/UUPSProxiable.sol/UUPSProxiable.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/UUPSProxy.sol/Proxy.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/UUPSProxy.sol/UUPSProxy.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/UUPSProxy.sol/UUPSUtils.dbg.json +1 -1
- package/artifacts/contracts/ubi/UBIScheme.sol/UBIScheme.dbg.json +1 -1
- package/artifacts/contracts/ubi/UBISchemeV2.sol/UBISchemeV2.dbg.json +1 -1
- package/artifacts/contracts/utils/AdminWallet.sol/AdminWallet.dbg.json +1 -1
- package/artifacts/contracts/utils/AdminWalletFuse.sol/AdminWalletFuse.dbg.json +1 -1
- 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/BulkWhitelist.sol/BulkWhitelist.dbg.json +1 -1
- package/artifacts/contracts/utils/BuyAndBridgeHelper.sol/BuyAndBridgeHelper.dbg.json +1 -1
- package/artifacts/contracts/utils/BuyFromReserveHelper.sol/BuyFromReserveHelper.dbg.json +1 -1
- package/artifacts/contracts/utils/BuyGDClone.sol/BuyGDClone.dbg.json +1 -1
- package/artifacts/contracts/utils/BuyGDClone.sol/BuyGDCloneFactory.dbg.json +1 -1
- package/artifacts/contracts/utils/BuyGDClone.sol/DonateGDClone.dbg.json +1 -1
- package/artifacts/contracts/utils/DAOContract.sol/DAOContract.dbg.json +1 -1
- package/artifacts/contracts/utils/DAOUpgradeableContract.sol/DAOUpgradeableContract.dbg.json +1 -1
- 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/FuseOldBridgeKill.sol/EternalStorage.dbg.json +1 -1
- package/artifacts/contracts/utils/FuseOldBridgeKill.sol/FuseOldBridgeKill.dbg.json +1 -1
- package/artifacts/contracts/utils/FuseOldBridgeKill.sol/IUpgradeabilityOwnerStorage.dbg.json +1 -1
- package/artifacts/contracts/utils/FuseOldBridgeKill.sol/Initializable.dbg.json +1 -1
- package/artifacts/contracts/utils/FuseOldBridgeKill.sol/Ownable.dbg.json +1 -1
- package/artifacts/contracts/utils/FuseOldBridgeKill.sol/Upgradeable.dbg.json +1 -1
- package/artifacts/contracts/utils/GDFaucet.sol/GDFaucet.dbg.json +1 -1
- package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/GoodDollarMintBurnWrapper.dbg.json +1 -1
- 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/IdentityFix.sol/IdentityFix.dbg.json +1 -1
- package/artifacts/contracts/utils/MultiCall.sol/Multicall.dbg.json +1 -1
- package/artifacts/contracts/utils/MultichainBridgeHelper.sol/MultichainBridgeHelper.dbg.json +1 -1
- package/artifacts/contracts/utils/NameService.sol/NameService.dbg.json +1 -1
- package/artifacts/contracts/utils/OneTimePayments.sol/OneTimePayments.dbg.json +1 -1
- package/artifacts/contracts/utils/OneTimePaymentsV2.sol/OneTimePaymentsV2.dbg.json +1 -1
- package/artifacts/contracts/utils/ProtoclUpgradeV4Mento.sol/MentoExchange.dbg.json +1 -1
- package/artifacts/contracts/utils/ProtoclUpgradeV4Mento.sol/ProtocolUpgradeV4Mento.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/ProtocolUpgradeFuse.sol/ProtocolUpgradeFuse.dbg.json +1 -1
- package/artifacts/contracts/utils/ProtocolUpgradeFuseRecover.sol/ProtocolUpgradeFuseRecover.dbg.json +1 -1
- package/artifacts/contracts/utils/ProtocolUpgradeRecover.sol/ProtocolUpgradeRecover.dbg.json +1 -1
- 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/contracts/identity/IdentityV3.sol +0 -3
- package/contracts/identity/IdentityV4.sol +578 -0
- package/hardhat.config.ts +3 -4
- package/package.json +8 -4
- package/releases/deployment.json +691 -1
- package/test/governance/ClaimersDistribution.test.ts +1 -1
- package/test/governance/CompoundVotingMachine.castvote.test.ts +30 -30
- package/test/helpers.ts +76 -195
- package/test/identity/IdentityV3.test.ts +53 -129
- package/test/identity/IdentityV4.test.ts +454 -0
- package/test/reserve/GenericDistributionHelper.e2e.test.ts +445 -0
- package/test/utils/AdminWallet.test.ts +14 -15
- package/types/contracts/identity/IdentityV4.ts +2001 -0
- package/types/contracts/identity/index.ts +1 -0
- package/types/contracts/utils/UpdateReserveRatio.sol/MentoExchange.ts +81 -0
- package/types/contracts/utils/UpdateReserveRatio.sol/UpdateReserveRatio.ts +134 -0
- package/types/contracts/utils/UpdateReserveRatio.sol/index.ts +5 -0
- package/types/contracts/utils/UpdateReserveRatioAfterXDC.sol/UpdateReserveRatioAfterXDC.ts +7 -2
- package/types/contracts/utils/index.ts +2 -0
- package/types/factories/contracts/identity/IdentityV3__factory.ts +1 -1
- package/types/factories/contracts/identity/IdentityV4__factory.ts +1213 -0
- package/types/factories/contracts/identity/index.ts +1 -0
- package/types/factories/contracts/utils/UpdateReserveRatio.sol/MentoExchange__factory.ts +39 -0
- package/types/factories/contracts/utils/UpdateReserveRatio.sol/UpdateReserveRatio__factory.ts +113 -0
- package/types/factories/contracts/utils/UpdateReserveRatio.sol/index.ts +5 -0
- package/types/factories/contracts/utils/UpdateReserveRatioAfterXDC.sol/UpdateReserveRatioAfterXDC__factory.ts +9 -15
- package/types/factories/contracts/utils/index.ts +1 -0
- package/types/hardhat.d.ts +27 -0
- package/types/index.ts +4 -0
- package/scripts/ProxyFactory.json +0 -4425
- package/scripts/analytics/activeGDStakers.ts +0 -188
- package/scripts/analytics/activeStakers.ts +0 -25
- package/scripts/analytics/activeUsersCount.ts +0 -156
- package/scripts/analytics/activeWalletsStats.ts +0 -301
- package/scripts/analytics/checkActiveWallets.ts +0 -60
- package/scripts/analytics/checkBridgeBalances.ts +0 -442
- package/scripts/analytics/claimIncidentStats.ts +0 -98
- package/scripts/analytics/faucetStats.ts +0 -130
- package/scripts/analytics/gdinflow.ts +0 -57
- package/scripts/analytics/goodHolders.ts +0 -46
- package/scripts/analytics/goodgiveback.ts +0 -64
- package/scripts/analytics/p2pTxs.ts +0 -564
- package/scripts/analytics/stuckgd.ts +0 -70
- package/scripts/analytics/tokenInOutStats.ts +0 -48
- package/scripts/analytics/whitelistsyncIssue.ts +0 -87
- package/scripts/bulkProof.ts +0 -202
- package/scripts/bulkWhitelist.ts +0 -31
- package/scripts/deployGnosisSafe.ts +0 -111
- package/scripts/fetchOrDeployProxyFactory.ts +0 -46
- package/scripts/fv.ts +0 -263
- package/scripts/gdx/gdxAirdropCalculation.ts +0 -479
- package/scripts/getFounders.ts +0 -32
- package/scripts/governance/README.md +0 -70
- package/scripts/governance/airdropCalculation.ts +0 -1119
- package/scripts/governance/airdropCalculationRecover.ts +0 -416
- package/scripts/governance/airdropCalculationSorted.ts +0 -438
- package/scripts/governance/goodCheckpointSorted.ts +0 -300
- package/scripts/keeper/fishInactive.ts +0 -47
- package/scripts/minimize.sh +0 -17
- package/scripts/multichain-deploy/0_proxyFactory-deploy.ts +0 -131
- package/scripts/multichain-deploy/1_basicdao-deploy.ts +0 -294
- package/scripts/multichain-deploy/2_helpers-deploy.ts +0 -152
- package/scripts/multichain-deploy/2b_otp-deploy.ts +0 -73
- package/scripts/multichain-deploy/3_gdSavings-deploy.ts +0 -190
- package/scripts/multichain-deploy/4_ubi-deploy.ts +0 -129
- package/scripts/multichain-deploy/5_gov-deploy.ts +0 -179
- package/scripts/multichain-deploy/6_testnetFaucet.ts +0 -85
- package/scripts/multichain-deploy/7_superfluidfaucet-deploy.ts +0 -123
- package/scripts/multichain-deploy/8_disthelper-deploy.ts +0 -152
- package/scripts/multichain-deploy/createUniswapTestPools.ts +0 -163
- package/scripts/multichain-deploy/flattened/Avatar.sol +0 -913
- package/scripts/multichain-deploy/flattened/Controller.sol +0 -1891
- package/scripts/multichain-deploy/flattened/FeeFormula.sol +0 -1290
- package/scripts/multichain-deploy/fulldeploy.sh +0 -26
- package/scripts/multichain-deploy/helpers.ts +0 -647
- package/scripts/multichain-deploy/multichainWrapper-deploy.ts +0 -59
- package/scripts/multichain-deploy/verifyEtherscan.ts +0 -177
- package/scripts/proposals/gip-14_1.ts +0 -251
- package/scripts/proposals/gip-15.ts +0 -427
- package/scripts/proposals/gip-25-xdc-upgrade-ubi.ts +0 -746
- package/scripts/proposals/gips-14_1.md +0 -29
- package/scripts/proposals/hack-ubi-recovery.ts +0 -414
- package/scripts/proposals/identityAuthPeriod.ts +0 -229
- package/scripts/proposals/reserveRestore.ts +0 -474
- package/scripts/proposals/updateDistHelper.ts +0 -180
- package/scripts/proposals/v4Upgrade.ts +0 -845
- package/scripts/releaser.js +0 -24
- package/scripts/staking/stakersGdRewardsCalculation.ts +0 -64
- package/scripts/upgradeScheme.ts +0 -97
- package/scripts/upgradeToV2/upgradeToV2.ts +0 -853
- package/scripts/upgradeToV2/upgradeToV2Recover.ts +0 -939
- package/scripts/upgradeToV3/v3-fix.ts +0 -120
- package/scripts/upgradeToV3/v3-fuse-multichain.ts +0 -117
- package/scripts/upgradeToV3/v3-upgrade.ts +0 -219
- package/scripts/upgrades/celo-defi-ubi-deploy.ts +0 -184
- package/scripts/upgrades/identity-upgrade.ts +0 -126
- package/scripts/upgrades/multichain-formula-upgrade.ts +0 -143
- package/scripts/upgrades/multichain-temp-fix.ts +0 -129
- package/scripts/upgrades/restoreFunds.ts +0 -91
- package/scripts/upgrades/superfluid-nft-celo-gas-token.ts +0 -159
- package/scripts/upgrades/transferDaoToGuardians.ts +0 -80
- package/scripts/upgrades/upgradeAdminWallet.ts +0 -29
- package/scripts/upgrades/upgradeFaucet.ts +0 -46
- package/scripts/utils.ts +0 -50
- package/scripts/verify.ts +0 -67
- package/scripts/voltageswaps.ts +0 -46
|
@@ -1,438 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* this version is for testing purposes only, to test greputation initial rootstate with the fixed merkle v2
|
|
3
|
-
* which uses sorted pairs so no position is required and it uses double hash for preimage attack
|
|
4
|
-
* future blockchain state hashes should be recalculated and created using similar method done here
|
|
5
|
-
*/
|
|
6
|
-
import { get, range, chunk, flatten, mergeWith, sortBy, uniq } from "lodash";
|
|
7
|
-
import fs from "fs";
|
|
8
|
-
import { MerkleTree } from "merkletreejs";
|
|
9
|
-
|
|
10
|
-
import coreContracts from "@gooddollar/goodcontracts/releases/deployment.json";
|
|
11
|
-
import stakingContracts from "@gooddollar/goodcontracts/stakingModel/releases/deployment.json";
|
|
12
|
-
import upgradablesContracts from "@gooddollar/goodcontracts/upgradables/releases/deployment.json";
|
|
13
|
-
import { ethers as Ethers } from "hardhat";
|
|
14
|
-
import { BigNumber } from "ethers";
|
|
15
|
-
type Balances = {
|
|
16
|
-
[key: string]: {
|
|
17
|
-
isNotContract: boolean;
|
|
18
|
-
balance: number;
|
|
19
|
-
claims: number;
|
|
20
|
-
stake: number;
|
|
21
|
-
gdRepShare: number;
|
|
22
|
-
claimRepShare: number;
|
|
23
|
-
stakeRepShare: number;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
type Tree = {
|
|
28
|
-
[key: string]: {
|
|
29
|
-
hash: string;
|
|
30
|
-
rep: number;
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
const DefaultBalance = {
|
|
34
|
-
balance: 0,
|
|
35
|
-
claims: 0,
|
|
36
|
-
gdRepShare: 0,
|
|
37
|
-
claimRepShare: 0,
|
|
38
|
-
stake: 0,
|
|
39
|
-
stakeRepShare: 0,
|
|
40
|
-
isNotContract: true
|
|
41
|
-
};
|
|
42
|
-
const otherContracts = [
|
|
43
|
-
"0x8d441C2Ff54C015A1BE22ad88e5D42EFBEC6C7EF", //fuseswap
|
|
44
|
-
"0x0bf36731724f0baceb0748a9e71cd4883b69c533", //fuseswap usdc
|
|
45
|
-
"0x17b09b22823f00bb9b8ee2d4632e332cadc29458", //old bridge
|
|
46
|
-
"0xd5d11ee582c8931f336fbcd135e98cee4db8ccb0", //new bridge
|
|
47
|
-
"0xa56A281cD8BA5C083Af121193B2AaCCaAAC9850a", //mainnet uniswap
|
|
48
|
-
"0x66c0f5449ba4ff4fba0b05716705a4176bbdb848", //defender automation
|
|
49
|
-
"0xA478c2975Ab1Ea89e8196811F51A7B7Ade33eB11" //"uniswap DAI"
|
|
50
|
-
];
|
|
51
|
-
|
|
52
|
-
const systemContracts = {};
|
|
53
|
-
const allContracts = flatten(
|
|
54
|
-
[coreContracts, stakingContracts, upgradablesContracts].map(_ =>
|
|
55
|
-
Object.values(_).map(_ => Object.values(_))
|
|
56
|
-
)
|
|
57
|
-
);
|
|
58
|
-
flatten(
|
|
59
|
-
[].concat(
|
|
60
|
-
...[otherContracts, allContracts]
|
|
61
|
-
.map(Object.values)
|
|
62
|
-
.map(arr => arr.map(x => (typeof x === "object" ? Object.values(x) : x)))
|
|
63
|
-
)
|
|
64
|
-
)
|
|
65
|
-
.filter(x => typeof x === "string" && x.startsWith("0x"))
|
|
66
|
-
.map(addr => (systemContracts[addr.toLowerCase()] = true));
|
|
67
|
-
|
|
68
|
-
const isSystemContract = addr => systemContracts[addr.toLowerCase()] === true;
|
|
69
|
-
|
|
70
|
-
const updateBalance = (balance, update) => {
|
|
71
|
-
return Object.assign({}, DefaultBalance, balance, update);
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const quantile = (sorted, q) => {
|
|
75
|
-
const pos = (sorted.length - 1) * q;
|
|
76
|
-
const base = Math.floor(pos);
|
|
77
|
-
|
|
78
|
-
let sum = 0;
|
|
79
|
-
for (let i = 0; i < base; i++) sum += sorted[i];
|
|
80
|
-
|
|
81
|
-
return sum;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export const airdrop = (
|
|
85
|
-
ethers: typeof Ethers,
|
|
86
|
-
ethplorer_key,
|
|
87
|
-
etherscan_key
|
|
88
|
-
) => {
|
|
89
|
-
const fusePoktProvider = new ethers.providers.JsonRpcProvider({
|
|
90
|
-
url: "https://fuse-mainnet.gateway.pokt.network/v1/lb/60ee374fc6318362996a1fb0",
|
|
91
|
-
user: "",
|
|
92
|
-
password: "d57939c260bdf0a6f22550e2350b4312" //end point will be removed, so its ok to keep clear text password
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
const fuseProvider = new ethers.providers.JsonRpcProvider(
|
|
96
|
-
"https://rpc.fuse.io"
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
const fuseGDProvider = new ethers.providers.JsonRpcProvider(
|
|
100
|
-
"https://gooddollar-rpc.fuse.io"
|
|
101
|
-
);
|
|
102
|
-
const fuseArchiveProvider = new ethers.providers.JsonRpcBatchProvider(
|
|
103
|
-
"https://explorer-node.fuse.io/"
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
const poktArchiveProvider = new ethers.providers.JsonRpcProvider({
|
|
107
|
-
url: "https://eth-trace.gateway.pokt.network/v1/lb/6130bad2dc57c50036551041",
|
|
108
|
-
user: "",
|
|
109
|
-
password: "15439e4f4aeceb469b6b38e319f4f2a5" //end point will be removed, so its ok to keep clear text password
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
console.log({ systemContracts });
|
|
113
|
-
|
|
114
|
-
const LAST_BLOCK_ETH = 14296865;
|
|
115
|
-
const LAST_BLOCK_FUSE = 14296865;
|
|
116
|
-
const START_BLOCK_FUSE = 14149729;
|
|
117
|
-
const START_BLOCK_ETH = 13683492;
|
|
118
|
-
|
|
119
|
-
const collectAirdropData = async () => {
|
|
120
|
-
const goodMainnet = await ethers
|
|
121
|
-
.getContractAt(
|
|
122
|
-
"GReputation",
|
|
123
|
-
"0x3A9299BE789ac3730e4E4c49d6d2Ad1b8BC34DFf"
|
|
124
|
-
)
|
|
125
|
-
.then(_ => _.connect(new ethers.providers.InfuraProvider()));
|
|
126
|
-
|
|
127
|
-
const goodFuse = await ethers
|
|
128
|
-
.getContractAt(
|
|
129
|
-
"GReputation",
|
|
130
|
-
"0x3A9299BE789ac3730e4E4c49d6d2Ad1b8BC34DFf"
|
|
131
|
-
)
|
|
132
|
-
.then(_ => _.connect(fuseGDProvider));
|
|
133
|
-
|
|
134
|
-
console.log({
|
|
135
|
-
LAST_BLOCK_ETH,
|
|
136
|
-
LAST_BLOCK_FUSE
|
|
137
|
-
});
|
|
138
|
-
const calcGoodMints = async (runForFuse = true) => {
|
|
139
|
-
const step = 10000;
|
|
140
|
-
const START_BLOCK = runForFuse ? START_BLOCK_FUSE : START_BLOCK_ETH;
|
|
141
|
-
|
|
142
|
-
const good = runForFuse ? goodFuse : goodMainnet;
|
|
143
|
-
const LAST_BLOCK = await good.provider.getBlockNumber();
|
|
144
|
-
const blocks = range(START_BLOCK, LAST_BLOCK, step);
|
|
145
|
-
const allLogs = [];
|
|
146
|
-
for (let blockChunk of chunk(blocks, 10)) {
|
|
147
|
-
// Get the filter (the second null could be omitted)
|
|
148
|
-
const ps = blockChunk.map(async (bc: number) => {
|
|
149
|
-
const logs = await good
|
|
150
|
-
.queryFilter(
|
|
151
|
-
good.filters.Mint(),
|
|
152
|
-
bc,
|
|
153
|
-
Math.min(bc + step - 1, LAST_BLOCK)
|
|
154
|
-
)
|
|
155
|
-
.catch(e => {
|
|
156
|
-
console.log("block transfer logs failed retrying...", bc);
|
|
157
|
-
return good.queryFilter(
|
|
158
|
-
good.filters.Mint(),
|
|
159
|
-
bc,
|
|
160
|
-
Math.min(bc + step - 1, LAST_BLOCK)
|
|
161
|
-
);
|
|
162
|
-
});
|
|
163
|
-
const claimedLogs = await good
|
|
164
|
-
.queryFilter(
|
|
165
|
-
good.filters.StateHashProof(),
|
|
166
|
-
bc,
|
|
167
|
-
Math.min(bc + step - 1, LAST_BLOCK)
|
|
168
|
-
)
|
|
169
|
-
.catch(e => {
|
|
170
|
-
console.log("block transfer logs failed retrying...", bc);
|
|
171
|
-
return good.queryFilter(
|
|
172
|
-
good.filters.StateHashProof(),
|
|
173
|
-
bc,
|
|
174
|
-
Math.min(bc + step - 1, LAST_BLOCK)
|
|
175
|
-
);
|
|
176
|
-
});
|
|
177
|
-
console.log("found logs:", claimedLogs.length, logs.length, bc);
|
|
178
|
-
return logs.concat(claimedLogs);
|
|
179
|
-
});
|
|
180
|
-
let chunkLogs = flatten(await Promise.all(ps));
|
|
181
|
-
console.log("chunk logs: ", chunkLogs.length, { blockChunk });
|
|
182
|
-
allLogs.push(chunkLogs);
|
|
183
|
-
}
|
|
184
|
-
const logs = flatten(allLogs);
|
|
185
|
-
|
|
186
|
-
const balances: { [key: string]: BigNumber } = {};
|
|
187
|
-
const result = [];
|
|
188
|
-
if (runForFuse) {
|
|
189
|
-
logs.forEach(l => {
|
|
190
|
-
if (l.event === "Mint")
|
|
191
|
-
balances[l.args._to.toLowerCase()] = (
|
|
192
|
-
balances[l.args._to.toLowerCase()] || BigNumber.from("0")
|
|
193
|
-
).add(l.args._amount);
|
|
194
|
-
else
|
|
195
|
-
balances[l.args.user.toLowerCase()] = (
|
|
196
|
-
balances[l.args.user.toLowerCase()] || BigNumber.from("0")
|
|
197
|
-
).sub(l.args.repBalance);
|
|
198
|
-
});
|
|
199
|
-
Object.entries(balances).forEach(
|
|
200
|
-
([k, v]) => {
|
|
201
|
-
if (v.gt(0)) result.push([k, v.toString()]);
|
|
202
|
-
}
|
|
203
|
-
// console.log(k, v.toString())
|
|
204
|
-
);
|
|
205
|
-
console.log(
|
|
206
|
-
"total balances found:",
|
|
207
|
-
Object.entries(balances).length,
|
|
208
|
-
"to update balances:",
|
|
209
|
-
result.length
|
|
210
|
-
);
|
|
211
|
-
fs.writeFileSync("airdrop/repRecoverFuse.json", JSON.stringify(result));
|
|
212
|
-
} else {
|
|
213
|
-
const mints = {};
|
|
214
|
-
const claims = {};
|
|
215
|
-
const result = {};
|
|
216
|
-
console.log("logs found:", logs.length);
|
|
217
|
-
let totalMints = ethers.constants.Zero;
|
|
218
|
-
logs.forEach(l => {
|
|
219
|
-
if (l.event === "Mint") {
|
|
220
|
-
mints[l.args._to.toLowerCase()] = (
|
|
221
|
-
mints[l.args._to.toLowerCase()] || BigNumber.from("0")
|
|
222
|
-
).add(l.args._amount);
|
|
223
|
-
totalMints = totalMints.add(l.args._amount);
|
|
224
|
-
} else
|
|
225
|
-
claims[l.args.user.toLowerCase()] = l.args.repBalance.toString();
|
|
226
|
-
});
|
|
227
|
-
Object.entries(mints).forEach(
|
|
228
|
-
([k, v]) =>
|
|
229
|
-
(result[k] = { claim: "0", ...result[k], mint: v.toString() })
|
|
230
|
-
);
|
|
231
|
-
Object.entries(claims).forEach(
|
|
232
|
-
([k, v]) =>
|
|
233
|
-
(result[k] = { mint: "0", ...result[k], claim: v.toString() })
|
|
234
|
-
);
|
|
235
|
-
console.log({ result, totalMints: totalMints.toString() });
|
|
236
|
-
fs.writeFileSync(
|
|
237
|
-
"airdrop/repRecoverMainnet.json",
|
|
238
|
-
JSON.stringify(result)
|
|
239
|
-
);
|
|
240
|
-
}
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
await Promise.all([calcGoodMints(), calcGoodMints(false)]);
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
const buildMerkleTree = () => {
|
|
247
|
-
const { treeData } = JSON.parse(
|
|
248
|
-
fs.readFileSync("airdrop/airdropPrev.json").toString()
|
|
249
|
-
);
|
|
250
|
-
|
|
251
|
-
const fuseMints = JSON.parse(
|
|
252
|
-
fs.readFileSync("airdrop/repRecoverFuse.json").toString()
|
|
253
|
-
);
|
|
254
|
-
|
|
255
|
-
const mainnetMints = JSON.parse(
|
|
256
|
-
fs.readFileSync("airdrop/repRecoverMainnet.json").toString()
|
|
257
|
-
);
|
|
258
|
-
|
|
259
|
-
fuseMints.forEach(([addr, v]) => {
|
|
260
|
-
const rep = BigNumber.from(v);
|
|
261
|
-
const repInWei = BigNumber.from(
|
|
262
|
-
treeData[addr.toLowerCase()]?.rep || "0"
|
|
263
|
-
).add(rep);
|
|
264
|
-
//double hash to prevent preimage attack
|
|
265
|
-
const hash = ethers.utils.keccak256(
|
|
266
|
-
ethers.utils.keccak256(
|
|
267
|
-
ethers.utils.defaultAbiCoder.encode(
|
|
268
|
-
["address", "uint256"],
|
|
269
|
-
[addr, repInWei.toString()]
|
|
270
|
-
)
|
|
271
|
-
)
|
|
272
|
-
);
|
|
273
|
-
treeData[addr.toLowerCase()] = {
|
|
274
|
-
...treeData[addr.toLowerCase()],
|
|
275
|
-
rep: repInWei,
|
|
276
|
-
hash,
|
|
277
|
-
addr
|
|
278
|
-
};
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
//we need to recalculate all hashes with double hash
|
|
282
|
-
Object.entries(treeData)
|
|
283
|
-
.filter((_: any) => !_[1].addr)
|
|
284
|
-
.forEach(([addr, data]) => {
|
|
285
|
-
const repInWei = BigNumber.from((data as any).rep);
|
|
286
|
-
treeData[addr].addr = addr;
|
|
287
|
-
const hash = ethers.utils.keccak256(
|
|
288
|
-
ethers.utils.keccak256(
|
|
289
|
-
ethers.utils.defaultAbiCoder.encode(
|
|
290
|
-
["address", "uint256"],
|
|
291
|
-
[addr, repInWei.toString()]
|
|
292
|
-
)
|
|
293
|
-
)
|
|
294
|
-
);
|
|
295
|
-
treeData[addr].hash = hash;
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
const ethRestore = Object.entries(mainnetMints).map(
|
|
299
|
-
([k, v]: [string, any]) => {
|
|
300
|
-
return [
|
|
301
|
-
k.toLowerCase(),
|
|
302
|
-
BigNumber.from(treeData[k.toLowerCase()]?.rep || "0").toString(),
|
|
303
|
-
v.mint
|
|
304
|
-
];
|
|
305
|
-
}
|
|
306
|
-
);
|
|
307
|
-
fs.writeFileSync(
|
|
308
|
-
"airdrop/ethAirdropRecover.json",
|
|
309
|
-
JSON.stringify({
|
|
310
|
-
accounts: ethRestore.map(_ => _[0]),
|
|
311
|
-
stateValue: ethRestore.map(_ => _[1]),
|
|
312
|
-
mintValue: ethRestore.map(_ => _[2])
|
|
313
|
-
})
|
|
314
|
-
);
|
|
315
|
-
let toTree: Array<[string, BigNumber]> = Object.entries(treeData).map(
|
|
316
|
-
([k, v]) => {
|
|
317
|
-
return [k, BigNumber.from((v as any).rep)];
|
|
318
|
-
}
|
|
319
|
-
);
|
|
320
|
-
toTree = toTree.sort((a, b) => (a[1].gte(b[1]) ? 1 : -1));
|
|
321
|
-
// console.log({ toTree });
|
|
322
|
-
// const topContracts = toTree.filter(_ => _[2] === true);
|
|
323
|
-
const totalReputationAirdrop = toTree
|
|
324
|
-
.reduce((c, a) => c.add(a[1]), BigNumber.from(0))
|
|
325
|
-
.toString();
|
|
326
|
-
console.log({
|
|
327
|
-
totalReputationAirdrop,
|
|
328
|
-
numberOfAccounts: toTree.length
|
|
329
|
-
});
|
|
330
|
-
// const sorted = toTree.map(_ => _[1]);
|
|
331
|
-
console.log(toTree.slice(0, 100).map(_ => [_[0], _[1].toString()]));
|
|
332
|
-
// fs.writeFileSync(`${folder}/reptree.json`, JSON.stringify(toTree));
|
|
333
|
-
// console.log("Reputation Distribution");
|
|
334
|
-
// [0.001, 0.01, 0.1, 0.5].forEach(q =>
|
|
335
|
-
// console.log({
|
|
336
|
-
// precentile: q * 100 + "%",
|
|
337
|
-
// addresses: (sorted.length * q).toFixed(0),
|
|
338
|
-
// rep:
|
|
339
|
-
// quantile(sorted, q) /
|
|
340
|
-
// (CLAIMER_REP_ALLOCATION +
|
|
341
|
-
// HOLDER_REP_ALLOCATION +
|
|
342
|
-
// STAKER_REP_ALLOCATION)
|
|
343
|
-
// })
|
|
344
|
-
// );
|
|
345
|
-
const items = Object.values(treeData);
|
|
346
|
-
const elements = items.map((e: any) => Buffer.from(e.hash.slice(2), "hex"));
|
|
347
|
-
console.log("creating merkletree sorted...", elements.length);
|
|
348
|
-
//NOTICE: we use a non sorted merkletree to save generation time, this requires also a different proof verification algorithm which
|
|
349
|
-
//is not in the default openzeppelin library
|
|
350
|
-
const merkleTree = new MerkleTree(elements, ethers.utils.keccak256, {
|
|
351
|
-
sortPairs: true
|
|
352
|
-
});
|
|
353
|
-
|
|
354
|
-
// get the merkle root
|
|
355
|
-
// returns 32 byte buffer
|
|
356
|
-
const merkleRoot = merkleTree.getHexRoot();
|
|
357
|
-
console.log("Merkle Root:", merkleRoot);
|
|
358
|
-
|
|
359
|
-
// generate merkle proof
|
|
360
|
-
// returns array of 32 byte buffers
|
|
361
|
-
const proof = merkleTree.getHexProof(elements[0]);
|
|
362
|
-
const validProof = merkleTree.verify(proof, elements[0], merkleRoot);
|
|
363
|
-
|
|
364
|
-
const lastProof = merkleTree.getHexProof(elements[elements.length - 1]);
|
|
365
|
-
const lastValidProof = merkleTree.verify(
|
|
366
|
-
lastProof,
|
|
367
|
-
elements[elements.length - 1],
|
|
368
|
-
merkleRoot
|
|
369
|
-
);
|
|
370
|
-
|
|
371
|
-
//check for possible address preimage
|
|
372
|
-
const danger = (merkleTree.getHexLayers() as any).map(_ =>
|
|
373
|
-
_.find(_ => _.startsWith("0x000000"))
|
|
374
|
-
);
|
|
375
|
-
console.log({
|
|
376
|
-
danger,
|
|
377
|
-
merkleRoot,
|
|
378
|
-
proof,
|
|
379
|
-
validProof,
|
|
380
|
-
lastProof,
|
|
381
|
-
lastValidProof,
|
|
382
|
-
proofFor: items[0],
|
|
383
|
-
lastProofFor: items[items.length - 1],
|
|
384
|
-
index: elements.length,
|
|
385
|
-
leaf: elements[elements.length - 1].toString("hex")
|
|
386
|
-
});
|
|
387
|
-
fs.writeFileSync(
|
|
388
|
-
`airdrop/airdrop.json`,
|
|
389
|
-
JSON.stringify({
|
|
390
|
-
treeData,
|
|
391
|
-
merkleRoot
|
|
392
|
-
})
|
|
393
|
-
);
|
|
394
|
-
};
|
|
395
|
-
|
|
396
|
-
const getProof = addr => {
|
|
397
|
-
const { treeData, merkleRoot } = JSON.parse(
|
|
398
|
-
fs.readFileSync("airdrop/airdrop.json").toString()
|
|
399
|
-
);
|
|
400
|
-
|
|
401
|
-
let entries = Object.entries(treeData as Tree);
|
|
402
|
-
let elements = entries.map(e => Buffer.from(e[1].hash.slice(2), "hex"));
|
|
403
|
-
|
|
404
|
-
console.log("creating merkletree sorted pairs...", elements.length);
|
|
405
|
-
const merkleTree = new MerkleTree(elements, ethers.utils.keccak256, {
|
|
406
|
-
sortPairs: true
|
|
407
|
-
});
|
|
408
|
-
|
|
409
|
-
const calcMerkleRoot = merkleTree.getHexRoot();
|
|
410
|
-
console.log("merkleroots:", {
|
|
411
|
-
fromFile: merkleRoot,
|
|
412
|
-
calculated: calcMerkleRoot
|
|
413
|
-
});
|
|
414
|
-
|
|
415
|
-
const addrData = treeData[addr] || treeData[addr.toLowerCase()];
|
|
416
|
-
const proofFor = Buffer.from(addrData.hash.slice(2), "hex");
|
|
417
|
-
|
|
418
|
-
const proof = merkleTree.getHexProof(proofFor);
|
|
419
|
-
const proofIndex =
|
|
420
|
-
elements.findIndex(_ => "0x" + _.toString("hex") === addrData.hash) + 1;
|
|
421
|
-
|
|
422
|
-
console.log({ proofIndex, proof, [addr]: addrData });
|
|
423
|
-
console.log(
|
|
424
|
-
"checkProof:",
|
|
425
|
-
merkleTree.verify(proof, proofFor, calcMerkleRoot)
|
|
426
|
-
);
|
|
427
|
-
};
|
|
428
|
-
|
|
429
|
-
return { buildMerkleTree, collectAirdropData, getProof };
|
|
430
|
-
};
|
|
431
|
-
|
|
432
|
-
const _timer = async (name, promise) => {
|
|
433
|
-
const start = Date.now();
|
|
434
|
-
const res = await promise;
|
|
435
|
-
const milis = Date.now() - start;
|
|
436
|
-
console.log(`done task ${name} in ${milis / 1000} seconds`);
|
|
437
|
-
return res;
|
|
438
|
-
};
|