@railgun-community/shared-models 3.2.1 → 3.2.2
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/dist/utils/serializer.js
CHANGED
|
@@ -13,10 +13,14 @@ var __assign = (this && this.__assign) || function () {
|
|
|
13
13
|
exports.__esModule = true;
|
|
14
14
|
exports.deserializeTransaction = exports.serializeUnsignedTransaction = void 0;
|
|
15
15
|
var transactions_1 = require("@ethersproject/transactions");
|
|
16
|
+
var network_config_1 = require("../models/network-config");
|
|
16
17
|
var validatePreserialize = function (transaction) {
|
|
17
18
|
if (transaction.from) {
|
|
18
19
|
throw new Error("Cannot serialize 'from' field on transaction.");
|
|
19
20
|
}
|
|
21
|
+
if (transaction.type === network_config_1.EVMGasType.Type0 && transaction.accessList) {
|
|
22
|
+
throw new Error("Cannot serialize 'accessList' field on Type0 transaction.");
|
|
23
|
+
}
|
|
20
24
|
};
|
|
21
25
|
var serializeUnsignedTransaction = function (transaction) {
|
|
22
26
|
validatePreserialize(transaction);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../../src/utils/serializer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,4DAA4E;
|
|
1
|
+
{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../../src/utils/serializer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,4DAA4E;AAE5E,2DAAsD;AAEtD,IAAM,oBAAoB,GAAG,UAAC,WAAiC;IAC7D,IAAI,WAAW,CAAC,IAAI,EAAE;QACpB,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;KAClE;IACD,IAAI,WAAW,CAAC,IAAI,KAAK,2BAAU,CAAC,KAAK,IAAI,WAAW,CAAC,UAAU,EAAE;QACnE,MAAM,IAAI,KAAK,CACb,2DAA2D,CAC5D,CAAC;KACH;AACH,CAAC,CAAC;AAEK,IAAM,4BAA4B,GAAG,UAC1C,WAAiC;IAEjC,oBAAoB,CAAC,WAAW,CAAC,CAAC;IAClC,OAAO,IAAA,wBAAS,EAAC,WAAW,CAAC,CAAC;AAChC,CAAC,CAAC;AALW,QAAA,4BAA4B,gCAKvC;AAEF,8CAA8C;AAC9C,uCAAuC;AACvC,8BAA8B;AAC9B,iBAAiB;AACjB,uCAAuC;AACvC,8CAA8C;AAC9C,KAAK;AAEE,IAAM,sBAAsB,GAAG,UACpC,cAAsB,EACtB,KAAuB,EACvB,OAAe;;IAEf,IAAM,WAAW,GAAgB,IAAA,oBAAK,EAAC,cAAc,CAAC,CAAC;IACvD,6BACK,WAAW,KACd,IAAI,EAAE,MAAA,WAAW,CAAC,IAAI,mCAAI,SAAS,EACnC,KAAK,OAAA,EACL,OAAO,SAAA,IACP;AACJ,CAAC,CAAC;AAZW,QAAA,sBAAsB,0BAYjC","sourcesContent":["import { PopulatedTransaction } from '@ethersproject/contracts';\nimport { parse, serialize, Transaction } from '@ethersproject/transactions';\nimport { TransactionRequest } from '@ethersproject/providers';\nimport { EVMGasType } from '../models/network-config';\n\nconst validatePreserialize = (transaction: PopulatedTransaction) => {\n if (transaction.from) {\n throw new Error(`Cannot serialize 'from' field on transaction.`);\n }\n if (transaction.type === EVMGasType.Type0 && transaction.accessList) {\n throw new Error(\n `Cannot serialize 'accessList' field on Type0 transaction.`,\n );\n }\n};\n\nexport const serializeUnsignedTransaction = (\n transaction: PopulatedTransaction,\n): string => {\n validatePreserialize(transaction);\n return serialize(transaction);\n};\n\n// export const serializeSignedTransaction = (\n// transaction: PopulatedTransaction,\n// signature: SignatureLike,\n// ): string => {\n// validatePreserialize(transaction);\n// return serialize(transaction, signature);\n// };\n\nexport const deserializeTransaction = (\n rawTransaction: string,\n nonce: Optional<number>,\n chainId: number,\n): TransactionRequest => {\n const transaction: Transaction = parse(rawTransaction);\n return {\n ...transaction,\n type: transaction.type ?? undefined,\n nonce,\n chainId,\n };\n};\n"]}
|