@snapshot-labs/snapshot.js 0.11.38 → 0.12.0-beta.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.
Files changed (47) hide show
  1. package/LICENSE +0 -0
  2. package/dist/index.d.ts +2 -29
  3. package/dist/schemas/index.d.ts +2 -29
  4. package/dist/sign/types.d.ts +0 -3
  5. package/dist/snapshot.cjs.js +1549 -1906
  6. package/dist/snapshot.esm.js +1550 -1907
  7. package/dist/snapshot.js/src/index.d.ts +677 -0
  8. package/dist/snapshot.js/src/sign/index.d.ts +28 -0
  9. package/dist/snapshot.min.js +16 -5
  10. package/dist/src/index.d.ts +725 -0
  11. package/dist/src/schemas/index.d.ts +671 -0
  12. package/dist/src/sign/index.d.ts +29 -0
  13. package/dist/src/sign/types.d.ts +227 -0
  14. package/dist/src/utils/blockfinder.d.ts +1 -0
  15. package/dist/src/utils/delegation.d.ts +18 -0
  16. package/dist/src/utils/multicaller.d.ts +12 -0
  17. package/dist/src/utils/provider.d.ts +5 -0
  18. package/dist/src/utils/web3.d.ts +2 -0
  19. package/dist/src/utils.d.ts +91 -0
  20. package/dist/src/verify/evm.d.ts +4 -0
  21. package/dist/src/verify/evm.spec.d.ts +1 -0
  22. package/dist/src/verify/index.d.ts +11 -0
  23. package/dist/src/verify/index.spec.d.ts +1 -0
  24. package/dist/src/verify/starknet.d.ts +6 -0
  25. package/dist/src/verify/starknet.spec.d.ts +1 -0
  26. package/dist/src/voting/approval.d.ts +22 -0
  27. package/dist/src/voting/index.d.ts +14 -0
  28. package/dist/src/voting/quadratic.d.ts +20 -0
  29. package/dist/src/voting/rankedChoice.d.ts +18 -0
  30. package/dist/src/voting/singleChoice.d.ts +18 -0
  31. package/dist/src/voting/types.d.ts +35 -0
  32. package/dist/src/voting/weighted.d.ts +26 -0
  33. package/package.json +5 -3
  34. package/src/sign/hashedTypes.json +5 -1
  35. package/src/utils/dist/provider.js +47 -0
  36. package/src/utils/provider.ts +8 -2
  37. package/src/utils/web3.ts +1 -1
  38. package/src/utils.spec.js +36 -1
  39. package/src/utils.ts +44 -14
  40. package/src/verify/evm.spec.ts +32 -0
  41. package/src/verify/evm.ts +82 -0
  42. package/src/verify/index.spec.ts +84 -0
  43. package/src/verify/index.ts +41 -0
  44. package/src/verify/starknet.spec.ts +55 -0
  45. package/src/verify/starknet.ts +82 -0
  46. package/src/sign/eip1271.ts +0 -55
  47. package/src/sign/utils.ts +0 -27
