Skip to content

Commit

Permalink
Merge branch 'lsp-monorepo' of https://github.com/lukso-network/lsp-s…
Browse files Browse the repository at this point in the history
…mart-contracts into package/lsp17contractextension
  • Loading branch information
skimaharvey committed Jan 26, 2024
2 parents 6ce4494 + 6a51249 commit 65d8d98
Show file tree
Hide file tree
Showing 31 changed files with 2,081 additions and 1,551 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/build-lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ jobs:
contracts.ts
key: ${{ github.run_id }}

- name: 🧪 run import/requires tests
run: npm run test:importRequire

- name: 📚 generate ABI docs
run: npm run build:docs

Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/solc_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,11 @@ jobs:
--allow-paths $(pwd)/node_modules/,$(pwd)/packages/ \
@=node_modules/@ \
solidity-bytes-utils/=node_modules/solidity-bytes-utils/ \
../=$(pwd)/contracts/
../=$(pwd)/contracts/ \
lsp25/=packages/LSP25ExecuteRelayCall/
else
solc contracts/**/*.sol \
@=node_modules/@ \
solidity-bytes-utils/=node_modules/solidity-bytes-utils/
solidity-bytes-utils/=node_modules/solidity-bytes-utils/ \
lsp25/=packages/LSP25ExecuteRelayCall/
fi;
6 changes: 3 additions & 3 deletions contracts/LSP6KeyManager/LSP6KeyManagerCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from "../LSP20CallVerification/ILSP20CallVerifier.sol";
import {
ILSP25ExecuteRelayCall as ILSP25
} from "../LSP25ExecuteRelayCall/ILSP25ExecuteRelayCall.sol";
} from "lsp25/contracts/ILSP25ExecuteRelayCall.sol";

// modules
import {ILSP14Ownable2Step} from "../LSP14Ownable2Step/ILSP14Ownable2Step.sol";
Expand All @@ -29,7 +29,7 @@ import {
import {LSP6OwnershipModule} from "./LSP6Modules/LSP6OwnershipModule.sol";
import {
LSP25MultiChannelNonce
} from "../LSP25ExecuteRelayCall/LSP25MultiChannelNonce.sol";
} from "lsp25/contracts/LSP25MultiChannelNonce.sol";

// libraries
import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
Expand Down Expand Up @@ -69,7 +69,7 @@ import {
_LSP20_VERIFY_CALL_SUCCESS_VALUE_WITH_POST_VERIFICATION,
_LSP20_VERIFY_CALL_RESULT_SUCCESS_VALUE
} from "../LSP20CallVerification/LSP20Constants.sol";
import {_INTERFACEID_LSP25} from "../LSP25ExecuteRelayCall/LSP25Constants.sol";
import {_INTERFACEID_LSP25} from "lsp25/contracts/LSP25Constants.sol";

