@show-karma/karma-gap-sdk 0.3.45 → 0.3.46

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.
package/core/class/GAP.js CHANGED
@@ -81,15 +81,21 @@ class GAP extends types_1.Facade {
81
81
  this.generateSlug = async (text) => {
82
82
  let slug = text
83
83
  .toLowerCase()
84
+ // Remove emojis
85
+ .replace(/([\uE000-\uF8FF]|\uD83C[\uDF00-\uDFFF]|\uD83D[\uDC00-\uDDFF])/g, '')
86
+ // Remove basic text emoticons
87
+ .replace(/[:;=][()DP]/g, '')
84
88
  .replace(/ /g, "-")
85
- .replace(/[^\w-]+/g, "");
89
+ .replace(/[^\w-]+/g, "")
90
+ .trim()
91
+ .replace(/^-+|-+$/g, ''); // Remove leading and trailing hyphens
86
92
  const checkSlug = async (currentSlug, counter = 0) => {
87
93
  const slugToCheck = counter === 0 ? currentSlug : `${currentSlug}-${counter}`;
88
94
  const slugExists = await this.fetch.slugExists(slugToCheck);
89
95
  if (slugExists) {
90
96
  return checkSlug(currentSlug, counter + 1);
91
97
  }
92
- return slugToCheck;
98
+ return slugToCheck.toLowerCase();
93
99
  };
94
100
  return checkSlug(slug);
95
101
  };
@@ -0,0 +1,39 @@
1
+ import { Attestation, AttestationArgs } from "../Attestation";
2
+ import { AttestationWithTx } from "../types/attestations";
3
+ import { GapSchema } from "../GapSchema";
4
+ import { MultiAttestPayload, SignerOrProvider, TNetwork } from "core/types";
5
+ export interface IContributorProfile {
6
+ name: string;
7
+ aboutMe?: string;
8
+ github?: string;
9
+ twitter?: string;
10
+ linkdin?: number;
11
+ }
12
+ export declare class ContributorProfile extends Attestation<IContributorProfile> implements IContributorProfile {
13
+ name: string;
14
+ aboutMe?: string;
15
+ github?: string;
16
+ twitter?: string;
17
+ linkdin?: number;
18
+ constructor(data: AttestationArgs<IContributorProfile, GapSchema>);
19
+ /**
20
+ * Creates the payload for a multi-attestation.
21
+ *
22
+ * > if Current payload is set, it'll be used as the base payload
23
+ * and the project should refer to an index of the current payload,
24
+ * usually the community position.
25
+ *
26
+ * @param payload
27
+ * @param refIdx
28
+ */
29
+ multiAttestPayload(): Promise<MultiAttestPayload>;
30
+ /**
31
+ * Attest a community with its details.
32
+ *
33
+ * If the community exists, it will not be revoked but its details will be updated.
34
+ * @param signer
35
+ * @param details
36
+ */
37
+ attest(signer: SignerOrProvider, callback?: Function): Promise<AttestationWithTx>;
38
+ static from(attestation: ContributorProfile, network: TNetwork): ContributorProfile;
39
+ }
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ContributorProfile = void 0;
4
+ const Attestation_1 = require("../Attestation");
5
+ const consts_1 = require("../../consts");
6
+ const SchemaError_1 = require("../SchemaError");
7
+ const AllGapSchemas_1 = require("../AllGapSchemas");
8
+ class ContributorProfile extends Attestation_1.Attestation {
9
+ constructor(data) {
10
+ data.data.type = "contributor-profile";
11
+ super(data);
12
+ }
13
+ /**
14
+ * Creates the payload for a multi-attestation.
15
+ *
16
+ * > if Current payload is set, it'll be used as the base payload
17
+ * and the project should refer to an index of the current payload,
18
+ * usually the community position.
19
+ *
20
+ * @param payload
21
+ * @param refIdx
22
+ */
23
+ async multiAttestPayload() {
24
+ const payload = [[this, await this.payloadFor(0)]];
25
+ return payload;
26
+ }
27
+ /**
28
+ * Attest a community with its details.
29
+ *
30
+ * If the community exists, it will not be revoked but its details will be updated.
31
+ * @param signer
32
+ * @param details
33
+ */
34
+ async attest(signer, callback) {
35
+ console.log("Attesting ContributorProfile");
36
+ try {
37
+ if (callback)
38
+ callback("preparing");
39
+ const { tx: ContributorProfileTx, uids: ContributorProfileUID } = await this.schema.attest({
40
+ signer,
41
+ to: this.recipient,
42
+ refUID: consts_1.nullRef,
43
+ data: this.data,
44
+ });
45
+ this._uid = ContributorProfileUID[0];
46
+ console.log(this.uid);
47
+ if (callback)
48
+ callback("pending");
49
+ if (callback)
50
+ callback("confirmed");
51
+ return { tx: ContributorProfileTx, uids: ContributorProfileUID };
52
+ }
53
+ catch (error) {
54
+ console.error(error);
55
+ throw new SchemaError_1.AttestationError("ATTEST_ERROR", "Error during attestation.", error);
56
+ }
57
+ }
58
+ static from(attestation, network) {
59
+ return new ContributorProfile({
60
+ ...attestation,
61
+ data: {
62
+ ...attestation.data,
63
+ },
64
+ schema: new AllGapSchemas_1.AllGapSchemas().findSchema("ContributorProfile", consts_1.chainIdToNetwork[attestation.chainID]),
65
+ chainID: attestation.chainID,
66
+ });
67
+ }
68
+ }
69
+ exports.ContributorProfile = ContributorProfile;
@@ -10,6 +10,7 @@ export interface IMilestone {
10
10
  endsAt: number;
11
11
  description: string;
12
12
  type?: string;
13
+ priority?: number;
13
14
  }
14
15
  export declare class Milestone extends Attestation<IMilestone> implements IMilestone {
15
16
  title: string;
@@ -21,6 +22,7 @@ export declare class Milestone extends Attestation<IMilestone> implements IMiles
21
22
  rejected: MilestoneCompleted;
22
23
  verified: MilestoneCompleted[];
23
24
  type: string;
25
+ priority?: number;
24
26
  /**
25
27
  * Approves this milestone. If the milestone is not completed or already approved,
26
28
  * it will throw an error.
@@ -0,0 +1,37 @@
1
+ import { Attestation, AttestationArgs } from "../Attestation";
2
+ import { AttestationWithTx } from "../types/attestations";
3
+ import { GapSchema } from "../GapSchema";
4
+ import { MultiAttestPayload, SignerOrProvider, TNetwork } from "core/types";
5
+ export interface IUserSummary {
6
+ aboutMe: string;
7
+ github?: string;
8
+ twitter?: string;
9
+ linkdin?: number;
10
+ }
11
+ export declare class UserSummary extends Attestation<IUserSummary> implements IUserSummary {
12
+ aboutMe: string;
13
+ github?: string;
14
+ twitter?: string;
15
+ linkdin?: number;
16
+ constructor(data: AttestationArgs<IUserSummary, GapSchema>);
17
+ /**
18
+ * Creates the payload for a multi-attestation.
19
+ *
20
+ * > if Current payload is set, it'll be used as the base payload
21
+ * and the project should refer to an index of the current payload,
22
+ * usually the community position.
23
+ *
24
+ * @param payload
25
+ * @param refIdx
26
+ */
27
+ multiAttestPayload(): Promise<MultiAttestPayload>;
28
+ /**
29
+ * Attest a community with its details.
30
+ *
31
+ * If the community exists, it will not be revoked but its details will be updated.
32
+ * @param signer
33
+ * @param details
34
+ */
35
+ attest(signer: SignerOrProvider, callback?: Function): Promise<AttestationWithTx>;
36
+ static from(attestation: UserSummary, network: TNetwork): UserSummary;
37
+ }
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserSummary = void 0;
4
+ const Attestation_1 = require("../Attestation");
5
+ const consts_1 = require("../../consts");
6
+ const SchemaError_1 = require("../SchemaError");
7
+ const AllGapSchemas_1 = require("../AllGapSchemas");
8
+ class UserSummary extends Attestation_1.Attestation {
9
+ constructor(data) {
10
+ data.data.type = "user-summary";
11
+ super(data);
12
+ }
13
+ /**
14
+ * Creates the payload for a multi-attestation.
15
+ *
16
+ * > if Current payload is set, it'll be used as the base payload
17
+ * and the project should refer to an index of the current payload,
18
+ * usually the community position.
19
+ *
20
+ * @param payload
21
+ * @param refIdx
22
+ */
23
+ async multiAttestPayload() {
24
+ const payload = [[this, await this.payloadFor(0)]];
25
+ return payload;
26
+ }
27
+ /**
28
+ * Attest a community with its details.
29
+ *
30
+ * If the community exists, it will not be revoked but its details will be updated.
31
+ * @param signer
32
+ * @param details
33
+ */
34
+ async attest(signer, callback) {
35
+ console.log("Attesting UserSummary");
36
+ try {
37
+ if (callback)
38
+ callback("preparing");
39
+ const { tx: UserSummaryTx, uids: UserSummaryUID } = await this.schema.attest({
40
+ signer,
41
+ to: this.recipient,
42
+ refUID: consts_1.nullRef,
43
+ data: this.data,
44
+ });
45
+ this._uid = UserSummaryUID[0];
46
+ console.log(this.uid);
47
+ if (callback)
48
+ callback("pending");
49
+ if (callback)
50
+ callback("confirmed");
51
+ return { tx: UserSummaryTx, uids: UserSummaryUID };
52
+ }
53
+ catch (error) {
54
+ console.error(error);
55
+ throw new SchemaError_1.AttestationError("ATTEST_ERROR", "Error during attestation.", error);
56
+ }
57
+ }
58
+ static from(attestation, network) {
59
+ return new UserSummary({
60
+ ...attestation,
61
+ data: {
62
+ ...attestation.data,
63
+ },
64
+ schema: new AllGapSchemas_1.AllGapSchemas().findSchema("UserSummary", consts_1.chainIdToNetwork[attestation.chainID]),
65
+ chainID: attestation.chainID,
66
+ });
67
+ }
68
+ }
69
+ exports.UserSummary = UserSummary;
@@ -51,6 +51,7 @@ export interface IMilestoneResponse extends IAttestationResponse {
51
51
  endsAt: number;
52
52
  startsAt?: number;
53
53
  type: "milestone";
54
+ priority?: number;
54
55
  };
55
56
  }
