From cfc74a37c29dc40643ca32220eaf3d414572410d Mon Sep 17 00:00:00 2001 From: jules01 Date: Fri, 7 Jul 2023 14:06:15 +0300 Subject: [PATCH 1/4] - added more SC deploy scenario tests --- .../finishedFailedSCDeployWithTransfer.json | 125 ++++++++++++++++++ .../finishedOKSCDeployWithTransfer.json | 73 ++++++++++ process/transactionProcessor_test.go | 18 ++- 3 files changed, 215 insertions(+), 1 deletion(-) create mode 100644 process/testdata/finishedFailedSCDeployWithTransfer.json create mode 100644 process/testdata/finishedOKSCDeployWithTransfer.json diff --git a/process/testdata/finishedFailedSCDeployWithTransfer.json b/process/testdata/finishedFailedSCDeployWithTransfer.json new file mode 100644 index 00000000..b560d1dc --- /dev/null +++ b/process/testdata/finishedFailedSCDeployWithTransfer.json @@ -0,0 +1,125 @@ +{ + "transaction": { + "type": "normal", + "processingTypeOnSource": "SCInvoking", + "processingTypeOnDestination": "SCInvoking", + "hash": "a4823050d2396540b17bd9290523973763142c9f655bb26cd9e33f359b6d73ad", + "nonce": 9, + "round": 2735017, + "epoch": 2277, + "value": "1000", + "receiver": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty", + "sender": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty", + "data": "ZG9fZGVwbG95QDAwMDAwMDAwMDAwMDAwMDAwNTAwRkIxNUE1MEZGNUQ2MEQyQUI5NjA3MTgyRDdCQjM2MjlEQThFNkQxOEEwMTJAMDAwMDAwMDAwMDAwMDAwMDAwMDEwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAxRkZGRg==", + "smartContractResults": [ + { + "hash": "SCR-hash1", + "receiver": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty", + "sender": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty", + "operation": "transfer" + }, + { + "hash": "SCR-hash2", + "receiver": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty", + "sender": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty", + "data": "@73656e64696e672076616c756520746f206e6f6e2070617961626c6520636f6e7472616374", + "returnMessage": "sending value to non payable contract", + "operation": "transfer" + } + ], + "logs": { + "address": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty", + "events": [ + { + "address": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty", + "identifier": "transferValueOnly", + "topics": [ + "AAAAAAAAAAAFAAc2sq9MjfurX+5zluCpV5y58QqNoBI=", + "AAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAB//8=", + "A+g=" + ], + "data": null + }, + { + "address": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty", + "identifier": "SCDeploy", + "topics": [ + "AAAAAAAAAAAFAOchRUX9HQDwjcJbkLd9jkXd5nAjoBI=", + "AAAAAAAAAAAFAAc2sq9MjfurX+5zluCpV5y58QqNoBI=" + ], + "data": null + }, + { + "address": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty", + "identifier": "writeLog", + "topics": [ + "VuJjyDpv3q8GVEqm7SLrVgl7ySOB9Ya6HTmmeI4+oBI=", + "QHRvbyBtdWNoIGdhcyBwcm92aWRlZCBmb3IgcHJvY2Vzc2luZzogZ2FzIHByb3ZpZGVkID0gNDk3NDE1MDAsIGdhcyB1c2VkID0gMTUxMzQyMA==" + ], + "data": "QDZmNmI=" + } + ] + }, + "status": "success", + "operation": "transfer", + "function": "do_deploy", + "chainID": "T" + }, + "scrs": [ + { + "type": "unsigned", + "processingTypeOnSource": "MoveBalance", + "processingTypeOnDestination": "MoveBalance", + "hash": "SCR-hash1", + "receiver": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty", + "sender": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty", + "gasPrice": 1000000000, + "sourceShard": 2, + "destinationShard": 4294967295, + "blockNonce": 2733469, + "miniblockType": "SmartContractResultBlock", + "logs": { + "address": "erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqplllst77y4l", + "events": [ + { + "address": "erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqplllst77y4l", + "identifier": "signalError", + "topics": [ + "AAAAAAAAAAAFAAc2sq9MjfurX+5zluCpV5y58QqNoBI=", + "c2VuZGluZyB2YWx1ZSB0byBub24gcGF5YWJsZSBjb250cmFjdA==" + ], + "data": "QDczNjU2ZTY0Njk2ZTY3MjA3NjYxNmM3NTY1MjA3NDZmMjA2ZTZmNmUyMDcwNjE3OTYxNjI2YzY1MjA2MzZmNmU3NDcyNjE2Mzc0" + } + ] + }, + "status": "success", + "operation": "transfer", + "fee": "0", + "callType": "directCall", + "options": 0 + }, + { + "type": "unsigned", + "processingTypeOnSource": "MoveBalance", + "processingTypeOnDestination": "MoveBalance", + "hash": "SCR-hash2", + "nonce": 0, + "round": 2735021, + "epoch": 2277, + "value": "1000", + "receiver": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty", + "sender": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty", + "gasUsed": 162500, + "data": "QDczNjU2ZTY0Njk2ZTY3MjA3NjYxNmM3NTY1MjA3NDZmMjA2ZTZmNmUyMDcwNjE3OTYxNjI2YzY1MjA2MzZmNmU3NDcyNjE2Mzc0", + "returnMessage": "sending value to non payable contract", + "originalSender": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty", + "sourceShard": 4294967295, + "destinationShard": 2, + "status": "success", + "operation": "transfer", + "fee": "0", + "callType": "directCall", + "options": 0 + } + ] +} \ No newline at end of file diff --git a/process/testdata/finishedOKSCDeployWithTransfer.json b/process/testdata/finishedOKSCDeployWithTransfer.json new file mode 100644 index 00000000..4d3c17e5 --- /dev/null +++ b/process/testdata/finishedOKSCDeployWithTransfer.json @@ -0,0 +1,73 @@ +{ + "transaction": { + "type": "normal", + "processingTypeOnSource": "SCInvoking", + "processingTypeOnDestination": "SCInvoking", + "hash": "a4823050d2396540b17bd9290523973763142c9f655bb26cd9e33f359b6d73ad", + "receiver": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty", + "sender": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty", + "data": "ZG9fZGVwbG95QDAwMDAwMDAwMDAwMDAwMDAwNTAwRkIxNUE1MEZGNUQ2MEQyQUI5NjA3MTgyRDdCQjM2MjlEQThFNkQxOEEwMTJAQTlGNkE4MUFBN0RBNzY3OEE5NTg1NTgyOURBMjVFM0EyOTI3OUJDM0QwQjQ0QTg4RjI1MUMxNkFEM0JFQUNEQw==", + "smartContractResults": [ + { + "hash": "SCR-hash1", + "receiver": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty", + "sender": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty", + "operation": "transfer" + } + ], + "logs": { + "address": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty", + "events": [ + { + "address": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty", + "identifier": "transferValueOnly", + "topics": [ + "AAAAAAAAAAAFAAc2sq9MjfurX+5zluCpV5y58QqNoBI=", + "qfaoGqfadnipWFWCnaJeOiknm8PQtEqI8lHBatO+rNw=", + "A+g=" + ], + "data": null + }, + { + "address": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty", + "identifier": "SCDeploy", + "topics": [ + "AAAAAAAAAAAFAPiodj5xVGTYTcUG7NG4iLn/T/TUoBI=", + "AAAAAAAAAAAFAAc2sq9MjfurX+5zluCpV5y58QqNoBI=" + ], + "data": null + }, + { + "address": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty", + "identifier": "writeLog", + "topics": [ + "VuJjyDpv3q8GVEqm7SLrVgl7ySOB9Ya6HTmmeI4+oBI=", + "QHRvbyBtdWNoIGdhcyBwcm92aWRlZCBmb3IgcHJvY2Vzc2luZzogZ2FzIHByb3ZpZGVkID0gNDk3NDE1MDAsIGdhcyB1c2VkID0gMTUxMzQyMA==" + ], + "data": "QDZmNmI=" + } + ] + }, + "status": "success", + "operation": "transfer", + "function": "do_deploy", + "chainID": "T", + "version": 2, + "options": 0 + }, + "scrs": [ + { + "type": "unsigned", + "processingTypeOnSource": "MoveBalance", + "processingTypeOnDestination": "MoveBalance", + "hash": "SCR-hash1", + "receiver": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty", + "sender": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty", + "status": "success", + "operation": "transfer", + "fee": "0", + "callType": "directCall", + "options": 0 + } + ] +} \ No newline at end of file diff --git a/process/transactionProcessor_test.go b/process/transactionProcessor_test.go index 5d39bd3e..4ad18a51 100644 --- a/process/transactionProcessor_test.go +++ b/process/transactionProcessor_test.go @@ -1835,7 +1835,7 @@ func TestTransactionProcessor_computeTransactionStatus(t *testing.T) { }) }) t.Run("SC deploy", func(t *testing.T) { - t.Run("tx ok", func(t *testing.T) { + t.Run("ok simple SC deploy", func(t *testing.T) { t.Parallel() testData := loadJsonIntoTxAndScrs(t, "./testdata/finishedOKSCDeploy.json") @@ -1843,6 +1843,22 @@ func TestTransactionProcessor_computeTransactionStatus(t *testing.T) { status := tp.ComputeTransactionStatus(testData.Transaction, withResults) require.Equal(t, transaction.TxStatusSuccess, status) }) + t.Run("ok SC deploy with transfer value", func(t *testing.T) { + t.Parallel() + + testData := loadJsonIntoTxAndScrs(t, "./testdata/finishedOKSCDeployWithTransfer.json") + tp := createTestProcessorFromScenarioData(testData) + status := tp.ComputeTransactionStatus(testData.Transaction, withResults) + require.Equal(t, transaction.TxStatusSuccess, status) + }) + t.Run("failed SC deploy with transfer value", func(t *testing.T) { + t.Parallel() + + testData := loadJsonIntoTxAndScrs(t, "./testdata/finishedFailedSCDeployWithTransfer.json") + tp := createTestProcessorFromScenarioData(testData) + status := tp.ComputeTransactionStatus(testData.Transaction, withResults) + require.Equal(t, transaction.TxStatusFail, status) + }) }) t.Run("complex scenarios with failed async calls", func(t *testing.T) { t.Run("scenario 1: tx failed with ESDTs and SC calls", func(t *testing.T) { From 5f0f7d12f77dc4637d804feedaa0bead80438bc4 Mon Sep 17 00:00:00 2001 From: jules01 Date: Fri, 7 Jul 2023 14:43:54 +0300 Subject: [PATCH 2/4] - added empty line at the end of the files --- process/testdata/finishedFailedSCDeployWithTransfer.json | 2 +- process/testdata/finishedOKSCDeployWithTransfer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/process/testdata/finishedFailedSCDeployWithTransfer.json b/process/testdata/finishedFailedSCDeployWithTransfer.json index b560d1dc..e9a9eb82 100644 --- a/process/testdata/finishedFailedSCDeployWithTransfer.json +++ b/process/testdata/finishedFailedSCDeployWithTransfer.json @@ -122,4 +122,4 @@ "options": 0 } ] -} \ No newline at end of file +} diff --git a/process/testdata/finishedOKSCDeployWithTransfer.json b/process/testdata/finishedOKSCDeployWithTransfer.json index 4d3c17e5..33744dc4 100644 --- a/process/testdata/finishedOKSCDeployWithTransfer.json +++ b/process/testdata/finishedOKSCDeployWithTransfer.json @@ -70,4 +70,4 @@ "options": 0 } ] -} \ No newline at end of file +} From f8b4f50306c95f88fed400a5de4b54aeef6c4f0f Mon Sep 17 00:00:00 2001 From: Bogdan Rosianu Date: Fri, 21 Jul 2023 14:17:59 +0300 Subject: [PATCH 3/4] swagger ui updates --- cmd/proxy/config/swagger/favicon-16x16.png | Bin 665 -> 259 bytes cmd/proxy/config/swagger/favicon-32x32.png | Bin 628 -> 385 bytes cmd/proxy/config/swagger/index.html | 2 +- cmd/proxy/config/swagger/mvx-icon.png | Bin 0 -> 4851 bytes cmd/proxy/config/swagger/openapi.json | 96 ++++++++++-------- .../config/swagger/swagger-initializer.js | 14 ++- 6 files changed, 68 insertions(+), 44 deletions(-) create mode 100644 cmd/proxy/config/swagger/mvx-icon.png diff --git a/cmd/proxy/config/swagger/favicon-16x16.png b/cmd/proxy/config/swagger/favicon-16x16.png index 8b194e617af1c135e6b37939591d24ac3a5efa18..0faa5da4ba2bbe81b15850e9cc421d854c896fcb 100644 GIT binary patch delta 232 zcmbQq+RQXTxt_r+z$e7jy}(E1-xH;;xB0W;8Nq;ofdRq*k|O;L;)^G7`?{+A|Df>r zlwft9)V9S^+ZP*T_`d+E<0=XA3ugHL|NlbY|0jR@-Fo(OCQ!7<)5S4FVrpvtZJ`DQ z4wrDBJriR8{ZD6Jd$LG=#?v=UWTK7V*Z_=RiR)_mD|IdT8x!+&H1 e?tM4i&tSZr_0yXlv(tgrGkCiCxvX}JKSduyL>)s!A4EhTMMEM**HAWCILJToU6)QjhBuM}>O#m}900000004#RErjVTgXk=R z<}HEcEPvuIfZ;BE-7b9HE_Tu|bkHzz$}w@tF>uH+Z^klh#W8KfF>J#!YrryUzcOjQ zGibXrXu30JxPLQCjX6q+I!cK;M1MO&e>^~WJwA6mIc`2UZ9X_|KQ?MVHE2IGWj`A| zMH@av96v=IJw+ZvMIS^&AVx%BB@r(G00295QchF!^!4@j_4oGf?(gvG>gVC%;Nauq z-`v~V+S%CH+t0tex~!|IsiB#cl#YpogiJ9c9vvSQ41Wg-1pxpD2d>Eg007uYL_t(| z+C9(NE<;fmhT+d{ij7ifsUn89G0$_>yIZq_5*tB`HIzGb;D)3U!CK8upQHc(&R!X7 zE|*Dm4@@n&TgI#pca%#|I!=tPx?y85PNZpQ%?^c@=-t~SmN%OB;qn3N@gCY1R0!dH z3v1^M!g@*d1n?T*yg<;W6kOfxpC6nao>VR%?fpr=asSJ&`L*wu^rLJ5Peq*PB0;al zL#XazZCBxJLd&giTfw@!hW167F^`7kobi;(e<<>qNlP|xy7S1zl@lZNIBR7#o9ybJ bsptO#%}P0hz~sBp00000NkvXXu0mjf$+QP` diff --git a/cmd/proxy/config/swagger/favicon-32x32.png b/cmd/proxy/config/swagger/favicon-32x32.png index 249737fe44558e679f0b67134e274461d988fa98..3bc0dad22151e375624d9e9d289f80c01930147e 100644 GIT binary patch delta 358 zcmeyu(#SkPrQR&SC&bmgz=x5Mk%5s>`NusV0}ZJBeYcQiwivov9$sQ-e zzyH(y1O47=%}nztUz*Ci)PisG!FrL|mLdK8caFJ#_$$YLL%br{=E?i`%EOGC{*@nE z$g}=ryx{x_!>-r;9q(iwURFHzDQPv!@~v*ZaeB{tudVBPFnN>yoJq@K)>;2oW|$E0 zWBR5Uu<`8w`szS_vY;${DlOsBI4_WyR-cSm`-&H^`|bfE7UJYD@<);T3K0RVKt BoF@PP delta 603 zcmV-h0;K(c1M~!tB!7@lOjJbx000m(L>4th7B)r~Hbww0IuHAWUTMiw0}OV<074bNCP z7P7GVd{iMr*MC_p^;-**Jn$ugJVa~z$IE7iN#xHECAixdy+_#1Um$11o9qcU=Eeyp zIuUzKOaBE*y0%q*m=6EGT)Ii|C<9o@@T)n-qo$>CHps*sf*h&*R9K{wX^dBCM4exP zCEtFGnQ>lYE9KR-;ee{b2F0ZB1vc_=!vi=>^^c>J8h?~a5ikcXv3g?X&(Kgsk1s$9 z)i_M%gaT6~&!F-Rk=K3OWkJJ*;7wn13}u!UxFaD8IKKKr!pBiPmSKZ0l5bm>9!+soAY=%`}HONd3 z%cG$*Dpc4Y_276ZYmwuIqwbnPRQ9ul0sH*V%7JISUs`~J#qy;-r^JH^ALRYv0IV+f p_Vk7@XB>|A@qD}{&i2*${{Y5}Mti=v1!n*N002ovPDHLkV1gP^1sMPU diff --git a/cmd/proxy/config/swagger/index.html b/cmd/proxy/config/swagger/index.html index 84ae62d3..b9f86f94 100644 --- a/cmd/proxy/config/swagger/index.html +++ b/cmd/proxy/config/swagger/index.html @@ -3,7 +3,7 @@ - Swagger UI + MultiversX Gateway diff --git a/cmd/proxy/config/swagger/mvx-icon.png b/cmd/proxy/config/swagger/mvx-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..222ee1ff6e2f704da7eb2364bea743405262187a GIT binary patch literal 4851 zcmZ{I2T)T_^ll&s0cjzCRA~YR0RtK!^pZfR(m{&Sl^&#pB27x@f;5#T5Sr34DmBst zqzOnhR6&#`RqD%c-preM^Pm6R*?VU8?sxa>x!-s8+>JLh&|;wDq5}W`4BBX1!K(Gh^5D^UkoRGUB)&T&27yz(g2LQ`uU<$qUUYuO8O4~?I;K8j|IhK&v(VcJ%$3;=+?X(QE4u``=_LC;OivU$H9p@)VvFDhpIMAj89ytjxeDRkm8DDWC_14243b@hJ*PfqM*R ziAT;b8Mvz=sqm(q1-ud5k!h;ocWGlHgjAMa`E*6P-9>OmbQ9(Ag%X=2i9I03== zh%ZE5B0NHrB$O=_9l1$VTma(7&A~wTMJ`VxPsCnqFun4DoOax$?mhVk_cJEDxG^#jI=;Tdn?35hs2MyQHHIYZwL zuCFGN1kBs3+C)Sf7uq0~bSm@(SyUiUeU`BZ`U2b;H5Poc??dbwzar5N>;uJ5CZhkW zp%D@S$>PhXg&<;{_tznNxd;kDhnx7xi(LF&ZJcpGYudv%62+NG`}UOQs2fiA6Wlh6 zf~VfSETx5AQF_$aRw_+HGjb1k$PrsNacIJ|#Co;vT`|)RT@?f?vp^9H#hWMgMfQaC z{}L}@*rC}UBd|@YK@F+JS<=v*Oa_8o2{Q&73Qw!TGy{CDU{sMZcNG^W<^nazR zu45(bii#I?kt^j&*&Ky?96C@SHhOZ(RC1KzIL27VEFF1e8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kLe4@vsoasH)%$aTOXEgkx~mYf9v`ULHLZ3ci#bJweWRy1+qZ0?p~sSRBB`JM z%q^akTQ%B4e2;H_4k`fWNG0~kS|9wD)#xg@huhTk`;-xNDr$t?M)KHRQ1^XinUwrU zC~&+~xTc&0+ATPQP*}>+^ z^Cq!bE(a-xkVE5UCpNN*;zJKS_!iK)L&t{?X%6J^~%L$@S>A;UT{RXrotJ4Lg% zD#Ah-;SFmhfjelOk`g_f_aJ7b{eX|7J7(Ip!;0IFMU)cRHlx1Nd5>1&J}PuO^~-J5 zXuNLbY z{d}iMWybw;XL;D<&LcIe*&-7KIaO#4w89PsQfI;}JTvryWkGUF5%DPL){t$X0SH7yn0>#+F zn)3&78bg|#r`TjW+t`umzMq8q6s%tA}$)ixuIon(pL`M1sf3#yP_Z_8W6|JFv{pk4Wf zZwUTn-!YU=z>&00f8Aaz2tEB`?tsAf$E7eoXii&b>5jGt)jlf&9`rY&$N3Duu^;I_ z-B07`^y(S?^eliH62CHZ`&)_2q#~oruDXbr5a~(bYkMJ*aM4jHV! zFB6gR+cPN4=(XsdVVX_@hrVk$D!Oe=#b)H<2OqFYmpfnG6?h6G*V!+$XNBuC=ij%nD!W#s!_EiM0>W4xvR2a+x>TihLzhHhlKSZ<6K3>%) z(MF?O?j4kYzVRnZYj)(EXq{#~Xs+XFp_7KbkCH|6+if?00;~z<#M67!F(4W5w{-x)ndgp;gvbeMCNaEy#g|89q zS*x*I?D;F>M>lgGPqx?%Lu2hdOmwO=WgoTIe`*h>5R5&%lP^W@2t9mI?~uQU&BwqD!=Rl7&y&~m`6nZ_w`OU^0`69FLd`Jm@hQsR~M_{(k^ZZzormp#L2p t6`pm647mCKX7F?MboTYL_r&~9%w72Zo#Yf&Ge^b%v{44gYIVD){{u&51iJtL literal 0 HcmV?d00001 diff --git a/cmd/proxy/config/swagger/openapi.json b/cmd/proxy/config/swagger/openapi.json index 41539fe3..e6fdeda5 100644 --- a/cmd/proxy/config/swagger/openapi.json +++ b/cmd/proxy/config/swagger/openapi.json @@ -1,8 +1,8 @@ { "openapi": "3.0.3", "info": { - "title": "MultiversX Proxy API", - "description": "## Welcome to the MultiversX Proxy API\n\nThe documentation describes the endpoints that are available on the mx-chain-proxy-go project. This is used on `gateway.multiversx.com` while the public api (`api.multiversx.com`) is a wrapper over it.\n\nThis API is organized around REST principles, so if you've interacted with RESTful APIs before, many of the concepts will look familiar.\n\n## Request / Response Format\n\nJSON will be returned for all responses, including errors. Empty or blank fields are omitted. Requests with a message body use JSON as well. Successful requests will return a `2xx` HTTP status.\n\nThe general structure of a response is:\n``` JSON\n{\n data anything\n error string\n code string\n}\n```\nWhere:\n- data: the expected result if the request was successful. `null` otherwise\n- error: if the request failed, the reason will be returned in this field. empty otherwise\n- code: the internal code for the request. can be `successful`, `internal_issue` or `bad_request`\n", + "title": "MultiversX Gateway API", + "description": "![MultiversX](/mvx-icon.png)\n\nThe documentation describes the endpoints that are available on the mx-chain-proxy-go project. \n\nGithub URL: `https://github.com/multiversx/mx-chain-proxy-go`\n\nThis is used on `gateway.multiversx.com` while the public api (`api.multiversx.com`) is a wrapper over it.\n\nThis API is organized around REST principles, so if you've interacted with RESTful APIs before, many of the concepts will look familiar.\n\n## Request / Response Format\n\nJSON will be returned for all responses, including errors. Empty or blank fields are omitted. Requests with a message body use JSON as well. Successful requests will return a `2xx` HTTP status.\n\nThe general structure of a response is:\n``` JSON\n{\n data anything\n error string\n code string\n}\n```\nWhere:\n- data: the expected result if the request was successful. `null` otherwise\n- error: if the request failed, the reason will be returned in this field. empty otherwise\n- code: the internal code for the request. can be `successful`, `internal_issue` or `bad_request`\n", "version": "1.1.0" }, "paths": { @@ -2261,7 +2261,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Transaction" + "$ref": "#/components/schemas/TxStatusResponse" } } } @@ -2293,10 +2293,39 @@ "content": { "application/json": { "schema": { - "type": "object", - "items": { - "$ref": "#/components/schemas/AddressEsdtToken" - } + "$ref": "#/components/schemas/TxStatusResponse" + } + } + } + } + } + } + }, + "/transaction/{txhash}/process-status": { + "get": { + "tags": [ + "transaction" + ], + "summary": "returns the processing status of the transaction which corresponds to the hash. It searches for SCRs generated by the transaction and computes the actual processing status", + "parameters": [ + { + "name": "txhash", + "in": "path", + "description": "the transaction hash to search for", + "required": true, + "schema": { + "type": "string", + "default": null + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TxStatusResponse" } } } @@ -2453,40 +2482,6 @@ } } }, - "/transaction/{hash}/status": { - "get": { - "tags": [ - "transaction" - ], - "summary": "retrieves the status of the transaction with the provided hash", - "parameters": [ - { - "name": "hash", - "in": "path", - "required": true, - "description": "the hash of the transaction to look after", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "successful operation", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GenericResponse" - } - } - } - }, - "400": { - "description": "validation error" - } - } - } - }, "/validator/statistics": { "get": { "tags": [ @@ -3152,6 +3147,25 @@ } } }, + "TxStatusResponse": { + "type": "object", + "properties": { + "data": { + "type": "object", + "properties": { + "status": { + "type": "string" + } + } + }, + "error": { + "type": "string" + }, + "code": { + "type": "string" + } + } + }, "Guardian": { "type": "object", "properties": { diff --git a/cmd/proxy/config/swagger/swagger-initializer.js b/cmd/proxy/config/swagger/swagger-initializer.js index 1e4c816e..76ffa305 100644 --- a/cmd/proxy/config/swagger/swagger-initializer.js +++ b/cmd/proxy/config/swagger/swagger-initializer.js @@ -1,6 +1,15 @@ window.onload = function() { // + // Custom plugin to hide the API definition URL + const HideInfoUrlPartsPlugin = () => { + return { + wrapComponents: { + InfoUrl: () => () => null + } + } + } + // the following lines will be replaced by docker/configurator, when it runs in a docker-container window.ui = SwaggerUIBundle({ url: "openapi.json", @@ -8,10 +17,11 @@ window.onload = function() { deepLinking: true, presets: [ SwaggerUIBundle.presets.apis, - SwaggerUIStandalonePreset + SwaggerUIStandalonePreset.slice(1) ], plugins: [ - SwaggerUIBundle.plugins.DownloadUrl + SwaggerUIBundle.plugins.DownloadUrl, + HideInfoUrlPartsPlugin ], layout: "StandaloneLayout" }); From 804d3f2f83767bc11afe6bced0d725b00df46953 Mon Sep 17 00:00:00 2001 From: Bogdan Rosianu Date: Tue, 26 Sep 2023 15:56:39 +0300 Subject: [PATCH 4/4] removed inconsistency check for repopulated tokens supply --- process/errors.go | 3 -- process/esdtSupplyProcessor.go | 8 ---- process/esdtSupplyProcessor_test.go | 57 ----------------------------- 3 files changed, 68 deletions(-) diff --git a/process/errors.go b/process/errors.go index 3fd82766..e5f1ddbc 100644 --- a/process/errors.go +++ b/process/errors.go @@ -109,6 +109,3 @@ var ErrEmptyAppVersionString = errors.New("empty app version string") // ErrEmptyCommitString signals than an empty commit id string has been provided var ErrEmptyCommitString = errors.New("empty commit id string") - -// ErrInconsistentTokensSuppliesResponses signals an inconsistent response from the nodes -var ErrInconsistentTokensSuppliesResponses = errors.New("inconsistent tokens supplies shard responses") diff --git a/process/esdtSupplyProcessor.go b/process/esdtSupplyProcessor.go index 957bfb6d..37998d80 100644 --- a/process/esdtSupplyProcessor.go +++ b/process/esdtSupplyProcessor.go @@ -103,14 +103,6 @@ func (esp *esdtSupplyProcessor) getSupplyFromShards(tokenIdentifier string) (*da } if numNodesWithRecomputedSupply > 0 { - if numNodesWithRecomputedSupply != numNodesQueried { - // this means that some nodes have recomputed supply and some don't - log.Error("inconsistent observers setup: some nodes have recomputed supply and some don't", - "numNodesWithRecomputedSupply", numNodesWithRecomputedSupply, - "numNodesQueried", numNodesQueried) - return nil, ErrInconsistentTokensSuppliesResponses - } - totalSupply.RecomputedSupply = true } diff --git a/process/esdtSupplyProcessor_test.go b/process/esdtSupplyProcessor_test.go index d73dda9b..a12e0c16 100644 --- a/process/esdtSupplyProcessor_test.go +++ b/process/esdtSupplyProcessor_test.go @@ -120,63 +120,6 @@ func TestEsdtSupplyProcessor_GetESDTSupplyNonFungible(t *testing.T) { require.Equal(t, "0", supplyRes.Data.InitialMinted) } -func TestEsdtSupplyProcessor_GetESDTSupplyShouldReturnErrorIfInconsistentResponses(t *testing.T) { - t.Parallel() - - called := false - baseProc := &mock.ProcessorStub{ - GetShardIDsCalled: func() []uint32 { - return []uint32{0, 1, core.MetachainShardId} - }, - GetObserversCalled: func(shardID uint32) ([]*data.NodeData, error) { - return []*data.NodeData{ - { - ShardId: shardID, - Address: fmt.Sprintf("shard-%d", shardID), - }, - { - ShardId: shardID, - Address: fmt.Sprintf("shard-%d", shardID), - }, - }, nil - }, - CallGetRestEndPointCalled: func(address string, path string, value interface{}) (int, error) { - switch address { - case "shard-0": - if !called { - called = true - return 400, errors.New("local err") - } - valResp := value.(*data.ESDTSupplyResponse) - valResp.Data.Supply = "300" - valResp.Data.RecomputedSupply = true - return 200, nil - case "shard-1": - valResp := value.(*data.ESDTSupplyResponse) - valResp.Data.Supply = "600" - valResp.Data.Minted = "50" - valResp.Data.Burned = "100" - valResp.Data.RecomputedSupply = false - return 200, nil - } - return 0, nil - }, - } - scQueryProc := &mock.SCQueryServiceStub{ - ExecuteQueryCalled: func(query *data.SCQuery) (*vm.VMOutputApi, data.BlockInfo, error) { - return &vm.VMOutputApi{ - ReturnData: [][]byte{nil, nil, nil, []byte("500")}, - }, data.BlockInfo{}, nil - }, - } - esdtProc, err := NewESDTSupplyProcessor(baseProc, scQueryProc) - require.Nil(t, err) - - supplyRes, err := esdtProc.GetESDTSupply("SEMI-ABCDEF") - require.Empty(t, supplyRes) - require.Equal(t, ErrInconsistentTokensSuppliesResponses, err) -} - func TestEsdtSupplyProcessor_GetESDTSupplyShouldReturnRecomputed(t *testing.T) { t.Parallel()