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 23 commits into
base: feat/record-scanning-and-arithmetic
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
f9d061e
Fixing create-leo-app examples
Pauan Nov 28, 2024
0aa0798
Changing polyfill to use import instead of require
Pauan Dec 2, 2024
7d3742a
Renaming start script to dev
Pauan Dec 2, 2024
610c16c
Renaming start script to dev
Pauan Dec 2, 2024
5d18001
Update SnarkVM to v1.1.0 and revise fee calculations
iamalwaysuncomfortable Dec 4, 2024
105266b
Merge pull request #945 from Pauan/fix/examples
iamalwaysuncomfortable Dec 5, 2024
d3d771b
[Update] Update SnarkVM to v1.1.0 and revise fee calculations
iamalwaysuncomfortable Dec 5, 2024
a7e4a83
Merge branch 'testnet3' into feat/record-scanning-and-arithmetic-in-js
iamalwaysuncomfortable Dec 6, 2024
e22f778
Add wasm upgrades into the SDK
iamalwaysuncomfortable Dec 9, 2024
13119b8
Add upgraded wasm dependency
iamalwaysuncomfortable Dec 9, 2024
d236665
Fix method rename
iamalwaysuncomfortable Dec 9, 2024
034e638
Add tests of new wasm exports
iamalwaysuncomfortable Dec 10, 2024
871dab6
Address fmt lints
iamalwaysuncomfortable Dec 10, 2024
b0ffc4b
Update some types to interfaces, export all types, update docs
iamalwaysuncomfortable Jan 14, 2025
1bb628f
Update github action to allow wasm build to finish
iamalwaysuncomfortable Jan 14, 2025
e400890
Revert github action
iamalwaysuncomfortable Jan 14, 2025
c7e055c
Bump SDK and wasm version to 0.7.6
iamalwaysuncomfortable Jan 14, 2025
7518507
Add updated typescript models to reflect structure of API responses +…
iamalwaysuncomfortable Jan 15, 2025
43bfb79
Update tests to handle bigints and modify plaintext handling in the n…
iamalwaysuncomfortable Jan 16, 2025
4ba13dc
Address fmt lints
iamalwaysuncomfortable Jan 16, 2025
1b0f732
Standardize interfaces between objects and JSON
iamalwaysuncomfortable Jan 16, 2025
763b59a
Change nulls to undefined in Rust and apply format lints
iamalwaysuncomfortable Jan 16, 2025
5396edd
Fix BigInt serialization in parseJSON utility
iamalwaysuncomfortable Jan 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ jobs:
- run:
working_directory: create-leo-app/template-node
command: |
yarn start
yarn dev

template-node-ts:
executor: rust-node
Expand All @@ -108,7 +108,7 @@ jobs:
- run:
working_directory: create-leo-app/template-node-ts
command: |
yarn start
yarn dev

