Skip to content

Commit

Permalink
Fix: custom network selection (#528)
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky authored Jun 30, 2023
1 parent 7a38734 commit ef969cd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/components/schema/Schema.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ import SchemaAlertOpHashSuccess from "./schemaAlert/SchemaAlertOpHashSuccess";
import SchemaHeader from "./schemaComponents/SchemaHeader";
import SchemaAlertCustomSuccess from "./schemaAlert/SchemaAlertCustomSuccess";
import { TezosOperationType, AbortedBeaconError, BroadcastBeaconError, defaultEventCallbacks } from '@airgap/beacon-sdk'
import {Wallet} from "@/utils/wallet";
import {Wallet, isCustom} from "@/utils/wallet";
import { approveData } from "@/utils/approve";
import ConfirmDialog from "@/components/Dialogs/ConfirmDialog";
Expand Down Expand Up @@ -224,7 +224,6 @@ export default {
this.model = val;
},
setSelectedNetwork(val) {
this.selectedNetwork = val;
},
setSettings({key, val}) {
Expand Down Expand Up @@ -298,7 +297,10 @@ export default {
async checkWalletNetwork() {
const account = Wallet.getLastUsedAccount();
if(account && (this.selectedNetwork) !== account.network.type) {
const isNetwork = !isCustom(account.network.type) &&
account.network.type !== this.selectedNetwork
if(account && isNetwork) {
this.showConfirmDialog = true;
try {
const confirm = await this.$refs.confirm.open();
Expand Down Expand Up @@ -389,7 +391,7 @@ export default {
},
OPERATION_REQUEST_SUCCESS: {
handler: async (data) => {
const link = `/${data.account.network.type}/opg/${data.output.transactionHash}`;
const link = `/${this.selectedNetwork ? this.selectedNetwork : this.network}/opg/${data.output.transactionHash}`;
const successMessage = `The transaction
has successfully been <a href="${link}">broadcasted</a>
to the network.`;
Expand Down
7 changes: 5 additions & 2 deletions src/utils/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ const CORRECT_NETWORK_TYPES = {
"rollupnet": NetworkType.CUSTOM,
}

export function isCustom(network) {
return network === NetworkType.CUSTOM;
}

export class Wallet {
static async getWallet(network, eventHandlers = null) {
if (Wallet.wallet) return Wallet.wallet
Expand Down Expand Up @@ -94,7 +98,6 @@ export class Wallet {
await Wallet.wallet.setActiveAccount(Wallet.getLastUsedAccount());
}


const activeAccount = await this.wallet.getActiveAccount();

return new Promise((resolve, reject) => {
Expand All @@ -110,7 +113,7 @@ export class Wallet {
}
})
.then(() => {
Wallet.isPermissionGiven = true
Wallet.isPermissionGiven = true;
resolve();
})
.finally(() => reject())
Expand Down

0 comments on commit ef969cd

Please sign in to comment.