forked from yearn/yearn-vaults
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathneon-brownie.patch
89 lines (82 loc) · 3.87 KB
/
neon-brownie.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
diff -ur brownie.orig/exceptions.py brownie/exceptions.py
--- brownie.orig/exceptions.py 2022-09-29 12:53:05.360807566 +0000
+++ brownie/exceptions.py 2022-09-29 13:27:59.394425310 +0000
@@ -103,7 +103,8 @@
err_msg = exc["data"]
if err_msg.endswith("0x"):
err_msg = exc["data"][:-2].strip()
- raise ValueError(f"{self.message}: {err_msg}") from None
+ # raise ValueError(f"{self.message}: {err_msg}") from None
+ return
self.revert_type = "revert"
err_msg = exc["data"][len(ERROR_SIG) :]
diff -ur brownie.orig/network/account.py brownie/network/account.py
--- brownie.orig/network/account.py 2022-09-29 12:53:05.360807566 +0000
+++ brownie/network/account.py 2022-09-29 14:10:24.570151366 +0000
@@ -426,7 +426,10 @@
if isinstance(gas_limit, bool) or gas_limit in (None, "auto"):
gas_buffer = gas_buffer or CONFIG.active_network["settings"]["gas_buffer"]
- gas_limit = self.estimate_gas(to, amount, 0, data or "")
+ try:
+ gas_limit = self.estimate_gas(to, amount, 0, data or "")
+ except:
+ gas_limit = 15000000
if gas_limit > 21000 and gas_buffer != 1:
gas_limit = Wei(gas_limit * gas_buffer)
return min(gas_limit, Chain().block_gas_limit)
@@ -750,7 +753,7 @@
except ValueError as e:
if txid is None:
exc = VirtualMachineError(e)
- if not hasattr(exc, "txid"):
+ if not hasattr(exc, "txid") or exc.txid == '':
raise exc from None
txid = exc.txid
print(f"\rTransaction sent: {color('bright blue')}{txid}{color}")
@@ -853,7 +856,8 @@
def _transact(self, tx: Dict, allow_revert: bool) -> Any:
if allow_revert is None:
- allow_revert = bool(CONFIG.network_type == "development")
+ allow_revert = bool(CONFIG.network_type == "development" or
+ CONFIG.active_network["id"] == "neon")
if not allow_revert:
self._check_for_revert(tx)
return web3.eth.send_transaction(tx)
@@ -954,7 +958,8 @@
def _transact(self, tx: Dict, allow_revert: bool) -> None:
if allow_revert is None:
- allow_revert = bool(CONFIG.network_type == "development")
+ allow_revert = bool(CONFIG.network_type == "development" or
+ CONFIG.active_network["id"] == "neon")
if not allow_revert:
self._check_for_revert(tx)
tx["chainId"] = web3.chain_id
diff -ur brownie.orig/network/state.py brownie/network/state.py
--- brownie.orig/network/state.py 2022-09-29 12:53:05.360807566 +0000
+++ brownie/network/state.py 2022-09-29 12:58:42.170353394 +0000
@@ -372,11 +372,14 @@
"""
if not isinstance(seconds, int):
raise TypeError("seconds must be an integer value")
- self._time_offset = int(rpc.Rpc().sleep(seconds))
+ if CONFIG.active_network["id"] == "neon":
+ time.sleep(seconds)
+ else:
+ self._time_offset = int(rpc.Rpc().sleep(seconds))
+ if seconds:
+ self._redo_buffer.clear()
+ self._current_id = rpc.Rpc().snapshot()
- if seconds:
- self._redo_buffer.clear()
- self._current_id = rpc.Rpc().snapshot()
def mine(self, blocks: int = 1, timestamp: int = None, timedelta: int = None) -> int:
"""
@@ -417,6 +420,10 @@
duration = (timestamp - now) / (blocks - 1)
params = [[round(now + duration * i)] for i in range(blocks)]
+ if CONFIG.active_network["id"] == "neon":
+ self.sleep(blocks)
+ return
+
for i in range(blocks):
rpc.Rpc().mine(*params[i])