Library-wide configuration.
- Source:
Members
(static) aliases
Aliases handlers & most known Stellar addresses. Aliases takes the form:
{
'publicKey1': 'name1',
'publicKey2': 'name2',
...
'publicKeyN': 'nameN'
}
Aliases are only used as a displaying sugar and can't be used as a replacement for federated address as it would lead to security issues.
(static) clickHandlers
The active click handlers. Takes the form:
cosmicLib.config.clickHandlers = {
type1: callback1,
...
typeN: callbackN
}
Thoses click handlers are set by default:
- address: A prompt that shows the address details
- id: A function that copy the id into the clipboard
- hash: A function that copy the hash into the clipboard or show a prompt for preimage signature when relevant
- Source:
(static) network
The default fallback network.
- Default Value:
- 'public'
- Source:
(static) page
The base URI to build cosmic links.
- Default Value:
- 'https://cosmic.link/'
- Source:
(static) source
The default fallback source address.
- Default Value:
- undefined
- Source:
Methods
(static) addAliases(aliases)
Add new aliases or replace existing ones.
Parameters:
Name | Type | Description |
---|---|---|
aliases |
Object
|
An object such as |
Example
cosmicLib.config.addAliases({
'GCKA6K5PCQ6PNF5RQBF7PQDJWRHO6UOGFMRLK3DYHDOI244V47XKQ4GP': 'smartlands.io',
'GBVOL67TMUQBGL4TZYNMY3ZQ5WGQYFPFD5VJRWXR72VA33VFNL225PL5': 'stellarport.io'
})
(static) clearClickHandler(type)
Remove the current click handler for type.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
type |
string
|
Type of a transaction/operation field such as
|
Example
cosmicLib.config.clearClickHandler('address')
(static) removeAliases(publicKeys)
Remove publicKeys from aliases list.
Parameters:
Name | Type | Description |
---|---|---|
publicKeys |
Array
|
An array of public keys |
Example
cosmicLib.config.removeAliases([
'GCKA6K5PCQ6PNF5RQBF7PQDJWRHO6UOGFMRLK3DYHDOI244V47XKQ4GP',
'GBVOL67TMUQBGL4TZYNMY3ZQ5WGQYFPFD5VJRWXR72VA33VFNL225PL5',
])
(static) setClickHandler(type, callback)
Set the click handler for type HTML elements as callback.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
type |
string
|
Type of a transaction/operation field such as
|
callback |
function
|
A function that accept one |
Example
cosmicLib.config.setClickHandler('address', showAddressPopup)
(static) setupNetwork(name, horizon, passphraseopt)
Set default passphrase and horizon URL for network name.
Adding custom network this way will enable the use of their name in cosmic
queries (as in &network=name
). However, please remind that this feature
will works only on your side and could break compatibility with other
services.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
string
|
Network name (like 'public', 'test') |
|
horizon |
string
|
Horizon URL |
|
passphrase |
string
|
<optional> |
Network passphrase |
Example
cosmicLib.config.setupNetwork('public', 'https://my-own-horizon-instance.example.org')
cosmicLib.config.setupNetwork('custom', 'https://custom-horizon.example.org', 'My Custom Passphrase')