@show-karma/karma-gap-sdk 0.1.31 → 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
|
|
2
|
-
import { Attestation } from
|
|
3
|
-
import { MilestoneCompleted } from
|
|
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(
|
|
19
|
-
const schema = GapSchema_1.GapSchema.find(
|
|
20
|
-
schema.setValue(
|
|
21
|
-
schema.setValue(
|
|
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:
|
|
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(
|
|
41
|
-
await this.approved.
|
|
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(
|
|
52
|
-
const schema = GapSchema_1.GapSchema.find(
|
|
53
|
-
schema.setValue(
|
|
54
|
-
schema.setValue(
|
|
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:
|
|
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(
|
|
74
|
-
await this.rejected.
|
|
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(
|
|
84
|
-
schema.setValue(
|
|
85
|
-
schema.setValue(
|
|
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:
|
|
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(
|
|
105
|
-
await this.completed.
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
179
|
+
schema: GapSchema_1.GapSchema.find('MilestoneCompleted'),
|
|
165
180
|
});
|
|
166
181
|
}
|
|
167
182
|
return milestone;
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -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
|
-
|
|
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
|
|