Created
December 13, 2023 09:56
-
-
Save arthuryeti/173a794b32e2958d5506fd9b701ae5dc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import { ReactNode } from "react"; | |
import { ChainProvider } from "@cosmos-kit/react"; | |
import { GasPrice } from "@cosmjs/stargate"; | |
import { SignerOptions } from "@cosmos-kit/core"; | |
import { Chain, AssetList } from "@chain-registry/types"; | |
import { wallets } from "@cosmos-kit/keplr"; | |
import { getSigningPryzmClientOptions } from "@pryzm-finance/pryzmjs"; | |
import { wallets as leap } from "@cosmos-kit/leap"; | |
type Props = { | |
children: ReactNode; | |
}; | |
const localChain: Chain = { | |
chain_name: process.env.NEXT_PUBLIC_PRYZM_CHAIN_NAME, | |
chain_id: process.env.NEXT_PUBLIC_PRYZM_CHAIN_ID, | |
status: "development", | |
network_type: "testnet", | |
pretty_name: "Pryzm Testnet", | |
bech32_prefix: "pryzm", | |
slip44: 118, | |
staking: { | |
staking_tokens: [ | |
{ | |
denom: "upryzm", | |
}, | |
], | |
}, | |
fees: { | |
fee_tokens: [ | |
{ | |
denom: "upryzm", | |
fixed_min_gas_price: 0, | |
low_gas_price: 0, | |
average_gas_price: 0, | |
high_gas_price: 0.01, | |
}, | |
{ | |
denom: "factory/pryzm15k9s9p0ar0cx27nayrgk6vmhyec3lj7vkry7rx/uusdsim", | |
fixed_min_gas_price: 0, | |
low_gas_price: 0, | |
average_gas_price: 0, | |
high_gas_price: 0.01, | |
}, | |
], | |
}, | |
}; | |
const localAssets: AssetList = { | |
chain_name: process.env.NEXT_PUBLIC_PRYZM_CHAIN_NAME, | |
assets: [ | |
{ | |
description: "Pryzm token", | |
denom_units: [ | |
{ | |
denom: "upryzm", | |
exponent: 0, | |
}, | |
{ | |
denom: "pryzm", | |
exponent: 6, | |
}, | |
], | |
base: "upryzm", | |
name: "Pryzm", | |
display: "pryzm", | |
symbol: "PRYZM", | |
logo_URIs: { | |
png: "https://raw.githubusercontent.com/cosmos/chain-registry/master/prism/images/prism-token.png", | |
svg: "https://raw.githubusercontent.com/cosmos/chain-registry/master/prism/images/prism-token.svg", | |
}, | |
coingecko_id: "pryzm", | |
}, | |
], | |
}; | |
const defaultConfig = { | |
gasPrice: GasPrice.fromString("0.03upryzm"), | |
}; | |
const signerOptions: SignerOptions = { | |
// @ts-expect-error | |
signingStargate: (_chain: Chain) => { | |
const { registry, aminoTypes } = getSigningPryzmClientOptions(); | |
return { | |
registry, | |
aminoTypes, | |
gasPrice: defaultConfig.gasPrice, | |
}; | |
}, | |
preferredSignType: (_chain: Chain) => { | |
return "direct"; | |
}, | |
}; | |
export const CosmosKitProvider = ({ children }: Props) => { | |
return ( | |
<ChainProvider | |
chains={[localChain]} | |
assetLists={[localAssets]} | |
wallets={[...wallets, ...leap]} | |
signerOptions={signerOptions} | |
endpointOptions={{ | |
isLazy: true, | |
endpoints: { | |
[process.env.NEXT_PUBLIC_PRYZM_CHAIN_NAME]: { | |
rpc: [process.env.NEXT_PUBLIC_PRYZM_CHAIN_RPC_ENDPOINT], | |
rest: [process.env.NEXT_PUBLIC_PRYZM_CHAIN_ENDPOINT], | |
}, | |
}, | |
}} | |
> | |
{children} | |
</ChainProvider> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment