Skip to content

Commit b1dcbca

Browse files
feat(satp-hermes): improve satp gateway configuration object
Signed-off-by: Tomas Silva <[email protected]>
1 parent 2af0e92 commit b1dcbca

File tree

26 files changed

+616
-528
lines changed

26 files changed

+616
-528
lines changed

packages/cactus-plugin-satp-hermes/README.md

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ Ethereum-compatible networks use Web3 signing credentials and contract addresses
371371
"networkId": "besu-mainnet",
372372
"connectorUrl": "https://besu-connector.example.com:4000",
373373
"web3SigningCredential": {
374-
"ethAccount": "${ETH_ACCOUNT}",
374+
"bridgeOwnerAddress": "${ETH_ACCOUNT}",
375375
"secret": "${ETH_PRIVATE_KEY}",
376376
"type": "PRIVATE_KEY_HEX"
377377
},
@@ -381,7 +381,9 @@ Ethereum-compatible networks use Web3 signing credentials and contract addresses
381381
"http": "https://mainnet.infura.io/v3/${PROJECT_ID}",
382382
"ws": "wss://mainnet.infura.io/ws/v3/${PROJECT_ID}"
383383
},
384-
"gasLimit": 3000000
384+
"gasConfig": {
385+
"gasLimit": "3000000"
386+
}
385387
}
386388
}
387389
```
@@ -613,11 +615,13 @@ const leafConfig = {
613615
ledgerType: "BESU_2X" // Ledger type constant for Besu 2.x
614616
},
615617
signingCredential: {
616-
ethAccount: "0x736dC9B8258Ec5ab2419DDdffA9e1fa5C201D0b4", // Ethereum account address
618+
bridgeOwnerAddress: "0x736dC9B8258Ec5ab2419DDdffA9e1fa5C201D0b4", // Ethereum account address of the owner of the bridge
617619
secret: "0xc31e76f70d6416337d3a7b7a8711a43e30a14963b5ba622fa6c9dbb5b4555986", // Private key in hex
618620
type: "PRIVATE_KEY_HEX"
619621
},
620-
gas: 999999999999999, // Default gas limit for transactions
622+
gasConfig: {
623+
gasLimit: "6000000", // Default gas limit for transactions
624+
},
621625
connectorOptions: {
622626
rpcApiHttpHost: "http://172.20.0.6:8545", // Besu JSON-RPC HTTP endpoint
623627
rpcApiWsHost: "ws://172.20.0.6:8546" // Besu JSON-RPC WebSocket endpoint
@@ -635,11 +639,15 @@ const leafConfig = {
635639
ledgerType: "ETHEREUM" // Ledger type constant for Ethereum
636640
},
637641
signingCredential: {
638-
ethAccount: "0x09D16c22216BC873e53c8D93A38420f48A81dF1B", // Ethereum account address
642+
bridgeOwnerAddress: "0x09D16c22216BC873e53c8D93A38420f48A81dF1B", // Ethereum account address
639643
secret: "test", // Key store password or secret
640644
type: "GETH_KEYCHAIN_PASSWORD" // Credential type for geth keychain
641645
},
642-
gas: 5000000, // Default gas limit for transactions
646+
gasConfig: {
647+
gas: "6721975", // Default gas limit for transactions
648+
gasPrice: "20000000000" // Default gas Price
649+
}
650+
643651
connectorOptions: {
644652
rpcApiHttpHost: "http://172.20.0.7:8545", // Ethereum JSON-RPC HTTP endpoint
645653
rpcApiWsHost: "ws://172.20.0.7:8546" // Ethereum JSON-RPC WebSocket endpoint
@@ -656,6 +664,10 @@ const gatewayConfig = {
656664
gid: {
657665
id: "gatewayId",
658666
name: "GatewayWithBesuConnection",
667+
identificationCredential: {
668+
signingAlgorithm: "SECP256K1",
669+
pubKey: "0x03a34e1d66b78e47fa1bba3445a6019acb5b9c87d0c6ad81c09e7d496682ae81fc",
670+
}
659671
version: [{ Core: "v02", Architecture: "v02", Crash: "v02" }],
660672
proofID: "mockProofID10",
661673
address: "http://gateway1.satp-hermes",
@@ -675,11 +687,13 @@ const gatewayConfig = {
675687
ledgerType: "BESU_2X",
676688
},
677689
signingCredential: {
678-
ethAccount: "0x736dC9B8258Ec5ab2419DDdffA9e1fa5C201D0b4",
690+
bridgeOwnerAddress: "0x736dC9B8258Ec5ab2419DDdffA9e1fa5C201D0b4",
679691
secret: "0xc31e76f70d6416337d3a7b7a8711a43e30a14963b5ba622fa6c9dbb5b4555986",
680692
type: "PRIVATE_KEY_HEX",
681693
},
682-
gas: 999999999999999,
694+
gasConfig: {
695+
gasLimit: "6000000",
696+
},
683697
connectorOptions: {
684698
rpcApiHttpHost: "http://172.20.0.6:8545",
685699
rpcApiWsHost: "ws://172.20.0.6:8546",

packages/cactus-plugin-satp-hermes/src/main/typescript/core/types.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,30 @@ export type Address =
140140
| `https://${string}`
141141
| `${number}.${number}.${number}.${number}`;
142142

