Merge pull request #793 from cosmos/destructuring-bug
Fix destructuring bug
This commit is contained in:
commit
d4d84c8e60
@ -19,6 +19,8 @@ and this project adheres to
|
||||
|
||||
- @cosmjs/cosmwasm-stargate: Use `CosmWasmFeeTable` instead of `CosmosFeeTable`
|
||||
in `SigningCosmWasmClientOptions`; export type `CosmWasmFeeTable`.
|
||||
- @cosmjs/amino, @cosmjs/cli, @cosmjs/ledger-amino, @cosmjs/proto-signing: Fix
|
||||
runtime error caused by passing explicitly undefined options.
|
||||
|
||||
## [0.25.0] - 2021-05-05
|
||||
|
||||
|
||||
@ -33,6 +33,18 @@ describe("Secp256k1HdWallet", () => {
|
||||
expect(account.pubkey).not.toEqual(defaultPubkey);
|
||||
expect(account.address.slice(0, 4)).toEqual("yolo");
|
||||
});
|
||||
|
||||
it("works with explicitly undefined options", async () => {
|
||||
const wallet = await Secp256k1HdWallet.fromMnemonic(defaultMnemonic, {
|
||||
bip39Password: undefined,
|
||||
hdPaths: undefined,
|
||||
prefix: undefined,
|
||||
});
|
||||
expect(wallet.mnemonic).toEqual(defaultMnemonic);
|
||||
const [account] = await wallet.getAccounts();
|
||||
expect(account.pubkey).toEqual(defaultPubkey);
|
||||
expect(account.address).toEqual(defaultAddress);
|
||||
});
|
||||
});
|
||||
|
||||
describe("generate", () => {
|
||||
|
||||
@ -246,12 +246,13 @@ export class Secp256k1HdWallet implements OfflineAminoSigner {
|
||||
private readonly accounts: readonly DerivationInfo[];
|
||||
|
||||
protected constructor(mnemonic: EnglishMnemonic, options: Secp256k1HdWalletConstructorOptions) {
|
||||
const { seed, hdPaths, prefix } = { ...defaultOptions, ...options };
|
||||
const hdPaths = options.hdPaths ?? defaultOptions.hdPaths;
|
||||
const prefix = options.prefix ?? defaultOptions.prefix;
|
||||
this.secret = mnemonic;
|
||||
this.seed = seed;
|
||||
this.seed = options.seed;
|
||||
this.accounts = hdPaths.map((hdPath) => ({
|
||||
hdPath: hdPath,
|
||||
prefix: prefix,
|
||||
prefix,
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@ -30,7 +30,13 @@ const connect = async (
|
||||
client: SigningCosmWasmClient;
|
||||
address: string;
|
||||
}> => {
|
||||
const options: Options = { ...defaultOptions, ...opts };
|
||||
const options: Options = {
|
||||
bech32prefix: opts.bech32prefix ?? defaultOptions.bech32prefix,
|
||||
feeToken: opts.feeToken ?? defaultOptions.feeToken,
|
||||
gasPrice: opts.gasPrice ?? defaultOptions.gasPrice,
|
||||
httpUrl: opts.httpUrl ?? defaultOptions.httpUrl,
|
||||
networkId: opts.networkId ?? defaultOptions.networkId,
|
||||
};
|
||||
const gasPrice = GasPrice.fromString(`${options.gasPrice}${options.feeToken}`);
|
||||
const wallet = await Secp256k1HdWallet.fromMnemonic(mnemonic);
|
||||
const [{ address }] = await wallet.getAccounts();
|
||||
|
||||
@ -44,13 +44,10 @@ export class LaunchpadLedger {
|
||||
prefix: cosmosBech32Prefix,
|
||||
testModeAllowed: false,
|
||||
};
|
||||
const { hdPaths, prefix, testModeAllowed } = {
|
||||
...defaultOptions,
|
||||
...options,
|
||||
};
|
||||
this.testModeAllowed = testModeAllowed;
|
||||
this.hdPaths = hdPaths;
|
||||
this.prefix = prefix;
|
||||
|
||||
this.testModeAllowed = options.testModeAllowed ?? defaultOptions.testModeAllowed;
|
||||
this.hdPaths = options.hdPaths ?? defaultOptions.hdPaths;
|
||||
this.prefix = options.prefix ?? defaultOptions.prefix;
|
||||
this.app = new CosmosApp(transport);
|
||||
}
|
||||
|
||||
|
||||
@ -31,6 +31,18 @@ describe("DirectSecp256k1HdWallet", () => {
|
||||
expect(pubkey).not.toEqual(defaultPubkey);
|
||||
expect(address.slice(0, 4)).toEqual("yolo");
|
||||
});
|
||||
|
||||
it("works with explicitly undefined options", async () => {
|
||||
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(defaultMnemonic, {
|
||||
bip39Password: undefined,
|
||||
hdPaths: undefined,
|
||||
prefix: undefined,
|
||||
});
|
||||
expect(wallet.mnemonic).toEqual(defaultMnemonic);
|
||||
const [{ pubkey, address }] = await wallet.getAccounts();
|
||||
expect(pubkey).toEqual(defaultPubkey);
|
||||
expect(address).toEqual(defaultAddress);
|
||||
});
|
||||
});
|
||||
|
||||
describe("generate", () => {
|
||||
|
||||
@ -91,9 +91,10 @@ export class DirectSecp256k1HdWallet implements OfflineDirectSigner {
|
||||
private readonly accounts: readonly Secp256k1Derivation[];
|
||||
|
||||
protected constructor(mnemonic: EnglishMnemonic, options: DirectSecp256k1HdWalletConstructorOptions) {
|
||||
const { seed, hdPaths, prefix } = { ...defaultOptions, ...options };
|
||||
const prefix = options.prefix ?? defaultOptions.prefix;
|
||||
const hdPaths = options.hdPaths ?? defaultOptions.hdPaths;
|
||||
this.secret = mnemonic;
|
||||
this.seed = seed;
|
||||
this.seed = options.seed;
|
||||
this.accounts = hdPaths.map((hdPath) => ({
|
||||
hdPath: hdPath,
|
||||
prefix: prefix,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user