constructContractInvocationOperation static method
dynamic
constructContractInvocationOperation()
Implementation
static constructContractInvocationOperation(
String publicKeyHash,
int counter,
String contract,
int amount,
entrypoint,
String parameters,
TezosParameterFormat parameterFormat) {
OperationModel transaction = new OperationModel(
destination: contract,
amount: amount.toString(),
counter: counter,
source: publicKeyHash,
);
if (parameters != '') {
if (parameterFormat == TezosParameterFormat.Michelson) {
var michelineParams =
TezosLanguageUtil.translateMichelsonExpressionToMicheline(
parameters)!;
transaction.parameters = {
'entrypoint': entrypoint.isEmpty ? 'default' : entrypoint,
'value': jsonDecode(michelineParams)
};
} else if (parameterFormat == TezosParameterFormat.Micheline) {
transaction.parameters = {
'entrypoint': entrypoint.isEmpty ? 'default' : entrypoint,
'value': jsonDecode(parameters)
};
} else if (parameterFormat == TezosParameterFormat.MichelsonLambda) {
var michelineLambda =
TezosLanguageUtil.translateMichelsonExpressionToMicheline(
'code $parameters')!;
transaction.parameters = {
'entrypoint': entrypoint.isEmpty ? 'default' : entrypoint,
'value': jsonDecode(michelineLambda)
};
}
} else if (entrypoint != null) {
transaction.parameters = {'entrypoint': entrypoint, 'value': []};
}
return transaction;
}