{"id":16193567,"url":"https://github.com/pyramation/protobuf-demo","last_synced_at":"2025-08-24T21:25:02.166Z","repository":{"id":66351147,"uuid":"478326732","full_name":"pyramation/protobuf-demo","owner":"pyramation","description":null,"archived":false,"fork":false,"pushed_at":"2022-04-06T02:44:45.000Z","size":36140,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-07T15:19:54.390Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pyramation.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-05T22:57:50.000Z","updated_at":"2022-04-05T23:54:37.000Z","dependencies_parsed_at":"2023-02-24T18:00:56.337Z","dependency_job_id":null,"html_url":"https://github.com/pyramation/protobuf-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pyramation/protobuf-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyramation%2Fprotobuf-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyramation%2Fprotobuf-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyramation%2Fprotobuf-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyramation%2Fprotobuf-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pyramation","download_url":"https://codeload.github.com/pyramation/protobuf-demo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyramation%2Fprotobuf-demo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271953142,"owners_count":24849290,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-24T02:00:11.135Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T08:15:29.843Z","updated_at":"2025-08-24T21:25:02.116Z","avatar_url":"https://github.com/pyramation.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# protobuf demo\n\n- [ts-proto](./packages/ts-proto)\n  - [example](./packages/ts-proto/src/proto/osmosis/gamm/v1beta1/tx.ts)\n\n- [ts-proto-ast-babel](./packages/ts-proto-ast-babel)\n  - [example](./packages/ts-proto-ast-babel/src/proto/osmosis/gamm/v1beta1/tx.ts)\n  - [namespaces](./packages/ts-proto-ast-babel/src/proto/osmosis/gamm/v1beta1/tx.ts#L1560-L1563)\n\n- [protobuf-ts](./packages/protobuf-ts)\n  - [example](./packages/protobuf-ts/src/proto/osmosis/gamm/v1beta1/tx.ts)\n  - [client](./packages/protobuf-ts/src/proto/osmosis/gamm/v1beta1/tx.client.ts#L27-L60)\n\nWIP: \n\n- [protoc-gen-typescript](./packages/protoc-gen-typescript)\n\n# questions\n\n- [ ] can some portion of to/from amino be automated?\nhttps://github.com/grpc/grpc-node/blob/master/packages/grpc-js/src/duration.ts#L23-L32\n\n- ideally through tranpilation step\n  - [ ] one method for registry\n  - [ ] generate message composition objects (typeUrl + packet)\n    - [ ] type_url or typeurl\n\n# snippets/structures from other code bases\n\n## ts-proto w/registry option\n\n\n```\n      'osmosis.gamm.v1beta1.MsgJoinSwapShareAmountOutResponse' =\u003e {\n        '$type': 'osmosis.gamm.v1beta1.MsgJoinSwapShareAmountOutResponse',\n        encode: [Function: encode],\n        decode: [Function: decode],\n        fromJSON: [Function: fromJSON],\n        toJSON: [Function: toJSON],\n        fromPartial: [Function: fromPartial]\n      },\n      'osmosis.gamm.v1beta1.MsgExitSwapShareAmountIn' =\u003e {\n        '$type': 'osmosis.gamm.v1beta1.MsgExitSwapShareAmountIn',\n        encode: [Function: encode],\n        decode: [Function: decode],\n        fromJSON: [Function: fromJSON],\n        toJSON: [Function: toJSON],\n        fromPartial: [Function: fromPartial]\n      },\n\n```\n\n## keplr-wallet\n\nhttps://github.com/chainapsis/keplr-wallet/blob/master/packages/cosmos/src/stargate/codec/index.ts#L43-L63\n\n```js\nexport const defaultProtoCodec = new ProtoCodec();\ndefaultProtoCodec.registerAny(\n  \"/cosmos.bank.v1beta1.MsgSend\",\n  cosmos.bank.v1beta1.MsgSend\n);\ndefaultProtoCodec.registerAny(\n  \"/cosmos.staking.v1beta1.MsgDelegate\",\n  cosmos.staking.v1beta1.MsgDelegate\n);\ndefaultProtoCodec.registerAny(\n  \"/cosmos.staking.v1beta1.MsgUndelegate\",\n  cosmos.staking.v1beta1.MsgUndelegate\n);\ndefaultProtoCodec.registerAny(\n  \"/cosmos.staking.v1beta1.MsgBeginRedelegate\",\n  cosmos.staking.v1beta1.MsgBeginRedelegate\n);\ndefaultProtoCodec.registerAny(\n  \"/cosmwasm.wasm.v1.MsgExecuteContract\",\n  cosmwasm.wasm.v1.MsgExecuteContract\n);\n\n```\n\n## secret\n\nI believe they're using the `ts-proto`'s `outputClientImpl=grpc-web`\n### protobufs\n\nhttps://github.com/scrtlabs/secret.js/blob/master/src/tx/gov.ts#L110-L135\n\n```ts\n  async toProto(): Promise\u003cProtoMsg\u003e {\n    const { Any } = await import(\"../protobuf_stuff/google/protobuf/any\");\n    let content: import(\"../protobuf_stuff/google/protobuf/any\").Any;\n\n    switch (this.type) {\n      case ProposalType.TextProposal:\n        const { TextProposal } = await import(\n          \"../protobuf_stuff/cosmos/gov/v1beta1/gov\"\n        );\n        content = Any.fromPartial({\n          typeUrl: \"/cosmos.gov.v1beta1.TextProposal\",\n          value: TextProposal.encode(\n            TextProposal.fromPartial(this.content),\n          ).finish(),\n        });\n        break;\n ```\n\n### aminos\n\nhttps://github.com/scrtlabs/secret.js/blob/master/src/tx/gov.ts#L223-L244\n\n ```ts\n  async toAmino(): Promise\u003cAminoMsg\u003e {\n    const contentType = proposalTypeToAminoType.get(this.type);\n    if (!contentType) {\n      throw new Error(\n        `Proposal of type \"${String(\n          this.type,\n        )}\" is not supported with an Amino signer.`,\n      );\n    }\n\n    let content: any = this.content;\n    if (this.type === ProposalType.SoftwareUpgradeProposal) {\n      if (content.plan) {\n        content = {\n          ...content,\n          plan: {\n            type: \"cosmos-sdk/Plan\",\n            value: { ...content.plan },\n          },\n        };\n      }\n    }\n ```\n\n## osmosis\n\nregistry\n\nhttps://github.com/osmosis-labs/osmosis-frontend/blob/master/src/stores/osmosis/account/index.ts#L68-L87\n\n```js\ncreatePool: {\n    type: 'osmosis/gamm/create-balancer-pool',\n    gas: 350000,\n},\njoinPool: {\n    type: 'osmosis/gamm/join-pool',\n    gas: 240000,\n    shareCoinDecimals: 18,\n},\njoinSwapExternAmountIn: {\n    type: 'osmosis/gamm/join-swap-extern-amount-in',\n    gas: 140000,\n    shareCoinDecimals: 18,\n},\n```\n\naminos\n\nhttps://github.com/osmosis-labs/osmosis-frontend/blob/master/src/stores/osmosis/account/index.ts#L834-L861\n\n\n```js\n{\n    aminoMsgs: [msg],\n    protoMsgs: [\n        {\n            type_url: '/osmosis.lockup.MsgLockTokens',\n            value: osmosis.lockup.MsgLockTokens.encode({\n                owner: msg.value.owner,\n                duration: {\n                    seconds: Long.fromNumber(Math.floor(parseInt(msg.value.duration) / 1_000_000_000)),\n                    nanos: parseInt(msg.value.duration) % 1_000_000_000,\n                },\n                coins: msg.value.coins,\n            }).finish(),\n        },\n    ],\n}\n```\n\n## cosmology\n\n### registry \n\n```js\n  joinPool: {\n    osmosis: osmosis.gamm.v1beta1.MsgJoinPool,\n    amino: '/osmosis.gamm.v1beta1.MsgJoinPool',\n    type: 'osmosis/gamm/join-pool',\n    gas: 140000,\n    shareCoinDecimals: 18\n  },\n  joinSwapExternAmountIn: {\n    osmosis: osmosis.gamm.v1beta1.MsgJoinSwapExternAmountIn,\n    amino: '/osmosis.gamm.v1beta1.MsgJoinSwapExternAmountIn',\n    type: 'osmosis/gamm/join-swap-extern-amount-in',\n    gas: 140000,\n    shareCoinDecimals: 18\n  },\n  exitPool: {\n    osmosis: osmosis.gamm.v1beta1.MsgExitPool,\n    amino: '/osmosis.gamm.v1beta1.MsgExitPool',\n    type: 'osmosis/gamm/exit-pool',\n    gas: 140000,\n    shareCoinDecimals: 18\n  },\n```\n### amino messages\n\n```js\nswapExactAmountIn: {\n    toAmino: ({ sender, routes, tokenIn, tokenOutMinAmount }) =\u003e ({\n      sender,\n      routes: parseRoutes(routes),\n      tokenIn: {\n        denom: tokenIn.denom,\n        amount: Long.fromNumber(tokenIn.amount).toString()\n      },\n      tokenOutMinAmount: Long.fromNumber(tokenOutMinAmount).toString()\n    }),\n    fromAmino: ({ sender, routes, tokenIn, tokenOutMinAmount }) =\u003e ({\n      sender,\n      routes: parseRoutes(routes),\n      tokenIn,\n      tokenOutMinAmount\n    })\n  },\n  lockTokens: {\n    toAmino: ({ owner, duration, coins }) =\u003e {\n      return {\n        owner,\n        coins,\n        duration: (duration * 1_000_000_000).toString()\n      };\n    },\n    fromAmino: ({ owner, duration, coins }) =\u003e {\n      return {\n        owner,\n        coins,\n        duration: {\n          seconds: Long.fromNumber(\n            Math.floor(parseInt(duration) / 1_000_000_000)\n          ),\n          nanos: parseInt(duration) % 1_000_000_000\n        }\n      };\n    }\n  },\n ```\n\n### message composition functions\n\n\n```js\n  withdrawDelegatorReward: ({\n    delegatorAddress,\n    validatorAddress\n  }: {\n    delegatorAddress: string,\n    validatorAddress: string\n  }) =\u003e {\n    return {\n      typeUrl: '/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward',\n      value: MsgWithdrawDelegatorReward.fromPartial({\n        delegatorAddress,\n        validatorAddress\n      })\n    };\n  },\n\n  delegate: ({\n    delegatorAddress,\n    validatorAddress,\n    amount,\n    denom\n  }: {\n    delegatorAddress: string,\n    validatorAddress: string,\n    amount: string,\n    denom: string\n  }) =\u003e {\n    return {\n      typeUrl: '/cosmos.staking.v1beta1.MsgDelegate',\n      value: MsgDelegate.fromPartial({\n        delegatorAddress,\n        validatorAddress,\n        amount: coin(amount, denom)\n      })\n    };\n  },\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyramation%2Fprotobuf-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpyramation%2Fprotobuf-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyramation%2Fprotobuf-demo/lists"}