@aastar/dapp 0.16.7
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/core/src/abis/BLSAggregator.json +686 -0
- package/dist/core/src/abis/BLSValidator.json +42 -0
- package/dist/core/src/abis/DVTValidator.json +368 -0
- package/dist/core/src/abis/EntryPoint.json +1382 -0
- package/dist/core/src/abis/GToken.json +513 -0
- package/dist/core/src/abis/GTokenStaking.json +949 -0
- package/dist/core/src/abis/MySBT.json +1518 -0
- package/dist/core/src/abis/Paymaster.json +1143 -0
- package/dist/core/src/abis/PaymasterFactory.json +640 -0
- package/dist/core/src/abis/Registry.json +1942 -0
- package/dist/core/src/abis/ReputationSystem.json +699 -0
- package/dist/core/src/abis/SimpleAccount.json +560 -0
- package/dist/core/src/abis/SimpleAccountFactory.json +111 -0
- package/dist/core/src/abis/SuperPaymaster.json +1781 -0
- package/dist/core/src/abis/index.d.ts +1126 -0
- package/dist/core/src/abis/index.js +91 -0
- package/dist/core/src/abis/xPNTsFactory.json +718 -0
- package/dist/core/src/abis/xPNTsToken.json +1280 -0
- package/dist/core/src/actions/StateValidator.d.ts +68 -0
- package/dist/core/src/actions/StateValidator.js +187 -0
- package/dist/core/src/actions/account.d.ts +55 -0
- package/dist/core/src/actions/account.js +133 -0
- package/dist/core/src/actions/aggregator.d.ts +17 -0
- package/dist/core/src/actions/aggregator.js +31 -0
- package/dist/core/src/actions/dvt.d.ts +30 -0
- package/dist/core/src/actions/dvt.js +41 -0
- package/dist/core/src/actions/entryPoint.d.ts +90 -0
- package/dist/core/src/actions/entryPoint.js +211 -0
- package/dist/core/src/actions/factory.d.ts +215 -0
- package/dist/core/src/actions/factory.js +442 -0
- package/dist/core/src/actions/faucet.d.ts +48 -0
- package/dist/core/src/actions/faucet.js +337 -0
- package/dist/core/src/actions/gtokenExtended.d.ts +39 -0
- package/dist/core/src/actions/gtokenExtended.js +115 -0
- package/dist/core/src/actions/index.d.ts +15 -0
- package/dist/core/src/actions/index.js +17 -0
- package/dist/core/src/actions/paymasterV4.d.ts +170 -0
- package/dist/core/src/actions/paymasterV4.js +334 -0
- package/dist/core/src/actions/registry.d.ts +246 -0
- package/dist/core/src/actions/registry.js +667 -0
- package/dist/core/src/actions/reputation.d.ts +129 -0
- package/dist/core/src/actions/reputation.js +281 -0
- package/dist/core/src/actions/sbt.d.ts +191 -0
- package/dist/core/src/actions/sbt.js +533 -0
- package/dist/core/src/actions/staking.d.ts +132 -0
- package/dist/core/src/actions/staking.js +330 -0
- package/dist/core/src/actions/superPaymaster.d.ts +237 -0
- package/dist/core/src/actions/superPaymaster.js +644 -0
- package/dist/core/src/actions/tokens.d.ts +229 -0
- package/dist/core/src/actions/tokens.js +415 -0
- package/dist/core/src/branding.d.ts +30 -0
- package/dist/core/src/branding.js +30 -0
- package/dist/core/src/clients/BaseClient.d.ts +25 -0
- package/dist/core/src/clients/BaseClient.js +66 -0
- package/dist/core/src/clients/types.d.ts +60 -0
- package/dist/core/src/clients/types.js +1 -0
- package/dist/core/src/clients.d.ts +5 -0
- package/dist/core/src/clients.js +11 -0
- package/dist/core/src/communities.d.ts +52 -0
- package/dist/core/src/communities.js +73 -0
- package/dist/core/src/config/ContractConfigManager.d.ts +20 -0
- package/dist/core/src/config/ContractConfigManager.js +48 -0
- package/dist/core/src/constants.d.ts +88 -0
- package/dist/core/src/constants.js +125 -0
- package/dist/core/src/contract-addresses.d.ts +110 -0
- package/dist/core/src/contract-addresses.js +99 -0
- package/dist/core/src/contracts.d.ts +424 -0
- package/dist/core/src/contracts.js +343 -0
- package/dist/core/src/crypto/blsSigner.d.ts +64 -0
- package/dist/core/src/crypto/blsSigner.js +98 -0
- package/dist/core/src/crypto/index.d.ts +1 -0
- package/dist/core/src/crypto/index.js +1 -0
- package/dist/core/src/index.d.ts +21 -0
- package/dist/core/src/index.js +21 -0
- package/dist/core/src/networks.d.ts +127 -0
- package/dist/core/src/networks.js +118 -0
- package/dist/core/src/requirementChecker.d.ts +38 -0
- package/dist/core/src/requirementChecker.js +139 -0
- package/dist/core/src/roles.d.ts +204 -0
- package/dist/core/src/roles.js +211 -0
- package/dist/core/src/utils/validation.d.ts +24 -0
- package/dist/core/src/utils/validation.js +56 -0
- package/dist/dapp/src/index.d.ts +3 -0
- package/dist/dapp/src/index.js +3 -0
- package/dist/dapp/src/ui/components/EvaluationPanel.d.ts +11 -0
- package/dist/dapp/src/ui/components/EvaluationPanel.js +37 -0
- package/dist/dapp/src/ui/hooks/useCreditScore.d.ts +13 -0
- package/dist/dapp/src/ui/hooks/useCreditScore.js +32 -0
- package/dist/dapp/src/ui/hooks/useSuperPaymaster.d.ts +8 -0
- package/dist/dapp/src/ui/hooks/useSuperPaymaster.js +23 -0
- package/dist/dapp/src/ui/index.d.ts +4 -0
- package/dist/dapp/src/ui/index.js +17 -0
- package/dist/paymaster/src/SuperPaymaster/index.d.ts +44 -0
- package/dist/paymaster/src/SuperPaymaster/index.js +133 -0
- package/dist/paymaster/src/V4/PaymasterClient.d.ts +79 -0
- package/dist/paymaster/src/V4/PaymasterClient.js +315 -0
- package/dist/paymaster/src/V4/PaymasterOperator.d.ts +41 -0
- package/dist/paymaster/src/V4/PaymasterOperator.js +241 -0
- package/dist/paymaster/src/V4/PaymasterUtils.d.ts +55 -0
- package/dist/paymaster/src/V4/PaymasterUtils.js +124 -0
- package/dist/paymaster/src/V4/SuperPaymasterClient.d.ts +21 -0
- package/dist/paymaster/src/V4/SuperPaymasterClient.js +73 -0
- package/dist/paymaster/src/V4/index.d.ts +4 -0
- package/dist/paymaster/src/V4/index.js +4 -0
- package/dist/paymaster/src/index.d.ts +2 -0
- package/dist/paymaster/src/index.js +4 -0
- package/package.json +31 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { type Hex, type Address, type Chain } from 'viem';
|
|
2
|
+
/**
|
|
3
|
+
* Interface definitions
|
|
4
|
+
*/
|
|
5
|
+
export interface ValidationParams {
|
|
6
|
+
rpcUrl: string;
|
|
7
|
+
chain: Chain;
|
|
8
|
+
}
|
|
9
|
+
export interface RoleValidationParams extends ValidationParams {
|
|
10
|
+
registryAddress: Address;
|
|
11
|
+
roleId: Hex;
|
|
12
|
+
userAddress: Address;
|
|
13
|
+
}
|
|
14
|
+
export interface BalanceValidationParams extends ValidationParams {
|
|
15
|
+
address: Address;
|
|
16
|
+
minBalance?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface TokenBalanceValidationParams extends BalanceValidationParams {
|
|
19
|
+
tokenAddress: Address;
|
|
20
|
+
}
|
|
21
|
+
export interface DeploymentValidationParams extends ValidationParams {
|
|
22
|
+
contractAddress: Address;
|
|
23
|
+
}
|
|
24
|
+
export interface ValidationResult {
|
|
25
|
+
valid: boolean;
|
|
26
|
+
message?: string;
|
|
27
|
+
data?: any;
|
|
28
|
+
}
|
|
29
|
+
export interface AccountBalance {
|
|
30
|
+
address: Address;
|
|
31
|
+
eth: bigint;
|
|
32
|
+
gToken: bigint;
|
|
33
|
+
aPNTs: bigint;
|
|
34
|
+
xPNTs: bigint;
|
|
35
|
+
}
|
|
36
|
+
export declare class StateValidator {
|
|
37
|
+
/**
|
|
38
|
+
* Create PublicClient helper
|
|
39
|
+
*/
|
|
40
|
+
private static createClient;
|
|
41
|
+
/**
|
|
42
|
+
* Batch fetch balances for multiple accounts
|
|
43
|
+
*/
|
|
44
|
+
static getAccountBalances(params: {
|
|
45
|
+
rpcUrl: string;
|
|
46
|
+
chain: Chain;
|
|
47
|
+
addresses: Address[];
|
|
48
|
+
gTokenAddress?: Address;
|
|
49
|
+
aPNTsAddress?: Address;
|
|
50
|
+
xPNTsAddress?: Address;
|
|
51
|
+
}): Promise<AccountBalance[]>;
|
|
52
|
+
/**
|
|
53
|
+
* Role Validation
|
|
54
|
+
*/
|
|
55
|
+
static validateRole(params: RoleValidationParams): Promise<ValidationResult>;
|
|
56
|
+
/**
|
|
57
|
+
* ETH Balance Validation
|
|
58
|
+
*/
|
|
59
|
+
static validateETHBalance(params: BalanceValidationParams): Promise<ValidationResult>;
|
|
60
|
+
/**
|
|
61
|
+
* Token Balance Validation
|
|
62
|
+
*/
|
|
63
|
+
static validateTokenBalance(params: TokenBalanceValidationParams): Promise<ValidationResult>;
|
|
64
|
+
/**
|
|
65
|
+
* Deployment Validation
|
|
66
|
+
*/
|
|
67
|
+
static validateDeployment(params: DeploymentValidationParams): Promise<ValidationResult>;
|
|
68
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { createPublicClient, http, erc20Abi, formatEther } from 'viem';
|
|
2
|
+
export class StateValidator {
|
|
3
|
+
/**
|
|
4
|
+
* Create PublicClient helper
|
|
5
|
+
*/
|
|
6
|
+
static createClient(params) {
|
|
7
|
+
return createPublicClient({
|
|
8
|
+
chain: params.chain,
|
|
9
|
+
transport: http(params.rpcUrl)
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Batch fetch balances for multiple accounts
|
|
14
|
+
*/
|
|
15
|
+
static async getAccountBalances(params) {
|
|
16
|
+
const client = this.createClient({ rpcUrl: params.rpcUrl, chain: params.chain });
|
|
17
|
+
const results = await Promise.all(params.addresses.map(async (address) => {
|
|
18
|
+
const [eth, gToken, aPNTs, xPNTs] = await Promise.all([
|
|
19
|
+
client.getBalance({ address }),
|
|
20
|
+
params.gTokenAddress
|
|
21
|
+
? client.readContract({
|
|
22
|
+
address: params.gTokenAddress,
|
|
23
|
+
abi: erc20Abi,
|
|
24
|
+
functionName: 'balanceOf',
|
|
25
|
+
args: [address]
|
|
26
|
+
})
|
|
27
|
+
: Promise.resolve(0n),
|
|
28
|
+
params.aPNTsAddress
|
|
29
|
+
? client.readContract({
|
|
30
|
+
address: params.aPNTsAddress,
|
|
31
|
+
abi: erc20Abi,
|
|
32
|
+
functionName: 'balanceOf',
|
|
33
|
+
args: [address]
|
|
34
|
+
})
|
|
35
|
+
: Promise.resolve(0n),
|
|
36
|
+
params.xPNTsAddress
|
|
37
|
+
? client.readContract({
|
|
38
|
+
address: params.xPNTsAddress,
|
|
39
|
+
abi: erc20Abi,
|
|
40
|
+
functionName: 'balanceOf',
|
|
41
|
+
args: [address]
|
|
42
|
+
})
|
|
43
|
+
: Promise.resolve(0n)
|
|
44
|
+
]);
|
|
45
|
+
return {
|
|
46
|
+
address,
|
|
47
|
+
eth,
|
|
48
|
+
gToken,
|
|
49
|
+
aPNTs,
|
|
50
|
+
xPNTs
|
|
51
|
+
};
|
|
52
|
+
}));
|
|
53
|
+
return results;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Role Validation
|
|
57
|
+
*/
|
|
58
|
+
static async validateRole(params) {
|
|
59
|
+
try {
|
|
60
|
+
const client = this.createClient(params);
|
|
61
|
+
const hasRole = await client.readContract({
|
|
62
|
+
address: params.registryAddress,
|
|
63
|
+
abi: [{
|
|
64
|
+
name: 'hasRole',
|
|
65
|
+
type: 'function',
|
|
66
|
+
stateMutability: 'view',
|
|
67
|
+
inputs: [
|
|
68
|
+
{ name: 'roleId', type: 'bytes32' },
|
|
69
|
+
{ name: 'user', type: 'address' }
|
|
70
|
+
],
|
|
71
|
+
outputs: [{ name: '', type: 'bool' }]
|
|
72
|
+
}],
|
|
73
|
+
functionName: 'hasRole',
|
|
74
|
+
args: [params.roleId, params.userAddress]
|
|
75
|
+
});
|
|
76
|
+
return {
|
|
77
|
+
valid: hasRole,
|
|
78
|
+
message: hasRole
|
|
79
|
+
? `✅ User ${params.userAddress} has role ${params.roleId}`
|
|
80
|
+
: `❌ User ${params.userAddress} does NOT have role ${params.roleId}`,
|
|
81
|
+
data: { hasRole }
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
return {
|
|
86
|
+
valid: false,
|
|
87
|
+
message: `❌ Role validation failed: ${error.message}`,
|
|
88
|
+
data: { error }
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* ETH Balance Validation
|
|
94
|
+
*/
|
|
95
|
+
static async validateETHBalance(params) {
|
|
96
|
+
try {
|
|
97
|
+
const client = this.createClient(params);
|
|
98
|
+
const balance = await client.getBalance({ address: params.address });
|
|
99
|
+
const balanceETH = Number(formatEther(balance));
|
|
100
|
+
if (params.minBalance) {
|
|
101
|
+
const minBalanceWei = BigInt(Math.floor(parseFloat(params.minBalance) * 1e18));
|
|
102
|
+
const sufficient = balance >= minBalanceWei;
|
|
103
|
+
return {
|
|
104
|
+
valid: sufficient,
|
|
105
|
+
message: sufficient
|
|
106
|
+
? `✅ ETH balance (${balanceETH.toFixed(4)}) meets minimum (${params.minBalance})`
|
|
107
|
+
: `❌ ETH balance (${balanceETH.toFixed(4)}) below minimum (${params.minBalance})`,
|
|
108
|
+
data: { balance, balanceETH, minBalance: params.minBalance }
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
valid: true,
|
|
113
|
+
message: `ℹ️ ETH balance: ${balanceETH.toFixed(4)} ETH`,
|
|
114
|
+
data: { balance, balanceETH }
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
return {
|
|
119
|
+
valid: false,
|
|
120
|
+
message: `❌ ETH balance validation failed: ${error.message}`,
|
|
121
|
+
data: { error }
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Token Balance Validation
|
|
127
|
+
*/
|
|
128
|
+
static async validateTokenBalance(params) {
|
|
129
|
+
try {
|
|
130
|
+
const client = this.createClient(params);
|
|
131
|
+
const balance = await client.readContract({
|
|
132
|
+
address: params.tokenAddress,
|
|
133
|
+
abi: erc20Abi,
|
|
134
|
+
functionName: 'balanceOf',
|
|
135
|
+
args: [params.address]
|
|
136
|
+
});
|
|
137
|
+
const balanceToken = Number(formatEther(balance));
|
|
138
|
+
if (params.minBalance) {
|
|
139
|
+
const minBalanceWei = BigInt(Math.floor(parseFloat(params.minBalance) * 1e18));
|
|
140
|
+
const sufficient = balance >= minBalanceWei;
|
|
141
|
+
return {
|
|
142
|
+
valid: sufficient,
|
|
143
|
+
message: sufficient
|
|
144
|
+
? `✅ Token balance (${balanceToken.toFixed(4)}) meets minimum (${params.minBalance})`
|
|
145
|
+
: `❌ Token balance (${balanceToken.toFixed(4)}) below minimum (${params.minBalance})`,
|
|
146
|
+
data: { balance, balanceToken, minBalance: params.minBalance }
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
valid: true,
|
|
151
|
+
message: `ℹ️ Token balance: ${balanceToken.toFixed(4)}`,
|
|
152
|
+
data: { balance, balanceToken }
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
return {
|
|
157
|
+
valid: false,
|
|
158
|
+
message: `❌ Token balance validation failed: ${error.message}`,
|
|
159
|
+
data: { error }
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Deployment Validation
|
|
165
|
+
*/
|
|
166
|
+
static async validateDeployment(params) {
|
|
167
|
+
try {
|
|
168
|
+
const client = this.createClient(params);
|
|
169
|
+
const code = await client.getBytecode({ address: params.contractAddress });
|
|
170
|
+
const isDeployed = code !== undefined && code !== '0x';
|
|
171
|
+
return {
|
|
172
|
+
valid: isDeployed,
|
|
173
|
+
message: isDeployed
|
|
174
|
+
? `✅ Contract deployed at ${params.contractAddress}`
|
|
175
|
+
: `❌ No contract found at ${params.contractAddress}`,
|
|
176
|
+
data: { code, isDeployed }
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
catch (error) {
|
|
180
|
+
return {
|
|
181
|
+
valid: false,
|
|
182
|
+
message: `❌ Deployment validation failed: ${error.message}`,
|
|
183
|
+
data: { error }
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type Address, type PublicClient, type WalletClient, type Hex, type Hash, type Account } from 'viem';
|
|
2
|
+
export type AccountActions = {
|
|
3
|
+
execute: (args: {
|
|
4
|
+
dest: Address;
|
|
5
|
+
value: bigint;
|
|
6
|
+
func: Hex;
|
|
7
|
+
account?: Account | Address;
|
|
8
|
+
}) => Promise<Hash>;
|
|
9
|
+
executeBatch: (args: {
|
|
10
|
+
dest: Address[];
|
|
11
|
+
value: bigint[];
|
|
12
|
+
func: Hex[];
|
|
13
|
+
account?: Account | Address;
|
|
14
|
+
}) => Promise<Hash>;
|
|
15
|
+
getNonce: () => Promise<bigint>;
|
|
16
|
+
entryPoint: () => Promise<Address>;
|
|
17
|
+
addDeposit: (args: {
|
|
18
|
+
account?: Account | Address;
|
|
19
|
+
}) => Promise<Hash>;
|
|
20
|
+
withdrawDepositTo: (args: {
|
|
21
|
+
withdrawAddress: Address;
|
|
22
|
+
amount: bigint;
|
|
23
|
+
account?: Account | Address;
|
|
24
|
+
}) => Promise<Hash>;
|
|
25
|
+
getDeposit: () => Promise<bigint>;
|
|
26
|
+
owner: () => Promise<Address>;
|
|
27
|
+
initialize: (args: {
|
|
28
|
+
owner: Address;
|
|
29
|
+
account?: Account | Address;
|
|
30
|
+
}) => Promise<Hash>;
|
|
31
|
+
upgradeToAndCall: (args: {
|
|
32
|
+
newImplementation: Address;
|
|
33
|
+
data: Hex;
|
|
34
|
+
account?: Account | Address;
|
|
35
|
+
}) => Promise<Hash>;
|
|
36
|
+
proxiableUUID: () => Promise<Hex>;
|
|
37
|
+
supportsInterface: (args: {
|
|
38
|
+
interfaceId: Hex;
|
|
39
|
+
}) => Promise<boolean>;
|
|
40
|
+
UPGRADE_INTERFACE_VERSION: () => Promise<string>;
|
|
41
|
+
};
|
|
42
|
+
export type AccountFactoryActions = {
|
|
43
|
+
createAccount: (args: {
|
|
44
|
+
owner: Address;
|
|
45
|
+
salt: bigint;
|
|
46
|
+
account?: Account | Address;
|
|
47
|
+
}) => Promise<Hash>;
|
|
48
|
+
getAddress: (args: {
|
|
49
|
+
owner: Address;
|
|
50
|
+
salt: bigint;
|
|
51
|
+
}) => Promise<Address>;
|
|
52
|
+
accountImplementation: () => Promise<Address>;
|
|
53
|
+
};
|
|
54
|
+
export declare const accountActions: (address: Address) => (client: PublicClient | WalletClient) => AccountActions;
|
|
55
|
+
export declare const accountFactoryActions: (address: Address) => (client: PublicClient | WalletClient) => AccountFactoryActions;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { SimpleAccountABI, SimpleAccountFactoryABI } from '../abis/index.js';
|
|
2
|
+
export const accountActions = (address) => (client) => ({
|
|
3
|
+
async execute({ dest, value, func, account }) {
|
|
4
|
+
return client.writeContract({
|
|
5
|
+
address,
|
|
6
|
+
abi: SimpleAccountABI,
|
|
7
|
+
functionName: 'execute',
|
|
8
|
+
args: [dest, value, func],
|
|
9
|
+
account: account,
|
|
10
|
+
chain: client.chain
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
async executeBatch({ dest, value, func, account }) {
|
|
14
|
+
// Zip arguments into Call[] struct format
|
|
15
|
+
const calls = dest.map((t, i) => ({
|
|
16
|
+
target: t,
|
|
17
|
+
value: value[i],
|
|
18
|
+
data: func[i]
|
|
19
|
+
}));
|
|
20
|
+
return client.writeContract({
|
|
21
|
+
address,
|
|
22
|
+
abi: SimpleAccountABI,
|
|
23
|
+
functionName: 'executeBatch',
|
|
24
|
+
args: [calls],
|
|
25
|
+
account: account,
|
|
26
|
+
chain: client.chain
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
async getNonce() {
|
|
30
|
+
return client.readContract({
|
|
31
|
+
address,
|
|
32
|
+
abi: SimpleAccountABI,
|
|
33
|
+
functionName: 'getNonce',
|
|
34
|
+
args: []
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
async entryPoint() {
|
|
38
|
+
return client.readContract({
|
|
39
|
+
address,
|
|
40
|
+
abi: SimpleAccountABI,
|
|
41
|
+
functionName: 'entryPoint',
|
|
42
|
+
args: []
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
async addDeposit({ account }) {
|
|
46
|
+
return client.writeContract({
|
|
47
|
+
address,
|
|
48
|
+
abi: SimpleAccountABI,
|
|
49
|
+
functionName: 'addDeposit',
|
|
50
|
+
args: [],
|
|
51
|
+
account: account,
|
|
52
|
+
chain: client.chain
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
async withdrawDepositTo({ withdrawAddress, amount, account }) {
|
|
56
|
+
return client.writeContract({
|
|
57
|
+
address,
|
|
58
|
+
abi: SimpleAccountABI,
|
|
59
|
+
functionName: 'withdrawDepositTo',
|
|
60
|
+
args: [withdrawAddress, amount],
|
|
61
|
+
account: account,
|
|
62
|
+
chain: client.chain
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
async getDeposit() {
|
|
66
|
+
return client.readContract({
|
|
67
|
+
address,
|
|
68
|
+
abi: SimpleAccountABI,
|
|
69
|
+
functionName: 'getDeposit',
|
|
70
|
+
args: []
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
async owner() {
|
|
74
|
+
return client.readContract({
|
|
75
|
+
address,
|
|
76
|
+
abi: SimpleAccountABI,
|
|
77
|
+
functionName: 'owner',
|
|
78
|
+
args: []
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
async initialize({ owner, account }) {
|
|
82
|
+
return client.writeContract({
|
|
83
|
+
address,
|
|
84
|
+
abi: SimpleAccountABI,
|
|
85
|
+
functionName: 'initialize',
|
|
86
|
+
args: [owner],
|
|
87
|
+
account: account,
|
|
88
|
+
chain: client.chain
|
|
89
|
+
});
|
|
90
|
+
},
|
|
91
|
+
async upgradeToAndCall({ newImplementation, data, account }) {
|
|
92
|
+
return client.writeContract({
|
|
93
|
+
address,
|
|
94
|
+
abi: SimpleAccountABI,
|
|
95
|
+
functionName: 'upgradeToAndCall',
|
|
96
|
+
args: [newImplementation, data],
|
|
97
|
+
account: account,
|
|
98
|
+
chain: client.chain
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
async proxiableUUID() {
|
|
102
|
+
return client.readContract({ address, abi: SimpleAccountABI, functionName: 'proxiableUUID', args: [] });
|
|
103
|
+
},
|
|
104
|
+
async supportsInterface({ interfaceId }) {
|
|
105
|
+
return client.readContract({ address, abi: SimpleAccountABI, functionName: 'supportsInterface', args: [interfaceId] });
|
|
106
|
+
},
|
|
107
|
+
async UPGRADE_INTERFACE_VERSION() {
|
|
108
|
+
return client.readContract({ address, abi: SimpleAccountABI, functionName: 'UPGRADE_INTERFACE_VERSION', args: [] });
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
export const accountFactoryActions = (address) => (client) => ({
|
|
112
|
+
async createAccount({ owner, salt, account }) {
|
|
113
|
+
return client.writeContract({
|
|
114
|
+
address,
|
|
115
|
+
abi: SimpleAccountFactoryABI,
|
|
116
|
+
functionName: 'createAccount',
|
|
117
|
+
args: [owner, salt],
|
|
118
|
+
account: account,
|
|
119
|
+
chain: client.chain
|
|
120
|
+
});
|
|
121
|
+
},
|
|
122
|
+
async getAddress({ owner, salt }) {
|
|
123
|
+
return client.readContract({
|
|
124
|
+
address,
|
|
125
|
+
abi: SimpleAccountFactoryABI,
|
|
126
|
+
functionName: 'getAddress',
|
|
127
|
+
args: [owner, salt]
|
|
128
|
+
});
|
|
129
|
+
},
|
|
130
|
+
async accountImplementation() {
|
|
131
|
+
return client.readContract({ address, abi: SimpleAccountFactoryABI, functionName: 'accountImplementation', args: [] });
|
|
132
|
+
}
|
|
133
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Address, type PublicClient, type WalletClient, type Hex, type Hash, type Account } from 'viem';
|
|
2
|
+
export type AggregatorActions = {
|
|
3
|
+
registerBLSPublicKey: (args: {
|
|
4
|
+
address: Address;
|
|
5
|
+
publicKey: Hex;
|
|
6
|
+
account?: Account | Address;
|
|
7
|
+
}) => Promise<Hash>;
|
|
8
|
+
setBLSThreshold: (args: {
|
|
9
|
+
address: Address;
|
|
10
|
+
threshold: number;
|
|
11
|
+
account?: Account | Address;
|
|
12
|
+
}) => Promise<Hash>;
|
|
13
|
+
getBLSThreshold: (args: {
|
|
14
|
+
address: Address;
|
|
15
|
+
}) => Promise<bigint>;
|
|
16
|
+
};
|
|
17
|
+
export declare const aggregatorActions: () => (client: PublicClient | WalletClient) => AggregatorActions;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BLSAggregatorABI } from '../abis/index.js';
|
|
2
|
+
export const aggregatorActions = () => (client) => ({
|
|
3
|
+
async registerBLSPublicKey({ address, publicKey, account }) {
|
|
4
|
+
return client.writeContract({
|
|
5
|
+
address,
|
|
6
|
+
abi: BLSAggregatorABI,
|
|
7
|
+
functionName: 'registerBLSPublicKey',
|
|
8
|
+
args: [publicKey],
|
|
9
|
+
account: account,
|
|
10
|
+
chain: client.chain
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
async setBLSThreshold({ address, threshold, account }) {
|
|
14
|
+
return client.writeContract({
|
|
15
|
+
address,
|
|
16
|
+
abi: BLSAggregatorABI,
|
|
17
|
+
functionName: 'setThreshold',
|
|
18
|
+
args: [BigInt(threshold)],
|
|
19
|
+
account: account,
|
|
20
|
+
chain: client.chain
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
async getBLSThreshold({ address }) {
|
|
24
|
+
return client.readContract({
|
|
25
|
+
address,
|
|
26
|
+
abi: BLSAggregatorABI,
|
|
27
|
+
functionName: 'threshold',
|
|
28
|
+
args: []
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type Address, type PublicClient, type WalletClient, type Hex, type Hash, type Account } from 'viem';
|
|
2
|
+
export type DVTActions = {
|
|
3
|
+
createSlashProposal: (args: {
|
|
4
|
+
address: Address;
|
|
5
|
+
operator: Address;
|
|
6
|
+
level: number;
|
|
7
|
+
reason: string;
|
|
8
|
+
account?: Account | Address;
|
|
9
|
+
}) => Promise<Hash>;
|
|
10
|
+
signSlashProposal: (args: {
|
|
11
|
+
address: Address;
|
|
12
|
+
proposalId: bigint;
|
|
13
|
+
signature: Hex;
|
|
14
|
+
account?: Account | Address;
|
|
15
|
+
}) => Promise<Hash>;
|
|
16
|
+
executeSlashWithProof: (args: {
|
|
17
|
+
address: Address;
|
|
18
|
+
proposalId: bigint;
|
|
19
|
+
repUsers: Address[];
|
|
20
|
+
newScores: bigint[];
|
|
21
|
+
epoch: bigint;
|
|
22
|
+
proof: Hex;
|
|
23
|
+
account?: Account | Address;
|
|
24
|
+
}) => Promise<Hash>;
|
|
25
|
+
isValidator: (args: {
|
|
26
|
+
address: Address;
|
|
27
|
+
user: Address;
|
|
28
|
+
}) => Promise<boolean>;
|
|
29
|
+
};
|
|
30
|
+
export declare const dvtActions: () => (client: PublicClient | WalletClient) => DVTActions;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { DVTValidatorABI } from '../abis/index.js';
|
|
2
|
+
export const dvtActions = () => (client) => ({
|
|
3
|
+
async createSlashProposal({ address, operator, level, reason, account }) {
|
|
4
|
+
return client.writeContract({
|
|
5
|
+
address,
|
|
6
|
+
abi: DVTValidatorABI,
|
|
7
|
+
functionName: 'createProposal',
|
|
8
|
+
args: [operator, level, reason],
|
|
9
|
+
account: account,
|
|
10
|
+
chain: client.chain
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
async signSlashProposal({ address, proposalId, signature, account }) {
|
|
14
|
+
return client.writeContract({
|
|
15
|
+
address,
|
|
16
|
+
abi: DVTValidatorABI,
|
|
17
|
+
functionName: 'signProposal',
|
|
18
|
+
args: [proposalId, signature],
|
|
19
|
+
account: account,
|
|
20
|
+
chain: client.chain
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
async executeSlashWithProof({ address, proposalId, repUsers, newScores, epoch, proof, account }) {
|
|
24
|
+
return client.writeContract({
|
|
25
|
+
address,
|
|
26
|
+
abi: DVTValidatorABI,
|
|
27
|
+
functionName: 'executeWithProof',
|
|
28
|
+
args: [proposalId, repUsers, newScores, epoch, proof],
|
|
29
|
+
account: account,
|
|
30
|
+
chain: client.chain
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
async isValidator({ address, user }) {
|
|
34
|
+
return client.readContract({
|
|
35
|
+
address,
|
|
36
|
+
abi: DVTValidatorABI,
|
|
37
|
+
functionName: 'isValidator',
|
|
38
|
+
args: [user]
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { type Address, type PublicClient, type WalletClient, type Hex, type Hash, type Account } from 'viem';
|
|
2
|
+
export declare enum EntryPointVersion {
|
|
3
|
+
V06 = "0.6",
|
|
4
|
+
V07 = "0.7"
|
|
5
|
+
}
|
|
6
|
+
export type EntryPointActions = {
|
|
7
|
+
balanceOf: (args: {
|
|
8
|
+
account: Address;
|
|
9
|
+
}) => Promise<bigint>;
|
|
10
|
+
depositTo: (args: {
|
|
11
|
+
account: Address;
|
|
12
|
+
amount: bigint;
|
|
13
|
+
txAccount?: Account | Address;
|
|
14
|
+
}) => Promise<Hash>;
|
|
15
|
+
getNonce: (args: {
|
|
16
|
+
sender: Address;
|
|
17
|
+
key: bigint;
|
|
18
|
+
}) => Promise<bigint>;
|
|
19
|
+
getDepositInfo: (args: {
|
|
20
|
+
account: Address;
|
|
21
|
+
}) => Promise<{
|
|
22
|
+
deposit: bigint;
|
|
23
|
+
staked: boolean;
|
|
24
|
+
stake: bigint;
|
|
25
|
+
unstakeDelaySec: number;
|
|
26
|
+
withdrawTime: number;
|
|
27
|
+
}>;
|
|
28
|
+
addStake: (args: {
|
|
29
|
+
unstakeDelaySec: number;
|
|
30
|
+
amount: bigint;
|
|
31
|
+
account?: Account | Address;
|
|
32
|
+
}) => Promise<Hash>;
|
|
33
|
+
unlockStake: (args: {
|
|
34
|
+
account?: Account | Address;
|
|
35
|
+
}) => Promise<Hash>;
|
|
36
|
+
withdrawStake: (args: {
|
|
37
|
+
withdrawAddress: Address;
|
|
38
|
+
account?: Account | Address;
|
|
39
|
+
}) => Promise<Hash>;
|
|
40
|
+
withdrawTo: (args: {
|
|
41
|
+
withdrawAddress: Address;
|
|
42
|
+
amount: bigint;
|
|
43
|
+
account?: Account | Address;
|
|
44
|
+
}) => Promise<Hash>;
|
|
45
|
+
handleOps: (args: {
|
|
46
|
+
ops: any[];
|
|
47
|
+
beneficiary: Address;
|
|
48
|
+
account?: Account | Address;
|
|
49
|
+
}) => Promise<Hash>;
|
|
50
|
+
handleAggregatedOps: (args: {
|
|
51
|
+
opsPerAggregator: any[];
|
|
52
|
+
beneficiary: Address;
|
|
53
|
+
account?: Account | Address;
|
|
54
|
+
}) => Promise<Hash>;
|
|
55
|
+
innerHandleOp: (args: {
|
|
56
|
+
callData: Hex;
|
|
57
|
+
opInfo: any;
|
|
58
|
+
context: Hex;
|
|
59
|
+
account?: Account | Address;
|
|
60
|
+
}) => Promise<Hash>;
|
|
61
|
+
delegateAndRevert: (args: {
|
|
62
|
+
target: Address;
|
|
63
|
+
data: Hex;
|
|
64
|
+
account?: Account | Address;
|
|
65
|
+
}) => Promise<void>;
|
|
66
|
+
getUserOpHash: (args: {
|
|
67
|
+
op: any;
|
|
68
|
+
}) => Promise<Hash>;
|
|
69
|
+
getSenderAddress: (args: {
|
|
70
|
+
initCode: Hex;
|
|
71
|
+
}) => Promise<Address>;
|
|
72
|
+
senderCreator: () => Promise<Address>;
|
|
73
|
+
incrementNonce: (args: {
|
|
74
|
+
key: bigint;
|
|
75
|
+
account?: Account | Address;
|
|
76
|
+
}) => Promise<Hash>;
|
|
77
|
+
nonceSequenceNumber: (args: {
|
|
78
|
+
sender: Address;
|
|
79
|
+
key: bigint;
|
|
80
|
+
}) => Promise<bigint>;
|
|
81
|
+
supportsInterface: (args: {
|
|
82
|
+
interfaceId: Hex;
|
|
83
|
+
}) => Promise<boolean>;
|
|
84
|
+
eip712Domain: () => Promise<any>;
|
|
85
|
+
getCurrentUserOpHash: () => Promise<Hash>;
|
|
86
|
+
getDomainSeparatorV4: () => Promise<Hex>;
|
|
87
|
+
getPackedUserOpTypeHash: () => Promise<Hex>;
|
|
88
|
+
version: EntryPointVersion;
|
|
89
|
+
};
|
|
90
|
+
export declare const entryPointActions: (address: Address, version?: EntryPointVersion) => (client: PublicClient | WalletClient) => EntryPointActions;
|