Skip to content

Commit 34b4719

Browse files
authored
Use snake_case chain_type in omni_getSmartWalletRootSigner (#3622)
* use snake_case * fix * fmtted by githooks
1 parent 43bba1b commit 34b4719

File tree

7 files changed

+60
-45
lines changed

7 files changed

+60
-45
lines changed

parachain/ts-tests/common/setup/wait-finalized-block.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,20 @@ const TIMEOUT_MIN = 5;
2525

2626
console.log(`Connecting to parachain ${config.parachain_ws}`);
2727

28-
timeout = global.setTimeout(async () => {
29-
if (typeof unsub === 'function') unsub();
30-
31-
if (api) api.disconnect();
32-
provider.on('disconnected', () => {
33-
console.log(
34-
`\nno block production detected after ${TIMEOUT_MIN}min, you might want to check it manually. Quit now`
35-
);
36-
process.exit(1);
37-
});
38-
}, TIMEOUT_MIN * 60 * 1000);
28+
timeout = global.setTimeout(
29+
async () => {
30+
if (typeof unsub === 'function') unsub();
31+
32+
if (api) api.disconnect();
33+
provider.on('disconnected', () => {
34+
console.log(
35+
`\nno block production detected after ${TIMEOUT_MIN}min, you might want to check it manually. Quit now`
36+
);
37+
process.exit(1);
38+
});
39+
},
40+
TIMEOUT_MIN * 60 * 1000
41+
);
3942

4043
api = await ApiPromise.create({
4144
provider: provider,

parachain/ts-tests/common/utils/function.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,16 @@ export const observeEvent = async (expectedSection: string, expectedMethod: stri
9696
let eventFound = false;
9797
let result: any;
9898
const query = (event: any) => true;
99-
const timeout = setTimeout(() => {
100-
if (!eventFound) {
101-
reject(new Error(`Event -${expectedSection}.${expectedMethod} not found within the specified time`));
102-
}
103-
}, 5 * 60 * 1000); // 5 minutes
99+
const timeout = setTimeout(
100+
() => {
101+
if (!eventFound) {
102+
reject(
103+
new Error(`Event -${expectedSection}.${expectedMethod} not found within the specified time`)
104+
);
105+
}
106+
},
107+
5 * 60 * 1000
108+
); // 5 minutes
104109

105110
const unsubscribe = api.rpc.chain.subscribeNewHeads(async (header) => {
106111
const events = await api.query.system.events.at(header.hash);

parachain/ts-tests/integration-tests/evm-contract.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,8 @@ describeLitentry('Test EVM Module Contract', ``, (context) => {
9292
const transferReceipt = await web3.eth.sendSignedTransaction(transferTransaction.rawTransaction!);
9393
console.log(`Tx successful with hash: ${transferReceipt.transactionHash}`);
9494

95-
const { nonce: eveCurrentNonce, data: eveCurrentBalance } = await context.api.query.system.account(
96-
eveMappedSustrateAccount
97-
);
95+
const { nonce: eveCurrentNonce, data: eveCurrentBalance } =
96+
await context.api.query.system.account(eveMappedSustrateAccount);
9897
const { nonce: evmAccountCurrentNonce, data: evmAccountCurrentBalance } =
9998
await context.api.query.system.account(evmAccountRaw.mappedAddress);
10099

tee-worker/omni-executor/aa-contracts/aa-demo-app/src/lib/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export const DEFAULT_CLIENT_ID = "wildmeta";
7777
export const TEE_WORKER_CONFIG = {
7878
rpcUrl: process.env.NEXT_PUBLIC_TEE_WORKER_RPC_URL || "http://localhost:3000",
7979
clientId: "wildmeta",
80-
chainType: "Evm" as const,
80+
chainType: "evm" as const,
8181
signerIndex: 0,
8282
// Use proxy to avoid CORS issues when running in browser
8383
useProxy: true,

tee-worker/omni-executor/aa-contracts/aa-demo-app/src/lib/tee-worker-client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ interface UserLoginResponse {
2828

2929
interface GetSmartWalletRootSignerParams {
3030
omni_account: string;
31-
chain_type: "Evm" | "Solana" | "Tron";
31+
chain_type: "evm" | "solana" | "tron";
3232
wallet_index: number;
3333
}
3434

@@ -149,7 +149,7 @@ export async function loginWithEvm(
149149
// Get the TEE worker's smart wallet root signer address
150150
export async function getSmartWalletRootSigner(
151151
omniAccount: string,
152-
chainType: "Evm" | "Solana" | "Tron" = TEE_WORKER_CONFIG.chainType,
152+
chainType: "evm" | "solana" | "tron" = TEE_WORKER_CONFIG.chainType,
153153
index: number = TEE_WORKER_CONFIG.signerIndex
154154
): Promise<string> {
155155
const params: GetSmartWalletRootSignerParams = {

tee-worker/omni-executor/omni-cli/src/main.rs

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,17 @@ use clap::{Parser, Subcommand, ValueEnum};
33
use executor_core::types::SerializablePackedUserOperation;
44
use executor_primitives::ChainId;
55
use serde::{Deserialize, Serialize};
6-
use signer_client::ChainType;
76
use std::collections::HashMap;
87
use tracing::{debug, info};
98

109
#[derive(Debug, Clone, ValueEnum, Serialize)]
11-
#[serde(rename_all = "PascalCase")]
10+
#[serde(rename_all = "snake_case")]
1211
enum CliChainType {
1312
Evm,
1413
Solana,
1514
Tron,
1615
}
1716

18-
impl From<CliChainType> for ChainType {
19-
fn from(cli_type: CliChainType) -> Self {
20-
match cli_type {
21-
CliChainType::Evm => ChainType::Evm,
22-
CliChainType::Solana => ChainType::Solana,
23-
CliChainType::Tron => ChainType::Tron,
24-
}
25-
}
26-
}
27-
2817
#[derive(Debug, Serialize)]
2918
struct JsonRpcRequest {
3019
jsonrpc: String,
@@ -114,7 +103,7 @@ struct RequestEmailVerificationCodeParams {
114103
#[derive(Debug, Serialize)]
115104
struct GetSmartWalletRootSignerParams {
116105
omni_account: String,
117-
chain_type: ChainType,
106+
chain_type: CliChainType,
118107
wallet_index: u32,
119108
}
120109

@@ -556,11 +545,7 @@ async fn handle_get_smart_wallet_root_signer(
556545
chain_type: CliChainType,
557546
wallet_index: u32,
558547
) -> Result<()> {
559-
let params = GetSmartWalletRootSignerParams {
560-
omni_account,
561-
chain_type: chain_type.into(),
562-
wallet_index,
563-
};
548+
let params = GetSmartWalletRootSignerParams { omni_account, chain_type, wallet_index };
564549

565550
info!("Getting smart wallet root signer with params: {:?}", params);
566551

tee-worker/omni-executor/rpc-server/src/methods/omni/get_smart_wallet_root_signer.rs

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,33 @@ use executor_primitives::utils::hex::FromHexPrefixed;
33
use heima_primitives::Address32;
44
use jsonrpsee::RpcModule;
55
use pumpx::pubkey_to_address;
6-
use serde::{Deserialize, Serialize};
6+
use serde::Deserialize;
77
use signer_client::ChainType;
88
use tracing::{debug, error};
99

10-
#[derive(Debug, Deserialize, Serialize)]
10+
// used in rpc with backend only
11+
#[derive(Debug, Copy, Deserialize, Clone, PartialEq)]
12+
#[serde(rename_all = "snake_case")]
13+
pub enum SerdeChainType {
14+
Evm,
15+
Solana,
16+
Tron,
17+
}
18+
19+
impl From<SerdeChainType> for ChainType {
20+
fn from(c: SerdeChainType) -> Self {
21+
match c {
22+
SerdeChainType::Evm => Self::Evm,
23+
SerdeChainType::Solana => Self::Solana,
24+
SerdeChainType::Tron => Self::Tron,
25+
}
26+
}
27+
}
28+
29+
#[derive(Debug, Deserialize)]
1130
pub struct GetSmartWalletRootSignerParams {
1231
pub omni_account: String,
13-
pub chain_type: ChainType,
32+
pub chain_type: SerdeChainType,
1433
pub wallet_index: u32,
1534
}
1635

@@ -31,7 +50,11 @@ pub fn register_get_smart_wallet_root_signer(module: &mut RpcModule<RpcContext>)
3150

3251
let pubkey = ctx
3352
.signer_client
34-
.request_wallet(params.chain_type, params.wallet_index, address.as_ref().to_owned())
53+
.request_wallet(
54+
params.chain_type.into(),
55+
params.wallet_index,
56+
address.as_ref().to_owned(),
57+
)
3558
.await
3659
.map_err(|_| {
3760
error!("Failed to request wallet from signer client");
@@ -40,7 +63,7 @@ pub fn register_get_smart_wallet_root_signer(module: &mut RpcModule<RpcContext>)
4063
))
4164
})?;
4265

43-
let address = pubkey_to_address(params.chain_type, &pubkey).map_err(|_| {
66+
let address = pubkey_to_address(params.chain_type.into(), &pubkey).map_err(|_| {
4467
error!("Failed to convert pubkey to address");
4568
PumpxRpcError::from_error_code(ErrorCode::ServerError(
4669
PUMPX_SIGNER_PUBKEY_TO_ADDRESS_FAILED_CODE,

0 commit comments

Comments
 (0)