Skip to content

Commit

Permalink
✨ Add param resolve_last to call smart contract public method from …
Browse files Browse the repository at this point in the history
…specific address
  • Loading branch information
redDwarf03 committed Jun 5, 2024
1 parent de0dce7 commit e43c27f
Show file tree
Hide file tree
Showing 9 changed files with 326 additions and 215 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ Changelog
=========
=========

#### Version 3.3.17
* Add param `resolve_last` to call smart contract public method from specific address

#### Version 3.3.16
* Update `Transaction` model from Blockchain structure

Expand Down
19 changes: 19 additions & 0 deletions lib/src/model/smart_contracts/sc_call_function_params.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/// SPDX-License-Identifier: AGPL-3.0-or-later
// ignore_for_file: invalid_annotation_target
import 'package:freezed_annotation/freezed_annotation.dart';

part 'sc_call_function_params.freezed.dart';
part 'sc_call_function_params.g.dart';

@freezed
class SCCallFunctionParams with _$SCCallFunctionParams {
factory SCCallFunctionParams({
required String contract,
required String function,
required List<dynamic> args,
@Default(true) @JsonKey(name: 'resolve_last') bool resolveLast,
}) = _SCCallFunctionParams;

factory SCCallFunctionParams.fromJson(Map<String, dynamic> json) =>
_$SCCallFunctionParamsFromJson(json);
}
233 changes: 233 additions & 0 deletions lib/src/model/smart_contracts/sc_call_function_params.freezed.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark

part of 'sc_call_function_params.dart';

// **************************************************************************
// FreezedGenerator
// **************************************************************************

T _$identity<T>(T value) => value;

final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');

SCCallFunctionParams _$SCCallFunctionParamsFromJson(Map<String, dynamic> json) {
return _SCCallFunctionParams.fromJson(json);
}

/// @nodoc
mixin _$SCCallFunctionParams {
String get contract => throw _privateConstructorUsedError;
String get function => throw _privateConstructorUsedError;
List<dynamic> get args => throw _privateConstructorUsedError;
@JsonKey(name: 'resolve_last')
bool get resolveLast => throw _privateConstructorUsedError;

Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$SCCallFunctionParamsCopyWith<SCCallFunctionParams> get copyWith =>
throw _privateConstructorUsedError;
}

/// @nodoc
abstract class $SCCallFunctionParamsCopyWith<$Res> {
factory $SCCallFunctionParamsCopyWith(SCCallFunctionParams value,
$Res Function(SCCallFunctionParams) then) =
_$SCCallFunctionParamsCopyWithImpl<$Res, SCCallFunctionParams>;
@useResult
$Res call(
{String contract,
String function,
List<dynamic> args,
@JsonKey(name: 'resolve_last') bool resolveLast});
}

/// @nodoc
class _$SCCallFunctionParamsCopyWithImpl<$Res,
$Val extends SCCallFunctionParams>
implements $SCCallFunctionParamsCopyWith<$Res> {
_$SCCallFunctionParamsCopyWithImpl(this._value, this._then);

// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;

@pragma('vm:prefer-inline')
@override
$Res call({
Object? contract = null,
Object? function = null,
Object? args = null,
Object? resolveLast = null,
}) {
return _then(_value.copyWith(
contract: null == contract
? _value.contract
: contract // ignore: cast_nullable_to_non_nullable
as String,
function: null == function
? _value.function
: function // ignore: cast_nullable_to_non_nullable
as String,
args: null == args
? _value.args
: args // ignore: cast_nullable_to_non_nullable
as List<dynamic>,
resolveLast: null == resolveLast
? _value.resolveLast
: resolveLast // ignore: cast_nullable_to_non_nullable
as bool,
) as $Val);
}
}

/// @nodoc
abstract class _$$SCCallFunctionParamsImplCopyWith<$Res>
implements $SCCallFunctionParamsCopyWith<$Res> {
factory _$$SCCallFunctionParamsImplCopyWith(_$SCCallFunctionParamsImpl value,
$Res Function(_$SCCallFunctionParamsImpl) then) =
__$$SCCallFunctionParamsImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{String contract,
String function,
List<dynamic> args,
@JsonKey(name: 'resolve_last') bool resolveLast});
}

