Skip to content

Commit

Permalink
chore: updates per core-proto-ts
Browse files Browse the repository at this point in the history
  • Loading branch information
shane-moore committed Jul 29, 2024
1 parent 8bd257d commit 60f1703
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion packages/sdk-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@cosmjs/proto-signing": "^0.32.3",
"@cosmjs/stargate": "^0.32.3",
"@ethersproject/bytes": "^5.7.0",
"@injectivelabs/core-proto-ts": "0.0.27",
"@injectivelabs/core-proto-ts": "0.0.28",
"@injectivelabs/dmm-proto-ts": "1.0.20",
"@injectivelabs/exceptions": "^1.14.13-dev.3",
"@injectivelabs/grpc-web": "^0.0.1",
Expand Down
8 changes: 4 additions & 4 deletions packages/sdk-ts/src/client/chain/grpc/ChainGrpcIbcApi.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getNetworkEndpoints, Network } from '@injectivelabs/networks'
import { ChainGrpcIbcApi } from './ChainGrpcIbcApi'
import { sha256 } from '../../../utils/crypto'
import { fromUtf8 } from '../../../utils/utf8'
import { IbcApplicationsTransferV2Token } from '@injectivelabs/core-proto-ts'
import { IbcApplicationsTransferV1Transfer } from '@injectivelabs/core-proto-ts'

