Skip to content

Commit 9593f2c

Browse files
committed
feat: merge
2 parents 3a996af + cf4cbac commit 9593f2c

File tree

14 files changed

+675
-41
lines changed

14 files changed

+675
-41
lines changed

frontend/abi/PartiesFacetABI.ts

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
export const PartiesFacetABI = [
2+
{
3+
type: "event",
4+
anonymous: false,
5+
name: "PartyDeactivated",
6+
inputs: [
7+
{
8+
type: "tuple",
9+
name: "party",
10+
indexed: true,
11+
components: [
12+
{ type: "string", name: "name" },
13+
{ type: "address", name: "addr" },
14+
{ type: "uint8", name: "role" },
15+
{ type: "bool", name: "active" },
16+
{ type: "bool", name: "frozen" },
17+
{ type: "uint8", name: "rating" },
18+
],
19+
},
20+
],
21+
},
22+
{
23+
type: "event",
24+
anonymous: false,
25+
name: "PartyRegistered",
26+
inputs: [
27+
{
28+
type: "tuple",
29+
name: "party",
30+
indexed: true,
31+
components: [
32+
{ type: "string", name: "name" },
33+
{ type: "address", name: "addr" },
34+
{ type: "uint8", name: "role" },
35+
{ type: "bool", name: "active" },
36+
{ type: "bool", name: "frozen" },
37+
{ type: "uint8", name: "rating" },
38+
],
39+
},
40+
],
41+
},
42+
{
43+
type: "function",
44+
name: "deactivateParty",
45+
constant: false,
46+
payable: false,
47+
inputs: [{ type: "uint8", name: "_role" }],
48+
outputs: [],
49+
},
50+
{
51+
type: "function",
52+
name: "freezeParty",
53+
constant: false,
54+
payable: false,
55+
inputs: [{ type: "address", name: "_addr" }],
56+
outputs: [],
57+
},
58+
{
59+
type: "function",
60+
name: "getActiveParties",
61+
constant: true,
62+
stateMutability: "view",
63+
payable: false,
64+
inputs: [],
65+
outputs: [
66+
{
67+
type: "tuple[]",
68+
name: "",
69+
components: [
70+
{ type: "string", name: "name" },
71+
{ type: "address", name: "addr" },
72+
{ type: "uint8", name: "role" },
73+
{ type: "bool", name: "active" },
74+
{ type: "bool", name: "frozen" },
75+
{ type: "uint8", name: "rating" },
76+
],
77+
},
78+
],
79+
},
80+
{
81+
type: "function",
82+
name: "getActivePartiesAddress",
83+
constant: true,
84+
stateMutability: "view",
85+
payable: false,
86+
inputs: [],
87+
outputs: [{ type: "address[]", name: "" }],
88+
},
89+
{
90+
type: "function",
91+
name: "getActivePartiesAddressByRole",
92+
constant: true,
93+
stateMutability: "view",
94+
payable: false,
95+
inputs: [{ type: "uint8", name: "_role" }],
96+
outputs: [{ type: "address[]", name: "" }],
97+
},
98+
{
99+
type: "function",
100+
name: "getActivePartiesByRole",
101+
constant: true,
102+
stateMutability: "view",
103+
payable: false,
104+
inputs: [{ type: "uint8", name: "_role" }],
105+
outputs: [
106+
{
107+
type: "tuple[]",
108+
name: "",
109+
components: [
110+
{ type: "string", name: "name" },
111+
{ type: "address", name: "addr" },
112+
{ type: "uint8", name: "role" },
113+
{ type: "bool", name: "active" },
114+
{ type: "bool", name: "frozen" },
115+
{ type: "uint8", name: "rating" },
116+
],
117+
},
118+
],
119+
},
120+
{
121+
type: "function",
122+
name: "getParty",
123+
constant: true,
124+
stateMutability: "view",
125+
payable: false,
126+
inputs: [{ type: "address", name: "_addr" }],
127+
outputs: [
128+
{
129+
type: "tuple",
130+
name: "",
131+
components: [
132+
{ type: "string", name: "name" },
133+
{ type: "address", name: "addr" },
134+
{ type: "uint8", name: "role" },
135+
{ type: "bool", name: "active" },
136+
{ type: "bool", name: "frozen" },
137+
{ type: "uint8", name: "rating" },
138+
],
139+
},
140+
],
141+
},
142+
{
143+
type: "function",
144+
name: "hasActiveRole",
145+
constant: true,
146+
stateMutability: "view",
147+
payable: false,
148+
inputs: [
149+
{ type: "address", name: "_addr" },
150+
{ type: "uint8", name: "_role" },
151+
],
152+
outputs: [{ type: "bool", name: "" }],
153+
},
154+
{
155+
type: "function",
156+
name: "registerParty",
157+
constant: false,
158+
payable: false,
159+
inputs: [
160+
{ type: "string", name: "_name" },
161+
{ type: "uint8", name: "_role" },
162+
],
163+
outputs: [],
164+
},
165+
{
166+
type: "function",
167+
name: "unfreezeParty",
168+
constant: false,
169+
payable: false,
170+
inputs: [{ type: "address", name: "_addr" }],
171+
outputs: [],
172+
},
173+
];

