@vlayer/sdk
Advanced tools
Comparing version 0.1.0-nightly-20241001-f254bee to 0.1.0-nightly-20241002-4630acc
@@ -5,3 +5,4 @@ { | ||
"module": "src/index.ts", | ||
"version": "0.1.0-nightly-20241001-f254bee", | ||
"version": "0.1.0-nightly-20241002-4630acc", | ||
"types": "src/index.ts", | ||
"scripts": { | ||
@@ -15,3 +16,2 @@ "build": "npm run gen:types", | ||
"@types/bun": "latest", | ||
"@types/mailparser": "^3.4.4", | ||
"abitype": "^1.0.6", | ||
@@ -25,6 +25,6 @@ "vitest": "^2.1.1" | ||
"dns-over-http-resolver": "^3.0.3", | ||
"mailparser": "^3.7.1", | ||
"postal-mime": "^2.3.2", | ||
"viem": "^2.21.0" | ||
"viem": "^2.21.0", | ||
"zod": "^3.23.8" | ||
} | ||
} |
@@ -21,10 +21,6 @@ import { | ||
export const testChainId1 = 100001; | ||
export const testChainId2 = 100002; | ||
const rpcUrls: Map<number, HttpTransport> = new Map([ | ||
[testChainId1, http()], | ||
[testChainId2, http("http://127.0.0.1:8546")], | ||
]); | ||
const rpcUrls: Map<number, HttpTransport> = new Map([[testChainId1, http()]]); | ||
export const chainIds = [testChainId1, testChainId2]; | ||
export const chainIds = [testChainId1]; | ||
@@ -31,0 +27,0 @@ export function client( |
import { VlayerClient } from "types/vlayer"; | ||
import { WebProofProvider } from "types/webProof"; | ||
import { WebProofProvider } from "types/webProofProvider"; | ||
import { prove } from "../prover"; | ||
export const createVlayerClient = ({ | ||
@@ -11,9 +12,9 @@ url, | ||
}): VlayerClient => { | ||
// TODO : implement high level api | ||
console.log("createVlayerClient with", url, webProofProvider); | ||
return { | ||
prove: async () => { | ||
console.log("prove"); | ||
console.log("url", url); | ||
console.log("webProofProvider", webProofProvider); | ||
prove: async ({ address, functionName, chainId, proverAbi, args }) => { | ||
return prove(address, proverAbi, functionName, args, chainId); | ||
}, | ||
}; | ||
}; |
export * from "./ethereum"; | ||
export * from "./webProof"; | ||
export * from "./utils"; | ||
export * from "./vlayer"; | ||
export * from "./webProofProvider"; |
@@ -1,3 +0,13 @@ | ||
import { Address, Hex } from "viem"; | ||
import { | ||
Abi, | ||
AbiFunction, | ||
AbiStateMutability, | ||
Address, | ||
ContractFunctionArgs, | ||
ContractFunctionName, | ||
Hex, | ||
} from "viem"; | ||
import { type ProverCallCommitment } from "types/webProofProvider.ts"; | ||
type Calldata = string; | ||
@@ -33,3 +43,3 @@ | ||
]; | ||
commitment: { | ||
assumptions: { | ||
proverContractAddress: Address; | ||
@@ -55,3 +65,15 @@ functionSelector: Hex; | ||
export type VlayerClient = { | ||
prove: () => void; | ||
prove: < | ||
T extends readonly [AbiFunction, ...Abi[number][]], | ||
F extends ContractFunctionName<T>, | ||
>( | ||
args: VlayerClientProveArgs<T, F>, | ||
) => void; | ||
}; | ||
export type VlayerClientProveArgs< | ||
T extends readonly [AbiFunction, ...Abi[number][]], | ||
F extends ContractFunctionName<T>, | ||
> = ProverCallCommitment<T, F> & { | ||
args: ContractFunctionArgs<T, AbiStateMutability, F>; | ||
}; |
@@ -1,4 +0,4 @@ | ||
//NOTE : this is copied from tlsn-js 5.4 | ||
// for some reason newest vertsions doesnt not export this type (clarification is in progress) | ||
// probaly it should be reexported from tlsn-js | ||
// NOTE : this is copied from tlsn-js 5.4 | ||
// for some reason newest versions doesn't export this type (clarification is in progress) | ||
// probably it should be reexported from tlsn-js | ||
@@ -103,5 +103,10 @@ export interface WebProof { | ||
} | ||
export type WebProofProvider = { | ||
requestProof: (url: string) => Promise<WebProof>; | ||
export const assertWebProof = function (candidate: { | ||
notaryUrl?: string; | ||
}): asserts candidate is WebProof { | ||
//for now only thing we check is notary url | ||
//TODO: implement later once we known the conteact with tlsn-js | ||
if (!candidate.notaryUrl) { | ||
throw new Error("Missing required parameter"); | ||
} | ||
}; |
@@ -12,3 +12,3 @@ import { | ||
import { type CallContext, type CallParams, Proof } from "types/vlayer"; | ||
import { type CallContext, type CallParams } from "types/vlayer"; | ||
import { v_call } from "./v_call"; | ||
@@ -47,29 +47,10 @@ import { testChainId1 } from "./helpers"; | ||
const returnValue = decodeFunctionResult({ | ||
const [, ...returnValue] = decodeFunctionResult({ | ||
abi: abi as Abi, | ||
data: evm_call_result, | ||
functionName: functionName as string, | ||
}); | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
}) as any[]; | ||
addDynamicParamsOffsets(abi, functionName, proof); | ||
return { proof, returnValue: returnValue as `0x${string}`[] }; | ||
return { proof, returnValue }; | ||
} | ||
function addDynamicParamsOffsets( | ||
abi: Abi, | ||
functionName: string | undefined, | ||
proof: Proof, | ||
) { | ||
const proverFunction = abi.find( | ||
(f) => f.type === "function" && f.name === functionName, | ||
) as AbiFunction; | ||
if (proverFunction?.outputs && proverFunction.outputs.length > 0) { | ||
const secondVerifyMethodParamType = proverFunction.outputs[0].type; | ||
if (secondVerifyMethodParamType === "string") { | ||
proof.dynamicParamsOffsets[0] = BigInt(32); | ||
} | ||
} | ||
} |
@@ -9,1 +9,4 @@ export { v_call } from "./api/v_call"; | ||
export { preverifyEmail } from "./api/email/preverify.ts"; | ||
export * from "./api/webProof"; | ||
export * from "./api/lib/types"; |
32980
4
36
977
+ Addedzod@^3.23.8
+ Addedzod@3.24.2(transitive)
- Removedmailparser@^3.7.1
- Removed@selderee/plugin-htmlparser2@0.11.0(transitive)
- Removeddeepmerge@4.3.1(transitive)
- Removeddom-serializer@2.0.0(transitive)
- Removeddomelementtype@2.3.0(transitive)
- Removeddomhandler@5.0.3(transitive)
- Removeddomutils@3.2.2(transitive)
- Removedencoding-japanese@2.2.0(transitive)
- Removedentities@4.5.0(transitive)
- Removedhe@1.2.0(transitive)
- Removedhtml-to-text@9.0.5(transitive)
- Removedhtmlparser2@8.0.2(transitive)
- Removediconv-lite@0.6.3(transitive)
- Removedleac@0.6.0(transitive)
- Removedlibbase64@1.3.0(transitive)
- Removedlibmime@5.3.6(transitive)
- Removedlibqp@2.1.1(transitive)
- Removedlinkify-it@5.0.0(transitive)
- Removedmailparser@3.7.2(transitive)
- Removedmailsplit@5.4.2(transitive)
- Removednodemailer@6.9.16(transitive)
- Removedparseley@0.12.1(transitive)
- Removedpeberminta@0.9.0(transitive)
- Removedpunycode.js@2.3.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedselderee@0.11.0(transitive)
- Removedtlds@1.255.0(transitive)
- Removeduc.micro@2.1.0(transitive)