Skip to content

Commit a640415

Browse files
feat: force bond in the claim and stake flow (#1370)
1 parent 269335a commit a640415

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

apps/namadillo/src/atoms/staking/services.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ export const createClaimAndStakeTx = async (
129129
props: ClaimRewardsProps | BondProps
130130
): Promise<TxMsgValue> => {
131131
if ("amount" in props) {
132+
// We have to force it in case: current balance < rewards to claim
133+
// This will still log the error msg in the terminal, unfortunately we can't do much about it
134+
wrapperTxProps.force = true;
132135
return tx.buildBond(wrapperTxProps, props as BondProps);
133136
} else {
134137
return tx.buildClaimRewards(wrapperTxProps, props as ClaimRewardsProps);

packages/shared/lib/src/sdk/args.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ pub struct WrapperTxMsg {
3838
chain_id: String,
3939
public_key: Option<String>,
4040
memo: Option<String>,
41+
force: Option<bool>,
4142
}
4243

4344
impl WrapperTxMsg {
@@ -48,6 +49,7 @@ impl WrapperTxMsg {
4849
chain_id: String,
4950
public_key: Option<String>,
5051
memo: Option<String>,
52+
force: Option<bool>,
5153
) -> WrapperTxMsg {
5254
WrapperTxMsg {
5355
token,
@@ -56,6 +58,7 @@ impl WrapperTxMsg {
5658
chain_id,
5759
public_key,
5860
memo,
61+
force,
5962
}
6063
}
6164
}
@@ -884,6 +887,7 @@ fn tx_msg_into_args(tx_msg: &[u8]) -> Result<args::Tx, JsError> {
884887
chain_id,
885888
public_key,
886889
memo,
890+
force,
887891
} = tx_msg;
888892

889893
let token = Address::from_str(&token)?;
@@ -911,12 +915,14 @@ fn tx_msg_into_args(tx_msg: &[u8]) -> Result<args::Tx, JsError> {
911915

912916
let memo = memo.map(|v| v.as_bytes().to_vec());
913917

918+
let force = force.unwrap_or(false);
919+
914920
let args = args::Tx {
915921
dry_run: false,
916922
dry_run_wrapper: false,
917923
dump_tx: false,
918924
dump_wrapper_tx: false,
919-
force: false,
925+
force,
920926
broadcast_only: false,
921927
ledger_address,
922928
wallet_alias_force: false,

packages/shared/lib/src/sdk/tx.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ impl TxDetails {
234234
let token = wrapper.fee.token.to_string();
235235

236236
let wrapper_tx =
237-
WrapperTxMsg::new(token, fee_amount, gas_limit, chain_id, None, None);
237+
WrapperTxMsg::new(token, fee_amount, gas_limit, chain_id, None, None, None);
238238
let mut commitments: Vec<Commitment> = vec![];
239239
let wasm_hashes: Vec<WasmHash> = wasm_hashes.into_serde().unwrap();
240240

packages/types/src/tx/schema/wrapperTx.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ export class WrapperTxMsgValue {
2323
@field({ type: option("string") })
2424
memo?: string;
2525

26+
@field({ type: option("bool") })
27+
force?: boolean;
28+
2629
constructor(data: WrapperTxProps) {
2730
Object.assign(this, data);
2831
}

0 commit comments

Comments
 (0)