/// @nodoc
class __$$SCCallFunctionParamsImplCopyWithImpl<$Res>
extends _$SCCallFunctionParamsCopyWithImpl<$Res, _$SCCallFunctionParamsImpl>
implements _$$SCCallFunctionParamsImplCopyWith<$Res> {
__$$SCCallFunctionParamsImplCopyWithImpl(_$SCCallFunctionParamsImpl _value,
$Res Function(_$SCCallFunctionParamsImpl) _then)
: super(_value, _then);

@pragma('vm:prefer-inline')
@override
$Res call({
Object? contract = null,
Object? function = null,
Object? args = null,
Object? resolveLast = null,
}) {
return _then(_$SCCallFunctionParamsImpl(
contract: null == contract
? _value.contract
: contract // ignore: cast_nullable_to_non_nullable
as String,
function: null == function
? _value.function
: function // ignore: cast_nullable_to_non_nullable
as String,
args: null == args
? _value._args
: args // ignore: cast_nullable_to_non_nullable
as List<dynamic>,
resolveLast: null == resolveLast
? _value.resolveLast
: resolveLast // ignore: cast_nullable_to_non_nullable
as bool,
));
}
}

/// @nodoc
@JsonSerializable()
class _$SCCallFunctionParamsImpl implements _SCCallFunctionParams {
_$SCCallFunctionParamsImpl(
{required this.contract,
required this.function,
required final List<dynamic> args,
@JsonKey(name: 'resolve_last') this.resolveLast = true})
: _args = args;

factory _$SCCallFunctionParamsImpl.fromJson(Map<String, dynamic> json) =>
_$$SCCallFunctionParamsImplFromJson(json);

@override
final String contract;
@override
final String function;
final List<dynamic> _args;
@override
List<dynamic> get args {
if (_args is EqualUnmodifiableListView) return _args;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_args);
}

@override
@JsonKey(name: 'resolve_last')
final bool resolveLast;

@override
String toString() {
return 'SCCallFunctionParams(contract: $contract, function: $function, args: $args, resolveLast: $resolveLast)';
}

@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$SCCallFunctionParamsImpl &&
(identical(other.contract, contract) ||
other.contract == contract) &&
(identical(other.function, function) ||
other.function == function) &&
const DeepCollectionEquality().equals(other._args, _args) &&
(identical(other.resolveLast, resolveLast) ||
other.resolveLast == resolveLast));
}

@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(runtimeType, contract, function,
const DeepCollectionEquality().hash(_args), resolveLast);

@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$SCCallFunctionParamsImplCopyWith<_$SCCallFunctionParamsImpl>
get copyWith =>
__$$SCCallFunctionParamsImplCopyWithImpl<_$SCCallFunctionParamsImpl>(
this, _$identity);

@override
Map<String, dynamic> toJson() {
return _$$SCCallFunctionParamsImplToJson(
this,
);
}
}

abstract class _SCCallFunctionParams implements SCCallFunctionParams {
factory _SCCallFunctionParams(
{required final String contract,
required final String function,
required final List<dynamic> args,
@JsonKey(name: 'resolve_last') final bool resolveLast}) =
_$SCCallFunctionParamsImpl;

factory _SCCallFunctionParams.fromJson(Map<String, dynamic> json) =
_$SCCallFunctionParamsImpl.fromJson;

@override
String get contract;
@override
String get function;
@override
List<dynamic> get args;
@override
@JsonKey(name: 'resolve_last')
bool get resolveLast;
@override
@JsonKey(ignore: true)
_$$SCCallFunctionParamsImplCopyWith<_$SCCallFunctionParamsImpl>
get copyWith => throw _privateConstructorUsedError;
}
25 changes: 25 additions & 0 deletions lib/src/model/smart_contracts/sc_call_function_params.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 1 addition & 12 deletions lib/src/model/smart_contracts/sc_call_function_request.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/// SPDX-License-Identifier: AGPL-3.0-or-later
import 'package:archethic_lib_dart/src/model/smart_contracts/sc_call_function_params.dart';
import 'package:freezed_annotation/freezed_annotation.dart';

part 'sc_call_function_request.freezed.dart';
Expand All @@ -16,15 +17,3 @@ class SCCallFunctionRequest with _$SCCallFunctionRequest {
factory SCCallFunctionRequest.fromJson(Map<String, dynamic> json) =>
_$SCCallFunctionRequestFromJson(json);
}

@freezed
class SCCallFunctionParams with _$SCCallFunctionParams {
factory SCCallFunctionParams({
required String contract,
required String function,
required List<dynamic> args,
}) = _SCCallFunctionParams;

factory SCCallFunctionParams.fromJson(Map<String, dynamic> json) =>
_$SCCallFunctionParamsFromJson(json);
}
Loading

0 comments on commit e43c27f

Please sign in to comment.