diff --git a/README.md b/README.md index 93d7442..5e29bba 100644 --- a/README.md +++ b/README.md @@ -120,8 +120,18 @@ It's enabled by default but in some cases, you may not need the toast message (e #### `PeraWalletConnect.connect(): Promise` +| option | default | value | | +| --------- | --------- | --------------------------- | -------- | +| `network` | `mainnet` | `dev`, `testnet`, `mainnet` | optional | + Starts the initial connection flow and returns the array of account addresses. +`network` param of the `connect` method overrides the initial `network` on the constructor. + +```javascript +PeraWalletConnect.connect({network: "testnet"}); //optional +``` + #### `PeraWalletConnect.reconnectSession(): Promise` Reconnects to the wallet if there is any active connection and returns the array of account addresses. diff --git a/package-lock.json b/package-lock.json index b57945c..ad30e75 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@perawallet/connect", - "version": "1.0.5", + "version": "1.0.6", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@perawallet/connect", - "version": "1.0.5", + "version": "1.0.6", "license": "ISC", "dependencies": { "@json-rpc-tools/utils": "^1.7.6", diff --git a/package.json b/package.json index 04456b7..b545d5a 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "1.0.5", + "version": "1.0.6", "name": "@perawallet/connect", "description": "JavaScript SDK for integrating Pera Wallet to web applications.", "main": "dist/index.js", diff --git a/src/PeraWalletConnect.ts b/src/PeraWalletConnect.ts index a8f1a9c..7693db8 100644 --- a/src/PeraWalletConnect.ts +++ b/src/PeraWalletConnect.ts @@ -361,7 +361,7 @@ class PeraWalletConnect { }; } - connect() { + connect({network}: {network?: PeraWalletNetwork} = {}) { return new Promise(async (resolve, reject) => { try { // check if already connected and kill session first before creating a new one. @@ -370,13 +370,18 @@ class PeraWalletConnect { await this.connector.killSession(); } + if (network) { + // override network if provided + getLocalStorage()?.setItem(PERA_WALLET_LOCAL_STORAGE_KEYS.NETWORK, network); + } + const { isWebWalletAvailable, bridgeURL, webWalletURL, shouldDisplayNewBadge, shouldUseSound - } = await getPeraConnectConfig(this.network); + } = await getPeraConnectConfig(network || this.network); const {onWebWalletConnect} = this.connectWithWebWallet( resolve,