@getpara/rest-sdk 3.26.0 → 3.27.0

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/README.md CHANGED
@@ -85,7 +85,10 @@ should be treated as bytes instead of text.
85
85
  EVM transaction signing returns the REST API's signed transaction response. The SDK normalizes the caller's transaction
86
86
  request before sending it, but does not re-derive the signed payload locally or diff every returned field against the
87
87
  request. REST EVM transaction signing supports ordinary legacy and EIP-1559 sends only; contract deployments, access
88
- lists, blob transactions, authorization-list transactions, and custom viem serializers are rejected before calling REST.
88
+ lists, blob transactions, and authorization-list transactions are rejected before calling REST. The viem adapter accepts
89
+ a chain serializer whose output equals the standard Ethereum serialization, such as on Base and other OP Stack chains,
90
+ or for standard Celo and ZKsync transactions. Chain-specific transactions, such as OP Stack deposits, Celo `feeCurrency`
91
+ transactions, and ZKsync EIP-712 transactions, are rejected before calling REST.
89
92
 
90
93
  The Solana adapter implements the Solana v2 signer traits by signing message bytes through `sign-raw`. It returns
91
94
  signature dictionaries and can merge signatures into Solana v2 message and transaction objects. Use
@@ -1,5 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
3
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
6
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
@@ -16,6 +18,7 @@ var __spreadValues = (a, b) => {
16
18
  }
17
19
  return a;
18
20
  };
21
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
19
22
  var __export = (target, all) => {
20
23
  for (var name in all)
21
24
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -57,6 +60,15 @@ __export(viem_exports, {
57
60
  module.exports = __toCommonJS(viem_exports);
58
61
  var import_viem = require("viem");
59
62
  var import__ = require("../index.js");
63
+ const VIEM_TRANSACTION_TYPES = { 0: "legacy", 2: "eip1559" };
64
+ const UNSUPPORTED_TRANSACTION_FIELDS = [
65
+ "authorizationList",
66
+ "blobs",
67
+ "blobVersionedHashes",
68
+ "maxFeePerBlobGas",
69
+ "sidecars",
70
+ "kzg"
71
+ ];
60
72
  function hasDelegatedClient(options) {
61
73
  return options.client !== void 0;
62
74
  }
@@ -108,12 +120,13 @@ function createParaRestViemAccount(options) {
108
120
  return normalizeSignature(res.signature);
109
121
  }),
110
122
  signTransaction: (transaction, args) => __async(null, null, function* () {
123
+ const restTransaction = toRestTransaction(transaction);
111
124
  if (args == null ? void 0 : args.serializer) {
112
- throw new import__.ParaRestValidationError("custom transaction serializers are not supported by the REST signer");
125
+ assertStandardSerialization(transaction, restTransaction.type, args.serializer);
113
126
  }
114
127
  const res = yield client.signTransaction(walletId, {
115
128
  walletType: "EVM",
116
- transaction: toRestTransaction(transaction)
129
+ transaction: restTransaction
117
130
  });
118
131
  return res.signedTransaction;
119
132
  }),
@@ -164,6 +177,25 @@ function toRestTransaction(transaction) {
164
177
  type
165
178
  });
166
179
  }
180
+ function assertStandardSerialization(transaction, restType, serializer) {
181
+ const unsupportedField = UNSUPPORTED_TRANSACTION_FIELDS.find((field) => transaction[field] !== void 0);
182
+ if (unsupportedField) {
183
+ throw new import__.ParaRestValidationError(`transaction.${unsupportedField} is not supported by the REST signer`);
184
+ }
185
+ const type = VIEM_TRANSACTION_TYPES[restType];
186
+ if (!serializesAsStandard(__spreadProps(__spreadValues({}, transaction), { type }), serializer)) {
187
+ throw new import__.ParaRestValidationError(
188
+ `transaction.type ${type} with chain-specific fields is not supported by the REST signer`
189
+ );
190
+ }
191
+ }
192
+ function serializesAsStandard(transaction, serializer) {
193
+ try {
194
+ return serializer(transaction) === (0, import_viem.serializeTransaction)(transaction);
195
+ } catch (e) {
196
+ return false;
197
+ }
198
+ }
167
199
  function toRestTypedData(typedData) {
168
200
  var _a;
169
201
  const types = __spreadValues({}, typedData.types);
@@ -1,4 +1,6 @@
1
1
  var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
2
4
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
4
6
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
@@ -14,6 +16,7 @@ var __spreadValues = (a, b) => {
14
16
  }
15
17
  return a;
16
18
  };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
