@snapshot-labs/snapshot.js 0.12.64 → 0.13.0
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/dist/snapshot.cjs.js +1319 -1276
- package/dist/snapshot.esm.js +1319 -1276
- package/dist/snapshot.min.js +23 -23
- package/dist/src/index.d.ts +17 -3
- package/dist/src/schemas/index.d.ts +17 -3
- package/dist/src/utils.d.ts +1 -1
- package/package.json +1 -1
- package/src/schemas/space.json +21 -8
- package/src/sign/hashedTypes.json +11 -1
- package/src/sign/index.ts +5 -3
- package/src/sign/types.ts +10 -10
- package/src/utils.spec.js +57 -26
- package/src/utils.ts +8 -3
package/dist/src/index.d.ts
CHANGED
|
@@ -155,7 +155,11 @@ declare const _default: {
|
|
|
155
155
|
maxItems: number;
|
|
156
156
|
items: {
|
|
157
157
|
type: string;
|
|
158
|
-
|
|
158
|
+
anyOf: {
|
|
159
|
+
type: string;
|
|
160
|
+
format: string;
|
|
161
|
+
}[];
|
|
162
|
+
errorMessage: string;
|
|
159
163
|
};
|
|
160
164
|
title: string;
|
|
161
165
|
uniqueItems: boolean;
|
|
@@ -165,7 +169,11 @@ declare const _default: {
|
|
|
165
169
|
maxItems: number;
|
|
166
170
|
items: {
|
|
167
171
|
type: string;
|
|
168
|
-
|
|
172
|
+
anyOf: {
|
|
173
|
+
type: string;
|
|
174
|
+
format: string;
|
|
175
|
+
}[];
|
|
176
|
+
errorMessage: string;
|
|
169
177
|
};
|
|
170
178
|
title: string;
|
|
171
179
|
uniqueItems: boolean;
|
|
@@ -175,7 +183,11 @@ declare const _default: {
|
|
|
175
183
|
maxItems: number;
|
|
176
184
|
items: {
|
|
177
185
|
type: string;
|
|
178
|
-
|
|
186
|
+
anyOf: {
|
|
187
|
+
type: string;
|
|
188
|
+
format: string;
|
|
189
|
+
}[];
|
|
190
|
+
errorMessage: string;
|
|
179
191
|
};
|
|
180
192
|
title: string;
|
|
181
193
|
uniqueItems: boolean;
|
|
@@ -270,6 +282,7 @@ declare const _default: {
|
|
|
270
282
|
description: string;
|
|
271
283
|
examples: string[];
|
|
272
284
|
anyOf: {
|
|
285
|
+
type: string;
|
|
273
286
|
format: string;
|
|
274
287
|
}[];
|
|
275
288
|
errorMessage: string;
|
|
@@ -378,6 +391,7 @@ declare const _default: {
|
|
|
378
391
|
title: string;
|
|
379
392
|
examples: string[];
|
|
380
393
|
anyOf: {
|
|
394
|
+
type: string;
|
|
381
395
|
format: string;
|
|
382
396
|
}[];
|
|
383
397
|
errorMessage: string;
|
|
@@ -151,7 +151,11 @@ declare const _default: {
|
|
|
151
151
|
maxItems: number;
|
|
152
152
|
items: {
|
|
153
153
|
type: string;
|
|
154
|
-
|
|
154
|
+
anyOf: {
|
|
155
|
+
type: string;
|
|
156
|
+
format: string;
|
|
157
|
+
}[];
|
|
158
|
+
errorMessage: string;
|
|
155
159
|
};
|
|
156
160
|
title: string;
|
|
157
161
|
uniqueItems: boolean;
|
|
@@ -161,7 +165,11 @@ declare const _default: {
|
|
|
161
165
|
maxItems: number;
|
|
162
166
|
items: {
|
|
163
167
|
type: string;
|
|
164
|
-
|
|
168
|
+
anyOf: {
|
|
169
|
+
type: string;
|
|
170
|
+
format: string;
|
|
171
|
+
}[];
|
|
172
|
+
errorMessage: string;
|
|
165
173
|
};
|
|
166
174
|
title: string;
|
|
167
175
|
uniqueItems: boolean;
|
|
@@ -171,7 +179,11 @@ declare const _default: {
|
|
|
171
179
|
maxItems: number;
|
|
172
180
|
items: {
|
|
173
181
|
type: string;
|
|
174
|
-
|
|
182
|
+
anyOf: {
|
|
183
|
+
type: string;
|
|
184
|
+
format: string;
|
|
185
|
+
}[];
|
|
186
|
+
errorMessage: string;
|
|
175
187
|
};
|
|
176
188
|
title: string;
|
|
177
189
|
uniqueItems: boolean;
|
|
@@ -266,6 +278,7 @@ declare const _default: {
|
|
|
266
278
|
description: string;
|
|
267
279
|
examples: string[];
|
|
268
280
|
anyOf: {
|
|
281
|
+
type: string;
|
|
269
282
|
format: string;
|
|
270
283
|
}[];
|
|
271
284
|
errorMessage: string;
|
|
@@ -374,6 +387,7 @@ declare const _default: {
|
|
|
374
387
|
title: string;
|
|
375
388
|
examples: string[];
|
|
376
389
|
anyOf: {
|
|
390
|
+
type: string;
|
|
377
391
|
format: string;
|
|
378
392
|
}[];
|
|
379
393
|
errorMessage: string;
|
package/dist/src/utils.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ export declare function sleep(time: any): Promise<unknown>;
|
|
|
38
38
|
export declare function getNumberWithOrdinal(n: any): string;
|
|
39
39
|
export declare function isStarknetAddress(address: string): boolean;
|
|
40
40
|
export declare function isEvmAddress(address: string): boolean;
|
|
41
|
-
export declare function getFormattedAddress(address: string, format
|
|
41
|
+
export declare function getFormattedAddress(address: string, format?: 'evm' | 'starknet'): string;
|
|
42
42
|
export { getDelegatesBySpace, SNAPSHOT_SUBGRAPH_URL };
|
|
43
43
|
declare const _default: {
|
|
44
44
|
call: typeof call;
|
package/package.json
CHANGED
package/src/schemas/space.json
CHANGED
|
@@ -154,7 +154,11 @@
|
|
|
154
154
|
"maxItems": 100,
|
|
155
155
|
"items": {
|
|
156
156
|
"type": "string",
|
|
157
|
-
"
|
|
157
|
+
"anyOf": [
|
|
158
|
+
{ "type": "string", "format": "evmAddress" },
|
|
159
|
+
{ "type": "string", "format": "starknetAddress" }
|
|
160
|
+
],
|
|
161
|
+
"errorMessage": "Must be a valid address"
|
|
158
162
|
},
|
|
159
163
|
"title": "members",
|
|
160
164
|
"uniqueItems": true
|
|
@@ -164,7 +168,11 @@
|
|
|
164
168
|
"maxItems": 100,
|
|
165
169
|
"items": {
|
|
166
170
|
"type": "string",
|
|
167
|
-
"
|
|
171
|
+
"anyOf": [
|
|
172
|
+
{ "type": "string", "format": "evmAddress" },
|
|
173
|
+
{ "type": "string", "format": "starknetAddress" }
|
|
174
|
+
],
|
|
175
|
+
"errorMessage": "Must be a valid address"
|
|
168
176
|
},
|
|
169
177
|
"title": "admins",
|
|
170
178
|
"uniqueItems": true
|
|
@@ -174,7 +182,11 @@
|
|
|
174
182
|
"maxItems": 100,
|
|
175
183
|
"items": {
|
|
176
184
|
"type": "string",
|
|
177
|
-
"
|
|
185
|
+
"anyOf": [
|
|
186
|
+
{ "type": "string", "format": "evmAddress" },
|
|
187
|
+
{ "type": "string", "format": "starknetAddress" }
|
|
188
|
+
],
|
|
189
|
+
"errorMessage": "Must be a valid address"
|
|
178
190
|
},
|
|
179
191
|
"title": "moderators",
|
|
180
192
|
"uniqueItems": true
|
|
@@ -260,7 +272,8 @@
|
|
|
260
272
|
"description": "Specify the type of delegation that you are using",
|
|
261
273
|
"anyOf": [
|
|
262
274
|
{ "const": "compound-governor", "title": "Compound governor" },
|
|
263
|
-
{ "const": "split-delegation", "title": "Split Delegation" }
|
|
275
|
+
{ "const": "split-delegation", "title": "Split Delegation" },
|
|
276
|
+
{ "const": "apechain-delegate-registry", "title": "ApeChain Delegate Registry" }
|
|
264
277
|
]
|
|
265
278
|
},
|
|
266
279
|
"delegationContract": {
|
|
@@ -269,8 +282,8 @@
|
|
|
269
282
|
"description": "The address of your delegation contract",
|
|
270
283
|
"examples": ["0x3901D0fDe202aF1427216b79f5243f8A022d68cf"],
|
|
271
284
|
"anyOf": [
|
|
272
|
-
{ "format": "evmAddress" },
|
|
273
|
-
{ "format": "starknetAddress" }
|
|
285
|
+
{ "type": "string", "format": "evmAddress" },
|
|
286
|
+
{ "type": "string", "format": "starknetAddress" }
|
|
274
287
|
],
|
|
275
288
|
"errorMessage": "Must be a valid EVM of Starknet address"
|
|
276
289
|
},
|
|
@@ -396,8 +409,8 @@
|
|
|
396
409
|
"title": "Contract address",
|
|
397
410
|
"examples": ["e.g. 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984"],
|
|
398
411
|
"anyOf": [
|
|
399
|
-
{ "format": "evmAddress" },
|
|
400
|
-
{ "format": "starknetAddress" }
|
|
412
|
+
{ "type": "string", "format": "evmAddress" },
|
|
413
|
+
{ "type": "string", "format": "starknetAddress" }
|
|
401
414
|
],
|
|
402
415
|
"errorMessage": "Must be a valid EVM of Starknet address"
|
|
403
416
|
},
|
|
@@ -64,5 +64,15 @@
|
|
|
64
64
|
"d56782e3b50ac86c25ae292923da8c367e3c9e8e7ea9d8baa435051fe2f430fa": "proposal",
|
|
65
65
|
"df10a7eeabe19301d6018be8b6c5d13231320d7ece64d021043fa172b64f3796": "update-proposal",
|
|
66
66
|
"beda1f464a6112f9ed6335c4614e32a97f0e18ef4ac10b4b1c8239c475f2d8e8": "proposal",
|
|
67
|
-
"ff74674f39ca59b60056ecddaada0cb513c4729e634e99cb778f53ee404ac806": "update-proposal"
|
|
67
|
+
"ff74674f39ca59b60056ecddaada0cb513c4729e634e99cb778f53ee404ac806": "update-proposal",
|
|
68
|
+
"e037b37311c75c995f732b57cd456bdc685e5eac29668698be34388cafb14097": "proposal",
|
|
69
|
+
"9c66485d2c9af4010e89b0352e3f78ce2aa96661c531b1bdbd7042388867e830": "update-proposal",
|
|
70
|
+
"dd19ee4357e5bc813529e1b537b77ccb767135701f0223434f3b53f1ac03dcc6": "delete-proposal",
|
|
71
|
+
"817265460009cfdbde0752fcc7ef629ae7e05a6e8b6cbffab8a7cbf6cd19e87e": "delete-proposal",
|
|
72
|
+
"fb8fa9816cd42974e7f1af671aa548c8c458553364ed809e45042f141de8c0d5": "vote",
|
|
73
|
+
"5f95ed849bafb034c37e340dc06ad6fa6985d674714cb602a6bf11119ffba2a1": "vote-array",
|
|
74
|
+
"afc5911fd9722b3dc5e8b16a552997510644a52d2b229c3868fb1910b112416e": "vote-string",
|
|
75
|
+
"e4b768874f191321f9a6460e15f87e98800c78c1e3104f9d4e443f2ed9b1c45e": "vote",
|
|
76
|
+
"86c81555a3dda45aa7b151c574dc27f7402c23d9b1432156f1daa6c2e15f9891": "vote-array",
|
|
77
|
+
"c0f418890817b3e6deb58fa3182bf8ed7619242666a9087eab28f27a6876e1da": "vote-string"
|
|
68
78
|
}
|
package/src/sign/index.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import fetch from 'cross-fetch';
|
|
2
2
|
import { Web3Provider } from '@ethersproject/providers';
|
|
3
3
|
import { Wallet } from '@ethersproject/wallet';
|
|
4
|
-
import { getAddress } from '@ethersproject/address';
|
|
5
4
|
import {
|
|
6
5
|
Space,
|
|
7
6
|
Proposal,
|
|
@@ -39,6 +38,7 @@ import {
|
|
|
39
38
|
statementTypes
|
|
40
39
|
} from './types';
|
|
41
40
|
import constants from '../constants.json';
|
|
41
|
+
import { getFormattedAddress } from '../utils';
|
|
42
42
|
|
|
43
43
|
const NAME = 'snapshot';
|
|
44
44
|
const VERSION = '0.1.4';
|
|
@@ -74,8 +74,10 @@ export default class Client {
|
|
|
74
74
|
async sign(web3: Web3Provider | Wallet, address: string, message, types) {
|
|
75
75
|
// @ts-ignore
|
|
76
76
|
const signer = web3?.getSigner ? web3.getSigner() : web3;
|
|
77
|
-
const checksumAddress =
|
|
78
|
-
message.from = message.from
|
|
77
|
+
const checksumAddress = getFormattedAddress(address, 'evm');
|
|
78
|
+
message.from = message.from
|
|
79
|
+
? getFormattedAddress(message.from)
|
|
80
|
+
: checksumAddress;
|
|
79
81
|
if (!message.timestamp)
|
|
80
82
|
message.timestamp = parseInt((Date.now() / 1e3).toFixed());
|
|
81
83
|
|
package/src/sign/types.ts
CHANGED
|
@@ -139,7 +139,7 @@ export const spaceTypes = {
|
|
|
139
139
|
|
|
140
140
|
export const proposalTypes = {
|
|
141
141
|
Proposal: [
|
|
142
|
-
{ name: 'from', type: '
|
|
142
|
+
{ name: 'from', type: 'string' },
|
|
143
143
|
{ name: 'space', type: 'string' },
|
|
144
144
|
{ name: 'timestamp', type: 'uint64' },
|
|
145
145
|
{ name: 'type', type: 'string' },
|
|
@@ -160,7 +160,7 @@ export const proposalTypes = {
|
|
|
160
160
|
export const updateProposalTypes = {
|
|
161
161
|
UpdateProposal: [
|
|
162
162
|
{ name: 'proposal', type: 'string' },
|
|
163
|
-
{ name: 'from', type: '
|
|
163
|
+
{ name: 'from', type: 'string' },
|
|
164
164
|
{ name: 'space', type: 'string' },
|
|
165
165
|
{ name: 'timestamp', type: 'uint64' },
|
|
166
166
|
{ name: 'type', type: 'string' },
|
|
@@ -185,7 +185,7 @@ export const flagProposalTypes = {
|
|
|
185
185
|
|
|
186
186
|
export const cancelProposalTypes = {
|
|
187
187
|
CancelProposal: [
|
|
188
|
-
{ name: 'from', type: '
|
|
188
|
+
{ name: 'from', type: 'string' },
|
|
189
189
|
{ name: 'space', type: 'string' },
|
|
190
190
|
{ name: 'timestamp', type: 'uint64' },
|
|
191
191
|
{ name: 'proposal', type: 'string' }
|
|
@@ -194,7 +194,7 @@ export const cancelProposalTypes = {
|
|
|
194
194
|
|
|
195
195
|
export const cancelProposal2Types = {
|
|
196
196
|
CancelProposal: [
|
|
197
|
-
{ name: 'from', type: '
|
|
197
|
+
{ name: 'from', type: 'string' },
|
|
198
198
|
{ name: 'space', type: 'string' },
|
|
199
199
|
{ name: 'timestamp', type: 'uint64' },
|
|
200
200
|
{ name: 'proposal', type: 'bytes32' }
|
|
@@ -203,7 +203,7 @@ export const cancelProposal2Types = {
|
|
|
203
203
|
|
|
204
204
|
export const voteTypes = {
|
|
205
205
|
Vote: [
|
|
206
|
-
{ name: 'from', type: '
|
|
206
|
+
{ name: 'from', type: 'string' },
|
|
207
207
|
{ name: 'space', type: 'string' },
|
|
208
208
|
{ name: 'timestamp', type: 'uint64' },
|
|
209
209
|
{ name: 'proposal', type: 'string' },
|
|
@@ -216,7 +216,7 @@ export const voteTypes = {
|
|
|
216
216
|
|
|
217
217
|
export const voteArrayTypes = {
|
|
218
218
|
Vote: [
|
|
219
|
-
{ name: 'from', type: '
|
|
219
|
+
{ name: 'from', type: 'string' },
|
|
220
220
|
{ name: 'space', type: 'string' },
|
|
221
221
|
{ name: 'timestamp', type: 'uint64' },
|
|
222
222
|
{ name: 'proposal', type: 'string' },
|
|
@@ -229,7 +229,7 @@ export const voteArrayTypes = {
|
|
|
229
229
|
|
|
230
230
|
export const voteStringTypes = {
|
|
231
231
|
Vote: [
|
|
232
|
-
{ name: 'from', type: '
|
|
232
|
+
{ name: 'from', type: 'string' },
|
|
233
233
|
{ name: 'space', type: 'string' },
|
|
234
234
|
{ name: 'timestamp', type: 'uint64' },
|
|
235
235
|
{ name: 'proposal', type: 'string' },
|
|
@@ -242,7 +242,7 @@ export const voteStringTypes = {
|
|
|
242
242
|
|
|
243
243
|
export const vote2Types = {
|
|
244
244
|
Vote: [
|
|
245
|
-
{ name: 'from', type: '
|
|
245
|
+
{ name: 'from', type: 'string' },
|
|
246
246
|
{ name: 'space', type: 'string' },
|
|
247
247
|
{ name: 'timestamp', type: 'uint64' },
|
|
248
248
|
{ name: 'proposal', type: 'bytes32' },
|
|
@@ -255,7 +255,7 @@ export const vote2Types = {
|
|
|
255
255
|
|
|
256
256
|
export const voteArray2Types = {
|
|
257
257
|
Vote: [
|
|
258
|
-
{ name: 'from', type: '
|
|
258
|
+
{ name: 'from', type: 'string' },
|
|
259
259
|
{ name: 'space', type: 'string' },
|
|
260
260
|
{ name: 'timestamp', type: 'uint64' },
|
|
261
261
|
{ name: 'proposal', type: 'bytes32' },
|
|
@@ -268,7 +268,7 @@ export const voteArray2Types = {
|
|
|
268
268
|
|
|
269
269
|
export const voteString2Types = {
|
|
270
270
|
Vote: [
|
|
271
|
-
{ name: 'from', type: '
|
|
271
|
+
{ name: 'from', type: 'string' },
|
|
272
272
|
{ name: 'space', type: 'string' },
|
|
273
273
|
{ name: 'timestamp', type: 'uint64' },
|
|
274
274
|
{ name: 'proposal', type: 'bytes32' },
|
package/src/utils.spec.js
CHANGED
|
@@ -504,37 +504,68 @@ describe('utils', () => {
|
|
|
504
504
|
});
|
|
505
505
|
|
|
506
506
|
describe('getFormattedAddress', () => {
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
'
|
|
511
|
-
|
|
512
|
-
|
|
507
|
+
describe('when explicitly passing an address type', () => {
|
|
508
|
+
test('returns a checksummed EVM address', () => {
|
|
509
|
+
const address = '0x91fd2c8d24767db4ece7069aa27832ffaf8590f3';
|
|
510
|
+
expect(getFormattedAddress(address, 'evm')).toEqual(
|
|
511
|
+
'0x91FD2c8d24767db4Ece7069AA27832ffaf8590f3'
|
|
512
|
+
);
|
|
513
|
+
});
|
|
513
514
|
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
515
|
+
test('returns a padded and lowercased starknet address', () => {
|
|
516
|
+
const address =
|
|
517
|
+
'0x2a0a8f3b6097e7a6bd7649deb30715323072a159c0e6b71b689bd245c146cc0';
|
|
518
|
+
expect(getFormattedAddress(address, 'starknet')).toEqual(
|
|
519
|
+
'0x02a0a8f3b6097e7a6bd7649deb30715323072a159c0e6b71b689bd245c146cc0'
|
|
520
|
+
);
|
|
521
|
+
});
|
|
521
522
|
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
523
|
+
test('returns an EVM address as starknet address', () => {
|
|
524
|
+
const address = '0x91FD2c8d24767db4Ece7069AA27832ffaf8590f3';
|
|
525
|
+
expect(getFormattedAddress(address, 'starknet')).toEqual(
|
|
526
|
+
'0x00000000000000000000000091fd2c8d24767db4ece7069aa27832ffaf8590f3'
|
|
527
|
+
);
|
|
528
|
+
});
|
|
528
529
|
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
530
|
+
test('throws an error when the address is not a starknet address', () => {
|
|
531
|
+
const address = 'hello';
|
|
532
|
+
expect(() => getFormattedAddress(address, 'starknet')).toThrow();
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
test('throws an error when the address is not an EVM address', () => {
|
|
536
|
+
const address =
|
|
537
|
+
'0x2a0a8f3b6097e7a6bd7649deb30715323072a159c0e6b71b689bd245c146cc0';
|
|
538
|
+
expect(() => getFormattedAddress(address, 'evm')).toThrow();
|
|
539
|
+
});
|
|
532
540
|
});
|
|
533
541
|
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
'
|
|
537
|
-
|
|
542
|
+
describe('when not passing an address type', () => {
|
|
543
|
+
test('returns a checksummed EVM address for an EVM input', () => {
|
|
544
|
+
const address = '0x91fd2c8d24767db4ece7069aa27832ffaf8590f3';
|
|
545
|
+
expect(getFormattedAddress(address)).toEqual(
|
|
546
|
+
'0x91FD2c8d24767db4Ece7069AA27832ffaf8590f3'
|
|
547
|
+
);
|
|
548
|
+
});
|
|
549
|
+
|
|
550
|
+
test('returns a padded and lowercased starknet address for a Starknet input', () => {
|
|
551
|
+
const address =
|
|
552
|
+
'0x2a0a8f3b6097e7a6bd7649deb30715323072a159c0e6b71b689bd245c146cc0';
|
|
553
|
+
expect(getFormattedAddress(address)).toEqual(
|
|
554
|
+
'0x02a0a8f3b6097e7a6bd7649deb30715323072a159c0e6b71b689bd245c146cc0'
|
|
555
|
+
);
|
|
556
|
+
});
|
|
557
|
+
|
|
558
|
+
test('throws an error when the input is not address-like', () => {
|
|
559
|
+
const address = 'hello';
|
|
560
|
+
expect(() => getFormattedAddress(address)).toThrow();
|
|
561
|
+
});
|
|
562
|
+
|
|
563
|
+
test('returns a padded and lowercased starknet address for any non-EVM like address input', () => {
|
|
564
|
+
const address = '0x1';
|
|
565
|
+
expect(getFormattedAddress(address)).toEqual(
|
|
566
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001'
|
|
567
|
+
);
|
|
568
|
+
});
|
|
538
569
|
});
|
|
539
570
|
});
|
|
540
571
|
|
package/src/utils.ts
CHANGED
|
@@ -828,10 +828,15 @@ export function isEvmAddress(address: string): boolean {
|
|
|
828
828
|
|
|
829
829
|
export function getFormattedAddress(
|
|
830
830
|
address: string,
|
|
831
|
-
format
|
|
831
|
+
format?: 'evm' | 'starknet'
|
|
832
832
|
): string {
|
|
833
|
-
|
|
834
|
-
|
|
833
|
+
// Consider non-evm addresses as Starknet by default
|
|
834
|
+
// as there's no other way to differentiate them
|
|
835
|
+
const addressType = format ?? (isEvmAddress(address) ? 'evm' : 'starknet');
|
|
836
|
+
|
|
837
|
+
if (addressType === 'evm' && isEvmAddress(address))
|
|
838
|
+
return getAddress(address);
|
|
839
|
+
if (addressType === 'starknet' && isStarknetAddress(address))
|
|
835
840
|
return validateAndParseAddress(address);
|
|
836
841
|
|
|
837
842
|
throw new Error(`Invalid address: ${address}`);
|