@gooddollar/goodprotocol 2.0.3-beta.0 → 2.0.4

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 (186) hide show
  1. package/artifacts/abis/Faucet.min.json +1 -1
  2. package/artifacts/abis/FuseFaucetV2.min.json +1 -1
  3. package/artifacts/abis/GoodDollarMintBurnWrapper.min.json +1 -1
  4. package/artifacts/abis/OneTimePayments.min.json +1 -0
  5. package/artifacts/contracts/DAOStackInterfaces.sol/Avatar.dbg.json +1 -1
  6. package/artifacts/contracts/DAOStackInterfaces.sol/Controller.dbg.json +1 -1
  7. package/artifacts/contracts/DAOStackInterfaces.sol/GlobalConstraintInterface.dbg.json +1 -1
  8. package/artifacts/contracts/DAOStackInterfaces.sol/IntVoteInterface.dbg.json +1 -1
  9. package/artifacts/contracts/DAOStackInterfaces.sol/ReputationInterface.dbg.json +1 -1
  10. package/artifacts/contracts/DAOStackInterfaces.sol/SchemeRegistrar.dbg.json +1 -1
  11. package/artifacts/contracts/Interfaces.sol/AggregatorV3Interface.dbg.json +1 -1
  12. package/artifacts/contracts/Interfaces.sol/ERC20.dbg.json +1 -1
  13. package/artifacts/contracts/Interfaces.sol/IAaveIncentivesController.dbg.json +1 -1
  14. package/artifacts/contracts/Interfaces.sol/IAdminWallet.dbg.json +1 -1
  15. package/artifacts/contracts/Interfaces.sol/IDonationStaking.dbg.json +1 -1
  16. package/artifacts/contracts/Interfaces.sol/IERC2917.dbg.json +1 -1
  17. package/artifacts/contracts/Interfaces.sol/IFirstClaimPool.dbg.json +1 -1
  18. package/artifacts/contracts/Interfaces.sol/IGoodDollar.dbg.json +1 -1
  19. package/artifacts/contracts/Interfaces.sol/IGoodStaking.dbg.json +1 -1
  20. package/artifacts/contracts/Interfaces.sol/IHasRouter.dbg.json +1 -1
  21. package/artifacts/contracts/Interfaces.sol/IIdentity.dbg.json +1 -1
  22. package/artifacts/contracts/Interfaces.sol/IIdentityV2.dbg.json +1 -1
  23. package/artifacts/contracts/Interfaces.sol/ILendingPool.dbg.json +1 -1
  24. package/artifacts/contracts/Interfaces.sol/IMultichainRouter.dbg.json +1 -1
  25. package/artifacts/contracts/Interfaces.sol/INameService.dbg.json +1 -1
  26. package/artifacts/contracts/Interfaces.sol/IUBIScheme.dbg.json +1 -1
  27. package/artifacts/contracts/Interfaces.sol/ProxyAdmin.dbg.json +1 -1
  28. package/artifacts/contracts/Interfaces.sol/Reserve.dbg.json +1 -1
  29. package/artifacts/contracts/Interfaces.sol/Staking.dbg.json +1 -1
  30. package/artifacts/contracts/Interfaces.sol/Uniswap.dbg.json +1 -1
  31. package/artifacts/contracts/Interfaces.sol/UniswapFactory.dbg.json +1 -1
  32. package/artifacts/contracts/Interfaces.sol/UniswapPair.dbg.json +1 -1
  33. package/artifacts/contracts/Interfaces.sol/cERC20.dbg.json +1 -1
  34. package/artifacts/contracts/fuseFaucet/Faucet.sol/Faucet.dbg.json +1 -1
  35. package/artifacts/contracts/fuseFaucet/Faucet.sol/Faucet.json +43 -17
  36. package/artifacts/contracts/fuseFaucet/FuseFaucet.sol/FuseFaucet.dbg.json +1 -1
  37. package/artifacts/contracts/fuseFaucet/FuseFaucetV2.sol/FuseFaucetV2.dbg.json +1 -1
  38. package/artifacts/contracts/fuseFaucet/FuseFaucetV2.sol/FuseFaucetV2.json +37 -17
  39. package/artifacts/contracts/governance/ClaimersDistribution.sol/ClaimersDistribution.dbg.json +1 -1
  40. package/artifacts/contracts/governance/CompoundVotingMachine.sol/CompoundVotingMachine.dbg.json +1 -1
  41. package/artifacts/contracts/governance/GReputation.sol/GReputation.dbg.json +1 -1
  42. package/artifacts/contracts/governance/GoodDollarStaking.sol/GoodDollarStaking.dbg.json +1 -1
  43. package/artifacts/contracts/governance/GoodDollarStaking.sol/IGovernanceStaking.dbg.json +1 -1
  44. package/artifacts/contracts/governance/GoodDollarStaking.sol/IStakingUpgrade.dbg.json +1 -1
  45. package/artifacts/contracts/governance/GoodDollarStaking.sol/RewardsMinter.dbg.json +1 -1
  46. package/artifacts/contracts/governance/GovernanceStaking.sol/GovernanceStaking.dbg.json +1 -1
  47. package/artifacts/contracts/governance/MultiBaseGovernanceShareField.sol/MultiBaseGovernanceShareField.dbg.json +1 -1
  48. package/artifacts/contracts/governance/Reputation.sol/Reputation.dbg.json +1 -1
  49. package/artifacts/contracts/governance/StakersDistribution.sol/StakersDistribution.dbg.json +1 -1
  50. package/artifacts/contracts/identity/IdentityV2.sol/IdentityV2.dbg.json +1 -1
  51. package/artifacts/contracts/invite/InvitesFuseV2.sol/InvitesFuseV2.dbg.json +1 -1
  52. package/artifacts/contracts/invite/InvitesV1.sol/InvitesV1.dbg.json +1 -1
  53. package/artifacts/contracts/invite/InvitesV2.sol/InvitesV2.dbg.json +1 -1
  54. package/artifacts/contracts/mocks/AaveMock.sol/AaveMock.dbg.json +1 -1
  55. package/artifacts/contracts/mocks/DAIMock.sol/DAIMock.dbg.json +1 -1
  56. package/artifacts/contracts/mocks/DecimalsMock.sol/DecimalsMock.dbg.json +1 -1
  57. package/artifacts/contracts/mocks/DistributionBridgeMock.sol/DistributionBridgeMock.dbg.json +1 -1
  58. package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTest.dbg.json +1 -1
  59. package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTestHelper.dbg.json +1 -1
  60. package/artifacts/contracts/mocks/FeesFormularMock.sol/FeesFormulaMock.dbg.json +1 -1
  61. package/artifacts/contracts/mocks/GoodCompoundStakingTest.sol/GoodCompoundStakingTest.dbg.json +1 -1
  62. package/artifacts/contracts/mocks/GoodDollarStakingMock.sol/GoodDollarStakingMock.dbg.json +1 -1
  63. package/artifacts/contracts/mocks/GoodFundManagerTest.sol/GoodFundManagerTest.dbg.json +1 -1
  64. package/artifacts/contracts/mocks/IdentityMock.sol/IdentityMock.dbg.json +1 -1
  65. package/artifacts/contracts/mocks/IncentiveControllerMock.sol/IncentiveControllerMock.dbg.json +1 -1
  66. package/artifacts/contracts/mocks/LendingPoolMock.sol/LendingPoolMock.dbg.json +1 -1
  67. package/artifacts/contracts/mocks/MultichainRouterMock.sol/IWrapper.dbg.json +1 -1
  68. package/artifacts/contracts/mocks/MultichainRouterMock.sol/MultichainRouterMock.dbg.json +1 -1
  69. package/artifacts/contracts/mocks/OverMintTester.sol/IGoodDollarStakingTest.dbg.json +1 -1
  70. package/artifacts/contracts/mocks/OverMintTester.sol/OverMintTester.dbg.json +1 -1
  71. package/artifacts/contracts/mocks/OverMintTesterRegularStake.sol/OverMintTesterRegularStake.dbg.json +1 -1
  72. package/artifacts/contracts/mocks/SixteenDecimalsTokenMock.sol/SixteenDecimalsTokenMock.dbg.json +1 -1
  73. package/artifacts/contracts/mocks/StakingMockFixedAPY.sol/StakingMockFixedAPY.dbg.json +1 -1
  74. package/artifacts/contracts/mocks/SwapHelperTest.sol/SwapHelperTest.dbg.json +1 -1
  75. package/artifacts/contracts/mocks/TwentyDecimalsTokenMock.sol/TwentyDecimalsTokenMock.dbg.json +1 -1
  76. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock.dbg.json +1 -1
  77. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock2.dbg.json +1 -1
  78. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock3.dbg.json +1 -1
  79. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock4.dbg.json +1 -1
  80. package/artifacts/contracts/mocks/UsdcMock.sol/USDCMock.dbg.json +1 -1
  81. package/artifacts/contracts/mocks/cBATMock.sol/cBATMock.dbg.json +1 -1
  82. package/artifacts/contracts/mocks/cDAILowWorthMock.sol/cDAILowWorthMock.dbg.json +1 -1
  83. package/artifacts/contracts/mocks/cDAIMock.sol/cDAIMock.dbg.json +1 -1
  84. package/artifacts/contracts/mocks/cDAINonMintableMock.sol/cDAINonMintableMock.dbg.json +1 -1
  85. package/artifacts/contracts/mocks/cDecimalsMock.sol/cDecimalsMock.dbg.json +1 -1
  86. package/artifacts/contracts/mocks/cSDTMock.sol/cSDTMock.dbg.json +1 -1
  87. package/artifacts/contracts/mocks/cUSDCMock.sol/cUSDCMock.dbg.json +1 -1
  88. package/artifacts/contracts/reserve/DistributionHelper.sol/DistributionHelper.dbg.json +1 -1
  89. package/artifacts/contracts/reserve/ExchangeHelper.sol/ExchangeHelper.dbg.json +1 -1
  90. package/artifacts/contracts/reserve/GoodMarketMaker.sol/GoodMarketMaker.dbg.json +1 -1
  91. package/artifacts/contracts/reserve/GoodReserveCDai.sol/ContributionCalc.dbg.json +1 -1
  92. package/artifacts/contracts/reserve/GoodReserveCDai.sol/GoodReserveCDai.dbg.json +1 -1
  93. package/artifacts/contracts/staking/BaseShareField.sol/BaseShareField.dbg.json +1 -1
  94. package/artifacts/contracts/staking/BaseShareFieldV2.sol/BaseShareFieldV2.dbg.json +1 -1
  95. package/artifacts/contracts/staking/DonationsStaking.sol/DonationsStaking.dbg.json +1 -1
  96. package/artifacts/contracts/staking/FuseStakingV3.sol/FuseStakingV3.dbg.json +1 -1
  97. package/artifacts/contracts/staking/FuseStakingV3.sol/FuseStakingV3.json +2 -2
  98. package/artifacts/contracts/staking/FuseStakingV3.sol/IConsensus.dbg.json +1 -1
  99. package/artifacts/contracts/staking/FuseStakingV3.sol/PegSwap.dbg.json +1 -1
  100. package/artifacts/contracts/staking/GoodFundManager.sol/GoodFundManager.dbg.json +1 -1
  101. package/artifacts/contracts/staking/SimpleStaking.sol/SimpleStaking.dbg.json +1 -1
  102. package/artifacts/contracts/staking/SimpleStakingV2.sol/SimpleStakingV2.dbg.json +1 -1
  103. package/artifacts/contracts/staking/UniswapV2SwapHelper.sol/UniswapV2SwapHelper.dbg.json +1 -1
  104. package/artifacts/contracts/staking/aave/AaveStakingFactory.sol/AaveStakingFactory.dbg.json +1 -1
  105. package/artifacts/contracts/staking/aave/GoodAaveStaking.sol/GoodAaveStaking.dbg.json +1 -1
  106. package/artifacts/contracts/staking/aave/GoodAaveStakingV2.sol/GoodAaveStakingV2.dbg.json +1 -1
  107. package/artifacts/contracts/staking/compound/CompoundStakingFactory.sol/CompoundStakingFactory.dbg.json +1 -1
  108. package/artifacts/contracts/staking/compound/GoodCompoundStaking.sol/GoodCompoundStaking.dbg.json +1 -1
  109. package/artifacts/contracts/staking/compound/GoodCompoundStakingV2.sol/GoodCompoundStakingV2.dbg.json +1 -1
  110. package/artifacts/contracts/staking/utils/Math64X64.sol/Math64x64.dbg.json +1 -1
  111. package/artifacts/contracts/staking/utils/StakingRewardsFixedAPY.sol/StakingRewardsFixedAPY.dbg.json +1 -1
  112. package/artifacts/contracts/token/ERC20PresetMinterPauserUpgradeable.sol/ERC20PresetMinterPauserUpgradeable.dbg.json +1 -1
  113. package/artifacts/contracts/token/ERC677.sol/ERC677.dbg.json +1 -1
  114. package/artifacts/contracts/token/ERC677.sol/ERC677Receiver.dbg.json +1 -1
  115. package/artifacts/contracts/token/FeesFormula.sol/IFeesFormula.dbg.json +1 -1
  116. package/artifacts/contracts/token/GoodDollar.sol/GoodDollar.dbg.json +1 -1
  117. package/artifacts/contracts/token/superfluid/ERC20Permit.sol/ERC20Permit.dbg.json +1 -1
  118. package/artifacts/contracts/token/superfluid/ERC20Permit.sol/SelfApprove.dbg.json +1 -1
  119. package/artifacts/contracts/token/superfluid/ISuperGoodDollar.sol/IGoodDollarCustom.dbg.json +1 -1
  120. package/artifacts/contracts/token/superfluid/ISuperGoodDollar.sol/ISuperGoodDollar.dbg.json +1 -1
  121. package/artifacts/contracts/token/superfluid/SuperGoodDollar.sol/SuperGoodDollar.dbg.json +1 -1
  122. package/artifacts/contracts/token/superfluid/SuperToken.sol/SuperToken.dbg.json +1 -1
  123. package/artifacts/contracts/token/superfluid/SuperfluidToken.sol/SuperfluidToken.dbg.json +1 -1
  124. package/artifacts/contracts/token/superfluid/UUPSProxiable.sol/UUPSProxiable.dbg.json +1 -1
  125. package/artifacts/contracts/ubi/UBIScheme.sol/UBIScheme.dbg.json +1 -1
  126. package/artifacts/contracts/ubi/UBIScheme.sol/UBIScheme.json +2 -2
  127. package/artifacts/contracts/utils/AdminWallet.sol/AdminWallet.dbg.json +1 -1
  128. package/artifacts/contracts/utils/AdminWalletFuse.sol/AdminWalletFuse.dbg.json +1 -1
  129. package/artifacts/contracts/utils/BancorFormula.sol/BancorFormula.dbg.json +1 -1
  130. package/artifacts/contracts/utils/BulkProof.sol/BulkProof.dbg.json +1 -1
  131. package/artifacts/contracts/utils/BuyAndBridgeHelper.sol/BuyAndBridgeHelper.dbg.json +1 -1
  132. package/artifacts/contracts/utils/DAOContract.sol/DAOContract.dbg.json +1 -1
  133. package/artifacts/contracts/utils/DAOUpgradeableContract.sol/DAOUpgradeableContract.dbg.json +1 -1
  134. package/artifacts/contracts/utils/DSMath.sol/DSMath.dbg.json +1 -1
  135. package/artifacts/contracts/utils/DataTypes.sol/DataTypes.dbg.json +1 -1
  136. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/GoodDollarMintBurnWrapper.dbg.json +1 -1
  137. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/GoodDollarMintBurnWrapper.json +2 -9
  138. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/IRouter.dbg.json +1 -1
  139. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/PausableControl.dbg.json +1 -1
  140. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/TokenOperation.dbg.json +1 -1
  141. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/TokenOperation.json +2 -2
  142. package/artifacts/contracts/utils/MultichainBridgeHelper.sol/MultichainBridgeHelper.dbg.json +1 -1
  143. package/artifacts/contracts/utils/NameService.sol/NameService.dbg.json +1 -1
  144. package/artifacts/contracts/utils/OneTimePayments.sol/OneTimePayments.dbg.json +4 -0
  145. package/artifacts/contracts/utils/OneTimePayments.sol/OneTimePayments.json +270 -0
  146. package/artifacts/contracts/utils/ProtocolUpgrade.sol/OldMarketMaker.dbg.json +1 -1
  147. package/artifacts/contracts/utils/ProtocolUpgrade.sol/ProtocolUpgrade.dbg.json +1 -1
  148. package/artifacts/contracts/utils/ProtocolUpgradeFuse.sol/ProtocolUpgradeFuse.dbg.json +1 -1
  149. package/artifacts/contracts/utils/ProtocolUpgradeFuseRecover.sol/ProtocolUpgradeFuseRecover.dbg.json +1 -1
  150. package/artifacts/contracts/utils/ProtocolUpgradeRecover.sol/ProtocolUpgradeRecover.dbg.json +1 -1
  151. package/artifacts/contracts/utils/ProxyFactory1967.sol/ERC1967Proxy.dbg.json +1 -1
  152. package/artifacts/contracts/utils/ProxyFactory1967.sol/ProxyFactory1967.dbg.json +1 -1
  153. package/artifacts/contracts/utils/ReputationTestHelper.sol/ReputationTestHelper.dbg.json +1 -1
  154. package/contracts/fuseFaucet/Faucet.sol +19 -10
  155. package/contracts/fuseFaucet/FuseFaucetV2.sol +28 -16
  156. package/contracts/ubi/UBIScheme.sol +1 -1
  157. package/contracts/utils/GoodDollarMintBurnWrapper.sol +1 -19
  158. package/contracts/utils/OneTimePayments.sol +135 -0
  159. package/package.json +1 -1
  160. package/releases/deployment.json +16 -5
  161. package/scripts/multichain-deploy/2_helpers-deploy.ts +46 -21
  162. package/scripts/multichain-deploy/2b_otp-deploy.ts +73 -0
  163. package/scripts/multichain-deploy/4_ubi-deploy.ts +19 -35
  164. package/scripts/multichain-deploy/helpers.ts +2 -2
  165. package/scripts/multichain-deploy/multichainWrapper-deploy.ts +7 -4
  166. package/scripts/upgradeToV3/v3-fuse-multichain.ts +117 -0
  167. package/scripts/upgrades/celo-defi-ubi-deploy.ts +9 -3
  168. package/scripts/upgrades/identity-upgrade.ts +20 -12
  169. package/test/faucet/Faucet.test.ts +4 -3
  170. package/test/faucet/FuseFaucet.test.ts +1 -1
  171. package/test/ubi/UBISchemeCycle.test.ts +20 -58
  172. package/test/utils/GoodDollarMintBurnWrapper.test.ts +66 -224
  173. package/types/Faucet.ts +61 -32
  174. package/types/FuseFaucetV2.ts +69 -32
  175. package/types/GoodDollarMintBurnWrapper.ts +0 -27
  176. package/types/OneTimePayments.ts +396 -0
  177. package/types/factories/Faucet__factory.ts +42 -16
  178. package/types/factories/FuseFaucetV2__factory.ts +36 -16
  179. package/types/factories/FuseStakingV3__factory.ts +1 -1
  180. package/types/factories/GoodDollarMintBurnWrapper__factory.ts +1 -8
  181. package/types/factories/OneTimePayments__factory.ts +323 -0
  182. package/types/factories/UBIScheme__factory.ts +1 -1
  183. package/types/hardhat.d.ts +9 -0
  184. package/types/index.ts +2 -0
  185. package/scripts/multichain-deploy/v3-fix.ts +0 -120
  186. package/scripts/multichain-deploy/v3-upgrade.ts +0 -219
