File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed
Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change 4646 "mongodb-memory-server" : " ^9.1.4" ,
4747 "nodemon" : " ^3.1.0" ,
4848 "supertest" : " ^6.3.3"
49- }
49+ },
50+ "packageManager" : " pnpm@9.12.2+sha512.22721b3a11f81661ae1ec68ce1a7b879425a1ca5b991c975b074ac220b187ce56c708fe5db69f4c962c989452eee76c82877f4ee80f474cebd61ee13461b6228"
5051}
Original file line number Diff line number Diff line change @@ -77,6 +77,19 @@ const getUserBalanceAtLevel = async (
7777 return new BigNumber ( 0 ) ;
7878} ;
7979
80+ const getUserXTZBalanceAtLevelViaRpc = async ( network , level , userAddress ) => {
81+ const rpcUrl = rpcNodes [ network ] ;
82+ const url = `${ rpcUrl } /chains/main/blocks/${ level } /context/contracts/${ userAddress } /full_balance` ;
83+ console . log ( "url: " , url ) ;
84+ const response = await axios ( { url, method : "GET" } ) ;
85+
86+ if ( response . status === 200 ) {
87+ return new BigNumber ( response . data ) ;
88+ }
89+
90+ return new BigNumber ( 0 ) ;
91+ } ;
92+
8093const getUserXTZBalanceAtLevel = async ( network , level , userAddress ) => {
8194 const url = `https://api.${ network } .tzkt.io/v1/accounts/${ userAddress } /balance_history/${ level } ` ;
8295 const response = await axios ( { url, method : "GET" } ) ;
@@ -173,11 +186,18 @@ const getUserTotalVotingPowerAtReferenceBlock = async (
173186
174187 return userVotingPower ;
175188 } else {
176- const selfBalance = await getUserXTZBalanceAtLevel (
189+ const selfBalance = await getUserXTZBalanceAtLevelViaRpc (
190+ network ,
191+ level ,
192+ userAddress
193+ ) ;
194+ const selfBalanceLegacy = await getUserXTZBalanceAtLevel (
177195 network ,
178196 level ,
179197 userAddress
180198 ) ;
199+ console . log ( "selfBalance: " , selfBalance ) ;
200+ console . log ( "selfBalanceLegacy: " , selfBalanceLegacy ) ;
181201 return userVotingPower . plus ( selfBalance ) ;
182202 }
183203} ;
You can’t perform that action at this time.
0 commit comments