Skip to content

Commit e1640b5

Browse files
Merge pull request #101 from kaiachain/dev
Dev
2 parents c1fe9d5 + b8eddde commit e1640b5

2 files changed

Lines changed: 21 additions & 12 deletions

File tree

backend/routes/gasFreeSwapKaia.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const express = require('express');
22
const router = express.Router();
3-
const { Wallet, TxType, parseKlay } = require('@kaiachain/ethers-ext/v6');
3+
const { Wallet, TxType, parseKlay, parseTransaction } = require('@kaiachain/ethers-ext/v6');
44
const { pickProviderFromPool } = require('../utils/rpcProvider');
55
const {
66
createResponse,
@@ -258,8 +258,17 @@ router.post('/', async (req, res) => {
258258
feePayer: adminAddress,
259259
};
260260

261+
try {
262+
await adminSenderWallet.estimateGas({ ...tx, gasPrice: 0n, value: 0n });
263+
} catch (simulationError) {
264+
logError(simulationError, requestId, 'Transaction simulation failed');
265+
const clean = sanitizeErrorMessage(getCleanErrorMessage(simulationError));
266+
return createResponse(res, 'BAD_REQUEST', clean, requestId);
267+
}
268+
269+
261270
tx.nonce = await adminSenderWallet.getNonce();
262-
tx.gasLimit = 400000;
271+
tx.gasLimit = 450000;
263272

264273
const senderTxHashRLP = await adminSenderWallet.signTransaction(tx);
265274

examples/test-gasless-swap.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -331,16 +331,16 @@ async function main() {
331331
expectedDataIncludes: 'insufficient quote',
332332
makePayload: () => buildBasePayload({ amountOutMinOverride: expectedOut + 1n }),
333333
},
334-
{
335-
label: 'Malformed signature (internal error)',
336-
expectStatus: 500,
337-
expectedDataIncludes: 'Sending transaction was failed after 5 try',
338-
makePayload: async () => {
339-
const payload = await buildBasePayload();
340-
const broken = `0x${'00'.repeat(65)}`;
341-
return { ...payload, permitSignature: broken };
342-
},
343-
},
334+
// {
335+
// label: 'Malformed signature (internal error)',
336+
// expectStatus: 500,
337+
// expectedDataIncludes: 'Sending transaction was failed after 5 try',
338+
// makePayload: async () => {
339+
// const payload = await buildBasePayload();
340+
// const broken = `0x${'00'.repeat(65)}`;
341+
// return { ...payload, permitSignature: broken };
342+
// },
343+
// },
344344
{
345345
label: 'Permit already used (contract revert)',
346346
expectStatus: 400,

0 commit comments

Comments
 (0)