chore(contract): remove keypackage refs, regen bindings (#24)

This commit is contained in:
Aaryamann Challani
2024-07-26 23:08:41 +05:30
committed by GitHub
parent ebeabffd80
commit f819a58493
6 changed files with 56 additions and 1914 deletions

View File

@@ -1,24 +1,14 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;
struct KeyPackage {
// store serialized onchain
bytes[] data;
}
struct UserInfo {
uint256[] keyPackageIndices;
bytes signaturePubKey;
}
interface IScKeystore {
function userExists(address user) external view returns (bool);
function addUser(address user, bytes calldata signaturePubKey, KeyPackage calldata keyPackage) external;
function addUser(address user, bytes calldata signaturePubKey) external;
function getUser(address user) external view returns (UserInfo memory);
function addKeyPackage(KeyPackage calldata) external;
function getAvailableKeyPackage(address user) external view returns (KeyPackage memory);
}

View File

@@ -2,19 +2,16 @@
pragma solidity 0.8.24;
import { Ownable } from "Openzeppelin/access/Ownable.sol";
import { IScKeystore, UserInfo, KeyPackage } from "./IScKeystore.sol";
import { IScKeystore, UserInfo } from "./IScKeystore.sol";
error UserAlreadyExists();
error MalformedKeyPackage();
error MalformedUserInfo();
error UserDoesNotExist();
contract ScKeystore is Ownable, IScKeystore {
event UserAdded(address user, bytes signaturePubKey);
event UserKeyPackageAdded(address indexed user, uint256 index);
mapping(address user => UserInfo userInfo) private users;
KeyPackage[] private keyPackages;
constructor(address initialOwner) Ownable(initialOwner) { }
@@ -22,17 +19,11 @@ contract ScKeystore is Ownable, IScKeystore {
return users[user].signaturePubKey.length > 0;
}
function addUser(address user, bytes calldata signaturePubKey, KeyPackage calldata keyPackage) external onlyOwner {
function addUser(address user, bytes calldata signaturePubKey) external onlyOwner {
if (signaturePubKey.length == 0) revert MalformedUserInfo();
if (keyPackage.data.length == 0) revert MalformedKeyPackage();
if (userExists(user)) revert UserAlreadyExists();
keyPackages.push(keyPackage);
uint256 keyPackageIndex = keyPackages.length - 1;
users[user] = UserInfo(new uint256[](0), signaturePubKey);
users[user].signaturePubKey = signaturePubKey;
users[user].keyPackageIndices.push(keyPackageIndex);
users[user] = UserInfo(signaturePubKey);
emit UserAdded(user, signaturePubKey);
}
@@ -40,30 +31,4 @@ contract ScKeystore is Ownable, IScKeystore {
function getUser(address user) external view returns (UserInfo memory) {
return users[user];
}
function addKeyPackage(KeyPackage calldata keyPackage) external {
if (keyPackage.data.length == 0) revert MalformedKeyPackage();
if (!userExists(msg.sender)) revert UserDoesNotExist();
keyPackages.push(keyPackage);
uint256 keyPackageIndex = keyPackages.length - 1;
users[msg.sender].keyPackageIndices.push(keyPackageIndex);
emit UserKeyPackageAdded(msg.sender, keyPackageIndex);
}
function getAvailableKeyPackage(address user) external view returns (KeyPackage memory) {
UserInfo memory userInfo = users[user];
uint256 keyPackageIndex = userInfo.keyPackageIndices[userInfo.keyPackageIndices.length - 1];
return keyPackages[keyPackageIndex];
}
function getAllKeyPackagesForUser(address user) external view returns (KeyPackage[] memory) {
UserInfo memory userInfo = users[user];
KeyPackage[] memory userKeyPackages = new KeyPackage[](userInfo.keyPackageIndices.length);
for (uint256 i = 0; i < userInfo.keyPackageIndices.length; i++) {
userKeyPackages[i] = keyPackages[userInfo.keyPackageIndices[i]];
}
return userKeyPackages;
}
}

View File

@@ -18,8 +18,7 @@ contract ScKeystoreTest is Test {
}
function addUser() internal {
KeyPackage memory keyPackage = KeyPackage({ data: new bytes[](1) });
s.addUser(address(this), "0x", keyPackage);
s.addUser(address(this), "0x");
}
function test__owner() public view {
@@ -32,7 +31,7 @@ contract ScKeystoreTest is Test {
function test__addUser__reverts__whenUserInfoIsMalformed() public {
vm.expectRevert(MalformedUserInfo.selector);
s.addUser(address(this), "", KeyPackage({ data: new bytes[](0) }));
s.addUser(address(this), "");
}
function test__addUser__reverts__whenUserAlreadyExists() public {
@@ -57,12 +56,5 @@ contract ScKeystoreTest is Test {
addUser();
UserInfo memory userInfo = s.getUser(address(this));
assert(userInfo.signaturePubKey.length == 2);
assert(userInfo.keyPackageIndices.length == 1);
}
function test__getAllKeyPackagesForUser__returnsKeyPackages__whenUserExists() public {
addUser();
KeyPackage[] memory keyPackages = s.getAllKeyPackagesForUser(address(this));
assert(keyPackages.length == 1);
}
}

File diff suppressed because one or more lines are too long

View File

@@ -3,17 +3,11 @@
Generated by the following Solidity interface...
```solidity
interface IScKeystore {
struct KeyPackage {
bytes[] data;
}
struct UserInfo {
uint256[] keyPackageIndices;
bytes signaturePubKey;
}
function addKeyPackage(KeyPackage memory) external;
function addUser(address user, bytes memory signaturePubKey, KeyPackage memory keyPackage) external;
function getAvailableKeyPackage(address user) external view returns (KeyPackage memory);
function addUser(address user, bytes memory signaturePubKey) external;
function getUser(address user) external view returns (UserInfo memory);
function userExists(address user) external view returns (bool);
}
@@ -22,26 +16,6 @@ interface IScKeystore {
...which was generated by the following JSON ABI:
```json
[
{
"type": "function",
"name": "addKeyPackage",
"inputs": [
{
"name": "",
"type": "tuple",
"internalType": "struct KeyPackage",
"components": [
{
"name": "data",
"type": "bytes[]",
"internalType": "bytes[]"
}
]
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "addUser",
@@ -55,49 +29,11 @@ interface IScKeystore {
"name": "signaturePubKey",
"type": "bytes",
"internalType": "bytes"
},
{
"name": "keyPackage",
"type": "tuple",
"internalType": "struct KeyPackage",
"components": [
{
"name": "data",
"type": "bytes[]",
"internalType": "bytes[]"
}
]
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "getAvailableKeyPackage",
"inputs": [
{
"name": "user",
"type": "address",
"internalType": "address"
}
],
"outputs": [
{
"name": "",
"type": "tuple",
"internalType": "struct KeyPackage",
"components": [
{
"name": "data",
"type": "bytes[]",
"internalType": "bytes[]"
}
]
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "getUser",
@@ -114,11 +50,6 @@ interface IScKeystore {
"type": "tuple",
"internalType": "struct UserInfo",
"components": [
{
"name": "keyPackageIndices",
"type": "uint256[]",
"internalType": "uint256[]"
},
{
"name": "signaturePubKey",
"type": "bytes",
@@ -175,218 +106,20 @@ pub mod IScKeystore {
b"",
);
/**```solidity
struct KeyPackage { bytes[] data; }
```*/
#[allow(non_camel_case_types, non_snake_case)]
#[derive(Clone)]
pub struct KeyPackage {
pub data: alloy::sol_types::private::Vec<alloy::sol_types::private::Bytes>,
}
#[allow(non_camel_case_types, non_snake_case, clippy::style)]
const _: () = {
use alloy::sol_types as alloy_sol_types;
#[doc(hidden)]
type UnderlyingSolTuple<'a> = (
alloy::sol_types::sol_data::Array<alloy::sol_types::sol_data::Bytes>,
);
#[doc(hidden)]
type UnderlyingRustTuple<'a> = (
alloy::sol_types::private::Vec<alloy::sol_types::private::Bytes>,
);
#[cfg(test)]
#[allow(dead_code, unreachable_patterns)]
fn _type_assertion(
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
) {
match _t {
alloy_sol_types::private::AssertTypeEq::<
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
>(_) => {}
}
}
#[automatically_derived]
#[doc(hidden)]
impl ::core::convert::From<KeyPackage> for UnderlyingRustTuple<'_> {
fn from(value: KeyPackage) -> Self {
(value.data,)
}
}
#[automatically_derived]
#[doc(hidden)]
impl ::core::convert::From<UnderlyingRustTuple<'_>> for KeyPackage {
fn from(tuple: UnderlyingRustTuple<'_>) -> Self {
Self { data: tuple.0 }
}
}
#[automatically_derived]
impl alloy_sol_types::SolValue for KeyPackage {
type SolType = Self;
}
#[automatically_derived]
impl alloy_sol_types::private::SolTypeValue<Self> for KeyPackage {
#[inline]
fn stv_to_tokens(&self) -> <Self as alloy_sol_types::SolType>::Token<'_> {
(
<alloy::sol_types::sol_data::Array<
alloy::sol_types::sol_data::Bytes,
> as alloy_sol_types::SolType>::tokenize(&self.data),
)
}
#[inline]
fn stv_abi_encoded_size(&self) -> usize {
if let Some(size) = <Self as alloy_sol_types::SolType>::ENCODED_SIZE {
return size;
}
let tuple = <UnderlyingRustTuple<
'_,
> as ::core::convert::From<Self>>::from(self.clone());
<UnderlyingSolTuple<
'_,
> as alloy_sol_types::SolType>::abi_encoded_size(&tuple)
}
#[inline]
fn stv_eip712_data_word(&self) -> alloy_sol_types::Word {
<Self as alloy_sol_types::SolStruct>::eip712_hash_struct(self)
}
#[inline]
fn stv_abi_encode_packed_to(
&self,
out: &mut alloy_sol_types::private::Vec<u8>,
) {
let tuple = <UnderlyingRustTuple<
'_,
> as ::core::convert::From<Self>>::from(self.clone());
<UnderlyingSolTuple<
'_,
> as alloy_sol_types::SolType>::abi_encode_packed_to(&tuple, out)
}
#[inline]
fn stv_abi_packed_encoded_size(&self) -> usize {
if let Some(size) = <Self as alloy_sol_types::SolType>::PACKED_ENCODED_SIZE {
return size;
}
let tuple = <UnderlyingRustTuple<
'_,
> as ::core::convert::From<Self>>::from(self.clone());
<UnderlyingSolTuple<
'_,
> as alloy_sol_types::SolType>::abi_packed_encoded_size(&tuple)
}
}
#[automatically_derived]
impl alloy_sol_types::SolType for KeyPackage {
type RustType = Self;
type Token<'a> = <UnderlyingSolTuple<
'a,
> as alloy_sol_types::SolType>::Token<'a>;
const SOL_NAME: &'static str = <Self as alloy_sol_types::SolStruct>::NAME;
const ENCODED_SIZE: Option<usize> = <UnderlyingSolTuple<
'_,
> as alloy_sol_types::SolType>::ENCODED_SIZE;
const PACKED_ENCODED_SIZE: Option<usize> = <UnderlyingSolTuple<
'_,
> as alloy_sol_types::SolType>::PACKED_ENCODED_SIZE;
#[inline]
fn valid_token(token: &Self::Token<'_>) -> bool {
<UnderlyingSolTuple<'_> as alloy_sol_types::SolType>::valid_token(token)
}
#[inline]
fn detokenize(token: Self::Token<'_>) -> Self::RustType {
let tuple = <UnderlyingSolTuple<
'_,
> as alloy_sol_types::SolType>::detokenize(token);
<Self as ::core::convert::From<UnderlyingRustTuple<'_>>>::from(tuple)
}
}
#[automatically_derived]
impl alloy_sol_types::SolStruct for KeyPackage {
const NAME: &'static str = "KeyPackage";
#[inline]
fn eip712_root_type() -> alloy_sol_types::private::Cow<'static, str> {
alloy_sol_types::private::Cow::Borrowed("KeyPackage(bytes[] data)")
}
#[inline]
fn eip712_components() -> alloy_sol_types::private::Vec<
alloy_sol_types::private::Cow<'static, str>,
> {
alloy_sol_types::private::Vec::new()
}
#[inline]
fn eip712_encode_type() -> alloy_sol_types::private::Cow<'static, str> {
<Self as alloy_sol_types::SolStruct>::eip712_root_type()
}
#[inline]
fn eip712_encode_data(&self) -> alloy_sol_types::private::Vec<u8> {
<alloy::sol_types::sol_data::Array<
alloy::sol_types::sol_data::Bytes,
> as alloy_sol_types::SolType>::eip712_data_word(&self.data)
.0
.to_vec()
}
}
#[automatically_derived]
impl alloy_sol_types::EventTopic for KeyPackage {
#[inline]
fn topic_preimage_length(rust: &Self::RustType) -> usize {
0usize
+ <alloy::sol_types::sol_data::Array<
alloy::sol_types::sol_data::Bytes,
> as alloy_sol_types::EventTopic>::topic_preimage_length(&rust.data)
}
#[inline]
fn encode_topic_preimage(
rust: &Self::RustType,
out: &mut alloy_sol_types::private::Vec<u8>,
) {
out.reserve(
<Self as alloy_sol_types::EventTopic>::topic_preimage_length(rust),
);
<alloy::sol_types::sol_data::Array<
alloy::sol_types::sol_data::Bytes,
> as alloy_sol_types::EventTopic>::encode_topic_preimage(
&rust.data,
out,
);
}
#[inline]
fn encode_topic(
rust: &Self::RustType,
) -> alloy_sol_types::abi::token::WordToken {
let mut out = alloy_sol_types::private::Vec::new();
<Self as alloy_sol_types::EventTopic>::encode_topic_preimage(
rust,
&mut out,
);
alloy_sol_types::abi::token::WordToken(
alloy_sol_types::private::keccak256(out),
)
}
}
};
/**```solidity
struct UserInfo { uint256[] keyPackageIndices; bytes signaturePubKey; }
struct UserInfo { bytes signaturePubKey; }
```*/
#[allow(non_camel_case_types, non_snake_case)]
#[derive(Clone)]
pub struct UserInfo {
pub keyPackageIndices: alloy::sol_types::private::Vec<
alloy::sol_types::private::U256,
>,
pub signaturePubKey: alloy::sol_types::private::Bytes,
}
#[allow(non_camel_case_types, non_snake_case, clippy::style)]
const _: () = {
use alloy::sol_types as alloy_sol_types;
#[doc(hidden)]
type UnderlyingSolTuple<'a> = (
alloy::sol_types::sol_data::Array<alloy::sol_types::sol_data::Uint<256>>,
alloy::sol_types::sol_data::Bytes,
);
type UnderlyingSolTuple<'a> = (alloy::sol_types::sol_data::Bytes,);
#[doc(hidden)]
type UnderlyingRustTuple<'a> = (
alloy::sol_types::private::Vec<alloy::sol_types::private::U256>,
alloy::sol_types::private::Bytes,
);
type UnderlyingRustTuple<'a> = (alloy::sol_types::private::Bytes,);
#[cfg(test)]
#[allow(dead_code, unreachable_patterns)]
fn _type_assertion(
@@ -402,17 +135,14 @@ struct UserInfo { uint256[] keyPackageIndices; bytes signaturePubKey; }
#[doc(hidden)]
impl ::core::convert::From<UserInfo> for UnderlyingRustTuple<'_> {
fn from(value: UserInfo) -> Self {
(value.keyPackageIndices, value.signaturePubKey)
(value.signaturePubKey,)
}
}
#[automatically_derived]
#[doc(hidden)]
impl ::core::convert::From<UnderlyingRustTuple<'_>> for UserInfo {
fn from(tuple: UnderlyingRustTuple<'_>) -> Self {
Self {
keyPackageIndices: tuple.0,
signaturePubKey: tuple.1,
}
Self { signaturePubKey: tuple.0 }
}
}
#[automatically_derived]
@@ -424,9 +154,6 @@ struct UserInfo { uint256[] keyPackageIndices; bytes signaturePubKey; }
#[inline]
fn stv_to_tokens(&self) -> <Self as alloy_sol_types::SolType>::Token<'_> {
(
<alloy::sol_types::sol_data::Array<
alloy::sol_types::sol_data::Uint<256>,
> as alloy_sol_types::SolType>::tokenize(&self.keyPackageIndices),
<alloy::sol_types::sol_data::Bytes as alloy_sol_types::SolType>::tokenize(
&self.signaturePubKey,
),
@@ -504,7 +231,7 @@ struct UserInfo { uint256[] keyPackageIndices; bytes signaturePubKey; }
#[inline]
fn eip712_root_type() -> alloy_sol_types::private::Cow<'static, str> {
alloy_sol_types::private::Cow::Borrowed(
"UserInfo(uint256[] keyPackageIndices,bytes signaturePubKey)",
"UserInfo(bytes signaturePubKey)",
)
}
#[inline]
@@ -519,19 +246,11 @@ struct UserInfo { uint256[] keyPackageIndices; bytes signaturePubKey; }
}
#[inline]
fn eip712_encode_data(&self) -> alloy_sol_types::private::Vec<u8> {
[
<alloy::sol_types::sol_data::Array<
alloy::sol_types::sol_data::Uint<256>,
> as alloy_sol_types::SolType>::eip712_data_word(
&self.keyPackageIndices,
)
.0,
<alloy::sol_types::sol_data::Bytes as alloy_sol_types::SolType>::eip712_data_word(
&self.signaturePubKey,
)
.0,
]
.concat()
<alloy::sol_types::sol_data::Bytes as alloy_sol_types::SolType>::eip712_data_word(
&self.signaturePubKey,
)
.0
.to_vec()
}
}
#[automatically_derived]
@@ -539,11 +258,6 @@ struct UserInfo { uint256[] keyPackageIndices; bytes signaturePubKey; }
#[inline]
fn topic_preimage_length(rust: &Self::RustType) -> usize {
0usize
+ <alloy::sol_types::sol_data::Array<
alloy::sol_types::sol_data::Uint<256>,
> as alloy_sol_types::EventTopic>::topic_preimage_length(
&rust.keyPackageIndices,
)
+ <alloy::sol_types::sol_data::Bytes as alloy_sol_types::EventTopic>::topic_preimage_length(
&rust.signaturePubKey,
)
@@ -556,12 +270,6 @@ struct UserInfo { uint256[] keyPackageIndices; bytes signaturePubKey; }
out.reserve(
<Self as alloy_sol_types::EventTopic>::topic_preimage_length(rust),
);
<alloy::sol_types::sol_data::Array<
alloy::sol_types::sol_data::Uint<256>,
> as alloy_sol_types::EventTopic>::encode_topic_preimage(
&rust.keyPackageIndices,
out,
);
<alloy::sol_types::sol_data::Bytes as alloy_sol_types::EventTopic>::encode_topic_preimage(
&rust.signaturePubKey,
out,
@@ -582,133 +290,17 @@ struct UserInfo { uint256[] keyPackageIndices; bytes signaturePubKey; }
}
}
};
/**Function with signature `addKeyPackage((bytes[]))` and selector `0xfe52f796`.
/**Function with signature `addUser(address,bytes)` and selector `0xe3eccd10`.
```solidity
function addKeyPackage(KeyPackage memory) external;
```*/
#[allow(non_camel_case_types, non_snake_case)]
#[derive(Clone)]
pub struct addKeyPackageCall {
pub _0: <KeyPackage as alloy::sol_types::SolType>::RustType,
}
///Container type for the return parameters of the [`addKeyPackage((bytes[]))`](addKeyPackageCall) function.
#[allow(non_camel_case_types, non_snake_case)]
#[derive(Clone)]
pub struct addKeyPackageReturn {}
#[allow(non_camel_case_types, non_snake_case, clippy::style)]
const _: () = {
use alloy::sol_types as alloy_sol_types;
{
#[doc(hidden)]
type UnderlyingSolTuple<'a> = (KeyPackage,);
#[doc(hidden)]
type UnderlyingRustTuple<'a> = (
<KeyPackage as alloy::sol_types::SolType>::RustType,
);
#[cfg(test)]
#[allow(dead_code, unreachable_patterns)]
fn _type_assertion(
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
) {
match _t {
alloy_sol_types::private::AssertTypeEq::<
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
>(_) => {}
}
}
#[automatically_derived]
#[doc(hidden)]
impl ::core::convert::From<addKeyPackageCall> for UnderlyingRustTuple<'_> {
fn from(value: addKeyPackageCall) -> Self {
(value._0,)
}
}
#[automatically_derived]
#[doc(hidden)]
impl ::core::convert::From<UnderlyingRustTuple<'_>> for addKeyPackageCall {
fn from(tuple: UnderlyingRustTuple<'_>) -> Self {
Self { _0: tuple.0 }
}
}
}
{
#[doc(hidden)]
type UnderlyingSolTuple<'a> = ();
#[doc(hidden)]
type UnderlyingRustTuple<'a> = ();
#[cfg(test)]
#[allow(dead_code, unreachable_patterns)]
fn _type_assertion(
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
) {
match _t {
alloy_sol_types::private::AssertTypeEq::<
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
>(_) => {}
}
}
#[automatically_derived]
#[doc(hidden)]
impl ::core::convert::From<addKeyPackageReturn> for UnderlyingRustTuple<'_> {
fn from(value: addKeyPackageReturn) -> Self {
()
}
}
#[automatically_derived]
#[doc(hidden)]
impl ::core::convert::From<UnderlyingRustTuple<'_>> for addKeyPackageReturn {
fn from(tuple: UnderlyingRustTuple<'_>) -> Self {
Self {}
}
}
}
#[automatically_derived]
impl alloy_sol_types::SolCall for addKeyPackageCall {
type Parameters<'a> = (KeyPackage,);
type Token<'a> = <Self::Parameters<
'a,
> as alloy_sol_types::SolType>::Token<'a>;
type Return = addKeyPackageReturn;
type ReturnTuple<'a> = ();
type ReturnToken<'a> = <Self::ReturnTuple<
'a,
> as alloy_sol_types::SolType>::Token<'a>;
const SIGNATURE: &'static str = "addKeyPackage((bytes[]))";
const SELECTOR: [u8; 4] = [254u8, 82u8, 247u8, 150u8];
#[inline]
fn new<'a>(
tuple: <Self::Parameters<'a> as alloy_sol_types::SolType>::RustType,
) -> Self {
tuple.into()
}
#[inline]
fn tokenize(&self) -> Self::Token<'_> {
(<KeyPackage as alloy_sol_types::SolType>::tokenize(&self._0),)
}
#[inline]
fn abi_decode_returns(
data: &[u8],
validate: bool,
) -> alloy_sol_types::Result<Self::Return> {
<Self::ReturnTuple<
'_,
> as alloy_sol_types::SolType>::abi_decode_sequence(data, validate)
.map(Into::into)
}
}
};
/**Function with signature `addUser(address,bytes,(bytes[]))` and selector `0xc8d178b2`.
```solidity
function addUser(address user, bytes memory signaturePubKey, KeyPackage memory keyPackage) external;
function addUser(address user, bytes memory signaturePubKey) external;
```*/
#[allow(non_camel_case_types, non_snake_case)]
#[derive(Clone)]
pub struct addUserCall {
pub user: alloy::sol_types::private::Address,
pub signaturePubKey: alloy::sol_types::private::Bytes,
pub keyPackage: <KeyPackage as alloy::sol_types::SolType>::RustType,
}
///Container type for the return parameters of the [`addUser(address,bytes,(bytes[]))`](addUserCall) function.
///Container type for the return parameters of the [`addUser(address,bytes)`](addUserCall) function.
#[allow(non_camel_case_types, non_snake_case)]
#[derive(Clone)]
pub struct addUserReturn {}
@@ -720,13 +312,11 @@ function addUser(address user, bytes memory signaturePubKey, KeyPackage memory k
type UnderlyingSolTuple<'a> = (
alloy::sol_types::sol_data::Address,
alloy::sol_types::sol_data::Bytes,
KeyPackage,
);
#[doc(hidden)]
type UnderlyingRustTuple<'a> = (
alloy::sol_types::private::Address,
alloy::sol_types::private::Bytes,
<KeyPackage as alloy::sol_types::SolType>::RustType,
);
#[cfg(test)]
#[allow(dead_code, unreachable_patterns)]
@@ -743,7 +333,7 @@ function addUser(address user, bytes memory signaturePubKey, KeyPackage memory k
#[doc(hidden)]
impl ::core::convert::From<addUserCall> for UnderlyingRustTuple<'_> {
fn from(value: addUserCall) -> Self {
(value.user, value.signaturePubKey, value.keyPackage)
(value.user, value.signaturePubKey)
}
}
#[automatically_derived]
@@ -753,7 +343,6 @@ function addUser(address user, bytes memory signaturePubKey, KeyPackage memory k
Self {
user: tuple.0,
signaturePubKey: tuple.1,
keyPackage: tuple.2,
}
}
}
@@ -794,7 +383,6 @@ function addUser(address user, bytes memory signaturePubKey, KeyPackage memory k
type Parameters<'a> = (
alloy::sol_types::sol_data::Address,
alloy::sol_types::sol_data::Bytes,
KeyPackage,
);
type Token<'a> = <Self::Parameters<
'a,
@@ -804,8 +392,8 @@ function addUser(address user, bytes memory signaturePubKey, KeyPackage memory k
type ReturnToken<'a> = <Self::ReturnTuple<
'a,
> as alloy_sol_types::SolType>::Token<'a>;
const SIGNATURE: &'static str = "addUser(address,bytes,(bytes[]))";
const SELECTOR: [u8; 4] = [200u8, 209u8, 120u8, 178u8];
const SIGNATURE: &'static str = "addUser(address,bytes)";
const SELECTOR: [u8; 4] = [227u8, 236u8, 205u8, 16u8];
#[inline]
fn new<'a>(
tuple: <Self::Parameters<'a> as alloy_sol_types::SolType>::RustType,
@@ -821,132 +409,6 @@ function addUser(address user, bytes memory signaturePubKey, KeyPackage memory k
<alloy::sol_types::sol_data::Bytes as alloy_sol_types::SolType>::tokenize(
&self.signaturePubKey,
),
<KeyPackage as alloy_sol_types::SolType>::tokenize(&self.keyPackage),
)
}
#[inline]
fn abi_decode_returns(
data: &[u8],
validate: bool,
) -> alloy_sol_types::Result<Self::Return> {
<Self::ReturnTuple<
'_,
> as alloy_sol_types::SolType>::abi_decode_sequence(data, validate)
.map(Into::into)
}
}
};
/**Function with signature `getAvailableKeyPackage(address)` and selector `0x33cf520c`.
```solidity
function getAvailableKeyPackage(address user) external view returns (KeyPackage memory);
```*/
#[allow(non_camel_case_types, non_snake_case)]
#[derive(Clone)]
pub struct getAvailableKeyPackageCall {
pub user: alloy::sol_types::private::Address,
}
///Container type for the return parameters of the [`getAvailableKeyPackage(address)`](getAvailableKeyPackageCall) function.
#[allow(non_camel_case_types, non_snake_case)]
#[derive(Clone)]
pub struct getAvailableKeyPackageReturn {
pub _0: <KeyPackage as alloy::sol_types::SolType>::RustType,
}
#[allow(non_camel_case_types, non_snake_case, clippy::style)]
const _: () = {
use alloy::sol_types as alloy_sol_types;
{
#[doc(hidden)]
type UnderlyingSolTuple<'a> = (alloy::sol_types::sol_data::Address,);
#[doc(hidden)]
type UnderlyingRustTuple<'a> = (alloy::sol_types::private::Address,);
#[cfg(test)]
#[allow(dead_code, unreachable_patterns)]
fn _type_assertion(
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
) {
match _t {
alloy_sol_types::private::AssertTypeEq::<
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
>(_) => {}
}
}
#[automatically_derived]
#[doc(hidden)]
impl ::core::convert::From<getAvailableKeyPackageCall>
for UnderlyingRustTuple<'_> {
fn from(value: getAvailableKeyPackageCall) -> Self {
(value.user,)
}
}
#[automatically_derived]
#[doc(hidden)]
impl ::core::convert::From<UnderlyingRustTuple<'_>>
for getAvailableKeyPackageCall {
fn from(tuple: UnderlyingRustTuple<'_>) -> Self {
Self { user: tuple.0 }
}
}
}
{
#[doc(hidden)]
type UnderlyingSolTuple<'a> = (KeyPackage,);
#[doc(hidden)]
type UnderlyingRustTuple<'a> = (
<KeyPackage as alloy::sol_types::SolType>::RustType,
);
#[cfg(test)]
#[allow(dead_code, unreachable_patterns)]
fn _type_assertion(
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
) {
match _t {
alloy_sol_types::private::AssertTypeEq::<
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
>(_) => {}
}
}
#[automatically_derived]
#[doc(hidden)]
impl ::core::convert::From<getAvailableKeyPackageReturn>
for UnderlyingRustTuple<'_> {
fn from(value: getAvailableKeyPackageReturn) -> Self {
(value._0,)
}
}
#[automatically_derived]
#[doc(hidden)]
impl ::core::convert::From<UnderlyingRustTuple<'_>>
for getAvailableKeyPackageReturn {
fn from(tuple: UnderlyingRustTuple<'_>) -> Self {
Self { _0: tuple.0 }
}
}
}
#[automatically_derived]
impl alloy_sol_types::SolCall for getAvailableKeyPackageCall {
type Parameters<'a> = (alloy::sol_types::sol_data::Address,);
type Token<'a> = <Self::Parameters<
'a,
> as alloy_sol_types::SolType>::Token<'a>;
type Return = getAvailableKeyPackageReturn;
type ReturnTuple<'a> = (KeyPackage,);
type ReturnToken<'a> = <Self::ReturnTuple<
'a,
> as alloy_sol_types::SolType>::Token<'a>;
const SIGNATURE: &'static str = "getAvailableKeyPackage(address)";
const SELECTOR: [u8; 4] = [51u8, 207u8, 82u8, 12u8];
#[inline]
fn new<'a>(
tuple: <Self::Parameters<'a> as alloy_sol_types::SolType>::RustType,
) -> Self {
tuple.into()
}
#[inline]
fn tokenize(&self) -> Self::Token<'_> {
(
<alloy::sol_types::sol_data::Address as alloy_sol_types::SolType>::tokenize(
&self.user,
),
)
}
#[inline]
@@ -1203,9 +665,7 @@ function userExists(address user) external view returns (bool);
};
///Container for all the [`IScKeystore`](self) function calls.
pub enum IScKeystoreCalls {
addKeyPackage(addKeyPackageCall),
addUser(addUserCall),
getAvailableKeyPackage(getAvailableKeyPackageCall),
getUser(getUserCall),
userExists(userExistsCall),
}
@@ -1219,27 +679,19 @@ function userExists(address user) external view returns (bool);
/// Prefer using `SolInterface` methods instead.
pub const SELECTORS: &'static [[u8; 4usize]] = &[
[14u8, 102u8, 110u8, 73u8],
[51u8, 207u8, 82u8, 12u8],
[111u8, 119u8, 146u8, 107u8],
[200u8, 209u8, 120u8, 178u8],
[254u8, 82u8, 247u8, 150u8],
[227u8, 236u8, 205u8, 16u8],
];
}
#[automatically_derived]
impl alloy_sol_types::SolInterface for IScKeystoreCalls {
const NAME: &'static str = "IScKeystoreCalls";
const MIN_DATA_LENGTH: usize = 32usize;
const COUNT: usize = 5usize;
const COUNT: usize = 3usize;
#[inline]
fn selector(&self) -> [u8; 4] {
match self {
Self::addKeyPackage(_) => {
<addKeyPackageCall as alloy_sol_types::SolCall>::SELECTOR
}
Self::addUser(_) => <addUserCall as alloy_sol_types::SolCall>::SELECTOR,
Self::getAvailableKeyPackage(_) => {
<getAvailableKeyPackageCall as alloy_sol_types::SolCall>::SELECTOR
}
Self::getUser(_) => <getUserCall as alloy_sol_types::SolCall>::SELECTOR,
Self::userExists(_) => {
<userExistsCall as alloy_sol_types::SolCall>::SELECTOR
@@ -1278,19 +730,6 @@ function userExists(address user) external view returns (bool);
}
userExists
},
{
fn getAvailableKeyPackage(
data: &[u8],
validate: bool,
) -> alloy_sol_types::Result<IScKeystoreCalls> {
<getAvailableKeyPackageCall as alloy_sol_types::SolCall>::abi_decode_raw(
data,
validate,
)
.map(IScKeystoreCalls::getAvailableKeyPackage)
}
getAvailableKeyPackage
},
{
fn getUser(
data: &[u8],
@@ -1317,19 +756,6 @@ function userExists(address user) external view returns (bool);
}
addUser
},
{
fn addKeyPackage(
data: &[u8],
validate: bool,
) -> alloy_sol_types::Result<IScKeystoreCalls> {
<addKeyPackageCall as alloy_sol_types::SolCall>::abi_decode_raw(
data,
validate,
)
.map(IScKeystoreCalls::addKeyPackage)
}
addKeyPackage
},
];
let Ok(idx) = Self::SELECTORS.binary_search(&selector) else {
return Err(
@@ -1344,19 +770,9 @@ function userExists(address user) external view returns (bool);
#[inline]
fn abi_encoded_size(&self) -> usize {
match self {
Self::addKeyPackage(inner) => {
<addKeyPackageCall as alloy_sol_types::SolCall>::abi_encoded_size(
inner,
)
}
Self::addUser(inner) => {
<addUserCall as alloy_sol_types::SolCall>::abi_encoded_size(inner)
}
Self::getAvailableKeyPackage(inner) => {
<getAvailableKeyPackageCall as alloy_sol_types::SolCall>::abi_encoded_size(
inner,
)
}
Self::getUser(inner) => {
<getUserCall as alloy_sol_types::SolCall>::abi_encoded_size(inner)
}
@@ -1368,21 +784,9 @@ function userExists(address user) external view returns (bool);
#[inline]
fn abi_encode_raw(&self, out: &mut alloy_sol_types::private::Vec<u8>) {
match self {
Self::addKeyPackage(inner) => {
<addKeyPackageCall as alloy_sol_types::SolCall>::abi_encode_raw(
inner,
out,
)
}
Self::addUser(inner) => {
<addUserCall as alloy_sol_types::SolCall>::abi_encode_raw(inner, out)
}
Self::getAvailableKeyPackage(inner) => {
<getAvailableKeyPackageCall as alloy_sol_types::SolCall>::abi_encode_raw(
inner,
out,
)
}
Self::getUser(inner) => {
<getUserCall as alloy_sol_types::SolCall>::abi_encode_raw(inner, out)
}
@@ -1559,35 +963,19 @@ the bytecode concatenated with the constructor's ABI-encoded arguments.*/
) -> alloy_contract::SolCallBuilder<T, &P, C, N> {
alloy_contract::SolCallBuilder::new_sol(&self.provider, &self.address, call)
}
///Creates a new call builder for the [`addKeyPackage`] function.
pub fn addKeyPackage(
&self,
_0: <KeyPackage as alloy::sol_types::SolType>::RustType,
) -> alloy_contract::SolCallBuilder<T, &P, addKeyPackageCall, N> {
self.call_builder(&addKeyPackageCall { _0 })
}
///Creates a new call builder for the [`addUser`] function.
pub fn addUser(
&self,
user: alloy::sol_types::private::Address,
signaturePubKey: alloy::sol_types::private::Bytes,
keyPackage: <KeyPackage as alloy::sol_types::SolType>::RustType,
) -> alloy_contract::SolCallBuilder<T, &P, addUserCall, N> {
self.call_builder(
&addUserCall {
user,
signaturePubKey,
keyPackage,
},
)
}
///Creates a new call builder for the [`getAvailableKeyPackage`] function.
pub fn getAvailableKeyPackage(
&self,
user: alloy::sol_types::private::Address,
) -> alloy_contract::SolCallBuilder<T, &P, getAvailableKeyPackageCall, N> {
self.call_builder(&getAvailableKeyPackageCall { user })
}
///Creates a new call builder for the [`getUser`] function.
pub fn getUser(
&self,

File diff suppressed because one or more lines are too long