/**
* @title Core implementation of the LSP6 Key Manager standard.
Expand Down
4 changes: 2 additions & 2 deletions contracts/Mocks/ERC165Interfaces.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import {
} from "../LSP20CallVerification/ILSP20CallVerifier.sol";
import {
ILSP25ExecuteRelayCall as ILSP25
} from "../LSP25ExecuteRelayCall/ILSP25ExecuteRelayCall.sol";
} from "lsp25/contracts/ILSP25ExecuteRelayCall.sol";

// constants
import {_INTERFACEID_LSP0} from "../LSP0ERC725Account/LSP0Constants.sol";
Expand All @@ -83,7 +83,7 @@ import {
_INTERFACEID_LSP20_CALL_VERIFICATION,
_INTERFACEID_LSP20_CALL_VERIFIER
} from "../LSP20CallVerification/LSP20Constants.sol";
import {_INTERFACEID_LSP25} from "../LSP25ExecuteRelayCall/LSP25Constants.sol";
import {_INTERFACEID_LSP25} from "lsp25/contracts/LSP25Constants.sol";

// libraries
import {
Expand Down
2 changes: 1 addition & 1 deletion contracts/Mocks/Reentrancy/BatchReentrancyRelayer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.4;
// interfaces
import {
ILSP25ExecuteRelayCall
} from "../../LSP25ExecuteRelayCall/ILSP25ExecuteRelayCall.sol";
} from "lsp25/contracts/ILSP25ExecuteRelayCall.sol";

contract BatchReentrancyRelayer {
bytes[] private _signatures;
Expand Down
2 changes: 1 addition & 1 deletion contracts/Mocks/Reentrancy/SingleReentrancyRelayer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.4;
// interfaces
import {
ILSP25ExecuteRelayCall
} from "../../LSP25ExecuteRelayCall/ILSP25ExecuteRelayCall.sol";
} from "lsp25/contracts/ILSP25ExecuteRelayCall.sol";

contract SingleReentrancyRelayer {
bytes private _signature;
Expand Down
File renamed without changes.
203 changes: 203 additions & 0 deletions docs/contracts/lsp17contractextension/contracts/LSP17Extendable.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
<!-- This file is auto-generated. Do not edit! -->
<!-- Check `@lukso-network/lsp-smart-contracts/CONTRIBUTING.md#solidity-code-comments` for more information. -->


# LSP17Extendable

:::info Standard Specifications

[`LSP-17-Extendable.sol`](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-17-Extendable.sol.md)

:::
:::info Solidity implementation

[`LSP17Extendable.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/lsp17contractextension/contracts/LSP17Extendable.sol)

:::


> Module to add more functionalities to a contract using extensions.


Implementation of the `fallback(...)` logic according to LSP17

- Contract Extension standard. This module can be inherited to extend the functionality of the parent contract when calling a function that doesn't exist on the parent contract via forwarding the call to an extension mapped to the function selector being called, set originally by the parent contract



## Public Methods


Public methods are accessible externally from users, allowing interaction with this function from dApps or other smart contracts.
When marked as 'public', a method can be called both externally and internally, on the other hand, when marked as 'external', a method can only be called externally.


### supportsInterface

:::note References

- Specification details: [**LSP-17-Extendable.sol**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-17-Extendable.sol.md#supportsinterface)
- Solidity implementation: [`LSP17Extendable.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/lsp17contractextension/contracts/LSP17Extendable.sol)
- Function signature: `supportsInterface(bytes4)`
- Function selector: `0x01ffc9a7`

:::










```solidity
function supportsInterface(bytes4 interfaceId) external view returns (bool);
```




See [`IERC165-supportsInterface`](#ierc165-supportsinterface).





#### Parameters

| Name | Type | Description |
|---|:-:|---|
| `interfaceId` | `bytes4` | - |


#### Returns

| Name | Type | Description |
|---|:-:|---|
| `0` | `bool` | - |
<br/>







## Internal Methods

Any method labeled as `internal` serves as utility function within the contract. They can be used when writing solidity contracts that inherit from this contract. These methods can be extended or modified by overriding their internal behavior to suit specific needs.

Internal functions cannot be called externally, whether from other smart contracts, dApp interfaces, or backend services. Their restricted accessibility ensures that they remain exclusively available within the context of the current contract, promoting controlled and encapsulated usage of these internal utilities.


### _supportsInterfaceInERC165Extension








```solidity
function _supportsInterfaceInERC165Extension(bytes4 interfaceId) internal view returns (bool);
```




Returns whether the interfaceId being checked is supported in the extension of the
[`supportsInterface`](#supportsinterface) selector.
To be used by extendable contracts wishing to extend the ERC165 interfaceIds originally
supported by reading whether the interfaceId queried is supported in the `supportsInterface`
extension if the extension is set, if not it returns false.







<br/>

### _getExtensionAndForwardValue








```solidity
function _getExtensionAndForwardValue(bytes4 functionSelector) internal view returns (address, bool);
```




Returns the extension mapped to a specific function selector
If no extension was found, return the address(0)
To be overrided.
Up to the implementor contract to return an extension based on a function selector







<br/>

### _fallbackLSP17Extendable


:::tip Hint

This function does not forward to the extension contract the `msg.value` received by the contract that inherits `LSP17Extendable`.
If you would like to forward the `msg.value` to the extension contract, you can override the code of this internal function as follow:
```solidity
(bool success, bytes memory result) = extension.call{value: msg.value}(
abi.encodePacked(callData, msg.sender, msg.value)
);
```

:::






```solidity
function _fallbackLSP17Extendable(bytes callData) internal nonpayable returns (bytes);
```




Forwards the call to an extension mapped to a function selector.
Calls [`_getExtensionAndForwardValue`](#_getextensionandforwardvalue) to get the address of the extension mapped to the function selector being
called on the account. If there is no extension, the `address(0)` will be returned.
Forwards the value if the extension is payable.
Reverts if there is no extension for the function being called.
If there is an extension for the function selector being called, it calls the extension with the
`CALL` opcode, passing the `msg.data` appended with the 20 bytes of the [`msg.sender`](#msg.sender) and 32 bytes of the `msg.value`.







<br/>







Loading

0 comments on commit 65d8d98

Please sign in to comment.