From 467daedcd3176cf67931f61e364985e3b70b91d6 Mon Sep 17 00:00:00 2001 From: kaushalrajbacancy <78725072+kaushalrajbacancy@users.noreply.github.com> Date: Thu, 21 Sep 2023 12:03:11 +0530 Subject: [PATCH] Removed getTransactions endpoint and fixed session checking (#35) * Removed getTransactions endpoint and fixed session checking * updated package version --- CHANGELOG.md | 6 +++ examples/07-transactions.ts | 22 ----------- package-lock.json | 4 +- package.json | 3 +- src/sdk/data/classes/index.ts | 1 - src/sdk/data/classes/transactions.ts | 7 ---- src/sdk/data/data.service.ts | 58 +--------------------------- src/sdk/dto/get-transactions.dto.ts | 12 ------ src/sdk/dto/index.ts | 1 - src/sdk/sdk.ts | 40 +++---------------- 10 files changed, 15 insertions(+), 139 deletions(-) delete mode 100644 examples/07-transactions.ts delete mode 100644 src/sdk/data/classes/transactions.ts delete mode 100644 src/sdk/dto/get-transactions.dto.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 62537d40..180ab7a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,10 @@ # Changelog + +## [1.2.8] - 2023-09-21 +### Fixes +- Fixed the issue with getExchangeOffers endpoint (Account must need to be deployed to access this endpoint) +- Removed getTransactions endpoint + ## [1.2.7] - 2023-09-20 ### Fixes - Fixed the issue on usage of axios when paymaster is called via react native by replacing it to fetch. diff --git a/examples/07-transactions.ts b/examples/07-transactions.ts deleted file mode 100644 index 7d09cc92..00000000 --- a/examples/07-transactions.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { PrimeSdk } from '../src'; -import * as dotenv from 'dotenv'; - -dotenv.config(); - -async function main(): Promise { - // initializating sdk... - const primeSdk = new PrimeSdk({ privateKey: process.env.WALLET_PRIVATE_KEY }, { - chainId: Number(process.env.CHAIN_ID), - projectKey: '', // project key - }); - const chainId = 1; - const account = ''; // account address - const transactions = await primeSdk.getTransactions({ chainId, account }); - - console.log('\x1b[33m%s\x1b[0m', `EtherspotWallet transactions:`, transactions); -} - -main() - .catch(console.error) - .finally(() => process.exit()); - diff --git a/package-lock.json b/package-lock.json index 31d1beec..fcac64b4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@etherspot/prime-sdk", - "version": "1.2.7", + "version": "1.2.8", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@etherspot/prime-sdk", - "version": "1.2.7", + "version": "1.2.8", "license": "MIT", "dependencies": { "@apollo/client": "3.4.0", diff --git a/package.json b/package.json index b3c1bbdc..b0b9eb5f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@etherspot/prime-sdk", - "version": "1.2.7", + "version": "1.2.8", "description": "Etherspot Prime (Account Abstraction) SDK", "keywords": [ "ether", @@ -27,7 +27,6 @@ "03-transfer-erc20": "./node_modules/.bin/ts-node ./examples/03-transfer-erc20", "05-get-account-balances": "./node_modules/.bin/ts-node ./examples/05-get-account-balances", "06-transaction": "./node_modules/.bin/ts-node ./examples/06-transaction", - "07-transactions": "./node_modules/.bin/ts-node ./examples/07-transactions", "08-nft-list": "./node_modules/.bin/ts-node ./examples/08-nft-list", "09-exchange": "./node_modules/.bin/ts-node ./examples/09-exchange", "10-advance-routes-lifi": "./node_modules/.bin/ts-node ./examples/10-advance-routes-lifi", diff --git a/src/sdk/data/classes/index.ts b/src/sdk/data/classes/index.ts index 1a98e9df..81ea5b1d 100644 --- a/src/sdk/data/classes/index.ts +++ b/src/sdk/data/classes/index.ts @@ -7,7 +7,6 @@ export * from './transaction-log'; export * from './decoded-log-param'; export * from './transaction-log-decoded'; export * from './transaction'; -export * from './transactions'; export * from './nft-collection'; export * from './nft-list'; export * from './nft'; diff --git a/src/sdk/data/classes/transactions.ts b/src/sdk/data/classes/transactions.ts deleted file mode 100644 index 7c46d8b0..00000000 --- a/src/sdk/data/classes/transactions.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { Type } from 'class-transformer'; -import { Transaction } from './transaction'; - -export class Transactions { - @Type(() => Transaction) - items: Transaction[]; -} diff --git a/src/sdk/data/data.service.ts b/src/sdk/data/data.service.ts index dc3aec19..bc0363f7 100644 --- a/src/sdk/data/data.service.ts +++ b/src/sdk/data/data.service.ts @@ -1,7 +1,7 @@ import { gql } from '@apollo/client/core'; import { HeaderNames, ObjectSubject, Service } from '../common'; import { Route } from '@lifi/sdk'; -import { AccountBalances, AdvanceRoutesLiFi, BridgingQuotes, ExchangeOffer, ExchangeOffers, NftList, StepTransaction, StepTransactions, Transaction, Transactions } from './classes'; +import { AccountBalances, AdvanceRoutesLiFi, BridgingQuotes, ExchangeOffer, ExchangeOffers, NftList, StepTransaction, StepTransactions, Transaction } from './classes'; import { BigNumber } from 'ethers'; import { CrossChainServiceProvider, LiFiBridge } from './constants'; @@ -112,62 +112,6 @@ export class DataService extends Service { return result; } - async getTransactions(account: string, ChainId: number): Promise { - const { apiService } = this.services; - - const { result } = await apiService.query<{ - result: Transactions; - }>( - gql` - query($ChainId: Int, $account: String!) { - result: transactions(chainId: $ChainId, account: $account) { - items { - blockNumber - timestamp - from - gasLimit - gasPrice - gasUsed - hash - logs - status - to - value - direction - internalTransactions - internalTransactionsFetched - mainTransactionDataFetched - batch - asset { - from - to - name - symbol - category - type - value - decimal - contract - } - blockExplorerUrl - } - } - } - `, - { - variables: { - account, - ChainId, - }, - models: { - result: Transactions, - }, - }, - ); - - return result; - } - async getNftList(account: string, ChainId: number): Promise { const { apiService } = this.services; diff --git a/src/sdk/dto/get-transactions.dto.ts b/src/sdk/dto/get-transactions.dto.ts deleted file mode 100644 index dfe1da47..00000000 --- a/src/sdk/dto/get-transactions.dto.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { IsOptional, IsPositive } from 'class-validator'; -import { IsAddress } from './validators'; - -export class GetTransactionsDto { - @IsOptional() - @IsPositive() - chainId?: number; - - @IsOptional() - @IsAddress() - account?: string; -} diff --git a/src/sdk/dto/index.ts b/src/sdk/dto/index.ts index 9ebcc58a..a5600ce4 100644 --- a/src/sdk/dto/index.ts +++ b/src/sdk/dto/index.ts @@ -4,7 +4,6 @@ export * from './create-session.dto'; export * from './onRamper.dto'; export * from './get-account-balances.dto'; export * from './get-transaction.dto'; -export * from './get-transactions.dto'; export * from './get-nft-list.dto'; export * from './join-contract-account.dto'; export * from './get-exchange-offers.dto'; diff --git a/src/sdk/sdk.ts b/src/sdk/sdk.ts index 61b3fb1c..ca0ca280 100644 --- a/src/sdk/sdk.ts +++ b/src/sdk/sdk.ts @@ -15,8 +15,8 @@ import { getNetworkConfig, Networks, onRamperAllNetworks } from './network/const import { UserOperationStruct } from './contracts/account-abstraction/contracts/core/BaseAccount'; import { EtherspotWalletAPI, HttpRpcClient, VerifyingPaymasterAPI } from './base'; import { TransactionDetailsForUserOp, TransactionGasInfoForUserOp } from './base/TransactionDetailsForUserOp'; -import { CreateSessionDto, OnRamperDto, GetAccountBalancesDto, GetAdvanceRoutesLiFiDto, GetExchangeCrossChainQuoteDto, GetExchangeOffersDto, GetNftListDto, GetStepTransactionsLiFiDto, GetTransactionDto, GetTransactionsDto, SignMessageDto, validateDto } from './dto'; -import { AccountBalances, AdvanceRoutesLiFi, BridgingQuotes, ExchangeOffer, NftList, StepTransactions, Transaction, Transactions, Session } from './'; +import { CreateSessionDto, OnRamperDto, GetAccountBalancesDto, GetAdvanceRoutesLiFiDto, GetExchangeCrossChainQuoteDto, GetExchangeOffersDto, GetNftListDto, GetStepTransactionsLiFiDto, GetTransactionDto, SignMessageDto, validateDto } from './dto'; +import { AccountBalances, AdvanceRoutesLiFi, BridgingQuotes, ExchangeOffer, NftList, StepTransactions, Transaction, Session } from './'; /** * Prime-Sdk @@ -307,31 +307,6 @@ export class PrimeSdk { return this.etherspotWallet.services.dataService.getTransaction(hash); } - /** - * gets transactions - * @param dto - * @return Promise - */ - async getTransactions(dto: GetTransactionsDto): Promise { - const { account, chainId } = await validateDto(dto, GetTransactionsDto, { - addressKeys: ['account'], - }); - - this.etherspotWallet.services.accountService.joinContractAccount(account); - - await this.etherspotWallet.require({ - wallet: !account, - contractAccount: true, - }); - - const ChainId = chainId ? chainId : this.etherspotWallet.services.walletService.chainId; - - return this.etherspotWallet.services.dataService.getTransactions( - this.etherspotWallet.prepareAccountAddress(account), - ChainId, - ); - } - /** * gets NFT list belonging to account * @param dto @@ -366,14 +341,13 @@ export class PrimeSdk { let { toAddress, fromAddress } = dto; - if (!fromAddress) fromAddress = this.etherspotWallet.services.walletService.walletAddress; + if (!fromAddress) fromAddress = await this.getCounterFactualAddress(); if (!toAddress) toAddress = fromAddress; this.etherspotWallet.services.accountService.joinContractAccount(fromAddress); await this.etherspotWallet.require({ - session: true, contractAccount: true, }); @@ -428,7 +402,7 @@ export class PrimeSdk { } async getStepTransaction(dto: GetStepTransactionsLiFiDto): Promise { - const accountAddress = this.etherspotWallet.services.walletService.walletAddress; + const accountAddress = await this.getCounterFactualAddress(); return this.etherspotWallet.services.dataService.getStepTransaction(dto.route, accountAddress); } @@ -455,11 +429,7 @@ export class PrimeSdk { let { fromAddress } = dto; - await this.etherspotWallet.require({ - session: true, - }); - - if (!fromAddress) fromAddress = this.etherspotWallet.services.walletService.walletAddress; + if (!fromAddress) fromAddress = await this.getCounterFactualAddress(); let { chainId } = this.etherspotWallet.services.walletService;