@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
|
+
};
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Validators = exports.ValidationPatterns = void 0;
|
|
4
|
+
exports.validateString = validateString;
|
|
5
|
+
/**
|
|
6
|
+
* Generic string validator with configurable rules
|
|
7
|
+
*/
|
|
8
|
+
function validateString(value, options) {
|
|
9
|
+
const { required = false, defaultValue, minLength, maxLength, pattern, patternErrorMessage, trim = true, toLowerCase = false, toUpperCase = false, customValidator, } = options;
|
|
10
|
+
// Handle empty/undefined
|
|
11
|
+
if (!value || (trim && value.trim() === "")) {
|
|
12
|
+
if (required && !defaultValue) {
|
|
13
|
+
return { isValid: false, error: "This field is required" };
|
|
14
|
+
}
|
|
15
|
+
if (defaultValue) {
|
|
16
|
+
return { isValid: true, cleaned: defaultValue() };
|
|
17
|
+
}
|
|
18
|
+
return { isValid: true, cleaned: undefined };
|
|
19
|
+
}
|
|
20
|
+
// Pre-processing
|
|
21
|
+
let cleaned = value;
|
|
22
|
+
if (trim)
|
|
23
|
+
cleaned = cleaned.trim();
|
|
24
|
+
if (toLowerCase)
|
|
25
|
+
cleaned = cleaned.toLowerCase();
|
|
26
|
+
if (toUpperCase)
|
|
27
|
+
cleaned = cleaned.toUpperCase();
|
|
28
|
+
// Length validation
|
|
29
|
+
if (minLength !== undefined && cleaned.length < minLength) {
|
|
30
|
+
return {
|
|
31
|
+
isValid: false,
|
|
32
|
+
error: `Minimum length is ${minLength} characters`,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
if (maxLength !== undefined && cleaned.length > maxLength) {
|
|
36
|
+
return {
|
|
37
|
+
isValid: false,
|
|
38
|
+
error: `Maximum length is ${maxLength} characters`,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
// Pattern validation
|
|
42
|
+
if (pattern && !pattern.test(cleaned)) {
|
|
43
|
+
return {
|
|
44
|
+
isValid: false,
|
|
45
|
+
error: patternErrorMessage || "Invalid format",
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
// Custom validation
|
|
49
|
+
if (customValidator) {
|
|
50
|
+
const customResult = customValidator(cleaned);
|
|
51
|
+
if (!customResult.valid) {
|
|
52
|
+
return { isValid: false, error: customResult.error };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return { isValid: true, cleaned };
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Common validation patterns
|
|
59
|
+
*/
|
|
60
|
+
exports.ValidationPatterns = {
|
|
61
|
+
ALPHANUMERIC: /^[a-zA-Z0-9]+$/,
|
|
62
|
+
ALPHANUMERIC_WITH_DASH_UNDERSCORE: /^[a-zA-Z0-9_-]+$/,
|
|
63
|
+
ALPHANUMERIC_WITH_SAFE_CHARS: /^[a-zA-Z0-9_.\-]+$/,
|
|
64
|
+
SAFE_IDENTIFIER: /^[a-zA-Z0-9_.\-]+$/, // For IDs, references
|
|
65
|
+
NO_CONTROL_CHARS: /^[^\x00-\x1F\x7F]+$/,
|
|
66
|
+
URL_SAFE: /^[a-zA-Z0-9_.\-~]+$/,
|
|
67
|
+
NUMERIC: /^\d+$/,
|
|
68
|
+
HEX: /^[0-9a-fA-F]+$/,
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Pre-configured validators for common use cases
|
|
72
|
+
*/
|
|
73
|
+
exports.Validators = {
|
|
74
|
+
/**
|
|
75
|
+
* Validates client reference IDs (alphanumeric + safe chars)
|
|
76
|
+
* Returns undefined if not provided
|
|
77
|
+
*/
|
|
78
|
+
clientReferenceId: (value) => validateString(value, {
|
|
79
|
+
required: false,
|
|
80
|
+
maxLength: 255,
|
|
81
|
+
pattern: exports.ValidationPatterns.SAFE_IDENTIFIER,
|
|
82
|
+
patternErrorMessage: "Only letters, numbers, hyphens, underscores, and dots allowed",
|
|
83
|
+
trim: true,
|
|
84
|
+
customValidator: val => {
|
|
85
|
+
// Additional security checks
|
|
86
|
+
const dangerous = /('|"|;|--|\/\*|\*\/|<|>|script)/i;
|
|
87
|
+
if (dangerous.test(val)) {
|
|
88
|
+
return {
|
|
89
|
+
valid: false,
|
|
90
|
+
error: "Contains potentially dangerous characters",
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
return { valid: true };
|
|
94
|
+
},
|
|
95
|
+
}),
|
|
96
|
+
/**
|
|
97
|
+
* Validates alphanumeric strings (letters and numbers only)
|
|
98
|
+
*/
|
|
99
|
+
alphanumeric: (value, required = false) => validateString(value, {
|
|
100
|
+
required,
|
|
101
|
+
pattern: exports.ValidationPatterns.ALPHANUMERIC,
|
|
102
|
+
patternErrorMessage: "Only letters and numbers allowed",
|
|
103
|
+
trim: true,
|
|
104
|
+
}),
|
|
105
|
+
/**
|
|
106
|
+
* Validates wallet addresses (hex format)
|
|
107
|
+
*/
|
|
108
|
+
walletAddress: (value, required = true) => validateString(value, {
|
|
109
|
+
required,
|
|
110
|
+
minLength: 42,
|
|
111
|
+
maxLength: 42,
|
|
112
|
+
pattern: /^0x[a-fA-F0-9]{40}$/,
|
|
113
|
+
patternErrorMessage: "Invalid wallet address format",
|
|
114
|
+
trim: true,
|
|
115
|
+
toLowerCase: true,
|
|
116
|
+
}),
|
|
117
|
+
/**
|
|
118
|
+
* Validates order IDs (UUID format)
|
|
119
|
+
*/
|
|
120
|
+
orderId: (value) => validateString(value, {
|
|
121
|
+
required: false,
|
|
122
|
+
pattern: /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,
|
|
123
|
+
patternErrorMessage: "Invalid order ID format",
|
|
124
|
+
trim: true,
|
|
125
|
+
toLowerCase: true,
|
|
126
|
+
}),
|
|
127
|
+
/**
|
|
128
|
+
* Validates URL-safe strings
|
|
129
|
+
*/
|
|
130
|
+
urlSafe: (value, maxLength = 255) => validateString(value, {
|
|
131
|
+
maxLength,
|
|
132
|
+
pattern: exports.ValidationPatterns.URL_SAFE,
|
|
133
|
+
patternErrorMessage: "Contains invalid URL characters",
|
|
134
|
+
trim: true,
|
|
135
|
+
}),
|
|
136
|
+
/**
|
|
137
|
+
* Validates safe identifiers (no injection risks)
|
|
138
|
+
*/
|
|
139
|
+
safeIdentifier: (value, required = false) => validateString(value, {
|
|
140
|
+
required,
|
|
141
|
+
maxLength: 255,
|
|
142
|
+
pattern: exports.ValidationPatterns.SAFE_IDENTIFIER,
|
|
143
|
+
patternErrorMessage: "Invalid identifier format",
|
|
144
|
+
customValidator: val => {
|
|
145
|
+
// Additional security checks
|
|
146
|
+
const dangerous = /('|"|;|--|\/\*|\*\/|<|>|script)/i;
|
|
147
|
+
if (dangerous.test(val)) {
|
|
148
|
+
return {
|
|
149
|
+
valid: false,
|
|
150
|
+
error: "Contains potentially dangerous characters",
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
return { valid: true };
|
|
154
|
+
},
|
|
155
|
+
trim: true,
|
|
156
|
+
}),
|
|
157
|
+
};
|
|
@@ -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
|
|
@@ -6,6 +6,7 @@ export * from "./utils/json";
|
|
|
6
6
|
export * from "./utils/number";
|
|
7
7
|
export * from "./utils/string";
|
|
8
8
|
export * from "./utils/token";
|
|
9
|
+
export * from "./utils/validation";
|
|
9
10
|
export * from "./constants";
|
|
10
11
|
export * from "./abis/abiUsdcBase";
|
|
11
12
|
export * from "./abis/erc20Staking";
|
|
@@ -34,4 +34,10 @@ export declare function AnySpend(props: {
|
|
|
34
34
|
}) => void;
|
|
35
35
|
onSuccess?: (txHash?: string) => void;
|
|
36
36
|
customUsdInputValues?: string[];
|
|
37
|
+
/**
|
|
38
|
+
* Client-provided reference ID for tracking orders.
|
|
39
|
+
* Must be alphanumeric with optional hyphens, underscores, and dots (max 255 chars).
|
|
40
|
+
* Auto-generates UUID if not provided.
|
|
41
|
+
*/
|
|
42
|
+
clientReferenceId?: string;
|
|
37
43
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { getDefaultToken, USDC_BASE } from "../../../anyspend/index.js";
|
|
4
4
|
import { useAnyspendCreateOnrampOrder, useAnyspendCreateOrder, useAnyspendOrderAndTransactions, useAnyspendQuote, useGeoOnrampOptions, } from "../../../anyspend/react/index.js";
|
|
5
|
+
import { Validators } from "../../../anyspend/utils/validation.js";
|
|
5
6
|
import { Button, ShinyButton, StyleRoot, TransitionPanel, useAccountWallet, useProfile, useRouter, useSearchParamsSSR, useTokenBalanceDirect, useTokenData, useTokenFromUrl, } from "../../../global-account/react/index.js";
|
|
6
7
|
import { cn } from "../../../shared/utils/cn.js";
|
|
7
8
|
import { formatTokenAmount } from "../../../shared/utils/number.js";
|
|
@@ -48,9 +49,18 @@ export function AnySpend(props) {
|
|
|
48
49
|
const fingerprintConfig = getFingerprintConfig();
|
|
49
50
|
return (_jsx(AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: _jsx(AnySpendInner, { ...props }) }));
|
|
50
51
|
}
|
|
51
|
-
function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode = "modal", defaultActiveTab = "crypto", loadOrder, hideTransactionHistoryButton, recipientAddress: recipientAddressFromProps, onTokenSelect, onSuccess, customUsdInputValues, }) {
|
|
52
|
+
function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode = "modal", defaultActiveTab = "crypto", loadOrder, hideTransactionHistoryButton, recipientAddress: recipientAddressFromProps, onTokenSelect, onSuccess, customUsdInputValues, clientReferenceId: clientReferenceIdFromProps, }) {
|
|
52
53
|
const searchParams = useSearchParamsSSR();
|
|
53
54
|
const router = useRouter();
|
|
55
|
+
// Validate and clean clientReferenceId
|
|
56
|
+
const validatedClientReferenceId = useMemo(() => {
|
|
57
|
+
const validation = Validators.clientReferenceId(clientReferenceIdFromProps);
|
|
58
|
+
if (!validation.isValid) {
|
|
59
|
+
console.error(`[AnySpend] Invalid clientReferenceId: ${validation.error || "Validation failed"}. Will be set to undefined.`);
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
return validation.cleaned;
|
|
63
|
+
}, [clientReferenceIdFromProps]);
|
|
54
64
|
// Determine if we're in "buy mode" based on whether destination token props are provided
|
|
55
65
|
const isBuyMode = !!(destinationTokenAddress && destinationTokenChainId);
|
|
56
66
|
// Add refs to track URL state
|
|
@@ -638,6 +648,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
638
648
|
srcAmount: srcAmountBigInt.toString(),
|
|
639
649
|
expectedDstAmount: anyspendQuote?.data?.currencyOut?.amount || "0",
|
|
640
650
|
creatorAddress: globalAddress,
|
|
651
|
+
clientReferenceId: validatedClientReferenceId,
|
|
641
652
|
});
|
|
642
653
|
}
|
|
643
654
|
catch (err) {
|
|
@@ -702,6 +713,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
702
713
|
},
|
|
703
714
|
expectedDstAmount: anyspendQuote?.data?.currencyOut?.amount?.toString() || "0",
|
|
704
715
|
creatorAddress: globalAddress,
|
|
716
|
+
clientReferenceId: validatedClientReferenceId,
|
|
705
717
|
});
|
|
706
718
|
}
|
|
707
719
|
catch (err) {
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import { AnySpendBondKitProps } from "../../../global-account/react/stores/useModalStore";
|
|
2
|
-
export declare function AnySpendBondKit({ mode, recipientAddress, contractAddress, minTokensOut, imageUrl, b3Amount: initialB3Amount, onSuccess, }: AnySpendBondKitProps
|
|
2
|
+
export declare function AnySpendBondKit({ mode, recipientAddress, contractAddress, minTokensOut, imageUrl, b3Amount: initialB3Amount, onSuccess, clientReferenceId, }: AnySpendBondKitProps & {
|
|
3
|
+
clientReferenceId?: string;
|
|
4
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -20,7 +20,7 @@ function formatNumberWithCommas(x) {
|
|
|
20
20
|
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
21
21
|
return parts.join(".");
|
|
22
22
|
}
|
|
23
|
-
export function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddress, minTokensOut = "0", imageUrl, b3Amount: initialB3Amount, onSuccess, }) {
|
|
23
|
+
export function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddress, minTokensOut = "0", imageUrl, b3Amount: initialB3Amount, onSuccess, clientReferenceId, }) {
|
|
24
24
|
const hasMounted = useHasMounted();
|
|
25
25
|
const [showAmountPrompt, setShowAmountPrompt] = useState(!initialB3Amount);
|
|
26
26
|
const [b3Amount, setB3Amount] = useState(initialB3Amount || "");
|
|
@@ -200,5 +200,5 @@ export function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddr
|
|
|
200
200
|
});
|
|
201
201
|
return (_jsx(AnySpendCustom, { mode: mode, recipientAddress: recipientAddress, orderType: "custom", dstChainId: baseMainnet.id, dstToken: dstToken, dstAmount: parseEther(b3Amount).toString(), contractAddress: contractAddress, encodedData: encodedData, metadata: {
|
|
202
202
|
action: "BondKit Buy",
|
|
203
|
-
}, header: header, onSuccess: onSuccess, showRecipient: true }));
|
|
203
|
+
}, header: header, onSuccess: onSuccess, showRecipient: true, clientReferenceId: clientReferenceId }));
|
|
204
204
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function AnySpendBuySpin({ loadOrder, mode, spinwheelContractAddress, chainId, recipientAddress, prefillQuantity, onSuccess, }: {
|
|
1
|
+
export declare function AnySpendBuySpin({ loadOrder, mode, spinwheelContractAddress, chainId, recipientAddress, prefillQuantity, onSuccess, clientReferenceId, }: {
|
|
2
2
|
loadOrder?: string;
|
|
3
3
|
mode?: "modal" | "page";
|
|
4
4
|
spinwheelContractAddress: string;
|
|
@@ -6,4 +6,5 @@ export declare function AnySpendBuySpin({ loadOrder, mode, spinwheelContractAddr
|
|
|
6
6
|
recipientAddress: string;
|
|
7
7
|
prefillQuantity?: string;
|
|
8
8
|
onSuccess?: (txHash?: string) => void;
|
|
9
|
+
clientReferenceId?: string;
|
|
9
10
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -85,7 +85,7 @@ const basePublicClient = createPublicClient({
|
|
|
85
85
|
chain: baseMainnet,
|
|
86
86
|
transport: http(PUBLIC_BASE_RPC_URL),
|
|
87
87
|
});
|
|
88
|
-
export function AnySpendBuySpin({ loadOrder, mode = "modal", spinwheelContractAddress, chainId, recipientAddress, prefillQuantity, onSuccess, }) {
|
|
88
|
+
export function AnySpendBuySpin({ loadOrder, mode = "modal", spinwheelContractAddress, chainId, recipientAddress, prefillQuantity, onSuccess, clientReferenceId, }) {
|
|
89
89
|
const hasMounted = useHasMounted();
|
|
90
90
|
const { setB3ModalOpen } = useModalStore();
|
|
91
91
|
// Payment config state
|
|
@@ -391,5 +391,5 @@ export function AnySpendBuySpin({ loadOrder, mode = "modal", spinwheelContractAd
|
|
|
391
391
|
const encodedData = generateEncodedDataForBuyEntriesAndSpin(address || "", userSpinQuantity);
|
|
392
392
|
return (_jsx(AnySpendCustom, { loadOrder: loadOrder, mode: mode, recipientAddress: recipientAddress, orderType: "custom", dstChainId: chainId, dstToken: B3_TOKEN, dstAmount: totalCost.toString(), contractAddress: spinwheelContractAddress, spenderAddress: paymentConfig.entryModule, encodedData: encodedData, metadata: {
|
|
393
393
|
action: `buy ${userSpinQuantity} spin${userSpinQuantity !== "1" ? "s" : ""}`,
|
|
394
|
-
}, header: header, onSuccess: txHash => onSuccess?.(txHash), showRecipient: false }));
|
|
394
|
+
}, header: header, onSuccess: txHash => onSuccess?.(txHash), showRecipient: false, clientReferenceId: clientReferenceId }));
|
|
395
395
|
}
|
|
@@ -108,7 +108,7 @@ export function AnySpendCustom(props) {
|
|
|
108
108
|
const fingerprintConfig = getFingerprintConfig();
|
|
109
109
|
return (_jsx(AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: _jsx(AnySpendCustomInner, { ...props }) }));
|
|
110
110
|
}
|
|
111
|
-
function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabProps = "crypto", recipientAddress: recipientAddressProps, spenderAddress, orderType, dstChainId, dstToken, dstAmount, contractAddress, encodedData, metadata, header, onSuccess, showRecipient = true, onShowPointsDetail, }) {
|
|
111
|
+
function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabProps = "crypto", recipientAddress: recipientAddressProps, spenderAddress, orderType, dstChainId, dstToken, dstAmount, contractAddress, encodedData, metadata, header, onSuccess, showRecipient = true, onShowPointsDetail, clientReferenceId, }) {
|
|
112
112
|
const hasMounted = useHasMounted();
|
|
113
113
|
const featureFlags = useFeatureFlags();
|
|
114
114
|
const searchParams = useSearchParamsSSR();
|
|
@@ -351,10 +351,14 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
351
351
|
: window.location.origin,
|
|
352
352
|
},
|
|
353
353
|
expectedDstAmount: anyspendQuote?.data?.currencyOut?.amount?.toString() || "0",
|
|
354
|
+
clientReferenceId: clientReferenceId,
|
|
354
355
|
});
|
|
355
356
|
}
|
|
356
357
|
else {
|
|
357
|
-
void createRegularOrder(
|
|
358
|
+
void createRegularOrder({
|
|
359
|
+
...createOrderParams,
|
|
360
|
+
clientReferenceId: clientReferenceId,
|
|
361
|
+
});
|
|
358
362
|
}
|
|
359
363
|
}
|
|
360
364
|
catch (err) {
|
|
@@ -31,6 +31,7 @@ export interface AnySpendCustomExactInProps {
|
|
|
31
31
|
anyspendPrice: GetQuoteResponse | undefined;
|
|
32
32
|
isLoadingAnyspendPrice: boolean;
|
|
33
33
|
}) => React.JSX.Element;
|
|
34
|
+
clientReferenceId?: string;
|
|
34
35
|
}
|
|
35
36
|
export declare function AnySpendCustomExactIn(props: AnySpendCustomExactInProps): import("react/jsx-runtime").JSX.Element;
|
|
36
37
|
export {};
|
|
@@ -25,7 +25,7 @@ export function AnySpendCustomExactIn(props) {
|
|
|
25
25
|
const fingerprintConfig = getFingerprintConfig();
|
|
26
26
|
return (_jsx(AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: _jsx(AnySpendCustomExactInInner, { ...props }) }));
|
|
27
27
|
}
|
|
28
|
-
function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddress, paymentType = "crypto", sourceTokenAddress, sourceTokenChainId, destinationToken, destinationChainId, onSuccess, mainFooter, onTokenSelect, customUsdInputValues, preferEoa, customExactInConfig, orderType = "custom_exact_in", minDestinationAmount, header, }) {
|
|
28
|
+
function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddress, paymentType = "crypto", sourceTokenAddress, sourceTokenChainId, destinationToken, destinationChainId, onSuccess, mainFooter, onTokenSelect, customUsdInputValues, preferEoa, customExactInConfig, orderType = "custom_exact_in", minDestinationAmount, header, clientReferenceId, }) {
|
|
29
29
|
const actionLabel = customExactInConfig?.action ?? "Custom Execution";
|
|
30
30
|
const DESTINATION_TOKEN_DETAILS = {
|
|
31
31
|
SYMBOL: destinationToken.symbol ?? "TOKEN",
|
|
@@ -189,6 +189,7 @@ function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddres
|
|
|
189
189
|
expectedDstAmount: expectedDstAmountRaw,
|
|
190
190
|
creatorAddress: globalAddress,
|
|
191
191
|
payload,
|
|
192
|
+
clientReferenceId: clientReferenceId,
|
|
192
193
|
});
|
|
193
194
|
}
|
|
194
195
|
catch (err) {
|
|
@@ -241,6 +242,7 @@ function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddres
|
|
|
241
242
|
expectedDstAmount: expectedDstAmountRaw,
|
|
242
243
|
creatorAddress: globalAddress,
|
|
243
244
|
payload,
|
|
245
|
+
clientReferenceId: clientReferenceId,
|
|
244
246
|
});
|
|
245
247
|
}
|
|
246
248
|
catch (err) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { components } from "../../../anyspend/types/api";
|
|
2
|
-
export declare function AnySpendDepositUpside({ loadOrder, mode, recipientAddress, sourceTokenAddress, sourceTokenChainId, depositContractAddress, token, onSuccess, }: {
|
|
2
|
+
export declare function AnySpendDepositUpside({ loadOrder, mode, recipientAddress, sourceTokenAddress, sourceTokenChainId, depositContractAddress, token, onSuccess, clientReferenceId, }: {
|
|
3
3
|
loadOrder?: string;
|
|
4
4
|
mode?: "modal" | "page";
|
|
5
5
|
recipientAddress: string;
|
|
@@ -8,4 +8,5 @@ export declare function AnySpendDepositUpside({ loadOrder, mode, recipientAddres
|
|
|
8
8
|
depositContractAddress: string;
|
|
9
9
|
token: components["schemas"]["Token"];
|
|
10
10
|
onSuccess?: (amount: string) => void;
|
|
11
|
+
clientReferenceId?: string;
|
|
11
12
|
}): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -22,7 +22,7 @@ const DEPOSIT_FOR_FUNCTION_ABI = JSON.stringify([
|
|
|
22
22
|
type: "function",
|
|
23
23
|
},
|
|
24
24
|
]);
|
|
25
|
-
export function AnySpendDepositUpside({ loadOrder, mode = "modal", recipientAddress, sourceTokenAddress, sourceTokenChainId, depositContractAddress, token, onSuccess, }) {
|
|
25
|
+
export function AnySpendDepositUpside({ loadOrder, mode = "modal", recipientAddress, sourceTokenAddress, sourceTokenChainId, depositContractAddress, token, onSuccess, clientReferenceId, }) {
|
|
26
26
|
if (!recipientAddress)
|
|
27
27
|
return null;
|
|
28
28
|
const header = () => (_jsx(_Fragment, { children: _jsx("div", { className: "from-b3-react-background to-as-on-surface-1 w-full rounded-t-lg bg-gradient-to-t", children: _jsx("div", { className: "mb-1 flex w-full flex-col items-center gap-2", children: _jsxs("span", { className: "font-sf-rounded text-2xl font-semibold", children: ["Swap & Deposit ", token.symbol] }) }) }) }));
|
|
@@ -34,5 +34,5 @@ export function AnySpendDepositUpside({ loadOrder, mode = "modal", recipientAddr
|
|
|
34
34
|
spenderAddress: depositContractAddress,
|
|
35
35
|
action: `deposit ${token.symbol}`,
|
|
36
36
|
};
|
|
37
|
-
return (_jsx(AnySpendCustomExactIn, { loadOrder: loadOrder, mode: mode, recipientAddress: recipientAddress, sourceTokenAddress: sourceTokenAddress, sourceTokenChainId: sourceTokenChainId, destinationToken: token, destinationChainId: base.id, customExactInConfig: customExactInConfig, header: header, onSuccess: onSuccess }));
|
|
37
|
+
return (_jsx(AnySpendCustomExactIn, { loadOrder: loadOrder, mode: mode, recipientAddress: recipientAddress, sourceTokenAddress: sourceTokenAddress, sourceTokenChainId: sourceTokenChainId, destinationToken: token, destinationChainId: base.id, customExactInConfig: customExactInConfig, header: header, onSuccess: onSuccess, clientReferenceId: clientReferenceId }));
|
|
38
38
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { components } from "../../../anyspend/types/api";
|
|
2
|
-
export declare function AnySpendNFT({ loadOrder, mode, recipientAddress, nftContract, onSuccess, onShowPointsDetail, }: {
|
|
2
|
+
export declare function AnySpendNFT({ loadOrder, mode, recipientAddress, nftContract, onSuccess, onShowPointsDetail, clientReferenceId, }: {
|
|
3
3
|
loadOrder?: string;
|
|
4
4
|
mode?: "modal" | "page";
|
|
5
5
|
recipientAddress?: string;
|
|
6
6
|
nftContract: components["schemas"]["NftContract"];
|
|
7
7
|
onSuccess?: (txHash?: string) => void;
|
|
8
8
|
onShowPointsDetail?: () => void;
|
|
9
|
+
clientReferenceId?: string;
|
|
9
10
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -26,7 +26,7 @@ const CONTRACT_URI_ABI = [
|
|
|
26
26
|
type: "function",
|
|
27
27
|
},
|
|
28
28
|
];
|
|
29
|
-
export function AnySpendNFT({ loadOrder, mode = "modal", recipientAddress, nftContract, onSuccess, onShowPointsDetail, }) {
|
|
29
|
+
export function AnySpendNFT({ loadOrder, mode = "modal", recipientAddress, nftContract, onSuccess, onShowPointsDetail, clientReferenceId, }) {
|
|
30
30
|
const [imageUrlWithFallback, setFallbackImageUrl] = useState(nftContract.imageUrl);
|
|
31
31
|
const [isLoadingFallback, setIsLoadingFallback] = useState(false);
|
|
32
32
|
// Fetch contract metadata when imageUrl is empty
|
|
@@ -86,7 +86,7 @@ export function AnySpendNFT({ loadOrder, mode = "modal", recipientAddress, nftCo
|
|
|
86
86
|
return (_jsx(AnySpendCustom, { loadOrder: loadOrder, mode: mode, activeTab: "fiat", recipientAddress: recipientAddress, orderType: "mint_nft", dstChainId: nftContract.chainId, dstToken: nftContract.currency, dstAmount: nftContract.price, contractAddress: nftContract.contractAddress, encodedData: "0x", metadata: {
|
|
87
87
|
type: "mint_nft",
|
|
88
88
|
nftContract: nftContract,
|
|
89
|
-
}, header: header, onSuccess: onSuccess, onShowPointsDetail: onShowPointsDetail }));
|
|
89
|
+
}, header: header, onSuccess: onSuccess, onShowPointsDetail: onShowPointsDetail, clientReferenceId: clientReferenceId }));
|
|
90
90
|
}
|
|
91
91
|
function DropdownMenu({ nftContract }) {
|
|
92
92
|
const [open, setOpen] = useState(false);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export declare function AnySpendStakeB3({ loadOrder, mode, recipientAddress, stakeAmount, onSuccess, }: {
|
|
1
|
+
export declare function AnySpendStakeB3({ loadOrder, mode, recipientAddress, stakeAmount, onSuccess, clientReferenceId, }: {
|
|
2
2
|
loadOrder?: string;
|
|
3
3
|
mode?: "modal" | "page";
|
|
4
4
|
recipientAddress: string;
|
|
5
5
|
stakeAmount?: string;
|
|
6
6
|
onSuccess?: () => void;
|
|
7
|
+
clientReferenceId?: string;
|
|
7
8
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -29,7 +29,7 @@ function generateEncodedDataForStakingB3(amount, beneficiary) {
|
|
|
29
29
|
});
|
|
30
30
|
return encodedData;
|
|
31
31
|
}
|
|
32
|
-
export function AnySpendStakeB3({ loadOrder, mode = "modal", recipientAddress, stakeAmount, onSuccess, }) {
|
|
32
|
+
export function AnySpendStakeB3({ loadOrder, mode = "modal", recipientAddress, stakeAmount, onSuccess, clientReferenceId, }) {
|
|
33
33
|
const hasMounted = useHasMounted();
|
|
34
34
|
const { setB3ModalOpen } = useModalStore();
|
|
35
35
|
// Wagmi hooks for direct staking
|
|
@@ -271,5 +271,5 @@ export function AnySpendStakeB3({ loadOrder, mode = "modal", recipientAddress, s
|
|
|
271
271
|
const encodedData = generateEncodedDataForStakingB3(userStakeAmount, recipientAddress);
|
|
272
272
|
return (_jsx(AnySpendCustom, { loadOrder: loadOrder, mode: mode, recipientAddress: recipientAddress, orderType: "custom", dstChainId: base.id, dstToken: B3_TOKEN, dstAmount: userStakeAmount, contractAddress: ERC20Staking, encodedData: encodedData, metadata: {
|
|
273
273
|
action: "stake B3",
|
|
274
|
-
}, header: header, onSuccess: onSuccess, showRecipient: true }));
|
|
274
|
+
}, header: header, onSuccess: onSuccess, showRecipient: true, clientReferenceId: clientReferenceId }));
|
|
275
275
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function AnySpendStakeB3ExactIn({ loadOrder, mode, sourceTokenAddress, sourceTokenChainId, recipientAddress, stakeAmount, onSuccess, }: {
|
|
1
|
+
export declare function AnySpendStakeB3ExactIn({ loadOrder, mode, sourceTokenAddress, sourceTokenChainId, recipientAddress, stakeAmount, onSuccess, clientReferenceId, }: {
|
|
2
2
|
loadOrder?: string;
|
|
3
3
|
mode?: "modal" | "page";
|
|
4
4
|
sourceTokenAddress?: string;
|
|
@@ -6,4 +6,5 @@ export declare function AnySpendStakeB3ExactIn({ loadOrder, mode, sourceTokenAdd
|
|
|
6
6
|
recipientAddress: string;
|
|
7
7
|
stakeAmount?: string;
|
|
8
8
|
onSuccess?: (amount: string) => void;
|
|
9
|
+
clientReferenceId?: string;
|
|
9
10
|
}): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -32,7 +32,7 @@ const STAKE_FUNCTION_ABI = JSON.stringify([
|
|
|
32
32
|
outputs: [],
|
|
33
33
|
},
|
|
34
34
|
]);
|
|
35
|
-
export function AnySpendStakeB3ExactIn({ loadOrder, mode = "modal", sourceTokenAddress, sourceTokenChainId, recipientAddress, stakeAmount, onSuccess, }) {
|
|
35
|
+
export function AnySpendStakeB3ExactIn({ loadOrder, mode = "modal", sourceTokenAddress, sourceTokenChainId, recipientAddress, stakeAmount, onSuccess, clientReferenceId, }) {
|
|
36
36
|
const hasMounted = useHasMounted();
|
|
37
37
|
const { setB3ModalOpen } = useModalStore();
|
|
38
38
|
// Wagmi hooks for direct staking
|
|
@@ -281,5 +281,5 @@ export function AnySpendStakeB3ExactIn({ loadOrder, mode = "modal", sourceTokenA
|
|
|
281
281
|
onSuccess?.(formatTokenAmount(BigInt(userStakeAmount), 18) ?? "");
|
|
282
282
|
}, className: "bg-as-brand hover:bg-as-brand/90 text-as-primary h-14 w-full rounded-xl text-lg font-medium", children: "Done" })] })] }) }));
|
|
283
283
|
}
|
|
284
|
-
return (_jsx(AnySpendCustomExactIn, { loadOrder: loadOrder, mode: mode, recipientAddress: recipientAddress, sourceTokenAddress: sourceTokenAddress, sourceTokenChainId: sourceTokenChainId, destinationToken: B3_TOKEN, destinationChainId: base.id, customExactInConfig: customExactInConfig, header: header, onSuccess: onSuccess }));
|
|
284
|
+
return (_jsx(AnySpendCustomExactIn, { loadOrder: loadOrder, mode: mode, recipientAddress: recipientAddress, sourceTokenAddress: sourceTokenAddress, sourceTokenChainId: sourceTokenChainId, destinationToken: B3_TOKEN, destinationChainId: base.id, customExactInConfig: customExactInConfig, header: header, onSuccess: onSuccess, clientReferenceId: clientReferenceId }));
|
|
285
285
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { components } from "../../../anyspend/types/api";
|
|
2
|
-
export declare function AnySpendStakeUpside({ loadOrder, mode, beneficiaryAddress, stakeAmount, stakingContractAddress, token, onSuccess, activeTab, }: {
|
|
2
|
+
export declare function AnySpendStakeUpside({ loadOrder, mode, beneficiaryAddress, stakeAmount, stakingContractAddress, token, onSuccess, activeTab, clientReferenceId, }: {
|
|
3
3
|
loadOrder?: string;
|
|
4
4
|
mode?: "modal" | "page";
|
|
5
5
|
beneficiaryAddress: string;
|
|
@@ -8,4 +8,5 @@ export declare function AnySpendStakeUpside({ loadOrder, mode, beneficiaryAddres
|
|
|
8
8
|
token: components["schemas"]["Token"];
|
|
9
9
|
onSuccess?: () => void;
|
|
10
10
|
activeTab?: "crypto" | "fiat";
|
|
11
|
+
clientReferenceId?: string;
|
|
11
12
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -14,7 +14,7 @@ function generateEncodedDataForStaking(amount, beneficiary) {
|
|
|
14
14
|
args: [beneficiary, BigInt(amount)],
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
|
-
export function AnySpendStakeUpside({ loadOrder, mode = "modal", beneficiaryAddress, stakeAmount, stakingContractAddress, token, onSuccess, activeTab, }) {
|
|
17
|
+
export function AnySpendStakeUpside({ loadOrder, mode = "modal", beneficiaryAddress, stakeAmount, stakingContractAddress, token, onSuccess, activeTab, clientReferenceId, }) {
|
|
18
18
|
const header = () => (_jsx(_Fragment, { children: _jsxs("div", { className: "from-b3-react-background to-as-on-surface-1 mt-[-60px] w-full rounded-t-lg bg-gradient-to-t", children: [_jsx("div", { className: "h-[60px] w-full" }), _jsx("div", { className: "mb-1 flex w-full flex-col items-center gap-2 p-5", children: _jsxs("span", { className: "font-sf-rounded text-2xl font-semibold", children: ["Swap & Stake ", stakeAmount ? formatTokenAmount(BigInt(stakeAmount), token.decimals) : "", " ", token.symbol] }) })] }) }));
|
|
19
19
|
// Only generate encoded data if we have a valid beneficiary address
|
|
20
20
|
// This is used for the AnySpendCustom swap & stake flow
|
|
@@ -24,5 +24,5 @@ export function AnySpendStakeUpside({ loadOrder, mode = "modal", beneficiaryAddr
|
|
|
24
24
|
const encodedData = generateEncodedDataForStaking(stakeAmount, beneficiaryAddress);
|
|
25
25
|
return (_jsx(AnySpendCustom, { loadOrder: loadOrder, mode: mode, recipientAddress: beneficiaryAddress, orderType: "custom", dstChainId: base.id, dstToken: token, dstAmount: stakeAmount, contractAddress: stakingContractAddress, encodedData: encodedData, metadata: {
|
|
26
26
|
action: `stake ${token.symbol}`,
|
|
27
|
-
}, header: header, onSuccess: onSuccess, showRecipient: true, activeTab: activeTab }));
|
|
27
|
+
}, header: header, onSuccess: onSuccess, showRecipient: true, activeTab: activeTab, clientReferenceId: clientReferenceId }));
|
|
28
28
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { components } from "../../../anyspend/types/api";
|
|
2
|
-
export declare function AnySpendStakeUpsideExactIn({ loadOrder, mode, recipientAddress, sourceTokenAddress, sourceTokenChainId, stakingContractAddress, token, onSuccess, }: {
|
|
2
|
+
export declare function AnySpendStakeUpsideExactIn({ loadOrder, mode, recipientAddress, sourceTokenAddress, sourceTokenChainId, stakingContractAddress, token, onSuccess, clientReferenceId, }: {
|
|
3
3
|
loadOrder?: string;
|
|
4
4
|
mode?: "modal" | "page";
|
|
5
5
|
recipientAddress: string;
|
|
@@ -8,4 +8,5 @@ export declare function AnySpendStakeUpsideExactIn({ loadOrder, mode, recipientA
|
|
|
8
8
|
stakingContractAddress: string;
|
|
9
9
|
token: components["schemas"]["Token"];
|
|
10
10
|
onSuccess?: (amount: string) => void;
|
|
11
|
+
clientReferenceId?: string;
|
|
11
12
|
}): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -14,7 +14,7 @@ const STAKE_FOR_FUNCTION_ABI = JSON.stringify([
|
|
|
14
14
|
outputs: [],
|
|
15
15
|
},
|
|
16
16
|
]);
|
|
17
|
-
export function AnySpendStakeUpsideExactIn({ loadOrder, mode = "modal", recipientAddress, sourceTokenAddress, sourceTokenChainId, stakingContractAddress, token, onSuccess, }) {
|
|
17
|
+
export function AnySpendStakeUpsideExactIn({ loadOrder, mode = "modal", recipientAddress, sourceTokenAddress, sourceTokenChainId, stakingContractAddress, token, onSuccess, clientReferenceId, }) {
|
|
18
18
|
if (!recipientAddress)
|
|
19
19
|
return null;
|
|
20
20
|
const header = () => (_jsx(_Fragment, { children: _jsx("div", { className: "from-b3-react-background to-as-on-surface-1 w-full rounded-t-lg bg-gradient-to-t", children: _jsx("div", { className: "mb-1 flex w-full flex-col items-center gap-2", children: _jsxs("span", { className: "font-sf-rounded text-2xl font-semibold", children: ["Swap & Stake ", token.symbol, " (Exact In)"] }) }) }) }));
|
|
@@ -26,5 +26,5 @@ export function AnySpendStakeUpsideExactIn({ loadOrder, mode = "modal", recipien
|
|
|
26
26
|
spenderAddress: stakingContractAddress,
|
|
27
27
|
action: `stake ${token.symbol}`,
|
|
28
28
|
};
|
|
29
|
-
return (_jsx(AnySpendCustomExactIn, { loadOrder: loadOrder, mode: mode, recipientAddress: recipientAddress, sourceTokenAddress: sourceTokenAddress, sourceTokenChainId: sourceTokenChainId, destinationToken: token, destinationChainId: base.id, customExactInConfig: customExactInConfig, header: header, onSuccess: onSuccess }));
|
|
29
|
+
return (_jsx(AnySpendCustomExactIn, { loadOrder: loadOrder, mode: mode, recipientAddress: recipientAddress, sourceTokenAddress: sourceTokenAddress, sourceTokenChainId: sourceTokenChainId, destinationToken: token, destinationChainId: base.id, customExactInConfig: customExactInConfig, header: header, onSuccess: onSuccess, clientReferenceId: clientReferenceId }));
|
|
30
30
|
}
|
|
@@ -10,6 +10,7 @@ type AnySpendTournamentProps = {
|
|
|
10
10
|
tournamentEntryToken: components["schemas"]["Token"];
|
|
11
11
|
tournamentEntryFee: string;
|
|
12
12
|
onSuccess?: () => void;
|
|
13
|
+
clientReferenceId?: string;
|
|
13
14
|
} | {
|
|
14
15
|
mode?: "modal" | "page";
|
|
15
16
|
action: "fund";
|
|
@@ -20,6 +21,7 @@ type AnySpendTournamentProps = {
|
|
|
20
21
|
tournamentFundToken: components["schemas"]["Token"];
|
|
21
22
|
tournamentFundAmount: string;
|
|
22
23
|
onSuccess?: () => void;
|
|
24
|
+
clientReferenceId?: string;
|
|
23
25
|
};
|
|
24
26
|
export declare function AnySpendTournament(props: AnySpendTournamentProps): import("react/jsx-runtime").JSX.Element;
|
|
25
27
|
export {};
|