flipmeme-sdk 1.3.77 → 1.3.78

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.d.mts CHANGED
@@ -11,6 +11,16 @@ declare enum BlockchainType {
11
11
  SOLANA = "solana",
12
12
  ETHEREUM = "ethereum"
13
13
  }
14
+ declare enum ChainEnv {
15
+ Ethereum = 1,
16
+ EthereumSepolia = 11155111,
17
+ Base = 8453,
18
+ BaseSepolia = 84532,
19
+ ApeChain = 33139,
20
+ ApeChainTestnet = 33111,
21
+ Abstract = 2741,
22
+ AbstractTestnet = 11124
23
+ }
14
24
  interface EthereumConfig {
15
25
  signer?: Signer;
16
26
  chainId: number;
@@ -27,10 +37,9 @@ interface CollectionParams {
27
37
  name: string;
28
38
  tokenUri: string;
29
39
  totalSupply: number;
40
+ endPrice: string;
30
41
  symbol?: string;
31
42
  premint?: number;
32
- startPrice?: string;
33
- endPrice?: string;
34
43
  }
35
44
  interface CreateCollectionResponse {
36
45
  collectionId: string;
@@ -270,6 +279,7 @@ declare const RPC: {
270
279
  Devnet: string;
271
280
  Mainnet: string;
272
281
  };
282
+ declare const ETH_MAX_PROCESS_COUNT = 20;
273
283
  declare const SOLANA_PUBKEYS: {
274
284
  UPDATE_AUTHORITY_ID: PublicKey;
275
285
  TREASURY_ID: PublicKey;
@@ -491,7 +501,7 @@ declare class FlipmemeSDK {
491
501
  }>;
492
502
  }>;
493
503
  exportCollectionByEth(sessionId: string, totalSupply: number, slippage?: number): Promise<string>;
494
- getTotalPrice(type: PurcahseType, collectionId: string, amount: number): Promise<string>;
504
+ getTotalPrice(type: PurcahseType, collectionAddr: string, amount: number): Promise<string>;
495
505
  profileSellTotalPrice(data: Record<string, EthSellData>): Promise<string>;
496
506
  /**
497
507
  * create lookup table account with lookuptable addresses and return lookup table account
@@ -562,4 +572,4 @@ declare function placeMagicEdenCollectionBid(price: number, quantity: number, co
562
572
 
563
573
  declare function placeSpaaceCollectionBid(price: number, collection: string, tokenIdStart: string, tokenIdEnd: string, walletAddr: string, apiKey: string, source?: string): Promise<String | undefined>;
564
574
 
565
- export { APE_DEV, type AssetData, type AssetInfo, BASE_DEV, BlockchainType, type BuyParams, type BuyResponse, COLLECTION_BID_PRICE, type CollectionInfo, type CollectionParams, type Compression, type ConfirmResult, type CreateCollectionResponse, ENV, type ETHAddresses, ETHEREUM_DEV, ETHEREUM_RPC, ETH_ADDR, ETH_COMMON, type EthAddr, type EthBuyParams, type EthProfileSellParams, type EthSellData, type EthSellParams, type EthTransferParams, type EthereumConfig, FlipmemeSDK, type MerkleProof, type NetworkAddress, type NftInfo, type Ownership, PLATFORM, type ProfileSellParams, PurcahseType, ROUTER, RPC, type ReserveToken, type SDKSignature, type SDKTransaction, SDK_SOLANA_CONFIG, SOLANA_COMMON, SOLANA_DEV, SOLANA_MAIN, SOLANA_PUBKEYS, SOLANA_PUBKEYS_DEV, SOLANA_PUBKEYS_STAGE, SOLANA_STAGE, type SellData, type SellParams, type SellResponse, type SolanaConfig, TOKENS, type TransactionData, type TransferParams, VALID_SIZE_PAIR, decodeStr, getPrice, getSOLPriceInUSD, getUSDPriceInSOL, getUSDPriceInWETH, isEthereumConfig, isSolanaConfig, placeMagicEdenCollectionBid, placeSpaaceCollectionBid, placeTensorCollectionBid };
575
+ export { APE_DEV, type AssetData, type AssetInfo, BASE_DEV, BlockchainType, type BuyParams, type BuyResponse, COLLECTION_BID_PRICE, ChainEnv, type CollectionInfo, type CollectionParams, type Compression, type ConfirmResult, type CreateCollectionResponse, ENV, type ETHAddresses, ETHEREUM_DEV, ETHEREUM_RPC, ETH_ADDR, ETH_COMMON, ETH_MAX_PROCESS_COUNT, type EthAddr, type EthBuyParams, type EthProfileSellParams, type EthSellData, type EthSellParams, type EthTransferParams, type EthereumConfig, FlipmemeSDK, type MerkleProof, type NetworkAddress, type NftInfo, type Ownership, PLATFORM, type ProfileSellParams, PurcahseType, ROUTER, RPC, type ReserveToken, type SDKSignature, type SDKTransaction, SDK_SOLANA_CONFIG, SOLANA_COMMON, SOLANA_DEV, SOLANA_MAIN, SOLANA_PUBKEYS, SOLANA_PUBKEYS_DEV, SOLANA_PUBKEYS_STAGE, SOLANA_STAGE, type SellData, type SellParams, type SellResponse, type SolanaConfig, TOKENS, type TransactionData, type TransferParams, VALID_SIZE_PAIR, decodeStr, getPrice, getSOLPriceInUSD, getUSDPriceInSOL, getUSDPriceInWETH, isEthereumConfig, isSolanaConfig, placeMagicEdenCollectionBid, placeSpaaceCollectionBid, placeTensorCollectionBid };
package/dist/index.d.ts CHANGED
@@ -11,6 +11,16 @@ declare enum BlockchainType {
11
11
  SOLANA = "solana",
12
12
  ETHEREUM = "ethereum"
13
13
  }
14
+ declare enum ChainEnv {
15
+ Ethereum = 1,
16
+ EthereumSepolia = 11155111,
17
+ Base = 8453,
18
+ BaseSepolia = 84532,
19
+ ApeChain = 33139,
20
+ ApeChainTestnet = 33111,
21
+ Abstract = 2741,
22
+ AbstractTestnet = 11124
23
+ }
14
24
  interface EthereumConfig {
15
25
  signer?: Signer;
16
26
  chainId: number;
@@ -27,10 +37,9 @@ interface CollectionParams {
27
37
  name: string;
28
38
  tokenUri: string;
29
39
  totalSupply: number;
40
+ endPrice: string;
30
41
  symbol?: string;
31
42
  premint?: number;
32
- startPrice?: string;
33
- endPrice?: string;
34
43
  }
35
44
  interface CreateCollectionResponse {
36
45
  collectionId: string;
@@ -270,6 +279,7 @@ declare const RPC: {
270
279
  Devnet: string;
271
280
  Mainnet: string;
272
281
  };
282
+ declare const ETH_MAX_PROCESS_COUNT = 20;
273
283
  declare const SOLANA_PUBKEYS: {
274
284
  UPDATE_AUTHORITY_ID: PublicKey;
275
285
  TREASURY_ID: PublicKey;
@@ -491,7 +501,7 @@ declare class FlipmemeSDK {
491
501
  }>;
492
502
  }>;
493
503
  exportCollectionByEth(sessionId: string, totalSupply: number, slippage?: number): Promise<string>;
494
- getTotalPrice(type: PurcahseType, collectionId: string, amount: number): Promise<string>;
504
+ getTotalPrice(type: PurcahseType, collectionAddr: string, amount: number): Promise<string>;
495
505
  profileSellTotalPrice(data: Record<string, EthSellData>): Promise<string>;
496
506
  /**
497
507
  * create lookup table account with lookuptable addresses and return lookup table account
@@ -562,4 +572,4 @@ declare function placeMagicEdenCollectionBid(price: number, quantity: number, co
562
572
 
563
573
  declare function placeSpaaceCollectionBid(price: number, collection: string, tokenIdStart: string, tokenIdEnd: string, walletAddr: string, apiKey: string, source?: string): Promise<String | undefined>;
564
574
 
565
- export { APE_DEV, type AssetData, type AssetInfo, BASE_DEV, BlockchainType, type BuyParams, type BuyResponse, COLLECTION_BID_PRICE, type CollectionInfo, type CollectionParams, type Compression, type ConfirmResult, type CreateCollectionResponse, ENV, type ETHAddresses, ETHEREUM_DEV, ETHEREUM_RPC, ETH_ADDR, ETH_COMMON, type EthAddr, type EthBuyParams, type EthProfileSellParams, type EthSellData, type EthSellParams, type EthTransferParams, type EthereumConfig, FlipmemeSDK, type MerkleProof, type NetworkAddress, type NftInfo, type Ownership, PLATFORM, type ProfileSellParams, PurcahseType, ROUTER, RPC, type ReserveToken, type SDKSignature, type SDKTransaction, SDK_SOLANA_CONFIG, SOLANA_COMMON, SOLANA_DEV, SOLANA_MAIN, SOLANA_PUBKEYS, SOLANA_PUBKEYS_DEV, SOLANA_PUBKEYS_STAGE, SOLANA_STAGE, type SellData, type SellParams, type SellResponse, type SolanaConfig, TOKENS, type TransactionData, type TransferParams, VALID_SIZE_PAIR, decodeStr, getPrice, getSOLPriceInUSD, getUSDPriceInSOL, getUSDPriceInWETH, isEthereumConfig, isSolanaConfig, placeMagicEdenCollectionBid, placeSpaaceCollectionBid, placeTensorCollectionBid };
575
+ export { APE_DEV, type AssetData, type AssetInfo, BASE_DEV, BlockchainType, type BuyParams, type BuyResponse, COLLECTION_BID_PRICE, ChainEnv, type CollectionInfo, type CollectionParams, type Compression, type ConfirmResult, type CreateCollectionResponse, ENV, type ETHAddresses, ETHEREUM_DEV, ETHEREUM_RPC, ETH_ADDR, ETH_COMMON, ETH_MAX_PROCESS_COUNT, type EthAddr, type EthBuyParams, type EthProfileSellParams, type EthSellData, type EthSellParams, type EthTransferParams, type EthereumConfig, FlipmemeSDK, type MerkleProof, type NetworkAddress, type NftInfo, type Ownership, PLATFORM, type ProfileSellParams, PurcahseType, ROUTER, RPC, type ReserveToken, type SDKSignature, type SDKTransaction, SDK_SOLANA_CONFIG, SOLANA_COMMON, SOLANA_DEV, SOLANA_MAIN, SOLANA_PUBKEYS, SOLANA_PUBKEYS_DEV, SOLANA_PUBKEYS_STAGE, SOLANA_STAGE, type SellData, type SellParams, type SellResponse, type SolanaConfig, TOKENS, type TransactionData, type TransferParams, VALID_SIZE_PAIR, decodeStr, getPrice, getSOLPriceInUSD, getUSDPriceInSOL, getUSDPriceInWETH, isEthereumConfig, isSolanaConfig, placeMagicEdenCollectionBid, placeSpaaceCollectionBid, placeTensorCollectionBid };
package/dist/index.js CHANGED
@@ -68,11 +68,13 @@ __export(index_exports, {
68
68
  BASE_DEV: () => BASE_DEV,
69
69
  BlockchainType: () => BlockchainType,
70
70
  COLLECTION_BID_PRICE: () => COLLECTION_BID_PRICE,
71
+ ChainEnv: () => ChainEnv,
71
72
  ENV: () => ENV,
72
73
  ETHEREUM_DEV: () => ETHEREUM_DEV,
73
74
  ETHEREUM_RPC: () => ETHEREUM_RPC,
74
75
  ETH_ADDR: () => ETH_ADDR,
75
76
  ETH_COMMON: () => ETH_COMMON,
77
+ ETH_MAX_PROCESS_COUNT: () => ETH_MAX_PROCESS_COUNT,
76
78
  FlipmemeSDK: () => FlipmemeSDK,
77
79
  PLATFORM: () => PLATFORM,
78
80
  PurcahseType: () => PurcahseType,
@@ -157,6 +159,7 @@ var RPC = {
157
159
  Devnet: "https://devnet.helius-rpc.com/?api-key=cb62a28b-f3ca-4290-b952-1df61706e43d",
158
160
  Mainnet: "https://mainnet.helius-rpc.com/?api-key=cb62a28b-f3ca-4290-b952-1df61706e43d"
159
161
  };
162
+ var ETH_MAX_PROCESS_COUNT = 20;
160
163
  var SOLANA_PUBKEYS = __spreadValues({
161
164
  LOOKUP_TABLE: new import_web3.PublicKey(SOLANA_MAIN.LOOKUP_TABLE_STR),
162
165
  STATE_ID: new import_web3.PublicKey(SOLANA_MAIN.STATE_ID_STR),
@@ -252,6 +255,17 @@ var BlockchainType = /* @__PURE__ */ ((BlockchainType2) => {
252
255
  BlockchainType2["ETHEREUM"] = "ethereum";
253
256
  return BlockchainType2;
254
257
  })(BlockchainType || {});
258
+ var ChainEnv = /* @__PURE__ */ ((ChainEnv2) => {
259
+ ChainEnv2[ChainEnv2["Ethereum"] = 1] = "Ethereum";
260
+ ChainEnv2[ChainEnv2["EthereumSepolia"] = 11155111] = "EthereumSepolia";
261
+ ChainEnv2[ChainEnv2["Base"] = 8453] = "Base";
262
+ ChainEnv2[ChainEnv2["BaseSepolia"] = 84532] = "BaseSepolia";
263
+ ChainEnv2[ChainEnv2["ApeChain"] = 33139] = "ApeChain";
264
+ ChainEnv2[ChainEnv2["ApeChainTestnet"] = 33111] = "ApeChainTestnet";
265
+ ChainEnv2[ChainEnv2["Abstract"] = 2741] = "Abstract";
266
+ ChainEnv2[ChainEnv2["AbstractTestnet"] = 11124] = "AbstractTestnet";
267
+ return ChainEnv2;
268
+ })(ChainEnv || {});
255
269
  function isEthereumConfig(config) {
256
270
  return "chainId" in config;
257
271
  }
@@ -34714,8 +34728,12 @@ var EthereumConnector = class {
34714
34728
  createCollection(collection) {
34715
34729
  return __async(this, null, function* () {
34716
34730
  var _a;
34717
- const startPrice = collection.startPrice || new import_decimal2.default(10).pow(15).floor().toFixed();
34718
- const endPrice = collection.endPrice || new import_decimal2.default(10).pow(16).floor().toFixed();
34731
+ let endPrice = collection.endPrice;
34732
+ let [isAvailable, errorMsg] = this.isPriceAvailable(endPrice);
34733
+ if (!isAvailable) {
34734
+ throw new Error(`Price ${endPrice} Error: ${errorMsg}`);
34735
+ }
34736
+ const startPrice = new import_decimal2.default(endPrice).div(17).toFixed();
34719
34737
  let tx = yield this.factory.createCollection(
34720
34738
  collection.name,
34721
34739
  collection.symbol,
@@ -34742,6 +34760,9 @@ var EthereumConnector = class {
34742
34760
  }
34743
34761
  buy(params) {
34744
34762
  return __async(this, null, function* () {
34763
+ if (params.amount > ETH_MAX_PROCESS_COUNT || params.tokenIds.length > ETH_MAX_PROCESS_COUNT) {
34764
+ throw new Error(`Amount exceeds maximum process count of ${ETH_MAX_PROCESS_COUNT}`);
34765
+ }
34745
34766
  let collection = new Collection__factory(this.config.signer).attach(
34746
34767
  params.collectionAddress
34747
34768
  );
@@ -34770,6 +34791,9 @@ var EthereumConnector = class {
34770
34791
  }
34771
34792
  sell(params) {
34772
34793
  return __async(this, null, function* () {
34794
+ if (params.tokenIds.length > ETH_MAX_PROCESS_COUNT) {
34795
+ throw new Error(`Amount exceeds maximum process count of ${ETH_MAX_PROCESS_COUNT}`);
34796
+ }
34773
34797
  let collection = new Collection__factory(this.config.signer).attach(
34774
34798
  params.collectionAddress
34775
34799
  );
@@ -34790,6 +34814,9 @@ var EthereumConnector = class {
34790
34814
  let items = params.data[collectionId];
34791
34815
  collectionIds.push(collectionId);
34792
34816
  ids.push(items.tokenIds);
34817
+ if (items.tokenIds.length > ETH_MAX_PROCESS_COUNT) {
34818
+ throw new Error(`Amount exceeds maximum process count of ${ETH_MAX_PROCESS_COUNT} for collection ${collectionId}`);
34819
+ }
34793
34820
  totalCount += items.tokenIds.length;
34794
34821
  }
34795
34822
  const tx = yield factory.profileSell(collectionIds, ids, params.minPrice);
@@ -35172,13 +35199,23 @@ var EthereumConnector = class {
35172
35199
  };
35173
35200
  });
35174
35201
  }
35175
- // private addProtocolFee(totalPrice: Decimal) {
35176
- // return totalPrice
35177
- // .add(
35178
- // totalPrice.mul(this.configAddresses.PROTOCOL_FEE_BPS).div(10000).floor()
35179
- // )
35180
- // .toString();
35181
- // }
35202
+ isPriceAvailable(price) {
35203
+ const priceInDecimal = new import_decimal2.default(price);
35204
+ if (this.config.chainId === 1 /* Ethereum */ || this.config.chainId === 11155111 /* EthereumSepolia */) {
35205
+ const minPriceForEth = new import_decimal2.default(2).mul(new import_decimal2.default(10).pow(16)).toString();
35206
+ const maxPriceForEth = new import_decimal2.default(10).pow(18).toString();
35207
+ if (priceInDecimal.lessThan(minPriceForEth) || priceInDecimal.greaterThan(maxPriceForEth)) {
35208
+ return [false, `Price ${price} is out of the allowed range [${minPriceForEth}, ${maxPriceForEth}].`];
35209
+ }
35210
+ } else if (this.config.chainId === 8453 /* Base */ || this.config.chainId === 84532 /* BaseSepolia */) {
35211
+ const minPriceForEth = new import_decimal2.default(10).pow(16).toString();
35212
+ const maxPriceForEth = new import_decimal2.default(5).mul(new import_decimal2.default(10).pow(16)).toString();
35213
+ if (priceInDecimal.lessThan(minPriceForEth) || priceInDecimal.greaterThan(maxPriceForEth)) {
35214
+ return [false, `Price ${price} is out of the allowed range [${minPriceForEth}, ${maxPriceForEth}].`];
35215
+ }
35216
+ }
35217
+ return [true, ""];
35218
+ }
35182
35219
  };
35183
35220
 
35184
35221
  // src/solana/index.ts
@@ -40498,14 +40535,14 @@ var FlipmemeSDK = class {
40498
40535
  }
40499
40536
  });
40500
40537
  }
40501
- getTotalPrice(type, collectionId, amount) {
40538
+ getTotalPrice(type, collectionAddr, amount) {
40502
40539
  return __async(this, null, function* () {
40503
40540
  if (this.blockchainType === "solana" /* SOLANA */ && this.solana) {
40504
- return yield this.solana.getTotalPrice(type, collectionId, amount);
40541
+ return yield this.solana.getTotalPrice(type, collectionAddr, amount);
40505
40542
  } else if (this.blockchainType === "ethereum" /* ETHEREUM */ && this.ethereum) {
40506
40543
  return this.ethereum.getTotalPrice(
40507
40544
  type,
40508
- collectionId,
40545
+ collectionAddr,
40509
40546
  import_ethers63.BigNumber.from(amount)
40510
40547
  );
40511
40548
  } else {
@@ -40924,11 +40961,13 @@ function placeSpaaceCollectionBid(price, collection, tokenIdStart, tokenIdEnd, w
40924
40961
  BASE_DEV,
40925
40962
  BlockchainType,
40926
40963
  COLLECTION_BID_PRICE,
40964
+ ChainEnv,
40927
40965
  ENV,
40928
40966
  ETHEREUM_DEV,
40929
40967
  ETHEREUM_RPC,
40930
40968
  ETH_ADDR,
40931
40969
  ETH_COMMON,
40970
+ ETH_MAX_PROCESS_COUNT,
40932
40971
  FlipmemeSDK,
40933
40972
  PLATFORM,
40934
40973
  PurcahseType,