storeObjectRef.js 780 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { StoreObject } from './storeObject';
  2. export class StoreObjectRef extends StoreObject {
  3. constructor (refID, store) {
  4. super(null, null, false);
  5. this.refID = refID;
  6. this.store = store;
  7. }
  8. get isRef () {
  9. return true;
  10. }
  11. get type () {
  12. return this.store.applyStore(this.refID).type;
  13. }
  14. get value () {
  15. return this.store.applyStore(this.refID).value;
  16. }
  17. get number () {
  18. if (this.value instanceof BigNumber) {
  19. return this.value.toNumber();
  20. } else {
  21. return null;
  22. }
  23. }
  24. getRefObj () {
  25. return this.store.applyStore(this.refID);
  26. }
  27. updateRef (stoObj) {
  28. this.store.updateStore(this.refID, stoObj);
  29. }
  30. isCompatible (another) {
  31. return this.store.applyStore(this.refID).isCompatible(another);
  32. }
  33. }