@arcblock/nft 1.28.8 → 1.29.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/README.md +0 -1
- package/esm/enum.d.mts +23 -0
- package/esm/enum.mjs +22 -0
- package/esm/factory.d.mts +141 -0
- package/esm/factory.mjs +310 -0
- package/esm/index.d.mts +5 -0
- package/esm/index.mjs +6 -0
- package/esm/issuer.d.mts +44 -0
- package/esm/issuer.mjs +36 -0
- package/esm/package.mjs +5 -0
- package/esm/recipient.d.mts +40 -0
- package/esm/recipient.mjs +34 -0
- package/lib/_virtual/rolldown_runtime.cjs +29 -0
- package/lib/enum.cjs +24 -0
- package/lib/enum.d.cts +23 -0
- package/lib/factory.cjs +319 -0
- package/lib/factory.d.cts +141 -0
- package/lib/index.cjs +10 -0
- package/lib/index.d.cts +5 -0
- package/lib/issuer.cjs +38 -0
- package/lib/issuer.d.cts +44 -0
- package/lib/package.cjs +11 -0
- package/lib/recipient.cjs +36 -0
- package/lib/recipient.d.cts +40 -0
- package/package.json +41 -15
- package/lib/enum.d.ts +0 -18
- package/lib/enum.js +0 -21
- package/lib/factory.d.ts +0 -165
- package/lib/factory.js +0 -398
- package/lib/index.d.ts +0 -259
- package/lib/index.js +0 -12
- package/lib/issuer.d.ts +0 -31
- package/lib/issuer.js +0 -25
- package/lib/recipient.d.ts +0 -27
- package/lib/recipient.js +0 -24
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
//#region src/recipient.d.ts
|
|
2
|
+
interface RecipientAttributes {
|
|
3
|
+
name: string;
|
|
4
|
+
location?: string;
|
|
5
|
+
}
|
|
6
|
+
interface WalletObject {
|
|
7
|
+
address: string;
|
|
8
|
+
publicKey: Uint8Array | string;
|
|
9
|
+
}
|
|
10
|
+
interface NFTRecipientParams extends RecipientAttributes {
|
|
11
|
+
wallet: WalletObject;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Represents an NFT recipient with wallet and metadata
|
|
15
|
+
*/
|
|
16
|
+
declare class NFTRecipient {
|
|
17
|
+
wallet: WalletObject;
|
|
18
|
+
attributes: RecipientAttributes;
|
|
19
|
+
/**
|
|
20
|
+
* Creates an instance of NFTRecipient.
|
|
21
|
+
*
|
|
22
|
+
* @param params - Recipient parameters
|
|
23
|
+
* @param params.wallet - wallet object
|
|
24
|
+
* @param params.name - recipient name
|
|
25
|
+
* @param params.location - recipient location
|
|
26
|
+
*/
|
|
27
|
+
constructor({
|
|
28
|
+
wallet,
|
|
29
|
+
name,
|
|
30
|
+
location
|
|
31
|
+
}: NFTRecipientParams);
|
|
32
|
+
toJSON(): {
|
|
33
|
+
name: string;
|
|
34
|
+
location?: string;
|
|
35
|
+
did: string;
|
|
36
|
+
pk: any;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { NFTRecipient as default };
|
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.
|
|
4
|
+
"version": "1.29.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "wangshijun",
|
|
7
7
|
"email": "shijun@arcblock.io",
|
|
@@ -17,21 +17,49 @@
|
|
|
17
17
|
"publishConfig": {
|
|
18
18
|
"access": "public"
|
|
19
19
|
},
|
|
20
|
+
"type": "module",
|
|
21
|
+
"main": "./lib/index.cjs",
|
|
22
|
+
"module": "./esm/index.mjs",
|
|
23
|
+
"types": "./esm/index.d.mts",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./esm/index.d.mts",
|
|
27
|
+
"import": "./esm/index.mjs",
|
|
28
|
+
"default": "./lib/index.cjs"
|
|
29
|
+
},
|
|
30
|
+
"./lib/*.js": {
|
|
31
|
+
"types": "./esm/*.d.mts",
|
|
32
|
+
"import": "./esm/*.mjs",
|
|
33
|
+
"default": "./lib/*.cjs"
|
|
34
|
+
},
|
|
35
|
+
"./lib/*": {
|
|
36
|
+
"types": "./esm/*.d.mts",
|
|
37
|
+
"import": "./esm/*.mjs",
|
|
38
|
+
"default": "./lib/*.cjs"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"files": [
|
|
42
|
+
"lib",
|
|
43
|
+
"esm"
|
|
44
|
+
],
|
|
20
45
|
"dependencies": {
|
|
21
|
-
"@arcblock/did-util": "1.
|
|
22
|
-
"@arcblock/vc": "1.
|
|
23
|
-
"@ocap/client": "1.
|
|
24
|
-
"@ocap/tx-protocols": "1.
|
|
25
|
-
"@ocap/tx-util": "1.
|
|
26
|
-
"@ocap/util": "1.
|
|
27
|
-
"@ocap/wallet": "1.
|
|
28
|
-
"debug": "^4.3
|
|
46
|
+
"@arcblock/did-util": "1.29.0",
|
|
47
|
+
"@arcblock/vc": "1.29.0",
|
|
48
|
+
"@ocap/client": "1.29.0",
|
|
49
|
+
"@ocap/tx-protocols": "1.29.0",
|
|
50
|
+
"@ocap/tx-util": "1.29.0",
|
|
51
|
+
"@ocap/util": "1.29.0",
|
|
52
|
+
"@ocap/wallet": "1.29.0",
|
|
53
|
+
"debug": "^4.4.3",
|
|
29
54
|
"json-stable-stringify": "^1.0.1",
|
|
30
|
-
"lodash": "^4.17.
|
|
55
|
+
"lodash": "^4.17.23",
|
|
31
56
|
"pako": "^1.0.11"
|
|
32
57
|
},
|
|
33
58
|
"devDependencies": {
|
|
34
|
-
"@ocap/e2e-test": "1.
|
|
59
|
+
"@ocap/e2e-test": "1.29.0",
|
|
60
|
+
"@types/debug": "^4.1.12",
|
|
61
|
+
"@types/json-stable-stringify": "^1.0.36",
|
|
62
|
+
"@types/lodash": "^4.17.13",
|
|
35
63
|
"remark-cli": "^10.0.1",
|
|
36
64
|
"remark-preset-github": "^4.0.4"
|
|
37
65
|
},
|
|
@@ -53,15 +81,13 @@
|
|
|
53
81
|
"nodejs"
|
|
54
82
|
],
|
|
55
83
|
"license": "Apache-2.0",
|
|
56
|
-
"main": "./lib/index.js",
|
|
57
|
-
"files": [
|
|
58
|
-
"lib"
|
|
59
|
-
],
|
|
60
84
|
"repository": {
|
|
61
85
|
"type": "git",
|
|
62
86
|
"url": "https://github.com/ArcBlock/blockchain/tree/master/asset/nft"
|
|
63
87
|
},
|
|
64
88
|
"scripts": {
|
|
89
|
+
"build": "tsdown",
|
|
90
|
+
"prebuild": "rm -rf lib esm",
|
|
65
91
|
"lint": "biome check",
|
|
66
92
|
"lint:fix": "biome check --write",
|
|
67
93
|
"docs": "bun run gen-dts && bun run gen-docs && bun run cleanup-docs && bun run format-docs",
|
package/lib/enum.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export const NFTType: Readonly<{
|
|
2
|
-
ticket: number;
|
|
3
|
-
coupon: number;
|
|
4
|
-
certificate: number;
|
|
5
|
-
badge: number;
|
|
6
|
-
license: number;
|
|
7
|
-
giftcard: number;
|
|
8
|
-
passport: number;
|
|
9
|
-
idcard: number;
|
|
10
|
-
receipt: number;
|
|
11
|
-
other: number;
|
|
12
|
-
}>;
|
|
13
|
-
export const NFTStatus: Readonly<{
|
|
14
|
-
normal: number;
|
|
15
|
-
consumed: number;
|
|
16
|
-
invalid: number;
|
|
17
|
-
expired: number;
|
|
18
|
-
}>;
|
package/lib/enum.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const NFTType = Object.freeze({
|
|
2
|
-
ticket: 0,
|
|
3
|
-
coupon: 1,
|
|
4
|
-
certificate: 2,
|
|
5
|
-
badge: 3,
|
|
6
|
-
license: 4,
|
|
7
|
-
giftcard: 5,
|
|
8
|
-
passport: 6,
|
|
9
|
-
idcard: 7,
|
|
10
|
-
receipt: 8,
|
|
11
|
-
other: 127,
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
const NFTStatus = Object.freeze({
|
|
15
|
-
normal: 0,
|
|
16
|
-
consumed: 1,
|
|
17
|
-
invalid: 2,
|
|
18
|
-
expired: 3,
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
module.exports = { NFTType, NFTStatus };
|
package/lib/factory.d.ts
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
export = NFTFactory;
|
|
2
|
-
/**
|
|
3
|
-
* Used to create standard asset on forge powered blockchain
|
|
4
|
-
* All assets are signed assets, eg, the asset data are self approvable
|
|
5
|
-
*
|
|
6
|
-
* @class NFTFactory
|
|
7
|
-
*/
|
|
8
|
-
declare class NFTFactory {
|
|
9
|
-
/**
|
|
10
|
-
* Creates an instance of NFTFactory.
|
|
11
|
-
* @param {object} params
|
|
12
|
-
* @param {string} params.chainHost - on which chain to create wallet
|
|
13
|
-
* @param {WalletObject} params.wallet - issuer wallet
|
|
14
|
-
* @param {object} params.issuer - issuer attributes, such as name, url and logo
|
|
15
|
-
* @memberof NFTFactory
|
|
16
|
-
*/
|
|
17
|
-
constructor({ chainHost, wallet, issuer }: {
|
|
18
|
-
chainHost: string;
|
|
19
|
-
wallet: WalletObject;
|
|
20
|
-
issuer: object;
|
|
21
|
-
});
|
|
22
|
-
chainHost: string;
|
|
23
|
-
client: Client;
|
|
24
|
-
wallet: WalletObject;
|
|
25
|
-
issuer: NFTIssuer;
|
|
26
|
-
/**
|
|
27
|
-
* Create a ticket
|
|
28
|
-
*
|
|
29
|
-
* @param {object} params
|
|
30
|
-
* @param {string} params.display - display of the ticket { type, content }
|
|
31
|
-
* @param {object} params.data - asset payload
|
|
32
|
-
* @param {string} params.data.name - ticket name
|
|
33
|
-
* @param {string} params.data.description - ticket description
|
|
34
|
-
* @param {string} params.data.location - event location
|
|
35
|
-
* @param {number} params.data.startTime - event start time
|
|
36
|
-
* @param {number} params.data.endTime - event end time
|
|
37
|
-
* @param {object} params.attributes - asset attributes
|
|
38
|
-
* @returns {Promise} - the `[asset, hash]` on resolved
|
|
39
|
-
* @memberof NFTFactory
|
|
40
|
-
*/
|
|
41
|
-
createTicket({ display, data, attributes }: {
|
|
42
|
-
display: string;
|
|
43
|
-
data: {
|
|
44
|
-
name: string;
|
|
45
|
-
description: string;
|
|
46
|
-
location: string;
|
|
47
|
-
startTime: number;
|
|
48
|
-
endTime: number;
|
|
49
|
-
};
|
|
50
|
-
attributes: object;
|
|
51
|
-
}): Promise<any>;
|
|
52
|
-
/**
|
|
53
|
-
* Create a coupon asset
|
|
54
|
-
*
|
|
55
|
-
* @param {object} params
|
|
56
|
-
* @param {string} params.display - display of the coupon { type, content }
|
|
57
|
-
* @param {object} params.data - asset payload
|
|
58
|
-
* @param {string} params.data.name - coupon name
|
|
59
|
-
* @param {string} params.data.description - coupon description
|
|
60
|
-
* @param {number} params.data.ratio - discount ratio
|
|
61
|
-
* @param {number} params.data.amount - discount amount
|
|
62
|
-
* @param {number} params.data.minAmount - min order amount that this coupon can be used
|
|
63
|
-
* @param {number} params.data.startTime - event start time
|
|
64
|
-
* @param {number} params.data.endTime - event end time
|
|
65
|
-
* @param {object} params.attributes - asset attributes
|
|
66
|
-
* @returns {Promise} - the `[asset, hash]` on resolved
|
|
67
|
-
* @memberof NFTFactory
|
|
68
|
-
*/
|
|
69
|
-
createCoupon({ display, data, attributes }: {
|
|
70
|
-
display: string;
|
|
71
|
-
data: {
|
|
72
|
-
name: string;
|
|
73
|
-
description: string;
|
|
74
|
-
ratio: number;
|
|
75
|
-
amount: number;
|
|
76
|
-
minAmount: number;
|
|
77
|
-
startTime: number;
|
|
78
|
-
endTime: number;
|
|
79
|
-
};
|
|
80
|
-
attributes: object;
|
|
81
|
-
}): Promise<any>;
|
|
82
|
-
/**
|
|
83
|
-
* Create a coupon asset
|
|
84
|
-
*
|
|
85
|
-
* @param {object} params
|
|
86
|
-
* @param {string} params.display - display of the coupon { type, content }
|
|
87
|
-
* @param {object} params.data - asset payload
|
|
88
|
-
* @param {string} params.data.name - certificate name
|
|
89
|
-
* @param {string} params.data.description - certificate description
|
|
90
|
-
* @param {string} params.data.reason - certificate reason
|
|
91
|
-
* @param {string} params.data.logoUrl - certificate logo
|
|
92
|
-
* @param {NFTRecipient} params.data.recipient - certificate recipient
|
|
93
|
-
* @param {number} params.data.issueTime - when was certificate issued
|
|
94
|
-
* @param {number} params.data.expireTime - when will certificate expire
|
|
95
|
-
* @param {object} params.attributes - asset attributes
|
|
96
|
-
* @returns {Promise} - the `[asset, hash]` on resolved
|
|
97
|
-
* @memberof NFTFactory
|
|
98
|
-
*/
|
|
99
|
-
createCertificate({ display, data, attributes }: {
|
|
100
|
-
display: string;
|
|
101
|
-
data: {
|
|
102
|
-
name: string;
|
|
103
|
-
description: string;
|
|
104
|
-
reason: string;
|
|
105
|
-
logoUrl: string;
|
|
106
|
-
recipient: NFTRecipient;
|
|
107
|
-
issueTime: number;
|
|
108
|
-
expireTime: number;
|
|
109
|
-
};
|
|
110
|
-
attributes: object;
|
|
111
|
-
}): Promise<any>;
|
|
112
|
-
/**
|
|
113
|
-
* Create a badge
|
|
114
|
-
*
|
|
115
|
-
* @param {object} params
|
|
116
|
-
* @param {string} params.display - display of the badge { type, content }
|
|
117
|
-
* @param {object} params.data - asset payload
|
|
118
|
-
* @param {string} params.data.name - certificate name
|
|
119
|
-
* @param {string} params.data.description - certificate description
|
|
120
|
-
* @param {NFTRecipient} params.data.recipient - certificate recipient
|
|
121
|
-
* @param {object} params.attributes - asset attributes
|
|
122
|
-
* @returns {Promise} - the `[asset, hash]` on resolved
|
|
123
|
-
* @memberof NFTFactory
|
|
124
|
-
*/
|
|
125
|
-
createBadge({ display, data, attributes }: {
|
|
126
|
-
display: string;
|
|
127
|
-
data: {
|
|
128
|
-
name: string;
|
|
129
|
-
description: string;
|
|
130
|
-
recipient: NFTRecipient;
|
|
131
|
-
};
|
|
132
|
-
attributes: object;
|
|
133
|
-
}): Promise<any>;
|
|
134
|
-
/**
|
|
135
|
-
* Create a passport
|
|
136
|
-
*
|
|
137
|
-
* @param {object} params
|
|
138
|
-
* @param {string} params.display - display of the passport { type, content }
|
|
139
|
-
* @param {object} params.passport - asset payload
|
|
140
|
-
* @param {string} params.passport.name - passport name
|
|
141
|
-
* @param {string} params.passport.title - passport title
|
|
142
|
-
* @param {NFTRecipient} params.data.recipient - certificate recipient
|
|
143
|
-
* @param {object} params.attributes - asset attributes
|
|
144
|
-
* @returns {Promise} - the `[asset, hash]` on resolved
|
|
145
|
-
* @memberof NFTFactory
|
|
146
|
-
*/
|
|
147
|
-
createPassport({ display, data, attributes }: {
|
|
148
|
-
display: string;
|
|
149
|
-
passport: {
|
|
150
|
-
name: string;
|
|
151
|
-
title: string;
|
|
152
|
-
};
|
|
153
|
-
}): Promise<any>;
|
|
154
|
-
createSignedAsset(payload: any, attributes: any): Promise<any[]>;
|
|
155
|
-
_createDisplay(display: any): any;
|
|
156
|
-
_createCert({ display, data, attributes }: {
|
|
157
|
-
display?: string;
|
|
158
|
-
data?: {};
|
|
159
|
-
attributes?: {};
|
|
160
|
-
}): Promise<any[]>;
|
|
161
|
-
getVCBody(asset: any): any;
|
|
162
|
-
}
|
|
163
|
-
import Client = require("@ocap/client");
|
|
164
|
-
import NFTIssuer = require("./issuer");
|
|
165
|
-
import NFTRecipient = require("./recipient");
|