-
Notifications
You must be signed in to change notification settings - Fork 471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Add Field, Group, Scalar, Plaintext, Ciphertext, Transitions, and Transactions to JS SDK. #948
base: feat/record-scanning-and-arithmetic
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor nits, but generally looks good.
@@ -1,7 +1,7 @@ | |||
import { TransactionModel } from "./transactionModel"; | |||
import { TransactionJSON } from "./transaction/transactionJSON"; | |||
|
|||
export type ConfirmedTransaction = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For objects, it's better to use an interface
instead of type
@@ -0,0 +1,6 @@ | |||
import { FunctionObject } from "./functionObject"; | |||
|
|||
export type DeploymentMetadata = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, this should be an interface
@@ -0,0 +1,6 @@ | |||
import { TransitionJSON } from "./transition/transitionJSON"; | |||
|
|||
export type ExecutionJSON = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, this should be an interface
@@ -0,0 +1,8 @@ | |||
import { VerifyingKey } from "@provablehq/wasm"; | |||
|
|||
export type FunctionObject = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, this should be an interface
/** | ||
* Object representation of an Input as raw JSON returned from a SnarkOS node. | ||
*/ | ||
export type InputJSON = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, this should be an interface
async getTransactionObjectsInMempool(): Promise<Array<Transaction>> { | ||
try { | ||
return (await this.fetchData<Array<string>>("/memoryPool/transactions")) | ||
.reduce<Array<Transaction>>((acc, transaction) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, why is this using reduce
?
expect(unbondPublicProverLocal.isUnbondPublicProver()).equal(true); | ||
expect(unbondPublicVerifierLocal.isUnbondPublicVerifier()).equal(true); | ||
}); | ||
// it('should not fetch invalid transfer keys', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's cleaner to use describe.skip
or it.skip
to skip the tests, instead of commenting it out.
|
||
import { Account, BlockJSON, AleoNetworkClient, TransactionSummary, InputObject, OutputObject } from "../src/node"; | ||
import {beaconPrivateKeyString} from "./data/account-data"; | ||
import { Plaintext, Transition } from "@provablehq/wasm"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be importing from ../src/node
instead of @provablehq/wasm
.
import { Account, BlockJSON, AleoNetworkClient, TransactionSummary, InputObject, OutputObject } from "../src/node"; | ||
import {beaconPrivateKeyString} from "./data/account-data"; | ||
import { Plaintext, Transition } from "@provablehq/wasm"; | ||
import { TransitionObject } from "../src/models/transition/transitionObject"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably also be importing from ../src/node
import {beaconPrivateKeyString} from "./data/account-data"; | ||
import { Plaintext, Transition } from "@provablehq/wasm"; | ||
import { TransitionObject } from "../src/models/transition/transitionObject"; | ||
import { PlaintextObject } from "../src/models/plaintext/plaintext"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably also be importing from ../src/node
Motivation
Several feature requests have requested that the ability to the following be added to the SDK.
Struct
andArray
typesThis PR adds these types to the SDK with the ability to turn them into JavaScript/TypeScript objects for convenient extraction of data into a front or backend app as well as api methods that allow these new types to be directly instantiated when calling api endpoints.
It also provides several new typescript types that allow typescript users to work with the JS representation of these objects.
Once this PR is approved, it will constitute the release candidate for the next major version bump.
Test Plan
This PR adds the following unit tests for the new objects:
Related PRs
#944 - this PR adds the exports of SnarkVM types to
wasm
and provides code that