@coasys/ad4m 0.12.0 → 0.13.0-test-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -78,6 +78,15 @@ export class RuntimeClient {
78
78
  return runtimeInfo
79
79
  }
80
80
 
81
+ async tlsDomain(): Promise<string | null> {
82
+ const { runtimeTlsDomain } = unwrapApolloResult(await this.#apolloClient.query({
83
+ query: gql`query runtimeTlsDomain {
84
+ runtimeTlsDomain
85
+ }`,
86
+ }));
87
+ return runtimeTlsDomain
88
+ }
89
+
81
90
  async quit(): Promise<Boolean> {
82
91
  const result = unwrapApolloResult(await this.#apolloClient.mutate({
83
92
  mutation: gql`mutation runtimeQuit { runtimeQuit }`
@@ -405,6 +414,25 @@ export class RuntimeClient {
405
414
  return runtimeSetMultiUserEnabled
406
415
  }
407
416
 
417
+ async freeHostingEnabled(): Promise<boolean> {
418
+ const { runtimeFreeHostingEnabled } = unwrapApolloResult(await this.#apolloClient.query({
419
+ query: gql`query runtimeFreeHostingEnabled {
420
+ runtimeFreeHostingEnabled
421
+ }`
422
+ }))
423
+ return runtimeFreeHostingEnabled
424
+ }
425
+
426
+ async setFreeHostingEnabled(enabled: boolean): Promise<boolean> {
427
+ const { runtimeSetFreeHostingEnabled } = unwrapApolloResult(await this.#apolloClient.mutate({
428
+ mutation: gql`mutation runtimeSetFreeHostingEnabled($enabled: Boolean!) {
429
+ runtimeSetFreeHostingEnabled(enabled: $enabled)
430
+ }`,
431
+ variables: { enabled }
432
+ }))
433
+ return runtimeSetFreeHostingEnabled
434
+ }
435
+
408
436
  async listUsers(): Promise<UserStatistics[]> {
409
437
  const { runtimeListUsers } = unwrapApolloResult(await this.#apolloClient.query({
410
438
  query: gql`query runtimeListUsers {
@@ -413,12 +441,25 @@ export class RuntimeClient {
413
441
  did
414
442
  lastSeen
415
443
  perspectiveCount
444
+ remainingCredits
445
+ freeAccess
446
+ hotWalletAddress
416
447
  }
417
448
  }`
418
449
  }))
419
450
  return runtimeListUsers
420
451
  }
421
452
 
