Skip to content

Commit d38ba91

Browse files
committed
Fixing build errors
1 parent 2eb9e31 commit d38ba91

File tree

6 files changed

+70
-31
lines changed

6 files changed

+70
-31
lines changed

sdk/src/network-client.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,16 +1497,16 @@ class AleoNetworkClient {
14971497
* const transactionId = await networkClient.submitTransaction(tx);
14981498
*
14991499
* // Wait for the transaction to be confirmed.
1500-
* const transaction = await networkClient.waitForTransactionConfirmation(transactionId);
1500+
* const transaction = await networkClient.waitForTransactionConfirmation({ transactionId });
15011501
*/
15021502
async waitForTransactionConfirmation({
15031503
transactionId,
15041504
checkInterval = 2000,
15051505
timeout = 45000,
15061506
}: {
15071507
transactionId: string,
1508-
checkInterval: number,
1509-
timeout: number,
1508+
checkInterval?: number,
1509+
timeout?: number,
15101510
}): Promise<ConfirmedTransactionJSON> {
15111511
const startTime = Date.now();
15121512

sdk/src/program-manager.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2153,12 +2153,12 @@ class ProgramManager {
21532153
try {
21542154
const recordProvider = <RecordProvider>this.recordProvider;
21552155
return <RecordPlaintext>(
2156-
await recordProvider.findCreditsRecord(
2157-
amount,
2158-
true,
2156+
await recordProvider.findCreditsRecord({
2157+
microcredits: amount,
2158+
unspent: true,
21592159
nonces,
2160-
params,
2161-
)
2160+
searchParameters: params,
2161+
})
21622162
);
21632163
} catch (e: any) {
21642164
logAndThrow(

sdk/tests/network-client.test.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,9 @@ describe("NodeConnection", () => {
342342
it("should return confirmed transaction data for an accepted tx ID", async () => {
343343
const connection = new AleoNetworkClient(host);
344344
const txId = getTxId(connection, "accepted");
345-
const data = await connection.waitForTransactionConfirmation(txId);
345+
const data = await connection.waitForTransactionConfirmation({
346+
transactionId: txId,
347+
});
346348
expect(data.status).to.equal("accepted");
347349
expect(data.type).to.be.a("string");
348350
});
@@ -351,7 +353,9 @@ describe("NodeConnection", () => {
351353
const connection = new AleoNetworkClient(host);
352354
const txId = getTxId(connection, "rejected");
353355
try {
354-
await connection.waitForTransactionConfirmation(txId);
356+
await connection.waitForTransactionConfirmation({
357+
transactionId: txId,
358+
});
355359
throw new Error(
356360
"Expected waitForTransactionConfirmation to throw for rejected tx",
357361
);
@@ -363,7 +367,9 @@ describe("NodeConnection", () => {
363367
it("should throw for a malformed tx ID", async () => {
364368
const connection = new AleoNetworkClient(host);
365369
try {
366-
await connection.waitForTransactionConfirmation(invalidTx);
370+
await connection.waitForTransactionConfirmation({
371+
transactionId: invalidTx,
372+
});
367373
throw new Error(
368374
"Expected waitForTransactionConfirmation to throw",
369375
);
@@ -452,11 +458,11 @@ describe("NodeConnection", () => {
452458
it('Plaintext returned from the API should have expected properties', async () => {
453459
if (connection.network === "testnet") {
454460
// Check a struct variant of a plaintext object.
455-
let plaintext = await connection.getProgramMappingPlaintext(
456-
"credits.aleo",
457-
"committee",
458-
"aleo17m3l8a4hmf3wypzkf5lsausfdwq9etzyujd0vmqh35ledn2sgvqqzqkqal",
459-
);
461+
let plaintext = await connection.getProgramMappingPlaintext({
462+
programId: "credits.aleo",
463+
mappingName: "committee",
464+
key: "aleo17m3l8a4hmf3wypzkf5lsausfdwq9etzyujd0vmqh35ledn2sgvqqzqkqal",
465+
});
460466
expect(plaintext.plaintextType()).equal("struct");
461467

462468
// Ensure the JS object representation matches the wasm representation.
@@ -469,11 +475,11 @@ describe("NodeConnection", () => {
469475
expect(plaintextObject.commission).equal(commission);
470476

471477
// Check a literal variant of a plaintext object.
472-
plaintext = await connection.getProgramMappingPlaintext(
473-
"credits.aleo",
474-
"account",
475-
"aleo17m3l8a4hmf3wypzkf5lsausfdwq9etzyujd0vmqh35ledn2sgvqqzqkqal",
476-
);
478+
plaintext = await connection.getProgramMappingPlaintext({
479+
programId: "credits.aleo",
480+
mappingName: "account",
481+
key: "aleo17m3l8a4hmf3wypzkf5lsausfdwq9etzyujd0vmqh35ledn2sgvqqzqkqal",
482+
});
477483
expect(plaintext.plaintextType()).equal("u64");
478484
expect(plaintext.toObject()).a("bigint");
479485
}

sdk/tests/program-manager.test.ts

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,18 @@ import { IMPORT_1, IMPORT_2, MINT_VERIFYING_KEY, PROGRAM, SPEND_VERIFYING_KEY, S
1212
import { expect } from "chai";
1313

1414
describe('Program Manager', () => {
15-
const programManager = new ProgramManager("https://api.explorer.provable.com/v1");
15+
const programManager = new ProgramManager({
16+
host: "https://api.explorer.provable.com/v1",
17+
});
1618
programManager.setAccount(new Account({privateKey: statePathRecordOwnerPrivateKey}));
1719
const network = programManager.networkClient.network;
1820

1921
describe('Instantiate with AleoNetworkClientOptions', () => {
2022
it('should have the specified headers when instantiated', async () => {
21-
const newProgramManager = new ProgramManager("https://api.explorer.provable.com/v1", undefined, undefined, { headers: {'X-Test-Header': 'programManager'} });
23+
const newProgramManager = new ProgramManager({
24+
host: "https://api.explorer.provable.com/v1",
25+
networkClientOptions: { headers: {'X-Test-Header': 'programManager'} },
26+
});
2227
expect(Object.keys(newProgramManager.networkClient.headers).length).equal(1);
2328
expect(newProgramManager.networkClient.headers['X-Test-Header']).equal('programManager');
2429
expect(newProgramManager.networkClient.headers['X-Aleo-SDK-Version']).undefined;
@@ -39,9 +44,16 @@ describe('Program Manager', () => {
3944

4045
describe('Execute offline', () => {
4146
it.skip('Program manager should execute offline and verify the resulting proof correctly', async () => {
42-
const execution_result = <ExecutionResponse>await programManager.run(helloProgram, "hello", ["5u32", "5u32"], true, undefined, undefined, undefined, undefined, undefined, undefined)
47+
const execution_result = <ExecutionResponse>await programManager.run({
48+
program: helloProgram,
49+
functionName: "hello",
50+
inputs: ["5u32", "5u32"],
51+
proveExecution: true,
52+
});
4353
expect(execution_result.getOutputs()[0]).equal("10u32");
44-
programManager.verifyExecution(execution_result);
54+
programManager.verifyExecution({
55+
executionResponse: execution_result,
56+
});
4557
});
4658
});
4759

@@ -81,8 +93,16 @@ describe('Program Manager', () => {
8193
offlineQuery.addStatePath(commitment, recordStatePath);
8294
const credits = <string>await programManager.networkClient.getProgram("credits.aleo");
8395

84-
const execution_result = <ExecutionResponse>await programManager.run(credits, "transfer_private", [statePathRecord, beaconAddressString, "5u64"], true, undefined, undefined, undefined, undefined, undefined, offlineQuery);
85-
const verified = programManager.verifyExecution(execution_result);
96+
const execution_result = <ExecutionResponse>await programManager.run({
97+
program: credits,
98+
functionName: "transfer_private",
99+
inputs: [statePathRecord, beaconAddressString, "5u64"],
100+
proveExecution: true,
101+
offlineQuery,
102+
});
103+
const verified = programManager.verifyExecution({
104+
executionResponse: execution_result,
105+
});
86106
expect(verified).equal(true);
87107
});
88108
});

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)