@ledgerhq/live-common 21.36.2 → 21.36.3
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/lib/bridge/jsHelpers.d.ts.map +1 -1
- package/lib/bridge/jsHelpers.js +238 -245
- package/lib/bridge/jsHelpers.js.map +1 -1
- package/lib/families/bitcoin/js-signOperation.d.ts.map +1 -1
- package/lib/families/bitcoin/js-signOperation.js +130 -139
- package/lib/families/bitcoin/js-signOperation.js.map +1 -1
- package/lib/families/crypto_org/js-signOperation.d.ts.map +1 -1
- package/lib/families/crypto_org/js-signOperation.js +55 -62
- package/lib/families/crypto_org/js-signOperation.js.map +1 -1
- package/lib/families/elrond/js-signOperation.d.ts.map +1 -1
- package/lib/families/elrond/js-signOperation.js +43 -50
- package/lib/families/elrond/js-signOperation.js.map +1 -1
- package/lib/families/polkadot/js-signOperation.d.ts.map +1 -1
- package/lib/families/polkadot/js-signOperation.js +54 -61
- package/lib/families/polkadot/js-signOperation.js.map +1 -1
- package/lib/families/ripple/bridge/js.d.ts.map +1 -1
- package/lib/families/ripple/bridge/js.js +299 -313
- package/lib/families/ripple/bridge/js.js.map +1 -1
- package/lib/families/stellar/js-signOperation.d.ts.map +1 -1
- package/lib/families/stellar/js-signOperation.js +44 -51
- package/lib/families/stellar/js-signOperation.js.map +1 -1
- package/lib/families/tron/bridge/js.d.ts.map +1 -1
- package/lib/families/tron/bridge/js.js +159 -167
- package/lib/families/tron/bridge/js.js.map +1 -1
- package/package.json +1 -1
- package/src/.DS_Store +0 -0
- package/src/bridge/jsHelpers.ts +213 -213
- package/src/data/flags/.DS_Store +0 -0
- package/src/families/bitcoin/js-signOperation.ts +14 -17
- package/src/families/crypto_org/js-signOperation.ts +12 -16
- package/src/families/elrond/js-signOperation.ts +10 -14
- package/src/families/polkadot/js-signOperation.ts +61 -61
- package/src/families/ripple/bridge/js.ts +257 -260
- package/src/families/stellar/js-signOperation.ts +10 -14
- package/src/families/tron/bridge/js.ts +57 -58
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { BigNumber } from "bignumber.js";
|
|
2
2
|
import { Observable } from "rxjs";
|
|
3
|
+
import { utils } from "@crypto-com/chain-jslib";
|
|
3
4
|
import { FeeNotLoaded } from "@ledgerhq/errors";
|
|
5
|
+
import CryptoOrgApp from "@ledgerhq/hw-app-cosmos";
|
|
4
6
|
import {
|
|
5
7
|
CryptoOrgWrongSignatureHeader,
|
|
6
8
|
CryptoOrgSignatureSize,
|
|
7
9
|
} from "./errors";
|
|
8
10
|
import type { Transaction } from "./types";
|
|
9
11
|
import type { Account, Operation, SignOperationEvent } from "../../types";
|
|
10
|
-
import { open, close } from "../../hw";
|
|
11
12
|
import { encodeOperationId } from "../../operation";
|
|
12
|
-
import
|
|
13
|
-
import { utils } from "@crypto-com/chain-jslib";
|
|
13
|
+
import { withDevice } from "../../hw/deviceAccess";
|
|
14
14
|
import { buildTransaction } from "./js-buildTransaction";
|
|
15
15
|
import { isTestNet } from "./logic";
|
|
16
16
|
|
|
@@ -104,11 +104,9 @@ const signOperation = ({
|
|
|
104
104
|
deviceId: any;
|
|
105
105
|
transaction: Transaction;
|
|
106
106
|
}): Observable<SignOperationEvent> =>
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
try {
|
|
107
|
+
withDevice(deviceId)((transport) =>
|
|
108
|
+
Observable.create((o) => {
|
|
109
|
+
async function main() {
|
|
112
110
|
o.next({
|
|
113
111
|
type: "device-signature-requested",
|
|
114
112
|
});
|
|
@@ -165,15 +163,13 @@ const signOperation = ({
|
|
|
165
163
|
},
|
|
166
164
|
});
|
|
167
165
|
}
|
|
168
|
-
} finally {
|
|
169
|
-
close(transport, deviceId);
|
|
170
166
|
}
|
|
171
|
-
}
|
|
172
167
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
168
|
+
main().then(
|
|
169
|
+
() => o.complete(),
|
|
170
|
+
(e) => o.error(e)
|
|
171
|
+
);
|
|
172
|
+
})
|
|
173
|
+
);
|
|
178
174
|
|
|
179
175
|
export default signOperation;
|
|
@@ -3,7 +3,7 @@ import { Observable } from "rxjs";
|
|
|
3
3
|
import { FeeNotLoaded } from "@ledgerhq/errors";
|
|
4
4
|
import type { Transaction } from "./types";
|
|
5
5
|
import type { Account, Operation, SignOperationEvent } from "../../types";
|
|
6
|
-
import {
|
|
6
|
+
import { withDevice } from "../../hw/deviceAccess";
|
|
7
7
|
import { encodeOperationId } from "../../operation";
|
|
8
8
|
import Elrond from "./hw-app-elrond";
|
|
9
9
|
import { buildTransaction } from "./js-buildTransaction";
|
|
@@ -48,11 +48,9 @@ const signOperation = ({
|
|
|
48
48
|
deviceId: any;
|
|
49
49
|
transaction: Transaction;
|
|
50
50
|
}): Observable<SignOperationEvent> =>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
try {
|
|
51
|
+
withDevice(deviceId)((transport) =>
|
|
52
|
+
Observable.create((o) => {
|
|
53
|
+
async function main() {
|
|
56
54
|
if (!transaction.fees) {
|
|
57
55
|
throw new FeeNotLoaded();
|
|
58
56
|
}
|
|
@@ -89,15 +87,13 @@ const signOperation = ({
|
|
|
89
87
|
expirationDate: null,
|
|
90
88
|
},
|
|
91
89
|
});
|
|
92
|
-
} finally {
|
|
93
|
-
close(transport, deviceId);
|
|
94
90
|
}
|
|
95
|
-
}
|
|
96
91
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
92
|
+
main().then(
|
|
93
|
+
() => o.complete(),
|
|
94
|
+
(e) => o.error(e)
|
|
95
|
+
);
|
|
96
|
+
})
|
|
97
|
+
);
|
|
102
98
|
|
|
103
99
|
export default signOperation;
|
|
@@ -11,7 +11,7 @@ import type {
|
|
|
11
11
|
OperationType,
|
|
12
12
|
SignOperationEvent,
|
|
13
13
|
} from "../../types";
|
|
14
|
-
import {
|
|
14
|
+
import { withDevice } from "../../hw/deviceAccess";
|
|
15
15
|
import { encodeOperationId } from "../../operation";
|
|
16
16
|
import { buildTransaction } from "./js-buildTransaction";
|
|
17
17
|
import { calculateAmount, getNonce, isFirstBond } from "./logic";
|
|
@@ -157,69 +157,69 @@ const signOperation = ({
|
|
|
157
157
|
deviceId: any;
|
|
158
158
|
transaction: Transaction;
|
|
159
159
|
}): Observable<SignOperationEvent> =>
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
});
|
|
160
|
+
withDevice(deviceId)(
|
|
161
|
+
(transport) =>
|
|
162
|
+
new Observable((o) => {
|
|
163
|
+
async function main() {
|
|
164
|
+
o.next({
|
|
165
|
+
type: "device-signature-requested",
|
|
166
|
+
});
|
|
168
167
|
|
|
169
|
-
|
|
170
|
-
|
|
168
|
+
if (!transaction.fees) {
|
|
169
|
+
throw new FeeNotLoaded();
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Ensure amount is filled when useAllAmount
|
|
173
|
+
const transactionToSign = {
|
|
174
|
+
...transaction,
|
|
175
|
+
amount: calculateAmount({
|
|
176
|
+
a: account,
|
|
177
|
+
t: transaction,
|
|
178
|
+
}),
|
|
179
|
+
};
|
|
180
|
+
const { unsigned, registry } = await buildTransaction(
|
|
181
|
+
account,
|
|
182
|
+
transactionToSign,
|
|
183
|
+
true
|
|
184
|
+
);
|
|
185
|
+
const payload = registry
|
|
186
|
+
.createType("ExtrinsicPayload", unsigned, {
|
|
187
|
+
version: unsigned.version,
|
|
188
|
+
})
|
|
189
|
+
.toU8a({
|
|
190
|
+
method: true,
|
|
191
|
+
});
|
|
192
|
+
// Sign by device
|
|
193
|
+
const polkadot = new Polkadot(transport);
|
|
194
|
+
// FIXME: the type of payload Uint8Array is not compatible with the signature of sign which accept a string
|
|
195
|
+
const r = await polkadot.sign(
|
|
196
|
+
account.freshAddressPath,
|
|
197
|
+
payload as any
|
|
198
|
+
);
|
|
199
|
+
const signed = await signExtrinsic(unsigned, r.signature, registry);
|
|
200
|
+
o.next({
|
|
201
|
+
type: "device-signature-granted",
|
|
202
|
+
});
|
|
203
|
+
const operation = buildOptimisticOperation(
|
|
204
|
+
account,
|
|
205
|
+
transactionToSign,
|
|
206
|
+
transactionToSign.fees ?? new BigNumber(0)
|
|
207
|
+
);
|
|
208
|
+
o.next({
|
|
209
|
+
type: "signed",
|
|
210
|
+
signedOperation: {
|
|
211
|
+
operation,
|
|
212
|
+
signature: signed,
|
|
213
|
+
expirationDate: null,
|
|
214
|
+
},
|
|
215
|
+
});
|
|
171
216
|
}
|
|
172
217
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
amount: calculateAmount({
|
|
177
|
-
a: account,
|
|
178
|
-
t: transaction,
|
|
179
|
-
}),
|
|
180
|
-
};
|
|
181
|
-
const { unsigned, registry } = await buildTransaction(
|
|
182
|
-
account,
|
|
183
|
-
transactionToSign,
|
|
184
|
-
true
|
|
185
|
-
);
|
|
186
|
-
const payload = registry
|
|
187
|
-
.createType("ExtrinsicPayload", unsigned, {
|
|
188
|
-
version: unsigned.version,
|
|
189
|
-
})
|
|
190
|
-
.toU8a({
|
|
191
|
-
method: true,
|
|
192
|
-
});
|
|
193
|
-
// Sign by device
|
|
194
|
-
const polkadot = new Polkadot(transport);
|
|
195
|
-
// FIXME: the type of payload Uint8Array is not compatible with the signature of sign which accept a string
|
|
196
|
-
const r = await polkadot.sign(account.freshAddressPath, payload as any);
|
|
197
|
-
const signed = await signExtrinsic(unsigned, r.signature, registry);
|
|
198
|
-
o.next({
|
|
199
|
-
type: "device-signature-granted",
|
|
200
|
-
});
|
|
201
|
-
const operation = buildOptimisticOperation(
|
|
202
|
-
account,
|
|
203
|
-
transactionToSign,
|
|
204
|
-
transactionToSign.fees ?? new BigNumber(0)
|
|
218
|
+
main().then(
|
|
219
|
+
() => o.complete(),
|
|
220
|
+
(e) => o.error(e)
|
|
205
221
|
);
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
signedOperation: {
|
|
209
|
-
operation,
|
|
210
|
-
signature: signed,
|
|
211
|
-
expirationDate: null,
|
|
212
|
-
},
|
|
213
|
-
});
|
|
214
|
-
} finally {
|
|
215
|
-
close(transport, deviceId);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
main().then(
|
|
220
|
-
() => o.complete(),
|
|
221
|
-
(e) => o.error(e)
|
|
222
|
-
);
|
|
223
|
-
});
|
|
222
|
+
})
|
|
223
|
+
);
|
|
224
224
|
|
|
225
225
|
export default signOperation;
|