DeveryAdmined

DeveryAdmined

Main class to deal with contract administration related operations. You can use it to check the current admins and listen to admin related events.

Constructor

new DeveryAdmined(options)

Creates a new DeveryAdmined instance.

Usage example:

// creates a deveryAdminedClient with the default params
let deveryAdminedClient = new DeveryAdmined();

// creates a deveryAdminedClient pointing to a custom address
let deveryAdminedCustomAddress = new DeveryAdmined({address:'0xf17f52151EbEF6C7334FAD080c5704DAAA16b732'});

Parameters:
Name Type Description
options ClientOptions

network connection options

Version:
  • 2
Source:

Extends

Methods

(async) isAdmin(addr) → {Promise.<boolean>}

Checks if the given account is admin of the contract.

Usage example:

// first you need to get a DeveryAdmined instance
let deveryAdminedClient = new DeveryAdmined();
// now you can use it
deveryAdminedClient.isAdmin('0xf17f52151EbEF6C7334FAD080c5704DAAA16b732').then( (isAdmin) =>{
         if(isAdmin) {
             // continue your code here ...
         }
})

// if your function is async you can use the await syntax too

async function foo() {
     let deveryAdminedClient = new DeveryAdmined();
     let isAdmin = await deveryAdminedClient.isAdmin('0xf17f52151EbEF6C7334FAD080c5704DAAA16b732');
     if(isAdmin) {
         // continue your code here ...
     }
}

for more info about how to get a DeveryAdmined instance click here

Parameters:
Name Type Description
addr

target account address

Source:

(async) addAdmin(addr) → {Promise.<Transaction>}

Makes an account admin of the contract by adding it to the admin array.

One important point to observe is that unless you are the owner of the devery contract (what is a very unlikely condition) you will get an exception and lose you gas if you do a call to this function.

Usage example:

// first you need to get a DeveryAdmined instance
let deveryAdminedClient = new DeveryAdmined();
// now you can use it
deveryAdminedClient.addAdmin('0xf17f52151EbEF6C7334FAD080c5704DAAA16b732').then( (transaction) =>{
         // continue your code here ...
});

// if your function is async you can use the await syntax too

async function foo() {
     let deveryAdminedClient = new DeveryAdmined();
     let transaction = await deveryAdminedClient.addAdmin('0xf17f52151EbEF6C7334FAD080c5704DAAA16b732');
     // continue your code here ...

}

for more info about how to get a DeveryAdmined instance click here

Parameters:
Name Type Description
addr string

target account address

Source:

(async) removeAdmin(addr, overrideOptionsopt) → {Promise.<Transaction, Error>}

Removes admin role from a given account.

One important point to observe is that unless you are the owner of the devery contract (what is a very unlikely condition) you will get an exception and lose you gas if you do a call to this function.

Usage example:

// first you need to get a DeveryAdmined instance
let deveryAdminedClient = new DeveryAdmined();
// now you can use it
deveryAdminedClient.removeAdmin('0xf17f52151EbEF6C7334FAD080c5704DAAA16b732').then( (transaction) =>{
         // continue your code here ...
})

// if your function is async you can use the await syntax too

async function foo() {
     let deveryAdminedClient = new DeveryAdmined();
     let transaction = await deveryAdminedClient.removeAdmin('0xf17f52151EbEF6C7334FAD080c5704DAAA16b732');
     // continue your code here ...


}

for more info about how to get a DeveryAdmined instance click here

Parameters:
Name Type Attributes Description
addr string

target account address

overrideOptions TransactionOptions <optional>

transaction options like gas price for example

Source:

setAdminAddedEventListener(callback)

Listener to AdminAdded events, this event triggers whenever a new address is added as admin. Please note that the AdminAddedEventListeners do not stack, this means that whenever you set one you are removing the last one. If you want to remove an AdminAddedEventListener, just call this function passing undefined as param.

Usage example:

// first you need to get a DeveryAdmined instance
let deveryAdminedClient = new DeveryAdmined();

 // now you can use it
deveryAdminedClient.setAdminAddedEventListener((newAdminAddress) => {
     // whenever a new admin is added we will log it to the console
     console.log(newAdminAddress);
})

// if you want to remove the listener you can simply pass undefined as parameter
deveryAdminedClient.setAdminAddedEventListener(undefined)

// or that is equivalent to the above call
deveryAdminedClient.setAdminAddedEventListener()



for more info about how to get a DeveryAdmined instance click here

Parameters:
Name Type Description
callback adminEventCallback

the callback that will be executed whenever and AdminAdded event is triggered

Source:

setAdminRemovedEventListener(callback)

Listener to AdminRemoved events, this event triggers whenever an address is removed from the admin list. Please note that the AdminRemovedEventListeners do not stack, this means that whenever you set one you are removing the last one. If you want to remove an AdminRemovedEventListener, just call this function passing undefined as param.

Usage example:

// first you need to get a DeveryAdmined instance
let deveryAdminedClient = new DeveryAdmined();

 // now you can use it
deveryAdminedClient.setAdminRemovedEventListener((address) => {
     // whenever an admin is removed we will log it to the console
     console.log(address);
})

// if you want to remove the listener you can simply pass undefined as parameter
deveryAdminedClient.setAdminRemovedEventListener(undefined)

// or that is equivalent to the above call
deveryAdminedClient.setAdminRemovedEventListener()



for more info about how to get a DeveryAdmined instance click here

Parameters:
Name Type Description
callback adminEventCallback

the callback that will be executed whenever and AdminRemoved event is triggered

Source:

getSignerAddress() → {*}

You can use this method to check the current signer wallet address.

Overrides:
Source:

getProvider() → {*}

Returns the internal signer or provider, this method needs to be used with caution as it exposes internals. So unless you know what you are doing it's better to avoid using it.

Overrides:
Source: