-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(@desktop/wallet): Integrates the new sign model into the simple …
…send fixes #17060
- Loading branch information
1 parent
30009b2
commit 595807e
Showing
15 changed files
with
403 additions
and
103 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import QtQuick 2.15 | ||
|
||
import StatusQ 0.1 | ||
import StatusQ.Core.Utils 0.1 | ||
|
||
/** | ||
Adaptor transforming selected data from send to a format that | ||
can be used in the sign modal | ||
**/ | ||
QObject { | ||
id: root | ||
|
||
/** Account key used for filtering **/ | ||
required property string accountKey | ||
/** network chainId used for filtering **/ | ||
required property int chainId | ||
/** token key used for filtering **/ | ||
required property string tokenKey | ||
/** amount selected in send modal for sending **/ | ||
required property string selectedAmountInBaseUnit | ||
/** | ||
Expected model structure: | ||
name [int] - name of account | ||
address [string] - address of account | ||
emoji [string] - emoji of account | ||
colorId [string] - colorId of account | ||
**/ | ||
required property var accountsModel | ||
/** | ||
Expected model structure: | ||
chainId [int] - network chain id | ||
chainName [string] - name of network | ||
iconUrl [string] - network icon url | ||
**/ | ||
required property var networksModel | ||
/** | ||
Expected model structure: | ||
key [int] - unique id of token | ||
symbol [int] - symbol of token | ||
decimals [string] - decimals of token | ||
**/ | ||
required property var tokenBySymbolModel | ||
|
||
/** output property of the account selected **/ | ||
readonly property var selectedAccount: selectedAccountEntry.item | ||
/** output property of the network selected **/ | ||
readonly property var selectedNetwork: selectedNetworkEntry.item | ||
/** output property of the asset (ERC20) selected **/ | ||
readonly property var selectedAsset: selectedAssetEntry.item | ||
/** output property of the localised amount to send **/ | ||
readonly property string selectedAmount: { | ||
const decimals = !!root.selectedAsset ? root.selectedAsset.decimals: 0 | ||
const divisor = AmountsArithmetic.fromExponent(decimals) | ||
let amount = AmountsArithmetic.div( | ||
AmountsArithmetic.fromString(root.selectedAmountInBaseUnit), | ||
divisor).toFixed(decimals) | ||
// removeDecimalTrailingZeros | ||
amount = Utils.stripTrailingZeros(amount) | ||
// localize | ||
return amount.replace(".", Qt.locale().decimalPoint) | ||
} | ||
/** output property of the selected asset contract address on selected chainId **/ | ||
readonly property string selectedAssetContractAddress: selectedAssetContractEntry.available && | ||
!!selectedAssetContractEntry.item ? | ||
selectedAssetContractEntry.item.address: "" | ||
|
||
ModelEntry { | ||
id: selectedAccountEntry | ||
sourceModel: root.accountsModel | ||
value: root.accountKey | ||
key: "address" | ||
} | ||
|
||
ModelEntry { | ||
id: selectedNetworkEntry | ||
sourceModel: root.networksModel | ||
value: root.chainId | ||
key: "chainId" | ||
} | ||
|
||
ModelEntry { | ||
id: selectedAssetEntry | ||
sourceModel: root.tokenBySymbolModel | ||
value: root.tokenKey | ||
key: "key" | ||
} | ||
|
||
ModelEntry { | ||
id: selectedAssetContractEntry | ||
sourceModel: selectedAssetEntry.available && | ||
!!selectedAssetEntry.item ? | ||
selectedAssetEntry.item.addressPerChain: null | ||
value: root.chainId | ||
key: "chainId" | ||
} | ||
} |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
CollectiblesSelectionAdaptor 1.0 CollectiblesSelectionAdaptor.qml | ||
TokenSelectorViewAdaptor 1.0 TokenSelectorViewAdaptor.qml | ||
WalletAccountsSelectorAdaptor 1.0 WalletAccountsSelectorAdaptor.qml | ||
SignSendAdaptor 1.0 SignSendAdaptor.qml |
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
Oops, something went wrong.