Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
PP-508/fees-from-server (#31)
Browse files Browse the repository at this point in the history
* feat: estimateGasLimit, getERC20Token and getERC20TokenPrice

* feat: estimateGasLimit, getERC20Token and getERC20TokenPrice
delete un-use class

* chore: typos and packages

* refactor: type of tokenAmount

* test: updating tests

* refactor: renaming variables

* refactor: smartWallet validation

* chore: update rif-relay-common and rif-relay-client

* chore: update package.json version

Co-authored-by: Antonio Morrone <[email protected]>
  • Loading branch information
franciscotobar and antomor authored Nov 8, 2022
1 parent bf1ab9e commit 0bb0617
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 236 deletions.
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rsksmart/rif-relay-sdk",
"version": "1.0.0-alpha.0",
"version": "1.0.0-alpha.1",
"description": "This project contains the SDK of the relaying services system.",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
Expand Down Expand Up @@ -28,20 +28,22 @@
]
},
"dependencies": {
"loglevel": "^1.8.0",
"ethereumjs-tx": "~2.1.2",
"@rsksmart/rif-relay-client": "1.0.0-alpha.0",
"@rsksmart/rif-relay-common": "1.0.0-alpha.0",
"@rsksmart/rif-relay-client": "1.0.0-alpha.1",
"@rsksmart/rif-relay-common": "1.0.0-alpha.1",
"@rsksmart/rif-relay-contracts": "1.0.0-alpha.0",
"bignumber.js": "^9.1.0",
"ethereumjs-tx": "~2.1.2",
"loglevel": "^1.8.0",
"npmignore": "^0.3.0",
"web3": "1.2.6",
"web3-core": "1.2.6",
"web3-eth": "1.2.6",
"npmignore": "^0.3.0",
"web3-eth-contract": "1.2.6",
"web3-utils": "1.2.6"
},
"devDependencies": {
"@openeth/truffle-typings": "0.0.6",
"@types/bignumber.js": "^5.0.0",
"@types/jest": "^26.0.15",
"@types/node": "^13.0.0",
"@types/semver": "^7.3.4",
Expand Down
217 changes: 0 additions & 217 deletions src/ERC20Token.ts

This file was deleted.

44 changes: 41 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ import {
} from './interfaces';
import {
EnvelopingConfig,
EnvelopingTransactionDetails
EnvelopingTransactionDetails,
ERC20Options,
ERC20Token
} from '@rsksmart/rif-relay-common';
import { RelayingResult } from '@rsksmart/rif-relay-client';
import { RelayEstimation, RelayingResult } from '@rsksmart/rif-relay-client';
import BigNumber from 'bignumber.js';

interface RelayingServices {
/**
Expand Down Expand Up @@ -131,6 +134,19 @@ interface RelayingServices {
options: RelayGasEstimationOptions
): Promise<string>;

/**
* It estimates the max possible gas for a deploy/relay using a standard/linear fit
*
* @param destinationContract destination contract address
* @param smartWalletAddress smart wallet address to all forwarder transaction
* @param tokenFees amount of token that cost the transaction
* @param abiEncodedTx Abi encoding transaction details
* @param relayWorker the realy worker contract address
*/
estimateMaxPossibleGas(
options: RelayGasEstimationOptions
): Promise<RelayEstimation>;

/**
* It looks for the transaction receipt of a transaction hash
*
Expand All @@ -150,6 +166,25 @@ interface RelayingServices {
* @param address smart wallet address to validate
*/
validateSmartWallet(address: string): Promise<void>;

/**
* It returns an ERC20Token
*
* @param address token address
* @param options attributes to query
*/
getERC20Token(address: string, options?: ERC20Options): Promise<ERC20Token>;

/**
* It returns the ERC20 token price
*
* @param erc20Token token instance
* @param targetCurrency currency to get the price on
*/
getERC20TokenPrice(
erc20: ERC20Token,
targetCurrency: string
): Promise<BigNumber>;
}

export {
Expand All @@ -163,5 +198,8 @@ export {
RelayingServicesAddresses,
RelayingResult,
EnvelopingTransactionDetails,
EnvelopingConfig
EnvelopingConfig,
ERC20Token,
ERC20Options,
RelayEstimation
};
5 changes: 3 additions & 2 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface SmartWalletDeployment {

export interface SmartWalletDeploymentOptions {
tokenAddress?: string;
tokenAmount?: number;
tokenAmount?: string;
recovererAddress?: string;
onlyPreferredRelays?: boolean;
callVerifier?: string;
Expand Down Expand Up @@ -53,7 +53,7 @@ export interface RelayingServicesAddresses {
export interface RelayingTransactionOptions {
unsignedTx: TransactionConfig;
smartWallet: SmartWallet;
tokenAmount?: number;
tokenAmount?: string;
transactionDetails?: Partial<EnvelopingTransactionDetails>;
value?: number;
onlyPreferredRelays?: boolean;
Expand All @@ -72,4 +72,5 @@ export interface RelayGasEstimationOptions {
isSmartWalletDeploy?: boolean;
index?: string;
recoverer?: string;
isLinearEstimation?: boolean;
}
Loading

0 comments on commit 0bb0617

Please sign in to comment.