Skip to content

Commit

Permalink
feat: @demex-sdk/wallet (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenkhong authored Nov 28, 2024
1 parent 7fe8135 commit 4780cec
Show file tree
Hide file tree
Showing 555 changed files with 1,548 additions and 305 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ yarn-error.log
*.tsbuildinfo
dist
dist-*

.env
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
},
"packageManager": "[email protected]",
"dependencies": {
"@changesets/cli": "^2.27.9"
"@changesets/cli": "^2.27.9",
"turbo": "2.3.0"
}
}
40 changes: 40 additions & 0 deletions packages/amino-types/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "@demex-sdk/amino-types",
"version": "0.0.3",
"license": "MIT",
"scripts": {
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
"build:cjs": "tsc -p tsconfig.cjs.json",
"build:es": "tsc -p tsconfig.es.json",
"build:types": "tsc -p tsconfig.types.json",
"build:clean": "concurrently 'rimraf ./dist-*' 'rimraf ./tsconfig.*.tsbuildinfo'"
},
"main": "./dist-cjs/index.js",
"module": "./dist-es/index.js",
"types": "./dist-types/index.d.ts",
"dependencies": {
"tslib": "^2.6.2"
},
"exports": {
".": {
"module": "./dist-es/index.js",
"node": "./dist-cjs/index.js",
"import": "./dist-es/index.js",
"require": "./dist-cjs/index.js",
"types": "./dist-types/index.d.ts"
},
"./package.json": {
"module": "./package.json",
"node": "./package.json",
"import": "./package.json",
"require": "./package.json"
}
},
"files": [
"dist-*/**"
],
"devDependencies": {
"concurrently": "7.0.0",
"eslint": "^9.13.0"
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { Carbon, TxTypes } from "@demex-sdk/codecs";
import { MsgUpdateParams as MsgAuthUpdateParams } from "@demex-sdk/codecs/cosmos/auth/v1beta1/tx.js";
import { MsgUpdateParams as MsgBankUpdateParams } from "@demex-sdk/codecs/cosmos/bank/v1beta1/tx.js";
import { CommunityPoolSpendProposal } from "@demex-sdk/codecs/cosmos/distribution/v1beta1/distribution.js";
import { MsgCommunityPoolSpend, MsgUpdateParams as MsgDistributionUpdateParams } from "@demex-sdk/codecs/cosmos/distribution/v1beta1/tx.js";
import { MsgExecLegacyContent, MsgUpdateParams as MsgGovUpdateParams } from "@demex-sdk/codecs/cosmos/gov/v1/tx.js";
import { TextProposal } from "@demex-sdk/codecs/cosmos/gov/v1beta1/gov.js";
import { ParameterChangeProposal } from "@demex-sdk/codecs/cosmos/params/v1beta1/params.js";
import { MsgUpdateParams as MsgSlashingUpdateParams } from "@demex-sdk/codecs/cosmos/slashing/v1beta1/tx.js";
import { MsgUpdateParams as MsgStakingUpdateParams } from "@demex-sdk/codecs/cosmos/staking/v1beta1/tx.js";
import { MsgCancelUpgrade, MsgSoftwareUpgrade } from "@demex-sdk/codecs/cosmos/upgrade/v1beta1/tx.js";
import { CancelSoftwareUpgradeProposal, SoftwareUpgradeProposal } from "@demex-sdk/codecs/cosmos/upgrade/v1beta1/upgrade.js";
import { Any } from "@demex-sdk/codecs/google/protobuf/any.js";
import { ClientUpdateProposal } from "@demex-sdk/codecs/ibc/core/client/v1/client.js";
import { MsgRemoveMinGasPrice } from "@demex-sdk/codecs/Switcheo/carbon/fee/tx.js";
import { MsgUpdateParams as MsgOracleUpdateParams } from "@demex-sdk/codecs/Switcheo/carbon/oracle/tx.js";
import { MsgUpdateParams as MsgAuthUpdateParams } from "@demex-sdk/codecs/data/cosmos/auth/v1beta1/tx";
import { MsgUpdateParams as MsgBankUpdateParams } from "@demex-sdk/codecs/data/cosmos/bank/v1beta1/tx";
import { CommunityPoolSpendProposal } from "@demex-sdk/codecs/data/cosmos/distribution/v1beta1/distribution";
import { MsgCommunityPoolSpend, MsgUpdateParams as MsgDistributionUpdateParams } from "@demex-sdk/codecs/data/cosmos/distribution/v1beta1/tx";
import { MsgExecLegacyContent, MsgUpdateParams as MsgGovUpdateParams } from "@demex-sdk/codecs/data/cosmos/gov/v1/tx";
import { TextProposal } from "@demex-sdk/codecs/data/cosmos/gov/v1beta1/gov";
import { ParameterChangeProposal } from "@demex-sdk/codecs/data/cosmos/params/v1beta1/params";
import { MsgUpdateParams as MsgSlashingUpdateParams } from "@demex-sdk/codecs/data/cosmos/slashing/v1beta1/tx";
import { MsgUpdateParams as MsgStakingUpdateParams } from "@demex-sdk/codecs/data/cosmos/staking/v1beta1/tx";
import { MsgCancelUpgrade, MsgSoftwareUpgrade } from "@demex-sdk/codecs/data/cosmos/upgrade/v1beta1/tx";
import { CancelSoftwareUpgradeProposal, SoftwareUpgradeProposal } from "@demex-sdk/codecs/data/cosmos/upgrade/v1beta1/upgrade";
import { Any } from "@demex-sdk/codecs/data/google/protobuf/any";
import { ClientUpdateProposal } from "@demex-sdk/codecs/data/ibc/core/client/v1/client";
import { MsgRemoveMinGasPrice } from "@demex-sdk/codecs/data/Switcheo/carbon/fee/tx";
import { MsgUpdateParams as MsgOracleUpdateParams } from "@demex-sdk/codecs/data/Switcheo/carbon/oracle/tx";


export enum ProposalTypes {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AminoConverter } from "@cosmjs/stargate";
import { Carbon, TxTypes as CarbonTxTypes } from "@demex-sdk/codecs";
import { TextProposal } from "@demex-sdk/codecs/cosmos/gov/v1beta1/gov.js";
import { MsgSubmitProposal } from "@demex-sdk/codecs/cosmos/gov/v1beta1/tx.js";
import { TextProposal } from "@demex-sdk/codecs/data/cosmos/gov/v1beta1/gov";
import { MsgSubmitProposal } from "@demex-sdk/codecs/data/cosmos/gov/v1beta1/tx";
import * as GovUtils from "../gov";
import { AminoInit, AminoProcess, AminoValueMap, ConvertEncType, generateAminoType, mapEachIndiv } from "../utils";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { AminoConverter } from "@cosmjs/stargate";
import { Any, TxTypes as CarbonTxTypes } from "@demex-sdk/codecs";
import { GenericAuthorization } from "@demex-sdk/codecs/cosmos/authz/v1beta1/authz.js";
import { MsgGrant } from "@demex-sdk/codecs/cosmos/authz/v1beta1/tx.js";
import { AllowedMsgAllowance, BasicAllowance } from "@demex-sdk/codecs/cosmos/feegrant/v1beta1/feegrant.js";
import { MsgGrantAllowance } from "@demex-sdk/codecs/cosmos/feegrant/v1beta1/tx.js";
import { GenericAuthorization } from "@demex-sdk/codecs/data/cosmos/authz/v1beta1/authz.js";
import { MsgGrant } from "@demex-sdk/codecs/data/cosmos/authz/v1beta1/tx.js";
import { AllowedMsgAllowance, BasicAllowance } from "@demex-sdk/codecs/data/cosmos/feegrant/v1beta1/feegrant.js";
import { MsgGrantAllowance } from "@demex-sdk/codecs/data/cosmos/feegrant/v1beta1/tx.js";
import { AminoInit, AminoProcess, AminoValueMap, ConvertEncType, generateAminoType, mapEachIndiv } from "../utils";

const TxTypes: Record<string, string> = {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions packages/amino-types/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist-cjs",
"baseUrl": "."
},
"extends": "../../tsconfig.cjs.json",
"include": ["src/"]
}
9 changes: 9 additions & 0 deletions packages/amino-types/tsconfig.es.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist-es",
"baseUrl": "."
},
"extends": "../../tsconfig.es.json",
"include": ["src/"]
}
9 changes: 9 additions & 0 deletions packages/amino-types/tsconfig.types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"baseUrl": ".",
"declarationDir": "dist-types",
"rootDir": "src",
},
"extends": "../../tsconfig.types.json",
"include": ["src/"]
}
92 changes: 46 additions & 46 deletions packages/codecs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"codecs:copy": "cp ~/go/src/github.com/Switcheo/carbon/gen/proto-ts.tar.gz .",
"codecs:update": "sh scripts/update-codecs.sh",
"codecs:register": "yarn codecs:reset && sh scripts/generate-registry.sh",
"codecs:reset": "find . -type f -name 'export.ts' -delete && rm -f src/*-models.ts"
"codecs:reset": "find . -type f -name 'export.ts' -delete && rm -f src/*-models.ts && rm -f src/index.ts"
},
"main": "./dist-cjs/index.js",
"module": "./dist-es/index.js",
Expand All @@ -36,67 +36,67 @@
"require": "./package.json"
},
"./alliance/*": {
"module": "./dist-es/alliance/*",
"node": "./dist-cjs/alliance/*",
"import": "./dist-es/alliance/*",
"require": "./dist-cjs/alliance/*",
"types": "./dist-types/alliance/*"
"module": "./dist-es/data/alliance/*",
"node": "./dist-cjs/data/alliance/*",
"import": "./dist-es/data/alliance/*",
"require": "./dist-cjs/data/alliance/*",
"types": "./dist-types/data/alliance/*"
},
"./amino/*": {
"module": "./dist-es/amino/*",
"node": "./dist-cjs/amino/*",
"import": "./dist-es/amino/*",
"require": "./dist-cjs/amino/*",
"types": "./dist-types/amino/*"
"module": "./dist-es/data/amino/*",
"node": "./dist-cjs/data/amino/*",
"import": "./dist-es/data/amino/*",
"require": "./dist-cjs/data/amino/*",
"types": "./dist-types/data/amino/*"
},
"./cosmos/*": {
"module": "./dist-es/cosmos/*",
"node": "./dist-cjs/cosmos/*",
"import": "./dist-es/cosmos/*",
"require": "./dist-cjs/cosmos/*",
"types": "./dist-types/cosmos/*"
"module": "./dist-es/data/cosmos/*",
"node": "./dist-cjs/data/cosmos/*",
"import": "./dist-es/data/cosmos/*",
"require": "./dist-cjs/data/cosmos/*",
"types": "./dist-types/data/cosmos/*"
},
"./ethermint/*": {
"module": "./dist-es/ethermint/*",
"node": "./dist-cjs/ethermint/*",
"import": "./dist-es/ethermint/*",
"require": "./dist-cjs/ethermint/*",
"types": "./dist-types/ethermint/*"
"module": "./dist-es/data/ethermint/*",
"node": "./dist-cjs/data/ethermint/*",
"import": "./dist-es/data/ethermint/*",
"require": "./dist-cjs/data/ethermint/*",
"types": "./dist-types/data/ethermint/*"
},
"./google/*": {
"module": "./dist-es/google/*",
"node": "./dist-cjs/google/*",
"import": "./dist-es/google/*",
"require": "./dist-cjs/google/*",
"types": "./dist-types/google/*"
"module": "./dist-es/data/google/*",
"node": "./dist-cjs/data/google/*",
"import": "./dist-es/data/google/*",
"require": "./dist-cjs/data/google/*",
"types": "./dist-types/data/google/*"
},
"./ibc/*": {
"module": "./dist-es/ibc/*",
"node": "./dist-cjs/ibc/*",
"import": "./dist-es/ibc/*",
"require": "./dist-cjs/ibc/*",
"types": "./dist-types/ibc/*"
"module": "./dist-es/data/ibc/*",
"node": "./dist-cjs/data/ibc/*",
"import": "./dist-es/data/ibc/*",
"require": "./dist-cjs/data/ibc/*",
"types": "./dist-types/data/ibc/*"
},
"./oraclesvc/*": {
"module": "./dist-es/oraclesvc/*",
"node": "./dist-cjs/oraclesvc/*",
"import": "./dist-es/oraclesvc/*",
"require": "./dist-cjs/oraclesvc/*",
"types": "./dist-types/oraclesvc/*"
"module": "./dist-es/data/oraclesvc/*",
"node": "./dist-cjs/data/oraclesvc/*",
"import": "./dist-es/data/oraclesvc/*",
"require": "./dist-cjs/data/oraclesvc/*",
"types": "./dist-types/data/oraclesvc/*"
},
"./Switcheo/*": {
"module": "./dist-es/Switcheo/*",
"node": "./dist-cjs/Switcheo/*",
"import": "./dist-es/Switcheo/*",
"require": "./dist-cjs/Switcheo/*",
"types": "./dist-types/Switcheo/*"
"module": "./dist-es/data/Switcheo/*",
"node": "./dist-cjs/data/Switcheo/*",
"import": "./dist-es/data/Switcheo/*",
"require": "./dist-cjs/data/Switcheo/*",
"types": "./dist-types/data/Switcheo/*"
},
"./tendermint/*": {
"module": "./dist-es/tendermint/*",
"node": "./dist-cjs/tendermint/*",
"import": "./dist-es/tendermint/*",
"require": "./dist-cjs/tendermint/*",
"types": "./dist-types/tendermint/*"
"module": "./dist-es/data/tendermint/*",
"node": "./dist-cjs/data/tendermint/*",
"import": "./dist-es/data/tendermint/*",
"require": "./dist-cjs/data/tendermint/*",
"types": "./dist-types/data/tendermint/*"
}
},
"files": [
Expand Down
1 change: 1 addition & 0 deletions packages/codecs/scripts/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const whitelistCosmosExports: { [name: string]: string } = {
'Params': 'cosmos/params/v1beta1',
'Slashing': 'cosmos/slashing/v1beta1',
'Gov': 'cosmos/gov/v1',
'Query': 'cosmos/base/query/v1beta1',
};

export const whitelistEthermintExports: { [name: string]: string } = {
Expand Down
4 changes: 2 additions & 2 deletions packages/codecs/scripts/generate-carbon-models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const whitelistCarbonExports: { [name: string]: string } = {

for (const exportName in whitelistCarbonExports) {
const directoryPath = whitelistCarbonExports[exportName];
const directory = path.join(pwd, 'src', directoryPath);
const directory = path.join(pwd, 'src/data', directoryPath);
const files = fs.readdirSync(directory);

for (const file of files) {
Expand All @@ -57,6 +57,6 @@ for (const exportName in whitelistCarbonExports) {
fs.appendFileSync(path.join(directory, 'export.ts'), exportLine);
}

const exportLine = `export * as ${exportName} from "./${directoryPath}/export"\n`;
const exportLine = `export * as ${exportName} from "./data/${directoryPath}/export"\n`;
fs.appendFileSync(modelsFile, exportLine);
}
4 changes: 2 additions & 2 deletions packages/codecs/scripts/generate-cosmos-models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const MODEL_BLACKLIST = ['MsgClientImpl', 'protobufPackage', 'GenesisState', 'Qu

for (const exportName in whitelistCosmosExports) {
const directoryPath = whitelistCosmosExports[exportName];
const directory = path.join(pwd, 'src', directoryPath);
const directory = path.join(pwd, 'src/data', directoryPath);
const files = fs.readdirSync(directory);

for (const file of files) {
Expand All @@ -25,6 +25,6 @@ for (const exportName in whitelistCosmosExports) {
fs.appendFileSync(path.join(directory, 'export.ts'), exportLine);
}

const exportLine = `export * as ${exportName} from "./${directoryPath}/export"\n`;
const exportLine = `export * as ${exportName} from "./data/${directoryPath}/export"\n`;
fs.appendFileSync(modelsFile, exportLine);
}
4 changes: 2 additions & 2 deletions packages/codecs/scripts/generate-ethermint-models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const MODEL_BLACKLIST = ['MsgClientImpl', 'protobufPackage', 'GenesisState', 'Qu

for (const exportName in whitelistEthermintExports) {
const directoryPath = whitelistEthermintExports[exportName];
const directory = path.join(pwd, 'src', directoryPath);
const directory = path.join(pwd, 'src/data', directoryPath);
const files = fs.readdirSync(directory);

for (const file of files) {
Expand All @@ -25,6 +25,6 @@ for (const exportName in whitelistEthermintExports) {
fs.appendFileSync(path.join(directory, 'export.ts'), exportLine);
}

const exportLine = `export * as ${exportName} from "./${directoryPath}/export"\n`;
const exportLine = `export * as ${exportName} from "./data/${directoryPath}/export"\n`;
fs.appendFileSync(modelsFile, exportLine);
}
6 changes: 3 additions & 3 deletions packages/codecs/scripts/generate-ibc-models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ for (const exportName in whitelistIbcExports) {
const directoryArr: string[] = whitelistIbcExports[exportName];
// Get common path (e.g. ibc/applications/transfer for Transfer)
const commonPath = directoryArr[0].split('/').slice(0, 4).join('/');
const commonDir = path.join(pwd, 'src', commonPath);
const commonDir = path.join(pwd, 'src/data', commonPath);
for (const subExportId in directoryArr) {
const directory = path.join(pwd, 'src', directoryArr[subExportId]);
const directory = path.join(pwd, 'src/data', directoryArr[subExportId]);
// Get file names in directory
const files = fs.readdirSync(directory);

Expand All @@ -33,6 +33,6 @@ for (const exportName in whitelistIbcExports) {
fs.appendFileSync(path.join(commonDir, 'export.ts'), exportLine);
}
}
const majorExportLine = `export * as ${exportName} from "./${commonPath}/export";\n`;
const majorExportLine = `export * as ${exportName} from "./data/${commonPath}/export";\n`;
fs.appendFileSync(modelsFile, majorExportLine);
}
4 changes: 2 additions & 2 deletions packages/codecs/scripts/generate-polynetwork-models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const whitelistExports: { [name: string]: string } = {

for (const exportName in whitelistExports) {
const directoryPath = `Switcheo/carbon/${whitelistExports[exportName]}`;
const directory = path.join(pwd, 'src', directoryPath);
const directory = path.join(pwd, 'src/data', directoryPath);
const files = fs.readdirSync(directory);

for (const file of files) {
Expand All @@ -32,6 +32,6 @@ for (const exportName in whitelistExports) {
fs.appendFileSync(path.join(directory, 'export.ts'), exportLine);
}

const exportLine = `export * as ${exportName} from "./${directoryPath}/export"\n`;
const exportLine = `export * as ${exportName} from "./data/${directoryPath}/export"\n`;
fs.appendFileSync(modelsFile, exportLine);
}
10 changes: 5 additions & 5 deletions packages/codecs/scripts/generate-query-clients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ const queryFiles = files.slice(2, files.length - 1);
const [registryFile] = files.slice(-1);

const deconflictMap: Record<string, string> = {
"Switcheo/carbon/fee/query": "demexFee",
"Switcheo/carbon/bank/query": "demexBank",
"cosmos/gov/v1/query": "govV1",
"cosmos/gov/v1beta1/query": "govV1beta1",
"ibc/applications/fee/v1/query": "ibcFee",
"data/Switcheo/carbon/fee/query": "demexFee",
"data/Switcheo/carbon/bank/query": "demexBank",
"data/cosmos/gov/v1/query": "govV1",
"data/cosmos/gov/v1beta1/query": "govV1beta1",
"data/ibc/applications/fee/v1/query": "ibcFee",
}

const capitalize = (input: string) => input[0].toUpperCase().concat(input.slice(1));
Expand Down
6 changes: 2 additions & 4 deletions packages/codecs/scripts/generate-registry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ set -eo pipefail

echo "Generating registry…"

TX_FILES=$(find src -path -prune -o -name '*.ts')
QUERY_FILES=$(find ./src -name 'query.ts')
TX_FILES=$(find src/data -path -prune -o -name '*.ts')
QUERY_FILES=$(find ./src/data -name 'query.ts')
REGISTRY_FILE=src/index.ts
COSMOS_MODELS_FILE=src/cosmos-models.ts
IBC_MODELS_FILE=src/ibc-models.ts
Expand All @@ -21,5 +21,3 @@ ts-node ./scripts/generate-carbon-models.ts $PWD $CARBON_MODELS_FILE
ts-node ./scripts/generate-registry.ts $TX_FILES $PWD $REGISTRY_FILE $POLYNETWORK_MODELS_FILE $CARBON_MODELS_FILE $COSMOS_MODELS_FILE $IBC_MODELS_FILE $ETHERMINT_MODELS_FILE >> $REGISTRY_FILE
ts-node ./scripts/generate-query-clients.ts $QUERY_FILES $REGISTRY_FILE


rm -rf ./scripts/protobuf-def.json
Loading

0 comments on commit 4780cec

Please sign in to comment.