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

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,7 +1,7 @@
1
- import { Hex, IAttestation, JSONStr, MultiAttestData, SignerOrProvider } from "../types";
2
- import { Schema } from "./Schema";
3
- import { SchemaItem, SchemaValue } from "@ethereum-attestation-service/eas-sdk";
4
- import { GapSchema } from "./GapSchema";
1
+ import { Hex, IAttestation, JSONStr, MultiAttestData, SignerOrProvider } from '../types';
2
+ import { Schema } from './Schema';
3
+ import { SchemaItem, SchemaValue } from '@ethereum-attestation-service/eas-sdk';
4
+ import { GapSchema } from './GapSchema';
5
5
  export interface AttestationArgs<T = unknown, S extends Schema = Schema> {
6
6
  data: T | string;
7
7
  schema: S;
@@ -48,7 +48,7 @@ class Attestation {
48
48
  this.recipient = args.recipient;
49
49
  this.revoked = args.revoked;
50
50
  this.revocationTime = (0, get_date_1.getDate)(args.revocationTime);
51
- this.createdAt = (0, get_date_1.getDate)(args.createdAt || Date.now());
51
+ this.createdAt = (0, get_date_1.getDate)(args.createdAt || Date.now() / 1000);
52
52
  }
53
53
  /**
54
54
  * Encodes the schema.
@@ -70,7 +70,7 @@ class Attestation {
70
70
  setValues(values) {
71
71
  const isJsonSchema = this.schema.isJsonSchema();
72
72
  if (isJsonSchema)
73
- this.schema.setValue("json", JSON.stringify(values));
73
+ this.schema.setValue('json', JSON.stringify(values));
74
74
  this._data = values;
75
75
  Object.entries(values).forEach(([key, value]) => {
76
76
  this[key] = value;
@@ -90,7 +90,7 @@ class Attestation {
90
90
  * @returns
91
91
  */
92
92
  fromDecodedSchema(data) {
93
- return typeof data === "string"
93
+ return typeof data === 'string'
94
94
  ? Attestation.fromDecodedSchema(data)
95
95
  : data;
96
96
  }
@@ -116,7 +116,7 @@ class Attestation {
116
116
  }
117
117
  catch (error) {
118
118
  console.error(error);
119
- throw new SchemaError_1.SchemaError("REVOKE_ERROR", "Error revoking attestation.");
119
+ throw new SchemaError_1.SchemaError('REVOKE_ERROR', 'Error revoking attestation.');
120
120
  }
121
121
  }
122
122
  /**
@@ -140,7 +140,7 @@ class Attestation {
140
140
  }
141
141
  catch (error) {
142
142
  console.error(error);
143
- throw new SchemaError_1.AttestationError("ATTEST_ERROR", "Error during attestation.");
143
+ throw new SchemaError_1.AttestationError('ATTEST_ERROR', 'Error during attestation.');
144
144
  }
145
145
  }
146
146
  /**
@@ -218,17 +218,17 @@ class Attestation {
218
218
  const parsed = JSON.parse(data);
219
219
  if (data.length < 2 && !/\{.*\}/gim.test(data))
220
220
  return {};
221
- if (parsed.length === 1 && parsed[0].name === "json") {
221
+ if (parsed.length === 1 && parsed[0].name === 'json') {
222
222
  const { value } = parsed[0];
223
- return (typeof value.value === "string"
223
+ return (typeof value.value === 'string'
224
224
  ? JSON.parse(value.value)
225
225
  : value.value);
226
226
  }
227
227
  if (parsed && Array.isArray(parsed)) {
228
228
  return parsed.reduce((acc, curr) => {
229
229
  const { value } = curr.value;
230
- if (curr.type.includes("uint")) {
231
- acc[curr.name] = ["string", "bigint"].includes(typeof value)
230
+ if (curr.type.includes('uint')) {
231
+ acc[curr.name] = ['string', 'bigint'].includes(typeof value)
232
232
  ? BigInt(value)
233
233
  : Number(value);
234
234
  }
@@ -237,11 +237,11 @@ class Attestation {
237
237
  return acc;
238
238
  }, {});
239
239
  }
240
- throw new SchemaError_1.SchemaError("INVALID_DATA", "Data must be a valid JSON array string.");
240
+ throw new SchemaError_1.SchemaError('INVALID_DATA', 'Data must be a valid JSON array string.');
241
241
  }
242
242
  catch (error) {
243
243
  console.error(error);
244
- throw new SchemaError_1.SchemaError("INVALID_DATA", "Data must be a valid JSON string.");
244
+ throw new SchemaError_1.SchemaError('INVALID_DATA', 'Data must be a valid JSON string.');
245
245
  }
246
246
  }
247
247
  /**
@@ -272,10 +272,10 @@ class Attestation {
272
272
  assert(args, strict = false) {
273
273
  const { schema, uid } = args;
274
274
  if (!schema || !(schema instanceof Schema_1.Schema)) {
275
- throw new SchemaError_1.SchemaError("MISSING_FIELD", "Schema must be an array.");
275
+ throw new SchemaError_1.SchemaError('MISSING_FIELD', 'Schema must be an array.');
276
276
  }
277
277
  if (!uid) {
278
- throw new SchemaError_1.SchemaError("MISSING_FIELD", "Schema uid is required");
278
+ throw new SchemaError_1.SchemaError('MISSING_FIELD', 'Schema uid is required');
279
279
  }
280
280
  if (strict)
281
281
  Schema_1.Schema.validate();
@@ -303,7 +303,7 @@ class Attestation {
303
303
  recipient: to,
304
304
  attester: from,
305
305
  schema,
306
- uid: "0x0",
306
+ uid: '0x0',
307
307
  createdAt: new Date(),
308
308
  });
309
309
  }
@@ -10,10 +10,6 @@ class CommunityDetails extends Attestation_1.Attestation {
10
10
  }
11
11
  exports.CommunityDetails = CommunityDetails;
12
12
  class GrantDetails extends Attestation_1.Attestation {
13
- constructor() {
14
- super(...arguments);
15
- this.amount = '0';
16
- }
17
13
  }
18
14
  exports.GrantDetails = GrantDetails;
19
15
  class GrantRound extends Attestation_1.Attestation {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.1.32",
6
+ "version": "0.1.34",
7
7
  "description": "Simple and easy interface between EAS and Karma GAP.",
8
8
  "main": "dist/index.js",
9
9
  "author": "KarmaHQ",