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
2 changes: 1 addition & 1 deletion packages/networks/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export type NetworkEndpoints = {
indexer: string // Indexer API
grpc: string // Sentry gRPC
rest: string // LCD
rpc?: string // Tendermint
rpc: string // Tendermint
cacheGrpc?: string // Cache gRPC service
cacheRest?: string // Cache LCD service
chronos?: string // Chronos Service
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@
"@cosmjs/proto-signing": "catalog:",
"@cosmjs/stargate": "catalog:",
"@injectivelabs/abacus-proto-ts-v2": "1.17.5",
"@injectivelabs/core-proto-ts-v2": "1.20.0",
"@injectivelabs/core-proto-ts-v2": "1.20.1",
"@injectivelabs/exceptions": "workspace:*",
"@injectivelabs/grpc-web": "^0.0.1",
"@injectivelabs/grpc-web-node-http-transport": "^0.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import type { ExplorerValidator } from '../types/index.js'
import type { IndexerGrpcExplorerTransformer } from '../transformers/index.js'

const injectiveAddress = mockFactory.injectiveAddress
const endpoints = getNetworkEndpoints(Network.Devnet1)
const endpoints = getNetworkEndpoints(Network.Mainnet)
const indexerGrpcExplorerApi = new IndexerGrpcExplorerApi(endpoints.indexer)

describe('IndexerGrpcExplorerApi', () => {
let validator: Partial<ExplorerValidator>

beforeAll(async () => {
console.log(`${endpoints.indexer}/api/explorer/v1`)

const validators = await new IndexerRestExplorerApi(
`${endpoints.indexer}/api/explorer/v1`,
).fetchValidators()
Expand Down Expand Up @@ -273,7 +275,7 @@ describe('IndexerGrpcExplorerApi', () => {
}
})

test('fetchAccountTxsV2WithBlockDetails', async () => {
test.skip('fetchAccountTxsV2WithBlockDetails', async () => {
try {
const response = await new IndexerGrpcExplorerApi(
getNetworkEndpoints(Network.Testnet).indexer,
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk-ts/src/core/modules/exchange/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ import MsgCreateDerivativeMarketOrderV2 from './msgs/MsgCreateDerivativeMarketOr
import MsgAdminUpdateBinaryOptionsMarket from './msgs/MsgAdminUpdateBinaryOptionsMarket.js'
import MsgBatchCancelBinaryOptionsOrders from './msgs/MsgBatchCancelBinaryOptionsOrders.js'
import MsgCreateBinaryOptionsMarketOrder from './msgs/MsgCreateBinaryOptionsMarketOrder.js'
import MsgSetDelegationTransferReceivers from './msgs/MsgSetDelegationTransferReceivers.js'
import MsgCreateBinaryOptionsLimitOrderV2 from './msgs/MsgCreateBinaryOptionsLimitOrderV2.js'
import MsgSetDelegationTransferReceiversV2 from './msgs/MsgSetDelegationTransferReceiversV2.js'
import MsgInstantBinaryOptionsMarketLaunch from './msgs/MsgInstantBinaryOptionsMarketLaunch.js'
import MsgAdminUpdateBinaryOptionsMarketV2 from './msgs/MsgAdminUpdateBinaryOptionsMarketV2.js'
import MsgBatchCancelBinaryOptionsOrdersV2 from './msgs/MsgBatchCancelBinaryOptionsOrdersV2.js'
Expand Down Expand Up @@ -84,7 +84,6 @@ export {
MsgAdminUpdateBinaryOptionsMarket,
MsgCreateBinaryOptionsMarketOrder,
MsgBatchCancelBinaryOptionsOrders,
MsgSetDelegationTransferReceivers,
MsgInstantBinaryOptionsMarketLaunch,
MsgDepositV2,
MsgSignDataV2,
Expand All @@ -107,6 +106,7 @@ export {
MsgCreateDerivativeLimitOrderV2,
MsgBatchCancelDerivativeOrdersV2,
MsgCreateDerivativeMarketOrderV2,
MsgSetDelegationTransferReceiversV2,
MsgCreateBinaryOptionsLimitOrderV2,
MsgAdminUpdateBinaryOptionsMarketV2,
MsgBatchCancelBinaryOptionsOrdersV2,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { EIP712Version } from '@injectivelabs/ts-types'
import { mockFactory, prepareEip712 } from '@injectivelabs/utils/test-utils'
import MsgSetDelegationTransferReceivers from './MsgSetDelegationTransferReceivers.js'
import MsgSetDelegationTransferReceiversV2 from './MsgSetDelegationTransferReceiversV2.js'
import {
getEip712TypedData,
getEip712TypedDataV2,
} from '../../../tx/eip712/eip712.js'
import { IndexerGrpcWeb3GwApi } from './../../../../client/indexer/grpc/IndexerGrpcWeb3GwApi.js'

const params: MsgSetDelegationTransferReceivers['params'] = {
const params: MsgSetDelegationTransferReceiversV2['params'] = {
sender: mockFactory.injectiveAddress,
receivers: [mockFactory.injectiveAddress2],
}
Expand All @@ -22,17 +22,16 @@ const protoParamsAmino = {
sender: params.sender,
receivers: params.receivers,
}
const message = MsgSetDelegationTransferReceivers.fromJSON(params)
const message = MsgSetDelegationTransferReceiversV2.fromJSON(params)

// hidden in chain v1.18.0
describe('MsgSetDelegationTransferReceivers', () => {
it.skip('generates proper proto', () => {
describe('MsgSetDelegationTransferReceiversV2', () => {
it('generates proper proto', () => {
const proto = message.toProto()

expect(proto).toStrictEqual(protoParams)
})

it.skip('generates proper data', () => {
it('generates proper data', () => {
const data = message.toData()

expect(data).toStrictEqual({
Expand All @@ -41,7 +40,7 @@ describe('MsgSetDelegationTransferReceivers', () => {
})
})

it.skip('generates proper amino', () => {
it('generates proper amino', () => {
const amino = message.toAmino()

expect(amino).toStrictEqual({
Expand All @@ -50,7 +49,7 @@ describe('MsgSetDelegationTransferReceivers', () => {
})
})

it.skip('generates proper web3Gw', () => {
it('generates proper web3Gw', () => {
const web3 = message.toWeb3Gw()

expect(web3).toStrictEqual({
Expand All @@ -77,7 +76,6 @@ describe('MsgSetDelegationTransferReceivers', () => {
expect(eip712TypedData).toStrictEqual(JSON.parse(txResponse.data))
})

// will be resolved in chain v1.17.1
it.skip('EIP712 v2', async () => {
const eip712TypedData = getEip712TypedDataV2(eip712Args)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,37 @@
import * as InjectiveExchangeV2TxPb from '@injectivelabs/core-proto-ts-v2/generated/injective/exchange/v2/tx_pb'
import { MsgBase } from '../../MsgBase.js'

export declare namespace MsgSetDelegationTransferReceivers {
export declare namespace MsgSetDelegationTransferReceiversV2 {
export interface Params {
sender: string
receivers: string[]
}

// Note: MsgSetDelegationTransferReceivers doesn't exist in v2 proto package yet
export type Proto = {
sender: string
receivers: string[]
}
export type Proto = InjectiveExchangeV2TxPb.MsgSetDelegationTransferReceivers
}

/**
* @deprecated no longer supported on chain
* @deprecated Delegation transfer receiver support was removed. This message is kept for backward compatibility.
* @category Messages
*/
export default class MsgSetDelegationTransferReceivers extends MsgBase<
MsgSetDelegationTransferReceivers.Params,
MsgSetDelegationTransferReceivers.Proto
export default class MsgSetDelegationTransferReceiversV2 extends MsgBase<
MsgSetDelegationTransferReceiversV2.Params,
MsgSetDelegationTransferReceiversV2.Proto
> {
static fromJSON(
params: MsgSetDelegationTransferReceivers.Params,
): MsgSetDelegationTransferReceivers {
return new MsgSetDelegationTransferReceivers(params)
params: MsgSetDelegationTransferReceiversV2.Params,
): MsgSetDelegationTransferReceiversV2 {
return new MsgSetDelegationTransferReceiversV2(params)
}

public toProto() {
const { params } = this

// Note: MsgSetDelegationTransferReceivers doesn't exist in v2 proto package yet
// Returning a plain object for now
const message = {
sender: params.sender,
receivers: params.receivers,
}
const message =
InjectiveExchangeV2TxPb.MsgSetDelegationTransferReceivers.create({
sender: params.sender,
receivers: params.receivers,
})

return message
}
Expand Down Expand Up @@ -82,8 +78,8 @@ export default class MsgSetDelegationTransferReceivers extends MsgBase<
}

public toBinary(): Uint8Array {
// Note: MsgSetDelegationTransferReceivers doesn't exist in v2 proto package yet
// Returning empty bytes for now
return new Uint8Array(0)
return InjectiveExchangeV2TxPb.MsgSetDelegationTransferReceivers.toBinary(
this.toProto(),
)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import snakecaseKeys from 'snakecase-keys'
import { EIP712Version } from '@injectivelabs/ts-types'
import { mockFactory, prepareEip712 } from '@injectivelabs/utils/test-utils'
import * as InjectiveExchangeV2ProposalPb from '@injectivelabs/core-proto-ts-v2/generated/injective/exchange/v2/proposal_pb'
import MsgUpdateDerivativeMarketV2 from './MsgUpdateDerivativeMarketV2.js'
import {
getEip712TypedData,
Expand Down Expand Up @@ -31,6 +32,9 @@ const protoParams = {
newInitialMarginRatio: '0.05',
newMaintenanceMarginRatio: '0.05',
newReduceMarginRatio: '0.05',
crossMarginEligibility:
InjectiveExchangeV2ProposalPb.CrossMarginEligibility
.CM_ELIGIBILITY_UNSPECIFIED,
}
const protoParamsAmino = snakecaseKeys(protoParams)
const message = MsgUpdateDerivativeMarketV2.fromJSON(params)
Expand All @@ -46,7 +50,6 @@ describe('MsgUpdateDerivativeMarketV2', () => {
newInitialMarginRatio: '50000000000000000',
newMaintenanceMarginRatio: '50000000000000000',
newReduceMarginRatio: '50000000000000000',
crossMarginEligibility: 0,
})
})

Expand All @@ -61,7 +64,6 @@ describe('MsgUpdateDerivativeMarketV2', () => {
newInitialMarginRatio: '50000000000000000',
newMaintenanceMarginRatio: '50000000000000000',
newReduceMarginRatio: '50000000000000000',
crossMarginEligibility: 0,
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export declare namespace MsgUpdateDerivativeMarketV2 {
export type Proto = InjectiveExchangeV2TxPb.MsgUpdateDerivativeMarket
}

const defaultCrossMarginEligibility =
InjectiveExchangeV2ProposalPb.CrossMarginEligibility
.CM_ELIGIBILITY_UNSPECIFIED

const createMessage = (params: MsgUpdateDerivativeMarketV2.Params) => {
const message = InjectiveExchangeV2TxPb.MsgUpdateDerivativeMarket.create({
admin: params.admin,
Expand All @@ -33,9 +37,7 @@ const createMessage = (params: MsgUpdateDerivativeMarketV2.Params) => {
newMaintenanceMarginRatio: params.newMaintenanceMarginRatio || '0',
newReduceMarginRatio: params.newReduceMarginRatio || '0',
crossMarginEligibility:
params.crossMarginEligibility ??
InjectiveExchangeV2ProposalPb.CrossMarginEligibility
.CM_ELIGIBILITY_UNSPECIFIED,
params.crossMarginEligibility ?? defaultCrossMarginEligibility,
})

return message
Expand Down Expand Up @@ -77,6 +79,7 @@ export default class MsgUpdateDerivativeMarketV2 extends MsgBase<
newReduceMarginRatio: toChainFormat(
initialParams.newReduceMarginRatio || '0',
).toFixed(),
crossMarginEligibility: initialParams.crossMarginEligibility,
} as MsgUpdateDerivativeMarketV2.Params

return createMessage(params)
Expand All @@ -103,6 +106,8 @@ export default class MsgUpdateDerivativeMarketV2 extends MsgBase<
new_initial_margin_ratio: params.newInitialMarginRatio,
new_maintenance_margin_ratio: params.newMaintenanceMarginRatio,
new_reduce_margin_ratio: params.newReduceMarginRatio,
cross_margin_eligibility:
params.crossMarginEligibility ?? defaultCrossMarginEligibility,
}

return {
Expand Down Expand Up @@ -162,6 +167,10 @@ export default class MsgUpdateDerivativeMarketV2 extends MsgBase<
params.newReduceMarginRatio || '0',
),
new_open_notional_cap: {},
cross_margin_eligibility:
InjectiveExchangeV2ProposalPb.CrossMarginEligibility[
params.crossMarginEligibility ?? defaultCrossMarginEligibility
],
}

return messageAdjusted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const params: MsgSubmitProposalPerpetualMarketLaunchV2['params'] = {
adminPermissions: 1,
},
reduceMarginRatio: '0.01',
crossMarginEligible: false,
},
proposer: mockFactory.injectiveAddress,
deposit: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export declare namespace MsgSubmitProposalPerpetualMarketLaunchV2 {
admin: string
adminPermissions: number
}
crossMarginEligible: boolean
}
proposer: string
deposit: {
Expand Down Expand Up @@ -71,6 +72,7 @@ const createPerpetualMarketLaunch = (
minQuantityTickSize: params.market.minQuantityTickSize,
minNotional: params.market.minNotional,
reduceMarginRatio: params.market.reduceMarginRatio,
crossMarginEligibility: params.market.crossMarginEligible,
}

if (params.market.adminInfo) {
Expand Down Expand Up @@ -127,6 +129,7 @@ export default class MsgSubmitProposalPerpetualMarketLaunchV2 extends MsgBase<
reduceMarginRatio: toChainFormat(
initialParams.market.reduceMarginRatio,
).toFixed(),
crossMarginEligibility: initialParams.market.crossMarginEligible,
},
}

Expand Down Expand Up @@ -188,6 +191,7 @@ export default class MsgSubmitProposalPerpetualMarketLaunchV2 extends MsgBase<
admin_info: content.adminInfo || null,
reduce_margin_ratio: content.reduceMarginRatio,
open_notional_cap: { uncapped: {} },
cross_margin_eligible: content.crossMarginEligible,
},
},
initial_deposit: [
Expand Down Expand Up @@ -253,6 +257,7 @@ export default class MsgSubmitProposalPerpetualMarketLaunchV2 extends MsgBase<
params.market.reduceMarginRatio,
).toFixed(),
open_notional_cap: { uncapped: {} },
cross_margin_eligible: params.market.crossMarginEligible,
},
},
}
Expand Down Expand Up @@ -302,6 +307,7 @@ export default class MsgSubmitProposalPerpetualMarketLaunchV2 extends MsgBase<
params.market.reduceMarginRatio,
),
open_notional_cap: { uncapped: {} },
cross_margin_eligible: params.market.crossMarginEligible,
},
}

Expand Down
4 changes: 2 additions & 2 deletions packages/sdk-ts/src/core/modules/msgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ import type MsgCreateBinaryOptionsLimitOrder from './exchange/msgs/MsgCreateBina
import type MsgAdminUpdateBinaryOptionsMarket from './exchange/msgs/MsgAdminUpdateBinaryOptionsMarket.js'
import type MsgBatchCancelBinaryOptionsOrders from './exchange/msgs/MsgBatchCancelBinaryOptionsOrders.js'
import type MsgCreateBinaryOptionsMarketOrder from './exchange/msgs/MsgCreateBinaryOptionsMarketOrder.js'
import type MsgSetDelegationTransferReceivers from './exchange/msgs/MsgSetDelegationTransferReceivers.js'
import type MsgSetDelegationTransferReceiversV2 from './exchange/msgs/MsgSetDelegationTransferReceiversV2.js'

export type AuctionMsgs = MsgBid
export type IbcMsgs = MsgTransfer
Expand Down Expand Up @@ -119,11 +119,11 @@ export type ExchangeV1Msgs =
| MsgAdminUpdateBinaryOptionsMarket
| MsgBatchCancelBinaryOptionsOrders
| MsgCreateBinaryOptionsMarketOrder
| MsgSetDelegationTransferReceivers
export type ExchangeV2Msgs =
| MsgUpdateSpotMarketV2
| MsgCancelPostOnlyModeV2
| MsgUpdateDerivativeMarketV2
| MsgSetDelegationTransferReceiversV2
export type InsuranceMsgs =
| MsgUnderwrite
| MsgRequestRedemption
Expand Down
Loading