Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Sub Bridge] add ability to select substrate node #1346

Merged
merged 54 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
a2f4293
transfer to liberland
Nikita-Polyakov Feb 2, 2024
e094526
transfer from liberland
Nikita-Polyakov Feb 2, 2024
c2edfda
fix history fetch
Nikita-Polyakov Feb 5, 2024
104ad34
refactoring adapters
Nikita-Polyakov Feb 5, 2024
44a0347
Merge remote-tracking branch 'origin/develop' into feature/liberland-…
Nikita-Polyakov Feb 6, 2024
2ae72ff
update history restoration
Nikita-Polyakov Feb 6, 2024
42ac72b
change autoselectSubAddress
Nikita-Polyakov Feb 6, 2024
c6b68e4
add asset outgoing minimum amount
Nikita-Polyakov Feb 6, 2024
9fa2cce
update visible min limit
Nikita-Polyakov Feb 6, 2024
165c7b7
update config to sub network endpoint
Nikita-Polyakov Feb 7, 2024
9d58689
multiple endpoints in adapter
Nikita-Polyakov Feb 7, 2024
77b6bf1
update sup network apps & incoming transfer tracking
Nikita-Polyakov Feb 8, 2024
e13712d
add props to SelectNodeDialog
Nikita-Polyakov Feb 8, 2024
d3abe19
Merge remote-tracking branch 'origin/develop' into feature/liberland-…
Nikita-Polyakov Feb 8, 2024
10ebdba
simplify NodeErrorMixin
Nikita-Polyakov Feb 9, 2024
2661e6b
create connection class file
Nikita-Polyakov Feb 9, 2024
d557add
simplify trusted node check
Nikita-Polyakov Feb 12, 2024
63a83d8
remove nodeConnectionAllowance
Nikita-Polyakov Feb 13, 2024
c9e4dba
remove some nodes getters
Nikita-Polyakov Feb 13, 2024
481d6b4
move action to class
Nikita-Polyakov Feb 13, 2024
864fc82
refactoring connectToNode
Nikita-Polyakov Feb 13, 2024
f8fd8d4
transfer wallet init to App.vue
Nikita-Polyakov Feb 14, 2024
f3f2c8d
use appConnection for sora nodes
Nikita-Polyakov Feb 14, 2024
b93b575
fix node info loading state
Nikita-Polyakov Feb 14, 2024
e729046
use NodesConnection in SubAdapter
Nikita-Polyakov Feb 15, 2024
e6b522c
sub node dialog demo
Nikita-Polyakov Feb 16, 2024
83cb9c4
update node dialog texts
Nikita-Polyakov Feb 16, 2024
25e45b0
update network name in select node dialog
Nikita-Polyakov Feb 16, 2024
8bbb99f
refactoring NodesConnection reactivity
Nikita-Polyakov Feb 16, 2024
190a424
simplify adapter
Nikita-Polyakov Feb 20, 2024
9934d05
add BridgeNodeIcon
Nikita-Polyakov Feb 20, 2024
4b551b9
ui node name fixes
Nikita-Polyakov Feb 21, 2024
46b2248
merge origin/develop
Nikita-Polyakov Mar 11, 2024
265f488
ts fixes
Nikita-Polyakov Mar 11, 2024
aa174ae
remove todo comments
Nikita-Polyakov Mar 11, 2024
73220a9
fix failed sub tx status in history
Nikita-Polyakov Mar 11, 2024
cb58a64
add externalNativeMinBalance
Nikita-Polyakov Mar 11, 2024
85ee38d
improve connection wait logic
Nikita-Polyakov Mar 12, 2024
a65cbd0
refactoring min deposit usage, add translation keys
Nikita-Polyakov Mar 12, 2024
a33d2a0
check min balance in transferable amount
Nikita-Polyakov Mar 12, 2024
4141fa9
update bridge apps after reconnect
Nikita-Polyakov Mar 12, 2024
b47742b
fix select-network disabled css
Nikita-Polyakov Mar 12, 2024
a99eb83
update external min balance fetch
Nikita-Polyakov Mar 12, 2024
7d25821
hardcode liberland network fee
Nikita-Polyakov Mar 12, 2024
33fb9ef
set dns regexp with exact start
Nikita-Polyakov Mar 12, 2024
88ae465
add reload button to node list
Nikita-Polyakov Mar 14, 2024
146fa66
Merge remote-tracking branch 'origin/develop' into feature/sub-bridge…
Nikita-Polyakov Mar 14, 2024
2262d02
Merge branch 'develop' into feature/sub-bridge-select-node
Nikita-Polyakov Mar 15, 2024
e31dff8
Merge branch 'develop' into feature/sub-bridge-select-node
Nikita-Polyakov Mar 25, 2024
91ae1b8
Merge branch 'develop' into feature/sub-bridge-select-node
Nikita-Polyakov Mar 25, 2024
8ecc5b7
Merge branch 'develop' into feature/sub-bridge-select-node
stefashkaa Mar 25, 2024
e29053b
Merge branch 'develop' into feature/sub-bridge-select-node
stefashkaa Mar 25, 2024
d81661b
refactoring after review
Nikita-Polyakov Mar 26, 2024
5fb6649
update translations
Nikita-Polyakov Mar 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions env.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@
"NETWORK_TYPE": "Prod",
"CHAIN_GENESIS_HASH": "0x7e4e32d0feafd4f9c9414b0be86373f9a1efa904809b683453a9af6856d38ad5",
"SUB_NETWORKS": {
"Kusama": "wss://kusama-rpc.dwellir.com",
"KusamaSora": "wss://ws.parachain-collator-2.c2.sora2.soramitsu.co.jp",
"Polkadot": "wss://polkadot-rpc.dwellir.com",
"PolkadotSora": "wss://ws.parachain-collator-3.pc3.sora2.soramitsu.co.jp"
"Kusama": true,
"KusamaSora": true,
"Polkadot": true,
"PolkadotSora": true
},
"EVM_NETWORKS_IDS": [56, 8217],
"ETH_BRIDGE": {
Expand Down
33 changes: 27 additions & 6 deletions public/env.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
"chain": "SORA-dev Testnet #3",
"name": "SORA",
"address": "wss://ws.framenode-3.r0.dev.sora2.soramitsu.co.jp"
},
{
"chain": "SORA-dev Liberland",
"name": "SORA",
"address": "wss://ws.framenode-1.lib1.dev.sora2.soramitsu.co.jp"
}
],
"SUBQUERY_ENDPOINT": "https://api.subquery.network/sq/sora-xor/sora-dev",
Expand All @@ -41,11 +46,27 @@
"CHAIN_GENESIS_HASH": "",
"EVM_NETWORKS_IDS": [97, 1001],
"SUB_NETWORKS": {
"Rococo": "wss://ws.relaychain-node-1.r1.dev.sora2.soramitsu.co.jp",
"RococoSora": "wss://ws.parachain-collator-1.c1.dev.sora2.soramitsu.co.jp",
"Kusama": "wss://kusama-rpc.polkadot.io",
"KusamaSora": "wss://ws.parachain-collator-1.c1.sora2.soramitsu.co.jp",
"Polkadot": "wss://rpc.polkadot.io"
"Rococo": [
{
"chain": "Rococo Dev Testnet",
"name": "Soramitsu",
"address": "wss://ws.relaychain-node-1.r1.dev.sora2.soramitsu.co.jp"
}
],
"RococoSora": [
{
"chain": "SORA Rococo Parachain Dev Testnet",
"name": "Soramitsu",
"address": "wss://ws.parachain-collator-1.c1.dev.sora2.soramitsu.co.jp"
}
],
"Liberland": [
{
"chain": "Liberland Dev Testnet",
"name": "Soramitsu",
"address": "wss://rpc.liberland-1.lib1.dev.sora2.soramitsu.co.jp"
}
]
},
"ETH_BRIDGE": {
"evmNetwork": 11155111,
Expand All @@ -55,4 +76,4 @@
"OTHER": "0x401c6A23a44f72151D90878DF0aa86E77fBde0e2"
}
}
}
}
46 changes: 31 additions & 15 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ import {
WALLET_CONSTS,
WALLET_TYPES,
AlertsApiService,
initWallet,
waitForCore,
} from '@soramitsu/soraneo-wallet-web';
import debounce from 'lodash/debounce';
import { Component, Mixins, Watch } from 'vue-property-decorator';
Expand All @@ -54,15 +56,15 @@ import AppHeader from '@/components/App/Header/AppHeader.vue';
import AppMenu from '@/components/App/Menu/AppMenu.vue';
import NodeErrorMixin from '@/components/mixins/NodeErrorMixin';
import SoraLogo from '@/components/shared/Logo/Sora.vue';
import { PageNames, Components, Language, BreakpointClass, Breakpoint } from '@/consts';
import { PageNames, Components, Language, BreakpointClass, Breakpoint, WalletPermissions } from '@/consts';
import { getLocale } from '@/lang';
import router, { goTo, lazyComponent } from '@/router';
import { action, getter, mutation, state } from '@/store/decorators';
import { getMobileCssClasses, preloadFontFace, updateDocumentTitle } from '@/utils';
import type { NodesConnection } from '@/utils/connection';

