Merge branch 'main' of github.com:interchain-name/icns-frontend

# Conflicts:
#	pages/verification/index.tsx
This commit is contained in:
HeesungB 2022-12-12 15:42:13 +09:00
commit b33309493a
4 changed files with 51 additions and 35 deletions

View File

@ -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" });

View File

@ -8,8 +8,6 @@ import Image from "next/image";
import {
IcnsVerificationResponse,
TwitterAuthInfoResponse,
VerifierMsg,
WidthHeightProps,
} from "../../types";
import { request } from "../../utils/url";
@ -24,7 +22,6 @@ import { SkeletonChainList } from "../../components/skeleton";
import { PrimaryButton } from "../../components/primary-button";
import { AccountInfos } from "../../config";
import {
ProfileContainer,
TwitterProfile,
} from "../../components/twitter-profile";
import { ChainList } from "../../components/chain-list";
@ -49,24 +46,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",
// };
//
// await request<IcnsVerificationResponse>("/api/icns-verification", {
// method: "post",
// headers: {
// "Content-Type": "application/json",
// },
// body: JSON.stringify({
// msg: JSON.stringify(verifierMsg),
// authToken: newTwitterAuthInfo.accessToken,
// }),
// });
const icnsVerificationList = (
await request<IcnsVerificationResponse>("/api/icns-verification", {
method: "post",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
claimer: "osmo1y5mm5nj5m8ttddt5ccspek6xgyyavehrkak7gq",
authToken: newTwitterAuthInfo.accessToken,
}),
})
).verificationList;
console.log(icnsVerificationList);
setIsLoading(false);
}

View File

@ -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;
}
)[];
}

View File

@ -1,4 +1,4 @@
export interface VerifierMsg {
export interface VerifyingMsg {
unique_twitter_id: string;
name: string;
claimer: string;