@railgun-community/shared-models 3.7.5 → 3.7.6
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
|
@@ -35,9 +35,15 @@ exports.serializeUnsignedTransaction = serializeUnsignedTransaction;
|
|
|
35
35
|
// return serialize(transaction, signature);
|
|
36
36
|
// };
|
|
37
37
|
var deserializeTransaction = function (rawTransaction, nonce, chainId) {
|
|
38
|
-
var _a;
|
|
38
|
+
var _a, _b, _c, _d, _e;
|
|
39
39
|
var transaction = (0, transactions_1.parse)(rawTransaction);
|
|
40
|
-
return __assign(__assign({}, transaction), { type: (_a = transaction.type) !== null && _a !== void 0 ? _a : undefined, nonce: nonce, chainId: chainId
|
|
40
|
+
return __assign(__assign({}, transaction), { type: (_a = transaction.type) !== null && _a !== void 0 ? _a : undefined, nonce: nonce, chainId: chainId,
|
|
41
|
+
// Set gas-related vars as undefined if they're zero.
|
|
42
|
+
gasLimit: ((_b = transaction.gasLimit) === null || _b === void 0 ? void 0 : _b.eq(0)) ? undefined : transaction.gasLimit, gasPrice: ((_c = transaction.gasPrice) === null || _c === void 0 ? void 0 : _c.eq(0)) ? undefined : transaction.gasPrice, maxFeePerGas: ((_d = transaction.maxFeePerGas) === null || _d === void 0 ? void 0 : _d.eq(0))
|
|
43
|
+
? undefined
|
|
44
|
+
: transaction.maxFeePerGas, maxPriorityFeePerGas: ((_e = transaction.maxPriorityFeePerGas) === null || _e === void 0 ? void 0 : _e.eq(0))
|
|
45
|
+
? undefined
|
|
46
|
+
: transaction.maxPriorityFeePerGas });
|
|
41
47
|
};
|
|
42
48
|
exports.deserializeTransaction = deserializeTransaction;
|
|
43
49
|
//# sourceMappingURL=serializer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../../src/utils/serializer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,4DAA4E;AAE5E,2DAAs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M,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;QAEP,qDAAqD;QACrD,QAAQ,EAAE,CAAA,MAAA,WAAW,CAAC,QAAQ,0CAAE,EAAE,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,EACxE,QAAQ,EAAE,CAAA,MAAA,WAAW,CAAC,QAAQ,0CAAE,EAAE,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,EACxE,YAAY,EAAE,CAAA,MAAA,WAAW,CAAC,YAAY,0CAAE,EAAE,CAAC,CAAC,CAAC;YAC3C,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,WAAW,CAAC,YAAY,EAC5B,oBAAoB,EAAE,CAAA,MAAA,WAAW,CAAC,oBAAoB,0CAAE,EAAE,CAAC,CAAC,CAAC;YAC3D,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,WAAW,CAAC,oBAAoB,IACpC;AACJ,CAAC,CAAC;AAtBW,QAAA,sBAAsB,0BAsBjC","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 // Set gas-related vars as undefined if they're zero.\n gasLimit: transaction.gasLimit?.eq(0) ? undefined : transaction.gasLimit,\n gasPrice: transaction.gasPrice?.eq(0) ? undefined : transaction.gasPrice,\n maxFeePerGas: transaction.maxFeePerGas?.eq(0)\n ? undefined\n : transaction.maxFeePerGas,\n maxPriorityFeePerGas: transaction.maxPriorityFeePerGas?.eq(0)\n ? undefined\n : transaction.maxPriorityFeePerGas,\n };\n};\n"]}
|