Skip to content

Commit

Permalink
Merge pull request #31 from onbloc/develop
Browse files Browse the repository at this point in the history
Adena update version '1.5.1'
  • Loading branch information
jinoosss authored Mar 10, 2023
2 parents abdab3b + 15e2466 commit 62bdbc5
Show file tree
Hide file tree
Showing 43 changed files with 332 additions and 247 deletions.
88 changes: 0 additions & 88 deletions .circleci/config.yml

This file was deleted.

26 changes: 26 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Setup
description: Set up project environment and test environment.
runs:
using: composite
steps:
- uses: actions/checkout@v3
with:
submodules: true

- uses: actions/setup-node@v3
with:
node-version: 18
registry-url: https://registry.npmjs.org
cache: yarn

- uses: actions/cache@v3
id: install-cache
with:
path: node_modules/
key: ${{ runner.os }}-install-${{ hashFiles('**/yarn.lock') }}

- if: steps.install-cache.outputs.cache-hit != 'true'
run: |
npm install -g nx
yarn install
shell: bash
96 changes: 96 additions & 0 deletions .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Build And Deploy
on:
workflow_run:
workflows: ['Test']
branches: [qa, main]
types:
- completed
jobs:
wait-on-tests:
runs-on: ubuntu-latest
steps:
- id: unit-tests
uses: fountainhead/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
checkName: unit-tests

aws-deployment:
needs: wait-on-tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true

- name: Remove adena-torus-signin mock repository
run: |
git submodule deinit packages/adena-torus-signin
git rm --cached packages/adena-torus-signin
rm -rf .git/modules/packages/adena-torus-signin
rm -rf packages/adena-torus-signin
- name: Clone adena-torus-signin repository
uses: actions/checkout@v3
with:
token: ${{ secrets.PRIVATE_ACCESS_TOKEN }}
repository: onbloc/adena-torus-signin
path: 'packages/adena-torus-signin'

- name: Setup
uses: ./.github/actions/setup

- name: Reinstall dependencies
run: yarn install

- name: Build project
run: |
npx nx run-many --target=build --projects=adena-module,gno-client,adena-torus-signin
npx nx run-many --target=build --projects=adena-extension
- name: Make build files
run: |
bash scripts/build-qa.sh
- name: Deploy AWS S3 (QA)
uses: shallwefootball/s3-upload-action@master
with:
aws_key_id: ${{ secrets.AWS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}}
aws_bucket: ${{ secrets.AWS_BUCKET }}
source_dir: 'deploy'
destination_dir: '.'

- name: Deploy AWS S3 (Latest)
uses: shallwefootball/s3-upload-action@master
with:
aws_key_id: ${{ secrets.AWS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}}
aws_bucket: ${{ secrets.AWS_BUCKET }}
source_dir: 'deploy-latest'
destination_dir: '.'

- name: Run notification scripts
env:
RESOURCE_URI: ${{ secrets.RESOURCE_URI }}
HOOK_URI: ${{ secrets.HOOK_URI }}
run: |
bash scripts/notification-success.sh "$RESOURCE_URI" "$HOOK_URI"
# TODO: Discuss and decide to adopt Chromatic UI
# chromatic-deployment:
# needs: wait-on-tests
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v3

# - name: Setup
# uses: ./.github/actions/setup

# - name: Push chromatic UI
# uses: chromaui/action@v1
# with:
# projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN_2 }}
# workingDir: packages/web
25 changes: 25 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Test
on:
push:
branches: [qa, main]
pull_request:

jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
submodules: true
- uses: ./.github/actions/setup
- run: npx nx run-many --target=build --projects=adena-module,gno-client
- run: yarn run test

