Skip to content

Commit

Permalink
- bugfix: parseInt text input for id
Browse files Browse the repository at this point in the history
- add some stuff for PWA
  • Loading branch information
jasbanza committed Nov 3, 2023
1 parent bb14a92 commit d0b7bd5
Show file tree
Hide file tree
Showing 23 changed files with 344 additions and 6 deletions.
3 changes: 2 additions & 1 deletion docs/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -211527,6 +211527,7 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
var executeContract = _osmojs.cosmwasm.wasm.v1.MessageComposer.withTypeUrl.executeContract;
var MsgExecuteContract = _osmojs.cosmwasm.wasm.v1.MsgExecuteContract;
var restUrl = "https://rest-osmosis.ecostake.com";
navigator.serviceWorker.register("service-worker.js");
_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
var urlParams, orderId;
return _regeneratorRuntime().wrap(function _callee$(_context) {
Expand Down Expand Up @@ -211981,7 +211982,7 @@ function btnCancelCustomOrder() {
ui_showError("Invalid Order ID");
return;
}
cancelOrder(orderId);
cancelOrder(parseInt(orderId));
}

// UI FUNCTIONS
Expand Down
Binary file added docs/images/icons/apple-icon-180.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/icons/manifest-icon-192.maskable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/icons/manifest-icon-512.maskable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/logo.psd
Binary file not shown.
Binary file added docs/images/screenshots/1280x800-screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/screenshots/750x1334-screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
<title>Cancel Autoswap by jasbanza</title>
<script src="bundle.js"></script>
<link rel="stylesheet" href="styles/style.css" />
<script>
navigator.serviceWorker.register(
"service-worker.js"
);
</script>
<link rel="icon" href="favicon.ico" />
</head>
<body>
Expand Down
67 changes: 67 additions & 0 deletions docs/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"display_override": [
"window-controls-overlay"
],
"protocol_handlers": [
{
"protocol": "mailto",
"url": "/newEmail?to=%s"
}
],
"name": "Autoswap Cancel Orders",
"short_name": "This name will show in your Windows taskbar, in the start menu, and Android homescreen",
"start_url": "The URL that should be loaded when your application is opened",
"display": "standalone",
"description": "A description for your application",
"lang": " The default language of your application",
"dir": "auto",
"theme_color": "#000000",
"background_color": "#000000",
"orientation": "any",
"icons": [
{
"src": "images/icons/manifest-icon-192.maskable.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "any"
},
{
"src": "images/icons/manifest-icon-192.maskable.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "maskable"
},
{
"src": "images/icons/manifest-icon-512.maskable.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "any"
},
{
"src": "images/icons/manifest-icon-512.maskable.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "maskable"
}
],
"screenshots": [
{
"src": "images/screenshots/1280x800-screenshot.png",
"sizes": "1280x800",
"type": "image/png"
},
{
"src": "images/screenshots/750x1334-screenshot.png",
"sizes": "750x1334",
"type": "image/png"
}
],
"prefer_related_applications": false,
"shortcuts": [
{
"name": "The name you would like to be displayed for your shortcut",
"url": "The url you would like to open when the user chooses this shortcut. This must be a URL local to your PWA. For example: If my start_url is /, this URL must be something like /shortcut",
"description": "A description of the functionality of this shortcut"
}
]
}
93 changes: 93 additions & 0 deletions docs/service-worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@

// Based off of https://github.com/pwa-builder/PWABuilder/blob/main/docs/sw.js

/*
Welcome to our basic Service Worker! This Service Worker offers a basic offline experience
while also being easily customizeable. You can add in your own code to implement the capabilities
listed below, or change anything else you would like.
Need an introduction to Service Workers? Check our docs here: https://docs.pwabuilder.com/#/home/sw-intro
Want to learn more about how our Service Worker generation works? Check our docs here: https://docs.pwabuilder.com/#/studio/existing-app?id=add-a-service-worker
Did you know that Service Workers offer many more capabilities than just offline?
- Background Sync: https://microsoft.github.io/win-student-devs/#/30DaysOfPWA/advanced-capabilities/06
- Periodic Background Sync: https://web.dev/periodic-background-sync/
- Push Notifications: https://microsoft.github.io/win-student-devs/#/30DaysOfPWA/advanced-capabilities/07?id=push-notifications-on-the-web
- Badges: https://microsoft.github.io/win-student-devs/#/30DaysOfPWA/advanced-capabilities/07?id=application-badges
*/

