You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
require.using("Avatar Owner must always sign the newly created Avatar.", signers.contains(avatar.getOwner().getOwningKey()));
36
+
37
+
returnnull;
38
+
});
39
+
} elseif (valueinstanceofCommands.Transfer) {
40
+
requireThat(require -> {
41
+
require.using("There should be 2 inputs.", tx.getInputs().size() == 2);
42
+
require.using("There must be 1 expiry as an input.", tx.inputsOfType(Expiry.class).size() == 1);
43
+
require.using("There must be 1 avatar as an input", tx.inputsOfType(Avatar.class).size() == 1);
44
+
45
+
require.using("There should be two output states", tx.getInputs().size() == 2);
46
+
require.using("There should be 1 expiry state.", tx.outputsOfType(Expiry.class).size() == 1);
47
+
require.using("There shoule be 1 Avatar created.", tx.outputsOfType(Avatar.class).size() == 1);
48
+
49
+
AvatarnewAvatar = tx.outputsOfType(Avatar.class).stream().findFirst().orElseThrow(() -> newIllegalArgumentException("No Avatar created for transferring."));
50
+
AvataroldAvatar = tx.inputsOfType(Avatar.class).stream().findFirst().orElseThrow(() -> newIllegalArgumentException("Existing Avatar to transfer not found."));
51
+
52
+
require.using("New and old Avatar must just have the owners changed.", newAvatar.equals(oldAvatar));
53
+
require.using("New Owner should sign the new Avatar", signers.contains(newAvatar.getOwner().getOwningKey()));
54
+
require.using("Old owner must sign the old Avatar", signers.contains(oldAvatar.getOwner().getOwningKey()));
if (tx.getCommands().stream().anyMatch(e -> e.getValue() instanceofAvatarContract.Commands.Transfer))
21
+
expiry = tx.inputsOfType(Expiry.class).get(0);
22
+
else
23
+
expiry = tx.outputsOfType(Expiry.class).get(0);
24
+
25
+
TimeWindowtimeWindow = tx.getTimeWindow();
26
+
if (timeWindow == null || timeWindow.getUntilTime() == null) {
27
+
thrownewIllegalArgumentException("Make sure you specify the time window for the Avatar transaction.");
28
+
}
29
+
if (timeWindow.getUntilTime().isAfter(expiry.getExpiry())) {
30
+
thrownewIllegalArgumentException("Avatar transfer time has expired! Expiry date & time was: " + LocalDateTime.ofInstant(expiry.getExpiry(), ZoneId.systemDefault()));
0 commit comments