@dynamic-labs-wallet/tempo 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 +26 -1
- package/index.esm.js +27 -2
- package/package.json +2 -2
- package/src/utils/formatTypedData/formatTypedData.d.ts.map +1 -1
package/index.cjs
CHANGED
|
@@ -30,7 +30,32 @@ var TEMPO_SIGN_MESSAGE_PREFIX = '\x19Ethereum Signed Message:\n';
|
|
|
30
30
|
/**
|
|
31
31
|
* Format typed data for Tempo signing.
|
|
32
32
|
*/ var formatTypedData = function(typedData) {
|
|
33
|
-
|
|
33
|
+
try {
|
|
34
|
+
return viem.hashTypedData(typedData).slice(2);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
// hashTypedData throws opaque errors (e.g. "Cannot read properties of
|
|
37
|
+
// undefined (reading 'length')") when `message` doesn't match `types`.
|
|
38
|
+
// Re-throw with a clear, actionable message identifying the typedData as
|
|
39
|
+
// the cause. Two cases:
|
|
40
|
+
// 1) format issues (bad address, int out of range, wrong bytes size,
|
|
41
|
+
// invalid primaryType/struct) -> viem's validateTypedData pinpoints it.
|
|
42
|
+
// 2) a field declared in `types` is missing/undefined in `message`
|
|
43
|
+
// (incl. primitive `string`/`bytes`) -> validateTypedData does NOT
|
|
44
|
+
// flag this, so we surface it explicitly here.
|
|
45
|
+
var primaryType = typedData.primaryType;
|
|
46
|
+
try {
|
|
47
|
+
viem.validateTypedData(typedData);
|
|
48
|
+
} catch (validationError) {
|
|
49
|
+
throw Object.assign(new Error("Invalid EIP-712 typedData: ".concat(validationError.message)), {
|
|
50
|
+
cause: error
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
var primaryTypeSuffix = primaryType ? ' (primaryType "'.concat(primaryType, '")') : '';
|
|
54
|
+
var message = "Invalid EIP-712 typedData: a field declared in `types` is missing or " + "undefined in `message`".concat(primaryTypeSuffix, ". ") + "Every field declared in `types` must be present in `message`. " + "Underlying error: ".concat(error.message);
|
|
55
|
+
throw Object.assign(new Error(message), {
|
|
56
|
+
cause: error
|
|
57
|
+
});
|
|
58
|
+
}
|
|
34
59
|
};
|
|
35
60
|
|
|
36
61
|
/**
|
package/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AuthMode, MessageHash, DynamicWalletClient, ERROR_PASSWORD_MISMATCH, ERROR_CREATE_WALLET_ACCOUNT, ERROR_KEYGEN_FAILED, getMPCChainConfig, ERROR_SIGN_MESSAGE, ERROR_ACCOUNT_ADDRESS_REQUIRED, ERROR_VERIFY_MESSAGE_SIGNATURE, ERROR_SIGN_TYPED_DATA, ERROR_IMPORT_PRIVATE_KEY } from '@dynamic-labs-wallet/browser';
|
|
2
|
-
import { stringToHex, bytesToHex, size, concat, hashTypedData, serializeSignature, createPublicClient, http, getAddress, toHex } from 'viem';
|
|
2
|
+
import { stringToHex, bytesToHex, size, concat, hashTypedData, validateTypedData, serializeSignature, createPublicClient, http, getAddress, toHex } from 'viem';
|
|
3
3
|
import { privateKeyToAccount } from 'viem/accounts';
|
|
4
4
|
import { Transaction } from 'viem/tempo';
|
|
5
5
|
|
|
@@ -28,7 +28,32 @@ var TEMPO_SIGN_MESSAGE_PREFIX = '\x19Ethereum Signed Message:\n';
|
|
|
28
28
|
/**
|
|
29
29
|
* Format typed data for Tempo signing.
|
|
30
30
|
*/ var formatTypedData = function(typedData) {
|
|
31
|
-
|
|
31
|
+
try {
|
|
32
|
+
return hashTypedData(typedData).slice(2);
|
|
33
|
+
} catch (error) {
|
|
34
|
+
// hashTypedData throws opaque errors (e.g. "Cannot read properties of
|
|
35
|
+
// undefined (reading 'length')") when `message` doesn't match `types`.
|
|
36
|
+
// Re-throw with a clear, actionable message identifying the typedData as
|
|
37
|
+
// the cause. Two cases:
|
|
38
|
+
// 1) format issues (bad address, int out of range, wrong bytes size,
|
|
39
|
+
// invalid primaryType/struct) -> viem's validateTypedData pinpoints it.
|
|
40
|
+
// 2) a field declared in `types` is missing/undefined in `message`
|
|
41
|
+
// (incl. primitive `string`/`bytes`) -> validateTypedData does NOT
|
|
42
|
+
// flag this, so we surface it explicitly here.
|
|
43
|
+
var primaryType = typedData.primaryType;
|
|
44
|
+
try {
|
|
45
|
+
validateTypedData(typedData);
|
|
46
|
+
} catch (validationError) {
|
|
47
|
+
throw Object.assign(new Error("Invalid EIP-712 typedData: ".concat(validationError.message)), {
|
|
48
|
+
cause: error
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
var primaryTypeSuffix = primaryType ? ' (primaryType "'.concat(primaryType, '")') : '';
|
|
52
|
+
var message = "Invalid EIP-712 typedData: a field declared in `types` is missing or " + "undefined in `message`".concat(primaryTypeSuffix, ". ") + "Every field declared in `types` must be present in `message`. " + "Underlying error: ".concat(error.message);
|
|
53
|
+
throw Object.assign(new Error(message), {
|
|
54
|
+
cause: error
|
|
55
|
+
});
|
|
56
|
+
}
|
|
32
57
|
};
|
|
33
58
|
|
|
34
59
|
/**
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs-wallet/tempo",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.19",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@dynamic-labs-wallet/browser": "1.0.
|
|
7
|
+
"@dynamic-labs-wallet/browser": "1.0.19",
|
|
8
8
|
"@dynamic-labs/sdk-api-core": "^0.0.984"
|
|
9
9
|
},
|
|
10
10
|
"peerDependencies": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatTypedData.d.ts","sourceRoot":"","sources":["../../../src/utils/formatTypedData/formatTypedData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA2B,SAAS,EAAE,MAAM,MAAM,CAAC;AAG/D;;GAEG;AACH,eAAO,MAAM,eAAe,cAAe,SAAS,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"formatTypedData.d.ts","sourceRoot":"","sources":["../../../src/utils/formatTypedData/formatTypedData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA2B,SAAS,EAAE,MAAM,MAAM,CAAC;AAG/D;;GAEG;AACH,eAAO,MAAM,eAAe,cAAe,SAAS,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,WA6BhF,CAAC"}
|