Skip to content

Commit 4700241

Browse files
committed
Fixing build errors
1 parent 2fcf3db commit 4700241

File tree

6 files changed

+74
-31
lines changed

6 files changed

+74
-31
lines changed

sdk/src/network-client.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,16 +1696,16 @@ class AleoNetworkClient {
16961696
* const transactionId = await networkClient.submitTransaction(tx);
16971697
*
16981698
* // Wait for the transaction to be confirmed.
1699-
* const transaction = await networkClient.waitForTransactionConfirmation(transactionId);
1699+
* const transaction = await networkClient.waitForTransactionConfirmation({ transactionId });
17001700
*/
17011701
async waitForTransactionConfirmation({
17021702
transactionId,
17031703
checkInterval = 2000,
17041704
timeout = 45000,
17051705
}: {
17061706
transactionId: string,
1707-
checkInterval: number,
1708-
timeout: number,
1707+
checkInterval?: number,
1708+
timeout?: number,
17091709
}): Promise<ConfirmedTransactionJSON> {
17101710
const startTime = Date.now();
17111711

sdk/src/program-manager.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2660,12 +2660,12 @@ class ProgramManager {
26602660
try {
26612661
const recordProvider = <RecordProvider>this.recordProvider;
26622662
return <RecordPlaintext>(
2663-
await recordProvider.findCreditsRecord(
2664-
amount,
2665-
true,
2663+
await recordProvider.findCreditsRecord({
2664+
microcredits: amount,
2665+
unspent: true,
26662666
nonces,
2667-
params,
2668-
)
2667+
searchParameters: params,
2668+
})
26692669
);
26702670
} catch (e: any) {
26712671
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: 30 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,18 @@ 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, 9_000_000);
82+
83+
programManager.verifyExecution({
84+
executionResponse: execution_result,
85+
blockHeight: 9_000_000,
86+
});
7287
});
7388
});
7489

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

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, 9_000_000);
129+
const execution_result = <ExecutionResponse>await programManager.run({
130+
program: credits,
131+
functionName: "transfer_private",
132+
inputs: [statePathRecordv0, beaconAddressString, "5u64"],
133+
proveExecution: true,
134+
offlineQuery,
135+
});
136+
const verified = programManager.verifyExecution({
137+
executionResponse: execution_result,
138+
blockHeight: 9_000_000,
139+
});
116140
expect(verified).equal(true);
117141
});
118142
});

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)