@lukso/transaction-view-core 0.6.5 → 0.6.6-dev.2b7df2e
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/.turbo/turbo-build.log +11 -11
- package/.turbo/turbo-typecheck.log +1 -1
- package/CHANGELOG.md +15 -0
- package/dist/index.cjs +102 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +34 -16
- package/dist/index.d.ts +34 -16
- package/dist/index.js +105 -3
- package/dist/index.js.map +1 -1
- package/package.json +11 -6
- package/src/components/transaction-playback.ts +162 -19
- package/tsup.config.ts +3 -0
package/dist/index.d.cts
CHANGED
|
@@ -6,6 +6,7 @@ import { ResolvedAddress, ViewContext, ViewVariant, ViewMatch, FrameworkViewConf
|
|
|
6
6
|
export { DecoderRecordForSelection, DefaultViewRegistry, FrameworkSupport, FrameworkViewConfig, ViewContext, ViewDefinition, ViewLoader, ViewMatch, ViewMatchOptions, ViewRegistry, getGlobalRegistry, resetGlobalRegistry, setGlobalRegistry } from '@lukso/transaction-view-headless';
|
|
7
7
|
import { DecoderResult } from '@lukso/transaction-decoder';
|
|
8
8
|
export { DecoderResult } from '@lukso/transaction-decoder';
|
|
9
|
+
import { Transaction, Chain } from 'viem';
|
|
9
10
|
import '@preact/signals-core';
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -434,11 +435,20 @@ declare global {
|
|
|
434
435
|
}
|
|
435
436
|
}
|
|
436
437
|
|
|
438
|
+
/**
|
|
439
|
+
* Raw transaction input type - accepts transactions with JSON, BigintJSON, or bigint values
|
|
440
|
+
*/
|
|
441
|
+
type RawTransactionInput = Transaction | Record<string, any>;
|
|
437
442
|
/**
|
|
438
443
|
* Lit Transaction Playback Component
|
|
439
444
|
*
|
|
440
|
-
* Provides index-based rendering of transactions with support for batch navigation
|
|
441
|
-
*
|
|
445
|
+
* Provides index-based rendering of transactions with support for batch navigation,
|
|
446
|
+
* context-aware view matching, and local transaction decoding.
|
|
447
|
+
*
|
|
448
|
+
* **Transaction Input:**
|
|
449
|
+
* - Pass a decoded transaction via `transaction` prop, OR
|
|
450
|
+
* - Pass a raw transaction via `rawTransaction` + `chain` props for local decoding
|
|
451
|
+
* - Raw transactions can have JSON, BigintJSON ("123n"), or bigint values
|
|
442
452
|
*
|
|
443
453
|
* **Single Transaction:**
|
|
444
454
|
* - index="0" → renders the transaction
|
|
@@ -462,35 +472,31 @@ declare global {
|
|
|
462
472
|
*
|
|
463
473
|
* @example
|
|
464
474
|
* ```html
|
|
465
|
-
* <!--
|
|
475
|
+
* <!-- With decoded transaction -->
|
|
466
476
|
* <transaction-playback
|
|
467
|
-
* .transaction="${
|
|
477
|
+
* .transaction="${decodedTransaction}"
|
|
468
478
|
* index="1"
|
|
469
479
|
* context="feed"
|
|
470
480
|
* variant="compact"
|
|
471
|
-
* @header-info="${(e) => console.log('Header:', e.detail)}"
|
|
472
481
|
* ></transaction-playback>
|
|
473
482
|
*
|
|
474
|
-
* <!--
|
|
483
|
+
* <!-- With raw transaction (local decoding) -->
|
|
475
484
|
* <transaction-playback
|
|
476
|
-
* .
|
|
485
|
+
* .rawTransaction="${rawTx}"
|
|
486
|
+
* .chain="${lukso}"
|
|
477
487
|
* index="1"
|
|
478
488
|
* context="approval"
|
|
479
489
|
* variant="full"
|
|
480
490
|
* ></transaction-playback>
|
|
481
|
-
*
|
|
482
|
-
* <!-- Batch summary: collapsed view -->
|
|
483
|
-
* <transaction-playback
|
|
484
|
-
* .transaction="${transaction}"
|
|
485
|
-
* index="0"
|
|
486
|
-
* context="batch-summary"
|
|
487
|
-
* variant="collapsed"
|
|
488
|
-
* ></transaction-playback>
|
|
489
491
|
* ```
|
|
490
492
|
*/
|
|
491
493
|
declare class TransactionPlayback extends CoreLitElement {
|
|
492
|
-
/** The
|
|
494
|
+
/** The decoded transaction to display */
|
|
493
495
|
transaction?: DecoderResult;
|
|
496
|
+
/** Raw transaction to decode internally (alternative to passing decoded transaction) */
|
|
497
|
+
rawTransaction?: RawTransactionInput;
|
|
498
|
+
/** Chain configuration for decoding (required when using rawTransaction) */
|
|
499
|
+
chain?: Chain;
|
|
494
500
|
/** Index to display (0, 1, 2, ...) */
|
|
495
501
|
index: number;
|
|
496
502
|
/** Fallback view ID if no match found (optional - fallback-screen is registered with lowest priority) */
|
|
@@ -504,15 +510,27 @@ declare class TransactionPlayback extends CoreLitElement {
|
|
|
504
510
|
private playbackState?;
|
|
505
511
|
private currentResult?;
|
|
506
512
|
private isLoading;
|
|
513
|
+
private isDecoding;
|
|
507
514
|
private error?;
|
|
508
515
|
private loadedComponent?;
|
|
509
516
|
private headerInfo?;
|
|
517
|
+
private decodedTransaction?;
|
|
510
518
|
private componentContainerRef;
|
|
511
519
|
private loader;
|
|
520
|
+
private decodingUnsubscribe?;
|
|
512
521
|
protected willUpdate(changedProperties: PropertyValues): void;
|
|
513
522
|
protected updated(_changedProperties: PropertyValues): void;
|
|
514
523
|
connectedCallback(): void;
|
|
515
524
|
disconnectedCallback(): void;
|
|
525
|
+
/**
|
|
526
|
+
* Decode a raw transaction locally (no server API calls)
|
|
527
|
+
* Accepts transactions with JSON, BigintJSON, or bigint values
|
|
528
|
+
*
|
|
529
|
+
* Two-phase decoding:
|
|
530
|
+
* 1. Immediate sync decoding - shows basic decoded transaction right away
|
|
531
|
+
* 2. Async enhancement - progressively enhances with additional data
|
|
532
|
+
*/
|
|
533
|
+
private decodeRawTransaction;
|
|
516
534
|
private handleHeaderInfo;
|
|
517
535
|
private loadView;
|
|
518
536
|
private renderDebugPanel;
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { ResolvedAddress, ViewContext, ViewVariant, ViewMatch, FrameworkViewConf
|
|
|
6
6
|
export { DecoderRecordForSelection, DefaultViewRegistry, FrameworkSupport, FrameworkViewConfig, ViewContext, ViewDefinition, ViewLoader, ViewMatch, ViewMatchOptions, ViewRegistry, getGlobalRegistry, resetGlobalRegistry, setGlobalRegistry } from '@lukso/transaction-view-headless';
|
|
7
7
|
import { DecoderResult } from '@lukso/transaction-decoder';
|
|
8
8
|
export { DecoderResult } from '@lukso/transaction-decoder';
|
|
9
|
+
import { Transaction, Chain } from 'viem';
|
|
9
10
|
import '@preact/signals-core';
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -434,11 +435,20 @@ declare global {
|
|
|
434
435
|
}
|
|
435
436
|
}
|
|
436
437
|
|
|
438
|
+
/**
|
|
439
|
+
* Raw transaction input type - accepts transactions with JSON, BigintJSON, or bigint values
|
|
440
|
+
*/
|
|
441
|
+
type RawTransactionInput = Transaction | Record<string, any>;
|
|
437
442
|
/**
|
|
438
443
|
* Lit Transaction Playback Component
|
|
439
444
|
*
|
|
440
|
-
* Provides index-based rendering of transactions with support for batch navigation
|
|
441
|
-
*
|
|
445
|
+
* Provides index-based rendering of transactions with support for batch navigation,
|
|
446
|
+
* context-aware view matching, and local transaction decoding.
|
|
447
|
+
*
|
|
448
|
+
* **Transaction Input:**
|
|
449
|
+
* - Pass a decoded transaction via `transaction` prop, OR
|
|
450
|
+
* - Pass a raw transaction via `rawTransaction` + `chain` props for local decoding
|
|
451
|
+
* - Raw transactions can have JSON, BigintJSON ("123n"), or bigint values
|
|
442
452
|
*
|
|
443
453
|
* **Single Transaction:**
|
|
444
454
|
* - index="0" → renders the transaction
|
|
@@ -462,35 +472,31 @@ declare global {
|
|
|
462
472
|
*
|
|
463
473
|
* @example
|
|
464
474
|
* ```html
|
|
465
|
-
* <!--
|
|
475
|
+
* <!-- With decoded transaction -->
|
|
466
476
|
* <transaction-playback
|
|
467
|
-
* .transaction="${
|
|
477
|
+
* .transaction="${decodedTransaction}"
|
|
468
478
|
* index="1"
|
|
469
479
|
* context="feed"
|
|
470
480
|
* variant="compact"
|
|
471
|
-
* @header-info="${(e) => console.log('Header:', e.detail)}"
|
|
472
481
|
* ></transaction-playback>
|
|
473
482
|
*
|
|
474
|
-
* <!--
|
|
483
|
+
* <!-- With raw transaction (local decoding) -->
|
|
475
484
|
* <transaction-playback
|
|
476
|
-
* .
|
|
485
|
+
* .rawTransaction="${rawTx}"
|
|
486
|
+
* .chain="${lukso}"
|
|
477
487
|
* index="1"
|
|
478
488
|
* context="approval"
|
|
479
489
|
* variant="full"
|
|
480
490
|
* ></transaction-playback>
|
|
481
|
-
*
|
|
482
|
-
* <!-- Batch summary: collapsed view -->
|
|
483
|
-
* <transaction-playback
|
|
484
|
-
* .transaction="${transaction}"
|
|
485
|
-
* index="0"
|
|
486
|
-
* context="batch-summary"
|
|
487
|
-
* variant="collapsed"
|
|
488
|
-
* ></transaction-playback>
|
|
489
491
|
* ```
|
|
490
492
|
*/
|
|
491
493
|
declare class TransactionPlayback extends CoreLitElement {
|
|
492
|
-
/** The
|
|
494
|
+
/** The decoded transaction to display */
|
|
493
495
|
transaction?: DecoderResult;
|
|
496
|
+
/** Raw transaction to decode internally (alternative to passing decoded transaction) */
|
|
497
|
+
rawTransaction?: RawTransactionInput;
|
|
498
|
+
/** Chain configuration for decoding (required when using rawTransaction) */
|
|
499
|
+
chain?: Chain;
|
|
494
500
|
/** Index to display (0, 1, 2, ...) */
|
|
495
501
|
index: number;
|
|
496
502
|
/** Fallback view ID if no match found (optional - fallback-screen is registered with lowest priority) */
|
|
@@ -504,15 +510,27 @@ declare class TransactionPlayback extends CoreLitElement {
|
|
|
504
510
|
private playbackState?;
|
|
505
511
|
private currentResult?;
|
|
506
512
|
private isLoading;
|
|
513
|
+
private isDecoding;
|
|
507
514
|
private error?;
|
|
508
515
|
private loadedComponent?;
|
|
509
516
|
private headerInfo?;
|
|
517
|
+
private decodedTransaction?;
|
|
510
518
|
private componentContainerRef;
|
|
511
519
|
private loader;
|
|
520
|
+
private decodingUnsubscribe?;
|
|
512
521
|
protected willUpdate(changedProperties: PropertyValues): void;
|
|
513
522
|
protected updated(_changedProperties: PropertyValues): void;
|
|
514
523
|
connectedCallback(): void;
|
|
515
524
|
disconnectedCallback(): void;
|
|
525
|
+
/**
|
|
526
|
+
* Decode a raw transaction locally (no server API calls)
|
|
527
|
+
* Accepts transactions with JSON, BigintJSON, or bigint values
|
|
528
|
+
*
|
|
529
|
+
* Two-phase decoding:
|
|
530
|
+
* 1. Immediate sync decoding - shows basic decoded transaction right away
|
|
531
|
+
* 2. Async enhancement - progressively enhances with additional data
|
|
532
|
+
*/
|
|
533
|
+
private decodeRawTransaction;
|
|
516
534
|
private handleHeaderInfo;
|
|
517
535
|
private loadView;
|
|
518
536
|
private renderDebugPanel;
|
package/dist/index.js
CHANGED
|
@@ -4262,6 +4262,10 @@ PermissionsBlock = __decorateClass([
|
|
|
4262
4262
|
], PermissionsBlock);
|
|
4263
4263
|
|
|
4264
4264
|
// src/components/transaction-playback.ts
|
|
4265
|
+
import {
|
|
4266
|
+
decodeTransaction,
|
|
4267
|
+
JSONbigString
|
|
4268
|
+
} from "@lukso/transaction-decoder";
|
|
4265
4269
|
import {
|
|
4266
4270
|
createTransactionPlayback,
|
|
4267
4271
|
isHeaderInfoEvent,
|
|
@@ -4416,6 +4420,7 @@ var TransactionPlayback = class extends CoreLitElement {
|
|
|
4416
4420
|
this.index = 1;
|
|
4417
4421
|
this.debug = false;
|
|
4418
4422
|
this.isLoading = false;
|
|
4423
|
+
this.isDecoding = false;
|
|
4419
4424
|
this.componentContainerRef = createRef();
|
|
4420
4425
|
this.loader = getGlobalLitLoader();
|
|
4421
4426
|
this.handleHeaderInfo = (event) => {
|
|
@@ -4432,7 +4437,13 @@ var TransactionPlayback = class extends CoreLitElement {
|
|
|
4432
4437
|
};
|
|
4433
4438
|
}
|
|
4434
4439
|
willUpdate(changedProperties) {
|
|
4435
|
-
if (changedProperties.has("
|
|
4440
|
+
if (changedProperties.has("rawTransaction") || changedProperties.has("chain")) {
|
|
4441
|
+
if (this.rawTransaction) {
|
|
4442
|
+
this.decodeRawTransaction();
|
|
4443
|
+
return;
|
|
4444
|
+
}
|
|
4445
|
+
}
|
|
4446
|
+
if (changedProperties.has("transaction") || changedProperties.has("decodedTransaction") || changedProperties.has("index") || changedProperties.has("context") || changedProperties.has("variant")) {
|
|
4436
4447
|
this.loadView();
|
|
4437
4448
|
}
|
|
4438
4449
|
}
|
|
@@ -4455,9 +4466,80 @@ var TransactionPlayback = class extends CoreLitElement {
|
|
|
4455
4466
|
TransactionViewEvents.HEADER_INFO,
|
|
4456
4467
|
this.handleHeaderInfo
|
|
4457
4468
|
);
|
|
4469
|
+
if (this.decodingUnsubscribe) {
|
|
4470
|
+
this.decodingUnsubscribe();
|
|
4471
|
+
this.decodingUnsubscribe = void 0;
|
|
4472
|
+
}
|
|
4473
|
+
}
|
|
4474
|
+
/**
|
|
4475
|
+
* Decode a raw transaction locally (no server API calls)
|
|
4476
|
+
* Accepts transactions with JSON, BigintJSON, or bigint values
|
|
4477
|
+
*
|
|
4478
|
+
* Two-phase decoding:
|
|
4479
|
+
* 1. Immediate sync decoding - shows basic decoded transaction right away
|
|
4480
|
+
* 2. Async enhancement - progressively enhances with additional data
|
|
4481
|
+
*/
|
|
4482
|
+
async decodeRawTransaction() {
|
|
4483
|
+
if (!this.rawTransaction) {
|
|
4484
|
+
return;
|
|
4485
|
+
}
|
|
4486
|
+
if (!this.chain) {
|
|
4487
|
+
this.error = "Chain configuration is required when decoding raw transactions";
|
|
4488
|
+
return;
|
|
4489
|
+
}
|
|
4490
|
+
this.isDecoding = true;
|
|
4491
|
+
this.error = void 0;
|
|
4492
|
+
this.decodedTransaction = void 0;
|
|
4493
|
+
if (this.decodingUnsubscribe) {
|
|
4494
|
+
this.decodingUnsubscribe();
|
|
4495
|
+
this.decodingUnsubscribe = void 0;
|
|
4496
|
+
}
|
|
4497
|
+
try {
|
|
4498
|
+
const normalizedTx = JSONbigString.read(this.rawTransaction);
|
|
4499
|
+
const result = await decodeTransaction(normalizedTx, {
|
|
4500
|
+
chain: this.chain,
|
|
4501
|
+
plugins: [],
|
|
4502
|
+
// Use auto-registered plugins
|
|
4503
|
+
schemaPlugins: [],
|
|
4504
|
+
// Use auto-registered schema plugins
|
|
4505
|
+
wrappers: [],
|
|
4506
|
+
// No wrapper detection needed for raw transactions
|
|
4507
|
+
async: true
|
|
4508
|
+
// Enable async enhancement (ABI fetching, address resolution)
|
|
4509
|
+
});
|
|
4510
|
+
if (!Array.isArray(result)) {
|
|
4511
|
+
this.decodedTransaction = result.immediate;
|
|
4512
|
+
this.isDecoding = false;
|
|
4513
|
+
this.loadView();
|
|
4514
|
+
this.decodingUnsubscribe = result.signal.subscribe((state11) => {
|
|
4515
|
+
if (state11.data && state11.data !== this.decodedTransaction) {
|
|
4516
|
+
this.decodedTransaction = state11.data;
|
|
4517
|
+
this.loadView();
|
|
4518
|
+
}
|
|
4519
|
+
});
|
|
4520
|
+
} else {
|
|
4521
|
+
const firstResult = result[0];
|
|
4522
|
+
this.decodedTransaction = firstResult.immediate;
|
|
4523
|
+
this.isDecoding = false;
|
|
4524
|
+
this.loadView();
|
|
4525
|
+
this.decodingUnsubscribe = firstResult.signal.subscribe(
|
|
4526
|
+
(state11) => {
|
|
4527
|
+
if (state11.data && state11.data !== this.decodedTransaction) {
|
|
4528
|
+
this.decodedTransaction = state11.data;
|
|
4529
|
+
this.loadView();
|
|
4530
|
+
}
|
|
4531
|
+
}
|
|
4532
|
+
);
|
|
4533
|
+
}
|
|
4534
|
+
} catch (err) {
|
|
4535
|
+
this.error = err instanceof Error ? err.message : "Failed to decode transaction";
|
|
4536
|
+
this.isDecoding = false;
|
|
4537
|
+
console.error("Transaction decoding error:", err);
|
|
4538
|
+
}
|
|
4458
4539
|
}
|
|
4459
4540
|
async loadView() {
|
|
4460
|
-
|
|
4541
|
+
const txToDisplay = this.decodedTransaction || this.transaction;
|
|
4542
|
+
if (!txToDisplay) {
|
|
4461
4543
|
this.error = "No transaction provided";
|
|
4462
4544
|
return;
|
|
4463
4545
|
}
|
|
@@ -4466,7 +4548,7 @@ var TransactionPlayback = class extends CoreLitElement {
|
|
|
4466
4548
|
this.loadedComponent = void 0;
|
|
4467
4549
|
this.headerInfo = void 0;
|
|
4468
4550
|
try {
|
|
4469
|
-
this.playbackState = createTransactionPlayback(
|
|
4551
|
+
this.playbackState = createTransactionPlayback(txToDisplay, {
|
|
4470
4552
|
framework: "lit",
|
|
4471
4553
|
fallbackViewId: this.fallbackViewId,
|
|
4472
4554
|
context: this.context,
|
|
@@ -4588,6 +4670,14 @@ var TransactionPlayback = class extends CoreLitElement {
|
|
|
4588
4670
|
`;
|
|
4589
4671
|
}
|
|
4590
4672
|
render() {
|
|
4673
|
+
if (this.isDecoding) {
|
|
4674
|
+
return html19`
|
|
4675
|
+
<div class="flex flex-col items-center justify-center py-15 px-5 text-neutral-60">
|
|
4676
|
+
<div class="text-32 mb-4 animate-spin">🔄</div>
|
|
4677
|
+
<div class="text-16 font-500">Decoding transaction...</div>
|
|
4678
|
+
</div>
|
|
4679
|
+
`;
|
|
4680
|
+
}
|
|
4591
4681
|
if (this.isLoading) {
|
|
4592
4682
|
return html19`
|
|
4593
4683
|
<div class="flex flex-col items-center justify-center py-15 px-5 text-neutral-60">
|
|
@@ -4640,6 +4730,12 @@ var TransactionPlayback = class extends CoreLitElement {
|
|
|
4640
4730
|
__decorateClass([
|
|
4641
4731
|
property19({ type: Object })
|
|
4642
4732
|
], TransactionPlayback.prototype, "transaction", 2);
|
|
4733
|
+
__decorateClass([
|
|
4734
|
+
property19({ type: Object })
|
|
4735
|
+
], TransactionPlayback.prototype, "rawTransaction", 2);
|
|
4736
|
+
__decorateClass([
|
|
4737
|
+
property19({ type: Object })
|
|
4738
|
+
], TransactionPlayback.prototype, "chain", 2);
|
|
4643
4739
|
__decorateClass([
|
|
4644
4740
|
property19({ type: Number })
|
|
4645
4741
|
], TransactionPlayback.prototype, "index", 2);
|
|
@@ -4664,6 +4760,9 @@ __decorateClass([
|
|
|
4664
4760
|
__decorateClass([
|
|
4665
4761
|
state10()
|
|
4666
4762
|
], TransactionPlayback.prototype, "isLoading", 2);
|
|
4763
|
+
__decorateClass([
|
|
4764
|
+
state10()
|
|
4765
|
+
], TransactionPlayback.prototype, "isDecoding", 2);
|
|
4667
4766
|
__decorateClass([
|
|
4668
4767
|
state10()
|
|
4669
4768
|
], TransactionPlayback.prototype, "error", 2);
|
|
@@ -4673,6 +4772,9 @@ __decorateClass([
|
|
|
4673
4772
|
__decorateClass([
|
|
4674
4773
|
state10()
|
|
4675
4774
|
], TransactionPlayback.prototype, "headerInfo", 2);
|
|
4775
|
+
__decorateClass([
|
|
4776
|
+
state10()
|
|
4777
|
+
], TransactionPlayback.prototype, "decodedTransaction", 2);
|
|
4676
4778
|
TransactionPlayback = __decorateClass([
|
|
4677
4779
|
safeCustomElement("transaction-playback")
|
|
4678
4780
|
], TransactionPlayback);
|