Skip to content

Commit

Permalink
chore: WIP add @seda-protocol/utils
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomasvdam committed Sep 27, 2024
1 parent f9c7fc3 commit 5cf8fb4
Show file tree
Hide file tree
Showing 18 changed files with 29 additions and 80 deletions.
1 change: 1 addition & 0 deletions libs/dev-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@cosmjs/stargate": "^0.32.4",
"@cosmjs/tendermint-rpc": "^0.32.4",
"@seda-protocol/proto-messages": "0.3.0-dev.0-1",
"@seda-protocol/utils": "../../../seda-explorer/libs/seda-utils/seda-protocol-utils-0.0.1.tgz",
"@seda-protocol/vm": "^0.0.4",
"big.js": "^6.2.1",
"dotenv": "^16.3.1",
Expand Down
7 changes: 3 additions & 4 deletions libs/dev-tools/src/cli/oracle-program/show.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { Command } from "commander";
import { Maybe } from "true-myth";

import {
spinnerError,
spinnerSuccess,
updateSpinnerText,
} from "@dev-tools/cli-utils/spinner";
import { buildQueryConfig } from "@dev-tools/services/config";
import { createWasmQueryClient } from "@dev-tools/services/oracle-program/query-client";
import { tryAsync } from "@dev-tools/utils/try-async";
import { tryAsync } from "@seda-protocol/utils";
import { Command } from "commander";
import { Maybe } from "true-myth";

export const show = new Command("show");
show.description("show an Oracle Program in the SEDA chain");
Expand Down
2 changes: 1 addition & 1 deletion libs/dev-tools/src/cli/oracle-program/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { buildSigningConfig } from "@dev-tools/services/config";
import { getOracleProgram } from "@dev-tools/services/oracle-program/get-oracle-program";
import { uploadOracleProgram } from "@dev-tools/services/oracle-program/upload-oracle-program";
import { Signer } from "@dev-tools/services/signer";
import { tryAsync } from "@dev-tools/utils/try-async";
import { tryAsync } from "@seda-protocol/utils";

export const upload = new Command("upload");
upload.description("upload an Oracle Program to the SEDA chain.");
Expand Down
8 changes: 6 additions & 2 deletions libs/dev-tools/src/cli/utils/spinner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ export const stopSpinner = () => {
}
};

