nitowa 1 рік тому
джерело
коміт
bbe32c2c2d

+ 47
- 157
package-lock.json Переглянути файл

@@ -12,8 +12,8 @@
12 12
         "buffer": "^6.0.3",
13 13
         "chai": "^4.3.4",
14 14
         "node-fetch": "^2.6.1",
15
-        "xrpio": "^0.1.7",
16
-        "xrpl": "^2.6.0-beta.0"
15
+        "xrpio": "^0.2.1",
16
+        "xrpl": "^2.7.0"
17 17
       },
18 18
       "devDependencies": {
19 19
         "@types/node": "^18.11.9",
@@ -2791,11 +2791,11 @@
2791 2791
       }
2792 2792
     },
2793 2793
     "node_modules/ripple-address-codec": {
2794
-      "version": "4.2.4",
2795
-      "resolved": "https://registry.npmjs.org/ripple-address-codec/-/ripple-address-codec-4.2.4.tgz",
2796
-      "integrity": "sha512-roAOjKz94+FboTItey1XRh5qynwt4xvfBLvbbcx+FiR94Yw2x3LrKLF2GVCMCSAh5I6PkcpADg6AbYsUbGN3nA==",
2794
+      "version": "4.2.5",
2795
+      "resolved": "https://registry.npmjs.org/ripple-address-codec/-/ripple-address-codec-4.2.5.tgz",
2796
+      "integrity": "sha512-SZ96zZH+0REeyEcYVFl0vqcsGRXiFXS2RUgHupHhtVkOEk6men53vngVjJwBrSnY+oa6Cri15q1zSni3DEoxNw==",
2797 2797
       "dependencies": {
2798
-        "base-x": "3.0.9",
2798
+        "base-x": "^3.0.9",
2799 2799
         "create-hash": "^1.1.2"
2800 2800
       },
2801 2801
       "engines": {
@@ -2803,19 +2803,19 @@
2803 2803
       }
2804 2804
     },
2805 2805
     "node_modules/ripple-binary-codec": {
2806
-      "version": "1.4.2",
2807
-      "resolved": "https://registry.npmjs.org/ripple-binary-codec/-/ripple-binary-codec-1.4.2.tgz",
2808
-      "integrity": "sha512-EDKIyZMa/6Ay/oNgCwjD9b9CJv0zmBreeHVQeG4BYwy+9GPnIQjNeT5e/aB6OjAnhcmpgbPeBmzwmNVwzxlt0w==",
2806
+      "version": "1.4.3",
2807
+      "resolved": "https://registry.npmjs.org/ripple-binary-codec/-/ripple-binary-codec-1.4.3.tgz",
2808
+      "integrity": "sha512-P4ALjAJWBJpRApTQO+dJCrHE6mZxm7ypZot9OS0a3RCKOWTReNw0pDWfdhCGh1qXh71TeQnAk4CHdMLwR/76oQ==",
2809 2809
       "dependencies": {
2810 2810
         "assert": "^2.0.0",
2811 2811
         "big-integer": "^1.6.48",
2812 2812
         "buffer": "5.6.0",
2813 2813
         "create-hash": "^1.2.0",
2814 2814
         "decimal.js": "^10.2.0",
2815
-        "ripple-address-codec": "^4.2.4"
2815
+        "ripple-address-codec": "^4.2.5"
2816 2816
       },
2817 2817
       "engines": {
2818
-        "node": ">=10.22.0"
2818
+        "node": ">= 10"
2819 2819
       }
2820 2820
     },
2821 2821
     "node_modules/ripple-binary-codec/node_modules/buffer": {
@@ -2828,15 +2828,15 @@
2828 2828
       }
2829 2829
     },
