Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #2617

Merged
merged 11 commits into from
Dec 27, 2024
40 changes: 20 additions & 20 deletions landing/src/components/ui/SelectResources.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const SelectResources = ({
setSelectedResourceAmounts: any;
entity_id: ID;
}) => {
const { getBalance } = useResourceBalance({entityId: entity_id});
const { getBalance } = useResourceBalance({ entityId: entity_id });

const unselectedResources = useMemo(
() => resources.filter((res) => !selectedResourceIds.includes(res.id)),
Expand All @@ -32,20 +32,20 @@ export const SelectResources = ({
setSelectedResourceIds([...selectedResourceIds, unselectedResources[0].id]);
setSelectedResourceAmounts({
...selectedResourceAmounts,
[unselectedResources[0].id]: 1,
[unselectedResources[0].id]: divideByPrecision(getBalance(unselectedResources[0].id) || 0),
});
};

return (
<div className=" items-center col-span-4 space-y-2 p-3">
{selectedResourceIds.map((id: any, index: any) => {
const resource = getBalance(id);
const options = [resources.find((res) => res.id === id), ...unselectedResources].map((res: any) => ({
id: res.id,
label: (
<ResourceCost resourceId={res.id} amount={divideByPrecision(getBalance(res.id) || 0)} />
),
}));
const options = [resources.find((res) => res.id === id), ...unselectedResources]
.filter((res) => getBalance(res.id) > 0)
.map((res: any) => ({
id: res.id,
label: <ResourceCost resourceId={res.id} amount={divideByPrecision(getBalance(res.id) || 0)} />,
}));

return (
<div key={id} className="flex items-center gap-4">
Expand Down Expand Up @@ -75,7 +75,7 @@ export const SelectResources = ({
const { [selectedResourceIds[index]]: _, ...remainingAmounts } = selectedResourceAmounts;
setSelectedResourceAmounts({
...remainingAmounts,
[value]: 1,
[value]: divideByPrecision(getBalance(value) || 0),
});
// playResourceSound(value);
}}
Expand Down Expand Up @@ -117,7 +117,7 @@ export const SelectSingleResource = ({
setSelectedResourceAmounts: any;
entity_id: ID;
}) => {
const { getBalance } = useResourceBalance({entityId: entity_id});
const { getBalance } = useResourceBalance({ entityId: entity_id });

const unselectedResources = useMemo(
() => resources.filter((res) => !selectedResourceIds.includes(res.id)),
Expand All @@ -134,20 +134,20 @@ export const SelectSingleResource = ({
setSelectedResourceIds([...selectedResourceIds, unselectedResources[0].id]);
setSelectedResourceAmounts({
...selectedResourceAmounts,
[unselectedResources[0].id]: 1,
[unselectedResources[0].id]: divideByPrecision(getBalance(unselectedResources[0].id) || 0),
});
};

return (
<div className=" items-center col-span-4 space-y-2 p-3">
{selectedResourceIds.map((id: any, index: any) => {
const resourceBalance = getBalance(id);
const options = [resources.find((res) => res.id === id), ...unselectedResources].map((res: any) => ({
id: res.id,
label: (
<ResourceCost resourceId={res.id} amount={divideByPrecision(getBalance(res.id) || 0)} />
),
}));
const options = [resources.find((res) => res.id === id), ...unselectedResources]
.filter((res) => getBalance(res.id) > 0)
.map((res: any) => ({
id: res.id,
label: <ResourceCost resourceId={res.id} amount={divideByPrecision(getBalance(res.id) || 0)} />,
}));

return (
<>
Expand All @@ -165,7 +165,7 @@ export const SelectSingleResource = ({
const { [selectedResourceIds[index]]: _, ...remainingAmounts } = selectedResourceAmounts;
setSelectedResourceAmounts({
...remainingAmounts,
[value]: 1,
[value]: divideByPrecision(getBalance(value) || 0),
});
// playResourceSound(value);
}}
Expand Down Expand Up @@ -218,7 +218,7 @@ export const ShowSingleResource = ({
setSelectedResourceAmounts: any;
entity_id: ID;
}) => {
const { getBalance } = useResourceBalance({entityId: entity_id});
const { getBalance } = useResourceBalance({ entityId: entity_id });

const unselectedResources = useMemo(
() => resources.filter((res) => !selectedResourceIds.includes(res.id)),
Expand All @@ -235,7 +235,7 @@ export const ShowSingleResource = ({
setSelectedResourceIds([...selectedResourceIds, unselectedResources[0].id]);
setSelectedResourceAmounts({
...selectedResourceAmounts,
[unselectedResources[0].id]: 1,
[unselectedResources[0].id]: divideByPrecision(getBalance(unselectedResources[0].id) || 0),
});
};

Expand Down
12 changes: 6 additions & 6 deletions landing/src/hooks/gql/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import * as types from './graphql';
*/
const documents = {
"\n query getCapacitySpeedConfig($category: Enum!, $entityType: u32!) {\n s0EternumCapacityConfigModels(where: {category: $category }) {\n edges{\n node {\n weight_gram\n }\n }\n }\n s0EternumSpeedConfigModels(where: {entity_type: $entityType }) {\n edges{\n node {\n sec_per_km\n }\n }\n }\n }\n": types.GetCapacitySpeedConfigDocument,
"\n query getEternumOwnerRealmIds($accountAddress: ContractAddress!) {\n s0EternumOwnerModels(where: { address: $accountAddress }, limit: 1000) {\n edges {\n node {\n address\n entity_id\n entity {\n models {\n __typename\n ... on s0_eternum_Realm {\n realm_id\n }\n }\n }\n }\n }\n }\n }\n": types.GetEternumOwnerRealmIdsDocument,
"\n query getEternumOwnerRealmIds($accountAddress: ContractAddress!) {\n s0EternumOwnerModels(where: { address: $accountAddress }, limit: 8000) {\n edges {\n node {\n address\n entity_id\n entity {\n models {\n __typename\n ... on s0_eternum_Realm {\n realm_id\n }\n }\n }\n }\n }\n }\n }\n": types.GetEternumOwnerRealmIdsDocument,
"\n query getEternumEntityOwner($entityOwnerIds: [u32!]!) {\n s0EternumEntityOwnerModels(where: { entity_owner_idIN: $entityOwnerIds}, limit: 200) {\n edges {\n node {\n entity_id\n entity_owner_id\n entity {\n models {\n __typename\n ... on s0_eternum_OwnedResourcesTracker {\n resource_types\n }\n ... on s0_eternum_Position {\n x\n y\n }\n ... on s0_eternum_ArrivalTime {\n arrives_at\n }\n ... on s0_eternum_Weight {\n value\n }\n }\n }\n }\n }\n }\n }\n": types.GetEternumEntityOwnerDocument,
"\n query getAccountTokens($accountAddress: String!) {\n tokenBalances(accountAddress: $accountAddress, limit: 8000) {\n edges {\n node {\n tokenMetadata {\n __typename\n ... on ERC721__Token {\n tokenId\n metadataDescription\n imagePath\n contractAddress\n metadata\n }\n }\n }\n }\n }\n }\n": types.GetAccountTokensDocument,
"\n query getERC721Mints {\n tokenTransfers(accountAddress: \"0x0\", limit: 8000) {\n edges {\n node {\n tokenMetadata {\n __typename\n ... on ERC721__Token {\n tokenId\n metadataDescription\n imagePath\n contractAddress\n metadata\n }\n }\n }\n }\n }\n }\n": types.GetErc721MintsDocument,
Expand All @@ -28,8 +28,8 @@ const documents = {
"\n query getLeaderboard {\n s0EternumLeaderboardModels {\n edges {\n node {\n total_points\n registration_end_timestamp\n total_price_pool {\n Some\n option\n }\n distribution_started\n }\n }\n }\n }\n": types.GetLeaderboardDocument,
"\n query getHyperstructureContributions($accountAddress: ContractAddress!) {\n s0EternumContributionModels(where: { player_address: $accountAddress }, limit: 1000) {\n edges {\n node {\n hyperstructure_entity_id\n amount\n }\n }\n }\n }\n": types.GetHyperstructureContributionsDocument,
"\n query getEpochs {\n s0EternumEpochModels(limit: 1000) {\n edges {\n node {\n owners {\n _0\n _1\n }\n start_timestamp\n hyperstructure_entity_id\n index\n }\n }\n }\n }\n": types.GetEpochsDocument,
"\n query getEntityPosition($entityIds: [u32!]!) {\n s0EternumPositionModels(where: { entity_idIN: $entityIds }) {\n edges {\n node {\n x\n y\n entity_id\n entity {\n __typename\n }\n }\n }\n }\n }\n": types.GetEntityPositionDocument,
"\n query getEntitiesResources($entityIds: [u32!]!) {\n s0EternumResourceModels(\n where: { \n entity_idIN: $entityIds\n }\n limit: 100\n ) {\n edges {\n node {\n entity_id\n resource_type\n balance\n entity {\n __typename\n }\n }\n }\n }\n }\n": types.GetEntitiesResourcesDocument,
"\n query getEntityPosition($entityIds: [u32!]!) {\n s0EternumPositionModels(where: { entity_idIN: $entityIds }, limit: 8000) {\n edges {\n node {\n x\n y\n entity_id\n entity {\n __typename\n }\n }\n }\n }\n }\n": types.GetEntityPositionDocument,
"\n query getEntitiesResources($entityIds: [u32!]!) {\n s0EternumResourceModels(where: { entity_idIN: $entityIds }, limit: 8000) {\n edges {\n node {\n entity_id\n resource_type\n balance\n entity {\n __typename\n }\n }\n }\n }\n }\n": types.GetEntitiesResourcesDocument,
};

/**
Expand All @@ -39,7 +39,7 @@ export function graphql(source: "\n query getCapacitySpeedConfig($category: Enu
/**
* 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 getEternumOwnerRealmIds($accountAddress: ContractAddress!) {\n s0EternumOwnerModels(where: { address: $accountAddress }, limit: 1000) {\n edges {\n node {\n address\n entity_id\n entity {\n models {\n __typename\n ... on s0_eternum_Realm {\n realm_id\n }\n }\n }\n }\n }\n }\n }\n"): typeof import('./graphql').GetEternumOwnerRealmIdsDocument;
export function graphql(source: "\n query getEternumOwnerRealmIds($accountAddress: ContractAddress!) {\n s0EternumOwnerModels(where: { address: $accountAddress }, limit: 8000) {\n edges {\n node {\n address\n entity_id\n entity {\n models {\n __typename\n ... on s0_eternum_Realm {\n realm_id\n }\n }\n }\n }\n }\n }\n }\n"): typeof import('./graphql').GetEternumOwnerRealmIdsDocument;
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
Expand Down Expand Up @@ -87,11 +87,11 @@ export function graphql(source: "\n query getEpochs {\n s0EternumEpochModels
/**
* 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 getEntityPosition($entityIds: [u32!]!) {\n s0EternumPositionModels(where: { entity_idIN: $entityIds }) {\n edges {\n node {\n x\n y\n entity_id\n entity {\n __typename\n }\n }\n }\n }\n }\n"): typeof import('./graphql').GetEntityPositionDocument;
export function graphql(source: "\n query getEntityPosition($entityIds: [u32!]!) {\n s0EternumPositionModels(where: { entity_idIN: $entityIds }, limit: 8000) {\n edges {\n node {\n x\n y\n entity_id\n entity {\n __typename\n }\n }\n }\n }\n }\n"): typeof import('./graphql').GetEntityPositionDocument;
/**
* 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 getEntitiesResources($entityIds: [u32!]!) {\n s0EternumResourceModels(\n where: { \n entity_idIN: $entityIds\n }\n limit: 100\n ) {\n edges {\n node {\n entity_id\n resource_type\n balance\n entity {\n __typename\n }\n }\n }\n }\n }\n"): typeof import('./graphql').GetEntitiesResourcesDocument;
export function graphql(source: "\n query getEntitiesResources($entityIds: [u32!]!) {\n s0EternumResourceModels(where: { entity_idIN: $entityIds }, limit: 8000) {\n edges {\n node {\n entity_id\n resource_type\n balance\n entity {\n __typename\n }\n }\n }\n }\n }\n"): typeof import('./graphql').GetEntitiesResourcesDocument;


export function graphql(source: string) {
Expand Down
6 changes: 3 additions & 3 deletions landing/src/hooks/gql/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7395,7 +7395,7 @@ export const GetCapacitySpeedConfigDocument = new TypedDocumentString(`
`) as unknown as TypedDocumentString<GetCapacitySpeedConfigQuery, GetCapacitySpeedConfigQueryVariables>;
export const GetEternumOwnerRealmIdsDocument = new TypedDocumentString(`
query getEternumOwnerRealmIds($accountAddress: ContractAddress!) {
s0EternumOwnerModels(where: {address: $accountAddress}, limit: 1000) {
s0EternumOwnerModels(where: {address: $accountAddress}, limit: 8000) {
edges {
node {
address
Expand Down Expand Up @@ -7590,7 +7590,7 @@ export const GetEpochsDocument = new TypedDocumentString(`
`) as unknown as TypedDocumentString<GetEpochsQuery, GetEpochsQueryVariables>;
export const GetEntityPositionDocument = new TypedDocumentString(`
query getEntityPosition($entityIds: [u32!]!) {
s0EternumPositionModels(where: {entity_idIN: $entityIds}) {
s0EternumPositionModels(where: {entity_idIN: $entityIds}, limit: 8000) {
edges {
node {
x
Expand All @@ -7606,7 +7606,7 @@ export const GetEntityPositionDocument = new TypedDocumentString(`
`) as unknown as TypedDocumentString<GetEntityPositionQuery, GetEntityPositionQueryVariables>;
export const GetEntitiesResourcesDocument = new TypedDocumentString(`
query getEntitiesResources($entityIds: [u32!]!) {
s0EternumResourceModels(where: {entity_idIN: $entityIds}, limit: 100) {
s0EternumResourceModels(where: {entity_idIN: $entityIds}, limit: 8000) {
edges {
node {
entity_id
Expand Down
2 changes: 1 addition & 1 deletion landing/src/hooks/query/entities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { graphql } from "../gql";

export const GET_ETERNUM_OWNER_REALM_IDS = graphql(`
query getEternumOwnerRealmIds($accountAddress: ContractAddress!) {
s0EternumOwnerModels(where: { address: $accountAddress }, limit: 1000) {
s0EternumOwnerModels(where: { address: $accountAddress }, limit: 8000) {
edges {
node {
address
Expand Down
2 changes: 1 addition & 1 deletion landing/src/hooks/query/position.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { graphql } from "../gql";

export const GET_ENTITY_DISTANCE = graphql(`
query getEntityPosition($entityIds: [u32!]!) {
s0EternumPositionModels(where: { entity_idIN: $entityIds }) {
s0EternumPositionModels(where: { entity_idIN: $entityIds }, limit: 8000) {
edges {
node {
x
Expand Down
7 changes: 1 addition & 6 deletions landing/src/hooks/query/resources.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@ import { graphql } from "../gql";

export const GET_ENTITIES_RESOURCES = graphql(`
query getEntitiesResources($entityIds: [u32!]!) {
s0EternumResourceModels(
where: {
entity_idIN: $entityIds
}
limit: 100
) {
s0EternumResourceModels(where: { entity_idIN: $entityIds }, limit: 8000) {
edges {
node {
entity_id
Expand Down
Loading