Skip to content

Commit

Permalink
Merge pull request #1256 from o1-labs/lightnet-api-upd
Browse files Browse the repository at this point in the history
Lightnet namespace API updates.
  • Loading branch information
shimkiv authored Nov 21, 2023
2 parents 21d774f + 2c3abba commit ac75360
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
40 changes: 39 additions & 1 deletion src/lib/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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<Array<{
publicKey: PublicKey;
privateKey: PrivateKey;
}> | 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) {
Expand Down

0 comments on commit ac75360

Please sign in to comment.