56
57
  export interface IGrantUpdateStatus extends IAttestationResponse {
@@ -126,6 +127,7 @@ export interface IGrantDetails extends IAttestationResponse {
126
127
  startDate: number;
127
128
  programId?: string;
128
129
  type: "grant-details";
130
+ fundUsage?: string;
129
131
  };
130
132
  }
131
133
  export interface IGrantResponse extends IAttestationResponse {
@@ -44,6 +44,7 @@ export interface IGrantDetails {
44
44
  type?: string;
45
45
  startDate?: number;
46
46
  programId?: string;
47
+ fundUsage?: string;
47
48
  }
48
49
  export declare class GrantDetails extends Attestation<IGrantDetails> implements IGrantDetails {
49
50
  title: string;
@@ -58,6 +59,7 @@ export declare class GrantDetails extends Attestation<IGrantDetails> implements
58
59
  questions?: IGrantDetailsQuestion[];
59
60
  type: string;
60
61
  startDate?: number;
62
+ fundUsage?: string;
61
63
  }
62
64
  export interface IGrantRound {
63
65
  name: string;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.3.45",
6
+ "version": "0.3.46",
7
7
  "description": "Simple and easy interface between EAS and Karma GAP.",
8
8
  "main": "./index.js",
9
9
  "author": "KarmaHQ",