Skip to content

Commit 5c945f0

Browse files
authored
Rename the fields in DSNP Batch Publication (#38)
dsnpUrl -> fileUrl dsnpHash -> fileHash dsnpType -> announcementType
1 parent 6223667 commit 5c945f0

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

contracts/IPublish.sol

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22
pragma solidity >=0.8.0 <0.9.0;
33

44
interface IPublish {
5-
struct Batch {
6-
int16 dsnpType;
7-
string url;
8-
bytes32 hash;
5+
struct Publication {
6+
int16 announcementType;
7+
string fileUrl;
8+
bytes32 fileHash;
99
}
1010

1111
/**
12-
* @dev Log for each batch published
13-
* @param dsnpType The type of Announcement in the batch file
14-
* @param dsnpHash The keccak hash of the batch file
15-
* @param dsnpUrl A url that resolves to the batch file of Announcements
12+
* @dev Log Event for each batch published
13+
* @param announcementType The type of Announcement in the batch file
14+
* @param fileHash The keccak hash of the batch file
15+
* @param fileUrl A url that resolves to the batch file
1616
*/
17-
event DSNPBatchPublication(int16 indexed dsnpType, bytes32 dsnpHash, string dsnpUrl);
17+
event DSNPBatchPublication(int16 indexed announcementType, bytes32 fileHash, string fileUrl);
1818

1919
/**
2020
* @param publications Array of Batch struct to publish
2121
*/
22-
function publish(Batch[] calldata publications) external;
22+
function publish(Publication[] calldata publications) external;
2323
}

contracts/Publisher.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ import "./IPublish.sol";
55

66
contract Publisher is IPublish {
77
/**
8-
* @param publications Array of Batch structs to publish
8+
* @param publications Array of Publication structs to publish
99
*/
10-
function publish(Batch[] calldata publications) external override {
10+
function publish(Publication[] calldata publications) external override {
1111
require(publications.length < 100, "gas consumption is high");
1212
for (uint256 i = 0; i < publications.length; i++) {
1313
emit DSNPBatchPublication(
14-
publications[i].dsnpType,
15-
publications[i].hash,
16-
publications[i].url
14+
publications[i].announcementType,
15+
publications[i].fileHash,
16+
publications[i].fileUrl
1717
);
1818
}
1919
}

test/Publisher.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,19 @@ describe("publisher", () => {
1414
});
1515

1616
it("batch emits a DSNPBatchPublication event", async () => {
17-
await expect(publisher.publish([{ hash: hash, url: "http://x.com", dsnpType: 1 }]))
17+
await expect(
18+
publisher.publish([{ fileHash: hash, fileUrl: "http://x.com", announcementType: 1 }])
19+
)
1820
.to.emit(publisher, "DSNPBatchPublication")
1921
.withArgs(1, hash, "http://x.com");
2022
});
2123

2224
it("reverts when batch size is greater or equal to 100", async () => {
23-
const batch = Array(100).fill({ hash: hash, url: "http://x.com", dsnpType: 1 });
25+
const batch = Array(100).fill({
26+
fileHash: hash,
27+
fileUrl: "http://x.com",
28+
announcementType: 1,
29+
});
2430

2531
await expect(publisher.publish(batch)).to.be.revertedWith("gas consumption is high");
2632
});

0 commit comments

Comments
 (0)