-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix/prevent empty trc20 swap (#7094)
* bugfix: prevent TRC20 swap if empty account * chore: changeset
- Loading branch information
1 parent
714ba4c
commit 9a136dc
Showing
8 changed files
with
41 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
"@ledgerhq/types-live": patch | ||
"ledger-live-desktop": patch | ||
"live-mobile": patch | ||
"@ledgerhq/live-common": patch | ||
--- | ||
|
||
prevent TRC20 swaps if empty tron account |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
libs/ledger-live-common/src/exchange/swap/maybeTronEmptyAccount.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { SwapTransactionType } from "./types"; | ||
|
||
export const maybeTronEmptyAccount = (swapTransaction: SwapTransactionType): Error | undefined => { | ||
if ( | ||
swapTransaction?.swap?.to?.currency?.type === "TokenCurrency" && | ||
swapTransaction?.swap?.to?.currency?.tokenType === "trc20" && | ||
swapTransaction?.swap?.to?.parentAccount?.balance.lt(100_000) | ||
) { | ||
const tezosError = new Error("Cannot swap with an empty TRON account"); | ||
tezosError.name = "newAddressTRC20"; | ||
return tezosError; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters