Skip to content

Commit

Permalink
[feat-ls-2155-indexer]: update config
Browse files Browse the repository at this point in the history
* bump aptos
* add optional config for AptosClient to pass credentials
* bump node
  • Loading branch information
ildarH committed Aug 15, 2024
1 parent 23e28e9 commit dc875d9
Show file tree
Hide file tree
Showing 5 changed files with 261 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '12'
node-version: '16'
cache: 'yarn'
- run: yarn install
- run: yarn docs
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
fail-fast: false
matrix:
nodejs: [12, 14]
nodejs: [12, 14, 16]

steps:
- uses: actions/checkout@v2
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pontem/liquidswap-sdk",
"version": "0.7.1",
"version": "0.7.2",
"description": "SDK to use LiquidSwap functions",
"author": "Igor Demko <igor@pontem.network>",
"repository": "https://github.com/pontem-network/liquidswap-sdk",
Expand Down Expand Up @@ -45,7 +45,7 @@
"typescript": "^4.6.3"
},
"dependencies": {
"aptos": "^1.3.17",
"aptos": "1.21.0",
"axios": "^0.27.2",
"decimal.js": "^10.4.1"
}
Expand Down
31 changes: 21 additions & 10 deletions src/sdk.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { AptosClient } from 'aptos';
import { AptosClient, ClientConfig } from 'aptos';
import { SwapModule } from './modules/SwapModule';
import { ResourcesModule } from './modules/ResourcesModule';
import { AptosResourceType } from './types/aptos';
import { LiquidityModule } from './modules/LiquidityModule';
import { NETWORKS_MODULES, MODULES_ACCOUNT, RESOURCES_ACCOUNT, MODULES_V05_ACCOUNT, RESOURCES_V05_ACCOUNT } from './constants';
import {
NETWORKS_MODULES,
MODULES_ACCOUNT,
RESOURCES_ACCOUNT,
MODULES_V05_ACCOUNT,
RESOURCES_V05_ACCOUNT,
} from './constants';

const initialNetworkOptions = {
nativeToken: '0x1::aptos_coin::AptosCoin',
Expand All @@ -15,7 +21,7 @@ const initialNetworkOptions = {
resourceAccount: RESOURCES_ACCOUNT,
moduleAccount: MODULES_ACCOUNT,
moduleAccountV05: MODULES_V05_ACCOUNT,
resourceAccountV05: RESOURCES_V05_ACCOUNT
resourceAccountV05: RESOURCES_V05_ACCOUNT,
};

interface INetworkOptions {
Expand All @@ -33,6 +39,7 @@ interface INetworkOptions {

export interface SdkOptions {
nodeUrl: string;
nodeOptions?: Partial<ClientConfig>;
networkOptions?: INetworkOptions;
}

Expand Down Expand Up @@ -85,27 +92,31 @@ export class SDK {
this._networkOptions.modules = options.networkOptions.modules;
}
if (options.networkOptions?.moduleAccount) {
this._networkOptions.moduleAccount = options.networkOptions.moduleAccount;
this._networkOptions.moduleAccount =
options.networkOptions.moduleAccount;
}
if (options.networkOptions?.resourceAccount) {
this._networkOptions.resourceAccount = options.networkOptions.resourceAccount;
this._networkOptions.resourceAccount =
options.networkOptions.resourceAccount;
}
if (options.networkOptions?.moduleAccountV05) {
this._networkOptions.moduleAccountV05 = options.networkOptions.moduleAccountV05;
this._networkOptions.moduleAccountV05 =
options.networkOptions.moduleAccountV05;
}
if (options.networkOptions?.resourceAccountV05) {
this._networkOptions.resourceAccountV05 = options.networkOptions.resourceAccountV05;
this._networkOptions.resourceAccountV05 =
options.networkOptions.resourceAccountV05;
}
}
this._client = new AptosClient(options.nodeUrl);
this._client = new AptosClient(options.nodeUrl, options.nodeOptions);
this._swap = new SwapModule(this);
this._resources = new ResourcesModule(this);
this._liquidity = new LiquidityModule(this);
this._curves = {
uncorrelated: `${this._networkOptions.moduleAccount}::curves::Uncorrelated`,
stable: `${this._networkOptions.moduleAccount}::curves::Stable`,
uncorrelatedV05: `${this._networkOptions.moduleAccountV05}::curves::Uncorrelated`,
stableV05: `${this._networkOptions.moduleAccountV05}::curves::Stable`
}
stableV05: `${this._networkOptions.moduleAccountV05}::curves::Stable`,
};
}
}
Loading

0 comments on commit dc875d9

Please sign in to comment.