privately-smartcontract-lib 1.1.1 → 1.2.0

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/client.d.ts CHANGED
@@ -1,6 +1,16 @@
1
1
  import { Block, Signer, TransactionResponse } from "ethers";
2
2
  import { PrivatelyAuctionSystemClient } from "./modules/auctions";
3
3
  import { PrivatelyCollectionClient } from "./modules/collection";
4
+ /**
5
+ * Options for creating a PrivatelyClient instance.
6
+ * Use these to override default contract addresses (e.g., for testnet/mainnet).
7
+ */
8
+ export interface PrivatelyClientOptions {
9
+ /** Override the collection contract address */
10
+ collectionAddress?: string;
11
+ /** Override the auction contract address */
12
+ auctionAddress?: string;
13
+ }
4
14
  export declare class PrivatelyClient {
5
15
  readonly signer: Signer;
6
16
  readonly collection: PrivatelyCollectionClient;
@@ -9,9 +19,10 @@ export declare class PrivatelyClient {
9
19
  /**
10
20
  * Creates a new PrivatelyClient instance using the provided signer.
11
21
  * @param signer The signer to use for transactions.
22
+ * @param options Optional configuration for contract addresses.
12
23
  * @returns A new PrivatelyClient instance.
13
24
  */
14
- static create(signer: Signer): Promise<PrivatelyClient>;
25
+ static create(signer: Signer, options?: PrivatelyClientOptions): Promise<PrivatelyClient>;
15
26
  /**
16
27
  * Fetches the latest block from the connected provider.
17
28
  * @returns The latest block.
package/dist/client.js CHANGED
@@ -8,21 +8,22 @@ class PrivatelyClient {
8
8
  signer;
9
9
  collection;
10
10
  auctions;
11
- constructor(signer, network) {
11
+ constructor(signer, network, options) {
12
12
  this.signer = signer;
13
- this.collection = new collection_1.PrivatelyCollectionClient(signer, network);
14
- this.auctions = new auctions_1.PrivatelyAuctionSystemClient(signer, network);
13
+ this.collection = new collection_1.PrivatelyCollectionClient(signer, network, options?.collectionAddress);
14
+ this.auctions = new auctions_1.PrivatelyAuctionSystemClient(signer, network, options?.auctionAddress);
15
15
  }
16
16
  /**
17
17
  * Creates a new PrivatelyClient instance using the provided signer.
18
18
  * @param signer The signer to use for transactions.
19
+ * @param options Optional configuration for contract addresses.
19
20
  * @returns A new PrivatelyClient instance.
20
21
  */
21
- static async create(signer) {
22
+ static async create(signer, options) {
22
23
  if (!signer.provider)
23
24
  throw new Error("Signer must be connected to a provider.");
24
25
  const network = await signer.provider.getNetwork();
25
- return new PrivatelyClient(signer, network);
26
+ return new PrivatelyClient(signer, network, options);
26
27
  }
27
28
  /**
28
29
  * Fetches the latest block from the connected provider.
@@ -1,8 +1,6 @@
1
1
  export declare enum RequestType {
2
2
  AUCTION_CREATE = "AUCTION_CREATE",
3
3
  AUCTION_BID = "AUCTION_BID",
4
- COIN_TRANSFER = "COIN_TRANSFER",
5
- COIN_APPROVE = "COIN_APPROVE",
6
4
  COLLECTION_MINT = "COLLECTION_MINT",
7
5
  COLLECTION_TRANSFER = "COLLECTION_TRANSFER",
8
6
  COLLECTION_APPROVE = "COLLECTION_APPROVE"
@@ -6,9 +6,6 @@ var RequestType;
6
6
  // Auctions requests types
7
7
  RequestType["AUCTION_CREATE"] = "AUCTION_CREATE";
8
8
  RequestType["AUCTION_BID"] = "AUCTION_BID";
9
- // Coin requests types
10
- RequestType["COIN_TRANSFER"] = "COIN_TRANSFER";
11
- RequestType["COIN_APPROVE"] = "COIN_APPROVE";
12
9
  // Collection requests types
13
10
  RequestType["COLLECTION_MINT"] = "COLLECTION_MINT";
14
11
  RequestType["COLLECTION_TRANSFER"] = "COLLECTION_TRANSFER";
@@ -4,11 +4,14 @@ import { Auction } from "./auctions.auction";
4
4
  import { BidAuctionRequest } from "./auctions.bid.reqest";
5
5
  import { CreateAuctionRequest } from "./auctions.create.request";
6
6
  import { OnBidListener, OnCreateListener, OnEnd, OnWithdrawListener } from "./auctions.events";
7
+ /** Default address for local Hardhat deployment */
8
+ export declare const DEFAULT_AUCTION_ADDRESS = "0x9fe46736679d2d9a65f0992f2272de9f3c7fa6e0";
7
9
  export declare class PrivatelyAuctionSystemClient {
8
10
  readonly contract: Contract;
11
+ readonly address: string;
9
12
  private readonly signer;
10
13
  private readonly domain;
11
- constructor(signer: Signer, network: Network);
14
+ constructor(signer: Signer, network: Network, address?: string);
12
15
  /**
13
16
  * Retrieves the address of the current deployed contract.
14
17
  * @returns The contract address.
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.PrivatelyAuctionSystemClient = void 0;
6
+ exports.PrivatelyAuctionSystemClient = exports.DEFAULT_AUCTION_ADDRESS = void 0;
7
7
  const ethers_1 = require("ethers");
8
8
  const PrivatelyAuctionSystem_json_1 = __importDefault(require("../../../PrivatelyAuctionSystem.json"));
9
9
  const request_signature_1 = require("../../common/request-signature");
@@ -11,20 +11,23 @@ const auctions_auction_1 = require("./auctions.auction");
11
11
  const auctions_bid_reqest_1 = require("./auctions.bid.reqest");
12
12
  const auctions_create_request_1 = require("./auctions.create.request");
13
13
  const auctions_errors_1 = require("./auctions.errors");
14
- const AUCTION_SYSTEM_ADDRESS = "0x9fe46736679d2d9a65f0992f2272de9f3c7fa6e0";
14
+ /** Default address for local Hardhat deployment */
15
+ exports.DEFAULT_AUCTION_ADDRESS = "0x9fe46736679d2d9a65f0992f2272de9f3c7fa6e0";
15
16
  class PrivatelyAuctionSystemClient {
16
17
  contract;
18
+ address;
17
19
  signer;
18
20
  domain;
19
- constructor(signer, network) {
21
+ constructor(signer, network, address = exports.DEFAULT_AUCTION_ADDRESS) {
20
22
  this.signer = signer;
21
- this.contract = new ethers_1.Contract(AUCTION_SYSTEM_ADDRESS, PrivatelyAuctionSystem_json_1.default.abi, signer);
23
+ this.address = address;
24
+ this.contract = new ethers_1.Contract(address, PrivatelyAuctionSystem_json_1.default.abi, signer);
22
25
  const name = PrivatelyAuctionSystem_json_1.default.contractName;
23
26
  this.domain = {
24
27
  name,
25
28
  version: "1.0.0",
26
29
  chainId: network.chainId,
27
- verifyingContract: AUCTION_SYSTEM_ADDRESS
30
+ verifyingContract: address
28
31
  };
29
32
  }
30
33
  /**
@@ -32,7 +35,7 @@ class PrivatelyAuctionSystemClient {
32
35
  * @returns The contract address.
33
36
  */
34
37
  getContractAddress() {
35
- return AUCTION_SYSTEM_ADDRESS;
38
+ return this.address;
36
39
  }
37
40
  /**
38
41
  * Creates and signs a CreateAuctionRequest using EIP-712 structured data.
@@ -5,11 +5,14 @@ import { OnMintListener, OnTransferListener } from "./collection.events";
5
5
  import { CollectionMintRequest } from "./collection.mint.request";
6
6
  import { PrivatelyNFT } from "./collection.nft";
7
7
  import { CollectionTransferRequest } from "./collection.transfer.request";
8
+ /** Default address for local Hardhat deployment */
9
+ export declare const DEFAULT_COLLECTION_ADDRESS = "0xe7f1725e7734ce288f8367e1bb143e90bb3f0512";
8
10
  export declare class PrivatelyCollectionClient {
9
11
  readonly contract: Contract;
12
+ readonly address: string;
10
13
  private readonly signer;
11
14
  private readonly domain;
12
- constructor(signer: Signer, network: Network);
15
+ constructor(signer: Signer, network: Network, address?: string);
13
16
  /**
14
17
  * Retrieves a list of all NFT token IDs currently stored in the contract.
15
18
  * @returns An array of token IDs as bigint.
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.PrivatelyCollectionClient = void 0;
6
+ exports.PrivatelyCollectionClient = exports.DEFAULT_COLLECTION_ADDRESS = void 0;
7
7
  const ethers_1 = require("ethers");
8
8
  const PrivatelyCollection_json_1 = __importDefault(require("../../../PrivatelyCollection.json"));
9
9
  const request_signature_1 = require("../../common/request-signature");
@@ -12,20 +12,23 @@ const collection_errors_1 = require("./collection.errors");
12
12
  const collection_mint_request_1 = require("./collection.mint.request");
13
13
  const collection_nft_1 = require("./collection.nft");
14
14
  const collection_transfer_request_1 = require("./collection.transfer.request");
15
- const COLLECTION_ADDRESS = "0xe7f1725e7734ce288f8367e1bb143e90bb3f0512";
15
+ /** Default address for local Hardhat deployment */
16
+ exports.DEFAULT_COLLECTION_ADDRESS = "0xe7f1725e7734ce288f8367e1bb143e90bb3f0512";
16
17
  class PrivatelyCollectionClient {
17
18
  contract;
19
+ address;
18
20
  signer;
19
21
  domain;
20
- constructor(signer, network) {
22
+ constructor(signer, network, address = exports.DEFAULT_COLLECTION_ADDRESS) {
21
23
  this.signer = signer;
22
- this.contract = new ethers_1.Contract(COLLECTION_ADDRESS, PrivatelyCollection_json_1.default.abi, signer);
24
+ this.address = address;
25
+ this.contract = new ethers_1.Contract(address, PrivatelyCollection_json_1.default.abi, signer);
23
26
  const name = PrivatelyCollection_json_1.default.contractName;
24
27
  this.domain = {
25
28
  name,
26
29
  version: "1.0.0",
27
30
  chainId: network.chainId,
28
- verifyingContract: COLLECTION_ADDRESS
31
+ verifyingContract: address
29
32
  };
30
33
  }
31
34
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "privately-smartcontract-lib",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {