Skip to content

Commit

Permalink
Add reclaim functions to subgraph client
Browse files Browse the repository at this point in the history
  • Loading branch information
solimander committed Jan 22, 2024
1 parent 54dbe69 commit 22860e1
Show file tree
Hide file tree
Showing 9 changed files with 269 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/prop-house-sdk-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@prophouse/sdk-react",
"version": "1.0.19",
"version": "1.0.21",
"description": "Useful tools for interacting with the Prop House protocol from React applications",
"author": "solimander",
"homepage": "https://prop.house",
Expand All @@ -18,7 +18,7 @@
"wagmi": ">=0.9.2"
},
"dependencies": {
"@prophouse/sdk": "1.0.24"
"@prophouse/sdk": "1.0.26"
},
"devDependencies": {
"react": "^17.0.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/prop-house-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@prophouse/sdk",
"version": "1.0.25",
"version": "1.0.27",
"description": "Useful tools for interacting with the Prop House protocol",
"author": "solimander",
"homepage": "https://prop.house",
Expand Down
8 changes: 8 additions & 0 deletions packages/prop-house-sdk/src/gql/evm/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ const documents = {
types.ManyDepositsDocument,
'\n query manyClaims(\n $first: Int!\n $skip: Int!\n $orderBy: Claim_orderBy\n $orderDirection: OrderDirection\n $where: Claim_filter\n ) {\n claims(\n first: $first\n skip: $skip\n orderBy: $orderBy\n orderDirection: $orderDirection\n where: $where\n ) {\n id\n txHash\n claimedAt\n recipient\n proposalId\n round {\n id\n }\n asset {\n assetType\n token\n identifier\n }\n amount\n }\n }\n':
types.ManyClaimsDocument,
'\n query manyReclaims(\n $first: Int!\n $skip: Int!\n $orderBy: Reclaim_orderBy\n $orderDirection: OrderDirection\n $where: Reclaim_filter\n ) {\n reclaims(\n first: $first\n skip: $skip\n orderBy: $orderBy\n orderDirection: $orderDirection\n where: $where\n ) {\n id\n txHash\n reclaimer {\n id\n }\n reclaimedAt\n asset {\n assetType\n token\n identifier\n }\n amount\n round {\n id\n }\n }\n }\n':
types.ManyReclaimsDocument,
};

/**
Expand Down Expand Up @@ -141,6 +143,12 @@ export function graphql(
export function graphql(
source: '\n query manyClaims(\n $first: Int!\n $skip: Int!\n $orderBy: Claim_orderBy\n $orderDirection: OrderDirection\n $where: Claim_filter\n ) {\n claims(\n first: $first\n skip: $skip\n orderBy: $orderBy\n orderDirection: $orderDirection\n where: $where\n ) {\n id\n txHash\n claimedAt\n recipient\n proposalId\n round {\n id\n }\n asset {\n assetType\n token\n identifier\n }\n amount\n }\n }\n',
): (typeof documents)['\n query manyClaims(\n $first: Int!\n $skip: Int!\n $orderBy: Claim_orderBy\n $orderDirection: OrderDirection\n $where: Claim_filter\n ) {\n claims(\n first: $first\n skip: $skip\n orderBy: $orderBy\n orderDirection: $orderDirection\n where: $where\n ) {\n id\n txHash\n claimedAt\n recipient\n proposalId\n round {\n id\n }\n asset {\n assetType\n token\n identifier\n }\n amount\n }\n }\n'];
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
export function graphql(
source: '\n query manyReclaims(\n $first: Int!\n $skip: Int!\n $orderBy: Reclaim_orderBy\n $orderDirection: OrderDirection\n $where: Reclaim_filter\n ) {\n reclaims(\n first: $first\n skip: $skip\n orderBy: $orderBy\n orderDirection: $orderDirection\n where: $where\n ) {\n id\n txHash\n reclaimer {\n id\n }\n reclaimedAt\n asset {\n assetType\n token\n identifier\n }\n amount\n round {\n id\n }\n }\n }\n',
): (typeof documents)['\n query manyReclaims(\n $first: Int!\n $skip: Int!\n $orderBy: Reclaim_orderBy\n $orderDirection: OrderDirection\n $where: Reclaim_filter\n ) {\n reclaims(\n first: $first\n skip: $skip\n orderBy: $orderBy\n orderDirection: $orderDirection\n where: $where\n ) {\n id\n txHash\n reclaimer {\n id\n }\n reclaimedAt\n asset {\n assetType\n token\n identifier\n }\n amount\n round {\n id\n }\n }\n }\n'];

export function graphql(source: string) {
return (documents as any)[source] ?? {};
Expand Down
139 changes: 139 additions & 0 deletions packages/prop-house-sdk/src/gql/evm/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,7 @@ export type GovPowerStrategyVotingStrategyRoundsArgs = {
export enum GovPowerStrategyType {
Allowlist = 'ALLOWLIST',
BalanceOf = 'BALANCE_OF',
BalanceOfErc20 = 'BALANCE_OF_ERC20',
BalanceOfErc1155 = 'BALANCE_OF_ERC1155',
CheckpointableErc721 = 'CHECKPOINTABLE_ERC721',
Unknown = 'UNKNOWN',
Expand Down Expand Up @@ -3739,6 +3740,28 @@ export type ManyClaimsQuery = {
}>;
};

export type ManyReclaimsQueryVariables = Exact<{
first: Scalars['Int'];
skip: Scalars['Int'];
orderBy?: InputMaybe<Reclaim_OrderBy>;
orderDirection?: InputMaybe<OrderDirection>;
where?: InputMaybe<Reclaim_Filter>;
}>;

export type ManyReclaimsQuery = {
__typename?: 'Query';
reclaims: Array<{
__typename?: 'Reclaim';
id: string;
txHash: any;
reclaimedAt: any;
amount: any;
reclaimer: { __typename?: 'Account'; id: string };
asset: { __typename?: 'Asset'; assetType: AssetType; token: any; identifier: any };
round: { __typename?: 'Round'; id: string };
}>;
};

export const HouseFieldsFragmentDoc = {
kind: 'Document',
definitions: [
Expand Down Expand Up @@ -5572,3 +5595,119 @@ export const ManyClaimsDocument = {
},
],
} as unknown as DocumentNode<ManyClaimsQuery, ManyClaimsQueryVariables>;
export const ManyReclaimsDocument = {
kind: 'Document',
definitions: [
{
kind: 'OperationDefinition',
operation: 'query',
name: { kind: 'Name', value: 'manyReclaims' },
variableDefinitions: [
{
kind: 'VariableDefinition',
variable: { kind: 'Variable', name: { kind: 'Name', value: 'first' } },
type: {
kind: 'NonNullType',
type: { kind: 'NamedType', name: { kind: 'Name', value: 'Int' } },
},
},
{
kind: 'VariableDefinition',
variable: { kind: 'Variable', name: { kind: 'Name', value: 'skip' } },
type: {
kind: 'NonNullType',
type: { kind: 'NamedType', name: { kind: 'Name', value: 'Int' } },
},
},
{
kind: 'VariableDefinition',
variable: { kind: 'Variable', name: { kind: 'Name', value: 'orderBy' } },
type: { kind: 'NamedType', name: { kind: 'Name', value: 'Reclaim_orderBy' } },
},
{
kind: 'VariableDefinition',
variable: { kind: 'Variable', name: { kind: 'Name', value: 'orderDirection' } },
type: { kind: 'NamedType', name: { kind: 'Name', value: 'OrderDirection' } },
},
{
kind: 'VariableDefinition',
variable: { kind: 'Variable', name: { kind: 'Name', value: 'where' } },
type: { kind: 'NamedType', name: { kind: 'Name', value: 'Reclaim_filter' } },
},
],
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'Field',
name: { kind: 'Name', value: 'reclaims' },
arguments: [
{
kind: 'Argument',
name: { kind: 'Name', value: 'first' },
value: { kind: 'Variable', name: { kind: 'Name', value: 'first' } },
},
{
kind: 'Argument',
name: { kind: 'Name', value: 'skip' },
value: { kind: 'Variable', name: { kind: 'Name', value: 'skip' } },
},
{
kind: 'Argument',
name: { kind: 'Name', value: 'orderBy' },
value: { kind: 'Variable', name: { kind: 'Name', value: 'orderBy' } },
},
{
kind: 'Argument',
name: { kind: 'Name', value: 'orderDirection' },
value: { kind: 'Variable', name: { kind: 'Name', value: 'orderDirection' } },
},
{
kind: 'Argument',
name: { kind: 'Name', value: 'where' },
value: { kind: 'Variable', name: { kind: 'Name', value: 'where' } },
},
],
selectionSet: {
kind: 'SelectionSet',
selections: [
{ kind: 'Field', name: { kind: 'Name', value: 'id' } },
{ kind: 'Field', name: { kind: 'Name', value: 'txHash' } },
{
kind: 'Field',
name: { kind: 'Name', value: 'reclaimer' },
selectionSet: {
kind: 'SelectionSet',
selections: [{ kind: 'Field', name: { kind: 'Name', value: 'id' } }],
},
},
{ kind: 'Field', name: { kind: 'Name', value: 'reclaimedAt' } },
{
kind: 'Field',
name: { kind: 'Name', value: 'asset' },
selectionSet: {
kind: 'SelectionSet',
selections: [
{ kind: 'Field', name: { kind: 'Name', value: 'assetType' } },
{ kind: 'Field', name: { kind: 'Name', value: 'token' } },
{ kind: 'Field', name: { kind: 'Name', value: 'identifier' } },
],
},
},
{ kind: 'Field', name: { kind: 'Name', value: 'amount' } },
{
kind: 'Field',
name: { kind: 'Name', value: 'round' },
selectionSet: {
kind: 'SelectionSet',
selections: [{ kind: 'Field', name: { kind: 'Name', value: 'id' } }],
},
},
],
},
},
],
},
},
],
} as unknown as DocumentNode<ManyReclaimsQuery, ManyReclaimsQueryVariables>;
1 change: 1 addition & 0 deletions packages/prop-house-sdk/src/gql/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,5 @@ export {
Vote,
Deposit,
Claim,
Reclaim,
} from './types';
34 changes: 34 additions & 0 deletions packages/prop-house-sdk/src/gql/queries.evm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,37 @@ export const ManyClaimsQuery = graphql(`
}
}
`);

export const ManyReclaimsQuery = graphql(`
query manyReclaims(
$first: Int!
$skip: Int!
$orderBy: Reclaim_orderBy
$orderDirection: OrderDirection
$where: Reclaim_filter
) {
reclaims(
first: $first
skip: $skip
orderBy: $orderBy
orderDirection: $orderDirection
where: $where
) {
id
txHash
reclaimer {
id
}
reclaimedAt
asset {
assetType
token
identifier
}
amount
round {
id
}
}
}
`);
44 changes: 44 additions & 0 deletions packages/prop-house-sdk/src/gql/query-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import {
Deposit_Filter,
Claim_Filter,
RoundEventState,
Reclaim_OrderBy,
Reclaim_Filter,
} from './evm/graphql';
import {
HouseQuery,
Expand All @@ -28,6 +30,7 @@ import {
ManyGovPowerStrategiesQuery,
RoundQuery,
RoundWithHouseInfoQuery,
ManyReclaimsQuery,
} from './queries.evm';
import {
getDefaultConfig,
Expand Down Expand Up @@ -56,6 +59,7 @@ import {
RoundBalance,
Claim,
Deposit,
Reclaim,
} from './types';
import {
GlobalStatsQuery,
Expand Down Expand Up @@ -622,6 +626,46 @@ export class QueryWrapper {
});
}

/**
* Get paginated reclaims in the provided round address
* @param roundAddress The round address
* @param config Filtering, pagination, and ordering configuration
*/
public async getRoundReclaims(
roundAddress: Address,
config: Partial<QueryConfig<Reclaim_OrderBy, Reclaim_Filter>> = {},
) {
return this.getReclaims({
...config,
where: {
...config.where,
round: roundAddress.toLowerCase(),
},
});
}

/**
* Get paginated reclaims
* @param config Filtering, pagination, and ordering configuration
*/
public async getReclaims(config: Partial<QueryConfig<Reclaim_OrderBy, Reclaim_Filter>> = {}): Promise<Reclaim[]> {
const { reclaims } = await this._gql.evm.request(
ManyReclaimsQuery,
toPaginated(this.merge(getDefaultConfig(Reclaim_OrderBy.ReclaimedAt), config)),
);
return reclaims.map(reclaim => ({
id: reclaim.id,
txHash: reclaim.txHash,
reclaimedAt: reclaim.reclaimedAt,
reclaimer: reclaim.reclaimer.id,
round: reclaim.round.id,
asset: this.toAsset({
asset: reclaim.asset,
amount: reclaim.amount,
}),
}));
}

/**
* Get paginated proposals
* @param config Filtering, pagination, and ordering configuration
Expand Down
9 changes: 9 additions & 0 deletions packages/prop-house-sdk/src/gql/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,12 @@ export interface Claim {
round: string;
asset: Asset;
}

export interface Reclaim {
id: string;
txHash: string;
reclaimedAt: string;
reclaimer: string;
round: string;
asset: Asset;
}
31 changes: 31 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6023,6 +6023,37 @@
starknet "5.19.5"
time-ts "^0.1.0"

"@prophouse/[email protected]":
version "1.0.26"
resolved "https://registry.npmjs.org/@prophouse/sdk/-/sdk-1.0.26.tgz#4b4c305e0c35e1374f1307c67cef28309913370d"
integrity sha512-L6kkFD2i5f3aWqqleItDEdto5WyikI92IRBjZgfGXQbqjRvaeFlKMrgrBV5p0pT+I+lPCQ4QhkdGIaYlev69fQ==
dependencies:
"@ethersproject/abi" "~5.7.0"
"@ethersproject/abstract-provider" "~5.7.0"
"@ethersproject/abstract-signer" "~5.7.0"
"@ethersproject/address" "~5.7.0"
"@ethersproject/bignumber" "~5.7.0"
"@ethersproject/bytes" "~5.7.0"
"@ethersproject/constants" "~5.7.0"
"@ethersproject/contracts" "~5.7.0"
"@ethersproject/keccak256" "~5.7.0"
"@ethersproject/providers" "~5.7.0"
"@ethersproject/solidity" "~5.7.0"
"@ethersproject/strings" "~5.7.0"
"@ethersproject/wallet" "^5.7.0"
"@pinata/sdk" "^2.1.0"
"@prophouse/protocol" "1.0.8"
bn.js "^5.2.1"
ethereumjs-fork-block "^4.2.4"
ethereumjs-fork-common "^3.1.3"
graphql "^16.5.0"
graphql-request "5.0.0"
merkletreejs "^0.3.11"
micro-starknet "^0.2.3"
randombytes "^2.1.0"
starknet "5.19.5"
time-ts "^0.1.0"

"@protobufjs/aspromise@^1.1.1", "@protobufjs/aspromise@^1.1.2":
version "1.1.2"
resolved "https://registry.yarnpkg.com/@protobufjs/aspromise/-/aspromise-1.1.2.tgz#9b8b0cc663d669a7d8f6f5d0893a14d348f30fbf"
Expand Down

0 comments on commit 22860e1

Please sign in to comment.