@aastar/admin 0.16.16
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/dist/ProtocolGovernance.d.ts +57 -0
- package/dist/ProtocolGovernance.js +118 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +33 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 AAStar
|
|
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.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type Address, type Hash, type Hex } from 'viem';
|
|
2
|
+
import { BaseClient, type ClientConfig, type TransactionOptions } from '@aastar/core';
|
|
3
|
+
export interface ProtocolParams {
|
|
4
|
+
minStake: bigint;
|
|
5
|
+
treasury: Address;
|
|
6
|
+
entryPoint: Address;
|
|
7
|
+
superPaymaster: Address;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* ProtocolGovernance - L3 Pattern
|
|
11
|
+
*
|
|
12
|
+
* Responsibilities:
|
|
13
|
+
* 1. Global Protocol Parameter Management (Registry, EntryPoint)
|
|
14
|
+
* 2. High-level Governance Operations (DAO Transfer, Upgrades)
|
|
15
|
+
* 3. SuperPaymaster & Module Approval
|
|
16
|
+
*/
|
|
17
|
+
export declare class ProtocolGovernance extends BaseClient {
|
|
18
|
+
registryAddress: Address;
|
|
19
|
+
entryPointAddress: Address;
|
|
20
|
+
constructor(config: ClientConfig & {
|
|
21
|
+
registryAddress: Address;
|
|
22
|
+
entryPointAddress: Address;
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* Update the Global Treasury Address where protocol fees are collected
|
|
26
|
+
*/
|
|
27
|
+
setTreasury(treasury: Address, options?: TransactionOptions): Promise<Hash>;
|
|
28
|
+
/**
|
|
29
|
+
* Update the supported EntryPoint address
|
|
30
|
+
*/
|
|
31
|
+
updateEntryPoint(entryPoint: Address, options?: TransactionOptions): Promise<Hash>;
|
|
32
|
+
/**
|
|
33
|
+
* Approve a new SuperPaymaster contract address
|
|
34
|
+
*/
|
|
35
|
+
setSuperPaymaster(paymaster: Address, options?: TransactionOptions): Promise<Hash>;
|
|
36
|
+
/**
|
|
37
|
+
* Set the Staking contract address
|
|
38
|
+
*/
|
|
39
|
+
setStaking(staking: Address, options?: TransactionOptions): Promise<Hash>;
|
|
40
|
+
/**
|
|
41
|
+
* Configure a Role's parameters (Admin only)
|
|
42
|
+
* e.g. Setting minStake for ROLE_PAYMASTER_SUPER
|
|
43
|
+
*/
|
|
44
|
+
configureRole(params: {
|
|
45
|
+
roleId: Hex;
|
|
46
|
+
minStake?: bigint;
|
|
47
|
+
entryBurn?: bigint;
|
|
48
|
+
exitFeePercent?: bigint;
|
|
49
|
+
minExitFee?: bigint;
|
|
50
|
+
}, options?: TransactionOptions): Promise<Hash>;
|
|
51
|
+
/**
|
|
52
|
+
* Transfer Protocol Ownership to a DAO (Multisig/Timelock)
|
|
53
|
+
* This is the final step of "Protocol Admin" lifecycle.
|
|
54
|
+
*/
|
|
55
|
+
transferToDAO(daoAddress: Address, options?: TransactionOptions): Promise<Hash>;
|
|
56
|
+
getProtocolParams(): Promise<ProtocolParams>;
|
|
57
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { BaseClient } from '@aastar/core';
|
|
2
|
+
import { registryActions } from '@aastar/core'; // L2/L1 Actions
|
|
3
|
+
/**
|
|
4
|
+
* ProtocolGovernance - L3 Pattern
|
|
5
|
+
*
|
|
6
|
+
* Responsibilities:
|
|
7
|
+
* 1. Global Protocol Parameter Management (Registry, EntryPoint)
|
|
8
|
+
* 2. High-level Governance Operations (DAO Transfer, Upgrades)
|
|
9
|
+
* 3. SuperPaymaster & Module Approval
|
|
10
|
+
*/
|
|
11
|
+
export class ProtocolGovernance extends BaseClient {
|
|
12
|
+
registryAddress;
|
|
13
|
+
entryPointAddress;
|
|
14
|
+
constructor(config) {
|
|
15
|
+
super(config);
|
|
16
|
+
this.registryAddress = config.registryAddress;
|
|
17
|
+
this.entryPointAddress = config.entryPointAddress;
|
|
18
|
+
}
|
|
19
|
+
// ===========================================
|
|
20
|
+
// 1. Global Parameter Management
|
|
21
|
+
// ===========================================
|
|
22
|
+
/**
|
|
23
|
+
* Update the Global Treasury Address where protocol fees are collected
|
|
24
|
+
*/
|
|
25
|
+
async setTreasury(treasury, options) {
|
|
26
|
+
// Note: Registry might not have direct setTreasury if it relies on SuperPaymaster's config.
|
|
27
|
+
// Assuming Registry has ownership pointers or config pointers.
|
|
28
|
+
// If Logic resides in SuperPaymaster, we would use superPaymasterActions.
|
|
29
|
+
// Based on provided ABI/Actions, Registry manages Role Configs mainly.
|
|
30
|
+
// Let's assume we are updating a System Role or similar global config if available,
|
|
31
|
+
// OR adhering to what registryActions provides.
|
|
32
|
+
// Checking registryActions... it has 'transferOwnership' but maybe not direct 'setTreasury' depending on version.
|
|
33
|
+
// If strictly following ABI, we might need to update a specific Role Parameter (e.g. AOA/Super config).
|
|
34
|
+
throw new Error("Method not mapped to RegistryABI v1. Please verify contract capabilities.");
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Update the supported EntryPoint address
|
|
38
|
+
*/
|
|
39
|
+
async updateEntryPoint(entryPoint, options) {
|
|
40
|
+
// Placeholder: Real implementation depends on if Registry stores EntryPoint
|
|
41
|
+
// registryActions typically provides getters. Setters usually restricted to Owner.
|
|
42
|
+
// If action not available, throw standard error.
|
|
43
|
+
throw new Error("Method not mapped to RegistryABI v1.");
|
|
44
|
+
}
|
|
45
|
+
// ===========================================
|
|
46
|
+
// 2. Role & Module Governance
|
|
47
|
+
// ===========================================
|
|
48
|
+
/**
|
|
49
|
+
* Approve a new SuperPaymaster contract address
|
|
50
|
+
*/
|
|
51
|
+
async setSuperPaymaster(paymaster, options) {
|
|
52
|
+
const registry = registryActions(this.registryAddress);
|
|
53
|
+
return await registry(this.client).setSuperPaymaster({
|
|
54
|
+
paymaster,
|
|
55
|
+
account: options?.account
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Set the Staking contract address
|
|
60
|
+
*/
|
|
61
|
+
async setStaking(staking, options) {
|
|
62
|
+
const registry = registryActions(this.registryAddress);
|
|
63
|
+
return await registry(this.client).setStaking({
|
|
64
|
+
staking,
|
|
65
|
+
account: options?.account
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Configure a Role's parameters (Admin only)
|
|
70
|
+
* e.g. Setting minStake for ROLE_PAYMASTER_SUPER
|
|
71
|
+
*/
|
|
72
|
+
async configureRole(params, options) {
|
|
73
|
+
const registry = registryActions(this.registryAddress);
|
|
74
|
+
// Use the admin shortcut if only updating financial params
|
|
75
|
+
if (params.minStake !== undefined || params.entryBurn !== undefined) {
|
|
76
|
+
return await registry(this.client).adminConfigureRole({
|
|
77
|
+
roleId: params.roleId,
|
|
78
|
+
minStake: params.minStake || 0n, // Careful: this might overwrite if API expects full set
|
|
79
|
+
entryBurn: params.entryBurn || 0n,
|
|
80
|
+
exitFeePercent: params.exitFeePercent || 0n,
|
|
81
|
+
minExitFee: params.minExitFee || 0n,
|
|
82
|
+
account: options?.account
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
throw new Error("Invalid parameters for configureRole");
|
|
86
|
+
}
|
|
87
|
+
// ===========================================
|
|
88
|
+
// 3. Transfer to DAO (Exit/Upgrade)
|
|
89
|
+
// ===========================================
|
|
90
|
+
/**
|
|
91
|
+
* Transfer Protocol Ownership to a DAO (Multisig/Timelock)
|
|
92
|
+
* This is the final step of "Protocol Admin" lifecycle.
|
|
93
|
+
*/
|
|
94
|
+
async transferToDAO(daoAddress, options) {
|
|
95
|
+
const registry = registryActions(this.registryAddress);
|
|
96
|
+
return await registry(this.client).transferOwnership({
|
|
97
|
+
newOwner: daoAddress,
|
|
98
|
+
account: options?.account
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
// ===========================================
|
|
102
|
+
// 4. Query Capabilities
|
|
103
|
+
// ===========================================
|
|
104
|
+
async getProtocolParams() {
|
|
105
|
+
const registry = registryActions(this.registryAddress)(this.client); // Read-only via Client
|
|
106
|
+
// Parallel fetch
|
|
107
|
+
const [sp, staking] = await Promise.all([
|
|
108
|
+
registry.SUPER_PAYMASTER(),
|
|
109
|
+
registry.GTOKEN_STAKING()
|
|
110
|
+
]);
|
|
111
|
+
return {
|
|
112
|
+
minStake: 0n, // Global default not directly exposed, usually per role
|
|
113
|
+
treasury: await registry.owner(), // Approximation for now
|
|
114
|
+
entryPoint: this.entryPointAddress,
|
|
115
|
+
superPaymaster: sp
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ProtocolGovernance.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ProtocolGovernance.js';
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aastar/admin",
|
|
3
|
+
"version": "0.16.16",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"type": "module",
|
|
8
|
+
"description": "Admin/Governance client for AAstar SDK",
|
|
9
|
+
"main": "dist/index.js",
|
|
10
|
+
"types": "dist/index.d.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
14
|
+
"keywords": [
|
|
15
|
+
"aastar",
|
|
16
|
+
"admin",
|
|
17
|
+
"governance",
|
|
18
|
+
"web3"
|
|
19
|
+
],
|
|
20
|
+
"author": "AAstar Team",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"viem": "2.43.3",
|
|
24
|
+
"@aastar/core": "0.16.16"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"typescript": "5.7.2"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsc",
|
|
31
|
+
"test": "vitest run"
|
|
32
|
+
}
|
|
33
|
+
}
|