@flaunch/sdk 0.4.0 → 0.4.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/dist/index.esm.js CHANGED
@@ -6921,9 +6921,22 @@ const FlaunchPositionManagerAbi = [
6921
6921
  { stateMutability: "payable", type: "receive" },
6922
6922
  ];
6923
6923
 
6924
+ // List of public IPFS gateways to cycle through
6925
+ const IPFS_GATEWAYS = [
6926
+ "https://gateway.pinata.cloud/ipfs/",
6927
+ "https://ipfs.io/ipfs/",
6928
+ "https://dweb.link/ipfs/",
6929
+ ];
6930
+ // Counter to track the current gateway index
6931
+ let currentGatewayIndex = 0;
6924
6932
  const resolveIPFS = (value) => {
6925
6933
  if (value.startsWith("ipfs://")) {
6926
- return `https://gateway.pinata.cloud/ipfs/${value.slice(7)}`;
6934
+ const cid = value.slice(7);
6935
+ // Get the next gateway and increment the counter
6936
+ const gateway = IPFS_GATEWAYS[currentGatewayIndex];
6937
+ // Update the counter, cycling back to 0 when we reach the end
6938
+ currentGatewayIndex = (currentGatewayIndex + 1) % IPFS_GATEWAYS.length;
6939
+ return `${gateway}${cid}`;
6927
6940
  }
6928
6941
  return value;
6929
6942
  };
@@ -10196,6 +10209,16 @@ class ReadFlaunch {
10196
10209
  _tokenId: tokenId,
10197
10210
  });
10198
10211
  }
10212
+ /**
10213
+ * Gets the memecoin address for a given token ID
10214
+ * @param tokenId - The ID of the token
10215
+ * @returns Promise<Address> - The address of the memecoin
10216
+ */
10217
+ memecoin(tokenId) {
10218
+ return this.contract.read("memecoin", {
10219
+ _tokenId: tokenId,
10220
+ });
10221
+ }
10199
10222
  }
10200
10223
 
