Skip to content

Commit f7b061a

Browse files
authored
feat(Lima): Add support for lima (#105)
* feat(Lima): Add support for lima * fix(Test): FIx tests for lima. Update sdk to 5.0.0. Regenerate lock file * feat(Lima): Fix AENS inspect command and tests. Point to node 5.0.0-rc3 and compiler 4.0.0-rc5. Change default vm/abi version for contract * feat(AENS): Make claim transaction works with Lima * feat(Contract): Fix contract transactions commands and test
1 parent d0c85c1 commit f7b061a

File tree

14 files changed

+1156
-2285
lines changed

14 files changed

+1156
-2285
lines changed

.env

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
TAG=v5.0.0-rc.1
2-
COMPILER_TAG=v3.2.0
3-
1+
TAG=v5.0.0-rc.3
2+
COMPILER_TAG=v4.0.0-rc5

bin/aecli-contract.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ program
4141
// Example: `aecli contract compile ./mycontract.contract`
4242
program
4343
.command('compile <file>')
44+
.option('--backend [backend]', 'Print result in json format', utils.constant.COMPILER_BACKEND)
4445
.description('Compile a contract')
4546
.action(async (file, ...arguments) => await Contract.compile(file, utils.cli.getCmdFromArguments(arguments)))
4647

@@ -52,6 +53,7 @@ program
5253
// Example: `aecli contract encodeData ./mycontract.contract testFn 1 2`
5354
program
5455
.command('encodeData <source> <fn> [args...]')
56+
.option('--backend [backend]', 'Print result in json format', utils.constant.COMPILER_BACKEND)
5557
.description('Encode contract call data')
5658
.action(async (source, fn, args, ...arguments) => await Contract.encodeData(source, fn, args, utils.cli.getCmdFromArguments(arguments)))
5759

@@ -63,6 +65,7 @@ program
6365
// Example: `aecli contract decodeData cb_asdasdasdasdasdas int`
6466
program
6567
.command('decodeData <data> <returnType>')
68+
.option('--backend [backend]', 'Print result in json format', utils.constant.COMPILER_BACKEND)
6669
.description('Decode contract data')
6770
.action(async (data, returnType, ...arguments) => await Contract.decodeData(data, returnType, utils.cli.getCmdFromArguments(arguments)))
6871

@@ -78,6 +81,7 @@ program
7881
.option('--sourcePath [sourcePath]', 'Path to contract source')
7982
.option('--code [code]', 'Compiler contract code')
8083
.option('--fn [fn]', 'Function name')
84+
.option('--backend [backend]', 'Print result in json format', utils.constant.COMPILER_BACKEND)
8185
.description('Decode contract call data')
8286
.action(async (data, ...arguments) => await Contract.decodeCallData(data, utils.cli.getCmdFromArguments(arguments)))
8387

bin/aecli-tx.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ program
8181
.command('name-claim <accountId> <salt> <domain> <nonce>')
8282
.option('-T, --ttl [ttl]', 'Validity of the transaction in number of blocks (default forever)', utils.constant.TX_TTL)
8383
.option('-F, --fee [fee]', 'Transaction fee.')
84+
.option('--nameFee [nameFee]', 'Name fee.', utils.constant.NAME_FEE)
8485
.description('Build name claim transaction.')
8586
.action(async (accountId, salt, domain, nonce, ...arguments) => await Transaction.nameClaim(accountId, salt, domain, nonce, utils.cli.getCmdFromArguments(arguments)))
8687

@@ -122,6 +123,7 @@ program
122123
.option('--deposit [deposit]', 'Deposit', 0)
123124
.option('-G --gas [gas]', 'Amount of gas to deploy the contract', utils.constant.GAS)
124125
.option('--vmVersion [vmVersion]', 'VM version', utils.constant.VM_VERSION)
126+
.option('--abiVersion [abiVersion]', 'ABI version', utils.constant.DEFAULT_CONTRACT_PARAMS.abiVersion)
125127
.description('Build contract create transaction.')
126128
.action(async (ownerId, contractBytecode, initCallData, nonce, ...arguments) => await Transaction.contractDeploy(ownerId, contractBytecode, initCallData, nonce, utils.cli.getCmdFromArguments(arguments)))
127129

@@ -135,6 +137,8 @@ program
135137
.option('-T, --ttl [ttl]', 'Validity of the transaction in number of blocks (default forever)', utils.constant.TX_TTL)
136138
.option('-F, --fee [fee]', 'Transaction fee.')
137139
.option('-G --gas [gas]', 'Amount of gas to deploy the contract', utils.constant.GAS)
140+
.option('--abiVersion [abiVersion]', 'VM version', utils.constant.DEFAULT_CONTRACT_PARAMS.abiVersion)
141+
.option('--vmVersion [vmVersion]', 'ABI version', utils.constant.VM_VERSION)
138142
.description('Build contract create transaction.')
139143
.action(async (callerId, contractId, callData, nonce, ...arguments) => await Transaction.contractCall(callerId, contractId, callData, nonce, utils.cli.getCmdFromArguments(arguments)))
140144

bin/commands/contract.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { GAS_PRICE } from '../utils/constant'
3030

3131
// ## Function which compile your `source` code
3232
export async function compile (file, options) {
33+
const { backend } = options
3334
try {
3435
const code = readFile(path.resolve(process.cwd(), file), 'utf-8')
3536
if (!code) throw new Error('Contract file not found')
@@ -38,7 +39,7 @@ export async function compile (file, options) {
3839

3940
await handleApiError(async () => {
4041
// Call `node` API which return `compiled code`
41-
const contract = await client.compileContractAPI(code)
42+
const contract = await client.compileContractAPI(code, { backend })
4243
print(`Contract bytecode:
4344
${contract}`)
4445
})
@@ -49,6 +50,7 @@ export async function compile (file, options) {
4950

5051
// ## Function which compile your `source` code
5152
export async function encodeData (source, fn, args = [], options) {
53+
const { backend } = options
5254
try {
5355
const sourceCode = readFile(path.resolve(process.cwd(), source), 'utf-8')
5456
if (!sourceCode) throw new Error('Contract file not found')
@@ -57,7 +59,7 @@ export async function encodeData (source, fn, args = [], options) {
5759

5860
await handleApiError(async () => {
5961
// Call `node` API which return `compiled code`
60-
const callData = await client.contractEncodeCallDataAPI(sourceCode, fn, args, options)
62+
const callData = await client.contractEncodeCallDataAPI(sourceCode, fn, args, { backend })
6163
if (options.json) {
6264
print(JSON.stringify({ callData }))
6365
} else {
@@ -91,7 +93,7 @@ export async function decodeData (data, type, options) {
9193

9294
// ## Function which compile your `source` code
9395
export async function decodeCallData (data, options) {
94-
const { sourcePath, code, fn } = options
96+
const { sourcePath, code, fn, backend } = options
9597
let sourceCode
9698

9799
if (!sourcePath && !code) throw new Error('Contract source(--sourcePath) or contract code(--code) required!')
@@ -109,8 +111,8 @@ export async function decodeCallData (data, options) {
109111
await handleApiError(async () => {
110112
// Call `node` API which return `compiled code`
111113
const decoded = code
112-
? await client.contractDecodeCallDataByCodeAPI(code, data)
113-
: await client.contractDecodeCallDataBySourceAPI(sourceCode, fn, data)
114+
? await client.contractDecodeCallDataByCodeAPI(code, data, backend)
115+
: await client.contractDecodeCallDataBySourceAPI(sourceCode, fn, data, { backend })
114116

115117
if (options.json) {
116118
print(JSON.stringify({ decoded }))

bin/commands/transaction.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ async function namePreClaim (accountId, domain, nonce, options) {
9797

9898
// ## Build `nameClaim` transaction
9999
async function nameClaim (accountId, nameSalt, domain, nonce, options) {
100-
let { ttl, json, fee } = options
100+
const vsn = 2
101+
let { ttl, json, fee, nameFee } = options
101102
const nameHash = `nm_${encodeBase58Check(Buffer.from(domain))}`
102103

103104
try {
@@ -106,15 +107,16 @@ async function nameClaim (accountId, nameSalt, domain, nonce, options) {
106107
// Initialize `Ae`
107108
const txBuilder = initOfflineTxBuilder()
108109
const params = {
110+
nameFee,
109111
accountId,
110112
nameSalt,
111113
name: nameHash,
112114
ttl,
113115
nonce
114116
}
115-
fee = txBuilder.calculateFee(fee, TX_TYPE.nameClaim, { params })
117+
fee = txBuilder.calculateFee(fee, TX_TYPE.nameClaim, { params, vsn })
116118
// Build `claim` transaction's
117-
const { tx, txObject } = txBuilder.buildTx({ ...params, fee }, TX_TYPE.nameClaim)
119+
const { tx, txObject } = txBuilder.buildTx({ ...params, fee }, TX_TYPE.nameClaim, { vsn })
118120

119121
if (json) {
120122
print({ tx, txObject })
@@ -276,7 +278,7 @@ async function contractDeploy (ownerId, contractByteCode, initCallData, nonce, o
276278

277279
// ## Build `contractCall` transaction
278280
async function contractCall (callerId, contractId, callData, nonce, options) {
279-
let { ttl, json, fee, gas } = options
281+
const { ttl, json, fee, gas } = options
280282
nonce = parseInt(nonce)
281283
try {
282284
// Build `call` transaction's

bin/utils/constant.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,16 @@ export const PLAY_INTERVAL = 1000
4444
// ## CONTRACT
4545
export const GAS = 1600000 - 21000 // MAX GAS
4646
export const DEPOSIT = 0
47-
export const VM_VERSION = 4
47+
export const VM_VERSION = 5
48+
export const ABI_VERSION = 3
49+
export const COMPILER_BACKEND = 'fate'
4850
export const ORACLE_VM_VERSION = 0
4951
export const GAS_PRICE = 1000000000
5052
export const AMOUNT = 0
5153

5254
// ## AENS
5355
export const NAME_TTL = 50000
56+
export const NAME_FEE = '1000000000000000000000'
5457
export const CLIENT_TTL = 1
5558

5659
// ## ACCOUNT
@@ -64,4 +67,4 @@ export const QUERY_TTL = 10
6467
export const RESPONSE_TTL = 10
6568

6669
// ## Default transaction build param's
67-
export const DEFAULT_CONTRACT_PARAMS = { vmVersion: VM_VERSION, amount: AMOUNT, deposit: DEPOSIT, gasPrice: GAS_PRICE, abiVersion: 1 }
70+
export const DEFAULT_CONTRACT_PARAMS = { vmVersion: VM_VERSION, amount: AMOUNT, deposit: DEPOSIT, gasPrice: GAS_PRICE, abiVersion: ABI_VERSION }

bin/utils/helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ export function isAvailable (name) { return name.status === 'AVAILABLE' }
169169

170170
// Validate `name`
171171
export function validateName (name) {
172-
if (R.last(name.split('.')) !== 'test') { throw new Error('AENS TLDs must end in .test') }
172+
if (!['test', 'aet'].includes(R.last(name.split('.')))) { throw new Error('AENS TLDs must end in .test') }
173173
}
174174

175175
// Grab contract descriptor by path

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ services:
2020
expose: [3013, 3113, 3014, 3114]
2121
environment:
2222
EPOCH_CONFIG: /home/aeternity/aeternity_node.yaml
23-
command: -aecore expected_mine_rate ${EPOCH_MINE_RATE:-5000}
23+
command: bin/aeternity console -noinput -aecore expected_mine_rate ${EPOCH_MINE_RATE:-5000}
2424
volumes:
2525
- ${PWD}/docker/aeternity_node_mean16.yaml:/home/aeternity/aeternity_node.yaml
2626
- ${PWD}/docker/keys/node:/home/aeternity/node/keys

docker/aeternity_node_mean16.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ chain:
2424
"1": 0
2525
"2": 2
2626
"3": 4
27+
"4": 5
2728

2829
mining:
2930
autostart: true

0 commit comments

Comments
 (0)