@injectivelabs/wallet-ledger 0.0.2
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/README.md +111 -0
- package/dist/cjs/index.d.ts +5 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +25 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/strategy/Ledger/Base.d.ts +43 -0
- package/dist/cjs/strategy/Ledger/Base.d.ts.map +1 -0
- package/dist/cjs/strategy/Ledger/Base.js +302 -0
- package/dist/cjs/strategy/Ledger/Base.js.map +1 -0
- package/dist/cjs/strategy/Ledger/LedgerLegacy.d.ts +6 -0
- package/dist/cjs/strategy/Ledger/LedgerLegacy.d.ts.map +1 -0
- package/dist/cjs/strategy/Ledger/LedgerLegacy.js +15 -0
- package/dist/cjs/strategy/Ledger/LedgerLegacy.js.map +1 -0
- package/dist/cjs/strategy/Ledger/LedgerLive.d.ts +6 -0
- package/dist/cjs/strategy/Ledger/LedgerLive.d.ts.map +1 -0
- package/dist/cjs/strategy/Ledger/LedgerLive.js +15 -0
- package/dist/cjs/strategy/Ledger/LedgerLive.js.map +1 -0
- package/dist/cjs/strategy/Ledger/hw/AccountManager.d.ts +22 -0
- package/dist/cjs/strategy/Ledger/hw/AccountManager.d.ts.map +1 -0
- package/dist/cjs/strategy/Ledger/hw/AccountManager.js +106 -0
- package/dist/cjs/strategy/Ledger/hw/AccountManager.js.map +1 -0
- package/dist/cjs/strategy/Ledger/hw/index.d.ts +12 -0
- package/dist/cjs/strategy/Ledger/hw/index.d.ts.map +1 -0
- package/dist/cjs/strategy/Ledger/hw/index.js +108 -0
- package/dist/cjs/strategy/Ledger/hw/index.js.map +1 -0
- package/dist/cjs/strategy/Ledger/utils.d.ts +4 -0
- package/dist/cjs/strategy/Ledger/utils.d.ts.map +1 -0
- package/dist/cjs/strategy/Ledger/utils.js +9 -0
- package/dist/cjs/strategy/Ledger/utils.js.map +1 -0
- package/dist/cjs/strategy/LedgerCosmos/hw/AccountManager.d.ts +21 -0
- package/dist/cjs/strategy/LedgerCosmos/hw/AccountManager.d.ts.map +1 -0
- package/dist/cjs/strategy/LedgerCosmos/hw/AccountManager.js +84 -0
- package/dist/cjs/strategy/LedgerCosmos/hw/AccountManager.js.map +1 -0
- package/dist/cjs/strategy/LedgerCosmos/hw/index.d.ts +12 -0
- package/dist/cjs/strategy/LedgerCosmos/hw/index.d.ts.map +1 -0
- package/dist/cjs/strategy/LedgerCosmos/hw/index.js +68 -0
- package/dist/cjs/strategy/LedgerCosmos/hw/index.js.map +1 -0
- package/dist/cjs/strategy/LedgerCosmos/index.d.ts +37 -0
- package/dist/cjs/strategy/LedgerCosmos/index.d.ts.map +1 -0
- package/dist/cjs/strategy/LedgerCosmos/index.js +197 -0
- package/dist/cjs/strategy/LedgerCosmos/index.js.map +1 -0
- package/dist/cjs/types.d.ts +18 -0
- package/dist/cjs/types.d.ts.map +1 -0
- package/dist/cjs/types.js +15 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/strategy/Ledger/Base.d.ts +43 -0
- package/dist/esm/strategy/Ledger/Base.d.ts.map +1 -0
- package/dist/esm/strategy/Ledger/Base.js +240 -0
- package/dist/esm/strategy/Ledger/Base.js.map +1 -0
- package/dist/esm/strategy/Ledger/LedgerLegacy.d.ts +6 -0
- package/dist/esm/strategy/Ledger/LedgerLegacy.d.ts.map +1 -0
- package/dist/esm/strategy/Ledger/LedgerLegacy.js +11 -0
- package/dist/esm/strategy/Ledger/LedgerLegacy.js.map +1 -0
- package/dist/esm/strategy/Ledger/LedgerLive.d.ts +6 -0
- package/dist/esm/strategy/Ledger/LedgerLive.d.ts.map +1 -0
- package/dist/esm/strategy/Ledger/LedgerLive.js +11 -0
- package/dist/esm/strategy/Ledger/LedgerLive.js.map +1 -0
- package/dist/esm/strategy/Ledger/hw/AccountManager.d.ts +22 -0
- package/dist/esm/strategy/Ledger/hw/AccountManager.d.ts.map +1 -0
- package/dist/esm/strategy/Ledger/hw/AccountManager.js +86 -0
- package/dist/esm/strategy/Ledger/hw/AccountManager.js.map +1 -0
- package/dist/esm/strategy/Ledger/hw/index.d.ts +12 -0
- package/dist/esm/strategy/Ledger/hw/index.d.ts.map +1 -0
- package/dist/esm/strategy/Ledger/hw/index.js +60 -0
- package/dist/esm/strategy/Ledger/hw/index.js.map +1 -0
- package/dist/esm/strategy/Ledger/utils.d.ts +4 -0
- package/dist/esm/strategy/Ledger/utils.d.ts.map +1 -0
- package/dist/esm/strategy/Ledger/utils.js +4 -0
- package/dist/esm/strategy/Ledger/utils.js.map +1 -0
- package/dist/esm/strategy/LedgerCosmos/hw/AccountManager.d.ts +21 -0
- package/dist/esm/strategy/LedgerCosmos/hw/AccountManager.d.ts.map +1 -0
- package/dist/esm/strategy/LedgerCosmos/hw/AccountManager.js +67 -0
- package/dist/esm/strategy/LedgerCosmos/hw/AccountManager.js.map +1 -0
- package/dist/esm/strategy/LedgerCosmos/hw/index.d.ts +12 -0
- package/dist/esm/strategy/LedgerCosmos/hw/index.d.ts.map +1 -0
- package/dist/esm/strategy/LedgerCosmos/hw/index.js +43 -0
- package/dist/esm/strategy/LedgerCosmos/hw/index.js.map +1 -0
- package/dist/esm/strategy/LedgerCosmos/index.d.ts +37 -0
- package/dist/esm/strategy/LedgerCosmos/index.d.ts.map +1 -0
- package/dist/esm/strategy/LedgerCosmos/index.js +153 -0
- package/dist/esm/strategy/LedgerCosmos/index.js.map +1 -0
- package/dist/esm/types.d.ts +18 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +12 -0
- package/dist/esm/types.js.map +1 -0
- package/package.json +67 -0
package/README.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# 🌟 Injective Protocol - Ledger Wallet Strategy
|
|
2
|
+
|
|
3
|
+
<!-- TODO -->
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@injectivelabs/wallet-ts)
|
|
6
|
+
[](https://www.npmjs.com/package/@injectivelabs/wallet-ts)
|
|
7
|
+
[]()
|
|
8
|
+
|
|
9
|
+
_Package to use Ledger Wallets on Injective via the wallet strategy._
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 📚 Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
yarn add @injectivelabs/wallet-ledger
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 📖 Documentation
|
|
22
|
+
|
|
23
|
+
Injective's wallet packages are intended to make it easy for developers to choose exactly what wallets - and subsequent dependencies - they
|
|
24
|
+
want to include in their projects.
|
|
25
|
+
|
|
26
|
+
Regardless of which wallet package(s) you choose to use you must also have `@injectivelabs/wallet-core` and `@injectivelabs/wallet-base`
|
|
27
|
+
installed. These contain all of the types and core wallet functionality, with the separate wallet packages only providing the necessary
|
|
28
|
+
dependencies and implementations for their specific wallets.
|
|
29
|
+
|
|
30
|
+
Here's a brief example of how to use this package to send 1 INJ.:
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
import { Wallet } from '@injectivelabs/wallet-base';
|
|
34
|
+
import { BaseWalletStrategy, MsgBroadcaster } from '@injectivelabs/wallet-core';
|
|
35
|
+
import { LedgerLive } from '@injectivelabs/wallet-ledger';
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
const strategyArgs: WalletStrategyArguments = {
|
|
39
|
+
chainId: ChainId.Mainnet,
|
|
40
|
+
wallet: Wallet.Ledger,
|
|
41
|
+
strategies: {
|
|
42
|
+
[Wallet.Ledger]: new LedgerLive({
|
|
43
|
+
chainId: ChainId.Mainnet,
|
|
44
|
+
ethereumOptions: {
|
|
45
|
+
ethereumChainId: EthereumChainId.Mainnet,
|
|
46
|
+
},
|
|
47
|
+
}),
|
|
48
|
+
},
|
|
49
|
+
}
|
|
50
|
+
const walletStrategy = new BaseWalletStrategy(strategyArgs)
|
|
51
|
+
|
|
52
|
+
const msgBroadcaster = new MsgBroadcaster({
|
|
53
|
+
walletStrategy,
|
|
54
|
+
simulateTx: true,
|
|
55
|
+
network: Network.Mainnet,
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
const sendTX = async () => {
|
|
59
|
+
const injectiveAddress = 'someInjectiveAddress'
|
|
60
|
+
|
|
61
|
+
const message = MsgSend.fromJSON({
|
|
62
|
+
srcInjectiveAddress: injectiveAddress,
|
|
63
|
+
dstInjectiveAddress: injectiveAddress,
|
|
64
|
+
amount: {
|
|
65
|
+
amount: '1',
|
|
66
|
+
denom: 'inj',
|
|
67
|
+
},
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
return await msgBroadcaster.broadcast({ msgs: message })
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const result = await sendTX()
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Read more and find example usages on our [WalletStrategy Docs](https://docs.ts.injective.network/wallet/wallet-wallet-strategy)
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## 📜 Contribution
|
|
81
|
+
|
|
82
|
+
**Contribution guides and practices will be available once there is a stable foundation of the whole package set within the `injective-ts` repo.**
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## ⛑ Support
|
|
87
|
+
|
|
88
|
+
Reach out to us at one of the following places!
|
|
89
|
+
|
|
90
|
+
- Website at <a href="https://injective.com" target="_blank">`injective.com`</a>
|
|
91
|
+
- Twitter at <a href="https://twitter.com/Injective_" target="_blank">`@Injective`</a>
|
|
92
|
+
- Discord at <a href="https://discord.com/invite/NK4qdbv" target="_blank">`Discord`</a>
|
|
93
|
+
- Telegram at <a href="https://t.me/joininjective" target="_blank">`Telegram`</a>
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## 🔓 License
|
|
98
|
+
|
|
99
|
+
Copyright © 2021 - 2022 Injective Labs Inc. (https://injectivelabs.org/)
|
|
100
|
+
|
|
101
|
+
<a href="https://iili.io/mNneZN.md.png"><img src="https://iili.io/mNneZN.md.png" style="width: 300px; max-width: 100%; height: auto" />
|
|
102
|
+
|
|
103
|
+
Originally released by Injective Labs Inc. under: <br />
|
|
104
|
+
Apache License <br />
|
|
105
|
+
Version 2.0, January 2004 <br />
|
|
106
|
+
http://www.apache.org/licenses/
|
|
107
|
+
|
|
108
|
+
<p> </p>
|
|
109
|
+
<div align="center">
|
|
110
|
+
<sub><em>Powering the future of decentralized finance.</em></sub>
|
|
111
|
+
</div>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { LedgerLive as LedgerLiveStrategy } from './strategy/Ledger/LedgerLive';
|
|
2
|
+
export { LedgerLegacy as LedgerLegacyStrategy } from './strategy/Ledger/LedgerLegacy';
|
|
3
|
+
export { LedgerCosmos as LedgerCosmosStrategy } from './strategy/LedgerCosmos';
|
|
4
|
+
export * from './types';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,kBAAkB,EAAG,MAAM,8BAA8B,CAAA;AAChF,OAAO,EAAE,YAAY,IAAI,oBAAoB,EAAG,MAAM,gCAAgC,CAAA;AACtF,OAAO,EAAE,YAAY,IAAI,oBAAoB,EAAG,MAAM,yBAAyB,CAAA;AAC/E,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
exports.LedgerCosmosStrategy = exports.LedgerLegacyStrategy = exports.LedgerLiveStrategy = void 0;
|
|
18
|
+
var LedgerLive_1 = require("./strategy/Ledger/LedgerLive");
|
|
19
|
+
Object.defineProperty(exports, "LedgerLiveStrategy", { enumerable: true, get: function () { return LedgerLive_1.LedgerLive; } });
|
|
20
|
+
var LedgerLegacy_1 = require("./strategy/Ledger/LedgerLegacy");
|
|
21
|
+
Object.defineProperty(exports, "LedgerLegacyStrategy", { enumerable: true, get: function () { return LedgerLegacy_1.LedgerLegacy; } });
|
|
22
|
+
var LedgerCosmos_1 = require("./strategy/LedgerCosmos");
|
|
23
|
+
Object.defineProperty(exports, "LedgerCosmosStrategy", { enumerable: true, get: function () { return LedgerCosmos_1.LedgerCosmos; } });
|
|
24
|
+
__exportStar(require("./types"), exports);
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2DAAgF;AAAvE,gHAAA,UAAU,OAAsB;AACzC,+DAAsF;AAA7E,oHAAA,YAAY,OAAwB;AAC7C,wDAA+E;AAAtE,oHAAA,YAAY,OAAwB;AAC7C,0CAAuB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { AccountAddress, EthereumChainId } from '@injectivelabs/ts-types';
|
|
2
|
+
import { TxRaw, TxResponse, DirectSignResponse, AminoSignResponse } from '@injectivelabs/sdk-ts';
|
|
3
|
+
import { StdSignDoc, WalletDeviceType, BaseConcreteStrategy, SendTransactionOptions, ConcreteWalletStrategy, ConcreteEthereumWalletStrategyArgs } from '@injectivelabs/wallet-base';
|
|
4
|
+
import { LedgerDerivationPathType } from '../../types';
|
|
5
|
+
export default class LedgerBase extends BaseConcreteStrategy implements ConcreteWalletStrategy {
|
|
6
|
+
private baseDerivationPath;
|
|
7
|
+
private derivationPathType;
|
|
8
|
+
private ledger;
|
|
9
|
+
private ethereumOptions;
|
|
10
|
+
private alchemy;
|
|
11
|
+
constructor(args: ConcreteEthereumWalletStrategyArgs & {
|
|
12
|
+
derivationPathType: LedgerDerivationPathType;
|
|
13
|
+
});
|
|
14
|
+
getWalletDeviceType(): Promise<WalletDeviceType>;
|
|
15
|
+
enable(): Promise<boolean>;
|
|
16
|
+
disconnect(): Promise<void>;
|
|
17
|
+
getAddresses(): Promise<string[]>;
|
|
18
|
+
getSessionOrConfirm(address: AccountAddress): Promise<string>;
|
|
19
|
+
sendEthereumTransaction(txData: any, options: {
|
|
20
|
+
address: string;
|
|
21
|
+
ethereumChainId: EthereumChainId;
|
|
22
|
+
}): Promise<string>;
|
|
23
|
+
sendTransaction(transaction: TxRaw, options: SendTransactionOptions): Promise<TxResponse>;
|
|
24
|
+
signEip712TypedData(eip712json: string, address: AccountAddress): Promise<string>;
|
|
25
|
+
signAminoCosmosTransaction(_transaction: {
|
|
26
|
+
address: string;
|
|
27
|
+
signDoc: StdSignDoc;
|
|
28
|
+
}): Promise<AminoSignResponse>;
|
|
29
|
+
signCosmosTransaction(_transaction: {
|
|
30
|
+
txRaw: TxRaw;
|
|
31
|
+
accountNumber: number;
|
|
32
|
+
chainId: string;
|
|
33
|
+
address: string;
|
|
34
|
+
}): Promise<DirectSignResponse>;
|
|
35
|
+
signArbitrary(signer: AccountAddress, data: string | Uint8Array): Promise<string>;
|
|
36
|
+
getEthereumChainId(): Promise<string>;
|
|
37
|
+
getEthereumTransactionReceipt(txHash: string): Promise<string>;
|
|
38
|
+
getPubKey(): Promise<string>;
|
|
39
|
+
private signEthereumTransaction;
|
|
40
|
+
private getWalletForAddress;
|
|
41
|
+
private getAlchemy;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=Base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Base.d.ts","sourceRoot":"","sources":["../../../../src/strategy/Ledger/Base.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAYzE,OAAO,EAEL,KAAK,EAEL,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACL,UAAU,EAGV,gBAAgB,EAEhB,oBAAoB,EACpB,sBAAsB,EACtB,sBAAsB,EACtB,kCAAkC,EAKnC,MAAM,4BAA4B,CAAA;AAInC,OAAO,EAAE,wBAAwB,EAAoB,MAAM,aAAa,CAAA;AAkBxE,MAAM,CAAC,OAAO,OAAO,UACnB,SAAQ,oBACR,YAAW,sBAAsB;IAEjC,OAAO,CAAC,kBAAkB,CAAQ;IAElC,OAAO,CAAC,kBAAkB,CAA0B;IAEpD,OAAO,CAAC,MAAM,CAAU;IAExB,OAAO,CAAC,eAAe,CAA+B;IAEtD,OAAO,CAAC,OAAO,CAAqB;gBAGlC,IAAI,EAAE,kCAAkC,GAAG;QACzC,kBAAkB,EAAE,wBAAwB,CAAA;KAC7C;IAUG,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAIhD,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC;IAInB,UAAU;IAIV,YAAY,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAmBxC,mBAAmB,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;IAQ7D,uBAAuB,CAC3B,MAAM,EAAE,GAAG,EACX,OAAO,EAAE;QACP,OAAO,EAAE,MAAM,CAAA;QACf,eAAe,EAAE,eAAe,CAAA;KACjC,GACA,OAAO,CAAC,MAAM,CAAC;IAsBZ,eAAe,CACnB,WAAW,EAAE,KAAK,EAClB,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,UAAU,CAAC;IAyBhB,mBAAmB,CACvB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,MAAM,CAAC;IAwBZ,0BAA0B,CAAC,YAAY,EAAE;QAC7C,OAAO,EAAE,MAAM,CAAA;QACf,OAAO,EAAE,UAAU,CAAA;KACpB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAYxB,qBAAqB,CAAC,YAAY,EAAE;QACxC,KAAK,EAAE,KAAK,CAAA;QACZ,aAAa,EAAE,MAAM,CAAA;QACrB,OAAO,EAAE,MAAM,CAAA;QACf,OAAO,EAAE,MAAM,CAAA;KAChB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAWzB,aAAa,CACjB,MAAM,EAAE,cAAc,EACtB,IAAI,EAAE,MAAM,GAAG,UAAU,GACxB,OAAO,CAAC,MAAM,CAAC;IAsBZ,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAOrC,6BAA6B,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAK9D,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;YAMpB,uBAAuB;YAkEvB,mBAAmB;YAsCnB,UAAU;CAuBzB"}
|
|
@@ -0,0 +1,302 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
/* eslint-disable class-methods-use-this */
|
|
39
|
+
const ts_types_1 = require("@injectivelabs/ts-types");
|
|
40
|
+
const ethereumjs_util_1 = require("ethereumjs-util");
|
|
41
|
+
const common_1 = require("@ethereumjs/common");
|
|
42
|
+
const tx_1 = require("@ethereumjs/tx");
|
|
43
|
+
const exceptions_1 = require("@injectivelabs/exceptions");
|
|
44
|
+
const sdk_ts_1 = require("@injectivelabs/sdk-ts");
|
|
45
|
+
const wallet_base_1 = require("@injectivelabs/wallet-base");
|
|
46
|
+
const hw_1 = __importDefault(require("./hw"));
|
|
47
|
+
const utils_1 = require("./utils");
|
|
48
|
+
const alchemy_sdk_1 = require("alchemy-sdk");
|
|
49
|
+
const getNetworkFromChainId = (chainId) => {
|
|
50
|
+
if (chainId === ts_types_1.EthereumChainId.Goerli) {
|
|
51
|
+
return common_1.Chain.Goerli;
|
|
52
|
+
}
|
|
53
|
+
if (chainId === ts_types_1.EthereumChainId.Sepolia) {
|
|
54
|
+
return common_1.Chain.Sepolia;
|
|
55
|
+
}
|
|
56
|
+
if (chainId === ts_types_1.EthereumChainId.Kovan) {
|
|
57
|
+
return common_1.Chain.Goerli;
|
|
58
|
+
}
|
|
59
|
+
return common_1.Chain.Mainnet;
|
|
60
|
+
};
|
|
61
|
+
class LedgerBase extends wallet_base_1.BaseConcreteStrategy {
|
|
62
|
+
constructor(args) {
|
|
63
|
+
super(args);
|
|
64
|
+
this.baseDerivationPath = wallet_base_1.DEFAULT_BASE_DERIVATION_PATH;
|
|
65
|
+
this.derivationPathType = args.derivationPathType;
|
|
66
|
+
this.ledger = new hw_1.default();
|
|
67
|
+
this.ethereumOptions = args.ethereumOptions;
|
|
68
|
+
}
|
|
69
|
+
getWalletDeviceType() {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
return Promise.resolve(wallet_base_1.WalletDeviceType.Hardware);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
enable() {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
return Promise.resolve(true);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
disconnect() {
|
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
this.ledger = yield this.ledger.refresh();
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
getAddresses() {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
const { baseDerivationPath, derivationPathType } = this;
|
|
87
|
+
try {
|
|
88
|
+
const accountManager = yield this.ledger.getAccountManager();
|
|
89
|
+
const wallets = yield accountManager.getWallets(baseDerivationPath, derivationPathType);
|
|
90
|
+
return wallets.map((k) => k.address);
|
|
91
|
+
}
|
|
92
|
+
catch (e) {
|
|
93
|
+
throw new exceptions_1.LedgerException(new Error(e.message), {
|
|
94
|
+
code: exceptions_1.UnspecifiedErrorCode,
|
|
95
|
+
type: exceptions_1.ErrorType.WalletError,
|
|
96
|
+
contextModule: wallet_base_1.WalletAction.GetAccounts,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
getSessionOrConfirm(address) {
|
|
102
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
return Promise.resolve(`0x${Buffer.from(`Confirmation for ${address} at time: ${Date.now()}`).toString('hex')}`);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
sendEthereumTransaction(txData, options) {
|
|
107
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
+
const signedTransaction = yield this.signEthereumTransaction(txData, options);
|
|
109
|
+
try {
|
|
110
|
+
const alchemy = yield this.getAlchemy();
|
|
111
|
+
const txReceipt = yield alchemy.core.sendTransaction((0, ethereumjs_util_1.addHexPrefix)(signedTransaction.serialize().toString('hex')));
|
|
112
|
+
return txReceipt.hash;
|
|
113
|
+
}
|
|
114
|
+
catch (e) {
|
|
115
|
+
throw new exceptions_1.LedgerException(new Error(e.message), {
|
|
116
|
+
code: exceptions_1.UnspecifiedErrorCode,
|
|
117
|
+
type: exceptions_1.ErrorType.WalletError,
|
|
118
|
+
contextModule: wallet_base_1.WalletAction.SendEthereumTransaction,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
sendTransaction(transaction, options) {
|
|
124
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
125
|
+
const { endpoints, txTimeout } = options;
|
|
126
|
+
if (!endpoints) {
|
|
127
|
+
throw new exceptions_1.WalletException(new Error('You have to pass endpoints.grpc within the options for using Ethereum native wallets'));
|
|
128
|
+
}
|
|
129
|
+
const txApi = new sdk_ts_1.TxGrpcApi(endpoints.grpc);
|
|
130
|
+
const response = yield txApi.broadcast(transaction, { txTimeout });
|
|
131
|
+
if (response.code !== 0) {
|
|
132
|
+
throw new exceptions_1.TransactionException(new Error(response.rawLog), {
|
|
133
|
+
code: exceptions_1.UnspecifiedErrorCode,
|
|
134
|
+
contextCode: response.code,
|
|
135
|
+
contextModule: response.codespace,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
return response;
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
signEip712TypedData(eip712json, address) {
|
|
142
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
143
|
+
const { derivationPath } = yield this.getWalletForAddress(address);
|
|
144
|
+
const object = JSON.parse(eip712json);
|
|
145
|
+
try {
|
|
146
|
+
const ledger = yield this.ledger.getInstance();
|
|
147
|
+
const result = yield ledger.signEIP712HashedMessage(derivationPath, (0, ethereumjs_util_1.bufferToHex)((0, utils_1.domainHash)(object)), (0, ethereumjs_util_1.bufferToHex)((0, utils_1.messageHash)(object)));
|
|
148
|
+
const combined = `${result.r}${result.s}${result.v.toString(16)}`;
|
|
149
|
+
return combined.startsWith('0x') ? combined : `0x${combined}`;
|
|
150
|
+
}
|
|
151
|
+
catch (e) {
|
|
152
|
+
throw new exceptions_1.LedgerException(new Error(e.message), {
|
|
153
|
+
code: exceptions_1.UnspecifiedErrorCode,
|
|
154
|
+
type: exceptions_1.ErrorType.WalletError,
|
|
155
|
+
contextModule: wallet_base_1.WalletAction.SignTransaction,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
signAminoCosmosTransaction(_transaction) {
|
|
161
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
162
|
+
throw new exceptions_1.WalletException(new Error('This wallet does not support signing Cosmos transactions'), {
|
|
163
|
+
code: exceptions_1.UnspecifiedErrorCode,
|
|
164
|
+
type: exceptions_1.ErrorType.WalletError,
|
|
165
|
+
contextModule: wallet_base_1.WalletAction.SendTransaction,
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
// eslint-disable-next-line class-methods-use-this
|
|
170
|
+
signCosmosTransaction(_transaction) {
|
|
171
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
172
|
+
throw new exceptions_1.WalletException(new Error('This wallet does not support signing Cosmos transactions'), {
|
|
173
|
+
code: exceptions_1.UnspecifiedErrorCode,
|
|
174
|
+
type: exceptions_1.ErrorType.WalletError,
|
|
175
|
+
contextModule: wallet_base_1.WalletAction.SendTransaction,
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
signArbitrary(signer, data) {
|
|
180
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
181
|
+
try {
|
|
182
|
+
const { derivationPath } = yield this.getWalletForAddress(signer);
|
|
183
|
+
const ledger = yield this.ledger.getInstance();
|
|
184
|
+
const result = yield ledger.signPersonalMessage(derivationPath, Buffer.from((0, sdk_ts_1.toUtf8)(data), 'utf8').toString('hex'));
|
|
185
|
+
const combined = `${result.r}${result.s}${result.v.toString(16)}`;
|
|
186
|
+
return combined.startsWith('0x') ? combined : `0x${combined}`;
|
|
187
|
+
}
|
|
188
|
+
catch (e) {
|
|
189
|
+
throw new exceptions_1.LedgerException(new Error(e.message), {
|
|
190
|
+
code: exceptions_1.UnspecifiedErrorCode,
|
|
191
|
+
type: exceptions_1.ErrorType.WalletError,
|
|
192
|
+
contextModule: wallet_base_1.WalletAction.SignTransaction,
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
getEthereumChainId() {
|
|
198
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
199
|
+
const alchemy = yield this.getAlchemy();
|
|
200
|
+
const alchemyProvider = yield alchemy.config.getProvider();
|
|
201
|
+
return alchemyProvider.network.chainId.toString();
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
getEthereumTransactionReceipt(txHash) {
|
|
205
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
206
|
+
return Promise.resolve(txHash);
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
// eslint-disable-next-line class-methods-use-this
|
|
210
|
+
getPubKey() {
|
|
211
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
212
|
+
throw new exceptions_1.WalletException(new Error('You can only fetch PubKey from Cosmos native wallets'));
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
signEthereumTransaction(txData, options) {
|
|
216
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
217
|
+
const alchemy = yield this.getAlchemy();
|
|
218
|
+
const chainId = parseInt(options.ethereumChainId.toString(), 10);
|
|
219
|
+
const nonce = yield alchemy.core.getTransactionCount(options.address);
|
|
220
|
+
const common = new common_1.Common({
|
|
221
|
+
chain: getNetworkFromChainId(chainId),
|
|
222
|
+
hardfork: common_1.Hardfork.London,
|
|
223
|
+
});
|
|
224
|
+
const eip1559TxData = {
|
|
225
|
+
from: txData.from,
|
|
226
|
+
data: txData.data,
|
|
227
|
+
to: txData.to,
|
|
228
|
+
nonce: (0, ethereumjs_util_1.addHexPrefix)(nonce.toString(16)),
|
|
229
|
+
gas: (0, ethereumjs_util_1.addHexPrefix)(txData.gas),
|
|
230
|
+
gasLimit: (0, ethereumjs_util_1.addHexPrefix)(txData.gas),
|
|
231
|
+
maxFeePerGas: (0, ethereumjs_util_1.addHexPrefix)(txData.gasPrice || txData.maxFeePerGas),
|
|
232
|
+
maxPriorityFeePerGas: (0, ethereumjs_util_1.addHexPrefix)(txData.maxPriorityFeePerGas || wallet_base_1.TIP_IN_GWEI.toString(16)),
|
|
233
|
+
};
|
|
234
|
+
const tx = tx_1.FeeMarketEIP1559Transaction.fromTxData(eip1559TxData, { common });
|
|
235
|
+
const msg = tx.getMessageToSign(false);
|
|
236
|
+
// const encodedMessage = msg
|
|
237
|
+
const encodedMessageHex = msg.toString('hex');
|
|
238
|
+
try {
|
|
239
|
+
const ledger = yield this.ledger.getInstance();
|
|
240
|
+
const { derivationPath } = yield this.getWalletForAddress(options.address);
|
|
241
|
+
const ledgerService = yield Promise.resolve().then(() => __importStar(require('@ledgerhq/hw-app-eth/lib/services/ledger')));
|
|
242
|
+
const resolution = yield ledgerService.default.resolveTransaction(encodedMessageHex, {}, {});
|
|
243
|
+
const txSig = yield ledger.signTransaction(derivationPath, encodedMessageHex, resolution);
|
|
244
|
+
const signedTxData = Object.assign(Object.assign({}, eip1559TxData), { v: `0x${txSig.v}`, r: `0x${txSig.r}`, s: `0x${txSig.s}` });
|
|
245
|
+
return tx_1.FeeMarketEIP1559Transaction.fromTxData(signedTxData, {
|
|
246
|
+
common,
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
catch (e) {
|
|
250
|
+
throw new exceptions_1.LedgerException(new Error(e.message), {
|
|
251
|
+
code: exceptions_1.UnspecifiedErrorCode,
|
|
252
|
+
type: exceptions_1.ErrorType.WalletError,
|
|
253
|
+
contextModule: wallet_base_1.WalletAction.SignEthereumTransaction,
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
getWalletForAddress(address) {
|
|
259
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
260
|
+
try {
|
|
261
|
+
const { baseDerivationPath, derivationPathType } = this;
|
|
262
|
+
const accountManager = yield this.ledger.getAccountManager();
|
|
263
|
+
if (!accountManager.hasWalletForAddress(address)) {
|
|
264
|
+
for (let i = 0; i < wallet_base_1.DEFAULT_ADDRESS_SEARCH_LIMIT / wallet_base_1.DEFAULT_NUM_ADDRESSES_TO_FETCH; i += 1) {
|
|
265
|
+
yield accountManager.getWallets(baseDerivationPath, derivationPathType);
|
|
266
|
+
if (accountManager.hasWalletForAddress(address)) {
|
|
267
|
+
return (yield accountManager.getWalletForAddress(address));
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return (yield accountManager.getWalletForAddress(address));
|
|
272
|
+
}
|
|
273
|
+
catch (e) {
|
|
274
|
+
throw new exceptions_1.LedgerException(new Error(e.message), {
|
|
275
|
+
code: exceptions_1.UnspecifiedErrorCode,
|
|
276
|
+
type: exceptions_1.ErrorType.WalletError,
|
|
277
|
+
contextModule: wallet_base_1.WalletAction.GetAccounts,
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
getAlchemy() {
|
|
283
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
284
|
+
if (this.alchemy) {
|
|
285
|
+
return this.alchemy;
|
|
286
|
+
}
|
|
287
|
+
const { rpcUrl, ethereumChainId } = this.ethereumOptions;
|
|
288
|
+
if (!rpcUrl) {
|
|
289
|
+
throw new exceptions_1.GeneralException(new Error('Please pass rpcUrl within the ethereumOptions'));
|
|
290
|
+
}
|
|
291
|
+
this.alchemy = new alchemy_sdk_1.Alchemy({
|
|
292
|
+
apiKey: (0, wallet_base_1.getKeyFromRpcUrl)(rpcUrl),
|
|
293
|
+
network: ethereumChainId === ts_types_1.EthereumChainId.Mainnet
|
|
294
|
+
? alchemy_sdk_1.Network.ETH_MAINNET
|
|
295
|
+
: alchemy_sdk_1.Network.ETH_SEPOLIA,
|
|
296
|
+
});
|
|
297
|
+
return this.alchemy;
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
exports.default = LedgerBase;
|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AC,OAAO,CAAA;YACrB,CAAC;YAED,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC,eAAe,CAAA;YAExD,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,MAAM,IAAI,6BAAgB,CACxB,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAC3D,CAAA;YACH,CAAC;YAED,IAAI,CAAC,OAAO,GAAG,IAAI,qBAAO,CAAC;gBACzB,MAAM,EAAE,IAAA,8BAAgB,EAAC,MAAM,CAAC;gBAChC,OAAO,EACL,eAAe,KAAK,0BAAe,CAAC,OAAO;oBACzC,CAAC,CAAC,qBAAc,CAAC,WAAW;oBAC5B,CAAC,CAAC,qBAAc,CAAC,WAAW;aACjC,CAAC,CAAA;YAEF,OAAO,IAAI,CAAC,OAAO,CAAA;QACrB,CAAC;KAAA;CACF;AA9VD,6BA8VC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ConcreteEthereumWalletStrategyArgs } from '@injectivelabs/wallet-base';
|
|
2
|
+
import LedgerBase from './Base';
|
|
3
|
+
export declare class LedgerLegacy extends LedgerBase {
|
|
4
|
+
constructor(args: ConcreteEthereumWalletStrategyArgs);
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=LedgerLegacy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LedgerLegacy.d.ts","sourceRoot":"","sources":["../../../../src/strategy/Ledger/LedgerLegacy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kCAAkC,EAAE,MAAM,4BAA4B,CAAA;AAE/E,OAAO,UAAU,MAAM,QAAQ,CAAA;AAE/B,qBAAa,YAAa,SAAQ,UAAU;gBAC9B,IAAI,EAAE,kCAAkC;CAMrD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.LedgerLegacy = void 0;
|
|
7
|
+
const types_1 = require("../../types");
|
|
8
|
+
const Base_1 = __importDefault(require("./Base"));
|
|
9
|
+
class LedgerLegacy extends Base_1.default {
|
|
10
|
+
constructor(args) {
|
|
11
|
+
super(Object.assign(Object.assign({}, args), { derivationPathType: types_1.LedgerDerivationPathType.LedgerMew }));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.LedgerLegacy = LedgerLegacy;
|
|
15
|
+
//# sourceMappingURL=LedgerLegacy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LedgerLegacy.js","sourceRoot":"","sources":["../../../../src/strategy/Ledger/LedgerLegacy.ts"],"names":[],"mappings":";;;;;;AAEA,uCAAsD;AACtD,kDAA+B;AAE/B,MAAa,YAAa,SAAQ,cAAU;IAC1C,YAAY,IAAwC;QAClD,KAAK,iCACA,IAAI,KACP,kBAAkB,EAAE,gCAAwB,CAAC,SAAS,IACtD,CAAA;IACJ,CAAC;CACF;AAPD,oCAOC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ConcreteEthereumWalletStrategyArgs } from '@injectivelabs/wallet-base';
|
|
2
|
+
import LedgerBase from './Base';
|
|
3
|
+
export declare class LedgerLive extends LedgerBase {
|
|
4
|
+
constructor(args: ConcreteEthereumWalletStrategyArgs);
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=LedgerLive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LedgerLive.d.ts","sourceRoot":"","sources":["../../../../src/strategy/Ledger/LedgerLive.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kCAAkC,EAAE,MAAM,4BAA4B,CAAA;AAE/E,OAAO,UAAU,MAAM,QAAQ,CAAA;AAE/B,qBAAa,UAAW,SAAQ,UAAU;gBAC5B,IAAI,EAAE,kCAAkC;CAMrD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.LedgerLive = void 0;
|
|
7
|
+
const types_1 = require("../../types");
|
|
8
|
+
const Base_1 = __importDefault(require("./Base"));
|
|
9
|
+
class LedgerLive extends Base_1.default {
|
|
10
|
+
constructor(args) {
|
|
11
|
+
super(Object.assign(Object.assign({}, args), { derivationPathType: types_1.LedgerDerivationPathType.LedgerLive }));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.LedgerLive = LedgerLive;
|
|
15
|
+
//# sourceMappingURL=LedgerLive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LedgerLive.js","sourceRoot":"","sources":["../../../../src/strategy/Ledger/LedgerLive.ts"],"names":[],"mappings":";;;;;;AAEA,uCAAsD;AACtD,kDAA+B;AAE/B,MAAa,UAAW,SAAQ,cAAU;IACxC,YAAY,IAAwC;QAClD,KAAK,iCACA,IAAI,KACP,kBAAkB,EAAE,gCAAwB,CAAC,UAAU,IACvD,CAAA;IACJ,CAAC;CACF;AAPD,gCAOC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AccountAddress } from '@injectivelabs/ts-types';
|
|
2
|
+
import type EthereumApp from '@ledgerhq/hw-app-eth';
|
|
3
|
+
import { LedgerDerivationPathType, LedgerWalletInfo } from '../../../types';
|
|
4
|
+
export default class AccountManager {
|
|
5
|
+
private wallets;
|
|
6
|
+
private ledger;
|
|
7
|
+
constructor(ledger: EthereumApp);
|
|
8
|
+
getWallets(baseDerivationPath: string, derivationPathType: LedgerDerivationPathType): Promise<LedgerWalletInfo[]>;
|
|
9
|
+
getLedgerDerivationPathBasedOnType: ({ fullBaseDerivationPath, derivationPathType, index, }: {
|
|
10
|
+
fullBaseDerivationPath: string;
|
|
11
|
+
derivationPathType: LedgerDerivationPathType;
|
|
12
|
+
index: number;
|
|
13
|
+
}) => string;
|
|
14
|
+
private getWalletsBasedOnIndex;
|
|
15
|
+
private hasWallets;
|
|
16
|
+
private hasWalletsInOffset;
|
|
17
|
+
private getOffset;
|
|
18
|
+
hasWalletForAddress(address: AccountAddress): boolean;
|
|
19
|
+
getWalletForAddress(address: AccountAddress): Promise<LedgerWalletInfo | undefined>;
|
|
20
|
+
reset(): void;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=AccountManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccountManager.d.ts","sourceRoot":"","sources":["../../../../../src/strategy/Ledger/hw/AccountManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAGxD,OAAO,KAAK,WAAW,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAe3E,MAAM,CAAC,OAAO,OAAO,cAAc;IACjC,OAAO,CAAC,OAAO,CAAyB;IAExC,OAAO,CAAC,MAAM,CAAa;gBAEf,MAAM,EAAE,WAAW;IAKzB,UAAU,CACd,kBAAkB,EAAE,MAAM,EAC1B,kBAAkB,EAAE,wBAAwB,GAC3C,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAmB9B,kCAAkC;gCAKR,MAAM;4BACV,wBAAwB;eACrC,MAAM;UACX,MAAM,CAMT;YAEa,sBAAsB;IAiCpC,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,kBAAkB;IAI1B,OAAO,CAAC,SAAS;IAWjB,mBAAmB,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO;IAQ/C,mBAAmB,CACvB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAMxC,KAAK;CAGN"}
|