From 2a86b6a14976ddc635c1c6ddd199bae54fa452ef Mon Sep 17 00:00:00 2001 From: Reza Rahemtola Date: Sun, 27 Oct 2024 16:56:56 +0900 Subject: [PATCH] feat(solana): Support LTAI balances --- .env.example | 5 +- .eslintrc.yaml | 1 + package-lock.json | 60 +++++-------------- package.json | 1 + src/components/AccountButton.vue | 4 +- src/config/env.ts | 2 + src/layouts/AuthenticatedPage.vue | 8 +-- src/layouts/MainLayout.vue | 5 +- src/pages/TokensDetail.vue | 3 +- .../subscriptions/SubscriptionsLanding.vue | 8 +-- src/stores/account.ts | 40 +++++++++---- src/utils/aleph-persistent-storage.ts | 17 +++--- 12 files changed, 75 insertions(+), 79 deletions(-) diff --git a/.env.example b/.env.example index f74c402..c45c337 100644 --- a/.env.example +++ b/.env.example @@ -6,9 +6,12 @@ WALLET_CONNECT_PROJECT_ID= # APIs LTAI_SUBSCRIPTIONS_API_URL=http://localhost:8000 -WALLET_CONNECT_PROJECT_ID= + +# RPCs +SOLANA_RPC= # Blockchain addresses (change in development) # LTAI_BASE_ADDRESS=0x92e1d72210429Ce7eE8a0d64D526D4b9752801FF +# LTAI_SOLANA_ADDRESS=5ooRTqmvm95bHwp4HMo3iszCwsEseY5hksfSa9EDVpBY # LTAI_PUBLISHER_ADDRESS=0xae92Dc50115dbBb1CF0BA848e83842daf00CE129 # WAGMI_BASE_ID=84532 diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 4ba3288..c952c13 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -30,6 +30,7 @@ plugins: rules: 'no-unused-vars': [ 'warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' } ] + no-case-declarations: off 'vue/multi-word-component-names': 'off' 'vue/no-v-html': 'off' diff --git a/package-lock.json b/package-lock.json index 3eabe04..84c6b37 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,7 @@ "@hey-api/client-axios": "^0.2.7", "@libertai/libertai-js": "0.0.10", "@quasar/extras": "^1.16.12", + "@solana/web3.js": "^1.95.4", "@tanstack/vue-query": "^5.51.21", "@wagmi/vue": "^0.0.36", "axios": "^1.7.3", @@ -5825,7 +5826,6 @@ "resolved": "https://registry.npmjs.org/@solana/buffer-layout/-/buffer-layout-4.0.1.tgz", "integrity": "sha512-E1ImOIAD1tBZFRdjeM4/pzTiTApC0AOBGwyAMS4fwIodCWArzJ3DWdoh8cKxeFM2fElkxBh2Aqts1BPC373rHA==", "license": "MIT", - "peer": true, "dependencies": { "buffer": "~6.0.3" }, @@ -5920,11 +5920,10 @@ } }, "node_modules/@solana/web3.js": { - "version": "1.95.3", - "resolved": "https://registry.npmjs.org/@solana/web3.js/-/web3.js-1.95.3.tgz", - "integrity": "sha512-O6rPUN0w2fkNqx/Z3QJMB9L225Ex10PRDH8bTaIUPZXMPV0QP8ZpPvjQnXK+upUczlRgzHzd6SjKIha1p+I6og==", + "version": "1.95.4", + "resolved": "https://registry.npmjs.org/@solana/web3.js/-/web3.js-1.95.4.tgz", + "integrity": "sha512-sdewnNEA42ZSMxqkzdwEWi6fDgzwtJHaQa5ndUGEJYtoOnM6X5cvPmjoTUp7/k7bRrVAxfBgDnvQQHD6yhlLYw==", "license": "MIT", - "peer": true, "dependencies": { "@babel/runtime": "^7.25.0", "@noble/curves": "^1.4.2", @@ -5947,15 +5946,13 @@ "version": "5.2.1", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==", - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/@solana/web3.js/node_modules/superstruct": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/superstruct/-/superstruct-2.0.2.tgz", "integrity": "sha512-uV+TFRZdXsqXTL2pRvujROjdZQ4RAlBUS5BTh9IGm+jTqQntYThciG/qu57Gs69yjnVUSqdxF9YLmSnpupBW9A==", "license": "MIT", - "peer": true, "engines": { "node": ">=14.0.0" } @@ -6129,7 +6126,6 @@ "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.13.tgz", "integrity": "sha512-UoKGxQ3r5kYI9dALKJapMmuK+1zWM/H17Z1+iwnNmzcJRnfFuevZs375TA5rW31pu4BS4NoSy1fRsexDXfWn5w==", "license": "Apache-2.0", - "peer": true, "dependencies": { "tslib": "^2.4.0" } @@ -8397,7 +8393,6 @@ "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.10.tgz", "integrity": "sha512-7d0s06rR9rYaIWHkpfLIFICM/tkSVdoPC9qYAQRpxn9DdKNWNsKC0uk++akckyLq16Tx2WIinnZ6WRriAt6njQ==", "license": "MIT", - "peer": true, "dependencies": { "safe-buffer": "^5.0.1" } @@ -8432,7 +8427,6 @@ "integrity": "sha512-trfYco6AoZ+rKhKnxA0hgX0HAbVP/s808/EuDSe2JDzUnCp/xAsli35Orvk67UrTEcwuxZqYZDmfA2RXJgxVvA==", "hasInstallScript": true, "license": "Apache-2.0", - "peer": true, "dependencies": { "bindings": "^1.3.0" }, @@ -8461,7 +8455,6 @@ "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", "license": "MIT", - "peer": true, "dependencies": { "file-uri-to-path": "1.0.0" } @@ -8562,7 +8555,6 @@ "resolved": "https://registry.npmjs.org/borsh/-/borsh-0.7.0.tgz", "integrity": "sha512-CLCsZGIBCFnPtkNnieW/a8wmreDmfUtjU2m9yHrzPXIlNbqVs0AQrSatSG6vdNYUqdc83tkQi2eHfF98ubzQLA==", "license": "Apache-2.0", - "peer": true, "dependencies": { "bn.js": "^5.2.0", "bs58": "^4.0.0", @@ -8573,8 +8565,7 @@ "version": "5.2.1", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==", - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/bowser": { "version": "2.11.0", @@ -8751,7 +8742,6 @@ "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", "integrity": "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==", "license": "MIT", - "peer": true, "dependencies": { "base-x": "^3.0.2" } @@ -10056,7 +10046,6 @@ "resolved": "https://registry.npmjs.org/delay/-/delay-5.0.0.tgz", "integrity": "sha512-ReEBKkIfe4ya47wlPYf/gu5ib6yUG0/Aez0JQZQz94kiWtRQvZIQbTiehsnwHvLSWJnQdhVeqYue7Id1dKr0qw==", "license": "MIT", - "peer": true, "engines": { "node": ">=10" }, @@ -10423,15 +10412,13 @@ "version": "4.2.8", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==", - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/es6-promisify": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", "integrity": "sha512-C+d6UdsYDk0lMebHNR4S2NybQMMngAOnOwYBQjTOiv0MkoJMP0Myw2mgpDLBcpfCmRLxyFqYhS/CfOENq4SJhQ==", "license": "MIT", - "peer": true, "dependencies": { "es6-promise": "^4.0.3" } @@ -11227,7 +11214,6 @@ "version": "0.1.8", "resolved": "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz", "integrity": "sha512-GipyPsXO1anza0AOZdy69Im7hGFCNB7Y/NGjDlZGJ3GJJLtwNSb2vrzYrTYJRrRloVx7pl+bhUaTB8yiccPvFQ==", - "peer": true, "engines": { "node": "> 0.1.90" } @@ -11279,8 +11265,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/fast-stable-stringify/-/fast-stable-stringify-1.0.0.tgz", "integrity": "sha512-wpYMUmFu5f00Sm0cj2pfivpmawLZ0NKdviQ4w9zJeR8JVtOpOxHmLaJuj0vxvGqMJQWyP/COUkF75/57OKyRag==", - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/fast-uri": { "version": "3.0.1", @@ -11356,8 +11341,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/filesize": { "version": "10.1.4", @@ -12759,7 +12743,6 @@ "resolved": "https://registry.npmjs.org/jayson/-/jayson-4.1.2.tgz", "integrity": "sha512-5nzMWDHy6f+koZOuYsArh2AXs73NfWYVlFyJJuCedr93GpY+Ku8qq10ropSXVfHK+H0T6paA88ww+/dV+1fBNA==", "license": "MIT", - "peer": true, "dependencies": { "@types/connect": "^3.4.33", "@types/node": "^12.12.54", @@ -12785,15 +12768,13 @@ "version": "12.20.55", "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.55.tgz", "integrity": "sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==", - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/jayson/node_modules/@types/ws": { "version": "7.4.7", "resolved": "https://registry.npmjs.org/@types/ws/-/ws-7.4.7.tgz", "integrity": "sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww==", "license": "MIT", - "peer": true, "dependencies": { "@types/node": "*" } @@ -12802,15 +12783,13 @@ "version": "2.20.3", "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/jayson/node_modules/isomorphic-ws": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz", "integrity": "sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w==", "license": "MIT", - "peer": true, "peerDependencies": { "ws": "*" } @@ -12820,7 +12799,6 @@ "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", "license": "MIT", - "peer": true, "bin": { "uuid": "dist/bin/uuid" } @@ -12830,7 +12808,6 @@ "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz", "integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==", "license": "MIT", - "peer": true, "engines": { "node": ">=8.3.0" }, @@ -13217,8 +13194,7 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==", - "license": "ISC", - "peer": true + "license": "ISC" }, "node_modules/json5": { "version": "2.2.3", @@ -13251,8 +13227,7 @@ "engines": [ "node >= 0.2.0" ], - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/jsonpointer": { "version": "5.0.1", @@ -13268,7 +13243,6 @@ "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", "integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==", "license": "(MIT OR Apache-2.0)", - "peer": true, "dependencies": { "jsonparse": "^1.2.0", "through": ">=2.2.7 <3" @@ -17217,7 +17191,6 @@ "resolved": "https://registry.npmjs.org/rpc-websockets/-/rpc-websockets-9.0.4.tgz", "integrity": "sha512-yWZWN0M+bivtoNLnaDbtny4XchdAIF5Q4g/ZsC5UC61Ckbp0QczwO8fg44rV3uYmY4WHd+EZQbn90W1d8ojzqQ==", "license": "LGPL-3.0-only", - "peer": true, "dependencies": { "@swc/helpers": "^0.5.11", "@types/uuid": "^8.3.4", @@ -17240,15 +17213,13 @@ "version": "8.3.4", "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.4.tgz", "integrity": "sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==", - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/rpc-websockets/node_modules/uuid": { "version": "8.3.2", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", "license": "MIT", - "peer": true, "bin": { "uuid": "dist/bin/uuid" } @@ -18230,8 +18201,7 @@ "node_modules/text-encoding-utf-8": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/text-encoding-utf-8/-/text-encoding-utf-8-1.0.2.tgz", - "integrity": "sha512-8bw4MY9WjdsD2aMtO0OzOCY3pXGYNx2d2FfHRVUKkiCPDWjKuOlhLVASS+pD7VkLTVjW268LYJHwsnPFlBpbAg==", - "peer": true + "integrity": "sha512-8bw4MY9WjdsD2aMtO0OzOCY3pXGYNx2d2FfHRVUKkiCPDWjKuOlhLVASS+pD7VkLTVjW268LYJHwsnPFlBpbAg==" }, "node_modules/text-table": { "version": "0.2.0", diff --git a/package.json b/package.json index 45afb7a..52530d5 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "@hey-api/client-axios": "^0.2.7", "@libertai/libertai-js": "0.0.10", "@quasar/extras": "^1.16.12", + "@solana/web3.js": "^1.95.4", "@tanstack/vue-query": "^5.51.21", "@wagmi/vue": "^0.0.36", "axios": "^1.7.3", diff --git a/src/components/AccountButton.vue b/src/components/AccountButton.vue index 7832da0..44cb8e9 100644 --- a/src/components/AccountButton.vue +++ b/src/components/AccountButton.vue @@ -76,10 +76,10 @@ import { useAccount, useConnect, useDisconnect } from '@wagmi/vue'; import { watchAccount } from '@wagmi/vue/actions'; import LtaiIcon from 'components/libertai/LtaiIcon.vue'; -import { config } from 'src/config/wagmi'; -import { watch, watchEffect } from 'vue'; import { useWallet, WalletModalProvider } from 'solana-wallets-vue'; +import { config } from 'src/config/wagmi'; import { useAccountStore } from 'stores/account'; +import { watch, watchEffect } from 'vue'; const accountStore = useAccountStore(); diff --git a/src/config/env.ts b/src/config/env.ts index 56a3398..de4662e 100644 --- a/src/config/env.ts +++ b/src/config/env.ts @@ -5,7 +5,9 @@ const envSchema = z.object({ ALEPH_API_URL: z.string().optional(), LTAI_SUBSCRIPTIONS_API_URL: z.string(), WALLET_CONNECT_PROJECT_ID: z.string(), + SOLANA_RPC: z.string().url(), LTAI_BASE_ADDRESS: z.string().startsWith('0x').optional().default('0xF8B1b47AA748F5C7b5D0e80C726a843913EB573a'), + LTAI_SOLANA_ADDRESS: z.string().optional().default('mntpN8z1d29f3MWhMD7VqZFpeYmbD88MgwS3Bkz8y7u'), LTAI_PUBLISHER_ADDRESS: z.string().startsWith('0x').optional().default('0xCBFc3EeC41CBBfCAcc50337d712890C47a14ba99'), WAGMI_BASE_ID: z.union([z.literal(base.id), z.literal(baseSepolia.id)]).default(base.id), }); diff --git a/src/layouts/AuthenticatedPage.vue b/src/layouts/AuthenticatedPage.vue index 56301d0..5e2178d 100644 --- a/src/layouts/AuthenticatedPage.vue +++ b/src/layouts/AuthenticatedPage.vue @@ -1,21 +1,21 @@