Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Ğ
Ğcli-v2s
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
clients
Rust
Ğcli-v2s
Commits
fa9169b9
Commit
fa9169b9
authored
1 year ago
by
Hugo Trentesaux
Browse files
Options
Downloads
Patches
Plain Diff
add commented transfer
parent
8820e6de
No related branches found
No related tags found
1 merge request
!34
Draft: tx comments
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/commands.rs
+1
-0
1 addition, 0 deletions
src/commands.rs
src/commands/account.rs
+18
-5
18 additions, 5 deletions
src/commands/account.rs
src/commands/commented.rs
+36
-0
36 additions, 0 deletions
src/commands/commented.rs
src/commands/transfer.rs
+6
-6
6 additions, 6 deletions
src/commands/transfer.rs
with
61 additions
and
11 deletions
src/commands.rs
+
1
−
0
View file @
fa9169b9
...
@@ -16,3 +16,4 @@ pub mod sudo;
...
@@ -16,3 +16,4 @@ pub mod sudo;
pub
mod
transfer
;
pub
mod
transfer
;
pub
mod
ud
;
pub
mod
ud
;
pub
mod
vault
;
pub
mod
vault
;
pub
mod
commented
;
This diff is collapsed.
Click to expand it.
src/commands/account.rs
+
18
−
5
View file @
fa9169b9
...
@@ -12,12 +12,15 @@ pub enum Subcommand {
...
@@ -12,12 +12,15 @@ pub enum Subcommand {
amount
:
u64
,
amount
:
u64
,
/// Destination address
/// Destination address
dest
:
AccountId
,
dest
:
AccountId
,
///
Prevent from
going below account existential deposit
///
Allow
going below account existential deposit
#[clap(short
=
'k'
,
long
=
"
keep-alive
"
)]
#[clap(short
=
'k'
,
long
=
"
allow-death
"
)]
keep_alive
:
bool
,
allow_death
:
bool
,
/// Use universal dividends instead of units
/// Use universal dividends instead of units
#[clap(short
=
'u'
,
long
=
"ud"
)]
#[clap(short
=
'u'
,
long
=
"ud"
)]
is_ud
:
bool
,
is_ud
:
bool
,
/// Add a transaction comment
#[clap(short
=
'c'
,
long
=
"comment"
)]
comment
:
Option
<
String
>
,
},
},
/// Transfer the same amount for each space-separated address.
/// Transfer the same amount for each space-separated address.
/// If an address appears mutiple times, it will get multiple times the same amount
/// If an address appears mutiple times, it will get multiple times the same amount
...
@@ -39,10 +42,20 @@ pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliE
...
@@ -39,10 +42,20 @@ pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliE
Subcommand
::
Transfer
{
Subcommand
::
Transfer
{
amount
,
amount
,
dest
,
dest
,
keep_alive
,
allow_death
,
is_ud
,
is_ud
,
comment
,
}
=>
{
}
=>
{
commands
::
transfer
::
transfer
(
&
data
,
amount
,
dest
,
keep_alive
,
is_ud
)
.await
?
;
if
let
Some
(
comment
)
=
comment
{
if
is_ud
||
allow_death
{
return
Err
(
GcliError
::
Input
(
"ud or allow death commented transfers are not handled yet"
.to_string
(),
));
}
commands
::
commented
::
transfer
(
&
data
,
amount
,
dest
,
comment
)
.await
?
;
}
else
{
commands
::
transfer
::
transfer
(
&
data
,
amount
,
dest
,
allow_death
,
is_ud
)
.await
?
;
}
}
}
Subcommand
::
TransferMultiple
{
amount
,
dests
}
=>
{
Subcommand
::
TransferMultiple
{
amount
,
dests
}
=>
{
commands
::
transfer
::
transfer_multiple
(
&
data
,
amount
,
dests
)
.await
?
;
commands
::
transfer
::
transfer_multiple
(
&
data
,
amount
,
dests
)
.await
?
;
...
...
This diff is collapsed.
Click to expand it.
src/commands/commented.rs
0 → 100644
+
36
−
0
View file @
fa9169b9
use
crate
::
*
;
#[cfg(any(feature
=
"dev"
,
feature
=
"gdev"
))]
// find how to get runtime calls
type
Call
=
runtime
::
runtime_types
::
gdev_runtime
::
RuntimeCall
;
type
BalancesCall
=
runtime
::
runtime_types
::
pallet_balances
::
pallet
::
Call
;
type
SystemCall
=
runtime
::
runtime_types
::
frame_system
::
pallet
::
Call
;
/// commented balance transfer
pub
async
fn
transfer
(
data
:
&
Data
,
amount
:
u64
,
dest
:
AccountId
,
comment
:
String
,
)
->
Result
<
(),
subxt
::
Error
>
{
// build transfer call
let
transfer_call
=
Call
::
Balances
(
BalancesCall
::
transfer_keep_alive
{
dest
:
dest
.into
(),
value
:
amount
,
});
// build comment call
let
comment_call
=
Call
::
System
(
SystemCall
::
remark_with_event
{
remark
:
comment
.as_bytes
()
.to_vec
(),
});
// wrap these calls in a batch call
submit_call_and_look_event
::
<
runtime
::
utility
::
events
::
BatchCompleted
,
Payload
<
runtime
::
utility
::
calls
::
types
::
Batch
>
,
>
(
data
,
&
runtime
::
tx
()
.utility
()
.batch
(
vec!
[
transfer_call
,
comment_call
]),
)
.await
}
This diff is collapsed.
Click to expand it.
src/commands/transfer.rs
+
6
−
6
View file @
fa9169b9
...
@@ -9,11 +9,11 @@ pub async fn transfer(
...
@@ -9,11 +9,11 @@ pub async fn transfer(
data
:
&
Data
,
data
:
&
Data
,
balance
:
u64
,
balance
:
u64
,
dest
:
AccountId
,
dest
:
AccountId
,
keep_alive
:
bool
,
allow_deat
:
bool
,
is_ud
:
bool
,
is_ud
:
bool
,
)
->
Result
<
(),
subxt
::
Error
>
{
)
->
Result
<
(),
subxt
::
Error
>
{
match
(
keep_alive
,
is_ud
)
{
match
(
allow_deat
,
is_ud
)
{
(
tru
e
,
false
)
=>
{
(
fals
e
,
false
)
=>
{
submit_call_and_look_event
::
<
submit_call_and_look_event
::
<
runtime
::
balances
::
events
::
Transfer
,
runtime
::
balances
::
events
::
Transfer
,
Payload
<
runtime
::
balances
::
calls
::
types
::
TransferKeepAlive
>
,
Payload
<
runtime
::
balances
::
calls
::
types
::
TransferKeepAlive
>
,
...
@@ -25,7 +25,7 @@ pub async fn transfer(
...
@@ -25,7 +25,7 @@ pub async fn transfer(
)
)
.await
.await
}
}
(
fals
e
,
false
)
=>
{
(
tru
e
,
false
)
=>
{
submit_call_and_look_event
::
<
submit_call_and_look_event
::
<
runtime
::
balances
::
events
::
Transfer
,
runtime
::
balances
::
events
::
Transfer
,
Payload
<
runtime
::
balances
::
calls
::
types
::
TransferAllowDeath
>
,
Payload
<
runtime
::
balances
::
calls
::
types
::
TransferAllowDeath
>
,
...
@@ -37,7 +37,7 @@ pub async fn transfer(
...
@@ -37,7 +37,7 @@ pub async fn transfer(
)
)
.await
.await
}
}
(
tru
e
,
true
)
=>
{
(
fals
e
,
true
)
=>
{
submit_call_and_look_event
::
<
submit_call_and_look_event
::
<
runtime
::
balances
::
events
::
Transfer
,
runtime
::
balances
::
events
::
Transfer
,
Payload
<
runtime
::
universal_dividend
::
calls
::
types
::
TransferUdKeepAlive
>
,
Payload
<
runtime
::
universal_dividend
::
calls
::
types
::
TransferUdKeepAlive
>
,
...
@@ -49,7 +49,7 @@ pub async fn transfer(
...
@@ -49,7 +49,7 @@ pub async fn transfer(
)
)
.await
.await
}
}
(
fals
e
,
true
)
=>
{
(
tru
e
,
true
)
=>
{
submit_call_and_look_event
::
<
submit_call_and_look_event
::
<
runtime
::
balances
::
events
::
Transfer
,
runtime
::
balances
::
events
::
Transfer
,
Payload
<
runtime
::
universal_dividend
::
calls
::
types
::
TransferUd
>
,
Payload
<
runtime
::
universal_dividend
::
calls
::
types
::
TransferUd
>
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment