@dynamic-labs-wallet/node-evm 1.0.17 → 1.0.19

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/index.cjs CHANGED
@@ -48,7 +48,32 @@ const formatEVMMessage = (message_)=>{
48
48
  ]);
49
49
  };
50
50
  const formatTypedData = (typedData)=>{
51
- return viem.hashTypedData(typedData).slice(2);
51
+ try {
52
+ return viem.hashTypedData(typedData).slice(2);
53
+ } catch (error) {
54
+ // hashTypedData throws opaque errors (e.g. "Cannot read properties of
55
+ // undefined (reading 'length')") when `message` doesn't match `types`.
56
+ // Re-throw with a clear, actionable message identifying the typedData as
57
+ // the cause. Two cases:
58
+ // 1) format issues (bad address, int out of range, wrong bytes size,
59
+ // invalid primaryType/struct) -> viem's validateTypedData pinpoints it.
60
+ // 2) a field declared in `types` is missing/undefined in `message`
61
+ // (incl. primitive `string`/`bytes`) -> validateTypedData does NOT
62
+ // flag this, so we surface it explicitly here.
63
+ const primaryType = typedData.primaryType;
64
+ try {
65
+ viem.validateTypedData(typedData);
66
+ } catch (validationError) {
67
+ throw Object.assign(new Error(`Invalid EIP-712 typedData: ${validationError.message}`), {
68
+ cause: error
69
+ });
70
+ }
71
+ const primaryTypeSuffix = primaryType ? ` (primaryType "${primaryType}")` : '';
72
+ const message = `Invalid EIP-712 typedData: a field declared in \`types\` is missing or ` + `undefined in \`message\`${primaryTypeSuffix}. ` + `Every field declared in \`types\` must be present in \`message\`. ` + `Underlying error: ${error.message}`;
73
+ throw Object.assign(new Error(message), {
74
+ cause: error
75
+ });
76
+ }
52
77
  };
53
78
  const serializeECDSASignature = (signature)=>{
54
79
  return viem.serializeSignature({
package/index.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { toAccount } from 'viem/accounts';
2
2
  import { MessageHash, createLogError, createDelegatedWalletClient, delegatedSignMessage as delegatedSignMessage$1, stripHexPrefix, revokeDelegation as revokeDelegation$1, DynamicWalletClient, getMPCChainConfig, WalletOperation } from '@dynamic-labs-wallet/node';
3
- import { getAddress, stringToHex, bytesToHex, size, concat, hashTypedData, serializeSignature, parseSignature, serializeTransaction, createPublicClient, http, defineChain, createWalletClient } from 'viem';
3
+ import { getAddress, stringToHex, bytesToHex, size, concat, hashTypedData, validateTypedData, serializeSignature, parseSignature, serializeTransaction, createPublicClient, http, defineChain, createWalletClient } from 'viem';
4
4
  import { hashAuthorization } from 'viem/utils';
5
5
  import { mainnet } from 'viem/chains';
6
6
  import { initializeClient, refreshUser, getNetworksData, createDynamicClient } from '@dynamic-labs-sdk/client';
@@ -46,7 +46,32 @@ const formatEVMMessage = (message_)=>{
46
46
  ]);
47
47
  };
48
48
  const formatTypedData = (typedData)=>{
49
- return hashTypedData(typedData).slice(2);
49
+ try {
50
+ return hashTypedData(typedData).slice(2);
51
+ } catch (error) {
52
+ // hashTypedData throws opaque errors (e.g. "Cannot read properties of
53
+ // undefined (reading 'length')") when `message` doesn't match `types`.
54
+ // Re-throw with a clear, actionable message identifying the typedData as
55
+ // the cause. Two cases:
56
+ // 1) format issues (bad address, int out of range, wrong bytes size,
57
+ // invalid primaryType/struct) -> viem's validateTypedData pinpoints it.
58
+ // 2) a field declared in `types` is missing/undefined in `message`
59
+ // (incl. primitive `string`/`bytes`) -> validateTypedData does NOT
60
+ // flag this, so we surface it explicitly here.
61
+ const primaryType = typedData.primaryType;
62
+ try {
63
+ validateTypedData(typedData);
64
+ } catch (validationError) {
65
+ throw Object.assign(new Error(`Invalid EIP-712 typedData: ${validationError.message}`), {
66
+ cause: error
67
+ });
68
+ }
69
+ const primaryTypeSuffix = primaryType ? ` (primaryType "${primaryType}")` : '';
70
+ const message = `Invalid EIP-712 typedData: a field declared in \`types\` is missing or ` + `undefined in \`message\`${primaryTypeSuffix}. ` + `Every field declared in \`types\` must be present in \`message\`. ` + `Underlying error: ${error.message}`;
71
+ throw Object.assign(new Error(message), {
72
+ cause: error
73
+ });
74
+ }
50
75
  };
51
76
  const serializeECDSASignature = (signature)=>{
52
77
  return serializeSignature({
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@dynamic-labs-wallet/node-evm",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "dependencies": {
7
- "@dynamic-labs-wallet/node": "1.0.17",
7
+ "@dynamic-labs-wallet/node": "1.0.19",
8
8
  "@dynamic-labs/sdk-api-core": "^0.0.984",
9
9
  "@dynamic-labs-sdk/client": "0.3.0",
10
10
  "@dynamic-labs-sdk/zerodev": "0.3.0",
11
11
  "@dynamic-labs-sdk/evm": "0.3.0",
12
12
  "@zerodev/ecdsa-validator": "5.4.9",
13
13
  "@zerodev/sdk": "5.4.36",
14
- "@dynamic-labs-wallet/core": "1.0.17"
14
+ "@dynamic-labs-wallet/core": "1.0.19"
15
15
  },
16
16
  "publishConfig": {
17
17
  "access": "public"
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../packages/src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,cAAc,EAAe,MAAM,2BAA2B,CAAC;AAClG,OAAO,EASL,KAAK,SAAS,EACf,MAAM,MAAM,CAAC;AAGd,eAAO,MAAM,gBAAgB,aAAc,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,GAAG,UAAU,CAAA;CAAE,kBAQ/E,CAAC;AAEF,eAAO,MAAM,eAAe,cAAe,SAAS,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,WAEhF,CAAC;AAEF,eAAO,MAAM,uBAAuB,cAAe,cAAc,kBAMhE,CAAC;AAEF,eAAO,MAAM,oBAAoB,qBAAsB;IAAE,YAAY,EAAE,cAAc,CAAA;CAAE;;;CAQtF,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../packages/src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,cAAc,EAAe,MAAM,2BAA2B,CAAC;AAClG,OAAO,EASL,KAAK,SAAS,EAEf,MAAM,MAAM,CAAC;AAGd,eAAO,MAAM,gBAAgB,aAAc,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,GAAG,UAAU,CAAA;CAAE,kBAQ/E,CAAC;AAEF,eAAO,MAAM,eAAe,cAAe,SAAS,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,WA6BhF,CAAC;AAEF,eAAO,MAAM,uBAAuB,cAAe,cAAc,kBAMhE,CAAC;AAEF,eAAO,MAAM,oBAAoB,qBAAsB;IAAE,YAAY,EAAE,cAAc,CAAA;CAAE;;;CAQtF,CAAC"}