forked from Txio-labs/txio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPTBBuilder.tsx
More file actions
534 lines (495 loc) · 29.9 KB
/
Copy pathPTBBuilder.tsx
File metadata and controls
534 lines (495 loc) · 29.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
import React, { useState, useRef, useEffect } from 'react';
import { Box, ArrowRight, Play, Coins, Layers, Plus, X, Search, RefreshCw } from 'lucide-react';
import { PTBNode } from '../types';
import { useAppStore, appStore } from '@/lib/store';
import { useWallet } from '@/wallet';
import { getOwnedObjects } from '../services/suiService';
import { TransactionBuilder } from '../components/RequestPanel/builders/TransactionBuilder';
interface NodeProps {
node: PTBNode;
onMouseDown: (id: string, e: React.MouseEvent) => void;
}
const Node: React.FC<NodeProps> = ({ node, onMouseDown }) => {
let color = 'border-slate-600 bg-slate-800';
let icon = <Box size={14} />;
if (node.type === 'object') { color = 'border-blue-600 bg-blue-900/20'; icon = <Coins size={14} className="text-blue-400"/>; }
if (node.type === 'transfer') { color = 'border-emerald-600 bg-emerald-900/20'; icon = <ArrowRight size={14} className="text-emerald-400"/>; }
if (node.type === 'splitCoins') { color = 'border-amber-600 bg-amber-900/20'; icon = <Layers size={14} className="text-amber-400"/>; }
if (node.type === 'moveCall') { color = 'border-purple-600 bg-purple-900/20'; icon = <Layers size={14} className="text-purple-400"/>; }
return (
<div
className={`absolute w-48 rounded-lg border shadow-xl backdrop-blur-sm cursor-grab active:cursor-grabbing ${color}`}
style={{ left: node.position.x, top: node.position.y }}
onMouseDown={(e) => {
e.stopPropagation();
onMouseDown(node.id, e);
}}
>
<div className="px-3 py-2 border-b border-white/10 flex items-center gap-2 text-xs font-bold text-white uppercase tracking-wide select-none">
{icon} {node.type}
</div>
<div className="p-3 text-xs text-slate-300 space-y-2">
{Object.entries(node.data).map(([k, v]) => (
<div key={k} className="flex justify-between">
<span className="opacity-50 capitalize">{k}:</span>
<span className="font-mono text-white truncate max-w-[100px]">{Array.isArray(v) ? `[${v.join(', ')}]` : v}</span>
</div>
))}
</div>
{/* Handles */}
{node.inputs && node.inputs.length > 0 && <div className="absolute left-0 top-1/2 -translate-x-1/2 w-3 h-3 bg-slate-200 rounded-full border-2 border-white/5 hover:scale-125 transition-transform" />}
{node.outputs && node.outputs.length > 0 && <div className="absolute right-0 top-1/2 translate-x-1/2 w-3 h-3 bg-slate-200 rounded-full border-2 border-white/5 hover:scale-125 transition-transform" />}
</div>
);
};
export const PTBBuilder: React.FC = () => {
const { network, envVariables } = useAppStore();
const { currentWallet } = useWallet();
const connectedAddress = currentWallet?.family === 'sui' ? currentWallet.address : null;
const [nodes, setNodes] = useState<PTBNode[]>([
{ id: '1', type: 'object', position: { x: 100, y: 100 }, data: { label: 'Input Coin', type: '0x2::sui::SUI' }, inputs: [], outputs: ['c1'] },
{ id: '2', type: 'splitCoins', position: { x: 400, y: 100 }, data: { amounts: [1000, 500] }, inputs: ['c1'], outputs: ['c2', 'c3'] },
{ id: '3', type: 'transfer', position: { x: 700, y: 50 }, data: { recipient: '0xAlice' }, inputs: ['c2'], outputs: [] },
{ id: '4', type: 'transfer', position: { x: 700, y: 200 }, data: { recipient: '0xBob' }, inputs: ['c3'], outputs: [] }
]);
const [draggingId, setDraggingId] = useState<string | null>(null);
const canvasRef = useRef<HTMLDivElement>(null);
// Modal State
const [activeModal, setActiveModal] = useState<'addObject' | 'moveCall' | 'splitCoins' | null>(null);
// Add Object Modal State
const [objIdInput, setObjIdInput] = useState('');
const [objTypeInput, setObjTypeInput] = useState('0x2::sui::SUI');
const [objLabelInput, setObjLabelInput] = useState('');
const [ownedObjects, setOwnedObjects] = useState<any[]>([]);
const [loadingOwned, setLoadingOwned] = useState(false);
// Move Call Modal State
const [tempRequest, setTempRequest] = useState<any>({
id: 'temp-move-call',
type: 'TRANSACTION',
txType: 'MoveCall',
moveParams: {
packageId: '',
module: '',
function: '',
typeArguments: [],
arguments: [],
gasBudget: '10000000'
}
});
const [moveCallOutputs, setMoveCallOutputs] = useState('result_5');
// Split Coins Modal State
const [splitInputCoin, setSplitInputCoin] = useState('');
const [splitAmounts, setSplitAmounts] = useState('1000, 500');
const [splitOutputs, setSplitOutputs] = useState('split_1, split_2');
useEffect(() => {
let isSubscribed = true;
if (activeModal === 'addObject' && connectedAddress) {
queueMicrotask(() => {
if (!isSubscribed) return;
setLoadingOwned(true);
getOwnedObjects(network, connectedAddress)
.then(res => {
if (isSubscribed && res?.result?.data) {
setOwnedObjects(res.result.data);
}
})
.catch(() => {})
.finally(() => {
if (isSubscribed) {
setLoadingOwned(false);
}
});
});
}
return () => {
isSubscribed = false;
};
}, [activeModal, connectedAddress, network]);
// Simple Drag Logic
const handleMouseMove = (e: React.MouseEvent) => {
if (draggingId && canvasRef.current) {
const rect = canvasRef.current.getBoundingClientRect();
setNodes(nds => nds.map(n => {
if (n.id === draggingId) {
return {
...n,
position: {
x: Math.max(0, e.clientX - rect.left - 96), // center cursor
y: Math.max(0, e.clientY - rect.top - 20)
}
};
}
return n;
}));
}
};
// Draw SVG Connections
const renderConnections = () => {
// Map of connection ID to source node position
const outputsMap: Record<string, { x: number; y: number }> = {};
nodes.forEach(n => {
if (n.outputs) {
n.outputs.forEach(outId => {
outputsMap[outId] = {
x: n.position.x + 192,
y: n.position.y + 50
};
});
}
});
const paths: React.JSX.Element[] = [];
nodes.forEach(n => {
if (n.inputs) {
n.inputs.forEach(inId => {
const start = outputsMap[inId];
if (start) {
const end = {
x: n.position.x,
y: n.position.y + 50
};
const cp1x = start.x + Math.max(30, (end.x - start.x) / 2);
const cp1y = start.y;
const cp2x = end.x - Math.max(30, (end.x - start.x) / 2);
const cp2y = end.y;
paths.push(
<path
key={`${inId}-${n.id}`}
d={`M ${start.x} ${start.y} C ${cp1x} ${cp1y}, ${cp2x} ${cp2y}, ${end.x} ${end.y}`}
stroke="#475569"
strokeWidth="2"
fill="none"
/>
);
}
});
}
});
return (
<svg className="absolute inset-0 w-full h-full pointer-events-none overflow-visible">
{paths}
</svg>
);
};
const handleAddObject = () => {
if (!objIdInput) {
appStore.showToast('Object ID is required', 'error');
return;
}
const newNodeId = Date.now().toString();
const outId = `obj_out_${newNodeId}`;
const newNode: PTBNode = {
id: newNodeId,
type: 'object',
position: { x: 150 + (nodes.length % 5) * 40, y: 150 + (nodes.length % 5) * 40 },
data: { label: objLabelInput || 'Object', type: objTypeInput || 'Unknown Type', objectId: objIdInput },
inputs: [],
outputs: [outId]
};
setNodes(nds => [...nds, newNode]);
setActiveModal(null);
setObjIdInput('');
setObjTypeInput('0x2::sui::SUI');
setObjLabelInput('');
};
const handleAddMoveCall = () => {
if (!tempRequest.moveParams.packageId || !tempRequest.moveParams.module || !tempRequest.moveParams.function) {
appStore.showToast('Package ID, Module, and Function are required', 'error');
return;
}
const newNodeId = Date.now().toString();
const outputList = moveCallOutputs.split(',')
.map(s => s.trim())
.filter(Boolean);
const allActiveOutputs = nodes.flatMap(n => n.outputs || []);
const inputs = tempRequest.moveParams.arguments
.map((arg: any) => arg.value)
.filter((val: string) => val && (allActiveOutputs.includes(val) || val.startsWith('obj_out_') || val.startsWith('split_out_') || val.startsWith('move_out_') || val.startsWith('c')));
const newNode: PTBNode = {
id: newNodeId,
type: 'moveCall',
position: { x: 150 + (nodes.length % 5) * 40, y: 150 + (nodes.length % 5) * 40 },
data: {
package: tempRequest.moveParams.packageId,
module: tempRequest.moveParams.module,
function: tempRequest.moveParams.function,
arguments: tempRequest.moveParams.arguments.map((a: any) => `${a.type}: ${a.value}`).join(', '),
typeArguments: tempRequest.moveParams.typeArguments.join(', ')
},
inputs: inputs,
outputs: outputList
};
setNodes(nds => [...nds, newNode]);
setActiveModal(null);
setTempRequest({
id: 'temp-move-call',
type: 'TRANSACTION',
txType: 'MoveCall',
moveParams: {
packageId: '',
module: '',
function: '',
typeArguments: [],
arguments: [],
gasBudget: '10000000'
}
});
setMoveCallOutputs(`result_${nodes.length + 2}`);
};
const handleAddSplitCoins = () => {
if (!splitInputCoin) {
appStore.showToast('Input Coin is required', 'error');
return;
}
const newNodeId = Date.now().toString();
const amounts = splitAmounts.split(',')
.map(s => parseInt(s.trim()))
.filter(n => !isNaN(n));
const outputs = splitOutputs.split(',')
.map(s => s.trim())
.filter(Boolean);
const newNode: PTBNode = {
id: newNodeId,
type: 'splitCoins',
position: { x: 150 + (nodes.length % 5) * 40, y: 150 + (nodes.length % 5) * 40 },
data: {
input: splitInputCoin,
amounts: amounts
},
inputs: [splitInputCoin],
outputs: outputs
};
setNodes(nds => [...nds, newNode]);
setActiveModal(null);
setSplitInputCoin('');
setSplitAmounts('1000, 500');
setSplitOutputs('split_1, split_2');
};
return (
<div className="flex h-full bg-near-black">
{/* Toolbar */}
<div className="w-12 bg-dark-indigo-glow border-r border-white/5 flex flex-col items-center py-4 gap-4 z-10">
<button onClick={() => setActiveModal('addObject')} className="p-2 bg-blue-900/30 text-blue-400 rounded hover:bg-blue-900/50" title="Add Object"><Coins size={20}/></button>
<button onClick={() => setActiveModal('moveCall')} className="p-2 text-slate-500 hover:text-white hover:bg-white/5 rounded" title="Move Call"><Layers size={20}/></button>
<button onClick={() => setActiveModal('splitCoins')} className="p-2 text-slate-500 hover:text-white hover:bg-white/5 rounded" title="Split Coins"><Plus size={20}/></button>
</div>
{/* Canvas */}
<div
className="flex-1 relative overflow-hidden dot-grid"
ref={canvasRef}
onMouseMove={handleMouseMove}
onMouseUp={() => setDraggingId(null)}
onMouseLeave={() => setDraggingId(null)}
>
{renderConnections()}
{nodes.map(node => (
// Added key and updated onMouseDown to fix TypeScript error in JSX mapping
<Node
key={node.id}
node={node}
onMouseDown={(id) => setDraggingId(id)}
/>
))}
{/* Floating Action */}
<div className="absolute top-4 right-4 bg-dark-indigo-glow/80 backdrop-blur border border-white/10 p-2 rounded-lg flex gap-2">
<button onClick={() => appStore.showToast('Dry Run simulation started (Mock)', 'success')} className="bg-electric-violet hover:bg-electric-violet text-white px-4 py-1.5 rounded text-xs font-bold flex items-center gap-2">
<Play size={14} fill="currentColor" /> Dry Run
</button>
</div>
</div>
{/* Modals */}
{activeModal === 'addObject' && (
<div className="fixed inset-0 z-[100] flex items-center justify-center p-4 bg-near-black/60 backdrop-blur-md animate-in fade-in duration-200">
<div className="bg-[#0c0c0e] border border-white/5 rounded-2xl shadow-2xl w-full max-w-xl overflow-hidden relative">
<div className="absolute top-0 left-0 w-full h-1 bg-gradient-to-r from-transparent via-blue-500 to-transparent opacity-50" />
<div className="p-6 relative z-10">
<div className="flex items-start justify-between mb-4">
<div className="flex items-center gap-3">
<div className="w-10 h-10 bg-dark-indigo-glow rounded-xl border border-white/5 flex items-center justify-center shrink-0">
<Coins size={18} className="text-blue-400" />
</div>
<div>
<h2 className="text-sm font-bold text-white">Add Object Input</h2>
<p className="text-xs text-slate-500 mt-0.5">Input an object ID or select from your wallet</p>
</div>
</div>
<button onClick={() => setActiveModal(null)} className="text-slate-500 hover:text-white transition-colors"><X size={18} /></button>
</div>
<div className="space-y-4">
<div>
<label className="block text-[10px] uppercase font-bold text-slate-500 mb-1">Object ID *</label>
<input
value={objIdInput}
onChange={e => setObjIdInput(e.target.value)}
placeholder="0x..."
className="w-full bg-black/40 border border-white/5 rounded-lg p-2 text-xs font-mono text-slate-200 focus:outline-none focus:border-blue-500/50"
/>
</div>
<div>
<label className="block text-[10px] uppercase font-bold text-slate-500 mb-1">Object Type</label>
<input
value={objTypeInput}
onChange={e => setObjTypeInput(e.target.value)}
placeholder="e.g. 0x2::sui::SUI"
className="w-full bg-black/40 border border-white/5 rounded-lg p-2 text-xs font-mono text-slate-200 focus:outline-none focus:border-blue-500/50"
/>
</div>
<div>
<label className="block text-[10px] uppercase font-bold text-slate-500 mb-1">Label / Alias</label>
<input
value={objLabelInput}
onChange={e => setObjLabelInput(e.target.value)}
placeholder="e.g. Input Coin"
className="w-full bg-black/40 border border-white/5 rounded-lg p-2 text-xs text-slate-200 focus:outline-none focus:border-blue-500/50"
/>
</div>
{connectedAddress && (
<div className="border-t border-white/5 pt-3">
<label className="block text-[10px] uppercase font-bold text-slate-550 mb-2">Owned Objects ({ownedObjects.length})</label>
{loadingOwned ? (
<div className="flex justify-center p-4"><RefreshCw size={16} className="animate-spin text-slate-500" /></div>
) : (
<div className="max-h-40 overflow-y-auto space-y-1 custom-scrollbar">
{ownedObjects.map((obj, idx) => {
const id = obj.data?.objectId || '';
const type = obj.data?.type || '';
const shortType = type.split('::').pop()?.split('<')[0] || 'Object';
return (
<div
key={idx}
onClick={() => {
setObjIdInput(id);
setObjTypeInput(type);
setObjLabelInput(shortType);
}}
className="p-2 rounded bg-white/5 hover:bg-white/10 cursor-pointer border border-transparent hover:border-white/15 transition-all text-left flex justify-between items-center"
>
<div>
<div className="text-xs font-bold text-slate-300">{shortType}</div>
<div className="text-[10px] font-mono text-slate-500 truncate max-w-xs">{id}</div>
</div>
<span className="text-[9px] bg-blue-500/10 text-blue-400 px-1.5 py-0.5 rounded">Select</span>
</div>
);
})}
{ownedObjects.length === 0 && (
<div className="text-center text-xs text-slate-600 py-2">No owned objects found.</div>
)}
</div>
)}
</div>
)}
</div>
<div className="grid grid-cols-2 gap-3 mt-6">
<button onClick={() => setActiveModal(null)} className="px-4 py-2.5 bg-dark-indigo-glow border border-white/5 hover:bg-white/5 text-slate-400 hover:text-white text-xs font-bold rounded-xl transition-all">Cancel</button>
<button onClick={handleAddObject} className="px-4 py-2.5 bg-blue-600 hover:bg-blue-500 text-white text-xs font-bold rounded-xl shadow-lg transition-all">Add Node</button>
</div>
</div>
</div>
</div>
)}
{activeModal === 'moveCall' && (
<div className="fixed inset-0 z-[100] flex items-center justify-center p-4 bg-near-black/60 backdrop-blur-md animate-in fade-in duration-200">
<div className="bg-[#0c0c0e] border border-white/5 rounded-2xl shadow-2xl w-full max-w-2xl overflow-hidden relative">
<div className="absolute top-0 left-0 w-full h-1 bg-gradient-to-r from-transparent via-purple-500 to-transparent opacity-50" />
<div className="p-6 relative z-10 max-h-[85vh] overflow-y-auto custom-scrollbar">
<div className="flex items-start justify-between mb-4">
<div className="flex items-center gap-3">
<div className="w-10 h-10 bg-dark-indigo-glow rounded-xl border border-white/5 flex items-center justify-center shrink-0">
<Layers size={18} className="text-purple-400" />
</div>
<div>
<h2 className="text-sm font-bold text-white">Add Move Call Step</h2>
<p className="text-xs text-slate-500 mt-0.5">Configure and add a Move Smart Contract call node</p>
</div>
</div>
<button onClick={() => setActiveModal(null)} className="text-slate-500 hover:text-white transition-colors"><X size={18} /></button>
</div>
<div className="space-y-4">
<TransactionBuilder
request={tempRequest}
activeAddress={connectedAddress}
envVars={envVariables}
network={network}
onChange={setTempRequest}
/>
<div className="bg-near-black/45 p-4 rounded-xl border border-white/5 space-y-3">
<h4 className="text-xs font-bold text-slate-300 uppercase tracking-wider">PTB Integration Settings</h4>
<div>
<label className="block text-[10px] uppercase font-bold text-slate-500 mb-1">Exported Output Connections (comma separated)</label>
<input
value={moveCallOutputs}
onChange={e => setMoveCallOutputs(e.target.value)}
placeholder="e.g. result_1, result_2"
className="w-full bg-black/40 border border-white/5 rounded-lg p-2 text-xs font-mono text-slate-200 focus:outline-none focus:border-purple-500/50"
/>
<p className="text-[10px] text-slate-500 mt-1">Specify names for the returned values of this function so you can reference them in subsequent steps.</p>
</div>
</div>
</div>
<div className="grid grid-cols-2 gap-3 mt-6">
<button onClick={() => setActiveModal(null)} className="px-4 py-2.5 bg-dark-indigo-glow border border-white/5 hover:bg-white/5 text-slate-400 hover:text-white text-xs font-bold rounded-xl transition-all">Cancel</button>
<button onClick={handleAddMoveCall} className="px-4 py-2.5 bg-purple-600 hover:bg-purple-500 text-white text-xs font-bold rounded-xl shadow-lg transition-all">Add Node</button>
</div>
</div>
</div>
</div>
)}
{activeModal === 'splitCoins' && (
<div className="fixed inset-0 z-[100] flex items-center justify-center p-4 bg-near-black/60 backdrop-blur-md animate-in fade-in duration-200">
<div className="bg-[#0c0c0e] border border-white/5 rounded-2xl shadow-2xl w-full max-w-xl overflow-hidden relative">
<div className="absolute top-0 left-0 w-full h-1 bg-gradient-to-r from-transparent via-amber-500 to-transparent opacity-50" />
<div className="p-6 relative z-10">
<div className="flex items-start justify-between mb-4">
<div className="flex items-center gap-3">
<div className="w-10 h-10 bg-dark-indigo-glow rounded-xl border border-white/5 flex items-center justify-center shrink-0">
<Plus size={18} className="text-amber-400" />
</div>
<div>
<h2 className="text-sm font-bold text-white">Add Split Coins Step</h2>
<p className="text-xs text-slate-500 mt-0.5">Split a coin object into multiple smaller coins</p>
</div>
</div>
<button onClick={() => setActiveModal(null)} className="text-slate-500 hover:text-white transition-colors"><X size={18} /></button>
</div>
<div className="space-y-4">
<div>
<label className="block text-[10px] uppercase font-bold text-slate-500 mb-1">Input Coin Connection / Object ID *</label>
<input
value={splitInputCoin}
onChange={e => setSplitInputCoin(e.target.value)}
placeholder="e.g. c1 or 0x..."
className="w-full bg-black/40 border border-white/5 rounded-lg p-2 text-xs font-mono text-slate-200 focus:outline-none focus:border-amber-500/50"
/>
<p className="text-[10px] text-slate-500 mt-1">Select/type the name of the input coin connection (e.g. c1) or an Object ID.</p>
</div>
<div>
<label className="block text-[10px] uppercase font-bold text-slate-500 mb-1">Split Amounts (comma separated) *</label>
<input
value={splitAmounts}
onChange={e => setSplitAmounts(e.target.value)}
placeholder="e.g. 1000, 500"
className="w-full bg-black/40 border border-white/5 rounded-lg p-2 text-xs font-mono text-slate-200 focus:outline-none focus:border-amber-500/50"
/>
</div>
<div>
<label className="block text-[10px] uppercase font-bold text-slate-500 mb-1">Output Coin Connections (comma separated) *</label>
<input
value={splitOutputs}
onChange={e => setSplitOutputs(e.target.value)}
placeholder="e.g. split_1, split_2"
className="w-full bg-black/40 border border-white/5 rounded-lg p-2 text-xs font-mono text-slate-200 focus:outline-none focus:border-amber-500/50"
/>
<p className="text-[10px] text-slate-500 mt-1">Exported connection names for each split coin respectively.</p>
</div>
</div>
<div className="grid grid-cols-2 gap-3 mt-6">
<button onClick={() => setActiveModal(null)} className="px-4 py-2.5 bg-dark-indigo-glow border border-white/5 hover:bg-white/5 text-slate-400 hover:text-white text-xs font-bold rounded-xl transition-all">Cancel</button>
<button onClick={handleAddSplitCoins} className="px-4 py-2.5 bg-amber-600 hover:bg-amber-500 text-white text-xs font-bold rounded-xl shadow-lg transition-all">Add Node</button>
</div>
</div>
</div>
</div>
)}
</div>
);
};