Constructor
new FederationServer(serverURL, domain, optsopt)
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
serverURL |
string
|
The federation server URL (ex. |
|||||||||
domain |
string
|
Domain this server represents |
|||||||||
opts |
object
|
<optional> |
|
Methods
(static) createForDomain(domain, optsopt) → {Promise}
Creates a FederationServer instance based on information from digitalbits.toml file for a given domain.
Returns a Promise that resolves to a FederationServer object. If digitalbits.toml file does not exist for a given domain or it does not contain information about a federation server Promise will reject.
DigitalBitsSdk.FederationServer.createForDomain('acme.com')
.then(federationServer => {
// federationServer.forAddress('bob').then(...)
})
.catch(error => {
// digitalbits.toml does not exist or it does not contain information about federation server.
});
- Source:
- See:
Parameters:
| Name | Type | Attributes | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
domain |
string
|
Domain to get federation server for |
|||||||||
opts |
object
|
<optional> |
|
Returns:
- Type:
-
Promise
(static) resolve(value, optsopt) → {Promise}
This method is a helper method for handling user inputs that contain destination value.
It accepts two types of values:
- For DigitalBits address (ex.
tom*digitalbits.io) it splits DigitalBits address and then tries to find information about federation server indigitalbits.tomlfile for a given domain. It returns aPromisewhich resolves if federation server exists and user has been found and rejects in all other cases. - For Account ID (ex.
GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS) it returns aPromisewhich resolves if Account ID is valid and rejects in all other cases. Please note that this method does not check if the account actually exists in a ledger.
Example:
DigitalBitsSdk.FederationServer.resolve('tom*digitalbits.io')
.then(federationRecord => {
// {
// account_id: 'GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS',
// memo_type: 'id',
// memo: 100
// }
});It returns a Promise that will resolve to a JSON object with following fields:
account_id- Account ID of the destination,memo_type(optional) - Memo type that needs to be attached to a transaction,memo(optional) - Memo value that needs to be attached to a transaction.
The Promise will reject in case of any errors.
- Source:
- See:
Parameters:
| Name | Type | Attributes | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
value |
string
|
DigitalBits Address (ex. |
|||||||||
opts |
object
|
<optional> |
|
Returns:
- Type:
-
Promise
resolveAccountId(accountId) → {Promise}
Returns a Promise that resolves to federation record if the user was found for a given account ID.
- Source:
- See:
Parameters:
| Name | Type | Description |
|---|---|---|
accountId |
string
|
Account ID (ex. |
Returns:
- Type:
-
Promise
resolveAddress(address) → {Promise}
Returns a Promise that resolves to federation record if the user was found for a given DigitalBits address.
- Source:
- See:
Parameters:
| Name | Type | Description |
|---|---|---|
address |
string
|
DigitalBits address (ex. |
Returns:
- Type:
-
Promise
resolveTransactionId(transactionId) → {Promise}
Returns a Promise that resolves to federation record if the sender of the transaction was found for a given transaction ID.
- Source:
- See:
Parameters:
| Name | Type | Description |
|---|---|---|
transactionId |
string
|
Transaction ID (ex. |
Returns:
- Type:
-
Promise