const HOSTNAME_WHITELIST = [
self.location.hostname,
'fonts.gstatic.com',
'fonts.googleapis.com',
'cdn.jsdelivr.net'
]

// The Util Function to hack URLs of intercepted requests
const getFixedUrl = (req) => {
var now = Date.now()
var url = new URL(req.url)

// 1. fixed http URL
// Just keep syncing with location.protocol
// fetch(httpURL) belongs to active mixed content.
// And fetch(httpRequest) is not supported yet.
url.protocol = self.location.protocol

// 2. add query for caching-busting.
// Github Pages served with Cache-Control: max-age=600
// max-age on mutable content is error-prone, with SW life of bugs can even extend.
// Until cache mode of Fetch API landed, we have to workaround cache-busting with query string.
// Cache-Control-Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=453190
if (url.hostname === self.location.hostname) {
url.search += (url.search ? '&' : '?') + 'cache-bust=' + now
}
return url.href
}

/**
* @Lifecycle Activate
* New one activated when old isnt being used.
*
* waitUntil(): activating ====> activated
*/
self.addEventListener('activate', event => {
event.waitUntil(self.clients.claim())
})

/**
* @Functional Fetch
* All network requests are being intercepted here.
*
* void respondWith(Promise<Response> r)
*/
self.addEventListener('fetch', event => {
// Skip some of cross-origin requests, like those for Google Analytics.
if (HOSTNAME_WHITELIST.indexOf(new URL(event.request.url).hostname) > -1) {
// Stale-while-revalidate
// similar to HTTP's stale-while-revalidate: https://www.mnot.net/blog/2007/12/12/stale
// Upgrade from Jake's to Surma's: https://gist.github.com/surma/eb441223daaedf880801ad80006389f1
const cached = caches.match(event.request)
const fixedUrl = getFixedUrl(event.request)
const fetched = fetch(fixedUrl, { cache: 'no-store' })
const fetchedCopy = fetched.then(resp => resp.clone())

// Call respondWith() with whatever we get first.
// If the fetch fails (e.g disconnected), wait for the cache.
// If there’s nothing in cache, wait for the fetch.
// If neither yields a response, return offline pages.
event.respondWith(
Promise.race([fetched.catch(_ => cached), cached])
.then(resp => resp || fetched)
.catch(_ => { /* eat any errors */ })
)

// Update the cache with the version we fetched (only for ok status)
event.waitUntil(
Promise.all([fetchedCopy, caches.open("pwa-cache")])
.then(([response, cache]) => response.ok && cache.put(event.request, response))
.catch(_ => { /* eat any errors */ })
)
}
})
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,26 @@
"type": "module",
"scripts": {
"use-these": "########## USE THESE: ##########",
"compile": "npm run build-rm-github-pages & npm run build-rm-dist & npm run dev-rm-preview & npm-run-all --parallel build-html build-bundle-js build-css build-images & npm run build-github-pages",
"compile": "npm run build-rm-github-pages & npm run build-rm-dist & npm run dev-rm-preview & npm-run-all --parallel build-html build-bundle-js build-service-worker build-css build-images build-json & npm run build-github-pages",
"dev": "npm run dev-compile && concurrently -c \"auto\" npm:service-*",
"dont-use": "########## DON'T USE THESE: ##########",
"build-bundle-js": "browserify -t [ babelify --presets [ @babel/preset-env ] ] src/index.js -o dist/bundle.js -s module",
"build-service-worker": "xcopy /E /Y \".\\src\\service-worker.js\" \".\\dist\\\"",
"build-css": "xcopy /E /Y \".\\src\\styles\\\" \".\\dist\\styles\\\" ",
"build-html": "xcopy /E /Y \".\\src\\*.html\" \".\\dist\\\" ",
"build-images": "xcopy /E /Y \".\\src\\images\\\" \".\\dist\\images\\\" && xcopy /E /Y \".\\src\\favicon.ico\" \".\\dist\\\"",
"build-json": "xcopy /E /Y \".\\src\\*.json\" \".\\dist\\\" ",
"build-rm-dist": "rmdir /s /q dist",
"build-github-pages": "xcopy /E /Y \".\\dist\\\" \".\\docs\\\"",
"build-rm-github-pages": "rmdir /s /q docs",
"dev-bundle-js": "browserify -t [ babelify --presets [ @babel/preset-env ] ] src/index.js -o preview/bundle.js -s module",
"dev-css": "xcopy /E /Y \".\\src\\styles\\\" \".\\preview\\styles\\\" ",
"dev-html": "xcopy /E /Y \".\\src\\*.html\" \".\\preview\\\" ",
"dev-service-worker": "xcopy /E /Y \".\\src\\service-worker.js\" \".\\preview\\\"",
"dev-css": "xcopy /E /Y \".\\src\\styles\\\" \".\\preview\\styles\\\"",
"dev-html": "xcopy /E /Y \".\\src\\*.html\" \".\\preview\\\"",
"dev-images": "xcopy /E /Y \".\\src\\images\\\" \".\\preview\\images\\\" && xcopy /E /Y \".\\src\\favicon.ico\" \".\\preview\\\"",
"dev-json": "xcopy /E /Y \".\\src\\*.json\" \".\\preview\\\"",
"dev-rm-preview": "rmdir /s /q preview",
"dev-compile": "npm run dev-rm-preview & npm-run-all --parallel dev-html dev-bundle-js dev-css dev-images",
"dev-compile": "npm run dev-rm-preview & npm-run-all --parallel dev-html dev-bundle-js dev-service-worker dev-css dev-images dev-json",
"service-watch": "concurrently -c \"auto\" npm:watch-*",
"watch-html": "nodemon --watch \"src\" --ext \"html\" --exec \"npm run dev-html\"",
"watch-js": "nodemon --watch \"src\" --ext \"js\" --exec \"npm run dev-bundle-js\"",
Expand Down
Binary file added src/images/icons/apple-icon-180.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/icons/manifest-icon-192.maskable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/icons/manifest-icon-512.maskable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/logo.psd
Binary file not shown.
Binary file added src/images/screenshots/1280x800-screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/screenshots/750x1334-screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
<title>Cancel Autoswap by jasbanza</title>
<script src="bundle.js"></script>
<link rel="stylesheet" href="styles/style.css" />
<script>
navigator.serviceWorker.register(
"service-worker.js"
);
</script>
<link rel="icon" href="favicon.ico" />
</head>
<body>
Expand Down
5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ const { MsgExecuteContract } = cosmwasm.wasm.v1;

const restUrl = "https://rest-osmosis.ecostake.com";

navigator.serviceWorker.register("service-worker.js");


(async () => {
// waits for window.keplr to exist (if extension is installed, enabled and injecting its content script)
await getKeplr();
Expand Down Expand Up @@ -234,7 +237,7 @@ function btnCancelCustomOrder() {
ui_showError("Invalid Order ID");
return;
}
cancelOrder(orderId);
cancelOrder(parseInt(orderId));
}

// UI FUNCTIONS
Expand Down
67 changes: 67 additions & 0 deletions src/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"display_override": [
"window-controls-overlay"
],
"protocol_handlers": [
{
"protocol": "mailto",
"url": "/newEmail?to=%s"
}
],
"name": "Autoswap Cancel Orders",
"short_name": "This name will show in your Windows taskbar, in the start menu, and Android homescreen",
"start_url": "The URL that should be loaded when your application is opened",
"display": "standalone",
"description": "A description for your application",
"lang": " The default language of your application",
"dir": "auto",
"theme_color": "#000000",
"background_color": "#000000",
"orientation": "any",
"icons": [
{
"src": "images/icons/manifest-icon-192.maskable.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "any"
},
{
"src": "images/icons/manifest-icon-192.maskable.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "maskable"
},
{
"src": "images/icons/manifest-icon-512.maskable.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "any"
},
{
"src": "images/icons/manifest-icon-512.maskable.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "maskable"
}
],
"screenshots": [
{
"src": "images/screenshots/1280x800-screenshot.png",
"sizes": "1280x800",
"type": "image/png"
},
{
"src": "images/screenshots/750x1334-screenshot.png",
"sizes": "750x1334",
"type": "image/png"
}
],
"prefer_related_applications": false,
"shortcuts": [
{
"name": "The name you would like to be displayed for your shortcut",
"url": "The url you would like to open when the user chooses this shortcut. This must be a URL local to your PWA. For example: If my start_url is /, this URL must be something like /shortcut",
"description": "A description of the functionality of this shortcut"
}
]
}
Loading

0 comments on commit d0b7bd5

Please sign in to comment.