Junaidb commited on
Commit
564f50c
·
verified ·
1 Parent(s): ea15739

Update components/middleware.py

Browse files
Files changed (1) hide show
  1. components/middleware.py +42 -1
components/middleware.py CHANGED
@@ -47,7 +47,7 @@ def SecretNonceGenerator():
47
 
48
 
49
 
50
-
51
 
52
  def TokenCheck(walletPublicKey):
53
 
@@ -101,7 +101,48 @@ def TokenCheck(walletPublicKey):
101
  print(ui_amount)
102
  return False
103
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
 
 
105
 
106
 
107
 
 
47
 
48
 
49
 
50
+ '''
51
 
52
  def TokenCheck(walletPublicKey):
53
 
 
101
  print(ui_amount)
102
  return False
103
 
104
+ '''
105
+
106
+
107
+
108
+
109
+ def TokenCheck(walletPublicKey):
110
+
111
+ url = "https://mainnet.helius-rpc.com/?api-key=4e833ada-d32c-48c5-b020-c11b2253f25b"
112
+ payload = {
113
+ "jsonrpc": "2.0",
114
+ "id": "1",
115
+ "method": "getTokenAccountsByOwner",
116
+ "params": [
117
+ walletPublicKey,
118
+ {"mint":"3d4XyPWkUJzruF5c2qc1QfpLgsaNaDLMtTya1bWBpump"},
119
+ {"encoding": "jsonParsed"}
120
+ ]
121
+ }
122
+
123
+ headers = {"Content-Type": "application/json"}
124
+
125
+ try:
126
+ response = requests.post(url, json=payload, headers=headers)
127
+ response.raise_for_status()
128
+ data = response.json()
129
+ except:
130
+ return False # ALWAYS return a boolean
131
+
132
+ token_accounts = data.get("result", {}).get("value")
133
+
134
+ if not token_accounts:
135
+ return False
136
+
137
+ try:
138
+ account_info = token_accounts[0]["account"]["data"]["parsed"]["info"]
139
+ ui_amount = float(account_info["tokenAmount"].get("uiAmount"))
140
+ except:
141
+ return False
142
+
143
+ print(ui_amount)
144
 
145
+ return ui_amount >= 100000.0
146
 
147
 
148