@@ -25,10 +25,10 @@ import useIsMounted from '~/shared/hooks/useIsMounted'
25
25
import { ProjectType , SalePoint } from '~/shared/types'
26
26
import { ProjectDraft } from '~/stores/projectDraft'
27
27
import { SalePointsPayload } from '~/types/projects'
28
- import { formatChainName } from '~/utils'
29
28
import {
30
- getChainConfig ,
31
- getChainConfigExtension ,
29
+ getChainDisplayName ,
30
+ getChainKey ,
31
+ getMarketplaceChainConfigs ,
32
32
useCurrentChainId ,
33
33
} from '~/utils/chains'
34
34
import { Route as R , routeOptions } from '~/utils/routes'
@@ -59,15 +59,13 @@ export default function ProjectEditorPage() {
59
59
60
60
const chainId = useCurrentChainId ( )
61
61
62
- const availableChains = useMemo < Chain [ ] > (
63
- ( ) => getChainConfigExtension ( chainId ) . marketplaceChains . map ( getChainConfig ) ,
62
+ const availableChainConfigs = useMemo < Chain [ ] > (
63
+ ( ) => getMarketplaceChainConfigs ( chainId ) ,
64
64
[ chainId ] ,
65
65
)
66
66
67
- const salePoints = availableChains
68
- . map < SalePoint | undefined > (
69
- ( { name : chainName } ) => existingSalePoints [ chainName ] ,
70
- )
67
+ const salePoints = availableChainConfigs
68
+ . map < SalePoint | undefined > ( ( { id } ) => existingSalePoints [ getChainKey ( id ) ] )
71
69
. filter ( Boolean ) as SalePoint [ ]
72
70
73
71
function onSalePointChange ( value : SalePoint ) {
@@ -76,16 +74,16 @@ export default function ProjectEditorPage() {
76
74
}
77
75
78
76
update ( ( draft ) => {
79
- const { name : chainName } = getChainConfig ( value . chainId )
77
+ const chainKey = getChainKey ( value . chainId )
80
78
81
- if ( draft . salePoints [ chainName ] ?. readOnly ) {
79
+ if ( draft . salePoints [ chainKey ] ?. readOnly ) {
82
80
/**
83
81
* Read-only sale point must not be updated.
84
82
*/
85
83
return
86
84
}
87
85
88
- draft . salePoints [ chainName ] = value
86
+ draft . salePoints [ chainKey ] = value
89
87
90
88
if ( draft . type !== ProjectType . DataUnion ) {
91
89
return
@@ -151,14 +149,15 @@ export default function ProjectEditorPage() {
151
149
</ Content >
152
150
< Content $desktopMaxWidth = { 728 } >
153
151
{ salePoints . map ( ( salePoint ) => {
154
- const chainName = getChainConfig (
152
+ const chainKey = getChainKey (
155
153
salePoint . chainId ,
156
- ) . name
154
+ )
157
155
158
- const formattedChainName =
159
- formatChainName ( chainName )
156
+ const chainName = getChainDisplayName (
157
+ salePoint . chainId ,
158
+ )
160
159
161
- const beneficiaryErrorKey = `salePoints.${ chainName } .beneficiaryAddress`
160
+ const beneficiaryErrorKey = `salePoints.${ chainKey } .beneficiaryAddress`
162
161
163
162
const beneficiaryInvalid =
164
163
! ! errors [ beneficiaryErrorKey ]
@@ -172,7 +171,7 @@ export default function ProjectEditorPage() {
172
171
>
173
172
< h4 >
174
173
Set the payment token and price on
175
- the { formattedChainName } chain
174
+ the { chainName } chain
176
175
</ h4 >
177
176
< p >
178
177
You can set a price for others to
@@ -191,7 +190,7 @@ export default function ProjectEditorPage() {
191
190
< p >
192
191
This wallet address receives the
193
192
payments for this product on{ ' ' }
194
- { formattedChainName } chain.
193
+ { chainName } chain.
195
194
</ p >
196
195
< BeneficiaryAddressEditor
197
196
invalid = { beneficiaryInvalid }
@@ -325,10 +324,8 @@ export default function ProjectEditorPage() {
325
324
< >
326
325
Set the payment token and
327
326
price on the
328
- { formatChainName (
329
- getChainConfig (
330
- salePoint . chainId ,
331
- ) . name ,
327
+ { getChainDisplayName (
328
+ salePoint . chainId ,
332
329
) } { ' ' }
333
330
chain
334
331
</ >
0 commit comments