Skip to content

Commit f51487b

Browse files
authored
Merge pull request #1934 from ethereum-optimism/kevin/turnkey-config-docs
Improve Actions SDK Config sample code
2 parents bb1f676 + 8ea002e commit f51487b

File tree

2 files changed

+138
-65
lines changed

2 files changed

+138
-65
lines changed

app-developers/guides/configuring-actions.mdx

Lines changed: 118 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -23,62 +23,125 @@ Actions SDK lets you choose which assets, markets, chains, protocols, and provid
2323
Let Actions SDK know which Wallet Provider you've chosen:
2424

2525
<Tabs>
26-
<Tab title="Privy">
27-
```typescript title="actions.ts"
28-
import type { WalletConfig } from "@eth-optimism/actions-sdk";
29-
30-
const walletConfig: WalletConfig = {
31-
hostedWalletConfig: {
32-
provider: {
33-
type: "privy",
34-
},
35-
},
36-
smartWalletConfig: {
37-
provider: {
38-
type: "default",
39-
attributionSuffix: "actions",
40-
},
41-
},
42-
};
43-
```
26+
<Tab title="Frontend">
27+
Select a wallet provider:
28+
29+
<Tabs>
30+
<Tab title="Privy">
31+
```typescript title="actions.ts"
32+
const walletConfig = {
33+
hostedWalletConfig: {
34+
provider: {
35+
type: "privy" as const,
36+
},
37+
},
38+
smartWalletConfig: {
39+
provider: {
40+
type: "default" as const,
41+
attributionSuffix: "actions",
42+
},
43+
},
44+
};
45+
```
46+
</Tab>
47+
<Tab title="Turnkey">
48+
```typescript title="actions.ts"
49+
const walletConfig = {
50+
hostedWalletConfig: {
51+
provider: {
52+
type: "turnkey" as const,
53+
},
54+
},
55+
smartWalletConfig: {
56+
provider: {
57+
type: "default" as const,
58+
attributionSuffix: "actions",
59+
},
60+
},
61+
};
62+
```
63+
</Tab>
64+
<Tab title="Dynamic">
65+
```typescript title="actions.ts"
66+
const walletConfig = {
67+
hostedWalletConfig: {
68+
provider: {
69+
type: "dynamic" as const,
70+
},
71+
},
72+
smartWalletConfig: {
73+
provider: {
74+
type: "default" as const,
75+
attributionSuffix: "actions",
76+
},
77+
},
78+
};
79+
```
80+
</Tab>
81+
</Tabs>
4482
</Tab>
45-
<Tab title="Turnkey">
46-
```typescript title="actions.ts"
47-
import type { WalletConfig } from "@eth-optimism/actions-sdk";
48-
49-
const walletConfig: WalletConfig = {
50-
hostedWalletConfig: {
51-
provider: {
52-
type: "turnkey",
53-
},
54-
},
55-
smartWalletConfig: {
56-
provider: {
57-
type: "default",
58-
attributionSuffix: "actions",
59-
},
60-
},
61-
};
62-
```
63-
</Tab>
64-
<Tab title="Dynamic">
65-
```typescript title="actions.ts"
66-
import type { WalletConfig } from "@eth-optimism/actions-sdk";
67-
68-
const walletConfig: WalletConfig = {
69-
hostedWalletConfig: {
70-
provider: {
71-
type: "dynamic",
72-
},
73-
},
74-
smartWalletConfig: {
75-
provider: {
76-
type: "default",
77-
attributionSuffix: "actions",
78-
},
79-
},
80-
};
81-
```
83+
84+
<Tab title="Backend">
85+
Select a wallet provider:
86+
87+
<Tabs>
88+
<Tab title="Privy">
89+
```typescript title="actions.ts"
90+
import { PrivyClient } from '@privy-io/node'
91+
92+
const privyClient = new PrivyClient(
93+
process.env.PRIVY_APP_ID,
94+
process.env.PRIVY_APP_SECRET,
95+
)
96+
97+
const walletConfig = {
98+
hostedWalletConfig: {
99+
provider: {
100+
type: "privy" as const,
101+
config: {
102+
privyClient,
103+
},
104+
},
105+
},
106+
smartWalletConfig: {
107+
provider: {
108+
type: "default" as const,
109+
attributionSuffix: "actions",
110+
},
111+
},
112+
};
113+
```
114+
</Tab>
115+
<Tab title="Turnkey">
116+
```typescript title="actions.ts"
117+
import { Turnkey } from '@turnkey/sdk-server'
118+
119+
const turnkeyClient = new Turnkey({
120+
apiBaseUrl: 'https://api.turnkey.com',
121+
apiPublicKey: process.env.TURNKEY_API_KEY,
122+
apiPrivateKey: process.env.TURNKEY_API_SECRET,
123+
defaultOrganizationId: process.env.TURNKEY_ORGANIZATION_ID,
124+
})
125+
126+
const walletConfig = {
127+
hostedWalletConfig: {
128+
provider: {
129+
type: "turnkey" as const,
130+
config: {
131+
client: turnkeyClient.apiClient(),
132+
},
133+
},
134+
},
135+
smartWalletConfig: {
136+
provider: {
137+
type: "default" as const,
138+
attributionSuffix: "actions",
139+
},
140+
},
141+
};
142+
```
143+
</Tab>
144+
</Tabs>
82145
</Tab>
83146
</Tabs>
84147

