Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
require = require('esm')(module /*, options */) // use to handle es6 import/export
const AeSDK = require('@aeternity/aepp-sdk');
const Crypto = AeSDK.Crypto;
const toBytes = require('@aeternity/aepp-sdk/es/utils/bytes').toBytes;
function keyToHex (publicKey) {
let byteArray = Crypto.decodeBase58Check(publicKey.split('_')[1]);
let asHex = '#' + byteArray.toString('hex');
return asHex;
}
const isKeyPair = (k) => {
if (k == null) {
return false
}
if (typeof k != 'object') {
return false
}
require = require('esm')(module /*, options */) // use to handle es6 import/export
let axios = require('axios');
const fs = require('fs');
const path = require('path')
const AeSDK = require('@aeternity/aepp-sdk');
const Universal = AeSDK.Universal;
let rgx = /^include\s+\"([\d\w\/\.\-\_]+)\"/gmi;
let dependencyPathRgx = /"([\d\w\/\.\-\_]+)\"/gmi;
const mainContractsPathRgx = /.*\//g;
let match;
const config = require('../../aeproject-config/config/config.json');
const {
printError
} = require('./fs-utils')
const {
spawn,
exec
} = require('promisify-child-process');
const COMPILER_URL_POSTFIX = '/compile';
* ISC License (ISC)
* Copyright (c) 2018 aeternity developers
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
const Ae = require('@aeternity/aepp-sdk').Universal;
const fs = require('fs');
const path = require('path');
const config = {
host: "http://localhost:3001/",
internalHost: "http://localhost:3001/internal/",
gas: 200000,
ttl: 55,
compilerUrl: 'https://compiler.aepps.com'
// compilerUrl: 'http://localhost:3080'
}
let contractPath = path.resolve(__dirname, './../contracts/ExampleContract.aes');
let contractSource = fs.readFileSync(contractPath, 'utf8');
describe('Example Contract', () => {
require = require('esm')(module /*, options */) // use to handle es6 import/export
const AeSDK = require('@aeternity/aepp-sdk');
const Universal = AeSDK.Universal;
const ContractCompilerAPI = AeSDK.ContractCompilerAPI;
const config = require('forgae-config');
const {
printError
} = require('./fs-utils')
const {
spawn
} = require('promisify-child-process');
const getClient = async function (network, keypair = config.keypair) {
let client;
let internalUrl = network.url;
if (network.url.includes("localhost")) {
require = require('esm')(module /*, options */) // use to handle es6 import/export
const AeSDK = require('@aeternity/aepp-sdk');
const Universal = AeSDK.Universal;
const ContractCompilerAPI = AeSDK.ContractCompilerAPI;
const config = require('forgae-config');
const {
printError
} = require('./fs-utils')
const {
spawn
} = require('promisify-child-process');
const getClient = async function (network, keypair = config.keypair) {
let client;
let internalUrl = network.url;
if (network.url.includes("localhost")) {
internalUrl = internalUrl + "/internal"
* ISC License (ISC)
* Copyright (c) 2018 aeternity developers
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
const Ae = require('@aeternity/aepp-sdk').Universal;
const Deployer = require('aeproject-lib').Deployer;
const gasLimit = 1000000;
const deploy = async (network, privateKey) => {
let deployer = new Deployer(network, privateKey)
let result = await deployer.deploy("./contracts/ToDoManager.aes")
};
module.exports = {
deploy
};
const fs = require('fs');
const defaultDeploymentFilePath = `deployment/deploy.js`;
const AeSDK = require('@aeternity/aepp-sdk');
const Crypto = AeSDK.Crypto;
const path = require('path');
const verifyDeploymentFile = (deploymentFile) => {
if (!fs.existsSync(deploymentFile)) {
throw new Error(`${deploymentFile} file not found. Probably you've not initialized aeproject. Please run aeproject init first.`)
}
};
const getDeployMethod = (deploymentFilePath) => {
const _deploymentFilePath = (deploymentFilePath) ? deploymentFilePath : defaultDeploymentFilePath;
verifyDeploymentFile(_deploymentFilePath);
const deploymentFile = path.resolve(process.cwd(),_deploymentFilePath);
const deployModule = require(deploymentFile);
return deployModule.deploy;
await handleApiError(async () => {
client = await Universal({
url: network.url,
internalUrl,
accounts: [AeSDK.MemoryAccount({
keypair
})],
nativeMode: true,
networkId: network.networkId,
compilerUrl: network.compilerUrl
})
});
function decodedHexAddressToPublicAddress (hexAddress) {
const publicKey = Crypto.aeEncodeKey(toBytes(hexAddress, true));
return publicKey;
}