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