Skip to content

Commit

Permalink
Merge pull request #81 from perawallet/next-release
Browse files Browse the repository at this point in the history
  • Loading branch information
mucahit authored Nov 25, 2022
2 parents 0bfa66a + 3be9366 commit 624274c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,18 @@ It's enabled by default but in some cases, you may not need the toast message (e
#### `PeraWalletConnect.connect(): Promise<string[]>`
| 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<string[]>`
Reconnects to the wallet if there is any active connection and returns the array of account addresses.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
9 changes: 7 additions & 2 deletions src/PeraWalletConnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ class PeraWalletConnect {
};
}

connect() {
connect({network}: {network?: PeraWalletNetwork} = {}) {
return new Promise<string[]>(async (resolve, reject) => {
try {
// check if already connected and kill session first before creating a new one.
Expand All @@ -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,
Expand Down

0 comments on commit 624274c

Please sign in to comment.