@eth-optimism/actions-sdk 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/dist/actions.test.js +22 -2
  2. package/dist/actions.test.js.map +1 -1
  3. package/dist/constants/assets.d.ts.map +1 -1
  4. package/dist/constants/assets.js +2 -1
  5. package/dist/constants/assets.js.map +1 -1
  6. package/dist/constants/supportedChains.d.ts +1 -1
  7. package/dist/constants/supportedChains.d.ts.map +1 -1
  8. package/dist/constants/supportedChains.js +2 -1
  9. package/dist/constants/supportedChains.js.map +1 -1
  10. package/dist/lend/namespaces/WalletLendNamespace.d.ts +8 -2
  11. package/dist/lend/namespaces/WalletLendNamespace.d.ts.map +1 -1
  12. package/dist/lend/namespaces/WalletLendNamespace.js +8 -2
  13. package/dist/lend/namespaces/WalletLendNamespace.js.map +1 -1
  14. package/dist/lend/providers/morpho/sdk.d.ts.map +1 -1
  15. package/dist/lend/providers/morpho/sdk.js +0 -1
  16. package/dist/lend/providers/morpho/sdk.js.map +1 -1
  17. package/dist/services/ChainManager.d.ts +1 -1
  18. package/dist/test/MockPrivyClient.d.ts +10 -49
  19. package/dist/test/MockPrivyClient.d.ts.map +1 -1
  20. package/dist/test/MockPrivyClient.js +13 -72
  21. package/dist/test/MockPrivyClient.js.map +1 -1
  22. package/dist/wallet/core/namespace/WalletNamespace.d.ts +13 -13
  23. package/dist/wallet/core/namespace/WalletNamespace.d.ts.map +1 -1
  24. package/dist/wallet/core/namespace/WalletNamespace.js +13 -13
  25. package/dist/wallet/core/namespace/WalletNamespace.js.map +1 -1
  26. package/dist/wallet/core/namespace/__tests__/WalletNamespace.spec.js +55 -33
  27. package/dist/wallet/core/namespace/__tests__/WalletNamespace.spec.js.map +1 -1
  28. package/dist/wallet/core/providers/__tests__/WalletProvider.spec.js +43 -15
  29. package/dist/wallet/core/providers/__tests__/WalletProvider.spec.js.map +1 -1
  30. package/dist/wallet/core/providers/hosted/registry/__tests__/HostedWalletProviderRegistry.spec.js +14 -4
  31. package/dist/wallet/core/providers/hosted/registry/__tests__/HostedWalletProviderRegistry.spec.js.map +1 -1
  32. package/dist/wallet/node/providers/hosted/privy/PrivyHostedWalletProvider.d.ts +16 -3
  33. package/dist/wallet/node/providers/hosted/privy/PrivyHostedWalletProvider.d.ts.map +1 -1
  34. package/dist/wallet/node/providers/hosted/privy/PrivyHostedWalletProvider.js +18 -5
  35. package/dist/wallet/node/providers/hosted/privy/PrivyHostedWalletProvider.js.map +1 -1
  36. package/dist/wallet/node/providers/hosted/privy/__tests__/PrivyHostedWalletProvider.spec.js +31 -12
  37. package/dist/wallet/node/providers/hosted/privy/__tests__/PrivyHostedWalletProvider.spec.js.map +1 -1
  38. package/dist/wallet/node/providers/hosted/registry/NodeHostedWalletProviderRegistry.d.ts.map +1 -1
  39. package/dist/wallet/node/providers/hosted/registry/NodeHostedWalletProviderRegistry.js +6 -1
  40. package/dist/wallet/node/providers/hosted/registry/NodeHostedWalletProviderRegistry.js.map +1 -1
  41. package/dist/wallet/node/providers/hosted/registry/__tests__/NodeHostedWalletProviderRegistry.spec.js +9 -1
  42. package/dist/wallet/node/providers/hosted/registry/__tests__/NodeHostedWalletProviderRegistry.spec.js.map +1 -1
  43. package/dist/wallet/node/providers/hosted/types/index.d.ts +6 -1
  44. package/dist/wallet/node/providers/hosted/types/index.d.ts.map +1 -1
  45. package/dist/wallet/node/wallets/hosted/privy/PrivyWallet.d.ts +10 -5
  46. package/dist/wallet/node/wallets/hosted/privy/PrivyWallet.d.ts.map +1 -1
  47. package/dist/wallet/node/wallets/hosted/privy/PrivyWallet.js +11 -6
  48. package/dist/wallet/node/wallets/hosted/privy/PrivyWallet.js.map +1 -1
  49. package/dist/wallet/node/wallets/hosted/privy/__tests__/PrivyWallet.spec.js +26 -28
  50. package/dist/wallet/node/wallets/hosted/privy/__tests__/PrivyWallet.spec.js.map +1 -1
  51. package/dist/wallet/node/wallets/hosted/privy/utils/__tests__/createSigner.spec.js +12 -12
  52. package/dist/wallet/node/wallets/hosted/privy/utils/__tests__/createSigner.spec.js.map +1 -1
  53. package/dist/wallet/node/wallets/hosted/privy/utils/createSigner.d.ts +6 -2
  54. package/dist/wallet/node/wallets/hosted/privy/utils/createSigner.d.ts.map +1 -1
  55. package/dist/wallet/node/wallets/hosted/privy/utils/createSigner.js +10 -7
  56. package/dist/wallet/node/wallets/hosted/privy/utils/createSigner.js.map +1 -1
  57. package/package.json +2 -2
  58. package/src/actions.test.ts +24 -4
  59. package/src/constants/assets.ts +8 -1
  60. package/src/constants/supportedChains.ts +8 -1
  61. package/src/lend/namespaces/WalletLendNamespace.ts +8 -2
  62. package/src/lend/providers/morpho/sdk.ts +0 -1
  63. package/src/test/MockPrivyClient.ts +24 -91
  64. package/src/wallet/core/namespace/WalletNamespace.ts +13 -13
  65. package/src/wallet/core/namespace/__tests__/WalletNamespace.spec.ts +60 -61
  66. package/src/wallet/core/providers/__tests__/WalletProvider.spec.ts +47 -39
  67. package/src/wallet/core/providers/hosted/registry/__tests__/HostedWalletProviderRegistry.spec.ts +20 -7
  68. package/src/wallet/node/providers/hosted/privy/PrivyHostedWalletProvider.ts +27 -9
  69. package/src/wallet/node/providers/hosted/privy/__tests__/PrivyHostedWalletProvider.spec.ts +40 -21
  70. package/src/wallet/node/providers/hosted/registry/NodeHostedWalletProviderRegistry.ts +4 -3
  71. package/src/wallet/node/providers/hosted/registry/__tests__/NodeHostedWalletProviderRegistry.spec.ts +17 -2
  72. package/src/wallet/node/providers/hosted/types/index.ts +9 -2
  73. package/src/wallet/node/wallets/hosted/privy/PrivyWallet.ts +14 -6
  74. package/src/wallet/node/wallets/hosted/privy/__tests__/PrivyWallet.spec.ts +35 -40
  75. package/src/wallet/node/wallets/hosted/privy/utils/__tests__/createSigner.spec.ts +18 -14
  76. package/src/wallet/node/wallets/hosted/privy/utils/createSigner.ts +11 -9
