Skip to content

Commit b4b599c

Browse files
[Chore] SDK v0.9.1.8 release candidate (#1239)
* Update snarkVM dependencies to canary-v4.5.4 and add ExternalStruct support * fmt * Use [patch.crates-io] for snarkVM canary-v4.5.4 dependency resolution * Update SnarkVM dependency to testnet-4.5.4 * Update SnarkVM dependency to 4.5.0, add required mainnet code changes + bump sdk version --------- Co-authored-by: Cameron Marshall <cameron.marshall12@gmail.com>
1 parent 04e6cf3 commit b4b599c

File tree

32 files changed

+713
-462
lines changed

32 files changed

+713
-462
lines changed

.claude/CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
66

77
Yarn monorepo for the **Provable SDK** — a TypeScript/Rust SDK for building zero-knowledge applications on the Aleo
88
blockchain. The SDK re-exports core protocol objects from SnarkVM to allow users to perform operations related to their
9-
accounts and execute Aleo programs. Main published packages: `@provablehq/sdk` and `@provablehq/wasm` (both v0.9.17).
9+
accounts and execute Aleo programs. Main published packages: `@provablehq/sdk` and `@provablehq/wasm` (both v0.9.18).
1010

1111
**Workspaces:** `sdk`, `wasm`, `create-leo-app`
1212

.claude/commands/wrap-snarkvm.md

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ pub type TransactionNative = Transaction<CurrentNetwork>;
4949

5050
Do not add a new `use` statement if the crate is already imported — extend the existing one.
5151

52+
Ensure all imports are in alphabetical order.
53+
5254
---
5355

5456
## Step 3: Create the wrapper file at the specified destination
@@ -77,6 +79,7 @@ impl TypeName {
7779
// - to_string gets #[wasm_bindgen(js_name = "toString")] and #[allow(clippy::inherent_to_string)]
7880
// - from_str / constructors get #[wasm_bindgen(js_name = "fromString")] etc.
7981
// - Fallible methods return Result<T, String> — map errors with .map_err(|e| e.to_string())
82+
// - Methods should have to_string(), from_string(), to_bytes_le(), from_bytes_le(), to_field(), and to_fields(), from_fields(), to_bits_le(), and from_bits_le() if the SnarkVM object implements any of those.
8083
}
8184

8285
// Always generate all four two-way conversions between TypeName and TypeNameNative.
@@ -309,14 +312,72 @@ Match the style of existing entries in that file.
309312

310313
---
311314

312-
## Step 6: Verify
315+
## Step 6: Verify the wasm tests
313316

314-
Run:
317+
Run this from the sdk base directory.
315318
```bash
316-
cd wasm && cargo clippy --features testnet 2>&1 | head -50
319+
yarn test:wasm
317320
```
318321

319322
Fix any errors before declaring done. Common issues:
320323
- Missing imports in the wrapper file
321324
- Trait bounds not satisfied (check what traits the native type requires)
322325
- Method signatures that need adjustment for wasm-bindgen compatibility (e.g. no generic parameters, no lifetimes on return types)
326+
327+
## Step 7: Write JS tests of the wasm object and export it in `browser.ts`.
328+
329+
330+
Write JS tests of the wasm object and its methods in the JS sdk in the appropriate test file in `sdk/tests/wasm.test.ts`.
331+
332+
An example of how to write such tests are below.
333+
334+
```typescript
335+
describe('Transition', () => {
336+
const transitionStringTestnet = `{"id":"au1u62jasyx78x9hktak24awyj38fz73aseq8g9cx98u8egd9pj9uxq3u6s2z","program":"hello_hello.aleo","function":"hello","inputs":[{"type":"public","id":"3748790614260807060977840590007893602934308327222309419419577452790958781330field","value":"1u32"},{"type":"private","id":"5954208307642819953251922459490586292095132973876550778604572231610245257004field","value":"ciphertext1qyq0m5mp0d2gzh2pv9p25z70gz2avhqdt3dp8y8thzwf3aq6g35zcqcuyptz3"}],"outputs":[{"type":"private","id":"1557506318887190915592751299113729867877933642317637206076176689093854281418field","value":"ciphertext1qyqzmhw8ln9r6uuyh0n5jrsqlt25wdggqp3d9yqyttpr3g7g00k2sysdf9rmv"}],"tpk":"7532444547840484531569841377269810017844130178606467837628364672670182422388group","tcm":"7292056195970541935877520517416922164990366931599720071937561392936678536563field","scm":"8283770351301010771186520129040704279224805960417079922462917369178354050332field"}`;
337+
const transitionTestnet = Transition.fromString(transitionStringTestnet);
338+
const transitionDecryptedStringTestnet = `{"id":"au1mhdz6jqm973v5vfkz2pwgv63p340c9tpvydxha2zs8w03746qcpqvx3yye","program":"hello_hello.aleo","function":"hello","inputs":[{"type":"public","id":"3748790614260807060977840590007893602934308327222309419419577452790958781330field","value":"1u32"},{"type":"public","id":"5954208307642819953251922459490586292095132973876550778604572231610245257004field","value":"2u32"}],"outputs":[{"type":"public","id":"1557506318887190915592751299113729867877933642317637206076176689093854281418field","value":"3u32"}],"tpk":"7532444547840484531569841377269810017844130178606467837628364672670182422388group","tcm":"7292056195970541935877520517416922164990366931599720071937561392936678536563field","scm":"8283770351301010771186520129040704279224805960417079922462917369178354050332field"}`
339+
const transitionDecryptedTestnet = Transition.fromString(transitionDecryptedStringTestnet);
340+
const transitionViewKeyStringTestnet = "3975242887442171718863200089461896014344887434842278474302914755871123010247field";
341+
342+
const transitionStringMainnet = `{"id":"au1mguuz0dh20f78802m4z0py7n08xhl0pz60llzck63mhl8pc8l5xqxpwgtn","program":"hello_hello.aleo","function":"main","inputs":[{"type":"public","id":"6393584049543470937057043098611271993206122889317039351966319038535020834557field","value": "1u32"},{"type":"private","id":"8207446256045172951742235001162005156507562935942883128759030124682934277495field","value":"ciphertext1qyqqgz9qnupeld9vr4vuwp6yrpmhgtkvmgag5m7mmrruw0r6je666qgqdswk3"}],"outputs":[{"type":"private","id":"127469473292952941321346770257126666363371158501875622169294663492714835110field","value":"ciphertext1qyqyapkjuxm9dcslgyjf7hkr2k3dek500z40gjspnwvll0uawj23vzgggc405"}],"tpk":"7647553513996966044119163122930125808381703910407273818947266861843062002251group","tcm":"4479413938380109857414238205380483440836495997450846894155088299187217672609field","scm":"6461007226176477784737642021400489186736987671609840640950580467598882134642field"}`;
343+
const transitionMainnet = Transition.fromString(transitionStringMainnet);
344+
const transitionDecryptedStringMainnet = `{"id":"au1jl2ur42sj7hwe4r0alv6gnklqxj0fszrvu3q82gjcls5x6q9pyzqdgmu2k","program":"hello_hello.aleo","function":"main","inputs":[{"type":"public","id":"6393584049543470937057043098611271993206122889317039351966319038535020834557field","value":"1u32"},{"type":"public","id":"8207446256045172951742235001162005156507562935942883128759030124682934277495field","value":"2u32"}],"outputs":[{"type":"public","id":"127469473292952941321346770257126666363371158501875622169294663492714835110field","value":"3u32"}],"tpk":"7647553513996966044119163122930125808381703910407273818947266861843062002251group","tcm":"4479413938380109857414238205380483440836495997450846894155088299187217672609field","scm":"6461007226176477784737642021400489186736987671609840640950580467598882134642field"}`;
345+
const transitionDecryptedMainnet = Transition.fromString(transitionDecryptedStringMainnet);
346+
const transitionViewKeyStringMainnet = "8161419549946991944867064830365679191883723972221767444308198038592561311302field";
347+
348+
const invalidTransitionViewKeyString = "5089075468761042335883809641276568724119791331127957254389204093712358605127field"
349+
const invalidTransitionViewKey = Field.fromString(invalidTransitionViewKeyString);
350+
const privateKey = PrivateKey.from_string("APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH");
351+
const viewKey = privateKey.to_view_key();
352+
353+
let connection = new AleoNetworkClient("https://api.provable.com/v2");
354+
355+
if (connection.network === "testnet") {
356+
it('can be decrypted with a valid transition view key', () => {
357+
const tvk = transitionTestnet.tvk(viewKey);
358+
const transitionDecryptedWithTVK = transitionTestnet.decryptTransition(tvk);
359+
// Ensure the transition is valid
360+
expect(transitionDecryptedWithTVK.toString()).equal(transitionDecryptedTestnet.toString());
361+
});
362+
363+
it('cannot be decrypted with an invalid transition view key', () => {
364+
expect(() => transitionTestnet.decryptTransition(invalidTransitionViewKey).toThrow());
365+
});
366+
367+
it('can generate a transition view key from a valid view key', () => {
368+
const generatedTransitionViewKey = transitionTestnet.tvk(viewKey);
369+
370+
// Ensure the generated transition view key is the same as the one used to decrypt
371+
expect(generatedTransitionViewKey.toString()).equal(transitionViewKeyStringTestnet);
372+
});
373+
};
374+
```
375+
376+
Verify these tests work by running `yarn build:wasm && yarn build:sdk && yarn test:sdk` from the root of the sdk directory.
377+
378+
## Step 8: Cleanup Run cargo fmt --all
379+
380+
run the following in the `wasm` directory
381+
```bash
382+
cargo fmt --all
383+
```

create-leo-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "create-leo-app",
3-
"version": "0.9.17",
3+
"version": "0.9.18",
44
"type": "module",
55
"license": "GPL-3.0",
66
"collaborators": [

create-leo-app/template-build-and-execute-authorization-ts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"dev": "npm run build && node dist/index.js"
99
},
1010
"dependencies": {
11-
"@provablehq/sdk": "^0.9.17"
11+
"@provablehq/sdk": "^0.9.18"
1212
},
1313
"devDependencies": {
1414
"rimraf": "^6.0.1",

create-leo-app/template-devnode-js/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ constructor:
3232
async function main() {
3333
// Initialize multi-threading to allow WASM execution.
3434
await initThreadPool();
35-
const heights = getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11");
35+
const heights = getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12");
3636

3737
const privateKey = "APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH";
3838
const account = new Account({privateKey});

create-leo-app/template-devnode-js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
"dev": "node index.js"
88
},
99
"dependencies": {
10-
"@provablehq/sdk": "^0.9.17"
10+
"@provablehq/sdk": "^0.9.18"
1111
}
1212
}

create-leo-app/template-extension/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"build": "rimraf static/js && rollup --config"
88
},
99
"devDependencies": {
10-
"@provablehq/sdk": "^0.9.17",
10+
"@provablehq/sdk": "^0.9.18",
1111
"@web/rollup-plugin-import-meta-assets": "^2.2.1",
1212
"rimraf": "^6.0.1",
1313
"rollup": "^4.59.0"

create-leo-app/template-nextjs-ts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"lint": "next lint"
1010
},
1111
"dependencies": {
12-
"@provablehq/sdk": "^0.9.17",
12+
"@provablehq/sdk": "^0.9.18",
1313
"next": "15.5.10",
1414
"react": "^19.0.0",
1515
"react-dom": "^19.0.0",

create-leo-app/template-node-credits-aleo-functions-ts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"start": "npm run build && node dist/index.js"
99
},
1010
"dependencies": {
11-
"@provablehq/sdk": "^0.9.17"
11+
"@provablehq/sdk": "^0.9.18"
1212
},
1313
"devDependencies": {
1414
"rimraf": "^6.0.1",

create-leo-app/template-node-ts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"start": "npm run build && node dist/index.js"
99
},
1010
"dependencies": {
11-
"@provablehq/sdk": "^0.9.17"
11+
"@provablehq/sdk": "^0.9.18"
1212
},
1313
"devDependencies": {
1414
"rimraf": "^6.0.1",

0 commit comments

Comments
 (0)