-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mini v0 #14
Open
johnwhitton
wants to merge
35
commits into
main
Choose a base branch
from
miniV0
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Mini v0 #14
Changes from 30 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
c0473e2
Initial version of miniwallet server
johnwhitton ac251c4
Add in sms message parsing and responses in twilio format
johnwhitton e45388c
Fix logic error in funding where funder and recipient were backwards
johnwhitton a234cf9
WIP: Begin work on Miniserver multiple operators per node and other f…
johnwhitton 70ee740
WIP add executor logic to blockchain.js to support multiple accounts …
johnwhitton 4b988b4
Working version of executor supporting multiple accounts via mnemonic
johnwhitton a47c25b
Remove miniserver src/data files and use servers for now (consider mo…
johnwhitton 86c7933
Improve error handling for miniserver
johnwhitton 9d4ab08
rename AssetManager to MiniWallet
johnwhitton b55e00c
Make MiniWallet Approval function payable and call deposit
johnwhitton 5450eeb
Add in Logic for Proxy Upgrades for miniwallet
johnwhitton 559f191
Initial Scaffolding for NFTs Mini721 and Mini1155 contracts
johnwhitton 5990a9d
Clean up server and deploy logic (Feedback from PR 7 and 8)
johnwhitton 21ae963
Remove unused config in miniserver
johnwhitton de7e7c5
Clean up MiniWallt_v2.sol and redeploy locally
johnwhitton 875227f
Rename HRC721 to ERC721M (for MiniWallet)
johnwhitton a63d850
NFT Identity improvements around testing and config
johnwhitton 56d8d31
Merge branch 'main' into miniV0
johnwhitton b4b87d1
MiniWallet NFT Testing remove unused code and improve readability
johnwhitton 534e54f
Add in Deploy for Mini721 and update configuration
johnwhitton c746fef
Draft NFTId design
johnwhitton 5ae56da
NFTID.md add additional reference info
johnwhitton c969982
Add MiniID contract and update Proxy Deployments
johnwhitton 80c707c
Initial scaffolding for MiniID API
johnwhitton 79510f8
Initial scaffolding for MiniID API (all files)
johnwhitton 076c675
Initial work on including new Tokens MiniID,Mini721 and Mini1155
johnwhitton 7f3c01b
Fix miniwallet contract deployments and get client showing NFT's
johnwhitton 2a024ef
Update miniwallet nfts
johnwhitton b0c1a5c
Remove DUMMY_NFTs for testing and update NFTID.md
johnwhitton 8b60043
Initial lookup and getId api's for miniId
johnwhitton 1ad5a46
Implement our own ERC1967 Proxy and test upgrade process for MiniWall…
johnwhitton 1aeb0c7
Move NFTID and Proxy design docs into devlog
johnwhitton f851991
Refactor miniWallet for different streams miniWallet, miniId and Mini…
johnwhitton 696d0e2
Fix minor mistake in Miniwallet CONFIGURATION.md
johnwhitton 38a01cb
Clean up miniwallet configuration based on miniV0 feedback
johnwhitton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Server Configuration | ||
SERVER_URL='https://localhost' | ||
PORT=3101 | ||
HTTPS_PORT=8444 | ||
|
||
|
||
## Configurable (set these values to change default behaviour for local testing) | ||
MINISERVER_DEBUG=1 | ||
RELAYER_DEBUG=1 | ||
VERBOSE=1 | ||
SAFE_NONCE=1 | ||
APIDOCS=1 | ||
|
||
## Mandatory | ||
CORS=* | ||
SECRET='none' | ||
|
||
# Datastore | ||
GCP_PROJECT='sms-wallet-00' | ||
GCP_CRED_PATH='./credentials/sms-wallet-00-a91857ffcaaf.json' | ||
GCP_NAMESPACE='sms-wallet' | ||
|
||
# Twilio | ||
TWILIO_ACCOUNT_SID= | ||
TWILIO_AUTH_TOKEN= | ||
TWILIO_FROM= | ||
|
||
# OTP | ||
OTP_SALT='local-salt' | ||
|
||
# Client | ||
CLIENT_ROOT='https://localhost:3100/' | ||
|
||
## Netork Information | ||
# eth-local | ||
ETH_LOCAL_RPC='http://127.0.0.1:8545' | ||
ETH_LOCAL_WSS='ws://127.0.0.1:8545' | ||
ETH_LOCAL_KEY='0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d' | ||
ETH_LOCAL_MNEMONIC='test test test test test test test test test test test junk' | ||
ETH_LOCAL_NUM_ACCOUNTS=3 | ||
ETH_LOCAL_MINI_WALLET=0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 | ||
ETH_LOCAL_MINI_ID=0x5FC8d32690cc91D4c39d9d3abcBD16989F875707 | ||
|
||
## Default Values (can be ommitted) | ||
POLLING_INTERVAL=1000 | ||
DEFAULT_NETWORK='eth-local' | ||
GAS_LIMIT='67219000' | ||
#GAS_PRICE='10000000' | ||
GAS_PRICE='413290302' | ||
CACHE='cache' | ||
STATS_PATH='../data/stats.json' | ||
OTP_INTERVAL=60000 | ||
|
||
|
||
|
||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
module.exports = { | ||
root: true, | ||
env: { | ||
node: true, | ||
es2020: true, | ||
jest: true, | ||
}, | ||
extends: [ | ||
'standard', | ||
], | ||
globals: { | ||
artifacts: 'readonly', | ||
contract: 'readonly', | ||
assert: 'readonly', | ||
ethers: 'readonly' | ||
}, | ||
// 'parser': '@babel/eslint-parser', | ||
rules: { | ||
'no-await-in-loop': 0, | ||
'no-underscore-dangle': 0, | ||
'import/prefer-default-export': 0, | ||
'import/no-extraneous-dependencies': 1, | ||
'comma-dangle': 0, | ||
'no-console': 0, | ||
'no-mixed-operators': 0, | ||
'new-cap': 0, | ||
'max-len': 0, | ||
}, | ||
parserOptions: { | ||
requireConfigFile: false, | ||
ecmaVersion: 2020 | ||
}, | ||
plugins: [ | ||
'@babel', | ||
], | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/credentials | ||
/certs/* | ||
!/certs/README.md | ||
!/certs/gen.sh |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
require('dotenv').config() | ||
const createError = require('http-errors') | ||
// const rateLimit = require('express-rate-limit') | ||
const Fingerprint = require('express-fingerprint') | ||
const express = require('express') | ||
const path = require('path') | ||
const cookieParser = require('cookie-parser') | ||
const logger = require('morgan') | ||
const config = require('./config') | ||
const _index = require('./routes/index') | ||
const _minIID = require('./routes/miniID') | ||
const bodyParser = require('body-parser') | ||
const app = express() | ||
const https = require('https') | ||
const http = require('http') | ||
const env = process.env.NODE_ENV || 'development' | ||
const fs = require('fs') | ||
const blockchain = require('./blockchain') | ||
|
||
Error.stackTraceLimit = 100 | ||
app.locals.ENV = env | ||
app.locals.ENV_DEVELOPMENT = env === 'development' | ||
|
||
app.set('trust proxy', true) | ||
|
||
try { | ||
blockchain.init().catch(ex => { | ||
console.error('Blockchain initialization failed') | ||
console.error(ex) | ||
process.exit(2) | ||
}) | ||
} catch (ex) { | ||
console.error(ex) | ||
process.exit(1) | ||
} | ||
|
||
let httpServer, httpsServer | ||
|
||
const httpsOptions = { | ||
key: fs.readFileSync(config.https.key), | ||
cert: fs.readFileSync(config.https.cert) | ||
} | ||
|
||
if (config.https.only) { | ||
const httpApp = express() | ||
const httpRouter = express.Router() | ||
httpApp.use('*', httpRouter) | ||
httpRouter.get('*', function (req, res) { | ||
const hostPort = (req.get('host') || '').split(':') | ||
const url = hostPort.length === 2 ? `https://${hostPort[0]}:${config.httpsPort}${req.originalUrl}` : `https://${hostPort[0]}${req.originalUrl}` | ||
res.redirect(url) | ||
}) | ||
httpServer = http.createServer(httpApp) | ||
} else { | ||
httpServer = http.createServer(app) | ||
} | ||
|
||
httpsServer = https.createServer(httpsOptions, app) | ||
|
||
app.use(Fingerprint({ | ||
parameters: [ | ||
Fingerprint.useragent, | ||
Fingerprint.acceptHeaders, | ||
Fingerprint.geoip, | ||
] | ||
})) | ||
|
||
app.use(bodyParser.json({ | ||
verify: function (req, _res, buf) { | ||
req.rawBody = buf | ||
} | ||
})) | ||
app.use(bodyParser.urlencoded({ extended: true })) | ||
app.use(logger('dev')) | ||
app.use(express.json()) | ||
app.use(express.urlencoded({ extended: false })) | ||
app.use(cookieParser()) | ||
|
||
if (config.corsOrigins) { | ||
app.use((req, res, next) => { | ||
// res.header('Access-Control-Allow-Origin', config.corsOrigins) | ||
if (config.corsOrigins === '*' || config.corsOrigins.indexOf(req.headers.origin) >= 0) { | ||
res.header('Access-Control-Allow-Origin', req.headers.origin || config.corsOrigins) | ||
} else { | ||
res.header('Access-Control-Allow-Origin', config.corsOrigins) | ||
} | ||
|
||
res.header('Access-Control-Allow-Credentials', 'true') | ||
|
||
res.header('Access-Control-Allow-Methods', 'GET, PUT, POST, DELETE, OPTIONS') | ||
|
||
res.header('Access-Control-Allow-Headers', 'X-SECRET, X-NETWORK, X-MAJOR-VERSION, X-MINOR-VERSION, Accept, Accept-CH, Accept-Charset, Accept-Datetime, Accept-Encoding, Accept-Ext, Accept-Features, Accept-Language, Accept-Params, Accept-Ranges, Access-Control-Allow-Credentials, Access-Control-Allow-Headers, Access-Control-Allow-Methods, Access-Control-Allow-Origin, Access-Control-Expose-Headers, Access-Control-Max-Age, Access-Control-Request-Headers, Access-Control-Request-Method, Age, Allow, Alternates, Authentication-Info, Authorization, C-Ext, C-Man, C-Opt, C-PEP, C-PEP-Info, CONNECT, Cache-Control, Compliance, Connection, Content-Base, Content-Disposition, Content-Encoding, Content-ID, Content-Language, Content-Length, Content-Location, Content-MD5, Content-Range, Content-Script-Type, Content-Security-Policy, Content-Style-Type, Content-Transfer-Encoding, Content-Type, Content-Version, Cookie, Cost, DAV, DELETE, DNT, DPR, Date, Default-Style, Delta-Base, Depth, Derived-From, Destination, Differential-ID, Digest, ETag, Expect, Expires, Ext, From, GET, GetProfile, HEAD, HTTP-date, Host, IM, If, If-Match, If-Modified-Since, If-None-Match, If-Range, If-Unmodified-Since, Keep-Alive, Label, Last-Event-ID, Last-Modified, Link, Location, Lock-Token, MIME-Version, Man, Max-Forwards, Media-Range, Message-ID, Meter, Negotiate, Non-Compliance, OPTION, OPTIONS, OWS, Opt, Optional, Ordering-Type, Origin, Overwrite, P3P, PEP, PICS-Label, POST, PUT, Pep-Info, Permanent, Position, Pragma, ProfileObject, Protocol, Protocol-Query, Protocol-Request, Proxy-Authenticate, Proxy-Authentication-Info, Proxy-Authorization, Proxy-Features, Proxy-Instruction, Public, RWS, Range, Referer, Refresh, Resolution-Hint, Resolver-Location, Retry-After, Safe, Sec-Websocket-Extensions, Sec-Websocket-Key, Sec-Websocket-Origin, Sec-Websocket-Protocol, Sec-Websocket-Version, Security-Scheme, Server, Set-Cookie, Set-Cookie2, SetProfile, SoapAction, Status, Status-URI, Strict-Transport-Security, SubOK, Subst, Surrogate-Capability, Surrogate-Control, TCN, TE, TRACE, Timeout, Title, Trailer, Transfer-Encoding, UA-Color, UA-Media, UA-Pixels, UA-Resolution, UA-Windowpixels, URI, Upgrade, User-Agent, Variant-Vary, Vary, Version, Via, Viewport-Width, WWW-Authenticate, Want-Digest, Warning, Width, X-Content-Duration, X-Content-Security-Policy, X-Content-Type-Options, X-CustomHeader, X-DNSPrefetch-Control, X-Forwarded-For, X-Forwarded-Port, X-Forwarded-Proto, X-Frame-Options, X-Modified, X-OTHER, X-PING, X-PINGOTHER, X-Powered-By, X-Requested-With') | ||
next() | ||
}) | ||
} | ||
|
||
app.use(express.static(path.join(__dirname, 'public'))) | ||
app.options('*', async (_req, res) => res.end()) | ||
app.use('/', _index) | ||
app.use('/id', _minIID) | ||
|
||
// catch 404 and forward to error handler | ||
app.use(function (req, res, next) { | ||
next(createError(404)) | ||
}) | ||
|
||
// error handler | ||
app.use(function (err, req, res, next) { | ||
// set locals, only providing error in development | ||
res.locals.message = err.message | ||
res.locals.error = config.debug ? err : {} | ||
|
||
// render the error page | ||
res.status(err.status || 500) | ||
res.json({ error: res.locals.error, message: err.message }) | ||
}) | ||
|
||
module.exports = { | ||
httpServer, | ||
httpsServer | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env node | ||
const apps = require('../app') | ||
const config = require('../config') | ||
const httpsServer = apps.httpsServer | ||
const httpServer = apps.httpServer | ||
console.log('Starting web server...') | ||
|
||
httpsServer.listen(config.httpsPort || 8443, () => { | ||
const addr = httpsServer.address() | ||
console.log(`HTTPS server listening on port ${addr.port} at ${addr.address}`) | ||
}) | ||
|
||
httpServer.listen(config.port || 3000, () => { | ||
const addr = httpServer.address() | ||
console.log(`HTTP server listening on port ${addr.port} at ${addr.address}`) | ||
}) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we should move nfts to config file, keyed by chain (name)?