@zerodev/wallet-core 0.0.1-alpha.13 → 0.0.1-alpha.15

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 (106) hide show
  1. package/dist/_cjs/actions/auth/authenticateWithOAuth.js +2 -3
  2. package/dist/_cjs/actions/auth/authenticateWithOAuth.js.map +1 -1
  3. package/dist/_cjs/actions/auth/getWhoami.js +18 -4
  4. package/dist/_cjs/actions/auth/getWhoami.js.map +1 -1
  5. package/dist/_cjs/actions/index.js +5 -2
  6. package/dist/_cjs/actions/index.js.map +1 -1
  7. package/dist/_cjs/actions/wallet/index.js +9 -3
  8. package/dist/_cjs/actions/wallet/index.js.map +1 -1
  9. package/dist/_cjs/actions/wallet/sign7702Authorization.js +16 -0
  10. package/dist/_cjs/actions/wallet/sign7702Authorization.js.map +1 -0
  11. package/dist/_cjs/actions/wallet/signMessage.js +17 -0
  12. package/dist/_cjs/actions/wallet/signMessage.js.map +1 -0
  13. package/dist/_cjs/actions/wallet/signTransaction.js +9 -18
  14. package/dist/_cjs/actions/wallet/signTransaction.js.map +1 -1
  15. package/dist/_cjs/actions/wallet/signTypedDataV4.js +17 -0
  16. package/dist/_cjs/actions/wallet/signTypedDataV4.js.map +1 -0
  17. package/dist/_cjs/actions/wallet/signUserOperation.js +17 -0
  18. package/dist/_cjs/actions/wallet/signUserOperation.js.map +1 -0
  19. package/dist/_cjs/actions/wallet/signingUtils.js +64 -0
  20. package/dist/_cjs/actions/wallet/signingUtils.js.map +1 -0
  21. package/dist/_cjs/adapters/viem.js +57 -24
  22. package/dist/_cjs/adapters/viem.js.map +1 -1
  23. package/dist/_cjs/client/decorators/client.js +5 -3
  24. package/dist/_cjs/client/decorators/client.js.map +1 -1
  25. package/dist/_cjs/core/createZeroDevWallet.js +1 -0
  26. package/dist/_cjs/core/createZeroDevWallet.js.map +1 -1
  27. package/dist/_cjs/index.js +5 -2
  28. package/dist/_cjs/index.js.map +1 -1
  29. package/dist/_esm/actions/auth/authenticateWithOAuth.js +7 -7
  30. package/dist/_esm/actions/auth/authenticateWithOAuth.js.map +1 -1
  31. package/dist/_esm/actions/auth/getWhoami.js +28 -6
  32. package/dist/_esm/actions/auth/getWhoami.js.map +1 -1
  33. package/dist/_esm/actions/index.js +1 -1
  34. package/dist/_esm/actions/index.js.map +1 -1
  35. package/dist/_esm/actions/wallet/index.js +4 -1
  36. package/dist/_esm/actions/wallet/index.js.map +1 -1
  37. package/dist/_esm/actions/wallet/sign7702Authorization.js +13 -0
  38. package/dist/_esm/actions/wallet/sign7702Authorization.js.map +1 -0
  39. package/dist/_esm/actions/wallet/signMessage.js +14 -0
  40. package/dist/_esm/actions/wallet/signMessage.js.map +1 -0
  41. package/dist/_esm/actions/wallet/signTransaction.js +9 -36
  42. package/dist/_esm/actions/wallet/signTransaction.js.map +1 -1
  43. package/dist/_esm/actions/wallet/signTypedDataV4.js +14 -0
  44. package/dist/_esm/actions/wallet/signTypedDataV4.js.map +1 -0
  45. package/dist/_esm/actions/wallet/signUserOperation.js +14 -0
  46. package/dist/_esm/actions/wallet/signUserOperation.js.map +1 -0
  47. package/dist/_esm/actions/wallet/signingUtils.js +69 -0
  48. package/dist/_esm/actions/wallet/signingUtils.js.map +1 -0
  49. package/dist/_esm/adapters/viem.js +60 -27
  50. package/dist/_esm/adapters/viem.js.map +1 -1
  51. package/dist/_esm/client/decorators/client.js +5 -3
  52. package/dist/_esm/client/decorators/client.js.map +1 -1
  53. package/dist/_esm/core/createZeroDevWallet.js +1 -2
  54. package/dist/_esm/core/createZeroDevWallet.js.map +1 -1
  55. package/dist/_esm/index.js +1 -1
  56. package/dist/_esm/index.js.map +1 -1
  57. package/dist/_types/actions/auth/authenticateWithOAuth.d.ts +7 -4
  58. package/dist/_types/actions/auth/authenticateWithOAuth.d.ts.map +1 -1
  59. package/dist/_types/actions/auth/getWhoami.d.ts +9 -2
  60. package/dist/_types/actions/auth/getWhoami.d.ts.map +1 -1
  61. package/dist/_types/actions/index.d.ts +1 -1
  62. package/dist/_types/actions/index.d.ts.map +1 -1
  63. package/dist/_types/actions/wallet/index.d.ts +4 -1
  64. package/dist/_types/actions/wallet/index.d.ts.map +1 -1
  65. package/dist/_types/actions/wallet/sign7702Authorization.d.ts +19 -0
  66. package/dist/_types/actions/wallet/sign7702Authorization.d.ts.map +1 -0
  67. package/dist/_types/actions/wallet/signMessage.d.ts +19 -0
  68. package/dist/_types/actions/wallet/signMessage.d.ts.map +1 -0
  69. package/dist/_types/actions/wallet/signTransaction.d.ts +1 -19
  70. package/dist/_types/actions/wallet/signTransaction.d.ts.map +1 -1
  71. package/dist/_types/actions/wallet/signTypedDataV4.d.ts +21 -0
  72. package/dist/_types/actions/wallet/signTypedDataV4.d.ts.map +1 -0
  73. package/dist/_types/actions/wallet/signUserOperation.d.ts +21 -0
  74. package/dist/_types/actions/wallet/signUserOperation.d.ts.map +1 -0
  75. package/dist/_types/actions/wallet/signingUtils.d.ts +32 -0
  76. package/dist/_types/actions/wallet/signingUtils.d.ts.map +1 -0
  77. package/dist/_types/adapters/viem.d.ts.map +1 -1
  78. package/dist/_types/client/decorators/client.d.ts +15 -4
  79. package/dist/_types/client/decorators/client.d.ts.map +1 -1
  80. package/dist/_types/core/createZeroDevWallet.d.ts +1 -0
  81. package/dist/_types/core/createZeroDevWallet.d.ts.map +1 -1
  82. package/dist/_types/index.d.ts +2 -2
  83. package/dist/_types/index.d.ts.map +1 -1
  84. package/dist/tsconfig.build.tsbuildinfo +1 -1
  85. package/package.json +1 -1
  86. package/src/actions/auth/authenticateWithOAuth.ts +9 -7
  87. package/src/actions/auth/getWhoami.ts +33 -6
  88. package/src/actions/index.ts +12 -3
  89. package/src/actions/wallet/index.ts +22 -4
  90. package/src/actions/wallet/sign7702Authorization.ts +48 -0
  91. package/src/actions/wallet/signMessage.ts +47 -0
  92. package/src/actions/wallet/signTransaction.ts +19 -38
  93. package/src/actions/wallet/signTypedDataV4.ts +52 -0
  94. package/src/actions/wallet/signUserOperation.ts +56 -0
  95. package/src/actions/wallet/signingUtils.ts +110 -0
  96. package/src/adapters/viem.ts +71 -39
  97. package/src/client/decorators/client.ts +40 -11
  98. package/src/core/createZeroDevWallet.ts +2 -2
  99. package/src/index.ts +12 -3
  100. package/dist/_cjs/actions/wallet/signRawPayload.js +0 -27
  101. package/dist/_cjs/actions/wallet/signRawPayload.js.map +0 -1
  102. package/dist/_esm/actions/wallet/signRawPayload.js +0 -42
  103. package/dist/_esm/actions/wallet/signRawPayload.js.map +0 -1
  104. package/dist/_types/actions/wallet/signRawPayload.d.ts +0 -39
  105. package/dist/_types/actions/wallet/signRawPayload.d.ts.map +0 -1
  106. package/src/actions/wallet/signRawPayload.ts +0 -75
