mirror of
https://github.com/cosmos/cosmjs.git
synced 2025-03-10 21:49:15 +00:00
Add makeStdSignDoc and serializeSignDoc
This commit is contained in:
parent
a0ee9963c1
commit
6c116f3d5a
@ -45,6 +45,8 @@
|
||||
`isSearchBySentFromOrToQuery` and `isSearchByTagsQuery`.
|
||||
- @cosmjs/launchpad: Change type of `TxsResponse.logs` and
|
||||
`BroadcastTxsResponse.logs` to `unknown[]`.
|
||||
- @cosmjs/launchpad: Export `StdSignDoc` and create helpers to make and
|
||||
serialize a `StdSignDoc`: `makeStdSignDoc` and `serializeSignDoc`.
|
||||
- @cosmjs/launchpad-ledger: Add package supporting Ledger device integration for
|
||||
Launchpad. Two new classes are provided: `LedgerSigner` (for most use cases)
|
||||
and `LaunchpadLedger` for more fine-grained access.
|
||||
|
@ -29,14 +29,38 @@ function sortJson(json: any): any {
|
||||
* @see https://docs.cosmos.network/master/modules/auth/03_types.html#stdsigndoc
|
||||
*/
|
||||
export interface StdSignDoc {
|
||||
readonly account_number: string;
|
||||
readonly chain_id: string;
|
||||
readonly fee: StdFee;
|
||||
readonly memo: string;
|
||||
readonly msgs: readonly Msg[];
|
||||
readonly account_number: string;
|
||||
readonly sequence: string;
|
||||
readonly fee: StdFee;
|
||||
readonly msgs: readonly Msg[];
|
||||
readonly memo: string;
|
||||
}
|
||||
|
||||
export function makeStdSignDoc(
|
||||
msgs: readonly Msg[],
|
||||
fee: StdFee,
|
||||
chainId: string,
|
||||
memo: string,
|
||||
accountNumber: number | string,
|
||||
sequence: number | string,
|
||||
): StdSignDoc {
|
||||
return {
|
||||
chain_id: chainId,
|
||||
account_number: uint64ToString(accountNumber),
|
||||
sequence: uint64ToString(sequence),
|
||||
fee: fee,
|
||||
msgs: msgs,
|
||||
memo: memo,
|
||||
};
|
||||
}
|
||||
|
||||
export function serializeSignDoc(signDoc: StdSignDoc): Uint8Array {
|
||||
const sortedSignDoc = sortJson(signDoc);
|
||||
return toUtf8(JSON.stringify(sortedSignDoc));
|
||||
}
|
||||
|
||||
/** A convenience helper to create the StdSignDoc and serialize it */
|
||||
export function makeSignBytes(
|
||||
msgs: readonly Msg[],
|
||||
fee: StdFee,
|
||||
@ -45,14 +69,5 @@ export function makeSignBytes(
|
||||
accountNumber: number | string,
|
||||
sequence: number | string,
|
||||
): Uint8Array {
|
||||
const signDoc: StdSignDoc = {
|
||||
account_number: uint64ToString(accountNumber),
|
||||
chain_id: chainId,
|
||||
fee: fee,
|
||||
memo: memo,
|
||||
msgs: msgs,
|
||||
sequence: uint64ToString(sequence),
|
||||
};
|
||||
const sortedSignDoc = sortJson(signDoc);
|
||||
return toUtf8(JSON.stringify(sortedSignDoc));
|
||||
return serializeSignDoc(makeStdSignDoc(msgs, fee, chainId, memo, accountNumber, sequence));
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ export {
|
||||
isSearchBySentFromOrToQuery,
|
||||
isSearchByTagsQuery,
|
||||
} from "./cosmosclient";
|
||||
export { makeSignBytes, StdSignDoc } from "./encoding";
|
||||
export { makeSignBytes, makeStdSignDoc, serializeSignDoc, StdSignDoc } from "./encoding";
|
||||
export { buildFeeTable, FeeTable, GasLimits, GasPrice } from "./gas";
|
||||
export {
|
||||
AuthAccountsResponse,
|
||||
|
18
packages/launchpad/types/encoding.d.ts
vendored
18
packages/launchpad/types/encoding.d.ts
vendored
@ -6,13 +6,23 @@ import { StdFee } from "./types";
|
||||
* @see https://docs.cosmos.network/master/modules/auth/03_types.html#stdsigndoc
|
||||
*/
|
||||
export interface StdSignDoc {
|
||||
readonly account_number: string;
|
||||
readonly chain_id: string;
|
||||
readonly fee: StdFee;
|
||||
readonly memo: string;
|
||||
readonly msgs: readonly Msg[];
|
||||
readonly account_number: string;
|
||||
readonly sequence: string;
|
||||
readonly fee: StdFee;
|
||||
readonly msgs: readonly Msg[];
|
||||
readonly memo: string;
|
||||
}
|
||||
export declare function makeStdSignDoc(
|
||||
msgs: readonly Msg[],
|
||||
fee: StdFee,
|
||||
chainId: string,
|
||||
memo: string,
|
||||
accountNumber: number | string,
|
||||
sequence: number | string,
|
||||
): StdSignDoc;
|
||||
export declare function serializeSignDoc(signDoc: StdSignDoc): Uint8Array;
|
||||
/** A convenience helper to create the StdSignDoc and serialize it */
|
||||
export declare function makeSignBytes(
|
||||
msgs: readonly Msg[],
|
||||
fee: StdFee,
|
||||
|
2
packages/launchpad/types/index.d.ts
vendored
2
packages/launchpad/types/index.d.ts
vendored
@ -26,7 +26,7 @@ export {
|
||||
isSearchBySentFromOrToQuery,
|
||||
isSearchByTagsQuery,
|
||||
} from "./cosmosclient";
|
||||
export { makeSignBytes, StdSignDoc } from "./encoding";
|
||||
export { makeSignBytes, makeStdSignDoc, serializeSignDoc, StdSignDoc } from "./encoding";
|
||||
export { buildFeeTable, FeeTable, GasLimits, GasPrice } from "./gas";
|
||||
export {
|
||||
AuthAccountsResponse,
|
||||
|
Loading…
x
Reference in New Issue
Block a user