iwa 0.0.0__py3-none-any.whl → 0.0.1a2__py3-none-any.whl
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.
- conftest.py +22 -0
- iwa/__init__.py +1 -0
- iwa/__main__.py +6 -0
- iwa/core/__init__.py +1 -0
- iwa/core/chain/__init__.py +68 -0
- iwa/core/chain/errors.py +47 -0
- iwa/core/chain/interface.py +514 -0
- iwa/core/chain/manager.py +38 -0
- iwa/core/chain/models.py +128 -0
- iwa/core/chain/rate_limiter.py +193 -0
- iwa/core/cli.py +210 -0
- iwa/core/constants.py +28 -0
- iwa/core/contracts/__init__.py +1 -0
- iwa/core/contracts/contract.py +297 -0
- iwa/core/contracts/erc20.py +79 -0
- iwa/core/contracts/multisend.py +71 -0
- iwa/core/db.py +317 -0
- iwa/core/keys.py +361 -0
- iwa/core/mnemonic.py +385 -0
- iwa/core/models.py +344 -0
- iwa/core/monitor.py +209 -0
- iwa/core/plugins.py +45 -0
- iwa/core/pricing.py +91 -0
- iwa/core/services/__init__.py +17 -0
- iwa/core/services/account.py +57 -0
- iwa/core/services/balance.py +113 -0
- iwa/core/services/plugin.py +88 -0
- iwa/core/services/safe.py +392 -0
- iwa/core/services/transaction.py +172 -0
- iwa/core/services/transfer/__init__.py +166 -0
- iwa/core/services/transfer/base.py +260 -0
- iwa/core/services/transfer/erc20.py +247 -0
- iwa/core/services/transfer/multisend.py +386 -0
- iwa/core/services/transfer/native.py +262 -0
- iwa/core/services/transfer/swap.py +326 -0
- iwa/core/settings.py +95 -0
- iwa/core/tables.py +60 -0
- iwa/core/test.py +27 -0
- iwa/core/tests/test_wallet.py +255 -0
- iwa/core/types.py +59 -0
- iwa/core/ui.py +99 -0
- iwa/core/utils.py +59 -0
- iwa/core/wallet.py +380 -0
- iwa/plugins/__init__.py +1 -0
- iwa/plugins/gnosis/__init__.py +5 -0
- iwa/plugins/gnosis/cow/__init__.py +6 -0
- iwa/plugins/gnosis/cow/quotes.py +148 -0
- iwa/plugins/gnosis/cow/swap.py +403 -0
- iwa/plugins/gnosis/cow/types.py +20 -0
- iwa/plugins/gnosis/cow_utils.py +44 -0
- iwa/plugins/gnosis/plugin.py +68 -0
- iwa/plugins/gnosis/safe.py +157 -0
- iwa/plugins/gnosis/tests/test_cow.py +227 -0
- iwa/plugins/gnosis/tests/test_safe.py +100 -0
- iwa/plugins/olas/__init__.py +5 -0
- iwa/plugins/olas/constants.py +106 -0
- iwa/plugins/olas/contracts/activity_checker.py +93 -0
- iwa/plugins/olas/contracts/base.py +10 -0
- iwa/plugins/olas/contracts/mech.py +49 -0
- iwa/plugins/olas/contracts/mech_marketplace.py +43 -0
- iwa/plugins/olas/contracts/service.py +215 -0
- iwa/plugins/olas/contracts/staking.py +403 -0
- iwa/plugins/olas/importer.py +736 -0
- iwa/plugins/olas/mech_reference.py +135 -0
- iwa/plugins/olas/models.py +110 -0
- iwa/plugins/olas/plugin.py +243 -0
- iwa/plugins/olas/scripts/test_full_mech_flow.py +259 -0
- iwa/plugins/olas/scripts/test_simple_lifecycle.py +74 -0
- iwa/plugins/olas/service_manager/__init__.py +60 -0
- iwa/plugins/olas/service_manager/base.py +113 -0
- iwa/plugins/olas/service_manager/drain.py +336 -0
- iwa/plugins/olas/service_manager/lifecycle.py +839 -0
- iwa/plugins/olas/service_manager/mech.py +322 -0
- iwa/plugins/olas/service_manager/staking.py +530 -0
- iwa/plugins/olas/tests/conftest.py +30 -0
- iwa/plugins/olas/tests/test_importer.py +128 -0
- iwa/plugins/olas/tests/test_importer_error_handling.py +349 -0
- iwa/plugins/olas/tests/test_mech_contracts.py +85 -0
- iwa/plugins/olas/tests/test_olas_contracts.py +249 -0
- iwa/plugins/olas/tests/test_olas_integration.py +561 -0
- iwa/plugins/olas/tests/test_olas_models.py +144 -0
- iwa/plugins/olas/tests/test_olas_view.py +258 -0
- iwa/plugins/olas/tests/test_olas_view_actions.py +137 -0
- iwa/plugins/olas/tests/test_olas_view_modals.py +120 -0
- iwa/plugins/olas/tests/test_plugin.py +70 -0
- iwa/plugins/olas/tests/test_plugin_full.py +212 -0
- iwa/plugins/olas/tests/test_service_lifecycle.py +150 -0
- iwa/plugins/olas/tests/test_service_manager.py +1065 -0
- iwa/plugins/olas/tests/test_service_manager_errors.py +208 -0
- iwa/plugins/olas/tests/test_service_manager_flows.py +497 -0
- iwa/plugins/olas/tests/test_service_manager_mech.py +135 -0
- iwa/plugins/olas/tests/test_service_manager_rewards.py +360 -0
- iwa/plugins/olas/tests/test_service_manager_validation.py +145 -0
- iwa/plugins/olas/tests/test_service_staking.py +342 -0
- iwa/plugins/olas/tests/test_staking_integration.py +269 -0
- iwa/plugins/olas/tests/test_staking_validation.py +109 -0
- iwa/plugins/olas/tui/__init__.py +1 -0
- iwa/plugins/olas/tui/olas_view.py +952 -0
- iwa/tools/check_profile.py +67 -0
- iwa/tools/release.py +111 -0
- iwa/tools/reset_env.py +111 -0
- iwa/tools/reset_tenderly.py +362 -0
- iwa/tools/restore_backup.py +82 -0
- iwa/tui/__init__.py +1 -0
- iwa/tui/app.py +174 -0
- iwa/tui/modals/__init__.py +5 -0
- iwa/tui/modals/base.py +406 -0
- iwa/tui/rpc.py +63 -0
- iwa/tui/screens/__init__.py +1 -0
- iwa/tui/screens/wallets.py +749 -0
- iwa/tui/tests/test_app.py +125 -0
- iwa/tui/tests/test_rpc.py +139 -0
- iwa/tui/tests/test_wallets_refactor.py +30 -0
- iwa/tui/tests/test_widgets.py +123 -0
- iwa/tui/widgets/__init__.py +5 -0
- iwa/tui/widgets/base.py +100 -0
- iwa/tui/workers.py +42 -0
- iwa/web/dependencies.py +76 -0
- iwa/web/models.py +76 -0
- iwa/web/routers/accounts.py +115 -0
- iwa/web/routers/olas/__init__.py +24 -0
- iwa/web/routers/olas/admin.py +169 -0
- iwa/web/routers/olas/funding.py +135 -0
- iwa/web/routers/olas/general.py +29 -0
- iwa/web/routers/olas/services.py +378 -0
- iwa/web/routers/olas/staking.py +341 -0
- iwa/web/routers/state.py +65 -0
- iwa/web/routers/swap.py +617 -0
- iwa/web/routers/transactions.py +153 -0
- iwa/web/server.py +155 -0
- iwa/web/tests/test_web_endpoints.py +713 -0
- iwa/web/tests/test_web_olas.py +430 -0
- iwa/web/tests/test_web_swap.py +103 -0
- iwa-0.0.1a2.dist-info/METADATA +234 -0
- iwa-0.0.1a2.dist-info/RECORD +186 -0
- iwa-0.0.1a2.dist-info/entry_points.txt +2 -0
- iwa-0.0.1a2.dist-info/licenses/LICENSE +21 -0
- iwa-0.0.1a2.dist-info/top_level.txt +4 -0
- tests/legacy_cow.py +248 -0
- tests/legacy_safe.py +93 -0
- tests/legacy_transaction_retry_logic.py +51 -0
- tests/legacy_tui.py +440 -0
- tests/legacy_wallets_screen.py +554 -0
- tests/legacy_web.py +243 -0
- tests/test_account_service.py +120 -0
- tests/test_balance_service.py +186 -0
- tests/test_chain.py +490 -0
- tests/test_chain_interface.py +210 -0
- tests/test_cli.py +139 -0
- tests/test_contract.py +195 -0
- tests/test_db.py +180 -0
- tests/test_drain_coverage.py +174 -0
- tests/test_erc20.py +95 -0
- tests/test_gnosis_plugin.py +111 -0
- tests/test_keys.py +449 -0
- tests/test_legacy_wallet.py +1285 -0
- tests/test_main.py +13 -0
- tests/test_mnemonic.py +217 -0
- tests/test_modals.py +109 -0
- tests/test_models.py +213 -0
- tests/test_monitor.py +202 -0
- tests/test_multisend.py +84 -0
- tests/test_plugin_service.py +119 -0
- tests/test_pricing.py +143 -0
- tests/test_rate_limiter.py +199 -0
- tests/test_reset_tenderly.py +202 -0
- tests/test_rpc_view.py +73 -0
- tests/test_safe_coverage.py +139 -0
- tests/test_safe_service.py +168 -0
- tests/test_service_manager_integration.py +61 -0
- tests/test_service_manager_structure.py +31 -0
- tests/test_service_transaction.py +176 -0
- tests/test_staking_router.py +71 -0
- tests/test_staking_simple.py +31 -0
- tests/test_tables.py +76 -0
- tests/test_transaction_service.py +161 -0
- tests/test_transfer_multisend.py +179 -0
- tests/test_transfer_native.py +220 -0
- tests/test_transfer_security.py +93 -0
- tests/test_transfer_structure.py +37 -0
- tests/test_transfer_swap_unit.py +155 -0
- tests/test_ui_coverage.py +66 -0
- tests/test_utils.py +53 -0
- tests/test_workers.py +91 -0
- tools/verify_drain.py +183 -0
- __init__.py +0 -2
- hello.py +0 -6
- iwa-0.0.0.dist-info/METADATA +0 -10
- iwa-0.0.0.dist-info/RECORD +0 -6
- iwa-0.0.0.dist-info/top_level.txt +0 -2
- {iwa-0.0.0.dist-info → iwa-0.0.1a2.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"""Tests for StakingContract functionality and validation."""
|
|
2
|
+
|
|
3
|
+
from datetime import datetime, timedelta, timezone
|
|
4
|
+
from unittest.mock import MagicMock, patch
|
|
5
|
+
|
|
6
|
+
import pytest
|
|
7
|
+
|
|
8
|
+
from iwa.plugins.olas.contracts.staking import StakingContract
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@pytest.fixture
|
|
12
|
+
def mock_staking():
|
|
13
|
+
"""Mock staking contract."""
|
|
14
|
+
with (
|
|
15
|
+
patch("iwa.plugins.olas.contracts.staking.ActivityCheckerContract"),
|
|
16
|
+
patch("iwa.core.contracts.contract.ChainInterfaces") as mock_ci,
|
|
17
|
+
):
|
|
18
|
+
mock_ci.get_instance.return_value.web3.eth.contract.return_value = MagicMock()
|
|
19
|
+
contract = StakingContract("0x78731D3Ca6b7E34aC0F824c42a7cC18A495cabaB", "gnosis")
|
|
20
|
+
# Mocking all initial calls in __init__
|
|
21
|
+
contract.call = MagicMock()
|
|
22
|
+
return contract
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def test_staking_get_service_info_nested_tuple(mock_staking):
|
|
26
|
+
"""Test get_service_info with nested tuple result from web3."""
|
|
27
|
+
nested_result = (("0xMultisig", "0xOwner", (1, 2), 1000, 500, 0),)
|
|
28
|
+
mock_staking.call.side_effect = [
|
|
29
|
+
"0x1", # activityChecker
|
|
30
|
+
100, # availableRewards
|
|
31
|
+
200, # balance
|
|
32
|
+
3600, # livenessPeriod
|
|
33
|
+
10, # rewardsPerSecond
|
|
34
|
+
10, # maxNumServices
|
|
35
|
+
50, # minStakingDeposit
|
|
36
|
+
7200, # minStakingDuration
|
|
37
|
+
"0xToken", # stakingToken
|
|
38
|
+
nested_result, # getServiceInfo
|
|
39
|
+
2000, # getNextRewardCheckpointTimestamp
|
|
40
|
+
]
|
|
41
|
+
# Re-init to trigger calls
|
|
42
|
+
with (
|
|
43
|
+
patch("iwa.plugins.olas.contracts.staking.ActivityCheckerContract"),
|
|
44
|
+
patch("iwa.core.contracts.contract.ChainInterfaces") as mock_ci,
|
|
45
|
+
):
|
|
46
|
+
mock_ci.get_instance.return_value.web3.eth.contract.return_value = MagicMock()
|
|
47
|
+
staking = StakingContract("0x78731D3Ca6b7E34aC0F824c42a7cC18A495cabaB", "gnosis")
|
|
48
|
+
staking.call = MagicMock(side_effect=[nested_result, 2000])
|
|
49
|
+
staking.activity_checker.get_multisig_nonces.return_value = (1, 3)
|
|
50
|
+
staking.get_required_requests = MagicMock(return_value=5)
|
|
51
|
+
|
|
52
|
+
info = staking.get_service_info(1)
|
|
53
|
+
assert info["multisig_address"] == "0xMultisig"
|
|
54
|
+
assert info["mech_requests_this_epoch"] == 1 # 3 - 2
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def test_staking_get_service_info_unpack_error(mock_staking):
|
|
58
|
+
"""Test get_service_info with invalid result length."""
|
|
59
|
+
invalid_result = ("0x1", "0x2") # Too short
|
|
60
|
+
mock_staking.call.return_value = invalid_result
|
|
61
|
+
with pytest.raises(ValueError):
|
|
62
|
+
mock_staking.get_service_info(1)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def test_staking_min_staking_duration_cache(mock_staking):
|
|
66
|
+
"""Test caching of minStakingDuration."""
|
|
67
|
+
mock_staking.call.return_value = 1234
|
|
68
|
+
assert mock_staking.min_staking_duration == 1234
|
|
69
|
+
assert mock_staking.call.call_count == 1
|
|
70
|
+
# Second call should use cache
|
|
71
|
+
assert mock_staking.min_staking_duration == 1234
|
|
72
|
+
assert mock_staking.call.call_count == 1
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def test_staking_checkpoint_needed(mock_staking):
|
|
76
|
+
"""Test is_checkpoint_needed logic."""
|
|
77
|
+
epoch_end = datetime.now(timezone.utc) - timedelta(seconds=1000)
|
|
78
|
+
mock_staking.get_next_epoch_start = MagicMock(return_value=epoch_end)
|
|
79
|
+
|
|
80
|
+
# 1. Grace period not passed
|
|
81
|
+
assert mock_staking.is_checkpoint_needed(grace_period_seconds=2000) is False
|
|
82
|
+
|
|
83
|
+
# 2. Grace period passed
|
|
84
|
+
assert mock_staking.is_checkpoint_needed(grace_period_seconds=500) is True
|
|
85
|
+
|
|
86
|
+
# 3. Epoch not ended
|
|
87
|
+
mock_staking.get_next_epoch_start.return_value = datetime.now(timezone.utc) + timedelta(
|
|
88
|
+
seconds=1000
|
|
89
|
+
)
|
|
90
|
+
assert mock_staking.is_checkpoint_needed() is False
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def test_staking_prepare_transactions(mock_staking):
|
|
94
|
+
"""Test preparation of various transactions."""
|
|
95
|
+
mock_staking.prepare_transaction = MagicMock(return_value={"data": "0x1"})
|
|
96
|
+
|
|
97
|
+
# Claim
|
|
98
|
+
assert mock_staking.prepare_claim_tx("0xOwner", 1) == {"data": "0x1"}
|
|
99
|
+
# Checkpoint
|
|
100
|
+
assert mock_staking.prepare_checkpoint_tx("0xCaller") == {"data": "0x1"}
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def test_staking_get_accrued_rewards(mock_staking):
|
|
104
|
+
"""Test get_accrued_rewards from mapServiceInfo."""
|
|
105
|
+
mock_staking.call.return_value = ("0x1", "0x2", (1, 2), 1000, 999, 0)
|
|
106
|
+
assert mock_staking.get_accrued_rewards(1) == 999
|
|
107
|
+
|
|
108
|
+
mock_staking.call.return_value = ("0x1",) # Too short
|
|
109
|
+
assert mock_staking.get_accrued_rewards(2) == 0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Olas TUI view module."""
|