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