-
Notifications
You must be signed in to change notification settings - Fork 169
/
index.rsh
53 lines (44 loc) · 1.38 KB
/
index.rsh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
'reach 0.1';
'use strict';
export const main =
Reach.App(() => {
const Creator = Participant('Creator', {
getId: Fun([], UInt) });
const Owner = ParticipantClass('Owner', {
newOwner: Fun([], Address),
showOwner: Fun([UInt, Address], Null) });
const vNFT = View('NFT', {
owner: Address });
init();
Creator.only(() => {
const id = declassify(interact.getId()); });
Creator.publish(id);
var owner = Creator;
{ vNFT.owner.set(owner); };
invariant(balance() == 0);
while ( true ) {
commit();
Owner.only(() => {
interact.showOwner(id, owner);
const amOwner = this == owner;
const newOwner =
amOwner ? declassify(interact.newOwner()) : this; });
Owner.publish(newOwner)
.when(amOwner)
.timeout(false);
require(this == owner);
// We could add a pay above and transfer(fee).to(Creator) below to
// implement a basic royalty.
//
// Rather than the owner just doing a transfer, we could have the owner
// start an auction, and encode the logic of the auction here and the
// creator could get a cut.
//
// We could change from a straight transfer to the creator and instead
// manage a royalty fund with its own shares
owner = newOwner;
continue;
}
commit();
assert(false);
});