Skip to content

Commit

Permalink
Merge pull request #93 from tinymanorg/fix/tiny-1690-update-cache-cor…
Browse files Browse the repository at this point in the history
…rectly

Remove cache props from governance
  • Loading branch information
gulcinuras authored Nov 12, 2024
2 parents b22e80e + 8ec6637 commit db823e9
Show file tree
Hide file tree
Showing 20 changed files with 155 additions and 187 deletions.
3 changes: 2 additions & 1 deletion dist/governance/constants.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { SupportedNetwork } from "../util/commonTypes";
declare const HOUR_IN_S: number;
declare const DAY_IN_S: number;
declare const WEEK_IN_S: number;
declare const SECOND_IN_MS = 1000;
declare const VAULT_APP_ID: Record<SupportedNetwork, number>;
declare const STAKING_VOTING_APP_ID: Record<SupportedNetwork, number>;
declare const REWARDS_APP_ID: Record<SupportedNetwork, number>;
Expand All @@ -13,4 +14,4 @@ declare const DAY: number;
declare const WEEK: number;
export { HOUR, DAY, WEEK };
declare const TWO_TO_THE_64: number;
export { VAULT_APP_ID, STAKING_VOTING_APP_ID, REWARDS_APP_ID, BOX_BYTE_MIN_BALANCE, BOX_FLAT_MIN_BALANCE, TWO_TO_THE_64, WEEK_IN_S, DAY_IN_S, HOUR_IN_S, PROPOSAL_VOTING_APP_ID };
export { VAULT_APP_ID, STAKING_VOTING_APP_ID, REWARDS_APP_ID, BOX_BYTE_MIN_BALANCE, BOX_FLAT_MIN_BALANCE, TWO_TO_THE_64, WEEK_IN_S, DAY_IN_S, HOUR_IN_S, SECOND_IN_MS, PROPOSAL_VOTING_APP_ID };
19 changes: 9 additions & 10 deletions dist/governance/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import AlgodClient from "algosdk/dist/types/client/v2/algod/algod";
import { SuggestedParams, Transaction } from "algosdk";
import { VaultAppGlobalState } from "./vault/storage";
import { RewardsAppGlobalState } from "./rewards/storage";
import { ProposalVotingAppGlobalState } from "./proposal-voting/storage";
import { ProposalVote } from "./proposal-voting/constants";
import { GetRawBoxValueCacheProps } from "./types";
import AlgodClient from "algosdk/dist/types/client/v2/algod/algod";
import { SupportedNetwork } from "../util/commonTypes";
import { ProposalVote } from "./proposal-voting/constants";
import { ProposalVotingAppGlobalState } from "./proposal-voting/storage";
import { RewardsAppGlobalState } from "./rewards/storage";
import { VaultAppGlobalState } from "./vault/storage";
declare class TinymanGovernanceClient {
private algodClient;
private userAddress;
private network;
constructor(algodClient: AlgodClient, userAddress: string, network: SupportedNetwork);
getTinyPower(timeStamp?: number, cacheProps?: GetRawBoxValueCacheProps): Promise<number>;
getTotalTinyPower(timeStamp?: number, cacheProps?: GetRawBoxValueCacheProps): Promise<number>;
getCumulativeTinyPower(cacheProps?: GetRawBoxValueCacheProps, timeStamp?: number): Promise<number>;
getTinyPower(timeStamp?: number): Promise<number>;
getTotalTinyPower(timeStamp?: number): Promise<number>;
getCumulativeTinyPower(timeStamp?: number): Promise<number>;
fetchVaultAppGlobalState(): Promise<VaultAppGlobalState | null>;
generateCreateLockTransactions({ lockedAmount, lockEndTime, userAddress, suggestedParams }: {
lockedAmount: number;
Expand Down Expand Up @@ -71,6 +70,6 @@ declare class TinymanGovernanceClient {
suggestedParams?: SuggestedParams;
}): Promise<Transaction[]>;
fetchProposalVotingAppGlobalState(): Promise<ProposalVotingAppGlobalState>;
getRequiredTinyPowerToCreateProposal(): Promise<number>;
getRequiredTinyPowerToCreateProposal(totalTinyPower: number): Promise<number>;
}
export { TinymanGovernanceClient };
2 changes: 1 addition & 1 deletion dist/governance/rewards/storage.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ declare class RewardClaimSheet {
declare function getRewardPeriodBoxName(boxIndex: number): Uint8Array;
declare function getAccountRewardClaimSheetBoxName(address: string, boxIndex: number): Uint8Array;
declare function getRewardClaimSheet(algod: AlgodClient, appId: number, address: string, accountRewardClaimSheetBoxIndex: number): Promise<RewardClaimSheet | null>;
export { RewardClaimSheet, RewardsAppGlobalState, getRewardPeriodBoxName, getAccountRewardClaimSheetBoxName, getRewardClaimSheet };
export { getAccountRewardClaimSheetBoxName, getRewardClaimSheet, getRewardPeriodBoxName, RewardClaimSheet, RewardsAppGlobalState };
2 changes: 1 addition & 1 deletion dist/governance/staking-voting/storage.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ declare function getStakingDistributionProposalBoxName(proposalId: string): Uint
declare function getStakingAttendanceSheetBoxName(sender: string, boxIndex: number): Uint8Array;
declare function getStakingVoteBoxName(proposalIndex: number, assetId: number): Uint8Array;
declare function getStakingDistributionProposal(algod: AlgodClient, appId: number, proposalId: string): Promise<StakingDistributionProposal | null>;
export { StakingDistributionProposal, getStakingDistributionProposalBoxName, getStakingAttendanceSheetBoxName, getStakingVoteBoxName, getStakingDistributionProposal };
export { getStakingAttendanceSheetBoxName, getStakingDistributionProposal, getStakingDistributionProposalBoxName, getStakingVoteBoxName, StakingDistributionProposal };
4 changes: 0 additions & 4 deletions dist/governance/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
export interface RawBoxCacheValue {
[key: string]: Uint8Array;
}
export interface GetRawBoxValueCacheProps {
onCacheUpdate: (cacheData: RawBoxCacheValue) => void;
cacheData: RawBoxCacheValue | null;
}
5 changes: 2 additions & 3 deletions dist/governance/utils.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import AlgodClient from "algosdk/dist/types/client/v2/algod/algod";
import { Transaction } from "algosdk";
import { GetRawBoxValueCacheProps } from "./types";
declare function getRawBoxValue(algod: AlgodClient, appId: number, boxName: Uint8Array, cacheProps?: GetRawBoxValueCacheProps): Promise<Uint8Array | null>;
declare function getRawBoxValue(algod: AlgodClient, appId: number, boxName: Uint8Array): Promise<Uint8Array | null>;
declare function doesBoxExist(algod: AlgodClient, appId: number, boxName: Uint8Array): Promise<boolean>;
declare function getBias(slope: number, timeDelta: number): number;
/**
Expand All @@ -18,4 +17,4 @@ declare function concatUint8Arrays(...arrays: Uint8Array[]): Uint8Array;
declare function generateCidFromProposalMetadata(metadata: Record<string, any>): Promise<string>;
declare function combineAndRegroupTxns(...txns: Transaction[][]): Transaction[];
declare function getAllBoxNames(algod: AlgodClient, appId: number): Promise<Uint8Array[]>;
export { getRawBoxValue, getCumulativePowerDelta, getBias, getGlobalState, concatUint8Arrays, doesBoxExist, getAllBoxNames, generateCidFromProposalMetadata, combineAndRegroupTxns, calculateTinyPower };
export { calculateTinyPower, combineAndRegroupTxns, concatUint8Arrays, doesBoxExist, generateCidFromProposalMetadata, getAllBoxNames, getBias, getCumulativePowerDelta, getGlobalState, getRawBoxValue };
12 changes: 8 additions & 4 deletions dist/governance/vault/storage.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import AlgodClient from "algosdk/dist/types/client/v2/algod/algod";
import { GetRawBoxValueCacheProps } from "../types";
declare class AccountState {
lockedAmount: number;
lockEndTime: number;
Expand Down Expand Up @@ -47,7 +46,12 @@ declare function getLastAccountPowerBoxIndexes(powerCount: number): [number, num
declare function getAccountPowerBoxName(address: string, boxIndex: number): Uint8Array;
declare function getSlopeChange(algod: AlgodClient, appId: number, timeStamp: number): Promise<SlopeChange | null>;
declare function getSlopeChangeBoxName(timestamp: number): Uint8Array;
declare function getAllTotalPowers(algodClient: AlgodClient, appId: number, totalPowerCount: number, cacheProps?: GetRawBoxValueCacheProps): Promise<TotalPower[]>;
declare function getAccountPowers(algodClient: AlgodClient, address: string, appId: number, powerCount?: number | null, cacheProps?: GetRawBoxValueCacheProps): Promise<AccountPower[]>;
declare function getAllTotalPowers(algodClient: AlgodClient, appId: number, totalPowerCount: number): Promise<TotalPower[]>;
declare function getAccountPowers({ algodClient, address, appId, powerCount }: {
algodClient: AlgodClient;
address: string;
appId: number;
powerCount: number | null;
}): Promise<AccountPower[]>;
declare function getPowerIndexAt(powers: AccountPower[] | TotalPower[], timestamp: number): number | null;
export { AccountState, AccountPower, TotalPower, VaultAppGlobalState, SlopeChange, getAccountState, getAccountPowers, getAccountPowerBoxName, getAccountStateBoxName, getLastAccountPowerBoxIndexes, getPowerIndexAt, getTotalPowerBoxName, getSlopeChangeBoxName, getSlopeChange, getAllTotalPowers };
export { AccountPower, AccountState, SlopeChange, TotalPower, VaultAppGlobalState, getAccountPowerBoxName, getAccountPowers, getAccountState, getAccountStateBoxName, getAllTotalPowers, getLastAccountPowerBoxIndexes, getPowerIndexAt, getSlopeChange, getSlopeChangeBoxName, getTotalPowerBoxName };
2 changes: 1 addition & 1 deletion dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export { prepareCommitTransactions, getStakingAppID } from "./stake";
export { tinymanJSSDKConfig } from "./config";
export { combineAndRegroupSignerTxns } from "./util/transaction/transactionUtils";
export { TinymanGovernanceClient } from "./governance";
export type { GetRawBoxValueCacheProps, RawBoxCacheValue } from "./governance/types";
export type { RawBoxCacheValue } from "./governance/types";
export { AccountState } from "./governance/vault/storage";
export { getStartTimestampOfWeek } from "./governance/vault/utils";
export { ProposalVote } from "./governance/proposal-voting/constants";
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tinymanorg/tinyman-js-sdk",
"version": "4.0.5",
"version": "4.0.6",
"description": "Tinyman JS SDK",
"author": "Tinyman Core Team",
"license": "MIT",
Expand Down
2 changes: 2 additions & 0 deletions src/governance/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {SupportedNetwork} from "../util/commonTypes";
const HOUR_IN_S = 60 * 60;
const DAY_IN_S = 24 * HOUR_IN_S;
const WEEK_IN_S = 7 * DAY_IN_S;
const SECOND_IN_MS = 1000;

const VAULT_APP_ID: Record<SupportedNetwork, number> = {
testnet: 480164661,
Expand Down Expand Up @@ -45,5 +46,6 @@ export {
WEEK_IN_S,
DAY_IN_S,
HOUR_IN_S,
SECOND_IN_MS,
PROPOSAL_VOTING_APP_ID
};
Loading

0 comments on commit db823e9

Please sign in to comment.