Skip to content

Commit

Permalink
refactor: minimal boltz
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscotobar committed Feb 13, 2024
1 parent 6a5e141 commit 865c643
Show file tree
Hide file tree
Showing 11 changed files with 782 additions and 275 deletions.
2 changes: 2 additions & 0 deletions contracts/import.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import '@rsksmart/rif-relay-contracts/contracts/verifier/DeployVerifier.sol';
import '@rsksmart/rif-relay-contracts/contracts/verifier/RelayVerifier.sol';
import '@rsksmart/rif-relay-contracts/contracts/verifier/BoltzRelayVerifier.sol';
import '@rsksmart/rif-relay-contracts/contracts/verifier/BoltzDeployVerifier.sol';
import '@rsksmart/rif-relay-contracts/contracts/verifier/MinimalBoltzRelayVerifier.sol';
import '@rsksmart/rif-relay-contracts/contracts/verifier/MinimalBoltzDeployVerifier.sol';
import '@rsksmart/rif-relay-contracts/contracts/Penalizer.sol';
import '@rsksmart/rif-relay-contracts/contracts/utils/UtilToken.sol';
import '@rsksmart/rif-relay-contracts/contracts/interfaces/IForwarder.sol';
Expand Down
286 changes: 127 additions & 159 deletions package-lock.json

Large diffs are not rendered by default.

21 changes: 7 additions & 14 deletions scripts/GasEstimation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,10 @@ import {
SupportedType,
SupportedSmartWallet,
SupportedSmartWalletName,
SupportedSmartWalletFactory,
getSmartWalletAddress,
} from '../test/utils/TestUtils';
import { TestSwap, TestVerifierEverythingAccepted } from 'typechain-types';
import {
Penalizer,
RelayHub,
SmartWallet,
} from '@rsksmart/rif-relay-contracts';
import { Penalizer, RelayHub } from '@rsksmart/rif-relay-contracts';
import { expect } from 'chai';

const GAS_PRICE = '60000000';
Expand Down Expand Up @@ -123,11 +118,11 @@ async function deployAndSetup(payment: Payment = 'erc20') {
erc20: 'Default',
};

const factory = (await createSmartWalletFactory(
const factory = await createSmartWalletFactory(
template,
supportedTypes[payment],
owner
)) as SupportedSmartWalletFactory;
);

const tokenContracts: Record<Payment, string> = {
native: constants.AddressZero,
Expand Down Expand Up @@ -288,7 +283,7 @@ async function getDestinationContractCallParams(
transferReceiver: string,
balanceToTransfer: string,
token: UtilToken,
forwarder: SmartWallet,
forwarder: SupportedSmartWallet,
native: boolean,
swap: TestSwap
): Promise<DestinationContractCallParams> {
Expand Down Expand Up @@ -334,13 +329,13 @@ async function estimateRelayCost(fees = NO_FEES, payment: Payment = 'erc20') {

const isNative = isNativePayment(payment);

const smartWallet = (await createSupportedSmartWallet({
const smartWallet: SupportedSmartWallet = await createSupportedSmartWallet({
relayHub: relayHubSigner.address,
factory,
owner,
sender: relayHubSigner,
type,
})) as SmartWallet;
});

// provide the SW with some tokens
await token.mint(
Expand Down Expand Up @@ -544,7 +539,6 @@ async function prepareDeployRequest(
tokenContract: tokenContractAddress,
tokenGas: tokenGas.toString(),
value: '0',
gas: '0',
validUntilTime: 0,
index: SMART_WALLET_INDEX,
recoverer: constants.AddressZero,
Expand Down Expand Up @@ -580,14 +574,13 @@ async function estimateDeployCost(
...deployRequest,
};
if (withExecution) {
const { to, data, gas } = await getExecutionParameters(swap, swAddress);
const { to, data } = await getExecutionParameters(swap, swAddress);

updatedDeployRequest = {
request: {
...deployRequest.request,
to,
data,
gas,
},
relayData: {
...deployRequest.relayData,
Expand Down
Loading

0 comments on commit 865c643

Please sign in to comment.