-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add placeholder methods for porting virtual-fund command
- Loading branch information
Showing
9 changed files
with
124 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,15 @@ | ||
import { Channel } from './channel'; | ||
import { State } from './state/state'; | ||
|
||
// TODO: Implement | ||
export class VirtualChannel extends Channel {} | ||
export class VirtualChannel extends Channel { | ||
// NewVirtualChannel returns a new VirtualChannel based on the supplied state. | ||
// | ||
// Virtual channel protocol currently presumes exactly two "active" participants, | ||
// Alice and Bob (p[0] and p[last]). They should be the only destinations allocated | ||
// to in the supplied state's Outcome. | ||
// TODO: Implement | ||
static newVirtualChannel(s: State, myIndex: number): VirtualChannel { | ||
return new VirtualChannel({}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Address } from '../types/types'; | ||
|
||
const PAYER_INDEX = 0; | ||
|
||
// GetPayer returns the payer on a payment channel | ||
export const getPayer = (participants: Address[]): Address => participants[PAYER_INDEX]; | ||
|
||
// GetPayee returns the payee on a payment channel | ||
const getPayee = (participants: Address[]): Address => participants[participants.length - 1]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 62 additions & 2 deletions
64
packages/nitro-client/src/protocols/virtualfund/virtualfund.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,67 @@ | ||
// Objective is a cache of data computed by reading from the store. It stores (potentially) infinite data. | ||
|
||
import { Destination } from '../../types/destination'; | ||
import { ConsensusChannel } from '../../channel/consensus-channel/consensus-channel'; | ||
import { Exit } from '../../channel/state/outcome/exit'; | ||
import { State } from '../../channel/state/state'; | ||
import { Funds } from '../../types/funds'; | ||
import { Address } from '../../types/types'; | ||
|
||
// GetTwoPartyConsensusLedgerFuncion describes functions which return a ConsensusChannel ledger channel between | ||
// the calling client and the given counterparty, if such a channel exists. | ||
interface GetTwoPartyConsensusLedgerFunction { | ||
(counterparty: Address): [ConsensusChannel, boolean] | ||
} | ||
|
||
// TODO: Implement | ||
export class Connection { | ||
// insertGuaranteeInfo mutates the receiver Connection struct. | ||
private insertGuaranteeInfo(a0: Funds, b0: Funds, vId: Destination, left: Destination, right: Destination) {} | ||
} | ||
|
||
// TODO: Implement | ||
export class Objective {} | ||
export class Objective { | ||
// NewObjective creates a new virtual funding objective from a given request. | ||
// TODO: Implement | ||
static newObjective( | ||
request: ObjectiveRequest, | ||
preApprove: boolean, | ||
myAddress: Address, | ||
chainId: bigint, | ||
getTwoPartyConsensusLedger: GetTwoPartyConsensusLedgerFunction, | ||
): Objective { | ||
return new Objective(); | ||
} | ||
|
||
// constructFromState initiates an Objective from an initial state and set of ledgers. | ||
// TODO: Implement | ||
static constructFromState( | ||
preApprove: boolean, | ||
initialStateOfV: State, | ||
myAddress: Address, | ||
consensusChannelToMyLeft: ConsensusChannel, | ||
consensusChannelToMyRight: ConsensusChannel, | ||
): Objective { | ||
return new Objective(); | ||
} | ||
} | ||
|
||
// ObjectiveRequest represents a request to create a new virtual funding objective. | ||
// TODO: Implement | ||
export class ObjectiveRequest {} | ||
export class ObjectiveRequest { | ||
// NewObjectiveRequest creates a new ObjectiveRequest. | ||
static newObjectiveRequest( | ||
intermediaries: Address[], | ||
counterparty: Address, | ||
challengeDuration: number, | ||
outcome: Exit, | ||
nonce: string, | ||
appDefinition: Address, | ||
): ObjectiveRequest { | ||
return new ObjectiveRequest(); | ||
} | ||
} | ||
|
||
// ObjectiveResponse is the type returned across the API in response to the ObjectiveRequest. | ||
// TODO: Implement | ||
export class ObjectiveResponse {} |