mirror of
https://github.com/cosmos/cosmjs.git
synced 2025-03-11 14:09:15 +00:00
launchpad-ledger: Remove disconnect method
This commit is contained in:
parent
974ed65c92
commit
a8c325ba62
@ -36,8 +36,7 @@ export class LaunchpadLedger {
|
|||||||
private readonly testModeAllowed: boolean;
|
private readonly testModeAllowed: boolean;
|
||||||
private readonly hdPaths: readonly HdPath[];
|
private readonly hdPaths: readonly HdPath[];
|
||||||
private readonly prefix: string;
|
private readonly prefix: string;
|
||||||
private readonly transport: LedgerTransport;
|
private readonly app: CosmosApp | null;
|
||||||
private app: CosmosApp | null;
|
|
||||||
|
|
||||||
public constructor(transport: LedgerTransport, options: LaunchpadLedgerOptions = {}) {
|
public constructor(transport: LedgerTransport, options: LaunchpadLedgerOptions = {}) {
|
||||||
const defaultOptions = {
|
const defaultOptions = {
|
||||||
@ -52,7 +51,6 @@ export class LaunchpadLedger {
|
|||||||
this.testModeAllowed = testModeAllowed;
|
this.testModeAllowed = testModeAllowed;
|
||||||
this.hdPaths = hdPaths;
|
this.hdPaths = hdPaths;
|
||||||
this.prefix = prefix;
|
this.prefix = prefix;
|
||||||
this.transport = transport;
|
|
||||||
this.app = new CosmosApp(transport);
|
this.app = new CosmosApp(transport);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,13 +101,6 @@ export class LaunchpadLedger {
|
|||||||
return Secp256k1Signature.fromDer((response as SignResponse).signature).toFixedLength();
|
return Secp256k1Signature.fromDer((response as SignResponse).signature).toFixedLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async disconnect(): Promise<void> {
|
|
||||||
if (this.app) {
|
|
||||||
await this.transport.close();
|
|
||||||
this.app = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private verifyAppMode(testMode: boolean): void {
|
private verifyAppMode(testMode: boolean): void {
|
||||||
if (testMode && !this.testModeAllowed) {
|
if (testMode && !this.testModeAllowed) {
|
||||||
throw new Error(`DANGER: The Cosmos Ledger app is in test mode and should not be used on mainnet!`);
|
throw new Error(`DANGER: The Cosmos Ledger app is in test mode and should not be used on mainnet!`);
|
||||||
|
@ -74,8 +74,6 @@ describe("LedgerSigner", () => {
|
|||||||
pubkey: fromBase64("A2ZnLEcbpyjS30H5UF1vezq29aBcT9oo5EARATIW9Cpj"),
|
pubkey: fromBase64("A2ZnLEcbpyjS30H5UF1vezq29aBcT9oo5EARATIW9Cpj"),
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
await signer.disconnect();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -123,8 +121,6 @@ describe("LedgerSigner", () => {
|
|||||||
fistAccount.pubkey,
|
fistAccount.pubkey,
|
||||||
);
|
);
|
||||||
expect(valid).toEqual(true);
|
expect(valid).toEqual(true);
|
||||||
|
|
||||||
await signer.disconnect();
|
|
||||||
},
|
},
|
||||||
interactiveTimeout,
|
interactiveTimeout,
|
||||||
);
|
);
|
||||||
@ -144,8 +140,6 @@ describe("LedgerSigner", () => {
|
|||||||
const client = new SigningCosmosClient(wasmd.endpoint, fistAccount.address, signer);
|
const client = new SigningCosmosClient(wasmd.endpoint, fistAccount.address, signer);
|
||||||
const result = await client.sendTokens(defaultRecipient, coins(1234567, "ucosm"));
|
const result = await client.sendTokens(defaultRecipient, coins(1234567, "ucosm"));
|
||||||
assert(isBroadcastTxSuccess(result));
|
assert(isBroadcastTxSuccess(result));
|
||||||
|
|
||||||
await signer.disconnect();
|
|
||||||
},
|
},
|
||||||
interactiveTimeout,
|
interactiveTimeout,
|
||||||
);
|
);
|
||||||
|
@ -53,8 +53,4 @@ export class LedgerSigner implements OfflineSigner {
|
|||||||
signature: encodeSecp256k1Signature(accountForAddress.pubkey, signature),
|
signature: encodeSecp256k1Signature(accountForAddress.pubkey, signature),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public async disconnect(): Promise<void> {
|
|
||||||
return this.ledger.disconnect();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -14,15 +14,13 @@ export declare class LaunchpadLedger {
|
|||||||
private readonly testModeAllowed;
|
private readonly testModeAllowed;
|
||||||
private readonly hdPaths;
|
private readonly hdPaths;
|
||||||
private readonly prefix;
|
private readonly prefix;
|
||||||
private readonly transport;
|
private readonly app;
|
||||||
private app;
|
|
||||||
constructor(transport: LedgerTransport, options?: LaunchpadLedgerOptions);
|
constructor(transport: LedgerTransport, options?: LaunchpadLedgerOptions);
|
||||||
getCosmosAppVersion(): Promise<string>;
|
getCosmosAppVersion(): Promise<string>;
|
||||||
getPubkey(hdPath?: HdPath): Promise<Uint8Array>;
|
getPubkey(hdPath?: HdPath): Promise<Uint8Array>;
|
||||||
getPubkeys(): Promise<readonly Uint8Array[]>;
|
getPubkeys(): Promise<readonly Uint8Array[]>;
|
||||||
getCosmosAddress(pubkey?: Uint8Array): Promise<string>;
|
getCosmosAddress(pubkey?: Uint8Array): Promise<string>;
|
||||||
sign(message: Uint8Array, hdPath?: HdPath): Promise<Uint8Array>;
|
sign(message: Uint8Array, hdPath?: HdPath): Promise<Uint8Array>;
|
||||||
disconnect(): Promise<void>;
|
|
||||||
private verifyAppMode;
|
private verifyAppMode;
|
||||||
private getOpenAppName;
|
private getOpenAppName;
|
||||||
private verifyAppVersion;
|
private verifyAppVersion;
|
||||||
|
@ -10,5 +10,4 @@ export declare class LedgerSigner implements OfflineSigner {
|
|||||||
constructor(transport: LedgerTransport, options?: LaunchpadLedgerOptions);
|
constructor(transport: LedgerTransport, options?: LaunchpadLedgerOptions);
|
||||||
getAccounts(): Promise<readonly AccountData[]>;
|
getAccounts(): Promise<readonly AccountData[]>;
|
||||||
sign(signerAddress: string, signDoc: StdSignDoc): Promise<SignResponse>;
|
sign(signerAddress: string, signDoc: StdSignDoc): Promise<SignResponse>;
|
||||||
disconnect(): Promise<void>;
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user