Skip to content

Commit

Permalink
Merge branch 'main' into extra-endpoint-query-key
Browse files Browse the repository at this point in the history
  • Loading branch information
Zetazzz committed Aug 8, 2023
2 parents d7730bb + eaebc48 commit ad3143d
Show file tree
Hide file tree
Showing 46 changed files with 290 additions and 195 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ See [RPC Clients](#rpc-clients) for more info.
| `prototypes.typingsFormat.useExact` | defaults to false, but if enabled uses the `Exact` TS type | `false` |
| `prototypes.typingsFormat.timestamp` | use either `date` or `timestamp` for `Timestamp` proto type | "date" |
| `prototypes.typingsFormat.duration` | use either `duration` or `string` for `Duration` proto type | "duration"|
| `prototypes.typingsFormat.setDefaultEnumToUnrecognized` | false: enum empty value would be 0, true: -1(value for enum unrecognized) |true|
| `prototypes.typingsFormat.setDefaultCustomTypesToUndefined` | true: Timestamp,Duration,Any,Coin empty value would be undefined., false: using fromPartial to get an empty obj |false|

### Protobuf parser

Expand Down Expand Up @@ -720,7 +722,7 @@ Below will be an example of scaffold a `grant` Proto Msg for grpc-web and grpc-g
const signed_tx = await signClient.sign('granter_address', [msg], fee, 'telescope: grant', signerData);
const txRawBytes = Uint8Array.from(TxRaw.encode(signed_tx).finish());

const res = await client.cosmos.tx.v1beta1.broadcastTx(
const res = await client.cosmos.tx.v1beta1.broadcastTx(
{
txBytes: txRawBytes,
mode: BroadcastMode.BROADCAST_MODE_BLOCK
Expand Down
2 changes: 1 addition & 1 deletion __fixtures__/output1/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export const setPaginationParams = (options: Params, pagination?: PageRequest) =
}
if (typeof pagination?.key !== "undefined") {
// String to Uint8Array
// let uint8arr = new Uint8Array(Buffer.from(data,'base64'));
// let uint8arr = new Uint8Array(Buffer.from(data,'base64'));

// Uint8Array to String
options.params['pagination.key'] = Buffer.from(pagination.key).toString('base64');
Expand Down
2 changes: 1 addition & 1 deletion __fixtures__/output2/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export const setPaginationParams = (options: Params, pagination?: PageRequest) =
}
if (typeof pagination?.key !== "undefined") {
// String to Uint8Array
// let uint8arr = new Uint8Array(Buffer.from(data,'base64'));
// let uint8arr = new Uint8Array(Buffer.from(data,'base64'));

// Uint8Array to String
options.params['pagination.key'] = Buffer.from(pagination.key).toString('base64');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const usePiniaStore = defineStore('akash/cert/v1beta2/query.proto', {
}
},
actions: {
async fetchCertificates(param: QueryCertificatesRequestSDKType) {
async fetchCertificates(param : QueryCertificatesRequestSDKType) {
this.certificates = await this.lcdClient.certificates(param);
return this.certificates;
}
Expand Down
22 changes: 11 additions & 11 deletions __fixtures__/v-next/outputosmojs/binary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,12 +348,12 @@ export class BinaryWriter {
(value = value >>> 0) < 128
? 1
: value < 16384
? 2
: value < 2097152
? 3
: value < 268435456
? 4
: 5,
? 2
: value < 2097152
? 3
: value < 268435456
? 4
: 5,
value
)).len;
return this;
Expand Down Expand Up @@ -463,10 +463,10 @@ function pool(
function indexOutOfRange(reader: BinaryReader, writeLength?: number) {
return RangeError(
"index out of range: " +
reader.pos +
" + " +
(writeLength || 1) +
" > " +
reader.len
reader.pos +
" + " +
(writeLength || 1) +
" > " +
reader.len
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ export const usePiniaStore = defineStore('evmos/erc20/v1/query.proto', {
}
},
actions: {
async fetchTokenPairs(param: QueryTokenPairsRequestSDKType) {
async fetchTokenPairs(param : QueryTokenPairsRequestSDKType) {
this.tokenPairs = await this.lcdClient.tokenPairs(param);
return this.tokenPairs;
},
async fetchTokenPair(param: QueryTokenPairRequestSDKType) {
async fetchTokenPair(param : QueryTokenPairRequestSDKType) {
this.tokenPair = await this.lcdClient.tokenPair(param);
return this.tokenPair;
},
async fetchParams(param: QueryParamsRequestSDKType) {
async fetchParams(param : QueryParamsRequestSDKType) {
this.params = await this.lcdClient.params(param);
return this.params;
}
Expand Down
6 changes: 3 additions & 3 deletions __fixtures__/v-next/outputosmojs/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ type KeysOfUnion<T> = T extends T ? keyof T : never;
export type Exact<P, I extends P> = P extends Builtin
? P
: P & { [K in keyof P]: Exact<P[K], I[K]> } & Record<
Exclude<keyof I, KeysOfUnion<P>>,
never
>;
Exclude<keyof I, KeysOfUnion<P>>,
never
>;

export interface Rpc {
request(
Expand Down
2 changes: 1 addition & 1 deletion __fixtures__/v-next/outputosmojs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* 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.
*/

export * from "./akash/bundle";
export * from "./akash/client";
export * from "./ics23/bundle";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,63 +34,63 @@ export const usePiniaStore = defineStore('osmosis/gamm/v1beta1/query.proto', {
}
},
actions: {
async fetchPools(param: QueryPoolsRequestSDKType) {
async fetchPools(param : QueryPoolsRequestSDKType) {
this.pools = await this.lcdClient.pools(param);
return this.pools;
},
async fetchNumPools(param: QueryNumPoolsRequestSDKType) {
async fetchNumPools(param : QueryNumPoolsRequestSDKType) {
this.numPools = await this.lcdClient.numPools(param);
return this.numPools;
},
async fetchTotalLiquidity(param: QueryTotalLiquidityRequestSDKType) {
async fetchTotalLiquidity(param : QueryTotalLiquidityRequestSDKType) {
this.totalLiquidity = await this.lcdClient.totalLiquidity(param);
return this.totalLiquidity;
},
async fetchPoolsWithFilter(param: QueryPoolsWithFilterRequestSDKType) {
async fetchPoolsWithFilter(param : QueryPoolsWithFilterRequestSDKType) {
this.poolsWithFilter = await this.lcdClient.poolsWithFilter(param);
return this.poolsWithFilter;
},
async fetchPool(param: QueryPoolRequestSDKType) {
async fetchPool(param : QueryPoolRequestSDKType) {
this.pool = await this.lcdClient.pool(param);
return this.pool;
},
async fetchPoolType(param: QueryPoolTypeRequestSDKType) {
async fetchPoolType(param : QueryPoolTypeRequestSDKType) {
this.poolType = await this.lcdClient.poolType(param);
return this.poolType;
},
async fetchCalcJoinPoolNoSwapShares(param: QueryCalcJoinPoolNoSwapSharesRequestSDKType) {
async fetchCalcJoinPoolNoSwapShares(param : QueryCalcJoinPoolNoSwapSharesRequestSDKType) {
this.calcJoinPoolNoSwapShares = await this.lcdClient.calcJoinPoolNoSwapShares(param);
return this.calcJoinPoolNoSwapShares;
},
async fetchCalcJoinPoolShares(param: QueryCalcJoinPoolSharesRequestSDKType) {
async fetchCalcJoinPoolShares(param : QueryCalcJoinPoolSharesRequestSDKType) {
this.calcJoinPoolShares = await this.lcdClient.calcJoinPoolShares(param);
return this.calcJoinPoolShares;
},
async fetchCalcExitPoolCoinsFromShares(param: QueryCalcExitPoolCoinsFromSharesRequestSDKType) {
async fetchCalcExitPoolCoinsFromShares(param : QueryCalcExitPoolCoinsFromSharesRequestSDKType) {
this.calcExitPoolCoinsFromShares = await this.lcdClient.calcExitPoolCoinsFromShares(param);
return this.calcExitPoolCoinsFromShares;
},
async fetchPoolParams(param: QueryPoolParamsRequestSDKType) {
async fetchPoolParams(param : QueryPoolParamsRequestSDKType) {
this.poolParams = await this.lcdClient.poolParams(param);
return this.poolParams;
},
async fetchTotalPoolLiquidity(param: QueryTotalPoolLiquidityRequestSDKType) {
async fetchTotalPoolLiquidity(param : QueryTotalPoolLiquidityRequestSDKType) {
this.totalPoolLiquidity = await this.lcdClient.totalPoolLiquidity(param);
return this.totalPoolLiquidity;
},
async fetchTotalShares(param: QueryTotalSharesRequestSDKType) {
async fetchTotalShares(param : QueryTotalSharesRequestSDKType) {
this.totalShares = await this.lcdClient.totalShares(param);
return this.totalShares;
},
async fetchSpotPrice(param: QuerySpotPriceRequestSDKType) {
async fetchSpotPrice(param : QuerySpotPriceRequestSDKType) {
this.spotPrice = await this.lcdClient.spotPrice(param);
return this.spotPrice;
},
async fetchEstimateSwapExactAmountIn(param: QuerySwapExactAmountInRequestSDKType) {
async fetchEstimateSwapExactAmountIn(param : QuerySwapExactAmountInRequestSDKType) {
this.estimateSwapExactAmountIn = await this.lcdClient.estimateSwapExactAmountIn(param);
return this.estimateSwapExactAmountIn;
},
async fetchEstimateSwapExactAmountOut(param: QuerySwapExactAmountOutRequestSDKType) {
async fetchEstimateSwapExactAmountOut(param : QuerySwapExactAmountOutRequestSDKType) {
this.estimateSwapExactAmountOut = await this.lcdClient.estimateSwapExactAmountOut(param);
return this.estimateSwapExactAmountOut;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const usePiniaStore = defineStore('osmosis/gamm/v2/query.proto', {
}
},
actions: {
async fetchSpotPrice(param: QuerySpotPriceRequestSDKType) {
async fetchSpotPrice(param : QuerySpotPriceRequestSDKType) {
this.spotPrice = await this.lcdClient.spotPrice(param);
return this.spotPrice;
}
Expand Down
20 changes: 10 additions & 10 deletions __fixtures__/v-next/outputosmojs/varint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,18 +454,18 @@ export function int64Length(lo: number, hi: number) {
? 1
: 2
: part0 < 2097152
? 3
: 4
? 3
: 4
: part1 < 16384
? part1 < 128
? 5
: 6
: part1 < 2097152
? 7
: 8
? part1 < 128
? 5
: 6
: part1 < 2097152
? 7
: 8
: part2 < 128
? 9
: 10;
? 9
: 10;
}

export function writeFixed32(
Expand Down
32 changes: 16 additions & 16 deletions __fixtures__/v-next/outputv2/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@ export const setPaginationParams = (options: Params, pagination?: PageRequest) =
options.params['pagination.key'] = Buffer.from(pagination.key).toString('base64');
}
if (typeof pagination?.limit !== "undefined") {
options.params["pagination.limit"] = pagination.limit.toString()
options.params["pagination.limit"] = pagination.limit.toString()
}
if (typeof pagination?.offset !== "undefined") {
options.params["pagination.offset"] = pagination.offset.toString()
}
options.params["pagination.offset"] = pagination.offset.toString()
}
if (typeof pagination?.reverse !== "undefined") {
options.params['pagination.reverse'] = pagination.reverse;
}
Expand Down Expand Up @@ -221,22 +221,22 @@ const fromJSON = (object: any): Timestamp => {
};

const timestampFromJSON = (object: any): Timestamp => {
return {
seconds: isSet(object.seconds) ? Long.fromValue(object.seconds) : Long.ZERO,
nanos: isSet(object.nanos) ? Number(object.nanos) : 0,
};
return {
seconds: isSet(object.seconds) ? Long.fromValue(object.seconds) : Long.ZERO,
nanos: isSet(object.nanos) ? Number(object.nanos) : 0,
};
}

export function fromJsonTimestamp(o: any): Timestamp {
if (o instanceof Date) {
return toTimestamp(o);
} else if (typeof o === "string") {
return toTimestamp(new Date(o));
} else {
return timestampFromJSON(o);
}
if (o instanceof Date) {
return toTimestamp(o);
} else if (typeof o === "string") {
return toTimestamp(new Date(o));
} else {
return timestampFromJSON(o);
}
}

function numberToLong(number: number) {
return Long.fromNumber(number);
}
2 changes: 1 addition & 1 deletion __fixtures__/v-next/outputv2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* 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.
*/

export * from "./akash/bundle";
export * from "./akash/client";
export * from "./ics23/bundle";
Expand Down
24 changes: 12 additions & 12 deletions __fixtures__/v-next/outputv3/grpc-gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ const s64 = new Array(123);

// 65..90, 97..122, 48..57, 43, 47
for (let i = 0; i < 64;)
s64[b64[i] = i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i - 59 | 43] = i++;
s64[b64[i] = i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i - 59 | 43] = i++;

export function b64Encode(buffer: Uint8Array, start: number, end: number): string {
let parts: string[] = null;
let parts: string[] = null;
const chunk = [];
let i = 0, // output index
j = 0, // goto index
Expand Down Expand Up @@ -67,16 +67,16 @@ export function b64Encode(buffer: Uint8Array, start: number, end: number): strin
const invalidEncoding = "invalid encoding";

export function b64Decode(s: string): Uint8Array {
const buffer = [];
let offset = 0;
const buffer = [];
let offset = 0;
let j = 0, // goto index
t; // temporary
t; // temporary
for (let i = 0; i < s.length;) {
let c = s.charCodeAt(i++);
if (c === 61 && j > 1)
break;
break;
if ((c = s64[c]) === undefined)
throw Error(invalidEncoding);
throw Error(invalidEncoding);
switch (j) {
case 0:
t = c;
Expand All @@ -99,28 +99,28 @@ export function b64Decode(s: string): Uint8Array {
}
}
if (j === 1)
throw Error(invalidEncoding);
throw Error(invalidEncoding);
return new Uint8Array(buffer);
}

function b64Test(s: string): boolean {
return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(s);
return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(s);
}

export interface InitReq extends RequestInit {
pathPrefix?: string
}

export function replacer(key: any, value: any): any {
if (value && value.constructor === Uint8Array) {
if(value && value.constructor === Uint8Array) {
return b64Encode(value, 0, value.length);
}

return value;
}

export function fetchReq<I, O>(path: string, init?: InitReq): Promise<O> {
const { pathPrefix, ...req } = init || {}
const {pathPrefix, ...req} = init || {}

const url = pathPrefix ? `${pathPrefix}${path}` : path

Expand All @@ -139,7 +139,7 @@ export type NotifyStreamEntityArrival<T> = (resp: T) => void
* all entities will be returned as an array after the call finishes.
**/
export async function fetchStreamingRequest<S, R>(path: string, callback?: NotifyStreamEntityArrival<R>, init?: InitReq) {
const { pathPrefix, ...req } = init || {}
const {pathPrefix, ...req} = init || {}
const url = pathPrefix ? `${pathPrefix}${path}` : path
const result = await fetch(url, req)
// needs to use the .ok to check the status of HTTP status code
Expand Down
Loading

0 comments on commit ad3143d

Please sign in to comment.