Merge branch 'master' into check-against-null-addresses

pull/658/head
James Sangalli 6 years ago committed by GitHub
commit a8b4f05b58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      AlphaWallet.xcodeproj/project.pbxproj
  2. 3
      JS/.babelrc
  3. 1
      JS/dist/trust-min.js
  4. 57468
      JS/dist/trust.js
  5. 67
      JS/gulpfile.babel.js
  6. 6801
      JS/package-lock.json
  7. 46
      JS/package.json
  8. 100
      JS/src/index.js

@ -497,7 +497,6 @@
771AA964200D5EDB00D25403 /* WordCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 771AA963200D5EDB00D25403 /* WordCollectionViewCell.swift */; };
771AA966200D5F1900D25403 /* WordCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 771AA965200D5F1900D25403 /* WordCollectionViewCell.xib */; };
7721A6BE202A5677004DB16C /* DecryptError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7721A6BD202A5677004DB16C /* DecryptError.swift */; };
7721A6C4202D9520004DB16C /* trust-min.js in Resources */ = {isa = PBXBuildFile; fileRef = 7721A6C3202D9520004DB16C /* trust-min.js */; };
7721A6C8202EF81B004DB16C /* CustomRPC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7721A6C7202EF81B004DB16C /* CustomRPC.swift */; };
7721A6CC202EFBC5004DB16C /* AddCustomNetworkViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7721A6CB202EFBC5004DB16C /* AddCustomNetworkViewController.swift */; };
7721A6CE202EFC21004DB16C /* AddCustomNetworkViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7721A6CD202EFC21004DB16C /* AddCustomNetworkViewModel.swift */; };
@ -1074,7 +1073,6 @@
771AA965200D5F1900D25403 /* WordCollectionViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = WordCollectionViewCell.xib; sourceTree = "<group>"; };
7721A6BD202A5677004DB16C /* DecryptError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DecryptError.swift; sourceTree = "<group>"; };
7721A6BF202B1D3E004DB16C /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = "<group>"; };
7721A6C3202D9520004DB16C /* trust-min.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = "trust-min.js"; path = "JS/dist/trust-min.js"; sourceTree = SOURCE_ROOT; };
7721A6C7202EF81B004DB16C /* CustomRPC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomRPC.swift; sourceTree = "<group>"; };
7721A6CB202EFBC5004DB16C /* AddCustomNetworkViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddCustomNetworkViewController.swift; sourceTree = "<group>"; };
7721A6CD202EFC21004DB16C /* AddCustomNetworkViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddCustomNetworkViewModel.swift; sourceTree = "<group>"; };
@ -1492,7 +1490,6 @@
291F52AA1F6B805400B369AB /* Vendors */ = {
isa = PBXGroup;
children = (
7721A6C2202D94FC004DB16C /* JSWeb3Provider */,
2981C29A1FC18F6000537E43 /* Changelly */,
298542E61FBA9BA900CB5081 /* ShapeShift */,
295996041FAAFC9400DB66A8 /* Coinbase */,
@ -2869,14 +2866,6 @@
path = Views;
sourceTree = "<group>";
};
7721A6C2202D94FC004DB16C /* JSWeb3Provider */ = {
isa = PBXGroup;
children = (
7721A6C3202D9520004DB16C /* trust-min.js */,
);
path = JSWeb3Provider;
sourceTree = "<group>";
};
77872D2A202514930032D687 /* Wallet */ = {
isa = PBXGroup;
children = (
@ -3207,7 +3196,6 @@
files = (
C876FF82204A79D300B7D0EA /* SourceSansPro-Light.otf in Resources */,
C876FF84204A79D300B7D0EA /* SourceSansPro-Regular.otf in Resources */,
7721A6C4202D9520004DB16C /* trust-min.js in Resources */,
C868C5292053BDE00059672B /* LaunchScreen.storyboard in Resources */,
C876FF85204A79D300B7D0EA /* SourceSansPro-Semibold.otf in Resources */,
C880330E2054371500D73D6F /* non_asset_catalog_redemption_location@3x.png in Resources */,

@ -1,3 +0,0 @@
{
"presets": ["env"]
}

File diff suppressed because one or more lines are too long

57468
JS/dist/trust.js vendored

File diff suppressed because it is too large Load Diff

@ -1,67 +0,0 @@
const gulp = require('gulp'),
babelify = require('babelify'),
browserify = require('browserify'),
buffer = require('vinyl-buffer'),
del = require('del'),
minify = require('gulp-minify'),
runSequence = require('run-sequence'),
size = require('gulp-size'),
source = require('vinyl-source-stream'),
config = {
name: 'trust',
fileTypes: {
all: '**/*',
js: '**/*.js',
main: 'index.js'
},
source: {
baseDir: 'src'
},
staging: {
baseDir: 'staging'
},
distribution: {
baseDir: 'dist',
javascript: 'js'
}
};
gulp.task('clean', function (callback) {
runSequence('clean:dist', 'clean:stage', callback);
});
gulp.task('clean:stage', function () {
let stagingDir = `${config.staging.baseDir}/${config.fileTypes.all}`;
return del.sync(stagingDir);
});
gulp.task('clean:dist', function () {
let distributionDir = `${config.distribution.baseDir}/${config.fileTypes.all}`;
return del.sync(distributionDir);
});
gulp.task('javascript', function () {
let sourceDir = `${config.source.baseDir}/${config.fileTypes.js}`,
stagingDir = `${config.staging.baseDir}`;
return gulp.src(sourceDir)
.pipe(gulp.dest(stagingDir));
});
gulp.task('bundle:javascript', ['javascript', ], function () {
let mainFile = `${config.staging.baseDir}/${config.fileTypes.main}`,
distributionDir = `${config.distribution.baseDir}`;
return browserify(mainFile)
.transform(babelify, { presets: ['env'] })
.bundle()
.pipe(source(config.name + '.js'))
.pipe(buffer())
.pipe(minify())
.pipe(size())
.pipe(gulp.dest(distributionDir));
});
gulp.task('build', function (callback) {
runSequence('clean:dist', 'clean:stage', ['bundle:javascript'],
callback);
});

6801
JS/package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -1,46 +0,0 @@
{
"name": "trust-wallet",
"version": "0.0.1",
"description": "web3 injection",
"main": "index.js",
"scripts": {
"test": "test"
},
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/TrustWallet/trust-wallet-ios.git"
},
"keywords": [
"ethereum",
"swift",
"blockchain",
"wallet",
"ethereum-dapps",
"dapps"
],
"author": "Trust <support@trustwalletapp.com>",
"license": "GPL-3.0",
"bugs": {
"url": "https://github.com/TrustWallet/trust-wallet-ios/issues"
},
"homepage": "https://github.com/TrustWallet/trust-wallet-ios#readme",
"devDependencies": {
"babel-preset-env": "^1.6.1",
"babel-preset-es2015": "^6.24.1",
"babelify": "^8.0.0",
"browserify": "^15.2.0",
"del": "^3.0.0",
"gulp": "^3.9.1",
"gulp-minify": "^2.1.0",
"gulp-rename": "^1.2.2",
"gulp-size": "^3.0.0",
"run-sequence": "^2.2.1",
"vinyl-buffer": "^1.0.1",
"vinyl-source-stream": "^2.0.0"
},
"dependencies": {
"babel-core": "^6.26.0",
"web3": "^0.20.4",
"web3-provider-engine": "^13.6.0"
}
}

@ -1,100 +0,0 @@
const Web3 = require('web3')
const ProviderEngine = require('web3-provider-engine')
const HookedWalletSubprovider = require('web3-provider-engine/subproviders/hooked-wallet.js')
const FilterSubprovider = require('web3-provider-engine/subproviders/filters.js')
const Web3Subprovider = require("web3-provider-engine/subproviders/web3.js")
const context = window || global
context.chrome = { webstore: true }
context.Web3 = Web3
let callbacks = {}
let hookedSubProvider
let globalSyncOptions = {}
const Trust = {
init (rpcUrl, options, syncOptions) {
const engine = new ProviderEngine()
const web3 = new Web3(engine)
context.web3 = web3
globalSyncOptions = syncOptions
engine.addProvider(hookedSubProvider = new HookedWalletSubprovider(options))
engine.addProvider(new FilterSubprovider())
engine.addProvider(new Web3Subprovider(new Web3.providers.HttpProvider(rpcUrl)))
engine.on('error', err => console.error(err.stack))
engine.isTrust = true
engine.start()
return engine
},
addCallback (id, cb, isRPC) {
cb.isRPC = isRPC
callbacks[id] = cb
},
executeCallback (id, error, value) {
console.log(`executing callback: \nid: ${id}\nvalue: ${value}\nerror: ${error}\n`)
let callback = callbacks[id]
if (callback.isRPC) {
const response = {'id': id, jsonrpc: '2.0', result: value, error: {message: error} }
if (error) {
callback(response, null)
} else {
callback(null, response)
}
} else {
callback(error, value)
}
delete callbacks[id]
}
}
if (typeof context.Trust === 'undefined') {
context.Trust = Trust
}
ProviderEngine.prototype.send = function (payload) {
const self = this
let result = null
switch (payload.method) {
case 'eth_accounts':
let address = globalSyncOptions.address
result = address ? [address] : [] || null
break
case 'eth_coinbase':
result = globalSyncOptions.address || null
break
case 'eth_uninstallFilter':
self.sendAsync(payload, noop)
result = true
break
case 'net_version':
result = globalSyncOptions.networkVersion || null
break
// throw not-supported Error
default:
var link = 'https://github.com/MetaMask/faq/blob/master/DEVELOPERS.md#dizzy-all-async---think-of-metamask-as-a-light-client'
var message = `The MetaMask Web3 object does not support synchronous methods like ${payload.method} without a callback parameter. See ${link} for details.`
throw new Error(message)
}
// return the result
return {
id: payload.id,
jsonrpc: payload.jsonrpc,
result: result,
}
}
module.exports = Trust
Loading…
Cancel
Save