From 562dfb40464bad3b144b4eee0da93448558c96ef Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Sat, 23 Mar 2024 11:29:07 +0800 Subject: [PATCH] add ad --- env.d.ts | 2 + index.html | 1 + package.json | 1 + src/components/ad/AdBanner.vue | 31 ++ src/components/ad/ad.ts | 49 +++ src/modules/wallet/accounts.vue | 3 + src/modules/wallet/keplr.vue | 2 + src/modules/wallet/portfolio.vue | 4 +- src/modules/wallet/suggest.vue | 3 + src/pages/index.vue | 9 +- yarn.lock | 506 +++++++++++++++++++++++++++++-- 11 files changed, 578 insertions(+), 33 deletions(-) create mode 100644 src/components/ad/AdBanner.vue create mode 100644 src/components/ad/ad.ts diff --git a/env.d.ts b/env.d.ts index 11f02fe2..f18e8379 100644 --- a/env.d.ts +++ b/env.d.ts @@ -1 +1,3 @@ /// + +declare module '@personaxyz/ad-sdk'; \ No newline at end of file diff --git a/index.html b/index.html index 9e5df221..d9ab0919 100644 --- a/index.html +++ b/index.html @@ -32,5 +32,6 @@ gtag('config', 'G-SSBKVF3GMX'); + diff --git a/package.json b/package.json index 0315373e..397d5ae7 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "@leapwallet/cosmos-snap-provider": "^0.1.20", "@leapwallet/name-matcha": "^1.1.0", "@osmonauts/lcd": "^0.8.0", + "@personaxyz/ad-sdk": "0.0.21", "@ping-pub/chain-registry-client": "^0.0.25", "@vitejs/plugin-vue-jsx": "^3.0.0", "@vueuse/core": "^9.12.0", diff --git a/src/components/ad/AdBanner.vue b/src/components/ad/AdBanner.vue new file mode 100644 index 00000000..cfca09d2 --- /dev/null +++ b/src/components/ad/AdBanner.vue @@ -0,0 +1,31 @@ + + diff --git a/src/components/ad/ad.ts b/src/components/ad/ad.ts new file mode 100644 index 00000000..6e69d18a --- /dev/null +++ b/src/components/ad/ad.ts @@ -0,0 +1,49 @@ +import { PersonaAdSDK } from '@personaxyz/ad-sdk'; + +interface ADConfig { + apiKey: string; + environment: string; +} + +export const confs: Record = { + // "localhost": { + // apiKey: 'XXXX_api_key_staging_XXXX', // An actual API key is generated once you register an app with us. + // environment: 'staging', // use value 'production' when going live + // }, + "ping.pub": { + apiKey: 'persona-pub-0x6ca028de83d9bc438bb3fd7f9620f36b', + environment: 'production', + }, + "testnet.ping.pub": { + apiKey: 'persona-pub-0x14e9ba8ca5a658ba409fc0059ebc3711', + environment: 'production', + } +} + + +export const UNITS: Record> = { + "localhost": { + "banner": "3a094192-4c7b-4761-a50c-bd9b6a67e987", + }, + "ping.pub": { + "banner": "6883877a-ccae-4a08-b457-7e30b3465a8c", + }, + "testnet.ping.pub": { + "banner": "1644951b-5022-4544-8a85-11aef8a8f645", + }, +} + +export function getClient() { + const conf = confs[location.hostname] + if(conf) { + const sdk = new PersonaAdSDK(conf) + return sdk.getClient() + } +} + +export function getUnit(ad: string): string | undefined { + const ads = UNITS[location.hostname] + if(ads) { + return ads[ad] + } +} diff --git a/src/modules/wallet/accounts.vue b/src/modules/wallet/accounts.vue index 06ac38e2..80eabcec 100644 --- a/src/modules/wallet/accounts.vue +++ b/src/modules/wallet/accounts.vue @@ -12,6 +12,7 @@ import { scanCompatibleAccounts, type LocalKey, } from './utils'; +import AdBanner from '@/components/ad/AdBanner.vue'; const dashboard = useDashboard(); const chainStore = useBlockchain() @@ -221,6 +222,8 @@ async function loadBalances(chainName: string, endpoint: string, address: string + +
diff --git a/src/modules/wallet/keplr.vue b/src/modules/wallet/keplr.vue index 1f5b2749..6adb8f33 100644 --- a/src/modules/wallet/keplr.vue +++ b/src/modules/wallet/keplr.vue @@ -3,6 +3,7 @@ import { ref } from 'vue'; import { useDashboard, type ChainConfig, useBlockchain } from '@/stores'; import { CosmosRestClient } from '@/libs/client'; import { onMounted } from 'vue'; +import AdBanner from '@/components/ad/AdBanner.vue'; const error = ref("") const conf = ref("") @@ -85,6 +86,7 @@ function suggest() {