Skip to content

Commit e86e5db

Browse files
authored
Use the byte3 array directly for the versioning (#100)
The Version contract defined the version as the string "305" and the function returns a bytes3 value. The string "305" was encoded and the returned as 0x333035. This limited patch increments to the versioning. For example, we would not be able to fit the string "3010" (for version 3.0.10) into bytes3. The update changes the version encoding to be simply 3 digits, base 256 number. This allows major, minor, and patch numbers up to 255. The update was suggested by OpenZeppelin reviewer; no issue reference was assigned.
1 parent 8c700e0 commit e86e5db

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

contracts/version/Version.sol

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ pragma solidity 0.8.27;
66
*/
77
contract Version {
88
/**
9-
* @dev Returns the address of the current owner.
9+
* @dev Returns the version of the SFC contract
1010
*/
1111
function version() public pure returns (bytes3) {
12-
// version 3.0.5
13-
return "305";
12+
return 0x040000; // version 4.0.0
1413
}
1514
}

test/SFC.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ describe('SFC', () => {
127127
});
128128

129129
it('Should succeed and return version of the current implementation', async function () {
130-
expect(await this.sfc.version()).to.equal(ethers.hexlify(ethers.toUtf8Bytes('305')));
130+
expect(await this.sfc.version()).to.equal('0x040000');
131131
});
132132
});
133133

0 commit comments

Comments
 (0)