I am struggling to figure out how to supply tuple parameters to a dynamic call in the latest subxt master branch. I know parameters are combinations of Value types.
My current non-working code looks like:
let call = subxt::dynamic::tx(
MODULE,
"create_group",
vec![
Value::from_bytes(json.name.as_bytes()),
Value::unnamed_composite(
members
.into_iter()
.map(|(account_id, weight)| {
Value::unnamed_composite(vec![
Value::from_bytes(account_id),
Value::u128(weight.into()),
])
})
.collect::<Vec<_>>(),
),
Value::u128(json.threshold.into()),
Value::u128(json.initial_balance),
],
);
The call signature is :
pub fn create_group(
origin: OriginFor<T>,
name: Vec<u8>,
members: Vec<(T::AccountId, T::MemberCount)>,
threshold: T::MemberCount,
initial_balance: <<T as Config>::Currency as Currency<T::AccountId>>::Balance,
) -> DispatchResultWithPostInfo {
It compiles but I get the error:
Error encoding from dynamic value: Error at [0].[1]: Cannot encode to type; expected length 2 but got length 32
The auto-generated call works fine, but I am using dynamic calls because I need to be able to pass the call as a parameter to other extrinsics and it appears that that can only be done with dynamic queries.
The autogenerated call that works is:
let call = borlaug_subxt::tx().groups().create_group(
json.name.into(),
members,
json.threshold,
json.initial_balance,
);
And members is a vec of tuples of Account32,u32
The auto-generated call works fine,
? Could you please include this into the question too... I think you will be able to copy and paste from itmembers.iter(),map()
?