From 53bd7cfb7abc2201fa2760548bff20a58ec798df Mon Sep 17 00:00:00 2001 From: ohager Date: Thu, 9 Mar 2023 10:21:01 -0300 Subject: [PATCH 1/4] fix: fixed #63 --- package.json | 5 +- .../SignumP2PMessages/P2PMessageItem.tsx | 6 +-- yarn.lock | 51 +------------------ 3 files changed, 5 insertions(+), 57 deletions(-) diff --git a/package.json b/package.json index e6c9c79..c2b2c86 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,6 @@ "prepare": "husky install" }, "dependencies": { - "@babel/eslint-parser": "^7.17.0", "@braintree/sanitize-url": "^6.0.2", "@dicebear/avatars": "4.2.5", "@dicebear/avatars-bottts-sprites": "4.2.5", @@ -45,7 +44,6 @@ "clsx": "1.1.1", "constate": "2.0.0", "date-fns": "2.15.0", - "debounce-promise": "3.1.2", "dexie": "3.1.0-beta.13", "effector": "21.2.0", "fast-deep-equal": "3.1.3", @@ -54,8 +52,6 @@ "hashicon": "^0.3.0", "inter-ui": "3.13.1", "micro-memoize": "4.0.9", - "node-forge": "0.10.0", - "p-memoize": "4.0.3", "react": "^17.0.2", "react-dom": "16.13.1", "react-hook-form": "5.3.1", @@ -75,6 +71,7 @@ "webextension-polyfill": "^0.8.0" }, "devDependencies": { + "@babel/eslint-parser": "^7.17.0", "@babel/core": "^7.17.2", "@babel/preset-env": "^7.16.11", "@peculiar/webcrypto": "1.1.6", diff --git a/src/app/templates/SignumP2PMessages/P2PMessageItem.tsx b/src/app/templates/SignumP2PMessages/P2PMessageItem.tsx index 13ecaeb..4289899 100644 --- a/src/app/templates/SignumP2PMessages/P2PMessageItem.tsx +++ b/src/app/templates/SignumP2PMessages/P2PMessageItem.tsx @@ -32,9 +32,9 @@ const P2PMessageItem = memo(({ accountId, message }) => { const dateFnsLocale = getDateFnsLocale(); const isPending = message.blockTimestamp === undefined; - const isEncrypted = message.attachment.encryptedMessage; - const plainMessage = message.attachment.message; - const isReceivedMessage = message.sender !== accountId; + const isEncrypted = message.attachment && message.attachment.encryptedMessage; + const plainMessage = message.attachment ? message.attachment.message : ''; + const isReceivedMessage = message.sender !== accountId || message.sender === message.recipient; const transactionStatus = useMemo(() => { const content = isPending ? 'pending' : 'applied'; diff --git a/yarn.lock b/yarn.lock index fe67729..84bd3c0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3527,11 +3527,6 @@ date-fns@^2.16.1: resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.28.0.tgz#9570d656f5fc13143e50c975a3b6bbeb46cd08b2" integrity sha512-8d35hViGYx/QH0icHYCeLmsLmMUheMmTyV9Fcm6gvNwdw31yXXH+O85sOBJ+OLnLQMKZowvpKb6FgMIQjcpvQw== -debounce-promise@3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/debounce-promise/-/debounce-promise-3.1.2.tgz#320fb8c7d15a344455cd33cee5ab63530b6dc7c5" - integrity sha512-rZHcgBkbYavBeD9ej6sP56XfG53d51CD4dnaw989YX/nZ/ZJfgRx/9ePKmTNiUiyQvh4mtrMoS3OAWW+yoYtpg== - debug@4, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1: version "4.3.3" resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.3.tgz#04266e0b70a98d4462e6e288e38259213332b664" @@ -6263,13 +6258,6 @@ makeerror@1.0.12: dependencies: tmpl "1.0.5" -map-age-cleaner@^0.1.3: - version "0.1.3" - resolved "https://registry.yarnpkg.com/map-age-cleaner/-/map-age-cleaner-0.1.3.tgz#7d583a7306434c055fe474b0f45078e6e1b4b92a" - integrity sha512-bJzx6nMoP6PDLPBFmg7+xRKeFZvFboMrGlxmNj9ClvX53KrmvM5bXFXEWjbz4cz1AFn+jWJ9z/DJSz7hrs0w3w== - dependencies: - p-defer "^1.0.0" - map-cache@^0.2.2: version "0.2.2" resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf" @@ -6371,11 +6359,6 @@ mimic-fn@^2.1.0: resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== -mimic-fn@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-3.1.0.tgz#65755145bbf3e36954b949c16450427451d5ca74" - integrity sha512-Ysbi9uYW9hFyfrThdDEQuykN4Ey6BuwPD2kpI5ES/nFTDn/98yxYNLZJcgUAKPT/mcrLLKaGzJR9YVxJrIdASQ== - mimic-fn@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-4.0.0.tgz#60a90550d5cb0b239cca65d893b1a53b29871ecc" @@ -6525,11 +6508,6 @@ node-fetch@^1.0.1: encoding "^0.1.11" is-stream "^1.0.1" -node-forge@0.10.0: - version "0.10.0" - resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-0.10.0.tgz#32dea2afb3e9926f02ee5ce8794902691a676bf3" - integrity sha512-PPmu8eEeG9saEUvI97fm4OYxXVB6bFvyNTyiUOBichBpFG8A1Ljw3bY62+5oOjDEMHRnd0Y7HQ+x7uzxOzC6JA== - node-int64@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b" @@ -6798,11 +6776,6 @@ os-tmpdir@~1.0.2: resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" integrity sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ= -p-defer@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/p-defer/-/p-defer-1.0.0.tgz#9f6eb182f6c9aa8cd743004a7d4f96b196b0fb0c" - integrity sha1-n26xgvbJqozXQwBKfU+WsZaw+ww= - p-each-series@^2.1.0: version "2.2.0" resolved "https://registry.yarnpkg.com/p-each-series/-/p-each-series-2.2.0.tgz#105ab0357ce72b202a8a8b94933672657b5e2a9a" @@ -6820,7 +6793,7 @@ p-limit@^1.1.0: dependencies: p-try "^1.0.0" -p-limit@^2.0.0, p-limit@^2.2.0, p-limit@^2.2.2: +p-limit@^2.0.0, p-limit@^2.2.0: version "2.3.0" resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1" integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w== @@ -6855,28 +6828,6 @@ p-map@^4.0.0: dependencies: aggregate-error "^3.0.0" -p-memoize@4.0.3: - version "4.0.3" - resolved "https://registry.yarnpkg.com/p-memoize/-/p-memoize-4.0.3.tgz#9f3b9965f1fd79dadc2e6ec957c1b43c410a6f99" - integrity sha512-lX9GfP1NT5jheKsmvc1071L74/Vw7vul+uZEnst7LNuMtbKlWYwKItqcLSAVUyJnrfQAqFFCJQ5bt0whrDsWQA== - dependencies: - map-age-cleaner "^0.1.3" - mimic-fn "^3.0.0" - p-settle "^4.1.1" - -p-reflect@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/p-reflect/-/p-reflect-2.1.0.tgz#5d67c7b3c577c4e780b9451fc9129675bd99fe67" - integrity sha512-paHV8NUz8zDHu5lhr/ngGWQiW067DK/+IbJ+RfZ4k+s8y4EKyYCz8pGYWjxCg35eHztpJAt+NUgvN4L+GCbPlg== - -p-settle@^4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/p-settle/-/p-settle-4.1.1.tgz#37fbceb2b02c9efc28658fc8d36949922266035f" - integrity sha512-6THGh13mt3gypcNMm0ADqVNCcYa3BK6DWsuJWFCuEKP1rpY+OKGp7gaZwVmLspmic01+fsg/fN57MfvDzZ/PuQ== - dependencies: - p-limit "^2.2.2" - p-reflect "^2.1.0" - p-try@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3" From 624ba837c7c6fa7f93e93205cc51cb5dd96f9008 Mon Sep 17 00:00:00 2001 From: ohager Date: Thu, 9 Mar 2023 11:01:40 -0300 Subject: [PATCH 2/4] feat: added transfer token ownership in tx list --- package.json | 10 +-- public/_locales/de/messages.json | 3 + public/_locales/en/messages.json | 3 + public/_locales/es/messages.json | 3 + public/_locales/pt_BR/messages.json | 3 + public/_locales/ru/messages.json | 3 + public/_locales/th/messages.json | 3 + public/_locales/uk/messages.json | 3 + src/lib/temple/activity/parseTransaction.ts | 9 +++ .../temple/front/parseSignumTransaction.ts | 14 +++- yarn.lock | 67 ++++++++++--------- 11 files changed, 81 insertions(+), 40 deletions(-) diff --git a/package.json b/package.json index c2b2c86..8d8025f 100644 --- a/package.json +++ b/package.json @@ -33,11 +33,11 @@ "@dicebear/avatars-jdenticon-sprites": "4.2.5", "@popperjs/core": "2.4.4", "@serh11p/jest-webextension-mock": "4.0.0", - "@signumjs/core": "^1.0.0-rc.53", - "@signumjs/crypto": "^1.0.0-rc.53", - "@signumjs/http": "^1.0.0-rc.53", - "@signumjs/standards": "^1.0.0-rc.53", - "@signumjs/util": "^1.0.0-rc.53", + "@signumjs/core": "^1.0.0-rc.58", + "@signumjs/crypto": "^1.0.0-rc.58", + "@signumjs/http": "^1.0.0-rc.58", + "@signumjs/standards": "^1.0.0-rc.58", + "@signumjs/util": "^1.0.0-rc.58", "async-retry": "1.3.1", "bignumber.js": "9.0.1", "buffer": "5.6.0", diff --git a/public/_locales/de/messages.json b/public/_locales/de/messages.json index e924208..cff7dcd 100644 --- a/public/_locales/de/messages.json +++ b/public/_locales/de/messages.json @@ -1988,5 +1988,8 @@ }, "transferToMany": { "message": "an viele" + }, + "transferOwnership": { + "message": "Token-Besitz übertragen" } } diff --git a/public/_locales/en/messages.json b/public/_locales/en/messages.json index d4351f6..bd58ebe 100644 --- a/public/_locales/en/messages.json +++ b/public/_locales/en/messages.json @@ -1988,5 +1988,8 @@ }, "sendToAddress": { "message": "Send Signa to this Address" + }, + "transferOwnership": { + "message": "Transfer Token Ownership" } } diff --git a/public/_locales/es/messages.json b/public/_locales/es/messages.json index 6b58e48..d5da65c 100644 --- a/public/_locales/es/messages.json +++ b/public/_locales/es/messages.json @@ -1988,5 +1988,8 @@ }, "transferToMany": { "message": "demasiados" + }, + "transferOwnership": { + "message": "Transferir la propiedad del token" } } diff --git a/public/_locales/pt_BR/messages.json b/public/_locales/pt_BR/messages.json index fedea55..59043b3 100644 --- a/public/_locales/pt_BR/messages.json +++ b/public/_locales/pt_BR/messages.json @@ -1988,5 +1988,8 @@ }, "transferToMany": { "message": "para várias" + }, + "transferOwnership": { + "message": "Transferir propriedade de token" } } diff --git a/public/_locales/ru/messages.json b/public/_locales/ru/messages.json index 2f90fce..5d6f500 100644 --- a/public/_locales/ru/messages.json +++ b/public/_locales/ru/messages.json @@ -1988,5 +1988,8 @@ }, "transferToMany": { "message": "слишком много" + }, + "transferOwnership": { + "message": "Передача владения токеном" } } diff --git a/public/_locales/th/messages.json b/public/_locales/th/messages.json index 820fc57..e27323e 100644 --- a/public/_locales/th/messages.json +++ b/public/_locales/th/messages.json @@ -1988,5 +1988,8 @@ }, "transferToMany": { "message": "มากมาย" + }, + "transferOwnership": { + "message": "โอนกรรมสิทธิ์โทเค็น" } } diff --git a/public/_locales/uk/messages.json b/public/_locales/uk/messages.json index 0e2e804..80b25f3 100644 --- a/public/_locales/uk/messages.json +++ b/public/_locales/uk/messages.json @@ -1988,5 +1988,8 @@ }, "transferToMany": { "message": "забагато" + }, + "transferOwnership": { + "message": "Передача права власності на токени" } } diff --git a/src/lib/temple/activity/parseTransaction.ts b/src/lib/temple/activity/parseTransaction.ts index 724b429..84cb29e 100644 --- a/src/lib/temple/activity/parseTransaction.ts +++ b/src/lib/temple/activity/parseTransaction.ts @@ -107,6 +107,9 @@ function isContractTransaction(tx: Transaction): boolean { function isAddTreasuryAccount(tx: Transaction) { return tx.type === TransactionType.Asset && tx.subtype === TransactionAssetSubtype.AssetAddTreasureyAccount; } +function isTokenTransferOwnership(tx: Transaction) { + return tx.type === TransactionType.Asset && tx.subtype === TransactionAssetSubtype.AssetTransferOwnership; +} export function parseTransaction(tx: Transaction, accountId: string, accountPrefix: string): TransactionItem { // @ts-ignore @@ -150,6 +153,12 @@ export function parseTransaction(tx: Transaction, accountId: string, accountPref item.prefix = '🏦'; // @ts-ignore item.name = 'addTreasuryAccount'; + } else if (isTokenTransferOwnership(tx)) { + item.type = TransactionItemType.Other; + // @ts-ignore + item.prefix = '➡🪙'; + // @ts-ignore + item.name = 'transferOwnership'; } else { item.type = TransactionItemType.Other; // TODO: name the type more precisely diff --git a/src/lib/temple/front/parseSignumTransaction.ts b/src/lib/temple/front/parseSignumTransaction.ts index 8244512..c5d0e5c 100644 --- a/src/lib/temple/front/parseSignumTransaction.ts +++ b/src/lib/temple/front/parseSignumTransaction.ts @@ -77,7 +77,11 @@ function isTransactionToSelf(tx: Transaction): boolean { } async function eventuallyResolveTokenId(signum: Ledger, jsonTx: Transaction) { - if (jsonTx.type === TransactionType.Asset && jsonTx.subtype === TransactionAssetSubtype.AssetAddTreasureyAccount) { + if ( + jsonTx.type === TransactionType.Asset && + (jsonTx.subtype === TransactionAssetSubtype.AssetAddTreasureyAccount || + jsonTx.subtype === TransactionAssetSubtype.AssetTransferOwnership) + ) { try { const tx = await signum.service.query('getTransaction', { fullHash: jsonTx.referencedTransactionFullHash @@ -89,7 +93,6 @@ async function eventuallyResolveTokenId(signum: Ledger, jsonTx: Transaction) { return Promise.resolve(undefined); } } - return Promise.resolve(undefined); } @@ -309,6 +312,7 @@ function parseAssetExpenses(tx: Transaction, resolvedTokenId?: string): ParsedTr quantity: new BigNumber(tx.attachment.quantityQNT) } ]; + case TransactionAssetSubtype.AssetTransferOwnership: case TransactionAssetSubtype.AssetAddTreasureyAccount: return [ { @@ -448,6 +452,12 @@ function parseAssetSubType(tx: Transaction): ParsedTransactionType { textIcon: '🏦', hasAmount: false }; + case TransactionAssetSubtype.AssetTransferOwnership: + return { + i18nKey: 'transferOwnership', + textIcon: '➡🪙', + hasAmount: false + }; } return throwInappropriateTransactionType(); } diff --git a/yarn.lock b/yarn.lock index 84bd3c0..11dd629 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1471,27 +1471,28 @@ resolved "https://registry.yarnpkg.com/@serh11p/jest-webextension-mock/-/jest-webextension-mock-4.0.0.tgz#c3b2a00e8c758e156a4a922718b35183e9023af9" integrity sha512-SQDFFOJGwQpaPopzYkFgzdDdi8tL8US/XM2UjBu4rmLLztTI/wOSecwXj/i3lhOUwOs3bHO2Zz9eRu2rPy5p9A== -"@signumjs/contracts@^1.0.0-rc.53": - version "1.0.0-rc.53" - resolved "https://registry.yarnpkg.com/@signumjs/contracts/-/contracts-1.0.0-rc.53.tgz#43e51fc09ae4ada29880fb74a8902d87e8c7ea81" - integrity sha512-0gsRBD4HTIcCiMvfpnIN1OmMuRletu53JiKeOHufLOudcDAuB9qrT8V4itjvoKLcOREqOqQ+qqCZ/HrxtVETxw== - dependencies: - "@signumjs/util" "^1.0.0-rc.53" - -"@signumjs/core@^1.0.0-rc.53": - version "1.0.0-rc.53" - resolved "https://registry.yarnpkg.com/@signumjs/core/-/core-1.0.0-rc.53.tgz#d025a9298eff1498d99706c9047311a93178ba55" - integrity sha512-RPopcqKurblGZI03vkIWDiulL9bsHD/uyOUPDJGJvsMzNi/DxDGMAcmOJVXpfRSF9IYlzQdhu6RVebrseyh5Aw== - dependencies: - "@signumjs/contracts" "^1.0.0-rc.53" - "@signumjs/crypto" "^1.0.0-rc.53" - "@signumjs/http" "^1.0.0-rc.53" - "@signumjs/util" "^1.0.0-rc.53" +"@signumjs/contracts@^1.0.0-rc.58": + version "1.0.0-rc.58" + resolved "https://registry.yarnpkg.com/@signumjs/contracts/-/contracts-1.0.0-rc.58.tgz#0cd9125be285daef37ef6753b3d6740dea82e716" + integrity sha512-+rDMm6IicOaln1QsKHHSQvZ2DG1tgj9y+NWKr++TS9dPRfHcg7k9tAYl4JlKqNNOtgSfWaOY78N0gYXbC6gstg== + dependencies: + "@signumjs/util" "^1.0.0-rc.58" + +"@signumjs/core@^1.0.0-rc.58": + version "1.0.0-rc.58" + resolved "https://registry.yarnpkg.com/@signumjs/core/-/core-1.0.0-rc.58.tgz#2ff301e659b0ca4a11f7854d06557a8dc9531160" + integrity sha512-LZYTymCXKDIoFI3TEbTgiHzmZqTIC8Chju88xikMiCRRwtH5tZCq3myAqcp4sibJOeyvucWt8uJLZlhYBlJ7Kw== + dependencies: + "@signumjs/contracts" "^1.0.0-rc.58" + "@signumjs/crypto" "^1.0.0-rc.58" + "@signumjs/http" "^1.0.0-rc.58" + "@signumjs/util" "^1.0.0-rc.58" + bignumber.js "^9.0.0" -"@signumjs/crypto@^1.0.0-rc.53": - version "1.0.0-rc.53" - resolved "https://registry.yarnpkg.com/@signumjs/crypto/-/crypto-1.0.0-rc.53.tgz#beb30096a1d3a11d2f7159068990697fbafdab4d" - integrity sha512-kSSr2aQK7gXpZu/4o0J5JRS+urwpKiAYaWTw7R++x8uyWScWRClM9OWXsAee+jYhVEf9RXDgaDzYL/qNDyRIug== +"@signumjs/crypto@^1.0.0-rc.58": + version "1.0.0-rc.58" + resolved "https://registry.yarnpkg.com/@signumjs/crypto/-/crypto-1.0.0-rc.58.tgz#cbe20b86f93d95fd7861e510e99a7c5da0289310" + integrity sha512-qVnRbGN9cMyg/rYUW1EWKmesAVYVMCT08HanO5kM1+yEJlFBxWCyTuhvC6LDtl17MdtFpbijuRmuUbADBkmtzQ== dependencies: "@types/crypto-js" "^3.1.43" "@types/node" "^12.0.0" @@ -1501,25 +1502,25 @@ pako "^1.0.10" seedrandom "^3.0.5" -"@signumjs/http@^1.0.0-rc.53": - version "1.0.0-rc.53" - resolved "https://registry.yarnpkg.com/@signumjs/http/-/http-1.0.0-rc.53.tgz#f669733e72248d2b89fafa7c34ae03d11a2c136a" - integrity sha512-zt/r7leMdaUyjj+NBinsnO6ARXMwDxUQe/VA7OJ41N/d5tH3MFaEQsyP7YnN5vm8BRFLNFkazON6u5cNhPxQMQ== +"@signumjs/http@^1.0.0-rc.58": + version "1.0.0-rc.58" + resolved "https://registry.yarnpkg.com/@signumjs/http/-/http-1.0.0-rc.58.tgz#23d5896a816d23ef0afb93ba0ec6820f627892d0" + integrity sha512-RXBmMYY4tetBpgFRP2qHMx9sCUqh+v6hD8iMbgTnVgaggp0049YR1e9S5qpmWiDbly/V0LL2kaMjyATfInrHSA== dependencies: axios "^0.21.4" -"@signumjs/standards@^1.0.0-rc.53": - version "1.0.0-rc.53" - resolved "https://registry.yarnpkg.com/@signumjs/standards/-/standards-1.0.0-rc.53.tgz#74964a29d6f4f3492ab4f02a05e87d498a9c2b18" - integrity sha512-cWR1j9UXxYjJF0fYmrO4ZuCrx1/bHQseNgUia5CBS3Mf6vxQJG/cnCuAaNdBQ5ZbiGcZGYWiiVBrCue93k0+dw== +"@signumjs/standards@^1.0.0-rc.58": + version "1.0.0-rc.58" + resolved "https://registry.yarnpkg.com/@signumjs/standards/-/standards-1.0.0-rc.58.tgz#e26bc52a121b666d8835217713bed08a28150dbb" + integrity sha512-yx02abKwXe45aBgLrg3GbWcRzSUFZyutbGFaf0kwp9nDMrC3f0dSsdIa3HiAmXvw7RTBXfJh+VNVxCsYnd9PMw== dependencies: "@braintree/sanitize-url" "^6.0.1" - "@signumjs/core" "^1.0.0-rc.53" + "@signumjs/core" "^1.0.0-rc.58" -"@signumjs/util@^1.0.0-rc.53": - version "1.0.0-rc.53" - resolved "https://registry.yarnpkg.com/@signumjs/util/-/util-1.0.0-rc.53.tgz#7987e5cc0b21070d26e35a9c5135e1bddd6220e9" - integrity sha512-/jZf2RGBI6uKegypARMmo1c5kaV7Qj2hWckCE5veToVJQW7PRygv2+7kT164lmYoDPgM2JDRlf5xTMJ5l492vg== +"@signumjs/util@^1.0.0-rc.58": + version "1.0.0-rc.58" + resolved "https://registry.yarnpkg.com/@signumjs/util/-/util-1.0.0-rc.58.tgz#718d1ff2b4607bbb8ad6f08b63bd4da86b9a6a20" + integrity sha512-nS+U6nTwUqy5eaDVPBsjud1Vag3SB6/ENxufrlv9kebu5v6C4mFdApq18+zl99AdJdF1Y4jVmiKxtohJP6XkTw== dependencies: bignumber.js "^9.0.0" js-base64 "^3.6.0" From f0584b70e5952b5bc88d8ab7578a1a79dea09c19 Mon Sep 17 00:00:00 2001 From: ohager Date: Thu, 9 Mar 2023 11:30:21 -0300 Subject: [PATCH 3/4] feat: added create/cancel subscription to tx list --- public/_locales/de/messages.json | 6 ++++++ public/_locales/en/messages.json | 6 ++++++ public/_locales/es/messages.json | 6 ++++++ public/_locales/pt_BR/messages.json | 6 ++++++ public/_locales/ru/messages.json | 6 ++++++ public/_locales/th/messages.json | 6 ++++++ public/_locales/uk/messages.json | 6 ++++++ src/lib/temple/activity/parseTransaction.ts | 19 +++++++++++++++++++ 8 files changed, 61 insertions(+) diff --git a/public/_locales/de/messages.json b/public/_locales/de/messages.json index cff7dcd..e4426d6 100644 --- a/public/_locales/de/messages.json +++ b/public/_locales/de/messages.json @@ -1991,5 +1991,11 @@ }, "transferOwnership": { "message": "Token-Besitz übertragen" + }, + "subscriptionCancellation": { + "message": "Abonnement beenden" + }, + "subscriptionCreation": { + "message": "Abonnement erstellen" } } diff --git a/public/_locales/en/messages.json b/public/_locales/en/messages.json index bd58ebe..a75a756 100644 --- a/public/_locales/en/messages.json +++ b/public/_locales/en/messages.json @@ -1991,5 +1991,11 @@ }, "transferOwnership": { "message": "Transfer Token Ownership" + }, + "subscriptionCreation": { + "message": "Create Subscription" + }, + "subscriptionCancellation": { + "message": "Cancel Subscription" } } diff --git a/public/_locales/es/messages.json b/public/_locales/es/messages.json index d5da65c..eff99d9 100644 --- a/public/_locales/es/messages.json +++ b/public/_locales/es/messages.json @@ -1991,5 +1991,11 @@ }, "transferOwnership": { "message": "Transferir la propiedad del token" + }, + "subscriptionCancellation": { + "message": "Cancelar suscripción" + }, + "subscriptionCreation": { + "message": "Crear suscripción" } } diff --git a/public/_locales/pt_BR/messages.json b/public/_locales/pt_BR/messages.json index 59043b3..4803fa6 100644 --- a/public/_locales/pt_BR/messages.json +++ b/public/_locales/pt_BR/messages.json @@ -1991,5 +1991,11 @@ }, "transferOwnership": { "message": "Transferir propriedade de token" + }, + "subscriptionCancellation": { + "message": "Cancelar assinatura" + }, + "subscriptionCreation": { + "message": "Criar assinatura" } } diff --git a/public/_locales/ru/messages.json b/public/_locales/ru/messages.json index 5d6f500..aebdb29 100644 --- a/public/_locales/ru/messages.json +++ b/public/_locales/ru/messages.json @@ -1991,5 +1991,11 @@ }, "transferOwnership": { "message": "Передача владения токеном" + }, + "subscriptionCancellation": { + "message": "Отменить подписку" + }, + "subscriptionCreation": { + "message": "Создать подписку" } } diff --git a/public/_locales/th/messages.json b/public/_locales/th/messages.json index e27323e..c31e9e6 100644 --- a/public/_locales/th/messages.json +++ b/public/_locales/th/messages.json @@ -1991,5 +1991,11 @@ }, "transferOwnership": { "message": "โอนกรรมสิทธิ์โทเค็น" + }, + "subscriptionCancellation": { + "message": "ยกเลิกการสมัครสมาชิก" + }, + "subscriptionCreation": { + "message": "สร้างการสมัครสมาชิก" } } diff --git a/public/_locales/uk/messages.json b/public/_locales/uk/messages.json index 80b25f3..3af6f15 100644 --- a/public/_locales/uk/messages.json +++ b/public/_locales/uk/messages.json @@ -1991,5 +1991,11 @@ }, "transferOwnership": { "message": "Передача права власності на токени" + }, + "subscriptionCancellation": { + "message": "Скасувати підписку" + }, + "subscriptionCreation": { + "message": "Створити підписку" } } diff --git a/src/lib/temple/activity/parseTransaction.ts b/src/lib/temple/activity/parseTransaction.ts index 84cb29e..9ad7f97 100644 --- a/src/lib/temple/activity/parseTransaction.ts +++ b/src/lib/temple/activity/parseTransaction.ts @@ -27,6 +27,13 @@ function isDistribution(tx: Transaction): boolean { return tx.type === TransactionType.Asset && tx.subtype === TransactionAssetSubtype.AssetDistributeToHolders; } +function isSubscriptionCreation(tx: Transaction): boolean { + return tx.type === TransactionType.Escrow && tx.subtype === TransactionEscrowSubtype.SubscriptionSubscribe; +} +function isSubscriptionCancellation(tx: Transaction): boolean { + return tx.type === TransactionType.Escrow && tx.subtype === TransactionEscrowSubtype.SubscriptionCancel; +} + function isBurn(tx: Transaction): boolean { return ( !tx.recipient && @@ -159,6 +166,18 @@ export function parseTransaction(tx: Transaction, accountId: string, accountPref item.prefix = '➡🪙'; // @ts-ignore item.name = 'transferOwnership'; + } else if (isSubscriptionCreation(tx)) { + item.type = TransactionItemType.Other; + // @ts-ignore + item.prefix = '🕖✨'; + // @ts-ignore + item.name = 'subscriptionCreation'; + } else if (isSubscriptionCancellation(tx)) { + item.type = TransactionItemType.Other; + // @ts-ignore + item.prefix = '❌🕖'; + // @ts-ignore + item.name = 'subscriptionCreation'; } else { item.type = TransactionItemType.Other; // TODO: name the type more precisely From 5e39a9b84b84ff8c3c4d5162d6efeb2a3bb2784d Mon Sep 17 00:00:00 2001 From: ohager Date: Thu, 9 Mar 2023 15:42:42 -0300 Subject: [PATCH 4/4] feat: added more types on sign view --- public/_locales/de/messages.json | 7 ++- public/_locales/en/messages.json | 7 ++- public/_locales/es/messages.json | 7 ++- public/_locales/pt_BR/messages.json | 7 ++- public/_locales/ru/messages.json | 7 ++- public/_locales/th/messages.json | 7 ++- public/_locales/uk/messages.json | 7 ++- .../temple/front/parseSignumTransaction.ts | 48 ++++++++++++++++++- 8 files changed, 82 insertions(+), 15 deletions(-) diff --git a/public/_locales/de/messages.json b/public/_locales/de/messages.json index e4426d6..8ad55e8 100644 --- a/public/_locales/de/messages.json +++ b/public/_locales/de/messages.json @@ -1993,9 +1993,12 @@ "message": "Token-Besitz übertragen" }, "subscriptionCancellation": { - "message": "Abonnement beenden" + "message": "Automatische Zahlung stornieren" }, "subscriptionCreation": { - "message": "Abonnement erstellen" + "message": "Automatische Zahlung erstellen" + }, + "aliasSell": { + "message": "Alias verkaufen" } } diff --git a/public/_locales/en/messages.json b/public/_locales/en/messages.json index a75a756..2aeda10 100644 --- a/public/_locales/en/messages.json +++ b/public/_locales/en/messages.json @@ -1770,6 +1770,9 @@ "aliasBuy": { "message": "Buy Alias" }, + "aliasSell": { + "message": "Sell Alias" + }, "addCommitment": { "message": "Add Commitment" }, @@ -1993,9 +1996,9 @@ "message": "Transfer Token Ownership" }, "subscriptionCreation": { - "message": "Create Subscription" + "message": "Create Auto-Payment" }, "subscriptionCancellation": { - "message": "Cancel Subscription" + "message": "Cancel Auto-Payment" } } diff --git a/public/_locales/es/messages.json b/public/_locales/es/messages.json index eff99d9..b55e681 100644 --- a/public/_locales/es/messages.json +++ b/public/_locales/es/messages.json @@ -1993,9 +1993,12 @@ "message": "Transferir la propiedad del token" }, "subscriptionCancellation": { - "message": "Cancelar suscripción" + "message": "Cancelar pago automático" }, "subscriptionCreation": { - "message": "Crear suscripción" + "message": "Crear pago automático" + }, + "aliasSell": { + "message": "vender alias" } } diff --git a/public/_locales/pt_BR/messages.json b/public/_locales/pt_BR/messages.json index 4803fa6..e5dcd29 100644 --- a/public/_locales/pt_BR/messages.json +++ b/public/_locales/pt_BR/messages.json @@ -1993,9 +1993,12 @@ "message": "Transferir propriedade de token" }, "subscriptionCancellation": { - "message": "Cancelar assinatura" + "message": "Cancelar pagamento automático" }, "subscriptionCreation": { - "message": "Criar assinatura" + "message": "Criar pagamento automático" + }, + "aliasSell": { + "message": "Vender Alias" } } diff --git a/public/_locales/ru/messages.json b/public/_locales/ru/messages.json index aebdb29..3e3e73b 100644 --- a/public/_locales/ru/messages.json +++ b/public/_locales/ru/messages.json @@ -1993,9 +1993,12 @@ "message": "Передача владения токеном" }, "subscriptionCancellation": { - "message": "Отменить подписку" + "message": "Отменить автоплатеж" }, "subscriptionCreation": { - "message": "Создать подписку" + "message": "Создать автоплатеж" + }, + "aliasSell": { + "message": "Продать псевдоним" } } diff --git a/public/_locales/th/messages.json b/public/_locales/th/messages.json index c31e9e6..7d770a8 100644 --- a/public/_locales/th/messages.json +++ b/public/_locales/th/messages.json @@ -1993,9 +1993,12 @@ "message": "โอนกรรมสิทธิ์โทเค็น" }, "subscriptionCancellation": { - "message": "ยกเลิกการสมัครสมาชิก" + "message": "ยกเลิกการชำระเงินอัตโนมัติ" }, "subscriptionCreation": { - "message": "สร้างการสมัครสมาชิก" + "message": "สร้างการชำระเงินอัตโนมัติ" + }, + "aliasSell": { + "message": "ขายนามแฝง" } } diff --git a/public/_locales/uk/messages.json b/public/_locales/uk/messages.json index 3af6f15..385b0c6 100644 --- a/public/_locales/uk/messages.json +++ b/public/_locales/uk/messages.json @@ -1993,9 +1993,12 @@ "message": "Передача права власності на токени" }, "subscriptionCancellation": { - "message": "Скасувати підписку" + "message": "Скасувати автоматичну оплату" }, "subscriptionCreation": { - "message": "Створити підписку" + "message": "Створіть автоматичний платіж" + }, + "aliasSell": { + "message": "Продати псевдонім" } } diff --git a/src/lib/temple/front/parseSignumTransaction.ts b/src/lib/temple/front/parseSignumTransaction.ts index c5d0e5c..4e64560 100644 --- a/src/lib/temple/front/parseSignumTransaction.ts +++ b/src/lib/temple/front/parseSignumTransaction.ts @@ -4,6 +4,7 @@ import { Transaction, TransactionArbitrarySubtype, TransactionAssetSubtype, + TransactionEscrowSubtype, TransactionMiningSubtype, TransactionPaymentSubtype, TransactionSmartContractSubtype, @@ -143,6 +144,8 @@ function parseTransactionExpenses(tx: Transaction, resolvedTokenId?: string): Pa switch (tx.type) { case TransactionType.Payment: return parsePaymentExpenses(tx); + case TransactionType.Escrow: + return parseEscrowExpenses(tx); case TransactionType.Asset: return parseAssetExpenses(tx, resolvedTokenId); case TransactionType.AT: @@ -312,7 +315,6 @@ function parseAssetExpenses(tx: Transaction, resolvedTokenId?: string): ParsedTr quantity: new BigNumber(tx.attachment.quantityQNT) } ]; - case TransactionAssetSubtype.AssetTransferOwnership: case TransactionAssetSubtype.AssetAddTreasureyAccount: return [ { @@ -320,6 +322,13 @@ function parseAssetExpenses(tx: Transaction, resolvedTokenId?: string): ParsedTr tokenId: resolvedTokenId } ]; + case TransactionAssetSubtype.AssetTransferOwnership: + return [ + { + to: tx.recipient || BURN_ADDRESS, + tokenId: resolvedTokenId + } + ]; case TransactionAssetSubtype.AssetTransfer: default: return [ @@ -352,12 +361,30 @@ function parsePaymentExpenses(tx: Transaction): ParsedTransactionExpense[] { } } +function parseEscrowExpenses(tx: Transaction): ParsedTransactionExpense[] { + if (tx.subtype === TransactionEscrowSubtype.SubscriptionCancel) { + return [ + { + to: tx.sender // self + } + ]; + } + return [ + { + to: tx.recipient || BURN_ADDRESS, + amount: new BigNumber(tx?.amountNQT || 0) + } + ]; +} + // -- TYPE SECTION function parseTransactionType(tx: Transaction): ParsedTransactionType { switch (tx.type) { case TransactionType.Payment: return parsePaymentSubType(tx); + case TransactionType.Escrow: + return parseEscrowSubType(tx); case TransactionType.Asset: return parseAssetSubType(tx); case TransactionType.AT: @@ -389,6 +416,25 @@ function parsePaymentSubType(tx: Transaction): ParsedTransactionType { }; } +function parseEscrowSubType(tx: Transaction): ParsedTransactionType { + switch (tx.subtype) { + case TransactionEscrowSubtype.SubscriptionCancel: + return { + i18nKey: 'subscriptionCancellation', + textIcon: '❌🕖', + hasAmount: false + }; + case TransactionEscrowSubtype.SubscriptionSubscribe: + return { + i18nKey: 'subscriptionCreation', + textIcon: '🕖✨', + hasAmount: true + }; + } + + return throwInappropriateTransactionType(); +} + function parseAssetSubType(tx: Transaction): ParsedTransactionType { switch (tx.subtype) { case TransactionAssetSubtype.AssetTransfer: