@twin.org/wallet-connector-entity-storage 0.0.2-next.5 → 0.0.3-next.2

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.
@@ -0,0 +1,37 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { entity, property } from "@twin.org/entity";
4
+ /**
5
+ * Class describing a wallet address.
6
+ */
7
+ let WalletAddress = class WalletAddress {
8
+ /**
9
+ * The address in the wallet.
10
+ */
11
+ address;
12
+ /**
13
+ * The identity of the owner.
14
+ */
15
+ identity;
16
+ /**
17
+ * The balance of the wallet as bigint.
18
+ */
19
+ balance;
20
+ };
21
+ __decorate([
22
+ property({ type: "string", isPrimary: true }),
23
+ __metadata("design:type", String)
24
+ ], WalletAddress.prototype, "address", void 0);
25
+ __decorate([
26
+ property({ type: "string" }),
27
+ __metadata("design:type", String)
28
+ ], WalletAddress.prototype, "identity", void 0);
29
+ __decorate([
30
+ property({ type: "string" }),
31
+ __metadata("design:type", String)
32
+ ], WalletAddress.prototype, "balance", void 0);
33
+ WalletAddress = __decorate([
34
+ entity()
35
+ ], WalletAddress);
36
+ export { WalletAddress };
37
+ //# sourceMappingURL=walletAddress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"walletAddress.js","sourceRoot":"","sources":["../../../src/entities/walletAddress.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;GAEG;AAEI,IAAM,aAAa,GAAnB,MAAM,aAAa;IACzB;;OAEG;IAEI,OAAO,CAAU;IAExB;;OAEG;IAEI,QAAQ,CAAU;IAEzB;;OAEG;IAEI,OAAO,CAAU;CACxB,CAAA;AAbO;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;;8CACtB;AAMjB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;;+CACJ;AAMlB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;;8CACL;AAjBZ,aAAa;IADzB,MAAM,EAAE;GACI,aAAa,CAkBzB","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { entity, property } from \"@twin.org/entity\";\n\n/**\n * Class describing a wallet address.\n */\n@entity()\nexport class WalletAddress {\n\t/**\n\t * The address in the wallet.\n\t */\n\t@property({ type: \"string\", isPrimary: true })\n\tpublic address!: string;\n\n\t/**\n\t * The identity of the owner.\n\t */\n\t@property({ type: \"string\" })\n\tpublic identity!: string;\n\n\t/**\n\t * The balance of the wallet as bigint.\n\t */\n\t@property({ type: \"string\" })\n\tpublic balance!: string;\n}\n"]}
@@ -0,0 +1,61 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { Coerce, Guards, Is } from "@twin.org/core";
4
+ import { EntityStorageConnectorFactory } from "@twin.org/entity-storage-models";
5
+ /**
6
+ * Class for performing faucet operations using entity storage.
7
+ */
8
+ export class EntityStorageFaucetConnector {
9
+ /**
10
+ * The namespace supported by the wallet connector.
11
+ */
12
+ static NAMESPACE = "entity-storage";
13
+ /**
14
+ * Runtime name for the class.
15
+ */
16
+ static CLASS_NAME = "EntityStorageFaucetConnector";
17
+ /**
18
+ * The entity storage for wallets.
19
+ * @internal
20
+ */
21
+ _walletAddressEntityStorage;
22
+ /**
23
+ * Create a new instance of EntityStorageFaucetConnector.
24
+ * @param options The options for the wallet connector.
25
+ */
26
+ constructor(options) {
27
+ this._walletAddressEntityStorage = EntityStorageConnectorFactory.get(options?.walletAddressEntityStorageType ?? "wallet-address");
28
+ }
29
+ /**
30
+ * Returns the class name of the component.
31
+ * @returns The class name of the component.
32
+ */
33
+ className() {
34
+ return EntityStorageFaucetConnector.CLASS_NAME;
35
+ }
36
+ /**
37
+ * Fund the wallet from the faucet.
38
+ * @param identity The identity of the user to access the vault keys.
39
+ * @param address The hex encoded address of the address to fund.
40
+ * @param timeoutInSeconds The timeout in seconds to wait for the funding to complete.
41
+ * @returns The amount added to the address by the faucet.
42
+ */
43
+ async fundAddress(identity, address, timeoutInSeconds = 60) {
44
+ Guards.stringValue(EntityStorageFaucetConnector.CLASS_NAME, "identity", identity);
45
+ Guards.stringValue(EntityStorageFaucetConnector.CLASS_NAME, "address", address);
46
+ let walletAddress = await this._walletAddressEntityStorage.get(address);
47
+ if (Is.empty(walletAddress)) {
48
+ walletAddress = {
49
+ balance: "0",
50
+ identity,
51
+ address
52
+ };
53
+ }
54
+ const maxFundAmount = 1000000000n;
55
+ const balance = Coerce.bigint(walletAddress.balance) ?? 0n;
56
+ walletAddress.balance = (balance + maxFundAmount).toString();
57
+ await this._walletAddressEntityStorage.set(walletAddress);
58
+ return maxFundAmount;
59
+ }
60
+ }
61
+ //# sourceMappingURL=entityStorageFaucetConnector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entityStorageFaucetConnector.js","sourceRoot":"","sources":["../../src/entityStorageFaucetConnector.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EACN,6BAA6B,EAE7B,MAAM,iCAAiC,CAAC;AAMzC;;GAEG;AACH,MAAM,OAAO,4BAA4B;IACxC;;OAEG;IACI,MAAM,CAAU,SAAS,GAAW,gBAAgB,CAAC;IAE5D;;OAEG;IACI,MAAM,CAAU,UAAU,kCAAkD;IAEnF;;;OAGG;IACc,2BAA2B,CAAyC;IAErF;;;OAGG;IACH,YAAY,OAAyD;QACpE,IAAI,CAAC,2BAA2B,GAAG,6BAA6B,CAAC,GAAG,CACnE,OAAO,EAAE,8BAA8B,IAAI,gBAAgB,CAC3D,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,4BAA4B,CAAC,UAAU,CAAC;IAChD,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,WAAW,CACvB,QAAgB,EAChB,OAAe,EACf,mBAA2B,EAAE;QAE7B,MAAM,CAAC,WAAW,CAAC,4BAA4B,CAAC,UAAU,cAAoB,QAAQ,CAAC,CAAC;QACxF,MAAM,CAAC,WAAW,CAAC,4BAA4B,CAAC,UAAU,aAAmB,OAAO,CAAC,CAAC;QAEtF,IAAI,aAAa,GAAG,MAAM,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACxE,IAAI,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,CAAC;YAC7B,aAAa,GAAG;gBACf,OAAO,EAAE,GAAG;gBACZ,QAAQ;gBACR,OAAO;aACP,CAAC;QACH,CAAC;QAED,MAAM,aAAa,GAAG,WAAW,CAAC;QAClC,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QAC3D,aAAa,CAAC,OAAO,GAAG,CAAC,OAAO,GAAG,aAAa,CAAC,CAAC,QAAQ,EAAE,CAAC;QAE7D,MAAM,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QAE1D,OAAO,aAAa,CAAC;IACtB,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Coerce, Guards, Is } from \"@twin.org/core\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { IFaucetConnector } from \"@twin.org/wallet-models\";\nimport type { WalletAddress } from \"./entities/walletAddress.js\";\nimport type { IEntityStorageFaucetConnectorConstructorOptions } from \"./models/IEntityStorageFaucetConnectorConstructorOptions.js\";\n\n/**\n * Class for performing faucet operations using entity storage.\n */\nexport class EntityStorageFaucetConnector implements IFaucetConnector {\n\t/**\n\t * The namespace supported by the wallet connector.\n\t */\n\tpublic static readonly NAMESPACE: string = \"entity-storage\";\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<EntityStorageFaucetConnector>();\n\n\t/**\n\t * The entity storage for wallets.\n\t * @internal\n\t */\n\tprivate readonly _walletAddressEntityStorage: IEntityStorageConnector<WalletAddress>;\n\n\t/**\n\t * Create a new instance of EntityStorageFaucetConnector.\n\t * @param options The options for the wallet connector.\n\t */\n\tconstructor(options?: IEntityStorageFaucetConnectorConstructorOptions) {\n\t\tthis._walletAddressEntityStorage = EntityStorageConnectorFactory.get(\n\t\t\toptions?.walletAddressEntityStorageType ?? \"wallet-address\"\n\t\t);\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn EntityStorageFaucetConnector.CLASS_NAME;\n\t}\n\n\t/**\n\t * Fund the wallet from the faucet.\n\t * @param identity The identity of the user to access the vault keys.\n\t * @param address The hex encoded address of the address to fund.\n\t * @param timeoutInSeconds The timeout in seconds to wait for the funding to complete.\n\t * @returns The amount added to the address by the faucet.\n\t */\n\tpublic async fundAddress(\n\t\tidentity: string,\n\t\taddress: string,\n\t\ttimeoutInSeconds: number = 60\n\t): Promise<bigint> {\n\t\tGuards.stringValue(EntityStorageFaucetConnector.CLASS_NAME, nameof(identity), identity);\n\t\tGuards.stringValue(EntityStorageFaucetConnector.CLASS_NAME, nameof(address), address);\n\n\t\tlet walletAddress = await this._walletAddressEntityStorage.get(address);\n\t\tif (Is.empty(walletAddress)) {\n\t\t\twalletAddress = {\n\t\t\t\tbalance: \"0\",\n\t\t\t\tidentity,\n\t\t\t\taddress\n\t\t\t};\n\t\t}\n\n\t\tconst maxFundAmount = 1000000000n;\n\t\tconst balance = Coerce.bigint(walletAddress.balance) ?? 0n;\n\t\twalletAddress.balance = (balance + maxFundAmount).toString();\n\n\t\tawait this._walletAddressEntityStorage.set(walletAddress);\n\n\t\treturn maxFundAmount;\n\t}\n}\n"]}
@@ -1,103 +1,15 @@
1
- import { property, entity, ComparisonOperator, LogicalOperator, EntitySchemaFactory, EntitySchemaHelper } from '@twin.org/entity';
2
- import { Guards, Is, Coerce, GeneralError } from '@twin.org/core';
3
- import { EntityStorageConnectorFactory } from '@twin.org/entity-storage-models';
4
- import { Bip39, Bip44, KeyType } from '@twin.org/crypto';
5
- import { VaultConnectorFactory } from '@twin.org/vault-models';
6
- import { FaucetConnectorFactory } from '@twin.org/wallet-models';
7
-
8
- // Copyright 2024 IOTA Stiftung.
9
- // SPDX-License-Identifier: Apache-2.0.
10
- /**
11
- * Class describing a wallet address.
12
- */
13
- let WalletAddress = class WalletAddress {
14
- /**
15
- * The address in the wallet.
16
- */
17
- address;
18
- /**
19
- * The identity of the owner.
20
- */
21
- identity;
22
- /**
23
- * The balance of the wallet as bigint.
24
- */
25
- balance;
26
- };
27
- __decorate([
28
- property({ type: "string", isPrimary: true }),
29
- __metadata("design:type", String)
30
- ], WalletAddress.prototype, "address", void 0);
31
- __decorate([
32
- property({ type: "string" }),
33
- __metadata("design:type", String)
34
- ], WalletAddress.prototype, "identity", void 0);
35
- __decorate([
36
- property({ type: "string" }),
37
- __metadata("design:type", String)
38
- ], WalletAddress.prototype, "balance", void 0);
39
- WalletAddress = __decorate([
40
- entity()
41
- ], WalletAddress);
42
-
43
- // Copyright 2024 IOTA Stiftung.
44
- // SPDX-License-Identifier: Apache-2.0.
45
- /**
46
- * Class for performing faucet operations using entity storage.
47
- */
48
- class EntityStorageFaucetConnector {
49
- /**
50
- * The namespace supported by the wallet connector.
51
- */
52
- static NAMESPACE = "entity-storage";
53
- /**
54
- * Runtime name for the class.
55
- */
56
- static CLASS_NAME = "EntityStorageFaucetConnector";
57
- /**
58
- * The entity storage for wallets.
59
- * @internal
60
- */
61
- _walletAddressEntityStorage;
62
- /**
63
- * Create a new instance of EntityStorageFaucetConnector.
64
- * @param options The options for the wallet connector.
65
- */
66
- constructor(options) {
67
- this._walletAddressEntityStorage = EntityStorageConnectorFactory.get(options?.walletAddressEntityStorageType ?? "wallet-address");
68
- }
69
- /**
70
- * Fund the wallet from the faucet.
71
- * @param identity The identity of the user to access the vault keys.
72
- * @param address The hex encoded address of the address to fund.
73
- * @param timeoutInSeconds The timeout in seconds to wait for the funding to complete.
74
- * @returns The amount added to the address by the faucet.
75
- */
76
- async fundAddress(identity, address, timeoutInSeconds = 60) {
77
- Guards.stringValue(EntityStorageFaucetConnector.CLASS_NAME, "identity", identity);
78
- Guards.stringValue(EntityStorageFaucetConnector.CLASS_NAME, "address", address);
79
- let walletAddress = await this._walletAddressEntityStorage.get(address);
80
- if (Is.empty(walletAddress)) {
81
- walletAddress = {
82
- balance: "0",
83
- identity,
84
- address
85
- };
86
- }
87
- const maxFundAmount = 1000000000n;
88
- const balance = Coerce.bigint(walletAddress.balance) ?? 0n;
89
- walletAddress.balance = (balance + maxFundAmount).toString();
90
- await this._walletAddressEntityStorage.set(walletAddress);
91
- return maxFundAmount;
92
- }
93
- }
94
-
95
1
  // Copyright 2024 IOTA Stiftung.
