Skip to content
This repository has been archived by the owner on Jul 15, 2022. It is now read-only.

Cosmos JS #1713

Merged
35 commits merged into from Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
9ff6edc
increase gas amplifier
alexalouit Jan 31, 2022
bb1888b
fix payload construction
alexalouit Jan 31, 2022
92f4d59
More accurate gas amplifier
alexalouit Jan 31, 2022
f29a4ae
increase gas amplifier
alexalouit Jan 31, 2022
957a48f
use same node for calculation and broadcast
alexalouit Jan 31, 2022
b120a76
fix amount payload
alexalouit Jan 31, 2022
dd45d6d
Merge remote-tracking branch 'upstream/cosmos-js' into cosmos-js
alexalouit Jan 31, 2022
aaa9494
fix fees/gas calculation
alexalouit Jan 31, 2022
67a4414
fix signature
alexalouit Feb 1, 2022
510c1e9
Merge remote-tracking branch 'upstream/cosmos-js' into cosmos-js
alexalouit Feb 1, 2022
0594ce0
Merge remote-tracking branch 'upstream/cosmos-js' into cosmos-js
alexalouit Feb 3, 2022
75bd779
fix fees regression
alexalouit Feb 3, 2022
fff173f
Merge remote-tracking branch 'upstream/cosmos-js' into cosmos-js
alexalouit Feb 3, 2022
014b551
More accurate pubkey selection
alexalouit Feb 3, 2022
bed90f0
don't use extra.tx_bytes
alexalouit Feb 3, 2022
4faf89d
fix pubkey selection
alexalouit Feb 3, 2022
a49d4ff
simplify hex serialization
alexalouit Feb 4, 2022
e8ad8f3
update transaction: more strict types
alexalouit Feb 10, 2022
a03fd8f
many things
alexalouit Feb 10, 2022
27947b3
accuracy
alexalouit Feb 10, 2022
1ea1afe
remove useless isPreValidation
alexalouit Feb 10, 2022
f941d07
fix strange edge effect of ledger live desktop
alexalouit Feb 10, 2022
cda9bc1
Update xpub during sync
alexalouit Feb 14, 2022
d65266d
temporary enable log for bot
alexalouit Feb 14, 2022
1c62e0c
Merge remote-tracking branch 'upstream/cosmos-js' into cosmos-js
alexalouit Feb 14, 2022
8df4111
LL-9159 cosmos node
alexalouit Feb 16, 2022
804fccd
Update js-signOperation.ts
alexalouit Feb 16, 2022
35ecf59
fix signature
alexalouit Feb 16, 2022
f45276e
Merge remote-tracking branch 'upstream/cosmos-js' into cosmos-js
alexalouit Feb 17, 2022
99dc488
fix redelegate payload
alexalouit Feb 17, 2022
1800f02
fix payload send transaction when sendmax
alexalouit Feb 17, 2022
3aca833
fix optimistic operation type
alexalouit Feb 18, 2022
e22a144
Merge remote-tracking branch 'upstream/cosmos-js' into cosmos-js
alexalouit Feb 18, 2022
e7fd38b
fix typo
alexalouit Feb 18, 2022
c7a0e69
bugfix
alexalouit Feb 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/families/cosmos/js-buildTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const buildTransaction = async (
value: {
validatorSrcAddress: transaction.cosmosSourceValidator,
delegatorAddress: account.freshAddress,
validatorAddress: transaction.validators[0].address,
validatorDstAddress: transaction.validators[0].address,
amount: {
denom: account.currency.units[1].code,
amount: transaction.validators[0].amount.toString(),
Expand Down
5 changes: 4 additions & 1 deletion src/families/cosmos/js-prepareTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ const prepareTransaction = async (
patch.memo = "Ledger Live";
}

const unsignedPayload = await buildTransaction(account, transaction);
const unsignedPayload = await buildTransaction(account, {
...transaction,
...patch,
});

// be sure payload is complete
if (unsignedPayload) {
Expand Down
27 changes: 17 additions & 10 deletions src/families/cosmos/js-signOperation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Account, SignOperationEvent } from "../../types";
import { Account, OperationType, SignOperationEvent } from "../../types";
import type { Transaction } from "./types";
import { getAccount, getChainId } from "./api/Cosmos";
import { Observable } from "rxjs";
Expand Down Expand Up @@ -145,24 +145,31 @@ const signOperation = ({

o.next({ type: "device-signature-granted" });

// build optimistic operation
const txHash = ""; // resolved at broadcast time
const senders = [account.freshAddress];
const recipients = [transaction.recipient];
const accountId = account.id;
const type: OperationType =
transaction.mode === "undelegate"
? "UNDELEGATE"
: transaction.mode === "delegate"
? "DELEGATE"
: transaction.mode === "redelegate"
? "REDELEGATE"
: ["claimReward", "claimRewardCompound"].includes(transaction.mode)
? "REWARD"
: "OUT";

// build optimistic operation
const operation = {
id: encodeOperationId(accountId, txHash, "OUT"),
id: encodeOperationId(account.id, txHash, type),
hash: txHash,
type: "OUT",
type: type,
value: transaction.amount,
fee: transaction.fees,
extra: {},
blockHash: null,
blockHeight: null,
senders,
recipients,
accountId,
senders: [account.freshAddress],
recipients: [transaction.recipient],
account: account.id,
date: new Date(),
};

Expand Down