launchpad: Rename OfflineSigner.sign -> signAmino
This commit is contained in:
parent
7feea61e42
commit
fbc661c054
@ -56,7 +56,7 @@ describe("CosmosClient.searchTx", () => {
|
||||
const { accountNumber, sequence } = await client.getSequence();
|
||||
const chainId = await client.getChainId();
|
||||
const signDoc = makeSignDoc([sendMsg], fee, chainId, memo, accountNumber, sequence);
|
||||
const { signed, signature } = await wallet.sign(walletAddress, signDoc);
|
||||
const { signed, signature } = await wallet.signAmino(walletAddress, signDoc);
|
||||
const tx: WrappedStdTx = {
|
||||
type: "cosmos-sdk/StdTx",
|
||||
value: makeStdTx(signed, signature),
|
||||
|
||||
@ -232,7 +232,7 @@ describe("CosmosClient", () => {
|
||||
const chainId = await client.getChainId();
|
||||
const { accountNumber, sequence } = await client.getSequence(faucet.address);
|
||||
const signDoc = makeSignDoc([sendMsg], fee, chainId, memo, accountNumber, sequence);
|
||||
const { signed, signature } = await wallet.sign(walletAddress, signDoc);
|
||||
const { signed, signature } = await wallet.signAmino(walletAddress, signDoc);
|
||||
const signedTx = makeStdTx(signed, signature);
|
||||
const txResult = await client.broadcastTx(signedTx);
|
||||
assertIsBroadcastTxSuccess(txResult);
|
||||
|
||||
@ -47,7 +47,7 @@ describe("DistributionExtension", () => {
|
||||
const memo = "Test delegation for wasmd";
|
||||
const { accountNumber, sequence } = await client.getSequence();
|
||||
const signDoc = makeSignDoc([msg], defaultFee, chainId, memo, accountNumber, sequence);
|
||||
const { signed, signature } = await wallet.sign(faucet.address, signDoc);
|
||||
const { signed, signature } = await wallet.signAmino(faucet.address, signDoc);
|
||||
const signedTx = makeStdTx(signed, signature);
|
||||
|
||||
const result = await client.broadcastTx(signedTx);
|
||||
|
||||
@ -58,7 +58,7 @@ describe("GovExtension", () => {
|
||||
proposalAccountNumber,
|
||||
proposalSequence,
|
||||
);
|
||||
const { signature: proposalSignature } = await wallet.sign(faucet.address, proposalSignDoc);
|
||||
const { signature: proposalSignature } = await wallet.signAmino(faucet.address, proposalSignDoc);
|
||||
const proposalTx = {
|
||||
msg: [proposalMsg],
|
||||
fee: defaultFee,
|
||||
@ -90,7 +90,7 @@ describe("GovExtension", () => {
|
||||
voteAccountNumber,
|
||||
voteSequence,
|
||||
);
|
||||
const { signature: voteSignature } = await wallet.sign(faucet.address, voteSignDoc);
|
||||
const { signature: voteSignature } = await wallet.signAmino(faucet.address, voteSignDoc);
|
||||
const voteTx = {
|
||||
msg: [voteMsg],
|
||||
fee: defaultFee,
|
||||
|
||||
@ -240,7 +240,7 @@ describe("LcdClient", () => {
|
||||
const { accountNumber, sequence } = await client.getSequence();
|
||||
const chainId = await client.getChainId();
|
||||
const signDoc = makeSignDoc([sendMsg], fee, chainId, memo, accountNumber, sequence);
|
||||
const { signed, signature } = await wallet.sign(walletAddress, signDoc);
|
||||
const { signed, signature } = await wallet.signAmino(walletAddress, signDoc);
|
||||
const signedTx = makeStdTx(signed, signature);
|
||||
const transactionId = await client.getIdentifier({ type: "cosmos-sdk/StdTx", value: signedTx });
|
||||
const result = await client.broadcastTx(signedTx);
|
||||
@ -534,7 +534,7 @@ describe("LcdClient", () => {
|
||||
const { account_number, sequence } = (await client.auth.account(faucet.address)).result.value;
|
||||
|
||||
const signDoc = makeSignDoc([theMsg], fee, wasmd.chainId, memo, account_number, sequence);
|
||||
const { signed, signature } = await wallet.sign(walletAddress, signDoc);
|
||||
const { signed, signature } = await wallet.signAmino(walletAddress, signDoc);
|
||||
const signedTx = makeStdTx(signed, signature);
|
||||
const result = await client.broadcastTx(signedTx);
|
||||
expect(result.code).toBeUndefined();
|
||||
@ -593,9 +593,9 @@ describe("LcdClient", () => {
|
||||
const signDoc1 = makeSignDoc([theMsg], fee, wasmd.chainId, memo, an1, sequence1);
|
||||
const signDoc2 = makeSignDoc([theMsg], fee, wasmd.chainId, memo, an2, sequence2);
|
||||
const signDoc3 = makeSignDoc([theMsg], fee, wasmd.chainId, memo, an3, sequence3);
|
||||
const { signature: signature1 } = await account1.sign(address1, signDoc1);
|
||||
const { signature: signature2 } = await account2.sign(address2, signDoc2);
|
||||
const { signature: signature3 } = await account3.sign(address3, signDoc3);
|
||||
const { signature: signature1 } = await account1.signAmino(address1, signDoc1);
|
||||
const { signature: signature2 } = await account2.signAmino(address2, signDoc2);
|
||||
const { signature: signature3 } = await account3.signAmino(address3, signDoc3);
|
||||
const signedTx: StdTx = {
|
||||
msg: [theMsg],
|
||||
fee: fee,
|
||||
@ -655,7 +655,7 @@ describe("LcdClient", () => {
|
||||
const { account_number, sequence } = (await client.auth.account(walletAddress)).result.value;
|
||||
|
||||
const signDoc = makeSignDoc([msg1, msg2], fee, wasmd.chainId, memo, account_number, sequence);
|
||||
const { signed, signature } = await wallet.sign(walletAddress, signDoc);
|
||||
const { signed, signature } = await wallet.signAmino(walletAddress, signDoc);
|
||||
const signedTx = makeStdTx(signed, signature);
|
||||
const broadcastResult = await client.broadcastTx(signedTx);
|
||||
expect(broadcastResult.code).toBeUndefined();
|
||||
@ -715,8 +715,8 @@ describe("LcdClient", () => {
|
||||
|
||||
const signDoc1 = makeSignDoc([msg2, msg1], fee, wasmd.chainId, memo, an1, sequence1);
|
||||
const signDoc2 = makeSignDoc([msg2, msg1], fee, wasmd.chainId, memo, an2, sequence2);
|
||||
const { signature: signature1 } = await account1.sign(address1, signDoc1);
|
||||
const { signature: signature2 } = await account2.sign(address2, signDoc2);
|
||||
const { signature: signature1 } = await account1.signAmino(address1, signDoc1);
|
||||
const { signature: signature2 } = await account2.signAmino(address2, signDoc2);
|
||||
const signedTx: StdTx = {
|
||||
msg: [msg2, msg1],
|
||||
fee: fee,
|
||||
@ -786,8 +786,8 @@ describe("LcdClient", () => {
|
||||
|
||||
const signDoc1 = makeSignDoc([msg1, msg2], fee, wasmd.chainId, memo, an1, sequence1);
|
||||
const signDoc2 = makeSignDoc([msg1, msg2], fee, wasmd.chainId, memo, an2, sequence2);
|
||||
const { signature: signature1 } = await account1.sign(address1, signDoc1);
|
||||
const { signature: signature2 } = await account2.sign(address2, signDoc2);
|
||||
const { signature: signature1 } = await account1.signAmino(address1, signDoc1);
|
||||
const { signature: signature2 } = await account2.signAmino(address2, signDoc2);
|
||||
const signedTx: StdTx = {
|
||||
msg: [msg1, msg2],
|
||||
fee: fee,
|
||||
@ -852,8 +852,8 @@ describe("LcdClient", () => {
|
||||
|
||||
const signDoc1 = makeSignDoc([msg2, msg1], fee, wasmd.chainId, memo, an1, sequence1);
|
||||
const signDoc2 = makeSignDoc([msg2, msg1], fee, wasmd.chainId, memo, an2, sequence2);
|
||||
const { signature: signature1 } = await account1.sign(address1, signDoc1);
|
||||
const { signature: signature2 } = await account2.sign(address2, signDoc2);
|
||||
const { signature: signature1 } = await account1.signAmino(address1, signDoc1);
|
||||
const { signature: signature2 } = await account2.signAmino(address2, signDoc2);
|
||||
const signedTx: StdTx = {
|
||||
msg: [msg2, msg1],
|
||||
fee: fee,
|
||||
|
||||
@ -48,7 +48,7 @@ describe("StakingExtension", () => {
|
||||
const memo = "Test delegation for wasmd";
|
||||
const { accountNumber, sequence } = await client.getSequence();
|
||||
const signDoc = makeSignDoc([msg], defaultFee, chainId, memo, accountNumber, sequence);
|
||||
const { signed, signature } = await wallet.sign(faucet.address, signDoc);
|
||||
const { signed, signature } = await wallet.signAmino(faucet.address, signDoc);
|
||||
const signedTx = makeStdTx(signed, signature);
|
||||
|
||||
const result = await client.broadcastTx(signedTx);
|
||||
@ -66,7 +66,7 @@ describe("StakingExtension", () => {
|
||||
const memo = "Test undelegation for wasmd";
|
||||
const { accountNumber, sequence } = await client.getSequence();
|
||||
const signDoc = makeSignDoc([msg], defaultFee, chainId, memo, accountNumber, sequence);
|
||||
const { signed, signature } = await wallet.sign(faucet.address, signDoc);
|
||||
const { signed, signature } = await wallet.signAmino(faucet.address, signDoc);
|
||||
const signedTx = makeStdTx(signed, signature);
|
||||
|
||||
const result = await client.broadcastTx(signedTx);
|
||||
|
||||
@ -109,7 +109,7 @@ describe("Secp256k1HdWallet", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("sign", () => {
|
||||
describe("signAmino", () => {
|
||||
it("resolves to valid signature", async () => {
|
||||
const wallet = await Secp256k1HdWallet.fromMnemonic(defaultMnemonic);
|
||||
const signDoc: StdSignDoc = {
|
||||
@ -120,7 +120,7 @@ describe("Secp256k1HdWallet", () => {
|
||||
account_number: "7",
|
||||
sequence: "54",
|
||||
};
|
||||
const { signed, signature } = await wallet.sign(defaultAddress, signDoc);
|
||||
const { signed, signature } = await wallet.signAmino(defaultAddress, signDoc);
|
||||
expect(signed).toEqual(signDoc);
|
||||
const valid = await Secp256k1.verifySignature(
|
||||
Secp256k1Signature.fromFixedLength(fromBase64(signature.signature)),
|
||||
|
||||
@ -259,7 +259,7 @@ export class Secp256k1HdWallet implements OfflineSigner {
|
||||
];
|
||||
}
|
||||
|
||||
public async sign(signerAddress: string, signDoc: StdSignDoc): Promise<SignResponse> {
|
||||
public async signAmino(signerAddress: string, signDoc: StdSignDoc): Promise<SignResponse> {
|
||||
if (signerAddress !== this.address) {
|
||||
throw new Error(`Address ${signerAddress} not found in wallet`);
|
||||
}
|
||||
|
||||
@ -34,5 +34,5 @@ export interface OfflineSigner {
|
||||
* @param signerAddress The address of the account that should sign the transaction
|
||||
* @param signDoc The content that should be signed
|
||||
*/
|
||||
readonly sign: (signerAddress: string, signDoc: StdSignDoc) => Promise<SignResponse>;
|
||||
readonly signAmino: (signerAddress: string, signDoc: StdSignDoc) => Promise<SignResponse>;
|
||||
}
|
||||
|
||||
@ -90,7 +90,7 @@ export class SigningCosmosClient extends CosmosClient {
|
||||
const { accountNumber, sequence } = await this.getSequence();
|
||||
const chainId = await this.getChainId();
|
||||
const signDoc = makeSignDoc(msgs, fee, chainId, memo, accountNumber, sequence);
|
||||
const { signed, signature } = await this.signer.sign(this.senderAddress, signDoc);
|
||||
const { signed, signature } = await this.signer.signAmino(this.senderAddress, signDoc);
|
||||
const signedTx = makeStdTx(signed, signature);
|
||||
return this.broadcastTx(signedTx);
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ export declare class Secp256k1HdWallet implements OfflineSigner {
|
||||
get mnemonic(): string;
|
||||
private get address();
|
||||
getAccounts(): Promise<readonly AccountData[]>;
|
||||
sign(signerAddress: string, signDoc: StdSignDoc): Promise<SignResponse>;
|
||||
signAmino(signerAddress: string, signDoc: StdSignDoc): Promise<SignResponse>;
|
||||
/**
|
||||
* Generates an encrypted serialization of this wallet.
|
||||
*
|
||||
|
||||
4
packages/launchpad/types/signer.d.ts
vendored
4
packages/launchpad/types/signer.d.ts
vendored
@ -7,7 +7,7 @@ export interface AccountData {
|
||||
readonly algo: Algo;
|
||||
readonly pubkey: Uint8Array;
|
||||
}
|
||||
export interface SignResponse {
|
||||
export interface AminoSignResponse {
|
||||
/**
|
||||
* The sign doc that was signed.
|
||||
* This may be different from the input signDoc when the signer modifies it as part of the signing process.
|
||||
@ -29,5 +29,5 @@ export interface OfflineSigner {
|
||||
* @param signerAddress The address of the account that should sign the transaction
|
||||
* @param signDoc The content that should be signed
|
||||
*/
|
||||
readonly sign: (signerAddress: string, signDoc: StdSignDoc) => Promise<SignResponse>;
|
||||
readonly signAmino: (signerAddress: string, signDoc: StdSignDoc) => Promise<AminoSignResponse>;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user