Skip to content

Commit

Permalink
Merge branch 'main' into feat/dart-license-checker
Browse files Browse the repository at this point in the history
  • Loading branch information
bkioshn committed May 23, 2024
2 parents 1de6373 + 976b02e commit 5ee1b3f
Show file tree
Hide file tree
Showing 24 changed files with 1,304 additions and 90 deletions.
17 changes: 9 additions & 8 deletions .config/dictionaries/project.dic
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ asmjs
asyncio
asyncpg
auditability
backendpython
bech
bkioshn
bluefireteam
Expand Down Expand Up @@ -44,7 +45,9 @@ dotenvy
dotglob
drep
dreps
dtscalac
earthfile
Easterling
Edgedriver
emurgo
encryptor
Expand Down Expand Up @@ -76,6 +79,7 @@ Joaquín
jorm
jormungandr
Jörmungandr
junitxml
junitreport
Keyhash
keyserver
Expand All @@ -88,6 +92,8 @@ libflutter
lintfix
localizable
loguru
lovelace
lovelaces
mdlint
metadatum
metadatums
Expand Down Expand Up @@ -115,6 +121,7 @@ pbxproj
Pdart
permissionless
pg_isready
pinenacl
plpgsql
podfile
podhelper
Expand All @@ -133,6 +140,7 @@ Replayability
repr
reqwest
rfwtxt
rgloader
ripgrep
RPATH
rustc
Expand Down Expand Up @@ -176,6 +184,7 @@ Utxos
vite
vitss
vkey
vkeys
vkeywitness
voteplan
voteplans
Expand All @@ -191,11 +200,3 @@ xctest
xctestrun
xcworkspace
yoroi
multiplatform
Multiplatform
Easterling
lovelace
lovelaces
pinenacl
dtscalac
vkeys
12 changes: 12 additions & 0 deletions .github/workflows/generate-allure-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ jobs:
target_flags:
runner_address: ${{ secrets.EARTHLY_SATELLITE_ADDRESS }}
artifact: "false"

- name: Get backend python test report
uses: input-output-hk/catalyst-ci/actions/run@master
if: always()
continue-on-error: true
with:
earthfile: ./catalyst-gateway/tests/api_tests/
flags: --allow-privileged
targets: test
target_flags:
runner_address: ${{ secrets.EARTHLY_SATELLITE_ADDRESS }}
artifact: "false"

- name: Collect and upload test reports
uses: actions/upload-artifact@v4
Expand Down
4 changes: 2 additions & 2 deletions catalyst-gateway/Earthfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
VERSION 0.8

IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.00.0 AS rust-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/mithril_snapshot:v3.00.0 AS mithril-snapshot-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.00.1 AS rust-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/mithril_snapshot:v3.00.1 AS mithril-snapshot-ci

#cspell: words rustfmt toolsets USERARCH

Expand Down
2 changes: 1 addition & 1 deletion catalyst-gateway/event-db/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# the database and its associated software.
VERSION 0.8

IMPORT github.com/input-output-hk/catalyst-ci/earthly/postgresql:v3.00.0 AS postgresql-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/postgresql:v3.00.1 AS postgresql-ci

# cspell: words

Expand Down
3 changes: 2 additions & 1 deletion catalyst-gateway/tests/api_tests/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
__pycache__
__pycache__
junit-report.xml
9 changes: 6 additions & 3 deletions catalyst-gateway/tests/api_tests/Earthfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
VERSION 0.8

IMPORT github.com/input-output-hk/catalyst-ci/earthly/python:v3.00.0 AS python-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/python:v3.00.1 AS python-ci

# builder :
# builder :
builder:
FROM python-ci+python-base

Expand All @@ -22,5 +22,8 @@ test:
--load cat-gateway:latest=(../../+package-cat-gateway-with-preprod-snapshot) \
--service cat-gateway \
--allow-privileged
RUN poetry run pytest -s
RUN poetry run pytest -s --junitxml=junit-report.xml
END
WAIT
SAVE ARTIFACT junit-report.xml AS LOCAL backendpython.junit-report.xml
END
219 changes: 218 additions & 1 deletion catalyst_voices_packages/catalyst_cardano_serialization/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,218 @@
# catalyst_cardano_serialization
# Content

