-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
316c92d
commit e92f169
Showing
12 changed files
with
249 additions
and
202 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
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,25 @@ | ||
import { Route } from 'react-router-dom'; | ||
|
||
import { RouteUrls } from '@shared/route-urls'; | ||
|
||
import { ledgerStacksTxSigningRoutes } from '@app/features/ledger/flows/stacks-tx-signing/ledger-sign-tx.routes'; | ||
import { AccountGate } from '@app/routes/account-gate'; | ||
|
||
import { Swap } from './swap'; | ||
import { SwapChooseAsset } from './swap-choose-asset/swap-choose-asset'; | ||
import { SwapError } from './swap-error/swap-error'; | ||
import { SwapReview } from './swap-review/swap-review'; | ||
|
||
export function generateSwapRoutes(container: React.ReactNode) { | ||
return ( | ||
<Route element={<AccountGate>{container}</AccountGate>}> | ||
<Route path={RouteUrls.Swap} element={<Swap />}> | ||
<Route path={RouteUrls.SwapChooseAsset} element={<SwapChooseAsset />} /> | ||
</Route> | ||
<Route path={RouteUrls.SwapError} element={<SwapError />} /> | ||
<Route path={RouteUrls.SwapReview} element={<SwapReview />}> | ||
{ledgerStacksTxSigningRoutes} | ||
</Route> | ||
</Route> | ||
); | ||
} |
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 was deleted.
Oops, something went wrong.
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,56 @@ | ||
import type { StacksTransaction } from '@stacks/transactions'; | ||
|
||
type PubTypeFn<E> = <Key extends string & keyof E>( | ||
event: Key, | ||
// Ensures if we have an event with no payload, the second arg can be empty, | ||
// rather than `undefined` | ||
...message: null extends E[Key] ? [data?: never] : [data: E[Key]] | ||
) => void; | ||
|
||
type SubTypeFn<E> = <Key extends string & keyof E>( | ||
event: Key, | ||
fn: (message: E[Key]) => void | ||
) => void; | ||
|
||
type MessageFn<E> = <Key extends string & keyof E>(message: E[Key]) => void; | ||
|
||
interface PubSubType<E> { | ||
publish: PubTypeFn<E>; | ||
subscribe: SubTypeFn<E>; | ||
unsubscribe: SubTypeFn<E>; | ||
} | ||
function PublishSubscribe<E>(): PubSubType<E> { | ||
const handlers: { [key: string]: MessageFn<any>[] } = {}; | ||
|
||
return { | ||
publish(event, msg?) { | ||
handlers[event].forEach(h => h(msg)); | ||
}, | ||
|
||
subscribe(event, callback) { | ||
const list = handlers[event] ?? []; | ||
list.push(callback); | ||
handlers[event] = list; | ||
}, | ||
|
||
unsubscribe(event, callback) { | ||
let list = handlers[event] ?? []; | ||
list = list.filter(h => h !== callback); | ||
handlers[event] = list; | ||
}, | ||
}; | ||
} | ||
|
||
// Global app events. Only add events if your feature isn't capable of | ||
// communicating internally. | ||
export interface GlobalAppEvents { | ||
ledgerStacksTxSigned: { | ||
unsignedTx: string; | ||
signedTx: StacksTransaction; | ||
}; | ||
ledgerStacksTxSigningCancelled: { | ||
unsignedTx: string; | ||
}; | ||
} | ||
|
||
export const appEvents = PublishSubscribe<GlobalAppEvents>(); |
Oops, something went wrong.