@onekeyfe/hd-core 0.2.8 → 0.2.9

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.
Files changed (70) hide show
  1. package/dist/api/BaseMethod.d.ts.map +1 -1
  2. package/dist/api/cardano/CardanoGetAddress.d.ts +8 -0
  3. package/dist/api/cardano/CardanoGetAddress.d.ts.map +1 -0
  4. package/dist/api/cardano/CardanoGetPublicKey.d.ts +8 -0
  5. package/dist/api/cardano/CardanoGetPublicKey.d.ts.map +1 -0
  6. package/dist/api/cardano/CardanoSignTransaction.d.ts +9 -0
  7. package/dist/api/cardano/CardanoSignTransaction.d.ts.map +1 -0
  8. package/dist/api/cardano/helper/addressParameters.d.ts +7 -0
  9. package/dist/api/cardano/helper/addressParameters.d.ts.map +1 -0
  10. package/dist/api/cardano/helper/auxiliaryData.d.ts +5 -0
  11. package/dist/api/cardano/helper/auxiliaryData.d.ts.map +1 -0
  12. package/dist/api/cardano/helper/cardanoInputs.d.ts +14 -0
  13. package/dist/api/cardano/helper/cardanoInputs.d.ts.map +1 -0
  14. package/dist/api/cardano/helper/cardanoOutputs.d.ts +11 -0
  15. package/dist/api/cardano/helper/cardanoOutputs.d.ts.map +1 -0
  16. package/dist/api/cardano/helper/certificate.d.ts +9 -0
  17. package/dist/api/cardano/helper/certificate.d.ts.map +1 -0
  18. package/dist/api/cardano/helper/token.d.ts +3 -0
  19. package/dist/api/cardano/helper/token.d.ts.map +1 -0
  20. package/dist/api/cardano/helper/utils.d.ts +3 -0
  21. package/dist/api/cardano/helper/utils.d.ts.map +1 -0
  22. package/dist/api/cardano/helper/witnesses.d.ts +5 -0
  23. package/dist/api/cardano/helper/witnesses.d.ts.map +1 -0
  24. package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
  25. package/dist/api/helpers/paramsValidator.d.ts +2 -1
  26. package/dist/api/helpers/paramsValidator.d.ts.map +1 -1
  27. package/dist/api/index.d.ts +3 -0
  28. package/dist/api/index.d.ts.map +1 -1
  29. package/dist/core/index.d.ts.map +1 -1
  30. package/dist/device/Device.d.ts +1 -0
  31. package/dist/device/Device.d.ts.map +1 -1
  32. package/dist/index.d.ts +192 -0
  33. package/dist/index.js +850 -18
  34. package/dist/inject.d.ts.map +1 -1
  35. package/dist/types/api/cardano.d.ts +158 -0
  36. package/dist/types/api/cardano.d.ts.map +1 -0
  37. package/dist/types/api/cardanoGetAddress.d.ts +33 -0
  38. package/dist/types/api/cardanoGetAddress.d.ts.map +1 -0
  39. package/dist/types/api/cardanoGetPublicKey.d.ts +23 -0
  40. package/dist/types/api/cardanoGetPublicKey.d.ts.map +1 -0
  41. package/dist/types/api/cardanoSignTransaction.d.ts +4 -0
  42. package/dist/types/api/cardanoSignTransaction.d.ts.map +1 -0
  43. package/dist/types/api/index.d.ts +6 -0
  44. package/dist/types/api/index.d.ts.map +1 -1
  45. package/package.json +4 -4
  46. package/src/api/BaseMethod.ts +7 -1
  47. package/src/api/btc/helpers/signtxLegacy.ts +1 -1
  48. package/src/api/cardano/CardanoGetAddress.ts +87 -0
  49. package/src/api/cardano/CardanoGetPublicKey.ts +55 -0
  50. package/src/api/cardano/CardanoSignTransaction.ts +309 -0
  51. package/src/api/cardano/helper/addressParameters.ts +118 -0
  52. package/src/api/cardano/helper/auxiliaryData.ts +74 -0
  53. package/src/api/cardano/helper/cardanoInputs.ts +56 -0
  54. package/src/api/cardano/helper/cardanoOutputs.ts +89 -0
  55. package/src/api/cardano/helper/certificate.ts +199 -0
  56. package/src/api/cardano/helper/token.ts +43 -0
  57. package/src/api/cardano/helper/utils.ts +17 -0
  58. package/src/api/cardano/helper/witnesses.ts +63 -0
  59. package/src/api/firmware/uploadFirmware.ts +1 -3
  60. package/src/api/helpers/paramsValidator.ts +19 -1
  61. package/src/api/index.ts +4 -0
  62. package/src/core/index.ts +1 -0
  63. package/src/data/messages/messages.json +107 -68
  64. package/src/device/Device.ts +5 -0
  65. package/src/inject.ts +7 -0
  66. package/src/types/api/cardano.ts +186 -0
  67. package/src/types/api/cardanoGetAddress.ts +47 -0
  68. package/src/types/api/cardanoGetPublicKey.ts +33 -0
  69. package/src/types/api/cardanoSignTransaction.ts +8 -0
  70. package/src/types/api/index.ts +11 -0
