mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 19:21:13 +00:00
Split subxt (#102)
* Proc macro improvements. * Use proc-macros. * Update examples. * Fix build. * Run rustfmt. * Fix total issuance test. * Remove gas limit from put code call. * Handle runtime errors. * Fix tests. * Make test more reliable. * Revert "Handle runtime errors." This reverts commit 26f30a9f4cfcfddfb3e49308cded46cfe6468697. * Use expect instead of unwrap. * Parse marker type. * Fetch doesn't fail.
This commit is contained in:
@@ -14,47 +14,35 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with substrate-subxt. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#[macro_use]
|
||||
extern crate substrate_subxt;
|
||||
|
||||
use codec::{
|
||||
Codec,
|
||||
Decode,
|
||||
Encode,
|
||||
};
|
||||
use frame_support::Parameter;
|
||||
use sp_keyring::AccountKeyring;
|
||||
use sp_runtime::traits::{
|
||||
AtLeast32Bit,
|
||||
MaybeSerialize,
|
||||
Member,
|
||||
};
|
||||
use std::fmt::Debug;
|
||||
use substrate_subxt::{
|
||||
system::System,
|
||||
sp_runtime::traits::{
|
||||
AtLeast32Bit,
|
||||
MaybeSerialize,
|
||||
Member,
|
||||
},
|
||||
system::{
|
||||
System,
|
||||
SystemEventsDecoder,
|
||||
},
|
||||
ClientBuilder,
|
||||
KusamaRuntime,
|
||||
};
|
||||
use substrate_subxt_proc_macro::{
|
||||
module,
|
||||
subxt_test,
|
||||
Call,
|
||||
Event,
|
||||
Store,
|
||||
};
|
||||
|
||||
pub trait SystemEventsDecoder {
|
||||
fn with_system(&mut self) -> Result<(), substrate_subxt::EventsError>;
|
||||
}
|
||||
|
||||
impl<T: System> SystemEventsDecoder for substrate_subxt::EventsDecoder<T> {
|
||||
fn with_system(&mut self) -> Result<(), substrate_subxt::EventsError> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[module]
|
||||
pub trait Balances: System {
|
||||
type Balance: Parameter
|
||||
+ Member
|
||||
type Balance: Member
|
||||
+ AtLeast32Bit
|
||||
+ codec::Codec
|
||||
+ Codec
|
||||
+ Default
|
||||
+ Copy
|
||||
+ MaybeSerialize
|
||||
@@ -127,13 +115,15 @@ async fn transfer_balance_example() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let alice = AccountKeyring::Alice.to_account_id();
|
||||
let bob = AccountKeyring::Bob.to_account_id();
|
||||
|
||||
let alice_account = client.account(&alice).await?.unwrap_or_default();
|
||||
let bob_account = client.account(&bob).await?.unwrap_or_default();
|
||||
let alice_account = client.account(&alice).await?;
|
||||
let bob_account = client.account(&bob).await?;
|
||||
let pre = (alice_account, bob_account);
|
||||
|
||||
let result = client
|
||||
.xt(AccountKeyring::Alice.pair(), None)
|
||||
.await?
|
||||
let builder = client.xt(AccountKeyring::Alice.pair(), None).await?;
|
||||
|
||||
let _hash = builder.transfer(&bob.clone().into(), 10_000).await?;
|
||||
|
||||
let result = builder
|
||||
.watch()
|
||||
.transfer(&bob.clone().into(), 10_000)
|
||||
.await?;
|
||||
@@ -147,8 +137,8 @@ async fn transfer_balance_example() -> Result<(), Box<dyn std::error::Error>> {
|
||||
})
|
||||
);
|
||||
|
||||
let alice_account = client.account(&alice).await?.unwrap_or_default();
|
||||
let bob_account = client.account(&bob).await?.unwrap_or_default();
|
||||
let alice_account = client.account(&alice).await?;
|
||||
let bob_account = client.account(&bob).await?;
|
||||
let post = (alice_account, bob_account);
|
||||
|
||||
assert_eq!(pre.0.free, post.0.free - 10_000);
|
||||
|
||||
Reference in New Issue
Block a user