@lukso/lsp23-contracts 0.15.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,65 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.4;
3
+
4
+ import {
5
+ OPERATION_4_DELEGATECALL
6
+ } from "@erc725/smart-contracts/contracts/constants.sol";
7
+
8
+ import {
9
+ UniversalProfileInit
10
+ } from "@lukso/universalprofile-contracts/contracts/UniversalProfileInit.sol";
11
+
12
+ contract UniversalProfileInitPostDeploymentModule is UniversalProfileInit {
13
+ constructor() {
14
+ _disableInitializers();
15
+ }
16
+
17
+ function setDataAndTransferOwnership(
18
+ bytes32[] memory dataKeys,
19
+ bytes[] memory dataValues,
20
+ address newOwner
21
+ ) public payable {
22
+ // check that the msg.sender is the owner
23
+ require(
24
+ msg.sender == owner(),
25
+ "UniversalProfileInitPostDeploymentModule: setDataAndTransferOwnership only allowed through delegate call"
26
+ );
27
+
28
+ // update the dataKeys and dataValues in the UniversalProfile contract
29
+ for (uint256 i = 0; i < dataKeys.length; ) {
30
+ _setData(dataKeys[i], dataValues[i]);
31
+
32
+ unchecked {
33
+ ++i;
34
+ }
35
+ }
36
+
37
+ // transfer the ownership of the UniversalProfile contract to the newOwner
38
+ _setOwner(newOwner);
39
+ }
40
+
41
+ function executePostDeployment(
42
+ address universalProfile,
43
+ address keyManager,
44
+ bytes calldata setDataBatchBytes
45
+ ) public {
46
+ // retrieve the dataKeys and dataValues to setData from the initializationCalldata bytes
47
+ (bytes32[] memory dataKeys, bytes[] memory dataValues) = abi.decode(
48
+ setDataBatchBytes,
49
+ (bytes32[], bytes[])
50
+ );
51
+
52
+ // call the execute function with delegate_call on the universalProfile contract to setData and transferOwnership
53
+ UniversalProfileInit(payable(universalProfile)).execute(
54
+ OPERATION_4_DELEGATECALL,
55
+ address(this),
56
+ 0,
57
+ abi.encodeWithSignature(
58
+ "setDataAndTransferOwnership(bytes32[],bytes[],address)",
59
+ dataKeys,
60
+ dataValues,
61
+ keyManager
62
+ )
63
+ );
64
+ }
65
+ }
@@ -0,0 +1,63 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.4;
3
+
4
+ import {
5
+ OPERATION_4_DELEGATECALL
6
+ } from "@erc725/smart-contracts/contracts/constants.sol";
7
+
8
+ import {
9
+ UniversalProfile
10
+ } from "@lukso/universalprofile-contracts/contracts/UniversalProfile.sol";
11
+
12
+ contract UniversalProfilePostDeploymentModule is UniversalProfile {
13
+ constructor() UniversalProfile(address(0)) {}
14
+
15
+ function setDataAndTransferOwnership(
16
+ bytes32[] memory dataKeys,
17
+ bytes[] memory dataValues,
18
+ address newOwner
19
+ ) public payable {
20
+ // check that the msg.sender is the owner
21
+ require(
22
+ msg.sender == owner(),
23
+ "UniversalProfileInitPostDeploymentModule: setDataAndTransferOwnership only allowed through delegate call"
24
+ );
25
+
26
+ // update the dataKeys and dataValues in the UniversalProfile contract
27
+ for (uint256 i = 0; i < dataKeys.length; ) {
28
+ _setData(dataKeys[i], dataValues[i]);
29
+
30
+ unchecked {
31
+ ++i;
32
+ }
33
+ }
34
+
35
+ // transfer the ownership of the UniversalProfile contract to the newOwner
36
+ _setOwner(newOwner);
37
+ }
38
+
39
+ function executePostDeployment(
40
+ address universalProfile,
41
+ address keyManager,
42
+ bytes calldata setDataBatchBytes
43
+ ) public {
44
+ // retrieve the dataKeys and dataValues to setData from the initializationCalldata bytes
45
+ (bytes32[] memory dataKeys, bytes[] memory dataValues) = abi.decode(
46
+ setDataBatchBytes,
47
+ (bytes32[], bytes[])
48
+ );
49
+
50
+ // call the execute function with delegate_call on the universalProfile contract to setData and transferOwnership
51
+ UniversalProfile(payable(universalProfile)).execute(
52
+ OPERATION_4_DELEGATECALL,
53
+ address(this),
54
+ 0,
55
+ abi.encodeWithSignature(
56
+ "setDataAndTransferOwnership(bytes32[],bytes[],address)",
57
+ dataKeys,
58
+ dataValues,
59
+ keyManager
60
+ )
61
+ );
62
+ }
63
+ }
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@lukso/lsp23-contracts",
3
+ "version": "0.15.0-rc.0",
4
+ "description": "Package for the LSP23 Linked Contracts Factory standard",
5
+ "license": "Apache-2.0",
6
+ "author": "",
7
+ "main": "./dist/index.cjs",
8
+ "module": "./dist/index.mjs",
9
+ "typings": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "require": "./dist/index.cjs",
13
+ "import": "./dist/index.mjs",
14
+ "types": "./dist/index.d.ts"
15
+ },
16
+ "./artifacts/*": "./artifacts/*",
17
+ "./package.json": "./package.json"
18
+ },
19
+ "files": [
20
+ "contracts/**/*.sol",
21
+ "!contracts/Mocks/**/*.sol",
22
+ "artifacts/*.json",
23
+ "dist",
24
+ "types",
25
+ "!types/factories",
26
+ "./README.md"
27
+ ],
28
+ "keywords": [
29
+ "LUKSO",
30
+ "LSP",
31
+ "Blockchain",
32
+ "Standards",
33
+ "Smart Contracts",
34
+ "Ethereum",
35
+ "EVM",
36
+ "Solidity"
37
+ ],
38
+ "scripts": {
39
+ "package": "hardhat prepare-package",
40
+ "build": "hardhat compile --show-stack-traces",
41
+ "build:types": "npx typechain --target=ethers-v6 ./artifacts/*.json --out-dir types",
42
+ "clean": "hardhat clean && rm -Rf dist/",
43
+ "format": "prettier --write .",
44
+ "lint": "eslint . --ext .ts,.js",
45
+ "lint:solidity": "solhint 'contracts/**/*.sol' && prettier --check 'contracts/**/*.sol'"
46
+ },
47
+ "dependencies": {
48
+ "@erc725/smart-contracts": "^7.0.0",
49
+ "@openzeppelin/contracts": "^4.9.3",
50
+ "@lukso/universalprofile-contracts": "*"
51
+ }
52
+ }
@@ -0,0 +1,107 @@
1
+ /* Autogenerated file. Do not edit manually. */
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ import type {
5
+ BaseContract,
6
+ BytesLike,
7
+ FunctionFragment,
8
+ Result,
9
+ Interface,
10
+ AddressLike,
11
+ ContractRunner,
12
+ ContractMethod,
13
+ Listener,
14
+ } from "ethers";
15
+ import type {
16
+ TypedContractEvent,
17
+ TypedDeferredTopicFilter,
18
+ TypedEventLog,
19
+ TypedListener,
20
+ TypedContractMethod,
21
+ } from "./common";
22
+
23
+ export interface IPostDeploymentModuleInterface extends Interface {
24
+ getFunction(nameOrSignature: "executePostDeployment"): FunctionFragment;
25
+
26
+ encodeFunctionData(
27
+ functionFragment: "executePostDeployment",
28
+ values: [AddressLike, AddressLike, BytesLike]
29
+ ): string;
30
+
31
+ decodeFunctionResult(
32
+ functionFragment: "executePostDeployment",
33
+ data: BytesLike
34
+ ): Result;
35
+ }
36
+
37
+ export interface IPostDeploymentModule extends BaseContract {
38
+ connect(runner?: ContractRunner | null): IPostDeploymentModule;
39
+ waitForDeployment(): Promise<this>;
40
+
41
+ interface: IPostDeploymentModuleInterface;
42
+
43
+ queryFilter<TCEvent extends TypedContractEvent>(
44
+ event: TCEvent,
45
+ fromBlockOrBlockhash?: string | number | undefined,
46
+ toBlock?: string | number | undefined
47
+ ): Promise<Array<TypedEventLog<TCEvent>>>;
48
+ queryFilter<TCEvent extends TypedContractEvent>(
49
+ filter: TypedDeferredTopicFilter<TCEvent>,
50
+ fromBlockOrBlockhash?: string | number | undefined,
51
+ toBlock?: string | number | undefined
52
+ ): Promise<Array<TypedEventLog<TCEvent>>>;
53
+
54
+ on<TCEvent extends TypedContractEvent>(
55
+ event: TCEvent,
56
+ listener: TypedListener<TCEvent>
57
+ ): Promise<this>;
58
+ on<TCEvent extends TypedContractEvent>(
59
+ filter: TypedDeferredTopicFilter<TCEvent>,
60
+ listener: TypedListener<TCEvent>
61
+ ): Promise<this>;
62
+
63
+ once<TCEvent extends TypedContractEvent>(
64
+ event: TCEvent,
65
+ listener: TypedListener<TCEvent>
66
+ ): Promise<this>;
67
+ once<TCEvent extends TypedContractEvent>(
68
+ filter: TypedDeferredTopicFilter<TCEvent>,
69
+ listener: TypedListener<TCEvent>
70
+ ): Promise<this>;
71
+
72
+ listeners<TCEvent extends TypedContractEvent>(
73
+ event: TCEvent
74
+ ): Promise<Array<TypedListener<TCEvent>>>;
75
+ listeners(eventName?: string): Promise<Array<Listener>>;
76
+ removeAllListeners<TCEvent extends TypedContractEvent>(
77
+ event?: TCEvent
78
+ ): Promise<this>;
79
+
80
+ executePostDeployment: TypedContractMethod<
81
+ [
82
+ primaryContract: AddressLike,
83
+ secondaryContract: AddressLike,
84
+ calldataToPostDeploymentModule: BytesLike
85
+ ],
86
+ [void],
87
+ "nonpayable"
88
+ >;
89
+
90
+ getFunction<T extends ContractMethod = ContractMethod>(
91
+ key: string | FunctionFragment
92
+ ): T;
93
+
94
+ getFunction(
95
+ nameOrSignature: "executePostDeployment"
96
+ ): TypedContractMethod<
97
+ [
98
+ primaryContract: AddressLike,
99
+ secondaryContract: AddressLike,
100
+ calldataToPostDeploymentModule: BytesLike
101
+ ],
102
+ [void],
103
+ "nonpayable"
104
+ >;
105
+
106
+ filters: {};
107
+ }