template-extension:
executor: rust-node
Expand Down
2 changes: 1 addition & 1 deletion create-leo-app/template-node-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "module",
"scripts": {
"build": "rimraf dist/js && rollup --config",
"start": "npm run build && node dist/index.js"
"dev": "npm run build && node dist/index.js"
},
"dependencies": {
"@provablehq/sdk": "^0.7.0"
Expand Down
2 changes: 1 addition & 1 deletion create-leo-app/template-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"start": "node index.js"
"dev": "node index.js"
},
"dependencies": {
"@provablehq/sdk": "^0.7.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "module",
"scripts": {
"build": "rimraf dist/js && rollup --config",
"start": "npm run build && node dist/index.js"
"dev": "npm run build && node dist/index.js"
},
"dependencies": {
"@provablehq/sdk": "^0.7.0"
Expand Down
6 changes: 3 additions & 3 deletions sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@
},
"homepage": "https://github.com/ProvableHQ/sdk#readme",
"dependencies": {
"@provablehq/wasm": "^0.7.0",
"@provablehq/wasm": "^0.7.2",
"comlink": "^4.4.1",
"mime": "^3.0.0",
"sync-request": "^6.1.0"
"sync-request": "^6.1.0",
"core-js": "^3.38.1"
},
"devDependencies": {
"@rollup/plugin-replace": "^5.0.5",
Expand All @@ -63,7 +64,6 @@
"better-docs": "^2.7.2",
"chai": "^5.1.1",
"clean-jsdoc-theme": "^4.1.8",
"core-js": "^3.38.1",
"cpr": "^3.0.1",
"eslint": "^8.26.0",
"eslint-config-prettier": "^8.5.0",
Expand Down
43 changes: 31 additions & 12 deletions sdk/src/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@ import "./polyfill/shared";

import { Account } from "./account";
import { AleoNetworkClient, ProgramImports } from "./network-client";
import { Block } from "./models/block";
import { Execution } from "./models/execution";
import { Input } from "./models/input";
import { Output } from "./models/output";
import { TransactionModel } from "./models/transactionModel";
import { Transition } from "./models/transition";
import { BlockJSON } from "./models/blockJSON";
import { ExecutionJSON } from "./models/executionJSON";
import { FunctionObject } from "./models/functionObject";
import { InputJSON } from "./models/input/inputJSON";
import { InputObject } from "./models/input/inputObject";
import { OutputJSON } from "./models/output/outputJSON";
import { OutputObject } from "./models/output/outputObject";
import { PlaintextArray} from "./models/plaintext/array";
import { PlaintextLiteral} from "./models/plaintext/literal";
import { PlaintextStruct} from "./models/plaintext/struct";
import { TransactionJSON } from "./models/transaction/transactionJSON";
import { TransactionSummary } from "./models/transaction/transactionSummary";
import { TransitionJSON } from "./models/transition/transitionJSON";
import { TransitionObject } from "./models/transition/transitionObject";
import {
AleoKeyProvider,
AleoKeyProviderParams,
Expand Down Expand Up @@ -41,10 +49,13 @@ export { logAndThrow } from "./utils";

export {
Address,
Ciphertext,
Execution as FunctionExecution,
ExecutionResponse,
Field,
Group,
OfflineQuery,
Plaintext,
PrivateKey,
PrivateKeyCiphertext,
Program,
Expand All @@ -53,7 +64,9 @@ export {
RecordCiphertext,
RecordPlaintext,
Signature,
Scalar,
Transaction,
Transition,
VerifyingKey,
ViewKey,
initThreadPool,
Expand Down Expand Up @@ -81,21 +94,27 @@ export {
AleoKeyProviderParams,
AleoKeyProviderInitParams,
AleoNetworkClient,
Block,
BlockJSON,
BlockHeightSearch,
CachedKeyPair,
Execution,
ExecutionJSON,
FunctionObject,
FunctionKeyPair,
FunctionKeyProvider,
Input,
InputJSON,
InputObject,
KeySearchParams,
NetworkRecordProvider,
ProgramImports,
OfflineKeyProvider,
OfflineSearchParams,
Output,
PlaintextArray,
PlaintextLiteral,
PlaintextStruct,
OutputJSON,
OutputObject,
RecordProvider,
RecordSearchParams,
TransactionModel,
Transition,
TransactionJSON,
TransactionSummary,
};
2 changes: 1 addition & 1 deletion sdk/src/models/block.ts → sdk/src/models/blockJSON.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ConfirmedTransaction } from "./confirmed_transaction";

export type Block = {
export type BlockJSON = {
block_hash: string;
previous_hash: string;
header: Header;
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/models/confirmed_transaction.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TransactionModel } from "./transactionModel";
import { TransactionJSON } from "./transaction/transactionJSON";

export type ConfirmedTransaction = {
type: string;
iamalwaysuncomfortable marked this conversation as resolved.
Show resolved Hide resolved
id: string;
transaction: TransactionModel;
transaction: TransactionJSON;
}
6 changes: 6 additions & 0 deletions sdk/src/models/deploy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { FunctionObject } from "./functionObject";

export type DeploymentMetadata = {
iamalwaysuncomfortable marked this conversation as resolved.
Show resolved Hide resolved
"programId" : string,
"functions" : FunctionObject[]
}
6 changes: 0 additions & 6 deletions sdk/src/models/execution.ts

This file was deleted.

6 changes: 6 additions & 0 deletions sdk/src/models/executionJSON.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { TransitionJSON } from "./transition/transitionJSON";

export type ExecutionJSON = {
iamalwaysuncomfortable marked this conversation as resolved.
Show resolved Hide resolved
edition: number;
transitions?: (TransitionJSON)[];
}
8 changes: 8 additions & 0 deletions sdk/src/models/functionObject.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { VerifyingKey } from "@provablehq/wasm";

export type FunctionObject = {
iamalwaysuncomfortable marked this conversation as resolved.
Show resolved Hide resolved
"name" : string,
"constraints" : number,
"variables" : number,
"verifyingKey" : string | VerifyingKey,
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export type Input = {
/**
* Object representation of an Input as raw JSON returned from a SnarkOS node.
*/
export type InputJSON = {
type: string;
iamalwaysuncomfortable marked this conversation as resolved.
Show resolved Hide resolved
id: string;
tag?: string;
Expand Down
16 changes: 16 additions & 0 deletions sdk/src/models/input/inputObject.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Aleo function Input represented as a typed typescript object.
*/
import { Ciphertext, Field } from "@provablehq/wasm";
iamalwaysuncomfortable marked this conversation as resolved.
Show resolved Hide resolved
import { Plaintext } from "@provablehq/wasm/mainnet.js";
iamalwaysuncomfortable marked this conversation as resolved.
Show resolved Hide resolved
import { PlaintextObject } from "../plaintext/plaintext";

/**
* Object representation of an Input as raw JSON returned from a SnarkOS node.
*/
export type InputObject = {
iamalwaysuncomfortable marked this conversation as resolved.
Show resolved Hide resolved
type: "string",
id: "string" | Field,
tag?: string | Field,
value?: Ciphertext | Plaintext | PlaintextObject,
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type Output = {
export type OutputJSON = {
type: string;
iamalwaysuncomfortable marked this conversation as resolved.
Show resolved Hide resolved
id: string;
checksum: string;
Expand Down
18 changes: 18 additions & 0 deletions sdk/src/models/output/outputObject.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Aleo function Input represented as a typed typescript object.
*/
import { Field, Ciphertext, Plaintext } from "@provablehq/wasm";
iamalwaysuncomfortable marked this conversation as resolved.
Show resolved Hide resolved
import { PlaintextObject } from "../plaintext/plaintext";

/**
* Object representation of an Input as raw JSON returned from a SnarkOS node.
*/
export type OutputObject = {
iamalwaysuncomfortable marked this conversation as resolved.
Show resolved Hide resolved
type: string,
id: string | Field,
value?: Ciphertext | Plaintext | PlaintextObject,
checksum?: string | Field,
programId?: string,
functionName?: string,
arguments?: Array<Plaintext> | Array<OutputObject>
}
4 changes: 4 additions & 0 deletions sdk/src/models/plaintext/array.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { PlaintextLiteral } from "./literal";
import { PlaintextStruct } from "./struct";

export type PlaintextArray = PlaintextLiteral[] | PlaintextStruct[] | PlaintextArray[];
1 change: 1 addition & 0 deletions sdk/src/models/plaintext/literal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type PlaintextLiteral = boolean | bigint | number | string;
5 changes: 5 additions & 0 deletions sdk/src/models/plaintext/plaintext.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { PlaintextArray } from "./array";
import { PlaintextLiteral } from "./literal";
import { PlaintextStruct } from "./struct";

export type PlaintextObject = PlaintextArray| PlaintextLiteral | PlaintextStruct
6 changes: 6 additions & 0 deletions sdk/src/models/plaintext/struct.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { PlaintextArray } from "./array";
import { PlaintextLiteral } from "./literal";

export type PlaintextStruct = {
[key: string]: PlaintextArray | PlaintextLiteral | PlaintextStruct;
}
7 changes: 7 additions & 0 deletions sdk/src/models/transaction/transactionJSON.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { ExecutionJSON } from "../executionJSON";

export type TransactionJSON = {
iamalwaysuncomfortable marked this conversation as resolved.
Show resolved Hide resolved
type: string;
id: string;
execution: ExecutionJSON;
}
12 changes: 12 additions & 0 deletions sdk/src/models/transaction/transactionSummary.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { TransitionObject } from "../transition/transitionObject";
import { DeploymentMetadata } from "../deploy";

export type TransactionSummary = {
iamalwaysuncomfortable marked this conversation as resolved.
Show resolved Hide resolved
id : string;
type : string;
fee : bigint;
baseFee : bigint;
priorityFee : bigint;
transitions : TransitionObject[];
deployment?: DeploymentMetadata;
}
7 changes: 0 additions & 7 deletions sdk/src/models/transactionModel.ts

This file was deleted.

14 changes: 0 additions & 14 deletions sdk/src/models/transition.ts

This file was deleted.

14 changes: 14 additions & 0 deletions sdk/src/models/transition/transitionJSON.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { InputJSON } from "../input/inputJSON";
import { OutputJSON } from "../output/outputJSON";

export type TransitionJSON = {
iamalwaysuncomfortable marked this conversation as resolved.
Show resolved Hide resolved
id: string;
program: string;
function: string;
inputs?: (InputJSON)[];
outputs?: (OutputJSON)[];
proof: string;
tpk: string;
tcm: string;
fee: bigint;
}
16 changes: 16 additions & 0 deletions sdk/src/models/transition/transitionObject.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { InputObject } from "../input/inputObject";
import { OutputObject } from "../output/outputObject";
import { Field, Group } from "@provablehq/wasm";
iamalwaysuncomfortable marked this conversation as resolved.
Show resolved Hide resolved

export type TransitionObject = {
iamalwaysuncomfortable marked this conversation as resolved.
Show resolved Hide resolved
id: string;
program: string;
functionName: string;
inputs?: (InputObject)[];
outputs?: (OutputObject)[];
proof: string;
tpk: string | Group;
tcm: string | Field;
scm: string | Field;
fee: bigint;
}
Loading
Loading