@@ -65,15 +65,15 @@ export default {
6565 computed: {
6666 ... mapState ([' activeNetwork' , ' activeWalletId' ]),
6767 canSubmit () {
68- const { networkName , newRpcUrl , chainId , currencySymbol , explorerUrl } = this .formData
68+ const { networkName , newRpcUrl , chainId , currencySymbol } = this .formData
6969 const { network } = this .settings
70+ const { custom } = network
7071 if (
71- (networkName &&
72- newRpcUrl &&
73- chainId &&
74- currencySymbol &&
75- newRpcUrl !== this .getBaseUrl (network? .rpcUrl )) ||
76- explorerUrl !== network? .explorerUrl
72+ networkName &&
73+ newRpcUrl &&
74+ chainId &&
75+ currencySymbol &&
76+ newRpcUrl !== this .getBaseUrl (network? .rpcUrl , custom)
7777 ) {
7878 return true
7979 }
@@ -92,16 +92,20 @@ export default {
9292 walletId: this .activeWalletId ,
9393 chainId,
9494 chanifyNetwork: {
95+ custom: true ,
9596 ... network,
9697 explorerUrl: this .formData .explorerUrl ,
9798 rpcUrl: this .formData .newRpcUrl
9899 }
99100 }
100101
101102 await this .saveCustomChainSettings (payload)
102- this .setSettings ()
103103 },
104- getBaseUrl (url ) {
104+ getBaseUrl (url , custom = true ) {
105+ if (custom === true ) {
106+ return url
107+ }
108+
105109 const pathArray = url .split (' /' ),
106110 protocol = pathArray[0 ],
107111 host = pathArray[2 ]
@@ -114,20 +118,28 @@ export default {
114118 walletId: this .activeWalletId ,
115119 chainId: chain
116120 })
117- this .setSettings ()
118121 },
119122 setSettings () {
120123 const { chain , network , asset , chainId } = this .settings
121- const { rpcUrl , explorerUrl } = network
124+ const { rpcUrl , explorerUrl , custom } = network
122125 this .formData .networkName = chain
123126 this .formData .chainId = chainId
124127 this .formData .currencySymbol = asset
125- this .formData .newRpcUrl = this .getBaseUrl (rpcUrl)
128+ this .formData .newRpcUrl = this .getBaseUrl (rpcUrl, custom )
126129 this .formData .explorerUrl = explorerUrl
127130 }
128131 },
129132 created () {
133+ console .log (' this.settings' , this .settings )
130134 this .setSettings ()
135+ },
136+ watch: {
137+ settings: {
138+ handler () {
139+ this .setSettings ()
140+ },
141+ deep: true
142+ }
131143 }
132144}
133145< / script>
0 commit comments