Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/rich-guests-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"graz": patch
---

fix install deps warning
3 changes: 1 addition & 2 deletions packages/graz/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@
"dependencies": {
"@keplr-wallet/types": "0.12.156",
"@cosmsnap/snapper": "0.2.7",
"@dao-dao/cosmiframe": "0.1.0",
"@dao-dao/cosmiframe": "1.0.0",
"@keplr-wallet/cosmos": "0.12.156",
"@metamask/providers": "12.0.0",
"@terra-money/station-connector": "1.1.0",
"@vectis/extension-client": "^0.7.2",
"@walletconnect/sign-client": "2.20.2",
"@walletconnect/types": "2.20.2",
Expand Down
63 changes: 58 additions & 5 deletions packages/graz/src/actions/wallet/station.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,63 @@
import type { ChainInfo, KeplrSignOptions, StdSignDoc } from "@keplr-wallet/types";
import type { ChainInfoResponse } from "@terra-money/station-connector/keplrConnector";

import { useGrazInternalStore } from "../../store";
import type { Key, SignDoc, Wallet } from "../../types/wallet";
import { clearSession } from ".";
import { DirectSignResponse } from "@cosmjs/proto-signing";

type ChainInfoResponse = {
chainId: string;
chainName: string;
chainSymbolImageUrl: string;
stakeCurrency: {
coinDecimals: number;
coinDenom: string;
coinImageUrl: string;
coinMinimalDenom: string;
};
bip44: {
coinType: number;
};
bech32Config: {
bech32PrefixAccAddr: string;
bech32PrefixAccPub: string;
bech32PrefixConsAddr: string;
bech32PrefixConsPub: string;
bech32PrefixValAddr: string;
bech32PrefixValPub: string;
};
currencies: {
coinDecimals: number;
coinDenom: string;
coinImageUrl: string;
coinMinimalDenom: string;
}[];
/**
* This indicates which coin or token can be used for fee to send transaction.
* You can get actual currency information from Currencies.
*/
feeCurrencies: {
coinDecimals: number;
coinDenom: string;
coinImageUrl: string;
coinMinimalDenom: string;
gasPriceStep: {
average: number;
high: number;
low: number;
};
}[];
};

type GetKeyResponse = {
name: string;
algo: string;
pubKey: Uint8Array;
address: Uint8Array;
bech32Address: string;
isNanoLedger: boolean;
};

/**
* Function to return Station object (which is {@link Wallet}) and throws and error if it does not exist on `window`.
*
Expand All @@ -19,7 +71,7 @@ import { DirectSignResponse } from "@cosmjs/proto-signing";
* ```
*/
export const getStation = (): Wallet => {
if (typeof window.station !== "undefined") {
if (typeof window.station?.keplr !== "undefined") {
const station = window.station.keplr;

const subscription: (reconnect: () => void) => () => void = (reconnect) => {
Expand All @@ -34,7 +86,7 @@ export const getStation = (): Wallet => {
};

const getKey = async (chainId: string): Promise<Key> => {
const key = await station.getKey(chainId);
const key = (await station.getKey(chainId)) as GetKeyResponse;
return {
isKeystone: false,
...key,
Expand Down Expand Up @@ -106,9 +158,10 @@ export const getStation = (): Wallet => {
experimentalSuggestChain,
enable: (chainIds: string | string[]) => station.enable(chainIds),
disable: (chainIds?: string | string[]) => station.disable(chainIds),
getOfflineSignerAuto: (chainId: string) => station.getOfflineSignerAuto(chainId),
getOfflineSignerAuto: ((chainId: string) =>
station.getOfflineSignerAuto(chainId)) as unknown as Wallet["getOfflineSignerAuto"],
getOfflineSignerOnlyAmino: (chainId: string) => station.getOfflineSignerOnlyAmino(chainId),
signDirect: () => station.signDirect(),
signDirect: station.signDirect as unknown as Wallet["signDirect"],
signAmino: (chainId: string, signer: string, signDoc: StdSignDoc, _signOptions?: KeplrSignOptions) =>
station.signAmino(chainId, signer, signDoc),
};
Expand Down
50 changes: 49 additions & 1 deletion packages/graz/types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,50 @@ import type { InitiaWallet } from "../src/actions/wallet/initia";
type KeplrWindow = import("@keplr-wallet/types").Window;
type VectisWindow = import("@vectis/extension-client").VectisWindow;

type StationChainInfoResponse = {
chainId: string;
chainName: string;
chainSymbolImageUrl: string;
stakeCurrency: {
coinDecimals: number;
coinDenom: string;
coinImageUrl: string;
coinMinimalDenom: string;
};
bip44: {
coinType: number;
};
bech32Config: {
bech32PrefixAccAddr: string;
bech32PrefixAccPub: string;
bech32PrefixConsAddr: string;
bech32PrefixConsPub: string;
bech32PrefixValAddr: string;
bech32PrefixValPub: string;
};
currencies: {
coinDecimals: number;
coinDenom: string;
coinImageUrl: string;
coinMinimalDenom: string;
}[];
/**
* This indicates which coin or token can be used for fee to send transaction.
* You can get actual currency information from Currencies.
*/
feeCurrencies: {
coinDecimals: number;
coinDenom: string;
coinImageUrl: string;
coinMinimalDenom: string;
gasPriceStep: {
average: number;
high: number;
low: number;
};
}[];
};

declare global {
interface Window extends KeplrWindow, VectisWindow {
leap?: KeplrWindow["keplr"];
Expand All @@ -22,7 +66,11 @@ declare global {
okxwallet?: import("@metamask/providers").BaseProvider & {
keplr: KeplrWindow["keplr"];
};
station?: Station;
station?: {
keplr: KeplrWindow["keplr"] & {
experimentalSuggestChain: (chainInfo: StationChainInfoResponse) => Promise<void>;
};
};
xfi?: {
keplr: KeplrWindow["keplr"];
};
Expand Down
Loading