Skip to content

Commit

Permalink
refactor(GasEStimator): custom smart wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscotobar committed Sep 2, 2024
1 parent b2b2e9b commit e79318a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/gasEstimator/gasEstimator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ const estimateRelayMaxPossibleGasNoSignature = async (
throw Error('Token amount needs to be 0');
}

if (options?.isCustom) {
throw Error('CustomSmartWallet is not supported');
}

const {
request,
relayData: { gasPrice },
Expand Down
29 changes: 28 additions & 1 deletion test/gasEstimator/gasEstimator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ describe('GasEstimator', function () {
).to.be.true;
});

it('should fail if token amount is 0', async function () {
it('should fail if `tokenAmount` is not 0', async function () {
await expect(
estimateRelayMaxPossibleGas(FAKE_RELAY_TRANSACTION_REQUEST, relayWorker)
).to.be.rejectedWith('Token amount needs to be 0');
Expand Down Expand Up @@ -203,6 +203,33 @@ describe('GasEstimator', function () {
sandbox.restore();
});

it('should fail if `tokenAmount` is not 0', async function () {
await expect(
estimateRelayMaxPossibleGasNoSignature(
{
...relayTransactionRequest.relayRequest,
request: {
...relayTransactionRequest.relayRequest.request,
tokenAmount: constants.One,
},
},
relayWorker
)
).to.be.rejectedWith('Token amount needs to be 0');
});

it('should fail if CustomSmartWallet ', async function () {
await expect(
estimateRelayMaxPossibleGasNoSignature(
relayTransactionRequest.relayRequest,
relayWorker,
{
isCustom: true,
}
)
).to.be.rejectedWith('CustomSmartWallet is not supported');
});

describe('should estimate the relay request', function () {
before(async function () {
sandbox
Expand Down

0 comments on commit e79318a

Please sign in to comment.