mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-21 06:10:44 +08:00
Remove usage of Gnosis Safe subgraph
This commit is contained in:
+2
-14
@@ -29,15 +29,6 @@ const GetOrgs = `
|
||||
}
|
||||
`;
|
||||
|
||||
const GetSafes = `
|
||||
query GetSafes($owners: [String!]!) {
|
||||
wallets(where: { owners_contains: $owners }) {
|
||||
id
|
||||
owners
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const GetOrgsByOwner = `
|
||||
query GetOrgsByOwner($owners: [String!]!) {
|
||||
orgs(where: { owner_in: $owners }) {
|
||||
@@ -225,11 +216,8 @@ export class Org {
|
||||
}
|
||||
|
||||
static async getOrgsByMember(memberAddr: string, config: Config): Promise<Org[]> {
|
||||
const safeResult = await utils.querySubgraph(
|
||||
config.safe.subgraph, GetSafes, { owners: [memberAddr] }
|
||||
);
|
||||
const wallets: { id: string }[] = safeResult.wallets;
|
||||
const owners = wallets.map(wallet => wallet.id).concat([memberAddr]);
|
||||
const wallets = await utils.getOwnerSafes(memberAddr, config);
|
||||
const owners = wallets?.concat([memberAddr]);
|
||||
const orgsResult = await utils.querySubgraph(config.orgs.subgraph, GetOrgsByOwner, { owners });
|
||||
|
||||
return orgsResult.orgs.map((o: { id: string; owner: string }) => {
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
},
|
||||
"safe": {
|
||||
"api": "https://safe-transaction.gnosis.io",
|
||||
"subgraph": "https://api.thegraph.com/subgraphs/name/radicle-dev/gnosis-safe",
|
||||
"viewer": "https://gnosis-safe.io/app/#/safes"
|
||||
},
|
||||
"tokens": []
|
||||
@@ -38,7 +37,6 @@
|
||||
},
|
||||
"safe": {
|
||||
"api": null,
|
||||
"subgraph": null,
|
||||
"viewer": null
|
||||
},
|
||||
"tokens": []
|
||||
@@ -60,7 +58,6 @@
|
||||
},
|
||||
"safe": {
|
||||
"api": "https://safe-transaction.rinkeby.gnosis.io",
|
||||
"subgraph": "https://api.thegraph.com/subgraphs/name/radicle-dev/gnosis-safe-rinkeby",
|
||||
"viewer": "https://rinkeby.gnosis-safe.io/app/#/safes"
|
||||
},
|
||||
"tokens": []
|
||||
|
||||
@@ -24,7 +24,6 @@ export class Config {
|
||||
safe: {
|
||||
api?: string;
|
||||
client?: SafeServiceClient;
|
||||
subgraph: string;
|
||||
viewer: string | null;
|
||||
};
|
||||
abi: { [contract: string]: string[] };
|
||||
|
||||
@@ -266,6 +266,24 @@ export async function getSafe(address: string, config: Config): Promise<Safe | n
|
||||
};
|
||||
}
|
||||
|
||||
// Get the Gnosis Safe addresses owned by the given address.
|
||||
export async function getOwnerSafes(owner: string, config: Config): Promise<string[] | null> {
|
||||
if (! config.safe.api) return null;
|
||||
|
||||
const addr = ethers.utils.getAddress(owner);
|
||||
const response = await fetch(`${config.safe.api}/api/v1/owners/${addr}/safes/`, {
|
||||
method: 'GET',
|
||||
headers: { 'Accept': 'application/json' }
|
||||
});
|
||||
|
||||
if (! response.ok) {
|
||||
return null;
|
||||
}
|
||||
const json = await response.json();
|
||||
|
||||
return json.safes;
|
||||
}
|
||||
|
||||
// Get token balances for an address.
|
||||
export async function getTokens(address: string, config: Config):
|
||||
Promise<Array<{ tokenName: string; tokenLogo: string }>>
|
||||
|
||||
Reference in New Issue
Block a user