@show-karma/karma-gap-sdk 0.3.40 → 0.3.41
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.
|
@@ -6,7 +6,6 @@ const SchemaError_1 = require("./SchemaError");
|
|
|
6
6
|
const get_date_1 = require("../utils/get-date");
|
|
7
7
|
const consts_1 = require("../consts");
|
|
8
8
|
const GapContract_1 = require("./contract/GapContract");
|
|
9
|
-
const IpfsStorage_1 = require("./remote-storage/IpfsStorage");
|
|
10
9
|
/**
|
|
11
10
|
* Represents the EAS Attestation and provides methods to manage attestations.
|
|
12
11
|
* @example
|
|
@@ -196,18 +195,10 @@ class Attestation {
|
|
|
196
195
|
async payloadFor(refIdx) {
|
|
197
196
|
this.assertPayload();
|
|
198
197
|
if (this.schema.isJsonSchema()) {
|
|
199
|
-
const remoteClient = new IpfsStorage_1.IpfsStorage({
|
|
200
|
-
token: process.env.NEXT_PUBLIC_IPFS_TOKEN,
|
|
201
|
-
});
|
|
202
198
|
if (this.type) {
|
|
203
199
|
this._data.type = this.type;
|
|
204
200
|
this.schema.setValue("json", JSON.stringify(this._data));
|
|
205
201
|
}
|
|
206
|
-
if (remoteClient && JSON.stringify(this._data)?.length > 1500) {
|
|
207
|
-
const cid = await remoteClient.save(this._data);
|
|
208
|
-
const encodedData = remoteClient.encode(cid);
|
|
209
|
-
this.schema.setValue("json", JSON.stringify(encodedData));
|
|
210
|
-
}
|
|
211
202
|
}
|
|
212
203
|
const payload = (encode = true) => ({
|
|
213
204
|
uid: consts_1.nullRef,
|
package/core/class/GAP.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { AttestArgs, Facade, SchemaInterface, TNetwork, TSchemaName, SignerOrProvider } from
|
|
2
|
-
import { GapSchema } from
|
|
3
|
-
import { ethers } from
|
|
4
|
-
import { Fetcher } from
|
|
5
|
-
import { RemoteStorage } from
|
|
1
|
+
import { AttestArgs, Facade, SchemaInterface, TNetwork, TSchemaName, SignerOrProvider } from "../types";
|
|
2
|
+
import { GapSchema } from "./GapSchema";
|
|
3
|
+
import { ethers } from "ethers";
|
|
4
|
+
import { Fetcher } from "./Fetcher";
|
|
5
|
+
import { RemoteStorage } from "./remote-storage/RemoteStorage";
|
|
6
6
|
interface GAPArgs {
|
|
7
7
|
network: TNetwork;
|
|
8
8
|
globalSchemas?: boolean;
|
|
@@ -229,7 +229,7 @@ export declare class GAP extends Facade {
|
|
|
229
229
|
* In case of true, the transactions will be sent through [Gelato](https://gelato.network)
|
|
230
230
|
* and an API key is needed.
|
|
231
231
|
*/
|
|
232
|
-
static get gelatoOpts(): GAPArgs[
|
|
232
|
+
static get gelatoOpts(): GAPArgs["gelatoOpts"];
|
|
233
233
|
static set useGasLess(useGasLess: boolean);
|
|
234
234
|
static get remoteClient(): RemoteStorage<unknown>;
|
|
235
235
|
}
|
package/core/class/GAP.js
CHANGED
|
@@ -81,16 +81,15 @@ class GAP extends types_1.Facade {
|
|
|
81
81
|
this.generateSlug = async (text) => {
|
|
82
82
|
let slug = text
|
|
83
83
|
.toLowerCase()
|
|
84
|
-
.replace(/ /g,
|
|
85
|
-
.replace(/[^\w-]+/g,
|
|
84
|
+
.replace(/ /g, "-")
|
|
85
|
+
.replace(/[^\w-]+/g, "");
|
|
86
86
|
const slugExists = await this.fetch.slugExists(slug);
|
|
87
87
|
if (slugExists) {
|
|
88
|
-
const parts = slug.split(
|
|
88
|
+
const parts = slug.split("-");
|
|
89
89
|
const counter = parts.pop();
|
|
90
|
-
slug = /\d+/g.test(counter) ? parts.join(
|
|
90
|
+
slug = /\d+/g.test(counter) ? parts.join("-") : slug;
|
|
91
91
|
// eslint-disable-next-line no-param-reassign
|
|
92
92
|
const nextSlug = `${slug}-${counter && /\d+/g.test(counter) ? +counter + 1 : 1}`;
|
|
93
|
-
console.log({ nextSlug, counter, slug });
|
|
94
93
|
return this.generateSlug(nextSlug);
|
|
95
94
|
}
|
|
96
95
|
return slug.toLowerCase();
|
|
@@ -114,18 +113,18 @@ class GAP extends types_1.Facade {
|
|
|
114
113
|
assertGelatoOpts(args) {
|
|
115
114
|
if (args.gelatoOpts &&
|
|
116
115
|
!(args.gelatoOpts.sponsorUrl || args.gelatoOpts.apiKey)) {
|
|
117
|
-
throw new Error(
|
|
116
|
+
throw new Error("You must provide a `sponsorUrl` or an `apiKey`.");
|
|
118
117
|
}
|
|
119
118
|
if (args.gelatoOpts?.sponsorUrl &&
|
|
120
119
|
args.gelatoOpts?.contained &&
|
|
121
120
|
!args.gelatoOpts.env_gelatoApiKey) {
|
|
122
|
-
throw new Error(
|
|
121
|
+
throw new Error("You must provide `env_gelatoApiKey` to be able to use it in a backend handler.");
|
|
123
122
|
}
|
|
124
123
|
if ((args.gelatoOpts?.env_gelatoApiKey ||
|
|
125
124
|
args.gelatoOpts?.apiKey ||
|
|
126
125
|
args.gelatoOpts?.sponsorUrl) &&
|
|
127
126
|
!args.gelatoOpts?.useGasless) {
|
|
128
|
-
console.warn(
|
|
127
|
+
console.warn("GAP::You are using gelatoOpts but not setting useGasless to true. This will send transactions through the normal provider.");
|
|
129
128
|
}
|
|
130
129
|
}
|
|
131
130
|
/**
|
|
@@ -219,11 +218,11 @@ class GAP extends types_1.Facade {
|
|
|
219
218
|
* and an API key is needed.
|
|
220
219
|
*/
|
|
221
220
|
static set gelatoOpts(gelatoOpts) {
|
|
222
|
-
if (typeof this._gelatoOpts ===
|
|
221
|
+
if (typeof this._gelatoOpts === "undefined") {
|
|
223
222
|
this._gelatoOpts = gelatoOpts;
|
|
224
223
|
}
|
|
225
224
|
else {
|
|
226
|
-
throw new Error(
|
|
225
|
+
throw new Error("Cannot change a readonly value gelatoOpts.");
|
|
227
226
|
}
|
|
228
227
|
}
|
|
229
228
|
/**
|
|
@@ -240,7 +239,7 @@ class GAP extends types_1.Facade {
|
|
|
240
239
|
!this._gelatoOpts?.apiKey &&
|
|
241
240
|
!this._gelatoOpts?.sponsorUrl &&
|
|
242
241
|
!this._gelatoOpts?.env_gelatoApiKey) {
|
|
243
|
-
throw new Error(
|
|
242
|
+
throw new Error("You must provide a `sponsorUrl` or an `apiKey` before using gasless transactions.");
|
|
244
243
|
}
|
|
245
244
|
this._gelatoOpts.useGasless = useGasLess;
|
|
246
245
|
}
|
package/core/class/Schema.js
CHANGED
|
@@ -6,7 +6,6 @@ const SchemaError_1 = require("./SchemaError");
|
|
|
6
6
|
const consts_1 = require("../consts");
|
|
7
7
|
const GapContract_1 = require("./contract/GapContract");
|
|
8
8
|
const ethers_1 = require("ethers");
|
|
9
|
-
const IpfsStorage_1 = require("./remote-storage/IpfsStorage");
|
|
10
9
|
/**
|
|
11
10
|
* Represents the EAS Schema and provides methods to encode and decode the schema,
|
|
12
11
|
* and validate the schema references.
|
|
@@ -224,14 +223,6 @@ class Schema {
|
|
|
224
223
|
if (this.references && !refUID)
|
|
225
224
|
throw new SchemaError_1.AttestationError("INVALID_REFERENCE", "Attestation schema references another schema but no reference UID was provided.");
|
|
226
225
|
if (this.isJsonSchema()) {
|
|
227
|
-
const remoteClient = new IpfsStorage_1.IpfsStorage({
|
|
228
|
-
token: process.env.NEXT_PUBLIC_IPFS_TOKEN,
|
|
229
|
-
});
|
|
230
|
-
if (remoteClient) {
|
|
231
|
-
const cid = await remoteClient.save(data);
|
|
232
|
-
const encodedData = remoteClient.encode(cid);
|
|
233
|
-
data = encodedData;
|
|
234
|
-
}
|
|
235
226
|
this.setValue("json", JSON.stringify(data));
|
|
236
227
|
}
|
|
237
228
|
else {
|