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
  • Loading branch information
ildarH committed Aug 15, 2024
1 parent 23e28e9 commit a0c169c
Show file tree
Hide file tree
Showing 3 changed files with 259 additions and 31 deletions.
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 <[email protected]>",
"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 a0c169c

Please sign in to comment.