mirror of
https://github.com/cosmos/cosmjs.git
synced 2025-03-10 21:49:15 +00:00
Remove makeSignBytes
This commit is contained in:
parent
751861e501
commit
14c285748a
@ -53,6 +53,8 @@
|
|||||||
- @cosmjs/launchpad: Remove `PrehashType` and the prehash type argument in
|
- @cosmjs/launchpad: Remove `PrehashType` and the prehash type argument in
|
||||||
`OfflineSigner.sign` because the signer now needs to know how to serialize an
|
`OfflineSigner.sign` because the signer now needs to know how to serialize an
|
||||||
`StdSignDoc`.
|
`StdSignDoc`.
|
||||||
|
- @cosmjs/launchpad: Remove `makeSignBytes` in favour of `makeStdSignDoc` and
|
||||||
|
`serializeSignDoc`.
|
||||||
- @cosmjs/launchpad-ledger: Add package supporting Ledger device integration for
|
- @cosmjs/launchpad-ledger: Add package supporting Ledger device integration for
|
||||||
Launchpad. Two new classes are provided: `LedgerSigner` (for most use cases)
|
Launchpad. Two new classes are provided: `LedgerSigner` (for most use cases)
|
||||||
and `LaunchpadLedger` for more fine-grained access.
|
and `LaunchpadLedger` for more fine-grained access.
|
||||||
|
@ -66,7 +66,7 @@ const sendTokensMsg: MsgSend = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const signBytes = makeSignBytes(
|
const signDoc = makeStdSignDoc(
|
||||||
[sendTokensMsg],
|
[sendTokensMsg],
|
||||||
defaultFee,
|
defaultFee,
|
||||||
defaultNetworkId,
|
defaultNetworkId,
|
||||||
@ -74,7 +74,7 @@ const signBytes = makeSignBytes(
|
|||||||
account_number,
|
account_number,
|
||||||
sequence,
|
sequence,
|
||||||
);
|
);
|
||||||
const signature = await pen.sign(signBytes);
|
const { signature } = await wallet.sign(faucetAddress, signDoc);
|
||||||
const signedTx: StdTx = {
|
const signedTx: StdTx = {
|
||||||
msg: [sendTokensMsg],
|
msg: [sendTokensMsg],
|
||||||
fee: defaultFee,
|
fee: defaultFee,
|
||||||
|
@ -98,7 +98,6 @@ export async function main(originalArgs: readonly string[]): Promise<void> {
|
|||||||
"encodeSecp256k1Signature",
|
"encodeSecp256k1Signature",
|
||||||
"logs",
|
"logs",
|
||||||
"makeCosmoshubPath",
|
"makeCosmoshubPath",
|
||||||
"makeSignBytes",
|
|
||||||
"makeStdSignDoc",
|
"makeStdSignDoc",
|
||||||
"IndexedTx",
|
"IndexedTx",
|
||||||
"BroadcastTxResult",
|
"BroadcastTxResult",
|
||||||
|
@ -173,7 +173,7 @@ import { MsgExecuteContract, setupWasmExtension } from "@cosmjs/cosmwasm";
|
|||||||
import {
|
import {
|
||||||
assertIsPostTxSuccess,
|
assertIsPostTxSuccess,
|
||||||
LcdClient,
|
LcdClient,
|
||||||
makeSignBytes,
|
makeStdSignDoc,
|
||||||
setupAuthExtension,
|
setupAuthExtension,
|
||||||
StdFee,
|
StdFee,
|
||||||
StdTx,
|
StdTx,
|
||||||
@ -205,7 +205,7 @@ const memo = "Time for action";
|
|||||||
const { account_number, sequence } = (
|
const { account_number, sequence } = (
|
||||||
await client.auth.account(myAddress)
|
await client.auth.account(myAddress)
|
||||||
).result.value;
|
).result.value;
|
||||||
const signBytes = makeSignBytes(
|
const signDoc = makeStdSignDoc(
|
||||||
[msg],
|
[msg],
|
||||||
fee,
|
fee,
|
||||||
apiUrl,
|
apiUrl,
|
||||||
@ -213,7 +213,7 @@ const signBytes = makeSignBytes(
|
|||||||
account_number,
|
account_number,
|
||||||
sequence,
|
sequence,
|
||||||
);
|
);
|
||||||
const signature = await signer.sign(myAddress, signBytes);
|
const { signature } = await signer.sign(myAddress, signDoc);
|
||||||
const signedTx: StdTx = {
|
const signedTx: StdTx = {
|
||||||
msg: [msg],
|
msg: [msg],
|
||||||
fee: fee,
|
fee: fee,
|
||||||
|
@ -59,15 +59,3 @@ export function serializeSignDoc(signDoc: StdSignDoc): Uint8Array {
|
|||||||
const sortedSignDoc = sortJson(signDoc);
|
const sortedSignDoc = sortJson(signDoc);
|
||||||
return toUtf8(JSON.stringify(sortedSignDoc));
|
return toUtf8(JSON.stringify(sortedSignDoc));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A convenience helper to create the StdSignDoc and serialize it */
|
|
||||||
export function makeSignBytes(
|
|
||||||
msgs: readonly Msg[],
|
|
||||||
fee: StdFee,
|
|
||||||
chainId: string,
|
|
||||||
memo: string,
|
|
||||||
accountNumber: number | string,
|
|
||||||
sequence: number | string,
|
|
||||||
): Uint8Array {
|
|
||||||
return serializeSignDoc(makeStdSignDoc(msgs, fee, chainId, memo, accountNumber, sequence));
|
|
||||||
}
|
|
||||||
|
@ -28,7 +28,7 @@ export {
|
|||||||
isSearchBySentFromOrToQuery,
|
isSearchBySentFromOrToQuery,
|
||||||
isSearchByTagsQuery,
|
isSearchByTagsQuery,
|
||||||
} from "./cosmosclient";
|
} from "./cosmosclient";
|
||||||
export { makeSignBytes, makeStdSignDoc, serializeSignDoc, StdSignDoc } from "./encoding";
|
export { makeStdSignDoc, serializeSignDoc, StdSignDoc } from "./encoding";
|
||||||
export { buildFeeTable, FeeTable, GasLimits, GasPrice } from "./gas";
|
export { buildFeeTable, FeeTable, GasLimits, GasPrice } from "./gas";
|
||||||
export {
|
export {
|
||||||
AuthAccountsResponse,
|
AuthAccountsResponse,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Secp256k1, Secp256k1Signature, Sha256 } from "@cosmjs/crypto";
|
import { Secp256k1, Secp256k1Signature, Sha256 } from "@cosmjs/crypto";
|
||||||
|
|
||||||
import { makeSignBytes } from "./encoding";
|
import { makeStdSignDoc, serializeSignDoc } from "./encoding";
|
||||||
import { decodeSignature } from "./signature";
|
import { decodeSignature } from "./signature";
|
||||||
import { CosmosSdkTx } from "./types";
|
import { CosmosSdkTx } from "./types";
|
||||||
|
|
||||||
@ -30,13 +30,8 @@ export async function findSequenceForSignedTx(
|
|||||||
|
|
||||||
for (let s = min; s < upperBound; s++) {
|
for (let s = min; s < upperBound; s++) {
|
||||||
// console.log(`Trying sequence ${s}`);
|
// console.log(`Trying sequence ${s}`);
|
||||||
const signBytes = makeSignBytes(
|
const signBytes = serializeSignDoc(
|
||||||
tx.value.msg,
|
makeStdSignDoc(tx.value.msg, tx.value.fee, chainId, tx.value.memo || "", accountNumber, s),
|
||||||
tx.value.fee,
|
|
||||||
chainId,
|
|
||||||
tx.value.memo || "",
|
|
||||||
accountNumber,
|
|
||||||
s,
|
|
||||||
);
|
);
|
||||||
const prehashed = new Sha256(signBytes).digest();
|
const prehashed = new Sha256(signBytes).digest();
|
||||||
const valid = await Secp256k1.verifySignature(secp256keSignature, prehashed, pubkey);
|
const valid = await Secp256k1.verifySignature(secp256keSignature, prehashed, pubkey);
|
||||||
|
9
packages/launchpad/types/encoding.d.ts
vendored
9
packages/launchpad/types/encoding.d.ts
vendored
@ -22,12 +22,3 @@ export declare function makeStdSignDoc(
|
|||||||
sequence: number | string,
|
sequence: number | string,
|
||||||
): StdSignDoc;
|
): StdSignDoc;
|
||||||
export declare function serializeSignDoc(signDoc: StdSignDoc): Uint8Array;
|
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,
|
|
||||||
chainId: string,
|
|
||||||
memo: string,
|
|
||||||
accountNumber: number | string,
|
|
||||||
sequence: number | string,
|
|
||||||
): Uint8Array;
|
|
||||||
|
2
packages/launchpad/types/index.d.ts
vendored
2
packages/launchpad/types/index.d.ts
vendored
@ -26,7 +26,7 @@ export {
|
|||||||
isSearchBySentFromOrToQuery,
|
isSearchBySentFromOrToQuery,
|
||||||
isSearchByTagsQuery,
|
isSearchByTagsQuery,
|
||||||
} from "./cosmosclient";
|
} from "./cosmosclient";
|
||||||
export { makeSignBytes, makeStdSignDoc, serializeSignDoc, StdSignDoc } from "./encoding";
|
export { makeStdSignDoc, serializeSignDoc, StdSignDoc } from "./encoding";
|
||||||
export { buildFeeTable, FeeTable, GasLimits, GasPrice } from "./gas";
|
export { buildFeeTable, FeeTable, GasLimits, GasPrice } from "./gas";
|
||||||
export {
|
export {
|
||||||
AuthAccountsResponse,
|
AuthAccountsResponse,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user