@arcblock/nft 1.30.23 → 1.30.25
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/esm/factory.mjs +8 -6
- package/lib/factory.cjs +8 -6
- package/package.json +8 -8
package/esm/factory.mjs
CHANGED
|
@@ -58,7 +58,7 @@ var NFTFactory = class {
|
|
|
58
58
|
if (!data[x]) throw new Error(`Missing required field ${x} when creating ticket asset`);
|
|
59
59
|
});
|
|
60
60
|
timeFields.forEach((x) => {
|
|
61
|
-
if (!isDate(new Date(data[x]))) throw new Error(`Invalid date field ${x} when creating ticket asset`);
|
|
61
|
+
if (data[x] === void 0 || data[x] === null || !isDate(new Date(data[x])) || Number.isNaN(new Date(data[x]).getTime())) throw new Error(`Invalid date field ${x} when creating ticket asset`);
|
|
62
62
|
});
|
|
63
63
|
const { name: name$1, description, location, recipient, type, startTime, endTime, display: innerDisplay = "", issuanceDate } = data;
|
|
64
64
|
if (!(recipient instanceof recipient_default)) throw new Error(`Invalid recipient field when creating ${type} asset`);
|
|
@@ -111,7 +111,7 @@ var NFTFactory = class {
|
|
|
111
111
|
if (!data[x] || !isNumber(data[x])) throw new Error(`Invalid number field ${x} when creating coupon asset`);
|
|
112
112
|
});
|
|
113
113
|
timeFields.forEach((x) => {
|
|
114
|
-
if (!isDate(new Date(data[x]))) throw new Error(`Invalid date field ${x} when creating coupon asset`);
|
|
114
|
+
if (data[x] === void 0 || data[x] === null || !isDate(new Date(data[x])) || Number.isNaN(new Date(data[x]).getTime())) throw new Error(`Invalid date field ${x} when creating coupon asset`);
|
|
115
115
|
});
|
|
116
116
|
const { name: name$1, description, ratio, amount, location, minAmount, expireTime, type, recipient, display: innerDisplay = "", issuanceDate, endpoint, endpointScope } = data;
|
|
117
117
|
const vc = await create({
|
|
@@ -225,15 +225,17 @@ var NFTFactory = class {
|
|
|
225
225
|
}
|
|
226
226
|
async createSignedAsset(payload, attributes) {
|
|
227
227
|
payload.signature = toBase58(await this.wallet.sign(stringify(payload)));
|
|
228
|
+
const moniker = get(payload, "data.name") || get(payload, "credentialSubject.name") || "signed_asset";
|
|
229
|
+
const { data: _ignoredData, address: _ignoredAddress, ...safeAttributes } = attributes || {};
|
|
228
230
|
const asset = {
|
|
229
|
-
moniker
|
|
231
|
+
moniker,
|
|
230
232
|
readonly: false,
|
|
231
233
|
transferrable: true,
|
|
234
|
+
...safeAttributes,
|
|
232
235
|
data: {
|
|
233
236
|
typeUrl: "vc",
|
|
234
237
|
value: payload
|
|
235
|
-
}
|
|
236
|
-
...attributes
|
|
238
|
+
}
|
|
237
239
|
};
|
|
238
240
|
asset.address = toAssetAddress(asset, "cbor");
|
|
239
241
|
return [asset, await this.client.sendCreateAssetTx({
|
|
@@ -263,7 +265,7 @@ var NFTFactory = class {
|
|
|
263
265
|
if (!data[x]) throw new Error(`Missing required field ${x} when creating certificate`);
|
|
264
266
|
});
|
|
265
267
|
timeFields.forEach((x) => {
|
|
266
|
-
if (!isDate(new Date(data[x]))) throw new Error(`Invalid date field ${x} when creating certificate`);
|
|
268
|
+
if (data[x] === void 0 || data[x] === null || !isDate(new Date(data[x])) || Number.isNaN(new Date(data[x]).getTime())) throw new Error(`Invalid date field ${x} when creating certificate`);
|
|
267
269
|
});
|
|
268
270
|
if (!(data.recipient instanceof recipient_default)) throw new Error("Invalid recipient field when creating certificate");
|
|
269
271
|
const { name: name$1, description, reason, logoUrl, recipient, type, expireTime, display: innerDisplay = "", issuanceDate, endpoint, endpointScope } = data;
|
package/lib/factory.cjs
CHANGED
|
@@ -67,7 +67,7 @@ var NFTFactory = class {
|
|
|
67
67
|
if (!data[x]) throw new Error(`Missing required field ${x} when creating ticket asset`);
|
|
68
68
|
});
|
|
69
69
|
timeFields.forEach((x) => {
|
|
70
|
-
if (!(0, lodash_isDate.default)(new Date(data[x]))) throw new Error(`Invalid date field ${x} when creating ticket asset`);
|
|
70
|
+
if (data[x] === void 0 || data[x] === null || !(0, lodash_isDate.default)(new Date(data[x])) || Number.isNaN(new Date(data[x]).getTime())) throw new Error(`Invalid date field ${x} when creating ticket asset`);
|
|
71
71
|
});
|
|
72
72
|
const { name: name$1, description, location, recipient, type, startTime, endTime, display: innerDisplay = "", issuanceDate } = data;
|
|
73
73
|
if (!(recipient instanceof require_recipient.default)) throw new Error(`Invalid recipient field when creating ${type} asset`);
|
|
@@ -120,7 +120,7 @@ var NFTFactory = class {
|
|
|
120
120
|
if (!data[x] || !(0, lodash_isNumber.default)(data[x])) throw new Error(`Invalid number field ${x} when creating coupon asset`);
|
|
121
121
|
});
|
|
122
122
|
timeFields.forEach((x) => {
|
|
123
|
-
if (!(0, lodash_isDate.default)(new Date(data[x]))) throw new Error(`Invalid date field ${x} when creating coupon asset`);
|
|
123
|
+
if (data[x] === void 0 || data[x] === null || !(0, lodash_isDate.default)(new Date(data[x])) || Number.isNaN(new Date(data[x]).getTime())) throw new Error(`Invalid date field ${x} when creating coupon asset`);
|
|
124
124
|
});
|
|
125
125
|
const { name: name$1, description, ratio, amount, location, minAmount, expireTime, type, recipient, display: innerDisplay = "", issuanceDate, endpoint, endpointScope } = data;
|
|
126
126
|
const vc = await (0, _arcblock_vc.create)({
|
|
@@ -234,15 +234,17 @@ var NFTFactory = class {
|
|
|
234
234
|
}
|
|
235
235
|
async createSignedAsset(payload, attributes) {
|
|
236
236
|
payload.signature = (0, _ocap_util.toBase58)(await this.wallet.sign((0, fast_json_stable_stringify.default)(payload)));
|
|
237
|
+
const moniker = (0, lodash_get.default)(payload, "data.name") || (0, lodash_get.default)(payload, "credentialSubject.name") || "signed_asset";
|
|
238
|
+
const { data: _ignoredData, address: _ignoredAddress, ...safeAttributes } = attributes || {};
|
|
237
239
|
const asset = {
|
|
238
|
-
moniker
|
|
240
|
+
moniker,
|
|
239
241
|
readonly: false,
|
|
240
242
|
transferrable: true,
|
|
243
|
+
...safeAttributes,
|
|
241
244
|
data: {
|
|
242
245
|
typeUrl: "vc",
|
|
243
246
|
value: payload
|
|
244
|
-
}
|
|
245
|
-
...attributes
|
|
247
|
+
}
|
|
246
248
|
};
|
|
247
249
|
asset.address = (0, _arcblock_did_util.toAssetAddress)(asset, "cbor");
|
|
248
250
|
return [asset, await this.client.sendCreateAssetTx({
|
|
@@ -272,7 +274,7 @@ var NFTFactory = class {
|
|
|
272
274
|
if (!data[x]) throw new Error(`Missing required field ${x} when creating certificate`);
|
|
273
275
|
});
|
|
274
276
|
timeFields.forEach((x) => {
|
|
275
|
-
if (!(0, lodash_isDate.default)(new Date(data[x]))) throw new Error(`Invalid date field ${x} when creating certificate`);
|
|
277
|
+
if (data[x] === void 0 || data[x] === null || !(0, lodash_isDate.default)(new Date(data[x])) || Number.isNaN(new Date(data[x]).getTime())) throw new Error(`Invalid date field ${x} when creating certificate`);
|
|
276
278
|
});
|
|
277
279
|
if (!(data.recipient instanceof require_recipient.default)) throw new Error("Invalid recipient field when creating certificate");
|
|
278
280
|
const { name: name$1, description, reason, logoUrl, recipient, type, expireTime, display: innerDisplay = "", issuanceDate, endpoint, endpointScope } = data;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/nft",
|
|
3
3
|
"description": "Utility to create standard asset on forge powered blockchain",
|
|
4
|
-
"version": "1.30.
|
|
4
|
+
"version": "1.30.25",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "wangshijun",
|
|
7
7
|
"email": "shijun@arcblock.io",
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
"esm"
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@arcblock/did-util": "1.30.
|
|
47
|
-
"@arcblock/vc": "1.30.
|
|
48
|
-
"@ocap/client": "1.30.
|
|
49
|
-
"@ocap/tx-protocols": "1.30.
|
|
50
|
-
"@ocap/tx-util": "1.30.
|
|
51
|
-
"@ocap/util": "1.30.
|
|
52
|
-
"@ocap/wallet": "1.30.
|
|
46
|
+
"@arcblock/did-util": "1.30.25",
|
|
47
|
+
"@arcblock/vc": "1.30.25",
|
|
48
|
+
"@ocap/client": "1.30.25",
|
|
49
|
+
"@ocap/tx-protocols": "1.30.25",
|
|
50
|
+
"@ocap/tx-util": "1.30.25",
|
|
51
|
+
"@ocap/util": "1.30.25",
|
|
52
|
+
"@ocap/wallet": "1.30.25",
|
|
53
53
|
"debug": "^4.4.3",
|
|
54
54
|
"fast-json-stable-stringify": "^2.1.0",
|
|
55
55
|
"lodash": "^4.17.23",
|