Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function setup(): Promise<{ mockStorage: MockStorage; requestLogic: RequestLogic }> {
const mockStorage = new MockStorage();
// Data access setup
const dataAccess = new DataAccess(mockStorage);
await dataAccess.initialize();
// Logic setup
return {
mockStorage,
requestLogic: new RequestLogic(
new TransactionManager(dataAccess),
signatureProvider,
advancedLogic,
),
};
}? new KeyvFile({
filename: initializationStoragePath,
})
: undefined;
// Use ethereum storage for the storage layer
const ethereumStorage: StorageTypes.IStorage = getEthereumStorage(
getMnemonic(),
this.logger,
store,
);
// Use an in-file Transaction index if a path is specified, an in-memory otherwise
const transactionIndex = new TransactionIndex(store);
this.dataAccess = new DataAccess(ethereumStorage, {
logger: this.logger,
transactionIndex,
});
this.express = express();
this.mountRoutes();
}(async (): Promise => {
// Data access setup
const dataAccess = new DataAccess(new MockStorage());
await dataAccess.initialize();
// A transaction manager, for example @requestnetwork/transaction-manager
const transactionManager: TransactionTypes.ITransactionManager = new TransactionManager(
dataAccess,
);
const requestLogic = new RequestLogic(transactionManager, signatureProvider);
const signerIdentity = {
type: IdentityTypes.TYPE.ETHEREUM_ADDRESS,
value: '0x627306090abab3a6e1400e9345bc60c78a8bef57',
};
// optionally, compute the request ID before actually creating it.
const requestId = await requestLogic.computeRequestId(createParams, signerIdentity);(async (): Promise => {
// Data access setup
const dataAccess = new DataAccess(new MockStorage());
await dataAccess.initialize();
// A transaction manager, for example @requestnetwork/transaction-manager
const transactionManager: TransactionTypes.ITransactionManager = new TransactionManager(
dataAccess,
decryptionProvider,
);
const requestLogic = new RequestLogic(transactionManager, signatureProvider);
const signerIdentity = {
type: IdentityTypes.TYPE.ETHEREUM_ADDRESS,
value: '0x627306090abab3a6e1400e9345bc60c78a8bef57',
};
// optionally, compute the request ID before actually creating it.const store = initializationStoragePath
? new KeyvFile({
filename: initializationStoragePath,
})
: undefined;
// Use ethereum storage for the storage layer
const ethereumStorage: StorageTypes.IStorage = getEthereumStorage(
getMnemonic(),
this.logger,
store,
);
// Use an in-file Transaction index if a path is specified, an in-memory otherwise
const transactionIndex = new TransactionIndex(store);
this.dataAccess = new DataAccess(ethereumStorage, {
logger: this.logger,
transactionIndex,
});
this.express = express();
this.mountRoutes();
}