@@ -1,14 +1,18 @@
1
1
  import {
2
+ bytesToHex,
3
+ concat,
4
+ getTypesForEIP712Domain,
2
5
  type Hex,
3
- hashMessage,
6
+ hashTypedData,
4
7
  type LocalAccount,
8
+ numberToHex,
5
9
  parseSignature,
6
- parseTransaction,
7
10
  type SerializeTransactionFn,
8
11
  type SignableMessage,
9
12
  serializeTransaction,
10
13
  serializeTypedData,
11
14
  type TransactionSerializable,
15
+ toRlp,
12
16
  zeroAddress,
13
17
  } from 'viem'
14
18
  import type {
@@ -17,7 +21,6 @@ import type {
17
21
  } from 'viem/accounts'
18
22
  import { toAccount } from 'viem/accounts'
19
23
  import { hashAuthorization } from 'viem/utils'
20
- import type { signRawPayload } from '../actions/index.js'
21
24
  import type { ZeroDevWalletClient } from '../client/index.js'
22
25
 
23
26
  export interface ToViemAccountParams {
@@ -44,21 +47,6 @@ export async function toViemAccount(
44
47
  } catch {
45
48
  address = zeroAddress
46
49
  }
47
- const signRawPayloadInternal = async (
48
- payload: string,
49
- encoding: Parameters<
50
- typeof signRawPayload
51
- >[1]['encoding'] = 'PAYLOAD_ENCODING_HEXADECIMAL',
52
- ) => {
53
- return await client.signRawPayload({
54
- organizationId,
55
- projectId,
56
- token: await getToken(),
57
- address,
58
- payload,
59
- encoding,
60
- })
61
- }
62
50
 
63
51
  // Modified from: https://github.com/tkhq/sdk/blob/4e439bf2973ea13b51d981d7c24a4841d4e5fd5f/packages/viem/src/index.ts#L419-L461
64
52
  const signTransactionInternal = async <
@@ -84,27 +72,37 @@ export async function toViemAccount(
84
72
  unsignedTransaction: nonHexPrefixedSerializedTx,
85
73
  })
86
74
 
87
- if (transaction.type === 'eip4844') {
88
- // Grab components of the signature
89
- const { r, s, v } = parseTransaction(signature)
90
-
91
- // Recombine with the original transaction
92
- return serializeTransaction(transaction, {
93
- r: r!,
94
- s: s!,
95
- v: v!,
96
- })
97
- }
98
-
99
- return signature
75
+ const { r, s, v, yParity } = parseSignature(signature)
76
+ return serializeTransaction(transaction, { r, s, v, yParity })
100
77
  }
