proto-signing: Add and export makeSignBytes helper function
This commit is contained in:
parent
f53425d7ff
commit
53b216d1fb
@ -3,3 +3,4 @@ export { decodeAny } from "./any";
|
||||
export { Coin } from "./msgs";
|
||||
export { cosmosField } from "./decorator";
|
||||
export { Registry } from "./registry";
|
||||
export { makeSignBytes } from "./signing";
|
||||
|
||||
@ -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);
|
||||
|
||||
8
packages/proto-signing/src/signing.ts
Normal file
8
packages/proto-signing/src/signing.ts
Normal 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());
|
||||
}
|
||||
1
packages/proto-signing/types/index.d.ts
vendored
1
packages/proto-signing/types/index.d.ts
vendored
@ -3,3 +3,4 @@ export { decodeAny } from "./any";
|
||||
export { Coin } from "./msgs";
|
||||
export { cosmosField } from "./decorator";
|
||||
export { Registry } from "./registry";
|
||||
export { makeSignBytes } from "./signing";
|
||||
|
||||
2
packages/proto-signing/types/signing.d.ts
vendored
Normal file
2
packages/proto-signing/types/signing.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import { cosmos } from "./generated/codecimpl";
|
||||
export declare function makeSignBytes(signDoc: cosmos.tx.ISignDoc): Uint8Array;
|
||||
Loading…
Reference in New Issue
Block a user