@credenza3/contracts-lib-sui 0.1.8 → 0.1.10

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.
@@ -1525,7 +1525,7 @@ var require_lodash = __commonJS({
1525
1525
  }
1526
1526
  var runInContext = function runInContext2(context) {
1527
1527
  context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
1528
- var Array2 = context.Array, Date = context.Date, Error2 = context.Error, Function2 = context.Function, Math2 = context.Math, Object2 = context.Object, RegExp2 = context.RegExp, String = context.String, TypeError2 = context.TypeError;
1528
+ var Array2 = context.Array, Date2 = context.Date, Error2 = context.Error, Function2 = context.Function, Math2 = context.Math, Object2 = context.Object, RegExp2 = context.RegExp, String = context.String, TypeError2 = context.TypeError;
1529
1529
  var arrayProto = Array2.prototype, funcProto = Function2.prototype, objectProto = Object2.prototype;
1530
1530
  var coreJsData = context["__core-js_shared__"];
1531
1531
  var funcToString = funcProto.toString;
@@ -1550,8 +1550,8 @@ var require_lodash = __commonJS({
1550
1550
  } catch (e) {
1551
1551
  }
1552
1552
  }();
1553
- var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout, ctxNow = Date && Date.now !== root.Date.now && Date.now, ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
1554
- var nativeCeil = Math2.ceil, nativeFloor = Math2.floor, nativeGetSymbols = Object2.getOwnPropertySymbols, nativeIsBuffer = Buffer2 ? Buffer2.isBuffer : undefined2, nativeIsFinite = context.isFinite, nativeJoin = arrayProto.join, nativeKeys = overArg(Object2.keys, Object2), nativeMax = Math2.max, nativeMin = Math2.min, nativeNow = Date.now, nativeParseInt = context.parseInt, nativeRandom = Math2.random, nativeReverse = arrayProto.reverse;
1553
+ var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout, ctxNow = Date2 && Date2.now !== root.Date.now && Date2.now, ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
1554
+ var nativeCeil = Math2.ceil, nativeFloor = Math2.floor, nativeGetSymbols = Object2.getOwnPropertySymbols, nativeIsBuffer = Buffer2 ? Buffer2.isBuffer : undefined2, nativeIsFinite = context.isFinite, nativeJoin = arrayProto.join, nativeKeys = overArg(Object2.keys, Object2), nativeMax = Math2.max, nativeMin = Math2.min, nativeNow = Date2.now, nativeParseInt = context.parseInt, nativeRandom = Math2.random, nativeReverse = arrayProto.reverse;
1555
1555
  var DataView = getNative(context, "DataView"), Map = getNative(context, "Map"), Promise2 = getNative(context, "Promise"), Set = getNative(context, "Set"), WeakMap = getNative(context, "WeakMap"), nativeCreate = getNative(Object2, "create");
1556
1556
  var metaMap = WeakMap && new WeakMap();
1557
1557
  var realNames = {};
@@ -4975,7 +4975,7 @@ var require_lodash = __commonJS({
4975
4975
  function isNull(value) {
4976
4976
  return value === null;
4977
4977
  }
4978
- function isNil(value) {
4978
+ function isNil2(value) {
4979
4979
  return value == null;
4980
4980
  }
4981
4981
  function isNumber(value) {
@@ -6042,7 +6042,7 @@ var require_lodash = __commonJS({
6042
6042
  lodash.isMatchWith = isMatchWith;
6043
6043
  lodash.isNaN = isNaN;
6044
6044
  lodash.isNative = isNative;
6045
- lodash.isNil = isNil;
6045
+ lodash.isNil = isNil2;
6046
6046
  lodash.isNull = isNull;
6047
6047
  lodash.isNumber = isNumber;
6048
6048
  lodash.isObject = isObject;
@@ -6626,6 +6626,27 @@ var CredenzaMembership = class extends CredenzaSuiModule {
6626
6626
  });
6627
6627
  return this.client.signAndExecuteTransaction(tx);
6628
6628
  }
6629
+ async addMembershipWithExpiration(userAddress, metadata, expiresAt) {
6630
+ const tx = new import_transactions3.Transaction();
6631
+ tx.moveCall({
6632
+ target: `${this.client.getPackageId()}::membership::set_membership_with_expiration`,
6633
+ arguments: [
6634
+ tx.object(await this.getMembershipListId()),
6635
+ tx.pure.address(userAddress),
6636
+ tx.pure.string(metadata),
6637
+ tx.pure.u64(expiresAt)
6638
+ ]
6639
+ });
6640
+ return this.client.signAndExecuteTransaction(tx);
6641
+ }
6642
+ async setMembershipExpiration(userAddress, expiresAt) {
6643
+ const tx = new import_transactions3.Transaction();
6644
+ tx.moveCall({
6645
+ target: `${this.client.getPackageId()}::membership::set_membership_expiration`,
6646
+ arguments: [tx.object(await this.getMembershipListId()), tx.pure.address(userAddress), tx.pure.u64(expiresAt)]
6647
+ });
6648
+ return this.client.signAndExecuteTransaction(tx);
6649
+ }
6629
6650
  async removeMembership(userAddress) {
6630
6651
  const tx = new import_transactions3.Transaction();
6631
6652
  tx.moveCall({
@@ -6654,7 +6675,34 @@ var CredenzaMembership = class extends CredenzaSuiModule {
6654
6675
  }
6655
6676
  });
6656
6677
  const meta = field?.data?.content?.fields?.value;
6657
- return meta ?? null;
6678
+ if ((0, import_lodash.isNil)(meta)) {
6679
+ return null;
6680
+ }
6681
+ const expiresAt = await this.getMembershipExpiration(userAddress);
6682
+ if (!(0, import_lodash.isNil)(expiresAt) && expiresAt > 0 && expiresAt < (/* @__PURE__ */ new Date()).getTime() / 1e3) {
6683
+ return null;
6684
+ }
6685
+ return meta;
6686
+ }
6687
+ async getMembershipExpiration(userAddress) {
6688
+ const membershipListId = await this.getMembershipListId();
6689
+ const res = await this.client.suiClient.getObject({
6690
+ id: membershipListId,
6691
+ options: { showContent: true }
6692
+ });
6693
+ try {
6694
+ const field = await this.client.suiClient.getDynamicFieldObject({
6695
+ parentId: res?.data?.content?.fields.expirations.fields.id.id,
6696
+ name: {
6697
+ value: userAddress,
6698
+ type: "address"
6699
+ }
6700
+ });
6701
+ const expiresAt = field?.data?.content?.fields?.value;
6702
+ return expiresAt ?? null;
6703
+ } catch {
6704
+ return null;
6705
+ }
6658
6706
  }
6659
6707
  async setPriceCoin(price, coinType) {
6660
6708
  const sellConfig = await this.client.getEventData(