143+
/**
144+
* Enumeration of supported signing algorithms.
145+
*
146+
* @description
147+
* Defines the cryptographic signing algorithms supported for
148+
* gateway identification credentials.
149+
*/
150+
export enum SupportedSigningAlgorithms {
151+
SECP256K1 = "SECP256K1",
152+
}
153+
154+
/**
155+
* Identification credential structure for gateways.
156+
*
157+
* @description
158+
* Defines the structure for gateway identification credentials
159+
* including the signing algorithm used for key generation and
160+
* the respective public key.
161+
*/
162+
export type IdentificationCredential = {
163+
signingAlgorithm: SupportedSigningAlgorithms;
164+
pubKey: string;
165+
};
166+
143167
/**
144168
* SATP gateway identity structure.
145169
*
@@ -150,8 +174,8 @@ export type Address =
150174
export type GatewayIdentity = {
151175
/** Unique gateway identifier */
152176
id: string;
153-
/** Optional public key for cryptographic operations */
154-
pubKey?: string;
177+
/** Optional identification credential for the gateway*/
178+
identificationCredential?: IdentificationCredential;
155179
/** Optional human-readable gateway name */
156180
name?: string;
157181
/** Supported SATP draft versions */

packages/cactus-plugin-satp-hermes/src/main/typescript/cross-chain-mechanisms/bridge/bridge-manager.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,14 @@ import { SATPLoggerProvider as LoggerProvider } from "../../core/satp-logger-pro
4040
import { SATPLogger as Logger } from "../../core/satp-logger";
4141
import { BridgeLeaf } from "./bridge-leaf";
4242
import { LedgerType } from "@hyperledger/cactus-core-api";
43-
import { BesuLeaf, IBesuLeafNeworkOptions } from "./leafs/besu-leaf";
43+
import { BesuLeaf } from "./leafs/besu-leaf";
4444
import {
4545
DeployLeafError,
4646
LeafError,
4747
UnsupportedNetworkError,
4848
WrapperContractAlreadyCreatedError,
4949
} from "../common/errors";
50-
import {
51-
EthereumLeaf,
52-
IEthereumLeafNeworkOptions,
53-
} from "./leafs/ethereum-leaf";
50+
import { EthereumLeaf } from "./leafs/ethereum-leaf";
5451
import { FabricLeaf, IFabricLeafNeworkOptions } from "./leafs/fabric-leaf";
5552
import { BridgeManagerAdminInterface } from "./interfaces/bridge-manager-admin-interface";
5653
import { BridgeManagerClientInterface } from "./interfaces/bridge-manager-client-interface";
@@ -60,7 +57,11 @@ import {
6057
} from "../../generated/proto/cacti/satp/v02/common/message_pb";
6158
import { SATPBridgeExecutionLayer } from "./satp-bridge-execution-layer";
6259
import { SATPBridgeExecutionLayerImpl } from "./satp-bridge-execution-layer-implementation";
63-
import { INetworkOptions } from "./bridge-types";
60+
import {
61+
IBesuNetworkConfig,
62+
IEthereumNetworkConfig,
63+
INetworkOptions,
64+
} from "./bridge-types";
6465
import {
6566
IOntologyManagerOptions,
6667
OntologyManager,
@@ -185,7 +186,7 @@ export class BridgeManager
185186
)}`,
186187
);
187188
const besuNetworkOptions =
188-
leafNetworkOptions as unknown as IBesuLeafNeworkOptions;
189+
leafNetworkOptions as unknown as IBesuNetworkConfig;
189190
if (!this.ontologyManager) {
190191
throw new Error(`${fnTag}, Ontology Manager is not defined`);
191192
}
@@ -215,7 +216,7 @@ export class BridgeManager
215216
)}`,
216217
);
217218
const ethereumNetworkOptions =
218-
leafNetworkOptions as unknown as IEthereumLeafNeworkOptions;
219+
leafNetworkOptions as unknown as IEthereumNetworkConfig;
219220
if (!this.ontologyManager) {
220221
throw new Error(`${fnTag}, Ontology Manager is not defined`);
221222
}

0 commit comments

Comments
 (0)