keynesol-shared 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.
- package/README.md +118 -0
- package/dist/components/Common/ErrorBoundary.d.ts +23 -0
- package/dist/components/Common/ErrorBoundary.d.ts.map +1 -0
- package/dist/components/Common/ErrorBoundary.js +93 -0
- package/dist/components/Common/ErrorBoundary.jsx +103 -0
- package/dist/components/Common/ErrorMessage.d.ts +8 -0
- package/dist/components/Common/ErrorMessage.d.ts.map +1 -0
- package/dist/components/Common/ErrorMessage.js +36 -0
- package/dist/components/Common/ErrorMessage.jsx +40 -0
- package/dist/components/Common/Loading.d.ts +8 -0
- package/dist/components/Common/Loading.d.ts.map +1 -0
- package/dist/components/Common/Loading.js +41 -0
- package/dist/components/Common/Loading.jsx +44 -0
- package/dist/components/Common/LoadingIndicator.d.ts +17 -0
- package/dist/components/Common/LoadingIndicator.d.ts.map +1 -0
- package/dist/components/Common/LoadingIndicator.js +95 -0
- package/dist/components/Common/LoadingIndicator.jsx +108 -0
- package/dist/components/Common/ProgramStatus.d.ts +3 -0
- package/dist/components/Common/ProgramStatus.d.ts.map +1 -0
- package/dist/components/Common/ProgramStatus.js +26 -0
- package/dist/components/Common/ProgramStatus.jsx +27 -0
- package/dist/components/Common/Skeleton.d.ts +39 -0
- package/dist/components/Common/Skeleton.d.ts.map +1 -0
- package/dist/components/Common/Skeleton.js +53 -0
- package/dist/components/Common/Skeleton.jsx +67 -0
- package/dist/components/Common/SkeletonScreen.d.ts +18 -0
- package/dist/components/Common/SkeletonScreen.d.ts.map +1 -0
- package/dist/components/Common/SkeletonScreen.js +98 -0
- package/dist/components/Common/SkeletonScreen.jsx +108 -0
- package/dist/components/Common/index.d.ts +11 -0
- package/dist/components/Common/index.d.ts.map +1 -0
- package/dist/components/Common/index.js +10 -0
- package/dist/components/Wallet/TransactionStatus.d.ts +11 -0
- package/dist/components/Wallet/TransactionStatus.d.ts.map +1 -0
- package/dist/components/Wallet/TransactionStatus.js +97 -0
- package/dist/components/Wallet/TransactionStatus.jsx +106 -0
- package/dist/components/Wallet/WalletBalance.d.ts +4 -0
- package/dist/components/Wallet/WalletBalance.d.ts.map +1 -0
- package/dist/components/Wallet/WalletBalance.js +82 -0
- package/dist/components/Wallet/WalletBalance.jsx +86 -0
- package/dist/components/Wallet/WalletButton.d.ts +3 -0
- package/dist/components/Wallet/WalletButton.d.ts.map +1 -0
- package/dist/components/Wallet/WalletButton.js +51 -0
- package/dist/components/Wallet/WalletButton.jsx +53 -0
- package/dist/components/Wallet/WalletConnectionModal.d.ts +8 -0
- package/dist/components/Wallet/WalletConnectionModal.d.ts.map +1 -0
- package/dist/components/Wallet/WalletConnectionModal.js +150 -0
- package/dist/components/Wallet/WalletConnectionModal.jsx +170 -0
- package/dist/components/Wallet/WalletProvider.d.ts +9 -0
- package/dist/components/Wallet/WalletProvider.d.ts.map +1 -0
- package/dist/components/Wallet/WalletProvider.js +70 -0
- package/dist/components/Wallet/WalletProvider.jsx +75 -0
- package/dist/components/Wallet/index.d.ts +9 -0
- package/dist/components/Wallet/index.d.ts.map +1 -0
- package/dist/components/Wallet/index.js +8 -0
- package/dist/components/index.d.ts +7 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +6 -0
- package/dist/hooks/index.d.ts +10 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +9 -0
- package/dist/hooks/useCache.d.ts +16 -0
- package/dist/hooks/useCache.d.ts.map +1 -0
- package/dist/hooks/useCache.js +67 -0
- package/dist/hooks/usePolling.d.ts +16 -0
- package/dist/hooks/usePolling.d.ts.map +1 -0
- package/dist/hooks/usePolling.js +79 -0
- package/dist/hooks/useProgram.d.ts +14 -0
- package/dist/hooks/useProgram.d.ts.map +1 -0
- package/dist/hooks/useProgram.js +88 -0
- package/dist/hooks/useTokenBalance.d.ts +16 -0
- package/dist/hooks/useTokenBalance.d.ts.map +1 -0
- package/dist/hooks/useTokenBalance.js +100 -0
- package/dist/hooks/useVaults.d.ts +23 -0
- package/dist/hooks/useVaults.d.ts.map +1 -0
- package/dist/hooks/useVaults.js +98 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/services/index.d.ts +7 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +6 -0
- package/dist/services/reconciliationService.d.ts +76 -0
- package/dist/services/reconciliationService.d.ts.map +1 -0
- package/dist/services/reconciliationService.js +216 -0
- package/dist/services/syncService.d.ts +51 -0
- package/dist/services/syncService.d.ts.map +1 -0
- package/dist/services/syncService.js +218 -0
- package/dist/types/index.d.ts +201 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +1 -0
- package/dist/utils/cacheManager.d.ts +73 -0
- package/dist/utils/cacheManager.d.ts.map +1 -0
- package/dist/utils/cacheManager.js +232 -0
- package/dist/utils/errorHandler.d.ts +76 -0
- package/dist/utils/errorHandler.d.ts.map +1 -0
- package/dist/utils/errorHandler.js +267 -0
- package/dist/utils/index.d.ts +12 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +11 -0
- package/dist/utils/performanceMonitor.d.ts +75 -0
- package/dist/utils/performanceMonitor.d.ts.map +1 -0
- package/dist/utils/performanceMonitor.js +197 -0
- package/dist/utils/rpcRetry.d.ts +12 -0
- package/dist/utils/rpcRetry.d.ts.map +1 -0
- package/dist/utils/rpcRetry.js +47 -0
- package/dist/utils/supabase.d.ts +198 -0
- package/dist/utils/supabase.d.ts.map +1 -0
- package/dist/utils/supabase.js +50 -0
- package/dist/utils/toastService.d.ts +52 -0
- package/dist/utils/toastService.d.ts.map +1 -0
- package/dist/utils/toastService.js +139 -0
- package/dist/utils/tokenUtils.d.ts +33 -0
- package/dist/utils/tokenUtils.d.ts.map +1 -0
- package/dist/utils/tokenUtils.js +66 -0
- package/dist/utils/validation.d.ts +35 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +83 -0
- package/package.json +45 -0
- package/src/components/Common/ErrorBoundary.tsx +135 -0
- package/src/components/Common/ErrorMessage.tsx +52 -0
- package/src/components/Common/Loading.tsx +56 -0
- package/src/components/Common/LoadingIndicator.tsx +143 -0
- package/src/components/Common/ProgramStatus.tsx +37 -0
- package/src/components/Common/Skeleton.tsx +83 -0
- package/src/components/Common/SkeletonScreen.tsx +166 -0
- package/src/components/Common/index.ts +10 -0
- package/src/components/Wallet/TransactionStatus.tsx +138 -0
- package/src/components/Wallet/WalletBalance.tsx +94 -0
- package/src/components/Wallet/WalletButton.tsx +65 -0
- package/src/components/Wallet/WalletConnectionModal.tsx +193 -0
- package/src/components/Wallet/WalletProvider.tsx +104 -0
- package/src/components/Wallet/index.ts +8 -0
- package/src/components/index.ts +6 -0
- package/src/hooks/index.ts +10 -0
- package/src/hooks/useCache.ts +87 -0
- package/src/hooks/usePolling.ts +98 -0
- package/src/hooks/useProgram.ts +93 -0
- package/src/hooks/useTokenBalance.ts +113 -0
- package/src/hooks/useVaults.ts +122 -0
- package/src/index.ts +23 -0
- package/src/services/index.ts +6 -0
- package/src/services/reconciliationService.ts +246 -0
- package/src/services/syncService.ts +238 -0
- package/src/types/index.ts +233 -0
- package/src/utils/cacheManager.ts +286 -0
- package/src/utils/errorHandler.ts +336 -0
- package/src/utils/index.ts +12 -0
- package/src/utils/performanceMonitor.ts +222 -0
- package/src/utils/rpcRetry.ts +55 -0
- package/src/utils/supabase.ts +253 -0
- package/src/utils/toastService.ts +166 -0
- package/src/utils/tokenUtils.ts +75 -0
- package/src/utils/validation.ts +107 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Performance Monitor
|
|
3
|
+
* Tracks Web Vitals and custom performance metrics
|
|
4
|
+
* Requirements: 6.1, 6.4
|
|
5
|
+
*/
|
|
6
|
+
export interface PerformanceMetrics {
|
|
7
|
+
pageLoadTime: number;
|
|
8
|
+
timeToInteractive: number;
|
|
9
|
+
firstContentfulPaint: number;
|
|
10
|
+
largestContentfulPaint: number;
|
|
11
|
+
cumulativeLayoutShift: number;
|
|
12
|
+
firstInputDelay: number;
|
|
13
|
+
}
|
|
14
|
+
export interface PerformanceWarning {
|
|
15
|
+
metric: string;
|
|
16
|
+
value: number;
|
|
17
|
+
threshold: number;
|
|
18
|
+
severity: 'low' | 'medium' | 'high';
|
|
19
|
+
suggestion: string;
|
|
20
|
+
}
|
|
21
|
+
declare class PerformanceMonitor {
|
|
22
|
+
private metrics;
|
|
23
|
+
private customMetrics;
|
|
24
|
+
/**
|
|
25
|
+
* Measure page load performance
|
|
26
|
+
*/
|
|
27
|
+
measurePageLoad(): PerformanceMetrics | null;
|
|
28
|
+
/**
|
|
29
|
+
* Measure synchronous operation
|
|
30
|
+
*/
|
|
31
|
+
measureOperation(name: string, fn: () => void): number;
|
|
32
|
+
/**
|
|
33
|
+
* Measure asynchronous operation
|
|
34
|
+
*/
|
|
35
|
+
measureAsync(name: string, fn: () => Promise<void>): Promise<number>;
|
|
36
|
+
/**
|
|
37
|
+
* Check performance and return warnings
|
|
38
|
+
*/
|
|
39
|
+
checkPerformance(): PerformanceWarning[];
|
|
40
|
+
/**
|
|
41
|
+
* Report metrics to analytics
|
|
42
|
+
*/
|
|
43
|
+
reportMetrics(): void;
|
|
44
|
+
/**
|
|
45
|
+
* Get First Contentful Paint
|
|
46
|
+
*/
|
|
47
|
+
private getFCP;
|
|
48
|
+
/**
|
|
49
|
+
* Get Largest Contentful Paint
|
|
50
|
+
*/
|
|
51
|
+
private getLCP;
|
|
52
|
+
/**
|
|
53
|
+
* Get Cumulative Layout Shift
|
|
54
|
+
*/
|
|
55
|
+
private getCLS;
|
|
56
|
+
/**
|
|
57
|
+
* Get First Input Delay
|
|
58
|
+
*/
|
|
59
|
+
private getFID;
|
|
60
|
+
/**
|
|
61
|
+
* Record custom metric
|
|
62
|
+
*/
|
|
63
|
+
private recordMetric;
|
|
64
|
+
/**
|
|
65
|
+
* Get suggestion for performance issue
|
|
66
|
+
*/
|
|
67
|
+
private getSuggestion;
|
|
68
|
+
/**
|
|
69
|
+
* Get average for custom metric
|
|
70
|
+
*/
|
|
71
|
+
getAverageMetric(name: string): number | null;
|
|
72
|
+
}
|
|
73
|
+
export declare const performanceMonitor: PerformanceMonitor;
|
|
74
|
+
export {};
|
|
75
|
+
//# sourceMappingURL=performanceMonitor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"performanceMonitor.d.ts","sourceRoot":"","sources":["../../src/utils/performanceMonitor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,kBAAkB;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IACpC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,cAAM,kBAAkB;IACtB,OAAO,CAAC,OAAO,CAAkC;IACjD,OAAO,CAAC,aAAa,CAAoC;IAEzD;;OAEG;IACH,eAAe,IAAI,kBAAkB,GAAG,IAAI;IA2B5C;;OAEG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,IAAI,GAAG,MAAM;IAQtD;;OAEG;IACG,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAQ1E;;OAEG;IACH,gBAAgB,IAAI,kBAAkB,EAAE;IA4BxC;;OAEG;IACH,aAAa,IAAI,IAAI;IAUrB;;OAEG;IACH,OAAO,CAAC,MAAM;IAMd;;OAEG;IACH,OAAO,CAAC,MAAM;IAMd;;OAEG;IACH,OAAO,CAAC,MAAM;IAMd;;OAEG;IACH,OAAO,CAAC,MAAM;IAMd;;OAEG;IACH,OAAO,CAAC,YAAY;IAapB;;OAEG;IACH,OAAO,CAAC,aAAa;IAmBrB;;OAEG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;CAO9C;AAGD,eAAO,MAAM,kBAAkB,oBAA2B,CAAC"}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Performance Monitor
|
|
3
|
+
* Tracks Web Vitals and custom performance metrics
|
|
4
|
+
* Requirements: 6.1, 6.4
|
|
5
|
+
*/
|
|
6
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
7
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
8
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
10
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
12
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
class PerformanceMonitor {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.metrics = new Map();
|
|
18
|
+
this.customMetrics = new Map();
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Measure page load performance
|
|
22
|
+
*/
|
|
23
|
+
measurePageLoad() {
|
|
24
|
+
if (typeof window === 'undefined' || !window.performance) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
const navigation = performance.getEntriesByType('navigation')[0];
|
|
28
|
+
if (!navigation) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
const metrics = {
|
|
32
|
+
pageLoadTime: navigation.loadEventEnd - navigation.fetchStart,
|
|
33
|
+
timeToInteractive: navigation.domInteractive - navigation.fetchStart,
|
|
34
|
+
firstContentfulPaint: this.getFCP(),
|
|
35
|
+
largestContentfulPaint: this.getLCP(),
|
|
36
|
+
cumulativeLayoutShift: this.getCLS(),
|
|
37
|
+
firstInputDelay: this.getFID(),
|
|
38
|
+
};
|
|
39
|
+
// Store metrics
|
|
40
|
+
Object.entries(metrics).forEach(([key, value]) => {
|
|
41
|
+
this.metrics.set(key, value);
|
|
42
|
+
});
|
|
43
|
+
return metrics;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Measure synchronous operation
|
|
47
|
+
*/
|
|
48
|
+
measureOperation(name, fn) {
|
|
49
|
+
const start = performance.now();
|
|
50
|
+
fn();
|
|
51
|
+
const duration = performance.now() - start;
|
|
52
|
+
this.recordMetric(name, duration);
|
|
53
|
+
return duration;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Measure asynchronous operation
|
|
57
|
+
*/
|
|
58
|
+
measureAsync(name, fn) {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
const start = performance.now();
|
|
61
|
+
yield fn();
|
|
62
|
+
const duration = performance.now() - start;
|
|
63
|
+
this.recordMetric(name, duration);
|
|
64
|
+
return duration;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Check performance and return warnings
|
|
69
|
+
*/
|
|
70
|
+
checkPerformance() {
|
|
71
|
+
const warnings = [];
|
|
72
|
+
const thresholds = {
|
|
73
|
+
pageLoadTime: 3000, // 3 seconds
|
|
74
|
+
timeToInteractive: 5000, // 5 seconds
|
|
75
|
+
firstContentfulPaint: 2000, // 2 seconds
|
|
76
|
+
largestContentfulPaint: 2500, // 2.5 seconds
|
|
77
|
+
cumulativeLayoutShift: 0.1, // 0.1
|
|
78
|
+
firstInputDelay: 100, // 100ms
|
|
79
|
+
};
|
|
80
|
+
for (const [metric, threshold] of Object.entries(thresholds)) {
|
|
81
|
+
const value = this.metrics.get(metric);
|
|
82
|
+
if (value !== undefined && value > threshold) {
|
|
83
|
+
const severity = value > threshold * 2 ? 'high' : value > threshold * 1.5 ? 'medium' : 'low';
|
|
84
|
+
warnings.push({
|
|
85
|
+
metric,
|
|
86
|
+
value,
|
|
87
|
+
threshold,
|
|
88
|
+
severity,
|
|
89
|
+
suggestion: this.getSuggestion(metric, value, threshold),
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return warnings;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Report metrics to analytics
|
|
97
|
+
*/
|
|
98
|
+
reportMetrics() {
|
|
99
|
+
var _a;
|
|
100
|
+
const metrics = this.measurePageLoad();
|
|
101
|
+
if (metrics) {
|
|
102
|
+
// In production, send to analytics service
|
|
103
|
+
if (typeof process !== 'undefined' && ((_a = process.env) === null || _a === void 0 ? void 0 : _a.NODE_ENV) === 'development') {
|
|
104
|
+
console.log('Performance Metrics:', metrics);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Get First Contentful Paint
|
|
110
|
+
*/
|
|
111
|
+
getFCP() {
|
|
112
|
+
const paintEntries = performance.getEntriesByType('paint');
|
|
113
|
+
const fcpEntry = paintEntries.find(entry => entry.name === 'first-contentful-paint');
|
|
114
|
+
return fcpEntry ? fcpEntry.startTime : 0;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Get Largest Contentful Paint
|
|
118
|
+
*/
|
|
119
|
+
getLCP() {
|
|
120
|
+
// LCP is measured via PerformanceObserver in real implementation
|
|
121
|
+
// For now, return 0
|
|
122
|
+
return 0;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Get Cumulative Layout Shift
|
|
126
|
+
*/
|
|
127
|
+
getCLS() {
|
|
128
|
+
// CLS is measured via PerformanceObserver in real implementation
|
|
129
|
+
// For now, return 0
|
|
130
|
+
return 0;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Get First Input Delay
|
|
134
|
+
*/
|
|
135
|
+
getFID() {
|
|
136
|
+
// FID is measured via PerformanceObserver in real implementation
|
|
137
|
+
// For now, return 0
|
|
138
|
+
return 0;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Record custom metric
|
|
142
|
+
*/
|
|
143
|
+
recordMetric(name, value) {
|
|
144
|
+
if (!this.customMetrics.has(name)) {
|
|
145
|
+
this.customMetrics.set(name, []);
|
|
146
|
+
}
|
|
147
|
+
const metrics = this.customMetrics.get(name);
|
|
148
|
+
metrics.push(value);
|
|
149
|
+
// Keep only last 100 measurements
|
|
150
|
+
if (metrics.length > 100) {
|
|
151
|
+
metrics.shift();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Get suggestion for performance issue
|
|
156
|
+
*/
|
|
157
|
+
getSuggestion(metric, value, threshold) {
|
|
158
|
+
switch (metric) {
|
|
159
|
+
case 'pageLoadTime':
|
|
160
|
+
return 'Consider code splitting and lazy loading to reduce initial bundle size.';
|
|
161
|
+
case 'timeToInteractive':
|
|
162
|
+
return 'Optimize JavaScript execution and reduce main thread blocking.';
|
|
163
|
+
case 'firstContentfulPaint':
|
|
164
|
+
return 'Optimize critical rendering path and reduce render-blocking resources.';
|
|
165
|
+
case 'largestContentfulPaint':
|
|
166
|
+
return 'Optimize images and reduce resource load times.';
|
|
167
|
+
case 'cumulativeLayoutShift':
|
|
168
|
+
return 'Ensure images and ads have explicit dimensions to prevent layout shifts.';
|
|
169
|
+
case 'firstInputDelay':
|
|
170
|
+
return 'Reduce JavaScript execution time and break up long tasks.';
|
|
171
|
+
default:
|
|
172
|
+
return 'Review performance optimization best practices.';
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Get average for custom metric
|
|
177
|
+
*/
|
|
178
|
+
getAverageMetric(name) {
|
|
179
|
+
const metrics = this.customMetrics.get(name);
|
|
180
|
+
if (!metrics || metrics.length === 0)
|
|
181
|
+
return null;
|
|
182
|
+
const sum = metrics.reduce((a, b) => a + b, 0);
|
|
183
|
+
return sum / metrics.length;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
// Export singleton instance
|
|
187
|
+
export const performanceMonitor = new PerformanceMonitor();
|
|
188
|
+
// Initialize Web Vitals tracking
|
|
189
|
+
if (typeof window !== 'undefined') {
|
|
190
|
+
// Measure page load on mount
|
|
191
|
+
window.addEventListener('load', () => {
|
|
192
|
+
setTimeout(() => {
|
|
193
|
+
performanceMonitor.measurePageLoad();
|
|
194
|
+
performanceMonitor.reportMetrics();
|
|
195
|
+
}, 0);
|
|
196
|
+
});
|
|
197
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RPC Retry Utility
|
|
3
|
+
* Retries failed RPC calls with exponential backoff
|
|
4
|
+
*/
|
|
5
|
+
export interface RetryOptions {
|
|
6
|
+
maxRetries?: number;
|
|
7
|
+
initialDelay?: number;
|
|
8
|
+
maxDelay?: number;
|
|
9
|
+
backoffMultiplier?: number;
|
|
10
|
+
}
|
|
11
|
+
export declare function retryRpcCall<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
|
|
12
|
+
//# sourceMappingURL=rpcRetry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpcRetry.d.ts","sourceRoot":"","sources":["../../src/utils/rpcRetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,YAAY;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AASD,wBAAsB,YAAY,CAAC,CAAC,EAClC,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC,CAAC,CAAC,CAgCZ"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RPC Retry Utility
|
|
3
|
+
* Retries failed RPC calls with exponential backoff
|
|
4
|
+
*/
|
|
5
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
6
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
7
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
8
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
9
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
10
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
const DEFAULT_OPTIONS = {
|
|
15
|
+
maxRetries: 3,
|
|
16
|
+
initialDelay: 1000,
|
|
17
|
+
maxDelay: 10000,
|
|
18
|
+
backoffMultiplier: 2,
|
|
19
|
+
};
|
|
20
|
+
export function retryRpcCall(fn_1) {
|
|
21
|
+
return __awaiter(this, arguments, void 0, function* (fn, options = {}) {
|
|
22
|
+
var _a;
|
|
23
|
+
const opts = Object.assign(Object.assign({}, DEFAULT_OPTIONS), options);
|
|
24
|
+
let lastError = null;
|
|
25
|
+
for (let attempt = 0; attempt <= opts.maxRetries; attempt++) {
|
|
26
|
+
try {
|
|
27
|
+
return yield fn();
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
lastError = error;
|
|
31
|
+
// Don't retry on certain errors
|
|
32
|
+
if ((error === null || error === void 0 ? void 0 : error.code) === 4001 || ((_a = error === null || error === void 0 ? void 0 : error.message) === null || _a === void 0 ? void 0 : _a.includes('User rejected'))) {
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
// If this is the last attempt, throw the error
|
|
36
|
+
if (attempt === opts.maxRetries) {
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
// Calculate delay with exponential backoff
|
|
40
|
+
const delay = Math.min(opts.initialDelay * Math.pow(opts.backoffMultiplier, attempt), opts.maxDelay);
|
|
41
|
+
// Wait before retrying
|
|
42
|
+
yield new Promise(resolve => setTimeout(resolve, delay));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
throw lastError || new Error('RPC call failed after retries');
|
|
46
|
+
});
|
|
47
|
+
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
export interface Database {
|
|
2
|
+
public: {
|
|
3
|
+
Tables: {
|
|
4
|
+
transactions: {
|
|
5
|
+
Row: {
|
|
6
|
+
id: string;
|
|
7
|
+
user_public_key: string;
|
|
8
|
+
type: 'stake' | 'unstake' | 'reward';
|
|
9
|
+
amount: number;
|
|
10
|
+
vault_id: number;
|
|
11
|
+
epoch_id: number | null;
|
|
12
|
+
signature: string;
|
|
13
|
+
status: 'confirmed' | 'pending' | 'failed';
|
|
14
|
+
timestamp: string;
|
|
15
|
+
created_at: string;
|
|
16
|
+
};
|
|
17
|
+
Insert: {
|
|
18
|
+
id?: string;
|
|
19
|
+
user_public_key: string;
|
|
20
|
+
type: 'stake' | 'unstake' | 'reward';
|
|
21
|
+
amount: number;
|
|
22
|
+
vault_id: number;
|
|
23
|
+
epoch_id?: number | null;
|
|
24
|
+
signature: string;
|
|
25
|
+
status: 'confirmed' | 'pending' | 'failed';
|
|
26
|
+
timestamp?: string;
|
|
27
|
+
created_at?: string;
|
|
28
|
+
};
|
|
29
|
+
Update: {
|
|
30
|
+
id?: string;
|
|
31
|
+
user_public_key?: string;
|
|
32
|
+
type?: 'stake' | 'unstake' | 'reward';
|
|
33
|
+
amount?: number;
|
|
34
|
+
vault_id?: number;
|
|
35
|
+
epoch_id?: number | null;
|
|
36
|
+
signature?: string;
|
|
37
|
+
status?: 'confirmed' | 'pending' | 'failed';
|
|
38
|
+
timestamp?: string;
|
|
39
|
+
created_at?: string;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
rewards: {
|
|
43
|
+
Row: {
|
|
44
|
+
id: string;
|
|
45
|
+
user_public_key: string;
|
|
46
|
+
vault_id: number;
|
|
47
|
+
epoch_id: number;
|
|
48
|
+
amount: number;
|
|
49
|
+
claimed: boolean;
|
|
50
|
+
claim_signature: string | null;
|
|
51
|
+
timestamp: string;
|
|
52
|
+
claimed_at: string | null;
|
|
53
|
+
created_at: string;
|
|
54
|
+
};
|
|
55
|
+
Insert: {
|
|
56
|
+
id?: string;
|
|
57
|
+
user_public_key: string;
|
|
58
|
+
vault_id: number;
|
|
59
|
+
epoch_id: number;
|
|
60
|
+
amount: number;
|
|
61
|
+
claimed?: boolean;
|
|
62
|
+
claim_signature?: string | null;
|
|
63
|
+
timestamp: string;
|
|
64
|
+
claimed_at?: string | null;
|
|
65
|
+
created_at?: string;
|
|
66
|
+
};
|
|
67
|
+
Update: {
|
|
68
|
+
id?: string;
|
|
69
|
+
user_public_key?: string;
|
|
70
|
+
vault_id?: number;
|
|
71
|
+
epoch_id?: number;
|
|
72
|
+
amount?: number;
|
|
73
|
+
claimed?: boolean;
|
|
74
|
+
claim_signature?: string | null;
|
|
75
|
+
timestamp?: string;
|
|
76
|
+
claimed_at?: string | null;
|
|
77
|
+
created_at?: string;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
platform_metrics: {
|
|
81
|
+
Row: {
|
|
82
|
+
id: string;
|
|
83
|
+
timestamp: string;
|
|
84
|
+
total_value_locked: number;
|
|
85
|
+
total_users: number;
|
|
86
|
+
active_vaults: number;
|
|
87
|
+
average_apr: number;
|
|
88
|
+
current_epoch: number;
|
|
89
|
+
volume_24h: number;
|
|
90
|
+
created_at: string;
|
|
91
|
+
};
|
|
92
|
+
Insert: {
|
|
93
|
+
id?: string;
|
|
94
|
+
timestamp: string;
|
|
95
|
+
total_value_locked: number;
|
|
96
|
+
total_users: number;
|
|
97
|
+
active_vaults: number;
|
|
98
|
+
average_apr: number;
|
|
99
|
+
current_epoch: number;
|
|
100
|
+
volume_24h: number;
|
|
101
|
+
created_at?: string;
|
|
102
|
+
};
|
|
103
|
+
Update: {
|
|
104
|
+
id?: string;
|
|
105
|
+
timestamp?: string;
|
|
106
|
+
total_value_locked?: number;
|
|
107
|
+
total_users?: number;
|
|
108
|
+
active_vaults?: number;
|
|
109
|
+
average_apr?: number;
|
|
110
|
+
current_epoch?: number;
|
|
111
|
+
volume_24h?: number;
|
|
112
|
+
created_at?: string;
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
vault_history: {
|
|
116
|
+
Row: {
|
|
117
|
+
id: string;
|
|
118
|
+
vault_id: number;
|
|
119
|
+
epoch_id: number;
|
|
120
|
+
timestamp: string;
|
|
121
|
+
apr_rate: number;
|
|
122
|
+
total_staked: number;
|
|
123
|
+
staker_count: number;
|
|
124
|
+
rewards_distributed: number;
|
|
125
|
+
created_at: string;
|
|
126
|
+
};
|
|
127
|
+
Insert: {
|
|
128
|
+
id?: string;
|
|
129
|
+
vault_id: number;
|
|
130
|
+
epoch_id: number;
|
|
131
|
+
timestamp: string;
|
|
132
|
+
apr_rate: number;
|
|
133
|
+
total_staked: number;
|
|
134
|
+
staker_count: number;
|
|
135
|
+
rewards_distributed: number;
|
|
136
|
+
created_at?: string;
|
|
137
|
+
};
|
|
138
|
+
Update: {
|
|
139
|
+
id?: string;
|
|
140
|
+
vault_id?: number;
|
|
141
|
+
epoch_id?: number;
|
|
142
|
+
timestamp?: string;
|
|
143
|
+
apr_rate?: number;
|
|
144
|
+
total_staked?: number;
|
|
145
|
+
staker_count?: number;
|
|
146
|
+
rewards_distributed?: number;
|
|
147
|
+
created_at?: string;
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
admin_audit_log: {
|
|
151
|
+
Row: {
|
|
152
|
+
id: string;
|
|
153
|
+
admin_public_key: string;
|
|
154
|
+
action: string;
|
|
155
|
+
details: Record<string, any>;
|
|
156
|
+
signature: string;
|
|
157
|
+
status: 'success' | 'failed';
|
|
158
|
+
timestamp: string;
|
|
159
|
+
created_at: string;
|
|
160
|
+
};
|
|
161
|
+
Insert: {
|
|
162
|
+
id?: string;
|
|
163
|
+
admin_public_key: string;
|
|
164
|
+
action: string;
|
|
165
|
+
details: Record<string, any>;
|
|
166
|
+
signature: string;
|
|
167
|
+
status: 'success' | 'failed';
|
|
168
|
+
timestamp?: string;
|
|
169
|
+
created_at?: string;
|
|
170
|
+
};
|
|
171
|
+
Update: {
|
|
172
|
+
id?: string;
|
|
173
|
+
admin_public_key?: string;
|
|
174
|
+
action?: string;
|
|
175
|
+
details?: Record<string, any>;
|
|
176
|
+
signature?: string;
|
|
177
|
+
status?: 'success' | 'failed';
|
|
178
|
+
timestamp?: string;
|
|
179
|
+
created_at?: string;
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
export interface SupabaseConfig {
|
|
186
|
+
url: string;
|
|
187
|
+
anonKey: string;
|
|
188
|
+
}
|
|
189
|
+
export declare const getSupabaseClient: (config?: SupabaseConfig) => import("@supabase/supabase-js").SupabaseClient<Database, "public", "public", never, {
|
|
190
|
+
PostgrestVersion: "12";
|
|
191
|
+
}>;
|
|
192
|
+
export declare const isSupabaseConfigured: (config?: SupabaseConfig) => boolean;
|
|
193
|
+
export type Transaction = Database['public']['Tables']['transactions']['Row'];
|
|
194
|
+
export type Reward = Database['public']['Tables']['rewards']['Row'];
|
|
195
|
+
export type PlatformMetric = Database['public']['Tables']['platform_metrics']['Row'];
|
|
196
|
+
export type VaultHistory = Database['public']['Tables']['vault_history']['Row'];
|
|
197
|
+
export type AdminAuditLog = Database['public']['Tables']['admin_audit_log']['Row'];
|
|
198
|
+
//# source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AAGF,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC,cAAc,CAAC,CAAC,KAAK,CAAC,CAAC;AAC9E,MAAM,MAAM,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC;AACpE,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC,kBAAkB,CAAC,CAAC,KAAK,CAAC,CAAC;AACrF,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC,eAAe,CAAC,CAAC,KAAK,CAAC,CAAC;AAChF,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC,iBAAiB,CAAC,CAAC,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supabase Client Configuration
|
|
3
|
+
* Provides connection to Supabase for off-chain data storage
|
|
4
|
+
*/
|
|
5
|
+
import { createClient } from '@supabase/supabase-js';
|
|
6
|
+
// Create Supabase client with connection pooling
|
|
7
|
+
let supabaseClient = null;
|
|
8
|
+
export const getSupabaseClient = (config) => {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
if (supabaseClient && !config) {
|
|
11
|
+
return supabaseClient;
|
|
12
|
+
}
|
|
13
|
+
const supabaseUrl = (config === null || config === void 0 ? void 0 : config.url) ||
|
|
14
|
+
(typeof process !== 'undefined' && ((_a = process.env) === null || _a === void 0 ? void 0 : _a.NEXT_PUBLIC_SUPABASE_URL)) ||
|
|
15
|
+
'';
|
|
16
|
+
const supabaseAnonKey = (config === null || config === void 0 ? void 0 : config.anonKey) ||
|
|
17
|
+
(typeof process !== 'undefined' && ((_b = process.env) === null || _b === void 0 ? void 0 : _b.NEXT_PUBLIC_SUPABASE_ANON_KEY)) ||
|
|
18
|
+
'';
|
|
19
|
+
if (!supabaseUrl || !supabaseAnonKey) {
|
|
20
|
+
console.warn('Supabase credentials not configured. Off-chain features will be disabled.');
|
|
21
|
+
// Return a mock client that throws errors when used
|
|
22
|
+
return createClient('https://placeholder.supabase.co', 'placeholder-key');
|
|
23
|
+
}
|
|
24
|
+
supabaseClient = createClient(supabaseUrl, supabaseAnonKey, {
|
|
25
|
+
auth: {
|
|
26
|
+
persistSession: false, // We don't need auth sessions for this use case
|
|
27
|
+
autoRefreshToken: false,
|
|
28
|
+
},
|
|
29
|
+
db: {
|
|
30
|
+
schema: 'public',
|
|
31
|
+
},
|
|
32
|
+
global: {
|
|
33
|
+
headers: {
|
|
34
|
+
'x-client-info': 'web3-prediction-platform',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
return supabaseClient;
|
|
39
|
+
};
|
|
40
|
+
// Helper function to check if Supabase is configured
|
|
41
|
+
export const isSupabaseConfigured = (config) => {
|
|
42
|
+
var _a, _b;
|
|
43
|
+
const supabaseUrl = (config === null || config === void 0 ? void 0 : config.url) ||
|
|
44
|
+
(typeof process !== 'undefined' && ((_a = process.env) === null || _a === void 0 ? void 0 : _a.NEXT_PUBLIC_SUPABASE_URL)) ||
|
|
45
|
+
'';
|
|
46
|
+
const supabaseAnonKey = (config === null || config === void 0 ? void 0 : config.anonKey) ||
|
|
47
|
+
(typeof process !== 'undefined' && ((_b = process.env) === null || _b === void 0 ? void 0 : _b.NEXT_PUBLIC_SUPABASE_ANON_KEY)) ||
|
|
48
|
+
'';
|
|
49
|
+
return !!(supabaseUrl && supabaseAnonKey);
|
|
50
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export interface ToastOptions {
|
|
2
|
+
duration?: number;
|
|
3
|
+
position?: 'top-right' | 'top-center' | 'bottom-right' | 'bottom-center';
|
|
4
|
+
icon?: React.ReactNode;
|
|
5
|
+
}
|
|
6
|
+
declare class ToastService {
|
|
7
|
+
private defaultDuration;
|
|
8
|
+
private defaultPosition;
|
|
9
|
+
/**
|
|
10
|
+
* Show success toast
|
|
11
|
+
*/
|
|
12
|
+
success(message: string, options?: ToastOptions): string;
|
|
13
|
+
/**
|
|
14
|
+
* Show error toast
|
|
15
|
+
*/
|
|
16
|
+
error(message: string, options?: ToastOptions): string;
|
|
17
|
+
/**
|
|
18
|
+
* Show error toast with error handler integration
|
|
19
|
+
*/
|
|
20
|
+
errorWithHandler(error: Error, context: string, options?: ToastOptions): string;
|
|
21
|
+
/**
|
|
22
|
+
* Show warning toast
|
|
23
|
+
*/
|
|
24
|
+
warning(message: string, options?: ToastOptions): string;
|
|
25
|
+
/**
|
|
26
|
+
* Show info toast
|
|
27
|
+
*/
|
|
28
|
+
info(message: string, options?: ToastOptions): string;
|
|
29
|
+
/**
|
|
30
|
+
* Show loading toast
|
|
31
|
+
*/
|
|
32
|
+
loading(message: string, options?: ToastOptions): string;
|
|
33
|
+
/**
|
|
34
|
+
* Show promise toast (loading -> success/error)
|
|
35
|
+
*/
|
|
36
|
+
promise<T>(promise: Promise<T>, messages: {
|
|
37
|
+
loading: string;
|
|
38
|
+
success: string;
|
|
39
|
+
error: string;
|
|
40
|
+
}, options?: ToastOptions): Promise<T>;
|
|
41
|
+
/**
|
|
42
|
+
* Dismiss toast
|
|
43
|
+
*/
|
|
44
|
+
dismiss(toastId: string): void;
|
|
45
|
+
/**
|
|
46
|
+
* Dismiss all toasts
|
|
47
|
+
*/
|
|
48
|
+
dismissAll(): void;
|
|
49
|
+
}
|
|
50
|
+
export declare const toastService: ToastService;
|
|
51
|
+
export { toastService as toast };
|
|
52
|
+
//# sourceMappingURL=toastService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toastService.d.ts","sourceRoot":"","sources":["../../src/utils/toastService.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IA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