1
1
import { DEFAULT_BLOCKCHAIN_NAME , DEFAULT_CHAIN_ID } from "@/config/constants" ;
2
2
import { normieTechClient } from "@/lib/normie-tech" ;
3
3
import type { HypercertExchangeClient } from "@hypercerts-org/marketplace-sdk" ;
4
- import { User } from "@privy-io/react-auth" ;
5
4
import type { EthersError } from "ethers" ;
6
5
import { useState } from "react" ;
7
6
import type { Address } from "viem" ;
@@ -40,12 +39,14 @@ const useHandleBuyFraction = (
40
39
images ?: string [ ]
41
40
) => {
42
41
try {
42
+ console . log ( "order" , order )
43
43
const amountInCents = amountInDollars * 100 ;
44
44
setTransactionStatus ( "PreparingOrder" ) ;
45
45
const res = ( await normieTechClient . POST ( "/v1/voice-deck/0/checkout" , {
46
46
params : {
47
47
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
+
49
50
}
50
51
} ,
51
52
body :{
@@ -70,7 +71,7 @@ const useHandleBuyFraction = (
70
71
console . log ( "res" , res )
71
72
if ( res ) {
72
73
setTransactionStatus ( "Approval" )
73
- window . open ( res . url )
74
+ window . open ( res . url , "_self" )
74
75
}
75
76
} catch ( e ) {
76
77
setTransactionStatus ( "Failed" ) ; // generic fail error
@@ -205,36 +206,36 @@ const useHandleBuyFraction = (
205
206
name ,
206
207
images
207
208
) ;
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
+ // }
238
239
239
240
240
241
}
0 commit comments