@@ -0,0 +1,199 @@
1
+ import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
2
+ import { validateParams } from '../../helpers/paramsValidator';
3
+ import { validatePath } from '../../helpers/pathUtils';
4
+ import type {
5
+ CardanoCertificate,
6
+ CardanoPoolParameters,
7
+ CertificateWithPoolOwnersAndRelays,
8
+ CardanoPoolMargin,
9
+ CardanoPoolMetadata,
10
+ CardanoPoolRelay,
11
+ CardanoPoolOwner,
12
+ } from '../../../types/api/cardano';
13
+ import { PROTO } from '../../../constants';
14
+
15
+ export type PoolParametersWithOwnersAndRelays = {
16
+ poolParameters?: PROTO.CardanoPoolParametersType;
17
+ poolOwners: PROTO.CardanoPoolOwner[];
18
+ poolRelays: PROTO.CardanoPoolRelayParameters[];
19
+ };
20
+
21
+ const ipv4AddressToHex = (ipv4Address: string) =>
22
+ Buffer.from(ipv4Address.split('.').map(ipPart => parseInt(ipPart, 10))).toString('hex');
23
+
24
+ const ipv6AddressToHex = (ipv6Address: string) => ipv6Address.split(':').join('');
25
+
26
+ const validatePoolMargin = (margin: CardanoPoolMargin) => {
27
+ validateParams(margin, [
28
+ { name: 'numerator', type: 'string', required: true },
29
+ { name: 'denominator', type: 'string', required: true },
30
+ ]);
31
+ };
32
+
33
+ const validatePoolMetadata = (metadata: CardanoPoolMetadata) => {
34
+ validateParams(metadata, [
35
+ { name: 'url', type: 'string', required: true },
36
+ { name: 'hash', type: 'string', required: true },
37
+ ]);
38
+ };
39
+
40
+ const validatePoolRelay = (relay: CardanoPoolRelay) => {
41
+ validateParams(relay, [{ name: 'type', type: 'number', required: true }]);
42
+
43
+ if (relay.type === PROTO.CardanoPoolRelayType.SINGLE_HOST_IP) {
44
+ const paramsToValidate: Parameters<typeof validateParams>[1] = [
45
+ { name: 'port', type: 'number', required: true },
46
+ ];
47
+ if (relay.ipv4Address) {
48
+ paramsToValidate.push({ name: 'ipv4Address', type: 'string', required: false });
49
+ }
50
+ if (relay.ipv6Address) {
51
+ paramsToValidate.push({ name: 'ipv6Address', type: 'string', required: false });
52
+ }
53
+
54
+ validateParams(relay, paramsToValidate);
55
+
56
+ if (!relay.ipv4Address && !relay.ipv6Address) {
57
+ throw ERRORS.TypedError(
58
+ HardwareErrorCode.CallMethodInvalidParameter,
59
+ 'Either ipv4Address or ipv6Address must be supplied'
60
+ );
61
+ }
62
+ } else if (relay.type === PROTO.CardanoPoolRelayType.SINGLE_HOST_NAME) {
63
+ validateParams(relay, [
64
+ { name: 'hostName', type: 'string', required: true },
65
+ { name: 'port', type: 'number', required: true },
66
+ ]);
67
+ } else if (relay.type === PROTO.CardanoPoolRelayType.MULTIPLE_HOST_NAME) {
68
+ validateParams(relay, [{ name: 'hostName', type: 'string', required: true }]);
69
+ }
70
+ };
71
+
72
+ const validatePoolOwners = (owners: CardanoPoolOwner[]) => {
73
+ owners.forEach(owner => {
74
+ if (owner.stakingKeyHash) {
75
+ validateParams(owner, [
76
+ { name: 'stakingKeyHash', type: 'string', required: !owner.stakingKeyPath },
77
+ ]);
78
+ }
79
+
80
+ if (owner.stakingKeyPath) {
81
+ validatePath(owner.stakingKeyPath, 5);
82
+ }
83
+
84
+ if (!owner.stakingKeyHash && !owner.stakingKeyPath) {
85
+ throw ERRORS.TypedError(
86
+ HardwareErrorCode.CallMethodInvalidParameter,
87
+ 'Either stakingKeyHash or stakingKeyPath must be supplied'
88
+ );
89
+ }
90
+ });
91
+
92
+ const ownersAsPathCount = owners.filter(owner => !!owner.stakingKeyPath).length;
93
+ if (ownersAsPathCount !== 1) {
94
+ throw ERRORS.TypedError(
95
+ HardwareErrorCode.CallMethodInvalidParameter,
96
+ 'Exactly one pool owner must be given as a path'
97
+ );
98
+ }
99
+ };
100
+
101
+ const validatePoolParameters = (poolParameters: CardanoPoolParameters) => {
102
+ validateParams(poolParameters, [
103
+ { name: 'poolId', type: 'string', required: true },
104
+ { name: 'vrfKeyHash', type: 'string', required: true },
105
+ { name: 'pledge', type: 'string', required: true },
106
+ { name: 'cost', type: 'string', required: true },
107
+ { name: 'margin', type: 'object', required: true },
108
+ { name: 'rewardAccount', type: 'string', required: true },
109
+ { name: 'owners', type: 'array', required: true },
110
+ { name: 'relays', type: 'array', required: true, allowEmpty: true },
111
+ { name: 'metadata', type: 'object' },
112
+ ]);
113
+
114
+ validatePoolMargin(poolParameters.margin);
115
+ validatePoolOwners(poolParameters.owners);
116
+ poolParameters.relays.forEach(validatePoolRelay);
117
+
118
+ if (poolParameters.metadata) {
119
+ validatePoolMetadata(poolParameters.metadata);
120
+ }
121
+ };
122
+
123
+ const transformPoolParameters = (
124
+ poolParameters?: CardanoPoolParameters
125
+ ): PoolParametersWithOwnersAndRelays => {
126
+ if (!poolParameters) {
127
+ return { poolParameters: undefined, poolOwners: [], poolRelays: [] };
128
+ }
129
+
130
+ validatePoolParameters(poolParameters);
131
+
132
+ return {
133
+ // @ts-expect-error
134
+ poolParameters: {
135
+ pool_id: poolParameters.poolId,
136
+ vrf_key_hash: poolParameters.vrfKeyHash,
137
+ pledge: poolParameters.pledge,
138
+ cost: poolParameters.cost,
139
+ margin_numerator: poolParameters.margin.numerator,
140
+ margin_denominator: poolParameters.margin.denominator,
141
+ reward_account: poolParameters.rewardAccount,
142
+ metadata: poolParameters.metadata,
143
+ owners_count: poolParameters.owners.length,
144
+ relays_count: poolParameters.relays.length,
145
+ },
146
+ poolOwners: poolParameters.owners.map(owner => ({
147
+ staking_key_hash: owner.stakingKeyHash,
148
+ staking_key_path: owner.stakingKeyPath ? validatePath(owner.stakingKeyPath, 5) : undefined,
149
+ })),
150
+ poolRelays: poolParameters.relays.map(relay => ({
151
+ type: relay.type,
152
+ ipv4_address: relay.ipv4Address ? ipv4AddressToHex(relay.ipv4Address) : undefined,
153
+ ipv6_address: relay.ipv6Address ? ipv6AddressToHex(relay.ipv6Address) : undefined,
154
+ host_name: relay.hostName,
155
+ port: relay.port,
156
+ })),
157
+ };
158
+ };
159
+
160
+ export const transformCertificate = (
161
+ certificate: CardanoCertificate
162
+ ): CertificateWithPoolOwnersAndRelays => {
163
+ const paramsToValidate: Parameters<typeof validateParams>[1] = [
164
+ { name: 'type', type: 'number', required: true },
165
+ ];
166
+
167
+ if (certificate.type !== PROTO.CardanoCertificateType.STAKE_POOL_REGISTRATION) {
168
+ paramsToValidate.push({ name: 'scriptHash', type: 'string' });
169
+ paramsToValidate.push({ name: 'keyHash', type: 'string' });
170
+ }
171
+
172
+ if (certificate.type === PROTO.CardanoCertificateType.STAKE_DELEGATION) {
173
+ paramsToValidate.push({ name: 'pool', type: 'string', required: true });
174
+ }
175
+
176
+ if (certificate.type === PROTO.CardanoCertificateType.STAKE_POOL_REGISTRATION) {
177
+ paramsToValidate.push({ name: 'poolParameters', type: 'object', required: true });
178
+ }
179
+
180
+ validateParams(certificate, paramsToValidate);
181
+
182
+ const { poolParameters, poolOwners, poolRelays } = transformPoolParameters(
183
+ certificate.poolParameters
184
+ );
185
+
186
+ return {
187
+ certificate: {
188
+ type: certificate.type,
189
+ path: certificate.path ? validatePath(certificate.path, 5) : undefined,
190
+ script_hash: certificate.scriptHash,
191
+ // @ts-expect-error
192
+ key_hash: certificate.keyHash,
193
+ pool: certificate.pool,
194
+ pool_parameters: poolParameters,
195
+ },
196
+ poolOwners,
197
+ poolRelays,
198
+ };
199
+ };
@@ -0,0 +1,43 @@
1
+ import { validateParams } from '../../helpers/paramsValidator';
2
+ import type {
3
+ CardanoAssetGroup,
4
+ AssetGroupWithTokens,
5
+ CardanoToken,
6
+ } from '../../../types/api/cardano';
7
+ import type { PROTO } from '../../../constants';
8
+
9
+ const validateTokens = (tokenAmounts: CardanoToken[]) => {
10
+ tokenAmounts.forEach(tokenAmount => {
11
+ validateParams(tokenAmount, [
12
+ { name: 'assetNameBytes', type: 'string', required: true },
13
+ { name: 'amount', type: 'uint' },
14
+ { name: 'mintAmount', type: 'uint', allowNegative: true },
15
+ ]);
16
+ });
17
+ };
18
+
19
+ const validateTokenBundle = (tokenBundle: CardanoAssetGroup[]) => {
20
+ tokenBundle.forEach(tokenGroup => {
21
+ validateParams(tokenGroup, [
22
+ { name: 'policyId', type: 'string', required: true },
23
+ { name: 'tokenAmounts', type: 'array', required: true },
24
+ ]);
25
+
26
+ validateTokens(tokenGroup.tokenAmounts);
27
+ });
28
+ };
29
+
30
+ export const tokenBundleToProto = (tokenBundle: CardanoAssetGroup[]): AssetGroupWithTokens[] => {
31
+ validateTokenBundle(tokenBundle);
32
+ return tokenBundle.map(tokenGroup => ({
33
+ policyId: tokenGroup.policyId,
34
+ tokens: tokenAmountsToProto(tokenGroup.tokenAmounts),
35
+ }));
36
+ };
37
+
38
+ const tokenAmountsToProto = (tokenAmounts: CardanoToken[]): PROTO.CardanoToken[] =>
39
+ tokenAmounts.map(tokenAmount => ({
40
+ asset_name_bytes: tokenAmount.assetNameBytes,
41
+ amount: tokenAmount.amount,
42
+ mint_amount: tokenAmount.mintAmount,
43
+ }));
@@ -0,0 +1,17 @@
1
+ export const hexStringByteLength = (s: string) => s.length / 2;
2
+
3
+ export const sendChunkedHexString = async (
4
+ typedCall: any,
5
+ data: string,
6
+ chunkSize: number,
7
+ messageType: string
8
+ ) => {
9
+ let processedSize = 0;
10
+ while (processedSize < data.length) {
11
+ const chunk = data.slice(processedSize, processedSize + chunkSize);
12
+ await typedCall(messageType, 'CardanoTxItemAck', {
13
+ data: chunk,
14
+ });
15
+ processedSize += chunkSize;
16
+ }
17
+ };
@@ -0,0 +1,63 @@
1
+ import type { CertificateWithPoolOwnersAndRelays } from '../../../types/api/cardano';
2
+ import { CollateralInputWithPath, InputWithPath, Path } from './cardanoInputs';
3
+ import { PROTO } from '../../../constants';
4
+
5
+ export const gatherWitnessPaths = (
6
+ inputsWithPath: InputWithPath[],
7
+ certificatesWithPoolOwnersAndRelays: CertificateWithPoolOwnersAndRelays[],
8
+ withdrawals: PROTO.CardanoTxWithdrawal[],
9
+ collateralInputsWithPath: CollateralInputWithPath[],
10
+ // @ts-expect-error
11
+ requiredSigners: PROTO.CardanoTxRequiredSigner[],
12
+ additionalWitnessRequests: Path[],
13
+ signingMode: PROTO.CardanoTxSigningMode
14
+ ): Path[] => {
15
+ const witnessPaths = new Map<string, Path>();
16
+ function _insert(path: Path) {
17
+ const pathKey = JSON.stringify(path);
18
+ witnessPaths.set(pathKey, path);
19
+ }
20
+
21
+ // don't gather paths from tx elements in MULTISIG_TRANSACTION signing mode
22
+ if (signingMode !== PROTO.CardanoTxSigningMode.MULTISIG_TRANSACTION) {
23
+ inputsWithPath.forEach(({ path }) => {
24
+ if (path) _insert(path);
25
+ });
26
+
27
+ certificatesWithPoolOwnersAndRelays.forEach(({ certificate, poolOwners }) => {
28
+ if (
29
+ certificate.path &&
30
+ (certificate.type === PROTO.CardanoCertificateType.STAKE_DELEGATION ||
31
+ certificate.type === PROTO.CardanoCertificateType.STAKE_DEREGISTRATION)
32
+ ) {
33
+ _insert(certificate.path);
34
+ }
35
+ poolOwners.forEach(poolOwner => {
36
+ if (poolOwner.staking_key_path) _insert(poolOwner.staking_key_path);
37
+ });
38
+ });
39
+
40
+ withdrawals.forEach(({ path }) => {
41
+ if (path) _insert(path);
42
+ });
43
+ }
44
+
45
+ // gather Plutus-related paths
46
+ // @ts-expect-error
47
+ if (signingMode === PROTO.CardanoTxSigningMode.PLUTUS_TRANSACTION) {
48
+ collateralInputsWithPath.forEach(({ path }) => {
49
+ if (path) _insert(path);
50
+ });
51
+ }
52
+
53
+ requiredSigners.forEach(({ key_path }) => {
54
+ if (key_path) _insert(key_path);
55
+ });
56
+
57
+ // add additional witness requests in all cases (because of minting)
58
+ additionalWitnessRequests.forEach(path => {
59
+ _insert(path);
60
+ });
61
+
62
+ return Array.from(witnessPaths.values());
63
+ };
@@ -2,7 +2,7 @@ import { blake2s } from '@noble/hashes/blake2s';
2
2
  import JSZip from 'jszip';
