withdrawal method
Map<String, dynamic>
withdrawal({
- required Object amount,
- String type = '0x2::sui::SUI',
- WithdrawalSource from = WithdrawalSource.sender,
- String? allowance,
- String? funder,
Reserves funds without redeeming them, for Move calls that accept a Withdrawal.
Implementation
Map<String, dynamic> withdrawal({
required Object amount,
String type = '0x2::sui::SUI',
WithdrawalSource from = WithdrawalSource.sender,
String? allowance,
String? funder,
}) {
if ((from == WithdrawalSource.allowance) !=
(allowance != null && funder != null) ||
(from != WithdrawalSource.allowance &&
(allowance != null || funder != null))) {
throw ArgumentError(
'Allowance withdrawals require both allowance and funder',
);
}
return _blockData.addInput('withdrawal', {
r'$kind': 'FundsWithdrawal',
'FundsWithdrawal': {
'reservation': {'MaxAmountU64': parseBalanceAmount(amount).toString()},
'typeArg': {
'Balance': type.contains('@') ? type : normalizeStructTagString(type),
},
'withdrawFrom': switch (from) {
WithdrawalSource.sender => {'Sender': true},
WithdrawalSource.sponsor => {'Sponsor': true},
WithdrawalSource.allowance => {
'SenderAllowance': {
'funder': normalizeSuiAddress(funder!),
'allowance': normalizeSuiAddress(allowance!),
},
},
},
},
});
}