Skip to content

Commit

Permalink
Prime SDK changes for the new backend services (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushalrajbacancy authored Mar 4, 2024
1 parent aecac62 commit 54a63a7
Show file tree
Hide file tree
Showing 25 changed files with 2,215 additions and 2,722 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ module.exports = {
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
'prettier/@typescript-eslint',
],
env: {
node: true,
Expand All @@ -20,5 +19,6 @@ module.exports = {
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/camelcase': 'off',
'@typescript-eslint/ban-types': 'off'
},
};
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# Changelog
## [1.5.4] - 2024-03-01
### New
- The `DataUtils` module has been updated to fetch data from REST APIs provided by the new backend
- Added these endpoints into DataUtils: `getAccountBalances`, `getTransaction`, `getNftList`, `getAdvanceRoutesLiFi`, `getStepTransaction`, `getTokenLists`, `getTokenListTokens` and `fetchExchangeRates`
### Breaking changes
- Updated the `DataUtils` module to include a data API key parameter instead of project key and GraphQL endpoint parameters (If the data API key is not provided, it will automatically use the default API key, which has a strict rate limit)
- Added new parameter named `chainId` in `getTokenLists` and `getTokenListTokens` endpoints

## [1.5.3] - 2024-02-28
### Bug Fix
- Added Error Handling on bundler side
Expand Down
2 changes: 1 addition & 1 deletion example.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
WALLET_PRIVATE_KEY=0x...
CHAIN_ID=
CHAIN_ID=
4 changes: 2 additions & 2 deletions examples/05-get-account-balances.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { DataUtils, graphqlEndpoints } from '../src';
import { DataUtils } from '../src';
import * as dotenv from 'dotenv';

dotenv.config();

async function main() {
// initializating Data service...
const dataService = new DataUtils('public-prime-testnet-key', graphqlEndpoints.QA)
const dataService = new DataUtils();

const balances = await dataService.getAccountBalances({
account: '', // address
Expand Down
4 changes: 2 additions & 2 deletions examples/06-transaction.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { DataUtils, graphqlEndpoints } from '../src';
import { DataUtils } from '../src';
import * as dotenv from 'dotenv';

dotenv.config();

async function main(): Promise<void> {
// initializating Data service...
const dataService = new DataUtils('public-prime-testnet-key', graphqlEndpoints.QA)
const dataService = new DataUtils();
const hash = '0x7f8633f21d0c0c71d248333a0a2b976495015109a270a6f8a51befe3baf6fb6e';
const transaction = await dataService.getTransaction({ hash, chainId: 80001 });

Expand Down
4 changes: 2 additions & 2 deletions examples/08-nft-list.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { DataUtils, graphqlEndpoints } from '../src';
import { DataUtils } from '../src';
import * as dotenv from 'dotenv';

dotenv.config();

async function main(): Promise<void> {
// initializating Data service...
const dataService = new DataUtils('public-prime-testnet-key', graphqlEndpoints.QA)
const dataService = new DataUtils();
const chainId = 137;
const account = ''; // account address
const nfts = await dataService.getNftList({ chainId, account });
Expand Down
20 changes: 2 additions & 18 deletions examples/09-exchange.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,13 @@
import { DataUtils, graphqlEndpoints } from '../src';
import { DataUtils } from '../src';
import * as dotenv from 'dotenv';
import { BigNumber, constants } from 'ethers';

dotenv.config();

async function main(): Promise<void> {
// initializating Data service...
const dataService = new DataUtils('public-prime-testnet-key', graphqlEndpoints.QA)
const dataService = new DataUtils();
const exchangeSupportedAssets = await dataService.getExchangeSupportedAssets({ page: 1, limit: 100, account: '', chainId: Number(process.env.CHAIN_ID) });
console.log('\x1b[33m%s\x1b[0m', `Found exchange supported assets:`, exchangeSupportedAssets.items.length);

const fromTokenAddress = '0xe3818504c1b32bf1557b16c238b2e01fd3149c17';
const toTokenAddress = constants.AddressZero;
const fromAmount = '1000000000000000000';
const fromChainId = 1;

const offers = await dataService.getExchangeOffers({
fromAddress: '',
fromChainId,
fromTokenAddress,
toTokenAddress,
fromAmount: BigNumber.from(fromAmount),
});

console.log('\x1b[33m%s\x1b[0m', `Exchange offers:`, offers);
}

main()
Expand Down
4 changes: 2 additions & 2 deletions examples/10-advance-routes-lifi.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { ethers, utils } from 'ethers';
import { DataUtils, graphqlEndpoints } from '../src';
import { DataUtils } from '../src';
import * as dotenv from 'dotenv';
dotenv.config();

async function main(): Promise<void> {
// initializating Data service...
const dataService = new DataUtils('public-prime-testnet-key', graphqlEndpoints.QA)
const dataService = new DataUtils();

const fromChainId = 56;
const toChainId = 137;
Expand Down
39 changes: 0 additions & 39 deletions examples/11-cross-chain-quotes.ts

This file was deleted.

9 changes: 5 additions & 4 deletions examples/17-token-list.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
import { DataUtils, graphqlEndpoints } from '../src';
import { DataUtils } from '../src';
import * as dotenv from 'dotenv';

dotenv.config();

async function main(): Promise<void> {
// initializating Data service...
const dataService = new DataUtils('public-prime-testnet-key', graphqlEndpoints.QA)
const dataService = new DataUtils();

const tokenLists = await dataService.getTokenLists();
const tokenLists = await dataService.getTokenLists({ chainId: 1 });

console.log('\x1b[33m%s\x1b[0m', `TokenLists:`, tokenLists);

const { name } = tokenLists[0];

let tokenListTokens = await dataService.getTokenListTokens();
let tokenListTokens = await dataService.getTokenListTokens({ chainId: 1 });

console.log('\x1b[33m%s\x1b[0m', `Default token list tokens length:`, tokenListTokens.length);

tokenListTokens = await dataService.getTokenListTokens({
chainId: 1,
name,
});

Expand Down
5 changes: 3 additions & 2 deletions examples/18-exchange-rates.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { DataUtils, RateData, graphqlEndpoints } from '../src';
import { RateData } from '../src/sdk/data';
import { DataUtils } from '../src';
import * as dotenv from 'dotenv';

dotenv.config();

async function main(): Promise<void> {
// initializating Data service...
const dataService = new DataUtils('public-prime-testnet-key', graphqlEndpoints.QA)
const dataService = new DataUtils();

const ETH_AAVE_ADDR = '0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9';
const ETH_MATIC_ADDR = '0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0';
Expand Down
Loading

0 comments on commit 54a63a7

Please sign in to comment.