Skip to content

Commit

Permalink
fix(channel): return type of state
Browse files Browse the repository at this point in the history
  • Loading branch information
davidyuk committed Dec 22, 2022
1 parent 1552d3a commit 3c34457
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/channel/Base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,12 @@ export default class Channel {
/**
* Get current state
*/
async state(): Promise<ChannelState> {
async state(): Promise<{
calls: Encoded.CallStateTree;
halfSignedTx: Encoded.Transaction | '';
signedTx: Encoded.Transaction;
trees: Encoded.StateTrees;
}> {
return snakeToPascalObjKeys(await call(this, 'channels.get.offchain_state', {}));
}

Expand Down
3 changes: 1 addition & 2 deletions src/channel/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
ChannelState,
changeStatus,
changeState,
call,
notify,
emit,
disconnect,
Expand Down Expand Up @@ -164,7 +163,7 @@ export async function awaitingReconnection(
if (message.method === 'channels.info') {
if (message.params.data.event === 'fsm_up') {
channel._fsmId = message.params.data.fsm_id;
changeState(channel, (await call(channel, 'channels.get.offchain_state', {})).signed_tx);
changeState(channel, (await channel.state()).signedTx);
return { handler: channelOpen };
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/channel/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ export async function initialize(
changeStatus(channel, 'connected');
if (channelOptions.reconnectTx != null) {
enterState(channel, { handler: openHandler });
const signedTx = (await call(channel, 'channels.get.offchain_state', {})).signed_tx;
const { signedTx } = await channel.state();
changeState(channel, signedTx);
}
ping(channel);
Expand Down

0 comments on commit 3c34457

Please sign in to comment.