prividium 0.12.1 → 0.14.0
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/cli/commands/doctor/probes/global/reachability.js +11 -1
- package/dist/cli/commands/doctor/report/build.js +1 -0
- package/dist/sdk/chain-core.d.ts +2 -1
- package/dist/sdk/chain-core.js +4 -1
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/prividium-chain.js +1 -0
- package/dist/sdk/types.d.ts +16 -0
- package/dist/sdk/types.js +13 -0
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@ import * as net from 'node:net';
|
|
|
2
2
|
import { requireHttpOk } from '../../clients/http.js';
|
|
3
3
|
import { requireRpcResult } from '../../clients/rpc.js';
|
|
4
4
|
import { DEFAULT_DOCTOR_CALLBACK_PORT } from '../../constants.js';
|
|
5
|
+
import { getRawReason } from '../../utils.js';
|
|
5
6
|
export async function runCallbackPortProbe() {
|
|
6
7
|
const available = await new Promise((resolve) => {
|
|
7
8
|
const server = net.createServer();
|
|
@@ -17,8 +18,17 @@ export async function runUserPanelReachabilityProbe(context) {
|
|
|
17
18
|
await requireHttpOk(new URL('/health', context.targets.userPanelBaseUrl));
|
|
18
19
|
}
|
|
19
20
|
export async function runApiHealthProbe(context) {
|
|
20
|
-
await
|
|
21
|
+
const healthResponse = await fetch(new URL('/health', context.targets.apiBaseUrl));
|
|
22
|
+
if (!healthResponse.ok) {
|
|
23
|
+
const reason = getRawReason(healthResponse.status, await healthResponse.text());
|
|
24
|
+
throw new Error(reason);
|
|
25
|
+
}
|
|
21
26
|
await requireHttpOk(new URL('/readyz', context.targets.apiBaseUrl));
|
|
27
|
+
const body = (await healthResponse.json());
|
|
28
|
+
if (body.version) {
|
|
29
|
+
context.apiVersion = body.version;
|
|
30
|
+
}
|
|
31
|
+
return {};
|
|
22
32
|
}
|
|
23
33
|
export async function runPublicRpcProbe(context) {
|
|
24
34
|
const version = await requireRpcResult(context.targets.apiBaseUrl, { method: 'web3_clientVersion' });
|
|
@@ -21,6 +21,7 @@ function buildSummaryBlock(context) {
|
|
|
21
21
|
values: [
|
|
22
22
|
{ label: 'Status', value: `${failCount} failed, ${skipCount} skipped, ${passCount} passed` },
|
|
23
23
|
{ label: 'API', value: context.targets?.apiBaseUrl ?? context.rawRpcUrl },
|
|
24
|
+
...(context.apiVersion ? [{ label: 'API Version', value: context.apiVersion }] : []),
|
|
24
25
|
{ label: 'User Panel', value: context.targets?.userPanelBaseUrl ?? context.rawUserPanelUrl },
|
|
25
26
|
{ label: 'Time', value: new Date().toISOString() }
|
|
26
27
|
]
|
package/dist/sdk/chain-core.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Chain } from 'viem';
|
|
2
2
|
import { type ZodType, z } from 'zod';
|
|
3
|
-
import { type AuthorizeTransactionParams, type AuthorizeTransactionResponse, type UserProfile } from './types.js';
|
|
3
|
+
import { type AuthorizeTransactionParams, type AuthorizeTransactionResponse, type ContractAbiResponse, type UserProfile } from './types.js';
|
|
4
4
|
export declare function rpcUrl(apiUrl: string): string;
|
|
5
5
|
export declare function walletRpcUrl(apiUrl: string, token: string): string;
|
|
6
6
|
export declare function buildChainObject(config: {
|
|
@@ -17,4 +17,5 @@ export declare function createApiMethods(deps: {
|
|
|
17
17
|
getWalletRpcUrl(): Promise<string>;
|
|
18
18
|
invalidateWalletToken(): Promise<string>;
|
|
19
19
|
authorizeTransaction(params: AuthorizeTransactionParams): Promise<AuthorizeTransactionResponse>;
|
|
20
|
+
fetchContractAbi(contractAddress: string): Promise<ContractAbiResponse>;
|
|
20
21
|
};
|
package/dist/sdk/chain-core.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mainnet } from 'viem/chains';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { authorizeTransactionResponseSchema, profileSchema } from './types.js';
|
|
3
|
+
import { authorizeTransactionResponseSchema, contractAbiResponseSchema, profileSchema } from './types.js';
|
|
4
4
|
export function rpcUrl(apiUrl) {
|
|
5
5
|
return new URL('/rpc', apiUrl).toString();
|
|
6
6
|
}
|
|
@@ -45,6 +45,9 @@ export function createApiMethods(deps) {
|
|
|
45
45
|
calldata: params?.calldata ?? '0x',
|
|
46
46
|
value: params.value?.toString() ?? '0'
|
|
47
47
|
}));
|
|
48
|
+
},
|
|
49
|
+
async fetchContractAbi(contractAddress) {
|
|
50
|
+
return prividiumApiCall(contractAbiResponseSchema, `${prividiumApiBaseUrl}/api/contracts/${contractAddress}/abi`, 'GET');
|
|
48
51
|
}
|
|
49
52
|
};
|
|
50
53
|
}
|
package/dist/sdk/index.d.ts
CHANGED
|
@@ -4,5 +4,5 @@ export { createPrividiumChain } from './prividium-chain.js';
|
|
|
4
4
|
export { FORBIDDEN_ERROR_CODE, UNAUTHORIZED_ERROR_CODE } from './rpc-error-codes.js';
|
|
5
5
|
export { LocalStorage, TokenManager } from './storage.js';
|
|
6
6
|
export { generateRandomState } from './token-utils.js';
|
|
7
|
-
export type { AddNetworkParams, PopupOptions, PrividiumChain, PrividiumConfig, Storage, TokenData, UserProfile, UserRole } from './types.js';
|
|
7
|
+
export type { AddNetworkParams, ContractAbiResponse, PopupOptions, PrividiumChain, PrividiumConfig, Storage, TokenData, UserProfile, UserRole } from './types.js';
|
|
8
8
|
export { AUTH_ERRORS, STORAGE_KEYS } from './types.js';
|
|
@@ -96,6 +96,7 @@ export function createPrividiumChain(config) {
|
|
|
96
96
|
getWalletRpcUrl: apiMethods.getWalletRpcUrl,
|
|
97
97
|
invalidateWalletToken: apiMethods.invalidateWalletToken,
|
|
98
98
|
authorizeTransaction: apiMethods.authorizeTransaction,
|
|
99
|
+
fetchContractAbi: apiMethods.fetchContractAbi,
|
|
99
100
|
async addNetworkToWallet(params) {
|
|
100
101
|
if (typeof window === 'undefined' || !window.ethereum) {
|
|
101
102
|
throw new Error('Wallet not detected. Please install a wallet extension to add network.');
|
package/dist/sdk/types.d.ts
CHANGED
|
@@ -68,6 +68,21 @@ export declare const authorizeTransactionResponseSchema: z.ZodObject<{
|
|
|
68
68
|
activeUntil: z.ZodString;
|
|
69
69
|
}, z.core.$strip>;
|
|
70
70
|
export type AuthorizeTransactionResponse = z.infer<typeof authorizeTransactionResponseSchema>;
|
|
71
|
+
export declare const contractAbiResponseSchema: z.ZodObject<{
|
|
72
|
+
contractAddress: z.ZodString;
|
|
73
|
+
name: z.ZodNullable<z.ZodString>;
|
|
74
|
+
abi: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
75
|
+
functions: z.ZodArray<z.ZodObject<{
|
|
76
|
+
selector: z.ZodString;
|
|
77
|
+
signature: z.ZodString;
|
|
78
|
+
name: z.ZodString;
|
|
79
|
+
accessType: z.ZodEnum<{
|
|
80
|
+
read: "read";
|
|
81
|
+
write: "write";
|
|
82
|
+
}>;
|
|
83
|
+
}, z.core.$strip>>;
|
|
84
|
+
}, z.core.$strip>;
|
|
85
|
+
export type ContractAbiResponse = z.infer<typeof contractAbiResponseSchema>;
|
|
71
86
|
export interface PrividiumChain {
|
|
72
87
|
chain: Chain;
|
|
73
88
|
transport: Transport;
|
|
@@ -81,6 +96,7 @@ export interface PrividiumChain {
|
|
|
81
96
|
invalidateWalletToken(): Promise<string>;
|
|
82
97
|
authorizeTransaction(params: AuthorizeTransactionParams): Promise<AuthorizeTransactionResponse>;
|
|
83
98
|
addNetworkToWallet(params?: AddNetworkParams): Promise<void>;
|
|
99
|
+
fetchContractAbi(contractAddress: Address): Promise<ContractAbiResponse>;
|
|
84
100
|
}
|
|
85
101
|
export declare const tokenDataSchema: z.ZodObject<{
|
|
86
102
|
rawToken: z.ZodString;
|
package/dist/sdk/types.js
CHANGED
|
@@ -14,6 +14,19 @@ export const authorizeTransactionResponseSchema = z.object({
|
|
|
14
14
|
message: z.string(),
|
|
15
15
|
activeUntil: z.string()
|
|
16
16
|
});
|
|
17
|
+
const methodSelectorSchema = z.string().regex(/^0x[0-9a-fA-F]{8}$/, 'Invalid method selector format');
|
|
18
|
+
const addressSchema = z.string().regex(/^0x[0-9a-fA-F]{40}$/i, 'Invalid address format');
|
|
19
|
+
export const contractAbiResponseSchema = z.object({
|
|
20
|
+
contractAddress: addressSchema,
|
|
21
|
+
name: z.string().nullable(),
|
|
22
|
+
abi: z.array(z.record(z.string(), z.unknown())),
|
|
23
|
+
functions: z.array(z.object({
|
|
24
|
+
selector: methodSelectorSchema,
|
|
25
|
+
signature: z.string(),
|
|
26
|
+
name: z.string(),
|
|
27
|
+
accessType: z.enum(['read', 'write'])
|
|
28
|
+
}))
|
|
29
|
+
});
|
|
17
30
|
export const tokenDataSchema = z.object({
|
|
18
31
|
rawToken: z.string(),
|
|
19
32
|
expiresAt: z.coerce.date()
|