@@ -8,8 +8,12 @@ import type { NodeOptionsMap, PrivyHostedWalletToActionsWalletOptions } from '..
8
8
  * @param params.walletId - Privy wallet identifier
9
9
  * @param params.address - Ethereum address of the wallet
10
10
  * @param params.privyClient - Privy client instance
11
- * @returns Promise resolving to a LocalAccount configured for signing operations
11
+ * @param params.authorizationContext - Optional authorization context for the Privy client.
12
+ * Used when Privy needs to sign requests.
13
+ * See https://docs.privy.io/controls/authorization-keys/using-owners/sign/automatic#using-the-authorization-context
14
+ * for more information on building and using the authorization context.
15
+ * @returns LocalAccount configured for signing operations
12
16
  * @throws Error if wallet retrieval fails or signing operations are not supported
13
17
  */
14
- export declare function createSigner(params: PrivyHostedWalletToActionsWalletOptions & NodeOptionsMap['privy']): Promise<LocalAccount>;
18
+ export declare function createSigner(params: PrivyHostedWalletToActionsWalletOptions & NodeOptionsMap['privy']): LocalAccount;
15
19
  //# sourceMappingURL=createSigner.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createSigner.d.ts","sourceRoot":"","sources":["../../../../../../../src/wallet/node/wallets/hosted/privy/utils/createSigner.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAExC,OAAO,KAAK,EACV,cAAc,EACd,uCAAuC,EACxC,MAAM,+CAA+C,CAAA;AAEtD;;;;;;;;;;GAUG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,uCAAuC,GAAG,cAAc,CAAC,OAAO,CAAC,GACxE,OAAO,CAAC,YAAY,CAAC,CASvB"}
