diff --git a/package-lock.json b/package-lock.json index 3e7e9507..db5007f2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,6 +25,7 @@ "react-rewards": "^2.0.4", "react-toastify": "^9.1.3", "sass": "^1.57.1", + "soroban-client": "^1.0.0-beta.2", "stellar-wallets-kit": "github:Creit-Tech/Stellar-Wallets-Kit" }, "devDependencies": { @@ -4003,6 +4004,47 @@ "soroban-client": "0.8.1" } }, + "node_modules/@soroban-react/chains/node_modules/js-xdr": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/js-xdr/-/js-xdr-2.0.0.tgz", + "integrity": "sha512-4mctWHR47ejNcfpE8/Xl3l2wYqO1Qy09d1pveZRmarUz2BcuU/M8grzadxV6PoN/X0ywOb6cy6117qYUWkfeBA==" + }, + "node_modules/@soroban-react/chains/node_modules/soroban-client": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/soroban-client/-/soroban-client-0.8.1.tgz", + "integrity": "sha512-F+3K+hHlpXbSSdBMjvTlkim1tb2aMlg4OT+71r1ILk8T+bMFHXlZShettJg2VMQ402WGalBNN4Q9oSeoHsPVFQ==", + "dependencies": { + "axios": "^1.4.0", + "bignumber.js": "^9.1.1", + "buffer": "^6.0.3", + "detect-node": "^2.0.4", + "es6-promise": "^4.2.4", + "eventsource": "^2.0.2", + "lodash": "^4.17.21", + "randombytes": "^2.1.0", + "stellar-base": "9.0.0-soroban.3", + "toml": "^3.0.0", + "urijs": "^1.19.1" + } + }, + "node_modules/@soroban-react/chains/node_modules/stellar-base": { + "version": "9.0.0-soroban.3", + "resolved": "https://registry.npmjs.org/stellar-base/-/stellar-base-9.0.0-soroban.3.tgz", + "integrity": "sha512-PaeIrspURhbDA0FSkH/mu/lQxxSYPplOdhIcW4VqmKW2kMm/ADXjyQr1y4tFIfv8EpIe5DCJ6sfIyadIoPd8HQ==", + "dependencies": { + "base32.js": "^0.1.0", + "bignumber.js": "^9.1.1", + "crc": "^4.3.2", + "crypto-browserify": "^3.12.0", + "js-xdr": "^2.0.0", + "lodash": "^4.17.21", + "sha.js": "^2.3.6", + "tweetnacl": "^1.0.3" + }, + "optionalDependencies": { + "sodium-native": "^4.0.1" + } + }, "node_modules/@soroban-react/core": { "version": "5.3.12", "resolved": "https://registry.npmjs.org/@soroban-react/core/-/core-5.3.12.tgz", @@ -4017,6 +4059,47 @@ "react": ">=16.8" } }, + "node_modules/@soroban-react/core/node_modules/js-xdr": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/js-xdr/-/js-xdr-2.0.0.tgz", + "integrity": "sha512-4mctWHR47ejNcfpE8/Xl3l2wYqO1Qy09d1pveZRmarUz2BcuU/M8grzadxV6PoN/X0ywOb6cy6117qYUWkfeBA==" + }, + "node_modules/@soroban-react/core/node_modules/soroban-client": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/soroban-client/-/soroban-client-0.8.1.tgz", + "integrity": "sha512-F+3K+hHlpXbSSdBMjvTlkim1tb2aMlg4OT+71r1ILk8T+bMFHXlZShettJg2VMQ402WGalBNN4Q9oSeoHsPVFQ==", + "dependencies": { + "axios": "^1.4.0", + "bignumber.js": "^9.1.1", + "buffer": "^6.0.3", + "detect-node": "^2.0.4", + "es6-promise": "^4.2.4", + "eventsource": "^2.0.2", + "lodash": "^4.17.21", + "randombytes": "^2.1.0", + "stellar-base": "9.0.0-soroban.3", + "toml": "^3.0.0", + "urijs": "^1.19.1" + } + }, + "node_modules/@soroban-react/core/node_modules/stellar-base": { + "version": "9.0.0-soroban.3", + "resolved": "https://registry.npmjs.org/stellar-base/-/stellar-base-9.0.0-soroban.3.tgz", + "integrity": "sha512-PaeIrspURhbDA0FSkH/mu/lQxxSYPplOdhIcW4VqmKW2kMm/ADXjyQr1y4tFIfv8EpIe5DCJ6sfIyadIoPd8HQ==", + "dependencies": { + "base32.js": "^0.1.0", + "bignumber.js": "^9.1.1", + "crc": "^4.3.2", + "crypto-browserify": "^3.12.0", + "js-xdr": "^2.0.0", + "lodash": "^4.17.21", + "sha.js": "^2.3.6", + "tweetnacl": "^1.0.3" + }, + "optionalDependencies": { + "sodium-native": "^4.0.1" + } + }, "node_modules/@soroban-react/events": { "version": "5.3.12", "resolved": "https://registry.npmjs.org/@soroban-react/events/-/events-5.3.12.tgz", @@ -4031,6 +4114,47 @@ "react": ">=16.8" } }, + "node_modules/@soroban-react/events/node_modules/js-xdr": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/js-xdr/-/js-xdr-2.0.0.tgz", + "integrity": "sha512-4mctWHR47ejNcfpE8/Xl3l2wYqO1Qy09d1pveZRmarUz2BcuU/M8grzadxV6PoN/X0ywOb6cy6117qYUWkfeBA==" + }, + "node_modules/@soroban-react/events/node_modules/soroban-client": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/soroban-client/-/soroban-client-0.8.1.tgz", + "integrity": "sha512-F+3K+hHlpXbSSdBMjvTlkim1tb2aMlg4OT+71r1ILk8T+bMFHXlZShettJg2VMQ402WGalBNN4Q9oSeoHsPVFQ==", + "dependencies": { + "axios": "^1.4.0", + "bignumber.js": "^9.1.1", + "buffer": "^6.0.3", + "detect-node": "^2.0.4", + "es6-promise": "^4.2.4", + "eventsource": "^2.0.2", + "lodash": "^4.17.21", + "randombytes": "^2.1.0", + "stellar-base": "9.0.0-soroban.3", + "toml": "^3.0.0", + "urijs": "^1.19.1" + } + }, + "node_modules/@soroban-react/events/node_modules/stellar-base": { + "version": "9.0.0-soroban.3", + "resolved": "https://registry.npmjs.org/stellar-base/-/stellar-base-9.0.0-soroban.3.tgz", + "integrity": "sha512-PaeIrspURhbDA0FSkH/mu/lQxxSYPplOdhIcW4VqmKW2kMm/ADXjyQr1y4tFIfv8EpIe5DCJ6sfIyadIoPd8HQ==", + "dependencies": { + "base32.js": "^0.1.0", + "bignumber.js": "^9.1.1", + "crc": "^4.3.2", + "crypto-browserify": "^3.12.0", + "js-xdr": "^2.0.0", + "lodash": "^4.17.21", + "sha.js": "^2.3.6", + "tweetnacl": "^1.0.3" + }, + "optionalDependencies": { + "sodium-native": "^4.0.1" + } + }, "node_modules/@soroban-react/freighter": { "version": "5.3.12", "resolved": "https://registry.npmjs.org/@soroban-react/freighter/-/freighter-5.3.12.tgz", @@ -6189,7 +6313,6 @@ "version": "5.4.1", "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-5.4.1.tgz", "integrity": "sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA==", - "license": "MIT", "dependencies": { "bn.js": "^4.0.0", "inherits": "^2.0.1", @@ -6197,6 +6320,11 @@ "safer-buffer": "^2.1.0" } }, + "node_modules/asn1.js/node_modules/bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" + }, "node_modules/ast-types-flow": { "version": "0.0.7", "resolved": "https://registry.npmjs.org/ast-types-flow/-/ast-types-flow-0.0.7.tgz", @@ -6481,7 +6609,6 @@ "version": "0.1.0", "resolved": "https://registry.npmjs.org/base32.js/-/base32.js-0.1.0.tgz", "integrity": "sha512-n3TkB02ixgBOhTvANakDb4xaMXnYUVkNoRFJjQflcqMQhyEKxEHdj3E6N8t8sUQ0mjH/3/JxzlXuz3ul/J90pQ==", - "license": "MIT", "engines": { "node": ">=0.12.0" } @@ -6503,8 +6630,7 @@ "type": "consulting", "url": "https://feross.org/support" } - ], - "license": "MIT" + ] }, "node_modules/batch": { "version": "0.6.1", @@ -6522,10 +6648,9 @@ } }, "node_modules/bignumber.js": { - "version": "9.1.1", - "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.1.tgz", - "integrity": "sha512-pHm4LsMJ6lzgNGVfZHjMoO8sdoRhOzOH4MLmY65Jg70bpxCKu5iOHNJyfF6OyvYw7t8Fpf35RuzUyqnQsj8Vig==", - "license": "MIT", + "version": "9.1.2", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.2.tgz", + "integrity": "sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug==", "engines": { "node": "*" } @@ -6540,10 +6665,9 @@ } }, "node_modules/bn.js": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", - "license": "MIT" + "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/body-parser": { "version": "1.20.1", @@ -6726,14 +6850,12 @@ "node_modules/brorand": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", - "integrity": "sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==", - "license": "MIT" + "integrity": "sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==" }, "node_modules/browserify-aes": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", - "license": "MIT", "dependencies": { "buffer-xor": "^1.0.3", "cipher-base": "^1.0.0", @@ -6747,7 +6869,6 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.1.tgz", "integrity": "sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==", - "license": "MIT", "dependencies": { "browserify-aes": "^1.0.4", "browserify-des": "^1.0.0", @@ -6758,7 +6879,6 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.2.tgz", "integrity": "sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A==", - "license": "MIT", "dependencies": { "cipher-base": "^1.0.1", "des.js": "^1.0.0", @@ -6770,23 +6890,15 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.1.0.tgz", "integrity": "sha512-AdEER0Hkspgno2aR97SAf6vi0y0k8NuOpGnVH3O99rcA5Q6sh8QxcngtHuJ6uXwnfAXNM4Gn1Gb7/MV1+Ymbog==", - "license": "MIT", "dependencies": { "bn.js": "^5.0.0", "randombytes": "^2.0.1" } }, - "node_modules/browserify-rsa/node_modules/bn.js": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", - "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==", - "license": "MIT" - }, "node_modules/browserify-sign": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.2.1.tgz", "integrity": "sha512-/vrA5fguVAKKAVTNJjgSm1tRQDHUU6DbwO9IROu/0WAzC8PKhucDSh18J0RMvVeHAn5puMd+QHC2erPRNf8lmg==", - "license": "ISC", "dependencies": { "bn.js": "^5.1.1", "browserify-rsa": "^4.0.1", @@ -6799,12 +6911,6 @@ "safe-buffer": "^5.2.0" } }, - "node_modules/browserify-sign/node_modules/bn.js": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", - "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==", - "license": "MIT" - }, "node_modules/browserslist": { "version": "4.21.9", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.9.tgz", @@ -6888,8 +6994,7 @@ "node_modules/buffer-xor": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", - "integrity": "sha512-571s0T7nZWK6vB67HI5dyUF7wXiNcfaPPPTl6zYCNApANjIvYJTg7hlud/+cJpdAhS7dVzqMLmfhfHR3rAcOjQ==", - "license": "MIT" + "integrity": "sha512-571s0T7nZWK6vB67HI5dyUF7wXiNcfaPPPTl6zYCNApANjIvYJTg7hlud/+cJpdAhS7dVzqMLmfhfHR3rAcOjQ==" }, "node_modules/builtin-modules": { "version": "3.3.0", @@ -7225,7 +7330,6 @@ "version": "1.0.4", "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", "integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==", - "license": "MIT", "dependencies": { "inherits": "^2.0.1", "safe-buffer": "^5.0.1" @@ -7879,7 +7983,6 @@ "version": "4.3.2", "resolved": "https://registry.npmjs.org/crc/-/crc-4.3.2.tgz", "integrity": "sha512-uGDHf4KLLh2zsHa8D8hIQ1H/HtFQhyHrc0uhHBcoKGol/Xnb+MPYfUMw7cvON6ze/GUESTudKayDcJC5HnJv1A==", - "license": "MIT", "engines": { "node": ">=12" }, @@ -7896,17 +7999,20 @@ "version": "4.0.4", "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.4.tgz", "integrity": "sha512-mf+TCx8wWc9VpuxfP2ht0iSISLZnt0JgWlrOKZiNqyUZWnjIaCIVNQArMHnCZKfEYRg6IM7A+NeJoN8gf/Ws0A==", - "license": "MIT", "dependencies": { "bn.js": "^4.1.0", "elliptic": "^6.5.3" } }, + "node_modules/create-ecdh/node_modules/bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" + }, "node_modules/create-hash": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", - "license": "MIT", "dependencies": { "cipher-base": "^1.0.1", "inherits": "^2.0.1", @@ -7919,7 +8025,6 @@ "version": "1.1.7", "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", - "license": "MIT", "dependencies": { "cipher-base": "^1.0.3", "create-hash": "^1.1.0", @@ -7956,7 +8061,6 @@ "version": "3.12.0", "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", "integrity": "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==", - "license": "MIT", "dependencies": { "browserify-cipher": "^1.0.0", "browserify-sign": "^4.0.0", @@ -9097,7 +9201,6 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.1.0.tgz", "integrity": "sha512-r17GxjhUCjSRy8aiJpr8/UadFIzMzJGexI3Nmz4ADi9LYSFx4gTBp80+NaX/YsXWWLhpZ7v/v/ubEc/bCNfKwg==", - "license": "MIT", "dependencies": { "inherits": "^2.0.1", "minimalistic-assert": "^1.0.0" @@ -9197,13 +9300,17 @@ "version": "5.0.3", "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", - "license": "MIT", "dependencies": { "bn.js": "^4.1.0", "miller-rabin": "^4.0.0", "randombytes": "^2.0.0" } }, + "node_modules/diffie-hellman/node_modules/bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" + }, "node_modules/dijkstrajs": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/dijkstrajs/-/dijkstrajs-1.0.3.tgz", @@ -9417,7 +9524,6 @@ "version": "6.5.4", "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", "integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", - "license": "MIT", "dependencies": { "bn.js": "^4.11.9", "brorand": "^1.1.0", @@ -9428,6 +9534,11 @@ "minimalistic-crypto-utils": "^1.0.1" } }, + "node_modules/elliptic/node_modules/bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" + }, "node_modules/emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", @@ -9611,8 +9722,7 @@ "node_modules/es6-promise": { "version": "4.2.8", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", - "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==", - "license": "MIT" + "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==" }, "node_modules/escalade": { "version": "3.1.1", @@ -10293,7 +10403,6 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/eventsource/-/eventsource-2.0.2.tgz", "integrity": "sha512-IzUmBGPR3+oUG9dUeXynyNmf91/3zUSJg1lCktzKw47OXuhco54U3r9B7O4XX+Rb1Itm9OZ2b0RkTs10bICOxA==", - "license": "MIT", "engines": { "node": ">=12.0.0" } @@ -10302,7 +10411,6 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", - "license": "MIT", "dependencies": { "md5.js": "^1.3.4", "safe-buffer": "^5.1.1" @@ -11471,7 +11579,6 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.1.0.tgz", "integrity": "sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA==", - "license": "MIT", "dependencies": { "inherits": "^2.0.4", "readable-stream": "^3.6.0", @@ -11485,7 +11592,6 @@ "version": "1.1.7", "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", - "license": "MIT", "dependencies": { "inherits": "^2.0.3", "minimalistic-assert": "^1.0.1" @@ -11719,7 +11825,6 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", "integrity": "sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==", - "license": "MIT", "dependencies": { "hash.js": "^1.0.3", "minimalistic-assert": "^1.0.0", @@ -12027,8 +12132,7 @@ "type": "consulting", "url": "https://feross.org/support" } - ], - "license": "BSD-3-Clause" + ] }, "node_modules/ignore": { "version": "5.2.4", @@ -12856,10 +12960,9 @@ "license": "MIT" }, "node_modules/js-xdr": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/js-xdr/-/js-xdr-2.0.0.tgz", - "integrity": "sha512-4mctWHR47ejNcfpE8/Xl3l2wYqO1Qy09d1pveZRmarUz2BcuU/M8grzadxV6PoN/X0ywOb6cy6117qYUWkfeBA==", - "license": "Apache-2.0" + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/js-xdr/-/js-xdr-3.0.0.tgz", + "integrity": "sha512-tSt6UKJ2L7t+yaQURGkHo9kop9qnVbChTlCu62zNiDbDZQoZb/YjUj2iFJ3lgelhfg9p5bhO2o/QX+g36TPsSQ==" }, "node_modules/js-yaml": { "version": "4.1.0", @@ -13308,7 +13411,6 @@ "version": "1.3.5", "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", "integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==", - "license": "MIT", "dependencies": { "hash-base": "^3.0.0", "inherits": "^2.0.1", @@ -14123,7 +14225,6 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz", "integrity": "sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==", - "license": "MIT", "dependencies": { "bn.js": "^4.0.0", "brorand": "^1.0.1" @@ -14132,6 +14233,11 @@ "miller-rabin": "bin/miller-rabin" } }, + "node_modules/miller-rabin/node_modules/bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" + }, "node_modules/mime": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", @@ -14281,8 +14387,7 @@ "node_modules/minimalistic-crypto-utils": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", - "integrity": "sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==", - "license": "MIT" + "integrity": "sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==" }, "node_modules/minimatch": { "version": "3.1.2", @@ -14464,10 +14569,9 @@ } }, "node_modules/node-gyp-build": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.6.0.tgz", - "integrity": "sha512-NTZVKn9IylLwUzaKjkas1e4u2DLNcV4rdYagA4PWdPwW87Bi7z+BznyKSRwS/761tV/lzCGXplWsiaMjLqP2zQ==", - "license": "MIT", + "version": "4.6.1", + "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.6.1.tgz", + "integrity": "sha512-24vnklJmyRS8ViBNI8KbtK/r/DmXQMRiOMXTNz2nrTnAYUwjmEEbnnpB/+kt+yWRv73bPsSPRFddrcIbAxSiMQ==", "optional": true, "bin": { "node-gyp-build": "bin.js", @@ -14915,7 +15019,6 @@ "version": "5.1.6", "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.6.tgz", "integrity": "sha512-RnZRo1EPU6JBnra2vGHj0yhp6ebyjBZpmUCLHWiFhxlzvBCCpAuZ7elsBp1PVAbQN0/04VD/19rfzlBSwLstMw==", - "license": "ISC", "dependencies": { "asn1.js": "^5.2.0", "browserify-aes": "^1.0.0", @@ -15095,7 +15198,6 @@ "version": "3.1.2", "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.1.2.tgz", "integrity": "sha512-iuh7L6jA7JEGu2WxDwtQP1ddOpaJNC4KlDEFfdQajSGgGPNi4OyDc2R7QnbY2bR9QjBVGwgvTdNJZoE7RaxUMA==", - "license": "MIT", "dependencies": { "create-hash": "^1.1.2", "create-hmac": "^1.1.4", @@ -16111,7 +16213,6 @@ "version": "4.0.3", "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.3.tgz", "integrity": "sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q==", - "license": "MIT", "dependencies": { "bn.js": "^4.1.0", "browserify-rsa": "^4.0.0", @@ -16121,6 +16222,11 @@ "safe-buffer": "^5.1.2" } }, + "node_modules/public-encrypt/node_modules/bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" + }, "node_modules/pump": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", @@ -16285,7 +16391,6 @@ "version": "1.0.4", "resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz", "integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==", - "license": "MIT", "dependencies": { "randombytes": "^2.0.5", "safe-buffer": "^5.1.0" @@ -17353,7 +17458,6 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz", "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", - "license": "MIT", "dependencies": { "hash-base": "^3.0.0", "inherits": "^2.0.1" @@ -17907,7 +18011,6 @@ "version": "2.4.11", "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", - "license": "(MIT AND BSD-3-Clause)", "dependencies": { "inherits": "^2.0.1", "safe-buffer": "^5.0.1" @@ -18080,7 +18183,6 @@ "resolved": "https://registry.npmjs.org/sodium-native/-/sodium-native-4.0.4.tgz", "integrity": "sha512-faqOKw4WQKK7r/ybn6Lqo1F9+L5T6NlBJJYvpxbZPetpWylUVqz449mvlwIBKBqxEHbWakWuOlUt8J3Qpc4sWw==", "hasInstallScript": true, - "license": "MIT", "optional": true, "dependencies": { "node-gyp-build": "^4.6.0" @@ -18095,21 +18197,14 @@ } }, "node_modules/soroban-client": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/soroban-client/-/soroban-client-0.8.1.tgz", - "integrity": "sha512-F+3K+hHlpXbSSdBMjvTlkim1tb2aMlg4OT+71r1ILk8T+bMFHXlZShettJg2VMQ402WGalBNN4Q9oSeoHsPVFQ==", - "license": "Apache-2.0", + "version": "1.0.0-beta.2", + "resolved": "https://registry.npmjs.org/soroban-client/-/soroban-client-1.0.0-beta.2.tgz", + "integrity": "sha512-v5h3yvef7HkUD3H26w33NUEgRXcPiOSDWEsVzMloaxsprs3N002tXJHvFF+Uw1eYt50Uk6bvqBgvkLwX10VENw==", "dependencies": { "axios": "^1.4.0", "bignumber.js": "^9.1.1", "buffer": "^6.0.3", - "detect-node": "^2.0.4", - "es6-promise": "^4.2.4", - "eventsource": "^2.0.2", - "lodash": "^4.17.21", - "randombytes": "^2.1.0", - "stellar-base": "9.0.0-soroban.3", - "toml": "^3.0.0", + "stellar-base": "v10.0.0-beta.1", "urijs": "^1.19.1" } }, @@ -18302,17 +18397,14 @@ "license": "MIT" }, "node_modules/stellar-base": { - "version": "9.0.0-soroban.3", - "resolved": "https://registry.npmjs.org/stellar-base/-/stellar-base-9.0.0-soroban.3.tgz", - "integrity": "sha512-PaeIrspURhbDA0FSkH/mu/lQxxSYPplOdhIcW4VqmKW2kMm/ADXjyQr1y4tFIfv8EpIe5DCJ6sfIyadIoPd8HQ==", - "license": "Apache-2.0", + "version": "10.0.0-beta.1", + "resolved": "https://registry.npmjs.org/stellar-base/-/stellar-base-10.0.0-beta.1.tgz", + "integrity": "sha512-zXC5AsbUsLi57JruyeIMv23s3iUxq/P2ZFrSJ+FerLIZjSAjY8EDs4zwY4LCuu7swUu46Lm8GK6sqxUZCPekHw==", "dependencies": { "base32.js": "^0.1.0", - "bignumber.js": "^9.1.1", - "crc": "^4.3.2", - "crypto-browserify": "^3.12.0", - "js-xdr": "^2.0.0", - "lodash": "^4.17.21", + "bignumber.js": "^9.1.2", + "buffer": "^6.0.3", + "js-xdr": "^3.0.0", "sha.js": "^2.3.6", "tweetnacl": "^1.0.3" }, @@ -18790,8 +18882,7 @@ "node_modules/toml": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/toml/-/toml-3.0.0.tgz", - "integrity": "sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==", - "license": "MIT" + "integrity": "sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==" }, "node_modules/totalist": { "version": "1.1.0", @@ -18900,8 +18991,7 @@ "node_modules/tweetnacl": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz", - "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==", - "license": "Unlicense" + "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==" }, "node_modules/tweetnacl-util": { "version": "0.15.1", diff --git a/package.json b/package.json index 1cfc064d..e1cf2bac 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "react-rewards": "^2.0.4", "react-toastify": "^9.1.3", "sass": "^1.57.1", + "soroban-client": "^1.0.0-beta.2", "stellar-wallets-kit": "github:Creit-Tech/Stellar-Wallets-Kit" }, "browserslist": { diff --git a/src/components/atoms/challenge-contract-form/index.tsx b/src/components/atoms/challenge-contract-form/index.tsx index dcf19293..7412abe2 100644 --- a/src/components/atoms/challenge-contract-form/index.tsx +++ b/src/components/atoms/challenge-contract-form/index.tsx @@ -30,8 +30,6 @@ function ChallengeContractForm({ address, id }: ChallengeFormProps) { ); const isSubmitBtnDisabled = !contractId || savedContractId === contractId; - // TODO add logic with TVL based on contractId here - useEffect(() => { if (address) { const challenge = getActiveChallenge(data, id); diff --git a/src/components/atoms/challenges-list/index.tsx b/src/components/atoms/challenges-list/index.tsx index 03b3001d..2c449d6d 100644 --- a/src/components/atoms/challenges-list/index.tsx +++ b/src/components/atoms/challenges-list/index.tsx @@ -3,19 +3,31 @@ import styles from "./style.module.css"; import { Challenge, ChallengeInfo } from "../../../interfaces/challenge"; import { ChallengeCard } from "../challenge-card"; import Switcher from "../UI/switcher"; +import ConfirmModal from "../confirm-modal"; interface Props { availableChallenges: Challenge[]; userChallenges: ChallengeInfo[]; onRefresh: () => void; + onReset?: () => void; } export default function ChallengeList({ availableChallenges, userChallenges, onRefresh, + onReset, }: Props) { const [onlyMine, setOnlyMine] = useState(false); + const [confirmReset, setConfirmReset] = useState(false); + + const onResetClick = () => { + setConfirmReset(true); + }; + + const onCancelClick = () => { + setConfirmReset(false); + }; const myChallanges = ( <> @@ -53,21 +65,32 @@ export default function ChallengeList({ return ( <>
- {userChallenges?.length > 0 ? ( - setOnlyMine(value)} - /> - ) : null} - +
+ {userChallenges?.length > 0 ? ( + setOnlyMine(value)} + /> + ) : null} + +
+ {onReset && ( + + )}
+ + {confirmReset && onReset && ( + + )} ); } diff --git a/src/components/atoms/challenges-list/style.module.css b/src/components/atoms/challenges-list/style.module.css index 834b6e61..498a033f 100644 --- a/src/components/atoms/challenges-list/style.module.css +++ b/src/components/atoms/challenges-list/style.module.css @@ -14,6 +14,11 @@ .listHeader { display: flex; + justify-content: space-between; +} + +.dataControls { + display: flex; } .refreshBtn { @@ -21,9 +26,23 @@ font-weight: 500; font-family: var(--ifm-font-family-base); background-color: transparent; - color: #369EA7; + color: #369ea7; border-radius: 4px; - border: 1px solid #369EA7; + border: 1px solid #369ea7; + padding: 12px 8px; + line-height: 0.8; + width: max-content; + cursor: pointer; +} + +.resetBtn { + font-size: 14px; + font-weight: 500; + font-family: var(--ifm-font-family-base); + background-color: transparent; + color: #df0101; + border-radius: 4px; + border: 1px solid #df0101; padding: 12px 8px; line-height: 0.8; width: max-content; @@ -32,4 +51,4 @@ div + .refreshBtn { margin-left: 20px; -} \ No newline at end of file +} diff --git a/src/components/atoms/complete-step-button/index.tsx b/src/components/atoms/complete-step-button/index.tsx index 02881025..0754ff66 100644 --- a/src/components/atoms/complete-step-button/index.tsx +++ b/src/components/atoms/complete-step-button/index.tsx @@ -19,6 +19,7 @@ import { UpdateProgressData, } from "../../../interfaces/challenge"; import { updateUserProgress } from "../../../services/challenges"; +import { getContractBalance } from "../../../utils/get-contract-balance"; interface CompleteStepButtonState { isCompleted: boolean; @@ -143,6 +144,7 @@ export default function CompleteStepButton({ completedAt: Date.now(), startDate: challenge?.startDate, contractId: challenge?.contractId, + totalValueLocked: challenge?.totalValueLocked, }); showToast(challenge?.isPullRequestRequired ? passedToast : completedToast); @@ -155,6 +157,49 @@ export default function CompleteStepButton({ return; } + let balance = 0; + + // if funding step => get contract balance + if (progress === 2) { + if (challenge?.contractId) { + try { + const result = await getContractBalance( + challenge?.contractId, + address, + ); + if (!result) { + toast("No locked balance found!", { + type: "error", + hideProgressBar: true, + position: "top-center", + autoClose: 2000, + }); + + return; + } + + balance = result; + } catch (error) { + console.error(error); + + toast("No locked balance found!", { + type: "error", + hideProgressBar: true, + position: "top-center", + autoClose: 2000, + }); + return; + } + } else { + toast("No contract id found!", { + type: "error", + hideProgressBar: true, + position: "top-center", + autoClose: 2000, + }); + } + } + setState((prevState: CompleteStepButtonState) => { return { ...prevState, @@ -168,6 +213,7 @@ export default function CompleteStepButton({ challengeProgress: progress, startDate: challenge?.startDate, contractId: challenge?.contractId || contractId, + totalValueLocked: challenge?.totalValueLocked || balance, }); showToast(milestoneToast); diff --git a/src/components/atoms/confirm-modal/index.tsx b/src/components/atoms/confirm-modal/index.tsx new file mode 100644 index 00000000..d55d0c1b --- /dev/null +++ b/src/components/atoms/confirm-modal/index.tsx @@ -0,0 +1,28 @@ +import React from "react"; +import styles from "./style.module.css"; + +interface Props { + onCancel: () => void; + onReset: () => void; +} + +export default function ConfirmModal({ onCancel, onReset }: Props) { + return ( + <> +
+
+

Reseting progress!

+ It may take up to minute!
+ Are you sure you want to continue? +
+ + +
+
+ + ); +} diff --git a/src/components/atoms/confirm-modal/style.module.css b/src/components/atoms/confirm-modal/style.module.css new file mode 100644 index 00000000..d855ac2c --- /dev/null +++ b/src/components/atoms/confirm-modal/style.module.css @@ -0,0 +1,63 @@ +.blurContainer { + position: absolute; + height: 100vh; + width: 100vw; + overflow: hidden; + top: 0; + left: 0; + background: rgba(0, 0, 0, 0.7); + z-index: 1000; +} + +.modalContainer { + position: absolute; + width: 350px; + height: 200px; + top: calc(50% - 100px); + left: calc(50% - 175px); + background-color: #ffffff; + padding: 20px; + border-radius: 8px; + text-align: center; + z-index: 1001; +} + +.title { + font-size: 18px; + font-weight: 600; +} + +.buttons { + margin-top: 20px; + display: flex; + justify-content: center; + gap: 20px; +} + +.cancelBtn { + font-size: 14px; + font-weight: 500; + font-family: var(--ifm-font-family-base); + background-color: transparent; + color: #369ea7; + border-radius: 4px; + border: 1px solid #369ea7; + padding: 12px 8px; + line-height: 0.8; + width: max-content; + cursor: pointer; +} + +.resetBtn { + font-size: 14px; + font-weight: 500; + font-family: var(--ifm-font-family-base); + background-color: transparent; + color: #df0101; + border-radius: 4px; + border: 1px solid #df0101; + padding: 12px 8px; + line-height: 0.8; + width: max-content; + cursor: pointer; +} diff --git a/src/components/molecules/leaderboard/index.tsx b/src/components/molecules/leaderboard/index.tsx index a80c4ef9..1b96cb51 100644 --- a/src/components/molecules/leaderboard/index.tsx +++ b/src/components/molecules/leaderboard/index.tsx @@ -24,7 +24,7 @@ const Leaderboard: React.FC = ({ userId, list, onColumnClick }) => { setAsc(col === val ? !asc : false); onColumnClick({ colName: val, - direction: nextAsc ? "asc" : "desc", + direction: nextAsc ? "desc" : "asc", }); setCol(val); }; diff --git a/src/contants.ts b/src/contants.ts new file mode 100644 index 00000000..151a50c7 --- /dev/null +++ b/src/contants.ts @@ -0,0 +1,5 @@ +export const FUTURENET_DETAILS = { + network: "FUTURENET", + networkUrl: "https://horizon-futurenet.stellar.org", + networkPassphrase: "Test SDF Future Network ; October 2022", +}; diff --git a/src/hooks/useAuth.tsx b/src/hooks/useAuth.tsx index eec0ac06..2f78c00d 100644 --- a/src/hooks/useAuth.tsx +++ b/src/hooks/useAuth.tsx @@ -11,12 +11,7 @@ import { toast } from "react-toastify"; import UserChallengesContext, { UserChallengesContextProps, } from "../store/user-challenges-context"; - -export const FUTURENET_DETAILS = { - network: "FUTURENET", - networkUrl: "https://horizon-futurenet.stellar.org", - networkPassphrase: "Test SDF Future Network ; October 2022", -}; +import { FUTURENET_DETAILS } from "../contants"; const useAuth = () => { const { address, setAddress } = useContext( diff --git a/src/interfaces/challenge.ts b/src/interfaces/challenge.ts index 1f648f52..53788d89 100644 --- a/src/interfaces/challenge.ts +++ b/src/interfaces/challenge.ts @@ -11,6 +11,7 @@ export interface UpdateProgressData { startDate?: number; completedAt?: number; contractId?: string; + totalValueLocked?: number; } export interface Ranking { @@ -40,6 +41,7 @@ export interface ChallengeInfo extends Challenge { startDate?: number; completedAt?: number; isCompleted?: boolean; + totalValueLocked?: number; } export interface UserProgress { diff --git a/src/pages/dashboard/index.tsx b/src/pages/dashboard/index.tsx index 22c07419..8e43fa7b 100644 --- a/src/pages/dashboard/index.tsx +++ b/src/pages/dashboard/index.tsx @@ -11,6 +11,7 @@ import styles from "./style.module.css"; import { fetchInitialChallenges, fetchUserProgress, + resetUserProgress, } from "../../services/challenges"; import useAuth from "../../hooks/useAuth"; import DashboardHeader from "../../components/atoms/dashboard-header"; @@ -43,7 +44,7 @@ export default function Dashboard() { setTotalCompleted(result.data?.completedChallenges || 0); setRanking(result.data?.ranking || null); } catch (e) { - toast("Sometning went wrong! Please reload", { + toast("Something went wrong! Please reload", { type: "error", hideProgressBar: true, position: "top-center", @@ -59,7 +60,7 @@ export default function Dashboard() { const result = await fetchLeaderboard(params); setLeaderboard(result?.data); } catch (e) { - toast("Sometning went wrong! Please reload", { + toast("Something went wrong! Please reload", { type: "error", hideProgressBar: true, position: "top-center", @@ -68,6 +69,22 @@ export default function Dashboard() { } }; + const onReset = async () => { + try { + setIsLoading(true); + await resetUserProgress(address); + } catch (error) { + toast("Something went wrong! Please try again", { + type: "error", + hideProgressBar: true, + position: "top-center", + autoClose: 2000, + }); + } finally { + setIsLoading(false); + } + }; + useEffect(() => { const fetchData = async () => { try { @@ -101,7 +118,7 @@ export default function Dashboard() { setIsLoading(false); } catch (error) { setIsLoading(false); - toast("Sometning went wrong! Please reload", { + toast("Something went wrong! Please reload", { type: "error", hideProgressBar: true, position: "top-center", @@ -129,6 +146,7 @@ export default function Dashboard() { availableChallenges={availableChallenges} userChallenges={userChallenges} onRefresh={fetchUserChallenges} + {...(userChallenges.length ? { onReset } : {})} /> diff --git a/src/services/challenges.ts b/src/services/challenges.ts index 768669d0..1a86b61a 100644 --- a/src/services/challenges.ts +++ b/src/services/challenges.ts @@ -20,6 +20,12 @@ export const fetchUserProgress = async (userId: string) => { }); }; +export const resetUserProgress = async (userId: string) => { + return await httpClient.delete("/users", { + params: { userId }, + }); +}; + export const updateUserProgress = async (challenge: UpdateProgressData) => { return await httpClient.post< Partial, diff --git a/src/utils/get-contract-balance.ts b/src/utils/get-contract-balance.ts new file mode 100644 index 00000000..632d4a73 --- /dev/null +++ b/src/utils/get-contract-balance.ts @@ -0,0 +1,50 @@ +import { + Contract, + scValToBigInt, + Server, + TransactionBuilder, + TimeoutInfinite, + Address, +} from "soroban-client"; +import { FUTURENET_DETAILS } from "../contants"; + +const XLM_DECIMALS = 7; + +const BASE_FEE = "100"; +const RPC_URLS: { [key: string]: string } = { + FUTURENET: "https://rpc-futurenet.stellar.org/", +}; +const server = new Server(RPC_URLS[FUTURENET_DETAILS.network]); + +function formatAmount( + undivided: bigint, + decimals?: number = XLM_DECIMALS, +): string { + const n = + undivided.valueOf() < BigInt(Number.MAX_SAFE_INTEGER) + ? Number(undivided) / 10 ** decimals + : undivided.valueOf() / 10n ** BigInt(decimals); + return String(n); +} + +export const getContractBalance = async ( + contractId: string, + address: string, +): Promise => { + const account = await server.getAccount(address); + const contract = new Contract(contractId); + const params = [new Address(address).toScVal()]; + + const transaction = new TransactionBuilder(account, { + fee: BASE_FEE, + networkPassphrase: FUTURENET_DETAILS.networkPassphrase, + }) + .addOperation(contract.call("balance", ...params)) + .setTimeout(TimeoutInfinite) + .build(); + + const response = await server.simulateTransaction(transaction); + + const balanceStr = formatAmount(scValToBigInt(response.result.retval)); + return +balanceStr; +}; diff --git a/yarn.lock b/yarn.lock index 982320a4..61dbf605 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3719,27 +3719,32 @@ big.js@^5.2.2: resolved "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz" integrity sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ== -bignumber.js@^9.1.1: - version "9.1.1" - resolved "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.1.tgz" - integrity sha512-pHm4LsMJ6lzgNGVfZHjMoO8sdoRhOzOH4MLmY65Jg70bpxCKu5iOHNJyfF6OyvYw7t8Fpf35RuzUyqnQsj8Vig== +bignumber.js@^9.1.1, bignumber.js@^9.1.2: + version "9.1.2" + resolved "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.2.tgz" + integrity sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug== binary-extensions@^2.0.0: version "2.2.0" resolved "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz" integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== -bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.11.9: +bn.js@^4.0.0: version "4.12.0" resolved "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz" integrity sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA== -bn.js@^5.0.0: - version "5.2.1" - resolved "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz" - integrity sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ== +bn.js@^4.1.0: + version "4.12.0" + resolved "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz" + integrity sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA== -bn.js@^5.1.1: +bn.js@^4.11.9: + version "4.12.0" + resolved "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz" + integrity sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA== + +bn.js@^5.0.0, bn.js@^5.1.1: version "5.2.1" resolved "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz" integrity sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ== @@ -7297,6 +7302,11 @@ js-xdr@^2.0.0: resolved "https://registry.npmjs.org/js-xdr/-/js-xdr-2.0.0.tgz" integrity sha512-4mctWHR47ejNcfpE8/Xl3l2wYqO1Qy09d1pveZRmarUz2BcuU/M8grzadxV6PoN/X0ywOb6cy6117qYUWkfeBA== +js-xdr@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/js-xdr/-/js-xdr-3.0.0.tgz" + integrity sha512-tSt6UKJ2L7t+yaQURGkHo9kop9qnVbChTlCu62zNiDbDZQoZb/YjUj2iFJ3lgelhfg9p5bhO2o/QX+g36TPsSQ== + js-yaml@^3.13.1: version "3.14.1" resolved "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz" @@ -8244,9 +8254,9 @@ node-forge@^1: integrity sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA== node-gyp-build@^4.6.0: - version "4.6.0" - resolved "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.6.0.tgz" - integrity sha512-NTZVKn9IylLwUzaKjkas1e4u2DLNcV4rdYagA4PWdPwW87Bi7z+BznyKSRwS/761tV/lzCGXplWsiaMjLqP2zQ== + version "4.6.1" + resolved "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.6.1.tgz" + integrity sha512-24vnklJmyRS8ViBNI8KbtK/r/DmXQMRiOMXTNz2nrTnAYUwjmEEbnnpB/+kt+yWRv73bPsSPRFddrcIbAxSiMQ== node-releases@^2.0.12: version "2.0.13" @@ -10223,6 +10233,17 @@ sonic-boom@^2.2.1: dependencies: atomic-sleep "^1.0.0" +soroban-client@^1.0.0-beta.2: + version "1.0.0-beta.2" + resolved "https://registry.npmjs.org/soroban-client/-/soroban-client-1.0.0-beta.2.tgz" + integrity sha512-v5h3yvef7HkUD3H26w33NUEgRXcPiOSDWEsVzMloaxsprs3N002tXJHvFF+Uw1eYt50Uk6bvqBgvkLwX10VENw== + dependencies: + axios "^1.4.0" + bignumber.js "^9.1.1" + buffer "^6.0.3" + stellar-base v10.0.0-beta.1 + urijs "^1.19.1" + soroban-client@0.8.1: version "0.8.1" resolved "https://registry.npmjs.org/soroban-client/-/soroban-client-0.8.1.tgz" @@ -10379,6 +10400,20 @@ stellar-base@9.0.0-soroban.3: optionalDependencies: sodium-native "^4.0.1" +stellar-base@v10.0.0-beta.1: + version "10.0.0-beta.1" + resolved "https://registry.npmjs.org/stellar-base/-/stellar-base-10.0.0-beta.1.tgz" + integrity sha512-zXC5AsbUsLi57JruyeIMv23s3iUxq/P2ZFrSJ+FerLIZjSAjY8EDs4zwY4LCuu7swUu46Lm8GK6sqxUZCPekHw== + dependencies: + base32.js "^0.1.0" + bignumber.js "^9.1.2" + buffer "^6.0.3" + js-xdr "^3.0.0" + sha.js "^2.3.6" + tweetnacl "^1.0.3" + optionalDependencies: + sodium-native "^4.0.1" + "stellar-wallets-kit@github:Creit-Tech/Stellar-Wallets-Kit": version "0.1.1" resolved "git+ssh://git@github.com/Creit-Tech/Stellar-Wallets-Kit.git#7f5dcffef493eb3569c954c033b166def5403b98"