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

Commit

Permalink
Translate new solana errors (#1949)
Browse files Browse the repository at this point in the history
* solana switch to translatable errors

* solana make bot transfer amount integer
  • Loading branch information
konoart authored May 11, 2022
1 parent 7d287c8 commit c68eac5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
8 changes: 8 additions & 0 deletions src/families/solana/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,11 @@ export const SolanaStakeNoStakeAuth = createCustomErrorClass(
export const SolanaUseAllAmountStakeWarning = createCustomErrorClass(
"SolanaUseAllAmountStakeWarning"
);

export const SolanaTxSimulationFailedPendingOp = createCustomErrorClass(
"SolanaTxSimulationFailedWhilePendingOp"
);

export const SolanaTxConfirmationTimeout = createCustomErrorClass(
"SolanaTxConfirmationTimeout"
);
12 changes: 6 additions & 6 deletions src/families/solana/js-broadcast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import { log } from "@ledgerhq/logs";
import { patchOperationWithHash } from "../../operation";
import type { Account, Operation, SignedOperation } from "../../types";
import { ChainAPI } from "./api";
import {
SolanaTxConfirmationTimeout,
SolanaTxSimulationFailedPendingOp,
} from "./errors";

export const broadcastWithAPI = async (
{
Expand Down Expand Up @@ -29,15 +33,11 @@ export const broadcastWithAPI = async (
e.message.includes("simulation failed") &&
account.pendingOperations.length > 0
) {
throw new Error(
"Your previous transaction hasn't been processed yet. Please wait a moment then check the transaction history before trying again."
);
throw new SolanaTxSimulationFailedPendingOp();
}

if (e.message.includes("was not confirmed in")) {
throw new Error(
"Your transaction may have failed. Please wait a moment then check the transaction history before trying again."
);
throw new SolanaTxConfirmationTimeout();
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/families/solana/specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ const solana: AppSpec<Transaction> = {
const transaction = bridge.createTransaction(account);
const sibling = pickSiblings(siblings);
const recipient = sibling.freshAddress;
const amount = account.spendableBalance.div(1.9 + 0.2 * Math.random());
const amount = account.spendableBalance
.div(1.9 + 0.2 * Math.random())
.integerValue();
return {
transaction,
updates: [{ recipient }, { amount }, maybeTransferMemo()],
Expand Down

1 comment on commit c68eac5

@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 txs ❌ 3 txs ($3.09) for Bot 'Solana on Silicium'

⚠️ 4 mutations uncovered

3 mutation errors
all accounts sync in 66.5s
▬ Solana 1.2.0 on nanoS 2.1.0
→ FROM Solana 2: 0.01991 SOL (25ops) (2Nf8waFSiDNSukswnCFisTQeXimXvet8VWY5CddVk5Qf on 44'/501'/1') solanaSub#1 js:2:solana:2Nf8waFSiDNSukswnCFisTQeXimXvet8VWY5CddVk5Qf:solanaSub (! sum of ops 0.017528009 SOL)
max spendable ~0.017523
★ using mutation 'Transfer ~50%'
→ TO Solana 3: 0.006768 SOL (21ops) (3hbeg9Xr63J4RcrHQ1FVgYrKvqRoQmWZeN2LQDNEVEic on 44'/501'/2') solanaSub#2 js:2:solana:3hbeg9Xr63J4RcrHQ1FVgYrKvqRoQmWZeN2LQDNEVEic:solanaSub
✔️ transaction 
  SEND: 0.009088783 SOL
  TO: 3hbeg9Xr63J4RcrHQ1FVgYrKvqRoQmWZeN2LQDNEVEic
  MEMO: a memo
STATUS (941ms)
  amount: 0.009088783 SOL
  estimated fees: 0.000005 SOL
  total spent: 0.009093783 SOL
✔️ has been signed! (2188ms) {"operation":{"id":"js:2:solana:2Nf8waFSiDNSukswnCFisTQeXimXvet8VWY5CddVk5Qf:solanaSub--OUT","hash":"","type":"OUT","senders":["2Nf8waFSiDNSukswnCFisTQeXimXvet8VWY5CddVk5Qf"],"recipients":["3hbeg9Xr63J4RcrHQ1FVgYrKvqRoQmWZeN2LQDNEVEic"],"accountId":"js:2:solana:2Nf8waFSiDNSukswnCFisTQeXimXvet8VWY5CddVk5Qf:solanaSub","blockHash":null,"blockHeight":null,"extra":{"memo":"a memo"},"date":"2022-05-11T15:22:58.003Z","value":"9093783","fee":"5000","transactionSequenceNumber":26},"signature":"01bc8c131d1922b0ea07c43c54985fe570d666ef59ad573faad6a25efa14313313854073010a1e904231067cf2c4e7af5ba49b6b4be827d998a5a07faa4895ec050100020414680165e84eb4e712d3f84ed5ea055fb9a214193d0fbded4a928f18b5e4b964281dc8dc058ab0973ca1ddc903cdb0d41133afcddb36c1dc07676522d8c8a6110000000000000000000000000000000000000000000000000000000000000000054a535a992921064d24e87160da387c7c35b5ddbc92bb81e41fa8404105448d2b2936b5d86370d321832234a4e00638e31bede1b934ad5a88998f3cff0ba61302020200010c020000000faf8a000000000003000661206d656d6f","expirationDate":null}
⚠️ SolanaTxConfirmationTimeout: SolanaTxConfirmationTimeout

SolanaTxConfirmationTimeout: SolanaTxConfirmationTimeout
all accounts sync in 69.1s
▬ Solana 1.2.0 on nanoS 2.1.0
→ FROM Solana 3: 0.006768 SOL (21ops) (3hbeg9Xr63J4RcrHQ1FVgYrKvqRoQmWZeN2LQDNEVEic on 44'/501'/2') solanaSub#2 js:2:solana:3hbeg9Xr63J4RcrHQ1FVgYrKvqRoQmWZeN2LQDNEVEic:solanaSub
max spendable ~0.006763
★ using mutation 'Transfer Max'
→ TO Solana 4: 0.0023828 SOL (14ops) (GezsPyTAM8zfpLKLcbZLnoeUGgn8enmWeg8RsA6Jgq9E on 44'/501'/3') solanaSub#3 js:2:solana:GezsPyTAM8zfpLKLcbZLnoeUGgn8enmWeg8RsA6Jgq9E:solanaSub
✔️ transaction 
  SEND: 0.00676342 SOL (ALL)
  TO: GezsPyTAM8zfpLKLcbZLnoeUGgn8enmWeg8RsA6Jgq9E
  MEMO: a memo
STATUS (1039ms)
  amount: 0.00676342 SOL
  estimated fees: 0.000005 SOL
  total spent: 0.00676842 SOL
  warnings: recipient: SolanaAccountNotFunded
✔️ has been signed! (2244ms) 
✔️ broadcasted! (22.1s) optimistic operation: 
  -0.00676842 SOL    OUT        41cU1uEE7SudKm4EUbd2QQpYX1iku98P16614aDLeERqMzLKAEdHH5EYipZvrK9uTVqHJeboVnce1E9P5bjJEdvZ 2022-05-11T15:24
(final state reached in 123.4s)
⚠️ Error: expect(received).toBe(expected) // Object.is equality

Expected: 0
Received: 9088783

Error: expect(received).toBe(expected) // Object.is equality

Expected: 0
Received: 9088783
all accounts sync in 70.2s
▬ Solana 1.2.0 on nanoS 2.1.0
→ FROM Solana 5: 0.025651 SOL (22ops) (AnoW5Tw3VTFg8ADxxtntYfSqm7NWMNeBii3NEw4f5cmn on 44'/501'/4') solanaSub#4 js:2:solana:AnoW5Tw3VTFg8ADxxtntYfSqm7NWMNeBii3NEw4f5cmn:solanaSub (! sum of ops 0.018501854 SOL)
max spendable ~0.018496
★ using mutation 'Reactivate Deactivating Delegation'
✔️ transaction 
  DELEGATE: FciV1xZTyT6XhZqZhvhWRbxPDgMvHmN5yP3kFAPpwVE7
  TO: AWDiZEPxJizd3f7NxiJijUqHt2NDViGN5CWzzeN5Uoeh
STATUS (1920ms)
  amount: 0 SOL
  estimated fees: 0.000005 SOL
  total spent: 0.000005 SOL
✔️ has been signed! (2472ms) {"operation":{"id":"js:2:solana:AnoW5Tw3VTFg8ADxxtntYfSqm7NWMNeBii3NEw4f5cmn:solanaSub--DELEGATE","hash":"","type":"DELEGATE","senders":[],"recipients":[],"accountId":"js:2:solana:AnoW5Tw3VTFg8ADxxtntYfSqm7NWMNeBii3NEw4f5cmn:solanaSub","blockHash":null,"blockHeight":null,"extra":{},"date":"2022-05-11T15:30:36.212Z","value":"5000","fee":"5000","transactionSequenceNumber":23},"signature":"01585a33e6ba92a8966efde4fcddb421cbdbed709149ae349f6785c4e3ae8a292dbeccf393c5a50b3c25ed9744c9814921880011a7f2d375b65c14797b06a5ae06010005079174e5e0f3401abf5ca6e2d346fc5df8154b97874d30c46b2d6a62c88ed79ef1d929d9ae20f5d46e0cc3c94b5ad5672737b8595be58744ff659b42d5c7ba7b488d356784a125e89bcaa6be7af871e0caecd38151bc96077f88478946241fa65a06a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49dc00000000006a1d817a502050b680791e6ce6db88e1e5b7150f61fc6790a4eb4d10000000006a7d51718c774c928566398691d5eb68b5eb8a39b4b6d5c73555b210000000006a7d517193584d0feed9bb3431d13206be544281b57b8566cc5375ff40000009799efc9c608475133ba8942a86ac973b84b03f33ee6c4dd4f43984e257fce5d0103060102050604000402000000","expirationDate":null}
⚠️ SolanaTxConfirmationTimeout: SolanaTxConfirmationTimeout

SolanaTxConfirmationTimeout: SolanaTxConfirmationTimeout
Details of the 4 mutations

Spec Solana (7)

Spec Solana found 7 Solana accounts (preload: 6.1s). Will use Solana 1.2.0 on nanoS 2.1.0
(19.4s) Solana 1 cross: 0 SOL (6ops) (8VWxnnbHz2HNJRK2V23gvVQVdZUR3YpJRTBP5aZzPgmm on 44'/501'/0') solanaSub#0 js:2:solana:8VWxnnbHz2HNJRK2V23gvVQVdZUR3YpJRTBP5aZzPgmm:solanaSub
(11.8s) Solana 2: 0.01991 SOL (25ops) (2Nf8waFSiDNSukswnCFisTQeXimXvet8VWY5CddVk5Qf on 44'/501'/1') solanaSub#1 js:2:solana:2Nf8waFSiDNSukswnCFisTQeXimXvet8VWY5CddVk5Qf:solanaSub
(10.4s) Solana 3: 0.006768 SOL (21ops) (3hbeg9Xr63J4RcrHQ1FVgYrKvqRoQmWZeN2LQDNEVEic on 44'/501'/2') solanaSub#2 js:2:solana:3hbeg9Xr63J4RcrHQ1FVgYrKvqRoQmWZeN2LQDNEVEic:solanaSub
(10.9s) Solana 4: 0.0023828 SOL (14ops) (GezsPyTAM8zfpLKLcbZLnoeUGgn8enmWeg8RsA6Jgq9E on 44'/501'/3') solanaSub#3 js:2:solana:GezsPyTAM8zfpLKLcbZLnoeUGgn8enmWeg8RsA6Jgq9E:solanaSub
(14s) Solana 5: 0.025651 SOL (22ops) (AnoW5Tw3VTFg8ADxxtntYfSqm7NWMNeBii3NEw4f5cmn on 44'/501'/4') solanaSub#4 js:2:solana:AnoW5Tw3VTFg8ADxxtntYfSqm7NWMNeBii3NEw4f5cmn:solanaSub
(10s) Solana 6: 0 SOL (9ops) (HcyfM9UuUr46WXVHcoFUh6VR6ULFm7DFiPk25aEJHmEj on 44'/501'/5') solanaSub#5 js:2:solana:HcyfM9UuUr46WXVHcoFUh6VR6ULFm7DFiPk25aEJHmEj:solanaSub
(8.6s) Solana 7: 0 SOL (0ops) (GeptKUZeDiUtGMxqE6nSb1xCQNbBhBVHHnxd5ZivwyFL on 44'/501'/6') solanaSub#6 js:2:solana:GeptKUZeDiUtGMxqE6nSb1xCQNbBhBVHHnxd5ZivwyFL:solanaSub
all accounts sync in 66.5s
▬ Solana 1.2.0 on nanoS 2.1.0
→ FROM Solana 2: 0.01991 SOL (25ops) (2Nf8waFSiDNSukswnCFisTQeXimXvet8VWY5CddVk5Qf on 44'/501'/1') solanaSub#1 js:2:solana:2Nf8waFSiDNSukswnCFisTQeXimXvet8VWY5CddVk5Qf:solanaSub (! sum of ops 0.017528009 SOL)
max spendable ~0.017523
★ using mutation 'Transfer ~50%'
→ TO Solana 3: 0.006768 SOL (21ops) (3hbeg9Xr63J4RcrHQ1FVgYrKvqRoQmWZeN2LQDNEVEic on 44'/501'/2') solanaSub#2 js:2:solana:3hbeg9Xr63J4RcrHQ1FVgYrKvqRoQmWZeN2LQDNEVEic:solanaSub
✔️ transaction 
  SEND: 0.009088783 SOL
  TO: 3hbeg9Xr63J4RcrHQ1FVgYrKvqRoQmWZeN2LQDNEVEic
  MEMO: a memo
STATUS (941ms)
  amount: 0.009088783 SOL
  estimated fees: 0.000005 SOL
  total spent: 0.009093783 SOL
✔️ has been signed! (2188ms) {"operation":{"id":"js:2:solana:2Nf8waFSiDNSukswnCFisTQeXimXvet8VWY5CddVk5Qf:solanaSub--OUT","hash":"","type":"OUT","senders":["2Nf8waFSiDNSukswnCFisTQeXimXvet8VWY5CddVk5Qf"],"recipients":["3hbeg9Xr63J4RcrHQ1FVgYrKvqRoQmWZeN2LQDNEVEic"],"accountId":"js:2:solana:2Nf8waFSiDNSukswnCFisTQeXimXvet8VWY5CddVk5Qf:solanaSub","blockHash":null,"blockHeight":null,"extra":{"memo":"a memo"},"date":"2022-05-11T15:22:58.003Z","value":"9093783","fee":"5000","transactionSequenceNumber":26},"signature":"01bc8c131d1922b0ea07c43c54985fe570d666ef59ad573faad6a25efa14313313854073010a1e904231067cf2c4e7af5ba49b6b4be827d998a5a07faa4895ec050100020414680165e84eb4e712d3f84ed5ea055fb9a214193d0fbded4a928f18b5e4b964281dc8dc058ab0973ca1ddc903cdb0d41133afcddb36c1dc07676522d8c8a6110000000000000000000000000000000000000000000000000000000000000000054a535a992921064d24e87160da387c7c35b5ddbc92bb81e41fa8404105448d2b2936b5d86370d321832234a4e00638e31bede1b934ad5a88998f3cff0ba61302020200010c020000000faf8a000000000003000661206d656d6f","expirationDate":null}
⚠️ SolanaTxConfirmationTimeout: SolanaTxConfirmationTimeout

all accounts sync in 69.1s
▬ Solana 1.2.0 on nanoS 2.1.0
→ FROM Solana 3: 0.006768 SOL (21ops) (3hbeg9Xr63J4RcrHQ1FVgYrKvqRoQmWZeN2LQDNEVEic on 44'/501'/2') solanaSub#2 js:2:solana:3hbeg9Xr63J4RcrHQ1FVgYrKvqRoQmWZeN2LQDNEVEic:solanaSub
max spendable ~0.006763
★ using mutation 'Transfer Max'
→ TO Solana 4: 0.0023828 SOL (14ops) (GezsPyTAM8zfpLKLcbZLnoeUGgn8enmWeg8RsA6Jgq9E on 44'/501'/3') solanaSub#3 js:2:solana:GezsPyTAM8zfpLKLcbZLnoeUGgn8enmWeg8RsA6Jgq9E:solanaSub
✔️ transaction 
  SEND: 0.00676342 SOL (ALL)
  TO: GezsPyTAM8zfpLKLcbZLnoeUGgn8enmWeg8RsA6Jgq9E
  MEMO: a memo
STATUS (1039ms)
  amount: 0.00676342 SOL
  estimated fees: 0.000005 SOL
  total spent: 0.00676842 SOL
  warnings: recipient: SolanaAccountNotFunded
✔️ has been signed! (2244ms) 
✔️ broadcasted! (22.1s) optimistic operation: 
  -0.00676842 SOL    OUT        41cU1uEE7SudKm4EUbd2QQpYX1iku98P16614aDLeERqMzLKAEdHH5EYipZvrK9uTVqHJeboVnce1E9P5bjJEdvZ 2022-05-11T15:24
(final state reached in 123.4s)
⚠️ Error: expect(received).toBe(expected) // Object.is equality

Expected: 0
Received: 9088783

all accounts sync in 69.9s
▬ Solana 1.2.0 on nanoS 2.1.0
→ FROM Solana 4: 0.009146 SOL (15ops) (GezsPyTAM8zfpLKLcbZLnoeUGgn8enmWeg8RsA6Jgq9E on 44'/501'/3') solanaSub#3 js:2:solana:GezsPyTAM8zfpLKLcbZLnoeUGgn8enmWeg8RsA6Jgq9E:solanaSub (! sum of ops 0.00676342 SOL)
max spendable ~0.006758
★ using mutation 'Delegate'
✔️ transaction 
  CREATE STAKE ACCOUNT: 2PN7nk9XRxG411H5MpFTGASBnjZmRW4L71i9S6RX7aTJ
  FROM: GezsPyTAM8zfpLKLcbZLnoeUGgn8enmWeg8RsA6Jgq9E
  AMOUNT: 0.00238288 SOL
  SEED: stake:0.2022893438172293
  VALIDATOR: 3yafqDTZxjRCaF8TgPYUvGhnCeuK3sGyoXVRwWnS8ADy
STATUS (2934ms)
  amount: 0.0001 SOL
  estimated fees: 0.00228788 SOL
  total spent: 0.00238788 SOL
✔️ has been signed! (2629ms) 
✔️ broadcasted! (5.1s) optimistic operation: 
  -0.00238788 SOL    DELEGATE   3S1MNvLTBLW2574aSZdRzx5ssm5xVktS8XQ1hNnTy4P5oSpnfuMvUVEc5no7BrMUChmf8GPFDpS5JUTLaRYwpu1R 2022-05-11T15:28
✔️ operation confirmed (44.4s): 
  -0.00238788 SOL    DELEGATE   3S1MNvLTBLW2574aSZdRzx5ssm5xVktS8XQ1hNnTy4P5oSpnfuMvUVEc5no7BrMUChmf8GPFDpS5JUTLaRYwpu1R 2022-05-11T15:28
✔️ Solana 4: 0.009141 SOL (16ops) (GezsPyTAM8zfpLKLcbZLnoeUGgn8enmWeg8RsA6Jgq9E on 44'/501'/3') solanaSub#3 js:2:solana:GezsPyTAM8zfpLKLcbZLnoeUGgn8enmWeg8RsA6Jgq9E:solanaSub (! sum of ops 0.00437554 SOL)
(final state reached in 44.4s)

all accounts sync in 70.2s
▬ Solana 1.2.0 on nanoS 2.1.0
→ FROM Solana 5: 0.025651 SOL (22ops) (AnoW5Tw3VTFg8ADxxtntYfSqm7NWMNeBii3NEw4f5cmn on 44'/501'/4') solanaSub#4 js:2:solana:AnoW5Tw3VTFg8ADxxtntYfSqm7NWMNeBii3NEw4f5cmn:solanaSub (! sum of ops 0.018501854 SOL)
max spendable ~0.018496
★ using mutation 'Reactivate Deactivating Delegation'
✔️ transaction 
  DELEGATE: FciV1xZTyT6XhZqZhvhWRbxPDgMvHmN5yP3kFAPpwVE7
  TO: AWDiZEPxJizd3f7NxiJijUqHt2NDViGN5CWzzeN5Uoeh
STATUS (1920ms)
  amount: 0 SOL
  estimated fees: 0.000005 SOL
  total spent: 0.000005 SOL
✔️ has been signed! (2472ms) {"operation":{"id":"js:2:solana:AnoW5Tw3VTFg8ADxxtntYfSqm7NWMNeBii3NEw4f5cmn:solanaSub--DELEGATE","hash":"","type":"DELEGATE","senders":[],"recipients":[],"accountId":"js:2:solana:AnoW5Tw3VTFg8ADxxtntYfSqm7NWMNeBii3NEw4f5cmn:solanaSub","blockHash":null,"blockHeight":null,"extra":{},"date":"2022-05-11T15:30:36.212Z","value":"5000","fee":"5000","transactionSequenceNumber":23},"signature":"01585a33e6ba92a8966efde4fcddb421cbdbed709149ae349f6785c4e3ae8a292dbeccf393c5a50b3c25ed9744c9814921880011a7f2d375b65c14797b06a5ae06010005079174e5e0f3401abf5ca6e2d346fc5df8154b97874d30c46b2d6a62c88ed79ef1d929d9ae20f5d46e0cc3c94b5ad5672737b8595be58744ff659b42d5c7ba7b488d356784a125e89bcaa6be7af871e0caecd38151bc96077f88478946241fa65a06a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49dc00000000006a1d817a502050b680791e6ce6db88e1e5b7150f61fc6790a4eb4d10000000006a7d51718c774c928566398691d5eb68b5eb8a39b4b6d5c73555b210000000006a7d517193584d0feed9bb3431d13206be544281b57b8566cc5375ff40000009799efc9c608475133ba8942a86ac973b84b03f33ee6c4dd4f43984e257fce5d0103060102050604000402000000","expirationDate":null}
⚠️ SolanaTxConfirmationTimeout: SolanaTxConfirmationTimeout


Details of the 4 uncovered mutations

Spec Solana (4)

  • Deactivate Activating Delegation: not enough balance (3)
  • Deactivate Active Delegation: not enough balance (3)
  • Activate Inactive Delegation: not enough balance (3)
  • Withdraw Delegation: not enough balance (3)

Portfolio ($3.09)

Details of the 1 currencies
Spec (accounts) Operations Balance funds?
Solana (5) 103 (+6) 0.04279 SOL (- 0.0024028) ($3.09) ⚠️ 8VWxnnbHz2HNJRK2V23gvVQVdZUR3YpJRTBP5aZzPgmm

Please sign in to comment.