Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Environment variables declared in this file are automatically made available to Prisma.
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema

# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings

# DATABASE_URL="postgresql://johndoe:randompassword@localhost:5432/mydb?schema=public"
DATABASE_URL="file:./dev.db"

NEXT_PUBLIC_BASE_API_URL = 'http://localhost:3000'
NEXT_PUBLIC_ORIGIN = 'http://localhost:3000,https://multisig-ton.oraidex.io/,'

r
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts

/prisma/dev.db
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ RUN \
else echo "Lockfile not found." && exit 1; \
fi

# Check if dev.db exists and run Prisma migrate if not
RUN \
if [ ! -f "dev.db" ]; \
then npx prisma migrate deploy; \
else echo "Database exists, skipping migration"; \
fi

# Rebuild the source code only when needed
FROM base AS builder
Expand Down
104 changes: 104 additions & 0 deletions app/api/multisig/[id]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import { NextRequest, NextResponse } from "next/server";
import { PrismaClient } from "@prisma/client";

const prisma = new PrismaClient();

export async function GET(req: NextRequest, { params }) {
try {
const { id } = params || {};
const url = new URL(req.url);

if (!id) {
return new NextResponse(
JSON.stringify({ error: "Address multisig notfound!" }),
{
status: 400,
}
);
}

const result = await prisma.multisig.findFirst({
where: {
address: id,
},
});

return new NextResponse(JSON.stringify({ data: result }), { status: 200 });
} catch (error) {
console.log("Error get multisig record: ", error);
return new NextResponse(
JSON.stringify({ error: "Failed to get multisig" }),
{
status: 500,
}
);
}
}

export async function PATCH(req: NextRequest, { params }) {
try {
const { name, address, createdBy, importedBy, signers, proposers } =
await req.json();

const { id } = params || {};
if (!id) {
return new NextResponse(
JSON.stringify({ error: "Address multisig notfound!" }),
{
status: 400,
}
);
}

const url = new URL(req.url);
const addressUser = url.searchParams.get("userAddress");

if (!addressUser) {
return new NextResponse(
JSON.stringify({ error: "addressUser is required" }),
{
status: 400,
}
);
}

const updateData: any = {};

if (name) {
updateData["name"] = name;
}
if (importedBy) {
updateData["importedBy"] = importedBy;
}
if (signers) {
updateData["signers"] = signers;
}
if (proposers) {
updateData["proposers"] = proposers;
}

const result = await prisma.multisig.upsert({
where: { address: id },
update: updateData,
create: {
...updateData,
address: id,
createdBy: addressUser,
},
});

return new NextResponse(
JSON.stringify({
message: "Multisig updated successfully",
data: result,
}),
{ status: 200 }
);
} catch (error) {
console.log("Error updating multisig record: ", error);
return new NextResponse(
JSON.stringify({ error: "Failed to update multisig" }),
{ status: 500 }
);
}
}
104 changes: 104 additions & 0 deletions app/api/multisig/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import { NextRequest, NextResponse } from "next/server";
import { PrismaClient } from "@prisma/client";

const prisma = new PrismaClient();

export async function GET(req: NextRequest) {
try {
const url = new URL(req.url);
const addressUser = url.searchParams.get("addressUser");

if (!addressUser) {
return new NextResponse(
JSON.stringify({ error: "addressUser is required" }),
{
status: 400,
}
);
}

const result = await prisma.multisig.findMany({
where: {
OR: [
{ createdBy: addressUser },
{ importedBy: { contains: addressUser } },
{ signers: { contains: addressUser } },
{ proposers: { contains: addressUser } },
],
},
});

return new NextResponse(JSON.stringify({ data: result }), { status: 200 });
} catch (error) {
console.log("Error get multisig record: ", error);
return new NextResponse(
JSON.stringify({ error: "Failed to get multisig" }),
{
status: 500,
}
);
}
}

export async function POST(req: NextRequest) {
try {
const { name, address, createdBy, importedBy, signers, proposers } =
await req.json();

const result = await prisma.multisig.create({
data: {
name,
address,
createdBy,
importedBy,
signers,
proposers,
},
});

return new NextResponse(
JSON.stringify({ message: "Multisig added successfully", data: result }),
{ status: 200 }
);
} catch (error) {
console.log("Error adding multisig record: ", error);
return new NextResponse(
JSON.stringify({ error: "Failed to add multisig" }),
{
status: 500,
}
);
}
}

// export async function PATCH(req: NextRequest) {
// try {
// const { name, address, createdBy, importedBy, signers, proposers } =
// await req.json();

// const result = await prisma.multisig.update({
// where: { address },
// data: {
// name,
// createdBy,
// importedBy: JSON.stringify(importedBy),
// signers: JSON.stringify(signers),
// proposers: JSON.stringify(proposers),
// },
// });

// return new NextResponse(
// JSON.stringify({
// message: "Multisig updated successfully",
// data: result,
// }),
// { status: 200 }
// );
// } catch (error) {
// console.log("Error updating multisig record: ", error);
// return new NextResponse(
// JSON.stringify({ error: "Failed to update multisig" }),
// { status: 500 }
// );
// }
// }
Empty file added app/api/other/.keep
Empty file.
3 changes: 0 additions & 3 deletions components/layout/connectButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,6 @@ const ConnectButton: FC<{ fullWidth?: boolean }> = ({ fullWidth }) => {
return;
}

console.log("userFriendlyAddress", userFriendlyAddress, wallet);

handleSetTonAddress({ tonAddress: userFriendlyAddress });
handleSetTonWallet({
tonWallet:
Expand All @@ -141,7 +139,6 @@ const ConnectButton: FC<{ fullWidth?: boolean }> = ({ fullWidth }) => {
});
}, [userFriendlyAddress, wallet]);

console.log("tonAddress", tonAddress);
return (
<div
className={classNames(styles.wrapperConnect, {
Expand Down
Loading