@zubari/sdk 0.3.6 → 0.3.8

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.
Files changed (43) hide show
  1. package/dist/PayoutsProtocol-B5z8SEA-.d.ts +734 -0
  2. package/dist/PayoutsProtocol-CLiMFe54.d.mts +734 -0
  3. package/dist/{TransactionService-DuMJmrG3.d.mts → TransactionService-1Jt8ZRqO.d.mts} +1 -1
  4. package/dist/{TransactionService-DURp3bRL.d.ts → TransactionService-Djonkbp4.d.ts} +1 -1
  5. package/dist/{WalletManager-CmiNyapl.d.ts → WalletManager-DfvFJ-mk.d.ts} +12 -1
  6. package/dist/{WalletManager-DXt6vihp.d.mts → WalletManager-j0tgNIKi.d.mts} +12 -1
  7. package/dist/{index-VNzO49qu.d.ts → index-BZDwdQUe.d.mts} +3 -2
  8. package/dist/{index-CRsZrlN0.d.mts → index-CTb2uJpD.d.ts} +3 -2
  9. package/dist/{index-DF0Gf8NK.d.mts → index-CTyZlHKg.d.mts} +7 -1
  10. package/dist/{index-DF0Gf8NK.d.ts → index-CTyZlHKg.d.ts} +7 -1
  11. package/dist/index.d.mts +21 -5
  12. package/dist/index.d.ts +21 -5
  13. package/dist/index.js +120 -17
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +120 -17
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/protocols/index.d.mts +102 -502
  18. package/dist/protocols/index.d.ts +102 -502
  19. package/dist/protocols/index.js +1829 -0
  20. package/dist/protocols/index.js.map +1 -1
  21. package/dist/protocols/index.mjs +1829 -1
  22. package/dist/protocols/index.mjs.map +1 -1
  23. package/dist/react/index.d.mts +7 -3
  24. package/dist/react/index.d.ts +7 -3
  25. package/dist/react/index.js +128 -13
  26. package/dist/react/index.js.map +1 -1
  27. package/dist/react/index.mjs +128 -13
  28. package/dist/react/index.mjs.map +1 -1
  29. package/dist/services/index.d.mts +2 -2
  30. package/dist/services/index.d.ts +2 -2
  31. package/dist/services/index.js.map +1 -1
  32. package/dist/services/index.mjs.map +1 -1
  33. package/dist/storage/index.js +61 -3
  34. package/dist/storage/index.js.map +1 -1
  35. package/dist/storage/index.mjs +61 -3
  36. package/dist/storage/index.mjs.map +1 -1
  37. package/dist/wallet/index.d.mts +3 -3
  38. package/dist/wallet/index.d.ts +3 -3
  39. package/dist/wallet/index.js +120 -17
  40. package/dist/wallet/index.js.map +1 -1
  41. package/dist/wallet/index.mjs +120 -17
  42. package/dist/wallet/index.mjs.map +1 -1
  43. package/package.json +7 -7
@@ -3923,6 +3923,1834 @@ var ZubariSubscriptionProtocol = class {
3923
3923
  }
3924
3924
  };
3925
3925
 
