Skip to content

Commit

Permalink
Merge pull request #80 from initia-labs/feat/apply-updates
Browse files Browse the repository at this point in the history
Apply updates from core
  • Loading branch information
joon9823 authored Sep 13, 2024
2 parents d9c4bea + 936220e commit d8750e1
Show file tree
Hide file tree
Showing 33 changed files with 1,301 additions and 365 deletions.
36 changes: 18 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@initia/initia.js",
"version": "0.2.14",
"version": "0.2.15",
"description": "The JavaScript SDK for Initia",
"license": "Apache-2.0",
"author": "Initia Foundation",
Expand Down Expand Up @@ -59,8 +59,8 @@
"webpack-cli": "^4.10.0"
},
"dependencies": {
"@initia/initia.proto": "^0.2.1",
"@initia/opinit.proto": "^0.0.8",
"@initia/initia.proto": "^0.2.2",
"@initia/opinit.proto": "^0.0.9",
"@ledgerhq/hw-transport": "^6.27.12",
"@ledgerhq/hw-transport-webhid": "^6.27.12",
"@ledgerhq/hw-transport-webusb": "^6.27.12",
Expand Down
8 changes: 8 additions & 0 deletions src/client/lcd/api/EvmAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ export class EvmAPI extends BaseAPI {
.then((d) => d.value)
}

public async erc20Factory(params: APIParams = {}): Promise<string> {
return this.c
.get<{
address: string
}>(`/minievm/evm/v1/contracts/erc20_factory`, params)
.then((d) => d.address)
}

public async contractAddrByDenom(
denom: string,
params: APIParams = {}
Expand Down
32 changes: 19 additions & 13 deletions src/client/lcd/api/IbcPermAPI.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,38 @@
import { BaseAPI } from './BaseAPI'
import { APIParams, Pagination, PaginationOptions } from '../APIRequester'

export interface PermissionedRelayers {
export interface ChannelState {
port_id: string
channel_id: string
halt_state: HaltState
relayers: string[]
}

export interface HaltState {
halted: boolean
halted_by: string
}

export class IbcPermAPI extends BaseAPI {
public async relayers(
public async channelStates(
params: Partial<PaginationOptions & APIParams> = {}
): Promise<[PermissionedRelayers[], Pagination]> {
): Promise<[ChannelState[], Pagination]> {
return this.c
.get<{
permissioned_relayers: PermissionedRelayers[]
channel_states: ChannelState[]
pagination: Pagination
}>(`/ibc/apps/perm/v1/relayers`, params)
.then((d) => [d.permissioned_relayers, d.pagination])
}>(`/ibc/apps/perm/v1/channel_states`, params)
.then((d) => [d.channel_states, d.pagination])
}

public async relayersByChannel(
port_id: string,
channel_id: string
): Promise<PermissionedRelayers> {
public async channelState(
channelId: string,
portId: string
): Promise<ChannelState> {
return this.c
.get<{
permissioned_relayers: PermissionedRelayers
}>(`/ibc/apps/perm/v1/relayers/${port_id}/${channel_id}`)
.then((d) => d.permissioned_relayers)
channel_state: ChannelState
}>(`/ibc/apps/perm/v1/channel_states/${channelId}/${portId}`)
.then((d) => d.channel_state)
}
}
27 changes: 27 additions & 0 deletions src/client/lcd/api/OpchildAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,33 @@ export class OpchildAPI extends BaseAPI {
.then((d) => BridgeInfo.fromData(d.bridge_info))
}

public async nextL1Sequence(params: APIParams = {}): Promise<number> {
return this.c
.get<{
next_l1_sequence: string
}>(`/opinit/opchild/v1/next_l1_sequence`, params)
.then((d) => parseInt(d.next_l1_sequence))
}

public async nextL2Sequence(params: APIParams = {}): Promise<number> {
return this.c
.get<{
next_l2_sequence: string
}>(`/opinit/opchild/v1/next_l2_sequence`, params)
.then((d) => parseInt(d.next_l2_sequence))
}

public async baseDenom(
denom: string,
params: APIParams = {}
): Promise<string> {
return this.c
.get<{
base_denom: string
}>(`/opinit/opchild/v1/base_denom/${denom}`, params)
.then((d) => d.base_denom)
}

public async parameters(params: APIParams = {}): Promise<OpchildParams> {
return this.c
.get<{ params: OpchildParams.Data }>(`/opinit/opchild/v1/params`, params)
Expand Down
48 changes: 47 additions & 1 deletion src/client/lcd/api/OphostAPI.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { BaseAPI } from './BaseAPI'
import { APIParams, Pagination, PaginationOptions } from '../APIRequester'
import { OphostParams, Output, BridgeInfo } from '../../../core'
import {
OphostParams,
Output,
BridgeInfo,
BatchInfoWithOutput,
} from '../../../core'

export interface TokenPair {
l1_denom: string
Expand Down Expand Up @@ -135,6 +140,47 @@ export class OphostAPI extends BaseAPI {
}))
}

public async withdrawalClaimed(
bridgeId: number,
withdrawalHash: string,
params: APIParams = {}
): Promise<boolean> {
return this.c
.get<{
claimed: boolean
}>(`/opinit/ophost/v1/bridges/${bridgeId}/withdrawals/claimed/by_hash`, {
...params,
withdrawal_hash: Buffer.from(withdrawalHash, 'hex').toString('base64'),
})
.then((d) => d.claimed)
}

public async nextL1Sequence(
bridgeId: number,
params: APIParams = {}
): Promise<number> {
return this.c
.get<{
next_l1_sequence: string
}>(`/opinit/ophost/v1/bridges/${bridgeId}/next_l1_sequence`, params)
.then((d) => parseInt(d.next_l1_sequence))
}

public async batchInfos(
bridgeId: number,
params: Partial<PaginationOptions & APIParams> = {}
): Promise<[BatchInfoWithOutput[], Pagination]> {
return this.c
.get<{
batch_infos: BatchInfoWithOutput.Data[]
pagination: Pagination
}>(`/opinit/ophost/v1/bridges/${bridgeId}/batch_infos`, params)
.then((d) => [
d.batch_infos.map((info) => BatchInfoWithOutput.fromData(info)),
d.pagination,
])
}

public async parameters(params: APIParams = {}): Promise<OphostParams> {
return this.c
.get<{ params: OphostParams.Data }>(`/opinit/opchild/v1/params`, params)
Expand Down
Loading

0 comments on commit d8750e1

Please sign in to comment.