private object ReadAction(byte[] data, ref Int32 readIndex, Api.v1.Action action, Abi abi) { if (action == null) { throw new ArgumentNullException("action"); } var size = Convert.ToInt32(ReadVarUint32(data, ref readIndex)); action.Authorization = new List <PermissionLevel>(size); for (var i = 0; i < size; i++) { action.Authorization.Add((PermissionLevel)ReadPermissionLevel(data, ref readIndex)); } var abiAction = abi.Actions.First(aa => aa.Name == action.Name); var abiStruct = abi.Structs.First(s => s.Name == abiAction.Type); var dataSize = Convert.ToInt32(ReadVarUint32(data, ref readIndex)); action.Data = ReadAbiStruct(data, ref readIndex, abiStruct, abi); action.HexData = (string)ReadString(data, ref readIndex); return(action); }
public object DeserializeActionData(Api.v1.Action action, Abi abi) { var data = SerializationHelper.HexStringToByteArray((string)action.Data); var abiAction = abi.Actions.First(aa => aa.Name == action.Name); var abiStruct = abi.Structs.First(s => s.Name == abiAction.Type); int readIndex = 0; return(ReadStruct(data, ref readIndex, abiStruct, abi)); }
public byte[] SerializeActionData(Api.v1.Action action, Abi abi) { using (MemoryStream ms = new MemoryStream()) { var abiAction = abi.Actions.First(aa => aa.Name == action.Name); var abiStruct = abi.Structs.First(s => s.Name == abiAction.Type); WriteAbiStruct(ms, action.Data, abiStruct, abi); return(ms.ToArray()); } }
private void WriteAction(MemoryStream ms, Api.v1.Action action, Abi abi) { WriteName(ms, action.Account); WriteName(ms, action.Name); WriteVarUint32(ms, (UInt32)action.Authorization.Count); foreach (var perm in action.Authorization) { WritePermissionLevel(ms, perm); } WriteBytes(ms, SerializeActionData(action, abi)); }
private object ReadAction(byte[] data, ref Int32 readIndex, Api.v1.Action action, Abi abi) { if (action == null) { throw new ArgumentNullException("action"); } var size = (int)ReadVarUint32(data, ref readIndex); action.Authorization = new List <PermissionLevel>(size); for (var i = 0; i < size; i++) { action.Authorization.Add((PermissionLevel)ReadPermissionLevel(data, ref readIndex)); } action.Data = DeserializeActionData(action, abi); return(action); }