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

Fix Sub bridge issues #1060

Merged
merged 5 commits into from
Jun 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
"dependencies": {
"@metamask/detect-provider": "^2.0.0",
"@soramitsu/soraneo-wallet-web": "1.17.11",
"@soramitsu/soraneo-wallet-web": "1.17.13",
"@walletconnect/web3-provider": "^1.8.0",
"base-64": "^1.0.0",
"core-js": "^3.26.0",
Expand Down
20 changes: 19 additions & 1 deletion src/components/mixins/NetworkFormatterMixin.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { BridgeNetworkType } from '@sora-substrate/util/build/bridgeProxy/consts';
import { EvmNetworkId } from '@sora-substrate/util/build/bridgeProxy/evm/consts';
import { SubNetwork } from '@sora-substrate/util/build/bridgeProxy/sub/consts';
import { WALLET_CONSTS } from '@soramitsu/soraneo-wallet-web';
import { Component, Mixins } from 'vue-property-decorator';

import { EvmLinkType, EVM_NETWORKS } from '@/consts/evm';
import { SUB_NETWORKS } from '@/consts/sub';
import { state, getter } from '@/store/decorators';
import type { NetworkData } from '@/types/bridge';

Expand All @@ -18,14 +20,30 @@ export default class NetworkFormatterMixin extends Mixins(TranslationMixin) {

readonly EvmLinkType = EvmLinkType;

formatNetwork(isSora: boolean): string {
formatProvidedNetwork(isSora: boolean): string {
if (isSora && this.soraNetwork) {
return this.TranslationConsts.soraNetwork[this.soraNetwork];
}

return this.providedNetwork?.name ?? '';
}

formatNetworkShortName(isSora: boolean): string {
if (isSora) {
return this.TranslationConsts.Sora;
}

return this.providedNetwork?.shortName ?? '';
}

getNetworkName(type: Nullable<BridgeNetworkType>, id: Nullable<BridgeNetworkId>): string {
if (!(type && id)) return '';

const networks = type === BridgeNetworkType.Sub ? SUB_NETWORKS : EVM_NETWORKS;

return networks[id]?.shortName ?? '';
}

getNetworkIcon(network?: Nullable<BridgeNetworkId>): string {
switch (network) {
// special case
Expand Down
6 changes: 3 additions & 3 deletions src/store/assets/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,18 @@ async function getSubRegisteredAssets(context: ActionContext<any, any>): Promise
return [
// ROC
{
'0x00c9b0c0ce84da8283187401b673c5ece0b307f270036076f129fc4edfb9083f': {
'0x005963f9e01c987ae213bca46603d8b569ebbf91d3c52ab59207d7e4dae87bff': {
address: '',
balance: '0',
decimals: 12,
decimals: 18,
},
},
];
} else {
return [
// KAR
{
'0x005963f9e01c987ae213bca46603d8b569ebbf91d3c52ab59207d7e4dae87bff': {
'0x00c9b0c0ce84da8283187401b673c5ece0b307f270036076f129fc4edfb9083f': {
address: '',
balance: '0',
decimals: 12,
Expand Down
10 changes: 10 additions & 0 deletions src/store/bridge/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,16 @@ function bridgeDataToHistoryItem(
}

const actions = defineActions({
resetForm(context) {
const { commit, dispatch } = bridgeActionContext(context);

commit.setSoraToEvm(true);
commit.setExternalHistory({});
commit.setAmount();

dispatch.setAssetAddress();
},

async updateBalanceSubscription(context): Promise<void> {
const { getters, commit, rootGetters } = bridgeActionContext(context);
const updateBalance = (balance: Nullable<AccountBalance>) => commit.setAssetBalance(balance);
Expand Down
13 changes: 4 additions & 9 deletions src/store/web3/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,12 @@ async function connectEvmNetwork(context: ActionContext<any, any>, networkHex?:
async function connectSubNetwork(context: ActionContext<any, any>, network?: SubNetwork): Promise<void> {
// [TODO] connect to substrate network
// this code just takes network from storage
const { commit, rootCommit } = web3ActionContext(context);
const { commit } = web3ActionContext(context);
const provided = network || ethersUtil.getSelectedNetwork();

if (provided) {
commit.setProvidedNetwork(provided);
}

// only outgoing direction
rootCommit.bridge.setSoraToEvm(true);
}

const actions = defineActions({
Expand All @@ -40,17 +37,15 @@ const actions = defineActions({
},

async connectExternalNetwork(context, network?: string): Promise<void> {
const { state, rootCommit } = web3ActionContext(context);
const { state, rootDispatch } = web3ActionContext(context);

if (state.networkType === BridgeNetworkType.Sub) {
await connectSubNetwork(context, network as SubNetwork);
} else {
await connectEvmNetwork(context, network);
}

// reset bridge direction & history
rootCommit.bridge.setSoraToEvm(true);
rootCommit.bridge.setExternalHistory({});
// reset bridge form
rootDispatch.bridge.resetForm();
},

async selectExternalNetwork(context, network: BridgeNetworkId): Promise<void> {
Expand Down
6 changes: 2 additions & 4 deletions src/views/Bridge.vue
Original file line number Diff line number Diff line change
Expand Up @@ -516,13 +516,11 @@ export default class Bridge extends Mixins(
}

getBridgeItemTitle(isSoraNetwork = false): string {
return this.formatNetwork(isSoraNetwork);
return this.formatProvidedNetwork(isSoraNetwork);
}

getCopyTooltip(isSoraNetwork = false): string {
if (isSoraNetwork) return this.copyTooltip(this.t('bridge.soraAddress'));

const networkName = this.providedNetwork?.shortName ?? '';
const networkName = this.formatNetworkShortName(isSoraNetwork);
const text = `${networkName} ${this.t('addressText')}`;

return this.copyTooltip(text);
Expand Down
11 changes: 10 additions & 1 deletion src/views/BridgeTransaction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,14 @@ export default class BridgeTransaction extends Mixins(
return this.t('bridgeTransaction.statuses.pending') + '...';
}

get txExternalNetworkName(): string {
const id = this.historyItem?.externalNetwork;
const type = this.historyItem?.externalNetworkType;
const name = this.getNetworkName(type, id);

return name;
}

get txExternalAccount(): string {
return this.historyItem?.to ?? '';
}
Expand Down Expand Up @@ -476,8 +484,9 @@ export default class BridgeTransaction extends Mixins(
}

getNetworkText(key: string, isSora = true): string {
const network = isSora ? this.TranslationConsts.Sora : this.TranslationConsts.EVM;
const network = isSora ? this.TranslationConsts.Sora : this.txExternalNetworkName;
const text = this.t(key);

return `${network} ${text}`;
}

Expand Down
3 changes: 0 additions & 3 deletions src/views/BridgeTransactionsHistory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@
</div>
</s-form>
</s-card>

<bridge-select-network :selected-evm-network="selectedNetwork" />
</div>
</template>

Expand All @@ -90,7 +88,6 @@ import type { IBridgeTransaction } from '@sora-substrate/util';
components: {
GenericPageHeader: lazyComponent(Components.GenericPageHeader),
SwapStatusActionBadge: lazyComponent(Components.SwapStatusActionBadge),
BridgeSelectNetwork: lazyComponent(Components.BridgeSelectNetwork),
SearchInput: components.SearchInput,
FormattedAmount: components.FormattedAmount,
HistoryPagination: components.HistoryPagination,
Expand Down
84 changes: 42 additions & 42 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2667,68 +2667,68 @@
resolved "https://registry.yarnpkg.com/@soda/get-current-script/-/get-current-script-1.0.2.tgz#a53515db25d8038374381b73af20bb4f2e508d87"
integrity sha512-T7VNNlYVM1SgQ+VsMYhnDkcGmWhQdL0bDyGm5TlQ3GBXnJscEClUUOKduWTmm2zCnvNLC1hc3JpuXjs/nFOc5w==

"@sora-substrate/api@1.17.13":
version "1.17.13"
resolved "https://registry.yarnpkg.com/@sora-substrate/api/-/api-1.17.13.tgz#32aed571347ff3a1fac28a4bc44d4168d49bd59a"
integrity sha512-ehqQ0N4rNbPOfucfK6FJFA+4XtTEVW9cenZcsgCxi3PAvFPpA/G1oeVSvl8Thl2S7WiGGEGMg+5psI2NdKXb7g==
"@sora-substrate/api@1.17.15":
version "1.17.15"
resolved "https://registry.yarnpkg.com/@sora-substrate/api/-/api-1.17.15.tgz#72fbd31c9d0a9d521f6b209ff987c8fb82d3fe18"
integrity sha512-OuP73okGw6UVQ35T73CQ5zbg5xaFIFRH1s7YyZ6MNyDxyhGLbiaIjHwNblt4/VlV8tduc8eU+UNVOj+SpiQ80A==
dependencies:
"@open-web3/orml-api-derive" "1.1.4"
"@polkadot/api" "9.14.2"
"@sora-substrate/types" "1.17.13"
"@sora-substrate/types" "1.17.15"

"@sora-substrate/connection@1.17.13":
version "1.17.13"
resolved "https://registry.yarnpkg.com/@sora-substrate/connection/-/connection-1.17.13.tgz#8408a4dee869adcb43bdf7515fb2db5f1c7b9556"
integrity sha512-cX/d/aovwsW2Jgip8GFzTxLpau1zHj1fa8IvSDNaxLCe9ZKexj9k9hoMp7JHmj4OjvxURMS6jiGFA2/i9xReWQ==
"@sora-substrate/connection@1.17.15":
version "1.17.15"
resolved "https://registry.yarnpkg.com/@sora-substrate/connection/-/connection-1.17.15.tgz#56b27a19b9b6a41c5e974f1ddf7b66d06d5d01f7"
integrity sha512-BhwmdV8zWotItc7B839Gfbe+Z9QiyNCuovSDG6MfSmt+gB4+7CVD87eLz88n/KMfQf+/o36z8lAj4hAx616UkQ==
dependencies:
"@sora-substrate/api" "1.17.13"
"@sora-substrate/api" "1.17.15"

"@sora-substrate/liquidity-proxy@1.17.13":
version "1.17.13"
resolved "https://registry.yarnpkg.com/@sora-substrate/liquidity-proxy/-/liquidity-proxy-1.17.13.tgz#7d93f505aa5084e3ec61c86ca730c39a78422b89"
integrity sha512-CQscykH5YlHWi+RtNr3fNmf+GuG7fr/J4bJIrXcBBPn3BlLB156ofL3zzwS3DM0rDsl4ydN850jVY12of5Guqg==
"@sora-substrate/liquidity-proxy@1.17.15":
version "1.17.15"
resolved "https://registry.yarnpkg.com/@sora-substrate/liquidity-proxy/-/liquidity-proxy-1.17.15.tgz#0514f8c7b8cb94f0416d6539528f814dabc72dd7"
integrity sha512-1PA9nmDCJgbJTPiQnI12YydIHYKuOV3MCnR8DrNnd4JYm5L1QCGRBsUBydXaGDz00DkhUGsPrJcftDITL1zOjg==
dependencies:
"@sora-substrate/math" "1.17.13"
"@sora-substrate/math" "1.17.15"

"@sora-substrate/math@1.17.13":
version "1.17.13"
resolved "https://registry.yarnpkg.com/@sora-substrate/math/-/math-1.17.13.tgz#3377d48fd0425972de88f23194eec1e4675b94d7"
integrity sha512-60PaOR+P+sBIyi9QHknT3mj5UEkd7IaHD/ygtxSkZOkerZxLxt5dDJl5v05pxzxvwCxyEseWwsakCucbCTg+SQ==
"@sora-substrate/math@1.17.15":
version "1.17.15"
resolved "https://registry.yarnpkg.com/@sora-substrate/math/-/math-1.17.15.tgz#87e3cdc1935e22501d3275ecca1e2e05084c3a0a"
integrity sha512-P/6PFcF9wC2+exgIQt+FBvuAK+UPGoHhfz2bFEqIsl+HF8jcoOVB759dOkwAiCJVDlPvCGhxYf+V9dIPQ7tt7Q==
dependencies:
"@polkadot/types" "9.14.2"
bignumber.js "^9.0.1"
lodash "^4.17.15"

"@sora-substrate/type-definitions@1.17.13":
version "1.17.13"
resolved "https://registry.yarnpkg.com/@sora-substrate/type-definitions/-/type-definitions-1.17.13.tgz#859874d891466980f8d008fc138ee60740de2086"
integrity sha512-TJPmw4ISx5IOMzJTm2O3iPJQ6i0G5u/O0wK60TT9ttTw7o8ZVhVJjG02pDVhx4p+ok1EBdNfA1OQoU73kxS4dg==
"@sora-substrate/type-definitions@1.17.15":
version "1.17.15"
resolved "https://registry.yarnpkg.com/@sora-substrate/type-definitions/-/type-definitions-1.17.15.tgz#130bd66166570c8a58726cf10580d2085e16744b"
integrity sha512-bYTIwTCJTgRr4/9+wpm4VIYH7hBMcmBg0MtDYmiEjt3sB1JnwOVM19fQk1wtbDyDrlHLU9vALpOKpdj7Mfv06A==
dependencies:
"@open-web3/orml-type-definitions" "1.1.4"

"@sora-substrate/types@1.17.13":
version "1.17.13"
resolved "https://registry.yarnpkg.com/@sora-substrate/types/-/types-1.17.13.tgz#5c1615e1871b678ffade6b160a35f249e6488e93"
integrity sha512-yatnvGlRzyNTrBmY1zOxZWyEwpmn2YVoTh/qkGUJEZhC2+HpcZuLNlY3xE+j3294TM1YBfslA6huWxRLHX2SZg==
"@sora-substrate/types@1.17.15":
version "1.17.15"
resolved "https://registry.yarnpkg.com/@sora-substrate/types/-/types-1.17.15.tgz#7c634bffc5fce1777fa21ca8d31976ddc6ff3fa7"
integrity sha512-XRNWGgWGudziWGkOZTrpsJCpixLjRK1+mMuJa8WUoEOlK23pa76snWY7U6X9mGvUtIUJDfnnkjXUO5CM58Hrgw==
dependencies:
"@open-web3/api-mobx" "0.9.4-26"
"@open-web3/orml-types" "1.1.4"
"@polkadot/api" "9.14.2"
"@polkadot/typegen" "9.14.2"
"@polkadot/types" "9.14.2"
"@sora-substrate/type-definitions" "1.17.13"
"@sora-substrate/type-definitions" "1.17.15"

"@sora-substrate/util@1.17.13":
version "1.17.13"
resolved "https://registry.yarnpkg.com/@sora-substrate/util/-/util-1.17.13.tgz#8b18daf36dd4c480de9e9e8c772233a968db5be0"
integrity sha512-EtYBYG8logM/2n6kr3ib0b9tRPriW+u0N+OYtH9IoYksXeE/7SSG6DtSFKEHApM0nq5rsWWIFsTcOZisriLxvw==
"@sora-substrate/util@1.17.15":
version "1.17.15"
resolved "https://registry.yarnpkg.com/@sora-substrate/util/-/util-1.17.15.tgz#6195200a5dc08d7b92f814f2185af5827bbc99dd"
integrity sha512-5n5fso//KXRHeJCe5JdEnQtJEVm3V+CVSO+rjKg+hwB6hGZeDHqrzKoYsnFVQXd4AQtkqLkQWCdKuw5JFtpvjg==
dependencies:
"@polkadot/ui-keyring" "2.12.1"
"@sora-substrate/api" "1.17.13"
"@sora-substrate/connection" "1.17.13"
"@sora-substrate/liquidity-proxy" "1.17.13"
"@sora-substrate/math" "1.17.13"
"@sora-substrate/types" "1.17.13"
"@sora-substrate/api" "1.17.15"
"@sora-substrate/connection" "1.17.15"
"@sora-substrate/liquidity-proxy" "1.17.15"
"@sora-substrate/math" "1.17.15"
"@sora-substrate/types" "1.17.15"
axios "^0.21.1"
bignumber.js "^9.0.1"
crypto-js "^4.0.0"
Expand Down Expand Up @@ -2762,13 +2762,13 @@
vue-property-decorator "^9.1.2"
vuex "^3.6.2"

"@soramitsu/soraneo-wallet-web@1.17.11":
version "1.17.11"
resolved "https://nexus.iroha.tech/repository/npm-group/@soramitsu/soraneo-wallet-web/-/soraneo-wallet-web-1.17.11.tgz#527abcf1f75930a35716cdbd2194ac9cc8141155"
integrity sha512-/lTPCQ91EeA508A50Fiu6ofaq9L9+64HjpSs+Dw5TUt1arXUI5hFZ8VIOH47f+heD0QAz+Idsv/SyL1CfcY8Cw==
"@soramitsu/soraneo-wallet-web@1.17.13":
version "1.17.13"
resolved "https://nexus.iroha.tech/repository/npm-group/@soramitsu/soraneo-wallet-web/-/soraneo-wallet-web-1.17.13.tgz#153dd57b865d88f6646b76adb6077a86b498f756"
integrity sha512-/DZ/nRMfDrzB+Tneo5LDsLQhVlTWaF0tbg8s4lzXQR+aySGJYvuPoydgQptdiHuUIpFq814rxbhv4IaTxgsz0A==
dependencies:
"@polkadot/vue-identicon" "2.12.1"
"@sora-substrate/util" "1.17.13"
"@sora-substrate/util" "1.17.15"
"@sora-test/wallet-connect" "^0.0.9"
"@soramitsu/soramitsu-js-ui" "^1.0.45"
"@urql/core" "^3.0.5"
Expand Down