@getpara/rest-sdk 3.25.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 +4 -1
- package/dist/cjs/viem/index.js +55 -3
- package/dist/esm/viem/index.js +56 -5
- package/dist/types/index.d.ts +2 -0
- package/dist/types/viem/index.d.ts +19 -1
- package/package.json +3 -3
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
|
|
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
|
package/dist/cjs/viem/index.js
CHANGED
|
@@ -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 });
|
|
@@ -51,11 +54,38 @@ var __async = (__this, __arguments, generator) => {
|
|
|
51
54
|
};
|
|
52
55
|
var viem_exports = {};
|
|
53
56
|
__export(viem_exports, {
|
|
57
|
+
createParaDelegatedViemAccount: () => createParaDelegatedViemAccount,
|
|
54
58
|
createParaRestViemAccount: () => createParaRestViemAccount
|
|
55
59
|
});
|
|
56
60
|
module.exports = __toCommonJS(viem_exports);
|
|
57
61
|
var import_viem = require("viem");
|
|
58
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
|
+
];
|
|
72
|
+
function hasDelegatedClient(options) {
|
|
73
|
+
return options.client !== void 0;
|
|
74
|
+
}
|
|
75
|
+
function createParaDelegatedViemAccount(options) {
|
|
76
|
+
const client = hasDelegatedClient(options) ? options.client : new import__.ParaRestClient({
|
|
77
|
+
apiKey: options.apiKey,
|
|
78
|
+
env: options.env,
|
|
79
|
+
fetch: options.fetch,
|
|
80
|
+
requestIdGenerator: options.requestIdGenerator
|
|
81
|
+
});
|
|
82
|
+
return createParaRestViemAccount({
|
|
83
|
+
client,
|
|
84
|
+
walletId: options.walletId,
|
|
85
|
+
address: options.address,
|
|
86
|
+
publicKey: options.publicKey
|
|
87
|
+
});
|
|
88
|
+
}
|
|
59
89
|
function createParaRestViemAccount(options) {
|
|
60
90
|
const { client, walletId, address, publicKey = "0x" } = options;
|
|
61
91
|
return {
|
|
@@ -80,7 +110,7 @@ function createParaRestViemAccount(options) {
|
|
|
80
110
|
});
|
|
81
111
|
return normalizeSignature(res2.signature);
|
|
82
112
|
}
|
|
83
|
-
const res = yield client.signMessage(walletId, { message });
|
|
113
|
+
const res = yield client.signMessage(walletId, { message, walletType: "EVM" });
|
|
84
114
|
return normalizeSignature(res.signature);
|
|
85
115
|
}),
|
|
86
116
|
signTypedData: (typedDataDefinition) => __async(null, null, function* () {
|
|
@@ -90,11 +120,13 @@ function createParaRestViemAccount(options) {
|
|
|
90
120
|
return normalizeSignature(res.signature);
|
|
91
121
|
}),
|
|
92
122
|
signTransaction: (transaction, args) => __async(null, null, function* () {
|
|
123
|
+
const restTransaction = toRestTransaction(transaction);
|
|
93
124
|
if (args == null ? void 0 : args.serializer) {
|
|
94
|
-
|
|
125
|
+
assertStandardSerialization(transaction, restTransaction.type, args.serializer);
|
|
95
126
|
}
|
|
96
127
|
const res = yield client.signTransaction(walletId, {
|
|
97
|
-
|
|
128
|
+
walletType: "EVM",
|
|
129
|
+
transaction: restTransaction
|
|
98
130
|
});
|
|
99
131
|
return res.signedTransaction;
|
|
100
132
|
}),
|
|
@@ -145,6 +177,25 @@ function toRestTransaction(transaction) {
|
|
|
145
177
|
type
|
|
146
178
|
});
|
|
147
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
|
+
}
|
|
148
199
|
function toRestTypedData(typedData) {
|
|
149
200
|
var _a;
|
|
150
201
|
const types = __spreadValues({}, typedData.types);
|
|
@@ -174,5 +225,6 @@ function omitUndefined(value) {
|
|
|
174
225
|
}
|
|
175
226
|
// Annotate the CommonJS export names for ESM import in node:
|
|
176
227
|
0 && (module.exports = {
|
|
228
|
+
createParaDelegatedViemAccount,
|
|
177
229
|
createParaRestViemAccount
|
|
178
230
|
});
|
package/dist/esm/viem/index.js
CHANGED
|
@@ -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,34 @@ 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";
|
|
38
|
-
import { ParaRestValidationError } from "../index.js";
|
|
40
|
+
import { hashMessage, parseSignature, serializeSignature, serializeTransaction } from "viem";
|
|
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
|
+
];
|
|
51
|
+
function hasDelegatedClient(options) {
|
|
52
|
+
return options.client !== void 0;
|
|
53
|
+
}
|
|
54
|
+
function createParaDelegatedViemAccount(options) {
|
|
55
|
+
const client = hasDelegatedClient(options) ? options.client : new ParaRestClientImplementation({
|
|
56
|
+
apiKey: options.apiKey,
|
|
57
|
+
env: options.env,
|
|
58
|
+
fetch: options.fetch,
|
|
59
|
+
requestIdGenerator: options.requestIdGenerator
|
|
60
|
+
});
|
|
61
|
+
return createParaRestViemAccount({
|
|
62
|
+
client,
|
|
63
|
+
walletId: options.walletId,
|
|
64
|
+
address: options.address,
|
|
65
|
+
publicKey: options.publicKey
|
|
66
|
+
});
|
|
67
|
+
}
|
|
39
68
|
function createParaRestViemAccount(options) {
|
|
40
69
|
const { client, walletId, address, publicKey = "0x" } = options;
|
|
41
70
|
return {
|
|
@@ -60,7 +89,7 @@ function createParaRestViemAccount(options) {
|
|
|
60
89
|
});
|
|
61
90
|
return normalizeSignature(res2.signature);
|
|
62
91
|
}
|
|
63
|
-
const res = yield client.signMessage(walletId, { message });
|
|
92
|
+
const res = yield client.signMessage(walletId, { message, walletType: "EVM" });
|
|
64
93
|
return normalizeSignature(res.signature);
|
|
65
94
|
}),
|
|
66
95
|
signTypedData: (typedDataDefinition) => __async(null, null, function* () {
|
|
@@ -70,11 +99,13 @@ function createParaRestViemAccount(options) {
|
|
|
70
99
|
return normalizeSignature(res.signature);
|
|
71
100
|
}),
|
|
72
101
|
signTransaction: (transaction, args) => __async(null, null, function* () {
|
|
102
|
+
const restTransaction = toRestTransaction(transaction);
|
|
73
103
|
if (args == null ? void 0 : args.serializer) {
|
|
74
|
-
|
|
104
|
+
assertStandardSerialization(transaction, restTransaction.type, args.serializer);
|
|
75
105
|
}
|
|
76
106
|
const res = yield client.signTransaction(walletId, {
|
|
77
|
-
|
|
107
|
+
walletType: "EVM",
|
|
108
|
+
transaction: restTransaction
|
|
78
109
|
});
|
|
79
110
|
return res.signedTransaction;
|
|
80
111
|
}),
|
|
@@ -125,6 +156,25 @@ function toRestTransaction(transaction) {
|
|
|
125
156
|
type
|
|
126
157
|
});
|
|
127
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
|
+
}
|
|
128
178
|
function toRestTypedData(typedData) {
|
|
129
179
|
var _a;
|
|
130
180
|
const types = __spreadValues({}, typedData.types);
|
|
@@ -153,5 +203,6 @@ function omitUndefined(value) {
|
|
|
153
203
|
return Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== void 0));
|
|
154
204
|
}
|
|
155
205
|
export {
|
|
206
|
+
createParaDelegatedViemAccount,
|
|
156
207
|
createParaRestViemAccount
|
|
157
208
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -84,12 +84,14 @@ export interface SignRawResponse {
|
|
|
84
84
|
}
|
|
85
85
|
export interface SignMessageRequest extends RestSigningRequestContext {
|
|
86
86
|
message: string;
|
|
87
|
+
walletType?: WalletType;
|
|
87
88
|
}
|
|
88
89
|
export interface SignMessageResponse {
|
|
89
90
|
signature: string;
|
|
90
91
|
}
|
|
91
92
|
export interface SignTransactionRequest extends RestSigningRequestContext {
|
|
92
93
|
transaction: EvmSignTransactionRequest | string;
|
|
94
|
+
walletType?: WalletType;
|
|
93
95
|
broadcast?: boolean;
|
|
94
96
|
network?: SolanaNetwork | SuiNetwork;
|
|
95
97
|
networkPassphrase?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Address, Hex, LocalAccount } from 'viem';
|
|
2
|
-
import type { ParaRestClient } from '../index.js';
|
|
2
|
+
import type { ParaRestClient, ParaRestClientOptions } from '../index.js';
|
|
3
3
|
type ParaRestViemClient = Pick<ParaRestClient, 'signRaw' | 'signMessage' | 'signTypedData' | 'signTransaction' | 'signAuthorization'>;
|
|
4
4
|
export interface CreateParaRestViemAccountOptions {
|
|
5
5
|
client: ParaRestViemClient;
|
|
@@ -7,5 +7,23 @@ export interface CreateParaRestViemAccountOptions {
|
|
|
7
7
|
address: Address;
|
|
8
8
|
publicKey?: Hex;
|
|
9
9
|
}
|
|
10
|
+
type ParaDelegatedViemAccountIdentity = Omit<CreateParaRestViemAccountOptions, 'client'>;
|
|
11
|
+
export type CreateParaDelegatedViemAccountOptions = ParaDelegatedViemAccountIdentity & ({
|
|
12
|
+
client: ParaRestViemClient;
|
|
13
|
+
apiKey?: never;
|
|
14
|
+
} | (ParaRestClientOptions & {
|
|
15
|
+
client?: never;
|
|
16
|
+
}));
|
|
17
|
+
/**
|
|
18
|
+
* Creates a server-side viem account for a user-owned wallet whose signing
|
|
19
|
+
* authority is enforced by an active Para signing grant.
|
|
20
|
+
*
|
|
21
|
+
* This intentionally accepts partner REST credentials and a wallet id, never a
|
|
22
|
+
* ParaCore user session or grant id. Para resolves the active grant on every
|
|
23
|
+
* normal REST signing request. While the grant is active, only a request that
|
|
24
|
+
* its policy allows is signed. Every other request fails with 403
|
|
25
|
+
* `SIGNING_GRANT_REQUIRED`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function createParaDelegatedViemAccount(options: CreateParaDelegatedViemAccountOptions): LocalAccount;
|
|
10
28
|
export declare function createParaRestViemAccount(options: CreateParaRestViemAccountOptions): LocalAccount;
|
|
11
29
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/rest-sdk",
|
|
3
|
-
"version": "3.
|
|
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",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"vitest": "^3.2.4"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@getpara/shared": "^1.
|
|
30
|
+
"@getpara/shared": "^1.42.0"
|
|
31
31
|
},
|
|
32
32
|
"exports": {
|
|
33
33
|
".": {
|
|
@@ -111,5 +111,5 @@
|
|
|
111
111
|
}
|
|
112
112
|
},
|
|
113
113
|
"typings": "dist/types/index.d.ts",
|
|
114
|
-
"gitHead": "
|
|
114
|
+
"gitHead": "6f1dd93f4508c6da9256b76bcc306ec995002754"
|
|
115
115
|
}
|