@@ -0,0 +1,227 @@
1
+ export interface Space {
2
+ from?: string;
3
+ space: string;
4
+ timestamp?: number;
5
+ settings: string;
6
+ }
7
+ export type ProposalType = 'single-choice' | 'approval' | 'quadratic' | 'ranked-choice' | 'weighted' | 'basic';
8
+ export interface Proposal {
9
+ from?: string;
10
+ space: string;
11
+ timestamp?: number;
12
+ type: ProposalType;
13
+ title: string;
14
+ body: string;
15
+ discussion: string;
16
+ choices: string[];
17
+ start: number;
18
+ end: number;
19
+ snapshot: number;
20
+ plugins: string;
21
+ app?: string;
22
+ }
23
+ export interface UpdateProposal {
24
+ proposal: string;
25
+ from?: string;
26
+ space: string;
27
+ timestamp?: number;
28
+ type: ProposalType;
29
+ title: string;
30
+ body: string;
31
+ discussion: string;
32
+ choices: string[];
33
+ plugins: string;
34
+ }
35
+ export interface FlagProposal {
36
+ from?: string;
37
+ space: string;
38
+ proposal: string;
39
+ timestamp?: number;
40
+ }
41
+ export interface CancelProposal {
42
+ from?: string;
43
+ space: string;
44
+ timestamp?: number;
45
+ proposal: string;
46
+ }
47
+ export interface Vote {
48
+ from?: string;
49
+ space: string;
50
+ timestamp?: number;
51
+ proposal: string;
52
+ type: ProposalType;
53
+ choice: number | number[] | string | {
54
+ [key: string]: number;
55
+ };
56
+ privacy?: string;
57
+ reason?: string;
58
+ app?: string;
59
+ metadata?: string;
60
+ }
61
+ export interface Follow {
62
+ from?: string;
63
+ network?: string;
64
+ space: string;
65
+ timestamp?: number;
66
+ }
67
+ export interface Unfollow {
68
+ from?: string;
69
+ network?: string;
70
+ space: string;
71
+ timestamp?: number;
72
+ }
73
+ export interface Subscribe {
74
+ from?: string;
75
+ space: string;
76
+ timestamp?: number;
77
+ }
78
+ export interface Unsubscribe {
79
+ from?: string;
80
+ space: string;
81
+ timestamp?: number;
82
+ }
83
+ export interface Profile {
84
+ from?: string;
85
+ timestamp?: number;
86
+ profile: string;
87
+ }
88
+ export interface Statement {
89
+ from?: string;
90
+ timestamp?: number;
91
+ space: string;
92
+ about: string;
93
+ statement: string;
94
+ discourse?: string;
95
+ status?: string;
96
+ network?: string;
97
+ }
98
+ export interface Alias {
99
+ from?: string;
100
+ alias: string;
101
+ timestamp?: number;
102
+ }
103
+ export interface DeleteSpace {
104
+ from?: string;
105
+ space: string;
106
+ timestamp?: number;
107
+ }
108
+ export declare const spaceTypes: {
109
+ Space: {
110
+ name: string;
111
+ type: string;
112
+ }[];
113
+ };
114
+ export declare const proposalTypes: {
115
+ Proposal: {
116
+ name: string;
117
+ type: string;
118
+ }[];
119
+ };
120
+ export declare const updateProposalTypes: {
121
+ UpdateProposal: {
122
+ name: string;
123
+ type: string;
124
+ }[];
125
+ };
126
+ export declare const flagProposalTypes: {
127
+ FlagProposal: {
128
+ name: string;
129
+ type: string;
130
+ }[];
131
+ };
132
+ export declare const cancelProposalTypes: {
133
+ CancelProposal: {
134
+ name: string;
135
+ type: string;
136
+ }[];
137
+ };
138
+ export declare const cancelProposal2Types: {
139
+ CancelProposal: {
140
+ name: string;
141
+ type: string;
142
+ }[];
143
+ };
144
+ export declare const voteTypes: {
145
+ Vote: {
146
+ name: string;
147
+ type: string;
148
+ }[];
149
+ };
150
+ export declare const voteArrayTypes: {
151
+ Vote: {
152
+ name: string;
153
+ type: string;
154
+ }[];
155
+ };
156
+ export declare const voteStringTypes: {
157
+ Vote: {
158
+ name: string;
159
+ type: string;
160
+ }[];
161
+ };
162
+ export declare const vote2Types: {
163
+ Vote: {
164
+ name: string;
165
+ type: string;
166
+ }[];
167
+ };
168
+ export declare const voteArray2Types: {
169
+ Vote: {
170
+ name: string;
171
+ type: string;
172
+ }[];
173
+ };
174
+ export declare const voteString2Types: {
175
+ Vote: {
176
+ name: string;
177
+ type: string;
178
+ }[];
179
+ };
180
+ export declare const followTypes: {
181
+ Follow: {
182
+ name: string;
183
+ type: string;
184
+ }[];
185
+ };
186
+ export declare const unfollowTypes: {
187
+ Unfollow: {
188
+ name: string;
189
+ type: string;
190
+ }[];
191
+ };
192
+ export declare const subscribeTypes: {
193
+ Subscribe: {
194
+ name: string;
195
+ type: string;
196
+ }[];
197
+ };
198
+ export declare const unsubscribeTypes: {
199
+ Unsubscribe: {
200
+ name: string;
201
+ type: string;
202
+ }[];
203
+ };
204
+ export declare const profileTypes: {
205
+ Profile: {
206
+ name: string;
207
+ type: string;
208
+ }[];
209
+ };
210
+ export declare const statementTypes: {
211
+ Statement: {
212
+ name: string;
213
+ type: string;
214
+ }[];
215
+ };
216
+ export declare const aliasTypes: {
217
+ Alias: {
218
+ name: string;
219
+ type: string;
220
+ }[];
221
+ };
222
+ export declare const deleteSpaceType: {
223
+ DeleteSpace: {
224
+ name: string;
225
+ type: string;
226
+ }[];
227
+ };
@@ -0,0 +1 @@
1
+ export declare function getSnapshots(network: any, snapshot: any, provider: any, networks: any, options?: any): Promise<any>;
@@ -0,0 +1,18 @@
1
+ export declare const SNAPSHOT_SUBGRAPH_URL: {
2
+ "1": string;
3
+ "10": string;
4
+ "56": string;
5
+ "100": string;
6
+ "137": string;
7
+ "250": string;
8
+ "42161": string;
9
+ "11155111": string;
10
+ };
11
+ type Delegation = {
12
+ delegator: string;
13
+ delegate: string;
14
+ space: string;
15
+ timestamp: number;
16
+ };
17
+ export default function getDelegatesBySpace(network: string, space: string, snapshot?: string | number, options?: any): Promise<Delegation[]>;
18
+ export {};
@@ -0,0 +1,12 @@
1
+ import { StaticJsonRpcProvider } from '@ethersproject/providers';
2
+ export default class Multicaller {
3
+ network: string;
4
+ provider: StaticJsonRpcProvider;
5
+ abi: any[];
6
+ options: any;
7
+ calls: any[];
8
+ paths: any[];
9
+ constructor(network: string, provider: StaticJsonRpcProvider, abi: any[], options?: any);
10
+ call(path: any, address: any, fn: any, params?: any): Multicaller;
11
+ execute(from?: any): Promise<any>;
12
+ }
@@ -0,0 +1,5 @@
1
+ export type ProviderOptions = {
2
+ broviderUrl?: string;
3
+ };
4
+ export default function getProvider(network: any, { broviderUrl }?: ProviderOptions): any;
5
+ export declare function getBatchedProvider(network: any, { broviderUrl }?: ProviderOptions): any;
@@ -0,0 +1,2 @@
1
+ export declare function signMessage(web3: any, msg: any, address: any): Promise<any>;
2
+ export declare function getBlockNumber(provider: any): Promise<number>;
@@ -0,0 +1,91 @@
1
+ import Multicaller from './utils/multicaller';
2
+ import { getSnapshots } from './utils/blockfinder';
3
+ import getProvider from './utils/provider';
4
+ import { signMessage, getBlockNumber } from './utils/web3';
5
+ import { getHash, verify } from './verify';
6
+ import getDelegatesBySpace, { SNAPSHOT_SUBGRAPH_URL } from './utils/delegation';
7
+ interface Options {
8
+ url?: string;
9
+ headers?: any;
10
+ }
11
+ interface Strategy {
12
+ name: string;
13
+ network?: string;
14
+ params: any;
15
+ }
16
+ export declare function call(provider: any, abi: any[], call: any[], options?: any): Promise<any>;
17
+ export declare function multicall(network: string, provider: any, abi: any[], calls: any[], options?: any): Promise<any>;
18
+ export declare function subgraphRequest(url: string, query: any, options?: any): Promise<any>;
19
+ export declare function getUrl(uri: any, gateway?: string): any;
20
+ export declare function getJSON(uri: any, options?: any): Promise<any>;
21
+ export declare function ipfsGet(gateway: string, ipfsHash: string, protocolType?: string): Promise<any>;
22
+ export declare function sendTransaction(web3: any, contractAddress: string, abi: any[], action: string, params: any[], overrides?: {}): Promise<any>;
23
+ export declare function getScores(space: string, strategies: Strategy[], network: string, addresses: string[], snapshot?: number | string, scoreApiUrl?: string, options?: any): Promise<any>;
24
+ export declare function getVp(address: string, network: string, strategies: Strategy[], snapshot: number | 'latest', space: string, delegation: boolean, options?: Options): Promise<any>;
25
+ export declare function validate(validation: string, author: string, space: string, network: string, snapshot: number | 'latest', params: any, options?: Options): Promise<any>;
26
+ interface validateSchemaOptions {
27
+ snapshotEnv?: string;
28
+ spaceType?: string;
29
+ }
30
+ export declare function validateSchema(schema: any, data: any, options?: validateSchemaOptions): true | import("ajv").ErrorObject<string, Record<string, any>, unknown>[] | null | undefined;
31
+ export declare function getEnsTextRecord(ens: string, record: string, network?: string, options?: any): Promise<any>;
32
+ export declare function getSpaceUri(id: string, network?: string, options?: any): Promise<string | null>;
33
+ export declare function getEnsOwner(ens: string, network?: string, options?: any): Promise<string | null>;
34
+ export declare function getSpaceController(id: string, network?: string, options?: any): Promise<string | null>;
35
+ export declare function clone(item: any): any;
36
+ export declare function sleep(time: any): Promise<unknown>;
37
+ export declare function getNumberWithOrdinal(n: any): string;
38
+ export declare function isStarknetAddress(address: string): boolean;
39
+ export declare function isEvmAddress(address: string): boolean;
40
+ export declare function getFormattedAddress(address: string, format?: string[]): string;
41
+ export { getDelegatesBySpace, SNAPSHOT_SUBGRAPH_URL };
42
+ declare const _default: {
43
+ call: typeof call;
44
+ multicall: typeof multicall;
45
+ subgraphRequest: typeof subgraphRequest;
46
+ ipfsGet: typeof ipfsGet;
47
+ getUrl: typeof getUrl;
48
+ getJSON: typeof getJSON;
49
+ sendTransaction: typeof sendTransaction;
50
+ getScores: typeof getScores;
51
+ getVp: typeof getVp;
52
+ validateSchema: typeof validateSchema;
53
+ getEnsTextRecord: typeof getEnsTextRecord;
54
+ getSpaceUri: typeof getSpaceUri;
55
+ getEnsOwner: typeof getEnsOwner;
56
+ getSpaceController: typeof getSpaceController;
57
+ getDelegatesBySpace: typeof getDelegatesBySpace;
58
+ clone: typeof clone;
59
+ sleep: typeof sleep;
60
+ getNumberWithOrdinal: typeof getNumberWithOrdinal;
61
+ voting: {
62
+ 'single-choice': typeof import("./voting/singleChoice").default;
63
+ approval: typeof import("./voting/approval").default;
64
+ quadratic: typeof import("./voting/quadratic").default;
65
+ 'ranked-choice': typeof import("./voting/rankedChoice").default;
66
+ weighted: typeof import("./voting/weighted").default;
67
+ basic: typeof import("./voting/singleChoice").default;
68
+ };
69
+ getProvider: typeof getProvider;
70
+ signMessage: typeof signMessage;
71
+ getBlockNumber: typeof getBlockNumber;
72
+ Multicaller: typeof Multicaller;
73
+ getSnapshots: typeof getSnapshots;
74
+ getHash: typeof getHash;
75
+ verify: typeof verify;
76
+ validate: typeof validate;
77
+ isStarknetAddress: typeof isStarknetAddress;
78
+ isEvmAddress: typeof isEvmAddress;
79
+ getFormattedAddress: typeof getFormattedAddress;
80
+ SNAPSHOT_SUBGRAPH_URL: {
81
+ "1": string;
82
+ "10": string;
83
+ "56": string;
84
+ "100": string;
85
+ "137": string;
86
+ "250": string;
87
+ "42161": string;
88
+ "11155111": string;
89
+ };
90
+ };
91
+ export default _default;
@@ -0,0 +1,4 @@
1
+ import { type ProviderOptions } from '../utils/provider';
2
+ import type { SignaturePayload } from '.';
3
+ export declare function getHash(data: SignaturePayload): string;
4
+ export default function verify(address: string, sig: string, data: SignaturePayload, network?: string, options?: ProviderOptions): Promise<boolean>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ import type { StarkNetType } from 'starknet';
2
+ import type { TypedDataField } from '@ethersproject/abstract-signer';
3
+ import type { ProviderOptions } from '../utils/provider';
4
+ export type SignaturePayload = {
5
+ domain: Record<string, string>;
6
+ types: Record<string, StarkNetType[] | TypedDataField[]>;
7
+ primaryType?: string;
8
+ message: Record<string, any>;
9
+ };
10
+ export declare function getHash(data: SignaturePayload, address?: string): string;
11
+ export declare function verify(address: string, sig: string | string[], data: SignaturePayload, network?: string, options?: ProviderOptions): Promise<boolean>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { SignaturePayload } from '.';
2
+ import type { ProviderOptions } from '../utils/provider';
3
+ export type NetworkType = 'SN_MAIN' | 'SN_SEPOLIA';
4
+ export declare function isStarknetMessage(data: SignaturePayload): boolean;
5
+ export declare function getHash(data: SignaturePayload, address: string): string;
6
+ export default function verify(address: string, sig: string[], data: SignaturePayload, network?: NetworkType, options?: ProviderOptions): Promise<boolean>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,22 @@
1
+ import { ApprovalVote, Strategy } from './types';
2
+ export default class ApprovalVoting {
3
+ proposal: {
4
+ choices: string[];
5
+ };
6
+ votes: ApprovalVote[];
7
+ strategies: Strategy[];
8
+ selected: number[];
9
+ constructor(proposal: {
10
+ choices: string[];
11
+ }, votes: ApprovalVote[], strategies: Strategy[], selected: number[]);
12
+ static isValidChoice(voteChoice: number[], proposalChoices: string[]): boolean;
13
+ getValidVotes(): {
14
+ choice: number[];
15
+ balance: number;
16
+ scores: number[];
17
+ }[];
18
+ getScores(): number[];
19
+ getScoresByStrategy(): number[][];
20
+ getScoresTotal(): number;
21
+ getChoiceString(): string;
22
+ }
@@ -0,0 +1,14 @@
1
+ import singleChoice from './singleChoice';
2
+ import approval from './approval';
3
+ import quadratic from './quadratic';
4
+ import rankedChoice from './rankedChoice';
5
+ import weighted from './weighted';
6
+ declare const _default: {
7
+ 'single-choice': typeof singleChoice;
8
+ approval: typeof approval;
9
+ quadratic: typeof quadratic;
10
+ 'ranked-choice': typeof rankedChoice;
11
+ weighted: typeof weighted;
12
+ basic: typeof singleChoice;
13
+ };
14
+ export default _default;
@@ -0,0 +1,20 @@
1
+ import { QuadraticVote, QuadraticChoice, Strategy } from './types';
2
+ export declare function calcPercentageOfSum(part: number, wholeArray: number[]): number;
3
+ export declare function calcSqrt(percentageWeight: number, votingPower: number): number;
4
+ export default class QuadraticVoting {
5
+ proposal: {
6
+ choices: string[];
7
+ };
8
+ votes: QuadraticVote[];
9
+ strategies: Strategy[];
10
+ selected: QuadraticChoice;
11
+ constructor(proposal: {
12
+ choices: string[];
13
+ }, votes: QuadraticVote[], strategies: Strategy[], selected: QuadraticChoice);
14
+ static isValidChoice(voteChoice: QuadraticChoice, proposalChoices: string[]): boolean;
15
+ getValidVotes(): QuadraticVote[];
16
+ getScores(): number[];
17
+ getScoresByStrategy(): number[][];
18
+ getScoresTotal(): number;
19
+ getChoiceString(): string;
20
+ }
@@ -0,0 +1,18 @@
1
+ import { RankedChoiceVote, Strategy } from './types';
2
+ export default class RankedChoiceVoting {
3
+ proposal: {
4
+ choices: string[];
5
+ };
6
+ votes: RankedChoiceVote[];
7
+ strategies: Strategy[];
8
+ selected: number[];
9
+ constructor(proposal: {
10
+ choices: string[];
11
+ }, votes: RankedChoiceVote[], strategies: Strategy[], selected: number[]);
12
+ static isValidChoice(voteChoice: number[], proposalChoices: string[]): boolean;
13
+ getValidVotes(): RankedChoiceVote[];
14
+ getScores(): number[];
15
+ getScoresByStrategy(): number[][];
16
+ getScoresTotal(): number;
17
+ getChoiceString(): string;
18
+ }
@@ -0,0 +1,18 @@
1
+ import { SingleChoiceVote, Strategy } from './types';
2
+ export default class SingleChoiceVoting {
3
+ proposal: {
4
+ choices: string[];
5
+ };
6
+ votes: SingleChoiceVote[];
7
+ strategies: Strategy[];
8
+ selected: number;
9
+ constructor(proposal: {
10
+ choices: string[];
11
+ }, votes: SingleChoiceVote[], strategies: Strategy[], selected: number);
12
+ static isValidChoice(voteChoice: number, proposalChoices: string[]): boolean;
13
+ getValidVotes(): SingleChoiceVote[];
14
+ getScores(): number[];
15
+ getScoresByStrategy(): number[][];
16
+ getScoresTotal(): number;
17
+ getChoiceString(): string;
18
+ }
@@ -0,0 +1,35 @@
1
+ export interface Strategy {
2
+ name: string;
3
+ network: string;
4
+ params: Record<string, unknown>;
5
+ }
6
+ export interface SingleChoiceVote {
7
+ choice: number;
8
+ balance: number;
9
+ scores: number[];
10
+ }
11
+ export interface ApprovalVote {
12
+ choice: number[];
13
+ balance: number;
14
+ scores: number[];
15
+ }
16
+ export interface RankedChoiceVote {
17
+ choice: number[];
18
+ balance: number;
19
+ scores: number[];
20
+ }
21
+ export interface QuadraticChoice {
22
+ [key: string]: number;
23
+ }
24
+ export interface QuadraticVote {
25
+ choice: QuadraticChoice;
26
+ balance: number;
27
+ scores: number[];
28
+ }
29
+ export interface WeightedVote {
30
+ choice: {
31
+ [key: string]: number;
32
+ };
33
+ balance: number;
34
+ scores: number[];
35
+ }
@@ -0,0 +1,26 @@
1
+ import { WeightedVote, Strategy } from './types';
2
+ export declare function percentageOfTotal(i: any, values: any, total: any): number;
3
+ export declare function weightedPower(i: any, choice: any, balance: any): number;
4
+ export default class WeightedVoting {
5
+ proposal: {
6
+ choices: string[];
7
+ };
8
+ votes: WeightedVote[];
9
+ strategies: Strategy[];
10
+ selected: {
11
+ [key: string]: number;
12
+ };
13
+ constructor(proposal: {
14
+ choices: string[];
15
+ }, votes: WeightedVote[], strategies: Strategy[], selected: {
16
+ [key: string]: number;
17
+ });
18
+ static isValidChoice(voteChoice: {
19
+ [key: string]: number;
20
+ }, proposalChoices: string[]): boolean;
21
+ getValidVotes(): WeightedVote[];
22
+ getScores(): number[];
23
+ getScoresByStrategy(): number[][];
24
+ getScoresTotal(): number;
25
+ getChoiceString(): string;
26
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snapshot-labs/snapshot.js",
3
- "version": "0.11.38",
3
+ "version": "0.12.0-beta.1",
4
4
  "repository": "snapshot-labs/snapshot.js",
5
5
  "license": "MIT",
6
6
  "main": "dist/snapshot.cjs.js",
@@ -22,7 +22,8 @@
22
22
  "ajv-formats": "^2.1.1",
23
23
  "cross-fetch": "^3.1.6",
24
24
  "json-to-graphql-query": "^2.2.4",
25
- "lodash.set": "^4.3.2"
25
+ "lodash.set": "^4.3.2",
26
+ "starknet": "^5.24.3"
26
27
  },
