Skip to content

Commit 67d221f

Browse files
authored
Merge pull request #1209 from peanutprotocol/hotfix/poland-claim
hot-fix: poland guest link claim issue
2 parents aa4cf42 + 9096316 commit 67d221f

4 files changed

Lines changed: 20 additions & 7 deletions

File tree

src/app/actions/external-accounts.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const API_URL = process.env.PEANUT_API_URL!
1010
export async function createBridgeExternalAccountForGuest(
1111
customerId: string,
1212
accountDetails: AddBankAccountPayload
13-
): Promise<IBridgeAccount | { error: string }> {
13+
): Promise<IBridgeAccount | { error: string; source?: string }> {
1414
try {
1515
const response = await fetchWithSentry(`${API_URL}/bridge/customers/${customerId}/external-accounts`, {
1616
method: 'POST',
@@ -23,6 +23,12 @@ export async function createBridgeExternalAccountForGuest(
2323

2424
const data = await response.json()
2525

26+
if (data?.code === 'invalid_parameters') {
27+
const source =
28+
typeof data.source === 'string' ? data.source : data?.source?.key
29+
return { error: data?.message ?? 'Invalid parameters', source }
30+
}
31+
2632
if (!response.ok) {
2733
return { error: data.error || 'Failed to create external account.' }
2834
}

src/components/AddWithdraw/DynamicBankAccountForm.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,11 @@ export const DynamicBankAccountForm = forwardRef<{ handleSubmit: () => void }, D
398398
>
399399
Review
400400
</Button>
401-
{submissionError && <ErrorAlert description={submissionError} />}
402-
{error && <ErrorAlert description={error} />}
401+
{submissionError ? (
402+
<ErrorAlert description={submissionError} />
403+
) : (
404+
error && <ErrorAlert description={error} />
405+
)}
403406
</form>
404407
</div>
405408
</div>

src/components/Claim/Link/views/BankFlowManager.view.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ export const BankFlowManager = (props: IClaimScreenProps) => {
255255
try {
256256
const addBankAccountResponse = await addBankAccount(payload)
257257
if (addBankAccountResponse.error) {
258-
setError(addBankAccountResponse.error)
259258
return { error: addBankAccountResponse.error }
260259
}
261260
if (addBankAccountResponse.data?.id) {
@@ -316,9 +315,15 @@ export const BankFlowManager = (props: IClaimScreenProps) => {
316315
}
317316
if (!senderInfo.bridgeCustomerId) throw new Error('Sender bridge customer ID not found')
318317

318+
const threeLetterCountryCode = getCountryCodeForWithdraw(selectedCountry.id)
319319
const payloadWithCountry = {
320320
...payload,
321-
country: selectedCountry.id,
321+
countryCode: threeLetterCountryCode,
322+
address: {
323+
...payload.address,
324+
country: threeLetterCountryCode,
325+
},
326+
country: threeLetterCountryCode,
322327
}
323328

324329
const externalAccountResponse = await createBridgeExternalAccountForGuest(
@@ -358,7 +363,6 @@ export const BankFlowManager = (props: IClaimScreenProps) => {
358363
return {}
359364
} catch (e: any) {
360365
const errorString = ErrorHandler(e)
361-
setError(errorString)
362366
Sentry.captureException(e)
363367
return { error: errorString }
364368
} finally {

src/utils/sdkErrorHandler.utils.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export const ErrorHandler = (error: any) => {
112112
} else if (error.toString().includes('The operation either timed out or was not allowed')) {
113113
return 'Please confirm the transaction.'
114114
} else {
115-
return 'Something failed. Please try again.'
115+
return 'There was an issue with your request. Please contact support.'
116116
}
117117
}
118118
}

0 commit comments

Comments
 (0)