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.
- package/PrivatelyAuctionSystem.json +734 -0
- package/PrivatelyCoin.json +863 -0
- package/PrivatelyCollection.json +865 -0
- package/dist/PrivatelyAuctionSystem.json +734 -0
- package/dist/PrivatelyCoin.json +863 -0
- package/dist/PrivatelyCollection.json +865 -0
- package/dist/client.d.ts +38 -0
- package/dist/client.js +67 -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 +38 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +21 -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/coin/coin.approve.request.d.ts +8 -0
- package/dist/modules/coin/coin.approve.request.js +11 -0
- package/dist/modules/coin/coin.client.d.ts +120 -0
- package/dist/modules/coin/coin.client.js +246 -0
- package/dist/modules/coin/coin.errors.d.ts +6 -0
- package/dist/modules/coin/coin.errors.js +23 -0
- package/dist/modules/coin/coin.events.d.ts +3 -0
- package/dist/modules/coin/coin.events.js +2 -0
- package/dist/modules/coin/coin.nonces.d.ts +4 -0
- package/dist/modules/coin/coin.nonces.js +2 -0
- package/dist/modules/coin/coin.transfer.request.d.ts +8 -0
- package/dist/modules/coin/coin.transfer.request.js +11 -0
- package/dist/modules/coin/index.d.ts +5 -0
- package/dist/modules/coin/index.js +21 -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 +53 -0
|
@@ -0,0 +1,246 @@
|
|
|
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.PrivatelyCoinClient = void 0;
|
|
7
|
+
const ethers_1 = require("ethers");
|
|
8
|
+
const PrivatelyCoin_json_1 = __importDefault(require("../../../PrivatelyCoin.json"));
|
|
9
|
+
const request_signature_1 = require("../../common/request-signature");
|
|
10
|
+
const coin_approve_request_1 = require("./coin.approve.request");
|
|
11
|
+
const coin_errors_1 = require("./coin.errors");
|
|
12
|
+
const coin_transfer_request_1 = require("./coin.transfer.request");
|
|
13
|
+
const COIN_CONTRACT_ADDRESS = "0x5fbdb2315678afecb367f032d93f642f64180aa3";
|
|
14
|
+
/**
|
|
15
|
+
* CoinClient class to interact with the PrivatelyCoin smart contract
|
|
16
|
+
*/
|
|
17
|
+
class PrivatelyCoinClient {
|
|
18
|
+
contract;
|
|
19
|
+
signer;
|
|
20
|
+
domain;
|
|
21
|
+
/**
|
|
22
|
+
* Constructs a CoinClient instance to interact with the token contract
|
|
23
|
+
* @param signer The transaction signer (wallet with private key)
|
|
24
|
+
* @param network Network configuration for blockchain connection
|
|
25
|
+
*/
|
|
26
|
+
constructor(signer, network) {
|
|
27
|
+
this.signer = signer;
|
|
28
|
+
this.contract = new ethers_1.Contract(COIN_CONTRACT_ADDRESS, PrivatelyCoin_json_1.default.abi, signer);
|
|
29
|
+
const name = PrivatelyCoin_json_1.default.contractName;
|
|
30
|
+
this.domain = {
|
|
31
|
+
name,
|
|
32
|
+
version: "1.0.0",
|
|
33
|
+
chainId: network.chainId,
|
|
34
|
+
verifyingContract: COIN_CONTRACT_ADDRESS
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Retrieves the address of the current deployed contract.
|
|
39
|
+
* @returns The contract address.
|
|
40
|
+
*/
|
|
41
|
+
getContractAddress() {
|
|
42
|
+
return COIN_CONTRACT_ADDRESS;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Creates a signed transfer request for meta-transaction execution
|
|
46
|
+
* @param to Recipient address
|
|
47
|
+
* @param amount Token amount to transfer
|
|
48
|
+
* @returns Promise containing transfer request and EIP-712 signature
|
|
49
|
+
*/
|
|
50
|
+
async createTransferRequest(to, amount) {
|
|
51
|
+
const from = await this.signer.getAddress();
|
|
52
|
+
const nonce = (await this.getNonces()).transferNonce;
|
|
53
|
+
const request = {
|
|
54
|
+
from: from,
|
|
55
|
+
to: to,
|
|
56
|
+
amount: amount,
|
|
57
|
+
nonce: nonce
|
|
58
|
+
};
|
|
59
|
+
const signature = await this.signer.signTypedData(this.domain, coin_transfer_request_1.TRANSFER_REQUEST_TYPE, request);
|
|
60
|
+
return new request_signature_1.RequestSignature(request_signature_1.RequestType.COIN_TRANSFER, signature, request);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Relays a signed transfer request to execute as a meta-transaction
|
|
64
|
+
* @param request Signed transfer request object
|
|
65
|
+
* @param signature EIP-712 signature of the request
|
|
66
|
+
* @returns Blockchain transaction response
|
|
67
|
+
*/
|
|
68
|
+
async relayTransferRequest(request, signature) {
|
|
69
|
+
try {
|
|
70
|
+
return await this.contract.metaTransfer(request.from, request.to, request.amount, signature);
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
throw coin_errors_1.CoinError.from(error, this.contract);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Creates a signed allowance approval request for meta-transaction execution
|
|
78
|
+
* @param spender Authorized spending address
|
|
79
|
+
* @param amount Approved token amount
|
|
80
|
+
* @returns Promise containing approval request and EIP-712 signature
|
|
81
|
+
*/
|
|
82
|
+
async createApproveRequest(spender, amount) {
|
|
83
|
+
const owner = await this.signer.getAddress();
|
|
84
|
+
const nonce = (await this.getNonces()).approveNonce;
|
|
85
|
+
const request = {
|
|
86
|
+
owner: owner,
|
|
87
|
+
spender: spender,
|
|
88
|
+
amount: amount,
|
|
89
|
+
nonce: nonce
|
|
90
|
+
};
|
|
91
|
+
const signature = await this.signer.signTypedData(this.domain, coin_approve_request_1.APPROVE_REQUEST_TYPE, request);
|
|
92
|
+
return new request_signature_1.RequestSignature(request_signature_1.RequestType.COIN_APPROVE, signature, request);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Relays a signed approval request to execute as a meta-transaction
|
|
96
|
+
* @param request Signed approval request object
|
|
97
|
+
* @param signature EIP-712 signature of the request
|
|
98
|
+
* @returns Blockchain transaction response
|
|
99
|
+
* @throws If signature verification fails or nonce mismatch occurs
|
|
100
|
+
*/
|
|
101
|
+
async relayApproveRequest(request, signature) {
|
|
102
|
+
try {
|
|
103
|
+
return await this.contract.metaApprove(request.owner, request.spender, request.amount, signature);
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
throw coin_errors_1.CoinError.from(error, this.contract);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Mints new tokens (requires minter role)
|
|
111
|
+
* @param to Recipient address
|
|
112
|
+
* @param amount Amount to mint
|
|
113
|
+
* @returns Blockchain transaction response
|
|
114
|
+
*/
|
|
115
|
+
async mint(to, amount) {
|
|
116
|
+
try {
|
|
117
|
+
return await this.contract.mint(to, amount);
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
throw coin_errors_1.CoinError.from(error, this.contract);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Executes standard ERC20 token transfer
|
|
125
|
+
* @param to Recipient address
|
|
126
|
+
* @param amount Amount to transfer
|
|
127
|
+
* @returns Blockchain transaction response
|
|
128
|
+
*/
|
|
129
|
+
async transfer(to, amount) {
|
|
130
|
+
try {
|
|
131
|
+
return await this.contract.transfer(to, amount);
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
throw coin_errors_1.CoinError.from(error, this.contract);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Approves spending allowance for a spender address
|
|
139
|
+
* @param spender Authorized spending address
|
|
140
|
+
* @param amount Approved amount
|
|
141
|
+
* @returns Blockchain transaction response
|
|
142
|
+
*/
|
|
143
|
+
async approve(spender, amount) {
|
|
144
|
+
try {
|
|
145
|
+
return await this.contract.approve(spender, amount);
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
throw coin_errors_1.CoinError.from(error, this.contract);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Gets remaining approved spending allowance
|
|
153
|
+
* @param owner Token owner address
|
|
154
|
+
* @param spender Authorized spender address
|
|
155
|
+
* @returns Remaining allowed amount
|
|
156
|
+
*/
|
|
157
|
+
async allowance(owner, spender) {
|
|
158
|
+
try {
|
|
159
|
+
return await this.contract.allowance(owner, spender);
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
throw coin_errors_1.CoinError.from(error, this.contract);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Transfers tokens from an approved address
|
|
167
|
+
* @param from Source address (must have allowance)
|
|
168
|
+
* @param to Recipient address
|
|
169
|
+
* @param amount Amount to transfer
|
|
170
|
+
* @returns Blockchain transaction response
|
|
171
|
+
*/
|
|
172
|
+
async transferFrom(from, to, amount) {
|
|
173
|
+
try {
|
|
174
|
+
return await this.contract.transferFrom(from, to, amount);
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
throw coin_errors_1.CoinError.from(error, this.contract);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Retrieves total token supply
|
|
182
|
+
* @returns Total circulating token amount
|
|
183
|
+
*/
|
|
184
|
+
async totalSupply() {
|
|
185
|
+
try {
|
|
186
|
+
return await this.contract.totalSupply();
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
throw coin_errors_1.CoinError.from(error, this.contract);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Gets token balance for a specific address
|
|
194
|
+
* @param user Address to check
|
|
195
|
+
* @returns Current token balance
|
|
196
|
+
*/
|
|
197
|
+
async getUserBalance(user) {
|
|
198
|
+
try {
|
|
199
|
+
return this.contract.balanceOf(user);
|
|
200
|
+
}
|
|
201
|
+
catch (error) {
|
|
202
|
+
throw coin_errors_1.CoinError.from(error, this.contract);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Retrieves current balance for the signer's address
|
|
207
|
+
* @returns Current token balance for signer
|
|
208
|
+
*/
|
|
209
|
+
async getBalance() {
|
|
210
|
+
const selfAddress = await this.signer.getAddress();
|
|
211
|
+
return this.getUserBalance(selfAddress);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Registers a listener for the "OnMint" event emitted by the contract when new coins are minted.
|
|
215
|
+
* @param listener A callback function to be executed when the "OnMint" event is triggered.
|
|
216
|
+
*/
|
|
217
|
+
onMintEvent(listener) {
|
|
218
|
+
void this.contract.on("OnMint", (to, amount, finalBalance, event) => {
|
|
219
|
+
listener(to, amount, finalBalance, event);
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Subscribes a listener to the "OnTransfer" event emitted by the contract when a transaction is executed.
|
|
224
|
+
* @param listener A callback function to be executed when the "OnTransfer" event is triggered.
|
|
225
|
+
*/
|
|
226
|
+
onTransferEvent(listener) {
|
|
227
|
+
void this.contract.on("OnTransfer", (from, to, amount, fromFinalBalance, toFinalBalance, event) => {
|
|
228
|
+
listener(from, to, amount, fromFinalBalance, toFinalBalance, event);
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Retrieves the current nonce for transfer and approve requests
|
|
233
|
+
* @returns Current nonces for signer's address
|
|
234
|
+
*/
|
|
235
|
+
async getNonces() {
|
|
236
|
+
const selfAddress = await this.signer.getAddress();
|
|
237
|
+
try {
|
|
238
|
+
const nonces = await this.contract.getNonces(selfAddress);
|
|
239
|
+
return { transferNonce: nonces.transferNonce, approveNonce: nonces.approveNonce };
|
|
240
|
+
}
|
|
241
|
+
catch (error) {
|
|
242
|
+
throw coin_errors_1.CoinError.from(error, this.contract);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
exports.PrivatelyCoinClient = PrivatelyCoinClient;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CoinError = void 0;
|
|
4
|
+
const privately_error_1 = require("../../common/privately.error");
|
|
5
|
+
class CoinError extends privately_error_1.PrivatelyError {
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(`CoinError: ${typeof message === 'object' ? JSON.stringify(message) : message}`);
|
|
8
|
+
this.name = "CoinError";
|
|
9
|
+
}
|
|
10
|
+
static from(error, contract) {
|
|
11
|
+
try {
|
|
12
|
+
const message = (0, privately_error_1.parseContractError)(error, contract?.interface);
|
|
13
|
+
return new CoinError(message);
|
|
14
|
+
}
|
|
15
|
+
catch (parseError) {
|
|
16
|
+
return new CoinError({
|
|
17
|
+
originalError: error,
|
|
18
|
+
parseError
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.CoinError = CoinError;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Log } from "ethers";
|
|
2
|
+
export type OnMintListener = (to: string, amount: bigint, finalBalance: bigint, event: Log) => void;
|
|
3
|
+
export type OnTransferListener = (from: string, to: string, amount: bigint, fromFinalBalance: bigint, toFinalBalance: bigint, event: Log) => void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TRANSFER_REQUEST_TYPE = void 0;
|
|
4
|
+
exports.TRANSFER_REQUEST_TYPE = {
|
|
5
|
+
TransferRequest: [
|
|
6
|
+
{ name: "from", type: "address" },
|
|
7
|
+
{ name: "to", type: "address" },
|
|
8
|
+
{ name: "amount", type: "uint256" },
|
|
9
|
+
{ name: "nonce", type: "uint256" }
|
|
10
|
+
]
|
|
11
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
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("./coin.approve.request"), exports);
|
|
18
|
+
__exportStar(require("./coin.client"), exports);
|
|
19
|
+
__exportStar(require("./coin.errors"), exports);
|
|
20
|
+
__exportStar(require("./coin.nonces"), exports);
|
|
21
|
+
__exportStar(require("./coin.transfer.request"), 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
|
+
}
|