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

Hotfix: Handle Bridge drains history when no receipt is available #3229

Merged
merged 3 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion amplify/backend/api/colonycdapp/schema/bridge.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type BridgeDrain {
currency: String!
state: String!
createdAt: String!
receipt: BridgeDrainReceipt!
receipt: BridgeDrainReceipt
}

type BridgeIbanBankAccount {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
const fetch = require('cross-fetch');
const { graphqlRequest } = require('../utils');
/*
* @TODO This needs to be imported properly into the project (maybe?)
* So that we can always ensure it follows the latest schema
* (currently it's just saved statically)
*/
const { getUser } = require('../graphql');
const { getLiquidationAddresses } = require('./utils');

const getDrainsHistoryHandler = async (
event,
Expand All @@ -25,26 +21,17 @@ const getDrainsHistoryHandler = async (

const bridgeCustomerId = colonyUser?.bridgeCustomerId;

const res = await fetch(
`${apiUrl}/v0/customers/${bridgeCustomerId}/liquidation_addresses`,
{
headers: {
'Content-Type': 'application/json',
'Api-Key': apiKey,
},
method: 'GET',
},
const liquidationAddresses = await getLiquidationAddresses(
apiUrl,
apiKey,
bridgeCustomerId,
);

const liquidationAddressResult = await res.json();

if (!liquidationAddressResult.count) {
if (!liquidationAddresses.length) {
return [];
}

const liquidationAddressIds = liquidationAddressResult.data.map(
(item) => item.id,
);
const liquidationAddressIds = liquidationAddresses.map((item) => item.id);

const drains = [];

Expand All @@ -68,9 +55,11 @@ const getDrainsHistoryHandler = async (
currency: drain.currency,
state: drain.state,
createdAt: drain.created_at,
receipt: {
url: drain.receipt.url,
},
receipt: drain.receipt
? {
url: drain.receipt.url,
}
: null,
}));

drains.push(...mappedDrains);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const createExternalAccount = async (

const getLiquidationAddresses = async (apiUrl, apiKey, bridgeCustomerId) => {
const liquidationAddressesRes = await fetch(
`${apiUrl}/v0/customers/${bridgeCustomerId}/liquidation_addresses`,
`${apiUrl}/v0/customers/${bridgeCustomerId}/liquidation_addresses?limit=100`,
{
headers: {
'Content-Type': 'application/json',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,15 @@ export const useFiatTransfersTableColumns = (
if (loading) {
return <div className="h-4 w-12 skeleton" />;
}

if (!row.original.receipt) {
return (
<div className="text-gray-400">
{formatText({ id: 'table.content.receiptGenerating' })}
</div>
);
}

return (
<ExternalLink
href={row.original.receipt.url}
Expand Down
6 changes: 3 additions & 3 deletions src/graphql/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export type BridgeDrain = {
createdAt: Scalars['String'];
currency: Scalars['String'];
id: Scalars['String'];
receipt: BridgeDrainReceipt;
receipt?: Maybe<BridgeDrainReceipt>;
state: Scalars['String'];
};

Expand Down Expand Up @@ -9679,7 +9679,7 @@ export type ColonyMultiSigFragment = { __typename?: 'ColonyMultiSig', id: string

export type BridgeBankAccountFragment = { __typename?: 'BridgeBankAccount', id: string, currency: string, bankName: string, accountOwner: string, iban?: { __typename?: 'BridgeIbanBankAccount', bic: string, country: string, last4: string } | null, usAccount?: { __typename?: 'BridgeUsBankAccount', last4: string, routingNumber: string } | null };

export type BridgeDrainFragment = { __typename?: 'BridgeDrain', id: string, amount: string, currency: string, state: string, createdAt: string, receipt: { __typename?: 'BridgeDrainReceipt', url: string } };
export type BridgeDrainFragment = { __typename?: 'BridgeDrain', id: string, amount: string, currency: string, state: string, createdAt: string, receipt?: { __typename?: 'BridgeDrainReceipt', url: string } | null };

export type ColonyFragment = { __typename?: 'Colony', name: string, version: number, reputation?: string | null, expendituresGlobalClaimDelay?: string | null, private?: boolean | null, lastUpdatedContributorsWithReputation?: string | null, colonyAddress: string, nativeToken: { __typename?: 'Token', decimals: number, name: string, symbol: string, type?: TokenType | null, avatar?: string | null, thumbnail?: string | null, tokenAddress: string }, status?: { __typename?: 'ColonyStatus', recovery?: boolean | null, nativeToken?: { __typename?: 'NativeTokenStatus', mintable?: boolean | null, unlockable?: boolean | null, unlocked?: boolean | null } | null } | null, chainMetadata: { __typename?: 'ChainMetadata', chainId: string, network?: Network | null }, tokens?: { __typename?: 'ModelColonyTokensConnection', items: Array<{ __typename?: 'ColonyTokens', colonyTokensId: string, token: { __typename?: 'Token', decimals: number, name: string, symbol: string, type?: TokenType | null, avatar?: string | null, thumbnail?: string | null, tokenAddress: string } } | null> } | null, motionsWithUnclaimedStakes?: Array<{ __typename?: 'ColonyUnclaimedStake', motionId: string, unclaimedRewards: Array<{ __typename?: 'StakerRewards', address: string, rewards: { __typename?: 'MotionStakeValues', nay: string, yay: string } }> }> | null, domains?: { __typename?: 'ModelDomainConnection', items: Array<{ __typename?: 'Domain', id: string, nativeId: number, isRoot: boolean, nativeFundingPotId: number, nativeSkillId: string, reputation?: string | null, reputationPercentage?: string | null, metadata?: { __typename?: 'DomainMetadata', name: string, color: DomainColor, description?: string | null, id: string, changelog?: Array<{ __typename?: 'DomainMetadataChangelog', transactionHash: string, oldName: string, newName: string, oldColor: DomainColor, newColor: DomainColor, oldDescription?: string | null, newDescription?: string | null }> | null } | null } | null> } | null, balances?: { __typename?: 'ColonyBalances', items?: Array<{ __typename?: 'ColonyBalance', id: string, balance: string, domain?: { __typename?: 'Domain', id: string, nativeId: number, isRoot: boolean, nativeFundingPotId: number, nativeSkillId: string, reputation?: string | null, reputationPercentage?: string | null, metadata?: { __typename?: 'DomainMetadata', name: string, color: DomainColor, description?: string | null, id: string, changelog?: Array<{ __typename?: 'DomainMetadataChangelog', transactionHash: string, oldName: string, newName: string, oldColor: DomainColor, newColor: DomainColor, oldDescription?: string | null, newDescription?: string | null }> | null } | null } | null, token: { __typename?: 'Token', decimals: number, name: string, symbol: string, type?: TokenType | null, avatar?: string | null, thumbnail?: string | null, tokenAddress: string } } | null> | null } | null, fundsClaims?: { __typename?: 'ModelColonyFundsClaimConnection', items: Array<{ __typename?: 'ColonyFundsClaim', id: string, createdAtBlock: number, createdAt: string, amount: string, isClaimed?: boolean | null, token: { __typename?: 'Token', decimals: number, name: string, symbol: string, type?: TokenType | null, avatar?: string | null, thumbnail?: string | null, tokenAddress: string } } | null> } | null, chainFundsClaim?: { __typename?: 'ColonyChainFundsClaim', id: string, createdAtBlock: number, createdAt: string, amount: string, isClaimed?: boolean | null } | null, metadata?: { __typename?: 'ColonyMetadata', displayName: string, avatar?: string | null, description?: string | null, thumbnail?: string | null, externalLinks?: Array<{ __typename?: 'ExternalLink', name: ExternalLinks, link: string }> | null, objective?: { __typename?: 'ColonyObjective', title: string, description: string, progress: number } | null, changelog?: Array<{ __typename?: 'ColonyMetadataChangelog', transactionHash: string, newDisplayName: string, oldDisplayName: string, hasAvatarChanged: boolean, hasDescriptionChanged?: boolean | null, haveExternalLinksChanged?: boolean | null, hasObjectiveChanged?: boolean | null, newSafes?: Array<{ __typename?: 'Safe', name: string, address: string, chainId: string, moduleContractAddress: string }> | null, oldSafes?: Array<{ __typename?: 'Safe', name: string, address: string, chainId: string, moduleContractAddress: string }> | null }> | null, safes?: Array<{ __typename?: 'Safe', name: string, address: string, chainId: string, moduleContractAddress: string }> | null } | null, roles?: { __typename?: 'ModelColonyRoleConnection', items: Array<{ __typename?: 'ColonyRole', id: string, targetAddress: string, role_0?: boolean | null, role_1?: boolean | null, role_2?: boolean | null, role_3?: boolean | null, role_5?: boolean | null, role_6?: boolean | null, isMultiSig?: boolean | null, domain: { __typename?: 'Domain', id: string, nativeId: number } } | null> } | null, colonyMemberInvite?: { __typename?: 'ColonyMemberInvite', id: string, invitesRemaining: number } | null };

Expand Down Expand Up @@ -10019,7 +10019,7 @@ export type SearchActionsQuery = { __typename?: 'Query', searchColonyActions?: {
export type GetUserDrainsQueryVariables = Exact<{ [key: string]: never; }>;


export type GetUserDrainsQuery = { __typename?: 'Query', bridgeGetDrainsHistory?: Array<{ __typename?: 'BridgeDrain', id: string, amount: string, currency: string, state: string, createdAt: string, receipt: { __typename?: 'BridgeDrainReceipt', url: string } }> | null };
export type GetUserDrainsQuery = { __typename?: 'Query', bridgeGetDrainsHistory?: Array<{ __typename?: 'BridgeDrain', id: string, amount: string, currency: string, state: string, createdAt: string, receipt?: { __typename?: 'BridgeDrainReceipt', url: string } | null }> | null };

export type CheckKycStatusQueryVariables = Exact<{ [key: string]: never; }>;

Expand Down
1 change: 1 addition & 0 deletions src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1446,6 +1446,7 @@
"table.row.asset": "Asset",
"table.row.balance": "Balance",
"table.content.viewReceipt": "View receipt",
"table.content.receiptGenerating": "Generating...",
"user.not.verified.warning": "This member has not yet been verified. Ensure you know who this member and the address is correct.",
"actionSidebar.distribution": "Distribution",
"actionSidebar.distributionPlaceholder": "Select split type",
Expand Down
Loading