2830 2830
     "node_modules/ripple-keypairs": {
2831
-      "version": "1.1.4",
2832
-      "resolved": "https://registry.npmjs.org/ripple-keypairs/-/ripple-keypairs-1.1.4.tgz",
2833
-      "integrity": "sha512-PMMjTOxZmCSBOvHPj6bA+V/HGx7oFgDtGGI8VcZYuaFO2H87UX0X0jhfHy+LA2Xy31WYlD7GaDIDDt2QO+AMtw==",
2831
+      "version": "1.1.5",
2832
+      "resolved": "https://registry.npmjs.org/ripple-keypairs/-/ripple-keypairs-1.1.5.tgz",
2833
+      "integrity": "sha512-wLJXIBsMVazn2Yp/7oP4PvgA4Gd1HtuZLftdEJFNOLgraf82phqa2AnNK3t9f3XeQnApW1jAe/FcFFOY6QUn5w==",
2834 2834
       "dependencies": {
2835 2835
         "bn.js": "^5.1.1",
2836 2836
         "brorand": "^1.0.5",
2837 2837
         "elliptic": "^6.5.4",
2838 2838
         "hash.js": "^1.0.3",
2839
-        "ripple-address-codec": "^4.2.4"
2839
+        "ripple-address-codec": "^4.2.5"
2840 2840
       },
2841 2841
       "engines": {
2842 2842
         "node": ">= 10"
@@ -3685,97 +3685,33 @@
3685 3685
       }
3686 3686
     },
3687 3687
     "node_modules/xrpio": {
3688
-      "version": "0.1.7",
3689
-      "resolved": "https://registry.npmjs.org/xrpio/-/xrpio-0.1.7.tgz",
3690
-      "integrity": "sha512-X/Hxlf31KC1OONq7NYQ518Esd8LHYpyc/RFN9F1J9Nr8WEjgz/XaJDR4IakV7MrNeC3uIRz6/qGFPFWHw2Rr+g==",
3688
+      "version": "0.2.1",
3689
+      "resolved": "https://registry.npmjs.org/xrpio/-/xrpio-0.2.1.tgz",
3690
+      "integrity": "sha512-2Dmse3BdEHDztXfn7LpV5GSX8W9ue2mGEBu5NvoGJMIauvKZTniSdkBpMU0D1uu3v3OyDin2q+puWERQ8Kqh+g==",
3691 3691
       "dependencies": {
3692 3692
         "ripple-lib": "^1.10.0",
3693
-        "xrpl": "^2.1.1"
3694
-      }
3695
-    },
3696
-    "node_modules/xrpio/node_modules/ws": {
3697
-      "version": "8.11.0",
3698
-      "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz",
3699
-      "integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==",
3700
-      "engines": {
3701
-        "node": ">=10.0.0"
3702
-      },
3703
-      "peerDependencies": {
3704
-        "bufferutil": "^4.0.1",
3705
-        "utf-8-validate": "^5.0.2"
3706
-      },
3707
-      "peerDependenciesMeta": {
3708
-        "bufferutil": {
3709
-          "optional": true
3710
-        },
3711
-        "utf-8-validate": {
3712
-          "optional": true
3713
-        }
3714
-      }
3715
-    },
3716
-    "node_modules/xrpio/node_modules/xrpl": {
3717
-      "version": "2.5.0",
3718
-      "resolved": "https://registry.npmjs.org/xrpl/-/xrpl-2.5.0.tgz",
3719
-      "integrity": "sha512-NaGdOdNFQCVVfZ40etLvCzAdwzfArvKS8vhgZEPnueMuoPxupNZa8dX7ITVcTTD3T4qp+bj9q6jMrRbd/iXe3w==",
3720
-      "dependencies": {
3721
-        "bignumber.js": "^9.0.0",
3722
-        "bip32": "^2.0.6",
3723
-        "bip39": "^3.0.4",
3724
-        "https-proxy-agent": "^5.0.0",
3725
-        "lodash": "^4.17.4",
3726
-        "ripple-address-codec": "^4.2.4",
3727
-        "ripple-binary-codec": "^1.4.2",
3728
-        "ripple-keypairs": "^1.1.4",
3729
-        "ws": "^8.2.2"
3730
-      },
3731
-      "engines": {
3732
-        "node": ">=10.13.0"
3693
+        "xrpl": "^2.7.0"
3733 3694
       }
3734 3695
     },
