15
15
*/
16
16
17
17
import { useConnectModal } from '@rainbow-me/rainbowkit' ;
18
- import { writeContract } from '@wagmi/core' ;
19
18
// import { formatTime } from '@/utils/date'
20
19
import clsx from 'clsx' ;
21
20
import Image from 'next/image' ;
@@ -30,7 +29,7 @@ import Loader from '@/components/Loader';
30
29
import { Modal } from '@/components/Modal' ;
31
30
import { Confirm } from '@/components/Modal/Confirm' ;
32
31
import { NoData } from '@/components/NoData' ;
33
- import { BountyABI } from '@/constants/abis/bounty' ;
32
+ import { writeBountyAbiActions } from '@/constants/abis/bounty' ;
34
33
import { BOUNTY_SUPPORTED_CHAIN } from '@/constants/chain' ;
35
34
import { contracts , payTokens } from '@/constants/contract' ;
36
35
import { useAllowance , useApprove } from '@/hooks/useERC20' ;
@@ -39,10 +38,7 @@ import { parseTokenUnits } from '@/utils/web3';
39
38
import { EXPERIENCE_OPTIONS } from '#/lib/user' ;
40
39
import { denyBuilder , approveBuilder } from '#/services/creator' ;
41
40
import { useCreatorBountyBuilders } from '#/services/creator/hooks' ;
42
- import {
43
- useMediaUrl ,
44
- useConfig ,
45
- } from '#/state/application/hooks' ;
41
+ import { useMediaUrl , useConfig } from '#/state/application/hooks' ;
46
42
47
43
import { CommentsModal } from './CommentsModal' ;
48
44
@@ -66,18 +62,10 @@ export function AppliedModal({ open, closeModal, bounty, applyCallback }) {
66
62
bid : undefined ,
67
63
bountyId : undefined ,
68
64
} ) ;
69
- const [ currUser , setCurrUser ] = useState ( ) ;
65
+ const [ currUser , setCurrUser ] = useState < any > ( ) ;
70
66
71
- const { allowance } = useAllowance (
72
- payToken . address ,
73
- _contracts . bounty ,
74
- address
75
- ) ;
76
- const { approveAsync } = useApprove (
77
- payToken . address ,
78
- _contracts . bounty ,
79
- address
80
- ) ;
67
+ const { allowance } = useAllowance ( payToken . address , _contracts . bounty , address ) ;
68
+ const { approveAsync } = useApprove ( payToken . address , _contracts . bounty , address ) ;
81
69
82
70
const rolesOpts = useMemo ( ( ) => {
83
71
return allOpts ?. roles ?. map ( i => ( {
@@ -106,10 +94,7 @@ export function AppliedModal({ open, closeModal, bounty, applyCallback }) {
106
94
skip : 0 ,
107
95
take : 20 ,
108
96
} ) ;
109
- const { loading, list, hasNextPage, doSetList } = useCreatorBountyBuilders (
110
- listParams ,
111
- open
112
- ) ;
97
+ const { loading, list, hasNextPage, doSetList } = useCreatorBountyBuilders ( listParams , open ) ;
113
98
114
99
const [ sentryRef ] = useInfiniteScroll ( {
115
100
loading,
@@ -123,13 +108,13 @@ export function AppliedModal({ open, closeModal, bounty, applyCallback }) {
123
108
}
124
109
125
110
const successCallback = useCallback (
126
- ( res , bid , status ) => {
111
+ ( res : any , bid : any , status : any ) => {
127
112
if ( res . code === 200 ) {
128
113
const _list = [ ...list ] ;
129
- const curr = _list . find ( f => f . id === bid ) ;
114
+ const curr : any = _list . find ( ( f : any ) => f . id === bid ) ;
130
115
if ( curr ) {
131
116
curr . status = status ;
132
- const fixedList = _list . map ( m => {
117
+ const fixedList = _list . map ( ( m : any ) => {
133
118
return m . id === bid ? { ...curr } : m ;
134
119
} ) ;
135
120
doSetList ( fixedList ) ;
@@ -143,7 +128,7 @@ export function AppliedModal({ open, closeModal, bounty, applyCallback }) {
143
128
toast . error ( res . message ) ;
144
129
}
145
130
} ,
146
- [ doSetList , list , applyCallback ]
131
+ [ doSetList , list , applyCallback ] ,
147
132
) ;
148
133
149
134
const decline = async ( bountyId , bid ) => {
@@ -157,28 +142,19 @@ export function AppliedModal({ open, closeModal, bounty, applyCallback }) {
157
142
158
143
const write = async ( ) => {
159
144
try {
160
- const { hash } = await writeContract ( {
161
- address : _contracts . bounty ,
162
- abi : BountyABI ,
163
- functionName : 'createTask' ,
164
- args : [
165
- bounty . task ,
166
- currUser ?. user_wallet ,
167
- payToken . address ,
168
- parseTokenUnits ( ( bounty . amount / 100 ) . toString ( ) , payToken . decimals ) ,
169
- ] ,
170
- } ) ;
145
+ const { hash } = await writeBountyAbiActions . createTask ( _contracts . bounty , [
146
+ bounty . task ,
147
+ currUser ?. user_wallet ,
148
+ payToken . address ,
149
+ parseTokenUnits ( ( bounty . amount / 100 ) . toString ( ) , payToken . decimals ) . toBigInt ( ) ,
150
+ ] ) ;
171
151
172
152
if ( approveConfirmIds . bountyId && approveConfirmIds . bid ) {
173
- const res = await approveBuilder (
174
- approveConfirmIds . bountyId ,
175
- approveConfirmIds . bid ,
176
- hash
177
- ) ;
153
+ const res = await approveBuilder ( approveConfirmIds . bountyId , approveConfirmIds . bid , hash ) ;
178
154
successCallback ( res , approveConfirmIds . bid , 6 ) ;
179
155
}
180
156
setApproveConfirmLoading ( false ) ;
181
- } catch ( err ) {
157
+ } catch ( err : any ) {
182
158
setApproveConfirmLoading ( false ) ;
183
159
console . log ( err ) ;
184
160
toast . error ( err ) ;
@@ -192,13 +168,13 @@ export function AppliedModal({ open, closeModal, bounty, applyCallback }) {
192
168
193
169
const approveConfirm = async ( ) => {
194
170
if ( ! isConnected ) {
195
- openConnectModal ( ) ;
171
+ openConnectModal ?. ( ) ;
196
172
return ;
197
173
}
198
174
setApproveConfirmLoading ( true ) ;
199
175
if (
200
- Number ( allowance . toString ( ) ) < Number ( parseTokenUnits ( ( bounty . amount / 100 ) . toString ( ) , payToken . decimals ) . toString ( ) )
201
- &&
176
+ Number ( allowance . toString ( ) ) <
177
+ Number ( parseTokenUnits ( ( bounty . amount / 100 ) . toString ( ) , payToken . decimals ) . toString ( ) ) &&
202
178
approveAsync
203
179
) {
204
180
await approveAsync ( ) ;
@@ -209,12 +185,7 @@ export function AppliedModal({ open, closeModal, bounty, applyCallback }) {
209
185
} ;
210
186
211
187
return (
212
- < Modal
213
- isOpen = { open }
214
- title = { 'Build applied' }
215
- closeModal = { closeModal }
216
- big = { true }
217
- >
188
+ < Modal isOpen = { open } title = { 'Build applied' } closeModal = { closeModal } big = { true } >
218
189
< div className = "w-full bg-white" >
219
190
< ul
220
191
className = { clsx ( 'grid h-10 items-center font-bold text-xs' , {
@@ -253,12 +224,7 @@ export function AppliedModal({ open, closeModal, bounty, applyCallback }) {
253
224
< p > { i . builder_user . user_nick_name } </ p >
254
225
</ li >
255
226
< li className = "text-center" >
256
- < p >
257
- {
258
- rolesOpts ?. find ( f => f . key === i . builder_user . user_roles )
259
- ?. name
260
- }
261
- </ p >
227
+ < p > { rolesOpts ?. find ( f => f . key === i . builder_user . user_roles ) ?. name } </ p >
262
228
263
229
< p >
264
230
{ i . builder_user . user_skills . map (
@@ -268,28 +234,20 @@ export function AppliedModal({ open, closeModal, bounty, applyCallback }) {
268
234
{ skillOpts ?. find ( f => f . key === s ) ?. name }
269
235
{ k + 1 < i . builder_user . user_skills . length && ', ' } { ' ' }
270
236
</ span >
271
- )
237
+ ) ,
272
238
) }
273
239
{ /* */ }
274
240
</ p >
275
241
</ li >
276
242
< li className = "text-center" >
277
- {
278
- EXPERIENCE_OPTIONS . find (
279
- f => f . key === i . builder_user . user_experience
280
- ) ?. name
281
- }
243
+ { EXPERIENCE_OPTIONS . find ( f => f . key === i . builder_user . user_experience ) ?. name }
282
244
</ li >
283
245
< li className = "text-center" >
284
246
< div
285
247
className = "truncate hover:underline cursor-pointer"
286
- onClick = { ( ) =>
287
- window . open ( mediaUrl + i . builder_user . user_resume )
288
- }
248
+ onClick = { ( ) => window . open ( mediaUrl + i . builder_user . user_resume ) }
289
249
>
290
- { i . builder_user . user_resume
291
- . split ( 'resume/' ) [ 1 ]
292
- ?. split ( '-' ) [ 1 ] || '' }
250
+ { i . builder_user . user_resume . split ( 'resume/' ) [ 1 ] ?. split ( '-' ) [ 1 ] || '' }
293
251
</ div >
294
252
</ li >
295
253
{ /* <li className="text-center">
@@ -356,11 +314,7 @@ export function AppliedModal({ open, closeModal, bounty, applyCallback }) {
356
314
357
315
{ ( loading || hasNextPage ) && < div ref = { sentryRef } /> }
358
316
</ div >
359
- < CommentsModal
360
- comment = { userComment }
361
- open = { commentsModalOpen }
362
- closeModal = { ( ) => setCommentsModalOpen ( false ) }
363
- />
317
+ < CommentsModal comment = { userComment } open = { commentsModalOpen } closeModal = { ( ) => setCommentsModalOpen ( false ) } />
364
318
< Confirm
365
319
loading = { approveConfirmLoading }
366
320
confirmEvt = { approveConfirm }
0 commit comments