@onekeyfe/hd-transport 0.1.38 → 0.1.41

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 (38) hide show
  1. package/.eslintrc +3 -1
  2. package/__tests__/build-receive.test.js +117 -0
  3. package/__tests__/encode-decode-basic.test.js +272 -0
  4. package/__tests__/encode-decode.test.js +532 -0
  5. package/__tests__/messages.test.js +86 -0
  6. package/dist/index.d.ts +7 -6
  7. package/dist/index.js +133 -161
  8. package/dist/serialization/protobuf/decode.d.ts +1 -1
  9. package/dist/serialization/protobuf/decode.d.ts.map +1 -1
  10. package/dist/serialization/protobuf/encode.d.ts +1 -2
  11. package/dist/serialization/protobuf/encode.d.ts.map +1 -1
  12. package/dist/serialization/protocol/decode.d.ts +3 -3
  13. package/dist/serialization/protocol/decode.d.ts.map +1 -1
  14. package/dist/serialization/protocol/encode.d.ts +0 -1
  15. package/dist/serialization/protocol/encode.d.ts.map +1 -1
  16. package/dist/serialization/receive.d.ts.map +1 -1
  17. package/dist/serialization/send.d.ts +1 -2
  18. package/dist/serialization/send.d.ts.map +1 -1
  19. package/dist/utils/index.d.ts +3 -0
  20. package/dist/utils/index.d.ts.map +1 -0
  21. package/dist/utils/namespace.d.ts +2 -0
  22. package/dist/utils/namespace.d.ts.map +1 -0
  23. package/jest.config.js +7 -0
  24. package/package.json +5 -3
  25. package/scripts/protobuf-build.sh +57 -0
  26. package/scripts/protobuf-patches/TxAck.js +44 -0
  27. package/scripts/protobuf-patches/TxInputType.js +49 -0
  28. package/scripts/protobuf-patches/TxOutputType.js +50 -0
  29. package/scripts/protobuf-patches/index.js +305 -0
  30. package/scripts/protobuf-types.js +283 -0
  31. package/src/serialization/protobuf/decode.ts +1 -1
  32. package/src/serialization/protobuf/encode.ts +1 -1
  33. package/src/serialization/protocol/decode.ts +1 -1
  34. package/src/serialization/protocol/encode.ts +1 -1
  35. package/src/serialization/receive.ts +1 -1
  36. package/src/serialization/send.ts +1 -1
  37. package/src/utils/index.ts +6 -0
  38. package/src/utils/namespace.ts +3 -0
