Skip to content

Commit

Permalink
v0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
siddharthborderwala committed May 2, 2023
1 parent ffa3613 commit 80e1a25
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@leapwallet/buffer-boba",
"description": "Buffer Boba is a library for decoding protocol buffers in the cosmos ecosystem.",
"version": "0.1.0",
"version": "0.1.1",
"repository": "https://github.com/leapwallet/buffer-boba",
"author": "Leap Wallet",
"license": "MIT",
Expand Down
8 changes: 2 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@ export type {
GeneratedRegistry
} from './supported-modules'

export {
convertToProtoFactory,
convertCamelCaseToSnakeCase,
convertSnakeCaseToCamelCase,
decodeSignDoc
} from './util'
export * from './util'
export { Registry } from './registry'
export { MsgConverter } from './msg-converter'
export type { AnyWithUnpacked, ProtoFactory, UnknownMessage } from './codec'
export { ProtoCodec, defaultProtoCodec } from './codec'
export type { TxBody, AuthInfo, SignDoc } from './decoder'
export { DirectSignDocDecoder } from './decoder'
2 changes: 1 addition & 1 deletion src/msg-converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from 'osmojs'
import { strideAminoConverters } from 'stridejs'

import { AminoConverters } from './supported-modules'
import type { AminoConverters } from './supported-modules'

const convertFromModuleGroup = (
msg: any,
Expand Down
2 changes: 1 addition & 1 deletion src/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from 'osmojs'
import { strideProtoRegistry } from 'stridejs'

import { GeneratedEntry, GeneratedRegistry } from './supported-modules'
import type { GeneratedEntry, GeneratedRegistry } from './supported-modules'

const registries = [
cosmosProtoRegistry,
Expand Down
21 changes: 21 additions & 0 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,27 @@ export const convertSnakeCaseToCamelCase = (key: string): string => {
return key.replace(/(_\w)/g, (m) => m[1].toUpperCase())
}

export const convertObjectCasingFromCamelToSnake = (
record: Record<string, any>
): Record<string, any> => {
const msgKeys = Object.keys(record)
const convertedMsg = msgKeys.reduce((acc, key) => {
const convertedKey = convertCamelCaseToSnakeCase(key)
const value = record[key]
if (typeof value === 'object' && value !== null) {
return {
...acc,
[convertedKey]: convertObjectCasingFromCamelToSnake(value)
}
}
return {
...acc,
[convertedKey]: record[key]
}
}, {} as Record<string, unknown>)
return convertedMsg
}

export const convertToProtoFactory = (
generatedType: GeneratedType
): ProtoFactory => {
Expand Down

0 comments on commit 80e1a25

Please sign in to comment.