-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(node): calculate endpoint account paths on the fly
- Loading branch information
Showing
13 changed files
with
55 additions
and
33 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
36 changes: 36 additions & 0 deletions
36
packages/app-dassie/src/ilp-connector/functions/get-endpoint-account-path.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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import type { Reactor } from "@dassie/lib-reactive" | ||
import { UnreachableCaseError } from "@dassie/lib-type-utils" | ||
|
||
import { OwnerLedgerIdSignal } from "../../accounting/signals/owner-ledger-id" | ||
import type { AccountPath } from "../../accounting/types/account-paths" | ||
import type { EndpointInfo } from "./send-packet" | ||
|
||
export function GetEndpointAccountPath(reactor: Reactor) { | ||
const ownerLedgerIdSignal = reactor.use(OwnerLedgerIdSignal) | ||
|
||
return function getEndpointAccountPath( | ||
endpointInfo: EndpointInfo, | ||
): AccountPath { | ||
switch (endpointInfo.type) { | ||
case "peer": { | ||
return endpointInfo.accountPath | ||
} | ||
case "ildcp": { | ||
// ILDCP cannot send or receive money so we set the account path to an impossible value | ||
return "unreachable" as AccountPath | ||
} | ||
case "btp": { | ||
return `${ownerLedgerIdSignal.read()}:equity/owner` | ||
} | ||
case "local": { | ||
return `${ownerLedgerIdSignal.read()}:equity/owner` | ||
} | ||
case "http": { | ||
return `${ownerLedgerIdSignal.read()}:equity/owner` | ||
} | ||
default: { | ||
throw new UnreachableCaseError(endpointInfo) | ||
} | ||
} | ||
} | ||
} |
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
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
6 changes: 4 additions & 2 deletions
6
packages/app-dassie/src/ilp-connector/senders/send-peer-packets.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
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