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

ABI / codecs: examples, cookbook, pre-release fixes #64

Merged
merged 9 commits into from
Jun 17, 2024

Conversation

andreibancioiu
Copy link
Contributor

@andreibancioiu andreibancioiu commented Jun 14, 2024

Added examples in the Cookbook. Minor fixes along the way.

@andreibancioiu andreibancioiu self-assigned this Jun 14, 2024
Copy link

github-actions bot commented Jun 14, 2024

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  multiversx_sdk/abi
  __init__.py
  abi_definition.py 40, 113
  multiversx_sdk/core/transactions_outcome_parsers
  smart_contract_transactions_outcome_parser_types.py 12
Project Total  

This report was generated by python-coverage-comment-action

@andreibancioiu andreibancioiu marked this pull request as ready for review June 17, 2024 10:10
Comment on lines 883 to 891
":::tip\n",
"When creating transactions using `SmartContractTransactionsFactory`, even if the ABI is available and provided,\n",
"you can still use _typed value_ objects as arguments for deployments and interactions.\n",
"\n",
"Even further, you can use a mix of _typed value_ objects and plain Python values and objects. For example:\n",
"```\n",
"args = [U32Value(42), \"hello\", { \"foo\": \"bar\" }, TokenIdentifierValue(\"TEST-abcdef\")];\n",
"```\n",
":::"
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is not properly rendered.

Copy link
Collaborator

Choose a reason for hiding this comment

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

looks good in the docs but not on the notebook.
image

Copy link
Contributor Author

@andreibancioiu andreibancioiu Jun 17, 2024

Choose a reason for hiding this comment

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

Removed markers. We'll separately maintain these markers in mx-docs.

"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Transaction: {'nonce': 0, 'value': '0', 'receiver': 'erd1qqqqqqqqqqqqqpgquzmh78klkqwt0p4rjys0qtp3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GY1NTRlNTQ0NTUyMDBAMDUwNkAyYUA3NDY1NzM3NA==', 'chainID': 'D', 'version': 2, 'options': 0, 'guardian': '', 'signature': '', 'guardianSignature': ''}\n",
"Transaction data: upgradeContract@0061736d0100000001150460037f7f7e017f60027f7f017e60017e0060000002420303656e7611696e74363473746f7261676553746f7265000003656e7610696e74363473746f726167654c6f6164000103656e760b696e74363466696e6973680002030504030303030405017001010105030100020608017f01419088040b072f05066d656d6f7279020004696e6974000309696e6372656d656e7400040964656372656d656e7400050367657400060a8a01041300418088808000410742011080808080001a0b2e01017e4180888080004107418088808000410710818080800042017c22001080808080001a20001082808080000b2e01017e41808880800041074180888080004107108180808000427f7c22001080808080001a20001082808080000b160041808880800041071081808080001082808080000b0b0f01004180080b08434f554e54455200@0506@2a@74657374\n"
"SmartContractDeployOutcome(return_code='', return_message='', contracts=[DeployedSmartContract(address='erd1qqqqqqqqqqqqqpgqws44xjx2t056nn79fn29q0rjwfrd3m43396ql35kxy', owner_address='erd1testnlersh4z0wsv8kjx39me4rmnvjkwu8dsaea7ukdvvc9z396qykv7z7', code_hash=b'8Kh\\r\\xf7\\xa9^\\xbc\\xec\\xa0/\\xfb>v\\n/\\xc2\\x88\\xde\\xa1\\xb8\\x02h^\\xf1]\\xf2*\\xe8\\x8b\\xa1[')])\n"
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe in the future, we override the __repr__ method to display code hash as hex. just a thought.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