@@ -0,0 +1,3 @@
1
+ declare const ByteBuffer: any;
2
+ export { ByteBuffer };
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,UAAU,KAAuD,CAAC;AAExE,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function getDefaultExportFromNamespaceIfPresent(n: any): any;
2
+ //# sourceMappingURL=namespace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"namespace.d.ts","sourceRoot":"","sources":["../../src/utils/namespace.ts"],"names":[],"mappings":"AAAA,wBAAgB,sCAAsC,CAAC,CAAC,EAAE,GAAG,OAE5D"}
package/jest.config.js ADDED
@@ -0,0 +1,7 @@
1
+ module.exports = {
2
+ preset: '../../jest.config.js',
3
+ testEnvironment: 'node',
4
+ modulePathIgnorePatterns: ['node_modules', '<rootDir>/lib', '<rootDir>/libDev'],
5
+ collectCoverage: true,
6
+ // collectCoverageFrom: ['src/**/*.ts'],
7
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-transport",
3
- "version": "0.1.38",
3
+ "version": "0.1.41",
4
4
  "description": "> TODO: description",
5
5
  "author": "OneKey",
6
6
  "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
@@ -13,8 +13,10 @@
13
13
  "scripts": {
14
14
  "dev": "rimraf dist && rollup -c ../../build/rollup.config.js -w",
15
15
  "build": "rimraf dist && rollup -c ../../build/rollup.config.js",
16
+ "test": "jest",
16
17
  "lint": "eslint .",
17
- "lint:fix": "eslint . --fix"
18
+ "lint:fix": "eslint . --fix",
19
+ "update:protobuf": "./scripts/protobuf-build.sh"
18
20
  },
19
21
  "devDependencies": {
20
22
  "@types/bytebuffer": "^5.0.42"
@@ -24,5 +26,5 @@
24
26
  "long": "^4.0.0",
25
27
  "protobufjs": "^6.11.2"
26
28
  },
27
- "gitHead": "5828c78b10fca8604e158ef425a8c7314ece2bbf"
29
+ "gitHead": "0c5bf8f29b26ee02a5587aa716db4dfd7b17defd"
28
30
  }
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -euxo pipefail
4
+
5
+ echo $#
6
+
7
+ PARENT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
8
+
9
+ SRC="../../submodules/firmware/common/protob"
10
+ DIST="."
11
+ LANG="typescript"
12
+
13
+ if [[ $# -ne 0 && $# -ne 3 ]]
14
+ then
15
+ echo "must provide either 3 or 0 arguments. $# provided"
16
+ exit 1
17
+ fi
18
+
19
+ if [[ $# -eq 3 ]]
20
+ then
21
+ SRC=$1
22
+ DIST=$2
23
+ LANG=$3
24
+ fi
25
+
26
+ if [[ "$LANG" != "typescript" && "$LANG" != "flow" ]];
27
+ then
28
+ echo "either typescript or flow must be specified as the third argument"
29
+ exit 1
30
+ fi
31
+
32
+
33
+ # BUILD combined messages.proto file from protobuf files
34
+ # this code was copied from ./submodules/trezor-common/protob Makekile
35
+ # clear protobuf syntax and remove unknown values to be able to work with proto2js
36
+ echo 'syntax = "proto2";' > $DIST/messages.proto
37
+ echo 'import "google/protobuf/descriptor.proto";' >> $DIST/messages.proto
38
+ echo "Build proto file from $SRC"
39
+ grep -hv -e '^import ' -e '^syntax' -e '^package' -e 'option java_' $SRC/messages*.proto \
40
+ | sed 's/ hw\.trezor\.messages\.common\./ /' \
41
+ | sed 's/ common\./ /' \
42
+ | sed 's/ management\./ /' \
43
+ | sed 's/^option /\/\/ option /' \
44
+ | grep -v ' reserved '>> $DIST/messages.proto
45
+
46
+ # BUILD messages.json from message.proto
47
+ node_modules/.bin/pbjs -t json -p $DIST -o $DIST/messages.json --keep-case messages.proto
48
+ rm $DIST/messages.proto
49
+
50
+ echo "generating type definitions for: $LANG"
51
+
52
+ cd "$PARENT_PATH"
53
+
54
+ node ./protobuf-types.js $LANG
55
+
56
+ yarn prettier --write messages.json
57
+ yarn prettier --write **/messages.ts
@@ -0,0 +1,44 @@
1
+ // @flow
2
+
3
+ // TxAck replacement
4
+ // TxAck needs more exact types
5
+ // PrevInput and TxInputType requires exact responses in TxAckResponse
6
+ // main difference: PrevInput should not contain address_n (unexpected field by protobuf)
7
+
8
+ // @overhead-start this will be removed during compilation
9
+ type TxInputType = any;
10
+ type PrevInput = any;
11
+ type TxOutputBinType = any;
12
+ type TxOutputType = any;
13
+ // @overhead-end
14
+
15
+ export type TxAckResponse =
16
+ | {|
17
+ inputs: Array<TxInputType | PrevInput>,
18
+ |}
19
+ | {|
20
+ bin_outputs: TxOutputBinType[],
21
+ |}
22
+ | {|
23
+ outputs: TxOutputType[],
24
+ |}
25
+ | {|
26
+ extra_data: string,
27
+ |}
28
+ | {|
29
+ version?: number,
30
+ lock_time?: number,
31
+ inputs_cnt: number,
32
+ outputs_cnt: number,
33
+ extra_data?: string,
34
+ extra_data_len?: number,
35
+ timestamp?: number,
36
+ version_group_id?: number,
37
+ expiry?: number,
38
+ branch_id?: number,
39
+ |};
40
+
41
+ export type TxAck = {
42
+ tx: TxAckResponse,
43
+ };
44
+ // - TxAck replacement end
@@ -0,0 +1,49 @@
1
+ // @flow
2
+ // TxInputType replacement
3
+ // TxInputType needs more exact types
4
+ // differences: external input (no address_n + required script_pubkey)
5
+
6
+ // @overhead-start
7
+ // will be removed during compilation
8
+ type UintType = any;
9
+ type MultisigRedeemScriptType = any;
10
+ type InternalInputScriptType = any;
11
+ type DecredStakingSpendType = any;
12
+ // @overhead-end
13
+
14
+ // @flowtype-variant: export type InternalInputScriptType = $Keys<$Diff<typeof Enum_InputScriptType, { EXTERNAL: * }>>;
15
+ // @typescript-variant: export type InternalInputScriptType = Exclude<InputScriptType, 'EXTERNAL'>;
16
+
17
+ type CommonTxInputType = {|
18
+ prev_hash: string, // required: previous transaction hash (reversed)
19
+ prev_index: number, // required: previous transaction index
20
+ amount: UintType, // required
21
+ sequence?: number,
22
+ multisig?: MultisigRedeemScriptType,
23
+ decred_tree?: number,
24
+ orig_hash?: string, // RBF
25
+ orig_index?: number, // RBF
26
+ decred_staking_spend?: DecredStakingSpendType,
27
+ script_pubkey?: string, // required if script_type=EXTERNAL
28
+ script_sig?: string, // used by EXTERNAL, depending on script_pubkey
29
+ witness?: string, // used by EXTERNAL, depending on script_pubkey
30
+ ownership_proof?: string, // used by EXTERNAL, depending on script_pubkey
31
+ commitment_data?: string, // used by EXTERNAL, depending on ownership_proof
32
+ |};
33
+
34
+ export type TxInputType =
35
+ | {|
36
+ ...CommonTxInputType,
37
+ address_n: number[],
38
+ script_type?: InternalInputScriptType,
39
+ |}
40
+ | {|
41
+ ...CommonTxInputType,
42
+ address_n?: typeof undefined,
43
+ script_type: 'EXTERNAL',
44
+ script_pubkey: string,
45
+ |};
46
+
47
+ export type TxInput = TxInputType;
48
+
49
+ // TxInputType replacement end
@@ -0,0 +1,50 @@
1
+ // @flow
2
+ // TxOutputType replacement
3
+ // TxOutputType needs more exact types
4
+ // differences: external output (no address_n), opreturn output (no address_n, no address)
5
+
6
+ // @overhead-start
7
+ // will be removed during compilation
8
+ type UintType = any;
9
+ type MultisigRedeemScriptType = any;
10
+ type ChangeOutputScriptType = any;
11
+ // @overhead-end
12
+
13
+ // @typescript-variant: export type ChangeOutputScriptType = Exclude<OutputScriptType, 'PAYTOOPRETURN'>;
14
+ // @flowtype-variant: export type ChangeOutputScriptType = $Keys<$Diff<typeof Enum_OutputScriptType, { PAYTOOPRETURN: * }>>;
15
+
16
+ export type TxOutputType =
17
+ | {|
18
+ address: string,
19
+ address_n?: typeof undefined,
20
+ script_type: 'PAYTOADDRESS',
21
+ amount: UintType,
22
+ multisig?: MultisigRedeemScriptType,
23
+ orig_hash?: string,
24
+ orig_index?: number,
25
+ payment_req_index?: number,
26
+ |}
27
+ | {|
28
+ address?: typeof undefined,
29
+ address_n: number[],
30
+ script_type: ChangeOutputScriptType,
31
+ amount: UintType,
32
+ multisig?: MultisigRedeemScriptType,
33
+ orig_hash?: string,
34
+ orig_index?: number,
35
+ payment_req_index?: number,
36
+ |}
37
+ | {|
38
+ address?: typeof undefined,
39
+ address_n?: typeof undefined,
40
+ amount: '0',
41
+ op_return_data: string,
42
+ script_type: 'PAYTOOPRETURN',
43
+ orig_hash?: string,
44
+ orig_index?: number,
45
+ payment_req_index?: number,
46
+ |};
47
+
48
+ export type TxOutput = TxOutputType;
49
+
50
+ // - TxOutputType replacement end
@@ -0,0 +1,305 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ const UINT_TYPE = 'UintType';
5
+
6
+ // type rule fixes, ideally it should not be here
7
+ const RULE_PATCH = {
8
+ 'MultisigRedeemScriptType.nodes': 'optional', // its valid to be undefined according to implementation/tests
9
+ 'MultisigRedeemScriptType.address_n': 'optional', // its valid to be undefined according to implementation/tests
10
+ 'TxRequestDetailsType.request_index': 'required',
11
+ 'TxRequest.request_type': 'required',
12
+ 'TxRequest.details': 'required',
13
+ 'TxAckPaymentRequest.memos': 'optional', // protobuf repeated bytes are always optional (fallback to [])
14
+ 'CardanoPoolOwnerType.staking_key_path': 'optional',
15
+ 'CardanoPoolOwner.staking_key_path': 'optional',
16
+ 'CardanoTxCertificateType.path': 'optional',
17
+ 'CardanoTxCertificate.path': 'optional',
18
+ 'CardanoTxInputType.address_n': 'optional',
19
+ 'CardanoTxWithdrawal.path': 'optional',
20
+ 'CardanoNativeScript.scripts': 'optional',
21
+ 'CardanoNativeScript.key_path': 'optional',
22
+ 'CardanoTxRequiredSigner.key_path': 'optional',
23
+ 'Success.message': 'required', // didn't find use case where it's not sent
24
+ 'SignedIdentity.address': 'required',
25
+ 'EosAuthorizationKey.key': 'required', // its valid to be undefined according to implementation/tests
26
+ 'EosAuthorizationKey.type': 'optional', // its valid to be undefined according to implementation/tests
27
+ 'EosAuthorizationKey.address_n': 'optional', // its valid to be undefined according to implementation/tests
28
+ 'EthereumAddress.address': 'required', // address is transformed from legacy type _old_address
29
+ // TODO: Features should be union: bootloader|normal
30
+ // fields below are marked as required because of backward compatibility (suite implementation)
31
+ 'Features.vendor': 'required',
32
+ 'Features.bootloader_mode': 'required',
33
+ 'Features.device_id': 'required',
34
+ 'Features.major_version': 'required',
35
+ 'Features.minor_version': 'required',
36
+ 'Features.patch_version': 'required',
37
+ 'Features.pin_protection': 'required',
38
+ 'Features.passphrase_protection': 'required',
39
+ 'Features.language': 'required',
40
+ 'Features.label': 'required',
41
+ 'Features.initialized': 'required',
42
+ 'Features.revision': 'required',
43
+ 'Features.bootloader_hash': 'required',
44
+ 'Features.imported': 'required',
45
+ 'Features.unlocked': 'required',
46
+ 'Features.firmware_present': 'required',
47
+ 'Features.needs_backup': 'required',
48
+ 'Features.flags': 'required',
49
+ 'Features.fw_major': 'required',
50
+ 'Features.fw_minor': 'required',
51
+ 'Features.fw_patch': 'required',
52
+ 'Features.fw_vendor': 'required',
53
+ 'Features.model': 'required',
54
+ 'Features.unfinished_backup': 'required',
55
+ 'Features.no_backup': 'required',
56
+ 'Features.recovery_mode': 'required',
57
+ 'Features.backup_type': 'required',
58
+ 'Features.sd_card_present': 'required',
59
+ 'Features.sd_protection': 'required',
60
+ 'Features.wipe_code_protection': 'required',
61
+ 'Features.session_id': 'required',
62
+ 'Features.passphrase_always_on_device': 'required',
63
+ 'Features.safety_checks': 'required',
64
+ 'Features.auto_lock_delay_ms': 'required',
65
+ 'Features.display_rotation': 'required',
66
+ 'Features.experimental_features': 'required',
67
+ 'GetOwnershipProof.ownership_ids': 'optional', // protobuf repeated bytes are always optional (fallback to [])
68
+ 'NEMTransactionCommon.address_n': 'optional', // no address_n in multisig
69
+ 'NEMTransfer.mosaics': 'optional', // its valid to be undefined according to implementation/tests
70
+ 'NEMMosaicDefinition.networks': 'optional', // never used according to implementation/tests
71
+ 'NEMAggregateModification.modifications': 'optional', // its valid to be undefined according to implementation/tests
72
+ 'StellarAssetType.code': 'required',
73
+ 'StellarPathPaymentStrictReceiveOp.paths': 'optional', // its valid to be undefined according to implementation/tests
74
+ 'StellarPathPaymentStrictSendOp.paths': 'optional', // its valid to be undefined according to implementation/tests
75
+ };
76
+
77
+ // custom types IN to trezor
78
+ // protobuf lib will handle the translation to required type
79
+ // connect or other 3rd party libs are using compatible types (string as number etc...)
80
+ const TYPE_PATCH = {
81
+ 'Features.bootloader_mode': 'boolean | null',
82
+ 'Features.device_id': 'string | null',
83
+ 'Features.pin_protection': 'boolean | null',
84
+ 'Features.passphrase_protection': 'boolean | null',
85
+ 'Features.language': 'string | null',
86
+ 'Features.label': 'string | null',
87
+ 'Features.initialized': 'boolean | null',
88
+ 'Features.revision': 'string | null',
89
+ 'Features.bootloader_hash': 'string | null',
90
+ 'Features.imported': 'boolean | null',
91
+ 'Features.unlocked': 'boolean | null',
92
+ 'Features.firmware_present': 'boolean | null',
93
+ 'Features.needs_backup': 'boolean | null',
94
+ 'Features.flags': 'number | null',
95
+ 'Features.fw_major': 'number | null',
96
+ 'Features.fw_minor': 'number | null',
97
+ 'Features.fw_patch': 'number | null',
98
+ 'Features.fw_vendor': 'string | null',
99
+ 'Features.unfinished_backup': 'boolean | null',
100
+ 'Features.no_backup': 'boolean | null',
101
+ 'Features.recovery_mode': 'boolean | null',
102
+ 'Features.backup_type': 'BackupType | null',
103
+ 'Features.sd_card_present': 'boolean | null',
104
+ 'Features.sd_protection': 'boolean | null',
105
+ 'Features.wipe_code_protection': 'boolean | null',
106
+ 'Features.session_id': 'string | null',
107
+ 'Features.passphrase_always_on_device': 'boolean | null',
108
+ 'Features.safety_checks': 'SafetyCheckLevel | null',
109
+ 'Features.auto_lock_delay_ms': 'number | null',
110
+ 'Features.display_rotation': 'number | null',
111
+ 'Features.experimental_features': 'boolean | null',
112
+ 'HDNodePathType.node': 'HDNodeType | string',
113
+ 'FirmwareUpload.payload': 'Buffer | ArrayBuffer',
114
+ 'CardanoCatalystRegistrationParametersType.nonce': UINT_TYPE,
115
+ 'CardanoPoolParametersType.pledge': UINT_TYPE,
116
+ 'CardanoPoolParametersType.cost': UINT_TYPE,
117
+ 'CardanoPoolParametersType.margin_numerator': UINT_TYPE,
118
+ 'CardanoPoolParametersType.margin_denominator': UINT_TYPE,
119
+ 'CardanoSignTx.ttl': UINT_TYPE,
120
+ 'CardanoSignTx.validity_interval_start': UINT_TYPE,
121
+ 'CardanoSignTxInit.ttl': UINT_TYPE,
122
+ 'CardanoSignTxInit.validity_interval_start': UINT_TYPE,
123
+ 'CardanoToken.mint_amount': UINT_TYPE,
124
+ 'CardanoNativeScript.invalid_before': UINT_TYPE,
125
+ 'CardanoNativeScript.invalid_hereafter': UINT_TYPE,
126
+ 'EosAsset.symbol': 'string',
127
+ 'EosPermissionLevel.actor': 'string',
128
+ 'EosPermissionLevel.permission': 'string',
129
+ 'EosAuthorizationKey.key': 'string',
130
+ 'EosActionCommon.account': 'string',
131
+ 'EosActionCommon.name': 'string',
132
+ 'EosActionTransfer.sender': 'string',
133
+ 'EosActionTransfer.receiver': 'string',
134
+ 'EosActionDelegate.sender': 'string',
135
+ 'EosActionDelegate.receiver': 'string',
136
+ 'EosActionUndelegate.sender': 'string',
137
+ 'EosActionUndelegate.receiver': 'string',
138
+ 'EosActionRefund.owner': 'string',
139
+ 'EosActionBuyRam.payer': 'string',
140
+ 'EosActionBuyRam.receiver': 'string',
141
+ 'EosActionBuyRamBytes.payer': 'string',
142
+ 'EosActionBuyRamBytes.receiver': 'string',
143
+ 'EosActionSellRam.account': 'string',
144
+ 'EosActionVoteProducer.voter': 'string',
145
+ 'EosActionVoteProducer.proxy': 'string',
146
+ 'EosActionVoteProducer.producers': 'string',
147
+ 'EosActionUpdateAuth.account': 'string',
148
+ 'EosActionUpdateAuth.permission': 'string',
149
+ 'EosActionUpdateAuth.parent': 'string',
150
+ 'EosActionDeleteAuth.account': 'string',
151
+ 'EosActionDeleteAuth.permission': 'string',
152
+ 'EosActionLinkAuth.account': 'string',
153
+ 'EosActionLinkAuth.code': 'string',
154
+ 'EosActionLinkAuth.type': 'string',
155
+ 'EosActionLinkAuth.requirement': 'string',
156
+ 'EosActionUnlinkAuth.account': 'string',
157
+ 'EosActionUnlinkAuth.code': 'string',
158
+ 'EosActionUnlinkAuth.type': 'string',
159
+ 'EosActionNewAccount.creator': 'string',
160
+ 'EosActionNewAccount.name': 'string',
161
+ 'ResetDevice.backup_type': 'string | number', // BackupType is a enum. in Features displayed as string, in resetDevice method param accepted as number
162
+ 'StellarAssetType.type': '0 | 1 | 2',
163
+ 'StellarSignTx.sequence_number': UINT_TYPE,
164
+ 'StellarSignTx.memo_id': 'string',
165
+ 'StellarSignTx.memo_hash': 'Buffer | string',
166
+ 'StellarCreateAccountOp.starting_balance': UINT_TYPE,
167
+ 'StellarPathPaymentStrictReceiveOp.send_max': UINT_TYPE,
168
+ 'StellarPathPaymentStrictReceiveOp.destination_amount': UINT_TYPE,
169
+ 'StellarPathPaymentStrictSendOp.send_amount': UINT_TYPE,
170
+ 'StellarPathPaymentStrictSendOp.destination_min': UINT_TYPE,
171
+ 'StellarManageSellOfferOp.offer_id': UINT_TYPE,
172
+ 'StellarManageBuyOfferOp.offer_id': UINT_TYPE,
173
+ 'StellarSetOptionsOp.master_weight': UINT_TYPE,
174
+ 'StellarSetOptionsOp.low_threshold': UINT_TYPE,
175
+ 'StellarSetOptionsOp.medium_threshold': UINT_TYPE,
176
+ 'StellarSetOptionsOp.high_threshold': UINT_TYPE,
177
+ 'StellarSetOptionsOp.signer_key': 'Buffer | string',
178
+ 'StellarChangeTrustOp.limit': UINT_TYPE,
179
+ 'StellarManageDataOp.value': 'Buffer | string',
180
+ 'StellarBumpSequenceOp.bump_to': UINT_TYPE,
181
+ 'TezosContractID.tag': 'number',
182
+ 'TezosContractID.hash': 'Uint8Array',
183
+ 'TezosRevealOp.source': 'Uint8Array',
184
+ 'TezosRevealOp.public_key': 'Uint8Array',
185
+ 'TezosParametersManager.set_delegate': 'Uint8Array',
186
+ 'TezosTransactionOp.source': 'Uint8Array',
187
+ 'TezosTransactionOp.parameters': 'number[]',
188
+ 'TezosOriginationOp.source': 'Uint8Array',
189
+ 'TezosOriginationOp.delegate': 'Uint8Array',
190
+ 'TezosOriginationOp.script': 'string | number[]',
191
+ 'TezosDelegationOp.source': 'Uint8Array',
192
+ 'TezosDelegationOp.delegate': 'Uint8Array',
193
+ 'TezosSignTx.branch': 'Uint8Array',
194
+ };
195
+
196
+ const DEFINITION_PATCH = {
197
+ TxInputType: fs.readFileSync(path.join(__dirname, './TxInputType.js'), 'utf8'),
198
+ TxOutputType: fs.readFileSync(path.join(__dirname, './TxOutputType.js'), 'utf8'),
199
+ TxAck: fs.readFileSync(path.join(__dirname, './TxAck.js'), 'utf8'),
200
+ };
201
+
202
+ // skip unnecessary types
203
+ const SKIP = [
204
+ 'MessageType', // connect uses custom definition
205
+ 'TransactionType', // connect uses custom definition
206
+ 'TxInput', // declared in TxInputType patch
207
+ 'TxOutput', // declared in TxOutputType patch
208
+ // not implemented
209
+ 'CosiCommit',
210
+ 'CosiCommitment',
211
+ 'CosiSign',
212
+ 'CosiSignature',
213
+ 'DebugSwipeDirection',
214
+ 'DebugLinkDecision',
215
+ 'DebugLinkLayout',
216
+ 'DebugLinkReseedRandom',
217
+ 'DebugLinkRecordScreen',
218
+ 'DebugLinkGetState',
219
+ 'DebugLinkState',
220
+ 'DebugLinkStop',
221
+ 'DebugLinkLog',
222
+ 'DebugLinkMemoryRead',
223
+ 'DebugLinkMemory',
224
+ 'DebugLinkMemoryWrite',
225
+ 'DebugLinkFlashErase',
226
+ 'DebugLinkEraseSdCard',
227
+ 'DebugLinkWatchLayout',
228
+ 'LoadDevice',
229
+ 'MoneroRctKeyPublic',
230
+ 'MoneroOutputEntry',
231
+ 'MoneroMultisigKLRki',
232
+ 'MoneroTransactionSourceEntry',
233
+ 'MoneroAccountPublicAddress',
234
+ 'MoneroTransactionDestinationEntry',
235
+ 'MoneroTransactionRsigData',
236
+ 'MoneroGetAddress',
237
+ 'MoneroAddress',
238
+ 'MoneroGetWatchKey',
239
+ 'MoneroWatchKey',
240
+ 'MoneroTransactionData',
241
+ 'MoneroTransactionInitRequest',
242
+ 'MoneroTransactionInitAck',
243
+ 'MoneroTransactionSetInputRequest',
244
+ 'MoneroTransactionSetInputAck',
245
+ 'MoneroTransactionInputsPermutationRequest',
246
+ 'MoneroTransactionInputsPermutationAck',
247
+ 'MoneroTransactionInputViniRequest',
248
+ 'MoneroTransactionInputViniAck',
249
+ 'MoneroTransactionAllInputsSetRequest',
250
+ 'MoneroTransactionAllInputsSetAck',
251
+ 'MoneroTransactionSetOutputRequest',
252
+ 'MoneroTransactionSetOutputAck',
253
+ 'MoneroTransactionAllOutSetRequest',
254
+ 'MoneroRingCtSig',
255
+ 'MoneroTransactionAllOutSetAck',
256
+ 'MoneroTransactionSignInputRequest',
257
+ 'MoneroTransactionSignInputAck',
258
+ 'MoneroTransactionFinalRequest',
259
+ 'MoneroTransactionFinalAck',
260
+ 'MoneroSubAddressIndicesList',
261
+ 'MoneroKeyImageExportInitRequest',
262
+ 'MoneroKeyImageExportInitAck',
263
+ 'MoneroTransferDetails',
264
+ 'MoneroKeyImageSyncStepRequest',
265
+ 'MoneroExportedKeyImage',
266
+ 'MoneroKeyImageSyncStepAck',
267
+ 'MoneroKeyImageSyncFinalRequest',
268
+ 'MoneroKeyImageSyncFinalAck',
269
+ 'MoneroGetTxKeyRequest',
270
+ 'MoneroGetTxKeyAck',
271
+ 'MoneroLiveRefreshStartRequest',
272
+ 'MoneroLiveRefreshStartAck',
273
+ 'MoneroLiveRefreshStepRequest',
274
+ 'MoneroLiveRefreshStepAck',
275
+ 'MoneroLiveRefreshFinalRequest',
276
+ 'MoneroLiveRefreshFinalAck',
277
+ 'DebugMoneroDiagRequest',
278
+ 'DebugMoneroDiagAck',
279
+ 'WebAuthnListResidentCredentials',
280
+ 'WebAuthnAddResidentCredential',
281
+ 'WebAuthnRemoveResidentCredential',
282
+ 'WebAuthnCredential',
283
+ 'WebAuthnCredentials',
284
+ 'wire_in',
285
+ 'wire_out',
286
+ 'wire_debug_in',
287
+ 'wire_debug_out',
288
+ 'wire_tiny',
289
+ 'wire_bootloader',
290
+ 'wire_no_fsm',
291
+ 'bitcoin_only',
292
+ 'has_bitcoin_only_values',
293
+ 'unstable',
294
+ 'wire_type',
295
+ 'experimental',
296
+ 'include_in_bitcoin_only',
297
+ ];
298
+
299
+ module.exports = {
300
+ RULE_PATCH,
301
+ TYPE_PATCH,
302
+ DEFINITION_PATCH,
303
+ SKIP,
304
+ UINT_TYPE,
305
+ };