privately-smartcontract-lib 1.0.2

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.
Files changed (65) hide show
  1. package/PrivatelyAuctionSystem.json +734 -0
  2. package/PrivatelyCoin.json +863 -0
  3. package/PrivatelyCollection.json +865 -0
  4. package/dist/PrivatelyAuctionSystem.json +734 -0
  5. package/dist/PrivatelyCoin.json +863 -0
  6. package/dist/PrivatelyCollection.json +865 -0
  7. package/dist/client.d.ts +38 -0
  8. package/dist/client.js +67 -0
  9. package/dist/common/index.d.ts +2 -0
  10. package/dist/common/index.js +18 -0
  11. package/dist/common/privately.error.d.ts +5 -0
  12. package/dist/common/privately.error.js +47 -0
  13. package/dist/common/request-signature.d.ts +17 -0
  14. package/dist/common/request-signature.js +38 -0
  15. package/dist/index.d.ts +5 -0
  16. package/dist/index.js +21 -0
  17. package/dist/modules/auctions/auctions.auction.d.ts +12 -0
  18. package/dist/modules/auctions/auctions.auction.js +29 -0
  19. package/dist/modules/auctions/auctions.bid.reqest.d.ts +12 -0
  20. package/dist/modules/auctions/auctions.bid.reqest.js +11 -0
  21. package/dist/modules/auctions/auctions.client.d.ts +147 -0
  22. package/dist/modules/auctions/auctions.client.js +312 -0
  23. package/dist/modules/auctions/auctions.create.request.d.ts +13 -0
  24. package/dist/modules/auctions/auctions.create.request.js +12 -0
  25. package/dist/modules/auctions/auctions.errors.d.ts +6 -0
  26. package/dist/modules/auctions/auctions.errors.js +14 -0
  27. package/dist/modules/auctions/auctions.events.d.ts +5 -0
  28. package/dist/modules/auctions/auctions.events.js +2 -0
  29. package/dist/modules/auctions/auctions.nonces.d.ts +4 -0
  30. package/dist/modules/auctions/auctions.nonces.js +2 -0
  31. package/dist/modules/auctions/index.d.ts +6 -0
  32. package/dist/modules/auctions/index.js +22 -0
  33. package/dist/modules/coin/coin.approve.request.d.ts +8 -0
  34. package/dist/modules/coin/coin.approve.request.js +11 -0
  35. package/dist/modules/coin/coin.client.d.ts +120 -0
  36. package/dist/modules/coin/coin.client.js +246 -0
  37. package/dist/modules/coin/coin.errors.d.ts +6 -0
  38. package/dist/modules/coin/coin.errors.js +23 -0
  39. package/dist/modules/coin/coin.events.d.ts +3 -0
  40. package/dist/modules/coin/coin.events.js +2 -0
  41. package/dist/modules/coin/coin.nonces.d.ts +4 -0
  42. package/dist/modules/coin/coin.nonces.js +2 -0
  43. package/dist/modules/coin/coin.transfer.request.d.ts +8 -0
  44. package/dist/modules/coin/coin.transfer.request.js +11 -0
  45. package/dist/modules/coin/index.d.ts +5 -0
  46. package/dist/modules/coin/index.js +21 -0
  47. package/dist/modules/collection/collection.approve.request.d.ts +8 -0
  48. package/dist/modules/collection/collection.approve.request.js +11 -0
  49. package/dist/modules/collection/collection.client.d.ts +97 -0
  50. package/dist/modules/collection/collection.client.js +224 -0
  51. package/dist/modules/collection/collection.errors.d.ts +6 -0
  52. package/dist/modules/collection/collection.errors.js +14 -0
  53. package/dist/modules/collection/collection.events.d.ts +3 -0
  54. package/dist/modules/collection/collection.events.js +2 -0
  55. package/dist/modules/collection/collection.mint.request.d.ts +9 -0
  56. package/dist/modules/collection/collection.mint.request.js +12 -0
  57. package/dist/modules/collection/collection.nft.d.ts +8 -0
  58. package/dist/modules/collection/collection.nft.js +21 -0
  59. package/dist/modules/collection/collection.nonces.d.ts +5 -0
  60. package/dist/modules/collection/collection.nonces.js +2 -0
  61. package/dist/modules/collection/collection.transfer.request.d.ts +12 -0
  62. package/dist/modules/collection/collection.transfer.request.js +11 -0
  63. package/dist/modules/collection/index.d.ts +7 -0
  64. package/dist/modules/collection/index.js +23 -0
  65. package/package.json +53 -0
