|
1 | | -import type { SatelliteDid } from '$declarations'; |
2 | 1 | import { SYNC_CUSTOM_DOMAIN_TIMER_INTERVAL } from '$lib/constants/app.constants'; |
3 | | -import { getCustomDomainRegistrationV0 } from '$lib/rest/bn.v0.rest'; |
4 | 2 | import { getCustomDomainRegistration } from '$lib/rest/bn.v1.rest'; |
5 | 3 | import type { CustomDomain, CustomDomainName, CustomDomainState } from '$lib/types/custom-domain'; |
6 | 4 | import type { PostMessageDataRequest, PostMessageRequest } from '$lib/types/post-message'; |
7 | | -import { fromNullable, isNullish, nonNullish } from '@dfinity/utils'; |
| 5 | +import { isNullish } from '@dfinity/utils'; |
8 | 6 |
|
9 | 7 | export const onHostingMessage = async ({ data: dataMsg }: MessageEvent<PostMessageRequest>) => { |
10 | 8 | const { msg, data } = dataMsg; |
@@ -55,12 +53,7 @@ const syncCustomDomainRegistration = async ({ customDomain }: { customDomain: Cu |
55 | 53 |
|
56 | 54 | try { |
57 | 55 | const sync = async (): Promise<CustomDomainState> => { |
58 | | - const [domainName, custom] = customDomain; |
59 | | - |
60 | | - if (nonNullish(fromNullable(custom.bn_id))) { |
61 | | - return await syncCustomDomainRegistrationV0({ customDomain: custom }); |
62 | | - } |
63 | | - |
| 56 | + const [domainName] = customDomain; |
64 | 57 | return await syncCustomDomainRegistrationV1({ domain: domainName }); |
65 | 58 | }; |
66 | 59 |
|
@@ -100,30 +93,6 @@ const syncCustomDomainRegistrationV1 = async ({ |
100 | 93 | return 'failed'; |
101 | 94 | }; |
102 | 95 |
|
103 | | -const syncCustomDomainRegistrationV0 = async ({ |
104 | | - customDomain |
105 | | -}: { |
106 | | - customDomain: SatelliteDid.CustomDomain; |
107 | | -}): Promise<CustomDomainState> => { |
108 | | - const registration = await getCustomDomainRegistrationV0(customDomain); |
109 | | - const registrationState = nonNullish(registration) |
110 | | - ? typeof registration.state !== 'string' && 'Failed' in registration.state |
111 | | - ? 'Failed' |
112 | | - : registration.state |
113 | | - : null; |
114 | | - |
115 | | - switch (registrationState) { |
116 | | - case 'PendingOrder': |
117 | | - case 'PendingChallengeResponse': |
118 | | - case 'PendingAcmeApproval': |
119 | | - return 'registering'; |
120 | | - case 'Available': |
121 | | - return 'registered'; |
122 | | - default: |
123 | | - return 'failed'; |
124 | | - } |
125 | | -}; |
126 | | - |
127 | 96 | // Update ui with registration state |
128 | 97 | const emit = (registrationState: CustomDomainState | null) => |
129 | 98 | postMessage({ |
|
0 commit comments