@@ -0,0 +1,135 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity >=0.8.0;
3
+
4
+ import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
5
+
6
+ import "../Interfaces.sol";
7
+ import "./DAOContract.sol";
8
+ import "../utils/NameService.sol";
9
+
10
+ /* @title One Time payment scheme
11
+ * Scheme that allows address to deposit tokens for any address to withdraw
12
+ */
13
+ contract OneTimePayments is DAOContract {
14
+ struct Payment {
15
+ bool hasPayment;
16
+ uint256 paymentAmount;
17
+ address paymentSender;
18
+ }
19
+
20
+ mapping(address => Payment) public payments;
21
+
22
+ event PaymentDeposit(address indexed from, address paymentId, uint256 amount);
23
+ event PaymentCancel(address indexed from, address paymentId, uint256 amount);
24
+ event PaymentWithdraw(
25
+ address indexed from,
26
+ address indexed to,
27
+ address indexed paymentId,
28
+ uint256 amount
29
+ );
30
+
31
+ /* @dev Constructor
32
+ * @param _avatar The avatar of the DAO
33
+ * @param _identity The identity contract
34
+ * @param _gasLimit The gas limit
35
+ */
36
+ constructor(INameService _ns) {
37
+ setDAO(_ns);
38
+ }
39
+
40
+ /* @dev ERC677 on token transfer function. When transferAndCall is called on this contract,
41
+ * this function is called, depositing the payment amount under the hash of the given bytes.
42
+ * Reverts if hash is already in use. Can only be called by token contract.
43
+ * @param sender the address of the sender
44
+ * @param value the amount to deposit
45
+ * @param data The given paymentId which should be a fresh address of a wallet
46
+ */
47
+ function onTokenTransfer(
48
+ address sender,
49
+ uint256 value,
50
+ bytes calldata data
51
+ ) external returns (bool) {
52
+ address paymentId = abi.decode(data, (address));
53
+
54
+ require(!payments[paymentId].hasPayment, "paymentId already in use");
55
+ require(msg.sender == address(nativeToken()), "Only callable by this");
56
+
57
+ payments[paymentId] = Payment(true, value, sender);
58
+
59
+ emit PaymentDeposit(sender, paymentId, value);
60
+
61
+ return true;
62
+ }
63
+
64
+ /* @dev Withdrawal function.
65
+ * allows the sender that proves ownership of paymentId to withdraw
66
+ * @param paymentId the address of the public key that the
67
+ * rightful receiver of the payment knows the private key to
68
+ * @param signature the signature of a the message containing the msg.sender address signed
69
+ * with the private key.
70
+ */
71
+ function withdraw(address paymentId, bytes memory signature) public {
72
+ address signer = signerOfAddress(msg.sender, signature);
73
+ require(signer == paymentId, "Signature is not correct");
74
+
75
+ uint256 value = payments[paymentId].paymentAmount;
76
+ address sender = payments[paymentId].paymentSender;
77
+
78
+ _withdraw(paymentId, value);
79
+ emit PaymentWithdraw(sender, msg.sender, paymentId, value);
80
+ }
81
+
82
+ /* @dev Cancel function
83
+ * allows only creator of payment to cancel
84
+ * @param paymentId The paymentId of the payment to cancelæ
85
+ */
86
+ function cancel(address paymentId) public {
87
+ require(
88
+ payments[paymentId].paymentSender == msg.sender,
89
+ "Can only be called by creator"
90
+ );
91
+
92
+ uint256 value = payments[paymentId].paymentAmount;
93
+
94
+ _withdraw(paymentId, value);
95
+ emit PaymentCancel(msg.sender, paymentId, value);
96
+ }
97
+
98
+ /* @dev Internal withdraw function
99
+ * @param paymentId the paymentId of the payment
100
+ * @param value the amopunt in the payment
101
+ */
102
+ function _withdraw(address paymentId, uint256 value) internal {
103
+ require(payments[paymentId].hasPayment, "paymentId not in use");
104
+
105
+ payments[paymentId].hasPayment = false;
106
+
107
+ require(
108
+ nativeToken().transfer(msg.sender, value),
109
+ "withdraw transfer failed"
110
+ );
111
+ }
112
+
113
+ /* @dev function to check if a payment hash is in use
114
+ * @param paymentId the given paymentId
115
+ */
116
+ function hasPayment(address paymentId) public view returns (bool) {
117
+ return payments[paymentId].hasPayment;
118
+ }
119
+
120
+ /* @dev gives the signer address of the signature and the message
121
+ * @param message the plain-text message that is signed by the signature
122
+ * @param signature the signature of the plain-text message
123
+ */
124
+ function signerOfAddress(address message, bytes memory signature)
125
+ internal
126
+ pure
127
+ returns (address)
128
+ {
129
+ bytes32 signedMessage = ECDSA.toEthSignedMessageHash(
130
+ keccak256(abi.encodePacked(message))
131
+ );
132
+ address signer = ECDSA.recover(signedMessage, signature);
133
+ return signer;
134
+ }
135
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gooddollar/goodprotocol",
3
- "version": "2.0.3-beta.0",
3
+ "version": "2.0.4",
4
4
  "description": "GoodDollar Protocol",
5
5
  "scripts": {
6
6
  "prepack": "npm run minimize",
@@ -409,6 +409,7 @@
409
409
  "DistributionHelper": "0xAcadA0C9795fdBb6921AE96c4D7Db2F8B8c52Fd0"
410
410
  },
411
411
  "production": {
412
+ "ProxyFactory": "0xDa85fceD9Bd193526b7667F2AD1fD4A0F900d3A7",
412
413
  "NameService": "0xec6dcE387B1616a0c44fF2E4fA9E90E53Cf14eb0",
413
414
  "GReputation": "0x603B8C0F110E037b51A381CBCacAbb8d6c6E4543",
414
415
  "CompoundVotingMachine": "0x57Ee6Ceff51CB30Ecb1245934a882c500Fbec1e9",
@@ -425,7 +426,7 @@
425
426
  "Invites": "0xCa2F09c3ccFD7aD5cB9276918Bd1868f2b922ea0",
426
427
  "AdminWallet": "0x9A34822112BC73BDc941C62dCc311Ca905Aef2a3",
427
428
  "AdminWalletOld": "0x9F75dAcB77419b87f568d417eBc84346e134144E",
428
- "Identity": "0xFa8d865A962ca8456dF331D78806152d3aC5B84F",
429
+ "Identity": "0x2F9C28de9e6d44b71B91b8BA337A5D82e308E7BE",
429
430
  "GoodDollar": "0x495d133B938596C9984d462F007B676bDc57eCEC",
430
431
  "Controller": "0xBcE053b99e22158f8B62f4DBFbEdE1f936b2D4e4",
431
432
  "Avatar": "0xf96dADc6D71113F6500e97590760C924dA1eF70e",
@@ -433,7 +434,10 @@
433
434
  "ProxyAdmin": "0x57179b2A8eB019157b0C3E761cdB26c82C982a3B",
434
435
  "FuseFaucet": "0x01ab5966C1d742Ae0CFF7f14cC0F4D85156e83d9",
435
436
  "FuseStaking": "0xA199F0C353E25AdF022378B0c208D600f39a6505",
436
- "GuardiansSafe": "0x5878123fe880881f1Ecc92D5fd31e5D3F5Fba2e9"
437
+ "GuardiansSafe": "0x5878123fe880881f1Ecc92D5fd31e5D3F5Fba2e9",
438
+ "IdentityOld": "0xFa8d865A962ca8456dF331D78806152d3aC5B84F",
439
+ "MultichainRouter": "0x735aBE48e8782948a37C7765ECb76b98CdE97B0F",
440
+ "GoodDollarMintBurnWrapper": "0x031b2B7C7854dd8EE9C4A644D7e54aD17F56e3cB"
437
441
  },
438
442
  "pre-production-celo": {
439
443
  "ProxyFactory": "0x99C22e78A579e2176311c736C4c9F0b0D5A47806",
@@ -466,7 +470,12 @@
466
470
  "GoodDollarMintBurnWrapper": "0x5566b6E4962BA83e05a426Ad89031ec18e9CadD3",
467
471
  "GuardiansSafeOld": "0xC9D09BA972B4EB6Bb7347F2229FB6d50434fFCa6",
468
472
  "GuardiansSafe": "0xa2521e8F5A990903fdD8Afa6570C52526e7E0D5E",
469
- "MultichainRouter": "0xf27Ee99622C3C9b264583dACB2cCE056e194494f"
473
+ "MultichainRouter": "0xf27Ee99622C3C9b264583dACB2cCE056e194494f",
474
+ "AdminWallet": "0x7119CD89D4792aF90277d84cDffa3F2Ab22a0022",
475
+ "Faucet": "0x4F93Fa058b03953C851eFaA2e4FC5C34afDFAb84",
476
+ "Invites": "0x36829D1Cda92FFF5782d5d48991620664FC857d3",
477
+ "UBIScheme": "0x43d72Ff17701B2DA814620735C39C620Ce0ea4A1",
478
+ "OneTimePayments": "0xB27D247f5C2a61D2Cb6b6E67FEE51d839447e97d"
470
479
  },
471
480
  "gnosis": {
472
481
  "GuardiansSafe": "0x84c10b45fe51bfb4f86c19a47fdbc187d4572fb8"
@@ -491,7 +500,8 @@
491
500
  "UBIScheme": "0x6B86F82293552C3B9FE380FC038A89e0328C7C5f",
492
501
  "ClaimersDistribution": "0x6e3c0ad79FA7ccDFa27bE14C2630511415A2F635",
493
502
  "CompoundVotingMachine": "0xC2C303131939370ed75c95686F691f290b56Be66",
494
- "GuardiansSafe": "0x84C10B45fE51bfB4f86c19A47Fdbc187d4572Fb8"
503
+ "GuardiansSafe": "0x84C10B45fE51bfB4f86c19A47Fdbc187d4572Fb8",
504
+ "OneTimePayments": "0xB23e54fd8c2f35F9d38884Fc1611F5e9004f10ea"
495
505
  },
496
506
  "staging-celo": {
497
507
  "network": "staging-celo",
@@ -513,6 +523,7 @@
513
523
  "UBIScheme": "0x2881d417dA066600372753E73A3570F0781f18cB",
514
524
  "ClaimersDistribution": "0x671123F1c7a5B5445467Ff765a5E2Bc86878B245",
515
525
  "CompoundVotingMachine": "0xCd25fB84AB22582F1034bcd80c399a3126f2E775",
516
- "GuardiansSafe": "0x84C10B45fE51bfB4f86c19A47Fdbc187d4572Fb8"
526
+ "GuardiansSafe": "0x84C10B45fE51bfB4f86c19A47Fdbc187d4572Fb8",
527
+ "OneTimePayments": "0x514820Af2DaE5F537dE16E576471528176318113"
517
528
  }
518
529
  }
