@cardano-sdk/hardware-ledger 0.2.0
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/LICENSE +201 -0
- package/NOTICE +5 -0
- package/README.md +1 -0
- package/dist/cjs/LedgerKeyAgent.d.ts +43 -0
- package/dist/cjs/LedgerKeyAgent.d.ts.map +1 -0
- package/dist/cjs/LedgerKeyAgent.js +269 -0
- package/dist/cjs/LedgerKeyAgent.js.map +1 -0
- package/dist/cjs/index.d.ts +4 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +20 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/transformers/assets.d.ts +4 -0
- package/dist/cjs/transformers/assets.d.ts.map +1 -0
- package/dist/cjs/transformers/assets.js +50 -0
- package/dist/cjs/transformers/assets.js.map +1 -0
- package/dist/cjs/transformers/auxiliaryData.d.ts +10 -0
- package/dist/cjs/transformers/auxiliaryData.d.ts.map +1 -0
- package/dist/cjs/transformers/auxiliaryData.js +13 -0
- package/dist/cjs/transformers/auxiliaryData.js.map +1 -0
- package/dist/cjs/transformers/certificates.d.ts +8 -0
- package/dist/cjs/transformers/certificates.d.ts.map +1 -0
- package/dist/cjs/transformers/certificates.js +238 -0
- package/dist/cjs/transformers/certificates.js.map +1 -0
- package/dist/cjs/transformers/collateralInputs.d.ts +5 -0
- package/dist/cjs/transformers/collateralInputs.d.ts.map +1 -0
- package/dist/cjs/transformers/collateralInputs.js +7 -0
- package/dist/cjs/transformers/collateralInputs.js.map +1 -0
- package/dist/cjs/transformers/collateralOutput.d.ts +17 -0
- package/dist/cjs/transformers/collateralOutput.d.ts.map +1 -0
- package/dist/cjs/transformers/collateralOutput.js +7 -0
- package/dist/cjs/transformers/collateralOutput.js.map +1 -0
- package/dist/cjs/transformers/index.d.ts +13 -0
- package/dist/cjs/transformers/index.d.ts.map +1 -0
- package/dist/cjs/transformers/index.js +29 -0
- package/dist/cjs/transformers/index.js.map +1 -0
- package/dist/cjs/transformers/keyPaths.d.ts +5 -0
- package/dist/cjs/transformers/keyPaths.d.ts.map +1 -0
- package/dist/cjs/transformers/keyPaths.js +28 -0
- package/dist/cjs/transformers/keyPaths.js.map +1 -0
- package/dist/cjs/transformers/referenceInputs.d.ts +4 -0
- package/dist/cjs/transformers/referenceInputs.d.ts.map +1 -0
- package/dist/cjs/transformers/referenceInputs.js +12 -0
- package/dist/cjs/transformers/referenceInputs.js.map +1 -0
- package/dist/cjs/transformers/requiredSigners.d.ts +7 -0
- package/dist/cjs/transformers/requiredSigners.d.ts.map +1 -0
- package/dist/cjs/transformers/requiredSigners.js +59 -0
- package/dist/cjs/transformers/requiredSigners.js.map +1 -0
- package/dist/cjs/transformers/tx.d.ts +7 -0
- package/dist/cjs/transformers/tx.d.ts.map +1 -0
- package/dist/cjs/transformers/tx.js +39 -0
- package/dist/cjs/transformers/tx.js.map +1 -0
- package/dist/cjs/transformers/txIn.d.ts +7 -0
- package/dist/cjs/transformers/txIn.d.ts.map +1 -0
- package/dist/cjs/transformers/txIn.js +27 -0
- package/dist/cjs/transformers/txIn.js.map +1 -0
- package/dist/cjs/transformers/txOut.d.ts +7 -0
- package/dist/cjs/transformers/txOut.d.ts.map +1 -0
- package/dist/cjs/transformers/txOut.js +100 -0
- package/dist/cjs/transformers/txOut.js.map +1 -0
- package/dist/cjs/transformers/withdrawals.d.ts +7 -0
- package/dist/cjs/transformers/withdrawals.d.ts.map +1 -0
- package/dist/cjs/transformers/withdrawals.js +84 -0
- package/dist/cjs/transformers/withdrawals.js.map +1 -0
- package/dist/cjs/tsconfig.tsbuildinfo +1 -0
- package/dist/cjs/types.d.ts +14 -0
- package/dist/cjs/types.d.ts.map +1 -0
- package/dist/cjs/types.js +8 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/esm/LedgerKeyAgent.d.ts +43 -0
- package/dist/esm/LedgerKeyAgent.d.ts.map +1 -0
- package/dist/esm/LedgerKeyAgent.js +239 -0
- package/dist/esm/LedgerKeyAgent.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +4 -0
- package/dist/esm/transformers/assets.d.ts +4 -0
- package/dist/esm/transformers/assets.d.ts.map +1 -0
- package/dist/esm/transformers/assets.js +46 -0
- package/dist/esm/transformers/assets.js.map +1 -0
- package/dist/esm/transformers/auxiliaryData.d.ts +10 -0
- package/dist/esm/transformers/auxiliaryData.d.ts.map +1 -0
- package/dist/esm/transformers/auxiliaryData.js +9 -0
- package/dist/esm/transformers/auxiliaryData.js.map +1 -0
- package/dist/esm/transformers/certificates.d.ts +8 -0
- package/dist/esm/transformers/certificates.d.ts.map +1 -0
- package/dist/esm/transformers/certificates.js +209 -0
- package/dist/esm/transformers/certificates.js.map +1 -0
- package/dist/esm/transformers/collateralInputs.d.ts +5 -0
- package/dist/esm/transformers/collateralInputs.d.ts.map +1 -0
- package/dist/esm/transformers/collateralInputs.js +3 -0
- package/dist/esm/transformers/collateralInputs.js.map +1 -0
- package/dist/esm/transformers/collateralOutput.d.ts +17 -0
- package/dist/esm/transformers/collateralOutput.d.ts.map +1 -0
- package/dist/esm/transformers/collateralOutput.js +3 -0
- package/dist/esm/transformers/collateralOutput.js.map +1 -0
- package/dist/esm/transformers/index.d.ts +13 -0
- package/dist/esm/transformers/index.d.ts.map +1 -0
- package/dist/esm/transformers/index.js +13 -0
- package/dist/esm/transformers/index.js.map +1 -0
- package/dist/esm/transformers/keyPaths.d.ts +5 -0
- package/dist/esm/transformers/keyPaths.d.ts.map +1 -0
- package/dist/esm/transformers/keyPaths.js +23 -0
- package/dist/esm/transformers/keyPaths.js.map +1 -0
- package/dist/esm/transformers/referenceInputs.d.ts +4 -0
- package/dist/esm/transformers/referenceInputs.d.ts.map +1 -0
- package/dist/esm/transformers/referenceInputs.js +8 -0
- package/dist/esm/transformers/referenceInputs.js.map +1 -0
- package/dist/esm/transformers/requiredSigners.d.ts +7 -0
- package/dist/esm/transformers/requiredSigners.d.ts.map +1 -0
- package/dist/esm/transformers/requiredSigners.js +31 -0
- package/dist/esm/transformers/requiredSigners.js.map +1 -0
- package/dist/esm/transformers/tx.d.ts +7 -0
- package/dist/esm/transformers/tx.d.ts.map +1 -0
- package/dist/esm/transformers/tx.js +35 -0
- package/dist/esm/transformers/tx.js.map +1 -0
- package/dist/esm/transformers/txIn.d.ts +7 -0
- package/dist/esm/transformers/txIn.d.ts.map +1 -0
- package/dist/esm/transformers/txIn.js +22 -0
- package/dist/esm/transformers/txIn.js.map +1 -0
- package/dist/esm/transformers/txOut.d.ts +7 -0
- package/dist/esm/transformers/txOut.d.ts.map +1 -0
- package/dist/esm/transformers/txOut.js +72 -0
- package/dist/esm/transformers/txOut.js.map +1 -0
- package/dist/esm/transformers/withdrawals.d.ts +7 -0
- package/dist/esm/transformers/withdrawals.d.ts.map +1 -0
- package/dist/esm/transformers/withdrawals.js +56 -0
- package/dist/esm/transformers/withdrawals.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -0
- package/dist/esm/types.d.ts +14 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +5 -0
- package/dist/esm/types.js.map +1 -0
- package/package.json +81 -0
package/LICENSE
ADDED
@@ -0,0 +1,201 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
177
|
+
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
179
|
+
|
180
|
+
To apply the Apache License to your work, attach the following
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
182
|
+
replaced with your own identifying information. (Don't include
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
184
|
+
comment syntax for the file format. We also recommend that a
|
185
|
+
file or class name and description of purpose be included on the
|
186
|
+
same "printed page" as the copyright notice for easier
|
187
|
+
identification within third-party archives.
|
188
|
+
|
189
|
+
Copyright © 2022 IOHK
|
190
|
+
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192
|
+
you may not use this file except in compliance with the License.
|
193
|
+
You may obtain a copy of the License at
|
194
|
+
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
196
|
+
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200
|
+
See the License for the specific language governing permissions and
|
201
|
+
limitations under the License.
|
package/NOTICE
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
Copyright 2022 IOHK
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License”). You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.txt
|
4
|
+
|
5
|
+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
package/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Cardano JS SDK | Hardware | Ledger
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import * as Crypto from '@cardano-sdk/crypto';
|
2
|
+
import { Cardano } from '@cardano-sdk/core';
|
3
|
+
import { CommunicationType, KeyAgentBase, KeyAgentDependencies, SerializableLedgerKeyAgentData, SignBlobResult } from '@cardano-sdk/key-management';
|
4
|
+
import { LedgerTransportType } from './types';
|
5
|
+
import LedgerConnection, { GetVersionResponse, Transaction, TransactionSigningMode } from '@cardano-foundation/ledgerjs-hw-app-cardano';
|
6
|
+
import type LedgerTransport from '@ledgerhq/hw-transport';
|
7
|
+
export interface LedgerKeyAgentProps extends Omit<SerializableLedgerKeyAgentData, '__typename'> {
|
8
|
+
deviceConnection?: LedgerConnection;
|
9
|
+
}
|
10
|
+
export interface CreateLedgerKeyAgentProps {
|
11
|
+
chainId: Cardano.ChainId;
|
12
|
+
accountIndex?: number;
|
13
|
+
communicationType: CommunicationType;
|
14
|
+
deviceConnection?: LedgerConnection | null;
|
15
|
+
}
|
16
|
+
export interface GetLedgerXpubProps {
|
17
|
+
deviceConnection?: LedgerConnection;
|
18
|
+
communicationType: CommunicationType;
|
19
|
+
accountIndex: number;
|
20
|
+
}
|
21
|
+
export interface CreateLedgerTransportProps {
|
22
|
+
communicationType: CommunicationType;
|
23
|
+
activeTransport?: LedgerTransportType;
|
24
|
+
devicePath?: string;
|
25
|
+
}
|
26
|
+
export declare class LedgerKeyAgent extends KeyAgentBase {
|
27
|
+
#private;
|
28
|
+
readonly deviceConnection?: LedgerConnection;
|
29
|
+
constructor({ deviceConnection, ...serializableData }: LedgerKeyAgentProps, dependencies: KeyAgentDependencies);
|
30
|
+
static getHidDeviceList(communicationType: CommunicationType): Promise<string[]>;
|
31
|
+
static createTransport({ communicationType, activeTransport, devicePath }: CreateLedgerTransportProps): Promise<LedgerTransportType>;
|
32
|
+
static createDeviceConnection(activeTransport: LedgerTransport): Promise<LedgerConnection>;
|
33
|
+
static establishDeviceConnection(communicationType: CommunicationType, devicePath?: string): Promise<LedgerConnection>;
|
34
|
+
static checkDeviceConnection(communicationType: CommunicationType, deviceConnection?: LedgerConnection): Promise<LedgerConnection>;
|
35
|
+
static getXpub({ deviceConnection, communicationType, accountIndex }: GetLedgerXpubProps): Promise<Crypto.Bip32PublicKeyHex>;
|
36
|
+
static getAppVersion(communicationType: CommunicationType, deviceConnection?: LedgerConnection): Promise<GetVersionResponse>;
|
37
|
+
static createWithDevice({ chainId, accountIndex, communicationType, deviceConnection }: CreateLedgerKeyAgentProps, dependencies: KeyAgentDependencies): Promise<LedgerKeyAgent>;
|
38
|
+
static getSigningMode(tx: Transaction): TransactionSigningMode;
|
39
|
+
signTransaction({ body, hash }: Cardano.TxBodyWithHash): Promise<Cardano.Signatures>;
|
40
|
+
signBlob(): Promise<SignBlobResult>;
|
41
|
+
exportRootPrivateKey(): Promise<Crypto.Bip32PrivateKeyHex>;
|
42
|
+
}
|
43
|
+
//# sourceMappingURL=LedgerKeyAgent.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"LedgerKeyAgent.d.ts","sourceRoot":"","sources":["../../src/LedgerKeyAgent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAuB,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAGL,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,EAEpB,8BAA8B,EAC9B,cAAc,EAEf,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAI9C,OAAO,gBAAgB,EAAE,EAGvB,kBAAkB,EAKlB,WAAW,EACX,sBAAsB,EAEvB,MAAM,6CAA6C,CAAC;AAGrD,OAAO,KAAK,eAAe,MAAM,wBAAwB,CAAC;AAE1D,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAAC,8BAA8B,EAAE,YAAY,CAAC;IAC7F,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC;AAED,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,gBAAgB,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;CAC5C;AAED,MAAM,WAAW,kBAAk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AE,EAAE,yBAAyB,EAC7F,YAAY,EAAE,oBAAoB;IA+BpC,MAAM,CAAC,cAAc,CAAC,EAAE,EAAE,WAAW,GAAG,sBAAsB;IAqCxD,eAAe,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,OAAO,CAAC,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC;IA+CpF,QAAQ,IAAI,OAAO,CAAC,cAAc,CAAC;IAInC,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC;CAGjE"}
|
@@ -0,0 +1,269 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
24
|
+
};
|
25
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
26
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
27
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
28
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
29
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
30
|
+
};
|
31
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
32
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
33
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
34
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
35
|
+
};
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
38
|
+
};
|
39
|
+
var _LedgerKeyAgent_communicationType;
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
41
|
+
exports.LedgerKeyAgent = void 0;
|
42
|
+
const Crypto = __importStar(require("@cardano-sdk/crypto"));
|
43
|
+
const core_1 = require("@cardano-sdk/core");
|
44
|
+
const key_management_1 = require("@cardano-sdk/key-management");
|
45
|
+
const util_1 = require("@cardano-sdk/util");
|
46
|
+
const address_1 = require("@cardano-foundation/ledgerjs-hw-app-cardano/dist/utils/address");
|
47
|
+
const transformers_1 = require("./transformers");
|
48
|
+
const ledgerjs_hw_app_cardano_1 = __importStar(require("@cardano-foundation/ledgerjs-hw-app-cardano"));
|
49
|
+
const hw_transport_node_hid_noevents_1 = __importDefault(require("@ledgerhq/hw-transport-node-hid-noevents"));
|
50
|
+
const hw_transport_webhid_1 = __importDefault(require("@ledgerhq/hw-transport-webhid"));
|
51
|
+
const transportTypedError = (error) => new key_management_1.errors.TransportError('Ledger transport failed', error);
|
52
|
+
const hasRegistrationOrRetirementCerts = (certificates) => {
|
53
|
+
if (!certificates)
|
54
|
+
return false;
|
55
|
+
return (certificates.some((cert) => cert.type === ledgerjs_hw_app_cardano_1.CertificateType.STAKE_POOL_RETIREMENT) ||
|
56
|
+
certificates.some((cert) => cert.type === ledgerjs_hw_app_cardano_1.CertificateType.STAKE_POOL_REGISTRATION));
|
57
|
+
};
|
58
|
+
const stakeCredentialCert = (cert) => cert.type === ledgerjs_hw_app_cardano_1.CertificateType.STAKE_REGISTRATION ||
|
59
|
+
cert.type === ledgerjs_hw_app_cardano_1.CertificateType.STAKE_DEREGISTRATION ||
|
60
|
+
cert.type === ledgerjs_hw_app_cardano_1.CertificateType.STAKE_DELEGATION;
|
61
|
+
const containsOnlyScriptHashCreds = (tx) => {
|
62
|
+
const withdrawalsAllScriptHash = !tx.withdrawals?.some((withdrawal) => withdrawal.stakeCredential.type !== ledgerjs_hw_app_cardano_1.StakeCredentialParamsType.SCRIPT_HASH);
|
63
|
+
if (tx.certificates) {
|
64
|
+
for (const cert of tx.certificates) {
|
65
|
+
if (!stakeCredentialCert(cert))
|
66
|
+
return false;
|
67
|
+
const certParams = cert.params;
|
68
|
+
if (certParams.stakeCredential.type !== ledgerjs_hw_app_cardano_1.StakeCredentialParamsType.SCRIPT_HASH)
|
69
|
+
return false;
|
70
|
+
}
|
71
|
+
}
|
72
|
+
return withdrawalsAllScriptHash;
|
73
|
+
};
|
74
|
+
const isMultiSig = (tx) => {
|
75
|
+
const result = false;
|
76
|
+
const allThirdPartyInputs = !tx.inputs.some((input) => input.path !== null);
|
77
|
+
const allThirdPartyOutputs = !tx.outputs.some((out) => out.destination.type !== ledgerjs_hw_app_cardano_1.TxOutputDestinationType.THIRD_PARTY);
|
78
|
+
if (allThirdPartyInputs &&
|
79
|
+
allThirdPartyOutputs &&
|
80
|
+
!tx.collateralInputs &&
|
81
|
+
!tx.requiredSigners &&
|
82
|
+
!hasRegistrationOrRetirementCerts(tx.certificates) &&
|
83
|
+
containsOnlyScriptHashCreds(tx)) {
|
84
|
+
return true;
|
85
|
+
}
|
86
|
+
return result;
|
87
|
+
};
|
88
|
+
class LedgerKeyAgent extends key_management_1.KeyAgentBase {
|
89
|
+
constructor({ deviceConnection, ...serializableData }, dependencies) {
|
90
|
+
super({ ...serializableData, __typename: key_management_1.KeyAgentType.Ledger }, dependencies);
|
91
|
+
_LedgerKeyAgent_communicationType.set(this, void 0);
|
92
|
+
this.deviceConnection = deviceConnection;
|
93
|
+
__classPrivateFieldSet(this, _LedgerKeyAgent_communicationType, serializableData.communicationType, "f");
|
94
|
+
}
|
95
|
+
static async getHidDeviceList(communicationType) {
|
96
|
+
try {
|
97
|
+
return communicationType === key_management_1.CommunicationType.Node ? hw_transport_node_hid_noevents_1.default.list() : hw_transport_webhid_1.default.list();
|
98
|
+
}
|
99
|
+
catch (error) {
|
100
|
+
throw new key_management_1.errors.TransportError('Cannot fetch device list', error);
|
101
|
+
}
|
102
|
+
}
|
103
|
+
static async createTransport({ communicationType, activeTransport, devicePath = '' }) {
|
104
|
+
try {
|
105
|
+
if (communicationType === key_management_1.CommunicationType.Node) {
|
106
|
+
return await hw_transport_node_hid_noevents_1.default.open(devicePath);
|
107
|
+
}
|
108
|
+
return await (activeTransport && activeTransport instanceof hw_transport_webhid_1.default
|
109
|
+
? hw_transport_webhid_1.default.open(activeTransport.device)
|
110
|
+
: hw_transport_webhid_1.default.request());
|
111
|
+
}
|
112
|
+
catch (error) {
|
113
|
+
throw new key_management_1.errors.TransportError('Creating transport failed', error);
|
114
|
+
}
|
115
|
+
}
|
116
|
+
static async createDeviceConnection(activeTransport) {
|
117
|
+
try {
|
118
|
+
const deviceConnection = new ledgerjs_hw_app_cardano_1.default(activeTransport);
|
119
|
+
await deviceConnection.getVersion();
|
120
|
+
return deviceConnection;
|
121
|
+
}
|
122
|
+
catch (error) {
|
123
|
+
throw new key_management_1.errors.TransportError('Cannot communicate with Ledger Cardano App', error);
|
124
|
+
}
|
125
|
+
}
|
126
|
+
static async establishDeviceConnection(communicationType, devicePath) {
|
127
|
+
let transport;
|
128
|
+
try {
|
129
|
+
transport = await LedgerKeyAgent.createTransport({ communicationType, devicePath });
|
130
|
+
if (!transport || !transport.deviceModel) {
|
131
|
+
throw new key_management_1.errors.TransportError('Missing transport');
|
132
|
+
}
|
133
|
+
const isSupportedLedgerModel = transport.deviceModel.id === 'nanoS' ||
|
134
|
+
transport.deviceModel.id === 'nanoX' ||
|
135
|
+
transport.deviceModel.id === 'nanoSP';
|
136
|
+
if (!isSupportedLedgerModel) {
|
137
|
+
throw new key_management_1.errors.TransportError(`Ledger device model: "${transport.deviceModel.id}" is not supported`);
|
138
|
+
}
|
139
|
+
return await LedgerKeyAgent.createDeviceConnection(transport);
|
140
|
+
}
|
141
|
+
catch (error) {
|
142
|
+
if (error.innerError.message.includes('cannot open device with path')) {
|
143
|
+
throw new key_management_1.errors.TransportError('Connection already established', error);
|
144
|
+
}
|
145
|
+
if (transport) {
|
146
|
+
transport.close();
|
147
|
+
}
|
148
|
+
throw new key_management_1.errors.TransportError('Establishing device connection failed', error);
|
149
|
+
}
|
150
|
+
}
|
151
|
+
static async checkDeviceConnection(communicationType, deviceConnection) {
|
152
|
+
try {
|
153
|
+
if (!deviceConnection) {
|
154
|
+
return await LedgerKeyAgent.establishDeviceConnection(communicationType);
|
155
|
+
}
|
156
|
+
return await LedgerKeyAgent.createDeviceConnection(deviceConnection.transport);
|
157
|
+
}
|
158
|
+
catch (error) {
|
159
|
+
if (error.name === 'DisconnectedDeviceDuringOperation') {
|
160
|
+
return await LedgerKeyAgent.establishDeviceConnection(communicationType);
|
161
|
+
}
|
162
|
+
throw error;
|
163
|
+
}
|
164
|
+
}
|
165
|
+
static async getXpub({ deviceConnection, communicationType, accountIndex }) {
|
166
|
+
try {
|
167
|
+
const recoveredDeviceConnection = await LedgerKeyAgent.checkDeviceConnection(communicationType, deviceConnection);
|
168
|
+
const derivationPath = `${key_management_1.CardanoKeyConst.PURPOSE}'/${key_management_1.CardanoKeyConst.COIN_TYPE}'/${accountIndex}'`;
|
169
|
+
const extendedPublicKey = await recoveredDeviceConnection.getExtendedPublicKey({
|
170
|
+
path: (0, address_1.str_to_path)(derivationPath)
|
171
|
+
});
|
172
|
+
const xPubHex = `${extendedPublicKey.publicKeyHex}${extendedPublicKey.chainCodeHex}`;
|
173
|
+
return Crypto.Bip32PublicKeyHex(xPubHex);
|
174
|
+
}
|
175
|
+
catch (error) {
|
176
|
+
if (error.code === 28169) {
|
177
|
+
throw new key_management_1.errors.AuthenticationError('Failed to export extended account public key', error);
|
178
|
+
}
|
179
|
+
throw transportTypedError(error);
|
180
|
+
}
|
181
|
+
}
|
182
|
+
static async getAppVersion(communicationType, deviceConnection) {
|
183
|
+
const recoveredDeviceConnection = await LedgerKeyAgent.checkDeviceConnection(communicationType, deviceConnection);
|
184
|
+
return await recoveredDeviceConnection.getVersion();
|
185
|
+
}
|
186
|
+
static async createWithDevice({ chainId, accountIndex = 0, communicationType, deviceConnection }, dependencies) {
|
187
|
+
const deviceListPaths = await LedgerKeyAgent.getHidDeviceList(communicationType);
|
188
|
+
const activeDeviceConnection = await (deviceConnection
|
189
|
+
? LedgerKeyAgent.checkDeviceConnection(communicationType, deviceConnection)
|
190
|
+
: LedgerKeyAgent.establishDeviceConnection(communicationType, deviceListPaths[0]));
|
191
|
+
const extendedAccountPublicKey = await LedgerKeyAgent.getXpub({
|
192
|
+
accountIndex,
|
193
|
+
communicationType,
|
194
|
+
deviceConnection: activeDeviceConnection
|
195
|
+
});
|
196
|
+
return new LedgerKeyAgent({
|
197
|
+
accountIndex,
|
198
|
+
chainId,
|
199
|
+
communicationType,
|
200
|
+
deviceConnection: activeDeviceConnection,
|
201
|
+
extendedAccountPublicKey,
|
202
|
+
knownAddresses: []
|
203
|
+
}, dependencies);
|
204
|
+
}
|
205
|
+
static getSigningMode(tx) {
|
206
|
+
if (tx.certificates) {
|
207
|
+
for (const cert of tx.certificates) {
|
208
|
+
if (cert.type === ledgerjs_hw_app_cardano_1.CertificateType.STAKE_POOL_REGISTRATION &&
|
209
|
+
cert.params.poolOwners.some((owner) => owner.type === ledgerjs_hw_app_cardano_1.PoolOwnerType.DEVICE_OWNED))
|
210
|
+
return ledgerjs_hw_app_cardano_1.TransactionSigningMode.POOL_REGISTRATION_AS_OWNER;
|
211
|
+
if (cert.type === ledgerjs_hw_app_cardano_1.CertificateType.STAKE_POOL_REGISTRATION &&
|
212
|
+
cert.params.poolKey.type === ledgerjs_hw_app_cardano_1.PoolKeyType.DEVICE_OWNED)
|
213
|
+
return ledgerjs_hw_app_cardano_1.TransactionSigningMode.POOL_REGISTRATION_AS_OPERATOR;
|
214
|
+
}
|
215
|
+
}
|
216
|
+
if (tx.collateralInputs || tx.requiredSigners) {
|
217
|
+
return ledgerjs_hw_app_cardano_1.TransactionSigningMode.PLUTUS_TRANSACTION;
|
218
|
+
}
|
219
|
+
if (isMultiSig(tx)) {
|
220
|
+
return ledgerjs_hw_app_cardano_1.TransactionSigningMode.MULTISIG_TRANSACTION;
|
221
|
+
}
|
222
|
+
return ledgerjs_hw_app_cardano_1.TransactionSigningMode.ORDINARY_TRANSACTION;
|
223
|
+
}
|
224
|
+
async signTransaction({ body, hash }) {
|
225
|
+
const scope = new util_1.ManagedFreeableScope();
|
226
|
+
try {
|
227
|
+
const ledgerTxData = await (0, transformers_1.toLedgerTx)(body, {
|
228
|
+
chainId: this.chainId,
|
229
|
+
inputResolver: this.inputResolver,
|
230
|
+
knownAddresses: this.knownAddresses
|
231
|
+
});
|
232
|
+
const deviceConnection = await LedgerKeyAgent.checkDeviceConnection(__classPrivateFieldGet(this, _LedgerKeyAgent_communicationType, "f"), this.deviceConnection);
|
233
|
+
const signingMode = LedgerKeyAgent.getSigningMode(ledgerTxData);
|
234
|
+
const result = await deviceConnection.signTransaction({
|
235
|
+
signingMode,
|
236
|
+
tx: ledgerTxData
|
237
|
+
});
|
238
|
+
if (result.txHashHex !== hash) {
|
239
|
+
throw new key_management_1.errors.HwMappingError('Ledger computed a different transaction id');
|
240
|
+
}
|
241
|
+
return new Map(await Promise.all(result.witnesses.map(async (witness) => {
|
242
|
+
const publicKey = await this.derivePublicKey({
|
243
|
+
index: witness.path[key_management_1.Cip1852PathLevelIndexes.INDEX],
|
244
|
+
role: witness.path[key_management_1.Cip1852PathLevelIndexes.ROLE]
|
245
|
+
});
|
246
|
+
const signature = Crypto.Ed25519SignatureHex(witness.witnessSignatureHex);
|
247
|
+
return [publicKey, signature];
|
248
|
+
})));
|
249
|
+
}
|
250
|
+
catch (error) {
|
251
|
+
if (error.code === 28169) {
|
252
|
+
throw new key_management_1.errors.AuthenticationError('Transaction signing aborted', error);
|
253
|
+
}
|
254
|
+
throw transportTypedError(error);
|
255
|
+
}
|
256
|
+
finally {
|
257
|
+
scope.dispose();
|
258
|
+
}
|
259
|
+
}
|
260
|
+
async signBlob() {
|
261
|
+
throw new core_1.NotImplementedError('signBlob');
|
262
|
+
}
|
263
|
+
async exportRootPrivateKey() {
|
264
|
+
throw new core_1.NotImplementedError('Operation not supported!');
|
265
|
+
}
|
266
|
+
}
|
267
|
+
exports.LedgerKeyAgent = LedgerKeyAgent;
|
268
|
+
_LedgerKeyAgent_communicationType = new WeakMap();
|
269
|
+
//# sourceMappingURL=LedgerKeyAgent.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"LedgerKeyAgent.js","sourceRoot":"","sources":["../../src/LedgerKeyAgent.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,4DAA8C;AAC9C,4CAAiE;AACjE,gEAUqC;AAErC,4CAAyD;AACzD,4FAA6F;AAC7F,iDAA4C;AAC5C,uGAWqD;AACrD,8GAAwE;AACxE,wFAA4D;AA0B5D,MAAM,mBAAmB,GAAG,CAAC,KAAW,EAAE,EAAE,CAAC,IAAI,uBAAM,CAAC,cAAc,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;AAEzG,MAAM,gCAAgC,GAAG,CAAC,YAA8C,EAAW,EAAE;IACnG,IAAI,C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I,KAAK,CAAC,IAAI,KAAK,KAAM,EAAE;gBACzB,MAAM,IAAI,uBAAM,CAAC,mBAAmB,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC;aAC5E;YACD,MAAM,mBAAmB,CAAC,KAAK,CAAC,CAAC;SAClC;gBAAS;YACR,KAAK,CAAC,OAAO,EAAE,CAAC;SACjB;IACH,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,MAAM,IAAI,0BAAmB,CAAC,UAAU,CAAC,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,oBAAoB;QACxB,MAAM,IAAI,0BAAmB,CAAC,0BAA0B,CAAC,CAAC;IAC5D,CAAC;CACF;AAlRD,wCAkRC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC"}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
__exportStar(require("./transformers"), exports);
|
18
|
+
__exportStar(require("./LedgerKeyAgent"), exports);
|
19
|
+
__exportStar(require("./types"), exports);
|
20
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,mDAAiC;AACjC,0CAAwB"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../../src/transformers/assets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,6CAA6C,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AA6C5C,eAAO,MAAM,WAAW,aAAc,QAAQ,QAAQ,GAAG,SAAS,+BAIjE,CAAC"}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.mapTokenMap = void 0;
|
4
|
+
const core_1 = require("@cardano-sdk/core");
|
5
|
+
const compareAssetNameCanonically = (a, b) => {
|
6
|
+
if (a.assetNameHex === b.assetNameHex) {
|
7
|
+
return a.assetNameHex > b.assetNameHex ? 1 : -1;
|
8
|
+
}
|
9
|
+
else if (a.assetNameHex.length > b.assetNameHex.length)
|
10
|
+
return 1;
|
11
|
+
return -1;
|
12
|
+
};
|
13
|
+
const comparePolicyIdCanonically = (a, b) => {
|
14
|
+
if (a.policyIdHex === b.policyIdHex) {
|
15
|
+
return a.policyIdHex > b.policyIdHex ? 1 : -1;
|
16
|
+
}
|
17
|
+
else if (a.policyIdHex.length > b.policyIdHex.length)
|
18
|
+
return 1;
|
19
|
+
return -1;
|
20
|
+
};
|
21
|
+
const tokenMapToAssetGroup = (tokenMap) => {
|
22
|
+
const map = new Map();
|
23
|
+
for (const [key, value] of tokenMap.entries()) {
|
24
|
+
const policyId = core_1.Cardano.AssetId.getPolicyId(key);
|
25
|
+
const assetName = core_1.Cardano.AssetId.getAssetName(key);
|
26
|
+
if (!map.has(policyId))
|
27
|
+
map.set(policyId, new Array());
|
28
|
+
map.get(policyId).push({
|
29
|
+
amount: value,
|
30
|
+
assetNameHex: assetName
|
31
|
+
});
|
32
|
+
}
|
33
|
+
const tokenMapAssetsGroup = [];
|
34
|
+
for (const [key, value] of map.entries()) {
|
35
|
+
value.sort(compareAssetNameCanonically);
|
36
|
+
tokenMapAssetsGroup.push({
|
37
|
+
policyIdHex: key,
|
38
|
+
tokens: value
|
39
|
+
});
|
40
|
+
}
|
41
|
+
tokenMapAssetsGroup.sort(comparePolicyIdCanonically);
|
42
|
+
return tokenMapAssetsGroup;
|
43
|
+
};
|
44
|
+
const mapTokenMap = (tokenMap) => {
|
45
|
+
if (!tokenMap)
|
46
|
+
return null;
|
47
|
+
return tokenMapToAssetGroup(tokenMap);
|
48
|
+
};
|
49
|
+
exports.mapTokenMap = mapTokenMap;
|
50
|
+
//# sourceMappingURL=assets.js.map
|