@hsuite/native-connect-types 2.2.0 → 2.2.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/hedera-transfer-legs.d.ts +80 -0
- package/dist/hedera-transfer-legs.d.ts.map +1 -0
- package/dist/hedera-transfer-legs.js +95 -0
- package/dist/hedera-transfer-legs.js.map +1 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/ledger.d.ts +20 -0
- package/dist/ledger.d.ts.map +1 -1
- package/dist/ledger.js +22 -0
- package/dist/ledger.js.map +1 -1
- package/dist/messages.d.ts +5 -0
- package/dist/messages.d.ts.map +1 -1
- package/dist/multisig-account.d.ts +41 -1
- package/dist/multisig-account.d.ts.map +1 -1
- package/dist/multisig-account.js +6 -1
- package/dist/multisig-account.js.map +1 -1
- package/dist/rpc.d.ts +7 -0
- package/dist/rpc.d.ts.map +1 -1
- package/dist/transaction-amount-utils.d.ts +88 -0
- package/dist/transaction-amount-utils.d.ts.map +1 -0
- package/dist/transaction-amount-utils.js +94 -0
- package/dist/transaction-amount-utils.js.map +1 -0
- package/dist/transaction-approval.d.ts +104 -1
- package/dist/transaction-approval.d.ts.map +1 -1
- package/dist/vault.d.ts +24 -12
- package/dist/vault.d.ts.map +1 -1
- package/dist/widget.types.d.ts +19 -2
- package/dist/widget.types.d.ts.map +1 -1
- package/dist/widget.types.js.map +1 -1
- package/dist/xrpl-trustline.d.ts +31 -0
- package/dist/xrpl-trustline.d.ts.map +1 -0
- package/dist/xrpl-trustline.js +31 -0
- package/dist/xrpl-trustline.js.map +1 -0
- package/package.json +16 -10
- package/src/hedera-transfer-legs.spec.ts +392 -0
- package/src/hedera-transfer-legs.ts +164 -0
- package/src/index.ts +28 -0
- package/src/ledger.spec.ts +44 -1
- package/src/ledger.ts +25 -0
- package/src/multisig-account.ts +25 -1
- package/src/transaction-amount-utils.spec.ts +184 -0
- package/src/transaction-amount-utils.ts +124 -0
- package/src/transaction-approval.ts +103 -0
- package/src/widget.types.ts +20 -2
package/src/multisig-account.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* @
|
|
12
|
+
* @file Unified account management for singlesig and multisig accounts.
|
|
13
13
|
*
|
|
14
14
|
* This module provides a unified data model where both singlesig and multisig
|
|
15
15
|
* accounts are stored together in the KeyVault. This design enables:
|
|
@@ -85,8 +85,17 @@ export const MultisigSignerSchema = z.object({
|
|
|
85
85
|
weight: z.number().positive().default(1),
|
|
86
86
|
/** Whether this signer is "self" (controlled by this wallet instance) */
|
|
87
87
|
isSelf: z.boolean().optional(),
|
|
88
|
+
/** Whether this row is a live on-chain key member that maps to no known account */
|
|
89
|
+
unresolved: z.boolean().optional(),
|
|
88
90
|
});
|
|
89
91
|
|
|
92
|
+
/**
|
|
93
|
+
* A single member of a multisig account's authorization set.
|
|
94
|
+
*
|
|
95
|
+
* Identity is ledger-dependent: Hedera surfaces `publicKey` (a ThresholdKey
|
|
96
|
+
* member), XRPL surfaces `accountAddress` (a SignerList entry). Either may be
|
|
97
|
+
* populated on its own, so comparisons must tolerate one side being empty.
|
|
98
|
+
*/
|
|
90
99
|
export interface MultisigSigner {
|
|
91
100
|
/** Human-readable label for this signer (e.g., "Alice", "Treasury Hot Wallet") */
|
|
92
101
|
label: string;
|
|
@@ -98,6 +107,18 @@ export interface MultisigSigner {
|
|
|
98
107
|
weight?: number;
|
|
99
108
|
/** Whether this signer is "self" (controlled by this wallet instance) */
|
|
100
109
|
isSelf?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* True when this row was recovered from the account's LIVE on-chain key list
|
|
112
|
+
* but matches no account the wallet could resolve — e.g. a bare public key
|
|
113
|
+
* sitting in a Hedera `ThresholdKey` that was never assigned to an account.
|
|
114
|
+
*
|
|
115
|
+
* Such a signer can never sign (nobody holds a matching account) and has no
|
|
116
|
+
* address to render, but it MUST stay in the persisted signer list: a later
|
|
117
|
+
* policy update rebuilds the ThresholdKey from these `publicKey` values
|
|
118
|
+
* (`composeHederaMultisigUpdate`), so dropping the row would silently
|
|
119
|
+
* rewrite the account's on-chain key and hand control to a different set.
|
|
120
|
+
*/
|
|
121
|
+
unresolved?: boolean;
|
|
101
122
|
}
|
|
102
123
|
|
|
103
124
|
/**
|
|
@@ -284,6 +305,9 @@ export function createMultisigMetadata(
|
|
|
284
305
|
*
|
|
285
306
|
* @param existingMetadata - Current account metadata
|
|
286
307
|
* @param multisigConfig - Multisig configuration to apply
|
|
308
|
+
* @param multisigConfig.threshold - Signatures (or summed weights) required to authorize
|
|
309
|
+
* @param multisigConfig.signers - Full member list, including any unresolved on-chain keys
|
|
310
|
+
* @param multisigConfig.name - Human-readable account label
|
|
287
311
|
* @param localSignerAddress - Address of the local signer
|
|
288
312
|
* @returns Updated metadata with multisig configuration
|
|
289
313
|
*/
|
|
@@ -0,0 +1,184 @@
|
|
|
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
|
+
/**
|
|
12
|
+
* Tests for transaction-amount-utils.ts
|
|
13
|
+
*
|
|
14
|
+
* These tests cover the headline-amount arithmetic used by
|
|
15
|
+
* `WalletStateService.enrichTransactionForUser`. Pure helper — no DI / no
|
|
16
|
+
* TestBed required, so they remain runnable even though the wallet app's
|
|
17
|
+
* Karma runner is currently a no-op.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { extractUserAmountForHedera, extractUserAmountForXrpl } from './transaction-amount-utils';
|
|
21
|
+
|
|
22
|
+
describe('extractUserAmountForHedera', () => {
|
|
23
|
+
const USER = '0.0.USER';
|
|
24
|
+
const PEER = '0.0.PEER';
|
|
25
|
+
const FEE_COLLECTOR = '0.0.98';
|
|
26
|
+
|
|
27
|
+
describe('amountTinybars (Hedera headline)', () => {
|
|
28
|
+
it('outgoing transfer: excludes user-paid fee', () => {
|
|
29
|
+
// user pays 0.005 HBAR fee + sends 1 HBAR to peer
|
|
30
|
+
const metadata = {
|
|
31
|
+
transfers: [
|
|
32
|
+
{ account: USER, amount: -100_500_000 }, // -1 HBAR transfer - 0.005 HBAR fee
|
|
33
|
+
{ account: PEER, amount: 100_000_000 },
|
|
34
|
+
{ account: FEE_COLLECTOR, amount: 500_000 },
|
|
35
|
+
],
|
|
36
|
+
charged_tx_fee: 500_000,
|
|
37
|
+
};
|
|
38
|
+
const result = extractUserAmountForHedera(metadata, USER);
|
|
39
|
+
expect(result).toBe(-100_000_000);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('incoming transfer: no fee subtraction', () => {
|
|
43
|
+
const metadata = {
|
|
44
|
+
transfers: [
|
|
45
|
+
{ account: USER, amount: 100_000_000 },
|
|
46
|
+
{ account: PEER, amount: -100_500_000 },
|
|
47
|
+
{ account: FEE_COLLECTOR, amount: 500_000 },
|
|
48
|
+
],
|
|
49
|
+
charged_tx_fee: 500_000,
|
|
50
|
+
};
|
|
51
|
+
// userTotal > 0 → derived userIsSender = false
|
|
52
|
+
const result = extractUserAmountForHedera(metadata, USER);
|
|
53
|
+
expect(result).toBe(100_000_000);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('account-update (no transfer): undefined headline', () => {
|
|
57
|
+
const metadata = {
|
|
58
|
+
transfers: [],
|
|
59
|
+
charged_tx_fee: 500_000,
|
|
60
|
+
};
|
|
61
|
+
const result = extractUserAmountForHedera(metadata, USER);
|
|
62
|
+
expect(result).toBeUndefined();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('self-transfer: nets to zero when user is both sender and receiver', () => {
|
|
66
|
+
// Self-transfers leave only the fee row in transfers[]; no net principal
|
|
67
|
+
// movement. Helper should report 0 (gross transfer is 0), not -fee.
|
|
68
|
+
const metadata = {
|
|
69
|
+
transfers: [
|
|
70
|
+
{ account: USER, amount: -500_000 }, // only the fee debit
|
|
71
|
+
{ account: '0.0.98', amount: 500_000 },
|
|
72
|
+
],
|
|
73
|
+
charged_tx_fee: 500_000,
|
|
74
|
+
};
|
|
75
|
+
expect(extractUserAmountForHedera(metadata, USER)).toBe(0);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
describe('edge cases', () => {
|
|
80
|
+
it('handles undefined metadata', () => {
|
|
81
|
+
expect(extractUserAmountForHedera(undefined, USER)).toBeUndefined();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('handles undefined transfers', () => {
|
|
85
|
+
expect(extractUserAmountForHedera({ charged_tx_fee: 500_000 }, USER)).toBeUndefined();
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('handles missing charged_tx_fee for sender (treats as 0)', () => {
|
|
89
|
+
const metadata = {
|
|
90
|
+
transfers: [
|
|
91
|
+
{ account: USER, amount: -100_000_000 },
|
|
92
|
+
{ account: PEER, amount: 100_000_000 },
|
|
93
|
+
],
|
|
94
|
+
};
|
|
95
|
+
// No fee field → falls back to 0, so headline equals raw user delta
|
|
96
|
+
const result = extractUserAmountForHedera(metadata, USER);
|
|
97
|
+
expect(result).toBe(-100_000_000);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('sums multiple user entries (defensive shape handling)', () => {
|
|
101
|
+
// Hypothetical shape where mirror returns user as two rows: transfer
|
|
102
|
+
// + separate fee. Reducer should still produce the gross transfer
|
|
103
|
+
// once the fee is added back.
|
|
104
|
+
const metadata = {
|
|
105
|
+
transfers: [
|
|
106
|
+
{ account: USER, amount: -100_000_000 }, // pure transfer
|
|
107
|
+
{ account: USER, amount: -500_000 }, // fee share
|
|
108
|
+
{ account: PEER, amount: 100_000_000 },
|
|
109
|
+
{ account: FEE_COLLECTOR, amount: 500_000 },
|
|
110
|
+
],
|
|
111
|
+
charged_tx_fee: 500_000,
|
|
112
|
+
};
|
|
113
|
+
const result = extractUserAmountForHedera(metadata, USER);
|
|
114
|
+
// userTotal = -100_500_000; userPaidFee = +500_000 → -100_000_000
|
|
115
|
+
expect(result).toBe(-100_000_000);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
describe('extractUserAmountForXrpl', () => {
|
|
121
|
+
const USER = 'rUSER';
|
|
122
|
+
const PEER = 'rPEER';
|
|
123
|
+
|
|
124
|
+
describe('amountDrops (XRPL sign + non-payment)', () => {
|
|
125
|
+
it('undefined when tx has no amount', () => {
|
|
126
|
+
const tx = { ledgerId: 'xrpl', type: 'TrustSet', from: USER };
|
|
127
|
+
expect(extractUserAmountForXrpl(tx, USER)).toBeUndefined();
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('outgoing payment is negative', () => {
|
|
131
|
+
const tx = { ledgerId: 'xrpl', type: 'Payment', amount: 1_000_000, from: USER, to: PEER };
|
|
132
|
+
expect(extractUserAmountForXrpl(tx, USER)).toBe(-1_000_000);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it('incoming payment is positive', () => {
|
|
136
|
+
const tx = { ledgerId: 'xrpl', type: 'Payment', amount: 1_000_000, from: PEER, to: USER };
|
|
137
|
+
expect(extractUserAmountForXrpl(tx, USER)).toBe(1_000_000);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it('does not fabricate a sign when from is missing', () => {
|
|
141
|
+
const tx = { ledgerId: 'xrpl', type: 'AccountSet', from: undefined };
|
|
142
|
+
expect(extractUserAmountForXrpl(tx, USER)).toBeUndefined();
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
describe('edge cases', () => {
|
|
147
|
+
it('handles undefined tx', () => {
|
|
148
|
+
expect(extractUserAmountForXrpl(undefined, USER)).toBeUndefined();
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it('handles null amount', () => {
|
|
152
|
+
const tx = { ledgerId: 'xrpl', type: 'TrustSet', amount: null, from: USER };
|
|
153
|
+
expect(extractUserAmountForXrpl(tx, USER)).toBeUndefined();
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it('handles string amount (XRPL adapter shape)', () => {
|
|
157
|
+
const tx = { ledgerId: 'xrpl', type: 'Payment', amount: '1000000', from: USER, to: PEER };
|
|
158
|
+
expect(extractUserAmountForXrpl(tx, USER)).toBe(-1_000_000);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it('user not a direct participant: positive raw, no sign', () => {
|
|
162
|
+
// Offer-fulfillment style: amount present but the user is neither
|
|
163
|
+
// payer nor receiver on this leg.
|
|
164
|
+
const tx = { ledgerId: 'xrpl', type: 'Payment', amount: 500_000, from: PEER, to: 'rOTHER' };
|
|
165
|
+
expect(extractUserAmountForXrpl(tx, USER)).toBe(500_000);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it('returns undefined for IOU object amount (XRPL trust-line payments)', () => {
|
|
169
|
+
const tx = {
|
|
170
|
+
ledgerId: 'xrpl',
|
|
171
|
+
type: 'Payment',
|
|
172
|
+
amount: { currency: 'USD', value: '100', issuer: 'rISSUER' },
|
|
173
|
+
from: 'rUSER',
|
|
174
|
+
to: 'rPEER',
|
|
175
|
+
} as any;
|
|
176
|
+
expect(extractUserAmountForXrpl(tx, 'rUSER')).toBeUndefined();
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it('returns undefined for non-numeric string amount', () => {
|
|
180
|
+
const tx = { ledgerId: 'xrpl', amount: 'abc', from: 'rUSER', to: 'rPEER' };
|
|
181
|
+
expect(extractUserAmountForXrpl(tx, 'rUSER')).toBeUndefined();
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
});
|
|
@@ -0,0 +1,124 @@
|
|
|
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
|
+
/**
|
|
12
|
+
* Pure helpers for deriving the user-facing headline amount from a raw
|
|
13
|
+
* ledger transaction.
|
|
14
|
+
*
|
|
15
|
+
* Extracted from `WalletStateService.enrichTransactionForUser` so we can
|
|
16
|
+
* unit-test the arithmetic without standing up the full DI graph (the
|
|
17
|
+
* wallet-app `pnpm test` runner is a no-op due to an Angular 20 / Karma
|
|
18
|
+
* bug — see project memory `project_wallet_vitest_infra.md`).
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/** Mirror-node transaction slice the Hedera headline derivation reads. */
|
|
22
|
+
export interface HederaTransferMetadata {
|
|
23
|
+
transfers?: Array<{ account: string; amount: number }>;
|
|
24
|
+
charged_tx_fee?: number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Compute the gross HBAR transfer attributable to `userAddress` for a Hedera
|
|
29
|
+
* mirror-node transaction.
|
|
30
|
+
*
|
|
31
|
+
* Mirror node shape: each `transfers[]` entry is one signed delta. The user
|
|
32
|
+
* may appear:
|
|
33
|
+
* - As a SINGLE entry whose amount already includes their fee share
|
|
34
|
+
* subtracted (the common case — `{account: USER, amount: -100_500_000}`
|
|
35
|
+
* for "sent 1 ℏ + paid 0.005 ℏ fee").
|
|
36
|
+
* - As MULTIPLE entries (rare — e.g. one transfer + a separate fee row).
|
|
37
|
+
*
|
|
38
|
+
* In both cases `userTotal` reduces to the user's net delta. Sender status
|
|
39
|
+
* is derived from `userTotal < 0` (net outflow). Mirror nodes net the
|
|
40
|
+
* charged fee into the sender's row, so we add `charged_tx_fee` back to
|
|
41
|
+
* recover the gross transfer; receivers (net inflow) never had a fee netted
|
|
42
|
+
* in, so no add-back. Deriving sender from the data — rather than from
|
|
43
|
+
* `tx.from === userAddress` passed by the caller — avoids a scheduled-tx
|
|
44
|
+
* footgun where `tx.from` is not the actual fee payer.
|
|
45
|
+
*
|
|
46
|
+
* Returns `undefined` when the user does not appear in `transfers` at all
|
|
47
|
+
* (e.g. an `ACCOUNTUPDATE` or other non-payment transaction). The caller
|
|
48
|
+
* should render that as "—" rather than "0 ℏ".
|
|
49
|
+
*
|
|
50
|
+
* @param metadata transaction metadata as captured from the mirror node
|
|
51
|
+
* @param userAddress the wallet account being enriched (e.g. `0.0.12345`)
|
|
52
|
+
* @returns gross transfer in tinybars, or `undefined` if no user entry
|
|
53
|
+
*/
|
|
54
|
+
export function extractUserAmountForHedera(
|
|
55
|
+
metadata: HederaTransferMetadata | undefined,
|
|
56
|
+
userAddress: string,
|
|
57
|
+
): number | undefined {
|
|
58
|
+
const entries = (metadata?.transfers ?? []).filter((t) => t.account === userAddress);
|
|
59
|
+
if (entries.length === 0) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
const userTotal = entries.reduce((sum, t) => sum + t.amount, 0);
|
|
63
|
+
// Sender = net outflow. Mirror nets the fee into the sender's row, so we
|
|
64
|
+
// add it back to recover the gross transfer. Receivers (net inflow) never
|
|
65
|
+
// had a fee netted in, so no add-back.
|
|
66
|
+
const userIsSender = userTotal < 0;
|
|
67
|
+
const userPaidFee = userIsSender ? Number(metadata?.charged_tx_fee) || 0 : 0;
|
|
68
|
+
return userTotal + userPaidFee;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** XRPL adapter transaction slice the XRP headline derivation reads. */
|
|
72
|
+
export interface XrplAmountTx {
|
|
73
|
+
amount?: number | string | null;
|
|
74
|
+
from?: string;
|
|
75
|
+
to?: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Compute the signed XRP drops headline for an XRPL transaction from the
|
|
80
|
+
* user's perspective.
|
|
81
|
+
*
|
|
82
|
+
* XRPL `tx.amount` is only populated for `Payment` and a few other transfer
|
|
83
|
+
* types. Non-payment transactions (`TrustSet`, `AccountSet`, `OfferCreate`,
|
|
84
|
+
* …) leave it absent — in that case there is no amount to display, and the
|
|
85
|
+
* caller should render the row without one. We return `undefined` instead
|
|
86
|
+
* of `0` so the UI can distinguish "zero transfer" from "no transfer".
|
|
87
|
+
*
|
|
88
|
+
* Returns `undefined` for non-finite amounts (e.g. XRPL IOU object shape
|
|
89
|
+
* `{currency, value, issuer}` or malformed strings), so callers don't have
|
|
90
|
+
* to pre-filter. Issued-currency payments are not XRP transfers and have no
|
|
91
|
+
* drops-denominated headline to display.
|
|
92
|
+
*
|
|
93
|
+
* Sign convention:
|
|
94
|
+
* - `tx.from === userAddress` → negative (outgoing)
|
|
95
|
+
* - `tx.to === userAddress` → positive (incoming)
|
|
96
|
+
* - neither matches → positive raw value (defensive — e.g. offer
|
|
97
|
+
* fulfillments where the user is not a direct participant on the
|
|
98
|
+
* payment leg).
|
|
99
|
+
*
|
|
100
|
+
* @param tx transaction fragment from the XRPL adapter
|
|
101
|
+
* @param userAddress the wallet account being enriched (r-address)
|
|
102
|
+
* @returns signed drops, or `undefined` if the tx has no amount
|
|
103
|
+
*/
|
|
104
|
+
export function extractUserAmountForXrpl(
|
|
105
|
+
tx: XrplAmountTx | undefined,
|
|
106
|
+
userAddress: string,
|
|
107
|
+
): number | undefined {
|
|
108
|
+
if (!tx || tx.amount === undefined || tx.amount === null) {
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
const rawAmount = Number(tx.amount);
|
|
112
|
+
if (!Number.isFinite(rawAmount)) {
|
|
113
|
+
// IOU object, malformed string, or other unrepresentable input.
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
116
|
+
if (tx.from === userAddress) {
|
|
117
|
+
return -rawAmount;
|
|
118
|
+
}
|
|
119
|
+
if (tx.to === userAddress) {
|
|
120
|
+
return rawAmount;
|
|
121
|
+
}
|
|
122
|
+
// Not a direct participant — surface the raw value without a sign hint.
|
|
123
|
+
return rawAmount;
|
|
124
|
+
}
|
|
@@ -96,6 +96,7 @@ export type TxKind =
|
|
|
96
96
|
| 'hedera.schedule.create'
|
|
97
97
|
| 'hedera.schedule.sign'
|
|
98
98
|
| 'hedera.schedule.delete'
|
|
99
|
+
| 'hedera.allowance.approve'
|
|
99
100
|
| 'hedera.batch'
|
|
100
101
|
| 'hedera.message.sign'
|
|
101
102
|
| 'hedera.file.create'
|
|
@@ -388,6 +389,13 @@ export interface HederaTransactionData extends BaseTransactionData {
|
|
|
388
389
|
*/
|
|
389
390
|
batchNetImpact?: BatchNetImpact;
|
|
390
391
|
|
|
392
|
+
/**
|
|
393
|
+
* Spending approvals decoded from an `AccountAllowanceApproveTransaction`,
|
|
394
|
+
* one entry per approval in its `hbarApprovals`, `tokenApprovals` and
|
|
395
|
+
* `tokenNftApprovals` lists. Only present on that transaction type.
|
|
396
|
+
*/
|
|
397
|
+
allowances?: HederaAllowanceApproval[];
|
|
398
|
+
|
|
391
399
|
/**
|
|
392
400
|
* Structured diff for `AccountUpdate` transactions — only present when
|
|
393
401
|
* `type === 'AccountUpdate'`.
|
|
@@ -516,6 +524,37 @@ export interface ScheduleCreateEnvelope {
|
|
|
516
524
|
* modal can render a "could not verify schedule state" affordance
|
|
517
525
|
* instead of silently showing stale data.
|
|
518
526
|
*/
|
|
527
|
+
/**
|
|
528
|
+
* The one summary for any transaction shown to the user: a multisig proposal,
|
|
529
|
+
* a dApp request, a widget batch, a send review or a history record. It is
|
|
530
|
+
* built once and read by the hub/sheet cards, the drawer header and the
|
|
531
|
+
* approval review, so the title, the figure and the rows can never disagree.
|
|
532
|
+
* Amounts arrive formatted by the canonical formatter with a "." decimal mark.
|
|
533
|
+
*/
|
|
534
|
+
export interface TransactionSummaryCard {
|
|
535
|
+
/** Mapper that produced the card, e.g. 'hbar-transfer', 'token-transfer', 'xrp-payment', 'generic'. */
|
|
536
|
+
kind: string;
|
|
537
|
+
/** Translated verb ("Send"). */
|
|
538
|
+
verb: string;
|
|
539
|
+
/** What the verb applies to ("25 ℏ", "12.5 DCT · 3 recipients", "DCT"). */
|
|
540
|
+
object: string;
|
|
541
|
+
/** `verb + ' ' + object`, the card title. */
|
|
542
|
+
title: string;
|
|
543
|
+
/** Primary figure when there is one ("25 ℏ"); absent for associations, policies, schedules. */
|
|
544
|
+
figure?: string;
|
|
545
|
+
/** Single destination when there is exactly one. */
|
|
546
|
+
to?: string;
|
|
547
|
+
/** Network fee, formatted. */
|
|
548
|
+
fee?: string;
|
|
549
|
+
/** Up to five key-value rows for the type. */
|
|
550
|
+
rows: Array<{ label: string; value: string }>;
|
|
551
|
+
/** One line per recipient / token / NFT when the transfer has several legs. */
|
|
552
|
+
legs?: Array<{ to: string; amount: string; symbol?: string }>;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
*
|
|
557
|
+
*/
|
|
519
558
|
export interface ScheduleSignPayload {
|
|
520
559
|
/** On-chain schedule ID being signed (e.g., `"0.0.226412"`). */
|
|
521
560
|
scheduleId: string;
|
|
@@ -643,6 +682,52 @@ export interface TxShapeDetection {
|
|
|
643
682
|
parsedKind?: 'hedera.transaction' | 'xrpl.transaction';
|
|
644
683
|
}
|
|
645
684
|
|
|
685
|
+
/**
|
|
686
|
+
* One spending approval granted by an `AccountAllowanceApproveTransaction`.
|
|
687
|
+
*
|
|
688
|
+
* Every field except the token `decimals` / `symbol` / `name` comes from the
|
|
689
|
+
* transaction bytes. Those three are mirror-node metadata, filled in by the
|
|
690
|
+
* wallet's approval enrichment when available and absent otherwise, so the
|
|
691
|
+
* UI must not scale a token `amount` without `decimals`.
|
|
692
|
+
*/
|
|
693
|
+
export type HederaAllowanceApproval =
|
|
694
|
+
| {
|
|
695
|
+
kind: 'hbar';
|
|
696
|
+
/** Account the allowance draws from, when the approval names one. */
|
|
697
|
+
ownerAccountId?: string;
|
|
698
|
+
spenderAccountId: string;
|
|
699
|
+
/** Allowance cap in tinybars, as a decimal string. */
|
|
700
|
+
amount: string;
|
|
701
|
+
/** The cap is the maximal value, i.e. no effective limit. */
|
|
702
|
+
unlimited: boolean;
|
|
703
|
+
}
|
|
704
|
+
| {
|
|
705
|
+
kind: 'token';
|
|
706
|
+
ownerAccountId?: string;
|
|
707
|
+
spenderAccountId: string;
|
|
708
|
+
tokenId: string;
|
|
709
|
+
/** Allowance cap in the token's raw base units, as a decimal string. */
|
|
710
|
+
amount: string;
|
|
711
|
+
unlimited: boolean;
|
|
712
|
+
decimals?: number;
|
|
713
|
+
symbol?: string;
|
|
714
|
+
name?: string;
|
|
715
|
+
}
|
|
716
|
+
| {
|
|
717
|
+
kind: 'nft';
|
|
718
|
+
ownerAccountId?: string;
|
|
719
|
+
spenderAccountId: string;
|
|
720
|
+
tokenId: string;
|
|
721
|
+
/** Specific serials approved. Empty when `allSerials` is true. */
|
|
722
|
+
serials: number[];
|
|
723
|
+
/** Approval covers every serial of the collection, including future ones. */
|
|
724
|
+
allSerials: boolean;
|
|
725
|
+
/** Spender already approved for all serials who is delegating this approval. */
|
|
726
|
+
delegatingSpenderAccountId?: string;
|
|
727
|
+
symbol?: string;
|
|
728
|
+
name?: string;
|
|
729
|
+
};
|
|
730
|
+
|
|
646
731
|
/**
|
|
647
732
|
* @description Aggregated net impact across all inner transactions in
|
|
648
733
|
* a `BatchTransaction`. Computed from the signer's perspective —
|
|
@@ -1107,8 +1192,26 @@ export interface TransactionApprovalContext {
|
|
|
1107
1192
|
need: number;
|
|
1108
1193
|
members: string[];
|
|
1109
1194
|
};
|
|
1195
|
+
/** Signer identities and collected signatures for the approval review. */
|
|
1196
|
+
signers?: Array<{
|
|
1197
|
+
address: string;
|
|
1198
|
+
label?: string;
|
|
1199
|
+
signed: boolean;
|
|
1200
|
+
isSelf: boolean;
|
|
1201
|
+
required: boolean;
|
|
1202
|
+
/** This signer proposed the transaction. */
|
|
1203
|
+
proposer?: boolean;
|
|
1204
|
+
}>;
|
|
1205
|
+
/** Absolute proposal expiry, in milliseconds since the Unix epoch. */
|
|
1206
|
+
expiresAt?: number;
|
|
1110
1207
|
/** Who initiated this proposal */
|
|
1111
1208
|
initiator: string;
|
|
1209
|
+
/** Display label of the initiator (a signer label), when known. */
|
|
1210
|
+
initiatorLabel?: string;
|
|
1211
|
+
/** Proposal summary shown as the review title ("Send 25 ℏ"). */
|
|
1212
|
+
title?: string;
|
|
1213
|
+
/** The one summary contract every surface reads (hub card, header, hero, rows). */
|
|
1214
|
+
summary?: TransactionSummaryCard;
|
|
1112
1215
|
};
|
|
1113
1216
|
/** Inner transactions for batch transactions */
|
|
1114
1217
|
innerTransactions?: Array<{
|
package/src/widget.types.ts
CHANGED
|
@@ -228,6 +228,16 @@ export interface WidgetManifestV2 extends WidgetManifest {
|
|
|
228
228
|
*/
|
|
229
229
|
experienceType?: ExperienceType;
|
|
230
230
|
|
|
231
|
+
/**
|
|
232
|
+
* Who draws the fullscreen top bar. `'host'` (default): the host wraps the
|
|
233
|
+
* app with its generic glass-island header (app name + exit). `'app'`: the
|
|
234
|
+
* app renders its OWN branded navbar inside its content (e.g. SilkDex's
|
|
235
|
+
* navbar with its page buttons, matching its standalone shell), and the host
|
|
236
|
+
* PROJECTS its controls (account switch + exit) into that navbar's end slot
|
|
237
|
+
* — exit stays host-owned either way.
|
|
238
|
+
*/
|
|
239
|
+
shellNavbar?: 'host' | 'app';
|
|
240
|
+
|
|
231
241
|
/**
|
|
232
242
|
* Execution context - where/how the experience runs.
|
|
233
243
|
* If not specified, will be inferred from experienceType using inferExecutionContext().
|
|
@@ -361,8 +371,16 @@ export function normalizeManifestToV2(manifest: WidgetManifest): WidgetManifestV
|
|
|
361
371
|
export interface HsuiteWidget {
|
|
362
372
|
/** Widget metadata and configuration (supports V2 fields like experienceType) */
|
|
363
373
|
manifest: WidgetManifestV2;
|
|
364
|
-
/**
|
|
365
|
-
|
|
374
|
+
/**
|
|
375
|
+
* Angular component class, when eagerly bundled.
|
|
376
|
+
* Exactly one of `component` / `loadComponent` must be set.
|
|
377
|
+
*/
|
|
378
|
+
component?: unknown; // Type<unknown> from @angular/core, but we don't import Angular here
|
|
379
|
+
/**
|
|
380
|
+
* Lazy component loader. Preferred: the component code-splits into its
|
|
381
|
+
* own chunk and only downloads when the widget is actually mounted.
|
|
382
|
+
*/
|
|
383
|
+
loadComponent?: () => Promise<unknown>;
|
|
366
384
|
}
|
|
367
385
|
|
|
368
386
|
/**
|