Skip to content

Commit 1c452d1

Browse files
committed
Fixing build errors
1 parent 35bb0af commit 1c452d1

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
@@ -1715,16 +1715,16 @@ class AleoNetworkClient {
17151715
* const transactionId = await networkClient.submitTransaction(tx);
17161716
*
17171717
* // Wait for the transaction to be confirmed.
1718-
* const transaction = await networkClient.waitForTransactionConfirmation(transactionId);
1718+
* const transaction = await networkClient.waitForTransactionConfirmation({ transactionId });
17191719
*/
17201720
async waitForTransactionConfirmation({
17211721
transactionId,
17221722
checkInterval = 2000,
17231723
timeout = 45000,
17241724
}: {
17251725
transactionId: string,
1726-
checkInterval: number,
1727-
timeout: number,
1726+
checkInterval?: number,
1727+
timeout?: number,
17281728
}): Promise<ConfirmedTransactionJSON> {
17291729
const startTime = Date.now();
17301730

sdk/src/program-manager.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2681,12 +2681,12 @@ class ProgramManager {
26812681
try {
26822682
const recordProvider = <RecordProvider>this.recordProvider;
26832683
return <RecordPlaintext>(
2684-
await recordProvider.findCreditsRecord(
2685-
amount,
2686-
true,
2684+
await recordProvider.findCreditsRecord({
2685+
microcredits: amount,
2686+
unspent: true,
26872687
nonces,
2688-
params,
2689-
)
2688+
searchParameters: params,
2689+
})
26902690
);
26912691
} catch (e: any) {
26922692
logAndThrow(

sdk/tests/network-client.test.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,9 @@ describe("NodeConnection", () => {
345345
if (connection.network === "mainnet") {
346346
const connection = new AleoNetworkClient(host);
347347
const txId = getTxId(connection, "accepted");
348-
const data = await connection.waitForTransactionConfirmation(txId);
348+
const data = await connection.waitForTransactionConfirmation({
349+
transactionId: txId,
350+
});
349351
expect(data.status).to.equal("accepted");
350352
expect(data.type).to.be.a("string");
351353
}
@@ -356,7 +358,9 @@ describe("NodeConnection", () => {
356358
const txId = getTxId(connection, "rejected");
357359
try {
358360
console.log(txId);
359-
await connection.waitForTransactionConfirmation(txId);
361+
await connection.waitForTransactionConfirmation({
362+
transactionId: txId,
363+
});
360364
throw new Error(
361365
"Expected waitForTransactionConfirmation to throw for rejected tx",
362366
);
@@ -371,7 +375,9 @@ describe("NodeConnection", () => {
371375
it("should throw for a malformed tx ID", async () => {
372376
const connection = new AleoNetworkClient(host);
373377
try {
374-
await connection.waitForTransactionConfirmation(invalidTx);
378+
await connection.waitForTransactionConfirmation({
379+
transactionId: invalidTx,
380+
});
375381
throw new Error(
376382
"Expected waitForTransactionConfirmation to throw",
377383
);
@@ -480,11 +486,11 @@ describe("NodeConnection", () => {
480486
it('Plaintext returned from the API should have expected properties', async () => {
481487
if (connection.network === "testnet") {
482488
// Check a struct variant of a plaintext object.
483-
let plaintext = await connection.getProgramMappingPlaintext(
484-
"credits.aleo",
485-
"committee",
486-
"aleo17m3l8a4hmf3wypzkf5lsausfdwq9etzyujd0vmqh35ledn2sgvqqzqkqal",
487-
);
489+
let plaintext = await connection.getProgramMappingPlaintext({
490+
programId: "credits.aleo",
491+
mappingName: "committee",
492+
key: "aleo17m3l8a4hmf3wypzkf5lsausfdwq9etzyujd0vmqh35ledn2sgvqqzqkqal",
493+
});
488494
expect(plaintext.plaintextType()).equal("struct");
489495

490496
// Ensure the JS object representation matches the wasm representation.
@@ -497,11 +503,11 @@ describe("NodeConnection", () => {
497503
expect(plaintextObject.commission).equal(commission);
498504

499505
// Check a literal variant of a plaintext object.
500-
plaintext = await connection.getProgramMappingPlaintext(
501-
"credits.aleo",
502-
"account",
503-
"aleo17m3l8a4hmf3wypzkf5lsausfdwq9etzyujd0vmqh35ledn2sgvqqzqkqal",
504-
);
506+
plaintext = await connection.getProgramMappingPlaintext({
507+
programId: "credits.aleo",
508+
mappingName: "account",
509+
key: "aleo17m3l8a4hmf3wypzkf5lsausfdwq9etzyujd0vmqh35ledn2sgvqqzqkqal",
510+
});
505511
expect(plaintext.plaintextType()).equal("u64");
506512
expect(plaintext.toObject()).a("bigint");
507513
}

sdk/tests/program-manager.test.ts

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,19 @@ import * as process from "node:process";
3939
describe('Program Manager', async () => {
4040
const keyProvider = new AleoKeyProvider();
4141
keyProvider.useCache(true);
42-
const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider);
42+
const programManager = new ProgramManager({
43+
host: "https://api.explorer.provable.com/v1",
44+
keyProvider,
45+
});
4346
programManager.setAccount(new Account({privateKey: statePathv0RecordOwnerPrivateKey}));
4447
const network = programManager.networkClient.network;
4548

4649
describe('Instantiate with AleoNetworkClientOptions', () => {
4750
it('should have the specified headers when instantiated', async () => {
48-
const newProgramManager = new ProgramManager("https://api.explorer.provable.com/v1", undefined, undefined, { headers: {'X-Test-Header': 'programManager'} });
51+
const newProgramManager = new ProgramManager({
52+
host: "https://api.explorer.provable.com/v1",
53+
networkClientOptions: { headers: {'X-Test-Header': 'programManager'} },
54+
});
4955
expect(Object.keys(newProgramManager.networkClient.headers).length).equal(1);
5056
expect(newProgramManager.networkClient.headers['X-Test-Header']).equal('programManager');
5157
expect(newProgramManager.networkClient.headers['X-Aleo-SDK-Version']).undefined;
@@ -66,9 +72,17 @@ describe('Program Manager', async () => {
6672

6773
describe('Execute offline', () => {
6874
it.skip('Program manager should execute offline and verify the resulting proof correctly', async () => {
69-
const execution_result = <ExecutionResponse>await programManager.run(helloProgram, "hello", ["5u32", "5u32"], true, undefined, undefined, undefined, undefined, undefined, undefined)
75+
const execution_result = <ExecutionResponse>await programManager.run({
76+
program: helloProgram,
77+
functionName: "hello",
78+
inputs: ["5u32", "5u32"],
79+
proveExecution: true,
80+
});
7081
expect(execution_result.getOutputs()[0]).equal("10u32");
71-
programManager.verifyExecution(execution_result, 10_300_000);
82+
programManager.verifyExecution({
83+
executionResponse: execution_result,
84+
blockHeight: 10_300_000,
85+
});
7286
});
7387
});
7488

@@ -111,8 +125,17 @@ describe('Program Manager', async () => {
111125
offlineQuery.addStatePath(commitment, recordStatePathv0);
112126
const credits = <string>await programManager.networkClient.getProgram("credits.aleo");
113127

114-
const execution_result = <ExecutionResponse>await programManager.run(credits, "transfer_private", [statePathRecordv0, beaconAddressString, "5u64"], true, undefined, undefined, undefined, undefined, undefined, offlineQuery);
115-
const verified = programManager.verifyExecution(execution_result, 10_300_000);
128+
const execution_result = <ExecutionResponse>await programManager.run({
129+
program: credits,
130+
functionName: "transfer_private",
131+
inputs: [statePathRecordv0, beaconAddressString, "5u64"],
132+
proveExecution: true,
133+
offlineQuery,
134+
});
135+
const verified = programManager.verifyExecution({
136+
executionResponse: execution_result,
137+
blockHeight: 10_300_000,
138+
});
116139
expect(verified).equal(true);
117140
});
118141
});

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)