Skip to content

Commit f9a9478

Browse files
crazyrabbitLTCfrangio
authored andcommitted
GSNSignatureBouncer fix (#1920)
* GSNSignatureBoucer does not accept zero address * Linting code. * Update contracts/GSN/bouncers/GSNBouncerSignature.sol Makes sense! Co-Authored-By: Nicolás Venturo <[email protected]> * Update test/GSN/GSNBouncerSignature.test.js ok! Co-Authored-By: Nicolás Venturo <[email protected]> * Add zero address constant from OZ test Helpers * revert prettier formatting
1 parent 18473d0 commit f9a9478

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

contracts/GSN/bouncers/GSNBouncerSignature.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ contract GSNBouncerSignature is GSNBouncerBase {
2222
* @dev Sets the trusted signer that is going to be producing signatures to approve relayed calls.
2323
*/
2424
constructor(address trustedSigner) public {
25+
require(trustedSigner != address(0), "GSNBouncerSignature: trusted signer is the zero address");
2526
_trustedSigner = trustedSigner;
2627
}
2728

test/GSN/GSNBouncerSignature.test.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
const { expectEvent } = require('openzeppelin-test-helpers');
1+
const { expectEvent, expectRevert, constants } = require('openzeppelin-test-helpers');
22
const gsn = require('@openzeppelin/gsn-helpers');
33
const { fixSignature } = require('../helpers/sign');
44
const { utils: { toBN } } = require('web3');
5+
const { ZERO_ADDRESS } = constants;
56

67
const GSNBouncerSignatureMock = artifacts.require('GSNBouncerSignatureMock');
78

@@ -17,6 +18,17 @@ contract('GSNBouncerSignature', function ([_, signer, other]) {
1718
});
1819
});
1920

21+
context('when constructor is called with a zero address', function () {
22+
it('fails when constructor called with a zero address', async function () {
23+
await expectRevert(
24+
GSNBouncerSignatureMock.new(
25+
ZERO_ADDRESS
26+
),
27+
'GSNBouncerSignature: trusted signer is the zero address'
28+
);
29+
});
30+
});
31+
2032
context('when relay-called', function () {
2133
beforeEach(async function () {
2234
await gsn.fundRecipient(web3, { recipient: this.recipient.address });

0 commit comments

Comments
 (0)