-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create and test
LSP26FollowingSystem
- Loading branch information
Showing
6 changed files
with
87 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,17 @@ | ||
# LSP Package Template | ||
# LSP26 Following System · [![npm version](https://img.shields.io/npm/v/@lukso/lsp26-contracts.svg?style=flat)](https://www.npmjs.com/package/@lukso/lsp26-contracts) | ||
|
||
This project can be used as a skeleton to build a package for a LSP implementation in Solidity (LUKSO Standard Proposal) | ||
Package for the LSP26 Following System standard. | ||
|
||
It is based on Hardhat. | ||
|
||
## How to setup a LSP as a package? | ||
|
||
1. Copy the `template/` folder and paste it under the `packages/` folder. Then rename this `template/` folder that you copied with the LSP name. | ||
|
||
You can do so either: | ||
|
||
- manually, by copying the folder and pasting it inside `packages` and then renaming it. | ||
or | ||
- by running the following command from the root of the repository. | ||
## Installation | ||
|
||
```bash | ||
cp -r template packages/lsp-name | ||
npm i @lukso/lsp26-contracts | ||
``` | ||
|
||
2. Update the `"name"` and `"description"` field inside the `package.json` for this LSP package you just created. | ||
|
||
3. Setup the dependencies | ||
|
||
If this LSP uses external dependencies like `@openzeppelin/contracts`, put them under `dependencies` with the version number. | ||
|
||
```json | ||
"@openzeppelin/contracts": "^4.9.3" | ||
``` | ||
## Available Constants & Types | ||
|
||
If this LSP uses other LSP as dependencies, put each LSP dependency as shown below. This will use the current code in the package: | ||
The `@lukso/lsp26-contracts` npm package contains useful constants such as InterfaceIds, and specific constants related to the LSP26 Standard. You can import and access them as follow: | ||
|
||
```json | ||
"@lsp2": "*" | ||
```js | ||
import { INTERFACE_ID_LSP26, LSP26_TYPE_IDS } from "@lukso/lsp26-contracts"; | ||
``` | ||
|
||
4. Setup the npm commands for linting, building, testing, etc... under the `"scripts"` in the `package.json` | ||
|
||
5. Test that all commands you setup run successfully | ||
|
||
By running the commands below, your LSP package should come up in the list of packages that Turbo is running this command for. | ||
|
||
```bash | ||
turbo build | ||
turbo lint | ||
turbo lint:solidity | ||
turbo test | ||
turbo test:foundry | ||
``` | ||
|
||
6. Finally update the relevant information in the `README.md` file in the folder of the newly created package, such as the title at the top, some description, etc... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
// Define your constants to be exported here | ||
export const INTERFACE_ID_LSP26 = '0xc52d6008'; | ||
|
||
// example | ||
export const LSPN_CONSTANT_VALUE = 123; | ||
export const LSP26_TYPE_IDS = { | ||
// keccak256('LSP26FollowerSystem_FollowNotification') | ||
_TYPEID_LSP26_FOLLOW: '0x71e02f9f05bcd5816ec4f3134aa2e5a916669537ec6c77fe66ea595fabc2d51a', | ||
|
||
// keccak256('LSP26FollowerSystem_UnfollowNotification') | ||
_TYPEID_LSP26_UNFOLLOW: '0x9d3c0b4012b69658977b099bdaa51eff0f0460f421fba96d15669506c00d1c4f', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
packages/lsp26-contracts/contracts/mock/RevertOnFollow.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity ^0.8.17; | ||
|
||
// interfaces | ||
import { | ||
ILSP1UniversalReceiver | ||
} from "@lukso/lsp1-contracts/contracts/ILSP1UniversalReceiver.sol"; | ||
|
||
contract RevertOnFollow is ILSP1UniversalReceiver { | ||
function supportsInterface(bytes4) external pure returns (bool) { | ||
return true; | ||
} | ||
|
||
function universalReceiver( | ||
bytes32, | ||
bytes memory | ||
) external payable returns (bytes memory) { | ||
revert("Block LSP1 notifications"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters