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.
|
|
|
import "@stdlib/ownable";
|
|
|
|
import "./messages";
|
|
|
|
import "./constants";
|
|
|
|
|
|
|
|
|
|
|
|
contract Linker {
|
|
|
|
index: Int;
|
|
|
|
master: Address;
|
|
|
|
owner: Address;
|
|
|
|
neighbor: Address?;
|
|
|
|
|
|
|
|
init(index: Int, owner: Address, master: Address) {
|
|
|
|
self.index = index;
|
|
|
|
self.owner = owner;
|
|
|
|
self.master = master;
|
|
|
|
}
|
|
|
|
|
|
|
|
receive(msg: SetLinkerNeighbor) {
|
|
|
|
let ctx: Context = context();
|
|
|
|
require(ctx.sender == self.master, "Invalid sender");
|
|
|
|
self.neighbor = msg.neighbor;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
get fun owner(): Address? {
|
|
|
|
return self.owner;
|
|
|
|
}
|
|
|
|
|
|
|
|
get fun master(): Address {
|
|
|
|
return self.master;
|
|
|
|
}
|
|
|
|
}
|