chore: fix missing prettier formatting
This commit is contained in:
parent
04b98ac68e
commit
592a6e097a
@ -6,7 +6,7 @@ import * as polkadot from "./polkadot";
|
||||
import * as solana from "./solana";
|
||||
import * as near from "./near";
|
||||
import * as elrond from "./elrond";
|
||||
import * as tron from './tron';
|
||||
import * as tron from "./tron";
|
||||
|
||||
import { ChainMetadata, ChainRequestRender } from "../helpers";
|
||||
|
||||
@ -25,7 +25,7 @@ export function getChainMetadata(chainId: string): ChainMetadata {
|
||||
return near.getChainMetadata(chainId);
|
||||
case "elrond":
|
||||
return elrond.getChainMetadata(chainId);
|
||||
case 'tron':
|
||||
case "tron":
|
||||
return tron.getChainMetadata(chainId);
|
||||
default:
|
||||
throw new Error(`No metadata handler for namespace ${namespace}`);
|
||||
|
@ -13,7 +13,7 @@ export const DEFAULT_MAIN_CHAINS = [
|
||||
"solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ",
|
||||
"polkadot:91b171bb158e2d3848fa23a9f1c25182",
|
||||
"elrond:1",
|
||||
'tron:0x2b6653dc',
|
||||
"tron:0x2b6653dc",
|
||||
];
|
||||
|
||||
export const DEFAULT_TEST_CHAINS = [
|
||||
@ -27,7 +27,7 @@ export const DEFAULT_TEST_CHAINS = [
|
||||
"polkadot:e143f23803ac50e8f6f8e62695d1ce9e",
|
||||
"near:testnet",
|
||||
"elrond:D",
|
||||
'tron:0xcd8690dc',
|
||||
"tron:0xcd8690dc",
|
||||
];
|
||||
|
||||
export const DEFAULT_CHAINS = [...DEFAULT_MAIN_CHAINS, ...DEFAULT_TEST_CHAINS];
|
||||
@ -119,8 +119,8 @@ export enum DEFAULT_ELROND_EVENTS {}
|
||||
* TRON
|
||||
*/
|
||||
export enum DEFAULT_TRON_METHODS {
|
||||
TRON_SIGN_TRANSACTION = 'tron_signTransaction',
|
||||
TRON_SIGN_MESSAGE = 'tron_signMessage'
|
||||
TRON_SIGN_TRANSACTION = "tron_signTransaction",
|
||||
TRON_SIGN_MESSAGE = "tron_signMessage",
|
||||
}
|
||||
|
||||
export enum DEFAULT_TRON_EVENTS {}
|
||||
|
@ -20,7 +20,7 @@ import {
|
||||
Transaction as SolanaTransaction,
|
||||
} from "@solana/web3.js";
|
||||
// @ts-expect-error
|
||||
import TronWeb from 'tronweb';
|
||||
import TronWeb from "tronweb";
|
||||
import {
|
||||
eip712,
|
||||
formatTestTransaction,
|
||||
@ -674,11 +674,14 @@ export function JsonRpcContextProvider({
|
||||
specVersion: "0x00002468",
|
||||
transactionVersion: "0x0000000e",
|
||||
address: `${address}`,
|
||||
blockHash: "0x554d682a74099d05e8b7852d19c93b527b5fae1e9e1969f6e1b82a2f09a14cc9",
|
||||
blockHash:
|
||||
"0x554d682a74099d05e8b7852d19c93b527b5fae1e9e1969f6e1b82a2f09a14cc9",
|
||||
blockNumber: "0x00cb539c",
|
||||
era: "0xc501",
|
||||
genesisHash: "0xe143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e",
|
||||
method: "0x0001784920616d207369676e696e672074686973207472616e73616374696f6e21",
|
||||
genesisHash:
|
||||
"0xe143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e",
|
||||
method:
|
||||
"0x0001784920616d207369676e696e672074686973207472616e73616374696f6e21",
|
||||
nonce: "0x00000000",
|
||||
signedExtensions: [
|
||||
"CheckNonZeroSender",
|
||||
@ -688,11 +691,11 @@ export function JsonRpcContextProvider({
|
||||
"CheckMortality",
|
||||
"CheckNonce",
|
||||
"CheckWeight",
|
||||
"ChargeTransactionPayment"
|
||||
"ChargeTransactionPayment",
|
||||
],
|
||||
tip: "0x00000000000000000000000000000000",
|
||||
version: 4
|
||||
}
|
||||
version: 4,
|
||||
};
|
||||
|
||||
try {
|
||||
const result = await client!.request<{
|
||||
@ -1060,28 +1063,34 @@ export function JsonRpcContextProvider({
|
||||
|
||||
const tronRpc = {
|
||||
testSignTransaction: _createJsonRpcRequestHandler(
|
||||
async (chainId: string, address: string): Promise<IFormattedRpcResponse> => {
|
||||
async (
|
||||
chainId: string,
|
||||
address: string
|
||||
): Promise<IFormattedRpcResponse> => {
|
||||
// Nile TestNet, if you want to use in MainNet, change the fullHost to 'https://api.trongrid.io'
|
||||
const fullHost = isTestnet ? "https://nile.trongrid.io/" : "https://api.trongrid.io/";
|
||||
const fullHost = isTestnet
|
||||
? "https://nile.trongrid.io/"
|
||||
: "https://api.trongrid.io/";
|
||||
|
||||
const tronWeb = new TronWeb({
|
||||
fullHost,
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
// Take USDT as an example:
|
||||
// Nile TestNet: https://nile.tronscan.org/#/token20/TXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBf
|
||||
// MainNet: https://tronscan.org/#/token20/TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t
|
||||
|
||||
|
||||
const testContract = isTestnet ? "TXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBf" : "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t";
|
||||
const testTransaction = await tronWeb.transactionBuilder.triggerSmartContract(
|
||||
const testContract = isTestnet
|
||||
? "TXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBf"
|
||||
: "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t";
|
||||
const testTransaction =
|
||||
await tronWeb.transactionBuilder.triggerSmartContract(
|
||||
testContract,
|
||||
'approve(address,uint256)',
|
||||
"approve(address,uint256)",
|
||||
{ feeLimit: 200000000 },
|
||||
[
|
||||
{ type: 'address', value: address },
|
||||
{ type: 'uint256', value: 0 }
|
||||
{ type: "address", value: address },
|
||||
{ type: "uint256", value: 0 },
|
||||
],
|
||||
address
|
||||
);
|
||||
@ -1095,17 +1104,17 @@ export function JsonRpcContextProvider({
|
||||
params: {
|
||||
address,
|
||||
transaction: {
|
||||
...testTransaction
|
||||
}
|
||||
}
|
||||
}
|
||||
...testTransaction,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
method: DEFAULT_TRON_METHODS.TRON_SIGN_TRANSACTION,
|
||||
address,
|
||||
valid: true,
|
||||
result: result.signature
|
||||
result: result.signature,
|
||||
};
|
||||
} catch (error: any) {
|
||||
throw new Error(error);
|
||||
@ -1113,9 +1122,11 @@ export function JsonRpcContextProvider({
|
||||
}
|
||||
),
|
||||
testSignMessage: _createJsonRpcRequestHandler(
|
||||
async (chainId: string, address: string): Promise<IFormattedRpcResponse> => {
|
||||
|
||||
const message = 'This is a message to be signed for Tron';
|
||||
async (
|
||||
chainId: string,
|
||||
address: string
|
||||
): Promise<IFormattedRpcResponse> => {
|
||||
const message = "This is a message to be signed for Tron";
|
||||
|
||||
try {
|
||||
const result = await client!.request<{ signature: string }>({
|
||||
@ -1125,25 +1136,24 @@ export function JsonRpcContextProvider({
|
||||
method: DEFAULT_TRON_METHODS.TRON_SIGN_MESSAGE,
|
||||
params: {
|
||||
address,
|
||||
message
|
||||
}
|
||||
}
|
||||
message,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
method: DEFAULT_TRON_METHODS.TRON_SIGN_MESSAGE,
|
||||
address,
|
||||
valid: true,
|
||||
result: result.signature
|
||||
result: result.signature,
|
||||
};
|
||||
} catch (error: any) {
|
||||
throw new Error(error);
|
||||
}
|
||||
}
|
||||
)
|
||||
),
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<JsonRpcContext.Provider
|
||||
value={{
|
||||
|
@ -106,7 +106,7 @@ export async function apiGetAccountBalance(
|
||||
chainId: string
|
||||
): Promise<AssetData> {
|
||||
const namespace = chainId.split(":")[0];
|
||||
if (namespace !== 'eip155') {
|
||||
if (namespace !== "eip155") {
|
||||
return { balance: "", symbol: "", name: "" };
|
||||
}
|
||||
const ethChainId = chainId.split(":")[1];
|
||||
|
@ -42,7 +42,7 @@ export const getSupportedMethodsByNamespace = (namespace: string) => {
|
||||
return Object.values(DEFAULT_NEAR_METHODS);
|
||||
case "elrond":
|
||||
return Object.values(DEFAULT_ELROND_METHODS);
|
||||
case 'tron':
|
||||
case "tron":
|
||||
return Object.values(DEFAULT_TRON_METHODS);
|
||||
default:
|
||||
throw new Error(`No default methods for namespace: ${namespace}`);
|
||||
|
@ -114,10 +114,10 @@ const Home: NextPage = () => {
|
||||
}
|
||||
|
||||
await client.emit({
|
||||
topic: session?.topic || '',
|
||||
event: { name: 'chainChanged', data: {} },
|
||||
chainId: 'eip155:5'
|
||||
})
|
||||
topic: session?.topic || "",
|
||||
event: { name: "chainChanged", data: {} },
|
||||
chainId: "eip155:5",
|
||||
});
|
||||
}
|
||||
|
||||
const getEthereumActions = (): AccountAction[] => {
|
||||
@ -297,12 +297,12 @@ const Home: NextPage = () => {
|
||||
return [
|
||||
{
|
||||
method: DEFAULT_TRON_METHODS.TRON_SIGN_TRANSACTION,
|
||||
callback: onSignTransaction
|
||||
callback: onSignTransaction,
|
||||
},
|
||||
{
|
||||
method: DEFAULT_TRON_METHODS.TRON_SIGN_MESSAGE,
|
||||
callback: onSignMessage
|
||||
}
|
||||
callback: onSignMessage,
|
||||
},
|
||||
];
|
||||
};
|
||||
|
||||
@ -420,7 +420,12 @@ const Home: NextPage = () => {
|
||||
return (
|
||||
<SLayout>
|
||||
<Column maxWidth={1000} spanHeight>
|
||||
<Header ping={onPing} disconnect={disconnect} session={session} emit={emit}/>
|
||||
<Header
|
||||
ping={onPing}
|
||||
disconnect={disconnect}
|
||||
session={session}
|
||||
emit={emit}
|
||||
/>
|
||||
<SContent>{isInitializing ? "Loading..." : renderContent()}</SContent>
|
||||
</Column>
|
||||
<Modal show={!!modal} closeModal={closeModal}>
|
||||
|
Loading…
Reference in New Issue
Block a user