mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
Add missing symbol and name helper on datatoken (#1667)
* add two helpers method * fix tests * update comments
This commit is contained in:
parent
d539e00072
commit
cbc3cd6776
@ -788,6 +788,26 @@ export class Datatoken extends SmartContract {
|
||||
return decimals
|
||||
}
|
||||
|
||||
/** It returns the token symbol
|
||||
* @param {String} dtAddress Datatoken adress
|
||||
* @return {Promise<number>}
|
||||
*/
|
||||
public async getSymbol(dtAddress: string): Promise<string> {
|
||||
const dtContract = this.getContract(dtAddress)
|
||||
const symbol = await dtContract.methods.symbol().call()
|
||||
return symbol
|
||||
}
|
||||
|
||||
/** It returns the name of the token
|
||||
* @param {String} dtAddress Datatoken adress
|
||||
* @return {Promise<number>}
|
||||
*/
|
||||
public async getName(dtAddress: string): Promise<string> {
|
||||
const dtContract = this.getContract(dtAddress)
|
||||
const name = await dtContract.methods.name().call()
|
||||
return name
|
||||
}
|
||||
|
||||
/** It returns the token decimals, how many supported decimal points
|
||||
* @param {String} dtAddress Datatoken adress
|
||||
* @return {Promise<number>}
|
||||
|
@ -575,6 +575,16 @@ describe('Datatoken', () => {
|
||||
assert(decimals === '18')
|
||||
})
|
||||
|
||||
it('#getSymbol - should return the symbbol of the datatoken', async () => {
|
||||
const symbol = await datatoken.getSymbol(datatokenAddress)
|
||||
assert(symbol === 'ERC20DT1Symbol')
|
||||
})
|
||||
|
||||
it('#getName - should return the name of the datatoken', async () => {
|
||||
const name = await datatoken.getName(datatokenAddress)
|
||||
assert(name === 'ERC20B1')
|
||||
})
|
||||
|
||||
it('#transfer - we can transfer the datatoken', async () => {
|
||||
const balance1before = await datatoken.balance(datatokenAddress, user1)
|
||||
const balance2before = await datatoken.balance(datatokenAddress, user2)
|
||||
|
Loading…
x
Reference in New Issue
Block a user