From 1e4f5bae1ffd1eb3688f8c9e5c354f000ef00548 Mon Sep 17 00:00:00 2001 From: Juraj Date: Mon, 20 Jun 2022 10:30:57 +0100 Subject: [PATCH] patch: builds upon install and removes dist folder (#19) * patch: removes dist and old scripts * chore: changes deps to npm * chore: updates README --- .gitignore | 5 +- .npmrc | 1 + Readme.md | 44 +------ dist/AmountRequired.d.ts | 16 --- dist/Constants.d.ts | 21 --- dist/ContractInteractor.d.ts | 132 ------------------- dist/EIP712/ForwardRequest.d.ts | 26 ---- dist/EIP712/RelayData.d.ts | 8 -- dist/EIP712/RelayRequest.d.ts | 12 -- dist/EIP712/TypedRequestData.d.ts | 48 ------- dist/Environments.d.ts | 17 --- dist/ErrorReplacerJSON.d.ts | 3 - dist/PingResponse.d.ts | 10 -- dist/TokenResponse.d.ts | 3 - dist/Utils.d.ts | 44 ------- dist/VerifierResponse.d.ts | 3 - dist/VersionRegistry.d.ts | 40 ------ dist/VersionsManager.d.ts | 12 -- dist/dev/NetworkSimulatingProvider.d.ts | 15 --- dist/dev/ProfilingProvider.d.ts | 15 --- dist/dev/SendCallback.d.ts | 2 - dist/dev/WrapperProviderBase.d.ts | 12 -- dist/index.d.ts | 27 ---- dist/index.js | 1 - dist/types/EnvelopingConfig.d.ts | 26 ---- dist/types/EnvelopingTransactionDetails.d.ts | 42 ------ dist/types/RelayHubConfiguration.d.ts | 6 - dist/types/RelayTransactionRequest.d.ts | 72 ---------- package.json | 16 +-- scripts/postpublish | 3 - scripts/{postinstall => prepare} | 2 +- scripts/prepublishOnly | 1 - scripts/publishManually | 4 - 33 files changed, 16 insertions(+), 673 deletions(-) create mode 100644 .npmrc delete mode 100644 dist/AmountRequired.d.ts delete mode 100644 dist/Constants.d.ts delete mode 100644 dist/ContractInteractor.d.ts delete mode 100644 dist/EIP712/ForwardRequest.d.ts delete mode 100644 dist/EIP712/RelayData.d.ts delete mode 100644 dist/EIP712/RelayRequest.d.ts delete mode 100644 dist/EIP712/TypedRequestData.d.ts delete mode 100644 dist/Environments.d.ts delete mode 100644 dist/ErrorReplacerJSON.d.ts delete mode 100644 dist/PingResponse.d.ts delete mode 100644 dist/TokenResponse.d.ts delete mode 100644 dist/Utils.d.ts delete mode 100644 dist/VerifierResponse.d.ts delete mode 100644 dist/VersionRegistry.d.ts delete mode 100644 dist/VersionsManager.d.ts delete mode 100644 dist/dev/NetworkSimulatingProvider.d.ts delete mode 100644 dist/dev/ProfilingProvider.d.ts delete mode 100644 dist/dev/SendCallback.d.ts delete mode 100644 dist/dev/WrapperProviderBase.d.ts delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/types/EnvelopingConfig.d.ts delete mode 100644 dist/types/EnvelopingTransactionDetails.d.ts delete mode 100644 dist/types/RelayHubConfiguration.d.ts delete mode 100644 dist/types/RelayTransactionRequest.d.ts delete mode 100755 scripts/postpublish rename scripts/{postinstall => prepare} (60%) delete mode 100755 scripts/publishManually diff --git a/.gitignore b/.gitignore index 19817bc..320c107 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,3 @@ node_modules/ -build/ -# we need to add this ignore and remove the dist folder after we publish this library -#dist/ -.idea/ +dist/ package-lock.json diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..43c97e7 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/Readme.md b/Readme.md index a5151f8..f64fe6d 100644 --- a/Readme.md +++ b/Readme.md @@ -29,9 +29,9 @@ This project works as a dependency and needs to be installed in order to be used ### Dependencies -To start working with this project you need to first enable `postinstall` scripts (refer to section [Enabling postinstall scripts](#enabling-postinstall-scripts)). +Install all dependencies by running `npm install`. -Then just run `npm install` to install all dependencies. +The project is ready to be used at this point. ## Usage @@ -44,43 +44,14 @@ Install with: npm i --save @rsksmart/rif-relay-common ``` -### Use the repo distributable - -Modify your `package.json` file to add the following line: - -``` -"@rsksmart/rif-relay-common": "https://github.com/infuy/rif-relay-common", -``` - ### Use a local distributable -Clone this repository inside your project's root folder, and modify your `package.json` file to add the following line: - -``` -"@rsksmart/rif-relay-common": "../rif-relay-common", -``` +Clone this repository inside your project's root folder and use the `npm link` mechanism (https://docs.npmjs.com/cli/v8/commands/npm-link) to add it to your project. ## Development -If you need to modify resources inside this repository: -- make sure that [`postinstall` scripts are enabled](#enabling-postinstall-scripts) in the `package.json` file. These are disabled by default due to distribution issues (which will be solved in the future), but will enable husky and other tools. -- run `npm install` to execute the post install hooks. - -After that, make your modifications and then run `npm run build` to validate them. - -After you are done with your changes you can publish them by creating a distributable version. - -### Enabling postinstall scripts - -To enable `postinstall` scripts you need to modify the `package.json` file, specifically the `scripts` section and change this line: - -``` -"_postinstall": "scripts/postinstall", -``` -to -``` -"postinstall": "scripts/postinstall", -``` +Make your modifications and then run `npm run build` to validate them. +When you are done with your changes, you can publish them by creating a distributable version. ### Husky and linters @@ -95,16 +66,13 @@ to check and fix the errors before trying to commit again: ### Generating a new distributable version -**IMPORTANT: when you publish a version postinstall scripts must be disabled. This is disabled by default, so don't push any changes to the postinstall scripts section in the `package.json` file.** - 1. Run the `npm run dist` command to generate the `dist` folder with the distributable version inside. 2. Bump the version on the `package.json` file (not strictly needed). 3. Commit and push any changes, including the version bump. #### For GitHub -1. Run `npm pack` to generate the tarball to be published as a release on GitHub. -2. Generate a new release on GitHub and upload the generated tarball. +1. Create a new tag with the new version (from `package.json`) and github actions will update npm #### For NPM diff --git a/dist/AmountRequired.d.ts b/dist/AmountRequired.d.ts deleted file mode 100644 index 761e28a..0000000 --- a/dist/AmountRequired.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/// -/// -export declare class AmountRequired { - _name: string; - _currentValue: import("bn.js"); - _requiredValue: import("bn.js"); - _listener?: () => void; - constructor(name: string, requiredValue: BN, listener?: () => void); - get currentValue(): BN; - set currentValue(newValue: BN); - get requiredValue(): BN; - set requiredValue(newValue: BN); - _onChange(wasSatisfied: boolean): void; - get isSatisfied(): boolean; - get description(): string; -} diff --git a/dist/Constants.d.ts b/dist/Constants.d.ts deleted file mode 100644 index 4182129..0000000 --- a/dist/Constants.d.ts +++ /dev/null @@ -1,21 +0,0 @@ -import BN from 'bn.js'; -export declare const constants: { - dayInSec: number; - weekInSec: number; - oneEther: BN; - ZERO_ADDRESS: string; - ZERO_BYTES32: string; - MAX_UINT256: BN; - MAX_INT256: BN; - MIN_INT256: BN; - SHA3_NULL_S: string; - TRANSACTION_CREATE_CONTRACT_GAS_COST: number; - TRANSACTION_GAS_COST: number; - TX_ZERO_DATA_GAS_COST: number; - TX_NO_ZERO_DATA_GAS_COST: number; - MAX_ESTIMATED_GAS_DEVIATION: number; - ESTIMATED_GAS_CORRECTION_FACTOR: number; - INTERNAL_TRANSACTION_ESTIMATE_CORRECTION: number; - WAIT_FOR_RECEIPT_RETRIES: number; - WAIT_FOR_RECEIPT_INITIAL_BACKOFF: number; -}; diff --git a/dist/ContractInteractor.d.ts b/dist/ContractInteractor.d.ts deleted file mode 100644 index e1ce4eb..0000000 --- a/dist/ContractInteractor.d.ts +++ /dev/null @@ -1,132 +0,0 @@ -import Web3 from 'web3'; -import { BlockTransactionString } from 'web3-eth'; -import { EventData, PastEventOptions } from 'web3-eth-contract'; -import { PrefixedHexString, TransactionOptions } from 'ethereumjs-tx'; -import { BlockNumber, HttpProvider, IpcProvider, provider, Transaction, TransactionReceipt, WebsocketProvider } from 'web3-core'; -import { DeployRequest, RelayRequest } from './EIP712/RelayRequest'; -import { RelayManagerData } from '@rsksmart/rif-relay-contracts'; -import { IForwarderInstance, IRelayVerifierInstance, IRelayHubInstance, IDeployVerifierInstance, IWalletFactoryInstance, ITokenHandlerInstance } from '@rsksmart/rif-relay-contracts/types/truffle-contracts'; -import { EnvelopingConfig } from './types/EnvelopingConfig'; -import EnvelopingTransactionDetails from './types/EnvelopingTransactionDetails'; -import BN from 'bn.js'; -import { DeployTransactionRequest, RelayTransactionRequest } from './types/RelayTransactionRequest'; -declare type EventName = string; -export interface EstimateGasParams { - from: string; - to: string; - data: PrefixedHexString; - gasPrice?: PrefixedHexString; -} -export declare const RelayServerRegistered: EventName; -export declare const RelayWorkersAdded: EventName; -export declare const TransactionRelayed: EventName; -export declare const TransactionRejectedByRecipient: EventName; -export declare const StakeAdded: EventName; -export declare const StakeUnlocked: EventName; -export declare const StakeWithdrawn: EventName; -export declare const StakePenalized: EventName; -export declare type Web3Provider = HttpProvider | IpcProvider | WebsocketProvider; -export default class ContractInteractor { - private readonly VERSION; - private readonly IRelayVerifierContract; - private readonly IDeployVerifierContract; - private readonly ITokenHandlerContract; - private readonly IRelayHubContract; - private readonly IForwarderContract; - private readonly IWalletFactoryContract; - private relayVerifierInstance; - private deployVerifierInstance; - relayHubInstance: IRelayHubInstance; - readonly web3: Web3; - private readonly provider; - private readonly config; - private readonly versionManager; - private rawTxOptions?; - chainId: number; - private networkId?; - private networkType?; - constructor(provider: Web3Provider, config: EnvelopingConfig); - getProvider(): provider; - init(): Promise; - isInitialized(): boolean; - _setNetworkType(): Promise; - getAsyncChainId(): Promise; - _validateCompatibility(): Promise; - _validateVersion(version: string): void; - _initializeContracts(): Promise; - getRawTxOptions(): TransactionOptions; - _createRelayVerifier(address: string): Promise; - _createDeployVerifier(address: string): Promise; - createTokenHandler(address: string): Promise; - _createRelayHub(address: string): Promise; - _createForwarder(address: string): Promise; - _createFactory(address: string): Promise; - getSenderNonce(sWallet: string): Promise; - getFactoryNonce(factoryAddr: string, from: string): Promise; - _getBlockGasLimit(): Promise; - validateAcceptRelayCall(relayRequest: RelayRequest, signature: PrefixedHexString): Promise<{ - verifierAccepted: boolean; - returnValue: string; - reverted: boolean; - revertedInDestination: boolean; - }>; - validateAcceptDeployCall(request: DeployTransactionRequest): Promise<{ - verifierAccepted: boolean; - returnValue: string; - reverted: boolean; - }>; - getMaxViewableDeployGasLimit(request: DeployTransactionRequest): Promise; - estimateRelayTransactionMaxPossibleGas(relayRequest: RelayRequest, signature: PrefixedHexString): Promise; - estimateRelayTransactionMaxPossibleGasWithTransactionRequest(request: RelayTransactionRequest): Promise; - estimateDestinationContractCallGas(transactionDetails: EstimateGasParams, addCushion?: boolean): Promise; - getMaxViewableRelayGasLimit(relayRequest: RelayRequest, signature: PrefixedHexString): Promise; - encodeRelayCallABI(relayRequest: RelayRequest, sig: PrefixedHexString): PrefixedHexString; - encodeDeployCallABI(relayRequest: DeployRequest, sig: PrefixedHexString): PrefixedHexString; - getActiveRelayInfo(relayManagers: Set): Promise; - getRelayInfo(relayManagers: Set): Promise; - getPastEventsForHub(extraTopics: string[], options: PastEventOptions, names?: EventName[]): Promise; - getPastEventsForStakeManagement(names: EventName[], extraTopics: string[], options: PastEventOptions): Promise; - _getPastEvents(contract: any, names: EventName[], extraTopics: string[], options: PastEventOptions): Promise; - getBalance(address: string, defaultBlock?: BlockNumber): Promise; - getBlockNumber(): Promise; - sendSignedTransaction(rawTx: string): Promise; - estimateGas(transactionDetails: EnvelopingTransactionDetails): Promise; - getGasPrice(): Promise; - getTransactionCount(address: string, defaultBlock?: BlockNumber): Promise; - getTransaction(transactionHash: string): Promise; - getBlock(blockHashOrBlockNumber: BlockNumber): Promise; - validateAddress(address: string, exceptionTitle?: string): void; - getCode(address: string): Promise; - getChainId(): number; - getNetworkId(): number; - getNetworkType(): string; - isContractDeployed(address: string): Promise; - getStakeInfo(managerAddress: string): Promise<{ - stake: string; - unstakeDelay: string; - withdrawBlock: string; - owner: string; - }>; - walletFactoryDeployEstimateGasForInternalCall(request: DeployRequest, factory: string, domainHash: string, suffixData: string, signature: string, testCall?: boolean): Promise; - walletFactoryEstimateGasOfDeployCall(request: DeployTransactionRequest): Promise; - getRegisterRelayMethod(url: string): Promise; - getAddRelayWorkersMethod(workers: string[]): Promise; - /** - * Web3.js as of 1.2.6 (see web3-core-method::_confirmTransaction) does not allow - * broadcasting of a transaction without waiting for it to be mined. - * This method sends the RPC call directly - * @param signedTransaction - the raw signed transaction to broadcast - */ - broadcastTransaction(signedTransaction: PrefixedHexString): Promise; - getTransactionReceipt(transactionHash: PrefixedHexString, retries?: number, initialBackoff?: number): Promise; -} -/** - * Ganache does not seem to enforce EIP-155 signature. Buidler does, though. - * This is how {@link Transaction} constructor allows support for custom and private network. - * @param chainId - * @param networkId - * @param chain - * @return {{common: Common}} - */ -export declare function getRawTxOptions(chainId: number, networkId: number, chain?: string): TransactionOptions; -export {}; diff --git a/dist/EIP712/ForwardRequest.d.ts b/dist/EIP712/ForwardRequest.d.ts deleted file mode 100644 index 7d46cfe..0000000 --- a/dist/EIP712/ForwardRequest.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { PrefixedHexString } from 'ethereumjs-tx'; -export interface ForwardRequest { - relayHub: string; - from: string; - to: string; - tokenContract: string; - value: string; - gas: string; - nonce: string; - tokenAmount: string; - tokenGas: string; - data: PrefixedHexString; -} -export interface DeployRequestStruct { - relayHub: string; - from: string; - to: string; - tokenContract: string; - recoverer: string; - value: string; - nonce: string; - tokenAmount: string; - tokenGas: string; - index: string; - data: PrefixedHexString; -} diff --git a/dist/EIP712/RelayData.d.ts b/dist/EIP712/RelayData.d.ts deleted file mode 100644 index bacfc67..0000000 --- a/dist/EIP712/RelayData.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { PrefixedHexString } from 'ethereumjs-tx'; -export default interface RelayData { - gasPrice: string; - domainSeparator: PrefixedHexString; - relayWorker: string; - callForwarder: string; - callVerifier: string; -} diff --git a/dist/EIP712/RelayRequest.d.ts b/dist/EIP712/RelayRequest.d.ts deleted file mode 100644 index 26f211a..0000000 --- a/dist/EIP712/RelayRequest.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -import RelayData from './RelayData'; -import { ForwardRequest, DeployRequestStruct } from './ForwardRequest'; -export interface RelayRequest { - request: ForwardRequest; - relayData: RelayData; -} -export interface DeployRequest { - request: DeployRequestStruct; - relayData: RelayData; -} -export declare function cloneRelayRequest(relayRequest: RelayRequest): RelayRequest; -export declare function cloneDeployRequest(deployRequest: DeployRequest): DeployRequest; diff --git a/dist/EIP712/TypedRequestData.d.ts b/dist/EIP712/TypedRequestData.d.ts deleted file mode 100644 index 706962d..0000000 --- a/dist/EIP712/TypedRequestData.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { DeployRequest, RelayRequest } from './RelayRequest'; -import { EIP712Domain, EIP712TypedData, EIP712TypeProperty, EIP712Types } from 'eth-sig-util'; -import { PrefixedHexString } from 'ethereumjs-tx'; -export declare const EIP712DomainType: { - name: string; - type: string; -}[]; -export declare const ForwardRequestType: { - name: string; - type: string; -}[]; -export declare const DeployRequestDataType: { - name: string; - type: string; -}[]; -interface Types extends EIP712Types { - EIP712Domain: EIP712TypeProperty[]; - RelayRequest: EIP712TypeProperty[]; - RelayData: EIP712TypeProperty[]; -} -export declare const DomainSeparatorType: { - prefix: string; - name: string; - version: string; -}; -export declare function getDomainSeparator(verifyingContract: string, chainId: number): EIP712Domain; -export declare function getDomainSeparatorHash(verifier: string, chainId: number): PrefixedHexString; -export default class TypedRequestData implements EIP712TypedData { - readonly types: Types; - readonly domain: EIP712Domain; - readonly primaryType: string; - readonly message: any; - constructor(chainId: number, verifier: string, relayRequest: RelayRequest); -} -export declare class TypedDeployRequestData implements EIP712TypedData { - readonly types: Types; - readonly domain: EIP712Domain; - readonly primaryType: string; - readonly message: any; - constructor(chainId: number, verifier: string, relayRequest: DeployRequest); -} -export declare const ENVELOPING_PARAMS = "address relayHub,address from,address to,address tokenContract,uint256 value,uint256 gas,uint256 nonce,uint256 tokenAmount,uint256 tokenGas,bytes data"; -export declare const DEPLOY_PARAMS = "address relayHub,address from,address to,address tokenContract,address recoverer,uint256 value,uint256 nonce,uint256 tokenAmount,uint256 tokenGas,uint256 index,bytes data"; -export declare const RequestType: { - typeName: string; - typeSuffix: string; -}; -export {}; diff --git a/dist/Environments.d.ts b/dist/Environments.d.ts deleted file mode 100644 index cbb1c9d..0000000 --- a/dist/Environments.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -/** - * We will need some mechanism to support different constants and algorithms for different networks. - * So far the only conflict we will have is migration to Istanbul, as ETC does not integrate it as of this writing. - * TODO: see the differences between networks we want to support and make project structure multi-chain - */ -import { RelayHubConfiguration } from './types/RelayHubConfiguration'; -export interface Environment { - readonly chainId: number; - readonly mintxgascost: number; - readonly relayHubConfiguration: RelayHubConfiguration; -} -export declare const environments: { - [key: string]: Environment; -}; -export declare const defaultEnvironment: Environment; -export declare function getEnvironment(networkName: string): Environment; -export declare function isRsk(environment: Environment): boolean; diff --git a/dist/ErrorReplacerJSON.d.ts b/dist/ErrorReplacerJSON.d.ts deleted file mode 100644 index 6e190c1..0000000 --- a/dist/ErrorReplacerJSON.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export default function replaceErrors(key: string, value: { - [key: string]: any; -}): any; diff --git a/dist/PingResponse.d.ts b/dist/PingResponse.d.ts deleted file mode 100644 index 8cac8e3..0000000 --- a/dist/PingResponse.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -export default interface PingResponse { - relayWorkerAddress: string; - relayManagerAddress: string; - relayHubAddress: string; - minGasPrice: string; - networkId?: string; - chainId?: string; - ready: boolean; - version: string; -} diff --git a/dist/TokenResponse.d.ts b/dist/TokenResponse.d.ts deleted file mode 100644 index 5f5a7e4..0000000 --- a/dist/TokenResponse.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export default interface TokenResponse { - [verifier: string]: string[]; -} diff --git a/dist/Utils.d.ts b/dist/Utils.d.ts deleted file mode 100644 index 15c3e6b..0000000 --- a/dist/Utils.d.ts +++ /dev/null @@ -1,44 +0,0 @@ -/// -/// -import { EIP712TypedData } from 'eth-sig-util'; -import { EventData } from 'web3-eth-contract'; -import { PrefixedHexString } from 'ethereumjs-tx'; -import { RelayManagerData } from '@rsksmart/rif-relay-contracts'; -import { DeployTransactionRequest, RelayTransactionRequest } from './types/RelayTransactionRequest'; -export declare function removeHexPrefix(hex: string): string; -export declare function padTo64(hex: string): string; -export declare function event2topic(contract: any, names: string[]): any; -export declare function addresses2topics(addresses: string[]): string[]; -export declare function address2topic(address: string): string; -export declare function decodeRevertReason(revertBytes: PrefixedHexString, throwOnError?: boolean): string | null; -export declare function getLocalEip712Signature(typedRequestData: EIP712TypedData, privateKey: Buffer): PrefixedHexString; -export declare function getEip712Signature(web3: Web3, typedRequestData: EIP712TypedData, methodSuffix?: string, jsonStringifyRequest?: boolean): Promise; -/** - * @returns maximum possible gas consumption by this deploy call - */ -export declare function calculateDeployTransactionMaxPossibleGas(estimatedDeployGas: string, estimatedTokenPaymentGas?: string): BN; -/** - * @returns maximum possible gas consumption by this relay call - * Note that not using the linear fit would result in an Inadequate amount of gas - * You can add another kind of estimation (a hardcoded value for example) in that "else" statement - * if you don't then use this function with usingLinearFit = true - */ -export declare function estimateMaxPossibleRelayCallWithLinearFit(relayCallGasLimit: number, tokenPaymentGas: number, addCushion?: boolean): number; -export declare function parseHexString(str: string): number[]; -export declare function isSameAddress(address1: string, address2: string): boolean; -export declare function sleep(ms: number): Promise; -export declare function randomInRange(min: number, max: number): number; -export declare function isSecondEventLater(a: EventData, b: EventData): boolean; -export declare function getLatestEventData(events: EventData[]): EventData | undefined; -export declare function isRegistrationValid(relayData: RelayManagerData | undefined, config: any, managerAddress: string): boolean; -export interface VerifierGasLimits { - preRelayedCallGasLimit: string; - postRelayedCallGasLimit: string; -} -export interface Signature { - v: number[]; - r: number[]; - s: number[]; -} -export declare function boolString(bool: boolean): string; -export declare function transactionParamDataCost(req: RelayTransactionRequest | DeployTransactionRequest): number; diff --git a/dist/VerifierResponse.d.ts b/dist/VerifierResponse.d.ts deleted file mode 100644 index aa4b40b..0000000 --- a/dist/VerifierResponse.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export default interface VerifierResponse { - trustedVerifiers: string[]; -} diff --git a/dist/VersionRegistry.d.ts b/dist/VersionRegistry.d.ts deleted file mode 100644 index cd49036..0000000 --- a/dist/VersionRegistry.d.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { PrefixedHexString } from 'ethereumjs-tx'; -import { Contract } from 'web3-eth-contract'; -import Web3 from 'web3'; -export declare function string32(s: string): PrefixedHexString; -export declare function bytes32toString(s: PrefixedHexString): string; -export interface VersionInfo { - value: string; - version: string; - time: number; - canceled: boolean; - cancelReason: string; -} -export declare class VersionRegistry { - readonly sendOptions: {}; - registryContract: Contract; - web3: Web3; - constructor(web3provider: any, registryAddress: PrefixedHexString, sendOptions?: {}); - isValid(): Promise; - /** - * return the latest "mature" version from the registry - * - * @dev: current time is last block's timestamp. This resolves any client time-zone discrepancies, - * but on local ganache, note that the time doesn't advance unless you mine transactions. - * - * @param id object id to return a version for - * @param delayPeriod - don't return entries younger than that (in seconds) - * @param optInVersion - if set, return this version even if it is young - * @return version info that include actual version used, its timestamp and value. - */ - getVersion(id: string, delayPeriod: number, optInVersion?: string): Promise; - /** - * return all version history of the given id - * @param id object id to return version history for - */ - getAllVersions(id: string): Promise; - listIds(): Promise; - addVersion(id: string, version: string, value: string, sendOptions?: {}): Promise; - cancelVersion(id: string, version: string, cancelReason?: string, sendOptions?: {}): Promise; - private checkVersion; -} diff --git a/dist/VersionsManager.d.ts b/dist/VersionsManager.d.ts deleted file mode 100644 index 2b442a3..0000000 --- a/dist/VersionsManager.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -export default class VersionsManager { - readonly componentVersion: string; - /** - * @param componentVersion - a semver of a component that uses the VersionsManager - */ - constructor(componentVersion: string); - /** - * @param version - the version of a dependency to compare against - * @return true if {@param version} is same or newer then {@link componentVersion} - */ - isMinorSameOrNewer(version: string): boolean; -} diff --git a/dist/dev/NetworkSimulatingProvider.d.ts b/dist/dev/NetworkSimulatingProvider.d.ts deleted file mode 100644 index b3ac9da..0000000 --- a/dist/dev/NetworkSimulatingProvider.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { PrefixedHexString } from 'ethereumjs-tx'; -import { JsonRpcPayload } from 'web3-core-helpers'; -import { WrapperProviderBase } from './WrapperProviderBase'; -import { SendCallback } from './SendCallback'; -import { HttpProvider } from 'web3-core'; -export declare class NetworkSimulatingProvider extends WrapperProviderBase { - private isDelayTransactionsOn; - mempool: Map; - constructor(provider: HttpProvider); - setDelayTransactions(delayTransactions: boolean): void; - calculateTxHash(payload: JsonRpcPayload): PrefixedHexString; - send(payload: JsonRpcPayload, callback: SendCallback): void; - supportsSubscriptions(): boolean; - mineTransaction(txHash: PrefixedHexString): Promise; -} diff --git a/dist/dev/ProfilingProvider.d.ts b/dist/dev/ProfilingProvider.d.ts deleted file mode 100644 index 53b773c..0000000 --- a/dist/dev/ProfilingProvider.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { HttpProvider } from 'web3-core'; -import { JsonRpcPayload } from 'web3-core-helpers'; -import { SendCallback } from './SendCallback'; -import { WrapperProviderBase } from './WrapperProviderBase'; -export declare class ProfilingProvider extends WrapperProviderBase { - methodsCount: Map; - requestsCount: number; - logTraffic: boolean; - constructor(provider: HttpProvider, logTraffic?: boolean); - disconnect(): boolean; - supportsSubscriptions(): boolean; - send(payload: JsonRpcPayload, callback: SendCallback): void; - reset(): void; - log(): void; -} diff --git a/dist/dev/SendCallback.d.ts b/dist/dev/SendCallback.d.ts deleted file mode 100644 index 1eb2c7e..0000000 --- a/dist/dev/SendCallback.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import { JsonRpcResponse } from 'web3-core-helpers'; -export declare type SendCallback = (error: Error | null, result?: JsonRpcResponse) => void; diff --git a/dist/dev/WrapperProviderBase.d.ts b/dist/dev/WrapperProviderBase.d.ts deleted file mode 100644 index 504a6d6..0000000 --- a/dist/dev/WrapperProviderBase.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { HttpProvider } from 'web3-core'; -import { SendCallback } from './SendCallback'; -import { JsonRpcPayload } from 'web3-core-helpers'; -export declare abstract class WrapperProviderBase implements HttpProvider { - provider: HttpProvider; - protected constructor(provider: HttpProvider); - get connected(): boolean; - get host(): string; - disconnect(): boolean; - abstract send(payload: JsonRpcPayload, callback: SendCallback): void; - supportsSubscriptions(): boolean; -} diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 01da6eb..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -import RelayData from './EIP712/RelayData'; -import TypedRequestData from './EIP712/TypedRequestData'; -import EnvelopingTransactionDetails from './types/EnvelopingTransactionDetails'; -import ContractInteractor from './ContractInteractor'; -import replaceErrors from './ErrorReplacerJSON'; -import PingResponse from './PingResponse'; -import TokenResponse from './TokenResponse'; -import VerifierResponse from './VerifierResponse'; -import VersionsManager from './VersionsManager'; -export * from './dev/NetworkSimulatingProvider'; -export * from './dev/ProfilingProvider'; -export * from './dev/SendCallback'; -export * from './dev/WrapperProviderBase'; -export * from './EIP712/ForwardRequest'; -export * from './EIP712/RelayRequest'; -export * from './EIP712/TypedRequestData'; -export * from './types/EnvelopingConfig'; -export * from './types/EnvelopingTransactionDetails'; -export * from './types/RelayHubConfiguration'; -export * from './types/RelayTransactionRequest'; -export * from './AmountRequired'; -export * from './Constants'; -export * from './ContractInteractor'; -export * from './Environments'; -export * from './Utils'; -export * from './VersionRegistry'; -export { RelayData, TypedRequestData, EnvelopingTransactionDetails, ContractInteractor, replaceErrors, PingResponse, TokenResponse, VerifierResponse, VersionsManager }; diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e5179c6..0000000 --- a/dist/index.js +++ /dev/null @@ -1 +0,0 @@ -(()=>{"use strict";var e={945:function(e,t,r){var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.AmountRequired=void 0;const n=a(r(742)),i=a(r(732)),s=r(784),o=r(675);t.AmountRequired=class{constructor(e,t,r){this._currentValue=s.toBN(0),this._requiredValue=s.toBN(0),this._name=e,this._requiredValue=t,this._listener=r}get currentValue(){return this._currentValue}set currentValue(e){const t=!this._currentValue.eq(e),r=this.isSatisfied;this._currentValue=e,t&&this._onChange(r)}get requiredValue(){return this._requiredValue}set requiredValue(e){const t=!this._requiredValue.eq(e),r=this.isSatisfied;this._requiredValue=e,t&&this._onChange(r)}_onChange(e){let t;t=e===this.isSatisfied?"still"+(this.isSatisfied?"":" not"):this.isSatisfied?"now":"no longer";const r=`${this._name} requirement is ${t} satisfied\n${this.description}`;i.default.warn(r),null!=this._listener&&this._listener()}get isSatisfied(){return this._currentValue.gte(this._requiredValue)}get description(){const e=o.boolString(this.isSatisfied),t=new n.default(this._currentValue).toEth().toFixed(4),r=new n.default(this._requiredValue).toEth().toFixed(4);return`${this._name.padEnd(14)} | ${e.padEnd(14)} | actual: ${t.padStart(12)} RBTC | required: ${r.padStart(12)} RBTC`}}},738:function(e,t,r){var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.constants=void 0;const n=a(r(416)),i=r(784).toBN(1e18);t.constants={dayInSec:86400,weekInSec:604800,oneEther:i,ZERO_ADDRESS:"0x0000000000000000000000000000000000000000",ZERO_BYTES32:"0x0000000000000000000000000000000000000000000000000000000000000000",MAX_UINT256:new n.default("2").pow(new n.default("256")).sub(new n.default("1")),MAX_INT256:new n.default("2").pow(new n.default("255")).sub(new n.default("1")),MIN_INT256:new n.default("2").pow(new n.default("255")).mul(new n.default("-1")),SHA3_NULL_S:"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",TRANSACTION_CREATE_CONTRACT_GAS_COST:53e3,TRANSACTION_GAS_COST:21e3,TX_ZERO_DATA_GAS_COST:4,TX_NO_ZERO_DATA_GAS_COST:68,MAX_ESTIMATED_GAS_DEVIATION:.2,ESTIMATED_GAS_CORRECTION_FACTOR:1,INTERNAL_TRANSACTION_ESTIMATE_CORRECTION:2e4,WAIT_FOR_RECEIPT_RETRIES:6,WAIT_FOR_RECEIPT_INITIAL_BACKOFF:1e3}},359:function(e,t,r){var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getRawTxOptions=t.StakePenalized=t.StakeWithdrawn=t.StakeUnlocked=t.StakeAdded=t.TransactionRejectedByRecipient=t.TransactionRelayed=t.RelayWorkersAdded=t.RelayServerRegistered=void 0;const n=a(r(477)),i=a(r(409)),s=a(r(732)),o=r(820),l=r(675),u=r(738),c=a(r(319)),d=a(r(223)),y=r(784),h=r(414);a(r(748)).default.install({errorFormatterForce:!0}),t.RelayServerRegistered="RelayServerRegistered",t.RelayWorkersAdded="RelayWorkersAdded",t.TransactionRelayed="TransactionRelayed",t.TransactionRejectedByRecipient="TransactionRelayedButRevertedByRecipient";const f=[t.RelayServerRegistered,t.RelayWorkersAdded,t.TransactionRelayed,t.TransactionRejectedByRecipient];function p(e,t,r){return null!=r&&"main"!==r&&"private"!==r||(r="mainnet"),{common:n.default.forCustomChain(r,{chainId:e,networkId:t},"istanbul")}}t.StakeAdded="StakeAdded",t.StakeUnlocked="StakeUnlocked",t.StakeWithdrawn="StakeWithdrawn",t.StakePenalized="StakePenalized",t.default=class{constructor(e,t){this.VERSION="2.0.1",this.versionManager=new d.default(this.VERSION),this.web3=new i.default(e),this.config=t,this.provider=e,this.chainId=t.chainId,this.IRelayVerifierContract=h({contractName:"IRelayVerifier",abi:o.IRelayVerifier.abi}),this.IDeployVerifierContract=h({contractName:"IDeployVerifier",abi:o.IDeployVerifier.abi}),this.IRelayHubContract=h({contractName:"IRelayHub",abi:o.IRelayHub.abi}),this.IForwarderContract=h({contractName:"IForwarder",abi:o.IForwarder.abi}),this.IWalletFactoryContract=h({contractName:"IWalletFactory",abi:o.IWalletFactory.abi}),this.ITokenHandlerContract=h({contractName:"ITokenHandler",abi:o.ITokenHandler.abi}),this.IRelayHubContract.setProvider(this.provider,void 0),this.IRelayVerifierContract.setProvider(this.provider,void 0),this.IDeployVerifierContract.setProvider(this.provider,void 0),this.IForwarderContract.setProvider(this.provider,void 0),this.IWalletFactoryContract.setProvider(this.provider,void 0),this.ITokenHandlerContract.setProvider(this.provider,void 0)}getProvider(){return this.provider}async init(){if(s.default.debug("Contract Interactor - Initializing"),this.isInitialized())throw new Error("_init has already called");await this._initializeContracts(),s.default.debug("Contract Interactor - Initialized succesfully"),await this._validateCompatibility().catch((e=>s.default.warn("WARNING: beta ignore version compatibility",e.message))),this.chainId=await this.web3.eth.getChainId(),this.networkId=await this.web3.eth.net.getId(),await this._setNetworkType(),s.default.debug(`Contract Interactor - Using chainId: ${this.chainId}, networkId:${this.networkId} , networkType:${this.networkType} `),this.rawTxOptions=p(this.chainId,this.networkId,this.networkType)}isInitialized(){return null!=this.rawTxOptions}async _setNetworkType(){try{this.networkType=await this.web3.eth.net.getNetworkType()}catch(e){s.default.warn("WARNING: Could not retrieve the network type, used default value private"),this.networkType="private"}}async getAsyncChainId(){return await this.web3.eth.getChainId()}async _validateCompatibility(){if(this.config.relayHubAddress===u.constants.ZERO_ADDRESS)return;const e=this.relayHubInstance,t=await e.versionHub();this._validateVersion(t)}_validateVersion(e){if(!this.versionManager.isMinorSameOrNewer(e))throw new Error(`Provided Hub version(${e}) is not supported by the current interactor(${this.versionManager.componentVersion})`)}async _initializeContracts(){this.config.relayHubAddress!==u.constants.ZERO_ADDRESS&&(this.relayHubInstance=await this._createRelayHub(this.config.relayHubAddress),s.default.debug(`Contract Interactor - Relay Hub initialized: ${this.relayHubInstance.address}`)),this.config.relayVerifierAddress!==u.constants.ZERO_ADDRESS&&(this.relayVerifierInstance=await this._createRelayVerifier(this.config.relayVerifierAddress),s.default.debug(`Contract Interactor - Relay Verifier initialized: ${this.relayVerifierInstance.address}`)),this.config.deployVerifierAddress!==u.constants.ZERO_ADDRESS&&(this.deployVerifierInstance=await this._createDeployVerifier(this.config.deployVerifierAddress),s.default.debug(`Contract Interactor - Deploy Verifier initialized: ${this.deployVerifierInstance.address}`)),s.default.info("Contracts initialized correctly")}getRawTxOptions(){if(null==this.rawTxOptions)throw new Error("_init not called");return this.rawTxOptions}async _createRelayVerifier(e){return await this.IRelayVerifierContract.at(e)}async _createDeployVerifier(e){return await this.IDeployVerifierContract.at(e)}async createTokenHandler(e){return await this.ITokenHandlerContract.at(e)}async _createRelayHub(e){return await this.IRelayHubContract.at(e)}async _createForwarder(e){return await this.IForwarderContract.at(e)}async _createFactory(e){return await this.IWalletFactoryContract.at(e)}async getSenderNonce(e){const t=await this._createForwarder(e);return(await t.nonce()).toString()}async getFactoryNonce(e,t){const r=await this._createFactory(e);return(await r.nonce(t)).toString()}async _getBlockGasLimit(){return(await this.web3.eth.getBlock("latest")).gasLimit}async validateAcceptRelayCall(e,t){const r=this.relayHubInstance,a=await this.getMaxViewableRelayGasLimit(e,t);if(0===a)return{verifierAccepted:!1,reverted:!1,returnValue:`relayWorker ${e.relayData.relayWorker} does not have enough balance to cover the maximum possible gas for this transaction`,revertedInDestination:!1};try{await this.relayVerifierInstance.contract.methods.verifyRelayedCall(e,t).call({from:e.relayData.relayWorker},"pending")}catch(e){return{verifierAccepted:!1,reverted:!1,returnValue:`view call to 'relayCall' reverted in verifier: ${e instanceof Error?e.message:JSON.stringify(e,c.default)}`,revertedInDestination:!1}}try{return{verifierAccepted:!0,reverted:!1,returnValue:"",revertedInDestination:!await r.contract.methods.relayCall(e,t).call({from:e.relayData.relayWorker,gasPrice:e.relayData.gasPrice,gas:y.toHex(a)})}}catch(e){return{verifierAccepted:!0,reverted:!0,returnValue:`view call to 'relayCall' reverted in client: ${e instanceof Error?e.message:JSON.stringify(e,c.default)}`,revertedInDestination:!1}}}async validateAcceptDeployCall(e){const t=this.relayHubInstance,r=await this.getMaxViewableDeployGasLimit(e);if(r.eq(y.toBN(0)))return{verifierAccepted:!1,reverted:!1,returnValue:`relayWorker ${e.relayRequest.relayData.relayWorker} does not have enough balance to cover the maximum possible gas for this transaction`};try{await this.deployVerifierInstance.contract.methods.verifyRelayedCall(e.relayRequest,e.metadata.signature).call({from:e.relayRequest.relayData.relayWorker})}catch(e){return{verifierAccepted:!1,reverted:!1,returnValue:`view call to 'deploy call' reverted in verifier: ${e instanceof Error?e.message:JSON.stringify(e,c.default)}`}}try{return{verifierAccepted:!0,reverted:!1,returnValue:(await t.contract.methods.deployCall(e.relayRequest,e.metadata.signature).call({from:e.relayRequest.relayData.relayWorker,gasPrice:e.relayRequest.relayData.gasPrice,gas:r})).returnValue}}catch(e){return{verifierAccepted:!0,reverted:!0,returnValue:`view call to 'deployCall' reverted in client: ${e instanceof Error?e.message:JSON.stringify(e,c.default)}`}}}async getMaxViewableDeployGasLimit(e){const t=y.toBN(e.relayRequest.relayData.gasPrice);let r=y.toBN(0);if(!t.eq(y.toBN(0))){const a=y.toBN(await this.walletFactoryEstimateGasOfDeployCall(e));y.toBN(await this.getBalance(e.relayRequest.relayData.relayWorker)).div(t).gte(a)&&(r=a)}return r}async estimateRelayTransactionMaxPossibleGas(e,t){const r=await this.estimateGas({from:e.relayData.relayWorker,to:e.request.relayHub,data:this.relayHubInstance.contract.methods.relayCall(e,t).encodeABI(),gasPrice:e.relayData.gasPrice});return Math.ceil(r*u.constants.ESTIMATED_GAS_CORRECTION_FACTOR)}async estimateRelayTransactionMaxPossibleGasWithTransactionRequest(e){if(void 0===e.metadata.relayHubAddress||null===e.metadata.relayHubAddress||e.metadata.relayHubAddress===u.constants.ZERO_ADDRESS)throw new Error("calculateDeployCallGas: RelayHub must be defined");const t=(await this._createRelayHub(e.metadata.relayHubAddress)).contract.methods.relayCall(e.relayRequest,e.metadata.signature),r=await t.estimateGas({from:e.relayRequest.relayData.relayWorker,gasPrice:e.relayRequest.relayData.gasPrice});return Math.ceil(r*u.constants.ESTIMATED_GAS_CORRECTION_FACTOR)}async estimateDestinationContractCallGas(e,t=!0){const r=await this.estimateGas({from:e.from,to:e.to,gasPrice:e.gasPrice,data:e.data});let a=r>u.constants.INTERNAL_TRANSACTION_ESTIMATE_CORRECTION?r-u.constants.INTERNAL_TRANSACTION_ESTIMATE_CORRECTION:r;return t&&(a*=u.constants.ESTIMATED_GAS_CORRECTION_FACTOR),a}async getMaxViewableRelayGasLimit(e,t){const r=y.toBN(e.relayData.gasPrice);let a=0;if(r.gt(y.toBN(0))){const n=await this.estimateRelayTransactionMaxPossibleGas(e,t);y.toBN(await this.getBalance(e.relayData.relayWorker)).div(r).gte(y.toBN(n))&&(a=n)}return a}encodeRelayCallABI(e,t){return new this.IRelayHubContract("").contract.methods.relayCall(e,t).encodeABI()}encodeDeployCallABI(e,t){return new this.IRelayHubContract("").contract.methods.deployCall(e,t).encodeABI()}async getActiveRelayInfo(e){return(await this.getRelayInfo(e)).filter((e=>e.registered&&e.currentlyStaked))}async getRelayInfo(e){const t=Array.from(e).map((e=>this.relayHubInstance.getRelayInfo(e)));return await Promise.all(t)}async getPastEventsForHub(e,t,r=f){return await this._getPastEvents(this.relayHubInstance.contract,r,e,t)}async getPastEventsForStakeManagement(e,t,r){const a=this.relayHubInstance;return await this._getPastEvents(a.contract,e,t,r)}async _getPastEvents(e,t,r,a){const n=[],i=l.event2topic(e,t);return n.push(i),r.length>0&&n.push(r),e.getPastEvents("allEvents",Object.assign({},a,{topics:n}))}async getBalance(e,t="latest"){return await this.web3.eth.getBalance(e,t)}async getBlockNumber(){return await this.web3.eth.getBlockNumber()}async sendSignedTransaction(e){return await this.web3.eth.sendSignedTransaction(e)}async estimateGas(e){return await this.web3.eth.estimateGas(e)}async getGasPrice(){return await this.web3.eth.getGasPrice()}async getTransactionCount(e,t){return await this.web3.eth.getTransactionCount(e,t)}async getTransaction(e){return await this.web3.eth.getTransaction(e)}async getBlock(e){return await this.web3.eth.getBlock(e)}validateAddress(e,t="invalid address:"){if(!this.web3.utils.isAddress(e))throw new Error(t+" "+e)}async getCode(e){return await this.web3.eth.getCode(e)}getChainId(){if(null==this.chainId)throw new Error("_init not called");return this.chainId}getNetworkId(){if(null==this.networkId)throw new Error("_init not called");return this.networkId}getNetworkType(){if(null==this.networkType)throw new Error("_init not called");return this.networkType}async isContractDeployed(e){const t=await this.getCode(e);return"0x"!==t&&"0x00"!==t}async getStakeInfo(e){return await this.relayHubInstance.getStakeInfo(e)}async walletFactoryDeployEstimateGasForInternalCall(e,t,r,a,n,i=!1){const s=(await this._createFactory(t)).contract.methods.relayedUserSmartWalletCreation(e.request,r,a,n);return i&&await s.call({from:e.request.relayHub}),s.estimateGas({from:e.request.relayHub,gasPrice:e.relayData.gasPrice})}async walletFactoryEstimateGasOfDeployCall(e){if(void 0===e.metadata.relayHubAddress||null===e.metadata.relayHubAddress||e.metadata.relayHubAddress===u.constants.ZERO_ADDRESS)throw new Error("calculateDeployCallGas: RelayHub must be defined");return(await this._createRelayHub(e.metadata.relayHubAddress)).contract.methods.deployCall(e.relayRequest,e.metadata.signature).estimateGas({from:e.relayRequest.relayData.relayWorker,gasPrice:e.relayRequest.relayData.gasPrice})}async getRegisterRelayMethod(e){return this.relayHubInstance.contract.methods.registerRelayServer(e)}async getAddRelayWorkersMethod(e){return this.relayHubInstance.contract.methods.addRelayWorkers(e)}async broadcastTransaction(e){return await new Promise(((t,r)=>{if(null==this.provider)throw new Error("provider is not set");this.provider.send({jsonrpc:"2.0",method:"eth_sendRawTransaction",params:[e],id:Date.now()},((e,a)=>{null!=e?r(e):null!=a.error?r(a.error):t(a.result)}))}))}async getTransactionReceipt(e,t=u.constants.WAIT_FOR_RECEIPT_RETRIES,r=u.constants.WAIT_FOR_RECEIPT_INITIAL_BACKOFF){for(let a=0,n=r;a{Object.defineProperty(t,"__esModule",{value:!0})},422:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.cloneDeployRequest=t.cloneRelayRequest=void 0,t.cloneRelayRequest=function(e){return{request:Object.assign({},e.request),relayData:Object.assign({},e.relayData)}},t.cloneDeployRequest=function(e){return{request:Object.assign({},e.request),relayData:Object.assign({},e.relayData)}}},172:function(e,t,r){var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.RequestType=t.DEPLOY_PARAMS=t.ENVELOPING_PARAMS=t.TypedDeployRequestData=t.getDomainSeparatorHash=t.getDomainSeparator=t.DomainSeparatorType=t.DeployRequestDataType=t.ForwardRequestType=t.EIP712DomainType=void 0;const n=r(458),i=r(519);a(r(748)).default.install({errorFormatterForce:!0}),t.EIP712DomainType=[{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"}];const s=[{name:"gasPrice",type:"uint256"},{name:"domainSeparator",type:"bytes32"},{name:"relayWorker",type:"address"},{name:"callForwarder",type:"address"},{name:"callVerifier",type:"address"}];t.ForwardRequestType=[{name:"relayHub",type:"address"},{name:"from",type:"address"},{name:"to",type:"address"},{name:"tokenContract",type:"address"},{name:"value",type:"uint256"},{name:"gas",type:"uint256"},{name:"nonce",type:"uint256"},{name:"tokenAmount",type:"uint256"},{name:"tokenGas",type:"uint256"},{name:"data",type:"bytes"}],t.DeployRequestDataType=[{name:"relayHub",type:"address"},{name:"from",type:"address"},{name:"to",type:"address"},{name:"tokenContract",type:"address"},{name:"recoverer",type:"address"},{name:"value",type:"uint256"},{name:"nonce",type:"uint256"},{name:"tokenAmount",type:"uint256"},{name:"tokenGas",type:"uint256"},{name:"index",type:"uint256"},{name:"data",type:"bytes"}];const o=[...t.ForwardRequestType,{name:"relayData",type:"RelayData"}],l=[...t.DeployRequestDataType,{name:"relayData",type:"RelayData"}];function u(e,r){return{name:t.DomainSeparatorType.name,version:t.DomainSeparatorType.version,chainId:r,verifyingContract:e}}t.DomainSeparatorType={prefix:"string name,string version",name:"RSK Enveloping Transaction",version:"2"},t.getDomainSeparator=u,t.getDomainSeparatorHash=function(e,r){return i.bufferToHex(n.TypedDataUtils.hashStruct("EIP712Domain",u(e,r),{EIP712Domain:t.EIP712DomainType}))},t.default=class{constructor(e,r,a){this.types={EIP712Domain:t.EIP712DomainType,RelayRequest:o,RelayData:s},this.domain=u(r,e),this.primaryType="RelayRequest",this.message=Object.assign(Object.assign({},a.request),{relayData:a.relayData})}},t.TypedDeployRequestData=class{constructor(e,r,a){this.types={EIP712Domain:t.EIP712DomainType,RelayRequest:l,RelayData:s},this.domain=u(r,e),this.primaryType="RelayRequest",this.message=Object.assign(Object.assign({},a.request),{relayData:a.relayData})}},t.ENVELOPING_PARAMS="address relayHub,address from,address to,address tokenContract,uint256 value,uint256 gas,uint256 nonce,uint256 tokenAmount,uint256 tokenGas,bytes data",t.DEPLOY_PARAMS="address relayHub,address from,address to,address tokenContract,address recoverer,uint256 value,uint256 nonce,uint256 tokenAmount,uint256 tokenGas,uint256 index,bytes data",t.RequestType={typeName:"RelayRequest",typeSuffix:"RelayData relayData)RelayData(uint256 gasPrice,bytes32 domainSeparator,address relayWorker,address callForwarder,address callVerifier)"}},917:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isRsk=t.getEnvironment=t.defaultEnvironment=t.environments=void 0;const r={maxWorkerCount:10,minimumStake:1e18.toString(),minimumUnstakeDelay:1e3,minimumEntryDepositValue:1e18.toString()};t.environments={istanbul:{chainId:1,relayHubConfiguration:r,mintxgascost:21e3},constantinople:{chainId:1,relayHubConfiguration:r,mintxgascost:21e3},rsk:{chainId:33,relayHubConfiguration:r,mintxgascost:21e3}},t.defaultEnvironment=t.environments.rsk,t.getEnvironment=function(e){return e.startsWith("rsk")?t.environments.rsk:t.defaultEnvironment},t.isRsk=function(e){return 33===e.chainId}},319:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){if(t instanceof Map)return{dataType:"Map",value:Array.from(t.entries())};if(t instanceof Error){const e={};return Object.getOwnPropertyNames(t).filter((e=>!["request","response"].includes(e))).forEach((function(r){e[r]=t[r]})),e}return t}},675:function(e,t,r){var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.transactionParamDataCost=t.boolString=t.isRegistrationValid=t.getLatestEventData=t.isSecondEventLater=t.randomInRange=t.sleep=t.isSameAddress=t.parseHexString=t.estimateMaxPossibleRelayCallWithLinearFit=t.calculateDeployTransactionMaxPossibleGas=t.getEip712Signature=t.getLocalEip712Signature=t.decodeRevertReason=t.address2topic=t.addresses2topics=t.event2topic=t.padTo64=t.removeHexPrefix=void 0;const n=a(r(107)),i=r(784),s=a(r(458)),o=r(103),l=r(820),u=a(r(242)),c=r(738),d=r(414);function y(e){return"0x"+"0".repeat(24)+e.toLowerCase().slice(2)}function h(e,t){return e.toLowerCase()===t.toLowerCase()}t.removeHexPrefix=function(e){if(null==e||"function"!=typeof e.replace)throw new Error("Cannot remove hex prefix");return e.replace(/^0x/,"")},t.padTo64=function(e){return e.length<64&&(e=("0000000000000000000000000000000000000000000000000000000000000000"+e).slice(-64)),e},t.event2topic=function e(t,r){return t.options&&t.options.jsonInterface?"string"==typeof r?e(t,[r])[0]:t.options.jsonInterface.filter((e=>r.includes(e.name))).map(n.default.encodeEventSignature):r},t.addresses2topics=function(e){return e.map(y)},t.address2topic=y,t.decodeRevertReason=function(e,t=!1){if(null==e)return null;if(!e.startsWith("0x08c379a0")){if(t)throw new Error("invalid revert bytes: "+e);return e}return n.default.decodeParameter("string","0x"+e.slice(10))},t.getLocalEip712Signature=function(e,t){return s.default.signTypedData_v4(t,{data:e})},t.getEip712Signature=async function(e,t,r="",a=!1){const n=t.message.from;let i;return i=a?JSON.stringify(t):t,await new Promise(((t,a)=>{let s;s="function"==typeof e.currentProvider.sendAsync?e.currentProvider.sendAsync:e.currentProvider.send,s.bind(e.currentProvider)({method:"eth_signTypedData"+r,params:[n,i],from:n,id:Date.now()},((e,r)=>{var n;null!=(null==r?void 0:r.error)&&(e=r.error),null!=e||null==r?a(null!==(n=e.message)&&void 0!==n?n:e):t(r.result)}))}))},t.calculateDeployTransactionMaxPossibleGas=function(e,t){return void 0===t||null==t||i.toBN(t).isZero()?i.toBN(e).add(i.toBN("12000")):i.toBN(e)},t.estimateMaxPossibleRelayCallWithLinearFit=function(e,t,r=!1){const a=r?c.constants.ESTIMATED_GAS_CORRECTION_FACTOR:1;if(i.toBN(t).isZero()){const t=Number("85090.977"),r=Number("1.067")*e+t;return Math.ceil(r*a)}{const r=Number("72530.9611"),n=Number("1.1114")*(e+t)+r;return Math.ceil(n*a)}},t.parseHexString=function(e){const t=[];for(;e.length>=2;)t.push(parseInt(e.substring(0,2),16)),e=e.substring(2,e.length);return t},t.isSameAddress=h,t.sleep=async function(e){return await new Promise((t=>setTimeout(t,e)))},t.randomInRange=function(e,t){return Math.floor(Math.random()*(t-e)+e)},t.isSecondEventLater=function(e,t){return e.blockNumber===t.blockNumber?t.transactionIndex>e.transactionIndex:t.blockNumber>e.blockNumber},t.getLatestEventData=function(e){if(0!==e.length)return e.sort(((e,t)=>e.blockNumber===t.blockNumber?t.transactionIndex-e.transactionIndex:t.blockNumber-e.blockNumber))[0]},t.isRegistrationValid=function(e,t,r){const a=t.url.indexOf(":")>0;return void 0!==e&&h(e.manager,r)&&e.url.toString()===t.url.toString()+(!a&&t.port>0?":"+t.port.toString():"")},t.boolString=function(e){return e?u.default.green("good".padEnd(14)):u.default.red("wrong".padEnd(14))},t.transactionParamDataCost=function(e){var t;const r=d({contractName:"IRelayHub",abi:l.IRelayHub.abi});r.setProvider(web3.currentProvider,void 0);const a=new r(""),n=function(e){let t=!1;return void 0!==e.relayRequest.request.recoverer&&(t=!0),t}(e),i=null!==(t=(n?a.contract.methods.deployCall(e.relayRequest,e.metadata.signature):a.contract.methods.relayCall(e.relayRequest,e.metadata.signature)).encodeABI())&&void 0!==t?t:"0x",s=o.arrayify(i),u=function(e){let t=0;for(let r=0;re.timestamp))]),i=a.find((e=>!e.canceled&&(e.time+t<=n||e.version===r)));if(null==i)throw new Error(`getVersion(${e}) - no version found`);return i}async getAllVersions(e){const t=await this.registryContract.getPastEvents("allEvents",{fromBlock:1,topics:[null,o(e)]}),r=t.filter((e=>"VersionCanceled"===e.event)).reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.returnValues.version]:t.returnValues.reason})),{}),a=new Set;return t.filter((e=>"VersionAdded"===e.event)).map((e=>({version:l(e.returnValues.version),canceled:null!=r[e.returnValues.version],cancelReason:r[e.returnValues.version],value:e.returnValues.value,time:parseInt(e.returnValues.time)}))).filter((e=>!a.has(e.version)&&(a.add(e.version),!0))).reverse()}async listIds(){const e=await this.registryContract.getPastEvents("VersionAdded",{fromBlock:1}),t=new Set(e.map((e=>l(e.returnValues.id))));return Array.from(t)}async addVersion(e,t,r,a={}){await this.checkVersion(e,t,!1),await this.registryContract.methods.addVersion(o(e),o(t),r).send(Object.assign(Object.assign({},this.sendOptions),a))}async cancelVersion(e,t,r="",a={}){await this.checkVersion(e,t,!0),await this.registryContract.methods.cancelVersion(o(e),o(t),r).send(Object.assign(Object.assign({},this.sendOptions),a))}async checkVersion(e,t,r){if(null!=(await this.getAllVersions(e).catch((()=>[]))).find((e=>e.version===t))!==r)throw new Error(`version ${r?"does not exist":"already exists"}: ${e} @ ${t}`)}}},223:function(e,t,r){var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=a(r(513));t.default=class{constructor(e){if(null==n.default.valid(e))throw new Error("Component version is not valid");this.componentVersion=e}isMinorSameOrNewer(e){e=e.replace("_","-");const t="^"+this.componentVersion;return n.default.satisfies(e,t)}}},209:function(e,t,r){var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.NetworkSimulatingProvider=void 0;const n=a(r(784)),i=r(360);class s extends i.WrapperProviderBase{constructor(e){super(e),this.isDelayTransactionsOn=!1,this.mempool=new Map}setDelayTransactions(e){this.isDelayTransactionsOn=e}calculateTxHash(e){const t=n.default.sha3(e.params[0]);if(null==t)throw new Error("Failed to hash transaction");return t}send(e,t){let r;if("eth_sendRawTransaction"===e.method&&this.isDelayTransactionsOn){const t=this.calculateTxHash(e);r={jsonrpc:"2.0",id:(a=e.id,"string"==typeof a?parseInt(a):"number"==typeof a?a:0),result:t},this.mempool.set(t,e)}var a;null!=r?t(null,r):this.provider.send(e,t)}supportsSubscriptions(){return!1}async mineTransaction(e){const t=this.mempool.get(e);return this.mempool.delete(e),await new Promise(((e,r)=>{if(null==t)throw new Error("Transaction is not in simulated mempool. It must be already mined");this.provider.send(t,(function(t,a){null!=t||null==a?r(t):e(a)}))}))}}t.NetworkSimulatingProvider=s},498:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ProfilingProvider=void 0;const a=r(360);class n extends a.WrapperProviderBase{constructor(e,t=!1){super(e),this.methodsCount=new Map,this.requestsCount=0,this.logTraffic=t}disconnect(){return!1}supportsSubscriptions(){return!1}send(e,t){var r,a;this.requestsCount++;const n=null!==(r=this.methodsCount.get(e.method))&&void 0!==r?r:0;this.methodsCount.set(e.method,n+1);let i=t;this.logTraffic&&(i=function(e,r){var a,n;null!=e&&console.log(`<<< error: ${null!==(a=e.message)&&void 0!==a?a:"null error message"}`),console.log(`<<< result: ${null!==(n=JSON.stringify(r))&&void 0!==n?n:"null result"}`),t(e,r)},console.log(`>>> payload: ${null!==(a=JSON.stringify(e))&&void 0!==a?a:"null result"}`)),this.provider.send(e,i)}reset(){this.requestsCount=0,this.methodsCount.clear()}log(){console.log("Profiling Provider Stats:"),new Map([...this.methodsCount.entries()].sort((function([,e],[,t]){return t-e}))).forEach((function(e,t){console.log(`Method: ${t.padEnd(30)} was called: ${e.toString().padEnd(3)} times`)})),console.log(`Total RPC calls: ${this.requestsCount}`)}}t.ProfilingProvider=n},792:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},360:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WrapperProviderBase=void 0,t.WrapperProviderBase=class{constructor(e){this.provider=e}get connected(){return this.provider.connected}get host(){return this.provider.host}disconnect(){return this.provider.disconnect()}supportsSubscriptions(){return this.provider.supportsSubscriptions()}}},607:function(e,t,r){var a=this&&this.__createBinding||(Object.create?function(e,t,r,a){void 0===a&&(a=r),Object.defineProperty(e,a,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,a){void 0===a&&(a=r),e[a]=t[r]}),n=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||a(t,e,r)},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.VersionsManager=t.replaceErrors=t.ContractInteractor=t.TypedRequestData=void 0;const s=i(r(172));t.TypedRequestData=s.default;const o=i(r(359));t.ContractInteractor=o.default;const l=i(r(319));t.replaceErrors=l.default;const u=i(r(223));t.VersionsManager=u.default,n(r(209),t),n(r(498),t),n(r(792),t),n(r(360),t),n(r(874),t),n(r(422),t),n(r(172),t),n(r(868),t),n(r(104),t),n(r(659),t),n(r(322),t),n(r(945),t),n(r(738),t),n(r(359),t),n(r(917),t),n(r(675),t),n(r(415),t)},868:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},104:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},659:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},322:function(e,t,r){var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.RelayTransactionRequestShape=t.DeployTransactionRequestShape=void 0;const n=a(r(349));t.DeployTransactionRequestShape={relayRequest:{request:{relayHub:n.default.string,from:n.default.string,to:n.default.string,value:n.default.string,nonce:n.default.string,data:n.default.string,tokenContract:n.default.string,tokenAmount:n.default.string,tokenGas:n.default.string,recoverer:n.default.string,index:n.default.string},relayData:{gasPrice:n.default.string,domainSeparator:n.default.string,relayWorker:n.default.string,callForwarder:n.default.string,callVerifier:n.default.string}},metadata:{relayHubAddress:n.default.string,relayMaxNonce:n.default.number,signature:n.default.string}},t.RelayTransactionRequestShape={relayRequest:{request:{relayHub:n.default.string,from:n.default.string,to:n.default.string,value:n.default.string,gas:n.default.string,nonce:n.default.string,data:n.default.string,tokenContract:n.default.string,tokenAmount:n.default.string,tokenGas:n.default.string},relayData:{gasPrice:n.default.string,domainSeparator:n.default.string,relayWorker:n.default.string,callForwarder:n.default.string,callVerifier:n.default.string}},metadata:{relayHubAddress:n.default.string,relayMaxNonce:n.default.number,signature:n.default.string}}},103:e=>{e.exports=require("@ethersproject/bytes")},820:e=>{e.exports=require("@rsksmart/rif-relay-contracts")},414:e=>{e.exports=require("@truffle/contract")},416:e=>{e.exports=require("bn.js")},242:e=>{e.exports=require("chalk")},458:e=>{e.exports=require("eth-sig-util")},477:e=>{e.exports=require("ethereumjs-common")},519:e=>{e.exports=require("ethereumjs-util")},742:e=>{e.exports=require("ethval")},732:e=>{e.exports=require("loglevel")},349:e=>{e.exports=require("ow")},513:e=>{e.exports=require("semver")},748:e=>{e.exports=require("source-map-support")},409:e=>{e.exports=require("web3")},107:e=>{e.exports=require("web3-eth-abi")},784:e=>{e.exports=require("web3-utils")}},t={},r=function r(a){var n=t[a];if(void 0!==n)return n.exports;var i=t[a]={exports:{}};return e[a].call(i.exports,i,i.exports,r),i.exports}(607);module.exports=r})(); \ No newline at end of file diff --git a/dist/types/EnvelopingConfig.d.ts b/dist/types/EnvelopingConfig.d.ts deleted file mode 100644 index 63eba7a..0000000 --- a/dist/types/EnvelopingConfig.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { LogLevelNumbers } from 'loglevel'; -/** - * @field methodSuffix - allows use of versioned methods, i.e. 'eth_signTypedData_v4'. Should be '_v4' for Metamask - * @field jsonStringifyRequest - should be 'true' for Metamask, false for ganache - */ -export interface EnvelopingConfig { - preferredRelays: string[]; - onlyPreferredRelays: boolean; - relayLookupWindowBlocks: number; - relayLookupWindowParts: number; - methodSuffix: string; - jsonStringifyRequest: boolean; - relayTimeoutGrace: number; - sliceSize: number; - logLevel: LogLevelNumbers; - gasPriceFactorPercent: number; - minGasPrice: number; - maxRelayNonceGap: number; - relayHubAddress: string; - deployVerifierAddress: string; - relayVerifierAddress: string; - forwarderAddress: string; - smartWalletFactoryAddress: string; - chainId: number; - clientId: string; -} diff --git a/dist/types/EnvelopingTransactionDetails.d.ts b/dist/types/EnvelopingTransactionDetails.d.ts deleted file mode 100644 index e64db2b..0000000 --- a/dist/types/EnvelopingTransactionDetails.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { PrefixedHexString } from 'ethereumjs-tx'; -export default interface EnvelopingTransactionDetails { - readonly from: string; - readonly data: PrefixedHexString; - readonly to: string; - readonly tokenContract?: string; - readonly tokenAmount?: string; - tokenGas?: string; - readonly recoverer?: string; - readonly index?: string; - readonly value?: string; - /** - * TODO: this is horrible. Think about it some more - * Do not set this value manually as this value will be overwritten. Use {@link forceGasPrice} instead. - */ - gas?: PrefixedHexString; - gasPrice?: PrefixedHexString; - readonly relayHub?: string; - readonly callForwarder?: string; - readonly callVerifier?: string; - readonly isSmartWalletDeploy?: boolean; - smartWalletAddress?: string; - readonly clientId?: string; - /** - * Set to 'false' to create a direct transaction - */ - readonly useEnveloping?: boolean; - /** - * Use this to force the {@link RelayClient} to use provided gas price instead of calculated one. - */ - readonly forceGasPrice?: PrefixedHexString; - /** - * Use this to force the {@link RelayProvider} to use provided gas instead of the one estimated by the {@link RelayClient}. - */ - readonly forceGas?: PrefixedHexString; - /** - * Use this to force the RelayClient to use only the preferred relays when searching for a suitable relay server - */ - readonly onlyPreferredRelays?: boolean; - retries?: number; - initialBackoff?: number; -} diff --git a/dist/types/RelayHubConfiguration.d.ts b/dist/types/RelayHubConfiguration.d.ts deleted file mode 100644 index 5471fa3..0000000 --- a/dist/types/RelayHubConfiguration.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export interface RelayHubConfiguration { - maxWorkerCount: number; - minimumUnstakeDelay: number; - minimumStake: string; - minimumEntryDepositValue: string; -} diff --git a/dist/types/RelayTransactionRequest.d.ts b/dist/types/RelayTransactionRequest.d.ts deleted file mode 100644 index 852a690..0000000 --- a/dist/types/RelayTransactionRequest.d.ts +++ /dev/null @@ -1,72 +0,0 @@ -import { PrefixedHexString } from 'ethereumjs-tx'; -import { DeployRequest, RelayRequest } from '../EIP712/RelayRequest'; -export interface RelayMetadata { - relayHubAddress: string; - relayMaxNonce: number; - signature: PrefixedHexString; -} -export interface RelayTransactionRequest { - relayRequest: RelayRequest; - metadata: RelayMetadata; -} -export interface DeployTransactionRequest { - relayRequest: DeployRequest; - metadata: RelayMetadata; -} -export declare const DeployTransactionRequestShape: { - relayRequest: { - request: { - relayHub: import("ow").StringPredicate; - from: import("ow").StringPredicate; - to: import("ow").StringPredicate; - value: import("ow").StringPredicate; - nonce: import("ow").StringPredicate; - data: import("ow").StringPredicate; - tokenContract: import("ow").StringPredicate; - tokenAmount: import("ow").StringPredicate; - tokenGas: import("ow").StringPredicate; - recoverer: import("ow").StringPredicate; - index: import("ow").StringPredicate; - }; - relayData: { - gasPrice: import("ow").StringPredicate; - domainSeparator: import("ow").StringPredicate; - relayWorker: import("ow").StringPredicate; - callForwarder: import("ow").StringPredicate; - callVerifier: import("ow").StringPredicate; - }; - }; - metadata: { - relayHubAddress: import("ow").StringPredicate; - relayMaxNonce: import("ow").NumberPredicate; - signature: import("ow").StringPredicate; - }; -}; -export declare const RelayTransactionRequestShape: { - relayRequest: { - request: { - relayHub: import("ow").StringPredicate; - from: import("ow").StringPredicate; - to: import("ow").StringPredicate; - value: import("ow").StringPredicate; - gas: import("ow").StringPredicate; - nonce: import("ow").StringPredicate; - data: import("ow").StringPredicate; - tokenContract: import("ow").StringPredicate; - tokenAmount: import("ow").StringPredicate; - tokenGas: import("ow").StringPredicate; - }; - relayData: { - gasPrice: import("ow").StringPredicate; - domainSeparator: import("ow").StringPredicate; - relayWorker: import("ow").StringPredicate; - callForwarder: import("ow").StringPredicate; - callVerifier: import("ow").StringPredicate; - }; - }; - metadata: { - relayHubAddress: import("ow").StringPredicate; - relayMaxNonce: import("ow").NumberPredicate; - signature: import("ow").StringPredicate; - }; -}; diff --git a/package.json b/package.json index 1263cae..a22df42 100644 --- a/package.json +++ b/package.json @@ -1,26 +1,25 @@ { "name": "@rsksmart/rif-relay-common", - "version": "0.0.2-alpha-0", + "version": "0.0.2-alpha.3", "description": "This project contains all the common code for the rif relay system.", "main": "dist/index.js", "scripts": { + "prepare": "scripts/prepare", "build": "scripts/build", - "dist": "scripts/dist", - "_postinstall": "scripts/postinstall", "lint": "eslint . --ext .ts", "lint:fix": "eslint . --ext .ts --fix", - "prepublishOnly": "scripts/prepublishOnly", - "postpublish": "scripts/postpublish", - "publishManually": "scripts/publishManually", "prettier:fix": "npx prettier --write --ignore-unknown .", - "prettier": "npx prettier --check ." + "prettier": "npx prettier --check .", + "test": "#test_suite_to_be_added", + "dist": "scripts/dist", + "prepublishOnly": "scripts/prepublishOnly" }, "author": "Relaying Services Team", "license": "MIT", "dependencies": { "@openeth/truffle-typings": "0.0.6", "@openzeppelin/contracts": "~3.2.0", - "@rsksmart/rif-relay-contracts": "https://github.com/anarancio/rif-relay-contracts", + "@rsksmart/rif-relay-contracts": "0.0.2-alpha.2", "@truffle/abi-utils": "~0.2.3", "@truffle/contract": "~4.2.23", "@truffle/contract-schema": "3.3.2", @@ -55,7 +54,6 @@ "@typescript-eslint/parser": "~4.28.3", "eslint": "~7.30.0", "husky": "~6.0.0", - "pinst": "^2.1.6", "prettier": "2.3.0", "ts-loader": "~9.2.3", "ts-node": "8.6.2", diff --git a/scripts/postpublish b/scripts/postpublish deleted file mode 100755 index 39da013..0000000 --- a/scripts/postpublish +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -pinst --enable diff --git a/scripts/postinstall b/scripts/prepare similarity index 60% rename from scripts/postinstall rename to scripts/prepare index bbf2440..2cfb53c 100755 --- a/scripts/postinstall +++ b/scripts/prepare @@ -1,5 +1,5 @@ #!/bin/bash patch-package -npx husky install +husky install diff --git a/scripts/prepublishOnly b/scripts/prepublishOnly index 56e02c3..5dc28f0 100755 --- a/scripts/prepublishOnly +++ b/scripts/prepublishOnly @@ -1,4 +1,3 @@ #!/bin/bash -pinst --disable npm run dist diff --git a/scripts/publishManually b/scripts/publishManually deleted file mode 100755 index 6106edf..0000000 --- a/scripts/publishManually +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -npm run prepublishOnly -npm run dist