Skip to content

Commit 0030013

Browse files
committed
chore: update mcp
1 parent 87e08ab commit 0030013

File tree

3 files changed

+63
-32
lines changed

3 files changed

+63
-32
lines changed

justfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ install-try-runtime:
6565
cargo install --git https://github.com/paritytech/try-runtime-cli --locked
6666

6767
try-runtime-upgrade-testnet:
68-
cargo build --release --features try-runtime,testnet
68+
SKIP_WASM_BUILD=0 cargo build --release -p torus-runtime --features try-runtime,testnet
6969
RUST_BACKTRACE=1 RUST_LOG=info try-runtime --runtime target/release/wbuild/torus-runtime/torus_runtime.compact.compressed.wasm on-runtime-upgrade --blocktime 8000 live --uri wss://api.testnet.torus.network
7070

7171
try-runtime-upgrade-mainnet:
72-
cargo build --release --features try-runtime
72+
SKIP_WASM_BUILD=0 cargo build --release -p torus-runtime --features try-runtime
7373
RUST_BACKTRACE=1 RUST_LOG=info try-runtime --runtime target/release/wbuild/torus-runtime/torus_runtime.compact.compressed.wasm on-runtime-upgrade --blocktime 8000 live --uri wss://api.torus.network
7474

7575
# Github Actions

