@one_deploy/sdk 1.0.0

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.
Files changed (83) hide show
  1. package/.turbo/turbo-build.log +0 -0
  2. package/.turbo/turbo-type-check.log +0 -0
  3. package/dist/config/index.d.mts +74 -0
  4. package/dist/config/index.d.ts +74 -0
  5. package/dist/config/index.js +242 -0
  6. package/dist/config/index.js.map +1 -0
  7. package/dist/config/index.mjs +224 -0
  8. package/dist/config/index.mjs.map +1 -0
  9. package/dist/engine-5ndtBaCr.d.ts +1039 -0
  10. package/dist/engine-CrlhH0nw.d.mts +1039 -0
  11. package/dist/hooks/index.d.mts +56 -0
  12. package/dist/hooks/index.d.ts +56 -0
  13. package/dist/hooks/index.js +1360 -0
  14. package/dist/hooks/index.js.map +1 -0
  15. package/dist/hooks/index.mjs +1356 -0
  16. package/dist/hooks/index.mjs.map +1 -0
  17. package/dist/index.d.mts +356 -0
  18. package/dist/index.d.ts +356 -0
  19. package/dist/index.js +5068 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/index.mjs +4949 -0
  22. package/dist/index.mjs.map +1 -0
  23. package/dist/price-CgqXPnT3.d.ts +13 -0
  24. package/dist/price-ClbLHHjv.d.mts +13 -0
  25. package/dist/providers/index.d.mts +121 -0
  26. package/dist/providers/index.d.ts +121 -0
  27. package/dist/providers/index.js +1642 -0
  28. package/dist/providers/index.js.map +1 -0
  29. package/dist/providers/index.mjs +1600 -0
  30. package/dist/providers/index.mjs.map +1 -0
  31. package/dist/react-native.d.mts +120 -0
  32. package/dist/react-native.d.ts +120 -0
  33. package/dist/react-native.js +1792 -0
  34. package/dist/react-native.js.map +1 -0
  35. package/dist/react-native.mjs +1755 -0
  36. package/dist/react-native.mjs.map +1 -0
  37. package/dist/services/index.d.mts +85 -0
  38. package/dist/services/index.d.ts +85 -0
  39. package/dist/services/index.js +1466 -0
  40. package/dist/services/index.js.map +1 -0
  41. package/dist/services/index.mjs +1458 -0
  42. package/dist/services/index.mjs.map +1 -0
  43. package/dist/types/index.d.mts +759 -0
  44. package/dist/types/index.d.ts +759 -0
  45. package/dist/types/index.js +4 -0
  46. package/dist/types/index.js.map +1 -0
  47. package/dist/types/index.mjs +3 -0
  48. package/dist/types/index.mjs.map +1 -0
  49. package/dist/utils/index.d.mts +36 -0
  50. package/dist/utils/index.d.ts +36 -0
  51. package/dist/utils/index.js +164 -0
  52. package/dist/utils/index.js.map +1 -0
  53. package/dist/utils/index.mjs +142 -0
  54. package/dist/utils/index.mjs.map +1 -0
  55. package/package.json +101 -0
  56. package/src/components/OneConnectButton.tsx +143 -0
  57. package/src/components/OneNFTGallery.tsx +324 -0
  58. package/src/components/OneOfframpWidget.tsx +660 -0
  59. package/src/components/OneOnrampWidget.tsx +596 -0
  60. package/src/components/OnePayWidget.tsx +160 -0
  61. package/src/components/OneReceiveWidget.tsx +272 -0
  62. package/src/components/OneSendWidget.tsx +248 -0
  63. package/src/components/OneSwapWidget.tsx +715 -0
  64. package/src/components/OneTransactionButton.tsx +150 -0
  65. package/src/components/OneWalletBalance.tsx +354 -0
  66. package/src/components/index.ts +24 -0
  67. package/src/config/index.ts +299 -0
  68. package/src/hooks/index.ts +2 -0
  69. package/src/hooks/useTokenPrice.ts +162 -0
  70. package/src/hooks/useWalletBalance.ts +98 -0
  71. package/src/index.ts +193 -0
  72. package/src/providers/OneProvider.tsx +452 -0
  73. package/src/providers/ThirdwebProvider.tsx +203 -0
  74. package/src/providers/index.ts +26 -0
  75. package/src/react-native.ts +378 -0
  76. package/src/services/engine.ts +1854 -0
  77. package/src/services/index.ts +30 -0
  78. package/src/services/price.ts +164 -0
  79. package/src/services/supabase.ts +180 -0
  80. package/src/types/index.ts +887 -0
  81. package/src/utils/index.ts +200 -0
  82. package/tsconfig.json +22 -0
  83. package/tsup.config.ts +25 -0
