forked from mradkov/BondingCurve
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
2,771 additions
and
255 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
node_modules | ||
.aeproject-store | ||
.DS_Store | ||
package-lock.json | ||
.idea | ||
|
||
*.aes.js | ||
generated/*.aes.js |
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,90 @@ | ||
const { utils, networks } = require("@aeternity/aeproject"); | ||
const fs = require("fs"); | ||
const crypto = require("crypto"); | ||
const path = require("path"); | ||
const { CompilerHttp, hash, getFileSystem} = require("@aeternity/aepp-sdk"); | ||
|
||
// add contract paths from base | ||
const CONTRACTS = [ | ||
"Bond.aes", | ||
"BondCurveLinear.aes", | ||
]; | ||
|
||
function generateSourceHashes() { | ||
const hashes = CONTRACTS.reduce((acc, contract) => { | ||
const source = fs.readFileSync("./contracts/" + contract, "utf-8"); | ||
acc[contract] = Buffer.from(hash(source)).toString("base64"); | ||
return acc; | ||
}, {}); | ||
|
||
fs.writeFileSync( | ||
"./generated/source_hashes.json", | ||
JSON.stringify(hashes, null, 2), | ||
); | ||
} | ||
|
||
function writeAci(aci, contract) { | ||
fs.writeFileSync( | ||
`${__dirname}/../generated/${path.basename(contract, ".aes")}.aci.json`, | ||
JSON.stringify(aci, null, 2), | ||
"utf-8", | ||
); | ||
} | ||
|
||
async function generateBytecodeAci() { | ||
const aeSdk = await utils.getSdk(); | ||
|
||
const bytecode_hashes = await CONTRACTS.reduce( | ||
async (promiseAcc, contract) => { | ||
const acc = await promiseAcc; | ||
const fileSystem = await getFileSystem( | ||
"./contracts/" + contract, | ||
); | ||
let sourceCode = utils.getContractContent("./contracts/" + contract); | ||
|
||
try { | ||
const compiled = await aeSdk.compilerApi.compileBySourceCode( | ||
sourceCode, | ||
fileSystem, | ||
); | ||
|
||
const compilerVersion = await aeSdk.compilerApi.version(); | ||
if (!acc[compilerVersion]) acc[compilerVersion] = {}; | ||
|
||
acc[compilerVersion][contract] = { | ||
hash: crypto | ||
.createHash("sha256") | ||
.update(compiled.bytecode) | ||
.digest("hex"), | ||
bytecode: compiled.bytecode, | ||
}; | ||
|
||
writeAci(compiled.aci, contract); | ||
} catch (e) { | ||
console.log( | ||
"falling back to just aci generation without compilation for", | ||
contract, | ||
e.message, | ||
); | ||
|
||
const compilerHttp = new CompilerHttp(networks.devmode.compilerUrl); | ||
await compilerHttp | ||
.generateAciBySourceCode(sourceCode, fileSystem) | ||
.then((aci) => writeAci(aci, contract)) | ||
.catch(console.error); | ||
} | ||
|
||
return acc; | ||
}, | ||
Promise.resolve({}), | ||
); | ||
|
||
fs.writeFileSync( | ||
"./generated/bytecode_hashes.json", | ||
JSON.stringify(bytecode_hashes, null, 2), | ||
"utf-8", | ||
); | ||
} | ||
|
||
generateSourceHashes(); | ||
void generateBytecodeAci(); |
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 |
---|---|---|
@@ -1,8 +1,5 @@ | ||
const fs = require('fs'); | ||
|
||
const BondCurveLinear = fs.readFileSync(__dirname + '/../contracts/BondCurveLinear.aes', 'utf-8'); | ||
fs.writeFileSync(__dirname + '/../BondCurveLinear.aes.js', `module.exports = \`\n${BondCurveLinear.replace(/`/g, "\\`")}\`;\n`, 'utf-8'); | ||
|
||
const BondCurveLinearInterface = fs.readFileSync(__dirname + '/../contracts/BondCurveLinearInterface.aes', 'utf-8'); | ||
fs.writeFileSync(__dirname + '/../BondCurveLinearInterface.aes.js', `module.exports = \`\n${BondCurveLinearInterface.replace(/`/g, "\\`")}\`;\n`, 'utf-8'); | ||
fs.writeFileSync(__dirname + '/../generated/BondCurveLinear.aes.js', `module.exports = \`\n${BondCurveLinear.replace(/`/g, "\\`")}\`;\n`, 'utf-8'); | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,18 +1,34 @@ | ||
version: '3' | ||
version: "3.6" | ||
services: | ||
node: | ||
image: 'aeternity/aeternity:${NODE_TAG}' | ||
aeproject_node: | ||
image: aeternity/aeternity:${NODE_TAG:-v7.0.0}-bundle | ||
hostname: node | ||
# TODO: remove after releasing https://github.com/aeternity/aeternity/pull/4292 | ||
healthcheck: | ||
interval: 2s | ||
environment: | ||
AETERNITY_CONFIG: /home/aeternity/aeternity.yaml | ||
command: | | ||
bin/aeternity console -noinput -aehttp enable_debug_endpoints true | ||
AE__SYSTEM__CUSTOM_PREFUNDED_ACCS_FILE: "/home/aeternity/node/data/aecore/.genesis/accounts_test.json" | ||
volumes: | ||
- './docker/aeternity.yaml:/home/aeternity/aeternity.yaml' | ||
proxy: | ||
image: 'nginx:1.13.8' | ||
- "./docker/aeternity.yaml:/home/aeternity/aeternity.yaml" | ||
- "./docker/accounts.json:/home/aeternity/node/data/aecore/.genesis/accounts_test.json" | ||
|
||
aeproject_compiler: | ||
image: aeternity/aesophia_http:${COMPILER_TAG:-v8.0.0} | ||
hostname: compiler | ||
# TODO: remove after releasing https://github.com/aeternity/aesophia_http/pull/133 | ||
healthcheck: | ||
interval: 2s | ||
ports: | ||
- "3080:3080" | ||
|
||
aeproject_proxy: | ||
image: nginx:latest | ||
hostname: proxy | ||
ports: | ||
- '3001:3001' | ||
- "3001:3001" | ||
volumes: | ||
- './docker/nginx.conf:/etc/nginx/conf.d/default.conf' | ||
- "./docker/nginx.conf:/etc/nginx/conf.d/default.conf" | ||
depends_on: | ||
- aeproject_compiler | ||
- aeproject_node |
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,13 @@ | ||
{ | ||
"ak_fUq2NesPXcYZ1CcqBcGC3StpdnQw3iVxMA3YSeCNAwfN4myQk": 100000000000000000000000000000000, | ||
"ak_tWZrf8ehmY7CyB1JAoBmWJEeThwWnDpU4NadUdzxVSbzDgKjP": 100000000000000000000000000000000, | ||
"ak_FHZrEbRmanKUe9ECPXVNTLLpRP2SeQCLCT6Vnvs9JuVu78J7V": 100000000000000000000000000000000, | ||
"ak_RYkcTuYcyxQ6fWZsL2G3Kj3K5WCRUEXsi76bPUNkEsoHc52Wp": 100000000000000000000000000000000, | ||
"ak_2VvB4fFu7BQHaSuW5EkQ7GCaM5qiA5BsFUHjJ7dYpAaBoeFCZi": 100000000000000000000000000000000, | ||
"ak_286tvbfP6xe4GY9sEbuN2ftx1LpavQwFVcPor9H4GxBtq5fXws": 100000000000000000000000000000000, | ||
"ak_f9bmi44rdvUGKDsTLp3vMCMLMvvqsMQVWyc3XDAYECmCXEbzy": 100000000000000000000000000000000, | ||
"ak_23p6pT7bajYMJRbnJ5BsbFUuYGX2PBoZAiiYcsrRHZ1BUY2zSF": 100000000000000000000000000000000, | ||
"ak_gLYH5tAexTCvvQA6NpXksrkPJKCkLnB9MTDFTVCBuHNDJ3uZv": 100000000000000000000000000000000, | ||
"ak_zPoY7cSHy2wBKFsdWJGXM7LnSjVt6cn1TWBDdRBUMC7Tur2NQ": 100000000000000000000000000000000, | ||
"ak_RdoCvwe7kxPu2VBv2gQAc1V81sGyTTuxFv36AcvNQYZN7qgut": 0 | ||
} |
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 |
---|---|---|
@@ -1,34 +1,47 @@ | ||
peers: [] | ||
|
||
http: | ||
external: | ||
port: 3013 | ||
gas_limit: 60000000 | ||
internal: | ||
debug_endpoints: true | ||
port: 3113 | ||
listen_address: 0.0.0.0 | ||
endpoints: | ||
dry-run: true | ||
|
||
system: | ||
plugin_path: /home/aeternity/node/plugins | ||
plugins: | ||
- name: aeplugin_dev_mode | ||
config: # keeping the old config style at first to stay backwards compatible | ||
keyblock_interval: 0 | ||
microblock_interval: 0 | ||
auto_emit_microblocks: true | ||
|
||
dev_mode: | ||
keyblock_interval: 0 | ||
microblock_interval: 0 | ||
auto_emit_microblocks: true | ||
|
||
fork_management: | ||
network_id: ae_dev | ||
|
||
chain: | ||
persist: true | ||
consensus: | ||
"0": | ||
name: "on_demand" # keeping the old config style at first to stay backwards compatible | ||
type: "on_demand" | ||
|
||
mining: | ||
beneficiary: "ak_RdoCvwe7kxPu2VBv2gQAc1V81sGyTTuxFv36AcvNQYZN7qgut" | ||
beneficiary_reward_delay: 2 | ||
strictly_follow_top: true | ||
|
||
websocket: | ||
channel: | ||
listen_address: 0.0.0.0 | ||
port: 3014 | ||
listen_address: 0.0.0.0 | ||
|
||
mining: | ||
autostart: true | ||
beneficiary: "ak_2mwRmUeYmfuW93ti9HMSUJzCk1EYcQEfikVSzgo6k2VghsWhgU" | ||
beneficiary_reward_delay: 2 | ||
expected_mine_rate: 4000 | ||
micro_block_cycle: 1000 | ||
cuckoo: | ||
miner: | ||
executable: mean15-generic | ||
extra_args: "" | ||
edge_bits: 15 | ||
|
||
fork_management: | ||
network_id: ae_devnet | ||
logging: | ||
# Controls the overload protection in the logs. | ||
hwm: 50 | ||
level: debug |
Oops, something went wrong.