3
3
  import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
4
4
  import { Success } from '@onekeyfe/hd-transport';
5
- import { wait, getLogger, LoggerNames } from '../../utils/index';
5
+ import { wait } from '../../utils/index';
6
6
  import { DEVICE, CoreMessage, createUiMessage, UI_REQUEST } from '../../events';
7
7
  import { PROTO } from '../../constants';
8
8
  import type { Device } from '../../device/Device';
@@ -10,8 +10,6 @@ import type { TypedCall, TypedResponseMessage } from '../../device/DeviceCommand
10
10
  import { KnownDevice } from '../../types';
11
11
  import { bytesToHex } from '../helpers/hexUtils';
12
12
 
13
- const Log = getLogger(LoggerNames.Device);
14
-
15
13
  const postConfirmationMessage = (device: Device) => {
16
14
  // only if firmware is already installed. fresh device does not require button confirmation
17
15
  if (device.features?.firmware_present) {
@@ -10,12 +10,14 @@ export type SchemaParam = {
10
10
  | 'number'
11
11
  | 'boolean'
12
12
  | 'bigNumber'
13
+ | 'uint'
13
14
  | 'buffer'
14
15
  | 'object'
15
16
  | 'array'
16
17
  | 'hexString';
17
18
  required?: boolean;
18
19
  allowEmpty?: boolean;
20
+ allowNegative?: boolean;
19
21
  };
20
22
 
21
23
  const invalidParameter = (message: string) =>
@@ -42,7 +44,23 @@ export const validateParams = (values: any, fields: Array<SchemaParam>): void =>
42
44
  throw invalidParameter(`Parameter "${field.name}" is empty.`);
43
45
  }
44
46
  break;
45
-
47
+ case 'uint':
48
+ if (typeof value !== 'string' && typeof value !== 'number') {
49
+ throw invalidParameter(
50
+ `Parameter [${field.name}] has invalid type. "string|number" expected.`
51
+ );
52
+ }
53
+ if (
54
+ (typeof value === 'number' && !Number.isSafeInteger(value)) ||
55
+ !/^(?:[1-9]\d*|\d)$/.test(
56
+ value.toString().replace(/^-/, field.allowNegative ? '' : '-')
57
+ )
58
+ ) {
59
+ throw invalidParameter(
60
+ `Parameter [${field.name}] has invalid value "${value}". Integer representation expected.`
61
+ );
62
+ }
63
+ break;
46
64
  case 'bigNumber':
47
65
  if (typeof value !== 'string') {
48
66
  throw invalidParameter(
package/src/api/index.ts CHANGED
@@ -85,3 +85,7 @@ export { default as xrpSignTransaction } from './xrp/XrpSignTransaction';
85
85
  export { default as suiGetAddress } from './sui/SuiGetAddress';
86
86
  export { default as suiGetPublicKey } from './sui/SuiGetPublicKey';
87
87
  export { default as suiSignTransaction } from './sui/SuiSignTransaction';
88
+
89
+ export { default as cardanoGetAddress } from './cardano/CardanoGetAddress';
90
+ export { default as cardanoGetPublicKey } from './cardano/CardanoGetPublicKey';
91
+ export { default as cardanoSignTransaction } from './cardano/CardanoSignTransaction';
package/src/core/index.ts CHANGED
@@ -45,6 +45,7 @@ const parseInitOptions = (method?: BaseMethod): InitOptions => ({
45
45
  initSession: method?.payload.initSession,
46
46
  passphraseState: method?.payload.passphraseState,
47
47
  deviceId: method?.payload.deviceId,
48
+ deriveCardano: method?.name.startsWith('cardano'),
48
49
  });
49
50
 
50
51
  let _core: Core;
@@ -1892,74 +1892,113 @@
1892
1892
  },
1893
1893
  "CardanoSignTxInit": {
1894
1894
  "fields": {
1895
- "signing_mode": {
1896
- "rule": "required",
1897
- "type": "CardanoTxSigningMode",
1898
- "id": 1
1899
- },
1900
- "protocol_magic": {
1901
- "rule": "required",
1902
- "type": "uint32",
1903
- "id": 2
1904
- },
1905
- "network_id": {
1906
- "rule": "required",
1907
- "type": "uint32",
1908
- "id": 3
1909
- },
1910
- "inputs_count": {
1911
- "rule": "required",
1912
- "type": "uint32",
1913
- "id": 4
1914
- },
1915
- "outputs_count": {
1916
- "rule": "required",
1917
- "type": "uint32",
1918
- "id": 5
1919
- },
1920
- "fee": {
1921
- "rule": "required",
1922
- "type": "uint64",
1923
- "id": 6
1924
- },
1925
- "ttl": {
1926
- "type": "uint64",
1927
- "id": 7
1928
- },
1929
- "certificates_count": {
1930
- "rule": "required",
1931
- "type": "uint32",
1932
- "id": 8
1933
- },
1934
- "withdrawals_count": {
1935
- "rule": "required",
1936
- "type": "uint32",
1937
- "id": 9
1938
- },
1939
- "has_auxiliary_data": {
1940
- "rule": "required",
1941
- "type": "bool",
1942
- "id": 10
1943
- },
1944
- "validity_interval_start": {
1945
- "type": "uint64",
1946
- "id": 11
1947
- },
1948
- "witness_requests_count": {
1949
- "rule": "required",
1950
- "type": "uint32",
1951
- "id": 12
1952
- },
1953
- "minting_asset_groups_count": {
1954
- "rule": "required",
1955
- "type": "uint32",
1956
- "id": 13
1957
- },
1958
- "derivation_type": {
1959
- "rule": "required",
1960
- "type": "CardanoDerivationType",
1961
- "id": 14
1962
- }
1895
+ "signing_mode": {
1896
+ "rule": "required",
1897
+ "type": "CardanoTxSigningMode",
1898
+ "id": 1
1899
+ },
1900
+ "protocol_magic": {
1901
+ "rule": "required",
1902
+ "type": "uint32",
1903
+ "id": 2
1904
+ },
1905
+ "network_id": {
1906
+ "rule": "required",
1907
+ "type": "uint32",
1908
+ "id": 3
1909
+ },
1910
+ "inputs_count": {
1911
+ "rule": "required",
1912
+ "type": "uint32",
1913
+ "id": 4
1914
+ },
1915
+ "outputs_count": {
1916
+ "rule": "required",
1917
+ "type": "uint32",
1918
+ "id": 5
1919
+ },
1920
+ "fee": {
1921
+ "rule": "required",
1922
+ "type": "uint64",
1923
+ "id": 6
1924
+ },
1925
+ "ttl": {
1926
+ "type": "uint64",
1927
+ "id": 7
1928
+ },
1929
+ "certificates_count": {
1930
+ "rule": "required",
1931
+ "type": "uint32",
1932
+ "id": 8
1933
+ },
1934
+ "withdrawals_count": {
1935
+ "rule": "required",
1936
+ "type": "uint32",
1937
+ "id": 9
1938
+ },
1939
+ "has_auxiliary_data": {
1940
+ "rule": "required",
1941
+ "type": "bool",
1942
+ "id": 10
1943
+ },
1944
+ "validity_interval_start": {
1945
+ "type": "uint64",
1946
+ "id": 11
1947
+ },
1948
+ "witness_requests_count": {
1949
+ "rule": "required",
1950
+ "type": "uint32",
1951
+ "id": 12
1952
+ },
1953
+ "minting_asset_groups_count": {
1954
+ "rule": "required",
1955
+ "type": "uint32",
1956
+ "id": 13
1957
+ },
1958
+ "derivation_type": {
1959
+ "rule": "required",
1960
+ "type": "CardanoDerivationType",
1961
+ "id": 14
1962
+ },
1963
+ "include_network_id": {
1964
+ "type": "bool",
1965
+ "id": 15,
1966
+ "options": {
1967
+ "default": false
1968
+ }
1969
+ },
1970
+ "script_data_hash": {
1971
+ "type": "bytes",
1972
+ "id": 16
1973
+ },
1974
+ "collateral_inputs_count": {
1975
+ "rule": "required",
1976
+ "type": "uint32",
1977
+ "id": 17
1978
+ },
1979
+ "required_signers_count": {
1980
+ "rule": "required",
1981
+ "type": "uint32",
1982
+ "id": 18
1983
+ },
1984
+ "has_collateral_return": {
1985
+ "type": "bool",
1986
+ "id": 19,
1987
+ "options": {
1988
+ "default": false
1989
+ }
1990
+ },
1991
+ "total_collateral": {
1992
+ "type": "uint64",
1993
+ "id": 20
1994
+ },
1995
+ "reference_inputs_count": {
1996
+ "type": "uint32",
1997
+ "id": 21,
1998
+ "options": {
1999
+ "default": 0
2000
+ }
2001
+ }
1963
2002
  }
1964
2003
  },
1965
2004
  "CardanoTxInput": {
@@ -32,6 +32,7 @@ export type InitOptions = {
32
32
  initSession?: boolean;
33
33
  deviceId?: string;
34
34
  passphraseState?: string;
35
+ deriveCardano?: boolean;
35
36
  };
36
37
 
37
38
  export type RunOptions = {
@@ -343,6 +344,10 @@ export class Device extends EventEmitter {
343
344
  payload.session_id = internalState;
344
345
  }
345
346
 
347
+ if (options?.deriveCardano) {
348
+ payload.derive_cardano = true;
349
+ }
350
+
346
351
  Log.debug('initialize payload:', payload);
347
352
 
348
353
  const { message } = await this.commands.typedCall('Initialize', 'Features', payload);
package/src/inject.ts CHANGED
@@ -205,6 +205,13 @@ export const inject = ({
205
205
  call({ ...params, connectId, deviceId, method: 'suiGetPublicKey' }),
206
206
  suiSignTransaction: (connectId, deviceId, params) =>
207
207
  call({ ...params, connectId, deviceId, method: 'suiSignTransaction' }),
208
+
209
+ cardanoGetAddress: (connectId, deviceId, params) =>
210
+ call({ ...params, connectId, deviceId, method: 'cardanoGetAddress' }),
211
+ cardanoGetPublicKey: (connectId, deviceId, params) =>
212
+ call({ ...params, connectId, deviceId, method: 'cardanoGetPublicKey' }),
213
+ cardanoSignTransaction: (connectId, deviceId, params) =>
214
+ call({ ...params, connectId, deviceId, method: 'cardanoSignTransaction' }),
208
215
  };
209
216
  return api;
210
217
  };