0.33.0 • Published 5 days ago

@requestnetwork/transaction-manager v0.33.0

Weekly downloads
121
License
MIT
Repository
github
Last release
5 days ago

@requestnetwork/transaction-manager

@requestnetwork/transaction-manager is a typescript library part of the Request Network protocol. It is the default implementation of the Transaction layer. It creates transactions to be sent to Data Access. When privacy is implemented, this package will handle the encryption

Installation

npm install @requestnetwork/transaction-manager

Usage

Note on the decryption provider

In order to decrypt encrypted transactions, you must provide a decryption provider. You can see the specification of decryption provider here.

An example of implementation of a decryption provider is available in the package: epk-decryption

import EthereumPrivateKeyDecryptionProvider from '@requestnetwork/epk-decryption';
import { TransactionManager } from '@requestnetwork/transaction-manager';

// Decryption provider setup
const decryptionProvider = new EthereumPrivateKeyDecryptionProvider({
  key: '0x04674d2e53e0e14653487d7323cc5f0a7959c83067f5654cafe4094bde90fa8a',
  method: EncryptionTypes.METHOD.ECIES,
});

// Potentially add another decryption key
decryptionProvider.addDecryptionParameters({
  key: '0x0906ff14227cead2b25811514302d57706e7d5013fcc40eca5985b216baeb998',
  method: EncryptionTypes.METHOD.ECIES,
});

const transactionManager = new TransactionManager(dataAccess, decryptionProvider);

Persist a clear transaction

import { DataAccessTypes, SignatureTypes } from '@requestnetwork/types';
import { TransactionManager } from '@requestnetwork/transaction-manager';

const dataAccess: DataAccessTypes.IDataAccess; // A Data Access implementation, for example @requestnetwork/data-access

const transactionManager = new TransactionManager(dataAccess);

const data = '{ what: "ever", it: "is,", this: "must", work: true }';
const channelId = 'myRequest';
const channelTopics = ['stakeholder1','stakeholder2'];

const { result } = await transactionManager.persistTransaction(data, channelId, channelTopics);

Persist an encrypted transaction

import { DataAccessTypes, SignatureTypes } from '@requestnetwork/types';
import { TransactionManager } from '@requestnetwork/transaction-manager';

const dataAccess: DataAccessTypes.IDataAccess; // A Data Access implementation, for example @requestnetwork/data-access

const transactionManager = new TransactionManager(dataAccess, decryptionProvider);

const data = '{ what: "ever", it: "is,", this: "must", work: true }';
const channelId = 'myRequest';
const channelTopics = ['stakeholder1','stakeholder2'];
const encryptionParameters: EncryptionTypes.IEncryptionParameters[] = [
  {
    key:
      '299708c07399c9b28e9870c4e643742f65c94683f35d1b3fc05d0478344ee0cc5a6a5e23f78b5ff8c93a04254232b32350c8672d2873677060d5095184dad422',
    method: EncryptionTypes.METHOD.ECIES,
  },
  {
    key:
      '9008306d319755055226827c22f4b95552c799bae7af0e99780cf1b5500d9d1ecbdbcf6f27cdecc72c97fef3703c54b717bca613894212e0b2525cbb2d1161b9',
    method: EncryptionTypes.METHOD.ECIES,
  }
]);

const { result } = await transactionManager.persistTransaction(data, channelId, channelTopics, encryptionParameters);

Get Transactions from channel id

import EthereumPrivateKeyDecryptionProvider from '@requestnetwork/epk-decryption';
import { DataAccessTypes, SignatureTypes } from '@requestnetwork/types';
import { TransactionManager } from '@requestnetwork/transaction-manager';

const dataAccess: DataAccessTypes.IDataAccess; // A Data Access implementation, for example @requestnetwork/data-access

// Decryption provider setup if needed
const decryptionProvider = new EthereumPrivateKeyDecryptionProvider({
  key: '0x04674d2e53e0e14653487d7323cc5f0a7959c83067f5654cafe4094bde90fa8a',
  method: EncryptionTypes.METHOD.ECIES,
});

const transactionManager = new TransactionManager(dataAccess, decryptionProvider);

const channelId = 'myRequest';

const { result: {transactions} } = await transactionManager.getTransactionsByChannelId(channelId);

Get Transactions from topic

