-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ica/icq api and models definition
- Loading branch information
Showing
9 changed files
with
364 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { Params as HostParams } from '@terra-money/terra.proto/ibc/applications/interchain_accounts/host/v1/host'; | ||
import { Params as ControllerParams } from '@terra-money/terra.proto/ibc/applications/interchain_accounts/controller/v1/controller'; | ||
import { APIParams } from '../APIRequester'; | ||
import { LCDClient } from '../LCDClient'; | ||
import { BaseAPI } from './BaseAPI'; | ||
import { AccAddress } from 'core'; | ||
|
||
export class ICAv1API extends BaseAPI { | ||
constructor(public lcd: LCDClient) { | ||
super(lcd.apiRequesters, lcd.config); | ||
} | ||
|
||
/** | ||
* Query interchain account host module params | ||
* | ||
* @tags Query | ||
* @name params | ||
* @request GET:/ibc/apps/interchain_accounts/host/v1/params | ||
*/ | ||
public async hostParams(chainId: string, params: Partial<APIParams> = {}) { | ||
return this.getReqFromChainID(chainId).get<{ params: HostParams }>( | ||
`/ibc/apps/interchain_accounts/host/v1/params`, | ||
params | ||
); | ||
} | ||
|
||
/** | ||
* Query interchain account controller module params | ||
* | ||
* @tags Query | ||
* @name params | ||
* @request GET:/ibc/apps/interchain_accounts/controller/v1/params | ||
*/ | ||
public async controllerParams( | ||
chainId: string, | ||
params: Partial<APIParams> = {} | ||
) { | ||
return this.getReqFromChainID(chainId).get<{ params: ControllerParams }>( | ||
`/ibc/apps/interchain_accounts/controller/v1/params`, | ||
params | ||
); | ||
} | ||
|
||
/** | ||
* Returns the interchain account address for a given owner address on a given connection | ||
* | ||
* @tags Query | ||
* @name params | ||
* @request GET:/ibc/apps/interchain_accounts/controller/v1/owners/${ownerAddr}/connections/${connectionId} | ||
*/ | ||
public async controllerAccountAddress( | ||
ownerAddr: AccAddress, | ||
connectionId: string, | ||
params: Partial<APIParams> = {} | ||
) { | ||
return this.getReqFromAddress(ownerAddr).get<{ params: ControllerParams }>( | ||
`/ibc/apps/interchain_accounts/controller/v1/owners/${ownerAddr}/connections/${connectionId}`, | ||
params | ||
); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Params } from '@terra-money/terra.proto/icq/v1/icq'; | ||
import { APIParams } from '../APIRequester'; | ||
import { LCDClient } from '../LCDClient'; | ||
import { BaseAPI } from './BaseAPI'; | ||
|
||
export class ICQv1API extends BaseAPI { | ||
constructor(public lcd: LCDClient) { | ||
super(lcd.apiRequesters, lcd.config); | ||
} | ||
|
||
/** | ||
* Query all parameters associated with the icq module. | ||
* | ||
* @tags Query | ||
* @name params | ||
* @summary Query icq module params | ||
* @request GET:/async-icq/v1/params | ||
*/ | ||
public async params(chainId: string, params: Partial<APIParams> = {}) { | ||
return this.getReqFromChainID(chainId).get<{ params: Params }>( | ||
`/async-icq/v1/params`, | ||
params | ||
); | ||
} | ||
} |
This file contains 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
119 changes: 119 additions & 0 deletions
119
src/core/ica/controller/v1/msgs/MsgRegisterInterchainAccount.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
import { AccAddress } from '../../../../bech32'; | ||
import { Any } from '@terra-money/legacy.proto/google/protobuf/any'; | ||
import { JSONSerializable } from '../../../../../util/json'; | ||
import { MsgRegisterInterchainAccount as MsgRegisterInterchainAccount_pb } from '@terra-money/terra.proto/ibc/applications/interchain_accounts/controller/v1/tx'; | ||
|
||
/** | ||
* A basic message for sending [[Coins]] between Terra accounts. | ||
*/ | ||
export class MsgRegisterInterchainAccount extends JSONSerializable< | ||
MsgRegisterInterchainAccount.Amino, | ||
MsgRegisterInterchainAccount.Data, | ||
MsgRegisterInterchainAccount.Proto | ||
> { | ||
/** | ||
* @param owner sender's address | ||
* @param connectionId ibc connection id | ||
* @param version of the interchain account | ||
*/ | ||
constructor( | ||
public owner: AccAddress, | ||
public connectionId: string, | ||
public version: string | ||
) { | ||
super(); | ||
} | ||
|
||
public static fromAmino( | ||
data: MsgRegisterInterchainAccount.Amino, | ||
_?: boolean | ||
): MsgRegisterInterchainAccount { | ||
_; | ||
data; | ||
throw new Error('Amino not supported on MsgRegisterInterchainAccount'); | ||
} | ||
|
||
public toAmino(_?: boolean): MsgRegisterInterchainAccount.Amino { | ||
_; | ||
throw new Error('Amino not supported on MsgRegisterInterchainAccount'); | ||
} | ||
|
||
public static fromData( | ||
data: MsgRegisterInterchainAccount.Data, | ||
_?: boolean | ||
): MsgRegisterInterchainAccount { | ||
_; | ||
const { owner, connection_id, version } = data; | ||
|
||
return new MsgRegisterInterchainAccount(owner, connection_id, version); | ||
} | ||
|
||
public toData(_?: boolean): MsgRegisterInterchainAccount.Data { | ||
_; | ||
const { owner, connectionId, version } = this; | ||
return { | ||
'@type': | ||
'/ibc.applications.interchain_accounts.controller.v1.MsgRegisterInterchainAccount', | ||
owner: owner, | ||
connection_id: connectionId, | ||
version: version, | ||
}; | ||
} | ||
|
||
public static fromProto( | ||
proto: MsgRegisterInterchainAccount.Proto, | ||
_?: boolean | ||
): MsgRegisterInterchainAccount { | ||
_; | ||
return new MsgRegisterInterchainAccount( | ||
proto.owner, | ||
proto.connectionId, | ||
proto.version | ||
); | ||
} | ||
|
||
public toProto(_?: boolean): MsgRegisterInterchainAccount.Proto { | ||
_; | ||
const { owner, connectionId, version } = this; | ||
return MsgRegisterInterchainAccount_pb.fromPartial({ | ||
owner, | ||
connectionId, | ||
version, | ||
}); | ||
} | ||
|
||
public packAny(isClassic?: boolean): Any { | ||
return Any.fromPartial({ | ||
typeUrl: | ||
'/ibc.applications.interchain_accounts.controller.v1.MsgRegisterInterchainAccount', | ||
value: MsgRegisterInterchainAccount_pb.encode( | ||
this.toProto(isClassic) | ||
).finish(), | ||
}); | ||
} | ||
|
||
public static unpackAny( | ||
msgAny: Any, | ||
isClassic?: boolean | ||
): MsgRegisterInterchainAccount { | ||
return MsgRegisterInterchainAccount.fromProto( | ||
MsgRegisterInterchainAccount_pb.decode(msgAny.value), | ||
isClassic | ||
); | ||
} | ||
} | ||
|
||
export namespace MsgRegisterInterchainAccount { | ||
export interface Amino { | ||
value: {}; | ||
} | ||
|
||
export interface Data { | ||
'@type': '/ibc.applications.interchain_accounts.controller.v1.MsgRegisterInterchainAccount'; | ||
owner: AccAddress; | ||
connection_id: string; | ||
version: string; | ||
} | ||
|
||
export type Proto = MsgRegisterInterchainAccount_pb; | ||
} |
Oops, something went wrong.