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

Commit

Permalink
Cosmos JS (#1715)
Browse files Browse the repository at this point in the history
* increase gas amplifier

* fix payload construction

handle payload atomic construction

* More accurate gas amplifier

* increase gas amplifier

* use same node for calculation and broadcast

* fix amount payload

* fix fees/gas calculation

* fix signature

fix public key when account is derivate

* fix fees regression

* More accurate pubkey selection

* don't use extra.tx_bytes

* fix pubkey selection

* simplify hex serialization

* update transaction: more strict types

* many things

restruct operation builder
simulate now return int
prepareTransaction use patch format

* accuracy

more accuracy int value
small refactor

* remove useless isPreValidation

* fix strange edge effect of ledger live desktop

* Update xpub during sync

* temporary enable log for bot

* LL-9159 cosmos node

* Update js-signOperation.ts

revert back test trace for bot

* fix signature

* fix redelegate payload

* fix payload send transaction when sendmax

* fix optimistic operation type

* fix typo

* bugfix

* fix regression

Co-authored-by: Alexandre Alouit <[email protected]>
  • Loading branch information
wa-aal and alexalouit authored Feb 18, 2022
1 parent c9df7c4 commit 9c6c682
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/families/cosmos/js-signOperation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ const signOperation = ({
o.next({ type: "device-signature-granted" });

const txHash = ""; // resolved at broadcast time
const accountId = account.id;
const type: OperationType =
transaction.mode === "undelegate"
? "UNDELEGATE"
Expand All @@ -159,7 +160,7 @@ const signOperation = ({

// build optimistic operation
const operation = {
id: encodeOperationId(account.id, txHash, type),
id: encodeOperationId(accountId, txHash, type),
hash: txHash,
type: type,
value: transaction.amount,
Expand All @@ -169,7 +170,7 @@ const signOperation = ({
blockHeight: null,
senders: [account.freshAddress],
recipients: [transaction.recipient],
account: account.id,
account: accountId,
date: new Date(),
};

Expand Down

2 comments on commit 9c6c682

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ 1 specs ($0.00) for Bot 'Cosmos JS'

⚠️ 6 mutations uncovered

1 critical spec errors

Spec Cosmos failed!

DisconnectedDeviceDuringOperation: DisconnectedDeviceDuringOperation
Details of the 0 mutations

Spec Cosmos (failed)


Details of the 6 uncovered mutations

Spec Cosmos (6)

  • send some:
  • send max:
  • delegate new validators:
  • undelegate:
  • redelegate:
  • claim rewards:

Portfolio ($0.00)

Details of the 1 currencies
Spec (accounts) Operations Balance funds?
Cosmos (0) 0 🤷‍♂️ ???

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ 2 txs ($29.46) for Bot 'Cosmos JS'

⚠️ 4 mutations uncovered

2 mutation errors
all accounts sync in 1753ms
▬ Cosmos 2.18.0 on nanoS 2.0.0
→ FROM Cosmos 2: 0.3918 ATOM (12ops) (cosmos1zd0e8j9g9wur8up7j5aqahz233r4jmvqhyffnv on 44'/118'/1'/0/0) #1 js:2:cosmos:cosmos1zd0e8j9g9wur8up7j5aqahz233r4jmvqhyffnv: (! sum of ops 0.410671 ATOM) 0.152361 ATOM spendable. 0.239492 ATOM delegated. 
DELEGATIONS
  to cosmosvaloper102ruvpv2srmunfffxavttxnhezln6fnc54at8c 0.002094 ATOM 
  to cosmosvaloper1wlagucxdxvsmvj6330864x8q3vxz4x02rmvmsu 0.061104 ATOM 
  to cosmosvaloper1rpgtz9pskr5geavkjz02caqmeep7cwwpv73axj 0.012531 ATOM 
  to cosmosvaloper1q6d3d089hg59x6gcx92uumx70s5y5wadklue8s 0.002439 ATOM 
  to cosmosvaloper1cgh5ksjwy2sd407lyre4l3uj2fdrqhpkzp06e6 0.022033 ATOM 
  to cosmosvaloper1thl5syhmscgnj7whdyrydw3w6vy80044hjpnxh 0.001467 ATOM 
  to cosmosvaloper1gjtvly9lel6zskvwtvlg5vhwpu9c9waw7sxzwx 0.00761 ATOM 
  to cosmosvaloper1rcp29q3hpd246n6qak7jluqep4v006cdsc2kkl 0.087313 ATOM 
  to cosmosvaloper156gqf9837u7d4c4678yt3rl4ls9c5vuursrrzf 0.000084 ATOM 
  to cosmosvaloper1x8rr4hcf54nz6hfckyy2n05sxss54h8wz9puzg 0.017993 ATOM 
  to cosmosvaloper14jlpmqquh0gste6nzf4dn43kc8h50l6fmx6dfs 0.000786 ATOM 
  to cosmosvaloper16qme5yxucnaj6snx35nmwze0wyxr8wfgqxsqfw 0.024038 ATOM 
  to cosmosvaloper1sxx9mszve0gaedz5ld7qdkjkfv8z992ax69k08 0.004641 ATOM 
UNDELEGATIONS
  from cosmosvaloper146kwpzhmleafmhtaxulfptyhnvwxzlvm87hwnm 0.01132 ATOM
  from cosmosvaloper1cgh5ksjwy2sd407lyre4l3uj2fdrqhpkzp06e6 0.003122 ATOM

max spendable ~0.14611
★ using mutation 'redelegate'
✔️ transaction 
REDELEGATE 
TO 
  0.002439 -> cosmosvaloper102ruvpv2srmunfffxavttxnhezln6fnc54at8c
  source validator=cosmosvaloper1q6d3d089hg59x6gcx92uumx70s5y5wadklue8s
with fees=0.014167
  memo=LedgerLiveBot
STATUS (773ms)
  amount: 0 ATOM
  estimated fees: 0.014167 ATOM
  total spent: 0.014167 ATOM
✔️ has been signed! (2662ms) 
✔️ broadcasted! (129ms) optimistic operation: 
  ? 0                REDELEGATE 578F8774FFCBE808868B97CD4C7888D82B1A79E4A879E2C488190F72D799D6FA 2022-02-18T14:29
⚠️ Error: could not find optimisticOperation undefined-578F8774FFCBE808868B97CD4C7888D82B1A79E4A879E2C488190F72D799D6FA-REDELEGATE

Error: could not find optimisticOperation undefined-578F8774FFCBE808868B97CD4C7888D82B1A79E4A879E2C488190F72D799D6FA-REDELEGATE
all accounts sync in 1629ms
▬ Cosmos 2.18.0 on nanoS 2.0.0
→ FROM Cosmos 3: 0.4181 ATOM (12ops) (cosmos1uty5nf28emeahuhdg9runmzuluq9uj5uek4jk0 on 44'/118'/2'/0/0) #2 js:2:cosmos:cosmos1uty5nf28emeahuhdg9runmzuluq9uj5uek4jk0: (! sum of ops 0.455721 ATOM) 0.20908 ATOM spendable. 0.209108 ATOM delegated. 
DELEGATIONS
  to cosmosvaloper1ey69r37gfxvxg62sh4r0ktpuc46pzjrm873ae8 0.006734 ATOM 
  to cosmosvaloper1hjadhj9nqzpye2vkmkz4thahhd0z8dh3udhq74 0.002393 ATOM 
  to cosmosvaloper1000ya26q2cmh399q4c5aaacd9lmmdqp90kw2jn 0.006595 ATOM 
  to cosmosvaloper14kn0kk33szpwus9nh8n87fjel8djx0y070ymmj 0.014991 ATOM 
  to cosmosvaloper1hjct6q7npsspsg3dgvzk3sdf89spmlpfdn6m9d 0.002407 ATOM 
  to cosmosvaloper1n3mhyp9fvcmuu8l0q8qvjy07x0rql8q46fe2xk 0.002511 ATOM 
  to cosmosvaloper1nm0rrq86ucezaf8uj35pq9fpwr5r82clzyvtd8 0.002212 ATOM 
  to cosmosvaloper1d0aup392g3enru7eash83sedqclaxvp7fzh6gk 0.171265 ATOM 
  to cosmosvaloper1clpqr4nrk4khgkxj78fcwwh6dl3uw4epsluffn 0.003568 ATOM 
  to cosmosvaloper157v7tczs40axfgejp2m43kwuzqe0wsy0rv8puv 0.000232 ATOM 
UNDELEGATIONS
  from cosmosvaloper1ey69r37gfxvxg62sh4r0ktpuc46pzjrm873ae8 0.000899 ATOM
REDELEGATIONS
  from undefined to undefined 

max spendable ~0.20283
★ using mutation 'undelegate'
✔️ transaction 
UNDELEGATE 
TO 
  0.001346 -> cosmosvaloper1hjadhj9nqzpye2vkmkz4thahhd0z8dh3udhq74
with fees=0.011401
  memo=LedgerLiveBot
STATUS (1288ms)
  amount: 0 ATOM
  estimated fees: 0.011401 ATOM
  total spent: 0.011401 ATOM
✔️ has been signed! (2281ms) 
✔️ broadcasted! (127ms) optimistic operation: 
  ? 0                UNDELEGATE D2532F9EE150E24C2AD0284AE30EABFBB0AF7D421390C7F2C495940AC2DD7B64 2022-02-18T14:31
⚠️ Error: could not find optimisticOperation undefined-D2532F9EE150E24C2AD0284AE30EABFBB0AF7D421390C7F2C495940AC2DD7B64-UNDELEGATE

Error: could not find optimisticOperation undefined-D2532F9EE150E24C2AD0284AE30EABFBB0AF7D421390C7F2C495940AC2DD7B64-UNDELEGATE
Details of the 2 mutations

Spec Cosmos (7)

Spec Cosmos found 7 Cosmos accounts (preload: 350ms). Will use Cosmos 2.18.0 on nanoS 2.0.0
(552ms) Cosmos 1: 0.04301 ATOM (11ops) (cosmos1zpvthe3pxvyje7vrcqv2m6qe2qgu0r8gkz64er on 44'/118'/0'/0/0) #0 js:2:cosmos:cosmos1zpvthe3pxvyje7vrcqv2m6qe2qgu0r8gkz64er:
(466ms) Cosmos 2: 0.30909 ATOM (12ops) (cosmos1zd0e8j9g9wur8up7j5aqahz233r4jmvqhyffnv on 44'/118'/1'/0/0) #1 js:2:cosmos:cosmos1zd0e8j9g9wur8up7j5aqahz233r4jmvqhyffnv:
(500ms) Cosmos 3: 0.4219 ATOM (12ops) (cosmos1uty5nf28emeahuhdg9runmzuluq9uj5uek4jk0 on 44'/118'/2'/0/0) #2 js:2:cosmos:cosmos1uty5nf28emeahuhdg9runmzuluq9uj5uek4jk0:
(751ms) Cosmos 4: 0.08733 ATOM (8ops) (cosmos1ccemcd8p3r293e5rcv0awaj9hfnn6wmxkz520n on 44'/118'/3'/0/0) #3 js:2:cosmos:cosmos1ccemcd8p3r293e5rcv0awaj9hfnn6wmxkz520n:
(351ms) Cosmos 5: 0.1038 ATOM (3ops) (cosmos1mvk3fwxgdfac4yjmgl9hdz0555q8gljydzvjtu on 44'/118'/4'/0/0) #4 js:2:cosmos:cosmos1mvk3fwxgdfac4yjmgl9hdz0555q8gljydzvjtu:
(373ms) Cosmos 6: 0.09884 ATOM (2ops) (cosmos1draxuzz0aukggx63m852wm8mlxqpus2009cs97 on 44'/118'/5'/0/0) #5 js:2:cosmos:cosmos1draxuzz0aukggx63m852wm8mlxqpus2009cs97:
(1227ms) Cosmos 7: 0 ATOM (0ops) (cosmos14k7faf4cvxlflta4hytxavx3p7vj6uw69lgf03 on 44'/118'/6'/0/0) #6 js:2:cosmos:cosmos14k7faf4cvxlflta4hytxavx3p7vj6uw69lgf03:
all accounts sync in 1753ms
▬ Cosmos 2.18.0 on nanoS 2.0.0
→ FROM Cosmos 2: 0.3918 ATOM (12ops) (cosmos1zd0e8j9g9wur8up7j5aqahz233r4jmvqhyffnv on 44'/118'/1'/0/0) #1 js:2:cosmos:cosmos1zd0e8j9g9wur8up7j5aqahz233r4jmvqhyffnv: (! sum of ops 0.410671 ATOM) 0.152361 ATOM spendable. 0.239492 ATOM delegated. 
DELEGATIONS
  to cosmosvaloper102ruvpv2srmunfffxavttxnhezln6fnc54at8c 0.002094 ATOM 
  to cosmosvaloper1wlagucxdxvsmvj6330864x8q3vxz4x02rmvmsu 0.061104 ATOM 
  to cosmosvaloper1rpgtz9pskr5geavkjz02caqmeep7cwwpv73axj 0.012531 ATOM 
  to cosmosvaloper1q6d3d089hg59x6gcx92uumx70s5y5wadklue8s 0.002439 ATOM 
  to cosmosvaloper1cgh5ksjwy2sd407lyre4l3uj2fdrqhpkzp06e6 0.022033 ATOM 
  to cosmosvaloper1thl5syhmscgnj7whdyrydw3w6vy80044hjpnxh 0.001467 ATOM 
  to cosmosvaloper1gjtvly9lel6zskvwtvlg5vhwpu9c9waw7sxzwx 0.00761 ATOM 
  to cosmosvaloper1rcp29q3hpd246n6qak7jluqep4v006cdsc2kkl 0.087313 ATOM 
  to cosmosvaloper156gqf9837u7d4c4678yt3rl4ls9c5vuursrrzf 0.000084 ATOM 
  to cosmosvaloper1x8rr4hcf54nz6hfckyy2n05sxss54h8wz9puzg 0.017993 ATOM 
  to cosmosvaloper14jlpmqquh0gste6nzf4dn43kc8h50l6fmx6dfs 0.000786 ATOM 
  to cosmosvaloper16qme5yxucnaj6snx35nmwze0wyxr8wfgqxsqfw 0.024038 ATOM 
  to cosmosvaloper1sxx9mszve0gaedz5ld7qdkjkfv8z992ax69k08 0.004641 ATOM 
UNDELEGATIONS
  from cosmosvaloper146kwpzhmleafmhtaxulfptyhnvwxzlvm87hwnm 0.01132 ATOM
  from cosmosvaloper1cgh5ksjwy2sd407lyre4l3uj2fdrqhpkzp06e6 0.003122 ATOM

max spendable ~0.14611
★ using mutation 'redelegate'
✔️ transaction 
REDELEGATE 
TO 
  0.002439 -> cosmosvaloper102ruvpv2srmunfffxavttxnhezln6fnc54at8c
  source validator=cosmosvaloper1q6d3d089hg59x6gcx92uumx70s5y5wadklue8s
with fees=0.014167
  memo=LedgerLiveBot
STATUS (773ms)
  amount: 0 ATOM
  estimated fees: 0.014167 ATOM
  total spent: 0.014167 ATOM
✔️ has been signed! (2662ms) 
✔️ broadcasted! (129ms) optimistic operation: 
  ? 0                REDELEGATE 578F8774FFCBE808868B97CD4C7888D82B1A79E4A879E2C488190F72D799D6FA 2022-02-18T14:29
⚠️ Error: could not find optimisticOperation undefined-578F8774FFCBE808868B97CD4C7888D82B1A79E4A879E2C488190F72D799D6FA-REDELEGATE

all accounts sync in 1629ms
▬ Cosmos 2.18.0 on nanoS 2.0.0
→ FROM Cosmos 3: 0.4181 ATOM (12ops) (cosmos1uty5nf28emeahuhdg9runmzuluq9uj5uek4jk0 on 44'/118'/2'/0/0) #2 js:2:cosmos:cosmos1uty5nf28emeahuhdg9runmzuluq9uj5uek4jk0: (! sum of ops 0.455721 ATOM) 0.20908 ATOM spendable. 0.209108 ATOM delegated. 
DELEGATIONS
  to cosmosvaloper1ey69r37gfxvxg62sh4r0ktpuc46pzjrm873ae8 0.006734 ATOM 
  to cosmosvaloper1hjadhj9nqzpye2vkmkz4thahhd0z8dh3udhq74 0.002393 ATOM 
  to cosmosvaloper1000ya26q2cmh399q4c5aaacd9lmmdqp90kw2jn 0.006595 ATOM 
  to cosmosvaloper14kn0kk33szpwus9nh8n87fjel8djx0y070ymmj 0.014991 ATOM 
  to cosmosvaloper1hjct6q7npsspsg3dgvzk3sdf89spmlpfdn6m9d 0.002407 ATOM 
  to cosmosvaloper1n3mhyp9fvcmuu8l0q8qvjy07x0rql8q46fe2xk 0.002511 ATOM 
  to cosmosvaloper1nm0rrq86ucezaf8uj35pq9fpwr5r82clzyvtd8 0.002212 ATOM 
  to cosmosvaloper1d0aup392g3enru7eash83sedqclaxvp7fzh6gk 0.171265 ATOM 
  to cosmosvaloper1clpqr4nrk4khgkxj78fcwwh6dl3uw4epsluffn 0.003568 ATOM 
  to cosmosvaloper157v7tczs40axfgejp2m43kwuzqe0wsy0rv8puv 0.000232 ATOM 
UNDELEGATIONS
  from cosmosvaloper1ey69r37gfxvxg62sh4r0ktpuc46pzjrm873ae8 0.000899 ATOM
REDELEGATIONS
  from undefined to undefined 

max spendable ~0.20283
★ using mutation 'undelegate'
✔️ transaction 
UNDELEGATE 
TO 
  0.001346 -> cosmosvaloper1hjadhj9nqzpye2vkmkz4thahhd0z8dh3udhq74
with fees=0.011401
  memo=LedgerLiveBot
STATUS (1288ms)
  amount: 0 ATOM
  estimated fees: 0.011401 ATOM
  total spent: 0.011401 ATOM
✔️ has been signed! (2281ms) 
✔️ broadcasted! (127ms) optimistic operation: 
  ? 0                UNDELEGATE D2532F9EE150E24C2AD0284AE30EABFBB0AF7D421390C7F2C495940AC2DD7B64 2022-02-18T14:31
⚠️ Error: could not find optimisticOperation undefined-D2532F9EE150E24C2AD0284AE30EABFBB0AF7D421390C7F2C495940AC2DD7B64-UNDELEGATE


Details of the 4 uncovered mutations

Spec Cosmos (4)

  • send some: balance is too low (5)
  • send max: balance is too low (5)
  • delegate new validators: balance is too low (5)
  • claim rewards: balance is too low (5)

Portfolio ($29.46)

Details of the 1 currencies
Spec (accounts) Operations Balance funds?
Cosmos (6) 50 (+2) 0.6678 ATOM (- 0.025568) ($29.46) ⚠️ cosmos1zpvthe3pxvyje7vrcqv2m6qe2qgu0r8gkz64er

Please sign in to comment.