Junaidb commited on
Commit
48de82b
·
verified ·
1 Parent(s): 9b8879a

Update components/middleware.py

Browse files
Files changed (1) hide show
  1. components/middleware.py +3 -52
components/middleware.py CHANGED
@@ -47,8 +47,6 @@ def SecretNonceGenerator():
47
 
48
 
49
 
50
- '''
51
-
52
  def TokenCheck(walletPublicKey):
53
 
54
  url = f"https://mainnet.helius-rpc.com/?api-key=4e833ada-d32c-48c5-b020-c11b2253f25b"
@@ -101,55 +99,9 @@ def TokenCheck(walletPublicKey):
101
  print(ui_amount)
102
  return False
103
 
104
- '''
105
-
106
-
107
-
108
-
109
- def TokenCheck(walletPublicKey):
110
-
111
- try:
112
-
113
- url = "https://mainnet.helius-rpc.com/?api-key=4e833ada-d32c-48c5-b020-c11b2253f25b"
114
- payload = {
115
- "jsonrpc": "2.0",
116
- "id": "1",
117
- "method": "getTokenAccountsByOwner",
118
- "params": [
119
- walletPublicKey,
120
- {"mint":"3d4XyPWkUJzruF5c2qc1QfpLgsaNaDLMtTya1bWBpump"},
121
- {"encoding": "jsonParsed"}
122
- ]
123
- }
124
-
125
- headers = {"Content-Type": "application/json"}
126
-
127
- try:
128
- response = requests.post(url, json=payload, headers=headers)
129
- response.raise_for_status()
130
- data = response.json()
131
- print(data)
132
- except:
133
- return False # ALWAYS return a boolean
134
-
135
- token_accounts = data.get("result", {}).get("value")
136
-
137
- if not token_accounts:
138
- return False
139
-
140
- try:
141
- account_info = token_accounts[0]["account"]["data"]["parsed"]["info"]
142
- ui_amount = float(account_info["tokenAmount"].get("uiAmount"))
143
- except:
144
- return False
145
 
146
- print(ui_amount)
147
 
148
- return ui_amount >= 100000.0
149
 
150
- except Exception as e:
151
- print(e)
152
- return True
153
 
154
 
155
 
@@ -225,11 +177,10 @@ class x401Kit(BaseHTTPMiddleware):
225
  challange=f"CHALLENGE::{X_401_Nonce}::{request.url.path}::{self.secret_domain}"
226
 
227
  signverify=SignatureVerification(X_401_Addr,X_401_Nonce,X_401_Sign,challange)
228
- #tokenverify=TokenCheck(X_401_Addr)
229
- #print(tokenverify)
230
 
231
- if signverify == True:
232
- #and tokenverify == True:
233
 
234
  response = await call_next(request)
235
 
 
47
 
48
 
49
 
 
 
50
  def TokenCheck(walletPublicKey):
51
 
52
  url = f"https://mainnet.helius-rpc.com/?api-key=4e833ada-d32c-48c5-b020-c11b2253f25b"
 
99
  print(ui_amount)
100
  return False
101
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
 
 
103
 
 
104
 
 
 
 
105
 
106
 
107
 
 
177
  challange=f"CHALLENGE::{X_401_Nonce}::{request.url.path}::{self.secret_domain}"
178
 
179
  signverify=SignatureVerification(X_401_Addr,X_401_Nonce,X_401_Sign,challange)
180
+ tokenverify=TokenCheck(X_401_Addr)
181
+ print(tokenverify)
182
 
183
+ if signverify == True and tokenverify == True:
 
184
 
185
  response = await call_next(request)
186