1
+ {"version":3,"file":"createSigner.d.ts","sourceRoot":"","sources":["../../../../../../../src/wallet/node/wallets/hosted/privy/utils/createSigner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAExC,OAAO,KAAK,EACV,cAAc,EACd,uCAAuC,EACxC,MAAM,+CAA+C,CAAA;AAEtD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,uCAAuC,GAAG,cAAc,CAAC,OAAO,CAAC,GACxE,YAAY,CAQd"}
@@ -1,4 +1,4 @@
1
- import { createViemAccount } from '@privy-io/server-auth/viem';
1
+ import { createViemAccount } from '@privy-io/node/viem';
2
2
  /**
3
3
  * Create a LocalAccount from a Privy wallet
4
4
  * @description Converts the Privy wallet into a viem-compatible LocalAccount that can sign
@@ -7,16 +7,19 @@ import { createViemAccount } from '@privy-io/server-auth/viem';
7
7
  * @param params.walletId - Privy wallet identifier
8
8
  * @param params.address - Ethereum address of the wallet
9
9
  * @param params.privyClient - Privy client instance
10
- * @returns Promise resolving to a LocalAccount configured for signing operations
10
+ * @param params.authorizationContext - Optional authorization context for the Privy client.
11
+ * Used when Privy needs to sign requests.
12
+ * See https://docs.privy.io/controls/authorization-keys/using-owners/sign/automatic#using-the-authorization-context
13
+ * for more information on building and using the authorization context.
14
+ * @returns LocalAccount configured for signing operations
11
15
  * @throws Error if wallet retrieval fails or signing operations are not supported
12
16
  */
13
- export async function createSigner(params) {
14
- const { walletId, address, privyClient } = params;
15
- const account = await createViemAccount({
17
+ export function createSigner(params) {
18
+ const { walletId, address, privyClient, authorizationContext } = params;
19
+ const account = createViemAccount(privyClient, {
16
20
  walletId,
17
21
  address,
18
- // TODO: Fix this type error
19
- privy: privyClient,
22
+ authorizationContext,
20
23
  });
21
24
  return account;
22
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"createSigner.js","sourceRoot":"","sources":["../../../../../../../src/wallet/node/wallets/hosted/privy/utils/createSigner.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAQ9D;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAyE;IAEzE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,MAAM,CAAA;IACjD,MAAM,OAAO,GAAG,MAAM,iBAAiB,CAAC;QACtC,QAAQ;QACR,OAAO;QACP,4BAA4B;QAC5B,KAAK,EAAE,WAA0D;KAClE,CAAC,CAAA;IACF,OAAO,OAAO,CAAA;AAChB,CAAC"}
1
+ {"version":3,"file":"createSigner.js","sourceRoot":"","sources":["../../../../../../../src/wallet/node/wallets/hosted/privy/utils/createSigner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAQvD;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,YAAY,CAC1B,MAAyE;IAEzE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,GAAG,MAAM,CAAA;IACvE,MAAM,OAAO,GAAG,iBAAiB,CAAC,WAAW,EAAE;QAC7C,QAAQ;QACR,OAAO;QACP,oBAAoB;KACrB,CAAC,CAAA;IACF,OAAO,OAAO,CAAA;AAChB,CAAC"}
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "url": "https://github.com/ethereum-optimism/actions/issues"
11
11
  },
12
12
  "type": "module",
13
- "version": "0.0.2",
13
+ "version": "0.0.4",
14
14
  "description": "TypeScript SDK for Actions",
15
15
  "main": "dist/index.js",
16
16
  "types": "dist/index.d.ts",
@@ -57,7 +57,7 @@
57
57
  "@dynamic-labs/waas-evm": ">=4.31.4",
58
58
  "@dynamic-labs/wallet-connector-core": ">=4.31.4",
59
59
  "@privy-io/react-auth": ">=2.24.0",
60
- "@privy-io/server-auth": ">=1.31.1",
60
+ "@privy-io/node": ">=0.3.0",
61
61
  "@turnkey/core": ">=1.1.1",
62
62
  "@turnkey/http": ">=3.12.1",
63
63
  "@turnkey/sdk-server": ">=4.9.1",
@@ -3,7 +3,10 @@ import { unichain } from 'viem/chains'
3
3
  import { describe, expect, it } from 'vitest'
4
4
 
5
5
  import { Actions } from '@/actions.js'
6
- import { createMockPrivyClient } from '@/test/MockPrivyClient.js'
6
+ import {
7
+ createMockPrivyClient,
8
+ getMockAuthorizationContext,
9
+ } from '@/test/MockPrivyClient.js'
7
10
  import type { LendMarketConfig, MorphoLendConfig } from '@/types/lend/index.js'
8
11
  import { externalTest } from '@/utils/test.js'
9
12
  import { HostedWalletProviderRegistry } from '@/wallet/core/providers/hosted/registry/HostedWalletProviderRegistry.js'
@@ -36,10 +39,11 @@ describe('Actions SDK', () => {
36
39
  return Boolean((options as NodeOptionsMap['privy'])?.privyClient)
37
40
  },
38
41
  create({ chainManager }, options) {
39
- return new PrivyHostedWalletProvider(
40
- options.privyClient,
42
+ return new PrivyHostedWalletProvider({
43
+ privyClient: options.privyClient,
41
44
  chainManager,
42
- )
45
+ authorizationContext: options.authorizationContext,
46
+ })
43
47
  },
44
48
  })
45
49
  }
@@ -67,6 +71,7 @@ describe('Actions SDK', () => {
67
71
  'test-id',
68
72
  'test-secret',
69
73
  ),
74
+ authorizationContext: getMockAuthorizationContext(),
70
75
  },
71
76
  },
72
77
  },
@@ -107,6 +112,7 @@ describe('Actions SDK', () => {
107
112
  'test-id',
108
113
  'test-secret',
109
114
  ),
115
+ authorizationContext: getMockAuthorizationContext(),
110
116
  },
111
117
  },
