Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add New Types of Transaction #726 #791

Merged

Conversation

apoorv-2204
Copy link
Contributor

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes # (726)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A
  • Test B

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@apoorv-2204 apoorv-2204 self-assigned this Jan 5, 2023
@apoorv-2204 apoorv-2204 added the transaction Involve transactions label Jan 5, 2023
@apoorv-2204 apoorv-2204 marked this pull request as ready for review January 5, 2023 15:44
@apoorv-2204 apoorv-2204 added the core team Assigned to the core team label Jan 10, 2023
config/config.exs Outdated Show resolved Hide resolved
Copy link
Member

@samuelmanzanera samuelmanzanera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can simplify the size limitation to be global, which will reduce the validations

@Neylix
Copy link
Member

Neylix commented Jan 11, 2023

Maybe you can add some test to ensure :data transaction cannot pass without content or ownerships, same for :contract transaction with code

@apoorv-2204 apoorv-2204 added the quality Improve code quality label Jan 12, 2023
do_validate_ownerships(ownerships)
end
defp validate_ownerships(%Transaction{data: %TransactionData{ownerships: ownerships}}) do
do_validate_ownerships(ownerships)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there is need for this function, you could merge it inside the validate_ownerships

@bchamagne
Copy link
Member

bchamagne commented Jan 12, 2023

This require lib{js,dart,go} update + transactionbuilder update. Who's up for it?

@samuelmanzanera
Copy link
Member

samuelmanzanera commented Jan 12, 2023

This require lib{js,dart,go} update + transactionbuilder update. Who's up for it?

Need to create the issues.
For libjs, you are welcome.
For dart, @redDwarf03

@bchamagne
Copy link
Member

bchamagne commented Jan 12, 2023

I hacked the transactionbuilder to create a transaction of type contract and it fails when calculating the fees:

curl cmd:

curl 'http://127.0.0.1:4000/api/transaction_fee' -X POST -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:108.0) Gecko/20100101 Firefox/108.0' -H 'Accept: application/json' -H 'Accept-Language: en-US,en;q=0.5' -H 'Accept-Encoding: gzip, deflate, br' -H 'content-type: application/json' -H 'Origin: http://127.0.0.1:8080' -H 'DNT: 1' -H 'Connection: keep-alive' -H 'Referer: http://127.0.0.1:8080/' -H 'Sec-Fetch-Dest: empty' -H 'Sec-Fetch-Mode: cors' -H 'Sec-Fetch-Site: same-site' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' --data-raw '{"version":1,"address":"00002223bbd4ec3d64ae597696c7d7ade1cee65c639d885450ad2d7b75592ac76afa","type":"contract","data":{"content":"","code":"condition inherit: [\n\ttype: true,\n\tcontent: true,\n\tuco_transfers: true\n]\n\ncondition transaction: [\n\tuco_transfers: size() > 0\n]\n\nactions triggered_by: transaction do\n\tset_type transfer\n\tadd_uco_transfer to: \"000030831178cd6a49fe446778455a7a980729a293bfa16b0a1d2743935db210da76\", amount: 1337\nend","ownerships":[{"secret":"2f6e6131b3030bb0e8f0349e88bf9ecd967f0bc5c3d77e156a9d0085ddf27e","authorizedKeys":[{"publicKey":"00013fdaa56ace7232d79ea5faff1131fa6ad977a9d53f5a1f59bc42e47b2b7e5f3a","encryptedSecretKey":"6e77b2ec3c4f43457b9f7c4cd4d6ab6430fe577376d7eb6c8c9ebeede78357738042e9c59e600aa712437484cfbd3b4ed3cf7b215c135f10750c2f2eb74b4ea5c3bf8e157fd653ab22758c8bd44970b0"}]}],"ledger":{"uco":{"transfers":[{"to":"000030831178cd6a49fe446778455a7a980729a293bfa16b0a1d2743935db210da76","amount":100000000}]},"token":{"transfers":[]}},"recipients":[]},"previousPublicKey":"000160dbbb1ad04320cbd0e758dd4c9ecaa4b22c9121a21b06c649080fceb37844d3","previousSignature":"062b146c0e0f7dd76709de38e6be47c679990c9d35b2ad8b59ac780456a93171bcd774a8b1d94a4a096d0cb2e9b053b64b8b6a74e7c849af475c5decd6245906","originSignature":"3045022100ef2a60e8483b0609e872426aef97225ae70d3232512565a71a3ba066b2378cf802202cca8ba1652cde4091c699e6aee4f98304f6382d8d4064277b9ee8f9b8369400"}'

