-
Notifications
You must be signed in to change notification settings - Fork 463
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
실제 swap이 이루어지고 있는 토큰만 destination에 표시하도록 수정
- Loading branch information
Showing
11 changed files
with
182 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from "./skip"; | ||
export * from "./price-changes"; | ||
export * from "./swap-usage"; |
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,2 @@ | ||
export * from "./queries"; | ||
export * from "./swap-usage"; |
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,11 @@ | ||
import { QuerySharedContext } from "@keplr-wallet/stores"; | ||
import { DeepReadonly } from "utility-types"; | ||
import { ObservableQuerySwapUsage } from "./swap-usage"; | ||
|
||
export class SwapUsageQueries { | ||
public readonly querySwapUsage: DeepReadonly<ObservableQuerySwapUsage>; | ||
|
||
constructor(sharedContext: QuerySharedContext, baseURL: string) { | ||
this.querySwapUsage = new ObservableQuerySwapUsage(sharedContext, baseURL); | ||
} | ||
} |
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,62 @@ | ||
import { | ||
HasMapStore, | ||
ObservableQuery, | ||
QuerySharedContext, | ||
} from "@keplr-wallet/stores"; | ||
import { computed, makeObservable } from "mobx"; | ||
import { ChainIdHelper } from "@keplr-wallet/cosmos"; | ||
|
||
export type SwapUsageResponse = string[]; | ||
|
||
export class ObservableQuerySwapUsageInner extends ObservableQuery<SwapUsageResponse> { | ||
constructor( | ||
sharedContext: QuerySharedContext, | ||
baseURL: string, | ||
chainIdentifier: string | ||
) { | ||
super(sharedContext, baseURL, `/swap-usage/denoms/${chainIdentifier}`); | ||
|
||
makeObservable(this); | ||
} | ||
|
||
get denoms(): string[] { | ||
if (!this.response) { | ||
return []; | ||
} | ||
|
||
return this.response.data; | ||
} | ||
|
||
@computed | ||
get denomMap(): Map<string, boolean> { | ||
const map = new Map<string, boolean>(); | ||
for (const denom of this.denoms) { | ||
map.set(denom, true); | ||
} | ||
|
||
return map; | ||
} | ||
|
||
isSwappable(denom: string): boolean { | ||
return this.denomMap.has(denom); | ||
} | ||
} | ||
|
||
export class ObservableQuerySwapUsage extends HasMapStore<ObservableQuerySwapUsageInner> { | ||
constructor( | ||
protected readonly sharedContext: QuerySharedContext, | ||
protected readonly baseURL: string | ||
) { | ||
super((str) => { | ||
return new ObservableQuerySwapUsageInner( | ||
this.sharedContext, | ||
baseURL, | ||
str | ||
); | ||
}); | ||
} | ||
|
||
getSwapUsage(chainIdentifier: string): ObservableQuerySwapUsageInner { | ||
return this.get(ChainIdHelper.parse(chainIdentifier).identifier); | ||
} | ||
} |