@chillwhales/lsp23 0.1.1
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.
- package/LICENSE +21 -0
- package/README.md +48 -0
- package/dist/index.d.mts +216 -0
- package/dist/index.d.ts +216 -0
- package/dist/index.mjs +151 -0
- package/package.json +61 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Chillwhales contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# @chillwhales/lsp23
|
|
2
|
+
|
|
3
|
+
[](./LICENSE)
|
|
4
|
+
|
|
5
|
+
LSP23 Linked Contracts Factory — deployment encoding utilities for creating Universal Profiles on LUKSO via the LSP23 factory contract.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @chillwhales/lsp23
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
> **Peer dependency:** This package requires [`viem`](https://viem.sh) ^2.0.0
|
|
14
|
+
>
|
|
15
|
+
> ```bash
|
|
16
|
+
> pnpm add viem
|
|
17
|
+
> ```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { generateDeployParams } from "@chillwhales/lsp23";
|
|
23
|
+
import type { Address } from "viem";
|
|
24
|
+
|
|
25
|
+
// Generate deployment parameters for a new Universal Profile
|
|
26
|
+
const controller: Address = "0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B";
|
|
27
|
+
|
|
28
|
+
const params = generateDeployParams({
|
|
29
|
+
salt: "0x" + "00".repeat(32),
|
|
30
|
+
controllerAddress: controller,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// params.universalProfileInitStruct — UP init calldata
|
|
34
|
+
// params.keyManagerInitStruct — Key Manager init calldata
|
|
35
|
+
// params.initializeEncodedBytes — post-deployment module data
|
|
36
|
+
|
|
37
|
+
// Pass these to the LSP23 factory contract's deploy function
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
> **Spec:** [LSP-23 Linked Contracts Factory](https://docs.lukso.tech/standards/smart-contracts/lsp23-linked-contracts-factory)
|
|
41
|
+
|
|
42
|
+
## API
|
|
43
|
+
|
|
44
|
+
Types are exported and available in your editor via TypeScript IntelliSense.
|
|
45
|
+
|
|
46
|
+
## License
|
|
47
|
+
|
|
48
|
+
[MIT](./LICENSE)
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { Address } from 'viem';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* LUKSO Mainnet contract addresses for LSP23 deployment.
|
|
6
|
+
* These are constants specific to the LUKSO network.
|
|
7
|
+
*/
|
|
8
|
+
/** LSP23 Linked Contracts Factory */
|
|
9
|
+
declare const LSP23_FACTORY_ADDRESS = "0x2300000A84D25dF63081feAa37ba6b62C4c89a30";
|
|
10
|
+
/** LSP23 Post Deployment Module */
|
|
11
|
+
declare const LSP23_POST_DEPLOYMENT_MODULE = "0x000000000066093407b6704B89793beFfD0D8F00";
|
|
12
|
+
/** Universal Receiver Delegate */
|
|
13
|
+
declare const UNIVERSAL_RECEIVER_ADDRESS = "0x7870C5B8BC9572A8001C3f96f7ff59961B23500D";
|
|
14
|
+
/** Standard implementation contracts for proxy patterns */
|
|
15
|
+
declare const IMPLEMENTATIONS: {
|
|
16
|
+
/** Universal Profile implementation contract */
|
|
17
|
+
readonly UNIVERSAL_PROFILE: "0x3024D38EA2434BA6635003Dc1BDC0daB5882ED4F";
|
|
18
|
+
/** LSP6 Key Manager implementation contract */
|
|
19
|
+
readonly LSP6_KEY_MANAGER: "0x2Fe3AeD98684E7351aD2D408A43cE09a738BF8a4";
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* LSP23 Linked Contracts Factory Schemas
|
|
24
|
+
*
|
|
25
|
+
* Zod schemas for validating LSP23 deployment parameters.
|
|
26
|
+
*
|
|
27
|
+
* @see https://docs.lukso.tech/standards/smart-contracts/lsp23-linked-contracts-factory
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Schema for Universal Profile initialization struct
|
|
32
|
+
*/
|
|
33
|
+
declare const universalProfileInitStructSchema: z.ZodObject<{
|
|
34
|
+
salt: z.ZodString;
|
|
35
|
+
fundingAmount: z.ZodBigInt;
|
|
36
|
+
implementationContract: z.ZodString;
|
|
37
|
+
initializationCalldata: z.ZodString;
|
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
|
39
|
+
salt: string;
|
|
40
|
+
fundingAmount: bigint;
|
|
41
|
+
implementationContract: string;
|
|
42
|
+
initializationCalldata: string;
|
|
43
|
+
}, {
|
|
44
|
+
salt: string;
|
|
45
|
+
fundingAmount: bigint;
|
|
46
|
+
implementationContract: string;
|
|
47
|
+
initializationCalldata: string;
|
|
48
|
+
}>;
|
|
49
|
+
/**
|
|
50
|
+
* Schema for Key Manager initialization struct
|
|
51
|
+
*/
|
|
52
|
+
declare const keyManagerInitStructSchema: z.ZodObject<{
|
|
53
|
+
fundingAmount: z.ZodBigInt;
|
|
54
|
+
implementationContract: z.ZodString;
|
|
55
|
+
addPrimaryContractAddress: z.ZodBoolean;
|
|
56
|
+
initializationCalldata: z.ZodString;
|
|
57
|
+
extraInitializationParams: z.ZodString;
|
|
58
|
+
}, "strip", z.ZodTypeAny, {
|
|
59
|
+
fundingAmount: bigint;
|
|
60
|
+
implementationContract: string;
|
|
61
|
+
initializationCalldata: string;
|
|
62
|
+
addPrimaryContractAddress: boolean;
|
|
63
|
+
extraInitializationParams: string;
|
|
64
|
+
}, {
|
|
65
|
+
fundingAmount: bigint;
|
|
66
|
+
implementationContract: string;
|
|
67
|
+
initializationCalldata: string;
|
|
68
|
+
addPrimaryContractAddress: boolean;
|
|
69
|
+
extraInitializationParams: string;
|
|
70
|
+
}>;
|
|
71
|
+
/**
|
|
72
|
+
* Schema for complete deployment parameters
|
|
73
|
+
*/
|
|
74
|
+
declare const deployParamsSchema: z.ZodObject<{
|
|
75
|
+
universalProfileInitStruct: z.ZodObject<{
|
|
76
|
+
salt: z.ZodString;
|
|
77
|
+
fundingAmount: z.ZodBigInt;
|
|
78
|
+
implementationContract: z.ZodString;
|
|
79
|
+
initializationCalldata: z.ZodString;
|
|
80
|
+
}, "strip", z.ZodTypeAny, {
|
|
81
|
+
salt: string;
|
|
82
|
+
fundingAmount: bigint;
|
|
83
|
+
implementationContract: string;
|
|
84
|
+
initializationCalldata: string;
|
|
85
|
+
}, {
|
|
86
|
+
salt: string;
|
|
87
|
+
fundingAmount: bigint;
|
|
88
|
+
implementationContract: string;
|
|
89
|
+
initializationCalldata: string;
|
|
90
|
+
}>;
|
|
91
|
+
keyManagerInitStruct: z.ZodObject<{
|
|
92
|
+
fundingAmount: z.ZodBigInt;
|
|
93
|
+
implementationContract: z.ZodString;
|
|
94
|
+
addPrimaryContractAddress: z.ZodBoolean;
|
|
95
|
+
initializationCalldata: z.ZodString;
|
|
96
|
+
extraInitializationParams: z.ZodString;
|
|
97
|
+
}, "strip", z.ZodTypeAny, {
|
|
98
|
+
fundingAmount: bigint;
|
|
99
|
+
implementationContract: string;
|
|
100
|
+
initializationCalldata: string;
|
|
101
|
+
addPrimaryContractAddress: boolean;
|
|
102
|
+
extraInitializationParams: string;
|
|
103
|
+
}, {
|
|
104
|
+
fundingAmount: bigint;
|
|
105
|
+
implementationContract: string;
|
|
106
|
+
initializationCalldata: string;
|
|
107
|
+
addPrimaryContractAddress: boolean;
|
|
108
|
+
extraInitializationParams: string;
|
|
109
|
+
}>;
|
|
110
|
+
initializeEncodedBytes: z.ZodString;
|
|
111
|
+
}, "strip", z.ZodTypeAny, {
|
|
112
|
+
universalProfileInitStruct: {
|
|
113
|
+
salt: string;
|
|
114
|
+
fundingAmount: bigint;
|
|
115
|
+
implementationContract: string;
|
|
116
|
+
initializationCalldata: string;
|
|
117
|
+
};
|
|
118
|
+
keyManagerInitStruct: {
|
|
119
|
+
fundingAmount: bigint;
|
|
120
|
+
implementationContract: string;
|
|
121
|
+
initializationCalldata: string;
|
|
122
|
+
addPrimaryContractAddress: boolean;
|
|
123
|
+
extraInitializationParams: string;
|
|
124
|
+
};
|
|
125
|
+
initializeEncodedBytes: string;
|
|
126
|
+
}, {
|
|
127
|
+
universalProfileInitStruct: {
|
|
128
|
+
salt: string;
|
|
129
|
+
fundingAmount: bigint;
|
|
130
|
+
implementationContract: string;
|
|
131
|
+
initializationCalldata: string;
|
|
132
|
+
};
|
|
133
|
+
keyManagerInitStruct: {
|
|
134
|
+
fundingAmount: bigint;
|
|
135
|
+
implementationContract: string;
|
|
136
|
+
initializationCalldata: string;
|
|
137
|
+
addPrimaryContractAddress: boolean;
|
|
138
|
+
extraInitializationParams: string;
|
|
139
|
+
};
|
|
140
|
+
initializeEncodedBytes: string;
|
|
141
|
+
}>;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* LSP23 Inferred Types
|
|
145
|
+
*
|
|
146
|
+
* TypeScript types inferred from LSP23 Zod schemas.
|
|
147
|
+
*/
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Initialization struct for Universal Profile deployment via LSP23.
|
|
151
|
+
*/
|
|
152
|
+
type UniversalProfileInitStruct = z.infer<typeof universalProfileInitStructSchema>;
|
|
153
|
+
/**
|
|
154
|
+
* Initialization struct for Key Manager deployment via LSP23.
|
|
155
|
+
*/
|
|
156
|
+
type KeyManagerInitStruct = z.infer<typeof keyManagerInitStructSchema>;
|
|
157
|
+
/**
|
|
158
|
+
* Complete deployment parameters for LSP23 Linked Contracts Factory.
|
|
159
|
+
*/
|
|
160
|
+
type DeployParams = z.infer<typeof deployParamsSchema>;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* LSP23 Deployment Encoding
|
|
164
|
+
*
|
|
165
|
+
* Generates deployment parameters for Universal Profile creation
|
|
166
|
+
* via the LSP23 Linked Contracts Factory on LUKSO.
|
|
167
|
+
*
|
|
168
|
+
* @see https://docs.lukso.tech/standards/smart-contracts/lsp23-linked-contracts-factory
|
|
169
|
+
*/
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Generate deployment parameters for Universal Profile
|
|
173
|
+
*
|
|
174
|
+
* Creates the initialization structs needed to deploy a Universal Profile
|
|
175
|
+
* via the LSP23 Linked Contracts Factory.
|
|
176
|
+
*
|
|
177
|
+
* @param salt - 32-byte hex salt for deterministic deployment (0x + 64 hex chars)
|
|
178
|
+
* @param controllerAddress - Address of the main controller (will have full permissions)
|
|
179
|
+
* @returns Deployment parameters for LSP23 factory
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```typescript
|
|
183
|
+
* import { generateDeployParams } from '@chillwhales/lsp23';
|
|
184
|
+
*
|
|
185
|
+
* const params = generateDeployParams({
|
|
186
|
+
* salt: '0x' + '00'.repeat(32),
|
|
187
|
+
* controllerAddress: '0x1234...',
|
|
188
|
+
* });
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
declare function generateDeployParams({ salt, controllerAddress, }: {
|
|
192
|
+
salt: string;
|
|
193
|
+
controllerAddress: Address;
|
|
194
|
+
}): DeployParams;
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* LSP23 Type Guards
|
|
198
|
+
*
|
|
199
|
+
* Runtime type guards for LSP23 schemas.
|
|
200
|
+
*/
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Type guard for Universal Profile initialization struct
|
|
204
|
+
*/
|
|
205
|
+
declare function isUniversalProfileInitStruct(obj: unknown): obj is z.infer<typeof universalProfileInitStructSchema>;
|
|
206
|
+
/**
|
|
207
|
+
* Type guard for Key Manager initialization struct
|
|
208
|
+
*/
|
|
209
|
+
declare function isKeyManagerInitStruct(obj: unknown): obj is z.infer<typeof keyManagerInitStructSchema>;
|
|
210
|
+
/**
|
|
211
|
+
* Type guard for complete deployment parameters
|
|
212
|
+
*/
|
|
213
|
+
declare function isDeployParams(obj: unknown): obj is z.infer<typeof deployParamsSchema>;
|
|
214
|
+
|
|
215
|
+
export { IMPLEMENTATIONS, LSP23_FACTORY_ADDRESS, LSP23_POST_DEPLOYMENT_MODULE, UNIVERSAL_RECEIVER_ADDRESS, deployParamsSchema, generateDeployParams, isDeployParams, isKeyManagerInitStruct, isUniversalProfileInitStruct, keyManagerInitStructSchema, universalProfileInitStructSchema };
|
|
216
|
+
export type { DeployParams, KeyManagerInitStruct, UniversalProfileInitStruct };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { Address } from 'viem';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* LUKSO Mainnet contract addresses for LSP23 deployment.
|
|
6
|
+
* These are constants specific to the LUKSO network.
|
|
7
|
+
*/
|
|
8
|
+
/** LSP23 Linked Contracts Factory */
|
|
9
|
+
declare const LSP23_FACTORY_ADDRESS = "0x2300000A84D25dF63081feAa37ba6b62C4c89a30";
|
|
10
|
+
/** LSP23 Post Deployment Module */
|
|
11
|
+
declare const LSP23_POST_DEPLOYMENT_MODULE = "0x000000000066093407b6704B89793beFfD0D8F00";
|
|
12
|
+
/** Universal Receiver Delegate */
|
|
13
|
+
declare const UNIVERSAL_RECEIVER_ADDRESS = "0x7870C5B8BC9572A8001C3f96f7ff59961B23500D";
|
|
14
|
+
/** Standard implementation contracts for proxy patterns */
|
|
15
|
+
declare const IMPLEMENTATIONS: {
|
|
16
|
+
/** Universal Profile implementation contract */
|
|
17
|
+
readonly UNIVERSAL_PROFILE: "0x3024D38EA2434BA6635003Dc1BDC0daB5882ED4F";
|
|
18
|
+
/** LSP6 Key Manager implementation contract */
|
|
19
|
+
readonly LSP6_KEY_MANAGER: "0x2Fe3AeD98684E7351aD2D408A43cE09a738BF8a4";
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* LSP23 Linked Contracts Factory Schemas
|
|
24
|
+
*
|
|
25
|
+
* Zod schemas for validating LSP23 deployment parameters.
|
|
26
|
+
*
|
|
27
|
+
* @see https://docs.lukso.tech/standards/smart-contracts/lsp23-linked-contracts-factory
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Schema for Universal Profile initialization struct
|
|
32
|
+
*/
|
|
33
|
+
declare const universalProfileInitStructSchema: z.ZodObject<{
|
|
34
|
+
salt: z.ZodString;
|
|
35
|
+
fundingAmount: z.ZodBigInt;
|
|
36
|
+
implementationContract: z.ZodString;
|
|
37
|
+
initializationCalldata: z.ZodString;
|
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
|
39
|
+
salt: string;
|
|
40
|
+
fundingAmount: bigint;
|
|
41
|
+
implementationContract: string;
|
|
42
|
+
initializationCalldata: string;
|
|
43
|
+
}, {
|
|
44
|
+
salt: string;
|
|
45
|
+
fundingAmount: bigint;
|
|
46
|
+
implementationContract: string;
|
|
47
|
+
initializationCalldata: string;
|
|
48
|
+
}>;
|
|
49
|
+
/**
|
|
50
|
+
* Schema for Key Manager initialization struct
|
|
51
|
+
*/
|
|
52
|
+
declare const keyManagerInitStructSchema: z.ZodObject<{
|
|
53
|
+
fundingAmount: z.ZodBigInt;
|
|
54
|
+
implementationContract: z.ZodString;
|
|
55
|
+
addPrimaryContractAddress: z.ZodBoolean;
|
|
56
|
+
initializationCalldata: z.ZodString;
|
|
57
|
+
extraInitializationParams: z.ZodString;
|
|
58
|
+
}, "strip", z.ZodTypeAny, {
|
|
59
|
+
fundingAmount: bigint;
|
|
60
|
+
implementationContract: string;
|
|
61
|
+
initializationCalldata: string;
|
|
62
|
+
addPrimaryContractAddress: boolean;
|
|
63
|
+
extraInitializationParams: string;
|
|
64
|
+
}, {
|
|
65
|
+
fundingAmount: bigint;
|
|
66
|
+
implementationContract: string;
|
|
67
|
+
initializationCalldata: string;
|
|
68
|
+
addPrimaryContractAddress: boolean;
|
|
69
|
+
extraInitializationParams: string;
|
|
70
|
+
}>;
|
|
71
|
+
/**
|
|
72
|
+
* Schema for complete deployment parameters
|
|
73
|
+
*/
|
|
74
|
+
declare const deployParamsSchema: z.ZodObject<{
|
|
75
|
+
universalProfileInitStruct: z.ZodObject<{
|
|
76
|
+
salt: z.ZodString;
|
|
77
|
+
fundingAmount: z.ZodBigInt;
|
|
78
|
+
implementationContract: z.ZodString;
|
|
79
|
+
initializationCalldata: z.ZodString;
|
|
80
|
+
}, "strip", z.ZodTypeAny, {
|
|
81
|
+
salt: string;
|
|
82
|
+
fundingAmount: bigint;
|
|
83
|
+
implementationContract: string;
|
|
84
|
+
initializationCalldata: string;
|
|
85
|
+
}, {
|
|
86
|
+
salt: string;
|
|
87
|
+
fundingAmount: bigint;
|
|
88
|
+
implementationContract: string;
|
|
89
|
+
initializationCalldata: string;
|
|
90
|
+
}>;
|
|
91
|
+
keyManagerInitStruct: z.ZodObject<{
|
|
92
|
+
fundingAmount: z.ZodBigInt;
|
|
93
|
+
implementationContract: z.ZodString;
|
|
94
|
+
addPrimaryContractAddress: z.ZodBoolean;
|
|
95
|
+
initializationCalldata: z.ZodString;
|
|
96
|
+
extraInitializationParams: z.ZodString;
|
|
97
|
+
}, "strip", z.ZodTypeAny, {
|
|
98
|
+
fundingAmount: bigint;
|
|
99
|
+
implementationContract: string;
|
|
100
|
+
initializationCalldata: string;
|
|
101
|
+
addPrimaryContractAddress: boolean;
|
|
102
|
+
extraInitializationParams: string;
|
|
103
|
+
}, {
|
|
104
|
+
fundingAmount: bigint;
|
|
105
|
+
implementationContract: string;
|
|
106
|
+
initializationCalldata: string;
|
|
107
|
+
addPrimaryContractAddress: boolean;
|
|
108
|
+
extraInitializationParams: string;
|
|
109
|
+
}>;
|
|
110
|
+
initializeEncodedBytes: z.ZodString;
|
|
111
|
+
}, "strip", z.ZodTypeAny, {
|
|
112
|
+
universalProfileInitStruct: {
|
|
113
|
+
salt: string;
|
|
114
|
+
fundingAmount: bigint;
|
|
115
|
+
implementationContract: string;
|
|
116
|
+
initializationCalldata: string;
|
|
117
|
+
};
|
|
118
|
+
keyManagerInitStruct: {
|
|
119
|
+
fundingAmount: bigint;
|
|
120
|
+
implementationContract: string;
|
|
121
|
+
initializationCalldata: string;
|
|
122
|
+
addPrimaryContractAddress: boolean;
|
|
123
|
+
extraInitializationParams: string;
|
|
124
|
+
};
|
|
125
|
+
initializeEncodedBytes: string;
|
|
126
|
+
}, {
|
|
127
|
+
universalProfileInitStruct: {
|
|
128
|
+
salt: string;
|
|
129
|
+
fundingAmount: bigint;
|
|
130
|
+
implementationContract: string;
|
|
131
|
+
initializationCalldata: string;
|
|
132
|
+
};
|
|
133
|
+
keyManagerInitStruct: {
|
|
134
|
+
fundingAmount: bigint;
|
|
135
|
+
implementationContract: string;
|
|
136
|
+
initializationCalldata: string;
|
|
137
|
+
addPrimaryContractAddress: boolean;
|
|
138
|
+
extraInitializationParams: string;
|
|
139
|
+
};
|
|
140
|
+
initializeEncodedBytes: string;
|
|
141
|
+
}>;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* LSP23 Inferred Types
|
|
145
|
+
*
|
|
146
|
+
* TypeScript types inferred from LSP23 Zod schemas.
|
|
147
|
+
*/
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Initialization struct for Universal Profile deployment via LSP23.
|
|
151
|
+
*/
|
|
152
|
+
type UniversalProfileInitStruct = z.infer<typeof universalProfileInitStructSchema>;
|
|
153
|
+
/**
|
|
154
|
+
* Initialization struct for Key Manager deployment via LSP23.
|
|
155
|
+
*/
|
|
156
|
+
type KeyManagerInitStruct = z.infer<typeof keyManagerInitStructSchema>;
|
|
157
|
+
/**
|
|
158
|
+
* Complete deployment parameters for LSP23 Linked Contracts Factory.
|
|
159
|
+
*/
|
|
160
|
+
type DeployParams = z.infer<typeof deployParamsSchema>;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* LSP23 Deployment Encoding
|
|
164
|
+
*
|
|
165
|
+
* Generates deployment parameters for Universal Profile creation
|
|
166
|
+
* via the LSP23 Linked Contracts Factory on LUKSO.
|
|
167
|
+
*
|
|
168
|
+
* @see https://docs.lukso.tech/standards/smart-contracts/lsp23-linked-contracts-factory
|
|
169
|
+
*/
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Generate deployment parameters for Universal Profile
|
|
173
|
+
*
|
|
174
|
+
* Creates the initialization structs needed to deploy a Universal Profile
|
|
175
|
+
* via the LSP23 Linked Contracts Factory.
|
|
176
|
+
*
|
|
177
|
+
* @param salt - 32-byte hex salt for deterministic deployment (0x + 64 hex chars)
|
|
178
|
+
* @param controllerAddress - Address of the main controller (will have full permissions)
|
|
179
|
+
* @returns Deployment parameters for LSP23 factory
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```typescript
|
|
183
|
+
* import { generateDeployParams } from '@chillwhales/lsp23';
|
|
184
|
+
*
|
|
185
|
+
* const params = generateDeployParams({
|
|
186
|
+
* salt: '0x' + '00'.repeat(32),
|
|
187
|
+
* controllerAddress: '0x1234...',
|
|
188
|
+
* });
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
declare function generateDeployParams({ salt, controllerAddress, }: {
|
|
192
|
+
salt: string;
|
|
193
|
+
controllerAddress: Address;
|
|
194
|
+
}): DeployParams;
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* LSP23 Type Guards
|
|
198
|
+
*
|
|
199
|
+
* Runtime type guards for LSP23 schemas.
|
|
200
|
+
*/
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Type guard for Universal Profile initialization struct
|
|
204
|
+
*/
|
|
205
|
+
declare function isUniversalProfileInitStruct(obj: unknown): obj is z.infer<typeof universalProfileInitStructSchema>;
|
|
206
|
+
/**
|
|
207
|
+
* Type guard for Key Manager initialization struct
|
|
208
|
+
*/
|
|
209
|
+
declare function isKeyManagerInitStruct(obj: unknown): obj is z.infer<typeof keyManagerInitStructSchema>;
|
|
210
|
+
/**
|
|
211
|
+
* Type guard for complete deployment parameters
|
|
212
|
+
*/
|
|
213
|
+
declare function isDeployParams(obj: unknown): obj is z.infer<typeof deployParamsSchema>;
|
|
214
|
+
|
|
215
|
+
export { IMPLEMENTATIONS, LSP23_FACTORY_ADDRESS, LSP23_POST_DEPLOYMENT_MODULE, UNIVERSAL_RECEIVER_ADDRESS, deployParamsSchema, generateDeployParams, isDeployParams, isKeyManagerInitStruct, isUniversalProfileInitStruct, keyManagerInitStructSchema, universalProfileInitStructSchema };
|
|
216
|
+
export type { DeployParams, KeyManagerInitStruct, UniversalProfileInitStruct };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import ERC725 from '@erc725/erc725.js';
|
|
2
|
+
import LSP1UniversalReceiverDelegateSchemas from '@erc725/erc725.js/schemas/LSP1UniversalReceiverDelegate.json';
|
|
3
|
+
import LSP6KeyManagerSchemas from '@erc725/erc725.js/schemas/LSP6KeyManager.json';
|
|
4
|
+
import { universalProfileInitAbi } from '@lukso/universalprofile-contracts/abi';
|
|
5
|
+
import { encodeFunctionData, getAddress, toHex, toFunctionSelector, isHex, encodeAbiParameters } from 'viem';
|
|
6
|
+
import { bytesSchema, addressSchema, bytes32Schema } from '@chillwhales/lsp2';
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
|
|
9
|
+
const LSP23_FACTORY_ADDRESS = "0x2300000A84D25dF63081feAa37ba6b62C4c89a30";
|
|
10
|
+
const LSP23_POST_DEPLOYMENT_MODULE = "0x000000000066093407b6704B89793beFfD0D8F00";
|
|
11
|
+
const UNIVERSAL_RECEIVER_ADDRESS = "0x7870C5B8BC9572A8001C3f96f7ff59961B23500D";
|
|
12
|
+
const IMPLEMENTATIONS = {
|
|
13
|
+
/** Universal Profile implementation contract */
|
|
14
|
+
UNIVERSAL_PROFILE: "0x3024D38EA2434BA6635003Dc1BDC0daB5882ED4F",
|
|
15
|
+
/** LSP6 Key Manager implementation contract */
|
|
16
|
+
LSP6_KEY_MANAGER: "0x2Fe3AeD98684E7351aD2D408A43cE09a738BF8a4"
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
function generateDeployParams({
|
|
20
|
+
salt,
|
|
21
|
+
controllerAddress
|
|
22
|
+
}) {
|
|
23
|
+
const universalProfileInitStruct = {
|
|
24
|
+
salt,
|
|
25
|
+
fundingAmount: BigInt(0),
|
|
26
|
+
implementationContract: getAddress(IMPLEMENTATIONS.UNIVERSAL_PROFILE),
|
|
27
|
+
initializationCalldata: encodeFunctionData({
|
|
28
|
+
abi: universalProfileInitAbi,
|
|
29
|
+
functionName: "initialize",
|
|
30
|
+
args: [getAddress(LSP23_POST_DEPLOYMENT_MODULE)]
|
|
31
|
+
})
|
|
32
|
+
};
|
|
33
|
+
const keyManagerInitStruct = {
|
|
34
|
+
fundingAmount: BigInt(0),
|
|
35
|
+
implementationContract: getAddress(IMPLEMENTATIONS.LSP6_KEY_MANAGER),
|
|
36
|
+
addPrimaryContractAddress: true,
|
|
37
|
+
initializationCalldata: toFunctionSelector(
|
|
38
|
+
"function initialize(address target)"
|
|
39
|
+
),
|
|
40
|
+
extraInitializationParams: toHex("")
|
|
41
|
+
};
|
|
42
|
+
const erc725 = new ERC725([
|
|
43
|
+
...LSP6KeyManagerSchemas,
|
|
44
|
+
...LSP1UniversalReceiverDelegateSchemas
|
|
45
|
+
]);
|
|
46
|
+
const setDataKeysAndValues = erc725.encodeData([
|
|
47
|
+
{
|
|
48
|
+
keyName: "LSP1UniversalReceiverDelegate",
|
|
49
|
+
value: UNIVERSAL_RECEIVER_ADDRESS
|
|
50
|
+
},
|
|
51
|
+
// Universal Receiver data key and value
|
|
52
|
+
{
|
|
53
|
+
keyName: "AddressPermissions:Permissions:<address>",
|
|
54
|
+
dynamicKeyParts: [UNIVERSAL_RECEIVER_ADDRESS],
|
|
55
|
+
value: erc725.encodePermissions({
|
|
56
|
+
REENTRANCY: true,
|
|
57
|
+
SUPER_SETDATA: true
|
|
58
|
+
})
|
|
59
|
+
},
|
|
60
|
+
// Universal Receiver Delegate permissions data key and value
|
|
61
|
+
{
|
|
62
|
+
keyName: "AddressPermissions:Permissions:<address>",
|
|
63
|
+
dynamicKeyParts: [controllerAddress],
|
|
64
|
+
value: erc725.encodePermissions({
|
|
65
|
+
CHANGEOWNER: true,
|
|
66
|
+
ADDCONTROLLER: true,
|
|
67
|
+
EDITPERMISSIONS: true,
|
|
68
|
+
ADDEXTENSIONS: true,
|
|
69
|
+
CHANGEEXTENSIONS: true,
|
|
70
|
+
ADDUNIVERSALRECEIVERDELEGATE: true,
|
|
71
|
+
CHANGEUNIVERSALRECEIVERDELEGATE: true,
|
|
72
|
+
REENTRANCY: false,
|
|
73
|
+
SUPER_TRANSFERVALUE: true,
|
|
74
|
+
TRANSFERVALUE: true,
|
|
75
|
+
SUPER_CALL: true,
|
|
76
|
+
CALL: true,
|
|
77
|
+
SUPER_STATICCALL: true,
|
|
78
|
+
STATICCALL: true,
|
|
79
|
+
SUPER_DELEGATECALL: false,
|
|
80
|
+
DELEGATECALL: false,
|
|
81
|
+
DEPLOY: true,
|
|
82
|
+
SUPER_SETDATA: true,
|
|
83
|
+
SETDATA: true,
|
|
84
|
+
ENCRYPT: true,
|
|
85
|
+
DECRYPT: true,
|
|
86
|
+
SIGN: true,
|
|
87
|
+
EXECUTE_RELAY_CALL: true
|
|
88
|
+
})
|
|
89
|
+
// Main Controller permissions data key and value
|
|
90
|
+
},
|
|
91
|
+
// Address Permissions array length = 2, and the controller addresses at each index
|
|
92
|
+
{
|
|
93
|
+
keyName: "AddressPermissions[]",
|
|
94
|
+
value: [UNIVERSAL_RECEIVER_ADDRESS, controllerAddress]
|
|
95
|
+
}
|
|
96
|
+
]);
|
|
97
|
+
const keys = setDataKeysAndValues.keys.filter((value) => isHex(value));
|
|
98
|
+
const values = setDataKeysAndValues.values.filter((value) => isHex(value));
|
|
99
|
+
if (keys.length !== setDataKeysAndValues.keys.length || values.length !== setDataKeysAndValues.values.length)
|
|
100
|
+
throw new Error("Invalid initialize parameters");
|
|
101
|
+
const initializeEncodedBytes = encodeAbiParameters(
|
|
102
|
+
[{ type: "bytes32[]" }, { type: "bytes[]" }],
|
|
103
|
+
[keys, values]
|
|
104
|
+
);
|
|
105
|
+
return {
|
|
106
|
+
universalProfileInitStruct,
|
|
107
|
+
keyManagerInitStruct,
|
|
108
|
+
initializeEncodedBytes
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const saltSchema = bytes32Schema;
|
|
113
|
+
const universalProfileInitStructSchema = z.object({
|
|
114
|
+
salt: saltSchema,
|
|
115
|
+
fundingAmount: z.bigint({
|
|
116
|
+
invalid_type_error: "Funding amount must be a bigint"
|
|
117
|
+
}),
|
|
118
|
+
implementationContract: addressSchema,
|
|
119
|
+
initializationCalldata: bytesSchema
|
|
120
|
+
});
|
|
121
|
+
const keyManagerInitStructSchema = z.object({
|
|
122
|
+
fundingAmount: z.bigint({
|
|
123
|
+
invalid_type_error: "Funding amount must be a bigint"
|
|
124
|
+
}),
|
|
125
|
+
implementationContract: addressSchema,
|
|
126
|
+
addPrimaryContractAddress: z.boolean({
|
|
127
|
+
invalid_type_error: "addPrimaryContractAddress must be a boolean"
|
|
128
|
+
}),
|
|
129
|
+
initializationCalldata: bytesSchema,
|
|
130
|
+
extraInitializationParams: bytesSchema
|
|
131
|
+
});
|
|
132
|
+
const deployParamsSchema = z.object({
|
|
133
|
+
universalProfileInitStruct: universalProfileInitStructSchema,
|
|
134
|
+
keyManagerInitStruct: keyManagerInitStructSchema,
|
|
135
|
+
initializeEncodedBytes: bytesSchema
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
function isUniversalProfileInitStruct(obj) {
|
|
139
|
+
const { success } = universalProfileInitStructSchema.safeParse(obj);
|
|
140
|
+
return success;
|
|
141
|
+
}
|
|
142
|
+
function isKeyManagerInitStruct(obj) {
|
|
143
|
+
const { success } = keyManagerInitStructSchema.safeParse(obj);
|
|
144
|
+
return success;
|
|
145
|
+
}
|
|
146
|
+
function isDeployParams(obj) {
|
|
147
|
+
const { success } = deployParamsSchema.safeParse(obj);
|
|
148
|
+
return success;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export { IMPLEMENTATIONS, LSP23_FACTORY_ADDRESS, LSP23_POST_DEPLOYMENT_MODULE, UNIVERSAL_RECEIVER_ADDRESS, deployParamsSchema, generateDeployParams, isDeployParams, isKeyManagerInitStruct, isUniversalProfileInitStruct, keyManagerInitStructSchema, universalProfileInitStructSchema };
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@chillwhales/lsp23",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "LSP23 Linked Contracts Factory — deployment encoding utilities for Universal Profile creation on LUKSO",
|
|
6
|
+
"author": "b00ste",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"types": "./dist/index.d.mts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.mts",
|
|
12
|
+
"default": "./dist/index.mjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"LICENSE",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=22"
|
|
22
|
+
},
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/chillwhales/LSPs.git",
|
|
26
|
+
"directory": "packages/lsp23"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"chillwhales",
|
|
30
|
+
"lukso",
|
|
31
|
+
"lsp",
|
|
32
|
+
"lsp23",
|
|
33
|
+
"linked-contracts",
|
|
34
|
+
"universal-profile",
|
|
35
|
+
"deployment"
|
|
36
|
+
],
|
|
37
|
+
"sideEffects": false,
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@erc725/erc725.js": "^0.28.2",
|
|
40
|
+
"@lukso/universalprofile-contracts": "^0.15.5",
|
|
41
|
+
"zod": "^3.24.1",
|
|
42
|
+
"@chillwhales/lsp2": "0.1.1"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"viem": "^2.0.0"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"typescript": "^5.9.3",
|
|
49
|
+
"unbuild": "^3.6.1",
|
|
50
|
+
"viem": "^2.0.0",
|
|
51
|
+
"vitest": "^4.0.17",
|
|
52
|
+
"@chillwhales/config": "0.0.0"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "unbuild",
|
|
56
|
+
"build:watch": "unbuild --watch",
|
|
57
|
+
"clean": "rm -rf dist",
|
|
58
|
+
"test": "vitest run",
|
|
59
|
+
"test:watch": "vitest"
|
|
60
|
+
}
|
|
61
|
+
}
|