112
118
  },
@@ -166,6 +172,7 @@ describe('Actions SDK', () => {
166
172
  'test-id',
167
173
  'test-secret',
168
174
  ),
175
+ authorizationContext: getMockAuthorizationContext(),
169
176
  },
170
177
  },
171
178
  },
@@ -248,6 +255,7 @@ describe('Actions SDK', () => {
248
255
  'test-id',
249
256
  'test-secret',
250
257
  ),
258
+ authorizationContext: getMockAuthorizationContext(),
251
259
  },
252
260
  },
253
261
  },
@@ -291,6 +299,7 @@ describe('Actions SDK', () => {
291
299
  'test-id',
292
300
  'test-secret',
293
301
  ),
302
+ authorizationContext: getMockAuthorizationContext(),
294
303
  },
295
304
  },
296
305
  },
@@ -324,6 +333,7 @@ describe('Actions SDK', () => {
324
333
  'test-id',
325
334
  'test-secret',
326
335
  ),
336
+ authorizationContext: getMockAuthorizationContext(),
327
337
  },
328
338
  },
329
339
  },
@@ -369,6 +379,7 @@ describe('Actions SDK', () => {
369
379
  'test-id',
370
380
  'test-secret',
371
381
  ),
382
+ authorizationContext: getMockAuthorizationContext(),
372
383
  },
373
384
  },
374
385
  },
@@ -408,6 +419,7 @@ describe('Actions SDK', () => {
408
419
  'test-id',
409
420
  'test-secret',
410
421
  ),
422
+ authorizationContext: getMockAuthorizationContext(),
411
423
  },
412
424
  },
413
425
  },
@@ -449,6 +461,7 @@ describe('Actions SDK', () => {
449
461
  'test-id',
450
462
  'test-secret',
451
463
  ),
464
+ authorizationContext: getMockAuthorizationContext(),
452
465
  },
453
466
  },
454
467
  },
@@ -492,6 +505,7 @@ describe('Actions SDK', () => {
492
505
  'test-app-id',
493
506
  'test-app-secret',
494
507
  ),
508
+ authorizationContext: getMockAuthorizationContext(),
495
509
  },
496
510
  },
497
511
  },
@@ -545,6 +559,7 @@ describe('Actions SDK', () => {
545
559
  'test-app-id',
546
560
  'test-app-secret',
547
561
  ),
562
+ authorizationContext: getMockAuthorizationContext(),
548
563
  },
549
564
  },
550
565
  },
