diff --git a/chain-signatures/README.md b/chain-signatures/README.md index 130cfb6a7..ed0128da8 100644 --- a/chain-signatures/README.md +++ b/chain-signatures/README.md @@ -44,12 +44,18 @@ Key versions refer new versions of the root key that we may choose to generate o pub const fn latest_key_version(&self) -> u32 ``` +## `experimantal_signature_deposit()` +This experimantal function calculates the fee for a signature request. The fee is volatile and depends on the number of pending requests. If used on a client side, it can give outdate results. +```rust +pub fn experimantal_signature_deposit(&self) -> u128 +``` + For more details check `User contract API` impl block in the [chain-signatures/contracts/src/lib.rs](./chain-signatures/contracts/src/lib.rs) file. # Environments Currently, we have 3 environments: -1. Mainnet: `v1.signer.near` // TODO: set when available +1. Mainnet: `v1.signer` 2. Testnet: `v1.sigenr-prod.testnet` -3. Dev: `v1.signer-dev.testnet` +3. Dev (unstable): `v1.signer-dev.testnet` Contracts can be changed from v1 to v2, etc. Older contracts should continue functioning. \ No newline at end of file diff --git a/chain-signatures/contract/src/lib.rs b/chain-signatures/contract/src/lib.rs index cab89f5b9..02d88eff2 100644 --- a/chain-signatures/contract/src/lib.rs +++ b/chain-signatures/contract/src/lib.rs @@ -135,7 +135,7 @@ impl VersionedMpcContract { } // Check deposit let deposit = env::attached_deposit(); - let required_deposit = self.signature_deposit(); + let required_deposit = self.experimantal_signature_deposit(); if deposit.as_yoctonear() < required_deposit { return Err(InvalidParameters::InsufficientDeposit.message(format!( "Attached {}, Required {}", @@ -208,6 +208,23 @@ impl VersionedMpcContract { pub const fn latest_key_version(&self) -> u32 { 0 } + + /// This experimantal function calculates the fee for a signature request. + /// The fee is volatile and depends on the number of pending requests. + /// If used on a client side, it can give outdate results. + pub fn experimantal_signature_deposit(&self) -> u128 { + const CHEAP_REQUESTS: u32 = 3; + let pending_requests = match self { + Self::V0(mpc_contract) => mpc_contract.request_counter, + }; + match pending_requests { + 0..=CHEAP_REQUESTS => 1, + _ => { + (pending_requests - CHEAP_REQUESTS) as u128 + * NearToken::from_millinear(50).as_yoctonear() + } + } + } } // Node API @@ -769,20 +786,6 @@ impl VersionedMpcContract { } } - fn signature_deposit(&self) -> u128 { - const CHEAP_REQUESTS: u32 = 3; - let pending_requests = match self { - Self::V0(mpc_contract) => mpc_contract.request_counter, - }; - match pending_requests { - 0..=CHEAP_REQUESTS => 1, - _ => { - (pending_requests - CHEAP_REQUESTS) as u128 - * NearToken::from_millinear(50).as_yoctonear() - } - } - } - fn threshold(&self) -> Result { match self { Self::V0(contract) => match &contract.protocol_state {