Skip to content

Commit

Permalink
Merge pull request #20 from multiversx/staking-v4
Browse files Browse the repository at this point in the history
Staking v4 branch
  • Loading branch information
miiu96 authored Mar 8, 2024
2 parents fd328ff + 5a517c8 commit 09fd222
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 30 deletions.
7 changes: 2 additions & 5 deletions cmd/chainsimulator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func startChainSimulator(ctx *cli.Context) error {
PathToProxyConfig: proxyConfigs,
ServerPort: cfg.Config.Simulator.ServerPort,
RestApiInterfaces: restApiInterfaces,
InitialWallets: simulator.GetInitialWalletKeys().ShardWallets,
InitialWallets: simulator.GetInitialWalletKeys().BalanceWallets,
})
if err != nil {
return err
Expand Down Expand Up @@ -231,10 +231,7 @@ func startChainSimulator(ctx *cli.Context) error {

generator.Close()

err = simulator.Close()
if err != nil {
log.Warn("cannot close simulator", "error", err)
}
simulator.Close()
proxyInstance.Close()

if !check.IfNilReflect(fileLogging) {
Expand Down
9 changes: 4 additions & 5 deletions examples/staking/staking.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ def main():
# ################## merge validator in delegator
response = provider.do_get(f"{INITIAL_WALLETS_URL}")
initial_address_with_stake = factory.create_from_bech32(
response.to_dictionary()["initialWalletWithStake"]["address"])
private_key_hex = response.to_dictionary()["initialWalletWithStake"]["privateKeyHex"]
response.to_dictionary()["stakeWallets"][0]["address"]["bech32"])

print(f"initial address with stake: {initial_address_with_stake.to_bech32()}")

Expand Down Expand Up @@ -124,11 +123,11 @@ def main():

# check if the owner receive more than 5 egld in rewards
claim_reward_tx = get_tx_and_verify_status(provider, tx_hash)
two_egld = 2000000000000000000
one_egld = 1000000000000000000
rewards_value = claim_reward_tx.contract_results.items[0].value
if rewards_value < two_egld:
if rewards_value < one_egld:
sys.exit(f"owner of the delegation contract didn't receive the expected amount of rewards: expected more than "
f"2 EGLD, received: {rewards_value}")
f"1 EGLD, received: {rewards_value}")

print(f"owner has received rewards, received rewards: {rewards_value}")

Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ go 1.20

require (
github.com/gin-gonic/gin v1.9.1
github.com/multiversx/mx-chain-core-go v1.2.19-0.20240129082057-a76d0c995cf2
github.com/multiversx/mx-chain-go v1.7.3-0.20240229193314-26883ef1e91b
github.com/multiversx/mx-chain-core-go v1.2.19-0.20240222081523-011c96ab2548
github.com/multiversx/mx-chain-go v1.7.6
github.com/multiversx/mx-chain-logger-go v1.0.14-0.20240129144507-d00e967c890c
github.com/multiversx/mx-chain-proxy-go v1.1.41
github.com/multiversx/mx-chain-proxy-go v1.1.44-0.20240212150040-5f7a82b10b0e
github.com/stretchr/testify v1.8.4
github.com/urfave/cli v1.22.10
)
Expand Down Expand Up @@ -120,8 +120,8 @@ require (
github.com/multiversx/mx-chain-es-indexer-go v1.4.19-0.20240129150813-a772c480d33a // indirect
github.com/multiversx/mx-chain-scenario-go v1.4.3-0.20240212160120-cc32d1580157 // indirect
github.com/multiversx/mx-chain-storage-go v1.0.15-0.20240129144933-b1c0d642d7f8 // indirect
github.com/multiversx/mx-chain-vm-common-go v1.5.12-0.20240227112124-bfd3f5676e5a // indirect
github.com/multiversx/mx-chain-vm-go v1.5.28-0.20240216071136-6d748b5d6a72 // indirect
github.com/multiversx/mx-chain-vm-common-go v1.5.12-0.20240305123516-2231c71162a2 // indirect
github.com/multiversx/mx-chain-vm-go v1.5.28-0.20240216171908-e2a4c8ed9823 // indirect
github.com/multiversx/mx-chain-vm-v1_2-go v1.2.66-0.20240129145751-f814f5525edb // indirect
github.com/multiversx/mx-chain-vm-v1_3-go v1.3.67-0.20240129150004-536a22d9c618 // indirect
github.com/multiversx/mx-chain-vm-v1_4-go v1.4.96-0.20240216071525-f7d1b8ce8662 // indirect
Expand Down
20 changes: 10 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -395,26 +395,26 @@ github.com/multiversx/concurrent-map v0.1.4 h1:hdnbM8VE4b0KYJaGY5yJS2aNIW9TFFsUY
github.com/multiversx/concurrent-map v0.1.4/go.mod h1:8cWFRJDOrWHOTNSqgYCUvwT7c7eFQ4U2vKMOp4A/9+o=
github.com/multiversx/mx-chain-communication-go v1.0.13-0.20240126121117-627adccf10ad h1:izxTyKCxvT7z2mhXCWAZibSxwRVgLmq/kDovs4Nx/6Y=
github.com/multiversx/mx-chain-communication-go v1.0.13-0.20240126121117-627adccf10ad/go.mod h1:n4E8BWIV0g3AcNGe1gf+vcjUC8A2QCJ4ARQSbiUDGrI=
github.com/multiversx/mx-chain-core-go v1.2.19-0.20240129082057-a76d0c995cf2 h1:pFh9bwOTRgW173aHqA8Bmax+jYzLnRyXqRvi5alF7V4=
github.com/multiversx/mx-chain-core-go v1.2.19-0.20240129082057-a76d0c995cf2/go.mod h1:B5zU4MFyJezmEzCsAHE9YNULmGCm2zbPHvl9hazNxmE=
github.com/multiversx/mx-chain-core-go v1.2.19-0.20240222081523-011c96ab2548 h1:WQoVgQG9YWiYM5Q3MmnbnxeoQkfHr63iFJZScFYsMxk=
github.com/multiversx/mx-chain-core-go v1.2.19-0.20240222081523-011c96ab2548/go.mod h1:B5zU4MFyJezmEzCsAHE9YNULmGCm2zbPHvl9hazNxmE=
github.com/multiversx/mx-chain-crypto-go v1.2.10-0.20231206065052-38843c1f1479 h1:beVIhs5ysylwNplQ/bZ0h5DoDlqKNWgpWE/NMHHNmAw=
github.com/multiversx/mx-chain-crypto-go v1.2.10-0.20231206065052-38843c1f1479/go.mod h1:Ap6p7QZFtwPlb++OvCG+85BfuZ+bLP/JtQp6EwjWJsI=
github.com/multiversx/mx-chain-es-indexer-go v1.4.19-0.20240129150813-a772c480d33a h1:mOMUhbsjTq7n5oAv4KkVnL67ngS0+wkqmkiv1XJfBIY=
github.com/multiversx/mx-chain-es-indexer-go v1.4.19-0.20240129150813-a772c480d33a/go.mod h1:3aSGRJNvfUuPQkZUGHWuF11rPPxphsKGuAuIB+eD3is=
github.com/multiversx/mx-chain-go v1.7.3-0.20240229193314-26883ef1e91b h1:sjDMICjTLQjPgeq8Vmz09hUOzdlOY+2adp5H7T5iZyk=
github.com/multiversx/mx-chain-go v1.7.3-0.20240229193314-26883ef1e91b/go.mod h1:woPMicov03+VrH2iPJ+oJXj4Kvj64kLgWg/5Z90qV8M=
github.com/multiversx/mx-chain-go v1.7.6 h1:OOXIVBJjtlppXbTKPoDmmnfCHtCyrUe8ju2S6if52SU=
github.com/multiversx/mx-chain-go v1.7.6/go.mod h1:QW56aus7apttxjK9o1msJwdrlfE2gHUfrP9CXRaJPO0=
github.com/multiversx/mx-chain-logger-go v1.0.14-0.20240129144507-d00e967c890c h1:QIUOn8FgNRa5cir4BCWHZi/Qcr6Gg0eGNhns4+jy6+k=
github.com/multiversx/mx-chain-logger-go v1.0.14-0.20240129144507-d00e967c890c/go.mod h1:fH/fR/GEBsDjPkBoZDVJMoYo2HhlA7++DP6QfITJ1N8=
github.com/multiversx/mx-chain-proxy-go v1.1.41 h1:u5LTek2keNvd25jrOmHLp0N4AFwYFImBnrs+GR7IGRY=
github.com/multiversx/mx-chain-proxy-go v1.1.41/go.mod h1:El07IztR9QuhbNPZkd2ew2H8KS2bUqG7/0eQ28BPPsY=
github.com/multiversx/mx-chain-proxy-go v1.1.44-0.20240212150040-5f7a82b10b0e h1:hcILtavxFRKcvzHK2fEb086P3fCTmXgYbkAn5aCbdxk=
github.com/multiversx/mx-chain-proxy-go v1.1.44-0.20240212150040-5f7a82b10b0e/go.mod h1:Ax+80b1qynepkZSxrz8QB3AO00JAL3svaLasMTE6Lh0=
github.com/multiversx/mx-chain-scenario-go v1.4.3-0.20240212160120-cc32d1580157 h1:ydzN3f+Y7H0InXuxAcNUSyVc+omNYL8uYtLqVzqaaX4=
github.com/multiversx/mx-chain-scenario-go v1.4.3-0.20240212160120-cc32d1580157/go.mod h1:ndk45i9J9McuCJpTcgiaK4ocd0yhnBBCPrlFwO6GRcs=
github.com/multiversx/mx-chain-storage-go v1.0.15-0.20240129144933-b1c0d642d7f8 h1:/EYv/HGX0OKbeNFt667J0yZRtuJiZH0lEK8YtobuH/c=
github.com/multiversx/mx-chain-storage-go v1.0.15-0.20240129144933-b1c0d642d7f8/go.mod h1:zl1A6teNe39T8yhdZlkX3ckm5aLYrMIJJZ6Ord1E71M=
github.com/multiversx/mx-chain-vm-common-go v1.5.12-0.20240227112124-bfd3f5676e5a h1:4Dlk5Hcxlt6az5qqJfklgSlAKEYiFLv+xkFavQJgSNY=
github.com/multiversx/mx-chain-vm-common-go v1.5.12-0.20240227112124-bfd3f5676e5a/go.mod h1:OUyhCFqZKqUk1uaPsenyPDwO1830SlHNDU7Q7b6CBVI=
github.com/multiversx/mx-chain-vm-go v1.5.28-0.20240216071136-6d748b5d6a72 h1:NMHNT4NcqOdnHttYsT3ydZHVapwOctp6t+WDGDy0UEQ=
github.com/multiversx/mx-chain-vm-go v1.5.28-0.20240216071136-6d748b5d6a72/go.mod h1:YCD2Q+kpzx86ydowe/BKw/ZdzYjfH/4IxWHS0NsyuD0=
github.com/multiversx/mx-chain-vm-common-go v1.5.12-0.20240305123516-2231c71162a2 h1:sBH1Zf5jdMqS+1LDfXBmsIdmol8CFloPzjDCtmBZGEc=
github.com/multiversx/mx-chain-vm-common-go v1.5.12-0.20240305123516-2231c71162a2/go.mod h1:OUyhCFqZKqUk1uaPsenyPDwO1830SlHNDU7Q7b6CBVI=
github.com/multiversx/mx-chain-vm-go v1.5.28-0.20240216171908-e2a4c8ed9823 h1:UMu8cs5nBli6oOZo7AEiWteJriSLV5//mc1tGoapMgY=
github.com/multiversx/mx-chain-vm-go v1.5.28-0.20240216171908-e2a4c8ed9823/go.mod h1:Xs0xFsPv+c1p8pwurLV7VBS7bEpIN/0jZrCwXVU26zw=
github.com/multiversx/mx-chain-vm-v1_2-go v1.2.66-0.20240129145751-f814f5525edb h1:UtiY8X73llF9OLtGb2CM7Xewae1chvPjLc8B+ZmDLjw=
github.com/multiversx/mx-chain-vm-v1_2-go v1.2.66-0.20240129145751-f814f5525edb/go.mod h1:8uugq3HUeDiE6G4AS3F8/B3zA1Pabzbl7SSD6Cebwz8=
github.com/multiversx/mx-chain-vm-v1_3-go v1.3.67-0.20240129150004-536a22d9c618 h1:1uMlT5TjiHUlx81fEH/WQANWlY0PjF3opMlW+E3L3GI=
Expand Down
2 changes: 1 addition & 1 deletion pkg/proxy/configs/configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func generatePemFromInitialAddress(fileName string, initialAddresses map[uint32]

for _, wallet := range initialAddresses {
blk := pem.Block{
Type: "PRIVATE KEY for " + wallet.Address,
Type: "PRIVATE KEY for " + wallet.Address.Bech32,
Bytes: []byte(wallet.PrivateKeyHex),
}

Expand Down
4 changes: 3 additions & 1 deletion pkg/proxy/configs/configs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ func createArgsProxyConfigs(t *testing.T) ArgsProxyConfigs {
},
InitialWallets: map[uint32]*dtos.WalletKey{
0: {
Address: "erd17g9splt634xppt782cktfyyfmhdqlya9vqlqjeclpk65ckuxkcwqxu78wy",
Address: dtos.WalletAddress{
Bech32: "erd17g9splt634xppt782cktfyyfmhdqlya9vqlqjeclpk65ckuxkcwqxu78wy",
},
PrivateKeyHex: "NzhkOGI1ZDYxOWVkNzkyY2U5ZWE1YTk5YjZkYjA4NzgwMDA1MzE3OTRlYmVhNzFk\nNWRhYWUwODdlNDE4MGZmZGYyMGIwMGZkN2E4ZDRjMTBhZmM3NTYyY2I0OTA4OWRk\nZGEwZjkzYTU2MDNlMDk2NzFmMGRiNTRjNWI4NmI2MWM=",
},
},
Expand Down
6 changes: 3 additions & 3 deletions scripts/run-examples/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ wait_simulator_to_start() {

wait_simulator_to_start

# run staking example
run_python_script ../../examples/staking staking.py

# run adder example
run_python_script ../../examples/contracts/adder/ adder.py

Expand All @@ -41,8 +44,5 @@ run_python_script ../../examples/contracts/wrappedegld wrapped-egld.py
# run esdt create example
run_python_script ../../examples/esdt/ issue-fungible.py

# run staking example
run_python_script ../../examples/staking staking.py

# run move balance example
run_python_script ../../examples/movebalance move-balance.py

0 comments on commit 09fd222

Please sign in to comment.