⚠️ stridejs currently bundles in a specific version of cosmos-sdk (v0.45.16-ics-lsm-rc0
) due to LSM. Carefully import the modules you need.
npm install stridejs
⚡️ For web interfaces, we recommend using cosmos-kit. To sign and broadcast messages, you can create signers with a variety of options:
- cosmos-kit (recommended)
- keplr
- cosmjs
We recommend manually making the SigningStargateClient
instance yourself by using getSigningStrideClientOptions
:
import {
getSigningStrideClientOptions,
strideAccountParser,
} from "@stride/proto";
const { registry, aminoTypes } = getSigningStrideClientOptions();
const client = await SigningStargateClient.connectWithSigner(
rpc,
offlineSigner,
{
registry,
aminoTypes,
accountParser: strideAccountParser,
},
);
You are free to wrap stride account's parser depending on your use-case, take this as an example:
import { accountFromAny, Account } from "@cosmjs/stargate";
function accountParser(input: Any): Account {
switch (input.typeUrl) {
case '/injective.types.v1beta1.EthAccount': {
return injectiveAccountParser(input)
}
case '/stride.vesting.StridePeriodicVestingAccount': {
return strideAccountParser(input)
}
default: {
return accountFromAny(input);
}
}
}
We strongly recommend that you check the generated files in src/codegen/stride
and use it as source of truth for which functions you could use.
The rest of our documentation will cover only the tip of the iceberg — examples you can take ideas from.
import { stride } from "stridejs";
const client = await stride.ClienFactory.createRPCQueryClient({
rpcEndpoint: RPC_ENDPOINT,
});
const balance = await client.cosmos.bank.v1beta1.allBalances({
address: "stride1addresshere",
});
import { stride } from "stridejs";
const msgClaimFreeAmount =
stride.claim.MessageComposer.withTypeUrl.claimFreeAmount({
user: "stride1addresshere",
});
const fee = {
amount: [
{
amount: "0",
denom: "STRD",
},
],
gas: 250_000,
};
const tx = await strideAccount.client.signAndBroadcast(
"stride1addresshere",
[msgClaimFreeAmount],
fee,
"",
);
assertIsDeliverTxSuccess(tx);
If you're unfamiliar with Stargate, you can read their guide here.
import { ibc } from "stridejs";
const { transfer } =
ibc.applications.transfer.v1.MessageComposer.withTypeUrl.transfer({
// Redacted (check internal types for the message parameters)
});
When first cloning the repo:
git submodule sync --recursive
git submodule update --init --recursive
pnpm install
We currently bundle in a specific version of cosmos-sdk because of LSM. And sometimes we do the same for Stride too.
Open up .gitmodules
to update the specified branches, then sync:
git submodule sync --recursive
git submodule update --init --recursive
Check if the submodules were updated:
# Check if the specified branch for Stride is correct
cd stride
git branch
cd ../
# Check if the specified branch for Cosmos is correct
cd cosmos
git branch
If the branches were not updated, that's ok. Sometimes things get stuck, so we have to manually check out and update branches despite the previous step covering those.
cd stride
git checkout <branch>
git pull origin <branch>
git log # Confirm if the latest commit is the same on the repository
cd ../
cd cosmos
git checkout <branch>
git pull origin <branch>
git log # Confirm if the latest commit is the same on the repository
If there are new public-facing transaction types on the Stride side, make sure to manually adjust its aminoType
by opening scripts/codegen.js
. Under options.aminoEncoding.exceptions
, you'll find stuff like:
"/stride.stakeibc.MsgLiquidStake": {
aminoType: "stakeibc/LiquidStake",
},
"/stride.stakeibc.MsgLSMLiquidStake": {
aminoType: "stakeibc/LSMLiquidStake",
},
Make sure to add the new transaction types with the same pattern:
"/stride.module.MsgModuleName": {
aminoType: "module/MsgModuleName",
},
Update the generated ts files:
pnpm run codegen
Build the module and types:
pnpm run build
If you haven't logged to npm cli, run:
npm login
Afterwards, update package.json version.
# Example: <version> = v0.4.1
git tag <version>
git push origin <version>
git push origin main
npm publish
🛠 Built by Cosmology — if you like our tools, please consider delegating to our validator ⚛️
Code built with the help of these related projects:
- @cosmwasm/ts-codegen for generated CosmWasm contract Typescript classes
- @cosmology/telescope a "babel for the Cosmos", Telescope is a TypeScript Transpiler for Cosmos Protobufs.
- cosmos-kit A wallet connector for the Cosmos ⚛️