object method
Implementation
Map<String, dynamic> object(dynamic value) {
if (value is Function) {
return object(value(this));
}
if (value is Map && value['\$kind'] != null) {
final kind = value['\$kind'];
if (kind == 'GasCoin'
|| kind == 'Input'
|| kind == 'Result'
|| kind == 'NestedResult') {
return value as Map<String, dynamic>;
}
}
final id = getIdFromCallArg(value);
final inserted = _blockData.inputs.firstWhere(
(i) => id == getIdFromCallArg(i),
orElse: () => <String, dynamic>{}
);
// Upgrade shared object inputs to mutable if needed:
if (inserted.isNotEmpty &&
inserted['Object']?['SharedObject'] != null &&
value is Map<String, dynamic> &&
value['Object']?['SharedObject'] != null) {
inserted['Object']['SharedObject']['mutable'] =
inserted['Object']['SharedObject']['mutable'] ||
value['Object']['SharedObject']['mutable'];
}
if (inserted.isNotEmpty) {
return {
'\$kind': 'Input',
'Input': _blockData.inputs.indexOf(inserted),
'type': 'object'
};
} else {
return _blockData.addInput(
'object',
value is String
? {
'\$kind': 'UnresolvedObject',
'UnresolvedObject': {
'objectId': normalizeSuiAddress(value)
},
}
: value,
);
}
}