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: veworld support, pin connex versions #132

Merged
merged 1 commit into from
Sep 13, 2024
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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"dependencies": {
"@fortawesome/fontawesome-free": "5.5.0",
"@vechain/connex": "2.0.14",
"@vechain/connex-types": "2.0.12",
"@vechain/picasso": "^2.1.1",
"bignumber.js": "8.0.2",
"buefy": "^0.8.20",
Expand Down Expand Up @@ -42,7 +43,7 @@
"vue-template-compiler": "^2.6.11"
},
"engines": {
"node": "16.20.2",
"node": "^16.20.0",
"yarn": "^1.22"
}
}
12 changes: 7 additions & 5 deletions src/create-connex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,27 @@ const soloGenesis = {
transactions: [],
};

export const isVeWorldAvailable = !!window.vechain

export function createConnex(net?: "main" | "test" | "solo") {
if (net) {
// net specified
const url = nodeUrls[net];
if (net == "solo") {
return new Connex({ node: url, network: soloGenesis });
return new Connex({ node: url, network: soloGenesis, noExtension: !isVeWorldAvailable })
}
return new Connex({ node: url, network: net });
return new Connex({ node: url, network: net, noExtension: !isVeWorldAvailable })
} else {
const injected = (window as any).connex;
// net unspecified
if (injected) {
return new Connex({ node: "", network: injected.thor.genesis });
return new Connex({ node: "", network: injected.thor.genesis, noExtension: !isVeWorldAvailable });
} else {
// defaults to main net, or soloUrl if solo is provided
if (isSoloNode) {
return new Connex({ node: nodeUrls.solo, network: soloGenesis });
return new Connex({ node: nodeUrls.solo, network: soloGenesis, noExtension: !isVeWorldAvailable });
}
return new Connex({ node: nodeUrls.main });
return new Connex({ node: nodeUrls.main, noExtension: !isVeWorldAvailable })
}
}
}
5 changes: 3 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import router from './Router'
import './overwrite.css'
import VueAnalytics from 'vue-analytics'
import Connex from '@vechain/connex'
import { createConnex, isSoloNode } from './create-connex'
import { createConnex, isSoloNode, isVeWorldAvailable } from './create-connex'
import { prePopulate } from '@/pre-populate'
declare module 'vue/types/vue' {
interface Vue {
Expand Down Expand Up @@ -55,7 +55,8 @@ if (window.connex) {
//@ts-ignore
network: window.connex.thor.genesis,
node: '',
noV1Compat: false
noV1Compat: false,
noExtension: !isVeWorldAvailable
})
setExplorerUrl('')
} else {
Expand Down
Loading