@settlemint/sdk-viem 2.1.4-pr0ce48af6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/viem.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import{http as i,createPublicClient as l,createWalletClient as c,defineChain as o}from"viem";import p from"viem/chains";var u=t=>l({chain:r(t),transport:i(t.rpcUrl,{batch:!0,timeout:6e4,...t.httpTransportConfig})}),m=t=>{let n=r(t);return e=>c({chain:n,transport:i(t.rpcUrl,{batch:!0,timeout:6e4,...t.httpTransportConfig,fetchOptions:{...t?.httpTransportConfig?.fetchOptions,headers:{...t?.httpTransportConfig?.fetchOptions?.headers,"x-auth-challenge-response":e?.challengeResponse??"","x-auth-verification-id":e?.verificationId??""}}})})};function r({chainId:t,chainName:n,rpcUrl:e}){return Object.values(p).find(a=>a.id.toString()===t)??o({id:Number(t),name:n,rpcUrls:{default:{http:[e]}},nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"}})}export{u as getPublicClient,m as getWalletClient};
2
+ //# sourceMappingURL=viem.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/viem.ts"],"sourcesContent":["import {\n http,\n type Chain,\n type HttpTransportConfig,\n type WalletClient,\n createPublicClient,\n createWalletClient,\n defineChain,\n} from \"viem\";\nimport chains from \"viem/chains\";\n\n/**\n * The options for the viem client.\n */\nexport interface ClientOptions {\n /**\n * The chain id to use for the viem client.\n */\n chainId: string;\n /**\n * The chain name to use for the viem client.\n */\n chainName: string;\n /**\n * The rpc url to use for the viem client.\n */\n rpcUrl: string;\n /**\n * The http transport config to use for the wallet client.\n */\n httpTransportConfig?: HttpTransportConfig;\n}\n\n/**\n * Get a public client. Use this if you need to read from the blockchain.\n * @param options - The options for the public client.\n * @returns The public client.\n */\nexport const getPublicClient = (options: ClientOptions) =>\n createPublicClient({\n chain: getChain(options),\n transport: http(options.rpcUrl, {\n batch: true,\n timeout: 60_000,\n ...options.httpTransportConfig,\n }),\n });\n\n/**\n * The options for the wallet client.\n */\nexport interface WalletVerificationOptions {\n /**\n * The verification id (used for HD wallets), if not provided, the challenge response will be validated against all active verifications.\n */\n verificationId?: string;\n /**\n * The challenge response (used for HD wallets)\n */\n challengeResponse: string;\n}\n\n/**\n * Get a wallet client. Use this if you need to write to the blockchain.\n * @param options - The options for the wallet client.\n * @returns A function that returns a wallet client. The function can be called with verification options.\n */\nexport const getWalletClient = (options: ClientOptions) => {\n const chain = getChain(options);\n return (verificationOptions?: WalletVerificationOptions): WalletClient =>\n createWalletClient({\n chain,\n transport: http(options.rpcUrl, {\n batch: true,\n timeout: 60_000,\n ...options.httpTransportConfig,\n fetchOptions: {\n ...options?.httpTransportConfig?.fetchOptions,\n headers: {\n ...options?.httpTransportConfig?.fetchOptions?.headers,\n \"x-auth-challenge-response\": verificationOptions?.challengeResponse ?? \"\",\n \"x-auth-verification-id\": verificationOptions?.verificationId ?? \"\",\n },\n },\n }),\n });\n};\n\nfunction getChain({ chainId, chainName, rpcUrl }: Pick<ClientOptions, \"chainId\" | \"chainName\" | \"rpcUrl\">): Chain {\n const knownChain = Object.values(chains).find((chain) => chain.id.toString() === chainId);\n return (\n knownChain ??\n defineChain({\n id: Number(chainId),\n name: chainName,\n rpcUrls: {\n default: {\n http: [rpcUrl],\n },\n },\n nativeCurrency: {\n decimals: 18,\n name: \"Ether\",\n symbol: \"ETH\",\n },\n })\n );\n}\n"],"mappings":"AAAA,OACE,QAAAA,EAIA,sBAAAC,EACA,sBAAAC,EACA,eAAAC,MACK,OACP,OAAOC,MAAY,cA6BZ,IAAMC,EAAmBC,GAC9BL,EAAmB,CACjB,MAAOM,EAASD,CAAO,EACvB,UAAWN,EAAKM,EAAQ,OAAQ,CAC9B,MAAO,GACP,QAAS,IACT,GAAGA,EAAQ,mBACb,CAAC,CACH,CAAC,EAqBUE,EAAmBF,GAA2B,CACzD,IAAMG,EAAQF,EAASD,CAAO,EAC9B,OAAQI,GACNR,EAAmB,CACjB,MAAAO,EACA,UAAWT,EAAKM,EAAQ,OAAQ,CAC9B,MAAO,GACP,QAAS,IACT,GAAGA,EAAQ,oBACX,aAAc,CACZ,GAAGA,GAAS,qBAAqB,aACjC,QAAS,CACP,GAAGA,GAAS,qBAAqB,cAAc,QAC/C,4BAA6BI,GAAqB,mBAAqB,GACvE,yBAA0BA,GAAqB,gBAAkB,EACnE,CACF,CACF,CAAC,CACH,CAAC,CACL,EAEA,SAASH,EAAS,CAAE,QAAAI,EAAS,UAAAC,EAAW,OAAAC,CAAO,EAAmE,CAEhH,OADmB,OAAO,OAAOT,CAAM,EAAE,KAAMK,GAAUA,EAAM,GAAG,SAAS,IAAME,CAAO,GAGtFR,EAAY,CACV,GAAI,OAAOQ,CAAO,EAClB,KAAMC,EACN,QAAS,CACP,QAAS,CACP,KAAM,CAACC,CAAM,CACf,CACF,EACA,eAAgB,CACd,SAAU,GACV,KAAM,QACN,OAAQ,KACV,CACF,CAAC,CAEL","names":["http","createPublicClient","createWalletClient","defineChain","chains","getPublicClient","options","getChain","getWalletClient","chain","verificationOptions","chainId","chainName","rpcUrl"]}
package/package.json ADDED
@@ -0,0 +1,76 @@
1
+ {
2
+ "name": "@settlemint/sdk-viem",
3
+ "description": "Viem (TypeScript Interface for Ethereum) module for SettleMint SDK",
4
+ "version": "2.1.4-pr0ce48af6",
5
+ "type": "module",
6
+ "private": false,
7
+ "license": "FSL-1.1-MIT",
8
+ "author": {
9
+ "name": "SettleMint",
10
+ "email": "support@settlemint.com",
11
+ "url": "https://settlemint.com"
12
+ },
13
+ "homepage": "https://github.com/settlemint/sdk/blob/main/sdk/viem/README.md",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/settlemint/sdk.git",
17
+ "directory": "sdk/viem"
18
+ },
19
+ "bugs": {
20
+ "url": "https://github.com/settlemint/sdk/issues",
21
+ "email": "support@settlemint.com"
22
+ },
23
+ "files": ["dist"],
24
+ "main": "./dist/viem.cjs",
25
+ "module": "./dist/viem.mjs",
26
+ "types": "./dist/viem.d.ts",
27
+ "exports": {
28
+ "./package.json": "./package.json",
29
+ ".": {
30
+ "import": {
31
+ "types": "./dist/viem.d.ts",
32
+ "default": "./dist/viem.mjs"
33
+ },
34
+ "require": {
35
+ "types": "./dist/viem.d.cts",
36
+ "default": "./dist/viem.cjs"
37
+ }
38
+ }
39
+ },
40
+ "scripts": {
41
+ "build": "tsup-node",
42
+ "dev": "tsup-node --watch",
43
+ "publint": "publint run --strict",
44
+ "attw": "attw --pack .",
45
+ "test": "bun test",
46
+ "test:coverage": "bun test --coverage",
47
+ "typecheck": "tsc --noEmit",
48
+ "publish-npm": "bun publish --tag ${TAG} --access public || exit 0",
49
+ "prepack": "cp ../../LICENSE .",
50
+ "docs": "typedoc --options '../../typedoc.config.mjs' --entryPoints src/viem.ts --out ./docs"
51
+ },
52
+ "devDependencies": {},
53
+ "dependencies": {
54
+ "@settlemint/sdk-utils": "2.1.4-pr0ce48af6",
55
+ "viem": "^2"
56
+ },
57
+ "peerDependencies": {},
58
+ "engines": {
59
+ "node": ">=20"
60
+ },
61
+ "keywords": [
62
+ "settlemint",
63
+ "blockchain",
64
+ "blockchain-development",
65
+ "enterprise-blockchain",
66
+ "web3",
67
+ "web3-development",
68
+ "web3-tools",
69
+ "sdk",
70
+ "typescript",
71
+ "eth",
72
+ "ethereum",
73
+ "dapps",
74
+ "wallet"
75
+ ]
76
+ }