frontend/abi/ProductsFacetABI.ts

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
export const ProductsFacetABI = [
2+
{
3+
type: "event",
4+
anonymous: false,
5+
name: "ProductCreated",
6+
inputs: [
7+
{
8+
type: "tuple",
9+
name: "product",
10+
indexed: true,
11+
components: [
12+
{ type: "uint24", name: "id" },
13+
{ type: "address", name: "tokenAddress" },
14+
{ type: "string", name: "name" },
15+
{ type: "int64", name: "price" },
16+
{ type: "int64", name: "totalSupply" },
17+
{ type: "address", name: "owner" },
18+
{ type: "uint8", name: "status" },
19+
{ type: "uint32", name: "timestamp" },
20+
{ type: "int64[]", name: "serialNumbers" },
21+
],
22+
},
23+
],
24+
},
25+
{
26+
type: "function",
27+
name: "createProduct",
28+
constant: false,
29+
payable: false,
30+
inputs: [
31+
{ type: "string", name: "_name" },
32+
{ type: "int64", name: "_price" },
33+
{ type: "int64", name: "_initialSupply" },
34+
],
35+
outputs: [],
36+
},
37+
{
38+
type: "function",
39+
name: "getAllProductTokenAddresses",
40+
constant: true,
41+
stateMutability: "view",
42+
payable: false,
43+
inputs: [],
44+
outputs: [{ type: "address[]", name: "" }],
45+
},
46+
{
47+
type: "function",
48+
name: "getAllProducts",
49+
constant: true,
50+
stateMutability: "view",
51+
payable: false,
52+
inputs: [],
53+
outputs: [
54+
{
55+
type: "tuple[]",
56+
name: "",
57+
components: [
58+
{ type: "uint24", name: "id" },
59+
{ type: "address", name: "tokenAddress" },
60+
{ type: "string", name: "name" },
61+
{ type: "int64", name: "price" },
62+
{ type: "int64", name: "totalSupply" },
63+
{ type: "address", name: "owner" },
64+
{ type: "uint8", name: "status" },
65+
{ type: "uint32", name: "timestamp" },
66+
{ type: "int64[]", name: "serialNumbers" },
67+
],
68+
},
69+
],
70+
},
71+
{
72+
type: "function",
73+
name: "getProductByTokenAddress",
74+
constant: true,
75+
stateMutability: "view",
76+
payable: false,
77+
inputs: [{ type: "address", name: "_tokenAddress" }],
78+
outputs: [
79+
{
80+
type: "tuple",
81+
name: "",
82+
components: [
83+
{ type: "uint24", name: "id" },
84+
{ type: "address", name: "tokenAddress" },
85+
{ type: "string", name: "name" },
86+
{ type: "int64", name: "price" },
87+
{ type: "int64", name: "totalSupply" },
88+
{ type: "address", name: "owner" },
89+
{ type: "uint8", name: "status" },
90+
{ type: "uint32", name: "timestamp" },
91+
{ type: "int64[]", name: "serialNumbers" },
92+
],
93+
},
94+
],
95+
},
96+
{
97+
type: "function",
98+
name: "getSupplierProductTokenAddresses",
99+
constant: true,
100+
stateMutability: "view",
101+
payable: false,
102+
inputs: [{ type: "address", name: "_owner" }],
103+
outputs: [{ type: "address[]", name: "" }],
104+
},
105+
{
106+
type: "function",
107+
name: "getSupplierProducts",
108+
constant: true,
109+
stateMutability: "view",
110+
payable: false,
111+
inputs: [{ type: "address", name: "_owner" }],
112+
outputs: [
113+
{
114+
type: "tuple[]",
115+
name: "",
116+
components: [
117+
{ type: "uint24", name: "id" },
118+
{ type: "address", name: "tokenAddress" },
119+
{ type: "string", name: "name" },
120+
{ type: "int64", name: "price" },
121+
{ type: "int64", name: "totalSupply" },
122+
{ type: "address", name: "owner" },
123+
{ type: "uint8", name: "status" },
124+
{ type: "uint32", name: "timestamp" },
125+
{ type: "int64[]", name: "serialNumbers" },
126+
],
127+
},
128+
],
129+
},
130+
];

frontend/app/(auth)/layout.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,28 @@
1+
'use client';
2+
import useGetUser from "@/hooks/useGetUser";
3+
import { useRouter } from "next/navigation";
4+
import { useEffect } from "react";
5+
16
export default function AuthLayout({
27
children,
38
}: Readonly<{
49
children: React.ReactNode;
510
}>) {
11+
const router = useRouter();
12+
const userData = useGetUser();
13+
14+
useEffect(() => {
15+
// Only redirect if we have user data and user is registered
16+
if (userData?.isRegistered) {
17+
const { roleString } = userData;
18+
19+
if (roleString === "Supplier" || roleString === "Retailer") {
20+
router.push("/dashboard");
21+
} else if (roleString === "Transporter") {
22+
router.push("/transport");
23+
}
24+
}
25+
}, [userData, router]);
26+
627
return <main className="w-full">{children}</main>;
728
}

frontend/app/(dashboard)/layout.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,25 @@
22
import Footer from "@/components/shared/dash-footer";
33
import Header from "@/components/shared/header";
44
import SideBar from "@/components/shared/sidebar";
5-
import { useState } from "react";
5+
import { useAppKitAccount } from "@reown/appkit/react";
6+
import { useRouter } from "next/navigation";
7+
import { useEffect, useState } from "react";
68

79
export default function DashboardLayout({
810
children,
911
}: Readonly<{
1012
children: React.ReactNode;
1113
}>) {
1214
const [sidebarOpen, setSidebarOpen] = useState<boolean>(false);
15+
const { isConnected } = useAppKitAccount();
16+
const router = useRouter();
17+
18+
useEffect(() => {
19+
if (!isConnected) {
20+
router.push("/");
21+
}
22+
}, [isConnected, router]);
23+
1324
return (
1425
<div className=" bg-white lg:p-1.5">
1526
{/* Page Wrapper Start */}

0 commit comments

Comments
 (0)