Use string | PubKey | null as public key type
This commit is contained in:
parent
2b52c8e75d
commit
5ad11bdef6
@ -20,6 +20,9 @@
|
||||
- @cosmjs/sdk38: `BaseAccount` now uses `number | string` as the type for
|
||||
`account_number` and `sequence`. The new helpers `uint64ToNumber` and
|
||||
`uint64ToString` allow you to normalize the mixed input.
|
||||
- @cosmjs/sdk38: `BaseAccount` now uses `string | PubKey | null` as the type for
|
||||
`public_key`. The new helper `normalizePubkey` allows you to normalize the
|
||||
mixed input.
|
||||
- @cosmjs/math: Add missing integer check to `Uint64.fromNumber`. Before
|
||||
`Uint64.fromNumber(1.1)` produced some result.
|
||||
- @cosmjs/sdk38: Add `SigningCosmosClient.signAndPost` as a mid-level
|
||||
|
||||
@ -6,9 +6,9 @@ import {
|
||||
BroadcastMode,
|
||||
Coin,
|
||||
CosmosSdkTx,
|
||||
decodeBech32Pubkey,
|
||||
IndexedTx,
|
||||
LcdClient,
|
||||
normalizePubkey,
|
||||
PostTxResult,
|
||||
PubKey,
|
||||
setupAuthExtension,
|
||||
@ -234,7 +234,7 @@ export class CosmWasmClient {
|
||||
return {
|
||||
address: value.address,
|
||||
balance: value.coins,
|
||||
pubkey: value.public_key ? decodeBech32Pubkey(value.public_key) : undefined,
|
||||
pubkey: normalizePubkey(value.public_key) || undefined,
|
||||
accountNumber: uint64ToNumber(value.account_number),
|
||||
sequence: uint64ToNumber(value.sequence),
|
||||
};
|
||||
|
||||
@ -3,9 +3,15 @@ import { fromBase64, fromHex, toHex } from "@cosmjs/encoding";
|
||||
import { Uint53 } from "@cosmjs/math";
|
||||
|
||||
import { Coin } from "./coins";
|
||||
import { AuthExtension, BroadcastMode, LcdClient, setupAuthExtension, uint64ToNumber } from "./lcdapi";
|
||||
import {
|
||||
AuthExtension,
|
||||
BroadcastMode,
|
||||
LcdClient,
|
||||
normalizePubkey,
|
||||
setupAuthExtension,
|
||||
uint64ToNumber,
|
||||
} from "./lcdapi";
|
||||
import { Log, parseLogs } from "./logs";
|
||||
import { decodeBech32Pubkey } from "./pubkey";
|
||||
import { CosmosSdkTx, PubKey, StdTx } from "./types";
|
||||
|
||||
export interface GetSequenceResult {
|
||||
@ -234,7 +240,7 @@ export class CosmosClient {
|
||||
return {
|
||||
address: value.address,
|
||||
balance: value.coins,
|
||||
pubkey: value.public_key ? decodeBech32Pubkey(value.public_key) : undefined,
|
||||
pubkey: normalizePubkey(value.public_key) || undefined,
|
||||
accountNumber: uint64ToNumber(value.account_number),
|
||||
sequence: uint64ToNumber(value.sequence),
|
||||
};
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { Coin } from "../coins";
|
||||
import { PubKey } from "../types";
|
||||
import { LcdClient } from "./lcdclient";
|
||||
|
||||
/**
|
||||
@ -14,8 +15,17 @@ export interface BaseAccount {
|
||||
/** Bech32 account address */
|
||||
readonly address: string;
|
||||
readonly coins: readonly Coin[];
|
||||
/** Bech32 encoded pubkey */
|
||||
readonly public_key: string;
|
||||
/**
|
||||
* The public key of the account. This is not available on-chain as long as the account
|
||||
* did not send a transaction.
|
||||
*
|
||||
* This was a type/value object in Cosmos SDK 0.37, changed to bech32 in Cosmos SDK 0.38 ([1])
|
||||
* and changed back to type/value object in Cosmos SDK 0.39 ([2]).
|
||||
*
|
||||
* [1]: https://github.com/cosmos/cosmos-sdk/pull/5280
|
||||
* [2]: https://github.com/cosmos/cosmos-sdk/pull/6749
|
||||
*/
|
||||
readonly public_key: string | PubKey | null;
|
||||
/**
|
||||
* The account number assigned by the blockchain.
|
||||
*
|
||||
|
||||
14
packages/sdk38/types/lcdapi/auth.d.ts
vendored
14
packages/sdk38/types/lcdapi/auth.d.ts
vendored
@ -1,4 +1,5 @@
|
||||
import { Coin } from "../coins";
|
||||
import { PubKey } from "../types";
|
||||
import { LcdClient } from "./lcdclient";
|
||||
/**
|
||||
* A Cosmos SDK base account.
|
||||
@ -12,8 +13,17 @@ export interface BaseAccount {
|
||||
/** Bech32 account address */
|
||||
readonly address: string;
|
||||
readonly coins: readonly Coin[];
|
||||
/** Bech32 encoded pubkey */
|
||||
readonly public_key: string;
|
||||
/**
|
||||
* The public key of the account. This is not available on-chain as long as the account
|
||||
* did not send a transaction.
|
||||
*
|
||||
* This was a type/value object in Cosmos SDK 0.37, changed to bech32 in Cosmos SDK 0.38 ([1])
|
||||
* and changed back to type/value object in Cosmos SDK 0.39 ([2]).
|
||||
*
|
||||
* [1]: https://github.com/cosmos/cosmos-sdk/pull/5280
|
||||
* [2]: https://github.com/cosmos/cosmos-sdk/pull/6749
|
||||
*/
|
||||
readonly public_key: string | PubKey | null;
|
||||
/**
|
||||
* The account number assigned by the blockchain.
|
||||
*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user