From 45e9174fda1548ace01385a35b72ea3e9fbddd91 Mon Sep 17 00:00:00 2001 From: Jan Bormet Date: Tue, 19 Dec 2023 10:30:56 +0100 Subject: [PATCH 1/7] WIP: fixes --- package.json | 2 +- perun-wallet-spec | 2 +- src/client.ts | 19 +- src/perun-wallet.ts | 162 ++++++ src/translator.ts | 19 +- src/wire.ts | 1208 ++++++++++++------------------------------- 6 files changed, 522 insertions(+), 890 deletions(-) diff --git a/package.json b/package.json index cbbcce4..d6504f5 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@polycrypt/perun-wallet-wrapper", "devDependencies": { "grpc-tools": "^1.12.4", - "ts-proto": "^1.162.1", + "ts-proto": "^1.165.1", "typescript": "^5.2.2" }, "dependencies": { diff --git a/perun-wallet-spec b/perun-wallet-spec index a8ac212..a209659 160000 --- a/perun-wallet-spec +++ b/perun-wallet-spec @@ -1 +1 @@ -Subproject commit a8ac2129e3ecf4254855e837a471900625634b16 +Subproject commit a209659bdcfb6bf9bb063c00290498babd9620b1 diff --git a/src/client.ts b/src/client.ts index 4347c97..b268e81 100644 --- a/src/client.ts +++ b/src/client.ts @@ -49,7 +49,6 @@ export class ServiceClient implements SimpleChannelServiceClient { } else { channelId = id; } - const channel = this.channels.get(channelId); if (!channel) { throw new ClientError("channel not found"); @@ -82,6 +81,8 @@ export class ServiceClient implements SimpleChannelServiceClient { } const channelId = this.idToString(res.channelId!); + console.log("Wrapper channelId res: ", res.channelId) + console.log("Wrapper channelId: ", channelId) const initState = { id: res.channelId!, version: 0, @@ -91,6 +92,10 @@ export class ServiceClient implements SimpleChannelServiceClient { isFinal: false, }; this.channels.set(channelId, { myIndex: 0, state: initState }); + // loop over this.channels map + for (let [key, value] of this.channels) { + console.log("Channels after open: ", key, value); + } return res; } @@ -100,7 +105,14 @@ export class ServiceClient implements SimpleChannelServiceClient { assetIdx: number, amount: bigint, ): ServiceResponse { - const channel = this.channels.get(this.idToString(channelId)); + const cID = this.idToString(channelId) + console.log("updateChannel cID: ", cID) + // loop over this.channels map + for (let [key, value] of this.channels) { + console.log("Channels during updateChannel: ", key, value); + } + const channel = this.channels.get(cID); + console.log("updateChannel: ", channel) if (!channel) { throw new ClientError("channel not found"); } @@ -115,8 +127,9 @@ export class ServiceClient implements SimpleChannelServiceClient { const req = { state: proposedState, }; - + console.log("updateChannel calling Channel Service: ", req) const res = await this.channelServiceClient.updateChannel(req); + console.log("updateChannel called channel servicec res: ", res) if (res.rejected) { return res; diff --git a/src/perun-wallet.ts b/src/perun-wallet.ts index 7520072..95ada64 100644 --- a/src/perun-wallet.ts +++ b/src/perun-wallet.ts @@ -11,6 +11,16 @@ export interface Rejected { reason: string; } +export interface GetChannelsRequest { + /** The channel id of the channel to be closed. */ + requester: Uint8Array; +} + +export interface GetChannelsResponse { + rejected?: Rejected | undefined; + channels?: Uint8Array | undefined; +} + export interface ChannelOpenRequest { /** The identity of the requester. */ requester: Uint8Array; @@ -216,6 +226,139 @@ export const Rejected = { }, }; +function createBaseGetChannelsRequest(): GetChannelsRequest { + return { requester: new Uint8Array(0) }; +} + +export const GetChannelsRequest = { + encode(message: GetChannelsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.requester.length !== 0) { + writer.uint32(10).bytes(message.requester); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): GetChannelsRequest { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetChannelsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.requester = reader.bytes(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): GetChannelsRequest { + return { requester: isSet(object.requester) ? bytesFromBase64(object.requester) : new Uint8Array(0) }; + }, + + toJSON(message: GetChannelsRequest): unknown { + const obj: any = {}; + if (message.requester.length !== 0) { + obj.requester = base64FromBytes(message.requester); + } + return obj; + }, + + create(base?: DeepPartial): GetChannelsRequest { + return GetChannelsRequest.fromPartial(base ?? {}); + }, + fromPartial(object: DeepPartial): GetChannelsRequest { + const message = createBaseGetChannelsRequest(); + message.requester = object.requester ?? new Uint8Array(0); + return message; + }, +}; + +function createBaseGetChannelsResponse(): GetChannelsResponse { + return { rejected: undefined, channels: undefined }; +} + +export const GetChannelsResponse = { + encode(message: GetChannelsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.rejected !== undefined) { + Rejected.encode(message.rejected, writer.uint32(10).fork()).ldelim(); + } + if (message.channels !== undefined) { + writer.uint32(18).bytes(message.channels); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): GetChannelsResponse { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetChannelsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.rejected = Rejected.decode(reader, reader.uint32()); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.channels = reader.bytes(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): GetChannelsResponse { + return { + rejected: isSet(object.rejected) ? Rejected.fromJSON(object.rejected) : undefined, + channels: isSet(object.channels) ? bytesFromBase64(object.channels) : undefined, + }; + }, + + toJSON(message: GetChannelsResponse): unknown { + const obj: any = {}; + if (message.rejected !== undefined) { + obj.rejected = Rejected.toJSON(message.rejected); + } + if (message.channels !== undefined) { + obj.channels = base64FromBytes(message.channels); + } + return obj; + }, + + create(base?: DeepPartial): GetChannelsResponse { + return GetChannelsResponse.fromPartial(base ?? {}); + }, + fromPartial(object: DeepPartial): GetChannelsResponse { + const message = createBaseGetChannelsResponse(); + message.rejected = (object.rejected !== undefined && object.rejected !== null) + ? Rejected.fromPartial(object.rejected) + : undefined; + message.channels = object.channels ?? undefined; + return message; + }, +}; + function createBaseChannelOpenRequest(): ChannelOpenRequest { return { requester: new Uint8Array(0), peer: new Uint8Array(0), allocation: undefined, challengeDuration: 0 }; } @@ -1855,6 +1998,15 @@ export const ChannelServiceDefinition = { responseStream: false, options: {}, }, + /** Query the current state of the Channels.option */ + getChannels: { + name: "GetChannels", + requestType: GetChannelsRequest, + requestStream: false, + responseType: GetChannelsResponse, + responseStream: false, + options: {}, + }, }, } as const; @@ -1874,6 +2026,11 @@ export interface ChannelServiceImplementation { request: ChannelCloseRequest, context: CallContext & CallContextExt, ): Promise>; + /** Query the current state of the Channels.option */ + getChannels( + request: GetChannelsRequest, + context: CallContext & CallContextExt, + ): Promise>; } export interface ChannelServiceClient { @@ -1892,6 +2049,11 @@ export interface ChannelServiceClient { request: DeepPartial, options?: CallOptions & CallOptionsExt, ): Promise; + /** Query the current state of the Channels.option */ + getChannels( + request: DeepPartial, + options?: CallOptions & CallOptionsExt, + ): Promise; } /** diff --git a/src/translator.ts b/src/translator.ts index 6ac0163..25e53fd 100644 --- a/src/translator.ts +++ b/src/translator.ts @@ -3,11 +3,22 @@ export interface AddressEncoder { } export function channelIdToString(id: Uint8Array): string { - const decoder = new TextDecoder("utf-8"); - return decoder.decode(id); + // Convert Uint8Array to hex string + const hexString: string = Array.from(id) + .map(byte => ('0' + byte.toString(16)).slice(-2)) + .join(''); + return "0x" + hexString; } export function channelIdFromString(id: string): Uint8Array { - const encoder = new TextEncoder(); - return encoder.encode(id); + if (id.startsWith('0x')) { + id = id.slice(2); + } + const uint8Array = new Uint8Array(id.length / 2); + for (let i = 0; i < id.length; i += 2) { + const byte = id.slice(i, i + 2); + uint8Array[i / 2] = parseInt(byte, 16); + } + + return uint8Array; } diff --git a/src/wire.ts b/src/wire.ts index 6d03464..afca4b4 100644 --- a/src/wire.ts +++ b/src/wire.ts @@ -25,12 +25,8 @@ export interface Envelope { virtualChannelProposalAccMsg?: VirtualChannelProposalAccMsg | undefined; channelProposalRejMsg?: ChannelProposalRejMsg | undefined; channelUpdateMsg?: ChannelUpdateMsg | undefined; - virtualChannelFundingProposalMsg?: - | VirtualChannelFundingProposalMsg - | undefined; - virtualChannelSettlementProposalMsg?: - | VirtualChannelSettlementProposalMsg - | undefined; + virtualChannelFundingProposalMsg?: VirtualChannelFundingProposalMsg | undefined; + virtualChannelSettlementProposalMsg?: VirtualChannelSettlementProposalMsg | undefined; channelUpdateAccMsg?: ChannelUpdateAccMsg | undefined; channelUpdateRejMsg?: ChannelUpdateRejMsg | undefined; channelSyncMsg?: ChannelSyncMsg | undefined; @@ -148,7 +144,8 @@ export interface ShutdownMsg { } /** AuthResponseMsg represents wire.AuthResponseMsg. */ -export interface AuthResponseMsg {} +export interface AuthResponseMsg { +} /** LedgerChannelProposalMsg represents client.LedgerChannelProposalMsg. */ export interface LedgerChannelProposalMsg { @@ -265,10 +262,7 @@ function createBaseEnvelope(): Envelope { } export const Envelope = { - encode( - message: Envelope, - writer: _m0.Writer = _m0.Writer.create(), - ): _m0.Writer { + encode(message: Envelope, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.sender.length !== 0) { writer.uint32(10).bytes(message.sender); } @@ -282,101 +276,57 @@ export const Envelope = { PongMsg.encode(message.pongMsg, writer.uint32(34).fork()).ldelim(); } if (message.shutdownMsg !== undefined) { - ShutdownMsg.encode( - message.shutdownMsg, - writer.uint32(42).fork(), - ).ldelim(); + ShutdownMsg.encode(message.shutdownMsg, writer.uint32(42).fork()).ldelim(); } if (message.authResponseMsg !== undefined) { - AuthResponseMsg.encode( - message.authResponseMsg, - writer.uint32(50).fork(), - ).ldelim(); + AuthResponseMsg.encode(message.authResponseMsg, writer.uint32(50).fork()).ldelim(); } if (message.ledgerChannelProposalMsg !== undefined) { - LedgerChannelProposalMsg.encode( - message.ledgerChannelProposalMsg, - writer.uint32(58).fork(), - ).ldelim(); + LedgerChannelProposalMsg.encode(message.ledgerChannelProposalMsg, writer.uint32(58).fork()).ldelim(); } if (message.ledgerChannelProposalAccMsg !== undefined) { - LedgerChannelProposalAccMsg.encode( - message.ledgerChannelProposalAccMsg, - writer.uint32(66).fork(), - ).ldelim(); + LedgerChannelProposalAccMsg.encode(message.ledgerChannelProposalAccMsg, writer.uint32(66).fork()).ldelim(); } if (message.subChannelProposalMsg !== undefined) { - SubChannelProposalMsg.encode( - message.subChannelProposalMsg, - writer.uint32(74).fork(), - ).ldelim(); + SubChannelProposalMsg.encode(message.subChannelProposalMsg, writer.uint32(74).fork()).ldelim(); } if (message.subChannelProposalAccMsg !== undefined) { - SubChannelProposalAccMsg.encode( - message.subChannelProposalAccMsg, - writer.uint32(82).fork(), - ).ldelim(); + SubChannelProposalAccMsg.encode(message.subChannelProposalAccMsg, writer.uint32(82).fork()).ldelim(); } if (message.virtualChannelProposalMsg !== undefined) { - VirtualChannelProposalMsg.encode( - message.virtualChannelProposalMsg, - writer.uint32(90).fork(), - ).ldelim(); + VirtualChannelProposalMsg.encode(message.virtualChannelProposalMsg, writer.uint32(90).fork()).ldelim(); } if (message.virtualChannelProposalAccMsg !== undefined) { - VirtualChannelProposalAccMsg.encode( - message.virtualChannelProposalAccMsg, - writer.uint32(98).fork(), - ).ldelim(); + VirtualChannelProposalAccMsg.encode(message.virtualChannelProposalAccMsg, writer.uint32(98).fork()).ldelim(); } if (message.channelProposalRejMsg !== undefined) { - ChannelProposalRejMsg.encode( - message.channelProposalRejMsg, - writer.uint32(106).fork(), - ).ldelim(); + ChannelProposalRejMsg.encode(message.channelProposalRejMsg, writer.uint32(106).fork()).ldelim(); } if (message.channelUpdateMsg !== undefined) { - ChannelUpdateMsg.encode( - message.channelUpdateMsg, - writer.uint32(114).fork(), - ).ldelim(); + ChannelUpdateMsg.encode(message.channelUpdateMsg, writer.uint32(114).fork()).ldelim(); } if (message.virtualChannelFundingProposalMsg !== undefined) { - VirtualChannelFundingProposalMsg.encode( - message.virtualChannelFundingProposalMsg, - writer.uint32(122).fork(), - ).ldelim(); + VirtualChannelFundingProposalMsg.encode(message.virtualChannelFundingProposalMsg, writer.uint32(122).fork()) + .ldelim(); } if (message.virtualChannelSettlementProposalMsg !== undefined) { - VirtualChannelSettlementProposalMsg.encode( - message.virtualChannelSettlementProposalMsg, - writer.uint32(130).fork(), - ).ldelim(); + VirtualChannelSettlementProposalMsg.encode(message.virtualChannelSettlementProposalMsg, writer.uint32(130).fork()) + .ldelim(); } if (message.channelUpdateAccMsg !== undefined) { - ChannelUpdateAccMsg.encode( - message.channelUpdateAccMsg, - writer.uint32(138).fork(), - ).ldelim(); + ChannelUpdateAccMsg.encode(message.channelUpdateAccMsg, writer.uint32(138).fork()).ldelim(); } if (message.channelUpdateRejMsg !== undefined) { - ChannelUpdateRejMsg.encode( - message.channelUpdateRejMsg, - writer.uint32(146).fork(), - ).ldelim(); + ChannelUpdateRejMsg.encode(message.channelUpdateRejMsg, writer.uint32(146).fork()).ldelim(); } if (message.channelSyncMsg !== undefined) { - ChannelSyncMsg.encode( - message.channelSyncMsg, - writer.uint32(154).fork(), - ).ldelim(); + ChannelSyncMsg.encode(message.channelSyncMsg, writer.uint32(154).fork()).ldelim(); } return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): Envelope { - const reader = - input instanceof _m0.Reader ? input : _m0.Reader.create(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEnvelope(); while (reader.pos < end) { @@ -422,132 +372,101 @@ export const Envelope = { break; } - message.authResponseMsg = AuthResponseMsg.decode( - reader, - reader.uint32(), - ); + message.authResponseMsg = AuthResponseMsg.decode(reader, reader.uint32()); continue; case 7: if (tag !== 58) { break; } - message.ledgerChannelProposalMsg = LedgerChannelProposalMsg.decode( - reader, - reader.uint32(), - ); + message.ledgerChannelProposalMsg = LedgerChannelProposalMsg.decode(reader, reader.uint32()); continue; case 8: if (tag !== 66) { break; } - message.ledgerChannelProposalAccMsg = - LedgerChannelProposalAccMsg.decode(reader, reader.uint32()); + message.ledgerChannelProposalAccMsg = LedgerChannelProposalAccMsg.decode(reader, reader.uint32()); continue; case 9: if (tag !== 74) { break; } - message.subChannelProposalMsg = SubChannelProposalMsg.decode( - reader, - reader.uint32(), - ); + message.subChannelProposalMsg = SubChannelProposalMsg.decode(reader, reader.uint32()); continue; case 10: if (tag !== 82) { break; } - message.subChannelProposalAccMsg = SubChannelProposalAccMsg.decode( - reader, - reader.uint32(), - ); + message.subChannelProposalAccMsg = SubChannelProposalAccMsg.decode(reader, reader.uint32()); continue; case 11: if (tag !== 90) { break; } - message.virtualChannelProposalMsg = VirtualChannelProposalMsg.decode( - reader, - reader.uint32(), - ); + message.virtualChannelProposalMsg = VirtualChannelProposalMsg.decode(reader, reader.uint32()); continue; case 12: if (tag !== 98) { break; } - message.virtualChannelProposalAccMsg = - VirtualChannelProposalAccMsg.decode(reader, reader.uint32()); + message.virtualChannelProposalAccMsg = VirtualChannelProposalAccMsg.decode(reader, reader.uint32()); continue; case 13: if (tag !== 106) { break; } - message.channelProposalRejMsg = ChannelProposalRejMsg.decode( - reader, - reader.uint32(), - ); + message.channelProposalRejMsg = ChannelProposalRejMsg.decode(reader, reader.uint32()); continue; case 14: if (tag !== 114) { break; } - message.channelUpdateMsg = ChannelUpdateMsg.decode( - reader, - reader.uint32(), - ); + message.channelUpdateMsg = ChannelUpdateMsg.decode(reader, reader.uint32()); continue; case 15: if (tag !== 122) { break; } - message.virtualChannelFundingProposalMsg = - VirtualChannelFundingProposalMsg.decode(reader, reader.uint32()); + message.virtualChannelFundingProposalMsg = VirtualChannelFundingProposalMsg.decode(reader, reader.uint32()); continue; case 16: if (tag !== 130) { break; } - message.virtualChannelSettlementProposalMsg = - VirtualChannelSettlementProposalMsg.decode(reader, reader.uint32()); + message.virtualChannelSettlementProposalMsg = VirtualChannelSettlementProposalMsg.decode( + reader, + reader.uint32(), + ); continue; case 17: if (tag !== 138) { break; } - message.channelUpdateAccMsg = ChannelUpdateAccMsg.decode( - reader, - reader.uint32(), - ); + message.channelUpdateAccMsg = ChannelUpdateAccMsg.decode(reader, reader.uint32()); continue; case 18: if (tag !== 146) { break; } - message.channelUpdateRejMsg = ChannelUpdateRejMsg.decode( - reader, - reader.uint32(), - ); + message.channelUpdateRejMsg = ChannelUpdateRejMsg.decode(reader, reader.uint32()); continue; case 19: if (tag !== 154) { break; } - message.channelSyncMsg = ChannelSyncMsg.decode( - reader, - reader.uint32(), - ); + message.channelSyncMsg = ChannelSyncMsg.decode(reader, reader.uint32()); continue; } if ((tag & 7) === 4 || tag === 0) { @@ -560,31 +479,17 @@ export const Envelope = { fromJSON(object: any): Envelope { return { - sender: isSet(object.sender) - ? bytesFromBase64(object.sender) - : new Uint8Array(0), - recipient: isSet(object.recipient) - ? bytesFromBase64(object.recipient) - : new Uint8Array(0), - pingMsg: isSet(object.pingMsg) - ? PingMsg.fromJSON(object.pingMsg) - : undefined, - pongMsg: isSet(object.pongMsg) - ? PongMsg.fromJSON(object.pongMsg) - : undefined, - shutdownMsg: isSet(object.shutdownMsg) - ? ShutdownMsg.fromJSON(object.shutdownMsg) - : undefined, - authResponseMsg: isSet(object.authResponseMsg) - ? AuthResponseMsg.fromJSON(object.authResponseMsg) - : undefined, + sender: isSet(object.sender) ? bytesFromBase64(object.sender) : new Uint8Array(0), + recipient: isSet(object.recipient) ? bytesFromBase64(object.recipient) : new Uint8Array(0), + pingMsg: isSet(object.pingMsg) ? PingMsg.fromJSON(object.pingMsg) : undefined, + pongMsg: isSet(object.pongMsg) ? PongMsg.fromJSON(object.pongMsg) : undefined, + shutdownMsg: isSet(object.shutdownMsg) ? ShutdownMsg.fromJSON(object.shutdownMsg) : undefined, + authResponseMsg: isSet(object.authResponseMsg) ? AuthResponseMsg.fromJSON(object.authResponseMsg) : undefined, ledgerChannelProposalMsg: isSet(object.ledgerChannelProposalMsg) ? LedgerChannelProposalMsg.fromJSON(object.ledgerChannelProposalMsg) : undefined, ledgerChannelProposalAccMsg: isSet(object.ledgerChannelProposalAccMsg) - ? LedgerChannelProposalAccMsg.fromJSON( - object.ledgerChannelProposalAccMsg, - ) + ? LedgerChannelProposalAccMsg.fromJSON(object.ledgerChannelProposalAccMsg) : undefined, subChannelProposalMsg: isSet(object.subChannelProposalMsg) ? SubChannelProposalMsg.fromJSON(object.subChannelProposalMsg) @@ -596,29 +501,17 @@ export const Envelope = { ? VirtualChannelProposalMsg.fromJSON(object.virtualChannelProposalMsg) : undefined, virtualChannelProposalAccMsg: isSet(object.virtualChannelProposalAccMsg) - ? VirtualChannelProposalAccMsg.fromJSON( - object.virtualChannelProposalAccMsg, - ) + ? VirtualChannelProposalAccMsg.fromJSON(object.virtualChannelProposalAccMsg) : undefined, channelProposalRejMsg: isSet(object.channelProposalRejMsg) ? ChannelProposalRejMsg.fromJSON(object.channelProposalRejMsg) : undefined, - channelUpdateMsg: isSet(object.channelUpdateMsg) - ? ChannelUpdateMsg.fromJSON(object.channelUpdateMsg) - : undefined, - virtualChannelFundingProposalMsg: isSet( - object.virtualChannelFundingProposalMsg, - ) - ? VirtualChannelFundingProposalMsg.fromJSON( - object.virtualChannelFundingProposalMsg, - ) + channelUpdateMsg: isSet(object.channelUpdateMsg) ? ChannelUpdateMsg.fromJSON(object.channelUpdateMsg) : undefined, + virtualChannelFundingProposalMsg: isSet(object.virtualChannelFundingProposalMsg) + ? VirtualChannelFundingProposalMsg.fromJSON(object.virtualChannelFundingProposalMsg) : undefined, - virtualChannelSettlementProposalMsg: isSet( - object.virtualChannelSettlementProposalMsg, - ) - ? VirtualChannelSettlementProposalMsg.fromJSON( - object.virtualChannelSettlementProposalMsg, - ) + virtualChannelSettlementProposalMsg: isSet(object.virtualChannelSettlementProposalMsg) + ? VirtualChannelSettlementProposalMsg.fromJSON(object.virtualChannelSettlementProposalMsg) : undefined, channelUpdateAccMsg: isSet(object.channelUpdateAccMsg) ? ChannelUpdateAccMsg.fromJSON(object.channelUpdateAccMsg) @@ -626,9 +519,7 @@ export const Envelope = { channelUpdateRejMsg: isSet(object.channelUpdateRejMsg) ? ChannelUpdateRejMsg.fromJSON(object.channelUpdateRejMsg) : undefined, - channelSyncMsg: isSet(object.channelSyncMsg) - ? ChannelSyncMsg.fromJSON(object.channelSyncMsg) - : undefined, + channelSyncMsg: isSet(object.channelSyncMsg) ? ChannelSyncMsg.fromJSON(object.channelSyncMsg) : undefined, }; }, @@ -653,64 +544,44 @@ export const Envelope = { obj.authResponseMsg = AuthResponseMsg.toJSON(message.authResponseMsg); } if (message.ledgerChannelProposalMsg !== undefined) { - obj.ledgerChannelProposalMsg = LedgerChannelProposalMsg.toJSON( - message.ledgerChannelProposalMsg, - ); + obj.ledgerChannelProposalMsg = LedgerChannelProposalMsg.toJSON(message.ledgerChannelProposalMsg); } if (message.ledgerChannelProposalAccMsg !== undefined) { - obj.ledgerChannelProposalAccMsg = LedgerChannelProposalAccMsg.toJSON( - message.ledgerChannelProposalAccMsg, - ); + obj.ledgerChannelProposalAccMsg = LedgerChannelProposalAccMsg.toJSON(message.ledgerChannelProposalAccMsg); } if (message.subChannelProposalMsg !== undefined) { - obj.subChannelProposalMsg = SubChannelProposalMsg.toJSON( - message.subChannelProposalMsg, - ); + obj.subChannelProposalMsg = SubChannelProposalMsg.toJSON(message.subChannelProposalMsg); } if (message.subChannelProposalAccMsg !== undefined) { - obj.subChannelProposalAccMsg = SubChannelProposalAccMsg.toJSON( - message.subChannelProposalAccMsg, - ); + obj.subChannelProposalAccMsg = SubChannelProposalAccMsg.toJSON(message.subChannelProposalAccMsg); } if (message.virtualChannelProposalMsg !== undefined) { - obj.virtualChannelProposalMsg = VirtualChannelProposalMsg.toJSON( - message.virtualChannelProposalMsg, - ); + obj.virtualChannelProposalMsg = VirtualChannelProposalMsg.toJSON(message.virtualChannelProposalMsg); } if (message.virtualChannelProposalAccMsg !== undefined) { - obj.virtualChannelProposalAccMsg = VirtualChannelProposalAccMsg.toJSON( - message.virtualChannelProposalAccMsg, - ); + obj.virtualChannelProposalAccMsg = VirtualChannelProposalAccMsg.toJSON(message.virtualChannelProposalAccMsg); } if (message.channelProposalRejMsg !== undefined) { - obj.channelProposalRejMsg = ChannelProposalRejMsg.toJSON( - message.channelProposalRejMsg, - ); + obj.channelProposalRejMsg = ChannelProposalRejMsg.toJSON(message.channelProposalRejMsg); } if (message.channelUpdateMsg !== undefined) { obj.channelUpdateMsg = ChannelUpdateMsg.toJSON(message.channelUpdateMsg); } if (message.virtualChannelFundingProposalMsg !== undefined) { - obj.virtualChannelFundingProposalMsg = - VirtualChannelFundingProposalMsg.toJSON( - message.virtualChannelFundingProposalMsg, - ); + obj.virtualChannelFundingProposalMsg = VirtualChannelFundingProposalMsg.toJSON( + message.virtualChannelFundingProposalMsg, + ); } if (message.virtualChannelSettlementProposalMsg !== undefined) { - obj.virtualChannelSettlementProposalMsg = - VirtualChannelSettlementProposalMsg.toJSON( - message.virtualChannelSettlementProposalMsg, - ); + obj.virtualChannelSettlementProposalMsg = VirtualChannelSettlementProposalMsg.toJSON( + message.virtualChannelSettlementProposalMsg, + ); } if (message.channelUpdateAccMsg !== undefined) { - obj.channelUpdateAccMsg = ChannelUpdateAccMsg.toJSON( - message.channelUpdateAccMsg, - ); + obj.channelUpdateAccMsg = ChannelUpdateAccMsg.toJSON(message.channelUpdateAccMsg); } if (message.channelUpdateRejMsg !== undefined) { - obj.channelUpdateRejMsg = ChannelUpdateRejMsg.toJSON( - message.channelUpdateRejMsg, - ); + obj.channelUpdateRejMsg = ChannelUpdateRejMsg.toJSON(message.channelUpdateRejMsg); } if (message.channelSyncMsg !== undefined) { obj.channelSyncMsg = ChannelSyncMsg.toJSON(message.channelSyncMsg); @@ -725,95 +596,66 @@ export const Envelope = { const message = createBaseEnvelope(); message.sender = object.sender ?? new Uint8Array(0); message.recipient = object.recipient ?? new Uint8Array(0); - message.pingMsg = - object.pingMsg !== undefined && object.pingMsg !== null - ? PingMsg.fromPartial(object.pingMsg) - : undefined; - message.pongMsg = - object.pongMsg !== undefined && object.pongMsg !== null - ? PongMsg.fromPartial(object.pongMsg) - : undefined; - message.shutdownMsg = - object.shutdownMsg !== undefined && object.shutdownMsg !== null - ? ShutdownMsg.fromPartial(object.shutdownMsg) - : undefined; - message.authResponseMsg = - object.authResponseMsg !== undefined && object.authResponseMsg !== null - ? AuthResponseMsg.fromPartial(object.authResponseMsg) - : undefined; + message.pingMsg = (object.pingMsg !== undefined && object.pingMsg !== null) + ? PingMsg.fromPartial(object.pingMsg) + : undefined; + message.pongMsg = (object.pongMsg !== undefined && object.pongMsg !== null) + ? PongMsg.fromPartial(object.pongMsg) + : undefined; + message.shutdownMsg = (object.shutdownMsg !== undefined && object.shutdownMsg !== null) + ? ShutdownMsg.fromPartial(object.shutdownMsg) + : undefined; + message.authResponseMsg = (object.authResponseMsg !== undefined && object.authResponseMsg !== null) + ? AuthResponseMsg.fromPartial(object.authResponseMsg) + : undefined; message.ledgerChannelProposalMsg = - object.ledgerChannelProposalMsg !== undefined && - object.ledgerChannelProposalMsg !== null + (object.ledgerChannelProposalMsg !== undefined && object.ledgerChannelProposalMsg !== null) ? LedgerChannelProposalMsg.fromPartial(object.ledgerChannelProposalMsg) : undefined; message.ledgerChannelProposalAccMsg = - object.ledgerChannelProposalAccMsg !== undefined && - object.ledgerChannelProposalAccMsg !== null - ? LedgerChannelProposalAccMsg.fromPartial( - object.ledgerChannelProposalAccMsg, - ) + (object.ledgerChannelProposalAccMsg !== undefined && object.ledgerChannelProposalAccMsg !== null) + ? LedgerChannelProposalAccMsg.fromPartial(object.ledgerChannelProposalAccMsg) : undefined; message.subChannelProposalMsg = - object.subChannelProposalMsg !== undefined && - object.subChannelProposalMsg !== null + (object.subChannelProposalMsg !== undefined && object.subChannelProposalMsg !== null) ? SubChannelProposalMsg.fromPartial(object.subChannelProposalMsg) : undefined; message.subChannelProposalAccMsg = - object.subChannelProposalAccMsg !== undefined && - object.subChannelProposalAccMsg !== null + (object.subChannelProposalAccMsg !== undefined && object.subChannelProposalAccMsg !== null) ? SubChannelProposalAccMsg.fromPartial(object.subChannelProposalAccMsg) : undefined; message.virtualChannelProposalMsg = - object.virtualChannelProposalMsg !== undefined && - object.virtualChannelProposalMsg !== null - ? VirtualChannelProposalMsg.fromPartial( - object.virtualChannelProposalMsg, - ) + (object.virtualChannelProposalMsg !== undefined && object.virtualChannelProposalMsg !== null) + ? VirtualChannelProposalMsg.fromPartial(object.virtualChannelProposalMsg) : undefined; message.virtualChannelProposalAccMsg = - object.virtualChannelProposalAccMsg !== undefined && - object.virtualChannelProposalAccMsg !== null - ? VirtualChannelProposalAccMsg.fromPartial( - object.virtualChannelProposalAccMsg, - ) + (object.virtualChannelProposalAccMsg !== undefined && object.virtualChannelProposalAccMsg !== null) + ? VirtualChannelProposalAccMsg.fromPartial(object.virtualChannelProposalAccMsg) : undefined; message.channelProposalRejMsg = - object.channelProposalRejMsg !== undefined && - object.channelProposalRejMsg !== null + (object.channelProposalRejMsg !== undefined && object.channelProposalRejMsg !== null) ? ChannelProposalRejMsg.fromPartial(object.channelProposalRejMsg) : undefined; - message.channelUpdateMsg = - object.channelUpdateMsg !== undefined && object.channelUpdateMsg !== null - ? ChannelUpdateMsg.fromPartial(object.channelUpdateMsg) - : undefined; + message.channelUpdateMsg = (object.channelUpdateMsg !== undefined && object.channelUpdateMsg !== null) + ? ChannelUpdateMsg.fromPartial(object.channelUpdateMsg) + : undefined; message.virtualChannelFundingProposalMsg = - object.virtualChannelFundingProposalMsg !== undefined && - object.virtualChannelFundingProposalMsg !== null - ? VirtualChannelFundingProposalMsg.fromPartial( - object.virtualChannelFundingProposalMsg, - ) + (object.virtualChannelFundingProposalMsg !== undefined && object.virtualChannelFundingProposalMsg !== null) + ? VirtualChannelFundingProposalMsg.fromPartial(object.virtualChannelFundingProposalMsg) : undefined; message.virtualChannelSettlementProposalMsg = - object.virtualChannelSettlementProposalMsg !== undefined && - object.virtualChannelSettlementProposalMsg !== null - ? VirtualChannelSettlementProposalMsg.fromPartial( - object.virtualChannelSettlementProposalMsg, - ) - : undefined; - message.channelUpdateAccMsg = - object.channelUpdateAccMsg !== undefined && - object.channelUpdateAccMsg !== null - ? ChannelUpdateAccMsg.fromPartial(object.channelUpdateAccMsg) - : undefined; - message.channelUpdateRejMsg = - object.channelUpdateRejMsg !== undefined && - object.channelUpdateRejMsg !== null - ? ChannelUpdateRejMsg.fromPartial(object.channelUpdateRejMsg) - : undefined; - message.channelSyncMsg = - object.channelSyncMsg !== undefined && object.channelSyncMsg !== null - ? ChannelSyncMsg.fromPartial(object.channelSyncMsg) + (object.virtualChannelSettlementProposalMsg !== undefined && object.virtualChannelSettlementProposalMsg !== null) + ? VirtualChannelSettlementProposalMsg.fromPartial(object.virtualChannelSettlementProposalMsg) : undefined; + message.channelUpdateAccMsg = (object.channelUpdateAccMsg !== undefined && object.channelUpdateAccMsg !== null) + ? ChannelUpdateAccMsg.fromPartial(object.channelUpdateAccMsg) + : undefined; + message.channelUpdateRejMsg = (object.channelUpdateRejMsg !== undefined && object.channelUpdateRejMsg !== null) + ? ChannelUpdateRejMsg.fromPartial(object.channelUpdateRejMsg) + : undefined; + message.channelSyncMsg = (object.channelSyncMsg !== undefined && object.channelSyncMsg !== null) + ? ChannelSyncMsg.fromPartial(object.channelSyncMsg) + : undefined; return message; }, }; @@ -823,10 +665,7 @@ function createBaseBalance(): Balance { } export const Balance = { - encode( - message: Balance, - writer: _m0.Writer = _m0.Writer.create(), - ): _m0.Writer { + encode(message: Balance, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { for (const v of message.balance) { writer.uint32(10).bytes(v!); } @@ -834,8 +673,7 @@ export const Balance = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Balance { - const reader = - input instanceof _m0.Reader ? input : _m0.Reader.create(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBalance(); while (reader.pos < end) { @@ -859,9 +697,7 @@ export const Balance = { fromJSON(object: any): Balance { return { - balance: globalThis.Array.isArray(object?.balance) - ? object.balance.map((e: any) => bytesFromBase64(e)) - : [], + balance: globalThis.Array.isArray(object?.balance) ? object.balance.map((e: any) => bytesFromBase64(e)) : [], }; }, @@ -888,10 +724,7 @@ function createBaseBalances(): Balances { } export const Balances = { - encode( - message: Balances, - writer: _m0.Writer = _m0.Writer.create(), - ): _m0.Writer { + encode(message: Balances, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { for (const v of message.balances) { Balance.encode(v!, writer.uint32(10).fork()).ldelim(); } @@ -899,8 +732,7 @@ export const Balances = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Balances { - const reader = - input instanceof _m0.Reader ? input : _m0.Reader.create(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBalances(); while (reader.pos < end) { @@ -924,9 +756,7 @@ export const Balances = { fromJSON(object: any): Balances { return { - balances: globalThis.Array.isArray(object?.balances) - ? object.balances.map((e: any) => Balance.fromJSON(e)) - : [], + balances: globalThis.Array.isArray(object?.balances) ? object.balances.map((e: any) => Balance.fromJSON(e)) : [], }; }, @@ -943,8 +773,7 @@ export const Balances = { }, fromPartial(object: DeepPartial): Balances { const message = createBaseBalances(); - message.balances = - object.balances?.map((e) => Balance.fromPartial(e)) || []; + message.balances = object.balances?.map((e) => Balance.fromPartial(e)) || []; return message; }, }; @@ -954,10 +783,7 @@ function createBaseIndexMap(): IndexMap { } export const IndexMap = { - encode( - message: IndexMap, - writer: _m0.Writer = _m0.Writer.create(), - ): _m0.Writer { + encode(message: IndexMap, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { writer.uint32(10).fork(); for (const v of message.indexMap) { writer.uint32(v); @@ -967,8 +793,7 @@ export const IndexMap = { }, decode(input: _m0.Reader | Uint8Array, length?: number): IndexMap { - const reader = - input instanceof _m0.Reader ? input : _m0.Reader.create(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseIndexMap(); while (reader.pos < end) { @@ -1002,9 +827,7 @@ export const IndexMap = { fromJSON(object: any): IndexMap { return { - indexMap: globalThis.Array.isArray(object?.indexMap) - ? object.indexMap.map((e: any) => globalThis.Number(e)) - : [], + indexMap: globalThis.Array.isArray(object?.indexMap) ? object.indexMap.map((e: any) => globalThis.Number(e)) : [], }; }, @@ -1031,10 +854,7 @@ function createBaseSubAlloc(): SubAlloc { } export const SubAlloc = { - encode( - message: SubAlloc, - writer: _m0.Writer = _m0.Writer.create(), - ): _m0.Writer { + encode(message: SubAlloc, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.id.length !== 0) { writer.uint32(10).bytes(message.id); } @@ -1048,8 +868,7 @@ export const SubAlloc = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SubAlloc { - const reader = - input instanceof _m0.Reader ? input : _m0.Reader.create(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSubAlloc(); while (reader.pos < end) { @@ -1089,9 +908,7 @@ export const SubAlloc = { return { id: isSet(object.id) ? bytesFromBase64(object.id) : new Uint8Array(0), bals: isSet(object.bals) ? Balance.fromJSON(object.bals) : undefined, - indexMap: isSet(object.indexMap) - ? IndexMap.fromJSON(object.indexMap) - : undefined, + indexMap: isSet(object.indexMap) ? IndexMap.fromJSON(object.indexMap) : undefined, }; }, @@ -1115,14 +932,10 @@ export const SubAlloc = { fromPartial(object: DeepPartial): SubAlloc { const message = createBaseSubAlloc(); message.id = object.id ?? new Uint8Array(0); - message.bals = - object.bals !== undefined && object.bals !== null - ? Balance.fromPartial(object.bals) - : undefined; - message.indexMap = - object.indexMap !== undefined && object.indexMap !== null - ? IndexMap.fromPartial(object.indexMap) - : undefined; + message.bals = (object.bals !== undefined && object.bals !== null) ? Balance.fromPartial(object.bals) : undefined; + message.indexMap = (object.indexMap !== undefined && object.indexMap !== null) + ? IndexMap.fromPartial(object.indexMap) + : undefined; return message; }, }; @@ -1132,10 +945,7 @@ function createBaseAllocation(): Allocation { } export const Allocation = { - encode( - message: Allocation, - writer: _m0.Writer = _m0.Writer.create(), - ): _m0.Writer { + encode(message: Allocation, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { for (const v of message.assets) { writer.uint32(10).bytes(v!); } @@ -1149,8 +959,7 @@ export const Allocation = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Allocation { - const reader = - input instanceof _m0.Reader ? input : _m0.Reader.create(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseAllocation(); while (reader.pos < end) { @@ -1188,15 +997,9 @@ export const Allocation = { fromJSON(object: any): Allocation { return { - assets: globalThis.Array.isArray(object?.assets) - ? object.assets.map((e: any) => bytesFromBase64(e)) - : [], - balances: isSet(object.balances) - ? Balances.fromJSON(object.balances) - : undefined, - locked: globalThis.Array.isArray(object?.locked) - ? object.locked.map((e: any) => SubAlloc.fromJSON(e)) - : [], + assets: globalThis.Array.isArray(object?.assets) ? object.assets.map((e: any) => bytesFromBase64(e)) : [], + balances: isSet(object.balances) ? Balances.fromJSON(object.balances) : undefined, + locked: globalThis.Array.isArray(object?.locked) ? object.locked.map((e: any) => SubAlloc.fromJSON(e)) : [], }; }, @@ -1220,10 +1023,9 @@ export const Allocation = { fromPartial(object: DeepPartial): Allocation { const message = createBaseAllocation(); message.assets = object.assets?.map((e) => e) || []; - message.balances = - object.balances !== undefined && object.balances !== null - ? Balances.fromPartial(object.balances) - : undefined; + message.balances = (object.balances !== undefined && object.balances !== null) + ? Balances.fromPartial(object.balances) + : undefined; message.locked = object.locked?.map((e) => SubAlloc.fromPartial(e)) || []; return message; }, @@ -1242,10 +1044,7 @@ function createBaseBaseChannelProposal(): BaseChannelProposal { } export const BaseChannelProposal = { - encode( - message: BaseChannelProposal, - writer: _m0.Writer = _m0.Writer.create(), - ): _m0.Writer { + encode(message: BaseChannelProposal, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.proposalId.length !== 0) { writer.uint32(10).bytes(message.proposalId); } @@ -1265,17 +1064,13 @@ export const BaseChannelProposal = { Allocation.encode(message.initBals, writer.uint32(50).fork()).ldelim(); } if (message.fundingAgreement !== undefined) { - Balances.encode( - message.fundingAgreement, - writer.uint32(58).fork(), - ).ldelim(); + Balances.encode(message.fundingAgreement, writer.uint32(58).fork()).ldelim(); } return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): BaseChannelProposal { - const reader = - input instanceof _m0.Reader ? input : _m0.Reader.create(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBaseChannelProposal(); while (reader.pos < end) { @@ -1341,25 +1136,13 @@ export const BaseChannelProposal = { fromJSON(object: any): BaseChannelProposal { return { - proposalId: isSet(object.proposalId) - ? bytesFromBase64(object.proposalId) - : new Uint8Array(0), - challengeDuration: isSet(object.challengeDuration) - ? globalThis.Number(object.challengeDuration) - : 0, - nonceShare: isSet(object.nonceShare) - ? bytesFromBase64(object.nonceShare) - : new Uint8Array(0), + proposalId: isSet(object.proposalId) ? bytesFromBase64(object.proposalId) : new Uint8Array(0), + challengeDuration: isSet(object.challengeDuration) ? globalThis.Number(object.challengeDuration) : 0, + nonceShare: isSet(object.nonceShare) ? bytesFromBase64(object.nonceShare) : new Uint8Array(0), app: isSet(object.app) ? bytesFromBase64(object.app) : new Uint8Array(0), - initData: isSet(object.initData) - ? bytesFromBase64(object.initData) - : new Uint8Array(0), - initBals: isSet(object.initBals) - ? Allocation.fromJSON(object.initBals) - : undefined, - fundingAgreement: isSet(object.fundingAgreement) - ? Balances.fromJSON(object.fundingAgreement) - : undefined, + initData: isSet(object.initData) ? bytesFromBase64(object.initData) : new Uint8Array(0), + initBals: isSet(object.initBals) ? Allocation.fromJSON(object.initBals) : undefined, + fundingAgreement: isSet(object.fundingAgreement) ? Balances.fromJSON(object.fundingAgreement) : undefined, }; }, @@ -1399,14 +1182,12 @@ export const BaseChannelProposal = { message.nonceShare = object.nonceShare ?? new Uint8Array(0); message.app = object.app ?? new Uint8Array(0); message.initData = object.initData ?? new Uint8Array(0); - message.initBals = - object.initBals !== undefined && object.initBals !== null - ? Allocation.fromPartial(object.initBals) - : undefined; - message.fundingAgreement = - object.fundingAgreement !== undefined && object.fundingAgreement !== null - ? Balances.fromPartial(object.fundingAgreement) - : undefined; + message.initBals = (object.initBals !== undefined && object.initBals !== null) + ? Allocation.fromPartial(object.initBals) + : undefined; + message.fundingAgreement = (object.fundingAgreement !== undefined && object.fundingAgreement !== null) + ? Balances.fromPartial(object.fundingAgreement) + : undefined; return message; }, }; @@ -1416,10 +1197,7 @@ function createBaseBaseChannelProposalAcc(): BaseChannelProposalAcc { } export const BaseChannelProposalAcc = { - encode( - message: BaseChannelProposalAcc, - writer: _m0.Writer = _m0.Writer.create(), - ): _m0.Writer { + encode(message: BaseChannelProposalAcc, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.proposalId.length !== 0) { writer.uint32(10).bytes(message.proposalId); } @@ -1429,12 +1207,8 @@ export const BaseChannelProposalAcc = { return writer; }, - decode( - input: _m0.Reader | Uint8Array, - length?: number, - ): BaseChannelProposalAcc { - const reader = - input instanceof _m0.Reader ? input : _m0.Reader.create(input); + decode(input: _m0.Reader | Uint8Array, length?: number): BaseChannelProposalAcc { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBaseChannelProposalAcc(); while (reader.pos < end) { @@ -1465,12 +1239,8 @@ export const BaseChannelProposalAcc = { fromJSON(object: any): BaseChannelProposalAcc { return { - proposalId: isSet(object.proposalId) - ? bytesFromBase64(object.proposalId) - : new Uint8Array(0), - nonceShare: isSet(object.nonceShare) - ? bytesFromBase64(object.nonceShare) - : new Uint8Array(0), + proposalId: isSet(object.proposalId) ? bytesFromBase64(object.proposalId) : new Uint8Array(0), + nonceShare: isSet(object.nonceShare) ? bytesFromBase64(object.nonceShare) : new Uint8Array(0), }; }, @@ -1488,9 +1258,7 @@ export const BaseChannelProposalAcc = { create(base?: DeepPartial): BaseChannelProposalAcc { return BaseChannelProposalAcc.fromPartial(base ?? {}); }, - fromPartial( - object: DeepPartial, - ): BaseChannelProposalAcc { + fromPartial(object: DeepPartial): BaseChannelProposalAcc { const message = createBaseBaseChannelProposalAcc(); message.proposalId = object.proposalId ?? new Uint8Array(0); message.nonceShare = object.nonceShare ?? new Uint8Array(0); @@ -1511,10 +1279,7 @@ function createBaseParams(): Params { } export const Params = { - encode( - message: Params, - writer: _m0.Writer = _m0.Writer.create(), - ): _m0.Writer { + encode(message: Params, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.id.length !== 0) { writer.uint32(10).bytes(message.id); } @@ -1540,8 +1305,7 @@ export const Params = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Params { - const reader = - input instanceof _m0.Reader ? input : _m0.Reader.create(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseParams(); while (reader.pos < end) { @@ -1608,22 +1372,12 @@ export const Params = { fromJSON(object: any): Params { return { id: isSet(object.id) ? bytesFromBase64(object.id) : new Uint8Array(0), - challengeDuration: isSet(object.challengeDuration) - ? globalThis.Number(object.challengeDuration) - : 0, - parts: globalThis.Array.isArray(object?.parts) - ? object.parts.map((e: any) => bytesFromBase64(e)) - : [], + challengeDuration: isSet(object.challengeDuration) ? globalThis.Number(object.challengeDuration) : 0, + parts: globalThis.Array.isArray(object?.parts) ? object.parts.map((e: any) => bytesFromBase64(e)) : [], app: isSet(object.app) ? bytesFromBase64(object.app) : new Uint8Array(0), - nonce: isSet(object.nonce) - ? bytesFromBase64(object.nonce) - : new Uint8Array(0), - ledgerChannel: isSet(object.ledgerChannel) - ? globalThis.Boolean(object.ledgerChannel) - : false, - virtualChannel: isSet(object.virtualChannel) - ? globalThis.Boolean(object.virtualChannel) - : false, + nonce: isSet(object.nonce) ? bytesFromBase64(object.nonce) : new Uint8Array(0), + ledgerChannel: isSet(object.ledgerChannel) ? globalThis.Boolean(object.ledgerChannel) : false, + virtualChannel: isSet(object.virtualChannel) ? globalThis.Boolean(object.virtualChannel) : false, }; }, @@ -1704,8 +1458,7 @@ export const State = { }, decode(input: _m0.Reader | Uint8Array, length?: number): State { - const reader = - input instanceof _m0.Reader ? input : _m0.Reader.create(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseState(); while (reader.pos < end) { @@ -1767,15 +1520,9 @@ export const State = { id: isSet(object.id) ? bytesFromBase64(object.id) : new Uint8Array(0), version: isSet(object.version) ? globalThis.Number(object.version) : 0, app: isSet(object.app) ? bytesFromBase64(object.app) : new Uint8Array(0), - allocation: isSet(object.allocation) - ? Allocation.fromJSON(object.allocation) - : undefined, - data: isSet(object.data) - ? bytesFromBase64(object.data) - : new Uint8Array(0), - isFinal: isSet(object.isFinal) - ? globalThis.Boolean(object.isFinal) - : false, + allocation: isSet(object.allocation) ? Allocation.fromJSON(object.allocation) : undefined, + data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(0), + isFinal: isSet(object.isFinal) ? globalThis.Boolean(object.isFinal) : false, }; }, @@ -1810,10 +1557,9 @@ export const State = { message.id = object.id ?? new Uint8Array(0); message.version = object.version ?? 0; message.app = object.app ?? new Uint8Array(0); - message.allocation = - object.allocation !== undefined && object.allocation !== null - ? Allocation.fromPartial(object.allocation) - : undefined; + message.allocation = (object.allocation !== undefined && object.allocation !== null) + ? Allocation.fromPartial(object.allocation) + : undefined; message.data = object.data ?? new Uint8Array(0); message.isFinal = object.isFinal ?? false; return message; @@ -1825,10 +1571,7 @@ function createBaseTransaction(): Transaction { } export const Transaction = { - encode( - message: Transaction, - writer: _m0.Writer = _m0.Writer.create(), - ): _m0.Writer { + encode(message: Transaction, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.state !== undefined) { State.encode(message.state, writer.uint32(10).fork()).ldelim(); } @@ -1839,8 +1582,7 @@ export const Transaction = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Transaction { - const reader = - input instanceof _m0.Reader ? input : _m0.Reader.create(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTransaction(); while (reader.pos < end) { @@ -1872,9 +1614,7 @@ export const Transaction = { fromJSON(object: any): Transaction { return { state: isSet(object.state) ? State.fromJSON(object.state) : undefined, - sigs: globalThis.Array.isArray(object?.sigs) - ? object.sigs.map((e: any) => bytesFromBase64(e)) - : [], + sigs: globalThis.Array.isArray(object?.sigs) ? object.sigs.map((e: any) => bytesFromBase64(e)) : [], }; }, @@ -1894,10 +1634,7 @@ export const Transaction = { }, fromPartial(object: DeepPartial): Transaction { const message = createBaseTransaction(); - message.state = - object.state !== undefined && object.state !== null - ? State.fromPartial(object.state) - : undefined; + message.state = (object.state !== undefined && object.state !== null) ? State.fromPartial(object.state) : undefined; message.sigs = object.sigs?.map((e) => e) || []; return message; }, @@ -1908,10 +1645,7 @@ function createBaseSignedState(): SignedState { } export const SignedState = { - encode( - message: SignedState, - writer: _m0.Writer = _m0.Writer.create(), - ): _m0.Writer { + encode(message: SignedState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.params !== undefined) { Params.encode(message.params, writer.uint32(10).fork()).ldelim(); } @@ -1925,8 +1659,7 @@ export const SignedState = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SignedState { - const reader = - input instanceof _m0.Reader ? input : _m0.Reader.create(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSignedState(); while (reader.pos < end) { @@ -1966,9 +1699,7 @@ export const SignedState = { return { params: isSet(object.params) ? Params.fromJSON(object.params) : undefined, state: isSet(object.state) ? State.fromJSON(object.state) : undefined, - sigs: globalThis.Array.isArray(object?.sigs) - ? object.sigs.map((e: any) => bytesFromBase64(e)) - : [], + sigs: globalThis.Array.isArray(object?.sigs) ? object.sigs.map((e: any) => bytesFromBase64(e)) : [], }; }, @@ -1991,14 +1722,10 @@ export const SignedState = { }, fromPartial(object: DeepPartial): SignedState { const message = createBaseSignedState(); - message.params = - object.params !== undefined && object.params !== null - ? Params.fromPartial(object.params) - : undefined; - message.state = - object.state !== undefined && object.state !== null - ? State.fromPartial(object.state) - : undefined; + message.params = (object.params !== undefined && object.params !== null) + ? Params.fromPartial(object.params) + : undefined; + message.state = (object.state !== undefined && object.state !== null) ? State.fromPartial(object.state) : undefined; message.sigs = object.sigs?.map((e) => e) || []; return message; }, @@ -2009,10 +1736,7 @@ function createBaseChannelUpdate(): ChannelUpdate { } export const ChannelUpdate = { - encode( - message: ChannelUpdate, - writer: _m0.Writer = _m0.Writer.create(), - ): _m0.Writer { + encode(message: ChannelUpdate, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.state !== undefined) { State.encode(message.state, writer.uint32(10).fork()).ldelim(); } @@ -2023,8 +1747,7 @@ export const ChannelUpdate = { }, decode(input: _m0.Reader | Uint8Array, length?: number): ChannelUpdate { - const reader = - input instanceof _m0.Reader ? input : _m0.Reader.create(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseChannelUpdate(); while (reader.pos < end) { @@ -2076,10 +1799,7 @@ export const ChannelUpdate = { }, fromPartial(object: DeepPartial): ChannelUpdate { const message = createBaseChannelUpdate(); - message.state = - object.state !== undefined && object.state !== null - ? State.fromPartial(object.state) - : undefined; + message.state = (object.state !== undefined && object.state !== null) ? State.fromPartial(object.state) : undefined; message.actorIdx = object.actorIdx ?? 0; return message; }, @@ -2090,10 +1810,7 @@ function createBasePingMsg(): PingMsg { } export const PingMsg = { - encode( - message: PingMsg, - writer: _m0.Writer = _m0.Writer.create(), - ): _m0.Writer { + encode(message: PingMsg, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.created !== 0) { writer.uint32(8).int64(message.created); } @@ -2101,8 +1818,7 @@ export const PingMsg = { }, decode(input: _m0.Reader | Uint8Array, length?: number): PingMsg { - const reader = - input instanceof _m0.Reader ? input : _m0.Reader.create(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBasePingMsg(); while (reader.pos < end) { @@ -2125,9 +1841,7 @@ export const PingMsg = { }, fromJSON(object: any): PingMsg { - return { - created: isSet(object.created) ? globalThis.Number(object.created) : 0, - }; + return { created: isSet(object.created) ? globalThis.Number(object.created) : 0 }; }, toJSON(message: PingMsg): unknown { @@ -2153,10 +1867,7 @@ function createBasePongMsg(): PongMsg { } export const PongMsg = { - encode( - message: PongMsg, - writer: _m0.Writer = _m0.Writer.create(), - ): _m0.Writer { + encode(message: PongMsg, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.created !== 0) { writer.uint32(8).int64(message.created); } @@ -2164,8 +1875,7 @@ export const PongMsg = { }, decode(input: _m0.Reader | Uint8Array, length?: number): PongMsg { - const reader = - input instanceof _m0.Reader ? input : _m0.Reader.create(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBasePongMsg(); while (reader.pos < end) { @@ -2188,9 +1898,7 @@ export const PongMsg = { }, fromJSON(object: any): PongMsg { - return { - created: isSet(object.created) ? globalThis.Number(object.created) : 0, - }; + return { created: isSet(object.created) ? globalThis.Number(object.created) : 0 }; }, toJSON(message: PongMsg): unknown { @@ -2216,10 +1924,7 @@ function createBaseShutdownMsg(): ShutdownMsg { } export const ShutdownMsg = { - encode( - message: ShutdownMsg, - writer: _m0.Writer = _m0.Writer.create(), - ): _m0.Writer { + encode(message: ShutdownMsg, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.reason !== "") { writer.uint32(10).string(message.reason); } @@ -2227,8 +1932,7 @@ export const ShutdownMsg = { }, decode(input: _m0.Reader | Uint8Array, length?: number): ShutdownMsg { - const reader = - input instanceof _m0.Reader ? input : _m0.Reader.create(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseShutdownMsg(); while (reader.pos < end) { @@ -2251,9 +1955,7 @@ export const ShutdownMsg = { }, fromJSON(object: any): ShutdownMsg { - return { - reason: isSet(object.reason) ? globalThis.String(object.reason) : "", - }; + return { reason: isSet(object.reason) ? globalThis.String(object.reason) : "" }; }, toJSON(message: ShutdownMsg): unknown { @@ -2279,16 +1981,12 @@ function createBaseAuthResponseMsg(): AuthResponseMsg { } export const AuthResponseMsg = { - encode( - _: AuthResponseMsg, - writer: _m0.Writer = _m0.Writer.create(), - ): _m0.Writer { + encode(_: AuthResponseMsg, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): AuthResponseMsg { - const reader = - input instanceof _m0.Reader ? input : _m0.Reader.create(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseAuthResponseMsg(); while (reader.pos < end) { @@ -2322,23 +2020,13 @@ export const AuthResponseMsg = { }; function createBaseLedgerChannelProposalMsg(): LedgerChannelProposalMsg { - return { - baseChannelProposal: undefined, - participant: new Uint8Array(0), - peers: [], - }; + return { baseChannelProposal: undefined, participant: new Uint8Array(0), peers: [] }; } export const LedgerChannelProposalMsg = { - encode( - message: LedgerChannelProposalMsg, - writer: _m0.Writer = _m0.Writer.create(), - ): _m0.Writer { + encode(message: LedgerChannelProposalMsg, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.baseChannelProposal !== undefined) { - BaseChannelProposal.encode( - message.baseChannelProposal, - writer.uint32(10).fork(), - ).ldelim(); + BaseChannelProposal.encode(message.baseChannelProposal, writer.uint32(10).fork()).ldelim(); } if (message.participant.length !== 0) { writer.uint32(18).bytes(message.participant); @@ -2349,12 +2037,8 @@ export const LedgerChannelProposalMsg = { return writer; }, - decode( - input: _m0.Reader | Uint8Array, - length?: number, - ): LedgerChannelProposalMsg { - const reader = - input instanceof _m0.Reader ? input : _m0.Reader.create(input); + decode(input: _m0.Reader | Uint8Array, length?: number): LedgerChannelProposalMsg { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseLedgerChannelProposalMsg(); while (reader.pos < end) { @@ -2365,10 +2049,7 @@ export const LedgerChannelProposalMsg = { break; } - message.baseChannelProposal = BaseChannelProposal.decode( - reader, - reader.uint32(), - ); + message.baseChannelProposal = BaseChannelProposal.decode(reader, reader.uint32()); continue; case 2: if (tag !== 18) { @@ -2398,21 +2079,15 @@ export const LedgerChannelProposalMsg = { baseChannelProposal: isSet(object.baseChannelProposal) ? BaseChannelProposal.fromJSON(object.baseChannelProposal) : undefined, - participant: isSet(object.participant) - ? bytesFromBase64(object.participant) - : new Uint8Array(0), - peers: globalThis.Array.isArray(object?.peers) - ? object.peers.map((e: any) => bytesFromBase64(e)) - : [], + participant: isSet(object.participant) ? bytesFromBase64(object.participant) : new Uint8Array(0), + peers: globalThis.Array.isArray(object?.peers) ? object.peers.map((e: any) => bytesFromBase64(e)) : [], }; }, toJSON(message: LedgerChannelProposalMsg): unknown { const obj: any = {}; if (message.baseChannelProposal !== undefined) { - obj.baseChannelProposal = BaseChannelProposal.toJSON( - message.baseChannelProposal, - ); + obj.baseChannelProposal = BaseChannelProposal.toJSON(message.baseChannelProposal); } if (message.participant.length !== 0) { obj.participant = base64FromBytes(message.participant); @@ -2423,20 +2098,14 @@ export const LedgerChannelProposalMsg = { return obj; }, - create( - base?: DeepPartial, - ): LedgerChannelProposalMsg { + create(base?: DeepPartial): LedgerChannelProposalMsg { return LedgerChannelProposalMsg.fromPartial(base ?? {}); }, - fromPartial( - object: DeepPartial, - ): LedgerChannelProposalMsg { + fromPartial(object: DeepPartial): LedgerChannelProposalMsg { const message = createBaseLedgerChannelProposalMsg(); - message.baseChannelProposal = - object.baseChannelProposal !== undefined && - object.baseChannelProposal !== null - ? BaseChannelProposal.fromPartial(object.baseChannelProposal) - : undefined; + message.baseChannelProposal = (object.baseChannelProposal !== undefined && object.baseChannelProposal !== null) + ? BaseChannelProposal.fromPartial(object.baseChannelProposal) + : undefined; message.participant = object.participant ?? new Uint8Array(0); message.peers = object.peers?.map((e) => e) || []; return message; @@ -2448,15 +2117,9 @@ function createBaseLedgerChannelProposalAccMsg(): LedgerChannelProposalAccMsg { } export const LedgerChannelProposalAccMsg = { - encode( - message: LedgerChannelProposalAccMsg, - writer: _m0.Writer = _m0.Writer.create(), - ): _m0.Writer { + encode(message: LedgerChannelProposalAccMsg, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.baseChannelProposalAcc !== undefined) { - BaseChannelProposalAcc.encode( - message.baseChannelProposalAcc, - writer.uint32(10).fork(), - ).ldelim(); + BaseChannelProposalAcc.encode(message.baseChannelProposalAcc, writer.uint32(10).fork()).ldelim(); } if (message.participant.length !== 0) { writer.uint32(18).bytes(message.participant); @@ -2464,12 +2127,8 @@ export const LedgerChannelProposalAccMsg = { return writer; }, - decode( - input: _m0.Reader | Uint8Array, - length?: number, - ): LedgerChannelProposalAccMsg { - const reader = - input instanceof _m0.Reader ? input : _m0.Reader.create(input); + decode(input: _m0.Reader | Uint8Array, length?: number): LedgerChannelProposalAccMsg { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseLedgerChannelProposalAccMsg(); while (reader.pos < end) { @@ -2480,10 +2139,7 @@ export const LedgerChannelProposalAccMsg = { break; } - message.baseChannelProposalAcc = BaseChannelProposalAcc.decode( - reader, - reader.uint32(), - ); + message.baseChannelProposalAcc = BaseChannelProposalAcc.decode(reader, reader.uint32()); continue; case 2: if (tag !== 18) { @@ -2506,18 +2162,14 @@ export const LedgerChannelProposalAccMsg = { baseChannelProposalAcc: isSet(object.baseChannelProposalAcc) ? BaseChannelProposalAcc.fromJSON(object.baseChannelProposalAcc) : undefined, - participant: isSet(object.participant) - ? bytesFromBase64(object.participant) - : new Uint8Array(0), + participant: isSet(object.participant) ? bytesFromBase64(object.participant) : new Uint8Array(0), }; }, toJSON(message: LedgerChannelProposalAccMsg): unknown { const obj: any = {}; if (message.baseChannelProposalAcc !== undefined) { - obj.baseChannelProposalAcc = BaseChannelProposalAcc.toJSON( - message.baseChannelProposalAcc, - ); + obj.baseChannelProposalAcc = BaseChannelProposalAcc.toJSON(message.baseChannelProposalAcc); } if (message.participant.length !== 0) { obj.participant = base64FromBytes(message.participant); @@ -2525,18 +2177,13 @@ export const LedgerChannelProposalAccMsg = { return obj; }, - create( - base?: DeepPartial, - ): LedgerChannelProposalAccMsg { + create(base?: DeepPartial): LedgerChannelProposalAccMsg { return LedgerChannelProposalAccMsg.fromPartial(base ?? {}); }, - fromPartial( - object: DeepPartial, - ): LedgerChannelProposalAccMsg { + fromPartial(object: DeepPartial): LedgerChannelProposalAccMsg { const message = createBaseLedgerChannelProposalAccMsg(); message.baseChannelProposalAcc = - object.baseChannelProposalAcc !== undefined && - object.baseChannelProposalAcc !== null + (object.baseChannelProposalAcc !== undefined && object.baseChannelProposalAcc !== null) ? BaseChannelProposalAcc.fromPartial(object.baseChannelProposalAcc) : undefined; message.participant = object.participant ?? new Uint8Array(0); @@ -2549,15 +2196,9 @@ function createBaseSubChannelProposalMsg(): SubChannelProposalMsg { } export const SubChannelProposalMsg = { - encode( - message: SubChannelProposalMsg, - writer: _m0.Writer = _m0.Writer.create(), - ): _m0.Writer { + encode(message: SubChannelProposalMsg, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.baseChannelProposal !== undefined) { - BaseChannelProposal.encode( - message.baseChannelProposal, - writer.uint32(10).fork(), - ).ldelim(); + BaseChannelProposal.encode(message.baseChannelProposal, writer.uint32(10).fork()).ldelim(); } if (message.parent.length !== 0) { writer.uint32(18).bytes(message.parent); @@ -2565,12 +2206,8 @@ export const SubChannelProposalMsg = { return writer; }, - decode( - input: _m0.Reader | Uint8Array, - length?: number, - ): SubChannelProposalMsg { - const reader = - input instanceof _m0.Reader ? input : _m0.Reader.create(input); + decode(input: _m0.Reader | Uint8Array, length?: number): SubChannelProposalMsg { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSubChannelProposalMsg(); while (reader.pos < end) { @@ -2581,10 +2218,7 @@ export const SubChannelProposalMsg = { break; } - message.baseChannelProposal = BaseChannelProposal.decode( - reader, - reader.uint32(), - ); + message.baseChannelProposal = BaseChannelProposal.decode(reader, reader.uint32()); continue; case 2: if (tag !== 18) { @@ -2607,18 +2241,14 @@ export const SubChannelProposalMsg = { baseChannelProposal: isSet(object.baseChannelProposal) ? BaseChannelProposal.fromJSON(object.baseChannelProposal) : undefined, - parent: isSet(object.parent) - ? bytesFromBase64(object.parent) - : new Uint8Array(0), + parent: isSet(object.parent) ? bytesFromBase64(object.parent) : new Uint8Array(0), }; }, toJSON(message: SubChannelProposalMsg): unknown { const obj: any = {}; if (message.baseChannelProposal !== undefined) { - obj.baseChannelProposal = BaseChannelProposal.toJSON( - message.baseChannelProposal, - ); + obj.baseChannelProposal = BaseChannelProposal.toJSON(message.baseChannelProposal); } if (message.parent.length !== 0) { obj.parent = base64FromBytes(message.parent); @@ -2629,15 +2259,11 @@ export const SubChannelProposalMsg = { create(base?: DeepPartial): SubChannelProposalMsg { return SubChannelProposalMsg.fromPartial(base ?? {}); }, - fromPartial( - object: DeepPartial, - ): SubChannelProposalMsg { + fromPartial(object: DeepPartial): SubChannelProposalMsg { const message = createBaseSubChannelProposalMsg(); - message.baseChannelProposal = - object.baseChannelProposal !== undefined && - object.baseChannelProposal !== null - ? BaseChannelProposal.fromPartial(object.baseChannelProposal) - : undefined; + message.baseChannelProposal = (object.baseChannelProposal !== undefined && object.baseChannelProposal !== null) + ? BaseChannelProposal.fromPartial(object.baseChannelProposal) + : undefined; message.parent = object.parent ?? new Uint8Array(0); return message; }, @@ -2648,25 +2274,15 @@ function createBaseSubChannelProposalAccMsg(): SubChannelProposalAccMsg { } export const SubChannelProposalAccMsg = { - encode( - message: SubChannelProposalAccMsg, - writer: _m0.Writer = _m0.Writer.create(), - ): _m0.Writer { + encode(message: SubChannelProposalAccMsg, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.baseChannelProposalAcc !== undefined) { - BaseChannelProposalAcc.encode( - message.baseChannelProposalAcc, - writer.uint32(10).fork(), - ).ldelim(); + BaseChannelProposalAcc.encode(message.baseChannelProposalAcc, writer.uint32(10).fork()).ldelim(); } return writer; }, - decode( - input: _m0.Reader | Uint8Array, - length?: number, - ): SubChannelProposalAccMsg { - const reader = - input instanceof _m0.Reader ? input : _m0.Reader.create(input); + decode(input: _m0.Reader | Uint8Array, length?: number): SubChannelProposalAccMsg { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSubChannelProposalAccMsg(); while (reader.pos < end) { @@ -2677,10 +2293,7 @@ export const SubChannelProposalAccMsg = { break; } - message.baseChannelProposalAcc = BaseChannelProposalAcc.decode( - reader, - reader.uint32(), - ); + message.baseChannelProposalAcc = BaseChannelProposalAcc.decode(reader, reader.uint32()); continue; } if ((tag & 7) === 4 || tag === 0) { @@ -2702,25 +2315,18 @@ export const SubChannelProposalAccMsg = { toJSON(message: SubChannelProposalAccMsg): unknown { const obj: any = {}; if (message.baseChannelProposalAcc !== undefined) { - obj.baseChannelProposalAcc = BaseChannelProposalAcc.toJSON( - message.baseChannelProposalAcc, - ); + obj.baseChannelProposalAcc = BaseChannelProposalAcc.toJSON(message.baseChannelProposalAcc); } return obj; }, - create( - base?: DeepPartial, - ): SubChannelProposalAccMsg { + create(base?: DeepPartial): SubChannelProposalAccMsg { return SubChannelProposalAccMsg.fromPartial(base ?? {}); }, - fromPartial( - object: DeepPartial, - ): SubChannelProposalAccMsg { + fromPartial(object: DeepPartial): SubChannelProposalAccMsg { const message = createBaseSubChannelProposalAccMsg(); message.baseChannelProposalAcc = - object.baseChannelProposalAcc !== undefined && - object.baseChannelProposalAcc !== null + (object.baseChannelProposalAcc !== undefined && object.baseChannelProposalAcc !== null) ? BaseChannelProposalAcc.fromPartial(object.baseChannelProposalAcc) : undefined; return message; @@ -2728,25 +2334,13 @@ export const SubChannelProposalAccMsg = { }; function createBaseVirtualChannelProposalMsg(): VirtualChannelProposalMsg { - return { - baseChannelProposal: undefined, - proposer: new Uint8Array(0), - peers: [], - parents: [], - indexMaps: [], - }; + return { baseChannelProposal: undefined, proposer: new Uint8Array(0), peers: [], parents: [], indexMaps: [] }; } export const VirtualChannelProposalMsg = { - encode( - message: VirtualChannelProposalMsg, - writer: _m0.Writer = _m0.Writer.create(), - ): _m0.Writer { + encode(message: VirtualChannelProposalMsg, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.baseChannelProposal !== undefined) { - BaseChannelProposal.encode( - message.baseChannelProposal, - writer.uint32(10).fork(), - ).ldelim(); + BaseChannelProposal.encode(message.baseChannelProposal, writer.uint32(10).fork()).ldelim(); } if (message.proposer.length !== 0) { writer.uint32(18).bytes(message.proposer); @@ -2763,12 +2357,8 @@ export const VirtualChannelProposalMsg = { return writer; }, - decode( - input: _m0.Reader | Uint8Array, - length?: number, - ): VirtualChannelProposalMsg { - const reader = - input instanceof _m0.Reader ? input : _m0.Reader.create(input); + decode(input: _m0.Reader | Uint8Array, length?: number): VirtualChannelProposalMsg { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseVirtualChannelProposalMsg(); while (reader.pos < end) { @@ -2779,10 +2369,7 @@ export const VirtualChannelProposalMsg = { break; } - message.baseChannelProposal = BaseChannelProposal.decode( - reader, - reader.uint32(), - ); + message.baseChannelProposal = BaseChannelProposal.decode(reader, reader.uint32()); continue; case 2: if (tag !== 18) { @@ -2826,15 +2413,9 @@ export const VirtualChannelProposalMsg = { baseChannelProposal: isSet(object.baseChannelProposal) ? BaseChannelProposal.fromJSON(object.baseChannelProposal) : undefined, - proposer: isSet(object.proposer) - ? bytesFromBase64(object.proposer) - : new Uint8Array(0), - peers: globalThis.Array.isArray(object?.peers) - ? object.peers.map((e: any) => bytesFromBase64(e)) - : [], - parents: globalThis.Array.isArray(object?.parents) - ? object.parents.map((e: any) => bytesFromBase64(e)) - : [], + proposer: isSet(object.proposer) ? bytesFromBase64(object.proposer) : new Uint8Array(0), + peers: globalThis.Array.isArray(object?.peers) ? object.peers.map((e: any) => bytesFromBase64(e)) : [], + parents: globalThis.Array.isArray(object?.parents) ? object.parents.map((e: any) => bytesFromBase64(e)) : [], indexMaps: globalThis.Array.isArray(object?.indexMaps) ? object.indexMaps.map((e: any) => IndexMap.fromJSON(e)) : [], @@ -2844,9 +2425,7 @@ export const VirtualChannelProposalMsg = { toJSON(message: VirtualChannelProposalMsg): unknown { const obj: any = {}; if (message.baseChannelProposal !== undefined) { - obj.baseChannelProposal = BaseChannelProposal.toJSON( - message.baseChannelProposal, - ); + obj.baseChannelProposal = BaseChannelProposal.toJSON(message.baseChannelProposal); } if (message.proposer.length !== 0) { obj.proposer = base64FromBytes(message.proposer); @@ -2863,25 +2442,18 @@ export const VirtualChannelProposalMsg = { return obj; }, - create( - base?: DeepPartial, - ): VirtualChannelProposalMsg { + create(base?: DeepPartial): VirtualChannelProposalMsg { return VirtualChannelProposalMsg.fromPartial(base ?? {}); }, - fromPartial( - object: DeepPartial, - ): VirtualChannelProposalMsg { + fromPartial(object: DeepPartial): VirtualChannelProposalMsg { const message = createBaseVirtualChannelProposalMsg(); - message.baseChannelProposal = - object.baseChannelProposal !== undefined && - object.baseChannelProposal !== null - ? BaseChannelProposal.fromPartial(object.baseChannelProposal) - : undefined; + message.baseChannelProposal = (object.baseChannelProposal !== undefined && object.baseChannelProposal !== null) + ? BaseChannelProposal.fromPartial(object.baseChannelProposal) + : undefined; message.proposer = object.proposer ?? new Uint8Array(0); message.peers = object.peers?.map((e) => e) || []; message.parents = object.parents?.map((e) => e) || []; - message.indexMaps = - object.indexMaps?.map((e) => IndexMap.fromPartial(e)) || []; + message.indexMaps = object.indexMaps?.map((e) => IndexMap.fromPartial(e)) || []; return message; }, }; @@ -2891,15 +2463,9 @@ function createBaseVirtualChannelProposalAccMsg(): VirtualChannelProposalAccMsg } export const VirtualChannelProposalAccMsg = { - encode( - message: VirtualChannelProposalAccMsg, - writer: _m0.Writer = _m0.Writer.create(), - ): _m0.Writer { + encode(message: VirtualChannelProposalAccMsg, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.baseChannelProposalAcc !== undefined) { - BaseChannelProposalAcc.encode( - message.baseChannelProposalAcc, - writer.uint32(10).fork(), - ).ldelim(); + BaseChannelProposalAcc.encode(message.baseChannelProposalAcc, writer.uint32(10).fork()).ldelim(); } if (message.responder.length !== 0) { writer.uint32(18).bytes(message.responder); @@ -2907,12 +2473,8 @@ export const VirtualChannelProposalAccMsg = { return writer; }, - decode( - input: _m0.Reader | Uint8Array, - length?: number, - ): VirtualChannelProposalAccMsg { - const reader = - input instanceof _m0.Reader ? input : _m0.Reader.create(input); + decode(input: _m0.Reader | Uint8Array, length?: number): VirtualChannelProposalAccMsg { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseVirtualChannelProposalAccMsg(); while (reader.pos < end) { @@ -2923,10 +2485,7 @@ export const VirtualChannelProposalAccMsg = { break; } - message.baseChannelProposalAcc = BaseChannelProposalAcc.decode( - reader, - reader.uint32(), - ); + message.baseChannelProposalAcc = BaseChannelProposalAcc.decode(reader, reader.uint32()); continue; case 2: if (tag !== 18) { @@ -2949,18 +2508,14 @@ export const VirtualChannelProposalAccMsg = { baseChannelProposalAcc: isSet(object.baseChannelProposalAcc) ? BaseChannelProposalAcc.fromJSON(object.baseChannelProposalAcc) : undefined, - responder: isSet(object.responder) - ? bytesFromBase64(object.responder) - : new Uint8Array(0), + responder: isSet(object.responder) ? bytesFromBase64(object.responder) : new Uint8Array(0), }; }, toJSON(message: VirtualChannelProposalAccMsg): unknown { const obj: any = {}; if (message.baseChannelProposalAcc !== undefined) { - obj.baseChannelProposalAcc = BaseChannelProposalAcc.toJSON( - message.baseChannelProposalAcc, - ); + obj.baseChannelProposalAcc = BaseChannelProposalAcc.toJSON(message.baseChannelProposalAcc); } if (message.responder.length !== 0) { obj.responder = base64FromBytes(message.responder); @@ -2968,18 +2523,13 @@ export const VirtualChannelProposalAccMsg = { return obj; }, - create( - base?: DeepPartial, - ): VirtualChannelProposalAccMsg { + create(base?: DeepPartial): VirtualChannelProposalAccMsg { return VirtualChannelProposalAccMsg.fromPartial(base ?? {}); }, - fromPartial( - object: DeepPartial, - ): VirtualChannelProposalAccMsg { + fromPartial(object: DeepPartial): VirtualChannelProposalAccMsg { const message = createBaseVirtualChannelProposalAccMsg(); message.baseChannelProposalAcc = - object.baseChannelProposalAcc !== undefined && - object.baseChannelProposalAcc !== null + (object.baseChannelProposalAcc !== undefined && object.baseChannelProposalAcc !== null) ? BaseChannelProposalAcc.fromPartial(object.baseChannelProposalAcc) : undefined; message.responder = object.responder ?? new Uint8Array(0); @@ -2992,10 +2542,7 @@ function createBaseChannelProposalRejMsg(): ChannelProposalRejMsg { } export const ChannelProposalRejMsg = { - encode( - message: ChannelProposalRejMsg, - writer: _m0.Writer = _m0.Writer.create(), - ): _m0.Writer { + encode(message: ChannelProposalRejMsg, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.proposalId.length !== 0) { writer.uint32(10).bytes(message.proposalId); } @@ -3005,12 +2552,8 @@ export const ChannelProposalRejMsg = { return writer; }, - decode( - input: _m0.Reader | Uint8Array, - length?: number, - ): ChannelProposalRejMsg { - const reader = - input instanceof _m0.Reader ? input : _m0.Reader.create(input); + decode(input: _m0.Reader | Uint8Array, length?: number): ChannelProposalRejMsg { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseChannelProposalRejMsg(); while (reader.pos < end) { @@ -3041,9 +2584,7 @@ export const ChannelProposalRejMsg = { fromJSON(object: any): ChannelProposalRejMsg { return { - proposalId: isSet(object.proposalId) - ? bytesFromBase64(object.proposalId) - : new Uint8Array(0), + proposalId: isSet(object.proposalId) ? bytesFromBase64(object.proposalId) : new Uint8Array(0), reason: isSet(object.reason) ? globalThis.String(object.reason) : "", }; }, @@ -3062,9 +2603,7 @@ export const ChannelProposalRejMsg = { create(base?: DeepPartial): ChannelProposalRejMsg { return ChannelProposalRejMsg.fromPartial(base ?? {}); }, - fromPartial( - object: DeepPartial, - ): ChannelProposalRejMsg { + fromPartial(object: DeepPartial): ChannelProposalRejMsg { const message = createBaseChannelProposalRejMsg(); message.proposalId = object.proposalId ?? new Uint8Array(0); message.reason = object.reason ?? ""; @@ -3077,15 +2616,9 @@ function createBaseChannelUpdateMsg(): ChannelUpdateMsg { } export const ChannelUpdateMsg = { - encode( - message: ChannelUpdateMsg, - writer: _m0.Writer = _m0.Writer.create(), - ): _m0.Writer { + encode(message: ChannelUpdateMsg, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.channelUpdate !== undefined) { - ChannelUpdate.encode( - message.channelUpdate, - writer.uint32(10).fork(), - ).ldelim(); + ChannelUpdate.encode(message.channelUpdate, writer.uint32(10).fork()).ldelim(); } if (message.sig.length !== 0) { writer.uint32(18).bytes(message.sig); @@ -3094,8 +2627,7 @@ export const ChannelUpdateMsg = { }, decode(input: _m0.Reader | Uint8Array, length?: number): ChannelUpdateMsg { - const reader = - input instanceof _m0.Reader ? input : _m0.Reader.create(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseChannelUpdateMsg(); while (reader.pos < end) { @@ -3126,9 +2658,7 @@ export const ChannelUpdateMsg = { fromJSON(object: any): ChannelUpdateMsg { return { - channelUpdate: isSet(object.channelUpdate) - ? ChannelUpdate.fromJSON(object.channelUpdate) - : undefined, + channelUpdate: isSet(object.channelUpdate) ? ChannelUpdate.fromJSON(object.channelUpdate) : undefined, sig: isSet(object.sig) ? bytesFromBase64(object.sig) : new Uint8Array(0), }; }, @@ -3149,33 +2679,22 @@ export const ChannelUpdateMsg = { }, fromPartial(object: DeepPartial): ChannelUpdateMsg { const message = createBaseChannelUpdateMsg(); - message.channelUpdate = - object.channelUpdate !== undefined && object.channelUpdate !== null - ? ChannelUpdate.fromPartial(object.channelUpdate) - : undefined; + message.channelUpdate = (object.channelUpdate !== undefined && object.channelUpdate !== null) + ? ChannelUpdate.fromPartial(object.channelUpdate) + : undefined; message.sig = object.sig ?? new Uint8Array(0); return message; }, }; function createBaseVirtualChannelFundingProposalMsg(): VirtualChannelFundingProposalMsg { - return { - channelUpdateMsg: undefined, - initial: undefined, - indexMap: undefined, - }; + return { channelUpdateMsg: undefined, initial: undefined, indexMap: undefined }; } export const VirtualChannelFundingProposalMsg = { - encode( - message: VirtualChannelFundingProposalMsg, - writer: _m0.Writer = _m0.Writer.create(), - ): _m0.Writer { + encode(message: VirtualChannelFundingProposalMsg, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.channelUpdateMsg !== undefined) { - ChannelUpdateMsg.encode( - message.channelUpdateMsg, - writer.uint32(10).fork(), - ).ldelim(); + ChannelUpdateMsg.encode(message.channelUpdateMsg, writer.uint32(10).fork()).ldelim(); } if (message.initial !== undefined) { SignedState.encode(message.initial, writer.uint32(18).fork()).ldelim(); @@ -3186,12 +2705,8 @@ export const VirtualChannelFundingProposalMsg = { return writer; }, - decode( - input: _m0.Reader | Uint8Array, - length?: number, - ): VirtualChannelFundingProposalMsg { - const reader = - input instanceof _m0.Reader ? input : _m0.Reader.create(input); + decode(input: _m0.Reader | Uint8Array, length?: number): VirtualChannelFundingProposalMsg { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseVirtualChannelFundingProposalMsg(); while (reader.pos < end) { @@ -3202,10 +2717,7 @@ export const VirtualChannelFundingProposalMsg = { break; } - message.channelUpdateMsg = ChannelUpdateMsg.decode( - reader, - reader.uint32(), - ); + message.channelUpdateMsg = ChannelUpdateMsg.decode(reader, reader.uint32()); continue; case 2: if (tag !== 18) { @@ -3232,15 +2744,9 @@ export const VirtualChannelFundingProposalMsg = { fromJSON(object: any): VirtualChannelFundingProposalMsg { return { - channelUpdateMsg: isSet(object.channelUpdateMsg) - ? ChannelUpdateMsg.fromJSON(object.channelUpdateMsg) - : undefined, - initial: isSet(object.initial) - ? SignedState.fromJSON(object.initial) - : undefined, - indexMap: isSet(object.indexMap) - ? IndexMap.fromJSON(object.indexMap) - : undefined, + channelUpdateMsg: isSet(object.channelUpdateMsg) ? ChannelUpdateMsg.fromJSON(object.channelUpdateMsg) : undefined, + initial: isSet(object.initial) ? SignedState.fromJSON(object.initial) : undefined, + indexMap: isSet(object.indexMap) ? IndexMap.fromJSON(object.indexMap) : undefined, }; }, @@ -3258,27 +2764,20 @@ export const VirtualChannelFundingProposalMsg = { return obj; }, - create( - base?: DeepPartial, - ): VirtualChannelFundingProposalMsg { + create(base?: DeepPartial): VirtualChannelFundingProposalMsg { return VirtualChannelFundingProposalMsg.fromPartial(base ?? {}); }, - fromPartial( - object: DeepPartial, - ): VirtualChannelFundingProposalMsg { + fromPartial(object: DeepPartial): VirtualChannelFundingProposalMsg { const message = createBaseVirtualChannelFundingProposalMsg(); - message.channelUpdateMsg = - object.channelUpdateMsg !== undefined && object.channelUpdateMsg !== null - ? ChannelUpdateMsg.fromPartial(object.channelUpdateMsg) - : undefined; - message.initial = - object.initial !== undefined && object.initial !== null - ? SignedState.fromPartial(object.initial) - : undefined; - message.indexMap = - object.indexMap !== undefined && object.indexMap !== null - ? IndexMap.fromPartial(object.indexMap) - : undefined; + message.channelUpdateMsg = (object.channelUpdateMsg !== undefined && object.channelUpdateMsg !== null) + ? ChannelUpdateMsg.fromPartial(object.channelUpdateMsg) + : undefined; + message.initial = (object.initial !== undefined && object.initial !== null) + ? SignedState.fromPartial(object.initial) + : undefined; + message.indexMap = (object.indexMap !== undefined && object.indexMap !== null) + ? IndexMap.fromPartial(object.indexMap) + : undefined; return message; }, }; @@ -3288,15 +2787,9 @@ function createBaseVirtualChannelSettlementProposalMsg(): VirtualChannelSettleme } export const VirtualChannelSettlementProposalMsg = { - encode( - message: VirtualChannelSettlementProposalMsg, - writer: _m0.Writer = _m0.Writer.create(), - ): _m0.Writer { + encode(message: VirtualChannelSettlementProposalMsg, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.channelUpdateMsg !== undefined) { - ChannelUpdateMsg.encode( - message.channelUpdateMsg, - writer.uint32(10).fork(), - ).ldelim(); + ChannelUpdateMsg.encode(message.channelUpdateMsg, writer.uint32(10).fork()).ldelim(); } if (message.final !== undefined) { SignedState.encode(message.final, writer.uint32(18).fork()).ldelim(); @@ -3304,12 +2797,8 @@ export const VirtualChannelSettlementProposalMsg = { return writer; }, - decode( - input: _m0.Reader | Uint8Array, - length?: number, - ): VirtualChannelSettlementProposalMsg { - const reader = - input instanceof _m0.Reader ? input : _m0.Reader.create(input); + decode(input: _m0.Reader | Uint8Array, length?: number): VirtualChannelSettlementProposalMsg { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseVirtualChannelSettlementProposalMsg(); while (reader.pos < end) { @@ -3320,10 +2809,7 @@ export const VirtualChannelSettlementProposalMsg = { break; } - message.channelUpdateMsg = ChannelUpdateMsg.decode( - reader, - reader.uint32(), - ); + message.channelUpdateMsg = ChannelUpdateMsg.decode(reader, reader.uint32()); continue; case 2: if (tag !== 18) { @@ -3343,12 +2829,8 @@ export const VirtualChannelSettlementProposalMsg = { fromJSON(object: any): VirtualChannelSettlementProposalMsg { return { - channelUpdateMsg: isSet(object.channelUpdateMsg) - ? ChannelUpdateMsg.fromJSON(object.channelUpdateMsg) - : undefined, - final: isSet(object.final) - ? SignedState.fromJSON(object.final) - : undefined, + channelUpdateMsg: isSet(object.channelUpdateMsg) ? ChannelUpdateMsg.fromJSON(object.channelUpdateMsg) : undefined, + final: isSet(object.final) ? SignedState.fromJSON(object.final) : undefined, }; }, @@ -3363,23 +2845,17 @@ export const VirtualChannelSettlementProposalMsg = { return obj; }, - create( - base?: DeepPartial, - ): VirtualChannelSettlementProposalMsg { + create(base?: DeepPartial): VirtualChannelSettlementProposalMsg { return VirtualChannelSettlementProposalMsg.fromPartial(base ?? {}); }, - fromPartial( - object: DeepPartial, - ): VirtualChannelSettlementProposalMsg { + fromPartial(object: DeepPartial): VirtualChannelSettlementProposalMsg { const message = createBaseVirtualChannelSettlementProposalMsg(); - message.channelUpdateMsg = - object.channelUpdateMsg !== undefined && object.channelUpdateMsg !== null - ? ChannelUpdateMsg.fromPartial(object.channelUpdateMsg) - : undefined; - message.final = - object.final !== undefined && object.final !== null - ? SignedState.fromPartial(object.final) - : undefined; + message.channelUpdateMsg = (object.channelUpdateMsg !== undefined && object.channelUpdateMsg !== null) + ? ChannelUpdateMsg.fromPartial(object.channelUpdateMsg) + : undefined; + message.final = (object.final !== undefined && object.final !== null) + ? SignedState.fromPartial(object.final) + : undefined; return message; }, }; @@ -3389,10 +2865,7 @@ function createBaseChannelUpdateAccMsg(): ChannelUpdateAccMsg { } export const ChannelUpdateAccMsg = { - encode( - message: ChannelUpdateAccMsg, - writer: _m0.Writer = _m0.Writer.create(), - ): _m0.Writer { + encode(message: ChannelUpdateAccMsg, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.channelId.length !== 0) { writer.uint32(10).bytes(message.channelId); } @@ -3406,8 +2879,7 @@ export const ChannelUpdateAccMsg = { }, decode(input: _m0.Reader | Uint8Array, length?: number): ChannelUpdateAccMsg { - const reader = - input instanceof _m0.Reader ? input : _m0.Reader.create(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseChannelUpdateAccMsg(); while (reader.pos < end) { @@ -3445,9 +2917,7 @@ export const ChannelUpdateAccMsg = { fromJSON(object: any): ChannelUpdateAccMsg { return { - channelId: isSet(object.channelId) - ? bytesFromBase64(object.channelId) - : new Uint8Array(0), + channelId: isSet(object.channelId) ? bytesFromBase64(object.channelId) : new Uint8Array(0), version: isSet(object.version) ? globalThis.Number(object.version) : 0, sig: isSet(object.sig) ? bytesFromBase64(object.sig) : new Uint8Array(0), }; @@ -3484,10 +2954,7 @@ function createBaseChannelUpdateRejMsg(): ChannelUpdateRejMsg { } export const ChannelUpdateRejMsg = { - encode( - message: ChannelUpdateRejMsg, - writer: _m0.Writer = _m0.Writer.create(), - ): _m0.Writer { + encode(message: ChannelUpdateRejMsg, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.channelId.length !== 0) { writer.uint32(10).bytes(message.channelId); } @@ -3501,8 +2968,7 @@ export const ChannelUpdateRejMsg = { }, decode(input: _m0.Reader | Uint8Array, length?: number): ChannelUpdateRejMsg { - const reader = - input instanceof _m0.Reader ? input : _m0.Reader.create(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseChannelUpdateRejMsg(); while (reader.pos < end) { @@ -3540,9 +3006,7 @@ export const ChannelUpdateRejMsg = { fromJSON(object: any): ChannelUpdateRejMsg { return { - channelId: isSet(object.channelId) - ? bytesFromBase64(object.channelId) - : new Uint8Array(0), + channelId: isSet(object.channelId) ? bytesFromBase64(object.channelId) : new Uint8Array(0), version: isSet(object.version) ? globalThis.Number(object.version) : 0, reason: isSet(object.reason) ? globalThis.String(object.reason) : "", }; @@ -3579,10 +3043,7 @@ function createBaseChannelSyncMsg(): ChannelSyncMsg { } export const ChannelSyncMsg = { - encode( - message: ChannelSyncMsg, - writer: _m0.Writer = _m0.Writer.create(), - ): _m0.Writer { + encode(message: ChannelSyncMsg, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.phase !== 0) { writer.uint32(8).uint32(message.phase); } @@ -3593,8 +3054,7 @@ export const ChannelSyncMsg = { }, decode(input: _m0.Reader | Uint8Array, length?: number): ChannelSyncMsg { - const reader = - input instanceof _m0.Reader ? input : _m0.Reader.create(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseChannelSyncMsg(); while (reader.pos < end) { @@ -3626,9 +3086,7 @@ export const ChannelSyncMsg = { fromJSON(object: any): ChannelSyncMsg { return { phase: isSet(object.phase) ? globalThis.Number(object.phase) : 0, - currentTx: isSet(object.currentTx) - ? Transaction.fromJSON(object.currentTx) - : undefined, + currentTx: isSet(object.currentTx) ? Transaction.fromJSON(object.currentTx) : undefined, }; }, @@ -3649,10 +3107,9 @@ export const ChannelSyncMsg = { fromPartial(object: DeepPartial): ChannelSyncMsg { const message = createBaseChannelSyncMsg(); message.phase = object.phase ?? 0; - message.currentTx = - object.currentTx !== undefined && object.currentTx !== null - ? Transaction.fromPartial(object.currentTx) - : undefined; + message.currentTx = (object.currentTx !== undefined && object.currentTx !== null) + ? Transaction.fromPartial(object.currentTx) + : undefined; return message; }, }; @@ -3682,23 +3139,12 @@ function base64FromBytes(arr: Uint8Array): string { } } -type Builtin = - | Date - | Function - | Uint8Array - | string - | number - | boolean - | undefined; - -export type DeepPartial = T extends Builtin - ? T - : T extends globalThis.Array - ? globalThis.Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; function longToNumber(long: Long): number { From 456bbe0ccfd6dbbcc31e0edabae9dcca03546087 Mon Sep 17 00:00:00 2001 From: Jan Bormet Date: Tue, 19 Dec 2023 15:00:45 +0100 Subject: [PATCH 2/7] WIP: Return go-perun State for getChannels --- perun-wallet-spec | 2 +- src/client.ts | 23 +++++++++++++++++++++++ src/perun-wallet.ts | 18 +++++++++--------- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/perun-wallet-spec b/perun-wallet-spec index a209659..119ae4b 160000 --- a/perun-wallet-spec +++ b/perun-wallet-spec @@ -1 +1 @@ -Subproject commit a209659bdcfb6bf9bb063c00290498babd9620b1 +Subproject commit 119ae4b9681ddee9e76c11751d22ff1f65d75e3b diff --git a/src/client.ts b/src/client.ts index b268e81..d42beae 100644 --- a/src/client.ts +++ b/src/client.ts @@ -8,6 +8,7 @@ import { ServiceResponse, SimpleChannelServiceClient } from "./services"; import { AddressEncoder, channelIdToString } from "./translator"; import { Allocation, State } from "./wire"; import { bigintFromLEBytes } from "./verifier"; +import { ChannelState } from "./ckb/serialization"; // The ServiceClient is purely actionable and only knows about the actions it // can perform. If channel updates are received from another peer, this client @@ -100,6 +101,28 @@ export class ServiceClient implements SimpleChannelServiceClient { return res; } + async getChannels( + me: Uint8Array, + ): ServiceResponse { + const req = { + requester: this.addrEncoder(me), + }; + + const res = await this.channelServiceClient.getChannels(req); + + if (res.rejected) { + return res; + } + if (!res.state) { + return res; + } + const cid = this.idToString(res.state!.id); + console.log("getChannels poll cid: ", cid); + this.updateChannelState(res.state!.id, res.state!); + return res; + } + + async updateChannel( channelId: Uint8Array, assetIdx: number, diff --git a/src/perun-wallet.ts b/src/perun-wallet.ts index 95ada64..4d10e13 100644 --- a/src/perun-wallet.ts +++ b/src/perun-wallet.ts @@ -18,7 +18,7 @@ export interface GetChannelsRequest { export interface GetChannelsResponse { rejected?: Rejected | undefined; - channels?: Uint8Array | undefined; + state?: State | undefined; } export interface ChannelOpenRequest { @@ -284,7 +284,7 @@ export const GetChannelsRequest = { }; function createBaseGetChannelsResponse(): GetChannelsResponse { - return { rejected: undefined, channels: undefined }; + return { rejected: undefined, state: undefined }; } export const GetChannelsResponse = { @@ -292,8 +292,8 @@ export const GetChannelsResponse = { if (message.rejected !== undefined) { Rejected.encode(message.rejected, writer.uint32(10).fork()).ldelim(); } - if (message.channels !== undefined) { - writer.uint32(18).bytes(message.channels); + if (message.state !== undefined) { + State.encode(message.state, writer.uint32(18).fork()).ldelim(); } return writer; }, @@ -317,7 +317,7 @@ export const GetChannelsResponse = { break; } - message.channels = reader.bytes(); + message.state = State.decode(reader, reader.uint32()); continue; } if ((tag & 7) === 4 || tag === 0) { @@ -331,7 +331,7 @@ export const GetChannelsResponse = { fromJSON(object: any): GetChannelsResponse { return { rejected: isSet(object.rejected) ? Rejected.fromJSON(object.rejected) : undefined, - channels: isSet(object.channels) ? bytesFromBase64(object.channels) : undefined, + state: isSet(object.state) ? State.fromJSON(object.state) : undefined, }; }, @@ -340,8 +340,8 @@ export const GetChannelsResponse = { if (message.rejected !== undefined) { obj.rejected = Rejected.toJSON(message.rejected); } - if (message.channels !== undefined) { - obj.channels = base64FromBytes(message.channels); + if (message.state !== undefined) { + obj.state = State.toJSON(message.state); } return obj; }, @@ -354,7 +354,7 @@ export const GetChannelsResponse = { message.rejected = (object.rejected !== undefined && object.rejected !== null) ? Rejected.fromPartial(object.rejected) : undefined; - message.channels = object.channels ?? undefined; + message.state = (object.state !== undefined && object.state !== null) ? State.fromPartial(object.state) : undefined; return message; }, }; From f3893f68419ac45edf1501e6059a35bd8459bfff Mon Sep 17 00:00:00 2001 From: Jan Bormet Date: Thu, 21 Dec 2023 10:27:15 +0100 Subject: [PATCH 3/7] services: Add getChannels endpoint to client --- src/services.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/services.ts b/src/services.ts index d879bf7..b556671 100644 --- a/src/services.ts +++ b/src/services.ts @@ -28,6 +28,10 @@ export interface SimpleChannelServiceClient { challengeDuration: number, ): ServiceResponse; + getChannels ( + requester: Uint8Array + ): ServiceResponse; + // Update the channel by paying the given amount to the peer. The asset is // identified by the idx of said asset in the channels state. See // ValidOpenChannelRequest.fundingAgreement in `verifier.ts` for more From 58b94b61920774599347a2d5b9f331c639faf2b0 Mon Sep 17 00:00:00 2001 From: Jan Bormet Date: Thu, 21 Dec 2023 12:32:05 +0100 Subject: [PATCH 4/7] WIP: Change channels map --- src/client.ts | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/src/client.ts b/src/client.ts index d42beae..14c8dba 100644 --- a/src/client.ts +++ b/src/client.ts @@ -17,6 +17,7 @@ export class ServiceClient implements SimpleChannelServiceClient { private addrEncoder: AddressEncoder; private channelServiceClient: ChannelServiceClient; private channels: Map; + private indexMap: Map; constructor( addrEncoder: AddressEncoder, @@ -25,6 +26,7 @@ export class ServiceClient implements SimpleChannelServiceClient { this.addrEncoder = addrEncoder; this.channelServiceClient = channelServiceClient; this.channels = new Map(); + this.indexMap = new Map(); } getCachedChannelState(id: Uint8Array | string): State | undefined { @@ -42,6 +44,17 @@ export class ServiceClient implements SimpleChannelServiceClient { return channel.state; } + + addOrUpdateChannels(id: Uint8Array | string, state: State): void { + let channelId; + if (id instanceof Uint8Array) { + channelId = this.idToString(id); + } else { + channelId = id; + } + const channel = this.channels.get(channelId); + this.channels.set(channelId, {state: state }); + } updateChannelState(id: Uint8Array | string, state: State): void { let channelId; @@ -82,18 +95,9 @@ export class ServiceClient implements SimpleChannelServiceClient { } const channelId = this.idToString(res.channelId!); + this.indexMap.set(channelId, 0); console.log("Wrapper channelId res: ", res.channelId) console.log("Wrapper channelId: ", channelId) - const initState = { - id: res.channelId!, - version: 0, - app: new Uint8Array(), - allocation: allocation, - data: new Uint8Array(), - isFinal: false, - }; - this.channels.set(channelId, { myIndex: 0, state: initState }); - // loop over this.channels map for (let [key, value] of this.channels) { console.log("Channels after open: ", key, value); } @@ -117,8 +121,8 @@ export class ServiceClient implements SimpleChannelServiceClient { return res; } const cid = this.idToString(res.state!.id); - console.log("getChannels poll cid: ", cid); - this.updateChannelState(res.state!.id, res.state!); + this.addOrUpdateChannels(cid, res.state!); + console.log("getChannels poll result: ", JSON.stringify(res)); return res; } @@ -139,11 +143,15 @@ export class ServiceClient implements SimpleChannelServiceClient { if (!channel) { throw new ClientError("channel not found"); } + let idx = this.indexMap.get(cID); + if (idx == undefined) { + idx = 1; + } const proposedState = updateStatePayment( channel.state, - channel.myIndex, - channel.myIndex == 0 ? 1 : 0, + idx, + idx == 0 ? 1 : 0, assetIdx, amount, ); @@ -189,7 +197,6 @@ export class ServiceClient implements SimpleChannelServiceClient { } export interface ClientChannel { - myIndex: number; state: State; } From a8c55b089d965dcd1e42f4df730e6387670572df Mon Sep 17 00:00:00 2001 From: Jan Bormet Date: Thu, 21 Dec 2023 12:51:33 +0100 Subject: [PATCH 5/7] Use big endian to encode balances --- src/client.ts | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/client.ts b/src/client.ts index 14c8dba..f1dfc33 100644 --- a/src/client.ts +++ b/src/client.ts @@ -122,7 +122,7 @@ export class ServiceClient implements SimpleChannelServiceClient { } const cid = this.idToString(res.state!.id); this.addOrUpdateChannels(cid, res.state!); - console.log("getChannels poll result: ", JSON.stringify(res)); + //console.log("getChannels poll result: ", JSON.stringify(res)); return res; } @@ -220,6 +220,16 @@ export class ClientError extends Error { } } +function bigintFromBEBytes(bytes: Uint8Array): bigint { + let result = BigInt(0); + + for (let i = 0; i < bytes.length; i++) { + result = (result << BigInt(8)) + BigInt(bytes[i]); + } + + return result; +} + // Updates the given channel state with a payment using the `from` index as the // source and the `to` index as the destination with the given `amount`. function updateStatePayment( @@ -229,25 +239,26 @@ function updateStatePayment( assetIdx: number, amount: bigint, ) { + console.log("old state:", JSON.stringify(oldState)) const newState = { ...oldState }; const oldFrom = newState.allocation!.balances!.balances[assetIdx].balance[from]; const oldTo = newState.allocation!.balances!.balances[assetIdx].balance[to]; - const oldFromBigInt = bigintFromLEBytes(oldFrom); + const oldFromBigInt = bigintFromBEBytes(oldFrom); if (oldFromBigInt < amount) { throw new Error("insufficient funds"); } - const oldToBigInt = bigintFromLEBytes(oldTo); + const oldToBigInt = bigintFromBEBytes(oldTo); const newFrom = oldFromBigInt - amount; const newTo = oldToBigInt + amount; // Update allocation struct for participants. newState.allocation!.balances!.balances[assetIdx].balance[from] = - bigintToLEBytes(newFrom); + bigintToBEBytes(newFrom); newState.allocation!.balances!.balances[assetIdx].balance[to] = - bigintToLEBytes(newTo); + bigintToBEBytes(newTo); // Make sure version count is incremented. newState.version = oldState.version + 1; @@ -264,3 +275,14 @@ function bigintToLEBytes(n: bigint): Uint8Array { } return Uint8Array.from(bytes); } + +function bigintToBEBytes(n: bigint): Uint8Array { + const bytes = []; + + while (n > 0) { + bytes.unshift(Number(n & BigInt(0xff))); + n = n >> BigInt(8); + } + + return Uint8Array.from(bytes); +} From dc282854eebbb89071ece1a26d40d7bc077630dd Mon Sep 17 00:00:00 2001 From: Jan Bormet Date: Thu, 21 Dec 2023 13:18:34 +0100 Subject: [PATCH 6/7] Do not update version number for state updates --- src/client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client.ts b/src/client.ts index f1dfc33..588d67f 100644 --- a/src/client.ts +++ b/src/client.ts @@ -260,7 +260,7 @@ function updateStatePayment( newState.allocation!.balances!.balances[assetIdx].balance[to] = bigintToBEBytes(newTo); // Make sure version count is incremented. - newState.version = oldState.version + 1; + newState.version = oldState.version; return newState; } From bf0d1d22e2433dd1674831f8231af6eecfbb5c97 Mon Sep 17 00:00:00 2001 From: sophia1ch Date: Mon, 15 Jan 2024 07:57:42 +0100 Subject: [PATCH 7/7] style(client): remove unnecessary logs. --- src/client.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/client.ts b/src/client.ts index 588d67f..33a3453 100644 --- a/src/client.ts +++ b/src/client.ts @@ -96,8 +96,7 @@ export class ServiceClient implements SimpleChannelServiceClient { const channelId = this.idToString(res.channelId!); this.indexMap.set(channelId, 0); - console.log("Wrapper channelId res: ", res.channelId) - console.log("Wrapper channelId: ", channelId) + console.log("Open Channel: ", channelId) for (let [key, value] of this.channels) { console.log("Channels after open: ", key, value); } @@ -122,7 +121,6 @@ export class ServiceClient implements SimpleChannelServiceClient { } const cid = this.idToString(res.state!.id); this.addOrUpdateChannels(cid, res.state!); - //console.log("getChannels poll result: ", JSON.stringify(res)); return res; } @@ -158,9 +156,7 @@ export class ServiceClient implements SimpleChannelServiceClient { const req = { state: proposedState, }; - console.log("updateChannel calling Channel Service: ", req) const res = await this.channelServiceClient.updateChannel(req); - console.log("updateChannel called channel servicec res: ", res) if (res.rejected) { return res; @@ -239,7 +235,6 @@ function updateStatePayment( assetIdx: number, amount: bigint, ) { - console.log("old state:", JSON.stringify(oldState)) const newState = { ...oldState }; const oldFrom = newState.allocation!.balances!.balances[assetIdx].balance[from];