Skip to content

Commit 5b7a730

Browse files
committed
Update tokens SDK
1 parent e09257e commit 5b7a730

File tree

4 files changed

+12
-39
lines changed

4 files changed

+12
-39
lines changed

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/token/distribution/token-sale.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { DollarSignIcon, XIcon } from "lucide-react";
55
import { useEffect, useState } from "react";
66
import type { ThirdwebClient } from "thirdweb";
77
import { defineChain } from "thirdweb";
8-
import { isRouterEnabled } from "thirdweb/tokens";
8+
import { isPoolRouterEnabled } from "thirdweb/tokens";
99
import { DistributionBarChart } from "@/components/blocks/distribution-chart";
1010
import { FormFieldSetup } from "@/components/blocks/FormFieldSetup";
1111
import { Badge } from "@/components/ui/badge";
@@ -36,7 +36,7 @@ export function TokenSaleSection(props: {
3636
const isRouterEnabledQuery = useQuery({
3737
queryFn: async () => {
3838
try {
39-
return await isRouterEnabled({
39+
return await isPoolRouterEnabled({
4040
// eslint-disable-next-line no-restricted-syntax
4141
chain: defineChain(Number(props.chainId)),
4242
client: props.client,

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/rewards/components/claim-rewards-page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
toTokens,
1111
} from "thirdweb";
1212
import { TokenIcon, TokenProvider, useSendTransaction } from "thirdweb/react";
13-
import { claimReward } from "thirdweb/tokens";
13+
import { claimRewards } from "thirdweb/tokens";
1414
import { DistributionBarChart } from "@/components/blocks/distribution-chart";
1515
import { WalletAddress } from "@/components/blocks/wallet-address";
1616
import { Button } from "@/components/ui/button";
@@ -42,7 +42,7 @@ export function ClaimRewardsPage(props: {
4242
const router = useDashboardRouter();
4343

4444
async function handleClaim() {
45-
const claimRewardsTx = claimReward({
45+
const claimRewardsTx = claimRewards({
4646
asset: props.assetContractClient.address,
4747
contract: props.entrypointContractClient,
4848
});

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/rewards/page.tsx

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import { notFound, redirect } from "next/navigation";
22
import { getContract } from "thirdweb";
33
import {
44
getDeployedEntrypointERC20,
5-
getRewardLocker,
6-
v3PositionManager as getV3PositionManager,
75
} from "thirdweb/tokens";
86
import { getProject } from "@/api/projects";
97
import { getContractPageParamsInfo } from "../../../../../../../(dashboard)/(chain)/[chain_id]/[contractAddress]/_utils/getContractFromParams";
@@ -44,27 +42,7 @@ export default async function Page(props: {
4442
entrypointContract: entrypointContractClient,
4543
});
4644

47-
const rewardLocker = await getRewardLocker({
48-
contract: entrypointContractClient,
49-
}).catch(() => null);
50-
51-
if (!reward || !rewardLocker) {
52-
redirect(
53-
`/team/${params.team_slug}/${params.project_slug}/contract/${params.chainIdOrSlug}/${params.contractAddress}`,
54-
);
55-
}
56-
57-
const rewardLockerContractClient = getContract({
58-
address: rewardLocker,
59-
chain: assetContractClient.chain,
60-
client: assetContractClient.client,
61-
});
62-
63-
const v3PositionManager = await getV3PositionManager({
64-
contract: rewardLockerContractClient,
65-
}).catch(() => null);
66-
67-
if (!v3PositionManager || v3PositionManager !== reward.positionManager) {
45+
if (!reward) {
6846
redirect(
6947
`/team/${params.team_slug}/${params.project_slug}/contract/${params.chainIdOrSlug}/${params.contractAddress}`,
7048
);
@@ -79,7 +57,7 @@ export default async function Page(props: {
7957
const unclaimedFees = await getUnclaimedFees({
8058
positionManager: v3PositionManagerContract,
8159
reward: {
82-
tokenId: reward.tokenId,
60+
tokenId: reward.positionId,
8361
recipient: reward.recipient,
8462
},
8563
});

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/rewards/utils/rewards.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,22 @@
1-
import { type ThirdwebContract, ZERO_ADDRESS } from "thirdweb";
2-
import { getReward } from "thirdweb/tokens";
1+
import { type ThirdwebContract } from "thirdweb";
2+
import { getRewards } from "thirdweb/tokens";
33

44
export async function getValidReward(params: {
55
assetContract: ThirdwebContract;
66
entrypointContract: ThirdwebContract;
77
}) {
88
try {
9-
const reward = await getReward({
9+
const rewards = await getRewards({
1010
contract: params.entrypointContract,
1111
asset: params.assetContract.address,
1212
});
1313

14-
if (
15-
reward.positionManager === ZERO_ADDRESS ||
16-
reward.recipient === ZERO_ADDRESS ||
17-
reward.referrer === ZERO_ADDRESS ||
18-
reward.referrerBps === 0 ||
19-
reward.tokenId === BigInt(0)
20-
) {
14+
if (rewards.length === 0) {
2115
return null;
2216
}
2317

24-
return reward;
18+
// It's potentially possible to have multiple rewards locked up, but it's not the default use case.
19+
return rewards[0];
2520
} catch {
2621
return null;
2722
}

0 commit comments

Comments
 (0)