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

feat: add amino encodings #60

Merged
merged 12 commits into from
Sep 14, 2023
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
/persistence/
/helpers.*
/index.*
/binary.*
/utf8.*
/varint.*
/proofs.*

# misc
Expand Down
2,030 changes: 1,142 additions & 888 deletions package-lock.json

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "persistenceonejs",
"version": "2.2.0",
"version": "2.3.0-rc0",
"description": "Client side JS libraries for persistenceSDK transaction generation, signing and broadcasting.",
"main": "main/index.js",
"module": "module/index.js",
Expand Down Expand Up @@ -33,13 +33,14 @@
"url": "https://github.com/persistenceOne/persistenceJS/issues"
},
"homepage": "https://github.com/persistenceOne/persistenceJS#readme",
"dependencies": {
"long": "^4.0.0",
"protobufjs": "~6.11.2"
},
"dependencies": {},
"devDependencies": {
"@cosmjs/amino": "^0.31.1",
"@cosmjs/stargate": "^0.31.1",
"@cosmjs/proto-signing": "^0.31.1",
"@cosmjs/tendermint-rpc": "^0.31.1",
"@cosmjs/encoding": "^0.31.1",
"@types/node": "^18.6.3",
"@types/long": "^4.0.1",
"@cosmology/telescope": "^0.109.4",
"cosmwasm-typescript-gen": "^0.3.9",
"husky": "^8.0.1",
Expand Down
15 changes: 12 additions & 3 deletions proto/pstake/liquidstakeibc/v1beta1/msgs.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "cosmos/msg/v1/msg.proto";
import "cosmos/base/v1beta1/coin.proto";
import "amino/amino.proto";

import "pstake/liquidstakeibc/v1beta1/liquidstakeibc.proto";
import "pstake/liquidstakeibc/v1beta1/params.proto";
Expand Down Expand Up @@ -39,6 +40,8 @@ service Msg {
message MsgRegisterHostChain {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
option (cosmos.msg.v1.signer) = "authority";
option (amino.name) = "pstake/MsgRegisterHostChain";

// authority is the address of the governance account
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
Expand Down Expand Up @@ -81,18 +84,20 @@ message MsgRegisterHostChainResponse {}
message MsgUpdateHostChain {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

option (cosmos.msg.v1.signer) = "authority";
option (amino.name) = "pstake/MsgUpdateHostChain";
// authority is the address of the governance account
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];

string chain_id = 2;
repeated KVUpdate updates = 3;
repeated KVUpdate updates = 3 [(amino.dont_omitempty) = true];
}

message MsgUpdateHostChainResponse {}

message MsgLiquidStake {
option (cosmos.msg.v1.signer) = "delegator_address";
option (amino.name) = "pstake/MsgLiquidStake";

string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
cosmos.base.v1beta1.Coin amount = 2 [(gogoproto.nullable) = false];
Expand All @@ -102,6 +107,7 @@ message MsgLiquidStakeResponse {}

message MsgLiquidStakeLSM {
option (cosmos.msg.v1.signer) = "delegator_address";
option (amino.name) = "pstake/MsgLiquidStakeLSM";

string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
repeated cosmos.base.v1beta1.Coin delegations = 2 [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
Expand All @@ -112,6 +118,7 @@ message MsgLiquidStakeLSMResponse {}

message MsgLiquidUnstake {
option (cosmos.msg.v1.signer) = "delegator_address";
option (amino.name) = "pstake/MsgLiquidUnstake";

string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
cosmos.base.v1beta1.Coin amount = 2 [(gogoproto.nullable) = false];
Expand All @@ -121,6 +128,7 @@ message MsgLiquidUnstakeResponse {}

message MsgRedeem {
option (cosmos.msg.v1.signer) = "delegator_address";
option (amino.name) = "pstake/MsgRedeem";

string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
cosmos.base.v1beta1.Coin amount = 2 [(gogoproto.nullable) = false];
Expand All @@ -133,9 +141,10 @@ message MsgUpdateParams {
option (gogoproto.goproto_getters) = false;

option (cosmos.msg.v1.signer) = "authority";
option (amino.name) = "pstake/MsgUpdateParams";

string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
Params params = 2 [(gogoproto.nullable) = false];
Params params = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
}

message MsgUpdateParamsResponse {}
3 changes: 3 additions & 0 deletions proto/pstake/liquidstakeibc/v1beta1/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ package pstake.liquidstakeibc.v1beta1;

import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "amino/amino.proto";

option go_package = "github.com/persistenceOne/pstake-native/v2/x/liquidstakeibc/types";

// Params defines the parameters for the module.
message Params {
option (amino.name) = "pstake/x/liquidstakeibc/Params";

string admin_address = 1 [
(cosmos_proto.scalar) = "cosmos.AddressString"
]; // protocol admin address
Expand Down
27 changes: 22 additions & 5 deletions scripts/prepare-publishing.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,33 @@
#!/bin/bash

set -o errexit -o nounset -o pipefail
command -v shellcheck >/dev/null && shellcheck "$0"

DIRS="amino cosmos cosmos_proto cosmwasm gogoproto google ibc tendermint pstake persistence"
FILES="helpers.d.ts helpers.js helpers.js.map index.d.ts index.js index.js.map"
DIRS=(amino cosmos cosmos_proto cosmwasm gogoproto google ibc tendermint pstake persistence)
FILES=(
helpers.d.ts
helpers.js
helpers.js.map
index.d.ts
index.js
index.js.map
binary.d.ts
binary.js
binary.js.map
utf8.d.ts
utf8.js
utf8.js.map
varint.d.ts
varint.js
varint.js.map
)

for dir in $DIRS; do
for dir in "${DIRS[@]}"; do
rm -rf "$dir"
cp -R "./build/$dir" ./
done

for f in $FILES; do
for f in "${FILES[@]}"; do
rm -rf "$f"
cp "./build/$f" ./
done
done
43 changes: 37 additions & 6 deletions scripts/telescope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,22 @@ telescope({
logLevel: 0,
useSDKTypes: false,
tsDisable: {
disableAll: false
patterns: ["**/tx.registry.ts", "**/msgs.registry.ts"],
files: [
"ibc/core/types/v1/genesis.ts",
"ibc/applications/interchain_accounts/genesis/v1/genesis.ts",
"cosmos/tx/signing/v1beta1/signing.ts",
"cosmos/staking/v1beta1/tx.ts",
"cosmos/staking/v1beta1/staking.ts",

"cosmos/authz/v1beta1/tx.amino.ts",
"cosmos/staking/v1beta1/tx.amino.ts",
"cosmos/slashing/v1beta1/tx.amino.ts",
"cosmos/upgrade/v1beta1/tx.amino.ts",

"cosmos/consensus/v1/tx.amino.ts",
"cosmos/gov/v1/tx.amino.ts"
]
},
eslintDisable: {
disableAll: true
Expand Down Expand Up @@ -54,13 +69,25 @@ telescope({
// There are users who need those functions. CosmJS does not need them directly.
// See https://github.com/cosmos/cosmjs/pull/1329
fromJSON: true,
toJSON: true
toJSON: true,
fromPartial: true

// encode: true,
// decode: true,
// toSDK: true,
// fromSDK: true,
// toAmino: true,
// fromAmino: true,
// fromProto: true,
// toProto: true
},
typingsFormat: {
useDeepPartial: true,
useExact: true,
useDeepPartial: false,
useExact: false,
timestamp: "timestamp",
duration: "duration"
duration: "duration",
num64: "bigint",
setDefaultCustomTypesToUndefined: false
}
},
lcdClients: {
Expand All @@ -79,8 +106,12 @@ telescope({
"ABCIApplication"
]
},
stargateClients: {
enabled: false,
includeCosmosDefaultTypes: false
},
aminoEncoding: {
enabled: false
enabled: true
}
}
}).then(() => {
Expand Down
Loading