From e03a023bb76937405801cc8b73781835ec6eefe2 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Tue, 9 Aug 2022 22:05:56 +0100 Subject: [PATCH] fix: promised crossbell contract --- src/lib/crossbell.ts | 4 ++-- src/models/page.model.ts | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib/crossbell.ts b/src/lib/crossbell.ts index 7221623a..0be89e33 100644 --- a/src/lib/crossbell.ts +++ b/src/lib/crossbell.ts @@ -4,10 +4,10 @@ const indexer = new Indexer() let contract: Contract | undefined -const getContract = () => { +const getContract = async () => { if (!contract && typeof window !== "undefined") { contract = new Contract((window).ethereum) - contract.connect() + await contract.connect() } return contract } diff --git a/src/models/page.model.ts b/src/models/page.model.ts index 3350bcbc..6e1774df 100644 --- a/src/models/page.model.ts +++ b/src/models/page.model.ts @@ -307,7 +307,7 @@ export async function likePage({ if (!characterId) { throw notFound(`character not found`) } else { - return getContract()?.linkNote( + return (await getContract())?.linkNote( characterId, pageId.split("-")[0], pageId.split("-")[1], @@ -327,7 +327,7 @@ export async function unlikePage({ if (!characterId) { throw notFound(`character not found`) } else { - return getContract()?.unlinkNote( + return (await getContract())?.unlinkNote( characterId, pageId.split("-")[0], pageId.split("-")[1], @@ -373,7 +373,7 @@ export async function mintPage({ address: string pageId: string }) { - return getContract()?.mintNote( + return (await getContract())?.mintNote( pageId.split("-")[0], pageId.split("-")[1], address, @@ -416,7 +416,7 @@ export async function commentPage({ if (!characterId) { throw notFound(`character not found`) } else { - return getContract()?.postNoteForNote( + return (await getContract())?.postNoteForNote( characterId, { content,