From d2452927093101449796eec3419841ae2989bd2b Mon Sep 17 00:00:00 2001 From: woodser Date: Tue, 5 Nov 2024 10:37:29 -0500 Subject: [PATCH] fix incorrect addresses when creating crypto accounts --- src/HavenoClient.test.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/HavenoClient.test.ts b/src/HavenoClient.test.ts index 3a766a94..1d2c9d99 100644 --- a/src/HavenoClient.test.ts +++ b/src/HavenoClient.test.ts @@ -3936,8 +3936,15 @@ function getCryptoAddress(currencyCode: string): string|undefined { async function createPaymentAccount(trader: HavenoClient, assetCodes: string, paymentMethodId?: string | PaymentAccountForm.FormId) { if (!paymentMethodId) paymentMethodId = isCrypto(assetCodes!) ? PaymentAccountForm.FormId.BLOCK_CHAINS : PaymentAccountForm.FormId.PAY_BY_MAIL; const accountForm = await trader.getPaymentAccountForm(paymentMethodId); - for (const field of accountForm.getFieldsList()) field.setValue(getValidFormInput(accountForm, field.getId())); + + // set trade currencies if (HavenoUtils.hasFormField(accountForm, PaymentAccountFormField.FieldId.TRADE_CURRENCIES)) HavenoUtils.setFormValue(accountForm, PaymentAccountFormField.FieldId.TRADE_CURRENCIES, assetCodes); + + // initialize remaining fields + for (const field of accountForm.getFieldsList()) { + if (field.getValue() !== "") continue; // skip if already set + field.setValue(getValidFormInput(accountForm, field.getId())); + } return await trader.createPaymentAccount(accountForm); }