const endpoints = getNetworkEndpoints(Network.MainnetSentry)
const chainGrpcIbcApi = new ChainGrpcIbcApi(endpoints.grpc)
Expand All @@ -17,7 +17,7 @@ describe('ChainGrpcIbcApi', () => {

expect(response).toBeDefined()
expect(response).toEqual(
expect.objectContaining<IbcApplicationsTransferV2Token.Denom[]>(
expect.objectContaining<IbcApplicationsTransferV1Transfer.DenomTrace[]>(
response,
),
)
Expand All @@ -30,13 +30,13 @@ describe('ChainGrpcIbcApi', () => {
try {
const [trace] = await chainGrpcIbcApi.fetchDenomsTrace()
const ibcHash = Buffer.from(
sha256(fromUtf8(`${trace.trace}/${trace.base}`)),
sha256(fromUtf8(`${trace.path}/${trace.baseDenom}`)),
).toString('hex')
const response = await chainGrpcIbcApi.fetchDenomTrace(ibcHash)

expect(response).toBeDefined()
expect(response).toEqual(
expect.objectContaining<IbcApplicationsTransferV2Token.Denom>(
expect.objectContaining<IbcApplicationsTransferV1Transfer.DenomTrace>(
response,
),
)
Expand Down
26 changes: 13 additions & 13 deletions packages/sdk-ts/src/client/chain/grpc/ChainGrpcIbcApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
GrpcUnaryRequestException,
UnspecifiedErrorCode,
} from '@injectivelabs/exceptions'
import { IbcApplicationsTransferV2Query } from '@injectivelabs/core-proto-ts'
import { IbcApplicationsTransferV1Query } from '@injectivelabs/core-proto-ts'
import BaseGrpcConsumer from '../../base/BaseGrpcConsumer'
import { ChainModule } from '../types'
import { PaginationOption } from '../../../types/pagination'
Expand All @@ -14,31 +14,31 @@ import { paginationRequestFromPagination } from '../../../utils/pagination'
export class ChainGrpcIbcApi extends BaseGrpcConsumer {
protected module: string = ChainModule.Ibc

protected client: IbcApplicationsTransferV2Query.QueryV2ClientImpl
protected client: IbcApplicationsTransferV1Query.QueryClientImpl

constructor(endpoint: string) {
super(endpoint)

this.client = new IbcApplicationsTransferV2Query.QueryV2ClientImpl(
this.client = new IbcApplicationsTransferV1Query.QueryClientImpl(
this.getGrpcWebImpl(endpoint),
)
}

async fetchDenomTrace(hash: string) {
const request =
IbcApplicationsTransferV2Query.QueryDenomRequest.create()
IbcApplicationsTransferV1Query.QueryDenomTraceRequest.create()

request.hash = hash

try {
const response =
await this.retry<IbcApplicationsTransferV2Query.QueryDenomResponse>(
() => this.client.Denom(request, this.metadata),
await this.retry<IbcApplicationsTransferV1Query.QueryDenomTraceResponse>(
() => this.client.DenomTrace(request, this.metadata),
)

return response.denom!
return response.denomTrace!
} catch (e: any) {
if (e instanceof IbcApplicationsTransferV2Query.GrpcWebError) {
if (e instanceof IbcApplicationsTransferV1Query.GrpcWebError) {
throw new GrpcUnaryRequestException(new Error(e.toString()), {
code: e.code,
context: 'DenomTrace',
Expand All @@ -56,7 +56,7 @@ export class ChainGrpcIbcApi extends BaseGrpcConsumer {

async fetchDenomsTrace(pagination?: PaginationOption) {
const request =
IbcApplicationsTransferV2Query.QueryDenomsRequest.create()
IbcApplicationsTransferV1Query.QueryDenomTracesRequest.create()

const paginationForRequest = paginationRequestFromPagination(pagination)

Expand All @@ -66,13 +66,13 @@ export class ChainGrpcIbcApi extends BaseGrpcConsumer {

try {
const response =
await this.retry<IbcApplicationsTransferV2Query.QueryDenomsResponse>(
() => this.client.Denoms(request, this.metadata),
await this.retry<IbcApplicationsTransferV1Query.QueryDenomTracesResponse>(
() => this.client.DenomTraces(request, this.metadata),
)

return response.denoms
return response.denomTraces
} catch (e: any) {
if (e instanceof IbcApplicationsTransferV2Query.GrpcWebError) {
if (e instanceof IbcApplicationsTransferV1Query.GrpcWebError) {
throw new GrpcUnaryRequestException(new Error(e.toString()), {
code: e.code,
context: 'DenomTraces',
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-ts/src/core/modules/ibc/msgs/MsgTransfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ export default class MsgTransfer extends MsgBase<
if (params.height) {
const timeoutHeight = IbcCoreClientV1Client.Height.create()

timeoutHeight.revisionHeight = params.height.revisionHeight.toString()
timeoutHeight.revisionNumber = params.height.revisionNumber.toString()
timeoutHeight.revisionHeight = params.height.revisionHeight.toString()

message.timeoutHeight = timeoutHeight
}
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2174,10 +2174,10 @@
resolved "https://registry.npmjs.org/@hutson/parse-repository-url/-/parse-repository-url-3.0.2.tgz#98c23c950a3d9b6c8f0daed06da6c3af06981340"
integrity sha512-H9XAx3hc0BQHY6l+IFSWHDySypcXsvsuLhgYLUGywmJ5pswRVQJUHpOsobnLYp2ZUaUlKiKDrgWWhosOwAEM8Q==

"@injectivelabs/core-proto-ts@0.0.27":
version "0.0.27"
resolved "https://registry.yarnpkg.com/@injectivelabs/core-proto-ts/-/core-proto-ts-0.0.27.tgz#c925607c77cf226e39b55f71fb695e710d2b4dbd"
integrity sha512-jGGjBp0Jp051S5nnvkzgfceHGwUlS05DsbC7coYI5MjFpoWnNKN4DXJb1vo3kYvWUMTYUjLEUIB+3hC1t4SuDA==
"@injectivelabs/core-proto-ts@0.0.28":
version "0.0.28"
resolved "https://registry.yarnpkg.com/@injectivelabs/core-proto-ts/-/core-proto-ts-0.0.28.tgz#87dde07027c0839fc27a29c19e54275c68538738"
integrity sha512-AHzRa8Us48HjciHS9KmZEgLuMBByeujZSyZv8xHOZku97pYapO7grIaLtLH41iMSD0bOAWqfV1SBgywYkOrDug==
dependencies:
"@injectivelabs/grpc-web" "^0.0.1"
google-protobuf "^3.14.0"
Expand Down

0 comments on commit 60f1703

Please sign in to comment.