@twin.org/engine 0.0.1-next.80 → 0.0.1-next.81

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.
@@ -138,6 +138,7 @@ function buildEngineConfiguration(envVars) {
138
138
  configureEntityStorage(coreConfig, envVars);
139
139
  configureBlobStorage(coreConfig, envVars);
140
140
  configureVault(coreConfig, envVars);
141
+ configureDlt(coreConfig, envVars);
141
142
  configureLogging(coreConfig, envVars);
142
143
  configureBackgroundTask(coreConfig, envVars);
143
144
  configureEventBus(coreConfig, envVars);
@@ -160,6 +161,15 @@ function buildEngineConfiguration(envVars) {
160
161
  configureTaskScheduler(coreConfig, envVars);
161
162
  return coreConfig;
162
163
  }
164
+ /**
165
+ * Helper function to get IOTA configuration from centralized dltConfig.
166
+ * @param coreConfig The core config.
167
+ * @returns The IOTA configuration if found, undefined otherwise.
168
+ */
169
+ function getIotaConfig(coreConfig) {
170
+ const dltConfig = coreConfig.types.dltConfig?.find(config => config.type === engineTypes.DltConfigType.Iota && config.isDefault);
171
+ return dltConfig?.options?.config;
172
+ }
163
173
  /**
164
174
  * Configures the entity storage.
165
175
  * @param coreConfig The core config.
@@ -612,16 +622,14 @@ function configureFaucet(coreConfig, envVars) {
612
622
  });
613
623
  }
614
624
  else if (envVars.faucetConnector === engineTypes.FaucetConnectorType.Iota) {
625
+ const iotaConfig = getIotaConfig(coreConfig);
615
626
  coreConfig.types.faucetConnector.push({
616
627
  type: engineTypes.FaucetConnectorType.Iota,
617
628
  options: {
618
629
  config: {
619
630
  endpoint: envVars.iotaFaucetEndpoint ?? "",
620
- clientOptions: {
621
- url: envVars.iotaNodeEndpoint ?? ""
622
- },
623
- network: envVars.iotaNetwork ?? "",
624
- coinType: core.Coerce.number(envVars.iotaCoinType)
631
+ clientOptions: iotaConfig?.clientOptions ?? { url: "" },
632
+ network: iotaConfig?.network ?? ""
625
633
  }
626
634
  }
627
635
  });
@@ -640,16 +648,11 @@ function configureWallet(coreConfig, envVars) {
640
648
  });
641
649
  }
642
650
  else if (envVars.walletConnector === engineTypes.WalletConnectorType.Iota) {
651
+ const iotaConfig = getIotaConfig(coreConfig);
643
652
  coreConfig.types.walletConnector.push({
644
653
  type: engineTypes.WalletConnectorType.Iota,
645
654
  options: {
646
- config: {
647
- clientOptions: {
648
- url: envVars.iotaNodeEndpoint ?? ""
649
- },
650
- network: envVars.iotaNetwork ?? "",
651
- coinType: core.Coerce.number(envVars.iotaCoinType)
652
- }
655
+ config: iotaConfig ?? {}
653
656
  }
654
657
  });
655
658
  }
@@ -667,16 +670,11 @@ function configureNft(coreConfig, envVars) {
667
670
  });
668
671
  }
669
672
  else if (envVars.nftConnector === engineTypes.NftConnectorType.Iota) {
673
+ const iotaConfig = getIotaConfig(coreConfig);
670
674
  coreConfig.types.nftConnector.push({
671
675
  type: engineTypes.NftConnectorType.Iota,
672
676
  options: {
673
- config: {
674
- clientOptions: {
675
- url: envVars.iotaNodeEndpoint ?? ""
676
- },
677
- network: envVars.iotaNetwork ?? "",
678
- coinType: core.Coerce.number(envVars.iotaCoinType)
679
- }
677
+ config: iotaConfig ?? {}
680
678
  }
681
679
  });
682
680
  }
@@ -698,16 +696,11 @@ function configureVerifiableStorage(coreConfig, envVars) {
698
696
  });
699
697
  }
700
698
  else if (envVars.verifiableStorageConnector === engineTypes.VerifiableStorageConnectorType.Iota) {
699
+ const iotaConfig = getIotaConfig(coreConfig);
701
700
  coreConfig.types.verifiableStorageConnector.push({
702
701
  type: engineTypes.VerifiableStorageConnectorType.Iota,
703
702
  options: {
704
- config: {
705
- clientOptions: {
706
- url: envVars.iotaNodeEndpoint ?? ""
707
- },
708
- network: envVars.iotaNetwork ?? "",
709
- coinType: core.Coerce.number(envVars.iotaCoinType)
710
- }
703
+ config: iotaConfig ?? {}
711
704
  }
712
705
  });
713
706
  }
@@ -748,16 +741,11 @@ function configureIdentity(coreConfig, envVars) {
748
741
  });
749
742
  }
750
743
  else if (envVars.identityConnector === engineTypes.IdentityConnectorType.Iota) {
744
+ const iotaConfig = getIotaConfig(coreConfig);
751
745
  coreConfig.types.identityConnector.push({
752
746
  type: engineTypes.IdentityConnectorType.Iota,
753
747
  options: {
754
- config: {
755
- clientOptions: {
756
- url: envVars.iotaNodeEndpoint ?? ""
757
- },
758
- network: envVars.iotaNetwork ?? "",
759
- coinType: core.Coerce.number(envVars.iotaCoinType)
760
- }
748
+ config: iotaConfig ?? {}
761
749
  }
762
750
  });
763
751
  }
@@ -779,16 +767,11 @@ function configureIdentityResolver(coreConfig, envVars) {
779
767
  });
780
768
  }
781
769
  else if (envVars.identityResolverConnector === engineTypes.IdentityResolverConnectorType.Iota) {
770
+ const iotaConfig = getIotaConfig(coreConfig);
782
771
  coreConfig.types.identityResolverConnector.push({
783
772
  type: engineTypes.IdentityResolverConnectorType.Iota,
784
773
  options: {
785
- config: {
786
- clientOptions: {
787
- url: envVars.iotaNodeEndpoint ?? ""
788
- },
789
- network: envVars.iotaNetwork ?? "",
790
- coinType: core.Coerce.number(envVars.iotaCoinType)
791
- }
774
+ config: iotaConfig ?? {}
792
775
  }
793
776
  });
794
777
  }
@@ -975,6 +958,38 @@ function configureTaskScheduler(coreConfig, envVars) {
975
958
  });
976
959
  }
977
960
  }
961
+ /**
962
+ * Configures the DLT.
963
+ * @param coreConfig The core config.
964
+ * @param envVars The environment variables.
965
+ */
966
+ function configureDlt(coreConfig, envVars) {
967
+ // Create centralized DLT configuration for IOTA if essential IOTA variables are set
968
+ if (core.Is.stringValue(envVars.iotaNodeEndpoint) && core.Is.stringValue(envVars.iotaNetwork)) {
969
+ coreConfig.types.dltConfig ??= [];
970
+ const gasStationConfig = core.Is.stringValue(envVars.iotaGasStationEndpoint) &&
971
+ core.Is.stringValue(envVars.iotaGasStationAuthToken)
972
+ ? {
973
+ gasStationUrl: envVars.iotaGasStationEndpoint,
974
+ gasStationAuthToken: envVars.iotaGasStationAuthToken
975
+ }
976
+ : undefined;
977
+ coreConfig.types.dltConfig.push({
978
+ type: engineTypes.DltConfigType.Iota,
979
+ isDefault: true,
980
+ options: {
981
+ config: {
982
+ clientOptions: {
983
+ url: envVars.iotaNodeEndpoint ?? ""
984
+ },
985
+ network: envVars.iotaNetwork ?? "",
986
+ coinType: core.Coerce.number(envVars.iotaCoinType),
987
+ gasStation: gasStationConfig
988
+ }
989
+ }
990
+ });
991
+ }
992
+ }
978
993
 
979
994
  exports.Engine = Engine;
980
995
  exports.EngineConfigHelper = EngineConfigHelper;
@@ -1,6 +1,6 @@
1
1
  import { EngineCore } from '@twin.org/engine-core';
2
2
  import { Guards, StringHelper, Is, Coerce } from '@twin.org/core';
3
- import { EntityStorageComponentType, EntityStorageConnectorType, BlobStorageConnectorType, BlobStorageComponentType, VaultConnectorType, LoggingConnectorType, LoggingComponentType, BackgroundTaskConnectorType, EventBusConnectorType, EventBusComponentType, TelemetryConnectorType, TelemetryComponentType, MessagingEmailConnectorType, MessagingSmsConnectorType, MessagingPushNotificationConnectorType, MessagingComponentType, FaucetConnectorType, WalletConnectorType, NftConnectorType, NftComponentType, VerifiableStorageConnectorType, VerifiableStorageComponentType, ImmutableProofComponentType, AuditableItemGraphComponentType, AuditableItemStreamComponentType, IdentityConnectorType, IdentityComponentType, IdentityResolverConnectorType, IdentityResolverComponentType, IdentityProfileConnectorType, IdentityProfileComponentType, AttestationConnectorType, AttestationComponentType, DataConverterConnectorType, DataExtractorConnectorType, DataProcessingComponentType, DocumentManagementComponentType, FederatedCatalogueComponentType, RightsManagementPapComponentType, RightsManagementComponentType, TaskSchedulerComponentType } from '@twin.org/engine-types';
3
+ import { EntityStorageComponentType, EntityStorageConnectorType, BlobStorageConnectorType, BlobStorageComponentType, VaultConnectorType, DltConfigType, LoggingConnectorType, LoggingComponentType, BackgroundTaskConnectorType, EventBusConnectorType, EventBusComponentType, TelemetryConnectorType, TelemetryComponentType, MessagingEmailConnectorType, MessagingSmsConnectorType, MessagingPushNotificationConnectorType, MessagingComponentType, FaucetConnectorType, WalletConnectorType, NftConnectorType, NftComponentType, VerifiableStorageConnectorType, VerifiableStorageComponentType, ImmutableProofComponentType, AuditableItemGraphComponentType, AuditableItemStreamComponentType, IdentityConnectorType, IdentityComponentType, IdentityResolverConnectorType, IdentityResolverComponentType, IdentityProfileConnectorType, IdentityProfileComponentType, AttestationConnectorType, AttestationComponentType, DataConverterConnectorType, DataExtractorConnectorType, DataProcessingComponentType, DocumentManagementComponentType, FederatedCatalogueComponentType, RightsManagementPapComponentType, RightsManagementComponentType, TaskSchedulerComponentType } from '@twin.org/engine-types';
4
4
  import { EntitySchemaFactory } from '@twin.org/entity';
5
5
  import path from 'node:path';
6
6
 
@@ -136,6 +136,7 @@ function buildEngineConfiguration(envVars) {
136
136
  configureEntityStorage(coreConfig, envVars);
137
137
  configureBlobStorage(coreConfig, envVars);
138
138
  configureVault(coreConfig, envVars);
139
+ configureDlt(coreConfig, envVars);
139
140
  configureLogging(coreConfig, envVars);
140
141
  configureBackgroundTask(coreConfig, envVars);
141
142
  configureEventBus(coreConfig, envVars);
@@ -158,6 +159,15 @@ function buildEngineConfiguration(envVars) {
158
159
  configureTaskScheduler(coreConfig, envVars);
159
160
  return coreConfig;
160
161
  }
162
+ /**
163
+ * Helper function to get IOTA configuration from centralized dltConfig.
164
+ * @param coreConfig The core config.
165
+ * @returns The IOTA configuration if found, undefined otherwise.
166
+ */
167
+ function getIotaConfig(coreConfig) {
168
+ const dltConfig = coreConfig.types.dltConfig?.find(config => config.type === DltConfigType.Iota && config.isDefault);
169
+ return dltConfig?.options?.config;
170
+ }
161
171
  /**
162
172
  * Configures the entity storage.
163
173
  * @param coreConfig The core config.
@@ -610,16 +620,14 @@ function configureFaucet(coreConfig, envVars) {
610
620
  });
611
621
  }
612
622
  else if (envVars.faucetConnector === FaucetConnectorType.Iota) {
623
+ const iotaConfig = getIotaConfig(coreConfig);
613
624
  coreConfig.types.faucetConnector.push({
614
625
  type: FaucetConnectorType.Iota,
615
626
  options: {
616
627
  config: {
617
628
  endpoint: envVars.iotaFaucetEndpoint ?? "",
618
- clientOptions: {
619
- url: envVars.iotaNodeEndpoint ?? ""
620
- },
621
- network: envVars.iotaNetwork ?? "",
622
- coinType: Coerce.number(envVars.iotaCoinType)
629
+ clientOptions: iotaConfig?.clientOptions ?? { url: "" },
630
+ network: iotaConfig?.network ?? ""
623
631
  }
624
632
  }
625
633
  });
@@ -638,16 +646,11 @@ function configureWallet(coreConfig, envVars) {
638
646
  });
639
647
  }
640
648
  else if (envVars.walletConnector === WalletConnectorType.Iota) {
649
+ const iotaConfig = getIotaConfig(coreConfig);
641
650
  coreConfig.types.walletConnector.push({
642
651
  type: WalletConnectorType.Iota,
643
652
  options: {
644
- config: {
645
- clientOptions: {
646
- url: envVars.iotaNodeEndpoint ?? ""
647
- },
648
- network: envVars.iotaNetwork ?? "",
649
- coinType: Coerce.number(envVars.iotaCoinType)
650
- }
653
+ config: iotaConfig ?? {}
651
654
  }
652
655
  });
653
656
  }
@@ -665,16 +668,11 @@ function configureNft(coreConfig, envVars) {
665
668
  });
666
669
  }
667
670
  else if (envVars.nftConnector === NftConnectorType.Iota) {
671
+ const iotaConfig = getIotaConfig(coreConfig);
668
672
  coreConfig.types.nftConnector.push({
669
673
  type: NftConnectorType.Iota,
670
674
  options: {
671
- config: {
672
- clientOptions: {
673
- url: envVars.iotaNodeEndpoint ?? ""
674
- },
675
- network: envVars.iotaNetwork ?? "",
676
- coinType: Coerce.number(envVars.iotaCoinType)
677
- }
675
+ config: iotaConfig ?? {}
678
676
  }
679
677
  });
680
678
  }
@@ -696,16 +694,11 @@ function configureVerifiableStorage(coreConfig, envVars) {
696
694
  });
697
695
  }
698
696
  else if (envVars.verifiableStorageConnector === VerifiableStorageConnectorType.Iota) {
697
+ const iotaConfig = getIotaConfig(coreConfig);
699
698
  coreConfig.types.verifiableStorageConnector.push({
700
699
  type: VerifiableStorageConnectorType.Iota,
701
700
  options: {
702
- config: {
703
- clientOptions: {
704
- url: envVars.iotaNodeEndpoint ?? ""
705
- },
706
- network: envVars.iotaNetwork ?? "",
707
- coinType: Coerce.number(envVars.iotaCoinType)
708
- }
701
+ config: iotaConfig ?? {}
709
702
  }
710
703
  });
711
704
  }
@@ -746,16 +739,11 @@ function configureIdentity(coreConfig, envVars) {
746
739
  });
747
740
  }
748
741
  else if (envVars.identityConnector === IdentityConnectorType.Iota) {
742
+ const iotaConfig = getIotaConfig(coreConfig);
749
743
  coreConfig.types.identityConnector.push({
750
744
  type: IdentityConnectorType.Iota,
751
745
  options: {
752
- config: {
753
- clientOptions: {
754
- url: envVars.iotaNodeEndpoint ?? ""
755
- },
756
- network: envVars.iotaNetwork ?? "",
757
- coinType: Coerce.number(envVars.iotaCoinType)
758
- }
746
+ config: iotaConfig ?? {}
759
747
  }
760
748
  });
761
749
  }
@@ -777,16 +765,11 @@ function configureIdentityResolver(coreConfig, envVars) {
777
765
  });
778
766
  }
779
767
  else if (envVars.identityResolverConnector === IdentityResolverConnectorType.Iota) {
768
+ const iotaConfig = getIotaConfig(coreConfig);
780
769
  coreConfig.types.identityResolverConnector.push({
781
770
  type: IdentityResolverConnectorType.Iota,
782
771
  options: {
783
- config: {
784
- clientOptions: {
785
- url: envVars.iotaNodeEndpoint ?? ""
786
- },
787
- network: envVars.iotaNetwork ?? "",
788
- coinType: Coerce.number(envVars.iotaCoinType)
789
- }
772
+ config: iotaConfig ?? {}
790
773
  }
791
774
  });
792
775
  }
@@ -973,5 +956,37 @@ function configureTaskScheduler(coreConfig, envVars) {
973
956
  });
974
957
  }
975
958
  }
959
+ /**
960
+ * Configures the DLT.
961
+ * @param coreConfig The core config.
962
+ * @param envVars The environment variables.
963
+ */
964
+ function configureDlt(coreConfig, envVars) {
965
+ // Create centralized DLT configuration for IOTA if essential IOTA variables are set
966
+ if (Is.stringValue(envVars.iotaNodeEndpoint) && Is.stringValue(envVars.iotaNetwork)) {
967
+ coreConfig.types.dltConfig ??= [];
968
+ const gasStationConfig = Is.stringValue(envVars.iotaGasStationEndpoint) &&
969
+ Is.stringValue(envVars.iotaGasStationAuthToken)
970
+ ? {
971
+ gasStationUrl: envVars.iotaGasStationEndpoint,
972
+ gasStationAuthToken: envVars.iotaGasStationAuthToken
973
+ }
974
+ : undefined;
975
+ coreConfig.types.dltConfig.push({
976
+ type: DltConfigType.Iota,
977
+ isDefault: true,
978
+ options: {
979
+ config: {
980
+ clientOptions: {
981
+ url: envVars.iotaNodeEndpoint ?? ""
982
+ },
983
+ network: envVars.iotaNetwork ?? "",
984
+ coinType: Coerce.number(envVars.iotaCoinType),
985
+ gasStation: gasStationConfig
986
+ }
987
+ }
988
+ });
989
+ }
990
+ }
976
991
 
977
992
  export { Engine, EngineConfigHelper, buildEngineConfiguration };
@@ -334,6 +334,14 @@ export interface IEngineEnvironmentVariables {
334
334
  * IOTA Explorer Endpoint.
335
335
  */
336
336
  iotaExplorerEndpoint?: string;
337
+ /**
338
+ * IOTA Gas Station Endpoint.
339
+ */
340
+ iotaGasStationEndpoint?: string;
341
+ /**
342
+ * IOTA Gas Station Authentication Token.
343
+ */
344
+ iotaGasStationAuthToken?: string;
337
345
  /**
338
346
  * Universal Resolver Endpoint.
339
347
  */
package/docs/changelog.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @twin.org/engine - Changelog
2
2
 
3
+ ## [0.0.1-next.81](https://github.com/twinfoundation/engine/compare/engine-v0.0.1-next.80...engine-v0.0.1-next.81) (2025-07-07)
4
+
5
+
6
+ ### Features
7
+
8
+ * gas station integration ([#17](https://github.com/twinfoundation/engine/issues/17)) ([a3f844a](https://github.com/twinfoundation/engine/commit/a3f844a7fc58c43b4d0700d8d4351062045e66e1))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/engine-core bumped from 0.0.1-next.80 to 0.0.1-next.81
16
+ * @twin.org/engine-types bumped from 0.0.1-next.80 to 0.0.1-next.81
17
+
3
18
  ## [0.0.1-next.80](https://github.com/twinfoundation/engine/compare/engine-v0.0.1-next.79...engine-v0.0.1-next.80) (2025-06-23)
4
19
 
5
20
 
package/docs/examples.md CHANGED
@@ -1 +1,35 @@
1
1
  # @twin.org/engine - Examples
2
+
3
+ ## Environment Variables
4
+
5
+ The engine supports various environment variables for configuration. Here are some key examples:
6
+
7
+ ### IOTA DLT Configuration
8
+
9
+ Basic IOTA configuration:
10
+
11
+ ```bash
12
+ # IOTA Node Configuration
13
+ IOTA_NODE_ENDPOINT="https://api.devnet.iota.cafe"
14
+ IOTA_FAUCET_ENDPOINT="https://faucet.devnet.iota.cafe"
15
+ IOTA_EXPLORER_ENDPOINT="https://explorer.iota.org/"
16
+ IOTA_NETWORK="devnet"
17
+ IOTA_COIN_TYPE="4218"
18
+ ```
19
+
20
+ ### IOTA Gas Station Configuration (Optional)
21
+
22
+ The IOTA Gas Station pattern allows for sponsored transactions and improved UX:
23
+
24
+ ```bash
25
+ # Gas Station Configuration
26
+ IOTA_GAS_STATION_ENDPOINT="https://gas-station.example.com"
27
+ IOTA_GAS_STATION_AUTH_TOKEN="your-auth-token"
28
+ ```
29
+
30
+ **Configuration Options:**
31
+
32
+ - `IOTA_GAS_STATION_ENDPOINT`: The URL of the gas station service
33
+ - `IOTA_GAS_STATION_AUTH_TOKEN`: Authentication token for the gas station
34
+
35
+ When gas station is configured, all IOTA-related connectors (wallet, nft, verifiable-storage, identity, identity-resolver) will automatically use the centralized configuration and have access to gas station functionality.
@@ -668,6 +668,22 @@ IOTA Explorer Endpoint.
668
668
 
669
669
  ***
670
670
 
671
+ ### iotaGasStationEndpoint?
672
+
673
+ > `optional` **iotaGasStationEndpoint**: `string`
674
+
675
+ IOTA Gas Station Endpoint.
676
+
677
+ ***
678
+
679
+ ### iotaGasStationAuthToken?
680
+
681
+ > `optional` **iotaGasStationAuthToken**: `string`
682
+
683
+ IOTA Gas Station Authentication Token.
684
+
685
+ ***
686
+
671
687
  ### universalResolverEndpoint?
672
688
 
673
689
  > `optional` **universalResolverEndpoint**: `string`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/engine",
3
- "version": "0.0.1-next.80",
3
+ "version": "0.0.1-next.81",
4
4
  "description": "Engine implementation.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -15,8 +15,8 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "@twin.org/core": "next",
18
- "@twin.org/engine-core": "0.0.1-next.80",
19
- "@twin.org/engine-types": "0.0.1-next.80",
18
+ "@twin.org/engine-core": "0.0.1-next.81",
19
+ "@twin.org/engine-types": "0.0.1-next.81",
20
20
  "@twin.org/entity": "next"
21
21
  },
22
22
  "main": "./dist/cjs/index.cjs",