forked from argentlabs/argent-starknet-recover
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getSigner.ts
38 lines (34 loc) · 899 Bytes
/
getSigner.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { SequencerProvider } from "starknet";
import { Multicall } from "@argent/x-multicall";
export async function getSigners(
addresses: string[],
network: "mainnet-alpha" | "goerli-alpha"
) {
const provider = new SequencerProvider({ network });
const multicallProvider = new Multicall(provider as any);
const signerAnswers = await Promise.allSettled(
addresses.map((address) =>
multicallProvider
.call({
contractAddress: address,
entrypoint: "getSigner",
})
.catch(() =>
multicallProvider.call({
contractAddress: address,
entrypoint: "get_signer",
})
)
)
);
const signers = signerAnswers
.map((answer) => {
if (answer.status === "fulfilled") {
return answer.value;
} else {
return null;
}
})
.flat();
return signers;
}