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