result: (code 400)
{"errors":{"type":["is invalid"]},"status":"invalid"}

EDIT: error is coming from: ArchethicWeb.API.Types.TransactionType

@bchamagne
Copy link
Member

bchamagne commented Jan 12, 2023

Apart from small issue above, I managed to create 2 transactions of type contract & data as expected (tested on 3 nodes).

Screenshot 2023-01-12 at 14-25-18 ARCHETHIC
Screenshot 2023-01-12 at 14-16-17 ARCHETHIC

@Neylix
Copy link
Member

Neylix commented Jan 12, 2023

I hacked the transactionbuilder to create a transaction of type contract and it fails when calculating the fees:

curl cmd:

curl 'http://127.0.0.1:4000/api/transaction_fee' -X POST -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:108.0) Gecko/20100101 Firefox/108.0' -H 'Accept: application/json' -H 'Accept-Language: en-US,en;q=0.5' -H 'Accept-Encoding: gzip, deflate, br' -H 'content-type: application/json' -H 'Origin: http://127.0.0.1:8080' -H 'DNT: 1' -H 'Connection: keep-alive' -H 'Referer: http://127.0.0.1:8080/' -H 'Sec-Fetch-Dest: empty' -H 'Sec-Fetch-Mode: cors' -H 'Sec-Fetch-Site: same-site' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' --data-raw '{"version":1,"address":"00002223bbd4ec3d64ae597696c7d7ade1cee65c639d885450ad2d7b75592ac76afa","type":"contract","data":{"content":"","code":"condition inherit: [\n\ttype: true,\n\tcontent: true,\n\tuco_transfers: true\n]\n\ncondition transaction: [\n\tuco_transfers: size() > 0\n]\n\nactions triggered_by: transaction do\n\tset_type transfer\n\tadd_uco_transfer to: \"000030831178cd6a49fe446778455a7a980729a293bfa16b0a1d2743935db210da76\", amount: 1337\nend","ownerships":[{"secret":"2f6e6131b3030bb0e8f0349e88bf9ecd967f0bc5c3d77e156a9d0085ddf27e","authorizedKeys":[{"publicKey":"00013fdaa56ace7232d79ea5faff1131fa6ad977a9d53f5a1f59bc42e47b2b7e5f3a","encryptedSecretKey":"6e77b2ec3c4f43457b9f7c4cd4d6ab6430fe577376d7eb6c8c9ebeede78357738042e9c59e600aa712437484cfbd3b4ed3cf7b215c135f10750c2f2eb74b4ea5c3bf8e157fd653ab22758c8bd44970b0"}]}],"ledger":{"uco":{"transfers":[{"to":"000030831178cd6a49fe446778455a7a980729a293bfa16b0a1d2743935db210da76","amount":100000000}]},"token":{"transfers":[]}},"recipients":[]},"previousPublicKey":"000160dbbb1ad04320cbd0e758dd4c9ecaa4b22c9121a21b06c649080fceb37844d3","previousSignature":"062b146c0e0f7dd76709de38e6be47c679990c9d35b2ad8b59ac780456a93171bcd774a8b1d94a4a096d0cb2e9b053b64b8b6a74e7c849af475c5decd6245906","originSignature":"3045022100ef2a60e8483b0609e872426aef97225ae70d3232512565a71a3ba066b2378cf802202cca8ba1652cde4091c699e6aee4f98304f6382d8d4064277b9ee8f9b8369400"}'

result: (code 400) {"errors":{"type":["is invalid"]},"status":"invalid"}

EDIT: error is coming from: ArchethicWeb.API.Types.TransactionType

Indeed, these new type need to be added in the TransactionType values for API

@Neylix Neylix merged commit 0a59a85 into archethic-foundation:develop Jan 13, 2023
@apoorv-2204 apoorv-2204 deleted the add_new_types_of_transaction#726 branch February 6, 2023 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core team Assigned to the core team quality Improve code quality transaction Involve transactions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants