Skip to content

Commit

Permalink
added new configuration types
Browse files Browse the repository at this point in the history
  • Loading branch information
mpsc0x committed Nov 1, 2024
1 parent 912b15b commit 9fbd570
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 42 deletions.
4 changes: 2 additions & 2 deletions examples/admin/setupTestnet.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import dotenv from "dotenv";
import { Account, AccountAddress, Ed25519PrivateKey } from "@aptos-labs/ts-sdk";
import { AptosProvider } from "../../src/clients/aptosProvider";
import { testnetConfig } from "../../src/configs/testnet";
import { DEFAULT_TESTNET_CONFIG } from "../../src/configs/testnet";
import { PoolClient, UnderlyingTokensClient } from "../../src/clients";

dotenv.config();
Expand Down Expand Up @@ -129,7 +129,7 @@ const poolSigner = Account.fromPrivateKey({
});

(async () => {
const aptosProvider = AptosProvider.fromConfig(testnetConfig);
const aptosProvider = AptosProvider.fromConfig(DEFAULT_TESTNET_CONFIG);

const poolClient = new PoolClient(aptosProvider, poolSigner);
const underlyingTokenClient = new UnderlyingTokensClient(
Expand Down
4 changes: 2 additions & 2 deletions examples/quiries/getAddresses.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { AptosProvider } from "../../src/clients";
import { PoolAddressesProviderClient } from "../../src/clients/poolAddressesProviderClient";
import { testnetConfig } from "../../src/configs/testnet";
import { DEFAULT_TESTNET_CONFIG } from "../../src/configs/testnet";

(async () => {
// global aptos provider
const aptosProvider = AptosProvider.fromConfig(testnetConfig);
const aptosProvider = AptosProvider.fromConfig(DEFAULT_TESTNET_CONFIG);

// pool addresses provider
const poolAddressesProviderClient = new PoolAddressesProviderClient(
Expand Down
4 changes: 2 additions & 2 deletions examples/quiries/getProtocolData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { UnderlyingTokensClient } from "../../src/clients/underlyingTokensClient
import { UiPoolDataProviderClient } from "../../src/clients/uiPoolDataProvider";
import { PoolClient } from "../../src/clients/poolClient";
import { AptosProvider } from "../../src/clients/aptosProvider";
import { testnetConfig } from "../../src/configs/testnet";
import { DEFAULT_TESTNET_CONFIG } from "../../src/configs/testnet";
import { VariableTokensClient } from "../../src/clients/variableTokensClient";

(async () => {
// global aptos provider
const aptosProvider = AptosProvider.fromConfig(testnetConfig);
const aptosProvider = AptosProvider.fromConfig(DEFAULT_TESTNET_CONFIG);

// all atokens-related operations client
const aTokensClient = new ATokensClient(aptosProvider);
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@
"ts-jest": "^29.2.5",
"ts-loader": "^9.5.1",
"ts-node": "^10.9.2",
"typedoc": "^0.26.10",
"typedoc": "^0.26.11",
"typescript": "^5.6.3",
"typescript-eslint": "^8.12.2",
"webpack": "^5.96.0",
"webpack": "^5.96.1",
"webpack-cli": "^5.1.4"
},
"optionalDependencies": {
Expand Down
81 changes: 49 additions & 32 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion src/configs/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
export { testnetConfig } from "./testnet";
export {
DEFAULT_TESTNET_CONFIG,
EMPTY_LOCAL_CONFIG,
EMPTY_TESTNET_CONFIG,
} from "./testnet";
45 changes: 44 additions & 1 deletion src/configs/testnet.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Network } from "@aptos-labs/ts-sdk";
import { AptosProviderConfig } from "../clients/aptosProvider";
import { ZERO_ADDRESS } from "../helpers";

export const testnetConfig: AptosProviderConfig = {
export const DEFAULT_TESTNET_CONFIG: AptosProviderConfig = {
network: Network.TESTNET,
addresses: {
A_TOKENS:
Expand Down Expand Up @@ -29,3 +30,45 @@ export const testnetConfig: AptosProviderConfig = {
"0x5bc11445584a763c1fa7ed39081f1b920954da14e04b32440cba863d03e19625",
},
};

export const EMPTY_TESTNET_CONFIG = (): AptosProviderConfig => {
return {
network: Network.TESTNET,
addresses: {
A_TOKENS: ZERO_ADDRESS.toString(),
UNDERLYING_TOKENS: ZERO_ADDRESS.toString(),
VARIABLE_TOKENS: ZERO_ADDRESS.toString(),
AAVE_ACL: ZERO_ADDRESS.toString(),
AAVE_CONFIG: ZERO_ADDRESS.toString(),
AAVE_MOCK_ORACLE: ZERO_ADDRESS.toString(),
AAVE_POOL: ZERO_ADDRESS.toString(),
},
oracle: {
URL: "https://hermes-beta.pyth.network",
CONTRACT_ACCOUNT: ZERO_ADDRESS.toString(),
DEPLOYER_ACCOUNT: ZERO_ADDRESS.toString(),
WORMHOLE: ZERO_ADDRESS.toString(),
},
} as AptosProviderConfig;
};

export const EMPTY_LOCAL_CONFIG = (): AptosProviderConfig => {
return {
network: Network.LOCAL,
addresses: {
A_TOKENS: ZERO_ADDRESS.toString(),
UNDERLYING_TOKENS: ZERO_ADDRESS.toString(),
VARIABLE_TOKENS: ZERO_ADDRESS.toString(),
AAVE_ACL: ZERO_ADDRESS.toString(),
AAVE_CONFIG: ZERO_ADDRESS.toString(),
AAVE_MOCK_ORACLE: ZERO_ADDRESS.toString(),
AAVE_POOL: ZERO_ADDRESS.toString(),
},
oracle: {
URL: "https://hermes-beta.pyth.network",
CONTRACT_ACCOUNT: ZERO_ADDRESS.toString(),
DEPLOYER_ACCOUNT: ZERO_ADDRESS.toString(),
WORMHOLE: ZERO_ADDRESS.toString(),
},
} as AptosProviderConfig;
};

0 comments on commit 9fbd570

Please sign in to comment.