@naviprotocol/lending 2.0.3 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -129,7 +129,7 @@ const oe = l.bytes(32).transform({
129
129
  borrow_balance: l.u256(),
130
130
  /** User's current supply balance */
131
131
  supply_balance: l.u256()
132
- }), Ge = "2.0.3", E = {
132
+ }), Ge = "2.0.4", E = {
133
133
  version: Ge
134
134
  }, We = E.version, He = () => {
135
135
  if (typeof process < "u" && process.versions && process.versions.node) {
@@ -353,7 +353,7 @@ class lt {
353
353
  }
354
354
  getCoreProvider() {
355
355
  const t = this.provider.core;
356
- return t && typeof t.getObject == "function" && typeof t.getDynamicObjectField == "function" ? t : null;
356
+ return t && typeof t.getObject == "function" && typeof t.getDynamicObjectField == "function" && typeof t.getDynamicField == "function" ? t : null;
357
357
  }
358
358
  async getMoveObjectJson(t) {
359
359
  const r = this.getCoreProvider();
@@ -500,16 +500,25 @@ class lt {
500
500
  async getPriceFeedObjectId(t) {
501
501
  const r = re(t);
502
502
  if (!this.priceFeedObjectIdCache.has(r)) {
503
- const { id: o, fieldType: n } = await this.getPriceTableInfo(), a = this.getCoreProvider() ? se(
504
- `${n}::price_identifier::PriceIdentifier`,
505
- it(ie(r))
506
- ) : {
507
- type: `${n}::price_identifier::PriceIdentifier`,
508
- value: {
509
- bytes: Array.from(ie(r))
510
- }
511
- }, c = await this.getDynamicMoveObjectJson(o, a);
512
- c?.fields ? this.priceFeedObjectIdCache.set(r, c.fields.value) : this.priceFeedObjectIdCache.set(r, void 0);
503
+ const { id: o, fieldType: n } = await this.getPriceTableInfo(), a = `${n}::price_identifier::PriceIdentifier`, c = this.getCoreProvider();
504
+ if (c) {
505
+ const { dynamicField: i } = await c.getDynamicField({
506
+ parentId: o,
507
+ name: se(a, it(ie(r)))
508
+ }), s = i?.value?.bcs;
509
+ this.priceFeedObjectIdCache.set(
510
+ r,
511
+ s && s.length === 32 ? l.Address.parse(Uint8Array.from(s)) : void 0
512
+ );
513
+ } else {
514
+ const i = await this.getDynamicMoveObjectJson(o, {
515
+ type: a,
516
+ value: {
517
+ bytes: Array.from(ie(r))
518
+ }
519
+ });
520
+ i?.fields ? this.priceFeedObjectIdCache.set(r, i.fields.value) : this.priceFeedObjectIdCache.set(r, void 0);
521
+ }
513
522
  }
514
523
  return this.priceFeedObjectIdCache.get(r);
515
524
  }