Skip to content

Commit

Permalink
feat: Update substrate to v1.2.0 (#3898)
Browse files Browse the repository at this point in the history
  • Loading branch information
ukint-vs authored Apr 25, 2024
1 parent a1f9f64 commit b270624
Show file tree
Hide file tree
Showing 19 changed files with 554 additions and 459 deletions.
529 changes: 261 additions & 268 deletions Cargo.lock

Large diffs are not rendered by default.

240 changes: 120 additions & 120 deletions Cargo.toml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion gcli/src/cmd/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl Transfer {
println!("Value: {}", self.value);

let addr: [u8; 32] = AccountId32::from_ss58check(&self.destination)?.into();
signer.transfer(addr.into(), self.value).await?;
signer.transfer_keep_alive(addr.into(), self.value).await?;

Ok(())
}
Expand Down
4 changes: 2 additions & 2 deletions gclient/src/api/calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ impl GearApi {
/// extrinsic.
///
/// This function returns a hash of the block with the transfer transaction.
pub async fn transfer(&self, destination: ProgramId, value: u128) -> Result<H256> {
pub async fn transfer_keep_alive(&self, destination: ProgramId, value: u128) -> Result<H256> {
let destination: [u8; 32] = destination.into();

let tx = self.0.calls.transfer(destination, value).await?;
let tx = self.0.calls.transfer_keep_alive(destination, value).await?;

for event in tx.wait_for_success().await?.iter() {
if let Event::Balances(BalancesEvent::Transfer { .. }) =
Expand Down
2 changes: 1 addition & 1 deletion gclient/tests/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async fn program_migrated_to_another_node() {

// Transfer some funds to the source program
src_node_api
.transfer(src_program_id, PROGRAM_FUNDS)
.transfer_keep_alive(src_program_id, PROGRAM_FUNDS)
.await
.expect("Unable to transfer funds to source program");

Expand Down
2 changes: 1 addition & 1 deletion gsdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async fn main() {
let signer = Api::new(None).signer("//Alice", None);

// Transaction with block details.
let tx = signer.transfer("//Bob", 42).await.expect("Transfer value failed.");
let tx = signer.transfer_keep_alive("//Bob", 42).await.expect("Transfer value failed.");

// Fetch all of the events associated with this transaction.
for events in tx.fetch_events().await {
Expand Down
98 changes: 70 additions & 28 deletions gsdk/src/metadata/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ pub mod runtime_types {
#[derive(
Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode,
)]
pub enum Bounded<_0> {
pub enum Bounded<_0, _1> {
#[codec(index = 0)]
Legacy {
hash: ::subxt::utils::H256,
Expand All @@ -135,7 +135,7 @@ pub mod runtime_types {
hash: ::subxt::utils::H256,
len: ::core::primitive::u32,
},
__Ignore(::core::marker::PhantomData<_0>),
__Ignore(::core::marker::PhantomData<(_0, _1)>),
}
}
pub mod schedule {
Expand All @@ -152,6 +152,17 @@ pub mod runtime_types {
}
pub mod tokens {
use super::runtime_types;
pub mod fungible {
use super::runtime_types;
#[derive(
::subxt::ext::codec::CompactAs,
Debug,
crate::gp::Decode,
crate::gp::DecodeAsType,
crate::gp::Encode,
)]
pub struct HoldConsideration(pub ::core::primitive::u128);
}
pub mod misc {
use super::runtime_types;
#[derive(
Expand Down Expand Up @@ -1172,15 +1183,6 @@ pub mod runtime_types {
#[codec(compact)]
value: ::core::primitive::u128,
},
#[codec(index = 1)]
#[doc = "See [`Pallet::set_balance_deprecated`]."]
set_balance_deprecated {
who: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>,
#[codec(compact)]
new_free: ::core::primitive::u128,
#[codec(compact)]
old_reserved: ::core::primitive::u128,
},
#[codec(index = 2)]
#[doc = "See [`Pallet::force_transfer`]."]
force_transfer {
Expand Down Expand Up @@ -1213,13 +1215,6 @@ pub mod runtime_types {
upgrade_accounts {
who: ::std::vec::Vec<::subxt::utils::AccountId32>,
},
#[codec(index = 7)]
#[doc = "See [`Pallet::transfer`]."]
transfer {
dest: ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>,
#[codec(compact)]
value: ::core::primitive::u128,
},
#[codec(index = 8)]
#[doc = "See [`Pallet::force_set_balance`]."]
force_set_balance {
Expand Down Expand Up @@ -4290,6 +4285,11 @@ pub mod runtime_types {
#[codec(index = 3)]
#[doc = "See [`Pallet::unrequest_preimage`]."]
unrequest_preimage { hash: ::subxt::utils::H256 },
#[codec(index = 4)]
#[doc = "See [`Pallet::ensure_updated`]."]
ensure_updated {
hashes: ::std::vec::Vec<::subxt::utils::H256>,
},
}
#[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)]
#[doc = "The `Error` enum of this pallet."]
Expand All @@ -4312,6 +4312,12 @@ pub mod runtime_types {
#[codec(index = 5)]
#[doc = "The preimage request cannot be removed since no outstanding requests exist."]
NotRequested,
#[codec(index = 6)]
#[doc = "More than `MAX_HASH_UPGRADE_BULK_COUNT` hashes were requested to be upgraded at once."]
TooMany,
#[codec(index = 7)]
#[doc = "Too few hashes were requested to be upgraded (i.e. zero)."]
TooFew,
}
#[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)]
#[doc = "The `Event` enum of this pallet"]
Expand All @@ -4326,9 +4332,14 @@ pub mod runtime_types {
#[doc = "A preimage has ben cleared."]
Cleared { hash: ::subxt::utils::H256 },
}
#[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)]
pub enum HoldReason {
#[codec(index = 0)]
Preimage,
}
}
#[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)]
pub enum RequestStatus<_0, _1> {
pub enum OldRequestStatus<_0, _1> {
#[codec(index = 0)]
Unrequested {
deposit: (_0, _1),
Expand All @@ -4341,6 +4352,20 @@ pub mod runtime_types {
len: ::core::option::Option<::core::primitive::u32>,
},
}
#[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)]
pub enum RequestStatus<_0, _1> {
#[codec(index = 0)]
Unrequested {
ticket: (_0, _1),
len: ::core::primitive::u32,
},
#[codec(index = 1)]
Requested {
maybe_ticket: ::core::option::Option<(_0, _1)>,
count: ::core::primitive::u32,
maybe_len: ::core::option::Option<::core::primitive::u32>,
},
}
}
pub mod pallet_proxy {
use super::runtime_types;
Expand Down Expand Up @@ -4643,6 +4668,7 @@ pub mod runtime_types {
::std::boxed::Box<runtime_types::vara_runtime::OriginCaller>,
proposal: runtime_types::frame_support::traits::preimages::Bounded<
runtime_types::vara_runtime::RuntimeCall,
runtime_types::sp_runtime::traits::BlakeTwo256,
>,
enactment_moment:
runtime_types::frame_support::traits::schedule::DispatchTime<
Expand Down Expand Up @@ -4687,6 +4713,7 @@ pub mod runtime_types {
::std::boxed::Box<runtime_types::vara_runtime::OriginCaller>,
proposal: runtime_types::frame_support::traits::preimages::Bounded<
runtime_types::vara_runtime::RuntimeCall,
runtime_types::sp_runtime::traits::BlakeTwo256,
>,
enactment_moment:
runtime_types::frame_support::traits::schedule::DispatchTime<
Expand Down Expand Up @@ -4817,6 +4844,7 @@ pub mod runtime_types {
track: ::core::primitive::u16,
proposal: runtime_types::frame_support::traits::preimages::Bounded<
runtime_types::vara_runtime::RuntimeCall,
runtime_types::sp_runtime::traits::BlakeTwo256,
>,
},
#[codec(index = 1)]
Expand Down Expand Up @@ -4846,6 +4874,7 @@ pub mod runtime_types {
track: ::core::primitive::u16,
proposal: runtime_types::frame_support::traits::preimages::Bounded<
runtime_types::vara_runtime::RuntimeCall,
runtime_types::sp_runtime::traits::BlakeTwo256,
>,
tally: runtime_types::pallet_conviction_voting::types::Tally<
::core::primitive::u128,
Expand Down Expand Up @@ -4928,6 +4957,7 @@ pub mod runtime_types {
track: ::core::primitive::u16,
proposal: runtime_types::frame_support::traits::preimages::Bounded<
runtime_types::vara_runtime::RuntimeCall,
runtime_types::sp_runtime::traits::BlakeTwo256,
>,
},
#[codec(index = 1)]
Expand Down Expand Up @@ -4957,6 +4987,7 @@ pub mod runtime_types {
track: ::core::primitive::u16,
proposal: runtime_types::frame_support::traits::preimages::Bounded<
runtime_types::vara_runtime::RuntimeCall,
runtime_types::sp_runtime::traits::BlakeTwo256,
>,
tally: runtime_types::pallet_ranked_collective::Tally,
},
Expand Down Expand Up @@ -5611,9 +5642,12 @@ pub mod runtime_types {
remainder: ::core::primitive::u128,
},
#[codec(index = 1)]
#[doc = "The nominator has been rewarded by this amount."]
#[doc = "The nominator has been rewarded by this amount to this destination."]
Rewarded {
stash: ::subxt::utils::AccountId32,
dest: runtime_types::pallet_staking::RewardDestination<
::subxt::utils::AccountId32,
>,
amount: ::core::primitive::u128,
},
#[codec(index = 2)]
Expand Down Expand Up @@ -5848,18 +5882,18 @@ pub mod runtime_types {
#[doc = "The `Event` enum of this pallet"]
pub enum Event {
#[codec(index = 0)]
#[doc = "A sudo just took place. \\[result\\]"]
#[doc = "A sudo call just took place."]
Sudid {
sudo_result:
::core::result::Result<(), runtime_types::sp_runtime::DispatchError>,
},
#[codec(index = 1)]
#[doc = "The \\[sudoer\\] just switched identity; the old key is supplied if one existed."]
#[doc = "The sudo key has been updated."]
KeyChanged {
old_sudoer: ::core::option::Option<::subxt::utils::AccountId32>,
},
#[codec(index = 2)]
#[doc = "A sudo just took place. \\[result\\]"]
#[doc = "A [sudo_as](Pallet::sudo_as) call just took place."]
SudoAsDone {
sudo_result:
::core::result::Result<(), runtime_types::sp_runtime::DispatchError>,
Expand Down Expand Up @@ -7088,6 +7122,11 @@ pub mod runtime_types {
}
}
}
pub mod traits {
use super::runtime_types;
#[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)]
pub struct BlakeTwo256;
}
#[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)]
pub enum DispatchError {
#[codec(index = 0)]
Expand Down Expand Up @@ -7685,7 +7724,10 @@ pub mod runtime_types {
GearDebug(runtime_types::pallet_gear_debug::pallet::Event),
}
#[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)]
pub enum RuntimeHoldReason {}
pub enum RuntimeHoldReason {
#[codec(index = 23)]
Preimage(runtime_types::pallet_preimage::pallet::HoldReason),
}
#[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)]
pub struct SessionKeys {
pub babe: runtime_types::sp_consensus_babe::app::Public,
Expand Down Expand Up @@ -7738,27 +7780,23 @@ pub mod calls {
#[doc = "Calls of pallet `Balances`."]
pub enum BalancesCall {
TransferAllowDeath,
SetBalanceDeprecated,
ForceTransfer,
TransferKeepAlive,
TransferAll,
ForceUnreserve,
UpgradeAccounts,
Transfer,
ForceSetBalance,
}
impl CallInfo for BalancesCall {
const PALLET: &'static str = "Balances";
fn call_name(&self) -> &'static str {
match self {
Self::TransferAllowDeath => "transfer_allow_death",
Self::SetBalanceDeprecated => "set_balance_deprecated",
Self::ForceTransfer => "force_transfer",
Self::TransferKeepAlive => "transfer_keep_alive",
Self::TransferAll => "transfer_all",
Self::ForceUnreserve => "force_unreserve",
Self::UpgradeAccounts => "upgrade_accounts",
Self::Transfer => "transfer",
Self::ForceSetBalance => "force_set_balance",
}
}
Expand Down Expand Up @@ -8113,6 +8151,7 @@ pub mod calls {
UnnotePreimage,
RequestPreimage,
UnrequestPreimage,
EnsureUpdated,
}
impl CallInfo for PreimageCall {
const PALLET: &'static str = "Preimage";
Expand All @@ -8122,6 +8161,7 @@ pub mod calls {
Self::UnnotePreimage => "unnote_preimage",
Self::RequestPreimage => "request_preimage",
Self::UnrequestPreimage => "unrequest_preimage",
Self::EnsureUpdated => "ensure_updated",
}
}
}
Expand Down Expand Up @@ -8978,13 +9018,15 @@ pub mod storage {
#[doc = "Storage of pallet `Preimage`."]
pub enum PreimageStorage {
StatusFor,
RequestStatusFor,
PreimageFor,
}
impl StorageInfo for PreimageStorage {
const PALLET: &'static str = "Preimage";
fn storage_name(&self) -> &'static str {
match self {
Self::StatusFor => "StatusFor",
Self::RequestStatusFor => "RequestStatusFor",
Self::PreimageFor => "PreimageFor",
}
}
Expand Down
10 changes: 7 additions & 3 deletions gsdk/src/signer/calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,15 @@ pub struct SignerCalls(pub(crate) Arc<Inner>);

// pallet-balances
impl SignerCalls {
/// `pallet_balances::transfer`
pub async fn transfer(&self, dest: impl Into<AccountId32>, value: u128) -> Result<TxInBlock> {
/// `pallet_balances::transfer_keep_alive`
pub async fn transfer_keep_alive(
&self,
dest: impl Into<AccountId32>,
value: u128,
) -> Result<TxInBlock> {
self.0
.run_tx(
BalancesCall::Transfer,
BalancesCall::TransferAllowDeath,
vec![
Value::unnamed_variant("Id", [Value::from_bytes(dest.into())]),
Value::u128(value),
Expand Down
4 changes: 2 additions & 2 deletions gsdk/src/signer/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,13 @@ impl Inner {
/// Value::unnamed_variant("Id", [Value::from_bytes(dest.into())]),
/// Value::u128(value),
/// ];
/// let in_block = signer.run_tx(BalancesCall::Transfer, args).await?;
/// let in_block = signer.run_tx(BalancesCall::TransferKeepAlive, args).await?;
/// }
///
/// // The code above euqals to:
///
/// {
/// let in_block = signer.calls.transfer(dest, value).await?;
/// let in_block = signer.calls.transfer_keep_alive(dest, value).await?;
/// }
///
/// // ...
Expand Down
2 changes: 1 addition & 1 deletion gsdk/tests/backtrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async fn transfer_backtrace() -> Result<()> {
let signer = Signer::new(api, "//Alice", None)?;
let alice: [u8; 32] = *alice_account_id().as_ref();

let tx = signer.calls.transfer(alice, 42).await?;
let tx = signer.calls.transfer_keep_alive(alice, 42).await?;
let backtrace = signer
.backtrace()
.get(tx.extrinsic_hash())
Expand Down
Loading

0 comments on commit b270624

Please sign in to comment.