@@ -599,6 +614,7 @@ describe('Actions SDK', () => {
599
614
  'test-app-id',
600
615
  'test-app-secret',
601
616
  ),
617
+ authorizationContext: getMockAuthorizationContext(),
602
618
  },
603
619
  },
604
620
  },
@@ -686,6 +702,7 @@ describe('Actions SDK', () => {
686
702
  'test-app-id',
687
703
  'test-app-secret',
688
704
  ),
705
+ authorizationContext: getMockAuthorizationContext(),
689
706
  },
690
707
  },
691
708
  },
@@ -748,6 +765,7 @@ describe('Actions SDK', () => {
748
765
  'test-app-id',
749
766
  'test-app-secret',
750
767
  ),
768
+ authorizationContext: getMockAuthorizationContext(),
751
769
  },
752
770
  },
753
771
  },
@@ -801,6 +819,7 @@ describe('Actions SDK', () => {
801
819
  'test-app-id',
802
820
  'test-app-secret',
803
821
  ),
822
+ authorizationContext: getMockAuthorizationContext(),
804
823
  },
805
824
  },
806
825
  },
@@ -852,6 +871,7 @@ describe('Actions SDK', () => {
852
871
  'test-app-id',
853
872
  'test-app-secret',
854
873
  ),
874
+ authorizationContext: getMockAuthorizationContext(),
855
875
  },
856
876
  },
857
877
  },
@@ -1,5 +1,11 @@
1
1
  import type { Address } from 'viem'
2
- import { base, baseSepolia, mainnet, unichain } from 'viem/chains'
2
+ import {
3
+ base,
4
+ baseSepolia,
5
+ mainnet,
6
+ optimismSepolia,
7
+ unichain,
8
+ } from 'viem/chains'
3
9
 
4
10
  import type { SupportedChainId } from '@/constants/supportedChains.js'
5
11
  import type { Asset } from '@/types/asset.js'
@@ -10,6 +16,7 @@ export const ETH: Asset = {
10
16
  [unichain.id]: '0x0000000000000000000000000000000000000000',
11
17
  [base.id]: '0x0000000000000000000000000000000000000000',
12
18
  [baseSepolia.id]: '0x0000000000000000000000000000000000000000',
19
+ [optimismSepolia.id]: '0x0000000000000000000000000000000000000000',
13
20
  } satisfies Record<SupportedChainId, Address>,
14
21
  metadata: {
15
22
  decimals: 18,
@@ -1,10 +1,17 @@
1
- import { base, baseSepolia, mainnet, unichain } from 'viem/chains'
1
+ import {
2
+ base,
3
+ baseSepolia,
4
+ mainnet,
5
+ optimismSepolia,
6
+ unichain,
7
+ } from 'viem/chains'
2
8
 
3
9
  export const SUPPORTED_CHAIN_IDS = [
4
10
  mainnet.id,
5
11
  unichain.id,
6
12
  base.id,
7
13
  baseSepolia.id,
14
+ optimismSepolia.id,
8
15
  ] as const
9
16
 
10
17
  export type SupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number]
@@ -39,6 +39,10 @@ export class WalletLendNamespace<
39
39
  /**
40
40
  * Open a lending position
41
41
  * @description Signs and sends a lend transaction from the wallet for the given amount and asset
42
+ * @param params - Lending position parameters
43
+ * @param params.marketId - Market identifier to open position in
44
+ * @param params.amount - Amount to lend
45
+ * @returns Promise resolving to transaction receipt
42
46
  */
