Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade telescope v1 and regen #78

Merged
merged 3 commits into from
Jan 8, 2024
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
**/node_modules
coverage
packages/**/build
packages/**/main
packages/**/module
packages/**/main
2 changes: 1 addition & 1 deletion packages/osmo-query/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pids
*.seed

# dist
dist
dist
mjs
main
module
Expand Down
2 changes: 1 addition & 1 deletion packages/osmo-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"@confio/relayer": "0.7.0",
"@cosmjs/cosmwasm-stargate": "0.29.4",
"@cosmjs/crypto": "0.29.4",
"@cosmology/telescope": "0.102.0",
"@cosmology/telescope": "1.4.3",
"@protobufs/confio": "^0.0.6",
"@protobufs/cosmos": "^0.1.0",
"@protobufs/cosmos_proto": "^0.0.10",
Expand Down
5 changes: 3 additions & 2 deletions packages/osmo-query/scripts/codegen.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ telescope({
protoDirs,
outPath,
options: {

env: "v-next",
removeUnusedImports: true,
tsDisable: {
patterns: ['**/*amino.ts', '**/*registry.ts']
Expand Down Expand Up @@ -109,7 +109,8 @@ telescope({
},
rpcClients: {
enabled: true,
camelCase: true
camelCase: true,
useConnectComet: true
},
reactQuery: {
enabled: true
Expand Down
4 changes: 2 additions & 2 deletions packages/osmo-query/src/codegen/amino/bundle.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as _41 from "./amino";
import * as _72 from "./amino";
export const amino = {
..._41
..._72
};
114 changes: 88 additions & 26 deletions packages/osmo-query/src/codegen/binary.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file and any referenced files were automatically generated by @cosmology/telescope@0.102.0
* This file and any referenced files were automatically generated by @cosmology/telescope@1.4.3
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or yarn proto command to regenerate this bundle.
*/
Expand Down Expand Up @@ -68,14 +68,38 @@ export enum WireType {
}

// Reader
export interface IBinaryReader {
buf: Uint8Array;
pos: number;
type: number;
len: number;
tag(): [number, WireType, number];
skip(length?: number): this;
skipType(wireType: number): this;
uint32(): number;
int32(): number;
sint32(): number;
fixed32(): number;
sfixed32(): number;
int64(): bigint;
uint64(): bigint;
sint64(): bigint;
fixed64(): bigint;
sfixed64(): bigint;
float(): number;
double(): number;
bool(): boolean;
bytes(): Uint8Array;
string(): string;
}

export class BinaryReader {
export class BinaryReader implements IBinaryReader {
buf: Uint8Array;
pos: number;
type: number;
len: number;

protected assertBounds(): void {
assertBounds(): void {
if (this.pos > this.len) throw new RangeError("premature EOF");
}

Expand Down Expand Up @@ -217,35 +241,73 @@ export class BinaryReader {
}

// Writer
export interface IBinaryWriter {
len: number;
head: IOp;
tail: IOp;
states: State | null;
finish(): Uint8Array;
fork(): IBinaryWriter;
reset(): IBinaryWriter;
ldelim(): IBinaryWriter;
tag(fieldNo: number, type: WireType): IBinaryWriter;
uint32(value: number): IBinaryWriter;
int32(value: number): IBinaryWriter;
sint32(value: number): IBinaryWriter;
int64(value: string | number | bigint): IBinaryWriter;
uint64: (value: string | number | bigint) => IBinaryWriter;
sint64(value: string | number | bigint): IBinaryWriter;
fixed64(value: string | number | bigint): IBinaryWriter;
sfixed64: (value: string | number | bigint) => IBinaryWriter;
bool(value: boolean): IBinaryWriter;
fixed32(value: number): IBinaryWriter;
sfixed32: (value: number) => IBinaryWriter;
float(value: number): IBinaryWriter;
double(value: number): IBinaryWriter;
bytes(value: Uint8Array): IBinaryWriter;
string(value: string): IBinaryWriter;
}

type OpVal = string | number | object | Uint8Array;
interface IOp {
len: number;
next?: IOp;
proceed(buf: Uint8Array | number[], pos: number): void;
}

class Op {
fn?: (val: OpVal, buf: Uint8Array | number[], pos: number) => void;
class Op<T> implements IOp {
fn?: ((val: T, buf: Uint8Array | number[], pos: number) => void) | null;
len: number;
val: OpVal;
next?: Op;
val: T;
next?: IOp;

constructor(
fn: (
val: OpVal,
buf: Uint8Array | number[],
pos: number
) => void | undefined,
fn:
| ((
val: T,
buf: Uint8Array | number[],
pos: number
) => void | undefined | null)
| null,
len: number,
val: OpVal
val: T
) {
this.fn = fn;
this.len = len;
this.val = val;
}

proceed(buf: Uint8Array | number[], pos: number) {
if (this.fn) {
this.fn(this.val, buf, pos);
}
}
}

class State {
head: Op;
tail: Op;
head: IOp;
tail: IOp;
len: number;
next: State;
next: State | null;

constructor(writer: BinaryWriter) {
this.head = writer.head;
Expand All @@ -255,11 +317,11 @@ class State {
}
}

export class BinaryWriter {
export class BinaryWriter implements IBinaryWriter {
len = 0;
head: Op;
tail: Op;
states: State;
head: IOp;
tail: IOp;
states: State | null;

constructor() {
this.head = new Op(null, 0, 0);
Expand All @@ -282,10 +344,10 @@ export class BinaryWriter {
}
}

private _push(
fn: (val: OpVal, buf: Uint8Array | number[], pos: number) => void,
private _push<T>(
fn: (val: T, buf: Uint8Array | number[], pos: number) => void,
len: number,
val: OpVal
val: T
) {
this.tail = this.tail.next = new Op(fn, len, val);
this.len += len;
Expand All @@ -297,7 +359,7 @@ export class BinaryWriter {
pos = 0;
const buf = BinaryWriter.alloc(this.len);
while (head) {
head.fn(head.val, buf, pos);
head.proceed(buf, pos);
pos += head.len;
head = head.next;
}
Expand Down Expand Up @@ -444,7 +506,7 @@ function pool(
): (size: number) => Uint8Array {
const SIZE = size || 8192;
const MAX = SIZE >>> 1;
let slab = null;
let slab: Uint8Array | null = null;
let offset = SIZE;
return function pool_alloc(size): Uint8Array {
if (size < 1 || size > MAX) return alloc(size);
Expand Down
8 changes: 4 additions & 4 deletions packages/osmo-query/src/codegen/capability/bundle.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as _42 from "./v1/capability";
import * as _43 from "./v1/genesis";
import * as _84 from "./v1/capability";
import * as _85 from "./v1/genesis";
export namespace capability {
export const v1 = {
..._42,
..._43
..._84,
..._85
};
}
32 changes: 19 additions & 13 deletions packages/osmo-query/src/codegen/capability/v1/capability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface CapabilityProtoMsg {
* provided to a Capability must be globally unique.
*/
export interface CapabilityAmino {
index: string;
index?: string;
}
export interface CapabilityAminoMsg {
type: "/capability.v1.Capability";
Expand Down Expand Up @@ -45,8 +45,8 @@ export interface OwnerProtoMsg {
* capability and the module name.
*/
export interface OwnerAmino {
module: string;
name: string;
module?: string;
name?: string;
}
export interface OwnerAminoMsg {
type: "/capability.v1.Owner";
Expand Down Expand Up @@ -125,9 +125,11 @@ export const Capability = {
return message;
},
fromAmino(object: CapabilityAmino): Capability {
return {
index: BigInt(object.index)
};
const message = createBaseCapability();
if (object.index !== undefined && object.index !== null) {
message.index = BigInt(object.index);
}
return message;
},
toAmino(message: Capability): CapabilityAmino {
const obj: any = {};
Expand Down Expand Up @@ -194,10 +196,14 @@ export const Owner = {
return message;
},
fromAmino(object: OwnerAmino): Owner {
return {
module: object.module,
name: object.name
};
const message = createBaseOwner();
if (object.module !== undefined && object.module !== null) {
message.module = object.module;
}
if (object.name !== undefined && object.name !== null) {
message.name = object.name;
}
return message;
},
toAmino(message: Owner): OwnerAmino {
const obj: any = {};
Expand Down Expand Up @@ -257,9 +263,9 @@ export const CapabilityOwners = {
return message;
},
fromAmino(object: CapabilityOwnersAmino): CapabilityOwners {
return {
owners: Array.isArray(object?.owners) ? object.owners.map((e: any) => Owner.fromAmino(e)) : []
};
const message = createBaseCapabilityOwners();
message.owners = object.owners?.map(e => Owner.fromAmino(e)) || [];
return message;
},
toAmino(message: CapabilityOwners): CapabilityOwnersAmino {
const obj: any = {};
Expand Down
30 changes: 18 additions & 12 deletions packages/osmo-query/src/codegen/capability/v1/genesis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ export interface GenesisOwnersProtoMsg {
/** GenesisOwners defines the capability owners with their corresponding index. */
export interface GenesisOwnersAmino {
/** index is the index of the capability owner. */
index: string;
index?: string;
/** index_owners are the owners at the given index. */
index_owners?: CapabilityOwnersAmino;
index_owners: CapabilityOwnersAmino;
}
export interface GenesisOwnersAminoMsg {
type: "/capability.v1.GenesisOwners";
Expand Down Expand Up @@ -44,7 +44,7 @@ export interface GenesisStateProtoMsg {
/** GenesisState defines the capability module's genesis state. */
export interface GenesisStateAmino {
/** index is the capability global index. */
index: string;
index?: string;
/**
* owners represents a map from index to owners of the capability index
* index key is string to allow amino marshalling.
Expand Down Expand Up @@ -104,15 +104,19 @@ export const GenesisOwners = {
return message;
},
fromAmino(object: GenesisOwnersAmino): GenesisOwners {
return {
index: BigInt(object.index),
indexOwners: object?.index_owners ? CapabilityOwners.fromAmino(object.index_owners) : undefined
};
const message = createBaseGenesisOwners();
if (object.index !== undefined && object.index !== null) {
message.index = BigInt(object.index);
}
if (object.index_owners !== undefined && object.index_owners !== null) {
message.indexOwners = CapabilityOwners.fromAmino(object.index_owners);
}
return message;
},
toAmino(message: GenesisOwners): GenesisOwnersAmino {
const obj: any = {};
obj.index = message.index ? message.index.toString() : undefined;
obj.index_owners = message.indexOwners ? CapabilityOwners.toAmino(message.indexOwners) : undefined;
obj.index_owners = message.indexOwners ? CapabilityOwners.toAmino(message.indexOwners) : CapabilityOwners.fromPartial({});
return obj;
},
fromAminoMsg(object: GenesisOwnersAminoMsg): GenesisOwners {
Expand Down Expand Up @@ -175,10 +179,12 @@ export const GenesisState = {
return message;
},
fromAmino(object: GenesisStateAmino): GenesisState {
return {
index: BigInt(object.index),
owners: Array.isArray(object?.owners) ? object.owners.map((e: any) => GenesisOwners.fromAmino(e)) : []
};
const message = createBaseGenesisState();
if (object.index !== undefined && object.index !== null) {
message.index = BigInt(object.index);
}
message.owners = object.owners?.map(e => GenesisOwners.fromAmino(e)) || [];
return message;
},
toAmino(message: GenesisState): GenesisStateAmino {
const obj: any = {};
Expand Down
Loading
Loading