* [Content](#content)
* [Features](#features)
* [Requirements](#requirements)
* [Install](#install)
* [Example](#example)
* [Limitations](#limitations)
* [Supported transaction body fields](#supported-transaction-body-fields)
* [Reference documentation](#reference-documentation)
* [Support](#support)
* [License](#license)

## Features

This package comes with serialization & deserialization of data structures related to Cardano
blockchain transactions and useful utility functions.

The goal of the package is to generate an unsigned transaction cbor that
can be signed and submitted to the blockchain.
The package communicates neither with the wallet nor with the blockchain therefore signing
and submission are outside of scope of this package.

## Requirements

* Dart: 3.3.0+
* Flutter: 3.19.5+

## Install

```yaml
dependencies:
catalyst_cardano_serialization: ^0.1.0
```
## Example
Import `package:catalyst_cardano_serialization/catalyst_cardano_serialization.dart`,
instantiate `TransactionBuilder`, provide transaction inputs, outputs, add change address
for any remaining unspent UTXOs and build the transaction body.

The transaction body must be signed by witnesses in order to be submitted to the blockchain.
Otherwise the validity of the transaction could not be established and such transaction
would be rejected.
The caller must prove that they are eligible to spend the input UTXOs.

```dart
import 'package:catalyst_cardano_serialization/catalyst_cardano_serialization.dart';
import 'package:cbor/cbor.dart';
import 'package:convert/convert.dart';
/* cSpell:disable */
void main() {
const txBuilderConfig = TransactionBuilderConfig(
feeAlgo: LinearFee(
constant: Coin(155381),
coefficient: Coin(44),
),
maxTxSize: 8000,
coinsPerUtxoByte: Coin(4310),
);
final txMetadata = AuxiliaryData(
map: {
const CborSmallInt(1): CborString('Test'),
const CborSmallInt(2): CborBytes(hex.decode('aabbccddeeff')),
const CborSmallInt(3): const CborSmallInt(997),
const CborSmallInt(4): cbor.decode(
hex.decode(
'82a50081825820afcf8497561065afe1ca623823508753cc580eb575ac8f1d6cfa'
'a18c3ceeac010001818258390080f9e2c88e6c817008f3a812ed889b4a4da8e0bd'
'103f86e7335422aa122a946b9ad3d2ddf029d3a828f0468aece76895f15c9efbd6'
'9b42771a00df1560021a0002e63003182f075820bdc2b27e6869aa9a5fa23a1f1f'
'd3a87025d8703df4fd7b120d058c839dc0415c82a10141aa80',
),
),
},
);
final utxo = TransactionUnspentOutput(
input: TransactionInput(
transactionId: TransactionHash.fromHex(
'4c1fbc5433ec764164945d736a09dc087d59ff30e64d26d462ff8570cd4be9a7',
),
index: 0,
),
output: TransactionOutput(
address: ShelleyAddress.fromBech32(
'addr_test1qpu5vlrf4xkxv2qpwngf6cjhtw542ayty80v8dyr49rf5ewvxwdrt70'
'qlcpeeagscasafhffqsxy36t90ldv06wqrk2qum8x5w',
),
amount: const Coin(10162333),
),
);
final txOutput = TransactionOutput(
address: ShelleyAddress.fromBech32(
'addr_test1vzpwq95z3xyum8vqndgdd9mdnmafh3djcxnc6jemlgdmswcve6tkw',
),
amount: const Coin(1000000),
);
final txBuilder = TransactionBuilder(
config: txBuilderConfig,
inputs: [utxo],
// fee can be left empty so that it's auto calculated or can be hardcoded
// fee: const Coin(1000000),
ttl: const SlotBigNum(410021),
auxiliaryData: txMetadata,
networkId: NetworkId.testnet,
);
final changeAddress = ShelleyAddress.fromBech32(
'addr_test1qrqr2ved9h96x46yazq89yvcgk0r93gwk0shnv06yfrnfryqhpr26'
'st0zgxmjnq6gqve99gtzxumclt9mwe5ynq03hjqgkjmhd',
);
final txBody = txBuilder
.withOutput(txOutput)
.withChangeAddressIfNeeded(changeAddress)
// fee can be set manually or left empty to be auto calculated
// .withFee(const Coin(10000000))
.buildBody();
final txHash = TransactionHash.fromTransactionBody(txBody);
final witnessSet = _signTransaction(txHash);
final tx = Transaction(
body: txBody,
isValid: true,
witnessSet: witnessSet,
auxiliaryData: txMetadata,
);
final txBytes = cbor.encode(tx.toCbor());
final txBytesHex = hex.encode(txBytes);
print(txBytesHex);
}
TransactionWitnessSet _signTransaction(TransactionHash txHash) {
// return a fake witness set, in real world the wallet
// would sign the transaction hash and provide this
return TransactionWitnessSet(
vkeyWitnesses: {
VkeyWitness(
vkey: Vkey.fromBytes(
hex.decode(
'3311ca404fcf22c91d607ace285d70e2'
'263a1b81745c39673080329bd1a3f56e',
),
),
signature: Ed25519Signature.fromBytes(
hex.decode(
'f5eb006f048fdfa9b81b0fe3abee1ce1f1a75789d'
'c21088b23ebf95c76b050ad157a497999e083e1957'
'c2a3d730a07a5b2aef4a755783c9ce778c02c4a08970f',
),
),
),
},
);
}
/* cSpell:enable */
```

## Limitations

This package supports a minimal `TransactionBuilder` that does not yet work with
Smart Contracts, scripts or NFTs.
However AuxiliaryMetadata is already supported thus it's possible to fulfill some of the use cases.

Only Shelley era bech32 base and stake addresses are supported.
Byron era addresses are not supported.

## Supported transaction body fields

| Field | Is supported? |
| ----- | ------------- |
| 0 = transaction inputs | ✔️ |
| 1 = transaction outputs | ✔️ |
| 2 = transaction fee | ✔️ |
| 3 = Time to live [TTL] | ✔️ |
| 4 = certificates | ❌️ |
| 5 = reward withdrawals | ❌️ |
| 6 = protocol parameter update | ❌️ |
| 7 = auxiliary_data_hash | ✔️ |
| 8 = validity interval start | ❌️ |
| 9 = mint | ❌️ |
| 11 = script_data_hash | ❌️ |
| 13 = collateral inputs | ❌️ |
| 14 = required signers | ❌️ |
| 15 = network_id | ✔️ |
| 16 = collateral return | ❌️ |
| 17 = total collateral | ❌️ |
| 18 = reference inputs | ❌️ |

## Reference documentation

* [Cardano transaction specification](https://github.com/input-output-hk/catalyst-CIPs/blob/x509-rbac-signing-with-cip30/CIP-XXXX/README.md#specification)
* [Cardano Multiplatform Lib](https://github.com/dcSpark/cardano-multiplatform-lib) with reference
implementation for fee calculation algorithm and change address management.

## Support

Post issues and feature requests on the GitHub [issue tracker](https://github.com/input-output-hk/catalyst-voices/issues).
Please read our [CONTRIBUTING](https://github.com/input-output-hk/catalyst-voices/blob/main/CONTRIBUTING.md)
for guidelines on how to contribute.

## License

Licensed under either of [Apache License, Version 2.0](https://github.com/input-output-hk/catalyst-voices/blob/main/LICENSE-APACHE)
or [MIT license](https://github.com/input-output-hk/catalyst-voices/blob/main/LICENSE-MIT)
at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in this crate by you, as defined in the Apache-2.0 license, shall
be dual licensed as above, without any additional terms or conditions.
Loading

0 comments on commit 5ee1b3f

Please sign in to comment.