@net-protocol/score 0.1.3 → 0.1.4
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 +180 -4
- package/dist/index.d.ts +180 -4
- package/dist/index.js +750 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +742 -3
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +56 -3
- package/dist/react.d.ts +56 -3
- package/dist/react.js +596 -0
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +593 -3
- package/dist/react.mjs.map +1 -1
- package/dist/{scoreKeyUtils-DgHOtf44.d.mts → scoreKeyUtils-DuH70ypB.d.mts} +30 -1
- package/dist/{scoreKeyUtils-DgHOtf44.d.ts → scoreKeyUtils-DuH70ypB.d.ts} +30 -1
- package/package.json +6 -2
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readContract } from 'viem/actions';
|
|
2
|
-
import { getPublicClient } from '@net-protocol/core';
|
|
3
|
-
import { decodeAbiParameters, keccak256, encodePacked, getAddress, encodeAbiParameters } from 'viem';
|
|
2
|
+
import { getPublicClient, getBaseDataSuffix } from '@net-protocol/core';
|
|
3
|
+
import { decodeAbiParameters, keccak256, encodePacked, getAddress, encodeAbiParameters, isAddressEqual } from 'viem';
|
|
4
4
|
import { getStorageKeyBytes } from '@net-protocol/storage';
|
|
5
5
|
|
|
6
6
|
// src/client/ScoreClient.ts
|
|
@@ -1932,6 +1932,467 @@ var multi_version_uniswap_pool_info_retriever_default = [
|
|
|
1932
1932
|
}
|
|
1933
1933
|
];
|
|
1934
1934
|
|
|
1935
|
+
// src/abis/user-upvote.json
|
|
1936
|
+
var user_upvote_default = [
|
|
1937
|
+
{
|
|
1938
|
+
type: "constructor",
|
|
1939
|
+
inputs: [
|
|
1940
|
+
{ name: "_alphaToken", type: "address", internalType: "address" },
|
|
1941
|
+
{ name: "_erc20TokenGatedChat", type: "address", internalType: "address" },
|
|
1942
|
+
{ name: "_net", type: "address", internalType: "address" },
|
|
1943
|
+
{ name: "_swapRouter", type: "address", internalType: "address" },
|
|
1944
|
+
{ name: "_weth", type: "address", internalType: "address" },
|
|
1945
|
+
{ name: "_upvotePrice", type: "uint256", internalType: "uint256" },
|
|
1946
|
+
{ name: "_feeBps", type: "uint256", internalType: "uint256" }
|
|
1947
|
+
],
|
|
1948
|
+
stateMutability: "nonpayable"
|
|
1949
|
+
},
|
|
1950
|
+
{
|
|
1951
|
+
type: "function",
|
|
1952
|
+
name: "ALPHA_TOKEN",
|
|
1953
|
+
inputs: [],
|
|
1954
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
1955
|
+
stateMutability: "view"
|
|
1956
|
+
},
|
|
1957
|
+
{
|
|
1958
|
+
type: "function",
|
|
1959
|
+
name: "ERC20_TOKEN_GATED_CHAT",
|
|
1960
|
+
inputs: [],
|
|
1961
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
1962
|
+
stateMutability: "view"
|
|
1963
|
+
},
|
|
1964
|
+
{
|
|
1965
|
+
type: "function",
|
|
1966
|
+
name: "ETH_USDC_POOL",
|
|
1967
|
+
inputs: [],
|
|
1968
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
1969
|
+
stateMutability: "view"
|
|
1970
|
+
},
|
|
1971
|
+
{
|
|
1972
|
+
type: "function",
|
|
1973
|
+
name: "MAX_TOKENS_PER_USER",
|
|
1974
|
+
inputs: [],
|
|
1975
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
1976
|
+
stateMutability: "view"
|
|
1977
|
+
},
|
|
1978
|
+
{
|
|
1979
|
+
type: "function",
|
|
1980
|
+
name: "NET",
|
|
1981
|
+
inputs: [],
|
|
1982
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
1983
|
+
stateMutability: "view"
|
|
1984
|
+
},
|
|
1985
|
+
{
|
|
1986
|
+
type: "function",
|
|
1987
|
+
name: "SWAP_ROUTER",
|
|
1988
|
+
inputs: [],
|
|
1989
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
1990
|
+
stateMutability: "view"
|
|
1991
|
+
},
|
|
1992
|
+
{
|
|
1993
|
+
type: "function",
|
|
1994
|
+
name: "UNISWAP_V3_FACTORY",
|
|
1995
|
+
inputs: [],
|
|
1996
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
1997
|
+
stateMutability: "view"
|
|
1998
|
+
},
|
|
1999
|
+
{
|
|
2000
|
+
type: "function",
|
|
2001
|
+
name: "WETH",
|
|
2002
|
+
inputs: [],
|
|
2003
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
2004
|
+
stateMutability: "view"
|
|
2005
|
+
},
|
|
2006
|
+
{
|
|
2007
|
+
type: "function",
|
|
2008
|
+
name: "addTokenToList",
|
|
2009
|
+
inputs: [
|
|
2010
|
+
{ name: "token", type: "address", internalType: "address" },
|
|
2011
|
+
{ name: "feeTier", type: "uint24", internalType: "uint24" }
|
|
2012
|
+
],
|
|
2013
|
+
outputs: [],
|
|
2014
|
+
stateMutability: "nonpayable"
|
|
2015
|
+
},
|
|
2016
|
+
{
|
|
2017
|
+
type: "function",
|
|
2018
|
+
name: "feeBps",
|
|
2019
|
+
inputs: [],
|
|
2020
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
2021
|
+
stateMutability: "view"
|
|
2022
|
+
},
|
|
2023
|
+
{
|
|
2024
|
+
type: "function",
|
|
2025
|
+
name: "getTokenFeeTier",
|
|
2026
|
+
inputs: [
|
|
2027
|
+
{ name: "user", type: "address", internalType: "address" },
|
|
2028
|
+
{ name: "token", type: "address", internalType: "address" }
|
|
2029
|
+
],
|
|
2030
|
+
outputs: [{ name: "", type: "uint24", internalType: "uint24" }],
|
|
2031
|
+
stateMutability: "view"
|
|
2032
|
+
},
|
|
2033
|
+
{
|
|
2034
|
+
type: "function",
|
|
2035
|
+
name: "getTotalUpvotesPerToken",
|
|
2036
|
+
inputs: [
|
|
2037
|
+
{ name: "token", type: "address", internalType: "address" }
|
|
2038
|
+
],
|
|
2039
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
2040
|
+
stateMutability: "view"
|
|
2041
|
+
},
|
|
2042
|
+
{
|
|
2043
|
+
type: "function",
|
|
2044
|
+
name: "getUserTokenCount",
|
|
2045
|
+
inputs: [
|
|
2046
|
+
{ name: "user", type: "address", internalType: "address" }
|
|
2047
|
+
],
|
|
2048
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
2049
|
+
stateMutability: "view"
|
|
2050
|
+
},
|
|
2051
|
+
{
|
|
2052
|
+
type: "function",
|
|
2053
|
+
name: "getUserTokensInRange",
|
|
2054
|
+
inputs: [
|
|
2055
|
+
{ name: "user", type: "address", internalType: "address" },
|
|
2056
|
+
{ name: "startIndex", type: "uint256", internalType: "uint256" },
|
|
2057
|
+
{ name: "endIndex", type: "uint256", internalType: "uint256" }
|
|
2058
|
+
],
|
|
2059
|
+
outputs: [
|
|
2060
|
+
{
|
|
2061
|
+
name: "",
|
|
2062
|
+
type: "tuple[]",
|
|
2063
|
+
internalType: "struct UserUpvoteContract.TokenInfo[]",
|
|
2064
|
+
components: [
|
|
2065
|
+
{ name: "token", type: "address", internalType: "address" },
|
|
2066
|
+
{ name: "feeTier", type: "uint24", internalType: "uint24" }
|
|
2067
|
+
]
|
|
2068
|
+
}
|
|
2069
|
+
],
|
|
2070
|
+
stateMutability: "view"
|
|
2071
|
+
},
|
|
2072
|
+
{
|
|
2073
|
+
type: "function",
|
|
2074
|
+
name: "getUserUpvotesGiven",
|
|
2075
|
+
inputs: [
|
|
2076
|
+
{ name: "user", type: "address", internalType: "address" }
|
|
2077
|
+
],
|
|
2078
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
2079
|
+
stateMutability: "view"
|
|
2080
|
+
},
|
|
2081
|
+
{
|
|
2082
|
+
type: "function",
|
|
2083
|
+
name: "getUserUpvotesGivenPerToken",
|
|
2084
|
+
inputs: [
|
|
2085
|
+
{ name: "user", type: "address", internalType: "address" },
|
|
2086
|
+
{ name: "token", type: "address", internalType: "address" }
|
|
2087
|
+
],
|
|
2088
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
2089
|
+
stateMutability: "view"
|
|
2090
|
+
},
|
|
2091
|
+
{
|
|
2092
|
+
type: "function",
|
|
2093
|
+
name: "getUserUpvotesGivenPerTokenBatch",
|
|
2094
|
+
inputs: [
|
|
2095
|
+
{ name: "user", type: "address", internalType: "address" },
|
|
2096
|
+
{ name: "tokens", type: "address[]", internalType: "address[]" }
|
|
2097
|
+
],
|
|
2098
|
+
outputs: [
|
|
2099
|
+
{ name: "", type: "uint256[]", internalType: "uint256[]" }
|
|
2100
|
+
],
|
|
2101
|
+
stateMutability: "view"
|
|
2102
|
+
},
|
|
2103
|
+
{
|
|
2104
|
+
type: "function",
|
|
2105
|
+
name: "getUserUpvotesReceived",
|
|
2106
|
+
inputs: [
|
|
2107
|
+
{ name: "user", type: "address", internalType: "address" }
|
|
2108
|
+
],
|
|
2109
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
2110
|
+
stateMutability: "view"
|
|
2111
|
+
},
|
|
2112
|
+
{
|
|
2113
|
+
type: "function",
|
|
2114
|
+
name: "getUserUpvotesReceivedPerToken",
|
|
2115
|
+
inputs: [
|
|
2116
|
+
{ name: "user", type: "address", internalType: "address" },
|
|
2117
|
+
{ name: "token", type: "address", internalType: "address" }
|
|
2118
|
+
],
|
|
2119
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
2120
|
+
stateMutability: "view"
|
|
2121
|
+
},
|
|
2122
|
+
{
|
|
2123
|
+
type: "function",
|
|
2124
|
+
name: "getUserUpvotesReceivedPerTokenBatch",
|
|
2125
|
+
inputs: [
|
|
2126
|
+
{ name: "user", type: "address", internalType: "address" },
|
|
2127
|
+
{ name: "tokens", type: "address[]", internalType: "address[]" }
|
|
2128
|
+
],
|
|
2129
|
+
outputs: [
|
|
2130
|
+
{ name: "", type: "uint256[]", internalType: "uint256[]" }
|
|
2131
|
+
],
|
|
2132
|
+
stateMutability: "view"
|
|
2133
|
+
},
|
|
2134
|
+
{
|
|
2135
|
+
type: "function",
|
|
2136
|
+
name: "isTokenInUserList",
|
|
2137
|
+
inputs: [
|
|
2138
|
+
{ name: "user", type: "address", internalType: "address" },
|
|
2139
|
+
{ name: "token", type: "address", internalType: "address" }
|
|
2140
|
+
],
|
|
2141
|
+
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
|
2142
|
+
stateMutability: "view"
|
|
2143
|
+
},
|
|
2144
|
+
{
|
|
2145
|
+
type: "function",
|
|
2146
|
+
name: "owner",
|
|
2147
|
+
inputs: [],
|
|
2148
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
2149
|
+
stateMutability: "view"
|
|
2150
|
+
},
|
|
2151
|
+
{
|
|
2152
|
+
type: "function",
|
|
2153
|
+
name: "removeTokenFromList",
|
|
2154
|
+
inputs: [
|
|
2155
|
+
{ name: "token", type: "address", internalType: "address" }
|
|
2156
|
+
],
|
|
2157
|
+
outputs: [],
|
|
2158
|
+
stateMutability: "nonpayable"
|
|
2159
|
+
},
|
|
2160
|
+
{
|
|
2161
|
+
type: "function",
|
|
2162
|
+
name: "renounceOwnership",
|
|
2163
|
+
inputs: [],
|
|
2164
|
+
outputs: [],
|
|
2165
|
+
stateMutability: "nonpayable"
|
|
2166
|
+
},
|
|
2167
|
+
{
|
|
2168
|
+
type: "function",
|
|
2169
|
+
name: "setFeeBps",
|
|
2170
|
+
inputs: [
|
|
2171
|
+
{ name: "newFeeBps", type: "uint256", internalType: "uint256" }
|
|
2172
|
+
],
|
|
2173
|
+
outputs: [],
|
|
2174
|
+
stateMutability: "nonpayable"
|
|
2175
|
+
},
|
|
2176
|
+
{
|
|
2177
|
+
type: "function",
|
|
2178
|
+
name: "setUpvotePrice",
|
|
2179
|
+
inputs: [
|
|
2180
|
+
{ name: "newUpvotePrice", type: "uint256", internalType: "uint256" }
|
|
2181
|
+
],
|
|
2182
|
+
outputs: [],
|
|
2183
|
+
stateMutability: "nonpayable"
|
|
2184
|
+
},
|
|
2185
|
+
{
|
|
2186
|
+
type: "function",
|
|
2187
|
+
name: "totalUpvotesPerToken",
|
|
2188
|
+
inputs: [{ name: "", type: "address", internalType: "address" }],
|
|
2189
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
2190
|
+
stateMutability: "view"
|
|
2191
|
+
},
|
|
2192
|
+
{
|
|
2193
|
+
type: "function",
|
|
2194
|
+
name: "transferOwnership",
|
|
2195
|
+
inputs: [
|
|
2196
|
+
{ name: "newOwner", type: "address", internalType: "address" }
|
|
2197
|
+
],
|
|
2198
|
+
outputs: [],
|
|
2199
|
+
stateMutability: "nonpayable"
|
|
2200
|
+
},
|
|
2201
|
+
{
|
|
2202
|
+
type: "function",
|
|
2203
|
+
name: "upvotePrice",
|
|
2204
|
+
inputs: [],
|
|
2205
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
2206
|
+
stateMutability: "view"
|
|
2207
|
+
},
|
|
2208
|
+
{
|
|
2209
|
+
type: "function",
|
|
2210
|
+
name: "upvoteUser",
|
|
2211
|
+
inputs: [
|
|
2212
|
+
{ name: "userToUpvote", type: "address", internalType: "address" },
|
|
2213
|
+
{ name: "token", type: "address", internalType: "address" },
|
|
2214
|
+
{ name: "numUpvotes", type: "uint256", internalType: "uint256" },
|
|
2215
|
+
{ name: "feeTier", type: "uint24", internalType: "uint24" }
|
|
2216
|
+
],
|
|
2217
|
+
outputs: [],
|
|
2218
|
+
stateMutability: "payable"
|
|
2219
|
+
},
|
|
2220
|
+
{
|
|
2221
|
+
type: "function",
|
|
2222
|
+
name: "userTokenCount",
|
|
2223
|
+
inputs: [{ name: "", type: "address", internalType: "address" }],
|
|
2224
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
2225
|
+
stateMutability: "view"
|
|
2226
|
+
},
|
|
2227
|
+
{
|
|
2228
|
+
type: "function",
|
|
2229
|
+
name: "userTokenExists",
|
|
2230
|
+
inputs: [
|
|
2231
|
+
{ name: "", type: "address", internalType: "address" },
|
|
2232
|
+
{ name: "", type: "address", internalType: "address" }
|
|
2233
|
+
],
|
|
2234
|
+
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
|
2235
|
+
stateMutability: "view"
|
|
2236
|
+
},
|
|
2237
|
+
{
|
|
2238
|
+
type: "function",
|
|
2239
|
+
name: "userTokenFeeTiers",
|
|
2240
|
+
inputs: [
|
|
2241
|
+
{ name: "", type: "address", internalType: "address" },
|
|
2242
|
+
{ name: "", type: "address", internalType: "address" }
|
|
2243
|
+
],
|
|
2244
|
+
outputs: [{ name: "", type: "uint24", internalType: "uint24" }],
|
|
2245
|
+
stateMutability: "view"
|
|
2246
|
+
},
|
|
2247
|
+
{
|
|
2248
|
+
type: "function",
|
|
2249
|
+
name: "userTokenSeen",
|
|
2250
|
+
inputs: [
|
|
2251
|
+
{ name: "", type: "address", internalType: "address" },
|
|
2252
|
+
{ name: "", type: "address", internalType: "address" }
|
|
2253
|
+
],
|
|
2254
|
+
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
|
2255
|
+
stateMutability: "view"
|
|
2256
|
+
},
|
|
2257
|
+
{
|
|
2258
|
+
type: "function",
|
|
2259
|
+
name: "userTokens",
|
|
2260
|
+
inputs: [
|
|
2261
|
+
{ name: "", type: "address", internalType: "address" },
|
|
2262
|
+
{ name: "", type: "uint256", internalType: "uint256" }
|
|
2263
|
+
],
|
|
2264
|
+
outputs: [
|
|
2265
|
+
{ name: "token", type: "address", internalType: "address" },
|
|
2266
|
+
{ name: "feeTier", type: "uint24", internalType: "uint24" }
|
|
2267
|
+
],
|
|
2268
|
+
stateMutability: "view"
|
|
2269
|
+
},
|
|
2270
|
+
{
|
|
2271
|
+
type: "function",
|
|
2272
|
+
name: "userUpvotesGiven",
|
|
2273
|
+
inputs: [{ name: "", type: "address", internalType: "address" }],
|
|
2274
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
2275
|
+
stateMutability: "view"
|
|
2276
|
+
},
|
|
2277
|
+
{
|
|
2278
|
+
type: "function",
|
|
2279
|
+
name: "userUpvotesGivenPerToken",
|
|
2280
|
+
inputs: [
|
|
2281
|
+
{ name: "", type: "address", internalType: "address" },
|
|
2282
|
+
{ name: "", type: "address", internalType: "address" }
|
|
2283
|
+
],
|
|
2284
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
2285
|
+
stateMutability: "view"
|
|
2286
|
+
},
|
|
2287
|
+
{
|
|
2288
|
+
type: "function",
|
|
2289
|
+
name: "userUpvotesReceived",
|
|
2290
|
+
inputs: [{ name: "", type: "address", internalType: "address" }],
|
|
2291
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
2292
|
+
stateMutability: "view"
|
|
2293
|
+
},
|
|
2294
|
+
{
|
|
2295
|
+
type: "function",
|
|
2296
|
+
name: "userUpvotesReceivedPerToken",
|
|
2297
|
+
inputs: [
|
|
2298
|
+
{ name: "", type: "address", internalType: "address" },
|
|
2299
|
+
{ name: "", type: "address", internalType: "address" }
|
|
2300
|
+
],
|
|
2301
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
2302
|
+
stateMutability: "view"
|
|
2303
|
+
},
|
|
2304
|
+
{
|
|
2305
|
+
type: "function",
|
|
2306
|
+
name: "withdrawErc20",
|
|
2307
|
+
inputs: [
|
|
2308
|
+
{ name: "to", type: "address", internalType: "address" },
|
|
2309
|
+
{ name: "token", type: "address", internalType: "address" }
|
|
2310
|
+
],
|
|
2311
|
+
outputs: [],
|
|
2312
|
+
stateMutability: "nonpayable"
|
|
2313
|
+
},
|
|
2314
|
+
{
|
|
2315
|
+
type: "event",
|
|
2316
|
+
name: "OwnershipTransferred",
|
|
2317
|
+
inputs: [
|
|
2318
|
+
{ name: "previousOwner", type: "address", indexed: true, internalType: "address" },
|
|
2319
|
+
{ name: "newOwner", type: "address", indexed: true, internalType: "address" }
|
|
2320
|
+
],
|
|
2321
|
+
anonymous: false
|
|
2322
|
+
},
|
|
2323
|
+
{
|
|
2324
|
+
type: "event",
|
|
2325
|
+
name: "TokenAddedToList",
|
|
2326
|
+
inputs: [
|
|
2327
|
+
{ name: "user", type: "address", indexed: true, internalType: "address" },
|
|
2328
|
+
{ name: "token", type: "address", indexed: true, internalType: "address" },
|
|
2329
|
+
{ name: "feeTier", type: "uint24", indexed: false, internalType: "uint24" }
|
|
2330
|
+
],
|
|
2331
|
+
anonymous: false
|
|
2332
|
+
},
|
|
2333
|
+
{
|
|
2334
|
+
type: "event",
|
|
2335
|
+
name: "TokenRemovedFromList",
|
|
2336
|
+
inputs: [
|
|
2337
|
+
{ name: "user", type: "address", indexed: true, internalType: "address" },
|
|
2338
|
+
{ name: "token", type: "address", indexed: true, internalType: "address" }
|
|
2339
|
+
],
|
|
2340
|
+
anonymous: false
|
|
2341
|
+
},
|
|
2342
|
+
{
|
|
2343
|
+
type: "event",
|
|
2344
|
+
name: "UserUpvoted",
|
|
2345
|
+
inputs: [
|
|
2346
|
+
{ name: "upvoter", type: "address", indexed: true, internalType: "address" },
|
|
2347
|
+
{ name: "upvotedUser", type: "address", indexed: true, internalType: "address" },
|
|
2348
|
+
{ name: "token", type: "address", indexed: true, internalType: "address" },
|
|
2349
|
+
{ name: "numUpvotes", type: "uint256", indexed: false, internalType: "uint256" }
|
|
2350
|
+
],
|
|
2351
|
+
anonymous: false
|
|
2352
|
+
},
|
|
2353
|
+
{ type: "error", name: "IncorrectEthSent", inputs: [] },
|
|
2354
|
+
{ type: "error", name: "MaxTokensReached", inputs: [] },
|
|
2355
|
+
{ type: "error", name: "NoAlphaToWithdraw", inputs: [] },
|
|
2356
|
+
{
|
|
2357
|
+
type: "error",
|
|
2358
|
+
name: "OwnableInvalidOwner",
|
|
2359
|
+
inputs: [{ name: "owner", type: "address", internalType: "address" }]
|
|
2360
|
+
},
|
|
2361
|
+
{
|
|
2362
|
+
type: "error",
|
|
2363
|
+
name: "OwnableUnauthorizedAccount",
|
|
2364
|
+
inputs: [{ name: "account", type: "address", internalType: "address" }]
|
|
2365
|
+
},
|
|
2366
|
+
{
|
|
2367
|
+
type: "error",
|
|
2368
|
+
name: "PoolNotFound",
|
|
2369
|
+
inputs: [
|
|
2370
|
+
{ name: "tokenA", type: "address", internalType: "address" },
|
|
2371
|
+
{ name: "tokenB", type: "address", internalType: "address" },
|
|
2372
|
+
{ name: "feeTier", type: "uint24", internalType: "uint24" }
|
|
2373
|
+
]
|
|
2374
|
+
},
|
|
2375
|
+
{ type: "error", name: "ReentrancyGuardReentrantCall", inputs: [] },
|
|
2376
|
+
{
|
|
2377
|
+
type: "error",
|
|
2378
|
+
name: "Slot0ReadFailed",
|
|
2379
|
+
inputs: [{ name: "pool", type: "address", internalType: "address" }]
|
|
2380
|
+
},
|
|
2381
|
+
{
|
|
2382
|
+
type: "error",
|
|
2383
|
+
name: "StringsInsufficientHexLength",
|
|
2384
|
+
inputs: [
|
|
2385
|
+
{ name: "value", type: "uint256", internalType: "uint256" },
|
|
2386
|
+
{ name: "length", type: "uint256", internalType: "uint256" }
|
|
2387
|
+
]
|
|
2388
|
+
},
|
|
2389
|
+
{ type: "error", name: "TokenAlreadyInList", inputs: [] },
|
|
2390
|
+
{ type: "error", name: "TokenNotInUserList", inputs: [] },
|
|
2391
|
+
{ type: "error", name: "UserCannotUpvoteSelf", inputs: [] },
|
|
2392
|
+
{ type: "error", name: "WithdrawFailed", inputs: [] },
|
|
2393
|
+
{ type: "error", name: "ZeroUpvotes", inputs: [] }
|
|
2394
|
+
];
|
|
2395
|
+
|
|
1935
2396
|
// src/constants.ts
|
|
1936
2397
|
var SCORE_CONTRACT = {
|
|
1937
2398
|
address: "0x0000000fa09b022e5616e5a173b4b67fa2fbcf28",
|
|
@@ -1988,6 +2449,10 @@ function getWethAddress(chainId) {
|
|
|
1988
2449
|
}
|
|
1989
2450
|
var NULL_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
1990
2451
|
var UPVOTE_PRICE_ETH = 25e-6;
|
|
2452
|
+
var USER_UPVOTE_CONTRACT = {
|
|
2453
|
+
address: "0xa4bc2c63dd0157692fd5f409389e5032e37d8895",
|
|
2454
|
+
abi: user_upvote_default
|
|
2455
|
+
};
|
|
1991
2456
|
var encodeUpvoteKey = (tokenAddress) => {
|
|
1992
2457
|
return `0x${BigInt(`0x${tokenAddress.slice(2)}`).toString(16).padStart(64, "0")}`;
|
|
1993
2458
|
};
|
|
@@ -2379,6 +2844,280 @@ var ScoreClient = class {
|
|
|
2379
2844
|
return [];
|
|
2380
2845
|
}
|
|
2381
2846
|
};
|
|
2847
|
+
function parseUserUpvoteMessage(message, topic) {
|
|
2848
|
+
try {
|
|
2849
|
+
if (topic.startsWith("ub-")) {
|
|
2850
|
+
const [
|
|
2851
|
+
upvotedUserString,
|
|
2852
|
+
actualToken,
|
|
2853
|
+
numUpvotes,
|
|
2854
|
+
tokenWethPrice,
|
|
2855
|
+
wethUsdcPrice,
|
|
2856
|
+
alphaWethPrice,
|
|
2857
|
+
userTokenBalance
|
|
2858
|
+
] = decodeAbiParameters(
|
|
2859
|
+
[
|
|
2860
|
+
{ type: "string" },
|
|
2861
|
+
{ type: "address" },
|
|
2862
|
+
{ type: "uint256" },
|
|
2863
|
+
{ type: "uint256" },
|
|
2864
|
+
{ type: "uint256" },
|
|
2865
|
+
{ type: "uint256" },
|
|
2866
|
+
{ type: "uint256" }
|
|
2867
|
+
],
|
|
2868
|
+
message.data
|
|
2869
|
+
);
|
|
2870
|
+
return {
|
|
2871
|
+
upvotedUserString,
|
|
2872
|
+
actualToken,
|
|
2873
|
+
numUpvotes: Number(numUpvotes),
|
|
2874
|
+
tokenWethPrice,
|
|
2875
|
+
wethUsdcPrice,
|
|
2876
|
+
alphaWethPrice,
|
|
2877
|
+
userTokenBalance
|
|
2878
|
+
};
|
|
2879
|
+
} else {
|
|
2880
|
+
const [
|
|
2881
|
+
upvotedUserString,
|
|
2882
|
+
actualToken,
|
|
2883
|
+
numUpvotes,
|
|
2884
|
+
tokenWethPrice,
|
|
2885
|
+
wethUsdcPrice,
|
|
2886
|
+
alphaWethPrice
|
|
2887
|
+
] = decodeAbiParameters(
|
|
2888
|
+
[
|
|
2889
|
+
{ type: "string" },
|
|
2890
|
+
{ type: "address" },
|
|
2891
|
+
{ type: "uint256" },
|
|
2892
|
+
{ type: "uint256" },
|
|
2893
|
+
{ type: "uint256" },
|
|
2894
|
+
{ type: "uint256" }
|
|
2895
|
+
],
|
|
2896
|
+
message.data
|
|
2897
|
+
);
|
|
2898
|
+
return {
|
|
2899
|
+
upvotedUserString,
|
|
2900
|
+
actualToken,
|
|
2901
|
+
numUpvotes: Number(numUpvotes),
|
|
2902
|
+
tokenWethPrice,
|
|
2903
|
+
wethUsdcPrice,
|
|
2904
|
+
alphaWethPrice
|
|
2905
|
+
};
|
|
2906
|
+
}
|
|
2907
|
+
} catch {
|
|
2908
|
+
return null;
|
|
2909
|
+
}
|
|
2910
|
+
}
|
|
2911
|
+
function extractTokenAddressesFromMessages(messages, topic) {
|
|
2912
|
+
const tokenSet = /* @__PURE__ */ new Set();
|
|
2913
|
+
const validMessages = [];
|
|
2914
|
+
for (const message of messages) {
|
|
2915
|
+
const parsed = parseUserUpvoteMessage(message, topic);
|
|
2916
|
+
if (parsed) {
|
|
2917
|
+
tokenSet.add(parsed.actualToken.toLowerCase());
|
|
2918
|
+
validMessages.push(parsed);
|
|
2919
|
+
}
|
|
2920
|
+
}
|
|
2921
|
+
return {
|
|
2922
|
+
tokenAddresses: Array.from(tokenSet),
|
|
2923
|
+
validMessages
|
|
2924
|
+
};
|
|
2925
|
+
}
|
|
2926
|
+
function validateUserUpvoteMessage(message, topic) {
|
|
2927
|
+
return parseUserUpvoteMessage(message, topic) !== null;
|
|
2928
|
+
}
|
|
2929
|
+
function calculatePriceInUsdc(parsedMessage, tokenDecimals = 18) {
|
|
2930
|
+
const { tokenWethPrice, wethUsdcPrice } = parsedMessage;
|
|
2931
|
+
if (tokenWethPrice > 0n && wethUsdcPrice > 0n) {
|
|
2932
|
+
const scale = 10 ** (36 - tokenDecimals);
|
|
2933
|
+
const tokenWethPriceNum = Number(tokenWethPrice) / scale;
|
|
2934
|
+
const wethUsdcPriceNum = Number(wethUsdcPrice) / 1e6;
|
|
2935
|
+
return tokenWethPriceNum * wethUsdcPriceNum;
|
|
2936
|
+
}
|
|
2937
|
+
return void 0;
|
|
2938
|
+
}
|
|
2939
|
+
function calculateUserTokenBalance(rawBalance, tokenDecimals = 18) {
|
|
2940
|
+
return Number(rawBalance) / Math.pow(10, tokenDecimals);
|
|
2941
|
+
}
|
|
2942
|
+
function validateUpvoteParams(params) {
|
|
2943
|
+
if (isAddressEqual(params.sender, params.userToUpvote)) {
|
|
2944
|
+
return { valid: false, error: "Cannot upvote yourself" };
|
|
2945
|
+
}
|
|
2946
|
+
if (!Number.isInteger(params.numUpvotes)) {
|
|
2947
|
+
return { valid: false, error: "Number of upvotes must be a whole number" };
|
|
2948
|
+
}
|
|
2949
|
+
if (params.numUpvotes <= 0) {
|
|
2950
|
+
return { valid: false, error: "Number of upvotes must be greater than zero" };
|
|
2951
|
+
}
|
|
2952
|
+
return { valid: true };
|
|
2953
|
+
}
|
|
2954
|
+
function calculateUpvoteCost(numUpvotes, upvotePrice) {
|
|
2955
|
+
return BigInt(numUpvotes) * upvotePrice;
|
|
2956
|
+
}
|
|
2957
|
+
function computeEnrichedFields(parsed, tokenInfo) {
|
|
2958
|
+
const decimals = tokenInfo?.decimals ?? 18;
|
|
2959
|
+
const priceInUsdc = calculatePriceInUsdc(parsed, decimals);
|
|
2960
|
+
const userTokenBalance = parsed.userTokenBalance ? calculateUserTokenBalance(parsed.userTokenBalance, decimals) : 0;
|
|
2961
|
+
const userTokenBalanceUsdValue = priceInUsdc !== void 0 && userTokenBalance > 0 ? priceInUsdc * userTokenBalance : void 0;
|
|
2962
|
+
return { priceInUsdc, userTokenBalance, userTokenBalanceUsdValue };
|
|
2963
|
+
}
|
|
2964
|
+
function buildUserUpvote(parsed, timestamp, tokenInfo) {
|
|
2965
|
+
return {
|
|
2966
|
+
tokenAddress: parsed.actualToken,
|
|
2967
|
+
numUpvotes: parsed.numUpvotes,
|
|
2968
|
+
timestamp,
|
|
2969
|
+
...computeEnrichedFields(parsed, tokenInfo),
|
|
2970
|
+
upvotedUserAddress: parsed.upvotedUserString,
|
|
2971
|
+
tokenInfo
|
|
2972
|
+
};
|
|
2973
|
+
}
|
|
2974
|
+
function buildUserUpvoteReceived(parsed, upvoterAddress, timestamp, tokenInfo) {
|
|
2975
|
+
return {
|
|
2976
|
+
upvoterAddress,
|
|
2977
|
+
tokenAddress: parsed.actualToken,
|
|
2978
|
+
numUpvotes: parsed.numUpvotes,
|
|
2979
|
+
timestamp,
|
|
2980
|
+
...computeEnrichedFields(parsed, tokenInfo),
|
|
2981
|
+
tokenInfo
|
|
2982
|
+
};
|
|
2983
|
+
}
|
|
2984
|
+
|
|
2985
|
+
// src/user-upvote/UserUpvoteClient.ts
|
|
2986
|
+
var UserUpvoteClient = class {
|
|
2987
|
+
constructor(params) {
|
|
2988
|
+
this.chainId = params.chainId;
|
|
2989
|
+
this.client = getPublicClient({
|
|
2990
|
+
chainId: params.chainId,
|
|
2991
|
+
rpcUrl: params.overrides?.rpcUrls
|
|
2992
|
+
});
|
|
2993
|
+
this.contractAddress = params.overrides?.contractAddress ?? USER_UPVOTE_CONTRACT.address;
|
|
2994
|
+
}
|
|
2995
|
+
async getUserUpvotesGiven({ user }) {
|
|
2996
|
+
const data = await readContract(this.client, {
|
|
2997
|
+
address: this.contractAddress,
|
|
2998
|
+
abi: USER_UPVOTE_CONTRACT.abi,
|
|
2999
|
+
functionName: "getUserUpvotesGiven",
|
|
3000
|
+
args: [user]
|
|
3001
|
+
});
|
|
3002
|
+
return data;
|
|
3003
|
+
}
|
|
3004
|
+
async getUserUpvotesReceived({ user }) {
|
|
3005
|
+
const data = await readContract(this.client, {
|
|
3006
|
+
address: this.contractAddress,
|
|
3007
|
+
abi: USER_UPVOTE_CONTRACT.abi,
|
|
3008
|
+
functionName: "getUserUpvotesReceived",
|
|
3009
|
+
args: [user]
|
|
3010
|
+
});
|
|
3011
|
+
return data;
|
|
3012
|
+
}
|
|
3013
|
+
async getUserUpvotesGivenPerTokenBatch({
|
|
3014
|
+
user,
|
|
3015
|
+
tokens
|
|
3016
|
+
}) {
|
|
3017
|
+
const data = await readContract(this.client, {
|
|
3018
|
+
address: this.contractAddress,
|
|
3019
|
+
abi: USER_UPVOTE_CONTRACT.abi,
|
|
3020
|
+
functionName: "getUserUpvotesGivenPerTokenBatch",
|
|
3021
|
+
args: [user, tokens]
|
|
3022
|
+
});
|
|
3023
|
+
return data;
|
|
3024
|
+
}
|
|
3025
|
+
async getUserUpvotesReceivedPerTokenBatch({
|
|
3026
|
+
user,
|
|
3027
|
+
tokens
|
|
3028
|
+
}) {
|
|
3029
|
+
const data = await readContract(this.client, {
|
|
3030
|
+
address: this.contractAddress,
|
|
3031
|
+
abi: USER_UPVOTE_CONTRACT.abi,
|
|
3032
|
+
functionName: "getUserUpvotesReceivedPerTokenBatch",
|
|
3033
|
+
args: [user, tokens]
|
|
3034
|
+
});
|
|
3035
|
+
return data;
|
|
3036
|
+
}
|
|
3037
|
+
async getTotalUpvotesPerToken({
|
|
3038
|
+
token
|
|
3039
|
+
}) {
|
|
3040
|
+
const data = await readContract(this.client, {
|
|
3041
|
+
address: this.contractAddress,
|
|
3042
|
+
abi: USER_UPVOTE_CONTRACT.abi,
|
|
3043
|
+
functionName: "getTotalUpvotesPerToken",
|
|
3044
|
+
args: [token]
|
|
3045
|
+
});
|
|
3046
|
+
return data;
|
|
3047
|
+
}
|
|
3048
|
+
async getUserTokensInRange({
|
|
3049
|
+
user,
|
|
3050
|
+
startIndex,
|
|
3051
|
+
endIndex
|
|
3052
|
+
}) {
|
|
3053
|
+
const data = await readContract(this.client, {
|
|
3054
|
+
address: this.contractAddress,
|
|
3055
|
+
abi: USER_UPVOTE_CONTRACT.abi,
|
|
3056
|
+
functionName: "getUserTokensInRange",
|
|
3057
|
+
args: [user, BigInt(startIndex), BigInt(endIndex)]
|
|
3058
|
+
});
|
|
3059
|
+
return data.map((item) => ({
|
|
3060
|
+
token: item.token,
|
|
3061
|
+
feeTier: Number(item.feeTier)
|
|
3062
|
+
}));
|
|
3063
|
+
}
|
|
3064
|
+
async getUserTokenCount({ user }) {
|
|
3065
|
+
const data = await readContract(this.client, {
|
|
3066
|
+
address: this.contractAddress,
|
|
3067
|
+
abi: USER_UPVOTE_CONTRACT.abi,
|
|
3068
|
+
functionName: "getUserTokenCount",
|
|
3069
|
+
args: [user]
|
|
3070
|
+
});
|
|
3071
|
+
return Number(data);
|
|
3072
|
+
}
|
|
3073
|
+
async isTokenInUserList({
|
|
3074
|
+
user,
|
|
3075
|
+
token
|
|
3076
|
+
}) {
|
|
3077
|
+
const data = await readContract(this.client, {
|
|
3078
|
+
address: this.contractAddress,
|
|
3079
|
+
abi: USER_UPVOTE_CONTRACT.abi,
|
|
3080
|
+
functionName: "isTokenInUserList",
|
|
3081
|
+
args: [user, token]
|
|
3082
|
+
});
|
|
3083
|
+
return data;
|
|
3084
|
+
}
|
|
3085
|
+
async getUpvotePrice() {
|
|
3086
|
+
const data = await readContract(this.client, {
|
|
3087
|
+
address: this.contractAddress,
|
|
3088
|
+
abi: USER_UPVOTE_CONTRACT.abi,
|
|
3089
|
+
functionName: "upvotePrice"
|
|
3090
|
+
});
|
|
3091
|
+
return data;
|
|
3092
|
+
}
|
|
3093
|
+
async upvoteUser({
|
|
3094
|
+
walletClient,
|
|
3095
|
+
userToUpvote,
|
|
3096
|
+
token = NULL_ADDRESS,
|
|
3097
|
+
numUpvotes,
|
|
3098
|
+
feeTier = 0,
|
|
3099
|
+
value: providedValue
|
|
3100
|
+
}) {
|
|
3101
|
+
const sender = walletClient.account?.address;
|
|
3102
|
+
if (sender) {
|
|
3103
|
+
const validation = validateUpvoteParams({ sender, userToUpvote, numUpvotes });
|
|
3104
|
+
if (!validation.valid) {
|
|
3105
|
+
throw new Error(validation.error);
|
|
3106
|
+
}
|
|
3107
|
+
}
|
|
3108
|
+
const value = providedValue ?? calculateUpvoteCost(numUpvotes, await this.getUpvotePrice());
|
|
3109
|
+
const hash = await walletClient.writeContract({
|
|
3110
|
+
address: this.contractAddress,
|
|
3111
|
+
abi: USER_UPVOTE_CONTRACT.abi,
|
|
3112
|
+
functionName: "upvoteUser",
|
|
3113
|
+
args: [userToUpvote, token, BigInt(numUpvotes), BigInt(feeTier)],
|
|
3114
|
+
value,
|
|
3115
|
+
chain: null,
|
|
3116
|
+
dataSuffix: getBaseDataSuffix(this.chainId)
|
|
3117
|
+
});
|
|
3118
|
+
return hash;
|
|
3119
|
+
}
|
|
3120
|
+
};
|
|
2382
3121
|
var encodePoolKey = (poolKey) => {
|
|
2383
3122
|
if (!poolKey || !isValidPoolKey2(poolKey)) {
|
|
2384
3123
|
return "0x";
|
|
@@ -2792,6 +3531,6 @@ async function discoverTokenPool({
|
|
|
2792
3531
|
return results[0] ?? null;
|
|
2793
3532
|
}
|
|
2794
3533
|
|
|
2795
|
-
export { ALL_STRATEGY_ADDRESSES, DYNAMIC_SPLIT_STRATEGY, LEGACY_UPVOTE_V1_ADDRESS, LEGACY_UPVOTE_V2_ADDRESS, MULTI_VERSION_UNISWAP_BULK_POOL_FINDER, MULTI_VERSION_UNISWAP_POOL_INFO_RETRIEVER, NULL_ADDRESS, PURE_ALPHA_STRATEGY, SCORE_CONTRACT, SUPPORTED_SCORE_CHAINS, ScoreClient, UNIV234_POOLS_STRATEGY, UPVOTE_APP, UPVOTE_PRICE_ETH, UPVOTE_STORAGE_APP, calculatePriceFromSqrtPriceX96, decodeStrategyMetadata, decodeUpvoteMessage, decodeUpvoteStorageBlob, discoverPools, discoverTokenPool, encodePoolKey, encodeUpvoteKey, extractStrategyAddress, extractTokenAddressFromScoreKey, getFeedContentKey, getScoreKey, getStorageScoreKey, getStorageUpvoteContext, getTokenScoreKey, getWethAddress, isDynamicSplitStrategy, isPureAlphaStrategy, isStrategyMessage, isTokenScoreKey, isUniv234PoolsStrategy, isUserUpvoteMessage, selectStrategy, tokenAddressToUpvoteKeyString };
|
|
3534
|
+
export { ALL_STRATEGY_ADDRESSES, DYNAMIC_SPLIT_STRATEGY, LEGACY_UPVOTE_V1_ADDRESS, LEGACY_UPVOTE_V2_ADDRESS, MULTI_VERSION_UNISWAP_BULK_POOL_FINDER, MULTI_VERSION_UNISWAP_POOL_INFO_RETRIEVER, NULL_ADDRESS, PURE_ALPHA_STRATEGY, SCORE_CONTRACT, SUPPORTED_SCORE_CHAINS, ScoreClient, UNIV234_POOLS_STRATEGY, UPVOTE_APP, UPVOTE_PRICE_ETH, UPVOTE_STORAGE_APP, USER_UPVOTE_CONTRACT, UserUpvoteClient, buildUserUpvote, buildUserUpvoteReceived, calculatePriceFromSqrtPriceX96, calculatePriceInUsdc, calculateUpvoteCost, calculateUserTokenBalance, decodeStrategyMetadata, decodeUpvoteMessage, decodeUpvoteStorageBlob, discoverPools, discoverTokenPool, encodePoolKey, encodeUpvoteKey, extractStrategyAddress, extractTokenAddressFromScoreKey, extractTokenAddressesFromMessages, getFeedContentKey, getScoreKey, getStorageScoreKey, getStorageUpvoteContext, getTokenScoreKey, getWethAddress, isDynamicSplitStrategy, isPureAlphaStrategy, isStrategyMessage, isTokenScoreKey, isUniv234PoolsStrategy, isUserUpvoteMessage, parseUserUpvoteMessage, selectStrategy, tokenAddressToUpvoteKeyString, validateUpvoteParams, validateUserUpvoteMessage };
|
|
2796
3535
|
//# sourceMappingURL=index.mjs.map
|
|
2797
3536
|
//# sourceMappingURL=index.mjs.map
|