@@ -43,59 +43,87 @@ <h1 class="logo--landing-page">
43
43
style ="cursor: pointer "
44
44
> here</ a > .
45
45
</ p >
46
- < div data-behavior ="claimModal " class ="modal " style ="display: none ">
46
+ < div data-behavior ="claimVerification " class ="modal " style ="display: none ">
47
47
< div class ="modal__container ">
48
48
< nav class ="modal__nav ">
49
49
< button
50
50
type ="button "
51
51
class ="modal__nav__button--close "
52
52
data-behavior ="closeModal "
53
53
>
54
- < svg
55
- width ="24 "
56
- height ="24 "
57
- viewBox ="0 0 24 24 "
58
- fill ="none "
59
- xmlns ="http://www.w3.org/2000/svg "
60
- >
61
- < path
62
- d ="M18 6L6 18 "
63
- stroke ="#A2A2A8 "
64
- stroke-width ="2 "
65
- stroke-linecap ="round "
66
- stroke-linejoin ="round "
67
- />
68
- < path
69
- d ="M6 6L18 18 "
70
- stroke ="#A2A2A8 "
71
- stroke-width ="2 "
72
- stroke-linecap ="round "
73
- stroke-linejoin ="round "
74
- />
75
- </ svg >
76
54
< span class ="visually-hidden "> close</ span >
77
55
</ button >
78
56
</ nav >
79
- < h1 class ="modal__heading "> Claim your NEAR account</ h1 >
80
- < p class ="modal__message ">
81
- Create a free NEAR account by showing that you have at least 0.05 ETH.
82
- Learn more about the Paras Faucet
83
- < a
84
- target ="_blank "
85
- rel ="noopener noreferrer "
86
- href ="https://faucet.paras.id/ "
87
- > here</ a
88
- > .
89
- </ p >
90
- < p data-behavior ="claimMessage "> </ p >
91
- < div class ="">
92
- < button data-behavior ="authEthereum " class ="full-width ">
93
- Connect Ethereum Wallet
57
+ < div data-behavior ="enoughETH ">
58
+ < div class ="modal-image__container ">
59
+ < img src ="img/gift.svg " alt ="" class ="modal__image "/>
60
+ </ div >
61
+ < h1 class ="modal__heading "> Claim Your NEAR Account</ h1 >
62
+ < p class ="modal__message ">
63
+ Ethereum holders may create a NEAR account using the
64
+ < a target ="_blank " rel ="noopener noreferrer " href ="https://faucet.paras.id/ "> Paras Faucet</ a > .
65
+ Connect your Ethereum wallet to get started.
66
+ </ p >
67
+ </ div >
68
+ < div data-behavior ="notEnoughETH " style ="display: none ">
69
+ < div class ="modal-image__container ">
70
+ < img src ="img/empty-wallet.svg " alt ="" class ="modal__image "/>
71
+ </ div >
72
+ < h1 class ="modal__heading "> Insufficient funds to claim account</ h1 >
73
+ < p class ="modal__message ">
74
+ Your Ethereum wallet must have a balance of at least 0.05 ETH as proof of liquidity in order to claim your account.
75
+ </ p >
76
+ </ div >
77
+ < div class ="authenticated-account__details space_around ">
78
+ < img src ="img/ethereum.svg " alt ="" class ="network-indicator network--ethereum "/>
79
+ < div data-behavior ="ethAccountPlaceholder "> Ethereum</ div >
80
+ < button
81
+ type ="button "
82
+ class ="button-size--small "
83
+ id ="authEthereum "
84
+ data-behavior ="authEthereum "
85
+ >
86
+ Connect
94
87
</ button >
95
- < button data-behavior ="claimNearAccount " class ="full-width ">
96
- Claim NEAR Account
88
+ < button
89
+ class ="button-size--small button-variant--secondary "
90
+ data-behavior ="disconnectEthereum "
91
+ style ="display: none "
92
+ type ="button "
93
+ >
94
+ Disconnect
95
+ </ button >
96
+ </ div >
97
+ < button data-behavior ="verifyEthAddress " class ="full-width ">
98
+ Verify & Continue
99
+ </ button >
100
+ </ div >
101
+ </ div >
102
+ < div data-behavior ="claimSignature " class ="modal " style ="display: none ">
103
+ < include src ="sign-message-modal.html "> </ include >
104
+ </ div >
105
+ < div data-behavior ="claimReady " class ="modal " style ="display: none ">
106
+ < include src ="claim-ready-modal.html "> </ include >
107
+ </ div >
108
+ < div data-behavior ="claimError " class ="modal " style ="display: none ">
109
+ < div class ="modal__container ">
110
+ < nav class ="modal__nav ">
111
+ < button
112
+ type ="button "
113
+ class ="modal__nav__button--close "
114
+ data-behavior ="closeModal "
115
+ >
116
+ < span class ="visually-hidden "> close</ span >
97
117
</ button >
118
+ </ nav >
119
+ < div class ="modal-image__container ">
120
+ < img src ="img/warning.svg " alt ="" class ="modal__image " />
98
121
</ div >
122
+ < h1 class ="modal__heading "> Oops! Something went wrong</ h1 >
123
+ < p class ="modal__message " data-behavior ="claimErrorMessage "> </ p >
124
+ < button data-behavior ="openClaimModal " class ="full-width ">
125
+ Return
126
+ </ button >
99
127
</ div >
100
128
</ div >
101
129
</ div >
@@ -154,36 +182,72 @@ <h1 class="modal__heading">Claim your NEAR account</h1>
154
182
font-weight : var (--fw-regular );
155
183
margin-top : 0.5em ;
156
184
}
185
+ .space_around {
186
+ margin : var (--spacing-xxl ) 0 ;
187
+ }
157
188
</ style >
158
189
< script >
159
- window . addEventListener ( "load" , function addClaimHandler ( ) {
190
+ window . addEventListener ( "load" , function addLoginParasFaucetHandler ( ) {
191
+ const verifyButton = window . dom . find ( "verifyEthAddress" ) ;
192
+ const claimButton = window . dom . find ( "claimNEARAccount" ) ;
160
193
window . dom . onClick ( 'openClaimModal' , function renderClaimModal ( ) {
161
194
if ( process . env . ethNetworkId !== 'main' ) {
162
195
window . location . href = 'https://wallet.testnet.near.org/'
163
196
return
164
197
}
165
- window . dom . fill ( 'claimMessage' ) . with ( '' )
198
+ window . dom . hide ( "claimError" )
199
+ window . dom . show ( "enoughETH" )
200
+ window . dom . hide ( "notEnoughETH" )
201
+ verifyButton . disabled = false
166
202
if ( ! window . ethInitialized ) {
167
- window . dom . hide ( "claimNearAccount" )
203
+ verifyButton . disabled = true
168
204
}
169
- window . dom . show ( "claimModal " )
205
+ window . dom . show ( "claimVerification " )
170
206
} )
171
207
172
- const claimButton = window . dom . find ( "claimNearAccount" ) ;
173
- claimButton . onclick = async ( ) => {
174
- window . dom . fill ( 'claimMessage' ) . with ( 'To claim, please sign the message when prompted on your Ethereum wallet...' ) ;
208
+ verifyButton . onclick = async ( ) => {
175
209
try {
176
- claimButton . disabled = true
177
- await window . faucetUtils . claim ( )
210
+ await window . faucetUtils . checkETHBalance ( )
178
211
} catch ( error ) {
179
- window . dom . fill ( 'claimMessage' ) . with ( error . message )
180
- claimButton . disabled = false
212
+ console . error ( error . message )
213
+ window . dom . hide ( "enoughETH" )
214
+ window . dom . show ( "notEnoughETH" )
215
+ verifyButton . disabled = true
216
+ return
217
+ }
218
+ window . dom . hide ( "claimVerification" )
219
+ window . dom . show ( "claimSignature" )
220
+ try {
221
+ await window . faucetUtils . parasFaucetLogin ( )
222
+ } catch ( error ) {
223
+ console . log ( error . message )
224
+ window . dom . fill ( 'claimErrorMessage' ) . with ( error . message ) ;
225
+ window . dom . hide ( "claimSignature" )
226
+ window . dom . show ( "claimError" )
227
+ return
228
+ }
229
+ window . dom . hide ( "claimSignature" )
230
+ window . dom . show ( "claimReady" )
231
+ }
232
+
233
+ claimButton . onclick = async ( ) => {
234
+ window . dom . fill ( 'claimErrorMessage' ) . with ( "" ) ;
235
+ let claimURL
236
+ try {
237
+ claimURL = await window . faucetUtils . getClaimURL ( )
238
+ } catch ( error ) {
239
+ console . error ( error . message )
240
+ window . dom . fill ( 'claimErrorMessage' ) . with ( error . message ) ;
241
+ window . dom . hide ( "claimReady" )
242
+ window . dom . show ( "claimError" )
243
+ return
181
244
}
245
+ window . location . href = claimURL
182
246
}
183
247
} )
184
248
185
- async function renderLanding ( ) {
186
- if ( window . ethInitialized ) { window . dom . show ( "claimNearAccount" ) }
249
+ async function renderLanding ( ) {
250
+ if ( window . ethInitialized ) { window . dom . find ( "verifyEthAddress" ) . disabled = false }
187
251
if ( window . ethInitialized && window . nearInitialized ) {
188
252
window . dom . find ( "landingSubmit" ) . disabled = false ;
189
253
} else {
0 commit comments