Fix TransactionResponse to have chainId instead of legacy networkId (#700).
This commit is contained in:
parent
4151c0eacd
commit
72b3bc9909
@ -328,29 +328,40 @@ export class Formatter {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let result = Formatter.check(this.formats.transaction, transaction);
|
let result: TransactionResponse = Formatter.check(this.formats.transaction, transaction);
|
||||||
|
|
||||||
let networkId = transaction.networkId;
|
if (transaction.chainId != null) {
|
||||||
|
let chainId = transaction.chainId;
|
||||||
|
|
||||||
// geth-etc returns chainId
|
if (isHexString(chainId)) {
|
||||||
if (transaction.chainId != null && networkId == null && result.v == null) {
|
chainId = BigNumber.from(chainId).toNumber();
|
||||||
networkId = transaction.chainId;
|
}
|
||||||
|
|
||||||
|
result.chainId = chainId;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
let chainId = transaction.networkId;
|
||||||
|
|
||||||
|
// geth-etc returns chainId
|
||||||
|
if (chainId == null && result.v == null) {
|
||||||
|
chainId = transaction.chainId;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isHexString(chainId)) {
|
||||||
|
chainId = BigNumber.from(chainId).toNumber();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof(chainId) !== "number" && result.v != null) {
|
||||||
|
chainId = (result.v - 35) / 2;
|
||||||
|
if (chainId < 0) { chainId = 0; }
|
||||||
|
chainId = parseInt(chainId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof(chainId) !== "number") { chainId = 0; }
|
||||||
|
|
||||||
|
result.chainId = chainId;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isHexString(networkId)) {
|
|
||||||
networkId = BigNumber.from(networkId).toNumber();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof(networkId) !== "number" && result.v != null) {
|
|
||||||
networkId = (result.v - 35) / 2;
|
|
||||||
if (networkId < 0) { networkId = 0; }
|
|
||||||
networkId = parseInt(networkId);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof(networkId) !== "number") { networkId = 0; }
|
|
||||||
|
|
||||||
result.networkId = networkId;
|
|
||||||
|
|
||||||
// 0x0000... should actually be null
|
// 0x0000... should actually be null
|
||||||
if (result.blockHash && result.blockHash.replace(/0/g, "") === "x") {
|
if (result.blockHash && result.blockHash.replace(/0/g, "") === "x") {
|
||||||
result.blockHash = null;
|
result.blockHash = null;
|
||||||
|
Loading…
Reference in New Issue
Block a user