@@ -23,9 +23,11 @@ type TestnetValidator struct {
2323 OperatorAddress sdk.ValAddress
2424 ConsensusAddress sdk.ConsAddress
2525 ConsensusPubKey * types.Any
26+ Status stakingtypes.BondStatus
2627 Moniker string
2728 Commission stakingtypes.Commission
2829 MinSelfDelegation sdk.Int
30+ Delegations []TestnetDelegation
2931}
3032
3133type TestnetUpgrade struct {
@@ -42,8 +44,18 @@ type TestnetGovConfig struct {
4244 } `json:"voting_params,omitempty"`
4345}
4446
47+ type TestnetAccount struct {
48+ Address sdk.AccAddress `json:"address"`
49+ Balances []sdk.Coin `json:"balances"`
50+ }
51+
52+ type TestnetDelegation struct {
53+ Address sdk.AccAddress `json:"address"`
54+ Amount sdk.Coin `json:"amount"`
55+ }
56+
4557type TestnetConfig struct {
46- Accounts []sdk. AccAddress
58+ Accounts []TestnetAccount
4759 Validators []TestnetValidator
4860 Gov TestnetGovConfig
4961 Upgrade TestnetUpgrade
@@ -131,33 +143,41 @@ func InitAkashAppForTestnet(
131143 panic (err )
132144 }
133145
146+ // BANK
147+ //
148+
149+ for _ , account := range tcfg .Accounts {
150+ err := app .Keepers .Cosmos .Bank .MintCoins (ctx , minttypes .ModuleName , account .Balances )
151+ if err != nil {
152+ panic (err )
153+ }
154+ err = app .Keepers .Cosmos .Bank .SendCoinsFromModuleToAccount (ctx , minttypes .ModuleName , account .Address , account .Balances )
155+ if err != nil {
156+ panic (err )
157+ }
158+ }
159+
134160 for _ , val := range tcfg .Validators {
135161 // Create Validator struct for our new validator.
136162 newVal := stakingtypes.Validator {
137163 OperatorAddress : val .OperatorAddress .String (),
138164 ConsensusPubkey : val .ConsensusPubKey ,
139165 Jailed : false ,
140- Status : stakingtypes . Bonded ,
141- Tokens : sdk .NewInt (900000000000000 ),
142- DelegatorShares : sdk .MustNewDecFromStr ("10000000 " ),
166+ Status : val . Status ,
167+ Tokens : sdk .NewInt (0 ),
168+ DelegatorShares : sdk .MustNewDecFromStr ("0 " ),
143169 Description : stakingtypes.Description {
144- Moniker : "Testnet Validator" ,
145- },
146- Commission : stakingtypes.Commission {
147- CommissionRates : stakingtypes.CommissionRates {
148- Rate : sdk .MustNewDecFromStr ("0.05" ),
149- MaxRate : sdk .MustNewDecFromStr ("0.1" ),
150- MaxChangeRate : sdk .MustNewDecFromStr ("0.05" ),
151- },
170+ Moniker : val .Moniker ,
152171 },
153- MinSelfDelegation : sdk .OneInt (),
172+ Commission : val .Commission ,
173+ MinSelfDelegation : val .MinSelfDelegation ,
154174 }
155175
156176 // Add our validator to power and last validators store
157177 app .Keepers .Cosmos .Staking .SetValidator (ctx , newVal )
158178 err = app .Keepers .Cosmos .Staking .SetValidatorByConsAddr (ctx , newVal )
159179 if err != nil {
160- return nil
180+ panic ( err )
161181 }
162182
163183 app .Keepers .Cosmos .Staking .SetValidatorByPowerIndex (ctx , newVal )
@@ -189,9 +209,24 @@ func InitAkashAppForTestnet(
189209 Tombstoned : false ,
190210 }
191211
192- _ , _ = app .Keepers .Cosmos .Staking .ApplyAndReturnValidatorSetUpdates (ctx )
212+ _ , err = app .Keepers .Cosmos .Staking .ApplyAndReturnValidatorSetUpdates (ctx )
213+ if err != nil {
214+ panic (err )
215+ }
193216
194217 app .Keepers .Cosmos .Slashing .SetValidatorSigningInfo (ctx , newConsAddr , newValidatorSigningInfo )
218+
219+ for _ , del := range val .Delegations {
220+ vl , found := app .Keepers .Cosmos .Staking .GetValidator (ctx , valAddr )
221+ if ! found {
222+ panic ("validator not found" )
223+ }
224+
225+ _ , err = app .Keepers .Cosmos .Staking .Delegate (ctx , del .Address , del .Amount .Amount , stakingtypes .Unbonded , vl , true )
226+ if err != nil {
227+ panic (err )
228+ }
229+ }
195230 }
196231
197232 //
@@ -205,25 +240,6 @@ func InitAkashAppForTestnet(
205240 voteParams .VotingPeriod = tcfg .Gov .VotingParams .VotingPeriod .Duration
206241 app .Keepers .Cosmos .Gov .SetVotingParams (ctx , voteParams )
207242
208- // BANK
209- //
210-
211- defaultCoins := sdk .NewCoins (
212- sdk .NewInt64Coin ("uakt" , 1000000000000 ),
213- sdk .NewInt64Coin ("ibc/12C6A0C374171B595A0A9E18B83FA09D295FB1F2D8C6DAA3AC28683471752D84" , 1000000000000 ), // axlUSDC
214- )
215-
216- for _ , account := range tcfg .Accounts {
217- err := app .Keepers .Cosmos .Bank .MintCoins (ctx , minttypes .ModuleName , defaultCoins )
218- if err != nil {
219- return nil
220- }
221- err = app .Keepers .Cosmos .Bank .SendCoinsFromModuleToAccount (ctx , minttypes .ModuleName , account , defaultCoins )
222- if err != nil {
223- return nil
224- }
225- }
226-
227243 // UPGRADE
228244 //
229245 if tcfg .Upgrade .Name != "" {
0 commit comments