feat: update crossbell SDK to v1 (#562)
This commit is contained in:
parent
8e052f25d6
commit
127617af9c
29
package.json
29
package.json
|
|
@ -35,12 +35,12 @@
|
|||
"@codemirror/state": "6.2.0",
|
||||
"@codemirror/theme-one-dark": "6.1.2",
|
||||
"@codemirror/view": "6.11.1",
|
||||
"@crossbell/connect-kit": "0.0.82",
|
||||
"@crossbell/contract": "0.0.82",
|
||||
"@crossbell/indexer": "0.0.82",
|
||||
"@crossbell/notification": "0.0.82",
|
||||
"@crossbell/ui": "0.0.82",
|
||||
"@crossbell/util-hooks": "0.0.82",
|
||||
"@crossbell/connect-kit": "1.2.2",
|
||||
"@crossbell/contract": "1.2.0",
|
||||
"@crossbell/indexer": "1.2.0",
|
||||
"@crossbell/notification": "1.2.2",
|
||||
"@crossbell/ui": "1.2.2",
|
||||
"@crossbell/util-hooks": "1.2.0",
|
||||
"@ddietr/codemirror-themes": "1.4.1",
|
||||
"@dqbd/tiktoken": "^1.0.7",
|
||||
"@emoji-mart/data": "1.1.2",
|
||||
|
|
@ -50,14 +50,14 @@
|
|||
"@heroicons/react": "2.0.18",
|
||||
"@iconify-json/mingcute": "^1.1.6",
|
||||
"@lezer/highlight": "^1.1.4",
|
||||
"@mantine/core": "^6.0.10",
|
||||
"@mantine/core": "^6.0.11",
|
||||
"@mantine/dates": "^6.0.11",
|
||||
"@monaco-editor/react": "4.5.1",
|
||||
"@popperjs/core": "^2.11.7",
|
||||
"@prisma/client": "^4.14.0",
|
||||
"@tanstack/react-query": "4.29.5",
|
||||
"@tanstack/react-query-devtools": "4.29.6",
|
||||
"@tanstack/react-query-persist-client": "4.29.5",
|
||||
"@tanstack/react-query": "4.29.7",
|
||||
"@tanstack/react-query-devtools": "4.29.7",
|
||||
"@tanstack/react-query-persist-client": "4.29.7",
|
||||
"@uiw/codemirror-extensions-events": "4.19.16",
|
||||
"@urql/core": "4.0.7",
|
||||
"ahooks": "^3.7.7",
|
||||
|
|
@ -67,7 +67,7 @@
|
|||
"canvas-confetti": "^1.6.0",
|
||||
"chroma-js": "^2.4.2",
|
||||
"clsx": "1.2.1",
|
||||
"crossbell.js": "0.19.9",
|
||||
"crossbell": "^1.1.0",
|
||||
"dayjs": "1.11.7",
|
||||
"dotenv": "16.0.3",
|
||||
"emoji-mart": "5.5.2",
|
||||
|
|
@ -139,13 +139,14 @@
|
|||
"tailwind-merge": "^1.12.0",
|
||||
"tailwind-scrollbar-hide": "^1.1.7",
|
||||
"tailwindcss-animate": "^1.0.5",
|
||||
"unidata.js": "0.7.20",
|
||||
"unidata.js": "0.8.0",
|
||||
"unified": "10.1.2",
|
||||
"unist-builder": "3.0.1",
|
||||
"unist-util-visit": "4.1.2",
|
||||
"use-onclickoutside": "0.4.1",
|
||||
"uuid": "9.0.0",
|
||||
"wagmi": "0.12.13",
|
||||
"viem": "^0.3.30",
|
||||
"wagmi": "1.0.5",
|
||||
"zustand": "^4.3.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
@ -203,4 +204,4 @@
|
|||
"minimumChangeThreshold": 0,
|
||||
"showDetails": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
994
pnpm-lock.yaml
994
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
|
|
@ -1,4 +1,4 @@
|
|||
import { NoteEntity } from "crossbell.js"
|
||||
import type { NoteEntity } from "crossbell"
|
||||
import { redirect } from "next/navigation"
|
||||
|
||||
import { IS_VERCEL_PREVIEW } from "~/lib/constants"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use client"
|
||||
|
||||
import type { NoteMetadata } from "crossbell.js"
|
||||
import type { NoteMetadata } from "crossbell"
|
||||
import { useParams } from "next/navigation"
|
||||
import { useEffect, useState } from "react"
|
||||
import { useForm } from "react-hook-form"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use client"
|
||||
|
||||
import type { NoteMetadata } from "crossbell.js"
|
||||
import type { NoteMetadata } from "crossbell"
|
||||
import { useParams } from "next/navigation"
|
||||
import { useEffect } from "react"
|
||||
import { useForm } from "react-hook-form"
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ export default function TokensPage() {
|
|||
</div>
|
||||
<div className="text-lg">
|
||||
{t("Balance")}:{" "}
|
||||
<span className="font-bold">{token.balance}</span>
|
||||
<span className="font-bold">{`${token.balance}`}</span>
|
||||
</div>
|
||||
<div>{token.buttons}</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
"use client"
|
||||
|
||||
import { useState } from "react"
|
||||
import { WagmiConfig, createClient } from "wagmi"
|
||||
import { WagmiConfig } from "wagmi"
|
||||
|
||||
import {
|
||||
ConnectKitProvider,
|
||||
getDefaultClientConfig,
|
||||
} from "@crossbell/connect-kit"
|
||||
import { ConnectKitProvider, createWagmiConfig } from "@crossbell/connect-kit"
|
||||
import {
|
||||
NotificationModal,
|
||||
NotificationModalColorScheme,
|
||||
|
|
@ -24,7 +21,7 @@ import { createIDBPersister } from "~/lib/persister.client"
|
|||
import { urlComposer } from "~/lib/url-composer"
|
||||
import { LangProvider } from "~/providers/LangProvider"
|
||||
|
||||
const wagmiClient = createClient(getDefaultClientConfig({ appName: APP_NAME }))
|
||||
const wagmiConfig = createWagmiConfig({ appName: APP_NAME })
|
||||
|
||||
const persister = createIDBPersister()
|
||||
|
||||
|
|
@ -58,7 +55,7 @@ export default function Providers({
|
|||
)
|
||||
|
||||
return (
|
||||
<WagmiConfig client={wagmiClient}>
|
||||
<WagmiConfig config={wagmiConfig}>
|
||||
<PersistQueryClientProvider
|
||||
client={queryClient}
|
||||
persistOptions={{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { CharacterEntity, NoteEntity } from "crossbell.js"
|
||||
import type { CharacterEntity, NoteEntity } from "crossbell"
|
||||
import { useCallback, useEffect, useRef } from "react"
|
||||
import { useForm } from "react-hook-form"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use client"
|
||||
|
||||
import { CharacterEntity, NoteEntity } from "crossbell.js"
|
||||
import type { CharacterEntity, NoteEntity } from "crossbell"
|
||||
import { useState } from "react"
|
||||
|
||||
import { useAccountState } from "@crossbell/connect-kit"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type { NoteMetadata } from "crossbell.js"
|
||||
import type { NoteMetadata } from "crossbell"
|
||||
import { useState } from "react"
|
||||
|
||||
import { useDate } from "~/hooks/useDate"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { CharacterEntity, NoteEntity } from "crossbell.js"
|
||||
import type { CharacterEntity, NoteEntity } from "crossbell"
|
||||
import { nanoid } from "nanoid"
|
||||
|
||||
import { SCORE_API_DOMAIN, SITE_URL } from "~/lib/env"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type { NoteEntity } from "crossbell.js"
|
||||
import type { NoteEntity } from "crossbell"
|
||||
|
||||
import { ExpandedCharacter, ExpandedNote } from "~/lib/types"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type { CharacterEntity, NoteEntity } from "crossbell.js"
|
||||
import type { CharacterEntity, NoteEntity } from "crossbell"
|
||||
|
||||
export type Site = {
|
||||
id: string
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ export async function getFeed({
|
|||
}
|
||||
switch (type) {
|
||||
case "latest": {
|
||||
let result = await indexer.getNotes({
|
||||
let result = await indexer.note.getMany({
|
||||
sources: "xlog",
|
||||
tags: ["post"],
|
||||
limit,
|
||||
|
|
@ -84,13 +84,16 @@ export async function getFeed({
|
|||
count: 0,
|
||||
}
|
||||
} else {
|
||||
const result = await indexer.getNotesOfCharacterFollowing(characterId, {
|
||||
sources: "xlog",
|
||||
tags: ["post"],
|
||||
limit: limit,
|
||||
cursor,
|
||||
includeCharacter: true,
|
||||
})
|
||||
const result = await indexer.note.getManyOfCharacterFollowing(
|
||||
characterId,
|
||||
{
|
||||
sources: "xlog",
|
||||
tags: ["post"],
|
||||
limit: limit,
|
||||
cursor,
|
||||
includeCharacter: true,
|
||||
},
|
||||
)
|
||||
|
||||
const list = await Promise.all(
|
||||
result.list.map(async (page: any) => {
|
||||
|
|
@ -260,7 +263,7 @@ export async function getFeed({
|
|||
}
|
||||
}
|
||||
case "search": {
|
||||
const result = await indexer.searchNotes(searchKeyword!, {
|
||||
const result = await indexer.search.notes(searchKeyword!, {
|
||||
sources: ["xlog"],
|
||||
tags: ["post"],
|
||||
limit: limit,
|
||||
|
|
@ -298,7 +301,7 @@ export async function getFeed({
|
|||
}
|
||||
}
|
||||
|
||||
let result = await indexer.getNotes({
|
||||
let result = await indexer.note.getMany({
|
||||
sources: "xlog",
|
||||
tags: ["post", tag],
|
||||
limit,
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
import { NoteMetadata } from "crossbell.js"
|
||||
import type {
|
||||
CharacterEntity,
|
||||
Contract,
|
||||
ListResponse,
|
||||
MintedNoteEntity,
|
||||
NoteEntity,
|
||||
} from "crossbell.js"
|
||||
NoteMetadata,
|
||||
} from "crossbell"
|
||||
import type Unidata from "unidata.js"
|
||||
import type { Address } from "viem"
|
||||
|
||||
import { GeneralAccount } from "@crossbell/connect-kit"
|
||||
import { indexer } from "@crossbell/indexer"
|
||||
|
|
@ -136,12 +137,12 @@ export async function postNotes(
|
|||
},
|
||||
contract?: Contract,
|
||||
) {
|
||||
return contract?.postNotes(
|
||||
input.notes.map((note) => ({
|
||||
return contract?.note.postMany({
|
||||
notes: input.notes.map((note) => ({
|
||||
characterId: input.characterId,
|
||||
metadataOrUri: note,
|
||||
})),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
const getLocalPages = (input: {
|
||||
|
|
@ -175,15 +176,15 @@ const getLocalPages = (input: {
|
|||
locked: false,
|
||||
contractAddress: null,
|
||||
uri: null,
|
||||
operator: "",
|
||||
owner: "",
|
||||
operator: "" as Address, // TODO: check usage and replace it with viem's `zeroAddress`.
|
||||
owner: "" as Address, // TODO: check usage and replace it with viem's `zeroAddress`.
|
||||
createdAt: new Date(page.date).toISOString(),
|
||||
updatedAt: new Date(page.date).toISOString(),
|
||||
deletedAt: null,
|
||||
transactionHash: "",
|
||||
transactionHash: "" as Address, // TODO: check usage and replace it with viem's `zeroAddress`.
|
||||
blockNumber: 0,
|
||||
logIndex: 0,
|
||||
updatedTransactionHash: "",
|
||||
updatedTransactionHash: "" as Address, // TODO: check usage and replace it with viem's `zeroAddress`.
|
||||
updatedBlockNumber: 0,
|
||||
updatedLogIndex: 0,
|
||||
metadata: {
|
||||
|
|
@ -234,7 +235,7 @@ export async function getPagesBySite(input: {
|
|||
|
||||
const visibility = input.visibility || PageVisibilityEnum.All
|
||||
|
||||
const notes = await indexer.getNotes({
|
||||
const notes = await indexer.note.getMany({
|
||||
characterId: input.characterId,
|
||||
limit: input.limit || 10,
|
||||
cursor: input.cursor,
|
||||
|
|
@ -338,7 +339,7 @@ export async function getSearchPagesBySite(input: {
|
|||
keyword?: string
|
||||
cursor?: string
|
||||
}) {
|
||||
const result = await indexer.searchNotes(input.keyword || "", {
|
||||
const result = await indexer.search.notes(input.keyword || "", {
|
||||
cursor: input.cursor,
|
||||
characterId: input.characterId,
|
||||
tags: ["post"],
|
||||
|
|
@ -386,7 +387,7 @@ export async function getPage<TRender extends boolean = false>(input: {
|
|||
input.noteId = (await response.json())?.noteId
|
||||
}
|
||||
if (input.noteId) {
|
||||
page = await indexer.getNote(input.characterId, input.noteId)
|
||||
page = await indexer.note.get(input.characterId, input.noteId)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -470,7 +471,7 @@ export async function getLikes({
|
|||
cursor?: string
|
||||
includeCharacter?: boolean
|
||||
}) {
|
||||
const res = await indexer.getBacklinksOfNote(characterId, noteId, {
|
||||
const res = await indexer.link.getBacklinksByNote(characterId, noteId, {
|
||||
linkType: "like",
|
||||
cursor,
|
||||
})
|
||||
|
|
@ -495,7 +496,7 @@ export async function checkLike({
|
|||
if (!account.characterId) {
|
||||
throw notFound(`character not found`)
|
||||
} else {
|
||||
return indexer.getLinks(account.characterId, {
|
||||
return indexer.link.getMany(account.characterId, {
|
||||
linkType: "like",
|
||||
toCharacterId: characterId,
|
||||
toNoteId: noteId,
|
||||
|
|
@ -515,7 +516,11 @@ export async function mintPage(
|
|||
},
|
||||
contract?: Contract,
|
||||
) {
|
||||
return contract?.mintNote(characterId, noteId, address)
|
||||
return contract?.note.mint({
|
||||
characterId,
|
||||
noteId,
|
||||
toAddress: address as Address,
|
||||
})
|
||||
}
|
||||
|
||||
export async function getMints({
|
||||
|
|
@ -529,7 +534,7 @@ export async function getMints({
|
|||
cursor?: string
|
||||
includeCharacter?: boolean
|
||||
}) {
|
||||
const data = await indexer.getMintedNotesOfNote(characterId, noteId, {
|
||||
const data = await indexer.mintedNote.getManyOfNote(characterId, noteId, {
|
||||
cursor,
|
||||
limit: 5,
|
||||
})
|
||||
|
|
@ -538,7 +543,7 @@ export async function getMints({
|
|||
await Promise.all(
|
||||
data.list.map(async (item: any) => {
|
||||
if (!item.character) {
|
||||
item.character = await indexer.getPrimaryCharacter(item.owner)
|
||||
item.character = await indexer.character.getPrimary(item.owner)
|
||||
}
|
||||
}),
|
||||
)
|
||||
|
|
@ -560,7 +565,7 @@ export async function checkMint({
|
|||
noteCharacterId: number
|
||||
noteId: number
|
||||
}) {
|
||||
return indexer.getMintedNotesOfAddress(address, {
|
||||
return indexer.mintedNote.getManyOfAddress(address as Address, {
|
||||
noteCharacterId: noteCharacterId,
|
||||
noteId: noteId,
|
||||
})
|
||||
|
|
@ -586,7 +591,7 @@ export async function getComments({
|
|||
limit: 5,
|
||||
}
|
||||
|
||||
const res = (await indexer.getNotes(options)) || {
|
||||
const res = (await indexer.note.getMany(options)) || {
|
||||
total: 0,
|
||||
list: [],
|
||||
}
|
||||
|
|
@ -608,16 +613,20 @@ export async function updateComment(
|
|||
},
|
||||
contract: Contract,
|
||||
) {
|
||||
return contract.setNoteMetadata(characterId, noteId, {
|
||||
content,
|
||||
external_urls: [externalUrl],
|
||||
tags: ["comment"],
|
||||
sources: ["xlog"],
|
||||
return contract.note.setMetadata({
|
||||
characterId,
|
||||
noteId,
|
||||
metadata: {
|
||||
content,
|
||||
external_urls: [externalUrl],
|
||||
tags: ["comment"],
|
||||
sources: ["xlog"],
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export async function checkMirror(characterId: number) {
|
||||
const notes = await indexer.getNotes({
|
||||
const notes = await indexer.note.getMany({
|
||||
characterId,
|
||||
sources: "xlog",
|
||||
tags: ["post", "Mirror.xyz"],
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
import { CharacterOperatorPermission, Indexer } from "crossbell.js"
|
||||
import { CharacterOperatorPermission } from "crossbell"
|
||||
import type Unidata from "unidata.js"
|
||||
import type { Address } from "viem"
|
||||
|
||||
import type { useContract } from "@crossbell/contract"
|
||||
import { indexer } from "@crossbell/indexer"
|
||||
import { cacheExchange, createClient, fetchExchange } from "@urql/core"
|
||||
|
||||
import { expandCrossbellCharacter } from "~/lib/expand-unit"
|
||||
|
|
@ -9,17 +11,15 @@ import { SiteNavigationItem } from "~/lib/types"
|
|||
|
||||
type Contract = ReturnType<typeof useContract>
|
||||
|
||||
const indexer = new Indexer()
|
||||
|
||||
export const getSite = async (input: string) => {
|
||||
const result = await indexer.getCharacterByHandle(input)
|
||||
const result = await indexer.character.getByHandle(input)
|
||||
if (result) {
|
||||
return expandCrossbellCharacter(result)
|
||||
}
|
||||
}
|
||||
|
||||
export const getSiteByAddress = async (input: string) => {
|
||||
const result = await indexer.getCharacters(input, {
|
||||
const result = await indexer.character.getMany(input as Address, {
|
||||
primary: true,
|
||||
})
|
||||
|
||||
|
|
@ -66,7 +66,7 @@ export const getSubscription = async (input: {
|
|||
toCharacterId: number
|
||||
characterId: number
|
||||
}) => {
|
||||
const result = await indexer.getLinks(input.characterId, {
|
||||
const result = await indexer.link.getMany(input.characterId, {
|
||||
linkType: "follow",
|
||||
toCharacterId: input.toCharacterId,
|
||||
})
|
||||
|
|
@ -79,7 +79,7 @@ export const getSiteSubscriptions = async (data: {
|
|||
cursor?: string
|
||||
limit?: number
|
||||
}) => {
|
||||
return indexer.getBacklinksOfCharacter(data.characterId, {
|
||||
return indexer.link.getBacklinksOfCharacter(data.characterId, {
|
||||
linkType: "follow",
|
||||
cursor: data.cursor,
|
||||
limit: data.limit,
|
||||
|
|
@ -90,7 +90,7 @@ export const getSiteToSubscriptions = async (data: {
|
|||
characterId: number
|
||||
cursor?: string
|
||||
}) => {
|
||||
return indexer.getLinks(data.characterId, {
|
||||
return indexer.link.getMany(data.characterId, {
|
||||
linkType: "follow",
|
||||
cursor: data.cursor,
|
||||
})
|
||||
|
|
@ -218,7 +218,7 @@ export async function getCommentsBySite(input: {
|
|||
characterId?: number
|
||||
cursor?: string
|
||||
}) {
|
||||
const notes = await indexer.getNotes({
|
||||
const notes = await indexer.note.getMany({
|
||||
toCharacterId: input.characterId,
|
||||
limit: 7,
|
||||
includeCharacter: true,
|
||||
|
|
@ -250,19 +250,20 @@ export async function addOperator(
|
|||
contract?: Contract,
|
||||
) {
|
||||
if (input.operator && input.characterId) {
|
||||
return contract?.grantOperatorPermissionsForCharacter(
|
||||
input.characterId,
|
||||
input.operator,
|
||||
xLogOperatorPermissions,
|
||||
)
|
||||
return contract?.operator.grantForCharacter({
|
||||
characterId: input.characterId,
|
||||
operator: input.operator as Address,
|
||||
permissions: xLogOperatorPermissions,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export async function getOperators(input: { characterId?: number }) {
|
||||
if (input.characterId) {
|
||||
const result = await indexer?.getCharacterOperators(input.characterId, {
|
||||
limit: 100,
|
||||
})
|
||||
const result = await indexer?.operator.getManyForCharacter(
|
||||
input.characterId,
|
||||
{ limit: 100 },
|
||||
)
|
||||
result.list = result.list
|
||||
.filter(
|
||||
(o) =>
|
||||
|
|
@ -288,8 +289,12 @@ export async function isOperators(input: {
|
|||
}) {
|
||||
if (input.characterId) {
|
||||
const permissions =
|
||||
(await indexer?.getCharacterOperator(input.characterId, input.operator))
|
||||
?.permissions || []
|
||||
(
|
||||
await indexer?.operator.getForCharacter(
|
||||
input.characterId,
|
||||
input.operator as Address,
|
||||
)
|
||||
)?.permissions || []
|
||||
for (const permission of xLogOperatorPermissions) {
|
||||
if (!permissions.includes(permission)) {
|
||||
return false
|
||||
|
|
@ -308,11 +313,11 @@ export async function removeOperator(
|
|||
contract?: Contract,
|
||||
) {
|
||||
if (input.characterId) {
|
||||
return contract?.grantOperatorPermissionsForCharacter(
|
||||
input.characterId,
|
||||
input.operator,
|
||||
[],
|
||||
)
|
||||
return contract?.operator.grantForCharacter({
|
||||
characterId: input.characterId,
|
||||
operator: input.operator as Address,
|
||||
permissions: [],
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -334,15 +339,13 @@ export async function getStat({ characterId }: { characterId: number }) {
|
|||
`https://indexer.crossbell.io/v1/stat/characters/${characterId}`,
|
||||
)
|
||||
).json(),
|
||||
indexer.getCharacter(characterId),
|
||||
indexer.getBacklinksOfCharacter(characterId, {
|
||||
limit: 0,
|
||||
}),
|
||||
indexer.getNotes({
|
||||
indexer.character.get(characterId),
|
||||
indexer.link.getBacklinksOfCharacter(characterId, { limit: 0 }),
|
||||
indexer.note.getMany({
|
||||
limit: 0,
|
||||
toCharacterId: characterId,
|
||||
}),
|
||||
indexer.getNotes({
|
||||
indexer.note.getMany({
|
||||
characterId,
|
||||
sources: "xlog",
|
||||
tags: ["post"],
|
||||
|
|
@ -363,7 +366,7 @@ export async function getStat({ characterId }: { characterId: number }) {
|
|||
const getMiraTokenDecimals = async (contract: Contract) => {
|
||||
let decimals
|
||||
try {
|
||||
decimals = await contract.getMiraTokenDecimals()
|
||||
decimals = await contract.tips.getTokenDecimals()
|
||||
} catch (error) {
|
||||
decimals = {
|
||||
data: 18,
|
||||
|
|
@ -383,18 +386,18 @@ export async function tipCharacter(
|
|||
) {
|
||||
const decimals = await getMiraTokenDecimals(contract)
|
||||
if (input.noteId) {
|
||||
return await contract?.tipCharacterForNote(
|
||||
input.fromCharacterId,
|
||||
input.toCharacterId,
|
||||
input.noteId,
|
||||
BigInt(input.amount) * BigInt(10) ** BigInt(decimals?.data || 18),
|
||||
)
|
||||
return await contract?.tips.tipCharacterForNote({
|
||||
fromCharacterId: input.fromCharacterId,
|
||||
toCharacterId: input.toCharacterId,
|
||||
toNoteId: input.noteId,
|
||||
amount: BigInt(input.amount) * BigInt(10) ** BigInt(decimals?.data || 18),
|
||||
})
|
||||
} else {
|
||||
return await contract?.tipCharacter(
|
||||
input.fromCharacterId,
|
||||
input.toCharacterId,
|
||||
BigInt(input.amount) * BigInt(10) ** BigInt(decimals?.data || 18),
|
||||
)
|
||||
return await contract?.tips.tipCharacter({
|
||||
fromCharacterId: input.fromCharacterId,
|
||||
toCharacterId: input.toCharacterId,
|
||||
amount: BigInt(input.amount) * BigInt(10) ** BigInt(decimals?.data || 18),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -408,8 +411,8 @@ export async function getTips(
|
|||
},
|
||||
contract: Contract,
|
||||
) {
|
||||
const address = await contract.getMiraTokenAddress()
|
||||
const tips = await indexer?.getTips({
|
||||
const address = await contract.tips.getTokenAddress()
|
||||
const tips = await indexer?.tip.getMany({
|
||||
characterId: input.characterId,
|
||||
toNoteId: input.toNoteId,
|
||||
toCharacterId: input.toCharacterId,
|
||||
|
|
@ -474,7 +477,7 @@ export type AchievementSection = {
|
|||
}
|
||||
|
||||
export async function getAchievements(characterId: number) {
|
||||
const crossbellAchievements = (await indexer.getAchievements(characterId))
|
||||
const crossbellAchievements = (await indexer.achievement.getMany(characterId))
|
||||
?.list as AchievementSection[] | undefined
|
||||
const xLogAchievements: AchievementSection[] = [
|
||||
{
|
||||
|
|
@ -552,16 +555,14 @@ export async function mintAchievement(input: {
|
|||
characterId: number
|
||||
achievementId: number
|
||||
}) {
|
||||
return indexer.mintAchievement(input.characterId, input.achievementId)
|
||||
return indexer.achievement.mint(input.characterId, input.achievementId)
|
||||
}
|
||||
|
||||
export async function getMiraBalance(characterId: number, contract: Contract) {
|
||||
const decimals = await getMiraTokenDecimals(contract)
|
||||
const result = await contract.getMiraBalanceOfCharacter(characterId)
|
||||
result.data = (
|
||||
BigInt(result.data) /
|
||||
BigInt(10) ** BigInt(decimals?.data || 18)
|
||||
).toString()
|
||||
const result = await contract.tips.getBalanceOfCharacter({ characterId })
|
||||
|
||||
result.data = BigInt(result.data) / BigInt(10) ** BigInt(decimals?.data || 18)
|
||||
|
||||
return result
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue