Skip to content

Commit

Permalink
chore: update viewer contracts deploy script and add ui data fetching…
Browse files Browse the repository at this point in the history
… script for claimable NXM
  • Loading branch information
mixplore committed Nov 12, 2024
1 parent 05526e3 commit eb3d23e
Show file tree
Hide file tree
Showing 2 changed files with 141 additions and 1 deletion.
5 changes: 4 additions & 1 deletion scripts/deploy/assessment-and-nexus-viewer-deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const { ethers, network } = require('hardhat');

const STV = '0xcafea5E8a7a54dd14Bb225b66C7a016dfd7F236b'; // StakingViewer
const MS = '0x01BFd82675DBCc7762C84019cA518e701C0cD07e'; // NXMaster
const NXM = '0xd7c49CEE7E9188cCa6AD8FF264C1DA2e69D4Cf3B'; // NXMToken

const main = async () => {
console.log(`Starting deploy script on ${network.name} network`);
Expand All @@ -13,13 +14,15 @@ const main = async () => {
const assessmentViewerImplementation = await ethers.deployContract('AssessmentViewer', [MS], signer);
const nexusViewerImplementation = await ethers.deployContract(
'NexusViewer',
[MS, STV, assessmentViewerImplementation.address],
[MS, STV, assessmentViewerImplementation.address, NXM],
signer,
);

console.log('AssessmentViewer implementation address:', assessmentViewerImplementation.address);
console.log('NexusViewer implementation address:', nexusViewerImplementation.address);
console.log('NexusViewer ABI', nexusViewerImplementation.interface.format(ethers.utils.FormatTypes.json));

console.log('Done');
};
main()
.then(() => process.exit(0))
Expand Down
137 changes: 137 additions & 0 deletions scripts/ui-data-fetching/get-claimable-nxm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
require('dotenv').config();
const { ethers } = require('hardhat');

const NexusViewerABI = [
{
type: 'constructor',
payable: false,
inputs: [
{ type: 'address', name: '_master' },
{ type: 'address', name: '_stakingViewer' },
{ type: 'address', name: '_assessmentViewer' },
{ type: 'address', name: '_nxm' },
],
},
{ type: 'error', name: 'RevertedWithoutReason', inputs: [{ type: 'uint256', name: 'index' }] },
{
type: 'function',
name: 'assessmentViewer',
constant: true,
stateMutability: 'view',
payable: false,
gas: 11000000,
inputs: [],
outputs: [{ type: 'address' }],
},
{
type: 'function',
name: 'getClaimableNXM',
constant: true,
stateMutability: 'view',
payable: false,
gas: 11000000,
inputs: [
{ type: 'address', name: 'member' },
{ type: 'uint256[]', name: 'tokenIds' },
],
outputs: [
{
type: 'tuple',
components: [
{ type: 'uint256', name: 'governanceRewards' },
{ type: 'uint256', name: 'assessmentRewards' },
{ type: 'uint256', name: 'assessmentStake' },
{ type: 'uint256', name: 'stakingPoolTotalRewards' },
{ type: 'uint256', name: 'stakingPoolTotalExpiredStake' },
{ type: 'uint256', name: 'stakingPoolManagerIsNXMLockedForMV' },
{ type: 'uint256', name: 'managerTotalRewards' },
{ type: 'uint256', name: 'legacyPooledStakeRewards' },
{ type: 'uint256', name: 'legacyPooledStakeDeposits' },
{ type: 'uint256', name: 'legacyClaimAssessmentTokens' },
{ type: 'uint256', name: 'legacyCoverNoteDeposits' },
],
},
],
},
{
type: 'function',
name: 'getStakedNXM',
constant: true,
stateMutability: 'view',
payable: false,
gas: 11000000,
inputs: [
{ type: 'address', name: 'member' },
{ type: 'uint256[]', name: 'tokenIds' },
],
outputs: [
{
type: 'tuple',
components: [
{ type: 'uint256', name: 'stakingPoolTotalActiveStake' },
{ type: 'uint256', name: 'assessmentStake' },
{ type: 'uint256', name: 'assessmentStakeLockupExpiry' },
{ type: 'uint256', name: 'assessmentRewards' },
],
},
],
},
{
type: 'function',
name: 'master',
constant: true,
stateMutability: 'view',
payable: false,
gas: 11000000,
inputs: [],
outputs: [{ type: 'address' }],
},
{
type: 'function',
name: 'multicall',
constant: false,
payable: false,
gas: 11000000,
inputs: [{ type: 'bytes[]', name: 'data' }],
outputs: [{ type: 'bytes[]', name: 'results' }],
},
{
type: 'function',
name: 'nxm',
constant: true,
stateMutability: 'view',
payable: false,
gas: 11000000,
inputs: [],
outputs: [{ type: 'address' }],
},
{
type: 'function',
name: 'stakingViewer',
constant: true,
stateMutability: 'view',
payable: false,
gas: 11000000,
inputs: [],
outputs: [{ type: 'address' }],
},
];
const NexusViewerAddress = '0xF62eEc897fa5ef36a957702AA4a45B58fE8Fe312';

const member = '0xd6CE9335f5A68e885271CdbE460b7A4FED5FeDA9';
const tokenIds = [34, 35, 36, 103, 136];

async function main() {
const viewer = await ethers.getContractAt(NexusViewerABI, NexusViewerAddress);

const claimableNXM = await viewer.getClaimableNXM(member, tokenIds);

console.log('Claimable NXM:', claimableNXM);
}

main()
.then(() => process.exit(0))
.catch(error => {
console.error(error);
process.exit(1);
});

0 comments on commit eb3d23e

Please sign in to comment.