ratio1 3.4.115__py3-none-any.whl → 3.4.117__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.
- ratio1/_ver.py +1 -1
- ratio1/bc/evm.py +102 -151
- ratio1/const/evm_net.py +177 -167
- ratio1/ipfs/r1fs.py +15 -4
- {ratio1-3.4.115.dist-info → ratio1-3.4.117.dist-info}/METADATA +1 -1
- {ratio1-3.4.115.dist-info → ratio1-3.4.117.dist-info}/RECORD +9 -9
- {ratio1-3.4.115.dist-info → ratio1-3.4.117.dist-info}/WHEEL +0 -0
- {ratio1-3.4.115.dist-info → ratio1-3.4.117.dist-info}/entry_points.txt +0 -0
- {ratio1-3.4.115.dist-info → ratio1-3.4.117.dist-info}/licenses/LICENSE +0 -0
ratio1/_ver.py
CHANGED
ratio1/bc/evm.py
CHANGED
|
@@ -29,7 +29,6 @@ Web3Vars = namedtuple(
|
|
|
29
29
|
"proxy_contract_address",
|
|
30
30
|
"controller_contract_address",
|
|
31
31
|
"poai_manager_address",
|
|
32
|
-
"get_oracles_abi",
|
|
33
32
|
]
|
|
34
33
|
)
|
|
35
34
|
|
|
@@ -238,7 +237,6 @@ class _EVMMixin:
|
|
|
238
237
|
str_genesis_date = network_data[dAuth.EvmNetData.EE_GENESIS_EPOCH_DATE_KEY]
|
|
239
238
|
controller_contract_address = network_data[dAuth.EvmNetData.DAUTH_CONTROLLER_ADDR_KEY]
|
|
240
239
|
poai_manager_address = network_data[dAuth.EvmNetData.DAUTH_POAI_MANAGER_ADDR_KEY]
|
|
241
|
-
get_oracles_abi = network_data[dAuth.EvmNetData.DAUTH_GET_ORACLES_ABI]
|
|
242
240
|
genesis_date = self.log.str_to_date(str_genesis_date).replace(tzinfo=timezone.utc)
|
|
243
241
|
ep_sec = (
|
|
244
242
|
network_data[dAuth.EvmNetData.EE_EPOCH_INTERVAL_SECONDS_KEY] *
|
|
@@ -261,7 +259,6 @@ class _EVMMixin:
|
|
|
261
259
|
proxy_contract_address=proxy_contract_address,
|
|
262
260
|
controller_contract_address=controller_contract_address,
|
|
263
261
|
poai_manager_address=poai_manager_address,
|
|
264
|
-
get_oracles_abi=get_oracles_abi,
|
|
265
262
|
)
|
|
266
263
|
return result
|
|
267
264
|
|
|
@@ -767,7 +764,7 @@ class _EVMMixin:
|
|
|
767
764
|
|
|
768
765
|
def web3_is_node_licensed(self, address : str, network=None, debug=False) -> bool:
|
|
769
766
|
"""
|
|
770
|
-
Check if the address
|
|
767
|
+
Check if the address has a valid license
|
|
771
768
|
|
|
772
769
|
Parameters
|
|
773
770
|
----------
|
|
@@ -777,18 +774,15 @@ class _EVMMixin:
|
|
|
777
774
|
if EE_VPN_IMPL:
|
|
778
775
|
self.P("VPN implementation. Skipping Ethereum check.", color='r')
|
|
779
776
|
return False
|
|
780
|
-
|
|
781
|
-
w3vars = self._get_web3_vars(network)
|
|
782
|
-
|
|
783
777
|
assert self.is_valid_eth_address(address), "Invalid Ethereum address"
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
self.P(f"Checking if {address} ({network}) is allowed...")
|
|
787
|
-
|
|
778
|
+
|
|
779
|
+
w3vars = self._get_web3_vars(network)
|
|
788
780
|
contract = w3vars.w3.eth.contract(
|
|
789
781
|
address=w3vars.controller_contract_address,
|
|
790
|
-
abi=EVM_ABI_DATA.
|
|
782
|
+
abi=EVM_ABI_DATA.CONTROLLER_ABI,
|
|
791
783
|
)
|
|
784
|
+
if debug:
|
|
785
|
+
self.P(f"Checking if {address} ({w3vars.network}) is allowed...")
|
|
792
786
|
|
|
793
787
|
result = contract.functions.isNodeActive(address).call()
|
|
794
788
|
return result
|
|
@@ -801,27 +795,22 @@ class _EVMMixin:
|
|
|
801
795
|
Parameters
|
|
802
796
|
----------
|
|
803
797
|
network : str, optional
|
|
804
|
-
|
|
798
|
+
The network to use. The default is None.
|
|
805
799
|
|
|
806
800
|
Returns
|
|
807
801
|
-------
|
|
808
802
|
list
|
|
809
|
-
|
|
810
|
-
|
|
803
|
+
The list of oracles addresses.
|
|
811
804
|
"""
|
|
812
805
|
w3vars = self._get_web3_vars(network)
|
|
813
|
-
|
|
814
|
-
func = w3vars.get_oracles_abi[0]["name"]
|
|
815
|
-
if debug:
|
|
816
|
-
self.P(f"Getting oracles for {w3vars.network} via {w3vars.rpc_url} using `{func}`...")
|
|
817
|
-
|
|
818
806
|
contract = w3vars.w3.eth.contract(
|
|
819
807
|
address=w3vars.controller_contract_address,
|
|
820
|
-
abi=
|
|
808
|
+
abi=EVM_ABI_DATA.CONTROLLER_ABI,
|
|
821
809
|
)
|
|
810
|
+
if debug:
|
|
811
|
+
self.P(f"Getting oracles for {w3vars.network} via {w3vars.rpc_url}...")
|
|
822
812
|
|
|
823
|
-
|
|
824
|
-
result = get_oracles_func().call()
|
|
813
|
+
result = contract.functions.getOracles().call()
|
|
825
814
|
return result
|
|
826
815
|
|
|
827
816
|
|
|
@@ -842,6 +831,7 @@ class _EVMMixin:
|
|
|
842
831
|
if address is None:
|
|
843
832
|
address = self.eth_address
|
|
844
833
|
assert self.is_valid_eth_address(address), "Invalid Ethereum address"
|
|
834
|
+
|
|
845
835
|
w3vars = self._get_web3_vars(network)
|
|
846
836
|
balance_wei = w3vars.w3.eth.get_balance(address)
|
|
847
837
|
balance_eth = w3vars.w3.from_wei(balance_wei, 'ether')
|
|
@@ -981,8 +971,8 @@ class _EVMMixin:
|
|
|
981
971
|
if address is None:
|
|
982
972
|
address = self.eth_address
|
|
983
973
|
assert self.is_valid_eth_address(address), "Invalid Ethereum address"
|
|
984
|
-
w3vars = self._get_web3_vars(network)
|
|
985
974
|
|
|
975
|
+
w3vars = self._get_web3_vars(network)
|
|
986
976
|
token_contract = w3vars.w3.eth.contract(
|
|
987
977
|
address=w3vars.r1_contract_address, abi=EVM_ABI_DATA.ERC20_ABI
|
|
988
978
|
)
|
|
@@ -991,7 +981,6 @@ class _EVMMixin:
|
|
|
991
981
|
decimals = token_contract.functions.decimals().call()
|
|
992
982
|
except Exception:
|
|
993
983
|
decimals = 18 # default to 18 if the decimals call fails
|
|
994
|
-
|
|
995
984
|
raw_balance = token_contract.functions.balanceOf(address).call()
|
|
996
985
|
human_balance = raw_balance / (10 ** decimals)
|
|
997
986
|
return float(human_balance)
|
|
@@ -1014,44 +1003,39 @@ class _EVMMixin:
|
|
|
1014
1003
|
Parameters
|
|
1015
1004
|
----------
|
|
1016
1005
|
to_address : str
|
|
1017
|
-
|
|
1006
|
+
The recipient's Ethereum address.
|
|
1018
1007
|
|
|
1019
1008
|
amount : float
|
|
1020
|
-
|
|
1009
|
+
The amount of R1 tokens to send (in human-readable units).
|
|
1021
1010
|
|
|
1022
1011
|
extra_buffer_eth : float, optional
|
|
1023
|
-
|
|
1012
|
+
Additional ETH (in Ether) as a buffer for gas fees. Default is 0.005 ETH.
|
|
1024
1013
|
|
|
1025
1014
|
wait_for_tx : bool, optional
|
|
1026
|
-
|
|
1027
|
-
|
|
1015
|
+
If True, waits for the transaction to be mined and returns the receipt.
|
|
1016
|
+
If False, returns immediately with the transaction hash.
|
|
1028
1017
|
|
|
1029
1018
|
timeout : int, optional
|
|
1030
|
-
|
|
1019
|
+
Maximum number of seconds to wait for the transaction receipt. Default is 120.
|
|
1031
1020
|
|
|
1032
1021
|
network : str, optional
|
|
1033
|
-
|
|
1022
|
+
The network to use. If None, uses the default self.evm_network.
|
|
1034
1023
|
|
|
1035
1024
|
return_receipt: bool, optional
|
|
1036
|
-
|
|
1025
|
+
If True, returns the transaction receipt instead of the transaction hash.
|
|
1037
1026
|
|
|
1038
1027
|
raise_if_error : bool, optional
|
|
1039
|
-
|
|
1028
|
+
If True, raises an exception if the transaction fails. Default is False.
|
|
1040
1029
|
|
|
1041
1030
|
Returns
|
|
1042
1031
|
-------
|
|
1043
|
-
|
|
1044
|
-
|
|
1032
|
+
If wait_for_tx is False, returns the transaction hash as a string.
|
|
1033
|
+
If wait_for_tx is True, returns the transaction receipt as a dict.
|
|
1045
1034
|
"""
|
|
1046
|
-
# Validate the recipient address.
|
|
1047
1035
|
assert self.is_valid_eth_address(to_address), "Invalid Ethereum address"
|
|
1048
|
-
|
|
1049
|
-
# Retrieve the Web3 instance, RPC URL, and the R1 contract address.
|
|
1050
|
-
# Note: This follows the same pattern as web3_get_balance_r1.
|
|
1036
|
+
|
|
1051
1037
|
w3vars = self._get_web3_vars(network)
|
|
1052
1038
|
network = w3vars.network
|
|
1053
|
-
|
|
1054
|
-
# Create the token contract instance.
|
|
1055
1039
|
token_contract = w3vars.w3.eth.contract(
|
|
1056
1040
|
address=w3vars.r1_contract_address, abi=EVM_ABI_DATA.ERC20_ABI
|
|
1057
1041
|
)
|
|
@@ -1061,7 +1045,6 @@ class _EVMMixin:
|
|
|
1061
1045
|
decimals = token_contract.functions.decimals().call()
|
|
1062
1046
|
except Exception:
|
|
1063
1047
|
decimals = 18
|
|
1064
|
-
|
|
1065
1048
|
# Convert the human-readable amount to the token's smallest unit.
|
|
1066
1049
|
token_amount = int(amount * (10 ** decimals))
|
|
1067
1050
|
|
|
@@ -1076,23 +1059,20 @@ class _EVMMixin:
|
|
|
1076
1059
|
return None
|
|
1077
1060
|
|
|
1078
1061
|
# Estimate gas fees for the token transfer.
|
|
1079
|
-
gas_price = w3vars.w3.
|
|
1062
|
+
gas_price = w3vars.w3.eth.gas_price # This fetches the current suggested gas price from the network.
|
|
1080
1063
|
estimated_gas = token_contract.functions.transfer(
|
|
1081
1064
|
to_address, token_amount
|
|
1082
1065
|
).estimate_gas(
|
|
1083
1066
|
{'from': self.eth_address}
|
|
1084
1067
|
)
|
|
1085
1068
|
gas_cost = estimated_gas * gas_price
|
|
1086
|
-
|
|
1087
1069
|
# Check that the sender's ETH balance can cover gas costs plus an extra buffer.
|
|
1088
1070
|
eth_balance = w3vars.w3.eth.get_balance(self.eth_address)
|
|
1089
1071
|
extra_buffer = w3vars.w3.to_wei(extra_buffer_eth, 'ether')
|
|
1090
1072
|
if eth_balance < gas_cost + extra_buffer:
|
|
1091
1073
|
raise Exception("Insufficient ETH balance to cover gas fees and extra buffer.")
|
|
1092
|
-
|
|
1093
1074
|
# Get the transaction count for the nonce.
|
|
1094
1075
|
nonce = w3vars.w3.eth.get_transaction_count(self.eth_address)
|
|
1095
|
-
|
|
1096
1076
|
# Programmatically determine the chainId.
|
|
1097
1077
|
chain_id = w3vars.w3.eth.chain_id
|
|
1098
1078
|
|
|
@@ -1104,13 +1084,11 @@ class _EVMMixin:
|
|
|
1104
1084
|
'gasPrice': gas_price,
|
|
1105
1085
|
'chainId': chain_id,
|
|
1106
1086
|
})
|
|
1107
|
-
|
|
1108
1087
|
self.P(f"Executing transaction on {network} via {w3vars.rpc_url}:\n {json.dumps(dict(tx), indent=2)}", verbosity=2)
|
|
1109
1088
|
|
|
1110
1089
|
# Sign the transaction using the internal account (via _get_eth_account).
|
|
1111
1090
|
eth_account = self._get_eth_account()
|
|
1112
1091
|
signed_tx = w3vars.w3.eth.account.sign_transaction(tx, eth_account.key)
|
|
1113
|
-
|
|
1114
1092
|
# Broadcast the transaction.
|
|
1115
1093
|
tx_hash = w3vars.w3.eth.send_raw_transaction(signed_tx.raw_transaction)
|
|
1116
1094
|
|
|
@@ -1139,41 +1117,31 @@ class _EVMMixin:
|
|
|
1139
1117
|
Parameters
|
|
1140
1118
|
----------
|
|
1141
1119
|
node_address : str
|
|
1142
|
-
|
|
1120
|
+
The node address (must be a valid Ethereum address).
|
|
1143
1121
|
|
|
1144
1122
|
network : str, optional
|
|
1145
|
-
|
|
1123
|
+
The network to use. If None, defaults to self.evm_network.
|
|
1146
1124
|
|
|
1147
1125
|
raise_if_issue : bool, optional
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1126
|
+
If True, raises an exception based on custom criteria (e.g., if node is banned).
|
|
1127
|
+
Default is False.
|
|
1151
1128
|
|
|
1152
1129
|
Returns
|
|
1153
1130
|
-------
|
|
1154
1131
|
dict
|
|
1155
|
-
|
|
1132
|
+
A dictionary containing all license details returned by getNodeLicenseDetails.
|
|
1156
1133
|
"""
|
|
1157
|
-
# Validate the node address.
|
|
1158
1134
|
assert self.is_valid_eth_address(node_address), "Invalid Ethereum address"
|
|
1159
1135
|
|
|
1160
|
-
# Retrieve the necessary Web3 variables (pattern consistent with web3_send_r1).
|
|
1161
1136
|
w3vars = self._get_web3_vars(network)
|
|
1162
1137
|
network = w3vars.network
|
|
1163
|
-
|
|
1164
|
-
# Create the contract instance for retrieving node info.
|
|
1165
|
-
# Assuming you have a specific contract address in w3vars (e.g. license_contract_address),
|
|
1166
|
-
# or you may adapt this code if your contract address is stored differently.
|
|
1167
1138
|
contract = w3vars.w3.eth.contract(
|
|
1168
|
-
address=w3vars.proxy_contract_address,
|
|
1169
|
-
abi=EVM_ABI_DATA.
|
|
1139
|
+
address=w3vars.proxy_contract_address,
|
|
1140
|
+
abi=EVM_ABI_DATA.PROXY_ABI,
|
|
1170
1141
|
)
|
|
1171
|
-
|
|
1172
1142
|
self.P(f"`getNodeLicenseDetails` on {network} via {w3vars.rpc_url}", verbosity=2)
|
|
1173
1143
|
|
|
1174
|
-
# Call the contract function to get details.
|
|
1175
1144
|
result_tuple = contract.functions.getNodeLicenseDetails(node_address).call()
|
|
1176
|
-
|
|
1177
1145
|
# Unpack the tuple into a dictionary for readability.
|
|
1178
1146
|
details = {
|
|
1179
1147
|
"network": network,
|
|
@@ -1198,7 +1166,6 @@ class _EVMMixin:
|
|
|
1198
1166
|
is_valid = not (
|
|
1199
1167
|
no_owner or no_real_addr or is_banned
|
|
1200
1168
|
)
|
|
1201
|
-
|
|
1202
1169
|
details['isValid'] = is_valid
|
|
1203
1170
|
|
|
1204
1171
|
self.P(f"Node Info:\n{json.dumps(details, indent=2)}", verbosity=2)
|
|
@@ -1220,35 +1187,27 @@ class _EVMMixin:
|
|
|
1220
1187
|
Parameters
|
|
1221
1188
|
----------
|
|
1222
1189
|
wallet_addr : str
|
|
1223
|
-
|
|
1190
|
+
The Ethereum wallet address to check.
|
|
1224
1191
|
|
|
1225
1192
|
network : str, optional
|
|
1226
|
-
|
|
1193
|
+
The network to use. If None, defaults to self.evm_network.
|
|
1227
1194
|
|
|
1228
1195
|
Returns
|
|
1229
1196
|
-------
|
|
1230
1197
|
list of dict
|
|
1231
|
-
|
|
1198
|
+
A list of dictionaries containing node details.
|
|
1232
1199
|
"""
|
|
1233
1200
|
assert self.is_valid_eth_address(address), "Invalid Ethereum address"
|
|
1234
1201
|
|
|
1235
|
-
# Retrieve the necessary Web3 variables (pattern consistent with web3_send_r1).
|
|
1236
1202
|
w3vars = self._get_web3_vars(network)
|
|
1237
1203
|
network = w3vars.network
|
|
1238
|
-
|
|
1239
|
-
# Create the contract instance for retrieving node info.
|
|
1240
|
-
# Assuming you have a specific contract address in w3vars (e.g. license_contract_address),
|
|
1241
|
-
# or you may adapt this code if your contract address is stored differently.
|
|
1242
1204
|
contract = w3vars.w3.eth.contract(
|
|
1243
|
-
address=w3vars.proxy_contract_address,
|
|
1244
|
-
abi=EVM_ABI_DATA.
|
|
1205
|
+
address=w3vars.proxy_contract_address,
|
|
1206
|
+
abi=EVM_ABI_DATA.PROXY_ABI,
|
|
1245
1207
|
)
|
|
1246
|
-
|
|
1247
1208
|
self.P(f"`getWalletNodes` on {network} via {w3vars.rpc_url}", verbosity=2)
|
|
1248
|
-
|
|
1209
|
+
|
|
1249
1210
|
result = contract.functions.getWalletNodes(address).call()
|
|
1250
|
-
# Unpack the tuple into a dictionary for readability.
|
|
1251
|
-
|
|
1252
1211
|
return result
|
|
1253
1212
|
|
|
1254
1213
|
def web3_get_addresses_balances(
|
|
@@ -1262,32 +1221,28 @@ class _EVMMixin:
|
|
|
1262
1221
|
Parameters
|
|
1263
1222
|
----------
|
|
1264
1223
|
addresses : list of str
|
|
1265
|
-
|
|
1224
|
+
The list of Ethereum addresses to check.
|
|
1266
1225
|
|
|
1267
1226
|
network : str, optional
|
|
1268
|
-
|
|
1227
|
+
The network to use. If None, defaults to self.evm_network.
|
|
1269
1228
|
|
|
1270
1229
|
Returns
|
|
1271
1230
|
-------
|
|
1272
1231
|
dict
|
|
1273
|
-
|
|
1232
|
+
A dictionary mapping each address to its balances.
|
|
1274
1233
|
"""
|
|
1275
1234
|
assert isinstance(addresses, list), "Addresses must be a list"
|
|
1276
1235
|
assert all(self.is_valid_eth_address(addr) for addr in addresses), "All addresses must be valid Ethereum addresses"
|
|
1277
1236
|
|
|
1278
|
-
# Retrieve the necessary Web3 variables (pattern consistent with web3_send_r1).
|
|
1279
1237
|
w3vars = self._get_web3_vars(network)
|
|
1280
1238
|
network = w3vars.network
|
|
1281
|
-
|
|
1282
|
-
# Create the contract instance for the proxy contract.
|
|
1283
1239
|
contract = w3vars.w3.eth.contract(
|
|
1284
1240
|
address=w3vars.proxy_contract_address,
|
|
1285
|
-
abi=EVM_ABI_DATA.
|
|
1241
|
+
abi=EVM_ABI_DATA.PROXY_ABI,
|
|
1286
1242
|
)
|
|
1287
|
-
|
|
1288
1243
|
self.P(f"`getAddressesBalances` on {network} via {w3vars.rpc_url}", verbosity=2)
|
|
1244
|
+
|
|
1289
1245
|
result = contract.functions.getAddressesBalances(addresses).call()
|
|
1290
|
-
|
|
1291
1246
|
balances = {}
|
|
1292
1247
|
for item in result:
|
|
1293
1248
|
addr = item[0]
|
|
@@ -1297,7 +1252,6 @@ class _EVMMixin:
|
|
|
1297
1252
|
"ethBalance": float(eth_balance),
|
|
1298
1253
|
"r1Balance": float(r1_balance),
|
|
1299
1254
|
}
|
|
1300
|
-
|
|
1301
1255
|
return balances
|
|
1302
1256
|
|
|
1303
1257
|
def web3_get_job_details(
|
|
@@ -1311,31 +1265,26 @@ class _EVMMixin:
|
|
|
1311
1265
|
Parameters
|
|
1312
1266
|
----------
|
|
1313
1267
|
job_id : int
|
|
1314
|
-
|
|
1268
|
+
The job ID to retrieve details for.
|
|
1315
1269
|
|
|
1316
1270
|
network : str, optional
|
|
1317
|
-
|
|
1318
|
-
|
|
1271
|
+
The network to use. If None, defaults to self.evm_network.
|
|
1319
1272
|
|
|
1320
1273
|
Returns
|
|
1321
1274
|
-------
|
|
1322
1275
|
dict
|
|
1323
|
-
|
|
1276
|
+
A dictionary containing all job details returned by getJobDetails.
|
|
1324
1277
|
"""
|
|
1325
|
-
# Validate the job ID.
|
|
1326
1278
|
assert isinstance(job_id, int), "Invalid job ID"
|
|
1327
1279
|
|
|
1328
|
-
# Retrieve the necessary Web3 variables (pattern consistent with web3_send_r1).
|
|
1329
1280
|
w3vars = self._get_web3_vars(network)
|
|
1330
1281
|
network = w3vars.network
|
|
1331
1282
|
contract = w3vars.w3.eth.contract(
|
|
1332
1283
|
address=w3vars.poai_manager_address,
|
|
1333
1284
|
abi=EVM_ABI_DATA.POAI_MANAGER_ABI
|
|
1334
1285
|
)
|
|
1335
|
-
|
|
1336
1286
|
self.P(f"`getJobDetails` on {network} via {w3vars.rpc_url}", verbosity=2)
|
|
1337
1287
|
|
|
1338
|
-
# Call the contract function to get details.
|
|
1339
1288
|
result_tuple = contract.functions.getJobDetails(job_id).call()
|
|
1340
1289
|
details = self._format_job_details(result_tuple, network)
|
|
1341
1290
|
self.P(f"Job Details:\n{json.dumps(details, indent=2)}", verbosity=2)
|
|
@@ -1351,12 +1300,12 @@ class _EVMMixin:
|
|
|
1351
1300
|
Parameters
|
|
1352
1301
|
----------
|
|
1353
1302
|
network : str, optional
|
|
1354
|
-
|
|
1303
|
+
The network to use. Defaults to the current engine network.
|
|
1355
1304
|
|
|
1356
1305
|
Returns
|
|
1357
1306
|
-------
|
|
1358
1307
|
list[dict]
|
|
1359
|
-
|
|
1308
|
+
A list with the job details for every active job.
|
|
1360
1309
|
"""
|
|
1361
1310
|
w3vars = self._get_web3_vars(network)
|
|
1362
1311
|
network = w3vars.network
|
|
@@ -1364,8 +1313,8 @@ class _EVMMixin:
|
|
|
1364
1313
|
address=w3vars.poai_manager_address,
|
|
1365
1314
|
abi=EVM_ABI_DATA.POAI_MANAGER_ABI
|
|
1366
1315
|
)
|
|
1367
|
-
|
|
1368
1316
|
self.P(f"`getAllActiveJobs` on {network} via {w3vars.rpc_url}", verbosity=2)
|
|
1317
|
+
|
|
1369
1318
|
raw_jobs = contract.functions.getAllActiveJobs().call()
|
|
1370
1319
|
jobs = [self._format_job_details(job, network) for job in raw_jobs]
|
|
1371
1320
|
self.P(f"Active jobs found: {len(jobs)}", verbosity=2)
|
|
@@ -1386,28 +1335,23 @@ class _EVMMixin:
|
|
|
1386
1335
|
Parameters
|
|
1387
1336
|
----------
|
|
1388
1337
|
job_id : int
|
|
1389
|
-
|
|
1338
|
+
The job ID to update.
|
|
1390
1339
|
|
|
1391
1340
|
nodes : list
|
|
1392
|
-
|
|
1341
|
+
The list of new nodes running the job.
|
|
1393
1342
|
|
|
1394
1343
|
network : str, optional
|
|
1395
|
-
|
|
1344
|
+
The network to use. If None, uses the default self.evm_network.
|
|
1396
1345
|
|
|
1397
1346
|
Returns
|
|
1398
1347
|
-------
|
|
1399
|
-
|
|
1348
|
+
The transaction hash.
|
|
1400
1349
|
"""
|
|
1401
|
-
# Validate the input parameters.
|
|
1402
1350
|
assert isinstance(job_id, int), "Invalid job ID"
|
|
1403
1351
|
assert isinstance(nodes, list), "Nodes must be a list"
|
|
1404
|
-
|
|
1405
|
-
# Retrieve the Web3 instance, RPC URL, and the R1 contract address.
|
|
1406
|
-
# Note: This follows the same pattern as web3_get_balance_r1.
|
|
1352
|
+
|
|
1407
1353
|
w3vars = self._get_web3_vars(network)
|
|
1408
1354
|
network = w3vars.network
|
|
1409
|
-
|
|
1410
|
-
# Create the token contract instance.
|
|
1411
1355
|
poai_manager_contract = w3vars.w3.eth.contract(
|
|
1412
1356
|
address=w3vars.poai_manager_address, abi=EVM_ABI_DATA.POAI_MANAGER_ABI
|
|
1413
1357
|
)
|
|
@@ -1416,15 +1360,12 @@ class _EVMMixin:
|
|
|
1416
1360
|
gas_price = w3vars.w3.eth.gas_price # This fetches the current suggested gas price from the network.
|
|
1417
1361
|
estimated_gas = 1_000_000 # Have enough gas to cover all the actions if consensus is reached
|
|
1418
1362
|
gas_cost = estimated_gas * gas_price
|
|
1419
|
-
|
|
1420
1363
|
# Check that the sender's ETH balance can cover gas costs plus an extra buffer.
|
|
1421
1364
|
eth_balance = w3vars.w3.eth.get_balance(self.eth_address)
|
|
1422
1365
|
if eth_balance < gas_cost:
|
|
1423
1366
|
raise Exception("Insufficient ETH balance to cover gas fees.")
|
|
1424
|
-
|
|
1425
1367
|
# Get the transaction count for the nonce.
|
|
1426
1368
|
nonce = w3vars.w3.eth.get_transaction_count(self.eth_address)
|
|
1427
|
-
|
|
1428
1369
|
# Programmatically determine the chainId.
|
|
1429
1370
|
chain_id = w3vars.w3.eth.chain_id
|
|
1430
1371
|
|
|
@@ -1436,13 +1377,11 @@ class _EVMMixin:
|
|
|
1436
1377
|
'gasPrice': gas_price,
|
|
1437
1378
|
'chainId': chain_id,
|
|
1438
1379
|
})
|
|
1439
|
-
|
|
1440
1380
|
self.P(f"Executing transaction on {network} via {w3vars.rpc_url}:\n {json.dumps(dict(tx), indent=2)}", verbosity=2)
|
|
1441
1381
|
|
|
1442
1382
|
# Sign the transaction using the internal account (via _get_eth_account).
|
|
1443
1383
|
eth_account = self._get_eth_account()
|
|
1444
1384
|
signed_tx = w3vars.w3.eth.account.sign_transaction(tx, eth_account.key)
|
|
1445
|
-
|
|
1446
1385
|
# Broadcast the transaction.
|
|
1447
1386
|
tx_hash = w3vars.w3.eth.send_raw_transaction(signed_tx.raw_transaction)
|
|
1448
1387
|
|
|
@@ -1471,18 +1410,14 @@ class _EVMMixin:
|
|
|
1471
1410
|
Parameters
|
|
1472
1411
|
----------
|
|
1473
1412
|
network : str, optional
|
|
1474
|
-
|
|
1413
|
+
The network to use. If None, uses the default self.evm_network.
|
|
1475
1414
|
|
|
1476
1415
|
Returns
|
|
1477
1416
|
-------
|
|
1478
|
-
|
|
1417
|
+
The transaction hash.
|
|
1479
1418
|
"""
|
|
1480
|
-
# Retrieve the Web3 instance, RPC URL, and the R1 contract address.
|
|
1481
|
-
# Note: This follows the same pattern as web3_get_balance_r1.
|
|
1482
1419
|
w3vars = self._get_web3_vars(network)
|
|
1483
1420
|
network = w3vars.network
|
|
1484
|
-
|
|
1485
|
-
# Create the token contract instance.
|
|
1486
1421
|
poai_manager_contract = w3vars.w3.eth.contract(
|
|
1487
1422
|
address=w3vars.poai_manager_address, abi=EVM_ABI_DATA.POAI_MANAGER_ABI
|
|
1488
1423
|
)
|
|
@@ -1493,15 +1428,12 @@ class _EVMMixin:
|
|
|
1493
1428
|
{'from': self.eth_address}
|
|
1494
1429
|
)
|
|
1495
1430
|
gas_cost = estimated_gas * gas_price
|
|
1496
|
-
|
|
1497
1431
|
# Check that the sender's ETH balance can cover gas costs plus an extra buffer.
|
|
1498
1432
|
eth_balance = w3vars.w3.eth.get_balance(self.eth_address)
|
|
1499
1433
|
if eth_balance < gas_cost:
|
|
1500
1434
|
raise Exception("Insufficient ETH balance to cover gas fees.")
|
|
1501
|
-
|
|
1502
1435
|
# Get the transaction count for the nonce.
|
|
1503
1436
|
nonce = w3vars.w3.eth.get_transaction_count(self.eth_address)
|
|
1504
|
-
|
|
1505
1437
|
# Programmatically determine the chainId.
|
|
1506
1438
|
chain_id = w3vars.w3.eth.chain_id
|
|
1507
1439
|
|
|
@@ -1513,13 +1445,11 @@ class _EVMMixin:
|
|
|
1513
1445
|
'gasPrice': gas_price,
|
|
1514
1446
|
'chainId': chain_id,
|
|
1515
1447
|
})
|
|
1516
|
-
|
|
1517
1448
|
self.P(f"Executing transaction on {network} via {w3vars.rpc_url}:\n {json.dumps(dict(tx), indent=2)}", verbosity=2)
|
|
1518
1449
|
|
|
1519
1450
|
# Sign the transaction using the internal account (via _get_eth_account).
|
|
1520
1451
|
eth_account = self._get_eth_account()
|
|
1521
1452
|
signed_tx = w3vars.w3.eth.account.sign_transaction(tx, eth_account.key)
|
|
1522
|
-
|
|
1523
1453
|
# Broadcast the transaction.
|
|
1524
1454
|
tx_hash = w3vars.w3.eth.send_raw_transaction(signed_tx.raw_transaction)
|
|
1525
1455
|
|
|
@@ -1547,32 +1477,26 @@ class _EVMMixin:
|
|
|
1547
1477
|
Parameters
|
|
1548
1478
|
----------
|
|
1549
1479
|
oracle_address : str
|
|
1550
|
-
|
|
1480
|
+
The oracle address to check for.
|
|
1551
1481
|
|
|
1552
1482
|
network : str, optional
|
|
1553
|
-
|
|
1483
|
+
The network to use. If None, defaults to self.evm_network.
|
|
1554
1484
|
|
|
1555
1485
|
Returns
|
|
1556
1486
|
-------
|
|
1557
1487
|
list
|
|
1558
|
-
|
|
1488
|
+
A list of unvalidated job IDs.
|
|
1559
1489
|
"""
|
|
1560
|
-
# Retrieve the necessary Web3 variables (pattern consistent with web3_get_job_details).
|
|
1561
1490
|
w3vars = self._get_web3_vars(network)
|
|
1562
1491
|
network = w3vars.network
|
|
1563
|
-
|
|
1564
1492
|
contract = w3vars.w3.eth.contract(
|
|
1565
1493
|
address=w3vars.poai_manager_address,
|
|
1566
1494
|
abi=EVM_ABI_DATA.POAI_MANAGER_ABI
|
|
1567
1495
|
)
|
|
1568
|
-
|
|
1569
1496
|
self.P(f"`getUnvalidatedJobIds` on {network} via {w3vars.rpc_url}", verbosity=2)
|
|
1570
1497
|
|
|
1571
|
-
# Call the contract function to get unvalidated job IDs.
|
|
1572
1498
|
result = contract.functions.getUnvalidatedJobIds(oracle_address).call()
|
|
1573
|
-
|
|
1574
1499
|
self.P(f"Unvalidated Job IDs: {result}", verbosity=2)
|
|
1575
|
-
|
|
1576
1500
|
return result
|
|
1577
1501
|
|
|
1578
1502
|
def web3_get_first_closable_job_id(
|
|
@@ -1585,29 +1509,25 @@ class _EVMMixin:
|
|
|
1585
1509
|
Parameters
|
|
1586
1510
|
----------
|
|
1587
1511
|
network : str, optional
|
|
1588
|
-
|
|
1512
|
+
The network to use. If None, defaults to self.evm_network.
|
|
1589
1513
|
|
|
1590
1514
|
Returns
|
|
1591
1515
|
-------
|
|
1592
1516
|
int or None
|
|
1593
|
-
|
|
1517
|
+
The ID of the first closable job, or None if no such job exists.
|
|
1594
1518
|
"""
|
|
1595
1519
|
w3vars = self._get_web3_vars(network)
|
|
1596
1520
|
network = w3vars.network
|
|
1597
|
-
|
|
1598
1521
|
contract = w3vars.w3.eth.contract(
|
|
1599
1522
|
address=w3vars.poai_manager_address,
|
|
1600
1523
|
abi=EVM_ABI_DATA.POAI_MANAGER_ABI
|
|
1601
1524
|
)
|
|
1602
|
-
|
|
1603
1525
|
self.P(f"`getFirstClosableJobId` on {network} via {w3vars.rpc_url}", verbosity=2)
|
|
1604
1526
|
|
|
1605
|
-
# Call the contract function to get the first closable job ID.
|
|
1606
1527
|
result = contract.functions.getFirstClosableJobId().call()
|
|
1607
1528
|
if result == 0:
|
|
1608
1529
|
result = None
|
|
1609
1530
|
self.P(f"First closable job ID: {result}", verbosity=2)
|
|
1610
|
-
|
|
1611
1531
|
return result
|
|
1612
1532
|
|
|
1613
1533
|
def web3_get_is_last_epoch_allocated(
|
|
@@ -1620,31 +1540,62 @@ class _EVMMixin:
|
|
|
1620
1540
|
Parameters
|
|
1621
1541
|
----------
|
|
1622
1542
|
network : str, optional
|
|
1623
|
-
|
|
1543
|
+
The network to use. If None, defaults to self.evm_network.
|
|
1624
1544
|
|
|
1625
1545
|
Returns
|
|
1626
1546
|
-------
|
|
1627
1547
|
bool
|
|
1628
|
-
|
|
1548
|
+
True if the last epoch has been allocated, False otherwise.
|
|
1629
1549
|
"""
|
|
1630
|
-
# Retrieve the necessary Web3 variables (pattern consistent with web3_get_unvalidated_job_ids).
|
|
1631
1550
|
w3vars = self._get_web3_vars(network)
|
|
1632
1551
|
network = w3vars.network
|
|
1633
|
-
|
|
1634
1552
|
contract = w3vars.w3.eth.contract(
|
|
1635
1553
|
address=w3vars.poai_manager_address,
|
|
1636
1554
|
abi=EVM_ABI_DATA.POAI_MANAGER_ABI
|
|
1637
1555
|
)
|
|
1638
|
-
|
|
1639
1556
|
self.P(f"`getIsLastEpochAllocated` on {network} via {w3vars.rpc_url}", verbosity=2)
|
|
1640
1557
|
|
|
1641
|
-
# Call the contract function to check if last epoch is allocated.
|
|
1642
1558
|
result = contract.functions.getIsLastEpochAllocated().call()
|
|
1643
|
-
|
|
1644
1559
|
self.P(f"Last epoch allocated: {result}", verbosity=2)
|
|
1645
|
-
|
|
1646
1560
|
return result
|
|
1647
1561
|
|
|
1562
|
+
def web3_get_user_escrow_details(self, address: str, network: str = None):
|
|
1563
|
+
"""
|
|
1564
|
+
Retrieve escrow details for a given wallet address.
|
|
1565
|
+
|
|
1566
|
+
Parameters
|
|
1567
|
+
----------
|
|
1568
|
+
address : str
|
|
1569
|
+
The Ethereum wallet address to check.
|
|
1570
|
+
|
|
1571
|
+
network : str, optional
|
|
1572
|
+
The network to use. If None, defaults to self.evm_network.
|
|
1573
|
+
|
|
1574
|
+
Returns
|
|
1575
|
+
-------
|
|
1576
|
+
dict
|
|
1577
|
+
A dictionary containing the user escrow details.
|
|
1578
|
+
"""
|
|
1579
|
+
assert self.is_valid_eth_address(address), "Invalid Ethereum address"
|
|
1580
|
+
|
|
1581
|
+
w3vars = self._get_web3_vars(network)
|
|
1582
|
+
network = w3vars.network
|
|
1583
|
+
contract = w3vars.w3.eth.contract(
|
|
1584
|
+
address=w3vars.proxy_contract_address,
|
|
1585
|
+
abi=EVM_ABI_DATA.PROXY_ABI,
|
|
1586
|
+
)
|
|
1587
|
+
self.P(f"`getUserEscrowDetails` on {network} via {w3vars.rpc_url}", verbosity=2)
|
|
1588
|
+
|
|
1589
|
+
result = contract.functions.getUserEscrowDetails(address).call()
|
|
1590
|
+
details = {
|
|
1591
|
+
"network": network,
|
|
1592
|
+
"isActive": result[0],
|
|
1593
|
+
"escrowAddress": result[1],
|
|
1594
|
+
"escrowOwner": result[2],
|
|
1595
|
+
"permissions": result[3],
|
|
1596
|
+
}
|
|
1597
|
+
return details
|
|
1598
|
+
|
|
1648
1599
|
def _format_job_details(self, raw_job_details, network: str):
|
|
1649
1600
|
"""
|
|
1650
1601
|
Normalize the job details tuple returned by the PoAI Manager contract.
|
ratio1/const/evm_net.py
CHANGED
|
@@ -10,9 +10,7 @@ class EvmNetData:
|
|
|
10
10
|
DAUTH_MND_ADDR_KEY = 'EE_DAUTH_MND_ADDR'
|
|
11
11
|
DAUTH_PROXYAPI_ADDR_KEY = 'EE_DAUTH_PROXYAPI_ADDR'
|
|
12
12
|
DAUTH_POAI_MANAGER_ADDR_KEY = 'EE_DAUTH_POAI_MANAGER_ADDR'
|
|
13
|
-
|
|
14
|
-
DAUTH_CONTROLLER_ADDR_KEY = 'EE_DAUTH_CONTROLLER_ADDR'
|
|
15
|
-
DAUTH_GET_ORACLES_ABI = 'EE_DAUTH_GET_ORACLES_ABI'
|
|
13
|
+
DAUTH_CONTROLLER_ADDR_KEY = 'EE_DAUTH_CONTROLLER_ADDR'
|
|
16
14
|
|
|
17
15
|
EE_GENESIS_EPOCH_DATE_KEY = 'EE_GENESIS_EPOCH_DATE'
|
|
18
16
|
EE_EPOCH_INTERVALS_KEY = 'EE_EPOCH_INTERVALS'
|
|
@@ -41,165 +39,142 @@ class EvmNetConstants:
|
|
|
41
39
|
# endclass EvmNetConstants
|
|
42
40
|
|
|
43
41
|
|
|
44
|
-
|
|
45
|
-
"inputs": [
|
|
46
|
-
{
|
|
47
|
-
"internalType": "address",
|
|
48
|
-
"name": "nodeAddress",
|
|
49
|
-
"type": "address"
|
|
50
|
-
}
|
|
51
|
-
],
|
|
52
|
-
"name": "isNodeActive",
|
|
53
|
-
"outputs": [
|
|
54
|
-
{
|
|
55
|
-
"internalType": "bool",
|
|
56
|
-
"name": "",
|
|
57
|
-
"type": "bool"
|
|
58
|
-
}
|
|
59
|
-
],
|
|
60
|
-
"stateMutability": "view",
|
|
61
|
-
"type": "function"
|
|
62
|
-
}]
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
_DAUTH_ABI_GET_ORACLES = [{
|
|
66
|
-
"inputs": [],
|
|
67
|
-
"name": "getOracles",
|
|
68
|
-
"outputs": [
|
|
69
|
-
{
|
|
70
|
-
"internalType": "address[]",
|
|
71
|
-
"name": "",
|
|
72
|
-
"type": "address[]"
|
|
73
|
-
}
|
|
74
|
-
],
|
|
75
|
-
"stateMutability": "view",
|
|
76
|
-
"type": "function"
|
|
77
|
-
}]
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
_DAUTH_ABI_GET_SIGNERS_deprecated = [{
|
|
81
|
-
"inputs": [],
|
|
82
|
-
"name": "getSigners",
|
|
83
|
-
"outputs": [
|
|
84
|
-
{
|
|
85
|
-
"internalType": "address[]",
|
|
86
|
-
"name": "",
|
|
87
|
-
"type": "address[]"
|
|
88
|
-
}
|
|
89
|
-
],
|
|
90
|
-
"stateMutability": "view",
|
|
91
|
-
"type": "function"
|
|
92
|
-
}]
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
_GET_NODE_INFO_ABI = [
|
|
42
|
+
_CONTROLLER_ABI = [
|
|
96
43
|
{
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
{
|
|
129
|
-
"internalType": "uint256",
|
|
130
|
-
"name": "totalAssignedAmount",
|
|
131
|
-
"type": "uint256"
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
"internalType": "uint256",
|
|
135
|
-
"name": "totalClaimedAmount",
|
|
136
|
-
"type": "uint256"
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
"internalType": "uint256",
|
|
140
|
-
"name": "lastClaimEpoch",
|
|
141
|
-
"type": "uint256"
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
"internalType": "uint256",
|
|
145
|
-
"name": "assignTimestamp",
|
|
146
|
-
"type": "uint256"
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
"internalType": "address",
|
|
150
|
-
"name": "lastClaimOracle",
|
|
151
|
-
"type": "address"
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
"internalType": "bool",
|
|
155
|
-
"name": "isBanned",
|
|
156
|
-
"type": "bool"
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
"internalType": "uint256",
|
|
160
|
-
"name": "usdcPoaiRewards",
|
|
161
|
-
"type": "uint256"
|
|
162
|
-
},
|
|
163
|
-
{
|
|
164
|
-
"internalType": "uint256",
|
|
165
|
-
"name": "r1PoaiRewards",
|
|
166
|
-
"type": "uint256"
|
|
167
|
-
}
|
|
168
|
-
],
|
|
169
|
-
"internalType": "struct LicenseDetails",
|
|
170
|
-
"name": "",
|
|
171
|
-
"type": "tuple"
|
|
172
|
-
}
|
|
173
|
-
],
|
|
174
|
-
"stateMutability": "view",
|
|
175
|
-
"type": "function"
|
|
176
|
-
}
|
|
177
|
-
]
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
_GET_WALLET_NODES = [
|
|
181
|
-
{
|
|
182
|
-
"inputs": [
|
|
183
|
-
{
|
|
184
|
-
"internalType": "address",
|
|
185
|
-
"name": "wallet",
|
|
186
|
-
"type": "address"
|
|
187
|
-
}
|
|
188
|
-
],
|
|
189
|
-
"name": "getWalletNodes",
|
|
190
|
-
"outputs": [
|
|
191
|
-
{
|
|
192
|
-
"internalType": "address[]",
|
|
193
|
-
"name": "nodes",
|
|
194
|
-
"type": "address[]"
|
|
195
|
-
}
|
|
196
|
-
],
|
|
197
|
-
"stateMutability": "view",
|
|
198
|
-
"type": "function"
|
|
199
|
-
},
|
|
44
|
+
"inputs": [
|
|
45
|
+
{
|
|
46
|
+
"internalType": "address",
|
|
47
|
+
"name": "nodeAddress",
|
|
48
|
+
"type": "address"
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
"name": "isNodeActive",
|
|
52
|
+
"outputs": [
|
|
53
|
+
{
|
|
54
|
+
"internalType": "bool",
|
|
55
|
+
"name": "",
|
|
56
|
+
"type": "bool"
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
"stateMutability": "view",
|
|
60
|
+
"type": "function"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"inputs": [],
|
|
64
|
+
"name": "getOracles",
|
|
65
|
+
"outputs": [
|
|
66
|
+
{
|
|
67
|
+
"internalType": "address[]",
|
|
68
|
+
"name": "",
|
|
69
|
+
"type": "address[]"
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
"stateMutability": "view",
|
|
73
|
+
"type": "function"
|
|
74
|
+
},
|
|
200
75
|
]
|
|
201
76
|
|
|
202
|
-
|
|
77
|
+
_PROXY_ABI = [
|
|
78
|
+
{
|
|
79
|
+
"inputs": [
|
|
80
|
+
{
|
|
81
|
+
"internalType": "address",
|
|
82
|
+
"name": "node",
|
|
83
|
+
"type": "address"
|
|
84
|
+
}
|
|
85
|
+
],
|
|
86
|
+
"name": "getNodeLicenseDetails",
|
|
87
|
+
"outputs": [
|
|
88
|
+
{
|
|
89
|
+
"components": [
|
|
90
|
+
{
|
|
91
|
+
"internalType": "enum LicenseType",
|
|
92
|
+
"name": "licenseType",
|
|
93
|
+
"type": "uint8"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"internalType": "uint256",
|
|
97
|
+
"name": "licenseId",
|
|
98
|
+
"type": "uint256"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"internalType": "address",
|
|
102
|
+
"name": "owner",
|
|
103
|
+
"type": "address"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"internalType": "address",
|
|
107
|
+
"name": "nodeAddress",
|
|
108
|
+
"type": "address"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"internalType": "uint256",
|
|
112
|
+
"name": "totalAssignedAmount",
|
|
113
|
+
"type": "uint256"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"internalType": "uint256",
|
|
117
|
+
"name": "totalClaimedAmount",
|
|
118
|
+
"type": "uint256"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"internalType": "uint256",
|
|
122
|
+
"name": "lastClaimEpoch",
|
|
123
|
+
"type": "uint256"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"internalType": "uint256",
|
|
127
|
+
"name": "assignTimestamp",
|
|
128
|
+
"type": "uint256"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"internalType": "address",
|
|
132
|
+
"name": "lastClaimOracle",
|
|
133
|
+
"type": "address"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"internalType": "bool",
|
|
137
|
+
"name": "isBanned",
|
|
138
|
+
"type": "bool"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"internalType": "uint256",
|
|
142
|
+
"name": "usdcPoaiRewards",
|
|
143
|
+
"type": "uint256"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"internalType": "uint256",
|
|
147
|
+
"name": "r1PoaiRewards",
|
|
148
|
+
"type": "uint256"
|
|
149
|
+
}
|
|
150
|
+
],
|
|
151
|
+
"internalType": "struct LicenseDetails",
|
|
152
|
+
"name": "",
|
|
153
|
+
"type": "tuple"
|
|
154
|
+
}
|
|
155
|
+
],
|
|
156
|
+
"stateMutability": "view",
|
|
157
|
+
"type": "function"
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"inputs": [
|
|
161
|
+
{
|
|
162
|
+
"internalType": "address",
|
|
163
|
+
"name": "wallet",
|
|
164
|
+
"type": "address"
|
|
165
|
+
}
|
|
166
|
+
],
|
|
167
|
+
"name": "getWalletNodes",
|
|
168
|
+
"outputs": [
|
|
169
|
+
{
|
|
170
|
+
"internalType": "address[]",
|
|
171
|
+
"name": "nodes",
|
|
172
|
+
"type": "address[]"
|
|
173
|
+
}
|
|
174
|
+
],
|
|
175
|
+
"stateMutability": "view",
|
|
176
|
+
"type": "function"
|
|
177
|
+
},
|
|
203
178
|
{
|
|
204
179
|
"inputs": [
|
|
205
180
|
{
|
|
@@ -235,6 +210,47 @@ _GET_ADDRESSES_BALANCES = [
|
|
|
235
210
|
],
|
|
236
211
|
"stateMutability": "view",
|
|
237
212
|
"type": "function"
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"inputs": [
|
|
216
|
+
{
|
|
217
|
+
"internalType": "address",
|
|
218
|
+
"name": "user",
|
|
219
|
+
"type": "address"
|
|
220
|
+
}
|
|
221
|
+
],
|
|
222
|
+
"name": "getUserEscrowDetails",
|
|
223
|
+
"outputs": [
|
|
224
|
+
{
|
|
225
|
+
"components": [
|
|
226
|
+
{
|
|
227
|
+
"internalType": "bool",
|
|
228
|
+
"name": "isActive",
|
|
229
|
+
"type": "bool"
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"internalType": "address",
|
|
233
|
+
"name": "escrowAddress",
|
|
234
|
+
"type": "address"
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
"internalType": "address",
|
|
238
|
+
"name": "escrowOwner",
|
|
239
|
+
"type": "address"
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
"internalType": "uint256",
|
|
243
|
+
"name": "permissions",
|
|
244
|
+
"type": "uint256"
|
|
245
|
+
}
|
|
246
|
+
],
|
|
247
|
+
"internalType": "struct UserEscrowDetails",
|
|
248
|
+
"name": "",
|
|
249
|
+
"type": "tuple"
|
|
250
|
+
}
|
|
251
|
+
],
|
|
252
|
+
"stateMutability": "view",
|
|
253
|
+
"type": "function"
|
|
238
254
|
}
|
|
239
255
|
]
|
|
240
256
|
|
|
@@ -542,7 +558,6 @@ EVM_NET_DATA = {
|
|
|
542
558
|
EvmNetData.EE_DAPP_APP_URL_KEY : "https://app.ratio1.ai",
|
|
543
559
|
EvmNetData.EE_EXPLORER_APP_URL_KEY : "https://explorer.ratio1.ai",
|
|
544
560
|
EvmNetData.EE_DEEPLOY_APP_URL_KEY : "https://deeploy.ratio1.ai",
|
|
545
|
-
EvmNetData.DAUTH_GET_ORACLES_ABI : _DAUTH_ABI_GET_ORACLES,
|
|
546
561
|
},
|
|
547
562
|
|
|
548
563
|
EvmNetData.TESTNET: {
|
|
@@ -564,7 +579,6 @@ EVM_NET_DATA = {
|
|
|
564
579
|
EvmNetData.EE_DAPP_APP_URL_KEY : "https://testnet-app.ratio1.ai",
|
|
565
580
|
EvmNetData.EE_EXPLORER_APP_URL_KEY : "https://testnet-explorer.ratio1.ai",
|
|
566
581
|
EvmNetData.EE_DEEPLOY_APP_URL_KEY : "https://testnet-deeploy.ratio1.ai",
|
|
567
|
-
EvmNetData.DAUTH_GET_ORACLES_ABI : _DAUTH_ABI_GET_ORACLES,
|
|
568
582
|
},
|
|
569
583
|
|
|
570
584
|
|
|
@@ -587,7 +601,6 @@ EVM_NET_DATA = {
|
|
|
587
601
|
EvmNetData.EE_DAPP_APP_URL_KEY : "https://devnet-app.ratio1.ai",
|
|
588
602
|
EvmNetData.EE_EXPLORER_APP_URL_KEY : "https://devnet-explorer.ratio1.ai",
|
|
589
603
|
EvmNetData.EE_DEEPLOY_APP_URL_KEY : "https://devnet-deeploy.ratio1.ai",
|
|
590
|
-
EvmNetData.DAUTH_GET_ORACLES_ABI : _DAUTH_ABI_GET_ORACLES,
|
|
591
604
|
},
|
|
592
605
|
}
|
|
593
606
|
|
|
@@ -633,10 +646,7 @@ EVM_NET_CONSTANTS = {
|
|
|
633
646
|
}
|
|
634
647
|
|
|
635
648
|
class EVM_ABI_DATA:
|
|
636
|
-
GET_NODE_INFO = _GET_NODE_INFO_ABI
|
|
637
|
-
GET_WALLET_NODES = _GET_WALLET_NODES
|
|
638
|
-
GET_ADDRESSES_BALANCES = _GET_ADDRESSES_BALANCES
|
|
639
|
-
IS_NODE_ACTIVE = _DAUTH_ABI_IS_NODE_ACTIVE
|
|
640
649
|
ERC20_ABI = _ERC20_ABI
|
|
641
650
|
POAI_MANAGER_ABI = _POAI_MANAGER_ABI
|
|
642
|
-
|
|
651
|
+
PROXY_ABI = _PROXY_ABI
|
|
652
|
+
CONTROLLER_ABI = _CONTROLLER_ABI
|
ratio1/ipfs/r1fs.py
CHANGED
|
@@ -919,6 +919,9 @@ class R1FSEngine:
|
|
|
919
919
|
>>> print(cid)
|
|
920
920
|
QmFolder123ABC
|
|
921
921
|
"""
|
|
922
|
+
add_time, remove_time, pin_time = 0.0, 0.0, 0.0
|
|
923
|
+
start_time = time.time()
|
|
924
|
+
|
|
922
925
|
if secret in ["", None]:
|
|
923
926
|
secret = self.__DEFAULT_SECRET
|
|
924
927
|
|
|
@@ -954,7 +957,6 @@ class R1FSEngine:
|
|
|
954
957
|
tmp_cipher_path = os.path.join(tempfile.gettempdir(), uuid.uuid4().hex + ".bin")
|
|
955
958
|
|
|
956
959
|
folder_cid = None
|
|
957
|
-
start_time = time.time()
|
|
958
960
|
try:
|
|
959
961
|
encryptor = Cipher(algorithms.AES(key), modes.GCM(nonce_bytes)).encryptor()
|
|
960
962
|
|
|
@@ -996,11 +998,16 @@ class R1FSEngine:
|
|
|
996
998
|
else:
|
|
997
999
|
self.P(msg, color='r')
|
|
998
1000
|
#end try
|
|
999
|
-
|
|
1001
|
+
add_time = time.time() - start_time
|
|
1002
|
+
|
|
1003
|
+
remove_start_time = time.time()
|
|
1000
1004
|
# Cleanup temp file
|
|
1001
1005
|
os.remove(tmp_cipher_path)
|
|
1006
|
+
remove_time = time.time() - remove_start_time
|
|
1002
1007
|
|
|
1003
1008
|
if folder_cid is not None:
|
|
1009
|
+
# Now we notify the relay (if any) about the new CID
|
|
1010
|
+
pin_start_time = time.time()
|
|
1004
1011
|
if self.__ipfs_relay_api is not None:
|
|
1005
1012
|
# Notifying the Relay about a new CID.
|
|
1006
1013
|
try:
|
|
@@ -1028,10 +1035,14 @@ class R1FSEngine:
|
|
|
1028
1035
|
self.__uploaded_files[folder_cid] = file_path
|
|
1029
1036
|
# now we pin the folder
|
|
1030
1037
|
res = self.__pin_add(folder_cid)
|
|
1031
|
-
|
|
1032
|
-
self.P(f"Added file {file_path} as <{folder_cid}> in {elapsed_time:.1f}s")
|
|
1038
|
+
pin_time = time.time() - pin_start_time
|
|
1033
1039
|
#end if show_logs
|
|
1034
1040
|
#end if folder_cid is not None
|
|
1041
|
+
total_time = time.time() - start_time
|
|
1042
|
+
if show_logs:
|
|
1043
|
+
self.P("Added file {} as <{}> in {.2f}s: add_time={.2f}s, remove_time={.2f}s, pin_time={.2f}s".format(
|
|
1044
|
+
file_path, folder_cid, total_time, add_time, remove_time, pin_time
|
|
1045
|
+
))
|
|
1035
1046
|
return folder_cid
|
|
1036
1047
|
|
|
1037
1048
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ratio1
|
|
3
|
-
Version: 3.4.
|
|
3
|
+
Version: 3.4.117
|
|
4
4
|
Summary: `ratio1` or Ration1 SDK is the Python SDK required for client app development for the Ratio1 ecosystem
|
|
5
5
|
Project-URL: Homepage, https://github.com/Ratio1/ratio1_sdk
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/Ratio1/ratio1_sdk/issues
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
ratio1/__init__.py,sha256=YimqgDbjLuywsf8zCWE0EaUXH4MBUrqLxt0TDV558hQ,632
|
|
2
|
-
ratio1/_ver.py,sha256=
|
|
2
|
+
ratio1/_ver.py,sha256=d5GaaIQCUfy5PSr-k2MpkZjU4dkFGmzUk5O_ZF9UnAE,332
|
|
3
3
|
ratio1/base_decentra_object.py,sha256=iXvAAf6wPnGWzeeiRfwLojVoan-m1e_VsyPzjUQuENo,4492
|
|
4
4
|
ratio1/plugins_manager_mixin.py,sha256=X1JdGLDz0gN1rPnTN_5mJXR8JmqoBFQISJXmPR9yvCo,11106
|
|
5
5
|
ratio1/base/__init__.py,sha256=hACh83_cIv7-PwYMM3bQm2IBmNqiHw-3PAfDfAEKz9A,259
|
|
@@ -17,7 +17,7 @@ ratio1/bc/__init__.py,sha256=BI5pcqHdhwnMdbWTYDLW1cVP_844VtLra-lz7xprgsk,171
|
|
|
17
17
|
ratio1/bc/base.py,sha256=g7tARNgi_0N1p9HpvqRDWDVYxuqU7W6S0q3ARC6oxKk,45870
|
|
18
18
|
ratio1/bc/chain.py,sha256=HCTQGnmuKqTvUo95OKdg8rL2jhKfSMwrich2e_7Nyms,2336
|
|
19
19
|
ratio1/bc/ec.py,sha256=FwlkWmJvQ9aHuf_BZX1CWSUAxw6OZ9jBparLIWcs_e4,18933
|
|
20
|
-
ratio1/bc/evm.py,sha256=
|
|
20
|
+
ratio1/bc/evm.py,sha256=iMLdm_rtQFqmt44zTE_UA0OKSTmuH7sCSI2iKvFI1_k,52013
|
|
21
21
|
ratio1/certs/141.136.35.100.crt,sha256=DQ0GEz-CeTU_n2o3B6SeNqANWVVWu8m5a4OQ8FnYzvc,1866
|
|
22
22
|
ratio1/certs/195.35.29.4.crt,sha256=5aODzjC_mffZ8pl26LkE-nUHj6Ih8UWajmvd2paVwVY,1159
|
|
23
23
|
ratio1/certs/31.97.72.187.crt,sha256=2aY-YhlupUFCYldPsoOlhU_OYdFDTOmBSXa7gQOLB60,1858
|
|
@@ -48,7 +48,7 @@ ratio1/const/apps.py,sha256=MD4SRTNId663D3SX78_GJa40BI_H1mdcNbL2gy_Hio0,827
|
|
|
48
48
|
ratio1/const/base.py,sha256=QIeRH6X-u8DbezQCGipI3isL1LGComBQC5hLedO1jrQ,6042
|
|
49
49
|
ratio1/const/comms.py,sha256=qEYX4ciYg8SYWSDZZTUYxzpR1--2a7UusrWzAq0hxo8,2259
|
|
50
50
|
ratio1/const/environment.py,sha256=632L5GrcNqF3-JhvrC6kXzXwLMcihRgMlOkLurnOwGY,1031
|
|
51
|
-
ratio1/const/evm_net.py,sha256=
|
|
51
|
+
ratio1/const/evm_net.py,sha256=5Hs5JVIO5WZqMuxzSyKjAAXDlMUMkxZ1CqVio_ueuZQ,20049
|
|
52
52
|
ratio1/const/formatter.py,sha256=AW3bWlqf39uaqV4BBUuW95qKYfF2OkkU4f9hy3kSVhM,200
|
|
53
53
|
ratio1/const/heartbeat.py,sha256=eVWuGIP5sAIYzQjOJUehmKlYHetoquSw-sTJwSKrHk8,3223
|
|
54
54
|
ratio1/const/misc.py,sha256=VDCwwpf5bl9ltx9rzT2WPVP8B3mZFRufU1tSS5MO240,413
|
|
@@ -74,7 +74,7 @@ ratio1/io_formatter/default/aixp1.py,sha256=MX0TeUR4APA-qN3vUC6uzcz8Pssz5lgrQWo7
|
|
|
74
74
|
ratio1/io_formatter/default/default.py,sha256=gEy78cP2D5s0y8vQh4aHuxqz7D10gGfuiKF311QhrpE,494
|
|
75
75
|
ratio1/ipfs/__init__.py,sha256=vXEDLUNUO6lOTMGa8iQ9Zf7ajIQq9GZuvYraAHt3meE,38
|
|
76
76
|
ratio1/ipfs/ifps_keygen,sha256=PcoYuo4c89_C9FWrKq9K_28ruhKqnxNn1s3nLHiF1tc,879
|
|
77
|
-
ratio1/ipfs/r1fs.py,sha256=
|
|
77
|
+
ratio1/ipfs/r1fs.py,sha256=eNHDEG15CNc32PD-yoSTCwLhuOuyolZxqiYVrz_UkSA,92048
|
|
78
78
|
ratio1/ipfs/ipfs_setup/ipfs.service,sha256=isTJQsktPy4i1yaDA9AC1OKdlTYvsCCRRAVX-EmGqAs,248
|
|
79
79
|
ratio1/ipfs/ipfs_setup/launch_service.sh,sha256=GWhZyNqtohLxJg8Q_c8YnNZduu1ddXDU-IFRRMaEyiY,141
|
|
80
80
|
ratio1/ipfs/ipfs_setup/restart.sh,sha256=9xHMgkUoAMI25jeaoDVFbCa_LjojYm3ubljW58RatKE,22
|
|
@@ -109,8 +109,8 @@ ratio1/utils/comm_utils.py,sha256=4cS9llRr_pK_3rNgDcRMCQwYPO0kcNU7AdWy_LtMyCY,10
|
|
|
109
109
|
ratio1/utils/config.py,sha256=Elfkl7W4aDMvB5WZLiYlPXrecBncgTxb4hcKhQedMzI,10111
|
|
110
110
|
ratio1/utils/dotenv.py,sha256=_AgSo35n7EnQv5yDyu7C7i0kHragLJoCGydHjvOkrYY,2008
|
|
111
111
|
ratio1/utils/oracle_sync/oracle_tester.py,sha256=aJOPcZhtbw1XPqsFG4qYpfv2Taj5-qRXbwJzrPyeXDE,27465
|
|
112
|
-
ratio1-3.4.
|
|
113
|
-
ratio1-3.4.
|
|
114
|
-
ratio1-3.4.
|
|
115
|
-
ratio1-3.4.
|
|
116
|
-
ratio1-3.4.
|
|
112
|
+
ratio1-3.4.117.dist-info/METADATA,sha256=3I7LyVPKgPy0h5kpherF6b4QKxtjCLY5gMOjJ8xAygI,12256
|
|
113
|
+
ratio1-3.4.117.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
114
|
+
ratio1-3.4.117.dist-info/entry_points.txt,sha256=DR_olREzU1egwmgek3s4GfQslBi-KR7lXsd4ap0TFxE,46
|
|
115
|
+
ratio1-3.4.117.dist-info/licenses/LICENSE,sha256=cvOsJVslde4oIaTCadabXnPqZmzcBO2f2zwXZRmJEbE,11311
|
|
116
|
+
ratio1-3.4.117.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|