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.
|
|
|
// Pseudo staking contract for the tests
|
|
|
|
import "./messages";
|
|
|
|
|
|
|
|
contract PseudoStaking {
|
|
|
|
stakes: map[Address]Int;
|
|
|
|
init() {}
|
|
|
|
|
|
|
|
receive("Deposit") {
|
|
|
|
let ctx: Context = context();
|
|
|
|
let sender: Address = ctx.sender;
|
|
|
|
let ex_stake: Int? = self.stakes.get(sender);
|
|
|
|
if (ex_stake == null) {
|
|
|
|
ex_stake = 0;
|
|
|
|
}
|
|
|
|
self.stakes.set(sender, ex_stake!! + ctx.value);
|
|
|
|
}
|
|
|
|
|
|
|
|
receive(msg: StakingWithdraw) {
|
|
|
|
let ctx: Context = context();
|
|
|
|
send(SendParameters {
|
|
|
|
value: msg.value,
|
|
|
|
to: ctx.sender
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
receive(msg: Slice) {
|
|
|
|
let op: Int = msg.loadUint(32);
|
|
|
|
if (op == 0x7bcd1fef) {
|
|
|
|
let ctx: Context = context();
|
|
|
|
let sender: Address = ctx.sender;
|
|
|
|
let ex_stake: Int? = self.stakes.get(sender);
|
|
|
|
if (ex_stake == null) {
|
|
|
|
ex_stake = 0;
|
|
|
|
}
|
|
|
|
self.stakes.set(sender, ex_stake!! + ctx.value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|