@zubari/sdk 0.1.29 → 0.1.31
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/{WalletManager-2jAcWdXE.d.mts → WalletManager-Du9oKIeu.d.mts} +1 -1
- package/dist/{WalletManager-CO-urS0z.d.ts → WalletManager-Ry-PqMUp.d.ts} +1 -1
- package/dist/{index-IPLQBUaD.d.mts → index-6y3uV1Sh.d.mts} +11 -1
- package/dist/{index-IPLQBUaD.d.ts → index-6y3uV1Sh.d.ts} +11 -1
- package/dist/{index-47yJyxgt.d.ts → index-BK6MH30q.d.ts} +2 -2
- package/dist/{index-CUX8jPBi.d.mts → index-yA3Aorn-.d.mts} +2 -2
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1946 -112
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1946 -112
- package/dist/index.mjs.map +1 -1
- package/dist/protocols/index.d.mts +331 -31
- package/dist/protocols/index.d.ts +331 -31
- package/dist/protocols/index.js +1946 -112
- package/dist/protocols/index.js.map +1 -1
- package/dist/protocols/index.mjs +1946 -112
- package/dist/protocols/index.mjs.map +1 -1
- package/dist/react/index.d.mts +3 -3
- package/dist/react/index.d.ts +3 -3
- package/dist/services/index.d.mts +1 -1
- package/dist/services/index.d.ts +1 -1
- package/dist/wallet/index.d.mts +3 -3
- package/dist/wallet/index.d.ts +3 -3
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3292,97 +3292,1713 @@ var ZubariMarketProtocol = class {
|
|
|
3292
3292
|
}
|
|
3293
3293
|
};
|
|
3294
3294
|
|
|
3295
|
+
// src/abi/ZubariTips.json
|
|
3296
|
+
var ZubariTips_default = [
|
|
3297
|
+
{
|
|
3298
|
+
inputs: [
|
|
3299
|
+
{
|
|
3300
|
+
internalType: "address",
|
|
3301
|
+
name: "_treasury",
|
|
3302
|
+
type: "address"
|
|
3303
|
+
},
|
|
3304
|
+
{
|
|
3305
|
+
internalType: "uint256",
|
|
3306
|
+
name: "_platformFeeBps",
|
|
3307
|
+
type: "uint256"
|
|
3308
|
+
}
|
|
3309
|
+
],
|
|
3310
|
+
stateMutability: "nonpayable",
|
|
3311
|
+
type: "constructor"
|
|
3312
|
+
},
|
|
3313
|
+
{
|
|
3314
|
+
inputs: [],
|
|
3315
|
+
name: "EnforcedPause",
|
|
3316
|
+
type: "error"
|
|
3317
|
+
},
|
|
3318
|
+
{
|
|
3319
|
+
inputs: [],
|
|
3320
|
+
name: "ExpectedPause",
|
|
3321
|
+
type: "error"
|
|
3322
|
+
},
|
|
3323
|
+
{
|
|
3324
|
+
inputs: [],
|
|
3325
|
+
name: "InvalidAddress",
|
|
3326
|
+
type: "error"
|
|
3327
|
+
},
|
|
3328
|
+
{
|
|
3329
|
+
inputs: [],
|
|
3330
|
+
name: "InvalidAmount",
|
|
3331
|
+
type: "error"
|
|
3332
|
+
},
|
|
3333
|
+
{
|
|
3334
|
+
inputs: [],
|
|
3335
|
+
name: "InvalidFee",
|
|
3336
|
+
type: "error"
|
|
3337
|
+
},
|
|
3338
|
+
{
|
|
3339
|
+
inputs: [],
|
|
3340
|
+
name: "InvalidRecipient",
|
|
3341
|
+
type: "error"
|
|
3342
|
+
},
|
|
3343
|
+
{
|
|
3344
|
+
inputs: [
|
|
3345
|
+
{
|
|
3346
|
+
internalType: "address",
|
|
3347
|
+
name: "owner",
|
|
3348
|
+
type: "address"
|
|
3349
|
+
}
|
|
3350
|
+
],
|
|
3351
|
+
name: "OwnableInvalidOwner",
|
|
3352
|
+
type: "error"
|
|
3353
|
+
},
|
|
3354
|
+
{
|
|
3355
|
+
inputs: [
|
|
3356
|
+
{
|
|
3357
|
+
internalType: "address",
|
|
3358
|
+
name: "account",
|
|
3359
|
+
type: "address"
|
|
3360
|
+
}
|
|
3361
|
+
],
|
|
3362
|
+
name: "OwnableUnauthorizedAccount",
|
|
3363
|
+
type: "error"
|
|
3364
|
+
},
|
|
3365
|
+
{
|
|
3366
|
+
inputs: [],
|
|
3367
|
+
name: "ReentrancyGuardReentrantCall",
|
|
3368
|
+
type: "error"
|
|
3369
|
+
},
|
|
3370
|
+
{
|
|
3371
|
+
inputs: [
|
|
3372
|
+
{
|
|
3373
|
+
internalType: "address",
|
|
3374
|
+
name: "token",
|
|
3375
|
+
type: "address"
|
|
3376
|
+
}
|
|
3377
|
+
],
|
|
3378
|
+
name: "SafeERC20FailedOperation",
|
|
3379
|
+
type: "error"
|
|
3380
|
+
},
|
|
3381
|
+
{
|
|
3382
|
+
inputs: [],
|
|
3383
|
+
name: "TransferFailed",
|
|
3384
|
+
type: "error"
|
|
3385
|
+
},
|
|
3386
|
+
{
|
|
3387
|
+
anonymous: false,
|
|
3388
|
+
inputs: [
|
|
3389
|
+
{
|
|
3390
|
+
indexed: false,
|
|
3391
|
+
internalType: "uint256[]",
|
|
3392
|
+
name: "tipIds",
|
|
3393
|
+
type: "uint256[]"
|
|
3394
|
+
},
|
|
3395
|
+
{
|
|
3396
|
+
indexed: true,
|
|
3397
|
+
internalType: "address",
|
|
3398
|
+
name: "sender",
|
|
3399
|
+
type: "address"
|
|
3400
|
+
}
|
|
3401
|
+
],
|
|
3402
|
+
name: "BatchTipSent",
|
|
3403
|
+
type: "event"
|
|
3404
|
+
},
|
|
3405
|
+
{
|
|
3406
|
+
anonymous: false,
|
|
3407
|
+
inputs: [
|
|
3408
|
+
{
|
|
3409
|
+
indexed: true,
|
|
3410
|
+
internalType: "address",
|
|
3411
|
+
name: "previousOwner",
|
|
3412
|
+
type: "address"
|
|
3413
|
+
},
|
|
3414
|
+
{
|
|
3415
|
+
indexed: true,
|
|
3416
|
+
internalType: "address",
|
|
3417
|
+
name: "newOwner",
|
|
3418
|
+
type: "address"
|
|
3419
|
+
}
|
|
3420
|
+
],
|
|
3421
|
+
name: "OwnershipTransferred",
|
|
3422
|
+
type: "event"
|
|
3423
|
+
},
|
|
3424
|
+
{
|
|
3425
|
+
anonymous: false,
|
|
3426
|
+
inputs: [
|
|
3427
|
+
{
|
|
3428
|
+
indexed: false,
|
|
3429
|
+
internalType: "address",
|
|
3430
|
+
name: "account",
|
|
3431
|
+
type: "address"
|
|
3432
|
+
}
|
|
3433
|
+
],
|
|
3434
|
+
name: "Paused",
|
|
3435
|
+
type: "event"
|
|
3436
|
+
},
|
|
3437
|
+
{
|
|
3438
|
+
anonymous: false,
|
|
3439
|
+
inputs: [
|
|
3440
|
+
{
|
|
3441
|
+
indexed: false,
|
|
3442
|
+
internalType: "uint256",
|
|
3443
|
+
name: "oldFee",
|
|
3444
|
+
type: "uint256"
|
|
3445
|
+
},
|
|
3446
|
+
{
|
|
3447
|
+
indexed: false,
|
|
3448
|
+
internalType: "uint256",
|
|
3449
|
+
name: "newFee",
|
|
3450
|
+
type: "uint256"
|
|
3451
|
+
}
|
|
3452
|
+
],
|
|
3453
|
+
name: "PlatformFeeUpdated",
|
|
3454
|
+
type: "event"
|
|
3455
|
+
},
|
|
3456
|
+
{
|
|
3457
|
+
anonymous: false,
|
|
3458
|
+
inputs: [
|
|
3459
|
+
{
|
|
3460
|
+
indexed: true,
|
|
3461
|
+
internalType: "uint256",
|
|
3462
|
+
name: "tipId",
|
|
3463
|
+
type: "uint256"
|
|
3464
|
+
},
|
|
3465
|
+
{
|
|
3466
|
+
indexed: true,
|
|
3467
|
+
internalType: "address",
|
|
3468
|
+
name: "sender",
|
|
3469
|
+
type: "address"
|
|
3470
|
+
},
|
|
3471
|
+
{
|
|
3472
|
+
indexed: true,
|
|
3473
|
+
internalType: "address",
|
|
3474
|
+
name: "recipient",
|
|
3475
|
+
type: "address"
|
|
3476
|
+
},
|
|
3477
|
+
{
|
|
3478
|
+
indexed: false,
|
|
3479
|
+
internalType: "address",
|
|
3480
|
+
name: "token",
|
|
3481
|
+
type: "address"
|
|
3482
|
+
},
|
|
3483
|
+
{
|
|
3484
|
+
indexed: false,
|
|
3485
|
+
internalType: "uint256",
|
|
3486
|
+
name: "amount",
|
|
3487
|
+
type: "uint256"
|
|
3488
|
+
},
|
|
3489
|
+
{
|
|
3490
|
+
indexed: false,
|
|
3491
|
+
internalType: "uint256",
|
|
3492
|
+
name: "platformFee",
|
|
3493
|
+
type: "uint256"
|
|
3494
|
+
},
|
|
3495
|
+
{
|
|
3496
|
+
indexed: false,
|
|
3497
|
+
internalType: "string",
|
|
3498
|
+
name: "message",
|
|
3499
|
+
type: "string"
|
|
3500
|
+
}
|
|
3501
|
+
],
|
|
3502
|
+
name: "TipSent",
|
|
3503
|
+
type: "event"
|
|
3504
|
+
},
|
|
3505
|
+
{
|
|
3506
|
+
anonymous: false,
|
|
3507
|
+
inputs: [
|
|
3508
|
+
{
|
|
3509
|
+
indexed: false,
|
|
3510
|
+
internalType: "address",
|
|
3511
|
+
name: "oldTreasury",
|
|
3512
|
+
type: "address"
|
|
3513
|
+
},
|
|
3514
|
+
{
|
|
3515
|
+
indexed: false,
|
|
3516
|
+
internalType: "address",
|
|
3517
|
+
name: "newTreasury",
|
|
3518
|
+
type: "address"
|
|
3519
|
+
}
|
|
3520
|
+
],
|
|
3521
|
+
name: "TreasuryUpdated",
|
|
3522
|
+
type: "event"
|
|
3523
|
+
},
|
|
3524
|
+
{
|
|
3525
|
+
anonymous: false,
|
|
3526
|
+
inputs: [
|
|
3527
|
+
{
|
|
3528
|
+
indexed: false,
|
|
3529
|
+
internalType: "address",
|
|
3530
|
+
name: "account",
|
|
3531
|
+
type: "address"
|
|
3532
|
+
}
|
|
3533
|
+
],
|
|
3534
|
+
name: "Unpaused",
|
|
3535
|
+
type: "event"
|
|
3536
|
+
},
|
|
3537
|
+
{
|
|
3538
|
+
inputs: [
|
|
3539
|
+
{
|
|
3540
|
+
internalType: "uint256",
|
|
3541
|
+
name: "tipId",
|
|
3542
|
+
type: "uint256"
|
|
3543
|
+
}
|
|
3544
|
+
],
|
|
3545
|
+
name: "getTip",
|
|
3546
|
+
outputs: [
|
|
3547
|
+
{
|
|
3548
|
+
components: [
|
|
3549
|
+
{
|
|
3550
|
+
internalType: "uint256",
|
|
3551
|
+
name: "tipId",
|
|
3552
|
+
type: "uint256"
|
|
3553
|
+
},
|
|
3554
|
+
{
|
|
3555
|
+
internalType: "address",
|
|
3556
|
+
name: "sender",
|
|
3557
|
+
type: "address"
|
|
3558
|
+
},
|
|
3559
|
+
{
|
|
3560
|
+
internalType: "address",
|
|
3561
|
+
name: "recipient",
|
|
3562
|
+
type: "address"
|
|
3563
|
+
},
|
|
3564
|
+
{
|
|
3565
|
+
internalType: "address",
|
|
3566
|
+
name: "token",
|
|
3567
|
+
type: "address"
|
|
3568
|
+
},
|
|
3569
|
+
{
|
|
3570
|
+
internalType: "uint256",
|
|
3571
|
+
name: "amount",
|
|
3572
|
+
type: "uint256"
|
|
3573
|
+
},
|
|
3574
|
+
{
|
|
3575
|
+
internalType: "uint256",
|
|
3576
|
+
name: "platformFee",
|
|
3577
|
+
type: "uint256"
|
|
3578
|
+
},
|
|
3579
|
+
{
|
|
3580
|
+
internalType: "string",
|
|
3581
|
+
name: "message",
|
|
3582
|
+
type: "string"
|
|
3583
|
+
},
|
|
3584
|
+
{
|
|
3585
|
+
internalType: "uint256",
|
|
3586
|
+
name: "timestamp",
|
|
3587
|
+
type: "uint256"
|
|
3588
|
+
}
|
|
3589
|
+
],
|
|
3590
|
+
internalType: "struct ZubariTips.Tip",
|
|
3591
|
+
name: "",
|
|
3592
|
+
type: "tuple"
|
|
3593
|
+
}
|
|
3594
|
+
],
|
|
3595
|
+
stateMutability: "view",
|
|
3596
|
+
type: "function"
|
|
3597
|
+
},
|
|
3598
|
+
{
|
|
3599
|
+
inputs: [],
|
|
3600
|
+
name: "owner",
|
|
3601
|
+
outputs: [
|
|
3602
|
+
{
|
|
3603
|
+
internalType: "address",
|
|
3604
|
+
name: "",
|
|
3605
|
+
type: "address"
|
|
3606
|
+
}
|
|
3607
|
+
],
|
|
3608
|
+
stateMutability: "view",
|
|
3609
|
+
type: "function"
|
|
3610
|
+
},
|
|
3611
|
+
{
|
|
3612
|
+
inputs: [],
|
|
3613
|
+
name: "pause",
|
|
3614
|
+
outputs: [],
|
|
3615
|
+
stateMutability: "nonpayable",
|
|
3616
|
+
type: "function"
|
|
3617
|
+
},
|
|
3618
|
+
{
|
|
3619
|
+
inputs: [],
|
|
3620
|
+
name: "paused",
|
|
3621
|
+
outputs: [
|
|
3622
|
+
{
|
|
3623
|
+
internalType: "bool",
|
|
3624
|
+
name: "",
|
|
3625
|
+
type: "bool"
|
|
3626
|
+
}
|
|
3627
|
+
],
|
|
3628
|
+
stateMutability: "view",
|
|
3629
|
+
type: "function"
|
|
3630
|
+
},
|
|
3631
|
+
{
|
|
3632
|
+
inputs: [],
|
|
3633
|
+
name: "platformFeeBps",
|
|
3634
|
+
outputs: [
|
|
3635
|
+
{
|
|
3636
|
+
internalType: "uint256",
|
|
3637
|
+
name: "",
|
|
3638
|
+
type: "uint256"
|
|
3639
|
+
}
|
|
3640
|
+
],
|
|
3641
|
+
stateMutability: "view",
|
|
3642
|
+
type: "function"
|
|
3643
|
+
},
|
|
3644
|
+
{
|
|
3645
|
+
inputs: [],
|
|
3646
|
+
name: "renounceOwnership",
|
|
3647
|
+
outputs: [],
|
|
3648
|
+
stateMutability: "nonpayable",
|
|
3649
|
+
type: "function"
|
|
3650
|
+
},
|
|
3651
|
+
{
|
|
3652
|
+
inputs: [
|
|
3653
|
+
{
|
|
3654
|
+
internalType: "address[]",
|
|
3655
|
+
name: "recipients",
|
|
3656
|
+
type: "address[]"
|
|
3657
|
+
},
|
|
3658
|
+
{
|
|
3659
|
+
internalType: "uint256[]",
|
|
3660
|
+
name: "amounts",
|
|
3661
|
+
type: "uint256[]"
|
|
3662
|
+
},
|
|
3663
|
+
{
|
|
3664
|
+
internalType: "string[]",
|
|
3665
|
+
name: "messages",
|
|
3666
|
+
type: "string[]"
|
|
3667
|
+
}
|
|
3668
|
+
],
|
|
3669
|
+
name: "sendBatchTips",
|
|
3670
|
+
outputs: [],
|
|
3671
|
+
stateMutability: "payable",
|
|
3672
|
+
type: "function"
|
|
3673
|
+
},
|
|
3674
|
+
{
|
|
3675
|
+
inputs: [
|
|
3676
|
+
{
|
|
3677
|
+
internalType: "uint256",
|
|
3678
|
+
name: "_feeBps",
|
|
3679
|
+
type: "uint256"
|
|
3680
|
+
}
|
|
3681
|
+
],
|
|
3682
|
+
name: "setPlatformFee",
|
|
3683
|
+
outputs: [],
|
|
3684
|
+
stateMutability: "nonpayable",
|
|
3685
|
+
type: "function"
|
|
3686
|
+
},
|
|
3687
|
+
{
|
|
3688
|
+
inputs: [
|
|
3689
|
+
{
|
|
3690
|
+
internalType: "address",
|
|
3691
|
+
name: "_treasury",
|
|
3692
|
+
type: "address"
|
|
3693
|
+
}
|
|
3694
|
+
],
|
|
3695
|
+
name: "setTreasury",
|
|
3696
|
+
outputs: [],
|
|
3697
|
+
stateMutability: "nonpayable",
|
|
3698
|
+
type: "function"
|
|
3699
|
+
},
|
|
3700
|
+
{
|
|
3701
|
+
inputs: [],
|
|
3702
|
+
name: "tipCounter",
|
|
3703
|
+
outputs: [
|
|
3704
|
+
{
|
|
3705
|
+
internalType: "uint256",
|
|
3706
|
+
name: "",
|
|
3707
|
+
type: "uint256"
|
|
3708
|
+
}
|
|
3709
|
+
],
|
|
3710
|
+
stateMutability: "view",
|
|
3711
|
+
type: "function"
|
|
3712
|
+
},
|
|
3713
|
+
{
|
|
3714
|
+
inputs: [
|
|
3715
|
+
{
|
|
3716
|
+
internalType: "address",
|
|
3717
|
+
name: "recipient",
|
|
3718
|
+
type: "address"
|
|
3719
|
+
},
|
|
3720
|
+
{
|
|
3721
|
+
internalType: "string",
|
|
3722
|
+
name: "message",
|
|
3723
|
+
type: "string"
|
|
3724
|
+
}
|
|
3725
|
+
],
|
|
3726
|
+
name: "tipETH",
|
|
3727
|
+
outputs: [],
|
|
3728
|
+
stateMutability: "payable",
|
|
3729
|
+
type: "function"
|
|
3730
|
+
},
|
|
3731
|
+
{
|
|
3732
|
+
inputs: [
|
|
3733
|
+
{
|
|
3734
|
+
internalType: "address",
|
|
3735
|
+
name: "recipient",
|
|
3736
|
+
type: "address"
|
|
3737
|
+
},
|
|
3738
|
+
{
|
|
3739
|
+
internalType: "address",
|
|
3740
|
+
name: "token",
|
|
3741
|
+
type: "address"
|
|
3742
|
+
},
|
|
3743
|
+
{
|
|
3744
|
+
internalType: "uint256",
|
|
3745
|
+
name: "amount",
|
|
3746
|
+
type: "uint256"
|
|
3747
|
+
},
|
|
3748
|
+
{
|
|
3749
|
+
internalType: "string",
|
|
3750
|
+
name: "message",
|
|
3751
|
+
type: "string"
|
|
3752
|
+
}
|
|
3753
|
+
],
|
|
3754
|
+
name: "tipToken",
|
|
3755
|
+
outputs: [],
|
|
3756
|
+
stateMutability: "nonpayable",
|
|
3757
|
+
type: "function"
|
|
3758
|
+
},
|
|
3759
|
+
{
|
|
3760
|
+
inputs: [
|
|
3761
|
+
{
|
|
3762
|
+
internalType: "uint256",
|
|
3763
|
+
name: "",
|
|
3764
|
+
type: "uint256"
|
|
3765
|
+
}
|
|
3766
|
+
],
|
|
3767
|
+
name: "tips",
|
|
3768
|
+
outputs: [
|
|
3769
|
+
{
|
|
3770
|
+
internalType: "uint256",
|
|
3771
|
+
name: "tipId",
|
|
3772
|
+
type: "uint256"
|
|
3773
|
+
},
|
|
3774
|
+
{
|
|
3775
|
+
internalType: "address",
|
|
3776
|
+
name: "sender",
|
|
3777
|
+
type: "address"
|
|
3778
|
+
},
|
|
3779
|
+
{
|
|
3780
|
+
internalType: "address",
|
|
3781
|
+
name: "recipient",
|
|
3782
|
+
type: "address"
|
|
3783
|
+
},
|
|
3784
|
+
{
|
|
3785
|
+
internalType: "address",
|
|
3786
|
+
name: "token",
|
|
3787
|
+
type: "address"
|
|
3788
|
+
},
|
|
3789
|
+
{
|
|
3790
|
+
internalType: "uint256",
|
|
3791
|
+
name: "amount",
|
|
3792
|
+
type: "uint256"
|
|
3793
|
+
},
|
|
3794
|
+
{
|
|
3795
|
+
internalType: "uint256",
|
|
3796
|
+
name: "platformFee",
|
|
3797
|
+
type: "uint256"
|
|
3798
|
+
},
|
|
3799
|
+
{
|
|
3800
|
+
internalType: "string",
|
|
3801
|
+
name: "message",
|
|
3802
|
+
type: "string"
|
|
3803
|
+
},
|
|
3804
|
+
{
|
|
3805
|
+
internalType: "uint256",
|
|
3806
|
+
name: "timestamp",
|
|
3807
|
+
type: "uint256"
|
|
3808
|
+
}
|
|
3809
|
+
],
|
|
3810
|
+
stateMutability: "view",
|
|
3811
|
+
type: "function"
|
|
3812
|
+
},
|
|
3813
|
+
{
|
|
3814
|
+
inputs: [
|
|
3815
|
+
{
|
|
3816
|
+
internalType: "address",
|
|
3817
|
+
name: "",
|
|
3818
|
+
type: "address"
|
|
3819
|
+
}
|
|
3820
|
+
],
|
|
3821
|
+
name: "totalTipsReceived",
|
|
3822
|
+
outputs: [
|
|
3823
|
+
{
|
|
3824
|
+
internalType: "uint256",
|
|
3825
|
+
name: "",
|
|
3826
|
+
type: "uint256"
|
|
3827
|
+
}
|
|
3828
|
+
],
|
|
3829
|
+
stateMutability: "view",
|
|
3830
|
+
type: "function"
|
|
3831
|
+
},
|
|
3832
|
+
{
|
|
3833
|
+
inputs: [
|
|
3834
|
+
{
|
|
3835
|
+
internalType: "address",
|
|
3836
|
+
name: "newOwner",
|
|
3837
|
+
type: "address"
|
|
3838
|
+
}
|
|
3839
|
+
],
|
|
3840
|
+
name: "transferOwnership",
|
|
3841
|
+
outputs: [],
|
|
3842
|
+
stateMutability: "nonpayable",
|
|
3843
|
+
type: "function"
|
|
3844
|
+
},
|
|
3845
|
+
{
|
|
3846
|
+
inputs: [],
|
|
3847
|
+
name: "treasury",
|
|
3848
|
+
outputs: [
|
|
3849
|
+
{
|
|
3850
|
+
internalType: "address",
|
|
3851
|
+
name: "",
|
|
3852
|
+
type: "address"
|
|
3853
|
+
}
|
|
3854
|
+
],
|
|
3855
|
+
stateMutability: "view",
|
|
3856
|
+
type: "function"
|
|
3857
|
+
},
|
|
3858
|
+
{
|
|
3859
|
+
inputs: [],
|
|
3860
|
+
name: "unpause",
|
|
3861
|
+
outputs: [],
|
|
3862
|
+
stateMutability: "nonpayable",
|
|
3863
|
+
type: "function"
|
|
3864
|
+
}
|
|
3865
|
+
];
|
|
3866
|
+
|
|
3295
3867
|
// src/protocols/TipsProtocol.ts
|
|
3296
3868
|
var ZubariTipsProtocol = class {
|
|
3297
3869
|
contractAddress;
|
|
3298
3870
|
chainId;
|
|
3299
|
-
|
|
3300
|
-
constructor(contractAddress, chainId
|
|
3871
|
+
abi = ZubariTips_default;
|
|
3872
|
+
constructor(contractAddress, chainId) {
|
|
3873
|
+
this.contractAddress = contractAddress;
|
|
3874
|
+
this.chainId = chainId;
|
|
3875
|
+
}
|
|
3876
|
+
/**
|
|
3877
|
+
* Get the contract ABI
|
|
3878
|
+
*/
|
|
3879
|
+
getAbi() {
|
|
3880
|
+
return this.abi;
|
|
3881
|
+
}
|
|
3882
|
+
/**
|
|
3883
|
+
* Get the contract address
|
|
3884
|
+
*/
|
|
3885
|
+
getAddress() {
|
|
3886
|
+
return this.contractAddress;
|
|
3887
|
+
}
|
|
3888
|
+
/**
|
|
3889
|
+
* Send ETH tip to a creator
|
|
3890
|
+
* @param recipient The recipient address
|
|
3891
|
+
* @param message Optional tip message
|
|
3892
|
+
* @param signer Wallet signer with sendTransaction method
|
|
3893
|
+
* @param value ETH amount to tip (in wei)
|
|
3894
|
+
*/
|
|
3895
|
+
async tipETH(recipient, message, signer, value) {
|
|
3896
|
+
if (!recipient || recipient === "0x0000000000000000000000000000000000000000") {
|
|
3897
|
+
throw new Error("Invalid recipient address");
|
|
3898
|
+
}
|
|
3899
|
+
if (value <= 0n) {
|
|
3900
|
+
throw new Error("Tip amount must be greater than 0");
|
|
3901
|
+
}
|
|
3902
|
+
const iface = new (await import('ethers')).Interface(this.abi);
|
|
3903
|
+
const data = iface.encodeFunctionData("tipETH", [recipient, message || ""]);
|
|
3904
|
+
const result = await signer.sendTransaction({
|
|
3905
|
+
to: this.contractAddress,
|
|
3906
|
+
value,
|
|
3907
|
+
data
|
|
3908
|
+
});
|
|
3909
|
+
return {
|
|
3910
|
+
hash: result.hash,
|
|
3911
|
+
network: "ethereum",
|
|
3912
|
+
status: "pending"
|
|
3913
|
+
};
|
|
3914
|
+
}
|
|
3915
|
+
/**
|
|
3916
|
+
* Send ERC-20 token tip to a creator
|
|
3917
|
+
* @param recipient The recipient address
|
|
3918
|
+
* @param token The ERC-20 token address
|
|
3919
|
+
* @param amount The amount of tokens to tip
|
|
3920
|
+
* @param message Optional tip message
|
|
3921
|
+
* @param signer Wallet signer
|
|
3922
|
+
*/
|
|
3923
|
+
async tipToken(recipient, token, amount, message, signer) {
|
|
3924
|
+
if (!recipient || recipient === "0x0000000000000000000000000000000000000000") {
|
|
3925
|
+
throw new Error("Invalid recipient address");
|
|
3926
|
+
}
|
|
3927
|
+
if (!token || token === "0x0000000000000000000000000000000000000000") {
|
|
3928
|
+
throw new Error("Use tipETH for native ETH tips");
|
|
3929
|
+
}
|
|
3930
|
+
if (amount <= 0n) {
|
|
3931
|
+
throw new Error("Tip amount must be greater than 0");
|
|
3932
|
+
}
|
|
3933
|
+
const iface = new (await import('ethers')).Interface(this.abi);
|
|
3934
|
+
const data = iface.encodeFunctionData("tipToken", [recipient, token, amount, message || ""]);
|
|
3935
|
+
const result = await signer.sendTransaction({
|
|
3936
|
+
to: this.contractAddress,
|
|
3937
|
+
value: 0n,
|
|
3938
|
+
data
|
|
3939
|
+
});
|
|
3940
|
+
return {
|
|
3941
|
+
hash: result.hash,
|
|
3942
|
+
network: "ethereum",
|
|
3943
|
+
status: "pending"
|
|
3944
|
+
};
|
|
3945
|
+
}
|
|
3946
|
+
/**
|
|
3947
|
+
* Send batch tips to multiple creators in a single transaction
|
|
3948
|
+
* @param recipients Array of recipient addresses
|
|
3949
|
+
* @param amounts Array of tip amounts (in wei)
|
|
3950
|
+
* @param messages Array of tip messages
|
|
3951
|
+
* @param signer Wallet signer
|
|
3952
|
+
* @param value Total ETH to send
|
|
3953
|
+
*/
|
|
3954
|
+
async sendBatchTips(recipients, amounts, messages, signer, value) {
|
|
3955
|
+
if (recipients.length === 0) {
|
|
3956
|
+
throw new Error("At least one recipient is required");
|
|
3957
|
+
}
|
|
3958
|
+
if (recipients.length !== amounts.length || recipients.length !== messages.length) {
|
|
3959
|
+
throw new Error("Recipients, amounts, and messages arrays must have the same length");
|
|
3960
|
+
}
|
|
3961
|
+
for (const recipient of recipients) {
|
|
3962
|
+
if (!recipient || recipient === "0x0000000000000000000000000000000000000000") {
|
|
3963
|
+
throw new Error("Invalid recipient address in batch");
|
|
3964
|
+
}
|
|
3965
|
+
}
|
|
3966
|
+
const totalAmount = amounts.reduce((sum, amount) => sum + amount, 0n);
|
|
3967
|
+
if (totalAmount <= 0n) {
|
|
3968
|
+
throw new Error("Total tip amount must be greater than 0");
|
|
3969
|
+
}
|
|
3970
|
+
const iface = new (await import('ethers')).Interface(this.abi);
|
|
3971
|
+
const data = iface.encodeFunctionData("sendBatchTips", [recipients, amounts, messages]);
|
|
3972
|
+
const result = await signer.sendTransaction({
|
|
3973
|
+
to: this.contractAddress,
|
|
3974
|
+
value,
|
|
3975
|
+
data
|
|
3976
|
+
});
|
|
3977
|
+
return {
|
|
3978
|
+
hash: result.hash,
|
|
3979
|
+
network: "ethereum",
|
|
3980
|
+
status: "pending"
|
|
3981
|
+
};
|
|
3982
|
+
}
|
|
3983
|
+
/**
|
|
3984
|
+
* Get tip details by ID
|
|
3985
|
+
* @param tipId The tip ID
|
|
3986
|
+
* @param provider JSON-RPC provider
|
|
3987
|
+
*/
|
|
3988
|
+
async getTip(tipId, provider) {
|
|
3989
|
+
const iface = new (await import('ethers')).Interface(this.abi);
|
|
3990
|
+
const data = iface.encodeFunctionData("getTip", [tipId]);
|
|
3991
|
+
try {
|
|
3992
|
+
const result = await provider.call({
|
|
3993
|
+
to: this.contractAddress,
|
|
3994
|
+
data
|
|
3995
|
+
});
|
|
3996
|
+
const decoded = iface.decodeFunctionResult("getTip", result);
|
|
3997
|
+
const tip = decoded[0];
|
|
3998
|
+
if (BigInt(tip.tipId) === 0n) {
|
|
3999
|
+
return null;
|
|
4000
|
+
}
|
|
4001
|
+
return {
|
|
4002
|
+
tipId: tip.tipId.toString(),
|
|
4003
|
+
sender: tip.sender,
|
|
4004
|
+
recipient: tip.recipient,
|
|
4005
|
+
token: tip.token,
|
|
4006
|
+
amount: BigInt(tip.amount),
|
|
4007
|
+
platformFee: BigInt(tip.platformFee),
|
|
4008
|
+
message: tip.message,
|
|
4009
|
+
timestamp: Number(tip.timestamp)
|
|
4010
|
+
};
|
|
4011
|
+
} catch {
|
|
4012
|
+
return null;
|
|
4013
|
+
}
|
|
4014
|
+
}
|
|
4015
|
+
/**
|
|
4016
|
+
* Get total tips received by an address
|
|
4017
|
+
* @param address The address to query
|
|
4018
|
+
* @param provider JSON-RPC provider
|
|
4019
|
+
*/
|
|
4020
|
+
async getTotalTipsReceived(address, provider) {
|
|
4021
|
+
const iface = new (await import('ethers')).Interface(this.abi);
|
|
4022
|
+
const data = iface.encodeFunctionData("totalTipsReceived", [address]);
|
|
4023
|
+
try {
|
|
4024
|
+
const result = await provider.call({
|
|
4025
|
+
to: this.contractAddress,
|
|
4026
|
+
data
|
|
4027
|
+
});
|
|
4028
|
+
const decoded = iface.decodeFunctionResult("totalTipsReceived", result);
|
|
4029
|
+
return BigInt(decoded[0]);
|
|
4030
|
+
} catch {
|
|
4031
|
+
return 0n;
|
|
4032
|
+
}
|
|
4033
|
+
}
|
|
4034
|
+
/**
|
|
4035
|
+
* Get platform fee in basis points
|
|
4036
|
+
* @param provider JSON-RPC provider
|
|
4037
|
+
*/
|
|
4038
|
+
async getPlatformFeeBps(provider) {
|
|
4039
|
+
const iface = new (await import('ethers')).Interface(this.abi);
|
|
4040
|
+
const data = iface.encodeFunctionData("platformFeeBps", []);
|
|
4041
|
+
try {
|
|
4042
|
+
const result = await provider.call({
|
|
4043
|
+
to: this.contractAddress,
|
|
4044
|
+
data
|
|
4045
|
+
});
|
|
4046
|
+
const decoded = iface.decodeFunctionResult("platformFeeBps", result);
|
|
4047
|
+
return Number(decoded[0]);
|
|
4048
|
+
} catch {
|
|
4049
|
+
return 300;
|
|
4050
|
+
}
|
|
4051
|
+
}
|
|
4052
|
+
/**
|
|
4053
|
+
* Get current tip counter
|
|
4054
|
+
* @param provider JSON-RPC provider
|
|
4055
|
+
*/
|
|
4056
|
+
async getTipCounter(provider) {
|
|
4057
|
+
const iface = new (await import('ethers')).Interface(this.abi);
|
|
4058
|
+
const data = iface.encodeFunctionData("tipCounter", []);
|
|
4059
|
+
try {
|
|
4060
|
+
const result = await provider.call({
|
|
4061
|
+
to: this.contractAddress,
|
|
4062
|
+
data
|
|
4063
|
+
});
|
|
4064
|
+
const decoded = iface.decodeFunctionResult("tipCounter", result);
|
|
4065
|
+
return BigInt(decoded[0]);
|
|
4066
|
+
} catch {
|
|
4067
|
+
return 0n;
|
|
4068
|
+
}
|
|
4069
|
+
}
|
|
4070
|
+
/**
|
|
4071
|
+
* Get treasury address
|
|
4072
|
+
* @param provider JSON-RPC provider
|
|
4073
|
+
*/
|
|
4074
|
+
async getTreasury(provider) {
|
|
4075
|
+
const iface = new (await import('ethers')).Interface(this.abi);
|
|
4076
|
+
const data = iface.encodeFunctionData("treasury", []);
|
|
4077
|
+
try {
|
|
4078
|
+
const result = await provider.call({
|
|
4079
|
+
to: this.contractAddress,
|
|
4080
|
+
data
|
|
4081
|
+
});
|
|
4082
|
+
const decoded = iface.decodeFunctionResult("treasury", result);
|
|
4083
|
+
return decoded[0];
|
|
4084
|
+
} catch {
|
|
4085
|
+
return "0x0000000000000000000000000000000000000000";
|
|
4086
|
+
}
|
|
4087
|
+
}
|
|
4088
|
+
/**
|
|
4089
|
+
* Calculate platform fee for a given amount
|
|
4090
|
+
* @param amount The tip amount
|
|
4091
|
+
* @param feeBps Fee in basis points (default: 300 = 3%)
|
|
4092
|
+
*/
|
|
4093
|
+
calculateFee(amount, feeBps = 300) {
|
|
4094
|
+
const fee = amount * BigInt(feeBps) / 10000n;
|
|
4095
|
+
return {
|
|
4096
|
+
fee,
|
|
4097
|
+
creatorAmount: amount - fee
|
|
4098
|
+
};
|
|
4099
|
+
}
|
|
4100
|
+
};
|
|
4101
|
+
|
|
4102
|
+
// src/abi/ZubariSubscription.json
|
|
4103
|
+
var ZubariSubscription_default = [
|
|
4104
|
+
{
|
|
4105
|
+
inputs: [
|
|
4106
|
+
{
|
|
4107
|
+
internalType: "address",
|
|
4108
|
+
name: "_treasury",
|
|
4109
|
+
type: "address"
|
|
4110
|
+
},
|
|
4111
|
+
{
|
|
4112
|
+
internalType: "uint256",
|
|
4113
|
+
name: "_platformFeeBps",
|
|
4114
|
+
type: "uint256"
|
|
4115
|
+
}
|
|
4116
|
+
],
|
|
4117
|
+
stateMutability: "nonpayable",
|
|
4118
|
+
type: "constructor"
|
|
4119
|
+
},
|
|
4120
|
+
{
|
|
4121
|
+
inputs: [],
|
|
4122
|
+
name: "AlreadySubscribed",
|
|
4123
|
+
type: "error"
|
|
4124
|
+
},
|
|
4125
|
+
{
|
|
4126
|
+
inputs: [],
|
|
4127
|
+
name: "EnforcedPause",
|
|
4128
|
+
type: "error"
|
|
4129
|
+
},
|
|
4130
|
+
{
|
|
4131
|
+
inputs: [],
|
|
4132
|
+
name: "ExpectedPause",
|
|
4133
|
+
type: "error"
|
|
4134
|
+
},
|
|
4135
|
+
{
|
|
4136
|
+
inputs: [],
|
|
4137
|
+
name: "InvalidAddress",
|
|
4138
|
+
type: "error"
|
|
4139
|
+
},
|
|
4140
|
+
{
|
|
4141
|
+
inputs: [],
|
|
4142
|
+
name: "InvalidAmount",
|
|
4143
|
+
type: "error"
|
|
4144
|
+
},
|
|
4145
|
+
{
|
|
4146
|
+
inputs: [],
|
|
4147
|
+
name: "InvalidDuration",
|
|
4148
|
+
type: "error"
|
|
4149
|
+
},
|
|
4150
|
+
{
|
|
4151
|
+
inputs: [],
|
|
4152
|
+
name: "InvalidFee",
|
|
4153
|
+
type: "error"
|
|
4154
|
+
},
|
|
4155
|
+
{
|
|
4156
|
+
inputs: [],
|
|
4157
|
+
name: "NotSubscriber",
|
|
4158
|
+
type: "error"
|
|
4159
|
+
},
|
|
4160
|
+
{
|
|
4161
|
+
inputs: [
|
|
4162
|
+
{
|
|
4163
|
+
internalType: "address",
|
|
4164
|
+
name: "owner",
|
|
4165
|
+
type: "address"
|
|
4166
|
+
}
|
|
4167
|
+
],
|
|
4168
|
+
name: "OwnableInvalidOwner",
|
|
4169
|
+
type: "error"
|
|
4170
|
+
},
|
|
4171
|
+
{
|
|
4172
|
+
inputs: [
|
|
4173
|
+
{
|
|
4174
|
+
internalType: "address",
|
|
4175
|
+
name: "account",
|
|
4176
|
+
type: "address"
|
|
4177
|
+
}
|
|
4178
|
+
],
|
|
4179
|
+
name: "OwnableUnauthorizedAccount",
|
|
4180
|
+
type: "error"
|
|
4181
|
+
},
|
|
4182
|
+
{
|
|
4183
|
+
inputs: [],
|
|
4184
|
+
name: "PlanFull",
|
|
4185
|
+
type: "error"
|
|
4186
|
+
},
|
|
4187
|
+
{
|
|
4188
|
+
inputs: [],
|
|
4189
|
+
name: "PlanNotActive",
|
|
4190
|
+
type: "error"
|
|
4191
|
+
},
|
|
4192
|
+
{
|
|
4193
|
+
inputs: [],
|
|
4194
|
+
name: "PlanNotFound",
|
|
4195
|
+
type: "error"
|
|
4196
|
+
},
|
|
4197
|
+
{
|
|
4198
|
+
inputs: [],
|
|
4199
|
+
name: "ReentrancyGuardReentrantCall",
|
|
4200
|
+
type: "error"
|
|
4201
|
+
},
|
|
4202
|
+
{
|
|
4203
|
+
inputs: [
|
|
4204
|
+
{
|
|
4205
|
+
internalType: "address",
|
|
4206
|
+
name: "token",
|
|
4207
|
+
type: "address"
|
|
4208
|
+
}
|
|
4209
|
+
],
|
|
4210
|
+
name: "SafeERC20FailedOperation",
|
|
4211
|
+
type: "error"
|
|
4212
|
+
},
|
|
4213
|
+
{
|
|
4214
|
+
anonymous: false,
|
|
4215
|
+
inputs: [
|
|
4216
|
+
{
|
|
4217
|
+
indexed: true,
|
|
4218
|
+
internalType: "address",
|
|
4219
|
+
name: "previousOwner",
|
|
4220
|
+
type: "address"
|
|
4221
|
+
},
|
|
4222
|
+
{
|
|
4223
|
+
indexed: true,
|
|
4224
|
+
internalType: "address",
|
|
4225
|
+
name: "newOwner",
|
|
4226
|
+
type: "address"
|
|
4227
|
+
}
|
|
4228
|
+
],
|
|
4229
|
+
name: "OwnershipTransferred",
|
|
4230
|
+
type: "event"
|
|
4231
|
+
},
|
|
4232
|
+
{
|
|
4233
|
+
anonymous: false,
|
|
4234
|
+
inputs: [
|
|
4235
|
+
{
|
|
4236
|
+
indexed: false,
|
|
4237
|
+
internalType: "address",
|
|
4238
|
+
name: "account",
|
|
4239
|
+
type: "address"
|
|
4240
|
+
}
|
|
4241
|
+
],
|
|
4242
|
+
name: "Paused",
|
|
4243
|
+
type: "event"
|
|
4244
|
+
},
|
|
4245
|
+
{
|
|
4246
|
+
anonymous: false,
|
|
4247
|
+
inputs: [
|
|
4248
|
+
{
|
|
4249
|
+
indexed: true,
|
|
4250
|
+
internalType: "bytes32",
|
|
4251
|
+
name: "planId",
|
|
4252
|
+
type: "bytes32"
|
|
4253
|
+
},
|
|
4254
|
+
{
|
|
4255
|
+
indexed: true,
|
|
4256
|
+
internalType: "address",
|
|
4257
|
+
name: "creator",
|
|
4258
|
+
type: "address"
|
|
4259
|
+
},
|
|
4260
|
+
{
|
|
4261
|
+
indexed: false,
|
|
4262
|
+
internalType: "string",
|
|
4263
|
+
name: "name",
|
|
4264
|
+
type: "string"
|
|
4265
|
+
},
|
|
4266
|
+
{
|
|
4267
|
+
indexed: false,
|
|
4268
|
+
internalType: "uint256",
|
|
4269
|
+
name: "price",
|
|
4270
|
+
type: "uint256"
|
|
4271
|
+
}
|
|
4272
|
+
],
|
|
4273
|
+
name: "PlanCreated",
|
|
4274
|
+
type: "event"
|
|
4275
|
+
},
|
|
4276
|
+
{
|
|
4277
|
+
anonymous: false,
|
|
4278
|
+
inputs: [
|
|
4279
|
+
{
|
|
4280
|
+
indexed: true,
|
|
4281
|
+
internalType: "bytes32",
|
|
4282
|
+
name: "planId",
|
|
4283
|
+
type: "bytes32"
|
|
4284
|
+
}
|
|
4285
|
+
],
|
|
4286
|
+
name: "PlanDeactivated",
|
|
4287
|
+
type: "event"
|
|
4288
|
+
},
|
|
4289
|
+
{
|
|
4290
|
+
anonymous: false,
|
|
4291
|
+
inputs: [
|
|
4292
|
+
{
|
|
4293
|
+
indexed: true,
|
|
4294
|
+
internalType: "bytes32",
|
|
4295
|
+
name: "planId",
|
|
4296
|
+
type: "bytes32"
|
|
4297
|
+
}
|
|
4298
|
+
],
|
|
4299
|
+
name: "PlanUpdated",
|
|
4300
|
+
type: "event"
|
|
4301
|
+
},
|
|
4302
|
+
{
|
|
4303
|
+
anonymous: false,
|
|
4304
|
+
inputs: [
|
|
4305
|
+
{
|
|
4306
|
+
indexed: true,
|
|
4307
|
+
internalType: "bytes32",
|
|
4308
|
+
name: "subscriptionId",
|
|
4309
|
+
type: "bytes32"
|
|
4310
|
+
},
|
|
4311
|
+
{
|
|
4312
|
+
indexed: true,
|
|
4313
|
+
internalType: "bytes32",
|
|
4314
|
+
name: "planId",
|
|
4315
|
+
type: "bytes32"
|
|
4316
|
+
},
|
|
4317
|
+
{
|
|
4318
|
+
indexed: true,
|
|
4319
|
+
internalType: "address",
|
|
4320
|
+
name: "subscriber",
|
|
4321
|
+
type: "address"
|
|
4322
|
+
},
|
|
4323
|
+
{
|
|
4324
|
+
indexed: false,
|
|
4325
|
+
internalType: "address",
|
|
4326
|
+
name: "creator",
|
|
4327
|
+
type: "address"
|
|
4328
|
+
},
|
|
4329
|
+
{
|
|
4330
|
+
indexed: false,
|
|
4331
|
+
internalType: "uint256",
|
|
4332
|
+
name: "endTime",
|
|
4333
|
+
type: "uint256"
|
|
4334
|
+
}
|
|
4335
|
+
],
|
|
4336
|
+
name: "Subscribed",
|
|
4337
|
+
type: "event"
|
|
4338
|
+
},
|
|
4339
|
+
{
|
|
4340
|
+
anonymous: false,
|
|
4341
|
+
inputs: [
|
|
4342
|
+
{
|
|
4343
|
+
indexed: true,
|
|
4344
|
+
internalType: "bytes32",
|
|
4345
|
+
name: "subscriptionId",
|
|
4346
|
+
type: "bytes32"
|
|
4347
|
+
}
|
|
4348
|
+
],
|
|
4349
|
+
name: "SubscriptionCancelled",
|
|
4350
|
+
type: "event"
|
|
4351
|
+
},
|
|
4352
|
+
{
|
|
4353
|
+
anonymous: false,
|
|
4354
|
+
inputs: [
|
|
4355
|
+
{
|
|
4356
|
+
indexed: true,
|
|
4357
|
+
internalType: "bytes32",
|
|
4358
|
+
name: "subscriptionId",
|
|
4359
|
+
type: "bytes32"
|
|
4360
|
+
},
|
|
4361
|
+
{
|
|
4362
|
+
indexed: false,
|
|
4363
|
+
internalType: "uint256",
|
|
4364
|
+
name: "newEndTime",
|
|
4365
|
+
type: "uint256"
|
|
4366
|
+
}
|
|
4367
|
+
],
|
|
4368
|
+
name: "SubscriptionRenewed",
|
|
4369
|
+
type: "event"
|
|
4370
|
+
},
|
|
4371
|
+
{
|
|
4372
|
+
anonymous: false,
|
|
4373
|
+
inputs: [
|
|
4374
|
+
{
|
|
4375
|
+
indexed: false,
|
|
4376
|
+
internalType: "address",
|
|
4377
|
+
name: "account",
|
|
4378
|
+
type: "address"
|
|
4379
|
+
}
|
|
4380
|
+
],
|
|
4381
|
+
name: "Unpaused",
|
|
4382
|
+
type: "event"
|
|
4383
|
+
},
|
|
4384
|
+
{
|
|
4385
|
+
inputs: [
|
|
4386
|
+
{
|
|
4387
|
+
internalType: "address",
|
|
4388
|
+
name: "",
|
|
4389
|
+
type: "address"
|
|
4390
|
+
},
|
|
4391
|
+
{
|
|
4392
|
+
internalType: "address",
|
|
4393
|
+
name: "",
|
|
4394
|
+
type: "address"
|
|
4395
|
+
}
|
|
4396
|
+
],
|
|
4397
|
+
name: "activeSubscription",
|
|
4398
|
+
outputs: [
|
|
4399
|
+
{
|
|
4400
|
+
internalType: "bytes32",
|
|
4401
|
+
name: "",
|
|
4402
|
+
type: "bytes32"
|
|
4403
|
+
}
|
|
4404
|
+
],
|
|
4405
|
+
stateMutability: "view",
|
|
4406
|
+
type: "function"
|
|
4407
|
+
},
|
|
4408
|
+
{
|
|
4409
|
+
inputs: [
|
|
4410
|
+
{
|
|
4411
|
+
internalType: "bytes32",
|
|
4412
|
+
name: "subscriptionId",
|
|
4413
|
+
type: "bytes32"
|
|
4414
|
+
}
|
|
4415
|
+
],
|
|
4416
|
+
name: "cancel",
|
|
4417
|
+
outputs: [],
|
|
4418
|
+
stateMutability: "nonpayable",
|
|
4419
|
+
type: "function"
|
|
4420
|
+
},
|
|
4421
|
+
{
|
|
4422
|
+
inputs: [
|
|
4423
|
+
{
|
|
4424
|
+
internalType: "string",
|
|
4425
|
+
name: "name",
|
|
4426
|
+
type: "string"
|
|
4427
|
+
},
|
|
4428
|
+
{
|
|
4429
|
+
internalType: "string",
|
|
4430
|
+
name: "description",
|
|
4431
|
+
type: "string"
|
|
4432
|
+
},
|
|
4433
|
+
{
|
|
4434
|
+
internalType: "uint256",
|
|
4435
|
+
name: "price",
|
|
4436
|
+
type: "uint256"
|
|
4437
|
+
},
|
|
4438
|
+
{
|
|
4439
|
+
internalType: "address",
|
|
4440
|
+
name: "paymentToken",
|
|
4441
|
+
type: "address"
|
|
4442
|
+
},
|
|
4443
|
+
{
|
|
4444
|
+
internalType: "uint256",
|
|
4445
|
+
name: "durationDays",
|
|
4446
|
+
type: "uint256"
|
|
4447
|
+
},
|
|
4448
|
+
{
|
|
4449
|
+
internalType: "uint256",
|
|
4450
|
+
name: "maxSubscribers",
|
|
4451
|
+
type: "uint256"
|
|
4452
|
+
}
|
|
4453
|
+
],
|
|
4454
|
+
name: "createPlan",
|
|
4455
|
+
outputs: [
|
|
4456
|
+
{
|
|
4457
|
+
internalType: "bytes32",
|
|
4458
|
+
name: "",
|
|
4459
|
+
type: "bytes32"
|
|
4460
|
+
}
|
|
4461
|
+
],
|
|
4462
|
+
stateMutability: "nonpayable",
|
|
4463
|
+
type: "function"
|
|
4464
|
+
},
|
|
4465
|
+
{
|
|
4466
|
+
inputs: [
|
|
4467
|
+
{
|
|
4468
|
+
internalType: "address",
|
|
4469
|
+
name: "",
|
|
4470
|
+
type: "address"
|
|
4471
|
+
},
|
|
4472
|
+
{
|
|
4473
|
+
internalType: "uint256",
|
|
4474
|
+
name: "",
|
|
4475
|
+
type: "uint256"
|
|
4476
|
+
}
|
|
4477
|
+
],
|
|
4478
|
+
name: "creatorPlans",
|
|
4479
|
+
outputs: [
|
|
4480
|
+
{
|
|
4481
|
+
internalType: "bytes32",
|
|
4482
|
+
name: "",
|
|
4483
|
+
type: "bytes32"
|
|
4484
|
+
}
|
|
4485
|
+
],
|
|
4486
|
+
stateMutability: "view",
|
|
4487
|
+
type: "function"
|
|
4488
|
+
},
|
|
4489
|
+
{
|
|
4490
|
+
inputs: [
|
|
4491
|
+
{
|
|
4492
|
+
internalType: "bytes32",
|
|
4493
|
+
name: "planId",
|
|
4494
|
+
type: "bytes32"
|
|
4495
|
+
}
|
|
4496
|
+
],
|
|
4497
|
+
name: "deactivatePlan",
|
|
4498
|
+
outputs: [],
|
|
4499
|
+
stateMutability: "nonpayable",
|
|
4500
|
+
type: "function"
|
|
4501
|
+
},
|
|
4502
|
+
{
|
|
4503
|
+
inputs: [
|
|
4504
|
+
{
|
|
4505
|
+
internalType: "address",
|
|
4506
|
+
name: "creator",
|
|
4507
|
+
type: "address"
|
|
4508
|
+
}
|
|
4509
|
+
],
|
|
4510
|
+
name: "getCreatorPlans",
|
|
4511
|
+
outputs: [
|
|
4512
|
+
{
|
|
4513
|
+
internalType: "bytes32[]",
|
|
4514
|
+
name: "",
|
|
4515
|
+
type: "bytes32[]"
|
|
4516
|
+
}
|
|
4517
|
+
],
|
|
4518
|
+
stateMutability: "view",
|
|
4519
|
+
type: "function"
|
|
4520
|
+
},
|
|
4521
|
+
{
|
|
4522
|
+
inputs: [
|
|
4523
|
+
{
|
|
4524
|
+
internalType: "bytes32",
|
|
4525
|
+
name: "planId",
|
|
4526
|
+
type: "bytes32"
|
|
4527
|
+
}
|
|
4528
|
+
],
|
|
4529
|
+
name: "getPlan",
|
|
4530
|
+
outputs: [
|
|
4531
|
+
{
|
|
4532
|
+
components: [
|
|
4533
|
+
{
|
|
4534
|
+
internalType: "bytes32",
|
|
4535
|
+
name: "planId",
|
|
4536
|
+
type: "bytes32"
|
|
4537
|
+
},
|
|
4538
|
+
{
|
|
4539
|
+
internalType: "address",
|
|
4540
|
+
name: "creator",
|
|
4541
|
+
type: "address"
|
|
4542
|
+
},
|
|
4543
|
+
{
|
|
4544
|
+
internalType: "string",
|
|
4545
|
+
name: "name",
|
|
4546
|
+
type: "string"
|
|
4547
|
+
},
|
|
4548
|
+
{
|
|
4549
|
+
internalType: "string",
|
|
4550
|
+
name: "description",
|
|
4551
|
+
type: "string"
|
|
4552
|
+
},
|
|
4553
|
+
{
|
|
4554
|
+
internalType: "uint256",
|
|
4555
|
+
name: "price",
|
|
4556
|
+
type: "uint256"
|
|
4557
|
+
},
|
|
4558
|
+
{
|
|
4559
|
+
internalType: "address",
|
|
4560
|
+
name: "paymentToken",
|
|
4561
|
+
type: "address"
|
|
4562
|
+
},
|
|
4563
|
+
{
|
|
4564
|
+
internalType: "uint256",
|
|
4565
|
+
name: "durationDays",
|
|
4566
|
+
type: "uint256"
|
|
4567
|
+
},
|
|
4568
|
+
{
|
|
4569
|
+
internalType: "uint256",
|
|
4570
|
+
name: "maxSubscribers",
|
|
4571
|
+
type: "uint256"
|
|
4572
|
+
},
|
|
4573
|
+
{
|
|
4574
|
+
internalType: "uint256",
|
|
4575
|
+
name: "subscriberCount",
|
|
4576
|
+
type: "uint256"
|
|
4577
|
+
},
|
|
4578
|
+
{
|
|
4579
|
+
internalType: "bool",
|
|
4580
|
+
name: "isActive",
|
|
4581
|
+
type: "bool"
|
|
4582
|
+
}
|
|
4583
|
+
],
|
|
4584
|
+
internalType: "struct ZubariSubscription.SubscriptionPlan",
|
|
4585
|
+
name: "",
|
|
4586
|
+
type: "tuple"
|
|
4587
|
+
}
|
|
4588
|
+
],
|
|
4589
|
+
stateMutability: "view",
|
|
4590
|
+
type: "function"
|
|
4591
|
+
},
|
|
4592
|
+
{
|
|
4593
|
+
inputs: [
|
|
4594
|
+
{
|
|
4595
|
+
internalType: "bytes32",
|
|
4596
|
+
name: "subscriptionId",
|
|
4597
|
+
type: "bytes32"
|
|
4598
|
+
}
|
|
4599
|
+
],
|
|
4600
|
+
name: "getSubscription",
|
|
4601
|
+
outputs: [
|
|
4602
|
+
{
|
|
4603
|
+
components: [
|
|
4604
|
+
{
|
|
4605
|
+
internalType: "bytes32",
|
|
4606
|
+
name: "subscriptionId",
|
|
4607
|
+
type: "bytes32"
|
|
4608
|
+
},
|
|
4609
|
+
{
|
|
4610
|
+
internalType: "bytes32",
|
|
4611
|
+
name: "planId",
|
|
4612
|
+
type: "bytes32"
|
|
4613
|
+
},
|
|
4614
|
+
{
|
|
4615
|
+
internalType: "address",
|
|
4616
|
+
name: "creator",
|
|
4617
|
+
type: "address"
|
|
4618
|
+
},
|
|
4619
|
+
{
|
|
4620
|
+
internalType: "address",
|
|
4621
|
+
name: "subscriber",
|
|
4622
|
+
type: "address"
|
|
4623
|
+
},
|
|
4624
|
+
{
|
|
4625
|
+
internalType: "uint256",
|
|
4626
|
+
name: "startTime",
|
|
4627
|
+
type: "uint256"
|
|
4628
|
+
},
|
|
4629
|
+
{
|
|
4630
|
+
internalType: "uint256",
|
|
4631
|
+
name: "endTime",
|
|
4632
|
+
type: "uint256"
|
|
4633
|
+
},
|
|
4634
|
+
{
|
|
4635
|
+
internalType: "bool",
|
|
4636
|
+
name: "autoRenew",
|
|
4637
|
+
type: "bool"
|
|
4638
|
+
},
|
|
4639
|
+
{
|
|
4640
|
+
internalType: "enum ZubariSubscription.SubscriptionStatus",
|
|
4641
|
+
name: "status",
|
|
4642
|
+
type: "uint8"
|
|
4643
|
+
}
|
|
4644
|
+
],
|
|
4645
|
+
internalType: "struct ZubariSubscription.Subscription",
|
|
4646
|
+
name: "",
|
|
4647
|
+
type: "tuple"
|
|
4648
|
+
}
|
|
4649
|
+
],
|
|
4650
|
+
stateMutability: "view",
|
|
4651
|
+
type: "function"
|
|
4652
|
+
},
|
|
4653
|
+
{
|
|
4654
|
+
inputs: [
|
|
4655
|
+
{
|
|
4656
|
+
internalType: "address",
|
|
4657
|
+
name: "subscriber",
|
|
4658
|
+
type: "address"
|
|
4659
|
+
},
|
|
4660
|
+
{
|
|
4661
|
+
internalType: "address",
|
|
4662
|
+
name: "creator",
|
|
4663
|
+
type: "address"
|
|
4664
|
+
}
|
|
4665
|
+
],
|
|
4666
|
+
name: "isSubscribed",
|
|
4667
|
+
outputs: [
|
|
4668
|
+
{
|
|
4669
|
+
internalType: "bool",
|
|
4670
|
+
name: "",
|
|
4671
|
+
type: "bool"
|
|
4672
|
+
}
|
|
4673
|
+
],
|
|
4674
|
+
stateMutability: "view",
|
|
4675
|
+
type: "function"
|
|
4676
|
+
},
|
|
4677
|
+
{
|
|
4678
|
+
inputs: [],
|
|
4679
|
+
name: "owner",
|
|
4680
|
+
outputs: [
|
|
4681
|
+
{
|
|
4682
|
+
internalType: "address",
|
|
4683
|
+
name: "",
|
|
4684
|
+
type: "address"
|
|
4685
|
+
}
|
|
4686
|
+
],
|
|
4687
|
+
stateMutability: "view",
|
|
4688
|
+
type: "function"
|
|
4689
|
+
},
|
|
4690
|
+
{
|
|
4691
|
+
inputs: [],
|
|
4692
|
+
name: "pause",
|
|
4693
|
+
outputs: [],
|
|
4694
|
+
stateMutability: "nonpayable",
|
|
4695
|
+
type: "function"
|
|
4696
|
+
},
|
|
4697
|
+
{
|
|
4698
|
+
inputs: [],
|
|
4699
|
+
name: "paused",
|
|
4700
|
+
outputs: [
|
|
4701
|
+
{
|
|
4702
|
+
internalType: "bool",
|
|
4703
|
+
name: "",
|
|
4704
|
+
type: "bool"
|
|
4705
|
+
}
|
|
4706
|
+
],
|
|
4707
|
+
stateMutability: "view",
|
|
4708
|
+
type: "function"
|
|
4709
|
+
},
|
|
4710
|
+
{
|
|
4711
|
+
inputs: [
|
|
4712
|
+
{
|
|
4713
|
+
internalType: "bytes32",
|
|
4714
|
+
name: "",
|
|
4715
|
+
type: "bytes32"
|
|
4716
|
+
}
|
|
4717
|
+
],
|
|
4718
|
+
name: "plans",
|
|
4719
|
+
outputs: [
|
|
4720
|
+
{
|
|
4721
|
+
internalType: "bytes32",
|
|
4722
|
+
name: "planId",
|
|
4723
|
+
type: "bytes32"
|
|
4724
|
+
},
|
|
4725
|
+
{
|
|
4726
|
+
internalType: "address",
|
|
4727
|
+
name: "creator",
|
|
4728
|
+
type: "address"
|
|
4729
|
+
},
|
|
4730
|
+
{
|
|
4731
|
+
internalType: "string",
|
|
4732
|
+
name: "name",
|
|
4733
|
+
type: "string"
|
|
4734
|
+
},
|
|
4735
|
+
{
|
|
4736
|
+
internalType: "string",
|
|
4737
|
+
name: "description",
|
|
4738
|
+
type: "string"
|
|
4739
|
+
},
|
|
4740
|
+
{
|
|
4741
|
+
internalType: "uint256",
|
|
4742
|
+
name: "price",
|
|
4743
|
+
type: "uint256"
|
|
4744
|
+
},
|
|
4745
|
+
{
|
|
4746
|
+
internalType: "address",
|
|
4747
|
+
name: "paymentToken",
|
|
4748
|
+
type: "address"
|
|
4749
|
+
},
|
|
4750
|
+
{
|
|
4751
|
+
internalType: "uint256",
|
|
4752
|
+
name: "durationDays",
|
|
4753
|
+
type: "uint256"
|
|
4754
|
+
},
|
|
4755
|
+
{
|
|
4756
|
+
internalType: "uint256",
|
|
4757
|
+
name: "maxSubscribers",
|
|
4758
|
+
type: "uint256"
|
|
4759
|
+
},
|
|
4760
|
+
{
|
|
4761
|
+
internalType: "uint256",
|
|
4762
|
+
name: "subscriberCount",
|
|
4763
|
+
type: "uint256"
|
|
4764
|
+
},
|
|
4765
|
+
{
|
|
4766
|
+
internalType: "bool",
|
|
4767
|
+
name: "isActive",
|
|
4768
|
+
type: "bool"
|
|
4769
|
+
}
|
|
4770
|
+
],
|
|
4771
|
+
stateMutability: "view",
|
|
4772
|
+
type: "function"
|
|
4773
|
+
},
|
|
4774
|
+
{
|
|
4775
|
+
inputs: [],
|
|
4776
|
+
name: "platformFeeBps",
|
|
4777
|
+
outputs: [
|
|
4778
|
+
{
|
|
4779
|
+
internalType: "uint256",
|
|
4780
|
+
name: "",
|
|
4781
|
+
type: "uint256"
|
|
4782
|
+
}
|
|
4783
|
+
],
|
|
4784
|
+
stateMutability: "view",
|
|
4785
|
+
type: "function"
|
|
4786
|
+
},
|
|
4787
|
+
{
|
|
4788
|
+
inputs: [],
|
|
4789
|
+
name: "renounceOwnership",
|
|
4790
|
+
outputs: [],
|
|
4791
|
+
stateMutability: "nonpayable",
|
|
4792
|
+
type: "function"
|
|
4793
|
+
},
|
|
4794
|
+
{
|
|
4795
|
+
inputs: [
|
|
4796
|
+
{
|
|
4797
|
+
internalType: "bytes32",
|
|
4798
|
+
name: "subscriptionId",
|
|
4799
|
+
type: "bytes32"
|
|
4800
|
+
},
|
|
4801
|
+
{
|
|
4802
|
+
internalType: "bool",
|
|
4803
|
+
name: "autoRenew",
|
|
4804
|
+
type: "bool"
|
|
4805
|
+
}
|
|
4806
|
+
],
|
|
4807
|
+
name: "setAutoRenew",
|
|
4808
|
+
outputs: [],
|
|
4809
|
+
stateMutability: "nonpayable",
|
|
4810
|
+
type: "function"
|
|
4811
|
+
},
|
|
4812
|
+
{
|
|
4813
|
+
inputs: [
|
|
4814
|
+
{
|
|
4815
|
+
internalType: "uint256",
|
|
4816
|
+
name: "_feeBps",
|
|
4817
|
+
type: "uint256"
|
|
4818
|
+
}
|
|
4819
|
+
],
|
|
4820
|
+
name: "setPlatformFee",
|
|
4821
|
+
outputs: [],
|
|
4822
|
+
stateMutability: "nonpayable",
|
|
4823
|
+
type: "function"
|
|
4824
|
+
},
|
|
4825
|
+
{
|
|
4826
|
+
inputs: [
|
|
4827
|
+
{
|
|
4828
|
+
internalType: "address",
|
|
4829
|
+
name: "_treasury",
|
|
4830
|
+
type: "address"
|
|
4831
|
+
}
|
|
4832
|
+
],
|
|
4833
|
+
name: "setTreasury",
|
|
4834
|
+
outputs: [],
|
|
4835
|
+
stateMutability: "nonpayable",
|
|
4836
|
+
type: "function"
|
|
4837
|
+
},
|
|
4838
|
+
{
|
|
4839
|
+
inputs: [
|
|
4840
|
+
{
|
|
4841
|
+
internalType: "bytes32",
|
|
4842
|
+
name: "planId",
|
|
4843
|
+
type: "bytes32"
|
|
4844
|
+
},
|
|
4845
|
+
{
|
|
4846
|
+
internalType: "uint256",
|
|
4847
|
+
name: "months",
|
|
4848
|
+
type: "uint256"
|
|
4849
|
+
}
|
|
4850
|
+
],
|
|
4851
|
+
name: "subscribe",
|
|
4852
|
+
outputs: [
|
|
4853
|
+
{
|
|
4854
|
+
internalType: "bytes32",
|
|
4855
|
+
name: "",
|
|
4856
|
+
type: "bytes32"
|
|
4857
|
+
}
|
|
4858
|
+
],
|
|
4859
|
+
stateMutability: "payable",
|
|
4860
|
+
type: "function"
|
|
4861
|
+
},
|
|
4862
|
+
{
|
|
4863
|
+
inputs: [
|
|
4864
|
+
{
|
|
4865
|
+
internalType: "address",
|
|
4866
|
+
name: "",
|
|
4867
|
+
type: "address"
|
|
4868
|
+
},
|
|
4869
|
+
{
|
|
4870
|
+
internalType: "uint256",
|
|
4871
|
+
name: "",
|
|
4872
|
+
type: "uint256"
|
|
4873
|
+
}
|
|
4874
|
+
],
|
|
4875
|
+
name: "subscriberSubscriptions",
|
|
4876
|
+
outputs: [
|
|
4877
|
+
{
|
|
4878
|
+
internalType: "bytes32",
|
|
4879
|
+
name: "",
|
|
4880
|
+
type: "bytes32"
|
|
4881
|
+
}
|
|
4882
|
+
],
|
|
4883
|
+
stateMutability: "view",
|
|
4884
|
+
type: "function"
|
|
4885
|
+
},
|
|
4886
|
+
{
|
|
4887
|
+
inputs: [
|
|
4888
|
+
{
|
|
4889
|
+
internalType: "bytes32",
|
|
4890
|
+
name: "",
|
|
4891
|
+
type: "bytes32"
|
|
4892
|
+
}
|
|
4893
|
+
],
|
|
4894
|
+
name: "subscriptions",
|
|
4895
|
+
outputs: [
|
|
4896
|
+
{
|
|
4897
|
+
internalType: "bytes32",
|
|
4898
|
+
name: "subscriptionId",
|
|
4899
|
+
type: "bytes32"
|
|
4900
|
+
},
|
|
4901
|
+
{
|
|
4902
|
+
internalType: "bytes32",
|
|
4903
|
+
name: "planId",
|
|
4904
|
+
type: "bytes32"
|
|
4905
|
+
},
|
|
4906
|
+
{
|
|
4907
|
+
internalType: "address",
|
|
4908
|
+
name: "creator",
|
|
4909
|
+
type: "address"
|
|
4910
|
+
},
|
|
4911
|
+
{
|
|
4912
|
+
internalType: "address",
|
|
4913
|
+
name: "subscriber",
|
|
4914
|
+
type: "address"
|
|
4915
|
+
},
|
|
4916
|
+
{
|
|
4917
|
+
internalType: "uint256",
|
|
4918
|
+
name: "startTime",
|
|
4919
|
+
type: "uint256"
|
|
4920
|
+
},
|
|
4921
|
+
{
|
|
4922
|
+
internalType: "uint256",
|
|
4923
|
+
name: "endTime",
|
|
4924
|
+
type: "uint256"
|
|
4925
|
+
},
|
|
4926
|
+
{
|
|
4927
|
+
internalType: "bool",
|
|
4928
|
+
name: "autoRenew",
|
|
4929
|
+
type: "bool"
|
|
4930
|
+
},
|
|
4931
|
+
{
|
|
4932
|
+
internalType: "enum ZubariSubscription.SubscriptionStatus",
|
|
4933
|
+
name: "status",
|
|
4934
|
+
type: "uint8"
|
|
4935
|
+
}
|
|
4936
|
+
],
|
|
4937
|
+
stateMutability: "view",
|
|
4938
|
+
type: "function"
|
|
4939
|
+
},
|
|
4940
|
+
{
|
|
4941
|
+
inputs: [
|
|
4942
|
+
{
|
|
4943
|
+
internalType: "address",
|
|
4944
|
+
name: "newOwner",
|
|
4945
|
+
type: "address"
|
|
4946
|
+
}
|
|
4947
|
+
],
|
|
4948
|
+
name: "transferOwnership",
|
|
4949
|
+
outputs: [],
|
|
4950
|
+
stateMutability: "nonpayable",
|
|
4951
|
+
type: "function"
|
|
4952
|
+
},
|
|
4953
|
+
{
|
|
4954
|
+
inputs: [],
|
|
4955
|
+
name: "treasury",
|
|
4956
|
+
outputs: [
|
|
4957
|
+
{
|
|
4958
|
+
internalType: "address",
|
|
4959
|
+
name: "",
|
|
4960
|
+
type: "address"
|
|
4961
|
+
}
|
|
4962
|
+
],
|
|
4963
|
+
stateMutability: "view",
|
|
4964
|
+
type: "function"
|
|
4965
|
+
},
|
|
4966
|
+
{
|
|
4967
|
+
inputs: [],
|
|
4968
|
+
name: "unpause",
|
|
4969
|
+
outputs: [],
|
|
4970
|
+
stateMutability: "nonpayable",
|
|
4971
|
+
type: "function"
|
|
4972
|
+
}
|
|
4973
|
+
];
|
|
4974
|
+
|
|
4975
|
+
// src/protocols/SubscriptionProtocol.ts
|
|
4976
|
+
var ZubariSubscriptionProtocol = class {
|
|
4977
|
+
contractAddress;
|
|
4978
|
+
chainId;
|
|
4979
|
+
abi = ZubariSubscription_default;
|
|
4980
|
+
constructor(contractAddress, chainId) {
|
|
3301
4981
|
this.contractAddress = contractAddress;
|
|
3302
4982
|
this.chainId = chainId;
|
|
3303
|
-
this.gaslessEnabled = gaslessEnabled;
|
|
3304
|
-
}
|
|
3305
|
-
/**
|
|
3306
|
-
* Send a tip to a creator
|
|
3307
|
-
*/
|
|
3308
|
-
async sendTip(tip) {
|
|
3309
|
-
const { recipient, amount, token, message } = tip;
|
|
3310
|
-
const platformFee = amount * BigInt(PLATFORM_CONFIG.tipFeeBps) / BigInt(1e4);
|
|
3311
|
-
const creatorAmount = amount - platformFee;
|
|
3312
|
-
if (amount <= 0n) {
|
|
3313
|
-
throw new Error("Tip amount must be greater than 0");
|
|
3314
|
-
}
|
|
3315
|
-
const txResult = {
|
|
3316
|
-
hash: ""};
|
|
3317
|
-
return {
|
|
3318
|
-
txHash: txResult.hash,
|
|
3319
|
-
tipId: "",
|
|
3320
|
-
// Will be returned from contract event
|
|
3321
|
-
recipient,
|
|
3322
|
-
amount: creatorAmount,
|
|
3323
|
-
platformFee,
|
|
3324
|
-
timestamp: Math.floor(Date.now() / 1e3)
|
|
3325
|
-
};
|
|
3326
|
-
}
|
|
3327
|
-
/**
|
|
3328
|
-
* Send tips to multiple creators in a single transaction
|
|
3329
|
-
*/
|
|
3330
|
-
async sendBatchTips(tips) {
|
|
3331
|
-
if (tips.length === 0) {
|
|
3332
|
-
throw new Error("At least one tip is required");
|
|
3333
|
-
}
|
|
3334
|
-
tips.reduce((sum, tip) => sum + tip.amount, BigInt(0));
|
|
3335
|
-
return tips.map((tip) => ({
|
|
3336
|
-
txHash: "",
|
|
3337
|
-
tipId: "",
|
|
3338
|
-
recipient: tip.recipient,
|
|
3339
|
-
amount: tip.amount - tip.amount * BigInt(PLATFORM_CONFIG.tipFeeBps) / BigInt(1e4),
|
|
3340
|
-
platformFee: tip.amount * BigInt(PLATFORM_CONFIG.tipFeeBps) / BigInt(1e4),
|
|
3341
|
-
timestamp: Math.floor(Date.now() / 1e3)
|
|
3342
|
-
}));
|
|
3343
|
-
}
|
|
3344
|
-
/**
|
|
3345
|
-
* Get tips received by an address
|
|
3346
|
-
*/
|
|
3347
|
-
async getTipsReceived(address) {
|
|
3348
|
-
return [];
|
|
3349
|
-
}
|
|
3350
|
-
/**
|
|
3351
|
-
* Get tips sent by an address
|
|
3352
|
-
*/
|
|
3353
|
-
async getTipsSent(address) {
|
|
3354
|
-
return [];
|
|
3355
4983
|
}
|
|
3356
4984
|
/**
|
|
3357
|
-
* Get
|
|
4985
|
+
* Get the contract ABI
|
|
3358
4986
|
*/
|
|
3359
|
-
|
|
3360
|
-
return
|
|
3361
|
-
totalReceived: BigInt(0),
|
|
3362
|
-
tipCount: 0,
|
|
3363
|
-
uniqueTippers: 0
|
|
3364
|
-
};
|
|
4987
|
+
getAbi() {
|
|
4988
|
+
return this.abi;
|
|
3365
4989
|
}
|
|
3366
4990
|
/**
|
|
3367
|
-
* Get
|
|
4991
|
+
* Get the contract address
|
|
3368
4992
|
*/
|
|
3369
|
-
|
|
3370
|
-
return
|
|
3371
|
-
}
|
|
3372
|
-
};
|
|
3373
|
-
|
|
3374
|
-
// src/protocols/SubscriptionProtocol.ts
|
|
3375
|
-
var ZubariSubscriptionProtocol = class {
|
|
3376
|
-
contractAddress;
|
|
3377
|
-
chainId;
|
|
3378
|
-
constructor(contractAddress, chainId) {
|
|
3379
|
-
this.contractAddress = contractAddress;
|
|
3380
|
-
this.chainId = chainId;
|
|
4993
|
+
getAddress() {
|
|
4994
|
+
return this.contractAddress;
|
|
3381
4995
|
}
|
|
3382
4996
|
/**
|
|
3383
4997
|
* Create a new subscription plan
|
|
4998
|
+
* @param plan The plan details
|
|
4999
|
+
* @param signer Wallet signer with sendTransaction method
|
|
3384
5000
|
*/
|
|
3385
|
-
async createPlan(plan) {
|
|
5001
|
+
async createPlan(plan, signer) {
|
|
3386
5002
|
if (!plan.name || plan.name.length === 0) {
|
|
3387
5003
|
throw new Error("Plan name is required");
|
|
3388
5004
|
}
|
|
@@ -3392,87 +5008,305 @@ var ZubariSubscriptionProtocol = class {
|
|
|
3392
5008
|
if (plan.duration <= 0) {
|
|
3393
5009
|
throw new Error("Plan duration must be greater than 0");
|
|
3394
5010
|
}
|
|
3395
|
-
const
|
|
3396
|
-
|
|
5011
|
+
const iface = new (await import('ethers')).Interface(this.abi);
|
|
5012
|
+
const durationDays = Math.ceil(plan.duration / (24 * 60 * 60));
|
|
5013
|
+
const data = iface.encodeFunctionData("createPlan", [
|
|
5014
|
+
plan.name,
|
|
5015
|
+
plan.description || "",
|
|
5016
|
+
plan.price,
|
|
5017
|
+
plan.paymentToken || "0x0000000000000000000000000000000000000000",
|
|
5018
|
+
// ETH by default
|
|
5019
|
+
durationDays,
|
|
5020
|
+
plan.maxSubscribers || 0
|
|
5021
|
+
// 0 = unlimited
|
|
5022
|
+
]);
|
|
5023
|
+
const result = await signer.sendTransaction({
|
|
5024
|
+
to: this.contractAddress,
|
|
5025
|
+
value: 0n,
|
|
5026
|
+
data
|
|
5027
|
+
});
|
|
5028
|
+
return result.hash;
|
|
3397
5029
|
}
|
|
3398
5030
|
/**
|
|
3399
|
-
*
|
|
5031
|
+
* Deactivate a subscription plan (only creator can do this)
|
|
5032
|
+
* @param planId The plan ID to deactivate
|
|
5033
|
+
* @param signer Wallet signer
|
|
3400
5034
|
*/
|
|
3401
|
-
async
|
|
5035
|
+
async deactivatePlan(planId, signer) {
|
|
5036
|
+
const iface = new (await import('ethers')).Interface(this.abi);
|
|
5037
|
+
const data = iface.encodeFunctionData("deactivatePlan", [planId]);
|
|
5038
|
+
const result = await signer.sendTransaction({
|
|
5039
|
+
to: this.contractAddress,
|
|
5040
|
+
value: 0n,
|
|
5041
|
+
data
|
|
5042
|
+
});
|
|
3402
5043
|
return {
|
|
3403
|
-
hash:
|
|
5044
|
+
hash: result.hash,
|
|
3404
5045
|
network: "ethereum",
|
|
3405
5046
|
status: "pending"
|
|
3406
5047
|
};
|
|
3407
5048
|
}
|
|
3408
5049
|
/**
|
|
3409
5050
|
* Subscribe to a creator's plan
|
|
5051
|
+
* @param planId The plan ID to subscribe to
|
|
5052
|
+
* @param months Number of months to subscribe
|
|
5053
|
+
* @param signer Wallet signer
|
|
5054
|
+
* @param value ETH value to send (if paying with ETH)
|
|
3410
5055
|
*/
|
|
3411
|
-
async subscribe(
|
|
5056
|
+
async subscribe(planId, months, signer, value) {
|
|
3412
5057
|
if (months <= 0) {
|
|
3413
5058
|
throw new Error("Subscription duration must be at least 1 month");
|
|
3414
5059
|
}
|
|
3415
|
-
const
|
|
3416
|
-
const
|
|
5060
|
+
const iface = new (await import('ethers')).Interface(this.abi);
|
|
5061
|
+
const data = iface.encodeFunctionData("subscribe", [planId, months]);
|
|
5062
|
+
const result = await signer.sendTransaction({
|
|
5063
|
+
to: this.contractAddress,
|
|
5064
|
+
value: value || 0n,
|
|
5065
|
+
data
|
|
5066
|
+
});
|
|
3417
5067
|
return {
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
subscriber: "",
|
|
3422
|
-
// Current user address
|
|
3423
|
-
startTime: now,
|
|
3424
|
-
endTime: now + durationSeconds,
|
|
3425
|
-
autoRenew: false,
|
|
3426
|
-
status: "active"
|
|
5068
|
+
hash: result.hash,
|
|
5069
|
+
network: "ethereum",
|
|
5070
|
+
status: "pending"
|
|
3427
5071
|
};
|
|
3428
5072
|
}
|
|
3429
5073
|
/**
|
|
3430
5074
|
* Cancel an active subscription
|
|
5075
|
+
* @param subscriptionId The subscription ID to cancel
|
|
5076
|
+
* @param signer Wallet signer
|
|
3431
5077
|
*/
|
|
3432
|
-
async cancel(subscriptionId) {
|
|
5078
|
+
async cancel(subscriptionId, signer) {
|
|
5079
|
+
const iface = new (await import('ethers')).Interface(this.abi);
|
|
5080
|
+
const data = iface.encodeFunctionData("cancel", [subscriptionId]);
|
|
5081
|
+
const result = await signer.sendTransaction({
|
|
5082
|
+
to: this.contractAddress,
|
|
5083
|
+
value: 0n,
|
|
5084
|
+
data
|
|
5085
|
+
});
|
|
3433
5086
|
return {
|
|
3434
|
-
hash:
|
|
5087
|
+
hash: result.hash,
|
|
5088
|
+
network: "ethereum",
|
|
5089
|
+
status: "pending"
|
|
5090
|
+
};
|
|
5091
|
+
}
|
|
5092
|
+
/**
|
|
5093
|
+
* Set auto-renew for a subscription
|
|
5094
|
+
* @param subscriptionId The subscription ID
|
|
5095
|
+
* @param autoRenew Whether to enable auto-renew
|
|
5096
|
+
* @param signer Wallet signer
|
|
5097
|
+
*/
|
|
5098
|
+
async setAutoRenew(subscriptionId, autoRenew, signer) {
|
|
5099
|
+
const iface = new (await import('ethers')).Interface(this.abi);
|
|
5100
|
+
const data = iface.encodeFunctionData("setAutoRenew", [subscriptionId, autoRenew]);
|
|
5101
|
+
const result = await signer.sendTransaction({
|
|
5102
|
+
to: this.contractAddress,
|
|
5103
|
+
value: 0n,
|
|
5104
|
+
data
|
|
5105
|
+
});
|
|
5106
|
+
return {
|
|
5107
|
+
hash: result.hash,
|
|
3435
5108
|
network: "ethereum",
|
|
3436
5109
|
status: "pending"
|
|
3437
5110
|
};
|
|
3438
5111
|
}
|
|
3439
5112
|
/**
|
|
3440
5113
|
* Check if an address is subscribed to a creator
|
|
5114
|
+
* @param subscriber The subscriber address
|
|
5115
|
+
* @param creator The creator address
|
|
5116
|
+
* @param provider JSON-RPC provider
|
|
3441
5117
|
*/
|
|
3442
|
-
async isSubscribed(creator,
|
|
3443
|
-
|
|
5118
|
+
async isSubscribed(subscriber, creator, provider) {
|
|
5119
|
+
const iface = new (await import('ethers')).Interface(this.abi);
|
|
5120
|
+
const data = iface.encodeFunctionData("isSubscribed", [subscriber, creator]);
|
|
5121
|
+
try {
|
|
5122
|
+
const result = await provider.call({
|
|
5123
|
+
to: this.contractAddress,
|
|
5124
|
+
data
|
|
5125
|
+
});
|
|
5126
|
+
const decoded = iface.decodeFunctionResult("isSubscribed", result);
|
|
5127
|
+
return decoded[0];
|
|
5128
|
+
} catch {
|
|
5129
|
+
return false;
|
|
5130
|
+
}
|
|
3444
5131
|
}
|
|
3445
5132
|
/**
|
|
3446
|
-
* Get active
|
|
5133
|
+
* Get the active subscription ID between subscriber and creator
|
|
5134
|
+
* @param subscriber The subscriber address
|
|
5135
|
+
* @param creator The creator address
|
|
5136
|
+
* @param provider JSON-RPC provider
|
|
3447
5137
|
*/
|
|
3448
|
-
async
|
|
3449
|
-
|
|
5138
|
+
async getActiveSubscriptionId(subscriber, creator, provider) {
|
|
5139
|
+
const iface = new (await import('ethers')).Interface(this.abi);
|
|
5140
|
+
const data = iface.encodeFunctionData("activeSubscription", [subscriber, creator]);
|
|
5141
|
+
try {
|
|
5142
|
+
const result = await provider.call({
|
|
5143
|
+
to: this.contractAddress,
|
|
5144
|
+
data
|
|
5145
|
+
});
|
|
5146
|
+
const decoded = iface.decodeFunctionResult("activeSubscription", result);
|
|
5147
|
+
const subscriptionId = decoded[0];
|
|
5148
|
+
if (subscriptionId === "0x0000000000000000000000000000000000000000000000000000000000000000") {
|
|
5149
|
+
return null;
|
|
5150
|
+
}
|
|
5151
|
+
return subscriptionId;
|
|
5152
|
+
} catch {
|
|
5153
|
+
return null;
|
|
5154
|
+
}
|
|
3450
5155
|
}
|
|
3451
5156
|
/**
|
|
3452
|
-
* Get
|
|
5157
|
+
* Get subscription details by ID
|
|
5158
|
+
* @param subscriptionId The subscription ID
|
|
5159
|
+
* @param provider JSON-RPC provider
|
|
3453
5160
|
*/
|
|
3454
|
-
async
|
|
3455
|
-
|
|
5161
|
+
async getSubscription(subscriptionId, provider) {
|
|
5162
|
+
const iface = new (await import('ethers')).Interface(this.abi);
|
|
5163
|
+
const data = iface.encodeFunctionData("getSubscription", [subscriptionId]);
|
|
5164
|
+
try {
|
|
5165
|
+
const result = await provider.call({
|
|
5166
|
+
to: this.contractAddress,
|
|
5167
|
+
data
|
|
5168
|
+
});
|
|
5169
|
+
const decoded = iface.decodeFunctionResult("getSubscription", result);
|
|
5170
|
+
const sub = decoded[0];
|
|
5171
|
+
if (sub.subscriptionId === "0x0000000000000000000000000000000000000000000000000000000000000000") {
|
|
5172
|
+
return null;
|
|
5173
|
+
}
|
|
5174
|
+
let status;
|
|
5175
|
+
switch (Number(sub.status)) {
|
|
5176
|
+
case 0 /* Active */:
|
|
5177
|
+
status = "active";
|
|
5178
|
+
break;
|
|
5179
|
+
case 1 /* Cancelled */:
|
|
5180
|
+
status = "cancelled";
|
|
5181
|
+
break;
|
|
5182
|
+
case 2 /* Expired */:
|
|
5183
|
+
status = "expired";
|
|
5184
|
+
break;
|
|
5185
|
+
default:
|
|
5186
|
+
status = "active";
|
|
5187
|
+
}
|
|
5188
|
+
return {
|
|
5189
|
+
subscriptionId: sub.subscriptionId,
|
|
5190
|
+
planId: sub.planId,
|
|
5191
|
+
creator: sub.creator,
|
|
5192
|
+
subscriber: sub.subscriber,
|
|
5193
|
+
startTime: Number(sub.startTime),
|
|
5194
|
+
endTime: Number(sub.endTime),
|
|
5195
|
+
autoRenew: sub.autoRenew,
|
|
5196
|
+
status
|
|
5197
|
+
};
|
|
5198
|
+
} catch {
|
|
5199
|
+
return null;
|
|
5200
|
+
}
|
|
3456
5201
|
}
|
|
3457
5202
|
/**
|
|
3458
5203
|
* Get a specific plan by ID
|
|
5204
|
+
* @param planId The plan ID
|
|
5205
|
+
* @param provider JSON-RPC provider
|
|
3459
5206
|
*/
|
|
3460
|
-
async getPlan(planId) {
|
|
3461
|
-
|
|
5207
|
+
async getPlan(planId, provider) {
|
|
5208
|
+
const iface = new (await import('ethers')).Interface(this.abi);
|
|
5209
|
+
const data = iface.encodeFunctionData("getPlan", [planId]);
|
|
5210
|
+
try {
|
|
5211
|
+
const result = await provider.call({
|
|
5212
|
+
to: this.contractAddress,
|
|
5213
|
+
data
|
|
5214
|
+
});
|
|
5215
|
+
const decoded = iface.decodeFunctionResult("getPlan", result);
|
|
5216
|
+
const plan = decoded[0];
|
|
5217
|
+
if (plan.planId === "0x0000000000000000000000000000000000000000000000000000000000000000") {
|
|
5218
|
+
return null;
|
|
5219
|
+
}
|
|
5220
|
+
const durationSeconds = Number(plan.durationDays) * 24 * 60 * 60;
|
|
5221
|
+
return {
|
|
5222
|
+
planId: plan.planId,
|
|
5223
|
+
name: plan.name,
|
|
5224
|
+
description: plan.description,
|
|
5225
|
+
price: plan.price,
|
|
5226
|
+
paymentToken: plan.paymentToken,
|
|
5227
|
+
duration: durationSeconds,
|
|
5228
|
+
perks: [],
|
|
5229
|
+
// Not stored on-chain
|
|
5230
|
+
maxSubscribers: Number(plan.maxSubscribers),
|
|
5231
|
+
nftBadge: false
|
|
5232
|
+
// Not stored on-chain in this contract version
|
|
5233
|
+
};
|
|
5234
|
+
} catch {
|
|
5235
|
+
return null;
|
|
5236
|
+
}
|
|
3462
5237
|
}
|
|
3463
5238
|
/**
|
|
3464
|
-
* Get all
|
|
5239
|
+
* Get all plan IDs for a creator
|
|
5240
|
+
* @param creator The creator address
|
|
5241
|
+
* @param provider JSON-RPC provider
|
|
3465
5242
|
*/
|
|
3466
|
-
async
|
|
3467
|
-
|
|
5243
|
+
async getCreatorPlanIds(creator, provider) {
|
|
5244
|
+
const iface = new (await import('ethers')).Interface(this.abi);
|
|
5245
|
+
const data = iface.encodeFunctionData("getCreatorPlans", [creator]);
|
|
5246
|
+
try {
|
|
5247
|
+
const result = await provider.call({
|
|
5248
|
+
to: this.contractAddress,
|
|
5249
|
+
data
|
|
5250
|
+
});
|
|
5251
|
+
const decoded = iface.decodeFunctionResult("getCreatorPlans", result);
|
|
5252
|
+
return decoded[0];
|
|
5253
|
+
} catch {
|
|
5254
|
+
return [];
|
|
5255
|
+
}
|
|
3468
5256
|
}
|
|
3469
5257
|
/**
|
|
3470
|
-
*
|
|
5258
|
+
* Get all plans for a creator with full details
|
|
5259
|
+
* @param creator The creator address
|
|
5260
|
+
* @param provider JSON-RPC provider
|
|
3471
5261
|
*/
|
|
3472
|
-
|
|
3473
|
-
const
|
|
3474
|
-
|
|
3475
|
-
|
|
5262
|
+
async getCreatorPlans(creator, provider) {
|
|
5263
|
+
const planIds = await this.getCreatorPlanIds(creator, provider);
|
|
5264
|
+
const plans = [];
|
|
5265
|
+
for (const planId of planIds) {
|
|
5266
|
+
const plan = await this.getPlan(planId, provider);
|
|
5267
|
+
if (plan && plan.planId) {
|
|
5268
|
+
plans.push(plan);
|
|
5269
|
+
}
|
|
5270
|
+
}
|
|
5271
|
+
return plans;
|
|
5272
|
+
}
|
|
5273
|
+
/**
|
|
5274
|
+
* Get platform fee in basis points
|
|
5275
|
+
* @param provider JSON-RPC provider
|
|
5276
|
+
*/
|
|
5277
|
+
async getPlatformFeeBps(provider) {
|
|
5278
|
+
const iface = new (await import('ethers')).Interface(this.abi);
|
|
5279
|
+
const data = iface.encodeFunctionData("platformFeeBps", []);
|
|
5280
|
+
try {
|
|
5281
|
+
const result = await provider.call({
|
|
5282
|
+
to: this.contractAddress,
|
|
5283
|
+
data
|
|
5284
|
+
});
|
|
5285
|
+
const decoded = iface.decodeFunctionResult("platformFeeBps", result);
|
|
5286
|
+
return Number(decoded[0]);
|
|
5287
|
+
} catch {
|
|
5288
|
+
return 300;
|
|
5289
|
+
}
|
|
5290
|
+
}
|
|
5291
|
+
/**
|
|
5292
|
+
* Calculate the total cost for a subscription
|
|
5293
|
+
* @param planPrice The plan price per period
|
|
5294
|
+
* @param months Number of months
|
|
5295
|
+
*/
|
|
5296
|
+
calculateSubscriptionCost(planPrice, months) {
|
|
5297
|
+
return planPrice * BigInt(months);
|
|
5298
|
+
}
|
|
5299
|
+
/**
|
|
5300
|
+
* Calculate platform fee for a given amount
|
|
5301
|
+
* @param amount The amount
|
|
5302
|
+
* @param feeBps Fee in basis points
|
|
5303
|
+
*/
|
|
5304
|
+
calculateFee(amount, feeBps = 300) {
|
|
5305
|
+
const fee = amount * BigInt(feeBps) / 10000n;
|
|
5306
|
+
return {
|
|
5307
|
+
fee,
|
|
5308
|
+
creatorAmount: amount - fee
|
|
5309
|
+
};
|
|
3476
5310
|
}
|
|
3477
5311
|
};
|
|
3478
5312
|
|