Skip to content

Commit

Permalink
fix: veworld support, pin connex versions
Browse files Browse the repository at this point in the history
  • Loading branch information
akanoce committed Sep 13, 2024
1 parent 89ae755 commit d58b21a
Show file tree
Hide file tree
Showing 4 changed files with 935 additions and 957 deletions.
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

0 comments on commit d58b21a

Please sign in to comment.