@@ -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,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,4 @@
1
+ export interface AuctionsNonces {
2
+ createAuctionNonce: bigint;
3
+ bidNonce: bigint;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ export * from "./auctions.auction";
2
+ export * from "./auctions.bid.reqest";
3
+ export * from "./auctions.client";
4
+ export * from "./auctions.create.request";
5
+ export * from "./auctions.errors";
6
+ export * from "./auctions.nonces";
@@ -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,8 @@
1
+ import { TypedDataField } from "ethers";
2
+ export interface CoinApproveRequest {
3
+ owner: string;
4
+ spender: string;
5
+ amount: bigint;
6
+ nonce: bigint;
7
+ }
8
+ export declare const APPROVE_REQUEST_TYPE: Record<string, TypedDataField[]>;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.APPROVE_REQUEST_TYPE = void 0;
4
+ exports.APPROVE_REQUEST_TYPE = {
5
+ ApproveRequest: [
6
+ { name: "owner", type: "address" },
7
+ { name: "spender", type: "address" },
8
+ { name: "amount", type: "uint256" },
9
+ { name: "nonce", type: "uint256" }
10
+ ]
11
+ };
@@ -0,0 +1,120 @@
1
+ import { Contract, Network, Signer, TransactionResponse } from "ethers";
2
+ import { RequestSignature } from "../../common/request-signature";
3
+ import { CoinApproveRequest } from "./coin.approve.request";
4
+ import { OnMintListener, OnTransferListener } from "./coin.events";
5
+ import { CoinTransferRequest } from "./coin.transfer.request";
6
+ /**
7
+ * CoinClient class to interact with the PrivatelyCoin smart contract
8
+ */
9
+ export declare class PrivatelyCoinClient {
10
+ readonly contract: Contract;
11
+ private readonly signer;
12
+ private readonly domain;
13
+ /**
14
+ * Constructs a CoinClient instance to interact with the token contract
15
+ * @param signer The transaction signer (wallet with private key)
16
+ * @param network Network configuration for blockchain connection
17
+ */
18
+ constructor(signer: Signer, network: Network);
19
+ /**
20
+ * Retrieves the address of the current deployed contract.
21
+ * @returns The contract address.
22
+ */
23
+ getContractAddress(): string;
24
+ /**
25
+ * Creates a signed transfer request for meta-transaction execution
26
+ * @param to Recipient address
27
+ * @param amount Token amount to transfer
28
+ * @returns Promise containing transfer request and EIP-712 signature
29
+ */
30
+ createTransferRequest(to: string, amount: bigint): Promise<RequestSignature<CoinTransferRequest>>;
31
+ /**
32
+ * Relays a signed transfer request to execute as a meta-transaction
33
+ * @param request Signed transfer request object
34
+ * @param signature EIP-712 signature of the request
35
+ * @returns Blockchain transaction response
36
+ */
37
+ relayTransferRequest(request: CoinTransferRequest, signature: string): Promise<TransactionResponse>;
38
+ /**
39
+ * Creates a signed allowance approval request for meta-transaction execution
40
+ * @param spender Authorized spending address
41
+ * @param amount Approved token amount
42
+ * @returns Promise containing approval request and EIP-712 signature
43
+ */
44
+ createApproveRequest(spender: string, amount: bigint): Promise<RequestSignature<CoinApproveRequest>>;
45
+ /**
46
+ * Relays a signed approval request to execute as a meta-transaction
47
+ * @param request Signed approval request object
48
+ * @param signature EIP-712 signature of the request
49
+ * @returns Blockchain transaction response
50
+ * @throws If signature verification fails or nonce mismatch occurs
51
+ */
52
+ relayApproveRequest(request: CoinApproveRequest, signature: string): Promise<TransactionResponse>;
53
+ /**
54
+ * Mints new tokens (requires minter role)
55
+ * @param to Recipient address
56
+ * @param amount Amount to mint
57
+ * @returns Blockchain transaction response
58
+ */
59
+ mint(to: string, amount: bigint): Promise<TransactionResponse>;
60
+ /**
61
+ * Executes standard ERC20 token transfer
62
+ * @param to Recipient address
63
+ * @param amount Amount to transfer
64
+ * @returns Blockchain transaction response
65
+ */
66
+ transfer(to: string, amount: bigint): Promise<TransactionResponse>;
67
+ /**
68
+ * Approves spending allowance for a spender address
69
+ * @param spender Authorized spending address
70
+ * @param amount Approved amount
71
+ * @returns Blockchain transaction response
72
+ */
73
+ approve(spender: string, amount: bigint): Promise<TransactionResponse>;
74
+ /**
75
+ * Gets remaining approved spending allowance
76
+ * @param owner Token owner address
77
+ * @param spender Authorized spender address
78
+ * @returns Remaining allowed amount
79
+ */
80
+ allowance(owner: string, spender: string): Promise<bigint>;
81
+ /**
82
+ * Transfers tokens from an approved address
83
+ * @param from Source address (must have allowance)
84
+ * @param to Recipient address
85
+ * @param amount Amount to transfer
86
+ * @returns Blockchain transaction response
87
+ */
88
+ transferFrom(from: string, to: string, amount: bigint): Promise<TransactionResponse>;
89
+ /**
90
+ * Retrieves total token supply
91
+ * @returns Total circulating token amount
92
+ */
93
+ totalSupply(): Promise<bigint>;
94
+ /**
95
+ * Gets token balance for a specific address
96
+ * @param user Address to check
97
+ * @returns Current token balance
98
+ */
99
+ getUserBalance(user: string): Promise<bigint>;
100
+ /**
101
+ * Retrieves current balance for the signer's address
102
+ * @returns Current token balance for signer
103
+ */
104
+ getBalance(): Promise<bigint>;
105
+ /**
106
+ * Registers a listener for the "OnMint" event emitted by the contract when new coins are minted.
107
+ * @param listener A callback function to be executed when the "OnMint" event is triggered.
108
+ */
109
+ onMintEvent(listener: OnMintListener): void;
110
+ /**
111
+ * Subscribes a listener to the "OnTransfer" event emitted by the contract when a transaction is executed.
112
+ * @param listener A callback function to be executed when the "OnTransfer" event is triggered.
113
+ */
114
+ onTransferEvent(listener: OnTransferListener): void;
115
+ /**
116
+ * Retrieves the current nonce for transfer and approve requests
117
+ * @returns Current nonces for signer's address
118
+ */
119
+ private getNonces;
120
+ }