neat: test page for testing router v2
This commit is contained in:
parent
e896267874
commit
76fbc4e6fd
|
@ -1,4 +1,4 @@
|
||||||
import sugar, sequtils, stint
|
import Tables, sugar, sequtils, stint
|
||||||
import uuids, chronicles
|
import uuids, chronicles
|
||||||
import io_interface
|
import io_interface
|
||||||
import app_service/service/wallet_account/service as wallet_account_service
|
import app_service/service/wallet_account/service as wallet_account_service
|
||||||
|
@ -114,6 +114,12 @@ proc suggestedRoutes*(self: Controller, accountFrom: string, accountTo: string,
|
||||||
self.transactionService.suggestedRoutes(accountFrom, accountTo, amount, token, toToken, disabledFromChainIDs,
|
self.transactionService.suggestedRoutes(accountFrom, accountTo, amount, token, toToken, disabledFromChainIDs,
|
||||||
disabledToChainIDs, preferredChainIDs, sendType, lockedInAmounts)
|
disabledToChainIDs, preferredChainIDs, sendType, lockedInAmounts)
|
||||||
|
|
||||||
|
proc suggestedRoutesV2*(self: Controller, accountFrom: string, accountTo: string, amount: Uint256, token: string, toToken: string,
|
||||||
|
disabledFromChainIDs, disabledToChainIDs, preferredChainIDs: seq[int], sendType: SendType, lockedInAmounts: Table[string, string],
|
||||||
|
extraParamsTable: Table[string, string]): string =
|
||||||
|
return self.transactionService.suggestedRoutesV2(accountFrom, accountTo, amount, token, toToken, disabledFromChainIDs,
|
||||||
|
disabledToChainIDs, preferredChainIDs, sendType, lockedInAmounts, extraParamsTable)
|
||||||
|
|
||||||
proc transfer*(self: Controller, from_addr: string, to_addr: string, assetKey: string, toAssetKey: string,
|
proc transfer*(self: Controller, from_addr: string, to_addr: string, assetKey: string, toAssetKey: string,
|
||||||
uuid: string, selectedRoutes: seq[TransactionPathDto], password: string, sendType: SendType,
|
uuid: string, selectedRoutes: seq[TransactionPathDto], password: string, sendType: SendType,
|
||||||
usePassword: bool, doHashing: bool, tokenName: string, isOwnerToken: bool) =
|
usePassword: bool, doHashing: bool, tokenName: string, isOwnerToken: bool) =
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import stint
|
import Tables, stint
|
||||||
import app/modules/shared_models/currency_amount
|
import app/modules/shared_models/currency_amount
|
||||||
import app_service/service/transaction/dto
|
import app_service/service/transaction/dto
|
||||||
import app/modules/shared_models/collectibles_model as collectibles
|
import app/modules/shared_models/collectibles_model as collectibles
|
||||||
|
@ -28,6 +28,11 @@ method suggestedRoutes*(self: AccessInterface, accountFrom: string, accountTo: s
|
||||||
disabledFromChainIDs, disabledToChainIDs, preferredChainIDs: seq[int], sendType: SendType, lockedInAmounts: string) {.base.} =
|
disabledFromChainIDs, disabledToChainIDs, preferredChainIDs: seq[int], sendType: SendType, lockedInAmounts: string) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method suggestedRoutesV2*(self: AccessInterface, accountFrom: string, accountTo: string, amount: Uint256, token: string, toToken: string,
|
||||||
|
disabledFromChainIDs, disabledToChainIDs, preferredChainIDs: seq[int], sendType: SendType, lockedInAmounts: Table[string, string],
|
||||||
|
extraParamsTable: Table[string, string]): string {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method suggestedRoutesReady*(self: AccessInterface, suggestedRoutes: SuggestedRoutesDto) {.base.} =
|
method suggestedRoutesReady*(self: AccessInterface, suggestedRoutes: SuggestedRoutesDto) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
|
|
@ -360,6 +360,13 @@ method suggestedRoutesReady*(self: Module, suggestedRoutes: SuggestedRoutesDto)
|
||||||
rawPaths = suggestedRoutes.rawBest)
|
rawPaths = suggestedRoutes.rawBest)
|
||||||
self.view.setTransactionRoute(transactionRoutes)
|
self.view.setTransactionRoute(transactionRoutes)
|
||||||
|
|
||||||
|
method suggestedRoutesV2*(self: Module, accountFrom: string, accountTo: string, amount: Uint256, token: string, toToken: string,
|
||||||
|
disabledFromChainIDs, disabledToChainIDs, preferredChainIDs: seq[int], sendType: SendType, lockedInAmounts: Table[string, string],
|
||||||
|
extraParamsTable: Table[string, string]): string =
|
||||||
|
discard
|
||||||
|
return self.controller.suggestedRoutesV2(accountFrom, accountTo, amount, token, toToken, disabledFromChainIDs,
|
||||||
|
disabledToChainIDs, preferredChainIDs, sendType, lockedInAmounts, extraParamsTable)
|
||||||
|
|
||||||
method filterChanged*(self: Module, addresses: seq[string], chainIds: seq[int]) =
|
method filterChanged*(self: Module, addresses: seq[string], chainIds: seq[int]) =
|
||||||
if addresses.len == 0:
|
if addresses.len == 0:
|
||||||
return
|
return
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import NimQml, sequtils, strutils, stint, sugar
|
import NimQml, Tables, json, sequtils, strutils, stint, sugar
|
||||||
|
|
||||||
import ./io_interface, ./accounts_model, ./account_item, ./network_model, ./network_item, ./suggested_route_item, ./transaction_routes
|
import ./io_interface, ./accounts_model, ./account_item, ./network_model, ./network_item, ./suggested_route_item, ./transaction_routes
|
||||||
import app/modules/shared_models/collectibles_model as collectibles
|
import app/modules/shared_models/collectibles_model as collectibles
|
||||||
|
@ -247,6 +247,32 @@ QtObject:
|
||||||
self.toNetworksModel.getRouteDisabledNetworkChainIds(), self.toNetworksModel.getRoutePreferredNetworkChainIds(),
|
self.toNetworksModel.getRouteDisabledNetworkChainIds(), self.toNetworksModel.getRoutePreferredNetworkChainIds(),
|
||||||
self.sendType, self.fromNetworksModel.getRouteLockedChainIds())
|
self.sendType, self.fromNetworksModel.getRouteLockedChainIds())
|
||||||
|
|
||||||
|
proc suggestedRoutesV2*(self: View, accountFrom: string, accountTo: string, amount: string, token: string, toToken: string,
|
||||||
|
disabledFromChainIDs: string, disabledToChainIDs: string, preferredChainIDs: string, sendType: int, lockedInAmounts: string,
|
||||||
|
extraParamsJson: string): string {.slot.} =
|
||||||
|
var
|
||||||
|
parsedAmount = stint.u256(0)
|
||||||
|
disabledFromChainIDsArray: seq[int]
|
||||||
|
disabledToChainIDsArray: seq[int]
|
||||||
|
preferredChainIDsArray: seq[int]
|
||||||
|
lockedInAmountsTable: Table[string, string]
|
||||||
|
extraParamsTable: Table[string, string]
|
||||||
|
|
||||||
|
try:
|
||||||
|
parsedAmount = amount.parse(Uint256)
|
||||||
|
disabledFromChainIDsArray = map(parseJson(disabledFromChainIDs).getElems(), proc(x:JsonNode):int = x.getInt())
|
||||||
|
disabledToChainIDsArray = map(parseJson(disabledToChainIDs).getElems(), proc(x:JsonNode):int = x.getInt())
|
||||||
|
preferredChainIDsArray = map(parseJson(preferredChainIDs).getElems(), proc(x:JsonNode):int = x.getInt())
|
||||||
|
for chainId, lockedAmount in parseJson(lockedInAmounts):
|
||||||
|
lockedInAmountsTable[chainId] = lockedAmount.getStr()
|
||||||
|
for key, value in parseJson(extraParamsJson):
|
||||||
|
extraParamsTable[key] = value.getStr()
|
||||||
|
except Exception as e:
|
||||||
|
discard
|
||||||
|
|
||||||
|
return self.delegate.suggestedRoutesV2(accountFrom, accountTo, parsedAmount, token, toToken, disabledFromChainIDsArray,
|
||||||
|
disabledToChainIDsArray, preferredChainIDsArray, (SendType)sendType, lockedInAmountsTable, extraParamsTable)
|
||||||
|
|
||||||
proc switchSenderAccountByAddress*(self: View, address: string) =
|
proc switchSenderAccountByAddress*(self: View, address: string) =
|
||||||
let (account, index) = self.senderAccounts.getItemByAddress(address)
|
let (account, index) = self.senderAccounts.getItemByAddress(address)
|
||||||
self.setSelectedSenderAccount(account)
|
self.setSelectedSenderAccount(account)
|
||||||
|
|
|
@ -597,6 +597,29 @@ QtObject:
|
||||||
)
|
)
|
||||||
self.threadpool.start(arg)
|
self.threadpool.start(arg)
|
||||||
|
|
||||||
|
proc suggestedRoutesV2*(self: Service, accountFrom: string, accountTo: string, amount: Uint256, token: string, toToken: string,
|
||||||
|
disabledFromChainIDs, disabledToChainIDs, preferredChainIDs: seq[int], sendType: SendType, lockedInAmounts: Table[string, string],
|
||||||
|
extraParamsTable: Table[string, string]): string =
|
||||||
|
let amountAsHex = "0x" & eth_utils.stripLeadingZeros(amount.toHex)
|
||||||
|
|
||||||
|
try:
|
||||||
|
let response = eth.suggestedRoutesV2(
|
||||||
|
accountFrom,
|
||||||
|
accountTo,
|
||||||
|
amountAsHex,
|
||||||
|
token,
|
||||||
|
toToken,
|
||||||
|
disabledFromChainIDs,
|
||||||
|
disabledToChainIDs,
|
||||||
|
preferredChainIDs,
|
||||||
|
ord(sendType),
|
||||||
|
lockedInAmounts,
|
||||||
|
extraParamsTable,
|
||||||
|
)
|
||||||
|
return $response.result
|
||||||
|
except Exception as e:
|
||||||
|
error "Error getting suggested routes V2", message = e.msg
|
||||||
|
|
||||||
proc onFetchCryptoServices*(self: Service, response: string) {.slot.} =
|
proc onFetchCryptoServices*(self: Service, response: string) {.slot.} =
|
||||||
let cryptoServices = parseJson(response){"result"}.getElems().map(x => x.toCryptoRampDto())
|
let cryptoServices = parseJson(response){"result"}.getElems().map(x => x.toCryptoRampDto())
|
||||||
self.events.emit(SIGNAL_CRYPTO_SERVICES_READY, CryptoServicesArgs(data: cryptoServices))
|
self.events.emit(SIGNAL_CRYPTO_SERVICES_READY, CryptoServicesArgs(data: cryptoServices))
|
||||||
|
|
|
@ -32,5 +32,33 @@ proc suggestedRoutes*(accountFrom: string, accountTo: string, amount: string, to
|
||||||
preferredChainIDs, 1, lockedInAmounts]
|
preferredChainIDs, 1, lockedInAmounts]
|
||||||
return core.callPrivateRPC("wallet_getSuggestedRoutes", payload)
|
return core.callPrivateRPC("wallet_getSuggestedRoutes", payload)
|
||||||
|
|
||||||
|
proc suggestedRoutesV2*(accountFrom: string, accountTo: string, amount: string, token: string, toToken: string, disabledFromChainIDs,
|
||||||
|
disabledToChainIDs, preferredChainIDs: seq[int], sendType: int, lockedInAmounts: Table[string, string], extraParamsTable: Table[string, string]): RpcResponse[JsonNode] =
|
||||||
|
const
|
||||||
|
gasFeeLow = 0
|
||||||
|
gasFeeMedium = 1
|
||||||
|
gasFeeHigh = 2
|
||||||
|
|
||||||
|
let data = %* {
|
||||||
|
"sendType": sendType,
|
||||||
|
"addrFrom": accountFrom,
|
||||||
|
"addrTo": accountTo,
|
||||||
|
"amountIn": amount,
|
||||||
|
"tokenID": token,
|
||||||
|
"toTokenID": toToken,
|
||||||
|
"disabledFromChainIDs": disabledFromChainIDs,
|
||||||
|
"disabledToChaindIDs": disabledToChainIDs,
|
||||||
|
"preferedChainIDs": preferredChainIDs,
|
||||||
|
"gasFeeMode": gasFeeMedium,
|
||||||
|
"fromLockedAmount": lockedInAmounts,
|
||||||
|
# "testnetMode" optional parameter
|
||||||
|
}
|
||||||
|
|
||||||
|
for key, value in extraParamsTable:
|
||||||
|
data[key] = %* value
|
||||||
|
|
||||||
|
let payload = %* [data]
|
||||||
|
return core.callPrivateRPC("wallet_getSuggestedRoutesV2", payload)
|
||||||
|
|
||||||
rpc(getEstimatedLatestBlockNumber, "wallet"):
|
rpc(getEstimatedLatestBlockNumber, "wallet"):
|
||||||
chainId: int
|
chainId: int
|
||||||
|
|
|
@ -44,6 +44,7 @@ SettingsContentBase {
|
||||||
readonly property int accountViewIndex: 4
|
readonly property int accountViewIndex: 4
|
||||||
readonly property int manageTokensViewIndex: 5
|
readonly property int manageTokensViewIndex: 5
|
||||||
readonly property int savedAddressesViewIndex: 6
|
readonly property int savedAddressesViewIndex: 6
|
||||||
|
readonly property int routerTestViewIndex: 7
|
||||||
|
|
||||||
readonly property string walletSectionTitle: qsTr("Wallet")
|
readonly property string walletSectionTitle: qsTr("Wallet")
|
||||||
readonly property string networksSectionTitle: qsTr("Networks")
|
readonly property string networksSectionTitle: qsTr("Networks")
|
||||||
|
@ -133,6 +134,7 @@ SettingsContentBase {
|
||||||
stackContainer.currentIndex === root.accountOrderViewIndex ? accountOrderView.height:
|
stackContainer.currentIndex === root.accountOrderViewIndex ? accountOrderView.height:
|
||||||
stackContainer.currentIndex === root.manageTokensViewIndex ? manageTokensView.implicitHeight :
|
stackContainer.currentIndex === root.manageTokensViewIndex ? manageTokensView.implicitHeight :
|
||||||
stackContainer.currentIndex === root.savedAddressesViewIndex ? savedAddressesView.height:
|
stackContainer.currentIndex === root.savedAddressesViewIndex ? savedAddressesView.height:
|
||||||
|
stackContainer.currentIndex === root.routerTestViewIndex ? routerTest.height:
|
||||||
accountView.height
|
accountView.height
|
||||||
currentIndex: mainViewIndex
|
currentIndex: mainViewIndex
|
||||||
|
|
||||||
|
@ -185,6 +187,10 @@ SettingsContentBase {
|
||||||
root.sectionTitle = qsTr("Saved addresses")
|
root.sectionTitle = qsTr("Saved addresses")
|
||||||
|
|
||||||
root.titleRowComponentLoader.sourceComponent = addNewSavedAddressButtonComponent
|
root.titleRowComponentLoader.sourceComponent = addNewSavedAddressButtonComponent
|
||||||
|
} else if(currentIndex == root.routerTestViewIndex) {
|
||||||
|
root.rootStore.backButtonName = root.walletSectionTitle
|
||||||
|
root.sectionTitle = qsTr("Test the Router")
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,8 +242,8 @@ SettingsContentBase {
|
||||||
onGoToManageTokensView: {
|
onGoToManageTokensView: {
|
||||||
stackContainer.currentIndex = manageTokensViewIndex
|
stackContainer.currentIndex = manageTokensViewIndex
|
||||||
}
|
}
|
||||||
onGoToSavedAddressesView: {
|
onGoToRouterTestView: {
|
||||||
stackContainer.currentIndex = root.savedAddressesViewIndex
|
stackContainer.currentIndex = root.routerTestViewIndex
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -369,6 +375,13 @@ SettingsContentBase {
|
||||||
sendModal: root.rootStore.sendModalPopup
|
sendModal: root.rootStore.sendModalPopup
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RouterTestView {
|
||||||
|
id: routerTest
|
||||||
|
Layout.fillHeight: true
|
||||||
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
DappPermissionsView {
|
DappPermissionsView {
|
||||||
walletStore: root.walletStore
|
walletStore: root.walletStore
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ Column {
|
||||||
signal goToDappPermissionsView()
|
signal goToDappPermissionsView()
|
||||||
signal goToManageTokensView()
|
signal goToManageTokensView()
|
||||||
signal goToSavedAddressesView()
|
signal goToSavedAddressesView()
|
||||||
|
signal goToRouterTestView()
|
||||||
|
|
||||||
signal runRenameKeypairFlow(var model)
|
signal runRenameKeypairFlow(var model)
|
||||||
signal runRemoveKeypairFlow(var model)
|
signal runRemoveKeypairFlow(var model)
|
||||||
|
@ -177,6 +178,21 @@ Column {
|
||||||
|
|
||||||
Separator {}
|
Separator {}
|
||||||
|
|
||||||
|
StatusListItem {
|
||||||
|
title: qsTr("Test the Router")
|
||||||
|
height: 64
|
||||||
|
width: parent.width
|
||||||
|
onClicked: root.goToRouterTestView()
|
||||||
|
components: [
|
||||||
|
StatusIcon {
|
||||||
|
icon: "next"
|
||||||
|
color: Theme.palette.baseColor1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
Separator {}
|
||||||
|
|
||||||
Spacer {
|
Spacer {
|
||||||
visible: root.walletStore.walletModule.hasPairedDevices
|
visible: root.walletStore.walletModule.hasPairedDevices
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -8,3 +8,4 @@ ManageTokensView 1.0 ManageTokensView.qml
|
||||||
NetworksView 1.0 NetworksView.qml
|
NetworksView 1.0 NetworksView.qml
|
||||||
PermissionsListView 1.0 PermissionsListView.qml
|
PermissionsListView 1.0 PermissionsListView.qml
|
||||||
SavedAddressesView 1.0 SavedAddressesView.qml
|
SavedAddressesView 1.0 SavedAddressesView.qml
|
||||||
|
RouterTestView 1.0 RouterTestView.qml
|
||||||
|
|
Loading…
Reference in New Issue