@zerodev/wallet-core 0.0.1 → 0.0.2
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/adapters/viem.js +10 -11
- package/dist/_cjs/adapters/viem.js.map +1 -1
- package/dist/_cjs/core/createZeroDevWalletCore.js +4 -1
- package/dist/_cjs/core/createZeroDevWalletCore.js.map +1 -1
- package/dist/_cjs/utils/hpke.js +3 -2
- package/dist/_cjs/utils/hpke.js.map +1 -1
- package/dist/_esm/adapters/viem.js +11 -12
- package/dist/_esm/adapters/viem.js.map +1 -1
- package/dist/_esm/core/createZeroDevWalletCore.js +4 -1
- package/dist/_esm/core/createZeroDevWalletCore.js.map +1 -1
- package/dist/_esm/utils/hpke.js +3 -2
- package/dist/_esm/utils/hpke.js.map +1 -1
- package/dist/_types/adapters/viem.d.ts.map +1 -1
- package/dist/_types/core/createZeroDevWalletCore.d.ts.map +1 -1
- package/dist/_types/utils/hpke.d.ts.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +8 -3
- package/src/adapters/viem.ts +16 -11
- package/src/core/createZeroDevWalletCore.ts +6 -1
- package/src/utils/hpke.ts +3 -2
package/package.json
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zerodev/wallet-core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "ZeroDev Wallet SDK built on Turnkey",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/zerodevapp/zerodev-wallet-sdk.git",
|
|
8
|
+
"directory": "packages/core"
|
|
9
|
+
},
|
|
5
10
|
"sideEffects": false,
|
|
6
11
|
"main": "./dist/_cjs/index.js",
|
|
7
12
|
"module": "./dist/_esm/index.js",
|
|
@@ -108,7 +113,7 @@
|
|
|
108
113
|
"json-canonicalize": "^2.0.0"
|
|
109
114
|
},
|
|
110
115
|
"peerDependencies": {
|
|
111
|
-
"viem": "^2.
|
|
116
|
+
"viem": "^2.47.18",
|
|
112
117
|
"@react-native-async-storage/async-storage": ">=2.0.0",
|
|
113
118
|
"@turnkey/api-key-stamper": ">=0.6.0",
|
|
114
119
|
"@turnkey/crypto": ">=2.8.0",
|
|
@@ -149,7 +154,7 @@
|
|
|
149
154
|
"@types/node": "^20.0.0",
|
|
150
155
|
"expo-secure-store": "55.0.9",
|
|
151
156
|
"typescript": "5.9.3",
|
|
152
|
-
"uuid": "^13.0.
|
|
157
|
+
"uuid": "^13.0.2"
|
|
153
158
|
},
|
|
154
159
|
"scripts": {
|
|
155
160
|
"build": "pnpm run clean && pnpm run build:cjs && pnpm run build:esm && pnpm run build:types",
|
package/src/adapters/viem.ts
CHANGED
|
@@ -4,6 +4,8 @@ import {
|
|
|
4
4
|
getTypesForEIP712Domain,
|
|
5
5
|
type Hex,
|
|
6
6
|
hashTypedData,
|
|
7
|
+
isAddress,
|
|
8
|
+
isAddressEqual,
|
|
7
9
|
type LocalAccount,
|
|
8
10
|
numberToHex,
|
|
9
11
|
parseSignature,
|
|
@@ -35,17 +37,20 @@ export async function toViemAccount(
|
|
|
35
37
|
): Promise<LocalAccount> {
|
|
36
38
|
const { client, organizationId, projectId, getToken } = params
|
|
37
39
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
address
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
const walletResponse = await client.getUserWallet({
|
|
41
|
+
organizationId,
|
|
42
|
+
projectId,
|
|
43
|
+
token: await getToken(),
|
|
44
|
+
})
|
|
45
|
+
const address = walletResponse.walletAddresses[0]
|
|
46
|
+
if (
|
|
47
|
+
!address ||
|
|
48
|
+
!isAddress(address, { strict: false }) ||
|
|
49
|
+
isAddressEqual(address, zeroAddress)
|
|
50
|
+
) {
|
|
51
|
+
throw new Error(
|
|
52
|
+
`Cannot build account: wallet address is missing, malformed, or zero for organization ${organizationId} (got ${address ?? 'undefined'}).`,
|
|
53
|
+
)
|
|
49
54
|
}
|
|
50
55
|
|
|
51
56
|
// Modified from: https://github.com/tkhq/sdk/blob/4e439bf2973ea13b51d981d7c24a4841d4e5fd5f/packages/viem/src/index.ts#L419-L461
|
|
@@ -459,7 +459,12 @@ export async function createZeroDevWalletCore(
|
|
|
459
459
|
projectId,
|
|
460
460
|
getToken: async () => {
|
|
461
461
|
const activeSession = await sessionStorageManager.getActiveSession()
|
|
462
|
-
|
|
462
|
+
if (!activeSession?.token) {
|
|
463
|
+
throw new Error(
|
|
464
|
+
'No active session token; refusing to build an account without authentication.',
|
|
465
|
+
)
|
|
466
|
+
}
|
|
467
|
+
return activeSession.token
|
|
463
468
|
},
|
|
464
469
|
})
|
|
465
470
|
},
|
package/src/utils/hpke.ts
CHANGED
|
@@ -58,9 +58,10 @@ function concat(...parts: Uint8Array[]): Uint8Array {
|
|
|
58
58
|
|
|
59
59
|
function i2osp(n: number, len: number): Uint8Array {
|
|
60
60
|
const out = new Uint8Array(len)
|
|
61
|
+
let value = n
|
|
61
62
|
for (let i = len - 1; i >= 0; i--) {
|
|
62
|
-
out[i] =
|
|
63
|
-
|
|
63
|
+
out[i] = value & 0xff
|
|
64
|
+
value >>>= 8
|
|
64
65
|
}
|
|
65
66
|
return out
|
|
66
67
|
}
|