-
Notifications
You must be signed in to change notification settings - Fork 0
/
inscriptionProcess.html
579 lines (473 loc) · 17.2 KB
/
inscriptionProcess.html
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
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bitcoin Audional Generator</title>
<style>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
background-color: #202020;
color: #fff;
font-family: 'ShareTechMono-Regular', Arial, sans-serif;
width: 100vw;
overflow-x: hidden;
}
.header {
align-items: center;
background-color: #000;
display: flex;
height: 100px;
justify-content: space-between;
width: 100vw;
}
.header img {
height: 100%;
}
.header h1 {
color: #fff;
flex-grow: 2;
font-size: 6em;
text-align: right;
margin-right: 100px;
}
.row {
display: flex;
flex-wrap: wrap;
margin: 0 -5px;
}
.form-group {
margin-bottom: 10px;
}
label {
display: block;
margin-bottom: 5px;
}
input[type=text],
textarea,
datalist,
input[type=checkbox],
input[type=file],
input[type=number] {
box-sizing: border-box;
height: 25px;
padding: 0;
width: 100%
}
.input-wrapper {
padding: 10px;
}
.form-group input[type=text],
.form-group textarea,
.form-group datalist,
.form-group input[type=file],
.form-group input[type=number] {
width: 100%
}
.button-container {
display: flex;
justify-content: center;
}
button {
background-color: green(255, 0, 0);
border: none;
color: #fff;
cursor: pointer;
padding: 10px 20px;
}
button:enabled {
background-color: #555;
}
.custom-button {
background-color: blue !important;
}
.flashing {
animation: flash 2s linear infinite;
background-color: rgb(55, 0, 255) !important;
}
@keyframes flash {
0% {
opacity: 1;
}
50% {
opacity: .7;
}
100% {
opacity: 1;
}
}
#json-output {
margin-top: 20px;
word-wrap: break-word;
}
.info-button,
.more-info-button {
display: block;
margin: 0 10px;
text-align: center;
border: none;
color: #fff;
cursor: pointer;
padding: 10px 20px;
}
.info-content {
display: none;
margin-top: 20px;
padding: 20px;
background-color: #333;
color: #fff;
}
.modal {
display: none;
position: fixed;
z-index: 9999;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgba(0, 0, 0, .8);
}
.modal-content {
background-color: #fff;
margin: 10% auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
max-width: 900px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, .2);
animation-name: modal-animation;
animation-duration: .5s;
}
@keyframes modal-animation {
from {
transform: scale(0);
}
to {
transform: scale(1);
}
}
.magic-button {
border: none;
color: #000;
cursor: pointer;
padding: 10px 20px;
position: relative;
overflow: hidden;
z-index: 0;
}
.magic-button:not(:disabled):before {
background: grey;
content: "";
background: linear-gradient(45deg, rgba(255, 255, 255, .1), rgba(255, 255, 255, .5), rgba(255, 255, 255, .1));
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
z-index: 1;
transform: rotate(0deg);
pointer-events: none;
animation: shimmer 5s ease-in-out infinite;
}
.magic-button:active:not(#inscribe:disabled) {
color: grey;
background: #000;
}
@keyframes shimmer {
0% {
left: -100%
}
50% {
left: 100%
}
100% {
left: -100%
}
}
.magic-button>* {
position: relative;
z-index: 10;
}
/* Added CSS for left and right columns */
.content-container {
display: flex;
margin-top: 20px;
justify-content: space-between;
}
.left-column {
flex: 1;
padding-right: 20px;
}
.right-column {
flex: 1;
padding-left: 20px;
}
.custom-gold-button {
background-color: gold !important;
}
.payment-input {
display: block;
width: 100%;
padding: 10px;
font-size: 20px;
border: 2px solid #ccc;
border-radius: 5px;
margin-bottom: 10px;
}
#inscribe:disabled.custom-gold-button {
background-color: grey !important;
color: #000;
}
#inscribe.enabled {
color: #000;
}
#metadata-button {
background-color: red!important;
}
</style>
<script src="startInscriptionProcess.js"></script>
</head>
<body>
<div class="header">
<img src="AudionalsLogo.png" alt="Audionals Logo">
<h1>Audionals.com</h1>
<div>
<button id="sequencer-button" class="magic-button custom-gold-button" onclick="tryAudionalSequencer()">Register Audional IDs</button>
<p style="text-align: center; color: rgb(255, 255, 255);">For the Audional Sequencer</p>
</div>
<img src="AudionalsLogo.png" alt="Audionals Logo">
</div>
<div id="sequencer-container">
</div>
<div class="button-container">
</div>
<div class="content-container">
<div class="left-column">
<div class="button-container" style="display: flex; justify-content: center;">
<button id="metadata-button" class="info-button active" onclick="toggleDescription('taproot')">Check Your Metadata</button>
</div>
<div class="info-content" id="info-content-taproot">
<p>Some information about best practices when filling JSON fields for indexing</p>
</div>
<h1>Audional Inscription Order</h1>
<main id="app" role="main">
<p id="reminder" style="color: rgb(250, 66, 66); font-weight: bold;">Please enter the address that you want your audional inscription sent to <br> and check over the audional JSON file you are about to inscribe (in the box below).</p>
<fieldset class="form-group">
<legend>Audional Ordinal Recipient Address:</legend>
<div class="input-wrapper">
<input id="bitcoinAddress" type="text" placeholder="Enter the Bitcoin address to receive this inscription. Must be TAPROOT COMPATIBLE address starting with bc1" oninput="validateBitcoinAddress(this)">
</div>
</fieldset>
<script>function validateBitcoinAddress(input) {
const address = input.value.trim();
const isValid = address.startsWith("bc1");
input.setCustomValidity(isValid ? "" : "Bitcoin address must start with 'bc1'");
}</script>
<fieldset class="form-group">
<legend>View your Audional JSON file (check field details are correct)</legend>
<div class="input-wrapper">
<textarea id="user-defined" class="input-width" style="width: 600px; height: 350px;" placeholder=""></textarea>
</div>
</fieldset>
<br>
<div>
</div>
</div>
<div class="right-column">
<div class="button-container" style="display: flex; justify-content: center;">
<button id="check-order-button" class="more-info-button custom-button" onclick="toggleDescription('json')">Check Existing Orders</button>
</div>
<div class="info-content" id="info-content-json" style="display: none;">
<p>No existing orders found</p>
</div>
<h1>Audional Inscription Payment</h1>
<main id="app" role="main">
<button id="checkPrice" class="flashing" onclick="showPaymentDetails()">Get Inscription Price</button>
<button id="inscribe" class="magic-button custom-gold-button" disabled>Inscribe Audional</button>
<fieldset class="form-group">
<legend>Check Payment Details</legend>
<div id="user-defined-right" class="input-wrapper">
<textarea class="input-width" style="width: 600px; height: 430px;" placeholder=""></textarea>
</div>
</fieldset>
<br>
<div>
</div>
</main>
</div>
<script>
// Define these values globally or within your class/component scope
let inscriptionCost = null;
let currentFeeRates = null;
export async function startInscriptionProcess(
audionalJsonTextarea,
inscriptionPreviewContainer,
estimatedFeesSpan,
networkFeeRateSpan
) {
var audionalJsonObject = JSON.parse(audionalJsonTextarea.value);
var inscriptionPreview = await getInscriptionPreview(audionalJsonObject);
var totalFees = inscriptionPreview.calculated_fee_summary.high.total_fee_sats;
// Save these values to use later
inscriptionCost = totalFees;
currentFeeRates = inscriptionPreview.calculated_fee_summary.high.network_fee_rate;
// hide audionalJsonTextarea
audionalJsonTextarea.style.display = "none";
// show inscriptionPreviewArea
inscriptionPreviewContainer.style.display = "block";
// update span with id estimatedFees to totalFees
estimatedFeesSpan.value = totalFees;
networkFeeRateSpan.value = currentFeeRates;
}
function showPaymentDetails() {
// Retrieve the Audional Ordinal Recipient Address
const recipientAddress = document.getElementById("bitcoinAddress").value.trim();
// Check if the recipient address is valid
if (!isValidRecipientAddress(recipientAddress)) {
alert("Please enter a valid recipient's address.");
return;
}
// Show loading state
const inscriptionButton = document.getElementById("inscribe");
inscriptionButton.disabled = true;
inscriptionButton.classList.remove("custom-gold-button");
// Simulate asynchronous data retrieval
setTimeout(function() {
// Retrieve the current fee rates, inscription cost, and Bitcoin payment address
// Now we use actual values from `startInscriptionProcess`
const paymentAddress = getPaymentAddress(); // Replace this with your own logic to get the payment address
// Create and populate the text nodes for displaying the information
const feeRatesTextNode = document.createTextNode("Current Fee Rates: " + currentFeeRates);
const inscriptionCostTextNode = document.createTextNode("Inscription Cost: " + inscriptionCost);
const paymentAddressTextNode = document.createTextNode("Payment Address: " + paymentAddress);
// Clear the current content and append the text nodes
const userDefinedRight = document.getElementById("user-defined-right");
userDefinedRight.innerHTML = ''; // Clear the current content
const feeRatesInput = document.createElement("div");
feeRatesInput.className = "payment-input";
feeRatesInput.appendChild(feeRatesTextNode);
userDefinedRight.appendChild(feeRatesInput);
const inscriptionCostInput = document.createElement("div");
inscriptionCostInput.className = "payment-input";
inscriptionCostInput.appendChild(inscriptionCostTextNode);
userDefinedRight.appendChild(inscriptionCostInput);
const paymentAddressInput = document.createElement("div");
paymentAddressInput.className = "payment-input";
paymentAddressInput.appendChild(paymentAddressTextNode);
userDefinedRight.appendChild(paymentAddressInput);
// Enable and style the inscription button
inscriptionButton.disabled = false;
setTimeout(function() {
inscriptionButton.classList.add("custom-gold-button", "enabled");
}, 100); // Delay for button color change and shimmer effect
}, 2000); // Simulated delay, replace with your data retrieval logic
}
function isValidRecipientAddress(address) {
// Replace this with your own validation logic for the recipient's address
// Return true if the address is valid, false otherwise
return address.startsWith("bc1");
}
// Example functions to retrieve the fee rates, inscription cost, and payment address
function getCurrentFeeRates() {
// Replace this with your own logic to retrieve the current fee rates
return "15 Sat/vB";
}
function getInscriptionCost() {
// Replace this with your own logic to retrieve the inscription cost
return "15 Sat/vB * filesize";
}
function getPaymentAddress() {
// Replace this with your own logic to retrieve the payment address
return "1ABCxyz..."; // Example payment address
}
window.addEventListener('DOMContentLoaded', (event) => {
fetch("Step-for-man_audional.json")
.then(response => response.json())
.then(data => {
const textarea = document.getElementById("user-defined");
textarea.placeholder = JSON.stringify(data, null, 2);
})
.catch(error => console.error('Error:', error));
});
function toggleInfo(buttonId) {
var audionalsButton = document.getElementById("audionals-button");
var jsonButton = document.getElementById("check-order-button");
var audionalsContent = document.getElementById("info-content-audionals");
var jsonContent = document.getElementById("info-content-json");
if (buttonId === "audionals") {
var isAudionalsActive = audionalsButton.classList.contains("active");
if (isAudionalsActive) {
audionalsButton.classList.remove("active");
audionalsContent.style.display = "none";
} else {
audionalsButton.classList.add("active");
jsonButton.classList.remove("active");
audionalsContent.style.display = "block";
jsonContent.style.display = "none";
}
} else {
var isJsonActive = jsonButton.classList.contains("active");
if (isJsonActive) {
jsonButton.classList.remove("active");
jsonContent.style.display = "none";
} else {
jsonButton.classList.add("active");
audionalsButton.classList.remove("active");
audionalsContent.style.display = "none";
jsonContent.style.display = "block";
}
}
}
function toggleDescription(buttonId) {
var taprootButton = document.getElementById("metadata-button");
var jsonButton = document.getElementById("check-order-button");
var taprootContent = document.getElementById("info-content-taproot");
var jsonContent = document.getElementById("info-content-json");
if (buttonId === "taproot") {
var isTaprootActive = taprootButton.classList.contains("active");
if (isTaprootActive) {
taprootButton.classList.remove("active");
taprootContent.style.display = "none";
} else {
taprootButton.classList.add("active");
jsonButton.classList.remove("active");
taprootContent.style.display = "block";
jsonContent.style.display = "none";
}
} else {
var isJsonActive = jsonButton.classList.contains("active");
if (isJsonActive) {
jsonButton.classList.remove("active");
jsonContent.style.display = "none";
} else {
jsonButton.classList.add("active");
taprootButton.classList.remove("active");
taprootContent.style.display = "none";
jsonContent.style.display = "block";
}
}
}
// Set initial state
window.onload = function() {
var audionalsButton = document.getElementById("audionals-button");
var taprootButton = document.getElementById("metadata-button");
var jsonButton = document.getElementById("check-order-button");
var audionalsContent = document.getElementById("info-content-audionals");
var taprootContent = document.getElementById("info-content-taproot");
var jsonContent = document.getElementById("info-content-json");
// Enable all buttons
audionalsButton.disabled = false;
taprootButton.disabled = false;
jsonButton.disabled = false;
// Show all content
audionalsContent.style.display = "block";
taprootContent.style.display = "block";
jsonContent.style.display = "block";
};
</script>
</main>
</body>
</html>