import type { FeatureFlags } from './store/settings/types';
import type { EthBridgeSettings, SubNetworkApps } from './store/web3/types';
import type { ConnectToNodeOptions, Node } from './types/nodes';
import type { History, HistoryItem } from '@sora-substrate/util';
import type { WhitelistArrayItem } from '@sora-substrate/util/build/assets/types';
import type { EvmNetwork } from '@sora-substrate/util/build/bridgeProxy/evm/types';
Expand Down Expand Up @@ -95,13 +97,15 @@ export default class App extends Mixins(mixins.TransactionMixin, NodeErrorMixin)
showNotifsDarkPage = false;
responsiveClass = BreakpointClass.LargeDesktop;

@state.settings.appConnection appConnection!: NodesConnection;
@state.settings.browserNotifPopupVisibility private browserNotifPopup!: boolean;
@state.settings.browserNotifPopupBlockedVisibility private browserNotifPopupBlocked!: boolean;
@state.wallet.account.assetsToNotifyQueue assetsToNotifyQueue!: Array<WhitelistArrayItem>;
@state.referrals.storageReferrer storageReferrer!: string;
@state.settings.disclaimerVisibility disclaimerVisibility!: boolean;
@state.router.loading pageLoading!: boolean;

@getter.settings.nodeIsConnected nodeIsConnected!: boolean;
@getter.settings.chartsEnabled private chartsEnabled!: boolean;
@getter.wallet.transactions.firstReadyTx firstReadyTransaction!: Nullable<HistoryItem>;
@getter.wallet.account.isLoggedIn isSoraAccountConnected!: boolean;
Expand All @@ -114,8 +118,6 @@ export default class App extends Mixins(mixins.TransactionMixin, NodeErrorMixin)
endpoint: string;
}) => void;

