@0xobelisk/client 1.2.0-pre.113 → 1.2.0-pre.117
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/browser/obelisk-client.js +6 -6
- package/dist/browser/obelisk-client.js.map +1 -1
- package/dist/browser/obelisk-client.min.js +6 -6
- package/dist/browser/obelisk-client.min.js.map +1 -1
- package/dist/sui/index.d.mts +17 -4
- package/dist/sui/index.js +6 -2
- package/dist/sui/index.js.map +1 -1
- package/dist/sui/index.mjs +6 -2
- package/dist/sui/index.mjs.map +1 -1
- package/dist/sui/types.d.ts +17 -4
- package/package.json +5 -5
- package/src/sui/client.ts +6 -2
- package/src/sui/types.ts +17 -4
package/dist/sui/index.d.mts
CHANGED
|
@@ -22,8 +22,17 @@ interface ClientConfig {
|
|
|
22
22
|
packageId: string;
|
|
23
23
|
/** Contract metadata (required for contract instantiation) */
|
|
24
24
|
metadata: any;
|
|
25
|
-
/**
|
|
26
|
-
|
|
25
|
+
/** Object ID of the Dubhe framework's DappHub shared object. */
|
|
26
|
+
dappHubId?: string;
|
|
27
|
+
/** DApp Storage object ID — required for UserStorage operations (initUserStorage, settleWrites, etc.) */
|
|
28
|
+
dappStorageId?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Published package ID of the Dubhe framework.
|
|
31
|
+
* Required for proxy/session operations (settleWrites, activateSession, etc.).
|
|
32
|
+
* For testnet/mainnet this is inferred automatically from the network default.
|
|
33
|
+
* For localnet/devnet you must supply it explicitly after deploying dubhe locally.
|
|
34
|
+
*/
|
|
35
|
+
frameworkPackageId?: string;
|
|
27
36
|
/** Dubhe metadata (enables GraphQL/ECS features) */
|
|
28
37
|
dubheMetadata?: any;
|
|
29
38
|
/** Authentication credentials */
|
|
@@ -81,8 +90,12 @@ interface DubheClientBundle {
|
|
|
81
90
|
network: NetworkType;
|
|
82
91
|
/** Package ID */
|
|
83
92
|
packageId: string;
|
|
84
|
-
/** Dubhe
|
|
85
|
-
|
|
93
|
+
/** Object ID of the Dubhe framework's DappHub shared object (if provided) */
|
|
94
|
+
dappHubId?: string;
|
|
95
|
+
/** DApp Storage object ID (if provided) */
|
|
96
|
+
dappStorageId?: string;
|
|
97
|
+
/** Published package ID of the Dubhe framework (if provided) */
|
|
98
|
+
frameworkPackageId?: string;
|
|
86
99
|
/** User address */
|
|
87
100
|
address: string;
|
|
88
101
|
/** Configuration options used */
|
package/dist/sui/index.js
CHANGED
|
@@ -23,7 +23,9 @@ function createClient(config) {
|
|
|
23
23
|
secretKey: config.credentials?.secretKey,
|
|
24
24
|
mnemonics: config.credentials?.mnemonics,
|
|
25
25
|
fullnodeUrls: config.endpoints?.fullnodeUrls,
|
|
26
|
-
channelUrl: config.endpoints?.channelUrl
|
|
26
|
+
channelUrl: config.endpoints?.channelUrl,
|
|
27
|
+
dappStorageId: config.dappStorageId,
|
|
28
|
+
frameworkPackageId: config.frameworkPackageId
|
|
27
29
|
});
|
|
28
30
|
const graphqlClient$1 = graphqlClient.createDubheGraphqlClient({
|
|
29
31
|
endpoint: config.endpoints?.graphql || "http://localhost:4000/graphql",
|
|
@@ -53,7 +55,9 @@ function createClient(config) {
|
|
|
53
55
|
metadata: config.metadata,
|
|
54
56
|
network: config.network,
|
|
55
57
|
packageId: config.packageId,
|
|
56
|
-
|
|
58
|
+
dappHubId: config.dappHubId,
|
|
59
|
+
dappStorageId: config.dappStorageId,
|
|
60
|
+
frameworkPackageId: config.frameworkPackageId,
|
|
57
61
|
address,
|
|
58
62
|
options: config.options
|
|
59
63
|
};
|
package/dist/sui/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/sui/client.ts"],"names":[],"mappings":";AAAA,SAAS,aAAa;AACtB,SAAS,gCAAgC;AACzC,SAAS,sBAAsB;AAC/B,SAAS,uBAAuB;AAwCzB,SAAS,aAAa,QAAyC;AAEpE,MAAI,CAAC,OAAO,SAAS;AACnB,UAAM,IAAI,MAAM,mCAAmC;AAA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AA2B,QAAkD;AAC3F,uBAAqB,MAAM;AAC3B,SAAO,aAAa,MAAM;AAC5B","sourcesContent":["import { Dubhe } from '@0xobelisk/sui-client';\nimport { createDubheGraphqlClient } from '@0xobelisk/graphql-client';\nimport { createECSWorld } from '@0xobelisk/ecs';\nimport { DubheGrpcClient } from '@0xobelisk/grpc-client';\nimport type { ClientConfig, DubheClientBundle } from './types';\n\n/**\n * Create a Dubhe client bundle with all necessary instances\n *\n * This factory function creates and initializes:\n * - Dubhe contract client for on-chain interactions\n * - GraphQL client for querying indexed data\n * - gRPC client for high-performance queries\n * - ECS World for entity-component-system queries\n *\n * @param config - Client configuration matching @0xobelisk/react interface\n * @returns DubheClientBundle with all initialized client instances\n *\n * @example\n * ```typescript\n * import { createClient } from '@0xobelisk/client/sui';\n * import metadata from './metadata.json';\n *\n * const client = createClient({\n * network: 'devnet',\n * packageId: '0x123...',\n * metadata,\n * credentials: {\n * secretKey: process.env.PRIVATE_KEY\n * }\n * });\n *\n * // Use the contract client\n * const tx = new Transaction();\n * await client.contract.tx.counter_system.inc({ tx });\n *\n * // Use GraphQL client\n * const data = await client.graphqlClient.query(...);\n *\n * // Use ECS World\n * const entities = client.ecsWorld.getEntities();\n * ```\n */\nexport function createClient(config: ClientConfig): DubheClientBundle {\n // Validate required fields\n if (!config.network) {\n throw new Error('ClientConfig: network is required');\n }\n if (!config.packageId) {\n throw new Error('ClientConfig: packageId is required');\n }\n if (!config.metadata) {\n throw new Error('ClientConfig: metadata is required');\n }\n\n // Initialize Dubhe contract client\n const contract = new Dubhe({\n networkType: config.network,\n packageId: config.packageId,\n metadata: config.metadata,\n secretKey: config.credentials?.secretKey,\n mnemonics: config.credentials?.mnemonics,\n fullnodeUrls: config.endpoints?.fullnodeUrls,\n channelUrl: config.endpoints?.channelUrl,\n dappStorageId: config.dappStorageId,\n frameworkPackageId: config.frameworkPackageId\n });\n\n // Initialize GraphQL client with default localhost endpoint if not provided\n const graphqlClient = createDubheGraphqlClient({\n endpoint: config.endpoints?.graphql || 'http://localhost:4000/graphql',\n subscriptionEndpoint: config.endpoints?.websocket || 'ws://localhost:4000/graphql',\n dubheMetadata: config.dubheMetadata\n });\n\n // Initialize gRPC client with default localhost endpoint if not provided\n const grpcClient = new DubheGrpcClient({\n baseUrl: config.endpoints?.grpc || 'http://localhost:8080'\n });\n\n // Initialize ECS World (depends on GraphQL client)\n const ecsWorld = createECSWorld(graphqlClient, {\n dubheMetadata: config.dubheMetadata,\n queryConfig: {\n enableBatchOptimization: config.options?.enableBatchOptimization ?? true,\n defaultCacheTimeout: config.options?.cacheTimeout ?? 5000\n },\n subscriptionConfig: {\n defaultDebounceMs: config.options?.debounceMs ?? 100,\n reconnectOnError: config.options?.reconnectOnError ?? true\n }\n });\n\n // Get user address from contract\n const address = contract.getAddress();\n\n // Return complete client bundle\n return {\n contract,\n graphqlClient,\n grpcClient,\n ecsWorld,\n metadata: config.metadata,\n network: config.network,\n packageId: config.packageId,\n dappHubId: config.dappHubId,\n dappStorageId: config.dappStorageId,\n frameworkPackageId: config.frameworkPackageId,\n address,\n options: config.options\n };\n}\n\n/**\n * Type guard to check if a value is a valid NetworkType\n */\nexport function isNetworkType(value: string): value is ClientConfig['network'] {\n return ['mainnet', 'testnet', 'devnet', 'localnet'].includes(value);\n}\n\n/**\n * Helper function to validate client configuration\n * Throws descriptive errors for invalid configurations\n */\nexport function validateClientConfig(\n config: Partial<ClientConfig>\n): asserts config is ClientConfig {\n if (!config.network) {\n throw new Error('ClientConfig validation failed: network is required');\n }\n if (!isNetworkType(config.network)) {\n throw new Error(\n `ClientConfig validation failed: invalid network type \"${config.network}\". ` +\n 'Must be one of: mainnet, testnet, devnet, localnet'\n );\n }\n if (!config.packageId) {\n throw new Error('ClientConfig validation failed: packageId is required');\n }\n if (typeof config.packageId !== 'string' || config.packageId.trim() === '') {\n throw new Error('ClientConfig validation failed: packageId must be a non-empty string');\n }\n if (!config.metadata) {\n throw new Error('ClientConfig validation failed: metadata is required');\n }\n}\n\n/**\n * Create client with configuration validation\n * Useful when working with external configuration sources\n *\n * @example\n * ```typescript\n * const config = loadConfigFromFile(); // May be incomplete\n * const client = createClientWithValidation(config); // Throws if invalid\n * ```\n */\nexport function createClientWithValidation(config: Partial<ClientConfig>): DubheClientBundle {\n validateClientConfig(config);\n return createClient(config);\n}\n"]}
|
package/dist/sui/index.mjs
CHANGED
|
@@ -21,7 +21,9 @@ function createClient(config) {
|
|
|
21
21
|
secretKey: config.credentials?.secretKey,
|
|
22
22
|
mnemonics: config.credentials?.mnemonics,
|
|
23
23
|
fullnodeUrls: config.endpoints?.fullnodeUrls,
|
|
24
|
-
channelUrl: config.endpoints?.channelUrl
|
|
24
|
+
channelUrl: config.endpoints?.channelUrl,
|
|
25
|
+
dappStorageId: config.dappStorageId,
|
|
26
|
+
frameworkPackageId: config.frameworkPackageId
|
|
25
27
|
});
|
|
26
28
|
const graphqlClient = createDubheGraphqlClient({
|
|
27
29
|
endpoint: config.endpoints?.graphql || "http://localhost:4000/graphql",
|
|
@@ -51,7 +53,9 @@ function createClient(config) {
|
|
|
51
53
|
metadata: config.metadata,
|
|
52
54
|
network: config.network,
|
|
53
55
|
packageId: config.packageId,
|
|
54
|
-
|
|
56
|
+
dappHubId: config.dappHubId,
|
|
57
|
+
dappStorageId: config.dappStorageId,
|
|
58
|
+
frameworkPackageId: config.frameworkPackageId,
|
|
55
59
|
address,
|
|
56
60
|
options: config.options
|
|
57
61
|
};
|
package/dist/sui/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/sui/client.ts"],"names":[],"mappings":";AAAA,SAAS,aAAa;AACtB,SAAS,gCAAgC;AACzC,SAAS,sBAAsB;AAC/B,SAAS,uBAAuB;AAwCzB,SAAS,aAAa,QAAyC;AAEpE,MAAI,CAAC,OAAO,SAAS;AACnB,UAAM,IAAI,MAAM,mCAAmC;AAAA,EACrD;AACA,MAAI,CAAC,OAAO,WAAW;AACrB,UAAM,IAAI,MAAM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AAC5B","sourcesContent":["import { Dubhe } from '@0xobelisk/sui-client';\nimport { createDubheGraphqlClient } from '@0xobelisk/graphql-client';\nimport { createECSWorld } from '@0xobelisk/ecs';\nimport { DubheGrpcClient } from '@0xobelisk/grpc-client';\nimport type { ClientConfig, DubheClientBundle } from './types';\n\n/**\n * Create a Dubhe client bundle with all necessary instances\n *\n * This factory function creates and initializes:\n * - Dubhe contract client for on-chain interactions\n * - GraphQL client for querying indexed data\n * - gRPC client for high-performance queries\n * - ECS World for entity-component-system queries\n *\n * @param config - Client configuration matching @0xobelisk/react interface\n * @returns DubheClientBundle with all initialized client instances\n *\n * @example\n * ```typescript\n * import { createClient } from '@0xobelisk/client/sui';\n * import metadata from './metadata.json';\n *\n * const client = createClient({\n * network: 'devnet',\n * packageId: '0x123...',\n * metadata,\n * credentials: {\n * secretKey: process.env.PRIVATE_KEY\n * }\n * });\n *\n * // Use the contract client\n * const tx = new Transaction();\n * await client.contract.tx.counter_system.inc({ tx });\n *\n * // Use GraphQL client\n * const data = await client.graphqlClient.query(...);\n *\n * // Use ECS World\n * const entities = client.ecsWorld.getEntities();\n * ```\n */\nexport function createClient(config: ClientConfig): DubheClientBundle {\n // Validate required fields\n if (!config.network) {\n throw new Error('ClientConfig: network is required');\n }\n if (!config.packageId) {\n throw new Error('ClientConfig: packageId is required');\n }\n if (!config.metadata) {\n throw new Error('ClientConfig: metadata is required');\n }\n\n // Initialize Dubhe contract client\n const contract = new Dubhe({\n networkType: config.network,\n packageId: config.packageId,\n metadata: config.metadata,\n secretKey: config.credentials?.secretKey,\n mnemonics: config.credentials?.mnemonics,\n fullnodeUrls: config.endpoints?.fullnodeUrls,\n channelUrl: config.endpoints?.channelUrl,\n dappStorageId: config.dappStorageId,\n frameworkPackageId: config.frameworkPackageId\n });\n\n // Initialize GraphQL client with default localhost endpoint if not provided\n const graphqlClient = createDubheGraphqlClient({\n endpoint: config.endpoints?.graphql || 'http://localhost:4000/graphql',\n subscriptionEndpoint: config.endpoints?.websocket || 'ws://localhost:4000/graphql',\n dubheMetadata: config.dubheMetadata\n });\n\n // Initialize gRPC client with default localhost endpoint if not provided\n const grpcClient = new DubheGrpcClient({\n baseUrl: config.endpoints?.grpc || 'http://localhost:8080'\n });\n\n // Initialize ECS World (depends on GraphQL client)\n const ecsWorld = createECSWorld(graphqlClient, {\n dubheMetadata: config.dubheMetadata,\n queryConfig: {\n enableBatchOptimization: config.options?.enableBatchOptimization ?? true,\n defaultCacheTimeout: config.options?.cacheTimeout ?? 5000\n },\n subscriptionConfig: {\n defaultDebounceMs: config.options?.debounceMs ?? 100,\n reconnectOnError: config.options?.reconnectOnError ?? true\n }\n });\n\n // Get user address from contract\n const address = contract.getAddress();\n\n // Return complete client bundle\n return {\n contract,\n graphqlClient,\n grpcClient,\n ecsWorld,\n metadata: config.metadata,\n network: config.network,\n packageId: config.packageId,\n dappHubId: config.dappHubId,\n dappStorageId: config.dappStorageId,\n frameworkPackageId: config.frameworkPackageId,\n address,\n options: config.options\n };\n}\n\n/**\n * Type guard to check if a value is a valid NetworkType\n */\nexport function isNetworkType(value: string): value is ClientConfig['network'] {\n return ['mainnet', 'testnet', 'devnet', 'localnet'].includes(value);\n}\n\n/**\n * Helper function to validate client configuration\n * Throws descriptive errors for invalid configurations\n */\nexport function validateClientConfig(\n config: Partial<ClientConfig>\n): asserts config is ClientConfig {\n if (!config.network) {\n throw new Error('ClientConfig validation failed: network is required');\n }\n if (!isNetworkType(config.network)) {\n throw new Error(\n `ClientConfig validation failed: invalid network type \"${config.network}\". ` +\n 'Must be one of: mainnet, testnet, devnet, localnet'\n );\n }\n if (!config.packageId) {\n throw new Error('ClientConfig validation failed: packageId is required');\n }\n if (typeof config.packageId !== 'string' || config.packageId.trim() === '') {\n throw new Error('ClientConfig validation failed: packageId must be a non-empty string');\n }\n if (!config.metadata) {\n throw new Error('ClientConfig validation failed: metadata is required');\n }\n}\n\n/**\n * Create client with configuration validation\n * Useful when working with external configuration sources\n *\n * @example\n * ```typescript\n * const config = loadConfigFromFile(); // May be incomplete\n * const client = createClientWithValidation(config); // Throws if invalid\n * ```\n */\nexport function createClientWithValidation(config: Partial<ClientConfig>): DubheClientBundle {\n validateClientConfig(config);\n return createClient(config);\n}\n"]}
|
package/dist/sui/types.d.ts
CHANGED
|
@@ -17,8 +17,17 @@ export interface ClientConfig {
|
|
|
17
17
|
packageId: string;
|
|
18
18
|
/** Contract metadata (required for contract instantiation) */
|
|
19
19
|
metadata: any;
|
|
20
|
-
/**
|
|
21
|
-
|
|
20
|
+
/** Object ID of the Dubhe framework's DappHub shared object. */
|
|
21
|
+
dappHubId?: string;
|
|
22
|
+
/** DApp Storage object ID — required for UserStorage operations (initUserStorage, settleWrites, etc.) */
|
|
23
|
+
dappStorageId?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Published package ID of the Dubhe framework.
|
|
26
|
+
* Required for proxy/session operations (settleWrites, activateSession, etc.).
|
|
27
|
+
* For testnet/mainnet this is inferred automatically from the network default.
|
|
28
|
+
* For localnet/devnet you must supply it explicitly after deploying dubhe locally.
|
|
29
|
+
*/
|
|
30
|
+
frameworkPackageId?: string;
|
|
22
31
|
/** Dubhe metadata (enables GraphQL/ECS features) */
|
|
23
32
|
dubheMetadata?: any;
|
|
24
33
|
/** Authentication credentials */
|
|
@@ -76,8 +85,12 @@ export interface DubheClientBundle {
|
|
|
76
85
|
network: NetworkType;
|
|
77
86
|
/** Package ID */
|
|
78
87
|
packageId: string;
|
|
79
|
-
/** Dubhe
|
|
80
|
-
|
|
88
|
+
/** Object ID of the Dubhe framework's DappHub shared object (if provided) */
|
|
89
|
+
dappHubId?: string;
|
|
90
|
+
/** DApp Storage object ID (if provided) */
|
|
91
|
+
dappStorageId?: string;
|
|
92
|
+
/** Published package ID of the Dubhe framework (if provided) */
|
|
93
|
+
frameworkPackageId?: string;
|
|
81
94
|
/** User address */
|
|
82
95
|
address: string;
|
|
83
96
|
/** Configuration options used */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xobelisk/client",
|
|
3
|
-
"version": "1.2.0-pre.
|
|
3
|
+
"version": "1.2.0-pre.117",
|
|
4
4
|
"description": "Unified client creation layer for Dubhe framework with multi-chain support",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dubhe",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"dotenv": "^17.2.3",
|
|
35
|
-
"@0xobelisk/ecs": "1.2.0-pre.
|
|
36
|
-
"@0xobelisk/graphql-client": "1.2.0-pre.
|
|
37
|
-
"@0xobelisk/sui-client": "1.2.0-pre.
|
|
38
|
-
"@0xobelisk/grpc-client": "1.2.0-pre.
|
|
35
|
+
"@0xobelisk/ecs": "1.2.0-pre.117",
|
|
36
|
+
"@0xobelisk/graphql-client": "1.2.0-pre.117",
|
|
37
|
+
"@0xobelisk/sui-client": "1.2.0-pre.117",
|
|
38
|
+
"@0xobelisk/grpc-client": "1.2.0-pre.117"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/node": "^20.8.7",
|
package/src/sui/client.ts
CHANGED
|
@@ -61,7 +61,9 @@ export function createClient(config: ClientConfig): DubheClientBundle {
|
|
|
61
61
|
secretKey: config.credentials?.secretKey,
|
|
62
62
|
mnemonics: config.credentials?.mnemonics,
|
|
63
63
|
fullnodeUrls: config.endpoints?.fullnodeUrls,
|
|
64
|
-
channelUrl: config.endpoints?.channelUrl
|
|
64
|
+
channelUrl: config.endpoints?.channelUrl,
|
|
65
|
+
dappStorageId: config.dappStorageId,
|
|
66
|
+
frameworkPackageId: config.frameworkPackageId
|
|
65
67
|
});
|
|
66
68
|
|
|
67
69
|
// Initialize GraphQL client with default localhost endpoint if not provided
|
|
@@ -101,7 +103,9 @@ export function createClient(config: ClientConfig): DubheClientBundle {
|
|
|
101
103
|
metadata: config.metadata,
|
|
102
104
|
network: config.network,
|
|
103
105
|
packageId: config.packageId,
|
|
104
|
-
|
|
106
|
+
dappHubId: config.dappHubId,
|
|
107
|
+
dappStorageId: config.dappStorageId,
|
|
108
|
+
frameworkPackageId: config.frameworkPackageId,
|
|
105
109
|
address,
|
|
106
110
|
options: config.options
|
|
107
111
|
};
|
package/src/sui/types.ts
CHANGED
|
@@ -19,8 +19,17 @@ export interface ClientConfig {
|
|
|
19
19
|
packageId: string;
|
|
20
20
|
/** Contract metadata (required for contract instantiation) */
|
|
21
21
|
metadata: any;
|
|
22
|
-
/**
|
|
23
|
-
|
|
22
|
+
/** Object ID of the Dubhe framework's DappHub shared object. */
|
|
23
|
+
dappHubId?: string;
|
|
24
|
+
/** DApp Storage object ID — required for UserStorage operations (initUserStorage, settleWrites, etc.) */
|
|
25
|
+
dappStorageId?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Published package ID of the Dubhe framework.
|
|
28
|
+
* Required for proxy/session operations (settleWrites, activateSession, etc.).
|
|
29
|
+
* For testnet/mainnet this is inferred automatically from the network default.
|
|
30
|
+
* For localnet/devnet you must supply it explicitly after deploying dubhe locally.
|
|
31
|
+
*/
|
|
32
|
+
frameworkPackageId?: string;
|
|
24
33
|
/** Dubhe metadata (enables GraphQL/ECS features) */
|
|
25
34
|
dubheMetadata?: any;
|
|
26
35
|
/** Authentication credentials */
|
|
@@ -80,8 +89,12 @@ export interface DubheClientBundle {
|
|
|
80
89
|
network: NetworkType;
|
|
81
90
|
/** Package ID */
|
|
82
91
|
packageId: string;
|
|
83
|
-
/** Dubhe
|
|
84
|
-
|
|
92
|
+
/** Object ID of the Dubhe framework's DappHub shared object (if provided) */
|
|
93
|
+
dappHubId?: string;
|
|
94
|
+
/** DApp Storage object ID (if provided) */
|
|
95
|
+
dappStorageId?: string;
|
|
96
|
+
/** Published package ID of the Dubhe framework (if provided) */
|
|
97
|
+
frameworkPackageId?: string;
|
|
85
98
|
/** User address */
|
|
86
99
|
address: string;
|
|
87
100
|
/** Configuration options used */
|