diff --git a/package-lock.json b/package-lock.json index d24dbd275..40a35a3ce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -116,7 +116,8 @@ "stylelint-scss": "^4.3.0", "ts-jest": "^26.5.6", "ts-node": "^10.9.1", - "typescript": "^4.9.4" + "typescript": "^4.9.4", + "xrpl": "^2.8.1" }, "engines": { "node": ">=18.0.0 <19", @@ -5154,6 +5155,18 @@ "semver": "bin/semver.js" } }, + "node_modules/@noble/hashes": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.1.tgz", + "integrity": "sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA==", + "dev": true, + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "license": "MIT", @@ -7294,11 +7307,49 @@ "version": "1.5.0", "dev": true, "license": "MIT", - "optional": true, "dependencies": { "file-uri-to-path": "1.0.0" } }, + "node_modules/bip32": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/bip32/-/bip32-2.0.6.tgz", + "integrity": "sha512-HpV5OMLLGTjSVblmrtYRfFFKuQB+GArM0+XP8HGWfJ5vxYBqo+DesvJwOdC2WJ3bCkZShGf0QIfoIpeomVzVdA==", + "dev": true, + "dependencies": { + "@types/node": "10.12.18", + "bs58check": "^2.1.1", + "create-hash": "^1.2.0", + "create-hmac": "^1.1.7", + "tiny-secp256k1": "^1.1.3", + "typeforce": "^1.11.5", + "wif": "^2.0.6" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/bip32/node_modules/@types/node": { + "version": "10.12.18", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.18.tgz", + "integrity": "sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ==", + "dev": true + }, + "node_modules/bip39": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/bip39/-/bip39-3.1.0.tgz", + "integrity": "sha512-c9kiwdk45Do5GL0vJMe7tS95VjCii65mYAH7DfWl3uW8AVzXKQVUm64i3hzVybBDMp9r7j9iNxR85+ul8MdN/A==", + "dev": true, + "dependencies": { + "@noble/hashes": "^1.2.0" + } + }, + "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==", + "dev": true + }, "node_modules/body-parser": { "version": "1.20.2", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz", @@ -7428,6 +7479,12 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/brorand": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", + "integrity": "sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==", + "dev": true + }, "node_modules/browser-process-hrtime": { "version": "1.0.0", "dev": true, @@ -7477,6 +7534,26 @@ "node": ">= 6" } }, + "node_modules/bs58": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", + "integrity": "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==", + "dev": true, + "dependencies": { + "base-x": "^3.0.2" + } + }, + "node_modules/bs58check": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/bs58check/-/bs58check-2.1.2.tgz", + "integrity": "sha512-0TS1jicxdU09dwJMNZtVAfzPi6Q6QeN0pM1Fkzrjn+XYHvzMKPU3pHVpva+769iNVSfIYWf7LJ6WR+BuuMf8cA==", + "dev": true, + "dependencies": { + "bs58": "^4.0.0", + "create-hash": "^1.1.0", + "safe-buffer": "^5.1.2" + } + }, "node_modules/bser": { "version": "2.1.1", "dev": true, @@ -8287,6 +8364,20 @@ "sha.js": "^2.4.0" } }, + "node_modules/create-hmac": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", + "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", + "dev": true, + "dependencies": { + "cipher-base": "^1.0.3", + "create-hash": "^1.1.0", + "inherits": "^2.0.1", + "ripemd160": "^2.0.0", + "safe-buffer": "^5.0.1", + "sha.js": "^2.4.8" + } + }, "node_modules/create-require": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", @@ -8924,8 +9015,7 @@ "node_modules/decimal.js": { "version": "10.3.1", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/decimal.js-light": { "version": "2.5.1", @@ -9346,6 +9436,27 @@ "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.284.tgz", "integrity": "sha512-M8WEXFuKXMYMVr45fo8mq0wUrrJHheiKZf6BArTKk9ZBYCKJEOU5H8cdWgDT+qCVZf7Na4lVUaZsA+h6uA9+PA==" }, + "node_modules/elliptic": { + "version": "6.5.4", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", + "integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", + "dev": true, + "dependencies": { + "bn.js": "^4.11.9", + "brorand": "^1.1.0", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.1", + "inherits": "^2.0.4", + "minimalistic-assert": "^1.0.1", + "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==", + "dev": true + }, "node_modules/emittery": { "version": "0.7.2", "dev": true, @@ -11407,8 +11518,7 @@ "node_modules/file-uri-to-path": { "version": "1.0.0", "dev": true, - "license": "MIT", - "optional": true + "license": "MIT" }, "node_modules/filelist": { "version": "1.0.2", @@ -12128,6 +12238,16 @@ "node": ">=4" } }, + "node_modules/hash.js": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", + "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", + "dev": true, + "dependencies": { + "inherits": "^2.0.3", + "minimalistic-assert": "^1.0.1" + } + }, "node_modules/he": { "version": "1.2.0", "license": "MIT", @@ -12135,6 +12255,17 @@ "he": "bin/he" } }, + "node_modules/hmac-drbg": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", + "integrity": "sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==", + "dev": true, + "dependencies": { + "hash.js": "^1.0.3", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.1" + } + }, "node_modules/hoist-non-react-statics": { "version": "3.3.2", "license": "BSD-3-Clause", @@ -20333,6 +20464,18 @@ "node": ">=4" } }, + "node_modules/minimalistic-assert": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", + "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==", + "dev": true + }, + "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==", + "dev": true + }, "node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", @@ -22965,6 +23108,39 @@ "node": ">= 10" } }, + "node_modules/ripple-binary-codec": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/ripple-binary-codec/-/ripple-binary-codec-1.6.0.tgz", + "integrity": "sha512-fa0aMSbh1VOGEHIWCF/VuIvoMoQ/1HLJoBxm+oPNPIDyZJG1uRpLYph1pcvAlDuMutHM3ZHMzWjJpe3AaiMIUA==", + "dev": true, + "dependencies": { + "assert": "^2.0.0", + "big-integer": "^1.6.48", + "buffer": "6.0.3", + "create-hash": "^1.2.0", + "decimal.js": "^10.2.0", + "ripple-address-codec": "^4.3.0" + }, + "engines": { + "node": ">= 10" + } + }, + "node_modules/ripple-keypairs": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/ripple-keypairs/-/ripple-keypairs-1.3.0.tgz", + "integrity": "sha512-LzM3Up9Pwz3dYqnczzNptimN3AxtjeGbDGeiOzREzbkslKiZcJ615b/ghBN4H23SC6W1GAL95juEzzimDi4THw==", + "dev": true, + "dependencies": { + "bn.js": "^5.1.1", + "brorand": "^1.0.5", + "elliptic": "^6.5.4", + "hash.js": "^1.0.3", + "ripple-address-codec": "^4.3.0" + }, + "engines": { + "node": ">= 10" + } + }, "node_modules/robust-predicates": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/robust-predicates/-/robust-predicates-3.0.1.tgz", @@ -25229,6 +25405,29 @@ "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==", "dev": true }, + "node_modules/tiny-secp256k1": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/tiny-secp256k1/-/tiny-secp256k1-1.1.6.tgz", + "integrity": "sha512-FmqJZGduTyvsr2cF3375fqGHUovSwDi/QytexX1Se4BPuPZpTE5Ftp5fg+EFSuEf3lhZqgCRjEG3ydUQ/aNiwA==", + "dev": true, + "hasInstallScript": true, + "dependencies": { + "bindings": "^1.3.0", + "bn.js": "^4.11.8", + "create-hmac": "^1.1.7", + "elliptic": "^6.4.0", + "nan": "^2.13.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/tiny-secp256k1/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==", + "dev": true + }, "node_modules/tmpl": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz", @@ -25775,6 +25974,12 @@ "is-typedarray": "^1.0.0" } }, + "node_modules/typeforce": { + "version": "1.18.0", + "resolved": "https://registry.npmjs.org/typeforce/-/typeforce-1.18.0.tgz", + "integrity": "sha512-7uc1O8h1M1g0rArakJdf0uLRSSgFcYexrVoKo+bzJd32gd4gDy2L/Z+8/FjPnU9ydY3pEnVPtr9FyscYY60K1g==", + "dev": true + }, "node_modules/typescript": { "version": "4.9.4", "devOptional": true, @@ -26808,6 +27013,15 @@ "string-width": "^1.0.2 || 2" } }, + "node_modules/wif": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/wif/-/wif-2.0.6.tgz", + "integrity": "sha512-HIanZn1zmduSF+BQhkE+YXIbEiH0xPr1012QbFEGB0xsKqJii0/SqJjyn8dFv6y36kOznMgMB+LGcbZTJ1xACQ==", + "dev": true, + "dependencies": { + "bs58check": "<3.0.0" + } + }, "node_modules/word-wrap": { "version": "1.2.3", "license": "MIT", @@ -26953,6 +27167,26 @@ "license": "MIT", "peer": true }, + "node_modules/xrpl": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/xrpl/-/xrpl-2.8.1.tgz", + "integrity": "sha512-P6SwGpA3QDusaqjElo6HbNvMI+voTQbkSknbqwZCTG6cpwsvrYbKWqS/Kl2hoqvhhe8L9d8tdCdm4YXcGy/j8g==", + "dev": true, + "dependencies": { + "bignumber.js": "^9.0.0", + "bip32": "^2.0.6", + "bip39": "^3.0.4", + "https-proxy-agent": "^5.0.0", + "lodash": "^4.17.4", + "ripple-address-codec": "^4.3.0", + "ripple-binary-codec": "^1.6.0", + "ripple-keypairs": "^1.3.0", + "ws": "^8.2.2" + }, + "engines": { + "node": ">=10.13.0" + } + }, "node_modules/xrpl-client": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/xrpl-client/-/xrpl-client-2.1.0.tgz", @@ -26962,6 +27196,27 @@ "websocket": "^1.0.34" } }, + "node_modules/xrpl/node_modules/ws": { + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz", + "integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==", + "dev": true, + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, "node_modules/y18n": { "version": "4.0.3", "dev": true, @@ -30385,6 +30640,12 @@ "integrity": "sha512-3Yc1fUTs69MG/uZbJlLSI3JISMn2UV2rg+1D/vROUqZyh3l6iYHCs7GMp+M40ZD7yOdDbYjJcU1oTJhrc+dGKg==", "dev": true }, + "@noble/hashes": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.1.tgz", + "integrity": "sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA==", + "dev": true + }, "@nodelib/fs.scandir": { "version": "2.1.5", "requires": { @@ -31925,11 +32186,48 @@ "bindings": { "version": "1.5.0", "dev": true, - "optional": true, "requires": { "file-uri-to-path": "1.0.0" } }, + "bip32": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/bip32/-/bip32-2.0.6.tgz", + "integrity": "sha512-HpV5OMLLGTjSVblmrtYRfFFKuQB+GArM0+XP8HGWfJ5vxYBqo+DesvJwOdC2WJ3bCkZShGf0QIfoIpeomVzVdA==", + "dev": true, + "requires": { + "@types/node": "10.12.18", + "bs58check": "^2.1.1", + "create-hash": "^1.2.0", + "create-hmac": "^1.1.7", + "tiny-secp256k1": "^1.1.3", + "typeforce": "^1.11.5", + "wif": "^2.0.6" + }, + "dependencies": { + "@types/node": { + "version": "10.12.18", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.18.tgz", + "integrity": "sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ==", + "dev": true + } + } + }, + "bip39": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/bip39/-/bip39-3.1.0.tgz", + "integrity": "sha512-c9kiwdk45Do5GL0vJMe7tS95VjCii65mYAH7DfWl3uW8AVzXKQVUm64i3hzVybBDMp9r7j9iNxR85+ul8MdN/A==", + "dev": true, + "requires": { + "@noble/hashes": "^1.2.0" + } + }, + "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==", + "dev": true + }, "body-parser": { "version": "1.20.2", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz", @@ -32030,6 +32328,12 @@ } } }, + "brorand": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", + "integrity": "sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==", + "dev": true + }, "browser-process-hrtime": { "version": "1.0.0", "dev": true @@ -32061,6 +32365,26 @@ "fast-json-stable-stringify": "2.x" } }, + "bs58": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", + "integrity": "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==", + "dev": true, + "requires": { + "base-x": "^3.0.2" + } + }, + "bs58check": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/bs58check/-/bs58check-2.1.2.tgz", + "integrity": "sha512-0TS1jicxdU09dwJMNZtVAfzPi6Q6QeN0pM1Fkzrjn+XYHvzMKPU3pHVpva+769iNVSfIYWf7LJ6WR+BuuMf8cA==", + "dev": true, + "requires": { + "bs58": "^4.0.0", + "create-hash": "^1.1.0", + "safe-buffer": "^5.1.2" + } + }, "bser": { "version": "2.1.1", "dev": true, @@ -32586,6 +32910,20 @@ "sha.js": "^2.4.0" } }, + "create-hmac": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", + "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", + "dev": true, + "requires": { + "cipher-base": "^1.0.3", + "create-hash": "^1.1.0", + "inherits": "^2.0.1", + "ripemd160": "^2.0.0", + "safe-buffer": "^5.0.1", + "sha.js": "^2.4.8" + } + }, "create-require": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", @@ -33047,8 +33385,7 @@ }, "decimal.js": { "version": "10.3.1", - "dev": true, - "peer": true + "dev": true }, "decimal.js-light": { "version": "2.5.1" @@ -33349,6 +33686,29 @@ "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.284.tgz", "integrity": "sha512-M8WEXFuKXMYMVr45fo8mq0wUrrJHheiKZf6BArTKk9ZBYCKJEOU5H8cdWgDT+qCVZf7Na4lVUaZsA+h6uA9+PA==" }, + "elliptic": { + "version": "6.5.4", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", + "integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", + "dev": true, + "requires": { + "bn.js": "^4.11.9", + "brorand": "^1.1.0", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.1", + "inherits": "^2.0.4", + "minimalistic-assert": "^1.0.1", + "minimalistic-crypto-utils": "^1.0.1" + }, + "dependencies": { + "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==", + "dev": true + } + } + }, "emittery": { "version": "0.7.2", "dev": true, @@ -34788,8 +35148,7 @@ }, "file-uri-to-path": { "version": "1.0.0", - "dev": true, - "optional": true + "dev": true }, "filelist": { "version": "1.0.2", @@ -35252,9 +35611,30 @@ "safe-buffer": "^5.2.0" } }, + "hash.js": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", + "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", + "dev": true, + "requires": { + "inherits": "^2.0.3", + "minimalistic-assert": "^1.0.1" + } + }, "he": { "version": "1.2.0" }, + "hmac-drbg": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", + "integrity": "sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==", + "dev": true, + "requires": { + "hash.js": "^1.0.3", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.1" + } + }, "hoist-non-react-statics": { "version": "3.3.2", "requires": { @@ -40908,6 +41288,18 @@ "version": "1.0.1", "dev": true }, + "minimalistic-assert": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", + "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==", + "dev": true + }, + "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==", + "dev": true + }, "minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", @@ -42649,6 +43041,33 @@ "create-hash": "^1.1.2" } }, + "ripple-binary-codec": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/ripple-binary-codec/-/ripple-binary-codec-1.6.0.tgz", + "integrity": "sha512-fa0aMSbh1VOGEHIWCF/VuIvoMoQ/1HLJoBxm+oPNPIDyZJG1uRpLYph1pcvAlDuMutHM3ZHMzWjJpe3AaiMIUA==", + "dev": true, + "requires": { + "assert": "^2.0.0", + "big-integer": "^1.6.48", + "buffer": "6.0.3", + "create-hash": "^1.2.0", + "decimal.js": "^10.2.0", + "ripple-address-codec": "^4.3.0" + } + }, + "ripple-keypairs": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/ripple-keypairs/-/ripple-keypairs-1.3.0.tgz", + "integrity": "sha512-LzM3Up9Pwz3dYqnczzNptimN3AxtjeGbDGeiOzREzbkslKiZcJ615b/ghBN4H23SC6W1GAL95juEzzimDi4THw==", + "dev": true, + "requires": { + "bn.js": "^5.1.1", + "brorand": "^1.0.5", + "elliptic": "^6.5.4", + "hash.js": "^1.0.3", + "ripple-address-codec": "^4.3.0" + } + }, "robust-predicates": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/robust-predicates/-/robust-predicates-3.0.1.tgz", @@ -44177,6 +44596,27 @@ "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==", "dev": true }, + "tiny-secp256k1": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/tiny-secp256k1/-/tiny-secp256k1-1.1.6.tgz", + "integrity": "sha512-FmqJZGduTyvsr2cF3375fqGHUovSwDi/QytexX1Se4BPuPZpTE5Ftp5fg+EFSuEf3lhZqgCRjEG3ydUQ/aNiwA==", + "dev": true, + "requires": { + "bindings": "^1.3.0", + "bn.js": "^4.11.8", + "create-hmac": "^1.1.7", + "elliptic": "^6.4.0", + "nan": "^2.13.2" + }, + "dependencies": { + "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==", + "dev": true + } + } + }, "tmpl": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz", @@ -44551,6 +44991,12 @@ "is-typedarray": "^1.0.0" } }, + "typeforce": { + "version": "1.18.0", + "resolved": "https://registry.npmjs.org/typeforce/-/typeforce-1.18.0.tgz", + "integrity": "sha512-7uc1O8h1M1g0rArakJdf0uLRSSgFcYexrVoKo+bzJd32gd4gDy2L/Z+8/FjPnU9ydY3pEnVPtr9FyscYY60K1g==", + "dev": true + }, "typescript": { "version": "4.9.4", "devOptional": true @@ -45204,6 +45650,15 @@ "string-width": "^1.0.2 || 2" } }, + "wif": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/wif/-/wif-2.0.6.tgz", + "integrity": "sha512-HIanZn1zmduSF+BQhkE+YXIbEiH0xPr1012QbFEGB0xsKqJii0/SqJjyn8dFv6y36kOznMgMB+LGcbZTJ1xACQ==", + "dev": true, + "requires": { + "bs58check": "<3.0.0" + } + }, "word-wrap": { "version": "1.2.3" }, @@ -45301,6 +45756,32 @@ "dev": true, "peer": true }, + "xrpl": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/xrpl/-/xrpl-2.8.1.tgz", + "integrity": "sha512-P6SwGpA3QDusaqjElo6HbNvMI+voTQbkSknbqwZCTG6cpwsvrYbKWqS/Kl2hoqvhhe8L9d8tdCdm4YXcGy/j8g==", + "dev": true, + "requires": { + "bignumber.js": "^9.0.0", + "bip32": "^2.0.6", + "bip39": "^3.0.4", + "https-proxy-agent": "^5.0.0", + "lodash": "^4.17.4", + "ripple-address-codec": "^4.3.0", + "ripple-binary-codec": "^1.6.0", + "ripple-keypairs": "^1.3.0", + "ws": "^8.2.2" + }, + "dependencies": { + "ws": { + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz", + "integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==", + "dev": true, + "requires": {} + } + } + }, "xrpl-client": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/xrpl-client/-/xrpl-client-2.1.0.tgz", diff --git a/package.json b/package.json index bd1f4f35f..a2d4d75d5 100644 --- a/package.json +++ b/package.json @@ -111,7 +111,8 @@ "stylelint-scss": "^4.3.0", "ts-jest": "^26.5.6", "ts-node": "^10.9.1", - "typescript": "^4.9.4" + "typescript": "^4.9.4", + "xrpl": "^2.8.1" }, "resolutions": { "jest-environment-jsdom": "29.3.1" diff --git a/src/containers/shared/components/Transaction/AccountDelete/Simple.tsx b/src/containers/shared/components/Transaction/AccountDelete/Simple.tsx index 117e9c1e7..321e77c4e 100644 --- a/src/containers/shared/components/Transaction/AccountDelete/Simple.tsx +++ b/src/containers/shared/components/Transaction/AccountDelete/Simple.tsx @@ -1,9 +1,9 @@ import { useTranslation } from 'react-i18next' +import type { AccountDelete } from 'xrpl' import { SimpleRow } from '../SimpleRow' import { TransactionSimpleProps } from '../types' import { Account } from '../../Account' -import { AccountDelete } from './types' export const Simple = ({ data }: TransactionSimpleProps) => { const { t } = useTranslation() diff --git a/src/containers/shared/components/Transaction/AccountDelete/index.ts b/src/containers/shared/components/Transaction/AccountDelete/index.ts index efa48a89b..8ccf40a4c 100644 --- a/src/containers/shared/components/Transaction/AccountDelete/index.ts +++ b/src/containers/shared/components/Transaction/AccountDelete/index.ts @@ -1,3 +1,4 @@ +import type { AccountDelete } from 'xrpl' import { TransactionAction, TransactionCategory, @@ -5,7 +6,6 @@ import { } from '../types' import { Simple } from './Simple' -import { AccountDelete } from './types' export const AccountDeleteTransaction: TransactionMapping = { Simple, diff --git a/src/containers/shared/components/Transaction/AccountDelete/types.ts b/src/containers/shared/components/Transaction/AccountDelete/types.ts deleted file mode 100644 index d72c36553..000000000 --- a/src/containers/shared/components/Transaction/AccountDelete/types.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { TransactionCommonFields } from '../types' - -export interface AccountDelete extends TransactionCommonFields { - Destination: string - DestinationTag?: string -} diff --git a/src/containers/shared/components/Transaction/AccountSet/Description.tsx b/src/containers/shared/components/Transaction/AccountSet/Description.tsx index f7b4b9d7c..f93309913 100644 --- a/src/containers/shared/components/Transaction/AccountSet/Description.tsx +++ b/src/containers/shared/components/Transaction/AccountSet/Description.tsx @@ -1,8 +1,8 @@ import { useTranslation, Trans } from 'react-i18next' +import type { AccountSet } from 'xrpl' import { ACCOUNT_FLAGS } from '../../../transactionUtils' import DomainLink from '../../DomainLink' import { TransactionDescriptionProps } from '../types' -import { AccountSet } from './types' import { Account } from '../../Account' export const Description = ({ diff --git a/src/containers/shared/components/Transaction/AccountSet/Simple.tsx b/src/containers/shared/components/Transaction/AccountSet/Simple.tsx index 739eee12a..6822640d0 100644 --- a/src/containers/shared/components/Transaction/AccountSet/Simple.tsx +++ b/src/containers/shared/components/Transaction/AccountSet/Simple.tsx @@ -1,10 +1,10 @@ import { useTranslation } from 'react-i18next' +import type { AccountSet } from 'xrpl' import { ACCOUNT_FLAGS } from '../../../transactionUtils' import DomainLink from '../../DomainLink' import { Account } from '../../Account' import { SimpleRow } from '../SimpleRow' import { TransactionSimpleProps } from '../types' -import { AccountSet } from './types' export const Simple = ({ data }: TransactionSimpleProps) => { const { t } = useTranslation() diff --git a/src/containers/shared/components/Transaction/AccountSet/TableDetail.tsx b/src/containers/shared/components/Transaction/AccountSet/TableDetail.tsx index 453f8898e..bfee92fd6 100644 --- a/src/containers/shared/components/Transaction/AccountSet/TableDetail.tsx +++ b/src/containers/shared/components/Transaction/AccountSet/TableDetail.tsx @@ -1,7 +1,7 @@ import { useTranslation } from 'react-i18next' +import type { AccountSet } from 'xrpl' import { ACCOUNT_FLAGS, decodeHex } from '../../../transactionUtils' import { Account } from '../../Account' -import { AccountSet } from './types' import { TransactionTableDetailProps } from '../types' export const TableDetail = ({ diff --git a/src/containers/shared/components/Transaction/AccountSet/index.tsx b/src/containers/shared/components/Transaction/AccountSet/index.tsx index ffcdac872..80b06e81e 100644 --- a/src/containers/shared/components/Transaction/AccountSet/index.tsx +++ b/src/containers/shared/components/Transaction/AccountSet/index.tsx @@ -3,9 +3,7 @@ import { TransactionCategory, TransactionMapping, } from '../types' - import { Description } from './Description' -import { parser } from './parser' import { Simple } from './Simple' import { TableDetail } from './TableDetail' @@ -15,5 +13,4 @@ export const AccountSetTransaction: TransactionMapping = { TableDetail, action: TransactionAction.MODIFY, category: TransactionCategory.ACCOUNT, - parser, } diff --git a/src/containers/shared/components/Transaction/AccountSet/parser.ts b/src/containers/shared/components/Transaction/AccountSet/parser.ts deleted file mode 100644 index 11a9fcc5e..000000000 --- a/src/containers/shared/components/Transaction/AccountSet/parser.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { AccountSet } from './types' - -export const parser = (tx: AccountSet): AccountSet => tx diff --git a/src/containers/shared/components/Transaction/AccountSet/types.ts b/src/containers/shared/components/Transaction/AccountSet/types.ts deleted file mode 100644 index d8bba6128..000000000 --- a/src/containers/shared/components/Transaction/AccountSet/types.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { TransactionCommonFields } from '../types' - -export interface AccountSet extends TransactionCommonFields { - ClearFlag?: number - Domain?: string - EmailHash?: string - MessageKey?: string - NFTokenMinter?: string - SetFlag?: number - TickSize?: number - TransferRate?: number -} diff --git a/src/containers/shared/components/Transaction/DepositPreauth/parser.ts b/src/containers/shared/components/Transaction/DepositPreauth/parser.ts index 98c88d951..7418cc222 100644 --- a/src/containers/shared/components/Transaction/DepositPreauth/parser.ts +++ b/src/containers/shared/components/Transaction/DepositPreauth/parser.ts @@ -1,6 +1,5 @@ +import type { DepositPreauth } from 'xrpl' import { TransactionParser } from '../types' -import { DepositPreauth } from './types' - export const parser: TransactionParser = (tx) => tx diff --git a/src/containers/shared/components/Transaction/EnableAmendment/index.ts b/src/containers/shared/components/Transaction/EnableAmendment/index.ts index 4d4204d53..d7f13e2a4 100644 --- a/src/containers/shared/components/Transaction/EnableAmendment/index.ts +++ b/src/containers/shared/components/Transaction/EnableAmendment/index.ts @@ -5,11 +5,9 @@ import { } from '../types' import { Simple } from './Simple' -import { EnableAmendment } from './types' export const EnableAmendmentTransaction: TransactionMapping = { Simple, action: TransactionAction.MODIFY, category: TransactionCategory.PSEUDO, - parser: (tx: EnableAmendment): EnableAmendment => tx, } diff --git a/src/containers/shared/components/Transaction/EscrowCancel/Description.tsx b/src/containers/shared/components/Transaction/EscrowCancel/Description.tsx index c0403b3ab..d5511f247 100644 --- a/src/containers/shared/components/Transaction/EscrowCancel/Description.tsx +++ b/src/containers/shared/components/Transaction/EscrowCancel/Description.tsx @@ -1,4 +1,5 @@ import { useTranslation, Trans } from 'react-i18next' +import type { EscrowCancel } from 'xrpl' import { findNode, normalizeAmount } from '../../../transactionUtils' import { Account } from '../../Account' import { @@ -9,12 +10,12 @@ import { TRANSACTION_ROUTE } from '../../../../App/routes' import { RouteLink } from '../../../routing' const Description: TransactionDescriptionComponent = ( - props: TransactionDescriptionProps, + props: TransactionDescriptionProps, ) => { const { t, i18n } = useTranslation() const language = i18n.resolvedLanguage const { data } = props - const deleted: any = findNode(data, 'DeletedNode', 'Escrow') + const deleted: any = findNode(data.meta, 'DeletedNode', 'Escrow') if (deleted == null) { return null } @@ -39,7 +40,7 @@ const Description: TransactionDescriptionComponent = ( ( {normalizeAmount( - deleted.FinalFields.Amount - data.tx.Fee, + deleted.FinalFields.Amount - parseInt(data.tx.Fee || '0', 10), language, )} XRP diff --git a/src/containers/shared/components/Transaction/EscrowCancel/parser.ts b/src/containers/shared/components/Transaction/EscrowCancel/parser.ts index b1e58ef5f..c641e87fb 100644 --- a/src/containers/shared/components/Transaction/EscrowCancel/parser.ts +++ b/src/containers/shared/components/Transaction/EscrowCancel/parser.ts @@ -1,15 +1,14 @@ +import type { EscrowCancel, TransactionMetadata } from 'xrpl' import { formatAmount } from '../../../../../rippled/lib/txSummary/formatAmount' +import { findNode } from '../../../transactionUtils' -const findNode = (meta: any) => { - const node = meta.AffectedNodes.filter( - (a: any) => a.DeletedNode && a.DeletedNode.LedgerEntryType === 'Escrow', - )[0] - - return node ? node.DeletedNode.FinalFields : {} +const findNodeFinalFields = (meta: TransactionMetadata) => { + const node = findNode(meta, 'DeletedNode', 'Escrow') + return node ? node.FinalFields : {} } -export function parser(tx: any, meta: any) { - const escrow = findNode(meta) +export function parser(tx: EscrowCancel, meta: TransactionMetadata) { + const escrow = findNodeFinalFields(meta) return { sequence: tx.OfferSequence, diff --git a/src/containers/shared/components/Transaction/EscrowCreate/Description.tsx b/src/containers/shared/components/Transaction/EscrowCreate/Description.tsx index a59d09b94..78661978f 100644 --- a/src/containers/shared/components/Transaction/EscrowCreate/Description.tsx +++ b/src/containers/shared/components/Transaction/EscrowCreate/Description.tsx @@ -1,32 +1,26 @@ import { useTranslation, Trans } from 'react-i18next' -import { - DATE_OPTIONS, - RIPPLE_EPOCH, - normalizeAmount, -} from '../../../transactionUtils' +import type { EscrowCreate } from 'xrpl' +import { DATE_OPTIONS, normalizeAmount } from '../../../transactionUtils' import { Account } from '../../Account' import { localizeDate } from '../../../utils' import { TransactionDescriptionComponent, TransactionDescriptionProps, } from '../types' +import { convertRippleDate } from '../../../../../rippled/lib/convertRippleDate' const Description: TransactionDescriptionComponent = ( - props: TransactionDescriptionProps, + props: TransactionDescriptionProps, ) => { const { t, i18n } = useTranslation() const language = i18n.resolvedLanguage const { data } = props - const cancelAfter = localizeDate( - (data.tx.CancelAfter + RIPPLE_EPOCH) * 1000, - language, - DATE_OPTIONS, - ) - const finishAfter = localizeDate( - (data.tx.FinishAfter + RIPPLE_EPOCH) * 1000, - language, - DATE_OPTIONS, - ) + + const formatDate = (time: number) => + `${localizeDate(convertRippleDate(time), language, DATE_OPTIONS)} ${ + DATE_OPTIONS.timeZone + }` + return ( <> {data.tx.Destination !== data.tx.Account ? ( @@ -60,13 +54,13 @@ const Description: TransactionDescriptionComponent = ( {data.tx.CancelAfter && (
{t('describe_cancel_after')} - {` ${cancelAfter} ${DATE_OPTIONS.timeZone}`} + {formatDate(data.tx.CancelAfter)}
)} {data.tx.FinishAfter && (
{t('describe_finish_after')} - {` ${finishAfter} ${DATE_OPTIONS.timeZone}`} + {formatDate(data.tx.FinishAfter)}
)} diff --git a/src/containers/shared/components/Transaction/EscrowCreate/parser.ts b/src/containers/shared/components/Transaction/EscrowCreate/parser.ts index 3e2834450..9a4b159e5 100644 --- a/src/containers/shared/components/Transaction/EscrowCreate/parser.ts +++ b/src/containers/shared/components/Transaction/EscrowCreate/parser.ts @@ -1,7 +1,8 @@ +import type { EscrowCreate } from 'xrpl' import { formatAmount } from '../../../../../rippled/lib/txSummary/formatAmount' import { convertRippleDate } from '../../../../../rippled/lib/convertRippleDate' -export function parser(tx: any) { +export function parser(tx: EscrowCreate) { return { amount: formatAmount(tx.Amount), destination: tx.Destination !== tx.Account ? tx.Destination : undefined, diff --git a/src/containers/shared/components/Transaction/EscrowFinish/Description.tsx b/src/containers/shared/components/Transaction/EscrowFinish/Description.tsx index 50e4bdd28..bf5e2be8e 100644 --- a/src/containers/shared/components/Transaction/EscrowFinish/Description.tsx +++ b/src/containers/shared/components/Transaction/EscrowFinish/Description.tsx @@ -1,4 +1,5 @@ import { useTranslation, Trans } from 'react-i18next' +import type { EscrowFinish } from 'xrpl' import { normalizeAmount, findNode } from '../../../transactionUtils' import { Account } from '../../Account' import { @@ -9,12 +10,12 @@ import { RouteLink } from '../../../routing' import { TRANSACTION_ROUTE } from '../../../../App/routes' const Description: TransactionDescriptionComponent = ( - props: TransactionDescriptionProps, + props: TransactionDescriptionProps, ) => { const { t, i18n } = useTranslation() const language = i18n.resolvedLanguage const { data } = props - const deleted: any = findNode(data, 'DeletedNode', 'Escrow') + const deleted: any = findNode(data.meta, 'DeletedNode', 'Escrow') if (deleted == null) { return null @@ -40,7 +41,7 @@ const Description: TransactionDescriptionComponent = ( ( {normalizeAmount( - deleted.FinalFields.Amount - data.tx.Fee, + deleted.FinalFields.Amount - parseInt(data.tx.Fee || '0', 10), language, )} XRP diff --git a/src/containers/shared/components/Transaction/EscrowFinish/parser.ts b/src/containers/shared/components/Transaction/EscrowFinish/parser.ts index 23e61f72f..ccaa1544e 100644 --- a/src/containers/shared/components/Transaction/EscrowFinish/parser.ts +++ b/src/containers/shared/components/Transaction/EscrowFinish/parser.ts @@ -1,14 +1,14 @@ +import type { EscrowFinish, TransactionMetadata } from 'xrpl' import { formatAmount } from '../../../../../rippled/lib/txSummary/formatAmount' +import { findNode } from '../../../transactionUtils' -const findNode = (meta: any) => { - const node = meta.AffectedNodes.filter( - (a: any) => a.DeletedNode && a.DeletedNode.LedgerEntryType === 'Escrow', - )[0] - - return node ? node.DeletedNode.FinalFields : {} +const findNodeFinalFields = (meta: TransactionMetadata) => { + const node = findNode(meta, 'DeletedNode', 'Escrow') + return node ? node.FinalFields : {} } -export function parser(tx: any, meta: any) { - const escrow = findNode(meta) + +export function parser(tx: EscrowFinish, meta: TransactionMetadata) { + const escrow = findNodeFinalFields(meta) return { sequence: tx.OfferSequence, owner: tx.Owner, diff --git a/src/containers/shared/components/Transaction/NFTokenAcceptOffer/parser.ts b/src/containers/shared/components/Transaction/NFTokenAcceptOffer/parser.ts index aa3ccb3d5..85abfdaa6 100644 --- a/src/containers/shared/components/Transaction/NFTokenAcceptOffer/parser.ts +++ b/src/containers/shared/components/Transaction/NFTokenAcceptOffer/parser.ts @@ -1,4 +1,5 @@ -import { NFTokenAcceptOffer, NFTokenAcceptOfferInstructions } from './types' +import type { NFTokenAcceptOffer } from 'xrpl' +import { NFTokenAcceptOfferInstructions } from './types' import { TransactionParser } from '../types' import { formatAmount } from '../../../../../rippled/lib/txSummary/formatAmount' diff --git a/src/containers/shared/components/Transaction/NFTokenAcceptOffer/types.ts b/src/containers/shared/components/Transaction/NFTokenAcceptOffer/types.ts index 8c1145a47..249a9632d 100644 --- a/src/containers/shared/components/Transaction/NFTokenAcceptOffer/types.ts +++ b/src/containers/shared/components/Transaction/NFTokenAcceptOffer/types.ts @@ -1,12 +1,3 @@ -import { TransactionCommonFields } from '../types' -import { Amount } from '../../../types' - -export interface NFTokenAcceptOffer extends TransactionCommonFields { - NFTokenSellOffer?: string - NFTokenBuyOffer?: string - NFTokenBrokerFee?: Amount -} - export interface NFTokenAcceptOfferInstructions { acceptedOfferIDs: string[] amount?: { currency: string; amount: number; issuer?: string } diff --git a/src/containers/shared/components/Transaction/NFTokenBurn/Simple.tsx b/src/containers/shared/components/Transaction/NFTokenBurn/Simple.tsx index 82e692859..86e2c663a 100644 --- a/src/containers/shared/components/Transaction/NFTokenBurn/Simple.tsx +++ b/src/containers/shared/components/Transaction/NFTokenBurn/Simple.tsx @@ -1,24 +1,24 @@ import { useTranslation } from 'react-i18next' +import type { NFTokenBurn } from 'xrpl' import { SimpleRow } from '../SimpleRow' import { TransactionSimpleComponent, TransactionSimpleProps } from '../types' -import { NFTokenBurnInstructions } from './types' import { NFTokenLink } from '../../NFTokenLink' import { Account } from '../../Account' export const Simple: TransactionSimpleComponent = ({ data, -}: TransactionSimpleProps) => { - const { tokenID, owner } = data.instructions +}: TransactionSimpleProps) => { + const { NFTokenID, Owner } = data.instructions const { t } = useTranslation() return ( <> - + - {owner && ( + {Owner && ( - + )} diff --git a/src/containers/shared/components/Transaction/NFTokenBurn/index.ts b/src/containers/shared/components/Transaction/NFTokenBurn/index.ts index e30418ffc..8f0091001 100644 --- a/src/containers/shared/components/Transaction/NFTokenBurn/index.ts +++ b/src/containers/shared/components/Transaction/NFTokenBurn/index.ts @@ -5,11 +5,9 @@ import { } from '../types' import { Simple } from './Simple' -import { parser } from './parser' export const NFTokenBurnTransaction: TransactionMapping = { Simple, action: TransactionAction.CANCEL, category: TransactionCategory.NFT, - parser, } diff --git a/src/containers/shared/components/Transaction/NFTokenBurn/parser.ts b/src/containers/shared/components/Transaction/NFTokenBurn/parser.ts deleted file mode 100644 index 4671262dc..000000000 --- a/src/containers/shared/components/Transaction/NFTokenBurn/parser.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { NFTokenBurn, NFTokenBurnInstructions } from './types' -import { TransactionParser } from '../types' - -export const parser: TransactionParser = ( - tx, -) => ({ - tokenID: tx.NFTokenID, - owner: tx.Owner, -}) diff --git a/src/containers/shared/components/Transaction/NFTokenBurn/types.ts b/src/containers/shared/components/Transaction/NFTokenBurn/types.ts deleted file mode 100644 index 5278f6b37..000000000 --- a/src/containers/shared/components/Transaction/NFTokenBurn/types.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { TransactionCommonFields } from '../types' - -export interface NFTokenBurn extends TransactionCommonFields { - NFTokenID: string - Owner?: string -} - -export interface NFTokenBurnInstructions { - tokenID: string - owner?: string -} diff --git a/src/containers/shared/components/Transaction/NFTokenCancelOffer/parser.ts b/src/containers/shared/components/Transaction/NFTokenCancelOffer/parser.ts index 8afab3552..f2a8debe2 100644 --- a/src/containers/shared/components/Transaction/NFTokenCancelOffer/parser.ts +++ b/src/containers/shared/components/Transaction/NFTokenCancelOffer/parser.ts @@ -1,4 +1,5 @@ -import { NFTokenCancelOffer, NFTokenCancelOfferInstructions } from './types' +import type { NFTokenCancelOffer } from 'xrpl' +import { NFTokenCancelOfferInstructions } from './types' import { TransactionParser } from '../types' import { formatAmount } from '../../../../../rippled/lib/txSummary/formatAmount' diff --git a/src/containers/shared/components/Transaction/NFTokenCancelOffer/types.ts b/src/containers/shared/components/Transaction/NFTokenCancelOffer/types.ts index 6da124857..bfa03a964 100644 --- a/src/containers/shared/components/Transaction/NFTokenCancelOffer/types.ts +++ b/src/containers/shared/components/Transaction/NFTokenCancelOffer/types.ts @@ -1,9 +1,3 @@ -import { TransactionCommonFields } from '../types' - -export interface NFTokenCancelOffer extends TransactionCommonFields { - NFTokenOffers: string[] -} - export interface NFTokenCancelOfferInstructions { cancelledOffers: { amount: { currency: string; amount: number; issuer: string } diff --git a/src/containers/shared/components/Transaction/NFTokenCreateOffer/parser.ts b/src/containers/shared/components/Transaction/NFTokenCreateOffer/parser.ts index 609541d92..e818c0294 100644 --- a/src/containers/shared/components/Transaction/NFTokenCreateOffer/parser.ts +++ b/src/containers/shared/components/Transaction/NFTokenCreateOffer/parser.ts @@ -1,6 +1,8 @@ -import { NFTokenCreateOffer, NFTokenCreateOfferInstructions } from './types' +import type { NFTokenCreateOffer } from 'xrpl' +import { NFTokenCreateOfferInstructions } from './types' import { TransactionParser } from '../types' import { formatAmount } from '../../../../../rippled/lib/txSummary/formatAmount' +import { findNode } from '../../../transactionUtils' export const parser: TransactionParser< NFTokenCreateOffer, @@ -9,11 +11,9 @@ export const parser: TransactionParser< const account = tx.Account const amount = formatAmount(tx.Amount) const tokenID = tx.NFTokenID - const isSellOffer = (tx.Flags! & 1) !== 0 + const isSellOffer = ((tx.Flags as number)! & 1) !== 0 const owner = tx.Owner - const offerID = meta.AffectedNodes.find( - (node: any) => node?.CreatedNode?.LedgerEntryType === 'NFTokenOffer', - )?.CreatedNode?.LedgerIndex + const offerID = findNode(meta, 'CreatedNode', 'NFTokenOffer')?.LedgerIndex const destination = tx.Destination return { diff --git a/src/containers/shared/components/Transaction/NFTokenCreateOffer/types.ts b/src/containers/shared/components/Transaction/NFTokenCreateOffer/types.ts index 0399abeb0..624c2dc47 100644 --- a/src/containers/shared/components/Transaction/NFTokenCreateOffer/types.ts +++ b/src/containers/shared/components/Transaction/NFTokenCreateOffer/types.ts @@ -1,14 +1,3 @@ -import { Amount } from '../../../types' -import { TransactionCommonFields } from '../types' - -export interface NFTokenCreateOffer extends TransactionCommonFields { - Owner?: string - NFTokenID: string - Amount: Amount - Expiration?: number - Destination?: string -} - export interface NFTokenCreateOfferInstructions { account: string amount: { currency: string; amount: number; issuer?: string } diff --git a/src/containers/shared/components/Transaction/NFTokenMint/parser.ts b/src/containers/shared/components/Transaction/NFTokenMint/parser.ts index 60a14499e..998ab089f 100644 --- a/src/containers/shared/components/Transaction/NFTokenMint/parser.ts +++ b/src/containers/shared/components/Transaction/NFTokenMint/parser.ts @@ -1,4 +1,5 @@ -import { NFTokenMint, NFTokenMintInstructions } from './types' +import type { NFTokenMint } from 'xrpl' +import { NFTokenMintInstructions } from './types' import { TransactionParser } from '../types' import { convertHexToString } from '../../../../../rippled/lib/utils' diff --git a/src/containers/shared/components/Transaction/NFTokenMint/types.ts b/src/containers/shared/components/Transaction/NFTokenMint/types.ts index ace180bc3..f434548df 100644 --- a/src/containers/shared/components/Transaction/NFTokenMint/types.ts +++ b/src/containers/shared/components/Transaction/NFTokenMint/types.ts @@ -1,12 +1,3 @@ -import { TransactionCommonFields } from '../types' - -export interface NFTokenMint extends TransactionCommonFields { - NFTokenTaxon: number - Issuer?: string - TransferFee?: number - URI?: string -} - export interface NFTokenMintInstructions { tokenID: string tokenTaxon: number diff --git a/src/containers/shared/components/Transaction/OfferCancel/Description.tsx b/src/containers/shared/components/Transaction/OfferCancel/Description.tsx index 3759795f5..79cf988fc 100644 --- a/src/containers/shared/components/Transaction/OfferCancel/Description.tsx +++ b/src/containers/shared/components/Transaction/OfferCancel/Description.tsx @@ -1,7 +1,7 @@ import { useTranslation } from 'react-i18next' +import type { OfferCancel } from 'xrpl' import { TransactionDescriptionProps } from '../types' -import { OfferCancel } from './types' export const Description = ({ data, diff --git a/src/containers/shared/components/Transaction/OfferCancel/Simple.tsx b/src/containers/shared/components/Transaction/OfferCancel/Simple.tsx index 76bbaa82d..a0a525e34 100644 --- a/src/containers/shared/components/Transaction/OfferCancel/Simple.tsx +++ b/src/containers/shared/components/Transaction/OfferCancel/Simple.tsx @@ -1,17 +1,15 @@ import { useTranslation } from 'react-i18next' +import type { OfferCancel } from 'xrpl' import { TransactionSimpleProps } from '../types' import { SimpleRow } from '../SimpleRow' -import { OfferCancelInstructions } from './types' -export const Simple = ({ - data, -}: TransactionSimpleProps) => { +export const Simple = ({ data }: TransactionSimpleProps) => { const { t } = useTranslation() - const { cancel } = data.instructions + const { OfferSequence } = data.instructions return ( - #{cancel} + #{OfferSequence} ) } diff --git a/src/containers/shared/components/Transaction/OfferCancel/TableDetail.tsx b/src/containers/shared/components/Transaction/OfferCancel/TableDetail.tsx index 6d0c09856..55082db59 100644 --- a/src/containers/shared/components/Transaction/OfferCancel/TableDetail.tsx +++ b/src/containers/shared/components/Transaction/OfferCancel/TableDetail.tsx @@ -1,18 +1,18 @@ import { useTranslation } from 'react-i18next' +import type { OfferCancel } from 'xrpl' import { TransactionTableDetailProps } from '../types' -import { OfferCancelInstructions } from './types' export const TableDetail = ({ instructions, -}: TransactionTableDetailProps) => { +}: TransactionTableDetailProps) => { const { t } = useTranslation() - const { cancel } = instructions + const { OfferSequence } = instructions return (
{t('cancel_offer')} {` #`} - {cancel} + {OfferSequence}
) } diff --git a/src/containers/shared/components/Transaction/OfferCancel/index.ts b/src/containers/shared/components/Transaction/OfferCancel/index.ts index 3dbe23c6e..34702a752 100644 --- a/src/containers/shared/components/Transaction/OfferCancel/index.ts +++ b/src/containers/shared/components/Transaction/OfferCancel/index.ts @@ -6,7 +6,6 @@ import { import { Description } from './Description' import { Simple } from './Simple' -import { parser } from './parser' import { TableDetail } from './TableDetail' export const OfferCancelTransaction: TransactionMapping = { @@ -15,5 +14,4 @@ export const OfferCancelTransaction: TransactionMapping = { TableDetail, action: TransactionAction.CANCEL, category: TransactionCategory.DEX, - parser, } diff --git a/src/containers/shared/components/Transaction/OfferCancel/parser.ts b/src/containers/shared/components/Transaction/OfferCancel/parser.ts deleted file mode 100644 index 8f086e0de..000000000 --- a/src/containers/shared/components/Transaction/OfferCancel/parser.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { OfferCancel } from './types' - -export const parser = (tx: OfferCancel) => ({ - cancel: tx.OfferSequence, -}) diff --git a/src/containers/shared/components/Transaction/OfferCancel/types.ts b/src/containers/shared/components/Transaction/OfferCancel/types.ts deleted file mode 100644 index 6aa9ea4f7..000000000 --- a/src/containers/shared/components/Transaction/OfferCancel/types.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { TransactionCommonFields } from '../types' - -export interface OfferCancel extends TransactionCommonFields { - OfferSequence: number -} - -export interface OfferCancelInstructions { - cancel: number -} diff --git a/src/containers/shared/components/Transaction/Payment/Description.tsx b/src/containers/shared/components/Transaction/Payment/Description.tsx index 49228d82d..fb74bbc20 100644 --- a/src/containers/shared/components/Transaction/Payment/Description.tsx +++ b/src/containers/shared/components/Transaction/Payment/Description.tsx @@ -1,11 +1,12 @@ import { Trans, useTranslation } from 'react-i18next' +import type { Payment } from 'xrpl' import { Account } from '../../Account' import { TransactionDescriptionProps } from '../types' import { isPartialPayment } from './parser' import { Amount } from '../../Amount' import { formatAmount } from '../../../../../rippled/lib/txSummary/formatAmount' -export const Description = ({ data }: TransactionDescriptionProps) => { +export const Description = ({ data }: TransactionDescriptionProps) => { const { t } = useTranslation() const partial = isPartialPayment(data.tx.Flags) diff --git a/src/containers/shared/components/Transaction/Payment/parser.ts b/src/containers/shared/components/Transaction/Payment/parser.ts index f8a4e513c..743c05367 100644 --- a/src/containers/shared/components/Transaction/Payment/parser.ts +++ b/src/containers/shared/components/Transaction/Payment/parser.ts @@ -1,5 +1,6 @@ +import type { Payment } from 'xrpl' import { formatAmount } from '../../../../../rippled/lib/txSummary/formatAmount' -import { Payment, PaymentInstructions } from './types' +import { PaymentInstructions } from './types' import { Amount, ExplorerAmount } from '../../../types' const formatFailedPartialAmount = (d: Amount): ExplorerAmount => ({ diff --git a/src/containers/shared/components/Transaction/Payment/types.ts b/src/containers/shared/components/Transaction/Payment/types.ts index 6a544f2f2..6181d1d8e 100644 --- a/src/containers/shared/components/Transaction/Payment/types.ts +++ b/src/containers/shared/components/Transaction/Payment/types.ts @@ -1,14 +1,4 @@ -import { Amount, ExplorerAmount } from '../../../types' -import { TransactionCommonFields } from '../types' - -export interface Payment extends TransactionCommonFields { - Amount: Amount - DeliverMin?: Amount // TODO: Display this value somewhere - Destination: string - DestinationTag?: number - InvoiceId?: string // TODO: Display this value somewhere - SendMax?: Amount -} +import { ExplorerAmount } from '../../../types' export interface PaymentInstructions { partial: boolean diff --git a/src/containers/shared/components/Transaction/PaymentChannelClaim/Description.tsx b/src/containers/shared/components/Transaction/PaymentChannelClaim/Description.tsx index 40c59b96e..5841765fb 100644 --- a/src/containers/shared/components/Transaction/PaymentChannelClaim/Description.tsx +++ b/src/containers/shared/components/Transaction/PaymentChannelClaim/Description.tsx @@ -1,8 +1,8 @@ import { useTranslation } from 'react-i18next' +import type { PaymentChannelClaim } from 'xrpl' import { findNode, normalizeAmount } from '../../../transactionUtils' import { Account } from '../../Account' import { TransactionDescriptionProps } from '../types' -import { PaymentChannelClaim } from './types' import { useLanguage } from '../../../hooks' export const Description = ({ @@ -10,8 +10,8 @@ export const Description = ({ }: TransactionDescriptionProps) => { const { t } = useTranslation() const language = useLanguage() - const deleted = findNode(data, 'DeletedNode', 'PayChannel') - const modified = findNode(data, 'ModifiedNode', 'PayChannel') + const deleted = findNode(data.meta, 'DeletedNode', 'PayChannel') + const modified = findNode(data.meta, 'ModifiedNode', 'PayChannel') const node = deleted || modified const change = node && node.PreviousFields && node.PreviousFields.Balance diff --git a/src/containers/shared/components/Transaction/PaymentChannelClaim/parser.ts b/src/containers/shared/components/Transaction/PaymentChannelClaim/parser.ts index dd9fcbb6a..c57f3fa4f 100644 --- a/src/containers/shared/components/Transaction/PaymentChannelClaim/parser.ts +++ b/src/containers/shared/components/Transaction/PaymentChannelClaim/parser.ts @@ -1,18 +1,11 @@ -import type { Meta } from '../../../types' -import { PaymentChannelClaim, PaymentChannelClaimInstructions } from './types' +import type { PaymentChannelClaim, TransactionMetadata } from 'xrpl' +import { PaymentChannelClaimInstructions } from './types' import { formatAmount } from '../../../../../rippled/lib/txSummary/formatAmount' +import { findNode } from '../../../transactionUtils' const hasRenew = (flags: number): boolean => !!(0x00010000 & flags) const hasClose = (flags: number) => !!(0x00020000 & flags) -const findNode = (meta: Meta, nodeType: 'DeletedNode' | 'ModifiedNode') => { - const metaNode = meta.AffectedNodes.find( - (node: any) => - node[nodeType] && node[nodeType].LedgerEntryType === 'PayChannel', - ) - return metaNode ? metaNode[nodeType] : null -} - const getDetails = (node: any) => { const st = node.FinalFields.SourceTag ? `:${node.FinalFields.SourceTag}` : '' const dt = node.FinalFields.DestinationTag @@ -27,14 +20,14 @@ const getDetails = (node: any) => { export const parser = ( tx: PaymentChannelClaim, - meta: Meta, + meta: TransactionMetadata, ): PaymentChannelClaimInstructions => { - let node = findNode(meta, 'ModifiedNode') + let node = findNode(meta, 'ModifiedNode', 'PayChannel') const data: PaymentChannelClaimInstructions = { channel: tx.Channel, totalClaimed: tx.Balance ? formatAmount(tx.Balance) : undefined, - renew: hasRenew(tx.Flags || 0) || undefined, - close: hasClose(tx.Flags || 0) || undefined, + renew: hasRenew(typeof tx.Flags === 'number' ? tx.Flags : 0) || undefined, + close: hasClose(typeof tx.Flags === 'number' ? tx.Flags : 0) || undefined, } if (node) { @@ -53,7 +46,7 @@ export const parser = ( }) } - node = findNode(meta, 'DeletedNode') + node = findNode(meta, 'DeletedNode', 'PayChannel') if (node) { const details = getDetails(node) const returned = node.FinalFields.Amount - node.FinalFields.Balance diff --git a/src/containers/shared/components/Transaction/PaymentChannelClaim/types.ts b/src/containers/shared/components/Transaction/PaymentChannelClaim/types.ts index 9a1e53bf5..ef16c8fc0 100644 --- a/src/containers/shared/components/Transaction/PaymentChannelClaim/types.ts +++ b/src/containers/shared/components/Transaction/PaymentChannelClaim/types.ts @@ -1,12 +1,5 @@ -import { TransactionCommonFields } from '../types' import { ExplorerAmount } from '../../../types' -export interface PaymentChannelClaim extends TransactionCommonFields { - Channel: string - Balance: string - Amount: string -} - export interface PaymentChannelClaimInstructions { channelAmount?: ExplorerAmount claimed?: ExplorerAmount diff --git a/src/containers/shared/components/Transaction/PaymentChannelCreate/Description.tsx b/src/containers/shared/components/Transaction/PaymentChannelCreate/Description.tsx index 3d03ce9f3..813389254 100644 --- a/src/containers/shared/components/Transaction/PaymentChannelCreate/Description.tsx +++ b/src/containers/shared/components/Transaction/PaymentChannelCreate/Description.tsx @@ -1,11 +1,11 @@ import { useTranslation } from 'react-i18next' +import type { PaymentChannelCreate } from 'xrpl' import { localizeDate, localizeNumber } from '../../../utils' import { convertRippleDate } from '../../../../../rippled/lib/convertRippleDate' import { DATE_OPTIONS, findNode } from '../../../transactionUtils' import { Account } from '../../Account' import { useLanguage } from '../../../hooks' import { TransactionDescriptionProps } from '../types' -import { PaymentChannelCreate } from './types' import { Amount } from '../../Amount' export const Description = ({ @@ -18,7 +18,7 @@ export const Description = ({ tx.CancelAfter && localizeDate(convertRippleDate(tx.CancelAfter), language, DATE_OPTIONS) - const node = findNode(data, 'CreatedNode', 'PayChannel') + const node = findNode(data.meta, 'CreatedNode', 'PayChannel') return ( <> diff --git a/src/containers/shared/components/Transaction/PaymentChannelCreate/parser.ts b/src/containers/shared/components/Transaction/PaymentChannelCreate/parser.ts index fac621151..d428d3026 100644 --- a/src/containers/shared/components/Transaction/PaymentChannelCreate/parser.ts +++ b/src/containers/shared/components/Transaction/PaymentChannelCreate/parser.ts @@ -1,19 +1,12 @@ +import type { PaymentChannelCreate } from 'xrpl' import { convertRippleDate } from '../../../../../rippled/lib/convertRippleDate' import { formatAmount } from '../../../../../rippled/lib/txSummary/formatAmount' -import { PaymentChannelCreate } from './types' - -const findNode = (meta: any, nodeType: string) => { - const metaNode = meta.AffectedNodes.find( - (node: any) => - node[nodeType] && node[nodeType].LedgerEntryType === 'PayChannel', - ) - return metaNode ? metaNode[nodeType] : null -} +import { findNode } from '../../../transactionUtils' export const parser = (tx: PaymentChannelCreate, meta: any) => { const st = tx.SourceTag ? `:${tx.SourceTag}` : '' const dt = tx.DestinationTag ? `:${tx.DestinationTag}` : '' - const node = findNode(meta, 'CreatedNode') + const node = findNode(meta, 'CreatedNode', 'PayChannel') return { amount: formatAmount(tx.Amount), source: `${tx.Account}${st}`, diff --git a/src/containers/shared/components/Transaction/PaymentChannelCreate/types.ts b/src/containers/shared/components/Transaction/PaymentChannelCreate/types.ts index ff3422b8e..38ba5c1b9 100644 --- a/src/containers/shared/components/Transaction/PaymentChannelCreate/types.ts +++ b/src/containers/shared/components/Transaction/PaymentChannelCreate/types.ts @@ -1,15 +1,5 @@ -import { TransactionCommonFields } from '../types' import { ExplorerAmount } from '../../../types' -export interface PaymentChannelCreate extends TransactionCommonFields { - Amount: string - Destination: string - SettleDelay: number - PublicKey: string - CancelAfter?: number - DestinationTag?: number -} - export interface PaymentChannelCreateInstructions { amount: ExplorerAmount source: string diff --git a/src/containers/shared/components/Transaction/PaymentChannelFund/Description.tsx b/src/containers/shared/components/Transaction/PaymentChannelFund/Description.tsx index ec5b54d8b..6a3fbb5c6 100644 --- a/src/containers/shared/components/Transaction/PaymentChannelFund/Description.tsx +++ b/src/containers/shared/components/Transaction/PaymentChannelFund/Description.tsx @@ -1,10 +1,14 @@ import { useTranslation } from 'react-i18next' +import type { PaymentChannelFund } from 'xrpl' import { findNode } from '../../../transactionUtils' import { Amount } from '../../Amount' +import { TransactionDescriptionProps } from '../types' -export const Description = ({ data }: any) => { +export const Description = ({ + data, +}: TransactionDescriptionProps) => { const { t } = useTranslation() - const node = findNode(data, 'ModifiedNode', 'PayChannel') + const node = findNode(data.meta, 'ModifiedNode', 'PayChannel') return ( <> diff --git a/src/containers/shared/components/Transaction/PaymentChannelFund/parser.ts b/src/containers/shared/components/Transaction/PaymentChannelFund/parser.ts index 3fc1f5c46..511c8b87d 100644 --- a/src/containers/shared/components/Transaction/PaymentChannelFund/parser.ts +++ b/src/containers/shared/components/Transaction/PaymentChannelFund/parser.ts @@ -1,8 +1,11 @@ -import { PaymentChannelFund, PaymentChannelFundInstructions } from './types' -import { Meta } from '../../../types' +import type { PaymentChannelFund, TransactionMetadata } from 'xrpl' +import { PaymentChannelFundInstructions } from './types' import { formatAmount } from '../../../../../rippled/lib/txSummary/formatAmount' -const findNode = (meta: Meta, nodeType: 'DeletedNode' | 'ModifiedNode') => { +const findNode = ( + meta: TransactionMetadata, + nodeType: 'DeletedNode' | 'ModifiedNode', +) => { const metaNode = meta.AffectedNodes.find( (node) => node[nodeType] && node[nodeType].LedgerEntryType === 'PayChannel', ) @@ -22,7 +25,7 @@ const getDetails = (node: any): PaymentChannelFundInstructions => { export const parser = ( tx: PaymentChannelFund, - meta: Meta, + meta: TransactionMetadata, ): PaymentChannelFundInstructions => { const node = findNode(meta, 'ModifiedNode') const channel = { diff --git a/src/containers/shared/components/Transaction/PaymentChannelFund/types.ts b/src/containers/shared/components/Transaction/PaymentChannelFund/types.ts index 8e91862f5..9108b8f1f 100644 --- a/src/containers/shared/components/Transaction/PaymentChannelFund/types.ts +++ b/src/containers/shared/components/Transaction/PaymentChannelFund/types.ts @@ -1,11 +1,4 @@ import { ExplorerAmount } from '../../../types' -import { TransactionCommonFields } from '../types' - -export interface PaymentChannelFund extends TransactionCommonFields { - Channel: string - Balance: string - Amount: string -} export interface PaymentChannelFundInstructions { channelAmount?: ExplorerAmount diff --git a/src/containers/shared/components/Transaction/SetRegularKey/Description.tsx b/src/containers/shared/components/Transaction/SetRegularKey/Description.tsx index 659cba522..ec06da376 100644 --- a/src/containers/shared/components/Transaction/SetRegularKey/Description.tsx +++ b/src/containers/shared/components/Transaction/SetRegularKey/Description.tsx @@ -1,7 +1,10 @@ import { useTranslation } from 'react-i18next' +import type { SetRegularKey } from 'xrpl' import { TransactionDescriptionProps } from '../types' -export const Description = ({ data }: TransactionDescriptionProps) => { +export const Description = ({ + data, +}: TransactionDescriptionProps) => { const { t } = useTranslation() const key = data.tx.RegularKey diff --git a/src/containers/shared/components/Transaction/SetRegularKey/Simple.tsx b/src/containers/shared/components/Transaction/SetRegularKey/Simple.tsx index eeae9fe14..f1b4f8c63 100644 --- a/src/containers/shared/components/Transaction/SetRegularKey/Simple.tsx +++ b/src/containers/shared/components/Transaction/SetRegularKey/Simple.tsx @@ -1,9 +1,10 @@ import { useTranslation } from 'react-i18next' +import type { SetRegularKey } from 'xrpl' import { SimpleRow } from '../SimpleRow' import { TransactionSimpleProps } from '../types' -export const Simple = ({ data }: TransactionSimpleProps) => { - const { key } = data.instructions +export const Simple = ({ data }: TransactionSimpleProps) => { + const { RegularKey: key } = data.instructions const { t } = useTranslation() let label = '' let value = t('unset_regular_key') diff --git a/src/containers/shared/components/Transaction/SetRegularKey/TableDetail.tsx b/src/containers/shared/components/Transaction/SetRegularKey/TableDetail.tsx index c7cd8d16e..0e2d118f7 100644 --- a/src/containers/shared/components/Transaction/SetRegularKey/TableDetail.tsx +++ b/src/containers/shared/components/Transaction/SetRegularKey/TableDetail.tsx @@ -1,9 +1,12 @@ import { useTranslation } from 'react-i18next' +import type { SetRegularKey } from 'xrpl' import { TransactionTableDetailProps } from '../types' -export const TableDetail = ({ instructions }: TransactionTableDetailProps) => { +export const TableDetail = ({ + instructions, +}: TransactionTableDetailProps) => { const { t } = useTranslation() - const { key } = instructions + const { RegularKey: key } = instructions return key ? (
{t('regular_key')}: diff --git a/src/containers/shared/components/Transaction/SetRegularKey/index.ts b/src/containers/shared/components/Transaction/SetRegularKey/index.ts index dd56dc279..77330b53a 100644 --- a/src/containers/shared/components/Transaction/SetRegularKey/index.ts +++ b/src/containers/shared/components/Transaction/SetRegularKey/index.ts @@ -6,7 +6,6 @@ import { import { Simple } from './Simple' import { Description } from './Description' -import { parser } from './parser' import { TableDetail } from './TableDetail' export const SetRegularKeyTransaction: TransactionMapping = { @@ -15,5 +14,4 @@ export const SetRegularKeyTransaction: TransactionMapping = { TableDetail, action: TransactionAction.MODIFY, category: TransactionCategory.ACCOUNT, - parser, } diff --git a/src/containers/shared/components/Transaction/SetRegularKey/parser.ts b/src/containers/shared/components/Transaction/SetRegularKey/parser.ts deleted file mode 100644 index a6466810f..000000000 --- a/src/containers/shared/components/Transaction/SetRegularKey/parser.ts +++ /dev/null @@ -1,5 +0,0 @@ -export function parser(tx: any) { - return { - key: tx.RegularKey, - } -} diff --git a/src/containers/shared/components/Transaction/TicketCreate/Simple.tsx b/src/containers/shared/components/Transaction/TicketCreate/Simple.tsx index 935d1debe..f84766083 100644 --- a/src/containers/shared/components/Transaction/TicketCreate/Simple.tsx +++ b/src/containers/shared/components/Transaction/TicketCreate/Simple.tsx @@ -1,15 +1,18 @@ import { useTranslation } from 'react-i18next' +import type { TicketCreate } from 'xrpl' import { TransactionSimpleComponent, TransactionSimpleProps } from '../types' import { SimpleRow } from '../SimpleRow' -const Simple: TransactionSimpleComponent = (props: TransactionSimpleProps) => { +const Simple: TransactionSimpleComponent = ( + props: TransactionSimpleProps, +) => { const { t } = useTranslation() const { data } = props - const { ticketCount } = data.instructions + const { TicketCount } = data.instructions return ( - {ticketCount} + {TicketCount} ) } diff --git a/src/containers/shared/components/Transaction/TicketCreate/TableDetail.tsx b/src/containers/shared/components/Transaction/TicketCreate/TableDetail.tsx index 4b8242866..21eb0ac61 100644 --- a/src/containers/shared/components/Transaction/TicketCreate/TableDetail.tsx +++ b/src/containers/shared/components/Transaction/TicketCreate/TableDetail.tsx @@ -1,13 +1,16 @@ import { useTranslation } from 'react-i18next' +import type { TicketCreate } from 'xrpl' +import { TransactionTableDetailProps } from '../types' -export const TableDetail = (props: any) => { +export const TableDetail = ({ + instructions, +}: TransactionTableDetailProps) => { const { t } = useTranslation() - const { instructions } = props - const { ticketCount } = instructions + const { TicketCount } = instructions return (
{t('ticket_count')}: - {ticketCount} + {TicketCount}
) } diff --git a/src/containers/shared/components/Transaction/TicketCreate/index.ts b/src/containers/shared/components/Transaction/TicketCreate/index.ts index cbc40a75a..539594346 100644 --- a/src/containers/shared/components/Transaction/TicketCreate/index.ts +++ b/src/containers/shared/components/Transaction/TicketCreate/index.ts @@ -5,7 +5,6 @@ import { } from '../types' import { Simple } from './Simple' -import { parser } from './parser' import { TableDetail } from './TableDetail' export const TicketCreateTransaction: TransactionMapping = { @@ -13,5 +12,4 @@ export const TicketCreateTransaction: TransactionMapping = { TableDetail, action: TransactionAction.CREATE, category: TransactionCategory.ACCOUNT, - parser, } diff --git a/src/containers/shared/components/Transaction/TicketCreate/parser.ts b/src/containers/shared/components/Transaction/TicketCreate/parser.ts deleted file mode 100644 index 4768496ef..000000000 --- a/src/containers/shared/components/Transaction/TicketCreate/parser.ts +++ /dev/null @@ -1,8 +0,0 @@ -export function parser(tx: any) { - const ticketCount = tx.TicketCount - const ticketSequence = tx.TicketSequence - return { - ticketCount, - ticketSequence, - } -} diff --git a/src/containers/shared/components/Transaction/TrustSet/Description.tsx b/src/containers/shared/components/Transaction/TrustSet/Description.tsx index 30497d48f..96a52f471 100644 --- a/src/containers/shared/components/Transaction/TrustSet/Description.tsx +++ b/src/containers/shared/components/Transaction/TrustSet/Description.tsx @@ -1,8 +1,8 @@ import { Trans } from 'react-i18next' +import type { TrustSet } from 'xrpl' import { Account } from '../../Account' import { normalizeAmount } from '../../../transactionUtils' import { useLanguage } from '../../../hooks' -import { TrustSet } from './types' import { TransactionDescriptionProps } from '../types' export const Description = ({ diff --git a/src/containers/shared/components/Transaction/TrustSet/Simple.tsx b/src/containers/shared/components/Transaction/TrustSet/Simple.tsx index 02a00e3ca..4f7fa0015 100644 --- a/src/containers/shared/components/Transaction/TrustSet/Simple.tsx +++ b/src/containers/shared/components/Transaction/TrustSet/Simple.tsx @@ -1,18 +1,17 @@ import { useTranslation } from 'react-i18next' +import type { TrustSet } from 'xrpl' import { Amount } from '../../Amount' import { SimpleRow } from '../SimpleRow' import { TransactionSimpleProps } from '../types' -import { TrustSetInstructions } from './types' +import { formatAmount } from '../../../../../rippled/lib/txSummary/formatAmount' -export const Simple = ({ - data, -}: TransactionSimpleProps) => { +export const Simple = ({ data }: TransactionSimpleProps) => { const { t } = useTranslation() - const { limit } = data.instructions + const { LimitAmount } = data.instructions return ( - + ) } diff --git a/src/containers/shared/components/Transaction/TrustSet/TableDetail.tsx b/src/containers/shared/components/Transaction/TrustSet/TableDetail.tsx index 56ecc4094..26428e140 100644 --- a/src/containers/shared/components/Transaction/TrustSet/TableDetail.tsx +++ b/src/containers/shared/components/Transaction/TrustSet/TableDetail.tsx @@ -1,16 +1,17 @@ import { useTranslation } from 'react-i18next' +import type { TrustSet } from 'xrpl' import { TransactionTableDetailProps } from '../types' -import { TrustSetInstructions } from './types' import { Amount } from '../../Amount' +import { formatAmount } from '../../../../../rippled/lib/txSummary/formatAmount' export const TableDetail = ({ instructions, -}: TransactionTableDetailProps) => { +}: TransactionTableDetailProps) => { const { t } = useTranslation() return (
{t('set_limit')} - +
) } diff --git a/src/containers/shared/components/Transaction/TrustSet/index.ts b/src/containers/shared/components/Transaction/TrustSet/index.ts index 8529758a9..7e932b336 100644 --- a/src/containers/shared/components/Transaction/TrustSet/index.ts +++ b/src/containers/shared/components/Transaction/TrustSet/index.ts @@ -6,7 +6,6 @@ import { import { Simple } from './Simple' import { Description } from './Description' -import { parser } from './parser' import { TableDetail } from './TableDetail' export const TrustSetTransaction: TransactionMapping = { @@ -15,5 +14,4 @@ export const TrustSetTransaction: TransactionMapping = { TableDetail, action: TransactionAction.MODIFY, category: TransactionCategory.DEX, - parser, } diff --git a/src/containers/shared/components/Transaction/TrustSet/parser.ts b/src/containers/shared/components/Transaction/TrustSet/parser.ts deleted file mode 100644 index 60dbf87c0..000000000 --- a/src/containers/shared/components/Transaction/TrustSet/parser.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { formatAmount } from '../../../../../rippled/lib/txSummary/formatAmount' -import { TrustSet } from './types' - -export const parser = (tx: TrustSet) => ({ - limit: formatAmount(tx.LimitAmount), -}) diff --git a/src/containers/shared/components/Transaction/TrustSet/types.ts b/src/containers/shared/components/Transaction/TrustSet/types.ts deleted file mode 100644 index 022e2f4d7..000000000 --- a/src/containers/shared/components/Transaction/TrustSet/types.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { ExplorerAmount, IssuedCurrencyAmount } from '../../../types' -import { TransactionCommonFields } from '../types' - -export interface TrustSet extends TransactionCommonFields { - LimitAmount: IssuedCurrencyAmount -} - -export interface TrustSetInstructions { - limit: ExplorerAmount -} diff --git a/src/containers/shared/components/Transaction/types.ts b/src/containers/shared/components/Transaction/types.ts index 91bf44111..5f7009682 100644 --- a/src/containers/shared/components/Transaction/types.ts +++ b/src/containers/shared/components/Transaction/types.ts @@ -1,5 +1,6 @@ import { FC } from 'react' -import { Memo } from '../../types' +import type { Memo } from 'xrpl/dist/npm/models/common' +import type { TransactionMetadata } from 'xrpl' export enum TransactionCategory { DEX = 'DEX', @@ -25,7 +26,7 @@ export interface TransactionTableDetailProps { } export type TransactionTableDetailComponent = FC -export interface TransactionDescriptionProps { +export interface TransactionDescriptionProps { data: { tx: T meta: M @@ -45,7 +46,7 @@ export interface TransactionMapping { Description?: TransactionDescriptionComponent Simple: TransactionSimpleComponent TableDetail?: TransactionTableDetailComponent - parser: TransactionParser + parser?: TransactionParser action: TransactionAction category: TransactionCategory } diff --git a/src/containers/shared/transactionUtils.ts b/src/containers/shared/transactionUtils.ts index 3d85d8996..6f7bd6f1b 100644 --- a/src/containers/shared/transactionUtils.ts +++ b/src/containers/shared/transactionUtils.ts @@ -1,4 +1,11 @@ -import { IssuedCurrencyAmount, Transaction, Node } from './types' +import type { TransactionMetadata } from 'xrpl' +import type { + CreatedNode, + DeletedNode, + ModifiedNode, + Node, +} from 'xrpl/dist/npm/models/transactions/metadata' +import { IssuedCurrencyAmount, Transaction } from './types' import { localizeNumber, CURRENCY_OPTIONS } from './utils' export const RIPPLE_EPOCH = 946684800 @@ -127,17 +134,21 @@ export const DATE_OPTIONS = { } export function groupAffectedNodes(trans: Transaction) { - const group: Record = { + const group: { + created: CreatedNode['CreatedNode'][] + deleted: DeletedNode['DeletedNode'][] + modified: ModifiedNode['ModifiedNode'][] + } = { created: [], modified: [], deleted: [], } ;(trans.meta.AffectedNodes || []).forEach((node) => { - if (node.DeletedNode) { + if ('DeletedNode' in node && node.DeletedNode) { group.deleted.push(node.DeletedNode) - } else if (node.ModifiedNode) { + } else if ('ModifiedNode' in node && node.ModifiedNode) { group.modified.push(node.ModifiedNode) - } else if (node.CreatedNode) { + } else if ('CreatedNode' in node && node.CreatedNode) { group.created.push(node.CreatedNode) } }) @@ -160,15 +171,15 @@ export function buildMemos(trans: Transaction) { const { Memos = [] } = trans.tx const memoList: string[] = [] Memos.forEach((data) => { - if (hexMatch.test(data.Memo.MemoType)) { + if (data.Memo.MemoType && hexMatch.test(data.Memo.MemoType)) { memoList.push(decodeHex(data.Memo.MemoType)) } - if (hexMatch.test(data.Memo.MemoData)) { + if (data.Memo.MemoData && hexMatch.test(data.Memo.MemoData)) { memoList.push(decodeHex(data.Memo.MemoData)) } - if (hexMatch.test(data.Memo.MemoFormat)) { + if (data.Memo.MemoFormat && hexMatch.test(data.Memo.MemoFormat)) { memoList.push(decodeHex(data.Memo.MemoFormat)) } }) @@ -235,12 +246,13 @@ export function normalizeAmount( } export function findNode( - transaction: Transaction, - nodeType: keyof Node, + meta: TransactionMetadata, + nodeType: 'DeletedNode' | 'CreatedNode' | 'ModifiedNode', entryType: string, ): any { - const metaNode = transaction.meta.AffectedNodes.find( - (node) => node[nodeType] && node[nodeType].LedgerEntryType === entryType, + const metaNode = meta.AffectedNodes.find( + (node: Node) => + node[nodeType] && node[nodeType].LedgerEntryType === entryType, ) return metaNode ? metaNode[nodeType] : null } diff --git a/src/containers/shared/types.ts b/src/containers/shared/types.ts index ed000ac27..877de0c0b 100644 --- a/src/containers/shared/types.ts +++ b/src/containers/shared/types.ts @@ -1,3 +1,6 @@ +import type { TransactionMetadata } from 'xrpl' +import type { Memo } from 'xrpl/dist/npm/models/common' + export interface IssuedCurrency { currency: string issuer: string @@ -21,25 +24,6 @@ export type ExplorerAmount = { amount: number } -export interface Node { - DeletedNode?: any - ModifiedNode?: any - CreatedNode?: any - LedgerEntryType: string -} - -export interface Meta { - AffectedNodes: Node[] -} - -export interface Memo { - Memo: { - MemoType: string - MemoData: string - MemoFormat: string - } -} - export interface Tx { Memos?: Memo[] TransactionType: string @@ -47,7 +31,7 @@ export interface Tx { } export interface Transaction { - meta: Meta + meta: TransactionMetadata tx: Tx } diff --git a/src/rippled/lib/txSummary/index.js b/src/rippled/lib/txSummary/index.js index 2a83c0fd0..b20027a3a 100644 --- a/src/rippled/lib/txSummary/index.js +++ b/src/rippled/lib/txSummary/index.js @@ -3,7 +3,8 @@ import { defaultParser } from '../../../containers/shared/components/Transaction const getInstructions = (tx, meta) => { const type = tx.TransactionType - return transactionTypes[type]?.parser(tx, meta) || defaultParser(tx, meta) + const parser = transactionTypes[type]?.parser || defaultParser + return parser(tx, meta) } const summarizeTransaction = (d, details = false) => ({