Skip to content

Commit 1355670

Browse files
Merge 2c97f53 into 3b3d713
2 parents 3b3d713 + 2c97f53 commit 1355670

12 files changed

Lines changed: 302 additions & 65 deletions

File tree

docs.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,8 @@
278278
"sdk/web/wallet-sdk/ecosystem/hooks/useOpenConnectModal",
279279
"sdk/web/wallet-sdk/ecosystem/hooks/useChain",
280280
"sdk/web/wallet-sdk/ecosystem/hooks/useFeeOptions",
281+
"sdk/web/wallet-sdk/ecosystem/hooks/useHasPermission",
282+
"sdk/web/wallet-sdk/ecosystem/hooks/useSendWalletTransaction",
281283
"sdk/web/wallet-sdk/ecosystem/hooks/useExplicitSessions",
282284
"sdk/web/wallet-sdk/ecosystem/hooks/useListAccounts",
283285
"sdk/web/wallet-sdk/ecosystem/hooks/useSignInEmail",
@@ -1288,6 +1290,8 @@
12881290
"ja/sdk/web/wallet-sdk/ecosystem/hooks/useOpenConnectModal",
12891291
"ja/sdk/web/wallet-sdk/ecosystem/hooks/useChain",
12901292
"ja/sdk/web/wallet-sdk/ecosystem/hooks/useFeeOptions",
1293+
"ja/sdk/web/wallet-sdk/ecosystem/hooks/useHasPermission",
1294+
"ja/sdk/web/wallet-sdk/ecosystem/hooks/useSendWalletTransaction",
12911295
"ja/sdk/web/wallet-sdk/ecosystem/hooks/useExplicitSessions",
12921296
"ja/sdk/web/wallet-sdk/ecosystem/hooks/useListAccounts",
12931297
"ja/sdk/web/wallet-sdk/ecosystem/hooks/useSignInEmail",
@@ -2268,6 +2272,8 @@
22682272
"es/sdk/web/wallet-sdk/ecosystem/hooks/useOpenConnectModal",
22692273
"es/sdk/web/wallet-sdk/ecosystem/hooks/useChain",
22702274
"es/sdk/web/wallet-sdk/ecosystem/hooks/useFeeOptions",
2275+
"es/sdk/web/wallet-sdk/ecosystem/hooks/useHasPermission",
2276+
"es/sdk/web/wallet-sdk/ecosystem/hooks/useSendWalletTransaction",
22712277
"es/sdk/web/wallet-sdk/ecosystem/hooks/useExplicitSessions",
22722278
"es/sdk/web/wallet-sdk/ecosystem/hooks/useListAccounts",
22732279
"es/sdk/web/wallet-sdk/ecosystem/hooks/useSignInEmail",

ja/solutions/payments/checkout-sdk.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
title: Checkout SDK(NFT向けカード決済)
3-
description: @0xsequence/checkout を使って、パートナー(例:Transak、Forte)経由でNFT購入時にクレジット/デビットカード決済を追加できます。
2+
title: "Checkout SDK(NFT向けカード決済)"
3+
description: "@0xsequence/checkout を使って、パートナー(例:Transak、Forte)経由でNFT購入時にクレジット/デビットカード決済を追加できます。"
44
sidebarTitle: Checkout SDK
55
---
66

