@kaleidorg/wallet-protocols 1.0.0-beta.2
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/dist/adapters/ArkadeAdapter.d.ts +48 -0
- package/dist/adapters/ArkadeAdapter.d.ts.map +1 -0
- package/dist/adapters/ArkadeAdapter.js +314 -0
- package/dist/adapters/ArkadeAdapter.js.map +1 -0
- package/dist/adapters/IProtocolAdapter.d.ts +71 -0
- package/dist/adapters/IProtocolAdapter.d.ts.map +1 -0
- package/dist/adapters/IProtocolAdapter.js +29 -0
- package/dist/adapters/IProtocolAdapter.js.map +1 -0
- package/dist/adapters/RgbAdapter.d.ts +70 -0
- package/dist/adapters/RgbAdapter.d.ts.map +1 -0
- package/dist/adapters/RgbAdapter.js +818 -0
- package/dist/adapters/RgbAdapter.js.map +1 -0
- package/dist/adapters/SparkAdapter.d.ts +47 -0
- package/dist/adapters/SparkAdapter.d.ts.map +1 -0
- package/dist/adapters/SparkAdapter.js +390 -0
- package/dist/adapters/SparkAdapter.js.map +1 -0
- package/dist/adapters/wdk/ArkadeWdkAdapter.d.ts +78 -0
- package/dist/adapters/wdk/ArkadeWdkAdapter.d.ts.map +1 -0
- package/dist/adapters/wdk/ArkadeWdkAdapter.js +226 -0
- package/dist/adapters/wdk/ArkadeWdkAdapter.js.map +1 -0
- package/dist/adapters/wdk/LiquidWdkAdapter.d.ts +88 -0
- package/dist/adapters/wdk/LiquidWdkAdapter.d.ts.map +1 -0
- package/dist/adapters/wdk/LiquidWdkAdapter.js +272 -0
- package/dist/adapters/wdk/LiquidWdkAdapter.js.map +1 -0
- package/dist/adapters/wdk/RlnWdkAdapter.d.ts +85 -0
- package/dist/adapters/wdk/RlnWdkAdapter.d.ts.map +1 -0
- package/dist/adapters/wdk/RlnWdkAdapter.js +308 -0
- package/dist/adapters/wdk/RlnWdkAdapter.js.map +1 -0
- package/dist/adapters/wdk/SparkWdkAdapter.d.ts +79 -0
- package/dist/adapters/wdk/SparkWdkAdapter.d.ts.map +1 -0
- package/dist/adapters/wdk/SparkWdkAdapter.js +317 -0
- package/dist/adapters/wdk/SparkWdkAdapter.js.map +1 -0
- package/dist/adapters/wdk/moduleLoader.d.ts +22 -0
- package/dist/adapters/wdk/moduleLoader.d.ts.map +1 -0
- package/dist/adapters/wdk/moduleLoader.js +31 -0
- package/dist/adapters/wdk/moduleLoader.js.map +1 -0
- package/dist/capabilities/index.d.ts +46 -0
- package/dist/capabilities/index.d.ts.map +1 -0
- package/dist/capabilities/index.js +102 -0
- package/dist/capabilities/index.js.map +1 -0
- package/dist/disclosure/index.d.ts +51 -0
- package/dist/disclosure/index.d.ts.map +1 -0
- package/dist/disclosure/index.js +64 -0
- package/dist/disclosure/index.js.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/arkade-client-manager.d.ts +47 -0
- package/dist/lib/arkade-client-manager.d.ts.map +1 -0
- package/dist/lib/arkade-client-manager.js +121 -0
- package/dist/lib/arkade-client-manager.js.map +1 -0
- package/dist/lib/bolt11.d.ts +18 -0
- package/dist/lib/bolt11.d.ts.map +1 -0
- package/dist/lib/bolt11.js +31 -0
- package/dist/lib/bolt11.js.map +1 -0
- package/dist/lib/flashnet-client-manager.d.ts +29 -0
- package/dist/lib/flashnet-client-manager.d.ts.map +1 -0
- package/dist/lib/flashnet-client-manager.js +116 -0
- package/dist/lib/flashnet-client-manager.js.map +1 -0
- package/dist/lib/kaleido-client-manager.d.ts +26 -0
- package/dist/lib/kaleido-client-manager.d.ts.map +1 -0
- package/dist/lib/kaleido-client-manager.js +55 -0
- package/dist/lib/kaleido-client-manager.js.map +1 -0
- package/dist/lib/spark-client-manager.d.ts +41 -0
- package/dist/lib/spark-client-manager.d.ts.map +1 -0
- package/dist/lib/spark-client-manager.js +101 -0
- package/dist/lib/spark-client-manager.js.map +1 -0
- package/dist/manager/ProtocolManager.d.ts +57 -0
- package/dist/manager/ProtocolManager.d.ts.map +1 -0
- package/dist/manager/ProtocolManager.js +228 -0
- package/dist/manager/ProtocolManager.js.map +1 -0
- package/dist/ports/index.d.ts +29 -0
- package/dist/ports/index.d.ts.map +1 -0
- package/dist/ports/index.js +9 -0
- package/dist/ports/index.js.map +1 -0
- package/dist/receive/unifiedReceive.d.ts +54 -0
- package/dist/receive/unifiedReceive.d.ts.map +1 -0
- package/dist/receive/unifiedReceive.js +102 -0
- package/dist/receive/unifiedReceive.js.map +1 -0
- package/dist/registry/createWdkRegistry.d.ts +20 -0
- package/dist/registry/createWdkRegistry.d.ts.map +1 -0
- package/dist/registry/createWdkRegistry.js +32 -0
- package/dist/registry/createWdkRegistry.js.map +1 -0
- package/dist/router/destination.d.ts +28 -0
- package/dist/router/destination.d.ts.map +1 -0
- package/dist/router/destination.js +72 -0
- package/dist/router/destination.js.map +1 -0
- package/dist/router/index.d.ts +55 -0
- package/dist/router/index.d.ts.map +1 -0
- package/dist/router/index.js +67 -0
- package/dist/router/index.js.map +1 -0
- package/dist/swap/KaleidoswapSwap.d.ts +44 -0
- package/dist/swap/KaleidoswapSwap.d.ts.map +1 -0
- package/dist/swap/KaleidoswapSwap.js +123 -0
- package/dist/swap/KaleidoswapSwap.js.map +1 -0
- package/dist/types/arkade.d.ts +40 -0
- package/dist/types/arkade.d.ts.map +1 -0
- package/dist/types/arkade.js +6 -0
- package/dist/types/arkade.js.map +1 -0
- package/dist/types/base.d.ts +197 -0
- package/dist/types/base.d.ts.map +1 -0
- package/dist/types/base.js +27 -0
- package/dist/types/base.js.map +1 -0
- package/dist/types/cross-l2.d.ts +158 -0
- package/dist/types/cross-l2.d.ts.map +1 -0
- package/dist/types/cross-l2.js +16 -0
- package/dist/types/cross-l2.js.map +1 -0
- package/dist/types/flashnet.d.ts +31 -0
- package/dist/types/flashnet.d.ts.map +1 -0
- package/dist/types/flashnet.js +23 -0
- package/dist/types/flashnet.js.map +1 -0
- package/dist/types/rgb.d.ts +91 -0
- package/dist/types/rgb.d.ts.map +1 -0
- package/dist/types/rgb.js +6 -0
- package/dist/types/rgb.js.map +1 -0
- package/dist/types/spark.d.ts +59 -0
- package/dist/types/spark.d.ts.map +1 -0
- package/dist/types/spark.js +6 -0
- package/dist/types/spark.js.map +1 -0
- package/dist/utils.d.ts +10 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +23 -0
- package/dist/utils.js.map +1 -0
- package/package.json +35 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified Receive URI (BIP321)
|
|
3
|
+
* ----------------------------
|
|
4
|
+
* Builds ONE QR payload that any wallet can pay, while Kaleido-aware wallets get the
|
|
5
|
+
* richer multi-protocol options. The base is a **BIP321** `bitcoin:` URI — the
|
|
6
|
+
* generalized successor to BIP21: an optional on-chain address in the path plus
|
|
7
|
+
* payment methods as query params (`lightning=` BOLT11, `lno=` BOLT12), and unknown
|
|
8
|
+
* params are ignored by other wallets. It stays backward-compatible with BIP21
|
|
9
|
+
* (the `bitcoin:` scheme + `amount`/`label`/`lightning` are understood by BIP21 wallets).
|
|
10
|
+
*
|
|
11
|
+
* Per BIP321 the address MAY be omitted (`bitcoin:?lightning=...&spark=...`), so a
|
|
12
|
+
* lite wallet with no on-chain address can still publish one QR. Ark / Spark / Liquid
|
|
13
|
+
* / RGB ride as extra (non-standard) params that only Kaleido wallets read.
|
|
14
|
+
*
|
|
15
|
+
* This is the "single QR with embedded LN, Ark, Spark addresses" the lite-mode
|
|
16
|
+
* receive flow needs. Pure + dependency-free.
|
|
17
|
+
*/
|
|
18
|
+
/** BIP321 query keys (case-insensitive). `lightning`/`lno` are standard; the rest are Kaleido-namespaced. */
|
|
19
|
+
const K = {
|
|
20
|
+
lightning: 'lightning',
|
|
21
|
+
lno: 'lno',
|
|
22
|
+
spark: 'spark',
|
|
23
|
+
ark: 'ark',
|
|
24
|
+
liquid: 'liquid',
|
|
25
|
+
rgb: 'rgb',
|
|
26
|
+
assetId: 'assetid',
|
|
27
|
+
assetAmount: 'assetamount',
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Build a single BIP321 `bitcoin:` URI carrying every available receive method.
|
|
31
|
+
* The address is optional; at least one of (address | lightning | lno | spark | ark |
|
|
32
|
+
* liquid | rgb) must be present.
|
|
33
|
+
*
|
|
34
|
+
* Examples:
|
|
35
|
+
* bitcoin:bc1q...?amount=0.001&lightning=lnbc...&spark=spark1...&ark=ark1...
|
|
36
|
+
* bitcoin:?lightning=lnbc...&liquid=lq1... (BIP321: address omitted)
|
|
37
|
+
*/
|
|
38
|
+
export function buildUnifiedReceiveURI(p) {
|
|
39
|
+
const hasMethod = !!p.btcAddress ||
|
|
40
|
+
!!p.lightningInvoice ||
|
|
41
|
+
!!p.lightningOffer ||
|
|
42
|
+
!!p.sparkAddress ||
|
|
43
|
+
!!p.arkadeAddress ||
|
|
44
|
+
!!p.liquidAddress ||
|
|
45
|
+
!!p.rgbInvoice;
|
|
46
|
+
if (!hasMethod) {
|
|
47
|
+
throw new Error('buildUnifiedReceiveURI requires at least one receive method (address or a payment param)');
|
|
48
|
+
}
|
|
49
|
+
const params = new URLSearchParams();
|
|
50
|
+
if (p.amountBtc != null)
|
|
51
|
+
params.set('amount', formatBtc(p.amountBtc));
|
|
52
|
+
if (p.label)
|
|
53
|
+
params.set('label', p.label);
|
|
54
|
+
if (p.lightningInvoice)
|
|
55
|
+
params.set(K.lightning, p.lightningInvoice);
|
|
56
|
+
if (p.lightningOffer)
|
|
57
|
+
params.set(K.lno, p.lightningOffer);
|
|
58
|
+
if (p.sparkAddress)
|
|
59
|
+
params.set(K.spark, p.sparkAddress);
|
|
60
|
+
if (p.arkadeAddress)
|
|
61
|
+
params.set(K.ark, p.arkadeAddress);
|
|
62
|
+
if (p.liquidAddress)
|
|
63
|
+
params.set(K.liquid, p.liquidAddress);
|
|
64
|
+
if (p.rgbInvoice)
|
|
65
|
+
params.set(K.rgb, p.rgbInvoice);
|
|
66
|
+
if (p.assetId)
|
|
67
|
+
params.set(K.assetId, p.assetId);
|
|
68
|
+
if (p.assetAmount != null)
|
|
69
|
+
params.set(K.assetAmount, String(p.assetAmount));
|
|
70
|
+
const qs = params.toString();
|
|
71
|
+
// BIP321: `bitcoin:` + optional address + optional `?params`.
|
|
72
|
+
return `bitcoin:${p.btcAddress ?? ''}${qs ? `?${qs}` : ''}`;
|
|
73
|
+
}
|
|
74
|
+
/** Parse a BIP321 unified URI back into its parts (Kaleido wallets use this on scan). */
|
|
75
|
+
export function parseUnifiedReceiveURI(uri) {
|
|
76
|
+
// Address is optional under BIP321 → allow an empty path.
|
|
77
|
+
const m = (uri ?? '').trim().match(/^bitcoin:([^?]*)(?:\?(.*))?$/i);
|
|
78
|
+
if (!m)
|
|
79
|
+
return null;
|
|
80
|
+
const btcAddress = m[1] || undefined;
|
|
81
|
+
const params = new URLSearchParams(m[2] ?? '');
|
|
82
|
+
const amount = params.get('amount');
|
|
83
|
+
const assetAmount = params.get(K.assetAmount);
|
|
84
|
+
return {
|
|
85
|
+
btcAddress,
|
|
86
|
+
amountBtc: amount != null ? Number(amount) : undefined,
|
|
87
|
+
label: params.get('label') ?? undefined,
|
|
88
|
+
lightningInvoice: params.get(K.lightning) ?? undefined,
|
|
89
|
+
lightningOffer: params.get(K.lno) ?? undefined,
|
|
90
|
+
sparkAddress: params.get(K.spark) ?? undefined,
|
|
91
|
+
arkadeAddress: params.get(K.ark) ?? undefined,
|
|
92
|
+
liquidAddress: params.get(K.liquid) ?? undefined,
|
|
93
|
+
rgbInvoice: params.get(K.rgb) ?? undefined,
|
|
94
|
+
assetId: params.get(K.assetId) ?? undefined,
|
|
95
|
+
assetAmount: assetAmount != null ? Number(assetAmount) : undefined,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/** BIP21/BIP321 amounts are in BTC with up to 8 decimals, no trailing zeros / exponent. */
|
|
99
|
+
function formatBtc(amountBtc) {
|
|
100
|
+
return amountBtc.toFixed(8).replace(/\.?0+$/, '');
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=unifiedReceive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unifiedReceive.js","sourceRoot":"","sources":["../../src/receive/unifiedReceive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AA2BH,6GAA6G;AAC7G,MAAM,CAAC,GAAG;IACR,SAAS,EAAE,WAAW;IACtB,GAAG,EAAE,KAAK;IACV,KAAK,EAAE,OAAO;IACd,GAAG,EAAE,KAAK;IACV,MAAM,EAAE,QAAQ;IAChB,GAAG,EAAE,KAAK;IACV,OAAO,EAAE,SAAS;IAClB,WAAW,EAAE,aAAa;CAClB,CAAA;AAEV;;;;;;;;GAQG;AACH,MAAM,UAAU,sBAAsB,CAAC,CAAuB;IAC5D,MAAM,SAAS,GACb,CAAC,CAAC,CAAC,CAAC,UAAU;QACd,CAAC,CAAC,CAAC,CAAC,gBAAgB;QACpB,CAAC,CAAC,CAAC,CAAC,cAAc;QAClB,CAAC,CAAC,CAAC,CAAC,YAAY;QAChB,CAAC,CAAC,CAAC,CAAC,aAAa;QACjB,CAAC,CAAC,CAAC,CAAC,aAAa;QACjB,CAAC,CAAC,CAAC,CAAC,UAAU,CAAA;IAChB,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,0FAA0F,CAAC,CAAA;IAC7G,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAA;IACpC,IAAI,CAAC,CAAC,SAAS,IAAI,IAAI;QAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAA;IACrE,IAAI,CAAC,CAAC,KAAK;QAAE,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAA;IACzC,IAAI,CAAC,CAAC,gBAAgB;QAAE,MAAM,CAAC,GAAG,CAAC,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AAC,CAAC,CAAC,SAAS;KACnE,CAAA;AACH,CAAC;AAED,2FAA2F;AAC3F,SAAS,SAAS,CAAC,SAAiB;IAClC,OAAO,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;AACnD,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WDK Registry Factory
|
|
3
|
+
* --------------------
|
|
4
|
+
* Convenience: build a `ProtocolAdapterRegistry` populated with the WDK-backed
|
|
5
|
+
* adapters. Opt-in — apps may instead register adapters selectively to keep bundles
|
|
6
|
+
* lean. Importing this pulls only the thin adapter wrappers; the heavy WDK modules
|
|
7
|
+
* are loaded lazily inside each adapter's `connect()` (dynamic import), so this does
|
|
8
|
+
* NOT eagerly bundle the WDK modules.
|
|
9
|
+
*
|
|
10
|
+
* Adapters are constructed but NOT connected — call `connect(config)` per protocol
|
|
11
|
+
* (each adapter's config carries its mnemonic + protocol-specific endpoints).
|
|
12
|
+
*/
|
|
13
|
+
import { ProtocolAdapterRegistry } from '../adapters/IProtocolAdapter';
|
|
14
|
+
import { ProtocolType } from '../types/base';
|
|
15
|
+
export interface WdkRegistryOptions {
|
|
16
|
+
/** Which protocols to register (default: all four). */
|
|
17
|
+
enabled?: ProtocolType[];
|
|
18
|
+
}
|
|
19
|
+
export declare function createWdkRegistry(opts?: WdkRegistryOptions): ProtocolAdapterRegistry;
|
|
20
|
+
//# sourceMappingURL=createWdkRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createWdkRegistry.d.ts","sourceRoot":"","sources":["../../src/registry/createWdkRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAA;AAKtE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAE5C,MAAM,WAAW,kBAAkB;IACjC,uDAAuD;IACvD,OAAO,CAAC,EAAE,YAAY,EAAE,CAAA;CACzB;AAID,wBAAgB,iBAAiB,CAAC,IAAI,GAAE,kBAAuB,GAAG,uBAAuB,CAQxF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WDK Registry Factory
|
|
3
|
+
* --------------------
|
|
4
|
+
* Convenience: build a `ProtocolAdapterRegistry` populated with the WDK-backed
|
|
5
|
+
* adapters. Opt-in — apps may instead register adapters selectively to keep bundles
|
|
6
|
+
* lean. Importing this pulls only the thin adapter wrappers; the heavy WDK modules
|
|
7
|
+
* are loaded lazily inside each adapter's `connect()` (dynamic import), so this does
|
|
8
|
+
* NOT eagerly bundle the WDK modules.
|
|
9
|
+
*
|
|
10
|
+
* Adapters are constructed but NOT connected — call `connect(config)` per protocol
|
|
11
|
+
* (each adapter's config carries its mnemonic + protocol-specific endpoints).
|
|
12
|
+
*/
|
|
13
|
+
import { ProtocolAdapterRegistry } from '../adapters/IProtocolAdapter';
|
|
14
|
+
import { SparkWdkAdapter } from '../adapters/wdk/SparkWdkAdapter';
|
|
15
|
+
import { LiquidWdkAdapter } from '../adapters/wdk/LiquidWdkAdapter';
|
|
16
|
+
import { RlnWdkAdapter } from '../adapters/wdk/RlnWdkAdapter';
|
|
17
|
+
import { ArkadeWdkAdapter } from '../adapters/wdk/ArkadeWdkAdapter';
|
|
18
|
+
const ALL = ['SPARK', 'LIQUID', 'RGB', 'ARKADE'];
|
|
19
|
+
export function createWdkRegistry(opts = {}) {
|
|
20
|
+
const enabled = opts.enabled ?? ALL;
|
|
21
|
+
const registry = new ProtocolAdapterRegistry();
|
|
22
|
+
if (enabled.includes('SPARK'))
|
|
23
|
+
registry.register(new SparkWdkAdapter());
|
|
24
|
+
if (enabled.includes('LIQUID'))
|
|
25
|
+
registry.register(new LiquidWdkAdapter());
|
|
26
|
+
if (enabled.includes('RGB'))
|
|
27
|
+
registry.register(new RlnWdkAdapter());
|
|
28
|
+
if (enabled.includes('ARKADE'))
|
|
29
|
+
registry.register(new ArkadeWdkAdapter());
|
|
30
|
+
return registry;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=createWdkRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createWdkRegistry.js","sourceRoot":"","sources":["../../src/registry/createWdkRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAA;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AAQnE,MAAM,GAAG,GAAmB,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAA;AAEhE,MAAM,UAAU,iBAAiB,CAAC,OAA2B,EAAE;IAC7D,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,GAAG,CAAA;IACnC,MAAM,QAAQ,GAAG,IAAI,uBAAuB,EAAE,CAAA;IAC9C,IAAI,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;QAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,eAAe,EAAE,CAAC,CAAA;IACvE,IAAI,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,gBAAgB,EAAE,CAAC,CAAA;IACzE,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,aAAa,EAAE,CAAC,CAAA;IACnE,IAAI,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,gBAAgB,EAAE,CAAC,CAAA;IACzE,OAAO,QAAQ,CAAA;AACjB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Destination Classifier
|
|
3
|
+
* ----------------------
|
|
4
|
+
* Pure, dependency-free classification of a send destination string into a
|
|
5
|
+
* (kind, layer, candidate protocols) triple. The cross-protocol router uses this
|
|
6
|
+
* to decide which adapter(s) can pay a given destination — without any adapter
|
|
7
|
+
* needing to know about the others.
|
|
8
|
+
*
|
|
9
|
+
* This is the cross-protocol layer that WDK's per-module detection does NOT cover:
|
|
10
|
+
* WDK detects within a protocol; this chooses BETWEEN protocols.
|
|
11
|
+
*/
|
|
12
|
+
import { ProtocolType, Layer, AddressFormat } from '../types/base';
|
|
13
|
+
export type DestinationKind = 'BOLT11' | 'LN_ADDRESS' | 'RGB_INVOICE' | 'SPARK' | 'ARKADE' | 'LIQUID' | 'BTC_ONCHAIN' | 'BIP21' | 'UNKNOWN';
|
|
14
|
+
export interface ClassifiedDestination {
|
|
15
|
+
kind: DestinationKind;
|
|
16
|
+
/** The most specific layer this destination settles on. */
|
|
17
|
+
layer: Layer | null;
|
|
18
|
+
/** Address format (for passing to swap receiverAddressFormat / UI). */
|
|
19
|
+
format: AddressFormat | null;
|
|
20
|
+
/** Protocols capable of paying this destination, best-first. */
|
|
21
|
+
candidates: ProtocolType[];
|
|
22
|
+
/** For BIP21: an embedded BOLT11 fallback, if present. */
|
|
23
|
+
lightningFallback?: string;
|
|
24
|
+
/** The normalized payable string (URI-stripped where relevant). */
|
|
25
|
+
value: string;
|
|
26
|
+
}
|
|
27
|
+
export declare function classifyDestination(raw: string): ClassifiedDestination;
|
|
28
|
+
//# sourceMappingURL=destination.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"destination.d.ts","sourceRoot":"","sources":["../../src/router/destination.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAElE,MAAM,MAAM,eAAe,GACvB,QAAQ,GACR,YAAY,GACZ,aAAa,GACb,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,aAAa,GACb,OAAO,GACP,SAAS,CAAA;AAEb,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,eAAe,CAAA;IACrB,2DAA2D;IAC3D,KAAK,EAAE,KAAK,GAAG,IAAI,CAAA;IACnB,uEAAuE;IACvE,MAAM,EAAE,aAAa,GAAG,IAAI,CAAA;IAC5B,gEAAgE;IAChE,UAAU,EAAE,YAAY,EAAE,CAAA;IAC1B,0DAA0D;IAC1D,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,mEAAmE;IACnE,KAAK,EAAE,MAAM,CAAA;CACd;AAoBD,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,qBAAqB,CAoDtE"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Destination Classifier
|
|
3
|
+
* ----------------------
|
|
4
|
+
* Pure, dependency-free classification of a send destination string into a
|
|
5
|
+
* (kind, layer, candidate protocols) triple. The cross-protocol router uses this
|
|
6
|
+
* to decide which adapter(s) can pay a given destination — without any adapter
|
|
7
|
+
* needing to know about the others.
|
|
8
|
+
*
|
|
9
|
+
* This is the cross-protocol layer that WDK's per-module detection does NOT cover:
|
|
10
|
+
* WDK detects within a protocol; this chooses BETWEEN protocols.
|
|
11
|
+
*/
|
|
12
|
+
const RE = {
|
|
13
|
+
bolt11: /^ln(bc|tb|bcrt|sb)[0-9]/i,
|
|
14
|
+
lnurl: /^lnurl[0-9a-z]/i,
|
|
15
|
+
lnAddress: /^[^@\s]+@[^@\s]+\.[^@\s]+$/i,
|
|
16
|
+
rgb: /^(rgb:|utxob:)/i,
|
|
17
|
+
spark: /^(spark|sparkrt|sprt|spt)1[0-9a-z]/i,
|
|
18
|
+
arkade: /^(ark|tark)1[0-9a-z]/i,
|
|
19
|
+
liquid: /^(lq1|tlq1|ex1|el1|VJL|VT|CT|Az|Gq|H)/, // confidential + segwit Liquid prefixes
|
|
20
|
+
btc: /^(bc1|tb1|bcrt1|[13]|[mn2])[0-9a-zA-Z]/,
|
|
21
|
+
bip21: /^bitcoin:/i,
|
|
22
|
+
};
|
|
23
|
+
/** Pull a `lightning=` parameter out of a BIP21 URI, if present. */
|
|
24
|
+
function extractLightning(uri) {
|
|
25
|
+
const m = uri.match(/[?&]lightning=([^&]+)/i);
|
|
26
|
+
return m ? decodeURIComponent(m[1]) : undefined;
|
|
27
|
+
}
|
|
28
|
+
export function classifyDestination(raw) {
|
|
29
|
+
const dest = (raw ?? '').trim();
|
|
30
|
+
if (RE.bip21.test(dest)) {
|
|
31
|
+
const addr = dest.slice('bitcoin:'.length).split('?')[0];
|
|
32
|
+
const lightningFallback = extractLightning(dest);
|
|
33
|
+
return {
|
|
34
|
+
kind: 'BIP21',
|
|
35
|
+
layer: 'BTC_L1',
|
|
36
|
+
format: 'BTC_ADDRESS',
|
|
37
|
+
// On-chain BTC can be served by any protocol with an on-chain path; LN fallback widens it.
|
|
38
|
+
candidates: ['RGB', 'ARKADE', 'SPARK', 'LIQUID'],
|
|
39
|
+
lightningFallback,
|
|
40
|
+
value: addr,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
if (RE.bolt11.test(dest)) {
|
|
44
|
+
return { kind: 'BOLT11', layer: 'BTC_LN', format: 'BOLT11', candidates: ['RGB', 'SPARK', 'ARKADE'], value: dest };
|
|
45
|
+
}
|
|
46
|
+
if (RE.lnurl.test(dest) || RE.lnAddress.test(dest)) {
|
|
47
|
+
return { kind: 'LN_ADDRESS', layer: 'BTC_LN', format: 'BOLT11', candidates: ['RGB', 'SPARK', 'ARKADE'], value: dest };
|
|
48
|
+
}
|
|
49
|
+
if (RE.rgb.test(dest)) {
|
|
50
|
+
return { kind: 'RGB_INVOICE', layer: 'RGB_LN', format: 'RGB_INVOICE', candidates: ['RGB'], value: dest };
|
|
51
|
+
}
|
|
52
|
+
if (RE.spark.test(dest)) {
|
|
53
|
+
return { kind: 'SPARK', layer: 'SPARK_SPARK', format: 'SPARK_ADDRESS', candidates: ['SPARK'], value: dest };
|
|
54
|
+
}
|
|
55
|
+
if (RE.arkade.test(dest)) {
|
|
56
|
+
return { kind: 'ARKADE', layer: 'ARKADE_ARKADE', format: 'ARKADE_ADDRESS', candidates: ['ARKADE'], value: dest };
|
|
57
|
+
}
|
|
58
|
+
if (RE.liquid.test(dest)) {
|
|
59
|
+
return { kind: 'LIQUID', layer: 'BTC_LIQUID', format: 'LIQUID_ADDRESS', candidates: ['LIQUID'], value: dest };
|
|
60
|
+
}
|
|
61
|
+
if (RE.btc.test(dest)) {
|
|
62
|
+
return {
|
|
63
|
+
kind: 'BTC_ONCHAIN',
|
|
64
|
+
layer: 'BTC_L1',
|
|
65
|
+
format: 'BTC_ADDRESS',
|
|
66
|
+
candidates: ['RGB', 'ARKADE', 'SPARK'], // protocols that can pay an on-chain BTC address
|
|
67
|
+
value: dest,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return { kind: 'UNKNOWN', layer: null, format: null, candidates: [], value: dest };
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=destination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"destination.js","sourceRoot":"","sources":["../../src/router/destination.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AA6BH,MAAM,EAAE,GAAG;IACT,MAAM,EAAE,0BAA0B;IAClC,KAAK,EAAE,iBAAiB;IACxB,SAAS,EAAE,6BAA6B;IACxC,GAAG,EAAE,iBAAiB;IACtB,KAAK,EAAE,qCAAqC;IAC5C,MAAM,EAAE,uBAAuB;IAC/B,MAAM,EAAE,uCAAuC,EAAE,wCAAwC;IACzF,GAAG,EAAE,wCAAwC;IAC7C,KAAK,EAAE,YAAY;CACpB,CAAA;AAED,oEAAoE;AACpE,SAAS,gBAAgB,CAAC,GAAW;IACnC,MAAM,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AAK,EAAE,QAAQ;YACf,MAAM,EAAE,aAAa;YACrB,UAAU,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,iDAAiD;YACzF,KAAK,EAAE,IAAI;SACZ,CAAA;IACH,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAA;AACpF,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CrossProtocolRouter
|
|
3
|
+
* -------------------
|
|
4
|
+
* Sits ON TOP of the adapters and chooses BETWEEN protocols. Given a send
|
|
5
|
+
* destination or a receive intent, it returns the protocol(s) that can fulfil it,
|
|
6
|
+
* filtered to what's actually registered and connected. This is the layer that
|
|
7
|
+
* makes lite mode possible: it auto-selects the route so the UI never has to.
|
|
8
|
+
*
|
|
9
|
+
* It reads the capability manifest (differences-as-data) + the destination
|
|
10
|
+
* classifier — never the adapters' internals.
|
|
11
|
+
*/
|
|
12
|
+
import { ProtocolAdapterRegistry, IProtocolAdapter } from '../adapters/IProtocolAdapter';
|
|
13
|
+
import { ProtocolType, Layer } from '../types/base';
|
|
14
|
+
import { ClassifiedDestination } from './destination';
|
|
15
|
+
export interface SendRoute {
|
|
16
|
+
protocol: ProtocolType;
|
|
17
|
+
adapter: IProtocolAdapter;
|
|
18
|
+
layer: Layer | null;
|
|
19
|
+
/** True when this protocol can pay the destination directly (no swap). */
|
|
20
|
+
direct: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface SendResolution {
|
|
23
|
+
destination: ClassifiedDestination;
|
|
24
|
+
/** Routes that can pay the destination directly, best-first. */
|
|
25
|
+
routes: SendRoute[];
|
|
26
|
+
/** The auto-selected route for lite mode (first direct route), or null. */
|
|
27
|
+
best: SendRoute | null;
|
|
28
|
+
}
|
|
29
|
+
export interface ReceiveRoute {
|
|
30
|
+
protocol: ProtocolType;
|
|
31
|
+
adapter: IProtocolAdapter;
|
|
32
|
+
layer: Layer;
|
|
33
|
+
}
|
|
34
|
+
export declare class CrossProtocolRouter {
|
|
35
|
+
private registry;
|
|
36
|
+
constructor(registry: ProtocolAdapterRegistry);
|
|
37
|
+
/** Only adapters that are registered AND connected are eligible to route. */
|
|
38
|
+
private connected;
|
|
39
|
+
/**
|
|
40
|
+
* Resolve how to SEND to a destination string.
|
|
41
|
+
* Lite mode uses `.best`; advanced mode can offer the full `.routes` list.
|
|
42
|
+
*/
|
|
43
|
+
resolveSend(destination: string): SendResolution;
|
|
44
|
+
/**
|
|
45
|
+
* Resolve which protocols can RECEIVE on a given layer (e.g. show the user
|
|
46
|
+
* the available "receive over Lightning / Spark / on-chain" options).
|
|
47
|
+
*/
|
|
48
|
+
resolveReceive(layer: Layer): ReceiveRoute[];
|
|
49
|
+
/**
|
|
50
|
+
* Which registered+connected protocols hold/transfer a given asset family.
|
|
51
|
+
* `assetFamily`: 'BTC' or a specific asset id resolved by the caller to a protocol.
|
|
52
|
+
*/
|
|
53
|
+
resolveByCapability(predicate: (protocol: ProtocolType) => boolean): IProtocolAdapter[];
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/router/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AACxF,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAEnD,OAAO,EAAuB,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAE1E,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,YAAY,CAAA;IACtB,OAAO,EAAE,gBAAgB,CAAA;IACzB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAA;IACnB,0EAA0E;IAC1E,MAAM,EAAE,OAAO,CAAA;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,qBAAqB,CAAA;IAClC,gEAAgE;IAChE,MAAM,EAAE,SAAS,EAAE,CAAA;IACnB,2EAA2E;IAC3E,IAAI,EAAE,SAAS,GAAG,IAAI,CAAA;CACvB;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,YAAY,CAAA;IACtB,OAAO,EAAE,gBAAgB,CAAA;IACzB,KAAK,EAAE,KAAK,CAAA;CACb;AAED,qBAAa,mBAAmB;IAClB,OAAO,CAAC,QAAQ;gBAAR,QAAQ,EAAE,uBAAuB;IAErD,6EAA6E;IAC7E,OAAO,CAAC,SAAS;IAKjB;;;OAGG;IACH,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,cAAc;IAahD;;;OAGG;IACH,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,YAAY,EAAE;IAY5C;;;OAGG;IACH,mBAAmB,CAAC,SAAS,EAAE,CAAC,QAAQ,EAAE,YAAY,KAAK,OAAO,GAAG,gBAAgB,EAAE;CAOxF"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CrossProtocolRouter
|
|
3
|
+
* -------------------
|
|
4
|
+
* Sits ON TOP of the adapters and chooses BETWEEN protocols. Given a send
|
|
5
|
+
* destination or a receive intent, it returns the protocol(s) that can fulfil it,
|
|
6
|
+
* filtered to what's actually registered and connected. This is the layer that
|
|
7
|
+
* makes lite mode possible: it auto-selects the route so the UI never has to.
|
|
8
|
+
*
|
|
9
|
+
* It reads the capability manifest (differences-as-data) + the destination
|
|
10
|
+
* classifier — never the adapters' internals.
|
|
11
|
+
*/
|
|
12
|
+
import { getCapabilities } from '../capabilities';
|
|
13
|
+
import { classifyDestination } from './destination';
|
|
14
|
+
export class CrossProtocolRouter {
|
|
15
|
+
constructor(registry) {
|
|
16
|
+
this.registry = registry;
|
|
17
|
+
}
|
|
18
|
+
/** Only adapters that are registered AND connected are eligible to route. */
|
|
19
|
+
connected(protocol) {
|
|
20
|
+
const a = this.registry.get(protocol);
|
|
21
|
+
return a && a.isConnected() ? a : null;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Resolve how to SEND to a destination string.
|
|
25
|
+
* Lite mode uses `.best`; advanced mode can offer the full `.routes` list.
|
|
26
|
+
*/
|
|
27
|
+
resolveSend(destination) {
|
|
28
|
+
const classified = classifyDestination(destination);
|
|
29
|
+
const routes = [];
|
|
30
|
+
for (const protocol of classified.candidates) {
|
|
31
|
+
const adapter = this.connected(protocol);
|
|
32
|
+
if (!adapter)
|
|
33
|
+
continue;
|
|
34
|
+
routes.push({ protocol, adapter, layer: classified.layer, direct: true });
|
|
35
|
+
}
|
|
36
|
+
return { destination: classified, routes, best: routes[0] ?? null };
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Resolve which protocols can RECEIVE on a given layer (e.g. show the user
|
|
40
|
+
* the available "receive over Lightning / Spark / on-chain" options).
|
|
41
|
+
*/
|
|
42
|
+
resolveReceive(layer) {
|
|
43
|
+
const out = [];
|
|
44
|
+
for (const protocol of this.registry.getSupportedProtocols()) {
|
|
45
|
+
const caps = getCapabilities(protocol);
|
|
46
|
+
if (!caps.layers.includes(layer))
|
|
47
|
+
continue;
|
|
48
|
+
const adapter = this.connected(protocol);
|
|
49
|
+
if (!adapter)
|
|
50
|
+
continue;
|
|
51
|
+
out.push({ protocol, adapter, layer });
|
|
52
|
+
}
|
|
53
|
+
return out;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Which registered+connected protocols hold/transfer a given asset family.
|
|
57
|
+
* `assetFamily`: 'BTC' or a specific asset id resolved by the caller to a protocol.
|
|
58
|
+
*/
|
|
59
|
+
resolveByCapability(predicate) {
|
|
60
|
+
return this.registry
|
|
61
|
+
.getSupportedProtocols()
|
|
62
|
+
.filter(predicate)
|
|
63
|
+
.map((p) => this.connected(p))
|
|
64
|
+
.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,KAAY;QACzB,MAAM,GAAG,GAAmB,EAAE,CAAA;QAC9B,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,qBAAqB,EAAE,EAAE,CAAC;YAC7D,MAAM,IAAI,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAA;YACtC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;gBAAE,SAAQ;YAC1C,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAA;YACxC,IAAI,CAAC,OAAO;gBAAE,SAAQ;YACtB,GAAG,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAA;QACxC,CAAC;QACD,OAAO,GAAG,CAAA;IACZ,CAAC;IAED;;;OAGG;IACH,mBAAmB,CAAC,SAA8C;QAChE,OAAO,IAAI,CAAC,QAAQ;aACjB,qBAAqB,EAAE;aACvB,MAAM,CAAC,SAAS,CAAC;aACjB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;aAC7B,MAAM,CAAC,CAAC,CAAC,EAAyB,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,CAAA;IACpD,CAAC;CACF"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KaleidoswapSwap
|
|
3
|
+
* ---------------
|
|
4
|
+
* Wraps the WDK Kaleidoswap swap protocol module (@kaleidorg/wdk-protocol-swap-kaleidoswap)
|
|
5
|
+
* behind domain `Quote`/`SwapResult` types. This is the cross-asset swap path (RFQ via the
|
|
6
|
+
* maker) — distinct from the lower-level cross-L2 atomic (VHTLC/Boltz) layer in types/cross-l2.
|
|
7
|
+
*
|
|
8
|
+
* The swap module is bound to an account (it needs a wallet to settle legs) + a baseUrl.
|
|
9
|
+
* No WDK/kaleido-sdk types cross this boundary.
|
|
10
|
+
*/
|
|
11
|
+
import { Quote, QuoteRequest, SwapResult } from '../types/base';
|
|
12
|
+
export interface KaleidoswapSwapConfig {
|
|
13
|
+
/** KaleidoSwap maker API base URL. */
|
|
14
|
+
baseUrl: string;
|
|
15
|
+
}
|
|
16
|
+
/** Extended quote request carrying the layer hints the maker RFQ needs. */
|
|
17
|
+
export interface SwapQuoteRequest extends QuoteRequest {
|
|
18
|
+
fromLayer: string;
|
|
19
|
+
toLayer: string;
|
|
20
|
+
}
|
|
21
|
+
export interface SwapExecuteRequest extends SwapQuoteRequest {
|
|
22
|
+
/** Destination address/invoice for the OUTPUT asset. */
|
|
23
|
+
receiverAddress: string;
|
|
24
|
+
/** Format of the receiver address (e.g. 'RGB_INVOICE', 'BOLT11', 'BTC_ADDRESS'). */
|
|
25
|
+
receiverAddressFormat: string;
|
|
26
|
+
}
|
|
27
|
+
export declare class KaleidoswapSwap {
|
|
28
|
+
private account;
|
|
29
|
+
private config;
|
|
30
|
+
private proto;
|
|
31
|
+
/**
|
|
32
|
+
* @param account a connected WDK account (e.g. the RLN account that settles RGB-LN legs).
|
|
33
|
+
* Passed straight through to the swap module; held as `any`.
|
|
34
|
+
*/
|
|
35
|
+
constructor(account: any, config: KaleidoswapSwapConfig);
|
|
36
|
+
private ensure;
|
|
37
|
+
getQuote(req: SwapQuoteRequest): Promise<Quote>;
|
|
38
|
+
executeSwap(req: SwapExecuteRequest): Promise<SwapResult & {
|
|
39
|
+
depositAddress: string | null;
|
|
40
|
+
depositAddressFormat: string | null;
|
|
41
|
+
}>;
|
|
42
|
+
getSwapStatus(orderId: string): Promise<SwapResult>;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=KaleidoswapSwap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KaleidoswapSwap.d.ts","sourceRoot":"","sources":["../../src/swap/KaleidoswapSwap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,UAAU,EAAiB,MAAM,eAAe,CAAA;AAG9E,MAAM,WAAW,qBAAqB;IACpC,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,2EAA2E;AAC3E,MAAM,WAAW,gBAAiB,SAAQ,YAAY;IACpD,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,kBAAmB,SAAQ,gBAAgB;IAC1D,wDAAwD;IACxD,eAAe,EAAE,MAAM,CAAA;IACvB,oFAAoF;IACpF,qBAAqB,EAAE,MAAM,CAAA;CAC9B;AAED,qBAAa,eAAe;IAOd,OAAO,CAAC,OAAO;IAAO,OAAO,CAAC,MAAM;IANhD,OAAO,CAAC,KAAK,CAAY;IAEzB;;;OAGG;gBACiB,OAAO,EAAE,GAAG,EAAU,MAAM,EAAE,qBAAqB;YAEzD,MAAM;IASd,QAAQ,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,KAAK,CAAC;IAyB/C,WAAW,CAAC,GAAG,EAAE,kBAAkB,GAAG,OAAO,CAAC,UAAU,GAAG;QAAE,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IAkClI,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CAqB1D"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KaleidoswapSwap
|
|
3
|
+
* ---------------
|
|
4
|
+
* Wraps the WDK Kaleidoswap swap protocol module (@kaleidorg/wdk-protocol-swap-kaleidoswap)
|
|
5
|
+
* behind domain `Quote`/`SwapResult` types. This is the cross-asset swap path (RFQ via the
|
|
6
|
+
* maker) — distinct from the lower-level cross-L2 atomic (VHTLC/Boltz) layer in types/cross-l2.
|
|
7
|
+
*
|
|
8
|
+
* The swap module is bound to an account (it needs a wallet to settle legs) + a baseUrl.
|
|
9
|
+
* No WDK/kaleido-sdk types cross this boundary.
|
|
10
|
+
*/
|
|
11
|
+
import { ProtocolError } from '../types/base';
|
|
12
|
+
import { loadWdkModule } from '../adapters/wdk/moduleLoader';
|
|
13
|
+
export class KaleidoswapSwap {
|
|
14
|
+
/**
|
|
15
|
+
* @param account a connected WDK account (e.g. the RLN account that settles RGB-LN legs).
|
|
16
|
+
* Passed straight through to the swap module; held as `any`.
|
|
17
|
+
*/
|
|
18
|
+
constructor(account, config) {
|
|
19
|
+
this.account = account;
|
|
20
|
+
this.config = config;
|
|
21
|
+
this.proto = null;
|
|
22
|
+
}
|
|
23
|
+
async ensure() {
|
|
24
|
+
if (this.proto)
|
|
25
|
+
return this.proto;
|
|
26
|
+
// @ts-ignore — declared as a workspace/optional dep; resolved at runtime.
|
|
27
|
+
const mod = await loadWdkModule('@kaleidorg/wdk-protocol-swap-kaleidoswap', () => import('@kaleidorg/wdk-protocol-swap-kaleidoswap'));
|
|
28
|
+
const KaleidoswapProtocol = mod.default ?? mod;
|
|
29
|
+
this.proto = new KaleidoswapProtocol(this.account, { baseUrl: this.config.baseUrl });
|
|
30
|
+
return this.proto;
|
|
31
|
+
}
|
|
32
|
+
async getQuote(req) {
|
|
33
|
+
if (req.fromAmount == null) {
|
|
34
|
+
throw new ProtocolError('Swap quote requires fromAmount', 'RGB', 'NO_AMOUNT');
|
|
35
|
+
}
|
|
36
|
+
const proto = await this.ensure();
|
|
37
|
+
const q = await proto.quoteSwap({
|
|
38
|
+
fromAssetId: req.fromAsset,
|
|
39
|
+
toAssetId: req.toAsset,
|
|
40
|
+
fromLayer: req.fromLayer,
|
|
41
|
+
toLayer: req.toLayer,
|
|
42
|
+
fromAmount: req.fromAmount,
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
id: q.rfqId,
|
|
46
|
+
fromAsset: req.fromAsset,
|
|
47
|
+
fromAmount: Number(q.tokenInAmount),
|
|
48
|
+
toAsset: req.toAsset,
|
|
49
|
+
toAmount: Number(q.tokenOutAmount),
|
|
50
|
+
price: Number(q.price),
|
|
51
|
+
fee: { amount: Number(q.fee), asset: req.fromAsset },
|
|
52
|
+
expiresAt: Number(q.expiresAt) * 1000,
|
|
53
|
+
provider: 'kaleidoswap',
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
async executeSwap(req) {
|
|
57
|
+
if (req.fromAmount == null) {
|
|
58
|
+
throw new ProtocolError('Swap requires fromAmount', 'RGB', 'NO_AMOUNT');
|
|
59
|
+
}
|
|
60
|
+
const proto = await this.ensure();
|
|
61
|
+
const r = await proto.swap({
|
|
62
|
+
fromAssetId: req.fromAsset,
|
|
63
|
+
toAssetId: req.toAsset,
|
|
64
|
+
fromLayer: req.fromLayer,
|
|
65
|
+
toLayer: req.toLayer,
|
|
66
|
+
fromAmount: req.fromAmount,
|
|
67
|
+
receiverAddress: req.receiverAddress,
|
|
68
|
+
receiverAddressFormat: req.receiverAddressFormat,
|
|
69
|
+
});
|
|
70
|
+
return {
|
|
71
|
+
swapId: r.orderId,
|
|
72
|
+
status: 'pending',
|
|
73
|
+
quote: {
|
|
74
|
+
id: r.orderId,
|
|
75
|
+
fromAsset: req.fromAsset,
|
|
76
|
+
fromAmount: Number(r.tokenInAmount),
|
|
77
|
+
toAsset: req.toAsset,
|
|
78
|
+
toAmount: Number(r.tokenOutAmount),
|
|
79
|
+
price: 0,
|
|
80
|
+
fee: { amount: Number(r.fee), asset: req.fromAsset },
|
|
81
|
+
expiresAt: 0,
|
|
82
|
+
provider: 'kaleidoswap',
|
|
83
|
+
},
|
|
84
|
+
timestamp: Date.now(),
|
|
85
|
+
depositAddress: r.depositAddress ?? null,
|
|
86
|
+
depositAddressFormat: r.depositAddressFormat ?? null,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
async getSwapStatus(orderId) {
|
|
90
|
+
const proto = await this.ensure();
|
|
91
|
+
const o = await proto.getOrderStatus(orderId);
|
|
92
|
+
const status = mapOrderStatus(o?.status);
|
|
93
|
+
return {
|
|
94
|
+
swapId: o.id,
|
|
95
|
+
status,
|
|
96
|
+
quote: {
|
|
97
|
+
id: o.rfq_id,
|
|
98
|
+
fromAsset: o.from_asset?.asset_id,
|
|
99
|
+
fromAmount: Number(o.from_asset?.amount ?? 0),
|
|
100
|
+
toAsset: o.to_asset?.asset_id,
|
|
101
|
+
toAmount: Number(o.to_asset?.amount ?? 0),
|
|
102
|
+
price: Number(o.price ?? 0),
|
|
103
|
+
fee: { amount: 0, asset: o.from_asset?.asset_id },
|
|
104
|
+
expiresAt: 0,
|
|
105
|
+
provider: 'kaleidoswap',
|
|
106
|
+
},
|
|
107
|
+
timestamp: Date.now(),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function mapOrderStatus(s) {
|
|
112
|
+
switch (s) {
|
|
113
|
+
case 'FILLED':
|
|
114
|
+
return 'confirmed';
|
|
115
|
+
case 'FAILED':
|
|
116
|
+
case 'EXPIRED':
|
|
117
|
+
case 'CANCELLED':
|
|
118
|
+
return 'failed';
|
|
119
|
+
default:
|
|
120
|
+
return 'pending';
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=KaleidoswapSwap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KaleidoswapSwap.js","sourceRoot":"","sources":["../../src/swap/KaleidoswapSwap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAmC,aAAa,EAAE,MAAM,eAAe,CAAA;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAoB5D,MAAM,OAAO,eAAe;IAG1B;;;OAGG;IACH,YAAoB,OAAY,EAAU,MAA6B;QAAnD,YAAO,GAAP,OAAO,CAAK;QAAU,WAAM,GAAN,MAAM,CAAuB;QAN/D,UAAK,GAAQ,IAAI,CAAA;IAMiD,CAAC;IAEnE,KAAK,CAAC,MAAM;QAClB,IAAI,IAAI,CAAC,KAAK;YA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ACd,KAAK,SAAS,CAAC;QACf,KAAK,WAAW;YACd,OAAO,QAAQ,CAAA;QACjB;YACE,OAAO,SAAS,CAAA;IACpB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Arkade Protocol Types
|
|
3
|
+
* Ported from rate-extension/src/protocols/types/arkade.ts
|
|
4
|
+
*/
|
|
5
|
+
import { BaseProtocolConfig } from '../adapters/IProtocolAdapter';
|
|
6
|
+
export interface ArkadeConfig extends Omit<BaseProtocolConfig, 'network'> {
|
|
7
|
+
protocol: 'ARKADE';
|
|
8
|
+
mnemonic: string;
|
|
9
|
+
arkServerUrl: string;
|
|
10
|
+
esploraUrl?: string;
|
|
11
|
+
network?: 'mainnet' | 'signet';
|
|
12
|
+
delegatorUrl?: string;
|
|
13
|
+
delegationEnabled?: boolean;
|
|
14
|
+
vtxoThresholdSeconds?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface ArkadeVtxo {
|
|
17
|
+
txid: string;
|
|
18
|
+
vout: number;
|
|
19
|
+
amount: bigint;
|
|
20
|
+
expiresAt?: number;
|
|
21
|
+
status?: 'confirmed' | 'preconfirmed' | 'recoverable';
|
|
22
|
+
}
|
|
23
|
+
export interface ArkadeBalance {
|
|
24
|
+
total: bigint;
|
|
25
|
+
available: bigint;
|
|
26
|
+
preconfirmed: bigint;
|
|
27
|
+
settled: bigint;
|
|
28
|
+
recoverable: bigint;
|
|
29
|
+
boarding: {
|
|
30
|
+
total: bigint;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export interface ArkadeTransaction {
|
|
34
|
+
type: 'send' | 'receive' | 'boarding' | 'offboard';
|
|
35
|
+
amount: number;
|
|
36
|
+
txid?: string;
|
|
37
|
+
timestamp?: number;
|
|
38
|
+
status?: string;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=arkade.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arkade.d.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