mirror of
https://github.com/cosmos/cosmjs.git
synced 2025-03-10 21:49:15 +00:00
feat(timeout-height): signAndBroadcast
This commit is contained in:
parent
af78d546ec
commit
423b30949d
@ -574,18 +574,20 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a transaction with the given messages, fee and memo. Then signs and broadcasts the transaction.
|
* Creates a transaction with the given messages, fee, memo and timeout height. Then signs and broadcasts the transaction.
|
||||||
*
|
*
|
||||||
* @param signerAddress The address that will sign transactions using this instance. The signer must be able to sign with this address.
|
* @param signerAddress The address that will sign transactions using this instance. The signer must be able to sign with this address.
|
||||||
* @param messages
|
* @param messages
|
||||||
* @param fee
|
* @param fee
|
||||||
* @param memo
|
* @param memo
|
||||||
|
* @param timeoutHeight (optional) timeout height to prevent the tx from being committed past a certain height
|
||||||
*/
|
*/
|
||||||
public async signAndBroadcast(
|
public async signAndBroadcast(
|
||||||
signerAddress: string,
|
signerAddress: string,
|
||||||
messages: readonly EncodeObject[],
|
messages: readonly EncodeObject[],
|
||||||
fee: StdFee | "auto" | number,
|
fee: StdFee | "auto" | number,
|
||||||
memo = "",
|
memo = "",
|
||||||
|
timeoutHeight?: bigint,
|
||||||
): Promise<DeliverTxResponse> {
|
): Promise<DeliverTxResponse> {
|
||||||
let usedFee: StdFee;
|
let usedFee: StdFee;
|
||||||
if (fee == "auto" || typeof fee === "number") {
|
if (fee == "auto" || typeof fee === "number") {
|
||||||
@ -598,13 +600,13 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
|||||||
} else {
|
} else {
|
||||||
usedFee = fee;
|
usedFee = fee;
|
||||||
}
|
}
|
||||||
const txRaw = await this.sign(signerAddress, messages, usedFee, memo);
|
const txRaw = await this.sign(signerAddress, messages, usedFee, memo, undefined, timeoutHeight);
|
||||||
const txBytes = TxRaw.encode(txRaw).finish();
|
const txBytes = TxRaw.encode(txRaw).finish();
|
||||||
return this.broadcastTx(txBytes, this.broadcastTimeoutMs, this.broadcastPollIntervalMs);
|
return this.broadcastTx(txBytes, this.broadcastTimeoutMs, this.broadcastPollIntervalMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a transaction with the given messages, fee and memo. Then signs and broadcasts the transaction.
|
* Creates a transaction with the given messages, fee, memo and timeout height. Then signs and broadcasts the transaction.
|
||||||
*
|
*
|
||||||
* This method is useful if you want to send a transaction in broadcast,
|
* This method is useful if you want to send a transaction in broadcast,
|
||||||
* without waiting for it to be placed inside a block, because for example
|
* without waiting for it to be placed inside a block, because for example
|
||||||
@ -614,6 +616,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
|||||||
* @param messages
|
* @param messages
|
||||||
* @param fee
|
* @param fee
|
||||||
* @param memo
|
* @param memo
|
||||||
|
* @param timeoutHeight (optional) timeout height to prevent the tx from being committed past a certain height
|
||||||
*
|
*
|
||||||
* @returns Returns the hash of the transaction
|
* @returns Returns the hash of the transaction
|
||||||
*/
|
*/
|
||||||
@ -622,6 +625,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
|||||||
messages: readonly EncodeObject[],
|
messages: readonly EncodeObject[],
|
||||||
fee: StdFee | "auto" | number,
|
fee: StdFee | "auto" | number,
|
||||||
memo = "",
|
memo = "",
|
||||||
|
timeoutHeight?: bigint,
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
let usedFee: StdFee;
|
let usedFee: StdFee;
|
||||||
if (fee == "auto" || typeof fee === "number") {
|
if (fee == "auto" || typeof fee === "number") {
|
||||||
@ -632,7 +636,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
|||||||
} else {
|
} else {
|
||||||
usedFee = fee;
|
usedFee = fee;
|
||||||
}
|
}
|
||||||
const txRaw = await this.sign(signerAddress, messages, usedFee, memo);
|
const txRaw = await this.sign(signerAddress, messages, usedFee, memo, undefined, timeoutHeight);
|
||||||
const txBytes = TxRaw.encode(txRaw).finish();
|
const txBytes = TxRaw.encode(txRaw).finish();
|
||||||
return this.broadcastTxSync(txBytes);
|
return this.broadcastTxSync(txBytes);
|
||||||
}
|
}
|
||||||
|
@ -312,6 +312,7 @@ export class SigningStargateClient extends StargateClient {
|
|||||||
messages: readonly EncodeObject[],
|
messages: readonly EncodeObject[],
|
||||||
fee: StdFee | "auto" | number,
|
fee: StdFee | "auto" | number,
|
||||||
memo = "",
|
memo = "",
|
||||||
|
timeoutHeight?: bigint,
|
||||||
): Promise<DeliverTxResponse> {
|
): Promise<DeliverTxResponse> {
|
||||||
let usedFee: StdFee;
|
let usedFee: StdFee;
|
||||||
if (fee == "auto" || typeof fee === "number") {
|
if (fee == "auto" || typeof fee === "number") {
|
||||||
@ -324,7 +325,7 @@ export class SigningStargateClient extends StargateClient {
|
|||||||
} else {
|
} else {
|
||||||
usedFee = fee;
|
usedFee = fee;
|
||||||
}
|
}
|
||||||
const txRaw = await this.sign(signerAddress, messages, usedFee, memo);
|
const txRaw = await this.sign(signerAddress, messages, usedFee, memo, undefined, timeoutHeight);
|
||||||
const txBytes = TxRaw.encode(txRaw).finish();
|
const txBytes = TxRaw.encode(txRaw).finish();
|
||||||
return this.broadcastTx(txBytes, this.broadcastTimeoutMs, this.broadcastPollIntervalMs);
|
return this.broadcastTx(txBytes, this.broadcastTimeoutMs, this.broadcastPollIntervalMs);
|
||||||
}
|
}
|
||||||
@ -340,6 +341,7 @@ export class SigningStargateClient extends StargateClient {
|
|||||||
messages: readonly EncodeObject[],
|
messages: readonly EncodeObject[],
|
||||||
fee: StdFee | "auto" | number,
|
fee: StdFee | "auto" | number,
|
||||||
memo = "",
|
memo = "",
|
||||||
|
timeoutHeight?: bigint,
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
let usedFee: StdFee;
|
let usedFee: StdFee;
|
||||||
if (fee == "auto" || typeof fee === "number") {
|
if (fee == "auto" || typeof fee === "number") {
|
||||||
@ -350,7 +352,7 @@ export class SigningStargateClient extends StargateClient {
|
|||||||
} else {
|
} else {
|
||||||
usedFee = fee;
|
usedFee = fee;
|
||||||
}
|
}
|
||||||
const txRaw = await this.sign(signerAddress, messages, usedFee, memo);
|
const txRaw = await this.sign(signerAddress, messages, usedFee, memo, undefined, timeoutHeight);
|
||||||
const txBytes = TxRaw.encode(txRaw).finish();
|
const txBytes = TxRaw.encode(txRaw).finish();
|
||||||
return this.broadcastTxSync(txBytes);
|
return this.broadcastTxSync(txBytes);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user