43
47
  async openPosition(
44
48
  params: LendOpenPositionParams,
@@ -86,8 +90,10 @@ export class WalletLendNamespace<
86
90
 
87
91
  /**
88
92
  * Close a lending position (withdraw from market)
89
- * @param closePositionParams - Position closing parameters
90
- * @returns Promise resolving to transaction hash
93
+ * @param params - Position closing parameters
94
+ * @param params.marketId - Market identifier to close position in
95
+ * @param params.amount - Amount to withdraw
96
+ * @returns Promise resolving to transaction receipt
91
97
  */
92
98
  async closePosition(
93
99
  params: ClosePositionParams,
@@ -178,7 +178,6 @@ export async function getVault(params: GetVaultParams): Promise<LendMarket> {
178
178
 
179
179
  // Morpho sdk doesn't support base sepolia, so we need to use the mock vault
180
180
  if (params.marketId.chainId === 84532) {
181
- console.log('Using mock vault for base sepolia')
182
181
  return createMockVaultData(params.marketId, marketConfig)
183
182
  }
184
183
 
@@ -1,5 +1,6 @@
1
- import type { PrivyClient } from '@privy-io/server-auth'
1
+ import type { AuthorizationContext, PrivyClient } from '@privy-io/node'
2
2
  import type { Address } from 'viem'
3
+ import { generatePrivateKey } from 'viem/accounts'
3
4
 
4
5
  import { getRandomAddress } from '@/test/utils.js'
5
6
 
@@ -8,102 +9,12 @@ import { getRandomAddress } from '@/test/utils.js'
8
9
  * @description Provides a mock implementation of PrivyClient for testing purposes
9
10
  */
10
11
  export class MockPrivyClient {
11
- public walletApi = {
12
- createWallet: async (params: { chainType: string }) => {
13
- const walletId = `mock-wallet-${++this.walletCounter}`
14
- const address = getRandomAddress()
15
-
16
- const wallet = new MockWallet(walletId, address)
17
- this.mockWallets.set(walletId, wallet)
18
-
19
- return {
20
- id: walletId,
21
- address: address,
22
- chainType: params.chainType,
23
- }
24
- },
25
-
26
- getWallet: async (params: { id: string }) => {
27
- const wallet = this.mockWallets.get(params.id)
28
- if (!wallet) {
29
- throw new Error(`Wallet ${params.id} not found`)
30
- }
31
-
32
- return {
33
- id: wallet.id,
34
- address: wallet.address,
35
- chainType: 'ethereum',
36
- }
37
- },
38
-
39
- getWallets: async (params?: { limit?: number; cursor?: string }) => {
40
- const wallets = Array.from(this.mockWallets.values())
41
- const limit = params?.limit || wallets.length
42
-
43
- return {
44
- data: wallets.slice(0, limit).map((wallet) => ({
45
- id: wallet.id,
46
- address: wallet.address,
47
- chainType: 'ethereum',
48
- })),
49
- }
50
- },
51
-
52
- ethereum: {
53
- signMessage: async (params: { walletId: string; message: string }) => {
54
- const wallet = this.mockWallets.get(params.walletId)
55
- if (!wallet) {
56
- throw new Error(`Wallet ${params.walletId} not found`)
57
- }
58
-
59
- // Mock signature - deterministic based on message
60
- const mockSig = `0x${'a'.repeat(128)}${params.message.length.toString(16).padStart(2, '0')}`
61
- return { signature: mockSig }
62
- },
63
-
64
- secp256k1Sign: async (params: { walletId: string; hash: string }) => {
65
- const wallet = this.mockWallets.get(params.walletId)
66
- if (!wallet) {
67
- throw new Error(`Wallet ${params.walletId} not found`)
68
- }
69
-
70
- // Mock signature - deterministic based on hash
71
- const mockSig = `0x${'b'.repeat(128)}${params.hash.slice(-2)}`
72
- return { signature: mockSig }
73
- },
74
-
75
- signTransaction: async (params: {
76
- walletId: string
77
- transaction: unknown
78
- }) => {
79
- const wallet = this.mockWallets.get(params.walletId)
80
- if (!wallet) {
81
- throw new Error(`Wallet ${params.walletId} not found`)
82
- }
83
-
84
- // Mock signed transaction
85
- const mockSignedTx = `0x${'c'.repeat(200)}`
86
- return { signedTransaction: mockSignedTx }
87
- },
88
- },
89
- }
90
-
91
- private mockWallets = new Map<string, MockWallet>()
92
- private walletCounter = 0
93
-
94
12
  constructor(
95
13
  public appId: string,
96
14
  public appSecret: string,
97
15
  ) {}
98
16
  }
99
17
 
100
- class MockWallet {
101
- constructor(
102
- public id: string,
103
- public address: Address,
104
- ) {}
105
- }
106
-
107
18
  /**
108
19
  * Create a mock Privy client cast as PrivyClient type
109
20
  * @param appId - Mock app ID
@@ -116,3 +27,25 @@ export function createMockPrivyClient(
116
27
  ): PrivyClient {
117
28
  return new MockPrivyClient(appId, appSecret) as unknown as PrivyClient
118
29
  }
30
+
31
+ export function createMockPrivyWallet(params?: {
32
+ id?: string
33
+ address?: Address
34
+ }): {
35
+ id: string
36
+ address: Address
37
+ } {
38
+ const { id, address } = params ?? {}
39
+ return {
40
+ id: id ?? 'mock-wallet-1',
41
+ address: address ?? getRandomAddress(),
42
+ }
43
+ }
44
+
45
+ export function getMockAuthorizationContext(
46
+ privateKey?: string,
47
+ ): AuthorizationContext {
48
+ return {
49
+ authorization_private_keys: [privateKey ?? generatePrivateKey()],
50
+ }
51
+ }
@@ -55,19 +55,19 @@ export class WalletNamespace<
55
55
  /**
56
56
  * Create a new smart wallet
57
57
  * @description Creates a smart wallet and attempts to deploy it across all supported chains.
58
- * The wallet address is deterministically calculated from owners and nonce. The signer must
59
- * be included in the owners array. Deployment failures on individual chains do not prevent
58
+ * The wallet address is deterministically calculated from signers and nonce. The signer must
59
+ * be included in the signers array. Deployment failures on individual chains do not prevent
60
60
  * wallet creation - they are reported in the result.
61
61
  * @param params - Smart wallet creation parameters
62
- * @param params.owners - Array of owners for the smart wallet (addresses or WebAuthn public keys)
63
- * @param params.signer - Local account used for signing transactions (must be in owners array)
62
+ * @param params.signer - Primary local account used for signing transactions
63
+ * @param params.signers - Optional array of additional signers for the smart wallet
64
64
  * @param params.nonce - Optional nonce for smart wallet address generation (defaults to 0)
65
65
  * @param params.deploymentChainIds - Optional chain IDs to deploy the wallet to.
66
66
  * If not provided, the wallet will be deployed to all supported chains.
67
67
  * @returns Promise resolving to deployment result containing:
68
68
  * - `wallet`: The created SmartWallet instance
69
69
  * - `deployments`: Array of deployment results with chainId, receipt, success flag, and error
70
- * @throws Error if signer is not included in the owners array
70
+ * @throws Error if signer is not included in the signers array
71
71
  */
72
72
  async createSmartWallet(
73
73
  params: CreateSmartWalletOptions,
@@ -98,7 +98,7 @@ export class WalletNamespace<
98
98
  * @param params.address - Ethereum address of the hosted wallet
99
99
  * @returns Promise resolving to the Actions wallet instance
100
100
  */
101
- async hostedWalletToActionsWallet(
101
+ async toActionsWallet(
102
102
  params: TToActionsMap[THostedProviderType],
103
103
  ): Promise<Wallet> {
104
104
  return this.provider.hostedWalletToActionsWallet(params)
@@ -110,14 +110,14 @@ export class WalletNamespace<
110
110
  * you already have a LocalAccount signer and want to access an existing smart wallet without
111
111
  * going through the hosted wallet provider. Use this instead of getSmartWalletWithHostedSigner
112
112
  * when you have direct control over the signer.
113
- * @param signer - Local account to use for signing transactions on the smart wallet
114
- * @param getWalletParams - Wallet retrieval parameters
115
- * @param getWalletParams.deploymentOwners - Array of original deployment owners for smart wallet address calculation. Required if walletAddress not provided. Must match the exact owners array used during wallet deployment.
116
- * @param getWalletParams.signerOwnerIndex - Current index of the signer in the smart wallet's current owners array (used for transaction signing). Defaults to 0 if not specified. This may differ from the original deployment index if owners have been modified.
117
- * @param getWalletParams.walletAddress - Optional explicit smart wallet address (skips address calculation)
118
- * @param getWalletParams.nonce - Optional nonce used during smart wallet creation
113
+ * @param params - Wallet retrieval parameters
114
+ * @param params.signer - Local account to use for signing transactions on the smart wallet
115
+ * @param params.signers - Optional array of additional signers for the smart wallet
116
+ * @param params.deploymentSigners - Optional array of signers used during wallet deployment
117
+ * @param params.walletAddress - Optional explicit smart wallet address (skips address calculation)
118
+ * @param params.nonce - Optional nonce used during smart wallet creation
119
119
  * @returns Promise resolving to the smart wallet instance with the provided signer
120
- * @throws Error if neither walletAddress nor deploymentOwners provided
120
+ * @throws Error if neither walletAddress nor deploymentSigners provided
121
121
  */
122
122
  async getSmartWallet(params: GetSmartWalletOptions) {
123
123
  return this.provider.getSmartWallet(params)