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

chore: remove noir_wasm dependency on noirc_abi_wasm #4315

Merged
merged 3 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 3 additions & 7 deletions .github/workflows/publish-es-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ jobs:
result/noirc_abi_wasm/web

build-noir_wasm:
needs: [build-noirc_abi_wasm]
runs-on: ubuntu-latest
steps:
- name: Checkout sources
Expand All @@ -58,15 +57,12 @@ jobs:
key: noir-wasm
save-if: false

- name: Download noirc_abi_wasm package artifact
uses: actions/download-artifact@v4
with:
name: noirc_abi_wasm
path: ./tooling/noirc_abi_wasm

- name: Install Yarn dependencies
uses: ./.github/actions/setup

- name: Build noir_js_types
run: yarn workspace @noir-lang/types build

- name: Build noir_wasm
run: yarn workspace @noir-lang/noir_wasm build

Expand Down
10 changes: 3 additions & 7 deletions .github/workflows/test-js-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ jobs:
retention-days: 3

build-noir-wasm:
needs: [build-noirc-abi]
runs-on: ubuntu-latest
timeout-minutes: 30

Expand All @@ -64,15 +63,12 @@ jobs:
cache-on-failure: true
save-if: ${{ github.event_name != 'merge_group' }}

- name: Download noirc_abi_wasm package artifact
uses: actions/download-artifact@v4
with:
name: noirc_abi_wasm
path: ./tooling/noirc_abi_wasm

- name: Install Yarn dependencies
uses: ./.github/actions/setup

- name: Build noir_js_types
run: yarn workspace @noir-lang/types build

- name: Build noir_wasm
run: yarn workspace @noir-lang/noir_wasm build

Expand Down
1 change: 1 addition & 0 deletions compiler/wasm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"webpack-cli": "^4.7.2"
},
"dependencies": {
"@noir-lang/types": "workspace:*",
"pako": "^2.1.0"
}
}
2 changes: 1 addition & 1 deletion compiler/wasm/src/types/noir_artifact.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Abi, AbiType } from '@noir-lang/noirc_abi';
import { Abi, AbiType } from '@noir-lang/types';