@mutation.settings.setDefaultNodes private setDefaultNodes!: (nodes: Array<Node>) => void;
@mutation.settings.setNetworkChainGenesisHash private setNetworkChainGenesisHash!: (hash?: string) => void;
@mutation.settings.setFaucetUrl private setFaucetUrl!: (url: string) => void;
@mutation.settings.setFeatureFlags private setFeatureFlags!: (data: FeatureFlags) => void;
@mutation.settings.setBrowserNotifsPopupEnabled private setBrowserNotifsPopup!: (flag: boolean) => void;
Expand All @@ -125,15 +127,14 @@ export default class App extends Mixins(mixins.TransactionMixin, NodeErrorMixin)
@mutation.settings.setScreenBreakpointClass private setScreenBreakpointClass!: (cssClass: string) => void;
@mutation.referrals.unsubscribeFromInvitedUsers private unsubscribeFromInvitedUsers!: FnWithoutArgs;
@mutation.web3.setEvmNetworksApp private setEvmNetworksApp!: (data: EvmNetwork[]) => void;
@mutation.web3.setSubNetworkApps private setSubNetworkApps!: (data: SubNetworkApps) => void;
@mutation.web3.setEthBridgeSettings private setEthBridgeSettings!: (settings: EthBridgeSettings) => Promise<void>;
@mutation.referrals.resetStorageReferrer private resetStorageReferrer!: FnWithoutArgs;

