Skip to content

Commit

Permalink
chore(gsdk): update transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
ukint-vs committed Apr 17, 2024
1 parent 1aaa313 commit 841ecff
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
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_allow_death("//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
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_allow_death`
pub async fn transfer_allow_death(
&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::TransferAllowDeath, args).await?;
/// }
///
/// // The code above euqals to:
///
/// {
/// let in_block = signer.calls.transfer(dest, value).await?;
/// let in_block = signer.calls.transfer_allow_death(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_allow_death(alice, 42).await?;
let backtrace = signer
.backtrace()
.get(tx.extrinsic_hash())
Expand Down

0 comments on commit 841ecff

Please sign in to comment.