@@ -0,0 +1,200 @@
1
+ // ===== Address Utilities =====
2
+ export function shortenAddress(address: string, chars = 4): string {
3
+ if (!address) return '';
4
+ return `${address.slice(0, chars + 2)}...${address.slice(-chars)}`;
5
+ }
6
+
7
+ export function isValidAddress(address: string): boolean {
8
+ return /^0x[a-fA-F0-9]{40}$/.test(address);
9
+ }
10
+
11
+ export function checksumAddress(address: string): string {
12
+ // Basic checksum - for proper checksum use ethers/viem
13
+ return address.toLowerCase();
14
+ }
15
+
16
+ // ===== Number Formatting =====
17
+ export function formatNumber(
18
+ value: number,
19
+ options: {
20
+ decimals?: number;
21
+ compact?: boolean;
22
+ currency?: string;
23
+ locale?: string;
24
+ } = {}
25
+ ): string {
26
+ const { decimals = 2, compact = false, currency, locale = 'en-US' } = options;
27
+
28
+ if (currency) {
29
+ return new Intl.NumberFormat(locale, {
30
+ style: 'currency',
31
+ currency,
32
+ minimumFractionDigits: decimals,
33
+ maximumFractionDigits: decimals,
34
+ notation: compact ? 'compact' : 'standard',
35
+ }).format(value);
36
+ }
37
+
38
+ return new Intl.NumberFormat(locale, {
39
+ minimumFractionDigits: decimals,
40
+ maximumFractionDigits: decimals,
41
+ notation: compact ? 'compact' : 'standard',
42
+ }).format(value);
43
+ }
44
+
45
+ export function formatUSD(value: number, compact = false): string {
46
+ return formatNumber(value, { currency: 'USD', compact });
47
+ }
48
+
49
+ export function formatPercent(value: number, decimals = 2): string {
50
+ const sign = value >= 0 ? '+' : '';
51
+ return `${sign}${value.toFixed(decimals)}%`;
52
+ }
53
+
54
+ export function formatTokenAmount(amount: number, decimals = 6): string {
55
+ if (amount === 0) return '0';
56
+ if (amount < 0.000001) return '<0.000001';
57
+ if (amount < 1) return amount.toFixed(decimals);
58
+ if (amount < 1000) return amount.toFixed(4);
59
+ if (amount < 1000000) return formatNumber(amount, { decimals: 2 });
60
+ return formatNumber(amount, { decimals: 2, compact: true });
61
+ }
62
+
63
+ // ===== Date & Time Utilities =====
64
+ export function formatDate(
65
+ date: string | Date,
66
+ options: Intl.DateTimeFormatOptions = {
67
+ year: 'numeric',
68
+ month: 'short',
69
+ day: 'numeric',
70
+ }
71
+ ): string {
72
+ const d = typeof date === 'string' ? new Date(date) : date;
73
+ return d.toLocaleDateString('en-US', options);
74
+ }
75
+
76
+ export function formatDateTime(date: string | Date): string {
77
+ const d = typeof date === 'string' ? new Date(date) : date;
78
+ return d.toLocaleString('en-US', {
79
+ year: 'numeric',
80
+ month: 'short',
81
+ day: 'numeric',
82
+ hour: '2-digit',
83
+ minute: '2-digit',
84
+ });
85
+ }
86
+
87
+ export function formatRelativeTime(date: string | Date): string {
88
+ const d = typeof date === 'string' ? new Date(date) : date;
89
+ const now = new Date();
90
+ const diffMs = now.getTime() - d.getTime();
91
+ const diffSec = Math.floor(diffMs / 1000);
92
+ const diffMin = Math.floor(diffSec / 60);
93
+ const diffHour = Math.floor(diffMin / 60);
94
+ const diffDay = Math.floor(diffHour / 24);
95
+
96
+ if (diffSec < 60) return 'just now';
97
+ if (diffMin < 60) return `${diffMin}m ago`;
98
+ if (diffHour < 24) return `${diffHour}h ago`;
99
+ if (diffDay < 7) return `${diffDay}d ago`;
100
+
101
+ return formatDate(d);
102
+ }
103
+
104
+ // ===== Validation Utilities =====
105
+ export function isValidEmail(email: string): boolean {
106
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
107
+ return emailRegex.test(email);
108
+ }
109
+
110
+ export function isValidPhone(phone: string): boolean {
111
+ const phoneRegex = /^\+?[1-9]\d{1,14}$/;
112
+ return phoneRegex.test(phone.replace(/[\s-()]/g, ''));
113
+ }
114
+
115
+ // ===== String Utilities =====
116
+ export function capitalize(str: string): string {
117
+ return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
118
+ }
119
+
120
+ export function truncate(str: string, length: number): string {
121
+ if (str.length <= length) return str;
122
+ return `${str.slice(0, length)}...`;
123
+ }
124
+
125
+ export function slugify(str: string): string {
126
+ return str
127
+ .toLowerCase()
128
+ .replace(/[^a-z0-9]+/g, '-')
129
+ .replace(/(^-|-$)/g, '');
130
+ }
131
+
132
+ // ===== Async Utilities =====
133
+ export function sleep(ms: number): Promise<void> {
134
+ return new Promise((resolve) => setTimeout(resolve, ms));
135
+ }
136
+
137
+ export async function retry<T>(
138
+ fn: () => Promise<T>,
139
+ options: { maxAttempts?: number; delay?: number; backoff?: number } = {}
140
+ ): Promise<T> {
141
+ const { maxAttempts = 3, delay = 1000, backoff = 2 } = options;
142
+
143
+ let lastError: Error | undefined;
144
+
145
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
146
+ try {
147
+ return await fn();
148
+ } catch (error) {
149
+ lastError = error instanceof Error ? error : new Error(String(error));
150
+
151
+ if (attempt < maxAttempts) {
152
+ await sleep(delay * Math.pow(backoff, attempt - 1));
153
+ }
154
+ }
155
+ }
156
+
157
+ throw lastError;
158
+ }
159
+
160
+ // ===== Object Utilities =====
161
+ export function omit<T extends Record<string, any>, K extends keyof T>(
162
+ obj: T,
163
+ keys: K[]
164
+ ): Omit<T, K> {
165
+ const result = { ...obj };
166
+ for (const key of keys) {
167
+ delete result[key];
168
+ }
169
+ return result;
170
+ }
171
+
172
+ export function pick<T extends Record<string, any>, K extends keyof T>(
173
+ obj: T,
174
+ keys: K[]
175
+ ): Pick<T, K> {
176
+ const result = {} as Pick<T, K>;
177
+ for (const key of keys) {
178
+ if (key in obj) {
179
+ result[key] = obj[key];
180
+ }
181
+ }
182
+ return result;
183
+ }
184
+
185
+ // ===== Error Handling =====
186
+ export class OneSDKError extends Error {
187
+ code: string;
188
+ details?: any;
189
+
190
+ constructor(message: string, code: string, details?: any) {
191
+ super(message);
192
+ this.name = 'OneSDKError';
193
+ this.code = code;
194
+ this.details = details;
195
+ }
196
+ }
197
+
198
+ export function isOneSDKError(error: unknown): error is OneSDKError {
199
+ return error instanceof OneSDKError;
200
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
5
+ "module": "ESNext",
6
+ "moduleResolution": "bundler",
7
+ "jsx": "react-jsx",
8
+ "declaration": true,
9
+ "declarationMap": true,
10
+ "sourceMap": true,
11
+ "outDir": "./dist",
12
+ "rootDir": "./src",
13
+ "strict": true,
14
+ "esModuleInterop": true,
15
+ "skipLibCheck": true,
16
+ "forceConsistentCasingInFileNames": true,
17
+ "resolveJsonModule": true,
18
+ "isolatedModules": true
19
+ },
20
+ "include": ["src/**/*"],
21
+ "exclude": ["node_modules", "dist"]
22
+ }
package/tsup.config.ts ADDED
@@ -0,0 +1,25 @@
1
+ import { defineConfig } from 'tsup';
2
+
3
+ export default defineConfig({
4
+ entry: {
5
+ index: 'src/index.ts',
6
+ 'services/index': 'src/services/index.ts',
7
+ 'types/index': 'src/types/index.ts',
8
+ 'utils/index': 'src/utils/index.ts',
9
+ 'config/index': 'src/config/index.ts',
10
+ 'providers/index': 'src/providers/index.ts',
11
+ 'hooks/index': 'src/hooks/index.ts',
12
+ 'react-native': 'src/react-native.ts',
13
+ },
14
+ format: ['cjs', 'esm'],
15
+ dts: true,
16
+ splitting: false,
17
+ sourcemap: true,
18
+ clean: true,
19
+ external: ['react', 'react-native', 'react-dom'],
20
+ treeshake: true,
21
+ minify: false,
22
+ banner: {
23
+ js: '"use client";',
24
+ },
25
+ });