forked from LaconicNetwork/icns-frontend
Update to get verification list
This commit is contained in:
parent
4b866891ac
commit
cd81a19f00
@ -9,21 +9,29 @@ export default withIronSessionApiRoute(async function handler(
|
||||
res: NextApiResponse,
|
||||
) {
|
||||
try {
|
||||
if (!process.env.ICNS_VERIFIER_URI) {
|
||||
if (!process.env.ICNS_VERIFIER_ORIGIN_LIST) {
|
||||
console.log(".env is not set");
|
||||
return res.status(500).json({ error: "Internal server error" });
|
||||
}
|
||||
const icnsVerificationInfo = await request<IcnsVerificationResponse>(
|
||||
process.env.ICNS_VERIFIER_URI,
|
||||
{
|
||||
method: "post",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(req.body),
|
||||
},
|
||||
const verifierOriginList = process.env.ICNS_VERIFIER_ORIGIN_LIST.split(",");
|
||||
|
||||
const verificationList = await Promise.allSettled(
|
||||
verifierOriginList.map((verfierOrigin) =>
|
||||
request<IcnsVerificationResponse>(
|
||||
`${verfierOrigin}/api/verify_twitter`,
|
||||
{
|
||||
method: "post",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(req.body),
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
res.status(200).json(icnsVerificationInfo);
|
||||
res.status(200).json({
|
||||
verificationList,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).json({ error: "Internal server error" });
|
||||
|
@ -8,7 +8,7 @@ import Image from "next/image";
|
||||
import {
|
||||
IcnsVerificationResponse,
|
||||
TwitterAuthInfoResponse,
|
||||
VerifierMsg,
|
||||
VerifyingMsg,
|
||||
WidthHeightProps,
|
||||
} from "../../types";
|
||||
import { request } from "../../utils/url";
|
||||
@ -48,24 +48,20 @@ export default function VerificationPage() {
|
||||
|
||||
setTwitterAuthInfo(newTwitterAuthInfo);
|
||||
|
||||
const verifierMsg: VerifierMsg = {
|
||||
unique_twitter_id: newTwitterAuthInfo.id,
|
||||
name: newTwitterAuthInfo.username,
|
||||
claimer: "osmo1y5mm5nj5m8ttddt5ccspek6xgyyavehrkak7gq",
|
||||
contract_address: "osmo1y5mm5nj5m8ttddt5ccspek6xgyyavehrkak7gq",
|
||||
chain_id: "osmosis-1",
|
||||
};
|
||||
const icnsVerificationList = (
|
||||
await request<IcnsVerificationResponse>("/api/icns-verification", {
|
||||
method: "post",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
claimer: "osmo1y5mm5nj5m8ttddt5ccspek6xgyyavehrkak7gq",
|
||||
authToken: newTwitterAuthInfo.accessToken,
|
||||
}),
|
||||
})
|
||||
).verificationList;
|
||||
|
||||
await request<IcnsVerificationResponse>("/api/icns-verification", {
|
||||
method: "post",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
msg: JSON.stringify(verifierMsg),
|
||||
authToken: newTwitterAuthInfo.accessToken,
|
||||
}),
|
||||
});
|
||||
console.log(icnsVerificationList);
|
||||
|
||||
setIsLoading(false);
|
||||
}
|
||||
|
@ -15,6 +15,21 @@ export interface TwitterAuthInfoResponse {
|
||||
}
|
||||
|
||||
export interface IcnsVerificationResponse {
|
||||
signature: number[];
|
||||
algorithm: string;
|
||||
verificationList: (
|
||||
| {
|
||||
status: "fulfilled";
|
||||
value: {
|
||||
errors: Error[];
|
||||
data: {
|
||||
verifying_msg: string;
|
||||
signature: number[];
|
||||
algorithm: string;
|
||||
};
|
||||
};
|
||||
}
|
||||
| {
|
||||
status: "rejected";
|
||||
reason: Error;
|
||||
}
|
||||
)[];
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
export interface VerifierMsg {
|
||||
export interface VerifyingMsg {
|
||||
unique_twitter_id: string;
|
||||
name: string;
|
||||
claimer: string;
|
||||
|
Loading…
Reference in New Issue
Block a user