Skip to content

Commit

Permalink
Add getAddress() method
Browse files Browse the repository at this point in the history
  • Loading branch information
platfowner committed Feb 23, 2024
1 parent c66214e commit 1f450f9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions __tests__/ain.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ describe('ain-js', function() {
});
});

describe('Provider', function() {
it('getAddress', async function() {
const address = await ain.provider.getAddress();
expect(address).not.toBeNull();
});
});

describe('Wallet', function() {
it('countDecimals', function() {
expect(Wallet.countDecimals(0)).toBe(0); // '0'
Expand Down
8 changes: 8 additions & 0 deletions src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ export default class Provider {
this.httpClient = axios.create(axiosConfig);
}

/**
* Fetches the blockchain node's address.
* @returns {Promise<number>} The address value.
*/
getAddress(): Promise<number> {
return this.send('ain_getAddress', {})
}

/**
* Creates a JSON-RPC payload and sends it to the network.
* @param {string} rpcMethod The JSON-RPC method.
Expand Down

0 comments on commit 1f450f9

Please sign in to comment.