Skip to content

Commit 9af4101

Browse files
author
Yash Agrawal
committed
debug: add console.logs
1 parent c1f3c46 commit 9af4101

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/pages/api/send-transactions/AchievementsSBT/[contract].ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable functional/no-expression-statements */
12
import { always } from 'ramda'
23
import { createClient } from 'redis'
34
import type { APIRoute, Params } from 'astro'
@@ -52,7 +53,7 @@ export const POST: APIRoute = async ({
5253
isAddress(_p.contract) ? true : new Error('Bad request data'),
5354
) ?? new Error('Bad request data'),
5455
)
55-
56+
console.log('HERE1')
5657
const data = await whenNotErrorAll(
5758
[isValidAuth, request],
5859
async ([_iVA, _request]) =>
@@ -80,7 +81,7 @@ export const POST: APIRoute = async ({
8081
.catch((err) => new Error(err))
8182
}) ?? new Error('Invalid metadata'),
8283
)
83-
84+
console.log('HERE2')
8485
const sbtContractAddress = whenNotErrorAll(
8586
[isParamValid, params],
8687
([_iPV, _params]) =>
@@ -90,17 +91,17 @@ export const POST: APIRoute = async ({
9091
: _p.contract
9192
}) ?? new Error('Invalid sbt contract address'),
9293
)
93-
94+
console.log('HERE3')
9495
const wallet = whenNotErrorAll(
9596
[data],
9697
([{ rpcUrl }]) => createWallet({ rpcUrl }) ?? new Error('Wallet error'),
9798
)
98-
99+
console.log('HERE4')
99100
const contract = whenNotErrorAll(
100101
[sbtContractAddress, wallet],
101102
([addr, wal]) => new Contract(addr, abi, wal),
102103
)
103-
104+
console.log('HERE5')
104105
const redis = await whenNotError(
105106
createClient({
106107
url: REDIS_URL,
@@ -113,7 +114,7 @@ export const POST: APIRoute = async ({
113114
.then(always(db))
114115
.catch((err) => new Error(err)),
115116
)
116-
117+
console.log('HERE6')
117118
const encodedMetadata = await whenNotErrorAll(
118119
[contract, wallet, data, redis],
119120
async ([contract_, , { metadata }]) => {
@@ -129,7 +130,7 @@ export const POST: APIRoute = async ({
129130
.catch((err: Error) => err)
130131
},
131132
)
132-
133+
console.log('HERE7')
133134
const tx = await whenNotErrorAll(
134135
[contract, wallet, data, redis, encodedMetadata],
135136
async ([
@@ -153,7 +154,7 @@ export const POST: APIRoute = async ({
153154
.catch((err: Error) => err)
154155
},
155156
)
156-
157+
console.log('HERE8')
157158
const sbtMintLog = await whenNotErrorAll(
158159
[contract, tx],
159160
async ([contract_, tx_]) => {
@@ -166,15 +167,15 @@ export const POST: APIRoute = async ({
166167
new Error('SBT Mint log not found')
167168
},
168169
)
169-
170+
console.log('HERE9')
170171
const sbtToBeMinted = whenNotErrorAll(
171172
[tx, sbtMintLog],
172173
([tx_, sbtMintLog_]) =>
173174
whenDefinedAll([tx_, sbtMintLog_], ([, ml]) =>
174175
Number(ml.args.at(0).toString()),
175176
) ?? new Error('SBT minted not found'),
176177
)
177-
178+
console.log('HERE10')
178179
const saved = await whenNotErrorAll(
179180
[tx, redis, data, sbtContractAddress, sbtToBeMinted],
180181
([_tx, db, { reqId }, ,]) =>
@@ -185,14 +186,14 @@ export const POST: APIRoute = async ({
185186
'Missing TransactionResponse field to save the transaction: .to, .data',
186187
),
187188
)
188-
189+
console.log('HERE11')
189190
const result = await whenNotErrorAll([redis], ([db]) =>
190191
db
191192
.quit()
192193
.then((x) => x)
193194
.catch((err: Error) => err),
194195
)
195-
196+
console.log('HERE12')
196197
return result instanceof Error ||
197198
sbtToBeMinted instanceof Error ||
198199
saved instanceof Error

0 commit comments

Comments
 (0)