@b3dotfun/sdk 0.0.70-alpha.0 → 0.0.70-alpha.1
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/index.d.ts +1 -0
- package/dist/cjs/anyspend/index.js +1 -0
- package/dist/cjs/anyspend/react/components/AnySpend.d.ts +6 -0
- package/dist/cjs/anyspend/react/components/AnySpend.js +13 -1
- package/dist/cjs/anyspend/react/components/AnySpendBondKit.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/AnySpendBondKit.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendBuySpin.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/AnySpendBuySpin.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendCustom.d.ts +1 -0
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +6 -2
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.d.ts +1 -0
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +3 -1
- package/dist/cjs/anyspend/react/components/AnySpendDepositUpside.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/AnySpendDepositUpside.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendNFT.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3ExactIn.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3ExactIn.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendStakeUpside.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/AnySpendStakeUpside.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/AnySpendStakeUpsideExactIn.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendTournament.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/AnySpendTournament.js +1 -1
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +2 -2
- package/dist/cjs/anyspend/react/components/AnyspendSignatureMint.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/AnyspendSignatureMint.js +2 -2
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +2 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOrder.d.ts +1 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOrder.js +2 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +16 -0
- package/dist/cjs/anyspend/services/anyspend.d.ts +2 -1
- package/dist/cjs/anyspend/services/anyspend.js +2 -1
- package/dist/cjs/anyspend/types/api.d.ts +295 -0
- package/dist/cjs/anyspend/utils/validation.d.ts +67 -0
- package/dist/cjs/anyspend/utils/validation.js +157 -0
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +4 -0
- package/dist/esm/anyspend/index.d.ts +1 -0
- package/dist/esm/anyspend/index.js +1 -0
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +6 -0
- package/dist/esm/anyspend/react/components/AnySpend.js +13 -1
- package/dist/esm/anyspend/react/components/AnySpendBondKit.d.ts +3 -1
- package/dist/esm/anyspend/react/components/AnySpendBondKit.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendBuySpin.d.ts +2 -1
- package/dist/esm/anyspend/react/components/AnySpendBuySpin.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendCustom.d.ts +1 -0
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +6 -2
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.d.ts +1 -0
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +3 -1
- package/dist/esm/anyspend/react/components/AnySpendDepositUpside.d.ts +2 -1
- package/dist/esm/anyspend/react/components/AnySpendDepositUpside.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendNFT.d.ts +2 -1
- package/dist/esm/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.d.ts +2 -1
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeB3ExactIn.d.ts +2 -1
- package/dist/esm/anyspend/react/components/AnySpendStakeB3ExactIn.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeUpside.d.ts +2 -1
- package/dist/esm/anyspend/react/components/AnySpendStakeUpside.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +2 -1
- package/dist/esm/anyspend/react/components/AnySpendStakeUpsideExactIn.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendTournament.d.ts +2 -0
- package/dist/esm/anyspend/react/components/AnySpendTournament.js +1 -1
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.d.ts +2 -1
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +2 -2
- package/dist/esm/anyspend/react/components/AnyspendSignatureMint.d.ts +2 -1
- package/dist/esm/anyspend/react/components/AnyspendSignatureMint.js +2 -2
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +2 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOrder.d.ts +1 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOrder.js +2 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +16 -0
- package/dist/esm/anyspend/services/anyspend.d.ts +2 -1
- package/dist/esm/anyspend/services/anyspend.js +2 -1
- package/dist/esm/anyspend/types/api.d.ts +295 -0
- package/dist/esm/anyspend/utils/validation.d.ts +67 -0
- package/dist/esm/anyspend/utils/validation.js +153 -0
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +4 -0
- package/dist/types/anyspend/index.d.ts +1 -0
- package/dist/types/anyspend/react/components/AnySpend.d.ts +6 -0
- package/dist/types/anyspend/react/components/AnySpendBondKit.d.ts +3 -1
- package/dist/types/anyspend/react/components/AnySpendBuySpin.d.ts +2 -1
- package/dist/types/anyspend/react/components/AnySpendCustom.d.ts +1 -0
- package/dist/types/anyspend/react/components/AnySpendCustomExactIn.d.ts +1 -0
- package/dist/types/anyspend/react/components/AnySpendDepositUpside.d.ts +2 -1
- package/dist/types/anyspend/react/components/AnySpendNFT.d.ts +2 -1
- package/dist/types/anyspend/react/components/AnySpendStakeB3.d.ts +2 -1
- package/dist/types/anyspend/react/components/AnySpendStakeB3ExactIn.d.ts +2 -1
- package/dist/types/anyspend/react/components/AnySpendStakeUpside.d.ts +2 -1
- package/dist/types/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +2 -1
- package/dist/types/anyspend/react/components/AnySpendTournament.d.ts +2 -0
- package/dist/types/anyspend/react/components/AnyspendDepositHype.d.ts +2 -1
- package/dist/types/anyspend/react/components/AnyspendSignatureMint.d.ts +2 -1
- package/dist/types/anyspend/react/hooks/useAnyspendCreateOrder.d.ts +1 -0
- package/dist/types/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +16 -0
- package/dist/types/anyspend/services/anyspend.d.ts +2 -1
- package/dist/types/anyspend/types/api.d.ts +295 -0
- package/dist/types/anyspend/utils/validation.d.ts +67 -0
- package/dist/types/global-account/react/stores/useModalStore.d.ts +4 -0
- package/package.json +1 -1
- package/src/anyspend/index.ts +1 -0
- package/src/anyspend/react/components/AnySpend.tsx +23 -0
- package/src/anyspend/react/components/AnySpendBondKit.tsx +3 -1
- package/src/anyspend/react/components/AnySpendBuySpin.tsx +3 -0
- package/src/anyspend/react/components/AnySpendCustom.tsx +8 -1
- package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +4 -0
- package/src/anyspend/react/components/AnySpendDepositUpside.tsx +3 -0
- package/src/anyspend/react/components/AnySpendNFT.tsx +3 -0
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +3 -0
- package/src/anyspend/react/components/AnySpendStakeB3ExactIn.tsx +3 -0
- package/src/anyspend/react/components/AnySpendStakeUpside.tsx +3 -0
- package/src/anyspend/react/components/AnySpendStakeUpsideExactIn.tsx +3 -0
- package/src/anyspend/react/components/AnySpendTournament.tsx +3 -0
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +3 -0
- package/src/anyspend/react/components/AnyspendSignatureMint.tsx +3 -0
- package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +2 -0
- package/src/anyspend/react/hooks/useAnyspendCreateOrder.ts +13 -1
- package/src/anyspend/services/anyspend.ts +3 -0
- package/src/anyspend/types/api.ts +295 -0
- package/src/anyspend/utils/validation.ts +209 -0
- package/src/global-account/react/stores/useModalStore.ts +4 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export interface ValidationResult {
|
|
2
|
+
isValid: boolean;
|
|
3
|
+
error?: string;
|
|
4
|
+
cleaned?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface StringValidationOptions {
|
|
7
|
+
required?: boolean;
|
|
8
|
+
defaultValue?: () => string;
|
|
9
|
+
minLength?: number;
|
|
10
|
+
maxLength?: number;
|
|
11
|
+
pattern?: RegExp;
|
|
12
|
+
patternErrorMessage?: string;
|
|
13
|
+
trim?: boolean;
|
|
14
|
+
toLowerCase?: boolean;
|
|
15
|
+
toUpperCase?: boolean;
|
|
16
|
+
customValidator?: (value: string) => {
|
|
17
|
+
valid: boolean;
|
|
18
|
+
error?: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Generic string validator with configurable rules
|
|
23
|
+
*/
|
|
24
|
+
export declare function validateString(value: string | undefined, options: StringValidationOptions): ValidationResult;
|
|
25
|
+
/**
|
|
26
|
+
* Common validation patterns
|
|
27
|
+
*/
|
|
28
|
+
export declare const ValidationPatterns: {
|
|
29
|
+
readonly ALPHANUMERIC: RegExp;
|
|
30
|
+
readonly ALPHANUMERIC_WITH_DASH_UNDERSCORE: RegExp;
|
|
31
|
+
readonly ALPHANUMERIC_WITH_SAFE_CHARS: RegExp;
|
|
32
|
+
readonly SAFE_IDENTIFIER: RegExp;
|
|
33
|
+
readonly NO_CONTROL_CHARS: RegExp;
|
|
34
|
+
readonly URL_SAFE: RegExp;
|
|
35
|
+
readonly NUMERIC: RegExp;
|
|
36
|
+
readonly HEX: RegExp;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Pre-configured validators for common use cases
|
|
40
|
+
*/
|
|
41
|
+
export declare const Validators: {
|
|
42
|
+
/**
|
|
43
|
+
* Validates client reference IDs (alphanumeric + safe chars)
|
|
44
|
+
* Returns undefined if not provided
|
|
45
|
+
*/
|
|
46
|
+
clientReferenceId: (value?: string) => ValidationResult;
|
|
47
|
+
/**
|
|
48
|
+
* Validates alphanumeric strings (letters and numbers only)
|
|
49
|
+
*/
|
|
50
|
+
alphanumeric: (value?: string, required?: boolean) => ValidationResult;
|
|
51
|
+
/**
|
|
52
|
+
* Validates wallet addresses (hex format)
|
|
53
|
+
*/
|
|
54
|
+
walletAddress: (value?: string, required?: boolean) => ValidationResult;
|
|
55
|
+
/**
|
|
56
|
+
* Validates order IDs (UUID format)
|
|
57
|
+
*/
|
|
58
|
+
orderId: (value?: string) => ValidationResult;
|
|
59
|
+
/**
|
|
60
|
+
* Validates URL-safe strings
|
|
61
|
+
*/
|
|
62
|
+
urlSafe: (value?: string, maxLength?: number) => ValidationResult;
|
|
63
|
+
/**
|
|
64
|
+
* Validates safe identifiers (no injection risks)
|
|
65
|
+
*/
|
|
66
|
+
safeIdentifier: (value?: string, required?: boolean) => ValidationResult;
|
|
67
|
+
};
|
|
@@ -122,6 +122,8 @@ export interface AnySpendModalProps extends BaseModalProps {
|
|
|
122
122
|
destinationTokenChainId?: number;
|
|
123
123
|
/** Custom USD input values for quick amount buttons in fiat onramp */
|
|
124
124
|
customUsdInputValues?: string[];
|
|
125
|
+
/** Client-provided reference ID for tracking orders */
|
|
126
|
+
clientReferenceId?: string;
|
|
125
127
|
}
|
|
126
128
|
/**
|
|
127
129
|
* Props for the AnySpend NFT modal
|
|
@@ -136,6 +138,8 @@ export interface AnySpendNftProps extends BaseModalProps {
|
|
|
136
138
|
recipientAddress?: string;
|
|
137
139
|
/** Callback function called when the NFT is successfully transferred */
|
|
138
140
|
onSuccess?: (txHash?: string) => void;
|
|
141
|
+
/** Client-provided reference ID for tracking orders */
|
|
142
|
+
clientReferenceId?: string;
|
|
139
143
|
}
|
|
140
144
|
/**
|
|
141
145
|
* Props for the AnySpend tournament modal
|
package/package.json
CHANGED
package/src/anyspend/index.ts
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
useAnyspendQuote,
|
|
9
9
|
useGeoOnrampOptions,
|
|
10
10
|
} from "@b3dotfun/sdk/anyspend/react";
|
|
11
|
+
import { Validators } from "@b3dotfun/sdk/anyspend/utils/validation";
|
|
11
12
|
import {
|
|
12
13
|
Button,
|
|
13
14
|
ShinyButton,
|
|
@@ -87,6 +88,12 @@ export function AnySpend(props: {
|
|
|
87
88
|
onTokenSelect?: (token: components["schemas"]["Token"], event: { preventDefault: () => void }) => void;
|
|
88
89
|
onSuccess?: (txHash?: string) => void;
|
|
89
90
|
customUsdInputValues?: string[];
|
|
91
|
+
/**
|
|
92
|
+
* Client-provided reference ID for tracking orders.
|
|
93
|
+
* Must be alphanumeric with optional hyphens, underscores, and dots (max 255 chars).
|
|
94
|
+
* Auto-generates UUID if not provided.
|
|
95
|
+
*/
|
|
96
|
+
clientReferenceId?: string;
|
|
90
97
|
}) {
|
|
91
98
|
const fingerprintConfig = getFingerprintConfig();
|
|
92
99
|
|
|
@@ -108,6 +115,7 @@ function AnySpendInner({
|
|
|
108
115
|
onTokenSelect,
|
|
109
116
|
onSuccess,
|
|
110
117
|
customUsdInputValues,
|
|
118
|
+
clientReferenceId: clientReferenceIdFromProps,
|
|
111
119
|
}: {
|
|
112
120
|
destinationTokenAddress?: string;
|
|
113
121
|
destinationTokenChainId?: number;
|
|
@@ -119,10 +127,23 @@ function AnySpendInner({
|
|
|
119
127
|
onTokenSelect?: (token: components["schemas"]["Token"], event: { preventDefault: () => void }) => void;
|
|
120
128
|
onSuccess?: (txHash?: string) => void;
|
|
121
129
|
customUsdInputValues?: string[];
|
|
130
|
+
clientReferenceId?: string;
|
|
122
131
|
}) {
|
|
123
132
|
const searchParams = useSearchParamsSSR();
|
|
124
133
|
const router = useRouter();
|
|
125
134
|
|
|
135
|
+
// Validate and clean clientReferenceId
|
|
136
|
+
const validatedClientReferenceId = useMemo(() => {
|
|
137
|
+
const validation = Validators.clientReferenceId(clientReferenceIdFromProps);
|
|
138
|
+
if (!validation.isValid) {
|
|
139
|
+
console.error(
|
|
140
|
+
`[AnySpend] Invalid clientReferenceId: ${validation.error || "Validation failed"}. Will be set to undefined.`,
|
|
141
|
+
);
|
|
142
|
+
return undefined;
|
|
143
|
+
}
|
|
144
|
+
return validation.cleaned;
|
|
145
|
+
}, [clientReferenceIdFromProps]);
|
|
146
|
+
|
|
126
147
|
// Determine if we're in "buy mode" based on whether destination token props are provided
|
|
127
148
|
const isBuyMode = !!(destinationTokenAddress && destinationTokenChainId);
|
|
128
149
|
|
|
@@ -823,6 +844,7 @@ function AnySpendInner({
|
|
|
823
844
|
srcAmount: srcAmountBigInt.toString(),
|
|
824
845
|
expectedDstAmount: anyspendQuote?.data?.currencyOut?.amount || "0",
|
|
825
846
|
creatorAddress: globalAddress,
|
|
847
|
+
clientReferenceId: validatedClientReferenceId,
|
|
826
848
|
});
|
|
827
849
|
} catch (err: any) {
|
|
828
850
|
console.error(err);
|
|
@@ -891,6 +913,7 @@ function AnySpendInner({
|
|
|
891
913
|
},
|
|
892
914
|
expectedDstAmount: anyspendQuote?.data?.currencyOut?.amount?.toString() || "0",
|
|
893
915
|
creatorAddress: globalAddress,
|
|
916
|
+
clientReferenceId: validatedClientReferenceId,
|
|
894
917
|
});
|
|
895
918
|
} catch (err: any) {
|
|
896
919
|
console.error(err);
|
|
@@ -38,7 +38,8 @@ export function AnySpendBondKit({
|
|
|
38
38
|
imageUrl,
|
|
39
39
|
b3Amount: initialB3Amount,
|
|
40
40
|
onSuccess,
|
|
41
|
-
|
|
41
|
+
clientReferenceId,
|
|
42
|
+
}: AnySpendBondKitProps & { clientReferenceId?: string }) {
|
|
42
43
|
const hasMounted = useHasMounted();
|
|
43
44
|
const [showAmountPrompt, setShowAmountPrompt] = useState(!initialB3Amount);
|
|
44
45
|
const [b3Amount, setB3Amount] = useState(initialB3Amount || "");
|
|
@@ -371,6 +372,7 @@ export function AnySpendBondKit({
|
|
|
371
372
|
header={header}
|
|
372
373
|
onSuccess={onSuccess}
|
|
373
374
|
showRecipient={true}
|
|
375
|
+
clientReferenceId={clientReferenceId}
|
|
374
376
|
/>
|
|
375
377
|
);
|
|
376
378
|
}
|
|
@@ -129,6 +129,7 @@ export function AnySpendBuySpin({
|
|
|
129
129
|
recipientAddress,
|
|
130
130
|
prefillQuantity,
|
|
131
131
|
onSuccess,
|
|
132
|
+
clientReferenceId,
|
|
132
133
|
}: {
|
|
133
134
|
loadOrder?: string;
|
|
134
135
|
mode?: "modal" | "page";
|
|
@@ -137,6 +138,7 @@ export function AnySpendBuySpin({
|
|
|
137
138
|
recipientAddress: string;
|
|
138
139
|
prefillQuantity?: string;
|
|
139
140
|
onSuccess?: (txHash?: string) => void;
|
|
141
|
+
clientReferenceId?: string;
|
|
140
142
|
}) {
|
|
141
143
|
const hasMounted = useHasMounted();
|
|
142
144
|
const { setB3ModalOpen } = useModalStore();
|
|
@@ -680,6 +682,7 @@ export function AnySpendBuySpin({
|
|
|
680
682
|
header={header}
|
|
681
683
|
onSuccess={txHash => onSuccess?.(txHash)}
|
|
682
684
|
showRecipient={false}
|
|
685
|
+
clientReferenceId={clientReferenceId}
|
|
683
686
|
/>
|
|
684
687
|
);
|
|
685
688
|
}
|
|
@@ -187,6 +187,7 @@ export function AnySpendCustom(props: {
|
|
|
187
187
|
onSuccess?: (txHash?: string) => void;
|
|
188
188
|
showRecipient?: boolean;
|
|
189
189
|
onShowPointsDetail?: () => void;
|
|
190
|
+
clientReferenceId?: string;
|
|
190
191
|
}) {
|
|
191
192
|
const fingerprintConfig = getFingerprintConfig();
|
|
192
193
|
|
|
@@ -214,6 +215,7 @@ function AnySpendCustomInner({
|
|
|
214
215
|
onSuccess,
|
|
215
216
|
showRecipient = true,
|
|
216
217
|
onShowPointsDetail,
|
|
218
|
+
clientReferenceId,
|
|
217
219
|
}: {
|
|
218
220
|
loadOrder?: string;
|
|
219
221
|
mode?: "modal" | "page";
|
|
@@ -237,6 +239,7 @@ function AnySpendCustomInner({
|
|
|
237
239
|
onSuccess?: (txHash?: string) => void;
|
|
238
240
|
showRecipient?: boolean;
|
|
239
241
|
onShowPointsDetail?: () => void;
|
|
242
|
+
clientReferenceId?: string;
|
|
240
243
|
}) {
|
|
241
244
|
const hasMounted = useHasMounted();
|
|
242
245
|
const featureFlags = useFeatureFlags();
|
|
@@ -532,9 +535,13 @@ function AnySpendCustomInner({
|
|
|
532
535
|
: window.location.origin,
|
|
533
536
|
},
|
|
534
537
|
expectedDstAmount: anyspendQuote?.data?.currencyOut?.amount?.toString() || "0",
|
|
538
|
+
clientReferenceId: clientReferenceId,
|
|
535
539
|
});
|
|
536
540
|
} else {
|
|
537
|
-
void createRegularOrder(
|
|
541
|
+
void createRegularOrder({
|
|
542
|
+
...createOrderParams,
|
|
543
|
+
clientReferenceId: clientReferenceId,
|
|
544
|
+
});
|
|
538
545
|
}
|
|
539
546
|
} catch (err) {
|
|
540
547
|
console.error(err);
|
|
@@ -57,6 +57,7 @@ export interface AnySpendCustomExactInProps {
|
|
|
57
57
|
anyspendPrice: GetQuoteResponse | undefined;
|
|
58
58
|
isLoadingAnyspendPrice: boolean;
|
|
59
59
|
}) => React.JSX.Element;
|
|
60
|
+
clientReferenceId?: string;
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
export function AnySpendCustomExactIn(props: AnySpendCustomExactInProps) {
|
|
@@ -87,6 +88,7 @@ function AnySpendCustomExactInInner({
|
|
|
87
88
|
orderType = "custom_exact_in",
|
|
88
89
|
minDestinationAmount,
|
|
89
90
|
header,
|
|
91
|
+
clientReferenceId,
|
|
90
92
|
}: AnySpendCustomExactInProps) {
|
|
91
93
|
const actionLabel = customExactInConfig?.action ?? "Custom Execution";
|
|
92
94
|
|
|
@@ -433,6 +435,7 @@ function AnySpendCustomExactInInner({
|
|
|
433
435
|
expectedDstAmount: expectedDstAmountRaw,
|
|
434
436
|
creatorAddress: globalAddress,
|
|
435
437
|
payload,
|
|
438
|
+
clientReferenceId: clientReferenceId,
|
|
436
439
|
});
|
|
437
440
|
} catch (err: any) {
|
|
438
441
|
console.error(err);
|
|
@@ -488,6 +491,7 @@ function AnySpendCustomExactInInner({
|
|
|
488
491
|
expectedDstAmount: expectedDstAmountRaw,
|
|
489
492
|
creatorAddress: globalAddress,
|
|
490
493
|
payload,
|
|
494
|
+
clientReferenceId: clientReferenceId,
|
|
491
495
|
});
|
|
492
496
|
} catch (err: any) {
|
|
493
497
|
console.error(err);
|
|
@@ -33,6 +33,7 @@ export function AnySpendDepositUpside({
|
|
|
33
33
|
depositContractAddress,
|
|
34
34
|
token,
|
|
35
35
|
onSuccess,
|
|
36
|
+
clientReferenceId,
|
|
36
37
|
}: {
|
|
37
38
|
loadOrder?: string;
|
|
38
39
|
mode?: "modal" | "page";
|
|
@@ -42,6 +43,7 @@ export function AnySpendDepositUpside({
|
|
|
42
43
|
depositContractAddress: string;
|
|
43
44
|
token: components["schemas"]["Token"];
|
|
44
45
|
onSuccess?: (amount: string) => void;
|
|
46
|
+
clientReferenceId?: string;
|
|
45
47
|
}) {
|
|
46
48
|
if (!recipientAddress) return null;
|
|
47
49
|
|
|
@@ -76,6 +78,7 @@ export function AnySpendDepositUpside({
|
|
|
76
78
|
customExactInConfig={customExactInConfig}
|
|
77
79
|
header={header}
|
|
78
80
|
onSuccess={onSuccess}
|
|
81
|
+
clientReferenceId={clientReferenceId}
|
|
79
82
|
/>
|
|
80
83
|
);
|
|
81
84
|
}
|
|
@@ -37,6 +37,7 @@ export function AnySpendNFT({
|
|
|
37
37
|
nftContract,
|
|
38
38
|
onSuccess,
|
|
39
39
|
onShowPointsDetail,
|
|
40
|
+
clientReferenceId,
|
|
40
41
|
}: {
|
|
41
42
|
loadOrder?: string;
|
|
42
43
|
mode?: "modal" | "page";
|
|
@@ -44,6 +45,7 @@ export function AnySpendNFT({
|
|
|
44
45
|
nftContract: components["schemas"]["NftContract"];
|
|
45
46
|
onSuccess?: (txHash?: string) => void;
|
|
46
47
|
onShowPointsDetail?: () => void;
|
|
48
|
+
clientReferenceId?: string;
|
|
47
49
|
}) {
|
|
48
50
|
const [imageUrlWithFallback, setFallbackImageUrl] = useState<string | null>(nftContract.imageUrl);
|
|
49
51
|
const [isLoadingFallback, setIsLoadingFallback] = useState(false);
|
|
@@ -167,6 +169,7 @@ export function AnySpendNFT({
|
|
|
167
169
|
header={header}
|
|
168
170
|
onSuccess={onSuccess}
|
|
169
171
|
onShowPointsDetail={onShowPointsDetail}
|
|
172
|
+
clientReferenceId={clientReferenceId}
|
|
170
173
|
/>
|
|
171
174
|
);
|
|
172
175
|
}
|
|
@@ -48,12 +48,14 @@ export function AnySpendStakeB3({
|
|
|
48
48
|
recipientAddress,
|
|
49
49
|
stakeAmount,
|
|
50
50
|
onSuccess,
|
|
51
|
+
clientReferenceId,
|
|
51
52
|
}: {
|
|
52
53
|
loadOrder?: string;
|
|
53
54
|
mode?: "modal" | "page";
|
|
54
55
|
recipientAddress: string;
|
|
55
56
|
stakeAmount?: string;
|
|
56
57
|
onSuccess?: () => void;
|
|
58
|
+
clientReferenceId?: string;
|
|
57
59
|
}) {
|
|
58
60
|
const hasMounted = useHasMounted();
|
|
59
61
|
const { setB3ModalOpen } = useModalStore();
|
|
@@ -506,6 +508,7 @@ export function AnySpendStakeB3({
|
|
|
506
508
|
header={header}
|
|
507
509
|
onSuccess={onSuccess}
|
|
508
510
|
showRecipient={true}
|
|
511
|
+
clientReferenceId={clientReferenceId}
|
|
509
512
|
/>
|
|
510
513
|
);
|
|
511
514
|
}
|
|
@@ -53,6 +53,7 @@ export function AnySpendStakeB3ExactIn({
|
|
|
53
53
|
recipientAddress,
|
|
54
54
|
stakeAmount,
|
|
55
55
|
onSuccess,
|
|
56
|
+
clientReferenceId,
|
|
56
57
|
}: {
|
|
57
58
|
loadOrder?: string;
|
|
58
59
|
mode?: "modal" | "page";
|
|
@@ -61,6 +62,7 @@ export function AnySpendStakeB3ExactIn({
|
|
|
61
62
|
recipientAddress: string;
|
|
62
63
|
stakeAmount?: string;
|
|
63
64
|
onSuccess?: (amount: string) => void;
|
|
65
|
+
clientReferenceId?: string;
|
|
64
66
|
}) {
|
|
65
67
|
const hasMounted = useHasMounted();
|
|
66
68
|
const { setB3ModalOpen } = useModalStore();
|
|
@@ -517,6 +519,7 @@ export function AnySpendStakeB3ExactIn({
|
|
|
517
519
|
customExactInConfig={customExactInConfig}
|
|
518
520
|
header={header}
|
|
519
521
|
onSuccess={onSuccess}
|
|
522
|
+
clientReferenceId={clientReferenceId}
|
|
520
523
|
/>
|
|
521
524
|
);
|
|
522
525
|
}
|
|
@@ -25,6 +25,7 @@ export function AnySpendStakeUpside({
|
|
|
25
25
|
token,
|
|
26
26
|
onSuccess,
|
|
27
27
|
activeTab,
|
|
28
|
+
clientReferenceId,
|
|
28
29
|
}: {
|
|
29
30
|
loadOrder?: string;
|
|
30
31
|
mode?: "modal" | "page";
|
|
@@ -34,6 +35,7 @@ export function AnySpendStakeUpside({
|
|
|
34
35
|
token: components["schemas"]["Token"];
|
|
35
36
|
onSuccess?: () => void;
|
|
36
37
|
activeTab?: "crypto" | "fiat";
|
|
38
|
+
clientReferenceId?: string;
|
|
37
39
|
}) {
|
|
38
40
|
const header = () => (
|
|
39
41
|
<>
|
|
@@ -80,6 +82,7 @@ export function AnySpendStakeUpside({
|
|
|
80
82
|
onSuccess={onSuccess}
|
|
81
83
|
showRecipient={true}
|
|
82
84
|
activeTab={activeTab}
|
|
85
|
+
clientReferenceId={clientReferenceId}
|
|
83
86
|
/>
|
|
84
87
|
);
|
|
85
88
|
}
|
|
@@ -25,6 +25,7 @@ export function AnySpendStakeUpsideExactIn({
|
|
|
25
25
|
stakingContractAddress,
|
|
26
26
|
token,
|
|
27
27
|
onSuccess,
|
|
28
|
+
clientReferenceId,
|
|
28
29
|
}: {
|
|
29
30
|
loadOrder?: string;
|
|
30
31
|
mode?: "modal" | "page";
|
|
@@ -34,6 +35,7 @@ export function AnySpendStakeUpsideExactIn({
|
|
|
34
35
|
stakingContractAddress: string;
|
|
35
36
|
token: components["schemas"]["Token"];
|
|
36
37
|
onSuccess?: (amount: string) => void;
|
|
38
|
+
clientReferenceId?: string;
|
|
37
39
|
}) {
|
|
38
40
|
if (!recipientAddress) return null;
|
|
39
41
|
|
|
@@ -68,6 +70,7 @@ export function AnySpendStakeUpsideExactIn({
|
|
|
68
70
|
customExactInConfig={customExactInConfig}
|
|
69
71
|
header={header}
|
|
70
72
|
onSuccess={onSuccess}
|
|
73
|
+
clientReferenceId={clientReferenceId}
|
|
71
74
|
/>
|
|
72
75
|
);
|
|
73
76
|
}
|
|
@@ -17,6 +17,7 @@ type AnySpendTournamentProps =
|
|
|
17
17
|
tournamentEntryToken: components["schemas"]["Token"];
|
|
18
18
|
tournamentEntryFee: string;
|
|
19
19
|
onSuccess?: () => void;
|
|
20
|
+
clientReferenceId?: string;
|
|
20
21
|
}
|
|
21
22
|
| {
|
|
22
23
|
mode?: "modal" | "page";
|
|
@@ -28,6 +29,7 @@ type AnySpendTournamentProps =
|
|
|
28
29
|
tournamentFundToken: components["schemas"]["Token"];
|
|
29
30
|
tournamentFundAmount: string;
|
|
30
31
|
onSuccess?: () => void;
|
|
32
|
+
clientReferenceId?: string;
|
|
31
33
|
};
|
|
32
34
|
|
|
33
35
|
export function AnySpendTournament(props: AnySpendTournamentProps) {
|
|
@@ -104,6 +106,7 @@ export function AnySpendTournament(props: AnySpendTournamentProps) {
|
|
|
104
106
|
header={header}
|
|
105
107
|
onSuccess={onSuccess}
|
|
106
108
|
showRecipient={action === "join"}
|
|
109
|
+
clientReferenceId={props.clientReferenceId}
|
|
107
110
|
/>
|
|
108
111
|
);
|
|
109
112
|
}
|
|
@@ -24,6 +24,7 @@ export interface AnySpendDepositHypeProps {
|
|
|
24
24
|
onTokenSelect?: (token: components["schemas"]["Token"], event: { preventDefault: () => void }) => void;
|
|
25
25
|
customUsdInputValues?: string[];
|
|
26
26
|
preferEoa?: boolean;
|
|
27
|
+
clientReferenceId?: string;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
export function AnySpendDepositHype({
|
|
@@ -38,6 +39,7 @@ export function AnySpendDepositHype({
|
|
|
38
39
|
onTokenSelect,
|
|
39
40
|
customUsdInputValues,
|
|
40
41
|
preferEoa,
|
|
42
|
+
clientReferenceId,
|
|
41
43
|
}: AnySpendDepositHypeProps) {
|
|
42
44
|
if (!recipientAddress) return null;
|
|
43
45
|
|
|
@@ -79,6 +81,7 @@ export function AnySpendDepositHype({
|
|
|
79
81
|
onTokenSelect={onTokenSelect}
|
|
80
82
|
customUsdInputValues={customUsdInputValues}
|
|
81
83
|
preferEoa={preferEoa}
|
|
84
|
+
clientReferenceId={clientReferenceId}
|
|
82
85
|
/>
|
|
83
86
|
);
|
|
84
87
|
}
|
|
@@ -47,12 +47,14 @@ export function AnyspendSignatureMint({
|
|
|
47
47
|
signatureData,
|
|
48
48
|
imageUrl,
|
|
49
49
|
onSuccess,
|
|
50
|
+
clientReferenceId,
|
|
50
51
|
}: {
|
|
51
52
|
loadOrder?: string;
|
|
52
53
|
mode?: "modal" | "page";
|
|
53
54
|
signatureData: GenerateSigMintResponse;
|
|
54
55
|
imageUrl?: string;
|
|
55
56
|
onSuccess?: (txHash?: string) => void;
|
|
57
|
+
clientReferenceId?: string;
|
|
56
58
|
}) {
|
|
57
59
|
// Get token data
|
|
58
60
|
const {
|
|
@@ -149,6 +151,7 @@ export function AnyspendSignatureMint({
|
|
|
149
151
|
header={header}
|
|
150
152
|
onSuccess={onSuccess}
|
|
151
153
|
showRecipient={true}
|
|
154
|
+
clientReferenceId={clientReferenceId}
|
|
152
155
|
/>
|
|
153
156
|
);
|
|
154
157
|
}
|
|
@@ -55,6 +55,7 @@ export function useAnyspendCreateOnrampOrder({ onSuccess, onError }: UseAnyspend
|
|
|
55
55
|
tournament,
|
|
56
56
|
payload,
|
|
57
57
|
partnerId,
|
|
58
|
+
clientReferenceId,
|
|
58
59
|
} = params;
|
|
59
60
|
|
|
60
61
|
try {
|
|
@@ -102,6 +103,7 @@ export function useAnyspendCreateOnrampOrder({ onSuccess, onError }: UseAnyspend
|
|
|
102
103
|
}),
|
|
103
104
|
creatorAddress: creatorAddress ? normalizeAddress(creatorAddress) : undefined,
|
|
104
105
|
partnerId,
|
|
106
|
+
clientReferenceId,
|
|
105
107
|
visitorData,
|
|
106
108
|
});
|
|
107
109
|
} catch (error: any) {
|
|
@@ -20,6 +20,7 @@ export type CreateOrderParams = {
|
|
|
20
20
|
creatorAddress?: string;
|
|
21
21
|
payload?: any;
|
|
22
22
|
partnerId?: string;
|
|
23
|
+
clientReferenceId?: string;
|
|
23
24
|
};
|
|
24
25
|
|
|
25
26
|
export type UseAnyspendCreateOrderProps = {
|
|
@@ -41,7 +42,17 @@ export function useAnyspendCreateOrder({ onSuccess, onError }: UseAnyspendCreate
|
|
|
41
42
|
};
|
|
42
43
|
const { mutate: createOrder, isPending } = useMutation({
|
|
43
44
|
mutationFn: async (params: CreateOrderParams) => {
|
|
44
|
-
const {
|
|
45
|
+
const {
|
|
46
|
+
recipientAddress,
|
|
47
|
+
orderType,
|
|
48
|
+
srcChain,
|
|
49
|
+
dstChain,
|
|
50
|
+
srcToken,
|
|
51
|
+
dstToken,
|
|
52
|
+
srcAmount,
|
|
53
|
+
creatorAddress,
|
|
54
|
+
clientReferenceId,
|
|
55
|
+
} = params;
|
|
45
56
|
|
|
46
57
|
try {
|
|
47
58
|
return await anyspendService.createOrder({
|
|
@@ -75,6 +86,7 @@ export function useAnyspendCreateOrder({ onSuccess, onError }: UseAnyspendCreate
|
|
|
75
86
|
},
|
|
76
87
|
}),
|
|
77
88
|
creatorAddress: creatorAddress ? normalizeAddress(creatorAddress) : undefined,
|
|
89
|
+
clientReferenceId,
|
|
78
90
|
visitorData,
|
|
79
91
|
});
|
|
80
92
|
} catch (error: any) {
|
|
@@ -67,6 +67,7 @@ export const anyspendService = {
|
|
|
67
67
|
metadata,
|
|
68
68
|
creatorAddress,
|
|
69
69
|
partnerId,
|
|
70
|
+
clientReferenceId,
|
|
70
71
|
visitorData,
|
|
71
72
|
}: {
|
|
72
73
|
recipientAddress: string;
|
|
@@ -81,6 +82,7 @@ export const anyspendService = {
|
|
|
81
82
|
metadata: Record<string, any>;
|
|
82
83
|
creatorAddress?: string;
|
|
83
84
|
partnerId?: string;
|
|
85
|
+
clientReferenceId?: string;
|
|
84
86
|
visitorData?: VisitorData;
|
|
85
87
|
}) => {
|
|
86
88
|
const response = await fetch(`${ANYSPEND_MAINNET_BASE_URL}/orders`, {
|
|
@@ -103,6 +105,7 @@ export const anyspendService = {
|
|
|
103
105
|
metadata,
|
|
104
106
|
creatorAddress,
|
|
105
107
|
partnerId,
|
|
108
|
+
...(clientReferenceId && { clientReferenceId }),
|
|
106
109
|
}),
|
|
107
110
|
});
|
|
108
111
|
const data: CreateOrderResponse = await response.json();
|