/**
* A named type.
Expand Down
3 changes: 0 additions & 3 deletions tooling/noir_js_types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@
"types": "./lib/esm/types.d.ts"
}
},
"dependencies": {
"@noir-lang/noirc_abi": "workspace:*"
},
"devDependencies": {
"@types/prettier": "^3",
"eslint": "^8.50.0",
Expand Down
31 changes: 29 additions & 2 deletions tooling/noir_js_types/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
import { Abi } from '@noir-lang/noirc_abi';
export type Field = string | number | boolean;
export type InputValue = Field | InputMap | (Field | InputMap)[];
export type InputMap = { [key: string]: InputValue };

export { Abi, WitnessMap } from '@noir-lang/noirc_abi';
export type Visibility = 'public' | 'private' | 'databus';
export type Sign = 'unsigned' | 'signed';
export type AbiType =
| { kind: 'field' }
| { kind: 'boolean' }
| { kind: 'string'; length: number }
| { kind: 'integer'; sign: Sign; width: number }
| { kind: 'array'; length: number; type: AbiType }
| { kind: 'tuple'; fields: AbiType[] }
| { kind: 'struct'; path: string; fields: { name: string; type: AbiType }[] };

export type AbiParameter = {
name: string;
type: AbiType;
visibility: Visibility;
};

// Map from witness index to hex string value of witness.
export type WitnessMap = Map<number, string>;

export type Abi = {
parameters: AbiParameter[];
param_witnesses: Record<string, { start: number; end: number }[]>;
return_type: { abi_type: AbiType; visibility: Visibility } | null;
return_witnesses: number[];
};

export interface Backend {
/**
Expand Down
3 changes: 3 additions & 0 deletions tooling/noirc_abi_wasm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
"build:nix": "nix build -L .#noirc_abi_wasm",
"install:from:nix": "yarn clean && yarn build:nix && cp -rL ./result/noirc_abi_wasm/nodejs ./ && cp -rL ./result/noirc_abi_wasm/web ./"
},
"dependencies": {
"@noir-lang/types": "workspace:*"
},
"devDependencies": {
"@esm-bundle/chai": "^4.3.4-fix.0",
"@web/dev-server-esbuild": "^0.3.6",
Expand Down
6 changes: 0 additions & 6 deletions tooling/noirc_abi_wasm/src/js_witness_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ use acvm::{
use js_sys::{JsString, Map};
use wasm_bindgen::prelude::{wasm_bindgen, JsValue};

#[wasm_bindgen(typescript_custom_section)]
const WITNESS_MAP: &'static str = r#"
// Map from witness index to hex string value of witness.
export type WitnessMap = Map<number, string>;
"#;

// WitnessMap
#[wasm_bindgen]
extern "C" {
Expand Down
38 changes: 2 additions & 36 deletions tooling/noirc_abi_wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,54 +26,20 @@ use js_witness_map::JsWitnessMap;

#[wasm_bindgen(typescript_custom_section)]
const INPUT_MAP: &'static str = r#"
export type Field = string | number | boolean;
export type InputValue = Field | InputMap | (Field | InputMap)[];
export type InputMap = { [key: string]: InputValue };
import { Field, InputValue, InputMap, Visibility, Sign, AbiType, AbiParameter, Abi, WitnessMap } from "@noir-lang/types";
export { Field, InputValue, InputMap, Visibility, Sign, AbiType, AbiParameter, Abi, WitnessMap } from "@noir-lang/types";
"#;

#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(extends = js_sys::Object, js_name = "InputMap", typescript_type = "InputMap")]
#[derive(Clone, Debug, PartialEq, Eq)]
pub type JsInputMap;
}

#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(extends = js_sys::Object, js_name = "InputValue", typescript_type = "InputValue")]
#[derive(Clone, Debug, PartialEq, Eq)]
pub type JsInputValue;
}

#[wasm_bindgen(typescript_custom_section)]
const ABI: &'static str = r#"
export type Visibility = "public" | "private" | "databus";
export type Sign = "unsigned" | "signed";
export type AbiType =
{ kind: "field" } |
{ kind: "boolean" } |
{ kind: "string", length: number } |
{ kind: "integer", sign: Sign, width: number } |
{ kind: "array", length: number, type: AbiType } |
{ kind: "tuple", fields: AbiType[] } |
{ kind: "struct", path: string, fields: { name: string, type: AbiType }[] };

export type AbiParameter = {
name: string,
type: AbiType,
visibility: Visibility,
};

export type Abi = {
parameters: AbiParameter[],
param_witnesses: Record<string, {start: number, end: number}[]>,
return_type: {abi_type: AbiType, visibility: Visibility} | null,
return_witnesses: number[],
}
"#;

#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(extends = js_sys::Object, js_name = "Abi", typescript_type = "Abi")]
#[derive(Clone, Debug, PartialEq, Eq)]
pub type JsAbi;
Expand Down
3 changes: 2 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4523,6 +4523,7 @@ __metadata:
"@esm-bundle/chai": ^4.3.4-fix.0
"@ltd/j-toml": ^1.38.0
"@noir-lang/noirc_abi": "workspace:*"
"@noir-lang/types": "workspace:*"
"@types/adm-zip": ^0.5.0
"@types/chai": ^4
"@types/mocha": ^10.0.6
Expand Down Expand Up @@ -4572,6 +4573,7 @@ __metadata:
resolution: "@noir-lang/noirc_abi@workspace:tooling/noirc_abi_wasm"
dependencies:
"@esm-bundle/chai": ^4.3.4-fix.0
"@noir-lang/types": "workspace:*"
"@web/dev-server-esbuild": ^0.3.6
"@web/test-runner": ^0.15.3
"@web/test-runner-playwright": ^0.10.0
Expand Down Expand Up @@ -4610,7 +4612,6 @@ __metadata:
version: 0.0.0-use.local
resolution: "@noir-lang/types@workspace:tooling/noir_js_types"
dependencies:
"@noir-lang/noirc_abi": "workspace:*"
"@types/prettier": ^3
eslint: ^8.50.0
eslint-plugin-prettier: ^5.0.0
Expand Down
Loading