Skip to content

Commit

Permalink
fix: resolved usePrice and XCM issue
Browse files Browse the repository at this point in the history
  • Loading branch information
impelcrypto committed Jul 5, 2024
1 parent 8524332 commit d02b2d0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
32 changes: 19 additions & 13 deletions src/hooks/usePrice.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useStore } from 'src/store';
import { computed, ref, watchEffect } from 'vue';
import { computed, ref, watch } from 'vue';
import { useNetworkInfo } from 'src/hooks';
import { getUsdBySymbol } from '@astar-network/astar-sdk-core';
import { getUsdBySymbol, wait } from '@astar-network/astar-sdk-core';

export function usePrice() {
const store = useStore();
Expand All @@ -13,18 +13,24 @@ export function usePrice() {

const { isMainnet, isAstarZkEvm } = useNetworkInfo();

watchEffect(async () => {
const tokenSymbolRef = tokenSymbol.value;
if (!tokenSymbolRef) return;
try {
if (isMainnet.value) {
const nativeToken = isAstarZkEvm.value ? 'ETH' : tokenSymbolRef;
nativeTokenUsd.value = await getUsdBySymbol(nativeToken);
watch(
[tokenSymbol],
async () => {
// Memo: hacky way to fix the 'invalid BigNumber string' error
await wait(500);
const tokenSymbolRef = tokenSymbol.value;
if (!tokenSymbolRef) return;
try {
if (isMainnet.value) {
const nativeToken = isAstarZkEvm.value ? 'ETH' : tokenSymbolRef;
nativeTokenUsd.value = await getUsdBySymbol(nativeToken);
}
} catch (error: any) {
console.error(error.message);
}
} catch (error: any) {
console.error(error.message);
}
});
},
{ immediate: true }
);

return {
nativeTokenUsd,
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/xcm/useTransferRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export type TransferMode = 'local' | 'xcm';
export const astarNetworks = ['astar', 'shiden', 'shibuya'];
export const astarNativeTokens = ['sdn', 'astr', 'sby'];
// e.g.: endpointKey.SHIDEN;
const disabledXcmChain: endpointKey | undefined = endpointKey.SHIDEN;
const disabledXcmChain: endpointKey | undefined = undefined;

export interface NetworkFromTo {
from: string;
Expand Down
4 changes: 2 additions & 2 deletions src/v2/repositories/implementations/PolkasafeRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ export class PolkasafeRepository implements IPolkasafeRepository {
const polkasafeClient = container.get<PolkasafeWrapper>(Symbols.PolkasafeClient);
const { data, error } = await polkasafeClient.customTransactionAsMulti(
multisigAddress,
transaction,
transaction as any,
undefined,
isProxyAccount,
new BN(tip)
new BN(tip) as any
);
if (error) {
console.error('error', error);
Expand Down
4 changes: 3 additions & 1 deletion src/v2/repositories/implementations/XcmRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ export class XcmRepository implements IXcmRepository {
},
id: {
Concrete: {
interior: 'Here',
interior: {
Here: null,
},
parents: new BN(0),
},
},
Expand Down

0 comments on commit d02b2d0

Please sign in to comment.