# TODO: Apply when you're done setting up your storybook environment
# storybook-tests:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: ./.github/actions/setup
# - run: run test:storybook
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "adena-wallet",
"version": "1.5.0",
"version": "1.5.1",
"description": "Adena Wallet",
"license": "Adena License",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/adena-extension/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "adena-extension",
"version": "1.5.0",
"version": "1.5.1",
"description": "Adena Wallet",
"scripts": {
"build:dev": "webpack --mode=development --watch",
Expand Down
4 changes: 2 additions & 2 deletions packages/adena-extension/public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Adena",
"description": "Adena Wallet",
"manifest_version": 3,
"version": "1.5.0",
"version": "1.5.1",
"action": {
"default_popup": "popup.html"
},
Expand Down Expand Up @@ -34,6 +34,6 @@
}
],
"content_security_policy": {
"extension_pages": "script-src 'self' 'wasm-unsafe-eval'; default-src 'self'; img-src 'self' data:; font-src https://fonts.gstatic.com; style-src 'self' 'unsafe-inline'; style-src-elem 'self' 'unsafe-inline' https://fonts.googleapis.com https://cdn.jsdelivr.net; connect-src 'self' data: https://api.adena.app https://conf.adena.app https://t2.gstatic.com https://t3.gstatic.com https://raw.githubusercontent.com https://github.com https://rpc.test2.gno.land https://rpc.test3.gno.land https://api.developer.tor.us http://127.0.0.1:*; prefetch-src https://*.openlogin.com; frame-src https://*;"
"extension_pages": "script-src 'self' 'wasm-unsafe-eval'; default-src 'self'; img-src 'self' data:; font-src https://fonts.gstatic.com; style-src 'self' 'unsafe-inline'; style-src-elem 'self' 'unsafe-inline' https://fonts.googleapis.com https://cdn.jsdelivr.net; connect-src 'self' data: https://*; prefetch-src https://*.openlogin.com; frame-src https://*;"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export class ChromeSessionStorage implements Storage {
private storage: chrome.storage.SessionStorageArea;

constructor() {
this.storage = chrome.storage.local;
this.storage = chrome.storage.session;
}

public get = async (key: string) => {
Expand Down
44 changes: 37 additions & 7 deletions packages/adena-extension/src/common/utils/client-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,21 +259,43 @@ export const decodeParameter = (data: string) => {

export const createFaviconByHostname = async (hostname: string) => {
try {
const response = await axios.get(
`https://t3.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=https://${hostname}&size=512`,
{
responseType: 'arraybuffer',
},
);
const faviconData = await fetchFavicon(hostname);
const encodeImageData =
'data:image/;base64,' + Buffer.from(response.data, 'binary').toString('base64');
'data:image/;base64,' + Buffer.from(faviconData, 'binary').toString('base64');
return encodeImageData;
} catch (e) {
console.log(e);
}
return null;
};

const fetchFavicon = async (hostname: string) => {
let response = null;

response = await fetchArrayData(`https://${hostname}/apple-touch-icon.png`);
if (response?.data) {
return response.data;
}

response = await fetchArrayData(`https://${hostname}/favicon.ico`);
if (response?.data) {
return response.data;
}

response = await fetchArrayData(`https://www.google.com/s2/favicons?domain=${hostname}&sz=256`);
if (response?.data) {
return response.data;
}

return null;
}

const fetchArrayData = (uri: string) => {
return axios.get(uri, { responseType: 'arraybuffer' })
.then(response => response.headers['content-type'].startsWith("image") ? response : null)
.catch(() => null);
}

export const createImageDataBySvg = async (imageUri: string) => {
try {
const response = await axios.get(imageUri, { responseType: 'arraybuffer', });
Expand All @@ -289,6 +311,14 @@ const isFailedReceive = (cur: any) => {
return cur.func === 'Received' && cur.result.status === 'Failed';
};

// TODO: CHECK SSL
export const getSiteName = (hostname: string | undefined) => {
if (!hostname) {
return "-";
}
return hostname.replace("www.", "");
};

export const optimizeNumber = (value: BigNumber, multiply: BigNumber) => {
const decimalPosition = multiply.toString().indexOf('.');
const decimalLength = decimalPosition > -1 ? `${multiply}`.substring(decimalPosition).length : 0;
Expand Down
16 changes: 6 additions & 10 deletions packages/adena-extension/src/components/background/background.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export const Background = ({ children }: Props) => {
setState("NONE");
return;
}
updateBalances();
}
}, [location]);

Expand All @@ -53,21 +52,17 @@ export const Background = ({ children }: Props) => {
if (!accounts || accounts.length === 0) {
return;
}
updateBalances();
updateAccountBalances();
}, [accounts?.length, currentAccount?.getAddress(), gnoClient?.chainId]);
updateBalances();

useEffect(() => {
if (!accounts || accounts.length === 0) {
return;
}
const balancesFetchTimer = setInterval(() => {
updateBalances();
updateAccountBalances();
}, 5000);
}, 10 * 1000);
return () => {
clearInterval(balancesFetchTimer);
}
}, [gnoClient?.chainId, accounts?.length]);
}, [gnoClient?.chainId, accounts?.length, currentAccount?.getAddress()]);

/**
* History Data Interval Fetch
Expand All @@ -83,7 +78,8 @@ export const Background = ({ children }: Props) => {
if (gnoClient?.chainId && currentAccount) {
const historyFetchTimer = setInterval(() => {
updateLastTransactionHistory();
}, 5000);
}, 10 * 1000);

return () => {
clearInterval(historyFetchTimer);
}
Expand Down
Loading

0 comments on commit 62bdbc5

Please sign in to comment.