@niftykit/redeemable 0.1.0 → 0.2.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 NiftyKit Inc. (niftykit.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -76,9 +76,9 @@ var Redeemable = /** @class */ (function () {
76
76
  }
77
77
  this.version = resp.data.version;
78
78
  this.contract =
79
- this.version === 1
80
- ? contracts_1.TokenCollection__factory.connect(contractAddress, signerOrProvider)
81
- : contracts_1.TokenCollection__factoryV2.connect(contractAddress, signerOrProvider);
79
+ this.version > 1
80
+ ? contracts_1.TokenCollection__factoryV2.connect(contractAddress, signerOrProvider)
81
+ : contracts_1.TokenCollection__factory.connect(contractAddress, signerOrProvider);
82
82
  if (!this.contract) {
83
83
  throw new Error('Initialization failed.');
84
84
  }
@@ -108,12 +108,12 @@ var Redeemable = /** @class */ (function () {
108
108
  return __generator(this, function (_b) {
109
109
  switch (_b.label) {
110
110
  case 0:
111
- if (!(this.version === 1)) return [3 /*break*/, 2];
112
- return [4 /*yield*/, this.contract.redeemableByIndex(tokenId)];
111
+ if (!(this.version > 1)) return [3 /*break*/, 2];
112
+ return [4 /*yield*/, this.contract.redeemableAt(tokenId)];
113
113
  case 1:
114
114
  _a = _b.sent();
115
115
  return [3 /*break*/, 4];
116
- case 2: return [4 /*yield*/, this.contract.redeemableAt(tokenId)];
116
+ case 2: return [4 /*yield*/, this.contract.redeemableByIndex(tokenId)];
117
117
  case 3:
118
118
  _a = _b.sent();
119
119
  _b.label = 4;
@@ -143,10 +143,15 @@ var Redeemable = /** @class */ (function () {
143
143
  case 0: return [4 /*yield*/, this.getRedeemable(tokenId)];
144
144
  case 1:
145
145
  nft = _a.sent();
146
- return [4 /*yield*/, this.contract['redeem(uint256,uint256,bytes)'](nft.index, quantity, signature, {
146
+ if (!(this.version > 1)) return [3 /*break*/, 3];
147
+ return [4 /*yield*/, this.contract.redeem(nft.index, quantity, signature, [], {
147
148
  value: nft.price.mul(quantity),
148
149
  })];
149
150
  case 2: return [2 /*return*/, _a.sent()];
151
+ case 3: return [4 /*yield*/, this.contract['redeem(uint256,uint256,bytes)'](nft.index, quantity, signature, {
152
+ value: nft.price.mul(quantity),
153
+ })];
154
+ case 4: return [2 /*return*/, _a.sent()];
150
155
  }
151
156
  });
152
157
  });
@@ -159,23 +164,21 @@ var Redeemable = /** @class */ (function () {
159
164
  case 0: return [4 /*yield*/, this.getRedeemable(tokenId)];
160
165
  case 1:
161
166
  nft = _a.sent();
162
- return [4 /*yield*/, this.contract['redeem(uint256,uint256,bytes,bytes32[])'](nft.index, quantity, signature, proof, {
167
+ if (!(this.version > 1)) return [3 /*break*/, 3];
168
+ return [4 /*yield*/, this.contract.redeem(nft.index, quantity, signature, proof, {
163
169
  value: nft.price.mul(quantity),
164
170
  })];
165
171
  case 2: return [2 /*return*/, _a.sent()];
172
+ case 3: return [4 /*yield*/, this.contract['redeem(uint256,uint256,bytes,bytes32[])'](nft.index, quantity, signature, proof, {
173
+ value: nft.price.mul(quantity),
174
+ })];
175
+ case 4: return [2 /*return*/, _a.sent()];
166
176
  }
167
177
  });
168
178
  });
169
179
  };
170
180
  Redeemable.prototype.burn = function (tokenId) {
171
- return __awaiter(this, void 0, void 0, function () {
172
- return __generator(this, function (_a) {
173
- switch (_a.label) {
174
- case 0: return [4 /*yield*/, this.contract.burn(tokenId)];
175
- case 1: return [2 /*return*/, _a.sent()];
176
- }
177
- });
178
- });
181
+ return this.contract.burn(tokenId);
179
182
  };
180
183
  return Redeemable;
181
184
  }());
@@ -71,9 +71,9 @@ var Redeemable = /** @class */ (function () {
71
71
  }
72
72
  this.version = resp.data.version;
73
73
  this.contract =
74
- this.version === 1
75
- ? TokenCollection__factory.connect(contractAddress, signerOrProvider)
76
- : TokenCollection__factoryV2.connect(contractAddress, signerOrProvider);
74
+ this.version > 1
75
+ ? TokenCollection__factoryV2.connect(contractAddress, signerOrProvider)
76
+ : TokenCollection__factory.connect(contractAddress, signerOrProvider);
77
77
  if (!this.contract) {
78
78
  throw new Error('Initialization failed.');
79
79
  }
@@ -103,12 +103,12 @@ var Redeemable = /** @class */ (function () {
103
103
  return __generator(this, function (_b) {
104
104
  switch (_b.label) {
105
105
  case 0:
106
- if (!(this.version === 1)) return [3 /*break*/, 2];
107
- return [4 /*yield*/, this.contract.redeemableByIndex(tokenId)];
106
+ if (!(this.version > 1)) return [3 /*break*/, 2];
107
+ return [4 /*yield*/, this.contract.redeemableAt(tokenId)];
108
108
  case 1:
109
109
  _a = _b.sent();
110
110
  return [3 /*break*/, 4];
111
- case 2: return [4 /*yield*/, this.contract.redeemableAt(tokenId)];
111
+ case 2: return [4 /*yield*/, this.contract.redeemableByIndex(tokenId)];
112
112
  case 3:
113
113
  _a = _b.sent();
114
114
  _b.label = 4;
@@ -138,10 +138,15 @@ var Redeemable = /** @class */ (function () {
138
138
  case 0: return [4 /*yield*/, this.getRedeemable(tokenId)];
139
139
  case 1:
140
140
  nft = _a.sent();
141
- return [4 /*yield*/, this.contract['redeem(uint256,uint256,bytes)'](nft.index, quantity, signature, {
141
+ if (!(this.version > 1)) return [3 /*break*/, 3];
142
+ return [4 /*yield*/, this.contract.redeem(nft.index, quantity, signature, [], {
142
143
  value: nft.price.mul(quantity),
143
144
  })];
144
145
  case 2: return [2 /*return*/, _a.sent()];
146
+ case 3: return [4 /*yield*/, this.contract['redeem(uint256,uint256,bytes)'](nft.index, quantity, signature, {
147
+ value: nft.price.mul(quantity),
148
+ })];
149
+ case 4: return [2 /*return*/, _a.sent()];
145
150
  }
146
151
  });
147
152
  });
@@ -154,23 +159,21 @@ var Redeemable = /** @class */ (function () {
154
159
  case 0: return [4 /*yield*/, this.getRedeemable(tokenId)];
155
160
  case 1:
156
161
  nft = _a.sent();
157
- return [4 /*yield*/, this.contract['redeem(uint256,uint256,bytes,bytes32[])'](nft.index, quantity, signature, proof, {
162
+ if (!(this.version > 1)) return [3 /*break*/, 3];
163
+ return [4 /*yield*/, this.contract.redeem(nft.index, quantity, signature, proof, {
158
164
  value: nft.price.mul(quantity),
159
165
  })];
160
166
  case 2: return [2 /*return*/, _a.sent()];
167
+ case 3: return [4 /*yield*/, this.contract['redeem(uint256,uint256,bytes,bytes32[])'](nft.index, quantity, signature, proof, {
168
+ value: nft.price.mul(quantity),
169
+ })];
170
+ case 4: return [2 /*return*/, _a.sent()];
161
171
  }
162
172
  });
163
173
  });
164
174
  };
165
175
  Redeemable.prototype.burn = function (tokenId) {
166
- return __awaiter(this, void 0, void 0, function () {
167
- return __generator(this, function (_a) {
168
- switch (_a.label) {
169
- case 0: return [4 /*yield*/, this.contract.burn(tokenId)];
170
- case 1: return [2 /*return*/, _a.sent()];
171
- }
172
- });
173
- });
176
+ return this.contract.burn(tokenId);
174
177
  };
175
178
  return Redeemable;
176
179
  }());