@ember-finance/sdk 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,6 +4,7 @@ import { TxBuilder } from "./on-chain-calls";
4
4
  import { AdminCalls } from "./on-chain-calls/admin";
5
5
  import { DeploymentParser } from "./utils/deployment-parser";
6
6
  import { AccountsApi, VaultsApi } from "./api";
7
+ export type PlatformEnv = "prod" | "staging" | "dev";
7
8
  export declare class EmberVaults {
8
9
  suiClient: SuiClient;
9
10
  signer: Signer;
@@ -15,5 +16,17 @@ export declare class EmberVaults {
15
16
  apiHost: string;
16
17
  api: AccountsApi;
17
18
  vaultsApi: VaultsApi;
18
- constructor(_network: string, _suiClient: SuiClient, _deployment: IDeployment, _signer?: Signer, _walletAddress?: string);
19
+ private _deployment;
20
+ constructor(_network: string, _suiClient: SuiClient, _deployment: IDeployment, _signer?: Signer, _walletAddress?: string, basePath?: string, environment?: PlatformEnv);
21
+ /**
22
+ * Updates the deployment configuration and reinitializes all deployment-dependent components
23
+ * This allows for updating deployment without creating a new EmberVaults instance
24
+ * @param newDeployment The new deployment configuration
25
+ */
26
+ updateDeployment(newDeployment: IDeployment): void;
27
+ /**
28
+ * Gets the current deployment configuration
29
+ * @returns The current deployment configuration
30
+ */
31
+ get deployment(): IDeployment;
19
32
  }
@@ -6,29 +6,51 @@ const admin_1 = require("./on-chain-calls/admin");
6
6
  const deployment_parser_1 = require("./utils/deployment-parser");
7
7
  const api_1 = require("./api");
8
8
  const environmentConfig = {
9
- mainnet: {
9
+ prod: {
10
10
  apiHost: "https://vaults.api.sui-prod.bluefin.io"
11
11
  },
12
- testnet: {
12
+ staging: {
13
13
  apiHost: "https://vaults.api.sui-staging.bluefin.io"
14
14
  },
15
- devnet: {
15
+ dev: {
16
16
  apiHost: "https://vaults.api.sui-dev.bluefin.io"
17
17
  }
18
18
  };
19
19
  class EmberVaults {
20
- constructor(_network, _suiClient, _deployment, _signer, _walletAddress) {
20
+ constructor(_network, _suiClient, _deployment, _signer, _walletAddress, basePath, environment = "prod") {
21
21
  this.network = _network;
22
22
  this.suiClient = _suiClient;
23
+ this._deployment = _deployment;
23
24
  this.parser = new deployment_parser_1.DeploymentParser(_deployment);
24
25
  // could be undefined, if initializing the EmberVaults for only get calls
25
26
  this.signer = _signer;
26
27
  this.walletAddress = _walletAddress || _signer?.toSuiAddress();
27
28
  this.txBuilder = new on_chain_calls_1.TxBuilder(_deployment);
28
- this.apiHost = environmentConfig[_network].apiHost;
29
+ this.apiHost = basePath || environmentConfig[environment].apiHost;
29
30
  this.admin = new admin_1.AdminCalls(_network, _suiClient, _deployment, _signer, _walletAddress);
30
31
  this.api = new api_1.AccountsApi(new api_1.Configuration({ basePath: this.apiHost }));
31
32
  this.vaultsApi = new api_1.VaultsApi(new api_1.Configuration({ basePath: this.apiHost }));
32
33
  }
34
+ /**
35
+ * Updates the deployment configuration and reinitializes all deployment-dependent components
36
+ * This allows for updating deployment without creating a new EmberVaults instance
37
+ * @param newDeployment The new deployment configuration
38
+ */
39
+ updateDeployment(newDeployment) {
40
+ this._deployment = newDeployment;
41
+ // Update deployment parser
42
+ this.parser.updateDeployment(newDeployment);
43
+ // Update transaction builder
44
+ this.txBuilder.updateDeployment(newDeployment);
45
+ // Update admin calls
46
+ this.admin.updateDeployment(newDeployment);
47
+ }
48
+ /**
49
+ * Gets the current deployment configuration
50
+ * @returns The current deployment configuration
51
+ */
52
+ get deployment() {
53
+ return this._deployment;
54
+ }
33
55
  }
34
56
  exports.EmberVaults = EmberVaults;
@@ -12,6 +12,11 @@ export declare class OnChainCalls {
12
12
  network: string;
13
13
  isUIWallet: boolean;
14
14
  constructor(_network: string, _suiClient: SuiClient, _deployment: IDeployment, _signer?: Signer, _walletAddress?: Address, _isUIWallet?: boolean);
15
+ /**
16
+ * Updates the deployment configuration
17
+ * @param newDeployment The new deployment configuration
18
+ */
19
+ updateDeployment(newDeployment: IDeployment): void;
15
20
  /**
16
21
  * Signs and executes the given transaction block
17
22
  * @param txBlock Sui transaction block
@@ -15,6 +15,14 @@ class OnChainCalls {
15
15
  this.txBuilder = new tx_builder_1.TxBuilder(_deployment);
16
16
  this.isUIWallet = _isUIWallet || false;
17
17
  }
18
+ /**
19
+ * Updates the deployment configuration
20
+ * @param newDeployment The new deployment configuration
21
+ */
22
+ updateDeployment(newDeployment) {
23
+ this.parser.updateDeployment(newDeployment);
24
+ this.txBuilder.updateDeployment(newDeployment);
25
+ }
18
26
  /**
19
27
  * Signs and executes the given transaction block
20
28
  * @param txBlock Sui transaction block
@@ -4,6 +4,11 @@ import { NumStr, TransactionBlock } from "@firefly-exchange/library-sui";
4
4
  export declare class TxBuilder {
5
5
  parser: DeploymentParser;
6
6
  constructor(_deployment: IDeployment);
7
+ /**
8
+ * Updates the deployment configuration
9
+ * @param newDeployment The new deployment configuration
10
+ */
11
+ updateDeployment(newDeployment: IDeployment): void;
7
12
  /**
8
13
  * Pauses or unpauses the non-admin operations
9
14
  * @param pause True if the non-admin operations should be paused, false otherwise
@@ -8,6 +8,13 @@ class TxBuilder {
8
8
  constructor(_deployment) {
9
9
  this.parser = new utils_1.DeploymentParser(_deployment);
10
10
  }
11
+ /**
12
+ * Updates the deployment configuration
13
+ * @param newDeployment The new deployment configuration
14
+ */
15
+ updateDeployment(newDeployment) {
16
+ this.parser.updateDeployment(newDeployment);
17
+ }
11
18
  /**
12
19
  * Pauses or unpauses the non-admin operations
13
20
  * @param pause True if the non-admin operations should be paused, false otherwise
@@ -2,6 +2,11 @@ import { IDeployment } from "../interfaces";
2
2
  export declare class DeploymentParser {
3
3
  deployment: IDeployment;
4
4
  constructor(_deployment: IDeployment);
5
+ /**
6
+ * Updates the deployment configuration
7
+ * @param newDeployment The new deployment configuration
8
+ */
9
+ updateDeployment(newDeployment: IDeployment): void;
5
10
  getAdminCap(): string;
6
11
  getPackageId(): string;
7
12
  getUpgradeCap(): string;
@@ -5,6 +5,13 @@ class DeploymentParser {
5
5
  constructor(_deployment) {
6
6
  this.deployment = _deployment;
7
7
  }
8
+ /**
9
+ * Updates the deployment configuration
10
+ * @param newDeployment The new deployment configuration
11
+ */
12
+ updateDeployment(newDeployment) {
13
+ this.deployment = newDeployment;
14
+ }
8
15
  getAdminCap() {
9
16
  return this.deployment.VaultProtocol.AdminCap;
10
17
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ember-finance/sdk",
3
3
  "description": "Ember Protocol SDK",
4
- "version": "1.0.2",
4
+ "version": "1.0.4",
5
5
  "module": "./dist/index.js",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",