Skip to content

Commit 6badc71

Browse files
committed
Fixing build errors
1 parent c57ce30 commit 6badc71

File tree

6 files changed

+73
-31
lines changed

6 files changed

+73
-31
lines changed

sdk/src/network-client.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,16 +1643,16 @@ class AleoNetworkClient {
16431643
* const transactionId = await networkClient.submitTransaction(tx);
16441644
*
16451645
* // Wait for the transaction to be confirmed.
1646-
* const transaction = await networkClient.waitForTransactionConfirmation(transactionId);
1646+
* const transaction = await networkClient.waitForTransactionConfirmation({ transactionId });
16471647
*/
16481648
async waitForTransactionConfirmation({
16491649
transactionId,
16501650
checkInterval = 2000,
16511651
timeout = 45000,
16521652
}: {
16531653
transactionId: string,
1654-
checkInterval: number,
1655-
timeout: number,
1654+
checkInterval?: number,
1655+
timeout?: number,
16561656
}): Promise<ConfirmedTransactionJSON> {
16571657
const startTime = Date.now();
16581658

sdk/src/program-manager.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2611,12 +2611,12 @@ class ProgramManager {
26112611
try {
26122612
const recordProvider = <RecordProvider>this.recordProvider;
26132613
return <RecordPlaintext>(
2614-
await recordProvider.findCreditsRecord(
2615-
amount,
2616-
true,
2614+
await recordProvider.findCreditsRecord({
2615+
microcredits: amount,
2616+
unspent: true,
26172617
nonces,
2618-
params,
2619-
)
2618+
searchParameters: params,
2619+
})
26202620
);
26212621
} catch (e: any) {
26222622
logAndThrow(

sdk/tests/network-client.test.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,9 @@ describe("NodeConnection", () => {
348348
it("should return confirmed transaction data for an accepted tx ID", async () => {
349349
const connection = new AleoNetworkClient(host);
350350
const txId = getTxId(connection, "accepted");
351-
const data = await connection.waitForTransactionConfirmation(txId);
351+
const data = await connection.waitForTransactionConfirmation({
352+
transactionId: txId,
353+
});
352354
expect(data.status).to.equal("accepted");
353355
expect(data.type).to.be.a("string");
354356
});
@@ -357,7 +359,9 @@ describe("NodeConnection", () => {
357359
const connection = new AleoNetworkClient(host);
358360
const txId = getTxId(connection, "rejected");
359361
try {
360-
await connection.waitForTransactionConfirmation(txId);
362+
await connection.waitForTransactionConfirmation({
363+
transactionId: txId,
364+
});
361365
throw new Error(
362366
"Expected waitForTransactionConfirmation to throw for rejected tx",
363367
);
@@ -369,7 +373,9 @@ describe("NodeConnection", () => {
369373
it("should throw for a malformed tx ID", async () => {
370374
const connection = new AleoNetworkClient(host);
371375
try {
372-
await connection.waitForTransactionConfirmation(invalidTx);
376+
await connection.waitForTransactionConfirmation({
377+
transactionId: invalidTx,
378+
});
373379
throw new Error(
374380
"Expected waitForTransactionConfirmation to throw",
375381
);
@@ -476,11 +482,11 @@ describe("NodeConnection", () => {
476482
it('Plaintext returned from the API should have expected properties', async () => {
477483
if (connection.network === "testnet") {
478484
// Check a struct variant of a plaintext object.
479-
let plaintext = await connection.getProgramMappingPlaintext(
480-
"credits.aleo",
481-
"committee",
482-
"aleo17m3l8a4hmf3wypzkf5lsausfdwq9etzyujd0vmqh35ledn2sgvqqzqkqal",
483-
);
485+
let plaintext = await connection.getProgramMappingPlaintext({
486+
programId: "credits.aleo",
487+
mappingName: "committee",
488+
key: "aleo17m3l8a4hmf3wypzkf5lsausfdwq9etzyujd0vmqh35ledn2sgvqqzqkqal",
489+
});
484490
expect(plaintext.plaintextType()).equal("struct");
485491

486492
// Ensure the JS object representation matches the wasm representation.
@@ -493,11 +499,11 @@ describe("NodeConnection", () => {
493499
expect(plaintextObject.commission).equal(commission);
494500

495501
// Check a literal variant of a plaintext object.
496-
plaintext = await connection.getProgramMappingPlaintext(
497-
"credits.aleo",
498-
"account",
499-
"aleo17m3l8a4hmf3wypzkf5lsausfdwq9etzyujd0vmqh35ledn2sgvqqzqkqal",
500-
);
502+
plaintext = await connection.getProgramMappingPlaintext({
503+
programId: "credits.aleo",
504+
mappingName: "account",
505+
key: "aleo17m3l8a4hmf3wypzkf5lsausfdwq9etzyujd0vmqh35ledn2sgvqqzqkqal",
506+
});
501507
expect(plaintext.plaintextType()).equal("u64");
502508
expect(plaintext.toObject()).a("bigint");
503509
}

sdk/tests/program-manager.test.ts

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,18 @@ import {
3434
import * as process from "node:process";
3535

3636
describe('Program Manager', () => {
37-
const programManager = new ProgramManager("https://api.explorer.provable.com/v1");
37+
const programManager = new ProgramManager({
38+
host: "https://api.explorer.provable.com/v1",
39+
});
3840
programManager.setAccount(new Account({privateKey: statePathRecordOwnerPrivateKey}));
3941
const network = programManager.networkClient.network;
4042

4143
describe('Instantiate with AleoNetworkClientOptions', () => {
4244
it('should have the specified headers when instantiated', async () => {
43-
const newProgramManager = new ProgramManager("https://api.explorer.provable.com/v1", undefined, undefined, { headers: {'X-Test-Header': 'programManager'} });
45+
const newProgramManager = new ProgramManager({
46+
host: "https://api.explorer.provable.com/v1",
47+
networkClientOptions: { headers: {'X-Test-Header': 'programManager'} },
48+
});
4449
expect(Object.keys(newProgramManager.networkClient.headers).length).equal(1);
4550
expect(newProgramManager.networkClient.headers['X-Test-Header']).equal('programManager');
4651
expect(newProgramManager.networkClient.headers['X-Aleo-SDK-Version']).undefined;
@@ -61,9 +66,18 @@ describe('Program Manager', () => {
6166

6267
describe('Execute offline', () => {
6368
it.skip('Program manager should execute offline and verify the resulting proof correctly', async () => {
64-
const execution_result = <ExecutionResponse>await programManager.run(helloProgram, "hello", ["5u32", "5u32"], true, undefined, undefined, undefined, undefined, undefined, undefined)
69+
const execution_result = <ExecutionResponse>await programManager.run({
70+
program: helloProgram,
71+
functionName: "hello",
72+
inputs: ["5u32", "5u32"],
73+
proveExecution: true,
74+
});
6575
expect(execution_result.getOutputs()[0]).equal("10u32");
66-
programManager.verifyExecution(execution_result, 9_000_000);
76+
77+
programManager.verifyExecution({
78+
executionResponse: execution_result,
79+
blockHeight: 9_000_000,
80+
});
6781
});
6882
});
6983

@@ -106,8 +120,17 @@ describe('Program Manager', () => {
106120
offlineQuery.addStatePath(commitment, recordStatePath);
107121
const credits = <string>await programManager.networkClient.getProgram("credits.aleo");
108122

109-
const execution_result = <ExecutionResponse>await programManager.run(credits, "transfer_private", [statePathRecord, beaconAddressString, "5u64"], true, undefined, undefined, undefined, undefined, undefined, offlineQuery);
110-
const verified = programManager.verifyExecution(execution_result, 9_000_000);
123+
const execution_result = <ExecutionResponse>await programManager.run({
124+
program: credits,
125+
functionName: "transfer_private",
126+
inputs: [statePathRecord, beaconAddressString, "5u64"],
127+
proveExecution: true,
128+
offlineQuery,
129+
});
130+
const verified = programManager.verifyExecution({
131+
executionResponse: execution_result,
132+
blockHeight: 9_000_000,
133+
});
111134
expect(verified).equal(true);
112135
});
113136
});

sdk/tests/record-provider.integration.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ describe('RecordProvider', () => {
1818
try {
1919
// Find two records with findCreditsRecords
2020
const nonces: string[] = [];
21-
const records = await recordProvider.findCreditsRecords([100, 200], true, []);
21+
const records = await recordProvider.findCreditsRecords({
22+
microcredits: [100, 200],
23+
unspent: true,
24+
nonces: [],
25+
});
2226
if (Array.isArray(records)) {
2327
expect(records.length).equal(2);
2428
records.forEach((record) => {
@@ -29,7 +33,11 @@ describe('RecordProvider', () => {
2933
}
3034

3135
// Get another two records with findCreditsRecords and ensure they are unique
32-
const records2 = await recordProvider.findCreditsRecords([100, 200], true, nonces);
36+
const records2 = await recordProvider.findCreditsRecords({
37+
microcredits: [100, 200],
38+
unspent: true,
39+
nonces: nonces,
40+
});
3341
if (Array.isArray(records2)) {
3442
expect(records2.length).equal(2);
3543
records2.forEach((record) => {

sdk/tests/record-provider.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@ describe.skip('RecordProvider', () => {
1515

1616
describe('Record provider', () => {
1717
it('should not find records where there are none', async () => {
18-
const params = new BlockHeightSearch(0, 100);
19-
const records = await recordProvider.findCreditsRecords([100, 200], true, [], params);
18+
const params = new BlockHeightSearch({ startHeight: 0, endHeight: 100 });
19+
const records = await recordProvider.findCreditsRecords({
20+
microcredits: [100, 200],
21+
unspent: true,
22+
nonces: [],
23+
searchParameters: params,
24+
});
2025
expect(<object>records).equal([]);
2126
});
2227
});

0 commit comments

Comments
 (0)