Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Wizdave97 committed Jan 9, 2025
1 parent c6edc0b commit 70e0100
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
5 changes: 5 additions & 0 deletions docs/pages/developers/polkadot/token-gateway.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Let's look at the pallet specific components of the configuration trait: <br/><b
- `AssetIdFactory`: This type should be configured with a component that implements `pallet_token_gateway::types::CreateAssetId`. It should return a unique asset id each time the `AssetIdFactory::create_asset_id` is called.<br/><br/>
- `NativeAssetId`: A constant value that represents the identifier of the native asset.<br/><br/>
- `Decimals`: A constant that represents the precision of the native currency. <br/><br/>
- `EvmToSubstrate`: A type that allows conversion of an EVM account to a substrate account. <br/><br/>

## Calls

Expand Down Expand Up @@ -77,6 +78,8 @@ impl pallet_token_gateway::Config for Runtime {
type AssetIdFactory = ();
// The precision of the native asset
type Decimals = Decimals;
// An implementation that converts an evm account to a substrate account
type EvmToSubstrate = ();
}

// Add the token gateway pallet to your ISMP router
Expand Down Expand Up @@ -166,6 +169,8 @@ pub struct TeleportParams<AssetId, Balance> {
pub token_gateway: Vec<u8>,
/// Relayer fee
pub relayer_fee: Balance,
/// Optional call data
pub call_data: Option<Vec<u8>>
}
```
Let's explore what each parameter holds:
Expand Down
13 changes: 4 additions & 9 deletions modules/pallets/token-gateway/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ use ismp::{
};

use sp_core::{Get, H160, U256};
use sp_runtime::{
traits::{Dispatchable, Hash},
MultiSignature,
};
use sp_runtime::{traits::Dispatchable, MultiSignature};
use token_gateway_primitives::{
token_gateway_id, token_governor_id, AssetMetadata, DeregisterAssets,
};
Expand Down Expand Up @@ -636,7 +633,7 @@ where
// Verify signature against encoded runtime call
let nonce = frame_system::Pallet::<T>::account_nonce(beneficiary.clone());
let payload = (nonce, substrate_data.runtime_call.clone()).encode();
let message = <<T as frame_system::Config>::Hashing as Hash>::hash(&payload);
let message = sp_io::hashing::keccak_256(&payload);

let multi_signature = MultiSignature::decode(&mut &*substrate_data.signature)?;

Expand All @@ -662,10 +659,8 @@ where
}
},
MultiSignature::Ecdsa(sig) => {
let mut msg = [0u8; 32];
msg.copy_from_slice(message.as_ref());
let pub_key =
sp_io::crypto::secp256k1_ecdsa_recover(&sig.0, &msg).map_err(|_| {
let pub_key = sp_io::crypto::secp256k1_ecdsa_recover(&sig.0, &message)
.map_err(|_| {
anyhow!("Failed to recover ecdsa public key from signature")
})?;
let eth_address =
Expand Down
4 changes: 2 additions & 2 deletions modules/pallets/token-gateway/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ alloy_sol_macro::sol! {

#[derive(Debug, Clone, Encode, Decode, scale_info::TypeInfo, PartialEq, Eq)]
pub struct SubstrateCalldata {
/// A scale encoded encoded [MultiSignature](sp_runtime::MultiSignature) of the hash of the
/// encoded runtime call by the beneficiary account
/// A scale encoded encoded [MultiSignature](sp_runtime::MultiSignature) of the beneficiary's
/// account nonce and the encoded runtime call
pub signature: Vec<u8>,
/// Encoded Runtime call that should be executed
pub runtime_call: Vec<u8>,
Expand Down

0 comments on commit 70e0100

Please sign in to comment.