mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
`get` keyword behaves exactly like `method_id` (auto-calc hash), but it's placed on the left, similar to Tact: `get T name()`. `method_id(n)` is still valid, considering it can't be invoked by name, since a client will compute another hash. It's supposed it will be still used in tests and in low-level code (not to be called externally, but to be called after replacing c3). `get(hash)` is invalid, this keyword does not accept anything.
125 lines
3.1 KiB
Text
125 lines
3.1 KiB
Text
;;
|
|
;; Related contracts
|
|
;;
|
|
|
|
get _ get_proxy() {
|
|
load_base_data();
|
|
return ctx_proxy;
|
|
}
|
|
|
|
get _ get_owner() {
|
|
load_base_data();
|
|
return ctx_owner;
|
|
}
|
|
|
|
get _ get_controller() {
|
|
load_base_data();
|
|
return ctx_controller;
|
|
}
|
|
|
|
;;
|
|
;; Balances for controller
|
|
;;
|
|
|
|
get _ get_unowned() {
|
|
load_base_data();
|
|
var [balance, extra] = get_balance();
|
|
return max(balance - owned_balance(), 0);
|
|
}
|
|
|
|
get _ get_available() {
|
|
load_base_data();
|
|
return ctx_balance - ctx_balance_sent;
|
|
}
|
|
|
|
;;
|
|
;; Pool and staking status
|
|
;;
|
|
|
|
get _ get_staking_status() {
|
|
load_base_data();
|
|
load_validator_data();
|
|
|
|
var querySent = proxy_stored_query_id != 0;
|
|
var unlocked = (proxy_stake_until == 0) | (proxy_stake_until < now());
|
|
var until_val = proxy_stake_until;
|
|
if ((proxy_stake_at != 0) & (proxy_stake_until != 0)) {
|
|
until_val = lockup_lift_time(proxy_stake_at, proxy_stake_until);
|
|
unlocked = unlocked & (until_val < now());
|
|
}
|
|
return (proxy_stake_at, until_val, proxy_stake_sent, querySent, unlocked, ctx_locked);
|
|
}
|
|
|
|
get _ get_pool_status() {
|
|
load_base_data();
|
|
load_member(owner_id());
|
|
return (ctx_balance, ctx_balance_sent, ctx_balance_pending_deposits, ctx_balance_pending_withdraw, ctx_balance_withdraw);
|
|
}
|
|
|
|
;;
|
|
;; Params
|
|
;;
|
|
get _ get_params() {
|
|
load_base_data();
|
|
var (enabled, udpates_enabled, min_stake, deposit_fee, withdraw_fee, pool_fee, receipt_price) = ctx_extras;
|
|
return (enabled, udpates_enabled, min_stake, deposit_fee, withdraw_fee, pool_fee, receipt_price);
|
|
}
|
|
|
|
;;
|
|
;; Members
|
|
;;
|
|
|
|
get _ get_member_balance(slice address) {
|
|
load_base_data();
|
|
load_member(parse_work_addr(address));
|
|
|
|
member_update_balance();
|
|
return (ctx_member_balance, ctx_member_pending_deposit, ctx_member_pending_withdraw, ctx_member_withdraw);
|
|
}
|
|
|
|
get _ get_members_raw() {
|
|
load_base_data();
|
|
return ctx_nominators;
|
|
}
|
|
|
|
get _ get_members() {
|
|
load_base_data();
|
|
|
|
;; Init with owner
|
|
load_member(owner_id());
|
|
member_update_balance();
|
|
var list = nil;
|
|
list = cons([ctx_owner, ctx_member_balance, ctx_member_pending_deposit, ctx_member_pending_withdraw, ctx_member_withdraw], list);
|
|
|
|
;; Iterate all members
|
|
var id = -1;
|
|
do {
|
|
(id, var cs, var f) = ctx_nominators.udict_get_next?(256, id);
|
|
|
|
;; NOTE: One line condition doesn't work
|
|
if (f) {
|
|
if (id != owner_id()) {
|
|
;; For some reason loading member from slice doesn't work
|
|
load_member(id);
|
|
member_update_balance();
|
|
list = cons([serialize_work_addr(id), ctx_member_balance, ctx_member_pending_deposit, ctx_member_pending_withdraw, ctx_member_withdraw], list);
|
|
}
|
|
}
|
|
} until (~ f);
|
|
|
|
return list;
|
|
}
|
|
|
|
get _ get_member(slice address) {
|
|
load_base_data();
|
|
load_member(parse_work_addr(address));
|
|
member_update_balance();
|
|
return (ctx_member_balance, ctx_member_pending_deposit, ctx_member_pending_withdraw, ctx_member_withdraw);
|
|
}
|
|
|
|
get _ supported_interfaces() {
|
|
return (
|
|
123515602279859691144772641439386770278, ;; org.ton.introspection.v0
|
|
256184278959413194623484780286929323492 ;; com.tonwhales.nominators:v0
|
|
);
|
|
}
|