@railgun-community/shared-models 3.9.3 → 3.9.4

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.
@@ -37,13 +37,20 @@ exports.serializeUnsignedTransaction = serializeUnsignedTransaction;
37
37
  var deserializeTransaction = function (rawTransaction, nonce, chainId) {
38
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 cleanTransaction(__assign(__assign({}, transaction), { type: (_a = transaction.type) !== null && _a !== void 0 ? _a : undefined, nonce: nonce, chainId: chainId,
41
41
  // Set gas-related vars as undefined if they're zero.
42
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
43
  ? undefined
44
44
  : transaction.maxFeePerGas, maxPriorityFeePerGas: ((_e = transaction.maxPriorityFeePerGas) === null || _e === void 0 ? void 0 : _e.eq(0))
45
45
  ? undefined
46
- : transaction.maxPriorityFeePerGas });
46
+ : transaction.maxPriorityFeePerGas }));
47
47
  };
48
48
  exports.deserializeTransaction = deserializeTransaction;
49
+ var cleanTransaction = function (tx) {
50
+ // Remove keys that have an undefined value
51
+ return Object.fromEntries(Object.entries(tx).filter(function (_a) {
52
+ var _k = _a[0], v = _a[1];
53
+ return v !== undefined;
54
+ }));
55
+ };
49
56
  //# sourceMappingURL=serializer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"serializer.js","sourceRoot":"","sources":["../../src/utils/serializer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,4DAA4E;AAE5E,2DAAsD;AAEtD,IAA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Y,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/response-types';\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"]}
1
+ {"version":3,"file":"serializer.js","sourceRoot":"","sources":["../../src/utils/serializer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,4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AAC,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,CAAC;AACL,CAAC,CAAC;AAtBW,QAAA,sBAAsB,0BAsBjC;AAEF,IAAM,gBAAgB,GAAG,UAAC,EAAsB;IAC9C,2CAA2C;IAC3C,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,UAAC,EAAO;YAAN,EAAE,QAAA,EAAE,CAAC,QAAA;QAAM,OAAA,CAAC,KAAK,SAAS;IAAf,CAAe,CAAC,CACxD,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { PopulatedTransaction } from '@ethersproject/contracts';\nimport { parse, serialize, Transaction } from '@ethersproject/transactions';\nimport { TransactionRequest } from '@ethersproject/providers';\nimport { EVMGasType } from '../models/response-types';\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 cleanTransaction({\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\nconst cleanTransaction = (tx: TransactionRequest): TransactionRequest => {\n // Remove keys that have an undefined value\n return Object.fromEntries(\n Object.entries(tx).filter(([_k, v]) => v !== undefined),\n );\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@railgun-community/shared-models",
3
- "version": "3.9.3",
3
+ "version": "3.9.4",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "files": [