@cryptorubic/web3 1.5.0 → 1.5.1-alpha.tron.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cryptorubic/web3",
3
- "version": "1.5.0",
3
+ "version": "1.5.1-alpha.tron.1",
4
4
  "dependencies": {
5
5
  "@ethersproject/bignumber": "^5.8.0",
6
6
  "@mysten/sui": "^1.24.0",
@@ -16,12 +16,13 @@ import { ApprovableAdapter } from '../models/approve-adapter';
16
16
  import { TxStatus } from '../models/web3-public-models/tx-status';
17
17
  export declare class TronAdapter extends AbstractAdapter<TronWeb, TronWeb, TronBlockchainName> implements ApprovableAdapter<TronTransactionConfig> {
18
18
  private readonly rpcList;
19
+ private readonly clientParams?;
19
20
  readonly signer: TronAdapterSigner;
20
21
  private readonly multicallAddress;
21
22
  needPreswapAction(): Promise<boolean>;
22
23
  constructor(rpcList: (string | {
23
24
  fullHost: string;
24
- })[], httpClient: HttpClient, logger?: ICustomLogger, clientParams?: ClientAdaptersFactoryParams);
25
+ })[], httpClient: HttpClient, logger?: ICustomLogger, clientParams?: ClientAdaptersFactoryParams | undefined);
25
26
  initWeb3Client(): void;
26
27
  callContractMethod<T extends Web3PrimitiveType = string>(contractAddress: string, contractAbi: Abi, methodName: string, methodArguments?: unknown[]): Promise<T>;
27
28
  getTransactionStatus(srcTxHash: string): Promise<TxStatus>;
@@ -20,12 +20,17 @@ class TronAdapter extends abstract_adapter_1.AbstractAdapter {
20
20
  constructor(rpcList, httpClient, logger, clientParams) {
21
21
  super(core_1.BLOCKCHAIN_NAME.TRON, logger);
22
22
  this.rpcList = rpcList;
23
+ this.clientParams = clientParams;
23
24
  this.multicallAddress = 'T9ziQU4EBteJzjzMzhHELdhgWFqwzS5Vki';
24
25
  this.signer = new tron_adapter_signer_1.TronAdapterSigner(this.publicRef, httpClient, logger, clientParams);
25
26
  }
26
27
  initWeb3Client() {
27
28
  const rpc = typeof this.rpcList[0] === 'string' ? this.rpcList[0] : this.rpcList[0].fullHost;
28
- this.public = new tronweb_1.TronWeb({ fullHost: rpc });
29
+ const tronApiKey = this.clientParams?.tronApiKey;
30
+ this.public = new tronweb_1.TronWeb({
31
+ fullHost: rpc,
32
+ headers: { ...(tronApiKey && { 'TRON-PRO-API-KEY': tronApiKey }) }
33
+ });
29
34
  }
30
35
  async callContractMethod(contractAddress, contractAbi, methodName, methodArguments = []) {
31
36
  this.public.setAddress(contractAddress);
@@ -16,6 +16,7 @@ export interface ClientAdaptersFactoryParams {
16
16
  envType: EnvType;
17
17
  viemConfig?: ViemChainConfig;
18
18
  lazyLoadWeb3?: boolean;
19
+ tronApiKey?: string;
19
20
  }
20
21
  export type ViemChainConfig = Partial<Record<EvmBlockchainName, ViemConfig>>;
21
22
  export interface ViemConfig {