@b3dotfun/sdk 0.0.7-alpha.7 → 0.0.7-alpha.9
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 +80 -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/cjs/global-account/react/stores/useModalStore.d.ts +2 -0
- 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 +57 -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/esm/global-account/react/stores/useModalStore.d.ts +2 -0
- 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/dist/types/global-account/react/stores/useModalStore.d.ts +2 -0
- 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 +73 -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
- package/src/global-account/react/stores/useModalStore.ts +2 -0
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ANYSPEND_MAINNET_BASE_URL, ANYSPEND_TESTNET_BASE_URL } from "@b3dotfun/sdk/anyspend/constants";
|
|
2
|
+
import { OnrampOptions } from "@b3dotfun/sdk/anyspend/react";
|
|
1
3
|
import {
|
|
2
4
|
GetOrderAndTxsResponse,
|
|
3
5
|
GetQuoteRequest,
|
|
@@ -11,8 +13,6 @@ import {
|
|
|
11
13
|
} from "@b3dotfun/sdk/anyspend/types";
|
|
12
14
|
import { getNativeToken, isNativeToken } from "@b3dotfun/sdk/anyspend/utils";
|
|
13
15
|
import invariant from "invariant";
|
|
14
|
-
import { ANYSPEND_MAINNET_BASE_URL, ANYSPEND_TESTNET_BASE_URL } from "@b3dotfun/sdk/anyspend/constants";
|
|
15
|
-
import { OnrampOptions } from "@b3dotfun/sdk/anyspend/react";
|
|
16
16
|
|
|
17
17
|
// Service functions
|
|
18
18
|
export const anyspendService = {
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { NftContract } from "./nft";
|
|
2
|
+
import { OrderType } from "./order";
|
|
3
|
+
|
|
4
|
+
export type BaseMetadata = {
|
|
5
|
+
type: OrderType;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export type NftMetadata = BaseMetadata & {
|
|
9
|
+
type: OrderType.MintNFT;
|
|
10
|
+
nftContract: NftContract;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type TournamentMetadata = BaseMetadata & {
|
|
14
|
+
type: OrderType.JoinTournament | OrderType.FundTournament;
|
|
15
|
+
tournament: {
|
|
16
|
+
slug: string;
|
|
17
|
+
name: string;
|
|
18
|
+
description: string;
|
|
19
|
+
imageUrl: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type CustomTxMetadata = BaseMetadata & {
|
|
24
|
+
type: OrderType.Custom;
|
|
25
|
+
action: string;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type AnySpendMetadata = NftMetadata | TournamentMetadata | CustomTxMetadata;
|
|
29
|
+
|
|
30
|
+
// Type guard functions
|
|
31
|
+
export function isNftMetadata(metadata: AnySpendMetadata): metadata is NftMetadata {
|
|
32
|
+
return metadata.type === OrderType.MintNFT;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function isTournamentMetadata(metadata: AnySpendMetadata): metadata is TournamentMetadata {
|
|
36
|
+
return metadata.type === OrderType.JoinTournament || metadata.type === OrderType.FundTournament;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function isCustomTxMetadata(metadata: AnySpendMetadata): metadata is CustomTxMetadata {
|
|
40
|
+
return metadata.type === OrderType.Custom;
|
|
41
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { QuoteDetails } from "@reservoir0x/relay-sdk";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
|
|
4
|
+
import { zCustomPayload } from "../custom";
|
|
5
|
+
import { NftType } from "../nft";
|
|
4
6
|
import { OrderType } from "../order";
|
|
5
7
|
import { TradeType } from "../relay";
|
|
6
|
-
import { zCustomPayload } from "../custom";
|
|
7
8
|
|
|
8
9
|
const zGetQuoteBody = z.object({
|
|
9
10
|
srcChain: z.number(),
|
|
@@ -21,6 +22,8 @@ const zGetQuoteForSwapOrderBody = zGetQuoteBody.extend({
|
|
|
21
22
|
const zGetQuoteForMintNftOrderBody = zGetQuoteBody.extend({
|
|
22
23
|
type: z.literal(OrderType.MintNFT),
|
|
23
24
|
contractAddress: z.string(),
|
|
25
|
+
tokenId: z.number().nullable(),
|
|
26
|
+
contractType: z.nativeEnum(NftType),
|
|
24
27
|
price: z.string()
|
|
25
28
|
});
|
|
26
29
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Nft, OrderType, Token, Tournament } from "@b3dotfun/sdk/anyspend/types";
|
|
1
|
+
import { Nft, NftType, OrderType, Token, Tournament } from "@b3dotfun/sdk/anyspend/types";
|
|
2
2
|
import { normalizeAddress } from "@b3dotfun/sdk/anyspend/utils";
|
|
3
3
|
|
|
4
4
|
export type OrderParams = {
|
|
@@ -20,10 +20,22 @@ export const buildPayload = (orderType: OrderType, params: OrderParams) => {
|
|
|
20
20
|
actualDstAmount: null
|
|
21
21
|
};
|
|
22
22
|
case OrderType.MintNFT:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
if (nft?.type === NftType.ERC1155) {
|
|
24
|
+
return {
|
|
25
|
+
contractAddress: normalizeAddress(nft.contractAddress),
|
|
26
|
+
nftPrice: nft?.price || "",
|
|
27
|
+
tokenId: nft?.tokenId!,
|
|
28
|
+
contractType: nft?.type
|
|
29
|
+
};
|
|
30
|
+
} else if (nft?.type === NftType.ERC721) {
|
|
31
|
+
return {
|
|
32
|
+
contractAddress: normalizeAddress(nft.contractAddress),
|
|
33
|
+
nftPrice: nft?.price || "",
|
|
34
|
+
contractType: nft?.type
|
|
35
|
+
};
|
|
36
|
+
} else {
|
|
37
|
+
throw new Error(`Invalid nft payload: ${JSON.stringify(nft)}`);
|
|
38
|
+
}
|
|
27
39
|
case OrderType.JoinTournament:
|
|
28
40
|
return {
|
|
29
41
|
contractAddress: tournament?.contractAddress,
|
|
@@ -131,6 +131,8 @@ export interface AnySpendNftProps extends BaseModalProps {
|
|
|
131
131
|
nftContract: NftContract;
|
|
132
132
|
/** Recipient address to receive the NFT */
|
|
133
133
|
recipientAddress?: string;
|
|
134
|
+
/** Callback function called when the NFT is successfully transferred */
|
|
135
|
+
onSuccess?: () => void;
|
|
134
136
|
}
|
|
135
137
|
|
|
136
138
|
/**
|