@credenza3/contracts-lib-sui 0.0.2 → 0.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.
@@ -2838,6 +2838,39 @@ var CredenzaLedger = (function (_super) {
2838
2838
  });
2839
2839
  });
2840
2840
  };
2841
+ CredenzaLedger.prototype.addPointsLifetime = function (userAddress, amount, eventId) {
2842
+ return __awaiter(this, void 0, Promise, function () {
2843
+ var tx, _a, _b, _c, _d, _e, _f, _g;
2844
+ var _h;
2845
+ return __generator(this, function (_j) {
2846
+ switch (_j.label) {
2847
+ case 0:
2848
+ tx = new transactions_1.Transaction();
2849
+ _b = (_a = tx).moveCall;
2850
+ _h = {
2851
+ target: "".concat(this.client.getPackageId(), "::credenza_loyalty::add_points_lifetime")
2852
+ };
2853
+ _d = (_c = tx).object;
2854
+ return [4, this.getTreasuryCap()];
2855
+ case 1:
2856
+ _e = [
2857
+ _d.apply(_c, [_j.sent()])
2858
+ ];
2859
+ _g = (_f = tx).object;
2860
+ return [4, this.getLoyaltyConfig()];
2861
+ case 2:
2862
+ _b.apply(_a, [(_h.arguments = _e.concat([
2863
+ _g.apply(_f, [_j.sent()]),
2864
+ tx.pure.address(userAddress),
2865
+ tx.pure.u64(amount),
2866
+ tx.pure.u64(eventId)
2867
+ ]),
2868
+ _h)]);
2869
+ return [2, this.client.signAndExecuteTransaction(tx)];
2870
+ }
2871
+ });
2872
+ });
2873
+ };
2841
2874
  CredenzaLedger.prototype.redeemPoints = function (token) {
2842
2875
  return __awaiter(this, void 0, Promise, function () {
2843
2876
  var tx, _a, _b, _c, _d;
@@ -3054,6 +3087,36 @@ var CredenzaLedger = (function (_super) {
3054
3087
  });
3055
3088
  });
3056
3089
  };
3090
+ CredenzaLedger.prototype.getLifetimePoints = function (userAddress) {
3091
+ return __awaiter(this, void 0, Promise, function () {
3092
+ var configId, res, field, amount;
3093
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
3094
+ return __generator(this, function (_k) {
3095
+ switch (_k.label) {
3096
+ case 0: return [4, this.getLoyaltyConfig()];
3097
+ case 1:
3098
+ configId = _k.sent();
3099
+ return [4, this.client.suiClient.getObject({
3100
+ id: configId,
3101
+ options: { showContent: true },
3102
+ })];
3103
+ case 2:
3104
+ res = _k.sent();
3105
+ return [4, this.client.suiClient.getDynamicFieldObject({
3106
+ parentId: (_f = (_e = (_d = (_c = (_b = (_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.fields) === null || _c === void 0 ? void 0 : _c.lifetime_points) === null || _d === void 0 ? void 0 : _d.fields) === null || _e === void 0 ? void 0 : _e.id) === null || _f === void 0 ? void 0 : _f.id,
3107
+ name: {
3108
+ value: userAddress,
3109
+ type: 'address',
3110
+ },
3111
+ })];
3112
+ case 3:
3113
+ field = _k.sent();
3114
+ amount = (_j = (_h = (_g = field === null || field === void 0 ? void 0 : field.data) === null || _g === void 0 ? void 0 : _g.content) === null || _h === void 0 ? void 0 : _h.fields) === null || _j === void 0 ? void 0 : _j.value;
3115
+ return [2, amount ? parseInt(amount) : 0];
3116
+ }
3117
+ });
3118
+ });
3119
+ };
3057
3120
  return CredenzaLedger;
3058
3121
  }(CredenzaSuiModule_1.CredenzaSuiModule));
3059
3122
  exports.CredenzaLedger = CredenzaLedger;
@@ -3178,7 +3241,7 @@ var CredenzaMembership = (function (_super) {
3178
3241
  };
3179
3242
  CredenzaMembership.prototype.hasMembership = function (userAddress) {
3180
3243
  return __awaiter(this, void 0, Promise, function () {
3181
- var membershipListId, res, field;
3244
+ var membershipListId, res, field, meta;
3182
3245
  var _a, _b, _c, _d, _e;
3183
3246
  return __generator(this, function (_f) {
3184
3247
  switch (_f.label) {
@@ -3200,7 +3263,8 @@ var CredenzaMembership = (function (_super) {
3200
3263
  })];
3201
3264
  case 3:
3202
3265
  field = _f.sent();
3203
- return [2, ((_e = (_d = (_c = field === null || field === void 0 ? void 0 : field.data) === null || _c === void 0 ? void 0 : _c.content) === null || _d === void 0 ? void 0 : _d.fields) === null || _e === void 0 ? void 0 : _e.value) || null];
3266
+ meta = (_e = (_d = (_c = field === null || field === void 0 ? void 0 : field.data) === null || _c === void 0 ? void 0 : _c.content) === null || _d === void 0 ? void 0 : _d.fields) === null || _e === void 0 ? void 0 : _e.value;
3267
+ return [2, meta !== null && meta !== void 0 ? meta : null];
3204
3268
  }
3205
3269
  });
3206
3270
  });