carbon-js-sdk 0.4.15 → 0.4.16
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/CarbonSDK.js
CHANGED
|
@@ -236,6 +236,10 @@ class CarbonSDK {
|
|
|
236
236
|
});
|
|
237
237
|
}
|
|
238
238
|
disconnect() {
|
|
239
|
+
var _a;
|
|
240
|
+
if ((_a = this.wallet) === null || _a === void 0 ? void 0 : _a.isLedgerSigner()) {
|
|
241
|
+
this.wallet.signer.ledger.disconnect();
|
|
242
|
+
}
|
|
239
243
|
return new CarbonSDK(Object.assign(Object.assign({}, this), { wallet: null, skipInit: true }));
|
|
240
244
|
}
|
|
241
245
|
connectWithPrivateKey(privateKey, opts) {
|
|
@@ -16,6 +16,7 @@ declare class KeplrAccount {
|
|
|
16
16
|
} | undefined;
|
|
17
17
|
};
|
|
18
18
|
static createKeplrSigner(keplr: Keplr, chainInfo: ChainInfo, account: Key): CarbonSigner;
|
|
19
|
+
static createKeplrSignerAmino(keplr: Keplr, chainInfo: ChainInfo, account: Key): CarbonSigner;
|
|
19
20
|
static queryFeeCurrencies(configProvider: SDKProvider): Promise<FeeCurrency[]>;
|
|
20
21
|
static processCurrencies(feeCurrencies: FeeCurrency[]): AppCurrency[];
|
|
21
22
|
static getChainInfo(configProvider: SDKProvider): Promise<ChainInfo>;
|
|
@@ -45,6 +45,26 @@ class KeplrAccount {
|
|
|
45
45
|
getAccounts,
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
|
+
static createKeplrSignerAmino(keplr, chainInfo, account) {
|
|
49
|
+
const signAmino = (signerAddress, doc) => __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
const signOpts = { preferNoSetFee: true };
|
|
51
|
+
return yield keplr.signAmino(chainInfo.chainId, signerAddress, doc, signOpts);
|
|
52
|
+
});
|
|
53
|
+
const getAccounts = () => __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
return [
|
|
55
|
+
{
|
|
56
|
+
algo: "secp256k1",
|
|
57
|
+
address: account.bech32Address,
|
|
58
|
+
pubkey: account.pubKey,
|
|
59
|
+
},
|
|
60
|
+
];
|
|
61
|
+
});
|
|
62
|
+
return {
|
|
63
|
+
type: wallet_1.CarbonSignerTypes.BrowserInjected,
|
|
64
|
+
signAmino,
|
|
65
|
+
getAccounts,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
48
68
|
static queryFeeCurrencies(configProvider) {
|
|
49
69
|
return __awaiter(this, void 0, void 0, function* () {
|
|
50
70
|
const tokenClient = configProvider.getTokenClient();
|
|
@@ -11,6 +11,7 @@ declare class CosmosLedger {
|
|
|
11
11
|
testDevice(): Promise<this>;
|
|
12
12
|
private isReady;
|
|
13
13
|
connect(timeout?: number): Promise<this>;
|
|
14
|
+
disconnect(): Promise<void>;
|
|
14
15
|
getCosmosAppVersion(): Promise<string>;
|
|
15
16
|
isCosmosAppOpen(): Promise<void>;
|
|
16
17
|
getOpenApp(): Promise<any>;
|
|
@@ -141,6 +141,11 @@ class CosmosLedger {
|
|
|
141
141
|
return this;
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
|
+
disconnect() {
|
|
145
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
146
|
+
yield this.cosmosApp.transport.close();
|
|
147
|
+
});
|
|
148
|
+
}
|
|
144
149
|
// returns the cosmos app version as a string like "1.1.0"
|
|
145
150
|
getCosmosAppVersion() {
|
|
146
151
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -110,7 +110,7 @@ class CarbonWallet {
|
|
|
110
110
|
publicKeyBase64 }));
|
|
111
111
|
}
|
|
112
112
|
static withKeplr(keplr, chainInfo, keplrKey, opts = {}) {
|
|
113
|
-
const signer = provider_1.KeplrAccount.createKeplrSigner(keplr, chainInfo, keplrKey);
|
|
113
|
+
const signer = keplrKey.isNanoLedger ? provider_1.KeplrAccount.createKeplrSignerAmino(keplr, chainInfo, keplrKey) : provider_1.KeplrAccount.createKeplrSigner(keplr, chainInfo, keplrKey);
|
|
114
114
|
const publicKeyBase64 = Buffer.from(keplrKey.pubKey).toString("base64");
|
|
115
115
|
const wallet = CarbonWallet.withSigner(signer, publicKeyBase64, Object.assign(Object.assign({}, opts), { providerAgent: 'keplr-extension' }));
|
|
116
116
|
return wallet;
|