Skip to content

Commit 799962f

Browse files
committed
fix: use getFunction() for overloaded contract methods
1 parent ad7f062 commit 799962f

File tree

9 files changed

+113
-94
lines changed

9 files changed

+113
-94
lines changed

contracts/mocks/Secp256k1ProverResettable.sol

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ contract Secp256k1ProverResettable is Secp256k1ProverV1 {
2121
function resetProverState(SedaDataTypes.Batch memory batch) external onlyOwner {
2222
// Reset storage to zero values
2323
Secp256k1ProverStorage.Layout storage s = Secp256k1ProverStorage.layout();
24-
s.batches[batch.batchHeight] = Secp256k1ProverStorage.BatchData({resultsRoot: batch.resultsRoot, sender: address(0)});
24+
s.batches[batch.batchHeight] = Secp256k1ProverStorage.BatchData({
25+
resultsRoot: batch.resultsRoot,
26+
sender: address(0)
27+
});
2528
s.lastBatchHeight = batch.batchHeight;
2629
s.lastValidatorsRoot = batch.validatorsRoot;
2730
emit BatchPosted(batch.batchHeight, SedaDataTypes.deriveBatchId(batch), msg.sender);

tasks/tasks/utils/pause.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ sedaScope
6767
// Execute the pause/unpause action
6868
const tx =
6969
action === 'pause'
70-
? await contractInstance.connect(signer).pause()
71-
: await contractInstance.connect(signer).unpause();
70+
? await contractInstance.connect(signer).getFunction('pause')()
71+
: await contractInstance.connect(signer).getFunction('unpause')();
7272

7373
logger.info(`Transaction hash: ${tx.hash}`);
7474
await tx.wait();

tasks/tasks/utils/postRequest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ sedaScope
4949

5050
logger.info(`Posting DR with memo: ${request.memo}`);
5151

52-
const tx = await core.postRequest(request, requestFee, resultFee, batchFee, {
52+
const tx = await core.getFunction('postRequest')(request, requestFee, resultFee, batchFee, {
5353
value: totalValue,
5454
});
5555

tasks/tasks/utils/transferOwnership.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ sedaScope
6969
logger.info(`Transferring ownership to: ${newOwner}`);
7070

7171
// Execute the ownership transfer
72-
const tx = await contractInstance.connect(signer).transferOwnership(newOwner);
72+
const tx = await contractInstance.connect(signer).getFunction('transferOwnership')(newOwner);
7373
logger.info(`Transaction hash: ${tx.hash}`);
7474
const receipt = await tx.wait();
7575

test/core/RequestHandler.test.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ describe('RequestHandler', () => {
3636
it('posts request and retrieves it successfully', async () => {
3737
const { handler, requests } = await loadFixture(deployFixture);
3838

39-
const requestId = await handler.postRequest.staticCall(requests[0]);
40-
await handler.postRequest(requests[0]);
39+
const requestId = await handler.getFunction('postRequest').staticCall(requests[0]);
40+
await handler.getFunction('postRequest')(requests[0]);
4141

4242
const postedRequest = await handler.getRequest(requestId);
4343
compareRequests(postedRequest, requests[0]);
@@ -46,11 +46,11 @@ describe('RequestHandler', () => {
4646
it('allows posting duplicate request', async () => {
4747
const { handler, requests } = await loadFixture(deployFixture);
4848

49-
const requestId = await handler.postRequest.staticCall(requests[0]);
50-
await handler.postRequest(requests[0]);
49+
const requestId = await handler.getFunction('postRequest').staticCall(requests[0]);
50+
await handler.getFunction('postRequest')(requests[0]);
5151

5252
// Second post of the same request should succeed and return the same ID
53-
const duplicateRequestId = await handler.postRequest.staticCall(requests[0]);
53+
const duplicateRequestId = await handler.getFunction('postRequest').staticCall(requests[0]);
5454
expect(duplicateRequestId).to.equal(requestId);
5555

5656
// Verify the request data remains unchanged
@@ -63,15 +63,17 @@ describe('RequestHandler', () => {
6363

6464
const requestId = await handler.deriveRequestId.staticCall(requests[0]);
6565

66-
await expect(handler.postRequest(requests[0])).to.emit(handler, 'RequestPosted').withArgs(requestId);
66+
await expect(handler.getFunction('postRequest')(requests[0]))
67+
.to.emit(handler, 'RequestPosted')
68+
.withArgs(requestId);
6769
});
6870

6971
it('reverts when replication factor is zero', async () => {
7072
const { handler, requests } = await loadFixture(deployFixture);
7173

7274
const invalidRequest = { ...requests[0], replicationFactor: 0 };
7375

74-
await expect(handler.postRequest(invalidRequest))
76+
await expect(handler.getFunction('postRequest')(invalidRequest))
7577
.to.be.revertedWithCustomError(handler, 'InvalidParameter')
7678
.withArgs('replicationFactor', 0, 1);
7779
});
@@ -81,7 +83,7 @@ describe('RequestHandler', () => {
8183

8284
const invalidRequest = { ...requests[0], gasPrice: 999n };
8385

84-
await expect(handler.postRequest(invalidRequest))
86+
await expect(handler.getFunction('postRequest')(invalidRequest))
8587
.to.be.revertedWithCustomError(handler, 'InvalidParameter')
8688
.withArgs('gasPrice', 999n, 1_000n);
8789
});
@@ -91,7 +93,7 @@ describe('RequestHandler', () => {
9193

9294
const invalidRequest = { ...requests[0], execGasLimit: 9_999_999_999_999n };
9395

94-
await expect(handler.postRequest(invalidRequest))
96+
await expect(handler.getFunction('postRequest')(invalidRequest))
9597
.to.be.revertedWithCustomError(handler, 'InvalidParameter')
9698
.withArgs('execGasLimit', 9_999_999_999_999n, 10_000_000_000_000n);
9799
});
@@ -101,7 +103,7 @@ describe('RequestHandler', () => {
101103

102104
const invalidRequest = { ...requests[0], tallyGasLimit: 9_999_999_999_999n };
103105

104-
await expect(handler.postRequest(invalidRequest))
106+
await expect(handler.getFunction('postRequest')(invalidRequest))
105107
.to.be.revertedWithCustomError(handler, 'InvalidParameter')
106108
.withArgs('tallyGasLimit', 9_999_999_999_999n, 10_000_000_000_000n);
107109
});
@@ -121,8 +123,8 @@ describe('RequestHandler', () => {
121123
it('retrieves existing request correctly', async () => {
122124
const { handler, requests } = await loadFixture(deployFixture);
123125

124-
const requestId = await handler.postRequest.staticCall(requests[0]);
125-
await handler.postRequest(requests[0]);
126+
const requestId = await handler.getFunction('postRequest').staticCall(requests[0]);
127+
await handler.getFunction('postRequest')(requests[0]);
126128
const retrievedRequest = await handler.getRequest(requestId);
127129

128130
compareRequests(retrievedRequest, requests[0]);

0 commit comments

Comments
 (0)