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