Skip to content

Commit 09adb23

Browse files
committed
Revert "fix: renamed COULD_NOT_ESTIMATE_GAS_PRICE to COULD_NOT_SIMULATE_TRANSACTION"
This reverts commit 5e834c7.
1 parent a6949d9 commit 09adb23

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

packages/relay/src/lib/errors/JsonRpcError.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,10 @@ export const predefined = {
196196
message: message,
197197
});
198198
},
199-
COULD_NOT_SIMULATE_TRANSACTION: (errMessage: string) => {
199+
COULD_NOT_ESTIMATE_GAS_PRICE: (errMessage: string) => {
200200
return new JsonRpcError({
201201
code: -32000,
202-
message: `Error occurred during transaction simulation: ${errMessage}`,
202+
message: `Error occurred during gas price estimation: ${errMessage}`,
203203
});
204204
},
205205
COULD_NOT_RETRIEVE_LATEST_BLOCK: new JsonRpcError({

packages/relay/src/lib/services/ethService/contractService/ContractService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,11 @@ export class ContractService implements IContractService {
180180
if (e.isContractRevert()) {
181181
throw predefined.CONTRACT_REVERT(e.detail || e.message, e.data);
182182
} else if (e.statusCode === 400) {
183-
throw predefined.COULD_NOT_SIMULATE_TRANSACTION(e.detail || e.message);
183+
throw predefined.COULD_NOT_ESTIMATE_GAS_PRICE(e.detail || e.message);
184184
}
185185
}
186186

187-
// for any other error or Mirror Node upstream server errors (429, 500, 502, 503, 504, etc.), preserve the original error and re-throw to the upper layer for further handling logic
187+
// for any other errors, preserve and re-throw to the upper layer as more mapping logic may be applied there
188188
throw e;
189189
}
190190
}

packages/relay/tests/lib/eth/eth_estimateGas.spec.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ describe('@ethEstimateGas Estimate Gas spec', async function () {
6262
};
6363
const id = uuid();
6464
const defaultGasOverride = constants.TX_DEFAULT_GAS_DEFAULT + 1;
65-
const gasPriceErrorMessage = 'Error occurred during transaction simulation';
65+
const gasPriceErrorMessage = 'Error occurred during gas price estimation';
6666

6767
overrideEnvsInMochaDescribe({
6868
ETH_GET_TRANSACTION_COUNT_MAX_BLOCK_RANGE: 1,
@@ -94,7 +94,7 @@ describe('@ethEstimateGas Estimate Gas spec', async function () {
9494

9595
describe('eth_estimateGas with contract call', async function () {});
9696

97-
it('should eth_estimateGas with transaction.data null throws COULD_NOT_SIMULATE_TRANSACTION error on 400', async function () {
97+
it('should eth_estimateGas with transaction.data null throws COULD_NOT_ESTIMATE_GAS_PRICE error on 400', async function () {
9898
const callData: IContractCallRequest = {
9999
from: '0x05fba803be258049a27b820088bab1cad2058871',
100100
value: '0x0',
@@ -109,7 +109,7 @@ describe('@ethEstimateGas Estimate Gas spec', async function () {
109109
);
110110
});
111111

112-
it('should eth_estimateGas to mirror node for contract call returns 400 throws COULD_NOT_SIMULATE_TRANSACTION error', async function () {
112+
it('should eth_estimateGas to mirror node for contract call returns 400 throws COULD_NOT_ESTIMATE_GAS_PRICE error', async function () {
113113
const callData: IContractCallRequest = {
114114
data: '0x608060405234801561001057600080fd5b506040516107893803806107898339818101604052810190610032919061015a565b806000908051906020019061004892919061004f565b50506102f6565b82805461005b90610224565b90600052602060002090601f01602090048101928261007d57600085556100c4565b82601f1061009657805160ff19168380011785556100c4565b828001600101855582156100c4579182015b828111156100c35782518255916020019190600101906100a8565b5b5090506100d191906100d5565b5090565b5b808211156100ee5760008160009055506001016100d6565b5090565b6000610105610100846101c0565b61019b565b90508281526020810184848401111561011d57600080fd5b6101288482856101f1565b509392505050565b600082601f83011261014157600080fd5b81516101518482602086016100f2565b91505092915050565b60006020828403121561016c57600080fd5b600082015167ffffffffffffffff81111561018657600080fd5b61019284828501610130565b91505092915050565b60006101a56101b6565b90506101b18282610256565b919050565b6000604051905090565b600067ffffffffffffffff8211156101db576101da6102b6565b5b6101e4826102e5565b9050602081019050919050565b60005b8381101561020f5780820151818401526020810190506101f4565b8381111561021e576000848401525b50505050565b6000600282049050600182168061023c57607f821691505b602082108114156102505761024f610287565b5b50919050565b61025f826102e5565b810181811067ffffffffffffffff8211171561027e5761027d6102b6565b5b80604052505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b610484806103056000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063a41368621461003b578063cfae321714610057575b600080fd5b6100556004803603810190610050919061022c565b610075565b005b61005f61008f565b60405161006c91906102a6565b60405180910390f35b806000908051906020019061008b929190610121565b5050565b60606000805461009e9061037c565b80601f01602080910402602001604051908101604052809291908181526020018280546100ca9061037c565b80156101175780601f106100ec57610100808354040283529160200191610117565b820191906000526020600020905b8154815290600101906020018083116100fa57829003601f168201915b5050505050905090565b82805461012d9061037c565b90600052602060002090601f01602090048101928261014f5760008555610196565b82601f1061016857805160ff1916838001178555610196565b82800160010185558215610196579182015b8281111561019557825182559160200191906001019061017a565b5b5090506101a391906101a7565b5090565b5b808211156101c05760008160009055506001016101a8565b5090565b60006101d76101d2846102ed565b6102c8565b9050828152602081018484840111156101ef57600080fd5b6101fa84828561033a565b509392505050565b600082601f83011261021357600080fd5b81356102238482602086016101c4565b91505092915050565b60006020828403121561023e57600080fd5b600082013567ffffffffffffffff81111561025857600080fd5b61026484828501610202565b91505092915050565b60006102788261031e565b6102828185610329565b9350610292818560208601610349565b61029b8161043d565b840191505092915050565b600060208201905081810360008301526102c0818461026d565b905092915050565b60006102d26102e3565b90506102de82826103ae565b919050565b6000604051905090565b600067ffffffffffffffff8211156103085761030761040e565b5b6103118261043d565b9050602081019050919050565b600081519050919050565b600082825260208201905092915050565b82818337600083830152505050565b60005b8381101561036757808201518184015260208101905061034c565b83811115610376576000848401525b50505050565b6000600282049050600182168061039457607f821691505b602082108114156103a8576103a76103df565b5b50919050565b6103b78261043d565b810181811067ffffffffffffffff821117156103d6576103d561040e565b5b80604052505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f830116905091905056fea264697066735822122070d157c4efbb3fba4a1bde43cbba5b92b69f2fc455a650c0dfb61e9ed3d4bd6364736f6c634300080400330000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000b696e697469616c5f6d7367000000000000000000000000000000000000000000',
115115
from: '0x81cb089c285e5ee3a7353704fb114955037443af',
@@ -146,7 +146,7 @@ describe('@ethEstimateGas Estimate Gas spec', async function () {
146146
expect((gas as string).toLowerCase()).to.equal(numberTo0x(constants.TX_DEFAULT_GAS_DEFAULT).toLowerCase());
147147
});
148148

149-
it('should eth_estimateGas for contract deploy throws COULD_NOT_SIMULATE_TRANSACTION error on 400', async function () {
149+
it('should eth_estimateGas for contract deploy throws COULD_NOT_ESTIMATE_GAS_PRICE error on 400', async function () {
150150
const callData: IContractCallRequest = {
151151
data: '0x01',
152152
};
@@ -158,7 +158,7 @@ describe('@ethEstimateGas Estimate Gas spec', async function () {
158158
);
159159
});
160160

161-
it('should eth_estimateGas to mirror node for transfer throws COULD_NOT_SIMULATE_TRANSACTION error on 400', async function () {
161+
it('should eth_estimateGas to mirror node for transfer throws COULD_NOT_ESTIMATE_GAS_PRICE error on 400', async function () {
162162
const callData: IContractCallRequest = {
163163
from: '0x81cb089c285e5ee3a7353704fb114955037443af',
164164
to: RECEIVER_ADDRESS,
@@ -176,7 +176,7 @@ describe('@ethEstimateGas Estimate Gas spec', async function () {
176176
);
177177
});
178178

179-
it('should eth_estimateGas to mirror node for transfer without value throws COULD_NOT_SIMULATE_TRANSACTION error on 400', async function () {
179+
it('should eth_estimateGas to mirror node for transfer without value throws COULD_NOT_ESTIMATE_GAS_PRICE error on 400', async function () {
180180
const callData: IContractCallRequest = {
181181
from: '0x81cb089c285e5ee3a7353704fb114955037443af',
182182
to: RECEIVER_ADDRESS,
@@ -306,7 +306,7 @@ describe('@ethEstimateGas Estimate Gas spec', async function () {
306306
expect((gas as string).toLowerCase()).to.equal(numberTo0x(gasEstimation).toLowerCase());
307307
});
308308

309-
it('should eth_estimateGas transfer with invalid value throws COULD_NOT_SIMULATE_TRANSACTION error on 400', async function () {
309+
it('should eth_estimateGas transfer with invalid value throws COULD_NOT_ESTIMATE_GAS_PRICE error on 400', async function () {
310310
const callData: IContractCallRequest = {
311311
to: RECEIVER_ADDRESS,
312312
value: -100_000_000_000, //in tinybars
@@ -328,7 +328,7 @@ describe('@ethEstimateGas Estimate Gas spec', async function () {
328328
).to.be.rejectedWith(JsonRpcError, gasPriceErrorMessage);
329329
});
330330

331-
it('should eth_estimateGas empty call throws COULD_NOT_SIMULATE_TRANSACTION error on 400', async function () {
331+
it('should eth_estimateGas empty call throws COULD_NOT_ESTIMATE_GAS_PRICE error on 400', async function () {
332332
const callData: IContractCallRequest = {};
333333
await mockContractCall(callData, true, 400, { errorMessage: '', statusCode: 400 }, requestDetails);
334334

@@ -343,7 +343,7 @@ describe('@ethEstimateGas Estimate Gas spec', async function () {
343343
expect(gas).to.equal(numberTo0x(defaultGasOverride));
344344
});
345345

346-
it('should eth_estimateGas empty input throws COULD_NOT_SIMULATE_TRANSACTION error on 400', async function () {
346+
it('should eth_estimateGas empty input throws COULD_NOT_ESTIMATE_GAS_PRICE error on 400', async function () {
347347
const callData: IContractCallRequest = {
348348
data: '',
349349
estimate: true,
@@ -358,7 +358,7 @@ describe('@ethEstimateGas Estimate Gas spec', async function () {
358358
);
359359
});
360360

361-
it('should eth_estimateGas empty input throws COULD_NOT_SIMULATE_TRANSACTION error on 400 with overridden default gas', async function () {
361+
it('should eth_estimateGas empty input throws COULD_NOT_ESTIMATE_GAS_PRICE error on 400 with overridden default gas', async function () {
362362
const callData: IContractCallRequest = {
363363
data: '',
364364
};
@@ -391,7 +391,7 @@ describe('@ethEstimateGas Estimate Gas spec', async function () {
391391
expect(gas).to.equal(gasTxBaseCost);
392392
});
393393

394-
it('should eth_estimateGas zero input throws COULD_NOT_SIMULATE_TRANSACTION error on 400 with overridden default gas', async function () {
394+
it('should eth_estimateGas zero input throws COULD_NOT_ESTIMATE_GAS_PRICE error on 400 with overridden default gas', async function () {
395395
const callData: IContractCallRequest = {
396396
gas: '0x0',
397397
};
@@ -519,7 +519,7 @@ describe('@ethEstimateGas Estimate Gas spec', async function () {
519519
});
520520
});
521521

522-
it('should eth_estimateGas handles a 400 response from the mirror node correctly by throwing COULD_NOT_SIMULATE_TRANSACTION error', async function () {
522+
it('should eth_estimateGas handles a 400 response from the mirror node correctly by throwing COULD_NOT_ESTIMATE_GAS_PRICE error', async function () {
523523
const callData: IContractCallRequest = {
524524
from: '0x05fba803be258049a27b820088bab1cad2058871',
525525
value: '0x1',

packages/server/tests/acceptance/rpc_batch2.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ describe('@api-batch-2 RPC Server Acceptance Tests', function () {
162162
return (
163163
errorBody &&
164164
errorBody.code === -32000 &&
165-
errorBody.message.includes('Error occurred during transaction simulation')
165+
errorBody.message.includes('Error occurred during gas price estimation')
166166
);
167167
});
168168
});
@@ -463,7 +463,7 @@ describe('@api-batch-2 RPC Server Acceptance Tests', function () {
463463
});
464464

465465
describe('Gas estimation errors (non-contract revert)', async function () {
466-
it('should throw COULD_NOT_SIMULATE_TRANSACTION error when sender account does not exist', async function () {
466+
it('should throw COULD_NOT_ESTIMATE_GAS_PRICE error when sender account does not exist', async function () {
467467
const promise = relay.call(RelayCalls.ETH_ENDPOINTS.ETH_ESTIMATE_GAS, [
468468
{
469469
from: NON_EXISTENT_ACCOUNT,
@@ -477,13 +477,13 @@ describe('@api-batch-2 RPC Server Acceptance Tests', function () {
477477
return (
478478
errorBody &&
479479
errorBody.code === -32000 &&
480-
errorBody.message.includes('Error occurred during transaction simulation') &&
480+
errorBody.message.includes('Error occurred during gas price estimation') &&
481481
errorBody.message.includes('Sender account not found')
482482
);
483483
});
484484
});
485485

486-
it('should throw COULD_NOT_SIMULATE_TRANSACTION error when "to" field is empty for contract call', async function () {
486+
it('should throw COULD_NOT_ESTIMATE_GAS_PRICE error when "to" field is empty for contract call', async function () {
487487
const promise = relay.call(RelayCalls.ETH_ENDPOINTS.ETH_ESTIMATE_GAS, [
488488
{
489489
from: accounts[0].address,
@@ -496,7 +496,7 @@ describe('@api-batch-2 RPC Server Acceptance Tests', function () {
496496
return (
497497
errorBody &&
498498
errorBody.code === -32000 &&
499-
errorBody.message.includes('Error occurred during transaction simulation')
499+
errorBody.message.includes('Error occurred during gas price estimation')
500500
);
501501
});
502502
});

0 commit comments

Comments
 (0)