-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmongoAPI.py
More file actions
195 lines (162 loc) · 6.34 KB
/
Copy pathmongoAPI.py
File metadata and controls
195 lines (162 loc) · 6.34 KB
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
90
91
92
93
94
95
96
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
from flask import Flask, request, redirect
from json import loads
from pymongo import MongoClient
from os import getenv,system
from dotenv import load_dotenv
load_dotenv()
connection = f"mongodb://mongoadmin:{getenv('mongoPass')}@localhost:27017"
client = MongoClient(connection)
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def index():
database = client["xade"]
users = database["users"]
wallets = database["wallets"]
phones = database["phones"]
if request.method == 'GET':
return redirect('https://app.xade.finance', code=301)
elif request.method == 'POST':
data = request.get_data(as_text=True)
if data.startswith("address:"):
z = data.split("||")
adr = z[0].replace("address:","")
i = z[1].replace("id:","")
scw = z[2];
addrChk = wallets.find_one({"Wallet Address":adr})
if addrChk == None:
x = wallets.insert_one({"Wallet Address":adr,"ID":i, "scw":scw})
elif data.startswith('{"phone":'):
p = loads(data)
phn = p["phone"]
i = p["id"]
phnChk = phones.find_one({"Phone Number":phn})
if phnChk == None:
x = phones.insert_one({"Phone Number":phn,"ID":i})
else:
j = data.replace("'", "\"")
d = loads(j)
email = d["email"]
name = d["name"]
pfp = d["profileImage"]
verify = d["verifier"]
i = d["verifierId"]
login = d["typeOfLogin"]
i = d["id"]
if login == "jwt":
login = "email"
emailAndLoginChk = users.find_one({"Email":email,"Login Type":login})
if emailAndLoginChk == None:
info = {
"Email":email,
"Username":name,
"Login Type":login,
"ID":i
}
x = users.insert_one(info)
else:
info = "duplicate lol"
return data
@app.route('/polygon', methods=['GET', 'POST'])
def polygon():
database = client["mobile"]
users = database["users"]
if request.method == 'GET':
return redirect('https://app.xade.finance', code=301)
elif request.method == 'POST':
data = request.get_data(as_text=True)
if data.startswith("test"):
return "im up"
else:
j = data.replace("'", "\"")
d = loads(j)
email = d["email"]
phone = d["phone"]
name = d["name"]
login = d["typeOfLogin"]
eoa = d["eoa"]
scw = d["scw"]
i = d["id"]
sak = d["spritzApiKey"]
phoneAndLoginChk = None
emailAndLoginChk = None
if phone == "NULL":
emailAndLoginChk = users.find_one({"Email":email,"Login Type":login})
phoneAndLoginChk = None
elif email == "NULL":
phoneAndLoginChk = users.find_one({"Phone":phone,"Login Type":login})
emailAndLoginChk = None
if emailAndLoginChk == None and phoneAndLoginChk == None:
info = {
"Email":email,
"Phone":phone,
"Username":name,
"Login Type":login,
"Wallet Address":eoa,
"SCW Address":scw,
"ID":i,
"sak":sak
}
v2Db = client["remmitex"]
testnet = v2Db["testnet"]
mainnet = v2Db["mainnet"]
x = users.insert_one(info)
address = scw
checkTestnet = testnet.find_one({'Email': email})
if checkTestnet:
amount = int(float(checkTestnet.get("Amount")) * pow(10,18))
print(address)
print(amount)
system(f"node /home/xade/xade-api/testnetV2.js {address} {amount}")
deleteDoc = testnet.delete_one({'Email': email})
checkMainnet = mainnet.find_one({'Email': email})
if checkMainnet:
amount = int(float(checkMainnet.get("Amount")) * pow(10,6))
print(address)
print(amount)
system(f"node /home/xade/xade-api/mainnetV2.js {address} {amount}")
deleteDoc = mainnet.delete_one({'Email': email})
checkTestnet = testnet.find_one({'Phone': phone})
if checkTestnet:
amount = int(float(checkTestnet.get("Amount")) * pow(10,18))
print(address)
print(amount)
system(f"node /home/xade/xade-api/testnetV2.js {address} {amount}")
deleteDoc = testnet.delete_one({'Phone': phone})
checkMainnet = mainnet.find_one({'Phone': phone})
if checkMainnet:
amount = int(float(checkMainnet.get("Amount")) * pow(10,6))
print(address)
print(amount)
system(f"node /home/xade/xade-api/mainnetV2.js {address} {amount}")
deleteDoc = mainnet.delete_one({'Phone': phone})
print(email)
print(phone)
else:
info = "duplicate lol"
return data
def blueprintig():
database = client["extra-info"]
extras = database["extras"]
return "hi", 200
@app.route('spritz', methods=['GET'])
def spritz():
database = client["xade"]
users = database["users"]
wallets = database["wallets"]
phones = database["phones"]
address = request.args.get('address')
database = client["xade"]
users = database["users"]
users.findOne({'Wallet Address':address, (err, document) => {
if (err) {
console.error('Error finding document:', err);
return;
}
// Print the matching document
console.log('Matching document:', document);
// Close the MongoDB connection
# client.close();
});
return address
if __name__ == '__main__':
app.run(host='127.0.0.1', port=8000)