export const spinnerError = (message?: string) => {
export const spinnerError = (message?: unknown) => {
if (spinner.isSpinning) {
spinner.fail(message);
if (typeof message === "string" || message?.toString) {
spinner.fail(`${message}`);
} else {
spinner.fail("Unknown error");
}
}
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ISigner } from "@dev-tools/services/signer";
import { createSigningClient } from "@dev-tools/services/signing-client";
import { tryAsync } from "@dev-tools/utils/try-async";
import { tryAsync } from "@seda-protocol/utils";
import { getDataResultBundle } from "./get-data-result-bundle";

type Opts = {
Expand Down
2 changes: 1 addition & 1 deletion libs/dev-tools/src/lib/services/dr/await-data-result.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ISigner } from "@dev-tools/services/signer";
import { createSigningClient } from "@dev-tools/services/signing-client";
import { tryAsync } from "@dev-tools/utils/try-async";
import { tryAsync } from "@seda-protocol/utils";
import { getDataResult } from "./get-data-result";

type Opts = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { tryAsync } from "@dev-tools/utils/try-async";
import { tryAsync } from "@seda-protocol/utils";
import type { ISigner } from "../signer";
import {
type DataRequestStatus,
Expand All @@ -8,7 +8,7 @@ import {
type StatusBatchResponse = {
drId: string;
status: DataRequestStatus | null;
error?: string;
error?: unknown;
};

export async function getDataRequestBundleStatus(
Expand Down
4 changes: 2 additions & 2 deletions libs/dev-tools/src/lib/services/dr/get-data-result-bundle.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { tryAsync } from "@dev-tools/utils/try-async";
import { tryAsync } from "@seda-protocol/utils";
import type { ISigner } from "../signer";
import { type DataRequestResult, getDataResult } from "./get-data-result";

type ResultBatchResponse = {
drId: string;
result: DataRequestResult | null;
error?: string;
error?: unknown;
};

export async function getDataResultBundle(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { tryAsync } from "@dev-tools/utils/try-async";
import { tryAsync } from "@seda-protocol/utils";
import { Maybe, Result } from "true-myth";
import type { ISigner } from "../signer";
import { createWasmQueryClient } from "./query-client";
Expand All @@ -14,7 +14,7 @@ export async function getOracleProgram(
bytecode: Uint8Array;
expirationHeight: number;
}>,
string
unknown
>
> {
const queryClient = await tryAsync(
Expand Down
2 changes: 1 addition & 1 deletion libs/dev-tools/src/lib/services/sign-and-send-tx.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate";
import type { EncodeObject } from "@cosmjs/proto-signing";
import type { DeliverTxResponse, StdFee } from "@cosmjs/stargate";
import { tryAsync } from "@dev-tools/utils/try-async";
import { tryAsync } from "@seda-protocol/utils";
import { Result, ResultNS } from "true-myth";
import {
DEFAULT_ADJUSTMENT_FACTOR,
Expand Down
2 changes: 1 addition & 1 deletion libs/dev-tools/src/lib/services/signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
type OfflineSigner,
} from "@cosmjs/proto-signing";
import { createWasmQueryClient } from "@dev-tools/services/oracle-program/query-client";
import { tryAsync } from "@dev-tools/utils/try-async";
import { tryAsync } from "@seda-protocol/utils";
import {
AUTO_CORE_CONTRACT_VALUE,
type SigningConfig,
Expand Down
2 changes: 1 addition & 1 deletion libs/dev-tools/src/lib/services/signing-client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate";
import { tryAsync } from "@dev-tools/utils/try-async";
import { sedachain } from "@seda-protocol/proto-messages";
import { tryAsync } from "@seda-protocol/utils";
import { MsgExecuteContractResponse } from "cosmjs-types/cosmwasm/wasm/v1/tx";
import { Result } from "true-myth";
import type { ISigner } from "./signer";
Expand Down
22 changes: 0 additions & 22 deletions libs/dev-tools/src/lib/utils/try-async.ts

This file was deleted.

3 changes: 2 additions & 1 deletion libs/vm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"@wasmer/wasi": "^1.2.2",
"true-myth": "^7.3.0",
"@noble/secp256k1": "2.1.0",
"@noble/hashes": "1.4.0"
"@noble/hashes": "1.4.0",
"@seda-protocol/utils": "../../../seda-explorer/libs/seda-utils/seda-protocol-utils-0.0.1.tgz"
}
}
35 changes: 0 additions & 35 deletions libs/vm/src/services/try.ts

This file was deleted.

2 changes: 1 addition & 1 deletion libs/vm/src/vm-imports.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as Secp256k1 from "@noble/secp256k1";
import { trySync } from "@seda-protocol/utils";
import { Maybe } from "true-myth";
import { keccak256, secp256k1Verify } from "./services/crypto";
import { trySync } from "./services/try";
import { type HttpFetchAction, HttpFetchResponse } from "./types/vm-actions";
import { PromiseStatus } from "./types/vm-promise";
import { WorkerToHost } from "./worker-host-communication.js";
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,17 @@
"@cosmjs/crypto": "^0.32.4",
"@cosmjs/proto-signing": "^0.32.4",
"@cosmjs/stargate": "^0.32.4",
"@noble/secp256k1": "2.1.0",
"@seda-protocol/utils": "../seda-explorer/libs/seda-utils/seda-protocol-utils-0.0.1.tgz",
"@types/node-gzip": "^1.1.1",
"@wasmer/wasi": "^1.2.2",
"as-bignum": "^0.3.1",
"big.js": "^6.2.1",
"@noble/secp256k1": "2.1.0",
"commander": "^11.0.0",
"cosmjs-types": "^0.9.0",
"dotenv": "^16.3.1",
"figlet": "^1.6.0",
"json-as": "0.9.6",
"as-bignum": "^0.3.1",
"node-fetch": "^3.3.2",
"node-gzip": "^1.1.2",
"ora": "^7.0.1",
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"rootDir": ".",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"moduleResolution": "bundler",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
Expand Down

0 comments on commit 5cf8fb4

Please sign in to comment.