diff --git a/src/certificates/index.ts b/src/certificates/index.ts index bc1c414..d20f33a 100644 --- a/src/certificates/index.ts +++ b/src/certificates/index.ts @@ -6,6 +6,7 @@ import { createStarGateMessage } from "../pbclient/pbclient"; import { QueryCertificatesRequest, QueryCertificatesResponse } from "../protobuf/akash/cert/v1beta3/query"; import { CertificateFilter } from "../protobuf/akash/cert/v1beta1/cert"; +// eslint-disable-next-line @typescript-eslint/no-var-requires const JsonRPC = require("simple-jsonrpc-js"); import { toBase64 } from "pvutils"; diff --git a/src/keplr/index.ts b/src/keplr/index.ts index f598e2d..f3b7263 100644 --- a/src/keplr/index.ts +++ b/src/keplr/index.ts @@ -1,8 +1,13 @@ import { getAkashTypeRegistry } from "../stargate"; import { defaultRegistryTypes, SigningStargateClient } from "@cosmjs/stargate"; -import { Registry } from "@cosmjs/proto-signing"; +import { OfflineDirectSigner, OfflineSigner, Registry } from "@cosmjs/proto-signing"; import { AminoTypes } from "@cosmjs/stargate"; import { Certificate } from "../protobuf/akash/cert/v1beta2/cert"; +import { MsgCreateCertificate } from "../protobuf/akash/cert/v1beta1/cert"; + +interface Chain { + id: string; +} export function getChains() { return { @@ -15,45 +20,37 @@ export function getChains() { }; } -export function getSigner(chain: any) { - return (window as any).getOfflineSignerAuto(chain.id); +export function getSigner(chain: Chain) { + return window.getOfflineSignerAuto(chain.id); } -export async function get(chain: any, signer: any, endPoint: string) { - const customAminoTypes: any = new AminoTypes({ +export async function get(chain: Chain, signer: OfflineSigner | OfflineDirectSigner, endPoint: string) { + const customAminoTypes = new AminoTypes({ "/akash.cert.v1beta2.MsgCreateCertificate": { aminoType: "cert/cert-create-certificate", - toAmino: ({ owner, cert, pubkey }: any) => { - const buf: any = Certificate.encode( + toAmino: ({ cert, pubkey }: MsgCreateCertificate) => { + const buf = Certificate.encode( Certificate.fromPartial({ - owner, cert, pubkey - } as any) + }) ).finish(); const encoded = Buffer.from(buf); return encoded.toString("base64"); }, - fromAmino: ({ owner, cert, pubkey }: any) => { + fromAmino: ({ cert, pubkey }: MsgCreateCertificate) => { return Certificate.fromPartial({ - owner, cert, pubkey - } as any); + }); } } - } as any); + }); const myRegistry = new Registry([...defaultRegistryTypes, ...getAkashTypeRegistry()]); return await SigningStargateClient.connectWithSigner(endPoint, signer, { - bip44: { - coinType: "118" - }, registry: myRegistry, aminoTypes: customAminoTypes - } as any); -} -function bufferToHex(buffer: any) { - return [...new Uint8Array(buffer)].map(b => b.toString(16).padStart(2, "0")).join(""); + }); } diff --git a/src/sdl/index.ts b/src/sdl/index.ts index 92d9456..8fe1ba0 100644 --- a/src/sdl/index.ts +++ b/src/sdl/index.ts @@ -110,7 +110,9 @@ export class SDL { if ( units > 0 && - Object.values(gpu.attributes?.vendor || {}).some(models => models?.some(model => model.interface && !GPU_SUPPORTED_INTERFACES.includes(model.interface))) + Object.values(gpu.attributes?.vendor || {}).some(models => + models?.some(model => model.interface && !GPU_SUPPORTED_INTERFACES.includes(model.interface)) + ) ) { throw new Error(`GPU interface must be one of the supported interfaces (${GPU_SUPPORTED_INTERFACES.join(",")}).`); } diff --git a/src/types/global.d.ts b/src/types/global.d.ts new file mode 100644 index 0000000..f1e56a7 --- /dev/null +++ b/src/types/global.d.ts @@ -0,0 +1,9 @@ +import { OfflineDirectSigner, OfflineSigner } from "@cosmjs/proto-signing"; + +export {}; + +declare global { + interface Window { + getOfflineSignerAuto: (chainId: string) => Promise; + } +} diff --git a/tsconfig.json b/tsconfig.json index 759daac..81423b8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -68,6 +68,6 @@ "skipLibCheck": true /* Skip type checking of declaration files. */, "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ }, - "include": ["./src"], + "include": ["./src/**/*"], "exclude": ["./examples", "./tests"] }