import EthereumPrivateKeyDecryptionProvider from '@requestnetwork/epk-decryption';
import { DataAccessTypes, SignatureTypes } from '@requestnetwork/types';
import { TransactionManager } from '@requestnetwork/transaction-manager';

const dataAccess: DataAccessTypes.IDataAccess; // A Data Access implementation, for example @requestnetwork/data-access

// Decryption provider setup if needed
const decryptionProvider = new EthereumPrivateKeyDecryptionProvider({
  key: '0x04674d2e53e0e14653487d7323cc5f0a7959c83067f5654cafe4094bde90fa8a',
  method: EncryptionTypes.METHOD.ECIES,
});

const transactionManager = new TransactionManager(dataAccess, decryptionProvider);

const channelTopic = 'stakeholder1';

const {
  result: { transactions },
} = await transactionManager.getTransactionsByTopic(channelTopic);

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Read the contributing guide

License

MIT

0.34.1-next.2034

15 days ago

0.34.1-next.2033

29 days ago

0.34.1-next.2032

1 month ago

0.34.1-next.2031

1 month ago

0.34.1-next.2030

2 months ago

0.34.1-next.2029

2 months ago

0.34.1-next.2028

2 months ago

0.34.1-next.2027

2 months ago

0.34.1-next.2026

2 months ago

0.33.0

2 months ago

0.34.1-next.2025

2 months ago

0.33.1-next.2022

2 months ago

0.33.1-next.2024

2 months ago

0.33.1-next.2023

2 months ago

0.31.1-next.2019

2 months ago

0.32.1-next.2020

2 months ago

0.32.1-next.2021

2 months ago

0.32.0

2 months ago

0.31.1-next.2017

2 months ago

0.31.1-next.2016

2 months ago

0.31.1-next.2015

2 months ago

0.31.1-next.2014

2 months ago

0.31.1-next.2013

2 months ago

0.31.1-next.2012

3 months ago

0.31.1-next.2009

3 months ago

0.31.1-next.2010

3 months ago

0.31.1-next.2008

3 months ago

0.31.1-next.2007

3 months ago

0.31.1-next.2006

4 months ago

0.31.1-next.2005

4 months ago

0.31.1-next.2004

4 months ago

0.31.1-next.2003

4 months ago

0.31.1-next.2002

4 months ago

0.30.1-next.2000

4 months ago

0.31.0

4 months ago

0.30.1-next.1999

4 months ago

0.30.1-next.1998

4 months ago

0.30.1-next.1997

4 months ago

0.30.1-next.1992

4 months ago

0.30.1-next.1991

4 months ago

0.30.1-next.1990

4 months ago

0.30.1-next.1989

4 months ago

0.30.1-next.1983

4 months ago

0.30.1-next.1986

4 months ago

0.30.1-next.1987

4 months ago

0.30.1-next.1985

4 months ago

0.30.1-next.1988

4 months ago

0.30.1-next.1982

5 months ago

0.30.1-next.1981

5 months ago

0.30.1-next.1980

5 months ago

0.30.1-next.1979

5 months ago

0.30.1-next.1978

5 months ago

0.30.0

5 months ago

0.29.1-next.1976

5 months ago

0.30.1-next.1977

5 months ago

0.29.1-next.1974

5 months ago

0.29.1-next.1971

5 months ago

0.29.1-next.1973

5 months ago

0.29.1-next.1969

6 months ago

0.29.1-next.1957

6 months ago

0.29.1-next.1958

6 months ago

0.29.1-next.1959

6 months ago

0.29.1-next.1964

6 months ago

0.29.1-next.1965

6 months ago

0.29.1-next.1966

6 months ago

0.29.1-next.1967

6 months ago

0.29.1-next.1960

6 months ago

0.29.1-next.1961

6 months ago

0.29.1-next.1962

6 months ago

0.29.1-next.1963

6 months ago

0.28.1-next.1949

7 months ago

0.28.1-next.1948

7 months ago

0.28.1-next.1947

7 months ago

0.29.1-next.1955

6 months ago

0.29.1-next.1956

6 months ago

0.28.1-next.1953

6 months ago

0.28.1-next.1952

6 months ago

0.28.1-next.1950

6 months ago

0.27.1-next.1929

8 months ago

