Skip to content

Commit 8dbb863

Browse files
Rust/JS: migrate to IRaindexV7 SignedContextV2 names; oracle responses carry the EIP-712 domainSeparator
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent d5f2911 commit 8dbb863

42 files changed

Lines changed: 436 additions & 374 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎crates/bindings/ARCHITECTURE.md‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ Generated Solidity Bindings (Alloy `sol!`)
5757
- Practical result of the `sol!(… rpc)` attribute:
5858
- For `IRaindexV5` and `IERC20`, you can construct an instance bound to a
5959
provider and call methods with strong typing, for example:
60-
`let ob = IRaindexV5Instance::new(address, provider.clone()); ob.quote2(config).await?`.
60+
`let ob = IRaindexV5Instance::new(address, provider.clone()); ob.quote3(config).await?`.
6161
- For all bindings, you can still directly use generated call structs, e.g.,
62-
`IRaindexV5::removeOrder3Call { ... }.abi_encode()` or
62+
`IRaindexV5::removeOrder4Call { ... }.abi_encode()` or
6363
`Raindex::multicallCall { ... }`.
6464

6565
- Derives and defaults:
@@ -118,17 +118,17 @@ WASM and JS Interop
118118

119119
- Exposed interfaces (hand‑written TS definitions):
120120
- `IOV2`: `{ token: string; vaultId: string; }`
121-
- `QuoteV2`:
122-
`{ order: OrderV4; inputIOIndex: string; outputIOIndex: string; signedContext: SignedContextV1[]; }`
121+
- `QuoteV3`:
122+
`{ order: OrderV4; inputIOIndex: string; outputIOIndex: string; signedContext: SignedContextV2[]; }`
123123
- `OrderV4`:
124124
`{ owner: string; evaluable: EvaluableV4; validInputs: IOV2[]; validOutputs: IOV2[]; nonce: string; }`
125125
- `EvaluableV4`: `{ interpreter: string; store: string; bytecode: string; }`
126-
- `SignedContextV1`:
127-
`{ signer: string; context: string[]; signature: string; }`
128-
- `TakeOrderConfigV4`:
129-
`{ order: OrderV4; inputIOIndex: string; outputIOIndex: string; signedContext: SignedContextV1[]; }`
130-
- `TakeOrdersConfigV5`:
131-
`{ minimumIO: string; maximumIO: string; maximumIORatio: string; IOIsInput: string; orders: TakeOrderConfigV4[]; data: string; }`
126+
- `SignedContextV2`:
127+
`{ signer: string; domainSeparator: string; context: string[]; signature: string; }`
128+
- `TakeOrderConfigV5`:
129+
`{ order: OrderV4; inputIOIndex: string; outputIOIndex: string; signedContext: SignedContextV2[]; }`
130+
- `TakeOrdersConfigV6`:
131+
`{ minimumIO: string; maximumIO: string; maximumIORatio: string; IOIsInput: string; orders: TakeOrderConfigV5[]; data: string; }`
132132

133133
- Why many fields are `string` in TS
134134
- Large numeric values (e.g., `U256`) are represented as strings to avoid
@@ -157,11 +157,11 @@ How This Crate Is Used Elsewhere
157157

158158
- Quote engine (`crates/quote`):
159159
- Imports `IRaindexV5::IRaindexV5Instance` and `mk_read_provider`.
160-
- Binds the instance to a provider and calls `quote2` for many orders via
160+
- Binds the instance to a provider and calls `quote3` for many orders via
161161
Alloy’s multicall helper.
162162
- Common utilities (`crates/common`):
163163
- Uses ABI‑generated call structs (e.g., `deposit3Call`, `withdraw3Call`,
164-
`removeOrder3Call`, `IERC20::approveCall`) to build calldata for
164+
`removeOrder4Call`, `IERC20::approveCall`) to build calldata for
165165
transactions.
166166
- JS API (`crates/js_api`):
167167
- Builds order builder calldata for approvals/deposits/add‑order and uses call
@@ -209,12 +209,12 @@ Examples
209209
`let provider = mk_read_provider(&rpcs)?;`
210210
- Bind to a raindex:
211211
`let ob = IRaindexV5Instance::new(raindex_addr, provider.clone());`
212-
- Call a view: `let quote = ob.quote2(config).await?;`
212+
- Call a view: `let quote = ob.quote3(config).await?;`
213213