3926
+ // src/abi/ZubariSubscriptionV2.json
3927
+ var ZubariSubscriptionV2_default = [
3928
+ {
3929
+ inputs: [
3930
+ {
3931
+ internalType: "address",
3932
+ name: "_treasury",
3933
+ type: "address"
3934
+ },
3935
+ {
3936
+ internalType: "address",
3937
+ name: "_payoutsContract",
3938
+ type: "address"
3939
+ },
3940
+ {
3941
+ internalType: "uint256",
3942
+ name: "_platformFeeBps",
3943
+ type: "uint256"
3944
+ }
3945
+ ],
3946
+ stateMutability: "nonpayable",
3947
+ type: "constructor"
3948
+ },
3949
+ {
3950
+ inputs: [],
3951
+ name: "AlreadySubscribed",
3952
+ type: "error"
3953
+ },
3954
+ {
3955
+ inputs: [],
3956
+ name: "CreatorAlreadyRegistered",
3957
+ type: "error"
3958
+ },
3959
+ {
3960
+ inputs: [],
3961
+ name: "CreatorNotActive",
3962
+ type: "error"
3963
+ },
3964
+ {
3965
+ inputs: [],
3966
+ name: "CreatorNotRegistered",
3967
+ type: "error"
3968
+ },
3969
+ {
3970
+ inputs: [],
3971
+ name: "EnforcedPause",
3972
+ type: "error"
3973
+ },
3974
+ {
3975
+ inputs: [],
3976
+ name: "ExpectedPause",
3977
+ type: "error"
3978
+ },
3979
+ {
3980
+ inputs: [],
3981
+ name: "InvalidAddress",
3982
+ type: "error"
3983
+ },
3984
+ {
3985
+ inputs: [],
3986
+ name: "InvalidAmount",
3987
+ type: "error"
3988
+ },
3989
+ {
3990
+ inputs: [],
3991
+ name: "InvalidDuration",
3992
+ type: "error"
3993
+ },
3994
+ {
3995
+ inputs: [],
3996
+ name: "InvalidFee",
3997
+ type: "error"
3998
+ },
3999
+ {
4000
+ inputs: [],
4001
+ name: "NotCreator",
4002
+ type: "error"
4003
+ },
4004
+ {
4005
+ inputs: [],
4006
+ name: "NotSubscriber",
4007
+ type: "error"
4008
+ },
4009
+ {
4010
+ inputs: [
4011
+ {
4012
+ internalType: "address",
4013
+ name: "owner",
4014
+ type: "address"
4015
+ }
4016
+ ],
4017
+ name: "OwnableInvalidOwner",
4018
+ type: "error"
4019
+ },
4020
+ {
4021
+ inputs: [
4022
+ {
4023
+ internalType: "address",
4024
+ name: "account",
4025
+ type: "address"
4026
+ }
4027
+ ],
4028
+ name: "OwnableUnauthorizedAccount",
4029
+ type: "error"
4030
+ },
4031
+ {
4032
+ inputs: [],
4033
+ name: "PlanFull",
4034
+ type: "error"
4035
+ },
4036
+ {
4037
+ inputs: [],
4038
+ name: "PlanNotActive",
4039
+ type: "error"
4040
+ },
4041
+ {
4042
+ inputs: [],
4043
+ name: "PlanNotFound",
4044
+ type: "error"
4045
+ },
4046
+ {
4047
+ inputs: [],
4048
+ name: "ReentrancyGuardReentrantCall",
4049
+ type: "error"
4050
+ },
4051
+ {
4052
+ inputs: [
4053
+ {
4054
+ internalType: "address",
4055
+ name: "token",
4056
+ type: "address"
4057
+ }
4058
+ ],
4059
+ name: "SafeERC20FailedOperation",
4060
+ type: "error"
4061
+ },
4062
+ {
4063
+ inputs: [],
4064
+ name: "SubscriptionExpired",
4065
+ type: "error"
4066
+ },
4067
+ {
4068
+ inputs: [],
4069
+ name: "SubscriptionNotFound",
4070
+ type: "error"
4071
+ },
4072
+ {
4073
+ inputs: [],
4074
+ name: "TransferFailed",
4075
+ type: "error"
4076
+ },
4077
+ {
4078
+ anonymous: false,
4079
+ inputs: [
4080
+ {
4081
+ indexed: true,
4082
+ internalType: "address",
4083
+ name: "creator",
4084
+ type: "address"
4085
+ }
4086
+ ],
4087
+ name: "CreatorDeactivated",
4088
+ type: "event"
4089
+ },
4090
+ {
4091
+ anonymous: false,
4092
+ inputs: [
4093
+ {
4094
+ indexed: true,
4095
+ internalType: "address",
4096
+ name: "creator",
4097
+ type: "address"
4098
+ },
4099
+ {
4100
+ indexed: true,
4101
+ internalType: "address",
4102
+ name: "payoutWallet",
4103
+ type: "address"
4104
+ }
4105
+ ],
4106
+ name: "CreatorRegistered",
4107
+ type: "event"
4108
+ },
4109
+ {
4110
+ anonymous: false,
4111
+ inputs: [
4112
+ {
4113
+ indexed: true,
4114
+ internalType: "address",
4115
+ name: "creator",
4116
+ type: "address"
4117
+ },
4118
+ {
4119
+ indexed: true,
4120
+ internalType: "address",
4121
+ name: "oldWallet",
4122
+ type: "address"
4123
+ },
4124
+ {
4125
+ indexed: true,
4126
+ internalType: "address",
4127
+ name: "newWallet",
4128
+ type: "address"
4129
+ }
4130
+ ],
4131
+ name: "CreatorWalletUpdated",
4132
+ type: "event"
4133
+ },
4134
+ {
4135
+ anonymous: false,
4136
+ inputs: [
4137
+ {
4138
+ indexed: true,
4139
+ internalType: "address",
4140
+ name: "previousOwner",
4141
+ type: "address"
4142
+ },
4143
+ {
4144
+ indexed: true,
4145
+ internalType: "address",
4146
+ name: "newOwner",
4147
+ type: "address"
4148
+ }
4149
+ ],
4150
+ name: "OwnershipTransferred",
4151
+ type: "event"
4152
+ },
4153
+ {
4154
+ anonymous: false,
4155
+ inputs: [
4156
+ {
4157
+ indexed: false,
4158
+ internalType: "address",
4159
+ name: "account",
4160
+ type: "address"
4161
+ }
4162
+ ],
4163
+ name: "Paused",
4164
+ type: "event"
4165
+ },
4166
+ {
4167
+ anonymous: false,
4168
+ inputs: [
4169
+ {
4170
+ indexed: true,
4171
+ internalType: "address",
4172
+ name: "from",
4173
+ type: "address"
4174
+ },
4175
+ {
4176
+ indexed: true,
4177
+ internalType: "address",
4178
+ name: "creator",
4179
+ type: "address"
4180
+ },
4181
+ {
4182
+ indexed: false,
4183
+ internalType: "uint256",
4184
+ name: "totalAmount",
4185
+ type: "uint256"
4186
+ },
4187
+ {
4188
+ indexed: false,
4189
+ internalType: "uint256",
4190
+ name: "platformFee",
4191
+ type: "uint256"
4192
+ },
4193
+ {
4194
+ indexed: false,
4195
+ internalType: "uint256",
4196
+ name: "creatorAmount",
4197
+ type: "uint256"
4198
+ },
4199
+ {
4200
+ indexed: false,
4201
+ internalType: "address",
4202
+ name: "token",
4203
+ type: "address"
4204
+ }
4205
+ ],
4206
+ name: "PaymentProcessed",
4207
+ type: "event"
4208
+ },
4209
+ {
4210
+ anonymous: false,
4211
+ inputs: [
4212
+ {
4213
+ indexed: true,
4214
+ internalType: "bytes32",
4215
+ name: "planId",
4216
+ type: "bytes32"
4217
+ },
4218
+ {
4219
+ indexed: true,
4220
+ internalType: "address",
4221
+ name: "creator",
4222
+ type: "address"
4223
+ },
4224
+ {
4225
+ indexed: false,
4226
+ internalType: "string",
4227
+ name: "name",
4228
+ type: "string"
4229
+ },
4230
+ {
4231
+ indexed: false,
4232
+ internalType: "uint256",
4233
+ name: "price",
4234
+ type: "uint256"
4235
+ },
4236
+ {
4237
+ indexed: false,
4238
+ internalType: "uint256",
4239
+ name: "durationDays",
4240
+ type: "uint256"
4241
+ }
4242
+ ],
4243
+ name: "PlanCreated",
4244
+ type: "event"
4245
+ },
4246
+ {
4247
+ anonymous: false,
4248
+ inputs: [
4249
+ {
4250
+ indexed: true,
4251
+ internalType: "bytes32",
4252
+ name: "planId",
4253
+ type: "bytes32"
4254
+ }
4255
+ ],
4256
+ name: "PlanDeactivated",
4257
+ type: "event"
4258
+ },
4259
+ {
4260
+ anonymous: false,
4261
+ inputs: [
4262
+ {
4263
+ indexed: true,
4264
+ internalType: "bytes32",
4265
+ name: "planId",
4266
+ type: "bytes32"
4267
+ },
4268
+ {
4269
+ indexed: false,
4270
+ internalType: "uint256",
4271
+ name: "newPrice",
4272
+ type: "uint256"
4273
+ },
4274
+ {
4275
+ indexed: false,
4276
+ internalType: "uint256",
4277
+ name: "newDuration",
4278
+ type: "uint256"
4279
+ }
4280
+ ],
4281
+ name: "PlanUpdated",
4282
+ type: "event"
4283
+ },
4284
+ {
4285
+ anonymous: false,
4286
+ inputs: [
4287
+ {
4288
+ indexed: true,
4289
+ internalType: "bytes32",
4290
+ name: "subscriptionId",
4291
+ type: "bytes32"
4292
+ },
4293
+ {
4294
+ indexed: true,
4295
+ internalType: "bytes32",
4296
+ name: "planId",
4297
+ type: "bytes32"
4298
+ },
4299
+ {
4300
+ indexed: true,
4301
+ internalType: "address",
4302
+ name: "subscriber",
4303
+ type: "address"
4304
+ },
4305
+ {
4306
+ indexed: false,
4307
+ internalType: "address",
4308
+ name: "creator",
4309
+ type: "address"
4310
+ },
4311
+ {
4312
+ indexed: false,
4313
+ internalType: "uint256",
4314
+ name: "amount",
4315
+ type: "uint256"
4316
+ },
4317
+ {
4318
+ indexed: false,
4319
+ internalType: "uint256",
4320
+ name: "endTime",
4321
+ type: "uint256"
4322
+ }
4323
+ ],
4324
+ name: "Subscribed",
4325
+ type: "event"
4326
+ },
4327
+ {
4328
+ anonymous: false,
4329
+ inputs: [
4330
+ {
4331
+ indexed: true,
4332
+ internalType: "bytes32",
4333
+ name: "subscriptionId",
4334
+ type: "bytes32"
4335
+ }
4336
+ ],
4337
+ name: "SubscriptionCancelled",
4338
+ type: "event"
4339
+ },
4340
+ {
4341
+ anonymous: false,
4342
+ inputs: [
4343
+ {
4344
+ indexed: true,
4345
+ internalType: "bytes32",
4346
+ name: "subscriptionId",
4347
+ type: "bytes32"
4348
+ },
4349
+ {
4350
+ indexed: false,
4351
+ internalType: "uint256",
4352
+ name: "newEndTime",
4353
+ type: "uint256"
4354
+ }
4355
+ ],
4356
+ name: "SubscriptionRenewed",
4357
+ type: "event"
4358
+ },
4359
+ {
4360
+ anonymous: false,
4361
+ inputs: [
4362
+ {
4363
+ indexed: false,
4364
+ internalType: "address",
4365
+ name: "account",
4366
+ type: "address"
4367
+ }
4368
+ ],
4369
+ name: "Unpaused",
4370
+ type: "event"
4371
+ },
4372
+ {
4373
+ inputs: [
4374
+ {
4375
+ internalType: "address",
4376
+ name: "",
4377
+ type: "address"
4378
+ },
4379
+ {
4380
+ internalType: "address",
4381
+ name: "",
4382
+ type: "address"
4383
+ }
4384
+ ],
4385
+ name: "activeSubscription",
4386
+ outputs: [
4387
+ {
4388
+ internalType: "bytes32",
4389
+ name: "",
4390
+ type: "bytes32"
4391
+ }
4392
+ ],
4393
+ stateMutability: "view",
4394
+ type: "function"
4395
+ },
4396
+ {
4397
+ inputs: [
4398
+ {
4399
+ internalType: "uint256",
4400
+ name: "amount",
4401
+ type: "uint256"
4402
+ }
4403
+ ],
4404
+ name: "calculateFee",
4405
+ outputs: [
4406
+ {
4407
+ internalType: "uint256",
4408
+ name: "fee",
4409
+ type: "uint256"
4410
+ },
4411
+ {
4412
+ internalType: "uint256",
4413
+ name: "creatorAmount",
4414
+ type: "uint256"
4415
+ }
4416
+ ],
4417
+ stateMutability: "view",
4418
+ type: "function"
4419
+ },
4420
+ {
4421
+ inputs: [
4422
+ {
4423
+ internalType: "bytes32",
4424
+ name: "subscriptionId",
4425
+ type: "bytes32"
4426
+ }
4427
+ ],
4428
+ name: "cancel",
4429
+ outputs: [],
4430
+ stateMutability: "nonpayable",
4431
+ type: "function"
4432
+ },
4433
+ {
4434
+ inputs: [
4435
+ {
4436
+ internalType: "string",
4437
+ name: "name",
4438
+ type: "string"
4439
+ },
4440
+ {
4441
+ internalType: "string",
4442
+ name: "description",
4443
+ type: "string"
4444
+ },
4445
+ {
4446
+ internalType: "uint256",
4447
+ name: "price",
4448
+ type: "uint256"
4449
+ },
4450
+ {
4451
+ internalType: "address",
4452
+ name: "paymentToken",
4453
+ type: "address"
4454
+ },
4455
+ {
4456
+ internalType: "uint256",
4457
+ name: "durationDays",
4458
+ type: "uint256"
4459
+ },
4460
+ {
4461
+ internalType: "uint256",
4462
+ name: "maxSubscribers",
4463
+ type: "uint256"
4464
+ }
4465
+ ],
4466
+ name: "createPlan",
4467
+ outputs: [
4468
+ {
4469
+ internalType: "bytes32",
4470
+ name: "",
4471
+ type: "bytes32"
4472
+ }
4473
+ ],
4474
+ stateMutability: "nonpayable",
4475
+ type: "function"
4476
+ },
4477
+ {
4478
+ inputs: [
4479
+ {
4480
+ internalType: "address",
4481
+ name: "",
4482
+ type: "address"
4483
+ },
4484
+ {
4485
+ internalType: "uint256",
4486
+ name: "",
4487
+ type: "uint256"
4488
+ }
4489
+ ],
4490
+ name: "creatorPlans",
4491
+ outputs: [
4492
+ {
4493
+ internalType: "bytes32",
4494
+ name: "",
4495
+ type: "bytes32"
4496
+ }
4497
+ ],
4498
+ stateMutability: "view",
4499
+ type: "function"
4500
+ },
4501
+ {
4502
+ inputs: [
4503
+ {
4504
+ internalType: "address",
4505
+ name: "",
4506
+ type: "address"
4507
+ }
4508
+ ],
4509
+ name: "creators",
4510
+ outputs: [
4511
+ {
4512
+ internalType: "address",
4513
+ name: "payoutWallet",
4514
+ type: "address"
4515
+ },
4516
+ {
4517
+ internalType: "bool",
4518
+ name: "isActive",
4519
+ type: "bool"
4520
+ },
4521
+ {
4522
+ internalType: "uint256",
4523
+ name: "totalEarnings",
4524
+ type: "uint256"
4525
+ },
4526
+ {
4527
+ internalType: "uint256",
4528
+ name: "totalSubscribers",
4529
+ type: "uint256"
4530
+ }
4531
+ ],
4532
+ stateMutability: "view",
4533
+ type: "function"
4534
+ },
4535
+ {
4536
+ inputs: [
4537
+ {
4538
+ internalType: "address",
4539
+ name: "creatorAddress",
4540
+ type: "address"
4541
+ }
4542
+ ],
4543
+ name: "deactivateCreator",
4544
+ outputs: [],
4545
+ stateMutability: "nonpayable",
4546
+ type: "function"
4547
+ },
4548
+ {
4549
+ inputs: [
4550
+ {
4551
+ internalType: "bytes32",
4552
+ name: "planId",
4553
+ type: "bytes32"
4554
+ }
4555
+ ],
4556
+ name: "deactivatePlan",
4557
+ outputs: [],
4558
+ stateMutability: "nonpayable",
4559
+ type: "function"
4560
+ },
4561
+ {
4562
+ inputs: [
4563
+ {
4564
+ internalType: "address",
4565
+ name: "subscriber",
4566
+ type: "address"
4567
+ },
4568
+ {
4569
+ internalType: "address",
4570
+ name: "creatorAddress",
4571
+ type: "address"
4572
+ }
4573
+ ],
4574
+ name: "getActiveSubscriptionId",
4575
+ outputs: [
4576
+ {
4577
+ internalType: "bytes32",
4578
+ name: "",
4579
+ type: "bytes32"
4580
+ }
4581
+ ],
4582
+ stateMutability: "view",
4583
+ type: "function"
4584
+ },
4585
+ {
4586
+ inputs: [
4587
+ {
4588
+ internalType: "address",
4589
+ name: "creatorAddress",
4590
+ type: "address"
4591
+ }
4592
+ ],
4593
+ name: "getCreator",
4594
+ outputs: [
4595
+ {
4596
+ components: [
4597
+ {
4598
+ internalType: "address",
4599
+ name: "payoutWallet",
4600
+ type: "address"
4601
+ },
4602
+ {
4603
+ internalType: "bool",
4604
+ name: "isActive",
4605
+ type: "bool"
4606
+ },
4607
+ {
4608
+ internalType: "uint256",
4609
+ name: "totalEarnings",
4610
+ type: "uint256"
4611
+ },
4612
+ {
4613
+ internalType: "uint256",
4614
+ name: "totalSubscribers",
4615
+ type: "uint256"
4616
+ }
4617
+ ],
4618
+ internalType: "struct ZubariSubscriptionV2.Creator",
4619
+ name: "",
4620
+ type: "tuple"
4621
+ }
4622
+ ],
4623
+ stateMutability: "view",
4624
+ type: "function"
4625
+ },
4626
+ {
4627
+ inputs: [
4628
+ {
4629
+ internalType: "address",
4630
+ name: "creatorAddress",
4631
+ type: "address"
4632
+ }
4633
+ ],
4634
+ name: "getCreatorPlans",
4635
+ outputs: [
4636
+ {
4637
+ internalType: "bytes32[]",
4638
+ name: "",
4639
+ type: "bytes32[]"
4640
+ }
4641
+ ],
4642
+ stateMutability: "view",
4643
+ type: "function"
4644
+ },
4645
+ {
4646
+ inputs: [
4647
+ {
4648
+ internalType: "bytes32",
4649
+ name: "planId",
4650
+ type: "bytes32"
4651
+ }
4652
+ ],
4653
+ name: "getPlan",
4654
+ outputs: [
4655
+ {
4656
+ components: [
4657
+ {
4658
+ internalType: "bytes32",
4659
+ name: "planId",
4660
+ type: "bytes32"
4661
+ },
4662
+ {
4663
+ internalType: "address",
4664
+ name: "creator",
4665
+ type: "address"
4666
+ },
4667
+ {
4668
+ internalType: "string",
4669
+ name: "name",
4670
+ type: "string"
4671
+ },
4672
+ {
4673
+ internalType: "string",
4674
+ name: "description",
4675
+ type: "string"
4676
+ },
4677
+ {
4678
+ internalType: "uint256",
4679
+ name: "price",
4680
+ type: "uint256"
4681
+ },
4682
+ {
4683
+ internalType: "address",
4684
+ name: "paymentToken",
4685
+ type: "address"
4686
+ },
4687
+ {
4688
+ internalType: "uint256",
4689
+ name: "durationDays",
4690
+ type: "uint256"
4691
+ },
4692
+ {
4693
+ internalType: "uint256",
4694
+ name: "maxSubscribers",
4695
+ type: "uint256"
4696
+ },
4697
+ {
4698
+ internalType: "uint256",
4699
+ name: "subscriberCount",
4700
+ type: "uint256"
4701
+ },
4702
+ {
4703
+ internalType: "bool",
4704
+ name: "isActive",
4705
+ type: "bool"
4706
+ }
4707
+ ],
4708
+ internalType: "struct ZubariSubscriptionV2.SubscriptionPlan",
4709
+ name: "",
4710
+ type: "tuple"
4711
+ }
4712
+ ],
4713
+ stateMutability: "view",
4714
+ type: "function"
4715
+ },
4716
+ {
4717
+ inputs: [
4718
+ {
4719
+ internalType: "address",
4720
+ name: "subscriber",
4721
+ type: "address"
4722
+ }
4723
+ ],
4724
+ name: "getSubscriberSubscriptions",
4725
+ outputs: [
4726
+ {
4727
+ internalType: "bytes32[]",
4728
+ name: "",
4729
+ type: "bytes32[]"
4730
+ }
4731
+ ],
4732
+ stateMutability: "view",
4733
+ type: "function"
4734
+ },
4735
+ {
4736
+ inputs: [
4737
+ {
4738
+ internalType: "bytes32",
4739
+ name: "subscriptionId",
4740
+ type: "bytes32"
4741
+ }
4742
+ ],
4743
+ name: "getSubscription",
4744
+ outputs: [
4745
+ {
4746
+ components: [
4747
+ {
4748
+ internalType: "bytes32",
4749
+ name: "subscriptionId",
4750
+ type: "bytes32"
4751
+ },
4752
+ {
4753
+ internalType: "bytes32",
4754
+ name: "planId",
4755
+ type: "bytes32"
4756
+ },
4757
+ {
4758
+ internalType: "address",
4759
+ name: "creator",
4760
+ type: "address"
4761
+ },
4762
+ {
4763
+ internalType: "address",
4764
+ name: "subscriber",
4765
+ type: "address"
4766
+ },
4767
+ {
4768
+ internalType: "uint256",
4769
+ name: "startTime",
4770
+ type: "uint256"
4771
+ },
4772
+ {
4773
+ internalType: "uint256",
4774
+ name: "endTime",
4775
+ type: "uint256"
4776
+ },
4777
+ {
4778
+ internalType: "bool",
4779
+ name: "autoRenew",
4780
+ type: "bool"
4781
+ },
4782
+ {
4783
+ internalType: "enum ZubariSubscriptionV2.SubscriptionStatus",
4784
+ name: "status",
4785
+ type: "uint8"
4786
+ }
4787
+ ],
4788
+ internalType: "struct ZubariSubscriptionV2.Subscription",
4789
+ name: "",
4790
+ type: "tuple"
4791
+ }
4792
+ ],
4793
+ stateMutability: "view",
4794
+ type: "function"
4795
+ },
4796
+ {
4797
+ inputs: [
4798
+ {
4799
+ internalType: "address",
4800
+ name: "subscriber",
4801
+ type: "address"
4802
+ },
4803
+ {
4804
+ internalType: "address",
4805
+ name: "creatorAddress",
4806
+ type: "address"
4807
+ }
4808
+ ],
4809
+ name: "isSubscribed",
4810
+ outputs: [
4811
+ {
4812
+ internalType: "bool",
4813
+ name: "",
4814
+ type: "bool"
4815
+ }
4816
+ ],
4817
+ stateMutability: "view",
4818
+ type: "function"
4819
+ },
4820
+ {
4821
+ inputs: [],
4822
+ name: "owner",
4823
+ outputs: [
4824
+ {
4825
+ internalType: "address",
4826
+ name: "",
4827
+ type: "address"
4828
+ }
4829
+ ],
4830
+ stateMutability: "view",
4831
+ type: "function"
4832
+ },
4833
+ {
4834
+ inputs: [],
4835
+ name: "pause",
4836
+ outputs: [],
4837
+ stateMutability: "nonpayable",
4838
+ type: "function"
4839
+ },
4840
+ {
4841
+ inputs: [],
4842
+ name: "paused",
4843
+ outputs: [
4844
+ {
4845
+ internalType: "bool",
4846
+ name: "",
4847
+ type: "bool"
4848
+ }
4849
+ ],
4850
+ stateMutability: "view",
4851
+ type: "function"
4852
+ },
4853
+ {
4854
+ inputs: [],
4855
+ name: "payoutsContract",
4856
+ outputs: [
4857
+ {
4858
+ internalType: "address",
4859
+ name: "",
4860
+ type: "address"
4861
+ }
4862
+ ],
4863
+ stateMutability: "view",
4864
+ type: "function"
4865
+ },
4866
+ {
4867
+ inputs: [
4868
+ {
4869
+ internalType: "bytes32",
4870
+ name: "",
4871
+ type: "bytes32"
4872
+ }
4873
+ ],
4874
+ name: "plans",
4875
+ outputs: [
4876
+ {
4877
+ internalType: "bytes32",
4878
+ name: "planId",
4879
+ type: "bytes32"
4880
+ },
4881
+ {
4882
+ internalType: "address",
4883
+ name: "creator",
4884
+ type: "address"
4885
+ },
4886
+ {
4887
+ internalType: "string",
4888
+ name: "name",
4889
+ type: "string"
4890
+ },
4891
+ {
4892
+ internalType: "string",
4893
+ name: "description",
4894
+ type: "string"
4895
+ },
4896
+ {
4897
+ internalType: "uint256",
4898
+ name: "price",
4899
+ type: "uint256"
4900
+ },
4901
+ {
4902
+ internalType: "address",
4903
+ name: "paymentToken",
4904
+ type: "address"
4905
+ },
4906
+ {
4907
+ internalType: "uint256",
4908
+ name: "durationDays",
4909
+ type: "uint256"
4910
+ },
4911
+ {
4912
+ internalType: "uint256",
4913
+ name: "maxSubscribers",
4914
+ type: "uint256"
4915
+ },
4916
+ {
4917
+ internalType: "uint256",
4918
+ name: "subscriberCount",
4919
+ type: "uint256"
4920
+ },
4921
+ {
4922
+ internalType: "bool",
4923
+ name: "isActive",
4924
+ type: "bool"
4925
+ }
4926
+ ],
4927
+ stateMutability: "view",
4928
+ type: "function"
4929
+ },
4930
+ {
4931
+ inputs: [],
4932
+ name: "platformFeeBps",
4933
+ outputs: [
4934
+ {
4935
+ internalType: "uint256",
4936
+ name: "",
4937
+ type: "uint256"
4938
+ }
4939
+ ],
4940
+ stateMutability: "view",
4941
+ type: "function"
4942
+ },
4943
+ {
4944
+ inputs: [
4945
+ {
4946
+ internalType: "address",
4947
+ name: "payoutWallet",
4948
+ type: "address"
4949
+ }
4950
+ ],
4951
+ name: "registerCreator",
4952
+ outputs: [],
4953
+ stateMutability: "nonpayable",
4954
+ type: "function"
4955
+ },
4956
+ {
4957
+ inputs: [],
4958
+ name: "renounceOwnership",
4959
+ outputs: [],
4960
+ stateMutability: "nonpayable",
4961
+ type: "function"
4962
+ },
4963
+ {
4964
+ inputs: [
4965
+ {
4966
+ internalType: "bytes32",
4967
+ name: "subscriptionId",
4968
+ type: "bytes32"
4969
+ },
4970
+ {
4971
+ internalType: "bool",
4972
+ name: "autoRenew",
4973
+ type: "bool"
4974
+ }
4975
+ ],
4976
+ name: "setAutoRenew",
4977
+ outputs: [],
4978
+ stateMutability: "nonpayable",
4979
+ type: "function"
4980
+ },
4981
+ {
4982
+ inputs: [
4983
+ {
4984
+ internalType: "address",
4985
+ name: "_payoutsContract",
4986
+ type: "address"
4987
+ }
4988
+ ],
4989
+ name: "setPayoutsContract",
4990
+ outputs: [],
4991
+ stateMutability: "nonpayable",
4992
+ type: "function"
4993
+ },
4994
+ {
4995
+ inputs: [
4996
+ {
4997
+ internalType: "uint256",
4998
+ name: "_feeBps",
4999
+ type: "uint256"
5000
+ }
5001
+ ],
5002
+ name: "setPlatformFee",
5003
+ outputs: [],
5004
+ stateMutability: "nonpayable",
5005
+ type: "function"
5006
+ },
5007
+ {
5008
+ inputs: [
5009
+ {
5010
+ internalType: "address",
5011
+ name: "_treasury",
5012
+ type: "address"
5013
+ }
5014
+ ],
5015
+ name: "setTreasury",
5016
+ outputs: [],
5017
+ stateMutability: "nonpayable",
5018
+ type: "function"
5019
+ },
5020
+ {
5021
+ inputs: [
5022
+ {
5023
+ internalType: "bytes32",
5024
+ name: "planId",
5025
+ type: "bytes32"
5026
+ },
5027
+ {
5028
+ internalType: "uint256",
5029
+ name: "months",
5030
+ type: "uint256"
5031
+ }
5032
+ ],
5033
+ name: "subscribe",
5034
+ outputs: [
5035
+ {
5036
+ internalType: "bytes32",
5037
+ name: "",
5038
+ type: "bytes32"
5039
+ }
5040
+ ],
5041
+ stateMutability: "payable",
5042
+ type: "function"
5043
+ },
5044
+ {
5045
+ inputs: [
5046
+ {
5047
+ internalType: "address",
5048
+ name: "",
5049
+ type: "address"
5050
+ },
5051
+ {
5052
+ internalType: "uint256",
5053
+ name: "",
5054
+ type: "uint256"
5055
+ }
5056
+ ],
5057
+ name: "subscriberSubscriptions",
5058
+ outputs: [
5059
+ {
5060
+ internalType: "bytes32",
5061
+ name: "",
5062
+ type: "bytes32"
5063
+ }
5064
+ ],
5065
+ stateMutability: "view",
5066
+ type: "function"
5067
+ },
5068
+ {
5069
+ inputs: [
5070
+ {
5071
+ internalType: "bytes32",
5072
+ name: "",
5073
+ type: "bytes32"
5074
+ }
5075
+ ],
5076
+ name: "subscriptions",
5077
+ outputs: [
5078
+ {
5079
+ internalType: "bytes32",
5080
+ name: "subscriptionId",
5081
+ type: "bytes32"
5082
+ },
5083
+ {
5084
+ internalType: "bytes32",
5085
+ name: "planId",
5086
+ type: "bytes32"
5087
+ },
5088
+ {
5089
+ internalType: "address",
5090
+ name: "creator",
5091
+ type: "address"
5092
+ },
5093
+ {
5094
+ internalType: "address",
5095
+ name: "subscriber",
5096
+ type: "address"
5097
+ },
5098
+ {
5099
+ internalType: "uint256",
5100
+ name: "startTime",
5101
+ type: "uint256"
5102
+ },
5103
+ {
5104
+ internalType: "uint256",
5105
+ name: "endTime",
5106
+ type: "uint256"
5107
+ },
5108
+ {
5109
+ internalType: "bool",
5110
+ name: "autoRenew",
5111
+ type: "bool"
5112
+ },
5113
+ {
5114
+ internalType: "enum ZubariSubscriptionV2.SubscriptionStatus",
5115
+ name: "status",
5116
+ type: "uint8"
5117
+ }
5118
+ ],
5119
+ stateMutability: "view",
5120
+ type: "function"
5121
+ },
5122
+ {
5123
+ inputs: [
5124
+ {
5125
+ internalType: "address",
5126
+ name: "newOwner",
5127
+ type: "address"
5128
+ }
5129
+ ],
5130
+ name: "transferOwnership",
5131
+ outputs: [],
5132
+ stateMutability: "nonpayable",
5133
+ type: "function"
5134
+ },
5135
+ {
5136
+ inputs: [],
5137
+ name: "treasury",
5138
+ outputs: [
5139
+ {
5140
+ internalType: "address",
5141
+ name: "",
5142
+ type: "address"
5143
+ }
5144
+ ],
5145
+ stateMutability: "view",
5146
+ type: "function"
5147
+ },
5148
+ {
5149
+ inputs: [],
5150
+ name: "unpause",
5151
+ outputs: [],
5152
+ stateMutability: "nonpayable",
5153
+ type: "function"
5154
+ },
5155
+ {
5156
+ inputs: [
5157
+ {
5158
+ internalType: "address",
5159
+ name: "newWallet",
5160
+ type: "address"
5161
+ }
5162
+ ],
5163
+ name: "updatePayoutWallet",
5164
+ outputs: [],
5165
+ stateMutability: "nonpayable",
5166
+ type: "function"
5167
+ },
5168
+ {
5169
+ inputs: [
5170
+ {
5171
+ internalType: "bytes32",
5172
+ name: "planId",
5173
+ type: "bytes32"
5174
+ },
5175
+ {
5176
+ internalType: "uint256",
5177
+ name: "newPrice",
5178
+ type: "uint256"
5179
+ },
5180
+ {
5181
+ internalType: "uint256",
5182
+ name: "newDurationDays",
5183
+ type: "uint256"
5184
+ }
5185
+ ],
5186
+ name: "updatePlan",
5187
+ outputs: [],
5188
+ stateMutability: "nonpayable",
5189
+ type: "function"
5190
+ },
5191
+ {
5192
+ stateMutability: "payable",
5193
+ type: "receive"
5194
+ }
5195
+ ];
5196
+
5197
+ // src/protocols/SubscriptionV2Protocol.ts
5198
+ var ZubariSubscriptionV2Protocol = class {
5199
+ contractAddress;
5200
+ chainId;
5201
+ abi = ZubariSubscriptionV2_default;
5202
+ constructor(contractAddress, chainId) {
5203
+ this.contractAddress = contractAddress;
5204
+ this.chainId = chainId;
5205
+ }
5206
+ /**
5207
+ * Get the contract ABI
5208
+ */
5209
+ getAbi() {
5210
+ return this.abi;
5211
+ }
5212
+ /**
5213
+ * Get the contract address
5214
+ */
5215
+ getAddress() {
5216
+ return this.contractAddress;
5217
+ }
5218
+ // ===== CREATOR MANAGEMENT =====
5219
+ /**
5220
+ * Register as a creator with a payout wallet
5221
+ * @param payoutWallet The wallet that will receive payments (WDK wallet by default)
5222
+ * @param signer Wallet signer with sendTransaction method
5223
+ */
5224
+ async registerCreator(payoutWallet, signer) {
5225
+ if (!payoutWallet || payoutWallet === "0x0000000000000000000000000000000000000000") {
5226
+ throw new Error("Payout wallet address is required");
5227
+ }
5228
+ const iface = new (await import('ethers')).Interface(this.abi);
5229
+ const data = iface.encodeFunctionData("registerCreator", [payoutWallet]);
5230
+ const result = await signer.sendTransaction({
5231
+ to: this.contractAddress,
5232
+ value: 0n,
5233
+ data
5234
+ });
5235
+ return {
5236
+ hash: result.hash,
5237
+ network: "ethereum",
5238
+ status: "pending"
5239
+ };
5240
+ }
5241
+ /**
5242
+ * Prepare transaction data for creator registration (for frontend signing)
5243
+ * @param payoutWallet The wallet that will receive payments
5244
+ */
5245
+ async prepareRegisterCreator(payoutWallet) {
5246
+ if (!payoutWallet || payoutWallet === "0x0000000000000000000000000000000000000000") {
5247
+ throw new Error("Payout wallet address is required");
5248
+ }
5249
+ const iface = new (await import('ethers')).Interface(this.abi);
5250
+ const data = iface.encodeFunctionData("registerCreator", [payoutWallet]);
5251
+ return {
5252
+ to: this.contractAddress,
5253
+ data,
5254
+ value: "0"
5255
+ };
5256
+ }
5257
+ /**
5258
+ * Update the payout wallet address
5259
+ * @param newWallet New wallet address (can be WDK or MetaMask)
5260
+ * @param signer Wallet signer
5261
+ */
5262
+ async updatePayoutWallet(newWallet, signer) {
5263
+ if (!newWallet || newWallet === "0x0000000000000000000000000000000000000000") {
5264
+ throw new Error("New wallet address is required");
5265
+ }
5266
+ const iface = new (await import('ethers')).Interface(this.abi);
5267
+ const data = iface.encodeFunctionData("updatePayoutWallet", [newWallet]);
5268
+ const result = await signer.sendTransaction({
5269
+ to: this.contractAddress,
5270
+ value: 0n,
5271
+ data
5272
+ });
5273
+ return {
5274
+ hash: result.hash,
5275
+ network: "ethereum",
5276
+ status: "pending"
5277
+ };
5278
+ }
5279
+ /**
5280
+ * Get creator information
5281
+ * @param creatorAddress The creator's address
5282
+ * @param provider JSON-RPC provider
5283
+ */
5284
+ async getCreator(creatorAddress, provider) {
5285
+ const iface = new (await import('ethers')).Interface(this.abi);
5286
+ const data = iface.encodeFunctionData("getCreator", [creatorAddress]);
5287
+ try {
5288
+ const result = await provider.call({
5289
+ to: this.contractAddress,
5290
+ data
5291
+ });
5292
+ const decoded = iface.decodeFunctionResult("getCreator", result);
5293
+ const creator = decoded[0];
5294
+ if (!creator.isActive && creator.payoutWallet === "0x0000000000000000000000000000000000000000") {
5295
+ return null;
5296
+ }
5297
+ return {
5298
+ payoutWallet: creator.payoutWallet,
5299
+ isActive: creator.isActive,
5300
+ totalEarnings: creator.totalEarnings,
5301
+ totalSubscribers: Number(creator.totalSubscribers)
5302
+ };
5303
+ } catch {
5304
+ return null;
5305
+ }
5306
+ }
5307
+ /**
5308
+ * Check if an address is a registered creator
5309
+ * @param creatorAddress The address to check
5310
+ * @param provider JSON-RPC provider
5311
+ */
5312
+ async isRegisteredCreator(creatorAddress, provider) {
5313
+ const creator = await this.getCreator(creatorAddress, provider);
5314
+ return creator !== null && creator.isActive;
5315
+ }
5316
+ // ===== PLAN MANAGEMENT =====
5317
+ /**
5318
+ * Create a new subscription plan
5319
+ * @param plan The plan details
5320
+ * @param signer Wallet signer with sendTransaction method
5321
+ */
5322
+ async createPlan(plan, signer) {
5323
+ if (!plan.name || plan.name.length === 0) {
5324
+ throw new Error("Plan name is required");
5325
+ }
5326
+ if (plan.price <= 0n) {
5327
+ throw new Error("Plan price must be greater than 0");
5328
+ }
5329
+ if (plan.duration <= 0) {
5330
+ throw new Error("Plan duration must be greater than 0");
5331
+ }
5332
+ const iface = new (await import('ethers')).Interface(this.abi);
5333
+ const durationDays = Math.ceil(plan.duration / (24 * 60 * 60));
5334
+ const data = iface.encodeFunctionData("createPlan", [
5335
+ plan.name,
5336
+ plan.description || "",
5337
+ plan.price,
5338
+ plan.paymentToken || "0x0000000000000000000000000000000000000000",
5339
+ // ETH by default
5340
+ durationDays,
5341
+ plan.maxSubscribers || 0
5342
+ // 0 = unlimited
5343
+ ]);
5344
+ const result = await signer.sendTransaction({
5345
+ to: this.contractAddress,
5346
+ value: 0n,
5347
+ data
5348
+ });
5349
+ return result.hash;
5350
+ }
5351
+ /**
5352
+ * Update an existing plan's price and duration
5353
+ * @param planId The plan ID to update
5354
+ * @param newPrice New price (0 to keep current)
5355
+ * @param newDurationDays New duration in days (0 to keep current)
5356
+ * @param signer Wallet signer
5357
+ */
5358
+ async updatePlan(planId, newPrice, newDurationDays, signer) {
5359
+ const iface = new (await import('ethers')).Interface(this.abi);
5360
+ const data = iface.encodeFunctionData("updatePlan", [planId, newPrice, newDurationDays]);
5361
+ const result = await signer.sendTransaction({
5362
+ to: this.contractAddress,
5363
+ value: 0n,
5364
+ data
5365
+ });
5366
+ return {
5367
+ hash: result.hash,
5368
+ network: "ethereum",
5369
+ status: "pending"
5370
+ };
5371
+ }
5372
+ /**
5373
+ * Deactivate a subscription plan (only creator can do this)
5374
+ * @param planId The plan ID to deactivate
5375
+ * @param signer Wallet signer
5376
+ */
5377
+ async deactivatePlan(planId, signer) {
5378
+ const iface = new (await import('ethers')).Interface(this.abi);
5379
+ const data = iface.encodeFunctionData("deactivatePlan", [planId]);
5380
+ const result = await signer.sendTransaction({
5381
+ to: this.contractAddress,
5382
+ value: 0n,
5383
+ data
5384
+ });
5385
+ return {
5386
+ hash: result.hash,
5387
+ network: "ethereum",
5388
+ status: "pending"
5389
+ };
5390
+ }
5391
+ /**
5392
+ * Get a specific plan by ID
5393
+ * @param planId The plan ID
5394
+ * @param provider JSON-RPC provider
5395
+ */
5396
+ async getPlan(planId, provider) {
5397
+ const iface = new (await import('ethers')).Interface(this.abi);
5398
+ const data = iface.encodeFunctionData("getPlan", [planId]);
5399
+ try {
5400
+ const result = await provider.call({
5401
+ to: this.contractAddress,
5402
+ data
5403
+ });
5404
+ const decoded = iface.decodeFunctionResult("getPlan", result);
5405
+ const plan = decoded[0];
5406
+ if (plan.planId === "0x0000000000000000000000000000000000000000000000000000000000000000") {
5407
+ return null;
5408
+ }
5409
+ const durationSeconds = Number(plan.durationDays) * 24 * 60 * 60;
5410
+ return {
5411
+ planId: plan.planId,
5412
+ name: plan.name,
5413
+ description: plan.description,
5414
+ price: plan.price,
5415
+ paymentToken: plan.paymentToken,
5416
+ duration: durationSeconds,
5417
+ perks: [],
5418
+ // Not stored on-chain
5419
+ maxSubscribers: Number(plan.maxSubscribers),
5420
+ nftBadge: false
5421
+ // Not stored on-chain in this contract version
5422
+ };
5423
+ } catch {
5424
+ return null;
5425
+ }
5426
+ }
5427
+ /**
5428
+ * Get all plan IDs for a creator
5429
+ * @param creator The creator address
5430
+ * @param provider JSON-RPC provider
5431
+ */
5432
+ async getCreatorPlanIds(creator, provider) {
5433
+ const iface = new (await import('ethers')).Interface(this.abi);
5434
+ const data = iface.encodeFunctionData("getCreatorPlans", [creator]);
5435
+ try {
5436
+ const result = await provider.call({
5437
+ to: this.contractAddress,
5438
+ data
5439
+ });
5440
+ const decoded = iface.decodeFunctionResult("getCreatorPlans", result);
5441
+ return decoded[0];
5442
+ } catch {
5443
+ return [];
5444
+ }
5445
+ }
5446
+ /**
5447
+ * Get all plans for a creator with full details
5448
+ * @param creator The creator address
5449
+ * @param provider JSON-RPC provider
5450
+ */
5451
+ async getCreatorPlans(creator, provider) {
5452
+ const planIds = await this.getCreatorPlanIds(creator, provider);
5453
+ const plans = [];
5454
+ for (const planId of planIds) {
5455
+ const plan = await this.getPlan(planId, provider);
5456
+ if (plan && plan.planId) {
5457
+ plans.push(plan);
5458
+ }
5459
+ }
5460
+ return plans;
5461
+ }
5462
+ // ===== SUBSCRIPTION =====
5463
+ /**
5464
+ * Subscribe to a creator's plan
5465
+ * @param planId The plan ID to subscribe to
5466
+ * @param months Number of months to subscribe
5467
+ * @param signer Wallet signer
5468
+ * @param value ETH value to send (if paying with ETH)
5469
+ */
5470
+ async subscribe(planId, months, signer, value) {
5471
+ if (months <= 0) {
5472
+ throw new Error("Subscription duration must be at least 1 month");
5473
+ }
5474
+ const iface = new (await import('ethers')).Interface(this.abi);
5475
+ const data = iface.encodeFunctionData("subscribe", [planId, months]);
5476
+ const result = await signer.sendTransaction({
5477
+ to: this.contractAddress,
5478
+ value: value || 0n,
5479
+ data
5480
+ });
5481
+ return {
5482
+ hash: result.hash,
5483
+ network: "ethereum",
5484
+ status: "pending"
5485
+ };
5486
+ }
5487
+ /**
5488
+ * Prepare transaction data for subscription (for frontend signing)
5489
+ * @param planId The plan ID to subscribe to
5490
+ * @param months Number of months to subscribe
5491
+ * @param value ETH value in wei
5492
+ */
5493
+ async prepareSubscribe(planId, months, value) {
5494
+ if (months <= 0) {
5495
+ throw new Error("Subscription duration must be at least 1 month");
5496
+ }
5497
+ const iface = new (await import('ethers')).Interface(this.abi);
5498
+ const data = iface.encodeFunctionData("subscribe", [planId, months]);
5499
+ return {
5500
+ to: this.contractAddress,
5501
+ data,
5502
+ value: value.toString()
5503
+ };
5504
+ }
5505
+ /**
5506
+ * Cancel an active subscription
5507
+ * @param subscriptionId The subscription ID to cancel
5508
+ * @param signer Wallet signer
5509
+ */
5510
+ async cancel(subscriptionId, signer) {
5511
+ const iface = new (await import('ethers')).Interface(this.abi);
5512
+ const data = iface.encodeFunctionData("cancel", [subscriptionId]);
5513
+ const result = await signer.sendTransaction({
5514
+ to: this.contractAddress,
5515
+ value: 0n,
5516
+ data
5517
+ });
5518
+ return {
5519
+ hash: result.hash,
5520
+ network: "ethereum",
5521
+ status: "pending"
5522
+ };
5523
+ }
5524
+ /**
5525
+ * Set auto-renew for a subscription
5526
+ * @param subscriptionId The subscription ID
5527
+ * @param autoRenew Whether to enable auto-renew
5528
+ * @param signer Wallet signer
5529
+ */
5530
+ async setAutoRenew(subscriptionId, autoRenew, signer) {
5531
+ const iface = new (await import('ethers')).Interface(this.abi);
5532
+ const data = iface.encodeFunctionData("setAutoRenew", [subscriptionId, autoRenew]);
5533
+ const result = await signer.sendTransaction({
5534
+ to: this.contractAddress,
5535
+ value: 0n,
5536
+ data
5537
+ });
5538
+ return {
5539
+ hash: result.hash,
5540
+ network: "ethereum",
5541
+ status: "pending"
5542
+ };
5543
+ }
5544
+ /**
5545
+ * Check if an address is subscribed to a creator
5546
+ * @param subscriber The subscriber address
5547
+ * @param creator The creator address
5548
+ * @param provider JSON-RPC provider
5549
+ */
5550
+ async isSubscribed(subscriber, creator, provider) {
5551
+ const iface = new (await import('ethers')).Interface(this.abi);
5552
+ const data = iface.encodeFunctionData("isSubscribed", [subscriber, creator]);
5553
+ try {
5554
+ const result = await provider.call({
5555
+ to: this.contractAddress,
5556
+ data
5557
+ });
5558
+ const decoded = iface.decodeFunctionResult("isSubscribed", result);
5559
+ return decoded[0];
5560
+ } catch {
5561
+ return false;
5562
+ }
5563
+ }
5564
+ /**
5565
+ * Get the active subscription ID between subscriber and creator
5566
+ * @param subscriber The subscriber address
5567
+ * @param creator The creator address
5568
+ * @param provider JSON-RPC provider
5569
+ */
5570
+ async getActiveSubscriptionId(subscriber, creator, provider) {
5571
+ const iface = new (await import('ethers')).Interface(this.abi);
5572
+ const data = iface.encodeFunctionData("getActiveSubscriptionId", [subscriber, creator]);
5573
+ try {
5574
+ const result = await provider.call({
5575
+ to: this.contractAddress,
5576
+ data
5577
+ });
5578
+ const decoded = iface.decodeFunctionResult("getActiveSubscriptionId", result);
5579
+ const subscriptionId = decoded[0];
5580
+ if (subscriptionId === "0x0000000000000000000000000000000000000000000000000000000000000000") {
5581
+ return null;
5582
+ }
5583
+ return subscriptionId;
5584
+ } catch {
5585
+ return null;
5586
+ }
5587
+ }
5588
+ /**
5589
+ * Get subscription details by ID
5590
+ * @param subscriptionId The subscription ID
5591
+ * @param provider JSON-RPC provider
5592
+ */
5593
+ async getSubscription(subscriptionId, provider) {
5594
+ const iface = new (await import('ethers')).Interface(this.abi);
5595
+ const data = iface.encodeFunctionData("getSubscription", [subscriptionId]);
5596
+ try {
5597
+ const result = await provider.call({
5598
+ to: this.contractAddress,
5599
+ data
5600
+ });
5601
+ const decoded = iface.decodeFunctionResult("getSubscription", result);
5602
+ const sub = decoded[0];
5603
+ if (sub.subscriptionId === "0x0000000000000000000000000000000000000000000000000000000000000000") {
5604
+ return null;
5605
+ }
5606
+ let status;
5607
+ switch (Number(sub.status)) {
5608
+ case 0 /* Active */:
5609
+ status = "active";
5610
+ break;
5611
+ case 2 /* Cancelled */:
5612
+ status = "cancelled";
5613
+ break;
5614
+ case 1 /* Expired */:
5615
+ status = "expired";
5616
+ break;
5617
+ default:
5618
+ status = "active";
5619
+ }
5620
+ return {
5621
+ subscriptionId: sub.subscriptionId,
5622
+ planId: sub.planId,
5623
+ creator: sub.creator,
5624
+ subscriber: sub.subscriber,
5625
+ startTime: Number(sub.startTime),
5626
+ endTime: Number(sub.endTime),
5627
+ autoRenew: sub.autoRenew,
5628
+ status
5629
+ };
5630
+ } catch {
5631
+ return null;
5632
+ }
5633
+ }
5634
+ /**
5635
+ * Get all subscription IDs for a subscriber
5636
+ * @param subscriber The subscriber address
5637
+ * @param provider JSON-RPC provider
5638
+ */
5639
+ async getSubscriberSubscriptionIds(subscriber, provider) {
5640
+ const iface = new (await import('ethers')).Interface(this.abi);
5641
+ const data = iface.encodeFunctionData("getSubscriberSubscriptions", [subscriber]);
5642
+ try {
5643
+ const result = await provider.call({
5644
+ to: this.contractAddress,
5645
+ data
5646
+ });
5647
+ const decoded = iface.decodeFunctionResult("getSubscriberSubscriptions", result);
5648
+ return decoded[0];
5649
+ } catch {
5650
+ return [];
5651
+ }
5652
+ }
5653
+ // ===== FEE CALCULATION =====
5654
+ /**
5655
+ * Get platform fee in basis points
5656
+ * @param provider JSON-RPC provider
5657
+ */
5658
+ async getPlatformFeeBps(provider) {
5659
+ const iface = new (await import('ethers')).Interface(this.abi);
5660
+ const data = iface.encodeFunctionData("platformFeeBps", []);
5661
+ try {
5662
+ const result = await provider.call({
5663
+ to: this.contractAddress,
5664
+ data
5665
+ });
5666
+ const decoded = iface.decodeFunctionResult("platformFeeBps", result);
5667
+ return Number(decoded[0]);
5668
+ } catch {
5669
+ return 1e3;
5670
+ }
5671
+ }
5672
+ /**
5673
+ * Calculate the total cost for a subscription
5674
+ * @param planPrice The plan price per period
5675
+ * @param months Number of months
5676
+ */
5677
+ calculateSubscriptionCost(planPrice, months) {
5678
+ return planPrice * BigInt(months);
5679
+ }
5680
+ /**
5681
+ * Calculate platform fee for a given amount
5682
+ * @param amount The amount
5683
+ * @param feeBps Fee in basis points (default: 1000 = 10%)
5684
+ * Platform keeps 10%, Creator receives 90%
5685
+ */
5686
+ calculateFee(amount, feeBps = 1e3) {
5687
+ const fee = amount * BigInt(feeBps) / 10000n;
5688
+ return {
5689
+ fee,
5690
+ creatorAmount: amount - fee
5691
+ };
5692
+ }
5693
+ /**
5694
+ * Calculate fee using on-chain values
5695
+ * @param amount The amount
5696
+ * @param provider JSON-RPC provider
5697
+ */
5698
+ async calculateFeeOnChain(amount, provider) {
5699
+ const iface = new (await import('ethers')).Interface(this.abi);
5700
+ const data = iface.encodeFunctionData("calculateFee", [amount]);
5701
+ try {
5702
+ const result = await provider.call({
5703
+ to: this.contractAddress,
5704
+ data
5705
+ });
5706
+ const decoded = iface.decodeFunctionResult("calculateFee", result);
5707
+ return {
5708
+ fee: decoded[0],
5709
+ creatorAmount: decoded[1]
5710
+ };
5711
+ } catch {
5712
+ return this.calculateFee(amount);
5713
+ }
5714
+ }
5715
+ // ===== ADMIN (Read-Only) =====
5716
+ /**
5717
+ * Get treasury address
5718
+ * @param provider JSON-RPC provider
5719
+ */
5720
+ async getTreasury(provider) {
5721
+ const iface = new (await import('ethers')).Interface(this.abi);
5722
+ const data = iface.encodeFunctionData("treasury", []);
5723
+ try {
5724
+ const result = await provider.call({
5725
+ to: this.contractAddress,
5726
+ data
5727
+ });
5728
+ const decoded = iface.decodeFunctionResult("treasury", result);
5729
+ return decoded[0];
5730
+ } catch {
5731
+ return "";
5732
+ }
5733
+ }
5734
+ /**
5735
+ * Get payouts contract address
5736
+ * @param provider JSON-RPC provider
5737
+ */
5738
+ async getPayoutsContract(provider) {
5739
+ const iface = new (await import('ethers')).Interface(this.abi);
5740
+ const data = iface.encodeFunctionData("payoutsContract", []);
5741
+ try {
5742
+ const result = await provider.call({
5743
+ to: this.contractAddress,
5744
+ data
5745
+ });
5746
+ const decoded = iface.decodeFunctionResult("payoutsContract", result);
5747
+ return decoded[0];
5748
+ } catch {
5749
+ return "";
5750
+ }
5751
+ }
5752
+ };
5753
+
3926
5754
  // src/protocols/PayoutsProtocol.ts
3927
5755
  var PAYOUTS_SELECTORS = {
3928
5756
  getEarningsBreakdown: "0xd4e9329c",
@@ -4275,6 +6103,6 @@ var ZubariPayoutsProtocol = class {
4275
6103
  }
4276
6104
  };
4277
6105
 
4278
- export { ZubariMarketProtocol, ZubariNFTProtocol, ZubariPayoutsProtocol, ZubariSubscriptionProtocol, ZubariTipsProtocol };
6106
+ export { ZubariMarketProtocol, ZubariNFTProtocol, ZubariPayoutsProtocol, ZubariSubscriptionProtocol, ZubariSubscriptionV2Protocol, ZubariTipsProtocol };
4279
6107
  //# sourceMappingURL=index.mjs.map
4280
6108
  //# sourceMappingURL=index.mjs.map