public async Task <bool> Add(Promise promise, ApplicationUser user) { //it's guaranteed it's unique by contract code var counter = await GetPromiseCount(user); promise.Id = (counter == 0) ? 1 : counter + 1; var json = JsonConvert.SerializeObject(promise); var jsonHex = SmartPromiseConverter.Str2Hex(json); var revSh = await SmartPromiseConverter.GetScriptHashReversed(user.Address, _blockchain); var res = await _blockchain.InvokeContractAdd(NETWORK_TYPE.TESTNET, user.Wif, revSh, jsonHex, GAS_COST); return(res); }
public async Task <bool> Complete(int id, string proof, ApplicationUser user) { var promise = await Get(id, user); if (promise == null) { return(false); } promise.Status = PROMISE_STATUS.COMPLETED; promise.Proof = proof; var json = JsonConvert.SerializeObject(promise); var jsonHex = SmartPromiseConverter.Str2Hex(json); var revSh = await SmartPromiseConverter.GetScriptHashReversed(user.Address, _blockchain); var res = await _blockchain.InvokeContractReplace(NETWORK_TYPE.TESTNET, user.Wif, revSh, jsonHex, id, GAS_COST); return(res); }