Skip to content

Commit

Permalink
Merge branch 'main' into timestamps-events
Browse files Browse the repository at this point in the history
  • Loading branch information
ba1ciu committed Jun 21, 2023
2 parents c36ba34 + 4b926c3 commit 4af1363
Show file tree
Hide file tree
Showing 5 changed files with 320 additions and 195 deletions.
3 changes: 3 additions & 0 deletions frontend/proof-of-existence/src/assets/images/copy-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions frontend/proof-of-existence/src/utils/wallet-utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Wallet } from "@/types/enums";
import type { Keplr } from "@keplr-wallet/types";

export function getWalletFromType(wallet: string): Keplr {
switch (wallet) {
case Wallet.Keplr:
return window.keplr;
case Wallet.Cosmostation:
return window.cosmostation.providers.keplr;
case Wallet.Leap:
return window.leap;
default:
throw new Error("Wallet not supported");
}
}
28 changes: 28 additions & 0 deletions frontend/proof-of-existence/src/views/certify/CreateProofView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { CHAIN_ID, RPC_URL } from "@/config/config";
import type { OfflineSigner } from "@cosmjs/proto-signing";
import type { DeliverTxResponse } from "@cosmjs/stargate/build/stargateclient";
import { toast } from "vue3-toastify";
import { getWalletFromType } from "@/utils/wallet-utils";
const fee = {
amount: [{ amount: "100000", denom: "umpwr" }],
Expand All @@ -28,6 +29,8 @@ const showModal = ref(false);
const selectedWallet = ref("");
const errorMessage = ref<string | undefined>();
const loading = ref(false);
const address = ref();
const addressVisible = ref();
//Methods
const back = () => {
Expand All @@ -46,9 +49,21 @@ const closeModal = () => {
const handleSelectedWallet = (wallet: Wallet) => {
selectedWallet.value = wallet;
showWalletAddress(wallet);
closeModal();
};
const showWalletAddress = async (selectedWallet: Wallet) => {
const wallet = getWalletFromType(selectedWallet);
const account = await wallet.getKey(CHAIN_ID);
const walletAddress = account.bech32Address;
address.value = walletAddress;
addressVisible.value =
walletAddress?.substring(0, 10) +
"..." +
walletAddress?.substring(walletAddress?.length - 4);
};
const handleTransaction = async () => {
loading.value = true;
switch (selectedWallet.value) {
Expand Down Expand Up @@ -125,6 +140,11 @@ const pushToSuccessPage = () => {
},
});
};
const copyAddress = async () => {
await navigator.clipboard.writeText(address.value);
toast.success("Address copied to clipboard");
};
</script>
<template>
<SelectWalletModel
Expand Down Expand Up @@ -209,6 +229,14 @@ const pushToSuccessPage = () => {
class="h-20 cursor-pointer mb-3"
v-if="selectedWallet === Wallet.Leap"
/>
<div
v-if="addressVisible"
class="flex flex-row bg-lightGray rounded-lg p-2 cursor-pointer w-fit mt-5 flex-wrap"
@click="copyAddress"
>
<p class="text-white text-title12">{{ addressVisible }}</p>
<img class="w-4 ml-4" src="../../assets/images/copy-icon.svg" />
</div>
<button
@click="openModal"
class="bg-lightGreen mt-7 content-center p-1 px-7 rounded text-white"
Expand Down
22 changes: 16 additions & 6 deletions indexer/scripts/build-with-env.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
#!/bin/bash
set -e

# Get Google Maps API key from .env file (trim double quotes)
# Get Google Maps API key, Rollbar access token and environment from .env file (trim double quotes)
GOOGLE_MAPS_API_KEY=$(grep GOOGLE_MAPS_API_KEY .env | cut -d '=' -f2 | sed 's/"//g')
ROLLBAR_ACCESS_TOKEN=$(grep ROLLBAR_ACCESS_TOKEN .env | cut -d '=' -f2 | sed 's/"//g')
ENVIRONMENT=$(grep ENVIRONMENT .env | cut -d '=' -f2 | sed 's/"//g')

# Replace $KEY in src/mappings/mappingHandlers.ts with Google Maps API key
# Replace $GOOGLE_MAPS_API_KEY, $ROLLBAR_ACCESS_TOKEN and $ENVIRONMENT in src/mappings/mappingHandlers.ts
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
sed -i "s/\$KEY/$GOOGLE_MAPS_API_KEY/g" ./src/mappings/mappingHandlers.ts
sed -i "s/\$GOOGLE_MAPS_API_KEY/$GOOGLE_MAPS_API_KEY/g" ./src/mappings/mappingHandlers.ts
sed -i "s/\$ROLLBAR_ACCESS_TOKEN/$ROLLBAR_ACCESS_TOKEN/g" ./src/mappings/mappingHandlers.ts
sed -i "s/\$ENVIRONMENT/$ENVIRONMENT/g" ./src/mappings/mappingHandlers.ts
elif [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' "s/\$KEY/$GOOGLE_MAPS_API_KEY/g" ./src/mappings/mappingHandlers.ts
sed -i '' "s/\$GOOGLE_MAPS_API_KEY/$GOOGLE_MAPS_API_KEY/g" ./src/mappings/mappingHandlers.ts
sed -i '' "s/\$ROLLBAR_ACCESS_TOKEN/$ROLLBAR_ACCESS_TOKEN/g" ./src/mappings/mappingHandlers.ts
sed -i '' "s/\$ENVIRONMENT/$ENVIRONMENT/g" ./src/mappings/mappingHandlers.ts
fi

# Build project
subql build

# Restore original mappingHandlers.ts
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
sed -i "s/$GOOGLE_MAPS_API_KEY/\$KEY/g" ./src/mappings/mappingHandlers.ts
sed -i "s/$GOOGLE_MAPS_API_KEY/\$GOOGLE_MAPS_API_KEY/g" ./src/mappings/mappingHandlers.ts
sed -i "s/$ROLLBAR_ACCESS_TOKEN/\$ROLLBAR_ACCESS_TOKEN/g" ./src/mappings/mappingHandlers.ts
sed -i "s/$ENVIRONMENT/\$ENVIRONMENT/g" ./src/mappings/mappingHandlers.ts
elif [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' "s/$GOOGLE_MAPS_API_KEY/\$KEY/g" ./src/mappings/mappingHandlers.ts
sed -i '' "s/$GOOGLE_MAPS_API_KEY/\$GOOGLE_MAPS_API_KEY/g" ./src/mappings/mappingHandlers.ts
sed -i '' "s/$ROLLBAR_ACCESS_TOKEN/\$ROLLBAR_ACCESS_TOKEN/g" ./src/mappings/mappingHandlers.ts
sed -i '' "s/$ENVIRONMENT/\$ENVIRONMENT/g" ./src/mappings/mappingHandlers.ts
fi
Loading

0 comments on commit 4af1363

Please sign in to comment.