Skip to content

Commit 4ae3d62

Browse files
committed
refactored inputs as params object
1 parent 48a1aa1 commit 4ae3d62

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

sdk/src/network-client.ts

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,21 @@ interface AleoNetworkClientOptions {
2121
headers?: { [key: string]: string };
2222
}
2323

24+
/**
25+
* Options for executing a fee authorization.
26+
*
27+
* @property provingRequest {ProvingRequest | string} The proving request being submitted to the network.
28+
* @property url {string} The URL of the delegated proving service.
29+
* @property apiKey {string} The API key to use for authentication. NOTE: This is not currently used but will be in a future release.
30+
* @property delegatedProvingJWT {string} JWT token for authentication. NOTE: This will be deprecated in favor of apiKey in a future release.
31+
*/
32+
interface DelegatedProvingParams {
33+
provingRequest: ProvingRequest | string;
34+
url?: string;
35+
apiKey?: string;
36+
delegatedProvingJWT?: string;
37+
}
38+
2439
/**
2540
* Client library that encapsulates REST calls to publicly exposed endpoints of Aleo nodes. The methods provided in this
2641
* allow users to query public information from the Aleo blockchain and submit transactions to the network.
@@ -1603,16 +1618,11 @@ class AleoNetworkClient {
16031618
* @param {string} delegatedProvingJWT - (Optional) JWT token for authentication. This will be deprecated in favor of apiKey in the future.
16041619
* @returns {Promise<ProvingResponse>} The ProvingResponse containing the transaction result and the result of the broadcast if the `broadcast` flag was set to `true`.
16051620
*/
1606-
async submitProvingRequest(
1607-
provingRequest: ProvingRequest | string,
1608-
url?: string,
1609-
apiKey?: string,
1610-
delegatedProvingJWT?: string
1611-
): Promise<ProvingResponse> {
1612-
const proverUri = url ?? this.host;
1613-
const provingRequestString = provingRequest instanceof ProvingRequest
1614-
? provingRequest.toString()
1615-
: provingRequest;
1621+
async submitProvingRequest(options: DelegatedProvingParams): Promise<ProvingResponse> {
1622+
const proverUri = options.url ?? this.host;
1623+
const provingRequestString = options.provingRequest instanceof ProvingRequest
1624+
? options.provingRequest.toString()
1625+
: options.provingRequest;
16161626

16171627
// Build headers with proper auth fallback
16181628
const headers: Record<string, string> = {
@@ -1622,10 +1632,10 @@ class AleoNetworkClient {
16221632
};
16231633

16241634
// Add auth header based on what's available
1625-
if (delegatedProvingJWT) {
1626-
headers["Authorization"] = `Bearer ${delegatedProvingJWT}`;
1627-
} else if (apiKey) {
1628-
headers["X-API-Key"] = apiKey;
1635+
if (options.delegatedProvingJWT) {
1636+
headers["Authorization"] = `Bearer ${options.delegatedProvingJWT}`;
1637+
} else if (options.apiKey) {
1638+
headers["X-API-Key"] = options.apiKey;
16291639
}
16301640

16311641
try {

0 commit comments

Comments
 (0)