@superfluid-finance/ethereum-contracts 1.4.1-dev.e675dbc.0 → 1.4.2-dev.e06ddfc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/build/contracts/AccessControl.json +1 -1
  2. package/build/contracts/AccessControlEnumerable.json +1 -1
  3. package/build/contracts/Address.json +1 -1
  4. package/build/contracts/AgreementBase.json +28 -28
  5. package/build/contracts/AgreementLibrary.json +165 -165
  6. package/build/contracts/BaseRelayRecipient.json +55 -55
  7. package/build/contracts/BatchLiquidator.json +208 -208
  8. package/build/contracts/BatchOperation.json +784 -784
  9. package/build/contracts/CFAv1Forwarder.json +2299 -2473
  10. package/build/contracts/CFAv1Library.json +2279 -2279
  11. package/build/contracts/CallUtils.json +198 -198
  12. package/build/contracts/ClosingOnUpdateFlowTestApp.json +1544 -1544
  13. package/build/contracts/ConstantFlowAgreementV1.json +8579 -8423
  14. package/build/contracts/Context.json +1 -1
  15. package/build/contracts/ContextDefinitions.json +784 -784
  16. package/build/contracts/Create2.json +1 -1
  17. package/build/contracts/CustomSuperTokenBase.json +19 -19
  18. package/build/contracts/ERC165.json +1 -1
  19. package/build/contracts/ERC1820Implementer.json +1 -1
  20. package/build/contracts/ERC1820RegistryCompiled.json +22 -22
  21. package/build/contracts/ERC20.json +1 -1
  22. package/build/contracts/ERC20Burnable.json +1 -1
  23. package/build/contracts/ERC20Pausable.json +1 -1
  24. package/build/contracts/ERC20PresetMinterPauser.json +1 -1
  25. package/build/contracts/ERC20WithTokenInfo.json +23 -23
  26. package/build/contracts/ERC777Helper.json +380 -380
  27. package/build/contracts/ERC777RecipientDrainingGas.json +855 -855
  28. package/build/contracts/ERC777RecipientReverting.json +855 -855
  29. package/build/contracts/EnumerableSet.json +1 -1
  30. package/build/contracts/EventsEmitter.json +43 -43
  31. package/build/contracts/ExclusiveInflowTestApp.json +1544 -1544
  32. package/build/contracts/FixedSizeData.json +200 -200
  33. package/build/contracts/FlowExchangeTestApp.json +1545 -1545
  34. package/build/contracts/FlowOperatorDefinitions.json +784 -784
  35. package/build/contracts/FullUpgradableSuperTokenProxy.json +116 -116
  36. package/build/contracts/IAccessControl.json +1 -1
  37. package/build/contracts/IAccessControlEnumerable.json +1 -1
  38. package/build/contracts/IConstantFlowAgreementV1.json +608 -608
  39. package/build/contracts/IDAv1Library.json +2611 -2611
  40. package/build/contracts/IERC165.json +1 -1
  41. package/build/contracts/IERC1820Implementer.json +1 -1
  42. package/build/contracts/IERC1820Registry.json +1 -1
  43. package/build/contracts/IERC20.json +1 -1
  44. package/build/contracts/IERC20Metadata.json +1 -1
  45. package/build/contracts/IERC20Permit.json +1 -1
  46. package/build/contracts/IERC777.json +1 -1
  47. package/build/contracts/IERC777Recipient.json +1 -1
  48. package/build/contracts/IERC777Sender.json +1 -1
  49. package/build/contracts/IInstantDistributionAgreementV1.json +652 -652
  50. package/build/contracts/IMultiSigWallet.json +24 -24
  51. package/build/contracts/IPureSuperToken.json +47 -47
  52. package/build/contracts/IPureSuperTokenCustom.json +47 -47
  53. package/build/contracts/IRelayRecipient.json +27 -27
  54. package/build/contracts/IResolver.json +38 -38
  55. package/build/contracts/ISETH.json +52 -52
  56. package/build/contracts/ISETHCustom.json +52 -52
  57. package/build/contracts/ISuperAgreement.json +50 -50
  58. package/build/contracts/ISuperApp.json +191 -191
  59. package/build/contracts/ISuperToken.json +544 -544
  60. package/build/contracts/ISuperTokenFactory.json +166 -166
  61. package/build/contracts/ISuperfluid.json +874 -874
  62. package/build/contracts/ISuperfluidGovernance.json +254 -254
  63. package/build/contracts/ISuperfluidToken.json +395 -395
  64. package/build/contracts/ITOGAv1.json +1441 -1441
  65. package/build/contracts/ITOGAv2.json +1441 -1441
  66. package/build/contracts/Initializable.json +1 -1
  67. package/build/contracts/InstantDistributionAgreementV1.json +5893 -5893
  68. package/build/contracts/NonClosableOutflowTestApp.json +1545 -1545
  69. package/build/contracts/Ownable.json +1 -1
  70. package/build/contracts/Pausable.json +1 -1
  71. package/build/contracts/Proxy.json +1 -1
  72. package/build/contracts/PureSuperToken.json +106 -106
  73. package/build/contracts/Resolver.json +98 -98
  74. package/build/contracts/SETHProxy.json +224 -224
  75. package/build/contracts/SafeCast.json +1 -1
  76. package/build/contracts/SafeERC20.json +1 -1
  77. package/build/contracts/SafeMath.json +1 -1
  78. package/build/contracts/SelfDeletingFlowTestApp.json +1544 -1544
  79. package/build/contracts/SlotsBitmapLibrary.json +457 -457
  80. package/build/contracts/StreamRedirector.json +745 -745
  81. package/build/contracts/Strings.json +1 -1
  82. package/build/contracts/SuperAppBase.json +239 -239
  83. package/build/contracts/SuperAppDefinitions.json +784 -784
  84. package/build/contracts/SuperToken.json +2475 -2475
  85. package/build/contracts/SuperTokenFactory.json +774 -774
  86. package/build/contracts/SuperTokenFactoryBase.json +764 -764
  87. package/build/contracts/SuperTokenFactoryHelper.json +767 -767
  88. package/build/contracts/SuperUpgrader.json +437 -437
  89. package/build/contracts/Superfluid.json +5082 -5082
  90. package/build/contracts/SuperfluidErrors.json +784 -784
  91. package/build/contracts/SuperfluidFrameworkDeployer.json +765 -765
  92. package/build/contracts/SuperfluidGovernanceBase.json +2459 -2459
  93. package/build/contracts/SuperfluidGovernanceConfigs.json +784 -784
  94. package/build/contracts/SuperfluidGovernanceII.json +155 -155
  95. package/build/contracts/SuperfluidGovernanceIIProxy.json +135 -135
  96. package/build/contracts/SuperfluidLoader.json +207 -207
  97. package/build/contracts/SuperfluidToken.json +1471 -1471
  98. package/build/contracts/TOGA.json +1457 -1457
  99. package/build/contracts/TestGovernance.json +250 -250
  100. package/build/contracts/TestToken.json +93 -93
  101. package/build/contracts/TokenCustodian.json +214 -214
  102. package/build/contracts/TokenInfo.json +32 -32
  103. package/build/contracts/UUPSProxiable.json +139 -139
  104. package/build/contracts/UUPSProxy.json +81 -81
  105. package/build/contracts/UUPSUtils.json +37 -37
  106. package/build/contracts-sizes.txt +1 -1
  107. package/contracts/agreements/ConstantFlowAgreementV1.sol +8 -3
  108. package/contracts/utils/CFAv1Forwarder.sol +2 -6
  109. package/package.json +10 -6
  110. package/scripts/deploy-deterministically.js +35 -24
  111. package/scripts/deploy-framework.js +65 -38
  112. package/scripts/gov-upgrade-governance.js +87 -0
  113. package/scripts/info-print-contract-addresses.js +1 -1
  114. package/scripts/libs/common.js +2 -1
  115. package/scripts/libs/getConfig.js +1 -1
@@ -15,15 +15,15 @@
15
15
  "absolutePath": "project:/contracts/upgradability/UUPSUtils.sol",
16
16
  "exportedSymbols": {
17
17
  "UUPSUtils": [
18
- 37588
18
+ 37600
19
19
  ]
20
20
  },
21
- "id": 37589,
21
+ "id": 37601,
22
22
  "license": "AGPLv3",
23
23
  "nodeType": "SourceUnit",
24
24
  "nodes": [
25
25
  {
26
- "id": 37566,
26
+ "id": 37578,
27
27
  "literals": [
28
28
  "solidity",
29
29
  "0.8",
@@ -39,15 +39,15 @@
39
39
  "contractDependencies": [],
40
40
  "contractKind": "library",
41
41
  "documentation": {
42
- "id": 37567,
42
+ "id": 37579,
43
43
  "nodeType": "StructuredDocumentation",
44
44
  "src": "60:76:95",
45
45
  "text": " @title UUPS (Universal Upgradeable Proxy Standard) Shared Library"
46
46
  },
47
47
  "fullyImplemented": true,
48
- "id": 37588,
48
+ "id": 37600,
49
49
  "linearizedBaseContracts": [
50
- 37588
50
+ 37600
51
51
  ],
52
52
  "name": "UUPSUtils",
53
53
  "nameLocation": "145:9:95",
@@ -56,17 +56,17 @@
56
56
  {
57
57
  "constant": true,
58
58
  "documentation": {
59
- "id": 37568,
59
+ "id": 37580,
60
60
  "nodeType": "StructuredDocumentation",
61
61
  "src": "162:288:95",
62
62
  "text": " @dev Implementation slot constant.\n Using https://eips.ethereum.org/EIPS/eip-1967 standard\n Storage slot 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc\n (obtained as bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1))."
63
63
  },
64
- "id": 37571,
64
+ "id": 37583,
65
65
  "mutability": "constant",
66
66
  "name": "_IMPLEMENTATION_SLOT",
67
67
  "nameLocation": "481:20:95",
68
68
  "nodeType": "VariableDeclaration",
69
- "scope": 37588,
69
+ "scope": 37600,
70
70
  "src": "455:115:95",
71
71
  "stateVariable": true,
72
72
  "storageLocation": "default",
@@ -75,7 +75,7 @@
75
75
  "typeString": "bytes32"
76
76
  },
77
77
  "typeName": {
78
- "id": 37569,
78
+ "id": 37581,
79
79
  "name": "bytes32",
80
80
  "nodeType": "ElementaryTypeName",
81
81
  "src": "455:7:95",
@@ -86,7 +86,7 @@
86
86
  },
87
87
  "value": {
88
88
  "hexValue": "307833363038393461313362613161333231303636376338323834393264623938646361336532303736636333373335613932306133636135303564333832626263",
89
- "id": 37570,
89
+ "id": 37582,
90
90
  "isConstant": false,
91
91
  "isLValue": false,
92
92
  "isPure": true,
@@ -104,7 +104,7 @@
104
104
  },
105
105
  {
106
106
  "body": {
107
- "id": 37578,
107
+ "id": 37590,
108
108
  "nodeType": "Block",
109
109
  "src": "681:107:95",
110
110
  "statements": [
@@ -145,33 +145,33 @@
145
145
  "evmVersion": "london",
146
146
  "externalReferences": [
147
147
  {
148
- "declaration": 37571,
148
+ "declaration": 37583,
149
149
  "isOffset": false,
150
150
  "isSlot": false,
151
151
  "src": "751:20:95",
152
152
  "valueSize": 1
153
153
  },
154
154
  {
155
- "declaration": 37575,
155
+ "declaration": 37587,
156
156
  "isOffset": false,
157
157
  "isSlot": false,
158
158
  "src": "737:4:95",
159
159
  "valueSize": 1
160
160
  }
161
161
  ],
162
- "id": 37577,
162
+ "id": 37589,
163
163
  "nodeType": "InlineAssembly",
164
164
  "src": "691:91:95"
165
165
  }
166
166
  ]
167
167
  },
168
168
  "documentation": {
169
- "id": 37572,
169
+ "id": 37584,
170
170
  "nodeType": "StructuredDocumentation",
171
171
  "src": "577:36:95",
172
172
  "text": "@dev Get implementation address."
173
173
  },
174
- "id": 37579,
174
+ "id": 37591,
175
175
  "implemented": true,
176
176
  "kind": "function",
177
177
  "modifiers": [],
@@ -179,23 +179,23 @@
179
179
  "nameLocation": "627:14:95",
180
180
  "nodeType": "FunctionDefinition",
181
181
  "parameters": {
182
- "id": 37573,
182
+ "id": 37585,
183
183
  "nodeType": "ParameterList",
184
184
  "parameters": [],
185
185
  "src": "641:2:95"
186
186
  },
187
187
  "returnParameters": {
188
- "id": 37576,
188
+ "id": 37588,
189
189
  "nodeType": "ParameterList",
190
190
  "parameters": [
191
191
  {
192
192
  "constant": false,
193
- "id": 37575,
193
+ "id": 37587,
194
194
  "mutability": "mutable",
195
195
  "name": "impl",
196
196
  "nameLocation": "675:4:95",
197
197
  "nodeType": "VariableDeclaration",
198
- "scope": 37579,
198
+ "scope": 37591,
199
199
  "src": "667:12:95",
200
200
  "stateVariable": false,
201
201
  "storageLocation": "default",
@@ -204,7 +204,7 @@
204
204
  "typeString": "address"
205
205
  },
206
206
  "typeName": {
207
- "id": 37574,
207
+ "id": 37586,
208
208
  "name": "address",
209
209
  "nodeType": "ElementaryTypeName",
210
210
  "src": "667:7:95",
@@ -219,7 +219,7 @@
219
219
  ],
220
220
  "src": "666:14:95"
221
221
  },
222
- "scope": 37588,
222
+ "scope": 37600,
223
223
  "src": "618:170:95",
224
224
  "stateMutability": "view",
225
225
  "virtual": false,
@@ -227,7 +227,7 @@
227
227
  },
228
228
  {
229
229
  "body": {
230
- "id": 37586,
230
+ "id": 37598,
231
231
  "nodeType": "Block",
232
232
  "src": "896:171:95",
233
233
  "statements": [
@@ -266,33 +266,33 @@
266
266
  "evmVersion": "london",
267
267
  "externalReferences": [
268
268
  {
269
- "declaration": 37571,
269
+ "declaration": 37583,
270
270
  "isOffset": false,
271
271
  "isSlot": false,
272
272
  "src": "988:20:95",
273
273
  "valueSize": 1
274
274
  },
275
275
  {
276
- "declaration": 37582,
276
+ "declaration": 37594,
277
277
  "isOffset": false,
278
278
  "isSlot": false,
279
279
  "src": "1026:11:95",
280
280
  "valueSize": 1
281
281
  }
282
282
  ],
283
- "id": 37585,
283
+ "id": 37597,
284
284
  "nodeType": "InlineAssembly",
285
285
  "src": "906:155:95"
286
286
  }
287
287
  ]
288
288
  },
289
289
  "documentation": {
290
- "id": 37580,
290
+ "id": 37592,
291
291
  "nodeType": "StructuredDocumentation",
292
292
  "src": "794:40:95",
293
293
  "text": "@dev Set new implementation address."
294
294
  },
295
- "id": 37587,
295
+ "id": 37599,
296
296
  "implemented": true,
297
297
  "kind": "function",
298
298
  "modifiers": [],
@@ -300,17 +300,17 @@
300
300
  "nameLocation": "848:17:95",
301
301
  "nodeType": "FunctionDefinition",
302
302
  "parameters": {
303
- "id": 37583,
303
+ "id": 37595,
304
304
  "nodeType": "ParameterList",
305
305
  "parameters": [
306
306
  {
307
307
  "constant": false,
308
- "id": 37582,
308
+ "id": 37594,
309
309
  "mutability": "mutable",
310
310
  "name": "codeAddress",
311
311
  "nameLocation": "874:11:95",
312
312
  "nodeType": "VariableDeclaration",
313
- "scope": 37587,
313
+ "scope": 37599,
314
314
  "src": "866:19:95",
315
315
  "stateVariable": false,
316
316
  "storageLocation": "default",
@@ -319,7 +319,7 @@
319
319
  "typeString": "address"
320
320
  },
321
321
  "typeName": {
322
- "id": 37581,
322
+ "id": 37593,
323
323
  "name": "address",
324
324
  "nodeType": "ElementaryTypeName",
325
325
  "src": "866:7:95",
@@ -335,19 +335,19 @@
335
335
  "src": "865:21:95"
336
336
  },
337
337
  "returnParameters": {
338
- "id": 37584,
338
+ "id": 37596,
339
339
  "nodeType": "ParameterList",
340
340
  "parameters": [],
341
341
  "src": "896:0:95"
342
342
  },
343
- "scope": 37588,
343
+ "scope": 37600,
344
344
  "src": "839:228:95",
345
345
  "stateMutability": "nonpayable",
346
346
  "virtual": false,
347
347
  "visibility": "internal"
348
348
  }
349
349
  ],
350
- "scope": 37589,
350
+ "scope": 37601,
351
351
  "src": "137:933:95",
352
352
  "usedErrors": []
353
353
  }
@@ -360,7 +360,7 @@
360
360
  },
361
361
  "networks": {},
362
362
  "schemaVersion": "3.4.9",
363
- "updatedAt": "2022-09-05T13:33:19.193Z",
363
+ "updatedAt": "2022-09-21T11:06:18.589Z",
364
364
  "devdoc": {
365
365
  "kind": "dev",
366
366
  "methods": {},
@@ -5,7 +5,7 @@ SuperToken.sol : 18114 (6462)
5
5
  SuperfluidToken.sol : 2 (24574)
6
6
  InstantDistributionAgreementV1.sol : 21380 (3196)
7
7
  AgreementLibrary.sol : 143 (24433)
8
- ConstantFlowAgreementV1.sol : 20582 (3994)
8
+ ConstantFlowAgreementV1.sol : 20609 (3967)
9
9
  AgreementBase.sol : 2 (24574)
10
10
  SuperfluidGovernanceII.sol : 8155 (16421)
11
11
  SuperfluidGovernanceBase.sol : 2 (24574)
@@ -446,7 +446,7 @@ contract ConstantFlowAgreementV1 is
446
446
  ctx, currentContext);
447
447
  }