10201
10224
  const MemecoinAbi = [
@@ -16318,8 +16341,470 @@ const RevenueManagerAbi = [
16318
16341
  { stateMutability: "payable", type: "receive" },
16319
16342
  ];
16320
16343
 
16344
+ const MulticallAbi = [
16345
+ {
16346
+ inputs: [
16347
+ {
16348
+ components: [
16349
+ {
16350
+ internalType: "address",
16351
+ name: "target",
16352
+ type: "address",
16353
+ },
16354
+ {
16355
+ internalType: "bytes",
16356
+ name: "callData",
16357
+ type: "bytes",
16358
+ },
16359
+ ],
16360
+ internalType: "struct Multicall3.Call[]",
16361
+ name: "calls",
16362
+ type: "tuple[]",
16363
+ },
16364
+ ],
16365
+ name: "aggregate",
16366
+ outputs: [
16367
+ {
16368
+ internalType: "uint256",
16369
+ name: "blockNumber",
16370
+ type: "uint256",
16371
+ },
16372
+ {
16373
+ internalType: "bytes[]",
16374
+ name: "returnData",
16375
+ type: "bytes[]",
16376
+ },
16377
+ ],
16378
+ stateMutability: "payable",
16379
+ type: "function",
16380
+ },
16381
+ {
16382
+ inputs: [
16383
+ {
16384
+ components: [
16385
+ {
16386
+ internalType: "address",
16387
+ name: "target",
16388
+ type: "address",
16389
+ },
16390
+ {
16391
+ internalType: "bool",
16392
+ name: "allowFailure",
16393
+ type: "bool",
16394
+ },
16395
+ {
16396
+ internalType: "bytes",
16397
+ name: "callData",
16398
+ type: "bytes",
16399
+ },
16400
+ ],
16401
+ internalType: "struct Multicall3.Call3[]",
16402
+ name: "calls",
16403
+ type: "tuple[]",
16404
+ },
16405
+ ],
16406
+ name: "aggregate3",
16407
+ outputs: [
16408
+ {
16409
+ components: [
16410
+ {
16411
+ internalType: "bool",
16412
+ name: "success",
16413
+ type: "bool",
16414
+ },
16415
+ {
16416
+ internalType: "bytes",
16417
+ name: "returnData",
16418
+ type: "bytes",
16419
+ },
16420
+ ],
16421
+ internalType: "struct Multicall3.Result[]",
16422
+ name: "returnData",
16423
+ type: "tuple[]",
16424
+ },
16425
+ ],
16426
+ stateMutability: "payable",
16427
+ type: "function",
16428
+ },
16429
+ {
16430
+ inputs: [
16431
+ {
16432
+ components: [
16433
+ {
16434
+ internalType: "address",
16435
+ name: "target",
16436
+ type: "address",
16437
+ },
16438
+ {
16439
+ internalType: "bool",
16440
+ name: "allowFailure",
16441
+ type: "bool",
16442
+ },
16443
+ {
16444
+ internalType: "uint256",
16445
+ name: "value",
16446
+ type: "uint256",
16447
+ },
16448
+ {
16449
+ internalType: "bytes",
16450
+ name: "callData",
16451
+ type: "bytes",
16452
+ },
16453
+ ],
16454
+ internalType: "struct Multicall3.Call3Value[]",
16455
+ name: "calls",
16456
+ type: "tuple[]",
16457
+ },
16458
+ ],
16459
+ name: "aggregate3Value",
16460
+ outputs: [
16461
+ {
16462
+ components: [
16463
+ {
16464
+ internalType: "bool",
16465
+ name: "success",
16466
+ type: "bool",
16467
+ },
16468
+ {
16469
+ internalType: "bytes",
16470
+ name: "returnData",
16471
+ type: "bytes",
16472
+ },
16473
+ ],
16474
+ internalType: "struct Multicall3.Result[]",
16475
+ name: "returnData",
16476
+ type: "tuple[]",
16477
+ },
16478
+ ],
16479
+ stateMutability: "payable",
16480
+ type: "function",
16481
+ },
16482
+ {
16483
+ inputs: [
16484
+ {
16485
+ components: [
16486
+ {
16487
+ internalType: "address",
16488
+ name: "target",
16489
+ type: "address",
16490
+ },
16491
+ {
16492
+ internalType: "bytes",
16493
+ name: "callData",
16494
+ type: "bytes",
16495
+ },
16496
+ ],
16497
+ internalType: "struct Multicall3.Call[]",
16498
+ name: "calls",
16499
+ type: "tuple[]",
16500
+ },
16501
+ ],
16502
+ name: "blockAndAggregate",
16503
+ outputs: [
16504
+ {
16505
+ internalType: "uint256",
16506
+ name: "blockNumber",
16507
+ type: "uint256",
16508
+ },
16509
+ {
16510
+ internalType: "bytes32",
16511
+ name: "blockHash",
16512
+ type: "bytes32",
16513
+ },
16514
+ {
16515
+ components: [
16516
+ {
16517
+ internalType: "bool",
16518
+ name: "success",
16519
+ type: "bool",
16520
+ },
16521
+ {
16522
+ internalType: "bytes",
16523
+ name: "returnData",
16524
+ type: "bytes",
16525
+ },
16526
+ ],
16527
+ internalType: "struct Multicall3.Result[]",
16528
+ name: "returnData",
16529
+ type: "tuple[]",
16530
+ },
16531
+ ],
16532
+ stateMutability: "payable",
16533
+ type: "function",
16534
+ },
16535
+ {
16536
+ inputs: [],
16537
+ name: "getBasefee",
16538
+ outputs: [
16539
+ {
16540
+ internalType: "uint256",
16541
+ name: "basefee",
16542
+ type: "uint256",
16543
+ },
16544
+ ],
16545
+ stateMutability: "view",
16546
+ type: "function",
16547
+ },
16548
+ {
16549
+ inputs: [
16550
+ {
16551
+ internalType: "uint256",
16552
+ name: "blockNumber",
16553
+ type: "uint256",
16554
+ },
16555
+ ],
16556
+ name: "getBlockHash",
16557
+ outputs: [
16558
+ {
16559
+ internalType: "bytes32",
16560
+ name: "blockHash",
16561
+ type: "bytes32",
16562
+ },
16563
+ ],
16564
+ stateMutability: "view",
16565
+ type: "function",
16566
+ },
16567
+ {
16568
+ inputs: [],
16569
+ name: "getBlockNumber",
16570
+ outputs: [
16571
+ {
16572
+ internalType: "uint256",
16573
+ name: "blockNumber",
16574
+ type: "uint256",
16575
+ },
16576
+ ],
16577
+ stateMutability: "view",
16578
+ type: "function",
16579
+ },
16580
+ {
16581
+ inputs: [],
16582
+ name: "getChainId",
16583
+ outputs: [
16584
+ {
16585
+ internalType: "uint256",
16586
+ name: "chainid",
16587
+ type: "uint256",
16588
+ },
16589
+ ],
16590
+ stateMutability: "view",
16591
+ type: "function",
16592
+ },
16593
+ {
16594
+ inputs: [],
16595
+ name: "getCurrentBlockCoinbase",
16596
+ outputs: [
16597
+ {
16598
+ internalType: "address",
16599
+ name: "coinbase",
16600
+ type: "address",
16601
+ },
16602
+ ],
16603
+ stateMutability: "view",
16604
+ type: "function",
16605
+ },
16606
+ {
16607
+ inputs: [],
16608
+ name: "getCurrentBlockDifficulty",
16609
+ outputs: [
16610
+ {
16611
+ internalType: "uint256",
16612
+ name: "difficulty",
16613
+ type: "uint256",
16614
+ },
16615
+ ],
16616
+ stateMutability: "view",
16617
+ type: "function",
16618
+ },
16619
+ {
16620
+ inputs: [],
16621
+ name: "getCurrentBlockGasLimit",
16622
+ outputs: [
16623
+ {
16624
+ internalType: "uint256",
16625
+ name: "gaslimit",
16626
+ type: "uint256",
16627
+ },
16628
+ ],
16629
+ stateMutability: "view",
16630
+ type: "function",
16631
+ },
16632
+ {
16633
+ inputs: [],
16634
+ name: "getCurrentBlockTimestamp",
16635
+ outputs: [
16636
+ {
16637
+ internalType: "uint256",
16638
+ name: "timestamp",
16639
+ type: "uint256",
16640
+ },
16641
+ ],
16642
+ stateMutability: "view",
16643
+ type: "function",
16644
+ },
16645
+ {
16646
+ inputs: [
16647
+ {
16648
+ internalType: "address",
16649
+ name: "addr",
16650
+ type: "address",
16651
+ },
16652
+ ],
16653
+ name: "getEthBalance",
16654
+ outputs: [
16655
+ {
16656
+ internalType: "uint256",
16657
+ name: "balance",
16658
+ type: "uint256",
16659
+ },
16660
+ ],
16661
+ stateMutability: "view",
16662
+ type: "function",
16663
+ },
16664
+ {
16665
+ inputs: [],
16666
+ name: "getLastBlockHash",
16667
+ outputs: [
16668
+ {
16669
+ internalType: "bytes32",
16670
+ name: "blockHash",
16671
+ type: "bytes32",
16672
+ },
16673
+ ],
16674
+ stateMutability: "view",
16675
+ type: "function",
16676
+ },
16677
+ {
16678
+ inputs: [
16679
+ {
16680
+ internalType: "bool",
16681
+ name: "requireSuccess",
16682
+ type: "bool",
16683
+ },
16684
+ {
16685
+ components: [
16686
+ {
16687
+ internalType: "address",
16688
+ name: "target",
16689
+ type: "address",
16690
+ },
16691
+ {
16692
+ internalType: "bytes",
16693
+ name: "callData",
16694
+ type: "bytes",
16695
+ },
16696
+ ],
16697
+ internalType: "struct Multicall3.Call[]",
16698
+ name: "calls",
16699
+ type: "tuple[]",
16700
+ },
16701
+ ],
16702
+ name: "tryAggregate",
16703
+ outputs: [
16704
+ {
16705
+ components: [
16706
+ {
16707
+ internalType: "bool",
16708
+ name: "success",
16709
+ type: "bool",
16710
+ },
16711
+ {
16712
+ internalType: "bytes",
16713
+ name: "returnData",
16714
+ type: "bytes",
16715
+ },
16716
+ ],
16717
+ internalType: "struct Multicall3.Result[]",
16718
+ name: "returnData",
16719
+ type: "tuple[]",
16720
+ },
16721
+ ],
16722
+ stateMutability: "payable",
16723
+ type: "function",
16724
+ },
16725
+ {
16726
+ inputs: [
16727
+ {
16728
+ internalType: "bool",
16729
+ name: "requireSuccess",
16730
+ type: "bool",
16731
+ },
16732
+ {
16733
+ components: [
16734
+ {
16735
+ internalType: "address",
16736
+ name: "target",
16737
+ type: "address",
16738
+ },
16739
+ {
16740
+ internalType: "bytes",
16741
+ name: "callData",
16742
+ type: "bytes",
16743
+ },
16744
+ ],
16745
+ internalType: "struct Multicall3.Call[]",
16746
+ name: "calls",
16747
+ type: "tuple[]",
16748
+ },
16749
+ ],
16750
+ name: "tryBlockAndAggregate",
16751
+ outputs: [
16752
+ {
16753
+ internalType: "uint256",
16754
+ name: "blockNumber",
16755
+ type: "uint256",
16756
+ },
16757
+ {
16758
+ internalType: "bytes32",
16759
+ name: "blockHash",
16760
+ type: "bytes32",
16761
+ },
16762
+ {
16763
+ components: [
16764
+ {
16765
+ internalType: "bool",
16766
+ name: "success",
16767
+ type: "bool",
16768
+ },
16769
+ {
16770
+ internalType: "bytes",
16771
+ name: "returnData",
16772
+ type: "bytes",
16773
+ },
16774
+ ],
16775
+ internalType: "struct Multicall3.Result[]",
16776
+ name: "returnData",
16777
+ type: "tuple[]",
16778
+ },
16779
+ ],
16780
+ stateMutability: "payable",
16781
+ type: "function",
16782
+ },
16783
+ ];
16784
+
16785
+ class ReadMulticall {
16786
+ constructor(drift) {
16787
+ // same address across all chains
16788
+ this.address = "0xcA11bde05977b3631167028862bE2a173976CA11";
16789
+ this.contract = drift.contract({
16790
+ abi: MulticallAbi,
16791
+ address: this.address,
16792
+ });
16793
+ }
16794
+ aggregate3(calls) {
16795
+ return this.contract.simulateWrite("aggregate3", {
16796
+ calls: calls.map((call) => ({
16797
+ target: call.target,
16798
+ allowFailure: true,
16799
+ callData: call.callData,
16800
+ })),
16801
+ });
16802
+ }
16803
+ }
16804
+
16321
16805
  class ReadRevenueManager {
16322
16806
  constructor(address, drift = createDrift()) {
16807
+ this.drift = drift;
16323
16808
  this.contract = drift.contract({
16324
16809
  abi: RevenueManagerAbi,
16325
16810
  address,
@@ -16342,6 +16827,51 @@ class ReadRevenueManager {
16342
16827
  protocolRecipient() {
16343
16828
  return this.contract.read("protocolRecipient");
16344
16829
  }
16830
+ /**
16831
+ * Gets the total number of tokens managed by the revenue manager
16832
+ * @returns Promise<bigint> - The total count of tokens
16833
+ */
16834
+ async tokensCount() {
16835
+ const nextInternalId = await this.contract.read("nextInternalId");
16836
+ return nextInternalId - 1n;
16837
+ }
16838
+ /**
16839
+ * Gets all tokens created by a specific creator address
16840
+ * @param creator - The address of the creator to query tokens for
16841
+ * @param sortByDesc - Optional boolean to sort tokens in descending order (default: false)
16842
+ * @returns Promise<Array<{flaunch: Address, tokenId: bigint}>> - Array of token objects containing flaunch address and token ID
16843
+ */
16844
+ async allTokensByCreator(creator, sortByDesc = false) {
16845
+ const tokens = await this.contract.read("tokens", {
16846
+ _creator: creator,
16847
+ });
16848
+ if (sortByDesc) {
16849
+ return [...tokens].reverse();
16850
+ }
16851
+ return tokens;
16852
+ }
16853
+ /**
16854
+ * Gets all tokens currently managed by the revenue manager contract
16855
+ * @dev Uses multicall to batch requests for better performance
16856
+ * @param sortByDesc - Optional boolean to sort tokens in descending order (default: false)
16857
+ * @returns Promise<Array<{flaunch: Address, tokenId: bigint}>> - Array of token objects containing flaunch address and token ID
16858
+ */
16859
+ async allTokensInManager(sortByDesc = false) {
16860
+ const count = await this.tokensCount();
16861
+ const multicall = new ReadMulticall(this.drift);
16862
+ let calldatas = Array.from({ length: Number(count) }, (_, i) => this.contract.encodeFunctionData("internalIds", {
16863
+ _internalId: BigInt(i + 1),
16864
+ }));
16865
+ // Reverse the array if sortByDesc is true
16866
+ if (sortByDesc) {
16867
+ calldatas = calldatas.reverse();
16868
+ }
16869
+ const result = await multicall.aggregate3(calldatas.map((calldata) => ({
16870
+ target: this.contract.address,
16871
+ callData: calldata,
16872
+ })));
16873
+ return result.map((r) => this.contract.decodeFunctionReturn("internalIds", r.returnData));
16874
+ }
16345
16875
  }
16346
16876
  class ReadWriteRevenueManager extends ReadRevenueManager {
16347
16877
  constructor(address, drift = createDrift()) {
@@ -17041,6 +17571,7 @@ class ReadFlaunchSDK {
17041
17571
  this.TICK_SPACING = TICK_SPACING;
17042
17572
  this.chainId = chainId;
17043
17573
  this.drift = drift;
17574
+ this.resolveIPFS = resolveIPFS;
17044
17575
  this.readPositionManager = new ReadFlaunchPositionManager(FlaunchPositionManagerAddress[this.chainId], drift);
17045
17576
  this.readPositionManagerV1_1 = new ReadFlaunchPositionManagerV1_1(FlaunchPositionManagerV1_1Address[this.chainId], drift);
17046
17577
  this.readPoolManager = new ReadPoolManager(PoolManagerAddress[this.chainId], drift);
@@ -17082,12 +17613,12 @@ class ReadFlaunchSDK {
17082
17613
  const symbol = await memecoin.symbol();
17083
17614
  const tokenURI = await memecoin.tokenURI();
17084
17615
  // get metadata from tokenURI
17085
- const metadata = (await axios.get(resolveIPFS(tokenURI))).data;
17616
+ const metadata = (await axios.get(this.resolveIPFS(tokenURI))).data;
17086
17617
  return {
17087
17618
  name,
17088
17619
  symbol,
17089
17620
  description: metadata.description ?? "",
17090
- image: metadata.image ? resolveIPFS(metadata.image) : "",
17621
+ image: metadata.image ? this.resolveIPFS(metadata.image) : "",
17091
17622
  external_link: metadata.websiteUrl ?? "",
17092
17623
  collaborators: metadata.collaborators ?? [],
17093
17624
  discordUrl: metadata.discordUrl ?? "",
@@ -17095,6 +17626,103 @@ class ReadFlaunchSDK {
17095
17626
  telegramUrl: metadata.telegramUrl ?? "",
17096
17627
  };
17097
17628
  }
17629
+ /**
17630
+ * Retrieves metadata for a given Flaunch coin using its token ID & Flaunch contract address
17631
+ * @param flaunch - The address of the Flaunch contract
17632
+ * @param tokenId - The token ID of the coin
17633
+ * @returns The coin's metadata including name, symbol, description, and social links
17634
+ */
17635
+ async getCoinMetadataFromTokenId(flaunch, tokenId) {
17636
+ const _flaunch = new ReadFlaunch(flaunch, this.drift);
17637
+ const coinAddress = await _flaunch.memecoin(tokenId);
17638
+ return this.getCoinMetadata(coinAddress);
17639
+ }
17640
+ /**
17641
+ * Retrieves metadata for multiple Flaunch coins using their token IDs & Flaunch contract addresses
17642
+ * @param params - An array of objects containing flaunch contract address and token ID
17643
+ * @param batchSize - Optional, the number of ipfs requests to process in each batch
17644
+ * @param batchDelay - Optional, the delay in milliseconds between batches
17645
+ * @returns An array of objects containing coin address, name, symbol, description, and social links
17646
+ */
17647
+ async getCoinMetadataFromTokenIds(params, batchSize = 9, batchDelay = 500) {
17648
+ const multicall = new ReadMulticall(this.drift);
17649
+ // get coin addresses via multicall
17650
+ const coinAddresses_calldata = params.map((p) => this.readFlaunch.contract.encodeFunctionData("memecoin", {
17651
+ _tokenId: p.tokenId,
17652
+ }));
17653
+ const coinAddresses_result = await multicall.aggregate3(coinAddresses_calldata.map((calldata, i) => ({
17654
+ target: params[i].flaunch,
17655
+ callData: calldata,
17656
+ })));
17657
+ const coinAddresses = coinAddresses_result.map((r) => this.readFlaunch.contract.decodeFunctionReturn("memecoin", r.returnData));
17658
+ /// get coin metadata for each coin address via multicall
17659
+ const coinMetadata_calldata = [];
17660
+ // name, symbol, tokenURI for each coin
17661
+ coinAddresses.forEach(() => {
17662
+ coinMetadata_calldata.push(this.drift.adapter.encodeFunctionData({
17663
+ abi: MemecoinAbi,
17664
+ fn: "name",
17665
+ }));
17666
+ coinMetadata_calldata.push(this.drift.adapter.encodeFunctionData({
17667
+ abi: MemecoinAbi,
17668
+ fn: "symbol",
17669
+ }));
17670
+ coinMetadata_calldata.push(this.drift.adapter.encodeFunctionData({
17671
+ abi: MemecoinAbi,
17672
+ fn: "tokenURI",
17673
+ }));
17674
+ });
17675
+ const coinMetadata_result = await multicall.aggregate3(coinMetadata_calldata.map((calldata, i) => ({
17676
+ target: coinAddresses[Math.floor(i / 3)],
17677
+ callData: calldata,
17678
+ })));
17679
+ // First decode all the results
17680
+ const results = [];
17681
+ for (let i = 0; i < coinAddresses.length; i++) {
17682
+ const name = this.drift.adapter.decodeFunctionReturn({
17683
+ abi: MemecoinAbi,
17684
+ fn: "name",
17685
+ data: coinMetadata_result[i * 3].returnData,
17686
+ });
17687
+ const symbol = this.drift.adapter.decodeFunctionReturn({
17688
+ abi: MemecoinAbi,
17689
+ fn: "symbol",
17690
+ data: coinMetadata_result[i * 3 + 1].returnData,
17691
+ });
17692
+ const tokenURI = this.drift.adapter.decodeFunctionReturn({
17693
+ abi: MemecoinAbi,
17694
+ fn: "tokenURI",
17695
+ data: coinMetadata_result[i * 3 + 2].returnData,
17696
+ });
17697
+ results.push({ name, symbol, tokenURI, coinAddress: coinAddresses[i] });
17698
+ }
17699
+ // Process IPFS requests in batches to avoid rate limiting
17700
+ const processedResults = [];
17701
+ for (let i = 0; i < results.length; i += batchSize) {
17702
+ const batch = results.slice(i, i + batchSize);
17703
+ const batchResults = await Promise.all(batch.map(async ({ name, symbol, tokenURI, coinAddress }) => {
17704
+ const metadata = (await axios.get(this.resolveIPFS(tokenURI))).data;
17705
+ return {
17706
+ coinAddress,
17707
+ name,
17708
+ symbol,
17709
+ description: metadata.description ?? "",
17710
+ image: metadata.image ? this.resolveIPFS(metadata.image) : "",
17711
+ external_link: metadata.websiteUrl ?? "",
17712
+ collaborators: metadata.collaborators ?? [],
17713
+ discordUrl: metadata.discordUrl ?? "",
17714
+ twitterUrl: metadata.twitterUrl ?? "",
17715
+ telegramUrl: metadata.telegramUrl ?? "",
17716
+ };
17717
+ }));
17718
+ processedResults.push(...batchResults);
17719
+ // Add a small delay between batches to avoid rate limiting
17720
+ if (i + batchSize < results.length) {
17721
+ await new Promise((resolve) => setTimeout(resolve, batchDelay));
17722
+ }
17723
+ }
17724
+ return processedResults;
17725
+ }
17098
17726
  /**
17099
17727
  * Watches for pool creation events on V1 contracts
17100
17728
  * @param params - Parameters for watching pool creation
@@ -17456,6 +18084,38 @@ class ReadFlaunchSDK {
17456
18084
  const protocolRecipient = await readRevenueManager.protocolRecipient();
17457
18085
  return readRevenueManager.balances(protocolRecipient);
17458
18086
  }
18087
+ /**
18088
+ * Gets the total number of tokens managed by a revenue manager
18089
+ * @param revenueManagerAddress - The address of the revenue manager
18090
+ * @returns Promise<bigint> - The total count of tokens
18091
+ */
18092
+ async revenueManagerTokensCount(revenueManagerAddress) {
18093
+ const readRevenueManager = new ReadRevenueManager(revenueManagerAddress, this.drift);
18094
+ return readRevenueManager.tokensCount();
18095
+ }
18096
+ /**
18097
+ * Gets all tokens created by a specific creator address
18098
+ * @param params - Parameters for querying tokens by creator
18099
+ * @param params.revenueManagerAddress - The address of the revenue manager
18100
+ * @param params.creator - The address of the creator to query tokens for
18101
+ * @param params.sortByDesc - Whether to sort the tokens by descending order
18102
+ * @returns Promise<Array<{flaunch: Address, tokenId: bigint}>> - Array of token objects containing flaunch address and token ID
18103
+ */
18104
+ async revenueManagerAllTokensByCreator(params) {
18105
+ const readRevenueManager = new ReadRevenueManager(params.revenueManagerAddress, this.drift);
18106
+ return readRevenueManager.allTokensByCreator(params.creator, params.sortByDesc);
18107
+ }
18108
+ /**
18109
+ * Gets all tokens currently managed by a revenue manager
18110
+ * @param params - Parameters for querying tokens in manager
18111
+ * @param params.revenueManagerAddress - The address of the revenue manager
18112
+ * @param params.sortByDesc - Optional boolean to sort tokens in descending order (default: false)
18113
+ * @returns Promise<Array<{flaunch: Address, tokenId: bigint}>> - Array of token objects containing flaunch address and token ID
18114
+ */
18115
+ async revenueManagerAllTokensInManager(params) {
18116
+ const readRevenueManager = new ReadRevenueManager(params.revenueManagerAddress, this.drift);
18117
+ return readRevenueManager.allTokensInManager(params.sortByDesc);
18118
+ }
17459
18119
  /**
17460
18120
  * Gets the pool ID for a given coin
17461
18121
  * @param coinAddress - The address of the coin
@@ -17484,6 +18144,14 @@ class ReadFlaunchSDK {
17484
18144
  flETHIsCurrencyZero(coinAddress) {
17485
18145
  return coinAddress > FLETHAddress[this.chainId];
17486
18146
  }
18147
+ /**
18148
+ * Sets a custom IPFS resolver function
18149
+ * @dev this is used to resolve IPFS hash to a gateway URL
18150
+ * @param resolverFn - Custom function to resolve IPFS URIs
18151
+ */
18152
+ setIPFSResolver(resolverFn) {
18153
+ this.resolveIPFS = resolverFn;
18154
+ }
17487
18155
  }
17488
18156
  class ReadWriteFlaunchSDK extends ReadFlaunchSDK {
17489
18157
  constructor(chainId, drift = createDrift()) {