1.1.0 • Published 3 years ago
ibc-domains-sdk v1.1.0
IBC Domains SDK
- Convert address
- Resolve IBC Domain to addresses
- Resolve IBC Domain details
- Resolve address into primary IBC Domain
Example usage
import {
convertAddress,
resolveDomainDetails,
resolveDomainIntoAddresses,
resolvePrimaryDomainByAddress,
resolveDomainIntoChainAddress
} from "ibc-domains-sdk";
const result = convertAddress("cosmos1elwrkcazwacy3gyj6jg2g4yp243zkzs62mpsd7", "osmo");
if (result.isOk()) {
console.log(result.value);
} else {
console.log("error:", result.error);
}
resolveDomainIntoAddresses("jacky").then(result => {
if (result.isOk()) {
console.log("f", result.value)
} else {
console.log("error:", result.error);
}
});
resolveDomainIntoChainAddress("jacky.cosmos", "kujira").then(result => {
if (result.isOk()) {
console.log(result.value)
} else {
console.log("error:", result.error);
}
});
resolvePrimaryDomainByAddress("osmo1elwrkcazwacy3gyj6jg2g4yp243zkzs6zqjqmv").then(result => {
if (result.isOk()) {
console.log(result.value)
} else {
console.log("error:", result.error);
}
});
resolveDomainDetails("jacky").then(result => {
if (result.isOk()) {
console.log(result.value)
} else {
console.log("error:", result.error);
}
});Convert Cosmos address
Example
import {
convertAddress
} from "ibc-domains-sdk";
const result = convertAddress("cosmos1elwrkcazwacy3gyj6jg2g4yp243zkzs62mpsd7", "osmo");
if (result.isOk()) {
console.log(result.value);
} else {
console.log("error:", result.error);
}API
convertAddress
Input
- Valid bech32 address, for instance "cosmos1elwrkcazwacy3gyj6jg2g4yp243zkzs62mpsd7"
- Bech32 prefix of the destination chain, for instance "kujira" or "osmo"
Output
| Property | Type | Explanation |
|---|---|---|
| value | String or null | Converted address or null if conversion failed |
| error | null or String | String explaining why conversion failed or null if conversion was successful |
| isOk | function | Helper function that can be called to see if resolution was successful |
Relevant bech32 prefixes
| bech32 prefixes | ||||
|---|---|---|---|---|
| agoric | chihuahua | gravity | lum | sent |
| akash | comdex | iaa | micro | sif |
| axelar | cosmos | inj | osmo | somm |
| bcna | cro | ixo | panacea | star |
| bitsong | desmos | juno | persistence | stars |
| bostrom | dig | ki | regen | terra |
| certik | emoney | kujira | rebus | umee |
| cheqd | evmos | like | secret | vdl |
Resolve domain
Example
import {
resolveDomainIntoAddresses,
resolveDomainIntoChainAddress
} from "ibc-domains-sdk";
resolveDomainIntoAddresses("jacky.cosmos").then(result => {
if (result.isOk()) {
console.log(result.value)
} else {
console.log("error:", result.error);
}
});
resolveDomainIntoChainAddress("jacky.cosmos", "kujira").then(result => {
if (result.isOk()) {
console.log(result.value)
} else {
console.log("error:", result.error);
}
});API
resolveDomainIntoAddresses
Input
- IBC domain, with or without .cosmos extension, for instance "jacky.cosmos"
Output
| Property | Type | Explanation |
|---|---|---|
| value | String [] or null | Array of associated addresses or null if resolution failed / no association was found |
| error | null or String | String explaining why resolution failed or null if resolution was successful |
| isOk | function | Helper function that can be called to see if resolution was successful |
import {
resolveDomainIntoAddresses
} from "ibc-domains-sdk";
resolveDomainIntoAddresses("jacky.cosmos").then(result => {
if (result.isOk()) {
console.log(result.value)
} else {
console.log("error:", result.error);
}
});resolveDomainIntoChainAddress
Input
- IBC domain, with or without .cosmos extension, for instance "jacky.cosmos"
- bech32 prefix of the destination chain, for instance "kujira" or "osmo"
Output
| Property | Type | Explanation |
|---|---|---|
| value | String or null | Associated addresses on the specified chain or null if resolution failed / no association was found |
| error | null or String | String explaining why resolution failed or null if resolution was successful |
| isOk | function | Helper function that can be called to see if resolution was successful |
import {
resolveDomainIntoChainAddress
} from "ibc-domains-sdk";
resolveDomainIntoChainAddress("jacky.cosmos", "kujira").then(result => {
if (result.isOk()) {
console.log(result.value)
} else {
console.log("error:", result.error);
}
});Resolve address into primary domain
Example
import {
resolvePrimaryDomainByAddress
} from "ibc-domains-sdk";
resolvePrimaryDomainByAddress("osmo1elwrkcazwacy3gyj6jg2g4yp243zkzs6zqjqmv").then(result => {
if (result.isOk()) {
console.log(result.value)
} else {
console.log("error:", result.error);
}
});API
resolvePrimaryDomainByAddress
Input
- Cosmos address, for instance "osmo1elwrkcazwacy3gyj6jg2g4yp243zkzs6zqjqmv"
Output
| Property | Type | Explanation |
|---|---|---|
| value | { domain: String, domain_full: String } or null | Array of associated addresses or null if resolution failed / no association was found |
| error | null or String | String explaining why resolution failed or null if resolution was successful |
| isOk | function | Helper function that can be called to see if resolution was successful |
Resolve IBC domain details
Example
import {
resolveDomainDetails
} from "ibc-domains-sdk";
resolveDomainDetails("jacky").then(result => {
if (result.isOk()) {
console.log(result.value)
} else {
console.log("error:", result.error);
}
});API
resolveDomainDetails
Input
- IBC domain, with or without .cosmos extension, for instance "jacky.cosmos"
Output
| Property | Type | Explanation |
|---|---|---|
| value | Metadata or null | Metadata or null if resolution failed / no association was found |
| error | null or String | String explaining why resolution failed or null if resolution was successful |
| isOk | function | Helper function that can be called to see if resolution was successful |
Where Metadata is defined as follows:
| Property | Type | Explanation |
|---|---|---|
| expiration | String | ISO date format, for instance "2023-11-04T19:24:14.000Z" or "Never" |
| imageData | String or null | User provided information if any |
| twitterId | String or null | User provided information if any |
| discordId | String or null | User provided information if any |
| telegramId | String or null | User provided information if any |
| keybaseId | String or null | User provided information if any |
| pgpPublicKey | String or null | User provided information if any |