@settlemint/sdk-viem 2.3.2-pr7f10bc49 → 2.3.2-pr8e5bdf14
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.cjs +1 -1
- package/dist/viem.cjs.map +1 -1
- package/dist/viem.d.cts +19 -15
- package/dist/viem.d.ts +19 -15
- package/dist/viem.mjs +1 -1
- package/dist/viem.mjs.map +1 -1
- package/package.json +2 -2
package/dist/viem.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var I=Object.create;var p=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var P=Object.getPrototypeOf,A=Object.prototype.hasOwnProperty;var b=(t,e)=>{for(var i in e)p(t,i,{get:e[i],enumerable:!0})},C=(t,e,i,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of v(e))!A.call(t,o)&&o!==i&&p(t,o,{get:()=>e[o],enumerable:!(a=S(e,o))||a.enumerable});return t};var j=(t,e,i)=>(i=t!=null?I(P(t)):{},C(e||!t||!t.__esModule?p(i,"default",{value:t,enumerable:!0}):i,t)),H=t=>C(p({},"__esModule",{value:!0}),t);var D={};b(D,{ClientOptionsSchema:()=>h,GetChainIdOptionsSchema:()=>R,OTPAlgorithm:()=>W,WalletVerificationType:()=>d,getChainId:()=>E,getPublicClient:()=>w,getWalletClient:()=>k});module.exports=H(D);var f=require("@settlemint/sdk-utils/http"),m=require("@settlemint/sdk-utils/runtime"),n=require("@settlemint/sdk-utils/validation"),r=require("viem"),_=j(require("viem/chains"),1),c=require("zod/v4");function V(t){return{createWalletVerificationChallenges(e){return t.request({method:"user_createWalletVerificationChallenges",params:[e.addressOrObject]})}}}function u(t){return{createWalletVerification(e){return t.request({method:"user_createWalletVerification",params:[e.userWalletAddress,e.walletVerificationInfo]})}}}function g(t){return{createWallet(e){return t.request({method:"user_createWallet",params:[e.keyVaultId,e.walletInfo]})}}}function y(t){return{deleteWalletVerification(e){return t.request({method:"user_deleteWalletVerification",params:[e.userWalletAddress,e.verificationId]})}}}function O(t){return{getWalletVerifications(e){return t.request({method:"user_walletVerifications",params:[e.userWalletAddress]})}}}function x(t){return{verifyWalletVerificationChallenge(e){return t.request({method:"user_verifyWalletVerificationChallenge",params:[e.addressOrObject,e.challengeResponse]})}}}var d=(a=>(a.PINCODE="PINCODE",a.OTP="OTP",a.SECRET_CODES="SECRET_CODES",a))(d||{}),W=(l=>(l.SHA1="SHA1",l.SHA224="SHA224",l.SHA256="SHA256",l.SHA384="SHA384",l.SHA512="SHA512",l.SHA3_224="SHA3-224",l.SHA3_256="SHA3-256",l.SHA3_384="SHA3-384",l.SHA3_512="SHA3-512",l))(W||{});var h=c.z.object({accessToken:n.ApplicationAccessTokenSchema.optional(),chainId:c.z.string().optional(),chainName:c.z.string(),rpcUrl:n.UrlOrPathSchema,httpTransportConfig:c.z.any().optional()}),w=t=>{(0,m.ensureServer)();let e=(0,n.validate)(h,t);return(0,r.createPublicClient)({chain:T(e),transport:(0,r.http)(e.rpcUrl,{batch:!0,timeout:6e4,...e.httpTransportConfig,fetchOptions:{...e?.httpTransportConfig?.fetchOptions,headers:(0,f.appendHeaders)(e?.httpTransportConfig?.fetchOptions?.headers,{"x-auth-token":e.accessToken})}})})},k=t=>{(0,m.ensureServer)();let e=(0,n.validate)(h,t),i=T(e);return a=>(0,r.createWalletClient)({chain:i,transport:(0,r.http)(e.rpcUrl,{batch:!0,timeout:6e4,...e.httpTransportConfig,fetchOptions:{...e?.httpTransportConfig?.fetchOptions,headers:(0,f.appendHeaders)(e?.httpTransportConfig?.fetchOptions?.headers,{"x-auth-token":e.accessToken,"x-auth-challenge-response":a?.challengeResponse??"","x-auth-verification-id":a?.verificationId??""})}})}).extend(r.publicActions).extend(g).extend(O).extend(u).extend(y).extend(V).extend(x)},R=c.z.object({accessToken:n.ApplicationAccessTokenSchema.optional(),rpcUrl:n.UrlOrPathSchema,httpTransportConfig:c.z.any().optional()});async function E(t){(0,m.ensureServer)();let e=(0,n.validate)(R,t);return(0,r.createPublicClient)({transport:(0,r.http)(e.rpcUrl,{...e.httpTransportConfig,fetchOptions:{...e?.httpTransportConfig?.fetchOptions,headers:(0,f.appendHeaders)(e?.httpTransportConfig?.fetchOptions?.headers,{"x-auth-token":e.accessToken})}})}).getChainId()}function T({chainId:t,chainName:e,rpcUrl:i}){return Object.values(_).find(o=>o.id.toString()===t)??(0,r.defineChain)({id:Number(t),name:e,rpcUrls:{default:{http:[i]}},nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"}})}0&&(module.exports={ClientOptionsSchema,GetChainIdOptionsSchema,OTPAlgorithm,WalletVerificationType,getChainId,getPublicClient,getWalletClient});
|
|
2
2
|
//# sourceMappingURL=viem.cjs.map
|
package/dist/viem.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/viem.ts","../src/custom-actions/create-wallet-verification-challenges.action.ts","../src/custom-actions/create-wallet-verification.action.ts","../src/custom-actions/create-wallet.action.ts","../src/custom-actions/delete-wallet-verification.action.ts","../src/custom-actions/get-wallet-verifications.action.ts","../src/custom-actions/verify-wallet-verification-challenge.action.ts","../src/custom-actions/types/wallet-verification.enum.ts"],"sourcesContent":["import { ensureServer } from \"@settlemint/sdk-utils/runtime\";\nimport { ApplicationAccessTokenSchema, UrlOrPathSchema, validate } from \"@settlemint/sdk-utils/validation\";\nimport {\n http,\n type Chain as ViemChain,\n createPublicClient,\n createWalletClient,\n defineChain,\n publicActions,\n} from \"viem\";\nimport * as chains from \"viem/chains\";\nimport { z } from \"zod/v4\";\nimport { createWalletVerificationChallenges } from \"./custom-actions/create-wallet-verification-challenges.action.js\";\nimport { createWalletVerification } from \"./custom-actions/create-wallet-verification.action.js\";\nimport { createWallet } from \"./custom-actions/create-wallet.action.js\";\nimport { deleteWalletVerification } from \"./custom-actions/delete-wallet-verification.action.js\";\nimport { getWalletVerifications } from \"./custom-actions/get-wallet-verifications.action.js\";\nimport { verifyWalletVerificationChallenge } from \"./custom-actions/verify-wallet-verification-challenge.action.js\";\n\n/**\n * Schema for the viem client options.\n */\nexport const ClientOptionsSchema = z.object({\n /**\n * The instance URL\n */\n instance: UrlOrPathSchema,\n /**\n * The access token\n */\n accessToken: ApplicationAccessTokenSchema.optional(),\n /**\n * The chain id\n */\n chainId: z.string().optional(),\n /**\n * The chain name\n */\n chainName: z.string(),\n /**\n * The json rpc url\n */\n rpcUrl: UrlOrPathSchema,\n /**\n * The http transport config\n */\n httpTransportConfig: z.any().optional(),\n});\n\n/**\n * Type representing the validated client options.\n */\nexport type ClientOptions = z.infer<typeof ClientOptionsSchema>;\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. see {@link https://viem.sh/docs/clients/public}\n * @example\n * ```ts\n * import { getPublicClient } from '@settlemint/sdk-viem';\n *\n * const publicClient = getPublicClient({\n * accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,\n * chainId: process.env.SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID!,\n * chainName: process.env.SETTLEMINT_BLOCKCHAIN_NETWORK!,\n * rpcUrl: process.env.SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT!,\n * });\n *\n * // Get the block number\n * const block = await publicClient.getBlockNumber();\n * console.log(block);\n * ```\n */\nexport const getPublicClient = (options: ClientOptions) => {\n ensureServer();\n const validatedOptions = validate(ClientOptionsSchema, options);\n return createPublicClient({\n chain: getChain(validatedOptions),\n transport: http(validatedOptions.rpcUrl, {\n batch: true,\n timeout: 60_000,\n ...validatedOptions.httpTransportConfig,\n fetchOptions: {\n ...validatedOptions?.httpTransportConfig?.fetchOptions,\n headers: {\n ...validatedOptions?.httpTransportConfig?.fetchOptions?.headers,\n \"x-auth-token\": validatedOptions.accessToken,\n },\n },\n }),\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 for HD wallets. see {@link https://viem.sh/docs/clients/wallet}\n * @example\n * ```ts\n * import { getWalletClient } from '@settlemint/sdk-viem';\n * import { parseAbi } from \"viem\";\n *\n * const walletClient = getWalletClient({\n * accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,\n * chainId: process.env.SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID!,\n * chainName: process.env.SETTLEMINT_BLOCKCHAIN_NETWORK!,\n * rpcUrl: process.env.SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT!,\n * });\n *\n * // Get the chain id\n * const chainId = await walletClient().getChainId();\n * console.log(chainId);\n *\n * // write to the blockchain\n * const transactionHash = await walletClient().writeContract({\n * account: \"0x0000000000000000000000000000000000000000\",\n * address: \"0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2\",\n * abi: parseAbi([\"function mint(uint32 tokenId) nonpayable\"]),\n * functionName: \"mint\",\n * args: [69420],\n * });\n * console.log(transactionHash);\n * ```\n */\nexport const getWalletClient = (options: ClientOptions) => {\n ensureServer();\n const validatedOptions = validate(ClientOptionsSchema, options);\n const chain = getChain(validatedOptions);\n return (verificationOptions?: WalletVerificationOptions) =>\n createWalletClient({\n chain: chain,\n transport: http(validatedOptions.rpcUrl, {\n batch: true,\n timeout: 60_000,\n ...validatedOptions.httpTransportConfig,\n fetchOptions: {\n ...validatedOptions?.httpTransportConfig?.fetchOptions,\n headers: {\n ...validatedOptions?.httpTransportConfig?.fetchOptions?.headers,\n \"x-auth-token\": validatedOptions.accessToken,\n \"x-auth-challenge-response\": verificationOptions?.challengeResponse ?? \"\",\n \"x-auth-verification-id\": verificationOptions?.verificationId ?? \"\",\n },\n },\n }),\n })\n .extend(publicActions)\n .extend(createWallet)\n .extend(getWalletVerifications)\n .extend(createWalletVerification)\n .extend(deleteWalletVerification)\n .extend(createWalletVerificationChallenges)\n .extend(verifyWalletVerificationChallenge);\n};\n\n/**\n * Schema for the viem client options.\n */\nexport const GetChainIdOptionsSchema = z.object({\n /**\n * The access token\n */\n accessToken: ApplicationAccessTokenSchema.optional(),\n /**\n * The json rpc url\n */\n rpcUrl: UrlOrPathSchema,\n});\n\n/**\n * Type representing the validated get chain id options.\n */\nexport type GetChainIdOptions = z.infer<typeof GetChainIdOptionsSchema>;\n\n/**\n * Get the chain id of a blockchain network.\n * @param options - The options for the public client.\n * @returns The chain id.\n * @example\n * ```ts\n * import { getChainId } from '@settlemint/sdk-viem';\n *\n * const chainId = await getChainId({\n * accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,\n * rpcUrl: process.env.SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT!,\n * });\n * console.log(chainId);\n * ```\n */\nexport async function getChainId(options: GetChainIdOptions): Promise<number> {\n ensureServer();\n const validatedOptions = validate(GetChainIdOptionsSchema, options);\n const client = createPublicClient({\n transport: http(validatedOptions.rpcUrl, {\n fetchOptions: {\n headers: validatedOptions.accessToken\n ? {\n \"x-auth-token\": validatedOptions.accessToken,\n }\n : undefined,\n },\n }),\n });\n\n return client.getChainId();\n}\n\nfunction getChain({ chainId, chainName, rpcUrl }: Pick<ClientOptions, \"chainId\" | \"chainName\" | \"rpcUrl\">): ViemChain {\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\nexport { OTPAlgorithm, WalletVerificationType } from \"./custom-actions/types/wallet-verification.enum.js\";\n\nexport type {\n CreateWalletVerificationChallengesResponse,\n CreateWalletVerificationChallengesParameters,\n WalletVerificationChallenge,\n} from \"./custom-actions/create-wallet-verification-challenges.action.js\";\nexport type {\n CreateWalletVerificationResponse,\n CreateWalletVerificationParameters,\n WalletVerificationInfo,\n WalletPincodeVerificationInfo,\n WalletOTPVerificationInfo,\n WalletSecretCodesVerificationInfo,\n} from \"./custom-actions/create-wallet-verification.action.js\";\nexport type {\n CreateWalletResponse,\n CreateWalletParameters,\n WalletInfo,\n} from \"./custom-actions/create-wallet.action.js\";\nexport type {\n DeleteWalletVerificationParameters,\n DeleteWalletVerificationResponse,\n} from \"./custom-actions/delete-wallet-verification.action.js\";\nexport type {\n GetWalletVerificationsParameters,\n GetWalletVerificationsResponse,\n WalletVerification,\n} from \"./custom-actions/get-wallet-verifications.action.js\";\nexport type {\n VerifyWalletVerificationChallengeParameters,\n AddressOrObject,\n VerifyWalletVerificationChallengeResponse,\n VerificationResult,\n} from \"./custom-actions/verify-wallet-verification-challenge.action.js\";\n","import type { Client } from \"viem\";\nimport type { WalletVerificationType } from \"./types/wallet-verification.enum.js\";\nimport type { AddressOrObject } from \"./verify-wallet-verification-challenge.action.js\";\n\n/**\n * Parameters for creating wallet verification challenges.\n */\nexport interface CreateWalletVerificationChallengesParameters {\n /** The wallet address or object containing wallet address and optional verification ID. */\n addressOrObject: AddressOrObject;\n}\n\n/**\n * Represents a wallet verification challenge.\n */\nexport interface WalletVerificationChallenge {\n /** The unique identifier of the challenge. */\n id: string;\n /** The name of the challenge. */\n name: string;\n /** The type of verification required. */\n verificationType: WalletVerificationType;\n /** The challenge parameters specific to the verification type. */\n challenge: Record<string, string>;\n}\n\n/**\n * Response from creating wallet verification challenges.\n */\nexport type CreateWalletVerificationChallengesResponse = WalletVerificationChallenge[];\n\n/**\n * RPC schema for creating wallet verification challenges.\n */\ntype WalletRpcSchema = {\n Method: \"user_createWalletVerificationChallenges\";\n Parameters: [addressOrObject: AddressOrObject];\n ReturnType: CreateWalletVerificationChallengesResponse;\n};\n\n/**\n * Creates a wallet verification challenges action for the given client.\n * @param client - The viem client to use for the request.\n * @returns An object with a createWalletVerificationChallenges method.\n */\nexport function createWalletVerificationChallenges(client: Client) {\n return {\n /**\n * Creates verification challenges for a wallet.\n * @param args - The parameters for creating the challenges.\n * @returns A promise that resolves to an array of wallet verification challenges.\n */\n createWalletVerificationChallenges(\n args: CreateWalletVerificationChallengesParameters,\n ): Promise<CreateWalletVerificationChallengesResponse> {\n return client.request<WalletRpcSchema>({\n method: \"user_createWalletVerificationChallenges\",\n params: [args.addressOrObject],\n });\n },\n };\n}\n","import type { Client } from \"viem\";\nimport type { OTPAlgorithm, WalletVerificationType } from \"./types/wallet-verification.enum.js\";\n\n/**\n * Base interface for wallet verification information.\n */\ntype BaseWalletVerificationInfo = {\n /** The name of the verification method. */\n name: string;\n /** The type of verification method. */\n verificationType: WalletVerificationType;\n};\n\n/**\n * Information for PIN code verification.\n */\nexport interface WalletPincodeVerificationInfo extends BaseWalletVerificationInfo {\n /** The type of verification method. */\n verificationType: WalletVerificationType.PINCODE;\n /** The PIN code to use for verification. */\n pincode: string;\n}\n\n/**\n * Information for One-Time Password (OTP) verification.\n */\nexport interface WalletOTPVerificationInfo extends BaseWalletVerificationInfo {\n /** The type of verification method. */\n verificationType: WalletVerificationType.OTP;\n /** The hash algorithm to use for OTP generation. */\n algorithm?: OTPAlgorithm;\n /** The number of digits in the OTP code. */\n digits?: number;\n /** The time period in seconds for OTP validity. */\n period?: number;\n /** The issuer of the OTP. */\n issuer?: string;\n}\n\n/**\n * Information for secret recovery codes verification.\n */\nexport interface WalletSecretCodesVerificationInfo extends BaseWalletVerificationInfo {\n /** The type of verification method. */\n verificationType: WalletVerificationType.SECRET_CODES;\n}\n\n/**\n * Union type of all possible wallet verification information types.\n */\nexport type WalletVerificationInfo =\n | WalletPincodeVerificationInfo\n | WalletOTPVerificationInfo\n | WalletSecretCodesVerificationInfo;\n\n/**\n * Parameters for creating a wallet verification.\n */\nexport interface CreateWalletVerificationParameters {\n /** The wallet address for which to create the verification. */\n userWalletAddress: string;\n /** The verification information to create. */\n walletVerificationInfo: WalletVerificationInfo;\n}\n\n/**\n * Response from creating a wallet verification.\n */\nexport interface CreateWalletVerificationResponse {\n /** The unique identifier of the verification. */\n id: string;\n /** The name of the verification method. */\n name: string;\n /** The type of verification method. */\n verificationType: WalletVerificationType;\n /** Additional parameters specific to the verification type. */\n parameters: Record<string, string>;\n}\n\n/**\n * RPC schema for creating a wallet verification.\n */\ntype WalletRpcSchema = {\n Method: \"user_createWalletVerification\";\n Parameters: [userWalletAddress: string, walletVerificationInfo: WalletVerificationInfo];\n ReturnType: CreateWalletVerificationResponse[];\n};\n\n/**\n * Creates a wallet verification action for the given client.\n * @param client - The viem client to use for the request.\n * @returns An object with a createWalletVerification method.\n */\nexport function createWalletVerification(client: Client) {\n return {\n /**\n * Creates a new wallet verification.\n * @param args - The parameters for creating the verification.\n * @returns A promise that resolves to an array of created wallet verification responses.\n */\n createWalletVerification(args: CreateWalletVerificationParameters): Promise<CreateWalletVerificationResponse[]> {\n return client.request<WalletRpcSchema>({\n method: \"user_createWalletVerification\",\n params: [args.userWalletAddress, args.walletVerificationInfo],\n });\n },\n };\n}\n","import type { Client } from \"viem\";\n\n/**\n * Information about the wallet to be created.\n */\nexport interface WalletInfo {\n /** The name of the wallet. */\n name: string;\n}\n\n/**\n * Parameters for creating a wallet.\n */\nexport interface CreateWalletParameters {\n /** The unique name of the key vault where the wallet will be created. */\n keyVaultId: string;\n /** Information about the wallet to be created. */\n walletInfo: WalletInfo;\n}\n\n/**\n * Response from creating a wallet.\n */\nexport interface CreateWalletResponse {\n /** The unique identifier of the wallet. */\n id: string;\n /** The name of the wallet. */\n name: string;\n /** The blockchain address of the wallet. */\n address: string;\n /** The HD derivation path used to create the wallet. */\n derivationPath: string;\n}\n\n/**\n * RPC schema for wallet creation.\n */\ntype WalletRpcSchema = {\n Method: \"user_createWallet\";\n Parameters: [keyVaultId: string, walletInfo: WalletInfo];\n ReturnType: CreateWalletResponse[];\n};\n\n/**\n * Creates a wallet action for the given client.\n * @param client - The viem client to use for the request.\n * @returns An object with a createWallet method.\n */\nexport function createWallet(client: Client) {\n return {\n /**\n * Creates a new wallet in the specified key vault.\n * @param args - The parameters for creating a wallet.\n * @returns A promise that resolves to an array of created wallet responses.\n */\n createWallet(args: CreateWalletParameters): Promise<CreateWalletResponse[]> {\n return client.request<WalletRpcSchema>({\n method: \"user_createWallet\",\n params: [args.keyVaultId, args.walletInfo],\n });\n },\n };\n}\n","import type { Client } from \"viem\";\n\n/**\n * Parameters for deleting a wallet verification.\n */\nexport interface DeleteWalletVerificationParameters {\n /** The wallet address for which to delete the verification. */\n userWalletAddress: string;\n /** The unique identifier of the verification to delete. */\n verificationId: string;\n}\n\n/**\n * Response from deleting a wallet verification.\n */\nexport interface DeleteWalletVerificationResponse {\n /** Whether the deletion was successful. */\n success: boolean;\n}\n\n/**\n * RPC schema for deleting a wallet verification.\n */\ntype WalletRpcSchema = {\n Method: \"user_deleteWalletVerification\";\n Parameters: [userWalletAddress: string, verificationId: string];\n ReturnType: DeleteWalletVerificationResponse[];\n};\n\n/**\n * Creates a wallet verification deletion action for the given client.\n * @param client - The viem client to use for the request.\n * @returns An object with a deleteWalletVerification method.\n */\nexport function deleteWalletVerification(client: Client) {\n return {\n /**\n * Deletes a wallet verification.\n * @param args - The parameters for deleting the verification.\n * @returns A promise that resolves to an array of deletion results.\n */\n deleteWalletVerification(args: DeleteWalletVerificationParameters): Promise<DeleteWalletVerificationResponse[]> {\n return client.request<WalletRpcSchema>({\n method: \"user_deleteWalletVerification\",\n params: [args.userWalletAddress, args.verificationId],\n });\n },\n };\n}\n","import type { Client } from \"viem\";\nimport type { WalletVerificationType } from \"./types/wallet-verification.enum.js\";\n\n/**\n * Parameters for getting wallet verifications.\n */\nexport interface GetWalletVerificationsParameters {\n /** The wallet address for which to fetch verifications. */\n userWalletAddress: string;\n}\n\n/**\n * Represents a wallet verification.\n */\nexport interface WalletVerification {\n /** The unique identifier of the verification. */\n id: string;\n /** The name of the verification method. */\n name: string;\n /** The type of verification method. */\n verificationType: WalletVerificationType;\n}\n\n/**\n * Response from getting wallet verifications.\n */\nexport type GetWalletVerificationsResponse = WalletVerification[];\n\n/**\n * RPC schema for getting wallet verifications.\n */\ntype WalletRpcSchema = {\n Method: \"user_walletVerifications\";\n Parameters: [userWalletAddress: string];\n ReturnType: GetWalletVerificationsResponse;\n};\n\n/**\n * Creates a wallet verifications retrieval action for the given client.\n * @param client - The viem client to use for the request.\n * @returns An object with a getWalletVerifications method.\n */\nexport function getWalletVerifications(client: Client) {\n return {\n /**\n * Gets all verifications for a wallet.\n * @param args - The parameters for getting the verifications.\n * @returns A promise that resolves to an array of wallet verifications.\n */\n getWalletVerifications(args: GetWalletVerificationsParameters): Promise<GetWalletVerificationsResponse> {\n return client.request<WalletRpcSchema>({\n method: \"user_walletVerifications\",\n params: [args.userWalletAddress],\n });\n },\n };\n}\n","import type { Client } from \"viem\";\n\n/**\n * Represents either a wallet address string or an object containing wallet address and optional verification ID.\n */\nexport type AddressOrObject =\n | string\n | {\n userWalletAddress: string;\n verificationId?: string;\n };\n\n/**\n * Parameters for verifying a wallet verification challenge.\n */\nexport interface VerifyWalletVerificationChallengeParameters {\n /** The wallet address or object containing wallet address and optional verification ID. */\n addressOrObject: AddressOrObject;\n /** The response to the verification challenge. */\n challengeResponse: string;\n}\n\n/**\n * Result of a wallet verification challenge.\n */\nexport interface VerificationResult {\n /** Whether the verification was successful. */\n verified: boolean;\n}\n\n/**\n * Response from verifying a wallet verification challenge.\n */\nexport type VerifyWalletVerificationChallengeResponse = VerificationResult[];\n\n/**\n * RPC schema for wallet verification challenge verification.\n */\ntype WalletRpcSchema = {\n Method: \"user_verifyWalletVerificationChallenge\";\n Parameters: [addressOrObject: AddressOrObject, challengeResponse: string];\n ReturnType: VerifyWalletVerificationChallengeResponse;\n};\n\n/**\n * Creates a wallet verification challenge verification action for the given client.\n * @param client - The viem client to use for the request.\n * @returns An object with a verifyWalletVerificationChallenge method.\n */\nexport function verifyWalletVerificationChallenge(client: Client) {\n return {\n /**\n * Verifies a wallet verification challenge.\n * @param args - The parameters for verifying the challenge.\n * @returns A promise that resolves to an array of verification results.\n */\n verifyWalletVerificationChallenge(\n args: VerifyWalletVerificationChallengeParameters,\n ): Promise<VerifyWalletVerificationChallengeResponse> {\n return client.request<WalletRpcSchema>({\n method: \"user_verifyWalletVerificationChallenge\",\n params: [args.addressOrObject, args.challengeResponse],\n });\n },\n };\n}\n","/**\n * Types of wallet verification methods supported by the system.\n * Used to identify different verification mechanisms when creating or managing wallet verifications.\n */\nexport enum WalletVerificationType {\n /** PIN code verification method */\n PINCODE = \"PINCODE\",\n /** One-Time Password verification method */\n OTP = \"OTP\",\n /** Secret recovery codes verification method */\n SECRET_CODES = \"SECRET_CODES\",\n}\n\n/**\n * Supported hash algorithms for One-Time Password (OTP) verification.\n * These algorithms determine the cryptographic function used to generate OTP codes.\n */\nexport enum OTPAlgorithm {\n /** SHA-1 hash algorithm */\n SHA1 = \"SHA1\",\n /** SHA-224 hash algorithm */\n SHA224 = \"SHA224\",\n /** SHA-256 hash algorithm */\n SHA256 = \"SHA256\",\n /** SHA-384 hash algorithm */\n SHA384 = \"SHA384\",\n /** SHA-512 hash algorithm */\n SHA512 = \"SHA512\",\n /** SHA3-224 hash algorithm */\n SHA3_224 = \"SHA3-224\",\n /** SHA3-256 hash algorithm */\n SHA3_256 = \"SHA3-256\",\n /** SHA3-384 hash algorithm */\n SHA3_384 = \"SHA3-384\",\n /** SHA3-512 hash algorithm */\n SHA3_512 = \"SHA3-512\",\n}\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,EAAA,4BAAAC,EAAA,iBAAAC,EAAA,2BAAAC,EAAA,eAAAC,EAAA,oBAAAC,EAAA,oBAAAC,IAAA,eAAAC,EAAAT,GAAA,IAAAU,EAA6B,yCAC7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AiC,CAC/C,EAKaC,EAA0B,IAAE,OAAO,CAI9C,YAAa,+BAA6B,SAAS,EAInD,OAAQ,iBACV,CAAC,EAsBD,eAAsBC,EAAWb,EAA6C,IAC5E,gBAAa,EACb,IAAMC,KAAmB,YAASW,EAAyBZ,CAAO,EAalE,SAZe,sBAAmB,CAChC,aAAW,QAAKC,EAAiB,OAAQ,CACvC,aAAc,CACZ,QAASA,EAAiB,YACtB,CACE,eAAgBA,EAAiB,WACnC,EACA,MACN,CACF,CAAC,CACH,CAAC,EAEa,WAAW,CAC3B,CAEA,SAASC,EAAS,CAAE,QAAAY,EAAS,UAAAC,EAAW,OAAAC,CAAO,EAAuE,CAEpH,OADmB,OAAO,OAAOC,CAAM,EAAE,KAAMb,GAAUA,EAAM,GAAG,SAAS,IAAMU,CAAO,MAGtF,eAAY,CACV,GAAI,OAAOA,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":["viem_exports","__export","ClientOptionsSchema","GetChainIdOptionsSchema","OTPAlgorithm","WalletVerificationType","getChainId","getPublicClient","getWalletClient","__toCommonJS","import_runtime","import_validation","import_viem","chains","import_v4","createWalletVerificationChallenges","client","args","createWalletVerification","client","args","createWallet","client","args","deleteWalletVerification","client","args","getWalletVerifications","client","args","verifyWalletVerificationChallenge","client","args","WalletVerificationType","OTPAlgorithm","ClientOptionsSchema","getPublicClient","options","validatedOptions","getChain","getWalletClient","chain","verificationOptions","createWallet","getWalletVerifications","createWalletVerification","deleteWalletVerification","createWalletVerificationChallenges","verifyWalletVerificationChallenge","GetChainIdOptionsSchema","getChainId","chainId","chainName","rpcUrl","chains"]}
|
|
1
|
+
{"version":3,"sources":["../src/viem.ts","../src/custom-actions/create-wallet-verification-challenges.action.ts","../src/custom-actions/create-wallet-verification.action.ts","../src/custom-actions/create-wallet.action.ts","../src/custom-actions/delete-wallet-verification.action.ts","../src/custom-actions/get-wallet-verifications.action.ts","../src/custom-actions/verify-wallet-verification-challenge.action.ts","../src/custom-actions/types/wallet-verification.enum.ts"],"sourcesContent":["import { appendHeaders } from \"@settlemint/sdk-utils/http\";\nimport { ensureServer } from \"@settlemint/sdk-utils/runtime\";\nimport { ApplicationAccessTokenSchema, UrlOrPathSchema, validate } from \"@settlemint/sdk-utils/validation\";\nimport {\n http,\n type HttpTransportConfig,\n type Chain as ViemChain,\n createPublicClient,\n createWalletClient,\n defineChain,\n publicActions,\n} from \"viem\";\nimport * as chains from \"viem/chains\";\nimport { z } from \"zod/v4\";\nimport { createWalletVerificationChallenges } from \"./custom-actions/create-wallet-verification-challenges.action.js\";\nimport { createWalletVerification } from \"./custom-actions/create-wallet-verification.action.js\";\nimport { createWallet } from \"./custom-actions/create-wallet.action.js\";\nimport { deleteWalletVerification } from \"./custom-actions/delete-wallet-verification.action.js\";\nimport { getWalletVerifications } from \"./custom-actions/get-wallet-verifications.action.js\";\nimport { verifyWalletVerificationChallenge } from \"./custom-actions/verify-wallet-verification-challenge.action.js\";\n\n/**\n * Schema for the viem client options.\n */\nexport const ClientOptionsSchema = z.object({\n /**\n * The access token\n */\n accessToken: ApplicationAccessTokenSchema.optional(),\n /**\n * The chain id\n */\n chainId: z.string().optional(),\n /**\n * The chain name\n */\n chainName: z.string(),\n /**\n * The json rpc url\n */\n rpcUrl: UrlOrPathSchema,\n /**\n * The http transport config\n */\n httpTransportConfig: z.any().optional(),\n});\n\n/**\n * Type representing the validated client options.\n */\nexport type ClientOptions = Omit<z.infer<typeof ClientOptionsSchema>, \"httpTransportConfig\"> & {\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. see {@link https://viem.sh/docs/clients/public}\n * @example\n * ```ts\n * import { getPublicClient } from '@settlemint/sdk-viem';\n *\n * const publicClient = getPublicClient({\n * accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,\n * chainId: process.env.SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID!,\n * chainName: process.env.SETTLEMINT_BLOCKCHAIN_NETWORK!,\n * rpcUrl: process.env.SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT!,\n * });\n *\n * // Get the block number\n * const block = await publicClient.getBlockNumber();\n * console.log(block);\n * ```\n */\nexport const getPublicClient = (options: ClientOptions) => {\n ensureServer();\n const validatedOptions: ClientOptions = validate(ClientOptionsSchema, options);\n return createPublicClient({\n chain: getChain(validatedOptions),\n transport: http(validatedOptions.rpcUrl, {\n batch: true,\n timeout: 60_000,\n ...validatedOptions.httpTransportConfig,\n fetchOptions: {\n ...validatedOptions?.httpTransportConfig?.fetchOptions,\n headers: appendHeaders(validatedOptions?.httpTransportConfig?.fetchOptions?.headers, {\n \"x-auth-token\": validatedOptions.accessToken,\n }),\n },\n }),\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 for HD wallets. see {@link https://viem.sh/docs/clients/wallet}\n * @example\n * ```ts\n * import { getWalletClient } from '@settlemint/sdk-viem';\n * import { parseAbi } from \"viem\";\n *\n * const walletClient = getWalletClient({\n * accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,\n * chainId: process.env.SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID!,\n * chainName: process.env.SETTLEMINT_BLOCKCHAIN_NETWORK!,\n * rpcUrl: process.env.SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT!,\n * });\n *\n * // Get the chain id\n * const chainId = await walletClient().getChainId();\n * console.log(chainId);\n *\n * // write to the blockchain\n * const transactionHash = await walletClient().writeContract({\n * account: \"0x0000000000000000000000000000000000000000\",\n * address: \"0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2\",\n * abi: parseAbi([\"function mint(uint32 tokenId) nonpayable\"]),\n * functionName: \"mint\",\n * args: [69420],\n * });\n * console.log(transactionHash);\n * ```\n */\nexport const getWalletClient = (options: ClientOptions) => {\n ensureServer();\n const validatedOptions: ClientOptions = validate(ClientOptionsSchema, options);\n const chain = getChain(validatedOptions);\n return (verificationOptions?: WalletVerificationOptions) =>\n createWalletClient({\n chain: chain,\n transport: http(validatedOptions.rpcUrl, {\n batch: true,\n timeout: 60_000,\n ...validatedOptions.httpTransportConfig,\n fetchOptions: {\n ...validatedOptions?.httpTransportConfig?.fetchOptions,\n headers: appendHeaders(validatedOptions?.httpTransportConfig?.fetchOptions?.headers, {\n \"x-auth-token\": validatedOptions.accessToken,\n \"x-auth-challenge-response\": verificationOptions?.challengeResponse ?? \"\",\n \"x-auth-verification-id\": verificationOptions?.verificationId ?? \"\",\n }),\n },\n }),\n })\n .extend(publicActions)\n .extend(createWallet)\n .extend(getWalletVerifications)\n .extend(createWalletVerification)\n .extend(deleteWalletVerification)\n .extend(createWalletVerificationChallenges)\n .extend(verifyWalletVerificationChallenge);\n};\n\n/**\n * Schema for the viem client options.\n */\nexport const GetChainIdOptionsSchema = z.object({\n /**\n * The access token\n */\n accessToken: ApplicationAccessTokenSchema.optional(),\n /**\n * The json rpc url\n */\n rpcUrl: UrlOrPathSchema,\n /**\n * The http transport config\n */\n httpTransportConfig: z.any().optional(),\n});\n\n/**\n * Type representing the validated get chain id options.\n */\nexport type GetChainIdOptions = Omit<z.infer<typeof GetChainIdOptionsSchema>, \"httpTransportConfig\"> & {\n httpTransportConfig?: HttpTransportConfig;\n};\n\n/**\n * Get the chain id of a blockchain network.\n * @param options - The options for the public client.\n * @returns The chain id.\n * @example\n * ```ts\n * import { getChainId } from '@settlemint/sdk-viem';\n *\n * const chainId = await getChainId({\n * accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,\n * rpcUrl: process.env.SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT!,\n * });\n * console.log(chainId);\n * ```\n */\nexport async function getChainId(options: GetChainIdOptions): Promise<number> {\n ensureServer();\n const validatedOptions: GetChainIdOptions = validate(GetChainIdOptionsSchema, options);\n const client = createPublicClient({\n transport: http(validatedOptions.rpcUrl, {\n ...validatedOptions.httpTransportConfig,\n fetchOptions: {\n ...validatedOptions?.httpTransportConfig?.fetchOptions,\n headers: appendHeaders(validatedOptions?.httpTransportConfig?.fetchOptions?.headers, {\n \"x-auth-token\": validatedOptions.accessToken,\n }),\n },\n }),\n });\n\n return client.getChainId();\n}\n\nfunction getChain({ chainId, chainName, rpcUrl }: Pick<ClientOptions, \"chainId\" | \"chainName\" | \"rpcUrl\">): ViemChain {\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\nexport { OTPAlgorithm, WalletVerificationType } from \"./custom-actions/types/wallet-verification.enum.js\";\n\nexport type {\n CreateWalletVerificationChallengesParameters,\n CreateWalletVerificationChallengesResponse,\n WalletVerificationChallenge,\n} from \"./custom-actions/create-wallet-verification-challenges.action.js\";\nexport type {\n CreateWalletVerificationParameters,\n CreateWalletVerificationResponse,\n WalletOTPVerificationInfo,\n WalletPincodeVerificationInfo,\n WalletSecretCodesVerificationInfo,\n WalletVerificationInfo,\n} from \"./custom-actions/create-wallet-verification.action.js\";\nexport type {\n CreateWalletParameters,\n CreateWalletResponse,\n WalletInfo,\n} from \"./custom-actions/create-wallet.action.js\";\nexport type {\n DeleteWalletVerificationParameters,\n DeleteWalletVerificationResponse,\n} from \"./custom-actions/delete-wallet-verification.action.js\";\nexport type {\n GetWalletVerificationsParameters,\n GetWalletVerificationsResponse,\n WalletVerification,\n} from \"./custom-actions/get-wallet-verifications.action.js\";\nexport type {\n AddressOrObject,\n VerificationResult,\n VerifyWalletVerificationChallengeParameters,\n VerifyWalletVerificationChallengeResponse,\n} from \"./custom-actions/verify-wallet-verification-challenge.action.js\";\n","import type { Client } from \"viem\";\nimport type { WalletVerificationType } from \"./types/wallet-verification.enum.js\";\nimport type { AddressOrObject } from \"./verify-wallet-verification-challenge.action.js\";\n\n/**\n * Parameters for creating wallet verification challenges.\n */\nexport interface CreateWalletVerificationChallengesParameters {\n /** The wallet address or object containing wallet address and optional verification ID. */\n addressOrObject: AddressOrObject;\n}\n\n/**\n * Represents a wallet verification challenge.\n */\nexport interface WalletVerificationChallenge {\n /** The unique identifier of the challenge. */\n id: string;\n /** The name of the challenge. */\n name: string;\n /** The type of verification required. */\n verificationType: WalletVerificationType;\n /** The challenge parameters specific to the verification type. */\n challenge: Record<string, string>;\n}\n\n/**\n * Response from creating wallet verification challenges.\n */\nexport type CreateWalletVerificationChallengesResponse = WalletVerificationChallenge[];\n\n/**\n * RPC schema for creating wallet verification challenges.\n */\ntype WalletRpcSchema = {\n Method: \"user_createWalletVerificationChallenges\";\n Parameters: [addressOrObject: AddressOrObject];\n ReturnType: CreateWalletVerificationChallengesResponse;\n};\n\n/**\n * Creates a wallet verification challenges action for the given client.\n * @param client - The viem client to use for the request.\n * @returns An object with a createWalletVerificationChallenges method.\n */\nexport function createWalletVerificationChallenges(client: Client) {\n return {\n /**\n * Creates verification challenges for a wallet.\n * @param args - The parameters for creating the challenges.\n * @returns A promise that resolves to an array of wallet verification challenges.\n */\n createWalletVerificationChallenges(\n args: CreateWalletVerificationChallengesParameters,\n ): Promise<CreateWalletVerificationChallengesResponse> {\n return client.request<WalletRpcSchema>({\n method: \"user_createWalletVerificationChallenges\",\n params: [args.addressOrObject],\n });\n },\n };\n}\n","import type { Client } from \"viem\";\nimport type { OTPAlgorithm, WalletVerificationType } from \"./types/wallet-verification.enum.js\";\n\n/**\n * Base interface for wallet verification information.\n */\ntype BaseWalletVerificationInfo = {\n /** The name of the verification method. */\n name: string;\n /** The type of verification method. */\n verificationType: WalletVerificationType;\n};\n\n/**\n * Information for PIN code verification.\n */\nexport interface WalletPincodeVerificationInfo extends BaseWalletVerificationInfo {\n /** The type of verification method. */\n verificationType: WalletVerificationType.PINCODE;\n /** The PIN code to use for verification. */\n pincode: string;\n}\n\n/**\n * Information for One-Time Password (OTP) verification.\n */\nexport interface WalletOTPVerificationInfo extends BaseWalletVerificationInfo {\n /** The type of verification method. */\n verificationType: WalletVerificationType.OTP;\n /** The hash algorithm to use for OTP generation. */\n algorithm?: OTPAlgorithm;\n /** The number of digits in the OTP code. */\n digits?: number;\n /** The time period in seconds for OTP validity. */\n period?: number;\n /** The issuer of the OTP. */\n issuer?: string;\n}\n\n/**\n * Information for secret recovery codes verification.\n */\nexport interface WalletSecretCodesVerificationInfo extends BaseWalletVerificationInfo {\n /** The type of verification method. */\n verificationType: WalletVerificationType.SECRET_CODES;\n}\n\n/**\n * Union type of all possible wallet verification information types.\n */\nexport type WalletVerificationInfo =\n | WalletPincodeVerificationInfo\n | WalletOTPVerificationInfo\n | WalletSecretCodesVerificationInfo;\n\n/**\n * Parameters for creating a wallet verification.\n */\nexport interface CreateWalletVerificationParameters {\n /** The wallet address for which to create the verification. */\n userWalletAddress: string;\n /** The verification information to create. */\n walletVerificationInfo: WalletVerificationInfo;\n}\n\n/**\n * Response from creating a wallet verification.\n */\nexport interface CreateWalletVerificationResponse {\n /** The unique identifier of the verification. */\n id: string;\n /** The name of the verification method. */\n name: string;\n /** The type of verification method. */\n verificationType: WalletVerificationType;\n /** Additional parameters specific to the verification type. */\n parameters: Record<string, string>;\n}\n\n/**\n * RPC schema for creating a wallet verification.\n */\ntype WalletRpcSchema = {\n Method: \"user_createWalletVerification\";\n Parameters: [userWalletAddress: string, walletVerificationInfo: WalletVerificationInfo];\n ReturnType: CreateWalletVerificationResponse[];\n};\n\n/**\n * Creates a wallet verification action for the given client.\n * @param client - The viem client to use for the request.\n * @returns An object with a createWalletVerification method.\n */\nexport function createWalletVerification(client: Client) {\n return {\n /**\n * Creates a new wallet verification.\n * @param args - The parameters for creating the verification.\n * @returns A promise that resolves to an array of created wallet verification responses.\n */\n createWalletVerification(args: CreateWalletVerificationParameters): Promise<CreateWalletVerificationResponse[]> {\n return client.request<WalletRpcSchema>({\n method: \"user_createWalletVerification\",\n params: [args.userWalletAddress, args.walletVerificationInfo],\n });\n },\n };\n}\n","import type { Client } from \"viem\";\n\n/**\n * Information about the wallet to be created.\n */\nexport interface WalletInfo {\n /** The name of the wallet. */\n name: string;\n}\n\n/**\n * Parameters for creating a wallet.\n */\nexport interface CreateWalletParameters {\n /** The unique name of the key vault where the wallet will be created. */\n keyVaultId: string;\n /** Information about the wallet to be created. */\n walletInfo: WalletInfo;\n}\n\n/**\n * Response from creating a wallet.\n */\nexport interface CreateWalletResponse {\n /** The unique identifier of the wallet. */\n id: string;\n /** The name of the wallet. */\n name: string;\n /** The blockchain address of the wallet. */\n address: string;\n /** The HD derivation path used to create the wallet. */\n derivationPath: string;\n}\n\n/**\n * RPC schema for wallet creation.\n */\ntype WalletRpcSchema = {\n Method: \"user_createWallet\";\n Parameters: [keyVaultId: string, walletInfo: WalletInfo];\n ReturnType: CreateWalletResponse[];\n};\n\n/**\n * Creates a wallet action for the given client.\n * @param client - The viem client to use for the request.\n * @returns An object with a createWallet method.\n */\nexport function createWallet(client: Client) {\n return {\n /**\n * Creates a new wallet in the specified key vault.\n * @param args - The parameters for creating a wallet.\n * @returns A promise that resolves to an array of created wallet responses.\n */\n createWallet(args: CreateWalletParameters): Promise<CreateWalletResponse[]> {\n return client.request<WalletRpcSchema>({\n method: \"user_createWallet\",\n params: [args.keyVaultId, args.walletInfo],\n });\n },\n };\n}\n","import type { Client } from \"viem\";\n\n/**\n * Parameters for deleting a wallet verification.\n */\nexport interface DeleteWalletVerificationParameters {\n /** The wallet address for which to delete the verification. */\n userWalletAddress: string;\n /** The unique identifier of the verification to delete. */\n verificationId: string;\n}\n\n/**\n * Response from deleting a wallet verification.\n */\nexport interface DeleteWalletVerificationResponse {\n /** Whether the deletion was successful. */\n success: boolean;\n}\n\n/**\n * RPC schema for deleting a wallet verification.\n */\ntype WalletRpcSchema = {\n Method: \"user_deleteWalletVerification\";\n Parameters: [userWalletAddress: string, verificationId: string];\n ReturnType: DeleteWalletVerificationResponse[];\n};\n\n/**\n * Creates a wallet verification deletion action for the given client.\n * @param client - The viem client to use for the request.\n * @returns An object with a deleteWalletVerification method.\n */\nexport function deleteWalletVerification(client: Client) {\n return {\n /**\n * Deletes a wallet verification.\n * @param args - The parameters for deleting the verification.\n * @returns A promise that resolves to an array of deletion results.\n */\n deleteWalletVerification(args: DeleteWalletVerificationParameters): Promise<DeleteWalletVerificationResponse[]> {\n return client.request<WalletRpcSchema>({\n method: \"user_deleteWalletVerification\",\n params: [args.userWalletAddress, args.verificationId],\n });\n },\n };\n}\n","import type { Client } from \"viem\";\nimport type { WalletVerificationType } from \"./types/wallet-verification.enum.js\";\n\n/**\n * Parameters for getting wallet verifications.\n */\nexport interface GetWalletVerificationsParameters {\n /** The wallet address for which to fetch verifications. */\n userWalletAddress: string;\n}\n\n/**\n * Represents a wallet verification.\n */\nexport interface WalletVerification {\n /** The unique identifier of the verification. */\n id: string;\n /** The name of the verification method. */\n name: string;\n /** The type of verification method. */\n verificationType: WalletVerificationType;\n}\n\n/**\n * Response from getting wallet verifications.\n */\nexport type GetWalletVerificationsResponse = WalletVerification[];\n\n/**\n * RPC schema for getting wallet verifications.\n */\ntype WalletRpcSchema = {\n Method: \"user_walletVerifications\";\n Parameters: [userWalletAddress: string];\n ReturnType: GetWalletVerificationsResponse;\n};\n\n/**\n * Creates a wallet verifications retrieval action for the given client.\n * @param client - The viem client to use for the request.\n * @returns An object with a getWalletVerifications method.\n */\nexport function getWalletVerifications(client: Client) {\n return {\n /**\n * Gets all verifications for a wallet.\n * @param args - The parameters for getting the verifications.\n * @returns A promise that resolves to an array of wallet verifications.\n */\n getWalletVerifications(args: GetWalletVerificationsParameters): Promise<GetWalletVerificationsResponse> {\n return client.request<WalletRpcSchema>({\n method: \"user_walletVerifications\",\n params: [args.userWalletAddress],\n });\n },\n };\n}\n","import type { Client } from \"viem\";\n\n/**\n * Represents either a wallet address string or an object containing wallet address and optional verification ID.\n */\nexport type AddressOrObject =\n | string\n | {\n userWalletAddress: string;\n verificationId?: string;\n };\n\n/**\n * Parameters for verifying a wallet verification challenge.\n */\nexport interface VerifyWalletVerificationChallengeParameters {\n /** The wallet address or object containing wallet address and optional verification ID. */\n addressOrObject: AddressOrObject;\n /** The response to the verification challenge. */\n challengeResponse: string;\n}\n\n/**\n * Result of a wallet verification challenge.\n */\nexport interface VerificationResult {\n /** Whether the verification was successful. */\n verified: boolean;\n}\n\n/**\n * Response from verifying a wallet verification challenge.\n */\nexport type VerifyWalletVerificationChallengeResponse = VerificationResult[];\n\n/**\n * RPC schema for wallet verification challenge verification.\n */\ntype WalletRpcSchema = {\n Method: \"user_verifyWalletVerificationChallenge\";\n Parameters: [addressOrObject: AddressOrObject, challengeResponse: string];\n ReturnType: VerifyWalletVerificationChallengeResponse;\n};\n\n/**\n * Creates a wallet verification challenge verification action for the given client.\n * @param client - The viem client to use for the request.\n * @returns An object with a verifyWalletVerificationChallenge method.\n */\nexport function verifyWalletVerificationChallenge(client: Client) {\n return {\n /**\n * Verifies a wallet verification challenge.\n * @param args - The parameters for verifying the challenge.\n * @returns A promise that resolves to an array of verification results.\n */\n verifyWalletVerificationChallenge(\n args: VerifyWalletVerificationChallengeParameters,\n ): Promise<VerifyWalletVerificationChallengeResponse> {\n return client.request<WalletRpcSchema>({\n method: \"user_verifyWalletVerificationChallenge\",\n params: [args.addressOrObject, args.challengeResponse],\n });\n },\n };\n}\n","/**\n * Types of wallet verification methods supported by the system.\n * Used to identify different verification mechanisms when creating or managing wallet verifications.\n */\nexport enum WalletVerificationType {\n /** PIN code verification method */\n PINCODE = \"PINCODE\",\n /** One-Time Password verification method */\n OTP = \"OTP\",\n /** Secret recovery codes verification method */\n SECRET_CODES = \"SECRET_CODES\",\n}\n\n/**\n * Supported hash algorithms for One-Time Password (OTP) verification.\n * These algorithms determine the cryptographic function used to generate OTP codes.\n */\nexport enum OTPAlgorithm {\n /** SHA-1 hash algorithm */\n SHA1 = \"SHA1\",\n /** SHA-224 hash algorithm */\n SHA224 = \"SHA224\",\n /** SHA-256 hash algorithm */\n SHA256 = \"SHA256\",\n /** SHA-384 hash algorithm */\n SHA384 = \"SHA384\",\n /** SHA-512 hash algorithm */\n SHA512 = \"SHA512\",\n /** SHA3-224 hash algorithm */\n SHA3_224 = \"SHA3-224\",\n /** SHA3-256 hash algorithm */\n SHA3_256 = \"SHA3-256\",\n /** SHA3-384 hash algorithm */\n SHA3_384 = \"SHA3-384\",\n /** SHA3-512 hash algorithm */\n SHA3_512 = \"SHA3-512\",\n}\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,EAAA,4BAAAC,EAAA,iBAAAC,EAAA,2BAAAC,EAAA,eAAAC,EAAA,oBAAAC,EAAA,oBAAAC,IAAA,eAAAC,EAAAT,GAAA,IAAAU,EAA8B,sCAC9BC,EAA6B,yCAC7BC,EAAwE,4CACxEC,EAQO,gBACPC,EAAwB,4BACxBC,EAAkB,kBCgCX,SAASC,EAAmCC,EAAgB,CACjE,MAAO,CAML,mCACEC,EACqD,CACrD,OAAOD,EAAO,QAAyB,CACrC,OAAQ,0CACR,OAAQ,CAACC,EAAK,eAAe,CAC/B,CAAC,CACH,CACF,CACF,CCgCO,SAASC,EAAyBC,EAAgB,CACvD,MAAO,CAML,yBAAyBC,EAAuF,CAC9G,OAAOD,EAAO,QAAyB,CACrC,OAAQ,gCACR,OAAQ,CAACC,EAAK,kBAAmBA,EAAK,sBAAsB,CAC9D,CAAC,CACH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S,CACnF,eAAgBA,EAAiB,WACnC,CAAC,CACH,CACF,CAAC,CACH,CAAC,EAEa,WAAW,CAC3B,CAEA,SAASC,EAAS,CAAE,QAAAY,EAAS,UAAAC,EAAW,OAAAC,CAAO,EAAuE,CAEpH,OADmB,OAAO,OAAOC,CAAM,EAAE,KAAMb,GAAUA,EAAM,GAAG,SAAS,IAAMU,CAAO,MAGtF,eAAY,CACV,GAAI,OAAOA,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":["viem_exports","__export","ClientOptionsSchema","GetChainIdOptionsSchema","OTPAlgorithm","WalletVerificationType","getChainId","getPublicClient","getWalletClient","__toCommonJS","import_http","import_runtime","import_validation","import_viem","chains","import_v4","createWalletVerificationChallenges","client","args","createWalletVerification","client","args","createWallet","client","args","deleteWalletVerification","client","args","getWalletVerifications","client","args","verifyWalletVerificationChallenge","client","args","WalletVerificationType","OTPAlgorithm","ClientOptionsSchema","getPublicClient","options","validatedOptions","getChain","getWalletClient","chain","verificationOptions","createWallet","getWalletVerifications","createWalletVerification","deleteWalletVerification","createWalletVerificationChallenges","verifyWalletVerificationChallenge","GetChainIdOptionsSchema","getChainId","chainId","chainName","rpcUrl","chains"]}
|
package/dist/viem.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as viem from 'viem';
|
|
2
|
-
import { Chain } from 'viem';
|
|
2
|
+
import { HttpTransportConfig, Chain } from 'viem';
|
|
3
3
|
import * as chains from 'viem/chains';
|
|
4
4
|
import { z } from 'zod/v4';
|
|
5
5
|
|
|
@@ -234,7 +234,6 @@ type CreateWalletVerificationChallengesResponse = WalletVerificationChallenge[];
|
|
|
234
234
|
* Schema for the viem client options.
|
|
235
235
|
*/
|
|
236
236
|
declare const ClientOptionsSchema: z.ZodObject<{
|
|
237
|
-
instance: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
238
237
|
accessToken: z.ZodOptional<z.ZodString>;
|
|
239
238
|
chainId: z.ZodOptional<z.ZodString>;
|
|
240
239
|
chainName: z.ZodString;
|
|
@@ -244,7 +243,9 @@ declare const ClientOptionsSchema: z.ZodObject<{
|
|
|
244
243
|
/**
|
|
245
244
|
* Type representing the validated client options.
|
|
246
245
|
*/
|
|
247
|
-
type ClientOptions = z.infer<typeof ClientOptionsSchema
|
|
246
|
+
type ClientOptions = Omit<z.infer<typeof ClientOptionsSchema>, "httpTransportConfig"> & {
|
|
247
|
+
httpTransportConfig?: HttpTransportConfig;
|
|
248
|
+
};
|
|
248
249
|
/**
|
|
249
250
|
* Get a public client. Use this if you need to read from the blockchain.
|
|
250
251
|
* @param options - The options for the public client.
|
|
@@ -280,7 +281,7 @@ declare const getPublicClient: (options: ClientOptions) => {
|
|
|
280
281
|
pollingInterval: number;
|
|
281
282
|
request: viem.EIP1193RequestFn<viem.PublicRpcSchema>;
|
|
282
283
|
transport: viem.TransportConfig<"http", viem.EIP1193RequestFn> & {
|
|
283
|
-
fetchOptions?:
|
|
284
|
+
fetchOptions?: HttpTransportConfig["fetchOptions"] | undefined;
|
|
284
285
|
url?: string | undefined;
|
|
285
286
|
};
|
|
286
287
|
type: string;
|
|
@@ -7132,10 +7133,10 @@ declare const getPublicClient: (options: ClientOptions) => {
|
|
|
7132
7133
|
uninstallFilter: (args: viem.UninstallFilterParameters) => Promise<viem.UninstallFilterReturnType>;
|
|
7133
7134
|
waitForTransactionReceipt: (args: viem.WaitForTransactionReceiptParameters<Chain>) => Promise<viem.TransactionReceipt>;
|
|
7134
7135
|
watchBlockNumber: (args: viem.WatchBlockNumberParameters) => viem.WatchBlockNumberReturnType;
|
|
7135
|
-
watchBlocks: <includeTransactions extends boolean = false, blockTag extends viem.BlockTag = "latest">(args: viem.WatchBlocksParameters<viem.HttpTransport<undefined,
|
|
7136
|
-
watchContractEvent: <const abi extends viem.Abi | readonly unknown[], eventName extends viem.ContractEventName<abi>, strict extends boolean | undefined = undefined>(args: viem.WatchContractEventParameters<abi, eventName, strict, viem.HttpTransport<undefined,
|
|
7137
|
-
watchEvent: <const abiEvent extends viem.AbiEvent | undefined = undefined, const abiEvents extends readonly viem.AbiEvent[] | readonly unknown[] | undefined = abiEvent extends viem.AbiEvent ? [abiEvent] : undefined, strict extends boolean | undefined = undefined>(args: viem.WatchEventParameters<abiEvent, abiEvents, strict, viem.HttpTransport<undefined,
|
|
7138
|
-
watchPendingTransactions: (args: viem.WatchPendingTransactionsParameters<viem.HttpTransport<undefined,
|
|
7136
|
+
watchBlocks: <includeTransactions extends boolean = false, blockTag extends viem.BlockTag = "latest">(args: viem.WatchBlocksParameters<viem.HttpTransport<viem.RpcSchema | undefined, boolean>, Chain, includeTransactions, blockTag>) => viem.WatchBlocksReturnType;
|
|
7137
|
+
watchContractEvent: <const abi extends viem.Abi | readonly unknown[], eventName extends viem.ContractEventName<abi>, strict extends boolean | undefined = undefined>(args: viem.WatchContractEventParameters<abi, eventName, strict, viem.HttpTransport<viem.RpcSchema | undefined, boolean>>) => viem.WatchContractEventReturnType;
|
|
7138
|
+
watchEvent: <const abiEvent extends viem.AbiEvent | undefined = undefined, const abiEvents extends readonly viem.AbiEvent[] | readonly unknown[] | undefined = abiEvent extends viem.AbiEvent ? [abiEvent] : undefined, strict extends boolean | undefined = undefined>(args: viem.WatchEventParameters<abiEvent, abiEvents, strict, viem.HttpTransport<viem.RpcSchema | undefined, boolean>>) => viem.WatchEventReturnType;
|
|
7139
|
+
watchPendingTransactions: (args: viem.WatchPendingTransactionsParameters<viem.HttpTransport<viem.RpcSchema | undefined, boolean>>) => viem.WatchPendingTransactionsReturnType;
|
|
7139
7140
|
extend: <const client extends {
|
|
7140
7141
|
[x: string]: unknown;
|
|
7141
7142
|
account?: undefined;
|
|
@@ -7150,7 +7151,7 @@ declare const getPublicClient: (options: ClientOptions) => {
|
|
|
7150
7151
|
transport?: undefined;
|
|
7151
7152
|
type?: undefined;
|
|
7152
7153
|
uid?: undefined;
|
|
7153
|
-
} & viem.ExactPartial<Pick<viem.PublicActions<viem.HttpTransport<undefined,
|
|
7154
|
+
} & viem.ExactPartial<Pick<viem.PublicActions<viem.HttpTransport<viem.RpcSchema | undefined, boolean>, Chain, undefined>, "call" | "createContractEventFilter" | "createEventFilter" | "estimateContractGas" | "estimateGas" | "getBlock" | "getBlockNumber" | "getChainId" | "getContractEvents" | "getEnsText" | "getFilterChanges" | "getGasPrice" | "getLogs" | "getTransaction" | "getTransactionCount" | "getTransactionReceipt" | "prepareTransactionRequest" | "readContract" | "sendRawTransaction" | "simulateContract" | "uninstallFilter" | "watchBlockNumber" | "watchContractEvent"> & Pick<viem.WalletActions<Chain, undefined>, "sendTransaction" | "writeContract">>>(fn: (client: viem.Client<viem.HttpTransport<viem.RpcSchema | undefined, boolean>, Chain, undefined, viem.PublicRpcSchema, viem.PublicActions<viem.HttpTransport<viem.RpcSchema | undefined, boolean>, Chain>>) => client) => viem.Client<viem.HttpTransport<viem.RpcSchema | undefined, boolean>, Chain, undefined, viem.PublicRpcSchema, { [K in keyof client]: client[K]; } & viem.PublicActions<viem.HttpTransport<viem.RpcSchema | undefined, boolean>, Chain>>;
|
|
7154
7155
|
};
|
|
7155
7156
|
/**
|
|
7156
7157
|
* The options for the wallet client.
|
|
@@ -7196,7 +7197,7 @@ interface WalletVerificationOptions {
|
|
|
7196
7197
|
* console.log(transactionHash);
|
|
7197
7198
|
* ```
|
|
7198
7199
|
*/
|
|
7199
|
-
declare const getWalletClient: (options: ClientOptions) => (verificationOptions?: WalletVerificationOptions) => viem.Client<viem.HttpTransport<undefined,
|
|
7200
|
+
declare const getWalletClient: (options: ClientOptions) => (verificationOptions?: WalletVerificationOptions) => viem.Client<viem.HttpTransport<viem.RpcSchema | undefined, boolean>, Chain, undefined, viem.WalletRpcSchema, {
|
|
7200
7201
|
verifyWalletVerificationChallenge: (args: VerifyWalletVerificationChallengeParameters) => Promise<VerifyWalletVerificationChallengeResponse>;
|
|
7201
7202
|
} & {
|
|
7202
7203
|
createWalletVerificationChallenges: (args: CreateWalletVerificationChallengesParameters) => Promise<CreateWalletVerificationChallengesResponse>;
|
|
@@ -14056,10 +14057,10 @@ declare const getWalletClient: (options: ClientOptions) => (verificationOptions?
|
|
|
14056
14057
|
uninstallFilter: (args: viem.UninstallFilterParameters) => Promise<viem.UninstallFilterReturnType>;
|
|
14057
14058
|
waitForTransactionReceipt: (args: viem.WaitForTransactionReceiptParameters<Chain>) => Promise<viem.TransactionReceipt>;
|
|
14058
14059
|
watchBlockNumber: (args: viem.WatchBlockNumberParameters) => viem.WatchBlockNumberReturnType;
|
|
14059
|
-
watchBlocks: <includeTransactions extends boolean = false, blockTag extends viem.BlockTag = "latest">(args: viem.WatchBlocksParameters<viem.HttpTransport<undefined,
|
|
14060
|
-
watchContractEvent: <const abi extends viem.Abi | readonly unknown[], eventName extends viem.ContractEventName<abi>, strict extends boolean | undefined = undefined>(args: viem.WatchContractEventParameters<abi, eventName, strict, viem.HttpTransport<undefined,
|
|
14061
|
-
watchEvent: <const abiEvent extends viem.AbiEvent | undefined = undefined, const abiEvents extends readonly viem.AbiEvent[] | readonly unknown[] | undefined = abiEvent extends viem.AbiEvent ? [abiEvent] : undefined, strict extends boolean | undefined = undefined>(args: viem.WatchEventParameters<abiEvent, abiEvents, strict, viem.HttpTransport<undefined,
|
|
14062
|
-
watchPendingTransactions: (args: viem.WatchPendingTransactionsParameters<viem.HttpTransport<undefined,
|
|
14060
|
+
watchBlocks: <includeTransactions extends boolean = false, blockTag extends viem.BlockTag = "latest">(args: viem.WatchBlocksParameters<viem.HttpTransport<viem.RpcSchema | undefined, boolean>, Chain, includeTransactions, blockTag>) => viem.WatchBlocksReturnType;
|
|
14061
|
+
watchContractEvent: <const abi extends viem.Abi | readonly unknown[], eventName extends viem.ContractEventName<abi>, strict extends boolean | undefined = undefined>(args: viem.WatchContractEventParameters<abi, eventName, strict, viem.HttpTransport<viem.RpcSchema | undefined, boolean>>) => viem.WatchContractEventReturnType;
|
|
14062
|
+
watchEvent: <const abiEvent extends viem.AbiEvent | undefined = undefined, const abiEvents extends readonly viem.AbiEvent[] | readonly unknown[] | undefined = abiEvent extends viem.AbiEvent ? [abiEvent] : undefined, strict extends boolean | undefined = undefined>(args: viem.WatchEventParameters<abiEvent, abiEvents, strict, viem.HttpTransport<viem.RpcSchema | undefined, boolean>>) => viem.WatchEventReturnType;
|
|
14063
|
+
watchPendingTransactions: (args: viem.WatchPendingTransactionsParameters<viem.HttpTransport<viem.RpcSchema | undefined, boolean>>) => viem.WatchPendingTransactionsReturnType;
|
|
14063
14064
|
} & viem.WalletActions<Chain, undefined>>;
|
|
14064
14065
|
/**
|
|
14065
14066
|
* Schema for the viem client options.
|
|
@@ -14067,11 +14068,14 @@ declare const getWalletClient: (options: ClientOptions) => (verificationOptions?
|
|
|
14067
14068
|
declare const GetChainIdOptionsSchema: z.ZodObject<{
|
|
14068
14069
|
accessToken: z.ZodOptional<z.ZodString>;
|
|
14069
14070
|
rpcUrl: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
14071
|
+
httpTransportConfig: z.ZodOptional<z.ZodAny>;
|
|
14070
14072
|
}, z.core.$strip>;
|
|
14071
14073
|
/**
|
|
14072
14074
|
* Type representing the validated get chain id options.
|
|
14073
14075
|
*/
|
|
14074
|
-
type GetChainIdOptions = z.infer<typeof GetChainIdOptionsSchema
|
|
14076
|
+
type GetChainIdOptions = Omit<z.infer<typeof GetChainIdOptionsSchema>, "httpTransportConfig"> & {
|
|
14077
|
+
httpTransportConfig?: HttpTransportConfig;
|
|
14078
|
+
};
|
|
14075
14079
|
/**
|
|
14076
14080
|
* Get the chain id of a blockchain network.
|
|
14077
14081
|
* @param options - The options for the public client.
|
package/dist/viem.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as viem from 'viem';
|
|
2
|
-
import { Chain } from 'viem';
|
|
2
|
+
import { HttpTransportConfig, Chain } from 'viem';
|
|
3
3
|
import * as chains from 'viem/chains';
|
|
4
4
|
import { z } from 'zod/v4';
|
|
5
5
|
|
|
@@ -234,7 +234,6 @@ type CreateWalletVerificationChallengesResponse = WalletVerificationChallenge[];
|
|
|
234
234
|
* Schema for the viem client options.
|
|
235
235
|
*/
|
|
236
236
|
declare const ClientOptionsSchema: z.ZodObject<{
|
|
237
|
-
instance: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
238
237
|
accessToken: z.ZodOptional<z.ZodString>;
|
|
239
238
|
chainId: z.ZodOptional<z.ZodString>;
|
|
240
239
|
chainName: z.ZodString;
|
|
@@ -244,7 +243,9 @@ declare const ClientOptionsSchema: z.ZodObject<{
|
|
|
244
243
|
/**
|
|
245
244
|
* Type representing the validated client options.
|
|
246
245
|
*/
|
|
247
|
-
type ClientOptions = z.infer<typeof ClientOptionsSchema
|
|
246
|
+
type ClientOptions = Omit<z.infer<typeof ClientOptionsSchema>, "httpTransportConfig"> & {
|
|
247
|
+
httpTransportConfig?: HttpTransportConfig;
|
|
248
|
+
};
|
|
248
249
|
/**
|
|
249
250
|
* Get a public client. Use this if you need to read from the blockchain.
|
|
250
251
|
* @param options - The options for the public client.
|
|
@@ -280,7 +281,7 @@ declare const getPublicClient: (options: ClientOptions) => {
|
|
|
280
281
|
pollingInterval: number;
|
|
281
282
|
request: viem.EIP1193RequestFn<viem.PublicRpcSchema>;
|
|
282
283
|
transport: viem.TransportConfig<"http", viem.EIP1193RequestFn> & {
|
|
283
|
-
fetchOptions?:
|
|
284
|
+
fetchOptions?: HttpTransportConfig["fetchOptions"] | undefined;
|
|
284
285
|
url?: string | undefined;
|
|
285
286
|
};
|
|
286
287
|
type: string;
|
|
@@ -7132,10 +7133,10 @@ declare const getPublicClient: (options: ClientOptions) => {
|
|
|
7132
7133
|
uninstallFilter: (args: viem.UninstallFilterParameters) => Promise<viem.UninstallFilterReturnType>;
|
|
7133
7134
|
waitForTransactionReceipt: (args: viem.WaitForTransactionReceiptParameters<Chain>) => Promise<viem.TransactionReceipt>;
|
|
7134
7135
|
watchBlockNumber: (args: viem.WatchBlockNumberParameters) => viem.WatchBlockNumberReturnType;
|
|
7135
|
-
watchBlocks: <includeTransactions extends boolean = false, blockTag extends viem.BlockTag = "latest">(args: viem.WatchBlocksParameters<viem.HttpTransport<undefined,
|
|
7136
|
-
watchContractEvent: <const abi extends viem.Abi | readonly unknown[], eventName extends viem.ContractEventName<abi>, strict extends boolean | undefined = undefined>(args: viem.WatchContractEventParameters<abi, eventName, strict, viem.HttpTransport<undefined,
|
|
7137
|
-
watchEvent: <const abiEvent extends viem.AbiEvent | undefined = undefined, const abiEvents extends readonly viem.AbiEvent[] | readonly unknown[] | undefined = abiEvent extends viem.AbiEvent ? [abiEvent] : undefined, strict extends boolean | undefined = undefined>(args: viem.WatchEventParameters<abiEvent, abiEvents, strict, viem.HttpTransport<undefined,
|
|
7138
|
-
watchPendingTransactions: (args: viem.WatchPendingTransactionsParameters<viem.HttpTransport<undefined,
|
|
7136
|
+
watchBlocks: <includeTransactions extends boolean = false, blockTag extends viem.BlockTag = "latest">(args: viem.WatchBlocksParameters<viem.HttpTransport<viem.RpcSchema | undefined, boolean>, Chain, includeTransactions, blockTag>) => viem.WatchBlocksReturnType;
|
|
7137
|
+
watchContractEvent: <const abi extends viem.Abi | readonly unknown[], eventName extends viem.ContractEventName<abi>, strict extends boolean | undefined = undefined>(args: viem.WatchContractEventParameters<abi, eventName, strict, viem.HttpTransport<viem.RpcSchema | undefined, boolean>>) => viem.WatchContractEventReturnType;
|
|
7138
|
+
watchEvent: <const abiEvent extends viem.AbiEvent | undefined = undefined, const abiEvents extends readonly viem.AbiEvent[] | readonly unknown[] | undefined = abiEvent extends viem.AbiEvent ? [abiEvent] : undefined, strict extends boolean | undefined = undefined>(args: viem.WatchEventParameters<abiEvent, abiEvents, strict, viem.HttpTransport<viem.RpcSchema | undefined, boolean>>) => viem.WatchEventReturnType;
|
|
7139
|
+
watchPendingTransactions: (args: viem.WatchPendingTransactionsParameters<viem.HttpTransport<viem.RpcSchema | undefined, boolean>>) => viem.WatchPendingTransactionsReturnType;
|
|
7139
7140
|
extend: <const client extends {
|
|
7140
7141
|
[x: string]: unknown;
|
|
7141
7142
|
account?: undefined;
|
|
@@ -7150,7 +7151,7 @@ declare const getPublicClient: (options: ClientOptions) => {
|
|
|
7150
7151
|
transport?: undefined;
|
|
7151
7152
|
type?: undefined;
|
|
7152
7153
|
uid?: undefined;
|
|
7153
|
-
} & viem.ExactPartial<Pick<viem.PublicActions<viem.HttpTransport<undefined,
|
|
7154
|
+
} & viem.ExactPartial<Pick<viem.PublicActions<viem.HttpTransport<viem.RpcSchema | undefined, boolean>, Chain, undefined>, "call" | "createContractEventFilter" | "createEventFilter" | "estimateContractGas" | "estimateGas" | "getBlock" | "getBlockNumber" | "getChainId" | "getContractEvents" | "getEnsText" | "getFilterChanges" | "getGasPrice" | "getLogs" | "getTransaction" | "getTransactionCount" | "getTransactionReceipt" | "prepareTransactionRequest" | "readContract" | "sendRawTransaction" | "simulateContract" | "uninstallFilter" | "watchBlockNumber" | "watchContractEvent"> & Pick<viem.WalletActions<Chain, undefined>, "sendTransaction" | "writeContract">>>(fn: (client: viem.Client<viem.HttpTransport<viem.RpcSchema | undefined, boolean>, Chain, undefined, viem.PublicRpcSchema, viem.PublicActions<viem.HttpTransport<viem.RpcSchema | undefined, boolean>, Chain>>) => client) => viem.Client<viem.HttpTransport<viem.RpcSchema | undefined, boolean>, Chain, undefined, viem.PublicRpcSchema, { [K in keyof client]: client[K]; } & viem.PublicActions<viem.HttpTransport<viem.RpcSchema | undefined, boolean>, Chain>>;
|
|
7154
7155
|
};
|
|
7155
7156
|
/**
|
|
7156
7157
|
* The options for the wallet client.
|
|
@@ -7196,7 +7197,7 @@ interface WalletVerificationOptions {
|
|
|
7196
7197
|
* console.log(transactionHash);
|
|
7197
7198
|
* ```
|
|
7198
7199
|
*/
|
|
7199
|
-
declare const getWalletClient: (options: ClientOptions) => (verificationOptions?: WalletVerificationOptions) => viem.Client<viem.HttpTransport<undefined,
|
|
7200
|
+
declare const getWalletClient: (options: ClientOptions) => (verificationOptions?: WalletVerificationOptions) => viem.Client<viem.HttpTransport<viem.RpcSchema | undefined, boolean>, Chain, undefined, viem.WalletRpcSchema, {
|
|
7200
7201
|
verifyWalletVerificationChallenge: (args: VerifyWalletVerificationChallengeParameters) => Promise<VerifyWalletVerificationChallengeResponse>;
|
|
7201
7202
|
} & {
|
|
7202
7203
|
createWalletVerificationChallenges: (args: CreateWalletVerificationChallengesParameters) => Promise<CreateWalletVerificationChallengesResponse>;
|
|
@@ -14056,10 +14057,10 @@ declare const getWalletClient: (options: ClientOptions) => (verificationOptions?
|
|
|
14056
14057
|
uninstallFilter: (args: viem.UninstallFilterParameters) => Promise<viem.UninstallFilterReturnType>;
|
|
14057
14058
|
waitForTransactionReceipt: (args: viem.WaitForTransactionReceiptParameters<Chain>) => Promise<viem.TransactionReceipt>;
|
|
14058
14059
|
watchBlockNumber: (args: viem.WatchBlockNumberParameters) => viem.WatchBlockNumberReturnType;
|
|
14059
|
-
watchBlocks: <includeTransactions extends boolean = false, blockTag extends viem.BlockTag = "latest">(args: viem.WatchBlocksParameters<viem.HttpTransport<undefined,
|
|
14060
|
-
watchContractEvent: <const abi extends viem.Abi | readonly unknown[], eventName extends viem.ContractEventName<abi>, strict extends boolean | undefined = undefined>(args: viem.WatchContractEventParameters<abi, eventName, strict, viem.HttpTransport<undefined,
|
|
14061
|
-
watchEvent: <const abiEvent extends viem.AbiEvent | undefined = undefined, const abiEvents extends readonly viem.AbiEvent[] | readonly unknown[] | undefined = abiEvent extends viem.AbiEvent ? [abiEvent] : undefined, strict extends boolean | undefined = undefined>(args: viem.WatchEventParameters<abiEvent, abiEvents, strict, viem.HttpTransport<undefined,
|
|
14062
|
-
watchPendingTransactions: (args: viem.WatchPendingTransactionsParameters<viem.HttpTransport<undefined,
|
|
14060
|
+
watchBlocks: <includeTransactions extends boolean = false, blockTag extends viem.BlockTag = "latest">(args: viem.WatchBlocksParameters<viem.HttpTransport<viem.RpcSchema | undefined, boolean>, Chain, includeTransactions, blockTag>) => viem.WatchBlocksReturnType;
|
|
14061
|
+
watchContractEvent: <const abi extends viem.Abi | readonly unknown[], eventName extends viem.ContractEventName<abi>, strict extends boolean | undefined = undefined>(args: viem.WatchContractEventParameters<abi, eventName, strict, viem.HttpTransport<viem.RpcSchema | undefined, boolean>>) => viem.WatchContractEventReturnType;
|
|
14062
|
+
watchEvent: <const abiEvent extends viem.AbiEvent | undefined = undefined, const abiEvents extends readonly viem.AbiEvent[] | readonly unknown[] | undefined = abiEvent extends viem.AbiEvent ? [abiEvent] : undefined, strict extends boolean | undefined = undefined>(args: viem.WatchEventParameters<abiEvent, abiEvents, strict, viem.HttpTransport<viem.RpcSchema | undefined, boolean>>) => viem.WatchEventReturnType;
|
|
14063
|
+
watchPendingTransactions: (args: viem.WatchPendingTransactionsParameters<viem.HttpTransport<viem.RpcSchema | undefined, boolean>>) => viem.WatchPendingTransactionsReturnType;
|
|
14063
14064
|
} & viem.WalletActions<Chain, undefined>>;
|
|
14064
14065
|
/**
|
|
14065
14066
|
* Schema for the viem client options.
|
|
@@ -14067,11 +14068,14 @@ declare const getWalletClient: (options: ClientOptions) => (verificationOptions?
|
|
|
14067
14068
|
declare const GetChainIdOptionsSchema: z.ZodObject<{
|
|
14068
14069
|
accessToken: z.ZodOptional<z.ZodString>;
|
|
14069
14070
|
rpcUrl: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
14071
|
+
httpTransportConfig: z.ZodOptional<z.ZodAny>;
|
|
14070
14072
|
}, z.core.$strip>;
|
|
14071
14073
|
/**
|
|
14072
14074
|
* Type representing the validated get chain id options.
|
|
14073
14075
|
*/
|
|
14074
|
-
type GetChainIdOptions = z.infer<typeof GetChainIdOptionsSchema
|
|
14076
|
+
type GetChainIdOptions = Omit<z.infer<typeof GetChainIdOptionsSchema>, "httpTransportConfig"> & {
|
|
14077
|
+
httpTransportConfig?: HttpTransportConfig;
|
|
14078
|
+
};
|
|
14075
14079
|
/**
|
|
14076
14080
|
* Get the chain id of a blockchain network.
|
|
14077
14081
|
* @param options - The options for the public client.
|
package/dist/viem.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ensureServer as c}from"@settlemint/sdk-utils/runtime";import{ApplicationAccessTokenSchema as y,UrlOrPathSchema as
|
|
1
|
+
import{appendHeaders as s}from"@settlemint/sdk-utils/http";import{ensureServer as c}from"@settlemint/sdk-utils/runtime";import{ApplicationAccessTokenSchema as y,UrlOrPathSchema as O,validate as p}from"@settlemint/sdk-utils/validation";import{http as f,createPublicClient as x,createWalletClient as S,defineChain as v,publicActions as P}from"viem";import*as A from"viem/chains";import{z as l}from"zod/v4";function m(t){return{createWalletVerificationChallenges(e){return t.request({method:"user_createWalletVerificationChallenges",params:[e.addressOrObject]})}}}function d(t){return{createWalletVerification(e){return t.request({method:"user_createWalletVerification",params:[e.userWalletAddress,e.walletVerificationInfo]})}}}function W(t){return{createWallet(e){return t.request({method:"user_createWallet",params:[e.keyVaultId,e.walletInfo]})}}}function h(t){return{deleteWalletVerification(e){return t.request({method:"user_deleteWalletVerification",params:[e.userWalletAddress,e.verificationId]})}}}function C(t){return{getWalletVerifications(e){return t.request({method:"user_walletVerifications",params:[e.userWalletAddress]})}}}function V(t){return{verifyWalletVerificationChallenge(e){return t.request({method:"user_verifyWalletVerificationChallenge",params:[e.addressOrObject,e.challengeResponse]})}}}var u=(r=>(r.PINCODE="PINCODE",r.OTP="OTP",r.SECRET_CODES="SECRET_CODES",r))(u||{}),g=(i=>(i.SHA1="SHA1",i.SHA224="SHA224",i.SHA256="SHA256",i.SHA384="SHA384",i.SHA512="SHA512",i.SHA3_224="SHA3-224",i.SHA3_256="SHA3-256",i.SHA3_384="SHA3-384",i.SHA3_512="SHA3-512",i))(g||{});var R=l.object({accessToken:y.optional(),chainId:l.string().optional(),chainName:l.string(),rpcUrl:O,httpTransportConfig:l.any().optional()}),ie=t=>{c();let e=p(R,t);return x({chain:T(e),transport:f(e.rpcUrl,{batch:!0,timeout:6e4,...e.httpTransportConfig,fetchOptions:{...e?.httpTransportConfig?.fetchOptions,headers:s(e?.httpTransportConfig?.fetchOptions?.headers,{"x-auth-token":e.accessToken})}})})},re=t=>{c();let e=p(R,t),o=T(e);return r=>S({chain:o,transport:f(e.rpcUrl,{batch:!0,timeout:6e4,...e.httpTransportConfig,fetchOptions:{...e?.httpTransportConfig?.fetchOptions,headers:s(e?.httpTransportConfig?.fetchOptions?.headers,{"x-auth-token":e.accessToken,"x-auth-challenge-response":r?.challengeResponse??"","x-auth-verification-id":r?.verificationId??""})}})}).extend(P).extend(W).extend(C).extend(d).extend(h).extend(m).extend(V)},b=l.object({accessToken:y.optional(),rpcUrl:O,httpTransportConfig:l.any().optional()});async function ae(t){c();let e=p(b,t);return x({transport:f(e.rpcUrl,{...e.httpTransportConfig,fetchOptions:{...e?.httpTransportConfig?.fetchOptions,headers:s(e?.httpTransportConfig?.fetchOptions?.headers,{"x-auth-token":e.accessToken})}})}).getChainId()}function T({chainId:t,chainName:e,rpcUrl:o}){return Object.values(A).find(I=>I.id.toString()===t)??v({id:Number(t),name:e,rpcUrls:{default:{http:[o]}},nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"}})}export{R as ClientOptionsSchema,b as GetChainIdOptionsSchema,g as OTPAlgorithm,u as WalletVerificationType,ae as getChainId,ie as getPublicClient,re as getWalletClient};
|
|
2
2
|
//# sourceMappingURL=viem.mjs.map
|
package/dist/viem.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/viem.ts","../src/custom-actions/create-wallet-verification-challenges.action.ts","../src/custom-actions/create-wallet-verification.action.ts","../src/custom-actions/create-wallet.action.ts","../src/custom-actions/delete-wallet-verification.action.ts","../src/custom-actions/get-wallet-verifications.action.ts","../src/custom-actions/verify-wallet-verification-challenge.action.ts","../src/custom-actions/types/wallet-verification.enum.ts"],"sourcesContent":["import { ensureServer } from \"@settlemint/sdk-utils/runtime\";\nimport { ApplicationAccessTokenSchema, UrlOrPathSchema, validate } from \"@settlemint/sdk-utils/validation\";\nimport {\n http,\n type Chain as ViemChain,\n createPublicClient,\n createWalletClient,\n defineChain,\n publicActions,\n} from \"viem\";\nimport * as chains from \"viem/chains\";\nimport { z } from \"zod/v4\";\nimport { createWalletVerificationChallenges } from \"./custom-actions/create-wallet-verification-challenges.action.js\";\nimport { createWalletVerification } from \"./custom-actions/create-wallet-verification.action.js\";\nimport { createWallet } from \"./custom-actions/create-wallet.action.js\";\nimport { deleteWalletVerification } from \"./custom-actions/delete-wallet-verification.action.js\";\nimport { getWalletVerifications } from \"./custom-actions/get-wallet-verifications.action.js\";\nimport { verifyWalletVerificationChallenge } from \"./custom-actions/verify-wallet-verification-challenge.action.js\";\n\n/**\n * Schema for the viem client options.\n */\nexport const ClientOptionsSchema = z.object({\n /**\n * The instance URL\n */\n instance: UrlOrPathSchema,\n /**\n * The access token\n */\n accessToken: ApplicationAccessTokenSchema.optional(),\n /**\n * The chain id\n */\n chainId: z.string().optional(),\n /**\n * The chain name\n */\n chainName: z.string(),\n /**\n * The json rpc url\n */\n rpcUrl: UrlOrPathSchema,\n /**\n * The http transport config\n */\n httpTransportConfig: z.any().optional(),\n});\n\n/**\n * Type representing the validated client options.\n */\nexport type ClientOptions = z.infer<typeof ClientOptionsSchema>;\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. see {@link https://viem.sh/docs/clients/public}\n * @example\n * ```ts\n * import { getPublicClient } from '@settlemint/sdk-viem';\n *\n * const publicClient = getPublicClient({\n * accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,\n * chainId: process.env.SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID!,\n * chainName: process.env.SETTLEMINT_BLOCKCHAIN_NETWORK!,\n * rpcUrl: process.env.SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT!,\n * });\n *\n * // Get the block number\n * const block = await publicClient.getBlockNumber();\n * console.log(block);\n * ```\n */\nexport const getPublicClient = (options: ClientOptions) => {\n ensureServer();\n const validatedOptions = validate(ClientOptionsSchema, options);\n return createPublicClient({\n chain: getChain(validatedOptions),\n transport: http(validatedOptions.rpcUrl, {\n batch: true,\n timeout: 60_000,\n ...validatedOptions.httpTransportConfig,\n fetchOptions: {\n ...validatedOptions?.httpTransportConfig?.fetchOptions,\n headers: {\n ...validatedOptions?.httpTransportConfig?.fetchOptions?.headers,\n \"x-auth-token\": validatedOptions.accessToken,\n },\n },\n }),\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 for HD wallets. see {@link https://viem.sh/docs/clients/wallet}\n * @example\n * ```ts\n * import { getWalletClient } from '@settlemint/sdk-viem';\n * import { parseAbi } from \"viem\";\n *\n * const walletClient = getWalletClient({\n * accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,\n * chainId: process.env.SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID!,\n * chainName: process.env.SETTLEMINT_BLOCKCHAIN_NETWORK!,\n * rpcUrl: process.env.SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT!,\n * });\n *\n * // Get the chain id\n * const chainId = await walletClient().getChainId();\n * console.log(chainId);\n *\n * // write to the blockchain\n * const transactionHash = await walletClient().writeContract({\n * account: \"0x0000000000000000000000000000000000000000\",\n * address: \"0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2\",\n * abi: parseAbi([\"function mint(uint32 tokenId) nonpayable\"]),\n * functionName: \"mint\",\n * args: [69420],\n * });\n * console.log(transactionHash);\n * ```\n */\nexport const getWalletClient = (options: ClientOptions) => {\n ensureServer();\n const validatedOptions = validate(ClientOptionsSchema, options);\n const chain = getChain(validatedOptions);\n return (verificationOptions?: WalletVerificationOptions) =>\n createWalletClient({\n chain: chain,\n transport: http(validatedOptions.rpcUrl, {\n batch: true,\n timeout: 60_000,\n ...validatedOptions.httpTransportConfig,\n fetchOptions: {\n ...validatedOptions?.httpTransportConfig?.fetchOptions,\n headers: {\n ...validatedOptions?.httpTransportConfig?.fetchOptions?.headers,\n \"x-auth-token\": validatedOptions.accessToken,\n \"x-auth-challenge-response\": verificationOptions?.challengeResponse ?? \"\",\n \"x-auth-verification-id\": verificationOptions?.verificationId ?? \"\",\n },\n },\n }),\n })\n .extend(publicActions)\n .extend(createWallet)\n .extend(getWalletVerifications)\n .extend(createWalletVerification)\n .extend(deleteWalletVerification)\n .extend(createWalletVerificationChallenges)\n .extend(verifyWalletVerificationChallenge);\n};\n\n/**\n * Schema for the viem client options.\n */\nexport const GetChainIdOptionsSchema = z.object({\n /**\n * The access token\n */\n accessToken: ApplicationAccessTokenSchema.optional(),\n /**\n * The json rpc url\n */\n rpcUrl: UrlOrPathSchema,\n});\n\n/**\n * Type representing the validated get chain id options.\n */\nexport type GetChainIdOptions = z.infer<typeof GetChainIdOptionsSchema>;\n\n/**\n * Get the chain id of a blockchain network.\n * @param options - The options for the public client.\n * @returns The chain id.\n * @example\n * ```ts\n * import { getChainId } from '@settlemint/sdk-viem';\n *\n * const chainId = await getChainId({\n * accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,\n * rpcUrl: process.env.SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT!,\n * });\n * console.log(chainId);\n * ```\n */\nexport async function getChainId(options: GetChainIdOptions): Promise<number> {\n ensureServer();\n const validatedOptions = validate(GetChainIdOptionsSchema, options);\n const client = createPublicClient({\n transport: http(validatedOptions.rpcUrl, {\n fetchOptions: {\n headers: validatedOptions.accessToken\n ? {\n \"x-auth-token\": validatedOptions.accessToken,\n }\n : undefined,\n },\n }),\n });\n\n return client.getChainId();\n}\n\nfunction getChain({ chainId, chainName, rpcUrl }: Pick<ClientOptions, \"chainId\" | \"chainName\" | \"rpcUrl\">): ViemChain {\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\nexport { OTPAlgorithm, WalletVerificationType } from \"./custom-actions/types/wallet-verification.enum.js\";\n\nexport type {\n CreateWalletVerificationChallengesResponse,\n CreateWalletVerificationChallengesParameters,\n WalletVerificationChallenge,\n} from \"./custom-actions/create-wallet-verification-challenges.action.js\";\nexport type {\n CreateWalletVerificationResponse,\n CreateWalletVerificationParameters,\n WalletVerificationInfo,\n WalletPincodeVerificationInfo,\n WalletOTPVerificationInfo,\n WalletSecretCodesVerificationInfo,\n} from \"./custom-actions/create-wallet-verification.action.js\";\nexport type {\n CreateWalletResponse,\n CreateWalletParameters,\n WalletInfo,\n} from \"./custom-actions/create-wallet.action.js\";\nexport type {\n DeleteWalletVerificationParameters,\n DeleteWalletVerificationResponse,\n} from \"./custom-actions/delete-wallet-verification.action.js\";\nexport type {\n GetWalletVerificationsParameters,\n GetWalletVerificationsResponse,\n WalletVerification,\n} from \"./custom-actions/get-wallet-verifications.action.js\";\nexport type {\n VerifyWalletVerificationChallengeParameters,\n AddressOrObject,\n VerifyWalletVerificationChallengeResponse,\n VerificationResult,\n} from \"./custom-actions/verify-wallet-verification-challenge.action.js\";\n","import type { Client } from \"viem\";\nimport type { WalletVerificationType } from \"./types/wallet-verification.enum.js\";\nimport type { AddressOrObject } from \"./verify-wallet-verification-challenge.action.js\";\n\n/**\n * Parameters for creating wallet verification challenges.\n */\nexport interface CreateWalletVerificationChallengesParameters {\n /** The wallet address or object containing wallet address and optional verification ID. */\n addressOrObject: AddressOrObject;\n}\n\n/**\n * Represents a wallet verification challenge.\n */\nexport interface WalletVerificationChallenge {\n /** The unique identifier of the challenge. */\n id: string;\n /** The name of the challenge. */\n name: string;\n /** The type of verification required. */\n verificationType: WalletVerificationType;\n /** The challenge parameters specific to the verification type. */\n challenge: Record<string, string>;\n}\n\n/**\n * Response from creating wallet verification challenges.\n */\nexport type CreateWalletVerificationChallengesResponse = WalletVerificationChallenge[];\n\n/**\n * RPC schema for creating wallet verification challenges.\n */\ntype WalletRpcSchema = {\n Method: \"user_createWalletVerificationChallenges\";\n Parameters: [addressOrObject: AddressOrObject];\n ReturnType: CreateWalletVerificationChallengesResponse;\n};\n\n/**\n * Creates a wallet verification challenges action for the given client.\n * @param client - The viem client to use for the request.\n * @returns An object with a createWalletVerificationChallenges method.\n */\nexport function createWalletVerificationChallenges(client: Client) {\n return {\n /**\n * Creates verification challenges for a wallet.\n * @param args - The parameters for creating the challenges.\n * @returns A promise that resolves to an array of wallet verification challenges.\n */\n createWalletVerificationChallenges(\n args: CreateWalletVerificationChallengesParameters,\n ): Promise<CreateWalletVerificationChallengesResponse> {\n return client.request<WalletRpcSchema>({\n method: \"user_createWalletVerificationChallenges\",\n params: [args.addressOrObject],\n });\n },\n };\n}\n","import type { Client } from \"viem\";\nimport type { OTPAlgorithm, WalletVerificationType } from \"./types/wallet-verification.enum.js\";\n\n/**\n * Base interface for wallet verification information.\n */\ntype BaseWalletVerificationInfo = {\n /** The name of the verification method. */\n name: string;\n /** The type of verification method. */\n verificationType: WalletVerificationType;\n};\n\n/**\n * Information for PIN code verification.\n */\nexport interface WalletPincodeVerificationInfo extends BaseWalletVerificationInfo {\n /** The type of verification method. */\n verificationType: WalletVerificationType.PINCODE;\n /** The PIN code to use for verification. */\n pincode: string;\n}\n\n/**\n * Information for One-Time Password (OTP) verification.\n */\nexport interface WalletOTPVerificationInfo extends BaseWalletVerificationInfo {\n /** The type of verification method. */\n verificationType: WalletVerificationType.OTP;\n /** The hash algorithm to use for OTP generation. */\n algorithm?: OTPAlgorithm;\n /** The number of digits in the OTP code. */\n digits?: number;\n /** The time period in seconds for OTP validity. */\n period?: number;\n /** The issuer of the OTP. */\n issuer?: string;\n}\n\n/**\n * Information for secret recovery codes verification.\n */\nexport interface WalletSecretCodesVerificationInfo extends BaseWalletVerificationInfo {\n /** The type of verification method. */\n verificationType: WalletVerificationType.SECRET_CODES;\n}\n\n/**\n * Union type of all possible wallet verification information types.\n */\nexport type WalletVerificationInfo =\n | WalletPincodeVerificationInfo\n | WalletOTPVerificationInfo\n | WalletSecretCodesVerificationInfo;\n\n/**\n * Parameters for creating a wallet verification.\n */\nexport interface CreateWalletVerificationParameters {\n /** The wallet address for which to create the verification. */\n userWalletAddress: string;\n /** The verification information to create. */\n walletVerificationInfo: WalletVerificationInfo;\n}\n\n/**\n * Response from creating a wallet verification.\n */\nexport interface CreateWalletVerificationResponse {\n /** The unique identifier of the verification. */\n id: string;\n /** The name of the verification method. */\n name: string;\n /** The type of verification method. */\n verificationType: WalletVerificationType;\n /** Additional parameters specific to the verification type. */\n parameters: Record<string, string>;\n}\n\n/**\n * RPC schema for creating a wallet verification.\n */\ntype WalletRpcSchema = {\n Method: \"user_createWalletVerification\";\n Parameters: [userWalletAddress: string, walletVerificationInfo: WalletVerificationInfo];\n ReturnType: CreateWalletVerificationResponse[];\n};\n\n/**\n * Creates a wallet verification action for the given client.\n * @param client - The viem client to use for the request.\n * @returns An object with a createWalletVerification method.\n */\nexport function createWalletVerification(client: Client) {\n return {\n /**\n * Creates a new wallet verification.\n * @param args - The parameters for creating the verification.\n * @returns A promise that resolves to an array of created wallet verification responses.\n */\n createWalletVerification(args: CreateWalletVerificationParameters): Promise<CreateWalletVerificationResponse[]> {\n return client.request<WalletRpcSchema>({\n method: \"user_createWalletVerification\",\n params: [args.userWalletAddress, args.walletVerificationInfo],\n });\n },\n };\n}\n","import type { Client } from \"viem\";\n\n/**\n * Information about the wallet to be created.\n */\nexport interface WalletInfo {\n /** The name of the wallet. */\n name: string;\n}\n\n/**\n * Parameters for creating a wallet.\n */\nexport interface CreateWalletParameters {\n /** The unique name of the key vault where the wallet will be created. */\n keyVaultId: string;\n /** Information about the wallet to be created. */\n walletInfo: WalletInfo;\n}\n\n/**\n * Response from creating a wallet.\n */\nexport interface CreateWalletResponse {\n /** The unique identifier of the wallet. */\n id: string;\n /** The name of the wallet. */\n name: string;\n /** The blockchain address of the wallet. */\n address: string;\n /** The HD derivation path used to create the wallet. */\n derivationPath: string;\n}\n\n/**\n * RPC schema for wallet creation.\n */\ntype WalletRpcSchema = {\n Method: \"user_createWallet\";\n Parameters: [keyVaultId: string, walletInfo: WalletInfo];\n ReturnType: CreateWalletResponse[];\n};\n\n/**\n * Creates a wallet action for the given client.\n * @param client - The viem client to use for the request.\n * @returns An object with a createWallet method.\n */\nexport function createWallet(client: Client) {\n return {\n /**\n * Creates a new wallet in the specified key vault.\n * @param args - The parameters for creating a wallet.\n * @returns A promise that resolves to an array of created wallet responses.\n */\n createWallet(args: CreateWalletParameters): Promise<CreateWalletResponse[]> {\n return client.request<WalletRpcSchema>({\n method: \"user_createWallet\",\n params: [args.keyVaultId, args.walletInfo],\n });\n },\n };\n}\n","import type { Client } from \"viem\";\n\n/**\n * Parameters for deleting a wallet verification.\n */\nexport interface DeleteWalletVerificationParameters {\n /** The wallet address for which to delete the verification. */\n userWalletAddress: string;\n /** The unique identifier of the verification to delete. */\n verificationId: string;\n}\n\n/**\n * Response from deleting a wallet verification.\n */\nexport interface DeleteWalletVerificationResponse {\n /** Whether the deletion was successful. */\n success: boolean;\n}\n\n/**\n * RPC schema for deleting a wallet verification.\n */\ntype WalletRpcSchema = {\n Method: \"user_deleteWalletVerification\";\n Parameters: [userWalletAddress: string, verificationId: string];\n ReturnType: DeleteWalletVerificationResponse[];\n};\n\n/**\n * Creates a wallet verification deletion action for the given client.\n * @param client - The viem client to use for the request.\n * @returns An object with a deleteWalletVerification method.\n */\nexport function deleteWalletVerification(client: Client) {\n return {\n /**\n * Deletes a wallet verification.\n * @param args - The parameters for deleting the verification.\n * @returns A promise that resolves to an array of deletion results.\n */\n deleteWalletVerification(args: DeleteWalletVerificationParameters): Promise<DeleteWalletVerificationResponse[]> {\n return client.request<WalletRpcSchema>({\n method: \"user_deleteWalletVerification\",\n params: [args.userWalletAddress, args.verificationId],\n });\n },\n };\n}\n","import type { Client } from \"viem\";\nimport type { WalletVerificationType } from \"./types/wallet-verification.enum.js\";\n\n/**\n * Parameters for getting wallet verifications.\n */\nexport interface GetWalletVerificationsParameters {\n /** The wallet address for which to fetch verifications. */\n userWalletAddress: string;\n}\n\n/**\n * Represents a wallet verification.\n */\nexport interface WalletVerification {\n /** The unique identifier of the verification. */\n id: string;\n /** The name of the verification method. */\n name: string;\n /** The type of verification method. */\n verificationType: WalletVerificationType;\n}\n\n/**\n * Response from getting wallet verifications.\n */\nexport type GetWalletVerificationsResponse = WalletVerification[];\n\n/**\n * RPC schema for getting wallet verifications.\n */\ntype WalletRpcSchema = {\n Method: \"user_walletVerifications\";\n Parameters: [userWalletAddress: string];\n ReturnType: GetWalletVerificationsResponse;\n};\n\n/**\n * Creates a wallet verifications retrieval action for the given client.\n * @param client - The viem client to use for the request.\n * @returns An object with a getWalletVerifications method.\n */\nexport function getWalletVerifications(client: Client) {\n return {\n /**\n * Gets all verifications for a wallet.\n * @param args - The parameters for getting the verifications.\n * @returns A promise that resolves to an array of wallet verifications.\n */\n getWalletVerifications(args: GetWalletVerificationsParameters): Promise<GetWalletVerificationsResponse> {\n return client.request<WalletRpcSchema>({\n method: \"user_walletVerifications\",\n params: [args.userWalletAddress],\n });\n },\n };\n}\n","import type { Client } from \"viem\";\n\n/**\n * Represents either a wallet address string or an object containing wallet address and optional verification ID.\n */\nexport type AddressOrObject =\n | string\n | {\n userWalletAddress: string;\n verificationId?: string;\n };\n\n/**\n * Parameters for verifying a wallet verification challenge.\n */\nexport interface VerifyWalletVerificationChallengeParameters {\n /** The wallet address or object containing wallet address and optional verification ID. */\n addressOrObject: AddressOrObject;\n /** The response to the verification challenge. */\n challengeResponse: string;\n}\n\n/**\n * Result of a wallet verification challenge.\n */\nexport interface VerificationResult {\n /** Whether the verification was successful. */\n verified: boolean;\n}\n\n/**\n * Response from verifying a wallet verification challenge.\n */\nexport type VerifyWalletVerificationChallengeResponse = VerificationResult[];\n\n/**\n * RPC schema for wallet verification challenge verification.\n */\ntype WalletRpcSchema = {\n Method: \"user_verifyWalletVerificationChallenge\";\n Parameters: [addressOrObject: AddressOrObject, challengeResponse: string];\n ReturnType: VerifyWalletVerificationChallengeResponse;\n};\n\n/**\n * Creates a wallet verification challenge verification action for the given client.\n * @param client - The viem client to use for the request.\n * @returns An object with a verifyWalletVerificationChallenge method.\n */\nexport function verifyWalletVerificationChallenge(client: Client) {\n return {\n /**\n * Verifies a wallet verification challenge.\n * @param args - The parameters for verifying the challenge.\n * @returns A promise that resolves to an array of verification results.\n */\n verifyWalletVerificationChallenge(\n args: VerifyWalletVerificationChallengeParameters,\n ): Promise<VerifyWalletVerificationChallengeResponse> {\n return client.request<WalletRpcSchema>({\n method: \"user_verifyWalletVerificationChallenge\",\n params: [args.addressOrObject, args.challengeResponse],\n });\n },\n };\n}\n","/**\n * Types of wallet verification methods supported by the system.\n * Used to identify different verification mechanisms when creating or managing wallet verifications.\n */\nexport enum WalletVerificationType {\n /** PIN code verification method */\n PINCODE = \"PINCODE\",\n /** One-Time Password verification method */\n OTP = \"OTP\",\n /** Secret recovery codes verification method */\n SECRET_CODES = \"SECRET_CODES\",\n}\n\n/**\n * Supported hash algorithms for One-Time Password (OTP) verification.\n * These algorithms determine the cryptographic function used to generate OTP codes.\n */\nexport enum OTPAlgorithm {\n /** SHA-1 hash algorithm */\n SHA1 = \"SHA1\",\n /** SHA-224 hash algorithm */\n SHA224 = \"SHA224\",\n /** SHA-256 hash algorithm */\n SHA256 = \"SHA256\",\n /** SHA-384 hash algorithm */\n SHA384 = \"SHA384\",\n /** SHA-512 hash algorithm */\n SHA512 = \"SHA512\",\n /** SHA3-224 hash algorithm */\n SHA3_224 = \"SHA3-224\",\n /** SHA3-256 hash algorithm */\n SHA3_256 = \"SHA3-256\",\n /** SHA3-384 hash algorithm */\n SHA3_384 = \"SHA3-384\",\n /** SHA3-512 hash algorithm */\n SHA3_512 = \"SHA3-512\",\n}\n"],"mappings":"AAAA,OAAS,gBAAAA,MAAoB,gCAC7B,OAAS,gCAAAC,EAA8B,mBAAAC,EAAiB,YAAAC,MAAgB,mCACxE,OACE,QAAAC,EAEA,sBAAAC,EACA,sBAAAC,EACA,eAAAC,EACA,iBAAAC,MACK,OACP,UAAYC,MAAY,cACxB,OAAS,KAAAC,MAAS,SCkCX,SAASC,EAAmCC,EAAgB,CACjE,MAAO,CAML,mCACEC,EACqD,CACrD,OAAOD,EAAO,QAAyB,CACrC,OAAQ,0CACR,OAAQ,CAACC,EAAK,eAAe,CAC/B,CAAC,CACH,CACF,CACF,CCgCO,SAASC,EAAyBC,EAAgB,CACvD,MAAO,CAML,yBAAyBC,EAAuF,CAC9G,OAAOD,EAAO,QAAyB,CACrC,OAAQ,gCACR,OAAQ,CAACC,EAAK,kBAAmBA,EAAK,sBAAsB,CAC9D,CAAC,CACH,CACF,CACF,CC3DO,SAASC,EAAaC,EAAgB,CAC3C,MAAO,CAML,aAAaC,EAA+D,CAC1E,OAAOD,EAAO,QAAyB,CACrC,OAAQ,oBACR,OAAQ,CAACC,EAAK,WAAYA,EAAK,UAAU,CAC3C,CAAC,CACH,CACF,CACF,CC5BO,SAASC,EAAyBC,EAAgB,CACvD,MAAO,CAML,yBAAyBC,EAAuF,CAC9G,OAAOD,EAAO,QAAyB,CACrC,OAAQ,gCACR,OAAQ,CAACC,EAAK,kBAAmBA,EAAK,cAAc,CACtD,CAAC,CACH,CACF,CACF,CCNO,SAASC,EAAuBC,EAAgB,CACrD,MAAO,CAML,uBAAuBC,EAAiF,CACtG,OAAOD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AOF,EACP,UAAWF,EAAKJ,EAAiB,OAAQ,CACvC,MAAO,GACP,QAAS,IACT,GAAGA,EAAiB,oBACpB,aAAc,CACZ,GAAGA,GAAkB,qBAAqB,aAC1C,QAAS,CACP,GAAGA,GAAkB,qBAAqB,cAAc,QACxD,eAAgBA,EAAiB,YACjC,4BAA6BO,GAAqB,mBAAqB,GACvE,yBAA0BA,GAAqB,gBAAkB,EACnE,CACF,CACF,CAAC,CACH,CAAC,EACE,OAAOE,CAAa,EACpB,OAAOC,CAAY,EACnB,OAAOC,CAAsB,EAC7B,OAAOC,CAAwB,EAC/B,OAAOC,CAAwB,EAC/B,OAAOC,CAAkC,EACzC,OAAOC,CAAiC,CAC/C,EAKaC,EAA0BtB,EAAE,OAAO,CAI9C,YAAaE,EAA6B,SAAS,EAInD,OAAQD,CACV,CAAC,EAsBD,eAAsBsB,GAAWnB,EAA6C,CAC5EC,EAAa,EACb,IAAMC,EAAmBC,EAASe,EAAyBlB,CAAO,EAalE,OAZeI,EAAmB,CAChC,UAAWE,EAAKJ,EAAiB,OAAQ,CACvC,aAAc,CACZ,QAASA,EAAiB,YACtB,CACE,eAAgBA,EAAiB,WACnC,EACA,MACN,CACF,CAAC,CACH,CAAC,EAEa,WAAW,CAC3B,CAEA,SAASG,EAAS,CAAE,QAAAe,EAAS,UAAAC,EAAW,OAAAC,CAAO,EAAuE,CAEpH,OADmB,OAAO,OAAOC,CAAM,EAAE,KAAMf,GAAUA,EAAM,GAAG,SAAS,IAAMY,CAAO,GAGtFI,EAAY,CACV,GAAI,OAAOJ,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":["ensureServer","ApplicationAccessTokenSchema","UrlOrPathSchema","validate","http","createPublicClient","createWalletClient","defineChain","publicActions","chains","z","createWalletVerificationChallenges","client","args","createWalletVerification","client","args","createWallet","client","args","deleteWalletVerification","client","args","getWalletVerifications","client","args","verifyWalletVerificationChallenge","client","args","WalletVerificationType","OTPAlgorithm","ClientOptionsSchema","z","UrlOrPathSchema","ApplicationAccessTokenSchema","getPublicClient","options","ensureServer","validatedOptions","validate","createPublicClient","getChain","http","getWalletClient","chain","verificationOptions","createWalletClient","publicActions","createWallet","getWalletVerifications","createWalletVerification","deleteWalletVerification","createWalletVerificationChallenges","verifyWalletVerificationChallenge","GetChainIdOptionsSchema","getChainId","chainId","chainName","rpcUrl","chains","defineChain"]}
|
|
1
|
+
{"version":3,"sources":["../src/viem.ts","../src/custom-actions/create-wallet-verification-challenges.action.ts","../src/custom-actions/create-wallet-verification.action.ts","../src/custom-actions/create-wallet.action.ts","../src/custom-actions/delete-wallet-verification.action.ts","../src/custom-actions/get-wallet-verifications.action.ts","../src/custom-actions/verify-wallet-verification-challenge.action.ts","../src/custom-actions/types/wallet-verification.enum.ts"],"sourcesContent":["import { appendHeaders } from \"@settlemint/sdk-utils/http\";\nimport { ensureServer } from \"@settlemint/sdk-utils/runtime\";\nimport { ApplicationAccessTokenSchema, UrlOrPathSchema, validate } from \"@settlemint/sdk-utils/validation\";\nimport {\n http,\n type HttpTransportConfig,\n type Chain as ViemChain,\n createPublicClient,\n createWalletClient,\n defineChain,\n publicActions,\n} from \"viem\";\nimport * as chains from \"viem/chains\";\nimport { z } from \"zod/v4\";\nimport { createWalletVerificationChallenges } from \"./custom-actions/create-wallet-verification-challenges.action.js\";\nimport { createWalletVerification } from \"./custom-actions/create-wallet-verification.action.js\";\nimport { createWallet } from \"./custom-actions/create-wallet.action.js\";\nimport { deleteWalletVerification } from \"./custom-actions/delete-wallet-verification.action.js\";\nimport { getWalletVerifications } from \"./custom-actions/get-wallet-verifications.action.js\";\nimport { verifyWalletVerificationChallenge } from \"./custom-actions/verify-wallet-verification-challenge.action.js\";\n\n/**\n * Schema for the viem client options.\n */\nexport const ClientOptionsSchema = z.object({\n /**\n * The access token\n */\n accessToken: ApplicationAccessTokenSchema.optional(),\n /**\n * The chain id\n */\n chainId: z.string().optional(),\n /**\n * The chain name\n */\n chainName: z.string(),\n /**\n * The json rpc url\n */\n rpcUrl: UrlOrPathSchema,\n /**\n * The http transport config\n */\n httpTransportConfig: z.any().optional(),\n});\n\n/**\n * Type representing the validated client options.\n */\nexport type ClientOptions = Omit<z.infer<typeof ClientOptionsSchema>, \"httpTransportConfig\"> & {\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. see {@link https://viem.sh/docs/clients/public}\n * @example\n * ```ts\n * import { getPublicClient } from '@settlemint/sdk-viem';\n *\n * const publicClient = getPublicClient({\n * accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,\n * chainId: process.env.SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID!,\n * chainName: process.env.SETTLEMINT_BLOCKCHAIN_NETWORK!,\n * rpcUrl: process.env.SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT!,\n * });\n *\n * // Get the block number\n * const block = await publicClient.getBlockNumber();\n * console.log(block);\n * ```\n */\nexport const getPublicClient = (options: ClientOptions) => {\n ensureServer();\n const validatedOptions: ClientOptions = validate(ClientOptionsSchema, options);\n return createPublicClient({\n chain: getChain(validatedOptions),\n transport: http(validatedOptions.rpcUrl, {\n batch: true,\n timeout: 60_000,\n ...validatedOptions.httpTransportConfig,\n fetchOptions: {\n ...validatedOptions?.httpTransportConfig?.fetchOptions,\n headers: appendHeaders(validatedOptions?.httpTransportConfig?.fetchOptions?.headers, {\n \"x-auth-token\": validatedOptions.accessToken,\n }),\n },\n }),\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 for HD wallets. see {@link https://viem.sh/docs/clients/wallet}\n * @example\n * ```ts\n * import { getWalletClient } from '@settlemint/sdk-viem';\n * import { parseAbi } from \"viem\";\n *\n * const walletClient = getWalletClient({\n * accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,\n * chainId: process.env.SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID!,\n * chainName: process.env.SETTLEMINT_BLOCKCHAIN_NETWORK!,\n * rpcUrl: process.env.SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT!,\n * });\n *\n * // Get the chain id\n * const chainId = await walletClient().getChainId();\n * console.log(chainId);\n *\n * // write to the blockchain\n * const transactionHash = await walletClient().writeContract({\n * account: \"0x0000000000000000000000000000000000000000\",\n * address: \"0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2\",\n * abi: parseAbi([\"function mint(uint32 tokenId) nonpayable\"]),\n * functionName: \"mint\",\n * args: [69420],\n * });\n * console.log(transactionHash);\n * ```\n */\nexport const getWalletClient = (options: ClientOptions) => {\n ensureServer();\n const validatedOptions: ClientOptions = validate(ClientOptionsSchema, options);\n const chain = getChain(validatedOptions);\n return (verificationOptions?: WalletVerificationOptions) =>\n createWalletClient({\n chain: chain,\n transport: http(validatedOptions.rpcUrl, {\n batch: true,\n timeout: 60_000,\n ...validatedOptions.httpTransportConfig,\n fetchOptions: {\n ...validatedOptions?.httpTransportConfig?.fetchOptions,\n headers: appendHeaders(validatedOptions?.httpTransportConfig?.fetchOptions?.headers, {\n \"x-auth-token\": validatedOptions.accessToken,\n \"x-auth-challenge-response\": verificationOptions?.challengeResponse ?? \"\",\n \"x-auth-verification-id\": verificationOptions?.verificationId ?? \"\",\n }),\n },\n }),\n })\n .extend(publicActions)\n .extend(createWallet)\n .extend(getWalletVerifications)\n .extend(createWalletVerification)\n .extend(deleteWalletVerification)\n .extend(createWalletVerificationChallenges)\n .extend(verifyWalletVerificationChallenge);\n};\n\n/**\n * Schema for the viem client options.\n */\nexport const GetChainIdOptionsSchema = z.object({\n /**\n * The access token\n */\n accessToken: ApplicationAccessTokenSchema.optional(),\n /**\n * The json rpc url\n */\n rpcUrl: UrlOrPathSchema,\n /**\n * The http transport config\n */\n httpTransportConfig: z.any().optional(),\n});\n\n/**\n * Type representing the validated get chain id options.\n */\nexport type GetChainIdOptions = Omit<z.infer<typeof GetChainIdOptionsSchema>, \"httpTransportConfig\"> & {\n httpTransportConfig?: HttpTransportConfig;\n};\n\n/**\n * Get the chain id of a blockchain network.\n * @param options - The options for the public client.\n * @returns The chain id.\n * @example\n * ```ts\n * import { getChainId } from '@settlemint/sdk-viem';\n *\n * const chainId = await getChainId({\n * accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,\n * rpcUrl: process.env.SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT!,\n * });\n * console.log(chainId);\n * ```\n */\nexport async function getChainId(options: GetChainIdOptions): Promise<number> {\n ensureServer();\n const validatedOptions: GetChainIdOptions = validate(GetChainIdOptionsSchema, options);\n const client = createPublicClient({\n transport: http(validatedOptions.rpcUrl, {\n ...validatedOptions.httpTransportConfig,\n fetchOptions: {\n ...validatedOptions?.httpTransportConfig?.fetchOptions,\n headers: appendHeaders(validatedOptions?.httpTransportConfig?.fetchOptions?.headers, {\n \"x-auth-token\": validatedOptions.accessToken,\n }),\n },\n }),\n });\n\n return client.getChainId();\n}\n\nfunction getChain({ chainId, chainName, rpcUrl }: Pick<ClientOptions, \"chainId\" | \"chainName\" | \"rpcUrl\">): ViemChain {\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\nexport { OTPAlgorithm, WalletVerificationType } from \"./custom-actions/types/wallet-verification.enum.js\";\n\nexport type {\n CreateWalletVerificationChallengesParameters,\n CreateWalletVerificationChallengesResponse,\n WalletVerificationChallenge,\n} from \"./custom-actions/create-wallet-verification-challenges.action.js\";\nexport type {\n CreateWalletVerificationParameters,\n CreateWalletVerificationResponse,\n WalletOTPVerificationInfo,\n WalletPincodeVerificationInfo,\n WalletSecretCodesVerificationInfo,\n WalletVerificationInfo,\n} from \"./custom-actions/create-wallet-verification.action.js\";\nexport type {\n CreateWalletParameters,\n CreateWalletResponse,\n WalletInfo,\n} from \"./custom-actions/create-wallet.action.js\";\nexport type {\n DeleteWalletVerificationParameters,\n DeleteWalletVerificationResponse,\n} from \"./custom-actions/delete-wallet-verification.action.js\";\nexport type {\n GetWalletVerificationsParameters,\n GetWalletVerificationsResponse,\n WalletVerification,\n} from \"./custom-actions/get-wallet-verifications.action.js\";\nexport type {\n AddressOrObject,\n VerificationResult,\n VerifyWalletVerificationChallengeParameters,\n VerifyWalletVerificationChallengeResponse,\n} from \"./custom-actions/verify-wallet-verification-challenge.action.js\";\n","import type { Client } from \"viem\";\nimport type { WalletVerificationType } from \"./types/wallet-verification.enum.js\";\nimport type { AddressOrObject } from \"./verify-wallet-verification-challenge.action.js\";\n\n/**\n * Parameters for creating wallet verification challenges.\n */\nexport interface CreateWalletVerificationChallengesParameters {\n /** The wallet address or object containing wallet address and optional verification ID. */\n addressOrObject: AddressOrObject;\n}\n\n/**\n * Represents a wallet verification challenge.\n */\nexport interface WalletVerificationChallenge {\n /** The unique identifier of the challenge. */\n id: string;\n /** The name of the challenge. */\n name: string;\n /** The type of verification required. */\n verificationType: WalletVerificationType;\n /** The challenge parameters specific to the verification type. */\n challenge: Record<string, string>;\n}\n\n/**\n * Response from creating wallet verification challenges.\n */\nexport type CreateWalletVerificationChallengesResponse = WalletVerificationChallenge[];\n\n/**\n * RPC schema for creating wallet verification challenges.\n */\ntype WalletRpcSchema = {\n Method: \"user_createWalletVerificationChallenges\";\n Parameters: [addressOrObject: AddressOrObject];\n ReturnType: CreateWalletVerificationChallengesResponse;\n};\n\n/**\n * Creates a wallet verification challenges action for the given client.\n * @param client - The viem client to use for the request.\n * @returns An object with a createWalletVerificationChallenges method.\n */\nexport function createWalletVerificationChallenges(client: Client) {\n return {\n /**\n * Creates verification challenges for a wallet.\n * @param args - The parameters for creating the challenges.\n * @returns A promise that resolves to an array of wallet verification challenges.\n */\n createWalletVerificationChallenges(\n args: CreateWalletVerificationChallengesParameters,\n ): Promise<CreateWalletVerificationChallengesResponse> {\n return client.request<WalletRpcSchema>({\n method: \"user_createWalletVerificationChallenges\",\n params: [args.addressOrObject],\n });\n },\n };\n}\n","import type { Client } from \"viem\";\nimport type { OTPAlgorithm, WalletVerificationType } from \"./types/wallet-verification.enum.js\";\n\n/**\n * Base interface for wallet verification information.\n */\ntype BaseWalletVerificationInfo = {\n /** The name of the verification method. */\n name: string;\n /** The type of verification method. */\n verificationType: WalletVerificationType;\n};\n\n/**\n * Information for PIN code verification.\n */\nexport interface WalletPincodeVerificationInfo extends BaseWalletVerificationInfo {\n /** The type of verification method. */\n verificationType: WalletVerificationType.PINCODE;\n /** The PIN code to use for verification. */\n pincode: string;\n}\n\n/**\n * Information for One-Time Password (OTP) verification.\n */\nexport interface WalletOTPVerificationInfo extends BaseWalletVerificationInfo {\n /** The type of verification method. */\n verificationType: WalletVerificationType.OTP;\n /** The hash algorithm to use for OTP generation. */\n algorithm?: OTPAlgorithm;\n /** The number of digits in the OTP code. */\n digits?: number;\n /** The time period in seconds for OTP validity. */\n period?: number;\n /** The issuer of the OTP. */\n issuer?: string;\n}\n\n/**\n * Information for secret recovery codes verification.\n */\nexport interface WalletSecretCodesVerificationInfo extends BaseWalletVerificationInfo {\n /** The type of verification method. */\n verificationType: WalletVerificationType.SECRET_CODES;\n}\n\n/**\n * Union type of all possible wallet verification information types.\n */\nexport type WalletVerificationInfo =\n | WalletPincodeVerificationInfo\n | WalletOTPVerificationInfo\n | WalletSecretCodesVerificationInfo;\n\n/**\n * Parameters for creating a wallet verification.\n */\nexport interface CreateWalletVerificationParameters {\n /** The wallet address for which to create the verification. */\n userWalletAddress: string;\n /** The verification information to create. */\n walletVerificationInfo: WalletVerificationInfo;\n}\n\n/**\n * Response from creating a wallet verification.\n */\nexport interface CreateWalletVerificationResponse {\n /** The unique identifier of the verification. */\n id: string;\n /** The name of the verification method. */\n name: string;\n /** The type of verification method. */\n verificationType: WalletVerificationType;\n /** Additional parameters specific to the verification type. */\n parameters: Record<string, string>;\n}\n\n/**\n * RPC schema for creating a wallet verification.\n */\ntype WalletRpcSchema = {\n Method: \"user_createWalletVerification\";\n Parameters: [userWalletAddress: string, walletVerificationInfo: WalletVerificationInfo];\n ReturnType: CreateWalletVerificationResponse[];\n};\n\n/**\n * Creates a wallet verification action for the given client.\n * @param client - The viem client to use for the request.\n * @returns An object with a createWalletVerification method.\n */\nexport function createWalletVerification(client: Client) {\n return {\n /**\n * Creates a new wallet verification.\n * @param args - The parameters for creating the verification.\n * @returns A promise that resolves to an array of created wallet verification responses.\n */\n createWalletVerification(args: CreateWalletVerificationParameters): Promise<CreateWalletVerificationResponse[]> {\n return client.request<WalletRpcSchema>({\n method: \"user_createWalletVerification\",\n params: [args.userWalletAddress, args.walletVerificationInfo],\n });\n },\n };\n}\n","import type { Client } from \"viem\";\n\n/**\n * Information about the wallet to be created.\n */\nexport interface WalletInfo {\n /** The name of the wallet. */\n name: string;\n}\n\n/**\n * Parameters for creating a wallet.\n */\nexport interface CreateWalletParameters {\n /** The unique name of the key vault where the wallet will be created. */\n keyVaultId: string;\n /** Information about the wallet to be created. */\n walletInfo: WalletInfo;\n}\n\n/**\n * Response from creating a wallet.\n */\nexport interface CreateWalletResponse {\n /** The unique identifier of the wallet. */\n id: string;\n /** The name of the wallet. */\n name: string;\n /** The blockchain address of the wallet. */\n address: string;\n /** The HD derivation path used to create the wallet. */\n derivationPath: string;\n}\n\n/**\n * RPC schema for wallet creation.\n */\ntype WalletRpcSchema = {\n Method: \"user_createWallet\";\n Parameters: [keyVaultId: string, walletInfo: WalletInfo];\n ReturnType: CreateWalletResponse[];\n};\n\n/**\n * Creates a wallet action for the given client.\n * @param client - The viem client to use for the request.\n * @returns An object with a createWallet method.\n */\nexport function createWallet(client: Client) {\n return {\n /**\n * Creates a new wallet in the specified key vault.\n * @param args - The parameters for creating a wallet.\n * @returns A promise that resolves to an array of created wallet responses.\n */\n createWallet(args: CreateWalletParameters): Promise<CreateWalletResponse[]> {\n return client.request<WalletRpcSchema>({\n method: \"user_createWallet\",\n params: [args.keyVaultId, args.walletInfo],\n });\n },\n };\n}\n","import type { Client } from \"viem\";\n\n/**\n * Parameters for deleting a wallet verification.\n */\nexport interface DeleteWalletVerificationParameters {\n /** The wallet address for which to delete the verification. */\n userWalletAddress: string;\n /** The unique identifier of the verification to delete. */\n verificationId: string;\n}\n\n/**\n * Response from deleting a wallet verification.\n */\nexport interface DeleteWalletVerificationResponse {\n /** Whether the deletion was successful. */\n success: boolean;\n}\n\n/**\n * RPC schema for deleting a wallet verification.\n */\ntype WalletRpcSchema = {\n Method: \"user_deleteWalletVerification\";\n Parameters: [userWalletAddress: string, verificationId: string];\n ReturnType: DeleteWalletVerificationResponse[];\n};\n\n/**\n * Creates a wallet verification deletion action for the given client.\n * @param client - The viem client to use for the request.\n * @returns An object with a deleteWalletVerification method.\n */\nexport function deleteWalletVerification(client: Client) {\n return {\n /**\n * Deletes a wallet verification.\n * @param args - The parameters for deleting the verification.\n * @returns A promise that resolves to an array of deletion results.\n */\n deleteWalletVerification(args: DeleteWalletVerificationParameters): Promise<DeleteWalletVerificationResponse[]> {\n return client.request<WalletRpcSchema>({\n method: \"user_deleteWalletVerification\",\n params: [args.userWalletAddress, args.verificationId],\n });\n },\n };\n}\n","import type { Client } from \"viem\";\nimport type { WalletVerificationType } from \"./types/wallet-verification.enum.js\";\n\n/**\n * Parameters for getting wallet verifications.\n */\nexport interface GetWalletVerificationsParameters {\n /** The wallet address for which to fetch verifications. */\n userWalletAddress: string;\n}\n\n/**\n * Represents a wallet verification.\n */\nexport interface WalletVerification {\n /** The unique identifier of the verification. */\n id: string;\n /** The name of the verification method. */\n name: string;\n /** The type of verification method. */\n verificationType: WalletVerificationType;\n}\n\n/**\n * Response from getting wallet verifications.\n */\nexport type GetWalletVerificationsResponse = WalletVerification[];\n\n/**\n * RPC schema for getting wallet verifications.\n */\ntype WalletRpcSchema = {\n Method: \"user_walletVerifications\";\n Parameters: [userWalletAddress: string];\n ReturnType: GetWalletVerificationsResponse;\n};\n\n/**\n * Creates a wallet verifications retrieval action for the given client.\n * @param client - The viem client to use for the request.\n * @returns An object with a getWalletVerifications method.\n */\nexport function getWalletVerifications(client: Client) {\n return {\n /**\n * Gets all verifications for a wallet.\n * @param args - The parameters for getting the verifications.\n * @returns A promise that resolves to an array of wallet verifications.\n */\n getWalletVerifications(args: GetWalletVerificationsParameters): Promise<GetWalletVerificationsResponse> {\n return client.request<WalletRpcSchema>({\n method: \"user_walletVerifications\",\n params: [args.userWalletAddress],\n });\n },\n };\n}\n","import type { Client } from \"viem\";\n\n/**\n * Represents either a wallet address string or an object containing wallet address and optional verification ID.\n */\nexport type AddressOrObject =\n | string\n | {\n userWalletAddress: string;\n verificationId?: string;\n };\n\n/**\n * Parameters for verifying a wallet verification challenge.\n */\nexport interface VerifyWalletVerificationChallengeParameters {\n /** The wallet address or object containing wallet address and optional verification ID. */\n addressOrObject: AddressOrObject;\n /** The response to the verification challenge. */\n challengeResponse: string;\n}\n\n/**\n * Result of a wallet verification challenge.\n */\nexport interface VerificationResult {\n /** Whether the verification was successful. */\n verified: boolean;\n}\n\n/**\n * Response from verifying a wallet verification challenge.\n */\nexport type VerifyWalletVerificationChallengeResponse = VerificationResult[];\n\n/**\n * RPC schema for wallet verification challenge verification.\n */\ntype WalletRpcSchema = {\n Method: \"user_verifyWalletVerificationChallenge\";\n Parameters: [addressOrObject: AddressOrObject, challengeResponse: string];\n ReturnType: VerifyWalletVerificationChallengeResponse;\n};\n\n/**\n * Creates a wallet verification challenge verification action for the given client.\n * @param client - The viem client to use for the request.\n * @returns An object with a verifyWalletVerificationChallenge method.\n */\nexport function verifyWalletVerificationChallenge(client: Client) {\n return {\n /**\n * Verifies a wallet verification challenge.\n * @param args - The parameters for verifying the challenge.\n * @returns A promise that resolves to an array of verification results.\n */\n verifyWalletVerificationChallenge(\n args: VerifyWalletVerificationChallengeParameters,\n ): Promise<VerifyWalletVerificationChallengeResponse> {\n return client.request<WalletRpcSchema>({\n method: \"user_verifyWalletVerificationChallenge\",\n params: [args.addressOrObject, args.challengeResponse],\n });\n },\n };\n}\n","/**\n * Types of wallet verification methods supported by the system.\n * Used to identify different verification mechanisms when creating or managing wallet verifications.\n */\nexport enum WalletVerificationType {\n /** PIN code verification method */\n PINCODE = \"PINCODE\",\n /** One-Time Password verification method */\n OTP = \"OTP\",\n /** Secret recovery codes verification method */\n SECRET_CODES = \"SECRET_CODES\",\n}\n\n/**\n * Supported hash algorithms for One-Time Password (OTP) verification.\n * These algorithms determine the cryptographic function used to generate OTP codes.\n */\nexport enum OTPAlgorithm {\n /** SHA-1 hash algorithm */\n SHA1 = \"SHA1\",\n /** SHA-224 hash algorithm */\n SHA224 = \"SHA224\",\n /** SHA-256 hash algorithm */\n SHA256 = \"SHA256\",\n /** SHA-384 hash algorithm */\n SHA384 = \"SHA384\",\n /** SHA-512 hash algorithm */\n SHA512 = \"SHA512\",\n /** SHA3-224 hash algorithm */\n SHA3_224 = \"SHA3-224\",\n /** SHA3-256 hash algorithm */\n SHA3_256 = \"SHA3-256\",\n /** SHA3-384 hash algorithm */\n SHA3_384 = \"SHA3-384\",\n /** SHA3-512 hash algorithm */\n SHA3_512 = \"SHA3-512\",\n}\n"],"mappings":"AAAA,OAAS,iBAAAA,MAAqB,6BAC9B,OAAS,gBAAAC,MAAoB,gCAC7B,OAAS,gCAAAC,EAA8B,mBAAAC,EAAiB,YAAAC,MAAgB,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C7B,OAAOC,CAAwB,EAC/B,OAAOC,CAAwB,EAC/B,OAAOC,CAAkC,EACzC,OAAOC,CAAiC,CAC/C,EAKaC,EAA0BvB,EAAE,OAAO,CAI9C,YAAaC,EAA6B,SAAS,EAInD,OAAQC,EAIR,oBAAqBF,EAAE,IAAI,EAAE,SAAS,CACxC,CAAC,EAwBD,eAAsBwB,GAAWpB,EAA6C,CAC5EC,EAAa,EACb,IAAMC,EAAsCC,EAASgB,EAAyBnB,CAAO,EAarF,OAZeI,EAAmB,CAChC,UAAWE,EAAKJ,EAAiB,OAAQ,CACvC,GAAGA,EAAiB,oBACpB,aAAc,CACZ,GAAGA,GAAkB,qBAAqB,aAC1C,QAASK,EAAcL,GAAkB,qBAAqB,cAAc,QAAS,CACnF,eAAgBA,EAAiB,WACnC,CAAC,CACH,CACF,CAAC,CACH,CAAC,EAEa,WAAW,CAC3B,CAEA,SAASG,EAAS,CAAE,QAAAgB,EAAS,UAAAC,EAAW,OAAAC,CAAO,EAAuE,CAEpH,OADmB,OAAO,OAAOC,CAAM,EAAE,KAAMf,GAAUA,EAAM,GAAG,SAAS,IAAMY,CAAO,GAGtFI,EAAY,CACV,GAAI,OAAOJ,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":["appendHeaders","ensureServer","ApplicationAccessTokenSchema","UrlOrPathSchema","validate","http","createPublicClient","createWalletClient","defineChain","publicActions","chains","z","createWalletVerificationChallenges","client","args","createWalletVerification","client","args","createWallet","client","args","deleteWalletVerification","client","args","getWalletVerifications","client","args","verifyWalletVerificationChallenge","client","args","WalletVerificationType","OTPAlgorithm","ClientOptionsSchema","z","ApplicationAccessTokenSchema","UrlOrPathSchema","getPublicClient","options","ensureServer","validatedOptions","validate","createPublicClient","getChain","http","appendHeaders","getWalletClient","chain","verificationOptions","createWalletClient","publicActions","createWallet","getWalletVerifications","createWalletVerification","deleteWalletVerification","createWalletVerificationChallenges","verifyWalletVerificationChallenge","GetChainIdOptionsSchema","getChainId","chainId","chainName","rpcUrl","chains","defineChain"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@settlemint/sdk-viem",
|
|
3
3
|
"description": "Viem (TypeScript Interface for Ethereum) module for SettleMint SDK",
|
|
4
|
-
"version": "2.3.2-
|
|
4
|
+
"version": "2.3.2-pr8e5bdf14",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
7
7
|
"license": "FSL-1.1-MIT",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@settlemint/sdk-utils": "2.3.2-
|
|
54
|
+
"@settlemint/sdk-utils": "2.3.2-pr8e5bdf14",
|
|
55
55
|
"viem": "^2"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {},
|