Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict'
const { Logger, fromJS, toJS, equal, getConfig, getImmutableKey, setImmutableKey }
= require('demo-utils')
const LOGGER = new Logger('client/helpers')
const { RemoteDB } = require('./client')
const assert = require('chai').assert
const helpers = {}
helpers.createInOut = ({hostname, port, autoConfig}) => {
// Autoconfig'd URL and host
const autoURL = getConfig()['DB_URL']
const [ autoScheme, autoHostPort ] = autoURL.split('://')
const [ autoHostname, autoPort ] = autoHostPort.split(':')
assert(autoHostname && autoPort, `Invalid autoconfig URL ${autoURL}`)
LOGGER.debug('createInOut autoconfig URL', autoConfig, autoHostname, autoPort)
const _hostname = (autoConfig) ? autoHostname : hostname
'use strict'
// A departure for AZTEC
const { Map } = require('immutable')
const { AZTEC_TYPES: TYPES } = require('demo-aztec-lib')
const { Logger } = require('demo-utils')
const { assert } = require('chai')
const { toChecksumAddress } = require('ethereumjs-util')
const LOGGER = new Logger('departSP')
depart(Map({
departName : Map({
type : TYPES.string,
value : 'AZTEC Departure',
}),
testValueETH : Map({
type : TYPES.string,
value : '0.2',
}),
testAccountIndex : Map({
type : TYPES.integer,
value : 6,
}),
unlockSeconds : Map({
type: TYPES.integer,
#!/usr/bin/env node
// Run as
// NODE_ENV=TEST node bin/simple.js
// A simple script to test a production-style departure
// outside of a unit test using .env and TEST.DEPLOYER_ADDRESS
const { Map } = require('immutable')
const { Logger } = require('demo-utils')
const LOGGER = new Logger('bin/simple')
const { deployerMixin, compileMixin, departMixin, argListMixin, run } = require('..')
const m0 = argListMixin(Map({
'anotherThing': 'foo',
unlockSeconds: 10,
sourcePathList: ['../test-contracts/contracts'],
}))
const m1 = deployerMixin(Map({}))
const m2 = compileMixin(false)
const m3 = departMixin(Map({
name: 'Simple departure',
}))
const departFunc = async (state) => {
const { compile, link, deploy, bm, deployerEth, deployerAddress, anotherThing } = state.toJS()
LOGGER.info(`Prepared signer at address ${deployerAddress}`)
LOGGER.info(`And another thing ${anotherThing}`)
await compile( 'DifferentSender', 'DifferentSender.sol' )
'use strict'
// Compile with solcjs
const fs = require('fs')
const path = require('path')
const assert = require('chai').assert
const { keccak } = require('ethereumjs-util')
const { List, Map, Set, OrderedMap }
= require('immutable')
const { ContractsManager, awaitOutputter, getInputsToBuild }
= require('demo-contract')
const { traverseDirs, ensureDir, COMPILES_DIR, DEMO_SRC_PATH, fromJS, toJS,
getImmutableKey, setImmutableKey, textsEqual, immEqual, Logger }
= require('demo-utils')
const LOGGER = new Logger('Compiler')
const compiles = {}
const ZEPPELIN_SRC_PATH_WS = '../../node_modules/openzeppelin-solidity/contracts'
const ZEPPELIN_SRC_PATH_PKG = './node_modules/openzeppelin-solidity/contracts'
compiles.ZEPPELIN_SRC_PATH = fs.existsSync(ZEPPELIN_SRC_PATH_WS) ?
ZEPPELIN_SRC_PATH_WS : ZEPPELIN_SRC_PATH_PKG
const { Flattener } = require('./flattener')
/**
* A reusable Compiler for Democracy.js with a search path and custom outputter.
* @class Compiler
* @memberof module:compile
* @param sourcePathList {Array} of strings for local directories. Can omit the `./` for relative paths.
const express = require('express')
const { setImmutableKey: set, getImmutableKey: get, isNetName, fromJS, Logger,
ensureDir, DB_DIR, COMPILES_DIR, LINKS_DIR, DEPLOYS_DIR, FLATS_DIR, OUTS_DIR }
= require('demo-utils')
const { Map } = require('immutable')
const utils = require('ethereumjs-util')
const http = require('http')
const path = require('path')
const LOGGER = new Logger('rest-server')
var bodyParser = require('body-parser')
const server = {}
server.RESTServer = class {
constructor(_port, _allowCORS) {
this.port = _port || 7000
this.app = express()
// configure app to use bodyParser()
// this will let us get the data from a POST
this.app.use(bodyParser.json({limit: '50mb'}));
this.app.use(bodyParser.urlencoded({limit: '5mb', extended: true}));
'use strict'
const assert = require('chai').assert
const { List, Map } = require('immutable')
const { Logger, isNetwork, getImmutableKey, setImmutableKey, LIB_PATTERN, LINKS_DIR }
= require('demo-utils')
const LOGGER = new Logger('Linker')
const { isContract } = require('./contractsManager')
const { BuildsManager } = require('./buildsManager')
const { awaitOutputter, isDeploy, isLink } = require('./utils')
const { keccak } = require('ethereumjs-util')
const linker = {}
linker.replaceLibraries = async (codeToStart, depMap, matches, deployMap) => {
return await depMap.reduce(async (codeSoFar, deployId, contractName) => {
// The linkId to replace for the given linkName can also
// be a full deployName by itself (e.g. TestInterface=TestImpl-deploy)
// in which case, deployId == `TestImpl-deploy` directly
// instead of `TestInterface-deploy`
const deployName = (deployId.startsWith('deploy')) ?
`${contractName}-${deployId}` : deployId
const { Map } = require('immutable')
const util = require('ethereumjs-util')
const assert = require('chai').assert
const aztec = require('aztec.js')
const { constants, proofs }
= require('@aztec/dev-utils')
const secp256k1 = require('@aztec/secp256k1')
const { fromJS, toJS, Logger, getConfig }
= require('demo-utils')
const { isAccount }
= require('demo-keys')
const { checkPublicKey } = require('./utils')
const LOGGER = new Logger('cxFunc')
const statusMap = {
'0': 'OFFCHAIN',
'1': 'UNSPENT',
'2': 'SPENT',
}
const statusFunc = async (state) => {
const {
bm, wallet, chainId, deployed, minedTx, deployerAddress, tradeSymbol,
ownerAddress, noteHash,
} = state.toJS()
// VALIDATE INCOMING PARAMETERS
const erc20Token = await deployed( 'TestERC20',
'use strict'
const assert = require('chai').assert
const { Map } = require('immutable')
const { begin, end } = require('./top')
const { Logger } = require('demo-utils')
const LOGGER = new Logger('depart/shims')
const shims = {}
let forksOpen = 0
let flowsOpen = 0
// Only make the flow command available within run files
shims.flowDepart = async (name, inputState) => {
flowsOpen += 1
assert(Map.isMap(inputState), 'Input state should be immutable Map')
const outState = (await begin(inputState, false))
return outState
}
shims.forkDepart = async (name, inputState) => {
forksOpen += 1
const { Compiler } = require('..')
const { Logger } = require('demo-utils')
const LOGGER = new Logger('compiler/scripts')
const c = new Compiler({sourcePathList: ['../test-contracts/contracts'] })
const sourceFile = process.argv[2]
LOGGER.info('Source File', sourceFile)
const main = async () => {
await c.compile( sourceFile )
}
main().then(() => { console.log("That's all folks") })
const { Map } = require('immutable')
const { wallet } = require('demo-keys')
const { forkDepart, forkDone } = require('../src/shims')
const assert = require('chai').assert
const { Logger } = require('demo-utils')
const LOGGER = new Logger('example.flow')
const BN = require('bn.js')
describe('Flow example 1', () => {
let dsState
before(async () => {
dsState = await forkDepart('DifferentSender', Map({
departFileName: 'departDS.js'
}))
})
it('some test', async () => {
LOGGER.info('Deployer Account', wallet.accountsMap[dsState.get('deployerAddress')])
})