"output_type": "stream",
"text": [
"Transaction: {'nonce': 0, 'value': '0', 'receiver': 'erd1qqqqqqqqqqqqqpgquzmh78klkqwt0p4rjys0qtp3la07gz4d396qn50nnm', 'sender': 'erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th', 'senderUsername': '', 'receiverUsername': '', 'gasPrice': 1000000000, 'gasLimit': 10000000, 'data': 'dXB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MDY2ZDY1NmQ2ZjcyNzkwMjAwMDQ2OTZlNjk3NDAwMTEwNjY3NjU3NDUzNzU2ZDAwMTIwMzYxNjQ2NDAwMTMwODYzNjE2YzZjNDI2MTYzNmIwMDE0MGE1ZjVmNjQ2MTc0NjE1ZjY1NmU2NDAzMDAwYjVmNWY2ODY1NjE3MDVmNjI2MTczNjUwMzAxMGFjYTAxMGEwZTAxMDE3ZjQxMDAxMDBjMjIwMDEwMDAyMDAwMGIxOTAxMDE3ZjQxOWM4MDA4NDE5YzgwMDgyODAyMDA0MTAxNmIyMjAwMzYwMjAwMjAwMDBiMTQwMDEwMDEyMDAwNDYwNDQwMGYwYjQxODA4MDA4NDExOTEwMDIwMDBiMTYwMDIwMDAxMDBjMjIwMDEwMDMxYTIwMDAxMDBjMjIwMDEwMDQxYTIwMDAwYjE0MDEwMTdmMTAwYzIyMDIyMDAxMTAwNTFhMjAwMDIwMDIxMDA2MWEwYjEzMDEwMTdmMTAwYzIyMDA0MTk5ODAwODQxMDMxMDA3MWEyMDAwMGIxNDAxMDE3ZjEwMDg0MTAxMTAwZDEwMGIyMTAwMTAxMDIwMDAxMDBmMGIwZTAwMTAwODQxMDAxMDBkMTAxMDEwMGUxMDA5MGIyMjAxMDM3ZjEwMDg0MTAxMTAwZDEwMGIyMTAxMTAxMDIyMDIxMDBlMjIwMDIwMDAyMDAxMTAwYTIwMDIyMDAwMTAwZjBiMDMwMDAxMGIwYjJmMDIwMDQxODA4MDA4MGIxYzc3NzI2ZjZlNjcyMDZlNzU2ZDYyNjU3MjIwNmY2NjIwNjE3MjY3NzU2ZDY1NmU3NDczNzM3NTZkMDA0MTljODAwODBiMDQ5Y2ZmZmZmZkAwNTA2QDJh', 'chainID': 'D', 'version': 2, 'options': 0, 'guardian': '', 'signature': '', 'guardianSignature': ''}\n",
"Transaction data: upgradeContract@0061736d010000000129086000006000017f60027f7f017f60027f7f0060017f0060037f7f7f017f60037f7f7f0060017f017f0290020b03656e7619626967496e74476574556e7369676e6564417267756d656e74000303656e760f6765744e756d417267756d656e7473000103656e760b7369676e616c4572726f72000303656e76126d42756666657253746f726167654c6f6164000203656e76176d427566666572546f426967496e74556e7369676e6564000203656e76196d42756666657246726f6d426967496e74556e7369676e6564000203656e76136d42756666657253746f7261676553746f7265000203656e760f6d4275666665725365744279746573000503656e760e636865636b4e6f5061796d656e74000003656e7614626967496e7446696e697368556e7369676e6564000403656e7609626967496e744164640006030b0a010104070301000000000503010003060f027f0041a080080b7f0041a080080b074607066d656d6f7279020004696e697400110667657453756d00120361646400130863616c6c4261636b00140a5f5f646174615f656e6403000b5f5f686561705f6261736503010aca010a0e01017f4100100c2200100020000b1901017f419c8008419c800828020041016b220036020020000b1400100120004604400f0b4180800841191002000b16002000100c220010031a2000100c220010041a20000b1401017f100c2202200110051a2000200210061a0b1301017f100c220041998008410310071a20000b1401017f10084101100d100b210010102000100f0b0e0010084100100d1010100e10090b2201037f10084101100d100b210110102202100e220020002001100a20022000100f0b0300010b0b2f0200418080080b1c77726f6e67206e756d626572206f6620617267756d656e747373756d00419c80080b049cffffff@0506@2a\n"
]
}
],
"source": [
"contract_address = Address.from_bech32(\"erd1qqqqqqqqqqqqqpgquzmh78klkqwt0p4rjys0qtp3la07gz4d396qn50nnm\")\n",
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe use new_from_bech32()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

]
}
],
"source": [
"contract_address = Address.from_bech32(\"erd1qqqqqqqqqqqqqpgquzmh78klkqwt0p4rjys0qtp3la07gz4d396qn50nnm\")\n",
"contract_address = Address.from_bech32(\"erd1qqqqqqqqqqqqqpgqws44xjx2t056nn79fn29q0rjwfrd3m43396ql35kxy\")\n",
Copy link
Collaborator

Choose a reason for hiding this comment

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

use new_from_bech32()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Comment on lines 1124 to 1132
":::tip\n",
"When creating transactions using `SmartContractTransactionsFactory`, even if the ABI is available and provided,\n",
"you can still use _typed value_ objects as arguments for deployments and interactions.\n",
"\n",
"Even further, you can use a mix of _typed value_ objects and plain Python values and objects. For example:\n",
"```\n",
"args = [U32Value(42), \"hello\", { \"foo\": \"bar\" }, TokenIdentifierValue(\"TEST-abcdef\")];\n",
"```\n",
":::"
Copy link
Collaborator

Choose a reason for hiding this comment

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

same comment as above, does not look good in the notebook.

Comment on lines 1139 to 1141
":::note\n",
"Setting the transaction nonce, signing a transaction and broadcasting it are depicted in a later section.\n",
":::"
Copy link
Collaborator

Choose a reason for hiding this comment

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

this does not look good either.

Comment on lines 1227 to 1229
":::note\n",
"Documentation in this section is preliminary and subject to change.\n",
":::"
Copy link
Collaborator

Choose a reason for hiding this comment

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

same as above

Comment on lines 1238 to 1240
":::note\n",
"Documentation in this section is preliminary and subject to change.\n",
":::"
Copy link
Collaborator

Choose a reason for hiding this comment

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

same as above

popenta
popenta previously approved these changes Jun 17, 2024
@andreibancioiu andreibancioiu merged commit 7c747a6 into feat/codecs Jun 17, 2024
5 checks passed
@andreibancioiu andreibancioiu deleted the abi-examples branch June 17, 2024 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants