flipmeme-sdk 1.3.77 → 1.3.79

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/index.mjs CHANGED
@@ -95,6 +95,7 @@ var RPC = {
95
95
  Devnet: "https://devnet.helius-rpc.com/?api-key=cb62a28b-f3ca-4290-b952-1df61706e43d",
96
96
  Mainnet: "https://mainnet.helius-rpc.com/?api-key=cb62a28b-f3ca-4290-b952-1df61706e43d"
97
97
  };
98
+ var ETH_MAX_PROCESS_COUNT = 20;
98
99
  var SOLANA_PUBKEYS = __spreadValues({
99
100
  LOOKUP_TABLE: new PublicKey(SOLANA_MAIN.LOOKUP_TABLE_STR),
100
101
  STATE_ID: new PublicKey(SOLANA_MAIN.STATE_ID_STR),
@@ -190,6 +191,17 @@ var BlockchainType = /* @__PURE__ */ ((BlockchainType2) => {
190
191
  BlockchainType2["ETHEREUM"] = "ethereum";
191
192
  return BlockchainType2;
192
193
  })(BlockchainType || {});
194
+ var ChainEnv = /* @__PURE__ */ ((ChainEnv2) => {
195
+ ChainEnv2[ChainEnv2["Ethereum"] = 1] = "Ethereum";
196
+ ChainEnv2[ChainEnv2["EthereumSepolia"] = 11155111] = "EthereumSepolia";
197
+ ChainEnv2[ChainEnv2["Base"] = 8453] = "Base";
198
+ ChainEnv2[ChainEnv2["BaseSepolia"] = 84532] = "BaseSepolia";
199
+ ChainEnv2[ChainEnv2["ApeChain"] = 33139] = "ApeChain";
200
+ ChainEnv2[ChainEnv2["ApeChainTestnet"] = 33111] = "ApeChainTestnet";
201
+ ChainEnv2[ChainEnv2["Abstract"] = 2741] = "Abstract";
202
+ ChainEnv2[ChainEnv2["AbstractTestnet"] = 11124] = "AbstractTestnet";
203
+ return ChainEnv2;
204
+ })(ChainEnv || {});
193
205
  function isEthereumConfig(config) {
194
206
  return "chainId" in config;
195
207
  }
@@ -34664,8 +34676,12 @@ var EthereumConnector = class {
34664
34676
  createCollection(collection) {
34665
34677
  return __async(this, null, function* () {
34666
34678
  var _a;
34667
- const startPrice = collection.startPrice || new Decimal2(10).pow(15).floor().toFixed();
34668
- const endPrice = collection.endPrice || new Decimal2(10).pow(16).floor().toFixed();
34679
+ let endPrice = collection.endPrice;
34680
+ let [isAvailable, errorMsg] = this.isPriceAvailable(endPrice);
34681
+ if (!isAvailable) {
34682
+ throw new Error(`Price ${endPrice} Error: ${errorMsg}`);
34683
+ }
34684
+ const startPrice = new Decimal2(endPrice).div(17).toFixed();
34669
34685
  let tx = yield this.factory.createCollection(
34670
34686
  collection.name,
34671
34687
  collection.symbol,
@@ -34692,6 +34708,9 @@ var EthereumConnector = class {
34692
34708
  }
34693
34709
  buy(params) {
34694
34710
  return __async(this, null, function* () {
34711
+ if (params.amount > ETH_MAX_PROCESS_COUNT || params.tokenIds.length > ETH_MAX_PROCESS_COUNT) {
34712
+ throw new Error(`Amount exceeds maximum process count of ${ETH_MAX_PROCESS_COUNT}`);
34713
+ }
34695
34714
  let collection = new Collection__factory(this.config.signer).attach(
34696
34715
  params.collectionAddress
34697
34716
  );
@@ -34720,6 +34739,9 @@ var EthereumConnector = class {
34720
34739
  }
34721
34740
  sell(params) {
34722
34741
  return __async(this, null, function* () {
34742
+ if (params.tokenIds.length > ETH_MAX_PROCESS_COUNT) {
34743
+ throw new Error(`Amount exceeds maximum process count of ${ETH_MAX_PROCESS_COUNT}`);
34744
+ }
34723
34745
  let collection = new Collection__factory(this.config.signer).attach(
34724
34746
  params.collectionAddress
34725
34747
  );
@@ -34740,6 +34762,9 @@ var EthereumConnector = class {
34740
34762
  let items = params.data[collectionId];
34741
34763
  collectionIds.push(collectionId);
34742
34764
  ids.push(items.tokenIds);
34765
+ if (items.tokenIds.length > ETH_MAX_PROCESS_COUNT) {
34766
+ throw new Error(`Amount exceeds maximum process count of ${ETH_MAX_PROCESS_COUNT} for collection ${collectionId}`);
34767
+ }
34743
34768
  totalCount += items.tokenIds.length;
34744
34769
  }
34745
34770
  const tx = yield factory.profileSell(collectionIds, ids, params.minPrice);
@@ -35122,13 +35147,23 @@ var EthereumConnector = class {
35122
35147
  };
35123
35148
  });
35124
35149
  }
35125
- // private addProtocolFee(totalPrice: Decimal) {
35126
- // return totalPrice
35127
- // .add(
35128
- // totalPrice.mul(this.configAddresses.PROTOCOL_FEE_BPS).div(10000).floor()
35129
- // )
35130
- // .toString();
35131
- // }
35150
+ isPriceAvailable(price) {
35151
+ const priceInDecimal = new Decimal2(price);
35152
+ if (this.config.chainId === 1 /* Ethereum */ || this.config.chainId === 11155111 /* EthereumSepolia */) {
35153
+ const minPriceForEth = new Decimal2(2).mul(new Decimal2(10).pow(16)).toString();
35154
+ const maxPriceForEth = new Decimal2(10).pow(18).toString();
35155
+ if (priceInDecimal.lessThan(minPriceForEth) || priceInDecimal.greaterThan(maxPriceForEth)) {
35156
+ return [false, `Price ${price} is out of the allowed range [${minPriceForEth}, ${maxPriceForEth}].`];
35157
+ }
35158
+ } else if (this.config.chainId === 8453 /* Base */ || this.config.chainId === 84532 /* BaseSepolia */) {
35159
+ const minPriceForEth = new Decimal2(10).pow(16).toString();
35160
+ const maxPriceForEth = new Decimal2(5).mul(new Decimal2(10).pow(16)).toString();
35161
+ if (priceInDecimal.lessThan(minPriceForEth) || priceInDecimal.greaterThan(maxPriceForEth)) {
35162
+ return [false, `Price ${price} is out of the allowed range [${minPriceForEth}, ${maxPriceForEth}].`];
35163
+ }
35164
+ }
35165
+ return [true, ""];
35166
+ }
35132
35167
  };
35133
35168
 
35134
35169
  // src/solana/index.ts
@@ -40462,14 +40497,14 @@ var FlipmemeSDK = class {
40462
40497
  }
40463
40498
  });
40464
40499
  }
40465
- getTotalPrice(type, collectionId, amount) {
40500
+ getTotalPrice(type, collectionAddr, amount) {
40466
40501
  return __async(this, null, function* () {
40467
40502
  if (this.blockchainType === "solana" /* SOLANA */ && this.solana) {
40468
- return yield this.solana.getTotalPrice(type, collectionId, amount);
40503
+ return yield this.solana.getTotalPrice(type, collectionAddr, amount);
40469
40504
  } else if (this.blockchainType === "ethereum" /* ETHEREUM */ && this.ethereum) {
40470
40505
  return this.ethereum.getTotalPrice(
40471
40506
  type,
40472
- collectionId,
40507
+ collectionAddr,
40473
40508
  BigNumber2.from(amount)
40474
40509
  );
40475
40510
  } else {
@@ -40887,11 +40922,13 @@ export {
40887
40922
  BASE_DEV,
40888
40923
  BlockchainType,
40889
40924
  COLLECTION_BID_PRICE,
40925
+ ChainEnv,
40890
40926
  ENV,
40891
40927
  ETHEREUM_DEV,
40892
40928
  ETHEREUM_RPC,
40893
40929
  ETH_ADDR,
40894
40930
  ETH_COMMON,
40931
+ ETH_MAX_PROCESS_COUNT,
40895
40932
  FlipmemeSDK,
40896
40933
  PLATFORM,
40897
40934
  PurcahseType,