Skip to content

Commit 7f0b2a1

Browse files
committed
refactor: clean up commented code and improve API client configuration
1 parent d6dd546 commit 7f0b2a1

File tree

3 files changed

+40
-37
lines changed

3 files changed

+40
-37
lines changed

components/global/connect-button.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ const ConnectButton = () => {
2929
return (
3030
<div>
3131
<Button onClick={() => open()}>Connect Wallet</Button>
32-
{!isLogin ? (
32+
{/* {!isLogin ? (
3333
<Button onClick={() => login({ loginMethods: ["email"] })}>
3434
Login
3535
</Button>
3636
) : (
3737
<Button onClick={() => logout()}>LogOut</Button>
38-
)}
38+
)} */}
3939
</div>
4040
);
4141
};

hooks/use-buy-fraction.ts

+34-33
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { DEFAULT_BLOCKCHAIN_NAME, DEFAULT_CHAIN_ID } from "@/config/constants";
22
import { normieTechClient } from "@/lib/normie-tech";
33
import type { HypercertExchangeClient } from "@hypercerts-org/marketplace-sdk";
4-
import { User } from "@privy-io/react-auth";
54
import type { EthersError } from "ethers";
65
import { useState } from "react";
76
import type { Address } from "viem";
@@ -40,12 +39,14 @@ const useHandleBuyFraction = (
4039
images?: string[]
4140
) =>{
4241
try{
42+
console.log("order",order)
4343
const amountInCents = amountInDollars * 100;
4444
setTransactionStatus("PreparingOrder");
4545
const res = (await normieTechClient.POST("/v1/voice-deck/0/checkout",{
4646
params: {
4747
header: {
48-
"x-api-key":process.env.NEXT_PUBLIC_NORMAL_TECH_API_KEY ?? ""
48+
"x-api-key":process.env.NEXT_PUBLIC_NORMAL_TECH_API_KEY ?? "",
49+
4950
}
5051
},
5152
body:{
@@ -70,7 +71,7 @@ const useHandleBuyFraction = (
7071
console.log("res", res)
7172
if(res){
7273
setTransactionStatus("Approval")
73-
window.open(res.url)
74+
window.open(res.url,"_self")
7475
}
7576
}catch(e){
7677
setTransactionStatus("Failed"); // generic fail error
@@ -205,36 +206,36 @@ const useHandleBuyFraction = (
205206
name,
206207
images
207208
);
208-
case "fiat-without-login": {
209-
if (!email) {
210-
throw new Error("Email is required for fiat-without-login");
211-
}
212-
const wallet : {wallet:User} = await fetch("/api/wallet-generate", {
213-
method: "POST",
214-
headers: {
215-
"Content-Type": "application/json",
216-
},
217-
body: JSON.stringify({
218-
address: email,
219-
}),
220-
}).then((res) => res.json());
221-
if(!wallet.wallet.wallet?.address){
222-
setTransactionStatus("Failed");
223-
224-
return
225-
}
226-
return handleFiatBuyFraction(
227-
order,
228-
amount,
229-
wallet.wallet.wallet.address as Address,
230-
hypercertId,
231-
comment,
232-
amountInDollars,
233-
email,
234-
name,
235-
images
236-
);
237-
}
209+
// case "fiat-without-login": {
210+
// if (!email) {
211+
// throw new Error("Email is required for fiat-without-login");
212+
// }
213+
// const wallet : {wallet:User} = await fetch("/api/wallet-generate", {
214+
// method: "POST",
215+
// headers: {
216+
// "Content-Type": "application/json",
217+
// },
218+
// body: JSON.stringify({
219+
// address: email,
220+
// }),
221+
// }).then((res) => res.json());
222+
// if(!wallet.wallet.wallet?.address){
223+
// setTransactionStatus("Failed");
224+
225+
// return
226+
// }
227+
// return handleFiatBuyFraction(
228+
// order,
229+
// amount,
230+
// wallet.wallet.wallet.address as Address,
231+
// hypercertId,
232+
// comment,
233+
// amountInDollars,
234+
// email,
235+
// name,
236+
// images
237+
// );
238+
// }
238239

239240

240241
}

lib/normie-tech.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,11 @@ export interface components {
154154
}
155155
export type $defs = Record<string, never>;
156156
export type operations = Record<string, never>;
157+
157158
export const normieTechClient = createClient<paths>({
158-
baseUrl: "https://hkov68i606.execute-api.us-east-2.amazonaws.com/dipanshu/",
159+
baseUrl: "https://api.normie.tech",
159160
headers:{
160-
"Access-Control-Allow-Origin":"*"
161+
"Access-Control-Allow-Origin":"*",
162+
"Content-Type":"application/json"
161163
}
162164
});

0 commit comments

Comments
 (0)