453
+ async userWalletAddress(email: string): Promise<string | null> {
454
+ const { runtimeUserWalletAddress } = unwrapApolloResult(await this.#apolloClient.query({
455
+ query: gql`query runtimeUserWalletAddress($email: String!) {
456
+ runtimeUserWalletAddress(email: $email)
457
+ }`,
458
+ variables: { email }
459
+ }))
460
+ return runtimeUserWalletAddress
461
+ }
462
+
422
463
  async emailTestModeEnable(): Promise<boolean> {
423
464
  const { runtimeEmailTestModeEnable } = unwrapApolloResult(await this.#apolloClient.mutate({
424
465
  mutation: gql`mutation runtimeEmailTestModeEnable {
@@ -466,6 +507,124 @@ export class RuntimeClient {
466
507
  return runtimeEmailTestSetExpiry
467
508
  }
468
509
 
510
+ // ---- Unyt / mHOT methods ----
511
+
512
+ async unytAgentKey(): Promise<string> {
513
+ const { runtimeUnytAgentKey } = unwrapApolloResult(await this.#apolloClient.query({
514
+ query: gql`query runtimeUnytAgentKey { runtimeUnytAgentKey }`,
515
+ fetchPolicy: "network-only",
516
+ }))
517
+ return runtimeUnytAgentKey
518
+ }
519
+
520
+ async unytHotAgentPubkey(): Promise<string> {
521
+ const { runtimeHotAgentPubkey } = unwrapApolloResult(await this.#apolloClient.query({
522
+ query: gql`query runtimeHotAgentPubkey { runtimeHotAgentPubkey }`,
523
+ fetchPolicy: "network-only",
524
+ }))
525
+ return runtimeHotAgentPubkey
526
+ }
527
+
528
+ async unytWalletBalance(): Promise<string> {
529
+ const { runtimeHotWalletBalance } = unwrapApolloResult(await this.#apolloClient.query({
530
+ query: gql`query runtimeHotWalletBalance { runtimeHotWalletBalance }`,
531
+ fetchPolicy: "network-only",
532
+ }))
533
+ return runtimeHotWalletBalance
534
+ }
535
+
536
+ async unytWalletHistory(page?: number, perPage?: number): Promise<string> {
537
+ const { runtimeHotWalletHistory } = unwrapApolloResult(await this.#apolloClient.query({
538
+ query: gql`query runtimeHotWalletHistory($page: Int, $perPage: Int) {
539
+ runtimeHotWalletHistory(page: $page, perPage: $perPage)
540
+ }`,
541
+ variables: { page, perPage },
542
+ fetchPolicy: "network-only",
543
+ }))
544
+ return runtimeHotWalletHistory
545
+ }
546
+
547
+ async unytVersionInfo(): Promise<string> {
548
+ const { runtimeUnytVersionInfo } = unwrapApolloResult(await this.#apolloClient.query({
549
+ query: gql`query runtimeUnytVersionInfo { runtimeUnytVersionInfo }`,
550
+ fetchPolicy: "network-only",
551
+ }))
552
+ return runtimeUnytVersionInfo
553
+ }
554
+
555
+ async unytSetMembraneProof(proof: string): Promise<{ success: boolean; message: string }> {
556
+ const { runtimeSetUnytMembraneProof } = unwrapApolloResult(await this.#apolloClient.mutate({
557
+ mutation: gql`mutation runtimeSetUnytMembraneProof($proof: String!) {
558
+ runtimeSetUnytMembraneProof(proof: $proof) { success message }
559
+ }`,
560
+ variables: { proof },
561
+ }))
562
+ return runtimeSetUnytMembraneProof
563
+ }
564
+
565
+ async unytReinstallDna(): Promise<{ success: boolean; message: string }> {
566
+ const { runtimeReinstallUnytDna } = unwrapApolloResult(await this.#apolloClient.mutate({
567
+ mutation: gql`mutation runtimeReinstallUnytDna {
568
+ runtimeReinstallUnytDna { success message }
569
+ }`,
570
+ }))
571
+ return runtimeReinstallUnytDna
572
+ }
573
+
574
+ async unytSendHot(recipient: string, amount: string): Promise<{ success: boolean; message: string }> {
575
+ const { runtimeSendHot } = unwrapApolloResult(await this.#apolloClient.mutate({
576
+ mutation: gql`mutation runtimeSendHot($recipient: String!, $amount: String!) {
577
+ runtimeSendHot(recipient: $recipient, amount: $amount) { success message }
578
+ }`,
579
+ variables: { recipient, amount },
580
+ }))
581
+ return runtimeSendHot
582
+ }
583
+
584
+ async setUserCredits(email: string, amount: number): Promise<boolean> {
585
+ const { runtimeSetUserCredits } = unwrapApolloResult(await this.#apolloClient.mutate({
586
+ mutation: gql`mutation runtimeSetUserCredits($email: String!, $amount: Float!) {
587
+ runtimeSetUserCredits(email: $email, amount: $amount)
588
+ }`,
589
+ variables: { email, amount },
590
+ }))
591
+ return runtimeSetUserCredits
592
+ }
593
+
594
+ async setUserFreeAccess(email: string, enabled: boolean): Promise<boolean> {
595
+ const { runtimeSetUserFreeAccess } = unwrapApolloResult(await this.#apolloClient.mutate({
596
+ mutation: gql`mutation runtimeSetUserFreeAccess($email: String!, $enabled: Boolean!) {
597
+ runtimeSetUserFreeAccess(email: $email, enabled: $enabled)
598
+ }`,
599
+ variables: { email, enabled },
600
+ }))
601
+ return runtimeSetUserFreeAccess
602
+ }
603
+
604
+ async setHostRates(ratesJson: string): Promise<boolean> {
605
+ const { runtimeSetHostRates } = unwrapApolloResult(await this.#apolloClient.mutate({
606
+ mutation: gql`mutation runtimeSetHostRates($ratesJson: String!) {
607
+ runtimeSetHostRates(ratesJson: $ratesJson)
608
+ }`,
609
+ variables: { ratesJson },
610
+ }))
611
+ return runtimeSetHostRates
612
+ }
613
+
614
+ async getHostRates(): Promise<{ description: string; priceInHOT: number }[]> {
615
+ const { runtimeHostRates } = unwrapApolloResult(await this.#apolloClient.query({
616
+ query: gql`query runtimeHostRates {
617
+ runtimeHostRates
618
+ }`,
619
+ fetchPolicy: 'network-only',
620
+ }))
621
+ try {
622
+ return JSON.parse(runtimeHostRates)
623
+ } catch {
624
+ return []
625
+ }
626
+ }
627
+
469
628
  addNotificationTriggeredCallback(cb: NotificationTriggeredCallback) {
470
629
  this.#notificationTriggeredCallbacks.push(cb)
471
630
  }
@@ -206,6 +206,15 @@ export class UserStatistics {
206
206
 
207
207
  @Field(type => Int)
208
208
  perspectiveCount: number;
209
+
210
+ @Field()
211
+ remainingCredits: string;
212
+
213
+ @Field()
214
+ freeAccess: boolean;
215
+
216
+ @Field({nullable: true})
217
+ hotWalletAddress?: string;
209
218
  }
210
219
 
211
220
  @ObjectType()
@@ -234,10 +243,14 @@ export class HostingUserInfo {
234
243
  @Field({ nullable: true })
235
244
  hotWalletAddress?: string;
236
245
 
237
- constructor(email: string, remainingCredits: string, hotWalletAddress?: string) {
246
+ @Field()
247
+ freeAccess: boolean;
248
+
249
+ constructor(email: string, remainingCredits: string, hotWalletAddress?: string, freeAccess: boolean = false) {
238
250
  this.email = email;
239
251
  this.remainingCredits = remainingCredits;
240
252
  this.hotWalletAddress = hotWalletAddress;
253
+ this.freeAccess = freeAccess;
241
254
  }
242
255
  }
243
256
 
@@ -500,13 +513,25 @@ export default class RuntimeResolver {
500
513
  return enabled
501
514
  }
502
515
 
516
+ @Query(returns => Boolean)
517
+ runtimeFreeHostingEnabled(): boolean {
518
+ return true
519
+ }
520
+
521
+ @Mutation(returns => Boolean)
522
+ runtimeSetFreeHostingEnabled(@Arg("enabled") enabled: boolean): boolean {
523
+ return enabled
524
+ }
525
+
503
526
  @Query(returns => [UserStatistics])
504
527
  runtimeListUsers(): UserStatistics[] {
505
528
  return [{
506
529
  email: "test@example.com",
507
530
  did: "did:key:test123",
508
531
  lastSeen: new Date().toISOString(),
509
- perspectiveCount: 5
532
+ perspectiveCount: 5,
533
+ remainingCredits: "0",
534
+ freeAccess: false
510
535
  }]
511
536
  }
512
537
 
@@ -597,7 +622,7 @@ export default class RuntimeResolver {
597
622
 
598
623
  @Query(returns => HostingUserInfo)
599
624
  runtimeHostingUserInfo(): HostingUserInfo {
600
- return new HostingUserInfo("test@example.com", "100000000", null)
625
+ return new HostingUserInfo("test@example.com", "100000000", null, false)
601
626
  }
602
627
 
603
628
  @Mutation(returns => Boolean)
@@ -613,5 +638,69 @@ export default class RuntimeResolver {
613
638
  ): PaymentRequestResult {
614
639
  return new PaymentRequestResult(true, "Mock payment of " + amountHOT + " base units credited")
615
640
  }
641
+
642
+ @Mutation(returns => Boolean)
643
+ runtimeSetUserCredits(
644
+ @Arg("email") email: string,
645
+ @Arg("amount") amount: number
646
+ ): boolean {
647
+ return true
648
+ }
649
+
650
+ @Mutation(returns => Boolean)
651
+ runtimeSetUserFreeAccess(
652
+ @Arg("email") email: string,
653
+ @Arg("enabled") enabled: boolean
654
+ ): boolean {
655
+ return true
656
+ }
657
+
658
+ @Mutation(returns => PaymentRequestResult)
659
+ runtimeReinstallUnytDna(): PaymentRequestResult {
660
+ return new PaymentRequestResult(true, "")
661
+ }
662
+
663
+ @Mutation(returns => PaymentRequestResult)
664
+ runtimeSendHot(
665
+ @Arg("recipient") recipient: string,
666
+ @Arg("amount") amount: string
667
+ ): PaymentRequestResult {
668
+ return new PaymentRequestResult(true, "")
669
+ }
670
+
671
+ @Mutation(returns => PaymentRequestResult)
672
+ runtimeSetUnytMembraneProof(
673
+ @Arg("proof") proof: string
674
+ ): PaymentRequestResult {
675
+ return new PaymentRequestResult(true, "")
676
+ }
677
+
678
+ @Query(returns => String)
679
+ runtimeHotWalletBalance(): string {
680
+ return ""
681
+ }
682
+
683
+ @Query(returns => String)
684
+ runtimeHotWalletHistory(
685
+ @Arg("page", { nullable: true }) page?: number,
686
+ @Arg("perPage", { nullable: true }) perPage?: number
687
+ ): string {
688
+ return ""
689
+ }
690
+
691
+ @Query(returns => String)
692
+ runtimeHotAgentPubkey(): string {
693
+ return ""
694
+ }
695
+
696
+ @Query(returns => String)
697
+ runtimeUnytAgentKey(): string {
698
+ return ""
699
+ }
700
+
701
+ @Query(returns => String)
702
+ runtimeUnytVersionInfo(): string {
703
+ return ""
704
+ }
616
705
  }
617
706