Skip to content

Commit

Permalink
Merge pull request #2 from aave/feat/sdk-fixes
Browse files Browse the repository at this point in the history
Feat/sdk fixes
  • Loading branch information
mpsc0x authored Nov 19, 2024
2 parents 2631e0e + 9a101cd commit 034e8a4
Show file tree
Hide file tree
Showing 15 changed files with 27 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ bundle.*
# docs files
docs


#.env files
.env

# Misc
.DS_Store

1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
"clean-dist": "rimraf dist/*",
"build-esm": "tsc --project tsconfig.esm.json",
"build-commonjs": "tsc --project tsconfig.commonjs.json",
"build-esm:watch": "tsc --project tsconfig.esm.json --watch",
"build-commonjs:watch": "tsc --project tsconfig.commonjs.json --watch",
"build-bundle": "webpack",
"build": "npm-run-all clean-dist build-*",
"dev": "run-p build-commonjs:watch build-esm:watch",
"update-version-major": "pnpm version major",
"update-version-minor": "pnpm version minor",
"update-version-patch": "pnpm version patch",
Expand Down
15 changes: 10 additions & 5 deletions src/clients/aptosProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
Ed25519Account,
} from "@aptos-labs/ts-sdk";
import YAML from "yaml";
import { map } from "yaml/dist/schema/common/map";

export interface AptosProviderConfig {
network: Network;
Expand Down Expand Up @@ -62,8 +63,8 @@ export class AptosProvider {

private oracleUrl: string;

private profileAddressMap: Map<string, AccountAddress> = new Map();
private profileAccountMap: Map<string, Ed25519PrivateKey> = new Map();
private profileAddressMap = new Map<string, AccountAddress>();
private profileAccountMap = new Map<string, Ed25519PrivateKey>();

private aptos: Aptos;

Expand Down Expand Up @@ -386,9 +387,13 @@ export class AptosProvider {

/** Returns the profile private key by name if found. */
public getProfileAccountByName(profileName: string): Ed25519Account {
return Account.fromPrivateKey({
privateKey: this.getProfileAccountPrivateKeyByName(profileName),
});
const profileAccount = this.getProfileAccountPrivateKeyByName(profileName);
if (profileAccount) {
return Account.fromPrivateKey({
privateKey: this.getProfileAccountPrivateKeyByName(profileName),
});
}
return undefined;
}

/** Returns the profile address by name if found. */
Expand Down
2 changes: 2 additions & 0 deletions src/clients/uiPoolDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export type UserReserveData = {
scaledATokenBalance: bigint;
usageAsCollateralEnabledOnUser: boolean;
scaledVariableDebt: bigint;
decimals: number;
};

export type ReservesData = {
Expand Down Expand Up @@ -211,6 +212,7 @@ export class UiPoolDataProviderClient extends AptosContractWrapperBaseClass {
usageAsCollateralEnabledOnUser:
item.usage_as_collateral_enabled_on_user as boolean,
scaledVariableDebt: BigInt(item.scaled_variable_debt),
decimals: Number(item.decimals.toString()),
}) as UserReserveData,
);

Expand Down
2 changes: 1 addition & 1 deletion src/contracts/acl_manage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class AclManagerContract {
setRoleAdmin: MoveFunctionId;

constructor(provider: AptosProvider) {
const AclManager = provider.getProfileAccountByName(AAVE_PROFILES.AAVE_ACL);
const AclManager = provider.getProfileAddressByName(AAVE_PROFILES.AAVE_ACL);
const AclManagerAccountAddress = AclManager.toString();
this.hasRoleFuncAddr = `${AclManagerAccountAddress}::acl_manage::has_role`;
this.grantRoleFuncAddr = `${AclManagerAccountAddress}::acl_manage::grant_role`;
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class BridgeContract {
BackUnbackedFuncAddr: MoveFunctionId;

constructor(provider: AptosProvider) {
const BridgeManager = provider.getProfileAccountByName(
const BridgeManager = provider.getProfileAddressByName(
AAVE_PROFILES.AAVE_POOL,
);
const BridgeManagerAccountAddress = BridgeManager.toString();
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/flashloan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class FlashLoanContract {
PayFlashLoanSimpleFuncAddr: MoveFunctionId;

constructor(provider: AptosProvider) {
const FlashLoanManager = provider.getProfileAccountByName(
const FlashLoanManager = provider.getProfileAddressByName(
AAVE_PROFILES.AAVE_POOL,
);
const FlashLoanManagerAccountAddress = FlashLoanManager.toString();
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/oracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class OracleContract {
GetGracePeriodFuncAddr: MoveFunctionId;

constructor(provider: AptosProvider) {
const OracleManager = provider.getProfileAccountByName(
const OracleManager = provider.getProfileAddressByName(
AAVE_PROFILES.AAVE_MOCK_ORACLE,
);
const OracleManagerAccountAddress = OracleManager.toString();
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ export class PoolContract {
SetPoolDataProviderFuncAddr: MoveFunctionId;

constructor(provider: AptosProvider) {
const PoolManager = provider.getProfileAccountByName(
const PoolManager = provider.getProfileAddressByName(
AAVE_PROFILES.AAVE_POOL,
);
const PoolManagerAccountAddress = PoolManager.toString();
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/supply_borrow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class SupplyBorrowContract {
GetUserAccountDataFuncAddr: MoveFunctionId;

constructor(provider: AptosProvider) {
const SupplyBorrowManager = provider.getProfileAccountByName(
const SupplyBorrowManager = provider.getProfileAddressByName(
AAVE_PROFILES.AAVE_POOL,
);
const SupplyBorrowManagerAccountAddress = SupplyBorrowManager.toString();
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class TokensContract {

constructor(provider: AptosProvider) {
// Underlying Token
const AaveTokensManager = provider.getProfileAccountByName(
const AaveTokensManager = provider.getProfileAddressByName(
AAVE_PROFILES.AAVE_POOL,
);
const AaveTokensManagerAccountAddress = AaveTokensManager.toString();
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/uiIncentiveDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class UiIncentiveDataProviderContract {
getUserReservesIncentivesData: MoveFunctionId;

constructor(provider: AptosProvider) {
const PeripheryManager = provider.getProfileAccountByName(
const PeripheryManager = provider.getProfileAddressByName(
AAVE_PROFILES.AAVE_POOL,
);
const PeripheryManagerAccountAddress = PeripheryManager.toString();
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/uiPoolDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class UiPoolDataProviderContract {
getUserReservesData: MoveFunctionId;

constructor(provider: AptosProvider) {
const PeripheryManager = provider.getProfileAccountByName(
const PeripheryManager = provider.getProfileAddressByName(
AAVE_PROFILES.AAVE_POOL,
);
const PeripheryManagerAccountAddress = PeripheryManager.toString();
Expand Down
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"noImplicitAny": false,
"noImplicitThis": false,
"skipLibCheck": true,
"strictNullChecks": false,
"downlevelIteration": true,
"esModuleInterop": true,
"outDir": "dist",
Expand Down

0 comments on commit 034e8a4

Please sign in to comment.