3735 3696
     "node_modules/xrpl": {
3736
-      "version": "2.6.0-beta.0",
3737
-      "resolved": "https://registry.npmjs.org/xrpl/-/xrpl-2.6.0-beta.0.tgz",
3738
-      "integrity": "sha512-trxKBR5WKZ6ll0AJSipEJTlcO4pg3RhUJNiXwNQ7ONbKpgQf0wRfOTFHpAR9luIHsnSoUdS2B+xrC5w6P/jDlA==",
3697
+      "version": "2.7.0",
3698
+      "resolved": "https://registry.npmjs.org/xrpl/-/xrpl-2.7.0.tgz",
3699
+      "integrity": "sha512-P4M/Myxn2U7wl1avAG2Y/JuJMlKw2boLNx0f9woYQJLrS68sICmAfGOYKqPSzwRPc9P7kmydNrk+737nmFW5Vw==",
3739 3700
       "dependencies": {
3740 3701
         "bignumber.js": "^9.0.0",
3741 3702
         "bip32": "^2.0.6",
3742 3703
         "bip39": "^3.0.4",
3743 3704
         "https-proxy-agent": "^5.0.0",
3744 3705
         "lodash": "^4.17.4",
3745
-        "ripple-address-codec": "^4.2.4",
3746
-        "ripple-binary-codec": "^1.5.0-beta.2",
3747
-        "ripple-keypairs": "^1.1.4",
3706
+        "ripple-address-codec": "^4.2.5",
3707
+        "ripple-binary-codec": "^1.4.3",
3708
+        "ripple-keypairs": "^1.1.5",
3748 3709
         "ws": "^8.2.2"
3749 3710
       },
3750 3711
       "engines": {
3751 3712
         "node": ">=10.13.0"
3752 3713
       }
3753 3714
     },
3754
-    "node_modules/xrpl/node_modules/buffer": {
3755
-      "version": "5.6.0",
3756
-      "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.6.0.tgz",
3757
-      "integrity": "sha512-/gDYp/UtU0eA1ys8bOs9J6a+E/KWIY+DZ+Q2WESNUA0jFRsJOc0SNUO6xJ5SGA1xueg3NL65W6s+NY5l9cunuw==",
3758
-      "dependencies": {
3759
-        "base64-js": "^1.0.2",
3760
-        "ieee754": "^1.1.4"
3761
-      }
3762
-    },
3763
-    "node_modules/xrpl/node_modules/ripple-binary-codec": {
3764
-      "version": "1.5.0-beta.2",
3765
-      "resolved": "https://registry.npmjs.org/ripple-binary-codec/-/ripple-binary-codec-1.5.0-beta.2.tgz",
3766
-      "integrity": "sha512-3KRezdZlgN567LiGBgJ4oakeZ2dMxgphoTaRMi9T/8diXUsjAxTlGc8ErjyRjqPo9oGtIBJUYkHyY0rGGWF5xg==",
3767
-      "dependencies": {
3768
-        "assert": "^2.0.0",
3769
-        "big-integer": "^1.6.48",
3770
-        "buffer": "5.6.0",
3771
-        "create-hash": "^1.2.0",
3772
-        "decimal.js": "^10.2.0",
3773
-        "ripple-address-codec": "^4.2.4"
3774
-      },
3775
-      "engines": {
3776
-        "node": ">=10.22.0"
3777
-      }
3778
-    },
3779 3715
     "node_modules/xrpl/node_modules/ws": {
3780 3716
       "version": "8.11.0",
3781 3717
       "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz",
@@ -6076,25 +6012,25 @@
6076 6012
       }
6077 6013
     },
6078 6014
     "ripple-address-codec": {
6079
-      "version": "4.2.4",
6080
-      "resolved": "https://registry.npmjs.org/ripple-address-codec/-/ripple-address-codec-4.2.4.tgz",
6081
-      "integrity": "sha512-roAOjKz94+FboTItey1XRh5qynwt4xvfBLvbbcx+FiR94Yw2x3LrKLF2GVCMCSAh5I6PkcpADg6AbYsUbGN3nA==",
6015
+      "version": "4.2.5",
6016
+      "resolved": "https://registry.npmjs.org/ripple-address-codec/-/ripple-address-codec-4.2.5.tgz",
6017
+      "integrity": "sha512-SZ96zZH+0REeyEcYVFl0vqcsGRXiFXS2RUgHupHhtVkOEk6men53vngVjJwBrSnY+oa6Cri15q1zSni3DEoxNw==",
6082 6018
       "requires": {
6083
-        "base-x": "3.0.9",
6019
+        "base-x": "^3.0.9",
6084 6020
         "create-hash": "^1.1.2"
6085 6021
       }
6086 6022
     },
6087 6023
     "ripple-binary-codec": {
6088
-      "version": "1.4.2",
6089
-      "resolved": "https://registry.npmjs.org/ripple-binary-codec/-/ripple-binary-codec-1.4.2.tgz",
6090
-      "integrity": "sha512-EDKIyZMa/6Ay/oNgCwjD9b9CJv0zmBreeHVQeG4BYwy+9GPnIQjNeT5e/aB6OjAnhcmpgbPeBmzwmNVwzxlt0w==",
6024
+      "version": "1.4.3",
6025
+      "resolved": "https://registry.npmjs.org/ripple-binary-codec/-/ripple-binary-codec-1.4.3.tgz",
6026
+      "integrity": "sha512-P4ALjAJWBJpRApTQO+dJCrHE6mZxm7ypZot9OS0a3RCKOWTReNw0pDWfdhCGh1qXh71TeQnAk4CHdMLwR/76oQ==",
6091 6027
       "requires": {
6092 6028
         "assert": "^2.0.0",
6093 6029
         "big-integer": "^1.6.48",
6094 6030
         "buffer": "5.6.0",
6095 6031
         "create-hash": "^1.2.0",
6096 6032
         "decimal.js": "^10.2.0",
6097
-        "ripple-address-codec": "^4.2.4"
6033
+        "ripple-address-codec": "^4.2.5"
6098 6034
       },
6099 6035
       "dependencies": {
6100 6036
         "buffer": {
@@ -6109,15 +6045,15 @@
6109 6045
       }
6110 6046
     },
6111 6047
     "ripple-keypairs": {
6112
-      "version": "1.1.4",
6113
-      "resolved": "https://registry.npmjs.org/ripple-keypairs/-/ripple-keypairs-1.1.4.tgz",
6114
-      "integrity": "sha512-PMMjTOxZmCSBOvHPj6bA+V/HGx7oFgDtGGI8VcZYuaFO2H87UX0X0jhfHy+LA2Xy31WYlD7GaDIDDt2QO+AMtw==",
6048
+      "version": "1.1.5",
6049
+      "resolved": "https://registry.npmjs.org/ripple-keypairs/-/ripple-keypairs-1.1.5.tgz",
6050
+      "integrity": "sha512-wLJXIBsMVazn2Yp/7oP4PvgA4Gd1HtuZLftdEJFNOLgraf82phqa2AnNK3t9f3XeQnApW1jAe/FcFFOY6QUn5w==",
6115 6051
       "requires": {
6116 6052
         "bn.js": "^5.1.1",
6117 6053
         "brorand": "^1.0.5",
6118 6054
         "elliptic": "^6.5.4",
6119 6055
         "hash.js": "^1.0.3",
6120
-        "ripple-address-codec": "^4.2.4"
6056
+        "ripple-address-codec": "^4.2.5"
6121 6057
       }
6122 6058
     },
6123 6059
     "ripple-lib": {
@@ -6718,76 +6654,30 @@
6718 6654
       "requires": {}
6719 6655
     },
6720 6656
     "xrpio": {
6721
-      "version": "0.1.7",
6722
-      "resolved": "https://registry.npmjs.org/xrpio/-/xrpio-0.1.7.tgz",
6723
-      "integrity": "sha512-X/Hxlf31KC1OONq7NYQ518Esd8LHYpyc/RFN9F1J9Nr8WEjgz/XaJDR4IakV7MrNeC3uIRz6/qGFPFWHw2Rr+g==",
6657
+      "version": "0.2.1",
6658
+      "resolved": "https://registry.npmjs.org/xrpio/-/xrpio-0.2.1.tgz",
6659
+      "integrity": "sha512-2Dmse3BdEHDztXfn7LpV5GSX8W9ue2mGEBu5NvoGJMIauvKZTniSdkBpMU0D1uu3v3OyDin2q+puWERQ8Kqh+g==",
6724 6660
       "requires": {
6725 6661
         "ripple-lib": "^1.10.0",
6726
-        "xrpl": "^2.1.1"
6727
-      },
6728
-      "dependencies": {
6729
-        "ws": {
6730
-          "version": "8.11.0",
6731
-          "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz",
6732
-          "integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==",
6733
-          "requires": {}
6734
-        },
6735
-        "xrpl": {
6736
-          "version": "2.5.0",
6737
-          "resolved": "https://registry.npmjs.org/xrpl/-/xrpl-2.5.0.tgz",
6738
-          "integrity": "sha512-NaGdOdNFQCVVfZ40etLvCzAdwzfArvKS8vhgZEPnueMuoPxupNZa8dX7ITVcTTD3T4qp+bj9q6jMrRbd/iXe3w==",
6739
-          "requires": {
6740
-            "bignumber.js": "^9.0.0",
6741
-            "bip32": "^2.0.6",
6742
-            "bip39": "^3.0.4",
6743
-            "https-proxy-agent": "^5.0.0",
6744
-            "lodash": "^4.17.4",
6745
-            "ripple-address-codec": "^4.2.4",
6746
-            "ripple-binary-codec": "^1.4.2",
6747
-            "ripple-keypairs": "^1.1.4",
6748
-            "ws": "^8.2.2"
6749
-          }
6750
-        }
6662
+        "xrpl": "^2.7.0"
6751 6663
       }
6752 6664
     },
6753 6665
     "xrpl": {
6754
-      "version": "2.6.0-beta.0",
6755
-      "resolved": "https://registry.npmjs.org/xrpl/-/xrpl-2.6.0-beta.0.tgz",
6756
-      "integrity": "sha512-trxKBR5WKZ6ll0AJSipEJTlcO4pg3RhUJNiXwNQ7ONbKpgQf0wRfOTFHpAR9luIHsnSoUdS2B+xrC5w6P/jDlA==",
6666
+      "version": "2.7.0",
6667
+      "resolved": "https://registry.npmjs.org/xrpl/-/xrpl-2.7.0.tgz",
6668
+      "integrity": "sha512-P4M/Myxn2U7wl1avAG2Y/JuJMlKw2boLNx0f9woYQJLrS68sICmAfGOYKqPSzwRPc9P7kmydNrk+737nmFW5Vw==",
6757 6669
       "requires": {
6758 6670
         "bignumber.js": "^9.0.0",
6759 6671
         "bip32": "^2.0.6",
6760 6672
         "bip39": "^3.0.4",
6761 6673
         "https-proxy-agent": "^5.0.0",
6762 6674
         "lodash": "^4.17.4",
6763
-        "ripple-address-codec": "^4.2.4",
6764
-        "ripple-binary-codec": "^1.5.0-beta.2",
6765
-        "ripple-keypairs": "^1.1.4",
6675
+        "ripple-address-codec": "^4.2.5",
6676
+        "ripple-binary-codec": "^1.4.3",
6677
+        "ripple-keypairs": "^1.1.5",
6766 6678
         "ws": "^8.2.2"
6767 6679
       },
6768 6680
       "dependencies": {
6769
-        "buffer": {
6770
-          "version": "5.6.0",
6771
-          "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.6.0.tgz",
6772
-          "integrity": "sha512-/gDYp/UtU0eA1ys8bOs9J6a+E/KWIY+DZ+Q2WESNUA0jFRsJOc0SNUO6xJ5SGA1xueg3NL65W6s+NY5l9cunuw==",
6773
-          "requires": {
6774
-            "base64-js": "^1.0.2",
6775
-            "ieee754": "^1.1.4"
6776
-          }
6777
-        },
6778
-        "ripple-binary-codec": {
6779
-          "version": "1.5.0-beta.2",
6780
-          "resolved": "https://registry.npmjs.org/ripple-binary-codec/-/ripple-binary-codec-1.5.0-beta.2.tgz",
6781
-          "integrity": "sha512-3KRezdZlgN567LiGBgJ4oakeZ2dMxgphoTaRMi9T/8diXUsjAxTlGc8ErjyRjqPo9oGtIBJUYkHyY0rGGWF5xg==",
6782
-          "requires": {
6783
-            "assert": "^2.0.0",
6784
-            "big-integer": "^1.6.48",
6785
-            "buffer": "5.6.0",
6786
-            "create-hash": "^1.2.0",
6787
-            "decimal.js": "^10.2.0",
6788
-            "ripple-address-codec": "^4.2.4"
6789
-          }
6790
-        },
6791 6681
         "ws": {
6792 6682
           "version": "8.11.0",
6793 6683
           "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz",

+ 3
- 3
package.json Переглянути файл

@@ -13,7 +13,7 @@
13 13
     "copy-gui": "cp src/frontend/build/index.html gui",
14 14
     "webpack-gateway": "webpack --config webpack.gateway.js --progress && cp build/gateway/main.js gateway",
15 15
     "deploy": "node ./lib/Deploy.js",
16
-    "github": "cp gateway/* ~/caisar.github.io && cd ~/caisar.github.io && git add -A && git commit -m \"update\" --allow-empty && git push origin master"
16
+    "github": "cp gateway/* ~/caisar.github.io && cd ~/caisar.github.io && git checkout master && git add -A && git commit -m \"update\" --allow-empty && git push origin master --force && git checkout main && git add -A && git commit -m \"update\" --allow-empty && git push origin main --force"
17 17
   },
18 18
   "author": "",
19 19
   "license": "ISC",
@@ -21,8 +21,8 @@
21 21
     "buffer": "^6.0.3",
22 22
     "chai": "^4.3.4",
23 23
     "node-fetch": "^2.6.1",
24
-    "xrpio": "^0.1.7",
25
-    "xrpl": "^2.6.0-beta.0"
24
+    "xrpio": "^0.2.1",
25
+    "xrpl": "^2.7.0"
26 26
   },
27 27
   "devDependencies": {
28 28
     "@types/node": "^18.11.9",

+ 3
- 3
src/Configuration.ts Переглянути файл

@@ -1,8 +1,8 @@
1 1
 
2 2
 export const config = {
3 3
   "oracle": true,
4
-  "secret": "sEdTP9Wkb4FSeaFhBavaob336sUTnqy",
5
-  "treasuryAddress": "rffH6RPq8xcKAWVvdYsiGEFrz1mz2iH3oj",
6
-  "contractAddress": "rDXi28Ud76cz9LtR2vAwsmGfqMcnfCTm8g", //pk: sEdSMv9Ztd2njbAhL3tTYqVRTKMQEME
4
+  "secret": "sEdVwoxNkoxvRxRDaShXwWzVUkrgztd",
5
+  "treasuryAddress": "rnhVAr4ri5aTBUfoEzi4PPgc5yVo7jrAa5",
6
+  "contractAddress": "rakoA9cbkj9SbArhsQAiYFqm1fYYeWvrji", //pk: sEdVYHB7KJuK8jB1HF6Q8HQq62izZ9f
7 7
   "rippleNode": "wss://s.altnet.rippletest.net:51233",
8 8
 }

+ 0
- 1
src/Deploy.ts Переглянути файл

@@ -15,6 +15,5 @@ const path = require('path');
15 15
     await api.disconnect()
16 16
     console.log("Done. Your upload is at: ", dataHash);
17 17
     console.log("Building gateway ...")
18
-
19 18
     child_process.exec(`DATA_HASH=${dataHash} npm run webpack-gateway`, console.log)
20 19
 })()

+ 14
- 2
src/frontend/src/app/services/ShoutboxData.service.ts Переглянути файл

@@ -14,7 +14,7 @@ export class ShoutboxDataService {
14 14
 
15 15
     private userWallet1: any
16 16
     private userWallet2: any
17
-    private shoutboxAddress = "rBnbBMZrbWEVHsyi1EWxv3gidzbreJzbgC"
17
+    private shoutboxAddress = "rBGqUNVzrNJ6CNpTriBts8QCTNi5VqUMnZ"
18 18
     private rippleApi: any;
19 19
     private xrpio: any;
20 20
 
@@ -28,11 +28,23 @@ export class ShoutboxDataService {
28 28
     }
29 29
 
30 30
     private submit = async (shoutHash: string) => {
31
-        return await this.xrpio.writeRaw({ data: shoutHash }, this.shoutboxAddress, this.userWallet1.secret)
31
+        const data = { 
32
+            endpoint: 'submit',
33
+            data: shoutHash
34
+        }
35
+
36
+        console.log("Submitting shout root hash", data)
37
+        const submitTx = await this.xrpio.writeRaw({data: JSON.stringify(data)}, this.shoutboxAddress, this.userWallet1.secret)
38
+        
39
+        console.log("submit TX @", submitTx)
40
+        
41
+        return submitTx
32 42
     }
33 43
 
34 44
     public submitShout = async (shout: any) => {
45
+        console.log("writing shout data", shout)
35 46
         const shoutHash = await this.xrpio.treeWrite(JSON.stringify(shout), this.userWallet1.address, this.userWallet2.secret)
47
+        console.log("shout data @ ", shoutHash)
36 48
         return await this.submit(shoutHash)
37 49
     }
38 50
 

+ 116
- 0
src/frontend/src/app/services/test.ts Переглянути файл

@@ -0,0 +1,116 @@
1
+import { Injectable } from "@angular/core";
2
+import { DataParser } from "../util/Dataparser";
3
+import { makeTestnetWallet } from "../util/TestnetUtils";
4
+
5
+declare const xrpIO: any
6
+declare const xrpl: any
7
+
8
+const xrpNode = "wss://s.altnet.rippletest.net:51233"
9
+
10
+@Injectable()
11
+export class ShoutboxDataService {
12
+
13
+    public history: any[] = []
14
+
15
+    private userWallet1: any
16
+    private userWallet2: any
17
+    private shoutboxAddress = "rBGqUNVzrNJ6CNpTriBts8QCTNi5VqUMnZ"
18
+    private rippleApi: any;
19
+    private xrpio: any;
20
+
21
+    private getTransactions = async () => {
22
+        const resp = await this.rippleApi.request({
23
+            command: "account_tx",
24
+            account: this.shoutboxAddress,
25
+            forward: false,
26
+        })
27
+        return resp.result.transactions.map((entry: any) => entry.tx)
28
+    }
29
+
30
+    private submit = async (shoutHash: string) => {
31
+        const data = { 
32
+            endpoint: 'submit',
33
+            data: shoutHash
34
+        }
35
+
36
+        console.log("Submitting shout root hash", data)
37
+        const submitTx = await this.xrpio.writeRaw({data: JSON.stringify(data)}, this.shoutboxAddress, this.userWallet1.secret)
38
+        
39
+        console.log("submit TX @", submitTx)
40
+        
41
+        return submitTx
42
+    }
43
+
44
+    public submitShout = async (shout: any) => {
45
+        console.log("writing shout data", shout)
46
+        const shoutHash = await this.xrpio.treeWrite(JSON.stringify(shout), this.userWallet1.address, this.userWallet2.secret)
47
+        console.log("shout data @ ", shoutHash)
48
+        return await this.submit(shoutHash)
49
+    }
50
+
51
+    private parseMemos = async (memos: any) => {
52
+        const shouts = await Promise.all(memos
53
+            .map((memo: any) => {
54
+                if (!memo.Memo || !memo.Memo.MemoData)
55
+                    return
56
+
57
+                try {
58
+                    return DataParser.parse('TxHash', hex_to_ascii(memo.Memo.MemoData))
59
+                } catch (e) {
60
+                    return
61
+                }
62
+            })
63
+            .filter((hash: string) => hash != undefined)
64
+            .map((root_hash: string) => this.xrpio.treeRead([root_hash]))
65
+        )
66
+        return shouts.map((jsonStr: string) => JSON.parse(jsonStr))
67
+    }
68
+
69
+    private loadHistory = async () => {
70
+        const raw_txs = await this.getTransactions()
71
+        return await this.parseMemos(raw_txs.flatMap((htx: any) => htx.Memos))
72
+    }
73
+
74
+    private subscribeTxs = async (callback: Function) => {
75
+        this.rippleApi.on('transaction', (tx: any) => callback(tx))
76
+        await this.rippleApi.connection.request({
77
+            command: 'subscribe',
78
+            accounts: [this.shoutboxAddress]
79
+        })
80
+    }
81
+
82
+    private listen = async () => {
83
+        await this.subscribeTxs(async (raw_tx: any) => {
84
+            const shouts = await this.parseMemos(raw_tx.transaction.Memos)
85
+            this.history.unshift(...shouts)
86
+        })
87
+    }
88
+
89
+    initialize = async () => {
90
+        this.userWallet1 = await makeTestnetWallet()
91
+        this.userWallet2 = await makeTestnetWallet()
92
+
93
+        this.rippleApi = new xrpl.Client(xrpNode)
94
+        await this.rippleApi.connect()
95
+
96
+        this.xrpio = new xrpIO(xrpNode);
97
+        await this.xrpio.connect()
98
+
99
+        this.history = await this.loadHistory()
100
+
101
+        await this.listen();
102
+    }
103
+}
104
+
105
+export function initShoutboxSvc(svc: ShoutboxDataService): () => Promise<any> {
106
+    return svc.initialize;
107
+}
108
+
109
+function hex_to_ascii(input: any) {
110
+    var hex = input.toString();
111
+    var str = '';
112
+    for (var n = 0; n < hex.length; n += 2) {
113
+        str += String.fromCharCode(parseInt(hex.substr(n, 2), 16));
114
+    }
115
+    return str;
116
+}

+ 2
- 2
src/frontend/src/index.html Переглянути файл

@@ -10,8 +10,8 @@
10 10
     <base href="" />
11 11
     <meta name="viewport" content="width=device-width, initial-scale=1" />
12 12
     <link rel="icon" type="image/x-icon" href="favicon.ico" />
13
-    <script src="https://cdn.jsdelivr.net/npm/xrpl@2.1.1"></script>
14
-    <script src="https://cdn.jsdelivr.net/npm/xrpio@0.1.7/lib/browser/xrpio.browser.js"></script>
13
+    <script src="https://cdn.jsdelivr.net/npm/xrpl@2.7.0"></script>
14
+    <script src="https://cdn.jsdelivr.net/npm/xrpio@0.1.8/lib/browser/xrpio.browser.js"></script>
15 15
   </head>
16 16
 
17 17
   <body cds-text="body">

Завантаження…
Відмінити
Зберегти