@ember-finance/sdk 1.0.3 → 1.0.5

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.
@@ -16,5 +16,18 @@ export declare class EmberVaults {
16
16
  apiHost: string;
17
17
  api: AccountsApi;
18
18
  vaultsApi: VaultsApi;
19
- constructor(_network: string, _suiClient: SuiClient, _deployment: IDeployment, _signer?: Signer, _walletAddress?: string, basePath?: string, environment?: PlatformEnv);
19
+ private _deployment;
20
+ constructor(_network: string, _suiClient: SuiClient, _signer?: Signer, _walletAddress?: string, basePath?: string, _deployment?: IDeployment, environment?: PlatformEnv);
21
+ init(): Promise<void>;
22
+ /**
23
+ * Updates the deployment configuration and reinitializes all deployment-dependent components
24
+ * This allows for updating deployment without creating a new EmberVaults instance
25
+ * @param newDeployment The new deployment configuration
26
+ */
27
+ updateDeployment(newDeployment: IDeployment): void;
28
+ /**
29
+ * Gets the current deployment configuration
30
+ * @returns The current deployment configuration
31
+ */
32
+ get deployment(): IDeployment;
20
33
  }
@@ -17,9 +17,10 @@ const environmentConfig = {
17
17
  }
18
18
  };
19
19
  class EmberVaults {
20
- constructor(_network, _suiClient, _deployment, _signer, _walletAddress, basePath, environment = "prod") {
20
+ constructor(_network, _suiClient, _signer, _walletAddress, basePath, _deployment, 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;
@@ -30,5 +31,31 @@ class EmberVaults {
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
+ async init() {
35
+ const deployment = await this.vaultsApi.getVaultsProtocolInfo();
36
+ const deploymentData = deployment.data;
37
+ this.updateDeployment(deploymentData);
38
+ }
39
+ /**
40
+ * Updates the deployment configuration and reinitializes all deployment-dependent components
41
+ * This allows for updating deployment without creating a new EmberVaults instance
42
+ * @param newDeployment The new deployment configuration
43
+ */
44
+ updateDeployment(newDeployment) {
45
+ this._deployment = newDeployment;
46
+ // Update deployment parser
47
+ this.parser.updateDeployment(newDeployment);
48
+ // Update transaction builder
49
+ this.txBuilder.updateDeployment(newDeployment);
50
+ // Update admin calls
51
+ this.admin.updateDeployment(newDeployment);
52
+ }
53
+ /**
54
+ * Gets the current deployment configuration
55
+ * @returns The current deployment configuration
56
+ */
57
+ get deployment() {
58
+ return this._deployment;
59
+ }
33
60
  }
34
61
  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.3",
4
+ "version": "1.0.5",
5
5
  "module": "./dist/index.js",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",