@@ -26,9 +26,9 @@ import { type CKBComponents } from '@ckb-lumos/lumos/rpc'
2626import {
2727 SerializeOffChainParticipant ,
2828 SerializeSEC1EncodedPubKey ,
29- } from '@ckb-connect /perun-wallet-wrapper/dist /ckb/serialization'
30- import { channelIdToString , channelIdFromString } from '@ckb-connect /perun-wallet-wrapper/dist /translator'
31- import * as wire from '@ckb-connect /perun-wallet-wrapper/dist /wire'
29+ } from 'utils /perun-wallet-wrapper/ckb/serialization'
30+ import { channelIdToString , channelIdFromString } from 'utils /perun-wallet-wrapper/translator'
31+ import * as wire from 'utils /perun-wallet-wrapper/wire'
3232
3333import { ControllerResponse } from 'services/remote/remoteApiWrapper'
3434import {
@@ -60,6 +60,7 @@ import PerunSendPayment from 'components/PerunSendPayment'
6060import type { State } from 'utils/perun-wallet-wrapper/wire'
6161import RowExtend from './RowExtend'
6262import styles from './perun.module.scss'
63+ import ChannelCard from './components/ChannelCard'
6364
6465enum DialogType {
6566 creationRequest = 'creationRequest' ,
@@ -111,90 +112,28 @@ const PaymentChannel = () => {
111112 if ( ! isSuccessResponse ( actionRes ) ) {
112113 return
113114 }
114-
115- const id = actionRes . result . channels . states [ 0 ] . id . data
116- const { version } = actionRes . result . channels . states [ 0 ]
117- const { app } = actionRes . result . channels . states [ 0 ]
118-
119- const alloc = wire . Allocation . create ( {
120- assets : [ new Uint8Array ( 32 ) ] ,
121- balances : wire . Balances . create ( {
122- balances : [
123- {
124- balance : [
125- actionRes . result . channels . states [ 0 ] . allocation . balances . balances [ 0 ] . balance [ 0 ] . data ,
126- actionRes . result . channels . states [ 0 ] . allocation . balances . balances [ 0 ] . balance [ 1 ] . data ,
127- ] ,
128- } ,
129- ] ,
130- } ) ,
131- locked : [ ] ,
132- } )
133- const { data } = actionRes . result . channels . states [ 0 ]
134- const { isFinal } = actionRes . result . channels . states [ 0 ]
135-
136- const state = wire . State . create ( {
137- id,
138- version,
139- app,
140- allocation : alloc ,
141- data,
142- isFinal,
143- } )
144- setChannels ( prev => {
145- if ( ! ! prev . find ( item => item . id === state . id ) ) {
146- // todo
147- return prev
148- }
149- return [ ...prev , state ]
150- } )
115+ const channelStates = actionRes . result . channels . states . map ( channelState => {
116+ const { id : idObj , version, app, allocation, data, isFinal } = channelState ;
117+ const id = idObj . data ;
118+ const alloc = wire . Allocation . create ( allocation ) ;
119+ const state = wire . State . create ( {
120+ id,
121+ version,
122+ app,
123+ allocation : alloc ,
124+ data,
125+ isFinal,
126+ } )
127+ return state ;
128+ } ) ;
129+ console . log ( { channelStates } )
130+ setChannels ( channelStates ) ;
151131 } ) ( )
152132
153133 }
154134
155135 } , [ requesterId , requests ] )
156136
157-
158- const handleExpandClick = ( idx : number | null ) => {
159- setExpandedRow ( prevIndex => ( prevIndex === idx ? null : idx ) )
160- }
161-
162- // const columns: TableProps<wire.State[]>['columns'] = [
163- // {
164- // title: t('history.table.asset'),
165- // dataIndex: 'allocation',
166- // align: 'left',
167- // minWidth: '150px',
168- // render: (_, __, item) => JSON.stringify(item.allocation),
169- // },
170- // {
171- // title: t('perun.creation-time'),
172- // dataIndex: 'createdAt',
173- // align: 'left',
174- // minWidth: '150px',
175- // render: (_, __, item) => item.createdAt,
176- // sortable: true,
177- // },
178- // {
179- // title: t('history.table.status'),
180- // dataIndex: 'status',
181- // align: 'left',
182- // minWidth: '50px',
183- // render(_, __, item) {
184- // return 'status'
185- // },
186- // },
187- // {
188- // title: t('history.table.operation'),
189- // dataIndex: 'operation',
190- // align: 'center',
191- // minWidth: '72px',
192- // render(_, idx) {
193- // return <ArrowNext className={styles.arrow} data-is-expand-show={expandedRow === idx} />
194- // },
195- // },
196- // ]
197-
198137 return (
199138 < PageContainer
200139 head = {
@@ -271,6 +210,18 @@ const PaymentChannel = () => {
271210 onRowClick={(_, __, idx) => handleExpandClick(idx)}
272211 /> */ }
273212 </ div >
213+ < div className = { styles . overviewWrap } >
214+ { channels . map ( item => (
215+ < ChannelCard
216+ key = { channelIdToString ( item . id ) }
217+ channelState = { item }
218+ onClose = { ( ) => { } }
219+ onSend = { ( ) => { } }
220+ // onClose={() => setShowCloseChannelDialog(true)}
221+ // onSend={() => setShowSendDialog(true)}
222+ />
223+ ) ) }
224+ </ div >
274225 </ div >
275226
276227 { dialogType === DialogType . creationRequest && requests . length > 0 && (
0 commit comments