@ledgerhq/coin-hedera 2.1.0 → 2.2.0-nightly.20260901020738
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/CHANGELOG.md +30 -0
- package/jest.config.js +6 -1
- package/lib/api/index.d.ts +84 -4
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +18 -18
- package/lib/api/index.js.map +1 -1
- package/lib/signer/frameworkSigner.d.ts +12 -0
- package/lib/signer/frameworkSigner.d.ts.map +1 -0
- package/lib/signer/frameworkSigner.js +22 -0
- package/lib/signer/frameworkSigner.js.map +1 -0
- package/lib/signer/index.d.ts +1 -0
- package/lib/signer/index.d.ts.map +1 -1
- package/lib/signer/index.js +3 -0
- package/lib/signer/index.js.map +1 -1
- package/lib-es/api/index.d.ts +84 -4
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.js +18 -18
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/signer/frameworkSigner.d.ts +12 -0
- package/lib-es/signer/frameworkSigner.d.ts.map +1 -0
- package/lib-es/signer/frameworkSigner.js +19 -0
- package/lib-es/signer/frameworkSigner.js.map +1 -0
- package/lib-es/signer/index.d.ts +1 -0
- package/lib-es/signer/index.d.ts.map +1 -1
- package/lib-es/signer/index.js +1 -0
- package/lib-es/signer/index.js.map +1 -1
- package/package.json +11 -10
- package/src/api/index.test.ts +36 -55
- package/src/api/index.ts +25 -41
- package/src/signer/frameworkSigner.test.ts +102 -0
- package/src/signer/frameworkSigner.ts +29 -0
- package/src/signer/index.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @ledgerhq/coin-hedera
|
|
2
2
|
|
|
3
|
+
## 2.2.0-nightly.20260901020738
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#21106](https://github.com/LedgerHQ/ledger-live/pull/21106) [`9f37206`](https://github.com/LedgerHQ/ledger-live/commit/9f372065ab564bc75960e4d02b8a9cb4e7ac21b0) Thanks [@mdomanski-ext-ledger](https://github.com/mdomanski-ext-ledger)! - feat: hedera framework signer
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#21168](https://github.com/LedgerHQ/ledger-live/pull/21168) [`1e438d1`](https://github.com/LedgerHQ/ledger-live/commit/1e438d109bf2644b1d25321d3bf9221d15873cfb) Thanks [@cted-ledger](https://github.com/cted-ledger)! - Adopt the coin-module authoring type, dropping the hand-written "not supported" stubs.
|
|
12
|
+
|
|
13
|
+
`createApi` now returns its object with `satisfies CoinModuleImpl<HederaCoinConfig, HederaMemo, HederaTxData>` — which keeps the precise shape, so a caller sees exactly which methods exist — and omits the five capabilities the module has none of, `validateIntent`, `getNextSequence`, `craftRawTransaction`, `call` and `register`, instead of giving each a `throw new Error("… is not supported")`.
|
|
14
|
+
|
|
15
|
+
Why each is absent is recorded above the factory rather than lost with the stub it used to sit on. Two are worth spelling out: intent validation still lives in the account bridge's `getTransactionStatus`, so the api path has none of its own yet, and there is no sequence to hand out because a Hedera transaction is identified by its payer plus a valid-start timestamp rather than by a per-account nonce. Staking, by contrast, is fully covered and untouched — Hedera proxy-stakes to a node id, so `getStakes`, `getRewards` and `getValidators` are all real implementations. So are the two methods that throw for a reason rather than as a placeholder: `craftTransaction` rejects `useAllAmount` and `listOperations` rejects a non-zero `minHeight`, both argument validations on working code.
|
|
16
|
+
|
|
17
|
+
The return type also loses its `& BridgeApi` half. Every member of `BridgeApi` is optional and this factory supplied none of them, so the intersection only ever promised hooks that were not there; nothing consumes `createApi` yet, so no call site relied on it.
|
|
18
|
+
|
|
19
|
+
The parameters an implementation declares now matter: `satisfies` infers the signature from the function itself, so the trailing `options` argument of `combine`, `craftTransaction`, `getValidators` and `getRewards` carries an explicit `?` rather than relying on the contract to make it optional — the integration suite already calls `getValidators(context)` and `getRewards(context, address)` without it.
|
|
20
|
+
|
|
21
|
+
Consumers see no change. They reach the module through a resolver that applies the framework's `withDefaults`, which supplies every omitted capability, so the same call still raises the same `"<method> is not supported"` error — and `supports(method)` now reports which capabilities are real.
|
|
22
|
+
|
|
23
|
+
The authored type also keeps the contract's trailing optional parameters, or a caller reaching the module through it could no longer pass them: `broadcast`, `estimateFees`, `getStakes` accept and ignore theirs. TypeScript does not hold a function's shorter parameter list against a target declaring more, so the `satisfies` passed either way and nothing flagged the narrowing.
|
|
24
|
+
|
|
25
|
+
The api test asserts the whole capability surface with the framework's `capabilityReport()` rather than one test per unimplemented capability: one expectation covers that each is absent, that reaching it raises `"<name> is not supported"`, and that `supports()` agrees. Being an exact comparison it is exhaustive, so implementing or dropping a capability changes the list instead of leaving a test that passes while covering less.
|
|
26
|
+
|
|
27
|
+
- Updated dependencies [[`27388a8`](https://github.com/LedgerHQ/ledger-live/commit/27388a894eaac67b8e162a60f6d3368aad0a8682), [`e21305a`](https://github.com/LedgerHQ/ledger-live/commit/e21305abce18f0a9408bf6c0e2bb47d5c992e06a)]:
|
|
28
|
+
- @ledgerhq/types-live@6.122.0-nightly.20260901020738
|
|
29
|
+
- @ledgerhq/ledger-wallet-framework@3.2.0-nightly.20260901020738
|
|
30
|
+
- @ledgerhq/live-env@3.2.0-nightly.20260901020738
|
|
31
|
+
- @ledgerhq/live-countervalues@0.24.5-nightly.20260901020738
|
|
32
|
+
|
|
3
33
|
## 2.1.0
|
|
4
34
|
|
|
5
35
|
### Minor Changes
|
package/jest.config.js
CHANGED
|
@@ -24,6 +24,11 @@ module.exports = {
|
|
|
24
24
|
"default",
|
|
25
25
|
...(process.env.CI ? ["github-actions"] : []),
|
|
26
26
|
["jest-sonar", { outputName: "sonar-executionTests-report.xml", reportedFilePath: "absolute" }],
|
|
27
|
+
"@ledgerhq/test-quarantine/jest",
|
|
28
|
+
],
|
|
29
|
+
setupFilesAfterEnv: [
|
|
30
|
+
"@ledgerhq/wallet-framework-test-setup",
|
|
31
|
+
"@ledgerhq/disable-network-setup",
|
|
32
|
+
"@ledgerhq/test-quarantine/jest-retries",
|
|
27
33
|
],
|
|
28
|
-
setupFilesAfterEnv: ["@ledgerhq/wallet-framework-test-setup", "@ledgerhq/disable-network-setup"],
|
|
29
34
|
};
|
package/lib/api/index.d.ts
CHANGED
|
@@ -1,5 +1,85 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import
|
|
3
|
-
import type { HederaMemo, HederaTxData, HederaCoinConfig } from "../types";
|
|
4
|
-
export declare function createApi(currencyId: string):
|
|
1
|
+
import type { BalanceOptions, ListOperationsOptions } from "@ledgerhq/coin-module-framework/api/index";
|
|
2
|
+
import BigNumber from "bignumber.js";
|
|
3
|
+
import type { HederaMemo, HederaTxData, HederaCoinConfig, HederaContext } from "../types";
|
|
4
|
+
export declare function createApi(currencyId: string): {
|
|
5
|
+
broadcast: (context: HederaContext, tx: string, _options?: {
|
|
6
|
+
broadcastConfig?: import("@ledgerhq/coin-module-framework/lib/api/types").BroadcastConfig;
|
|
7
|
+
} | undefined) => Promise<string>;
|
|
8
|
+
combine: (_context: import("@ledgerhq/coin-module-framework/lib/config").Context<HederaCoinConfig>, tx: string, signature: string[], options?: {
|
|
9
|
+
pubkey?: string;
|
|
10
|
+
} | undefined) => string;
|
|
11
|
+
craftTransaction: (context: HederaContext, txIntent: import("@ledgerhq/coin-module-framework/lib/api/types").TransactionIntent<HederaMemo, HederaTxData>, options?: {
|
|
12
|
+
customFees?: import("@ledgerhq/coin-module-framework/lib/api/types").FeeEstimation;
|
|
13
|
+
} | undefined) => Promise<{
|
|
14
|
+
transaction: string;
|
|
15
|
+
}>;
|
|
16
|
+
estimateFees: (context: HederaContext, txIntent: import("@ledgerhq/coin-module-framework/lib/api/types").TransactionIntent<HederaMemo, HederaTxData>, _options?: {
|
|
17
|
+
customFeesParameters?: import("@ledgerhq/coin-module-framework/lib/api/types").FeeEstimation['parameters'];
|
|
18
|
+
feeOption?: import("@ledgerhq/coin-module-framework/lib/api/types").EstimateFeesOptions;
|
|
19
|
+
} | undefined) => Promise<{
|
|
20
|
+
value: bigint;
|
|
21
|
+
}>;
|
|
22
|
+
getBalance: (context: HederaContext, address: string, options?: BalanceOptions) => Promise<import("@ledgerhq/coin-module-framework/lib/api/types").Balance[]>;
|
|
23
|
+
getBlock: (context: HederaContext, height: number) => Promise<import("@ledgerhq/coin-module-framework/lib/api/types").Block>;
|
|
24
|
+
getBlockInfo: (_context: HederaContext, height: number) => Promise<import("@ledgerhq/coin-module-framework/lib/api/types").BlockInfo>;
|
|
25
|
+
lastBlock: (context: HederaContext) => Promise<import("@ledgerhq/coin-module-framework/lib/api/types").BlockInfo>;
|
|
26
|
+
listOperations: (context: HederaContext, address: string, { cursor, limit, order, minHeight }: ListOperationsOptions) => Promise<{
|
|
27
|
+
items: {
|
|
28
|
+
id: string;
|
|
29
|
+
type: import("@ledgerhq/types-live").OperationType;
|
|
30
|
+
senders: string[];
|
|
31
|
+
recipients: string[];
|
|
32
|
+
value: bigint;
|
|
33
|
+
asset: {
|
|
34
|
+
type: string;
|
|
35
|
+
assetReference: string;
|
|
36
|
+
assetOwner: string;
|
|
37
|
+
} | {
|
|
38
|
+
assetReference?: never;
|
|
39
|
+
assetOwner?: never;
|
|
40
|
+
type: string;
|
|
41
|
+
};
|
|
42
|
+
details: {
|
|
43
|
+
consensusTimestamp?: string;
|
|
44
|
+
transactionId?: string;
|
|
45
|
+
feesPayer?: string;
|
|
46
|
+
associatedTokenId?: string;
|
|
47
|
+
pagingToken?: string;
|
|
48
|
+
gasConsumed?: number;
|
|
49
|
+
gasLimit?: number;
|
|
50
|
+
gasUsed?: number;
|
|
51
|
+
memo?: string | null;
|
|
52
|
+
targetStakingNodeId?: number | null;
|
|
53
|
+
previousStakingNodeId?: number | null;
|
|
54
|
+
stakedAmount?: bigint | BigNumber;
|
|
55
|
+
ledgerOpType: import("@ledgerhq/types-live").OperationType;
|
|
56
|
+
assetAmount?: string;
|
|
57
|
+
};
|
|
58
|
+
tx: {
|
|
59
|
+
hash: string;
|
|
60
|
+
fees: bigint;
|
|
61
|
+
feesPayer?: string;
|
|
62
|
+
date: Date;
|
|
63
|
+
block: {
|
|
64
|
+
height: number;
|
|
65
|
+
hash: string;
|
|
66
|
+
time: Date;
|
|
67
|
+
};
|
|
68
|
+
failed: boolean;
|
|
69
|
+
};
|
|
70
|
+
}[];
|
|
71
|
+
next: string | undefined;
|
|
72
|
+
}>;
|
|
73
|
+
getValidators: (context: HederaContext, options?: {
|
|
74
|
+
cursor?: import("@ledgerhq/coin-module-framework/lib/api/types").Cursor;
|
|
75
|
+
} | undefined) => Promise<import("@ledgerhq/coin-module-framework/lib/api/types").Page<import("@ledgerhq/coin-module-framework/lib/api/types").Validator>>;
|
|
76
|
+
getStakes: (context: HederaContext, address: string, _options?: {
|
|
77
|
+
cursor?: import("@ledgerhq/coin-module-framework/lib/api/types").Cursor;
|
|
78
|
+
} | undefined) => Promise<import("@ledgerhq/coin-module-framework/lib/api/types").Page<import("@ledgerhq/coin-module-framework/lib/api/types").Stake>>;
|
|
79
|
+
getRewards: (context: HederaContext, address: string, options?: {
|
|
80
|
+
cursor?: import("@ledgerhq/coin-module-framework/lib/api/types").Cursor;
|
|
81
|
+
} | undefined) => Promise<import("@ledgerhq/coin-module-framework/lib/api/types").Page<import("@ledgerhq/coin-module-framework/lib/api/types").Reward>>;
|
|
82
|
+
validateAddress: (_context: import("@ledgerhq/coin-module-framework/lib/config").Context<HederaCoinConfig>, address: string, parameters: Partial<import("@ledgerhq/coin-module-framework/lib/api/types").AddressValidationCurrencyParameters>) => Promise<boolean>;
|
|
83
|
+
craftTransactionData: (_context: import("@ledgerhq/coin-module-framework/lib/config").Context<HederaCoinConfig>, intent: import("@ledgerhq/coin-module-framework/lib/api/types").TransactionIntent<HederaMemo, HederaTxData>) => import("@ledgerhq/coin-module-framework/lib/api/types").TxDataNotSupported;
|
|
84
|
+
};
|
|
5
85
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/api/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,cAAc,EACd,qBAAqB,EAEtB,MAAM,2CAA2C,CAAC;AAEnD,OAAO,SAAS,MAAM,cAAc,CAAC;AA8BrC,OAAO,KAAK,EAEV,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACd,MAAM,UAAU,CAAC;AAqBlB,wBAAgB,SAAS,CAAC,UAAU,EAAE,MAAM;yBAEb,aAAa;;;;;;gCAUN,aAAa;;;;;4BAajB,aAAa;;;;;;0BAiBrB,aAAa,WAAW,MAAM,YAAY,cAAc;wBAKpD,aAAa;6BAId,aAAa;yBACX,aAAa;8BAK7B,aAAa,WACb,MAAM,uCACsB,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBA+FlD,MAAM;oBACN,IAAI;oBACJ,IAAI;;;;;;;6BAYiB,aAAa;;;yBAIjB,aAAa;;;0BAIZ,aAAa;;;;;EAO5C"}
|
package/lib/api/index.js
CHANGED
|
@@ -18,9 +18,24 @@ const utils_2 = require("../network/utils");
|
|
|
18
18
|
// logger) and passes it to each method. Each method resolves the coin configuration from the context
|
|
19
19
|
// via `context.config()` and threads it explicitly into the logic layer rather than seeding the
|
|
20
20
|
// module-level singleton (ADR-019).
|
|
21
|
+
//
|
|
22
|
+
// Checked against CoinModuleImpl with `satisfies` rather than annotated as it, so the precise shape
|
|
23
|
+
// survives and a caller sees exactly which methods exist. Staking is fully covered here — Hedera
|
|
24
|
+
// proxy-stakes to a node, so `getStakes`, `getRewards` and `getValidators` are all real.
|
|
25
|
+
//
|
|
26
|
+
// Omitted rather than stubbed, and why:
|
|
27
|
+
// - `validateIntent` — intent validation still lives in the account bridge's
|
|
28
|
+
// `getTransactionStatus`; the api path has none of its own yet.
|
|
29
|
+
// - `getNextSequence` — no per-account nonce: a Hedera transaction is identified by its
|
|
30
|
+
// payer plus a valid-start timestamp (`createTransactionId`).
|
|
31
|
+
// - `craftRawTransaction` — the module accepts no externally-built transaction.
|
|
32
|
+
// - `call` — no read-only contract-call escape hatch is exposed, even though the
|
|
33
|
+
// device app parses contract calls.
|
|
34
|
+
// - `register` — no enrollment step.
|
|
35
|
+
// The consumer resolver applies `withDefaults`, which answers "not supported" for each of them.
|
|
21
36
|
function createApi(currencyId) {
|
|
22
37
|
return {
|
|
23
|
-
broadcast: async (context, tx) => {
|
|
38
|
+
broadcast: async (context, tx, _options) => {
|
|
24
39
|
const coinConfig = await context.config();
|
|
25
40
|
const response = await (0, logic_1.broadcast)({
|
|
26
41
|
configOrCurrencyId: coinConfig,
|
|
@@ -28,12 +43,6 @@ function createApi(currencyId) {
|
|
|
28
43
|
});
|
|
29
44
|
return Buffer.from(response.transactionHash).toString("base64");
|
|
30
45
|
},
|
|
31
|
-
async call() {
|
|
32
|
-
throw new Error("call is not supported");
|
|
33
|
-
},
|
|
34
|
-
async register() {
|
|
35
|
-
throw new Error("register is not supported");
|
|
36
|
-
},
|
|
37
46
|
combine: (_context, tx, signature, options) => (0, logic_1.combine)(tx, signature, options?.pubkey),
|
|
38
47
|
craftTransaction: async (context, txIntent, options) => {
|
|
39
48
|
(0, invariant_1.default)(!txIntent.useAllAmount, "useAllAmount is not supported");
|
|
@@ -47,10 +56,7 @@ function createApi(currencyId) {
|
|
|
47
56
|
transaction: serializedTx,
|
|
48
57
|
};
|
|
49
58
|
},
|
|
50
|
-
|
|
51
|
-
throw new Error("craftRawTransaction is not supported");
|
|
52
|
-
},
|
|
53
|
-
estimateFees: async (context, txIntent) => {
|
|
59
|
+
estimateFees: async (context, txIntent, _options) => {
|
|
54
60
|
let estimateFeesParams;
|
|
55
61
|
const operationType = (0, utils_1.mapIntentToSDKOperation)(txIntent);
|
|
56
62
|
if (operationType === constants_1.HEDERA_OPERATION_TYPES.ContractCall) {
|
|
@@ -177,7 +183,7 @@ function createApi(currencyId) {
|
|
|
177
183
|
const coinConfig = await context.config();
|
|
178
184
|
return (0, logic_1.getValidators)({ configOrCurrencyId: coinConfig, cursor: options?.cursor });
|
|
179
185
|
},
|
|
180
|
-
getStakes: async (context, address) => {
|
|
186
|
+
getStakes: async (context, address, _options) => {
|
|
181
187
|
const coinConfig = await context.config();
|
|
182
188
|
return (0, logic_1.getStakes)({ configOrCurrencyId: coinConfig, address });
|
|
183
189
|
},
|
|
@@ -185,12 +191,6 @@ function createApi(currencyId) {
|
|
|
185
191
|
const coinConfig = await context.config();
|
|
186
192
|
return (0, logic_1.getRewards)({ configOrCurrencyId: coinConfig, address, cursor: options?.cursor });
|
|
187
193
|
},
|
|
188
|
-
validateIntent: async (_context, _transactionIntent, _balances, _options) => {
|
|
189
|
-
throw new Error("validateIntent is not supported");
|
|
190
|
-
},
|
|
191
|
-
getNextSequence: async (_context, _address) => {
|
|
192
|
-
throw new Error("getNextSequence is not supported");
|
|
193
|
-
},
|
|
194
194
|
validateAddress: (_context, address, parameters) => (0, validateAddress_1.validateAddress)(address, parameters),
|
|
195
195
|
craftTransactionData: (_context, intent) => (0, craftTransactionData_1.craftTransactionData)(intent),
|
|
196
196
|
};
|
package/lib/api/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":";;;;;;AAAA,8GAA2G;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":";;;;;;AAAA,8GAA2G;AAO3G,qGAAkG;AAClG,gEAAqC;AACrC,0DAAkC;AAClC,+DAA4D;AAC5D,4CAIsB;AACtB,oCAakB;AAClB,0CAKwB;AACxB,wCAA2C;AAC3C,4CAA8E;AAS9E,oGAAoG;AACpG,qGAAqG;AACrG,gGAAgG;AAChG,oCAAoC;AACpC,EAAE;AACF,oGAAoG;A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E,OAAO,EAAE,QAAS,EAAE,EAAE;YAC9D,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC;YAC1C,OAAO,IAAA,iBAAS,EAAC,EAAE,kBAAkB,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,CAAC;QAChE,CAAC;QACD,UAAU,EAAE,KAAK,EAAE,OAAsB,EAAE,OAAO,EAAE,OAAQ,EAAE,EAAE;YAC9D,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC;YAC1C,OAAO,IAAA,kBAAU,EAAC,EAAE,kBAAkB,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;QAC1F,CAAC;QACD,eAAe,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,CAAC,IAAA,iCAAe,EAAC,OAAO,EAAE,UAAU,CAAC;QACxF,oBAAoB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,CAAC,IAAA,2CAAoB,EAAC,MAAM,CAAC;KACJ,CAAC;AACzE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { HederaSigner } from "../types";
|
|
2
|
+
export type HederaFrameworkSigner = {
|
|
3
|
+
getAddress(path: string): Promise<{
|
|
4
|
+
path: string;
|
|
5
|
+
address: string;
|
|
6
|
+
publicKey: string;
|
|
7
|
+
}>;
|
|
8
|
+
signTransaction(path: string, unsignedTxHex: string): Promise<string>;
|
|
9
|
+
};
|
|
10
|
+
/** Adapts the device-level {@link HederaSigner} to the generic framework. */
|
|
11
|
+
export declare function createFrameworkSigner(signer: HederaSigner): HederaFrameworkSigner;
|
|
12
|
+
//# sourceMappingURL=frameworkSigner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frameworkSigner.d.ts","sourceRoot":"","sources":["../../src/signer/frameworkSigner.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,MAAM,MAAM,qBAAqB,GAAG;IAClC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxF,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACvE,CAAC;AAEF,6EAA6E;AAC7E,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,YAAY,GAAG,qBAAqB,CAejF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createFrameworkSigner = createFrameworkSigner;
|
|
4
|
+
const utils_1 = require("../logic/utils");
|
|
5
|
+
/** Adapts the device-level {@link HederaSigner} to the generic framework. */
|
|
6
|
+
function createFrameworkSigner(signer) {
|
|
7
|
+
return {
|
|
8
|
+
async getAddress(path) {
|
|
9
|
+
const publicKey = await signer.getPublicKey(path);
|
|
10
|
+
// Hedera has no derivable address; the 0.0.x id comes from the discovery scan.
|
|
11
|
+
return { path, address: publicKey, publicKey };
|
|
12
|
+
},
|
|
13
|
+
// The framework passes a path and an options object; hw-app-hedera takes neither and signs
|
|
14
|
+
// from account index 0 only (device-app limit), so both are dropped — as in the legacy bridge.
|
|
15
|
+
async signTransaction(_path, unsignedTxHex) {
|
|
16
|
+
const tx = (0, utils_1.deserializeTransaction)(unsignedTxHex);
|
|
17
|
+
const signature = await signer.signTransaction((0, utils_1.getHederaTransactionBodyBytes)(tx));
|
|
18
|
+
return (0, utils_1.serializeSignature)(signature);
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=frameworkSigner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frameworkSigner.js","sourceRoot":"","sources":["../../src/signer/frameworkSigner.ts"],"names":[],"mappings":";;;AAAA,0CAIwB;AAQxB,6EAA6E;AAC7E,+BAAsC,MAAoB;IACxD,OAAO;QACL,KAAK,CAAC,UAAU,CAAC,IAAI;YACnB,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YAClD,+EAA+E;YAC/E,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;QACjD,CAAC;QACD,2FAA2F;QAC3F,+FAA+F;QAC/F,KAAK,CAAC,eAAe,CAAC,KAAK,EAAE,aAAa;YACxC,MAAM,EAAE,GAAG,IAAA,8BAAsB,EAAC,aAAa,CAAC,CAAC;YACjD,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,IAAA,qCAA6B,EAAC,EAAE,CAAC,CAAC,CAAC;YAClF,OAAO,IAAA,0BAAkB,EAAC,SAAS,CAAC,CAAC;QACvC,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/lib/signer/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/signer/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,cAAc,CAAC;eAErB,QAAQ"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/signer/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,cAAc,CAAC;eAErB,QAAQ;AACvB,OAAO,EAAE,qBAAqB,EAAE,KAAK,qBAAqB,EAAE,MAAM,mBAAmB,CAAC"}
|
package/lib/signer/index.js
CHANGED
|
@@ -3,6 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createFrameworkSigner = void 0;
|
|
6
7
|
const getAddress_1 = __importDefault(require("./getAddress"));
|
|
7
8
|
exports.default = getAddress_1.default;
|
|
9
|
+
var frameworkSigner_1 = require("./frameworkSigner");
|
|
10
|
+
Object.defineProperty(exports, "createFrameworkSigner", { enumerable: true, get: function () { return frameworkSigner_1.createFrameworkSigner; } });
|
|
8
11
|
//# sourceMappingURL=index.js.map
|
package/lib/signer/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/signer/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/signer/index.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAoC;kBAErB,oBAAQ;AACvB,qDAAsF;AAA7E,wHAAA,qBAAqB,OAAA"}
|
package/lib-es/api/index.d.ts
CHANGED
|
@@ -1,5 +1,85 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import
|
|
3
|
-
import type { HederaMemo, HederaTxData, HederaCoinConfig } from "../types";
|
|
4
|
-
export declare function createApi(currencyId: string):
|
|
1
|
+
import type { BalanceOptions, ListOperationsOptions } from "@ledgerhq/coin-module-framework/api/index";
|
|
2
|
+
import BigNumber from "bignumber.js";
|
|
3
|
+
import type { HederaMemo, HederaTxData, HederaCoinConfig, HederaContext } from "../types";
|
|
4
|
+
export declare function createApi(currencyId: string): {
|
|
5
|
+
broadcast: (context: HederaContext, tx: string, _options?: {
|
|
6
|
+
broadcastConfig?: import("@ledgerhq/coin-module-framework/lib-es/api/types").BroadcastConfig;
|
|
7
|
+
} | undefined) => Promise<string>;
|
|
8
|
+
combine: (_context: import("@ledgerhq/coin-module-framework/lib-es/config").Context<HederaCoinConfig>, tx: string, signature: string[], options?: {
|
|
9
|
+
pubkey?: string;
|
|
10
|
+
} | undefined) => string;
|
|
11
|
+
craftTransaction: (context: HederaContext, txIntent: import("@ledgerhq/coin-module-framework/lib-es/api/types").TransactionIntent<HederaMemo, HederaTxData>, options?: {
|
|
12
|
+
customFees?: import("@ledgerhq/coin-module-framework/lib-es/api/types").FeeEstimation;
|
|
13
|
+
} | undefined) => Promise<{
|
|
14
|
+
transaction: string;
|
|
15
|
+
}>;
|
|
16
|
+
estimateFees: (context: HederaContext, txIntent: import("@ledgerhq/coin-module-framework/lib-es/api/types").TransactionIntent<HederaMemo, HederaTxData>, _options?: {
|
|
17
|
+
customFeesParameters?: import("@ledgerhq/coin-module-framework/lib-es/api/types").FeeEstimation['parameters'];
|
|
18
|
+
feeOption?: import("@ledgerhq/coin-module-framework/lib-es/api/types").EstimateFeesOptions;
|
|
19
|
+
} | undefined) => Promise<{
|
|
20
|
+
value: bigint;
|
|
21
|
+
}>;
|
|
22
|
+
getBalance: (context: HederaContext, address: string, options?: BalanceOptions) => Promise<import("@ledgerhq/coin-module-framework/lib-es/api/types").Balance[]>;
|
|
23
|
+
getBlock: (context: HederaContext, height: number) => Promise<import("@ledgerhq/coin-module-framework/lib-es/api/types").Block>;
|
|
24
|
+
getBlockInfo: (_context: HederaContext, height: number) => Promise<import("@ledgerhq/coin-module-framework/lib-es/api/types").BlockInfo>;
|
|
25
|
+
lastBlock: (context: HederaContext) => Promise<import("@ledgerhq/coin-module-framework/lib-es/api/types").BlockInfo>;
|
|
26
|
+
listOperations: (context: HederaContext, address: string, { cursor, limit, order, minHeight }: ListOperationsOptions) => Promise<{
|
|
27
|
+
items: {
|
|
28
|
+
id: string;
|
|
29
|
+
type: import("@ledgerhq/types-live").OperationType;
|
|
30
|
+
senders: string[];
|
|
31
|
+
recipients: string[];
|
|
32
|
+
value: bigint;
|
|
33
|
+
asset: {
|
|
34
|
+
type: string;
|
|
35
|
+
assetReference: string;
|
|
36
|
+
assetOwner: string;
|
|
37
|
+
} | {
|
|
38
|
+
assetReference?: never;
|
|
39
|
+
assetOwner?: never;
|
|
40
|
+
type: string;
|
|
41
|
+
};
|
|
42
|
+
details: {
|
|
43
|
+
consensusTimestamp?: string;
|
|
44
|
+
transactionId?: string;
|
|
45
|
+
feesPayer?: string;
|
|
46
|
+
associatedTokenId?: string;
|
|
47
|
+
pagingToken?: string;
|
|
48
|
+
gasConsumed?: number;
|
|
49
|
+
gasLimit?: number;
|
|
50
|
+
gasUsed?: number;
|
|
51
|
+
memo?: string | null;
|
|
52
|
+
targetStakingNodeId?: number | null;
|
|
53
|
+
previousStakingNodeId?: number | null;
|
|
54
|
+
stakedAmount?: bigint | BigNumber;
|
|
55
|
+
ledgerOpType: import("@ledgerhq/types-live").OperationType;
|
|
56
|
+
assetAmount?: string;
|
|
57
|
+
};
|
|
58
|
+
tx: {
|
|
59
|
+
hash: string;
|
|
60
|
+
fees: bigint;
|
|
61
|
+
feesPayer?: string;
|
|
62
|
+
date: Date;
|
|
63
|
+
block: {
|
|
64
|
+
height: number;
|
|
65
|
+
hash: string;
|
|
66
|
+
time: Date;
|
|
67
|
+
};
|
|
68
|
+
failed: boolean;
|
|
69
|
+
};
|
|
70
|
+
}[];
|
|
71
|
+
next: string | undefined;
|
|
72
|
+
}>;
|
|
73
|
+
getValidators: (context: HederaContext, options?: {
|
|
74
|
+
cursor?: import("@ledgerhq/coin-module-framework/lib-es/api/types").Cursor;
|
|
75
|
+
} | undefined) => Promise<import("@ledgerhq/coin-module-framework/lib-es/api/types").Page<import("@ledgerhq/coin-module-framework/lib-es/api/types").Validator>>;
|
|
76
|
+
getStakes: (context: HederaContext, address: string, _options?: {
|
|
77
|
+
cursor?: import("@ledgerhq/coin-module-framework/lib-es/api/types").Cursor;
|
|
78
|
+
} | undefined) => Promise<import("@ledgerhq/coin-module-framework/lib-es/api/types").Page<import("@ledgerhq/coin-module-framework/lib-es/api/types").Stake>>;
|
|
79
|
+
getRewards: (context: HederaContext, address: string, options?: {
|
|
80
|
+
cursor?: import("@ledgerhq/coin-module-framework/lib-es/api/types").Cursor;
|
|
81
|
+
} | undefined) => Promise<import("@ledgerhq/coin-module-framework/lib-es/api/types").Page<import("@ledgerhq/coin-module-framework/lib-es/api/types").Reward>>;
|
|
82
|
+
validateAddress: (_context: import("@ledgerhq/coin-module-framework/lib-es/config").Context<HederaCoinConfig>, address: string, parameters: Partial<import("@ledgerhq/coin-module-framework/lib-es/api/types").AddressValidationCurrencyParameters>) => Promise<boolean>;
|
|
83
|
+
craftTransactionData: (_context: import("@ledgerhq/coin-module-framework/lib-es/config").Context<HederaCoinConfig>, intent: import("@ledgerhq/coin-module-framework/lib-es/api/types").TransactionIntent<HederaMemo, HederaTxData>) => import("@ledgerhq/coin-module-framework/lib-es/api/types").TxDataNotSupported;
|
|
84
|
+
};
|
|
5
85
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,cAAc,EACd,qBAAqB,EAEtB,MAAM,2CAA2C,CAAC;AAEnD,OAAO,SAAS,MAAM,cAAc,CAAC;AA8BrC,OAAO,KAAK,EAEV,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACd,MAAM,UAAU,CAAC;AAqBlB,wBAAgB,SAAS,CAAC,UAAU,EAAE,MAAM;yBAEb,aAAa;;;;;;gCAUN,aAAa;;;;;4BAajB,aAAa;;;;;;0BAiBrB,aAAa,WAAW,MAAM,YAAY,cAAc;wBAKpD,aAAa;6BAId,aAAa;yBACX,aAAa;8BAK7B,aAAa,WACb,MAAM,uCACsB,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBA+FlD,MAAM;oBACN,IAAI;oBACJ,IAAI;;;;;;;6BAYiB,aAAa;;;yBAIjB,aAAa;;;0BAIZ,aAAa;;;;;EAO5C"}
|
package/lib-es/api/index.js
CHANGED
|
@@ -12,9 +12,24 @@ import { getERC20BalancesForAccountV2, toEVMAddress } from "../network/utils";
|
|
|
12
12
|
// logger) and passes it to each method. Each method resolves the coin configuration from the context
|
|
13
13
|
// via `context.config()` and threads it explicitly into the logic layer rather than seeding the
|
|
14
14
|
// module-level singleton (ADR-019).
|
|
15
|
+
//
|
|
16
|
+
// Checked against CoinModuleImpl with `satisfies` rather than annotated as it, so the precise shape
|
|
17
|
+
// survives and a caller sees exactly which methods exist. Staking is fully covered here — Hedera
|
|
18
|
+
// proxy-stakes to a node, so `getStakes`, `getRewards` and `getValidators` are all real.
|
|
19
|
+
//
|
|
20
|
+
// Omitted rather than stubbed, and why:
|
|
21
|
+
// - `validateIntent` — intent validation still lives in the account bridge's
|
|
22
|
+
// `getTransactionStatus`; the api path has none of its own yet.
|
|
23
|
+
// - `getNextSequence` — no per-account nonce: a Hedera transaction is identified by its
|
|
24
|
+
// payer plus a valid-start timestamp (`createTransactionId`).
|
|
25
|
+
// - `craftRawTransaction` — the module accepts no externally-built transaction.
|
|
26
|
+
// - `call` — no read-only contract-call escape hatch is exposed, even though the
|
|
27
|
+
// device app parses contract calls.
|
|
28
|
+
// - `register` — no enrollment step.
|
|
29
|
+
// The consumer resolver applies `withDefaults`, which answers "not supported" for each of them.
|
|
15
30
|
export function createApi(currencyId) {
|
|
16
31
|
return {
|
|
17
|
-
broadcast: async (context, tx) => {
|
|
32
|
+
broadcast: async (context, tx, _options) => {
|
|
18
33
|
const coinConfig = await context.config();
|
|
19
34
|
const response = await logicBroadcast({
|
|
20
35
|
configOrCurrencyId: coinConfig,
|
|
@@ -22,12 +37,6 @@ export function createApi(currencyId) {
|
|
|
22
37
|
});
|
|
23
38
|
return Buffer.from(response.transactionHash).toString("base64");
|
|
24
39
|
},
|
|
25
|
-
async call() {
|
|
26
|
-
throw new Error("call is not supported");
|
|
27
|
-
},
|
|
28
|
-
async register() {
|
|
29
|
-
throw new Error("register is not supported");
|
|
30
|
-
},
|
|
31
40
|
combine: (_context, tx, signature, options) => combine(tx, signature, options?.pubkey),
|
|
32
41
|
craftTransaction: async (context, txIntent, options) => {
|
|
33
42
|
invariant(!txIntent.useAllAmount, "useAllAmount is not supported");
|
|
@@ -41,10 +50,7 @@ export function createApi(currencyId) {
|
|
|
41
50
|
transaction: serializedTx,
|
|
42
51
|
};
|
|
43
52
|
},
|
|
44
|
-
|
|
45
|
-
throw new Error("craftRawTransaction is not supported");
|
|
46
|
-
},
|
|
47
|
-
estimateFees: async (context, txIntent) => {
|
|
53
|
+
estimateFees: async (context, txIntent, _options) => {
|
|
48
54
|
let estimateFeesParams;
|
|
49
55
|
const operationType = mapIntentToSDKOperation(txIntent);
|
|
50
56
|
if (operationType === HEDERA_OPERATION_TYPES.ContractCall) {
|
|
@@ -171,7 +177,7 @@ export function createApi(currencyId) {
|
|
|
171
177
|
const coinConfig = await context.config();
|
|
172
178
|
return getValidators({ configOrCurrencyId: coinConfig, cursor: options?.cursor });
|
|
173
179
|
},
|
|
174
|
-
getStakes: async (context, address) => {
|
|
180
|
+
getStakes: async (context, address, _options) => {
|
|
175
181
|
const coinConfig = await context.config();
|
|
176
182
|
return getStakes({ configOrCurrencyId: coinConfig, address });
|
|
177
183
|
},
|
|
@@ -179,12 +185,6 @@ export function createApi(currencyId) {
|
|
|
179
185
|
const coinConfig = await context.config();
|
|
180
186
|
return getRewards({ configOrCurrencyId: coinConfig, address, cursor: options?.cursor });
|
|
181
187
|
},
|
|
182
|
-
validateIntent: async (_context, _transactionIntent, _balances, _options) => {
|
|
183
|
-
throw new Error("validateIntent is not supported");
|
|
184
|
-
},
|
|
185
|
-
getNextSequence: async (_context, _address) => {
|
|
186
|
-
throw new Error("getNextSequence is not supported");
|
|
187
|
-
},
|
|
188
188
|
validateAddress: (_context, address, parameters) => validateAddress(address, parameters),
|
|
189
189
|
craftTransactionData: (_context, intent) => craftTransactionData(intent),
|
|
190
190
|
};
|
package/lib-es/api/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qEAAqE,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qEAAqE,CAAC;AAO3G,OAAO,EAAE,oBAAoB,EAAE,MAAM,4DAA4D,CAAC;AAClG,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,0BAA0B,GAC3B,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,OAAO,EACP,gBAAgB,EAChB,UAAU,EACV,YAAY,EACZ,UAAU,EACV,UAAU,EACV,SAAS,EACT,aAAa,EACb,WAAW,EACX,SAAS,IAAI,cAAc,EAC3B,YAAY,IAAI,iBAAiB,EACjC,gBAAgB,IAAI,qBAAqB,GAC1C,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,4BAA4B,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAS9E,oGAAoG;AACpG,qGAAqG;AACrG,gGAAgG;AAChG,oCAAoC;AACpC,EAAE;AACF,oGAAoG;AACpG,iGAAiG;AACjG,yFAAyF;AACzF,EAAE;AACF,wCAAwC;AACxC,oFAAoF;AACpF,4FAA4F;AAC5F,8FAA8F;AAC9F,0FAA0F;AAC1F,kFAAkF;AAClF,kGAAkG;AAClG,gEAAgE;AAChE,kDAAkD;AAClD,gGAAgG;AAChG,MAAM,UAAU,SAAS,CAAC,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AAU,CAAC,EAAE,kBAAkB,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;QAC1F,CAAC;QACD,eAAe,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,CAAC,eAAe,CAAC,OAAO,EAAE,UAAU,CAAC;QACxF,oBAAoB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,CAAC,oBAAoB,CAAC,MAAM,CAAC;KACJ,CAAC;AACzE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { HederaSigner } from "../types";
|
|
2
|
+
export type HederaFrameworkSigner = {
|
|
3
|
+
getAddress(path: string): Promise<{
|
|
4
|
+
path: string;
|
|
5
|
+
address: string;
|
|
6
|
+
publicKey: string;
|
|
7
|
+
}>;
|
|
8
|
+
signTransaction(path: string, unsignedTxHex: string): Promise<string>;
|
|
9
|
+
};
|
|
10
|
+
/** Adapts the device-level {@link HederaSigner} to the generic framework. */
|
|
11
|
+
export declare function createFrameworkSigner(signer: HederaSigner): HederaFrameworkSigner;
|
|
12
|
+
//# sourceMappingURL=frameworkSigner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frameworkSigner.d.ts","sourceRoot":"","sources":["../../src/signer/frameworkSigner.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,MAAM,MAAM,qBAAqB,GAAG;IAClC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxF,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACvE,CAAC;AAEF,6EAA6E;AAC7E,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,YAAY,GAAG,qBAAqB,CAejF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { deserializeTransaction, getHederaTransactionBodyBytes, serializeSignature, } from "../logic/utils";
|
|
2
|
+
/** Adapts the device-level {@link HederaSigner} to the generic framework. */
|
|
3
|
+
export function createFrameworkSigner(signer) {
|
|
4
|
+
return {
|
|
5
|
+
async getAddress(path) {
|
|
6
|
+
const publicKey = await signer.getPublicKey(path);
|
|
7
|
+
// Hedera has no derivable address; the 0.0.x id comes from the discovery scan.
|
|
8
|
+
return { path, address: publicKey, publicKey };
|
|
9
|
+
},
|
|
10
|
+
// The framework passes a path and an options object; hw-app-hedera takes neither and signs
|
|
11
|
+
// from account index 0 only (device-app limit), so both are dropped — as in the legacy bridge.
|
|
12
|
+
async signTransaction(_path, unsignedTxHex) {
|
|
13
|
+
const tx = deserializeTransaction(unsignedTxHex);
|
|
14
|
+
const signature = await signer.signTransaction(getHederaTransactionBodyBytes(tx));
|
|
15
|
+
return serializeSignature(signature);
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=frameworkSigner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frameworkSigner.js","sourceRoot":"","sources":["../../src/signer/frameworkSigner.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,6BAA6B,EAC7B,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AAQxB,6EAA6E;AAC7E,MAAM,UAAU,qBAAqB,CAAC,MAAoB;IACxD,OAAO;QACL,KAAK,CAAC,UAAU,CAAC,IAAI;YACnB,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YAClD,+EAA+E;YAC/E,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;QACjD,CAAC;QACD,2FAA2F;QAC3F,+FAA+F;QAC/F,KAAK,CAAC,eAAe,CAAC,KAAK,EAAE,aAAa;YACxC,MAAM,EAAE,GAAG,sBAAsB,CAAC,aAAa,CAAC,CAAC;YACjD,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,6BAA6B,CAAC,EAAE,CAAC,CAAC,CAAC;YAClF,OAAO,kBAAkB,CAAC,SAAS,CAAC,CAAC;QACvC,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/lib-es/signer/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/signer/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,cAAc,CAAC;eAErB,QAAQ"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/signer/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,cAAc,CAAC;eAErB,QAAQ;AACvB,OAAO,EAAE,qBAAqB,EAAE,KAAK,qBAAqB,EAAE,MAAM,mBAAmB,CAAC"}
|
package/lib-es/signer/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/signer/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,cAAc,CAAC;AAEpC,eAAe,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/signer/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,cAAc,CAAC;AAEpC,eAAe,QAAQ,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAA8B,MAAM,mBAAmB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/coin-hedera",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0-nightly.20260901020738",
|
|
4
4
|
"description": "Ledger Hedera Coin integration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ledger",
|
|
@@ -89,19 +89,19 @@
|
|
|
89
89
|
"license": "Apache-2.0",
|
|
90
90
|
"dependencies": {
|
|
91
91
|
"@hashgraph/sdk": "2.78.0",
|
|
92
|
-
"@ledgerhq/coin-module-framework": "8.
|
|
92
|
+
"@ledgerhq/coin-module-framework": "8.2.0",
|
|
93
93
|
"@ledgerhq/logs": "6.17.0",
|
|
94
94
|
"bignumber.js": "^9.1.2",
|
|
95
95
|
"invariant": "^2.2.2",
|
|
96
96
|
"lodash": "4.17.21",
|
|
97
97
|
"rxjs": "7.8.2",
|
|
98
98
|
"viem": "^2.27.0",
|
|
99
|
+
"@ledgerhq/ledger-wallet-framework": "^3.2.0-nightly.20260901020738",
|
|
99
100
|
"@ledgerhq/devices": "8.17.0",
|
|
100
|
-
"@ledgerhq/live-countervalues": "^0.24.
|
|
101
|
-
"@ledgerhq/
|
|
102
|
-
"@ledgerhq/live-env": "^3.1.0",
|
|
101
|
+
"@ledgerhq/live-countervalues": "^0.24.5-nightly.20260901020738",
|
|
102
|
+
"@ledgerhq/live-env": "^3.2.0-nightly.20260901020738",
|
|
103
103
|
"@ledgerhq/live-network": "^3.0.0",
|
|
104
|
-
"@ledgerhq/types-live": "^6.
|
|
104
|
+
"@ledgerhq/types-live": "^6.122.0-nightly.20260901020738"
|
|
105
105
|
},
|
|
106
106
|
"devDependencies": {
|
|
107
107
|
"@swc/core": "1.15.11",
|
|
@@ -110,13 +110,14 @@
|
|
|
110
110
|
"@types/jest": "30.0.0",
|
|
111
111
|
"@types/lodash": "^4.17.21",
|
|
112
112
|
"@types/node": "24.12.0",
|
|
113
|
-
"jest": "30.
|
|
113
|
+
"jest": "30.4.1",
|
|
114
114
|
"oxfmt": "0.64.0",
|
|
115
115
|
"oxlint": "1.79.0",
|
|
116
|
-
"@domain/entity-currency-crypto": "^0.
|
|
117
|
-
"@features/platform-currencies": "^0.6.
|
|
116
|
+
"@domain/entity-currency-crypto": "^0.11.0-nightly.20260901020738",
|
|
117
|
+
"@features/platform-currencies": "^0.6.3-nightly.20260901020738",
|
|
118
118
|
"@ledgerhq/disable-network-setup": "^0.3.0",
|
|
119
|
-
"@ledgerhq/
|
|
119
|
+
"@ledgerhq/test-quarantine": "0.0.0",
|
|
120
|
+
"@ledgerhq/wallet-framework-test-setup": "^0.1.8-nightly.20260901020738"
|
|
120
121
|
},
|
|
121
122
|
"scripts": {
|
|
122
123
|
"clean": "rimraf lib lib-es",
|
package/src/api/index.test.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { capabilityReport } from "@ledgerhq/coin-module-framework/test-utils";
|
|
2
|
+
import { withDefaults } from "@ledgerhq/coin-module-framework/api/index";
|
|
1
3
|
import { BalanceOptions, TransactionIntent } from "@ledgerhq/coin-module-framework/api/types";
|
|
2
4
|
import BigNumber from "bignumber.js";
|
|
3
5
|
import { HARDCODED_BLOCK_HEIGHT, HEDERA_OPERATION_TYPES } from "../constants";
|
|
@@ -36,30 +38,48 @@ const mockGetStakes = jest.mocked(logic.getStakes);
|
|
|
36
38
|
const mockGetRewards = jest.mocked(logic.getRewards);
|
|
37
39
|
const mockListOperationsV2 = jest.mocked(logic.listOperationsV2);
|
|
38
40
|
|
|
41
|
+
// The consumer resolver hands the module to callers through `withDefaults`, so exercise the API the
|
|
42
|
+
// way a consumer sees it: the capabilities Hedera omits are backfilled by the framework.
|
|
43
|
+
const buildApi = (currencyId: string) => withDefaults(createApi(currencyId));
|
|
44
|
+
|
|
39
45
|
describe("createApi", () => {
|
|
40
|
-
let api: ReturnType<typeof
|
|
46
|
+
let api: ReturnType<typeof buildApi>;
|
|
41
47
|
const mockContext = getMockedContext();
|
|
42
48
|
const mockCurrency = getMockedCurrency();
|
|
43
49
|
|
|
44
50
|
beforeEach(() => {
|
|
45
51
|
jest.clearAllMocks();
|
|
46
|
-
api =
|
|
52
|
+
api = buildApi(mockCurrency.id);
|
|
47
53
|
});
|
|
48
54
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
expect(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
55
|
+
// Absent, raising "<name> is not supported" through the resolver — exhaustive by `toEqual`.
|
|
56
|
+
//
|
|
57
|
+
// Kept out rather than stubbed: intent validation still lives in the account bridge's
|
|
58
|
+
// getTransactionStatus, and the module exposes no sequence, no externally-built transaction,
|
|
59
|
+
// no contract-call escape hatch and no enrollment step.
|
|
60
|
+
it("omits the capabilities the chain has none of", async () => {
|
|
61
|
+
await expect(capabilityReport(createApi(mockCurrency.id), mockContext)).resolves.toEqual({
|
|
62
|
+
unsupported: ["call", "craftRawTransaction", "getNextSequence", "register", "validateIntent"],
|
|
63
|
+
inconsistent: [],
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
it("declares every method the chain supports", () => {
|
|
67
|
+
const impl = createApi(mockCurrency.id);
|
|
68
|
+
|
|
69
|
+
expect(impl.broadcast).toBeInstanceOf(Function);
|
|
70
|
+
expect(impl.combine).toBeInstanceOf(Function);
|
|
71
|
+
expect(impl.craftTransaction).toBeInstanceOf(Function);
|
|
72
|
+
expect(impl.craftTransactionData).toBeInstanceOf(Function);
|
|
73
|
+
expect(impl.estimateFees).toBeInstanceOf(Function);
|
|
74
|
+
expect(impl.getBalance).toBeInstanceOf(Function);
|
|
75
|
+
expect(impl.getBlock).toBeInstanceOf(Function);
|
|
76
|
+
expect(impl.getBlockInfo).toBeInstanceOf(Function);
|
|
77
|
+
expect(impl.getValidators).toBeInstanceOf(Function);
|
|
78
|
+
expect(impl.getStakes).toBeInstanceOf(Function);
|
|
79
|
+
expect(impl.getRewards).toBeInstanceOf(Function);
|
|
80
|
+
expect(impl.lastBlock).toBeInstanceOf(Function);
|
|
81
|
+
expect(impl.listOperations).toBeInstanceOf(Function);
|
|
82
|
+
expect(impl.validateAddress).toBeInstanceOf(Function);
|
|
63
83
|
});
|
|
64
84
|
|
|
65
85
|
describe("broadcast", () => {
|
|
@@ -113,28 +133,6 @@ describe("createApi", () => {
|
|
|
113
133
|
});
|
|
114
134
|
});
|
|
115
135
|
|
|
116
|
-
describe("call", () => {
|
|
117
|
-
it("should throw 'call is not supported'", async () => {
|
|
118
|
-
await expect(api.call(mockContext, {})).rejects.toThrow("call is not supported");
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
describe("register", () => {
|
|
123
|
-
it("should throw 'register is not supported'", async () => {
|
|
124
|
-
await expect(api.register(mockContext, "address")).rejects.toThrow(
|
|
125
|
-
"register is not supported",
|
|
126
|
-
);
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
describe("craftRawTransaction", () => {
|
|
131
|
-
it("should throw when called", () => {
|
|
132
|
-
expect(() => api.craftRawTransaction(mockContext, "tx", "sender", "pubkey", 1n)).toThrow(
|
|
133
|
-
"craftRawTransaction is not supported",
|
|
134
|
-
);
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
|
|
138
136
|
describe("estimateFees", () => {
|
|
139
137
|
it("should call estimateFees from logic and return FeeEstimation for non-ContractCall", async () => {
|
|
140
138
|
// @ts-expect-error - testing with minimal required fields for TransactionIntent
|
|
@@ -520,21 +518,4 @@ describe("createApi", () => {
|
|
|
520
518
|
);
|
|
521
519
|
});
|
|
522
520
|
});
|
|
523
|
-
|
|
524
|
-
describe("validateIntent", () => {
|
|
525
|
-
it("should throw when called", async () => {
|
|
526
|
-
// @ts-expect-error - testing unsupported method
|
|
527
|
-
await expect(api.validateIntent(mockContext, {}, [], undefined)).rejects.toThrow(
|
|
528
|
-
"validateIntent is not supported",
|
|
529
|
-
);
|
|
530
|
-
});
|
|
531
|
-
});
|
|
532
|
-
|
|
533
|
-
describe("getNextSequence", () => {
|
|
534
|
-
it("should throw when called", async () => {
|
|
535
|
-
await expect(api.getNextSequence(mockContext, "0.0.1234")).rejects.toThrow(
|
|
536
|
-
"getNextSequence is not supported",
|
|
537
|
-
);
|
|
538
|
-
});
|
|
539
|
-
});
|
|
540
521
|
});
|
package/src/api/index.ts
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { rejectBalanceOptions } from "@ledgerhq/coin-module-framework/api/getBalance/rejectBalanceOptions";
|
|
2
2
|
import type {
|
|
3
|
-
|
|
3
|
+
CoinModuleImpl,
|
|
4
4
|
BalanceOptions,
|
|
5
|
-
CraftedTransaction,
|
|
6
5
|
ListOperationsOptions,
|
|
7
6
|
Operation,
|
|
8
|
-
TransactionValidation,
|
|
9
7
|
} from "@ledgerhq/coin-module-framework/api/index";
|
|
10
8
|
import { craftTransactionData } from "@ledgerhq/coin-module-framework/logic/craftTransactionData";
|
|
11
|
-
import { BridgeApi } from "@ledgerhq/ledger-wallet-framework/api/types";
|
|
12
9
|
import BigNumber from "bignumber.js";
|
|
13
10
|
import invariant from "invariant";
|
|
14
11
|
import { validateAddress } from "../bridge/validateAddress";
|
|
@@ -51,11 +48,24 @@ import type {
|
|
|
51
48
|
// logger) and passes it to each method. Each method resolves the coin configuration from the context
|
|
52
49
|
// via `context.config()` and threads it explicitly into the logic layer rather than seeding the
|
|
53
50
|
// module-level singleton (ADR-019).
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
//
|
|
52
|
+
// Checked against CoinModuleImpl with `satisfies` rather than annotated as it, so the precise shape
|
|
53
|
+
// survives and a caller sees exactly which methods exist. Staking is fully covered here — Hedera
|
|
54
|
+
// proxy-stakes to a node, so `getStakes`, `getRewards` and `getValidators` are all real.
|
|
55
|
+
//
|
|
56
|
+
// Omitted rather than stubbed, and why:
|
|
57
|
+
// - `validateIntent` — intent validation still lives in the account bridge's
|
|
58
|
+
// `getTransactionStatus`; the api path has none of its own yet.
|
|
59
|
+
// - `getNextSequence` — no per-account nonce: a Hedera transaction is identified by its
|
|
60
|
+
// payer plus a valid-start timestamp (`createTransactionId`).
|
|
61
|
+
// - `craftRawTransaction` — the module accepts no externally-built transaction.
|
|
62
|
+
// - `call` — no read-only contract-call escape hatch is exposed, even though the
|
|
63
|
+
// device app parses contract calls.
|
|
64
|
+
// - `register` — no enrollment step.
|
|
65
|
+
// The consumer resolver applies `withDefaults`, which answers "not supported" for each of them.
|
|
66
|
+
export function createApi(currencyId: string) {
|
|
57
67
|
return {
|
|
58
|
-
broadcast: async (context: HederaContext, tx) => {
|
|
68
|
+
broadcast: async (context: HederaContext, tx, _options?) => {
|
|
59
69
|
const coinConfig = await context.config();
|
|
60
70
|
const response = await logicBroadcast({
|
|
61
71
|
configOrCurrencyId: coinConfig,
|
|
@@ -64,14 +74,8 @@ export function createApi(
|
|
|
64
74
|
|
|
65
75
|
return Buffer.from(response.transactionHash).toString("base64");
|
|
66
76
|
},
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
},
|
|
70
|
-
async register() {
|
|
71
|
-
throw new Error("register is not supported");
|
|
72
|
-
},
|
|
73
|
-
combine: (_context, tx, signature, options) => combine(tx, signature, options?.pubkey),
|
|
74
|
-
craftTransaction: async (context: HederaContext, txIntent, options) => {
|
|
77
|
+
combine: (_context, tx, signature, options?) => combine(tx, signature, options?.pubkey),
|
|
78
|
+
craftTransaction: async (context: HederaContext, txIntent, options?) => {
|
|
75
79
|
invariant(!txIntent.useAllAmount, "useAllAmount is not supported");
|
|
76
80
|
const coinConfig = await context.config();
|
|
77
81
|
const { serializedTx } = await craftTransaction({
|
|
@@ -84,16 +88,7 @@ export function createApi(
|
|
|
84
88
|
transaction: serializedTx,
|
|
85
89
|
};
|
|
86
90
|
},
|
|
87
|
-
|
|
88
|
-
_context: HederaContext,
|
|
89
|
-
_transaction: string,
|
|
90
|
-
_sender: string,
|
|
91
|
-
_publicKey: string,
|
|
92
|
-
_sequence: bigint,
|
|
93
|
-
): Promise<CraftedTransaction> => {
|
|
94
|
-
throw new Error("craftRawTransaction is not supported");
|
|
95
|
-
},
|
|
96
|
-
estimateFees: async (context: HederaContext, txIntent) => {
|
|
91
|
+
estimateFees: async (context: HederaContext, txIntent, _options?) => {
|
|
97
92
|
let estimateFeesParams: EstimateFeesParams;
|
|
98
93
|
const operationType = mapIntentToSDKOperation(txIntent);
|
|
99
94
|
|
|
@@ -236,30 +231,19 @@ export function createApi(
|
|
|
236
231
|
next: latestAccountOperations.nextCursor || undefined,
|
|
237
232
|
};
|
|
238
233
|
},
|
|
239
|
-
getValidators: async (context: HederaContext, options) => {
|
|
234
|
+
getValidators: async (context: HederaContext, options?) => {
|
|
240
235
|
const coinConfig = await context.config();
|
|
241
236
|
return getValidators({ configOrCurrencyId: coinConfig, cursor: options?.cursor });
|
|
242
237
|
},
|
|
243
|
-
getStakes: async (context: HederaContext, address) => {
|
|
238
|
+
getStakes: async (context: HederaContext, address, _options?) => {
|
|
244
239
|
const coinConfig = await context.config();
|
|
245
240
|
return getStakes({ configOrCurrencyId: coinConfig, address });
|
|
246
241
|
},
|
|
247
|
-
getRewards: async (context: HederaContext, address, options) => {
|
|
242
|
+
getRewards: async (context: HederaContext, address, options?) => {
|
|
248
243
|
const coinConfig = await context.config();
|
|
249
244
|
return getRewards({ configOrCurrencyId: coinConfig, address, cursor: options?.cursor });
|
|
250
245
|
},
|
|
251
|
-
validateIntent: async (
|
|
252
|
-
_context: HederaContext,
|
|
253
|
-
_transactionIntent,
|
|
254
|
-
_balances,
|
|
255
|
-
_options,
|
|
256
|
-
): Promise<TransactionValidation> => {
|
|
257
|
-
throw new Error("validateIntent is not supported");
|
|
258
|
-
},
|
|
259
|
-
getNextSequence: async (_context: HederaContext, _address): Promise<bigint> => {
|
|
260
|
-
throw new Error("getNextSequence is not supported");
|
|
261
|
-
},
|
|
262
246
|
validateAddress: (_context, address, parameters) => validateAddress(address, parameters),
|
|
263
247
|
craftTransactionData: (_context, intent) => craftTransactionData(intent),
|
|
264
|
-
}
|
|
248
|
+
} satisfies CoinModuleImpl<HederaCoinConfig, HederaMemo, HederaTxData>;
|
|
265
249
|
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { PrivateKey } from "@hashgraph/sdk";
|
|
2
|
+
import type { TransactionIntent } from "@ledgerhq/coin-module-framework/api/index";
|
|
3
|
+
import { HEDERA_TRANSACTION_MODES, TINYBAR_SCALE } from "../constants";
|
|
4
|
+
import { combine } from "../logic/combine";
|
|
5
|
+
import { craftTransaction } from "../logic/craftTransaction";
|
|
6
|
+
import {
|
|
7
|
+
deserializeTransaction,
|
|
8
|
+
getHederaTransactionBodyBytes,
|
|
9
|
+
serializeSignature,
|
|
10
|
+
serializeTransaction,
|
|
11
|
+
} from "../logic/utils";
|
|
12
|
+
import { getMockedConfig } from "../test/fixtures/config.fixture";
|
|
13
|
+
import type { HederaMemo, HederaSigner } from "../types";
|
|
14
|
+
import { createFrameworkSigner } from "./frameworkSigner";
|
|
15
|
+
|
|
16
|
+
jest.mock("../network/rpc", () => ({
|
|
17
|
+
rpcClient: require("../test/fixtures/rpc.fixture").getMockedRpcClient(),
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
const PATH = "44'/3030'/0'/0'/0'";
|
|
21
|
+
|
|
22
|
+
const makeIntent = (): TransactionIntent<HederaMemo> => ({
|
|
23
|
+
intentType: "transaction",
|
|
24
|
+
type: HEDERA_TRANSACTION_MODES.Send,
|
|
25
|
+
amount: BigInt(1 * 10 ** TINYBAR_SCALE),
|
|
26
|
+
recipient: "0.0.12345",
|
|
27
|
+
sender: "0.0.54321",
|
|
28
|
+
asset: { type: "native" },
|
|
29
|
+
memo: { kind: "text", type: "string", value: "Hbar transfer" },
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const makeSigner = (overrides: Partial<HederaSigner> = {}): HederaSigner => ({
|
|
33
|
+
getPublicKey: jest.fn().mockResolvedValue("aabbcc"),
|
|
34
|
+
signTransaction: jest.fn().mockResolvedValue(new Uint8Array([1, 2, 3])),
|
|
35
|
+
...overrides,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
describe("createFrameworkSigner.getAddress", () => {
|
|
39
|
+
it("returns the device public key as both address and publicKey", async () => {
|
|
40
|
+
const device = makeSigner({ getPublicKey: jest.fn().mockResolvedValue("abcd1234") });
|
|
41
|
+
const framework = createFrameworkSigner(device);
|
|
42
|
+
|
|
43
|
+
const result = await framework.getAddress(PATH);
|
|
44
|
+
|
|
45
|
+
expect(device.getPublicKey).toHaveBeenCalledTimes(1);
|
|
46
|
+
expect(device.getPublicKey).toHaveBeenCalledWith(PATH);
|
|
47
|
+
expect(result).toEqual({ path: PATH, address: "abcd1234", publicKey: "abcd1234" });
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe("createFrameworkSigner.signTransaction", () => {
|
|
52
|
+
it("signs the transaction body bytes, not the envelope, dropping path and options", async () => {
|
|
53
|
+
const { serializedTx } = await craftTransaction({
|
|
54
|
+
configOrCurrencyId: getMockedConfig(),
|
|
55
|
+
txIntent: makeIntent(),
|
|
56
|
+
});
|
|
57
|
+
const expectedBodyBytes = getHederaTransactionBodyBytes(deserializeTransaction(serializedTx));
|
|
58
|
+
const signature = new Uint8Array([9, 9, 9]);
|
|
59
|
+
const device = makeSigner({ signTransaction: jest.fn().mockResolvedValue(signature) });
|
|
60
|
+
const framework = createFrameworkSigner(device);
|
|
61
|
+
|
|
62
|
+
const result = await framework.signTransaction(PATH, serializedTx);
|
|
63
|
+
|
|
64
|
+
expect(device.signTransaction).toHaveBeenCalledTimes(1);
|
|
65
|
+
expect(device.signTransaction).toHaveBeenCalledWith(expectedBodyBytes);
|
|
66
|
+
expect(result).toBe(serializeSignature(signature));
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
describe("createFrameworkSigner byte-identical parity with the legacy bridge", () => {
|
|
71
|
+
it("produces the same combined transaction as the legacy signOperation path", async () => {
|
|
72
|
+
// Craft exactly once: TransactionId.generate uses Timestamp.generate(hasJitter = true),
|
|
73
|
+
// so crafting twice would never yield byte-identical transactions to compare.
|
|
74
|
+
const { tx, serializedTx } = await craftTransaction({
|
|
75
|
+
configOrCurrencyId: getMockedConfig(),
|
|
76
|
+
txIntent: makeIntent(),
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const publicKey = PrivateKey.generateED25519().publicKey.toStringRaw();
|
|
80
|
+
const signatureBytes = new Uint8Array(64).fill(7);
|
|
81
|
+
const device: HederaSigner = {
|
|
82
|
+
getPublicKey: jest.fn().mockResolvedValue(publicKey),
|
|
83
|
+
signTransaction: jest.fn().mockResolvedValue(signatureBytes),
|
|
84
|
+
};
|
|
85
|
+
const framework = createFrameworkSigner(device);
|
|
86
|
+
|
|
87
|
+
const legacy = combine(
|
|
88
|
+
serializeTransaction(tx),
|
|
89
|
+
[serializeSignature(await device.signTransaction(getHederaTransactionBodyBytes(tx)))],
|
|
90
|
+
publicKey,
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
const { publicKey: frameworkPublicKey } = await framework.getAddress(PATH);
|
|
94
|
+
const generic = combine(
|
|
95
|
+
serializedTx,
|
|
96
|
+
[await framework.signTransaction(PATH, serializedTx)],
|
|
97
|
+
frameworkPublicKey,
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
expect(generic).toBe(legacy);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
deserializeTransaction,
|
|
3
|
+
getHederaTransactionBodyBytes,
|
|
4
|
+
serializeSignature,
|
|
5
|
+
} from "../logic/utils";
|
|
6
|
+
import type { HederaSigner } from "../types";
|
|
7
|
+
|
|
8
|
+
export type HederaFrameworkSigner = {
|
|
9
|
+
getAddress(path: string): Promise<{ path: string; address: string; publicKey: string }>;
|
|
10
|
+
signTransaction(path: string, unsignedTxHex: string): Promise<string>;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/** Adapts the device-level {@link HederaSigner} to the generic framework. */
|
|
14
|
+
export function createFrameworkSigner(signer: HederaSigner): HederaFrameworkSigner {
|
|
15
|
+
return {
|
|
16
|
+
async getAddress(path) {
|
|
17
|
+
const publicKey = await signer.getPublicKey(path);
|
|
18
|
+
// Hedera has no derivable address; the 0.0.x id comes from the discovery scan.
|
|
19
|
+
return { path, address: publicKey, publicKey };
|
|
20
|
+
},
|
|
21
|
+
// The framework passes a path and an options object; hw-app-hedera takes neither and signs
|
|
22
|
+
// from account index 0 only (device-app limit), so both are dropped — as in the legacy bridge.
|
|
23
|
+
async signTransaction(_path, unsignedTxHex) {
|
|
24
|
+
const tx = deserializeTransaction(unsignedTxHex);
|
|
25
|
+
const signature = await signer.signTransaction(getHederaTransactionBodyBytes(tx));
|
|
26
|
+
return serializeSignature(signature);
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
package/src/signer/index.ts
CHANGED