@show-karma/karma-gap-sdk 0.1.29
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/abi/MultiAttester.json +676 -0
- package/core/class/Attestation.d.ts +169 -0
- package/core/class/Attestation.js +311 -0
- package/core/class/Fetcher.d.ts +132 -0
- package/core/class/Fetcher.js +7 -0
- package/core/class/GAP.d.ts +212 -0
- package/core/class/GAP.js +206 -0
- package/core/class/GapSchema.d.ts +33 -0
- package/core/class/GapSchema.js +61 -0
- package/core/class/Gelato/Gelato.d.ts +0 -0
- package/core/class/Gelato/Gelato.js +263 -0
- package/core/class/GraphQL/AxiosGQL.d.ts +6 -0
- package/core/class/GraphQL/AxiosGQL.js +25 -0
- package/core/class/GraphQL/EASClient.d.ts +16 -0
- package/core/class/GraphQL/EASClient.js +26 -0
- package/core/class/GraphQL/Fetcher.d.ts +132 -0
- package/core/class/GraphQL/Fetcher.js +7 -0
- package/core/class/GraphQL/GAPFetcher.d.ts +160 -0
- package/core/class/GraphQL/GAPFetcher.js +516 -0
- package/core/class/GraphQL/GapEasClient.d.ts +63 -0
- package/core/class/GraphQL/GapEasClient.js +420 -0
- package/core/class/GraphQL/index.d.ts +3 -0
- package/core/class/GraphQL/index.js +19 -0
- package/core/class/Schema.d.ts +213 -0
- package/core/class/Schema.js +434 -0
- package/core/class/SchemaError.d.ts +26 -0
- package/core/class/SchemaError.js +34 -0
- package/core/class/contract/GapContract.d.ts +55 -0
- package/core/class/contract/GapContract.js +176 -0
- package/core/class/contract/MultiAttest.d.ts +10 -0
- package/core/class/contract/MultiAttest.js +19 -0
- package/core/class/entities/Community.d.ts +36 -0
- package/core/class/entities/Community.js +88 -0
- package/core/class/entities/Grant.d.ts +53 -0
- package/core/class/entities/Grant.js +194 -0
- package/core/class/entities/MemberOf.d.ts +11 -0
- package/core/class/entities/MemberOf.js +31 -0
- package/core/class/entities/Milestone.d.ts +63 -0
- package/core/class/entities/Milestone.js +171 -0
- package/core/class/entities/Project.d.ts +73 -0
- package/core/class/entities/Project.js +243 -0
- package/core/class/entities/index.d.ts +5 -0
- package/core/class/entities/index.js +21 -0
- package/core/class/index.d.ts +7 -0
- package/core/class/index.js +23 -0
- package/core/class/karma-indexer/GapIndexerClient.d.ts +28 -0
- package/core/class/karma-indexer/GapIndexerClient.js +137 -0
- package/core/class/types/attestations.d.ts +108 -0
- package/core/class/types/attestations.js +55 -0
- package/core/consts.d.ts +19 -0
- package/core/consts.js +228 -0
- package/core/index.d.ts +7 -0
- package/core/index.js +23 -0
- package/core/types.d.ts +107 -0
- package/core/types.js +13 -0
- package/core/utils/gelato/index.d.ts +3 -0
- package/core/utils/gelato/index.js +19 -0
- package/core/utils/gelato/send-gelato-txn.d.ts +54 -0
- package/core/utils/gelato/send-gelato-txn.js +99 -0
- package/core/utils/gelato/sponsor-handler.d.ts +9 -0
- package/core/utils/gelato/sponsor-handler.js +60 -0
- package/core/utils/gelato/watch-gelato-txn.d.ts +7 -0
- package/core/utils/gelato/watch-gelato-txn.js +55 -0
- package/core/utils/get-date.d.ts +1 -0
- package/core/utils/get-date.js +7 -0
- package/core/utils/gql-queries.d.ts +12 -0
- package/core/utils/gql-queries.js +90 -0
- package/core/utils/index.d.ts +6 -0
- package/core/utils/index.js +22 -0
- package/core/utils/map-filter.d.ts +8 -0
- package/core/utils/map-filter.js +20 -0
- package/core/utils/serialize-bigint.d.ts +1 -0
- package/core/utils/serialize-bigint.js +8 -0
- package/core/utils/to-unix.d.ts +1 -0
- package/core/utils/to-unix.js +25 -0
- package/index.d.ts +1 -0
- package/index.js +17 -0
- package/package.json +37 -0
|
@@ -0,0 +1,212 @@
|
|
|
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
|
+
interface GAPArgs {
|
|
6
|
+
network: TNetwork;
|
|
7
|
+
globalSchemas?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Custom API Client to be used to fetch attestation data.
|
|
10
|
+
* If not defined, will use the default EAS Client and rely on EAS's GraphQL API.
|
|
11
|
+
*/
|
|
12
|
+
apiClient?: Fetcher;
|
|
13
|
+
schemas?: SchemaInterface<TSchemaName>[];
|
|
14
|
+
/**
|
|
15
|
+
* Defined if the transactions will be gasless or not.
|
|
16
|
+
*
|
|
17
|
+
* In case of true, the transactions will be sent through [Gelato](https://gelato.network)
|
|
18
|
+
* and an API key is needed.
|
|
19
|
+
*
|
|
20
|
+
* > __Note that to safely transact through Gelato, the user must
|
|
21
|
+
* have set a handlerUrl and not expose gelato api in the frontend.__
|
|
22
|
+
*/
|
|
23
|
+
gelatoOpts?: {
|
|
24
|
+
/**
|
|
25
|
+
* Endpoint in which the transaction will be sent.
|
|
26
|
+
* A custom endpoint will ensure that the transaction will be sent through Gelato
|
|
27
|
+
* and api keys won't be exposed in the frontend.
|
|
28
|
+
*
|
|
29
|
+
* __If coding a backend, you can use `apiKey` prop instead.__
|
|
30
|
+
*
|
|
31
|
+
* `core/utils/gelato/sponsor-handler.ts` is a base handler that can be used
|
|
32
|
+
* together with NextJS API routes.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
*
|
|
36
|
+
* ```ts
|
|
37
|
+
* // pages/api/gelato.ts
|
|
38
|
+
* import { handler as sponsorHandler } from "core/utils/gelato/sponsor-handler";
|
|
39
|
+
*
|
|
40
|
+
* export default const handler(req, res) => sponsorHandler(req, res, "GELATO_API_KEY_ENV_VARIABLE");
|
|
41
|
+
*
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
sponsorUrl?: string;
|
|
45
|
+
/**
|
|
46
|
+
* If true, env_gelatoApiKey will be marked as required.
|
|
47
|
+
* This means that the endpoint at sponsorUrl is contained in this application.
|
|
48
|
+
*
|
|
49
|
+
* E.g. Next.JS api route.
|
|
50
|
+
*/
|
|
51
|
+
contained?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* The env key of gelato api key that will be used in the handler.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
*
|
|
57
|
+
* ```
|
|
58
|
+
* // .env
|
|
59
|
+
* GELATO_API_KEY=1234567890
|
|
60
|
+
*
|
|
61
|
+
* // sponsor-handler.ts
|
|
62
|
+
*
|
|
63
|
+
* export async function handler(req, res) {
|
|
64
|
+
* // ...code
|
|
65
|
+
*
|
|
66
|
+
* const { env_gelatoApiKey } = GAP.gelatoOpts;
|
|
67
|
+
*
|
|
68
|
+
* // Will be used to get the key from environment.
|
|
69
|
+
* const { [env_gelatoApiKey]: apiKey } = process.env;
|
|
70
|
+
*
|
|
71
|
+
* // send txn
|
|
72
|
+
* // res.send(result);
|
|
73
|
+
* }
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
env_gelatoApiKey?: string;
|
|
77
|
+
/**
|
|
78
|
+
* API key to be used in the handler.
|
|
79
|
+
*
|
|
80
|
+
* @deprecated Use this only if you have no option of setting a backend, next/nuxt api route
|
|
81
|
+
* or if this application is a backend.
|
|
82
|
+
*
|
|
83
|
+
* > __This will expose the api key if used in the frontend.__
|
|
84
|
+
*/
|
|
85
|
+
apiKey?: string;
|
|
86
|
+
/**
|
|
87
|
+
* If true, will use gelato to send transactions.
|
|
88
|
+
*/
|
|
89
|
+
useGasless?: boolean;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* GAP SDK Facade.
|
|
94
|
+
*
|
|
95
|
+
* This is the main class that is used to interact with the GAP SDK.
|
|
96
|
+
*
|
|
97
|
+
* This class can behave as a singleton or as a regular class.
|
|
98
|
+
*
|
|
99
|
+
* Using this class, the user will be able to:
|
|
100
|
+
*
|
|
101
|
+
* - Create and manage attestations
|
|
102
|
+
* - Create and manage schemas
|
|
103
|
+
* - Fetch data from the EAS
|
|
104
|
+
*
|
|
105
|
+
* #### Features
|
|
106
|
+
* - EAS Client: used to interact with EAS contracts
|
|
107
|
+
* - EAS Fetcher: used to fetch data from the EAS GraphQL API, providing methods for:
|
|
108
|
+
* - Get projects
|
|
109
|
+
* - Get grants with its details
|
|
110
|
+
* - Get grantees
|
|
111
|
+
* - Get members
|
|
112
|
+
* - Get tags
|
|
113
|
+
* - Get external links
|
|
114
|
+
* - Get schemas
|
|
115
|
+
* - Get attestations by pair, attester, recipient, schema, or UID
|
|
116
|
+
* - Get dependent attestations
|
|
117
|
+
* - Schema: used to create and manage schemas
|
|
118
|
+
* - Attestation: used to create and manage attestations
|
|
119
|
+
* - Replace schemas: used to replace the schema list with a new list
|
|
120
|
+
* - Replace single schema: used to replace a single schema from the schema list
|
|
121
|
+
*
|
|
122
|
+
* ---
|
|
123
|
+
* @example
|
|
124
|
+
* ```ts
|
|
125
|
+
* import { GAP } from "./core/class/GAP";
|
|
126
|
+
* import { GapSchema } from "./core/class/GapSchema";
|
|
127
|
+
* import { Schema } from "./core/class/Schema";
|
|
128
|
+
* import { MountEntities, Networks } from "./core/consts";
|
|
129
|
+
*
|
|
130
|
+
* const schemas = MountEntities(Networks.sepolia);
|
|
131
|
+
*
|
|
132
|
+
* // Use GAP.createClient to create a singleton GAP client
|
|
133
|
+
* const gap = GAP.createClient({
|
|
134
|
+
* network: "sepolia",
|
|
135
|
+
* owner: "0xd7d1DB401EA825b0325141Cd5e6cd7C2d01825f2",
|
|
136
|
+
* schemas: Object.values(schemas),
|
|
137
|
+
* });
|
|
138
|
+
*
|
|
139
|
+
* gap.fetcher
|
|
140
|
+
* .fetchProjects()
|
|
141
|
+
* .then((res) => {
|
|
142
|
+
* console.log(JSON.stringify(res, null, 2));
|
|
143
|
+
* })
|
|
144
|
+
*
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
export declare class GAP extends Facade {
|
|
148
|
+
private static client;
|
|
149
|
+
readonly fetch: Fetcher;
|
|
150
|
+
readonly network: TNetwork;
|
|
151
|
+
private _schemas;
|
|
152
|
+
private static _gelatoOpts;
|
|
153
|
+
constructor(args: GAPArgs);
|
|
154
|
+
private assert;
|
|
155
|
+
/**
|
|
156
|
+
* Creates the attestation payload using a specific schema.
|
|
157
|
+
* @param from
|
|
158
|
+
* @param to
|
|
159
|
+
* @param data
|
|
160
|
+
* @param schema
|
|
161
|
+
*/
|
|
162
|
+
attest<T>(attestation: AttestArgs<T> & {
|
|
163
|
+
schemaName: TSchemaName;
|
|
164
|
+
}): Promise<`0x${string}`>;
|
|
165
|
+
/**
|
|
166
|
+
* Replaces the schema list with a new list.
|
|
167
|
+
* @param schemas
|
|
168
|
+
*/
|
|
169
|
+
replaceSchemas(schemas: GapSchema[]): void;
|
|
170
|
+
/**
|
|
171
|
+
* Replaces a schema from the schema list.
|
|
172
|
+
* @throws {SchemaError} if desired schema name does not exist.
|
|
173
|
+
*/
|
|
174
|
+
replaceSingleSchema(schema: GapSchema): void;
|
|
175
|
+
/**
|
|
176
|
+
* Generates a slug from a text.
|
|
177
|
+
* @param text
|
|
178
|
+
* @returns
|
|
179
|
+
*/
|
|
180
|
+
generateSlug: (text: string) => Promise<string>;
|
|
181
|
+
/**
|
|
182
|
+
* Creates or returns an existing GAP client.
|
|
183
|
+
*
|
|
184
|
+
* _Use the constructor only if multiple clients are needed._
|
|
185
|
+
* @static
|
|
186
|
+
* @param {GAPArgs} args
|
|
187
|
+
* @returns
|
|
188
|
+
*/
|
|
189
|
+
static createClient(args: GAPArgs): GAP;
|
|
190
|
+
/**
|
|
191
|
+
* Get the multicall contract
|
|
192
|
+
* @param signer
|
|
193
|
+
*/
|
|
194
|
+
static getMulticall(signer: SignerOrProvider): ethers.Contract;
|
|
195
|
+
get schemas(): GapSchema[];
|
|
196
|
+
/**
|
|
197
|
+
* Defined if the transactions will be gasless or not.
|
|
198
|
+
*
|
|
199
|
+
* In case of true, the transactions will be sent through [Gelato](https://gelato.network)
|
|
200
|
+
* and an API key is needed.
|
|
201
|
+
*/
|
|
202
|
+
private static set gelatoOpts(value);
|
|
203
|
+
/**
|
|
204
|
+
* Defined if the transactions will be gasless or not.
|
|
205
|
+
*
|
|
206
|
+
* In case of true, the transactions will be sent through [Gelato](https://gelato.network)
|
|
207
|
+
* and an API key is needed.
|
|
208
|
+
*/
|
|
209
|
+
static get gelatoOpts(): GAPArgs["gelatoOpts"];
|
|
210
|
+
static set useGasLess(useGasLess: boolean);
|
|
211
|
+
}
|
|
212
|
+
export {};
|
|
@@ -0,0 +1,206 @@
|
|
|
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.GAP = void 0;
|
|
7
|
+
const types_1 = require("../types");
|
|
8
|
+
const Schema_1 = require("./Schema");
|
|
9
|
+
const GapSchema_1 = require("./GapSchema");
|
|
10
|
+
const GapEasClient_1 = require("./GraphQL/GapEasClient");
|
|
11
|
+
const eas_sdk_1 = require("@ethereum-attestation-service/eas-sdk");
|
|
12
|
+
const consts_1 = require("../consts");
|
|
13
|
+
const ethers_1 = require("ethers");
|
|
14
|
+
const MultiAttester_json_1 = __importDefault(require("../abi/MultiAttester.json"));
|
|
15
|
+
const package_json_1 = require("../../package.json");
|
|
16
|
+
/**
|
|
17
|
+
* GAP SDK Facade.
|
|
18
|
+
*
|
|
19
|
+
* This is the main class that is used to interact with the GAP SDK.
|
|
20
|
+
*
|
|
21
|
+
* This class can behave as a singleton or as a regular class.
|
|
22
|
+
*
|
|
23
|
+
* Using this class, the user will be able to:
|
|
24
|
+
*
|
|
25
|
+
* - Create and manage attestations
|
|
26
|
+
* - Create and manage schemas
|
|
27
|
+
* - Fetch data from the EAS
|
|
28
|
+
*
|
|
29
|
+
* #### Features
|
|
30
|
+
* - EAS Client: used to interact with EAS contracts
|
|
31
|
+
* - EAS Fetcher: used to fetch data from the EAS GraphQL API, providing methods for:
|
|
32
|
+
* - Get projects
|
|
33
|
+
* - Get grants with its details
|
|
34
|
+
* - Get grantees
|
|
35
|
+
* - Get members
|
|
36
|
+
* - Get tags
|
|
37
|
+
* - Get external links
|
|
38
|
+
* - Get schemas
|
|
39
|
+
* - Get attestations by pair, attester, recipient, schema, or UID
|
|
40
|
+
* - Get dependent attestations
|
|
41
|
+
* - Schema: used to create and manage schemas
|
|
42
|
+
* - Attestation: used to create and manage attestations
|
|
43
|
+
* - Replace schemas: used to replace the schema list with a new list
|
|
44
|
+
* - Replace single schema: used to replace a single schema from the schema list
|
|
45
|
+
*
|
|
46
|
+
* ---
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* import { GAP } from "./core/class/GAP";
|
|
50
|
+
* import { GapSchema } from "./core/class/GapSchema";
|
|
51
|
+
* import { Schema } from "./core/class/Schema";
|
|
52
|
+
* import { MountEntities, Networks } from "./core/consts";
|
|
53
|
+
*
|
|
54
|
+
* const schemas = MountEntities(Networks.sepolia);
|
|
55
|
+
*
|
|
56
|
+
* // Use GAP.createClient to create a singleton GAP client
|
|
57
|
+
* const gap = GAP.createClient({
|
|
58
|
+
* network: "sepolia",
|
|
59
|
+
* owner: "0xd7d1DB401EA825b0325141Cd5e6cd7C2d01825f2",
|
|
60
|
+
* schemas: Object.values(schemas),
|
|
61
|
+
* });
|
|
62
|
+
*
|
|
63
|
+
* gap.fetcher
|
|
64
|
+
* .fetchProjects()
|
|
65
|
+
* .then((res) => {
|
|
66
|
+
* console.log(JSON.stringify(res, null, 2));
|
|
67
|
+
* })
|
|
68
|
+
*
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
class GAP extends types_1.Facade {
|
|
72
|
+
constructor(args) {
|
|
73
|
+
super();
|
|
74
|
+
/**
|
|
75
|
+
* Generates a slug from a text.
|
|
76
|
+
* @param text
|
|
77
|
+
* @returns
|
|
78
|
+
*/
|
|
79
|
+
this.generateSlug = async (text) => {
|
|
80
|
+
let slug = text
|
|
81
|
+
.toLowerCase()
|
|
82
|
+
.replace(/ /g, "-")
|
|
83
|
+
.replace(/[^\w-]+/g, "");
|
|
84
|
+
const slugExists = await this.fetch.slugExists(slug);
|
|
85
|
+
if (slugExists) {
|
|
86
|
+
const parts = slug.split("-");
|
|
87
|
+
const counter = parts.pop();
|
|
88
|
+
slug = /\d+/g.test(counter) ? parts.join("-") : slug;
|
|
89
|
+
// eslint-disable-next-line no-param-reassign
|
|
90
|
+
const nextSlug = `${slug}-${counter && /\d+/g.test(counter) ? +counter + 1 : 1}`;
|
|
91
|
+
console.log({ nextSlug, counter, slug });
|
|
92
|
+
return this.generateSlug(nextSlug);
|
|
93
|
+
}
|
|
94
|
+
return slug.toLowerCase();
|
|
95
|
+
};
|
|
96
|
+
const schemas = args.schemas || Object.values((0, consts_1.MountEntities)(consts_1.Networks[args.network]));
|
|
97
|
+
this.network = args.network;
|
|
98
|
+
GAP._eas = new eas_sdk_1.EAS(consts_1.Networks[args.network].contracts.eas);
|
|
99
|
+
this.fetch = args.apiClient || new GapEasClient_1.GapEasClient({ network: args.network });
|
|
100
|
+
this.assert(args);
|
|
101
|
+
GAP._gelatoOpts = args.gelatoOpts;
|
|
102
|
+
this._schemas = schemas.map((schema) => new GapSchema_1.GapSchema(schema, false, args.globalSchemas ? !args.globalSchemas : false));
|
|
103
|
+
Schema_1.Schema.validate();
|
|
104
|
+
console.info(`Loaded GAP SDK v${package_json_1.version}`);
|
|
105
|
+
}
|
|
106
|
+
assert(args) {
|
|
107
|
+
if (args.gelatoOpts &&
|
|
108
|
+
!(args.gelatoOpts.sponsorUrl || args.gelatoOpts.apiKey)) {
|
|
109
|
+
throw new Error("You must provide a `sponsorUrl` or an `apiKey`.");
|
|
110
|
+
}
|
|
111
|
+
if (args.gelatoOpts?.sponsorUrl &&
|
|
112
|
+
args.gelatoOpts?.contained &&
|
|
113
|
+
!args.gelatoOpts.env_gelatoApiKey) {
|
|
114
|
+
throw new Error("You must provide `env_gelatoApiKey` to be able to use it in a backend handler.");
|
|
115
|
+
}
|
|
116
|
+
if ((args.gelatoOpts?.env_gelatoApiKey ||
|
|
117
|
+
args.gelatoOpts?.apiKey ||
|
|
118
|
+
args.gelatoOpts?.sponsorUrl) &&
|
|
119
|
+
!args.gelatoOpts?.useGasless) {
|
|
120
|
+
console.warn("GAP::You are using gelatoOpts but not setting useGasless to true. This will send transactions through the normal provider.");
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Creates the attestation payload using a specific schema.
|
|
125
|
+
* @param from
|
|
126
|
+
* @param to
|
|
127
|
+
* @param data
|
|
128
|
+
* @param schema
|
|
129
|
+
*/
|
|
130
|
+
async attest(attestation) {
|
|
131
|
+
const schema = GapSchema_1.GapSchema.find(attestation.schemaName);
|
|
132
|
+
return schema.attest(attestation);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Replaces the schema list with a new list.
|
|
136
|
+
* @param schemas
|
|
137
|
+
*/
|
|
138
|
+
replaceSchemas(schemas) {
|
|
139
|
+
Schema_1.Schema.replaceAll(schemas);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Replaces a schema from the schema list.
|
|
143
|
+
* @throws {SchemaError} if desired schema name does not exist.
|
|
144
|
+
*/
|
|
145
|
+
replaceSingleSchema(schema) {
|
|
146
|
+
Schema_1.Schema.replaceOne(schema);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Creates or returns an existing GAP client.
|
|
150
|
+
*
|
|
151
|
+
* _Use the constructor only if multiple clients are needed._
|
|
152
|
+
* @static
|
|
153
|
+
* @param {GAPArgs} args
|
|
154
|
+
* @returns
|
|
155
|
+
*/
|
|
156
|
+
static createClient(args) {
|
|
157
|
+
if (!this.client)
|
|
158
|
+
this.client = new this(args);
|
|
159
|
+
return this.client;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Get the multicall contract
|
|
163
|
+
* @param signer
|
|
164
|
+
*/
|
|
165
|
+
static getMulticall(signer) {
|
|
166
|
+
const address = consts_1.Networks[this.client.network].contracts.multicall;
|
|
167
|
+
return new ethers_1.ethers.Contract(address, MultiAttester_json_1.default, signer);
|
|
168
|
+
}
|
|
169
|
+
get schemas() {
|
|
170
|
+
return this._schemas;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Defined if the transactions will be gasless or not.
|
|
174
|
+
*
|
|
175
|
+
* In case of true, the transactions will be sent through [Gelato](https://gelato.network)
|
|
176
|
+
* and an API key is needed.
|
|
177
|
+
*/
|
|
178
|
+
static set gelatoOpts(gelatoOpts) {
|
|
179
|
+
if (typeof this._gelatoOpts === "undefined") {
|
|
180
|
+
this._gelatoOpts = gelatoOpts;
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
throw new Error("Cannot change a readonly value gelatoOpts.");
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Defined if the transactions will be gasless or not.
|
|
188
|
+
*
|
|
189
|
+
* In case of true, the transactions will be sent through [Gelato](https://gelato.network)
|
|
190
|
+
* and an API key is needed.
|
|
191
|
+
*/
|
|
192
|
+
static get gelatoOpts() {
|
|
193
|
+
return this._gelatoOpts;
|
|
194
|
+
}
|
|
195
|
+
static set useGasLess(useGasLess) {
|
|
196
|
+
if (useGasLess &&
|
|
197
|
+
!this._gelatoOpts?.apiKey &&
|
|
198
|
+
!this._gelatoOpts?.sponsorUrl &&
|
|
199
|
+
!this._gelatoOpts?.env_gelatoApiKey) {
|
|
200
|
+
throw new Error("You must provide a `sponsorUrl` or an `apiKey` before using gasless transactions.");
|
|
201
|
+
}
|
|
202
|
+
this._gelatoOpts.useGasless = useGasLess;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
exports.GAP = GAP;
|
|
206
|
+
GAP._gelatoOpts = null;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { IGapSchema, SchemaInterface, TSchemaName } from "../types";
|
|
2
|
+
import { Schema } from "./Schema";
|
|
3
|
+
/**
|
|
4
|
+
* Represents the GapSchema
|
|
5
|
+
* @extends Schema
|
|
6
|
+
*/
|
|
7
|
+
export declare class GapSchema extends Schema implements IGapSchema {
|
|
8
|
+
readonly name: TSchemaName;
|
|
9
|
+
readonly references: TSchemaName;
|
|
10
|
+
constructor(args: SchemaInterface<TSchemaName>, strict?: boolean, ignoreSchema?: boolean);
|
|
11
|
+
/**
|
|
12
|
+
* Clones a schema without references to the original.
|
|
13
|
+
* @param schema
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
static clone(schema: GapSchema): GapSchema;
|
|
17
|
+
/**
|
|
18
|
+
* Returns a copy of the original schema with no pointers.
|
|
19
|
+
* @param name
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
static find(name: TSchemaName): GapSchema;
|
|
23
|
+
/**
|
|
24
|
+
* Find many schemas by name and return their copies as an array in the same order.
|
|
25
|
+
* @param names
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
28
|
+
static findMany(names: TSchemaName[]): GapSchema[];
|
|
29
|
+
/**
|
|
30
|
+
* Get all schemas that references this schema.
|
|
31
|
+
*/
|
|
32
|
+
get children(): GapSchema[];
|
|
33
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GapSchema = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const Schema_1 = require("./Schema");
|
|
6
|
+
/**
|
|
7
|
+
* Represents the GapSchema
|
|
8
|
+
* @extends Schema
|
|
9
|
+
*/
|
|
10
|
+
class GapSchema extends Schema_1.Schema {
|
|
11
|
+
constructor(args, strict = false, ignoreSchema = false) {
|
|
12
|
+
super(args, strict, ignoreSchema);
|
|
13
|
+
if (!ignoreSchema)
|
|
14
|
+
Schema_1.Schema.add(new GapSchema({
|
|
15
|
+
name: args.name,
|
|
16
|
+
schema: args.schema.map((s) => ({ ...s })),
|
|
17
|
+
uid: args.uid,
|
|
18
|
+
references: args.references,
|
|
19
|
+
revocable: args.revocable,
|
|
20
|
+
}, strict, true));
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Clones a schema without references to the original.
|
|
24
|
+
* @param schema
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
27
|
+
static clone(schema) {
|
|
28
|
+
return new GapSchema({
|
|
29
|
+
name: schema.name,
|
|
30
|
+
schema: schema.schema.map((s) => ({ ...s })),
|
|
31
|
+
uid: schema.uid,
|
|
32
|
+
references: schema.references,
|
|
33
|
+
revocable: schema.revocable,
|
|
34
|
+
}, false, true);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Returns a copy of the original schema with no pointers.
|
|
38
|
+
* @param name
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
static find(name) {
|
|
42
|
+
const found = Schema_1.Schema.get(name);
|
|
43
|
+
return this.clone(found);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Find many schemas by name and return their copies as an array in the same order.
|
|
47
|
+
* @param names
|
|
48
|
+
* @returns
|
|
49
|
+
*/
|
|
50
|
+
static findMany(names) {
|
|
51
|
+
const schemas = Schema_1.Schema.getMany(names);
|
|
52
|
+
return schemas.map((s) => this.clone(s));
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get all schemas that references this schema.
|
|
56
|
+
*/
|
|
57
|
+
get children() {
|
|
58
|
+
return (0, utils_1.mapFilter)(GapSchema.schemas, (s) => s.references === this.name || s.references === this.uid, (s) => new GapSchema(s, false, true));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.GapSchema = GapSchema;
|
|
File without changes
|