@b3dotfun/sdk 0.0.7-alpha.7 → 0.0.7-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/anyspend/constants/index.js +5 -2
- package/dist/cjs/anyspend/index.d.ts +1 -0
- package/dist/cjs/anyspend/index.js +1 -0
- package/dist/cjs/anyspend/react/components/AnySpendBuySpin.js +33 -33
- package/dist/cjs/anyspend/react/components/AnySpendCustom.d.ts +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +75 -43
- package/dist/cjs/anyspend/react/components/AnySpendNFT.d.ts +3 -2
- package/dist/cjs/anyspend/react/components/AnySpendNFT.js +5 -3
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +4 -3
- package/dist/cjs/anyspend/react/components/AnySpendTournament.js +4 -1
- package/dist/cjs/anyspend/services/anyspend.d.ts +1 -1
- package/dist/cjs/anyspend/services/anyspend.js +1 -1
- package/dist/cjs/anyspend/types/index.d.ts +1 -0
- package/dist/cjs/anyspend/types/index.js +1 -0
- package/dist/cjs/anyspend/types/metadata.d.ts +26 -0
- package/dist/cjs/anyspend/types/metadata.js +16 -0
- package/dist/cjs/anyspend/types/nft.d.ts +1 -0
- package/dist/cjs/anyspend/types/req-res/getQuote.d.ts +11 -0
- package/dist/cjs/anyspend/types/req-res/getQuote.js +4 -1
- package/dist/cjs/anyspend/utils/orderPayload.d.ts +3 -3
- package/dist/cjs/anyspend/utils/orderPayload.js +18 -4
- package/dist/esm/anyspend/constants/index.js +5 -2
- package/dist/esm/anyspend/index.d.ts +1 -0
- package/dist/esm/anyspend/index.js +1 -0
- package/dist/esm/anyspend/react/components/AnySpendBuySpin.js +5 -5
- package/dist/esm/anyspend/react/components/AnySpendCustom.d.ts +2 -2
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +52 -20
- package/dist/esm/anyspend/react/components/AnySpendNFT.d.ts +3 -2
- package/dist/esm/anyspend/react/components/AnySpendNFT.js +5 -3
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +5 -4
- package/dist/esm/anyspend/react/components/AnySpendTournament.js +4 -1
- package/dist/esm/anyspend/services/anyspend.d.ts +1 -1
- package/dist/esm/anyspend/services/anyspend.js +1 -1
- package/dist/esm/anyspend/types/index.d.ts +1 -0
- package/dist/esm/anyspend/types/index.js +1 -0
- package/dist/esm/anyspend/types/metadata.d.ts +26 -0
- package/dist/esm/anyspend/types/metadata.js +11 -0
- package/dist/esm/anyspend/types/nft.d.ts +1 -0
- package/dist/esm/anyspend/types/req-res/getQuote.d.ts +11 -0
- package/dist/esm/anyspend/types/req-res/getQuote.js +4 -1
- package/dist/esm/anyspend/utils/orderPayload.d.ts +3 -3
- package/dist/esm/anyspend/utils/orderPayload.js +19 -5
- package/dist/types/anyspend/index.d.ts +1 -0
- package/dist/types/anyspend/react/components/AnySpendCustom.d.ts +2 -2
- package/dist/types/anyspend/react/components/AnySpendNFT.d.ts +3 -2
- package/dist/types/anyspend/services/anyspend.d.ts +1 -1
- package/dist/types/anyspend/types/index.d.ts +1 -0
- package/dist/types/anyspend/types/metadata.d.ts +26 -0
- package/dist/types/anyspend/types/nft.d.ts +1 -0
- package/dist/types/anyspend/types/req-res/getQuote.d.ts +11 -0
- package/dist/types/anyspend/utils/orderPayload.d.ts +3 -3
- package/package.json +1 -1
- package/src/anyspend/constants/index.ts +5 -3
- package/src/anyspend/index.ts +1 -0
- package/src/anyspend/react/components/AnySpendBuySpin.tsx +8 -7
- package/src/anyspend/react/components/AnySpendCustom.tsx +68 -24
- package/src/anyspend/react/components/AnySpendNFT.tsx +9 -4
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +7 -6
- package/src/anyspend/react/components/AnySpendTournament.tsx +4 -1
- package/src/anyspend/services/anyspend.ts +2 -2
- package/src/anyspend/types/index.ts +1 -0
- package/src/anyspend/types/metadata.ts +41 -0
- package/src/anyspend/types/nft.ts +1 -0
- package/src/anyspend/types/req-res/getQuote.ts +4 -1
- package/src/anyspend/utils/orderPayload.ts +17 -5
|
@@ -4,10 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.anyspendService = void 0;
|
|
7
|
+
const constants_1 = require("../../anyspend/constants");
|
|
7
8
|
const types_1 = require("../../anyspend/types");
|
|
8
9
|
const utils_1 = require("../../anyspend/utils");
|
|
9
10
|
const invariant_1 = __importDefault(require("invariant"));
|
|
10
|
-
const constants_1 = require("../../anyspend/constants");
|
|
11
11
|
// Service functions
|
|
12
12
|
exports.anyspendService = {
|
|
13
13
|
getTokenList: async (isMainnet, chainId, query) => {
|
|
@@ -18,6 +18,7 @@ __exportStar(require("./req-res"), exports);
|
|
|
18
18
|
__exportStar(require("./chain"), exports);
|
|
19
19
|
__exportStar(require("./custom"), exports);
|
|
20
20
|
__exportStar(require("./globalWallet"), exports);
|
|
21
|
+
__exportStar(require("./metadata"), exports);
|
|
21
22
|
__exportStar(require("./nft"), exports);
|
|
22
23
|
__exportStar(require("./onramp"), exports);
|
|
23
24
|
__exportStar(require("./order"), exports);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { NftContract } from "./nft";
|
|
2
|
+
import { OrderType } from "./order";
|
|
3
|
+
export type BaseMetadata = {
|
|
4
|
+
type: OrderType;
|
|
5
|
+
};
|
|
6
|
+
export type NftMetadata = BaseMetadata & {
|
|
7
|
+
type: OrderType.MintNFT;
|
|
8
|
+
nftContract: NftContract;
|
|
9
|
+
};
|
|
10
|
+
export type TournamentMetadata = BaseMetadata & {
|
|
11
|
+
type: OrderType.JoinTournament | OrderType.FundTournament;
|
|
12
|
+
tournament: {
|
|
13
|
+
slug: string;
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
imageUrl: string;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export type CustomTxMetadata = BaseMetadata & {
|
|
20
|
+
type: OrderType.Custom;
|
|
21
|
+
action: string;
|
|
22
|
+
};
|
|
23
|
+
export type AnySpendMetadata = NftMetadata | TournamentMetadata | CustomTxMetadata;
|
|
24
|
+
export declare function isNftMetadata(metadata: AnySpendMetadata): metadata is NftMetadata;
|
|
25
|
+
export declare function isTournamentMetadata(metadata: AnySpendMetadata): metadata is TournamentMetadata;
|
|
26
|
+
export declare function isCustomTxMetadata(metadata: AnySpendMetadata): metadata is CustomTxMetadata;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isNftMetadata = isNftMetadata;
|
|
4
|
+
exports.isTournamentMetadata = isTournamentMetadata;
|
|
5
|
+
exports.isCustomTxMetadata = isCustomTxMetadata;
|
|
6
|
+
const order_1 = require("./order");
|
|
7
|
+
// Type guard functions
|
|
8
|
+
function isNftMetadata(metadata) {
|
|
9
|
+
return metadata.type === order_1.OrderType.MintNFT;
|
|
10
|
+
}
|
|
11
|
+
function isTournamentMetadata(metadata) {
|
|
12
|
+
return metadata.type === order_1.OrderType.JoinTournament || metadata.type === order_1.OrderType.FundTournament;
|
|
13
|
+
}
|
|
14
|
+
function isCustomTxMetadata(metadata) {
|
|
15
|
+
return metadata.type === order_1.OrderType.Custom;
|
|
16
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { QuoteDetails } from "@reservoir0x/relay-sdk";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
+
import { NftType } from "../nft";
|
|
3
4
|
import { OrderType } from "../order";
|
|
4
5
|
import { TradeType } from "../relay";
|
|
5
6
|
export declare const zGetQuoteRequest: z.ZodObject<{
|
|
@@ -36,10 +37,14 @@ export declare const zGetQuoteRequest: z.ZodObject<{
|
|
|
36
37
|
} & {
|
|
37
38
|
type: z.ZodLiteral<OrderType.MintNFT>;
|
|
38
39
|
contractAddress: z.ZodString;
|
|
40
|
+
tokenId: z.ZodNullable<z.ZodNumber>;
|
|
41
|
+
contractType: z.ZodNativeEnum<typeof NftType>;
|
|
39
42
|
price: z.ZodString;
|
|
40
43
|
}, "strip", z.ZodTypeAny, {
|
|
41
44
|
type: OrderType.MintNFT;
|
|
42
45
|
contractAddress: string;
|
|
46
|
+
tokenId: number | null;
|
|
47
|
+
contractType: NftType;
|
|
43
48
|
srcChain: number;
|
|
44
49
|
dstChain: number;
|
|
45
50
|
srcTokenAddress: string;
|
|
@@ -48,6 +53,8 @@ export declare const zGetQuoteRequest: z.ZodObject<{
|
|
|
48
53
|
}, {
|
|
49
54
|
type: OrderType.MintNFT;
|
|
50
55
|
contractAddress: string;
|
|
56
|
+
tokenId: number | null;
|
|
57
|
+
contractType: NftType;
|
|
51
58
|
srcChain: number;
|
|
52
59
|
dstChain: number;
|
|
53
60
|
srcTokenAddress: string;
|
|
@@ -163,6 +170,8 @@ export declare const zGetQuoteRequest: z.ZodObject<{
|
|
|
163
170
|
} | {
|
|
164
171
|
type: OrderType.MintNFT;
|
|
165
172
|
contractAddress: string;
|
|
173
|
+
tokenId: number | null;
|
|
174
|
+
contractType: NftType;
|
|
166
175
|
srcChain: number;
|
|
167
176
|
dstChain: number;
|
|
168
177
|
srcTokenAddress: string;
|
|
@@ -209,6 +218,8 @@ export declare const zGetQuoteRequest: z.ZodObject<{
|
|
|
209
218
|
} | {
|
|
210
219
|
type: OrderType.MintNFT;
|
|
211
220
|
contractAddress: string;
|
|
221
|
+
tokenId: number | null;
|
|
222
|
+
contractType: NftType;
|
|
212
223
|
srcChain: number;
|
|
213
224
|
dstChain: number;
|
|
214
225
|
srcTokenAddress: string;
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.zGetQuoteRequest = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
+
const custom_1 = require("../custom");
|
|
6
|
+
const nft_1 = require("../nft");
|
|
5
7
|
const order_1 = require("../order");
|
|
6
8
|
const relay_1 = require("../relay");
|
|
7
|
-
const custom_1 = require("../custom");
|
|
8
9
|
const zGetQuoteBody = zod_1.z.object({
|
|
9
10
|
srcChain: zod_1.z.number(),
|
|
10
11
|
dstChain: zod_1.z.number(),
|
|
@@ -19,6 +20,8 @@ const zGetQuoteForSwapOrderBody = zGetQuoteBody.extend({
|
|
|
19
20
|
const zGetQuoteForMintNftOrderBody = zGetQuoteBody.extend({
|
|
20
21
|
type: zod_1.z.literal(order_1.OrderType.MintNFT),
|
|
21
22
|
contractAddress: zod_1.z.string(),
|
|
23
|
+
tokenId: zod_1.z.number().nullable(),
|
|
24
|
+
contractType: zod_1.z.nativeEnum(nft_1.NftType),
|
|
22
25
|
price: zod_1.z.string()
|
|
23
26
|
});
|
|
24
27
|
const zGetQuoteForJoinTournamentOrderBody = zGetQuoteBody.extend({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Nft, OrderType, Token, Tournament } from "../../anyspend/types";
|
|
1
|
+
import { Nft, NftType, OrderType, Token, Tournament } from "../../anyspend/types";
|
|
2
2
|
export type OrderParams = {
|
|
3
3
|
orderType: OrderType;
|
|
4
4
|
srcToken: Token;
|
|
@@ -38,13 +38,13 @@ export declare const buildMetadata: (orderType: OrderType, params: OrderParams)
|
|
|
38
38
|
} | {
|
|
39
39
|
nft: (({
|
|
40
40
|
name: string;
|
|
41
|
-
type:
|
|
41
|
+
type: NftType.ERC721;
|
|
42
42
|
contractAddress: string;
|
|
43
43
|
description: string;
|
|
44
44
|
imageUrl: string;
|
|
45
45
|
} | {
|
|
46
46
|
name: string;
|
|
47
|
-
type:
|
|
47
|
+
type: NftType.ERC1155;
|
|
48
48
|
contractAddress: string;
|
|
49
49
|
description: string;
|
|
50
50
|
imageUrl: string;
|
|
@@ -12,10 +12,24 @@ const buildPayload = (orderType, params) => {
|
|
|
12
12
|
actualDstAmount: null
|
|
13
13
|
};
|
|
14
14
|
case types_1.OrderType.MintNFT:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
if (nft?.type === types_1.NftType.ERC1155) {
|
|
16
|
+
return {
|
|
17
|
+
contractAddress: (0, utils_1.normalizeAddress)(nft.contractAddress),
|
|
18
|
+
nftPrice: nft?.price || "",
|
|
19
|
+
tokenId: nft?.tokenId,
|
|
20
|
+
contractType: nft?.type
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
else if (nft?.type === types_1.NftType.ERC721) {
|
|
24
|
+
return {
|
|
25
|
+
contractAddress: (0, utils_1.normalizeAddress)(nft.contractAddress),
|
|
26
|
+
nftPrice: nft?.price || "",
|
|
27
|
+
contractType: nft?.type
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
throw new Error(`Invalid nft payload: ${JSON.stringify(nft)}`);
|
|
32
|
+
}
|
|
19
33
|
case types_1.OrderType.JoinTournament:
|
|
20
34
|
return {
|
|
21
35
|
contractAddress: tournament?.contractAddress,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NftType } from "../../anyspend/types/index.js";
|
|
1
2
|
import { base } from "viem/chains";
|
|
2
3
|
export const ANYSPEND_MAINNET_BASE_URL = process.env.NEXT_PUBLIC_ANYSPEND_BASE_URL || "https://mainnet.anyspend.com";
|
|
3
4
|
export const ANYSPEND_TESTNET_BASE_URL = process.env.NEXT_PUBLIC_ANYSPEND_BASE_URL || "https://testnet.anyspend.com";
|
|
@@ -36,7 +37,8 @@ export const NFT_CONTRACTS = [
|
|
|
36
37
|
imageUrl: "https://storage.googleapis.com/nftimagebucket/base/tokens/0x80f0e6644723abb03aa8867d21e32bd854b2a2d9/preview/TVRjME1EUTRORFl4T0E9PV8zNjcy.jpg",
|
|
37
38
|
name: "Downhill Ski",
|
|
38
39
|
description: "Downhill Ski",
|
|
39
|
-
tokenId: null
|
|
40
|
+
tokenId: null,
|
|
41
|
+
type: NftType.ERC721
|
|
40
42
|
},
|
|
41
43
|
{
|
|
42
44
|
chainId: base.id,
|
|
@@ -47,7 +49,8 @@ export const NFT_CONTRACTS = [
|
|
|
47
49
|
imageUrl: "https://cdn.b3.fun/game-weapon-demo.png",
|
|
48
50
|
name: "Eclipse Venom",
|
|
49
51
|
description: "The Eclipse Venom's crystalline blade channels imprisoned astral toxins through swirling currents of violet and teal light, synchronizing with its wielder's heartbeat for strikes that bypass conventional armor. Wounds from this otherworldly weapon resist healing as victims describe being consumed from within by liquid darkness, their final moments filled with visions of infinite cosmic depths.",
|
|
50
|
-
tokenId: null
|
|
52
|
+
tokenId: null,
|
|
53
|
+
type: NftType.ERC721
|
|
51
54
|
}
|
|
52
55
|
];
|
|
53
56
|
export const DEFAULT_NFT_CONTRACT = NFT_CONTRACTS[1];
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { B3_TOKEN, OrderType } from "../../../anyspend/index.js";
|
|
3
|
+
import { Button, GlareCardRounded, Input, StyleRoot, TextLoop, useChainSwitchWithAction, useHasMounted, useModalStore, useTokenBalance } from "../../../global-account/react/index.js";
|
|
3
4
|
import { baseMainnet } from "../../../shared/constants/chains/supported.js";
|
|
4
|
-
import { EthIcon } from "./icons/EthIcon.js";
|
|
5
|
-
import { SolIcon } from "./icons/SolIcon.js";
|
|
6
|
-
import { UsdcIcon } from "./icons/USDCIcon.js";
|
|
7
|
-
import { StyleRoot } from "../../../global-account/react/index.js";
|
|
8
|
-
import { Button, GlareCardRounded, Input, TextLoop, useChainSwitchWithAction, useHasMounted, useTokenBalance, useModalStore } from "../../../global-account/react/index.js";
|
|
9
5
|
import { motion } from "framer-motion";
|
|
10
6
|
import invariant from "invariant";
|
|
11
7
|
import { ArrowRight, Loader2 } from "lucide-react";
|
|
@@ -14,6 +10,9 @@ import { toast } from "sonner";
|
|
|
14
10
|
import { createPublicClient, encodeFunctionData, erc20Abi, formatUnits, http } from "viem";
|
|
15
11
|
import { useAccount, useWaitForTransactionReceipt, useWriteContract } from "wagmi";
|
|
16
12
|
import { AnySpendCustom } from "./AnySpendCustom.js";
|
|
13
|
+
import { EthIcon } from "./icons/EthIcon.js";
|
|
14
|
+
import { SolIcon } from "./icons/SolIcon.js";
|
|
15
|
+
import { UsdcIcon } from "./icons/USDCIcon.js";
|
|
17
16
|
const SPIN_WHEEL_ABI = [
|
|
18
17
|
{
|
|
19
18
|
inputs: [],
|
|
@@ -388,6 +387,7 @@ export function AnySpendBuySpin({ isMainnet = true, loadOrder, mode = "modal", s
|
|
|
388
387
|
// AnySpend flow for when user needs to swap to B3
|
|
389
388
|
const encodedData = generateEncodedDataForBuyEntriesAndSpin(address || "", userSpinQuantity);
|
|
390
389
|
return (_jsx(AnySpendCustom, { isMainnet: isMainnet, loadOrder: loadOrder, mode: mode, recipientAddress: recipientAddress, orderType: OrderType.Custom, dstChainId: chainId, dstToken: B3_TOKEN, dstAmount: totalCost.toString(), contractAddress: spinwheelContractAddress, spenderAddress: paymentConfig.entryModule, encodedData: encodedData, metadata: {
|
|
390
|
+
type: OrderType.Custom,
|
|
391
391
|
action: `buy ${userSpinQuantity} spin${userSpinQuantity !== "1" ? "s" : ""}`
|
|
392
392
|
}, header: header, onSuccess: txHash => onSuccess?.(txHash), showRecipient: false }));
|
|
393
393
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GetQuoteResponse, OrderType, Token } from "../../../anyspend";
|
|
1
|
+
import { AnySpendMetadata, GetQuoteResponse, OrderType, Token } from "../../../anyspend";
|
|
2
2
|
import React from "react";
|
|
3
3
|
export declare function AnySpendCustom({ isMainnet, loadOrder, mode, recipientAddress: recipientAddressProps, spenderAddress, orderType, dstChainId, dstToken, dstAmount, contractAddress, encodedData, metadata, header, onSuccess, showRecipient }: {
|
|
4
4
|
isMainnet?: boolean;
|
|
@@ -12,7 +12,7 @@ export declare function AnySpendCustom({ isMainnet, loadOrder, mode, recipientAd
|
|
|
12
12
|
dstAmount: string;
|
|
13
13
|
contractAddress: string;
|
|
14
14
|
encodedData: string;
|
|
15
|
-
metadata:
|
|
15
|
+
metadata: AnySpendMetadata;
|
|
16
16
|
header: ({ anyspendPrice, isLoadingAnyspendPrice }: {
|
|
17
17
|
anyspendPrice: GetQuoteResponse | undefined;
|
|
18
18
|
isLoadingAnyspendPrice: boolean;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { eqci, getDefaultToken, NftType, OrderStatus, OrderType, RELAY_ETH_ADDRESS, USDC_BASE, useAnyspendCreateOnrampOrder, useAnyspendCreateOrder, useAnyspendOrderAndTransactions, useAnyspendQuote, useAnyspendTokenList, useGeoOnrampOptions } from "../../../anyspend/index.js";
|
|
3
|
-
import {
|
|
4
|
-
import { Badge, Button, ShinyButton, Skeleton, Tabs, TabsContent, TabsList, TabTrigger, useAccountWallet, useBsmntProfile, useHasMounted, useRouter, useTokenBalancesByChain, useModalStore, useSearchParamsSSR } from "../../../global-account/react/index.js";
|
|
5
|
-
import { TextShimmer } from "../../../global-account/react/index.js";
|
|
6
|
-
import { TransitionPanel } from "../../../global-account/react/index.js";
|
|
2
|
+
import { eqci, getDefaultToken, isCustomTxMetadata, isNftMetadata, isTournamentMetadata, NftType, OrderStatus, OrderType, RELAY_ETH_ADDRESS, USDC_BASE, useAnyspendCreateOnrampOrder, useAnyspendCreateOrder, useAnyspendOrderAndTransactions, useAnyspendQuote, useAnyspendTokenList, useGeoOnrampOptions } from "../../../anyspend/index.js";
|
|
3
|
+
import { Badge, Button, ShinyButton, Skeleton, StyleRoot, Tabs, TabsContent, TabsList, TabTrigger, TextShimmer, TransitionPanel, useAccountWallet, useB3, useBsmntProfile, useHasMounted, useModalStore, useRouter, useSearchParamsSSR, useTokenBalancesByChain } from "../../../global-account/react/index.js";
|
|
7
4
|
import { cn } from "../../../shared/utils/index.js";
|
|
8
5
|
import centerTruncate from "../../../shared/utils/centerTruncate.js";
|
|
9
6
|
import { formatTokenAmount } from "../../../shared/utils/number.js";
|
|
@@ -26,7 +23,7 @@ var PanelView;
|
|
|
26
23
|
PanelView[PanelView["ORDER_DETAILS"] = 2] = "ORDER_DETAILS";
|
|
27
24
|
PanelView[PanelView["LOADING"] = 3] = "LOADING";
|
|
28
25
|
})(PanelView || (PanelView = {}));
|
|
29
|
-
function generateGetRelayQuoteRequest({ orderType, srcChainId, srcToken, dstChainId, dstToken, dstAmount, contractAddress, encodedData, spenderAddress }) {
|
|
26
|
+
function generateGetRelayQuoteRequest({ orderType, srcChainId, srcToken, dstChainId, dstToken, dstAmount, contractAddress, tokenId, contractType, encodedData, spenderAddress }) {
|
|
30
27
|
switch (orderType) {
|
|
31
28
|
case OrderType.MintNFT: {
|
|
32
29
|
return {
|
|
@@ -36,7 +33,9 @@ function generateGetRelayQuoteRequest({ orderType, srcChainId, srcToken, dstChai
|
|
|
36
33
|
dstChain: dstChainId,
|
|
37
34
|
dstTokenAddress: dstToken.address,
|
|
38
35
|
price: dstAmount,
|
|
39
|
-
contractAddress: contractAddress
|
|
36
|
+
contractAddress: contractAddress,
|
|
37
|
+
tokenId: tokenId,
|
|
38
|
+
contractType: contractType
|
|
40
39
|
};
|
|
41
40
|
}
|
|
42
41
|
case OrderType.JoinTournament: {
|
|
@@ -160,6 +159,8 @@ export function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", re
|
|
|
160
159
|
dstToken: dstToken,
|
|
161
160
|
dstAmount: dstAmount,
|
|
162
161
|
contractAddress: contractAddress,
|
|
162
|
+
tokenId: isNftMetadata(metadata) ? metadata.nftContract.tokenId : undefined,
|
|
163
|
+
contractType: isNftMetadata(metadata) ? metadata.nftContract.type : undefined,
|
|
163
164
|
encodedData: encodedData,
|
|
164
165
|
spenderAddress: spenderAddress
|
|
165
166
|
});
|
|
@@ -239,21 +240,35 @@ export function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", re
|
|
|
239
240
|
srcAmount: srcAmount.toString(),
|
|
240
241
|
recipientAddress,
|
|
241
242
|
creatorAddress: currentWallet?.wallet?.address,
|
|
242
|
-
nft:
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
243
|
+
nft: isNftMetadata(metadata)
|
|
244
|
+
? metadata.nftContract.type === NftType.ERC1155
|
|
245
|
+
? {
|
|
246
|
+
type: NftType.ERC1155,
|
|
247
|
+
contractAddress: metadata.nftContract.contractAddress,
|
|
248
|
+
tokenId: metadata.nftContract.tokenId,
|
|
249
|
+
imageUrl: metadata.nftContract.imageUrl,
|
|
250
|
+
nftPrice: dstAmount
|
|
251
|
+
}
|
|
252
|
+
: {
|
|
253
|
+
type: NftType.ERC721,
|
|
254
|
+
contractAddress: metadata.nftContract.contractAddress,
|
|
255
|
+
contractType: metadata.nftContract.type,
|
|
256
|
+
nftPrice: dstAmount
|
|
257
|
+
}
|
|
258
|
+
: undefined,
|
|
259
|
+
tournament: isTournamentMetadata(metadata)
|
|
260
|
+
? {
|
|
261
|
+
...metadata.tournament,
|
|
262
|
+
contractAddress: contractAddress,
|
|
263
|
+
entryPriceOrFundAmount: dstAmount
|
|
264
|
+
}
|
|
265
|
+
: undefined,
|
|
251
266
|
payload: {
|
|
252
267
|
amount: dstAmount,
|
|
253
268
|
data: encodedData,
|
|
254
269
|
spenderAddress: spenderAddress,
|
|
255
270
|
to: contractAddress,
|
|
256
|
-
action: metadata.action
|
|
271
|
+
action: isCustomTxMetadata(metadata) ? metadata.action : undefined
|
|
257
272
|
}
|
|
258
273
|
};
|
|
259
274
|
if (onramp) {
|
|
@@ -350,9 +365,26 @@ export function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", re
|
|
|
350
365
|
opacity: hasMounted ? 1 : 0,
|
|
351
366
|
y: hasMounted ? 0 : 20,
|
|
352
367
|
filter: hasMounted ? "blur(0px)" : "blur(10px)"
|
|
353
|
-
}, transition: { duration: 0.3, delay: 0.3, ease: "easeInOut" }, className: "flex w-full flex-col gap-2", children: _jsx(ShinyButton, { accentColor: "hsl(var(--as-brand))", textColor: "text-white", disabled: isCreatingOrder || isLoadingAnyspendQuote || !anyspendQuote, onClick: () => handleConfirmOrder(), className: "relative w-full", children: !isAuthenticated ? ("Sign in with B3") : isCreatingOrder ? (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Loader2, { className: "size-4 animate-spin" }), _jsx("span", { children: "Creating order..." })] })) : isLoadingAnyspendQuote ? (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Loader2, { className: "size-4 animate-spin" }), _jsx("span", { children: "Loading quote..." })] })) : anyspendQuote ? (_jsxs(_Fragment, { children: [_jsx("span", { children: "Checkout" }), _jsx(ChevronRightCircle, { className: "absolute right-0 top-1/2 size-6 -translate-y-1/2 opacity-70" })] })) : ("No quote found") }) }) })] }) }), _jsx(TabsContent, { value: "fiat", children: _jsx("div", { className: "mt-6 flex w-full flex-col gap-6", children: _jsx(PanelOnrampPayment, { srcAmountOnRamp: anyspendQuote?.data?.currencyIn?.amountUsd || "0", recipientName: recipientEnsName, recipientAddress: recipientAddress, isMainnet: isMainnet, isBuyMode: false, selectedDstChainId: dstChainId, selectedDstToken: dstToken, anyspendQuote: anyspendQuote, globalAddress: currentWallet?.wallet?.address, onOrderCreated: (orderId) => setOrderId(orderId), onBack: () => setActiveTab("crypto"), orderType: orderType, nft: metadata
|
|
354
|
-
?
|
|
355
|
-
|
|
368
|
+
}, transition: { duration: 0.3, delay: 0.3, ease: "easeInOut" }, className: "flex w-full flex-col gap-2", children: _jsx(ShinyButton, { accentColor: "hsl(var(--as-brand))", textColor: "text-white", disabled: isCreatingOrder || isLoadingAnyspendQuote || !anyspendQuote, onClick: () => handleConfirmOrder(), className: "relative w-full", children: !isAuthenticated ? ("Sign in with B3") : isCreatingOrder ? (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Loader2, { className: "size-4 animate-spin" }), _jsx("span", { children: "Creating order..." })] })) : isLoadingAnyspendQuote ? (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Loader2, { className: "size-4 animate-spin" }), _jsx("span", { children: "Loading quote..." })] })) : anyspendQuote ? (_jsxs(_Fragment, { children: [_jsx("span", { children: "Checkout" }), _jsx(ChevronRightCircle, { className: "absolute right-0 top-1/2 size-6 -translate-y-1/2 opacity-70" })] })) : ("No quote found") }) }) })] }) }), _jsx(TabsContent, { value: "fiat", children: _jsx("div", { className: "mt-6 flex w-full flex-col gap-6", children: _jsx(PanelOnrampPayment, { srcAmountOnRamp: anyspendQuote?.data?.currencyIn?.amountUsd || "0", recipientName: recipientEnsName, recipientAddress: recipientAddress, isMainnet: isMainnet, isBuyMode: false, selectedDstChainId: dstChainId, selectedDstToken: dstToken, anyspendQuote: anyspendQuote, globalAddress: currentWallet?.wallet?.address, onOrderCreated: (orderId) => setOrderId(orderId), onBack: () => setActiveTab("crypto"), orderType: orderType, nft: isNftMetadata(metadata)
|
|
369
|
+
? metadata.nftContract.type === NftType.ERC1155
|
|
370
|
+
? {
|
|
371
|
+
type: NftType.ERC1155,
|
|
372
|
+
contractAddress: metadata.nftContract.contractAddress,
|
|
373
|
+
tokenId: metadata.nftContract.tokenId,
|
|
374
|
+
imageUrl: metadata.nftContract.imageUrl,
|
|
375
|
+
name: metadata.nftContract.name,
|
|
376
|
+
description: metadata.nftContract.description,
|
|
377
|
+
price: dstAmount
|
|
378
|
+
}
|
|
379
|
+
: {
|
|
380
|
+
type: NftType.ERC721,
|
|
381
|
+
contractAddress: metadata.nftContract.contractAddress,
|
|
382
|
+
name: metadata.nftContract.name,
|
|
383
|
+
description: metadata.nftContract.description,
|
|
384
|
+
imageUrl: metadata.nftContract.imageUrl,
|
|
385
|
+
price: dstAmount
|
|
386
|
+
}
|
|
387
|
+
: undefined, payload: isCustomTxMetadata(metadata)
|
|
356
388
|
? {
|
|
357
389
|
...metadata,
|
|
358
390
|
amount: dstAmount,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { NftContract } from "../../../anyspend/types";
|
|
2
|
-
export declare function AnySpendNFT({ isMainnet, loadOrder, mode, recipientAddress, nftContract }: {
|
|
2
|
+
export declare function AnySpendNFT({ isMainnet, loadOrder, mode, recipientAddress, nftContract, onSuccess }: {
|
|
3
3
|
isMainnet?: boolean;
|
|
4
4
|
loadOrder?: string;
|
|
5
5
|
mode?: "modal" | "page";
|
|
6
6
|
recipientAddress?: string;
|
|
7
|
-
nftContract
|
|
7
|
+
nftContract: NftContract;
|
|
8
|
+
onSuccess?: (txHash?: string) => void;
|
|
8
9
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { ALL_CHAINS, getChainName, getExplorerAddressUrl, OrderType } from "../../../anyspend/index.js";
|
|
3
|
-
import { DEFAULT_NFT_CONTRACT } from "../../../anyspend/constants/index.js";
|
|
4
3
|
import { GlareCard, Popover, PopoverContent, PopoverTrigger } from "../../../global-account/react/index.js";
|
|
5
4
|
import { cn } from "../../../shared/utils/index.js";
|
|
6
5
|
import { getIpfsUrl } from "../../../shared/utils/ipfs.js";
|
|
@@ -10,11 +9,14 @@ import { MoreVertical } from "lucide-react";
|
|
|
10
9
|
import { useState } from "react";
|
|
11
10
|
import { b3 } from "viem/chains";
|
|
12
11
|
import { AnySpendCustom } from "./AnySpendCustom.js";
|
|
13
|
-
export function AnySpendNFT({ isMainnet = true, loadOrder, mode = "modal", recipientAddress, nftContract
|
|
12
|
+
export function AnySpendNFT({ isMainnet = true, loadOrder, mode = "modal", recipientAddress, nftContract, onSuccess }) {
|
|
14
13
|
const header = ({ anyspendPrice, isLoadingAnyspendPrice }) => (_jsxs(_Fragment, { children: [_jsxs("div", { className: "relative size-[200px]", children: [_jsx("div", { className: "absolute inset-0 scale-95 bg-black/30 blur-md" }), _jsxs(GlareCard, { className: "overflow-hidden", children: [_jsx("img", { src: getIpfsUrl(nftContract.imageUrl), alt: nftContract.name, className: "size-full object-cover" }), _jsx("div", { className: "absolute inset-0 rounded-xl border border-white/10" })] }), _jsx(DropdownMenu, { nftContract: nftContract })] }), _jsxs("div", { className: "from-b3-react-background to-as-on-surface-1 mt-[-100px] w-full rounded-t-lg bg-gradient-to-t", children: [_jsx("div", { className: "h-[100px] w-full" }), _jsxs("div", { className: "mb-1 flex w-full flex-col items-center gap-2 p-5", children: [_jsx("span", { className: "font-sf-rounded text-2xl font-semibold", children: nftContract.name }), _jsx("div", { className: "flex w-fit items-center gap-1", children: anyspendPrice ? (_jsx(AnimatePresence, { mode: "wait", children: _jsx("div", { className: cn("text-as-primary group flex items-center text-3xl font-semibold transition-all", {
|
|
15
14
|
"opacity-0": isLoadingAnyspendPrice
|
|
16
15
|
}), children: formatDisplayNumber(anyspendPrice?.data?.currencyIn?.amountUsd, { style: "currency" }) }) })) : (_jsx("div", { className: "h-[36px] w-full" })) })] })] })] }));
|
|
17
|
-
return (_jsx(AnySpendCustom, { isMainnet: isMainnet, loadOrder: loadOrder, mode: mode, recipientAddress: recipientAddress, orderType: OrderType.MintNFT, dstChainId: nftContract.chainId, dstToken: nftContract.currency, dstAmount: nftContract.price, contractAddress: nftContract.contractAddress, encodedData: "0x", metadata: {
|
|
16
|
+
return (_jsx(AnySpendCustom, { isMainnet: isMainnet, loadOrder: loadOrder, mode: mode, recipientAddress: recipientAddress, orderType: OrderType.MintNFT, dstChainId: nftContract.chainId, dstToken: nftContract.currency, dstAmount: nftContract.price, contractAddress: nftContract.contractAddress, encodedData: "0x", metadata: {
|
|
17
|
+
type: OrderType.MintNFT,
|
|
18
|
+
nftContract: nftContract
|
|
19
|
+
}, header: header, onSuccess: onSuccess }));
|
|
18
20
|
}
|
|
19
21
|
function DropdownMenu({ nftContract }) {
|
|
20
22
|
const [open, setOpen] = useState(false);
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { ABI_ERC20_STAKING, B3_TOKEN, OrderType } from "../../../anyspend/index.js";
|
|
3
|
-
import {
|
|
4
|
-
import { SolIcon } from "./icons/SolIcon.js";
|
|
5
|
-
import { UsdcIcon } from "./icons/USDCIcon.js";
|
|
6
|
-
import { Button, GlareCardRounded, Input, TextLoop, useHasMounted, useModalStore, useChainSwitchWithAction, useTokenBalance, StyleRoot } from "../../../global-account/react/index.js";
|
|
3
|
+
import { Button, GlareCardRounded, Input, StyleRoot, TextLoop, useChainSwitchWithAction, useHasMounted, useModalStore, useTokenBalance } from "../../../global-account/react/index.js";
|
|
7
4
|
import { formatTokenAmount } from "../../../shared/utils/number.js";
|
|
8
5
|
import { motion } from "framer-motion";
|
|
9
6
|
import invariant from "invariant";
|
|
@@ -14,6 +11,9 @@ import { createPublicClient, encodeFunctionData, erc20Abi, http } from "viem";
|
|
|
14
11
|
import { base } from "viem/chains";
|
|
15
12
|
import { useAccount, useWaitForTransactionReceipt, useWriteContract } from "wagmi";
|
|
16
13
|
import { AnySpendCustom } from "./AnySpendCustom.js";
|
|
14
|
+
import { EthIcon } from "./icons/EthIcon.js";
|
|
15
|
+
import { SolIcon } from "./icons/SolIcon.js";
|
|
16
|
+
import { UsdcIcon } from "./icons/USDCIcon.js";
|
|
17
17
|
const basePublicClient = createPublicClient({
|
|
18
18
|
chain: base,
|
|
19
19
|
transport: http()
|
|
@@ -250,6 +250,7 @@ export function AnySpendStakeB3({ isMainnet = true, loadOrder, mode = "modal", r
|
|
|
250
250
|
}
|
|
251
251
|
const encodedData = generateEncodedDataForStakingB3(userStakeAmount, recipientAddress);
|
|
252
252
|
return (_jsx(AnySpendCustom, { isMainnet: isMainnet, loadOrder: loadOrder, mode: mode, recipientAddress: recipientAddress, orderType: OrderType.Custom, dstChainId: base.id, dstToken: B3_TOKEN, dstAmount: userStakeAmount, contractAddress: ERC20Staking, encodedData: encodedData, metadata: {
|
|
253
|
+
type: OrderType.Custom,
|
|
253
254
|
action: "stake B3"
|
|
254
255
|
}, header: header, onSuccess: onSuccess, showRecipient: true }));
|
|
255
256
|
}
|
|
@@ -11,5 +11,8 @@ export function AnySpendTournament(props) {
|
|
|
11
11
|
const header = ({ anyspendPrice, isLoadingAnyspendPrice }) => (_jsxs(_Fragment, { children: [_jsx("div", { className: "z-10 mt-[-100px] flex h-[270px] w-full items-end justify-center", children: _jsx("img", { src: "https://cdn.b3.fun/tournament-play.svg", alt: "Tournament Play", className: "h-[200px] w-[360px] object-cover object-center" }) }), _jsxs("div", { className: "from-b3-react-background to-as-on-surface-1 mt-[-100px] w-full rounded-t-lg bg-gradient-to-t", children: [_jsx("div", { className: "h-[100px] w-full" }), _jsxs("div", { className: "flex w-full flex-col items-center gap-1 p-6 pt-0", children: [_jsxs("span", { className: "font-sf-rounded text-center text-lg font-semibold", children: [action === "join" ? "Pay entry fee to join " : "Pay to fund ", " ", tournamentMetadata.name] }), _jsx("div", { className: "mt-2 flex w-fit items-center gap-1", children: anyspendPrice ? (_jsx(AnimatePresence, { mode: "wait", children: _jsxs("div", { className: cn("text-as-primary group flex items-center text-2xl font-semibold transition-all", {
|
|
12
12
|
"opacity-0": isLoadingAnyspendPrice
|
|
13
13
|
}), children: [formatDisplayNumber(anyspendPrice?.data?.currencyIn?.amountUsd, { style: "currency" }), " (", formatTokenAmount(BigInt(dstAmount), dstToken.decimals, 6, true), " ", dstToken.symbol, ")"] }) })) : (_jsx("div", { className: "h-[32px] w-full" })) })] })] })] }));
|
|
14
|
-
return (_jsx(AnySpendCustom, { isMainnet: isMainnet, loadOrder: loadOrder, mode: mode, recipientAddress: action === "join" ? props.joinFor : undefined, orderType: action === "join" ? OrderType.JoinTournament : OrderType.FundTournament, dstChainId: tournamentChainId, dstToken: dstToken, dstAmount: dstAmount, contractAddress: tournamentContractAddress, encodedData: "0x", metadata: {
|
|
14
|
+
return (_jsx(AnySpendCustom, { isMainnet: isMainnet, loadOrder: loadOrder, mode: mode, recipientAddress: action === "join" ? props.joinFor : undefined, orderType: action === "join" ? OrderType.JoinTournament : OrderType.FundTournament, dstChainId: tournamentChainId, dstToken: dstToken, dstAmount: dstAmount, contractAddress: tournamentContractAddress, encodedData: "0x", metadata: {
|
|
15
|
+
type: action === "join" ? OrderType.JoinTournament : OrderType.FundTournament,
|
|
16
|
+
tournament: tournamentMetadata
|
|
17
|
+
}, header: header, onSuccess: onSuccess, showRecipient: action === "join" }));
|
|
15
18
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { GetOrderAndTxsResponse, GetQuoteRequest, GetQuoteResponse, SendPermitDataRequestBody, Token } from "../../anyspend/types";
|
|
2
1
|
import { OnrampOptions } from "../../anyspend/react";
|
|
2
|
+
import { GetOrderAndTxsResponse, GetQuoteRequest, GetQuoteResponse, SendPermitDataRequestBody, Token } from "../../anyspend/types";
|
|
3
3
|
export declare const anyspendService: {
|
|
4
4
|
getTokenList: (isMainnet: boolean, chainId: number, query: string) => Promise<Token[]>;
|
|
5
5
|
getToken: (isMainnet: boolean, chainId: number, tokenAddress: string) => Promise<Token>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { ANYSPEND_MAINNET_BASE_URL, ANYSPEND_TESTNET_BASE_URL } from "../../anyspend/constants/index.js";
|
|
1
2
|
import { zGetCoinbaseOnrampOptionsResponse, zGetOrderAndTxsResponse, zGetOrderHistoryResponse, zGetTokenListResponse } from "../../anyspend/types/index.js";
|
|
2
3
|
import { getNativeToken, isNativeToken } from "../../anyspend/utils/index.js";
|
|
3
4
|
import invariant from "invariant";
|
|
4
|
-
import { ANYSPEND_MAINNET_BASE_URL, ANYSPEND_TESTNET_BASE_URL } from "../../anyspend/constants/index.js";
|
|
5
5
|
// Service functions
|
|
6
6
|
export const anyspendService = {
|
|
7
7
|
getTokenList: async (isMainnet, chainId, query) => {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { NftContract } from "./nft";
|
|
2
|
+
import { OrderType } from "./order";
|
|
3
|
+
export type BaseMetadata = {
|
|
4
|
+
type: OrderType;
|
|
5
|
+
};
|
|
6
|
+
export type NftMetadata = BaseMetadata & {
|
|
7
|
+
type: OrderType.MintNFT;
|
|
8
|
+
nftContract: NftContract;
|
|
9
|
+
};
|
|
10
|
+
export type TournamentMetadata = BaseMetadata & {
|
|
11
|
+
type: OrderType.JoinTournament | OrderType.FundTournament;
|
|
12
|
+
tournament: {
|
|
13
|
+
slug: string;
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
imageUrl: string;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export type CustomTxMetadata = BaseMetadata & {
|
|
20
|
+
type: OrderType.Custom;
|
|
21
|
+
action: string;
|
|
22
|
+
};
|
|
23
|
+
export type AnySpendMetadata = NftMetadata | TournamentMetadata | CustomTxMetadata;
|
|
24
|
+
export declare function isNftMetadata(metadata: AnySpendMetadata): metadata is NftMetadata;
|
|
25
|
+
export declare function isTournamentMetadata(metadata: AnySpendMetadata): metadata is TournamentMetadata;
|
|
26
|
+
export declare function isCustomTxMetadata(metadata: AnySpendMetadata): metadata is CustomTxMetadata;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { OrderType } from "./order.js";
|
|
2
|
+
// Type guard functions
|
|
3
|
+
export function isNftMetadata(metadata) {
|
|
4
|
+
return metadata.type === OrderType.MintNFT;
|
|
5
|
+
}
|
|
6
|
+
export function isTournamentMetadata(metadata) {
|
|
7
|
+
return metadata.type === OrderType.JoinTournament || metadata.type === OrderType.FundTournament;
|
|
8
|
+
}
|
|
9
|
+
export function isCustomTxMetadata(metadata) {
|
|
10
|
+
return metadata.type === OrderType.Custom;
|
|
11
|
+
}
|