Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for Tangle Substrate #26

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion chainIdRpcs.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
"https://demeter-testnet.webb.tools"
],
"4006": [
"https://tangle-standalone-archive.webb.tools"
"https://rpc.tangle.tools"
],
"1081": [
"ws://3.144.199.9:9944"
]
}
24 changes: 18 additions & 6 deletions faucet-frontend/src/components/ClaimFundsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type Chain = EvmChain | SubstrateChain;
const ClaimFundsForm: React.FC<ClaimFundsFormProps> = ({ accessToken }) => {
const [chain, setChain] = useState<Chain>({ Evm: 3884533461 });
const [address, setAddress] = useState<string>("");
const [onlyNativeToken, setOnlyNativeToken] = useState<boolean>(true);

const claimFunds = async () => {
// Implement your claim funds logic here
Expand All @@ -27,14 +28,15 @@ const ClaimFundsForm: React.FC<ClaimFundsFormProps> = ({ accessToken }) => {
type: (chain as EvmChain).Evm
? "ethereum"
: (chain as SubstrateChain).Substrate
? "substrate"
: "Unknown",
? "substrate"
: "Unknown",
value: address,
},
typedChainId: {
type: (chain as EvmChain).Evm ? "Evm" : "Substrate",
id: (chain as EvmChain).Evm || (chain as SubstrateChain).Substrate,
},
onlyNativeToken,
},
}),
{
Expand Down Expand Up @@ -86,9 +88,8 @@ const ClaimFundsForm: React.FC<ClaimFundsFormProps> = ({ accessToken }) => {
<option value={JSON.stringify({ Evm: 3884533461 })}>Athena</option>
<option value={JSON.stringify({ Evm: 3884533462 })}>Hermes</option>
<option value={JSON.stringify({ Evm: 3884533463 })}>Demeter</option>
<option value={JSON.stringify({ Substrate: 1081 })}>Tangle Standalone</option>
<option value={JSON.stringify({ Evm: 5 })}>Gorli</option>
<option value={JSON.stringify({ Evm: 80001 })}>Mumbai</option>
<option value={JSON.stringify({ Evm: 4006 })}>Tangle EVM</option>
<option value={JSON.stringify({ Substrate: 1081 })}>Tangle</option>
</select>

<label htmlFor="address">Address:</label>
Expand All @@ -99,14 +100,25 @@ const ClaimFundsForm: React.FC<ClaimFundsFormProps> = ({ accessToken }) => {
onChange={(event) => setAddress(event.target.value)}
/>

<input
id="only-native-token"
type="checkbox"
onChange={(event) => setOnlyNativeToken(event.target.checked)}
checked={onlyNativeToken}
>
</input>

<label htmlFor="only-native-token">
{onlyNativeToken ? "Only Native Token" : "ERC20/Assets Tokens"}
</label>
<button
className="submit-button"
disabled={accessToken === null ? true : false}
type="submit"
>
Claim
</button>
</form>
</form >
);
};

Expand Down
9 changes: 5 additions & 4 deletions src/helpers/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ pub fn get_evm_rpc_url(chain_id: u64) -> String {
rpc_data[0].clone()
}

pub fn get_substrate_rpc_url(_chain_id: u64) -> String {
// TODO: Decide if we want to push this into config
let url = "wss://tangle-standalone-archive.webb.tools:443";
url.to_string()
pub fn get_substrate_rpc_url(chain_id: u64) -> String {
let rpc_map = read_rpc_data();
let binding = vec!["ws://localhost:9944".to_string()];
let rpc_data = rpc_map.get(&chain_id).unwrap_or(&binding);
rpc_data[0].clone()
}

pub fn get_evm_token_address(chain_id: u64) -> [u8; 20] {
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,5 +299,5 @@ async fn rocket() -> _ {
.manage(cors.to_cors().unwrap())
.manage(tx_sender)
.mount("/", rocket_cors::catch_all_options_routes())
.mount("/", routes![auth::login::twitter, faucet::faucet,])
.mount("/", routes![auth::login::twitter, faucet::faucet])
}
1 change: 1 addition & 0 deletions src/txes/networks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ impl Network {
"athena" => Some(Self::Athena),
"demeter" => Some(Self::Demeter),
"tangle-evm-testnet" => Some(Self::TangleEVMTestnet),
"tangle" => Some(Self::Tangle),
_ => None,
}
}
Expand Down
Loading