@@ -126,37 +126,32 @@ async function addParaCustom(specPath: string, node: Node) {
126
126
const chainSpec = readAndParseChainSpec ( specPath ) ;
127
127
const runtimeConfig = getRuntimeConfig ( chainSpec ) ;
128
128
129
- // parachainStaking
130
129
if ( ! runtimeConfig ?. parachainStaking ) return ;
131
130
132
131
const { eth_account } = node . accounts ;
133
132
134
- const stakingBond = paraStakingBond || BigInt ( "1000000000000000000000 " ) ;
135
- const reservedBalance = BigInt ( "100000000000000000000 " ) ;
133
+ const stakingBond = paraStakingBond || BigInt ( "2000000000000000000000000 " ) ;
134
+ const reservedBalance = BigInt ( "100000000000000000000000 " ) ;
136
135
137
136
// Ensure collator account has enough balance to bond and add candidate
138
- const node_index = runtimeConfig . balances . balances . findIndex (
139
- ( item : [ string , BigInt ] ) => {
140
- return item [ 0 ] === eth_account . address . toLowerCase ( ) ;
141
- } ,
137
+ const collatorBalance = runtimeConfig . balances . balances . find (
138
+ ( [ address ] : [ string , BigInt ] ) =>
139
+ address === eth_account . address . toLowerCase ( ) ,
142
140
) ;
143
141
144
- if ( node_index > - 1 ) runtimeConfig . balances . balances . splice ( node_index , 1 ) ;
145
-
146
- runtimeConfig . balances . balances . push ( [
147
- eth_account . address ,
148
- stakingBond + reservedBalance ,
149
- ] ) ;
150
-
151
- const candidate_index = runtimeConfig . balances . balances . findIndex (
152
- ( item : [ string , BigInt ] ) => {
153
- return item [ 0 ] === eth_account . address . toLowerCase ( ) ;
154
- } ,
155
- ) ;
156
-
157
- if ( candidate_index > - 1 )
158
- runtimeConfig . balances . balances . splice ( candidate_index , 1 ) ;
142
+ const expectedBalance = stakingBond + reservedBalance ;
143
+ if ( collatorBalance ) {
144
+ if ( collatorBalance [ 1 ] < expectedBalance ) {
145
+ collatorBalance [ 1 ] = expectedBalance ;
146
+ }
147
+ } else {
148
+ runtimeConfig . balances . balances . push ( [
149
+ eth_account . address ,
150
+ expectedBalance ,
151
+ ] ) ;
152
+ }
159
153
154
+ // Add collator account as candidate
160
155
runtimeConfig . parachainStaking . candidates . push ( [
161
156
eth_account . address ,
162
157
stakingBond ,
0 commit comments