Skip to content

Commit 8d200f8

Browse files
committed
refactor: use agora singleton with the bearerToken from login
1 parent 9d5c9d0 commit 8d200f8

File tree

4 files changed

+4
-9
lines changed

4 files changed

+4
-9
lines changed

packages/ethernaut-optigov/src/tasks/Delegates.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const types = require('ethernaut-common/src/validation/types')
22
const output = require('ethernaut-common/src/ui/output')
33
const Delegates = require('../internal/agora/Delegates')
4-
const Agora = require('../internal/agora/Agora')
4+
const agora = require('../internal/agora/agoraInstance')
55

66
const RELATED_DATA = {
77
votes: 'votes',
@@ -40,7 +40,6 @@ require('../scopes/optigov')
4040
)
4141
.setAction(async ({ limit, offset, address, relatedData }) => {
4242
try {
43-
const agora = new Agora()
4443
const delegates = new Delegates(agora)
4544

4645
if (address) {
@@ -78,7 +77,6 @@ require('../scopes/optigov')
7877

7978
// If no specific address or ENS is given, fetch the list of delegates
8079
const delegateList = await delegates.getDelegates({ limit, offset })
81-
8280
return output.resultBox(printDelegates(delegateList), 'Delegates')
8381
} catch (err) {
8482
return output.errorBox(err)

packages/ethernaut-optigov/src/tasks/Projects.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const types = require('ethernaut-common/src/validation/types')
22
const output = require('ethernaut-common/src/ui/output')
33
const Projects = require('../internal/agora/Projects')
44
const Rounds = require('../internal/agora/Rounds')
5-
const Agora = require('../internal/agora/Agora')
5+
const agora = require('../internal/agora/agoraInstance')
66

77
require('../scopes/optigov')
88
.task(
@@ -81,7 +81,6 @@ function printProjects(projects) {
8181
}
8282

8383
async function getProjects(limit, offset, round) {
84-
const agora = new Agora()
8584
const projects = new Projects(agora)
8685
const rounds = new Rounds(agora)
8786

packages/ethernaut-optigov/src/tasks/Proposals.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const types = require('ethernaut-common/src/validation/types')
22
const output = require('ethernaut-common/src/ui/output')
33
const Proposals = require('../internal/agora/Proposals')
4-
const Agora = require('../internal/agora/Agora')
4+
const agora = require('../internal/agora/agoraInstance')
55

66
const VOTES = {
77
yes: 'yes',
@@ -40,7 +40,6 @@ require('../scopes/optigov')
4040
.setAction(async ({ limit, offset, proposalId, votes }) => {
4141
try {
4242
// Instantiate Agora and Proposals
43-
const agora = new Agora()
4443
const proposals = new Proposals(agora)
4544

4645
// If proposalId is provided, fetch specific proposal or votes

packages/ethernaut-optigov/src/tasks/Rounds.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const types = require('ethernaut-common/src/validation/types')
22
const output = require('ethernaut-common/src/ui/output')
33
const Rounds = require('../internal/agora/Rounds')
4-
const Agora = require('../internal/agora/Agora')
4+
const agora = require('../internal/agora/agoraInstance')
55

66
const LATEST = {
77
yes: 'yes',
@@ -39,7 +39,6 @@ require('../scopes/optigov')
3939
)
4040
.setAction(async ({ limit, offset, roundId, latest }) => {
4141
try {
42-
const agora = new Agora()
4342
const rounds = new Rounds(agora)
4443

4544
if (latest === LATEST.yes) {

0 commit comments

Comments
 (0)