Skip to content

Commit d341bc7

Browse files
committed
test: cover soroban event worker decoding and handlers
1 parent d16912b commit d341bc7

2 files changed

Lines changed: 449 additions & 5 deletions

File tree

backend/src/workers/soroban-event-worker.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ const INDEXER_STATE_ID = 'singleton';
1010
// ─── XDR Decoding Helpers ────────────────────────────────────────────────────
1111

1212
/** Decode an ScVal symbol to a string. */
13-
function decodeSymbol(val: xdr.ScVal): string {
13+
export function decodeSymbol(val: xdr.ScVal): string {
1414
return val.sym().toString();
1515
}
1616

1717
/**
1818
* Decode an ScVal U64 to a JavaScript bigint.
1919
* `xdr.UInt64` extends Long; `.toString()` gives the decimal representation.
2020
*/
21-
function decodeU64(val: xdr.ScVal): bigint {
21+
export function decodeU64(val: xdr.ScVal): bigint {
2222
return BigInt(val.u64().toString());
2323
}
2424

@@ -27,7 +27,7 @@ function decodeU64(val: xdr.ScVal): bigint {
2727
* I128 in XDR is split into hi (signed Int64) and lo (unsigned Uint64).
2828
* Full value = hi * 2^64 + lo.
2929
*/
30-
function decodeI128(val: xdr.ScVal): string {
30+
export function decodeI128(val: xdr.ScVal): string {
3131
const parts = val.i128();
3232
const hi = BigInt.asIntN(64, BigInt(parts.hi().toString()));
3333
const lo = BigInt.asUintN(64, BigInt(parts.lo().toString()));
@@ -38,7 +38,7 @@ function decodeI128(val: xdr.ScVal): string {
3838
* Decode an ScVal Address to a Stellar public key (G...) or contract (C...)
3939
* string.
4040
*/
41-
function decodeAddress(val: xdr.ScVal): string {
41+
export function decodeAddress(val: xdr.ScVal): string {
4242
const addr = val.address();
4343
if (
4444
addr.switch().value ===
@@ -54,7 +54,7 @@ function decodeAddress(val: xdr.ScVal): string {
5454
* Decode an ScVal Map (a `#[contracttype]` struct) into a plain object keyed
5555
* by field name with raw ScVal values for further decoding.
5656
*/
57-
function decodeMap(val: xdr.ScVal): Record<string, xdr.ScVal> {
57+
export function decodeMap(val: xdr.ScVal): Record<string, xdr.ScVal> {
5858
const result: Record<string, xdr.ScVal> = {};
5959
const entries = val.map();
6060
if (!entries) return result;

0 commit comments

Comments
 (0)