@@ -5,7 +5,8 @@
5
5
  import { network, ethers, upgrades, run } from "hardhat";
6
6
  import { Contract } from "ethers";
7
7
  import { defaultsDeep } from "lodash";
8
- import { deployDeterministic, verifyProductionSigner } from "./helpers";
8
+ import { getImplementationAddress } from "@openzeppelin/upgrades-core";
9
+ import { deployDeterministic, verifyProductionSigner, verifyContract } from "./helpers";
9
10
  import releaser from "../releaser";
10
11
  import ProtocolSettings from "../../releases/deploy-settings.json";
11
12
  import dao from "../../releases/deployment.json";
@@ -51,33 +52,32 @@ export const deployHelpers = async () => {
51
52
  walletAdmins.push(wallet.address);
52
53
  }
53
54
 
54
- console.log("deploying adminwallet", { walletAdmins });
55
+ console.log("deploying adminwallet", { walletAdmins, gasprice: protocolSettings.gasPrice });
55
56
  const AdminWallet = (await deployDeterministic(
56
57
  {
57
58
  // address payable[] memory _admins,
59
+ // NameService _ns,
58
60
  // address _owner,
59
- // IIdentityV2 _identity
61
+ // uint256 _gasPrice
60
62
  name: "AdminWallet",
61
63
  salt: "AdminWallet",
62
64
  isUpgradeable: true
63
65
  },
64
66
  [walletAdmins, release.NameService, root.address, protocolSettings.gasPrice]
65
67
  ).then(printDeploy)) as Contract;
