Skip to content

Conversation

@marchsu
Copy link
Contributor

@marchsu marchsu commented Aug 19, 2024

What changed? Why?

  • fix the parameters sequence to align with what api.ts has
    networkId, assetId, addressId

  • modify toString() of StakingBalance to be more readable

Tests

Result

StakingBalance { date: '2024-08-14T00:00:00.000Z' address: '0x80000001677f23a227dfed6f61b132d114be83b8ad0aa5f3c5d1d77e6ee0bf5f73b0af750cc34e8f2dae73c21dc36f4a' bondedStake: '32 ETH' unbondedBalance: '5.566622738 ETH' participantType: 'VALIDATOR' }
StakingBalance { date: '2024-08-13T00:00:00.000Z' address: '0x80000001677f23a227dfed6f61b132d114be83b8ad0aa5f3c5d1d77e6ee0bf5f73b0af750cc34e8f2dae73c21dc36f4a' bondedStake: '32 ETH' unbondedBalance: '5.564549466 ETH' participantType: 'VALIDATOR' }
StakingBalance { date: '2024-08-12T00:00:00.000Z' address: '0x80000001677f23a227dfed6f61b132d114be83b8ad0aa5f3c5d1d77e6ee0bf5f73b0af750cc34e8f2dae73c21dc36f4a' bondedStake: '32 ETH' unbondedBalance: '5.562466119 ETH' participantType: 'VALIDATOR' }
StakingBalance { date: '2024-08-11T00:00:00.000Z' address: '0x80000001677f23a227dfed6f61b132d114be83b8ad0aa5f3c5d1d77e6ee0bf5f73b0af750cc34e8f2dae73c21dc36f4a' bondedStake: '32 ETH' unbondedBalance: '5.560385432 ETH' participantType: 'VALIDATOR' }
StakingBalance { date: '2024-08-10T00:00:00.000Z' address: '0x80000001677f23a227dfed6f61b132d114be83b8ad0aa5f3c5d1d77e6ee0bf5f73b0af750cc34e8f2dae73c21dc36f4a' bondedStake: '32 ETH' unbondedBalance: '5.558446722 ETH' participantType: 'VALIDATOR' }
StakingBalance { date: '2024-08-09T00:00:00.000Z' address: '0x80000001677f23a227dfed6f61b132d114be83b8ad0aa5f3c5d1d77e6ee0bf5f73b0af750cc34e8f2dae73c21dc36f4a' bondedStake: '32 ETH' unbondedBalance: '5.556376299 ETH' participantType: 'VALIDATOR' }

Static Method

async function main() {
    let now = new Date();
    let tenDaysAgo = new Date();
    tenDaysAgo.setDate(now.getDate() - 10);
    const coinbase = Coinbase.configureFromJson({ filePath: "", basePath: "" });
    
    let stakingBalances = await StakingBalance.list(
        "ethereum-mainnet", "eth",
        "0x80000001677f23a227dfed6f61b132d114be83b8ad0aa5f3c5d1d77e6ee0bf5f73b0af750cc34e8f2dae73c21dc36f4a",
        tenDaysAgo.toISOString(), now.toISOString(),
    );
    
    // Loop through the historical staking balances and print each balance
    stakingBalances.forEach(stakingBalance => console.log(stakingBalance));
}


main();

External Address Class

const coinbase = Coinbase.configureFromJson({ filePath: "", basePath: "" });

const addr = new ExternalAddress(Coinbase.networks.EthereumMainnet, "0x80000001677f23a227dfed6f61b132d114be83b8ad0aa5f3c5d1d77e6ee0bf5f73b0af750cc34e8f2dae73c21dc36f4a") 
addr.historicalStakingBalances(Coinbase.assets.Eth, "2024-07-01T00:00:00Z", "2024-07-05T00:00:00Z").then(balances => { balances.forEach(balance => {console.log(balance)}); } ).catch(error => { console.log(error); });

Qualified Impact

@cb-heimdall
Copy link

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

@marchsu marchsu changed the base branch from master to v0.1.0 August 19, 2024 19:27
@marchsu marchsu marked this pull request as ready for review August 19, 2024 19:28
@marchsu marchsu marked this pull request as draft August 19, 2024 19:31
@marchsu marchsu force-pushed the fix-list-staking-balances branch from 388c9c0 to e29b053 Compare August 19, 2024 19:38
@marchsu marchsu marked this pull request as ready for review August 19, 2024 20:42
address,
networkId,
assetId,
address,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change these to be addressId?

address: string,
addressId: string,
startTime: string,
endTime: string,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this take an object v.s. parameters?

6 parameters is quite a big to have contextual ordering for

Copy link
Contributor

@alex-stone alex-stone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks good, as we go to 0.1.0 would be nice to update the initial request to take an object to be more usable .

@marchsu marchsu merged commit 8312dab into v0.1.0 Aug 20, 2024
@alex-stone alex-stone deleted the fix-list-staking-balances branch August 22, 2024 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants