Skip to content

Commit

Permalink
Merge branch '62-update-document' into 'dev'
Browse files Browse the repository at this point in the history
update AbstractChain document

Closes #62

See merge request ergo/rosen-bridge/rosen-chains!71
  • Loading branch information
vorujack committed Nov 6, 2023
2 parents cafa272 + 4d5c331 commit d87f498
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 28 deletions.
45 changes: 22 additions & 23 deletions packages/abstract-chain/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Required functions are as follows:
- **@param** `txType` transaction type
- **@param** `order` the payment order (list of single payments)
- **@param** `unsignedTransactions` ongoing unsigned PaymentTransactions which will be used to prevent double spending (gathered from database and guard TxAgreement process)
- **@param** `serializedSignedTransactions` the serialized string of ongoing signed transactions which will be used for chained transactions (gathered from database and mempool)
- **@param** `serializedSignedTransactions` the serialized string of ongoing signed transactions which will be used for chaining transactions (gathered from database and mempool)
- **@returns** the generated PaymentTransaction
- `getTransactionAssets`
- gets input and output assets of a PaymentTransaction
Expand All @@ -105,23 +105,23 @@ Required functions are as follows:
- `verifyTransactionFee`
- verifies transaction fee for a PaymentTransaction
- **@param** `transaction` the PaymentTransaction
- **@returns** true if the transaction fee verified
- **@returns** true if the transaction fee is verified
- `verifyNoTokenBurned`
- verifies no token burned in a PaymentTransaction
- **@param** `transaction` the PaymentTransaction
- **@returns** true if not token burned
- **@returns** true if no token burned
- `verifyTransactionExtraConditions`
- verifies additional conditions for a PaymentTransaction
- **@param** `transaction` the PaymentTransaction
- **@returns** true if the transaction verified
- **NOTE**: This function is implemented in AbstarctChain and will return true. In any chain
that requires extra check to verify the transaction, this function should be overrided.
- **@returns** true if the transaction is verified
- **NOTE**: This function is implemented in AbstractChain and will return true. In any chain
that requires extra check to verify the transaction, this function should be overridden.
- `verifyEvent`
- verifies an event data with its corresponding lock transaction
- **@param** `event` the event trigger model
- **@param** `eventSerializedBox` the serialized string of the event trigger box
- **@param** `feeConfig` minimum fee and rsn ratio config for the event
- **@returns** true if the event verified
- **@returns** true if the event is verified
- `isTxValid`
- checks if a transaction is still valid and can be sent to the network
- **@param** `transaction` the transaction
Expand All @@ -130,36 +130,29 @@ Required functions are as follows:
- requests the corresponding signer service to sign the transaction
- **@param** `transaction` the transaction
- **@param** `requiredSign` the required number of sign
- **@param** `signFunction` the function to sign transaction (provided in guard process)
- **@returns** the signed transaction
- `getTxConfirmationStatus`
- extracts confirmation status for a transaction
- **@param** `transactionId` the transaction id
- **@param** `transactionType` type of the transaction
- **@returns** the transaction confirmation status
- `getLockAddressAssets`
- gets the amount of each asset in the lock address
- **@returns** an object containing the amount of each asset
- `getHeight`
- gets the blockchain height
- **@returns** the blockchain height
- **NOTE**: This function is implemented in AbstarctChain and will redirect request to
network class `getHeight` function. If process is different in the chain, this function
should be overrided.
- `submitTransaction`
- submits a transaction to the blockchain
- **@param** `transaction` the transaction
- `isTxInMempool`
- checks if a transaction is in mempool (returns false if the chain has no mempool)
- **@param** `transactionId` the transaction id
- **@returns** true if the transaction is in mempool
- `hasLockAddressEnoughAssets`
- checks if lock address assets are more than required assets or not
- **@param** `required` required amount of assets
- **@returns** true if lock assets are more than required assets
- `getMinimumNativeToken`
- gets the minimum amount of native token for transferring asset
- **@returns** the minimum amount
- `getRWTToken`
- gets the RWT token id
- **@returns** the RWT token id
- `PaymentTransactionFromJson`
- converts json representation of the payment transaction to PaymentTransaction
- **@param** `jsonString` the json representation of the payment transaction
- **@returns** PaymentTransaction object

### `AbstractUtxoChain`

Expand All @@ -185,7 +178,7 @@ Required functions are as follows:
- gets the blockchain height
- **@returns** the blockchain height
- `getTxConfirmation`
- gets confirmation for a transaction
- gets confirmation for a transaction or -1 if tx is not in the blockchain
- **@param** `transactionId` the transaction id
- **@returns** the transaction confirmation
- `getAddressAssets`
Expand All @@ -196,6 +189,10 @@ Required functions are as follows:
- gets id of all transactions in the given block
- **@param** `blockId` the block id
- **@returns** list of the transaction ids in the block
- `getBlockInfo`
- gets info of the given block
- **@param** `blockId` the block id
- **@returns** an object containing block info (hash, parent hash and height of the block)
- `getTransaction`
- gets a transaction
- **@param** `transactionId` the transaction id
Expand All @@ -215,8 +212,10 @@ Required functions that are only needed in UTxO-based chains are as follows:
- `getAddressBoxes`
- gets confirmed and unspent boxes of an address
- **@param** `address` the address
- **@param** `offset`
- **@param** `limit`
- **@returns** list of serialized string of the boxes
- `isBoxUnspentAndValid`
- extracts box id and assets of a box
- checks if a box is still unspent and valid
- **@param** `boxId` the box id
- **@returns** true if the box is unspent and valid
9 changes: 4 additions & 5 deletions packages/abstract-chain/lib/AbstractChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ abstract class AbstractChain {
* @param txType transaction type
* @param order the payment order (list of single payments)
* @param unsignedTransactions ongoing unsigned PaymentTransactions (used for preventing double spend)
* @param serializedSignedTransactions the serialized string of ongoing signed transactions (used for chainning transaction)
* @param serializedSignedTransactions the serialized string of ongoing signed transactions (used for chaining transaction)
* @returns the generated PaymentTransaction
*/
abstract generateTransaction: (
Expand Down Expand Up @@ -69,7 +69,7 @@ abstract class AbstractChain {
/**
* verifies transaction fee for a PaymentTransaction
* @param transaction the PaymentTransaction
* @returns true if the transaction fee verified
* @returns true if the transaction fee is verified
*/
abstract verifyTransactionFee: (transaction: PaymentTransaction) => boolean;

Expand All @@ -91,7 +91,7 @@ abstract class AbstractChain {
/**
* verifies additional conditions for a PaymentTransaction
* @param transaction the PaymentTransaction
* @returns true if the transaction verified
* @returns true if the transaction is verified
*/
verifyTransactionExtraConditions = (
transaction: PaymentTransaction
Expand All @@ -103,7 +103,7 @@ abstract class AbstractChain {
* verifies an event data with its corresponding lock transaction
* @param event the event trigger model
* @param feeConfig minimum fee and rsn ratio config for the event
* @returns true if the event verified
* @returns true if the event is verified
*/
abstract verifyEvent: (
event: EventTrigger,
Expand All @@ -125,7 +125,6 @@ abstract class AbstractChain {
* requests the corresponding signer service to sign the transaction
* @param transaction the transaction
* @param requiredSign the required number of sign
* @param signFunction the function to sign transaction
* @returns the signed transaction
*/
abstract signTransaction: (
Expand Down

0 comments on commit d87f498

Please sign in to comment.