@b3dotfun/sdk 0.0.49-alpha.1 → 0.0.49-alpha.11
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.d.ts +1 -0
- package/dist/cjs/anyspend/constants/index.js +12 -2
- package/dist/cjs/anyspend/react/components/AnySpend.js +10 -1
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +1 -1
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.js +15 -9
- package/dist/cjs/anyspend/react/components/common/FeeDetailPanel.js +2 -2
- package/dist/cjs/anyspend/react/components/common/OrderDetails.d.ts +1 -0
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +6 -6
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.d.ts +1 -0
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.js +3 -2
- package/dist/cjs/anyspend/react/components/common/OrderToken.js +1 -1
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.js +1 -1
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmountFiat.js +1 -1
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmountNew.js +1 -1
- package/dist/cjs/anyspend/react/contexts/FeatureFlagsContext.js +1 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +24 -12
- package/dist/cjs/anyspend/types/api.d.ts +14 -2
- package/dist/cjs/anyspend/utils/chain.js +4 -4
- package/dist/cjs/bondkit/bondkitToken.d.ts +3 -1
- package/dist/cjs/bondkit/bondkitToken.js +19 -0
- package/dist/cjs/bondkit/components/TradingView.d.ts +1 -1
- package/dist/cjs/bondkit/components/TradingView.js +14 -3
- package/dist/cjs/bondkit/components/index.d.ts +1 -1
- package/dist/cjs/bondkit/components/index.js +1 -1
- package/dist/cjs/bondkit/components/types.d.ts +1 -0
- package/dist/cjs/bondkit/config.d.ts +1 -0
- package/dist/cjs/bondkit/config.js +1 -0
- package/dist/cjs/bondkit/index.d.ts +1 -1
- package/dist/cjs/bondkit/index.js +2 -6
- package/dist/cjs/bondkit/types.d.ts +15 -0
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +1 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +1 -1
- package/dist/cjs/global-account/react/components/B3Provider/RelayKitProviderWrapper.js +2 -2
- package/dist/cjs/shared/generated/chain-networks.json +40 -7
- package/dist/esm/anyspend/constants/index.d.ts +1 -0
- package/dist/esm/anyspend/constants/index.js +11 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +10 -1
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +1 -1
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.js +15 -9
- package/dist/esm/anyspend/react/components/common/FeeDetailPanel.js +2 -2
- package/dist/esm/anyspend/react/components/common/OrderDetails.d.ts +1 -0
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +6 -6
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.d.ts +1 -0
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.js +4 -3
- package/dist/esm/anyspend/react/components/common/OrderToken.js +1 -1
- package/dist/esm/anyspend/react/components/common/OrderTokenAmount.js +1 -1
- package/dist/esm/anyspend/react/components/common/OrderTokenAmountFiat.js +1 -1
- package/dist/esm/anyspend/react/components/common/OrderTokenAmountNew.js +1 -1
- package/dist/esm/anyspend/react/contexts/FeatureFlagsContext.js +1 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +24 -12
- package/dist/esm/anyspend/types/api.d.ts +14 -2
- package/dist/esm/anyspend/utils/chain.js +4 -4
- package/dist/esm/bondkit/bondkitToken.d.ts +3 -1
- package/dist/esm/bondkit/bondkitToken.js +19 -0
- package/dist/esm/bondkit/components/TradingView.d.ts +1 -1
- package/dist/esm/bondkit/components/TradingView.js +14 -3
- package/dist/esm/bondkit/components/index.d.ts +1 -1
- package/dist/esm/bondkit/components/index.js +1 -1
- package/dist/esm/bondkit/components/types.d.ts +1 -0
- package/dist/esm/bondkit/config.d.ts +1 -0
- package/dist/esm/bondkit/config.js +1 -0
- package/dist/esm/bondkit/index.d.ts +1 -1
- package/dist/esm/bondkit/index.js +1 -1
- package/dist/esm/bondkit/types.d.ts +15 -0
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +1 -1
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +1 -1
- package/dist/esm/global-account/react/components/B3Provider/RelayKitProviderWrapper.js +2 -2
- package/dist/esm/shared/generated/chain-networks.json +40 -7
- package/dist/types/anyspend/constants/index.d.ts +1 -0
- package/dist/types/anyspend/react/components/common/OrderDetails.d.ts +1 -0
- package/dist/types/anyspend/react/components/common/OrderDetailsCollapsible.d.ts +1 -0
- package/dist/types/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +24 -12
- package/dist/types/anyspend/types/api.d.ts +14 -2
- package/dist/types/bondkit/bondkitToken.d.ts +3 -1
- package/dist/types/bondkit/components/TradingView.d.ts +1 -1
- package/dist/types/bondkit/components/index.d.ts +1 -1
- package/dist/types/bondkit/components/types.d.ts +1 -0
- package/dist/types/bondkit/config.d.ts +1 -0
- package/dist/types/bondkit/index.d.ts +1 -1
- package/dist/types/bondkit/types.d.ts +15 -0
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +1 -1
- package/package.json +3 -3
- package/src/anyspend/constants/index.ts +12 -1
- package/src/anyspend/react/components/AnySpend.tsx +13 -0
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +1 -0
- package/src/anyspend/react/components/common/CryptoReceiveSection.tsx +17 -9
- package/src/anyspend/react/components/common/FeeDetailPanel.tsx +33 -6
- package/src/anyspend/react/components/common/OrderDetails.tsx +7 -0
- package/src/anyspend/react/components/common/OrderDetailsCollapsible.tsx +16 -0
- package/src/anyspend/react/components/common/OrderToken.tsx +1 -1
- package/src/anyspend/react/components/common/OrderTokenAmount.tsx +1 -1
- package/src/anyspend/react/components/common/OrderTokenAmountFiat.tsx +1 -1
- package/src/anyspend/react/components/common/OrderTokenAmountNew.tsx +1 -1
- package/src/anyspend/react/contexts/FeatureFlagsContext.tsx +2 -2
- package/src/anyspend/types/api.ts +14 -2
- package/src/anyspend/utils/chain.ts +4 -4
- package/src/bondkit/bondkitToken.ts +24 -0
- package/src/bondkit/components/TradingView.tsx +15 -3
- package/src/bondkit/components/index.ts +1 -1
- package/src/bondkit/components/types.ts +1 -0
- package/src/bondkit/config.ts +2 -0
- package/src/bondkit/index.ts +1 -1
- package/src/bondkit/types.ts +19 -0
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +1 -1
- package/src/global-account/react/components/B3Provider/RelayKitProviderWrapper.tsx +2 -2
- package/src/shared/generated/chain-networks.json +40 -7
|
@@ -20,7 +20,8 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
|
|
|
20
20
|
oneClickBuyUrl: string | null;
|
|
21
21
|
stripePaymentIntentId: string | null;
|
|
22
22
|
settlement: {
|
|
23
|
-
actualDstAmount
|
|
23
|
+
actualDstAmount?: string;
|
|
24
|
+
relay?: Record<string, never>;
|
|
24
25
|
} | null;
|
|
25
26
|
fee?: Omit<import("../..").components["schemas"]["Fee"], "type"> | null;
|
|
26
27
|
} & {
|
|
@@ -48,7 +49,8 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
|
|
|
48
49
|
oneClickBuyUrl: string | null;
|
|
49
50
|
stripePaymentIntentId: string | null;
|
|
50
51
|
settlement: {
|
|
51
|
-
actualDstAmount
|
|
52
|
+
actualDstAmount?: string;
|
|
53
|
+
relay?: Record<string, never>;
|
|
52
54
|
} | null;
|
|
53
55
|
fee?: Omit<import("../..").components["schemas"]["Fee"], "type"> | null;
|
|
54
56
|
} & {
|
|
@@ -76,7 +78,8 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
|
|
|
76
78
|
oneClickBuyUrl: string | null;
|
|
77
79
|
stripePaymentIntentId: string | null;
|
|
78
80
|
settlement: {
|
|
79
|
-
actualDstAmount
|
|
81
|
+
actualDstAmount?: string;
|
|
82
|
+
relay?: Record<string, never>;
|
|
80
83
|
} | null;
|
|
81
84
|
fee?: Omit<import("../..").components["schemas"]["Fee"], "type"> | null;
|
|
82
85
|
} & {
|
|
@@ -104,7 +107,8 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
|
|
|
104
107
|
oneClickBuyUrl: string | null;
|
|
105
108
|
stripePaymentIntentId: string | null;
|
|
106
109
|
settlement: {
|
|
107
|
-
actualDstAmount
|
|
110
|
+
actualDstAmount?: string;
|
|
111
|
+
relay?: Record<string, never>;
|
|
108
112
|
} | null;
|
|
109
113
|
fee?: Omit<import("../..").components["schemas"]["Fee"], "type"> | null;
|
|
110
114
|
} & {
|
|
@@ -132,7 +136,8 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
|
|
|
132
136
|
oneClickBuyUrl: string | null;
|
|
133
137
|
stripePaymentIntentId: string | null;
|
|
134
138
|
settlement: {
|
|
135
|
-
actualDstAmount
|
|
139
|
+
actualDstAmount?: string;
|
|
140
|
+
relay?: Record<string, never>;
|
|
136
141
|
} | null;
|
|
137
142
|
fee?: Omit<import("../..").components["schemas"]["Fee"], "type"> | null;
|
|
138
143
|
} & {
|
|
@@ -160,7 +165,8 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
|
|
|
160
165
|
oneClickBuyUrl: string | null;
|
|
161
166
|
stripePaymentIntentId: string | null;
|
|
162
167
|
settlement: {
|
|
163
|
-
actualDstAmount
|
|
168
|
+
actualDstAmount?: string;
|
|
169
|
+
relay?: Record<string, never>;
|
|
164
170
|
} | null;
|
|
165
171
|
fee?: Omit<import("../..").components["schemas"]["Fee"], "type"> | null;
|
|
166
172
|
} & {
|
|
@@ -191,7 +197,8 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
|
|
|
191
197
|
oneClickBuyUrl: string | null;
|
|
192
198
|
stripePaymentIntentId: string | null;
|
|
193
199
|
settlement: {
|
|
194
|
-
actualDstAmount
|
|
200
|
+
actualDstAmount?: string;
|
|
201
|
+
relay?: Record<string, never>;
|
|
195
202
|
} | null;
|
|
196
203
|
fee?: Omit<import("../..").components["schemas"]["Fee"], "type"> | null;
|
|
197
204
|
} & {
|
|
@@ -219,7 +226,8 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
|
|
|
219
226
|
oneClickBuyUrl: string | null;
|
|
220
227
|
stripePaymentIntentId: string | null;
|
|
221
228
|
settlement: {
|
|
222
|
-
actualDstAmount
|
|
229
|
+
actualDstAmount?: string;
|
|
230
|
+
relay?: Record<string, never>;
|
|
223
231
|
} | null;
|
|
224
232
|
fee?: Omit<import("../..").components["schemas"]["Fee"], "type"> | null;
|
|
225
233
|
} & {
|
|
@@ -247,7 +255,8 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
|
|
|
247
255
|
oneClickBuyUrl: string | null;
|
|
248
256
|
stripePaymentIntentId: string | null;
|
|
249
257
|
settlement: {
|
|
250
|
-
actualDstAmount
|
|
258
|
+
actualDstAmount?: string;
|
|
259
|
+
relay?: Record<string, never>;
|
|
251
260
|
} | null;
|
|
252
261
|
fee?: Omit<import("../..").components["schemas"]["Fee"], "type"> | null;
|
|
253
262
|
} & {
|
|
@@ -275,7 +284,8 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
|
|
|
275
284
|
oneClickBuyUrl: string | null;
|
|
276
285
|
stripePaymentIntentId: string | null;
|
|
277
286
|
settlement: {
|
|
278
|
-
actualDstAmount
|
|
287
|
+
actualDstAmount?: string;
|
|
288
|
+
relay?: Record<string, never>;
|
|
279
289
|
} | null;
|
|
280
290
|
fee?: Omit<import("../..").components["schemas"]["Fee"], "type"> | null;
|
|
281
291
|
} & {
|
|
@@ -303,7 +313,8 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
|
|
|
303
313
|
oneClickBuyUrl: string | null;
|
|
304
314
|
stripePaymentIntentId: string | null;
|
|
305
315
|
settlement: {
|
|
306
|
-
actualDstAmount
|
|
316
|
+
actualDstAmount?: string;
|
|
317
|
+
relay?: Record<string, never>;
|
|
307
318
|
} | null;
|
|
308
319
|
fee?: Omit<import("../..").components["schemas"]["Fee"], "type"> | null;
|
|
309
320
|
} & {
|
|
@@ -331,7 +342,8 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
|
|
|
331
342
|
oneClickBuyUrl: string | null;
|
|
332
343
|
stripePaymentIntentId: string | null;
|
|
333
344
|
settlement: {
|
|
334
|
-
actualDstAmount
|
|
345
|
+
actualDstAmount?: string;
|
|
346
|
+
relay?: Record<string, never>;
|
|
335
347
|
} | null;
|
|
336
348
|
fee?: Omit<import("../..").components["schemas"]["Fee"], "type"> | null;
|
|
337
349
|
} & {
|
|
@@ -1317,10 +1317,22 @@ export interface components {
|
|
|
1317
1317
|
/** @description Settlement information for executed orders */
|
|
1318
1318
|
settlement: {
|
|
1319
1319
|
/**
|
|
1320
|
-
* @description Actual received amount after execution
|
|
1320
|
+
* @description Actual received amount after execution (only for swap/hypeduel orders). Optional - only present for swap/hypeduel orders.
|
|
1321
1321
|
* @example 990000
|
|
1322
1322
|
*/
|
|
1323
|
-
actualDstAmount
|
|
1323
|
+
actualDstAmount?: string;
|
|
1324
|
+
/**
|
|
1325
|
+
* @description Complete relay API response data. Contains transaction details, state changes, fees, and execution status. Optional - can be backfilled by querying Relay API /requests/v2 endpoint.
|
|
1326
|
+
* @example {
|
|
1327
|
+
* "status": "success",
|
|
1328
|
+
* "metadata": {
|
|
1329
|
+
* "currencyOut": {
|
|
1330
|
+
* "amount": "990000"
|
|
1331
|
+
* }
|
|
1332
|
+
* }
|
|
1333
|
+
* }
|
|
1334
|
+
*/
|
|
1335
|
+
relay?: Record<string, never>;
|
|
1324
1336
|
} | null;
|
|
1325
1337
|
/** @description Fee structure for the order including Stripe and AnySpend fees */
|
|
1326
1338
|
fee?: Omit<components["schemas"]["Fee"], "type"> | null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Address, EIP1193Provider, GetContractReturnType, Hex, PublicClient, WalletClient } from "viem";
|
|
2
2
|
import { BondkitTokenABI } from "./abis";
|
|
3
|
-
import type { BondkitTokenInitializationConfig, GetTransactionHistoryOptions, SwapQuote, TokenDetails, TransactionResponse } from "./types";
|
|
3
|
+
import type { BondkitTokenInitializationConfig, GetTransactionHistoryOptions, MarketCapChartResponse, SwapQuote, TokenDetails, TransactionResponse } from "./types";
|
|
4
4
|
import { TokenStatus } from "./types";
|
|
5
5
|
type ExecuteWriteOptions = {
|
|
6
6
|
value?: bigint;
|
|
@@ -16,6 +16,7 @@ export declare class BondkitToken {
|
|
|
16
16
|
private walletKey?;
|
|
17
17
|
private rpcUrl;
|
|
18
18
|
private apiEndpoint;
|
|
19
|
+
private chartApiEndpoint;
|
|
19
20
|
private walletClientInstance;
|
|
20
21
|
private connectedProvider?;
|
|
21
22
|
private tradingToken?;
|
|
@@ -56,6 +57,7 @@ export declare class BondkitToken {
|
|
|
56
57
|
threshold: number;
|
|
57
58
|
} | undefined>;
|
|
58
59
|
getTransactionHistory(options?: GetTransactionHistoryOptions): Promise<TransactionResponse | undefined>;
|
|
60
|
+
getMarketCapChartData(): Promise<MarketCapChartResponse | undefined>;
|
|
59
61
|
private executeWrite;
|
|
60
62
|
/** Helper method to wait for transaction confirmation with OKX wallet fallback */
|
|
61
63
|
waitForTransaction(hash: Hex): Promise<import("viem").TransactionReceipt>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { TradingViewProps } from "./types";
|
|
2
|
-
declare const TradingView: ({ className, tokenAddress, tokenSymbol }: TradingViewProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
declare const TradingView: ({ className, tokenAddress, tokenSymbol, chainId }: TradingViewProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default TradingView;
|
|
@@ -86,3 +86,18 @@ export interface SwapQuote {
|
|
|
86
86
|
executionPrice: string;
|
|
87
87
|
fee: string;
|
|
88
88
|
}
|
|
89
|
+
export interface MarketCapDataPoint {
|
|
90
|
+
time: string;
|
|
91
|
+
value: string;
|
|
92
|
+
}
|
|
93
|
+
export interface TokenInfo {
|
|
94
|
+
contractAddress: string;
|
|
95
|
+
chainId: number;
|
|
96
|
+
name: string;
|
|
97
|
+
symbol: string;
|
|
98
|
+
found: boolean;
|
|
99
|
+
}
|
|
100
|
+
export interface MarketCapChartResponse {
|
|
101
|
+
tokenInfo: TokenInfo;
|
|
102
|
+
data: MarketCapDataPoint[];
|
|
103
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PermissionsConfig } from "@b3dotfun/sdk/global-account/types/permissions";
|
|
2
|
-
import "@
|
|
2
|
+
import "@relayprotocol/relay-kit-ui/styles.css";
|
|
3
3
|
import { Account } from "thirdweb/wallets";
|
|
4
4
|
import { ClientType } from "../../../client-manager";
|
|
5
5
|
import { B3ContextType } from "./types";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@b3dotfun/sdk",
|
|
3
|
-
"version": "0.0.49-alpha.
|
|
3
|
+
"version": "0.0.49-alpha.11",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"react-native": "./dist/cjs/index.native.js",
|
|
@@ -295,8 +295,8 @@
|
|
|
295
295
|
"@radix-ui/react-slot": "1.1.2",
|
|
296
296
|
"@radix-ui/react-tabs": "1.1.3",
|
|
297
297
|
"@radix-ui/react-tooltip": "1.1.8",
|
|
298
|
-
"@
|
|
299
|
-
"@
|
|
298
|
+
"@relayprotocol/relay-kit-ui": "5.0.3",
|
|
299
|
+
"@relayprotocol/relay-sdk": "3.0.0",
|
|
300
300
|
"@solana/spl-token": "^0.4.13",
|
|
301
301
|
"@solana/web3.js": "^1.98.2",
|
|
302
302
|
"@stripe/react-stripe-js": "^3.7.0",
|
|
@@ -12,7 +12,7 @@ export const SOLANA_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID = "ATokenGPvbdGVxr1b2hvZ
|
|
|
12
12
|
export const SOLANA_TOKEN_2022_PROGRAM_ID = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
|
|
13
13
|
|
|
14
14
|
export const B3_TOKEN: components["schemas"]["Token"] = {
|
|
15
|
-
chainId:
|
|
15
|
+
chainId: base.id,
|
|
16
16
|
address: "0xb3b32f9f8827d4634fe7d973fa1034ec9fddb3b3",
|
|
17
17
|
decimals: 18,
|
|
18
18
|
name: "B3",
|
|
@@ -22,6 +22,17 @@ export const B3_TOKEN: components["schemas"]["Token"] = {
|
|
|
22
22
|
},
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
+
export const ANYSPEND_TOKEN: components["schemas"]["Token"] = {
|
|
26
|
+
chainId: base.id,
|
|
27
|
+
address: "0xc17dda248e2d50fc006d8febb5a406dd31972712",
|
|
28
|
+
decimals: 18,
|
|
29
|
+
name: "Anyspend",
|
|
30
|
+
symbol: "ANY",
|
|
31
|
+
metadata: {
|
|
32
|
+
logoURI: "https://cdn.b3.fun/anyspend_64x64.png",
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
25
36
|
export const USDC_BASE: components["schemas"]["Token"] = {
|
|
26
37
|
symbol: "USDC",
|
|
27
38
|
chainId: base.id,
|
|
@@ -609,9 +609,20 @@ function AnySpendInner({
|
|
|
609
609
|
},
|
|
610
610
|
});
|
|
611
611
|
|
|
612
|
+
// Check if it's a same-chain same-token swap
|
|
613
|
+
const isSameChainSameToken = useMemo(() => {
|
|
614
|
+
return (
|
|
615
|
+
activeTab === "crypto" &&
|
|
616
|
+
selectedSrcChainId === selectedDstChainId &&
|
|
617
|
+
selectedSrcToken.address.toLowerCase() === selectedDstToken.address.toLowerCase()
|
|
618
|
+
);
|
|
619
|
+
}, [activeTab, selectedSrcChainId, selectedDstChainId, selectedSrcToken.address, selectedDstToken.address]);
|
|
620
|
+
|
|
612
621
|
// Determine button state and text
|
|
613
622
|
const btnInfo: { text: string; disable: boolean; error: boolean; loading: boolean } = useMemo(() => {
|
|
614
623
|
if (activeInputAmountInWei === "0") return { text: "Enter an amount", disable: true, error: false, loading: false };
|
|
624
|
+
if (isSameChainSameToken)
|
|
625
|
+
return { text: "Select a different token or chain", disable: true, error: false, loading: false };
|
|
615
626
|
if (isLoadingAnyspendQuote) return { text: "Loading quote...", disable: true, error: false, loading: true };
|
|
616
627
|
if (!recipientAddress) return { text: "Select recipient", disable: false, error: false, loading: false };
|
|
617
628
|
if (isCreatingOrder || isCreatingOnrampOrder)
|
|
@@ -648,6 +659,7 @@ function AnySpendInner({
|
|
|
648
659
|
return { text: "Buy", disable: false, error: false, loading: false };
|
|
649
660
|
}, [
|
|
650
661
|
activeInputAmountInWei,
|
|
662
|
+
isSameChainSameToken,
|
|
651
663
|
isLoadingAnyspendQuote,
|
|
652
664
|
recipientAddress,
|
|
653
665
|
isCreatingOrder,
|
|
@@ -905,6 +917,7 @@ function AnySpendInner({
|
|
|
905
917
|
refundTxs={oat.data.refundTxs}
|
|
906
918
|
selectedCryptoPaymentMethod={selectedCryptoPaymentMethod}
|
|
907
919
|
onPaymentMethodChange={setSelectedCryptoPaymentMethod}
|
|
920
|
+
points={oat.data.points || undefined}
|
|
908
921
|
onBack={() => {
|
|
909
922
|
setOrderId(undefined);
|
|
910
923
|
navigateBack();
|
|
@@ -130,7 +130,7 @@ export function CryptoReceiveSection({
|
|
|
130
130
|
(() => {
|
|
131
131
|
const calculatePriceImpact = (inputUsd?: string | number, outputUsd?: string | number) => {
|
|
132
132
|
if (!inputUsd || !outputUsd) {
|
|
133
|
-
return { percentage: "0.00", isNegative: false };
|
|
133
|
+
return { percentage: "0.00", percentageNum: 0, isNegative: false };
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
const input = Number(inputUsd);
|
|
@@ -138,38 +138,46 @@ export function CryptoReceiveSection({
|
|
|
138
138
|
|
|
139
139
|
// Handle edge cases
|
|
140
140
|
if (input === 0 || isNaN(input) || isNaN(output) || input <= output) {
|
|
141
|
-
return { percentage: "0.00", isNegative: false };
|
|
141
|
+
return { percentage: "0.00", percentageNum: 0, isNegative: false };
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
const percentageValue = ((output - input) / input) * 100;
|
|
145
145
|
|
|
146
146
|
// Handle the -0.00% case
|
|
147
147
|
if (percentageValue > -0.005 && percentageValue < 0) {
|
|
148
|
-
return { percentage: "0.00", isNegative: false };
|
|
148
|
+
return { percentage: "0.00", percentageNum: 0, isNegative: false };
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
return {
|
|
152
152
|
percentage: Math.abs(percentageValue).toFixed(2),
|
|
153
|
+
percentageNum: Math.abs(percentageValue),
|
|
153
154
|
isNegative: percentageValue < 0,
|
|
154
155
|
};
|
|
155
156
|
};
|
|
156
157
|
|
|
157
|
-
const { percentage, isNegative } = calculatePriceImpact(
|
|
158
|
+
const { percentage, percentageNum, isNegative } = calculatePriceImpact(
|
|
158
159
|
anyspendQuote.data.currencyIn.amountUsd,
|
|
159
160
|
anyspendQuote.data.currencyOut.amountUsd,
|
|
160
161
|
);
|
|
161
162
|
|
|
162
|
-
//
|
|
163
|
-
const
|
|
163
|
+
// Get the fee percentage if available
|
|
164
|
+
const feePercent = anyspendQuote.data.fee?.finalFeeBps ? anyspendQuote.data.fee.finalFeeBps / 100 : 0;
|
|
164
165
|
|
|
165
|
-
//
|
|
166
|
-
|
|
166
|
+
// Calculate actual slippage (price impact minus fee)
|
|
167
|
+
const actualSlippage = percentageNum - feePercent;
|
|
168
|
+
|
|
169
|
+
// Show warning based on actual slippage, not total impact
|
|
170
|
+
const yellowThreshold = 1; // 1% actual slippage
|
|
171
|
+
const redThreshold = 2; // 2% actual slippage
|
|
172
|
+
|
|
173
|
+
// Don't show if actual slippage is less than yellow threshold
|
|
174
|
+
if (actualSlippage < yellowThreshold) {
|
|
167
175
|
return null;
|
|
168
176
|
}
|
|
169
177
|
|
|
170
178
|
// Using inline style to ensure color displays
|
|
171
179
|
return (
|
|
172
|
-
<span className="ml-2" style={{ color:
|
|
180
|
+
<span className="ml-2" style={{ color: actualSlippage >= redThreshold ? "red" : "#FFD700" }}>
|
|
173
181
|
({isNegative ? "-" : ""}
|
|
174
182
|
{percentage}%)
|
|
175
183
|
</span>
|
|
@@ -114,7 +114,7 @@ export function FeeDetailPanel({ fee, transactionAmountUsd, onBack }: FeeDetailP
|
|
|
114
114
|
)}
|
|
115
115
|
>
|
|
116
116
|
<span>{tier.label}</span>
|
|
117
|
-
<span>
|
|
117
|
+
<span>Credit Card Fee + {tier.fee}</span>
|
|
118
118
|
</div>
|
|
119
119
|
);
|
|
120
120
|
})
|
|
@@ -244,11 +244,38 @@ export function FeeDetailPanel({ fee, transactionAmountUsd, onBack }: FeeDetailP
|
|
|
244
244
|
<span className="text-as-primary font-semibold">${transactionAmountUsd.toFixed(2)}</span>
|
|
245
245
|
</div>
|
|
246
246
|
|
|
247
|
-
{isStripeFee &&
|
|
248
|
-
|
|
249
|
-
<
|
|
250
|
-
|
|
251
|
-
|
|
247
|
+
{isStripeFee && (
|
|
248
|
+
<>
|
|
249
|
+
<div className="flex items-center justify-between">
|
|
250
|
+
<span className="text-as-secondary">
|
|
251
|
+
Credit Card Fee ({fee.stripeFeeBps ? `${bpsToPercent(fee.stripeFeeBps)}%` : "0%"} + $
|
|
252
|
+
{fee.stripeFeeUsd?.toFixed(2) || "0.00"})
|
|
253
|
+
</span>
|
|
254
|
+
<span className="text-as-primary font-medium">
|
|
255
|
+
${((transactionAmountUsd * (fee.stripeFeeBps || 0)) / 10000 + (fee.stripeFeeUsd || 0)).toFixed(2)}
|
|
256
|
+
</span>
|
|
257
|
+
</div>
|
|
258
|
+
<div className="flex items-center justify-between">
|
|
259
|
+
<span className="text-as-secondary">
|
|
260
|
+
AnySpend Fee ({fee.anyspendFeeBps ? `${bpsToPercent(fee.anyspendFeeBps)}%` : "0%"}
|
|
261
|
+
{fee.anyspendFeeUsd && fee.anyspendFeeUsd > 0 ? ` + $${fee.anyspendFeeUsd.toFixed(2)}` : ""})
|
|
262
|
+
</span>
|
|
263
|
+
<span className="text-as-primary font-medium">
|
|
264
|
+
$
|
|
265
|
+
{((transactionAmountUsd * (fee.anyspendFeeBps || 0)) / 10000 + (fee.anyspendFeeUsd || 0)).toFixed(
|
|
266
|
+
2,
|
|
267
|
+
)}
|
|
268
|
+
</span>
|
|
269
|
+
</div>
|
|
270
|
+
<div className="border-as-border-secondary border-t pt-2">
|
|
271
|
+
<div className="flex items-center justify-between">
|
|
272
|
+
<span className="text-as-primary font-semibold">Total Fee</span>
|
|
273
|
+
<span className="text-as-brand font-semibold">
|
|
274
|
+
${((transactionAmountUsd * (fee.finalFeeBps || 0)) / 10000 + (fee.finalFeeUsd || 0)).toFixed(2)}
|
|
275
|
+
</span>
|
|
276
|
+
</div>
|
|
277
|
+
</div>
|
|
278
|
+
</>
|
|
252
279
|
)}
|
|
253
280
|
|
|
254
281
|
{!isStripeFee && currentCryptoTier && (
|
|
@@ -68,6 +68,7 @@ interface OrderDetailsProps {
|
|
|
68
68
|
onPaymentMethodChange?: (method: CryptoPaymentMethodType) => void; // Callback for payment method switching
|
|
69
69
|
onBack?: () => void;
|
|
70
70
|
disableUrlParamManagement?: boolean; // When true, will not modify URL parameters
|
|
71
|
+
points?: number | undefined; // Points earned from the transaction
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
// Add this helper function near the top or just above the component
|
|
@@ -212,6 +213,7 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
212
213
|
onPaymentMethodChange,
|
|
213
214
|
onBack,
|
|
214
215
|
disableUrlParamManagement = false,
|
|
216
|
+
points,
|
|
215
217
|
}: OrderDetailsProps) {
|
|
216
218
|
const router = useRouter();
|
|
217
219
|
const searchParams = useSearchParams();
|
|
@@ -576,6 +578,7 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
576
578
|
nft={nft}
|
|
577
579
|
recipientName={recipientName}
|
|
578
580
|
formattedExpectedDstAmount={formattedExpectedDstAmount}
|
|
581
|
+
points={points}
|
|
579
582
|
/>
|
|
580
583
|
<Accordion type="single" collapsible className="order-details-accordion w-full">
|
|
581
584
|
<AccordionItem value="refund-details" className="order-details-refund-item">
|
|
@@ -654,6 +657,7 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
654
657
|
nft={nft}
|
|
655
658
|
recipientName={recipientName}
|
|
656
659
|
formattedExpectedDstAmount={formattedExpectedDstAmount}
|
|
660
|
+
points={points}
|
|
657
661
|
/>
|
|
658
662
|
<Accordion type="single" collapsible className="order-details-accordion w-full">
|
|
659
663
|
<AccordionItem value="execute-details" className="order-details-execute-item">
|
|
@@ -781,6 +785,7 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
781
785
|
nft={nft}
|
|
782
786
|
recipientName={recipientName}
|
|
783
787
|
formattedExpectedDstAmount={formattedExpectedDstAmount}
|
|
788
|
+
points={points}
|
|
784
789
|
/>
|
|
785
790
|
<Accordion type="single" collapsible className="order-details-accordion w-full">
|
|
786
791
|
<AccordionItem value="more-details" className="order-details-more-item">
|
|
@@ -910,6 +915,7 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
910
915
|
nft={nft}
|
|
911
916
|
recipientName={recipientName}
|
|
912
917
|
formattedExpectedDstAmount={formattedExpectedDstAmount}
|
|
918
|
+
points={points}
|
|
913
919
|
/>
|
|
914
920
|
<Accordion type="single" collapsible className="order-details-accordion w-full">
|
|
915
921
|
<AccordionItem value="deposit-details" className="order-details-deposit-item">
|
|
@@ -1190,6 +1196,7 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
1190
1196
|
nft={nft}
|
|
1191
1197
|
recipientName={recipientName}
|
|
1192
1198
|
formattedExpectedDstAmount={formattedExpectedDstAmount}
|
|
1199
|
+
points={points}
|
|
1193
1200
|
/>
|
|
1194
1201
|
)}
|
|
1195
1202
|
|
|
@@ -5,6 +5,7 @@ import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
|
5
5
|
import { CopyToClipboard } from "@b3dotfun/sdk/global-account/react";
|
|
6
6
|
import { cn } from "@b3dotfun/sdk/shared/utils";
|
|
7
7
|
import centerTruncate from "@b3dotfun/sdk/shared/utils/centerTruncate";
|
|
8
|
+
import { formatNumber } from "@b3dotfun/sdk/shared/utils/formatNumber";
|
|
8
9
|
import { formatTokenAmount } from "@b3dotfun/sdk/shared/utils/number";
|
|
9
10
|
import { ChevronDown, Copy } from "lucide-react";
|
|
10
11
|
import { motion } from "motion/react";
|
|
@@ -27,6 +28,7 @@ interface OrderDetailsCollapsibleProps {
|
|
|
27
28
|
className?: string;
|
|
28
29
|
showTotal?: boolean;
|
|
29
30
|
totalAmount?: string;
|
|
31
|
+
points?: number;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
export const OrderDetailsCollapsible = memo(function OrderDetailsCollapsible({
|
|
@@ -39,6 +41,7 @@ export const OrderDetailsCollapsible = memo(function OrderDetailsCollapsible({
|
|
|
39
41
|
className,
|
|
40
42
|
showTotal = false,
|
|
41
43
|
totalAmount,
|
|
44
|
+
points,
|
|
42
45
|
}: OrderDetailsCollapsibleProps) {
|
|
43
46
|
const [showOrderDetails, setShowOrderDetails] = useState(true);
|
|
44
47
|
|
|
@@ -150,6 +153,19 @@ export const OrderDetailsCollapsible = memo(function OrderDetailsCollapsible({
|
|
|
150
153
|
</div>
|
|
151
154
|
</div>
|
|
152
155
|
|
|
156
|
+
{points !== undefined && points !== null && (
|
|
157
|
+
<>
|
|
158
|
+
<div className="order-details-divider divider w-full" />
|
|
159
|
+
{/* Points Section */}
|
|
160
|
+
<div className="order-details-points-section flex w-full justify-between gap-4">
|
|
161
|
+
<div className="order-details-points-label text-as-tertiarry">Points</div>
|
|
162
|
+
<div className="order-details-points-value text-as-brand font-semibold">
|
|
163
|
+
+{formatNumber(points)} pts
|
|
164
|
+
</div>
|
|
165
|
+
</div>
|
|
166
|
+
</>
|
|
167
|
+
)}
|
|
168
|
+
|
|
153
169
|
<div className="order-details-divider divider w-full" />
|
|
154
170
|
|
|
155
171
|
{/* Order ID / Total Section */}
|
|
@@ -5,7 +5,7 @@ import { Button, useAccountWallet, useTokenBalancesByChain } from "@b3dotfun/sdk
|
|
|
5
5
|
import { cn } from "@b3dotfun/sdk/shared/utils";
|
|
6
6
|
import { formatTokenAmount } from "@b3dotfun/sdk/shared/utils/number";
|
|
7
7
|
import { simpleHashChainToChainName } from "@b3dotfun/sdk/shared/utils/simplehash";
|
|
8
|
-
import { TokenSelector } from "@
|
|
8
|
+
import { TokenSelector } from "@relayprotocol/relay-kit-ui";
|
|
9
9
|
import { CheckCircle2, ChevronsUpDown } from "lucide-react";
|
|
10
10
|
import { useMemo } from "react";
|
|
11
11
|
import { ChainTokenIcon } from "./ChainTokenIcon";
|
|
@@ -8,7 +8,7 @@ import { ALL_CHAINS, RELAY_SOLANA_MAINNET_CHAIN_ID } from "@b3dotfun/sdk/anyspen
|
|
|
8
8
|
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
9
9
|
import { Button } from "@b3dotfun/sdk/global-account/react";
|
|
10
10
|
import { cn } from "@b3dotfun/sdk/shared/utils";
|
|
11
|
-
import { TokenSelector } from "@
|
|
11
|
+
import { TokenSelector } from "@relayprotocol/relay-kit-ui";
|
|
12
12
|
import { ChainTokenIcon } from "./ChainTokenIcon";
|
|
13
13
|
|
|
14
14
|
export function OrderTokenAmount({
|
|
@@ -7,7 +7,7 @@ import { NumericFormat } from "react-number-format";
|
|
|
7
7
|
import { ALL_CHAINS, RELAY_SOLANA_MAINNET_CHAIN_ID } from "@b3dotfun/sdk/anyspend";
|
|
8
8
|
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
9
9
|
import { cn } from "@b3dotfun/sdk/shared/utils";
|
|
10
|
-
import { TokenSelector } from "@
|
|
10
|
+
import { TokenSelector } from "@relayprotocol/relay-kit-ui";
|
|
11
11
|
import { ChainTokenIcon } from "./ChainTokenIcon";
|
|
12
12
|
|
|
13
13
|
export function OrderTokenAmountFiat({
|
|
@@ -7,7 +7,7 @@ import { NumericFormat } from "react-number-format";
|
|
|
7
7
|
import { ALL_CHAINS, RELAY_SOLANA_MAINNET_CHAIN_ID } from "@b3dotfun/sdk/anyspend";
|
|
8
8
|
import { Button } from "@b3dotfun/sdk/global-account/react";
|
|
9
9
|
import { cn } from "@b3dotfun/sdk/shared/utils";
|
|
10
|
-
import { TokenSelector } from "@
|
|
10
|
+
import { TokenSelector } from "@relayprotocol/relay-kit-ui";
|
|
11
11
|
import { ChainTokenIcon } from "./ChainTokenIcon";
|
|
12
12
|
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
13
13
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { createContext, useContext
|
|
3
|
+
import { ReactNode, createContext, useContext } from "react";
|
|
4
4
|
|
|
5
5
|
export interface FeatureFlags {
|
|
6
6
|
showPoints?: boolean;
|
|
@@ -18,7 +18,7 @@ interface FeatureFlagsProviderProps {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
const defaultFeatureFlags: FeatureFlags = {
|
|
21
|
-
showPoints:
|
|
21
|
+
showPoints: true,
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
export function FeatureFlagsProvider({ children, featureFlags = defaultFeatureFlags }: FeatureFlagsProviderProps) {
|
|
@@ -1334,10 +1334,22 @@ export interface components {
|
|
|
1334
1334
|
/** @description Settlement information for executed orders */
|
|
1335
1335
|
settlement: {
|
|
1336
1336
|
/**
|
|
1337
|
-
* @description Actual received amount after execution
|
|
1337
|
+
* @description Actual received amount after execution (only for swap/hypeduel orders). Optional - only present for swap/hypeduel orders.
|
|
1338
1338
|
* @example 990000
|
|
1339
1339
|
*/
|
|
1340
|
-
actualDstAmount
|
|
1340
|
+
actualDstAmount?: string;
|
|
1341
|
+
/**
|
|
1342
|
+
* @description Complete relay API response data. Contains transaction details, state changes, fees, and execution status. Optional - can be backfilled by querying Relay API /requests/v2 endpoint.
|
|
1343
|
+
* @example {
|
|
1344
|
+
* "status": "success",
|
|
1345
|
+
* "metadata": {
|
|
1346
|
+
* "currencyOut": {
|
|
1347
|
+
* "amount": "990000"
|
|
1348
|
+
* }
|
|
1349
|
+
* }
|
|
1350
|
+
* }
|
|
1351
|
+
*/
|
|
1352
|
+
relay?: Record<string, never>;
|
|
1341
1353
|
} | null;
|
|
1342
1354
|
/** @description Fee structure for the order including Stripe and AnySpend fees */
|
|
1343
1355
|
fee?: Omit<components["schemas"]["Fee"], "type"> | null;
|