@action.web3.setSubNetworkApps private setSubNetworkApps!: (data: SubNetworkApps) => void;
@action.wallet.settings.setApiKeys private setApiKeys!: (apiKeys: WALLET_TYPES.ApiKeysObject) => Promise<void>;
@action.wallet.subscriptions.resetNetworkSubscriptions private resetNetworkSubscriptions!: AsyncFnWithoutArgs;
@action.wallet.subscriptions.resetInternalSubscriptions private resetInternalSubscriptions!: AsyncFnWithoutArgs;
@action.wallet.subscriptions.activateNetwokSubscriptions private activateNetwokSubscriptions!: AsyncFnWithoutArgs;
@action.settings.connectToNode private connectToNode!: (options: ConnectToNodeOptions) => Promise<void>;
@action.settings.setLanguage private setLanguage!: (lang: Language) => Promise<void>;
@action.settings.setBlockNumber private setBlockNumber!: AsyncFnWithoutArgs;
@action.settings.fetchAdsArray private fetchAdsArray!: AsyncFnWithoutArgs;
Expand Down Expand Up @@ -239,7 +240,6 @@ export default class App extends Mixins(mixins.TransactionMixin, NodeErrorMixin)
await this.setEthBridgeSettings(data.ETH_BRIDGE);
this.setFeatureFlags(data?.FEATURE_FLAGS);
this.setSoraNetwork(data.NETWORK_TYPE);
this.setDefaultNodes(data?.DEFAULT_NETWORKS);
this.setEvmNetworksApp(data.EVM_NETWORKS_IDS);
this.setSubNetworkApps(data.SUB_NETWORKS);

Expand All @@ -253,9 +253,9 @@ export default class App extends Mixins(mixins.TransactionMixin, NodeErrorMixin)
if (data.FAUCET_URL) {
this.setFaucetUrl(data.FAUCET_URL);
}
if (data.CHAIN_GENESIS_HASH) {
this.setNetworkChainGenesisHash(data.CHAIN_GENESIS_HASH);
}

this.appConnection.setDefaultNodes(data?.DEFAULT_NETWORKS);
this.appConnection.setNetworkChainGenesisHash(data?.CHAIN_GENESIS_HASH);

// connection to node
await this.runAppConnectionToNode();
Expand Down Expand Up @@ -362,12 +362,28 @@ export default class App extends Mixins(mixins.TransactionMixin, NodeErrorMixin)
}

private async runAppConnectionToNode() {
const walletOptions = {
permissions: WalletPermissions,
appName: WALLET_CONSTS.TranslationConsts.Polkaswap,
};

try {
await this.connectToNode({
onError: (error) => this.handleNodeError(error, true), // prefer notification on connection success
onDisconnect: this.handleNodeDisconnect,
onReconnect: this.handleNodeReconnect,
});
// Run in parallel
// 1) Wallet core initialization (node connection independent)
// 2) Connection to node
await Promise.all([
waitForCore(walletOptions),
this.appConnection.connect({
onError: this.handleNodeError,
onDisconnect: this.handleNodeDisconnect,
onReconnect: this.handleNodeConnect,
}),
]);

// Wallet node connection dependent logic
if (!this.isWalletLoaded) {
await initWallet(walletOptions);
}
} catch (error) {
// we handled error using callback, do nothing
}
Expand Down
Loading