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 subquery bridge history #1200

Merged
merged 1 commit into from
Oct 23, 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 @@ -24,7 +24,7 @@
},
"dependencies": {
"@metamask/detect-provider": "^2.0.0",
"@soramitsu/soraneo-wallet-web": "1.23.1",
"@soramitsu/soraneo-wallet-web": "1.23.3",
"@walletconnect/web3-provider": "^1.8.0",
"core-js": "^3.26.0",
"country-code-emoji": "^2.3.0",
Expand Down
4 changes: 3 additions & 1 deletion src/store/bridge/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,9 @@ const actions = defineActions({
const referenceAsset = DAI.address;
const sources = [LiquiditySourceTypes.XYKPool, LiquiditySourceTypes.XSTPool];
const limitObservable = api.bridgeProxy.getCurrentTransferLimitObservable();
const quoteObservable = await api.swap.getSwapQuoteObservable(referenceAsset, limitAsset, sources, DexId.XOR);
const quoteObservable = api.swap.getSwapQuoteObservable(referenceAsset, limitAsset, sources, DexId.XOR);

if (!quoteObservable) return;

let subscription!: Subscription;

Expand Down
3 changes: 2 additions & 1 deletion src/store/swap/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ const mutations = defineMutations<SwapState>()({
setRoute(state, route: string[]): void {
state.route = Object.freeze([...route]);
},
setSubscriptionPayload(state, { quote, isAvailable, liquiditySources }: SwapQuoteData): void {
setSubscriptionPayload(state, payload?: SwapQuoteData): void {
const { quote = null, isAvailable = false, liquiditySources = [] } = payload ?? {};
state.swapQuote = quote;
state.isAvailable = isAvailable;
state.liquiditySources = liquiditySources;
Expand Down
12 changes: 3 additions & 9 deletions src/utils/bridge/eth/classes/history.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import { Operation } from '@sora-substrate/util';
import { BridgeNetworkType, BridgeTxStatus } from '@sora-substrate/util/build/bridgeProxy/consts';
import {
api,
historyElementsFilter,
SUBQUERY_TYPES,
WALLET_CONSTS,
getCurrentIndexer,
} from '@soramitsu/soraneo-wallet-web';
import { api, SUBQUERY_TYPES, WALLET_CONSTS, getCurrentIndexer } from '@soramitsu/soraneo-wallet-web';
import { ethers, EtherscanProvider, BlockTag } from 'ethers';
import first from 'lodash/fp/first';
import last from 'lodash/fp/last';
Expand Down Expand Up @@ -259,16 +253,16 @@ export class EthBridgeHistory {
}

public async fetchHistoryElements(address: string, timestamp = 0, ids?: string[]): Promise<HistoryElement[]> {
const indexer = getCurrentIndexer();
const operations = [Operation.EthBridgeOutgoing, Operation.EthBridgeIncoming];
const filter = historyElementsFilter({ address, operations, timestamp, ids });
const filter = indexer.historyElementsFilter({ address, operations, timestamp, ids });
const history: HistoryElement[] = [];

let hasNext = true;
let after = '';

do {
const variables = { after, filter, first: 100 };
const indexer = getCurrentIndexer();
const response = await indexer.services.explorer.account.getHistoryPaged(variables);

if (!response) return history;
Expand Down
20 changes: 13 additions & 7 deletions src/views/Swap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export default class Swap extends Mixins(
@mutation.swap.setRewards private setRewards!: (rewards: Array<LPRewardsInfo>) => void;
@mutation.swap.setRoute private setRoute!: (route: Array<string>) => void;
@mutation.swap.selectDexId private selectDexId!: (dexId: DexId) => void;
@mutation.swap.setSubscriptionPayload private setSubscriptionPayload!: (payload: SwapQuoteData) => void;
@mutation.swap.setSubscriptionPayload private setSubscriptionPayload!: (payload?: SwapQuoteData) => void;

@action.swap.setTokenFromAddress private setTokenFromAddress!: (address?: string) => Promise<void>;
@action.swap.setTokenToAddress private setTokenToAddress!: (address?: string) => Promise<void>;
Expand Down Expand Up @@ -406,6 +406,8 @@ export default class Swap extends Mixins(
await this.setTokenFromAddress(XOR.address);
await this.setTokenToAddress();
}
// to update tbc & xst enabled assets
await api.swap.update();

this.enableSwapSubscriptions();
});
Expand Down Expand Up @@ -490,16 +492,20 @@ export default class Swap extends Mixins(

this.loading = true;

const observableQuote = await api.swap.getDexesSwapQuoteObservable(
const observableQuote = api.swap.getDexesSwapQuoteObservable(
(this.tokenFrom as AccountAsset).address,
(this.tokenTo as AccountAsset).address
);

this.quoteSubscription = observableQuote.subscribe((quoteData) => {
this.setSubscriptionPayload(quoteData);
this.runRecountSwapValues();
this.loading = false;
});
if (observableQuote) {
this.quoteSubscription = observableQuote.subscribe((quoteData) => {
this.setSubscriptionPayload(quoteData);
this.runRecountSwapValues();
this.loading = false;
});
} else {
this.setSubscriptionPayload();
}
}

handleFocusField(isExchangeB = false): void {
Expand Down
84 changes: 42 additions & 42 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2263,68 +2263,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.23.3":
version "1.23.3"
resolved "https://registry.yarnpkg.com/@sora-substrate/api/-/api-1.23.3.tgz#1b2f0ebcde0c48fd81901aadcca59ae5c77158eb"
integrity sha512-yrEVQS+pSnJv0kB17Ex+z7ZhLR2KY7d/jU/7/DrX5da7uJ8YLeXxL3aGmswkNMSBJtBJPcQQJwXwQXGoE17M6g==
"@sora-substrate/api@1.23.9":
version "1.23.9"
resolved "https://registry.yarnpkg.com/@sora-substrate/api/-/api-1.23.9.tgz#8e1bd67c0efddc4b49bf0c7f42aa4b5f394915e3"
integrity sha512-xmD36pc78zbBDY568oCyItzYKokU3sHKnVnVdVO5rGA5KfeY4fKg+KHl5ekUB5HtJN/+IXPIhomLFj89e7J0sQ==
dependencies:
"@open-web3/orml-api-derive" "1.1.4"
"@polkadot/api" "9.14.2"
"@sora-substrate/types" "1.23.3"
"@sora-substrate/types" "1.23.9"

"@sora-substrate/connection@1.23.3":
version "1.23.3"
resolved "https://registry.yarnpkg.com/@sora-substrate/connection/-/connection-1.23.3.tgz#515f6f4e0055df848f630b66f3be33a07a1abcc5"
integrity sha512-nK1znTMy+3jGvylJB+zIt9qBD1Q9aJhrx36K1VOWTHrbiPa1gsOfizXE2s4S7DcdxgRIA0hhJVkNAEuNsO02SA==
"@sora-substrate/connection@1.23.9":
version "1.23.9"
resolved "https://registry.yarnpkg.com/@sora-substrate/connection/-/connection-1.23.9.tgz#724d8101782fe2280e56e39837372c61f10997a3"
integrity sha512-qXKkO5h8RbLdhCw/T0UfwyWpAoAbQE+d5k3sHdymZjhCk6V4xgwIba2jl/v8v5Xw4W+lYqOiNs/3M3IJ0ZvF+A==
dependencies:
"@sora-substrate/api" "1.23.3"
"@sora-substrate/api" "1.23.9"

"@sora-substrate/liquidity-proxy@1.23.3":
version "1.23.3"
resolved "https://registry.yarnpkg.com/@sora-substrate/liquidity-proxy/-/liquidity-proxy-1.23.3.tgz#cd87fc3e9ea829174105bb20896f707fffb734ed"
integrity sha512-Wt1N+zH6CyzCK3uiyNZAf6SfjTQTyHRtz2bfJt87bI8AqE/dIf+HI5kvGZ2wjw49LVl35zL9WCmK4d/YNIgsTg==
"@sora-substrate/liquidity-proxy@1.23.9":
version "1.23.9"
resolved "https://registry.yarnpkg.com/@sora-substrate/liquidity-proxy/-/liquidity-proxy-1.23.9.tgz#7a6c2106bef9c6e28c708ca2fb0f8ffd113b1fb6"
integrity sha512-Q7KtncQq/BHmfpeICbUXrfUNf24VLlyXhdWVJKpVEenHUHCkIkepj/OhcG5dMU7aojLAgTYsoHmTqBNGlcvjcQ==
dependencies:
"@sora-substrate/math" "1.23.3"
"@sora-substrate/math" "1.23.9"

"@sora-substrate/math@1.23.3":
version "1.23.3"
resolved "https://registry.yarnpkg.com/@sora-substrate/math/-/math-1.23.3.tgz#53eddcf6a5bd71b9679f1899d4d4386892eaec94"
integrity sha512-mhMyyfaGQFbf01J9vbJFavcfZCgXtcduKi/V6VtGUjbgCeWps/GcUBAOdUWDLGJUprVOFXbefgsTeaMbxeiHmA==
"@sora-substrate/math@1.23.9":
version "1.23.9"
resolved "https://registry.yarnpkg.com/@sora-substrate/math/-/math-1.23.9.tgz#55c45b555533c8b608333635c06b29761027925b"
integrity sha512-MODKMFvgSL7vsR9s0k1D6770cEX2kn/6BbEtBpsjGPda17Vw2kWwYxaGdn1vP8Gy2tpGynvbfdeHWS1EzxQzBw==
dependencies:
"@polkadot/types" "9.14.2"
bignumber.js "^9.0.1"
lodash "^4.17.15"

"@sora-substrate/type-definitions@1.23.3":
version "1.23.3"
resolved "https://registry.yarnpkg.com/@sora-substrate/type-definitions/-/type-definitions-1.23.3.tgz#ee4cbc272deb5b8af9650e4a1426f954a2406533"
integrity sha512-z1cWllnw8hnB2EbYK/AVWN/rrg9qpl5xoRzg4Hhp4ovia9RA+2w6ibSk1o+rvXX8lW2QaR4roUQdWr82CqpFhg==
"@sora-substrate/type-definitions@1.23.9":
version "1.23.9"
resolved "https://registry.yarnpkg.com/@sora-substrate/type-definitions/-/type-definitions-1.23.9.tgz#d76f417af43fbbfecf777318e629198465610d5e"
integrity sha512-Rnqm0HsKtXfnJTDl/emtNaI1BTdXmjPsZcTGHjfnDXmIWjE6YQ8iegJEuJiGg6AcCyICXoEoEqrLzXZC+jH01g==
dependencies:
"@open-web3/orml-type-definitions" "1.1.4"

"@sora-substrate/types@1.23.3":
version "1.23.3"
resolved "https://registry.yarnpkg.com/@sora-substrate/types/-/types-1.23.3.tgz#e2f611900cdc6cbc10c7bb8de18b61d53dc2a52e"
integrity sha512-jrbztVx0ZAyD9us5CkZtQtnrXahoL2eZVsEyMM5gn1cxI2j80WIvnkAvD8DwocQx53cID8K60ma4dhCQZBdVDA==
"@sora-substrate/types@1.23.9":
version "1.23.9"
resolved "https://registry.yarnpkg.com/@sora-substrate/types/-/types-1.23.9.tgz#a3a51ab48b501b5c5ac1fcfebff29f8713e8b347"
integrity sha512-P1/1RA4jGzw9r87AUfT05tfMshBPoW4aQoR1oMqf9RmanhPBEVJZq4ZOa3W0HIQAxoTemkC1Cs13lg+CAxiXnQ==
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.23.3"
"@sora-substrate/type-definitions" "1.23.9"

"@sora-substrate/util@1.23.3":
version "1.23.3"
resolved "https://registry.yarnpkg.com/@sora-substrate/util/-/util-1.23.3.tgz#396d44d50c54d430d0a1d1dcb45b37bd6d6da701"
integrity sha512-Sh70+A/qKVSnE8AKSNzV8ATO2V4cjzJS23OI7iPn0fC2LcVl/sexg4jwKxCFZacK8knxAvw1VOSTSlg2VieW1A==
"@sora-substrate/util@1.23.9":
version "1.23.9"
resolved "https://registry.yarnpkg.com/@sora-substrate/util/-/util-1.23.9.tgz#fb2f37e3078874be457609c766d5cd0dfa218d3c"
integrity sha512-yrsn7bClablYI9iYFpAFsDgkhTKCC3R8GsV17NDD0c1vFt60sCF3pHXRWJcmgssu9SZ7Fqbx50Pd1pLD6/Kpmw==
dependencies:
"@polkadot/ui-keyring" "2.12.1"
"@sora-substrate/api" "1.23.3"
"@sora-substrate/connection" "1.23.3"
"@sora-substrate/liquidity-proxy" "1.23.3"
"@sora-substrate/math" "1.23.3"
"@sora-substrate/types" "1.23.3"
"@sora-substrate/api" "1.23.9"
"@sora-substrate/connection" "1.23.9"
"@sora-substrate/liquidity-proxy" "1.23.9"
"@sora-substrate/math" "1.23.9"
"@sora-substrate/types" "1.23.9"
axios "^0.21.1"
crypto-js "^4.0.0"
lodash "^4.17.15"
Expand Down Expand Up @@ -2357,13 +2357,13 @@
vue-property-decorator "^9.1.2"
vuex "^3.6.2"

"@soramitsu/soraneo-wallet-web@1.23.1":
version "1.23.1"
resolved "https://nexus.iroha.tech/repository/npm-group/@soramitsu/soraneo-wallet-web/-/soraneo-wallet-web-1.23.1.tgz#7be6d0e977e7169ba700f063fc0d2932c2dd970c"
integrity sha512-WEqgvAtMW/ywSUMHyc3UdK5lOw9b4ACoxkqzFVaxfGbeMXLNLLNLitfpw88faKs0x0L4ACWmlt1qpS25Y+TTyg==
"@soramitsu/soraneo-wallet-web@1.23.3":
version "1.23.3"
resolved "https://nexus.iroha.tech/repository/npm-group/@soramitsu/soraneo-wallet-web/-/soraneo-wallet-web-1.23.3.tgz#5236a91badaa266ed42416ed568fc4981c94cd2a"
integrity sha512-TkfqRlbwT2XvzKASTL6RCXTl/OfV3OI0/sB76/5E+AroBM8flxHjtJsHs0aLAu5Hc8OF8l80R/1M92qOn10Geg==
dependencies:
"@polkadot/vue-identicon" "2.12.1"
"@sora-substrate/util" "1.23.3"
"@sora-substrate/util" "1.23.9"
"@sora-test/wallet-connect" "^0.0.9"
"@soramitsu/soramitsu-js-ui" "^1.0.46"
"@urql/core" "^4.1.2"
Expand Down