@keep-network/tbtc-v2 1.6.0-dev.16 → 1.6.0-dev.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/artifacts/BLS.json +1 -1
- package/artifacts/Bank.json +3 -3
- package/artifacts/BeaconAuthorization.json +1 -1
- package/artifacts/BeaconDkg.json +1 -1
- package/artifacts/BeaconDkgValidator.json +1 -1
- package/artifacts/BeaconInactivity.json +1 -1
- package/artifacts/BeaconSortitionPool.json +3 -3
- package/artifacts/Bridge.json +5 -5
- package/artifacts/BridgeGovernance.json +2 -2
- package/artifacts/BridgeGovernanceParameters.json +2 -2
- package/artifacts/Deposit.json +2 -2
- package/artifacts/DepositSweep.json +2 -2
- package/artifacts/DonationVault.json +3 -3
- package/artifacts/EcdsaDkgValidator.json +1 -1
- package/artifacts/EcdsaInactivity.json +1 -1
- package/artifacts/EcdsaSortitionPool.json +3 -3
- package/artifacts/Fraud.json +2 -2
- package/artifacts/LightRelay.json +18 -18
- package/artifacts/LightRelayMaintainerProxy.json +8 -8
- package/artifacts/MaintainerProxy.json +19 -19
- package/artifacts/MovingFunds.json +2 -2
- package/artifacts/NuCypherToken.json +2 -2
- package/artifacts/RandomBeacon.json +2 -2
- package/artifacts/RandomBeaconChaosnet.json +2 -2
- package/artifacts/RandomBeaconGovernance.json +2 -2
- package/artifacts/Redemption.json +2 -2
- package/artifacts/ReimbursementPool.json +2 -2
- package/artifacts/T.json +2 -2
- package/artifacts/TBTC.json +3 -3
- package/artifacts/TBTCToken.json +3 -3
- package/artifacts/TBTCVault.json +23 -23
- package/artifacts/TokenStaking.json +1 -1
- package/artifacts/TokenholderGovernor.json +9 -9
- package/artifacts/TokenholderTimelock.json +8 -8
- package/artifacts/VendingMachine.json +3 -3
- package/artifacts/VendingMachineNuCypher.json +1 -1
- package/artifacts/VendingMachineV2.json +3 -3
- package/artifacts/VendingMachineV3.json +3 -3
- package/artifacts/WalletProposalValidator.json +2 -2
- package/artifacts/WalletRegistry.json +5 -5
- package/artifacts/WalletRegistryGovernance.json +2 -2
- package/artifacts/Wallets.json +2 -2
- package/artifacts/solcInputs/{8bdb4098420884547fe701093440e1b8.json → d86f3b9c8cafe2e77604a4fc30b88b09.json} +2 -2
- package/build/contracts/GovernanceUtils.sol/GovernanceUtils.dbg.json +1 -1
- package/build/contracts/bank/Bank.sol/Bank.dbg.json +1 -1
- package/build/contracts/bank/IReceiveBalanceApproval.sol/IReceiveBalanceApproval.dbg.json +1 -1
- package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.dbg.json +1 -1
- package/build/contracts/bridge/Bridge.sol/Bridge.dbg.json +1 -1
- package/build/contracts/bridge/BridgeGovernanceParameters.sol/BridgeGovernanceParameters.dbg.json +1 -1
- package/build/contracts/bridge/BridgeState.sol/BridgeState.dbg.json +1 -1
- package/build/contracts/bridge/Deposit.sol/Deposit.dbg.json +1 -1
- package/build/contracts/bridge/DepositSweep.sol/DepositSweep.dbg.json +1 -1
- package/build/contracts/bridge/EcdsaLib.sol/EcdsaLib.dbg.json +1 -1
- package/build/contracts/bridge/Fraud.sol/Fraud.dbg.json +1 -1
- package/build/contracts/bridge/Heartbeat.sol/Heartbeat.dbg.json +1 -1
- package/build/contracts/bridge/IRelay.sol/IRelay.dbg.json +1 -1
- package/build/contracts/bridge/MovingFunds.sol/MovingFunds.dbg.json +1 -1
- package/build/contracts/bridge/Redemption.sol/OutboundTx.dbg.json +1 -1
- package/build/contracts/bridge/Redemption.sol/Redemption.dbg.json +1 -1
- package/build/contracts/bridge/VendingMachine.sol/VendingMachine.dbg.json +1 -1
- package/build/contracts/bridge/VendingMachineV2.sol/VendingMachineV2.dbg.json +1 -1
- package/build/contracts/bridge/VendingMachineV3.sol/VendingMachineV3.dbg.json +1 -1
- package/build/contracts/bridge/WalletProposalValidator.sol/WalletProposalValidator.dbg.json +1 -1
- package/build/contracts/bridge/Wallets.sol/Wallets.dbg.json +1 -1
- package/build/contracts/integrator/AbstractTBTCDepositor.sol/AbstractTBTCDepositor.dbg.json +1 -1
- package/build/contracts/integrator/IBridge.sol/IBridge.dbg.json +1 -1
- package/build/contracts/integrator/IBridge.sol/IBridgeTypes.dbg.json +1 -1
- package/build/contracts/integrator/ITBTCVault.sol/ITBTCVault.dbg.json +1 -1
- package/build/contracts/l2/L2TBTC.sol/L2TBTC.dbg.json +1 -1
- package/build/contracts/l2/L2WormholeGateway.sol/IWormholeTokenBridge.dbg.json +1 -1
- package/build/contracts/l2/L2WormholeGateway.sol/L2WormholeGateway.dbg.json +1 -1
- package/build/contracts/maintainer/MaintainerProxy.sol/MaintainerProxy.dbg.json +1 -1
- package/build/contracts/relay/LightRelay.sol/ILightRelay.dbg.json +1 -1
- package/build/contracts/relay/LightRelay.sol/LightRelay.dbg.json +1 -1
- package/build/contracts/relay/LightRelay.sol/RelayUtils.dbg.json +1 -1
- package/build/contracts/relay/LightRelayMaintainerProxy.sol/LightRelayMaintainerProxy.dbg.json +1 -1
- package/build/contracts/test/BankStub.sol/BankStub.dbg.json +4 -0
- package/build/contracts/test/BankStub.sol/BankStub.json +555 -0
- package/build/contracts/test/BridgeStub.sol/BridgeStub.dbg.json +4 -0
- package/build/contracts/test/BridgeStub.sol/BridgeStub.json +3318 -0
- package/build/contracts/test/HeartbeatStub.sol/HeartbeatStub.dbg.json +4 -0
- package/build/contracts/test/HeartbeatStub.sol/HeartbeatStub.json +30 -0
- package/build/contracts/test/LightRelayStub.sol/LightRelayStub.dbg.json +4 -0
- package/build/contracts/test/LightRelayStub.sol/LightRelayStub.json +467 -0
- package/build/contracts/test/ReceiveApprovalStub.sol/ReceiveApprovalStub.dbg.json +4 -0
- package/build/contracts/test/ReceiveApprovalStub.sol/ReceiveApprovalStub.json +96 -0
- package/build/contracts/test/SepoliaLightRelay.sol/SepoliaLightRelay.dbg.json +4 -0
- package/build/contracts/test/SepoliaLightRelay.sol/SepoliaLightRelay.json +456 -0
- package/build/contracts/test/SystemTestRelay.sol/SystemTestRelay.dbg.json +4 -0
- package/build/contracts/test/SystemTestRelay.sol/SystemTestRelay.json +89 -0
- package/build/contracts/test/TestBitcoinTx.sol/TestBitcoinTx.dbg.json +4 -0
- package/build/contracts/test/TestBitcoinTx.sol/TestBitcoinTx.json +102 -0
- package/build/contracts/test/TestERC20.sol/TestERC20.dbg.json +4 -0
- package/build/contracts/test/TestERC20.sol/TestERC20.json +508 -0
- package/build/contracts/test/TestERC721.sol/TestERC721.dbg.json +4 -0
- package/build/contracts/test/TestERC721.sol/TestERC721.json +390 -0
- package/build/contracts/test/TestEcdsaLib.sol/TestEcdsaLib.dbg.json +4 -0
- package/build/contracts/test/TestEcdsaLib.sol/TestEcdsaLib.json +35 -0
- package/build/contracts/test/TestTBTCDepositor.sol/MockBridge.dbg.json +4 -0
- package/build/contracts/test/TestTBTCDepositor.sol/MockBridge.json +224 -0
- package/build/contracts/test/TestTBTCDepositor.sol/MockTBTCVault.dbg.json +4 -0
- package/build/contracts/test/TestTBTCDepositor.sol/MockTBTCVault.json +87 -0
- package/build/contracts/test/TestTBTCDepositor.sol/TestTBTCDepositor.dbg.json +4 -0
- package/build/contracts/test/TestTBTCDepositor.sol/TestTBTCDepositor.json +283 -0
- package/build/contracts/test/WormholeBridgeStub.sol/WormholeBridgeStub.dbg.json +4 -0
- package/build/contracts/test/WormholeBridgeStub.sol/WormholeBridgeStub.json +372 -0
- package/build/contracts/token/TBTC.sol/TBTC.dbg.json +1 -1
- package/build/contracts/vault/DonationVault.sol/DonationVault.dbg.json +1 -1
- package/build/contracts/vault/IVault.sol/IVault.dbg.json +1 -1
- package/build/contracts/vault/TBTCOptimisticMinting.sol/TBTCOptimisticMinting.dbg.json +1 -1
- package/build/contracts/vault/TBTCVault.sol/TBTCVault.dbg.json +1 -1
- package/contracts/integrator/AbstractTBTCDepositor.sol +16 -3
- package/contracts/test/BankStub.sol +11 -0
- package/contracts/test/BridgeStub.sol +174 -0
- package/contracts/test/HeartbeatStub.sol +16 -0
- package/contracts/test/LightRelayStub.sol +15 -0
- package/contracts/test/ReceiveApprovalStub.sol +33 -0
- package/contracts/test/SepoliaLightRelay.sol +48 -0
- package/contracts/test/SystemTestRelay.sol +57 -0
- package/contracts/test/TestBitcoinTx.sol +24 -0
- package/contracts/test/TestERC20.sol +12 -0
- package/contracts/test/TestERC721.sol +16 -0
- package/contracts/test/TestEcdsaLib.sol +17 -0
- package/contracts/test/TestTBTCDepositor.sol +196 -0
- package/contracts/test/WormholeBridgeStub.sol +125 -0
- package/export/artifacts/contracts/bridge/VendingMachine.sol/VendingMachine.json +6 -6
- package/export/artifacts/contracts/bridge/VendingMachineV2.sol/VendingMachineV2.json +6 -6
- package/export/artifacts/contracts/bridge/VendingMachineV3.sol/VendingMachineV3.json +6 -6
- package/export/artifacts/contracts/l2/L2TBTC.sol/L2TBTC.json +40 -40
- package/export/artifacts/contracts/l2/L2WormholeGateway.sol/L2WormholeGateway.json +47 -47
- package/export/artifacts/contracts/maintainer/MaintainerProxy.sol/MaintainerProxy.json +88 -88
- package/export/artifacts/contracts/relay/LightRelay.sol/LightRelay.json +57 -57
- package/export/artifacts/contracts/relay/LightRelayMaintainerProxy.sol/LightRelayMaintainerProxy.json +31 -31
- package/export/artifacts/contracts/test/BankStub.sol/BankStub.json +2 -2
- package/export/artifacts/contracts/test/BridgeStub.sol/BridgeStub.json +30 -30
- package/export/artifacts/contracts/test/HeartbeatStub.sol/HeartbeatStub.json +2 -2
- package/export/artifacts/contracts/test/LightRelayStub.sol/LightRelayStub.json +59 -59
- package/export/artifacts/contracts/test/ReceiveApprovalStub.sol/ReceiveApprovalStub.json +7 -7
- package/export/artifacts/contracts/test/SepoliaLightRelay.sol/SepoliaLightRelay.json +59 -59
- package/export/artifacts/contracts/test/SystemTestRelay.sol/SystemTestRelay.json +14 -14
- package/export/artifacts/contracts/test/TestBitcoinTx.sol/TestBitcoinTx.json +5 -5
- package/export/artifacts/contracts/test/TestERC20.sol/TestERC20.json +6 -6
- package/export/artifacts/contracts/test/TestERC721.sol/TestERC721.json +8 -8
- package/export/artifacts/contracts/test/TestEcdsaLib.sol/TestEcdsaLib.json +2 -2
- package/export/artifacts/contracts/test/TestTBTCDepositor.sol/MockBridge.json +2565 -805
- package/export/artifacts/contracts/test/TestTBTCDepositor.sol/MockTBTCVault.json +25 -25
- package/export/artifacts/contracts/test/TestTBTCDepositor.sol/TestTBTCDepositor.json +1628 -1573
- package/export/artifacts/contracts/test/WormholeBridgeStub.sol/WormholeBridgeStub.json +37 -37
- package/export/artifacts/contracts/token/TBTC.sol/TBTC.json +2 -2
- package/export/artifacts/contracts/vault/DonationVault.sol/DonationVault.json +11 -11
- package/export/artifacts/contracts/vault/TBTCVault.sol/TBTCVault.json +135 -135
- package/export/typechain/factories/MockBridge__factory.js +14 -1
- package/export/typechain/factories/MockTBTCVault__factory.js +1 -1
- package/export/typechain/factories/TestTBTCDepositor__factory.js +7 -1
- package/package.json +1 -2
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
|
+
|
|
3
|
+
pragma solidity 0.8.17;
|
|
4
|
+
|
|
5
|
+
import "../relay/LightRelay.sol";
|
|
6
|
+
|
|
7
|
+
contract LightRelayStub is LightRelay {
|
|
8
|
+
// Gas-reporting version of validateChain
|
|
9
|
+
function validateChainGasReport(bytes memory headers)
|
|
10
|
+
external
|
|
11
|
+
returns (uint256, uint256)
|
|
12
|
+
{
|
|
13
|
+
return this.validateChain(headers);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
|
+
|
|
3
|
+
pragma solidity 0.8.17;
|
|
4
|
+
|
|
5
|
+
import "../token/TBTC.sol";
|
|
6
|
+
|
|
7
|
+
contract ReceiveApprovalStub is IReceiveApproval {
|
|
8
|
+
bool public shouldRevert;
|
|
9
|
+
|
|
10
|
+
event ApprovalReceived(
|
|
11
|
+
address from,
|
|
12
|
+
uint256 value,
|
|
13
|
+
address token,
|
|
14
|
+
bytes extraData
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
function receiveApproval(
|
|
18
|
+
address from,
|
|
19
|
+
uint256 value,
|
|
20
|
+
address token,
|
|
21
|
+
bytes calldata extraData
|
|
22
|
+
) external override {
|
|
23
|
+
if (shouldRevert) {
|
|
24
|
+
revert("i am your father luke");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
emit ApprovalReceived(from, value, token, extraData);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function setShouldRevert(bool _shouldRevert) external {
|
|
31
|
+
shouldRevert = _shouldRevert;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
|
+
|
|
3
|
+
// ██████████████ ▐████▌ ██████████████
|
|
4
|
+
// ██████████████ ▐████▌ ██████████████
|
|
5
|
+
// ▐████▌ ▐████▌
|
|
6
|
+
// ▐████▌ ▐████▌
|
|
7
|
+
// ██████████████ ▐████▌ ██████████████
|
|
8
|
+
// ██████████████ ▐████▌ ██████████████
|
|
9
|
+
// ▐████▌ ▐████▌
|
|
10
|
+
// ▐████▌ ▐████▌
|
|
11
|
+
// ▐████▌ ▐████▌
|
|
12
|
+
// ▐████▌ ▐████▌
|
|
13
|
+
// ▐████▌ ▐████▌
|
|
14
|
+
// ▐████▌ ▐████▌
|
|
15
|
+
|
|
16
|
+
pragma solidity 0.8.17;
|
|
17
|
+
|
|
18
|
+
import {BTCUtils} from "@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol";
|
|
19
|
+
|
|
20
|
+
import "../relay/LightRelay.sol";
|
|
21
|
+
|
|
22
|
+
/// @title Sepolia Light Relay
|
|
23
|
+
/// @notice SepoliaLightRelay is a stub version of LightRelay intended to be
|
|
24
|
+
/// used on the Sepolia test network. It allows to set the relay's
|
|
25
|
+
/// difficulty based on arbitrary Bitcoin headers thus effectively
|
|
26
|
+
/// bypass the validation of difficulties of Bitcoin testnet blocks.
|
|
27
|
+
/// Since difficulty in Bitcoin testnet often falls to `1` it would not
|
|
28
|
+
/// be possible to validate blocks with the real LightRelay.
|
|
29
|
+
/// @dev Notice that SepoliaLightRelay is derived from LightRelay so that the two
|
|
30
|
+
/// contracts have the same API and correct bindings can be generated.
|
|
31
|
+
contract SepoliaLightRelay is LightRelay {
|
|
32
|
+
using BTCUtils for bytes;
|
|
33
|
+
using BTCUtils for uint256;
|
|
34
|
+
|
|
35
|
+
/// @notice Sets the current and previous difficulty based on the difficulty
|
|
36
|
+
/// inferred from the provided Bitcoin headers.
|
|
37
|
+
function setDifficultyFromHeaders(bytes memory bitcoinHeaders)
|
|
38
|
+
external
|
|
39
|
+
onlyOwner
|
|
40
|
+
{
|
|
41
|
+
uint256 firstHeaderDiff = bitcoinHeaders
|
|
42
|
+
.extractTarget()
|
|
43
|
+
.calculateDifficulty();
|
|
44
|
+
|
|
45
|
+
currentEpochDifficulty = firstHeaderDiff;
|
|
46
|
+
prevEpochDifficulty = firstHeaderDiff;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
|
+
|
|
3
|
+
pragma solidity 0.8.17;
|
|
4
|
+
|
|
5
|
+
import {BTCUtils} from "@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol";
|
|
6
|
+
|
|
7
|
+
import "../bridge/Bridge.sol";
|
|
8
|
+
|
|
9
|
+
/// @notice Used only for system tests.
|
|
10
|
+
contract SystemTestRelay is IRelay {
|
|
11
|
+
using BTCUtils for bytes;
|
|
12
|
+
using BTCUtils for uint256;
|
|
13
|
+
|
|
14
|
+
uint256 private currentEpochDifficulty;
|
|
15
|
+
uint256 private prevEpochDifficulty;
|
|
16
|
+
|
|
17
|
+
function setCurrentEpochDifficulty(uint256 _difficulty) external {
|
|
18
|
+
currentEpochDifficulty = _difficulty;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function setPrevEpochDifficulty(uint256 _difficulty) external {
|
|
22
|
+
prevEpochDifficulty = _difficulty;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function setCurrentEpochDifficultyFromHeaders(bytes memory bitcoinHeaders)
|
|
26
|
+
external
|
|
27
|
+
{
|
|
28
|
+
uint256 firstHeaderDiff = bitcoinHeaders
|
|
29
|
+
.extractTarget()
|
|
30
|
+
.calculateDifficulty();
|
|
31
|
+
|
|
32
|
+
currentEpochDifficulty = firstHeaderDiff;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function setPrevEpochDifficultyFromHeaders(bytes memory bitcoinHeaders)
|
|
36
|
+
external
|
|
37
|
+
{
|
|
38
|
+
uint256 firstHeaderDiff = bitcoinHeaders
|
|
39
|
+
.extractTarget()
|
|
40
|
+
.calculateDifficulty();
|
|
41
|
+
|
|
42
|
+
prevEpochDifficulty = firstHeaderDiff;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function getCurrentEpochDifficulty()
|
|
46
|
+
external
|
|
47
|
+
view
|
|
48
|
+
override
|
|
49
|
+
returns (uint256)
|
|
50
|
+
{
|
|
51
|
+
return currentEpochDifficulty;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function getPrevEpochDifficulty() external view override returns (uint256) {
|
|
55
|
+
return prevEpochDifficulty;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
|
+
|
|
3
|
+
pragma solidity 0.8.17;
|
|
4
|
+
|
|
5
|
+
import "../bridge/BitcoinTx.sol";
|
|
6
|
+
import "../bridge/BridgeState.sol";
|
|
7
|
+
import "../bridge/IRelay.sol";
|
|
8
|
+
|
|
9
|
+
contract TestBitcoinTx {
|
|
10
|
+
BridgeState.Storage internal self;
|
|
11
|
+
|
|
12
|
+
event ProofValidated(bytes32 txHash);
|
|
13
|
+
|
|
14
|
+
constructor(address _relay) {
|
|
15
|
+
self.relay = IRelay(_relay);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function validateProof(
|
|
19
|
+
BitcoinTx.Info calldata txInfo,
|
|
20
|
+
BitcoinTx.Proof calldata proof
|
|
21
|
+
) external {
|
|
22
|
+
emit ProofValidated(BitcoinTx.validateProof(self, txInfo, proof));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
|
+
|
|
3
|
+
pragma solidity 0.8.17;
|
|
4
|
+
|
|
5
|
+
import "@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol";
|
|
6
|
+
|
|
7
|
+
contract TestERC20 is ERC20WithPermit {
|
|
8
|
+
string public constant NAME = "Test ERC20 Token";
|
|
9
|
+
string public constant SYMBOL = "TT";
|
|
10
|
+
|
|
11
|
+
constructor() ERC20WithPermit(NAME, SYMBOL) {}
|
|
12
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
|
+
|
|
3
|
+
pragma solidity 0.8.17;
|
|
4
|
+
|
|
5
|
+
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
|
|
6
|
+
|
|
7
|
+
contract TestERC721 is ERC721 {
|
|
8
|
+
string public constant NAME = "Test ERC721 Token";
|
|
9
|
+
string public constant SYMBOL = "TT";
|
|
10
|
+
|
|
11
|
+
constructor() ERC721(NAME, SYMBOL) {}
|
|
12
|
+
|
|
13
|
+
function mint(address to, uint256 tokenId) public {
|
|
14
|
+
_mint(to, tokenId);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
|
+
|
|
3
|
+
pragma solidity 0.8.17;
|
|
4
|
+
|
|
5
|
+
import "../bridge/EcdsaLib.sol";
|
|
6
|
+
|
|
7
|
+
// TODO: Rename to EcdsLibStub
|
|
8
|
+
/// @dev This is a contract implemented to test EcdsaLib library directly.
|
|
9
|
+
contract TestEcdsaLib {
|
|
10
|
+
function compressPublicKey(bytes32 x, bytes32 y)
|
|
11
|
+
public
|
|
12
|
+
pure
|
|
13
|
+
returns (bytes memory)
|
|
14
|
+
{
|
|
15
|
+
return EcdsaLib.compressPublicKey(x, y);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
|
+
|
|
3
|
+
pragma solidity ^0.8.0;
|
|
4
|
+
|
|
5
|
+
import {BTCUtils} from "@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol";
|
|
6
|
+
|
|
7
|
+
import "../integrator/AbstractTBTCDepositor.sol";
|
|
8
|
+
import "../integrator/IBridge.sol";
|
|
9
|
+
import "../integrator/ITBTCVault.sol";
|
|
10
|
+
|
|
11
|
+
contract TestTBTCDepositor is AbstractTBTCDepositor {
|
|
12
|
+
event InitializeDepositReturned(uint256 depositKey);
|
|
13
|
+
|
|
14
|
+
event FinalizeDepositReturned(
|
|
15
|
+
uint256 initialDepositAmount,
|
|
16
|
+
uint256 tbtcAmount,
|
|
17
|
+
bytes32 extraData
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
function initialize(address _bridge, address _tbtcVault) external {
|
|
21
|
+
__AbstractTBTCDepositor_initialize(_bridge, _tbtcVault);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function initializeDepositPublic(
|
|
25
|
+
IBridgeTypes.BitcoinTxInfo calldata fundingTx,
|
|
26
|
+
IBridgeTypes.DepositRevealInfo calldata reveal,
|
|
27
|
+
bytes32 extraData
|
|
28
|
+
) external {
|
|
29
|
+
uint256 depositKey = _initializeDeposit(fundingTx, reveal, extraData);
|
|
30
|
+
emit InitializeDepositReturned(depositKey);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function finalizeDepositPublic(uint256 depositKey) external {
|
|
34
|
+
(
|
|
35
|
+
uint256 initialDepositAmount,
|
|
36
|
+
uint256 tbtcAmount,
|
|
37
|
+
bytes32 extraData
|
|
38
|
+
) = _finalizeDeposit(depositKey);
|
|
39
|
+
emit FinalizeDepositReturned(
|
|
40
|
+
initialDepositAmount,
|
|
41
|
+
tbtcAmount,
|
|
42
|
+
extraData
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function calculateTbtcAmountPublic(
|
|
47
|
+
uint64 depositAmountSat,
|
|
48
|
+
uint64 depositTreasuryFeeSat
|
|
49
|
+
) external view returns (uint256) {
|
|
50
|
+
return _calculateTbtcAmount(depositAmountSat, depositTreasuryFeeSat);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
contract MockBridge is IBridge {
|
|
55
|
+
using BTCUtils for bytes;
|
|
56
|
+
|
|
57
|
+
mapping(uint256 => IBridgeTypes.DepositRequest) internal _deposits;
|
|
58
|
+
|
|
59
|
+
uint64 internal _depositTreasuryFeeDivisor = 50; // 1/50 == 100 bps == 2% == 0.02
|
|
60
|
+
uint64 internal _depositTxMaxFee = 1000; // 1000 satoshi = 0.00001 BTC
|
|
61
|
+
|
|
62
|
+
event DepositRevealed(uint256 depositKey);
|
|
63
|
+
|
|
64
|
+
function revealDepositWithExtraData(
|
|
65
|
+
IBridgeTypes.BitcoinTxInfo calldata fundingTx,
|
|
66
|
+
IBridgeTypes.DepositRevealInfo calldata reveal,
|
|
67
|
+
bytes32 extraData
|
|
68
|
+
) external {
|
|
69
|
+
bytes32 fundingTxHash = abi
|
|
70
|
+
.encodePacked(
|
|
71
|
+
fundingTx.version,
|
|
72
|
+
fundingTx.inputVector,
|
|
73
|
+
fundingTx.outputVector,
|
|
74
|
+
fundingTx.locktime
|
|
75
|
+
)
|
|
76
|
+
.hash256View();
|
|
77
|
+
|
|
78
|
+
uint256 depositKey = uint256(
|
|
79
|
+
keccak256(
|
|
80
|
+
abi.encodePacked(fundingTxHash, reveal.fundingOutputIndex)
|
|
81
|
+
)
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
require(
|
|
85
|
+
_deposits[depositKey].revealedAt == 0,
|
|
86
|
+
"Deposit already revealed"
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
bytes memory fundingOutput = fundingTx
|
|
90
|
+
.outputVector
|
|
91
|
+
.extractOutputAtIndex(reveal.fundingOutputIndex);
|
|
92
|
+
|
|
93
|
+
uint64 fundingOutputAmount = fundingOutput.extractValue();
|
|
94
|
+
|
|
95
|
+
IBridgeTypes.DepositRequest memory request;
|
|
96
|
+
|
|
97
|
+
request.depositor = msg.sender;
|
|
98
|
+
request.amount = fundingOutputAmount;
|
|
99
|
+
/* solhint-disable-next-line not-rely-on-time */
|
|
100
|
+
request.revealedAt = uint32(block.timestamp);
|
|
101
|
+
request.vault = reveal.vault;
|
|
102
|
+
request.treasuryFee = _depositTreasuryFeeDivisor > 0
|
|
103
|
+
? fundingOutputAmount / _depositTreasuryFeeDivisor
|
|
104
|
+
: 0;
|
|
105
|
+
request.sweptAt = 0;
|
|
106
|
+
request.extraData = extraData;
|
|
107
|
+
|
|
108
|
+
_deposits[depositKey] = request;
|
|
109
|
+
|
|
110
|
+
emit DepositRevealed(depositKey);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function sweepDeposit(uint256 depositKey) public {
|
|
114
|
+
require(_deposits[depositKey].revealedAt != 0, "Deposit not revealed");
|
|
115
|
+
require(_deposits[depositKey].sweptAt == 0, "Deposit already swept");
|
|
116
|
+
/* solhint-disable-next-line not-rely-on-time */
|
|
117
|
+
_deposits[depositKey].sweptAt = uint32(block.timestamp);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function deposits(uint256 depositKey)
|
|
121
|
+
external
|
|
122
|
+
view
|
|
123
|
+
returns (IBridgeTypes.DepositRequest memory)
|
|
124
|
+
{
|
|
125
|
+
return _deposits[depositKey];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function depositParameters()
|
|
129
|
+
external
|
|
130
|
+
view
|
|
131
|
+
returns (
|
|
132
|
+
uint64 depositDustThreshold,
|
|
133
|
+
uint64 depositTreasuryFeeDivisor,
|
|
134
|
+
uint64 depositTxMaxFee,
|
|
135
|
+
uint32 depositRevealAheadPeriod
|
|
136
|
+
)
|
|
137
|
+
{
|
|
138
|
+
depositDustThreshold = 0;
|
|
139
|
+
depositTreasuryFeeDivisor = 0;
|
|
140
|
+
depositTxMaxFee = _depositTxMaxFee;
|
|
141
|
+
depositRevealAheadPeriod = 0;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function setDepositTreasuryFeeDivisor(uint64 value) external {
|
|
145
|
+
_depositTreasuryFeeDivisor = value;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function setDepositTxMaxFee(uint64 value) external {
|
|
149
|
+
_depositTxMaxFee = value;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
contract MockTBTCVault is ITBTCVault {
|
|
154
|
+
struct Request {
|
|
155
|
+
uint64 requestedAt;
|
|
156
|
+
uint64 finalizedAt;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
mapping(uint256 => Request) internal _requests;
|
|
160
|
+
|
|
161
|
+
uint32 public optimisticMintingFeeDivisor = 100; // 1%
|
|
162
|
+
|
|
163
|
+
function optimisticMintingRequests(uint256 depositKey)
|
|
164
|
+
external
|
|
165
|
+
returns (uint64 requestedAt, uint64 finalizedAt)
|
|
166
|
+
{
|
|
167
|
+
Request memory request = _requests[depositKey];
|
|
168
|
+
return (request.requestedAt, request.finalizedAt);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function createOptimisticMintingRequest(uint256 depositKey) external {
|
|
172
|
+
require(
|
|
173
|
+
_requests[depositKey].requestedAt == 0,
|
|
174
|
+
"Request already exists"
|
|
175
|
+
);
|
|
176
|
+
/* solhint-disable-next-line not-rely-on-time */
|
|
177
|
+
_requests[depositKey].requestedAt = uint64(block.timestamp);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function finalizeOptimisticMintingRequest(uint256 depositKey) public {
|
|
181
|
+
require(
|
|
182
|
+
_requests[depositKey].requestedAt != 0,
|
|
183
|
+
"Request does not exist"
|
|
184
|
+
);
|
|
185
|
+
require(
|
|
186
|
+
_requests[depositKey].finalizedAt == 0,
|
|
187
|
+
"Request already finalized"
|
|
188
|
+
);
|
|
189
|
+
/* solhint-disable-next-line not-rely-on-time */
|
|
190
|
+
_requests[depositKey].finalizedAt = uint64(block.timestamp);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function setOptimisticMintingFeeDivisor(uint32 value) external {
|
|
194
|
+
optimisticMintingFeeDivisor = value;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
|
+
|
|
3
|
+
pragma solidity 0.8.17;
|
|
4
|
+
|
|
5
|
+
import "./TestERC20.sol";
|
|
6
|
+
import "../l2/L2WormholeGateway.sol";
|
|
7
|
+
|
|
8
|
+
/// @dev Stub contract used in L2WormholeGateway unit tests.
|
|
9
|
+
/// Stub contract is used instead of a smock because of the token transfer
|
|
10
|
+
/// that needs to happen in completeTransferWithPayload function.
|
|
11
|
+
contract WormholeBridgeStub is IWormholeTokenBridge {
|
|
12
|
+
TestERC20 public wormholeToken;
|
|
13
|
+
|
|
14
|
+
uint256 public transferAmount;
|
|
15
|
+
bytes32 public receiverAddress;
|
|
16
|
+
|
|
17
|
+
// Two simple events allowing to assert Wormhole bridge functions are
|
|
18
|
+
// called.
|
|
19
|
+
event WormholeBridgeStub_completeTransferWithPayload(bytes encodedVm);
|
|
20
|
+
event WormholeBridgeStub_transferTokens(
|
|
21
|
+
address token,
|
|
22
|
+
uint256 amount,
|
|
23
|
+
uint16 recipientChain,
|
|
24
|
+
bytes32 recipient,
|
|
25
|
+
uint256 arbiterFee,
|
|
26
|
+
uint32 nonce
|
|
27
|
+
);
|
|
28
|
+
event WormholeBridgeStub_transferTokensWithPayload(
|
|
29
|
+
address token,
|
|
30
|
+
uint256 amount,
|
|
31
|
+
uint16 recipientChain,
|
|
32
|
+
bytes32 recipient,
|
|
33
|
+
uint32 nonce,
|
|
34
|
+
bytes payload
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
constructor(TestERC20 _wormholeToken) {
|
|
38
|
+
wormholeToken = _wormholeToken;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function completeTransferWithPayload(bytes memory encodedVm)
|
|
42
|
+
external
|
|
43
|
+
returns (bytes memory)
|
|
44
|
+
{
|
|
45
|
+
emit WormholeBridgeStub_completeTransferWithPayload(encodedVm);
|
|
46
|
+
wormholeToken.mint(msg.sender, transferAmount);
|
|
47
|
+
|
|
48
|
+
// In a real implementation, encodedVm is parsed. To avoid copy-pasting
|
|
49
|
+
// Wormhole code to this contract and then encoding parmaters in unit
|
|
50
|
+
// tests, we allow to set the receiver address on the stub contract and
|
|
51
|
+
// we return it here. The rest of the parameters does not matter.
|
|
52
|
+
IWormholeTokenBridge.TransferWithPayload memory transfer = IWormholeTokenBridge
|
|
53
|
+
.TransferWithPayload(
|
|
54
|
+
1, // payloadID
|
|
55
|
+
2, // amount
|
|
56
|
+
0x3000000000000000000000000000000000000000000000000000000000000000, // tokenAddress
|
|
57
|
+
4, // tokenChain
|
|
58
|
+
0x5000000000000000000000000000000000000000000000000000000000000000, // to
|
|
59
|
+
6, // toChain
|
|
60
|
+
0x7000000000000000000000000000000000000000000000000000000000000000, // fromAddress
|
|
61
|
+
abi.encode(receiverAddress) // payload
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
return abi.encode(transfer);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function transferTokens(
|
|
68
|
+
address token,
|
|
69
|
+
uint256 amount,
|
|
70
|
+
uint16 recipientChain,
|
|
71
|
+
bytes32 recipient,
|
|
72
|
+
uint256 arbiterFee,
|
|
73
|
+
uint32 nonce
|
|
74
|
+
) external payable returns (uint64 sequence) {
|
|
75
|
+
emit WormholeBridgeStub_transferTokens(
|
|
76
|
+
token,
|
|
77
|
+
amount,
|
|
78
|
+
recipientChain,
|
|
79
|
+
recipient,
|
|
80
|
+
arbiterFee,
|
|
81
|
+
nonce
|
|
82
|
+
);
|
|
83
|
+
return 777;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function transferTokensWithPayload(
|
|
87
|
+
address token,
|
|
88
|
+
uint256 amount,
|
|
89
|
+
uint16 recipientChain,
|
|
90
|
+
bytes32 recipient,
|
|
91
|
+
uint32 nonce,
|
|
92
|
+
bytes memory payload
|
|
93
|
+
) external payable returns (uint64 sequence) {
|
|
94
|
+
emit WormholeBridgeStub_transferTokensWithPayload(
|
|
95
|
+
token,
|
|
96
|
+
amount,
|
|
97
|
+
recipientChain,
|
|
98
|
+
recipient,
|
|
99
|
+
nonce,
|
|
100
|
+
payload
|
|
101
|
+
);
|
|
102
|
+
return 888;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function parseTransferWithPayload(bytes memory encoded)
|
|
106
|
+
external
|
|
107
|
+
pure
|
|
108
|
+
returns (IWormholeTokenBridge.TransferWithPayload memory transfer)
|
|
109
|
+
{
|
|
110
|
+
return abi.decode(encoded, (IWormholeTokenBridge.TransferWithPayload));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function setTransferAmount(uint256 _transferAmount) external {
|
|
114
|
+
transferAmount = _transferAmount;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function setReceiverAddress(bytes32 _receiverAddress) external {
|
|
118
|
+
receiverAddress = _receiverAddress;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Allows to mint Wormhole tBTC for depositWormholeTbtc unit tests.
|
|
122
|
+
function mintWormholeToken(address to, uint256 amount) external {
|
|
123
|
+
wormholeToken.mint(to, amount);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -601,7 +601,7 @@
|
|
|
601
601
|
"parameterSlots": 1,
|
|
602
602
|
"returnSlots": 0
|
|
603
603
|
},
|
|
604
|
-
"abi_decode_tuple_t_contract$_IERC20_$18228t_contract$_TBTC_$
|
|
604
|
+
"abi_decode_tuple_t_contract$_IERC20_$18228t_contract$_TBTC_$42171t_uint256_fromMemory": {
|
|
605
605
|
"entryPoint": 230,
|
|
606
606
|
"id": null,
|
|
607
607
|
"parameterSlots": 2,
|
|
@@ -1045,7 +1045,7 @@
|
|
|
1045
1045
|
}
|
|
1046
1046
|
]
|
|
1047
1047
|
},
|
|
1048
|
-
"name": "abi_decode_tuple_t_contract$_IERC20_$18228t_contract$_TBTC_$
|
|
1048
|
+
"name": "abi_decode_tuple_t_contract$_IERC20_$18228t_contract$_TBTC_$42171t_uint256_fromMemory",
|
|
1049
1049
|
"nodeType": "YulFunctionDefinition",
|
|
1050
1050
|
"parameters": [
|
|
1051
1051
|
{
|
|
@@ -1085,7 +1085,7 @@
|
|
|
1085
1085
|
}
|
|
1086
1086
|
]
|
|
1087
1087
|
},
|
|
1088
|
-
"contents": "{\n { }\n function validator_revert_contract_IERC20(value)\n {\n if iszero(eq(value, and(value, sub(shl(160, 1), 1)))) { revert(0, 0) }\n }\n function abi_decode_tuple_t_contract$_IERC20_$18228t_contract$_TBTC_$
|
|
1088
|
+
"contents": "{\n { }\n function validator_revert_contract_IERC20(value)\n {\n if iszero(eq(value, and(value, sub(shl(160, 1), 1)))) { revert(0, 0) }\n }\n function abi_decode_tuple_t_contract$_IERC20_$18228t_contract$_TBTC_$42171t_uint256_fromMemory(headStart, dataEnd) -> value0, value1, value2\n {\n if slt(sub(dataEnd, headStart), 96) { revert(0, 0) }\n let value := mload(headStart)\n validator_revert_contract_IERC20(value)\n value0 := value\n let value_1 := mload(add(headStart, 32))\n validator_revert_contract_IERC20(value_1)\n value1 := value_1\n value2 := mload(add(headStart, 64))\n }\n}",
|
|
1089
1089
|
"id": 130,
|
|
1090
1090
|
"language": "Yul",
|
|
1091
1091
|
"name": "#utility.yul"
|
|
@@ -1415,7 +1415,7 @@
|
|
|
1415
1415
|
"parameterSlots": 2,
|
|
1416
1416
|
"returnSlots": 1
|
|
1417
1417
|
},
|
|
1418
|
-
"abi_encode_tuple_t_contract$_TBTC_$
|
|
1418
|
+
"abi_encode_tuple_t_contract$_TBTC_$42171__to_t_address__fromStack_reversed": {
|
|
1419
1419
|
"entryPoint": null,
|
|
1420
1420
|
"id": null,
|
|
1421
1421
|
"parameterSlots": 2,
|
|
@@ -3111,7 +3111,7 @@
|
|
|
3111
3111
|
}
|
|
3112
3112
|
]
|
|
3113
3113
|
},
|
|
3114
|
-
"name": "abi_encode_tuple_t_contract$_TBTC_$
|
|
3114
|
+
"name": "abi_encode_tuple_t_contract$_TBTC_$42171__to_t_address__fromStack_reversed",
|
|
3115
3115
|
"nodeType": "YulFunctionDefinition",
|
|
3116
3116
|
"parameters": [
|
|
3117
3117
|
{
|
|
@@ -8190,7 +8190,7 @@
|
|
|
8190
8190
|
}
|
|
8191
8191
|
]
|
|
8192
8192
|
},
|
|
8193
|
-
"contents": "{\n { }\n function abi_encode_tuple_t_uint256__to_t_uint256__fromStack_reversed(headStart, value0) -> tail\n {\n tail := add(headStart, 32)\n mstore(headStart, value0)\n }\n function abi_encode_tuple_t_address__to_t_address__fromStack_reversed(headStart, value0) -> tail\n {\n tail := add(headStart, 32)\n mstore(headStart, and(value0, 0xffffffffffffffffffffffffffffffffffffffff))\n }\n function abi_decode_address(offset) -> value\n {\n value := calldataload(offset)\n if iszero(eq(value, and(value, 0xffffffffffffffffffffffffffffffffffffffff))) { revert(0, 0) }\n }\n function abi_decode_tuple_t_address(headStart, dataEnd) -> value0\n {\n if slt(sub(dataEnd, headStart), 32) { revert(0, 0) }\n value0 := abi_decode_address(headStart)\n }\n function abi_encode_tuple_t_contract$_IERC20_$18228__to_t_address__fromStack_reversed(headStart, value0) -> tail\n {\n tail := add(headStart, 32)\n mstore(headStart, and(value0, 0xffffffffffffffffffffffffffffffffffffffff))\n }\n function abi_decode_tuple_t_uint256(headStart, dataEnd) -> value0\n {\n if slt(sub(dataEnd, headStart), 32) { revert(0, 0) }\n value0 := calldataload(headStart)\n }\n function abi_decode_tuple_t_addresst_uint256t_addresst_bytes_calldata_ptr(headStart, dataEnd) -> value0, value1, value2, value3, value4\n {\n if slt(sub(dataEnd, headStart), 128) { revert(0, 0) }\n value0 := abi_decode_address(headStart)\n value1 := calldataload(add(headStart, 32))\n value2 := abi_decode_address(add(headStart, 64))\n let offset := calldataload(add(headStart, 96))\n let _1 := 0xffffffffffffffff\n if gt(offset, _1) { revert(0, 0) }\n let _2 := add(headStart, offset)\n if iszero(slt(add(_2, 0x1f), dataEnd)) { revert(0, 0) }\n let length := calldataload(_2)\n if gt(length, _1) { revert(0, 0) }\n if gt(add(add(_2, length), 32), dataEnd) { revert(0, 0) }\n value3 := add(_2, 32)\n value4 := length\n }\n function abi_encode_tuple_t_contract$_TBTC_$42134__to_t_address__fromStack_reversed(headStart, value0) -> tail\n {\n tail := add(headStart, 32)\n mstore(headStart, and(value0, 0xffffffffffffffffffffffffffffffffffffffff))\n }\n function abi_decode_tuple_t_addresst_uint256(headStart, dataEnd) -> value0, value1\n {\n if slt(sub(dataEnd, headStart), 64) { revert(0, 0) }\n value0 := abi_decode_address(headStart)\n value1 := calldataload(add(headStart, 32))\n }\n function abi_encode_tuple_t_stringliteral_9e5d6ee1ae898a2df1a30570594add9e68ad8b6af4a57d7f5f0cb2842bacfb92__to_t_string_memory_ptr__fromStack_reversed(headStart) -> tail\n {\n mstore(headStart, 32)\n mstore(add(headStart, 32), 24)\n mstore(add(headStart, 64), \"Caller is not authorized\")\n tail := add(headStart, 96)\n }\n function abi_encode_tuple_t_stringliteral_df41f55d800b6607edb1865fb30b4ab33d723889d164c99cca8fee73ff0a30ba__to_t_string_memory_ptr__fromStack_reversed(headStart) -> tail\n {\n mstore(headStart, 32)\n mstore(add(headStart, 32), 38)\n mstore(add(headStart, 64), \"New initiator must not be zero a\")\n mstore(add(headStart, 96), \"ddress\")\n tail := add(headStart, 128)\n }\n function abi_encode_tuple_t_uint256_t_uint256__to_t_uint256_t_uint256__fromStack_reversed(headStart, value1, value0) -> tail\n {\n tail := add(headStart, 64)\n mstore(headStart, value0)\n mstore(add(headStart, 32), value1)\n }\n function abi_encode_tuple_t_stringliteral_b1549855d8fed0f683c741615955b3e3f5ac1fbe3fc645d4559c62450ecc9620__to_t_string_memory_ptr__fromStack_reversed(headStart) -> tail\n {\n mstore(headStart, 32)\n mstore(add(headStart, 32), 41)\n mstore(add(headStart, 64), \"New VendingMachine cannot be zer\")\n mstore(add(headStart, 96), \"o address\")\n tail := add(headStart, 128)\n }\n function abi_encode_tuple_t_address_t_uint256__to_t_address_t_uint256__fromStack_reversed(headStart, value1, value0) -> tail\n {\n tail := add(headStart, 64)\n mstore(headStart, and(value0, 0xffffffffffffffffffffffffffffffffffffffff))\n mstore(add(headStart, 32), value1)\n }\n function panic_error_0x11()\n {\n mstore(0, 35408467139433450592217433187231851964531694900788300625387963629091585785856)\n mstore(4, 0x11)\n revert(0, 0x24)\n }\n function checked_add_t_uint256(x, y) -> sum\n {\n sum := add(x, y)\n if gt(x, sum) { panic_error_0x11() }\n }\n function abi_decode_tuple_t_uint256_fromMemory(headStart, dataEnd) -> value0\n {\n if slt(sub(dataEnd, headStart), 32) { revert(0, 0) }\n value0 := mload(headStart)\n }\n function abi_encode_tuple_t_stringliteral_1a06921938f9f63c056c578e8a5f166d5d113ae30837c6c39a7741ed0e1467eb__to_t_string_memory_ptr__fromStack_reversed(headStart) -> tail\n {\n mstore(headStart, 32)\n mstore(add(headStart, 32), 36)\n mstore(add(headStart, 64), \"Amount + fee exceeds TBTC v2 bal\")\n mstore(add(headStart, 96), \"ance\")\n tail := add(headStart, 128)\n }\n function abi_encode_tuple_t_stringliteral_ea12df8d4a8fcefc5cad59efc2d58b797f642582ed766ffab36a121e023bc406__to_t_string_memory_ptr__fromStack_reversed(headStart) -> tail\n {\n mstore(headStart, 32)\n mstore(add(headStart, 32), 20)\n mstore(add(headStart, 64), \"Token is not TBTC v1\")\n tail := add(headStart, 96)\n }\n function abi_encode_tuple_t_stringliteral_fd4966bd1bdd27d0ab34b8489f15fc58fd6abfe9ed90887e0c2e4963267e6422__to_t_string_memory_ptr__fromStack_reversed(headStart) -> tail\n {\n mstore(headStart, 32)\n mstore(add(headStart, 32), 27)\n mstore(add(headStart, 64), \"Only TBTC v1 caller allowed\")\n tail := add(headStart, 96)\n }\n function checked_mul_t_uint256(x, y) -> product\n {\n product := mul(x, y)\n if iszero(or(iszero(x), eq(y, div(product, x)))) { panic_error_0x11() }\n }\n function checked_div_t_uint256(x, y) -> r\n {\n if iszero(y)\n {\n mstore(0, 35408467139433450592217433187231851964531694900788300625387963629091585785856)\n mstore(4, 0x12)\n revert(0, 0x24)\n }\n r := div(x, y)\n }\n function abi_encode_tuple_t_stringliteral_245f15ff17f551913a7a18385165551503906a406f905ac1c2437281a7cd0cfe__to_t_string_memory_ptr__fromStack_reversed(headStart) -> tail\n {\n mstore(headStart, 32)\n mstore(add(headStart, 32), 38)\n mstore(add(headStart, 64), \"Ownable: new owner is the zero a\")\n mstore(add(headStart, 96), \"ddress\")\n tail := add(headStart, 128)\n }\n function abi_encode_tuple_t_stringliteral_61334796e55ed72efd746c0931e2d3cac4c97d3130d7bb275d5f0f57af1f045e__to_t_string_memory_ptr__fromStack_reversed(headStart) -> tail\n {\n mstore(headStart, 32)\n mstore(add(headStart, 32), 20)\n mstore(add(headStart, 64), \"Change not initiated\")\n tail := add(headStart, 96)\n }\n function checked_sub_t_uint256(x, y) -> diff\n {\n diff := sub(x, y)\n if gt(diff, x) { panic_error_0x11() }\n }\n function abi_encode_tuple_t_stringliteral_9924ebdf1add33d25d4ef888e16131f0a5687b0580a36c21b5c301a6c462effe__to_t_string_memory_ptr__fromStack_reversed(headStart) -> tail\n {\n mstore(headStart, 32)\n mstore(add(headStart, 32), 32)\n mstore(add(headStart, 64), \"Ownable: caller is not the owner\")\n tail := add(headStart, 96)\n }\n function abi_encode_tuple_t_stringliteral_92dde2c37d5ac1c8388fee9c21ec0fe0c957aca7e978d56c81b848f962f0a8ba__to_t_string_memory_ptr__fromStack_reversed(headStart) -> tail\n {\n mstore(headStart, 32)\n mstore(add(headStart, 32), 32)\n mstore(add(headStart, 64), \"Governance delay has not elapsed\")\n tail := add(headStart, 96)\n }\n function abi_encode_tuple_t_address_t_address_t_uint256__to_t_address_t_address_t_uint256__fromStack_reversed(headStart, value2, value1, value0) -> tail\n {\n tail := add(headStart, 96)\n let _1 := 0xffffffffffffffffffffffffffffffffffffffff\n mstore(headStart, and(value0, _1))\n mstore(add(headStart, 32), and(value1, _1))\n mstore(add(headStart, 64), value2)\n }\n function abi_decode_tuple_t_bool_fromMemory(headStart, dataEnd) -> value0\n {\n if slt(sub(dataEnd, headStart), 32) { revert(0, 0) }\n let value := mload(headStart)\n if iszero(eq(value, iszero(iszero(value)))) { revert(0, 0) }\n value0 := value\n }\n function abi_encode_tuple_t_stringliteral_e11ad79d1e4a7f2e5f376964cb99e8e8f7904e3fc16a109f7a7ecb9aa7956dcd__to_t_string_memory_ptr__fromStack_reversed(headStart) -> tail\n {\n mstore(headStart, 32)\n mstore(add(headStart, 32), 42)\n mstore(add(headStart, 64), \"SafeERC20: ERC20 operation did n\")\n mstore(add(headStart, 96), \"ot succeed\")\n tail := add(headStart, 128)\n }\n function abi_encode_tuple_t_stringliteral_565f1a77334fc4792800921178c71e4521acffab18ff9e7885b49377ee80ab4c__to_t_string_memory_ptr__fromStack_reversed(headStart) -> tail\n {\n mstore(headStart, 32)\n mstore(add(headStart, 32), 38)\n mstore(add(headStart, 64), \"Address: insufficient balance fo\")\n mstore(add(headStart, 96), \"r call\")\n tail := add(headStart, 128)\n }\n function copy_memory_to_memory_with_cleanup(src, dst, length)\n {\n let i := 0\n for { } lt(i, length) { i := add(i, 32) }\n {\n mstore(add(dst, i), mload(add(src, i)))\n }\n mstore(add(dst, length), 0)\n }\n function abi_encode_tuple_packed_t_bytes_memory_ptr__to_t_bytes_memory_ptr__nonPadded_inplace_fromStack_reversed(pos, value0) -> end\n {\n let length := mload(value0)\n copy_memory_to_memory_with_cleanup(add(value0, 0x20), pos, length)\n end := add(pos, length)\n }\n function abi_encode_tuple_t_stringliteral_cc2e4e38850b7c0a3e942cfed89b71c77302df25bcb2ec297a0c4ff9ff6b90ad__to_t_string_memory_ptr__fromStack_reversed(headStart) -> tail\n {\n mstore(headStart, 32)\n mstore(add(headStart, 32), 29)\n mstore(add(headStart, 64), \"Address: call to non-contract\")\n tail := add(headStart, 96)\n }\n function abi_encode_tuple_t_string_memory_ptr__to_t_string_memory_ptr__fromStack_reversed(headStart, value0) -> tail\n {\n mstore(headStart, 32)\n let length := mload(value0)\n mstore(add(headStart, 32), length)\n copy_memory_to_memory_with_cleanup(add(value0, 32), add(headStart, 64), length)\n tail := add(add(headStart, and(add(length, 31), not(31))), 64)\n }\n}",
|
|
8193
|
+
"contents": "{\n { }\n function abi_encode_tuple_t_uint256__to_t_uint256__fromStack_reversed(headStart, value0) -> tail\n {\n tail := add(headStart, 32)\n mstore(headStart, value0)\n }\n function abi_encode_tuple_t_address__to_t_address__fromStack_reversed(headStart, value0) -> tail\n {\n tail := add(headStart, 32)\n mstore(headStart, and(value0, 0xffffffffffffffffffffffffffffffffffffffff))\n }\n function abi_decode_address(offset) -> value\n {\n value := calldataload(offset)\n if iszero(eq(value, and(value, 0xffffffffffffffffffffffffffffffffffffffff))) { revert(0, 0) }\n }\n function abi_decode_tuple_t_address(headStart, dataEnd) -> value0\n {\n if slt(sub(dataEnd, headStart), 32) { revert(0, 0) }\n value0 := abi_decode_address(headStart)\n }\n function abi_encode_tuple_t_contract$_IERC20_$18228__to_t_address__fromStack_reversed(headStart, value0) -> tail\n {\n tail := add(headStart, 32)\n mstore(headStart, and(value0, 0xffffffffffffffffffffffffffffffffffffffff))\n }\n function abi_decode_tuple_t_uint256(headStart, dataEnd) -> value0\n {\n if slt(sub(dataEnd, headStart), 32) { revert(0, 0) }\n value0 := calldataload(headStart)\n }\n function abi_decode_tuple_t_addresst_uint256t_addresst_bytes_calldata_ptr(headStart, dataEnd) -> value0, value1, value2, value3, value4\n {\n if slt(sub(dataEnd, headStart), 128) { revert(0, 0) }\n value0 := abi_decode_address(headStart)\n value1 := calldataload(add(headStart, 32))\n value2 := abi_decode_address(add(headStart, 64))\n let offset := calldataload(add(headStart, 96))\n let _1 := 0xffffffffffffffff\n if gt(offset, _1) { revert(0, 0) }\n let _2 := add(headStart, offset)\n if iszero(slt(add(_2, 0x1f), dataEnd)) { revert(0, 0) }\n let length := calldataload(_2)\n if gt(length, _1) { revert(0, 0) }\n if gt(add(add(_2, length), 32), dataEnd) { revert(0, 0) }\n value3 := add(_2, 32)\n value4 := length\n }\n function abi_encode_tuple_t_contract$_TBTC_$42171__to_t_address__fromStack_reversed(headStart, value0) -> tail\n {\n tail := add(headStart, 32)\n mstore(headStart, and(value0, 0xffffffffffffffffffffffffffffffffffffffff))\n }\n function abi_decode_tuple_t_addresst_uint256(headStart, dataEnd) -> value0, value1\n {\n if slt(sub(dataEnd, headStart), 64) { revert(0, 0) }\n value0 := abi_decode_address(headStart)\n value1 := calldataload(add(headStart, 32))\n }\n function abi_encode_tuple_t_stringliteral_9e5d6ee1ae898a2df1a30570594add9e68ad8b6af4a57d7f5f0cb2842bacfb92__to_t_string_memory_ptr__fromStack_reversed(headStart) -> tail\n {\n mstore(headStart, 32)\n mstore(add(headStart, 32), 24)\n mstore(add(headStart, 64), \"Caller is not authorized\")\n tail := add(headStart, 96)\n }\n function abi_encode_tuple_t_stringliteral_df41f55d800b6607edb1865fb30b4ab33d723889d164c99cca8fee73ff0a30ba__to_t_string_memory_ptr__fromStack_reversed(headStart) -> tail\n {\n mstore(headStart, 32)\n mstore(add(headStart, 32), 38)\n mstore(add(headStart, 64), \"New initiator must not be zero a\")\n mstore(add(headStart, 96), \"ddress\")\n tail := add(headStart, 128)\n }\n function abi_encode_tuple_t_uint256_t_uint256__to_t_uint256_t_uint256__fromStack_reversed(headStart, value1, value0) -> tail\n {\n tail := add(headStart, 64)\n mstore(headStart, value0)\n mstore(add(headStart, 32), value1)\n }\n function abi_encode_tuple_t_stringliteral_b1549855d8fed0f683c741615955b3e3f5ac1fbe3fc645d4559c62450ecc9620__to_t_string_memory_ptr__fromStack_reversed(headStart) -> tail\n {\n mstore(headStart, 32)\n mstore(add(headStart, 32), 41)\n mstore(add(headStart, 64), \"New VendingMachine cannot be zer\")\n mstore(add(headStart, 96), \"o address\")\n tail := add(headStart, 128)\n }\n function abi_encode_tuple_t_address_t_uint256__to_t_address_t_uint256__fromStack_reversed(headStart, value1, value0) -> tail\n {\n tail := add(headStart, 64)\n mstore(headStart, and(value0, 0xffffffffffffffffffffffffffffffffffffffff))\n mstore(add(headStart, 32), value1)\n }\n function panic_error_0x11()\n {\n mstore(0, 35408467139433450592217433187231851964531694900788300625387963629091585785856)\n mstore(4, 0x11)\n revert(0, 0x24)\n }\n function checked_add_t_uint256(x, y) -> sum\n {\n sum := add(x, y)\n if gt(x, sum) { panic_error_0x11() }\n }\n function abi_decode_tuple_t_uint256_fromMemory(headStart, dataEnd) -> value0\n {\n if slt(sub(dataEnd, headStart), 32) { revert(0, 0) }\n value0 := mload(headStart)\n }\n function abi_encode_tuple_t_stringliteral_1a06921938f9f63c056c578e8a5f166d5d113ae30837c6c39a7741ed0e1467eb__to_t_string_memory_ptr__fromStack_reversed(headStart) -> tail\n {\n mstore(headStart, 32)\n mstore(add(headStart, 32), 36)\n mstore(add(headStart, 64), \"Amount + fee exceeds TBTC v2 bal\")\n mstore(add(headStart, 96), \"ance\")\n tail := add(headStart, 128)\n }\n function abi_encode_tuple_t_stringliteral_ea12df8d4a8fcefc5cad59efc2d58b797f642582ed766ffab36a121e023bc406__to_t_string_memory_ptr__fromStack_reversed(headStart) -> tail\n {\n mstore(headStart, 32)\n mstore(add(headStart, 32), 20)\n mstore(add(headStart, 64), \"Token is not TBTC v1\")\n tail := add(headStart, 96)\n }\n function abi_encode_tuple_t_stringliteral_fd4966bd1bdd27d0ab34b8489f15fc58fd6abfe9ed90887e0c2e4963267e6422__to_t_string_memory_ptr__fromStack_reversed(headStart) -> tail\n {\n mstore(headStart, 32)\n mstore(add(headStart, 32), 27)\n mstore(add(headStart, 64), \"Only TBTC v1 caller allowed\")\n tail := add(headStart, 96)\n }\n function checked_mul_t_uint256(x, y) -> product\n {\n product := mul(x, y)\n if iszero(or(iszero(x), eq(y, div(product, x)))) { panic_error_0x11() }\n }\n function checked_div_t_uint256(x, y) -> r\n {\n if iszero(y)\n {\n mstore(0, 35408467139433450592217433187231851964531694900788300625387963629091585785856)\n mstore(4, 0x12)\n revert(0, 0x24)\n }\n r := div(x, y)\n }\n function abi_encode_tuple_t_stringliteral_245f15ff17f551913a7a18385165551503906a406f905ac1c2437281a7cd0cfe__to_t_string_memory_ptr__fromStack_reversed(headStart) -> tail\n {\n mstore(headStart, 32)\n mstore(add(headStart, 32), 38)\n mstore(add(headStart, 64), \"Ownable: new owner is the zero a\")\n mstore(add(headStart, 96), \"ddress\")\n tail := add(headStart, 128)\n }\n function abi_encode_tuple_t_stringliteral_61334796e55ed72efd746c0931e2d3cac4c97d3130d7bb275d5f0f57af1f045e__to_t_string_memory_ptr__fromStack_reversed(headStart) -> tail\n {\n mstore(headStart, 32)\n mstore(add(headStart, 32), 20)\n mstore(add(headStart, 64), \"Change not initiated\")\n tail := add(headStart, 96)\n }\n function checked_sub_t_uint256(x, y) -> diff\n {\n diff := sub(x, y)\n if gt(diff, x) { panic_error_0x11() }\n }\n function abi_encode_tuple_t_stringliteral_9924ebdf1add33d25d4ef888e16131f0a5687b0580a36c21b5c301a6c462effe__to_t_string_memory_ptr__fromStack_reversed(headStart) -> tail\n {\n mstore(headStart, 32)\n mstore(add(headStart, 32), 32)\n mstore(add(headStart, 64), \"Ownable: caller is not the owner\")\n tail := add(headStart, 96)\n }\n function abi_encode_tuple_t_stringliteral_92dde2c37d5ac1c8388fee9c21ec0fe0c957aca7e978d56c81b848f962f0a8ba__to_t_string_memory_ptr__fromStack_reversed(headStart) -> tail\n {\n mstore(headStart, 32)\n mstore(add(headStart, 32), 32)\n mstore(add(headStart, 64), \"Governance delay has not elapsed\")\n tail := add(headStart, 96)\n }\n function abi_encode_tuple_t_address_t_address_t_uint256__to_t_address_t_address_t_uint256__fromStack_reversed(headStart, value2, value1, value0) -> tail\n {\n tail := add(headStart, 96)\n let _1 := 0xffffffffffffffffffffffffffffffffffffffff\n mstore(headStart, and(value0, _1))\n mstore(add(headStart, 32), and(value1, _1))\n mstore(add(headStart, 64), value2)\n }\n function abi_decode_tuple_t_bool_fromMemory(headStart, dataEnd) -> value0\n {\n if slt(sub(dataEnd, headStart), 32) { revert(0, 0) }\n let value := mload(headStart)\n if iszero(eq(value, iszero(iszero(value)))) { revert(0, 0) }\n value0 := value\n }\n function abi_encode_tuple_t_stringliteral_e11ad79d1e4a7f2e5f376964cb99e8e8f7904e3fc16a109f7a7ecb9aa7956dcd__to_t_string_memory_ptr__fromStack_reversed(headStart) -> tail\n {\n mstore(headStart, 32)\n mstore(add(headStart, 32), 42)\n mstore(add(headStart, 64), \"SafeERC20: ERC20 operation did n\")\n mstore(add(headStart, 96), \"ot succeed\")\n tail := add(headStart, 128)\n }\n function abi_encode_tuple_t_stringliteral_565f1a77334fc4792800921178c71e4521acffab18ff9e7885b49377ee80ab4c__to_t_string_memory_ptr__fromStack_reversed(headStart) -> tail\n {\n mstore(headStart, 32)\n mstore(add(headStart, 32), 38)\n mstore(add(headStart, 64), \"Address: insufficient balance fo\")\n mstore(add(headStart, 96), \"r call\")\n tail := add(headStart, 128)\n }\n function copy_memory_to_memory_with_cleanup(src, dst, length)\n {\n let i := 0\n for { } lt(i, length) { i := add(i, 32) }\n {\n mstore(add(dst, i), mload(add(src, i)))\n }\n mstore(add(dst, length), 0)\n }\n function abi_encode_tuple_packed_t_bytes_memory_ptr__to_t_bytes_memory_ptr__nonPadded_inplace_fromStack_reversed(pos, value0) -> end\n {\n let length := mload(value0)\n copy_memory_to_memory_with_cleanup(add(value0, 0x20), pos, length)\n end := add(pos, length)\n }\n function abi_encode_tuple_t_stringliteral_cc2e4e38850b7c0a3e942cfed89b71c77302df25bcb2ec297a0c4ff9ff6b90ad__to_t_string_memory_ptr__fromStack_reversed(headStart) -> tail\n {\n mstore(headStart, 32)\n mstore(add(headStart, 32), 29)\n mstore(add(headStart, 64), \"Address: call to non-contract\")\n tail := add(headStart, 96)\n }\n function abi_encode_tuple_t_string_memory_ptr__to_t_string_memory_ptr__fromStack_reversed(headStart, value0) -> tail\n {\n mstore(headStart, 32)\n let length := mload(value0)\n mstore(add(headStart, 32), length)\n copy_memory_to_memory_with_cleanup(add(value0, 32), add(headStart, 64), length)\n tail := add(add(headStart, and(add(length, 31), not(31))), 64)\n }\n}",
|
|
8194
8194
|
"id": 130,
|
|
8195
8195
|
"language": "Yul",
|
|
8196
8196
|
"name": "#utility.yul"
|