Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prime SDK changes for the new backend services #103

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
- 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=
5 changes: 3 additions & 2 deletions examples/05-get-account-balances.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { DataUtils, graphqlEndpoints } from '../src';
import { DataUtils } from '../src';
import * as dotenv from 'dotenv';

dotenv.config();
const dataApiKey = 'eyJvcmciOiI2NTIzZjY5MzUwOTBmNzAwMDFiYjJkZWIiLCJpZCI6IjI4ZWJiMGQ5YTMxYjQ3MmY4NmU4MWY2YTVhYzBhMzE1IiwiaCI6Im11cm11cjEyOCJ9';

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

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

dotenv.config();
const dataApiKey = 'eyJvcmciOiI2NTIzZjY5MzUwOTBmNzAwMDFiYjJkZWIiLCJpZCI6IjI4ZWJiMGQ5YTMxYjQ3MmY4NmU4MWY2YTVhYzBhMzE1IiwiaCI6Im11cm11cjEyOCJ9';

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

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

dotenv.config();
const dataApiKey = 'eyJvcmciOiI2NTIzZjY5MzUwOTBmNzAwMDFiYjJkZWIiLCJpZCI6IjI4ZWJiMGQ5YTMxYjQ3MmY4NmU4MWY2YTVhYzBhMzE1IiwiaCI6Im11cm11cjEyOCJ9';

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

dotenv.config();
const dataApiKey = 'eyJvcmciOiI2NTIzZjY5MzUwOTBmNzAwMDFiYjJkZWIiLCJpZCI6IjI4ZWJiMGQ5YTMxYjQ3MmY4NmU4MWY2YTVhYzBhMzE1IiwiaCI6Im11cm11cjEyOCJ9';

async function main(): Promise<void> {
// initializating Data service...
const dataService = new DataUtils('public-prime-testnet-key', graphqlEndpoints.QA)
const dataService = new DataUtils(dataApiKey);
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
5 changes: 3 additions & 2 deletions examples/10-advance-routes-lifi.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { ethers, utils } from 'ethers';
import { DataUtils, graphqlEndpoints } from '../src';
import { DataUtils } from '../src';
import * as dotenv from 'dotenv';
dotenv.config();
const dataApiKey = 'eyJvcmciOiI2NTIzZjY5MzUwOTBmNzAwMDFiYjJkZWIiLCJpZCI6IjI4ZWJiMGQ5YTMxYjQ3MmY4NmU4MWY2YTVhYzBhMzE1IiwiaCI6Im11cm11cjEyOCJ9';

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

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

This file was deleted.

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

dotenv.config();
const dataApiKey = 'eyJvcmciOiI2NTIzZjY5MzUwOTBmNzAwMDFiYjJkZWIiLCJpZCI6IjI4ZWJiMGQ5YTMxYjQ3MmY4NmU4MWY2YTVhYzBhMzE1IiwiaCI6Im11cm11cjEyOCJ9';

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

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
6 changes: 4 additions & 2 deletions examples/18-exchange-rates.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { DataUtils, RateData, graphqlEndpoints } from '../src';
import { RateData } from '../src/sdk/data';
import { DataUtils } from '../src';
import * as dotenv from 'dotenv';

dotenv.config();
const dataApiKey = 'eyJvcmciOiI2NTIzZjY5MzUwOTBmNzAwMDFiYjJkZWIiLCJpZCI6IjI4ZWJiMGQ5YTMxYjQ3MmY4NmU4MWY2YTVhYzBhMzE1IiwiaCI6Im11cm11cjEyOCJ9';

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

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