Skip to content

Commit

Permalink
update neptuneService constructor for non-mainnet
Browse files Browse the repository at this point in the history
  • Loading branch information
shane-moore committed Nov 12, 2024
1 parent cceff72 commit 3b1a1ee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
15 changes: 8 additions & 7 deletions packages/sdk-ts/src/client/wasm/neptune/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
isMainnet,
getNetworkEndpoints,
} from '@injectivelabs/networks'
import { NetworkEndpoints } from '@injectivelabs/networks'
import { AssetInfo, NEPTUNE_USDT_CW20_CONTRACT, AssetInfoWithPrice } from './types'
import { ChainGrpcWasmApi } from '../../chain'
import { QueryGetPrices } from './queries'
Expand All @@ -27,16 +28,16 @@ export class NeptuneService {
* @param endpoints Optional custom network endpoints.
*/
constructor(
network: Network = Network.Mainnet,
endpoints?: any // Replace `any` with the appropriate type if available
network: Network = Network.MainnetSentry,
endpoints?: NetworkEndpoints
) {
if (network !== Network.Mainnet) {
if (!isMainnet(network)) {
throw new GeneralException(new Error('Please switch to mainnet network'))
}

const networkEndpoints = endpoints || getNetworkEndpoints(network)
this.client = new ChainGrpcWasmApi(networkEndpoints.grpc)
this.priceOracleContract = isMainnet(network) ? NEPTUNE_PRICE_CONTRACT : ''
this.priceOracleContract = NEPTUNE_PRICE_CONTRACT
}

/**
Expand Down Expand Up @@ -112,12 +113,12 @@ export class NeptuneService {
* @param amount Amount to deposit as a string.
* @returns MsgExecuteContractCompat message.
*/
createDepositMsg(
createDepositMsg({ denom, amount, sender, contractAddress = NEPTUNE_USDT_MARKET_CONTRACT }: {
denom: string,
amount: string,
sender: string,
contractAddress: string = NEPTUNE_USDT_MARKET_CONTRACT,
): MsgExecuteContractCompat {
contractAddress?: string
}): MsgExecuteContractCompat {
return MsgExecuteContractCompat.fromJSON({
sender,
contractAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export default class Magic
}

try {
const walletInfo = await this.magicWallet.user.getMetadata()
const { publicAddress } = await this.magicWallet.user.getInfo()

if (!publicAddress?.startsWith('inj')) {
Expand Down

0 comments on commit 3b1a1ee

Please sign in to comment.