214214
- Building calldata without an instance:
215-
- `use raindex_bindings::IRaindexV5::removeOrder3Call;`
215+
- `use raindex_bindings::IRaindexV5::removeOrder4Call;`
216216
- Construct the struct and encode:
217-
`let bytes = removeOrder3Call { order, tasks }.abi_encode();`
217+
`let bytes = removeOrder4Call { order, tasks }.abi_encode();`
218218

219219
Limitations and Notes
220220

‎crates/bindings/src/js_api.rs‎

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
use crate::IRaindexV7::{
2-
EvaluableV4, OrderV4, QuoteV2, SignedContextV1, TakeOrderConfigV4, TakeOrdersConfigV5, IOV2,
2+
EvaluableV4, OrderV4, QuoteV3, SignedContextV2, TakeOrderConfigV5, TakeOrdersConfigV6, IOV2,
33
};
44
use wasm_bindgen_utils::{impl_custom_tsify, impl_wasm_traits, prelude::*};
55

66
impl_wasm_traits!(IOV2);
7-
impl_wasm_traits!(QuoteV2);
7+
impl_wasm_traits!(QuoteV3);
88
impl_wasm_traits!(OrderV4);
99
impl_wasm_traits!(EvaluableV4);
10-
impl_wasm_traits!(SignedContextV1);
11-
impl_wasm_traits!(TakeOrderConfigV4);
12-
impl_wasm_traits!(TakeOrdersConfigV5);
10+
impl_wasm_traits!(SignedContextV2);
11+
impl_wasm_traits!(TakeOrderConfigV5);
12+
impl_wasm_traits!(TakeOrdersConfigV6);
1313

