Skip to content

Commit

Permalink
Fix transactions nonce management
Browse files Browse the repository at this point in the history
  • Loading branch information
juanenrisley committed Aug 1, 2023
1 parent 165987a commit bfae15b
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 74 deletions.
4 changes: 0 additions & 4 deletions __tests__/transactions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const { build } = require('fastify-cli/helper');

const { generateSaltNonce } = require('./utils');

describe('Transactions features:', () => {
const url = '/transactions';
let app;
Expand All @@ -17,7 +15,6 @@ describe('Transactions features:', () => {
url,
method: 'POST',
payload: {
nonce: generateSaltNonce(),
target: '0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0',
data: '0x6a761202000000000000000000000000cfeb869f69431e42cdb54a4f4f105c19c080a6010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000449951d62f00000000000000000000000090f8bf6a479f320ead074411a4b0e7944ea8c9c1000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041eb667a968b979d8406df46c7fedbc2cd6e9046a10f379baa27ddecf560b233261aba9bdc6aa8f391e45156bdac5165f12b1c1ceae2729353ebf12810302dacbc1c00000000000000000000000000000000000000000000000000000000000000',
},
Expand All @@ -36,7 +33,6 @@ describe('Transactions features:', () => {
url,
method: 'POST',
payload: {
nonce: generateSaltNonce(),
target: '0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0',
data: '0x6a761202000000000000000000000000cfeb869f69431e42cdb54a4f4f105c19c080a6010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000449951d62f00000000000000000000000090f8bf6a479f320ead074411a4b0e7944ea8c9c1000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041eb667a968b979d8406df46c7fedbc2cd6e9046a10f379baa27ddecf560b233261aba9bdc6aa8f391e45156bdac5165f12b1c1ceae2729353ebf12810302dacbc1c00000000000000000000000000000000000000000000000000000000000000',
},
Expand Down
3 changes: 0 additions & 3 deletions __tests__/utils/generateSaltNonce.js

This file was deleted.

5 changes: 0 additions & 5 deletions __tests__/utils/index.js

This file was deleted.

111 changes: 53 additions & 58 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions src/features/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ const { chainId, gelatoApiKey } = require('../config');
const { funder } = require('../utils');

const relay = new GelatoRelay();

const fundLocalTransaction = (
{ body: { target: to, ...rest }, pendingRequests },
{ body: { target: to, ...rest }, pendingRequests = 0 },
_,
) =>
funder
Expand All @@ -15,10 +14,10 @@ const fundLocalTransaction = (
funder.sendTransaction({
...rest,
to,
nonce: nonce + pendingRequests + 1,
nonce: nonce + pendingRequests,
}),
)
.then((response) => response.wait())
.then((tx) => tx.wait())
.then((receipt) => ({ taskId: '0x', receipt }));
const fundGelatoTransaction = ({ body }, _) =>
relay.sponsoredCall({ ...body, chainId }, gelatoApiKey);
Expand Down

0 comments on commit bfae15b

Please sign in to comment.