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

v2 Release #165

Open
wants to merge 39 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
0b4c8eb
feat(v2): wallet connect v2 integration
yigiterdev Jan 6, 2023
d4fe984
feat: add algorand namespaces
yigiterdev Jan 23, 2023
57ed3d2
feat: update sign method
yigiterdev Jan 23, 2023
e3da183
feat: update required namespaces
yigiterdev Feb 16, 2023
1a6e910
feat: update sign txn request
yigiterdev Feb 16, 2023
3399b34
feat: use `formatJsonRpcRequest` package
yigiterdev Feb 16, 2023
ea5e08a
feat: update stored address on local storage
yigiterdev Feb 16, 2023
efbdee8
feat: store chainId for sign transaction
yigiterdev Feb 16, 2023
89966f8
chore: remove unused things
yigiterdev Feb 16, 2023
8bfa521
fix: update chainId typo
yigiterdev Feb 16, 2023
03cbccc
feat: update deeplink
yigiterdev Mar 13, 2023
17835ef
Merge remote-tracking branch 'origin/next-release' into feat/wallet-c…
yasincaliskan Oct 4, 2023
5830045
Update v2 integration
yasincaliskan Apr 2, 2024
8331ba4
Upgrade walletconnect packages
yasincaliskan Apr 8, 2024
c7a40ae
Make `projectId` optional
yasincaliskan May 1, 2024
4217f7d
Update README
yasincaliskan May 6, 2024
a1315cc
Remove unused constructor options
yasincaliskan May 6, 2024
fd75955
Reset wallet details from storage if it is v1
yasincaliskan May 9, 2024
7fb29ff
Throw error if WC version mismatch
yasincaliskan May 9, 2024
a8914aa
Error message typo
yasincaliskan May 9, 2024
dcb1dd3
Add migration guide
yasincaliskan May 22, 2024
2c6b056
Fix markdown
yasincaliskan May 22, 2024
fa7f93a
Add WC link in migration guide
yasincaliskan May 22, 2024
2e662b5
Update MIGRATION_GUIDE.md
yigitguler May 22, 2024
c16dc12
Remove duplicated selected addresses
yasincaliskan May 24, 2024
7633f1e
Sort connected accounts on local storage
yasincaliskan May 30, 2024
6ca6ee9
Wait to disconnect the old session if new connect triggered
yasincaliskan May 31, 2024
95fd1ec
Create client instance if not exist in reconnect function
yasincaliskan May 31, 2024
d0c2082
Fix arbitrary data signing and update docs
yasincaliskan Jul 24, 2024
6a9ef4e
Fix README
yasincaliskan Jul 24, 2024
87ca636
Upgrade `algosdk`
yasincaliskan Jul 25, 2024
426a604
Improve error messages
yasincaliskan Jul 25, 2024
83c4a63
Do not disconnect even if the client has a session on `connect`
yasincaliskan Sep 10, 2024
8972e00
Upgrade walletconnect packages
yasincaliskan Sep 16, 2024
87f0987
Check persisted state before signing transaction
yasincaliskan Sep 18, 2024
2ea2253
Setup "session_delete" event listener on creating client
yasincaliskan Sep 20, 2024
cab3c36
Reject signTxn request if topic is not defined
yasincaliskan Sep 23, 2024
08cbfc4
Fix "Launch Web Wallet" action
yasincaliskan Sep 24, 2024
0db1a6b
Upgrade WC package and add session event listener
yasincaliskan Oct 3, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ idea
.vscode
node_modules
dist
build

# misc
.DS_Store
Expand Down
34 changes: 34 additions & 0 deletions MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Migration Guide for Pera Wallet v2

Pera Connect is upgrading to WalletConnect v2. This update introduces some breaking changes. Please follow the steps below to ensure a seamless transition.

### 1. Initializing PeraWalletConnect Instance

In the new version, you must pass a `projectId` when creating an instance of `PeraWalletConnect`. You can obtain your `projectId` from Wallet Connect. For more details, please refer to this [documentation](https://docs.walletconnect.com/cloud/relay).

```js
const peraWallet = new PeraWalletConnect({projectId: <YOUR_PROJECT_ID>});
```


### 2. Updating Event Listeners

The event listener functions have been updated. For example, the event for disconnection has changed from "disconnect" to "session_delete".

##### v1

```js
peraWallet.connector?.on("disconnect", () => {
// handle disconnect
});
```

##### v2

```js
peraWallet.client?.on("session_delete", () => {
// handle session delete
});
```

Please make these changes to ensure your implementation continues to function correctly with the latest version of the SDK. If you have any questions or encounter issues, refer to the detailed documentation or contact support.
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,15 @@ npm install --save @perawallet/connect

```jsx
// Connect handler
const peraWallet = new PeraWalletConnect({
projectId: <YOUR_PROJECT_ID>
});

peraWallet
.connect()
.then((newAccounts) => {
// Setup the disconnect event listener
peraWallet.connector?.on("disconnect", handleDisconnectWalletClick);
peraWallet.client?.on("session_delete", handleDisconnectWalletClick);

setAccountAddress(newAccounts[0]);
})
Expand All @@ -67,7 +71,7 @@ If you don't want the user's account information to be lost by the dApp when the
// On the every page refresh
peraWallet.reconnectSession().then((accounts) => {
// Setup the disconnect event listener
peraWallet.connector?.on("disconnect", handleDisconnectWalletClick);
peraWallet.client?.on("session_delete", handleDisconnectWalletClick);

if (accounts.length) {
setAccountAddress(accounts[0]);
Expand All @@ -90,10 +94,15 @@ try {

| option | default | value | |
| ------------------------ | ------- | ------------------------------------- | -------- |
| `projectId` | | `string` | required |
| `chainId` | `4160` | `416001`, `416002`, `416003` , `4160` | optional |
| `shouldShowSignTxnToast` | `true` | `boolean` | optional |
| `compactMode` | `false` | `boolean` | optional |

#### **`projectId` (required)**

Your project's unique identifier that can be obtained at [Wallet Connect Cloud](https://cloud.walletconnect.com). Learn more on [Wallet Connect Docs](https://docs.walletconnect.com/cloud/relay).

#### **`chainId`**

Determines which Algorand network your dApp uses.
Expand Down Expand Up @@ -138,10 +147,6 @@ Returns the platform of the active session. Possible responses: _`mobile | web |

Checks if there's any active session regardless of platform. Possible responses: _`true | false`_

#### `PeraWalletConnect.signTransaction(txGroups: SignerTransaction[][], signerAddress?: string): Promise<Uint8Array[]>`

Starts the sign process and returns the signed transaction in `Uint8Array`

#### `PeraWalletConnect.signData(data: PeraWalletArbitraryData[], signer: string): Promise<Uint8Array[]>`

Starts the signing process for arbitrary data signing and returns the signed data in `Uint8Array`. Uses `signBytes` method of `algosdk` behind the scenes. `signer` should be a valid Algorand address that exists in the user's wallet.
Expand Down
Loading