@niftykit/diamond 0.2.2 → 0.2.8
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 +56 -1
- package/dist/cjs/Diamond.js +27 -0
- package/dist/esm/Diamond.js +27 -0
- package/dist/types/Diamond.d.ts +2 -0
- package/dist/umd/index.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -22,6 +22,8 @@ Or use it via CDN
|
|
|
22
22
|
|
|
23
23
|
## How to use
|
|
24
24
|
|
|
25
|
+
### Drop Collection
|
|
26
|
+
|
|
25
27
|
```typescript
|
|
26
28
|
// using ethers.js
|
|
27
29
|
import { ethers } from 'ethers';
|
|
@@ -33,7 +35,60 @@ const signer = provider.getSigner();
|
|
|
33
35
|
|
|
34
36
|
const diamond = await Diamond.create(signer, 'YOUR-SDK-KEY');
|
|
35
37
|
|
|
38
|
+
// minter
|
|
39
|
+
const recipient = await signer.getAddress();
|
|
40
|
+
|
|
41
|
+
// get current price
|
|
42
|
+
const price = await diamond.apps.drop.price();
|
|
43
|
+
|
|
36
44
|
// mint 1 NFT
|
|
37
|
-
await diamond.apps.drop
|
|
45
|
+
const tx = await state.diamond.apps.drop.mintTo(recipient, 1, {
|
|
46
|
+
value: price,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
await tx.wait();
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Edition Collection
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
// using ethers.js
|
|
57
|
+
import { ethers } from 'ethers';
|
|
58
|
+
import Diamond from '@niftykit/diamond';
|
|
59
|
+
|
|
60
|
+
const provider = new ethers.providers.Web3Provider(window.ethereum, 'any');
|
|
61
|
+
await provider.send('eth_requestAccounts', []);
|
|
62
|
+
const signer = provider.getSigner();
|
|
63
|
+
|
|
64
|
+
const diamond = await Diamond.create(signer, 'YOUR-SDK-KEY');
|
|
65
|
+
|
|
66
|
+
// edition id
|
|
67
|
+
const editionId = 0; // change this to your edition id
|
|
68
|
+
|
|
69
|
+
// get edition price
|
|
70
|
+
const price = await diamond.apps.edition.getEditionPrice(editionId);
|
|
71
|
+
|
|
72
|
+
// minter
|
|
73
|
+
const recipient = await signer.getAddress();
|
|
74
|
+
|
|
75
|
+
// check presale (if any)
|
|
76
|
+
const verify = await state.diamond.verifyForEdition(
|
|
77
|
+
recipient,
|
|
78
|
+
editionId
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
// mint 1 NFT
|
|
82
|
+
const tx = await diamond.apps.edition.mintEdition(
|
|
83
|
+
recipient,
|
|
84
|
+
editionId,
|
|
85
|
+
1,
|
|
86
|
+
verify?.proof ?? [],
|
|
87
|
+
{
|
|
88
|
+
value: price,
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
await tx.wait();
|
|
38
93
|
|
|
39
94
|
```
|
package/dist/cjs/Diamond.js
CHANGED
|
@@ -98,6 +98,9 @@ var Diamond = /** @class */ (function () {
|
|
|
98
98
|
Diamond.prototype.verify = function (wallet) {
|
|
99
99
|
return Diamond.verifyWallet(this.collectionId, wallet, this.isDev);
|
|
100
100
|
};
|
|
101
|
+
Diamond.prototype.verifyForEdition = function (wallet, editionId) {
|
|
102
|
+
return Diamond.verifyWalletForEdition(this.collectionId, wallet, editionId, this.isDev);
|
|
103
|
+
};
|
|
101
104
|
Diamond.create = function (signerOrProvider, key, data, isDev) {
|
|
102
105
|
return __awaiter(this, void 0, void 0, function () {
|
|
103
106
|
var instance;
|
|
@@ -141,6 +144,30 @@ var Diamond = /** @class */ (function () {
|
|
|
141
144
|
});
|
|
142
145
|
});
|
|
143
146
|
};
|
|
147
|
+
Diamond.verifyWalletForEdition = function (collectionId, wallet, editionId, isDev) {
|
|
148
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
149
|
+
var baseUrl, url, resp, message;
|
|
150
|
+
return __generator(this, function (_a) {
|
|
151
|
+
switch (_a.label) {
|
|
152
|
+
case 0:
|
|
153
|
+
baseUrl = isDev ? endpoint_1.API_ENDPOINT_DEV : endpoint_1.API_ENDPOINT;
|
|
154
|
+
url = "".concat(baseUrl, "/v3/editions/list/").concat(collectionId, "/").concat(editionId);
|
|
155
|
+
return [4 /*yield*/, axios_1.default.post(url, {
|
|
156
|
+
wallet: wallet,
|
|
157
|
+
}, {
|
|
158
|
+
validateStatus: function (status) { return status < 500; },
|
|
159
|
+
})];
|
|
160
|
+
case 1:
|
|
161
|
+
resp = _a.sent();
|
|
162
|
+
if (resp.status >= 400) {
|
|
163
|
+
message = resp.data.message;
|
|
164
|
+
throw new Error(message);
|
|
165
|
+
}
|
|
166
|
+
return [2 /*return*/, resp.data];
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
};
|
|
144
171
|
Diamond.getCollectionData = function (collectionId, isDev) {
|
|
145
172
|
return __awaiter(this, void 0, void 0, function () {
|
|
146
173
|
var baseUrl, url, resp, message;
|
package/dist/esm/Diamond.js
CHANGED
|
@@ -93,6 +93,9 @@ var Diamond = /** @class */ (function () {
|
|
|
93
93
|
Diamond.prototype.verify = function (wallet) {
|
|
94
94
|
return Diamond.verifyWallet(this.collectionId, wallet, this.isDev);
|
|
95
95
|
};
|
|
96
|
+
Diamond.prototype.verifyForEdition = function (wallet, editionId) {
|
|
97
|
+
return Diamond.verifyWalletForEdition(this.collectionId, wallet, editionId, this.isDev);
|
|
98
|
+
};
|
|
96
99
|
Diamond.create = function (signerOrProvider, key, data, isDev) {
|
|
97
100
|
return __awaiter(this, void 0, void 0, function () {
|
|
98
101
|
var instance;
|
|
@@ -136,6 +139,30 @@ var Diamond = /** @class */ (function () {
|
|
|
136
139
|
});
|
|
137
140
|
});
|
|
138
141
|
};
|
|
142
|
+
Diamond.verifyWalletForEdition = function (collectionId, wallet, editionId, isDev) {
|
|
143
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
144
|
+
var baseUrl, url, resp, message;
|
|
145
|
+
return __generator(this, function (_a) {
|
|
146
|
+
switch (_a.label) {
|
|
147
|
+
case 0:
|
|
148
|
+
baseUrl = isDev ? API_ENDPOINT_DEV : API_ENDPOINT;
|
|
149
|
+
url = "".concat(baseUrl, "/v3/editions/list/").concat(collectionId, "/").concat(editionId);
|
|
150
|
+
return [4 /*yield*/, axios.post(url, {
|
|
151
|
+
wallet: wallet,
|
|
152
|
+
}, {
|
|
153
|
+
validateStatus: function (status) { return status < 500; },
|
|
154
|
+
})];
|
|
155
|
+
case 1:
|
|
156
|
+
resp = _a.sent();
|
|
157
|
+
if (resp.status >= 400) {
|
|
158
|
+
message = resp.data.message;
|
|
159
|
+
throw new Error(message);
|
|
160
|
+
}
|
|
161
|
+
return [2 /*return*/, resp.data];
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
};
|
|
139
166
|
Diamond.getCollectionData = function (collectionId, isDev) {
|
|
140
167
|
return __awaiter(this, void 0, void 0, function () {
|
|
141
168
|
var baseUrl, url, resp, message;
|
package/dist/types/Diamond.d.ts
CHANGED
|
@@ -24,7 +24,9 @@ export default class Diamond {
|
|
|
24
24
|
init(): Promise<void>;
|
|
25
25
|
initWithData(data: CollectionApiResponse): void;
|
|
26
26
|
verify(wallet: string): Promise<VerifyApiResponse>;
|
|
27
|
+
verifyForEdition(wallet: string, editionId: number): Promise<VerifyApiResponse>;
|
|
27
28
|
static create(signerOrProvider: Signer | Provider, key: string, data?: CollectionApiResponse, isDev?: boolean): Promise<Diamond | null>;
|
|
28
29
|
static verifyWallet(collectionId: string, wallet: string, isDev?: boolean): Promise<VerifyApiResponse>;
|
|
30
|
+
static verifyWalletForEdition(collectionId: string, wallet: string, editionId: number, isDev?: boolean): Promise<VerifyApiResponse>;
|
|
29
31
|
static getCollectionData(collectionId: string, isDev?: boolean): Promise<CollectionApiResponse>;
|
|
30
32
|
}
|