app-developers/quickstarts/actions.mdx

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,13 @@ Actions works with both frontend and backend wallets depending on your needs:
5959

6060
<Tabs>
6161
<Tab title="Privy">
62-
Install and setup [Privy](https://docs.privy.io/basics/react/installation).
62+
**Set Up Privy**
63+
64+
Sign up for Privy and follow the full Privy installation [guide](https://docs.privy.io/basics/react/installation).
6365

6466
**Configure Wallet Provider**
6567

66-
Give your embedded wallets the ability to take Action:
68+
Once you have set up Privy embedded wallets, pass them to Actions SDK:
6769

6870
```typescript
6971
import { actions } from './config'
@@ -108,11 +110,13 @@ Actions works with both frontend and backend wallets depending on your needs:
108110
</Tab>
109111

110112
<Tab title="Turnkey">
111-
Install and setup [Turnkey](https://docs.turnkey.com/sdks/react/getting-started).
113+
**Set Up Turnkey**
114+
115+
Sign up for Turnkey and follow the full Turnkey installation [guide](https://docs.turnkey.com/sdks/react/getting-started).
112116

113117
**Configure Wallet Provider**
114118

115-
Give your embedded wallets the ability to take Action:
119+
Once you have set up Turnkey embedded wallets, pass them to Actions SDK:
116120

117121
```typescript
118122
import { useTurnkey, WalletSource } from "@turnkey/react-wallet-kit"
@@ -177,11 +181,13 @@ Actions works with both frontend and backend wallets depending on your needs:
177181
</Tab>
178182

179183
<Tab title="Dynamic">
180-
Install and setup [Dynamic](https://www.dynamic.xyz/docs/wallets/embedded-wallets/mpc/setup).
184+
**Set Up Dynamic**
185+
186+
Sign up for Dynamic and follow the full Dynamic installation [guide](https://www.dynamic.xyz/docs/wallets/embedded-wallets/mpc/setup).
181187

182188
**Configure Wallet Provider**
183189

184-
Give your embedded wallets the ability to take Action:
190+
Once you have set up Dynamic embedded wallets, pass them to Actions SDK:
185191

186192
```typescript
187193
import { useDynamicContext } from "@dynamic-labs/sdk-react-core"
@@ -234,11 +240,13 @@ Actions works with both frontend and backend wallets depending on your needs:
234240

235241
<Tabs>
236242
<Tab title="Privy">
237-
Install and setup [Privy](https://docs.privy.io/basics/nodeJS/installation).
243+
**Set Up Privy**
244+
245+
Sign up for Privy and follow the full Privy installation [guide](https://docs.privy.io/basics/nodeJS/installation).
238246

239247
**Configure Wallet Provider**
240248

241-
Give your embedded wallets the ability to take Action:
249+
Once you have set up Privy embedded wallets, pass them to Actions SDK:
242250

243251
```typescript
244252
import { actions } from './config'
@@ -290,11 +298,13 @@ Actions works with both frontend and backend wallets depending on your needs:
290298
</Tab>
291299

292300
<Tab title="Turnkey">
293-
Install and setup [Turnkey](https://docs.turnkey.com/sdks/javascript-server).
301+
**Set Up Turnkey**
302+
303+
Sign up for Turnkey and follow the full Turnkey installation [guide](https://docs.turnkey.com/sdks/javascript-server).
294304

295305
**Configure Wallet Provider**
296306

297-
Give your embedded wallets the ability to take Action:
307+
Once you have set up Turnkey embedded wallets, pass them to Actions SDK:
298308

299309
```typescript
300310
import { Turnkey } from '@turnkey/sdk-server'

0 commit comments

Comments
 (0)