27
28
  "devDependencies": {
28
29
  "@rollup/plugin-commonjs": "^18.1.0",
@@ -45,7 +46,7 @@
45
46
  "rollup-plugin-terser": "^7.0.0",
46
47
  "rollup-plugin-typescript2": "^0.27.0",
47
48
  "ts-node": "^10.9.2",
48
- "typescript": "^3.8.3",
49
+ "typescript": "^5",
49
50
  "vitest": "^0.33.0"
50
51
  },
51
52
  "scripts": {
@@ -55,6 +56,7 @@
55
56
  "test:once": "vitest run",
56
57
  "dev": "rollup -c -w",
57
58
  "lint": "eslint . --ext .ts --fix",
59
+ "typecheck": "tsc --noEmit",
58
60
  "prepublishOnly": "yarn build"
59
61
  },
60
62
  "engines": {
@@ -55,5 +55,9 @@
55
55
  "daaf0ff7d3e2ec189cf851228c386c7a4c432076d0ed197864916dd3f656531c": "subscribe",
56
56
  "f542edb6f9fe79d0b85554667991352be2fcca85df3dd3c6a6f451d189c7c25d": "unsubscribe",
57
57
  "6f6cdd15a1e9e6c4ee544231c4fa7b6c7e5183bc2b37fa4bd1a695f458348ab7": "delete-space",
58
- "1aad7825b991457fca04aae48a2a49d815ada524e10316af0da5522ea48b3df6": "alias"
58
+ "1aad7825b991457fca04aae48a2a49d815ada524e10316af0da5522ea48b3df6": "alias",
59
+ "8ea9074bff3a30cb61f4f0f0f142c9335c6be828feba0571a45de3f1fd0319c0": "alias",
60
+ "42f8858a21d4aa232721cb97074851e729829ea362b88bb21f3879899663b586": "follow",
61
+ "2bb75450e28b06f259ea764cd669de6bde0ba70ce729b0ff05ab9df56e0ff21d": "unfollow",
62
+ "2ffbebcbd22ef48fd2f4a1182ff1feda7795b57689bd6f0dd73c89e925e7fefb": "profile"
59
63
  }
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ exports.__esModule = true;
14
+ exports.getBatchedProvider = void 0;
15
+ var providers_1 = require("@ethersproject/providers");
16
+ var networks_json_1 = require("../networks.json");
17
+ var providers = {};
18
+ function getProvider(network, type) {
19
+ var _a;
20
+ if (type === void 0) { type = 'archive'; }
21
+ var url = networks_json_1["default"][network].rpc[0];
22
+ if (type === 'light' && ((_a = networks_json_1["default"][network].light) === null || _a === void 0 ? void 0 : _a.length))
23
+ url = networks_json_1["default"][network].light[0];
24
+ var connectionInfo = typeof url === 'object'
25
+ ? __assign(__assign({}, url), { timeout: 25000 }) : { url: url, timeout: 25000 };
26
+ if (!providers[network] || !providers[network][type]) {
27
+ providers[network] = __assign({}, providers[network]);
28
+ providers[network][type] = new providers_1.StaticJsonRpcProvider(connectionInfo);
29
+ }
30
+ return providers[network][type];
31
+ }
32
+ exports["default"] = getProvider;
33
+ function getBatchedProvider(network, type) {
34
+ var _a;
35
+ if (type === void 0) { type = 'archive'; }
36
+ var url = networks_json_1["default"][network].rpc[0];
37
+ if (type === 'light' && ((_a = networks_json_1["default"][network].light) === null || _a === void 0 ? void 0 : _a.length))
38
+ url = networks_json_1["default"][network].light[0];
39
+ var connectionInfo = typeof url === 'object'
40
+ ? __assign(__assign({}, url), { timeout: 25000 }) : { url: url, timeout: 25000 };
41
+ if (!providers[network] || !providers[network][type]) {
42
+ providers[network] = __assign({}, providers[network]);
43
+ providers[network][type] = new providers_1.JsonRpcBatchProvider(connectionInfo);
44
+ }
45
+ return providers[network][type];
46
+ }
47
+ exports.getBatchedProvider = getBatchedProvider;