@flaunch/sdk 0.4.0 → 0.4.1
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/abi/Multicall.d.ts +333 -0
- package/dist/abi/Multicall.d.ts.map +1 -0
- package/dist/clients/FlaunchClient.d.ts +6 -0
- package/dist/clients/FlaunchClient.d.ts.map +1 -1
- package/dist/clients/MulticallClient.d.ts +16 -0
- package/dist/clients/MulticallClient.d.ts.map +1 -0
- package/dist/clients/RevenueManagerClient.d.ts +26 -0
- package/dist/clients/RevenueManagerClient.d.ts.map +1 -1
- package/dist/index.cjs.js +634 -0
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +634 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/sdk/FlaunchSDK.d.ts +54 -0
- package/dist/sdk/FlaunchSDK.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -10204,6 +10204,16 @@ class ReadFlaunch {
|
|
|
10204
10204
|
_tokenId: tokenId,
|
|
10205
10205
|
});
|
|
10206
10206
|
}
|
|
10207
|
+
/**
|
|
10208
|
+
* Gets the memecoin address for a given token ID
|
|
10209
|
+
* @param tokenId - The ID of the token
|
|
10210
|
+
* @returns Promise<Address> - The address of the memecoin
|
|
10211
|
+
*/
|
|
10212
|
+
memecoin(tokenId) {
|
|
10213
|
+
return this.contract.read("memecoin", {
|
|
10214
|
+
_tokenId: tokenId,
|
|
10215
|
+
});
|
|
10216
|
+
}
|
|
10207
10217
|
}
|
|
10208
10218
|
|
|
10209
10219
|
const MemecoinAbi = [
|
|
@@ -16326,8 +16336,470 @@ const RevenueManagerAbi = [
|
|
|
16326
16336
|
{ stateMutability: "payable", type: "receive" },
|
|
16327
16337
|
];
|
|
16328
16338
|
|
|
16339
|
+
const MulticallAbi = [
|
|
16340
|
+
{
|
|
16341
|
+
inputs: [
|
|
16342
|
+
{
|
|
16343
|
+
components: [
|
|
16344
|
+
{
|
|
16345
|
+
internalType: "address",
|
|
16346
|
+
name: "target",
|
|
16347
|
+
type: "address",
|
|
16348
|
+
},
|
|
16349
|
+
{
|
|
16350
|
+
internalType: "bytes",
|
|
16351
|
+
name: "callData",
|
|
16352
|
+
type: "bytes",
|
|
16353
|
+
},
|
|
16354
|
+
],
|
|
16355
|
+
internalType: "struct Multicall3.Call[]",
|
|
16356
|
+
name: "calls",
|
|
16357
|
+
type: "tuple[]",
|
|
16358
|
+
},
|
|
16359
|
+
],
|
|
16360
|
+
name: "aggregate",
|
|
16361
|
+
outputs: [
|
|
16362
|
+
{
|
|
16363
|
+
internalType: "uint256",
|
|
16364
|
+
name: "blockNumber",
|
|
16365
|
+
type: "uint256",
|
|
16366
|
+
},
|
|
16367
|
+
{
|
|
16368
|
+
internalType: "bytes[]",
|
|
16369
|
+
name: "returnData",
|
|
16370
|
+
type: "bytes[]",
|
|
16371
|
+
},
|
|
16372
|
+
],
|
|
16373
|
+
stateMutability: "payable",
|
|
16374
|
+
type: "function",
|
|
16375
|
+
},
|
|
16376
|
+
{
|
|
16377
|
+
inputs: [
|
|
16378
|
+
{
|
|
16379
|
+
components: [
|
|
16380
|
+
{
|
|
16381
|
+
internalType: "address",
|
|
16382
|
+
name: "target",
|
|
16383
|
+
type: "address",
|
|
16384
|
+
},
|
|
16385
|
+
{
|
|
16386
|
+
internalType: "bool",
|
|
16387
|
+
name: "allowFailure",
|
|
16388
|
+
type: "bool",
|
|
16389
|
+
},
|
|
16390
|
+
{
|
|
16391
|
+
internalType: "bytes",
|
|
16392
|
+
name: "callData",
|
|
16393
|
+
type: "bytes",
|
|
16394
|
+
},
|
|
16395
|
+
],
|
|
16396
|
+
internalType: "struct Multicall3.Call3[]",
|
|
16397
|
+
name: "calls",
|
|
16398
|
+
type: "tuple[]",
|
|
16399
|
+
},
|
|
16400
|
+
],
|
|
16401
|
+
name: "aggregate3",
|
|
16402
|
+
outputs: [
|
|
16403
|
+
{
|
|
16404
|
+
components: [
|
|
16405
|
+
{
|
|
16406
|
+
internalType: "bool",
|
|
16407
|
+
name: "success",
|
|
16408
|
+
type: "bool",
|
|
16409
|
+
},
|
|
16410
|
+
{
|
|
16411
|
+
internalType: "bytes",
|
|
16412
|
+
name: "returnData",
|
|
16413
|
+
type: "bytes",
|
|
16414
|
+
},
|
|
16415
|
+
],
|
|
16416
|
+
internalType: "struct Multicall3.Result[]",
|
|
16417
|
+
name: "returnData",
|
|
16418
|
+
type: "tuple[]",
|
|
16419
|
+
},
|
|
16420
|
+
],
|
|
16421
|
+
stateMutability: "payable",
|
|
16422
|
+
type: "function",
|
|
16423
|
+
},
|
|
16424
|
+
{
|
|
16425
|
+
inputs: [
|
|
16426
|
+
{
|
|
16427
|
+
components: [
|
|
16428
|
+
{
|
|
16429
|
+
internalType: "address",
|
|
16430
|
+
name: "target",
|
|
16431
|
+
type: "address",
|
|
16432
|
+
},
|
|
16433
|
+
{
|
|
16434
|
+
internalType: "bool",
|
|
16435
|
+
name: "allowFailure",
|
|
16436
|
+
type: "bool",
|
|
16437
|
+
},
|
|
16438
|
+
{
|
|
16439
|
+
internalType: "uint256",
|
|
16440
|
+
name: "value",
|
|
16441
|
+
type: "uint256",
|
|
16442
|
+
},
|
|
16443
|
+
{
|
|
16444
|
+
internalType: "bytes",
|
|
16445
|
+
name: "callData",
|
|
16446
|
+
type: "bytes",
|
|
16447
|
+
},
|
|
16448
|
+
],
|
|
16449
|
+
internalType: "struct Multicall3.Call3Value[]",
|
|
16450
|
+
name: "calls",
|
|
16451
|
+
type: "tuple[]",
|
|
16452
|
+
},
|
|
16453
|
+
],
|
|
16454
|
+
name: "aggregate3Value",
|
|
16455
|
+
outputs: [
|
|
16456
|
+
{
|
|
16457
|
+
components: [
|
|
16458
|
+
{
|
|
16459
|
+
internalType: "bool",
|
|
16460
|
+
name: "success",
|
|
16461
|
+
type: "bool",
|
|
16462
|
+
},
|
|
16463
|
+
{
|
|
16464
|
+
internalType: "bytes",
|
|
16465
|
+
name: "returnData",
|
|
16466
|
+
type: "bytes",
|
|
16467
|
+
},
|
|
16468
|
+
],
|
|
16469
|
+
internalType: "struct Multicall3.Result[]",
|
|
16470
|
+
name: "returnData",
|
|
16471
|
+
type: "tuple[]",
|
|
16472
|
+
},
|
|
16473
|
+
],
|
|
16474
|
+
stateMutability: "payable",
|
|
16475
|
+
type: "function",
|
|
16476
|
+
},
|
|
16477
|
+
{
|
|
16478
|
+
inputs: [
|
|
16479
|
+
{
|
|
16480
|
+
components: [
|
|
16481
|
+
{
|
|
16482
|
+
internalType: "address",
|
|
16483
|
+
name: "target",
|
|
16484
|
+
type: "address",
|
|
16485
|
+
},
|
|
16486
|
+
{
|
|
16487
|
+
internalType: "bytes",
|
|
16488
|
+
name: "callData",
|
|
16489
|
+
type: "bytes",
|
|
16490
|
+
},
|
|
16491
|
+
],
|
|
16492
|
+
internalType: "struct Multicall3.Call[]",
|
|
16493
|
+
name: "calls",
|
|
16494
|
+
type: "tuple[]",
|
|
16495
|
+
},
|
|
16496
|
+
],
|
|
16497
|
+
name: "blockAndAggregate",
|
|
16498
|
+
outputs: [
|
|
16499
|
+
{
|
|
16500
|
+
internalType: "uint256",
|
|
16501
|
+
name: "blockNumber",
|
|
16502
|
+
type: "uint256",
|
|
16503
|
+
},
|
|
16504
|
+
{
|
|
16505
|
+
internalType: "bytes32",
|
|
16506
|
+
name: "blockHash",
|
|
16507
|
+
type: "bytes32",
|
|
16508
|
+
},
|
|
16509
|
+
{
|
|
16510
|
+
components: [
|
|
16511
|
+
{
|
|
16512
|
+
internalType: "bool",
|
|
16513
|
+
name: "success",
|
|
16514
|
+
type: "bool",
|
|
16515
|
+
},
|
|
16516
|
+
{
|
|
16517
|
+
internalType: "bytes",
|
|
16518
|
+
name: "returnData",
|
|
16519
|
+
type: "bytes",
|
|
16520
|
+
},
|
|
16521
|
+
],
|
|
16522
|
+
internalType: "struct Multicall3.Result[]",
|
|
16523
|
+
name: "returnData",
|
|
16524
|
+
type: "tuple[]",
|
|
16525
|
+
},
|
|
16526
|
+
],
|
|
16527
|
+
stateMutability: "payable",
|
|
16528
|
+
type: "function",
|
|
16529
|
+
},
|
|
16530
|
+
{
|
|
16531
|
+
inputs: [],
|
|
16532
|
+
name: "getBasefee",
|
|
16533
|
+
outputs: [
|
|
16534
|
+
{
|
|
16535
|
+
internalType: "uint256",
|
|
16536
|
+
name: "basefee",
|
|
16537
|
+
type: "uint256",
|
|
16538
|
+
},
|
|
16539
|
+
],
|
|
16540
|
+
stateMutability: "view",
|
|
16541
|
+
type: "function",
|
|
16542
|
+
},
|
|
16543
|
+
{
|
|
16544
|
+
inputs: [
|
|
16545
|
+
{
|
|
16546
|
+
internalType: "uint256",
|
|
16547
|
+
name: "blockNumber",
|
|
16548
|
+
type: "uint256",
|
|
16549
|
+
},
|
|
16550
|
+
],
|
|
16551
|
+
name: "getBlockHash",
|
|
16552
|
+
outputs: [
|
|
16553
|
+
{
|
|
16554
|
+
internalType: "bytes32",
|
|
16555
|
+
name: "blockHash",
|
|
16556
|
+
type: "bytes32",
|
|
16557
|
+
},
|
|
16558
|
+
],
|
|
16559
|
+
stateMutability: "view",
|
|
16560
|
+
type: "function",
|
|
16561
|
+
},
|
|
16562
|
+
{
|
|
16563
|
+
inputs: [],
|
|
16564
|
+
name: "getBlockNumber",
|
|
16565
|
+
outputs: [
|
|
16566
|
+
{
|
|
16567
|
+
internalType: "uint256",
|
|
16568
|
+
name: "blockNumber",
|
|
16569
|
+
type: "uint256",
|
|
16570
|
+
},
|
|
16571
|
+
],
|
|
16572
|
+
stateMutability: "view",
|
|
16573
|
+
type: "function",
|
|
16574
|
+
},
|
|
16575
|
+
{
|
|
16576
|
+
inputs: [],
|
|
16577
|
+
name: "getChainId",
|
|
16578
|
+
outputs: [
|
|
16579
|
+
{
|
|
16580
|
+
internalType: "uint256",
|
|
16581
|
+
name: "chainid",
|
|
16582
|
+
type: "uint256",
|
|
16583
|
+
},
|
|
16584
|
+
],
|
|
16585
|
+
stateMutability: "view",
|
|
16586
|
+
type: "function",
|
|
16587
|
+
},
|
|
16588
|
+
{
|
|
16589
|
+
inputs: [],
|
|
16590
|
+
name: "getCurrentBlockCoinbase",
|
|
16591
|
+
outputs: [
|
|
16592
|
+
{
|
|
16593
|
+
internalType: "address",
|
|
16594
|
+
name: "coinbase",
|
|
16595
|
+
type: "address",
|
|
16596
|
+
},
|
|
16597
|
+
],
|
|
16598
|
+
stateMutability: "view",
|
|
16599
|
+
type: "function",
|
|
16600
|
+
},
|
|
16601
|
+
{
|
|
16602
|
+
inputs: [],
|
|
16603
|
+
name: "getCurrentBlockDifficulty",
|
|
16604
|
+
outputs: [
|
|
16605
|
+
{
|
|
16606
|
+
internalType: "uint256",
|
|
16607
|
+
name: "difficulty",
|
|
16608
|
+
type: "uint256",
|
|
16609
|
+
},
|
|
16610
|
+
],
|
|
16611
|
+
stateMutability: "view",
|
|
16612
|
+
type: "function",
|
|
16613
|
+
},
|
|
16614
|
+
{
|
|
16615
|
+
inputs: [],
|
|
16616
|
+
name: "getCurrentBlockGasLimit",
|
|
16617
|
+
outputs: [
|
|
16618
|
+
{
|
|
16619
|
+
internalType: "uint256",
|
|
16620
|
+
name: "gaslimit",
|
|
16621
|
+
type: "uint256",
|
|
16622
|
+
},
|
|
16623
|
+
],
|
|
16624
|
+
stateMutability: "view",
|
|
16625
|
+
type: "function",
|
|
16626
|
+
},
|
|
16627
|
+
{
|
|
16628
|
+
inputs: [],
|
|
16629
|
+
name: "getCurrentBlockTimestamp",
|
|
16630
|
+
outputs: [
|
|
16631
|
+
{
|
|
16632
|
+
internalType: "uint256",
|
|
16633
|
+
name: "timestamp",
|
|
16634
|
+
type: "uint256",
|
|
16635
|
+
},
|
|
16636
|
+
],
|
|
16637
|
+
stateMutability: "view",
|
|
16638
|
+
type: "function",
|
|
16639
|
+
},
|
|
16640
|
+
{
|
|
16641
|
+
inputs: [
|
|
16642
|
+
{
|
|
16643
|
+
internalType: "address",
|
|
16644
|
+
name: "addr",
|
|
16645
|
+
type: "address",
|
|
16646
|
+
},
|
|
16647
|
+
],
|
|
16648
|
+
name: "getEthBalance",
|
|
16649
|
+
outputs: [
|
|
16650
|
+
{
|
|
16651
|
+
internalType: "uint256",
|
|
16652
|
+
name: "balance",
|
|
16653
|
+
type: "uint256",
|
|
16654
|
+
},
|
|
16655
|
+
],
|
|
16656
|
+
stateMutability: "view",
|
|
16657
|
+
type: "function",
|
|
16658
|
+
},
|
|
16659
|
+
{
|
|
16660
|
+
inputs: [],
|
|
16661
|
+
name: "getLastBlockHash",
|
|
16662
|
+
outputs: [
|
|
16663
|
+
{
|
|
16664
|
+
internalType: "bytes32",
|
|
16665
|
+
name: "blockHash",
|
|
16666
|
+
type: "bytes32",
|
|
16667
|
+
},
|
|
16668
|
+
],
|
|
16669
|
+
stateMutability: "view",
|
|
16670
|
+
type: "function",
|
|
16671
|
+
},
|
|
16672
|
+
{
|
|
16673
|
+
inputs: [
|
|
16674
|
+
{
|
|
16675
|
+
internalType: "bool",
|
|
16676
|
+
name: "requireSuccess",
|
|
16677
|
+
type: "bool",
|
|
16678
|
+
},
|
|
16679
|
+
{
|
|
16680
|
+
components: [
|
|
16681
|
+
{
|
|
16682
|
+
internalType: "address",
|
|
16683
|
+
name: "target",
|
|
16684
|
+
type: "address",
|
|
16685
|
+
},
|
|
16686
|
+
{
|
|
16687
|
+
internalType: "bytes",
|
|
16688
|
+
name: "callData",
|
|
16689
|
+
type: "bytes",
|
|
16690
|
+
},
|
|
16691
|
+
],
|
|
16692
|
+
internalType: "struct Multicall3.Call[]",
|
|
16693
|
+
name: "calls",
|
|
16694
|
+
type: "tuple[]",
|
|
16695
|
+
},
|
|
16696
|
+
],
|
|
16697
|
+
name: "tryAggregate",
|
|
16698
|
+
outputs: [
|
|
16699
|
+
{
|
|
16700
|
+
components: [
|
|
16701
|
+
{
|
|
16702
|
+
internalType: "bool",
|
|
16703
|
+
name: "success",
|
|
16704
|
+
type: "bool",
|
|
16705
|
+
},
|
|
16706
|
+
{
|
|
16707
|
+
internalType: "bytes",
|
|
16708
|
+
name: "returnData",
|
|
16709
|
+
type: "bytes",
|
|
16710
|
+
},
|
|
16711
|
+
],
|
|
16712
|
+
internalType: "struct Multicall3.Result[]",
|
|
16713
|
+
name: "returnData",
|
|
16714
|
+
type: "tuple[]",
|
|
16715
|
+
},
|
|
16716
|
+
],
|
|
16717
|
+
stateMutability: "payable",
|
|
16718
|
+
type: "function",
|
|
16719
|
+
},
|
|
16720
|
+
{
|
|
16721
|
+
inputs: [
|
|
16722
|
+
{
|
|
16723
|
+
internalType: "bool",
|
|
16724
|
+
name: "requireSuccess",
|
|
16725
|
+
type: "bool",
|
|
16726
|
+
},
|
|
16727
|
+
{
|
|
16728
|
+
components: [
|
|
16729
|
+
{
|
|
16730
|
+
internalType: "address",
|
|
16731
|
+
name: "target",
|
|
16732
|
+
type: "address",
|
|
16733
|
+
},
|
|
16734
|
+
{
|
|
16735
|
+
internalType: "bytes",
|
|
16736
|
+
name: "callData",
|
|
16737
|
+
type: "bytes",
|
|
16738
|
+
},
|
|
16739
|
+
],
|
|
16740
|
+
internalType: "struct Multicall3.Call[]",
|
|
16741
|
+
name: "calls",
|
|
16742
|
+
type: "tuple[]",
|
|
16743
|
+
},
|
|
16744
|
+
],
|
|
16745
|
+
name: "tryBlockAndAggregate",
|
|
16746
|
+
outputs: [
|
|
16747
|
+
{
|
|
16748
|
+
internalType: "uint256",
|
|
16749
|
+
name: "blockNumber",
|
|
16750
|
+
type: "uint256",
|
|
16751
|
+
},
|
|
16752
|
+
{
|
|
16753
|
+
internalType: "bytes32",
|
|
16754
|
+
name: "blockHash",
|
|
16755
|
+
type: "bytes32",
|
|
16756
|
+
},
|
|
16757
|
+
{
|
|
16758
|
+
components: [
|
|
16759
|
+
{
|
|
16760
|
+
internalType: "bool",
|
|
16761
|
+
name: "success",
|
|
16762
|
+
type: "bool",
|
|
16763
|
+
},
|
|
16764
|
+
{
|
|
16765
|
+
internalType: "bytes",
|
|
16766
|
+
name: "returnData",
|
|
16767
|
+
type: "bytes",
|
|
16768
|
+
},
|
|
16769
|
+
],
|
|
16770
|
+
internalType: "struct Multicall3.Result[]",
|
|
16771
|
+
name: "returnData",
|
|
16772
|
+
type: "tuple[]",
|
|
16773
|
+
},
|
|
16774
|
+
],
|
|
16775
|
+
stateMutability: "payable",
|
|
16776
|
+
type: "function",
|
|
16777
|
+
},
|
|
16778
|
+
];
|
|
16779
|
+
|
|
16780
|
+
class ReadMulticall {
|
|
16781
|
+
constructor(drift) {
|
|
16782
|
+
// same address across all chains
|
|
16783
|
+
this.address = "0xcA11bde05977b3631167028862bE2a173976CA11";
|
|
16784
|
+
this.contract = drift.contract({
|
|
16785
|
+
abi: MulticallAbi,
|
|
16786
|
+
address: this.address,
|
|
16787
|
+
});
|
|
16788
|
+
}
|
|
16789
|
+
aggregate3(calls) {
|
|
16790
|
+
return this.contract.simulateWrite("aggregate3", {
|
|
16791
|
+
calls: calls.map((call) => ({
|
|
16792
|
+
target: call.target,
|
|
16793
|
+
allowFailure: true,
|
|
16794
|
+
callData: call.callData,
|
|
16795
|
+
})),
|
|
16796
|
+
});
|
|
16797
|
+
}
|
|
16798
|
+
}
|
|
16799
|
+
|
|
16329
16800
|
class ReadRevenueManager {
|
|
16330
16801
|
constructor(address, drift$1 = drift.createDrift()) {
|
|
16802
|
+
this.drift = drift$1;
|
|
16331
16803
|
this.contract = drift$1.contract({
|
|
16332
16804
|
abi: RevenueManagerAbi,
|
|
16333
16805
|
address,
|
|
@@ -16350,6 +16822,51 @@ class ReadRevenueManager {
|
|
|
16350
16822
|
protocolRecipient() {
|
|
16351
16823
|
return this.contract.read("protocolRecipient");
|
|
16352
16824
|
}
|
|
16825
|
+
/**
|
|
16826
|
+
* Gets the total number of tokens managed by the revenue manager
|
|
16827
|
+
* @returns Promise<bigint> - The total count of tokens
|
|
16828
|
+
*/
|
|
16829
|
+
async tokensCount() {
|
|
16830
|
+
const nextInternalId = await this.contract.read("nextInternalId");
|
|
16831
|
+
return nextInternalId - 1n;
|
|
16832
|
+
}
|
|
16833
|
+
/**
|
|
16834
|
+
* Gets all tokens created by a specific creator address
|
|
16835
|
+
* @param creator - The address of the creator to query tokens for
|
|
16836
|
+
* @param sortByDesc - Optional boolean to sort tokens in descending order (default: false)
|
|
16837
|
+
* @returns Promise<Array<{flaunch: Address, tokenId: bigint}>> - Array of token objects containing flaunch address and token ID
|
|
16838
|
+
*/
|
|
16839
|
+
async allTokensByCreator(creator, sortByDesc = false) {
|
|
16840
|
+
const tokens = await this.contract.read("tokens", {
|
|
16841
|
+
_creator: creator,
|
|
16842
|
+
});
|
|
16843
|
+
if (sortByDesc) {
|
|
16844
|
+
return [...tokens].reverse();
|
|
16845
|
+
}
|
|
16846
|
+
return tokens;
|
|
16847
|
+
}
|
|
16848
|
+
/**
|
|
16849
|
+
* Gets all tokens currently managed by the revenue manager contract
|
|
16850
|
+
* @dev Uses multicall to batch requests for better performance
|
|
16851
|
+
* @param sortByDesc - Optional boolean to sort tokens in descending order (default: false)
|
|
16852
|
+
* @returns Promise<Array<{flaunch: Address, tokenId: bigint}>> - Array of token objects containing flaunch address and token ID
|
|
16853
|
+
*/
|
|
16854
|
+
async allTokensInManager(sortByDesc = false) {
|
|
16855
|
+
const count = await this.tokensCount();
|
|
16856
|
+
const multicall = new ReadMulticall(this.drift);
|
|
16857
|
+
let calldatas = Array.from({ length: Number(count) }, (_, i) => this.contract.encodeFunctionData("internalIds", {
|
|
16858
|
+
_internalId: BigInt(i + 1),
|
|
16859
|
+
}));
|
|
16860
|
+
// Reverse the array if sortByDesc is true
|
|
16861
|
+
if (sortByDesc) {
|
|
16862
|
+
calldatas = calldatas.reverse();
|
|
16863
|
+
}
|
|
16864
|
+
const result = await multicall.aggregate3(calldatas.map((calldata) => ({
|
|
16865
|
+
target: this.contract.address,
|
|
16866
|
+
callData: calldata,
|
|
16867
|
+
})));
|
|
16868
|
+
return result.map((r) => this.contract.decodeFunctionReturn("internalIds", r.returnData));
|
|
16869
|
+
}
|
|
16353
16870
|
}
|
|
16354
16871
|
class ReadWriteRevenueManager extends ReadRevenueManager {
|
|
16355
16872
|
constructor(address, drift$1 = drift.createDrift()) {
|
|
@@ -17103,6 +17620,91 @@ class ReadFlaunchSDK {
|
|
|
17103
17620
|
telegramUrl: metadata.telegramUrl ?? "",
|
|
17104
17621
|
};
|
|
17105
17622
|
}
|
|
17623
|
+
async getCoinMetadataFromTokenId(flaunch, tokenId) {
|
|
17624
|
+
const _flaunch = new ReadFlaunch(flaunch, this.drift);
|
|
17625
|
+
const coinAddress = await _flaunch.memecoin(tokenId);
|
|
17626
|
+
return this.getCoinMetadata(coinAddress);
|
|
17627
|
+
}
|
|
17628
|
+
async getCoinMetadataFromTokenIds(params) {
|
|
17629
|
+
const multicall = new ReadMulticall(this.drift);
|
|
17630
|
+
// get coin addresses via multicall
|
|
17631
|
+
const coinAddresses_calldata = params.map((p) => this.readFlaunch.contract.encodeFunctionData("memecoin", {
|
|
17632
|
+
_tokenId: p.tokenId,
|
|
17633
|
+
}));
|
|
17634
|
+
const coinAddresses_result = await multicall.aggregate3(coinAddresses_calldata.map((calldata, i) => ({
|
|
17635
|
+
target: params[i].flaunch,
|
|
17636
|
+
callData: calldata,
|
|
17637
|
+
})));
|
|
17638
|
+
const coinAddresses = coinAddresses_result.map((r) => this.readFlaunch.contract.decodeFunctionReturn("memecoin", r.returnData));
|
|
17639
|
+
/// get coin metadata for each coin address via multicall
|
|
17640
|
+
const coinMetadata_calldata = [];
|
|
17641
|
+
// name, symbol, tokenURI for each coin
|
|
17642
|
+
coinAddresses.forEach(() => {
|
|
17643
|
+
coinMetadata_calldata.push(this.drift.adapter.encodeFunctionData({
|
|
17644
|
+
abi: MemecoinAbi,
|
|
17645
|
+
fn: "name",
|
|
17646
|
+
}));
|
|
17647
|
+
coinMetadata_calldata.push(this.drift.adapter.encodeFunctionData({
|
|
17648
|
+
abi: MemecoinAbi,
|
|
17649
|
+
fn: "symbol",
|
|
17650
|
+
}));
|
|
17651
|
+
coinMetadata_calldata.push(this.drift.adapter.encodeFunctionData({
|
|
17652
|
+
abi: MemecoinAbi,
|
|
17653
|
+
fn: "tokenURI",
|
|
17654
|
+
}));
|
|
17655
|
+
});
|
|
17656
|
+
const coinMetadata_result = await multicall.aggregate3(coinMetadata_calldata.map((calldata, i) => ({
|
|
17657
|
+
target: coinAddresses[Math.floor(i / 3)],
|
|
17658
|
+
callData: calldata,
|
|
17659
|
+
})));
|
|
17660
|
+
// First decode all the results
|
|
17661
|
+
const results = [];
|
|
17662
|
+
for (let i = 0; i < coinAddresses.length; i++) {
|
|
17663
|
+
const name = this.drift.adapter.decodeFunctionReturn({
|
|
17664
|
+
abi: MemecoinAbi,
|
|
17665
|
+
fn: "name",
|
|
17666
|
+
data: coinMetadata_result[i * 3].returnData,
|
|
17667
|
+
});
|
|
17668
|
+
const symbol = this.drift.adapter.decodeFunctionReturn({
|
|
17669
|
+
abi: MemecoinAbi,
|
|
17670
|
+
fn: "symbol",
|
|
17671
|
+
data: coinMetadata_result[i * 3 + 1].returnData,
|
|
17672
|
+
});
|
|
17673
|
+
const tokenURI = this.drift.adapter.decodeFunctionReturn({
|
|
17674
|
+
abi: MemecoinAbi,
|
|
17675
|
+
fn: "tokenURI",
|
|
17676
|
+
data: coinMetadata_result[i * 3 + 2].returnData,
|
|
17677
|
+
});
|
|
17678
|
+
results.push({ name, symbol, tokenURI, coinAddress: coinAddresses[i] });
|
|
17679
|
+
}
|
|
17680
|
+
// Process IPFS requests in batches to avoid rate limiting
|
|
17681
|
+
const batchSize = 3;
|
|
17682
|
+
const processedResults = [];
|
|
17683
|
+
for (let i = 0; i < results.length; i += batchSize) {
|
|
17684
|
+
const batch = results.slice(i, i + batchSize);
|
|
17685
|
+
const batchResults = await Promise.all(batch.map(async ({ name, symbol, tokenURI, coinAddress }) => {
|
|
17686
|
+
const metadata = (await axios__default["default"].get(resolveIPFS(tokenURI))).data;
|
|
17687
|
+
return {
|
|
17688
|
+
coinAddress,
|
|
17689
|
+
name,
|
|
17690
|
+
symbol,
|
|
17691
|
+
description: metadata.description ?? "",
|
|
17692
|
+
image: metadata.image ? resolveIPFS(metadata.image) : "",
|
|
17693
|
+
external_link: metadata.websiteUrl ?? "",
|
|
17694
|
+
collaborators: metadata.collaborators ?? [],
|
|
17695
|
+
discordUrl: metadata.discordUrl ?? "",
|
|
17696
|
+
twitterUrl: metadata.twitterUrl ?? "",
|
|
17697
|
+
telegramUrl: metadata.telegramUrl ?? "",
|
|
17698
|
+
};
|
|
17699
|
+
}));
|
|
17700
|
+
processedResults.push(...batchResults);
|
|
17701
|
+
// Add a small delay between batches to avoid rate limiting
|
|
17702
|
+
if (i + batchSize < results.length) {
|
|
17703
|
+
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
17704
|
+
}
|
|
17705
|
+
}
|
|
17706
|
+
return processedResults;
|
|
17707
|
+
}
|
|
17106
17708
|
/**
|
|
17107
17709
|
* Watches for pool creation events on V1 contracts
|
|
17108
17710
|
* @param params - Parameters for watching pool creation
|
|
@@ -17464,6 +18066,38 @@ class ReadFlaunchSDK {
|
|
|
17464
18066
|
const protocolRecipient = await readRevenueManager.protocolRecipient();
|
|
17465
18067
|
return readRevenueManager.balances(protocolRecipient);
|
|
17466
18068
|
}
|
|
18069
|
+
/**
|
|
18070
|
+
* Gets the total number of tokens managed by a revenue manager
|
|
18071
|
+
* @param revenueManagerAddress - The address of the revenue manager
|
|
18072
|
+
* @returns Promise<bigint> - The total count of tokens
|
|
18073
|
+
*/
|
|
18074
|
+
async revenueManagerTokensCount(revenueManagerAddress) {
|
|
18075
|
+
const readRevenueManager = new ReadRevenueManager(revenueManagerAddress, this.drift);
|
|
18076
|
+
return readRevenueManager.tokensCount();
|
|
18077
|
+
}
|
|
18078
|
+
/**
|
|
18079
|
+
* Gets all tokens created by a specific creator address
|
|
18080
|
+
* @param params - Parameters for querying tokens by creator
|
|
18081
|
+
* @param params.revenueManagerAddress - The address of the revenue manager
|
|
18082
|
+
* @param params.creator - The address of the creator to query tokens for
|
|
18083
|
+
* @param params.sortByDesc - Whether to sort the tokens by descending order
|
|
18084
|
+
* @returns Promise<Array<{flaunch: Address, tokenId: bigint}>> - Array of token objects containing flaunch address and token ID
|
|
18085
|
+
*/
|
|
18086
|
+
async revenueManagerAllTokensByCreator(params) {
|
|
18087
|
+
const readRevenueManager = new ReadRevenueManager(params.revenueManagerAddress, this.drift);
|
|
18088
|
+
return readRevenueManager.allTokensByCreator(params.creator, params.sortByDesc);
|
|
18089
|
+
}
|
|
18090
|
+
/**
|
|
18091
|
+
* Gets all tokens currently managed by a revenue manager
|
|
18092
|
+
* @param params - Parameters for querying tokens in manager
|
|
18093
|
+
* @param params.revenueManagerAddress - The address of the revenue manager
|
|
18094
|
+
* @param params.sortByDesc - Optional boolean to sort tokens in descending order (default: false)
|
|
18095
|
+
* @returns Promise<Array<{flaunch: Address, tokenId: bigint}>> - Array of token objects containing flaunch address and token ID
|
|
18096
|
+
*/
|
|
18097
|
+
async revenueManagerAllTokensInManager(params) {
|
|
18098
|
+
const readRevenueManager = new ReadRevenueManager(params.revenueManagerAddress, this.drift);
|
|
18099
|
+
return readRevenueManager.allTokensInManager(params.sortByDesc);
|
|
18100
|
+
}
|
|
17467
18101
|
/**
|
|
17468
18102
|
* Gets the pool ID for a given coin
|
|
17469
18103
|
* @param coinAddress - The address of the coin
|