Skip to content

Commit

Permalink
Merge pull request #36 from ElrondNetwork/development
Browse files Browse the repository at this point in the history
Merge development into main
  • Loading branch information
ccorcoveanu authored Jul 21, 2021
2 parents 37b6908 + 435ebb5 commit e3639e3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how

## [Unreleased]


## [6.4.0]
- [Added web wallet token option for login hook #33](https://github.com/ElrondNetwork/elrond-sdk-erdjs/pull/33)

## [6.3.1]
- [Bugfix - Exported UserVerifier #31](https://github.com/ElrondNetwork/elrond-sdk-erdjs/pull/31)

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.3.1",
"version": "6.4.0",
"description": "Smart Contracts interaction framework",
"main": "out/index.js",
"types": "out/index.d.js",
Expand Down
2 changes: 1 addition & 1 deletion src/dapp/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {SignableMessage} from "../signableMessage";

export interface IDappProvider {
init(): Promise<boolean>;
login(options?: {callbackUrl?: string}): Promise<string>;
login(options?: {callbackUrl?: string; token?: string}): Promise<string>;
logout(): Promise<boolean>;
getAddress(): Promise<string>;
isInitialized(): boolean;
Expand Down
12 changes: 10 additions & 2 deletions src/dapp/walletProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class WalletProvider implements IDappProvider {
/**
* Fetches the login hook url and redirects the client to the wallet login.
*/
async login(options?:{callbackUrl?:string}): Promise<string> {
async login(options?:{callbackUrl?:string; token?:string}): Promise<string> {
if (!this.mainFrame) {
return '';
}
Expand Down Expand Up @@ -134,7 +134,15 @@ export class WalletProvider implements IDappProvider {

window.addEventListener('message', connectUrl);
}).then((connectionUrl: string) => {
window.location.href = `${this.baseWalletUrl()}${connectionUrl}?callbackUrl=${options !== undefined && options.callbackUrl !== undefined ? options.callbackUrl : window.location.href}`;
let callbackUrl = `callbackUrl=${window.location.href}`;
if (options && options.callbackUrl) {
callbackUrl = `callbackUrl=${options.callbackUrl}`;
}
let token = '';
if (options && options.token) {
token = `&token=${options.token}`;
}
window.location.href = `${this.baseWalletUrl()}${connectionUrl}?${callbackUrl}${token}`;
return window.location.href;
}).catch(_ => {
return '';
Expand Down

0 comments on commit e3639e3

Please sign in to comment.