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

Sdk rewrite pt1 #3

Merged
merged 25 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d9e96fc
private test
yanabaskakova Aug 4, 2024
8b1978b
move isBrowser check back + change check in initwallert
yanabaskakova Aug 4, 2024
fc4ae4d
built of the lastest commit
yanabaskakova Aug 4, 2024
f720a9c
add mnemonic wallet import
yanabaskakova Aug 5, 2024
68b1e93
update init wallet browser check
yanabaskakova Aug 5, 2024
025f03a
add log
yanabaskakova Aug 7, 2024
53bde4f
save keys to map
yanabaskakova Aug 7, 2024
1fe0925
update chat client
yanabaskakova Aug 7, 2024
a20b61d
add model name to broadcast func
yanabaskakova Aug 7, 2024
6da69b2
logs
yanabaskakova Aug 7, 2024
7de9a07
update log
yanabaskakova Aug 7, 2024
215a644
pass model name to sign messgae in sig payment
yanabaskakova Aug 7, 2024
6b503da
rewr pt1
yanabaskakova Aug 9, 2024
5c205f5
clean up of unnecessary props
yanabaskakova Aug 9, 2024
3b7db83
remove division of nesaclient
yanabaskakova Aug 9, 2024
dc5c82d
remove comments
yanabaskakova Aug 9, 2024
aa1d0ea
update request chat method + nesachat types
yanabaskakova Aug 9, 2024
129e205
rewrite request session to async await
yanabaskakova Aug 9, 2024
c315e20
rename questiontypes to QuestionParams
yanabaskakova Aug 9, 2024
f00a8d1
update request chat status
yanabaskakova Aug 9, 2024
5c44c2b
rename isChatinging to iisChatting
yanabaskakova Aug 9, 2024
e66384f
rename isRegisterSessioning
yanabaskakova Aug 9, 2024
fbd64d9
rename offline signer
yanabaskakova Aug 9, 2024
5f44dc5
change checks and smaller updates
yanabaskakova Aug 11, 2024
26f9a89
update checks and types
yanabaskakova Aug 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/.tsbuildinfo

Large diffs are not rendered by default.

