Skip to content

Commit 29e7eba

Browse files
committed
wip: update
1 parent 567f0d2 commit 29e7eba

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

packages/neuron-ui/src/components/PaymentChannel/components/Console/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ export default function PerunConsole(props: PerunConsoleProps) {
211211
<PerunCreationRequestList
212212
walletID={wallet?.id ?? ''}
213213
requests={requests}
214+
channelInfoMap={channelInfoMap}
214215
onOpenChannel={(request) => {
215216
// todo convert request.initBals to payload
216217
const payload: PerunAPI.OpenChannelParams['balances'] = [{ type: null, balances: ["1", "2"]}]

packages/neuron-ui/src/components/PaymentChannel/hooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function useChannelInfoMap() {
2020
const { [channelId]: _, ...rest } = map
2121
return rest
2222
})
23-
const get = (channelId: string) => map[channelId]
23+
const get = (channelId: string) => map[channelId] as ChannelInfo | undefined
2424

2525
return {
2626
add,

packages/neuron-ui/src/components/PerunCreationRequestList/index.tsx

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ import { deletePerunRequest } from 'states/stateProvider/actionCreators'
3434
import styles from './perunCreationRequestList.module.scss'
3535
import { getCompatibleTx } from './utils'
3636
import Token from 'components/PaymentChannel/components/Token'
37+
import { useChannelInfoMap } from 'components/PaymentChannel/hooks'
3738

3839
type PerunRequestListProps = {
3940
requests: Perun.ReadableMessage.Request[]
4041
onCancel: () => void
4142
walletID: string
43+
channelInfoMap: ReturnType<typeof useChannelInfoMap>
4244
onOpenChannel: (request: Perun.ReadableMessage.OpenChannelRequest) => void
4345
onUpdateChannel: (request: Perun.ReadableMessage.UpdateNotificationRequest) => void
4446
}
@@ -50,6 +52,7 @@ export const PerunCreationRequestList = (props: PerunRequestListProps) => {
5052
walletID,
5153
onOpenChannel,
5254
onUpdateChannel,
55+
channelInfoMap,
5356
} = props
5457
const [t] = useTranslation()
5558
const [showPasswordDialog, setShowPasswordDialog] = useState(false)
@@ -133,26 +136,31 @@ export const PerunCreationRequestList = (props: PerunRequestListProps) => {
133136
case "UpdateNotification": {
134137
console.log('UpdateNotification request: ', perunRequest.request)
135138
const channelState = perunRequest.request.state;
139+
const info = channelInfoMap.get(channelState!.id);
140+
const myPayloadIndex = info?.myPayloadIndex ?? 1
136141
return (
137142
<>
138143
<h3 className='my-0'>Update Notification</h3>
139144
<p>{`Channel ID: ${channelState?.id}`}</p>
140145
<div className='flex flex-row gap-4 mt-2'>
141146
<div>
142-
<div className='text-secondary'>Who's Token Locked</div>
147+
<div className='text-secondary'>My Token Locked</div>
143148
<div className='mt-1'>
144-
<Token type={null} amount={channelState?.allocation?.balances?.balances[0].balance[0] ?? "0"} />
149+
<Token type={null} amount={channelState?.allocation?.balances?.balances[0].balance[myPayloadIndex] ?? "0"} />
145150
</div>
146151
</div>
147152
<div>
148-
<div className='text-secondary'>Who's Token Locked</div>
153+
<div className='text-secondary'>Peer Token Locked</div>
149154
<div className='mt-1'>
150-
<Token type={null} amount={channelState?.allocation?.balances?.balances[0].balance[1] ?? "0"} />
155+
<Token type={null} amount={channelState?.allocation?.balances?.balances[0].balance[1 - myPayloadIndex] ?? "0"} />
156+
</div>
157+
</div>
158+
<div>
159+
<div className='text-secondary'>isFinal</div>
160+
<div className='mt-1'>
161+
{channelState?.isFinal === true ? 'true' : 'false'}
151162
</div>
152163
</div>
153-
</div>
154-
<div>
155-
isFinal: {channelState?.isFinal === true ? 'true' : 'false'}
156164
</div>
157165
</>
158166
)

0 commit comments

Comments
 (0)