blockfrost / blockfrost-dotnet

.NET, C# and PowerShell SDK for Blockfrost.io API
Apache License 2.0
17 stars 9 forks source link

Submit transaction via string #35

Closed tweakch closed 3 years ago

tweakch commented 3 years ago

Description

The SubmitAsync(String) method of the transaction service should inform the user that it expects the serialized and signed cborHex property of a transaction signed with cardano-cli.

{
  "type": "TxBodyMary",
  "description": "",
  "cborHex": "83a3008182582098035740ab68cad12cb4d8281d10ce1112ef0933dc84920b8937c3e80d78d12000018282581d60d0c43926a989c88d5049e61bdebf2a887aca10fa284b9067373ea28f0082581d603b75186909c120a97f6f0ee6822701f075e5136f3b9a08604a63dce700020080f6"
}

Meaning only hexadecimal characters are allowed: /[0-9a-f]+/i

Sample CBOR

83a3008182582098035740ab68cad12cb4d8281d10ce1112ef0933dc84920b8937c3e80d78d12000018282581d60d0c43926a989c88d5049e61bdebf2a887aca10fa284b9067373ea28f0082581d603b75186909c120a97f6f0ee6822701f075e5136f3b9a08604a63dce700020080f6
The above CBOR hex analyzed
83                                      # array(3)
   A3                                   # map(3)
      00                                # unsigned(0)
      81                                # array(1)
         82                             # array(2)
            58 20                       # bytes(32)
               98035740AB68CAD12CB4D8281D10CE1112EF0933DC84920B8937C3E80D78D120 # "\x98\x03W@\xABh\xCA\xD1,\xB4\xD8(\x1D\x10\xCE\x11\x12\xEF\t3\xDC\x84\x92\v\x897\xC3\xE8\rx\xD1 "
            00                          # unsigned(0)
      01                                # unsigned(1)
      82                                # array(2)
         82                             # array(2)
            58 1D                       # bytes(29)
               60D0C43926A989C88D5049E61BDEBF2A887ACA10FA284B9067373EA28F # "`\xD0\xC49&\xA9\x89\xC8\x8DPI\xE6\e\xDE\xBF*\x88z\xCA\x10\xFA(K\x90g7>\xA2\x8F"
            00                          # unsigned(0)
         82                             # array(2)
            58 1D                       # bytes(29)
               603B75186909C120A97F6F0EE6822701F075E5136F3B9A08604A63DCE7 # "`;u\x18i\t\xC1 \xA9\x7Fo\x0E\xE6\x82'\x01\xF0u\xE5\x13o;\x9A\b`Jc\xDC\xE7"
            00                          # unsigned(0)
      02                                # unsigned(2)
      00                                # unsigned(0)
   80                                   # array(0)
   F6                                   # primitive(22)

Possible Improvements

We could also allow the actual CBOR (unhexed) and try to perform the hexdump within the Method to improve usability:

[{0: [[h'98035740AB68CAD12CB4D8281D10CE1112EF0933DC84920B8937C3E80D78D120', 0]], 1: [[h'60D0C43926A989C88D5049E61BDEBF2A887ACA10FA284B9067373EA28F', 0], [h'603B75186909C120A97F6F0EE6822701F075E5136F3B9A08604A63DCE7', 0]], 2: 0}, [], null]
tweakch commented 3 years ago

@mmahut @eddex I did a prerelease of this branch on nuget

TxSubmit works... and together with BlockService and AddressService you can already do some cool stuff

still a lot to do in this PR and generally... but we are getting ahead