26 changes: 15 additions & 11 deletions dist/chatClient.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ChainInfo } from "@keplr-wallet/types";
import { NesaClient } from "./client";
interface ConfigOptions {
modelName: string;
lockAmount?: string;
Expand All @@ -7,8 +8,10 @@ interface ConfigOptions {
singlePaymentAmount?: string;
lowBalance?: string;
privateKey?: string;
mnemonic?: string;
chatId?: string;
}
interface questionTypes {
interface QuestionParams {
messages: any;
model: string;
stream?: boolean;
Expand All @@ -25,13 +28,14 @@ declare class ChatClient {
singlePaymentAmount: string;
lowBalance: string;
lockAmountDenom: string;
chatId: string;
private walletName;
private chatQueue;
private chatSeq;
private totalUsedPayment;
private totalSignedPayment;
private isChatinging;
private isRegisterSessioning;
private isChatting;
private isRegisteringSession;
private agentUrl;
private assistantRoleName;
private lastNesaClientPromise;
Expand All @@ -40,26 +44,26 @@ declare class ChatClient {
private lastInitOfflineSignerPromise;
private chatProgressReadable;
private nesaClient;
private offLinesigner;
private offlineSigner;
private signaturePayment;
private isBrowser;
private privateKey;
private mnemonic;
private isEverRequestSession;
private tokenPrice;
constructor(options: ConfigOptions);
initWallet(): any;
getNesaClient(): any;
getChainParams(nesaClient: any): any;
getNesaClient(): Promise<NesaClient>;
getChainParams(nesaClient: NesaClient): any;
version(): string;
checkChainInfo(): string | false;
getSignaturePayment(): string;
checkSinglePaymentAmount(): string;
requestChatQueue(readableStream: any, question: questionTypes): void;
requestChatQueue(readableStream: any, question: QuestionParams): void;
requestCloseHeartbeat(): void;
requestAgentInfo(result: any, readableStream: any): any;
checkSignBroadcastResult(readableStream?: any): Promise<unknown>;
requestChatStatus(): Promise<unknown>;
requestSession(): Promise<unknown>;
requestChat(question: questionTypes): Promise<unknown>;
requestChatStatus(): any;
requestSession(): Promise<any>;
requestChat(question: QuestionParams): Promise<any>;
}
export default ChatClient;
477 changes: 231 additions & 246 deletions dist/chatClient.js

Large diffs are not rendered by default.

34 changes: 24 additions & 10 deletions dist/client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
import { OfflineSigner } from "@cosmjs/proto-signing";
import { SigningStargateClient, SigningStargateClientOptions, GasPrice, Event, QueryClient } from "@cosmjs/stargate";
import { CometClient } from "@cosmjs/tendermint-rpc";
import { Logger } from './logger';
import { VRF } from './codec/agent/v1/tx';
import { Logger } from "./logger";
import { VRF } from "./codec/agent/v1/tx";
import { Payment, Params, SessionStatus } from "./codec/agent/v1/agent";
import { Coin } from "./codec/cosmos/base/v1beta1/coin";
import { AgentExtension } from './queries';
import { QueryParamsResponse, QueryInferenceAgentResponse, QuerySessionResponse, QueryVRFSeedResponse, QuerySessionByAgentResponse } from "./codec/agent/v1/query";
import { AgentExtension } from "./queries";
import { StdFee } from "@cosmjs/amino";
export type NesaClientOptions = SigningStargateClientOptions & {
logger?: Logger;
Expand All @@ -28,9 +27,21 @@ export type RegisterSessionResult = MsgResult & {
export declare class NesaClient {
readonly gasPrice: GasPrice;
readonly sign: SigningStargateClient;
readonly signByModel: {
[modelName: string]: SigningStargateClient;
};
readonly query: QueryClient & AgentExtension;
readonly queryByModel: {
[modelName: string]: QueryClient & AgentExtension;
};
readonly tm: CometClient;
readonly tmByModel: {
[modelName: string]: CometClient;
};
readonly senderAddress: string;
readonly senderAddressByModel: {
[modelName: string]: string;
};
readonly logger: Logger;
readonly chainId: string;
readonly estimatedBlockTime: number;
Expand All @@ -42,12 +53,15 @@ export declare class NesaClient {
updateParams(authority: string, params: Params): Promise<MsgResult>;
registerInferenceAgent(url: string, version: Long): Promise<MsgResult>;
broadcastRegisterSession(): any;
signRegisterSession(sessionId: string, modelName: string, fee: StdFee, lockBalance?: Coin, vrf?: VRF): Promise<any>;
signRegisterSession(sessionId: string, modelName: string, fee: StdFee, lockBalance?: Coin, vrf?: VRF): Promise<{
sessionId: string;
transactionHash: string;
}>;
registerSession(sessionId: string, modelName: string, lockBalance?: Coin, vrf?: VRF): Promise<RegisterSessionResult>;
submitPayment(sessionId: string, signature: Uint8Array, payment?: Payment): Promise<MsgResult>;
getParams(): Promise<QueryParamsResponse>;
getInferenceAgent(account: string, modelName: string, limit: Long, key: Uint8Array): Promise<QueryInferenceAgentResponse>;
getSession(sessionId: string): Promise<QuerySessionResponse>;
getSessionByAgent(account: string, status: SessionStatus, limit: Long, orderDesc: boolean, key: Uint8Array, expireTime?: Date): Promise<QuerySessionByAgentResponse>;
getVRFSeed(account: string): Promise<QueryVRFSeedResponse>;
getParams(): Promise<import("./codec/agent/v1/query").QueryParamsResponse>;
getInferenceAgent(account: string, modelName: string, limit: Long, key: Uint8Array): Promise<import("./codec/agent/v1/query").QueryInferenceAgentResponse>;
getSession(sessionId: string): Promise<import("./codec/agent/v1/query").QuerySessionResponse>;
getSessionByAgent(account: string, status: SessionStatus, limit: Long, orderDesc: boolean, key: Uint8Array, expireTime?: Date): Promise<import("./codec/agent/v1/query").QuerySessionByAgentResponse>;
getVRFSeed(account: string): Promise<import("./codec/agent/v1/query").QueryVRFSeedResponse>;
}
80 changes: 40 additions & 40 deletions dist/client.js

Large diffs are not rendered by default.

31 changes: 23 additions & 8 deletions dist/encryptUtils.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
import { NesaClient } from "./client";
import { CosmjsOfflineSigner } from "@leapwallet/cosmos-snap-provider";
import { VRF } from "./codec/agent/v1/tx";
type Key = {
x: string;
y: string;
};
declare class EncryptUtils {
static privateKey: any;
static publicKey: any;
static privateKeyBuf: any;
static generateKey(): {
static privateKeyMap: {
[recordId: string]: Key;
};
static publicKeyMap: {
[recordId: string]: Key;
};
static privateKeyBufMap: {
[recordId: string]: Key;
};
static generateKey(recordId: string): {
privateKey: any;
publicKey: any;
};
static sortObjectKeys(obj: Record<string, any>): Record<string, any>;
static signMessage(message: string, chatSeq: number, isQuestion?: boolean): string;
static requestVrf(client: any, offlineSigner: any): Promise<any>;
static signHeartbeat(message: string): string;
static signMessage(recordId: string, message: string, chatSeq: number, isQuestion?: boolean): string;
static requestVrf(recordId: string, client: NesaClient, offlineSigner: CosmjsOfflineSigner): Promise<{
vrf: VRF;
sessionId: string;
}>;
static signHeartbeat(recordId: string, message: string): string;
}
export default EncryptUtils;
100 changes: 36 additions & 64 deletions dist/encryptUtils.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions dist/helpers/getAgentUrls.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { InferenceAgent } from "../codec/agent/v1/agent";
export declare const getAgentUrls: (selectAgent: InferenceAgent) => {
agentWsUrl: string;
agentHeartbeatUrl: string;
};
12 changes: 12 additions & 0 deletions dist/helpers/getAgentUrls.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions dist/helpers/getIsChainInfoValid.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { ChainInfo } from "@leapwallet/cosmos-snap-provider";
export declare const getIsChainInfoValid: (chainInfo: ChainInfo) => string | false | undefined;
12 changes: 12 additions & 0 deletions dist/helpers/getIsChainInfoValid.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion dist/socket.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ interface ISocket {
heartbeat_timer: NodeJS.Timeout | string | number | undefined;
heartbeat_interval: number;
init: (handle: {
modelName?: string;
recordId: string;
ws_url: string;
onopen: () => void;
onclose?: (e: Event) => void;
onerror?: (e: Event | Error) => void;
}) => (WebSocket | null | undefined);
}) => WebSocket | null | undefined;
heartbeat: Function;
send: (data: any, callback?: Function) => void;
close: Function;
Expand Down
27 changes: 14 additions & 13 deletions dist/socket.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading