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: deep linking for veworld extension #195

Merged
merged 3 commits into from
Feb 12, 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
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');
});
});
});
Loading