Skip to content

Commit 37c97df

Browse files
authored
Merge pull request #106 from tinymanorg/hotfix/global-state-parser
Fix global state parser util function
2 parents 4772c88 + 02f7cfc commit 37c97df

File tree

9 files changed

+29
-28
lines changed

9 files changed

+29
-28
lines changed

dist/governance/rewards/storage.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ declare class RewardsAppGlobalState {
77
rewardPeriodCount: number;
88
manager: string;
99
rewardsManager: string;
10-
constructor(tinyAssetId: number, vaultAppId: number, rewardHistoryCount: number, firstPeriodTimestamp: number, rewardPeriodCount: number, manager: string, rewardsManager: string);
10+
constructor(tinyAssetId: bigint, vaultAppId: bigint, rewardHistoryCount: bigint, firstPeriodTimestamp: bigint, rewardPeriodCount: bigint, manager: string, rewardsManager: string);
1111
}
1212
declare class RewardClaimSheet {
1313
value: Uint8Array;

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/liquid-stake/tAlgoClient.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ declare class TinymanTAlgoClient extends TinymanBaseClient {
1616
/**
1717
* Retrieves the circulating supply of minted tALGO in base units.
1818
*
19-
* @returns {Promise<number>}
19+
* @returns {Promise<bigint>}
2020
*/
21-
getCirculatingSupply(): Promise<number>;
21+
getCirculatingSupply(): Promise<bigint>;
2222
}
2323
export { TinymanTAlgoClient };

dist/util/account/accountUtils.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import algosdk, { Algodv2 } from "algosdk";
1+
import { Algodv2, modelsv2 } from "algosdk";
22
import { ContractVersionValue } from "../../contract/types";
33
import { V1PoolInfo } from "../pool/poolTypes";
44
import { AccountExcess, AccountExcessWithinPool } from "./accountTypes";
55
/**
66
* @returns the decoded application local state object (both keys and values are decoded)
77
*/
8-
export declare function getDecodedAccountApplicationLocalState(accountInfo: algosdk.modelsv2.Account, validatorAppID: number): Record<string, string | number> | null;
9-
export declare function hasSufficientMinimumBalance(accountData: algosdk.modelsv2.Account): boolean;
8+
export declare function getDecodedAccountApplicationLocalState(accountInfo: Pick<modelsv2.Account, "appsLocalState">, validatorAppID: number): Record<string, string | number> | null;
9+
export declare function hasSufficientMinimumBalance(accountData: Pick<modelsv2.Account, "amount" | "minBalance">): boolean;
1010
/**
1111
* Finds the excess amounts accumulated for an account within a pool
1212
* @param params.client An Algodv2 client.
@@ -40,7 +40,7 @@ export declare function getAccountExcess({ client, accountAddr, validatorAppID }
4040
*/
4141
export declare function isAccountOptedIntoApp({ appID, accountAppsLocalState }: {
4242
appID: number;
43-
accountAppsLocalState: algosdk.modelsv2.Account["appsLocalState"];
43+
accountAppsLocalState: modelsv2.Account["appsLocalState"];
4444
}): boolean;
4545
/**
4646
* @returns the minimum balance required to opt in to an app or asset (decided by `type`)

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tinymanorg/tinyman-js-sdk",
3-
"version": "5.0.0-beta",
3+
"version": "5.0.0",
44
"description": "Tinyman JS SDK",
55
"author": "Tinyman Core Team",
66
"license": "MIT",

src/governance/rewards/storage.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ class RewardsAppGlobalState {
1515

1616
// eslint-disable-next-line max-params
1717
constructor(
18-
tinyAssetId: number,
19-
vaultAppId: number,
20-
rewardHistoryCount: number,
21-
firstPeriodTimestamp: number,
22-
rewardPeriodCount: number,
18+
tinyAssetId: bigint,
19+
vaultAppId: bigint,
20+
rewardHistoryCount: bigint,
21+
firstPeriodTimestamp: bigint,
22+
rewardPeriodCount: bigint,
2323
manager: string,
2424
rewardsManager: string
2525
) {
26-
this.tinyAssetId = tinyAssetId;
27-
this.vaultAppId = vaultAppId;
28-
this.rewardHistoryCount = rewardHistoryCount;
29-
this.firstPeriodTimestamp = firstPeriodTimestamp;
30-
this.rewardPeriodCount = rewardPeriodCount;
26+
this.tinyAssetId = Number(tinyAssetId);
27+
this.vaultAppId = Number(vaultAppId);
28+
this.rewardHistoryCount = Number(rewardHistoryCount);
29+
this.firstPeriodTimestamp = Number(firstPeriodTimestamp);
30+
this.rewardPeriodCount = Number(rewardPeriodCount);
3131
this.manager = manager;
3232
this.rewardsManager = rewardsManager;
3333
}

src/governance/utils.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {sha256} from "multiformats/hashes/sha2";
66
/* eslint-enable import/no-unresolved */
77
import {
88
Algodv2,
9+
modelsv2,
910
Transaction,
1011
assignGroupID,
1112
decodeUnsignedTransaction,
@@ -93,20 +94,20 @@ async function getGlobalState(algod: Algodv2, appId: number) {
9394
return parseGlobalStateFromApplicationInfo(applicationInfo);
9495
}
9596

96-
function parseGlobalStateFromApplicationInfo(applicationInfo: Record<string, any>) {
97-
const rawGlobalState = applicationInfo.params.globalState;
97+
function parseGlobalStateFromApplicationInfo(applicationInfo: modelsv2.Application) {
98+
const rawGlobalState = applicationInfo.params.globalState ?? [];
9899

99100
const globalState: Record<string, any> = {};
100101

101102
for (const pair of rawGlobalState) {
102-
const key = Buffer.from(pair.key, "base64").toString();
103+
const key = Buffer.from(pair.key).toString();
103104

104105
let value;
105106

106107
if (pair.value.type === 1) {
107-
value = Buffer.from(pair.value.bytes || "", "base64");
108+
value = pair.value.bytes;
108109
} else {
109-
value = pair.value.uint || 0;
110+
value = pair.value.uint;
110111
}
111112

112113
globalState[key] = value;

src/liquid-stake/tAlgoClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ class TinymanTAlgoClient extends TinymanBaseClient {
102102
/**
103103
* Retrieves the circulating supply of minted tALGO in base units.
104104
*
105-
* @returns {Promise<number>}
105+
* @returns {Promise<bigint>}
106106
*/
107-
getCirculatingSupply(): Promise<number> {
107+
getCirculatingSupply(): Promise<bigint> {
108108
return this.getGlobal(encodeString("minted_talgo"));
109109
}
110110
}

0 commit comments

Comments
 (0)