@zerodev/wallet-core 0.0.1-alpha.4 → 0.0.1-alpha.5
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.
- package/dist/_cjs/actions/wallet/getUserWallet.js +6 -1
- package/dist/_cjs/actions/wallet/getUserWallet.js.map +1 -1
- package/dist/_cjs/adapters/viem.js +3 -2
- package/dist/_cjs/adapters/viem.js.map +1 -1
- package/dist/_cjs/client/transports/rest.js +8 -2
- package/dist/_cjs/client/transports/rest.js.map +1 -1
- package/dist/_cjs/core/createZeroDevWallet.js +1 -0
- package/dist/_cjs/core/createZeroDevWallet.js.map +1 -1
- package/dist/_esm/actions/wallet/getUserWallet.js +7 -2
- package/dist/_esm/actions/wallet/getUserWallet.js.map +1 -1
- package/dist/_esm/adapters/viem.js +3 -2
- package/dist/_esm/adapters/viem.js.map +1 -1
- package/dist/_esm/client/transports/rest.js +8 -2
- package/dist/_esm/client/transports/rest.js.map +1 -1
- package/dist/_esm/core/createZeroDevWallet.js +1 -0
- package/dist/_esm/core/createZeroDevWallet.js.map +1 -1
- package/dist/_types/actions/wallet/getUserWallet.d.ts +4 -2
- package/dist/_types/actions/wallet/getUserWallet.d.ts.map +1 -1
- package/dist/_types/adapters/viem.d.ts +1 -0
- package/dist/_types/adapters/viem.d.ts.map +1 -1
- package/dist/_types/client/transports/rest.d.ts +1 -0
- package/dist/_types/client/transports/rest.d.ts.map +1 -1
- package/dist/_types/core/createZeroDevWallet.d.ts.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/actions/wallet/getUserWallet.ts +10 -3
- package/src/adapters/viem.ts +4 -2
- package/src/client/transports/rest.ts +8 -2
- package/src/core/createZeroDevWallet.ts +1 -0
package/package.json
CHANGED
|
@@ -6,11 +6,13 @@ export type GetUserWalletParameters = {
|
|
|
6
6
|
organizationId: string
|
|
7
7
|
/** The project ID for the request */
|
|
8
8
|
projectId: string
|
|
9
|
+
/** The token for the request */
|
|
10
|
+
token: string
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
export type GetUserWalletReturnType = {
|
|
12
14
|
/** The wallet address */
|
|
13
|
-
|
|
15
|
+
walletAddresses: Hex[]
|
|
14
16
|
/** The user ID */
|
|
15
17
|
userId?: string
|
|
16
18
|
}
|
|
@@ -28,19 +30,24 @@ export type GetUserWalletReturnType = {
|
|
|
28
30
|
* organizationId: 'org_123',
|
|
29
31
|
* projectId: 'proj_456'
|
|
30
32
|
* });
|
|
31
|
-
* console.log(wallet.
|
|
33
|
+
* console.log(wallet.walletAddresses); // ['0x...', '0x...']
|
|
32
34
|
* ```
|
|
33
35
|
*/
|
|
34
36
|
export async function getUserWallet(
|
|
35
37
|
client: Client,
|
|
36
38
|
params: GetUserWalletParameters,
|
|
37
39
|
): Promise<GetUserWalletReturnType> {
|
|
38
|
-
const { organizationId, projectId } = params
|
|
40
|
+
const { organizationId, projectId, token } = params
|
|
39
41
|
|
|
40
42
|
return await client.request({
|
|
41
43
|
path: `${projectId}/user-wallet`,
|
|
42
44
|
body: {
|
|
43
45
|
organizationId,
|
|
44
46
|
},
|
|
47
|
+
headers: {
|
|
48
|
+
Authorization: `Bearer ${token}`,
|
|
49
|
+
},
|
|
50
|
+
stamp: true,
|
|
51
|
+
stampPostion: 'headers',
|
|
45
52
|
})
|
|
46
53
|
}
|
package/src/adapters/viem.ts
CHANGED
|
@@ -24,12 +24,13 @@ export interface ToViemAccountParams {
|
|
|
24
24
|
client: ZeroDevWalletClient
|
|
25
25
|
organizationId: string
|
|
26
26
|
projectId: string
|
|
27
|
+
token: string
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
export async function toViemAccount(
|
|
30
31
|
params: ToViemAccountParams,
|
|
31
32
|
): Promise<LocalAccount> {
|
|
32
|
-
const { client, organizationId, projectId } = params
|
|
33
|
+
const { client, organizationId, projectId, token } = params
|
|
33
34
|
|
|
34
35
|
let address: Hex = zeroAddress
|
|
35
36
|
|
|
@@ -37,8 +38,9 @@ export async function toViemAccount(
|
|
|
37
38
|
const walletResponse = await client.getUserWallet({
|
|
38
39
|
organizationId,
|
|
39
40
|
projectId,
|
|
41
|
+
token,
|
|
40
42
|
})
|
|
41
|
-
address = walletResponse.
|
|
43
|
+
address = walletResponse.walletAddresses[0]
|
|
42
44
|
} catch {
|
|
43
45
|
address = zeroAddress
|
|
44
46
|
}
|
|
@@ -8,6 +8,7 @@ export type RestRequestArgs = {
|
|
|
8
8
|
headers?: Record<string, string>
|
|
9
9
|
stamp?: boolean
|
|
10
10
|
stampWith?: 'indexedDb' | 'webAuthn'
|
|
11
|
+
stampPostion?: 'body' | 'headers'
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export type RestRequestFn = <T = any>(args: RestRequestArgs) => Promise<T>
|
|
@@ -44,7 +45,7 @@ export function rest(url: string, cfg: RestTransportConfig): RestTransport {
|
|
|
44
45
|
|
|
45
46
|
try {
|
|
46
47
|
let requestBody = args.body
|
|
47
|
-
|
|
48
|
+
let requestHeaders = {
|
|
48
49
|
'content-type': 'application/json',
|
|
49
50
|
...(args.headers ?? {}),
|
|
50
51
|
...(cfg.fetchOptions?.headers ?? {}),
|
|
@@ -65,7 +66,12 @@ export function rest(url: string, cfg: RestTransportConfig): RestTransport {
|
|
|
65
66
|
const stamp = await stamper.stamp(bodyString)
|
|
66
67
|
|
|
67
68
|
// Restructure request body to match backend expectation
|
|
68
|
-
if (
|
|
69
|
+
if (args.stampPostion === 'headers') {
|
|
70
|
+
requestHeaders = {
|
|
71
|
+
...requestHeaders,
|
|
72
|
+
[stamp.stampHeaderName]: stamp.stampHeaderValue,
|
|
73
|
+
}
|
|
74
|
+
} else if (body) {
|
|
69
75
|
requestBody = {
|
|
70
76
|
body: bodyString,
|
|
71
77
|
stamp: {
|