Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit fbfbbca

Browse files
committed
Debug - minimal code refactor
1 parent 146b096 commit fbfbbca

File tree

1 file changed

+63
-60
lines changed

1 file changed

+63
-60
lines changed

packages/web3-core-method/src/index.js

+63-60
Original file line numberDiff line numberDiff line change
@@ -770,67 +770,27 @@ Method.prototype.buildCall = function () {
770770
return method.requestManager.send(payload, sendTxCallback);
771771
};
772772

773-
// Send the actual transaction
774-
if (isSendTx
775-
&& !!payload.params[0]
776-
&& typeof payload.params[0] === 'object'
777-
&& typeof payload.params[0].gasPrice === 'undefined'
778-
) {
779-
780-
var getGasPrice = (new Method({
781-
name: 'getGasPrice',
782-
call: 'eth_gasPrice',
783-
params: 0
784-
})).createFunction(method.requestManager);
785-
786-
getGasPrice(function (err, gasPrice) {
787-
console.log('debug1', gasPrice, payload)
788-
789-
if (gasPrice) {
790-
payload.params[0].gasPrice = gasPrice;
791-
}
792-
793-
console.log('debug2', gasPrice, payload)
794-
795-
if (isSendTx) {
796-
setTimeout(() => {
797-
defer.eventEmitter.emit('sending', payload);
798-
}, 0);
799-
}
800-
801-
sendRequest(payload, method);
802-
});
803-
804-
} else {
805-
if (isSendTx) {
806-
setTimeout(() => {
807-
defer.eventEmitter.emit('sending', payload);
808-
}, 0);
809-
}
810-
811-
sendRequest(payload, method);
812-
}
813-
814773
// Send the actual transaction
815774
// if (isSendTx
816775
// && !!payload.params[0]
817776
// && typeof payload.params[0] === 'object'
818777
// && typeof payload.params[0].gasPrice === 'undefined'
819-
// // && (
820-
// // typeof payload.params[0].gasPrice === 'undefined'
821-
// // && (
822-
// // typeof payload.params[0].maxPriorityFeePerGas === 'undefined'
823-
// // || typeof payload.params[0].maxFeePerGas === 'undefined'
824-
// // )
825-
// // )
826778
// ) {
827-
// // if (typeof payload.params[0].type === 'undefined')
828-
// // payload.params[0].type = _handleTxType(payload.params[0]);
829779

830-
// _handleTxPricing(method, payload.params[0]).then(txPricing => {
831-
// console.log('debug1', payload)
832-
// payload.params[0] = {...payload.params[0], ...txPricing};
833-
// console.log('debug2', payload)
780+
// var getGasPrice = (new Method({
781+
// name: 'getGasPrice',
782+
// call: 'eth_gasPrice',
783+
// params: 0
784+
// })).createFunction(method.requestManager);
785+
786+
// getGasPrice(function (err, gasPrice) {
787+
// console.log('debug1', gasPrice, payload)
788+
789+
// if (gasPrice) {
790+
// payload.params[0].gasPrice = gasPrice;
791+
// }
792+
793+
// console.log('debug2', gasPrice, payload)
834794

835795
// if (isSendTx) {
836796
// setTimeout(() => {
@@ -839,7 +799,8 @@ Method.prototype.buildCall = function () {
839799
// }
840800

841801
// sendRequest(payload, method);
842-
// })
802+
// });
803+
843804
// } else {
844805
// if (isSendTx) {
845806
// setTimeout(() => {
@@ -850,11 +811,53 @@ Method.prototype.buildCall = function () {
850811
// sendRequest(payload, method);
851812
// }
852813

853-
// if (isSendTx) {
854-
// setTimeout(() => {
855-
// defer.eventEmitter.emit('sent', payload);
856-
// }, 0);
857-
// }
814+
// Send the actual transaction
815+
if (isSendTx
816+
&& !!payload.params[0]
817+
&& typeof payload.params[0] === 'object'
818+
&& typeof payload.params[0].gasPrice === 'undefined'
819+
// && (
820+
// typeof payload.params[0].gasPrice === 'undefined'
821+
// && (
822+
// typeof payload.params[0].maxPriorityFeePerGas === 'undefined'
823+
// || typeof payload.params[0].maxFeePerGas === 'undefined'
824+
// )
825+
// )
826+
) {
827+
// if (typeof payload.params[0].type === 'undefined')
828+
// payload.params[0].type = _handleTxType(payload.params[0]);
829+
830+
_handleTxPricing(method, payload.params[0]).then(txPricing => {
831+
console.log('debug1', payload)
832+
console.log('debug3', txPricing)
833+
if (txPricing.gasPrice)
834+
payload.params[0].gasPrice = txPricing.gasPrice;
835+
// payload.params[0] = {...payload.params[0], ...txPricing};
836+
console.log('debug2', payload)
837+
838+
if (isSendTx) {
839+
setTimeout(() => {
840+
defer.eventEmitter.emit('sending', payload);
841+
}, 0);
842+
}
843+
844+
sendRequest(payload, method);
845+
})
846+
} else {
847+
if (isSendTx) {
848+
setTimeout(() => {
849+
defer.eventEmitter.emit('sending', payload);
850+
}, 0);
851+
}
852+
853+
sendRequest(payload, method);
854+
}
855+
856+
if (isSendTx) {
857+
setTimeout(() => {
858+
defer.eventEmitter.emit('sent', payload);
859+
}, 0);
860+
}
858861

859862
return defer.eventEmitter;
860863
};

0 commit comments

Comments
 (0)