Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Commit

Permalink
Upgrade Verida SDK + update doc about some changes (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-verida authored Apr 17, 2024
2 parents 973642d + 681cafc commit 26dffa1
Show file tree
Hide file tree
Showing 7 changed files with 193 additions and 558 deletions.
22 changes: 4 additions & 18 deletions docs/single-sign-on-sdk/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,21 @@ import { Network } from '@verida/client-ts';
import { EnvironmentType } from '@verida/types';
import { VaultAccount } from '@verida/account-web-vault';

// (optional) Import WalletConnect if required
import WalletConnect from "@walletconnect/client";

const VERIDA_ENVIRONMENT = EnvironmentType.TESTNET;
const CONTEXT_NAME = 'My Application: Context Name';

// (optional) WalletConnect configuration
// See the WalletConnect section of the documentation for details
const DEFAULT_CHAIN_ID = "eip155:1"
connector = new WalletConnect({
bridge: 'https://bridge.walletconnect.org',
});

// Logo for your application
// The LOGO_URL should be a 170x170 PNG file
// Logo for your application, should be a 170x170 PNG file
const LOGO_URL = "https://assets.verida.io/verida_login_request_logo_170x170.png";

const account = new VaultAccount({
request: {
logoUrl: LOGO_URL,
// An optional URL that will open a browser on the user's mobile device
// openURL: An optional URL that will open a browser on the user's mobile device
// after accepting the login request in the Verida Wallet mobile app
openURL: window.location.href,
},
walletConnect: {
version: connector.version,
uri: connector.uri,
chainId: DEFAULT_CHAIN_ID,
},
// environment: Indicates to the Wallet which network the identity should be on.
environment: VERIDA_ENVIRONMENT,
});

const context = await Network.connect({
Expand Down
3 changes: 2 additions & 1 deletion docs/single-sign-on-sdk/web-user.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export const user = new WebUser({
accountConfig: {
request: {
logoUrl: LOGO_URL
}
},
environment: VERIDA_ENVIRONMENT
},
clientConfig: {
environment: VERIDA_ENVIRONMENT
Expand Down
11 changes: 6 additions & 5 deletions docs/tutorial/SSO.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ keywords: [Verida, Web3, Developers, Tutorial, Verida Connect, Wallet connect]

import ReactPlayer from 'react-player';

# Sign-in with Verida Connect SDK
# Sign-in with Verida Connect SDK

## See a walk through of the code

Expand Down Expand Up @@ -55,12 +55,13 @@ VeridaLoginExample = () => {
const account = new VaultAccount({
request: {
logoUrl: 'https://developers.verida.io/img/tutorial_login_request_logo_170x170.png',
},
},
environment: EnvironmentType.MAINNET,
});

const context = await Network.connect({
client: {
environment: 'testnet'
environment: EnvironmentType.MAINNET,
},
account: account,
context: {
Expand All @@ -71,7 +72,7 @@ VeridaLoginExample = () => {
if (context) {
// set the local state variable
setVeridaContext(context);
}
}
};

logout = async function () {
Expand All @@ -96,7 +97,7 @@ VeridaLoginExample = () => {
<button onClick={this.logout}>Logout</button>
</div>
);
} else {
} else {
return (
<div>
<button onClick={this.login}>Login</button>
Expand Down
11 changes: 6 additions & 5 deletions docs/tutorial/walletconnect_verida.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ how to use the live code :
:::caution

You may get an error that display : "Session is disconnected" this means you're currently logged in without a WalletConnect session.
Steps to fix this error
Steps to fix this error
- Please ensure the Verida Wallet is updated to the latest version
- Login again to establish a WalletConnect session

Expand Down Expand Up @@ -90,14 +90,15 @@ VeridaLoginExample = () => {
const account = new VaultAccount({
request: {
logoUrl: 'https://developers.verida.io/img/tutorial_login_request_logo_170x170.png',
// Pass the WalletConnect details required for the connection.
// Pass the WalletConnect details required for the connection.
// Please not that the wallet connect object is optional.
walletConnect: {
version: connector.version,
uri: connector.uri,
chainId: CHAIN_ID
}
},
environment: 'testnet'
});
const context = await Network.connect({
client: {
Expand Down Expand Up @@ -141,7 +142,7 @@ VeridaLoginExample = () => {
message,
address
];
// Learn more about WalletConnect personal_sign here
// Learn more about WalletConnect personal_sign here
// https://docs.walletconnect.com/1.0/quick-start/dapps/client#sign-personal-message-personal_sign
const result = await walletConnector.signPersonalMessage(msgParams);
if(result) {
Expand Down Expand Up @@ -192,8 +193,8 @@ VeridaLoginExample = () => {
}
<button onClick={this.logout} style={styles}>Logout</button>
{
walletConnector
&& (processingWc ? 'Processing....' :
walletConnector
&& (processingWc ? 'Processing....' :
<button onClick={this.signInPersonalMessage}>
Sign Personal Message
</button>
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
"@docusaurus/theme-search-algolia": "^2.4.3",
"@mdx-js/react": "^1.6.21",
"@svgr/webpack": "^5.5.0",
"@verida/account-web-vault": "^2.3.9",
"@verida/client-ts": "^2.3.9",
"@verida/types": "^2.3.1",
"@verida/verifiable-credentials": "^2.3.9",
"@verida/account-web-vault": "^3.0.2",
"@verida/client-ts": "^3.0.3",
"@verida/types": "^3.0.1",
"@verida/verifiable-credentials": "^3.0.3",
"@walletconnect/client": "^1.8.0",
"clsx": "^1.1.1",
"crypto-browserify": "^3.12.0",
Expand Down
7 changes: 5 additions & 2 deletions src/theme/ReactLiveScope/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import ExecutionEnvironment from "@docusaurus/ExecutionEnvironment";
import { EnvironmentType } from "@verida/types";
import React, { useEffect, useState } from "react";
import { store, useGlobalState } from "state-pool";

Expand Down Expand Up @@ -84,11 +85,12 @@ if (ExecutionEnvironment.canUseDOM) {
"https://developers.verida.io/img/tutorial_login_request_logo_170x170.png",
walletConnect,
},
environment: EnvironmentType.MAINNET,
});

const context = await Network.connect({
client: {
environment: "testnet",
environment: EnvironmentType.MAINNET,
},
account: globalAccount,
context: {
Expand All @@ -114,7 +116,8 @@ const ReactLiveScope = {
WalletConnect,
globalAccount,
globalLoginFunction,
getCircularReplacer
getCircularReplacer,
EnvironmentType
};

export default ReactLiveScope;
Loading

0 comments on commit 26dffa1

Please sign in to comment.