Skip to content

Commit

Permalink
fix: fix sdk tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hugocaillard committed Jan 29, 2024
1 parent 0e30a30 commit c85f84e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions components/clarinet-sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,14 @@ export type GetDataVar = (contract: string, dataVar: string) => ClarityValue;
export type GetMapEntry = (contract: string, mapName: string, mapKey: ClarityValue) => ClarityValue;
export type GetContractAST = (contractId: string) => ContractAST;
export type GetContractsInterfaces = () => Map<string, ContractInterface>;
export type RunSnippet = (snippet: string) => ClarityValue | string;

// because the session is wrapped in a proxy the types need to be hardcoded
export type Simnet = {
[K in keyof SDK]: K extends "callReadOnlyFn" | "callPublicFn"
? CallFn
: K extends "runSnippet"
? ClarityValue
? RunSnippet
: K extends "deployContract"
? DeployContract
: K extends "transferSTX"
Expand Down Expand Up @@ -174,14 +175,15 @@ const getSessionProxy = () => ({
}

if (prop === "runSnippet") {
return (snippet: string) => {
const runSnippet: RunSnippet = (snippet) => {
const response = session[prop](snippet);
if (response.startsWith("0x")) {
return Cl.deserialize(response);
} else {
return response;
}
};
return runSnippet;
}

if (prop === "deployContract") {
Expand Down

0 comments on commit c85f84e

Please sign in to comment.