@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.
- package/build/contracts/AccessControl.json +1 -1
- package/build/contracts/AccessControlEnumerable.json +1 -1
- package/build/contracts/Address.json +1 -1
- package/build/contracts/AgreementBase.json +1 -1
- package/build/contracts/AgreementLibrary.json +1 -1
- package/build/contracts/BaseRelayRecipient.json +1 -1
- package/build/contracts/BatchLiquidator.json +1 -1
- package/build/contracts/BatchOperation.json +1 -1
- package/build/contracts/CFAv1Forwarder.json +1 -1
- package/build/contracts/CFAv1Library.json +1 -1
- package/build/contracts/CallUtils.json +1 -1
- package/build/contracts/ClosingOnUpdateFlowTestApp.json +1 -1
- package/build/contracts/ConstantFlowAgreementV1.json +1 -1
- package/build/contracts/Context.json +1 -1
- package/build/contracts/ContextDefinitions.json +1 -1
- package/build/contracts/CustomSuperTokenBase.json +1 -1
- package/build/contracts/ERC165.json +1 -1
- package/build/contracts/ERC1820Implementer.json +1 -1
- package/build/contracts/ERC1820RegistryCompiled.json +1 -1
- package/build/contracts/ERC20.json +1 -1
- package/build/contracts/ERC20WithTokenInfo.json +1 -1
- package/build/contracts/ERC777Helper.json +1 -1
- package/build/contracts/ERC777RecipientDrainingGas.json +1 -1
- package/build/contracts/ERC777RecipientReverting.json +1 -1
- package/build/contracts/EnumerableSet.json +1 -1
- package/build/contracts/EventsEmitter.json +1 -1
- package/build/contracts/ExclusiveInflowTestApp.json +1 -1
- package/build/contracts/FixedSizeData.json +1 -1
- package/build/contracts/FlowExchangeTestApp.json +1 -1
- package/build/contracts/FlowOperatorDefinitions.json +1 -1
- package/build/contracts/FullUpgradableSuperTokenProxy.json +1 -1
- package/build/contracts/IAccessControl.json +1 -1
- package/build/contracts/IAccessControlEnumerable.json +1 -1
- package/build/contracts/IConstantFlowAgreementHook.json +1 -1
- package/build/contracts/IConstantFlowAgreementV1.json +1 -1
- package/build/contracts/IDAv1Library.json +1 -1
- package/build/contracts/IERC165.json +1 -1
- package/build/contracts/IERC1820Implementer.json +1 -1
- package/build/contracts/IERC1820Registry.json +1 -1
- package/build/contracts/IERC20.json +1 -1
- package/build/contracts/IERC20Metadata.json +1 -1
- package/build/contracts/IERC20Permit.json +1 -1
- package/build/contracts/IERC777.json +1 -1
- package/build/contracts/IERC777Recipient.json +1 -1
- package/build/contracts/IERC777Sender.json +1 -1
- package/build/contracts/IInstantDistributionAgreementV1.json +1 -1
- package/build/contracts/IMultiSigWallet.json +1 -1
- package/build/contracts/IPureSuperToken.json +1 -1
- package/build/contracts/IPureSuperTokenCustom.json +1 -1
- package/build/contracts/IRelayRecipient.json +1 -1
- package/build/contracts/IResolver.json +1 -1
- package/build/contracts/ISETH.json +1 -1
- package/build/contracts/ISETHCustom.json +1 -1
- package/build/contracts/ISuperAgreement.json +1 -1
- package/build/contracts/ISuperApp.json +1 -1
- package/build/contracts/ISuperToken.json +1 -1
- package/build/contracts/ISuperTokenFactory.json +1 -1
- package/build/contracts/ISuperfluid.json +1 -1
- package/build/contracts/ISuperfluidGovernance.json +1 -1
- package/build/contracts/ISuperfluidToken.json +1 -1
- package/build/contracts/ITOGAv1.json +1 -1
- package/build/contracts/ITOGAv2.json +1 -1
- package/build/contracts/ITOGAv3.json +1 -1
- package/build/contracts/Initializable.json +1 -1
- package/build/contracts/InstantDistributionAgreementV1.json +1 -1
- package/build/contracts/Math.json +1 -1
- package/build/contracts/NonClosableOutflowTestApp.json +1 -1
- package/build/contracts/Ownable.json +1 -1
- package/build/contracts/Proxy.json +1 -1
- package/build/contracts/PureSuperToken.json +1 -1
- package/build/contracts/Resolver.json +1 -1
- package/build/contracts/SETHProxy.json +1 -1
- package/build/contracts/SafeCast.json +1 -1
- package/build/contracts/SafeERC20.json +1 -1
- package/build/contracts/SafeMath.json +1 -1
- package/build/contracts/SelfDeletingFlowTestApp.json +1 -1
- package/build/contracts/SlotsBitmapLibrary.json +1 -1
- package/build/contracts/StreamRedirector.json +1 -1
- package/build/contracts/Strings.json +1 -1
- package/build/contracts/SuperAppBase.json +1 -1
- package/build/contracts/SuperAppDefinitions.json +1 -1
- package/build/contracts/SuperToken.json +1 -1
- package/build/contracts/SuperTokenDeployerLibrary.json +1 -1
- package/build/contracts/SuperTokenFactory.json +1 -1
- package/build/contracts/SuperTokenFactoryBase.json +1 -1
- package/build/contracts/SuperTokenV1Library.json +1 -1
- package/build/contracts/SuperUpgrader.json +1 -1
- package/build/contracts/Superfluid.json +1 -1
- package/build/contracts/SuperfluidCFAv1DeployerLibrary.json +1 -1
- package/build/contracts/SuperfluidFrameworkDeployer.json +1 -1
- package/build/contracts/SuperfluidGovDeployerLibrary.json +1 -1
- package/build/contracts/SuperfluidGovernanceBase.json +1 -1
- package/build/contracts/SuperfluidGovernanceConfigs.json +1 -1
- package/build/contracts/SuperfluidGovernanceII.json +1 -1
- package/build/contracts/SuperfluidGovernanceIIProxy.json +1 -1
- package/build/contracts/SuperfluidHostDeployerLibrary.json +1 -1
- package/build/contracts/SuperfluidIDAv1DeployerLibrary.json +1 -1
- package/build/contracts/SuperfluidLoader.json +1 -1
- package/build/contracts/SuperfluidPeripheryDeployerLibrary.json +1 -1
- package/build/contracts/SuperfluidToken.json +1 -1
- package/build/contracts/TOGA.json +1 -1
- package/build/contracts/TestGovernance.json +1 -1
- package/build/contracts/TestResolver.json +1 -1
- package/build/contracts/TestToken.json +1 -1
- package/build/contracts/TokenInfo.json +1 -1
- package/build/contracts/UUPSProxiable.json +1 -1
- package/build/contracts/UUPSProxy.json +1 -1
- package/build/contracts/UUPSUtils.json +1 -1
- package/build/contracts-sizes.txt +9 -9
- package/package.json +2 -2
- package/contracts/mocks/AgreementMock.sol +0 -375
- package/contracts/mocks/CFAAppMocks.sol +0 -361
- package/contracts/mocks/CFAHookMocks.sol +0 -148
- package/contracts/mocks/CFALibraryMock.sol +0 -213
- package/contracts/mocks/CallUtilsMock.sol +0 -79
- package/contracts/mocks/CallUtilsTester.sol +0 -14
- package/contracts/mocks/CustomSuperTokenMock.sol +0 -104
- package/contracts/mocks/ERC777SenderRecipientMock.sol +0 -238
- package/contracts/mocks/FakeSuperfluidMock.sol +0 -21
- package/contracts/mocks/ForwarderMock.sol +0 -39
- package/contracts/mocks/IDASuperAppTester.sol +0 -297
- package/contracts/mocks/IDAv1LibraryMock.sol +0 -400
- package/contracts/mocks/MockSmartWallet.sol +0 -15
- package/contracts/mocks/MultiFlowTesterApp.sol +0 -336
- package/contracts/mocks/StreamRedirector.sol +0 -179
- package/contracts/mocks/SuperAppMocks.sol +0 -622
- package/contracts/mocks/SuperTokenFactoryMock.sol +0 -98
- package/contracts/mocks/SuperTokenLibraryV1Mock.sol +0 -583
- package/contracts/mocks/SuperTokenMock.sol +0 -113
- package/contracts/mocks/SuperfluidDestructorMock.sol +0 -14
- package/contracts/mocks/SuperfluidGovernanceIIMock.sol +0 -22
- package/contracts/mocks/SuperfluidMock.sol +0 -177
- package/contracts/mocks/UUPSProxiableMock.sol +0 -29
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity 0.8.18;
|
|
3
|
-
|
|
4
|
-
import {ISuperfluid, ISuperfluidToken, ISuperToken} from "../interfaces/superfluid/ISuperfluid.sol";
|
|
5
|
-
|
|
6
|
-
import {ISuperApp, ISuperAgreement} from "../interfaces/superfluid/ISuperfluid.sol";
|
|
7
|
-
|
|
8
|
-
import {ContextDefinitions, SuperAppDefinitions} from "../interfaces/superfluid/ISuperfluid.sol";
|
|
9
|
-
|
|
10
|
-
import {SuperAppBase} from "../apps/SuperAppBase.sol";
|
|
11
|
-
|
|
12
|
-
import {IConstantFlowAgreementV1} from "../interfaces/agreements/IConstantFlowAgreementV1.sol";
|
|
13
|
-
|
|
14
|
-
import {CFAv1Library} from "../apps/CFAv1Library.sol";
|
|
15
|
-
|
|
16
|
-
contract CFALibraryMock {
|
|
17
|
-
using CFAv1Library for CFAv1Library.InitData;
|
|
18
|
-
|
|
19
|
-
//initialize cfaV1 variable
|
|
20
|
-
CFAv1Library.InitData public cfaV1;
|
|
21
|
-
|
|
22
|
-
constructor(ISuperfluid host) {
|
|
23
|
-
//initialize InitData struct, and set equal to cfaV1
|
|
24
|
-
cfaV1 = CFAv1Library.InitData(
|
|
25
|
-
host,
|
|
26
|
-
IConstantFlowAgreementV1(
|
|
27
|
-
address(
|
|
28
|
-
host.getAgreementClass(
|
|
29
|
-
keccak256(
|
|
30
|
-
"org.superfluid-finance.agreements.ConstantFlowAgreement.v1"
|
|
31
|
-
)
|
|
32
|
-
)
|
|
33
|
-
)
|
|
34
|
-
)
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function createFlowTest(
|
|
39
|
-
ISuperfluidToken token,
|
|
40
|
-
address receiver,
|
|
41
|
-
int96 flowRate
|
|
42
|
-
) public {
|
|
43
|
-
cfaV1.createFlow(receiver, token, flowRate);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function updateFlowTest(
|
|
47
|
-
ISuperfluidToken token,
|
|
48
|
-
address receiver,
|
|
49
|
-
int96 flowRate
|
|
50
|
-
) public {
|
|
51
|
-
cfaV1.updateFlow(receiver, token, flowRate);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function deleteFlowTest(ISuperfluidToken token, address receiver) public {
|
|
55
|
-
cfaV1.deleteFlow(address(this), receiver, token);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function createFlowByOperatorTest(
|
|
59
|
-
address sender,
|
|
60
|
-
address receiver,
|
|
61
|
-
ISuperfluidToken token,
|
|
62
|
-
int96 flowRate
|
|
63
|
-
) public {
|
|
64
|
-
cfaV1.createFlowByOperator(sender, receiver, token, flowRate);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function updateFlowByOperatorTest(
|
|
68
|
-
address sender,
|
|
69
|
-
address receiver,
|
|
70
|
-
ISuperfluidToken token,
|
|
71
|
-
int96 flowRate
|
|
72
|
-
) public {
|
|
73
|
-
cfaV1.updateFlowByOperator(sender, receiver, token, flowRate);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function deleteFlowByOperator(
|
|
77
|
-
address sender,
|
|
78
|
-
address receiver,
|
|
79
|
-
ISuperfluidToken token
|
|
80
|
-
) public {
|
|
81
|
-
cfaV1.deleteFlowByOperator(sender, receiver, token);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function updateFlowOperatorPermissionsTest(
|
|
85
|
-
address flowOperator,
|
|
86
|
-
ISuperfluidToken token,
|
|
87
|
-
uint8 permissions,
|
|
88
|
-
int96 flowRateAllowance
|
|
89
|
-
) public {
|
|
90
|
-
cfaV1.updateFlowOperatorPermissions(flowOperator, token, permissions, flowRateAllowance);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function authorizeFlowOperatorWithFullControlTest(
|
|
94
|
-
address flowOperator,
|
|
95
|
-
ISuperfluidToken token
|
|
96
|
-
) public {
|
|
97
|
-
cfaV1.authorizeFlowOperatorWithFullControl(flowOperator, token);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function revokeFlowOperatorWithFullControlTest(
|
|
101
|
-
address flowOperator,
|
|
102
|
-
ISuperfluidToken token
|
|
103
|
-
) public {
|
|
104
|
-
cfaV1.revokeFlowOperatorWithFullControl(flowOperator, token);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
contract CFALibrarySuperAppMock is SuperAppBase {
|
|
109
|
-
|
|
110
|
-
using CFAv1Library for CFAv1Library.InitData;
|
|
111
|
-
CFAv1Library.InitData internal cfaV1;
|
|
112
|
-
|
|
113
|
-
// default values for smoke tests
|
|
114
|
-
uint8 internal constant PERMISSIONS = 7;
|
|
115
|
-
int96 internal constant FLOW_RATE = 1000000000000;
|
|
116
|
-
int96 internal constant UPDATED_FLOW_RATE = 2000000000000;
|
|
117
|
-
address internal immutable sender;
|
|
118
|
-
address internal immutable receiver;
|
|
119
|
-
address internal immutable flowOperator;
|
|
120
|
-
|
|
121
|
-
// for selectively testing functions in the same callback
|
|
122
|
-
enum FunctionIndex {
|
|
123
|
-
CREATE_FLOW,
|
|
124
|
-
UPDATE_FLOW,
|
|
125
|
-
DELETE_FLOW,
|
|
126
|
-
CREATE_FLOW_BY_OPERATOR,
|
|
127
|
-
UPDATE_FLOW_BY_OPERATOR,
|
|
128
|
-
DELETE_FLOW_BY_OPERATOR,
|
|
129
|
-
UPDATE_FLOW_OPERATOR_PERMISSIONS,
|
|
130
|
-
AUTHORIZE_FLOW_OPERATOR_WITH_FULL_CONTROL,
|
|
131
|
-
REVOKE_FLOW_OPERATOR_WITH_FULL_CONTROL
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
constructor(
|
|
135
|
-
ISuperfluid host,
|
|
136
|
-
address defaultSender,
|
|
137
|
-
address defaultReceiver,
|
|
138
|
-
address defaultFlowOperator
|
|
139
|
-
) {
|
|
140
|
-
cfaV1 = CFAv1Library.InitData(
|
|
141
|
-
host,
|
|
142
|
-
IConstantFlowAgreementV1(
|
|
143
|
-
address(
|
|
144
|
-
host.getAgreementClass(
|
|
145
|
-
keccak256(
|
|
146
|
-
"org.superfluid-finance.agreements.ConstantFlowAgreement.v1"
|
|
147
|
-
)
|
|
148
|
-
)
|
|
149
|
-
)
|
|
150
|
-
)
|
|
151
|
-
);
|
|
152
|
-
sender = defaultSender;
|
|
153
|
-
receiver = defaultReceiver;
|
|
154
|
-
flowOperator = defaultFlowOperator;
|
|
155
|
-
|
|
156
|
-
uint256 configWord = SuperAppDefinitions.APP_LEVEL_FINAL |
|
|
157
|
-
SuperAppDefinitions.BEFORE_AGREEMENT_CREATED_NOOP |
|
|
158
|
-
// SuperAppDefinitions.AFTER_AGREEMENT_CREATED_NOOP |
|
|
159
|
-
SuperAppDefinitions.BEFORE_AGREEMENT_UPDATED_NOOP |
|
|
160
|
-
SuperAppDefinitions.AFTER_AGREEMENT_UPDATED_NOOP |
|
|
161
|
-
SuperAppDefinitions.BEFORE_AGREEMENT_TERMINATED_NOOP |
|
|
162
|
-
SuperAppDefinitions.AFTER_AGREEMENT_TERMINATED_NOOP;
|
|
163
|
-
|
|
164
|
-
host.registerAppWithKey(configWord, "");
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
function createFlow(ISuperToken token) external {
|
|
168
|
-
cfaV1.createFlow(receiver, token, FLOW_RATE);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// literally ONLY for the revokeFlowOperatorWithFullControlWithCtx test.
|
|
172
|
-
function authorizeFlowOperatorWithFullControl(ISuperToken token) external {
|
|
173
|
-
cfaV1.authorizeFlowOperatorWithFullControl(flowOperator, token);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
function afterAgreementCreated(
|
|
177
|
-
ISuperToken token,
|
|
178
|
-
address,
|
|
179
|
-
bytes32,
|
|
180
|
-
bytes calldata,
|
|
181
|
-
bytes calldata,
|
|
182
|
-
bytes calldata ctx
|
|
183
|
-
) external override returns (bytes memory) {
|
|
184
|
-
bytes memory userData = cfaV1.host.decodeCtx(ctx).userData;
|
|
185
|
-
(uint8 functionIndex) = abi.decode(userData, (uint8));
|
|
186
|
-
|
|
187
|
-
if (functionIndex == uint8(FunctionIndex.CREATE_FLOW))
|
|
188
|
-
return cfaV1.createFlowWithCtx(ctx, receiver, token, FLOW_RATE);
|
|
189
|
-
else if (functionIndex == uint8(FunctionIndex.UPDATE_FLOW))
|
|
190
|
-
return cfaV1.updateFlowWithCtx(ctx, receiver, token, UPDATED_FLOW_RATE);
|
|
191
|
-
else if (functionIndex == uint8(FunctionIndex.DELETE_FLOW))
|
|
192
|
-
return cfaV1.deleteFlowWithCtx(ctx, address(this), receiver, token);
|
|
193
|
-
else if (functionIndex == uint8(FunctionIndex.CREATE_FLOW_BY_OPERATOR))
|
|
194
|
-
return cfaV1.createFlowByOperatorWithCtx(ctx, sender, receiver, token, FLOW_RATE);
|
|
195
|
-
else if (functionIndex == uint8(FunctionIndex.UPDATE_FLOW_BY_OPERATOR))
|
|
196
|
-
return cfaV1.updateFlowByOperatorWithCtx(ctx, sender, receiver, token, UPDATED_FLOW_RATE);
|
|
197
|
-
else if (functionIndex == uint8(FunctionIndex.DELETE_FLOW_BY_OPERATOR))
|
|
198
|
-
return cfaV1.deleteFlowByOperatorWithCtx(ctx, sender, receiver, token);
|
|
199
|
-
else if (functionIndex == uint8(FunctionIndex.UPDATE_FLOW_OPERATOR_PERMISSIONS))
|
|
200
|
-
return cfaV1.updateFlowOperatorPermissionsWithCtx(
|
|
201
|
-
ctx,
|
|
202
|
-
flowOperator,
|
|
203
|
-
token,
|
|
204
|
-
PERMISSIONS,
|
|
205
|
-
FLOW_RATE
|
|
206
|
-
);
|
|
207
|
-
else if (functionIndex == uint8(FunctionIndex.AUTHORIZE_FLOW_OPERATOR_WITH_FULL_CONTROL))
|
|
208
|
-
return cfaV1.authorizeFlowOperatorWithFullControlWithCtx(ctx, flowOperator, token);
|
|
209
|
-
else if (functionIndex == uint8(FunctionIndex.REVOKE_FLOW_OPERATOR_WITH_FULL_CONTROL))
|
|
210
|
-
return cfaV1.revokeFlowOperatorWithFullControlWithCtx(ctx, flowOperator, token);
|
|
211
|
-
else revert("invalid function index");
|
|
212
|
-
}
|
|
213
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: AGPLv3
|
|
2
|
-
pragma solidity 0.8.18;
|
|
3
|
-
|
|
4
|
-
import { CallUtils } from "../libs/CallUtils.sol";
|
|
5
|
-
|
|
6
|
-
contract CallUtilsMock {
|
|
7
|
-
error Custom();
|
|
8
|
-
error CustomVal(uint256);
|
|
9
|
-
|
|
10
|
-
enum Gm { Ngmi }
|
|
11
|
-
|
|
12
|
-
uint[] public a;
|
|
13
|
-
// case 1: catch all
|
|
14
|
-
function revertEmpty() public pure {
|
|
15
|
-
// solhint-disable-next-line reason-string
|
|
16
|
-
revert();
|
|
17
|
-
}
|
|
18
|
-
// case 2: (Panic(uint256)) 0x01
|
|
19
|
-
function revertAssert() public pure {
|
|
20
|
-
assert(false);
|
|
21
|
-
}
|
|
22
|
-
// case 2: (Panic(uint256)) 0x11
|
|
23
|
-
function revertOverflow() public pure returns(uint) {
|
|
24
|
-
uint b = type(uint256).max + 1;
|
|
25
|
-
return b;
|
|
26
|
-
}
|
|
27
|
-
// case 2: (Panic(uint256)) 0x12
|
|
28
|
-
function revertDivByZero() public pure {
|
|
29
|
-
int z = 0;
|
|
30
|
-
int b = 0;
|
|
31
|
-
b = z / b;
|
|
32
|
-
}
|
|
33
|
-
// case 2: (Panic(uint256)) 0x21
|
|
34
|
-
function revertEnum() public pure {
|
|
35
|
-
uint max = type(uint).max;
|
|
36
|
-
Gm(max);
|
|
37
|
-
}
|
|
38
|
-
// case 2: (Panic(uint256)) 0x31
|
|
39
|
-
function revertPop() public {
|
|
40
|
-
a.pop();
|
|
41
|
-
}
|
|
42
|
-
// case 2: (Panic(uint256)) 0x32
|
|
43
|
-
function revertArrayAccess() public view {
|
|
44
|
-
a[type(uint).max];
|
|
45
|
-
}
|
|
46
|
-
// case 2: (Panic(uint256)) 0x41
|
|
47
|
-
function revertBigArray() public pure returns(uint8[] memory) {
|
|
48
|
-
uint8[] memory d = new uint8[](type(uint256).max);
|
|
49
|
-
return d;
|
|
50
|
-
}
|
|
51
|
-
// case 2: (Panic(uint256)) 0x51
|
|
52
|
-
function revertZeroInitializedFunctionPointer() external pure returns (int) {
|
|
53
|
-
// Variable containing a function pointer
|
|
54
|
-
function (int, int) internal pure returns (int) funcPtr;
|
|
55
|
-
|
|
56
|
-
// This call will fail because funcPtr is still a zero-initialized function pointer
|
|
57
|
-
return funcPtr(4, 5);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// case 3: Error(string)
|
|
61
|
-
function revertString() public pure {
|
|
62
|
-
revert("gm");
|
|
63
|
-
}
|
|
64
|
-
// case 4: custom errors
|
|
65
|
-
function revertCustom() public pure {
|
|
66
|
-
revert Custom();
|
|
67
|
-
}
|
|
68
|
-
function revertCustomVal() public pure {
|
|
69
|
-
revert CustomVal(26);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function revertTest(string memory funcSig) public {
|
|
73
|
-
// solhint-disable-next-line avoid-low-level-calls
|
|
74
|
-
(bool success, bytes memory data) = address(this).call(abi.encodeWithSignature(funcSig));
|
|
75
|
-
if (!success) {
|
|
76
|
-
CallUtils.revertFromReturnedData(data);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: AGPLv3
|
|
2
|
-
pragma solidity 0.8.18;
|
|
3
|
-
|
|
4
|
-
import { CallUtils } from "../libs/CallUtils.sol";
|
|
5
|
-
|
|
6
|
-
contract CallUtilsTester {
|
|
7
|
-
function testIsValidAbiEncodedBytes() external pure {
|
|
8
|
-
require(!CallUtils.isValidAbiEncodedBytes(abi.encode(1, 2, 3)), "bad data");
|
|
9
|
-
require(CallUtils.isValidAbiEncodedBytes(abi.encode(new bytes(0))), "0");
|
|
10
|
-
require(CallUtils.isValidAbiEncodedBytes(abi.encode(new bytes(1))), "1");
|
|
11
|
-
require(CallUtils.isValidAbiEncodedBytes(abi.encode(new bytes(32))), "32");
|
|
12
|
-
require(CallUtils.isValidAbiEncodedBytes(abi.encode(new bytes(33))), "33");
|
|
13
|
-
}
|
|
14
|
-
}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: AGPLv3
|
|
2
|
-
pragma solidity 0.8.18;
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
CustomSuperTokenBase,
|
|
6
|
-
ISuperToken
|
|
7
|
-
}
|
|
8
|
-
from "../interfaces/superfluid/CustomSuperTokenBase.sol";
|
|
9
|
-
import { UUPSProxy } from "../upgradability/UUPSProxy.sol";
|
|
10
|
-
|
|
11
|
-
abstract contract CustomSuperTokenBaseMock is CustomSuperTokenBase, UUPSProxy {
|
|
12
|
-
function getFirstCustomTokenStorageSlot() external pure virtual returns (uint slot);
|
|
13
|
-
|
|
14
|
-
function callSelfBurn(
|
|
15
|
-
address to,
|
|
16
|
-
uint256 amount,
|
|
17
|
-
bytes memory userData
|
|
18
|
-
) external virtual;
|
|
19
|
-
|
|
20
|
-
function callSelfTransferFrom(
|
|
21
|
-
address holder,
|
|
22
|
-
address spender,
|
|
23
|
-
address recipient,
|
|
24
|
-
uint256 amount
|
|
25
|
-
) external virtual;
|
|
26
|
-
|
|
27
|
-
function callSelfApproveFor(
|
|
28
|
-
address account,
|
|
29
|
-
address spender,
|
|
30
|
-
uint256 amount
|
|
31
|
-
) external virtual;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// solhint-disable-next-line no-empty-blocks
|
|
35
|
-
abstract contract CustomSuperTokenMock is CustomSuperTokenBaseMock, ISuperToken {}
|
|
36
|
-
|
|
37
|
-
contract CustomSuperTokenProxyMock is CustomSuperTokenBaseMock {
|
|
38
|
-
|
|
39
|
-
uint256 private _firstStorageSlot;
|
|
40
|
-
|
|
41
|
-
function getFirstCustomTokenStorageSlot() external pure override returns (uint slot) {
|
|
42
|
-
assembly { slot:= _firstStorageSlot.slot }
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// this function overrides the default ISuperToken.selfMint behavior
|
|
46
|
-
function selfMint(
|
|
47
|
-
address to,
|
|
48
|
-
uint256 amount,
|
|
49
|
-
bytes memory userData
|
|
50
|
-
) external {
|
|
51
|
-
// this makes msg.sender to self
|
|
52
|
-
this.delegatecallSelfMint(to, amount, userData);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// this function uses delegatecall to avoid calling shadow mint defined in this contract
|
|
56
|
-
function delegatecallSelfMint(
|
|
57
|
-
address to,
|
|
58
|
-
uint256 amount,
|
|
59
|
-
bytes memory userData
|
|
60
|
-
) external {
|
|
61
|
-
address logic = _implementation();
|
|
62
|
-
// solhint-disable-next-line avoid-low-level-calls
|
|
63
|
-
(bool success, ) = logic.delegatecall(
|
|
64
|
-
abi.encodeCall(
|
|
65
|
-
ISuperToken(address(this)).selfMint,
|
|
66
|
-
(
|
|
67
|
-
to,
|
|
68
|
-
amount,
|
|
69
|
-
userData
|
|
70
|
-
)
|
|
71
|
-
)
|
|
72
|
-
);
|
|
73
|
-
assert(success);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// this function self calls burn
|
|
77
|
-
function callSelfBurn(
|
|
78
|
-
address to,
|
|
79
|
-
uint256 amount,
|
|
80
|
-
bytes memory userData
|
|
81
|
-
) external override {
|
|
82
|
-
// this makes msg.sender to self
|
|
83
|
-
ISuperToken(address(this)).selfBurn(to, amount, userData);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// this function self calls transferFrom
|
|
87
|
-
function callSelfTransferFrom(
|
|
88
|
-
address holder,
|
|
89
|
-
address spender,
|
|
90
|
-
address recipient,
|
|
91
|
-
uint256 amount
|
|
92
|
-
) external override {
|
|
93
|
-
ISuperToken(address(this)).selfTransferFrom(holder, spender, recipient, amount);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// this function self calls approveFor
|
|
97
|
-
function callSelfApproveFor(
|
|
98
|
-
address account,
|
|
99
|
-
address spender,
|
|
100
|
-
uint256 amount
|
|
101
|
-
) external override {
|
|
102
|
-
ISuperToken(address(this)).selfApproveFor(account, spender, amount);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: AGPLv3
|
|
2
|
-
pragma solidity 0.8.18;
|
|
3
|
-
|
|
4
|
-
import "@openzeppelin/contracts/utils/Context.sol";
|
|
5
|
-
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
6
|
-
import "@openzeppelin/contracts/token/ERC777/IERC777.sol";
|
|
7
|
-
import "@openzeppelin/contracts/token/ERC777/IERC777Sender.sol";
|
|
8
|
-
import "@openzeppelin/contracts/token/ERC777/IERC777Recipient.sol";
|
|
9
|
-
import "@openzeppelin/contracts/utils/introspection/IERC1820Registry.sol";
|
|
10
|
-
import "@openzeppelin/contracts/utils/introspection/ERC1820Implementer.sol";
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
ISuperToken
|
|
14
|
-
} from "../superfluid/SuperToken.sol";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
contract ERC777SenderRecipientMock is Context, IERC777Sender, IERC777Recipient, ERC1820Implementer {
|
|
18
|
-
event TokensToSendCalled(
|
|
19
|
-
address operator,
|
|
20
|
-
address from,
|
|
21
|
-
address to,
|
|
22
|
-
uint256 amount,
|
|
23
|
-
bytes data,
|
|
24
|
-
bytes operatorData,
|
|
25
|
-
address token,
|
|
26
|
-
uint256 fromBalance,
|
|
27
|
-
uint256 toBalance
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
event TokensReceivedCalled(
|
|
31
|
-
address operator,
|
|
32
|
-
address from,
|
|
33
|
-
address to,
|
|
34
|
-
uint256 amount,
|
|
35
|
-
bytes data,
|
|
36
|
-
bytes operatorData,
|
|
37
|
-
address token,
|
|
38
|
-
uint256 fromBalance,
|
|
39
|
-
uint256 toBalance
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
bool private _shouldRevertSend;
|
|
43
|
-
bool private _shouldRevertReceive;
|
|
44
|
-
|
|
45
|
-
IERC1820Registry private _erc1820 = IERC1820Registry(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24);
|
|
46
|
-
|
|
47
|
-
bytes32 constant private _TOKENS_SENDER_INTERFACE_HASH = keccak256("ERC777TokensSender");
|
|
48
|
-
bytes32 constant private _TOKENS_RECIPIENT_INTERFACE_HASH = keccak256("ERC777TokensRecipient");
|
|
49
|
-
|
|
50
|
-
function tokensToSend(
|
|
51
|
-
address operator,
|
|
52
|
-
address from,
|
|
53
|
-
address to,
|
|
54
|
-
uint256 amount,
|
|
55
|
-
bytes calldata userData,
|
|
56
|
-
bytes calldata operatorData
|
|
57
|
-
) external override {
|
|
58
|
-
if (_shouldRevertSend) {
|
|
59
|
-
revert("_shouldRevertSend");
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
IERC777 token = IERC777(_msgSender());
|
|
63
|
-
|
|
64
|
-
uint256 fromBalance = token.balanceOf(from);
|
|
65
|
-
// when called due to burn, to will be the zero address, which will have a balance of 0
|
|
66
|
-
uint256 toBalance = token.balanceOf(to);
|
|
67
|
-
|
|
68
|
-
emit TokensToSendCalled(
|
|
69
|
-
operator,
|
|
70
|
-
from,
|
|
71
|
-
to,
|
|
72
|
-
amount,
|
|
73
|
-
userData,
|
|
74
|
-
operatorData,
|
|
75
|
-
address(token),
|
|
76
|
-
fromBalance,
|
|
77
|
-
toBalance
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function tokensReceived(
|
|
82
|
-
address operator,
|
|
83
|
-
address from,
|
|
84
|
-
address to,
|
|
85
|
-
uint256 amount,
|
|
86
|
-
bytes calldata userData,
|
|
87
|
-
bytes calldata operatorData
|
|
88
|
-
) external override {
|
|
89
|
-
if (_shouldRevertReceive) {
|
|
90
|
-
revert("_shouldRevertReceive");
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
IERC777 token = IERC777(_msgSender());
|
|
94
|
-
|
|
95
|
-
uint256 fromBalance = token.balanceOf(from);
|
|
96
|
-
// when called due to burn, to will be the zero address, which will have a balance of 0
|
|
97
|
-
uint256 toBalance = token.balanceOf(to);
|
|
98
|
-
|
|
99
|
-
emit TokensReceivedCalled(
|
|
100
|
-
operator,
|
|
101
|
-
from,
|
|
102
|
-
to,
|
|
103
|
-
amount,
|
|
104
|
-
userData,
|
|
105
|
-
operatorData,
|
|
106
|
-
address(token),
|
|
107
|
-
fromBalance,
|
|
108
|
-
toBalance
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function senderFor(address account) public {
|
|
113
|
-
_registerInterfaceForAddress(_TOKENS_SENDER_INTERFACE_HASH, account);
|
|
114
|
-
|
|
115
|
-
address self = address(this);
|
|
116
|
-
if (account == self) {
|
|
117
|
-
registerSender(self);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function registerSender(address sender) public {
|
|
122
|
-
_erc1820.setInterfaceImplementer(address(this), _TOKENS_SENDER_INTERFACE_HASH, sender);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function recipientFor(address account) public {
|
|
126
|
-
_registerInterfaceForAddress(_TOKENS_RECIPIENT_INTERFACE_HASH, account);
|
|
127
|
-
|
|
128
|
-
address self = address(this);
|
|
129
|
-
if (account == self) {
|
|
130
|
-
registerRecipient(self);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function registerRecipient(address recipient) public {
|
|
135
|
-
_erc1820.setInterfaceImplementer(address(this), _TOKENS_RECIPIENT_INTERFACE_HASH, recipient);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
function setShouldRevertSend(bool shouldRevert) public {
|
|
139
|
-
_shouldRevertSend = shouldRevert;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function setShouldRevertReceive(bool shouldRevert) public {
|
|
143
|
-
_shouldRevertReceive = shouldRevert;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function send(IERC777 token, address to, uint256 amount, bytes memory data) public {
|
|
147
|
-
// This is 777's send function, not the Solidity send function
|
|
148
|
-
token.send(to, amount, data); // solhint-disable-line check-send-result
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
function burn(IERC777 token, uint256 amount, bytes memory data) public {
|
|
152
|
-
token.burn(amount, data);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
function upgradeAll(ISuperToken token) public {
|
|
156
|
-
IERC20 underlying = IERC20(token.getUnderlyingToken());
|
|
157
|
-
uint256 amount = underlying.balanceOf(address(this));
|
|
158
|
-
underlying.approve(address(token), amount);
|
|
159
|
-
token.upgrade(amount);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
function upgradeAllToSelf(ISuperToken token) public {
|
|
163
|
-
IERC20 underlying = IERC20(token.getUnderlyingToken());
|
|
164
|
-
uint256 amount = underlying.balanceOf(address(this));
|
|
165
|
-
underlying.approve(address(token), amount);
|
|
166
|
-
token.upgradeTo(address(this), amount, "");
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
contract ERC777RecipientReverting is IERC777Recipient, IERC1820Implementer {
|
|
171
|
-
bytes32 constant private _TOKENS_RECIPIENT_INTERFACE_HASH = keccak256("ERC777TokensRecipient");
|
|
172
|
-
|
|
173
|
-
// allow to use the hook for this contract itself
|
|
174
|
-
constructor() {
|
|
175
|
-
IERC1820Registry erc1820 = IERC1820Registry(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24);
|
|
176
|
-
erc1820.setInterfaceImplementer(address(this), keccak256("ERC777TokensRecipient"), address(this));
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
function tokensReceived(
|
|
180
|
-
address /*operator*/,
|
|
181
|
-
address /*from*/,
|
|
182
|
-
address /*to*/,
|
|
183
|
-
uint256 /*amount*/,
|
|
184
|
-
bytes calldata /*userData*/,
|
|
185
|
-
bytes calldata /*operatorData*/
|
|
186
|
-
) external pure override {
|
|
187
|
-
revert("they shall not pass");
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// allow anybody to use the hook
|
|
191
|
-
function canImplementInterfaceForAddress(bytes32 interfaceHash, address /*addr*/)
|
|
192
|
-
external pure override
|
|
193
|
-
returns(bytes32)
|
|
194
|
-
{
|
|
195
|
-
return
|
|
196
|
-
interfaceHash == _TOKENS_RECIPIENT_INTERFACE_HASH ?
|
|
197
|
-
keccak256(abi.encodePacked("ERC1820_ACCEPT_MAGIC")) :
|
|
198
|
-
bytes32(0x00);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
/*
|
|
203
|
-
* ERC777Recipient which drains all gas it gets, trying to make the caller run out of gas
|
|
204
|
-
*/
|
|
205
|
-
contract ERC777RecipientDrainingGas is IERC777Recipient, IERC1820Implementer {
|
|
206
|
-
bytes32 constant private _TOKENS_RECIPIENT_INTERFACE_HASH = keccak256("ERC777TokensRecipient");
|
|
207
|
-
uint256 internal _uselessVar = 1;
|
|
208
|
-
|
|
209
|
-
event DrainedGas(uint256 allowance, uint256 burned);
|
|
210
|
-
|
|
211
|
-
function tokensReceived(
|
|
212
|
-
address /*operator*/,
|
|
213
|
-
address /*from*/,
|
|
214
|
-
address /*to*/,
|
|
215
|
-
uint256 /*amount*/,
|
|
216
|
-
bytes calldata /*userData*/,
|
|
217
|
-
bytes calldata /*operatorData*/
|
|
218
|
-
) external override {
|
|
219
|
-
uint256 initialGas = gasleft();
|
|
220
|
-
while (gasleft() > 30000) { // need to leave enough for the send() itself to not fail
|
|
221
|
-
_uselessVar++; // SSTORE drains much faster than an empty loop
|
|
222
|
-
}
|
|
223
|
-
emit DrainedGas(initialGas, gasleft());
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
// allow anybody to use the hook
|
|
227
|
-
function canImplementInterfaceForAddress(bytes32 interfaceHash, address /*addr*/)
|
|
228
|
-
external pure override
|
|
229
|
-
returns(bytes32)
|
|
230
|
-
{
|
|
231
|
-
return
|
|
232
|
-
interfaceHash == _TOKENS_RECIPIENT_INTERFACE_HASH ?
|
|
233
|
-
keccak256(abi.encodePacked("ERC1820_ACCEPT_MAGIC")) :
|
|
234
|
-
bytes32(0x00);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: AGPLv3
|
|
2
|
-
pragma solidity 0.8.18;
|
|
3
|
-
|
|
4
|
-
import { CallUtils } from "../libs/CallUtils.sol";
|
|
5
|
-
|
|
6
|
-
contract FakeSuperfluidMock {
|
|
7
|
-
|
|
8
|
-
function callAgreement(
|
|
9
|
-
address agreement,
|
|
10
|
-
bytes calldata callData
|
|
11
|
-
)
|
|
12
|
-
external
|
|
13
|
-
{
|
|
14
|
-
bool success;
|
|
15
|
-
bytes memory returnedData;
|
|
16
|
-
// solhint-disable-next-line avoid-low-level-calls
|
|
17
|
-
(success, returnedData) = agreement.call(callData);
|
|
18
|
-
assert(!success);
|
|
19
|
-
CallUtils.revertFromReturnedData(returnedData);
|
|
20
|
-
}
|
|
21
|
-
}
|