From daa5a78492c1374f6f28d93cc0d1a1358416e96d Mon Sep 17 00:00:00 2001 From: Igor Papandinas <26460174+ipapandinas@users.noreply.github.com> Date: Tue, 31 Dec 2024 12:50:59 +0100 Subject: [PATCH 1/2] Warning message to use DAppStaking v3 interface for precompile calls --- docs/build/EVM/precompiles/index.md | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/docs/build/EVM/precompiles/index.md b/docs/build/EVM/precompiles/index.md index f3b76d6604c..a394ca02df4 100644 --- a/docs/build/EVM/precompiles/index.md +++ b/docs/build/EVM/precompiles/index.md @@ -44,23 +44,35 @@ The Addresses can be checked in the [Astar repo](https://github.com/AstarNetwork ## Usage Example -Here we'll demonstrate how to interact with the dApp staking precompile using Remix IDE. Other precompiles can be accessed in a similar manner. +This section demonstrates how to interact with the dApp Staking precompile from your contract or using Remix IDE. Other precompiles can be accessed in a similar manner. + +### From contract + +`DappsStakingV3.sol` contains functions that _mimic_ the interface of the latest version of `dApp Staking`. The interface can be found in the [Astar repository](https://github.com/AstarNetwork/Astar/blob/master/precompiles/dapp-staking/DappsStakingV3.sol). +Developers are encouraged to use this interface to fully utilize dApp staking functionality. ```solidity -import "./DappsStaking.sol"; +import "./DappsStakingV3.sol"; + contract A { - DappsStaking public constant DAPPS_STAKING = DappsStaking(0x0000000000000000000000000000000000005001); + DAppStaking public constant DAPPS_STAKING = DAppStaking(0x0000000000000000000000000000000000005001); - /// @notice Check current era - function checkCurrentEra() public view { - uint256 currentEra = DAPPS_STAKING.read_current_era(); + /// @notice Check protocol state + /// @return ProtocolState: The current protocol state. + function checkProtocolState() public view returns (DAppStaking.ProtocolState memory) { + DAppStaking.ProtocolState memory protocolState = DAPPS_STAKING.protocol_state(); + return protocolState; } } ``` +### Using Remix IDE + +:::caution The example below uses a soft-deprecated interface from the older dApp Staking v2. While it is still supported by the network, it does not reflect the recommended usage for dApp Staking v3. Please use the `v3` interface in a similar way for the latest version of the dApp Staking precompile. ::: + Example use: check `current era` and `total staked amount` in the `pallet-dapps-staking` for Shiden Network. For this example we will use Remix. -1. Copy `DappsStaking.sol` from [Astar repo](https://github.com/AstarNetwork/Astar/) and create new contract in Remix: +1. Copy `DappsStakingV2.sol` from [Astar repo](https://github.com/AstarNetwork/Astar/blob/master/precompiles/dapp-staking/DappsStakingV2.sol) and create new contract in Remix: ![](https://i.imgur.com/mr0TcLq.png) From 1f54117e76d23e1bd3c6d0cb11ec570573896558 Mon Sep 17 00:00:00 2001 From: Igor Papandinas <26460174+ipapandinas@users.noreply.github.com> Date: Tue, 31 Dec 2024 13:25:40 +0100 Subject: [PATCH 2/2] fix caution block --- docs/build/EVM/precompiles/index.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/build/EVM/precompiles/index.md b/docs/build/EVM/precompiles/index.md index a394ca02df4..1c6a0324d85 100644 --- a/docs/build/EVM/precompiles/index.md +++ b/docs/build/EVM/precompiles/index.md @@ -68,7 +68,13 @@ contract A { ### Using Remix IDE -:::caution The example below uses a soft-deprecated interface from the older dApp Staking v2. While it is still supported by the network, it does not reflect the recommended usage for dApp Staking v3. Please use the `v3` interface in a similar way for the latest version of the dApp Staking precompile. ::: +:::caution + +The example below uses a soft-deprecated interface from the older dApp Staking v2. +While it is still supported by the network, it does not reflect the recommended usage for dApp Staking v3. +Please use the `v3` interface in a similar way for the latest version of the dApp Staking precompile. + +::: Example use: check `current era` and `total staked amount` in the `pallet-dapps-staking` for Shiden Network. For this example we will use Remix.