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

Bugfix iframe url + merged missing main changes #54

Merged
merged 8 commits into from
Aug 12, 2021
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: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ Breaking changes:
- Removed `TestWallets`
- Use added function `loadTestWallets` (or `loadInteractive`)

## [6.6.1]
- [Bugfixed WalletProvider by adding possibility to match iframe by id #53](https://github.com/ElrondNetwork/elrond-sdk-erdjs/pull/53)

## [6.6.0]
- [Added signature to walletConnectProvider to handle Token Login #49](https://github.com/ElrondNetwork/elrond-sdk-erdjs/pull/49)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@elrondnetwork/erdjs",
"version": "6.6.0",
"version": "6.6.1",
"description": "Smart Contracts interaction framework",
"main": "out/index.js",
"types": "out/index.d.js",
Expand Down
20 changes: 4 additions & 16 deletions src/dapp/walletConnectProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,8 @@ export class WalletConnectProvider implements IDappProvider {
this.walletConnector.accounts.length
) {
const [account] = this.walletConnector.accounts;
if (account.includes(".")) {
const address = account.split(".");
if (address.length > 0) {
this.loginAccount(address[0], address[1]);
}
} else {
this.loginAccount(account);
}
const [address, signature] = account.split(".");
await this.loginAccount(address, signature);
}

return true;
Expand Down Expand Up @@ -220,14 +214,8 @@ export class WalletConnectProvider implements IDappProvider {
accounts: [account],
} = params[0];

if (account.includes(".")) {
const address = account.split(".");
if (address.length > 0) {
let _ = this.loginAccount(address[0], address[1]);
}
} else {
let _ = this.loginAccount(account);
}
const [address, signature] = account.split(".");
await this.loginAccount(address, signature);
}

private async onDisconnect(error: any) {
Expand Down
12 changes: 10 additions & 2 deletions src/dapp/walletProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@ import { ErrNotImplemented } from "../errors";

export class WalletProvider implements IDappProvider {
walletUrl: string;
customId: string;
mainFrame: HTMLIFrameElement | undefined;

/**
* Creates a new WalletProvider
* @param walletURL
* @param customId
*/
constructor(walletURL: string = '') {
constructor(walletURL: string = '', customId = '') {
this.walletUrl = walletURL;
this.customId = customId;
this.attachMainFrame();
let _ = this.init();
}
Expand Down Expand Up @@ -396,7 +399,12 @@ export class WalletProvider implements IDappProvider {
}

private attachMainFrame() {
const currentMainframe = <HTMLIFrameElement>document.querySelector(`iframe[src="${this.walletUrl}"]`);
let currentMainframe: HTMLIFrameElement|null;
if (this.customId) {
currentMainframe = document.querySelector(`iframe[id="${this.customId}"]`);
} else {
currentMainframe = document.querySelector(`iframe[src="${this.walletUrl}"]`);
}
if (currentMainframe) {
this.mainFrame = currentMainframe;
return;
Expand Down