diff --git a/ol/cli/src/check/items.rs b/ol/cli/src/check/items.rs index de7ee7ac04..3dcf24617d 100644 --- a/ol/cli/src/check/items.rs +++ b/ol/cli/src/check/items.rs @@ -32,6 +32,8 @@ pub struct Items { pub sync_delay: i64, /// is in the validator set pub validator_set: bool, + /// has auto pay not empty + pub has_auto_pay: bool, } impl Default for Items { @@ -49,6 +51,7 @@ impl Default for Items { db_files_exist: false, web_running: false, node_mode: None, + has_auto_pay: false, } } } diff --git a/ol/cli/src/node/account.rs b/ol/cli/src/node/account.rs index dabd54a6d4..f48db4fe21 100644 --- a/ol/cli/src/node/account.rs +++ b/ol/cli/src/node/account.rs @@ -7,6 +7,8 @@ use libra_types::{account_state::AccountState, transaction::Version}; use resource_viewer::{AnnotatedAccountStateBlob, MoveValueAnnotator, NullStateView}; use serde::{Deserialize, Serialize}; use std::convert::TryFrom; +use ol_types::autopay::{AutoPayResource, AutoPayView}; + #[derive(Clone, Debug, Deserialize, Serialize)] /// information on the owner account of this node. pub struct OwnerAccountView { @@ -16,6 +18,8 @@ pub struct OwnerAccountView { balance: u64, /// if is jailed is_in_validator_set: bool, + /// auto pay + auto_pay: Option, } impl OwnerAccountView { @@ -25,6 +29,15 @@ impl OwnerAccountView { address, balance: 0, is_in_validator_set: false, + auto_pay: None, + } + } + + /// query if account has auto pay settings, and not empty + pub fn has_auto_pay_not_empty(&self) -> bool { + match &self.auto_pay { + Some(auto_pay) => auto_pay.payments.len() > 0, + None => false } } } @@ -36,7 +49,7 @@ impl Node { Some(av) => { self.vitals.account_view.balance = get_balance(av); self.vitals.account_view.is_in_validator_set = self.is_in_validator_set(); - + self.vitals.account_view.auto_pay = self.get_auto_pay_view(self.vitals.account_view.address); Some(&self.vitals.account_view) } None => None @@ -52,6 +65,21 @@ impl Node { } } + /// Get account auto pay resource + pub fn get_auto_pay_view(&mut self, account: AccountAddress) -> Option { + let state = self.get_account_state(account); + match state { + Ok(state) => match state.get_resource::( + AutoPayResource::resource_path().as_slice() + ) { + Ok(Some(res)) => Some(res.get_view()), + Ok(None) => None, + Err(_) => None + } + Err(_) => None + } + } + /// Return a full Move-annotated account resource struct pub fn get_annotate_account_blob( &mut self, diff --git a/ol/cli/src/node/node.rs b/ol/cli/src/node/node.rs index 6ca361ec91..c27bc7e25a 100644 --- a/ol/cli/src/node/node.rs +++ b/ol/cli/src/node/node.rs @@ -104,6 +104,7 @@ impl Node { self.vitals.items.sync_height = 404; } self.vitals.items.validator_set = self.is_in_validator_set(); + self.vitals.items.has_auto_pay = self.vitals.account_view.has_auto_pay_not_empty(); self } diff --git a/ol/cli/web-monitor/public/build/bundle.js b/ol/cli/web-monitor/public/build/bundle.js index d48b7eae06..96ee49726c 100644 --- a/ol/cli/web-monitor/public/build/bundle.js +++ b/ol/cli/web-monitor/public/build/bundle.js @@ -1,5 +1,742 @@ -var app=function(){"use strict";function t(){}function n(t){return t()}function r(){return Object.create(null)}function e(t){t.forEach(n)}function u(t){return"function"==typeof t}function i(t,n){return t!=t?n==n:t!==n||t&&"object"==typeof t||"function"==typeof t}function o(t,n){t.appendChild(n)}function c(t,n,r){t.insertBefore(n,r||null)}function a(t){t.parentNode.removeChild(t)}function f(t,n){for(let r=0;rt.removeEventListener(n,r,e)}function v(t,n,r){null==r?t.removeAttribute(n):t.getAttribute(n)!==r&&t.setAttribute(n,r)}function _(t,n){n=""+n,t.wholeText!==n&&(t.data=n)}let g;function y(t){g=t}const m=[],b=[],w=[],x=[],k=Promise.resolve();let $=!1;function j(t){w.push(t)}let A=!1;const E=new Set;function O(){if(!A){A=!0;do{for(let t=0;t{C.delete(t),e&&(r&&t.d(1),e())})),t.o(n)}}function W(t){t&&t.c()}function N(t,r,i,o){const{fragment:c,on_mount:a,on_destroy:f,after_update:l}=t.$$;c&&c.m(r,i),o||j((()=>{const r=a.map(n).filter(u);f?f.push(...r):e(r),t.$$.on_mount=[]})),l.forEach(j)}function B(t,n){const r=t.$$;null!==r.fragment&&(e(r.on_destroy),r.fragment&&r.fragment.d(n),r.on_destroy=r.fragment=null,r.ctx=[])}function U(t,n){-1===t.$$.dirty[0]&&(m.push(t),$||($=!0,k.then(O)),t.$$.dirty.fill(0)),t.$$.dirty[n/31|0]|=1<{const u=e.length?e[0]:r;return h.ctx&&c(h.ctx[t],h.ctx[t]=u)&&(!h.skip_bound&&h.bound[t]&&h.bound[t](u),p&&U(n,t)),r})):[],h.update(),p=!0,e(h.before_update),h.fragment=!!o&&o(h.ctx),u.target){if(u.hydrate){const t=function(t){return Array.from(t.childNodes)}(u.target);h.fragment&&h.fragment.l(t),t.forEach(a)}else h.fragment&&h.fragment.c();u.intro&&L(n.$$.fragment),N(n,u.target,u.anchor,u.customElement),O()}y(s)}class M{$destroy(){B(this,1),this.$destroy=t}$on(t,n){const r=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return r.push(n),()=>{const t=r.indexOf(n);-1!==t&&r.splice(t,1)}}$set(t){var n;this.$$set&&(n=t,0!==Object.keys(n).length)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function P(n){let r;return{c(){r=l("main"),r.innerHTML=''},m(t,n){c(t,r,n)},p:t,i:t,o:t,d(t){t&&a(r)}}}class F extends M{constructor(t){super(),D(this,t,null,P,i,{})}}function q(t){let n;return{c(){n=l("span"),v(n,"class","uk-margin-small-right uk-text-warning"),v(n,"uk-icon","icon: warning; ratio: 1")},m(t,r){c(t,n,r)},d(t){t&&a(n)}}}function K(t){let n;return{c(){n=l("span"),v(n,"class","uk-margin-small-right uk-text-success"),v(n,"uk-icon","icon: check; ratio: 1")},m(t,r){c(t,n,r)},d(t){t&&a(n)}}}function V(n){let r,e,u,i,f,p,d,g;function y(t,n){return t[0]?K:q}let m=y(n),b=m(n);return{c(){r=l("div"),e=l("dt"),b.c(),u=h(),i=l("span"),f=s(n[1]),p=h(),d=l("dd"),g=s(n[2]),v(i,"class","uk-text-uppercase")},m(t,n){c(t,r,n),o(r,e),b.m(e,null),o(e,u),o(e,i),o(i,f),o(r,p),o(r,d),o(d,g)},p(t,[n]){m!==(m=y(t))&&(b.d(1),b=m(t),b&&(b.c(),b.m(e,u))),2&n&&_(f,t[1]),4&n&&_(g,t[2])},i:t,o:t,d(t){t&&a(r),b.d()}}}function Z(t,n,r){let{isTrue:e=!0}=n,{title:u}=n,{description:i}=n;return t.$$set=t=>{"isTrue"in t&&r(0,e=t.isTrue),"title"in t&&r(1,u=t.title),"description"in t&&r(2,i=t.description)},[e,u,i]}class H extends M{constructor(t){super(),D(this,t,Z,V,i,{isTrue:0,title:1,description:2})}}var J="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{}; -/** +var app = (function () { + 'use strict'; + + function noop() { } + function add_location(element, file, line, column, char) { + element.__svelte_meta = { + loc: { file, line, column, char } + }; + } + function run(fn) { + return fn(); + } + function blank_object() { + return Object.create(null); + } + function run_all(fns) { + fns.forEach(run); + } + function is_function(thing) { + return typeof thing === 'function'; + } + function safe_not_equal(a, b) { + return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); + } + function is_empty(obj) { + return Object.keys(obj).length === 0; + } + + function append(target, node) { + target.appendChild(node); + } + function insert(target, node, anchor) { + target.insertBefore(node, anchor || null); + } + function detach(node) { + node.parentNode.removeChild(node); + } + function destroy_each(iterations, detaching) { + for (let i = 0; i < iterations.length; i += 1) { + if (iterations[i]) + iterations[i].d(detaching); + } + } + function element(name) { + return document.createElement(name); + } + function text(data) { + return document.createTextNode(data); + } + function space() { + return text(' '); + } + function empty() { + return text(''); + } + function listen(node, event, handler, options) { + node.addEventListener(event, handler, options); + return () => node.removeEventListener(event, handler, options); + } + function attr(node, attribute, value) { + if (value == null) + node.removeAttribute(attribute); + else if (node.getAttribute(attribute) !== value) + node.setAttribute(attribute, value); + } + function children(element) { + return Array.from(element.childNodes); + } + function custom_event(type, detail) { + const e = document.createEvent('CustomEvent'); + e.initCustomEvent(type, false, false, detail); + return e; + } + + let current_component; + function set_current_component(component) { + current_component = component; + } + + const dirty_components = []; + const binding_callbacks = []; + const render_callbacks = []; + const flush_callbacks = []; + const resolved_promise = Promise.resolve(); + let update_scheduled = false; + function schedule_update() { + if (!update_scheduled) { + update_scheduled = true; + resolved_promise.then(flush); + } + } + function add_render_callback(fn) { + render_callbacks.push(fn); + } + let flushing = false; + const seen_callbacks = new Set(); + function flush() { + if (flushing) + return; + flushing = true; + do { + // first, call beforeUpdate functions + // and update components + for (let i = 0; i < dirty_components.length; i += 1) { + const component = dirty_components[i]; + set_current_component(component); + update(component.$$); + } + set_current_component(null); + dirty_components.length = 0; + while (binding_callbacks.length) + binding_callbacks.pop()(); + // then, once components are updated, call + // afterUpdate functions. This may cause + // subsequent updates... + for (let i = 0; i < render_callbacks.length; i += 1) { + const callback = render_callbacks[i]; + if (!seen_callbacks.has(callback)) { + // ...so guard against infinite loops + seen_callbacks.add(callback); + callback(); + } + } + render_callbacks.length = 0; + } while (dirty_components.length); + while (flush_callbacks.length) { + flush_callbacks.pop()(); + } + update_scheduled = false; + flushing = false; + seen_callbacks.clear(); + } + function update($$) { + if ($$.fragment !== null) { + $$.update(); + run_all($$.before_update); + const dirty = $$.dirty; + $$.dirty = [-1]; + $$.fragment && $$.fragment.p($$.ctx, dirty); + $$.after_update.forEach(add_render_callback); + } + } + const outroing = new Set(); + let outros; + function group_outros() { + outros = { + r: 0, + c: [], + p: outros // parent group + }; + } + function check_outros() { + if (!outros.r) { + run_all(outros.c); + } + outros = outros.p; + } + function transition_in(block, local) { + if (block && block.i) { + outroing.delete(block); + block.i(local); + } + } + function transition_out(block, local, detach, callback) { + if (block && block.o) { + if (outroing.has(block)) + return; + outroing.add(block); + outros.c.push(() => { + outroing.delete(block); + if (callback) { + if (detach) + block.d(1); + callback(); + } + }); + block.o(local); + } + } + function create_component(block) { + block && block.c(); + } + function mount_component(component, target, anchor, customElement) { + const { fragment, on_mount, on_destroy, after_update } = component.$$; + fragment && fragment.m(target, anchor); + if (!customElement) { + // onMount happens before the initial afterUpdate + add_render_callback(() => { + const new_on_destroy = on_mount.map(run).filter(is_function); + if (on_destroy) { + on_destroy.push(...new_on_destroy); + } + else { + // Edge case - component was destroyed immediately, + // most likely as a result of a binding initialising + run_all(new_on_destroy); + } + component.$$.on_mount = []; + }); + } + after_update.forEach(add_render_callback); + } + function destroy_component(component, detaching) { + const $$ = component.$$; + if ($$.fragment !== null) { + run_all($$.on_destroy); + $$.fragment && $$.fragment.d(detaching); + // TODO null out other refs, including component.$$ (but need to + // preserve final state?) + $$.on_destroy = $$.fragment = null; + $$.ctx = []; + } + } + function make_dirty(component, i) { + if (component.$$.dirty[0] === -1) { + dirty_components.push(component); + schedule_update(); + component.$$.dirty.fill(0); + } + component.$$.dirty[(i / 31) | 0] |= (1 << (i % 31)); + } + function init(component, options, instance, create_fragment, not_equal, props, dirty = [-1]) { + const parent_component = current_component; + set_current_component(component); + const $$ = component.$$ = { + fragment: null, + ctx: null, + // state + props, + update: noop, + not_equal, + bound: blank_object(), + // lifecycle + on_mount: [], + on_destroy: [], + on_disconnect: [], + before_update: [], + after_update: [], + context: new Map(parent_component ? parent_component.$$.context : options.context || []), + // everything else + callbacks: blank_object(), + dirty, + skip_bound: false + }; + let ready = false; + $$.ctx = instance + ? instance(component, options.props || {}, (i, ret, ...rest) => { + const value = rest.length ? rest[0] : ret; + if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) { + if (!$$.skip_bound && $$.bound[i]) + $$.bound[i](value); + if (ready) + make_dirty(component, i); + } + return ret; + }) + : []; + $$.update(); + ready = true; + run_all($$.before_update); + // `false` as a special case of no DOM component + $$.fragment = create_fragment ? create_fragment($$.ctx) : false; + if (options.target) { + if (options.hydrate) { + const nodes = children(options.target); + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + $$.fragment && $$.fragment.l(nodes); + nodes.forEach(detach); + } + else { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + $$.fragment && $$.fragment.c(); + } + if (options.intro) + transition_in(component.$$.fragment); + mount_component(component, options.target, options.anchor, options.customElement); + flush(); + } + set_current_component(parent_component); + } + /** + * Base class for Svelte components. Used when dev=false. + */ + class SvelteComponent { + $destroy() { + destroy_component(this, 1); + this.$destroy = noop; + } + $on(type, callback) { + const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = [])); + callbacks.push(callback); + return () => { + const index = callbacks.indexOf(callback); + if (index !== -1) + callbacks.splice(index, 1); + }; + } + $set($$props) { + if (this.$$set && !is_empty($$props)) { + this.$$.skip_bound = true; + this.$$set($$props); + this.$$.skip_bound = false; + } + } + } + + function dispatch_dev(type, detail) { + document.dispatchEvent(custom_event(type, Object.assign({ version: '3.37.0' }, detail))); + } + function append_dev(target, node) { + dispatch_dev('SvelteDOMInsert', { target, node }); + append(target, node); + } + function insert_dev(target, node, anchor) { + dispatch_dev('SvelteDOMInsert', { target, node, anchor }); + insert(target, node, anchor); + } + function detach_dev(node) { + dispatch_dev('SvelteDOMRemove', { node }); + detach(node); + } + function listen_dev(node, event, handler, options, has_prevent_default, has_stop_propagation) { + const modifiers = options === true ? ['capture'] : options ? Array.from(Object.keys(options)) : []; + if (has_prevent_default) + modifiers.push('preventDefault'); + if (has_stop_propagation) + modifiers.push('stopPropagation'); + dispatch_dev('SvelteDOMAddEventListener', { node, event, handler, modifiers }); + const dispose = listen(node, event, handler, options); + return () => { + dispatch_dev('SvelteDOMRemoveEventListener', { node, event, handler, modifiers }); + dispose(); + }; + } + function attr_dev(node, attribute, value) { + attr(node, attribute, value); + if (value == null) + dispatch_dev('SvelteDOMRemoveAttribute', { node, attribute }); + else + dispatch_dev('SvelteDOMSetAttribute', { node, attribute, value }); + } + function set_data_dev(text, data) { + data = '' + data; + if (text.wholeText === data) + return; + dispatch_dev('SvelteDOMSetData', { node: text, data }); + text.data = data; + } + function validate_each_argument(arg) { + if (typeof arg !== 'string' && !(arg && typeof arg === 'object' && 'length' in arg)) { + let msg = '{#each} only iterates over array-like objects.'; + if (typeof Symbol === 'function' && arg && Symbol.iterator in arg) { + msg += ' You can use a spread to convert this iterable into an array.'; + } + throw new Error(msg); + } + } + function validate_slots(name, slot, keys) { + for (const slot_key of Object.keys(slot)) { + if (!~keys.indexOf(slot_key)) { + console.warn(`<${name}> received an unexpected slot "${slot_key}".`); + } + } + } + /** + * Base class for Svelte components with some minor dev-enhancements. Used when dev=true. + */ + class SvelteComponentDev extends SvelteComponent { + constructor(options) { + if (!options || (!options.target && !options.$$inline)) { + throw new Error("'target' is a required option"); + } + super(); + } + $destroy() { + super.$destroy(); + this.$destroy = () => { + console.warn('Component was already destroyed'); // eslint-disable-line no-console + }; + } + $capture_state() { } + $inject_state() { } + } + + /* src/components/layout/Nav.svelte generated by Svelte v3.37.0 */ + + const file$c = "src/components/layout/Nav.svelte"; + + function create_fragment$c(ctx) { + let main; + let nav; + let div; + let ul; + let li0; + let a0; + let t1; + let li1; + let a1; + let t3; + let li2; + let a2; + let t5; + let li3; + let a3; + + const block = { + c: function create() { + main = element("main"); + nav = element("nav"); + div = element("div"); + ul = element("ul"); + li0 = element("li"); + a0 = element("a"); + a0.textContent = "Dash"; + t1 = space(); + li1 = element("li"); + a1 = element("a"); + a1.textContent = "Validators"; + t3 = space(); + li2 = element("li"); + a2 = element("a"); + a2.textContent = "Upgrades"; + t5 = space(); + li3 = element("li"); + a3 = element("a"); + a3.textContent = "Autopay"; + attr_dev(a0, "href", "#"); + add_location(a0, file$c, 4, 30, 194); + attr_dev(li0, "class", "uk-active"); + add_location(li0, file$c, 4, 8, 172); + attr_dev(a1, "href", "#"); + add_location(a1, file$c, 5, 12, 232); + add_location(li1, file$c, 5, 8, 228); + attr_dev(a2, "href", "#"); + add_location(a2, file$c, 6, 12, 276); + add_location(li2, file$c, 6, 8, 272); + attr_dev(a3, "href", "#"); + add_location(a3, file$c, 7, 12, 318); + add_location(li3, file$c, 7, 8, 314); + attr_dev(ul, "class", "uk-navbar-nav"); + attr_dev(ul, "uk-switcher", "connect: .switcher-container"); + add_location(ul, file$c, 3, 6, 94); + attr_dev(div, "class", "uk-navbar-center"); + add_location(div, file$c, 2, 4, 57); + attr_dev(nav, "class", "uk-navbar-container"); + attr_dev(nav, "uk-navbar", ""); + add_location(nav, file$c, 1, 2, 9); + add_location(main, file$c, 0, 0, 0); + }, + l: function claim(nodes) { + throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option"); + }, + m: function mount(target, anchor) { + insert_dev(target, main, anchor); + append_dev(main, nav); + append_dev(nav, div); + append_dev(div, ul); + append_dev(ul, li0); + append_dev(li0, a0); + append_dev(ul, t1); + append_dev(ul, li1); + append_dev(li1, a1); + append_dev(ul, t3); + append_dev(ul, li2); + append_dev(li2, a2); + append_dev(ul, t5); + append_dev(ul, li3); + append_dev(li3, a3); + }, + p: noop, + i: noop, + o: noop, + d: function destroy(detaching) { + if (detaching) detach_dev(main); + } + }; + + dispatch_dev("SvelteRegisterBlock", { + block, + id: create_fragment$c.name, + type: "component", + source: "", + ctx + }); + + return block; + } + + function instance$c($$self, $$props) { + let { $$slots: slots = {}, $$scope } = $$props; + validate_slots("Nav", slots, []); + const writable_props = []; + + Object.keys($$props).forEach(key => { + if (!~writable_props.indexOf(key) && key.slice(0, 2) !== "$$") console.warn(`