1414
impl_custom_tsify!(
1515
IOV2,
@@ -19,12 +19,12 @@ impl_custom_tsify!(
1919
}"
2020
);
2121
impl_custom_tsify!(
22-
QuoteV2,
23-
"export interface QuoteV2 {
22+
QuoteV3,
23+
"export interface QuoteV3 {
2424
order: OrderV4;
2525
inputIOIndex: string;
2626
outputIOIndex: string;
27-
signedContext: SignedContextV1[];
27+
signedContext: SignedContextV2[];
2828
}"
2929
);
3030
impl_custom_tsify!(
@@ -46,30 +46,31 @@ impl_custom_tsify!(
4646
}"
4747
);
4848
impl_custom_tsify!(
49-
SignedContextV1,
50-
"export interface SignedContextV1 {
49+
SignedContextV2,
50+
"export interface SignedContextV2 {
5151
signer: string;
52+
domainSeparator: string;
5253
context: string[];
5354
signature: string;
5455
}"
5556
);
5657
impl_custom_tsify!(
57-
TakeOrderConfigV4,
58-
"export interface TakeOrderConfigV4 {
58+
TakeOrderConfigV5,
59+
"export interface TakeOrderConfigV5 {
5960
order: OrderV4;
6061
inputIOIndex: string;
6162
outputIOIndex: string;
62-
signedContext: SignedContextV1[];
63+
signedContext: SignedContextV2[];
6364
}"
6465
);
6566
impl_custom_tsify!(
66-
TakeOrdersConfigV5,
67-
"export interface TakeOrdersConfigV5 {
67+
TakeOrdersConfigV6,
68+
"export interface TakeOrdersConfigV6 {
6869
minimumIO: string;
6970
maximumIO: string;
7071
maximumIORatio: string;
7172
IOIsInput: string;
72-
orders: TakeOrderConfigV4[];
73+
orders: TakeOrderConfigV5[];
7374
data: string;
7475
}"
7576
);
@@ -91,7 +92,7 @@ mod tests {
9192

9293
#[wasm_bindgen_test]
9394
fn test_quote_tsify() {
94-
let js_quote = to_js_value(&QuoteV2::default()).unwrap();
95+
let js_quote = to_js_value(&QuoteV3::default()).unwrap();
9596
// validate serialized props match the tsify definition
9697
assert!(JsString::from_str("order").unwrap().js_in(&js_quote));
9798
assert!(JsString::from_str("inputIOIndex").unwrap().js_in(&js_quote));
@@ -126,12 +127,15 @@ mod tests {
126127
}
127128

128129
#[wasm_bindgen_test]
129-
fn test_signed_contextv1_tsify() {
130-
let js_signed_context = to_js_value(&SignedContextV1::default()).unwrap();
130+
fn test_signed_contextv2_tsify() {
131+
let js_signed_context = to_js_value(&SignedContextV2::default()).unwrap();
131132
// validate serialized props match the tsify definition
132133
assert!(JsString::from_str("signer")
133134
.unwrap()
134135
.js_in(&js_signed_context));
136+
assert!(JsString::from_str("domainSeparator")
137+
.unwrap()
138+
.js_in(&js_signed_context));
135139
assert!(JsString::from_str("context")
136140
.unwrap()
137141
.js_in(&js_signed_context));
@@ -142,7 +146,7 @@ mod tests {
142146

143147
#[wasm_bindgen_test]
144148
fn test_take_order_config_v4_tsify() {
145-
let js_take_order_config = to_js_value(&TakeOrderConfigV4::default()).unwrap();
149+
let js_take_order_config = to_js_value(&TakeOrderConfigV5::default()).unwrap();
146150
// validate serialized props match the tsify definition
147151
assert!(JsString::from_str("order")
148152
.unwrap()
@@ -160,7 +164,7 @@ mod tests {
160164

161165
#[wasm_bindgen_test]
162166
fn test_take_orders_config_v4_tsify() {
163-
let js_take_orders_config = to_js_value(&TakeOrdersConfigV5::default()).unwrap();
167+
let js_take_orders_config = to_js_value(&TakeOrdersConfigV6::default()).unwrap();
164168
// validate serialized props match the tsify definition
165169
assert!(JsString::from_str("minimumIO")
166170
.unwrap()

‎crates/bindings/src/lib.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ pub mod topics {
5858
use crate::{
5959
IInterpreterStoreV3::Set,
6060
IRaindexV7::{
61-
AddOrderV3, AfterClearV2, ClearV3, DepositV2, RemoveOrderV3, TakeOrderV3, WithdrawV2,
61+
AddOrderV3, AfterClearV2, ClearV3, DepositV2, RemoveOrderV3, TakeOrderV4, WithdrawV2,
6262
},
6363
Raindex::MetaV1_2,
6464
};
6565
use alloy::{primitives::B256, sol_types::SolEvent};
6666

6767
pub const RAINDEX_EVENT_TOPICS: [B256; 8] = [
6868
AddOrderV3::SIGNATURE_HASH,
69-
TakeOrderV3::SIGNATURE_HASH,
69+
TakeOrderV4::SIGNATURE_HASH,
7070
WithdrawV2::SIGNATURE_HASH,
7171
DepositV2::SIGNATURE_HASH,
7272
RemoveOrderV3::SIGNATURE_HASH,

‎crates/common/ARCHITECTURE.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ require its `COMMIT_SHA` env var.
2323

2424
- `add_order` — Compose Rainlang from DOTRAIN, parse to bytecode via on‑chain
2525
Parser, generate `addOrder3` call parameters, execute or simulate on a fork.
26-
- `remove_order` — Convert subgraph `SgOrder` to `removeOrder3` call, execute or
26+
- `remove_order` — Convert subgraph `SgOrder` to `removeOrder4` call, execute or
2727
return calldata.
2828
- `deposit` — ERC20 allowance check/approve and `deposit3` call
2929
builder/executor.
@@ -94,7 +94,7 @@ Target gating is used extensively:
9494

9595
### 2) Remove Order
9696

97-
- `RemoveOrderArgs` converts `SgOrder` to `removeOrder3Call` via subgraph
97+
- `RemoveOrderArgs` converts `SgOrder` to `removeOrder4Call` via subgraph
9898
traits.
9999
- Native execution mirrors `add_order` (Ledger provider + `WriteTransaction`),
100100
or return calldata only.
@@ -356,7 +356,7 @@ are provided so frontends can submit via their own providers.
356356
## Notable Dependencies (workspace crates)
357357

358358
- `raindex_bindings` — Strongly‑typed ABI for Raindex and ERC20 contracts
359-
(`addOrder3`, `removeOrder3`, `deposit3`, `withdraw3`, multicall).
359+
(`addOrder3`, `removeOrder4`, `deposit3`, `withdraw3`, multicall).
360360
- `raindex_subgraph_client` — GraphQL types and clients for raindex data;
361361
provides `Sg*` models and helpers.
362362
- `raindex_app_settings` — DOTRAIN/raindex YAML structures, validation, and spec
@@ -384,7 +384,7 @@ are provided so frontends can submit via their own providers.
384384
submit via external provider (WASM).
385385

386386
- Remove an order:
387-
1. Fetch `SgOrder` from subgraph; convert to `removeOrder3Call` and execute or
387+
1. Fetch `SgOrder` from subgraph; convert to `removeOrder4Call` and execute or
388388
export calldata.
389389

390390
- Deposit/Withdraw:

‎crates/common/src/add_order.rs‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use rain_metadata::{
3131
use rain_metadata_bindings::MetaBoard::emitMetaCall;
3232
use raindex_app_settings::deployment::DeploymentCfg;
3333
use raindex_bindings::provider::{mk_read_provider, ReadProviderError};
34-
use raindex_bindings::IRaindexV7::{addOrder4Call, EvaluableV4, OrderConfigV4, TaskV2, IOV2};
34+
use raindex_bindings::IRaindexV7::{addOrder5Call, EvaluableV4, OrderConfigV4, TaskV3, IOV2};
3535
use serde::{Deserialize, Serialize};
3636
use serde_bytes::ByteBuf;
3737
use std::collections::HashMap;
@@ -251,7 +251,7 @@ impl AddOrderArgs {
251251
pub async fn try_into_call(
252252
&self,
253253
rpcs: Vec<String>,
254-
) -> Result<addOrder4Call, AddOrderArgsError> {
254+
) -> Result<addOrder5Call, AddOrderArgsError> {
255255
let rainlang = self.compose_to_rainlang()?;
256256
let bytecode = self
257257
.try_parse_rainlang(rpcs.clone(), rainlang.clone())
@@ -273,12 +273,12 @@ impl AddOrderArgs {
273273
bytecode: post_bytecode.into(),
274274
};
275275

276-
let post_task = TaskV2 {
276+
let post_task = TaskV3 {
277277
evaluable: post_evaluable,
278278
signedContext: vec![],
279279
};
280280

281-
Ok(addOrder4Call {
281+
Ok(addOrder5Call {
282282
config: OrderConfigV4 {
283283
validInputs: self.inputs.clone(),
284284
validOutputs: self.outputs.clone(),
@@ -1656,7 +1656,7 @@ _ _: 0 0;
16561656
additional_meta: None,
16571657
};
16581658

1659-
let add_order_call = addOrder4Call {
1659+
let add_order_call = addOrder5Call {
16601660
config: OrderConfigV4 {
16611661
evaluable: EvaluableV4 {
16621662
interpreter: *local_evm.interpreter.address(),
@@ -1679,7 +1679,7 @@ _ _: 0 0;
16791679
meta: Bytes::from_str("0xff0a89c674ee7874a30058382f2a20302e2063616c63756c6174652d696f202a2f200a5f205f3a203020303b0a0a2f2a20312e2068616e646c652d696f202a2f200a3a3b011bff13109e41336ff20278186170706c69636174696f6e2f6f637465742d73747265616d").unwrap(),
16801680
},
16811681
tasks: vec![
1682-
TaskV2 {
1682+
TaskV3 {
16831683
evaluable: EvaluableV4 {
16841684
interpreter: *local_evm.interpreter.address(),
16851685
store: *local_evm.store.address(),
@@ -1702,7 +1702,7 @@ _ _: 0 0;
17021702
.unwrap();
17031703

17041704
let input = res.input.input.expect("tx request has no input");
1705-
let decoded = addOrder4Call::abi_decode(&input).unwrap();
1705+
let decoded = addOrder5Call::abi_decode(&input).unwrap();
17061706

17071707
assert_eq!(decoded.config.evaluable, add_order_call.config.evaluable);
17081708
assert_eq!(
@@ -1749,7 +1749,7 @@ _ _: 0 0;
17491749
.unwrap()
17501750
.into();
17511751

1752-
let expected_bytes: Bytes = addOrder4Call {
1752+
let expected_bytes: Bytes = addOrder5Call {
17531753
config: OrderConfigV4 {
17541754
evaluable: EvaluableV4 {
17551755
interpreter: *local_evm.interpreter.address(),
@@ -1774,7 +1774,7 @@ _ _: 0 0;
17741774
secret: U256::from(0).into(),
17751775
meta: Bytes::from_str("0xff0a89c674ee7874a30058382f2a20302e2063616c63756c6174652d696f202a2f200a5f205f3a203020303b0a0a2f2a20312e2068616e646c652d696f202a2f200a3a3b011bff13109e41336ff20278186170706c69636174696f6e2f6f637465742d73747265616d").unwrap(),
17761776
},
1777-
tasks: vec![TaskV2 {
1777+
tasks: vec![TaskV3 {
17781778
evaluable: EvaluableV4 {
17791779
interpreter: *local_evm.interpreter.address(),
17801780
store: *local_evm.store.address(),

‎crates/common/src/deposit.rs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::allowance::read_allowance;
22
use crate::transaction::{TransactionArgs, TransactionArgsError, WritableTransactionExecuteError};
33
use alloy::primitives::{Address, B256, U256};
44
use rain_math_float::{Float, FloatError};
5-
use raindex_bindings::IRaindexV7::deposit4Call;
5+
use raindex_bindings::IRaindexV7::deposit5Call;
66
#[cfg(not(target_family = "wasm"))]
77
use raindex_bindings::IERC20::approveCall;
88
use serde::{Deserialize, Serialize};
@@ -35,11 +35,11 @@ pub struct DepositArgs {
3535
pub decimals: u8,
3636
}
3737

38-
impl TryFrom<DepositArgs> for deposit4Call {
38+
impl TryFrom<DepositArgs> for deposit5Call {
3939
type Error = FloatError;
4040

4141
fn try_from(val: DepositArgs) -> Result<Self, Self::Error> {
42-
Ok(deposit4Call {
42+
Ok(deposit5Call {
4343
token: val.token,
4444
vaultId: val.vault_id,
4545
depositAmount: val.amount.get_inner(),
@@ -99,7 +99,7 @@ impl DepositArgs {
9999
) -> Result<(), DepositError> {
100100
let (ledger_client, _) = transaction_args.clone().try_into_ledger_client().await?;
101101

102-
let deposit_call: deposit4Call = self.clone().try_into()?;
102+
let deposit_call: deposit5Call = self.clone().try_into()?;
103103
let tx_request = transaction_args
104104
.try_into_transaction_request(deposit_call, transaction_args.raindex_address)?;
105105

0 commit comments

Comments
 (0)