diff --git a/modules/browser-node/src/index.ts b/modules/browser-node/src/index.ts index 9382aacaf..0aa7d1951 100644 --- a/modules/browser-node/src/index.ts +++ b/modules/browser-node/src/index.ts @@ -399,7 +399,7 @@ export class BrowserNode implements INodeService { try { const rpc = constructRpcRequest<"chan_deposit">(ChannelRpcMethods.chan_deposit, params); const res = await this.channelProvider!.send(rpc); - return Result.ok({ channelAddress: res.channelAddress }); + return Result.ok(res); } catch (e) { return Result.fail(e); } @@ -410,8 +410,8 @@ export class BrowserNode implements INodeService { ): Promise> { try { const rpc = constructRpcRequest<"chan_requestCollateral">(ChannelRpcMethods.chan_requestCollateral, params); - await this.channelProvider!.send(rpc); - return Result.ok({ channelAddress: params.channelAddress }); + const res = await this.channelProvider!.send(rpc); + return Result.ok(res); } catch (e) { return Result.fail(e); } @@ -427,6 +427,7 @@ export class BrowserNode implements INodeService { channelAddress: res.channelAddress, transferId: (res.latestUpdate.details as CreateUpdateDetails).transferId, routingId: (res.latestUpdate.details as CreateUpdateDetails).meta?.routingId, + channel: res, }); } catch (e) { return Result.fail(e); @@ -442,7 +443,7 @@ export class BrowserNode implements INodeService { return Result.ok({ channelAddress: res.channelAddress, transferId: (res.latestUpdate.details as CreateUpdateDetails).transferId, - routingId: (res.latestUpdate.details as CreateUpdateDetails).meta?.routingId, + channel: res, }); } catch (e) { return Result.fail(e); @@ -459,6 +460,7 @@ export class BrowserNode implements INodeService { channelAddress: res.channel.channelAddress, transferId: (res.channel.latestUpdate.details as CreateUpdateDetails).transferId, transactionHash: res.transactionHash, + channel: res.channel, }); } catch (e) { return Result.fail(e); @@ -471,7 +473,7 @@ export class BrowserNode implements INodeService { try { const rpc = constructRpcRequest<"chan_restoreState">(ChannelRpcMethods.chan_restoreState, params); const res = await this.channelProvider!.send(rpc); - return Result.ok({ channelAddress: res.channelAddress }); + return Result.ok(res); } catch (e) { return Result.fail(e); } diff --git a/modules/router/src/forwarding.ts b/modules/router/src/forwarding.ts index ca5aa74e9..7ae291926 100644 --- a/modules/router/src/forwarding.ts +++ b/modules/router/src/forwarding.ts @@ -482,7 +482,7 @@ export async function forwardTransferResolution( logger.info({ method, methodId }, "Method complete"); return Result.ok({ - ...resolution.getValue(), + ...resolution.getValue() as any, assetId: incomingTransfer.assetId, }); } diff --git a/modules/router/src/listener.ts b/modules/router/src/listener.ts index c2e4abc0a..2e24db2fe 100644 --- a/modules/router/src/listener.ts +++ b/modules/router/src/listener.ts @@ -225,7 +225,7 @@ export async function setupListeners( "Error forwarding resolution", ); } - const resolved = res.getValue(); + const resolved: any = res.getValue(); if (!!resolved) { // was not queued, use receiver transfer for values const amount = BigNumber.from(data.transfer.balance.amount[0]).add(data.transfer.balance.amount[1]); diff --git a/modules/router/src/services/transfer.ts b/modules/router/src/services/transfer.ts index 0bae0683d..84a9c5a64 100644 --- a/modules/router/src/services/transfer.ts +++ b/modules/router/src/services/transfer.ts @@ -30,7 +30,7 @@ export const attemptTransferWithCollateralization = async ( logger: BaseLogger, requireOnline = true, errorContext?: ForwardTransferCreationErrorContext, -): Promise> => { +): Promise> => { const method = "attemptTransferWithCollateralization"; const methodId = getRandomBytes32(); logger.debug( diff --git a/modules/router/src/test/collateral.spec.ts b/modules/router/src/test/collateral.spec.ts index 430225d80..3b244156b 100644 --- a/modules/router/src/test/collateral.spec.ts +++ b/modules/router/src/test/collateral.spec.ts @@ -35,7 +35,7 @@ describe(testName, () => { node = Sinon.createStubInstance(RestServerNodeService); node.conditionalTransfer.resolves(Result.ok({} as any)); node.sendDepositTx.resolves(Result.ok({ txHash: getRandomBytes32() })); - node.reconcileDeposit.resolves(Result.ok({ channelAddress: mkAddress() })); + node.reconcileDeposit.resolves(Result.ok(createTestChannelState("deposit").channel)); chainReader = Sinon.createStubInstance(VectorChainReader); chainReader.getTotalDepositedA.resolves(Result.ok(BigNumber.from(0))); @@ -258,7 +258,9 @@ describe(testName, () => { ], }); node.getStateChannel.resolves(Result.ok(channel)); - node.withdraw.resolves(Result.ok({ channelAddress: channel.channelAddress, transferId: getRandomBytes32() })); + node.withdraw.resolves( + Result.ok({ channelAddress: channel.channelAddress, transferId: getRandomBytes32(), channel }), + ); const res = await adjustCollateral( channel.channelAddress, AddressZero, @@ -331,7 +333,9 @@ describe(testName, () => { const profile = { ...ethProfile, target: "0" }; getRebalanceProfile.returns(Result.ok(profile)); node.getStateChannel.resolves(Result.ok(channel)); - node.withdraw.resolves(Result.ok({ channelAddress: channel.channelAddress, transferId: getRandomBytes32() })); + node.withdraw.resolves( + Result.ok({ channelAddress: channel.channelAddress, transferId: getRandomBytes32(), channel }), + ); const res = await adjustCollateral( channel.channelAddress, AddressZero, diff --git a/modules/router/src/test/forwarding.spec.ts b/modules/router/src/test/forwarding.spec.ts index 1d04e3e00..dd9e45b44 100644 --- a/modules/router/src/test/forwarding.spec.ts +++ b/modules/router/src/test/forwarding.spec.ts @@ -246,7 +246,7 @@ describe(testName, () => { node.getStateChannelByParticipants.resolves(Result.ok(receiverChannel)); node.conditionalTransfer.resolves(Result.ok({} as any)); node.sendDepositTx.resolves(Result.ok({ txHash: getRandomBytes32() })); - node.reconcileDeposit.resolves(Result.ok({ channelAddress: data.channelAddress })); + node.reconcileDeposit.resolves(Result.ok(senderChannel)); store = Sinon.createStubInstance(PrismaStore); diff --git a/modules/server-node/src/index.ts b/modules/server-node/src/index.ts index bf9d677af..defc09e70 100644 --- a/modules/server-node/src/index.ts +++ b/modules/server-node/src/index.ts @@ -479,7 +479,7 @@ server.post<{ Body: NodeParams.RequestSetup }>( }); try { const result = await engine.request<"chan_requestSetup">(rpc); - logger.info({ result }, "Request collateral completed"); + logger.info({ result }, "Request setup completed"); return reply.status(200).send({ ...result, channelAddress: result.channelAddress }); } catch (e) { logger.error({ error: jsonifyError(e) }); @@ -754,6 +754,7 @@ server.post<{ Body: NodeParams.ConditionalTransfer }>( channelAddress: res.channelAddress, transferId: (res.latestUpdate.details as CreateUpdateDetails).transferId, routingId: (res.latestUpdate.details as CreateUpdateDetails).meta?.routingId, + channel: res, } as NodeResponses.ConditionalTransfer); } catch (e) { logger.error({ error: jsonifyError(e) }); @@ -787,6 +788,7 @@ server.post<{ Body: NodeParams.ResolveTransfer }>( return reply.status(200).send({ channelAddress: res.channelAddress, transferId: (res.latestUpdate.details as ResolveUpdateDetails).transferId, + channel: res, } as NodeResponses.ResolveTransfer); } catch (e) { logger.error({ error: jsonifyError(e) }); diff --git a/modules/test-runner/src/load/helpers/agent.ts b/modules/test-runner/src/load/helpers/agent.ts index 64c3e351f..12c24acf9 100644 --- a/modules/test-runner/src/load/helpers/agent.ts +++ b/modules/test-runner/src/load/helpers/agent.ts @@ -140,8 +140,8 @@ export class Agent { if (createRes.isError) { throw createRes.getError()!; } - logger.debug({ ...createRes.getValue() }, "Created transfer"); - return { ...createRes.getValue(), preImage, routingId }; + logger.debug({ ...(createRes.getValue() as any) }, "Created transfer"); + return { ...(createRes.getValue() as any), preImage, routingId }; } async resolveHashlockTransfer( @@ -159,8 +159,8 @@ export class Agent { if (resolveRes.isError) { throw resolveRes.getError()!; } - logger.debug({ ...resolveRes.getValue() }, "Resolved transfer"); - return { ...resolveRes.getValue()!, preImage }; + logger.debug({ ...(resolveRes.getValue() as any) }, "Resolved transfer"); + return { ...(resolveRes.getValue() as any), preImage }; } async fundChannelToTarget(assetId: string, target: BigNumber): Promise { diff --git a/modules/types/src/schemas/node.ts b/modules/types/src/schemas/node.ts index c049dbd24..75bba15d8 100644 --- a/modules/types/src/schemas/node.ts +++ b/modules/types/src/schemas/node.ts @@ -223,7 +223,7 @@ const PostSetupResponseSchema = BasicChannelServerResponseSchema; // POST REQUEST SETUP const PostRequestSetupBodySchema = PostSetupBodySchema; -const PostRequestSetupResponseSchema = BasicChannelServerResponseSchema; +const PostRequestSetupResponseSchema = { 200: TFullChannelState }; // POST DEPOSIT const PostDepositBodySchema = Type.Intersect([ @@ -231,7 +231,7 @@ const PostDepositBodySchema = Type.Intersect([ Type.Object({ publicIdentifier: TPublicIdentifier }), ]); -const PostDepositResponseSchema = BasicChannelServerResponseSchema; +const PostDepositResponseSchema = { 200: TFullChannelState }; // POST DEPOSIT const PostRequestCollateralBodySchema = Type.Intersect([ @@ -239,7 +239,7 @@ const PostRequestCollateralBodySchema = Type.Intersect([ Type.Object({ publicIdentifier: TPublicIdentifier }), ]); -const PostRequestCollateralResponseSchema = BasicChannelServerResponseSchema; +const PostRequestCollateralResponseSchema = { 200: TFullChannelState }; // POST SEND DEPOSIT TX const PostSendDepositTxBodySchema = Type.Object({ @@ -262,7 +262,14 @@ const PostConditionalTransferBodySchema = Type.Intersect([ Type.Object({ publicIdentifier: TPublicIdentifier }), ]); -const PostConditionalTransferResponseSchema = BasicTransferServerResponseSchema; +const PostConditionalTransferResponseSchema = { + 200: { + channelAddress: TAddress, + transferId: TBytes32, + routingId: TBytes32, + channel: TFullChannelState, + }, +}; // POST RESOLVE CONDITIONAL TRANSFER const PostResolveTransferBodySchema = Type.Intersect([ @@ -270,7 +277,13 @@ const PostResolveTransferBodySchema = Type.Intersect([ Type.Object({ publicIdentifier: TPublicIdentifier }), ]); -const PostResolveTransferResponseSchema = BasicTransferServerResponseSchema; +const PostResolveTransferResponseSchema = { + 200: { + channelAddress: TAddress, + transferId: TBytes32, + channel: TFullChannelState, + }, +}; // POST WITHDRAW TRANSFER const PostWithdrawTransferBodySchema = Type.Intersect([ @@ -283,6 +296,7 @@ const PostWithdrawTransferResponseSchema = { channelAddress: TAddress, transferId: TBytes32, transactionHash: Type.Optional(TBytes32), + channel: TFullChannelState, }), }; @@ -305,9 +319,7 @@ const PostRestoreStateBodySchema = Type.Intersect([ ]); const PostRestoreStateResponseSchema = { - 200: Type.Object({ - channelAddress: TAddress, - }), + 200: TFullChannelState, }; // CREATE NODE