Skip to content

Commit

Permalink
fix: deep linking for veworld extension (#195)
Browse files Browse the repository at this point in the history
* fix: deep linking for veworld extension

* fix: tests

* chore: increase version
  • Loading branch information
davidecarpini authored Feb 12, 2024
1 parent a34b536 commit 2f7cfd0
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 29 deletions.
2 changes: 1 addition & 1 deletion packages/dapp-kit-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vechain/dapp-kit-react",
"version": "1.0.6",
"version": "1.0.7",
"private": false,
"homepage": "https://github.com/vechainfoundation/vechain-dapp-kit",
"repository": "github:vechain/vechain-dapp-kit",
Expand Down
2 changes: 1 addition & 1 deletion packages/dapp-kit-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vechain/dapp-kit-ui",
"version": "1.0.6",
"version": "1.0.7",
"private": false,
"description": "Vanilla JS DAppKit",
"keywords": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
defaultI18n,
Font,
WalletSources,
VEWORLD_WEBSITE,
} from '../../../constants';
import {
DarkChevronLeftSvg,
Expand Down Expand Up @@ -97,6 +98,14 @@ export class ConnectModal extends LitElement {
@property({ type: Function })
onSourceClick = (source?: SourceInfo): void => {
if (source) {
if (source.id === 'veworld' && !window.vechain) {
const path = `${location.host}${location.pathname}${location.search}`;
window.open(
`${VEWORLD_WEBSITE}/?discoveryUrl=${path}`,
'_self',
);
return;
}
if (source.id !== 'wallet-connect') {
this.setWaitingForTheSignature(true);
this.requestForConnectionCertificate = true;
Expand Down
1 change: 1 addition & 0 deletions packages/dapp-kit-ui/src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export * from './stores';
export * from './font';
export * from './i18n';
export * from './z-index';
export * from './veworld';
1 change: 1 addition & 0 deletions packages/dapp-kit-ui/src/constants/veworld.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const VEWORLD_WEBSITE = 'https://veworld.com';
2 changes: 1 addition & 1 deletion packages/dapp-kit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vechain/dapp-kit",
"version": "1.0.6",
"version": "1.0.7",
"private": false,
"homepage": "https://github.com/vechainfoundation/vechain-dapp-kit",
"repository": "github:vechain/vechain-dapp-kit",
Expand Down
4 changes: 1 addition & 3 deletions packages/dapp-kit/src/classes/wallet-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,7 @@ class WalletManager {
private getAvailableSources = (): WalletSource[] => {
const wallets: WalletSource[] = [];

if (window.vechain) {
wallets.push('veworld');
}
wallets.push('veworld');

if (this.options.walletConnectOptions) {
wallets.push('wallet-connect');
Expand Down
2 changes: 1 addition & 1 deletion packages/dapp-kit/test/wallet-tests/sync.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe('sync', () => {
);
});

it('get available sources - should not include veworld', () => {
it('get available sources - should not include sync', () => {
const connex = createUnitTestConnex();

const sources = connex.wallet.state.availableSources;
Expand Down
22 changes: 0 additions & 22 deletions packages/dapp-kit/test/wallet-tests/veworld-extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,4 @@ describe('veworld', () => {
expect(sources).toContain('veworld');
});
});

describe('is NOT in veworld browser', () => {
beforeEach(() => {
window.vechain = undefined;
});

it('not installed - should throw error', () => {
const connex = createUnitTestConnex();

expect(() => connex.wallet.setSource('veworld')).toThrowError(
'VeWorld Extension is not installed',
);
});

it('get available sources - should not include veworld', () => {
const connex = createUnitTestConnex();

const sources = connex.wallet.state.availableSources;

expect(sources).not.toContain('veworld');
});
});
});

0 comments on commit 2f7cfd0

Please sign in to comment.