17
20
  var __async = (__this, __arguments, generator) => {
18
21
  return new Promise((resolve, reject) => {
19
22
  var fulfilled = (value) => {
@@ -34,8 +37,17 @@ var __async = (__this, __arguments, generator) => {
34
37
  step((generator = generator.apply(__this, __arguments)).next());
35
38
  });
36
39
  };
37
- import { hashMessage, parseSignature, serializeSignature } from "viem";
40
+ import { hashMessage, parseSignature, serializeSignature, serializeTransaction } from "viem";
38
41
  import { ParaRestClient as ParaRestClientImplementation, ParaRestValidationError } from "../index.js";
42
+ const VIEM_TRANSACTION_TYPES = { 0: "legacy", 2: "eip1559" };
43
+ const UNSUPPORTED_TRANSACTION_FIELDS = [
44
+ "authorizationList",
45
+ "blobs",
46
+ "blobVersionedHashes",
47
+ "maxFeePerBlobGas",
48
+ "sidecars",
49
+ "kzg"
50
+ ];
39
51
  function hasDelegatedClient(options) {
40
52
  return options.client !== void 0;
41
53
  }
@@ -87,12 +99,13 @@ function createParaRestViemAccount(options) {
87
99
  return normalizeSignature(res.signature);
88
100
  }),
89
101
  signTransaction: (transaction, args) => __async(null, null, function* () {
102
+ const restTransaction = toRestTransaction(transaction);
90
103
  if (args == null ? void 0 : args.serializer) {
91
- throw new ParaRestValidationError("custom transaction serializers are not supported by the REST signer");
104
+ assertStandardSerialization(transaction, restTransaction.type, args.serializer);
92
105
  }
93
106
  const res = yield client.signTransaction(walletId, {
94
107
  walletType: "EVM",
95
- transaction: toRestTransaction(transaction)
108
+ transaction: restTransaction
96
109
  });
97
110
  return res.signedTransaction;
98
111
  }),
@@ -143,6 +156,25 @@ function toRestTransaction(transaction) {
143
156
  type
144
157
  });
145
158
  }
159
+ function assertStandardSerialization(transaction, restType, serializer) {
160
+ const unsupportedField = UNSUPPORTED_TRANSACTION_FIELDS.find((field) => transaction[field] !== void 0);
161
+ if (unsupportedField) {
162
+ throw new ParaRestValidationError(`transaction.${unsupportedField} is not supported by the REST signer`);
163
+ }
164
+ const type = VIEM_TRANSACTION_TYPES[restType];
165
+ if (!serializesAsStandard(__spreadProps(__spreadValues({}, transaction), { type }), serializer)) {
166
+ throw new ParaRestValidationError(
167
+ `transaction.type ${type} with chain-specific fields is not supported by the REST signer`
168
+ );
169
+ }
170
+ }
171
+ function serializesAsStandard(transaction, serializer) {
172
+ try {
173
+ return serializer(transaction) === serializeTransaction(transaction);
174
+ } catch (e) {
175
+ return false;
176
+ }
177
+ }
146
178
  function toRestTypedData(typedData) {
147
179
  var _a;
148
180
  const types = __spreadValues({}, typedData.types);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpara/rest-sdk",
3
- "version": "3.26.0",
3
+ "version": "3.27.0",
4
4
  "description": "Typed server-side SDK for Para REST wallet management and signing",
5
5
  "author": "Para Team <hello@getpara.com> (https://getpara.com)",
6
6
  "homepage": "https://docs.getpara.com/v3/rest/sdk",
@@ -111,5 +111,5 @@
111
111
  }
112
112
  },
113
113
  "typings": "dist/types/index.d.ts",
114
- "gitHead": "3da03ae598e47dddcad44773264bcba424537e9d"
114
+ "gitHead": "6f1dd93f4508c6da9256b76bcc306ec995002754"
115
115
  }