constructContractOriginationOperation static method

OperationModel constructContractOriginationOperation(
  1. KeyStoreModel keyStore,
  2. int amount,
  3. String delegate,
  4. String code,
  5. String storage,
  6. TezosParameterFormat codeFormat,
  7. int counter,
)

Implementation

static OperationModel constructContractOriginationOperation(
    KeyStoreModel keyStore,
    int amount,
    String delegate,
    String code,
    String storage,
    TezosParameterFormat codeFormat,
    int counter) {
  var parsedCode;
  var parsedStorage;
  if (codeFormat == TezosParameterFormat.Michelson) {
    parsedCode = jsonDecode(
        TezosLanguageUtil.translateMichelsonScriptToMicheline(code)!);
    parsedStorage = jsonDecode(
        TezosLanguageUtil.translateMichelsonExpressionToMicheline(storage)!);
  } else if (codeFormat == TezosParameterFormat.Micheline) {
    parsedCode = jsonDecode(code);
    parsedStorage = jsonDecode(storage);
  }

  return OperationModel(
    kind: 'origination',
    source: keyStore.publicKeyHash,
    counter: counter,
    amount: amount.toString(),
    delegate: delegate,
    script: {
      'code': parsedCode,
      'storage': parsedStorage,
    },
  );
}