@bgd-labs/toolbox 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +46 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +43 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1896,7 +1896,7 @@ async function getNonFinalizedPayloads(client, payloadsController) {
|
|
|
1896
1896
|
const controllerContract = getPayloadsController(client, payloadsController);
|
|
1897
1897
|
const payloadsCount = await controllerContract.read.getPayloadsCount();
|
|
1898
1898
|
const nonFinalPayloads = [];
|
|
1899
|
-
for (
|
|
1899
|
+
for (let payloadId = payloadsCount - 1; payloadId != 0; payloadId--) {
|
|
1900
1900
|
const maxRange = (35 + 10 + 7) * 24 * 60 * 60;
|
|
1901
1901
|
const payload = await controllerContract.read.getPayloadById([payloadId]);
|
|
1902
1902
|
if ([2 /* Queued */, 1 /* Created */].includes(payload.state))
|
|
@@ -1913,15 +1913,26 @@ import {
|
|
|
1913
1913
|
toHex as toHex2
|
|
1914
1914
|
} from "viem";
|
|
1915
1915
|
import { getBlock as getBlock2, getStorageAt } from "viem/actions";
|
|
1916
|
+
var ProposalState = /* @__PURE__ */ ((ProposalState2) => {
|
|
1917
|
+
ProposalState2[ProposalState2["Null"] = 0] = "Null";
|
|
1918
|
+
ProposalState2[ProposalState2["Created"] = 1] = "Created";
|
|
1919
|
+
ProposalState2[ProposalState2["Active"] = 2] = "Active";
|
|
1920
|
+
ProposalState2[ProposalState2["Queued"] = 3] = "Queued";
|
|
1921
|
+
ProposalState2[ProposalState2["Executed"] = 4] = "Executed";
|
|
1922
|
+
ProposalState2[ProposalState2["Failed"] = 5] = "Failed";
|
|
1923
|
+
ProposalState2[ProposalState2["Cancelled"] = 6] = "Cancelled";
|
|
1924
|
+
ProposalState2[ProposalState2["Expired"] = 7] = "Expired";
|
|
1925
|
+
return ProposalState2;
|
|
1926
|
+
})(ProposalState || {});
|
|
1916
1927
|
var HUMAN_READABLE_PROPOSAL_STATE = {
|
|
1917
|
-
[
|
|
1918
|
-
[
|
|
1919
|
-
[
|
|
1920
|
-
[
|
|
1921
|
-
[
|
|
1922
|
-
[
|
|
1923
|
-
[
|
|
1924
|
-
[
|
|
1928
|
+
[0 /* Null */]: "Null",
|
|
1929
|
+
[1 /* Created */]: "Created",
|
|
1930
|
+
[2 /* Active */]: "Active",
|
|
1931
|
+
[3 /* Queued */]: "Queued",
|
|
1932
|
+
[4 /* Executed */]: "Executed",
|
|
1933
|
+
[5 /* Failed */]: "Failed",
|
|
1934
|
+
[6 /* Cancelled */]: "Cancelled",
|
|
1935
|
+
[7 /* Expired */]: "Expired"
|
|
1925
1936
|
};
|
|
1926
1937
|
function getGovernance(client, address) {
|
|
1927
1938
|
return getContract2({
|
|
@@ -1942,7 +1953,7 @@ async function makeProposalExecutableOnTestClient(client, governance, proposalId
|
|
|
1942
1953
|
manipulatedStorage,
|
|
1943
1954
|
0n,
|
|
1944
1955
|
8n,
|
|
1945
|
-
|
|
1956
|
+
3 /* Queued */
|
|
1946
1957
|
);
|
|
1947
1958
|
manipulatedStorage = setBits(
|
|
1948
1959
|
manipulatedStorage,
|
|
@@ -1958,6 +1969,22 @@ async function makeProposalExecutableOnTestClient(client, governance, proposalId
|
|
|
1958
1969
|
value: toHex2(manipulatedStorage, { size: 32 })
|
|
1959
1970
|
});
|
|
1960
1971
|
}
|
|
1972
|
+
async function getNonFinalizedProposals(client, governanceAddress) {
|
|
1973
|
+
const goverannceContract = getGovernance(client, governanceAddress);
|
|
1974
|
+
const proposalsCount = await goverannceContract.read.getProposalsCount();
|
|
1975
|
+
const nonFinalProposals = [];
|
|
1976
|
+
for (let proposalId = proposalsCount - 1n; proposalId != 0n; proposalId--) {
|
|
1977
|
+
const proposal = await goverannceContract.read.getProposal([proposalId]);
|
|
1978
|
+
if ([
|
|
1979
|
+
3 /* Queued */,
|
|
1980
|
+
1 /* Created */,
|
|
1981
|
+
2 /* Active */
|
|
1982
|
+
].includes(proposal.state))
|
|
1983
|
+
nonFinalProposals.push(proposalId);
|
|
1984
|
+
if (proposal.creationTime < Date.now() / 1e3 - 2592e3) break;
|
|
1985
|
+
}
|
|
1986
|
+
return nonFinalProposals;
|
|
1987
|
+
}
|
|
1961
1988
|
|
|
1962
1989
|
// src/ecosystem/generated/etherscanExplorers.ts
|
|
1963
1990
|
var etherscanExplorers = {
|
|
@@ -2852,7 +2879,7 @@ async function getSourceCode(params) {
|
|
|
2852
2879
|
}
|
|
2853
2880
|
return result[0];
|
|
2854
2881
|
}
|
|
2855
|
-
function
|
|
2882
|
+
function parseEtherscanStyleSourceCode(sourceCode) {
|
|
2856
2883
|
if (sourceCode.startsWith("{{") && sourceCode.endsWith("}}")) {
|
|
2857
2884
|
sourceCode = sourceCode.substring(1, sourceCode.length - 1);
|
|
2858
2885
|
}
|
|
@@ -2962,8 +2989,8 @@ import { format } from "prettier/standalone";
|
|
|
2962
2989
|
import solidityPlugin from "prettier-plugin-solidity/standalone";
|
|
2963
2990
|
var prettierOptions = { parser: "solidity-parse", plugins: [solidityPlugin] };
|
|
2964
2991
|
async function diffCode(codeBefore, codeAfter) {
|
|
2965
|
-
const before =
|
|
2966
|
-
const after =
|
|
2992
|
+
const before = parseEtherscanStyleSourceCode(codeBefore);
|
|
2993
|
+
const after = parseEtherscanStyleSourceCode(codeAfter);
|
|
2967
2994
|
const changes = {};
|
|
2968
2995
|
const settingsBefore = JSON.stringify(before.settings, null, 2);
|
|
2969
2996
|
const settingsAfter = JSON.stringify(after.settings, null, 2);
|
|
@@ -3012,6 +3039,7 @@ export {
|
|
|
3012
3039
|
HUMAN_READABLE_PROPOSAL_STATE,
|
|
3013
3040
|
LTV_PRECISION,
|
|
3014
3041
|
PayloadState,
|
|
3042
|
+
ProposalState,
|
|
3015
3043
|
RAY,
|
|
3016
3044
|
SECONDS_PER_YEAR,
|
|
3017
3045
|
WAD,
|
|
@@ -3034,13 +3062,14 @@ export {
|
|
|
3034
3062
|
getGovernance,
|
|
3035
3063
|
getMarketReferenceCurrencyAndUsdBalance,
|
|
3036
3064
|
getNonFinalizedPayloads,
|
|
3065
|
+
getNonFinalizedProposals,
|
|
3037
3066
|
getNormalizedDebt,
|
|
3038
3067
|
getNormalizedIncome,
|
|
3039
3068
|
getPayloadsController,
|
|
3040
3069
|
getSourceCode,
|
|
3041
3070
|
makePayloadExecutableOnTestClient,
|
|
3042
3071
|
makeProposalExecutableOnTestClient,
|
|
3043
|
-
|
|
3072
|
+
parseEtherscanStyleSourceCode,
|
|
3044
3073
|
rayDiv,
|
|
3045
3074
|
rayMul,
|
|
3046
3075
|
rayToWad,
|