101
78
 
102
79
  return toAccount({
103
80
  address,
104
81
 
105
82
  async signMessage({ message }: { message: SignableMessage }): Promise<Hex> {
106
- const hashedMessage = hashMessage(message)
107
- return signRawPayloadInternal(hashedMessage)
83
+ if (typeof message === 'string') {
84
+ return client.signMessage({
85
+ organizationId,
86
+ projectId,
87
+ token: await getToken(),
88
+ address,
89
+ message,
90
+ encoding: 'utf8',
91
+ })
92
+ }
93
+ // Raw message (Hex or ByteArray)
94
+ const raw =
95
+ typeof message.raw === 'string'
96
+ ? message.raw.replace(/^0x/, '')
97
+ : bytesToHex(message.raw).slice(2)
98
+ return client.signMessage({
99
+ organizationId,
100
+ projectId,
101
+ token: await getToken(),
102
+ address,
103
+ message: raw,
104
+ encoding: 'hex',
105
+ })
108
106
  },
109
107
 
110
108
  signTransaction: async <
@@ -123,11 +121,28 @@ export async function toViemAccount(
123
121
  return signTransactionInternal(transaction, serializer)
124
122
  },
125
123
  signTypedData: async (typedData) => {
126
- const serializedTypedData = serializeTypedData(typedData)
127
- return signRawPayloadInternal(
128
- serializedTypedData,
129
- 'PAYLOAD_ENCODING_EIP712',
130
- )
124
+ const serializedTypedData = serializeTypedData({
125
+ ...typedData,
126
+ types: {
127
+ ...typedData.types,
128
+ EIP712Domain: getTypesForEIP712Domain({
129
+ domain: typedData.domain as Parameters<
130
+ typeof getTypesForEIP712Domain
131
+ >[0]['domain'],
132
+ }),
133
+ },
134
+ } as Parameters<typeof serializeTypedData>[0])
135
+ return client.signTypedDataV4({
136
+ organizationId,
137
+ projectId,
138
+ token: await getToken(),
139
+ address,
140
+ unsignedTypedDataV4: serializedTypedData,
141
+ encoding: 'utf8',
142
+ typedDataHash: hashTypedData(
143
+ typedData as Parameters<typeof hashTypedData>[0],
144
+ ).slice(2),
145
+ })
131
146
  },
132
147
 
133
148
  async signAuthorization(
@@ -146,7 +161,24 @@ export async function toViemAccount(
146
161
  nonce,
147
162
  })
148
163
 
149
- const signature = await signRawPayloadInternal(hashedAuthorization)
164
+ // Serialize EIP-7702 authorization: 0x05 || RLP([chainId, address, nonce])
165
+ const unsignedTransaction = concat([
166
+ '0x05',
167
+ toRlp([
168
+ chainId ? numberToHex(chainId) : '0x',
169
+ authAddress,
170
+ nonce ? numberToHex(nonce) : '0x',
171
+ ]),
172
+ ]).slice(2)
173
+
174
+ const signature = await client.sign7702Authorization({
175
+ organizationId,
176
+ projectId,
177
+ token: await getToken(),
178
+ address,
179
+ unsignedTransaction,
180
+ hashedAuthorization: hashedAuthorization.slice(2),
181
+ })
150
182
 
151
183
  const parsedSignature = parseSignature(signature)
152
184
 
@@ -30,15 +30,22 @@ import {
30
30
  type RegisterWithPasskeyReturnType,
31
31
  registerWithOTP,
32
32
  registerWithPasskey,
33
- type SignRawPayloadParameters,
34
- type SignRawPayloadReturnType,
35
- signRawPayload,
36
- } from '../../actions/index.js'
37
- import {
33
+ type Sign7702AuthorizationParameters,
34
+ type Sign7702AuthorizationReturnType,
35
+ type SignMessageParameters,
36
+ type SignMessageReturnType,
38
37
  type SignTransactionParameters,
39
38
  type SignTransactionReturnType,
39
+ type SignTypedDataV4Parameters,
40
+ type SignTypedDataV4ReturnType,
41
+ type SignUserOperationParameters,
42
+ type SignUserOperationReturnType,
43
+ sign7702Authorization,
44
+ signMessage,
40
45
  signTransaction,
41
- } from '../../actions/wallet/signTransaction.js'
46
+ signTypedDataV4,
47
+ signUserOperation,
48
+ } from '../../actions/index.js'
42
49
  import type { Client } from '../types.js'
43
50
 
44
51
  /**
@@ -81,11 +88,9 @@ export type ZeroDevWalletActions = {
81
88
  ) => Promise<GetUserWalletReturnType>
82
89
 
83
90
  /**
84
- * Signs a raw payload with the user's wallet
91
+ * Signs a message with the user's wallet
85
92
  */
86
- signRawPayload: (
87
- params: SignRawPayloadParameters,
88
- ) => Promise<SignRawPayloadReturnType>
93
+ signMessage: (params: SignMessageParameters) => Promise<SignMessageReturnType>
89
94
 
90
95
  /**
91
96
  * Signs a transaction with the user's wallet
@@ -94,6 +99,27 @@ export type ZeroDevWalletActions = {
94
99
  params: SignTransactionParameters,
95
100
  ) => Promise<SignTransactionReturnType>
96
101
 
102
+ /**
103
+ * Signs EIP-712 typed data with the user's wallet
104
+ */
105
+ signTypedDataV4: (
106
+ params: SignTypedDataV4Parameters,
107
+ ) => Promise<SignTypedDataV4ReturnType>
108
+
109
+ /**
110
+ * Signs a user operation with the user's wallet
111
+ */
112
+ signUserOperation: (
113
+ params: SignUserOperationParameters,
114
+ ) => Promise<SignUserOperationReturnType>
115
+
116
+ /**
117
+ * Signs an EIP-7702 authorization with the user's wallet
118
+ */
119
+ sign7702Authorization: (
120
+ params: Sign7702AuthorizationParameters,
121
+ ) => Promise<Sign7702AuthorizationReturnType>
122
+
97
123
  /**
98
124
  * Registers a passkey with the user's wallet
99
125
  */
@@ -160,8 +186,11 @@ export function zeroDevWalletActions(client: Client): ZeroDevWalletActions {
160
186
 
161
187
  // Wallet actions
162
188
  getUserWallet: (params) => getUserWallet(client, params),
163
- signRawPayload: (params) => signRawPayload(client, params),
189
+ signMessage: (params) => signMessage(client, params),
164
190
  signTransaction: (params) => signTransaction(client, params),
191
+ signTypedDataV4: (params) => signTypedDataV4(client, params),
192
+ signUserOperation: (params) => signUserOperation(client, params),
193
+ sign7702Authorization: (params) => sign7702Authorization(client, params),
165
194
  registerWithPasskey: (params) => registerWithPasskey(client, params),
166
195
  loginWithStamp: (params) => loginWithStamp(client, params),
167
196
  registerWithOTP: (params) => registerWithOTP(client, params),
@@ -50,6 +50,7 @@ export type AuthParams =
50
50
  | {
51
51
  type: 'oauth'
52
52
  provider: string
53
+ sessionId: string
53
54
  }
54
55
  | {
55
56
  type: 'passkey'
@@ -219,11 +220,10 @@ export async function createZeroDevWallet(
219
220
  async auth(params: AuthParams) {
220
221
  switch (params.type) {
221
222
  case 'oauth': {
222
- // Backend OAuth flow - the backend reads the OAuth session from a cookie
223
- // set during the OAuth popup flow via /oauth/google/login
224
223
  const data = await client.authenticateWithOAuth({
225
224
  provider: params.provider,
226
225
  projectId,
226
+ sessionId: params.sessionId,
227
227
  })
228
228
 
229
229
  if (data.session) {
package/src/index.ts CHANGED
@@ -15,10 +15,16 @@ export type {
15
15
  OtpContact,
16
16
  RegisterWithOTPParameters,
17
17
  RegisterWithOTPReturnType,
18
- SignRawPayloadParameters,
19
- SignRawPayloadReturnType,
18
+ Sign7702AuthorizationParameters,
19
+ Sign7702AuthorizationReturnType,
20
+ SignMessageParameters,
21
+ SignMessageReturnType,
20
22
  SignTransactionParameters,
21
23
  SignTransactionReturnType,
24
+ SignTypedDataV4Parameters,
25
+ SignTypedDataV4ReturnType,
26
+ SignUserOperationParameters,
27
+ SignUserOperationReturnType,
22
28
  } from './actions/index.js'
23
29
 
24
30
  // Actions
@@ -31,8 +37,11 @@ export {
31
37
  getWhoami,
32
38
  loginWithOTP,
33
39
  registerWithOTP,
34
- signRawPayload,
40
+ sign7702Authorization,
41
+ signMessage,
35
42
  signTransaction,
43
+ signTypedDataV4,
44
+ signUserOperation,
36
45
  } from './actions/index.js'
37
46
  export type { ToViemAccountParams } from './adapters/viem.js'
38
47
  // Adapters
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.signRawPayload = signRawPayload;
4
- async function signRawPayload(client, params) {
5
- const { organizationId, projectId, token, address, payload, encoding = 'PAYLOAD_ENCODING_HEXADECIMAL', hashFunction = 'HASH_FUNCTION_NO_OP', } = params;
6
- const { signature } = await client.request({
7
- path: `${projectId}/sign/raw-payload`,
8
- body: {
9
- type: 'ACTIVITY_TYPE_SIGN_RAW_PAYLOAD_V2',
10
- timestampMs: Date.now().toString(),
11
- organizationId,
12
- parameters: {
13
- signWith: address,
14
- payload,
15
- encoding,
16
- hashFunction,
17
- },
18
- },
19
- headers: {
20
- Authorization: `Bearer ${token}`,
21
- },
22
- stamp: true,
23
- stampPostion: 'headers',
24
- });
25
- return signature;
26
- }
27
- //# sourceMappingURL=signRawPayload.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"signRawPayload.js","sourceRoot":"","sources":["../../../../src/actions/wallet/signRawPayload.ts"],"names":[],"mappings":";;AAwCA,wCAkCC;AAlCM,KAAK,UAAU,cAAc,CAClC,MAAc,EACd,MAAgC;IAEhC,MAAM,EACJ,cAAc,EACd,SAAS,EACT,KAAK,EACL,OAAO,EACP,OAAO,EACP,QAAQ,GAAG,8BAA8B,EACzC,YAAY,GAAG,qBAAqB,GACrC,GAAG,MAAM,CAAA;IAEV,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QACzC,IAAI,EAAE,GAAG,SAAS,mBAAmB;QACrC,IAAI,EAAE;YACJ,IAAI,EAAE,mCAAmC;YACzC,WAAW,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;YAClC,cAAc;YACd,UAAU,EAAE;gBACV,QAAQ,EAAE,OAAO;gBACjB,OAAO;gBACP,QAAQ;gBACR,YAAY;aACb;SACF;QACD,OAAO,EAAE;YACP,aAAa,EAAE,UAAU,KAAK,EAAE;SACjC;QACD,KAAK,EAAE,IAAI;QACX,YAAY,EAAE,SAAS;KACxB,CAAC,CAAA;IACF,OAAO,SAAgB,CAAA;AACzB,CAAC"}
@@ -1,42 +0,0 @@
1
- /**
2
- * Signs a raw payload with the user's wallet
3
- *
4
- * @param client - The ZeroDev Wallet client
5
- * @param params - The parameters for signing
6
- * @returns The signature
7
- *
8
- * @example
9
- * ```ts
10
- * const result = await signRawPayload(client, {
11
- * organizationId: 'org_123',
12
- * projectId: 'proj_456',
13
- * address: '0x123...',
14
- * payload: 'abc123...',
15
- * });
16
- * console.log(result.signature); // '0x...'
17
- * ```
18
- */
19
- export async function signRawPayload(client, params) {
20
- const { organizationId, projectId, token, address, payload, encoding = 'PAYLOAD_ENCODING_HEXADECIMAL', hashFunction = 'HASH_FUNCTION_NO_OP', } = params;
21
- const { signature } = await client.request({
22
- path: `${projectId}/sign/raw-payload`,
23
- body: {
24
- type: 'ACTIVITY_TYPE_SIGN_RAW_PAYLOAD_V2',
25
- timestampMs: Date.now().toString(),
26
- organizationId,
27
- parameters: {
28
- signWith: address,
29
- payload,
30
- encoding,
31
- hashFunction,
32
- },
33
- },
34
- headers: {
35
- Authorization: `Bearer ${token}`,
36
- },
37
- stamp: true,
38
- stampPostion: 'headers',
39
- });
40
- return signature;
41
- }
42
- //# sourceMappingURL=signRawPayload.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"signRawPayload.js","sourceRoot":"","sources":["../../../../src/actions/wallet/signRawPayload.ts"],"names":[],"mappings":"AAsBA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAAc,EACd,MAAgC;IAEhC,MAAM,EACJ,cAAc,EACd,SAAS,EACT,KAAK,EACL,OAAO,EACP,OAAO,EACP,QAAQ,GAAG,8BAA8B,EACzC,YAAY,GAAG,qBAAqB,GACrC,GAAG,MAAM,CAAA;IAEV,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QACzC,IAAI,EAAE,GAAG,SAAS,mBAAmB;QACrC,IAAI,EAAE;YACJ,IAAI,EAAE,mCAAmC;YACzC,WAAW,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;YAClC,cAAc;YACd,UAAU,EAAE;gBACV,QAAQ,EAAE,OAAO;gBACjB,OAAO;gBACP,QAAQ;gBACR,YAAY;aACb;SACF;QACD,OAAO,EAAE;YACP,aAAa,EAAE,UAAU,KAAK,EAAE;SACjC;QACD,KAAK,EAAE,IAAI;QACX,YAAY,EAAE,SAAS;KACxB,CAAC,CAAA;IACF,OAAO,SAAgB,CAAA;AACzB,CAAC"}
@@ -1,39 +0,0 @@
1
- import type { Hex } from 'viem';
2
- import type { Client } from '../../client/types.js';
3
- export type SignRawPayloadParameters = {
4
- /** The organization ID */
5
- organizationId: string;
6
- /** The project ID for the request */
7
- projectId: string;
8
- /** The session token for authorization */
9
- token: string;
10
- /** The address to sign with */
11
- address: Hex;
12
- /** The payload hash to sign (without 0x prefix) */
13
- payload: string;
14
- /** The encoding type */
15
- encoding?: 'PAYLOAD_ENCODING_HEXADECIMAL' | 'PAYLOAD_ENCODING_EIP712';
16
- /** The hash function type */
17
- hashFunction?: 'HASH_FUNCTION_NO_OP';
18
- };
19
- export type SignRawPayloadReturnType = Hex;
20
- /**
21
- * Signs a raw payload with the user's wallet
22
- *
23
- * @param client - The ZeroDev Wallet client
24
- * @param params - The parameters for signing
25
- * @returns The signature
26
- *
27
- * @example
28
- * ```ts
29
- * const result = await signRawPayload(client, {
30
- * organizationId: 'org_123',
31
- * projectId: 'proj_456',
32
- * address: '0x123...',
33
- * payload: 'abc123...',
34
- * });
35
- * console.log(result.signature); // '0x...'
36
- * ```
37
- */
38
- export declare function signRawPayload(client: Client, params: SignRawPayloadParameters): Promise<SignRawPayloadReturnType>;
39
- //# sourceMappingURL=signRawPayload.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"signRawPayload.d.ts","sourceRoot":"","sources":["../../../../src/actions/wallet/signRawPayload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAC/B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAEnD,MAAM,MAAM,wBAAwB,GAAG;IACrC,0BAA0B;IAC1B,cAAc,EAAE,MAAM,CAAA;IACtB,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAA;IACjB,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAA;IACb,+BAA+B;IAC/B,OAAO,EAAE,GAAG,CAAA;IACZ,mDAAmD;IACnD,OAAO,EAAE,MAAM,CAAA;IACf,wBAAwB;IACxB,QAAQ,CAAC,EAAE,8BAA8B,GAAG,yBAAyB,CAAA;IACrE,6BAA6B;IAC7B,YAAY,CAAC,EAAE,qBAAqB,CAAA;CACrC,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG,GAAG,CAAA;AAE1C;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,wBAAwB,GAC/B,OAAO,CAAC,wBAAwB,CAAC,CA+BnC"}
@@ -1,75 +0,0 @@
1
- import type { Hex } from 'viem'
2
- import type { Client } from '../../client/types.js'
3
-
4
- export type SignRawPayloadParameters = {
5
- /** The organization ID */
6
- organizationId: string
7
- /** The project ID for the request */
8
- projectId: string
9
- /** The session token for authorization */
10
- token: string
11
- /** The address to sign with */
12
- address: Hex
13
- /** The payload hash to sign (without 0x prefix) */
14
- payload: string
15
- /** The encoding type */
16
- encoding?: 'PAYLOAD_ENCODING_HEXADECIMAL' | 'PAYLOAD_ENCODING_EIP712'
17
- /** The hash function type */
18
- hashFunction?: 'HASH_FUNCTION_NO_OP'
19
- }
20
-
21
- export type SignRawPayloadReturnType = Hex
22
-
23
- /**
24
- * Signs a raw payload with the user's wallet
25
- *
26
- * @param client - The ZeroDev Wallet client
27
- * @param params - The parameters for signing
28
- * @returns The signature
29
- *
30
- * @example
31
- * ```ts
32
- * const result = await signRawPayload(client, {
33
- * organizationId: 'org_123',
34
- * projectId: 'proj_456',
35
- * address: '0x123...',
36
- * payload: 'abc123...',
37
- * });
38
- * console.log(result.signature); // '0x...'
39
- * ```
40
- */
41
- export async function signRawPayload(
42
- client: Client,
43
- params: SignRawPayloadParameters,
44
- ): Promise<SignRawPayloadReturnType> {
45
- const {
46
- organizationId,
47
- projectId,
48
- token,
49
- address,
50
- payload,
51
- encoding = 'PAYLOAD_ENCODING_HEXADECIMAL',
52
- hashFunction = 'HASH_FUNCTION_NO_OP',
53
- } = params
54
-
55
- const { signature } = await client.request({
56
- path: `${projectId}/sign/raw-payload`,
57
- body: {
58
- type: 'ACTIVITY_TYPE_SIGN_RAW_PAYLOAD_V2',
59
- timestampMs: Date.now().toString(),
60
- organizationId,
61
- parameters: {
62
- signWith: address,
63
- payload,
64
- encoding,
65
- hashFunction,
66
- },
67
- },
68
- headers: {
69
- Authorization: `Bearer ${token}`,
70
- },
71
- stamp: true,
72
- stampPostion: 'headers',
73
- })
74
- return signature as Hex
75
- }