1
0
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:
Bogdan Fazakas 2022-12-19 12:09:05 +02:00 committed by GitHub
parent d539e00072
commit cbc3cd6776
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 0 deletions

View File

@ -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>}

View File

@ -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)