privately-smartcontract-lib 1.1.0 → 1.1.1
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/dist/MockUSDC.json +342 -0
- package/dist/PrivatelyAuctionSystem.json +734 -0
- package/dist/PrivatelyCollection.json +865 -0
- package/dist/client.d.ts +36 -0
- package/dist/client.js +64 -0
- package/dist/common/index.d.ts +2 -0
- package/dist/common/index.js +18 -0
- package/dist/common/privately.error.d.ts +5 -0
- package/dist/common/privately.error.js +47 -0
- package/dist/common/request-signature.d.ts +17 -0
- package/dist/common/request-signature.js +43 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +20 -0
- package/dist/modules/auctions/auctions.auction.d.ts +12 -0
- package/dist/modules/auctions/auctions.auction.js +29 -0
- package/dist/modules/auctions/auctions.bid.reqest.d.ts +12 -0
- package/dist/modules/auctions/auctions.bid.reqest.js +11 -0
- package/dist/modules/auctions/auctions.client.d.ts +147 -0
- package/dist/modules/auctions/auctions.client.js +312 -0
- package/dist/modules/auctions/auctions.create.request.d.ts +13 -0
- package/dist/modules/auctions/auctions.create.request.js +12 -0
- package/dist/modules/auctions/auctions.errors.d.ts +6 -0
- package/dist/modules/auctions/auctions.errors.js +14 -0
- package/dist/modules/auctions/auctions.events.d.ts +5 -0
- package/dist/modules/auctions/auctions.events.js +2 -0
- package/dist/modules/auctions/auctions.nonces.d.ts +4 -0
- package/dist/modules/auctions/auctions.nonces.js +2 -0
- package/dist/modules/auctions/index.d.ts +6 -0
- package/dist/modules/auctions/index.js +22 -0
- package/dist/modules/collection/collection.approve.request.d.ts +8 -0
- package/dist/modules/collection/collection.approve.request.js +11 -0
- package/dist/modules/collection/collection.client.d.ts +97 -0
- package/dist/modules/collection/collection.client.js +224 -0
- package/dist/modules/collection/collection.errors.d.ts +6 -0
- package/dist/modules/collection/collection.errors.js +14 -0
- package/dist/modules/collection/collection.events.d.ts +3 -0
- package/dist/modules/collection/collection.events.js +2 -0
- package/dist/modules/collection/collection.mint.request.d.ts +9 -0
- package/dist/modules/collection/collection.mint.request.js +12 -0
- package/dist/modules/collection/collection.nft.d.ts +8 -0
- package/dist/modules/collection/collection.nft.js +21 -0
- package/dist/modules/collection/collection.nonces.d.ts +5 -0
- package/dist/modules/collection/collection.nonces.js +2 -0
- package/dist/modules/collection/collection.transfer.request.d.ts +12 -0
- package/dist/modules/collection/collection.transfer.request.js +11 -0
- package/dist/modules/collection/index.d.ts +7 -0
- package/dist/modules/collection/index.js +23 -0
- package/package.json +1 -1
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.PrivatelyAuctionSystemClient = void 0;
|
|
7
|
+
const ethers_1 = require("ethers");
|
|
8
|
+
const PrivatelyAuctionSystem_json_1 = __importDefault(require("../../../PrivatelyAuctionSystem.json"));
|
|
9
|
+
const request_signature_1 = require("../../common/request-signature");
|
|
10
|
+
const auctions_auction_1 = require("./auctions.auction");
|
|
11
|
+
const auctions_bid_reqest_1 = require("./auctions.bid.reqest");
|
|
12
|
+
const auctions_create_request_1 = require("./auctions.create.request");
|
|
13
|
+
const auctions_errors_1 = require("./auctions.errors");
|
|
14
|
+
const AUCTION_SYSTEM_ADDRESS = "0x9fe46736679d2d9a65f0992f2272de9f3c7fa6e0";
|
|
15
|
+
class PrivatelyAuctionSystemClient {
|
|
16
|
+
contract;
|
|
17
|
+
signer;
|
|
18
|
+
domain;
|
|
19
|
+
constructor(signer, network) {
|
|
20
|
+
this.signer = signer;
|
|
21
|
+
this.contract = new ethers_1.Contract(AUCTION_SYSTEM_ADDRESS, PrivatelyAuctionSystem_json_1.default.abi, signer);
|
|
22
|
+
const name = PrivatelyAuctionSystem_json_1.default.contractName;
|
|
23
|
+
this.domain = {
|
|
24
|
+
name,
|
|
25
|
+
version: "1.0.0",
|
|
26
|
+
chainId: network.chainId,
|
|
27
|
+
verifyingContract: AUCTION_SYSTEM_ADDRESS
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Retrieves the address of the current deployed contract.
|
|
32
|
+
* @returns The contract address.
|
|
33
|
+
*/
|
|
34
|
+
getContractAddress() {
|
|
35
|
+
return AUCTION_SYSTEM_ADDRESS;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Creates and signs a CreateAuctionRequest using EIP-712 structured data.
|
|
39
|
+
* The request can later be relayed to the contract via `relayCreateAuction`.
|
|
40
|
+
* @param tokenId The ID of the NFT being auctioned.
|
|
41
|
+
* @param startPrice The auction's starting price in wei.
|
|
42
|
+
* @param endTime The timestamp at which the auction ends.
|
|
43
|
+
* @returns An object containing the request struct and its signature.
|
|
44
|
+
*/
|
|
45
|
+
async createAuctionRequest(tokenId, startPrice, endTime) {
|
|
46
|
+
const seller = await this.signer.getAddress();
|
|
47
|
+
const nonce = (await this.getNonces(seller)).createAuctionNonce;
|
|
48
|
+
const request = {
|
|
49
|
+
seller,
|
|
50
|
+
tokenId,
|
|
51
|
+
startPrice,
|
|
52
|
+
endTime,
|
|
53
|
+
nonce
|
|
54
|
+
};
|
|
55
|
+
const signature = await this.signer.signTypedData(this.domain, auctions_create_request_1.AUCTIONS_CREATE_REQUEST_TYPE, request);
|
|
56
|
+
return new request_signature_1.RequestSignature(request_signature_1.RequestType.AUCTION_CREATE, signature, request);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Relays a signed CreateAuctionRequest on-chain. The relayer pays gas.
|
|
60
|
+
* @param request The CreateAuctionRequest struct.
|
|
61
|
+
* @param signature The EIP-712 signature that authorizes creating the auction.
|
|
62
|
+
* @returns A TransactionResponse from ethers.
|
|
63
|
+
*/
|
|
64
|
+
async relayCreateAuctionRequest(request, signature) {
|
|
65
|
+
try {
|
|
66
|
+
return await this.contract.metaCreateAuction(request.seller, request.tokenId, request.startPrice, request.endTime, signature);
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
throw auctions_errors_1.AuctionSystemError.from(error, this.contract);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Creates and signs a BidRequest using EIP-712 structured data.
|
|
74
|
+
* The request can later be relayed to the contract via `relayBid`.
|
|
75
|
+
* @param auctionId The ID of the auction the bidder is bidding on.
|
|
76
|
+
* @param bidAmount The amount in wei the bidder is offering.
|
|
77
|
+
* @returns An object containing the bid request struct and its signature.
|
|
78
|
+
*/
|
|
79
|
+
async createBidRequest(auctionId, bidAmount) {
|
|
80
|
+
const bidder = await this.signer.getAddress();
|
|
81
|
+
const nonce = (await this.getNonces(bidder)).bidNonce;
|
|
82
|
+
const request = {
|
|
83
|
+
bidder,
|
|
84
|
+
auctionId,
|
|
85
|
+
bidAmount,
|
|
86
|
+
nonce
|
|
87
|
+
};
|
|
88
|
+
const signature = await this.signer.signTypedData(this.domain, auctions_bid_reqest_1.AUCTIONS_BID_REQUEST_TYPE, request);
|
|
89
|
+
return new request_signature_1.RequestSignature(request_signature_1.RequestType.AUCTION_BID, signature, request);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Relays a signed bid request (BidRequest) on-chain. The relayer pays gas.
|
|
93
|
+
* IMPORTANT: The relayer must include `bidAmount` in `msg.value` when sending the transaction.
|
|
94
|
+
* @param request The BidRequest struct.
|
|
95
|
+
* @param signature The EIP-712 signature that authorizes the bid.
|
|
96
|
+
* @returns A TransactionResponse from ethers.
|
|
97
|
+
*/
|
|
98
|
+
async relayBidRequest(request, signature) {
|
|
99
|
+
try {
|
|
100
|
+
return await this.contract.metaBidAuction(request.bidder, request.auctionId, request.bidAmount, signature);
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
throw auctions_errors_1.AuctionSystemError.from(error, this.contract);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Finalizes an auction once the endTime is reached. Anyone can call this.
|
|
108
|
+
* @param auctionId The ID of the auction to finalize.
|
|
109
|
+
* @returns A TransactionResponse.
|
|
110
|
+
*/
|
|
111
|
+
async finalizeAuction(auctionId) {
|
|
112
|
+
try {
|
|
113
|
+
return await this.contract.finalizeAuction(auctionId);
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
throw auctions_errors_1.AuctionSystemError.from(error, this.contract);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Allows users to withdraw their pending refunds from previous unsuccessful bids.
|
|
121
|
+
* @returns A TransactionResponse.
|
|
122
|
+
*/
|
|
123
|
+
async withdraw() {
|
|
124
|
+
try {
|
|
125
|
+
return await this.contract.withdraw();
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
throw auctions_errors_1.AuctionSystemError.from(error, this.contract);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Retrieves all auction IDs created in the contract.
|
|
133
|
+
* @returns An array of auction IDs.
|
|
134
|
+
*/
|
|
135
|
+
async getAllAuctions() {
|
|
136
|
+
try {
|
|
137
|
+
return await this.contract.getAllAuctions();
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
throw auctions_errors_1.AuctionSystemError.from(error, this.contract);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Retrieves all active auction IDs in the contract.
|
|
145
|
+
* @returns An array of Auction objects representing active auctions.
|
|
146
|
+
*/
|
|
147
|
+
async getAllActiveAuctions() {
|
|
148
|
+
try {
|
|
149
|
+
const auctionList = await this.contract.getAllActiveAuctions();
|
|
150
|
+
return await auctions_auction_1.Auction.map(auctionList, this);
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
throw auctions_errors_1.AuctionSystemError.from(error, this.contract);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Retrieves all auction IDs created by a specific seller.
|
|
158
|
+
* @param seller The address of the seller to fetch auctions for.
|
|
159
|
+
* @returns An array of Auction objects.
|
|
160
|
+
*/
|
|
161
|
+
async getSellerAuctions(seller) {
|
|
162
|
+
try {
|
|
163
|
+
const auctionList = await this.contract.getSellerAuctions(seller);
|
|
164
|
+
return await auctions_auction_1.Auction.map(auctionList, this);
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
throw auctions_errors_1.AuctionSystemError.from(error, this.contract);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Retrieves all auction IDs created by the client's signer address.
|
|
172
|
+
* @returns An array of Auction objects.
|
|
173
|
+
*/
|
|
174
|
+
async getAuctions() {
|
|
175
|
+
return this.getSellerAuctions(await this.signer.getAddress());
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Retrieves the auction details for a specific auction ID.
|
|
179
|
+
* @param auctionId The ID of the auction to fetch.
|
|
180
|
+
* @returns An Auction object.
|
|
181
|
+
*/
|
|
182
|
+
async getAuction(auctionId) {
|
|
183
|
+
try {
|
|
184
|
+
const auction = await this.contract.getAuction(auctionId);
|
|
185
|
+
return new auctions_auction_1.Auction(auctionId, auction.seller, auction.tokenId, auction.startPrice, auction.highestBid, auction.highestBidder, auction.endTime, auction.settled);
|
|
186
|
+
}
|
|
187
|
+
catch (error) {
|
|
188
|
+
throw auctions_errors_1.AuctionSystemError.from(error, this.contract);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Registers a listener for the "OnCreate" event emitted by the contract when an auction is created.
|
|
193
|
+
* @param listener A callback function to be executed when the "OnCreate" event is triggered.
|
|
194
|
+
*/
|
|
195
|
+
onCreateEvent(listener) {
|
|
196
|
+
void this.contract.on("OnCreate", (auctionId, seller, tokenId, startPrice, endTime, event) => {
|
|
197
|
+
listener(auctionId, seller, tokenId, startPrice, endTime, event);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Registers a listener for the "OnBid" event emitted by the contract when a bid is placed.
|
|
202
|
+
* @param listener A callback function to be executed when the "OnBid" event is triggered.
|
|
203
|
+
*/
|
|
204
|
+
onBidEvent(listener) {
|
|
205
|
+
void this.contract.on("OnBid", (auctionId, bidder, bidAmount, event) => {
|
|
206
|
+
listener(auctionId, bidder, bidAmount, event);
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Registers a listener for the "OnEnd" event emitted by the contract when an auction ends.
|
|
211
|
+
* @param listener A callback function to be executed when the "OnEnd" event is triggered.
|
|
212
|
+
*/
|
|
213
|
+
onEndEvent(listener) {
|
|
214
|
+
void this.contract.on("OnEnd", (auctionId, tokenId, highestBidder, highestBid, event) => {
|
|
215
|
+
listener(auctionId, tokenId, highestBidder, highestBid, event);
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Registers a listener for the "OnWithdraw" event emitted by the contract when a user withdraws funds.
|
|
220
|
+
* @param listener A callback function to be executed when the "OnWithdraw" event is triggered.
|
|
221
|
+
*/
|
|
222
|
+
onWithdrawEvent(listener) {
|
|
223
|
+
void this.contract.on("OnWithdraw", (user, amount, event) => {
|
|
224
|
+
listener(user, amount, event);
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Retrieves all auctions (settled or not) for a given tokenId,
|
|
229
|
+
* and maps them into Auction instances via Auction.map().
|
|
230
|
+
* @param tokenId The NFT identifier.
|
|
231
|
+
* @returns A list of Auction objects.
|
|
232
|
+
*/
|
|
233
|
+
async getAuctionsByToken(tokenId) {
|
|
234
|
+
try {
|
|
235
|
+
const rawList = await this.contract.getAuctionsByToken(tokenId);
|
|
236
|
+
return rawList.map(raw => new auctions_auction_1.Auction(raw[1], raw[0], tokenId, raw[2], raw[3], raw[4], raw[5], raw[6]));
|
|
237
|
+
}
|
|
238
|
+
catch (error) {
|
|
239
|
+
throw auctions_errors_1.AuctionSystemError.from(error, this.contract);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Fetches the current nonces for a user.
|
|
244
|
+
* @param userAddress The address of the user to fetch the nonce for.
|
|
245
|
+
* @returns An object containing the nonces.
|
|
246
|
+
*/
|
|
247
|
+
async getNonces(userAddress) {
|
|
248
|
+
try {
|
|
249
|
+
const nonce = await this.contract.getNonces(userAddress);
|
|
250
|
+
return { createAuctionNonce: nonce.createAuctionNonce, bidNonce: nonce.bidNonce };
|
|
251
|
+
}
|
|
252
|
+
catch (error) {
|
|
253
|
+
throw auctions_errors_1.AuctionSystemError.from(error, this.contract);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Retrieves all auctions where the user has placed at least one bid.
|
|
258
|
+
* @param userAddress The address of the user to fetch auctions for.
|
|
259
|
+
* @returns An array of Auction objects where the user has bid.
|
|
260
|
+
*/
|
|
261
|
+
async getUserBidAuctions(userAddress) {
|
|
262
|
+
try {
|
|
263
|
+
const auctionIds = await this.contract.getUserBidAuctions(userAddress);
|
|
264
|
+
return await auctions_auction_1.Auction.map(auctionIds, this);
|
|
265
|
+
}
|
|
266
|
+
catch (error) {
|
|
267
|
+
throw auctions_errors_1.AuctionSystemError.from(error, this.contract);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Retrieves all active auctions where the user has placed at least one bid.
|
|
272
|
+
* @param userAddress The address of the user to fetch active auctions for.
|
|
273
|
+
* @returns An array of active Auction objects where the user has bid.
|
|
274
|
+
*/
|
|
275
|
+
async getUserActiveBidAuctions(userAddress) {
|
|
276
|
+
try {
|
|
277
|
+
const auctionIds = await this.contract.getUserActiveBidAuctions(userAddress);
|
|
278
|
+
return await auctions_auction_1.Auction.map(auctionIds, this);
|
|
279
|
+
}
|
|
280
|
+
catch (error) {
|
|
281
|
+
throw auctions_errors_1.AuctionSystemError.from(error, this.contract);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Retrieves all auctions where the current signer has placed at least one bid.
|
|
286
|
+
* @returns An array of Auction objects where the signer has bid.
|
|
287
|
+
*/
|
|
288
|
+
async getBidAuctions() {
|
|
289
|
+
return this.getUserBidAuctions(await this.signer.getAddress());
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Retrieves all active auctions where the current signer has placed at least one bid.
|
|
293
|
+
* @returns An array of active Auction objects where the signer has bid.
|
|
294
|
+
*/
|
|
295
|
+
async getActiveBidAuctions() {
|
|
296
|
+
return this.getUserActiveBidAuctions(await this.signer.getAddress());
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Retrieves all expired but unfinalized auction IDs in the contract.
|
|
300
|
+
* @returns An array of expired auction objects that need to be finalized.
|
|
301
|
+
*/
|
|
302
|
+
async getAllExpiredUnfinalizedAuctions() {
|
|
303
|
+
try {
|
|
304
|
+
const auctionList = await this.contract.getAllExpiredUnfinalizedAuctions();
|
|
305
|
+
return await auctions_auction_1.Auction.map(auctionList, this);
|
|
306
|
+
}
|
|
307
|
+
catch (error) {
|
|
308
|
+
throw auctions_errors_1.AuctionSystemError.from(error, this.contract);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
exports.PrivatelyAuctionSystemClient = PrivatelyAuctionSystemClient;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface CreateAuctionRequest {
|
|
2
|
+
seller: string;
|
|
3
|
+
tokenId: bigint;
|
|
4
|
+
startPrice: bigint;
|
|
5
|
+
endTime: bigint;
|
|
6
|
+
nonce: bigint;
|
|
7
|
+
}
|
|
8
|
+
export declare const AUCTIONS_CREATE_REQUEST_TYPE: {
|
|
9
|
+
CreateAuctionRequest: {
|
|
10
|
+
name: string;
|
|
11
|
+
type: string;
|
|
12
|
+
}[];
|
|
13
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AUCTIONS_CREATE_REQUEST_TYPE = void 0;
|
|
4
|
+
exports.AUCTIONS_CREATE_REQUEST_TYPE = {
|
|
5
|
+
CreateAuctionRequest: [
|
|
6
|
+
{ name: "seller", type: "address" },
|
|
7
|
+
{ name: "tokenId", type: "uint256" },
|
|
8
|
+
{ name: "startPrice", type: "uint256" },
|
|
9
|
+
{ name: "endTime", type: "uint256" },
|
|
10
|
+
{ name: "nonce", type: "uint256" }
|
|
11
|
+
]
|
|
12
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Contract } from "ethers";
|
|
2
|
+
import { PrivatelyError } from "../../common/privately.error";
|
|
3
|
+
export declare class AuctionSystemError extends PrivatelyError {
|
|
4
|
+
constructor(message: string);
|
|
5
|
+
static from(error: any, contract?: Contract): AuctionSystemError;
|
|
6
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuctionSystemError = void 0;
|
|
4
|
+
const privately_error_1 = require("../../common/privately.error");
|
|
5
|
+
class AuctionSystemError extends privately_error_1.PrivatelyError {
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(`AuctionSystemError: ${message}`);
|
|
8
|
+
this.name = "AuctionSystemError";
|
|
9
|
+
}
|
|
10
|
+
static from(error, contract) {
|
|
11
|
+
return new AuctionSystemError((0, privately_error_1.parseContractError)(error, contract?.interface));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.AuctionSystemError = AuctionSystemError;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Log } from "ethers/lib.esm";
|
|
2
|
+
export type OnCreateListener = (auctionId: bigint, seller: string, tokenId: bigint, startPrice: bigint, endTime: bigint, event: Log) => void;
|
|
3
|
+
export type OnBidListener = (auctionId: bigint, bidder: string, bidAmount: bigint, event: Log) => void;
|
|
4
|
+
export type OnEnd = (auctionId: bigint, tokenId: bigint, highestBidder: string, highestBid: bigint, event: Log) => void;
|
|
5
|
+
export type OnWithdrawListener = (user: string, amount: bigint, event: Log) => void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./auctions.auction"), exports);
|
|
18
|
+
__exportStar(require("./auctions.bid.reqest"), exports);
|
|
19
|
+
__exportStar(require("./auctions.client"), exports);
|
|
20
|
+
__exportStar(require("./auctions.create.request"), exports);
|
|
21
|
+
__exportStar(require("./auctions.errors"), exports);
|
|
22
|
+
__exportStar(require("./auctions.nonces"), exports);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.COLLECTION_APPROVE_REQUEST_TYPE = void 0;
|
|
4
|
+
exports.COLLECTION_APPROVE_REQUEST_TYPE = {
|
|
5
|
+
ApproveRequest: [
|
|
6
|
+
{ name: "owner", type: "address" },
|
|
7
|
+
{ name: "spender", type: "address" },
|
|
8
|
+
{ name: "tokenId", type: "uint256" },
|
|
9
|
+
{ name: "nonce", type: "uint256" }
|
|
10
|
+
]
|
|
11
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Contract, Network, Signer, TransactionResponse } from "ethers";
|
|
2
|
+
import { RequestSignature } from "../../common/request-signature";
|
|
3
|
+
import { CollectionApproveRequest } from "./collection.approve.request";
|
|
4
|
+
import { OnMintListener, OnTransferListener } from "./collection.events";
|
|
5
|
+
import { CollectionMintRequest } from "./collection.mint.request";
|
|
6
|
+
import { PrivatelyNFT } from "./collection.nft";
|
|
7
|
+
import { CollectionTransferRequest } from "./collection.transfer.request";
|
|
8
|
+
export declare class PrivatelyCollectionClient {
|
|
9
|
+
readonly contract: Contract;
|
|
10
|
+
private readonly signer;
|
|
11
|
+
private readonly domain;
|
|
12
|
+
constructor(signer: Signer, network: Network);
|
|
13
|
+
/**
|
|
14
|
+
* Retrieves a list of all NFT token IDs currently stored in the contract.
|
|
15
|
+
* @returns An array of token IDs as bigint.
|
|
16
|
+
*/
|
|
17
|
+
getSupplyCollection(): Promise<bigint[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Retrieves the list of NFT token IDs owned by a specific user.
|
|
20
|
+
* @param owner The address of the user whose Collection should be retrieved.
|
|
21
|
+
* @returns An array of token IDs as bigint.
|
|
22
|
+
*/
|
|
23
|
+
getUserCollection(owner: string): Promise<PrivatelyNFT[]>;
|
|
24
|
+
/**
|
|
25
|
+
* Retrieves the list of NFT token IDs owned by the client's signer address.
|
|
26
|
+
* @returns An array of token IDs as bigint.
|
|
27
|
+
*/
|
|
28
|
+
getCollection(): Promise<PrivatelyNFT[]>;
|
|
29
|
+
/**
|
|
30
|
+
* Fetches the metadata for a specific NFT token ID.
|
|
31
|
+
* @param tokenId The ID of the NFT (as BigNumberish).
|
|
32
|
+
* @returns A PrivatelyNFT object containing the NFT's metadata.
|
|
33
|
+
*/
|
|
34
|
+
getData(tokenId: bigint): Promise<PrivatelyNFT>;
|
|
35
|
+
/**
|
|
36
|
+
* Creates and signs a MintRequest using EIP-712 structured data.
|
|
37
|
+
* This request can later be relayed to the contract via `relayMintRequest`.
|
|
38
|
+
* @param title The NFT title.
|
|
39
|
+
* @param tokenURI The URI for the NFT metadata.
|
|
40
|
+
* @returns An object containing the mint request struct and its EIP-712 signature.
|
|
41
|
+
*/
|
|
42
|
+
createMintRequest(title: string, tokenURI: string): Promise<RequestSignature<CollectionMintRequest>>;
|
|
43
|
+
/**
|
|
44
|
+
* Relays a signed mint request to the blockchain.
|
|
45
|
+
* The relayer (caller of this function) is responsible for the transaction's gas cost.
|
|
46
|
+
* @param request The MintRequest object containing user, title, author, tokenURI, and nonce.
|
|
47
|
+
* @param signature The EIP-712 signature that authorizes this mint.
|
|
48
|
+
* @returns A TransactionResponse object from ethers.
|
|
49
|
+
*/
|
|
50
|
+
relayMintRequest(request: CollectionMintRequest, signature: string): Promise<TransactionResponse>;
|
|
51
|
+
/**
|
|
52
|
+
* Creates and signs a TransferRequest using EIP-712 structured data.
|
|
53
|
+
* This request can later be relayed to the contract via `relayTransferRequest`.
|
|
54
|
+
* @param to The address to which the NFT should be transferred.
|
|
55
|
+
* @param tokenId The ID of the NFT (BigNumberish).
|
|
56
|
+
* @returns An object containing the transfer request struct and its EIP-712 signature.
|
|
57
|
+
*/
|
|
58
|
+
createTransferRequest(to: string, tokenId: bigint): Promise<RequestSignature<CollectionTransferRequest>>;
|
|
59
|
+
/**
|
|
60
|
+
* Relays a signed transfer request to the blockchain.
|
|
61
|
+
* The relayer (caller of this function) is responsible for the transaction's gas cost.
|
|
62
|
+
* @param request The TransferRequest object containing from, to, tokenId, and nonce.
|
|
63
|
+
* @param signature The EIP-712 signature that authorizes this transfer.
|
|
64
|
+
* @returns A TransactionResponse object from ethers.
|
|
65
|
+
*/
|
|
66
|
+
relayTransferRequest(request: CollectionTransferRequest, signature: string): Promise<TransactionResponse>;
|
|
67
|
+
/**
|
|
68
|
+
* Creates and signs an ApproveRequest using EIP-712 structured data.
|
|
69
|
+
* @param spender The address to which the approval should be granted.
|
|
70
|
+
* @param tokenId The ID of the NFT (BigNumberish).
|
|
71
|
+
* @returns An object containing the approval request struct and its EIP-712 signature.
|
|
72
|
+
*/
|
|
73
|
+
createApproveRequest(spender: string, tokenId: bigint): Promise<RequestSignature<CollectionApproveRequest>>;
|
|
74
|
+
/**
|
|
75
|
+
* Relays a signed approval request to the blockchain.
|
|
76
|
+
* The relayer (caller of this function) is responsible for the transaction's gas cost.
|
|
77
|
+
* @param request The ApproveRequest object containing owner, spender, tokenId, and nonce.
|
|
78
|
+
* @param signature The EIP-712 signature that authorizes this approval.
|
|
79
|
+
* @returns A TransactionResponse object from ethers.
|
|
80
|
+
*/
|
|
81
|
+
relayApproveRequest(request: CollectionApproveRequest, signature: string): Promise<TransactionResponse>;
|
|
82
|
+
/**
|
|
83
|
+
* Registers a listener for the "OnMint" event emitted by the contract when a new NFT is minted.
|
|
84
|
+
* @param listener A callback function to be executed when the "OnMint" event is triggered.
|
|
85
|
+
*/
|
|
86
|
+
onMintEvent(listener: OnMintListener): void;
|
|
87
|
+
/**
|
|
88
|
+
* Subscribes a listener to the "OnTransfer" event emitted by the contract when a NFT transfer is executed.
|
|
89
|
+
* @param listener A callback function to be executed when the "OnTransfer" event is triggered.
|
|
90
|
+
*/
|
|
91
|
+
onTransferEvent(listener: OnTransferListener): void;
|
|
92
|
+
/**
|
|
93
|
+
* Retrieves current nonce for meta-transactions
|
|
94
|
+
* @returns Current nonce for signer's address
|
|
95
|
+
*/
|
|
96
|
+
private getNonces;
|
|
97
|
+
}
|