96
2
  // SPDX-License-Identifier: Apache-2.0.
3
+ import { Coerce, GeneralError, Guards, Is } from "@twin.org/core";
4
+ import { Bip39, Bip44, KeyType } from "@twin.org/crypto";
5
+ import { ComparisonOperator, LogicalOperator } from "@twin.org/entity";
6
+ import { EntityStorageConnectorFactory } from "@twin.org/entity-storage-models";
7
+ import { VaultConnectorFactory } from "@twin.org/vault-models";
8
+ import { FaucetConnectorFactory } from "@twin.org/wallet-models";
97
9
  /**
98
10
  * Class for performing wallet operations using in-memory storage.
99
11
  */
100
- class EntityStorageWalletConnector {
12
+ export class EntityStorageWalletConnector {
101
13
  /**
102
14
  * Runtime name for the class.
103
15
  */
@@ -153,6 +65,13 @@ class EntityStorageWalletConnector {
153
65
  this._config.coinType ??= EntityStorageWalletConnector._DEFAULT_COIN_TYPE;
154
66
  this._config.networkName ??= EntityStorageWalletConnector._DEFAULT_NETWORK_NAME;
155
67
  }
68
+ /**
69
+ * Returns the class name of the component.
70
+ * @returns The class name of the component.
71
+ */
72
+ className() {
73
+ return EntityStorageWalletConnector.CLASS_NAME;
74
+ }
156
75
  /**
157
76
  * Create a new wallet.
158
77
  * @param identity The identity of the user to access the vault keys.
@@ -290,14 +209,4 @@ class EntityStorageWalletConnector {
290
209
  return `${identity}/${this._config.vaultMnemonicId ?? EntityStorageWalletConnector._DEFAULT_MNEMONIC_SECRET_NAME}`;
291
210
  }
292
211
  }
293
-
294
- // Copyright 2024 IOTA Stiftung.
295
- // SPDX-License-Identifier: Apache-2.0.
296
- /**
297
- * Initialize the schema for the wallet entity storage connector.
298
- */
299
- function initSchema() {
300
- EntitySchemaFactory.register("WalletAddress", () => EntitySchemaHelper.getSchema(WalletAddress));
301
- }
302
-
303
- export { EntityStorageFaucetConnector, EntityStorageWalletConnector, WalletAddress, initSchema };
212
+ //# sourceMappingURL=entityStorageWalletConnector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entityStorageWalletConnector.js","sourceRoot":"","sources":["../../src/entityStorageWalletConnector.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EACN,6BAA6B,EAE7B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,qBAAqB,EAAwB,MAAM,wBAAwB,CAAC;AACrF,OAAO,EACN,sBAAsB,EAGtB,MAAM,yBAAyB,CAAC;AAKjC;;GAEG;AACH,MAAM,OAAO,4BAA4B;IACxC;;OAEG;IACI,MAAM,CAAU,U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AAE,mBAAmB,CAAC,CAAC;QACtF,CAAC;QAED,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;YAE1D,IAAI,iBAAiB,GAAG,MAAM,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;YAEhF,IAAI,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC;gBACjC,iBAAiB,GAAG;oBACnB,OAAO,EAAE,GAAG;oBACZ,QAAQ,EAAE,EAAE;oBACZ,OAAO,EAAE,WAAW;iBACpB,CAAC;YACH,CAAC;YAED,iBAAiB,CAAC,OAAO,GAAG,CAAC,MAAM,CAAC,iBAAiB,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC;YAEpF,MAAM,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAC/D,CAAC;QAED,OAAO,SAAS,CAAC;IAClB,CAAC;IAED;;;;;OAKG;IACK,gBAAgB,CAAC,QAAgB;QACxC,OAAO,GAAG,QAAQ,IAAI,IAAI,CAAC,OAAO,CAAC,eAAe,IAAI,4BAA4B,CAAC,6BAA6B,EAAE,CAAC;IACpH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Coerce, GeneralError, Guards, Is } from \"@twin.org/core\";\nimport { Bip39, Bip44, KeyType } from \"@twin.org/crypto\";\nimport { ComparisonOperator, LogicalOperator } from \"@twin.org/entity\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { VaultConnectorFactory, type IVaultConnector } from \"@twin.org/vault-models\";\nimport {\n\tFaucetConnectorFactory,\n\ttype IFaucetConnector,\n\ttype IWalletConnector\n} from \"@twin.org/wallet-models\";\nimport type { WalletAddress } from \"./entities/walletAddress.js\";\nimport type { IEntityStorageWalletConnectorConfig } from \"./models/IEntityStorageWalletConnectorConfig.js\";\nimport type { IEntityStorageWalletConnectorConstructorOptions } from \"./models/IEntityStorageWalletConnectorConstructorOptions.js\";\n\n/**\n * Class for performing wallet operations using in-memory storage.\n */\nexport class EntityStorageWalletConnector implements IWalletConnector {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<EntityStorageWalletConnector>();\n\n\t/**\n\t * The namespace supported by the wallet connector.\n\t */\n\tpublic static readonly NAMESPACE: string = \"entity-storage\";\n\n\t/**\n\t * Default name for the mnemonic secret.\n\t * @internal\n\t */\n\tprivate static readonly _DEFAULT_MNEMONIC_SECRET_NAME: string = \"mnemonic\";\n\n\t/**\n\t * Default coin type.\n\t * @internal\n\t */\n\tprivate static readonly _DEFAULT_COIN_TYPE: number = 9999;\n\n\t/**\n\t * Default network name.\n\t * @internal\n\t */\n\tprivate static readonly _DEFAULT_NETWORK_NAME: string = \"ent\";\n\n\t/**\n\t * The vault for the mnemonic.\n\t * @internal\n\t */\n\tprivate readonly _vaultConnector: IVaultConnector;\n\n\t/**\n\t * The faucet.\n\t * @internal\n\t */\n\tprivate readonly _faucetConnector?: IFaucetConnector;\n\n\t/**\n\t * The entity storage for wallets.\n\t * @internal\n\t */\n\tprivate readonly _walletAddressEntityStorage: IEntityStorageConnector<WalletAddress>;\n\n\t/**\n\t * The configuration to use for tangle operations.\n\t * @internal\n\t */\n\tprivate readonly _config: IEntityStorageWalletConnectorConfig;\n\n\t/**\n\t * Create a new instance of EntityStorageWalletConnector.\n\t * @param options The options for the wallet connector.\n\t */\n\tconstructor(options?: IEntityStorageWalletConnectorConstructorOptions) {\n\t\tthis._vaultConnector = VaultConnectorFactory.get(options?.vaultConnectorType ?? \"vault\");\n\t\tthis._faucetConnector = FaucetConnectorFactory.getIfExists(\n\t\t\toptions?.faucetConnectorType ?? \"faucet\"\n\t\t);\n\t\tthis._walletAddressEntityStorage = EntityStorageConnectorFactory.get(\n\t\t\toptions?.walletAddressEntityStorageType ?? \"wallet-address\"\n\t\t);\n\t\tthis._config = options?.config ?? {};\n\t\tthis._config.coinType ??= EntityStorageWalletConnector._DEFAULT_COIN_TYPE;\n\t\tthis._config.networkName ??= EntityStorageWalletConnector._DEFAULT_NETWORK_NAME;\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn EntityStorageWalletConnector.CLASS_NAME;\n\t}\n\n\t/**\n\t * Create a new wallet.\n\t * @param identity The identity of the user to access the vault keys.\n\t * @returns Nothing.\n\t */\n\tpublic async create(identity: string): Promise<void> {\n\t\tGuards.stringValue(EntityStorageWalletConnector.CLASS_NAME, nameof(identity), identity);\n\n\t\tconst mnemonic = Bip39.randomMnemonic();\n\t\tawait this._vaultConnector.setSecret<string>(this.buildMnemonicKey(identity), mnemonic);\n\t}\n\n\t/**\n\t * Get the addresses for the requested range.\n\t * @param identity The identity of the user to access the vault keys.\n\t * @param accountIndex The account index to get the addresses for.\n\t * @param startAddressIndex The start index for the addresses.\n\t * @param count The number of addresses to generate.\n\t * @returns The list of addresses.\n\t */\n\tpublic async getAddresses(\n\t\tidentity: string,\n\t\taccountIndex: number,\n\t\tstartAddressIndex: number,\n\t\tcount: number\n\t): Promise<string[]> {\n\t\tGuards.stringValue(EntityStorageWalletConnector.CLASS_NAME, nameof(identity), identity);\n\t\tGuards.integer(\n\t\t\tEntityStorageWalletConnector.CLASS_NAME,\n\t\t\tnameof(startAddressIndex),\n\t\t\tstartAddressIndex\n\t\t);\n\t\tGuards.integer(EntityStorageWalletConnector.CLASS_NAME, nameof(count), count);\n\n\t\tconst mnemonic = await this._vaultConnector.getSecret<string>(this.buildMnemonicKey(identity));\n\n\t\tconst seed = Bip39.mnemonicToSeed(mnemonic);\n\n\t\tconst keyPairs: string[] = [];\n\n\t\tfor (let i = startAddressIndex; i < startAddressIndex + count; i++) {\n\t\t\tconst addressKeyPair = Bip44.address(\n\t\t\t\tseed,\n\t\t\t\tKeyType.Ed25519,\n\t\t\t\tthis._config.coinType ?? EntityStorageWalletConnector._DEFAULT_COIN_TYPE,\n\t\t\t\taccountIndex,\n\t\t\t\tfalse,\n\t\t\t\ti\n\t\t\t);\n\n\t\t\tkeyPairs.push(addressKeyPair.address);\n\t\t}\n\n\t\treturn keyPairs;\n\t}\n\n\t/**\n\t * Get the balance for an address in a wallet.\n\t * @param identity The identity of the user to access the vault keys.\n\t * @param address The hex encoded address.\n\t * @returns The balance of the wallet address.\n\t */\n\tpublic async getBalance(identity: string, address: string): Promise<bigint> {\n\t\tGuards.stringValue(EntityStorageWalletConnector.CLASS_NAME, nameof(address), address);\n\n\t\tconst walletAddress = await this._walletAddressEntityStorage.get(address);\n\n\t\treturn Coerce.bigint(walletAddress?.balance) ?? 0n;\n\t}\n\n\t/**\n\t * Ensure the balance for an address in a wallet.\n\t * @param identity The identity of the user to access the vault keys.\n\t * @param address The hex encoded address.\n\t * @param ensureBalance The balance to ensure on the address.\n\t * @param timeoutInSeconds The timeout in seconds to wait for the funding to complete.\n\t * @returns True if the balance has been ensured.\n\t */\n\tpublic async ensureBalance(\n\t\tidentity: string,\n\t\taddress: string,\n\t\tensureBalance: bigint,\n\t\ttimeoutInSeconds?: number\n\t): Promise<boolean> {\n\t\tGuards.stringValue(EntityStorageWalletConnector.CLASS_NAME, nameof(identity), identity);\n\t\tGuards.stringValue(EntityStorageWalletConnector.CLASS_NAME, nameof(address), address);\n\t\tGuards.bigint(EntityStorageWalletConnector.CLASS_NAME, nameof(ensureBalance), ensureBalance);\n\n\t\tif (this._faucetConnector) {\n\t\t\tlet retryCount = 10;\n\t\t\tlet currentBalance = await this.getBalance(identity, address);\n\n\t\t\twhile (currentBalance < ensureBalance && retryCount > 0) {\n\t\t\t\tconst addedBalance = await this._faucetConnector.fundAddress(\n\t\t\t\t\tidentity,\n\t\t\t\t\taddress,\n\t\t\t\t\ttimeoutInSeconds\n\t\t\t\t);\n\t\t\t\tif (addedBalance === 0n) {\n\t\t\t\t\t// The balance has not increased, so return.\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tcurrentBalance += addedBalance;\n\t\t\t\tif (currentBalance < ensureBalance) {\n\t\t\t\t\t// The balance has increased but is still not enough, wait and try again.\n\t\t\t\t\tawait new Promise(resolve => setTimeout(resolve, 100));\n\t\t\t\t\tretryCount--;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn currentBalance >= ensureBalance;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t * Transfer funds to an address.\n\t * @param identity The identity of the user to access the vault keys.\n\t * @param addressSource The hex encoded address to send the funds from.\n\t * @param addressDest The hex encoded address to send the funds to.\n\t * @param amount The amount to transfer.\n\t * @returns An identifier for the transfer if there was one.\n\t */\n\tpublic async transfer(\n\t\tidentity: string,\n\t\taddressSource: string,\n\t\taddressDest: string,\n\t\tamount: bigint\n\t): Promise<string | undefined> {\n\t\tGuards.stringValue(EntityStorageWalletConnector.CLASS_NAME, nameof(identity), identity);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageWalletConnector.CLASS_NAME,\n\t\t\tnameof(addressSource),\n\t\t\taddressSource\n\t\t);\n\t\tGuards.stringValue(EntityStorageWalletConnector.CLASS_NAME, nameof(addressDest), addressDest);\n\t\tGuards.bigint(EntityStorageWalletConnector.CLASS_NAME, nameof(amount), amount);\n\n\t\tconst walletAddresses = await this._walletAddressEntityStorage.query({\n\t\t\tlogicalOperator: LogicalOperator.And,\n\t\t\tconditions: [\n\t\t\t\t{\n\t\t\t\t\tproperty: \"identity\",\n\t\t\t\t\tcomparison: ComparisonOperator.Equals,\n\t\t\t\t\tvalue: identity\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tproperty: \"address\",\n\t\t\t\t\tcomparison: ComparisonOperator.Equals,\n\t\t\t\t\tvalue: addressSource\n\t\t\t\t}\n\t\t\t]\n\t\t});\n\n\t\tlet walletAddress: WalletAddress | undefined;\n\t\tlet balance = 0n;\n\t\tif (walletAddresses.entities.length > 0) {\n\t\t\twalletAddress = walletAddresses.entities[0] as WalletAddress;\n\t\t\tbalance = BigInt(walletAddress.balance);\n\t\t\twalletAddress.balance = (BigInt(walletAddress.balance) - amount).toString();\n\t\t}\n\n\t\tif (balance < amount) {\n\t\t\tthrow new GeneralError(EntityStorageWalletConnector.CLASS_NAME, \"insufficientFunds\");\n\t\t}\n\n\t\tif (!Is.empty(walletAddress)) {\n\t\t\tawait this._walletAddressEntityStorage.set(walletAddress);\n\n\t\t\tlet destWalletAddress = await this._walletAddressEntityStorage.get(addressDest);\n\n\t\t\tif (Is.empty(destWalletAddress)) {\n\t\t\t\tdestWalletAddress = {\n\t\t\t\t\tbalance: \"0\",\n\t\t\t\t\tidentity: \"\",\n\t\t\t\t\taddress: addressDest\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tdestWalletAddress.balance = (BigInt(destWalletAddress.balance) + amount).toString();\n\n\t\t\tawait this._walletAddressEntityStorage.set(destWalletAddress);\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Build the key name to access the mnemonic in the vault.\n\t * @param identity The identity of the user to access the vault keys.\n\t * @returns The vault key.\n\t * @internal\n\t */\n\tprivate buildMnemonicKey(identity: string): string {\n\t\treturn `${identity}/${this._config.vaultMnemonicId ?? EntityStorageWalletConnector._DEFAULT_MNEMONIC_SECRET_NAME}`;\n\t}\n}\n"]}
@@ -0,0 +1,10 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export * from "./entities/walletAddress.js";
4
+ export * from "./entityStorageFaucetConnector.js";
5
+ export * from "./entityStorageWalletConnector.js";
6
+ export * from "./models/IEntityStorageFaucetConnectorConstructorOptions.js";
7
+ export * from "./models/IEntityStorageWalletConnectorConfig.js";
8
+ export * from "./models/IEntityStorageWalletConnectorConstructorOptions.js";
9
+ export * from "./schema.js";
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,6DAA6D,CAAC;AAC5E,cAAc,iDAAiD,CAAC;AAChE,cAAc,6DAA6D,CAAC;AAC5E,cAAc,aAAa,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./entities/walletAddress.js\";\nexport * from \"./entityStorageFaucetConnector.js\";\nexport * from \"./entityStorageWalletConnector.js\";\nexport * from \"./models/IEntityStorageFaucetConnectorConstructorOptions.js\";\nexport * from \"./models/IEntityStorageWalletConnectorConfig.js\";\nexport * from \"./models/IEntityStorageWalletConnectorConstructorOptions.js\";\nexport * from \"./schema.js\";\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export {};
4
+ //# sourceMappingURL=IEntityStorageFaucetConnectorConstructorOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IEntityStorageFaucetConnectorConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/IEntityStorageFaucetConnectorConstructorOptions.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Options for the entity storage faucet connector.\n */\nexport interface IEntityStorageFaucetConnectorConstructorOptions {\n\t/**\n\t * The entity storage type for wallet addresses.\n\t * @default wallet-address\n\t */\n\twalletAddressEntityStorageType?: string;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export {};
4
+ //# sourceMappingURL=IEntityStorageWalletConnectorConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IEntityStorageWalletConnectorConfig.js","sourceRoot":"","sources":["../../../src/models/IEntityStorageWalletConnectorConfig.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Configuration for the Entity Storage Wallet Connector.\n */\nexport interface IEntityStorageWalletConnectorConfig {\n\t/**\n\t * The id of the entry in the vault containing the mnemonic.\n\t * @default mnemonic\n\t */\n\tvaultMnemonicId?: string;\n\n\t/**\n\t * The coin type.\n\t * @default 9999\n\t */\n\tcoinType?: number;\n\n\t/**\n\t * The network name part for the addresses.\n\t * @default ent\n\t */\n\tnetworkName?: string;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IEntityStorageWalletConnectorConstructorOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IEntityStorageWalletConnectorConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/IEntityStorageWalletConnectorConstructorOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IEntityStorageWalletConnectorConfig } from \"./IEntityStorageWalletConnectorConfig.js\";\n\n/**\n * Options for the entity storage wallet connector.\n */\nexport interface IEntityStorageWalletConnectorConstructorOptions {\n\t/**\n\t * Vault connector to use for wallet secrets.\n\t * @default vault\n\t */\n\tvaultConnectorType?: string;\n\n\t/**\n\t * Optional faucet for requesting funds.\n\t * @default faucet\n\t */\n\tfaucetConnectorType?: string;\n\n\t/**\n\t * The entity storage for wallets.\n\t * @default wallet-address\n\t */\n\twalletAddressEntityStorageType?: string;\n\n\t/**\n\t * The configuration for the wallet connector.\n\t */\n\tconfig?: IEntityStorageWalletConnectorConfig;\n}\n"]}
@@ -0,0 +1,11 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { EntitySchemaFactory, EntitySchemaHelper } from "@twin.org/entity";
4
+ import { WalletAddress } from "./entities/walletAddress.js";
5
+ /**
6
+ * Initialize the schema for the wallet entity storage connector.
7
+ */
8
+ export function initSchema() {
9
+ EntitySchemaFactory.register("WalletAddress", () => EntitySchemaHelper.getSchema(WalletAddress));
10
+ }
11
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/schema.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE3E,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D;;GAEG;AACH,MAAM,UAAU,UAAU;IACzB,mBAAmB,CAAC,QAAQ,kBAA0B,GAAG,EAAE,CAC1D,kBAAkB,CAAC,SAAS,CAAC,aAAa,CAAC,CAC3C,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { EntitySchemaFactory, EntitySchemaHelper } from \"@twin.org/entity\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { WalletAddress } from \"./entities/walletAddress.js\";\n\n/**\n * Initialize the schema for the wallet entity storage connector.\n */\nexport function initSchema(): void {\n\tEntitySchemaFactory.register(nameof<WalletAddress>(), () =>\n\t\tEntitySchemaHelper.getSchema(WalletAddress)\n\t);\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import type { IFaucetConnector } from "@twin.org/wallet-models";
2
- import type { IEntityStorageFaucetConnectorConstructorOptions } from "./models/IEntityStorageFaucetConnectorConstructorOptions";
2
+ import type { IEntityStorageFaucetConnectorConstructorOptions } from "./models/IEntityStorageFaucetConnectorConstructorOptions.js";
3
3
  /**
4
4
  * Class for performing faucet operations using entity storage.
5
5
  */
@@ -17,6 +17,11 @@ export declare class EntityStorageFaucetConnector implements IFaucetConnector {
17
17
  * @param options The options for the wallet connector.
18
18
  */
19
19
  constructor(options?: IEntityStorageFaucetConnectorConstructorOptions);
20
+ /**
21
+ * Returns the class name of the component.
22
+ * @returns The class name of the component.
23
+ */
24
+ className(): string;
20
25
  /**
21
26
  * Fund the wallet from the faucet.
22
27
  * @param identity The identity of the user to access the vault keys.
@@ -1,5 +1,5 @@
1
1
  import { type IWalletConnector } from "@twin.org/wallet-models";
2
- import type { IEntityStorageWalletConnectorConstructorOptions } from "./models/IEntityStorageWalletConnectorConstructorOptions";
2
+ import type { IEntityStorageWalletConnectorConstructorOptions } from "./models/IEntityStorageWalletConnectorConstructorOptions.js";
3
3
  /**
4
4
  * Class for performing wallet operations using in-memory storage.
5
5
  */
@@ -17,6 +17,11 @@ export declare class EntityStorageWalletConnector implements IWalletConnector {
17
17
  * @param options The options for the wallet connector.
18
18
  */
19
19
  constructor(options?: IEntityStorageWalletConnectorConstructorOptions);
20
+ /**
21
+ * Returns the class name of the component.
22
+ * @returns The class name of the component.
23
+ */
24
+ className(): string;
20
25
  /**
21
26
  * Create a new wallet.
22
27
  * @param identity The identity of the user to access the vault keys.
@@ -1,7 +1,7 @@
1
- export * from "./entities/walletAddress";
2
- export * from "./entityStorageFaucetConnector";
3
- export * from "./entityStorageWalletConnector";
4
- export * from "./models/IEntityStorageFaucetConnectorConstructorOptions";
5
- export * from "./models/IEntityStorageWalletConnectorConfig";
6
- export * from "./models/IEntityStorageWalletConnectorConstructorOptions";
7
- export * from "./schema";
1
+ export * from "./entities/walletAddress.js";
2
+ export * from "./entityStorageFaucetConnector.js";
3
+ export * from "./entityStorageWalletConnector.js";
4
+ export * from "./models/IEntityStorageFaucetConnectorConstructorOptions.js";
5
+ export * from "./models/IEntityStorageWalletConnectorConfig.js";
6
+ export * from "./models/IEntityStorageWalletConnectorConstructorOptions.js";
7
+ export * from "./schema.js";
@@ -1,4 +1,4 @@
1
- import type { IEntityStorageWalletConnectorConfig } from "./IEntityStorageWalletConnectorConfig";
1
+ import type { IEntityStorageWalletConnectorConfig } from "./IEntityStorageWalletConnectorConfig.js";
2
2
  /**
3
3
  * Options for the entity storage wallet connector.
4
4
  */
package/docs/changelog.md CHANGED
@@ -1,5 +1,40 @@
1
1
  # @twin.org/wallet-connector-entity-storage - Changelog
2
2
 
3
+ ## [0.0.3-next.2](https://github.com/twinfoundation/wallet/compare/wallet-connector-entity-storage-v0.0.3-next.1...wallet-connector-entity-storage-v0.0.3-next.2) (2026-02-25)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * missing dependency ([6f02070](https://github.com/twinfoundation/wallet/commit/6f02070f3ad7d6dcdbbddd952c7d18a47386f15d))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/wallet-models bumped from 0.0.3-next.1 to 0.0.3-next.2
16
+
17
+ ## [0.0.3-next.1](https://github.com/twinfoundation/wallet/compare/wallet-connector-entity-storage-v0.0.3-next.0...wallet-connector-entity-storage-v0.0.3-next.1) (2025-11-11)
18
+
19
+
20
+ ### Features
21
+
22
+ * add context id features ([#46](https://github.com/twinfoundation/wallet/issues/46)) ([9389c28](https://github.com/twinfoundation/wallet/commit/9389c28084656666d04ed82575cbc8d3fa9f0d88))
23
+ * add validate-locales ([e5200c2](https://github.com/twinfoundation/wallet/commit/e5200c279de60592b64eeb64279fa8ed289a677f))
24
+ * eslint migration to flat config ([7068485](https://github.com/twinfoundation/wallet/commit/7068485f7c10121b76b6219798fdea4d3e91648a))
25
+ * iota rebased release ([d0c617d](https://github.com/twinfoundation/wallet/commit/d0c617d894f3663f7c80f7d53d2da858a0bd64f0))
26
+ * remove bech32 encoding for addresses ([869ef88](https://github.com/twinfoundation/wallet/commit/869ef8830eab0bcea6bc748f3bc637fc311e0709))
27
+ * update dependencies ([4b47a7d](https://github.com/twinfoundation/wallet/commit/4b47a7d900d72d1502d6db54cb391a954818478b))
28
+ * update framework core ([1c8a381](https://github.com/twinfoundation/wallet/commit/1c8a381e3c0544803a98db5560d87087fd095c23))
29
+ * use shared store mechanism ([#27](https://github.com/twinfoundation/wallet/issues/27)) ([2ba7861](https://github.com/twinfoundation/wallet/commit/2ba7861a2a610cf83396a3285c7bbaebe5a31551))
30
+
31
+
32
+ ### Dependencies
33
+
34
+ * The following workspace dependencies were updated
35
+ * dependencies
36
+ * @twin.org/wallet-models bumped from 0.0.3-next.0 to 0.0.3-next.1
37
+
3
38
  ## [0.0.2-next.5](https://github.com/twinfoundation/wallet/compare/wallet-connector-entity-storage-v0.0.2-next.4...wallet-connector-entity-storage-v0.0.2-next.5) (2025-10-09)
4
39
 
5
40
 
@@ -44,6 +44,24 @@ Runtime name for the class.
44
44
 
45
45
  ## Methods
46
46
 
47
+ ### className()
48
+
49
+ > **className**(): `string`
50
+
51
+ Returns the class name of the component.
52
+
53
+ #### Returns
54
+
55
+ `string`
56
+
57
+ The class name of the component.
58
+
59
+ #### Implementation of
60
+
61
+ `IFaucetConnector.className`
62
+
63
+ ***
64
+
47
65
  ### fundAddress()
48
66
 
49
67
  > **fundAddress**(`identity`, `address`, `timeoutInSeconds`): `Promise`\<`bigint`\>
@@ -44,6 +44,24 @@ The namespace supported by the wallet connector.
44
44
 
45
45
  ## Methods
46
46
 
47
+ ### className()
48
+
49
+ > **className**(): `string`
50
+
51
+ Returns the class name of the component.
52
+
53
+ #### Returns
54
+
55
+ `string`
56
+
57
+ The class name of the component.
58
+
59
+ #### Implementation of
60
+
61
+ `IWalletConnector.className`
62
+
63
+ ***
64
+
47
65
  ### create()
48
66
 
49
67
  > **create**(`identity`): `Promise`\<`void`\>
@@ -192,7 +210,7 @@ True if the balance has been ensured.
192
210
 
193
211
  ### transfer()
194
212
 
195
- > **transfer**(`identity`, `addressSource`, `addressDest`, `amount`): `Promise`\<`undefined` \| `string`\>
213
+ > **transfer**(`identity`, `addressSource`, `addressDest`, `amount`): `Promise`\<`string` \| `undefined`\>
196
214
 
197
215
  Transfer funds to an address.
198
216
 
@@ -224,7 +242,7 @@ The amount to transfer.
224
242
 
225
243
  #### Returns
226
244
 
227
- `Promise`\<`undefined` \| `string`\>
245
+ `Promise`\<`string` \| `undefined`\>
228
246
 
229
247
  An identifier for the transfer if there was one.
230
248
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/wallet-connector-entity-storage",
3
- "version": "0.0.2-next.5",
3
+ "version": "0.0.3-next.2",
4
4
  "description": "Wallet connector implementation using entity storage",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,22 +20,20 @@
20
20
  "@twin.org/entity-storage-models": "next",
21
21
  "@twin.org/nameof": "next",
22
22
  "@twin.org/vault-models": "next",
23
- "@twin.org/wallet-models": "0.0.2-next.5"
23
+ "@twin.org/wallet-models": "0.0.3-next.2"
24
24
  },
25
- "main": "./dist/cjs/index.cjs",
26
- "module": "./dist/esm/index.mjs",
25
+ "main": "./dist/es/index.js",
27
26
  "types": "./dist/types/index.d.ts",
28
27
  "exports": {
29
28
  ".": {
30
29
  "types": "./dist/types/index.d.ts",
31
- "require": "./dist/cjs/index.cjs",
32
- "import": "./dist/esm/index.mjs"
30
+ "import": "./dist/es/index.js",
31
+ "default": "./dist/es/index.js"
33
32
  },
34
33
  "./locales/*.json": "./locales/*.json"
35
34
  },
36
35
  "files": [
37
- "dist/cjs",
38
- "dist/esm",
36
+ "dist/es",
39
37
  "dist/types",
40
38
  "locales",
41
39
  "docs"
@@ -1,307 +0,0 @@
1
- 'use strict';
2
-
3
- var entity = require('@twin.org/entity');
4
- var core = require('@twin.org/core');
5
- var entityStorageModels = require('@twin.org/entity-storage-models');
6
- var crypto = require('@twin.org/crypto');
7
- var vaultModels = require('@twin.org/vault-models');
8
- var walletModels = require('@twin.org/wallet-models');
9
-
10
- // Copyright 2024 IOTA Stiftung.
11
- // SPDX-License-Identifier: Apache-2.0.
12
- /**
13
- * Class describing a wallet address.
14
- */
15
- exports.WalletAddress = class WalletAddress {
16
- /**
17
- * The address in the wallet.
18
- */
19
- address;
20
- /**
21
- * The identity of the owner.
22
- */
23
- identity;
24
- /**
25
- * The balance of the wallet as bigint.
26
- */
27
- balance;
28
- };
29
- __decorate([
30
- entity.property({ type: "string", isPrimary: true }),
31
- __metadata("design:type", String)
32
- ], exports.WalletAddress.prototype, "address", void 0);
33
- __decorate([
34
- entity.property({ type: "string" }),
35
- __metadata("design:type", String)
36
- ], exports.WalletAddress.prototype, "identity", void 0);
37
- __decorate([
38
- entity.property({ type: "string" }),
39
- __metadata("design:type", String)
40
- ], exports.WalletAddress.prototype, "balance", void 0);
41
- exports.WalletAddress = __decorate([
42
- entity.entity()
43
- ], exports.WalletAddress);
44
-
45
- // Copyright 2024 IOTA Stiftung.
46
- // SPDX-License-Identifier: Apache-2.0.
47
- /**
48
- * Class for performing faucet operations using entity storage.
49
- */
50
- class EntityStorageFaucetConnector {
51
- /**
52
- * The namespace supported by the wallet connector.
53
- */
54
- static NAMESPACE = "entity-storage";
55
- /**
56
- * Runtime name for the class.
57
- */
58
- static CLASS_NAME = "EntityStorageFaucetConnector";
59
- /**
60
- * The entity storage for wallets.
61
- * @internal
62
- */
63
- _walletAddressEntityStorage;
64
- /**
65
- * Create a new instance of EntityStorageFaucetConnector.
66
- * @param options The options for the wallet connector.
67
- */
68
- constructor(options) {
69
- this._walletAddressEntityStorage = entityStorageModels.EntityStorageConnectorFactory.get(options?.walletAddressEntityStorageType ?? "wallet-address");
70
- }
71
- /**
72
- * Fund the wallet from the faucet.
73
- * @param identity The identity of the user to access the vault keys.
74
- * @param address The hex encoded address of the address to fund.
75
- * @param timeoutInSeconds The timeout in seconds to wait for the funding to complete.
76
- * @returns The amount added to the address by the faucet.
77
- */
78
- async fundAddress(identity, address, timeoutInSeconds = 60) {
79
- core.Guards.stringValue(EntityStorageFaucetConnector.CLASS_NAME, "identity", identity);
80
- core.Guards.stringValue(EntityStorageFaucetConnector.CLASS_NAME, "address", address);
81
- let walletAddress = await this._walletAddressEntityStorage.get(address);
82
- if (core.Is.empty(walletAddress)) {
83
- walletAddress = {
84
- balance: "0",
85
- identity,
86
- address
87
- };
88
- }
89
- const maxFundAmount = 1000000000n;
90
- const balance = core.Coerce.bigint(walletAddress.balance) ?? 0n;
91
- walletAddress.balance = (balance + maxFundAmount).toString();
92
- await this._walletAddressEntityStorage.set(walletAddress);
93
- return maxFundAmount;
94
- }
95
- }
96
-
97
- // Copyright 2024 IOTA Stiftung.
98
- // SPDX-License-Identifier: Apache-2.0.
99
- /**
100
- * Class for performing wallet operations using in-memory storage.
101
- */
102
- class EntityStorageWalletConnector {
103
- /**
104
- * Runtime name for the class.
105
- */
106
- static CLASS_NAME = "EntityStorageWalletConnector";
107
- /**
108
- * The namespace supported by the wallet connector.
109
- */
110
- static NAMESPACE = "entity-storage";
111
- /**
112
- * Default name for the mnemonic secret.
113
- * @internal
114
- */
115
- static _DEFAULT_MNEMONIC_SECRET_NAME = "mnemonic";
116
- /**
117
- * Default coin type.
118
- * @internal
119
- */
120
- static _DEFAULT_COIN_TYPE = 9999;
121
- /**
122
- * Default network name.
123
- * @internal
124
- */
125
- static _DEFAULT_NETWORK_NAME = "ent";
126
- /**
127
- * The vault for the mnemonic.
128
- * @internal
129
- */
130
- _vaultConnector;
131
- /**
132
- * The faucet.
133
- * @internal
134
- */
135
- _faucetConnector;
136
- /**
137
- * The entity storage for wallets.
138
- * @internal
139
- */
140
- _walletAddressEntityStorage;
141
- /**
142
- * The configuration to use for tangle operations.
143
- * @internal
144
- */
145
- _config;
146
- /**
147
- * Create a new instance of EntityStorageWalletConnector.
148
- * @param options The options for the wallet connector.
149
- */
150
- constructor(options) {
151
- this._vaultConnector = vaultModels.VaultConnectorFactory.get(options?.vaultConnectorType ?? "vault");
152
- this._faucetConnector = walletModels.FaucetConnectorFactory.getIfExists(options?.faucetConnectorType ?? "faucet");
153
- this._walletAddressEntityStorage = entityStorageModels.EntityStorageConnectorFactory.get(options?.walletAddressEntityStorageType ?? "wallet-address");
154
- this._config = options?.config ?? {};
155
- this._config.coinType ??= EntityStorageWalletConnector._DEFAULT_COIN_TYPE;
156
- this._config.networkName ??= EntityStorageWalletConnector._DEFAULT_NETWORK_NAME;
157
- }
158
- /**
159
- * Create a new wallet.
160
- * @param identity The identity of the user to access the vault keys.
161
- * @returns Nothing.
162
- */
163
- async create(identity) {
164
- core.Guards.stringValue(EntityStorageWalletConnector.CLASS_NAME, "identity", identity);
165
- const mnemonic = crypto.Bip39.randomMnemonic();
166
- await this._vaultConnector.setSecret(this.buildMnemonicKey(identity), mnemonic);
167
- }
168
- /**
169
- * Get the addresses for the requested range.
170
- * @param identity The identity of the user to access the vault keys.
171
- * @param accountIndex The account index to get the addresses for.
172
- * @param startAddressIndex The start index for the addresses.
173
- * @param count The number of addresses to generate.
174
- * @returns The list of addresses.
175
- */
176
- async getAddresses(identity, accountIndex, startAddressIndex, count) {
177
- core.Guards.stringValue(EntityStorageWalletConnector.CLASS_NAME, "identity", identity);
178
- core.Guards.integer(EntityStorageWalletConnector.CLASS_NAME, "startAddressIndex", startAddressIndex);
179
- core.Guards.integer(EntityStorageWalletConnector.CLASS_NAME, "count", count);
180
- const mnemonic = await this._vaultConnector.getSecret(this.buildMnemonicKey(identity));
181
- const seed = crypto.Bip39.mnemonicToSeed(mnemonic);
182
- const keyPairs = [];
183
- for (let i = startAddressIndex; i < startAddressIndex + count; i++) {
184
- const addressKeyPair = crypto.Bip44.address(seed, crypto.KeyType.Ed25519, this._config.coinType ?? EntityStorageWalletConnector._DEFAULT_COIN_TYPE, accountIndex, false, i);
185
- keyPairs.push(addressKeyPair.address);
186
- }
187
- return keyPairs;
188
- }
189
- /**
190
- * Get the balance for an address in a wallet.
191
- * @param identity The identity of the user to access the vault keys.
192
- * @param address The hex encoded address.
193
- * @returns The balance of the wallet address.
194
- */
195
- async getBalance(identity, address) {
196
- core.Guards.stringValue(EntityStorageWalletConnector.CLASS_NAME, "address", address);
197
- const walletAddress = await this._walletAddressEntityStorage.get(address);
198
- return core.Coerce.bigint(walletAddress?.balance) ?? 0n;
199
- }
200
- /**
201
- * Ensure the balance for an address in a wallet.
202
- * @param identity The identity of the user to access the vault keys.
203
- * @param address The hex encoded address.
204
- * @param ensureBalance The balance to ensure on the address.
205
- * @param timeoutInSeconds The timeout in seconds to wait for the funding to complete.
206
- * @returns True if the balance has been ensured.
207
- */
208
- async ensureBalance(identity, address, ensureBalance, timeoutInSeconds) {
209
- core.Guards.stringValue(EntityStorageWalletConnector.CLASS_NAME, "identity", identity);
210
- core.Guards.stringValue(EntityStorageWalletConnector.CLASS_NAME, "address", address);
211
- core.Guards.bigint(EntityStorageWalletConnector.CLASS_NAME, "ensureBalance", ensureBalance);
212
- if (this._faucetConnector) {
213
- let retryCount = 10;
214
- let currentBalance = await this.getBalance(identity, address);
215
- while (currentBalance < ensureBalance && retryCount > 0) {
216
- const addedBalance = await this._faucetConnector.fundAddress(identity, address, timeoutInSeconds);
217
- if (addedBalance === 0n) {
218
- // The balance has not increased, so return.
219
- return false;
220
- }
221
- currentBalance += addedBalance;
222
- if (currentBalance < ensureBalance) {
223
- // The balance has increased but is still not enough, wait and try again.
224
- await new Promise(resolve => setTimeout(resolve, 100));
225
- retryCount--;
226
- }
227
- }
228
- return currentBalance >= ensureBalance;
229
- }
230
- return false;
231
- }
232
- /**
233
- * Transfer funds to an address.
234
- * @param identity The identity of the user to access the vault keys.
235
- * @param addressSource The hex encoded address to send the funds from.
236
- * @param addressDest The hex encoded address to send the funds to.
237
- * @param amount The amount to transfer.
238
- * @returns An identifier for the transfer if there was one.
239
- */
240
- async transfer(identity, addressSource, addressDest, amount) {
241
- core.Guards.stringValue(EntityStorageWalletConnector.CLASS_NAME, "identity", identity);
242
- core.Guards.stringValue(EntityStorageWalletConnector.CLASS_NAME, "addressSource", addressSource);
243
- core.Guards.stringValue(EntityStorageWalletConnector.CLASS_NAME, "addressDest", addressDest);
244
- core.Guards.bigint(EntityStorageWalletConnector.CLASS_NAME, "amount", amount);
245
- const walletAddresses = await this._walletAddressEntityStorage.query({
246
- logicalOperator: entity.LogicalOperator.And,
247
- conditions: [
248
- {
249
- property: "identity",
250
- comparison: entity.ComparisonOperator.Equals,
251
- value: identity
252
- },
253
- {
254
- property: "address",
255
- comparison: entity.ComparisonOperator.Equals,
256
- value: addressSource
257
- }
258
- ]
259
- });
260
- let walletAddress;
261
- let balance = 0n;
262
- if (walletAddresses.entities.length > 0) {
263
- walletAddress = walletAddresses.entities[0];
264
- balance = BigInt(walletAddress.balance);
265
- walletAddress.balance = (BigInt(walletAddress.balance) - amount).toString();
266
- }
267
- if (balance < amount) {
268
- throw new core.GeneralError(EntityStorageWalletConnector.CLASS_NAME, "insufficientFunds");
269
- }
270
- if (!core.Is.empty(walletAddress)) {
271
- await this._walletAddressEntityStorage.set(walletAddress);
272
- let destWalletAddress = await this._walletAddressEntityStorage.get(addressDest);
273
- if (core.Is.empty(destWalletAddress)) {
274
- destWalletAddress = {
275
- balance: "0",
276
- identity: "",
277
- address: addressDest
278
- };
279
- }
280
- destWalletAddress.balance = (BigInt(destWalletAddress.balance) + amount).toString();
281
- await this._walletAddressEntityStorage.set(destWalletAddress);
282
- }
283
- return undefined;
284
- }
285
- /**
286
- * Build the key name to access the mnemonic in the vault.
287
- * @param identity The identity of the user to access the vault keys.
288
- * @returns The vault key.
289
- * @internal
290
- */
291
- buildMnemonicKey(identity) {
292
- return `${identity}/${this._config.vaultMnemonicId ?? EntityStorageWalletConnector._DEFAULT_MNEMONIC_SECRET_NAME}`;
293
- }
294
- }
295
-
296
- // Copyright 2024 IOTA Stiftung.
297
- // SPDX-License-Identifier: Apache-2.0.
298
- /**
299
- * Initialize the schema for the wallet entity storage connector.
300
- */
301
- function initSchema() {
302
- entity.EntitySchemaFactory.register("WalletAddress", () => entity.EntitySchemaHelper.getSchema(exports.WalletAddress));
303
- }
304
-
305
- exports.EntityStorageFaucetConnector = EntityStorageFaucetConnector;
306
- exports.EntityStorageWalletConnector = EntityStorageWalletConnector;
307
- exports.initSchema = initSchema;