Skip to content
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

Open
wants to merge 18 commits into
base: feat/record-scanning-and-arithmetic
Choose a base branch
from

Conversation

iamalwaysuncomfortable
Copy link
Collaborator

Motivation

Several feature requests have requested that the ability to the following be added to the SDK.

  • Be able to do Field, Group, and Scalar arithmetic and be generally able to work with those types
  • Easily peer into Transaction and Transition data and associated inputs and outputs
  • Work with Ciphertexts and get items from Struct and Array types

This 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:

  • Field, Scalar, and Group arithmetic.
  • Conversion of Transitions and Transactions to JS objects.

Related PRs

#944 - this PR adds the exports of SnarkVM types to wasm and provides code that

@iamalwaysuncomfortable iamalwaysuncomfortable changed the base branch from testnet3 to feat/record-scanning-and-arithmetic December 10, 2024 15:02
Copy link
Collaborator

@Pauan Pauan left a 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.

sdk/src/models/confirmed_transaction.ts Outdated Show resolved Hide resolved
sdk/src/models/deploy.ts Outdated Show resolved Hide resolved
sdk/src/models/executionJSON.ts Outdated Show resolved Hide resolved
sdk/src/models/functionObject.ts Outdated Show resolved Hide resolved
sdk/src/models/input/inputJSON.ts Outdated Show resolved Hide resolved
sdk/src/network-client.ts Outdated Show resolved Hide resolved
sdk/tests/key-provider.test.ts Outdated Show resolved Hide resolved
sdk/tests/network-client.test.ts Outdated Show resolved Hide resolved
sdk/tests/network-client.test.ts Outdated Show resolved Hide resolved
sdk/tests/network-client.test.ts Outdated Show resolved Hide resolved
@Pauan
Copy link
Collaborator

Pauan commented Jan 14, 2025

Since the docs are being auto-generated by the build:sdk-docs script, shouldn't the .html files be added into .gitignore?

… add Raw method to API client allowing non-formatted data to be returned from the API.
Copy link
Collaborator

@Pauan Pauan left a comment

Choose a reason for hiding this comment

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

LGTM

@iamalwaysuncomfortable
Copy link
Collaborator Author

Since the docs are being auto-generated by the build:sdk-docs script, shouldn't the .html files be added into .gitignore?

In theory yes, but in practice when users, especially ones new to the protocol or who aren't great at JS arrive here they don't think to run that. I've found users reaching for the HTML docs immediately and getting use out of it, so this is why it's done currently. We should however replace this with a very prominent link to these documents online. That doesn't exist yet, but I'll talk to @jaketarnow to see if we can make it so.

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