public static AccountState FromBytes(byte[] bytes) { var cursor = new CursorBuffer(bytes); var authenticationKeyLen = cursor.Read32(); var authenticationKey = cursor.ReadXBytes((int)authenticationKeyLen); var balance = cursor.Read64(); var delegatedKeyRotationCapability = cursor.ReadBool(); var delegatedWithdrawalCapability = cursor.ReadBool(); var receivedEventsCount = cursor.Read32(); cursor.Read32(); // skip struct attribute sequence number var receivedEventsKeyLen = cursor.Read32(); var receivedEventsKey = cursor.ReadXBytes((int)receivedEventsKeyLen); var sentEventsCount = cursor.Read32(); cursor.Read32(); // skip struct attribute sequence number var sentEventsKeyLen = cursor.Read32(); var sentEventsKey = cursor.ReadXBytes((int)sentEventsKeyLen); var sequenceNumber = cursor.Read64(); var receivedEvents = new EventHandle(receivedEventsKey, receivedEventsCount); var sentEvents = new EventHandle(sentEventsKey, sentEventsCount); return(new AccountState(authenticationKey, balance, receivedEvents, sentEvents, sequenceNumber, delegatedWithdrawalCapability, delegatedKeyRotationCapability)); }
public void ReadBool2() { var bytes = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; var cursor = new CursorBuffer(bytes); var actual = cursor.ReadBool(); actual = cursor.ReadBool(); var expected = true; Assert.Equal(actual, expected); }
public static AccountState FromBytes(byte[] bytes) { var cursor = new CursorBuffer(bytes); var authenticationKeyLen = cursor.Read32(); var authenticationKey = cursor.ReadXBytes((int)authenticationKeyLen); var balance = cursor.Read64(); var delegatedWithdrawalCapability = cursor.ReadBool(); var receivedEventsCount = cursor.Read64(); var sentEventsCount = cursor.Read64(); var sequenceNumber = cursor.Read64(); return(new AccountState(authenticationKey, balance, receivedEventsCount, sentEventsCount, sequenceNumber, delegatedWithdrawalCapability)); }