Skip to content

Conversation

alexpitsikoulis
Copy link
Collaborator

…scanner implementation of said interface

Motivation

(Write your motivation here)

Test Plan

(Write your test plan here)

Related PRs

(Link your related PRs here)

Copy link
Member

@iamalwaysuncomfortable iamalwaysuncomfortable left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good core impl, but several comments on the interface, code organization, and some method naming.

Copy link
Member

@iamalwaysuncomfortable iamalwaysuncomfortable left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking better, the following things should be added

  • Can we add doc comments to the interface types. People will be confused about this initially and docs will help.
  • Can you add tests of the default implementation against stubs?
  • A few more nits?

*
* const records = await recordScanner.findRecords({ filter, responseFilter });
*/
class RecordScanner implements RecordProvider {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before it's marked ready this should pass tests using stubs for the test data.

@alexpitsikoulis alexpitsikoulis force-pushed the feat/upgraded-record-provider-interface branch from dba689e to 7f88144 Compare August 20, 2025 17:50
@alexpitsikoulis alexpitsikoulis force-pushed the feat/upgraded-record-provider-interface branch from 7f88144 to cdd92fa Compare August 20, 2025 18:27
@alexpitsikoulis alexpitsikoulis force-pushed the feat/upgraded-record-provider-interface branch from b78fbbb to 4487169 Compare August 20, 2025 22:32
@iamalwaysuncomfortable iamalwaysuncomfortable changed the title wip: started upgrade to record provider interface and started record … Update to RecordProvider Interface Aug 25, 2025
@alexpitsikoulis alexpitsikoulis force-pushed the feat/upgraded-record-provider-interface branch from 4487169 to de37e1c Compare September 8, 2025 18:07
@alexpitsikoulis alexpitsikoulis force-pushed the feat/upgraded-record-provider-interface branch from de37e1c to 8afa6ab Compare September 17, 2025 16:20
@alexpitsikoulis alexpitsikoulis marked this pull request as ready for review September 17, 2025 21:28
Copy link
Member

@iamalwaysuncomfortable iamalwaysuncomfortable left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some (expected) changes to the interface added here.

Secondly, let's please split out the concrete implementation of the RecordScanner from this PR and make it PR into this one. We need to put some pretty significant tests around it to ensure it's production ready. The interface however, matches what we expect.

* @param {number} startBlock The block height to start scanning from.
* @returns {Promise<void>} A promise that resolves when the account is registered.
*/
async register(startBlock: number): Promise<void> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should return a RegistrationResponse type

interface RegistrationResponse {
   uuid: string,
   job_id?: string,
   status?: string 
}
Suggested change
async register(startBlock: number): Promise<void> {
async register(startBlock: number): Promise<void> {

@@ -0,0 +1,52 @@
/**
* Encrypted Record found on chain. This type provides the record ciphertext and metadata from the ledger that such as the record's name, the program/function that produced it, etc.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Encrypted Record found on chain. This type provides the record ciphertext and metadata from the ledger that such as the record's name, the program/function that produced it, etc.
* Encrypted Record found on chain. This type provides the record ciphertext and metadata from the ledger such as the record's name, the program/function that produced it, etc.

@@ -0,0 +1,54 @@
/**
* Record owned by a registered view key. This type provides the record ciphertext, record plaintext and metadata from the ledger that such as the record's name, the program/function that produced it, etc.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Record owned by a registered view key. This type provides the record ciphertext, record plaintext and metadata from the ledger that such as the record's name, the program/function that produced it, etc.
* Record owned by a registered view key. This type provides the record ciphertext, record plaintext and metadata from the ledger such as the record's name, the program/function that produced it, etc.

@@ -0,0 +1,24 @@
import { RecordSearchParams } from "../record-provider/recordSearchParams";
import { RecordsFilter } from "./recordsFilter";
import { RecordsResponseFilter } from "../record-provider/recordsResponseFilter";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need another file to handle the OwnedFilter.

encryptedRecords(recordsFilter: RecordSearchParams, responseFilter: RecordsResponseFilter): Promise<EncryptedRecord[]>;

/**
* Check if a list of serial numbers exist in the chosen provider

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Check if a list of serial numbers exist in the chosen provider
* Check if a list of serial numbers exist in the chosen provider.

checkSerialNumbers(serialNumbers: string[]): Promise<Record<string, boolean>>;

/**
* Check if a list of tags exist in the chosen provider

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Check if a list of tags exist in the chosen provider
* Check if a list of tags exist in the chosen provider.

Comment on lines 12 to 33
/**
* RecordScanner is a RecordProvider implementation that uses the record scanner service to find records.
*
* @example
* const account = new Account({ privateKey: 'APrivateKey1...' });
*
* const recordScanner = new RecordScanner("https://record-scanner.aleo.org");
* recordScanner.setAccount(account);
* const uuid = await recordScanner.register(0);
*
* const filter = {
* uuid,
* filter: {
* program: "credits.aleo",
* records: ["credits"],
* },
* responseFilter: {
* program: true,
* record: true,
* function: true,
* transition: true,
* block_height: true,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we split this record provider out into a second PR so we can write proper tests around it?

return records.filter(record => {
const plaintext = RecordPlaintext.fromString(record.record_plaintext ?? '');
const amount = plaintext.getMember("microcredits").toString();
return microcreditAmounts.includes(parseInt(amount.replace("u64", "")));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will only match extremely specific micro credits amounts, which will match a very small amount of the time. This should ensure that records are found that are larger than the microcredit amounts in the array.

For instance if you have credits records with amounts:
100,
200,
3000,
4000,
30

And your filter specifies [100, 300, 400]
It should choose amounts above those like [100, 3000, 4000] OR [200, 3000, 4000]

Copy link
Member

@iamalwaysuncomfortable iamalwaysuncomfortable left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexpitsikoulis this is approved, merge at will.

@alexpitsikoulis alexpitsikoulis merged commit bce4d9f into mainnet Sep 22, 2025
13 checks passed
@alexpitsikoulis alexpitsikoulis deleted the feat/upgraded-record-provider-interface branch September 22, 2025 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants