@kaleidorg/wallet-engine 1.0.0-beta.36 → 1.0.0-beta.37

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rgb-converters.js","sourceRoot":"","sources":["../../src/lib/rgb-converters.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,eAAe,GAChB,MAAM,eAAe,CAAC;AAEvB,6EAA6E;AAC7E,kFAAkF;AAClF,uEAAuE;AACvE,2EAA2E;AAC3E,2BAA2B;AAE3B;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,UAA8B;IAC9D,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;IAC9E,OAAO;QACL,KAAK,EAAE,OAAO,CAAC,OAAO,IAAI,CAAC;QAC3B,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,CAAC;QACjC,OAAO,EAAE,OAAO,CAAC,MAAM,IAAI,CAAC;QAC5B,YAAY,EAAE,YAAY,CAAC,OAAO,CAAC,OAAO,IAAI,CAAC,EAAE,CAAC,CAAC;QACnD,gBAAgB,EAAE,YAAY,CAAC,OAAO,CAAC,SAAS,IAAI,CAAC,EAAE,CAAC,CAAC;KAC1D,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAC/B,OAA6B,EAC7B,YAAoB,CAAC;IAErB,OAAO;QACL,KAAK,EAAE,OAAO,CAAC,OAAO,IAAI,CAAC;QAC3B,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,CAAC;QACjC,OAAO,EAAE,OAAO,CAAC,MAAM,IAAI,CAAC;QAC5B,MAAM,EAAE,OAAO,CAAC,iBAAiB,IAAI,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AO,CAAC,UAAiC;QAC1D,CAAC,CAAE,OAAO,CAAC,UAAqB,GAAG,IAAI;QACvC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;IACf,OAAO;QACL,EAAE,EAAG,OAAO,CAAC,YAAuB,IAAI,OAAO,IAAI,CAAC,GAAG,EAAE,EAAE;QAC3D,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM;QAClC,MAAM,EAAE,gBAAgB,CAAC,OAAO,CAAC,MAA4B,CAAC;QAC9D,SAAS;QACT,MAAM;QACN,aAAa,EAAE,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;QACtC,GAAG,EAAE,CAAC;QACN,UAAU,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC;QAC9B,KAAK,EAAE,EAAkB;QACzB,EAAE,EAAE,OAAO,CAAC,YAAkC;QAC9C,YAAY,EAAE,OAAO;KACtB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Pure fee-rate policy for RGB on-chain operations.
3
+ *
4
+ * Extracted from `RgbAdapter#resolveFeeRate` so the priority order +
5
+ * mainnet floors are unit-testable without a live RGB client.
6
+ *
7
+ * The policy ([GL #26]):
8
+ * 1. If the caller passed a positive `provided` rate, honour it. The
9
+ * advanced UI can override the floor when the user knows what they
10
+ * want.
11
+ * 2. Non-mainnet networks (regtest/signet/testnet/null/unknown):
12
+ * return `1 sat/vB`. Cheap, always confirms locally.
13
+ * 3. Mainnet: ask the node for an estimate at the urgency-mapped block
14
+ * target, floor at `MAINNET_FEE_FLOOR[urgency]` so a cold-started
15
+ * node returning `1 sat/vB` doesn't strand mainnet transactions.
16
+ * 4. Mainnet + estimate failure: return the floor.
17
+ */
18
+ export type FeeUrgency = "low" | "normal" | "high";
19
+ /**
20
+ * Conservative mainnet floors (sat/vB). Well above the dust-attack rate
21
+ * but still cheap relative to any user-facing payment. Tuned for a
22
+ * typical 10-min-block target at "normal" urgency. Adjust here if
23
+ * mainnet conditions shift — every call site reads from this table.
24
+ */
25
+ export declare const MAINNET_FEE_FLOOR: Record<FeeUrgency, number>;
26
+ export interface ResolveRgbFeeRateInput {
27
+ /** Caller-provided rate (advanced UI override). Wins when > 0. */
28
+ provided: number | undefined;
29
+ /** Urgency tier; maps to a block target + floor. */
30
+ urgency: FeeUrgency;
31
+ /** Active network from the adapter config. `null` = unknown / not connected. */
32
+ network: string | null;
33
+ /**
34
+ * Async estimator. Receives the urgency-mapped block target. Should return
35
+ * the node's `fee_rate` in sat/vB, or `null` on failure. Failures must
36
+ * not throw — the policy needs a value to fall back on.
37
+ */
38
+ estimateFn: (blocks: number) => Promise<number | null>;
39
+ }
40
+ export declare function resolveRgbFeeRatePolicy(input: ResolveRgbFeeRateInput): Promise<number>;
41
+ //# sourceMappingURL=rgb-fee-policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rgb-fee-policy.d.ts","sourceRoot":"","sources":["../../src/lib/rgb-fee-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AASnD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAIxD,CAAC;AAEF,MAAM,WAAW,sBAAsB;IACrC,kEAAkE;IAClE,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,oDAAoD;IACpD,OAAO,EAAE,UAAU,CAAC;IACpB,gFAAgF;IAChF,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB;;;;OAIG;IACH,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CACxD;AAED,wBAAsB,uBAAuB,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC,CAgB5F"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Pure fee-rate policy for RGB on-chain operations.
3
+ *
4
+ * Extracted from `RgbAdapter#resolveFeeRate` so the priority order +
5
+ * mainnet floors are unit-testable without a live RGB client.
6
+ *
7
+ * The policy ([GL #26]):
8
+ * 1. If the caller passed a positive `provided` rate, honour it. The
9
+ * advanced UI can override the floor when the user knows what they
10
+ * want.
11
+ * 2. Non-mainnet networks (regtest/signet/testnet/null/unknown):
12
+ * return `1 sat/vB`. Cheap, always confirms locally.
13
+ * 3. Mainnet: ask the node for an estimate at the urgency-mapped block
14
+ * target, floor at `MAINNET_FEE_FLOOR[urgency]` so a cold-started
15
+ * node returning `1 sat/vB` doesn't strand mainnet transactions.
16
+ * 4. Mainnet + estimate failure: return the floor.
17
+ */
18
+ /** Block-target mapping per urgency. high = next block, low = ~2 hours. */
19
+ const URGENCY_BLOCKS = {
20
+ high: 1,
21
+ normal: 6,
22
+ low: 12,
23
+ };
24
+ /**
25
+ * Conservative mainnet floors (sat/vB). Well above the dust-attack rate
26
+ * but still cheap relative to any user-facing payment. Tuned for a
27
+ * typical 10-min-block target at "normal" urgency. Adjust here if
28
+ * mainnet conditions shift — every call site reads from this table.
29
+ */
30
+ export const MAINNET_FEE_FLOOR = {
31
+ low: 5,
32
+ normal: 10,
33
+ high: 25,
34
+ };
35
+ export async function resolveRgbFeeRatePolicy(input) {
36
+ const { provided, urgency, network, estimateFn } = input;
37
+ if (typeof provided === "number" && Number.isFinite(provided) && provided > 0) {
38
+ return provided;
39
+ }
40
+ const isMainnet = network === "mainnet";
41
+ if (!isMainnet) {
42
+ return 1;
43
+ }
44
+ const floor = MAINNET_FEE_FLOOR[urgency];
45
+ const blocks = URGENCY_BLOCKS[urgency];
46
+ const estimate = await estimateFn(blocks);
47
+ if (estimate == null || !Number.isFinite(estimate) || estimate <= 0) {
48
+ return floor;
49
+ }
50
+ return Math.max(Math.floor(estimate), floor);
51
+ }
52
+ //# sourceMappingURL=rgb-fee-policy.js.map
@@ -0,0 +1 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@ -0,0 +1,54 @@
1
+ /**
2
+ * Pure helpers for the RGB adapter.
3
+ *
4
+ * Extracted from src/protocols/rgb/adapter.ts so the adapter file can stay
5
+ * focused on the IProtocolAdapter surface + SDK orchestration. Everything in
6
+ * this module is side-effect free, has no `this` dependencies, and is
7
+ * covered by tests/unit/rgb-helpers.test.ts.
8
+ *
9
+ * Adding to this module: keep helpers pure (no class state, no SDK calls).
10
+ * Anything that needs the kaleido SDK client or the adapter's own config
11
+ * belongs in adapter.ts.
12
+ */
13
+ import type { TransactionStatus, TransactionType } from "../types/base.js";
14
+ /**
15
+ * Render a raw integer amount in the asset's display precision.
16
+ * Always emits `precision` fractional digits — the caller can trim trailing
17
+ * zeros if it wants a tighter rendering.
18
+ */
19
+ export declare function formatAmount(amount: number, precision: number): string;
20
+ /**
21
+ * Map the SDK's transfer `kind` field to our unified TransactionType.
22
+ *
23
+ * The SDK is inconsistent about case + naming — both raw lowercase strings
24
+ * and PascalCase ("ReceiveAsset", "SendAsset") have been observed. Defaults
25
+ * to "send" for unknown / undefined input so legacy entries don't display
26
+ * as a confusing third state.
27
+ */
28
+ export declare function mapTransferType(kind?: string): TransactionType;
29
+ /**
30
+ * Map the SDK's transfer status string to our unified TransactionStatus.
31
+ *
32
+ * SDK casing has drifted between releases; we accept both. "WaitingCounterparty"
33
+ * is RGB-specific (lightning transfer waiting on the receiver) and maps to
34
+ * pending so the UI keeps showing the spinner rather than green-checking too
35
+ * early.
36
+ */
37
+ export declare function mapTransferStatus(status?: string): TransactionStatus;
38
+ /**
39
+ * Map a Lightning-payment status string to our unified TransactionStatus.
40
+ *
41
+ * Three variants of "succeeded" have shown up in the SDK across versions —
42
+ * we accept all three to insulate the wallet UI from upstream churn.
43
+ */
44
+ export declare function mapPaymentStatus(status?: string): TransactionStatus;
45
+ /**
46
+ * Map a maker/taker swap status string to our unified TransactionStatus.
47
+ *
48
+ * The SDK historically returned PascalCase ("Completed") and lowercase
49
+ * ("completed", "success", "error") interchangeably depending on whether
50
+ * the response came from the maker or taker side. The mapper accepts both
51
+ * so a refactor of the SDK doesn't quietly flip swaps to "pending".
52
+ */
53
+ export declare function mapSwapStatus(status?: string): TransactionStatus;
54
+ //# sourceMappingURL=rgb-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rgb-helpers.d.ts","sourceRoot":"","sources":["../../src/lib/rgb-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAExE;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,eAAe,CAK9D;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,iBAAiB,CAMpE;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,iBAAiB,CAKnE;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,iBAAiB,CAKhE"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Pure helpers for the RGB adapter.
3
+ *
4
+ * Extracted from src/protocols/rgb/adapter.ts so the adapter file can stay
5
+ * focused on the IProtocolAdapter surface + SDK orchestration. Everything in
6
+ * this module is side-effect free, has no `this` dependencies, and is
7
+ * covered by tests/unit/rgb-helpers.test.ts.
8
+ *
9
+ * Adding to this module: keep helpers pure (no class state, no SDK calls).
10
+ * Anything that needs the kaleido SDK client or the adapter's own config
11
+ * belongs in adapter.ts.
12
+ */
13
+ /**
14
+ * Render a raw integer amount in the asset's display precision.
15
+ * Always emits `precision` fractional digits — the caller can trim trailing
16
+ * zeros if it wants a tighter rendering.
17
+ */
18
+ export function formatAmount(amount, precision) {
19
+ return (amount / Math.pow(10, precision)).toFixed(precision);
20
+ }
21
+ /**
22
+ * Map the SDK's transfer `kind` field to our unified TransactionType.
23
+ *
24
+ * The SDK is inconsistent about case + naming — both raw lowercase strings
25
+ * and PascalCase ("ReceiveAsset", "SendAsset") have been observed. Defaults
26
+ * to "send" for unknown / undefined input so legacy entries don't display
27
+ * as a confusing third state.
28
+ */
29
+ export function mapTransferType(kind) {
30
+ if (!kind)
31
+ return "send";
32
+ if (kind.includes("receive") || kind.includes("ReceiveAsset"))
33
+ return "receive";
34
+ if (kind.includes("send") || kind.includes("SendAsset"))
35
+ return "send";
36
+ return "send";
37
+ }
38
+ /**
39
+ * Map the SDK's transfer status string to our unified TransactionStatus.
40
+ *
41
+ * SDK casing has drifted between releases; we accept both. "WaitingCounterparty"
42
+ * is RGB-specific (lightning transfer waiting on the receiver) and maps to
43
+ * pending so the UI keeps showing the spinner rather than green-checking too
44
+ * early.
45
+ */
46
+ export function mapTransferStatus(status) {
47
+ if (!status)
48
+ return "pending";
49
+ if (status === "Settled" || status === "settled")
50
+ return "confirmed";
51
+ if (status === "Failed" || status === "failed")
52
+ return "failed";
53
+ if (status === "WaitingCounterparty")
54
+ return "pending";
55
+ return "pending";
56
+ }
57
+ /**
58
+ * Map a Lightning-payment status string to our unified TransactionStatus.
59
+ *
60
+ * Three variants of "succeeded" have shown up in the SDK across versions —
61
+ * we accept all three to insulate the wallet UI from upstream churn.
62
+ */
63
+ export function mapPaymentStatus(status) {
64
+ if (!status)
65
+ return "pending";
66
+ if (status === "succeeded" || status === "success" || status === "Succeeded")
67
+ return "confirmed";
68
+ if (status === "failed" || status === "Failed")
69
+ return "failed";
70
+ return "pending";
71
+ }
72
+ /**
73
+ * Map a maker/taker swap status string to our unified TransactionStatus.
74
+ *
75
+ * The SDK historically returned PascalCase ("Completed") and lowercase
76
+ * ("completed", "success", "error") interchangeably depending on whether
77
+ * the response came from the maker or taker side. The mapper accepts both
78
+ * so a refactor of the SDK doesn't quietly flip swaps to "pending".
79
+ */
80
+ export function mapSwapStatus(status) {
81
+ if (!status)
82
+ return "pending";
83
+ if (status === "completed" || status === "success" || status === "Completed")
84
+ return "confirmed";
85
+ if (status === "failed" || status === "error" || status === "Failed")
86
+ return "failed";
87
+ return "pending";
88
+ }
89
+ //# sourceMappingURL=rgb-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rgb-helpers.js","sourceRoot":"","sources":["../../src/lib/rgb-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,MAAc,EAAE,SAAiB;IAC5D,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAC/D,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,IAAa;IAC3C,IAAI,CAAC,IAAI;QAAE,OAAO,MAAM,CAAC;IACzB,IAAI,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC;QAAE,OAAO,SAAS,CAAC;IAChF,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;QAAE,OAAO,MAAM,CAAC;IACvE,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAe;IAC/C,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IAC9B,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,WAAW,CAAC;IACrE,IAAI,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAChE,IAAI,MAAM,KAAK,qBAAqB;QAAE,OAAO,SAAS,CAAC;IACvD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAe;IAC9C,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IAC9B,IAAI,MAAM,KAAK,WAAW,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,WAAW;QAAE,OAAO,WAAW,CAAC;IACjG,IAAI,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAChE,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,MAAe;IAC3C,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IAC9B,IAAI,MAAM,KAAK,WAAW,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,WAAW;QAAE,OAAO,WAAW,CAAC;IACjG,IAAI,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,OAAO,IAAI,MAAM,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAC;IACtF,OAAO,SAAS,CAAC;AACnB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaleidorg/wallet-engine",
3
- "version": "1.0.0-beta.36",
3
+ "version": "1.0.0-beta.37",
4
4
  "description": "WDK-based multi-protocol wallet engine (Spark, RGB/RLN, Liquid, Arkade): IProtocolAdapter contract + WDK adapters, cross-protocol router, BIP321 unified receive, and lite/advanced disclosure.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -22,6 +22,10 @@
22
22
  "types": "./dist/adapters/spark.d.ts",
23
23
  "default": "./dist/adapters/spark.js"
24
24
  },
25
+ "./adapters/rgb": {
26
+ "types": "./dist/adapters/rgb.d.ts",
27
+ "default": "./dist/adapters/rgb.js"
28
+ },
25
29
  "./adapters/wdk": {
26
30
  "types": "./dist/adapters/wdk/index.d.ts",
27
31
  "default": "./dist/adapters/wdk/index.js"