proto-signing: Add and export makeSignBytes helper function

This commit is contained in:
willclarktech 2020-08-12 12:40:59 +02:00
parent f53425d7ff
commit 53b216d1fb
No known key found for this signature in database
GPG Key ID: 551A86E2E398ADF7
5 changed files with 14 additions and 1 deletions

View File

@ -3,3 +3,4 @@ export { decodeAny } from "./any";
export { Coin } from "./msgs";
export { cosmosField } from "./decorator";
export { Registry } from "./registry";
export { makeSignBytes } from "./signing";

View File

@ -6,6 +6,7 @@ import { omitDefaults } from "./adr27";
import { cosmos } from "./generated/codecimpl";
import { defaultRegistry } from "./msgs";
import { Registry, TxBodyValue } from "./registry";
import { makeSignBytes } from "./signing";
const { AuthInfo, SignDoc, Tx, TxBody } = cosmos.tx;
const { PublicKey } = cosmos.crypto;
@ -158,7 +159,7 @@ describe("signing demo", () => {
accountSequence: sequenceNumber,
}),
);
const signDocBytes = Uint8Array.from(SignDoc.encode(signDoc).finish());
const signDocBytes = makeSignBytes(signDoc);
expect(toHex(signDocBytes)).toEqual(signBytes);
const signature = await wallet.sign(address, signDocBytes);

View File

@ -0,0 +1,8 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { cosmos } from "./generated/codecimpl";
const { SignDoc } = cosmos.tx;
export function makeSignBytes(signDoc: cosmos.tx.ISignDoc): Uint8Array {
return Uint8Array.from(SignDoc.encode(signDoc).finish());
}

View File

@ -3,3 +3,4 @@ export { decodeAny } from "./any";
export { Coin } from "./msgs";
export { cosmosField } from "./decorator";
export { Registry } from "./registry";
export { makeSignBytes } from "./signing";

View File

@ -0,0 +1,2 @@
import { cosmos } from "./generated/codecimpl";
export declare function makeSignBytes(signDoc: cosmos.tx.ISignDoc): Uint8Array;