Skip to content

Commit

Permalink
merge it
Browse files Browse the repository at this point in the history
  • Loading branch information
kamalbuilds committed Aug 11, 2024
2 parents 364c624 + ad3c2a7 commit 39bfd89
Show file tree
Hide file tree
Showing 5 changed files with 287 additions and 27 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

## Overview

Cross Pay is an innovative cross-chain payment solution designed to bridge the gap between merchants and customers by providing a seamless, preference-based payment experience. By integrating with multiple blockchain plugins and utilizing the power of the SwapKit API and SDK, ThorSwap, ChainFlip, and MayoChain, Cross Pay ensures a secure, efficient, and versatile payment method for all parties involved.
Merchants Pay is an innovative cross-chain payment solution designed to bridge the gap between merchants and customers by providing a seamless, preference-based payment experience. By integrating with multiple blockchain plugins and utilizing the power of the SwapKit API and SDK, ThorSwap, ChainFlip, and MayoChain, Cross Pay ensures a secure, efficient, and versatile payment method for all parties involved.

Cross Pay leverages advanced blockchain technology to deliver a comprehensive payment solution that caters to the needs of both merchants and users.
Merchants Pay leverages advanced blockchain technology to deliver a comprehensive payment solution that caters to the needs of both merchants and users.


## Contract Deployments via create2
Expand Down
37 changes: 21 additions & 16 deletions frontend/app/api/store/route.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,36 @@
import { NextRequest, NextResponse } from "next/server"
import { PinataSDK } from "pinata"
import { Web3Storage } from "web3.storage"

import { NextRequest , NextResponse } from 'next/server'
import { Web3Storage } from 'web3.storage'

function getAccessToken(): string {
return process.env.WEB3STORAGE_TOKEN!
export const config = {
api: {
bodyParser: false,
},
}

function makeStorageClient(): Web3Storage {
return new Web3Storage({ token: getAccessToken() })
}
export const pinata = new PinataSDK({
pinataJwt: `${process.env.NEXT_PUBLIC_APP_PINATA_JWT}`,
pinataGateway: `${process.env.NEXT_PUBLIC_APP_GATEWAY_URL}`,
})

export async function POST(req: NextRequest, res: NextResponse) {
if (req.method === 'POST') {
if (req.method === "POST") {
try {
const storageClient = makeStorageClient()
const { body } = await req.json()
const { data } = await req.json()

const file = new File([body], 'data.txt', { type: 'text/plain' })
const cid = await storageClient.put([file])
return NextResponse.json({cid})
const file = new File([data], "data.txt", { type: "text/plain" })
const upload = await pinata.upload.file(file)

return NextResponse.json({ cid: upload.IpfsHash }, { status: 200 })
// res.status(200).json({ cid })
} catch (error) {
NextResponse.json({ error: 'Error storing data' })
console.log("Error >>>", error)

NextResponse.json({ error: "Error storing data" })
// res.status(500).json({ error: 'Error storing data' })
}
} else {
NextResponse.json({ error: 'Only POST requests are allowed' })
NextResponse.json({ error: "Only POST requests are allowed" })
// res.status(405).json({ error: 'Only POST requests are allowed' })
}
}
4 changes: 3 additions & 1 deletion frontend/app/preference/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ const Merchantpreference: React.FC = () => {
const { chain } = await getChainDetails()
try {
setIsLoading(true)
console.log("Chain and Data", chain, data, JSON.stringify(data, null, 2))

const response = await axios.post("/api/store", {
data: JSON.stringify(data, null, 2),
})
Expand All @@ -200,7 +202,7 @@ const Merchantpreference: React.FC = () => {
}
} catch (error) {
toast.error("Error storing data")
console.log(error)
console.log("error", error)
console.log((error as any).stack)
} finally {
setIsLoading(false)
Expand Down
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"lucide-react": "0.105.0-alpha.4",
"next": "^13.4.8",
"next-themes": "^0.2.1",
"pinata": "^0.1.10",
"pino-pretty": "^11.2.2",
"postcss": "^8.4.27",
"react": "^18.2.0",
Expand Down
Loading

0 comments on commit 39bfd89

Please sign in to comment.