@show-karma/karma-gap-sdk 0.1.40 → 0.2.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.
@@ -134,10 +134,10 @@ export declare class Attestation<T = unknown, S extends Schema = GapSchema> impl
134
134
  * @param refIdx
135
135
  * @returns [Encoded payload, Raw payload]
136
136
  */
137
- payloadFor(refIdx: number): {
137
+ payloadFor(refIdx: number): Promise<{
138
138
  payload: MultiAttestData;
139
139
  raw: MultiAttestData;
140
- };
140
+ }>;
141
141
  /**
142
142
  * Returns an Attestation instance from a JSON decoded schema.
143
143
  * @param data
@@ -4,6 +4,7 @@ exports.Attestation = void 0;
4
4
  const Schema_1 = require("./Schema");
5
5
  const SchemaError_1 = require("./SchemaError");
6
6
  const get_date_1 = require("../utils/get-date");
7
+ const GAP_1 = require("./GAP");
7
8
  const consts_1 = require("../consts");
8
9
  const GapContract_1 = require("./contract/GapContract");
9
10
  /**
@@ -184,8 +185,16 @@ class Attestation {
184
185
  * @param refIdx
185
186
  * @returns [Encoded payload, Raw payload]
186
187
  */
187
- payloadFor(refIdx) {
188
+ async payloadFor(refIdx) {
188
189
  this.assertPayload();
190
+ if (this.schema.isJsonSchema()) {
191
+ const ipfsManager = GAP_1.GAP.ipfs;
192
+ if (ipfsManager) {
193
+ const ipfsHash = await ipfsManager.save(this._data);
194
+ const encodedData = ipfsManager.encode(ipfsHash, 0);
195
+ this.schema.setValue("json", JSON.stringify(encodedData));
196
+ }
197
+ }
189
198
  const payload = (encode = true) => ({
190
199
  uid: consts_1.nullRef,
191
200
  refIdx,
@@ -0,0 +1,7 @@
1
+ import { IPFS } from './IPFS/IPFS';
2
+ export declare class AttestationIPFS extends IPFS {
3
+ encode(data: string, storageType: number): {
4
+ ipfsHash: string;
5
+ type: number;
6
+ };
7
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AttestationIPFS = void 0;
4
+ const IPFS_1 = require("./IPFS/IPFS");
5
+ class AttestationIPFS extends IPFS_1.IPFS {
6
+ encode(data, storageType) {
7
+ return { ipfsHash: data, type: storageType };
8
+ }
9
+ }
10
+ exports.AttestationIPFS = AttestationIPFS;
@@ -2,6 +2,7 @@ import { AttestArgs, Facade, SchemaInterface, TNetwork, TSchemaName, SignerOrPro
2
2
  import { GapSchema } from "./GapSchema";
3
3
  import { ethers } from "ethers";
4
4
  import { Fetcher } from "./Fetcher";
5
+ import { AttestationIPFS } from "./AttestationIPFS";
5
6
  interface GAPArgs {
6
7
  network: TNetwork;
7
8
  globalSchemas?: boolean;
@@ -88,6 +89,17 @@ interface GAPArgs {
88
89
  */
89
90
  useGasless?: boolean;
90
91
  };
92
+ /**
93
+ * Specifies an optional IPFS key for uploading project details and other related data.
94
+ *
95
+ * This key is used to authenticate with the IPFS storage service, specifically designed for use with "NFT.STORAGE".
96
+ * Utilizing IPFS (InterPlanetary File System) offers a decentralized solution for storing data, ensuring better
97
+ * scalability and efficiency compared to sending large amounts of data directly in the attestation body.
98
+ *
99
+ * If an IPFS key is not provided, the default storage method will be used.
100
+ *
101
+ */
102
+ ipfsKey?: string;
91
103
  }
92
104
  /**
93
105
  * GAP SDK Facade.
@@ -146,12 +158,14 @@ interface GAPArgs {
146
158
  */
147
159
  export declare class GAP extends Facade {
148
160
  private static client;
161
+ private static ipfsManager;
149
162
  readonly fetch: Fetcher;
150
163
  readonly network: TNetwork;
151
164
  private _schemas;
152
165
  private static _gelatoOpts;
153
166
  constructor(args: GAPArgs);
154
- private assert;
167
+ private assertGelatoOpts;
168
+ private assertIPFSOpts;
155
169
  /**
156
170
  * Creates the attestation payload using a specific schema.
157
171
  * @param from
@@ -208,5 +222,6 @@ export declare class GAP extends Facade {
208
222
  */
209
223
  static get gelatoOpts(): GAPArgs["gelatoOpts"];
210
224
  static set useGasLess(useGasLess: boolean);
225
+ static get ipfs(): AttestationIPFS;
211
226
  }
212
227
  export {};
package/core/class/GAP.js CHANGED
@@ -13,6 +13,7 @@ const consts_1 = require("../consts");
13
13
  const ethers_1 = require("ethers");
14
14
  const MultiAttester_json_1 = __importDefault(require("../abi/MultiAttester.json"));
15
15
  const package_json_1 = require("../../package.json");
16
+ const AttestationIPFS_1 = require("./AttestationIPFS");
16
17
  /**
17
18
  * GAP SDK Facade.
18
19
  *
@@ -97,13 +98,16 @@ class GAP extends types_1.Facade {
97
98
  this.network = args.network;
98
99
  GAP._eas = new eas_sdk_1.EAS(consts_1.Networks[args.network].contracts.eas);
99
100
  this.fetch = args.apiClient || new GapEasClient_1.GapEasClient({ network: args.network });
100
- this.assert(args);
101
+ this.assertGelatoOpts(args);
101
102
  GAP._gelatoOpts = args.gelatoOpts;
103
+ if (this.assertIPFSOpts(args)) {
104
+ GAP.ipfsManager = new AttestationIPFS_1.AttestationIPFS(args.ipfsKey);
105
+ }
102
106
  this._schemas = schemas.map((schema) => new GapSchema_1.GapSchema(schema, false, args.globalSchemas ? !args.globalSchemas : false));
103
107
  Schema_1.Schema.validate();
104
108
  console.info(`Loaded GAP SDK v${package_json_1.version}`);
105
109
  }
106
- assert(args) {
110
+ assertGelatoOpts(args) {
107
111
  if (args.gelatoOpts &&
108
112
  !(args.gelatoOpts.sponsorUrl || args.gelatoOpts.apiKey)) {
109
113
  throw new Error("You must provide a `sponsorUrl` or an `apiKey`.");
@@ -120,6 +124,12 @@ class GAP extends types_1.Facade {
120
124
  console.warn("GAP::You are using gelatoOpts but not setting useGasless to true. This will send transactions through the normal provider.");
121
125
  }
122
126
  }
127
+ assertIPFSOpts(args) {
128
+ if (!args.ipfsKey) {
129
+ return false;
130
+ }
131
+ return true;
132
+ }
123
133
  /**
124
134
  * Creates the attestation payload using a specific schema.
125
135
  * @param from
@@ -201,6 +211,9 @@ class GAP extends types_1.Facade {
201
211
  }
202
212
  this._gelatoOpts.useGasless = useGasLess;
203
213
  }
214
+ static get ipfs() {
215
+ return this.ipfsManager;
216
+ }
204
217
  }
205
218
  exports.GAP = GAP;
206
219
  GAP._gelatoOpts = null;
@@ -0,0 +1,13 @@
1
+ import { NFTStorage } from "nft.storage";
2
+ export declare abstract class IPFS {
3
+ protected client: NFTStorage;
4
+ constructor(ipfsKey: string);
5
+ /**
6
+ * Insert the data in the IPFS and return the cid.
7
+ */
8
+ save<T = unknown>(data: T): Promise<string>;
9
+ /**
10
+ * Encode Attestation data using IPFS cid
11
+ */
12
+ protected abstract encode(data: string, storageType: number): any;
13
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IPFS = void 0;
4
+ const nft_storage_1 = require("nft.storage");
5
+ const SchemaError_1 = require("../SchemaError");
6
+ class IPFS {
7
+ constructor(ipfsKey) {
8
+ this.client = new nft_storage_1.NFTStorage({ token: ipfsKey });
9
+ }
10
+ /**
11
+ * Insert the data in the IPFS and return the cid.
12
+ */
13
+ async save(data) {
14
+ try {
15
+ const blob = new nft_storage_1.Blob([JSON.stringify(data)], { type: 'application/json' });
16
+ const cid = await this.client.storeBlob(blob);
17
+ return cid;
18
+ }
19
+ catch (error) {
20
+ throw new SchemaError_1.AttestationError('IPFS_UPLOAD', `Error adding data to IPFS`);
21
+ }
22
+ }
23
+ }
24
+ exports.IPFS = IPFS;
@@ -125,9 +125,18 @@ export declare abstract class Schema<T extends string = string> implements Schem
125
125
  */
126
126
  multiRevokeOffchain(uids: Hex[], signer: SignerOrProvider): Promise<import("@ethereum-attestation-service/eas-sdk/dist/transaction").Transaction<bigint[]>>;
127
127
  /**
128
- * Attest for a schema.
129
- * @param param0
130
- * @returns
128
+ * Validates and attests a given schema.
129
+ *
130
+ * This function checks a schema against predefined standards or rules. If the 'ipfsKey' parameter is enabled,
131
+ * it uploads the data to the IPFS (InterPlanetary File System). Upon successful upload, the function
132
+ * returns the CID (Content Identifier) within the Attestation Body, providing a reference to the data on IPFS.
133
+ *
134
+ * Usage:
135
+ * - Ensure that the schema to be attested conforms to the required format.
136
+ * - Enable 'ipfsKey' if you wish to store the data on IPFS and retrieve its CID.
137
+ *
138
+ * @param {Object} param0 - An object containing the schema and other optional settings.
139
+ * @returns {Object} An object containing the attestation results, including the CID if 'ipfsKey' is enabled.
131
140
  */
132
141
  attest<T>({ data, to, signer, refUID }: AttestArgs<T>): Promise<Hex>;
133
142
  /**
@@ -205,15 +205,30 @@ class Schema {
205
205
  return eas.multiRevokeOffchain(uids);
206
206
  }
207
207
  /**
208
- * Attest for a schema.
209
- * @param param0
210
- * @returns
208
+ * Validates and attests a given schema.
209
+ *
210
+ * This function checks a schema against predefined standards or rules. If the 'ipfsKey' parameter is enabled,
211
+ * it uploads the data to the IPFS (InterPlanetary File System). Upon successful upload, the function
212
+ * returns the CID (Content Identifier) within the Attestation Body, providing a reference to the data on IPFS.
213
+ *
214
+ * Usage:
215
+ * - Ensure that the schema to be attested conforms to the required format.
216
+ * - Enable 'ipfsKey' if you wish to store the data on IPFS and retrieve its CID.
217
+ *
218
+ * @param {Object} param0 - An object containing the schema and other optional settings.
219
+ * @returns {Object} An object containing the attestation results, including the CID if 'ipfsKey' is enabled.
211
220
  */
212
221
  async attest({ data, to, signer, refUID }) {
213
222
  const eas = GAP_1.GAP.eas.connect(signer);
214
223
  if (this.references && !refUID)
215
224
  throw new SchemaError_1.AttestationError("INVALID_REFERENCE", "Attestation schema references another schema but no reference UID was provided.");
216
225
  if (this.isJsonSchema()) {
226
+ const ipfsManager = GAP_1.GAP.ipfs;
227
+ if (ipfsManager) {
228
+ const ipfsHash = await ipfsManager.save(data);
229
+ const encodedData = ipfsManager.encode(ipfsHash, 0);
230
+ data = encodedData;
231
+ }
217
232
  this.setValue("json", JSON.stringify(data));
218
233
  }
219
234
  else {
@@ -14,6 +14,7 @@ declare const SchemaErrorCodes: {
14
14
  INVALID_REF_UID: number;
15
15
  REVOKATION_ERROR: number;
16
16
  NOT_REVOCABLE: number;
17
+ IPFS_UPLOAD: number;
17
18
  };
18
19
  export declare class SchemaError extends Error {
19
20
  readonly code: number;
@@ -17,6 +17,7 @@ const SchemaErrorCodes = {
17
17
  INVALID_REF_UID: 50013,
18
18
  REVOKATION_ERROR: 50014,
19
19
  NOT_REVOCABLE: 50015,
20
+ IPFS_UPLOAD: 50016,
20
21
  };
21
22
  class SchemaError extends Error {
22
23
  constructor(code, append) {
@@ -22,7 +22,7 @@ export declare class Community extends Attestation<ICommunity> {
22
22
  * @param payload
23
23
  * @param refIdx
24
24
  */
25
- multiAttestPayload(): MultiAttestPayload;
25
+ multiAttestPayload(): Promise<MultiAttestPayload>;
26
26
  /**
27
27
  * Attest a community with its details.
28
28
  *
@@ -23,15 +23,13 @@ class Community extends Attestation_1.Attestation {
23
23
  * @param payload
24
24
  * @param refIdx
25
25
  */
26
- multiAttestPayload() {
27
- const payload = [[this, this.payloadFor(0)]];
26
+ async multiAttestPayload() {
27
+ const payload = [[this, await this.payloadFor(0)]];
28
28
  if (this.details) {
29
- payload.push([this.details, this.details.payloadFor(0)]);
29
+ payload.push([this.details, await this.details.payloadFor(0)]);
30
30
  }
31
31
  if (this.projects?.length) {
32
- this.projects.forEach((p) => {
33
- payload.push(...p.multiAttestPayload(payload, 0));
34
- });
32
+ await Promise.all(this.projects.map(async (p) => payload.push(...(await p.multiAttestPayload(payload, 0)))));
35
33
  }
36
34
  return payload;
37
35
  }
@@ -42,7 +42,7 @@ export declare class Grant extends Attestation<IGrant> {
42
42
  * @param payload
43
43
  * @param projectIdx
44
44
  */
45
- multiAttestPayload(currentPayload?: MultiAttestPayload, projectIdx?: number): [Attestation<unknown, GapSchema>, import("core/types").RawMultiAttestPayload][];
45
+ multiAttestPayload(currentPayload?: MultiAttestPayload, projectIdx?: number): Promise<[Attestation<unknown, GapSchema>, import("core/types").RawMultiAttestPayload][]>;
46
46
  /**
47
47
  * @inheritdoc
48
48
  */
@@ -10,7 +10,6 @@ const SchemaError_1 = require("../SchemaError");
10
10
  const consts_1 = require("../../consts");
11
11
  const GapContract_1 = require("../contract/GapContract");
12
12
  const Community_1 = require("./Community");
13
- const Project_1 = require("./Project");
14
13
  class Grant extends Attestation_1.Attestation {
15
14
  constructor() {
16
15
  super(...arguments);
@@ -71,22 +70,18 @@ class Grant extends Attestation_1.Attestation {
71
70
  * @param payload
72
71
  * @param projectIdx
73
72
  */
74
- multiAttestPayload(currentPayload = [], projectIdx = 0) {
73
+ async multiAttestPayload(currentPayload = [], projectIdx = 0) {
75
74
  this.assertPayload();
76
75
  const payload = [...currentPayload];
77
- const grantIdx = payload.push([this, this.payloadFor(projectIdx)]) - 1;
76
+ const grantIdx = payload.push([this, await this.payloadFor(projectIdx)]) - 1;
78
77
  if (this.details) {
79
- payload.push([this.details, this.details.payloadFor(grantIdx)]);
78
+ payload.push([this.details, await this.details.payloadFor(grantIdx)]);
80
79
  }
81
80
  if (this.milestones.length) {
82
- this.milestones.forEach((m) => {
83
- payload.push([m, m.payloadFor(grantIdx)]);
84
- });
81
+ await Promise.all(this.milestones.map(async (m) => payload.push(...(await m.multiAttestPayload(currentPayload, grantIdx)))));
85
82
  }
86
83
  if (this.updates.length) {
87
- this.updates.forEach((u) => {
88
- payload.push([u, u.payloadFor(grantIdx)]);
89
- });
84
+ await Promise.all(this.updates.map(async (u) => payload.push([u, await u.payloadFor(grantIdx)])));
90
85
  }
91
86
  return payload.slice(currentPayload.length, payload.length);
92
87
  }
@@ -95,7 +90,7 @@ class Grant extends Attestation_1.Attestation {
95
90
  */
96
91
  async attest(signer) {
97
92
  this.assertPayload();
98
- const payload = this.multiAttestPayload();
93
+ const payload = await this.multiAttestPayload();
99
94
  const uids = await GapContract_1.GapContract.multiAttest(signer, payload.map((p) => p[1]));
100
95
  uids.forEach((uid, index) => {
101
96
  payload[index][0].uid = uid;
@@ -182,12 +177,7 @@ class Grant extends Attestation_1.Attestation {
182
177
  }
183
178
  if (attestation.project) {
184
179
  const { project } = attestation;
185
- const rawProject = Project_1.Project.from([project])[0];
186
- grant.project = {
187
- title: rawProject.details?.title,
188
- uid: rawProject.uid,
189
- slug: rawProject.details?.slug,
190
- };
180
+ grant.project = project;
191
181
  }
192
182
  if (attestation.community) {
193
183
  const { community } = attestation;
@@ -6,6 +6,6 @@ export interface IMemberOf {
6
6
  }
7
7
  export declare class MemberOf extends Attestation<IMemberOf> {
8
8
  details?: MemberDetails;
9
- multiAttestPayload(currentPayload?: MultiAttestPayload, projectIdx?: number): [Attestation<unknown, import("..").GapSchema>, import("core/types").RawMultiAttestPayload][];
9
+ multiAttestPayload(currentPayload?: MultiAttestPayload, projectIdx?: number): Promise<[Attestation<unknown, import("..").GapSchema>, import("core/types").RawMultiAttestPayload][]>;
10
10
  attest(signer: SignerOrProvider): Promise<void>;
11
11
  }
@@ -5,16 +5,16 @@ const Attestation_1 = require("../Attestation");
5
5
  const SchemaError_1 = require("../SchemaError");
6
6
  const GapContract_1 = require("../contract/GapContract");
7
7
  class MemberOf extends Attestation_1.Attestation {
8
- multiAttestPayload(currentPayload = [], projectIdx = 0) {
8
+ async multiAttestPayload(currentPayload = [], projectIdx = 0) {
9
9
  const payload = [...currentPayload];
10
- const memberIdx = payload.push([this, this.payloadFor(projectIdx)]) - 1;
10
+ const memberIdx = payload.push([this, await this.payloadFor(projectIdx)]) - 1;
11
11
  if (this.details) {
12
- payload.push([this.details, this.details.payloadFor(memberIdx)]);
12
+ payload.push([this.details, await this.details.payloadFor(memberIdx)]);
13
13
  }
14
14
  return payload.slice(currentPayload.length, payload.length);
15
15
  }
16
16
  async attest(signer) {
17
- const payload = this.multiAttestPayload();
17
+ const payload = await this.multiAttestPayload();
18
18
  try {
19
19
  const [memberUID, detailsUID] = await GapContract_1.GapContract.multiAttest(signer, payload.map((p) => p[1]));
20
20
  this.uid = memberUID;
@@ -1,5 +1,6 @@
1
- import { SignerOrProvider } from '../../types';
1
+ import { MultiAttestPayload, SignerOrProvider } from '../../types';
2
2
  import { Attestation } from '../Attestation';
3
+ import { GapSchema } from '../GapSchema';
3
4
  import { MilestoneCompleted } from '../types/attestations';
4
5
  interface _Milestone extends Milestone {
5
6
  }
@@ -54,6 +55,21 @@ export declare class Milestone extends Attestation<IMilestone> implements IMiles
54
55
  * @param signer
55
56
  */
56
57
  revokeCompletion(signer: SignerOrProvider): Promise<void>;
58
+ /**
59
+ * Creates the payload for a multi-attestation.
60
+ *
61
+ * > if Current payload is set, it'll be used as the base payload
62
+ * and the project should refer to an index of the current payload,
63
+ * usually the community position.
64
+ *
65
+ * @param payload
66
+ * @param grantIdx
67
+ */
68
+ multiAttestPayload(currentPayload?: MultiAttestPayload, grantIdx?: number): Promise<[Attestation<unknown, GapSchema>, import("../../types").RawMultiAttestPayload][]>;
69
+ /**
70
+ * @inheritdoc
71
+ */
72
+ attest(signer: SignerOrProvider): Promise<void>;
57
73
  /**
58
74
  * Attest the status of the milestone as approved, rejected or completed.
59
75
  */
@@ -5,6 +5,7 @@ const Attestation_1 = require("../Attestation");
5
5
  const GAP_1 = require("../GAP");
6
6
  const GapSchema_1 = require("../GapSchema");
7
7
  const SchemaError_1 = require("../SchemaError");
8
+ const GapContract_1 = require("../contract/GapContract");
8
9
  const attestations_1 = require("../types/attestations");
9
10
  class Milestone extends Attestation_1.Attestation {
10
11
  /**
@@ -119,6 +120,40 @@ class Milestone extends Attestation_1.Attestation {
119
120
  },
120
121
  ]);
121
122
  }
123
+ /**
124
+ * Creates the payload for a multi-attestation.
125
+ *
126
+ * > if Current payload is set, it'll be used as the base payload
127
+ * and the project should refer to an index of the current payload,
128
+ * usually the community position.
129
+ *
130
+ * @param payload
131
+ * @param grantIdx
132
+ */
133
+ async multiAttestPayload(currentPayload = [], grantIdx = 0) {
134
+ this.assertPayload();
135
+ const payload = [...currentPayload];
136
+ const milestoneIdx = payload.push([this, await this.payloadFor(grantIdx)]) - 1;
137
+ if (this.completed) {
138
+ payload.push([
139
+ this.completed,
140
+ await this.completed.payloadFor(milestoneIdx),
141
+ ]);
142
+ }
143
+ return payload.slice(currentPayload.length, payload.length);
144
+ }
145
+ /**
146
+ * @inheritdoc
147
+ */
148
+ async attest(signer) {
149
+ this.assertPayload();
150
+ const payload = await this.multiAttestPayload();
151
+ const uids = await GapContract_1.GapContract.multiAttest(signer, payload.map((p) => p[1]));
152
+ uids.forEach((uid, index) => {
153
+ payload[index][0].uid = uid;
154
+ });
155
+ console.log(uids);
156
+ }
122
157
  /**
123
158
  * Attest the status of the milestone as approved, rejected or completed.
124
159
  */
@@ -23,7 +23,7 @@ export declare class Project extends Attestation<IProject> {
23
23
  * @param payload
24
24
  * @param communityIdx
25
25
  */
26
- multiAttestPayload(currentPayload?: MultiAttestPayload, communityIdx?: number): MultiAttestPayload;
26
+ multiAttestPayload(currentPayload?: MultiAttestPayload, communityIdx?: number): Promise<MultiAttestPayload>;
27
27
  attest(signer: SignerOrProvider): Promise<void>;
28
28
  /**
29
29
  * Add new members to the project.
@@ -26,26 +26,22 @@ class Project extends Attestation_1.Attestation {
26
26
  * @param payload
27
27
  * @param communityIdx
28
28
  */
29
- multiAttestPayload(currentPayload = [], communityIdx = 0) {
29
+ async multiAttestPayload(currentPayload = [], communityIdx = 0) {
30
30
  const payload = [...currentPayload];
31
- const projectIdx = payload.push([this, this.payloadFor(communityIdx)]) - 1;
31
+ const projectIdx = payload.push([this, await this.payloadFor(communityIdx)]) - 1;
32
32
  if (this.details) {
33
- payload.push([this.details, this.details.payloadFor(projectIdx)]);
33
+ payload.push([this.details, await this.details.payloadFor(projectIdx)]);
34
34
  }
35
35
  if (this.members?.length) {
36
- this.members.forEach((m) => {
37
- payload.push(...m.multiAttestPayload(payload, projectIdx));
38
- });
36
+ await Promise.all(this.members.map(async (m) => payload.push(...(await m.multiAttestPayload(payload, projectIdx)))));
39
37
  }
40
38
  if (this.grants?.length) {
41
- this.grants.forEach((g) => {
42
- payload.push(...g.multiAttestPayload(payload, projectIdx));
43
- });
39
+ await Promise.all(this.grants.map(async (g) => payload.push(...(await g.multiAttestPayload(payload, projectIdx)))));
44
40
  }
45
41
  return payload.slice(currentPayload.length, payload.length);
46
42
  }
47
43
  async attest(signer) {
48
- const payload = this.multiAttestPayload();
44
+ const payload = await this.multiAttestPayload();
49
45
  const uids = await GapContract_1.GapContract.multiAttest(signer, payload.map((p) => p[1]));
50
46
  uids.forEach((uid, index) => {
51
47
  payload[index][0].uid = uid;
@@ -0,0 +1 @@
1
+ export declare function getIPFSData<T>(cid: string): Promise<T>;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getIPFSData = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ async function getIPFSData(cid) {
9
+ try {
10
+ const { data } = await axios_1.default.get(`https://ipfs.io/ipfs/${cid}`);
11
+ return data;
12
+ }
13
+ catch (err) {
14
+ throw new Error(`Error to retrive data for CID: ${cid}`);
15
+ }
16
+ }
17
+ exports.getIPFSData = getIPFSData;
@@ -4,3 +4,4 @@ export * from './gql-queries';
4
4
  export * from './map-filter';
5
5
  export * from './serialize-bigint';
6
6
  export * from './to-unix';
7
+ export * from './get-ipfs-data';
@@ -20,3 +20,4 @@ __exportStar(require("./gql-queries"), exports);
20
20
  __exportStar(require("./map-filter"), exports);
21
21
  __exportStar(require("./serialize-bigint"), exports);
22
22
  __exportStar(require("./to-unix"), exports);
23
+ __exportStar(require("./get-ipfs-data"), exports);
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.1.40",
6
+ "version": "0.2.1",
7
7
  "description": "Simple and easy interface between EAS and Karma GAP.",
8
8
  "main": "dist/index.js",
9
9
  "author": "KarmaHQ",
@@ -23,6 +23,7 @@
23
23
  "@types/sha256": "^0.2.0",
24
24
  "axios": "^1.4.0",
25
25
  "ethers": "5.7",
26
+ "nft.storage": "^7.1.1",
26
27
  "sha256": "^0.2.0",
27
28
  "simple-ts-job-runner": "^1.0.12"
28
29
  },