You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
936 B

2 years ago
import "@stdlib/ownable";
import "./messages";
2 years ago
import "./constants";
2 years ago
contract Linker {
index: Int;
master: Address;
2 years ago
owner: Address;
2 years ago
neighbor: Address?;
2 years ago
init(index: Int, owner: Address, master: Address) {
2 years ago
self.index = index;
self.owner = owner;
2 years ago
self.master = master;
2 years ago
}
receive(msg: SetLinkerNeighbor) {
let ctx: Context = context();
require(ctx.sender == self.master, "Invalid sender");
self.neighbor = msg.neighbor;
}
2 years ago
receive(msg: ForwardToWallet) {
let ctx: Context = context();
require(ctx.sender == self.master, "Invalid sender");
send(SendParameters{
to: self.owner,
value: 0,
mode: SendRemainingValue,
body: msg.body
});
}
2 years ago
get fun owner(): Address? {
return self.owner;
}
get fun master(): Address {
return self.master;
}
2 years ago
}