@reserve-protocol/sdk 0.1.3 → 0.1.5
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 +8 -7
- package/dist/index.mjs +53 -30
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -25789,6 +25789,7 @@ type ProposalContractDecoder = {
|
|
|
25789
25789
|
readonly contract: string;
|
|
25790
25790
|
readonly abi: Abi;
|
|
25791
25791
|
};
|
|
25792
|
+
type ProposalContractDecoderMap = Map<string, ProposalContractDecoder | readonly ProposalContractDecoder[]>;
|
|
25792
25793
|
type IndexDtfProposalGovernanceContractContext = {
|
|
25793
25794
|
readonly address: Address;
|
|
25794
25795
|
readonly timelock: {
|
|
@@ -25823,7 +25824,7 @@ type IndexDtfProposalDtfContractContext = {
|
|
|
25823
25824
|
type DecodeIndexDtfProposalCalldatasParams = {
|
|
25824
25825
|
readonly targets: readonly Address[];
|
|
25825
25826
|
readonly calldatas: readonly `0x${string}`[];
|
|
25826
|
-
readonly contractMap:
|
|
25827
|
+
readonly contractMap: ProposalContractDecoderMap;
|
|
25827
25828
|
};
|
|
25828
25829
|
type DecodeIndexDtfProposalParams = {
|
|
25829
25830
|
readonly chainId: SupportedChainId;
|
|
@@ -35680,8 +35681,8 @@ declare const indexDtfBasketTokenSchema: z.ZodObject<{
|
|
|
35680
35681
|
priceError: z.ZodOptional<z.ZodNumber>;
|
|
35681
35682
|
priceVolatility: z.ZodOptional<z.ZodEnum<{
|
|
35682
35683
|
low: "low";
|
|
35683
|
-
high: "high";
|
|
35684
35684
|
medium: "medium";
|
|
35685
|
+
high: "high";
|
|
35685
35686
|
degen: "degen";
|
|
35686
35687
|
}>>;
|
|
35687
35688
|
maxAuctionSizeUsd: z.ZodOptional<z.ZodNumber>;
|
|
@@ -35695,8 +35696,8 @@ declare const indexDtfBasketSharesSchema: z.ZodObject<{
|
|
|
35695
35696
|
priceError: z.ZodOptional<z.ZodNumber>;
|
|
35696
35697
|
priceVolatility: z.ZodOptional<z.ZodEnum<{
|
|
35697
35698
|
low: "low";
|
|
35698
|
-
high: "high";
|
|
35699
35699
|
medium: "medium";
|
|
35700
|
+
high: "high";
|
|
35700
35701
|
degen: "degen";
|
|
35701
35702
|
}>>;
|
|
35702
35703
|
maxAuctionSizeUsd: z.ZodOptional<z.ZodNumber>;
|
|
@@ -35712,8 +35713,8 @@ declare const indexDtfBasketUnitsSchema: z.ZodObject<{
|
|
|
35712
35713
|
priceError: z.ZodOptional<z.ZodNumber>;
|
|
35713
35714
|
priceVolatility: z.ZodOptional<z.ZodEnum<{
|
|
35714
35715
|
low: "low";
|
|
35715
|
-
high: "high";
|
|
35716
35716
|
medium: "medium";
|
|
35717
|
+
high: "high";
|
|
35717
35718
|
degen: "degen";
|
|
35718
35719
|
}>>;
|
|
35719
35720
|
maxAuctionSizeUsd: z.ZodOptional<z.ZodNumber>;
|
|
@@ -35729,8 +35730,8 @@ declare const indexDtfBasketSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
35729
35730
|
priceError: z.ZodOptional<z.ZodNumber>;
|
|
35730
35731
|
priceVolatility: z.ZodOptional<z.ZodEnum<{
|
|
35731
35732
|
low: "low";
|
|
35732
|
-
high: "high";
|
|
35733
35733
|
medium: "medium";
|
|
35734
|
+
high: "high";
|
|
35734
35735
|
degen: "degen";
|
|
35735
35736
|
}>>;
|
|
35736
35737
|
maxAuctionSizeUsd: z.ZodOptional<z.ZodNumber>;
|
|
@@ -35745,8 +35746,8 @@ declare const indexDtfBasketSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
35745
35746
|
priceError: z.ZodOptional<z.ZodNumber>;
|
|
35746
35747
|
priceVolatility: z.ZodOptional<z.ZodEnum<{
|
|
35747
35748
|
low: "low";
|
|
35748
|
-
high: "high";
|
|
35749
35749
|
medium: "medium";
|
|
35750
|
+
high: "high";
|
|
35750
35751
|
degen: "degen";
|
|
35751
35752
|
}>>;
|
|
35752
35753
|
maxAuctionSizeUsd: z.ZodOptional<z.ZodNumber>;
|
|
@@ -85674,7 +85675,7 @@ declare function createIndexDtfNamespace(client: DtfClient): {
|
|
|
85674
85675
|
getPrices: (params: Parameters<typeof getPrices>[1]) => Promise<readonly IndexDtfBatchPrice[]>;
|
|
85675
85676
|
getPriceHistory: (params: GetIndexDtfPriceHistoryParams) => Promise<readonly IndexDtfPricePoint[]>;
|
|
85676
85677
|
getStatus: (params: Parameters<typeof getIndexDtfStatus>[1]) => Promise<DtfStatus>;
|
|
85677
|
-
getStatuses: (params?: Parameters<typeof getIndexDtfStatuses>[1]) => Promise<readonly Pick<IndexDtfDiscoveryItem, "
|
|
85678
|
+
getStatuses: (params?: Parameters<typeof getIndexDtfStatuses>[1]) => Promise<readonly Pick<IndexDtfDiscoveryItem, "address" | "chainId" | "status">[]>;
|
|
85678
85679
|
getExposure: (params: Parameters<typeof getIndexDtfExposure>[1]) => Promise<readonly IndexDtfExposureGroup[]>;
|
|
85679
85680
|
getHolders: (params: Parameters<typeof getIndexDtfHolders>[1]) => Promise<IndexDtfHolders>;
|
|
85680
85681
|
getTransactions: (params: Parameters<typeof getIndexDtfTransactions>[1]) => Promise<readonly IndexDtfTransaction[]>;
|
package/dist/index.mjs
CHANGED
|
@@ -22916,24 +22916,33 @@ function buildProposalContractMap({ chainId, dtf, proposalGovernance }) {
|
|
|
22916
22916
|
addContract(contracts, proposalGovernance.address, getGovernanceContractName(proposalGovernance.timelock.type), dtfIndexGovernanceProposalAbi);
|
|
22917
22917
|
addContract(contracts, proposalGovernance.timelock.address, getTimelockContractName(proposalGovernance.timelock.type), timelockAbi);
|
|
22918
22918
|
}
|
|
22919
|
-
for (const extraContract of EXTRA_PROPOSAL_CONTRACTS) addContract(contracts, extraContract.addresses[chainId], extraContract.contract, extraContract.abi);
|
|
22919
|
+
for (const extraContract of EXTRA_PROPOSAL_CONTRACTS) addContract(contracts, extraContract.addresses[chainId], extraContract.contract, extraContract.abi, true);
|
|
22920
22920
|
return contracts;
|
|
22921
22921
|
}
|
|
22922
22922
|
function getContractAliases(contractMap) {
|
|
22923
22923
|
const aliases = {};
|
|
22924
|
-
for (const
|
|
22924
|
+
for (const entry of contractMap.values()) {
|
|
22925
|
+
const contract = getContractDecoders$1(entry)[0];
|
|
22926
|
+
if (!contract) continue;
|
|
22927
|
+
aliases[contract.target] = contract.contract;
|
|
22928
|
+
}
|
|
22925
22929
|
return aliases;
|
|
22926
22930
|
}
|
|
22927
|
-
function addContract(contracts, target, contract, abi) {
|
|
22931
|
+
function addContract(contracts, target, contract, abi, prefer = false) {
|
|
22928
22932
|
if (!target) return;
|
|
22929
22933
|
const address = getAddress(target);
|
|
22930
22934
|
const key = address.toLowerCase();
|
|
22931
|
-
|
|
22932
|
-
contracts.set(key, {
|
|
22935
|
+
const decoder = {
|
|
22933
22936
|
target: address,
|
|
22934
22937
|
contract,
|
|
22935
22938
|
abi
|
|
22936
|
-
}
|
|
22939
|
+
};
|
|
22940
|
+
const existing = getContractDecoders$1(contracts.get(key));
|
|
22941
|
+
contracts.set(key, existing ? prefer ? [decoder, ...existing] : [...existing, decoder] : [decoder]);
|
|
22942
|
+
}
|
|
22943
|
+
function getContractDecoders$1(entry) {
|
|
22944
|
+
if (!entry) return [];
|
|
22945
|
+
return "abi" in entry ? [entry] : entry;
|
|
22937
22946
|
}
|
|
22938
22947
|
function getGovernanceContractName(type) {
|
|
22939
22948
|
if (type === "OWNER") return "Owner Governance";
|
|
@@ -22967,8 +22976,8 @@ function decodeIndexDtfProposalCalldatas({ targets, calldatas, contractMap }) {
|
|
|
22967
22976
|
const callData = calldatas[i];
|
|
22968
22977
|
const targetAddress = getAddress(target);
|
|
22969
22978
|
const targetKey = targetAddress.toLowerCase();
|
|
22970
|
-
const
|
|
22971
|
-
if (
|
|
22979
|
+
const contractDecoders = getContractDecoders(contractMap.get(targetKey));
|
|
22980
|
+
if (contractDecoders.length === 0) {
|
|
22972
22981
|
const fallbackDecoded = decodeFallbackProposalCalldata(i, targetAddress, callData);
|
|
22973
22982
|
if (fallbackDecoded) {
|
|
22974
22983
|
calls.push(fallbackDecoded);
|
|
@@ -22985,7 +22994,7 @@ function decodeIndexDtfProposalCalldatas({ targets, calldatas, contractMap }) {
|
|
|
22985
22994
|
pushUnknownContractGroup(unknownContracts, unknownGroupMap, unknownCall);
|
|
22986
22995
|
continue;
|
|
22987
22996
|
}
|
|
22988
|
-
const decoded = decodeProposalCalldata(
|
|
22997
|
+
const decoded = decodeProposalCalldata(contractDecoders, i, targetAddress, callData);
|
|
22989
22998
|
if (decoded) {
|
|
22990
22999
|
calls.push(decoded);
|
|
22991
23000
|
pushDecodedContractGroup(dataByContract, dataGroupMap, decoded);
|
|
@@ -22993,7 +23002,7 @@ function decodeIndexDtfProposalCalldatas({ targets, calldatas, contractMap }) {
|
|
|
22993
23002
|
const unknownCall = {
|
|
22994
23003
|
index: i,
|
|
22995
23004
|
target: targetAddress,
|
|
22996
|
-
contract:
|
|
23005
|
+
contract: contractDecoders[0].contract,
|
|
22997
23006
|
callData
|
|
22998
23007
|
};
|
|
22999
23008
|
unknownCalls.push(unknownCall);
|
|
@@ -23043,28 +23052,42 @@ async function getExternalAbiContractMap(explorer, chainId, unknownCalls, contra
|
|
|
23043
23052
|
const externalContractMap = new Map(contractMap);
|
|
23044
23053
|
for (const { target, metadata } of withMetadata) {
|
|
23045
23054
|
const key = target.toLowerCase();
|
|
23046
|
-
const existing = externalContractMap.get(key);
|
|
23047
|
-
|
|
23055
|
+
const existing = getContractDecoders(externalContractMap.get(key));
|
|
23056
|
+
if (existing.length > 0) {
|
|
23057
|
+
const [primary, ...rest] = existing;
|
|
23058
|
+
externalContractMap.set(key, [{
|
|
23059
|
+
...primary,
|
|
23060
|
+
abi: [...primary.abi, ...metadata.abi]
|
|
23061
|
+
}, ...rest]);
|
|
23062
|
+
continue;
|
|
23063
|
+
}
|
|
23064
|
+
externalContractMap.set(key, [{
|
|
23048
23065
|
target,
|
|
23049
|
-
contract:
|
|
23050
|
-
abi:
|
|
23051
|
-
});
|
|
23066
|
+
contract: metadata.contractName,
|
|
23067
|
+
abi: metadata.abi
|
|
23068
|
+
}]);
|
|
23052
23069
|
}
|
|
23053
23070
|
return externalContractMap;
|
|
23054
23071
|
}
|
|
23055
|
-
function decodeProposalCalldata(
|
|
23056
|
-
const
|
|
23057
|
-
|
|
23058
|
-
|
|
23059
|
-
|
|
23060
|
-
|
|
23061
|
-
|
|
23062
|
-
|
|
23063
|
-
|
|
23064
|
-
|
|
23065
|
-
|
|
23066
|
-
|
|
23067
|
-
|
|
23072
|
+
function decodeProposalCalldata(contractDecoders, index, target, callData) {
|
|
23073
|
+
for (const contractDecoder of contractDecoders) {
|
|
23074
|
+
const decoded = tryDecodeCalldata(contractDecoder.abi, callData);
|
|
23075
|
+
if (!decoded) continue;
|
|
23076
|
+
return {
|
|
23077
|
+
index,
|
|
23078
|
+
target,
|
|
23079
|
+
contract: contractDecoder.contract,
|
|
23080
|
+
functionName: decoded.functionName,
|
|
23081
|
+
signature: decoded.signature,
|
|
23082
|
+
parameters: decoded.parameters,
|
|
23083
|
+
params: decoded.params,
|
|
23084
|
+
callData
|
|
23085
|
+
};
|
|
23086
|
+
}
|
|
23087
|
+
}
|
|
23088
|
+
function getContractDecoders(entry) {
|
|
23089
|
+
if (!entry) return [];
|
|
23090
|
+
return "abi" in entry ? [entry] : entry;
|
|
23068
23091
|
}
|
|
23069
23092
|
function tryDecodeCalldata(abi, callData) {
|
|
23070
23093
|
try {
|
|
@@ -23091,10 +23114,10 @@ function tryDecodeCalldata(abi, callData) {
|
|
|
23091
23114
|
}
|
|
23092
23115
|
function decodeFallbackProposalCalldata(index, target, callData) {
|
|
23093
23116
|
for (const fallbackDecoder of FALLBACK_DECODERS) {
|
|
23094
|
-
const decoded = decodeProposalCalldata({
|
|
23117
|
+
const decoded = decodeProposalCalldata([{
|
|
23095
23118
|
...fallbackDecoder,
|
|
23096
23119
|
target
|
|
23097
|
-
}, index, target, callData);
|
|
23120
|
+
}], index, target, callData);
|
|
23098
23121
|
if (decoded) return decoded;
|
|
23099
23122
|
}
|
|
23100
23123
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reserve-protocol/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Core TypeScript SDK for DTF interface integrations.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dtf",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"graphql-request": "^7.4.0",
|
|
41
41
|
"viem": "^2.48.8",
|
|
42
42
|
"zod": "^4.4.2",
|
|
43
|
-
"@reserve-protocol/dtf-catalog": "0.0.
|
|
43
|
+
"@reserve-protocol/dtf-catalog": "0.0.2"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@graphql-codegen/cli": "^6.3.1",
|