448
448
 
449
- _requireAvailableBalance(flowVars.token, currentContext);
449
+ _requireAvailableBalance(flowVars.token, flowVars.sender, currentContext);
450
450
  }
451
451
 
452
452
  function _updateFlow(
@@ -474,7 +474,7 @@ contract ConstantFlowAgreementV1 is
474
474
  ctx, currentContext);
475
475
  }
476
476
 
477
- _requireAvailableBalance(flowVars.token, currentContext);
477
+ _requireAvailableBalance(flowVars.token, flowVars.sender, currentContext);
478
478
  }
479
479
 
480
480
  function _deleteFlow(
@@ -1221,6 +1221,7 @@ contract ConstantFlowAgreementV1 is
1221
1221
  }
1222
1222
  function _requireAvailableBalance(
1223
1223
  ISuperfluidToken token,
1224
+ address flowSender,
1224
1225
  ISuperfluid.Context memory currentContext
1225
1226
  )
1226
1227
  private view
@@ -1228,7 +1229,7 @@ contract ConstantFlowAgreementV1 is
1228
1229
  // do not enforce balance checks during callbacks for the appCreditToken
1229
1230
  if (currentContext.callType != ContextDefinitions.CALL_INFO_CALL_TYPE_APP_CALLBACK ||
1230
1231
  currentContext.appCreditToken != token) {
1231
- (int256 availableBalance,,) = token.realtimeBalanceOf(currentContext.msgSender, currentContext.timestamp);
1232
+ (int256 availableBalance,,) = token.realtimeBalanceOf(flowSender, currentContext.timestamp);
1232
1233
  if (availableBalance < 0) {
1233
1234
  revert SuperfluidErrors.INSUFFICIENT_BALANCE(SuperfluidErrors.CFA_INSUFFICIENT_BALANCE);
1234
1235
  }
@@ -1432,6 +1433,10 @@ contract ConstantFlowAgreementV1 is
1432
1433
  internal pure
1433
1434
  returns (bool)
1434
1435
  {
1436
+ if (signedTotalCFADeposit == 0) {
1437
+ return false;
1438
+ }
1439
+
1435
1440
  int256 totalRewardLeft = availableBalance + signedTotalCFADeposit;
1436
1441
  int256 totalCFAOutFlowrate = signedTotalCFADeposit / int256(liquidationPeriod);
1437
1442
  // divisor cannot be zero with existing outflow
@@ -15,6 +15,7 @@ import {
15
15
  import { CallUtils } from "../libs/CallUtils.sol";
16
16
 
17
17
  /**
18
+ * Contract address: 0xCfA1E187C9141B8bA90a436CB789017FA573d051
18
19
  * The CFAv1Forwarder contract provides an easy to use interface to
19
20
  * ConstantFlowAgreementV1 specific functionality of Super Tokens.
20
21
  * Instances of this contract can operate on the protocol only if configured as "trusted forwarder"
@@ -376,7 +377,7 @@ contract CFAv1Forwarder {
376
377
  )
377
378
  );
378
379
 
379
- _forwardBatchCall(address(_cfa), cfaCallData);
380
+ _forwardBatchCall(address(_cfa), cfaCallData, new bytes(0));
380
381
  }
381
382
 
382
383
  // compiles the calldata of a single operation for the host invocation and executes it
@@ -405,9 +406,4 @@ contract CFAv1Forwarder {
405
406
  CallUtils.revertFromReturnedData(returnedData);
406
407
  }
407
408
  }
408
-
409
- // invokes_forwardBatchCall with empty userData
410
- function _forwardBatchCall(address target, bytes memory callData) internal {
411
- _forwardBatchCall(target, callData, new bytes(0));
412
- }
413
409
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superfluid-finance/ethereum-contracts",
3
- "version": "1.4.1-dev.e675dbc.0",
3
+ "version": "1.4.2-dev.e06ddfc.0",
4
4
  "description": " Ethereum contracts implementation for the Superfluid Protocol",
5
5
  "homepage": "https://github.com/superfluid-finance/protocol-monorepo/tree/dev/packages/ethereum-contracts#readme",
6
6
  "repository": {
@@ -27,7 +27,7 @@
27
27
  "run-hardhat": "IS_HARDHAT=true hardhat",
28
28
  "run-truffle": "IS_TRUFFLE=true truffle",
29
29
  "run-forge": "IS_FOUNDRY=true forge",
30
- "run-nodemon": "nodemon -e sol,js,ts -i build -x",
30
+ "run-nodemon": "nodemon -e sol,js,ts -x",
31
31
  "build": "run-s build:*",
32
32
  "build:contracts": "rm -f build/contracts/*;yarn run-truffle compile",
33
33
  "build:hardhat": "yarn run-hardhat compile",
@@ -37,7 +37,7 @@
37
37
  "testenv:deploy": "yarn run-truffle exec scripts/deploy-test-environment.js : TEST",
38
38
  "pretest": "{ yarn testenv:start > /dev/null& } && sleep 5",
39
39
  "test": "run-s test:*:*",
40
- "test:contracts:hardhat": "yarn run-hardhat test testsuites/all-contracts.js",
40
+ "test:contracts:hardhat": "yarn run-hardhat test testsuites/all-contracts.ts",
41
41
  "test:contracts:foundry": "yarn run-forge test --hardhat",
42
42
  "test:contracts:solc-compatibility": "test/test-solc-compatibility.sh",
43
43
  "test:deployment:scripts-js-hardhat": "yarn run-hardhat test test/scripts/deployment.test.js",
@@ -48,6 +48,10 @@
48
48
  "lint": "run-s lint:*",
49
49
  "lint:sol": "solhint -w 0 contracts/*.sol contracts/*/*.sol && echo '✔ Your .sol files look good.'",
50
50
  "lint:js-eslint": "eslint . --max-warnings=0 --report-unused-disable-directives && echo '✔ Your .js files look good.'",
51
+ "lint-ts": "eslint test -c .eslintrc.ts.json --ext .ts",
52
+ "lint:ts-eslint": "yarn lint-ts --max-warnings=0 --report-unused-disable-directives && echo '✔ Your .ts files look good.'",
53
+ "fix": "run-s fix:*",
54
+ "fix:eslint": "yarn lint-ts --fix",
51
55
  "lint:check-no-focused-tests": "grep -FR .only test || { echo 'No test is focused.';exit 0; } && { echo '✘ You have focused tests.'; exit 1; }",
52
56
  "pre-commit": "if [ ! -z \"$(git status -s .)\" ];then run-s pre-commit:*;else true;fi",
53
57
  "pre-commit:lint": "yarn lint",
@@ -58,21 +62,21 @@
58
62
  "dependencies": {
59
63
  "@decentral.ee/web3-helpers": "0.5.3",
60
64
  "@openzeppelin/contracts": "4.7.3",
61
- "@superfluid-finance/js-sdk": "^0.6.4-dev.e675dbc.0",
65
+ "@superfluid-finance/js-sdk": "0.6.3",
62
66
  "@truffle/contract": "4.5.23",
63
67
  "ethereumjs-tx": "2.1.2",
64
68
  "ethereumjs-util": "7.1.5",
65
69
  "stack-trace": "0.0.10"
66
70
  },
67
71
  "devDependencies": {
68
- "@nomiclabs/hardhat-truffle5": "^2.0.6",
72
+ "@nomiclabs/hardhat-truffle5": "^2.0.7",
69
73
  "async": "^3.2.4",
70
74
  "csv-writer": "^1.6.0",
71
75
  "ganache-time-traveler": "1.0.16",
72
76
  "mochawesome": "^7.1.3",
73
77
  "readline": "1.3.0",
74
78
  "solhint": "3.3.7",
75
- "solidity-coverage": "0.7.21",
79
+ "solidity-coverage": "0.8.0",
76
80
  "solidity-docgen": "^0.6.0-beta.25",
77
81
  "truffle-flattener": "^1.6.0",
78
82
  "truffle-plugin-verify": "0.5.28"
@@ -4,7 +4,7 @@ const SuperfluidSDK = require("@superfluid-finance/js-sdk");
4
4
  const Resolver = artifacts.require("Resolver");
5
5
 
6
6
  const SuperfluidLoader = artifacts.require("SuperfluidLoader");
7
- const AgreementForwarder = artifacts.require("AgreementForwarder");
7
+ const CFAv1Forwarder = artifacts.require("CFAv1Forwarder");
8
8
 
9
9
  /**
10
10
  * @dev Deploy specified contract at a deterministic address (defined by sender, nonce)
@@ -12,16 +12,23 @@ const AgreementForwarder = artifacts.require("AgreementForwarder");
12
12
  * In order to make this easy, the script takes a private key of the deployer account and funds it.
13
13
  * Recommendation: create a new account (guaranteed to be at nonce 1 everywhere) for the deployer.
14
14
  *
15
+ * Note: fee estimation does currently not work on optimism (mainnet and testnets).
16
+ * It's unknown how to do an estimation of the overall cost (L1 and L2).
17
+ * Solution: manually pre-fund the deployer account.
18
+ *
15
19
  * @param web3 The web3 instance to be used
16
20
  * @param from address to use for funding the deployer account
17
21
  *
18
- * Usage: npx truffle exec scripts/deploy-deterministically.js : {PRIVATE KEY} {CONTRACT NAME} [{NONCE}]
22
+ * Usage: npx truffle exec scripts/deploy-deterministically.js : {CONTRACT NAME} [{NONCE}]
19
23
  * CONTRACT NAME must be one of SuperfluidLoader, AgreementForwarder
20
- * If NONCE is not defined, 1 is assumed (-> first tx done from the deployer account)
24
+ * If NONCE is not defined, 0 is assumed (-> first tx done from the deployer account)
25
+ *
26
+ * Required ENV var: DETERMINISTIC_DEPLOYER_PK
21
27
  *
22
28
  * (optional) ENV vars:
23
- * GASLIMIT: override the gas limit for networks with misbehaving estimation (Arbitrum)
24
- * ESTTXCOST: override the estimated tx cost (amount to be sent to deployer)
29
+ * GAS_LIMIT: override the gas limit for networks with misbehaving estimation
30
+ * GAS_PRICE: override the estimated gas price
31
+ * EST_TX_COST: override the estimated tx cost (amount to be sent to deployer)
25
32
  * for networks with different cost derivation structure (Optimism)
26
33
  */
27
34
  module.exports = eval(`(${S.toString()})()`)(async function (
@@ -32,19 +39,19 @@ module.exports = eval(`(${S.toString()})()`)(async function (
32
39
 
33
40
  console.log("======== Deploying deterministically ========");
34
41
 
35
- let nonce = 1;
36
- if (args.length === 3) {
42
+ let nonce = 0;
43
+ if (args.length === 2) {
37
44
  nonce = parseInt(args.pop());
38
- if (nonce <= 0) {
39
- console.error("nonce must be > 0");
45
+ if (nonce < 0) {
46
+ console.error("nonce must be >= 0");
40
47
  process.exit(1);
41
48
  }
42
- } else if (args.length !== 2) {
49
+ } else if (args.length !== 1) {
43
50
  throw new Error("Wrong number of arguments");
44
51
  }
45
52
  const contractName = args.pop();
46
- const privKey = args.pop();
47
53
 
54
+ const privKey = process.env.DETERMINISTIC_DEPLOYER_PK;
48
55
  const deployer = web3.eth.accounts.privateKeyToAccount(privKey);
49
56
  console.log("deployer:", deployer.address);
50
57
  console.log("nonce:", nonce);
@@ -67,22 +74,20 @@ module.exports = eval(`(${S.toString()})()`)(async function (
67
74
  console.log(
68
75
  `setting up SuperfluidLoader for chainId ${chainId}, resolver ${resolverAddr}`
69
76
  );
70
- } else if (contractName === "AgreementForwarder") {
71
- ContractArtifact = AgreementForwarder;
77
+ } else if (contractName === "CFAv1Forwarder") {
78
+ ContractArtifact = CFAv1Forwarder;
72
79
  deployArgs = [hostAddr];
73
80
  console.log(
74
- `setting up AgreementForwarder for chainId ${chainId}, host ${hostAddr}`
81
+ `setting up CFAv1Forwarder for chainId ${chainId}, host ${hostAddr}`
75
82
  );
76
83
  } else {
77
84
  throw new Error("Contract unknown / not supported");
78
85
  }
79
86
 
80
87
  const deployerTxCnt = await web3.eth.getTransactionCount(deployer.address);
81
- if (nonce !== deployerTxCnt + 1) {
88
+ if (nonce !== deployerTxCnt) {
82
89
  console.error(
83
- `### ERR: requested nonce is ${nonce}, but next usable nonce is ${
84
- deployerTxCnt + 1
85
- }`
90
+ `### ERR: requested nonce is ${nonce}, but next usable nonce is ${deployerTxCnt}`
86
91
  );
87
92
  process.exit(1);
88
93
  }
@@ -90,7 +95,7 @@ module.exports = eval(`(${S.toString()})()`)(async function (
90
95
  const deployerBalance = await web3.eth.getBalance(deployer.address);
91
96
  console.log("deployer balance:", web3.utils.fromWei(deployerBalance));
92
97
 
93
- const gasPrice = await web3.eth.getGasPrice();
98
+ const gasPrice = process.env.GAS_PRICE || (await web3.eth.getGasPrice());
94
99
  console.log("gas price:", gasPrice);
95
100
 
96
101
  const Contract = new web3.eth.Contract(ContractArtifact.abi);
@@ -99,7 +104,7 @@ module.exports = eval(`(${S.toString()})()`)(async function (
99
104
  arguments: deployArgs,
100
105
  });
101
106
 
102
- const gasLimit = process.env.GASLIMIT || (await deployTx.estimateGas());
107
+ const gasLimit = process.env.GAS_LIMIT || (await deployTx.estimateGas());
103
108
  console.log("gas limit:", gasLimit);
104
109
 
105
110
  const deployCode = deployTx.encodeABI();
@@ -107,19 +112,24 @@ module.exports = eval(`(${S.toString()})()`)(async function (
107
112
  const BN = web3.utils.BN;
108
113
  // calc delta between deployer balance and estimated deployment cost
109
114
  // On Optimism, this won't reflect the actual cost bcs of missing L1 component, see https://community.optimism.io/docs/developers/build/transaction-fees/#estimating-the-total-fee
110
- const estTxCost = process.env.ESTTXCOST
111
- ? new BN(process.env.ESTTXCOST)
115
+ const estTxCost = process.env.EST_TX_COST
116
+ ? new BN(process.env.EST_TX_COST)
112
117
  : new BN(gasLimit).mul(new BN(gasPrice));
113
118
  console.log("estimated tx cost:", estTxCost.toString());
114
119
  const missingBalance = estTxCost.sub(new BN(deployerBalance));
115
120
  if (missingBalance.gt(new BN(0))) {
116
121
  console.log("deployer missing balance", missingBalance.toString());
117
122
  console.log("sending funding tx...");
118
- const fundingTx = await web3.eth.sendTransaction({
123
+ const fundingTxObj = {
119
124
  from: options.from || (await web3.eth.getAccounts())[0],
120
125
  to: deployer.address,
121
126
  value: missingBalance,
122
- });
127
+ };
128
+ if (process.env.GAS_PRICE !== undefined) {
129
+ fundingTxObj.gasPrice = gasPrice;
130
+ }
131
+ const fundingTx = await web3.eth.sendTransaction(fundingTxObj);
132
+
123
133
  console.log(
124
134
  `funded deployer account in tx ${fundingTx.transactionHash}`
125
135
  );
@@ -134,6 +144,7 @@ module.exports = eval(`(${S.toString()})()`)(async function (
134
144
  const unsignedTx = {
135
145
  data: deployCode,
136
146
  gas: gasLimit,
147
+ nonce,
137
148
  };
138
149
  if (hasEip1559) {
139
150
  console.log("creating EIP-1559 tx");