diff --git a/CHANGELOG.md b/CHANGELOG.md index dcfed4064..3dd5d7677 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Changed +- `Lightnet` namespace API updates with added `listAcquiredKeyPairs()` method https://github.com/o1-labs/o1js/pull/1256 - Expose raw provable methods of a `ZkProgram` on `zkProgram.rawMethods` https://github.com/o1-labs/o1js/pull/1241 - Reduce number of constraints needed by `rotate()`, `leftShift()` and, `rightShift()` gadgets https://github.com/o1-labs/o1js/pull/1201 @@ -56,7 +57,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Added -- `Lightnet` namespace to interact with the account manager provided by the [lightnet Mina network](https://hub.docker.com/r/o1labs/mina-local-network). https://github.com/o1-labs/o1js/pull/1167 +- `Lightnet` namespace to interact with the account manager provided by the [lightnet Mina network](https://hub.docker.com/r/o1labs/mina-local-network) https://github.com/o1-labs/o1js/pull/1167 - Internal support for several custom gates (range check, bitwise operations, foreign field operations) and lookup tables https://github.com/o1-labs/o1js/pull/1176 - `Gadgets.rangeCheck64()`, new provable method to do efficient 64-bit range checks using lookup tables https://github.com/o1-labs/o1js/pull/1181 - `Gadgets.rotate()`, new provable method to support bitwise rotation for native field elements. https://github.com/o1-labs/o1js/pull/1182 diff --git a/src/lib/fetch.ts b/src/lib/fetch.ts index 768410c1b..6872b1156 100644 --- a/src/lib/fetch.ts +++ b/src/lib/fetch.ts @@ -1019,7 +1019,7 @@ namespace Lightnet { * If an error is returned by the specified endpoint, an error is thrown. Otherwise, * the data is returned. * - * @param options.isRegularAccount Whether to acquire regular or zkApp account (one with already configured verification key) + * @param options.isRegularAccount Whether to acquire key pair of regular or zkApp account (one with already configured verification key) * @param options.lightnetAccountManagerEndpoint Account manager endpoint to fetch from * @returns Key pair */ @@ -1096,6 +1096,44 @@ namespace Lightnet { return null; } + + /** + * Gets previously acquired key pairs list. + * + * @param options.lightnetAccountManagerEndpoint Account manager endpoint to fetch from + * @returns Key pairs list or null if the request failed + */ + export async function listAcquiredKeyPairs(options: { + lightnetAccountManagerEndpoint?: string; + }): Promise | null> { + const { + lightnetAccountManagerEndpoint = networkConfig.lightnetAccountManagerEndpoint, + } = options; + const response = await fetch( + `${lightnetAccountManagerEndpoint}/list-acquired-accounts`, + { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + }, + } + ); + + if (response.ok) { + const data = await response.json(); + if (data) { + return data.map((account: any) => ({ + publicKey: PublicKey.fromBase58(account.pk), + privateKey: PrivateKey.fromBase58(account.sk), + })); + } + } + + return null; + } } function updateActionState(actions: string[][], actionState: Field) {