This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { getReducer, getState } from '../util/redux-util' | |
//default state | |
const defaultState = { | |
toggle: false | |
} | |
//reducer | |
const type = 'appReducer' | |
export const appReducer = getReducer(type, defaultState) | |
export const appState = getState(type) | |
//actions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -X GET http://localhost:9500 -H 'Content-Type: application/json' -d '{ | |
"jsonrpc":"2.0", | |
"method":"hmy_estimateGas", | |
"params":[{ | |
"from": "0x7c41e0668b551f4f902cfaec05b5bdca68b124ce", | |
"to": "0x7c41e0668b551f4f902cfaec05b5bdca68b124ce", | |
"value": "0x1" | |
}], | |
"id": 1 | |
}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//only handles integerValue, doubleValue, stringValue and booleanValue | |
const getType = (val) => { | |
if (val === null) return 'nullValue' | |
const t = typeof val | |
switch (t) { | |
case 'number': return n % 1 === 0 ? 'integerValue' : 'doubleValue' | |
case 'string': | |
case 'boolean': | |
return t + 'Value' | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SHARD0=https://api.s0.b.hmny.io | |
SHARD1=https://api.s1.b.hmny.io | |
SHARD2=https://api.s2.b.hmny.io | |
#your params | |
SHARD=SHARD1 | |
#example is HRC20 mint and transfer | |
TXID=0x039d2f87e6bdb81220e5a7490dc783ea835443f57f4e12d16d90dd0b3aa1f5af | |
#curl | |
curl -X POST $SHARD1 -H 'Accept: */*' -H 'Accept-Encoding: gzip, deflate' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' -H 'Content-Length: 162' -H 'Content-Type: application/json' -H 'Host: api.s1.b.hmny.io' -H 'Postman-Token: d5415117-657a-49f9-9100-a5b7ebc70daf,cc2f3cb9-2d10-408c-a003-d6e0822ec985' -H 'User-Agent: PostmanRuntime/7.19.0' -H 'cache-control: no-cache' -d '{ | |
"jsonrpc":"2.0", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/******************************** | |
* Module for generating and verifying JWT tokens | |
* Designed to work on Cloudflare Workers | |
* Should work in the browser or any env that supports Web Crypto API | |
********************************/ | |
/******************************** | |
* Key secret is a random Uint8Array of length 64 | |
* See below for instructions on generating random values / keys | |
********************************/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/******************************** | |
* GA data | |
********************************/ | |
let data = { | |
v: 1, | |
} | |
/******************************** | |
* Initializes GA data | |
* @param {string} tid your tracking id for GA | |
* @param {object} req the request object from event.request |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//FROM HERE: https://stackoverflow.com/a/54123275/1060487 | |
// base64 to buffer | |
function base64ToBufferAsync(base64) { | |
var dataUrl = "data:application/octet-binary;base64," + base64; | |
fetch(dataUrl) | |
.then(res => res.arrayBuffer()) | |
.then(buffer => { | |
console.log("base64 to buffer: " + new Uint8Array(buffer)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//example functions to set redux state of UI components | |
const {setDrawerState, setDialogState, setPopoverState} = ['Drawer', 'Dialog', 'Popover'].map((name) => ({ | |
['set' + name + 'State']: (state) => async (dispatch, getState) => { | |
const stateName = name.toLowerCase() + 'State' | |
const currentState = getState().appReducer[stateName] | |
dispatch({ type: 'UPDATE_UI_STATE', [stateName]: { ...currentState, ...state } }) | |
} | |
})).reduce((a, c) => ({...a, ...c})) | |
export { setDrawerState, setDialogState, setPopoverState } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const POST = (auth) => ({ | |
method: "POST", // *GET, POST, PUT, DELETE, etc. | |
mode: "cors", // no-cors, cors, *same-origin | |
headers: { | |
"Content-Type": "application/json", | |
...(auth ? { "Authorization": auth } : {}) | |
}, | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>YouTube Search Example</title> | |
<meta name="description" content="YouTube Search Example"> | |
<meta name="author" content="Matt Lockyer"> | |
</head> |