@drift-labs/common
Version:
Common functions for Drift
49 lines • 1.44 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.UIEnv = void 0;
/**
* Utility class to handle environment configs in the Drift UI. Note that these environments don't exactly align with the SDK environment (SDK can only be mainnet or devnet, but UI can be devnet, staging, mainnet) so there is a `sdkEnv` getter utility to convert the UI env to SDK env (UI staging => SDK mainnet).
*/
class UIEnv {
constructor(env) {
this.env = env;
}
static createMainnet() {
return new UIEnv('mainnet-beta');
}
static createDevnet() {
return new UIEnv('devnet');
}
static createStaging() {
return new UIEnv('staging');
}
static getUIEnvIdFromKey(key) {
return new UIEnv(key);
}
get isMainnet() {
return this.env === 'mainnet-beta';
}
get isDevnet() {
return this.env === 'devnet';
}
get isStaging() {
return this.env === 'staging';
}
/**
* Returns the SDK environment type. Note that 'staging' maps to 'mainnet-beta' for SDK purposes.
*/
get sdkEnv() {
return this.isStaging ? 'mainnet-beta' : this.env;
}
/**
* Returns a unique string that can be used as a key in a map.
*/
get key() {
return this.env;
}
equals(other) {
return this.env === other.env;
}
}
exports.UIEnv = UIEnv;
//# sourceMappingURL=UIEnv.js.map
;