
* feat: ✨ add ping method to avatax-client * refactor: ♻️ use avatax-auth-validation.service instead of address service * refactor: ♻️ extract avatax-configuration-address-fragment * refactor: ♻️ extract avatax-configuration-credentials-fragment * refactor: ♻️ extract form-helper-text * refactor: ♻️ extract form-section * refactor: ♻️ extract avatax-configuration-taxes-fragment * feat: ✨ move verify to credentials fragment && add disabled form section * refactor: 🚚 obfuscator * feat: ✨ add separate credentials and address validation services * build: 👷 add changeset * feat: ✨ add address resolution message * fix: 🐛 changeset * refactor: ♻️ extract avataxAddressResolutionProcessor and add tests * refactor: * refactor: ♻️ remove brs from avatax-instructions * refactor: ♻️ replace b with Text bodyStrong * refactor: ♻️ state tuple to object * refactor: ♻️ destructure some more constructors * refactor: ♻️ memoize isLoadings & handlers
27 lines
894 B
TypeScript
27 lines
894 B
TypeScript
import { createLogger, Logger } from "../../../lib/logger";
|
|
import { avataxAddressFactory } from "../address-factory";
|
|
import { AvataxClient } from "../avatax-client";
|
|
import { AvataxConfig } from "../avatax-connection-schema";
|
|
import { AvataxValidationErrorResolver } from "./avatax-validation-error-resolver";
|
|
|
|
export class AvataxAddressValidationService {
|
|
private logger: Logger;
|
|
|
|
constructor(private avataxClient: AvataxClient) {
|
|
this.logger = createLogger({
|
|
name: "AvataxAddressValidationService",
|
|
});
|
|
}
|
|
|
|
async validate(address: AvataxConfig["address"]) {
|
|
const formattedAddress = avataxAddressFactory.fromChannelAddress(address);
|
|
|
|
try {
|
|
return this.avataxClient.validateAddress({ address: formattedAddress });
|
|
} catch (error) {
|
|
const errorResolver = new AvataxValidationErrorResolver();
|
|
|
|
throw errorResolver.resolve(error);
|
|
}
|
|
}
|
|
}
|