From 43de68c9384f0a6b0054f2c84bd3d082f1770028 Mon Sep 17 00:00:00 2001 From: SpaghettiOverload Date: Fri, 15 Jul 2022 09:44:51 +0300 Subject: [PATCH 1/8] Adding Google Analytics --- src/frontend/pages/general/cudos-bridge.marko | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/frontend/pages/general/cudos-bridge.marko b/src/frontend/pages/general/cudos-bridge.marko index 5816441..e65f241 100644 --- a/src/frontend/pages/general/cudos-bridge.marko +++ b/src/frontend/pages/general/cudos-bridge.marko @@ -11,9 +11,16 @@ import pageLoading from './../common/page-loading.marko' + + + + + +
<${pageLoading} ...input/> From 13d463c30550a8df1bb8cda12178ac296dcca24f Mon Sep 17 00:00:00 2001 From: Bogo Lime Date: Mon, 1 Aug 2022 16:15:37 +0300 Subject: [PATCH 2/8] Refactored the UI to use the cudosJS - replaced the custom logic implemented through cosmJS: 1. Updated KeplrLedger.ts: - added queryClient( StargateClient) property to the KeplrLedger, that is used throughout the app. - cudos network configuration constants are imported from cudosJS - Transformed and split GetKeplrClientAndAccount function into -> GetKeplrSignerAndAccount and GetKeplrSigningClient - EstimateFee uses the estimateFee util function from cudosJS - isAddressValid uses the checkValidAddress util function from cudosJS - The send function uses the gravitySendToEth function from cudosJS --- config/.env.example | 34 -- package-lock.json | 409 ++++++++---------- .../common/js/models/ledgers/KeplrLedger.ts | 171 ++++---- .../common/js/models/ledgers/Ledger.ts | 14 +- .../js/models/ledgers/MetamaskLedger.ts | 7 +- 5 files changed, 261 insertions(+), 374 deletions(-) delete mode 100644 config/.env.example diff --git a/config/.env.example b/config/.env.example deleted file mode 100644 index 5d1da63..0000000 --- a/config/.env.example +++ /dev/null @@ -1,34 +0,0 @@ -NODE_ENV=production|dev -NETWORK_TYPE=mainnet/testnet -BACKEND_PORT= (port on which server will be accessed from browser) -FRONTEND_PORT= -URL=http://ip/localhost/domain -SESSION_UNIQUE_KEY=secret -SESSION_STORE_TCP_ADDR=127.0.0.1 -SESSION_STORE_PORT=6379 - -DATABASE_HOST=localhost -DATABASE_PORT=3306 -DATABASE_USER= -DATABASE_PASS= -DATABASE_NAME= -DATABASE_CONNECTION_LIMIT=10 - -#cudos network variables -CHAIN_NAME= -CHAIN_ID= -GRAVITY_MODULE_ADDRESS= -RPC= -API= -GAS_PRICE= -GAS= -STAKING= -BLOCK_EXPLORER=(http:///transactions) - -#orchestrator variables -ERC20_CONTRACT_ADDRESS= -BRIDGE_CONTRACT_ADDRESS= - -#ethereum variables -ETHEREUM_GAS= -ETHEREUM_RPC= diff --git a/package-lock.json b/package-lock.json index 3b9de35..1b87e7c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1895,20 +1895,20 @@ } }, "node_modules/@cosmjs/amino": { - "version": "0.28.4", - "resolved": "https://registry.npmjs.org/@cosmjs/amino/-/amino-0.28.4.tgz", - "integrity": "sha512-b8y5gFC0eGrH0IoYSNtDmTdsTgeQ1KFZ5YVOeIiKmzF91MeiciYO/MNqc027kctacZ+UbnVWGEUGyRBPi9ta/g==", + "version": "0.28.11", + "resolved": "https://registry.npmjs.org/@cosmjs/amino/-/amino-0.28.11.tgz", + "integrity": "sha512-WJkQQq8gbk5doJJ/3Gcax26I+VC4HdbbSlNdyT5hc6T+U2Jmyry9RLSE+wEZyFMgEabhr43SbIxf64gWZeR8YA==", "dependencies": { - "@cosmjs/crypto": "0.28.4", - "@cosmjs/encoding": "0.28.4", - "@cosmjs/math": "0.28.4", - "@cosmjs/utils": "0.28.4" + "@cosmjs/crypto": "0.28.11", + "@cosmjs/encoding": "0.28.11", + "@cosmjs/math": "0.28.11", + "@cosmjs/utils": "0.28.11" } }, "node_modules/@cosmjs/amino/node_modules/@cosmjs/encoding": { - "version": "0.28.4", - "resolved": "https://registry.npmjs.org/@cosmjs/encoding/-/encoding-0.28.4.tgz", - "integrity": "sha512-N6Qnjs4dd8KwjW5m9t3L+rWYYGW2wyS+iLtJJ9DD8DiTTxpW9h7/AmUVO/dsRe5H2tV8/DzH/B9pFfpsgro22A==", + "version": "0.28.11", + "resolved": "https://registry.npmjs.org/@cosmjs/encoding/-/encoding-0.28.11.tgz", + "integrity": "sha512-J7pvlzAt8hBZn316wGRmUlK3xwMgNXUvj4v56DK4fA0fv6VfGwMvVtHCXaqNQtzOGkC6EQcshzA/fL5MBIwu6A==", "dependencies": { "base64-js": "^1.3.0", "bech32": "^1.1.4", @@ -1916,13 +1916,13 @@ } }, "node_modules/@cosmjs/crypto": { - "version": "0.28.4", - "resolved": "https://registry.npmjs.org/@cosmjs/crypto/-/crypto-0.28.4.tgz", - "integrity": "sha512-JRxNLlED3DDh9d04A0RcRw3mYkoobN7q7wafUFy3vI1TjoyWx33v0gqqaYE6/hoo9ghUrJSVOfzVihl8fZajJA==", + "version": "0.28.11", + "resolved": "https://registry.npmjs.org/@cosmjs/crypto/-/crypto-0.28.11.tgz", + "integrity": "sha512-oJXOeBX4FP8bp0ZVydJFcRplErHp8cC6vNoULRck+7hcLuvp9tyv3SBOkBkwxTv81VcQyGCgn7WE0NYEKrpUbw==", "dependencies": { - "@cosmjs/encoding": "0.28.4", - "@cosmjs/math": "0.28.4", - "@cosmjs/utils": "0.28.4", + "@cosmjs/encoding": "0.28.11", + "@cosmjs/math": "0.28.11", + "@cosmjs/utils": "0.28.11", "@noble/hashes": "^1", "bn.js": "^5.2.0", "elliptic": "^6.5.3", @@ -1930,9 +1930,9 @@ } }, "node_modules/@cosmjs/crypto/node_modules/@cosmjs/encoding": { - "version": "0.28.4", - "resolved": "https://registry.npmjs.org/@cosmjs/encoding/-/encoding-0.28.4.tgz", - "integrity": "sha512-N6Qnjs4dd8KwjW5m9t3L+rWYYGW2wyS+iLtJJ9DD8DiTTxpW9h7/AmUVO/dsRe5H2tV8/DzH/B9pFfpsgro22A==", + "version": "0.28.11", + "resolved": "https://registry.npmjs.org/@cosmjs/encoding/-/encoding-0.28.11.tgz", + "integrity": "sha512-J7pvlzAt8hBZn316wGRmUlK3xwMgNXUvj4v56DK4fA0fv6VfGwMvVtHCXaqNQtzOGkC6EQcshzA/fL5MBIwu6A==", "dependencies": { "base64-js": "^1.3.0", "bech32": "^1.1.4", @@ -1955,11 +1955,11 @@ } }, "node_modules/@cosmjs/json-rpc": { - "version": "0.28.4", - "resolved": "https://registry.npmjs.org/@cosmjs/json-rpc/-/json-rpc-0.28.4.tgz", - "integrity": "sha512-An8ZQi9OKbnS8ew/MyHhF90zQpXBF8RTj2wdvIH+Hr8yA6QjynY8hxRpUwYUt3Skc5NeUnTZNuWCzlluHnoxVg==", + "version": "0.28.11", + "resolved": "https://registry.npmjs.org/@cosmjs/json-rpc/-/json-rpc-0.28.11.tgz", + "integrity": "sha512-YNZTozu5yWHyGGet5Wfc0CcxQezkMr37YaeU9elCaa11ClHlYAQ2NrPpPBOmgnJKsMhzfiKcAE9Sf6f4a0hCxA==", "dependencies": { - "@cosmjs/stream": "0.28.4", + "@cosmjs/stream": "0.28.11", "xstream": "^11.14.0" } }, @@ -2034,37 +2034,36 @@ "integrity": "sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw==" }, "node_modules/@cosmjs/math": { - "version": "0.28.4", - "resolved": "https://registry.npmjs.org/@cosmjs/math/-/math-0.28.4.tgz", - "integrity": "sha512-wsWjbxFXvk46Dsx8jQ5vsBZOIQuiUIyaaZbUvxsgIhAMpuuBnV5O/drK87+B+4cL+umTelFqTbWnkqueVCIFxQ==", + "version": "0.28.11", + "resolved": "https://registry.npmjs.org/@cosmjs/math/-/math-0.28.11.tgz", + "integrity": "sha512-MyhPnC4sYu86c2/0PpEeynaPl4nvAmLZH3acPh96SzcjERONbGZjjKtBFPq1avBrev2CCSPrZ4O8u9xpQ4aSvg==", "dependencies": { "bn.js": "^5.2.0" } }, "node_modules/@cosmjs/math/node_modules/bn.js": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.0.tgz", - "integrity": "sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw==" + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", + "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" }, "node_modules/@cosmjs/proto-signing": { - "version": "0.28.4", - "resolved": "https://registry.npmjs.org/@cosmjs/proto-signing/-/proto-signing-0.28.4.tgz", - "integrity": "sha512-4vgCLK9gOsdWzD78V5XbAsupSSyntPEzokWYhgRQNwgVTcKX1kg0eKZqUvF5ua5iL9x6MevfH/sgwPyiYleMBw==", - "dependencies": { - "@cosmjs/amino": "0.28.4", - "@cosmjs/crypto": "0.28.4", - "@cosmjs/encoding": "0.28.4", - "@cosmjs/math": "0.28.4", - "@cosmjs/utils": "0.28.4", + "version": "0.28.11", + "resolved": "https://registry.npmjs.org/@cosmjs/proto-signing/-/proto-signing-0.28.11.tgz", + "integrity": "sha512-ym0DpLff+0RBkD/mtFf6wrzyuGhcbcjuDMEdcUWOrJTo6n8DXeRmHkJkyy/mrG3QC4tQX/A81+DhfkANQmgcxw==", + "dependencies": { + "@cosmjs/amino": "0.28.11", + "@cosmjs/crypto": "0.28.11", + "@cosmjs/encoding": "0.28.11", + "@cosmjs/math": "0.28.11", + "@cosmjs/utils": "0.28.11", "cosmjs-types": "^0.4.0", - "long": "^4.0.0", - "protobufjs": "~6.10.2" + "long": "^4.0.0" } }, "node_modules/@cosmjs/proto-signing/node_modules/@cosmjs/encoding": { - "version": "0.28.4", - "resolved": "https://registry.npmjs.org/@cosmjs/encoding/-/encoding-0.28.4.tgz", - "integrity": "sha512-N6Qnjs4dd8KwjW5m9t3L+rWYYGW2wyS+iLtJJ9DD8DiTTxpW9h7/AmUVO/dsRe5H2tV8/DzH/B9pFfpsgro22A==", + "version": "0.28.11", + "resolved": "https://registry.npmjs.org/@cosmjs/encoding/-/encoding-0.28.11.tgz", + "integrity": "sha512-J7pvlzAt8hBZn316wGRmUlK3xwMgNXUvj4v56DK4fA0fv6VfGwMvVtHCXaqNQtzOGkC6EQcshzA/fL5MBIwu6A==", "dependencies": { "base64-js": "^1.3.0", "bech32": "^1.1.4", @@ -2072,39 +2071,39 @@ } }, "node_modules/@cosmjs/socket": { - "version": "0.28.4", - "resolved": "https://registry.npmjs.org/@cosmjs/socket/-/socket-0.28.4.tgz", - "integrity": "sha512-jAEL3Ri+s8XuBM3mqgO4yvmeQu+R+704V37lGROC1B6kAbGxWRyOWrMdOOiFJzCZ35sSMB7L+xKjpE8ug0vJjg==", + "version": "0.28.11", + "resolved": "https://registry.npmjs.org/@cosmjs/socket/-/socket-0.28.11.tgz", + "integrity": "sha512-4BhsWN984SLBhwPCD89riQ3SEJzJ1RLJPeP6apIGjhh6pguQZmwa2U/TZjnEUOGnJkUG2FZUH99jRGSTYaIvZg==", "dependencies": { - "@cosmjs/stream": "0.28.4", + "@cosmjs/stream": "0.28.11", "isomorphic-ws": "^4.0.1", "ws": "^7", "xstream": "^11.14.0" } }, "node_modules/@cosmjs/stargate": { - "version": "0.28.4", - "resolved": "https://registry.npmjs.org/@cosmjs/stargate/-/stargate-0.28.4.tgz", - "integrity": "sha512-tdwudilP5iLNwDm4TOMBjWuL5YehLPqGlC5/7hjJM/kVHyzLFo4Lzt0dVEwr5YegH+RsRXH/VtFLQz+NYlCobw==", + "version": "0.28.11", + "resolved": "https://registry.npmjs.org/@cosmjs/stargate/-/stargate-0.28.11.tgz", + "integrity": "sha512-UyFH/mTNNKTZohVhj+SmjCRv/xopqU/UinGedmWzs4MqEZteX9xs6D3HTmRCgpmBQ03lpbTslE/FhhT9Hkl9KQ==", "dependencies": { "@confio/ics23": "^0.6.8", - "@cosmjs/amino": "0.28.4", - "@cosmjs/encoding": "0.28.4", - "@cosmjs/math": "0.28.4", - "@cosmjs/proto-signing": "0.28.4", - "@cosmjs/stream": "0.28.4", - "@cosmjs/tendermint-rpc": "0.28.4", - "@cosmjs/utils": "0.28.4", + "@cosmjs/amino": "0.28.11", + "@cosmjs/encoding": "0.28.11", + "@cosmjs/math": "0.28.11", + "@cosmjs/proto-signing": "0.28.11", + "@cosmjs/stream": "0.28.11", + "@cosmjs/tendermint-rpc": "0.28.11", + "@cosmjs/utils": "0.28.11", "cosmjs-types": "^0.4.0", "long": "^4.0.0", - "protobufjs": "~6.10.2", + "protobufjs": "~6.11.3", "xstream": "^11.14.0" } }, "node_modules/@cosmjs/stargate/node_modules/@cosmjs/encoding": { - "version": "0.28.4", - "resolved": "https://registry.npmjs.org/@cosmjs/encoding/-/encoding-0.28.4.tgz", - "integrity": "sha512-N6Qnjs4dd8KwjW5m9t3L+rWYYGW2wyS+iLtJJ9DD8DiTTxpW9h7/AmUVO/dsRe5H2tV8/DzH/B9pFfpsgro22A==", + "version": "0.28.11", + "resolved": "https://registry.npmjs.org/@cosmjs/encoding/-/encoding-0.28.11.tgz", + "integrity": "sha512-J7pvlzAt8hBZn316wGRmUlK3xwMgNXUvj4v56DK4fA0fv6VfGwMvVtHCXaqNQtzOGkC6EQcshzA/fL5MBIwu6A==", "dependencies": { "base64-js": "^1.3.0", "bech32": "^1.1.4", @@ -2112,34 +2111,34 @@ } }, "node_modules/@cosmjs/stream": { - "version": "0.28.4", - "resolved": "https://registry.npmjs.org/@cosmjs/stream/-/stream-0.28.4.tgz", - "integrity": "sha512-BDwDdFOrOgRx/Wm5nknb9YCV9HHIUcsOxykTDZqdArCUsn4QJBq79QIjp919G05Z8UemkoHwiUCUNB2BfoKmFw==", + "version": "0.28.11", + "resolved": "https://registry.npmjs.org/@cosmjs/stream/-/stream-0.28.11.tgz", + "integrity": "sha512-3b6P4Il8mYzvY2bvEQyzgP+cm0HIGSpHNtuGjiWsQF3Wtp450iVRfEJqdt4+91vvxzfdjQEkQOLMaymnswX3sw==", "dependencies": { "xstream": "^11.14.0" } }, "node_modules/@cosmjs/tendermint-rpc": { - "version": "0.28.4", - "resolved": "https://registry.npmjs.org/@cosmjs/tendermint-rpc/-/tendermint-rpc-0.28.4.tgz", - "integrity": "sha512-iz6p4UW2QUZNh55WeJy9wHbMdqM8COo0AJdrGU4Ikb/xU0/H6b0dFPoEK+i6ngR0cSizh+hpTMzh3AA7ySUKlA==", - "dependencies": { - "@cosmjs/crypto": "0.28.4", - "@cosmjs/encoding": "0.28.4", - "@cosmjs/json-rpc": "0.28.4", - "@cosmjs/math": "0.28.4", - "@cosmjs/socket": "0.28.4", - "@cosmjs/stream": "0.28.4", - "@cosmjs/utils": "0.28.4", + "version": "0.28.11", + "resolved": "https://registry.npmjs.org/@cosmjs/tendermint-rpc/-/tendermint-rpc-0.28.11.tgz", + "integrity": "sha512-TUhWsUYxbKftQmHQK5TBH62vNaKB1ybxoFZ2uJtGMVvY3jcBux7P0Ll/u5nwrM0ETAeo2RjucehJUpGBy9q+HQ==", + "dependencies": { + "@cosmjs/crypto": "0.28.11", + "@cosmjs/encoding": "0.28.11", + "@cosmjs/json-rpc": "0.28.11", + "@cosmjs/math": "0.28.11", + "@cosmjs/socket": "0.28.11", + "@cosmjs/stream": "0.28.11", + "@cosmjs/utils": "0.28.11", "axios": "^0.21.2", "readonly-date": "^1.0.0", "xstream": "^11.14.0" } }, "node_modules/@cosmjs/tendermint-rpc/node_modules/@cosmjs/encoding": { - "version": "0.28.4", - "resolved": "https://registry.npmjs.org/@cosmjs/encoding/-/encoding-0.28.4.tgz", - "integrity": "sha512-N6Qnjs4dd8KwjW5m9t3L+rWYYGW2wyS+iLtJJ9DD8DiTTxpW9h7/AmUVO/dsRe5H2tV8/DzH/B9pFfpsgro22A==", + "version": "0.28.11", + "resolved": "https://registry.npmjs.org/@cosmjs/encoding/-/encoding-0.28.11.tgz", + "integrity": "sha512-J7pvlzAt8hBZn316wGRmUlK3xwMgNXUvj4v56DK4fA0fv6VfGwMvVtHCXaqNQtzOGkC6EQcshzA/fL5MBIwu6A==", "dependencies": { "base64-js": "^1.3.0", "bech32": "^1.1.4", @@ -2147,9 +2146,9 @@ } }, "node_modules/@cosmjs/utils": { - "version": "0.28.4", - "resolved": "https://registry.npmjs.org/@cosmjs/utils/-/utils-0.28.4.tgz", - "integrity": "sha512-lb3TU6833arPoPZF8HTeG9V418CpurvqH5Aa/ls0I0wYdPDEMO6622+PQNQhQ8Vw8Az2MXoSyc8jsqrgawT84Q==" + "version": "0.28.11", + "resolved": "https://registry.npmjs.org/@cosmjs/utils/-/utils-0.28.11.tgz", + "integrity": "sha512-FXVEr7Pg6MX9VbY5NemuKbtFVabSlUlArWIV+R74FQg5LIuSa+0QkxSpNldCuOLBEU4/GlrzybT4uEl338vSzg==" }, "node_modules/@dabh/diagnostics": { "version": "2.0.3", @@ -5545,31 +5544,6 @@ "protobufjs": "~6.11.2" } }, - "node_modules/cosmjs-types/node_modules/protobufjs": { - "version": "6.11.2", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.11.2.tgz", - "integrity": "sha512-4BQJoPooKJl2G9j3XftkIXjoC9C0Av2NOrWmbLWT1vH32GcSUHjM0Arra6UfTsVyfMAuFzaLucXn1sadxJydAw==", - "hasInstallScript": true, - "dependencies": { - "@protobufjs/aspromise": "^1.1.2", - "@protobufjs/base64": "^1.1.2", - "@protobufjs/codegen": "^2.0.4", - "@protobufjs/eventemitter": "^1.1.0", - "@protobufjs/fetch": "^1.1.0", - "@protobufjs/float": "^1.0.2", - "@protobufjs/inquire": "^1.1.0", - "@protobufjs/path": "^1.1.2", - "@protobufjs/pool": "^1.1.0", - "@protobufjs/utf8": "^1.1.0", - "@types/long": "^4.0.1", - "@types/node": ">=13.7.0", - "long": "^4.0.0" - }, - "bin": { - "pbjs": "bin/pbjs", - "pbts": "bin/pbts" - } - }, "node_modules/crc": { "version": "3.8.0", "resolved": "https://registry.npmjs.org/crc/-/crc-3.8.0.tgz", @@ -13375,9 +13349,9 @@ "integrity": "sha1-yyDTIqq32U//rCj0bJGGvVlHtLQ=" }, "node_modules/protobufjs": { - "version": "6.10.2", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.10.2.tgz", - "integrity": "sha512-27yj+04uF6ya9l+qfpH187aqEzfCF4+Uit0I9ZBQVqK09hk/SQzKa2MUqUpXaVa7LOFRg1TSSr3lVxGOk6c0SQ==", + "version": "6.11.3", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.11.3.tgz", + "integrity": "sha512-xL96WDdCZYdU7Slin569tFX712BxsxslWwAfAhCYjQKGTq7dAU91Lomy6nLLhh/dyGhk/YH4TwTSRxTzhuHyZg==", "hasInstallScript": true, "dependencies": { "@protobufjs/aspromise": "^1.1.2", @@ -13391,7 +13365,7 @@ "@protobufjs/pool": "^1.1.0", "@protobufjs/utf8": "^1.1.0", "@types/long": "^4.0.1", - "@types/node": "^13.7.0", + "@types/node": ">=13.7.0", "long": "^4.0.0" }, "bin": { @@ -13399,11 +13373,6 @@ "pbts": "bin/pbts" } }, - "node_modules/protobufjs/node_modules/@types/node": { - "version": "13.13.52", - "resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.52.tgz", - "integrity": "sha512-s3nugnZumCC//n4moGGe6tkNMyYEdaDBitVjwPxXmR5lnMG5dHePinH2EdxkG3Rh1ghFHHixAG4NJhpJW1rthQ==" - }, "node_modules/proxy-addr": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", @@ -17799,9 +17768,9 @@ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, "node_modules/ws": { - "version": "7.5.7", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.7.tgz", - "integrity": "sha512-KMvVuFzpKBuiIXW3E4u3mySRO2/mCHSyZDJQM5NQ9Q9KHWHWh0NHgfbRMLLrceUK5qAL4ytALJbpRMjixFZh8A==", + "version": "7.5.9", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", + "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", "engines": { "node": ">=8.3.0" }, @@ -19163,20 +19132,20 @@ } }, "@cosmjs/amino": { - "version": "0.28.4", - "resolved": "https://registry.npmjs.org/@cosmjs/amino/-/amino-0.28.4.tgz", - "integrity": "sha512-b8y5gFC0eGrH0IoYSNtDmTdsTgeQ1KFZ5YVOeIiKmzF91MeiciYO/MNqc027kctacZ+UbnVWGEUGyRBPi9ta/g==", + "version": "0.28.11", + "resolved": "https://registry.npmjs.org/@cosmjs/amino/-/amino-0.28.11.tgz", + "integrity": "sha512-WJkQQq8gbk5doJJ/3Gcax26I+VC4HdbbSlNdyT5hc6T+U2Jmyry9RLSE+wEZyFMgEabhr43SbIxf64gWZeR8YA==", "requires": { - "@cosmjs/crypto": "0.28.4", - "@cosmjs/encoding": "0.28.4", - "@cosmjs/math": "0.28.4", - "@cosmjs/utils": "0.28.4" + "@cosmjs/crypto": "0.28.11", + "@cosmjs/encoding": "0.28.11", + "@cosmjs/math": "0.28.11", + "@cosmjs/utils": "0.28.11" }, "dependencies": { "@cosmjs/encoding": { - "version": "0.28.4", - "resolved": "https://registry.npmjs.org/@cosmjs/encoding/-/encoding-0.28.4.tgz", - "integrity": "sha512-N6Qnjs4dd8KwjW5m9t3L+rWYYGW2wyS+iLtJJ9DD8DiTTxpW9h7/AmUVO/dsRe5H2tV8/DzH/B9pFfpsgro22A==", + "version": "0.28.11", + "resolved": "https://registry.npmjs.org/@cosmjs/encoding/-/encoding-0.28.11.tgz", + "integrity": "sha512-J7pvlzAt8hBZn316wGRmUlK3xwMgNXUvj4v56DK4fA0fv6VfGwMvVtHCXaqNQtzOGkC6EQcshzA/fL5MBIwu6A==", "requires": { "base64-js": "^1.3.0", "bech32": "^1.1.4", @@ -19186,13 +19155,13 @@ } }, "@cosmjs/crypto": { - "version": "0.28.4", - "resolved": "https://registry.npmjs.org/@cosmjs/crypto/-/crypto-0.28.4.tgz", - "integrity": "sha512-JRxNLlED3DDh9d04A0RcRw3mYkoobN7q7wafUFy3vI1TjoyWx33v0gqqaYE6/hoo9ghUrJSVOfzVihl8fZajJA==", + "version": "0.28.11", + "resolved": "https://registry.npmjs.org/@cosmjs/crypto/-/crypto-0.28.11.tgz", + "integrity": "sha512-oJXOeBX4FP8bp0ZVydJFcRplErHp8cC6vNoULRck+7hcLuvp9tyv3SBOkBkwxTv81VcQyGCgn7WE0NYEKrpUbw==", "requires": { - "@cosmjs/encoding": "0.28.4", - "@cosmjs/math": "0.28.4", - "@cosmjs/utils": "0.28.4", + "@cosmjs/encoding": "0.28.11", + "@cosmjs/math": "0.28.11", + "@cosmjs/utils": "0.28.11", "@noble/hashes": "^1", "bn.js": "^5.2.0", "elliptic": "^6.5.3", @@ -19200,9 +19169,9 @@ }, "dependencies": { "@cosmjs/encoding": { - "version": "0.28.4", - "resolved": "https://registry.npmjs.org/@cosmjs/encoding/-/encoding-0.28.4.tgz", - "integrity": "sha512-N6Qnjs4dd8KwjW5m9t3L+rWYYGW2wyS+iLtJJ9DD8DiTTxpW9h7/AmUVO/dsRe5H2tV8/DzH/B9pFfpsgro22A==", + "version": "0.28.11", + "resolved": "https://registry.npmjs.org/@cosmjs/encoding/-/encoding-0.28.11.tgz", + "integrity": "sha512-J7pvlzAt8hBZn316wGRmUlK3xwMgNXUvj4v56DK4fA0fv6VfGwMvVtHCXaqNQtzOGkC6EQcshzA/fL5MBIwu6A==", "requires": { "base64-js": "^1.3.0", "bech32": "^1.1.4", @@ -19227,11 +19196,11 @@ } }, "@cosmjs/json-rpc": { - "version": "0.28.4", - "resolved": "https://registry.npmjs.org/@cosmjs/json-rpc/-/json-rpc-0.28.4.tgz", - "integrity": "sha512-An8ZQi9OKbnS8ew/MyHhF90zQpXBF8RTj2wdvIH+Hr8yA6QjynY8hxRpUwYUt3Skc5NeUnTZNuWCzlluHnoxVg==", + "version": "0.28.11", + "resolved": "https://registry.npmjs.org/@cosmjs/json-rpc/-/json-rpc-0.28.11.tgz", + "integrity": "sha512-YNZTozu5yWHyGGet5Wfc0CcxQezkMr37YaeU9elCaa11ClHlYAQ2NrPpPBOmgnJKsMhzfiKcAE9Sf6f4a0hCxA==", "requires": { - "@cosmjs/stream": "0.28.4", + "@cosmjs/stream": "0.28.11", "xstream": "^11.14.0" } }, @@ -19308,39 +19277,38 @@ } }, "@cosmjs/math": { - "version": "0.28.4", - "resolved": "https://registry.npmjs.org/@cosmjs/math/-/math-0.28.4.tgz", - "integrity": "sha512-wsWjbxFXvk46Dsx8jQ5vsBZOIQuiUIyaaZbUvxsgIhAMpuuBnV5O/drK87+B+4cL+umTelFqTbWnkqueVCIFxQ==", + "version": "0.28.11", + "resolved": "https://registry.npmjs.org/@cosmjs/math/-/math-0.28.11.tgz", + "integrity": "sha512-MyhPnC4sYu86c2/0PpEeynaPl4nvAmLZH3acPh96SzcjERONbGZjjKtBFPq1avBrev2CCSPrZ4O8u9xpQ4aSvg==", "requires": { "bn.js": "^5.2.0" }, "dependencies": { "bn.js": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.0.tgz", - "integrity": "sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw==" + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", + "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" } } }, "@cosmjs/proto-signing": { - "version": "0.28.4", - "resolved": "https://registry.npmjs.org/@cosmjs/proto-signing/-/proto-signing-0.28.4.tgz", - "integrity": "sha512-4vgCLK9gOsdWzD78V5XbAsupSSyntPEzokWYhgRQNwgVTcKX1kg0eKZqUvF5ua5iL9x6MevfH/sgwPyiYleMBw==", - "requires": { - "@cosmjs/amino": "0.28.4", - "@cosmjs/crypto": "0.28.4", - "@cosmjs/encoding": "0.28.4", - "@cosmjs/math": "0.28.4", - "@cosmjs/utils": "0.28.4", + "version": "0.28.11", + "resolved": "https://registry.npmjs.org/@cosmjs/proto-signing/-/proto-signing-0.28.11.tgz", + "integrity": "sha512-ym0DpLff+0RBkD/mtFf6wrzyuGhcbcjuDMEdcUWOrJTo6n8DXeRmHkJkyy/mrG3QC4tQX/A81+DhfkANQmgcxw==", + "requires": { + "@cosmjs/amino": "0.28.11", + "@cosmjs/crypto": "0.28.11", + "@cosmjs/encoding": "0.28.11", + "@cosmjs/math": "0.28.11", + "@cosmjs/utils": "0.28.11", "cosmjs-types": "^0.4.0", - "long": "^4.0.0", - "protobufjs": "~6.10.2" + "long": "^4.0.0" }, "dependencies": { "@cosmjs/encoding": { - "version": "0.28.4", - "resolved": "https://registry.npmjs.org/@cosmjs/encoding/-/encoding-0.28.4.tgz", - "integrity": "sha512-N6Qnjs4dd8KwjW5m9t3L+rWYYGW2wyS+iLtJJ9DD8DiTTxpW9h7/AmUVO/dsRe5H2tV8/DzH/B9pFfpsgro22A==", + "version": "0.28.11", + "resolved": "https://registry.npmjs.org/@cosmjs/encoding/-/encoding-0.28.11.tgz", + "integrity": "sha512-J7pvlzAt8hBZn316wGRmUlK3xwMgNXUvj4v56DK4fA0fv6VfGwMvVtHCXaqNQtzOGkC6EQcshzA/fL5MBIwu6A==", "requires": { "base64-js": "^1.3.0", "bech32": "^1.1.4", @@ -19350,39 +19318,39 @@ } }, "@cosmjs/socket": { - "version": "0.28.4", - "resolved": "https://registry.npmjs.org/@cosmjs/socket/-/socket-0.28.4.tgz", - "integrity": "sha512-jAEL3Ri+s8XuBM3mqgO4yvmeQu+R+704V37lGROC1B6kAbGxWRyOWrMdOOiFJzCZ35sSMB7L+xKjpE8ug0vJjg==", + "version": "0.28.11", + "resolved": "https://registry.npmjs.org/@cosmjs/socket/-/socket-0.28.11.tgz", + "integrity": "sha512-4BhsWN984SLBhwPCD89riQ3SEJzJ1RLJPeP6apIGjhh6pguQZmwa2U/TZjnEUOGnJkUG2FZUH99jRGSTYaIvZg==", "requires": { - "@cosmjs/stream": "0.28.4", + "@cosmjs/stream": "0.28.11", "isomorphic-ws": "^4.0.1", "ws": "^7", "xstream": "^11.14.0" } }, "@cosmjs/stargate": { - "version": "0.28.4", - "resolved": "https://registry.npmjs.org/@cosmjs/stargate/-/stargate-0.28.4.tgz", - "integrity": "sha512-tdwudilP5iLNwDm4TOMBjWuL5YehLPqGlC5/7hjJM/kVHyzLFo4Lzt0dVEwr5YegH+RsRXH/VtFLQz+NYlCobw==", + "version": "0.28.11", + "resolved": "https://registry.npmjs.org/@cosmjs/stargate/-/stargate-0.28.11.tgz", + "integrity": "sha512-UyFH/mTNNKTZohVhj+SmjCRv/xopqU/UinGedmWzs4MqEZteX9xs6D3HTmRCgpmBQ03lpbTslE/FhhT9Hkl9KQ==", "requires": { "@confio/ics23": "^0.6.8", - "@cosmjs/amino": "0.28.4", - "@cosmjs/encoding": "0.28.4", - "@cosmjs/math": "0.28.4", - "@cosmjs/proto-signing": "0.28.4", - "@cosmjs/stream": "0.28.4", - "@cosmjs/tendermint-rpc": "0.28.4", - "@cosmjs/utils": "0.28.4", + "@cosmjs/amino": "0.28.11", + "@cosmjs/encoding": "0.28.11", + "@cosmjs/math": "0.28.11", + "@cosmjs/proto-signing": "0.28.11", + "@cosmjs/stream": "0.28.11", + "@cosmjs/tendermint-rpc": "0.28.11", + "@cosmjs/utils": "0.28.11", "cosmjs-types": "^0.4.0", "long": "^4.0.0", - "protobufjs": "~6.10.2", + "protobufjs": "~6.11.3", "xstream": "^11.14.0" }, "dependencies": { "@cosmjs/encoding": { - "version": "0.28.4", - "resolved": "https://registry.npmjs.org/@cosmjs/encoding/-/encoding-0.28.4.tgz", - "integrity": "sha512-N6Qnjs4dd8KwjW5m9t3L+rWYYGW2wyS+iLtJJ9DD8DiTTxpW9h7/AmUVO/dsRe5H2tV8/DzH/B9pFfpsgro22A==", + "version": "0.28.11", + "resolved": "https://registry.npmjs.org/@cosmjs/encoding/-/encoding-0.28.11.tgz", + "integrity": "sha512-J7pvlzAt8hBZn316wGRmUlK3xwMgNXUvj4v56DK4fA0fv6VfGwMvVtHCXaqNQtzOGkC6EQcshzA/fL5MBIwu6A==", "requires": { "base64-js": "^1.3.0", "bech32": "^1.1.4", @@ -19392,34 +19360,34 @@ } }, "@cosmjs/stream": { - "version": "0.28.4", - "resolved": "https://registry.npmjs.org/@cosmjs/stream/-/stream-0.28.4.tgz", - "integrity": "sha512-BDwDdFOrOgRx/Wm5nknb9YCV9HHIUcsOxykTDZqdArCUsn4QJBq79QIjp919G05Z8UemkoHwiUCUNB2BfoKmFw==", + "version": "0.28.11", + "resolved": "https://registry.npmjs.org/@cosmjs/stream/-/stream-0.28.11.tgz", + "integrity": "sha512-3b6P4Il8mYzvY2bvEQyzgP+cm0HIGSpHNtuGjiWsQF3Wtp450iVRfEJqdt4+91vvxzfdjQEkQOLMaymnswX3sw==", "requires": { "xstream": "^11.14.0" } }, "@cosmjs/tendermint-rpc": { - "version": "0.28.4", - "resolved": "https://registry.npmjs.org/@cosmjs/tendermint-rpc/-/tendermint-rpc-0.28.4.tgz", - "integrity": "sha512-iz6p4UW2QUZNh55WeJy9wHbMdqM8COo0AJdrGU4Ikb/xU0/H6b0dFPoEK+i6ngR0cSizh+hpTMzh3AA7ySUKlA==", - "requires": { - "@cosmjs/crypto": "0.28.4", - "@cosmjs/encoding": "0.28.4", - "@cosmjs/json-rpc": "0.28.4", - "@cosmjs/math": "0.28.4", - "@cosmjs/socket": "0.28.4", - "@cosmjs/stream": "0.28.4", - "@cosmjs/utils": "0.28.4", + "version": "0.28.11", + "resolved": "https://registry.npmjs.org/@cosmjs/tendermint-rpc/-/tendermint-rpc-0.28.11.tgz", + "integrity": "sha512-TUhWsUYxbKftQmHQK5TBH62vNaKB1ybxoFZ2uJtGMVvY3jcBux7P0Ll/u5nwrM0ETAeo2RjucehJUpGBy9q+HQ==", + "requires": { + "@cosmjs/crypto": "0.28.11", + "@cosmjs/encoding": "0.28.11", + "@cosmjs/json-rpc": "0.28.11", + "@cosmjs/math": "0.28.11", + "@cosmjs/socket": "0.28.11", + "@cosmjs/stream": "0.28.11", + "@cosmjs/utils": "0.28.11", "axios": "^0.21.2", "readonly-date": "^1.0.0", "xstream": "^11.14.0" }, "dependencies": { "@cosmjs/encoding": { - "version": "0.28.4", - "resolved": "https://registry.npmjs.org/@cosmjs/encoding/-/encoding-0.28.4.tgz", - "integrity": "sha512-N6Qnjs4dd8KwjW5m9t3L+rWYYGW2wyS+iLtJJ9DD8DiTTxpW9h7/AmUVO/dsRe5H2tV8/DzH/B9pFfpsgro22A==", + "version": "0.28.11", + "resolved": "https://registry.npmjs.org/@cosmjs/encoding/-/encoding-0.28.11.tgz", + "integrity": "sha512-J7pvlzAt8hBZn316wGRmUlK3xwMgNXUvj4v56DK4fA0fv6VfGwMvVtHCXaqNQtzOGkC6EQcshzA/fL5MBIwu6A==", "requires": { "base64-js": "^1.3.0", "bech32": "^1.1.4", @@ -19429,9 +19397,9 @@ } }, "@cosmjs/utils": { - "version": "0.28.4", - "resolved": "https://registry.npmjs.org/@cosmjs/utils/-/utils-0.28.4.tgz", - "integrity": "sha512-lb3TU6833arPoPZF8HTeG9V418CpurvqH5Aa/ls0I0wYdPDEMO6622+PQNQhQ8Vw8Az2MXoSyc8jsqrgawT84Q==" + "version": "0.28.11", + "resolved": "https://registry.npmjs.org/@cosmjs/utils/-/utils-0.28.11.tgz", + "integrity": "sha512-FXVEr7Pg6MX9VbY5NemuKbtFVabSlUlArWIV+R74FQg5LIuSa+0QkxSpNldCuOLBEU4/GlrzybT4uEl338vSzg==" }, "@dabh/diagnostics": { "version": "2.0.3", @@ -22086,28 +22054,6 @@ "requires": { "long": "^4.0.0", "protobufjs": "~6.11.2" - }, - "dependencies": { - "protobufjs": { - "version": "6.11.2", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.11.2.tgz", - "integrity": "sha512-4BQJoPooKJl2G9j3XftkIXjoC9C0Av2NOrWmbLWT1vH32GcSUHjM0Arra6UfTsVyfMAuFzaLucXn1sadxJydAw==", - "requires": { - "@protobufjs/aspromise": "^1.1.2", - "@protobufjs/base64": "^1.1.2", - "@protobufjs/codegen": "^2.0.4", - "@protobufjs/eventemitter": "^1.1.0", - "@protobufjs/fetch": "^1.1.0", - "@protobufjs/float": "^1.0.2", - "@protobufjs/inquire": "^1.1.0", - "@protobufjs/path": "^1.1.2", - "@protobufjs/pool": "^1.1.0", - "@protobufjs/utf8": "^1.1.0", - "@types/long": "^4.0.1", - "@types/node": ">=13.7.0", - "long": "^4.0.0" - } - } } }, "crc": { @@ -28318,9 +28264,9 @@ "integrity": "sha1-yyDTIqq32U//rCj0bJGGvVlHtLQ=" }, "protobufjs": { - "version": "6.10.2", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.10.2.tgz", - "integrity": "sha512-27yj+04uF6ya9l+qfpH187aqEzfCF4+Uit0I9ZBQVqK09hk/SQzKa2MUqUpXaVa7LOFRg1TSSr3lVxGOk6c0SQ==", + "version": "6.11.3", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.11.3.tgz", + "integrity": "sha512-xL96WDdCZYdU7Slin569tFX712BxsxslWwAfAhCYjQKGTq7dAU91Lomy6nLLhh/dyGhk/YH4TwTSRxTzhuHyZg==", "requires": { "@protobufjs/aspromise": "^1.1.2", "@protobufjs/base64": "^1.1.2", @@ -28333,15 +28279,8 @@ "@protobufjs/pool": "^1.1.0", "@protobufjs/utf8": "^1.1.0", "@types/long": "^4.0.1", - "@types/node": "^13.7.0", + "@types/node": ">=13.7.0", "long": "^4.0.0" - }, - "dependencies": { - "@types/node": { - "version": "13.13.52", - "resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.52.tgz", - "integrity": "sha512-s3nugnZumCC//n4moGGe6tkNMyYEdaDBitVjwPxXmR5lnMG5dHePinH2EdxkG3Rh1ghFHHixAG4NJhpJW1rthQ==" - } } }, "proxy-addr": { @@ -31886,9 +31825,9 @@ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, "ws": { - "version": "7.5.7", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.7.tgz", - "integrity": "sha512-KMvVuFzpKBuiIXW3E4u3mySRO2/mCHSyZDJQM5NQ9Q9KHWHWh0NHgfbRMLLrceUK5qAL4ytALJbpRMjixFZh8A==", + "version": "7.5.9", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", + "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", "requires": {} }, "xhr": { diff --git a/src/frontend/resources/common/js/models/ledgers/KeplrLedger.ts b/src/frontend/resources/common/js/models/ledgers/KeplrLedger.ts index d954ab5..0028f40 100644 --- a/src/frontend/resources/common/js/models/ledgers/KeplrLedger.ts +++ b/src/frontend/resources/common/js/models/ledgers/KeplrLedger.ts @@ -2,14 +2,13 @@ import Ledger from './Ledger'; import { makeObservable, observable } from 'mobx'; import S from '../../utilities/Main'; import Config from '../../../../../../../builds/dev-generated/Config'; -import CosmosNetworkH from './CosmosNetworkH'; -import { MsgSendToEth, MsgRequestBatch } from '../../cosmos/codec/gravity/gravity/v1/msgs'; -import { assertIsBroadcastTxSuccess, SigningStargateClient, defaultRegistryTypes, assertIsDeliverTxSuccess } from '@cosmjs/stargate'; -import { EncodeObject, Registry } from '@cosmjs/proto-signing'; +import { AccountData, Coin, coin, OfflineSigner, StargateClient, CudosNetworkConsts, ClientSimulateFn, DeliverTxResponse, StdFee } from 'cudosjs'; +import { assertIsBroadcastTxSuccess, SigningStargateClient, defaultRegistryTypes, assertIsDeliverTxSuccess, checkValidAddress, estimateFee, generateMsg } from 'cudosjs'; +import { EncodeObject, Registry } from 'cudosjs'; import BigNumber from 'bignumber.js'; -import { GasPrice } from '@cosmjs/launchpad'; -import { Uint53 } from "@cosmjs/math"; -import { coins } from "@cosmjs/amino"; +import { GasPrice } from 'cudosjs'; +import { Uint53 } from 'cudosjs'; +import { coins } from 'cudosjs'; export default class KeplrLedger implements Ledger { @observable connected: number; @@ -19,6 +18,7 @@ export default class KeplrLedger implements Ledger { @observable bridgeFee: BigNumber; @observable chainID: string; @observable rpcEndpoint: string; + queryClient: StargateClient static NETWORK_NAME = 'Cudos'; @@ -47,14 +47,14 @@ export default class KeplrLedger implements Ledger { // Staking coin information stakeCurrency: { // Coin denomination to be displayed to the user. - coinDenom: CosmosNetworkH.CURRENCY_DISPLAY_NAME, + coinDenom: CudosNetworkConsts.CURRENCY_DISPLAY_NAME, // Actual denom (i.e. uatom, uscrt) used by the blockchain. - coinMinimalDenom: CosmosNetworkH.CURRENCY_DENOM, + coinMinimalDenom: CudosNetworkConsts.CURRENCY_DENOM, // # of decimal points to convert minimal denomination to user-facing denomination. - coinDecimals: CosmosNetworkH.CURRENCY_DECIMALS, + coinDecimals: CudosNetworkConsts.CURRENCY_DECIMALS, // (Optional) Keplr can show the fiat value of the coin if a coingecko id is provided. // You can get id from https://api.coingecko.com/api/v3/coins/list if it is listed. - coinGeckoId: CosmosNetworkH.CURRENCY_COINGECKO_ID, + coinGeckoId: CudosNetworkConsts.CURRENCY_COINGECKO_ID, }, // (Optional) If you have a wallet webpage used to stake the coin then provide the url to the website in `walletUrlForStaking`. // The 'stake' button in Keplr extension will link to the webpage. @@ -63,36 +63,36 @@ export default class KeplrLedger implements Ledger { bip44: { // You can only set the coin type of BIP44. // 'Purpose' is fixed to 44. - coinType: CosmosNetworkH.LEDGER_COIN_TYPE, + coinType: CudosNetworkConsts.LEDGER_COIN_TYPE, }, bech32Config: { - bech32PrefixAccAddr: CosmosNetworkH.BECH32_PREFIX_ACC_ADDR, - bech32PrefixAccPub: CosmosNetworkH.BECH32_PREFIX_ACC_PUB, - bech32PrefixValAddr: CosmosNetworkH.BECH32_PREFIX_VAL_ADDR, - bech32PrefixValPub: CosmosNetworkH.BECH32_PREFIX_VAL_PUB, - bech32PrefixConsAddr: CosmosNetworkH.BECH32_PREFIX_CONS_ADDR, - bech32PrefixConsPub: CosmosNetworkH.BECH32_PREFIX_CONS_PUB, + bech32PrefixAccAddr: CudosNetworkConsts.BECH32_PREFIX_ACC_ADDR, + bech32PrefixAccPub: CudosNetworkConsts.BECH32_PREFIX_ACC_PUB, + bech32PrefixValAddr: CudosNetworkConsts.BECH32_PREFIX_VAL_ADDR, + bech32PrefixValPub: CudosNetworkConsts.BECH32_PREFIX_VAL_PUB, + bech32PrefixConsAddr: CudosNetworkConsts.BECH32_PREFIX_CONS_ADDR, + bech32PrefixConsPub: CudosNetworkConsts.BECH32_PREFIX_CONS_PUB, }, // List of all coin/tokens used in this chain. currencies: [{ // Coin denomination to be displayed to the user. - coinDenom: CosmosNetworkH.CURRENCY_DISPLAY_NAME, + coinDenom: CudosNetworkConsts.CURRENCY_DISPLAY_NAME, // Actual denom (i.e. uatom, uscrt) used by the blockchain. - coinMinimalDenom: CosmosNetworkH.CURRENCY_DENOM, + coinMinimalDenom: CudosNetworkConsts.CURRENCY_DENOM, // # of decimal points to convert minimal denomination to user-facing denomination. - coinDecimals: CosmosNetworkH.CURRENCY_DECIMALS, + coinDecimals: CudosNetworkConsts.CURRENCY_DECIMALS, // (Optional) Keplr can show the fiat value of the coin if a coingecko id is provided. // You can get id from https://api.coingecko.com/api/v3/coins/list if it is listed. - coinGeckoId: CosmosNetworkH.CURRENCY_COINGECKO_ID, + coinGeckoId: CudosNetworkConsts.CURRENCY_COINGECKO_ID, }], // List of coin/tokens used as a fee token in this chain. feeCurrencies: [{ // Coin denomination to be displayed to the user. - coinDenom: CosmosNetworkH.CURRENCY_DISPLAY_NAME, + coinDenom: CudosNetworkConsts.CURRENCY_DISPLAY_NAME, // Actual denom (i.e. uatom, uscrt) used by the blockchain. - coinMinimalDenom: CosmosNetworkH.CURRENCY_DENOM, + coinMinimalDenom: CudosNetworkConsts.CURRENCY_DENOM, // # of decimal points to convert minimal denomination to user-facing denomination. - coinDecimals: CosmosNetworkH.CURRENCY_DECIMALS, + coinDecimals: CudosNetworkConsts.CURRENCY_DECIMALS, // (Optional) Keplr can show the fiat value of the coin if a coingecko id is provided. // You can get id from https://api.coingecko.com/api/v3/coins/list if it is listed. // coinGeckoId: Meteor.settings.public.coingeckoId, @@ -102,7 +102,7 @@ export default class KeplrLedger implements Ledger { // Ideally, it is recommended to be the same with BIP44 path's coin type. // However, some early chains may choose to use the Cosmos Hub BIP44 path of '118'. // So, this is separated to support such chains. - coinType: CosmosNetworkH.LEDGER_COIN_TYPE, + coinType: CudosNetworkConsts.LEDGER_COIN_TYPE, // (Optional) This is used to set the fee of the transaction. // If this field is not provided, Keplr extension will set the default gas price as (low: 0.01, average: 0.025, high: 0.04). // Currently, Keplr doesn't support dynamic calculation of the gas prices based on on-chain data. @@ -127,12 +127,15 @@ export default class KeplrLedger implements Ledger { window.keplr.defaultOptions = { sign: { preferNoSetFee: true, - } - }; - - const offlineSigner = window.getOfflineSigner(Config.CUDOS_NETWORK.CHAIN_ID); - this.account = (await offlineSigner.getAccounts())[0].address; + }, + }; + + const [_, account] = await this.GetKeplrSignerAndAccount() + this.account = account.address; + // Instantiating the queryClient just once - since it's not tied to a particular account. + // This is more performant + this.queryClient = await StargateClient.connect(Config.CUDOS_NETWORK.RPC) this.connected = S.INT_TRUE; } catch (error) { if (!window.keplr) { @@ -150,68 +153,41 @@ export default class KeplrLedger implements Ledger { }); } - calculateFee = (gasLimit: number, { denom, amount: gasPriceAmount }) => { - const amount = Math.ceil(gasPriceAmount.multiply(new Uint53(gasLimit)).toFloatApproximation()); - return { - amount: coins(amount.toString(), denom), - gas: gasLimit.toString(), - }; - }; - - EstimateFee = async (client: SigningStargateClient, gasPrice: GasPrice, signerAddress: string, messages: readonly EncodeObject[], memo = "") => { - const multiplier = 1.3; - const gasEstimation = await client.simulate(signerAddress, messages, memo); - return this.calculateFee(Math.round(gasEstimation * multiplier), gasPrice); - }; - - GetKeplrClientAndAccount = async () => { - const offlineSigner = window.getOfflineSigner(this.chainID); - const myRegistry = new Registry([ - ...defaultRegistryTypes, - [CosmosNetworkH.MESSAGE_TYPE_URL, MsgSendToEth], - ]); - const client = await SigningStargateClient.connectWithSigner(this.rpcEndpoint, offlineSigner, { - registry: myRegistry, - }); + GetKeplrSignerAndAccount = async (): Promise<[OfflineSigner, AccountData]> => { + const offlineSigner = await window.getOfflineSigner(this.chainID); const account = (await offlineSigner.getAccounts())[0]; - return [client, account]; + return [offlineSigner, account] + } + + GetKeplrSigningClient = async (offlineSigner:OfflineSigner): Promise < SigningStargateClient > => { + const client = await SigningStargateClient.connectWithSigner(this.rpcEndpoint, offlineSigner); + return client } - async send(amount: BigNumber, destiantionAddress: string): Promise { - const stringifiedAmount = amount.multipliedBy(CosmosNetworkH.CURRENCY_1_CUDO).toString(10); + async send(amount: BigNumber, destinationAddress: string): Promise { await window.keplr.enable(this.chainID); - const [client, account] = await this.GetKeplrClientAndAccount(); - - const msgSend = [{ - typeUrl: CosmosNetworkH.MESSAGE_TYPE_URL, - value: { - sender: account.address, - ethDest: destiantionAddress, - amount: { - amount: stringifiedAmount, - denom: CosmosNetworkH.CURRENCY_DENOM, - }, - bridgeFee: { - amount: this.bridgeFee.toString(10), - denom: CosmosNetworkH.CURRENCY_DENOM, - }, - }, - }]; + const [offlineSigner, account] = await this.GetKeplrSignerAndAccount() + const client = await this.GetKeplrSigningClient(offlineSigner); + this.walletError = null; try { - this.walletError = null; - const msgFee = await this.EstimateFee( - client, - GasPrice.fromString(`${Config.CUDOS_NETWORK.GAS_PRICE}acudos`), - account.address, - msgSend, - 'Fee Estimation Message', - ); - const result = await client.signAndBroadcast( + const coinAmount:Coin = coin( + amount.multipliedBy(CudosNetworkConsts.CURRENCY_1_CUDO).toString(10), + CudosNetworkConsts.CURRENCY_DENOM, + ) + const bridgeFeeAmount:Coin = coin( + this.bridgeFee.toString(10), + CudosNetworkConsts.CURRENCY_DENOM, + ) + const gasPrice:GasPrice = GasPrice.fromString(`${Config.CUDOS_NETWORK.GAS_PRICE}acudos`) + + const result = await client.gravitySendToEth( account.address, - msgSend, - msgFee, + destinationAddress, + coinAmount, + bridgeFeeAmount, + gasPrice, 'Sent with CUDOS Gravity Bridge', ); @@ -222,23 +198,26 @@ export default class KeplrLedger implements Ledger { } } + async EstimateFee(client: SigningStargateClient, sender: string, messages: EncodeObject[], gasPrice: GasPrice, + memo?:string, gasMultiplier?: number):Promise { + const fee = await estimateFee(client, sender, messages, gasPrice, gasMultiplier, memo) + return fee + } + async getBalance(): Promise { this.walletError = null; try { - const offlineSigner = window.getOfflineSigner(Config.CUDOS_NETWORK.CHAIN_ID); - const account = (await offlineSigner.getAccounts())[0]; + const [_, account] = await this.GetKeplrSignerAndAccount() + const balance: Coin = await this.queryClient.getBalance(account.address, CudosNetworkConsts.CURRENCY_DENOM) - const url = `${Config.CUDOS_NETWORK.API}/cosmos/bank/v1beta1/balances/${account.address}/by_denom?denom=${CosmosNetworkH.CURRENCY_DENOM}`; - const amount = (await (await fetch(url)).json()).balance.amount; - - return new BigNumber(amount).div(CosmosNetworkH.CURRENCY_1_CUDO); + return new BigNumber(balance.amount).div(CudosNetworkConsts.CURRENCY_1_CUDO); } catch (e) { this.walletError = 'Failed to get balance!' } } setBridgeFee(bridgeFee: BigNumber) { - if (bridgeFee.lt((new BigNumber(1)).dividedBy(CosmosNetworkH.CURRENCY_1_CUDO))) { + if (bridgeFee.lt((new BigNumber(1)).dividedBy(CudosNetworkConsts.CURRENCY_1_CUDO))) { return; } @@ -246,6 +225,12 @@ export default class KeplrLedger implements Ledger { } isAddressValid(address: string): boolean { - return address.startsWith(CosmosNetworkH.BECH32_PREFIX_ACC_ADDR) && address.length === CosmosNetworkH.BECH32_ACC_ADDR_LENGTH; + try { + checkValidAddress(address) + return true + } catch { + this.walletError = 'Invalid Cosmos Address' + return false + } } } diff --git a/src/frontend/resources/common/js/models/ledgers/Ledger.ts b/src/frontend/resources/common/js/models/ledgers/Ledger.ts index 69d0897..a2d846f 100644 --- a/src/frontend/resources/common/js/models/ledgers/Ledger.ts +++ b/src/frontend/resources/common/js/models/ledgers/Ledger.ts @@ -1,6 +1,4 @@ -import { Coin, GasPrice } from '@cosmjs/launchpad'; -import { EncodeObject } from '@cosmjs/proto-signing'; -import { SigningStargateClient } from '@cosmjs/stargate'; +import { Coin, GasPrice, EncodeObject, StargateClient, SigningStargateClient, OfflineSigner, AccountData, StdFee } from 'cudosjs'; import BigNumber from 'bignumber.js'; export default interface Ledger { @@ -9,14 +7,14 @@ export default interface Ledger { walletError: string, txHash: string, txNonce: string, + queryClient:StargateClient, connect: () => Promise, disconnect: () => Promise, send: (amount: BigNumber, destination: string) => Promise, - EstimateFee: (client: SigningStargateClient, gasPrice: GasPrice, signerAddress: string, messages: readonly EncodeObject[], memo: string) => Promise<{ - amount: Coin[]; - gas: string; - }>, - GetKeplrClientAndAccount: () => Promise, + EstimateFee: (client: SigningStargateClient, sender: string, messages: EncodeObject[], gasPrice: GasPrice, + memo?:string, gasMultiplier?: number) => Promise, + GetKeplrSignerAndAccount: () => Promise<[OfflineSigner, AccountData]>, + GetKeplrSigningClient: (offlineSigner:OfflineSigner) => Promise < SigningStargateClient >, isAddressValid: (address: string) => boolean, getBalance(): Promise, } diff --git a/src/frontend/resources/common/js/models/ledgers/MetamaskLedger.ts b/src/frontend/resources/common/js/models/ledgers/MetamaskLedger.ts index 9307dd0..5fd7f37 100644 --- a/src/frontend/resources/common/js/models/ledgers/MetamaskLedger.ts +++ b/src/frontend/resources/common/js/models/ledgers/MetamaskLedger.ts @@ -8,8 +8,7 @@ import gravityContractAbi from '../../solidity/contract_interfaces/gravity.json' import Config from '../../../../../../../builds/dev-generated/Config'; import BigNumber from 'bignumber.js'; -import { Bech32, toBase64, toHex } from '@cosmjs/encoding'; -import CosmosNetworkH from './CosmosNetworkH'; +import { Bech32, toBase64, toHex, CudosNetworkConsts } from 'cudosjs'; export default class MetamaskLedger implements Ledger { static NETWORK_NAME = 'Ethereum'; @@ -80,7 +79,7 @@ export default class MetamaskLedger implements Ledger { }); const erc20Instance = new window.web3.eth.Contract(ERC20TokenAbi, Config.ORCHESTRATOR.ERC20_CONTRACT_ADDRESS); - const stringAmount = amount.multipliedBy(CosmosNetworkH.CURRENCY_1_CUDO).toString(10); + const stringAmount = amount.multipliedBy(CudosNetworkConsts.CURRENCY_1_CUDO).toString(10); erc20Instance.methods.approve(Config.ORCHESTRATOR.BRIDGE_CONTRACT_ADDRESS, stringAmount) .send({ from: account }, @@ -118,7 +117,7 @@ export default class MetamaskLedger implements Ledger { const balance = await erc20Contract.methods.balanceOf(wallet).call(); - return (new BigNumber(balance)).div(CosmosNetworkH.CURRENCY_1_CUDO); + return (new BigNumber(balance)).div(CudosNetworkConsts.CURRENCY_1_CUDO); } catch (e) { this.walletError = 'Failed to fetch balance'; } From 77430201cb32e586554a49499d7b70b244d61545 Mon Sep 17 00:00:00 2001 From: Bogo Lime Date: Mon, 1 Aug 2022 16:31:26 +0300 Subject: [PATCH 3/8] Refactored the UI to use the cudosJS package - replaced the custom logic implemented through cosmJS: 1. Updated CudosBridgePageComponent.ts: - All HTTP requests trough the API endpoint have been replaced with gRPC queries through CudosStargateSlient - Messages ( function simulatedMsgsCost ) are now constructed using the generateMsg factory function from cudosJS. --- config/.env.example | 34 ++++++ .../CudosBridgePageComponent.tsx | 100 ++++++++---------- 2 files changed, 81 insertions(+), 53 deletions(-) create mode 100644 config/.env.example diff --git a/config/.env.example b/config/.env.example new file mode 100644 index 0000000..9d036f5 --- /dev/null +++ b/config/.env.example @@ -0,0 +1,34 @@ +NODE_ENV=production|dev +NETWORK_TYPE=mainnet/testnet +BACKEND_PORT= (port on which server will be accessed from browser) +FRONTEND_PORT= +URL=http://ip/localhost/domain +SESSION_UNIQUE_KEY=secret +SESSION_STORE_TCP_ADDR=127.0.0.1 +SESSION_STORE_PORT=6379 + +DATABASE_HOST=localhost +DATABASE_PORT=3306 +DATABASE_USER= +DATABASE_PASS= +DATABASE_NAME= +DATABASE_CONNECTION_LIMIT=10 + +#cudos network variables +CHAIN_NAME= +CHAIN_ID= +GRAVITY_MODULE_ADDRESS= +RPC= +API= +GAS_PRICE= +GAS= +STAKING= +BLOCK_EXPLORER=(http:///transactions) + +#orchestrator variables +ERC20_CONTRACT_ADDRESS= +BRIDGE_CONTRACT_ADDRESS= + +#ethereum variables +ETHEREUM_GAS= +ETHEREUM_RPC= \ No newline at end of file diff --git a/src/frontend/resources/general/js/components-pages/CudosBridgePageComponent.tsx b/src/frontend/resources/general/js/components-pages/CudosBridgePageComponent.tsx index f205d8d..b0e462f 100644 --- a/src/frontend/resources/general/js/components-pages/CudosBridgePageComponent.tsx +++ b/src/frontend/resources/general/js/components-pages/CudosBridgePageComponent.tsx @@ -21,12 +21,13 @@ import NetworkStore from '../../../common/js/stores/NetworkStore'; import KeplrLedger from '../../../common/js/models/ledgers/KeplrLedger'; import ProjectUtils from '../../../common/js/ProjectUtils'; import Ledger from '../../../common/js/models/ledgers/Ledger'; -import CosmosNetworkH from '../../../common/js/models/ledgers/CosmosNetworkH'; +import { CudosNetworkConsts, generateMsg } from "cudosjs" import MetamaskLedger from '../../../common/js/models/ledgers/MetamaskLedger'; import Web3 from 'web3'; import ERC20TokenAbi from '../../../common/js/solidity/contract_interfaces/ERC20_token.json'; -import axios from 'axios'; -import { GasPrice } from '@cosmjs/launchpad'; +import { GasPrice } from 'cudosjs'; +import { SigningStargateClient, StargateClient, Coin, coin } from 'cudosjs' +import { Long } from "long"; interface Props extends ContextPageComponentProps { networkStore: NetworkStore; @@ -70,11 +71,6 @@ const cudosFont = '../../../../resources/common/img/favicon/cudos-font.svg' const transferLogoAlt = '../../../../resources/common/img/favicon/transfer-logo-alt.svg' const keplrLink = 'https://chrome.google.com/webstore/detail/keplr/dmkamcknogkgcdfhhbddcghachkejeap?hl=en' -const GRAVITY_TX_BY_HASH_REST_ENDPOINT = '/cosmos/tx/v1beta1/txs/' -const GRAVITY_TXS_RPC_ENDPOINT = '/tx_search?query="message.action=\'/gravity.v1.MsgSendToCosmosClaim\'"' -const PARAMS_REST_ENDPOINT = '/gravity/v1beta/params' -const BLOCK_HEIGHT__RPC_ENDPOINT = '/abci_info' - export default class CudosBridgeComponent extends ContextPageComponent { inputTimeouts: any; @@ -130,14 +126,15 @@ export default class CudosBridgeComponent extends ContextPageComponent => { - const url: string = `${Config.CUDOS_NETWORK.API}/bank/balances/${account}`; - const response = await axios.get(url); - let accountBalance: string; - if (response.status === 200 && response.data.result[0]) { - accountBalance = response.data.result[0].amount; - } else { - accountBalance = '0'; + + const rpc: string = Config.CUDOS_NETWORK.RPC + const queryClient: StargateClient = this.props.networkStore.networkHolders[1].ledger.queryClient + + try { + accountBalance = (await queryClient.getBalance(account, 'acudos')).amount + } catch (e) { + accountBalance = '0' } return accountBalance; } @@ -148,7 +145,7 @@ export default class CudosBridgeComponent extends ContextPageComponent { @@ -454,7 +451,7 @@ export default class CudosBridgeComponent extends ContextPageComponent => { let simulatedCost = new BigNumber(0); - const stringifiedAmount = new BigNumber(amount).multipliedBy(CosmosNetworkH.CURRENCY_1_CUDO).toString(10); + const stringifiedAmount = new BigNumber(amount).multipliedBy(CudosNetworkConsts.CURRENCY_1_CUDO).toString(10); const ledger = this.props.networkStore.networkHolders[this.state.selectedFromNetwork].ledger; - const [client, account] = await ledger.GetKeplrClientAndAccount(); + const [offlineSigner, account] = await ledger.GetKeplrSignerAndAccount() + const client = await ledger.GetKeplrSigningClient(offlineSigner) + let destination: string; let sender: string; @@ -687,41 +686,32 @@ export default class CudosBridgeComponent extends ContextPageComponent => { - const response = await axios.get(Config.CUDOS_NETWORK.API + PARAMS_REST_ENDPOINT); - const minTransferAmount = response.data.params.minimum_transfer_to_eth; - const minBridgeFeeAmount = response.data.params.minimum_fee_transfer_to_eth; + const response = await this.props.networkStore.networkHolders[1].ledger.queryClient.gravityModule.getParams() + const minTransferAmount = response.params.minimumTransferToEth; + const minBridgeFeeAmount = response.params.minimumFeeTransferToEth; - if (minTransferAmount === undefined || minBridgeFeeAmount === undefined || response.status != 200) { + if (minTransferAmount === undefined || minBridgeFeeAmount === undefined) { this.setState({ isTransactionFail: true, errorMessage: 'We cannot proceed with your request at the moment', @@ -729,19 +719,22 @@ export default class CudosBridgeComponent extends ContextPageComponent => { let result = ''; - const heightRes = await (await fetch(Config.CUDOS_NETWORK.RPC + BLOCK_HEIGHT__RPC_ENDPOINT)).json(); - let height = Number(heightRes.result.response.last_block_height); + const qClient = this.props.networkStore.networkHolders[1].ledger.queryClient + const heightRes = await qClient.getHeight(); + let height = Number(heightRes); while (result === '') { - const txData = await (await fetch(Config.CUDOS_NETWORK.RPC + GRAVITY_TXS_RPC_ENDPOINT)).json(); + const txData = await qClient.searchTx({ + tags: [{ key: "message.action", value: "/gravity.v1.MsgSendToCosmosClaim" }], + }) - const filteredTxs = txData.result.txs.filter((tx) => Number(tx.height) > height); + const filteredTxs = txData.filter((tx) => Number(tx.height) > height); if (filteredTxs.length > 0) { const txHashes: string[] = filteredTxs.map((tx) => tx.hash); @@ -752,10 +745,11 @@ export default class CudosBridgeComponent extends ContextPageComponent Date: Thu, 4 Aug 2022 15:50:32 +0000 Subject: [PATCH 4/8] added cudosjs package and remove unused var in env --- config/.env.example | 1 - config/config.js | 6 +- package-lock.json | 130 ++++++++++++++++++++++++++++++++++++++++++++ package.json | 3 +- 4 files changed, 134 insertions(+), 6 deletions(-) diff --git a/config/.env.example b/config/.env.example index 9d036f5..25a74e1 100644 --- a/config/.env.example +++ b/config/.env.example @@ -21,7 +21,6 @@ GRAVITY_MODULE_ADDRESS= RPC= API= GAS_PRICE= -GAS= STAKING= BLOCK_EXPLORER=(http:///transactions) diff --git a/config/config.js b/config/config.js index 9a9fd4d..f04d9b3 100644 --- a/config/config.js +++ b/config/config.js @@ -27,13 +27,12 @@ const envVariables = [ 'RPC', 'API', 'GAS_PRICE', - 'GAS', 'ERC20_CONTRACT_ADDRESS', 'BRIDGE_CONTRACT_ADDRESS', 'ETHEREUM_GAS', 'STAKING', 'BLOCK_EXPLORER', - 'NETWORK_TYPE' + 'NETWORK_TYPE', ]; if (process.env.NODE_ENV === 'production') { @@ -207,7 +206,6 @@ const Config = { RPC: process.env.RPC, API: process.env.API, GAS_PRICE: process.env.GAS_PRICE, - GAS: process.env.GAS, STAKING: process.env.STAKING, BLOCK_EXPLORER: process.env.BLOCK_EXPLORER, }, @@ -219,7 +217,7 @@ const Config = { ETHEREUM_GAS: process.env.ETHEREUM_GAS, ETHEREUM_RPC: process.env.ETHEREUM_RPC, ETHERSCAN_RINKEBY: 'https://rinkeby.etherscan.io/tx', - ETHERSCAN_MAINNET: 'https://etherscan.io/tx' + ETHERSCAN_MAINNET: 'https://etherscan.io/tx', }, }; diff --git a/package-lock.json b/package-lock.json index 1b87e7c..193186f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,7 @@ "bignum": "^0.13.1", "chokidar": "^3.5.2", "cors": "^2.8.5", + "cudosjs": "1.0.0", "dotenv": "^8.2.0", "js-sha256": "^0.9.0", "koa": "^2.13.0", @@ -1915,6 +1916,39 @@ "readonly-date": "^1.0.0" } }, + "node_modules/@cosmjs/cosmwasm-stargate": { + "version": "0.28.11", + "resolved": "https://registry.npmjs.org/@cosmjs/cosmwasm-stargate/-/cosmwasm-stargate-0.28.11.tgz", + "integrity": "sha512-sZ04c9ZvwAC7IngNeOhTnHJLBu7PXX3QfWM2vCVGd9puP9f3Hj3nbre75WKjHZ3DDVvxfS3u3JUJ6LjVWeIRuQ==", + "dependencies": { + "@cosmjs/amino": "0.28.11", + "@cosmjs/crypto": "0.28.11", + "@cosmjs/encoding": "0.28.11", + "@cosmjs/math": "0.28.11", + "@cosmjs/proto-signing": "0.28.11", + "@cosmjs/stargate": "0.28.11", + "@cosmjs/tendermint-rpc": "0.28.11", + "@cosmjs/utils": "0.28.11", + "cosmjs-types": "^0.4.0", + "long": "^4.0.0", + "pako": "^2.0.2" + } + }, + "node_modules/@cosmjs/cosmwasm-stargate/node_modules/@cosmjs/encoding": { + "version": "0.28.11", + "resolved": "https://registry.npmjs.org/@cosmjs/encoding/-/encoding-0.28.11.tgz", + "integrity": "sha512-J7pvlzAt8hBZn316wGRmUlK3xwMgNXUvj4v56DK4fA0fv6VfGwMvVtHCXaqNQtzOGkC6EQcshzA/fL5MBIwu6A==", + "dependencies": { + "base64-js": "^1.3.0", + "bech32": "^1.1.4", + "readonly-date": "^1.0.0" + } + }, + "node_modules/@cosmjs/cosmwasm-stargate/node_modules/pako": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pako/-/pako-2.0.4.tgz", + "integrity": "sha512-v8tweI900AUkZN6heMU/4Uy4cXRc2AYNRggVmTR+dEncawDJgCdLMximOVA2p4qO57WMynangsfGRb5WD6L1Bg==" + }, "node_modules/@cosmjs/crypto": { "version": "0.28.11", "resolved": "https://registry.npmjs.org/@cosmjs/crypto/-/crypto-0.28.11.tgz", @@ -6084,6 +6118,28 @@ "integrity": "sha512-/WwNkdXfckNgw6S5R125rrW8ez139lBHWouiBvX8dfMFtcn6V81REDqnH7+CRpRipfYlyU1CmOnOxrmGcFOjeA==", "dev": true }, + "node_modules/cudosjs": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/cudosjs/-/cudosjs-1.0.0.tgz", + "integrity": "sha512-IREAix5Guv0hQLRx1Pn16N1crS9dVvBeeVYjGYBoXt6PWB+cb2f3tmBrg4QiK3oV06XGpM7ipAIcPVaDsNWg5A==", + "dependencies": { + "@cosmjs/cosmwasm-stargate": "^0.28.4", + "@cosmjs/crypto": "^0.28.4", + "@cosmjs/proto-signing": "^0.28.4", + "@cosmjs/stargate": "^0.28.4", + "@cosmjs/tendermint-rpc": "^0.28.4", + "bignumber.js": "^9.0.2", + "yarn": "^1.22.19" + } + }, + "node_modules/cudosjs/node_modules/bignumber.js": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.2.tgz", + "integrity": "sha512-GAcQvbpsM0pUb0zw1EI0KhQEZ+lRwR5fYaAp3vPOYuP7aDvGy6cVN6XHLauvF8SOga2y0dcLcjt3iQDTSEliyw==", + "engines": { + "node": "*" + } + }, "node_modules/cyclist": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/cyclist/-/cyclist-1.0.1.tgz", @@ -17873,6 +17929,19 @@ "node": ">= 6" } }, + "node_modules/yarn": { + "version": "1.22.19", + "resolved": "https://registry.npmjs.org/yarn/-/yarn-1.22.19.tgz", + "integrity": "sha512-/0V5q0WbslqnwP91tirOvldvYISzaqhClxzyUKXYxs07yUILIs5jx/k6CFe8bvKSkds5w+eiOqta39Wk3WxdcQ==", + "hasInstallScript": true, + "bin": { + "yarn": "bin/yarn.js", + "yarnpkg": "bin/yarn.js" + }, + "engines": { + "node": ">=4.0.0" + } + }, "node_modules/ylru": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/ylru/-/ylru-1.3.2.tgz", @@ -19154,6 +19223,41 @@ } } }, + "@cosmjs/cosmwasm-stargate": { + "version": "0.28.11", + "resolved": "https://registry.npmjs.org/@cosmjs/cosmwasm-stargate/-/cosmwasm-stargate-0.28.11.tgz", + "integrity": "sha512-sZ04c9ZvwAC7IngNeOhTnHJLBu7PXX3QfWM2vCVGd9puP9f3Hj3nbre75WKjHZ3DDVvxfS3u3JUJ6LjVWeIRuQ==", + "requires": { + "@cosmjs/amino": "0.28.11", + "@cosmjs/crypto": "0.28.11", + "@cosmjs/encoding": "0.28.11", + "@cosmjs/math": "0.28.11", + "@cosmjs/proto-signing": "0.28.11", + "@cosmjs/stargate": "0.28.11", + "@cosmjs/tendermint-rpc": "0.28.11", + "@cosmjs/utils": "0.28.11", + "cosmjs-types": "^0.4.0", + "long": "^4.0.0", + "pako": "^2.0.2" + }, + "dependencies": { + "@cosmjs/encoding": { + "version": "0.28.11", + "resolved": "https://registry.npmjs.org/@cosmjs/encoding/-/encoding-0.28.11.tgz", + "integrity": "sha512-J7pvlzAt8hBZn316wGRmUlK3xwMgNXUvj4v56DK4fA0fv6VfGwMvVtHCXaqNQtzOGkC6EQcshzA/fL5MBIwu6A==", + "requires": { + "base64-js": "^1.3.0", + "bech32": "^1.1.4", + "readonly-date": "^1.0.0" + } + }, + "pako": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pako/-/pako-2.0.4.tgz", + "integrity": "sha512-v8tweI900AUkZN6heMU/4Uy4cXRc2AYNRggVmTR+dEncawDJgCdLMximOVA2p4qO57WMynangsfGRb5WD6L1Bg==" + } + } + }, "@cosmjs/crypto": { "version": "0.28.11", "resolved": "https://registry.npmjs.org/@cosmjs/crypto/-/crypto-0.28.11.tgz", @@ -22478,6 +22582,27 @@ "integrity": "sha512-/WwNkdXfckNgw6S5R125rrW8ez139lBHWouiBvX8dfMFtcn6V81REDqnH7+CRpRipfYlyU1CmOnOxrmGcFOjeA==", "dev": true }, + "cudosjs": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/cudosjs/-/cudosjs-1.0.0.tgz", + "integrity": "sha512-IREAix5Guv0hQLRx1Pn16N1crS9dVvBeeVYjGYBoXt6PWB+cb2f3tmBrg4QiK3oV06XGpM7ipAIcPVaDsNWg5A==", + "requires": { + "@cosmjs/cosmwasm-stargate": "^0.28.4", + "@cosmjs/crypto": "^0.28.4", + "@cosmjs/proto-signing": "^0.28.4", + "@cosmjs/stargate": "^0.28.4", + "@cosmjs/tendermint-rpc": "^0.28.4", + "bignumber.js": "^9.0.2", + "yarn": "^1.22.19" + }, + "dependencies": { + "bignumber.js": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.2.tgz", + "integrity": "sha512-GAcQvbpsM0pUb0zw1EI0KhQEZ+lRwR5fYaAp3vPOYuP7aDvGy6cVN6XHLauvF8SOga2y0dcLcjt3iQDTSEliyw==" + } + } + }, "cyclist": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/cyclist/-/cyclist-1.0.1.tgz", @@ -31907,6 +32032,11 @@ "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", "dev": true }, + "yarn": { + "version": "1.22.19", + "resolved": "https://registry.npmjs.org/yarn/-/yarn-1.22.19.tgz", + "integrity": "sha512-/0V5q0WbslqnwP91tirOvldvYISzaqhClxzyUKXYxs07yUILIs5jx/k6CFe8bvKSkds5w+eiOqta39Wk3WxdcQ==" + }, "ylru": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/ylru/-/ylru-1.3.2.tgz", diff --git a/package.json b/package.json index e3b4d3d..5140713 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "source-map-support": "^0.5.19", "web3": "^1.4.0", "web3-utils": "^1.4.0", - "winston": "^3.3.3" + "winston": "^3.3.3", + "cudosjs": "1.0.0" }, "devDependencies": { "@babel/cli": "^7.12.7", From 962086ef4618a14fcbfb0727a2e215ee4339c536 Mon Sep 17 00:00:00 2001 From: SpaghettiOverload Date: Thu, 29 Sep 2022 11:22:40 +0300 Subject: [PATCH 5/8] Renaming, redundant imports --- README.md | 2 +- .../resources/common/js/models/ledgers/KeplrLedger.ts | 10 ++++------ .../js/components-pages/CudosBridgePageComponent.tsx | 7 ++----- tsconfig.json | 3 ++- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index c834ac5..9710941 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ # cudos-gravity-bridge-ui -UI for the gravity bridge +UI for the Cudos Bridge diff --git a/src/frontend/resources/common/js/models/ledgers/KeplrLedger.ts b/src/frontend/resources/common/js/models/ledgers/KeplrLedger.ts index 0028f40..33697a1 100644 --- a/src/frontend/resources/common/js/models/ledgers/KeplrLedger.ts +++ b/src/frontend/resources/common/js/models/ledgers/KeplrLedger.ts @@ -2,13 +2,11 @@ import Ledger from './Ledger'; import { makeObservable, observable } from 'mobx'; import S from '../../utilities/Main'; import Config from '../../../../../../../builds/dev-generated/Config'; -import { AccountData, Coin, coin, OfflineSigner, StargateClient, CudosNetworkConsts, ClientSimulateFn, DeliverTxResponse, StdFee } from 'cudosjs'; -import { assertIsBroadcastTxSuccess, SigningStargateClient, defaultRegistryTypes, assertIsDeliverTxSuccess, checkValidAddress, estimateFee, generateMsg } from 'cudosjs'; -import { EncodeObject, Registry } from 'cudosjs'; +import { AccountData, Coin, coin, OfflineSigner, StargateClient, CudosNetworkConsts, StdFee } from 'cudosjs'; +import { SigningStargateClient, assertIsDeliverTxSuccess, checkValidAddress, estimateFee } from 'cudosjs'; +import { EncodeObject } from 'cudosjs'; import BigNumber from 'bignumber.js'; import { GasPrice } from 'cudosjs'; -import { Uint53 } from 'cudosjs'; -import { coins } from 'cudosjs'; export default class KeplrLedger implements Ledger { @observable connected: number; @@ -188,7 +186,7 @@ export default class KeplrLedger implements Ledger { coinAmount, bridgeFeeAmount, gasPrice, - 'Sent with CUDOS Gravity Bridge', + 'Sent with CUDOS Bridge', ); this.txHash = result.transactionHash; diff --git a/src/frontend/resources/general/js/components-pages/CudosBridgePageComponent.tsx b/src/frontend/resources/general/js/components-pages/CudosBridgePageComponent.tsx index b0e462f..db81936 100644 --- a/src/frontend/resources/general/js/components-pages/CudosBridgePageComponent.tsx +++ b/src/frontend/resources/general/js/components-pages/CudosBridgePageComponent.tsx @@ -26,7 +26,7 @@ import MetamaskLedger from '../../../common/js/models/ledgers/MetamaskLedger'; import Web3 from 'web3'; import ERC20TokenAbi from '../../../common/js/solidity/contract_interfaces/ERC20_token.json'; import { GasPrice } from 'cudosjs'; -import { SigningStargateClient, StargateClient, Coin, coin } from 'cudosjs' +import { StargateClient, coin } from 'cudosjs' import { Long } from "long"; interface Props extends ContextPageComponentProps { @@ -768,10 +768,7 @@ export default class CudosBridgeComponent extends ContextPageComponent
-
-
-
-
Gravity Bridge
+
Cudos Bridge
{this.state.selectedFromNetwork ? ProjectUtils.CUDOS_NETWORK_TEXT : ProjectUtils.ETHEREUM_NETWORK_TEXT}
diff --git a/tsconfig.json b/tsconfig.json index bc33644..70fcb09 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -61,7 +61,8 @@ /* Experimental Options */ "experimentalDecorators": true /* Enables experimental support for ES7 decorators. */, "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ - "useDefineForClassFields": true + "useDefineForClassFields": true, + "resolveJsonModule": true } } \ No newline at end of file From b7c3f2e42b672864cf48c1100148482d07b70b25 Mon Sep 17 00:00:00 2001 From: ealeksandrov-LimeChain <92088769+ealeksandrov-LimeChain@users.noreply.github.com> Date: Thu, 3 Nov 2022 18:57:13 +0200 Subject: [PATCH 6/8] update title tag and meta description --- .../requests/pages/general/cudos-bridge/CudosBridge.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/requests/pages/general/cudos-bridge/CudosBridge.ts b/src/backend/requests/pages/general/cudos-bridge/CudosBridge.ts index d02177e..6b07620 100644 --- a/src/backend/requests/pages/general/cudos-bridge/CudosBridge.ts +++ b/src/backend/requests/pages/general/cudos-bridge/CudosBridge.ts @@ -16,8 +16,8 @@ export default class CudosBridge extends CudosBridgeH { context.payload.ctx.type = 'html'; context.payload.ctx.body = TEMPLATE.stream({ META: { - TITLE: 'Cudos Bridge', - DESC: '', + TITLE: 'CUDOS Bridge | Migrate tokens between Blockchains', + DESC: 'A tool for migrating your tokens between the Ethereum and the CUDOS blockchain. Allows ERC-20 holders to migrate to the native CUDOS token & stake.', KEYWORDS: SV.KEYWORDS, ROBOTS: 'noindex, nofollow', PAGE_URL: `${Config.URL.GENERAL}${CudosBridge.URL}`, From c06d9c6bedbc9392c4bc1f469611cf1967040588 Mon Sep 17 00:00:00 2001 From: ealeksandrov-LimeChain <92088769+ealeksandrov-LimeChain@users.noreply.github.com> Date: Fri, 4 Nov 2022 16:16:18 +0200 Subject: [PATCH 7/8] enable SE robots --- src/backend/requests/pages/general/cudos-bridge/CudosBridge.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/requests/pages/general/cudos-bridge/CudosBridge.ts b/src/backend/requests/pages/general/cudos-bridge/CudosBridge.ts index 6b07620..9f08e1b 100644 --- a/src/backend/requests/pages/general/cudos-bridge/CudosBridge.ts +++ b/src/backend/requests/pages/general/cudos-bridge/CudosBridge.ts @@ -19,7 +19,7 @@ export default class CudosBridge extends CudosBridgeH { TITLE: 'CUDOS Bridge | Migrate tokens between Blockchains', DESC: 'A tool for migrating your tokens between the Ethereum and the CUDOS blockchain. Allows ERC-20 holders to migrate to the native CUDOS token & stake.', KEYWORDS: SV.KEYWORDS, - ROBOTS: 'noindex, nofollow', + ROBOTS: 'all', PAGE_URL: `${Config.URL.GENERAL}${CudosBridge.URL}`, }, CSS: { From 14a1f164b9a9a5efb25cca3f5d2fa49e5f356f5f Mon Sep 17 00:00:00 2001 From: SpaghettiOverload Date: Thu, 17 Aug 2023 10:57:03 +0300 Subject: [PATCH 8/8] Ledger support and TS types --- .../common/js/models/ledgers/KeplrLedger.ts | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/frontend/resources/common/js/models/ledgers/KeplrLedger.ts b/src/frontend/resources/common/js/models/ledgers/KeplrLedger.ts index 33697a1..ec30cbb 100644 --- a/src/frontend/resources/common/js/models/ledgers/KeplrLedger.ts +++ b/src/frontend/resources/common/js/models/ledgers/KeplrLedger.ts @@ -8,6 +8,14 @@ import { EncodeObject } from 'cudosjs'; import BigNumber from 'bignumber.js'; import { GasPrice } from 'cudosjs'; +declare global { + interface Window { + keplr: any + getOfflineSignerAuto: any + meta: any + } +} + export default class KeplrLedger implements Ledger { @observable connected: number; @observable account: string; @@ -16,6 +24,7 @@ export default class KeplrLedger implements Ledger { @observable bridgeFee: BigNumber; @observable chainID: string; @observable rpcEndpoint: string; + @observable txNonce: string; queryClient: StargateClient static NETWORK_NAME = 'Cudos'; @@ -146,18 +155,18 @@ export default class KeplrLedger implements Ledger { } async disconnect(): Promise { - return new Promise < void >((resolve, reject) => { + return new Promise((resolve, reject) => { resolve(); }); } GetKeplrSignerAndAccount = async (): Promise<[OfflineSigner, AccountData]> => { - const offlineSigner = await window.getOfflineSigner(this.chainID); + const offlineSigner = await window.getOfflineSignerAuto(this.chainID); const account = (await offlineSigner.getAccounts())[0]; return [offlineSigner, account] } - GetKeplrSigningClient = async (offlineSigner:OfflineSigner): Promise < SigningStargateClient > => { + GetKeplrSigningClient = async (offlineSigner: OfflineSigner): Promise => { const client = await SigningStargateClient.connectWithSigner(this.rpcEndpoint, offlineSigner); return client } @@ -170,15 +179,15 @@ export default class KeplrLedger implements Ledger { this.walletError = null; try { - const coinAmount:Coin = coin( + const coinAmount: Coin = coin( amount.multipliedBy(CudosNetworkConsts.CURRENCY_1_CUDO).toString(10), CudosNetworkConsts.CURRENCY_DENOM, ) - const bridgeFeeAmount:Coin = coin( + const bridgeFeeAmount: Coin = coin( this.bridgeFee.toString(10), CudosNetworkConsts.CURRENCY_DENOM, ) - const gasPrice:GasPrice = GasPrice.fromString(`${Config.CUDOS_NETWORK.GAS_PRICE}acudos`) + const gasPrice: GasPrice = GasPrice.fromString(`${Config.CUDOS_NETWORK.GAS_PRICE}acudos`) const result = await client.gravitySendToEth( account.address, @@ -197,7 +206,7 @@ export default class KeplrLedger implements Ledger { } async EstimateFee(client: SigningStargateClient, sender: string, messages: EncodeObject[], gasPrice: GasPrice, - memo?:string, gasMultiplier?: number):Promise { + memo?: string, gasMultiplier?: number): Promise { const fee = await estimateFee(client, sender, messages, gasPrice, gasMultiplier, memo) return fee }