Skip to content

Commit

Permalink
dont call getNetworkFee on not supported networks (#1438)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita-Polyakov authored Jun 18, 2024
1 parent 08596b8 commit 3daa74c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 34 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@
"@polkadot/extension-dapp": "^0.44.7",
"@polkadot/extension-inject": "^0.44.7",
"@polkadot/util": "^12.6.2",
"@sora-substrate/util": "1.38.12",
"ipfs-unixfs": "6.0.6",
"ipfs-unixfs-exporter": "7.0.6",
"ipfs-unixfs-importer": "9.0.6"
Expand Down
2 changes: 1 addition & 1 deletion src/components/mixins/SubscriptionsMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default class SubscriptionsMixin extends Mixins(mixins.LoadingMixin) {
// return if updateSubscription is already called by "watch" or "mounted"
if (this.loading) return;

await this.withLoading(async () => {
await this.withApi(async () => {
// wait for node connection & wallet init (App.vue)
await this.withParentLoading(async () => {
await Promise.all(this.startSubscriptionsList.map((fn) => fn?.()));
Expand Down
11 changes: 4 additions & 7 deletions src/utils/bridge/sub/classes/adapters/parachain/acala.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,10 @@ export class AcalaParachainAdapter extends SubAdapter {
);
}

/* Throws error until Substrate 5 migration */
public override async getNetworkFee(asset: RegisteredAsset, sender: string, recipient: string): Promise<CodecString> {
try {
return await super.getNetworkFee(asset, sender, recipient);
} catch (error) {
// Hardcoded value for Acala - 0.003 ACA
return '3000000000';
}
/* Throws error until Substrate 5 migration */
// return await super.getNetworkFee(asset, sender, recipient);
// Hardcoded value for Acala - 0.003 ACA
return '3000000000';
}
}
11 changes: 4 additions & 7 deletions src/utils/bridge/sub/classes/adapters/parachain/astar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,10 @@ export class AstarParachainAdapter extends SubAdapter {
: this.getAssetTransferExtrinsic(asset, recipient, amount);
}

/* Throws error until Substrate 5 migration */
public async getNetworkFee(asset: RegisteredAsset, sender: string, recipient: string): Promise<CodecString> {
try {
return await super.getNetworkFee(asset, sender, recipient);
} catch (error) {
// Hardcoded value for Astar - 0.057 ASTR
return '57000000000000000';
}
/* Throws error until Substrate 5 migration */
// return await super.getNetworkFee(asset, sender, recipient);
// Hardcoded value for Astar - 0.057 ASTR
return '57000000000000000';
}
}
33 changes: 15 additions & 18 deletions src/utils/bridge/sub/classes/adapters/relaychain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,25 +62,22 @@ export class RelaychainAdapter extends SubAdapter {
);
}

/* Throws error until Substrate 5 migration */
public override async getNetworkFee(asset: RegisteredAsset, sender: string, recipient: string): Promise<CodecString> {
try {
return await super.getNetworkFee(asset, sender, recipient);
} catch {
const toCodec = (fee: number) => new FPNumber(fee, asset.externalDecimals).toCodecString();
// Hardcoded values
switch (this.subNetwork) {
case SubNetworkId.Rococo:
return toCodec(0.000125);
case SubNetworkId.Alphanet:
return toCodec(0.019);
case SubNetworkId.Kusama:
return toCodec(0.002);
case SubNetworkId.Polkadot:
return toCodec(0.059);
default:
return '0';
}
/* Throws error until Substrate 5 migration */
// return await super.getNetworkFee(asset, sender, recipient);
const toCodec = (fee: number) => new FPNumber(fee, asset.externalDecimals).toCodecString();
// Hardcoded values
switch (this.subNetwork) {
case SubNetworkId.Rococo:
return toCodec(0.000125);
case SubNetworkId.Alphanet:
return toCodec(0.019);
case SubNetworkId.Kusama:
return toCodec(0.002);
case SubNetworkId.Polkadot:
return toCodec(0.059);
default:
return '0';
}
}
}

0 comments on commit 3daa74c

Please sign in to comment.