@hsuite/native-connect-types 1.0.0 → 2.1.1
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/emoji-avatar.d.ts +37 -0
- package/dist/emoji-avatar.d.ts.map +1 -0
- package/dist/emoji-avatar.js +111 -0
- package/dist/emoji-avatar.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -1
- package/dist/index.js.map +1 -1
- package/dist/ipfs-cdn.d.ts +82 -0
- package/dist/ipfs-cdn.d.ts.map +1 -0
- package/dist/ipfs-cdn.js +138 -0
- package/dist/ipfs-cdn.js.map +1 -0
- package/dist/ledger.d.ts +30 -0
- package/dist/ledger.d.ts.map +1 -1
- package/dist/ledger.js +24 -0
- package/dist/ledger.js.map +1 -1
- package/dist/messages.d.ts +51 -12
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +19 -0
- package/dist/messages.js.map +1 -1
- package/dist/rpc.d.ts +28 -18
- package/dist/rpc.d.ts.map +1 -1
- package/dist/transaction-approval.d.ts +18 -1
- package/dist/transaction-approval.d.ts.map +1 -1
- package/dist/vault.d.ts +56 -12
- package/dist/vault.d.ts.map +1 -1
- package/dist/vault.js +25 -0
- package/dist/vault.js.map +1 -1
- package/dist/xrpl-endpoints.d.ts +48 -0
- package/dist/xrpl-endpoints.d.ts.map +1 -0
- package/dist/xrpl-endpoints.js +54 -0
- package/dist/xrpl-endpoints.js.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +22 -0
- package/src/ipfs-cdn.spec.ts +163 -0
- package/src/ipfs-cdn.ts +152 -0
- package/src/ledger.spec.ts +51 -0
- package/src/ledger.ts +25 -0
- package/src/messages.ts +35 -0
- package/src/transaction-approval.ts +30 -0
- package/src/vault.spec.ts +36 -0
- package/src/vault.ts +31 -0
- package/src/xrpl-endpoints.spec.ts +46 -0
- package/src/xrpl-endpoints.ts +56 -0
- package/tsconfig.build.tsbuildinfo +1 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HSuite Native Connect
|
|
3
|
+
* Copyright 2024-2025 HSuite (https://hsuite.finance)
|
|
4
|
+
*
|
|
5
|
+
* SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0
|
|
6
|
+
*
|
|
7
|
+
* This file is part of HSuite Native Connect. For commercial licensing,
|
|
8
|
+
* visit https://hsuite.finance/licensing
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Represents a deterministic emoji avatar generated from a wallet address.
|
|
12
|
+
*/
|
|
13
|
+
export interface EmojiAvatar {
|
|
14
|
+
/** The emoji character representing this address */
|
|
15
|
+
emoji: string;
|
|
16
|
+
/** Dark background color (hex) */
|
|
17
|
+
backgroundColor: string;
|
|
18
|
+
/** Neon accent color for borders/effects (hex) */
|
|
19
|
+
accentColor: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Generate a deterministic emoji avatar from a wallet address.
|
|
23
|
+
*
|
|
24
|
+
* The same address will always produce the same emoji and colors,
|
|
25
|
+
* making it useful for consistent visual identification across the app.
|
|
26
|
+
*
|
|
27
|
+
* @param address - The wallet address (Hedera, XRPL, or Ethereum format)
|
|
28
|
+
* @returns An EmojiAvatar object with emoji and color information
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const avatar = emojiAvatarForAddress('0.0.12345');
|
|
33
|
+
* // { emoji: '🚀', backgroundColor: '#1a1a2e', accentColor: '#00d4ff' }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function emojiAvatarForAddress(address: string): EmojiAvatar;
|
|
37
|
+
//# sourceMappingURL=emoji-avatar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emoji-avatar.d.ts","sourceRoot":"","sources":["../src/emoji-avatar.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC;IACd,kCAAkC;IAClC,eAAe,EAAE,MAAM,CAAC;IACxB,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;CACrB;AAgFD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,CAalE"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HSuite Native Connect
|
|
3
|
+
* Copyright 2024-2025 HSuite (https://hsuite.finance)
|
|
4
|
+
*
|
|
5
|
+
* SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0
|
|
6
|
+
*
|
|
7
|
+
* This file is part of HSuite Native Connect. For commercial licensing,
|
|
8
|
+
* visit https://hsuite.finance/licensing
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Tech/crypto themed emojis (30 total)
|
|
12
|
+
*/
|
|
13
|
+
const EMOJIS = [
|
|
14
|
+
// Crypto/blockchain
|
|
15
|
+
'💎',
|
|
16
|
+
'⛓️',
|
|
17
|
+
'🪙',
|
|
18
|
+
'💰',
|
|
19
|
+
'🏦',
|
|
20
|
+
'📊',
|
|
21
|
+
// Tech/digital
|
|
22
|
+
'⚡',
|
|
23
|
+
'🔐',
|
|
24
|
+
'🛡️',
|
|
25
|
+
'🔑',
|
|
26
|
+
'🌐',
|
|
27
|
+
'💻',
|
|
28
|
+
// Space/futuristic
|
|
29
|
+
'🚀',
|
|
30
|
+
'🛸',
|
|
31
|
+
'🌌',
|
|
32
|
+
'🔮',
|
|
33
|
+
'✨',
|
|
34
|
+
'☄️',
|
|
35
|
+
// Abstract/symbols
|
|
36
|
+
'🎯',
|
|
37
|
+
'💡',
|
|
38
|
+
'🧩',
|
|
39
|
+
'🎲',
|
|
40
|
+
'🔷',
|
|
41
|
+
'💠',
|
|
42
|
+
// Science/innovation
|
|
43
|
+
'🧬',
|
|
44
|
+
'⚛️',
|
|
45
|
+
'🔬',
|
|
46
|
+
'📡',
|
|
47
|
+
'🤖',
|
|
48
|
+
'👾',
|
|
49
|
+
];
|
|
50
|
+
/**
|
|
51
|
+
* Dark/neon color pairs (15 total)
|
|
52
|
+
* Each pair has a dark background and a neon accent color
|
|
53
|
+
*/
|
|
54
|
+
const COLOR_PAIRS = [
|
|
55
|
+
{ bg: '#1a1a2e', accent: '#00d4ff' }, // Deep blue + cyan neon
|
|
56
|
+
{ bg: '#16213e', accent: '#0f4c75' }, // Navy + electric blue
|
|
57
|
+
{ bg: '#1b1b2f', accent: '#e94560' }, // Dark purple + pink neon
|
|
58
|
+
{ bg: '#0d1117', accent: '#58a6ff' }, // GitHub dark + blue
|
|
59
|
+
{ bg: '#1a1a1a', accent: '#00ff88' }, // Black + green neon
|
|
60
|
+
{ bg: '#2d132c', accent: '#ee4540' }, // Dark wine + red neon
|
|
61
|
+
{ bg: '#1f1f1f', accent: '#f39c12' }, // Charcoal + orange neon
|
|
62
|
+
{ bg: '#0f0e17', accent: '#ff8906' }, // Deep black + amber
|
|
63
|
+
{ bg: '#1a1a2e', accent: '#a855f7' }, // Deep blue + purple neon
|
|
64
|
+
{ bg: '#0d1b2a', accent: '#00ffff' }, // Dark teal + cyan
|
|
65
|
+
{ bg: '#1b0a1a', accent: '#ff00ff' }, // Deep purple + magenta
|
|
66
|
+
{ bg: '#0a192f', accent: '#64ffda' }, // Navy + mint neon
|
|
67
|
+
{ bg: '#141414', accent: '#ffd700' }, // Black + gold
|
|
68
|
+
{ bg: '#1a1a2e', accent: '#ff6b6b' }, // Deep blue + coral
|
|
69
|
+
{ bg: '#0f0f0f', accent: '#39ff14' }, // Black + matrix green
|
|
70
|
+
];
|
|
71
|
+
/**
|
|
72
|
+
* Generate a numeric hash from a string.
|
|
73
|
+
* Uses the same algorithm as RainbowKit for consistency.
|
|
74
|
+
* @param str
|
|
75
|
+
*/
|
|
76
|
+
function hashCode(str) {
|
|
77
|
+
let hash = 0;
|
|
78
|
+
for (let i = 0; i < str.length; i++) {
|
|
79
|
+
const chr = str.charCodeAt(i);
|
|
80
|
+
hash = (hash << 5) - hash + chr;
|
|
81
|
+
hash |= 0; // Convert to 32bit integer
|
|
82
|
+
}
|
|
83
|
+
return hash;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Generate a deterministic emoji avatar from a wallet address.
|
|
87
|
+
*
|
|
88
|
+
* The same address will always produce the same emoji and colors,
|
|
89
|
+
* making it useful for consistent visual identification across the app.
|
|
90
|
+
*
|
|
91
|
+
* @param address - The wallet address (Hedera, XRPL, or Ethereum format)
|
|
92
|
+
* @returns An EmojiAvatar object with emoji and color information
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```typescript
|
|
96
|
+
* const avatar = emojiAvatarForAddress('0.0.12345');
|
|
97
|
+
* // { emoji: '🚀', backgroundColor: '#1a1a2e', accentColor: '#00d4ff' }
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export function emojiAvatarForAddress(address) {
|
|
101
|
+
const hash = Math.abs(hashCode(address.toLowerCase()));
|
|
102
|
+
const emojiIndex = hash % EMOJIS.length;
|
|
103
|
+
const colorIndex = hash % COLOR_PAIRS.length;
|
|
104
|
+
const colorPair = COLOR_PAIRS[colorIndex];
|
|
105
|
+
return {
|
|
106
|
+
emoji: EMOJIS[emojiIndex],
|
|
107
|
+
backgroundColor: colorPair.bg,
|
|
108
|
+
accentColor: colorPair.accent,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=emoji-avatar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emoji-avatar.js","sourceRoot":"","sources":["../src/emoji-avatar.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAcH;;GAEG;AACH,MAAM,MAAM,GAAG;IACb,oBAAoB;IACpB,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;I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ANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* - Vault configuration schemas
|
|
21
21
|
* - JSON-RPC protocol types
|
|
22
22
|
*/
|
|
23
|
-
export { LedgerIdSchema, NetworkIdSchema, LedgerAccountSchema, LedgerPluginManifestSchema, LedgerAdapterHealthSchema, LedgerAdapterDiagnosticsSchema, DerivationPathSchema, } from './ledger.js';
|
|
23
|
+
export { LedgerIdSchema, LedgerIds, NetworkIdSchema, LedgerAccountSchema, LedgerPluginManifestSchema, LedgerAdapterHealthSchema, LedgerAdapterDiagnosticsSchema, DerivationPathSchema, } from './ledger.js';
|
|
24
24
|
export type { LedgerId, LedgerAccount, LedgerPluginManifest, LedgerAdapterHealth, LedgerAdapterDiagnostics, DerivationPath, DerivedAccount, FungibleTokenRef, NftRef, FungibleTokenInfo, NftInfo, IssuedTokenInfo, AssetKind, AssetId, AssetBalance, AssetPriceInfo, PortfolioAccount, Portfolio, NftCollection, TransactionStatus, LedgerTransaction, TransactionQueryOptions, PagedTransactionResult, AccountValidationResult, ActivationStatus, AccountActivationResult, ActivationInstructions, } from './ledger.js';
|
|
25
25
|
export { SessionRequestSchema, SessionApprovalSchema, SignPayloadSchema, SignResultSchema, MessageSignResultSchema, SignedInnerTransactionSchema, BatchInnerTransactionSchema, MessageEnvelopeSchema, TransactionSubmissionSchema, } from './messages.js';
|
|
26
26
|
export type { SessionRequest, SessionApproval, SignPayload, SignResult, SignMessagePayload, MessageSignResult, SignedInnerTransaction, BatchInnerTransaction, TransactionSubmission, MessageEnvelope, } from './messages.js';
|
|
@@ -40,4 +40,6 @@ export { avatarForAddress, marbleShapeTransform, MARBLE_AVATAR_SIZE, type Marble
|
|
|
40
40
|
export type { MemberIdentity } from './identity.js';
|
|
41
41
|
export { normalizeIdentityKey, matchesMemberIdentity } from './identity.js';
|
|
42
42
|
export { HEDERA_NODE_ACCOUNTS, HEDERA_FEE_COLLECTOR_ACCOUNTS, HEDERA_SYSTEM_ACCOUNTS, } from './hedera-system-accounts.js';
|
|
43
|
+
export { XRPL_ENDPOINTS, endpointsFor } from './xrpl-endpoints.js';
|
|
44
|
+
export { HSUITE_IPFS_CDN_BASE, HSUITE_IPFS_CDN_HOST, NFT_IMAGE_WIDTH, withImageOptimizer, } from './ipfs-cdn.js';
|
|
43
45
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;GAYG;AAMH,OAAO,EACL,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,0BAA0B,EAC1B,yBAAyB,EACzB,8BAA8B,EAC9B,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAIrB,YAAY,EACV,QAAQ,EACR,aAAa,EACb,oBAAoB,EACpB,mBAAmB,EACnB,wBAAwB,EACxB,cAAc,EACd,cAAc,EAEd,gBAAgB,EAChB,MAAM,EAEN,iBAAiB,EACjB,OAAO,EAEP,eAAe,EAEf,SAAS,EACT,OAAO,EACP,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,aAAa,EAEb,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,sBAAsB,EAEtB,uBAAuB,EAEvB,gBAAgB,EAChB,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EAChB,uBAAuB,EACvB,4BAA4B,EAC5B,2BAA2B,EAC3B,qBAAqB,EACrB,2BAA2B,GAE5B,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,cAAc,EACd,eAAe,EACf,WAAW,EACX,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,GAEhB,MAAM,eAAe,CAAC;AACvB,cAA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c,EACd,QAAQ,GACT,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAGhF,YAAY,EACV,WAAW,EACX,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACrB,YAAY,EACZ,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,EAClB,4BAA4B,EAC5B,iBAAiB,EACjB,eAAe,EACf,sBAAsB,EACtB,0BAA0B,GAC3B,MAAM,uBAAuB,CAAC;AAG/B,YAAY,EACV,oBAAoB,EACpB,uBAAuB,EACvB,qBAAqB,EACrB,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,yBAAyB,CAAC;AAGjC,YAAY,EACV,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,0BAA0B,GAC3B,MAAM,yBAAyB,CAAC;AAKjC,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,kBAAkB,EAClB,KAAK,YAAY,EACjB,KAAK,WAAW,GACjB,MAAM,qBAAqB,CAAC;AAS7B,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAO5E,OAAO,EACL,oBAAoB,EACpB,6BAA6B,EAC7B,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AAQrC,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAQnE,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EACf,kBAAkB,GACnB,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
// re-exports below so the emitted dist/index.js + dist/index.d.ts
|
|
25
25
|
// stay consistent under tsx/esm (which previously tried to load the
|
|
26
26
|
// .d.ts as JS and choked on the mixed value+type re-export).
|
|
27
|
-
export { LedgerIdSchema, NetworkIdSchema, LedgerAccountSchema, LedgerPluginManifestSchema, LedgerAdapterHealthSchema, LedgerAdapterDiagnosticsSchema, DerivationPathSchema, } from './ledger.js';
|
|
27
|
+
export { LedgerIdSchema, LedgerIds, NetworkIdSchema, LedgerAccountSchema, LedgerPluginManifestSchema, LedgerAdapterHealthSchema, LedgerAdapterDiagnosticsSchema, DerivationPathSchema, } from './ledger.js';
|
|
28
28
|
export { SessionRequestSchema, SessionApprovalSchema, SignPayloadSchema, SignResultSchema, MessageSignResultSchema, SignedInnerTransactionSchema, BatchInnerTransactionSchema, MessageEnvelopeSchema, TransactionSubmissionSchema,
|
|
29
29
|
// Note: RpcRequestSchema, RpcSuccessSchema, RpcErrorSchema are exported from rpc.js (JSON-RPC 2.0 compliant)
|
|
30
30
|
} from './messages.js';
|
|
@@ -49,4 +49,18 @@ export { normalizeIdentityKey, matchesMemberIdentity } from './identity.js';
|
|
|
49
49
|
// filtering / fee-breakdown labeling). Importing from one place keeps the
|
|
50
50
|
// filter and labeler from drifting apart.
|
|
51
51
|
export { HEDERA_NODE_ACCOUNTS, HEDERA_FEE_COLLECTOR_ACCOUNTS, HEDERA_SYSTEM_ACCOUNTS, } from './hedera-system-accounts.js';
|
|
52
|
+
// === XRPL Endpoints ===
|
|
53
|
+
// Canonical, ordered rippled endpoint lists per network (primary first, rest
|
|
54
|
+
// are failover). Imported by the ledger-xrpl adapter (WS clients, account
|
|
55
|
+
// checks, manifest) and the native-wallet-sdk (token discovery, import
|
|
56
|
+
// validation) so every XRPL read path fails over across the same nodes and the
|
|
57
|
+
// endpoint set never drifts across packages.
|
|
58
|
+
export { XRPL_ENDPOINTS, endpointsFor } from './xrpl-endpoints.js';
|
|
59
|
+
// === IPFS CDN primitives ===
|
|
60
|
+
// Single source of truth for the HSuite Bunny CDN host/base URL and the
|
|
61
|
+
// per-surface image-optimizer helper. Imported by the SDK gateway layer
|
|
62
|
+
// (the `convertIpfsUrl` default), the wallet app's image getters, and the UI
|
|
63
|
+
// render surfaces so the CDN domain and the optimizer query format never
|
|
64
|
+
// drift across packages.
|
|
65
|
+
export { HSUITE_IPFS_CDN_BASE, HSUITE_IPFS_CDN_HOST, NFT_IMAGE_WIDTH, withImageOptimizer, } from './ipfs-cdn.js';
|
|
52
66
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;GAYG;AAEH,mEAAmE;AACnE,kEAAkE;AAClE,oEAAoE;AACpE,6DAA6D;AAC7D,OAAO,EACL,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,0BAA0B,EAC1B,yBAAyB,EACzB,8BAA8B,EAC9B,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAwCrB,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EAChB,uBAAuB,EACvB,4BAA4B,EAC5B,2BAA2B,EAC3B,qBAAqB,EACrB,2BAA2B;AAC3B,6GAA6G;EAC9G,MAAM,eAAe,CAAC;AAcvB,cAAc,YAAY,CAAC;AAC3B,2FAA2F;AAC3F,4DAA4D;AAC5D,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAiBlC,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAYhF,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,EAClB,4BAA4B,EAC5B,iBAAiB,EACjB,eAAe,EACf,sBAAsB,EACtB,0BAA0B,GAC3B,MAAM,uBAAuB,CAAC;AAoB/B,iCAAiC;AACjC,2EAA2E;AAC3E,mEAAmE;AACnE,OAAO,EAC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2EAA2E;AAC3E,mEAAmE;AACnE,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,kBAAkB,GAGnB,MAAM,qBAAqB,CAAC;AAU7B,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAE5E,iCAAiC;AACjC,4EAA4E;AAC5E,0EAA0E;AAC1E,0EAA0E;AAC1E,0CAA0C;AAC1C,OAAO,EACL,oBAAoB,EACpB,6BAA6B,EAC7B,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AAErC,yBAAyB;AACzB,6EAA6E;AAC7E,0EAA0E;AAC1E,uEAAuE;AACvE,+EAA+E;AAC/E,6CAA6C;AAC7C,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnE,8BAA8B;AAC9B,wEAAwE;AACxE,wEAAwE;AACxE,6EAA6E;AAC7E,yEAAyE;AACzE,yBAAyB;AACzB,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EACf,kBAAkB,GACnB,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HSuite Native Connect
|
|
3
|
+
* Copyright 2024-2025 HSuite (https://hsuite.finance)
|
|
4
|
+
*
|
|
5
|
+
* SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0
|
|
6
|
+
*
|
|
7
|
+
* This file is part of HSuite Native Connect. For commercial licensing,
|
|
8
|
+
* visit https://hsuite.finance/licensing
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* @file Shared HSuite IPFS CDN primitives.
|
|
12
|
+
*
|
|
13
|
+
* The wallet resolves all NFT media (`ipfs://…`) through HSuite's own Bunny
|
|
14
|
+
* CDN, which fronts an IPFS gateway and ships a built-in image optimizer.
|
|
15
|
+
* This module is the single source of truth for:
|
|
16
|
+
*
|
|
17
|
+
* - the CDN host / base URL (so the SDK gateway, the wallet app, and the UI
|
|
18
|
+
* never hardcode the domain independently and drift apart), and
|
|
19
|
+
* - {@link withImageOptimizer}, which appends the Bunny optimizer query
|
|
20
|
+
* (`?optimizer=image&width=N`) so each surface fetches a right-sized
|
|
21
|
+
* variant instead of downloading a full-resolution master for a thumbnail.
|
|
22
|
+
*
|
|
23
|
+
* It lives in `@hsuite/native-connect-types` because that is the only package
|
|
24
|
+
* the SDK, the UI library, and the app all already depend on — the UI does
|
|
25
|
+
* not (and should not) depend on the SDK's channel-protocol/crypto stack.
|
|
26
|
+
*
|
|
27
|
+
* @module ipfs-cdn
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* Host of HSuite's Bunny IPFS CDN. Used for an exact-match host check in
|
|
31
|
+
* {@link withImageOptimizer} so the optimizer is never appended to
|
|
32
|
+
* third-party hosts (Arweave, DaVinciGraph, public IPFS gateways).
|
|
33
|
+
*/
|
|
34
|
+
export declare const HSUITE_IPFS_CDN_HOST = "hsuite-wallet.b-cdn.net";
|
|
35
|
+
/**
|
|
36
|
+
* Base URL for IPFS content on the HSuite CDN. `convertIpfsUrl` rewrites
|
|
37
|
+
* `ipfs://CID/path` to `${HSUITE_IPFS_CDN_BASE}CID/path`. Derived from
|
|
38
|
+
* {@link HSUITE_IPFS_CDN_HOST} so the host and base can never drift apart.
|
|
39
|
+
*/
|
|
40
|
+
export declare const HSUITE_IPFS_CDN_BASE: "https://hsuite-wallet.b-cdn.net/ipfs/";
|
|
41
|
+
/**
|
|
42
|
+
* Logical request widths per render surface, in CSS pixels (already ~2× the
|
|
43
|
+
* display size to cover retina). Bunny returns a variant resized to this
|
|
44
|
+
* width. Tunable in one place; every surface imports from here.
|
|
45
|
+
*
|
|
46
|
+
* - `THUMB` (200): tiny previews — account-overview cover, send NFT picker,
|
|
47
|
+
* approval/transfer hero cards.
|
|
48
|
+
* - `GRID` (350): collection grids and collection cover images.
|
|
49
|
+
* - `DETAIL` (800): the NFT detail-page hero.
|
|
50
|
+
*/
|
|
51
|
+
export declare const NFT_IMAGE_WIDTH: {
|
|
52
|
+
readonly THUMB: 200;
|
|
53
|
+
readonly GRID: 350;
|
|
54
|
+
readonly DETAIL: 800;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Append the Bunny image-optimizer query to an HSuite-CDN raster image URL.
|
|
58
|
+
*
|
|
59
|
+
* The transform is intentionally conservative — it returns the input
|
|
60
|
+
* **unchanged** in every case where optimizing would be wrong or unsafe:
|
|
61
|
+
*
|
|
62
|
+
* - empty / `undefined` input,
|
|
63
|
+
* - malformed or relative URLs (cannot be parsed),
|
|
64
|
+
* - any host other than {@link HSUITE_IPFS_CDN_HOST} (Arweave, DaVinci,
|
|
65
|
+
* public IPFS gateways, base64/data URIs),
|
|
66
|
+
* - non-raster or extensionless paths (SVG, GIF, video, audio, 3D, …),
|
|
67
|
+
* - URLs that already carry an `optimizer` param (idempotent — no double
|
|
68
|
+
* append, so re-wrapping is a no-op).
|
|
69
|
+
*
|
|
70
|
+
* Only when the URL is a CDN-hosted raster image does it append
|
|
71
|
+
* `?optimizer=image&width=<width>` (joining with `&` if a query already
|
|
72
|
+
* exists). This makes the helper safe to call from every image getter: it is
|
|
73
|
+
* a guaranteed no-op for non-image media and third-party hosts.
|
|
74
|
+
*
|
|
75
|
+
* @param url - The (already gateway-resolved) image URL, or `undefined`.
|
|
76
|
+
* @param width - Target width in pixels; defaults to {@link NFT_IMAGE_WIDTH}.GRID.
|
|
77
|
+
* Non-finite or non-positive values fall back to GRID; fractional values are
|
|
78
|
+
* rounded.
|
|
79
|
+
* @returns The optimized URL, or the original input unchanged.
|
|
80
|
+
*/
|
|
81
|
+
export declare function withImageOptimizer(url: string | undefined, width?: number): string | undefined;
|
|
82
|
+
//# sourceMappingURL=ipfs-cdn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ipfs-cdn.d.ts","sourceRoot":"","sources":["../src/ipfs-cdn.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,4BAA4B,CAAC;AAE9D;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,yCAAmD,CAAC;AAErF;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe;;;;CAIlB,CAAC;AA6BX;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,KAAK,GAAE,MAA6B,GACnC,MAAM,GAAG,SAAS,CAoCpB"}
|
package/dist/ipfs-cdn.js
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HSuite Native Connect
|
|
3
|
+
* Copyright 2024-2025 HSuite (https://hsuite.finance)
|
|
4
|
+
*
|
|
5
|
+
* SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0
|
|
6
|
+
*
|
|
7
|
+
* This file is part of HSuite Native Connect. For commercial licensing,
|
|
8
|
+
* visit https://hsuite.finance/licensing
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* @file Shared HSuite IPFS CDN primitives.
|
|
12
|
+
*
|
|
13
|
+
* The wallet resolves all NFT media (`ipfs://…`) through HSuite's own Bunny
|
|
14
|
+
* CDN, which fronts an IPFS gateway and ships a built-in image optimizer.
|
|
15
|
+
* This module is the single source of truth for:
|
|
16
|
+
*
|
|
17
|
+
* - the CDN host / base URL (so the SDK gateway, the wallet app, and the UI
|
|
18
|
+
* never hardcode the domain independently and drift apart), and
|
|
19
|
+
* - {@link withImageOptimizer}, which appends the Bunny optimizer query
|
|
20
|
+
* (`?optimizer=image&width=N`) so each surface fetches a right-sized
|
|
21
|
+
* variant instead of downloading a full-resolution master for a thumbnail.
|
|
22
|
+
*
|
|
23
|
+
* It lives in `@hsuite/native-connect-types` because that is the only package
|
|
24
|
+
* the SDK, the UI library, and the app all already depend on — the UI does
|
|
25
|
+
* not (and should not) depend on the SDK's channel-protocol/crypto stack.
|
|
26
|
+
*
|
|
27
|
+
* @module ipfs-cdn
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* Host of HSuite's Bunny IPFS CDN. Used for an exact-match host check in
|
|
31
|
+
* {@link withImageOptimizer} so the optimizer is never appended to
|
|
32
|
+
* third-party hosts (Arweave, DaVinciGraph, public IPFS gateways).
|
|
33
|
+
*/
|
|
34
|
+
export const HSUITE_IPFS_CDN_HOST = 'hsuite-wallet.b-cdn.net';
|
|
35
|
+
/**
|
|
36
|
+
* Base URL for IPFS content on the HSuite CDN. `convertIpfsUrl` rewrites
|
|
37
|
+
* `ipfs://CID/path` to `${HSUITE_IPFS_CDN_BASE}CID/path`. Derived from
|
|
38
|
+
* {@link HSUITE_IPFS_CDN_HOST} so the host and base can never drift apart.
|
|
39
|
+
*/
|
|
40
|
+
export const HSUITE_IPFS_CDN_BASE = `https://${HSUITE_IPFS_CDN_HOST}/ipfs/`;
|
|
41
|
+
/**
|
|
42
|
+
* Logical request widths per render surface, in CSS pixels (already ~2× the
|
|
43
|
+
* display size to cover retina). Bunny returns a variant resized to this
|
|
44
|
+
* width. Tunable in one place; every surface imports from here.
|
|
45
|
+
*
|
|
46
|
+
* - `THUMB` (200): tiny previews — account-overview cover, send NFT picker,
|
|
47
|
+
* approval/transfer hero cards.
|
|
48
|
+
* - `GRID` (350): collection grids and collection cover images.
|
|
49
|
+
* - `DETAIL` (800): the NFT detail-page hero.
|
|
50
|
+
*/
|
|
51
|
+
export const NFT_IMAGE_WIDTH = {
|
|
52
|
+
THUMB: 200,
|
|
53
|
+
GRID: 350,
|
|
54
|
+
DETAIL: 800,
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Raster formats the Bunny optimizer can safely resize. SVG (vector) and GIF
|
|
58
|
+
* (animation) are deliberately excluded — optimizing them would rasterize the
|
|
59
|
+
* vector or flatten the animation. Anything else (video/audio/3D, or no
|
|
60
|
+
* extension) is left untouched as well.
|
|
61
|
+
*/
|
|
62
|
+
const OPTIMIZABLE_RASTER_EXTENSIONS = new Set([
|
|
63
|
+
'png',
|
|
64
|
+
'jpg',
|
|
65
|
+
'jpeg',
|
|
66
|
+
'webp',
|
|
67
|
+
'avif',
|
|
68
|
+
'bmp',
|
|
69
|
+
]);
|
|
70
|
+
/**
|
|
71
|
+
* Extract the lowercased file extension from a URL pathname, or `''` when the
|
|
72
|
+
* last path segment has none.
|
|
73
|
+
* @param pathname - The URL pathname (already decoded by the URL parser).
|
|
74
|
+
*/
|
|
75
|
+
function fileExtension(pathname) {
|
|
76
|
+
const lastSlash = pathname.lastIndexOf('/');
|
|
77
|
+
const filename = lastSlash >= 0 ? pathname.slice(lastSlash + 1) : pathname;
|
|
78
|
+
const lastDot = filename.lastIndexOf('.');
|
|
79
|
+
return lastDot >= 0 ? filename.slice(lastDot + 1).toLowerCase() : '';
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Append the Bunny image-optimizer query to an HSuite-CDN raster image URL.
|
|
83
|
+
*
|
|
84
|
+
* The transform is intentionally conservative — it returns the input
|
|
85
|
+
* **unchanged** in every case where optimizing would be wrong or unsafe:
|
|
86
|
+
*
|
|
87
|
+
* - empty / `undefined` input,
|
|
88
|
+
* - malformed or relative URLs (cannot be parsed),
|
|
89
|
+
* - any host other than {@link HSUITE_IPFS_CDN_HOST} (Arweave, DaVinci,
|
|
90
|
+
* public IPFS gateways, base64/data URIs),
|
|
91
|
+
* - non-raster or extensionless paths (SVG, GIF, video, audio, 3D, …),
|
|
92
|
+
* - URLs that already carry an `optimizer` param (idempotent — no double
|
|
93
|
+
* append, so re-wrapping is a no-op).
|
|
94
|
+
*
|
|
95
|
+
* Only when the URL is a CDN-hosted raster image does it append
|
|
96
|
+
* `?optimizer=image&width=<width>` (joining with `&` if a query already
|
|
97
|
+
* exists). This makes the helper safe to call from every image getter: it is
|
|
98
|
+
* a guaranteed no-op for non-image media and third-party hosts.
|
|
99
|
+
*
|
|
100
|
+
* @param url - The (already gateway-resolved) image URL, or `undefined`.
|
|
101
|
+
* @param width - Target width in pixels; defaults to {@link NFT_IMAGE_WIDTH}.GRID.
|
|
102
|
+
* Non-finite or non-positive values fall back to GRID; fractional values are
|
|
103
|
+
* rounded.
|
|
104
|
+
* @returns The optimized URL, or the original input unchanged.
|
|
105
|
+
*/
|
|
106
|
+
export function withImageOptimizer(url, width = NFT_IMAGE_WIDTH.GRID) {
|
|
107
|
+
// Empty string and undefined pass straight through.
|
|
108
|
+
if (!url) {
|
|
109
|
+
return url;
|
|
110
|
+
}
|
|
111
|
+
let parsed;
|
|
112
|
+
try {
|
|
113
|
+
parsed = new URL(url);
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
// Relative or malformed URLs are never CDN raster images.
|
|
117
|
+
return url;
|
|
118
|
+
}
|
|
119
|
+
// Exact host match only (host includes any port) — never rewrite
|
|
120
|
+
// third-party hosts, look-alike subdomains, or the CDN host reached
|
|
121
|
+
// on a non-standard port.
|
|
122
|
+
if (parsed.host !== HSUITE_IPFS_CDN_HOST) {
|
|
123
|
+
return url;
|
|
124
|
+
}
|
|
125
|
+
// Only resize raster formats; leave SVG/GIF/video/extensionless alone.
|
|
126
|
+
if (!OPTIMIZABLE_RASTER_EXTENSIONS.has(fileExtension(parsed.pathname))) {
|
|
127
|
+
return url;
|
|
128
|
+
}
|
|
129
|
+
// Idempotent: if it's already optimized, return the original untouched.
|
|
130
|
+
if (parsed.searchParams.has('optimizer')) {
|
|
131
|
+
return url;
|
|
132
|
+
}
|
|
133
|
+
const safeWidth = Number.isFinite(width) && width > 0 ? Math.round(width) : NFT_IMAGE_WIDTH.GRID;
|
|
134
|
+
parsed.searchParams.set('optimizer', 'image');
|
|
135
|
+
parsed.searchParams.set('width', String(safeWidth));
|
|
136
|
+
return parsed.toString();
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=ipfs-cdn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ipfs-cdn.js","sourceR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ChB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;IAAC,MAAM,CAAC;QACP,0DAA0D;QAC1D,OAAO,GAAG,CAAC;IACb,CAAC;IAED,iEAAiE;IACjE,oEAAoE;IACpE,0BAA0B;IAC1B,IAAI,MAAM,CAAC,IAAI,KAAK,oBAAoB,EAAE,CAAC;QACzC,OAAO,GAAG,CAAC;IACb,CAAC;IAED,uEAAuE;IACvE,IAAI,CAAC,6BAA6B,CAAC,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC;QACvE,OAAO,GAAG,CAAC;IACb,CAAC;IAED,wEAAwE;IACxE,IAAI,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;QACzC,OAAO,GAAG,CAAC;IACb,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC;IAEjG,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAC9C,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;IACpD,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC;AAC3B,CAAC"}
|
package/dist/ledger.d.ts
CHANGED
|
@@ -40,6 +40,23 @@ export declare const LedgerIdSchema: z.ZodString;
|
|
|
40
40
|
* @description Type alias for ledger identifier strings
|
|
41
41
|
*/
|
|
42
42
|
export type LedgerId = z.infer<typeof LedgerIdSchema>;
|
|
43
|
+
/**
|
|
44
|
+
* @description Well-known ledger identifiers shipped with the SDK — a typed
|
|
45
|
+
* convenience layer over the open {@link LedgerId} string. Reference
|
|
46
|
+
* `LedgerIds.Hedera` instead of a bare `'hedera'` literal so call sites get
|
|
47
|
+
* compile-time typo safety, find-all-references, and safe rename.
|
|
48
|
+
*
|
|
49
|
+
* Deliberately NOT a closed set of supported ledgers, and it must not become
|
|
50
|
+
* one: `LedgerId` stays an open string and the ledger registry resolves
|
|
51
|
+
* adapters at runtime, so a future chain registers under its own id whether or
|
|
52
|
+
* not it is listed here. Per-ledger PROPERTIES (native decimals, symbol,
|
|
53
|
+
* capabilities) live on the adapter manifest ({@link LedgerMetadata}) — never
|
|
54
|
+
* in this map.
|
|
55
|
+
*/
|
|
56
|
+
export declare const LedgerIds: {
|
|
57
|
+
readonly Hedera: "hedera";
|
|
58
|
+
readonly Xrpl: "xrpl";
|
|
59
|
+
};
|
|
43
60
|
/**
|
|
44
61
|
* @description Network identifier within a ledger ecosystem (e.g., "mainnet", "testnet")
|
|
45
62
|
*/
|
|
@@ -128,6 +145,7 @@ export declare const LedgerMetadataSchema: z.ZodObject<{
|
|
|
128
145
|
displayName: z.ZodString;
|
|
129
146
|
description: z.ZodOptional<z.ZodString>;
|
|
130
147
|
defaultNetworkId: z.ZodString;
|
|
148
|
+
nativeDecimals: z.ZodNumber;
|
|
131
149
|
capabilities: z.ZodObject<{
|
|
132
150
|
supportsMultiSign: z.ZodDefault<z.ZodBoolean>;
|
|
133
151
|
supportsScheduledTx: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -146,6 +164,7 @@ export declare const LedgerMetadataSchema: z.ZodObject<{
|
|
|
146
164
|
displayName?: string;
|
|
147
165
|
description?: string;
|
|
148
166
|
defaultNetworkId?: string;
|
|
167
|
+
nativeDecimals?: number;
|
|
149
168
|
capabilities?: {
|
|
150
169
|
supportsMultiSign?: boolean;
|
|
151
170
|
supportsScheduledTx?: boolean;
|
|
@@ -156,6 +175,7 @@ export declare const LedgerMetadataSchema: z.ZodObject<{
|
|
|
156
175
|
displayName?: string;
|
|
157
176
|
description?: string;
|
|
158
177
|
defaultNetworkId?: string;
|
|
178
|
+
nativeDecimals?: number;
|
|
159
179
|
capabilities?: {
|
|
160
180
|
supportsMultiSign?: boolean;
|
|
161
181
|
supportsScheduledTx?: boolean;
|
|
@@ -175,6 +195,7 @@ export declare const LedgerPluginManifestSchema: z.ZodObject<{
|
|
|
175
195
|
displayName: z.ZodString;
|
|
176
196
|
description: z.ZodOptional<z.ZodString>;
|
|
177
197
|
defaultNetworkId: z.ZodString;
|
|
198
|
+
nativeDecimals: z.ZodNumber;
|
|
178
199
|
capabilities: z.ZodObject<{
|
|
179
200
|
supportsMultiSign: z.ZodDefault<z.ZodBoolean>;
|
|
180
201
|
supportsScheduledTx: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -193,6 +214,7 @@ export declare const LedgerPluginManifestSchema: z.ZodObject<{
|
|
|
193
214
|
displayName?: string;
|
|
194
215
|
description?: string;
|
|
195
216
|
defaultNetworkId?: string;
|
|
217
|
+
nativeDecimals?: number;
|
|
196
218
|
capabilities?: {
|
|
197
219
|
supportsMultiSign?: boolean;
|
|
198
220
|
supportsScheduledTx?: boolean;
|
|
@@ -203,6 +225,7 @@ export declare const LedgerPluginManifestSchema: z.ZodObject<{
|
|
|
203
225
|
displayName?: string;
|
|
204
226
|
description?: string;
|
|
205
227
|
defaultNetworkId?: string;
|
|
228
|
+
nativeDecimals?: number;
|
|
206
229
|
capabilities?: {
|
|
207
230
|
supportsMultiSign?: boolean;
|
|
208
231
|
supportsScheduledTx?: boolean;
|
|
@@ -260,6 +283,7 @@ export declare const LedgerPluginManifestSchema: z.ZodObject<{
|
|
|
260
283
|
displayName?: string;
|
|
261
284
|
description?: string;
|
|
262
285
|
defaultNetworkId?: string;
|
|
286
|
+
nativeDecimals?: number;
|
|
263
287
|
capabilities?: {
|
|
264
288
|
supportsMultiSign?: boolean;
|
|
265
289
|
supportsScheduledTx?: boolean;
|
|
@@ -285,6 +309,7 @@ export declare const LedgerPluginManifestSchema: z.ZodObject<{
|
|
|
285
309
|
displayName?: string;
|
|
286
310
|
description?: string;
|
|
287
311
|
defaultNetworkId?: string;
|
|
312
|
+
nativeDecimals?: number;
|
|
288
313
|
capabilities?: {
|
|
289
314
|
supportsMultiSign?: boolean;
|
|
290
315
|
supportsScheduledTx?: boolean;
|
|
@@ -342,6 +367,7 @@ export declare const LedgerAdapterDiagnosticsSchema: z.ZodObject<{
|
|
|
342
367
|
displayName: z.ZodString;
|
|
343
368
|
description: z.ZodOptional<z.ZodString>;
|
|
344
369
|
defaultNetworkId: z.ZodString;
|
|
370
|
+
nativeDecimals: z.ZodNumber;
|
|
345
371
|
capabilities: z.ZodObject<{
|
|
346
372
|
supportsMultiSign: z.ZodDefault<z.ZodBoolean>;
|
|
347
373
|
supportsScheduledTx: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -360,6 +386,7 @@ export declare const LedgerAdapterDiagnosticsSchema: z.ZodObject<{
|
|
|
360
386
|
displayName?: string;
|
|
361
387
|
description?: string;
|
|
362
388
|
defaultNetworkId?: string;
|
|
389
|
+
nativeDecimals?: number;
|
|
363
390
|
capabilities?: {
|
|
364
391
|
supportsMultiSign?: boolean;
|
|
365
392
|
supportsScheduledTx?: boolean;
|
|
@@ -370,6 +397,7 @@ export declare const LedgerAdapterDiagnosticsSchema: z.ZodObject<{
|
|
|
370
397
|
displayName?: string;
|
|
371
398
|
description?: string;
|
|
372
399
|
defaultNetworkId?: string;
|
|
400
|
+
nativeDecimals?: number;
|
|
373
401
|
capabilities?: {
|
|
374
402
|
supportsMultiSign?: boolean;
|
|
375
403
|
supportsScheduledTx?: boolean;
|
|
@@ -449,6 +477,7 @@ export declare const LedgerAdapterDiagnosticsSchema: z.ZodObject<{
|
|
|
449
477
|
displayName?: string;
|
|
450
478
|
description?: string;
|
|
451
479
|
defaultNetworkId?: string;
|
|
480
|
+
nativeDecimals?: number;
|
|
452
481
|
capabilities?: {
|
|
453
482
|
supportsMultiSign?: boolean;
|
|
454
483
|
supportsScheduledTx?: boolean;
|
|
@@ -485,6 +514,7 @@ export declare const LedgerAdapterDiagnosticsSchema: z.ZodObject<{
|
|
|
485
514
|
displayName?: string;
|
|
486
515
|
description?: string;
|
|
487
516
|
defaultNetworkId?: string;
|
|
517
|
+
nativeDecimals?: number;
|
|
488
518
|
capabilities?: {
|
|
489
519
|
supportsMultiSign?: boolean;
|
|
490
520
|
supportsScheduledTx?: boolean;
|
package/dist/ledger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ledger.d.ts","sourceRoot":"","sources":["../src/ledger.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,cAAc,aAAoB,CAAC;AAEhD;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAEtD;;GAEG;AACH,eAAO,MAAM,eAAe,aAAoB,CAAC;AAEjD;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB;;;;;IAK9B;;;;;OAKG;;;;;;;;;;;;;;EAEH,CAAC;AAEH;;;;;;;GAOG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,aAAa,CAAC;IACvB,UAAU,EAAE,UAAU,CAAC;IACvB,cAAc,EAAE,cAAc,CAAC;CAChC;AAED;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;EAInC,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E;;GAE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AAiF;IACjF,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,8CAA8C;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oCAAoC;IACpC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gFAAgF;IAChF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,4DAA4D;IAC5D,WAAW,EAAE,MAAM,CAAC;IACpB,mFAAmF;IACnF,aAAa,EAAE,MAAM,CAAC;IACtB,0DAA0D;IAC1D,MAAM,EAAE,MAAM,CAAC;IACf,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gDAAgD;IAChD,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B"}
|
package/dist/ledger.js
CHANGED
|
@@ -36,6 +36,23 @@ import { z } from 'zod';
|
|
|
36
36
|
* @description Unique identifier assigned to a ledger integration (e.g., "hedera", "xrpl")
|
|
37
37
|
*/
|
|
38
38
|
export const LedgerIdSchema = z.string().min(1);
|
|
39
|
+
/**
|
|
40
|
+
* @description Well-known ledger identifiers shipped with the SDK — a typed
|
|
41
|
+
* convenience layer over the open {@link LedgerId} string. Reference
|
|
42
|
+
* `LedgerIds.Hedera` instead of a bare `'hedera'` literal so call sites get
|
|
43
|
+
* compile-time typo safety, find-all-references, and safe rename.
|
|
44
|
+
*
|
|
45
|
+
* Deliberately NOT a closed set of supported ledgers, and it must not become
|
|
46
|
+
* one: `LedgerId` stays an open string and the ledger registry resolves
|
|
47
|
+
* adapters at runtime, so a future chain registers under its own id whether or
|
|
48
|
+
* not it is listed here. Per-ledger PROPERTIES (native decimals, symbol,
|
|
49
|
+
* capabilities) live on the adapter manifest ({@link LedgerMetadata}) — never
|
|
50
|
+
* in this map.
|
|
51
|
+
*/
|
|
52
|
+
export const LedgerIds = {
|
|
53
|
+
Hedera: 'hedera',
|
|
54
|
+
Xrpl: 'xrpl',
|
|
55
|
+
};
|
|
39
56
|
/**
|
|
40
57
|
* @description Network identifier within a ledger ecosystem (e.g., "mainnet", "testnet")
|
|
41
58
|
*/
|
|
@@ -76,6 +93,13 @@ export const LedgerMetadataSchema = z.object({
|
|
|
76
93
|
displayName: z.string(),
|
|
77
94
|
description: z.string().optional(),
|
|
78
95
|
defaultNetworkId: NetworkIdSchema,
|
|
96
|
+
// Money-critical native-decimals protocol constant (HBAR=8, XRP=6): the single
|
|
97
|
+
// source of truth for converting native base units to display amounts. REQUIRED
|
|
98
|
+
// so a missing value fails adapter registration loudly rather than silently
|
|
99
|
+
// defaulting and corrupting value math downstream. Upper-bounded at 18 (the
|
|
100
|
+
// highest real-world native-decimals, e.g. ETH) so a fat-finger like 80/800
|
|
101
|
+
// fails validation instead of mis-scaling every on-chain amount.
|
|
102
|
+
nativeDecimals: z.number().int().nonnegative().max(18),
|
|
79
103
|
capabilities: LedgerCapabilitiesSchema,
|
|
80
104
|
});
|
|
81
105
|
/**
|