@@ -122,4 +122,4 @@ export function CustomBuy() {
122122
## 参考情報
123123

124124
- [Web SDKチェックアウトガイド](/sdk/web/wallet-sdk/embedded/guides/checkout)
125-
- [Trails概要](/solutions/payments/trails)
125+
- [Trails概要](/solutions/payments/trails)

sdk/web/wallet-sdk/ecosystem/getting-started.mdx

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,39 @@ yarn add @0xsequence/connect@v6-beta wagmi viem
2828

2929
Next, create the Ecosystem Wallet configuration.
3030

31+
**Required for Ecosystem Wallet**
32+
33+
- `projectAccessKey`
34+
- `walletUrl`
35+
36+
**Optional**
37+
38+
- `dappOrigin`
39+
- `signIn.projectName`, `appName`
40+
- `chainIds`, `defaultChainId`
41+
- `explicitSessionParams` (optional; `nativeTokenSpending` defaults to `valueLimit: 0`)
42+
- `includeFeeOptionPermissions`, `enableImplicitSession`
43+
- `nodesUrl`, `relayerUrl`
44+
- `walletConnect`
45+
3146
```typescript [config.ts]
3247
import { createConfig } from "@0xsequence/connect";
3348

3449
export const config: any = createConfig({
3550
projectAccessKey: "AQAAAAAAAABtDHG1It7lxRF_9bbxw4diip8",
36-
signIn: {
37-
projectName: 'Sequence Web SDK Demo',
38-
},
3951
walletUrl: 'https://next-acme-wallet.sequence-dev.app',
52+
// Optional
4053
dappOrigin: window.location.origin,
54+
signIn: {
55+
projectName: 'Sequence Web SDK Demo'
56+
},
4157
appName: 'Sequence Web SDK Demo',
4258
chainIds: [42161],
4359
defaultChainId: 42161,
4460
google: true,
4561
apple: true,
4662
email: true,
47-
explicitSessionParams: {...}
63+
explicitSessionParams: { ... }
4864
});
4965
```
5066

@@ -55,6 +71,8 @@ The `dappOrigin` is the origin of your dapp, used to verify where the user is co
5571
The `explicitSessionParams` object allows your dapp to request specific permissions from the user upon connection.
5672
These permissions can authorize your dapp to perform certain actions on the user's behalf for a defined period, creating a more seamless user experience with no transaction prompts or allowing automations.
5773

74+
`nativeTokenSpending` is optional. If omitted, the session will default to a native token `valueLimit` of `0`.
75+
5876
For example, let's create an explicit session that allows your dapp to `deposit 100 USDC into the AAVE V3 pool on Arbitrum, on behalf of the user for the next 24 hours`
5977

6078
```typescript [config.ts]
@@ -66,11 +84,12 @@ export const AAVE_V3_POOL_ADDRESS_ARBITRUM = '0x794a61358D6845594F94dc1DB02A252b
6684

6785
export const config: any = createConfig({
6886
projectAccessKey: "AQAAAAAAAABtDHG1It7lxRF_9bbxw4diip8",
87+
walletUrl: 'https://next-acme-wallet.sequence-dev.app',
88+
// Optional
89+
dappOrigin: window.location.origin,
6990
signIn: {
7091
projectName: 'Sequence Web SDK Demo',
7192
},
72-
walletUrl: 'https://next-acme-wallet.sequence-dev.app',
73-
dappOrigin: window.location.origin,
7493
appName: 'Sequence Web SDK Demo',
7594
chainIds: [42161],
7695
defaultChainId: 42161,
@@ -200,6 +219,21 @@ yarn add @0xsequence/connect@v6-beta wagmi viem
200219

201220
Next, create the Ecosystem Wallet configuration.
202221

222+
**Required for Ecosystem Wallet**
223+
224+
- `projectAccessKey`
225+
- `walletUrl`
226+
227+
**Optional**
228+
229+
- `dappOrigin`
230+
- `signIn.projectName`, `appName`
231+
- `chainIds`, `defaultChainId`
232+
- `explicitSessionParams` (optional; `nativeTokenSpending` defaults to `valueLimit: 0`)
233+
- `includeFeeOptionPermissions`, `enableImplicitSession`
234+
- `nodesUrl`, `relayerUrl`
235+
- `walletConnect`
236+
203237
```typescript [config.ts]
204238
import { createConfig } from "@0xsequence/connect";
205239

@@ -227,6 +261,8 @@ The `dappOrigin` is the origin of your dapp, used to verify where the user is co
227261
The `explicitSessionParams` object allows your dapp to request specific permissions from the user upon connection.
228262
These permissions can authorize your dapp to perform certain actions on the user's behalf for a defined period, creating a more seamless user experience with no transaction prompts.
229263

264+
`nativeTokenSpending` is optional. If omitted, the session will default to a native token `valueLimit` of `0`.
265+
230266
For example, let's create an explicit session that allows your dapp to `deposit 100 USDC into the AAVE V3 pool on Arbitrum, on behalf of the user for the next 24 hours`
231267

232268
```typescript [config.ts]
@@ -390,5 +426,3 @@ The user will be prompted to approve the permissions when connecting.
390426
</Steps>
391427
</Tab>
392428
</Tabs>
393-
394-

sdk/web/wallet-sdk/ecosystem/hooks/useExplicitSessions.mdx

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { useExplicitSessions } from '@0xsequence/connect'
1313
## Usage
1414

1515
```tsx
16-
import { createContractPermission, createExplicitSession, useExplicitSessions, type Permission, type Session } from '@0xsequence/connect'
16+
import { createContractPermission, useExplicitSessions, type ExplicitSessionParams, type ExplicitSession } from '@0xsequence/connect'
1717
import { useEffect, useState } from 'react'
1818
import { parseUnits } from 'viem'
1919

@@ -22,10 +22,11 @@ function App() {
2222
isLoading,
2323
error,
2424
addExplicitSession,
25+
modifyExplicitSession,
2526
getExplicitSessions
2627
} = useExplicitSessions()
2728

28-
const [sessions, setSessions] = useState<Session[]>([])
29+
const [sessions, setSessions] = useState<ExplicitSession[]>([])
2930

3031
// Load existing sessions
3132
useEffect(() => {
@@ -47,15 +48,15 @@ function App() {
4748
address: '0x...',
4849
functionSignature: 'function testContract() public'
4950
})
50-
const currentSession = sessions[0];
51+
const currentSession = sessions[0]
5152
const modifiedSession = { ...currentSession, permissions: [...currentSession.permissions!, newPermission] }
5253
modifyExplicitSession(modifiedSession)
5354
}
5455

5556
// Handle creating a new explicit session
5657
const handleCreateSession = async () => {
5758
try {
58-
const tokenSpendingSession = createExplicitSession({
59+
const tokenSpendingSession: ExplicitSessionParams = {
5960
chainId: 42161,
6061
nativeTokenSpending: {
6162
valueLimit: 0n,
@@ -78,9 +79,9 @@ function App() {
7879
]
7980
})
8081
]
81-
})
82+
}
8283

83-
await addExplicitSession(42161, tokenSpendingSession)
84+
await addExplicitSession(tokenSpendingSession)
8485

8586
// Refresh sessions after creating a new one
8687
const updatedSessions = await getExplicitSessions()
@@ -113,10 +114,9 @@ function App() {
113114
<h3>Existing Sessions ({sessions.length})</h3>
114115
{sessions.map((session, index) => (
115116
<div key={index}>
116-
<p>Session Address: {session.address}</p>
117+
<p>Session Address: {session.sessionAddress}</p>
117118
<p>Chain ID: {session.chainId}</p>
118-
<p>Is Implicit: {session.isImplicit ? 'Yes' : 'No'}</p>
119-
<p>Permissions: {session.permissions?.permissions?.map((permission: Permission) => permission.target).join(', ')}</p>
119+
<p>Permissions: {session.permissions?.map(permission => permission.target).join(', ')}</p>
120120
</div>
121121
))}
122122
</div>
@@ -133,8 +133,9 @@ The hook returns an object with the following properties:
133133
type UseExplicitSessionsReturnType = {
134134
isLoading: boolean
135135
error: Error | null
136-
addExplicitSession: (chainId: ChainId, explicitSession: ExplicitSession) => Promise<void>
137-
getExplicitSessions: () => Promise<Session[]>
136+
addExplicitSession: (params: ExplicitSessionParams, includeFeeOptionPermissions?: boolean) => Promise<void>
137+
modifyExplicitSession: (explicitSession: ExplicitSession) => Promise<void>
138+
getExplicitSessions: () => Promise<ExplicitSession[]>
138139
}
139140
```
140141
@@ -154,7 +155,7 @@ An error object if the last operation failed, otherwise `null`.
154155
155156
#### addExplicitSession
156157
157-
`(chainId: ChainId, explicitSession: ExplicitSession) => Promise<void>`
158+
`(params: ExplicitSessionParams, includeFeeOptionPermissions?: boolean) => Promise<void>`
158159
159160
```typescript
160161
type ExplicitSession = {
@@ -188,20 +189,9 @@ Function to modify an existing explicit session.
188189
189190
#### getExplicitSessions
190191
191-
`() => Promise<Session[]>`
192-
193-
```typescript
194-
type Session = {
195-
type: 'explicit' | 'implicit'
196-
sessionAddress: Address.Address
197-
valueLimit?: bigint
198-
deadline?: bigint
199-
permissions?: Permission.Permission[]
200-
chainId?: number
201-
}
202-
```
192+
`() => Promise<ExplicitSession[]>`
203193
204-
Function to get all sessions for the connected wallet.
194+
Function to get all explicit sessions for the connected wallet.
205195
206196
## Notes
207197

sdk/web/wallet-sdk/ecosystem/hooks/useFeeOptions.mdx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ sidebarTitle: useFeeOptions
88

99
```tsx
1010
import { useFeeOptions } from '@0xsequence/connect'
11+
import { zeroAddress } from 'viem'
1112
```
1213

1314
## Usage
@@ -69,8 +70,8 @@ function App() {
6970
<input
7071
type="radio"
7172
name="feeOption"
72-
checked={selectedFeeOptionTokenAddress === (option.token.contractAddress || '')}
73-
onChange={() => setSelectedFeeOptionTokenAddress(option.token.contractAddress || '')}
73+
checked={selectedFeeOptionTokenAddress === (option.token.contractAddress || zeroAddress)}
74+
onChange={() => setSelectedFeeOptionTokenAddress(option.token.contractAddress || zeroAddress)}
7475
/>
7576
<label>
7677
{option.token.symbol} - {option.token.contractAddress || 'Native Token'}
@@ -85,7 +86,7 @@ function App() {
8586
</div>
8687
<div>
8788
<button
88-
onClick={() => handleConfirmFee(selectedFeeOptionTokenAddress || '')}
89+
onClick={() => handleConfirmFee(selectedFeeOptionTokenAddress || zeroAddress)}
8990
disabled={!selectedFeeOptionTokenAddress}
9091
>
9192
Confirm
@@ -161,7 +162,7 @@ Function to confirm the selected fee option.
161162
| Parameter | Type | Description |
162163
| --------- | ---- | ----------- |
163164
| `id` | `string` | The fee confirmation ID |
164-
| `feeTokenAddress` | `string` | The address of the token to use for fee payment (use empty string for native token) |
165+
| `feeTokenAddress` | `string` | The address of the token to use for fee payment (use `zeroAddress` for native token) |
165166
166167
#### rejectPendingFeeOption
167168
@@ -186,4 +187,4 @@ Key features:
186187
187188
The hook integrates with the Sequence V3 connector to intercept fee confirmation requests and presents a user interface to allow selection of the fee token. It uses shared state management to ensure consistent behavior across multiple instances of the hook.
188189
189-
For a detailed guide on how to use the hook, see the [Pay gas in ERC20](/sdk/web/wallet-sdk/embedded/guides/pay-gas-in-erc20) guide.
190+
For a detailed guide on how to use the hook, see the [Pay gas in ERC20](/sdk/web/wallet-sdk/embedded/guides/pay-gas-in-erc20) guide.
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
title: "useHasPermission"
3+
description: Hook to check whether the current Sequence V3 session can execute a set of transactions
4+
sidebarTitle: useHasPermission
5+
---
6+
7+
## Import
8+
9+
```tsx
10+
import { useHasPermission } from '@0xsequence/connect'
11+
```
12+
13+
## Usage
14+
15+
```tsx
16+
import { useHasPermission } from '@0xsequence/connect'
17+
import { encodeFunctionData, type TransactionRequest } from 'viem'
18+
19+
function App() {
20+
const { checkPermission, isLoading, error, data } = useHasPermission()
21+
22+
const check = async () => {
23+
const txs: TransactionRequest[] = [
24+
{
25+
to: '0x0000000000000000000000000000000000000000',
26+
data: encodeFunctionData({
27+
abi: [
28+
{
29+
type: 'function',
30+
name: 'foo',
31+
stateMutability: 'nonpayable',
32+
inputs: [],
33+
outputs: []
34+
}
35+
],
36+
functionName: 'foo'
37+
})
38+
}
39+
]
40+
41+
const allowed = await checkPermission({ chainId: 42161, transactions: txs })
42+
console.log('Allowed:', allowed)
43+
}
44+
45+
return (
46+
<div>
47+
<button onClick={check}>Check permission</button>
48+
{isLoading && <div>Checking...</div>}
49+
{error && <div>Error: {error.message}</div>}
50+
{data !== undefined && <div>Allowed: {data ? 'Yes' : 'No'}</div>}
51+
</div>
52+
)
53+
}
54+
```
55+
56+
## Parameters
57+
58+
```tsx
59+
type HasPermissionParams = {
60+
chainId: number
61+
transactions: TransactionRequest[]
62+
}
63+
```
64+
65+
## Return Type
66+
67+
```tsx
68+
type UseHasPermissionReturnType = {
69+
isLoading: boolean
70+
error: Error | null
71+
data: boolean | undefined
72+
checkPermission: (params: HasPermissionParams) => Promise<boolean>
73+
}
74+
```
75+
76+
## Notes
77+
78+
- This hook uses the Sequence V3 connector internally.
79+
- Each transaction must include a `to` address.

0 commit comments

Comments
 (0)