0.27.1-next.1928

8 months ago

0.27.1-next.1927

8 months ago

0.27.1-next.1926

8 months ago

0.29.0

6 months ago

0.27.1-next.1930

8 months ago

0.27.1-next.1918

9 months ago

0.27.1-next.1917

9 months ago

0.27.1-next.1916

9 months ago

0.27.1-next.1920

8 months ago

0.27.1-next.1925

8 months ago

0.27.1-next.1924

8 months ago

0.27.1-next.1923

8 months ago

0.27.1-next.1922

8 months ago

0.27.1-next.1907

11 months ago

0.27.1-next.1906

11 months ago

0.27.1-next.1905

11 months ago

0.27.1-next.1909

10 months ago

0.27.1-next.1908

10 months ago

0.27.1-next.1910

10 months ago

0.27.1-next.1913

10 months ago

0.27.1-next.1912

10 months ago

0.27.1-next.1911

10 months ago

0.28.0

8 months ago

0.28.1-next.1936

7 months ago

0.28.1-next.1937

7 months ago

0.28.1-next.1938

7 months ago

0.28.1-next.1939

7 months ago

0.28.1-next.1940

7 months ago

0.28.1-next.1941

7 months ago

0.28.1-next.1942

7 months ago

0.28.1-next.1943

7 months ago

0.28.1-next.1944

7 months ago

0.28.1-next.1945

7 months ago

0.28.1-next.1946

7 months ago

0.28.1-next.1933

7 months ago

0.27.1-next.1899

11 months ago

0.27.1-next.1898

12 months ago

0.27.1-next.1897

12 months ago

0.27.1-next.1904

11 months ago

0.27.1-next.1903

11 months ago

0.27.1-next.1902

11 months ago

0.27.1-next.1901

11 months ago

0.27.1-next.1900

11 months ago

0.27.1-next.1822

2 years ago

0.27.1-next.1826

2 years ago

0.27.1-next.1825

2 years ago

0.27.1-next.1824

2 years ago

0.27.1-next.1823

2 years ago

0.27.0

2 years ago

0.27.1-next.1829

2 years ago

0.27.1-next.1828

2 years ago

0.27.1-next.1827

2 years ago

0.26.9

3 years ago

0.26.9-next.1462

3 years ago

0.26.9-next.1461

3 years ago

0.26.9-next.1458

3 years ago

0.26.9-next.1459

3 years ago

0.26.9-next.1457

3 years ago

0.26.9-next.1456

3 years ago

0.26.9-next.1455

3 years ago

0.26.7-next.1430

3 years ago

0.26.7-next.1432

3 years ago

0.26.7-next.1431

3 years ago

0.26.7-next.1429

3 years ago

0.26.8-next.1448

3 years ago

0.26.8-next.1447

3 years ago

0.26.8-next.1449

3 years ago

0.26.8

3 years ago

0.26.9-next.1450

3 years ago

0.26.9-next.1451

3 years ago

0.26.9-next.1452

3 years ago

0.26.9-next.1453

3 years ago

0.26.9-next.1454

3 years ago

0.26.8-next.1437

3 years ago

0.26.8-next.1436

3 years ago

0.26.8-next.1439

3 years ago

0.26.8-next.1438

3 years ago

0.26.8-next.1444

3 years ago

0.26.8-next.1443

3 years ago

0.26.8-next.1446

3 years ago

0.26.8-next.1445

3 years ago

0.26.8-next.1442

3 years ago

0.26.8-next.1441

3 years ago

0.26.8-next.1435

3 years ago

0.26.8-next.1434

3 years ago

0.26.7-next.1426

3 years ago

0.26.7-next.1428

3 years ago

0.26.7

3 years ago

0.26.7-next.1425

3 years ago

0.26.7-next.1424

3 years ago

0.26.7-next.1421

3 years ago

0.26.7-next.1423

3 years ago

0.26.7-next.1422

3 years ago

0.26.7-next.1420

3 years ago

0.26.7-next.1416

3 years ago

0.26.7-next.1418

3 years ago

0.26.7-next.1417

3 years ago

0.26.7-next.1419

3 years ago

0.26.7-next.1415

3 years ago

0.26.7-next.1414

3 years ago

0.26.7-next.1413

3 years ago

0.26.7-next.1412

