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

[Unity] Update docs up to 4.3 #1119

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file modified docs/unity/assets/connectwallet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/unity/assets/connectwalletinspector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/unity/assets/jwt_auth_settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 10 additions & 5 deletions docs/unity/connecting-to-wallets/EmbeddedWallet.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ string address = await sdk.wallet.Connect(connection);

Allows the integration of a custom authentication flow, such as JWT, requiring the configuration of JWKS URI and AUD in the [API key settings](https://thirdweb.com/create-api-key).

Alternatively, allows passing a generic payload that will be authenticated against your backend Auth Endpoint set in the [API key settings](https://thirdweb.com/create-api-key).

You must also pass in an `encryptionKey` that will be used to encrypt the recovery share.

![Custom Auth Settings](../assets/jwt_auth_settings.png)

```csharp
Expand All @@ -66,8 +70,9 @@ var connection = new WalletConnection(
provider: WalletProvider.EmbeddedWallet,
chainId: 1,
authOptions: new AuthOptions(
authProvider: AuthProvider.CustomAuth,
authToken: "your-auth-token-here",
authProvider: AuthProvider.JWT,
jwtOrPayload: "my-jwt-token-or-payload",
encryptionKey: "my-encryption-key",
)
);

Expand All @@ -83,23 +88,23 @@ If using Email OTP flow, displays a modal where you can input your OTP code.

If using OAuth2 flow, opens a popup where you can login with your provider account. If successful, the popup will close and the wallet will connect.

If using Custom JWT flow, attempts to connect directly after verifying the JWT token.
If using Custom Auth flow, attempts to connect directly after verifying the auth token.

### Standalone

If using Email OTP flow, displays a modal where you can input your OTP code.

If using the OAuth2 flow, opens the default browser where you can login with your provider account. Connects after the login flow is complete.

If using Custom JWT flow, attempts to connect directly after verifying the JWT token.
If using Custom Auth flow, attempts to connect directly after verifying the auth token.

### Mobile

If using Email OTP flow, displays a modal where you can input your OTP code.

If using the OAuth2 flow, interacts with native in-app browser/authentication implementations to login with your provider account. Redirects back to the app through a deep link after the login flow is complete. Only available in builds.

If using Custom JWT flow, attempts to connect directly after verifying the JWT token.
If using Custom Auth flow, attempts to connect directly after verifying the auth token.

## Miscellaneous

Expand Down
34 changes: 28 additions & 6 deletions docs/unity/connecting-to-wallets/SmartWallet.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ They also work with any wallet provider as the EOA, but it is recommended to use

You would then be able to login to the exact same persistent EOA and smart wallet address across your apps, and even across different platforms.

You can also create session keys, allowing new signers to interact with the smart wallet without being the admin.
You can also create session keys (revokable), allowing new signers to interact with the smart wallet without being the admin.
You may also add/remove admins.

```csharp
Expand All @@ -61,16 +61,38 @@ using Thirdweb;
// Reference to your Thirdweb SDK
var sdk = ThirdwebManager.Instance.SDK;

// Create a session key to add a temporary signer
var createSessionResult = await sdk.wallet.CreateSessionKey("0xSignerAddress", ...options);
// Create a session key
string signerAddress = "0xSignerAddress";
List<string> approvedTargets = new List<string> { "0xTargetAddress" };
string nativeTokenLimitPerTransactionInWei = "0";
string permissionStartTimestamp = "0";
string permissionEndTimestamp = Utils.GetUnixTimestampIn10Years().ToString();
string reqValidityStartTimestamp = "0";
string reqValidityEndTimestamp = Utils.GetUnixTimestampIn10Years().ToString();

var createSessionResult = await sdk.wallet.CreateSessionKey(
"0xSignerAddress",
approvedTargets,
nativeTokenLimitPerTransactionInWei,
permissionStartTimestamp,
permissionEndTimestamp,
reqValidityStartTimestamp,
reqValidityEndTimestamp
);

// Get a list of current signers with permission details
List<SignerWithPermissions> signers = await sdk.wallet.GetAllActiveSigners();

// Revoke a session key
var revokeSessionResult = await sdk.wallet.RevokeSessionKey("0xSignerAddress");

// Alternatively, you can add an admin
// Add admin
var addAdminResult = await sdk.wallet.AddAdmin("0xSignerAddress");

// Or remove an admin
// Remove admin
var removeAdminResult = await sdk.wallet.RemoveAdmin("0xSignerAddress");

// This pairs well with the `smartWalletAccountOverride` option to connect to a specific smart wallet
// These features pair well with the `smartWalletAccountOverride` option to connect to a specific smart wallet
var connection = new WalletConnection(
...options,
smartWalletAccountOverride: "0xSmartWalletAddress"
Expand Down
17 changes: 6 additions & 11 deletions docs/unity/prefabs/ConnectWallet.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,16 @@ From the `Inspector` window, you can configure the options for the `ConnectWalle
The list of wallets you want to support.
Each wallet you provide appears as a button in the dropdown.

Supports `EmbeddedWallet`, `MetaMask`, `Coinbase`, `WalletConnect`, `MagicLink`, `LocalWallet`, `Paper`, `SmartWallet`, `HyperPlay`, `Injected` (window.ethereum).
Supports `EmbeddedWallet`, `MetaMask`, `Coinbase`, `WalletConnect`, `LocalWallet`, `HyperPlay`, `Injected` (window.ethereum).

Some wallet providers may not be supported on some native platforms.

### Personal Wallet
You can turn any of these wallets into a `SmartWallet` by checking the `Use Smart Wallets` checkbox.

When using Smart Wallets, you can set the EOA Wallet Provider that you'd like to initiate them with. Defaults to `LocalWallet`.
### Use Smart Wallets

### Custom Callbacks
When checked, the wallet provider will be wrapped in a `SmartWallet` which will allow you to use [SmartWallet features](/unity/wallet/SmartWallet).

Custom logic to run whenever an event occurs on the button, including:
### Events

- `OnConnected`: Triggered when the user connects their wallet successfully.
- `OnDisconnected`: Triggered when the user disconnects their wallet successfully.
- `OnSwitchNetwork`: Triggered when the user switches networks successfully.
- `OnFailedConnect`: Triggered when the user fails to connect their wallet.
- `OnFailedDisconnect`: Triggered when an error occurs after attempting to disconnect a wallet.
- `OnFailedSwitchNetwork`: Triggered when an error occurs after attempting to switch networks.
You can set up events to be triggered when the user connects, switches network or disconnects their wallet, from the inspector.