From acc02eee7053d9de73966fa11a9d5b86a463fbd9 Mon Sep 17 00:00:00 2001 From: Wilhelm Thieme Date: Wed, 6 Nov 2024 12:28:07 -0500 Subject: [PATCH 1/3] Made dependencies of orca_whirlpools_client less strict --- rust-sdk/client/Cargo.toml | 6 ++--- rust-sdk/integration/Cargo.toml | 10 ++++++++ rust-sdk/integration/index.test.ts | 40 ++++++++++++++++++++++++++++++ rust-sdk/integration/package.json | 13 ++++++++++ rust-sdk/integration/src/main.rs | 5 ++++ rust-sdk/integration/tsconfig.json | 7 ++++++ yarn.lock | 13 ++++++++-- 7 files changed, 89 insertions(+), 5 deletions(-) create mode 100644 rust-sdk/integration/Cargo.toml create mode 100644 rust-sdk/integration/index.test.ts create mode 100644 rust-sdk/integration/package.json create mode 100644 rust-sdk/integration/src/main.rs create mode 100644 rust-sdk/integration/tsconfig.json diff --git a/rust-sdk/client/Cargo.toml b/rust-sdk/client/Cargo.toml index 3900dac6f..7a7038c7b 100644 --- a/rust-sdk/client/Cargo.toml +++ b/rust-sdk/client/Cargo.toml @@ -20,12 +20,12 @@ core-types = ["dep:orca_whirlpools_core"] serde = ["dep:serde", "dep:serde_with"] [dependencies] -anchor-lang = { version = "^0.30", optional = true } +anchor-lang = { version = "^0", optional = true } borsh = { version = "^0.10" } num-derive = { version = "^0.4" } num-traits = { version = "^0.2" } orca_whirlpools_core = { path = "../core", optional = true } serde = { version = "^1", features = ["derive"], optional = true } serde_with = { version = "^3.10", optional = true } -solana-program = { version = "^1.18" } -thiserror = { version = "^1" } +solana-program = { version = "^1" } +thiserror = { version = "^2" } diff --git a/rust-sdk/integration/Cargo.toml b/rust-sdk/integration/Cargo.toml new file mode 100644 index 000000000..4552e1595 --- /dev/null +++ b/rust-sdk/integration/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "orca_whirlpools_integration" +edition = "2021" + +[features] +default = [] +anchor = ["orca_whirlpools_client/anchor"] + +[dependencies] +orca_whirlpools_client = { path = "../client" } diff --git a/rust-sdk/integration/index.test.ts b/rust-sdk/integration/index.test.ts new file mode 100644 index 000000000..4767b527e --- /dev/null +++ b/rust-sdk/integration/index.test.ts @@ -0,0 +1,40 @@ +import assert from "assert"; +import { execSync } from "child_process"; +import { existsSync, rmSync } from "fs"; +import { describe, it, beforeEach } from "vitest"; + +type RustConfig = { + solana: string; + anchor?: string; +}; + +// Make sure client package work with a wide range of solana/anchor versions +const rustConfigs: RustConfig[] = [ + { solana: "1.17.11" }, + { solana: "1.18.26" }, + { solana: "1.17.11", anchor: "0.29.0" }, + { solana: "1.18.26", anchor: "0.30.1" }, +]; + +describe("Integration", () => { + + beforeEach(() => { + if (existsSync("Cargo.lock")) { + rmSync("Cargo.lock"); + } + }) + + rustConfigs.forEach((config) => { + it(`Build using '${JSON.stringify(config)}'`, () => { + let features = ""; + if (config.anchor) { + features = `--features anchor`; + execSync(`cargo update anchor-lang --precise ${config.anchor}`); + } + execSync(`cargo update solana-program --precise ${config.solana}`); + + const output = execSync(`cargo run ${features}`).toString(); + assert(output.includes("whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc")); + }); + }); +}); diff --git a/rust-sdk/integration/package.json b/rust-sdk/integration/package.json new file mode 100644 index 000000000..72eaf2497 --- /dev/null +++ b/rust-sdk/integration/package.json @@ -0,0 +1,13 @@ +{ + "name": "@orca-so/whirlpools-rust-integration", + "version": "0.0.1", + "type": "module", + "scripts": { + "build": "tsc --noEmit", + "test": "vitest run index.test.ts" + }, + "devDependencies": { + "@orca-so/whirlpools-rust-client": "*", + "typescript": "^5.5.4" + } +} diff --git a/rust-sdk/integration/src/main.rs b/rust-sdk/integration/src/main.rs new file mode 100644 index 000000000..c320e3a13 --- /dev/null +++ b/rust-sdk/integration/src/main.rs @@ -0,0 +1,5 @@ +use orca_whirlpools_client::ID; + +fn main() { + println!("{:?}", ID); +} diff --git a/rust-sdk/integration/tsconfig.json b/rust-sdk/integration/tsconfig.json new file mode 100644 index 000000000..486d8dee3 --- /dev/null +++ b/rust-sdk/integration/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "./dist" + }, + "include": ["index.test.ts"] +} diff --git a/yarn.lock b/yarn.lock index ec9c9b1d1..ed7a9f141 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4578,6 +4578,15 @@ __metadata: languageName: unknown linkType: soft +"@orca-so/whirlpools-rust-integration@workspace:rust-sdk/integration": + version: 0.0.0-use.local + resolution: "@orca-so/whirlpools-rust-integration@workspace:rust-sdk/integration" + dependencies: + "@orca-so/whirlpools-rust-client": "npm:*" + typescript: "npm:^5.5.4" + languageName: unknown + linkType: soft + "@orca-so/whirlpools-rust-macros@npm:*, @orca-so/whirlpools-rust-macros@workspace:rust-sdk/macros": version: 0.0.0-use.local resolution: "@orca-so/whirlpools-rust-macros@workspace:rust-sdk/macros" @@ -17347,7 +17356,7 @@ __metadata: languageName: node linkType: hard -"typescript@npm:^5.6.3": +"typescript@npm:^5.5.4, typescript@npm:^5.6.3": version: 5.6.3 resolution: "typescript@npm:5.6.3" bin: @@ -17357,7 +17366,7 @@ __metadata: languageName: node linkType: hard -"typescript@patch:typescript@npm%3A^5.6.3#optional!builtin": +"typescript@patch:typescript@npm%3A^5.5.4#optional!builtin, typescript@patch:typescript@npm%3A^5.6.3#optional!builtin": version: 5.6.3 resolution: "typescript@patch:typescript@npm%3A5.6.3#optional!builtin::version=5.6.3&hash=8c6c40" bin: From efc56525242f903efdad83ad3751c1afb45ce664 Mon Sep 17 00:00:00 2001 From: Wilhelm Thieme Date: Wed, 6 Nov 2024 12:30:25 -0500 Subject: [PATCH 2/3] Rename --- rust-sdk/integration/index.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust-sdk/integration/index.test.ts b/rust-sdk/integration/index.test.ts index 4767b527e..c8f52a2ee 100644 --- a/rust-sdk/integration/index.test.ts +++ b/rust-sdk/integration/index.test.ts @@ -9,7 +9,7 @@ type RustConfig = { }; // Make sure client package work with a wide range of solana/anchor versions -const rustConfigs: RustConfig[] = [ +const versionConfigs: RustConfig[] = [ { solana: "1.17.11" }, { solana: "1.18.26" }, { solana: "1.17.11", anchor: "0.29.0" }, @@ -24,7 +24,7 @@ describe("Integration", () => { } }) - rustConfigs.forEach((config) => { + versionConfigs.forEach((config) => { it(`Build using '${JSON.stringify(config)}'`, () => { let features = ""; if (config.anchor) { From fd89eac0e091b62378554ad026d734551562795b Mon Sep 17 00:00:00 2001 From: Wilhelm Thieme Date: Wed, 6 Nov 2024 12:48:50 -0500 Subject: [PATCH 3/3] More relaxed versions --- rust-sdk/client/Cargo.toml | 8 ++++---- rust-sdk/core/Cargo.toml | 17 ++++++++--------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/rust-sdk/client/Cargo.toml b/rust-sdk/client/Cargo.toml index 7a7038c7b..ca9dde0fe 100644 --- a/rust-sdk/client/Cargo.toml +++ b/rust-sdk/client/Cargo.toml @@ -21,11 +21,11 @@ serde = ["dep:serde", "dep:serde_with"] [dependencies] anchor-lang = { version = "^0", optional = true } -borsh = { version = "^0.10" } -num-derive = { version = "^0.4" } -num-traits = { version = "^0.2" } +borsh = { version = "^0" } +num-derive = { version = "^0" } +num-traits = { version = "^0" } orca_whirlpools_core = { path = "../core", optional = true } serde = { version = "^1", features = ["derive"], optional = true } -serde_with = { version = "^3.10", optional = true } +serde_with = { version = "^3", optional = true } solana-program = { version = "^1" } thiserror = { version = "^2" } diff --git a/rust-sdk/core/Cargo.toml b/rust-sdk/core/Cargo.toml index 5a2803bac..73554dab2 100644 --- a/rust-sdk/core/Cargo.toml +++ b/rust-sdk/core/Cargo.toml @@ -15,16 +15,15 @@ wasm = ["dep:wasm-bindgen", "dep:serde", "dep:serde-big-array", "dep:serde-wasm- floats = ["dep:libm"] [dependencies] -ethnum = { version = "^1.5" } -libm = { version = "^0.2", optional = true } +ethnum = { version = "^1" } +libm = { version = "^0", optional = true } orca_whirlpools_macros = { path = "../macros" } -wasm-bindgen = { version = "^0.2", optional = true } +wasm-bindgen = { version = "^0", optional = true } serde = { version = "^1", features = ["derive"], optional = true } -serde-big-array = { version = "^0.5", optional = true } -serde-wasm-bindgen = { version = "^0.6", optional = true } -js-sys = { version = "^0.3", optional = true } -tsify = { version = "^0.4", features = ["js"], optional = true } +serde-big-array = { version = "^0", optional = true } +serde-wasm-bindgen = { version = "^0", optional = true } +js-sys = { version = "^0", optional = true } +tsify = { version = "^0", features = ["js"], optional = true } [dev-dependencies] -print-no-std = { version = "^0.2"} -approx = { version = "^0.5" } +approx = { version = "^0" }