9
9
replaceSelfAddress ,
10
10
PLACEHOLDER_ACCOUNT_ADDRESS ,
11
11
UUID ,
12
- ACCOUNT_PROXY ,
13
12
encodeProxyConstructorArgs ,
14
13
} from 'lib' ;
15
14
import { CREATE2_FACTORY } from 'lib/dapps' ;
@@ -21,13 +20,6 @@ import { FlowJob } from 'bullmq';
21
20
import { ConfirmationQueue } from '../system-txs/confirmations.queue' ;
22
21
import Decimal from 'decimal.js' ;
23
22
import { SimulationsQueue } from '../simulations/simulations.worker' ;
24
- import { toHex } from 'viem' ;
25
- import { utils as zkUtils } from 'zksync-ethers' ;
26
-
27
- interface FeeParams {
28
- account : UAddress ;
29
- feePerGas : Decimal ;
30
- }
31
23
32
24
@Injectable ( )
33
25
export class ActivationsService {
@@ -61,15 +53,15 @@ export class ActivationsService {
61
53
} satisfies FlowJob ;
62
54
}
63
55
64
- async fee ( { account, feePerGas } : FeeParams ) : Promise < Decimal | null > {
65
- const a = await this . db . queryWith (
56
+ async fee ( account : UAddress ) : Promise < Decimal | null > {
57
+ const a = await this . db . queryWith2 (
66
58
{ address : e . UAddress } ,
59
+ { address : account } ,
67
60
( { address } ) =>
68
61
e . select ( e . Account , ( ) => ( {
69
62
filter_single : { address } ,
70
63
activationEthFee : true ,
71
64
} ) ) ,
72
- { address : account } ,
73
65
) ;
74
66
if ( ! a ) return null ;
75
67
if ( a . activationEthFee ) return new Decimal ( a . activationEthFee ) ;
@@ -79,8 +71,11 @@ export class ActivationsService {
79
71
80
72
const network = this . networks . get ( account ) ;
81
73
try {
82
- const gas = await network . estimateContractGas ( request ) ;
83
- return feePerGas . mul ( gas . toString ( ) ) ;
74
+ const [ gas , maxFeePerGas ] = await Promise . all ( [
75
+ network . estimateContractGas ( request ) ,
76
+ network . maxFeePerGas ( ) ,
77
+ ] ) ;
78
+ return maxFeePerGas . mul ( gas . toString ( ) ) ;
84
79
} catch ( e ) {
85
80
const isDeployed = ! ! ( await network . getCode ( { address : asAddress ( account ) } ) ) ?. length ;
86
81
if ( isDeployed ) return null ;
@@ -97,7 +92,7 @@ export class ActivationsService {
97
92
filter_single : { address } ,
98
93
active : true ,
99
94
implementation : true ,
100
- salt : true ,
95
+ initialization : true ,
101
96
initPolicies : e . select ( a . policies , ( p ) => ( {
102
97
filter : p . initState ,
103
98
...PolicyShape ,
@@ -126,10 +121,10 @@ export class ActivationsService {
126
121
address : CREATE2_FACTORY . address ,
127
122
functionName : 'create2Account' as const ,
128
123
args : [
129
- asHex ( account . salt ) ,
130
- toHex ( zkUtils . hashBytecode ( ACCOUNT_PROXY . bytecode ) ) ,
124
+ asHex ( account . initialization . salt ) ,
125
+ asHex ( account . initialization . bytecodeHash ) ,
131
126
constructorArgs ,
132
- 1 , // AccountAbstractionVersion.Version1
127
+ account . initialization . aaVersion ,
133
128
] as const ,
134
129
// factoryDeps: [ACCOUNT_PROXY.bytecode], // Throws "rpc method is not whitelisted" if provided; bytecode must be deployed using SystemContractDeployer first
135
130
// gas: 3_000_000n * BigInt(params.policies.length), // ~1M per policy; gas estimation panics if not provided
0 commit comments