-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add ibc protobufs and
MsgIbcTransfer
model (#7)
* feat: ibc protobuf and MsgTransfer model * chore: generate protobufs * refactor: rename to MsgIbcTransfer * fix: toAmino conversion * fix: amino big ints * fix: convert names to pascal case --------- Co-authored-by: Aaron Choo <choozy.aaron@gmail.com>
- Loading branch information
Showing
85 changed files
with
16,824 additions
and
106 deletions.
There are no files selected for viewing
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,46 @@ | ||
import { PlainMessage } from "@bufbuild/protobuf"; | ||
import { IbcApplicationsTransferV1MsgTransfer as ProtoMsgIbcTransfer } from "cosmes/protobufs"; | ||
|
||
import { DeepPrettify } from "../../typeutils/prettify"; | ||
import { Adapter } from "./Adapter"; | ||
|
||
type Data = DeepPrettify<PlainMessage<ProtoMsgIbcTransfer>>; | ||
|
||
export class MsgIbcTransfer implements Adapter { | ||
private readonly data: Data; | ||
|
||
constructor(data: Data) { | ||
this.data = data; | ||
} | ||
|
||
public toProto() { | ||
return new ProtoMsgIbcTransfer(this.data); | ||
} | ||
|
||
public toAmino() { | ||
return { | ||
type: "cosmos-sdk/MsgTransfer", | ||
value: { | ||
source_port: this.data.sourcePort, | ||
source_channel: this.data.sourceChannel, | ||
token: this.data.token, | ||
sender: this.data.sender, | ||
receiver: this.data.receiver, | ||
/** | ||
* Protobuf type is optional, but Amino type is non-optional. | ||
* | ||
* @see https://github.com/cosmos/cosmjs/blob/358260bff71c9d3e7ad6644fcf64dc00325cdfb9/packages/stargate/src/modules/ibc/aminomessages.ts#L16-L42 | ||
*/ | ||
timeout_height: this.data.timeoutHeight | ||
? { | ||
revision_number: | ||
this.data.timeoutHeight.revisionNumber.toString(), | ||
revision_height: | ||
this.data.timeoutHeight.revisionHeight.toString(), | ||
} | ||
: {}, | ||
timeout_timestamp: this.data.timeoutTimestamp.toString(), | ||
}, | ||
}; | ||
} | ||
} |
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,134 @@ | ||
// @generated by protoc-gen-es v1.2.0 with parameter "target=ts" | ||
// @generated from file capability/v1/capability.proto (package capability.v1, syntax proto3) | ||
/* eslint-disable */ | ||
// @ts-nocheck | ||
|
||
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; | ||
import { Message, proto3, protoInt64 } from "@bufbuild/protobuf"; | ||
|
||
/** | ||
* Capability defines an implementation of an object capability. The index | ||
* provided to a Capability must be globally unique. | ||
* | ||
* @generated from message capability.v1.Capability | ||
*/ | ||
export class Capability extends Message<Capability> { | ||
/** | ||
* @generated from field: uint64 index = 1; | ||
*/ | ||
index = protoInt64.zero; | ||
|
||
constructor(data?: PartialMessage<Capability>) { | ||
super(); | ||
proto3.util.initPartial(data, this); | ||
} | ||
|
||
static readonly runtime: typeof proto3 = proto3; | ||
static readonly typeName = "capability.v1.Capability"; | ||
static readonly fields: FieldList = proto3.util.newFieldList(() => [ | ||
{ no: 1, name: "index", kind: "scalar", T: 4 /* ScalarType.UINT64 */ }, | ||
]); | ||
|
||
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Capability { | ||
return new Capability().fromBinary(bytes, options); | ||
} | ||
|
||
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Capability { | ||
return new Capability().fromJson(jsonValue, options); | ||
} | ||
|
||
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Capability { | ||
return new Capability().fromJsonString(jsonString, options); | ||
} | ||
|
||
static equals(a: Capability | PlainMessage<Capability> | undefined, b: Capability | PlainMessage<Capability> | undefined): boolean { | ||
return proto3.util.equals(Capability, a, b); | ||
} | ||
} | ||
|
||
/** | ||
* Owner defines a single capability owner. An owner is defined by the name of | ||
* capability and the module name. | ||
* | ||
* @generated from message capability.v1.Owner | ||
*/ | ||
export class Owner extends Message<Owner> { | ||
/** | ||
* @generated from field: string module = 1; | ||
*/ | ||
module = ""; | ||
|
||
/** | ||
* @generated from field: string name = 2; | ||
*/ | ||
name = ""; | ||
|
||
constructor(data?: PartialMessage<Owner>) { | ||
super(); | ||
proto3.util.initPartial(data, this); | ||
} | ||
|
||
static readonly runtime: typeof proto3 = proto3; | ||
static readonly typeName = "capability.v1.Owner"; | ||
static readonly fields: FieldList = proto3.util.newFieldList(() => [ | ||
{ no: 1, name: "module", kind: "scalar", T: 9 /* ScalarType.STRING */ }, | ||
{ no: 2, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */ }, | ||
]); | ||
|
||
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Owner { | ||
return new Owner().fromBinary(bytes, options); | ||
} | ||
|
||
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Owner { | ||
return new Owner().fromJson(jsonValue, options); | ||
} | ||
|
||
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Owner { | ||
return new Owner().fromJsonString(jsonString, options); | ||
} | ||
|
||
static equals(a: Owner | PlainMessage<Owner> | undefined, b: Owner | PlainMessage<Owner> | undefined): boolean { | ||
return proto3.util.equals(Owner, a, b); | ||
} | ||
} | ||
|
||
/** | ||
* CapabilityOwners defines a set of owners of a single Capability. The set of | ||
* owners must be unique. | ||
* | ||
* @generated from message capability.v1.CapabilityOwners | ||
*/ | ||
export class CapabilityOwners extends Message<CapabilityOwners> { | ||
/** | ||
* @generated from field: repeated capability.v1.Owner owners = 1; | ||
*/ | ||
owners: Owner[] = []; | ||
|
||
constructor(data?: PartialMessage<CapabilityOwners>) { | ||
super(); | ||
proto3.util.initPartial(data, this); | ||
} | ||
|
||
static readonly runtime: typeof proto3 = proto3; | ||
static readonly typeName = "capability.v1.CapabilityOwners"; | ||
static readonly fields: FieldList = proto3.util.newFieldList(() => [ | ||
{ no: 1, name: "owners", kind: "message", T: Owner, repeated: true }, | ||
]); | ||
|
||
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): CapabilityOwners { | ||
return new CapabilityOwners().fromBinary(bytes, options); | ||
} | ||
|
||
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): CapabilityOwners { | ||
return new CapabilityOwners().fromJson(jsonValue, options); | ||
} | ||
|
||
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): CapabilityOwners { | ||
return new CapabilityOwners().fromJsonString(jsonString, options); | ||
} | ||
|
||
static equals(a: CapabilityOwners | PlainMessage<CapabilityOwners> | undefined, b: CapabilityOwners | PlainMessage<CapabilityOwners> | undefined): boolean { | ||
return proto3.util.equals(CapabilityOwners, a, b); | ||
} | ||
} | ||
|
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,108 @@ | ||
// @generated by protoc-gen-es v1.2.0 with parameter "target=ts" | ||
// @generated from file capability/v1/genesis.proto (package capability.v1, syntax proto3) | ||
/* eslint-disable */ | ||
// @ts-nocheck | ||
|
||
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; | ||
import { Message, proto3, protoInt64 } from "@bufbuild/protobuf"; | ||
import { CapabilityOwners } from "./capability_pb.js"; | ||
|
||
/** | ||
* GenesisOwners defines the capability owners with their corresponding index. | ||
* | ||
* @generated from message capability.v1.GenesisOwners | ||
*/ | ||
export class GenesisOwners extends Message<GenesisOwners> { | ||
/** | ||
* index is the index of the capability owner. | ||
* | ||
* @generated from field: uint64 index = 1; | ||
*/ | ||
index = protoInt64.zero; | ||
|
||
/** | ||
* index_owners are the owners at the given index. | ||
* | ||
* @generated from field: capability.v1.CapabilityOwners index_owners = 2; | ||
*/ | ||
indexOwners?: CapabilityOwners; | ||
|
||
constructor(data?: PartialMessage<GenesisOwners>) { | ||
super(); | ||
proto3.util.initPartial(data, this); | ||
} | ||
|
||
static readonly runtime: typeof proto3 = proto3; | ||
static readonly typeName = "capability.v1.GenesisOwners"; | ||
static readonly fields: FieldList = proto3.util.newFieldList(() => [ | ||
{ no: 1, name: "index", kind: "scalar", T: 4 /* ScalarType.UINT64 */ }, | ||
{ no: 2, name: "index_owners", kind: "message", T: CapabilityOwners }, | ||
]); | ||
|
||
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GenesisOwners { | ||
return new GenesisOwners().fromBinary(bytes, options); | ||
} | ||
|
||
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): GenesisOwners { | ||
return new GenesisOwners().fromJson(jsonValue, options); | ||
} | ||
|
||
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): GenesisOwners { | ||
return new GenesisOwners().fromJsonString(jsonString, options); | ||
} | ||
|
||
static equals(a: GenesisOwners | PlainMessage<GenesisOwners> | undefined, b: GenesisOwners | PlainMessage<GenesisOwners> | undefined): boolean { | ||
return proto3.util.equals(GenesisOwners, a, b); | ||
} | ||
} | ||
|
||
/** | ||
* GenesisState defines the capability module's genesis state. | ||
* | ||
* @generated from message capability.v1.GenesisState | ||
*/ | ||
export class GenesisState extends Message<GenesisState> { | ||
/** | ||
* index is the capability global index. | ||
* | ||
* @generated from field: uint64 index = 1; | ||
*/ | ||
index = protoInt64.zero; | ||
|
||
/** | ||
* owners represents a map from index to owners of the capability index | ||
* index key is string to allow amino marshalling. | ||
* | ||
* @generated from field: repeated capability.v1.GenesisOwners owners = 2; | ||
*/ | ||
owners: GenesisOwners[] = []; | ||
|
||
constructor(data?: PartialMessage<GenesisState>) { | ||
super(); | ||
proto3.util.initPartial(data, this); | ||
} | ||
|
||
static readonly runtime: typeof proto3 = proto3; | ||
static readonly typeName = "capability.v1.GenesisState"; | ||
static readonly fields: FieldList = proto3.util.newFieldList(() => [ | ||
{ no: 1, name: "index", kind: "scalar", T: 4 /* ScalarType.UINT64 */ }, | ||
{ no: 2, name: "owners", kind: "message", T: GenesisOwners, repeated: true }, | ||
]); | ||
|
||
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GenesisState { | ||
return new GenesisState().fromBinary(bytes, options); | ||
} | ||
|
||
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): GenesisState { | ||
return new GenesisState().fromJson(jsonValue, options); | ||
} | ||
|
||
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): GenesisState { | ||
return new GenesisState().fromJsonString(jsonString, options); | ||
} | ||
|
||
static equals(a: GenesisState | PlainMessage<GenesisState> | undefined, b: GenesisState | PlainMessage<GenesisState> | undefined): boolean { | ||
return proto3.util.equals(GenesisState, a, b); | ||
} | ||
} | ||
|
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
Oops, something went wrong.