Junaidb commited on
Commit
555b5c6
·
verified ·
1 Parent(s): 2f33028

Update engine.py

Browse files
Files changed (1) hide show
  1. engine.py +20 -19
engine.py CHANGED
@@ -1,34 +1,33 @@
1
- from components.functions import NetworkResolver , HeliusAPI ,InfuraRPC , EthereumSigner ,SolanaSigner,EthereumPayment,SolanaPayment
2
- #from components.ucg_g1 import UGC_GRAPH_1
3
 
4
 
5
 
 
 
 
 
6
 
7
  TOOLS = {
8
 
9
- "NetworkResolver": lambda state: NetworkResolver(state["address"]),
10
- "InfuraRPC": lambda state: InfuraRPC(state["address"]),
11
- "HeliusAPI": lambda state: HeliusAPI(state["address"]),
12
- "PayloadGenerator": lambda state: {
13
- "payload": f"Sign for {state['address']} with balance {state.get('eth_balance', state.get('sol_balance',0))}"
14
- },
15
- "EthereumSigner": lambda state: EthereumSigner(state["address"], state.get("payload","")),
16
- "SolanaSigner": lambda state: SolanaSigner(state["address"], state.get("payload","")),
17
- "EthereumPayment": lambda state:EthereumPayment(state["address"],state.get("to"),state.get("amount")),
18
- "SolanaPayment": lambda state:SolanaPayment(state["address"],state.get("to"),state.get("amount"))
19
-
20
  }
21
 
22
 
23
-
24
  class UCGEngine:
25
  def __init__(self, ugc_graph, tools):
26
  self.ops = {op["operation"]: op for op in ugc_graph}
27
  self.tools = tools
28
  self.executed = set()
29
 
30
- def run(self, operation, address):
31
- self.state = address
32
  #initial facts
33
  self.executed = set()
34
  self._execute(operation)
@@ -52,9 +51,11 @@ class UCGEngine:
52
  return
53
 
54
  if op_name in self.tools:
 
 
 
55
  new_facts =self.tools[op_name](self.state)
 
56
  print(new_facts)
57
  self.state.update(new_facts)
58
- self.executed.add(op_name)
59
-
60
-
 
1
+ from components.functions import NetworkResolver , HeliusAPI ,InfuraRPC , EthereumSigner ,SolanaSigner,EthereumPayment
2
+ from components.ucg_g1 import UGC_GRAPH_1
3
 
4
 
5
 
6
+ def PayloadGen(address):
7
+ payload=f"PAYLOAD:{address}"
8
+ return payload
9
+
10
 
11
  TOOLS = {
12
 
13
+ "NetworkResolver": lambda state: NetworkResolver(state),
14
+ "InfuraRPC": lambda state: InfuraRPC(state),
15
+ "HeliusAPI": lambda state: HeliusAPI(state),
16
+ "PayloadGenerator": lambda state: PayloadGen(state),
17
+ "EthereumSigner": lambda state: EthereumSigner(state),
18
+ "SolanaSigner": lambda state: SolanaSigner(state),
19
+ "EthereumPayment": lambda state: EthereumPayment(state)
 
 
 
 
20
  }
21
 
22
 
 
23
  class UCGEngine:
24
  def __init__(self, ugc_graph, tools):
25
  self.ops = {op["operation"]: op for op in ugc_graph}
26
  self.tools = tools
27
  self.executed = set()
28
 
29
+ def run(self, operation,state):
30
+ self.state = state
31
  #initial facts
32
  self.executed = set()
33
  self._execute(operation)
 
51
  return
52
 
53
  if op_name in self.tools:
54
+
55
+ new_facts=self.tools[op_name](self.state)
56
+
57
  new_facts =self.tools[op_name](self.state)
58
+
59
  print(new_facts)
60
  self.state.update(new_facts)
61
+ self.executed.add(op_name)