Skip to content

Commit

Permalink
Add variable simulation when receiving tx data
Browse files Browse the repository at this point in the history
  • Loading branch information
axtezy committed Sep 16, 2024
1 parent 1f6b40e commit 806c120
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rubic-sdk",
"version": "5.36.8",
"version": "5.36.9",
"description": "Simplify dApp creation",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,9 @@ export interface EvmTransactionOptions extends EvmBasicTransactionOptions {
* gasLimit multiplier (to change ratio for specific chain)
*/
gasLimitRatio?: number;

/**
* Address send transaction to
*/
to?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,18 @@ export abstract class EvmCrossChainTrade extends CrossChainTrade<EvmEncodeConfig
const { data, value, to } = await this.encode({ ...options, fromAddress });

try {
const gasfullOptions = await this.web3Private.simulateTransaction(
to,
{
data,
value
},
this.from.blockchain
);
return gasfullOptions;
if (!options?.testMode) {
const gasfullOptions = await this.web3Private.simulateTransaction(
to,
{
data,
value
},
this.from.blockchain
);
return gasfullOptions;
}
return { data, value, to };
} catch (err) {
throw err;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ export abstract class EvmOnChainTrade extends OnChainTrade {
): Promise<EvmTransactionOptions | never> {
this.apiFromAddress = fromAddress;
if (!options?.testMode) {
await this.checkWalletState(options?.testMode);
await this.checkWalletState(options.testMode);
}
await this.checkReceiverAddress(
options.receiverAddress,
Expand All @@ -291,15 +291,19 @@ export abstract class EvmOnChainTrade extends OnChainTrade {
const { data, value, to } = await this.encode({ ...options, fromAddress });

try {
const gasfullOptions = await this.web3Private.simulateTransaction(
to,
{
data,
value
},
this.from.blockchain
);
return gasfullOptions;
if (!options?.testMode) {
const gasfullOptions = await this.web3Private.simulateTransaction(
to,
{
data,
value
},
this.from.blockchain
);
return gasfullOptions;
}

return { data, value, to };
} catch (err) {
throw err;
}
Expand Down

0 comments on commit 806c120

Please sign in to comment.