@qevm/transactions 5.7.1 → 5.7.3
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 +3 -5
- package/lib/_version.d.ts +1 -1
- package/lib/_version.js +1 -1
- package/lib/index.d.ts +4 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +105 -81
- package/lib/index.js.map +1 -1
- package/package.json +33 -29
- package/src.ts/_version.ts +1 -1
- package/src.ts/index.ts +209 -89
package/README.md
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
Ethereum Transaction Utilities
|
|
2
2
|
==============================
|
|
3
3
|
|
|
4
|
-
This sub-module is part of the [ethers project](https://github.com/ethers-io/ethers.js).
|
|
4
|
+
This sub-module is part of the qethers, a fork of [ethers project](https://github.com/ethers-io/ethers.js).
|
|
5
5
|
|
|
6
6
|
It contains various functions for encoding and decoding serialized transactios.
|
|
7
7
|
|
|
8
|
-
For more information, see the [documentation](https://docs.ethers.io/v5/api/utils/transactions/).
|
|
9
|
-
|
|
10
8
|
|
|
11
9
|
Importing
|
|
12
10
|
---------
|
|
13
11
|
|
|
14
|
-
Most users will prefer to use the [umbrella package](https://www.npmjs.com/package/
|
|
12
|
+
Most users will prefer to use the [umbrella package](https://www.npmjs.com/package/@qevm/qethers),
|
|
15
13
|
but for those with more specific needs, individual components can be imported.
|
|
16
14
|
|
|
17
15
|
```javascript
|
|
@@ -28,7 +26,7 @@ const {
|
|
|
28
26
|
Transaction,
|
|
29
27
|
UnsignedTransaction
|
|
30
28
|
|
|
31
|
-
} = require("@
|
|
29
|
+
} = require("@qevm/transactions");
|
|
32
30
|
```
|
|
33
31
|
|
|
34
32
|
|
package/lib/_version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "transactions/5.7.
|
|
1
|
+
export declare const version = "transactions/5.7.3";
|
|
2
2
|
//# sourceMappingURL=_version.d.ts.map
|
package/lib/_version.js
CHANGED
package/lib/index.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { BigNumber, BigNumberish } from "@
|
|
1
|
+
import { BigNumber, BigNumberish } from "@qevm/bignumber";
|
|
2
2
|
import { BytesLike, SignatureLike } from "@qevm/bytes";
|
|
3
|
-
export
|
|
3
|
+
export type AccessList = Array<{
|
|
4
4
|
address: string;
|
|
5
5
|
storageKeys: Array<string>;
|
|
6
6
|
}>;
|
|
7
|
-
export
|
|
7
|
+
export type AccessListish = AccessList | Array<[string, Array<string>]> | Record<string, Array<string>>;
|
|
8
8
|
export declare enum TransactionTypes {
|
|
9
9
|
legacy = 0,
|
|
10
10
|
eip2930 = 1,
|
|
11
11
|
eip1559 = 2
|
|
12
12
|
}
|
|
13
|
-
export
|
|
13
|
+
export type UnsignedTransaction = {
|
|
14
14
|
to?: string;
|
|
15
15
|
nonce?: number;
|
|
16
16
|
gasLimit?: BigNumberish;
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src.ts/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src.ts/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAEH,SAAS,EAMT,aAAa,EAGhB,MAAM,aAAa,CAAC;AAarB,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;CAAE,CAAC,CAAC;AAGhF,MAAM,MAAM,aAAa,GACnB,UAAU,GACV,KAAK,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,GAC9B,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC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;AAiCD,wBAAgB,aAAa,CAAC,KAAK,EAAE,aAAa,GAAG,UAAU,CAmC9D;AAiJD,wBAAgB,SAAS,CACrB,WAAW,EAAE,mBAAmB,EAChC,SAAS,CAAC,EAAE,aAAa,GAC1B,MAAM,CA+BR;AAwID,wBAAgB,KAAK,CAAC,cAAc,EAAE,SAAS,GAAG,WAAW,CA0B5D"}
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -11,32 +15,46 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
11
15
|
}) : function(o, v) {
|
|
12
16
|
o["default"] = v;
|
|
13
17
|
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
21
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
36
|
+
exports.TransactionTypes = void 0;
|
|
37
|
+
exports.computeAddress = computeAddress;
|
|
38
|
+
exports.recoverAddress = recoverAddress;
|
|
39
|
+
exports.accessListify = accessListify;
|
|
40
|
+
exports.serialize = serialize;
|
|
41
|
+
exports.parse = parse;
|
|
42
|
+
const address_1 = require("@qevm/address");
|
|
43
|
+
const bignumber_1 = require("@qevm/bignumber");
|
|
44
|
+
const bytes_1 = require("@qevm/bytes");
|
|
45
|
+
const constants_1 = require("@qevm/constants");
|
|
46
|
+
const keccak256_1 = require("@qevm/keccak256");
|
|
47
|
+
const properties_1 = require("@qevm/properties");
|
|
48
|
+
const RLP = __importStar(require("@qevm/rlp"));
|
|
49
|
+
const logger_1 = require("@qevm/logger");
|
|
50
|
+
const _version_1 = require("./_version");
|
|
51
|
+
const logger = new logger_1.Logger(_version_1.version);
|
|
33
52
|
var TransactionTypes;
|
|
34
53
|
(function (TransactionTypes) {
|
|
35
54
|
TransactionTypes[TransactionTypes["legacy"] = 0] = "legacy";
|
|
36
55
|
TransactionTypes[TransactionTypes["eip2930"] = 1] = "eip2930";
|
|
37
56
|
TransactionTypes[TransactionTypes["eip1559"] = 2] = "eip1559";
|
|
38
|
-
})(TransactionTypes
|
|
39
|
-
;
|
|
57
|
+
})(TransactionTypes || (exports.TransactionTypes = TransactionTypes = {}));
|
|
40
58
|
///////////////////////////////
|
|
41
59
|
function handleAddress(value) {
|
|
42
60
|
if (value === "0x") {
|
|
@@ -51,7 +69,7 @@ function handleNumber(value) {
|
|
|
51
69
|
return bignumber_1.BigNumber.from(value);
|
|
52
70
|
}
|
|
53
71
|
// Legacy Transaction Fields
|
|
54
|
-
|
|
72
|
+
const transactionFields = [
|
|
55
73
|
{ name: "nonce", maxLength: 32, numeric: true },
|
|
56
74
|
{ name: "gasPrice", maxLength: 32, numeric: true },
|
|
57
75
|
{ name: "gasLimit", maxLength: 32, numeric: true },
|
|
@@ -59,86 +77,90 @@ var transactionFields = [
|
|
|
59
77
|
{ name: "value", maxLength: 32, numeric: true },
|
|
60
78
|
{ name: "data" },
|
|
61
79
|
];
|
|
62
|
-
|
|
63
|
-
chainId: true,
|
|
80
|
+
const allowedTransactionKeys = {
|
|
81
|
+
chainId: true,
|
|
82
|
+
data: true,
|
|
83
|
+
gasLimit: true,
|
|
84
|
+
gasPrice: true,
|
|
85
|
+
nonce: true,
|
|
86
|
+
to: true,
|
|
87
|
+
type: true,
|
|
88
|
+
value: true,
|
|
64
89
|
};
|
|
65
90
|
function computeAddress(publicKey) {
|
|
66
91
|
return (0, keccak256_1.keccak256)(publicKey);
|
|
67
92
|
}
|
|
68
|
-
exports.computeAddress = computeAddress;
|
|
69
93
|
function recoverAddress(signature) {
|
|
70
|
-
|
|
94
|
+
let sig = (0, bytes_1.splitSignature)(signature);
|
|
71
95
|
return (0, keccak256_1.keccak256)(sig.publicKey);
|
|
72
96
|
}
|
|
73
|
-
exports.recoverAddress = recoverAddress;
|
|
74
97
|
function formatNumber(value, name) {
|
|
75
|
-
|
|
98
|
+
const result = (0, bytes_1.stripZeros)(bignumber_1.BigNumber.from(value).toHexString());
|
|
76
99
|
if (result.length > 32) {
|
|
77
|
-
logger.throwArgumentError("invalid length for " + name,
|
|
100
|
+
logger.throwArgumentError("invalid length for " + name, "transaction:" + name, value);
|
|
78
101
|
}
|
|
79
102
|
return result;
|
|
80
103
|
}
|
|
81
104
|
function accessSetify(addr, storageKeys) {
|
|
82
105
|
return {
|
|
83
106
|
address: (0, address_1.getAddress)(addr),
|
|
84
|
-
storageKeys: (storageKeys || []).map(
|
|
107
|
+
storageKeys: (storageKeys || []).map((storageKey, index) => {
|
|
85
108
|
if ((0, bytes_1.hexDataLength)(storageKey) !== 32) {
|
|
86
|
-
logger.throwArgumentError("invalid access list storageKey",
|
|
109
|
+
logger.throwArgumentError("invalid access list storageKey", `accessList[${addr}:${index}]`, storageKey);
|
|
87
110
|
}
|
|
88
111
|
return storageKey.toLowerCase();
|
|
89
|
-
})
|
|
112
|
+
}),
|
|
90
113
|
};
|
|
91
114
|
}
|
|
92
115
|
function accessListify(value) {
|
|
93
116
|
if (Array.isArray(value)) {
|
|
94
|
-
return value.map(
|
|
117
|
+
return value.map((set, index) => {
|
|
95
118
|
if (Array.isArray(set)) {
|
|
96
119
|
if (set.length > 2) {
|
|
97
|
-
logger.throwArgumentError("access list expected to be [ address, storageKeys[] ]",
|
|
120
|
+
logger.throwArgumentError("access list expected to be [ address, storageKeys[] ]", `value[${index}]`, set);
|
|
98
121
|
}
|
|
99
122
|
return accessSetify(set[0], set[1]);
|
|
100
123
|
}
|
|
101
124
|
return accessSetify(set.address, set.storageKeys);
|
|
102
125
|
});
|
|
103
126
|
}
|
|
104
|
-
|
|
105
|
-
|
|
127
|
+
const result = Object.keys(value).map((addr) => {
|
|
128
|
+
const storageKeys = value[addr].reduce((accum, storageKey) => {
|
|
106
129
|
accum[storageKey] = true;
|
|
107
130
|
return accum;
|
|
108
131
|
}, {});
|
|
109
132
|
return accessSetify(addr, Object.keys(storageKeys).sort());
|
|
110
133
|
});
|
|
111
|
-
result.sort(
|
|
134
|
+
result.sort((a, b) => a.address.localeCompare(b.address));
|
|
112
135
|
return result;
|
|
113
136
|
}
|
|
114
|
-
exports.accessListify = accessListify;
|
|
115
137
|
function formatAccessList(value) {
|
|
116
|
-
return accessListify(value).map(
|
|
138
|
+
return accessListify(value).map((set) => [set.address, set.storageKeys]);
|
|
117
139
|
}
|
|
118
140
|
function _serializeEip1559(transaction, signature) {
|
|
119
141
|
// If there is an explicit gasPrice, make sure it matches the
|
|
120
142
|
// EIP-1559 fees; otherwise they may not understand what they
|
|
121
143
|
// think they are setting in terms of fee.
|
|
122
144
|
if (transaction.gasPrice != null) {
|
|
123
|
-
|
|
124
|
-
|
|
145
|
+
const gasPrice = bignumber_1.BigNumber.from(transaction.gasPrice);
|
|
146
|
+
const maxFeePerGas = bignumber_1.BigNumber.from(transaction.maxFeePerGas || 0);
|
|
125
147
|
if (!gasPrice.eq(maxFeePerGas)) {
|
|
126
148
|
logger.throwArgumentError("mismatch EIP-1559 gasPrice != maxFeePerGas", "tx", {
|
|
127
|
-
gasPrice
|
|
128
|
-
maxFeePerGas
|
|
149
|
+
gasPrice,
|
|
150
|
+
maxFeePerGas,
|
|
129
151
|
});
|
|
130
152
|
}
|
|
131
153
|
}
|
|
132
|
-
|
|
154
|
+
const fields = [
|
|
133
155
|
formatNumber(transaction.chainId || 0, "chainId"),
|
|
134
156
|
formatNumber(transaction.nonce || 0, "nonce"),
|
|
135
157
|
formatNumber(transaction.maxPriorityFeePerGas || 0, "maxPriorityFeePerGas"),
|
|
136
158
|
formatNumber(transaction.maxFeePerGas || 0, "maxFeePerGas"),
|
|
137
159
|
formatNumber(transaction.gasLimit || 0, "gasLimit"),
|
|
138
|
-
|
|
160
|
+
transaction.to != null ? (0, address_1.getAddress)(transaction.to) : "0x",
|
|
139
161
|
formatNumber(transaction.value || 0, "value"),
|
|
140
|
-
|
|
141
|
-
|
|
162
|
+
transaction.data || "0x",
|
|
163
|
+
formatAccessList(transaction.accessList || []),
|
|
142
164
|
];
|
|
143
165
|
if (signature) {
|
|
144
166
|
fields.push((0, bytes_1.joinSignature)(signature));
|
|
@@ -146,15 +168,15 @@ function _serializeEip1559(transaction, signature) {
|
|
|
146
168
|
return (0, bytes_1.hexConcat)(["0x02", RLP.encode(fields)]);
|
|
147
169
|
}
|
|
148
170
|
function _serializeEip2930(transaction, signature) {
|
|
149
|
-
|
|
171
|
+
const fields = [
|
|
150
172
|
formatNumber(transaction.chainId || 0, "chainId"),
|
|
151
173
|
formatNumber(transaction.nonce || 0, "nonce"),
|
|
152
174
|
formatNumber(transaction.gasPrice || 0, "gasPrice"),
|
|
153
175
|
formatNumber(transaction.gasLimit || 0, "gasLimit"),
|
|
154
|
-
|
|
176
|
+
transaction.to != null ? (0, address_1.getAddress)(transaction.to) : "0x",
|
|
155
177
|
formatNumber(transaction.value || 0, "value"),
|
|
156
|
-
|
|
157
|
-
|
|
178
|
+
transaction.data || "0x",
|
|
179
|
+
formatAccessList(transaction.accessList || []),
|
|
158
180
|
];
|
|
159
181
|
if (signature) {
|
|
160
182
|
fields.push((0, bytes_1.joinSignature)(signature));
|
|
@@ -164,32 +186,34 @@ function _serializeEip2930(transaction, signature) {
|
|
|
164
186
|
// Legacy Transactions and EIP-155
|
|
165
187
|
function _serialize(transaction, signature) {
|
|
166
188
|
(0, properties_1.checkProperties)(transaction, allowedTransactionKeys);
|
|
167
|
-
|
|
189
|
+
const raw = [];
|
|
168
190
|
transactionFields.forEach(function (fieldInfo) {
|
|
169
|
-
|
|
170
|
-
|
|
191
|
+
let value = transaction[fieldInfo.name] || [];
|
|
192
|
+
const options = {};
|
|
171
193
|
if (fieldInfo.numeric) {
|
|
172
194
|
options.hexPad = "left";
|
|
173
195
|
}
|
|
174
196
|
value = (0, bytes_1.arrayify)((0, bytes_1.hexlify)(value, options));
|
|
175
197
|
// Fixed-width field
|
|
176
|
-
if (fieldInfo.length &&
|
|
177
|
-
|
|
198
|
+
if (fieldInfo.length &&
|
|
199
|
+
value.length !== fieldInfo.length &&
|
|
200
|
+
value.length > 0) {
|
|
201
|
+
logger.throwArgumentError("invalid length for " + fieldInfo.name, "transaction:" + fieldInfo.name, value);
|
|
178
202
|
}
|
|
179
203
|
// Variable-width (with a maximum)
|
|
180
204
|
if (fieldInfo.maxLength) {
|
|
181
205
|
value = (0, bytes_1.stripZeros)(value);
|
|
182
206
|
if (value.length > fieldInfo.maxLength) {
|
|
183
|
-
logger.throwArgumentError("invalid length for " + fieldInfo.name,
|
|
207
|
+
logger.throwArgumentError("invalid length for " + fieldInfo.name, "transaction:" + fieldInfo.name, value);
|
|
184
208
|
}
|
|
185
209
|
}
|
|
186
210
|
raw.push((0, bytes_1.hexlify)(value));
|
|
187
211
|
});
|
|
188
|
-
|
|
212
|
+
let chainId = 0;
|
|
189
213
|
if (transaction.chainId != null) {
|
|
190
214
|
// A chainId was provided; if non-zero we'll use EIP-155
|
|
191
215
|
chainId = transaction.chainId;
|
|
192
|
-
if (typeof
|
|
216
|
+
if (typeof chainId !== "number") {
|
|
193
217
|
logger.throwArgumentError("invalid transaction.chainId", "transaction", transaction);
|
|
194
218
|
}
|
|
195
219
|
}
|
|
@@ -219,20 +243,19 @@ function serialize(transaction, signature) {
|
|
|
219
243
|
default:
|
|
220
244
|
break;
|
|
221
245
|
}
|
|
222
|
-
return logger.throwError(
|
|
246
|
+
return logger.throwError(`unsupported transaction type: ${transaction.type}`, logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
|
|
223
247
|
operation: "serializeTransaction",
|
|
224
|
-
transactionType: transaction.type
|
|
248
|
+
transactionType: transaction.type,
|
|
225
249
|
});
|
|
226
250
|
}
|
|
227
|
-
exports.serialize = serialize;
|
|
228
251
|
function _parseEip1559(payload) {
|
|
229
|
-
|
|
252
|
+
const transaction = RLP.decode(payload.slice(1));
|
|
230
253
|
if (transaction.length !== 9 && transaction.length !== 10) {
|
|
231
254
|
logger.throwArgumentError("invalid component count for transaction type: 2", "payload", (0, bytes_1.hexlify)(payload));
|
|
232
255
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
256
|
+
const maxPriorityFeePerGas = handleNumber(transaction[2]);
|
|
257
|
+
const maxFeePerGas = handleNumber(transaction[3]);
|
|
258
|
+
const tx = {
|
|
236
259
|
type: 2,
|
|
237
260
|
chainId: handleNumber(transaction[0]).toNumber(),
|
|
238
261
|
nonce: handleNumber(transaction[1]).toNumber(),
|
|
@@ -252,15 +275,14 @@ function _parseEip1559(payload) {
|
|
|
252
275
|
tx.hash = (0, keccak256_1.keccak256)(payload);
|
|
253
276
|
tx.signature = (0, bytes_1.splitSignature)(transaction.slice(9)[0]);
|
|
254
277
|
tx.from = computeAddress(tx.signature.publicKey);
|
|
255
|
-
;
|
|
256
278
|
return tx;
|
|
257
279
|
}
|
|
258
280
|
function _parseEip2930(payload) {
|
|
259
|
-
|
|
281
|
+
const transaction = RLP.decode(payload.slice(1));
|
|
260
282
|
if (transaction.length !== 8 && transaction.length !== 9) {
|
|
261
283
|
logger.throwArgumentError("invalid component count for transaction type: 1", "payload", (0, bytes_1.hexlify)(payload));
|
|
262
284
|
}
|
|
263
|
-
|
|
285
|
+
const tx = {
|
|
264
286
|
type: 1,
|
|
265
287
|
chainId: handleNumber(transaction[0]).toNumber(),
|
|
266
288
|
nonce: handleNumber(transaction[1]).toNumber(),
|
|
@@ -282,18 +304,20 @@ function _parseEip2930(payload) {
|
|
|
282
304
|
return tx;
|
|
283
305
|
}
|
|
284
306
|
function _parseLegacyAndEIP_155(rawTransaction) {
|
|
285
|
-
|
|
286
|
-
if (transaction.length !== 8 &&
|
|
307
|
+
const transaction = RLP.decode(rawTransaction);
|
|
308
|
+
if (transaction.length !== 8 &&
|
|
309
|
+
transaction.length !== 7 &&
|
|
310
|
+
transaction.length !== 6) {
|
|
287
311
|
logger.throwArgumentError("invalid raw transaction", "rawTransaction", rawTransaction);
|
|
288
312
|
}
|
|
289
|
-
|
|
313
|
+
const tx = {
|
|
290
314
|
nonce: handleNumber(transaction[0]).toNumber(),
|
|
291
315
|
gasPrice: handleNumber(transaction[1]),
|
|
292
316
|
gasLimit: handleNumber(transaction[2]),
|
|
293
317
|
to: handleAddress(transaction[3]),
|
|
294
318
|
value: handleNumber(transaction[4]),
|
|
295
319
|
data: transaction[5],
|
|
296
|
-
chainId: 0
|
|
320
|
+
chainId: 0,
|
|
297
321
|
};
|
|
298
322
|
tx.type = null;
|
|
299
323
|
//FIXME Rewrite this
|
|
@@ -301,13 +325,15 @@ function _parseLegacyAndEIP_155(rawTransaction) {
|
|
|
301
325
|
case 6: // Legacy unsigned transaction
|
|
302
326
|
break;
|
|
303
327
|
case 7: // Legacy signed transaction or EIP-155 unsigned transaction
|
|
304
|
-
|
|
305
|
-
if (temp.length == 6522) {
|
|
328
|
+
let temp = transaction.slice(6)[0];
|
|
329
|
+
if (temp.length == 6522) {
|
|
330
|
+
//Legacy signed transaction
|
|
306
331
|
tx.hash = (0, keccak256_1.keccak256)(rawTransaction);
|
|
307
332
|
tx.signature = (0, bytes_1.splitSignature)(temp);
|
|
308
333
|
tx.from = computeAddress(tx.signature.publicKey);
|
|
309
334
|
}
|
|
310
|
-
else {
|
|
335
|
+
else {
|
|
336
|
+
//EIP-155 unsigned transaction
|
|
311
337
|
tx.chainId = bignumber_1.BigNumber.from(temp).toNumber();
|
|
312
338
|
}
|
|
313
339
|
break;
|
|
@@ -323,7 +349,7 @@ function _parseLegacyAndEIP_155(rawTransaction) {
|
|
|
323
349
|
return tx;
|
|
324
350
|
}
|
|
325
351
|
function parse(rawTransaction) {
|
|
326
|
-
|
|
352
|
+
const payload = (0, bytes_1.arrayify)(rawTransaction);
|
|
327
353
|
// Legacy and EIP-155 Transactions
|
|
328
354
|
if (payload[0] > 0x7f) {
|
|
329
355
|
return _parseLegacyAndEIP_155(payload);
|
|
@@ -337,11 +363,9 @@ function parse(rawTransaction) {
|
|
|
337
363
|
default:
|
|
338
364
|
break;
|
|
339
365
|
}
|
|
340
|
-
return logger.throwError(
|
|
366
|
+
return logger.throwError(`unsupported transaction type: ${payload[0]}`, logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
|
|
341
367
|
operation: "parseTransaction",
|
|
342
|
-
transactionType: payload[0]
|
|
368
|
+
transactionType: payload[0],
|
|
343
369
|
});
|
|
344
370
|
}
|
|
345
|
-
exports.parse = parse;
|
|
346
|
-
[0x8004605941139387635763a13a795c4dfb9904beb9555e76629321312908dbd5 != 0x8004605941139387635763A13a795c4dfb9904bEb9555e76629321312908dbd5];
|
|
347
371
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src.ts/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;AAEb,yCAA2C;AAC3C,sDAAmE;AACnE,qCAA6J;AAC7J,sDAAgD;AAChD,sDAAqD;AACrD,wDAA4D;AAC5D,sDAA0C;AAE1C,gDAA+C;AAC/C,uCAAqC;AACrC,IAAM,MAAM,GAAG,IAAI,eAAM,CAAC,kBAAO,CAAC,CAAC;AAYnC,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IACxB,2DAAU,CAAA;IACV,6DAAW,CAAA;IACX,6DAAW,CAAA;AACf,CAAC,EAJW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAI3B;AAAA,CAAC;AAmDF,+BAA+B;AAE/B,SAAS,aAAa,CAAC,KAAa;IAChC,IAAI,KAAK,KAAK,IAAI,EAAE;QAAE,OAAO,IAAI,CAAC;KAAE;IACpC,OAAO,IAAA,oBAAU,EAAC,KAAK,CAAC,CAAC;AAC7B,CAAC;AAED,SAAS,YAAY,CAAC,KAAa;IAC/B,IAAI,KAAK,KAAK,IAAI,EAAE;QAAE,OAAO,gBAAI,CAAC;KAAE;IACpC,OAAO,qBAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACjC,CAAC;AAED,4BAA4B;AAC5B,IAAM,iBAAiB,GAAG;IACtB,EAAE,IAAI,EAAE,OAAO,EAAK,SAAS,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;IAClD,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;IAClD,EAAE,IAAI,E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c,CAAC,CAAC;IAEzC,kCAAkC;IAClC,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC;QACpB,OAAO,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;IAED,+BAA+B;IAC/B,QAAQ,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;QACjB,KAAK,CAAC;YACF,OAAO,aAAa,CAAC,OAAO,CAAC,CAAC;QAClC,KAAK,CAAC;YACF,OAAO,aAAa,CAAC,OAAO,CAAC,CAAC;QAClC;YACI,MAAM;IACd,CAAC;IAED,OAAO,MAAM,CAAC,UAAU,CACpB,iCAAiC,OAAO,CAAC,CAAC,CAAC,EAAE,EAC7C,eAAM,CAAC,MAAM,CAAC,qBAAqB,EACnC;QACI,SAAS,EAAE,kBAAkB;QAC7B,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC;KAC9B,CACJ,CAAC;AACN,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,31 +1,35 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"qethers"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
2
|
+
"contributors": [
|
|
3
|
+
"Eugene Kuleshov <kulevgen32@gmail.com>",
|
|
4
|
+
"Richard Moore <me@ricmoo.com>"
|
|
5
|
+
],
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"@qevm/address": "^5.7.3",
|
|
8
|
+
"@qevm/bignumber": "^5.7.1",
|
|
9
|
+
"@qevm/bytes": "^5.7.2",
|
|
10
|
+
"@qevm/constants": "^5.7.2",
|
|
11
|
+
"@qevm/keccak256": "^5.7.1",
|
|
12
|
+
"@qevm/logger": "^5.7.1",
|
|
13
|
+
"@qevm/properties": "^5.7.1",
|
|
14
|
+
"@qevm/rlp": "^5.7.1"
|
|
15
|
+
},
|
|
16
|
+
"description": "Utilities for decoding and encoding QuantumEVM transaction for qethers.",
|
|
17
|
+
"keywords": [
|
|
18
|
+
"QuantumEVM",
|
|
19
|
+
"QEVM",
|
|
20
|
+
"qethers"
|
|
21
|
+
],
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"main": "./lib/index.js",
|
|
24
|
+
"module": "./lib.esm/index.js",
|
|
25
|
+
"name": "@qevm/transactions",
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
31
|
+
},
|
|
32
|
+
"sideEffects": false,
|
|
33
|
+
"types": "./lib/index.d.ts",
|
|
34
|
+
"version": "5.7.3"
|
|
31
35
|
}
|
package/src.ts/_version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "transactions/5.7.
|
|
1
|
+
export const version = "transactions/5.7.3";
|
package/src.ts/index.ts
CHANGED
|
@@ -1,32 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { getAddress } from "@qevm/address";
|
|
4
|
-
import { BigNumber, BigNumberish } from "@
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
import { BigNumber, BigNumberish } from "@qevm/bignumber";
|
|
5
|
+
import {
|
|
6
|
+
arrayify,
|
|
7
|
+
BytesLike,
|
|
8
|
+
DataOptions,
|
|
9
|
+
hexConcat,
|
|
10
|
+
hexDataLength,
|
|
11
|
+
hexlify,
|
|
12
|
+
joinSignature,
|
|
13
|
+
SignatureLike,
|
|
14
|
+
splitSignature,
|
|
15
|
+
stripZeros,
|
|
16
|
+
} from "@qevm/bytes";
|
|
17
|
+
import { Zero } from "@qevm/constants";
|
|
18
|
+
import { keccak256 } from "@qevm/keccak256";
|
|
19
|
+
import { checkProperties } from "@qevm/properties";
|
|
20
|
+
import * as RLP from "@qevm/rlp";
|
|
21
|
+
|
|
22
|
+
import { Logger } from "@qevm/logger";
|
|
12
23
|
import { version } from "./_version";
|
|
13
24
|
const logger = new Logger(version);
|
|
14
25
|
|
|
15
26
|
///////////////////////////////
|
|
16
27
|
// Exported Types
|
|
17
28
|
|
|
18
|
-
export type AccessList = Array<{ address: string
|
|
29
|
+
export type AccessList = Array<{ address: string; storageKeys: Array<string> }>;
|
|
19
30
|
|
|
20
31
|
// Input allows flexibility in describing an access list
|
|
21
|
-
export type AccessListish =
|
|
22
|
-
|
|
23
|
-
|
|
32
|
+
export type AccessListish =
|
|
33
|
+
| AccessList
|
|
34
|
+
| Array<[string, Array<string>]>
|
|
35
|
+
| Record<string, Array<string>>;
|
|
24
36
|
|
|
25
37
|
export enum TransactionTypes {
|
|
26
38
|
legacy = 0,
|
|
27
39
|
eip2930 = 1,
|
|
28
40
|
eip1559 = 2,
|
|
29
|
-
}
|
|
41
|
+
}
|
|
30
42
|
|
|
31
43
|
export type UnsignedTransaction = {
|
|
32
44
|
to?: string;
|
|
@@ -48,7 +60,7 @@ export type UnsignedTransaction = {
|
|
|
48
60
|
// EIP-1559; Type 2
|
|
49
61
|
maxPriorityFeePerGas?: BigNumberish;
|
|
50
62
|
maxFeePerGas?: BigNumberish;
|
|
51
|
-
}
|
|
63
|
+
};
|
|
52
64
|
|
|
53
65
|
export interface Transaction {
|
|
54
66
|
hash?: string;
|
|
@@ -80,28 +92,39 @@ export interface Transaction {
|
|
|
80
92
|
///////////////////////////////
|
|
81
93
|
|
|
82
94
|
function handleAddress(value: string): string {
|
|
83
|
-
if (value === "0x") {
|
|
95
|
+
if (value === "0x") {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
84
98
|
return getAddress(value);
|
|
85
99
|
}
|
|
86
100
|
|
|
87
101
|
function handleNumber(value: string): BigNumber {
|
|
88
|
-
if (value === "0x") {
|
|
102
|
+
if (value === "0x") {
|
|
103
|
+
return Zero;
|
|
104
|
+
}
|
|
89
105
|
return BigNumber.from(value);
|
|
90
106
|
}
|
|
91
107
|
|
|
92
108
|
// Legacy Transaction Fields
|
|
93
109
|
const transactionFields = [
|
|
94
|
-
{ name: "nonce",
|
|
110
|
+
{ name: "nonce", maxLength: 32, numeric: true },
|
|
95
111
|
{ name: "gasPrice", maxLength: 32, numeric: true },
|
|
96
112
|
{ name: "gasLimit", maxLength: 32, numeric: true },
|
|
97
|
-
{ name: "to",
|
|
98
|
-
{ name: "value",
|
|
113
|
+
{ name: "to", length: 32 },
|
|
114
|
+
{ name: "value", maxLength: 32, numeric: true },
|
|
99
115
|
{ name: "data" },
|
|
100
116
|
];
|
|
101
117
|
|
|
102
|
-
const allowedTransactionKeys: { [
|
|
103
|
-
chainId: true,
|
|
104
|
-
|
|
118
|
+
const allowedTransactionKeys: { [key: string]: boolean } = {
|
|
119
|
+
chainId: true,
|
|
120
|
+
data: true,
|
|
121
|
+
gasLimit: true,
|
|
122
|
+
gasPrice: true,
|
|
123
|
+
nonce: true,
|
|
124
|
+
to: true,
|
|
125
|
+
type: true,
|
|
126
|
+
value: true,
|
|
127
|
+
};
|
|
105
128
|
|
|
106
129
|
export function computeAddress(publicKey: BytesLike | string): string {
|
|
107
130
|
return keccak256(publicKey);
|
|
@@ -115,52 +138,81 @@ export function recoverAddress(signature: SignatureLike): string {
|
|
|
115
138
|
function formatNumber(value: BigNumberish, name: string): Uint8Array {
|
|
116
139
|
const result = stripZeros(BigNumber.from(value).toHexString());
|
|
117
140
|
if (result.length > 32) {
|
|
118
|
-
logger.throwArgumentError(
|
|
141
|
+
logger.throwArgumentError(
|
|
142
|
+
"invalid length for " + name,
|
|
143
|
+
"transaction:" + name,
|
|
144
|
+
value,
|
|
145
|
+
);
|
|
119
146
|
}
|
|
120
147
|
return result;
|
|
121
148
|
}
|
|
122
149
|
|
|
123
|
-
function accessSetify(
|
|
150
|
+
function accessSetify(
|
|
151
|
+
addr: string,
|
|
152
|
+
storageKeys: Array<string>,
|
|
153
|
+
): { address: string; storageKeys: Array<string> } {
|
|
124
154
|
return {
|
|
125
155
|
address: getAddress(addr),
|
|
126
156
|
storageKeys: (storageKeys || []).map((storageKey, index) => {
|
|
127
157
|
if (hexDataLength(storageKey) !== 32) {
|
|
128
|
-
logger.throwArgumentError(
|
|
158
|
+
logger.throwArgumentError(
|
|
159
|
+
"invalid access list storageKey",
|
|
160
|
+
`accessList[${addr}:${index}]`,
|
|
161
|
+
storageKey,
|
|
162
|
+
);
|
|
129
163
|
}
|
|
130
164
|
return storageKey.toLowerCase();
|
|
131
|
-
})
|
|
165
|
+
}),
|
|
132
166
|
};
|
|
133
167
|
}
|
|
134
168
|
|
|
135
169
|
export function accessListify(value: AccessListish): AccessList {
|
|
136
170
|
if (Array.isArray(value)) {
|
|
137
|
-
return (<
|
|
171
|
+
return (<
|
|
172
|
+
Array<
|
|
173
|
+
| [string, Array<string>]
|
|
174
|
+
| { address: string; storageKeys: Array<string> }
|
|
175
|
+
>
|
|
176
|
+
>value).map((set, index) => {
|
|
138
177
|
if (Array.isArray(set)) {
|
|
139
178
|
if (set.length > 2) {
|
|
140
|
-
logger.throwArgumentError(
|
|
179
|
+
logger.throwArgumentError(
|
|
180
|
+
"access list expected to be [ address, storageKeys[] ]",
|
|
181
|
+
`value[${index}]`,
|
|
182
|
+
set,
|
|
183
|
+
);
|
|
141
184
|
}
|
|
142
|
-
return accessSetify(set[0], set[1])
|
|
185
|
+
return accessSetify(set[0], set[1]);
|
|
143
186
|
}
|
|
144
187
|
return accessSetify(set.address, set.storageKeys);
|
|
145
188
|
});
|
|
146
189
|
}
|
|
147
190
|
|
|
148
|
-
const result: Array<{ address: string
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
191
|
+
const result: Array<{ address: string; storageKeys: Array<string> }> =
|
|
192
|
+
Object.keys(value).map((addr) => {
|
|
193
|
+
const storageKeys: Record<string, true> = value[addr].reduce(
|
|
194
|
+
(accum, storageKey) => {
|
|
195
|
+
accum[storageKey] = true;
|
|
196
|
+
return accum;
|
|
197
|
+
},
|
|
198
|
+
<Record<string, true>>{},
|
|
199
|
+
);
|
|
200
|
+
return accessSetify(addr, Object.keys(storageKeys).sort());
|
|
201
|
+
});
|
|
202
|
+
result.sort((a, b) => a.address.localeCompare(b.address));
|
|
156
203
|
return result;
|
|
157
204
|
}
|
|
158
205
|
|
|
159
|
-
function formatAccessList(
|
|
160
|
-
|
|
206
|
+
function formatAccessList(
|
|
207
|
+
value: AccessListish,
|
|
208
|
+
): Array<[string, Array<string>]> {
|
|
209
|
+
return accessListify(value).map((set) => [set.address, set.storageKeys]);
|
|
161
210
|
}
|
|
162
211
|
|
|
163
|
-
function _serializeEip1559(
|
|
212
|
+
function _serializeEip1559(
|
|
213
|
+
transaction: UnsignedTransaction,
|
|
214
|
+
signature?: SignatureLike,
|
|
215
|
+
): string {
|
|
164
216
|
// If there is an explicit gasPrice, make sure it matches the
|
|
165
217
|
// EIP-1559 fees; otherwise they may not understand what they
|
|
166
218
|
// think they are setting in terms of fee.
|
|
@@ -168,72 +220,100 @@ function _serializeEip1559(transaction: UnsignedTransaction, signature?: Signatu
|
|
|
168
220
|
const gasPrice = BigNumber.from(transaction.gasPrice);
|
|
169
221
|
const maxFeePerGas = BigNumber.from(transaction.maxFeePerGas || 0);
|
|
170
222
|
if (!gasPrice.eq(maxFeePerGas)) {
|
|
171
|
-
logger.throwArgumentError(
|
|
172
|
-
gasPrice
|
|
173
|
-
|
|
223
|
+
logger.throwArgumentError(
|
|
224
|
+
"mismatch EIP-1559 gasPrice != maxFeePerGas",
|
|
225
|
+
"tx",
|
|
226
|
+
{
|
|
227
|
+
gasPrice,
|
|
228
|
+
maxFeePerGas,
|
|
229
|
+
},
|
|
230
|
+
);
|
|
174
231
|
}
|
|
175
232
|
}
|
|
176
233
|
|
|
177
234
|
const fields: any = [
|
|
178
235
|
formatNumber(transaction.chainId || 0, "chainId"),
|
|
179
236
|
formatNumber(transaction.nonce || 0, "nonce"),
|
|
180
|
-
formatNumber(
|
|
237
|
+
formatNumber(
|
|
238
|
+
transaction.maxPriorityFeePerGas || 0,
|
|
239
|
+
"maxPriorityFeePerGas",
|
|
240
|
+
),
|
|
181
241
|
formatNumber(transaction.maxFeePerGas || 0, "maxFeePerGas"),
|
|
182
242
|
formatNumber(transaction.gasLimit || 0, "gasLimit"),
|
|
183
|
-
|
|
243
|
+
transaction.to != null ? getAddress(transaction.to) : "0x",
|
|
184
244
|
formatNumber(transaction.value || 0, "value"),
|
|
185
|
-
|
|
186
|
-
|
|
245
|
+
transaction.data || "0x",
|
|
246
|
+
formatAccessList(transaction.accessList || []),
|
|
187
247
|
];
|
|
188
248
|
|
|
189
249
|
if (signature) {
|
|
190
|
-
fields.push(joinSignature(signature))
|
|
250
|
+
fields.push(joinSignature(signature));
|
|
191
251
|
}
|
|
192
252
|
|
|
193
|
-
return hexConcat([
|
|
253
|
+
return hexConcat(["0x02", RLP.encode(fields)]);
|
|
194
254
|
}
|
|
195
255
|
|
|
196
|
-
function _serializeEip2930(
|
|
256
|
+
function _serializeEip2930(
|
|
257
|
+
transaction: UnsignedTransaction,
|
|
258
|
+
signature?: SignatureLike,
|
|
259
|
+
): string {
|
|
197
260
|
const fields: any = [
|
|
198
261
|
formatNumber(transaction.chainId || 0, "chainId"),
|
|
199
262
|
formatNumber(transaction.nonce || 0, "nonce"),
|
|
200
263
|
formatNumber(transaction.gasPrice || 0, "gasPrice"),
|
|
201
264
|
formatNumber(transaction.gasLimit || 0, "gasLimit"),
|
|
202
|
-
|
|
265
|
+
transaction.to != null ? getAddress(transaction.to) : "0x",
|
|
203
266
|
formatNumber(transaction.value || 0, "value"),
|
|
204
|
-
|
|
205
|
-
|
|
267
|
+
transaction.data || "0x",
|
|
268
|
+
formatAccessList(transaction.accessList || []),
|
|
206
269
|
];
|
|
207
270
|
|
|
208
271
|
if (signature) {
|
|
209
272
|
fields.push(joinSignature(signature));
|
|
210
273
|
}
|
|
211
274
|
|
|
212
|
-
return hexConcat([
|
|
275
|
+
return hexConcat(["0x01", RLP.encode(fields)]);
|
|
213
276
|
}
|
|
214
277
|
|
|
215
278
|
// Legacy Transactions and EIP-155
|
|
216
|
-
function _serialize(
|
|
279
|
+
function _serialize(
|
|
280
|
+
transaction: UnsignedTransaction,
|
|
281
|
+
signature?: SignatureLike,
|
|
282
|
+
): string {
|
|
217
283
|
checkProperties(transaction, allowedTransactionKeys);
|
|
218
284
|
|
|
219
285
|
const raw: Array<string | Uint8Array> = [];
|
|
220
286
|
|
|
221
|
-
transactionFields.forEach(function(fieldInfo) {
|
|
222
|
-
let value = (<any>transaction)[fieldInfo.name] ||
|
|
223
|
-
const options: DataOptions = {
|
|
224
|
-
if (fieldInfo.numeric) {
|
|
287
|
+
transactionFields.forEach(function (fieldInfo) {
|
|
288
|
+
let value = (<any>transaction)[fieldInfo.name] || [];
|
|
289
|
+
const options: DataOptions = {};
|
|
290
|
+
if (fieldInfo.numeric) {
|
|
291
|
+
options.hexPad = "left";
|
|
292
|
+
}
|
|
225
293
|
value = arrayify(hexlify(value, options));
|
|
226
294
|
|
|
227
295
|
// Fixed-width field
|
|
228
|
-
if (
|
|
229
|
-
|
|
296
|
+
if (
|
|
297
|
+
fieldInfo.length &&
|
|
298
|
+
value.length !== fieldInfo.length &&
|
|
299
|
+
value.length > 0
|
|
300
|
+
) {
|
|
301
|
+
logger.throwArgumentError(
|
|
302
|
+
"invalid length for " + fieldInfo.name,
|
|
303
|
+
"transaction:" + fieldInfo.name,
|
|
304
|
+
value,
|
|
305
|
+
);
|
|
230
306
|
}
|
|
231
307
|
|
|
232
308
|
// Variable-width (with a maximum)
|
|
233
309
|
if (fieldInfo.maxLength) {
|
|
234
310
|
value = stripZeros(value);
|
|
235
311
|
if (value.length > fieldInfo.maxLength) {
|
|
236
|
-
logger.throwArgumentError(
|
|
312
|
+
logger.throwArgumentError(
|
|
313
|
+
"invalid length for " + fieldInfo.name,
|
|
314
|
+
"transaction:" + fieldInfo.name,
|
|
315
|
+
value,
|
|
316
|
+
);
|
|
237
317
|
}
|
|
238
318
|
}
|
|
239
319
|
|
|
@@ -245,8 +325,12 @@ function _serialize(transaction: UnsignedTransaction, signature?: SignatureLike)
|
|
|
245
325
|
// A chainId was provided; if non-zero we'll use EIP-155
|
|
246
326
|
chainId = transaction.chainId;
|
|
247
327
|
|
|
248
|
-
if (typeof
|
|
249
|
-
logger.throwArgumentError(
|
|
328
|
+
if (typeof chainId !== "number") {
|
|
329
|
+
logger.throwArgumentError(
|
|
330
|
+
"invalid transaction.chainId",
|
|
331
|
+
"transaction",
|
|
332
|
+
transaction,
|
|
333
|
+
);
|
|
250
334
|
}
|
|
251
335
|
}
|
|
252
336
|
|
|
@@ -262,11 +346,18 @@ function _serialize(transaction: UnsignedTransaction, signature?: SignatureLike)
|
|
|
262
346
|
return RLP.encode(raw);
|
|
263
347
|
}
|
|
264
348
|
|
|
265
|
-
export function serialize(
|
|
349
|
+
export function serialize(
|
|
350
|
+
transaction: UnsignedTransaction,
|
|
351
|
+
signature?: SignatureLike,
|
|
352
|
+
): string {
|
|
266
353
|
// Legacy and EIP-155 Transactions
|
|
267
354
|
if (transaction.type == null || transaction.type === 0) {
|
|
268
355
|
if (transaction.accessList != null) {
|
|
269
|
-
logger.throwArgumentError(
|
|
356
|
+
logger.throwArgumentError(
|
|
357
|
+
"untyped transactions do not support accessList; include type: 1",
|
|
358
|
+
"transaction",
|
|
359
|
+
transaction,
|
|
360
|
+
);
|
|
270
361
|
}
|
|
271
362
|
return _serialize(transaction, signature);
|
|
272
363
|
}
|
|
@@ -281,17 +372,25 @@ export function serialize(transaction: UnsignedTransaction, signature?: Signatur
|
|
|
281
372
|
break;
|
|
282
373
|
}
|
|
283
374
|
|
|
284
|
-
return logger.throwError(
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
375
|
+
return logger.throwError(
|
|
376
|
+
`unsupported transaction type: ${transaction.type}`,
|
|
377
|
+
Logger.errors.UNSUPPORTED_OPERATION,
|
|
378
|
+
{
|
|
379
|
+
operation: "serializeTransaction",
|
|
380
|
+
transactionType: transaction.type,
|
|
381
|
+
},
|
|
382
|
+
);
|
|
288
383
|
}
|
|
289
384
|
|
|
290
385
|
function _parseEip1559(payload: Uint8Array): Transaction {
|
|
291
386
|
const transaction = RLP.decode(payload.slice(1));
|
|
292
387
|
|
|
293
388
|
if (transaction.length !== 9 && transaction.length !== 10) {
|
|
294
|
-
logger.throwArgumentError(
|
|
389
|
+
logger.throwArgumentError(
|
|
390
|
+
"invalid component count for transaction type: 2",
|
|
391
|
+
"payload",
|
|
392
|
+
hexlify(payload),
|
|
393
|
+
);
|
|
295
394
|
}
|
|
296
395
|
|
|
297
396
|
const maxPriorityFeePerGas = handleNumber(transaction[2]);
|
|
@@ -311,11 +410,13 @@ function _parseEip1559(payload: Uint8Array): Transaction {
|
|
|
311
410
|
};
|
|
312
411
|
|
|
313
412
|
// Unsigned EIP-1559 Transaction
|
|
314
|
-
if (transaction.length === 9) {
|
|
413
|
+
if (transaction.length === 9) {
|
|
414
|
+
return tx;
|
|
415
|
+
}
|
|
315
416
|
|
|
316
417
|
tx.hash = keccak256(payload);
|
|
317
418
|
tx.signature = splitSignature(transaction.slice(9)[0]);
|
|
318
|
-
tx.from = computeAddress(tx.signature.publicKey)
|
|
419
|
+
tx.from = computeAddress(tx.signature.publicKey);
|
|
319
420
|
|
|
320
421
|
return tx;
|
|
321
422
|
}
|
|
@@ -324,7 +425,11 @@ function _parseEip2930(payload: Uint8Array): Transaction {
|
|
|
324
425
|
const transaction = RLP.decode(payload.slice(1));
|
|
325
426
|
|
|
326
427
|
if (transaction.length !== 8 && transaction.length !== 9) {
|
|
327
|
-
logger.throwArgumentError(
|
|
428
|
+
logger.throwArgumentError(
|
|
429
|
+
"invalid component count for transaction type: 1",
|
|
430
|
+
"payload",
|
|
431
|
+
hexlify(payload),
|
|
432
|
+
);
|
|
328
433
|
}
|
|
329
434
|
|
|
330
435
|
const tx: Transaction = {
|
|
@@ -341,7 +446,9 @@ function _parseEip2930(payload: Uint8Array): Transaction {
|
|
|
341
446
|
};
|
|
342
447
|
|
|
343
448
|
// Unsigned EIP-2930 Transaction
|
|
344
|
-
if (transaction.length === 8) {
|
|
449
|
+
if (transaction.length === 8) {
|
|
450
|
+
return tx;
|
|
451
|
+
}
|
|
345
452
|
|
|
346
453
|
tx.hash = keccak256(payload);
|
|
347
454
|
tx.signature = splitSignature(transaction.slice(8)[0]);
|
|
@@ -353,8 +460,16 @@ function _parseEip2930(payload: Uint8Array): Transaction {
|
|
|
353
460
|
function _parseLegacyAndEIP_155(rawTransaction: Uint8Array): Transaction {
|
|
354
461
|
const transaction = RLP.decode(rawTransaction);
|
|
355
462
|
|
|
356
|
-
if (
|
|
357
|
-
|
|
463
|
+
if (
|
|
464
|
+
transaction.length !== 8 &&
|
|
465
|
+
transaction.length !== 7 &&
|
|
466
|
+
transaction.length !== 6
|
|
467
|
+
) {
|
|
468
|
+
logger.throwArgumentError(
|
|
469
|
+
"invalid raw transaction",
|
|
470
|
+
"rawTransaction",
|
|
471
|
+
rawTransaction,
|
|
472
|
+
);
|
|
358
473
|
}
|
|
359
474
|
|
|
360
475
|
const tx: Transaction = {
|
|
@@ -364,7 +479,7 @@ function _parseLegacyAndEIP_155(rawTransaction: Uint8Array): Transaction {
|
|
|
364
479
|
to: handleAddress(transaction[3]),
|
|
365
480
|
value: handleNumber(transaction[4]),
|
|
366
481
|
data: transaction[5],
|
|
367
|
-
chainId: 0
|
|
482
|
+
chainId: 0,
|
|
368
483
|
};
|
|
369
484
|
|
|
370
485
|
tx.type = null;
|
|
@@ -374,16 +489,17 @@ function _parseLegacyAndEIP_155(rawTransaction: Uint8Array): Transaction {
|
|
|
374
489
|
case 6: // Legacy unsigned transaction
|
|
375
490
|
break;
|
|
376
491
|
case 7: // Legacy signed transaction or EIP-155 unsigned transaction
|
|
377
|
-
|
|
378
492
|
let temp = transaction.slice(6)[0];
|
|
379
|
-
if(temp.length == 6522){
|
|
493
|
+
if (temp.length == 6522) {
|
|
494
|
+
//Legacy signed transaction
|
|
380
495
|
tx.hash = keccak256(rawTransaction);
|
|
381
496
|
tx.signature = splitSignature(temp);
|
|
382
497
|
tx.from = computeAddress(tx.signature.publicKey);
|
|
383
|
-
}else{
|
|
498
|
+
} else {
|
|
499
|
+
//EIP-155 unsigned transaction
|
|
384
500
|
tx.chainId = BigNumber.from(temp).toNumber();
|
|
385
501
|
}
|
|
386
|
-
|
|
502
|
+
|
|
387
503
|
break;
|
|
388
504
|
|
|
389
505
|
case 8: // // EIP-155 signed transaction
|
|
@@ -404,7 +520,9 @@ export function parse(rawTransaction: BytesLike): Transaction {
|
|
|
404
520
|
const payload = arrayify(rawTransaction);
|
|
405
521
|
|
|
406
522
|
// Legacy and EIP-155 Transactions
|
|
407
|
-
if (payload[0] > 0x7f) {
|
|
523
|
+
if (payload[0] > 0x7f) {
|
|
524
|
+
return _parseLegacyAndEIP_155(payload);
|
|
525
|
+
}
|
|
408
526
|
|
|
409
527
|
// Typed Transaction (EIP-2718)
|
|
410
528
|
switch (payload[0]) {
|
|
@@ -416,10 +534,12 @@ export function parse(rawTransaction: BytesLike): Transaction {
|
|
|
416
534
|
break;
|
|
417
535
|
}
|
|
418
536
|
|
|
419
|
-
return logger.throwError(
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
537
|
+
return logger.throwError(
|
|
538
|
+
`unsupported transaction type: ${payload[0]}`,
|
|
539
|
+
Logger.errors.UNSUPPORTED_OPERATION,
|
|
540
|
+
{
|
|
541
|
+
operation: "parseTransaction",
|
|
542
|
+
transactionType: payload[0],
|
|
543
|
+
},
|
|
544
|
+
);
|
|
423
545
|
}
|
|
424
|
-
|
|
425
|
-
[0x8004605941139387635763a13a795c4dfb9904beb9555e76629321312908dbd5 != 0x8004605941139387635763A13a795c4dfb9904bEb9555e76629321312908dbd5]
|