68
+ // const AdminWallet = await ethers.getContractAt("AdminWallet", release.AdminWallet);
66
69
 
67
- console.log("giving AdminWallet identity_admin permissions");
68
70
  const gd = await ethers.getContractAt("IGoodDollar", release.GoodDollar);
69
71
 
70
72
  const decimals = await gd.decimals();
71
73
 
72
- const identity = await ethers.getContractAt("IdentityV2", release.Identity);
73
- await identity.grantRole(ethers.utils.keccak256(ethers.utils.toUtf8Bytes("identity_admin")), AdminWallet.address);
74
-
75
74
  const Faucet = await deployDeterministic({ name: "Faucet", salt: "Faucet", isUpgradeable: true }, [
76
75
  release.NameService,
77
76
  protocolSettings.gasPrice,
78
77
  AdminWallet.address,
79
78
  root.address
80
79
  ]);
80
+ // const Faucet = await ethers.getContractAt("Faucet", release.Faucet);
81
81
 
82
82
  const Invites = await deployDeterministic({ name: "InvitesV2", salt: "InvitesV2", isUpgradeable: true }, [
83
83
  release.NameService,
@@ -85,18 +85,42 @@ export const deployHelpers = async () => {
85
85
  root.address
86
86
  ]);
87
87
 
88
+ // const Invites = await ethers.getContractAt("AdminWallet", release.Invites);
89
+
90
+ const torelease = {
91
+ AdminWallet: AdminWallet.address,
92
+ Faucet: Faucet.address,
93
+ Invites: Invites.address
94
+ };
95
+ await releaser(torelease, network.name, "deployment", false);
96
+
88
97
  const adminWalletOwner = await AdminWallet.hasRole(ethers.constants.HashZero, root.address);
89
98
  const faucetOwner = await Faucet.hasRole(ethers.constants.HashZero, root.address);
90
99
 
100
+ console.log("giving AdminWallet identity_admin permissions");
101
+ const identity = await ethers.getContractAt("IdentityV2", release.Identity);
102
+ await identity
103
+ .grantRole(ethers.utils.keccak256(ethers.utils.toUtf8Bytes("identity_admin")), AdminWallet.address)
104
+ .then(printDeploy);
105
+
106
+ const walletIsIdentityAdmin = await identity.hasRole(
107
+ ethers.utils.keccak256(ethers.utils.toUtf8Bytes("identity_admin")),
108
+ AdminWallet.address
109
+ );
110
+
91
111
  console.log("topping adminwallet and faucet with 1 native token");
92
- await root.sendTransaction({
93
- to: AdminWallet.address,
94
- value: ethers.constants.WeiPerEther
95
- });
96
- await root.sendTransaction({
97
- to: Faucet.address,
98
- value: ethers.constants.WeiPerEther
99
- });
112
+ await root
113
+ .sendTransaction({
114
+ to: AdminWallet.address,
115
+ value: ethers.constants.WeiPerEther
116
+ })
117
+ .then(printDeploy);
118
+ await root
119
+ .sendTransaction({
120
+ to: Faucet.address,
121
+ value: ethers.constants.WeiPerEther
122
+ })
123
+ .then(printDeploy);
100
124
 
101
125
  if (!network.name.includes("production")) {
102
126
  console.log("minting G$s to invites on dev envs");
@@ -104,16 +128,17 @@ export const deployHelpers = async () => {
104
128
  }
105
129
 
106
130
  console.log({
131
+ walletIsIdentityAdmin,
107
132
  adminWalletOwner,
108
133
  faucetOwner
109
134
  });
110
135
 
111
- release = {
112
- AdminWallet: AdminWallet.address,
113
- Faucet: Faucet.address,
114
- Invites: Invites.address
115
- };
116
- await releaser(release, network.name, "deployment", false);
136
+ let impl = await getImplementationAddress(ethers.provider, AdminWallet.address);
137
+ await verifyContract(impl, "AdminWallet", network.name);
138
+ impl = await getImplementationAddress(ethers.provider, Faucet.address);
139
+ await verifyContract(impl, "Faucet", network.name);
140
+ impl = await getImplementationAddress(ethers.provider, Invites.address);
141
+ await verifyContract(impl, "InvitesV2", network.name);
117
142
  };
118
143
 
119
144
  export const main = async () => {
@@ -0,0 +1,73 @@
1
+ /***
2
+ * Deploy helper contracts
3
+ * AdminWallet, Faucet, Invites
4
+ */
5
+ import { network, ethers, upgrades, run } from "hardhat";
6
+ import { Contract } from "ethers";
7
+ import { defaultsDeep } from "lodash";
8
+ import { getImplementationAddress } from "@openzeppelin/upgrades-core";
9
+ import { deployDeterministic, verifyProductionSigner, verifyContract } from "./helpers";
10
+ import releaser from "../releaser";
11
+ import ProtocolSettings from "../../releases/deploy-settings.json";
12
+ import dao from "../../releases/deployment.json";
13
+ import { TransactionResponse } from "@ethersproject/providers";
14
+
15
+ const { name } = network;
16
+
17
+ const printDeploy = async (c: Contract | TransactionResponse): Promise<Contract | TransactionResponse> => {
18
+ if (c instanceof Contract) {
19
+ await c.deployed();
20
+ console.log("deployed to: ", c.address);
21
+ }
22
+ if (c.wait) {
23
+ await c.wait();
24
+ console.log("tx done:", c.hash);
25
+ }
26
+ return c;
27
+ };
28
+
29
+ export const deployHelpers = async () => {
30
+ let protocolSettings = defaultsDeep({}, ProtocolSettings[network.name], ProtocolSettings["default"]);
31
+
32
+ let release: { [key: string]: any } = dao[network.name];
33
+
34
+ let [root] = await ethers.getSigners();
35
+ const isProduction = network.name.includes("production");
36
+
37
+ if (isProduction) verifyProductionSigner(root);
38
+
39
+ //generic call permissions
40
+ let schemeMock = root;
41
+
42
+ console.log("got signers:", {
43
+ network,
44
+ root: root.address,
45
+ schemeMock: schemeMock.address,
46
+ balance: await ethers.provider.getBalance(root.address).then(_ => _.toString())
47
+ });
48
+
49
+ console.log("deploying onetime payments", { gasprice: protocolSettings.gasPrice });
50
+ const OTP = (await deployDeterministic(
51
+ {
52
+ name: "OneTimePayments",
53
+ salt: "OneTimePayments",
54
+ isUpgradeable: false
55
+ },
56
+ [release.NameService]
57
+ ).then(printDeploy)) as Contract;
58
+
59
+ // const OTP = await ethers.getContractAt("OneTimePayments", release.OneTimePayments);
60
+
61
+ const torelease = {
62
+ OneTimePayments: OTP.address
63
+ };
64
+ await releaser(torelease, network.name, "deployment", false);
65
+
66
+ const constructorArgs = ethers.utils.defaultAbiCoder.encode(["address"], [release.NameService]);
67
+ await verifyContract(OTP.address, "OneTimePayments", network.name, undefined, constructorArgs);
68
+ };
69
+
70
+ export const main = async () => {
71
+ await deployHelpers();
72
+ };
73
+ if (process.argv[1].includes("2b_otp-deploy")) main();
@@ -5,24 +5,23 @@
5
5
  import { network, ethers, upgrades, run } from "hardhat";
6
6
  import { Contract } from "ethers";
7
7
  import { defaultsDeep } from "lodash";
8
+ import { getImplementationAddress } from "@openzeppelin/upgrades-core";
8
9
  import {
9
10
  deployDeterministic,
10
11
  executeViaGuardian,
11
12
  executeViaSafe,
13
+ verifyContract,
12
14
  verifyProductionSigner
13
15
  } from "./helpers";
14
16
  import releaser from "../releaser";
15
17
  import ProtocolSettings from "../../releases/deploy-settings.json";
16
18
  import dao from "../../releases/deployment.json";
17
19
  import { TransactionResponse } from "@ethersproject/providers";
18
- import { InvitesV1__factory } from "../../types";
19
20
  import { keccak256, toUtf8Bytes } from "ethers/lib/utils";
20
21
 
21
22
  const { name } = network;
22
23
 
23
- const printDeploy = async (
24
- c: Contract | TransactionResponse
25
- ): Promise<Contract | TransactionResponse> => {
24
+ const printDeploy = async (c: Contract | TransactionResponse): Promise<Contract | TransactionResponse> => {
26
25
  if (c instanceof Contract) {
27
26
  await c.deployed();
28
27
  console.log("deployed to: ", c.address);
@@ -35,16 +34,14 @@ const printDeploy = async (
35
34
  };
36
35
 
37
36
  export const deployHelpers = async () => {
38
- let protocolSettings = defaultsDeep(
39
- {},
40
- ProtocolSettings[network.name],
41
- ProtocolSettings["default"]
42
- );
37
+ const viaGuardians = false;
38
+
39
+ let protocolSettings = defaultsDeep({}, ProtocolSettings[network.name], ProtocolSettings["default"]);
43
40
  let release: { [key: string]: any } = dao[network.name];
44
41
 
45
42
  let [root, ...signers] = await ethers.getSigners();
46
43
  const isProduction = network.name.includes("production");
47
- const viaGuardians = false;
44
+
48
45
  if (isProduction) verifyProductionSigner(root);
49
46
  //generic call permissions
50
47
  let schemeMock = root;
@@ -53,9 +50,7 @@ export const deployHelpers = async () => {
53
50
  network,
54
51
  root: root.address,
55
52
  schemeMock: schemeMock.address,
56
- balance: await ethers.provider
57
- .getBalance(root.address)
58
- .then(_ => _.toString())
53
+ balance: await ethers.provider.getBalance(root.address).then(_ => _.toString())
59
54
  });
60
55
 
61
56
  console.log("deploying ubi pool");
@@ -64,19 +59,14 @@ export const deployHelpers = async () => {
64
59
  name: "UBIScheme",
65
60
  isUpgradeable: true
66
61
  },
67
- [
68
- release.NameService,
69
- ethers.constants.AddressZero,
70
- protocolSettings.ubi.maxInactiveDays
71
- ]
62
+ [release.NameService, ethers.constants.AddressZero, protocolSettings.ubi.maxInactiveDays]
72
63
  ).then(printDeploy)) as Contract;
73
64
 
74
65
  console.log("deploying claimers distribution");
75
66
 
76
- const ClaimersDistribution = (await deployDeterministic(
77
- { name: "ClaimersDistribution", isUpgradeable: true },
78
- [release.NameService]
79
- ).then(printDeploy)) as Contract;
67
+ const ClaimersDistribution = (await deployDeterministic({ name: "ClaimersDistribution", isUpgradeable: true }, [
68
+ release.NameService
69
+ ]).then(printDeploy)) as Contract;
80
70
 
81
71
  console.log("setting nameservice addresses via guardian");
82
72
  const proposalContracts = [
@@ -93,10 +83,7 @@ export const deployHelpers = async () => {
93
83
  ethers.utils.defaultAbiCoder.encode(
94
84
  ["bytes32[]", "address[]"],
95
85
  [
96
- [
97
- keccak256(toUtf8Bytes("UBISCHEME")),
98
- keccak256(toUtf8Bytes("GDAO_CLAIMERS"))
99
- ],
86
+ [keccak256(toUtf8Bytes("UBISCHEME")), keccak256(toUtf8Bytes("GDAO_CLAIMERS"))],
100
87
  [UBIScheme.address, ClaimersDistribution.address]
101
88
  ]
102
89
  )
@@ -106,17 +93,14 @@ export const deployHelpers = async () => {
106
93
  console.log("minting G$s to pool on dev envs");
107
94
  const gd = await ethers.getContractAt("IGoodDollar", release.GoodDollar);
108
95
  const decimals = await gd.decimals();
109
- await gd.mint(
110
- UBIScheme.address,
111
- ethers.BigNumber.from(1e6).mul(ethers.BigNumber.from("10").pow(decimals))
112
- ); //1million GD
96
+ await gd.mint(UBIScheme.address, ethers.BigNumber.from(1e6).mul(ethers.BigNumber.from("10").pow(decimals))); //1million GD
113
97
  }
114
98
 
115
- release = {
116
- UBIScheme: UBIScheme.address,
117
- ClaimersDistribution: ClaimersDistribution.address
118
- };
119
- await releaser(release, network.name, "deployment", false);
99
+ let impl = await getImplementationAddress(ethers.provider, UBIScheme.address);
100
+ await verifyContract(impl, "UBIScheme", network.name);
101
+
102
+ impl = await getImplementationAddress(ethers.provider, ClaimersDistribution.address);
103
+ await verifyContract(impl, "ClaimersDistribution", network.name);
120
104
 
121
105
  try {
122
106
  if (viaGuardians) {
@@ -207,7 +207,7 @@ export const executeViaSafe = async (
207
207
  txServiceUrl = "https://safe-transaction-mainnet.safe.global";
208
208
  break;
209
209
  case 122:
210
- txServiceUrl = "https://gateway.safe.fuse.io";
210
+ txServiceUrl = "https://transaction-fuse.safe.fuse.io";
211
211
  break;
212
212
  case 42220:
213
213
  txServiceUrl = "https://mainnet-tx-svc.celo-safe-prod.celo-networks-dev.org";
@@ -236,8 +236,8 @@ export const executeViaSafe = async (
236
236
  const contract = contracts[i];
237
237
 
238
238
  const sigHash = ethers.utils.keccak256(ethers.utils.toUtf8Bytes(functionSigs[i])).slice(0, 10);
239
+ console.log("creating tx:", contracts[i], functionSigs[i], functionInputs[i]);
239
240
  const encoded = ethers.utils.solidityPack(["bytes4", "bytes"], [sigHash, functionInputs[i]]);
240
- console.log("creating tx:", contracts[i], functionSigs[i], functionInputs[i], encoded);
241
241
  if (contract === ctrl.address) {
242
242
  const simulationResult =
243
243
  isSimulation === false &&
@@ -1,7 +1,8 @@
1
1
  import { network, ethers, upgrades, run } from "hardhat";
2
2
  import { Contract } from "ethers";
3
+ import { getImplementationAddress } from "@openzeppelin/upgrades-core";
3
4
 
4
- import { deployDeterministic, printDeploy } from "./helpers";
5
+ import { deployDeterministic, printDeploy, verifyContract } from "./helpers";
5
6
  import releaser from "../../scripts/releaser";
6
7
  import ProtocolSettings from "../../releases/deploy-settings.json";
7
8
  import dao from "../../releases/deployment.json";
@@ -20,9 +21,7 @@ export const deployWrapper = async (defaultAdmin = null) => {
20
21
  network,
21
22
  root: root.address,
22
23
  schemeMock: schemeMock.address,
23
- balance: await ethers.provider
24
- .getBalance(root.address)
25
- .then(_ => _.toString())
24
+ balance: await ethers.provider.getBalance(root.address).then(_ => _.toString())
26
25
  });
27
26
 
28
27
  console.log("MintBurnWrapper deploy params:", [
@@ -44,6 +43,10 @@ export const deployWrapper = async (defaultAdmin = null) => {
44
43
  GoodDollarMintBurnWrapper: Wrapper.address
45
44
  };
46
45
  await releaser(release, network.name, "deployment", false);
46
+
47
+ const impl = await getImplementationAddress(ethers.provider, Wrapper.address);
48
+ await verifyContract(impl, "GoodDollarMintBurnWrapper", network.name);
49
+
47
50
  return Wrapper;
48
51
  };
49
52