mcp/src/emission.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::interfaces::runtime_types::{
44
bounded_collections::bounded_btree_map::BoundedBTreeMap,
55
pallet_permission0::permission::{
66
EnforcementAuthority, PermissionDuration, RevocationTerms,
7-
emission::{DistributionControl, EmissionAllocation},
7+
stream::{DistributionControl, StreamAllocation},
88
},
99
sp_arithmetic::per_things::Percent,
1010
};
@@ -83,17 +83,18 @@ pub async fn delegate_emission(
8383
match torus_client
8484
.permission0()
8585
.calls()
86-
.delegate_emission_permission_wait(
87-
target_keypair.public_key().to_account_id(),
88-
EmissionAllocation::Streams(BoundedBTreeMap(vec![(stream, Percent(request.amount))])),
86+
.delegate_stream_permission_wait(
8987
BoundedBTreeMap(vec![(
9088
target_keypair.public_key().to_account_id(),
9189
u16::MAX,
9290
)]),
91+
StreamAllocation::Streams(BoundedBTreeMap(vec![(stream, Percent(request.amount))])),
9392
request.distribution.as_generated_type(),
9493
request.duration.as_generated_type(),
9594
RevocationTerms::RevocableByDelegator,
9695
EnforcementAuthority::None,
96+
None,
97+
None,
9798
source_keypair,
9899
)
99100
.await

mcp/src/namespace.rs

Lines changed: 56 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ use crate::{
99
},
1010
pallet_permission0::permission::{
1111
PermissionDuration, PermissionScope, RevocationTerms,
12-
emission::{DistributionControl, EmissionAllocation},
12+
stream::{DistributionControl, StreamAllocation},
13+
wallet::WalletScopeType,
1314
},
1415
},
1516
};
@@ -57,7 +58,8 @@ pub struct PermissionSummaryResponse {
5758
pub enum Permission {
5859
Namespace((NamespacePermission, Direction)),
5960
Curator((CuratorPermission, Direction)),
60-
Emission((EmissionPermission, Direction)),
61+
Stream((StreamPermission, Direction)),
62+
Wallet((WalletPermission, Direction)),
6163
}
6264

6365
#[derive(Clone, schemars::JsonSchema, serde::Deserialize, serde::Serialize)]
@@ -76,10 +78,10 @@ pub struct NamespacePermission {
7678
pub struct CuratorPermission {}
7779

7880
#[derive(schemars::JsonSchema, serde::Deserialize, serde::Serialize)]
79-
pub struct EmissionPermission {
81+
pub struct StreamPermission {
8082
allocation: Allocation,
8183
distribution: Distribution,
82-
targets: HashMap<String, u16>,
84+
recipients: HashMap<String, u16>,
8385
accumulating: bool,
8486
}
8587

@@ -89,6 +91,19 @@ pub enum Allocation {
8991
FixedAmount(u128),
9092
}
9193

94+
#[derive(schemars::JsonSchema, serde::Deserialize, serde::Serialize)]
95+
pub struct WalletPermission {
96+
r#type: WalletPermissionType,
97+
}
98+
99+
#[derive(schemars::JsonSchema, serde::Deserialize, serde::Serialize)]
100+
pub enum WalletPermissionType {
101+
Stake {
102+
can_transfer_stake: bool,
103+
exclusive_stake_access: bool,
104+
},
105+
}
106+
92107
pub async fn create_namespace_for_agent(
93108
torus_client: &Client,
94109
request: NamespaceCreationRequest,
@@ -206,57 +221,54 @@ pub async fn get_permission_summary_for_agent(
206221
};
207222

208223
match contract.scope {
209-
PermissionScope::Emission(emission) => {
224+
PermissionScope::Stream(stream) => {
210225
let direction = if contract.delegator == account_id {
211-
let mut recipients = vec![name_or_key(&contract.recipient)];
212-
recipients.append(
213-
&mut emission
214-
.targets
215-
.0
216-
.iter()
217-
.map(|(target, _)| name_or_key(target))
218-
.collect::<Vec<String>>(),
219-
);
226+
let recipients: Vec<_> = stream
227+
.recipients
228+
.0
229+
.iter()
230+
.map(|(target, _)| name_or_key(target))
231+
.collect();
220232
Direction::DelegatingTo(recipients)
221233
} else {
222234
Direction::DelegatedFrom(name_or_key(&contract.delegator))
223235
};
224236

225-
let allocation = match emission.allocation {
226-
EmissionAllocation::Streams(bounded_btree_map) => Allocation::Streams(
237+
let allocation = match stream.allocation {
238+
StreamAllocation::Streams(bounded_btree_map) => Allocation::Streams(
227239
bounded_btree_map
228240
.0
229241
.iter()
230242
.map(|(stream, percent)| (stream.to_string(), percent.0))
231243
.collect::<HashMap<_, _>>(),
232244
),
233-
EmissionAllocation::FixedAmount(amount) => Allocation::FixedAmount(amount),
245+
StreamAllocation::FixedAmount(amount) => Allocation::FixedAmount(amount),
234246
};
235247

236-
let distribution = match emission.distribution {
248+
let distribution = match stream.distribution {
237249
DistributionControl::Manual => Distribution::Manual,
238250
DistributionControl::Automatic(value) => Distribution::Automatic(value),
239251
DistributionControl::AtBlock(value) => Distribution::AtBlock(value),
240252
DistributionControl::Interval(value) => Distribution::Interval(value),
241253
};
242254

243-
let permission = EmissionPermission {
255+
let permission = StreamPermission {
244256
allocation,
245257
distribution,
246-
targets: emission
247-
.targets
258+
recipients: stream
259+
.recipients
248260
.0
249261
.iter()
250262
.map(|(account, amount)| (name_or_key(account), *amount))
251263
.collect(),
252-
accumulating: emission.accumulating,
264+
accumulating: stream.accumulating,
253265
};
254266

255-
permissions.push(Permission::Emission((permission, direction)));
267+
permissions.push(Permission::Stream((permission, direction)));
256268
}
257-
PermissionScope::Curator(_) => {
269+
PermissionScope::Curator(curator) => {
258270
let direction = if contract.delegator == account_id {
259-
Direction::DelegatingTo(vec![name_or_key(&contract.recipient)])
271+
Direction::DelegatingTo(vec![name_or_key(&curator.recipient)])
260272
} else {
261273
Direction::DelegatedFrom(name_or_key(&contract.delegator))
262274
};
@@ -265,7 +277,7 @@ pub async fn get_permission_summary_for_agent(
265277
}
266278
PermissionScope::Namespace(namespace) => {
267279
let direction = if contract.delegator == account_id {
268-
Direction::DelegatingTo(vec![name_or_key(&contract.recipient)])
280+
Direction::DelegatingTo(vec![name_or_key(&namespace.recipient)])
269281
} else {
270282
Direction::DelegatedFrom(name_or_key(&contract.delegator))
271283
};
@@ -281,6 +293,24 @@ pub async fn get_permission_summary_for_agent(
281293
}
282294
}
283295
}
296+
PermissionScope::Wallet(wallet) => {
297+
let direction = if contract.delegator == account_id {
298+
Direction::DelegatingTo(vec![name_or_key(&wallet.recipient)])
299+
} else {
300+
Direction::DelegatedFrom(name_or_key(&contract.delegator))
301+
};
302+
303+
let permission = WalletPermission {
304+
r#type: match wallet.r#type {
305+
WalletScopeType::Stake(stake) => WalletPermissionType::Stake {
306+
can_transfer_stake: stake.can_transfer_stake,
307+
exclusive_stake_access: stake.exclusive_stake_access,
308+
},
309+
},
310+
};
311+
312+
permissions.push(Permission::Wallet((permission, direction)));
313+
}
284314
}
285315
}
286316

0 commit comments

Comments
 (0)