3 years ago

0.26.7-next.1411

3 years ago

0.26.7-next.1410

3 years ago

0.26.7-next.1407

3 years ago

0.26.7-next.1409

3 years ago

0.26.7-next.1408

3 years ago

0.26.6-next.1403

3 years ago

0.26.6-next.1404

3 years ago

0.26.6

3 years ago

0.26.7-next.1405

3 years ago

0.26.5-next.1401

3 years ago

0.26.5-next.1402

3 years ago

0.26.5-next.1398

3 years ago

0.26.5-next.1393

3 years ago

0.26.5-next.1395

3 years ago

0.26.5-next.1394

3 years ago

0.26.5-next.1399

3 years ago

0.26.5-next.1392

3 years ago

0.26.5-next.1391

3 years ago

0.26.5-next.1397

3 years ago

0.26.5-next.1400

3 years ago

0.26.5

3 years ago

0.26.4

3 years ago

0.26.3

3 years ago

0.26.2

3 years ago

0.26.1

3 years ago

0.26.1-next.1351

3 years ago

0.26.0

3 years ago

0.9.0-next.1

3 years ago

0.25.0

4 years ago

0.24.1-next.1335

4 years ago

0.24.0

4 years ago

0.23.1-next.1332

4 years ago

0.23.1-next.1331

4 years ago

0.23.0

4 years ago

0.21.1-next.1326

4 years ago

0.22.1-next.1327

4 years ago

0.22.0

4 years ago

0.21.0

4 years ago

0.20.1-next.1322

4 years ago

0.20.0

4 years ago

0.19.1-next.1312

4 years ago

0.19.1-next.1310

4 years ago

0.19.0

4 years ago

0.18.0

4 years ago

0.17.0

4 years ago

0.17.1-next.1280

4 years ago

0.16.1-next.1278

4 years ago

0.16.0

4 years ago

0.15.1-next.1272

4 years ago

0.15.0

4 years ago

0.14.0

4 years ago

0.13.0

4 years ago

0.12.1-next.1231

4 years ago

0.12.1-next.1230

4 years ago

0.11.1-next.1227

4 years ago

0.12.0

4 years ago

0.11.1-next.1218

4 years ago

0.11.0

4 years ago

0.11.1-next.1217

4 years ago

0.10.1-next.1215

4 years ago

0.10.1-next.1207

4 years ago

0.10.1-next.1206

4 years ago

0.10.0

4 years ago

0.9.1-next.1203

4 years ago

0.9.1-next.1201

4 years ago

0.9.0

4 years ago

0.9.1-next.1192

4 years ago

0.8.5-next.1187

4 years ago

0.8.5-next.1186

4 years ago

0.8.5-next.1181

4 years ago

0.8.5-next.1176

4 years ago

0.8.5-next.1175

4 years ago

0.8.5-next.1173

4 years ago

0.8.5-next.1171

4 years ago

0.8.5-next.1164

4 years ago

0.8.5-next.1163

4 years ago

0.8.5-next.1161

4 years ago

0.8.4

4 years ago

0.8.4-next.1156

4 years ago

0.8.3

4 years ago

0.8.3-next.1142

4 years ago

0.8.3-next.1143

4 years ago

0.8.3-next.1140

4 years ago

0.8.3-next.1134

4 years ago

0.8.3-next.1130

4 years ago

0.8.3-next.1132

4 years ago

0.8.2

4 years ago

0.8.1

5 years ago

0.8.0

5 years ago

0.7.0

5 years ago

0.6.0

5 years ago

0.5.0

5 years ago

0.4.0

5 years ago

0.3.0

5 years ago

0.2.1-alpha.0

5 years ago

0.2.0

5 years ago

0.1.1-alpha.12

5 years ago

0.1.1-alpha.11

5 years ago

0.1.1-alpha.10

5 years ago

0.1.1-alpha.9

5 years ago

0.1.1-alpha.8

5 years ago

0.1.1-alpha.7

5 years ago

0.1.1-alpha.6

5 years ago

0.1.1-alpha.5

5 years ago

0.1.1-alpha.4

5 years ago

0.1.1-alpha.3

5 years ago

0.1.1-alpha.2

5 years ago

0.1.1-alpha.1

5 years ago

0.1.1-alpha.0

5 years ago