@show-karma/karma-gap-sdk 0.4.20 → 0.4.22
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.d.ts +52 -17
- package/core/class/GAP.js +43 -18
- package/core/class/GrantProgramRegistry/Allo.d.ts +5 -7
- package/core/class/GrantProgramRegistry/Allo.js +4 -28
- package/core/class/GrantProgramRegistry/AlloRegistry.d.ts +3 -8
- package/core/class/GrantProgramRegistry/AlloRegistry.js +5 -26
- package/core/class/Schema.d.ts +3 -8
- package/core/class/Schema.js +3 -8
- package/core/class/SchemaError.d.ts +0 -3
- package/core/class/SchemaError.js +1 -5
- package/core/class/contract/GapContract.d.ts +15 -13
- package/core/class/contract/GapContract.js +16 -14
- package/core/class/index.d.ts +0 -2
- package/core/class/index.js +0 -2
- package/core/class/karma-indexer/api/GapIndexerApi.d.ts +34 -34
- package/core/consts.js +99 -30
- package/core/types.d.ts +18 -14
- package/core/utils/get-web3-provider.d.ts +16 -1
- package/core/utils/get-web3-provider.js +50 -10
- package/core/utils/index.d.ts +1 -1
- package/core/utils/index.js +5 -1
- package/package.json +1 -1
package/core/class/GAP.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { ethers } from "ethers";
|
|
2
|
-
import { AttestArgs, Facade, SchemaInterface, SignerOrProvider, TNetwork, TSchemaName } from "../types";
|
|
2
|
+
import { AttestArgs, Facade, GAPRpcConfig, SchemaInterface, SignerOrProvider, TNetwork, TSchemaName } from "../types";
|
|
3
3
|
import { Fetcher } from "./Fetcher";
|
|
4
4
|
import { GapSchema } from "./GapSchema";
|
|
5
|
-
import { RemoteStorage } from "./remote-storage/RemoteStorage";
|
|
6
5
|
interface GAPArgs {
|
|
7
6
|
network: TNetwork;
|
|
8
7
|
globalSchemas?: boolean;
|
|
@@ -12,6 +11,37 @@ interface GAPArgs {
|
|
|
12
11
|
*/
|
|
13
12
|
apiClient?: Fetcher;
|
|
14
13
|
schemas?: SchemaInterface<TSchemaName>[];
|
|
14
|
+
/**
|
|
15
|
+
* RPC URL configuration for the networks you need to use.
|
|
16
|
+
* Maps chain IDs to RPC endpoint URLs.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* // Using literal strings
|
|
21
|
+
* const gap = new GAP({
|
|
22
|
+
* network: "optimism",
|
|
23
|
+
* rpcUrls: {
|
|
24
|
+
* 10: "https://opt-mainnet.g.alchemy.com/v2/YOUR_KEY",
|
|
25
|
+
* 42161: "https://arb-mainnet.g.alchemy.com/v2/YOUR_KEY",
|
|
26
|
+
* },
|
|
27
|
+
* });
|
|
28
|
+
*
|
|
29
|
+
* // Using environment variables (with validation)
|
|
30
|
+
* const requireEnv = (key: string): string => {
|
|
31
|
+
* const value = process.env[key];
|
|
32
|
+
* if (!value) throw new Error(`Missing: ${key}`);
|
|
33
|
+
* return value;
|
|
34
|
+
* };
|
|
35
|
+
*
|
|
36
|
+
* const gap = new GAP({
|
|
37
|
+
* network: "optimism",
|
|
38
|
+
* rpcUrls: {
|
|
39
|
+
* 10: requireEnv("OPTIMISM_RPC_URL"),
|
|
40
|
+
* },
|
|
41
|
+
* });
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
rpcUrls?: GAPRpcConfig;
|
|
15
45
|
/**
|
|
16
46
|
* Defined if the transactions will be gasless or not.
|
|
17
47
|
*
|
|
@@ -89,12 +119,6 @@ interface GAPArgs {
|
|
|
89
119
|
*/
|
|
90
120
|
useGasless?: boolean;
|
|
91
121
|
};
|
|
92
|
-
/**
|
|
93
|
-
* Defines a remote storage client to be used to store data.
|
|
94
|
-
* If defined, all the details data from an attestation will
|
|
95
|
-
* be stored in the remote storage, e.g. IPFS.
|
|
96
|
-
*/
|
|
97
|
-
remoteStorage?: RemoteStorage;
|
|
98
122
|
}
|
|
99
123
|
/**
|
|
100
124
|
* GAP SDK Facade.
|
|
@@ -156,10 +180,10 @@ interface GAPArgs {
|
|
|
156
180
|
* ```
|
|
157
181
|
*/
|
|
158
182
|
export declare class GAP extends Facade {
|
|
159
|
-
private static remoteStorage?;
|
|
160
183
|
private static instances;
|
|
161
184
|
readonly fetch: Fetcher;
|
|
162
185
|
readonly network: TNetwork;
|
|
186
|
+
readonly rpcConfig: GAPRpcConfig;
|
|
163
187
|
private _schemas;
|
|
164
188
|
private static _gelatoOpts;
|
|
165
189
|
/**
|
|
@@ -168,7 +192,7 @@ export declare class GAP extends Facade {
|
|
|
168
192
|
* @param args Optional initialization arguments
|
|
169
193
|
* @returns The singleton instance of GAP for the specified network
|
|
170
194
|
*/
|
|
171
|
-
static getInstance(args
|
|
195
|
+
static getInstance(args: GAPArgs): GAP;
|
|
172
196
|
/**
|
|
173
197
|
* Creates a new instance of GAP.
|
|
174
198
|
* You can either use this constructor directly or use the singleton pattern via getInstance().
|
|
@@ -214,25 +238,37 @@ export declare class GAP extends Facade {
|
|
|
214
238
|
* @returns
|
|
215
239
|
*/
|
|
216
240
|
findManySchemas(names: TSchemaName[]): GapSchema[];
|
|
241
|
+
/**
|
|
242
|
+
* Get a Web3 provider for a specific chain ID using this instance's RPC configuration.
|
|
243
|
+
*
|
|
244
|
+
* @param chainId - The chain ID to get a provider for
|
|
245
|
+
* @returns An ethers JsonRpcProvider for the specified chain
|
|
246
|
+
* @throws Error if no RPC URL is configured for the chain ID
|
|
247
|
+
*/
|
|
248
|
+
getProvider(chainId: number): ethers.JsonRpcProvider;
|
|
217
249
|
/**
|
|
218
250
|
* Get the multicall contract
|
|
219
251
|
* @param signer
|
|
220
252
|
*/
|
|
221
253
|
static getMulticall(signer: SignerOrProvider): Promise<ethers.Contract>;
|
|
222
254
|
/**
|
|
223
|
-
* Get the
|
|
224
|
-
* @param signer
|
|
255
|
+
* Get the project resolver contract
|
|
256
|
+
* @param signer - The signer or provider to use
|
|
257
|
+
* @param rpcConfig - RPC URL configuration (required when chainId is provided)
|
|
258
|
+
* @param chainId - Optional chain ID to use a different chain than the signer's
|
|
225
259
|
*/
|
|
226
260
|
static getProjectResolver(signer: SignerOrProvider & {
|
|
227
261
|
getChainId?: () => Promise<number>;
|
|
228
|
-
}, chainId?: number): Promise<ethers.Contract>;
|
|
262
|
+
}, rpcConfig?: GAPRpcConfig, chainId?: number): Promise<ethers.Contract>;
|
|
229
263
|
/**
|
|
230
|
-
* Get the
|
|
231
|
-
* @param signer
|
|
264
|
+
* Get the community resolver contract
|
|
265
|
+
* @param signer - The signer or provider to use
|
|
266
|
+
* @param rpcConfig - RPC URL configuration (required when chainId is provided)
|
|
267
|
+
* @param chainId - Optional chain ID to use a different chain than the signer's
|
|
232
268
|
*/
|
|
233
269
|
static getCommunityResolver(signer: SignerOrProvider & {
|
|
234
270
|
getChainId?: () => Promise<number>;
|
|
235
|
-
}, chainId?: number): Promise<ethers.Contract>;
|
|
271
|
+
}, rpcConfig?: GAPRpcConfig, chainId?: number): Promise<ethers.Contract>;
|
|
236
272
|
get schemas(): GapSchema[];
|
|
237
273
|
/**
|
|
238
274
|
* Defined if the transactions will be gasless or not.
|
|
@@ -249,6 +285,5 @@ export declare class GAP extends Facade {
|
|
|
249
285
|
*/
|
|
250
286
|
static get gelatoOpts(): GAPArgs["gelatoOpts"];
|
|
251
287
|
static set useGasLess(useGasLess: boolean);
|
|
252
|
-
static get remoteClient(): RemoteStorage<unknown>;
|
|
253
288
|
}
|
|
254
289
|
export {};
|
package/core/class/GAP.js
CHANGED
|
@@ -83,16 +83,10 @@ class GAP extends types_1.Facade {
|
|
|
83
83
|
* @returns The singleton instance of GAP for the specified network
|
|
84
84
|
*/
|
|
85
85
|
static getInstance(args) {
|
|
86
|
-
if (!args) {
|
|
87
|
-
throw new Error("Network must be specified when getting GAP instance");
|
|
88
|
-
}
|
|
89
86
|
const existingInstance = GAP.instances.get(args.network);
|
|
90
87
|
if (existingInstance) {
|
|
91
88
|
return existingInstance;
|
|
92
89
|
}
|
|
93
|
-
if (!args) {
|
|
94
|
-
throw new Error("Initialization arguments required for first instance");
|
|
95
|
-
}
|
|
96
90
|
const newInstance = new GAP(args);
|
|
97
91
|
GAP.instances.set(args.network, newInstance);
|
|
98
92
|
return newInstance;
|
|
@@ -132,6 +126,7 @@ class GAP extends types_1.Facade {
|
|
|
132
126
|
};
|
|
133
127
|
const schemas = args.schemas || Object.values((0, consts_1.MountEntities)(consts_1.Networks[args.network]));
|
|
134
128
|
this.network = args.network;
|
|
129
|
+
this.rpcConfig = args.rpcUrls ?? {};
|
|
135
130
|
this._eas = new eas_sdk_1.EAS(consts_1.Networks[args.network].contracts.eas);
|
|
136
131
|
this.fetch =
|
|
137
132
|
args.apiClient ||
|
|
@@ -141,7 +136,6 @@ class GAP extends types_1.Facade {
|
|
|
141
136
|
this.fetch.gapInstance = this;
|
|
142
137
|
this.assertGelatoOpts(args);
|
|
143
138
|
GAP._gelatoOpts = args.gelatoOpts;
|
|
144
|
-
GAP.remoteStorage = args.remoteStorage;
|
|
145
139
|
this._schemas = schemas.map((schema) => new GapSchema_1.GapSchema(schema, this, false, args.globalSchemas ? !args.globalSchemas : false));
|
|
146
140
|
Schema_1.Schema.validate(this.network);
|
|
147
141
|
console.info(`Loaded GAP SDK v${package_json_1.version} for network ${this.network}`);
|
|
@@ -207,6 +201,16 @@ class GAP extends types_1.Facade {
|
|
|
207
201
|
const schemas = Schema_1.Schema.getMany(names, this.network);
|
|
208
202
|
return schemas.map((s) => GapSchema_1.GapSchema.clone(s));
|
|
209
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* Get a Web3 provider for a specific chain ID using this instance's RPC configuration.
|
|
206
|
+
*
|
|
207
|
+
* @param chainId - The chain ID to get a provider for
|
|
208
|
+
* @returns An ethers JsonRpcProvider for the specified chain
|
|
209
|
+
* @throws Error if no RPC URL is configured for the chain ID
|
|
210
|
+
*/
|
|
211
|
+
getProvider(chainId) {
|
|
212
|
+
return (0, get_web3_provider_1.getWeb3Provider)(chainId, this.rpcConfig);
|
|
213
|
+
}
|
|
210
214
|
/**
|
|
211
215
|
* Get the multicall contract
|
|
212
216
|
* @param signer
|
|
@@ -220,28 +224,52 @@ class GAP extends types_1.Facade {
|
|
|
220
224
|
return new ethers_1.ethers.Contract(address, MultiAttester_json_1.default, signer);
|
|
221
225
|
}
|
|
222
226
|
/**
|
|
223
|
-
* Get the
|
|
224
|
-
* @param signer
|
|
227
|
+
* Get the project resolver contract
|
|
228
|
+
* @param signer - The signer or provider to use
|
|
229
|
+
* @param rpcConfig - RPC URL configuration (required when chainId is provided)
|
|
230
|
+
* @param chainId - Optional chain ID to use a different chain than the signer's
|
|
225
231
|
*/
|
|
226
|
-
static async getProjectResolver(signer, chainId) {
|
|
232
|
+
static async getProjectResolver(signer, rpcConfig, chainId) {
|
|
227
233
|
const currentChainId = chainId ||
|
|
228
234
|
Number((await signer.provider.getNetwork())?.chainId ||
|
|
229
235
|
(await signer.getChainId()));
|
|
230
|
-
|
|
236
|
+
if (chainId && !rpcConfig) {
|
|
237
|
+
throw new Error(`rpcConfig is required when specifying chainId for cross-chain operations. ` +
|
|
238
|
+
`Either provide rpcConfig or omit chainId to use the signer's chain.`);
|
|
239
|
+
}
|
|
240
|
+
const provider = chainId && rpcConfig
|
|
241
|
+
? (0, get_web3_provider_1.getWeb3Provider)(chainId, rpcConfig)
|
|
242
|
+
: signer;
|
|
231
243
|
const network = Object.values(consts_1.Networks).find((n) => +n.chainId === Number(currentChainId));
|
|
244
|
+
if (!network) {
|
|
245
|
+
throw new Error(`Network with chain ID ${currentChainId} is not supported. ` +
|
|
246
|
+
`Supported networks: ${Object.keys(consts_1.Networks).join(", ")}`);
|
|
247
|
+
}
|
|
232
248
|
const address = network.contracts.projectResolver;
|
|
233
249
|
return new ethers_1.ethers.Contract(address, ProjectResolver_json_1.default, provider);
|
|
234
250
|
}
|
|
235
251
|
/**
|
|
236
|
-
* Get the
|
|
237
|
-
* @param signer
|
|
252
|
+
* Get the community resolver contract
|
|
253
|
+
* @param signer - The signer or provider to use
|
|
254
|
+
* @param rpcConfig - RPC URL configuration (required when chainId is provided)
|
|
255
|
+
* @param chainId - Optional chain ID to use a different chain than the signer's
|
|
238
256
|
*/
|
|
239
|
-
static async getCommunityResolver(signer, chainId) {
|
|
257
|
+
static async getCommunityResolver(signer, rpcConfig, chainId) {
|
|
240
258
|
const currentChainId = chainId ||
|
|
241
259
|
Number((await signer.provider.getNetwork())?.chainId ||
|
|
242
260
|
(await signer.getChainId()));
|
|
243
|
-
|
|
261
|
+
if (chainId && !rpcConfig) {
|
|
262
|
+
throw new Error(`rpcConfig is required when specifying chainId for cross-chain operations. ` +
|
|
263
|
+
`Either provide rpcConfig or omit chainId to use the signer's chain.`);
|
|
264
|
+
}
|
|
265
|
+
const provider = chainId && rpcConfig
|
|
266
|
+
? (0, get_web3_provider_1.getWeb3Provider)(chainId, rpcConfig)
|
|
267
|
+
: signer;
|
|
244
268
|
const network = Object.values(consts_1.Networks).find((n) => +n.chainId === Number(currentChainId));
|
|
269
|
+
if (!network) {
|
|
270
|
+
throw new Error(`Network with chain ID ${currentChainId} is not supported. ` +
|
|
271
|
+
`Supported networks: ${Object.keys(consts_1.Networks).join(", ")}`);
|
|
272
|
+
}
|
|
245
273
|
const address = network.contracts.communityResolver;
|
|
246
274
|
return new ethers_1.ethers.Contract(address, CommunityResolverABI_json_1.default, provider);
|
|
247
275
|
}
|
|
@@ -280,9 +308,6 @@ class GAP extends types_1.Facade {
|
|
|
280
308
|
}
|
|
281
309
|
this._gelatoOpts.useGasless = useGasLess;
|
|
282
310
|
}
|
|
283
|
-
static get remoteClient() {
|
|
284
|
-
return this.remoteStorage;
|
|
285
|
-
}
|
|
286
311
|
}
|
|
287
312
|
exports.GAP = GAP;
|
|
288
313
|
GAP.instances = new Map();
|
|
@@ -3,15 +3,13 @@ export declare class AlloBase {
|
|
|
3
3
|
private signer;
|
|
4
4
|
private contract;
|
|
5
5
|
private allo;
|
|
6
|
-
|
|
7
|
-
constructor(signer: ethers.Signer, pinataJWTToken: string, chainId: number);
|
|
8
|
-
saveAndGetCID(data: any, pinataMetadata?: {
|
|
9
|
-
name: string;
|
|
10
|
-
}): Promise<any>;
|
|
6
|
+
constructor(signer: ethers.Signer, chainId: number);
|
|
11
7
|
encodeStrategyInitData(applicationStart: number, applicationEnd: number, roundStart: number, roundEnd: number, payoutToken: string): Promise<string>;
|
|
12
|
-
createGrant(args: any
|
|
8
|
+
createGrant(args: any & {
|
|
9
|
+
metadataCid: string;
|
|
10
|
+
}, callback?: Function): Promise<{
|
|
13
11
|
poolId: string;
|
|
14
12
|
txHash: string;
|
|
15
13
|
}>;
|
|
16
|
-
updatePoolMetadata(poolId: string,
|
|
14
|
+
updatePoolMetadata(poolId: string, metadataCid: string, callback?: Function): Promise<any>;
|
|
17
15
|
}
|
|
@@ -9,32 +9,13 @@ const Allo_json_1 = __importDefault(require("../../abi/Allo.json"));
|
|
|
9
9
|
const consts_1 = require("../../consts");
|
|
10
10
|
const ethers_2 = require("ethers");
|
|
11
11
|
const allo_v2_sdk_1 = require("@allo-team/allo-v2-sdk/");
|
|
12
|
-
const axios_1 = __importDefault(require("axios"));
|
|
13
12
|
// ABI fragment for the Initialized event
|
|
14
13
|
const INITIALIZED_EVENT = ["event Initialized(uint256 poolId, bytes data)"];
|
|
15
14
|
class AlloBase {
|
|
16
|
-
constructor(signer,
|
|
15
|
+
constructor(signer, chainId) {
|
|
17
16
|
this.signer = signer;
|
|
18
17
|
this.contract = new ethers_1.ethers.Contract(consts_1.AlloContracts.alloProxy, Allo_json_1.default, signer);
|
|
19
18
|
this.allo = new allo_v2_sdk_1.Allo({ chain: chainId });
|
|
20
|
-
this.pinataJWTToken = pinataJWTToken;
|
|
21
|
-
}
|
|
22
|
-
async saveAndGetCID(data, pinataMetadata = { name: "via karma-gap-sdk" }) {
|
|
23
|
-
try {
|
|
24
|
-
const res = await axios_1.default.post("https://api.pinata.cloud/pinning/pinJSONToIPFS", {
|
|
25
|
-
pinataContent: data,
|
|
26
|
-
pinataMetadata: pinataMetadata,
|
|
27
|
-
}, {
|
|
28
|
-
headers: {
|
|
29
|
-
"Content-Type": "application/json",
|
|
30
|
-
Authorization: `Bearer ${this.pinataJWTToken}`,
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
return res.data.IpfsHash;
|
|
34
|
-
}
|
|
35
|
-
catch (error) {
|
|
36
|
-
console.log(error);
|
|
37
|
-
}
|
|
38
19
|
}
|
|
39
20
|
async encodeStrategyInitData(applicationStart, applicationEnd, roundStart, roundEnd, payoutToken) {
|
|
40
21
|
const encoder = new ethers_2.AbiCoder();
|
|
@@ -54,13 +35,9 @@ class AlloBase {
|
|
|
54
35
|
const walletBalance = await this.signer.provider.getBalance(await this.signer.getAddress());
|
|
55
36
|
console.log("Wallet balance:", (0, ethers_1.formatEther)(walletBalance.toString()), " ETH");
|
|
56
37
|
try {
|
|
57
|
-
const metadata_cid = await this.saveAndGetCID({
|
|
58
|
-
round: args.roundMetadata,
|
|
59
|
-
application: args.applicationMetadata,
|
|
60
|
-
});
|
|
61
38
|
const metadata = {
|
|
62
39
|
protocol: BigInt(1),
|
|
63
|
-
pointer:
|
|
40
|
+
pointer: args.metadataCid,
|
|
64
41
|
};
|
|
65
42
|
const initStrategyData = (await this.encodeStrategyInitData(args.applicationStart, args.applicationEnd, args.roundStart, args.roundEnd, args.payoutToken));
|
|
66
43
|
const createPoolArgs = {
|
|
@@ -114,13 +91,12 @@ class AlloBase {
|
|
|
114
91
|
throw new Error(`Failed to create pool metadata: ${error}`);
|
|
115
92
|
}
|
|
116
93
|
}
|
|
117
|
-
async updatePoolMetadata(poolId,
|
|
94
|
+
async updatePoolMetadata(poolId, metadataCid, callback) {
|
|
118
95
|
try {
|
|
119
96
|
callback?.("preparing");
|
|
120
|
-
const metadata_cid = await this.saveAndGetCID(poolMetadata);
|
|
121
97
|
const metadata = {
|
|
122
98
|
protocol: 1,
|
|
123
|
-
pointer:
|
|
99
|
+
pointer: metadataCid,
|
|
124
100
|
};
|
|
125
101
|
const tx = await this.contract.updatePoolMetadata(poolId, metadata);
|
|
126
102
|
callback?.("pending");
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import { ethers } from "ethers";
|
|
2
|
-
import { ProfileMetadata } from "../types/allo";
|
|
3
2
|
export declare class AlloRegistry {
|
|
4
3
|
private contract;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
saveAndGetCID(data: any, pinataMetadata?: {
|
|
8
|
-
name: string;
|
|
9
|
-
}): Promise<any>;
|
|
10
|
-
createProgram(nonce: number, name: string, profileMetadata: ProfileMetadata, owner: string, members: string[]): Promise<{
|
|
4
|
+
constructor(signer: ethers.Signer);
|
|
5
|
+
createProgram(nonce: number, name: string, metadataCid: string, owner: string, members: string[]): Promise<{
|
|
11
6
|
profileId: any;
|
|
12
7
|
txHash: any;
|
|
13
8
|
}>;
|
|
14
|
-
updateProgramMetadata(profileId: string,
|
|
9
|
+
updateProgramMetadata(profileId: string, metadataCid: string): Promise<any>;
|
|
15
10
|
}
|
|
@@ -7,36 +7,16 @@ exports.AlloRegistry = void 0;
|
|
|
7
7
|
const ethers_1 = require("ethers");
|
|
8
8
|
const AlloRegistry_json_1 = __importDefault(require("../../abi/AlloRegistry.json"));
|
|
9
9
|
const consts_1 = require("../../consts");
|
|
10
|
-
const axios_1 = __importDefault(require("axios"));
|
|
11
10
|
class AlloRegistry {
|
|
12
|
-
constructor(signer
|
|
11
|
+
constructor(signer) {
|
|
13
12
|
this.contract = new ethers_1.ethers.Contract(consts_1.AlloContracts.registry, AlloRegistry_json_1.default, signer);
|
|
14
|
-
this.pinataJWTToken = pinataJWTToken;
|
|
15
13
|
}
|
|
16
|
-
async
|
|
17
|
-
try {
|
|
18
|
-
const res = await axios_1.default.post("https://api.pinata.cloud/pinning/pinJSONToIPFS", {
|
|
19
|
-
pinataContent: data,
|
|
20
|
-
pinataMetadata: pinataMetadata,
|
|
21
|
-
}, {
|
|
22
|
-
headers: {
|
|
23
|
-
"Content-Type": "application/json",
|
|
24
|
-
Authorization: `Bearer ${this.pinataJWTToken}`,
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
return res.data.IpfsHash;
|
|
28
|
-
}
|
|
29
|
-
catch (error) {
|
|
30
|
-
console.log(error);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
async createProgram(nonce, name, profileMetadata, owner, members) {
|
|
14
|
+
async createProgram(nonce, name, metadataCid, owner, members) {
|
|
34
15
|
console.log("Creating program...");
|
|
35
16
|
try {
|
|
36
|
-
const metadata_cid = await this.saveAndGetCID(profileMetadata);
|
|
37
17
|
const metadata = {
|
|
38
18
|
protocol: 1,
|
|
39
|
-
pointer:
|
|
19
|
+
pointer: metadataCid,
|
|
40
20
|
};
|
|
41
21
|
const tx = await this.contract.createProfile(nonce, name, metadata, owner, members);
|
|
42
22
|
const receipt = await tx.wait();
|
|
@@ -51,12 +31,11 @@ class AlloRegistry {
|
|
|
51
31
|
console.error(`Failed to register program: ${error}`);
|
|
52
32
|
}
|
|
53
33
|
}
|
|
54
|
-
async updateProgramMetadata(profileId,
|
|
34
|
+
async updateProgramMetadata(profileId, metadataCid) {
|
|
55
35
|
try {
|
|
56
|
-
const metadata_cid = await this.saveAndGetCID(profileMetadata);
|
|
57
36
|
const metadata = {
|
|
58
37
|
protocol: 1,
|
|
59
|
-
pointer:
|
|
38
|
+
pointer: metadataCid,
|
|
60
39
|
};
|
|
61
40
|
const tx = await this.contract.updateProfileMetadata(profileId, metadata);
|
|
62
41
|
const receipt = await tx.wait();
|
package/core/class/Schema.d.ts
CHANGED
|
@@ -135,16 +135,11 @@ export declare abstract class Schema<T extends string = string> implements Schem
|
|
|
135
135
|
/**
|
|
136
136
|
* Validates and attests a given schema.
|
|
137
137
|
*
|
|
138
|
-
* This function checks a schema against predefined standards or rules
|
|
139
|
-
*
|
|
140
|
-
* returns the CID (Content Identifier) within the Attestation Body, providing a reference to the data on IPFS.
|
|
141
|
-
*
|
|
142
|
-
* Usage:
|
|
143
|
-
* - Ensure that the schema to be attested conforms to the required format.
|
|
144
|
-
* - Enable 'ipfsKey' if you wish to store the data on IPFS and retrieve its CID.
|
|
138
|
+
* This function checks a schema against predefined standards or rules and creates
|
|
139
|
+
* an attestation on-chain.
|
|
145
140
|
*
|
|
146
141
|
* @param {Object} param0 - An object containing the schema and other optional settings.
|
|
147
|
-
* @returns {Object} An object containing the attestation results
|
|
142
|
+
* @returns {Object} An object containing the attestation results.
|
|
148
143
|
*/
|
|
149
144
|
attest<T>({ data, to, signer, refUID, callback, }: AttestArgs<T>): Promise<AttestationWithTx>;
|
|
150
145
|
/**
|
package/core/class/Schema.js
CHANGED
|
@@ -208,16 +208,11 @@ class Schema {
|
|
|
208
208
|
/**
|
|
209
209
|
* Validates and attests a given schema.
|
|
210
210
|
*
|
|
211
|
-
* This function checks a schema against predefined standards or rules
|
|
212
|
-
*
|
|
213
|
-
* returns the CID (Content Identifier) within the Attestation Body, providing a reference to the data on IPFS.
|
|
214
|
-
*
|
|
215
|
-
* Usage:
|
|
216
|
-
* - Ensure that the schema to be attested conforms to the required format.
|
|
217
|
-
* - Enable 'ipfsKey' if you wish to store the data on IPFS and retrieve its CID.
|
|
211
|
+
* This function checks a schema against predefined standards or rules and creates
|
|
212
|
+
* an attestation on-chain.
|
|
218
213
|
*
|
|
219
214
|
* @param {Object} param0 - An object containing the schema and other optional settings.
|
|
220
|
-
* @returns {Object} An object containing the attestation results
|
|
215
|
+
* @returns {Object} An object containing the attestation results.
|
|
221
216
|
*/
|
|
222
217
|
async attest({ data, to, signer, refUID, callback, }) {
|
|
223
218
|
const eas = this.gap.eas.connect(signer);
|
|
@@ -14,7 +14,6 @@ declare const SchemaErrorCodes: {
|
|
|
14
14
|
INVALID_REF_UID: number;
|
|
15
15
|
REVOKATION_ERROR: number;
|
|
16
16
|
NOT_REVOCABLE: number;
|
|
17
|
-
REMOTE_STORAGE_UPLOAD: number;
|
|
18
17
|
};
|
|
19
18
|
export declare class SchemaError extends Error {
|
|
20
19
|
readonly code: number;
|
|
@@ -25,6 +24,4 @@ export declare class SchemaError extends Error {
|
|
|
25
24
|
}
|
|
26
25
|
export declare class AttestationError extends SchemaError {
|
|
27
26
|
}
|
|
28
|
-
export declare class RemoteStorageError extends SchemaError {
|
|
29
|
-
}
|
|
30
27
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.AttestationError = exports.SchemaError = void 0;
|
|
4
4
|
const SchemaErrorCodes = {
|
|
5
5
|
INVALID_SCHEMA: 50001,
|
|
6
6
|
INVALID_SCHEMA_NAME: 50002,
|
|
@@ -17,7 +17,6 @@ const SchemaErrorCodes = {
|
|
|
17
17
|
INVALID_REF_UID: 50013,
|
|
18
18
|
REVOKATION_ERROR: 50014,
|
|
19
19
|
NOT_REVOCABLE: 50015,
|
|
20
|
-
REMOTE_STORAGE_UPLOAD: 50016,
|
|
21
20
|
};
|
|
22
21
|
class SchemaError extends Error {
|
|
23
22
|
constructor(code, append, originalError) {
|
|
@@ -34,6 +33,3 @@ exports.SchemaError = SchemaError;
|
|
|
34
33
|
class AttestationError extends SchemaError {
|
|
35
34
|
}
|
|
36
35
|
exports.AttestationError = AttestationError;
|
|
37
|
-
class RemoteStorageError extends SchemaError {
|
|
38
|
-
}
|
|
39
|
-
exports.RemoteStorageError = RemoteStorageError;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MultiRevocationRequest } from "@ethereum-attestation-service/eas-sdk";
|
|
2
|
-
import { CallbackStatus, Hex, RawAttestationPayload, RawMultiAttestPayload, SignerOrProvider } from "core/types";
|
|
2
|
+
import { CallbackStatus, GAPRpcConfig, Hex, RawAttestationPayload, RawMultiAttestPayload, SignerOrProvider } from "core/types";
|
|
3
3
|
import { Transaction } from "ethers";
|
|
4
4
|
import { AttestationWithTx } from "../types/attestations";
|
|
5
5
|
export declare class GapContract {
|
|
@@ -66,22 +66,24 @@ export declare class GapContract {
|
|
|
66
66
|
static transferProjectOwnership(signer: SignerOrProvider, projectUID: Hex, newOwner: Hex): Promise<any>;
|
|
67
67
|
/**
|
|
68
68
|
* Check if the signer is the owner of the project
|
|
69
|
-
* @param signer
|
|
70
|
-
* @param projectUID
|
|
71
|
-
* @param projectChainId
|
|
72
|
-
* @param publicAddress
|
|
73
|
-
* @
|
|
69
|
+
* @param signer - Signer or provider
|
|
70
|
+
* @param projectUID - The project UID
|
|
71
|
+
* @param projectChainId - The chain ID where the project exists
|
|
72
|
+
* @param publicAddress - Optional public address to check (uses signer address if not provided)
|
|
73
|
+
* @param rpcConfig - Optional RPC config for cross-chain operations. If not provided, uses the signer's chain.
|
|
74
|
+
* @returns Whether the address is a project owner
|
|
74
75
|
*/
|
|
75
|
-
static isProjectOwner(signer: SignerOrProvider, projectUID: Hex, projectChainId: number, publicAddress?: string): Promise<boolean>;
|
|
76
|
+
static isProjectOwner(signer: SignerOrProvider, projectUID: Hex, projectChainId: number, publicAddress?: string, rpcConfig?: GAPRpcConfig): Promise<boolean>;
|
|
76
77
|
/**
|
|
77
78
|
* Check if the signer is admin of the project
|
|
78
|
-
* @param signer
|
|
79
|
-
* @param projectUID
|
|
80
|
-
* @param projectChainId
|
|
81
|
-
* @param publicAddress
|
|
82
|
-
* @
|
|
79
|
+
* @param signer - Signer or provider
|
|
80
|
+
* @param projectUID - The project UID
|
|
81
|
+
* @param projectChainId - The chain ID where the project exists
|
|
82
|
+
* @param publicAddress - Optional public address to check (uses signer address if not provided)
|
|
83
|
+
* @param rpcConfig - Optional RPC config for cross-chain operations. If not provided, uses the signer's chain.
|
|
84
|
+
* @returns Whether the address is a project admin
|
|
83
85
|
*/
|
|
84
|
-
static isProjectAdmin(signer: SignerOrProvider, projectUID: Hex, projectChainId: number, publicAddress?: string): Promise<boolean>;
|
|
86
|
+
static isProjectAdmin(signer: SignerOrProvider, projectUID: Hex, projectChainId: number, publicAddress?: string, rpcConfig?: GAPRpcConfig): Promise<boolean>;
|
|
85
87
|
private static getTransactionLogs;
|
|
86
88
|
/**
|
|
87
89
|
* Add Project Admin
|
|
@@ -222,28 +222,30 @@ class GapContract {
|
|
|
222
222
|
}
|
|
223
223
|
/**
|
|
224
224
|
* Check if the signer is the owner of the project
|
|
225
|
-
* @param signer
|
|
226
|
-
* @param projectUID
|
|
227
|
-
* @param projectChainId
|
|
228
|
-
* @param publicAddress
|
|
229
|
-
* @
|
|
225
|
+
* @param signer - Signer or provider
|
|
226
|
+
* @param projectUID - The project UID
|
|
227
|
+
* @param projectChainId - The chain ID where the project exists
|
|
228
|
+
* @param publicAddress - Optional public address to check (uses signer address if not provided)
|
|
229
|
+
* @param rpcConfig - Optional RPC config for cross-chain operations. If not provided, uses the signer's chain.
|
|
230
|
+
* @returns Whether the address is a project owner
|
|
230
231
|
*/
|
|
231
|
-
static async isProjectOwner(signer, projectUID, projectChainId, publicAddress) {
|
|
232
|
-
const contract = await GAP_1.GAP.getProjectResolver(signer, projectChainId);
|
|
232
|
+
static async isProjectOwner(signer, projectUID, projectChainId, publicAddress, rpcConfig) {
|
|
233
|
+
const contract = await GAP_1.GAP.getProjectResolver(signer, rpcConfig, projectChainId);
|
|
233
234
|
const address = publicAddress || (await this.getSignerAddress(signer));
|
|
234
235
|
const isOwner = await contract.isOwner(projectUID, address);
|
|
235
236
|
return isOwner;
|
|
236
237
|
}
|
|
237
238
|
/**
|
|
238
239
|
* Check if the signer is admin of the project
|
|
239
|
-
* @param signer
|
|
240
|
-
* @param projectUID
|
|
241
|
-
* @param projectChainId
|
|
242
|
-
* @param publicAddress
|
|
243
|
-
* @
|
|
240
|
+
* @param signer - Signer or provider
|
|
241
|
+
* @param projectUID - The project UID
|
|
242
|
+
* @param projectChainId - The chain ID where the project exists
|
|
243
|
+
* @param publicAddress - Optional public address to check (uses signer address if not provided)
|
|
244
|
+
* @param rpcConfig - Optional RPC config for cross-chain operations. If not provided, uses the signer's chain.
|
|
245
|
+
* @returns Whether the address is a project admin
|
|
244
246
|
*/
|
|
245
|
-
static async isProjectAdmin(signer, projectUID, projectChainId, publicAddress) {
|
|
246
|
-
const contract = await GAP_1.GAP.getProjectResolver(signer, projectChainId);
|
|
247
|
+
static async isProjectAdmin(signer, projectUID, projectChainId, publicAddress, rpcConfig) {
|
|
248
|
+
const contract = await GAP_1.GAP.getProjectResolver(signer, rpcConfig, projectChainId);
|
|
247
249
|
const address = publicAddress || (await this.getSignerAddress(signer));
|
|
248
250
|
const isAdmin = await contract.isAdmin(projectUID, address);
|
|
249
251
|
return isAdmin;
|
package/core/class/index.d.ts
CHANGED
package/core/class/index.js
CHANGED
|
@@ -22,5 +22,3 @@ __exportStar(require("./SchemaError"), exports);
|
|
|
22
22
|
__exportStar(require("./entities"), exports);
|
|
23
23
|
__exportStar(require("./Fetcher"), exports);
|
|
24
24
|
__exportStar(require("./karma-indexer/GapIndexerClient"), exports);
|
|
25
|
-
__exportStar(require("./remote-storage/IpfsStorage"), exports);
|
|
26
|
-
__exportStar(require("./remote-storage/RemoteStorage"), exports);
|
|
@@ -2,72 +2,72 @@ import { AxiosGQL } from "../../GraphQL/AxiosGQL";
|
|
|
2
2
|
import { Hex, IAttestationResponse, ICommunityResponse, ICommunityAdminsResponse, IGrantResponse, IProjectResponse, ISearchResponse, IProjectMilestoneResponse, ITrackResponse, ITrackAssignmentResponse, IProjectTrackResponse } from "./types";
|
|
3
3
|
export declare class GapIndexerApi extends AxiosGQL {
|
|
4
4
|
constructor(url: string);
|
|
5
|
-
attestation(uid: Hex): Promise<import("axios").AxiosResponse<IAttestationResponse, any>>;
|
|
6
|
-
attestations(schemaUID: string, search?: string): Promise<import("axios").AxiosResponse<IAttestationResponse[], any>>;
|
|
7
|
-
attestationsOf(schemaUID: string, attester: Hex): Promise<import("axios").AxiosResponse<IAttestationResponse[], any>>;
|
|
5
|
+
attestation(uid: Hex): Promise<import("axios").AxiosResponse<IAttestationResponse, any, {}>>;
|
|
6
|
+
attestations(schemaUID: string, search?: string): Promise<import("axios").AxiosResponse<IAttestationResponse[], any, {}>>;
|
|
7
|
+
attestationsOf(schemaUID: string, attester: Hex): Promise<import("axios").AxiosResponse<IAttestationResponse[], any, {}>>;
|
|
8
8
|
/**
|
|
9
9
|
* Community
|
|
10
10
|
*/
|
|
11
|
-
communities(search?: string): Promise<import("axios").AxiosResponse<ICommunityResponse[], any>>;
|
|
12
|
-
communitiesOf(address: Hex, withGrants: boolean): Promise<import("axios").AxiosResponse<ICommunityResponse[], any>>;
|
|
13
|
-
adminOf(address: Hex): Promise<import("axios").AxiosResponse<ICommunityResponse[], any>>;
|
|
14
|
-
communityBySlug(slug: string): Promise<import("axios").AxiosResponse<ICommunityResponse, any>>;
|
|
15
|
-
communityAdmins(uid: Hex): Promise<import("axios").AxiosResponse<ICommunityAdminsResponse, any>>;
|
|
11
|
+
communities(search?: string): Promise<import("axios").AxiosResponse<ICommunityResponse[], any, {}>>;
|
|
12
|
+
communitiesOf(address: Hex, withGrants: boolean): Promise<import("axios").AxiosResponse<ICommunityResponse[], any, {}>>;
|
|
13
|
+
adminOf(address: Hex): Promise<import("axios").AxiosResponse<ICommunityResponse[], any, {}>>;
|
|
14
|
+
communityBySlug(slug: string): Promise<import("axios").AxiosResponse<ICommunityResponse, any, {}>>;
|
|
15
|
+
communityAdmins(uid: Hex): Promise<import("axios").AxiosResponse<ICommunityAdminsResponse, any, {}>>;
|
|
16
16
|
/**
|
|
17
17
|
* Project
|
|
18
18
|
*/
|
|
19
|
-
projectBySlug(slug: string): Promise<import("axios").AxiosResponse<IProjectResponse, any>>;
|
|
20
|
-
search(query: string): Promise<import("axios").AxiosResponse<ISearchResponse, any>>;
|
|
21
|
-
searchProjects(query: string): Promise<import("axios").AxiosResponse<IProjectResponse[], any>>;
|
|
22
|
-
projects(name?: string): Promise<import("axios").AxiosResponse<IProjectResponse[], any>>;
|
|
23
|
-
projectsOf(grantee: Hex): Promise<import("axios").AxiosResponse<IProjectResponse[], any>>;
|
|
24
|
-
projectMilestones(uidOrSlug: string): Promise<import("axios").AxiosResponse<IProjectMilestoneResponse[], any>>;
|
|
19
|
+
projectBySlug(slug: string): Promise<import("axios").AxiosResponse<IProjectResponse, any, {}>>;
|
|
20
|
+
search(query: string): Promise<import("axios").AxiosResponse<ISearchResponse, any, {}>>;
|
|
21
|
+
searchProjects(query: string): Promise<import("axios").AxiosResponse<IProjectResponse[], any, {}>>;
|
|
22
|
+
projects(name?: string): Promise<import("axios").AxiosResponse<IProjectResponse[], any, {}>>;
|
|
23
|
+
projectsOf(grantee: Hex): Promise<import("axios").AxiosResponse<IProjectResponse[], any, {}>>;
|
|
24
|
+
projectMilestones(uidOrSlug: string): Promise<import("axios").AxiosResponse<IProjectMilestoneResponse[], any, {}>>;
|
|
25
25
|
/**
|
|
26
26
|
* Grantee
|
|
27
27
|
*/
|
|
28
|
-
grantee(address: Hex): Promise<import("axios").AxiosResponse<any, any>>;
|
|
28
|
+
grantee(address: Hex): Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
29
29
|
grantees(): Promise<import("axios").AxiosResponse<{
|
|
30
30
|
[key: `0x${string}`]: {
|
|
31
31
|
grants: number;
|
|
32
32
|
projects: number;
|
|
33
33
|
};
|
|
34
|
-
}, any>>;
|
|
34
|
+
}, any, {}>>;
|
|
35
35
|
/**
|
|
36
36
|
* Grant
|
|
37
37
|
*/
|
|
38
|
-
grantsOf(grantee: Hex, withCommunity?: boolean): Promise<import("axios").AxiosResponse<IGrantResponse[], any>>;
|
|
39
|
-
grantsFor(uid: string, withCommunity?: boolean): Promise<import("axios").AxiosResponse<IGrantResponse[], any>>;
|
|
40
|
-
grantsForExtProject(projectExtId: string): Promise<import("axios").AxiosResponse<IGrantResponse[], any>>;
|
|
41
|
-
grantBySlug(slug: Hex): Promise<import("axios").AxiosResponse<IGrantResponse, any>>;
|
|
38
|
+
grantsOf(grantee: Hex, withCommunity?: boolean): Promise<import("axios").AxiosResponse<IGrantResponse[], any, {}>>;
|
|
39
|
+
grantsFor(uid: string, withCommunity?: boolean): Promise<import("axios").AxiosResponse<IGrantResponse[], any, {}>>;
|
|
40
|
+
grantsForExtProject(projectExtId: string): Promise<import("axios").AxiosResponse<IGrantResponse[], any, {}>>;
|
|
41
|
+
grantBySlug(slug: Hex): Promise<import("axios").AxiosResponse<IGrantResponse, any, {}>>;
|
|
42
42
|
grantsByCommunity(uid: Hex, page?: number, pageLimit?: number): Promise<import("axios").AxiosResponse<{
|
|
43
43
|
data: IGrantResponse[];
|
|
44
|
-
}, any>>;
|
|
44
|
+
}, any, {}>>;
|
|
45
45
|
/**
|
|
46
46
|
* Milestone
|
|
47
47
|
*/
|
|
48
|
-
milestonesOf(uid: Hex): Promise<import("axios").AxiosResponse<any, any>>;
|
|
48
|
+
milestonesOf(uid: Hex): Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
49
49
|
slugExists(slug: string): Promise<boolean>;
|
|
50
50
|
/**
|
|
51
51
|
* Tracks
|
|
52
52
|
*/
|
|
53
|
-
getTracks(communityUID: string, includeArchived?: boolean): Promise<import("axios").AxiosResponse<ITrackResponse[], any>>;
|
|
54
|
-
getTrackById(id: string): Promise<import("axios").AxiosResponse<ITrackResponse, any>>;
|
|
53
|
+
getTracks(communityUID: string, includeArchived?: boolean): Promise<import("axios").AxiosResponse<ITrackResponse[], any, {}>>;
|
|
54
|
+
getTrackById(id: string): Promise<import("axios").AxiosResponse<ITrackResponse, any, {}>>;
|
|
55
55
|
createTrack(data: {
|
|
56
56
|
name: string;
|
|
57
57
|
description?: string;
|
|
58
58
|
communityUID: string;
|
|
59
|
-
}): Promise<import("axios").AxiosResponse<ITrackResponse, any>>;
|
|
59
|
+
}): Promise<import("axios").AxiosResponse<ITrackResponse, any, {}>>;
|
|
60
60
|
updateTrack(id: string, data: {
|
|
61
61
|
name?: string;
|
|
62
62
|
description?: string;
|
|
63
63
|
communityUID?: string;
|
|
64
|
-
}): Promise<import("axios").AxiosResponse<ITrackResponse, any>>;
|
|
65
|
-
archiveTrack(id: string): Promise<import("axios").AxiosResponse<ITrackResponse, any>>;
|
|
66
|
-
assignTracksToProgram(programId: string, trackIds: string[]): Promise<import("axios").AxiosResponse<ITrackAssignmentResponse[], any>>;
|
|
67
|
-
unassignTrackFromProgram(programId: string, trackId: string): Promise<import("axios").AxiosResponse<ITrackAssignmentResponse, any>>;
|
|
68
|
-
getTracksForProgram(programId: string): Promise<import("axios").AxiosResponse<ITrackResponse[], any>>;
|
|
69
|
-
getTracksForProject(projectId: string, programId: string, activeOnly?: boolean): Promise<import("axios").AxiosResponse<ITrackResponse[], any>>;
|
|
70
|
-
assignTracksToProject(projectId: string, programId: string, trackIds: string[]): Promise<import("axios").AxiosResponse<any[], any>>;
|
|
71
|
-
unassignTracksFromProject(projectId: string, programId: string, trackIds: string[]): Promise<import("axios").AxiosResponse<any[], any>>;
|
|
72
|
-
getProjectsByTrack(communityId: string, programId: string, trackId?: string): Promise<import("axios").AxiosResponse<IProjectTrackResponse[], any>>;
|
|
64
|
+
}): Promise<import("axios").AxiosResponse<ITrackResponse, any, {}>>;
|
|
65
|
+
archiveTrack(id: string): Promise<import("axios").AxiosResponse<ITrackResponse, any, {}>>;
|
|
66
|
+
assignTracksToProgram(programId: string, trackIds: string[]): Promise<import("axios").AxiosResponse<ITrackAssignmentResponse[], any, {}>>;
|
|
67
|
+
unassignTrackFromProgram(programId: string, trackId: string): Promise<import("axios").AxiosResponse<ITrackAssignmentResponse, any, {}>>;
|
|
68
|
+
getTracksForProgram(programId: string): Promise<import("axios").AxiosResponse<ITrackResponse[], any, {}>>;
|
|
69
|
+
getTracksForProject(projectId: string, programId: string, activeOnly?: boolean): Promise<import("axios").AxiosResponse<ITrackResponse[], any, {}>>;
|
|
70
|
+
assignTracksToProject(projectId: string, programId: string, trackIds: string[]): Promise<import("axios").AxiosResponse<any[], any, {}>>;
|
|
71
|
+
unassignTracksFromProject(projectId: string, programId: string, trackIds: string[]): Promise<import("axios").AxiosResponse<any[], any, {}>>;
|
|
72
|
+
getProjectsByTrack(communityId: string, programId: string, trackId?: string): Promise<import("axios").AxiosResponse<IProjectTrackResponse[], any, {}>>;
|
|
73
73
|
}
|
package/core/consts.js
CHANGED
|
@@ -43,7 +43,6 @@ exports.Networks = {
|
|
|
43
43
|
optimism: {
|
|
44
44
|
chainId: 10,
|
|
45
45
|
url: "https://optimism.easscan.org/graphql",
|
|
46
|
-
rpcUrl: "https://opt-mainnet.g.alchemy.com/v2/fx2SlVDrPbXwPMQT4v0lRT1PABA16Myl",
|
|
47
46
|
contracts: {
|
|
48
47
|
eas: "0x4200000000000000000000000000000000000021",
|
|
49
48
|
schema: "0x4200000000000000000000000000000000000020",
|
|
@@ -98,7 +97,6 @@ exports.Networks = {
|
|
|
98
97
|
"optimism-sepolia": {
|
|
99
98
|
chainId: 11155420,
|
|
100
99
|
url: "https://optimism-sepolia.easscan.org/graphql",
|
|
101
|
-
rpcUrl: "https://opt-sepolia.g.alchemy.com/v2/9FEqTNKmgO7X7ll92ALJrEih7Jjhldf-",
|
|
102
100
|
contracts: {
|
|
103
101
|
communityResolver: "0xa5B7bbFD545A1a816aa8cBE28a1F0F2Cca58363d",
|
|
104
102
|
eas: "0x4200000000000000000000000000000000000021",
|
|
@@ -153,7 +151,6 @@ exports.Networks = {
|
|
|
153
151
|
arbitrum: {
|
|
154
152
|
chainId: 42161,
|
|
155
153
|
url: "https://arbitrum.easscan.org/graphql",
|
|
156
|
-
rpcUrl: "https://arb-mainnet.g.alchemy.com/v2/okcKBSKXvLuSCbas6QWGvKuh-IcHHSOr",
|
|
157
154
|
contracts: {
|
|
158
155
|
eas: "0xbD75f629A22Dc1ceD33dDA0b68c546A1c035c458",
|
|
159
156
|
schema: "0xA310da9c5B885E7fb3fbA9D66E9Ba6Df512b78eB",
|
|
@@ -208,7 +205,6 @@ exports.Networks = {
|
|
|
208
205
|
sepolia: {
|
|
209
206
|
chainId: 11155111,
|
|
210
207
|
url: "https://sepolia.easscan.org/graphql",
|
|
211
|
-
rpcUrl: "https://eth-sepolia.g.alchemy.com/v2/_M6YQg_DoVKuMisaFHSVZL-EcdkTbhUi",
|
|
212
208
|
contracts: {
|
|
213
209
|
eas: "0xC2679fBD37d54388Ce493F1DB75320D236e1815e",
|
|
214
210
|
schema: "0x0a7E2Ff54e76B8E6659aedc9103FB21c038050D0",
|
|
@@ -237,7 +233,6 @@ exports.Networks = {
|
|
|
237
233
|
"base-sepolia": {
|
|
238
234
|
chainId: 84532,
|
|
239
235
|
url: "https://base-sepolia.easscan.org/graphql",
|
|
240
|
-
rpcUrl: "https://sepolia.base.org",
|
|
241
236
|
contracts: {
|
|
242
237
|
eas: "0x4200000000000000000000000000000000000021",
|
|
243
238
|
schema: "0x4200000000000000000000000000000000000020",
|
|
@@ -265,7 +260,6 @@ exports.Networks = {
|
|
|
265
260
|
celo: {
|
|
266
261
|
chainId: 42220,
|
|
267
262
|
url: "https://celo.easscan.org/graphql",
|
|
268
|
-
rpcUrl: "https://forno.celo.org",
|
|
269
263
|
contracts: {
|
|
270
264
|
eas: "0x72E1d8ccf5299fb36fEfD8CC4394B8ef7e98Af92",
|
|
271
265
|
schema: "0x5ece93bE4BDCF293Ed61FA78698B594F2135AF34",
|
|
@@ -320,7 +314,6 @@ exports.Networks = {
|
|
|
320
314
|
sei: {
|
|
321
315
|
chainId: 1329,
|
|
322
316
|
url: "https://sei.easscan.org/graphql",
|
|
323
|
-
rpcUrl: "https://muddy-orbital-arrow.sei-pacific.quiknode.pro/594552c3ab4ed4106b40402c16dba137ab279d40",
|
|
324
317
|
contracts: {
|
|
325
318
|
eas: "0x391020888b0adBA584A67693458b374e4141f838",
|
|
326
319
|
schema: "0x80A4B50f549a8271e10A6C8e79172cb56f35fD57",
|
|
@@ -375,7 +368,6 @@ exports.Networks = {
|
|
|
375
368
|
"sei-testnet": {
|
|
376
369
|
chainId: 1328,
|
|
377
370
|
url: "https://sei-testnet.easscan.org/graphql",
|
|
378
|
-
rpcUrl: "https://evm-rpc-testnet.sei-apis.com",
|
|
379
371
|
contracts: {
|
|
380
372
|
eas: "0x4F166ed0A038ECdEEefa7Dc508f15991762974Fe",
|
|
381
373
|
schema: "0x906a57aCa067178e76e6eBDF4C7b26CBcAEC0Edd",
|
|
@@ -403,7 +395,6 @@ exports.Networks = {
|
|
|
403
395
|
lisk: {
|
|
404
396
|
chainId: 1135,
|
|
405
397
|
url: "https://lisk.easscan.org/graphql",
|
|
406
|
-
rpcUrl: "https://lisk.drpc.org",
|
|
407
398
|
contracts: {
|
|
408
399
|
eas: "0x4200000000000000000000000000000000000021",
|
|
409
400
|
schema: "0x4200000000000000000000000000000000000020",
|
|
@@ -431,7 +422,6 @@ exports.Networks = {
|
|
|
431
422
|
scroll: {
|
|
432
423
|
chainId: 534352,
|
|
433
424
|
url: "https://scroll.easscan.org/graphql",
|
|
434
|
-
rpcUrl: "https://scroll-mainnet.g.alchemy.com/v2/SsQRSwtqtBMGmXQCDH9lYb4U8p9QnqXK",
|
|
435
425
|
contracts: {
|
|
436
426
|
eas: "0xC47300428b6AD2c7D03BB76D05A176058b47E6B0",
|
|
437
427
|
schema: "0xD2CDF46556543316e7D34e8eDc4624e2bB95e3B6",
|
|
@@ -445,21 +435,47 @@ exports.Networks = {
|
|
|
445
435
|
Community: "0x3c2231024f4f17f3718b5bd9ed9ff29cc323dea5449f9ceba11a9888bfbdd0e1",
|
|
446
436
|
Details: "0x9895e82115987d8e3e02b35ced92e6a0509293890333f58f50ec291b34853dac",
|
|
447
437
|
Grant: "0x7afa603a89cee2d8f93d30007e2c64efddc6509fd76aa95d2ccd97b6e34acc71",
|
|
448
|
-
GrantVerified: "
|
|
438
|
+
GrantVerified: "0x837ae97827bdec74d0c8d755331634f730bb8ad00702099e9a6a2bbe193b1511",
|
|
449
439
|
MemberOf: "0xb4186a2401f40a4c78768941ef9140e1fbe5fe595053a65d44f31d6df180b712",
|
|
450
|
-
MilestoneApproved: "
|
|
451
|
-
MilestoneCompleted: "
|
|
452
|
-
GrantUpdateStatus: "
|
|
440
|
+
MilestoneApproved: "0x837ae97827bdec74d0c8d755331634f730bb8ad00702099e9a6a2bbe193b1511",
|
|
441
|
+
MilestoneCompleted: "0x837ae97827bdec74d0c8d755331634f730bb8ad00702099e9a6a2bbe193b1511",
|
|
442
|
+
GrantUpdateStatus: "0x837ae97827bdec74d0c8d755331634f730bb8ad00702099e9a6a2bbe193b1511",
|
|
453
443
|
Project: "0x672fbaa8a1fb6e1f73a89c84a8e97a808da0750003a9d1d18aba3d39fa165945",
|
|
454
|
-
ProjectUpdateStatus: "
|
|
455
|
-
ProjectMilestoneStatus: "
|
|
444
|
+
ProjectUpdateStatus: "0x837ae97827bdec74d0c8d755331634f730bb8ad00702099e9a6a2bbe193b1511",
|
|
445
|
+
ProjectMilestoneStatus: "0x837ae97827bdec74d0c8d755331634f730bb8ad00702099e9a6a2bbe193b1511",
|
|
456
446
|
ContributorProfile: null
|
|
457
447
|
},
|
|
448
|
+
oldSchemas: [
|
|
449
|
+
{
|
|
450
|
+
name: "GrantVerified",
|
|
451
|
+
uid: "0xf45fdf2c064073f0623416571c2746085d785cde5a57fd0696ff88bdf78bcbdc",
|
|
452
|
+
raw: oldStatusSchema
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
name: "MilestoneApproved",
|
|
456
|
+
uid: "0xf45fdf2c064073f0623416571c2746085d785cde5a57fd0696ff88bdf78bcbdc",
|
|
457
|
+
raw: oldStatusSchema
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
name: "MilestoneCompleted",
|
|
461
|
+
uid: "0xf45fdf2c064073f0623416571c2746085d785cde5a57fd0696ff88bdf78bcbdc",
|
|
462
|
+
raw: oldStatusSchema
|
|
463
|
+
},
|
|
464
|
+
{
|
|
465
|
+
name: "GrantUpdateStatus",
|
|
466
|
+
uid: "0xf45fdf2c064073f0623416571c2746085d785cde5a57fd0696ff88bdf78bcbdc",
|
|
467
|
+
raw: oldStatusSchema
|
|
468
|
+
},
|
|
469
|
+
{
|
|
470
|
+
name: "ProjectUpdateStatus",
|
|
471
|
+
uid: "0xf45fdf2c064073f0623416571c2746085d785cde5a57fd0696ff88bdf78bcbdc",
|
|
472
|
+
raw: oldStatusSchema
|
|
473
|
+
},
|
|
474
|
+
]
|
|
458
475
|
},
|
|
459
476
|
"base": {
|
|
460
477
|
chainId: 8453,
|
|
461
478
|
url: "https://base.easscan.org/graphql",
|
|
462
|
-
rpcUrl: "https://mainnet.base.org",
|
|
463
479
|
contracts: {
|
|
464
480
|
eas: "0x4200000000000000000000000000000000000021",
|
|
465
481
|
schema: "0x4200000000000000000000000000000000000020",
|
|
@@ -473,21 +489,47 @@ exports.Networks = {
|
|
|
473
489
|
Community: "0x721c17b065dccc5c916e0c2708d0ef50f1810591b76d0402ff6fe5accbd8488f",
|
|
474
490
|
Details: "0x70a3f615f738fc6a4f56100692ada93d947c028b840940d97af7e7d6f0fa0577",
|
|
475
491
|
Grant: "0x12837231f48acbca4e1e7f4416f684f3353bd4d71d4f03a09d29e5ffa6f21a50",
|
|
476
|
-
GrantVerified: "
|
|
492
|
+
GrantVerified: "0x535417d864b95c33fc0289082617b4004737a12c276ee27effd9f54491942934",
|
|
477
493
|
MemberOf: "0x7fbb8a65924d8ad2ae12356e04b1418043e8361ba3b1b6c917de2e23df3ec81c",
|
|
478
|
-
MilestoneApproved: "
|
|
479
|
-
MilestoneCompleted: "
|
|
480
|
-
GrantUpdateStatus: "
|
|
494
|
+
MilestoneApproved: "0x535417d864b95c33fc0289082617b4004737a12c276ee27effd9f54491942934",
|
|
495
|
+
MilestoneCompleted: "0x535417d864b95c33fc0289082617b4004737a12c276ee27effd9f54491942934",
|
|
496
|
+
GrantUpdateStatus: "0x535417d864b95c33fc0289082617b4004737a12c276ee27effd9f54491942934",
|
|
481
497
|
Project: "0x5a6b36ac106c74541efad39f8430751dd843bb78729bf7ffc296eca4cbb8d8f3",
|
|
482
|
-
ProjectUpdateStatus: "
|
|
483
|
-
ProjectMilestoneStatus: "
|
|
498
|
+
ProjectUpdateStatus: "0x535417d864b95c33fc0289082617b4004737a12c276ee27effd9f54491942934",
|
|
499
|
+
ProjectMilestoneStatus: "0x535417d864b95c33fc0289082617b4004737a12c276ee27effd9f54491942934",
|
|
484
500
|
ContributorProfile: "0xdfb8ad353dd144235bd45ae38803db6ffe066081770370f603709b9dec9ba8ff"
|
|
485
501
|
},
|
|
502
|
+
oldSchemas: [
|
|
503
|
+
{
|
|
504
|
+
name: "GrantVerified",
|
|
505
|
+
uid: "0xb7eab95609c821624edc3c3a5a6c787bdc9da6c91393a967fb22b0e274c619dd",
|
|
506
|
+
raw: oldStatusSchema
|
|
507
|
+
},
|
|
508
|
+
{
|
|
509
|
+
name: "MilestoneApproved",
|
|
510
|
+
uid: "0xb7eab95609c821624edc3c3a5a6c787bdc9da6c91393a967fb22b0e274c619dd",
|
|
511
|
+
raw: oldStatusSchema
|
|
512
|
+
},
|
|
513
|
+
{
|
|
514
|
+
name: "MilestoneCompleted",
|
|
515
|
+
uid: "0xb7eab95609c821624edc3c3a5a6c787bdc9da6c91393a967fb22b0e274c619dd",
|
|
516
|
+
raw: oldStatusSchema
|
|
517
|
+
},
|
|
518
|
+
{
|
|
519
|
+
name: "GrantUpdateStatus",
|
|
520
|
+
uid: "0xb7eab95609c821624edc3c3a5a6c787bdc9da6c91393a967fb22b0e274c619dd",
|
|
521
|
+
raw: oldStatusSchema
|
|
522
|
+
},
|
|
523
|
+
{
|
|
524
|
+
name: "ProjectUpdateStatus",
|
|
525
|
+
uid: "0xb7eab95609c821624edc3c3a5a6c787bdc9da6c91393a967fb22b0e274c619dd",
|
|
526
|
+
raw: oldStatusSchema
|
|
527
|
+
},
|
|
528
|
+
]
|
|
486
529
|
},
|
|
487
530
|
"polygon": {
|
|
488
531
|
chainId: 137,
|
|
489
532
|
url: "https://polygon.easscan.org/graphql",
|
|
490
|
-
rpcUrl: "https://polygon-rpc.com/",
|
|
491
533
|
contracts: {
|
|
492
534
|
eas: "0x5E634ef5355f45A855d02D66eCD687b1502AF790",
|
|
493
535
|
schema: "0x7876EEF51A891E737AF8ba5A5E0f0Fd29073D5a7",
|
|
@@ -501,16 +543,43 @@ exports.Networks = {
|
|
|
501
543
|
Community: "0x884bd33b1d7fce5c637e85aef538e83a8a87157d7df2d357e6cc8d4c59b89400",
|
|
502
544
|
Details: "0x2038ec9d8d0ab60324065aa0b4961d3f93d725f1c71f67b9f1ef209114c75f7f",
|
|
503
545
|
Grant: "0x2cedad5cda259c921f3380eedd5920be86a7dfe9496848cc8afc7f01159dfd65",
|
|
504
|
-
GrantVerified: "
|
|
546
|
+
GrantVerified: "0xefa705f5baaf91745bb4706fa4aa55156c5d9c3cd6834fcc4912bcb51ad5bea3",
|
|
505
547
|
MemberOf: "0x2cfa4adacb1efcd0ff408d749fd12bb36cd5f88aa0822f633962d4bd5c8023aa",
|
|
506
|
-
MilestoneApproved: "
|
|
507
|
-
MilestoneCompleted: "
|
|
508
|
-
GrantUpdateStatus: "
|
|
548
|
+
MilestoneApproved: "0xefa705f5baaf91745bb4706fa4aa55156c5d9c3cd6834fcc4912bcb51ad5bea3",
|
|
549
|
+
MilestoneCompleted: "0xefa705f5baaf91745bb4706fa4aa55156c5d9c3cd6834fcc4912bcb51ad5bea3",
|
|
550
|
+
GrantUpdateStatus: "0xefa705f5baaf91745bb4706fa4aa55156c5d9c3cd6834fcc4912bcb51ad5bea3",
|
|
509
551
|
Project: "0x7f0e4ac5f7cbe2a39af317b46bad7e86b053f76109c364d197447d9da34e821a",
|
|
510
|
-
ProjectUpdateStatus: "
|
|
511
|
-
ProjectMilestoneStatus: "
|
|
552
|
+
ProjectUpdateStatus: "0xefa705f5baaf91745bb4706fa4aa55156c5d9c3cd6834fcc4912bcb51ad5bea3",
|
|
553
|
+
ProjectMilestoneStatus: "0xefa705f5baaf91745bb4706fa4aa55156c5d9c3cd6834fcc4912bcb51ad5bea3",
|
|
512
554
|
ContributorProfile: "0x281f0afbb0313c6ff851400c4ed317fe9741be75e7e20c337dfd403059523bea"
|
|
513
555
|
},
|
|
556
|
+
oldSchemas: [
|
|
557
|
+
{
|
|
558
|
+
name: "GrantVerified",
|
|
559
|
+
uid: "0xe4b229d7051c27bb64cca0d29d92377143e6d5b9e076416e997c38d4cb40a399",
|
|
560
|
+
raw: oldStatusSchema
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
name: "MilestoneApproved",
|
|
564
|
+
uid: "0xe4b229d7051c27bb64cca0d29d92377143e6d5b9e076416e997c38d4cb40a399",
|
|
565
|
+
raw: oldStatusSchema
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
name: "MilestoneCompleted",
|
|
569
|
+
uid: "0xe4b229d7051c27bb64cca0d29d92377143e6d5b9e076416e997c38d4cb40a399",
|
|
570
|
+
raw: oldStatusSchema
|
|
571
|
+
},
|
|
572
|
+
{
|
|
573
|
+
name: "GrantUpdateStatus",
|
|
574
|
+
uid: "0xe4b229d7051c27bb64cca0d29d92377143e6d5b9e076416e997c38d4cb40a399",
|
|
575
|
+
raw: oldStatusSchema
|
|
576
|
+
},
|
|
577
|
+
{
|
|
578
|
+
name: "ProjectUpdateStatus",
|
|
579
|
+
uid: "0xe4b229d7051c27bb64cca0d29d92377143e6d5b9e076416e997c38d4cb40a399",
|
|
580
|
+
raw: oldStatusSchema
|
|
581
|
+
},
|
|
582
|
+
]
|
|
514
583
|
},
|
|
515
584
|
};
|
|
516
585
|
const DetailsSchema = [{ type: "string", name: "json", value: null }];
|
package/core/types.d.ts
CHANGED
|
@@ -31,6 +31,24 @@ export type TSchemaName = "Community" | "CommunityDetails" | "Grant" | "GrantDet
|
|
|
31
31
|
export type TResolvedSchemaNames = "Community" | "Grant" | "GrantVerified" | "MemberOf" | "MilestoneCompleted" | "MilestoneApproved" | "Project" | "Details" | "ProjectUpdateStatus" | "GrantUpdateStatus" | "ProjectUpdateStatus" | "ProjectMilestoneStatus" | "ContributorProfile";
|
|
32
32
|
export type TExternalLink = "twitter" | "github" | "website" | "linkedin" | "discord" | "pitchDeck" | "demoVideo" | "farcaster" | "custom";
|
|
33
33
|
export type TNetwork = "optimism" | "celo" | "optimism-sepolia" | "arbitrum" | "sepolia" | "sei" | "sei-testnet" | "base-sepolia" | "lisk" | "scroll" | "base" | "polygon";
|
|
34
|
+
/**
|
|
35
|
+
* Supported chain IDs for GAP SDK networks
|
|
36
|
+
*/
|
|
37
|
+
export type SupportedChainId = 10 | 11155420 | 42161 | 11155111 | 84532 | 42220 | 1328 | 1329 | 1135 | 534352 | 8453 | 137;
|
|
38
|
+
/**
|
|
39
|
+
* RPC configuration for GAP SDK.
|
|
40
|
+
* Maps chain IDs to RPC URLs.
|
|
41
|
+
* Only configure the networks you need to use.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* const rpcUrls: GAPRpcConfig = {
|
|
46
|
+
* 10: "https://opt-mainnet.g.alchemy.com/v2/YOUR_KEY",
|
|
47
|
+
* 42161: "https://arb-mainnet.g.alchemy.com/v2/YOUR_KEY",
|
|
48
|
+
* };
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export type GAPRpcConfig = Partial<Record<SupportedChainId, string>>;
|
|
34
52
|
/**
|
|
35
53
|
* Generic GAP Facade interface.
|
|
36
54
|
* This supplies the GAP class with the necessary properties.
|
|
@@ -61,7 +79,6 @@ export interface MultiAttestData {
|
|
|
61
79
|
export type MultiAttestPayload = [Attestation, RawMultiAttestPayload][];
|
|
62
80
|
export interface EASNetworkConfig {
|
|
63
81
|
url: string;
|
|
64
|
-
rpcUrl: string;
|
|
65
82
|
chainId: number;
|
|
66
83
|
contracts: {
|
|
67
84
|
eas: Hex;
|
|
@@ -116,16 +133,3 @@ export interface SchemaRes {
|
|
|
116
133
|
attestations: IAttestation[];
|
|
117
134
|
};
|
|
118
135
|
}
|
|
119
|
-
/**
|
|
120
|
-
* Valid remote storage types
|
|
121
|
-
*/
|
|
122
|
-
export declare const enum STORAGE_TYPE {
|
|
123
|
-
IPFS = 0,
|
|
124
|
-
ARWEAVE = 1,
|
|
125
|
-
SWARM = 2,
|
|
126
|
-
UNKNOWN = 3
|
|
127
|
-
}
|
|
128
|
-
export type TRemoteStorageOutput<T = unknown> = {
|
|
129
|
-
hash: T;
|
|
130
|
-
storageType: number;
|
|
131
|
-
};
|
|
@@ -1,2 +1,17 @@
|
|
|
1
1
|
import { ethers } from "ethers";
|
|
2
|
-
|
|
2
|
+
import { GAPRpcConfig } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* Get a Web3 provider for a specific chain ID using the provided RPC configuration.
|
|
5
|
+
*
|
|
6
|
+
* @param chainId - The chain ID to get a provider for
|
|
7
|
+
* @param config - RPC URL configuration mapping chain IDs to RPC URLs
|
|
8
|
+
* @returns An ethers JsonRpcProvider for the specified chain
|
|
9
|
+
* @throws Error if no RPC URL is configured for the chain ID or if the URL is invalid
|
|
10
|
+
*/
|
|
11
|
+
export declare const getWeb3Provider: (chainId: number, config: GAPRpcConfig) => ethers.JsonRpcProvider;
|
|
12
|
+
/**
|
|
13
|
+
* Clear all cached providers.
|
|
14
|
+
* Useful for testing or when reconfiguring the SDK.
|
|
15
|
+
* @internal - This is an internal function, not part of the public API.
|
|
16
|
+
*/
|
|
17
|
+
export declare const clearProviderCache: () => void;
|
|
@@ -1,18 +1,58 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getWeb3Provider = void 0;
|
|
4
|
-
const consts_1 = require("../consts");
|
|
3
|
+
exports.clearProviderCache = exports.getWeb3Provider = void 0;
|
|
5
4
|
const ethers_1 = require("ethers");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Global provider cache keyed by "chainId:rpcUrl" to allow caching
|
|
7
|
+
* while supporting different RPC URLs for the same chain.
|
|
8
|
+
*/
|
|
9
|
+
const providers = new Map();
|
|
10
|
+
/**
|
|
11
|
+
* Validate that a string is a valid URL.
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
const isValidUrl = (url) => {
|
|
15
|
+
try {
|
|
16
|
+
new URL(url);
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Get a Web3 provider for a specific chain ID using the provided RPC configuration.
|
|
25
|
+
*
|
|
26
|
+
* @param chainId - The chain ID to get a provider for
|
|
27
|
+
* @param config - RPC URL configuration mapping chain IDs to RPC URLs
|
|
28
|
+
* @returns An ethers JsonRpcProvider for the specified chain
|
|
29
|
+
* @throws Error if no RPC URL is configured for the chain ID or if the URL is invalid
|
|
30
|
+
*/
|
|
31
|
+
const getWeb3Provider = (chainId, config) => {
|
|
32
|
+
const rpcUrl = config[chainId];
|
|
10
33
|
if (!rpcUrl) {
|
|
11
|
-
throw new Error(`
|
|
34
|
+
throw new Error(`RPC URL not configured for chain ${chainId}. ` +
|
|
35
|
+
`Please provide an RPC URL in the rpcUrls configuration when initializing GAP.`);
|
|
12
36
|
}
|
|
13
|
-
if (!
|
|
14
|
-
|
|
37
|
+
if (!isValidUrl(rpcUrl)) {
|
|
38
|
+
throw new Error(`Invalid RPC URL for chain ${chainId}: "${rpcUrl}". ` +
|
|
39
|
+
`Please provide a valid URL (e.g., "https://mainnet.infura.io/v3/YOUR_KEY").`);
|
|
15
40
|
}
|
|
16
|
-
|
|
41
|
+
const cacheKey = `${chainId}:${rpcUrl}`;
|
|
42
|
+
let provider = providers.get(cacheKey);
|
|
43
|
+
if (!provider) {
|
|
44
|
+
provider = new ethers_1.ethers.JsonRpcProvider(rpcUrl);
|
|
45
|
+
providers.set(cacheKey, provider);
|
|
46
|
+
}
|
|
47
|
+
return provider;
|
|
17
48
|
};
|
|
18
49
|
exports.getWeb3Provider = getWeb3Provider;
|
|
50
|
+
/**
|
|
51
|
+
* Clear all cached providers.
|
|
52
|
+
* Useful for testing or when reconfiguring the SDK.
|
|
53
|
+
* @internal - This is an internal function, not part of the public API.
|
|
54
|
+
*/
|
|
55
|
+
const clearProviderCache = () => {
|
|
56
|
+
providers.clear();
|
|
57
|
+
};
|
|
58
|
+
exports.clearProviderCache = clearProviderCache;
|
package/core/utils/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from './gelato';
|
|
2
2
|
export * from './get-date';
|
|
3
|
+
export { clearProviderCache } from './get-web3-provider';
|
|
3
4
|
export * from './gql-queries';
|
|
4
5
|
export * from './map-filter';
|
|
5
6
|
export * from './serialize-bigint';
|
|
6
7
|
export * from './to-unix';
|
|
7
|
-
export * from './get-ipfs-data';
|
package/core/utils/index.js
CHANGED
|
@@ -14,10 +14,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.clearProviderCache = void 0;
|
|
17
18
|
__exportStar(require("./gelato"), exports);
|
|
18
19
|
__exportStar(require("./get-date"), exports);
|
|
20
|
+
// Note: get-web3-provider functions are internal. Use gap.getProvider() instead.
|
|
21
|
+
// clearProviderCache is exported only for testing purposes.
|
|
22
|
+
var get_web3_provider_1 = require("./get-web3-provider");
|
|
23
|
+
Object.defineProperty(exports, "clearProviderCache", { enumerable: true, get: function () { return get_web3_provider_1.clearProviderCache; } });
|
|
19
24
|
__exportStar(require("./gql-queries"), exports);
|
|
20
25
|
__exportStar(require("./map-filter"), exports);
|
|
21
26
|
__exportStar(require("./serialize-bigint"), exports);
|
|
22
27
|
__exportStar(require("./to-unix"), exports);
|
|
23
|
-
__exportStar(require("./get-ipfs-data"), exports);
|