@arcblock/nft 1.16.8 → 1.16.12
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 +1 -1
- package/lib/enum.d.ts +18 -0
- package/lib/factory.d.ts +165 -0
- package/lib/issuer.d.ts +31 -0
- package/lib/recipient.d.ts +27 -0
- package/package.json +12 -11
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/prettier/prettier)
|
|
4
4
|
[](https://docs.arcblock.io)
|
|
5
|
-
[](https://gitter.im/ArcBlock/community?utm_source=badge
|
|
5
|
+
[](https://gitter.im/ArcBlock/community?utm_source=badge\&utm_medium=badge\&utm_campaign=pr-badge)
|
|
6
6
|
|
|
7
7
|
> Utility to create standard assets that can be rendered in [DID Wallet](https://www.abtwallet.io)
|
|
8
8
|
|
package/lib/enum.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
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/factory.d.ts
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
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");
|
package/lib/issuer.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export = NFTIssuer;
|
|
2
|
+
declare class NFTIssuer {
|
|
3
|
+
/**
|
|
4
|
+
* Creates an instance of NFTIssuer.
|
|
5
|
+
*
|
|
6
|
+
* @param {object} attributes
|
|
7
|
+
* @param {WalletObject} attributes.wallet - wallet
|
|
8
|
+
* @param {string} attributes.name - issuer name
|
|
9
|
+
* @param {string} attributes.url - issuer website
|
|
10
|
+
* @param {string} attributes.logo - issuer logo image url or logo base64
|
|
11
|
+
*/
|
|
12
|
+
constructor({ wallet, name, url, logo }: {
|
|
13
|
+
wallet: WalletObject;
|
|
14
|
+
name: string;
|
|
15
|
+
url: string;
|
|
16
|
+
logo: string;
|
|
17
|
+
});
|
|
18
|
+
wallet: WalletObject;
|
|
19
|
+
attributes: {
|
|
20
|
+
name: string;
|
|
21
|
+
url: string;
|
|
22
|
+
logo: string;
|
|
23
|
+
};
|
|
24
|
+
toJSON(): {
|
|
25
|
+
name: string;
|
|
26
|
+
url: string;
|
|
27
|
+
logo: string;
|
|
28
|
+
did: any;
|
|
29
|
+
pk: string;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export = NFTRecipient;
|
|
2
|
+
declare class NFTRecipient {
|
|
3
|
+
/**
|
|
4
|
+
* Creates an instance of NFTRecipient.
|
|
5
|
+
*
|
|
6
|
+
* @param {object} attributes
|
|
7
|
+
* @param {WalletObject} attributes.wallet - wallet
|
|
8
|
+
* @param {string} attributes.name - recipient name
|
|
9
|
+
* @param {string} attributes.location - recipient website
|
|
10
|
+
*/
|
|
11
|
+
constructor({ wallet, name, location }: {
|
|
12
|
+
wallet: WalletObject;
|
|
13
|
+
name: string;
|
|
14
|
+
location: string;
|
|
15
|
+
});
|
|
16
|
+
wallet: WalletObject;
|
|
17
|
+
attributes: {
|
|
18
|
+
name: string;
|
|
19
|
+
location: string;
|
|
20
|
+
};
|
|
21
|
+
toJSON(): {
|
|
22
|
+
name: string;
|
|
23
|
+
location: string;
|
|
24
|
+
did: any;
|
|
25
|
+
pk: string;
|
|
26
|
+
};
|
|
27
|
+
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/nft",
|
|
3
3
|
"description": "Utility to create standard asset on forge powered blockchain",
|
|
4
|
-
"version": "1.16.
|
|
4
|
+
"version": "1.16.12",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "wangshijun",
|
|
7
7
|
"email": "shijun@arcblock.io",
|
|
8
8
|
"url": "https://github.com/wangshijun"
|
|
9
9
|
},
|
|
10
|
+
"contributors": [
|
|
11
|
+
"wangshijun <shijun@arcblock.io> (https://github.com/wangshijun)"
|
|
12
|
+
],
|
|
10
13
|
"bugs": {
|
|
11
14
|
"url": "https://github.com/ArcBlock/asset-chain/issues",
|
|
12
15
|
"email": "shijun@arcblock.io"
|
|
@@ -15,11 +18,11 @@
|
|
|
15
18
|
"access": "public"
|
|
16
19
|
},
|
|
17
20
|
"dependencies": {
|
|
18
|
-
"@arcblock/did-util": "1.16.
|
|
19
|
-
"@arcblock/vc": "1.16.
|
|
20
|
-
"@ocap/client": "1.16.
|
|
21
|
-
"@ocap/util": "1.16.
|
|
22
|
-
"@ocap/wallet": "1.16.
|
|
21
|
+
"@arcblock/did-util": "1.16.12",
|
|
22
|
+
"@arcblock/vc": "1.16.12",
|
|
23
|
+
"@ocap/client": "1.16.12",
|
|
24
|
+
"@ocap/util": "1.16.12",
|
|
25
|
+
"@ocap/wallet": "1.16.12",
|
|
23
26
|
"debug": "^4.3.3",
|
|
24
27
|
"json-stable-stringify": "^1.0.1",
|
|
25
28
|
"lodash": "^4.17.21",
|
|
@@ -28,14 +31,13 @@
|
|
|
28
31
|
},
|
|
29
32
|
"devDependencies": {
|
|
30
33
|
"jest": "^27.3.1",
|
|
31
|
-
"remark-cli": "^
|
|
32
|
-
"remark-preset-github": "^
|
|
34
|
+
"remark-cli": "^10.0.1",
|
|
35
|
+
"remark-preset-github": "^4.0.1"
|
|
33
36
|
},
|
|
34
37
|
"remarkConfig": {
|
|
35
38
|
"plugins": [
|
|
36
39
|
"preset-github",
|
|
37
40
|
[
|
|
38
|
-
"validate-links",
|
|
39
41
|
{
|
|
40
42
|
"repository": "ArcBlock/asset-chain"
|
|
41
43
|
}
|
|
@@ -44,7 +46,6 @@
|
|
|
44
46
|
},
|
|
45
47
|
"homepage": "https://github.com/ArcBlock/asset-chain/tree/master/asset/nft",
|
|
46
48
|
"keywords": [
|
|
47
|
-
"forge",
|
|
48
49
|
"blockchain",
|
|
49
50
|
"arcblock",
|
|
50
51
|
"sdk",
|
|
@@ -70,5 +71,5 @@
|
|
|
70
71
|
"test": "jest --forceExit --detectOpenHandles",
|
|
71
72
|
"coverage": "yarn test -- --coverage"
|
|
72
73
|
},
|
|
73
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "fbae535a1a8b38bb6942a5d80c4e20f88163833a"
|
|
74
75
|
}
|