File tree 3 files changed +23
-17
lines changed
3 files changed +23
-17
lines changed Original file line number Diff line number Diff line change 2
2
pragma solidity >= 0.8.0 < 0.9.0 ;
3
3
4
4
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 ;
9
9
}
10
10
11
11
/**
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
16
16
*/
17
- event DSNPBatchPublication (int16 indexed dsnpType , bytes32 dsnpHash , string dsnpUrl );
17
+ event DSNPBatchPublication (int16 indexed announcementType , bytes32 fileHash , string fileUrl );
18
18
19
19
/**
20
20
* @param publications Array of Batch struct to publish
21
21
*/
22
- function publish (Batch [] calldata publications ) external ;
22
+ function publish (Publication [] calldata publications ) external ;
23
23
}
Original file line number Diff line number Diff line change @@ -5,15 +5,15 @@ import "./IPublish.sol";
5
5
6
6
contract Publisher is IPublish {
7
7
/**
8
- * @param publications Array of Batch structs to publish
8
+ * @param publications Array of Publication structs to publish
9
9
*/
10
- function publish (Batch [] calldata publications ) external override {
10
+ function publish (Publication [] calldata publications ) external override {
11
11
require (publications.length < 100 , "gas consumption is high " );
12
12
for (uint256 i = 0 ; i < publications.length ; i++ ) {
13
13
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
17
17
);
18
18
}
19
19
}
Original file line number Diff line number Diff line change @@ -14,13 +14,19 @@ describe("publisher", () => {
14
14
} ) ;
15
15
16
16
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
+ )
18
20
. to . emit ( publisher , "DSNPBatchPublication" )
19
21
. withArgs ( 1 , hash , "http://x.com" ) ;
20
22
} ) ;
21
23
22
24
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
+ } ) ;
24
30
25
31
await expect ( publisher . publish ( batch ) ) . to . be . revertedWith ( "gas consumption is high" ) ;
26
32
} ) ;
You can’t perform that action at this time.
0 commit comments