@show-karma/karma-gap-sdk 0.1.30 → 0.1.32

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.
@@ -1,6 +1,6 @@
1
- import { SignerOrProvider } from "../../types";
2
- import { Attestation } from "../Attestation";
3
- import { MilestoneCompleted } from "../types/attestations";
1
+ import { SignerOrProvider } from '../../types';
2
+ import { Attestation } from '../Attestation';
3
+ import { MilestoneCompleted } from '../types/attestations';
4
4
  interface _Milestone extends Milestone {
5
5
  }
6
6
  export interface IMilestone {
@@ -13,16 +13,16 @@ class Milestone extends Attestation_1.Attestation {
13
13
  * @param signer
14
14
  * @param reason
15
15
  */
16
- async approve(signer, reason = "") {
16
+ async approve(signer, reason = '') {
17
17
  if (!this.completed)
18
- throw new SchemaError_1.AttestationError("ATTEST_ERROR", "Milestone is not completed");
19
- const schema = GapSchema_1.GapSchema.find("MilestoneCompleted");
20
- schema.setValue("type", "approved");
21
- schema.setValue("reason", reason);
18
+ throw new SchemaError_1.AttestationError('ATTEST_ERROR', 'Milestone is not completed');
19
+ const schema = GapSchema_1.GapSchema.find('MilestoneCompleted');
20
+ schema.setValue('type', 'approved');
21
+ schema.setValue('reason', reason);
22
22
  await this.attestStatus(signer, schema);
23
23
  this.approved = new attestations_1.MilestoneCompleted({
24
24
  data: {
25
- type: "approved",
25
+ type: 'approved',
26
26
  reason,
27
27
  },
28
28
  refUID: this.uid,
@@ -37,8 +37,13 @@ class Milestone extends Attestation_1.Attestation {
37
37
  */
38
38
  async revokeApproval(signer) {
39
39
  if (!this.approved)
40
- throw new SchemaError_1.AttestationError("ATTEST_ERROR", "Milestone is not approved");
41
- await this.approved.revoke(signer);
40
+ throw new SchemaError_1.AttestationError('ATTEST_ERROR', 'Milestone is not approved');
41
+ await this.approved.schema.multiRevoke(signer, [
42
+ {
43
+ schemaId: this.completed.schema.uid,
44
+ uid: this.completed.uid,
45
+ },
46
+ ]);
42
47
  }
43
48
  /**
44
49
  * Reject a completed milestone. If the milestone is not completed or already rejected,
@@ -46,16 +51,16 @@ class Milestone extends Attestation_1.Attestation {
46
51
  * @param signer
47
52
  * @param reason
48
53
  */
49
- async reject(signer, reason = "") {
54
+ async reject(signer, reason = '') {
50
55
  if (!this.completed)
51
- throw new SchemaError_1.AttestationError("ATTEST_ERROR", "Milestone is not completed");
52
- const schema = GapSchema_1.GapSchema.find("MilestoneCompleted");
53
- schema.setValue("type", "rejected");
54
- schema.setValue("reason", reason);
56
+ throw new SchemaError_1.AttestationError('ATTEST_ERROR', 'Milestone is not completed');
57
+ const schema = GapSchema_1.GapSchema.find('MilestoneCompleted');
58
+ schema.setValue('type', 'rejected');
59
+ schema.setValue('reason', reason);
55
60
  await this.attestStatus(signer, schema);
56
61
  this.rejected = new attestations_1.MilestoneCompleted({
57
62
  data: {
58
- type: "rejected",
63
+ type: 'rejected',
59
64
  reason,
60
65
  },
61
66
  refUID: this.uid,
@@ -70,8 +75,13 @@ class Milestone extends Attestation_1.Attestation {
70
75
  */
71
76
  async revokeRejection(signer) {
72
77
  if (!this.rejected)
73
- throw new SchemaError_1.AttestationError("ATTEST_ERROR", "Milestone is not rejected");
74
- await this.rejected.revoke(signer);
78
+ throw new SchemaError_1.AttestationError('ATTEST_ERROR', 'Milestone is not rejected');
79
+ await this.rejected.schema.multiRevoke(signer, [
80
+ {
81
+ schemaId: this.completed.schema.uid,
82
+ uid: this.completed.uid,
83
+ },
84
+ ]);
75
85
  }
76
86
  /**
77
87
  * Marks a milestone as completed. If the milestone is already completed,
@@ -79,14 +89,14 @@ class Milestone extends Attestation_1.Attestation {
79
89
  * @param signer
80
90
  * @param reason
81
91
  */
82
- async complete(signer, reason = "") {
83
- const schema = GapSchema_1.GapSchema.find("MilestoneCompleted");
84
- schema.setValue("type", "completed");
85
- schema.setValue("reason", reason);
92
+ async complete(signer, reason = '') {
93
+ const schema = GapSchema_1.GapSchema.find('MilestoneCompleted');
94
+ schema.setValue('type', 'completed');
95
+ schema.setValue('reason', reason);
86
96
  await this.attestStatus(signer, schema);
87
97
  this.completed = new attestations_1.MilestoneCompleted({
88
98
  data: {
89
- type: "completed",
99
+ type: 'completed',
90
100
  reason,
91
101
  },
92
102
  refUID: this.uid,
@@ -101,8 +111,13 @@ class Milestone extends Attestation_1.Attestation {
101
111
  */
102
112
  async revokeCompletion(signer) {
103
113
  if (!this.completed)
104
- throw new SchemaError_1.AttestationError("ATTEST_ERROR", "Milestone is not completed");
105
- await this.completed.revoke(signer);
114
+ throw new SchemaError_1.AttestationError('ATTEST_ERROR', 'Milestone is not completed');
115
+ await this.completed.schema.multiRevoke(signer, [
116
+ {
117
+ schemaId: this.completed.schema.uid,
118
+ uid: this.completed.uid,
119
+ },
120
+ ]);
106
121
  }
107
122
  /**
108
123
  * Attest the status of the milestone as approved, rejected or completed.
@@ -125,7 +140,7 @@ class Milestone extends Attestation_1.Attestation {
125
140
  }
126
141
  catch (error) {
127
142
  console.error(error);
128
- throw new SchemaError_1.AttestationError("ATTEST_ERROR", error.message);
143
+ throw new SchemaError_1.AttestationError('ATTEST_ERROR', error.message);
129
144
  }
130
145
  }
131
146
  static from(attestations) {
@@ -135,7 +150,7 @@ class Milestone extends Attestation_1.Attestation {
135
150
  data: {
136
151
  ...attestation.data,
137
152
  },
138
- schema: GapSchema_1.GapSchema.find("Milestone"),
153
+ schema: GapSchema_1.GapSchema.find('Milestone'),
139
154
  });
140
155
  if (attestation.completed) {
141
156
  milestone.completed = new attestations_1.MilestoneCompleted({
@@ -143,7 +158,7 @@ class Milestone extends Attestation_1.Attestation {
143
158
  data: {
144
159
  ...attestation.completed.data,
145
160
  },
146
- schema: GapSchema_1.GapSchema.find("MilestoneCompleted"),
161
+ schema: GapSchema_1.GapSchema.find('MilestoneCompleted'),
147
162
  });
148
163
  }
149
164
  if (attestation.approved) {
@@ -152,7 +167,7 @@ class Milestone extends Attestation_1.Attestation {
152
167
  data: {
153
168
  ...attestation.completed.data,
154
169
  },
155
- schema: GapSchema_1.GapSchema.find("MilestoneCompleted"),
170
+ schema: GapSchema_1.GapSchema.find('MilestoneCompleted'),
156
171
  });
157
172
  }
158
173
  if (attestation.rejected) {
@@ -161,7 +176,7 @@ class Milestone extends Attestation_1.Attestation {
161
176
  data: {
162
177
  ...attestation.completed.data,
163
178
  },
164
- schema: GapSchema_1.GapSchema.find("MilestoneCompleted"),
179
+ schema: GapSchema_1.GapSchema.find('MilestoneCompleted'),
165
180
  });
166
181
  }
167
182
  return milestone;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.1.30",
6
+ "version": "0.1.32",
7
7
  "description": "Simple and easy interface between EAS and Karma GAP.",
8
8
  "main": "dist/index.js",
9
9
  "author": "KarmaHQ",
package/readme.md CHANGED
@@ -102,7 +102,7 @@ The `apiClient` option is employed when you wish to use a Custom API. The SDK pr
102
102
 
103
103
  ```ts
104
104
  // MyCustomApiClient.ts
105
- import { Fetcher } from 'karma-gap-sdk/core/class/Fetcher';
105
+ import { Fetcher } from '@show-karma/karma-gap-sdk/core/class/Fetcher';
106
106
 
107
107
  export class MyCustomApiClient extends Fetcher {
108
108
  // ... implement all Fetcher methods following its return types and arguments.
@@ -657,7 +657,7 @@ export default handler;
657
657
 
658
658
  > Please note that `NEXT_GELATO_API_KEY` is not an actual API key but the name of the environment variable to retrieve from `process.env`. This setup will not expose the API key in the frontend. Your `.env` file should contain a field like `NEXT_GELATO_API_KEY=abcdefg123`. For more details, refer to [sponsor-handler.ts L63](https://github.com/show-karma/karma-gap-sdk/blob/f2f3f863c8b2b475ca74bd76bb9290a075c12f60/core/utils/gelato/sponsor-handler.ts#L63).
659
659
 
660
- ## After placing the API page, set `gelatoOpts.sponsorUrl: '/api/sponsored-txn'`, and all transactions will be routed through the Gelato Relay network.
660
+ After placing the API page, set `gelatoOpts.sponsorUrl: '/api/sponsored-txn'`, and all transactions will be routed through the Gelato Relay network.
661
661
 
662
662
  ### External API
663
663
 
@@ -666,7 +666,7 @@ When using an external API to facilitate gasless transactions, you'll need to cr
666
666
  ```ts
667
667
  // gelato/sponsor-handler.ts
668
668
  import { GelatoRelay } from '@gelatonetwork/relay-sdk';
669
- import { Gelato } from 'karma-gap-sdk/core/utils/gelato/';
669
+ import { Gelato } from '@show-karma/karma-gap-sdk/core/utils/gelato/';
670
670
  // Exception Handler available under your development.
671
671
  import { HttpException } from '../error/HttpException';
672
672
 
@@ -784,7 +784,7 @@ You can review the Fetcher interface in [this file](https://github.com/show-karm
784
784
 
785
785
  ```ts
786
786
  // my-fetcher.ts
787
- import { Fetcher } from 'karma-gap-sdk/core/class/Fetcher.ts';
787
+ import { Fetcher } from '@show-karma/karma-gap-sdk/core/class/Fetcher.ts';
788
788
  import { Attestation } from '@show-karma/karma-gap-sdk';
789
789
 
790
790
  const Endpoints = {