@superfluid-finance/ethereum-contracts 1.5.2-dev.a97f248.0 → 1.5.2-dev.fe6f63e.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 (133) 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 +1 -1
  5. package/build/contracts/AgreementLibrary.json +1 -1
  6. package/build/contracts/BaseRelayRecipient.json +1 -1
  7. package/build/contracts/BatchLiquidator.json +1 -1
  8. package/build/contracts/BatchOperation.json +1 -1
  9. package/build/contracts/CFAv1Forwarder.json +1 -1
  10. package/build/contracts/CFAv1Library.json +1 -1
  11. package/build/contracts/CallUtils.json +1 -1
  12. package/build/contracts/ClosingOnUpdateFlowTestApp.json +1 -1
  13. package/build/contracts/ConstantFlowAgreementV1.json +1 -1
  14. package/build/contracts/Context.json +1 -1
  15. package/build/contracts/ContextDefinitions.json +1 -1
  16. package/build/contracts/CustomSuperTokenBase.json +1 -1
  17. package/build/contracts/ERC165.json +1 -1
  18. package/build/contracts/ERC1820Implementer.json +1 -1
  19. package/build/contracts/ERC1820RegistryCompiled.json +1 -1
  20. package/build/contracts/ERC20.json +1 -1
  21. package/build/contracts/ERC20WithTokenInfo.json +1 -1
  22. package/build/contracts/ERC777Helper.json +1 -1
  23. package/build/contracts/ERC777RecipientDrainingGas.json +1 -1
  24. package/build/contracts/ERC777RecipientReverting.json +1 -1
  25. package/build/contracts/EnumerableSet.json +1 -1
  26. package/build/contracts/EventsEmitter.json +1 -1
  27. package/build/contracts/ExclusiveInflowTestApp.json +1 -1
  28. package/build/contracts/FixedSizeData.json +1 -1
  29. package/build/contracts/FlowExchangeTestApp.json +1 -1
  30. package/build/contracts/FlowOperatorDefinitions.json +1 -1
  31. package/build/contracts/FullUpgradableSuperTokenProxy.json +1 -1
  32. package/build/contracts/IAccessControl.json +1 -1
  33. package/build/contracts/IAccessControlEnumerable.json +1 -1
  34. package/build/contracts/IConstantFlowAgreementHook.json +1 -1
  35. package/build/contracts/IConstantFlowAgreementV1.json +1 -1
  36. package/build/contracts/IDAv1Library.json +1 -1
  37. package/build/contracts/IERC165.json +1 -1
  38. package/build/contracts/IERC1820Implementer.json +1 -1
  39. package/build/contracts/IERC1820Registry.json +1 -1
  40. package/build/contracts/IERC20.json +1 -1
  41. package/build/contracts/IERC20Metadata.json +1 -1
  42. package/build/contracts/IERC20Permit.json +1 -1
  43. package/build/contracts/IERC777.json +1 -1
  44. package/build/contracts/IERC777Recipient.json +1 -1
  45. package/build/contracts/IERC777Sender.json +1 -1
  46. package/build/contracts/IInstantDistributionAgreementV1.json +1 -1
  47. package/build/contracts/IMultiSigWallet.json +1 -1
  48. package/build/contracts/IPureSuperToken.json +1 -1
  49. package/build/contracts/IPureSuperTokenCustom.json +1 -1
  50. package/build/contracts/IRelayRecipient.json +1 -1
  51. package/build/contracts/IResolver.json +1 -1
  52. package/build/contracts/ISETH.json +1 -1
  53. package/build/contracts/ISETHCustom.json +1 -1
  54. package/build/contracts/ISuperAgreement.json +1 -1
  55. package/build/contracts/ISuperApp.json +1 -1
  56. package/build/contracts/ISuperToken.json +1 -1
  57. package/build/contracts/ISuperTokenFactory.json +1 -1
  58. package/build/contracts/ISuperfluid.json +1 -1
  59. package/build/contracts/ISuperfluidGovernance.json +1 -1
  60. package/build/contracts/ISuperfluidToken.json +1 -1
  61. package/build/contracts/ITOGAv1.json +1 -1
  62. package/build/contracts/ITOGAv2.json +1 -1
  63. package/build/contracts/ITOGAv3.json +1 -1
  64. package/build/contracts/Initializable.json +1 -1
  65. package/build/contracts/InstantDistributionAgreementV1.json +1 -1
  66. package/build/contracts/Math.json +1 -1
  67. package/build/contracts/NonClosableOutflowTestApp.json +1 -1
  68. package/build/contracts/Ownable.json +1 -1
  69. package/build/contracts/Proxy.json +1 -1
  70. package/build/contracts/PureSuperToken.json +1 -1
  71. package/build/contracts/Resolver.json +1 -1
  72. package/build/contracts/SETHProxy.json +1 -1
  73. package/build/contracts/SafeCast.json +1 -1
  74. package/build/contracts/SafeERC20.json +1 -1
  75. package/build/contracts/SafeMath.json +1 -1
  76. package/build/contracts/SelfDeletingFlowTestApp.json +1 -1
  77. package/build/contracts/SlotsBitmapLibrary.json +1 -1
  78. package/build/contracts/StreamRedirector.json +1 -1
  79. package/build/contracts/Strings.json +1 -1
  80. package/build/contracts/SuperAppBase.json +1 -1
  81. package/build/contracts/SuperAppDefinitions.json +1 -1
  82. package/build/contracts/SuperToken.json +1 -1
  83. package/build/contracts/SuperTokenDeployerLibrary.json +1 -1
  84. package/build/contracts/SuperTokenFactory.json +1 -1
  85. package/build/contracts/SuperTokenFactoryBase.json +1 -1
  86. package/build/contracts/SuperTokenV1Library.json +1 -1
  87. package/build/contracts/SuperUpgrader.json +1 -1
  88. package/build/contracts/Superfluid.json +1 -1
  89. package/build/contracts/SuperfluidCFAv1DeployerLibrary.json +1 -1
  90. package/build/contracts/SuperfluidFrameworkDeployer.json +1 -1
  91. package/build/contracts/SuperfluidGovDeployerLibrary.json +1 -1
  92. package/build/contracts/SuperfluidGovernanceBase.json +1 -1
  93. package/build/contracts/SuperfluidGovernanceConfigs.json +1 -1
  94. package/build/contracts/SuperfluidGovernanceII.json +1 -1
  95. package/build/contracts/SuperfluidGovernanceIIProxy.json +1 -1
  96. package/build/contracts/SuperfluidHostDeployerLibrary.json +1 -1
  97. package/build/contracts/SuperfluidIDAv1DeployerLibrary.json +1 -1
  98. package/build/contracts/SuperfluidLoader.json +1 -1
  99. package/build/contracts/SuperfluidPeripheryDeployerLibrary.json +1 -1
  100. package/build/contracts/SuperfluidToken.json +1 -1
  101. package/build/contracts/TOGA.json +1 -1
  102. package/build/contracts/TestGovernance.json +1 -1
  103. package/build/contracts/TestResolver.json +1 -1
  104. package/build/contracts/TestToken.json +1 -1
  105. package/build/contracts/TokenInfo.json +1 -1
  106. package/build/contracts/UUPSProxiable.json +1 -1
  107. package/build/contracts/UUPSProxy.json +1 -1
  108. package/build/contracts/UUPSUtils.json +1 -1
  109. package/build/contracts-sizes.txt +9 -9
  110. package/package.json +2 -2
  111. package/contracts/mocks/AgreementMock.sol +0 -375
  112. package/contracts/mocks/CFAAppMocks.sol +0 -361
  113. package/contracts/mocks/CFAHookMocks.sol +0 -148
  114. package/contracts/mocks/CFALibraryMock.sol +0 -213
  115. package/contracts/mocks/CallUtilsMock.sol +0 -79
  116. package/contracts/mocks/CallUtilsTester.sol +0 -14
  117. package/contracts/mocks/CustomSuperTokenMock.sol +0 -104
  118. package/contracts/mocks/ERC777SenderRecipientMock.sol +0 -238
  119. package/contracts/mocks/FakeSuperfluidMock.sol +0 -21
  120. package/contracts/mocks/ForwarderMock.sol +0 -39
  121. package/contracts/mocks/IDASuperAppTester.sol +0 -297
  122. package/contracts/mocks/IDAv1LibraryMock.sol +0 -400
  123. package/contracts/mocks/MockSmartWallet.sol +0 -15
  124. package/contracts/mocks/MultiFlowTesterApp.sol +0 -336
  125. package/contracts/mocks/StreamRedirector.sol +0 -179
  126. package/contracts/mocks/SuperAppMocks.sol +0 -622
  127. package/contracts/mocks/SuperTokenFactoryMock.sol +0 -98
  128. package/contracts/mocks/SuperTokenLibraryV1Mock.sol +0 -583
  129. package/contracts/mocks/SuperTokenMock.sol +0 -113
  130. package/contracts/mocks/SuperfluidDestructorMock.sol +0 -14
  131. package/contracts/mocks/SuperfluidGovernanceIIMock.sol +0 -22
  132. package/contracts/mocks/SuperfluidMock.sol +0 -177
  133. package/contracts/mocks/UUPSProxiableMock.sol +0 -29
@@ -1,583 +0,0 @@
1
- // SPDX-License-Identifier: AGPLv3
2
- pragma solidity 0.8.18;
3
-
4
- import {
5
- ISuperfluid,
6
- ISuperToken
7
- } from "../interfaces/superfluid/ISuperfluid.sol";
8
-
9
- import { ISuperApp, ISuperAgreement } from "../interfaces/superfluid/ISuperfluid.sol";
10
-
11
- import { ContextDefinitions, SuperAppDefinitions } from "../interfaces/superfluid/ISuperfluid.sol";
12
-
13
- import { SuperAppBase } from "../apps/SuperAppBase.sol";
14
-
15
- import { IConstantFlowAgreementV1 } from "../interfaces/agreements/IConstantFlowAgreementV1.sol";
16
- import { IInstantDistributionAgreementV1 } from "../interfaces/agreements/IInstantDistributionAgreementV1.sol";
17
- import { SuperTokenV1Library } from "../apps/SuperTokenV1Library.sol";
18
-
19
- contract SuperTokenLibraryCFAMock {
20
-
21
- using SuperTokenV1Library for ISuperToken;
22
-
23
- /**************************************************************************
24
- * View Functions
25
- *************************************************************************/
26
-
27
- function getFlowRateTest(
28
- ISuperToken token,
29
- address sender,
30
- address receiver
31
- ) public view returns (int96 rate) {
32
- return token.getFlowRate(sender, receiver);
33
- }
34
-
35
- function getFlowInfoTest(
36
- ISuperToken token,
37
- address sender,
38
- address receiver
39
- ) public view returns (uint256 lastUpdated, int96 flowRate, uint256 deposit, uint256 owedDeposit) {
40
- return token.getFlowInfo(sender, receiver);
41
- }
42
-
43
- function getNetFlowRateTest(
44
- ISuperToken token,
45
- address account
46
- ) public view returns (int96 netFlowRate) {
47
- return token.getNetFlowRate(account);
48
- }
49
-
50
- function getNetFlowInfoTest(
51
- ISuperToken token,
52
- address account
53
- ) public view returns (uint256 lastUpdated, int96 flowRate, uint256 deposit, uint256 owedDeposit) {
54
- return token.getNetFlowInfo(account);
55
- }
56
-
57
- function getBufferAmountByFlowRateTest(
58
- ISuperToken token,
59
- int96 flowRate
60
- ) public view returns (uint256 bufferAmount) {
61
- return token.getBufferAmountByFlowRate(flowRate);
62
- }
63
-
64
- function getFlowPermissionsTest(
65
- ISuperToken token,
66
- address sender,
67
- address flowOperator
68
- ) public view returns (bool allowCreate, bool allowUpdate, bool allowDelete, int96 flowRateAllowance) {
69
- return token.getFlowPermissions(sender, flowOperator);
70
- }
71
-
72
-
73
- /**************************************************************************
74
- * CFA Operations
75
- *************************************************************************/
76
-
77
- function createFlowTest(ISuperToken token, address receiver, int96 flowRate) public {
78
- token.createFlow(receiver, flowRate);
79
- }
80
- function deleteFlowTest(ISuperToken token, address sender, address receiver) public {
81
- token.deleteFlow(sender, receiver);
82
- }
83
-
84
- function updateFlowTest(ISuperToken token, address receiver, int96 flowRate) public {
85
- token.updateFlow(receiver, flowRate);
86
- }
87
-
88
- function createFlowFromTest(ISuperToken token, address sender, address receiver, int96 flowRate) public {
89
- token.createFlowFrom(sender, receiver, flowRate);
90
- }
91
- function deleteFlowFromTest(ISuperToken token, address sender, address receiver) public {
92
- token.deleteFlowFrom(sender, receiver);
93
- }
94
-
95
- function updateFlowFromTest(ISuperToken token, address sender, address receiver, int96 flowRate) public {
96
- token.updateFlowFrom(sender, receiver, flowRate);
97
- }
98
-
99
- function setFlowPermissionsTest(
100
- ISuperToken token,
101
- address flowOperator,
102
- bool allowCreate,
103
- bool allowUpdate,
104
- bool allowDelete,
105
- int96 flowRateAllowance
106
- ) public {
107
- token.setFlowPermissions(flowOperator, allowCreate, allowUpdate, allowDelete, flowRateAllowance);
108
- }
109
-
110
-
111
- function setMaxFlowPermissionsTest(
112
- address flowOperator,
113
- ISuperToken token
114
- ) public {
115
- token.setMaxFlowPermissions(flowOperator);
116
- }
117
-
118
- function revokeFlowPermissionsTest(
119
- address flowOperator,
120
- ISuperToken token
121
- ) public {
122
- token.revokeFlowPermissions(flowOperator);
123
- }
124
-
125
- }
126
-
127
- contract SuperTokenLibraryIDAMock {
128
-
129
- using SuperTokenV1Library for ISuperToken;
130
-
131
- /**************************************************************************
132
- * View Functions
133
- *************************************************************************/
134
-
135
- function getIndexTest(ISuperToken token, address publisher, uint32 indexId)
136
- external view
137
- returns (
138
- bool exist,
139
- uint128 indexValue,
140
- uint128 totalUnitsApproved,
141
- uint128 totalUnitsPending
142
- )
143
- {
144
- return token.getIndex(publisher, indexId);
145
- }
146
-
147
- function calculateDistributionTest(
148
- ISuperToken token,
149
- address publisher,
150
- uint32 indexId,
151
- uint256 amount
152
- )
153
- external view
154
- returns (
155
- uint256 actualAmount,
156
- uint128 newIndexValue
157
- )
158
- {
159
- return token.calculateDistribution(publisher, indexId, amount);
160
- }
161
-
162
- function listSubscriptionsTest(ISuperToken token, address subscriber)
163
- external view
164
- returns (
165
- address[] memory publishers,
166
- uint32[] memory indexIds,
167
- uint128[] memory unitsList
168
- )
169
- {
170
- return token.listSubscriptions(subscriber);
171
- }
172
-
173
- function getSubscriptionTest(
174
- ISuperToken token,
175
- address publisher,
176
- uint32 indexId,
177
- address subscriber
178
- )
179
- external view
180
- returns (
181
- bool exist,
182
- bool approved,
183
- uint128 units,
184
- uint256 pendingDistribution
185
- )
186
- {
187
- return token.getSubscription(publisher, indexId, subscriber);
188
- }
189
-
190
- /// @dev agreementId == keccak256(abi.encodePacked("subscription", subscriber, indexId));
191
- function getSubscriptionByIDTest(ISuperToken token, bytes32 agreementId)
192
- external view
193
- returns (
194
- address publisher,
195
- uint32 indexId,
196
- bool approved,
197
- uint128 units,
198
- uint256 pendingDistribution
199
- )
200
- {
201
- return token.getSubscriptionByID(agreementId);
202
- }
203
-
204
- /**************************************************************************
205
- * Index Operations
206
- *************************************************************************/
207
-
208
- function createIndexTest(ISuperToken token, uint32 indexId) external {
209
- token.createIndex(indexId);
210
- }
211
-
212
- function createIndexWithUserDataTest(
213
- ISuperToken token,
214
- uint32 indexId,
215
- bytes memory userData
216
- ) external {
217
- token.createIndex(indexId, userData);
218
- }
219
-
220
- function updateIndexValueTest(
221
- ISuperToken token,
222
- uint32 indexId,
223
- uint128 indexValue
224
- ) external {
225
- token.updateIndexValue(indexId, indexValue);
226
- }
227
-
228
- function updateIndexValueWithUserDataTest(
229
- ISuperToken token,
230
- uint32 indexId,
231
- uint128 indexValue,
232
- bytes memory userData
233
- ) external {
234
- token.updateIndexValue(indexId, indexValue, userData);
235
- }
236
-
237
- function distributeTest(ISuperToken token, uint32 indexId, uint256 amount) external {
238
- token.distribute(indexId, amount);
239
- }
240
-
241
- function distributeWithUserDataTest(
242
- ISuperToken token,
243
- uint32 indexId,
244
- uint256 amount,
245
- bytes memory userData
246
- ) external {
247
- token.distribute(indexId, amount, userData);
248
- }
249
-
250
- /**************************************************************************
251
- * Subscription Operations
252
- *************************************************************************/
253
-
254
- function approveSubscriptionTest(
255
- ISuperToken token,
256
- address publisher,
257
- uint32 indexId
258
- ) external {
259
- token.approveSubscription(publisher, indexId);
260
- }
261
-
262
- function approveSubscriptionWithUserDataTest(
263
- ISuperToken token,
264
- address publisher,
265
- uint32 indexId,
266
- bytes memory userData
267
- ) external {
268
- token.approveSubscription(publisher, indexId, userData);
269
- }
270
-
271
- function revokeSubscriptionTest(
272
- ISuperToken token,
273
- address publisher,
274
- uint32 indexId
275
- ) external {
276
- token.revokeSubscription(publisher, indexId);
277
- }
278
-
279
- function revokeSubscriptionWithUserDataTest(
280
- ISuperToken token,
281
- address publisher,
282
- uint32 indexId,
283
- bytes memory userData
284
- ) external {
285
- token.revokeSubscription(publisher, indexId, userData);
286
- }
287
-
288
- function updateSubscriptionUnitsTest(
289
- ISuperToken token,
290
- uint32 indexId,
291
- address subscriber,
292
- uint128 units
293
- ) external {
294
- token.updateSubscriptionUnits(indexId, subscriber, units);
295
- }
296
-
297
- function updateSubscriptionUnitsWithUserDataTest(
298
- ISuperToken token,
299
- uint32 indexId,
300
- address subscriber,
301
- uint128 units,
302
- bytes memory userData
303
- ) external {
304
- token.updateSubscriptionUnits(indexId, subscriber, units, userData);
305
- }
306
-
307
- function deleteSubscriptionTest(
308
- ISuperToken token,
309
- address publisher,
310
- uint32 indexId,
311
- address subscriber
312
- ) external {
313
- token.deleteSubscription(publisher, indexId, subscriber);
314
- }
315
-
316
- function deleteSubscriptionWithUserDataTest(
317
- ISuperToken token,
318
- address publisher,
319
- uint32 indexId,
320
- address subscriber,
321
- bytes memory userData
322
- ) external {
323
- token.deleteSubscription(publisher, indexId, subscriber, userData);
324
- }
325
-
326
- function claimTest(
327
- ISuperToken token,
328
- address publisher,
329
- uint32 indexId,
330
- address subscriber
331
- ) external {
332
- token.claim(publisher, indexId, subscriber);
333
- }
334
-
335
- function claimWithUserDataTest(
336
- ISuperToken token,
337
- address publisher,
338
- uint32 indexId,
339
- address subscriber,
340
- bytes memory userData
341
- ) external {
342
- token.claim(publisher, indexId, subscriber, userData);
343
- }
344
- }
345
-
346
- contract SuperTokenLibraryCFASuperAppMock is SuperAppBase {
347
-
348
- using SuperTokenV1Library for ISuperToken;
349
-
350
- // default values for smoke tests
351
- address internal immutable sender;
352
- address internal immutable receiver;
353
- address internal immutable flowOperator;
354
- ISuperfluid internal host;
355
-
356
- // for selectively testing functions in the same callback
357
- enum FunctionIndex {
358
- CREATE_FLOW,
359
- UPDATE_FLOW,
360
- DELETE_FLOW,
361
- CREATE_FLOW_BY_OPERATOR,
362
- UPDATE_FLOW_BY_OPERATOR,
363
- DELETE_FLOW_BY_OPERATOR,
364
- UPDATE_FLOW_OPERATOR_PERMISSIONS,
365
- AUTHORIZE_FLOW_OPERATOR_WITH_FULL_CONTROL,
366
- REVOKE_FLOW_OPERATOR_WITH_FULL_CONTROL
367
- }
368
-
369
- constructor(
370
- ISuperfluid _host,
371
- address defaultSender,
372
- address defaultReceiver,
373
- address defaultFlowOperator
374
- ) {
375
- host = _host;
376
- sender = defaultSender;
377
- receiver = defaultReceiver;
378
- flowOperator = defaultFlowOperator;
379
-
380
- uint256 configWord = SuperAppDefinitions.APP_LEVEL_FINAL |
381
- SuperAppDefinitions.BEFORE_AGREEMENT_CREATED_NOOP |
382
- // SuperAppDefinitions.AFTER_AGREEMENT_CREATED_NOOP |
383
- SuperAppDefinitions.BEFORE_AGREEMENT_UPDATED_NOOP |
384
- SuperAppDefinitions.AFTER_AGREEMENT_UPDATED_NOOP |
385
- SuperAppDefinitions.BEFORE_AGREEMENT_TERMINATED_NOOP |
386
- SuperAppDefinitions.AFTER_AGREEMENT_TERMINATED_NOOP;
387
-
388
- host.registerAppWithKey(configWord, "");
389
- }
390
-
391
- function createFlow(ISuperToken token) external {
392
- token.createFlow(receiver, 1000000000000);
393
- }
394
-
395
- // literally ONLY for the revokeFlowOperatorWithFullControlWithCtx test.
396
- function authorizeFlowOperatorWithFullControl(ISuperToken token) external {
397
- token.setMaxFlowPermissions(flowOperator);
398
- }
399
-
400
- function processTxAndReturnCtx(ISuperToken token, bytes memory ctx) internal returns (bytes memory updatedCtx) {
401
- uint8 functionIndex = abi.decode(host.decodeCtx(ctx).userData, (uint8));
402
-
403
- if (functionIndex == uint8(FunctionIndex.CREATE_FLOW))
404
- return token.createFlowWithCtx(receiver, 1000000000000, ctx);
405
- else if (functionIndex == uint8(FunctionIndex.UPDATE_FLOW))
406
- return token.updateFlowWithCtx(receiver, 2000000000000, ctx);
407
- else if (functionIndex == uint8(FunctionIndex.DELETE_FLOW))
408
- return token.deleteFlowWithCtx(address(this), receiver, ctx);
409
- else if (functionIndex == uint8(FunctionIndex.CREATE_FLOW_BY_OPERATOR))
410
- return token.createFlowFromWithCtx(sender, receiver, 1000000000000, ctx);
411
- else if (functionIndex == uint8(FunctionIndex.UPDATE_FLOW_BY_OPERATOR))
412
- return token.updateFlowFromWithCtx(sender, receiver, 2000000000000, ctx);
413
- else if (functionIndex == uint8(FunctionIndex.DELETE_FLOW_BY_OPERATOR))
414
- return token.deleteFlowFromWithCtx(sender, receiver, ctx);
415
- else if (functionIndex == uint8(FunctionIndex.UPDATE_FLOW_OPERATOR_PERMISSIONS))
416
- return token.setFlowPermissionsWithCtx(
417
- flowOperator,
418
- true,
419
- true,
420
- true,
421
- 1000000000000,
422
- ctx
423
- );
424
- else if (functionIndex == uint8(FunctionIndex.AUTHORIZE_FLOW_OPERATOR_WITH_FULL_CONTROL))
425
- return token.setMaxFlowPermissionsWithCtx(flowOperator, ctx);
426
- else if (functionIndex == uint8(FunctionIndex.REVOKE_FLOW_OPERATOR_WITH_FULL_CONTROL))
427
- return token.revokeFlowPermissionsWithCtx(flowOperator, ctx);
428
- else revert("invalid function index");
429
- }
430
-
431
- function afterAgreementCreated(
432
- ISuperToken token,
433
- address,
434
- bytes32,
435
- bytes calldata,
436
- bytes calldata,
437
- bytes calldata ctx
438
- ) external override returns (bytes memory newCtx) {
439
- newCtx = processTxAndReturnCtx(token, ctx);
440
- }
441
- }
442
-
443
- // IDA LIBRARY SUPER APP CALLBACK MOCK
444
- contract SuperTokenLibraryIDASuperAppMock is SuperTokenLibraryIDAMock, SuperAppBase {
445
-
446
- using SuperTokenV1Library for ISuperToken;
447
-
448
- bytes internal constant _MOCK_USER_DATA = abi.encode("oh hello");
449
- ISuperfluid internal host;
450
-
451
- constructor(ISuperfluid _host) SuperTokenLibraryIDAMock() {
452
- host = _host;
453
- uint256 configWord = SuperAppDefinitions.APP_LEVEL_FINAL |
454
- SuperAppDefinitions.BEFORE_AGREEMENT_CREATED_NOOP |
455
- // SuperAppDefinitions.AFTER_AGREEMENT_CREATED_NOOP |
456
- SuperAppDefinitions.BEFORE_AGREEMENT_UPDATED_NOOP |
457
- // SuperAppDefinitions.AFTER_AGREEMENT_UPDATED_NOOP |
458
- SuperAppDefinitions.BEFORE_AGREEMENT_TERMINATED_NOOP |
459
- SuperAppDefinitions.AFTER_AGREEMENT_TERMINATED_NOOP;
460
-
461
- host.registerAppWithKey(configWord, "");
462
- }
463
-
464
- function afterAgreementCreated(
465
- ISuperToken token,
466
- address,
467
- bytes32,
468
- bytes calldata,
469
- bytes calldata,
470
- bytes calldata ctx
471
- ) external override returns (bytes memory newCtx) {
472
- return _callbackTest(token, ctx);
473
- }
474
-
475
- function afterAgreementUpdated(
476
- ISuperToken token,
477
- address,
478
- bytes32,
479
- bytes calldata,
480
- bytes calldata,
481
- bytes calldata ctx
482
- ) external override returns (bytes memory newCtx) {
483
- return _callbackTest(token, ctx);
484
- }
485
-
486
- enum FunctionIndex {
487
- CREATE_INDEX,
488
- CREATE_INDEX_USER_DATA,
489
- UPDATE_INDEX,
490
- UPDATE_INDEX_USER_DATA,
491
- DISTRIBUTE,
492
- DISTRIBUTE_USER_DATA,
493
- APROVE_SUBSCRIPTION,
494
- APROVE_SUBSCRIPTION_USER_DATA,
495
- REVOKE_SUBSCRIPTION,
496
- REVOKE_SUBSCRIPTION_USER_DATA,
497
- UPDATE_SUBSCRIPTION,
498
- UPDATE_SUBSCRIPTION_USER_DATA,
499
- DELETE_SUBSCRIPTION,
500
- DELETE_SUBSCRIPTION_USER_DATA,
501
- CLAIM,
502
- CLAIM_USER_DATA
503
- }
504
-
505
- /// @dev extracts some user data to test out all callback library functions
506
- /// @param token super token
507
- /// @param ctx Context string
508
- /// @return New Context
509
- function _callbackTest(
510
- ISuperToken token,
511
- bytes memory ctx
512
- ) internal returns (bytes memory) {
513
-
514
- // extract userData, then decode everything else
515
- bytes memory userData = host.decodeCtx(ctx).userData;
516
- (
517
- uint8 functionIndex,
518
- uint32 indexId,
519
- address publisher,
520
- address subscriber,
521
- uint128 units
522
- ) = abi.decode(userData, (uint8, uint32, address, address, uint128));
523
-
524
- if (functionIndex == uint8(FunctionIndex.CREATE_INDEX)) {
525
- return token.createIndexWithCtx(indexId, ctx);
526
- } else if (functionIndex == uint8(FunctionIndex.CREATE_INDEX_USER_DATA)) {
527
- return token.createIndexWithCtx(indexId, ctx);
528
- } else if (functionIndex == uint8(FunctionIndex.UPDATE_INDEX)) {
529
- return token.updateIndexValueWithCtx(indexId, units, ctx);
530
- } else if (functionIndex == uint8(FunctionIndex.UPDATE_INDEX_USER_DATA)) {
531
- return token.updateIndexValueWithCtx(indexId, units, ctx);
532
- } else if (functionIndex == uint8(FunctionIndex.DISTRIBUTE)) {
533
- return token.distributeWithCtx(indexId, units, ctx);
534
- } else if (functionIndex == uint8(FunctionIndex.DISTRIBUTE_USER_DATA)) {
535
- return token.distributeWithCtx(indexId, units, ctx);
536
- } else if (functionIndex == uint8(FunctionIndex.APROVE_SUBSCRIPTION)) {
537
- return token.approveSubscriptionWithCtx(publisher, indexId, ctx);
538
- } else if (functionIndex == uint8(FunctionIndex.APROVE_SUBSCRIPTION_USER_DATA)) {
539
- return token.approveSubscriptionWithCtx(
540
- publisher,
541
- indexId,
542
- ctx
543
- );
544
- } else if (functionIndex == uint8(FunctionIndex.REVOKE_SUBSCRIPTION)) {
545
- return token.revokeSubscriptionWithCtx(publisher, indexId, ctx);
546
- } else if (functionIndex == uint8(FunctionIndex.REVOKE_SUBSCRIPTION_USER_DATA)) {
547
- return token.revokeSubscriptionWithCtx(
548
- publisher,
549
- indexId,
550
- ctx
551
- );
552
- } else if (functionIndex == uint8(FunctionIndex.UPDATE_SUBSCRIPTION)) {
553
- return token.updateSubscriptionUnitsWithCtx(indexId, subscriber, units, ctx);
554
- } else if (functionIndex == uint8(FunctionIndex.UPDATE_SUBSCRIPTION_USER_DATA)) {
555
- return token.updateSubscriptionUnitsWithCtx(
556
- indexId,
557
- subscriber,
558
- units,
559
- ctx
560
- );
561
- } else if (functionIndex == uint8(FunctionIndex.DELETE_SUBSCRIPTION)) {
562
- return token.deleteSubscriptionWithCtx(publisher, indexId, subscriber, ctx);
563
- } else if (functionIndex == uint8(FunctionIndex.DELETE_SUBSCRIPTION_USER_DATA)) {
564
- return token.deleteSubscriptionWithCtx(
565
- publisher,
566
- indexId,
567
- subscriber,
568
- ctx
569
- );
570
- } else if (functionIndex == uint8(FunctionIndex.CLAIM)) {
571
- return token.claimWithCtx(publisher, indexId, subscriber, ctx);
572
- } else if (functionIndex == uint8(FunctionIndex.CLAIM_USER_DATA)) {
573
- return token.claimWithCtx(
574
- publisher,
575
- indexId,
576
- subscriber,
577
- ctx
578
- );
579
- } else {
580
- revert("invalid function index");
581
- }
582
- }
583
- }
@@ -1,113 +0,0 @@
1
- // SPDX-License-Identifier: AGPLv3
2
- pragma solidity 0.8.18;
3
-
4
- import {
5
- ISuperfluid,
6
- ISuperAgreement,
7
- SuperToken
8
- } from "../superfluid/SuperToken.sol";
9
-
10
- contract SuperTokenStorageLayoutTester is SuperToken {
11
-
12
- constructor(ISuperfluid host)
13
- SuperToken(host)
14
- // solhint-disable-next-line no-empty-blocks
15
- {
16
- }
17
-
18
- // @dev Make sure the storage layout never change over the course of the development
19
- function validateStorageLayout() external pure {
20
- uint256 slot;
21
- uint256 offset;
22
-
23
- // Initializable _initialized and _initialized
24
-
25
- // SuperfluidToken storages
26
-
27
- assembly { slot:= _inactiveAgreementBitmap.slot offset := _inactiveAgreementBitmap.offset }
28
- require (slot == 1 && offset == 0, "_inactiveAgreementBitmap changed location");
29
-
30
- assembly { slot:= _sharedSettledBalances.slot offset := _sharedSettledBalances.offset }
31
- require (slot == 2 && offset == 0, "_sharedSettledBalances changed location");
32
-
33
- assembly { slot:= _totalSupply.slot offset := _totalSupply.offset }
34
- require (slot == 3 && offset == 0, "_totalSupply changed location");
35
-
36
- assembly { slot:= _reserve4.slot offset := _reserve4.offset }
37
- require (slot == 4 && offset == 0, "_reserve4 changed location");
38
-
39
- assembly { slot:= _reserve13.slot offset := _reserve13.offset }
40
- require (slot == 13 && offset == 0, "_reserve9 changed location");
41
-
42
- // SuperToken storages
43
-
44
- assembly { slot:= _underlyingToken.slot offset := _underlyingToken.offset }
45
- require (slot == 14 && offset == 0, "_underlyingToken changed location");
46
-
47
- assembly { slot:= _underlyingDecimals.slot offset := _underlyingDecimals.offset }
48
- require (slot == 14 && offset == 20, "_underlyingDecimals changed location");
49
-
50
- assembly { slot:= _name.slot offset := _name.offset }
51
- require (slot == 15 && offset == 0, "_name changed location");
52
-
53
- assembly { slot:= _symbol.slot offset := _symbol.offset }
54
- require (slot == 16 && offset == 0, "_symbol changed location");
55
-
56
- assembly { slot:= _allowances.slot offset := _allowances.offset }
57
- require (slot == 17 && offset == 0, "_allowances changed location");
58
-
59
- assembly { slot:= _operators.slot offset := _operators.offset }
60
- require (slot == 18 && offset == 0, "_operators changed location");
61
- // uses 4 slots
62
-
63
- assembly { slot:= _reserve22.slot offset := _reserve22.offset }
64
- require (slot == 22 && offset == 0, "_reserve22 changed location");
65
-
66
- assembly { slot:= _reserve31.slot offset := _reserve31.offset }
67
- require (slot == 31 && offset == 0, "_reserve31 changed location");
68
- }
69
-
70
- function getLastSuperTokenStorageSlot() external pure returns (uint slot) {
71
- assembly { slot:= _reserve31.slot }
72
- }
73
- }
74
-
75
- contract SuperTokenMock is SuperToken {
76
-
77
- uint256 immutable public waterMark;
78
-
79
- constructor(ISuperfluid host, uint256 w)
80
- SuperToken(host)
81
- {
82
- waterMark = w;
83
- }
84
-
85
- /**
86
- * ERC-20 mockings
87
- */
88
- function approveInternal(address owner, address spender, uint256 value) external {
89
- _approve(owner, spender, value);
90
- }
91
-
92
- function transferInternal(address from, address to, uint256 value) external {
93
- _transferFrom(from, from, to, value);
94
- }
95
-
96
- /**
97
- * ERC-777 mockings
98
- */
99
- function setupDefaultOperators(address[] memory operators) external {
100
- _setupDefaultOperators(operators);
101
- }
102
-
103
- function mintInternal(
104
- address to,
105
- uint256 amount,
106
- bytes memory userData,
107
- bytes memory operatorData
108
- ) external {
109
- // set requireReceptionAck to true always
110
- _mint(msg.sender, to, amount, true, userData, operatorData);
111
- }
112
-
113
- }
@@ -1,14 +0,0 @@
1
- // SPDX-License-Identifier: AGPLv3
2
- // solhint-disable
3
- pragma solidity 0.8.18;
4
-
5
- contract SuperfluidDestructorMock {
6
-
7
- bool immutable public NON_UPGRADABLE_DEPLOYMENT = false;
8
-
9
- fallback() external {
10
- // this == impl in this call
11
- selfdestruct(payable(0));
12
- }
13
-
14
- }