From a7f1d71b468852251f970c53047e9ffe7f72926f Mon Sep 17 00:00:00 2001 From: Denis Davidyuk Date: Fri, 23 Jun 2023 13:03:32 +0600 Subject: [PATCH 1/5] refactor(compiler): remove extra error transformation --- src/contract/compiler/Http.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/contract/compiler/Http.ts b/src/contract/compiler/Http.ts index a8164975c2..d2aa120a26 100644 --- a/src/contract/compiler/Http.ts +++ b/src/contract/compiler/Http.ts @@ -70,7 +70,7 @@ export default class CompilerHttp extends CompilerBase { return res as { bytecode: Encoded.ContractBytearray; aci: Aci }; } catch (error) { if (error instanceof RestError && error.statusCode === 400) { - throw new CompilerError(error.message.replace(/^aci error:/, 'compile error:')); + throw new CompilerError(error.message); } throw error; } From a12b5df95e12c49431ce1224ea71b9069115ef98 Mon Sep 17 00:00:00 2001 From: Denis Davidyuk Date: Fri, 23 Jun 2023 13:05:07 +0600 Subject: [PATCH 2/5] test(compiler): compare with exact aci --- test/integration/compiler.ts | 7 +++--- test/integration/contract-aci.ts | 20 +++------------ test/integration/contracts/Includes.json | 31 ++++++++++++++++++++++++ tsconfig.tests.json | 1 + 4 files changed, 38 insertions(+), 21 deletions(-) create mode 100644 test/integration/contracts/Includes.json diff --git a/test/integration/compiler.ts b/test/integration/compiler.ts index 218670e9bd..f809064618 100644 --- a/test/integration/compiler.ts +++ b/test/integration/compiler.ts @@ -2,6 +2,7 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; import { readFile } from 'fs/promises'; import { compilerUrl, ignoreVersion } from '.'; +import inclAci from './contracts/Includes.json'; import { CompilerBase, CompilerHttpNode, CompilerCli, CompilerError, getFileSystem, Encoded, } from '../../src'; @@ -30,15 +31,13 @@ function testCompiler(compiler: CompilerBase): void { it('compiles and generates aci by path', async () => { const { bytecode, aci } = await compiler.compile(inclSourceCodePath); expect(bytecode).to.equal(inclBytecode); - expect(aci).to.have.length(6); - expect(aci[aci.length - 1]).to.have.property('contract'); + expect(aci).to.eql(inclAci); }); it('compiles and generates aci by source code', async () => { const { bytecode, aci } = await compiler.compileBySourceCode(inclSourceCode, inclFileSystem); expect(bytecode).to.equal(inclBytecode); - expect(aci).to.have.length(6); - expect(aci[aci.length - 1]).to.have.property('contract'); + expect(aci).to.eql(inclAci); }); it('throws clear exception if compile broken contract', async () => { diff --git a/test/integration/contract-aci.ts b/test/integration/contract-aci.ts index d71526037e..3a90103ade 100644 --- a/test/integration/contract-aci.ts +++ b/test/integration/contract-aci.ts @@ -23,6 +23,7 @@ import { } from '../utils'; import { Aci } from '../../src/contract/compiler/Base'; import { ContractCallObject } from '../../src/contract/Contract'; +import includesAci from './contracts/Includes.json'; const identityContractSourceCode = ` contract Identity = @@ -207,23 +208,8 @@ describe('Contract instance', () => { it('compiles contract by sourceCodePath', async () => { const ctr = await aeSdk.initializeContract({ - aci: [{ - contract: { - functions: [{ - arguments: [{ name: 'x', type: 'int' }], - name: 'increment', - payable: false, - returns: 'int', - stateful: false, - }, - ], - kind: 'contract_main', - name: 'Increment', - payable: false, - typedefs: [], - }, - }], - sourceCodePath: './test/integration/contracts/Increment.aes', + aci: includesAci, + sourceCodePath: './test/integration/contracts/Includes.aes', }); expect(ctr.$options.bytecode).to.equal(undefined); expect(await ctr.$compile()).to.satisfy((b: string) => b.startsWith('cb_')); diff --git a/test/integration/contracts/Includes.json b/test/integration/contracts/Includes.json new file mode 100644 index 0000000000..564b1c35e0 --- /dev/null +++ b/test/integration/contracts/Includes.json @@ -0,0 +1,31 @@ +[{ + "namespace": { "name": "ListInternal", "typedefs": [] } +}, { + "namespace": { "name": "List", "typedefs": [] } +}, { + "namespace": { "name": "String", "typedefs": [] } +}, { + "namespace": { "name": "Sublibrary", "typedefs": [] } +}, { + "namespace": { "name": "Library", "typedefs": [] } +}, { + "contract": { + "functions": [{ + "arguments": [{ "name": "x", "type": "int" }], + "name": "test", + "payable": false, + "returns": "int", + "stateful": false + }, { + "arguments": [{ "name": "x", "type": "string" }], + "name": "getLength", + "payable": false, + "returns": "int", + "stateful": false + }], + "kind": "contract_main", + "name": "Includes", + "payable": false, + "typedefs": [] + } +}] diff --git a/tsconfig.tests.json b/tsconfig.tests.json index 46a28a8afa..237876c2d3 100644 --- a/tsconfig.tests.json +++ b/tsconfig.tests.json @@ -2,6 +2,7 @@ "extends": "./tsconfig.json", "compilerOptions": { "emitDeclarationOnly": false, + "resolveJsonModule": true, "noEmit": true }, "include": [ From 329c7e6e218357971f3d6dc9a05f6d3e42ccd4ba Mon Sep 17 00:00:00 2001 From: Denis Davidyuk Date: Fri, 23 Jun 2023 13:22:35 +0600 Subject: [PATCH 3/5] chore(compiler): update cli to 7.2.1 --- test/integration/compiler.ts | 20 +++++++------------- test/integration/contracts/Increment.aes | 2 -- tooling/fetch-aesophia-cli.mjs | 4 ++-- 3 files changed, 9 insertions(+), 17 deletions(-) delete mode 100644 test/integration/contracts/Increment.aes diff --git a/test/integration/compiler.ts b/test/integration/compiler.ts index f809064618..782302682d 100644 --- a/test/integration/compiler.ts +++ b/test/integration/compiler.ts @@ -12,16 +12,11 @@ function testCompiler(compiler: CompilerBase): void { let inclSourceCode: string; let inclFileSystem: Record; const inclBytecode = 'cb_+QEGRgOg7BH1sCv+p2IrS0Pn3/i6AfE8lOGUuC71lLPn6mbUm9PAuNm4cv4AWolkAjcCBwcHFBQAAgD+RNZEHwA3ADcAGg6CPwEDP/5Nt4A5AjcCBwcHDAECDAEABAMRAFqJZP6SiyA2ADcBBwcMAwgMAQAEAxFNt4A5/pSgnxIANwF3BwwBAAQDEarAwob+qsDChgI3AXcHPgQAALhgLwYRAFqJZD0uU3VibGlicmFyeS5zdW0RRNZEHxFpbml0EU23gDkxLkxpYnJhcnkuc3VtEZKLIDYRdGVzdBGUoJ8SJWdldExlbmd0aBGqwMKGOS5TdHJpbmcubGVuZ3Rogi8AhTcuMS4wAGHgFTw='; - // TODO: use Includes.aes after fixing https://github.com/aeternity/aesophia_cli/issues/74 - const incSourceCodePath = './test/integration/contracts/Increment.aes'; - let incSourceCode: string; - const incBytecode = 'cb_+G1GA6Cln3BxyOo1iNITGseMS58ZfBbRNB0x8Ix7Bh54qZlSOcC4QKD+Er1R0wA3AQcHFDQAAgD+RNZEHwA3ADcAGg6CPwEDP5svAhESvVHTJWluY3JlbWVudBFE1kQfEWluaXSCLwCFNy4wLjEAfImpuQ=='; const testBytecode = 'cb_+GhGA6BgYgXqYB9ctBcQ8mJ0+we5OXhb9PpsSQWP2DhPx9obn8C4O57+RNZEHwA3ADcAGg6CPwEDP/6AeCCSADcBd3cBAQCYLwIRRNZEHxFpbml0EYB4IJIZZ2V0QXJngi8AhTcuMC4xAMXqWXc='; before(async () => { inclSourceCode = await readFile(inclSourceCodePath, 'utf8'); inclFileSystem = await getFileSystem(inclSourceCodePath); - incSourceCode = await readFile(incSourceCodePath, 'utf8'); }); it('returns version', async () => { @@ -60,20 +55,19 @@ function testCompiler(compiler: CompilerBase): void { }); it('validates bytecode by path', async () => { - expect(await compiler.validate(incBytecode, incSourceCodePath)) - .to.be.equal(true); - expect(await compiler.validate(testBytecode, incSourceCodePath)).to.be.equal(false); + expect(await compiler.validate(inclBytecode, inclSourceCodePath)).to.be.equal(true); + expect(await compiler.validate(testBytecode, inclSourceCodePath)).to.be.equal(false); const invalidBytecode = `${testBytecode}test` as Encoded.ContractBytearray; - expect(await compiler.validate(invalidBytecode, incSourceCodePath)) - .to.be.equal(false); + expect(await compiler.validate(invalidBytecode, inclSourceCodePath)).to.be.equal(false); }); it('validates bytecode by source code', async () => { - expect(await compiler.validateBySourceCode(incBytecode, incSourceCode)) + expect(await compiler.validateBySourceCode(inclBytecode, inclSourceCode, inclFileSystem)) .to.be.equal(true); - expect(await compiler.validateBySourceCode(testBytecode, incSourceCode)).to.be.equal(false); + expect(await compiler.validateBySourceCode(testBytecode, inclSourceCode, inclFileSystem)) + .to.be.equal(false); const invalidBytecode = `${testBytecode}test` as Encoded.ContractBytearray; - expect(await compiler.validateBySourceCode(invalidBytecode, incSourceCode)) + expect(await compiler.validateBySourceCode(invalidBytecode, inclSourceCode, inclFileSystem)) .to.be.equal(false); }); } diff --git a/test/integration/contracts/Increment.aes b/test/integration/contracts/Increment.aes deleted file mode 100644 index e1e2e1fe7a..0000000000 --- a/test/integration/contracts/Increment.aes +++ /dev/null @@ -1,2 +0,0 @@ -contract Increment = - entrypoint increment(x: int): int = x + 1 diff --git a/tooling/fetch-aesophia-cli.mjs b/tooling/fetch-aesophia-cli.mjs index b525fa1d29..fa5c39f975 100644 --- a/tooling/fetch-aesophia-cli.mjs +++ b/tooling/fetch-aesophia-cli.mjs @@ -3,7 +3,7 @@ import { dirname } from 'path'; import { writeFileSync, readFileSync, mkdirSync } from 'fs'; const path = './bin/aesophia_cli'; -const hash = 'BqnxuwwjV5q+4nmnkB7Ksa6lR2wwFaCVT2Mq3Y5xJ6rgp5GiwQL3At0Sqi2Z573PXYw0JTXNsglA7R1SyuahVQ=='; +const hash = 'KSUb0KzzM3zhM2cbHeQRqnBvRR7CHvC5Lb9VFw3RPfmC5FOYuxHvRYYsMWwFbrYg76L9fPv5IypKEZbdGohXgA=='; function ensureBinaryCorrect() { const buffer = readFileSync(path); @@ -16,7 +16,7 @@ try { } catch { console.log('Fetching aesophia_cli'); const request = await fetch( - 'https://github.com/aeternity/aesophia_cli/releases/download/v7.1.0/aesophia_cli', + 'https://github.com/aeternity/aesophia_cli/releases/download/v7.2.1/aesophia_cli', ); const body = Buffer.from(await request.arrayBuffer()); mkdirSync(dirname(path), { recursive: true }); From 981bcf252432a3b96aca92ccd682214c124009e2 Mon Sep 17 00:00:00 2001 From: Denis Davidyuk Date: Fri, 23 Jun 2023 13:38:25 +0600 Subject: [PATCH 4/5] feat(compiler): add `generateAci`, `generateAciBySourceCode` --- docker-compose.yml | 2 +- src/contract/compiler/Base.ts | 26 +++++++++ src/contract/compiler/Cli.ts | 26 ++++++++- src/contract/compiler/Http.ts | 21 ++++++- src/contract/compiler/HttpNode.ts | 6 ++ test/integration/compiler.ts | 55 ++++++++++++++++++- test/integration/contracts/Interface.aes | 5 ++ .../contracts/lib/DecrementInterface.aes | 2 + test/integration/transaction.ts | 2 +- tooling/autorest/compiler-prepare.mjs | 2 +- 10 files changed, 139 insertions(+), 8 deletions(-) create mode 100644 test/integration/contracts/Interface.aes create mode 100644 test/integration/contracts/lib/DecrementInterface.aes diff --git a/docker-compose.yml b/docker-compose.yml index a0a96881cb..3bbbc2739f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,6 +9,6 @@ services: - ./docker/accounts_test.json:/home/aeternity/node/data/aecore/.genesis/accounts_test.json compiler: - image: aeternity/aesophia_http:v7.2.0 + image: aeternity/aesophia_http:v7.4.0 hostname: compiler ports: ["3080:3080"] diff --git a/src/contract/compiler/Base.ts b/src/contract/compiler/Base.ts index 4612301370..a06e4c733a 100644 --- a/src/contract/compiler/Base.ts +++ b/src/contract/compiler/Base.ts @@ -55,6 +55,32 @@ export default abstract class CompilerBase { aci: Aci; }>; + /** + * Generate contract's ACI by contract's path + * Available only in Node.js + * @param path - Path to contract source code + * @returns ACI + */ + abstract generateAci(path: string): Promise; + + /** + * Generate contract's ACI by contract's source code + * @param sourceCode - Contract source code as string + * @param fileSystem - A map of contract filename to the corresponding contract source code to + * include into the main contract + * @example + * ```js + * { + * 'library.aes': 'namespace TestLib =\n function sum(x: int, y: int) : int = x + y' + * } + * ``` + * @returns ACI + */ + abstract generateAciBySourceCode( + sourceCode: string, + fileSystem?: Record, + ): Promise; + /** * Verify that a contract bytecode is the result of compiling the given source code * Available only in Node.js diff --git a/src/contract/compiler/Cli.ts b/src/contract/compiler/Cli.ts index ccfea2bfc7..47ee9babc1 100644 --- a/src/contract/compiler/Cli.ts +++ b/src/contract/compiler/Cli.ts @@ -33,7 +33,7 @@ export default class CompilerCli extends CompilerBase { this.#path = compilerPath; if (ignoreVersion !== true) { this.#ensureCompatibleVersion = this.version().then((version) => { - const versions = [version, '7.0.1', '8.0.0'] as const; + const versions = [version, '7.2.1', '8.0.0'] as const; if (!semverSatisfies(...versions)) throw new UnsupportedVersionError('compiler', ...versions); }); } @@ -79,7 +79,7 @@ export default class CompilerCli extends CompilerBase { ]); return { bytecode: bytecode.trimEnd() as Encoded.ContractBytearray, - aci: aci as Aci, + aci, }; } catch (error) { ensureError(error); @@ -99,6 +99,28 @@ export default class CompilerCli extends CompilerBase { } } + async generateAci(path: string): Promise { + await this.#ensureCompatibleVersion; + try { + return JSON.parse(await this.#run('--no_code', '--create_json_aci', path)); + } catch (error) { + ensureError(error); + throw new CompilerError(error.message); + } + } + + async generateAciBySourceCode( + sourceCode: string, + fileSystem?: Record, + ): Promise { + const tmp = await CompilerCli.#saveContractToTmpDir(sourceCode, fileSystem); + try { + return await this.generateAci(tmp); + } finally { + await rm(dirname(tmp), { recursive: true }); + } + } + async validate(bytecode: Encoded.ContractBytearray, path: string): Promise { await this.#ensureCompatibleVersion; try { diff --git a/src/contract/compiler/Http.ts b/src/contract/compiler/Http.ts index d2aa120a26..176a633226 100644 --- a/src/contract/compiler/Http.ts +++ b/src/contract/compiler/Http.ts @@ -55,7 +55,7 @@ export default class CompilerHttp extends CompilerBase { const versionPromise = this.api.apiVersion() .then(({ apiVersion }) => apiVersion, (error) => error); this.api.pipeline.addPolicy( - genVersionCheckPolicy('compiler', '/api-version', versionPromise, '7.1.1', '8.0.0'), + genVersionCheckPolicy('compiler', '/api-version', versionPromise, '7.3.0', '8.0.0'), ); } } @@ -81,6 +81,25 @@ export default class CompilerHttp extends CompilerBase { throw new NotImplementedError('File system access, use CompilerHttpNode instead'); } + async generateAciBySourceCode( + sourceCode: string, + fileSystem?: Record, + ): Promise { + try { + return await this.api.generateACI({ code: sourceCode, options: { fileSystem } }); + } catch (error) { + if (error instanceof RestError && error.statusCode === 400) { + throw new CompilerError(error.message); + } + throw error; + } + } + + // eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars + async generateAci(path: string): Promise { + throw new NotImplementedError('File system access, use CompilerHttpNode instead'); + } + async validateBySourceCode( bytecode: Encoded.ContractBytearray, sourceCode: string, diff --git a/src/contract/compiler/HttpNode.ts b/src/contract/compiler/HttpNode.ts index aba048dff0..c4d4541c8f 100644 --- a/src/contract/compiler/HttpNode.ts +++ b/src/contract/compiler/HttpNode.ts @@ -18,6 +18,12 @@ export default class CompilerHttpNode extends HttpBrowser { return this.compileBySourceCode(sourceCode, fileSystem); } + override async generateAci(path: string): Promise { + const fileSystem = await getFileSystem(path); + const sourceCode = await readFile(path, 'utf8'); + return this.generateAciBySourceCode(sourceCode, fileSystem); + } + override async validate(bytecode: Encoded.ContractBytearray, path: string): Promise { const fileSystem = await getFileSystem(path); const sourceCode = await readFile(path, 'utf8'); diff --git a/test/integration/compiler.ts b/test/integration/compiler.ts index 782302682d..1b1e5c36d5 100644 --- a/test/integration/compiler.ts +++ b/test/integration/compiler.ts @@ -11,16 +11,57 @@ function testCompiler(compiler: CompilerBase): void { const inclSourceCodePath = './test/integration/contracts/Includes.aes'; let inclSourceCode: string; let inclFileSystem: Record; - const inclBytecode = 'cb_+QEGRgOg7BH1sCv+p2IrS0Pn3/i6AfE8lOGUuC71lLPn6mbUm9PAuNm4cv4AWolkAjcCBwcHFBQAAgD+RNZEHwA3ADcAGg6CPwEDP/5Nt4A5AjcCBwcHDAECDAEABAMRAFqJZP6SiyA2ADcBBwcMAwgMAQAEAxFNt4A5/pSgnxIANwF3BwwBAAQDEarAwob+qsDChgI3AXcHPgQAALhgLwYRAFqJZD0uU3VibGlicmFyeS5zdW0RRNZEHxFpbml0EU23gDkxLkxpYnJhcnkuc3VtEZKLIDYRdGVzdBGUoJ8SJWdldExlbmd0aBGqwMKGOS5TdHJpbmcubGVuZ3Rogi8AhTcuMS4wAGHgFTw='; + const inclBytecode = 'cb_+QEGRgOg7BH1sCv+p2IrS0Pn3/i6AfE8lOGUuC71lLPn6mbUm9PAuNm4cv4AWolkAjcCBwcHFBQAAgD+RNZEHwA3ADcAGg6CPwEDP/5Nt4A5AjcCBwcHDAECDAEABAMRAFqJZP6SiyA2ADcBBwcMAwgMAQAEAxFNt4A5/pSgnxIANwF3BwwBAAQDEarAwob+qsDChgI3AXcHPgQAALhgLwYRAFqJZD0uU3VibGlicmFyeS5zdW0RRNZEHxFpbml0EU23gDkxLkxpYnJhcnkuc3VtEZKLIDYRdGVzdBGUoJ8SJWdldExlbmd0aBGqwMKGOS5TdHJpbmcubGVuZ3Rogi8AhTcuMi4xAFw7b7s='; const testBytecode = 'cb_+GhGA6BgYgXqYB9ctBcQ8mJ0+we5OXhb9PpsSQWP2DhPx9obn8C4O57+RNZEHwA3ADcAGg6CPwEDP/6AeCCSADcBd3cBAQCYLwIRRNZEHxFpbml0EYB4IJIZZ2V0QXJngi8AhTcuMC4xAMXqWXc='; + const interfaceSourceCodePath = './test/integration/contracts/Interface.aes'; + let interfaceSourceCode: string; + let interfaceFileSystem: Record; + const interfaceAci = [ + { namespace: { name: 'ListInternal', typedefs: [] } }, + { namespace: { name: 'List', typedefs: [] } }, + { namespace: { name: 'String', typedefs: [] } }, + { + contract: { + functions: [{ + arguments: [{ name: '_1', type: 'int' }], + name: 'decrement', + payable: false, + returns: 'int', + stateful: false, + }], + kind: 'contract_child', + name: 'Decrement', + payable: false, + typedefs: [], + }, + }, + { + contract: { + functions: [{ + arguments: [{ name: '_1', type: 'int' }], + name: 'increment', + payable: false, + returns: 'int', + stateful: false, + }], + kind: 'contract_main', + name: 'Increment', + payable: false, + typedefs: [], + }, + }, + ]; + before(async () => { inclSourceCode = await readFile(inclSourceCodePath, 'utf8'); inclFileSystem = await getFileSystem(inclSourceCodePath); + interfaceSourceCode = await readFile(interfaceSourceCodePath, 'utf8'); + interfaceFileSystem = await getFileSystem(interfaceSourceCodePath); }); it('returns version', async () => { - expect(await compiler.version()).to.be.equal('7.1.0'); + expect(await compiler.version()).to.be.equal('7.2.1'); }); it('compiles and generates aci by path', async () => { @@ -54,6 +95,16 @@ function testCompiler(compiler: CompilerBase): void { ); }); + it('generates aci by path', async () => { + const aci = await compiler.generateAci(interfaceSourceCodePath); + expect(aci).to.eql(interfaceAci); + }); + + it('generates aci by source code', async () => { + const aci = await compiler.generateAciBySourceCode(interfaceSourceCode, interfaceFileSystem); + expect(aci).to.eql(interfaceAci); + }); + it('validates bytecode by path', async () => { expect(await compiler.validate(inclBytecode, inclSourceCodePath)).to.be.equal(true); expect(await compiler.validate(testBytecode, inclSourceCodePath)).to.be.equal(false); diff --git a/test/integration/contracts/Interface.aes b/test/integration/contracts/Interface.aes new file mode 100644 index 0000000000..8aafcb57c0 --- /dev/null +++ b/test/integration/contracts/Interface.aes @@ -0,0 +1,5 @@ +include "String.aes" +include "./lib/DecrementInterface.aes" + +main contract Increment = + entrypoint increment: (int) => int diff --git a/test/integration/contracts/lib/DecrementInterface.aes b/test/integration/contracts/lib/DecrementInterface.aes new file mode 100644 index 0000000000..f7b6ca7144 --- /dev/null +++ b/test/integration/contracts/lib/DecrementInterface.aes @@ -0,0 +1,2 @@ +contract Decrement = + entrypoint decrement: (int) => int diff --git a/test/integration/transaction.ts b/test/integration/transaction.ts index 09cce68c7a..cd6ea8210e 100644 --- a/test/integration/transaction.ts +++ b/test/integration/transaction.ts @@ -107,7 +107,7 @@ describe('Transaction', () => { }), ], [ 'contract create', - 'tx_+LAqAaEBhAyXS5cWR3ZFS6EZ2E7cTWBYqN7JK27cV4qy0wtMQgABuGr4aEYDoKEijZbj/w2AeiWwAbldusME5pm3ZgPuomnZ3TbUbYgrwLg7nv5E1kQfADcANwAaDoI/AQM//oB4IJIANwEHBwEBAJgvAhFE1kQfEWluaXQRgHggkhlnZXRBcmeCLwCFNy4xLjAAgwcAA4ZHcyzkwAAAAACDTEtAhDuaygCHKxFE1kQfP0tdwp4=', + 'tx_+LAqAaEBhAyXS5cWR3ZFS6EZ2E7cTWBYqN7JK27cV4qy0wtMQgABuGr4aEYDoKEijZbj/w2AeiWwAbldusME5pm3ZgPuomnZ3TbUbYgrwLg7nv5E1kQfADcANwAaDoI/AQM//oB4IJIANwEHBwEBAJgvAhFE1kQfEWluaXQRgHggkhlnZXRBcmeCLwCFNy4yLjEAgwcAA4ZHcyzkwAAAAACDTEtAhDuaygCHKxFE1kQfP7cARy4=', async () => aeSdk.buildTx({ tag: Tag.ContractCreateTx, nonce, diff --git a/tooling/autorest/compiler-prepare.mjs b/tooling/autorest/compiler-prepare.mjs index 0e909e3f5b..6d8f58755e 100644 --- a/tooling/autorest/compiler-prepare.mjs +++ b/tooling/autorest/compiler-prepare.mjs @@ -1,6 +1,6 @@ import fs from 'fs'; -const swaggerUrl = 'https://raw.githubusercontent.com/aeternity/aesophia_http/v7.1.1/config/swagger.yaml'; +const swaggerUrl = 'https://raw.githubusercontent.com/aeternity/aesophia_http/v7.4.0/config/swagger.yaml'; const response = await fetch(swaggerUrl); console.assert(response.status === 200, 'Invalid response code', response.status); From 22cc31bbcababbb5155872b63f28a2be8ee1303e Mon Sep 17 00:00:00 2001 From: Denis Davidyuk Date: Fri, 7 Jul 2023 20:11:43 +0600 Subject: [PATCH 5/5] chore(middleware): update to 1.53.0 --- test/integration/Middleware.ts | 6 ++++++ tooling/autorest/middleware-prepare.mjs | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/test/integration/Middleware.ts b/test/integration/Middleware.ts index c88834e6bb..248b584526 100644 --- a/test/integration/Middleware.ts +++ b/test/integration/Middleware.ts @@ -37,6 +37,8 @@ describe('Middleware API', () => { const expectedRes: typeof res = { data: [{ blockHash: 'mh_LAo6Cg6d8LGDpxJ3se2aGJZbCubDZyC6GonHK58MKiW4a4LWb', + // @ts-expect-error https://github.com/aeternity/ae_mdw/issues/1454 + block_time: 1684995426848, height: 779178, payload: { block_hash: 'mh_LAo6Cg6d8LGDpxJ3se2aGJZbCubDZyC6GonHK58MKiW4a4LWb', @@ -73,6 +75,8 @@ describe('Middleware API', () => { type: 'GAMetaTxEvent', }, { blockHash: 'mh_2R1PVwTNP3Jha7oRby9Me3SRBP4R9he6RMH6eCCJGyVBHAzy5f', + // @ts-expect-error https://github.com/aeternity/ae_mdw/issues/1454 + block_time: 1684995366595, height: 779178, payload: { block_hash: 'mh_2R1PVwTNP3Jha7oRby9Me3SRBP4R9he6RMH6eCCJGyVBHAzy5f', @@ -111,6 +115,8 @@ describe('Middleware API', () => { type: 'GAAttachTxEvent', }, { blockHash: 'mh_25snWYwTkU1xjPCcH592XVNzL894qSpF4yqnt8tABKGEVm6nSz', + // @ts-expect-error https://github.com/aeternity/ae_mdw/issues/1454 + block_time: 1684995336526, height: 779178, payload: { block_hash: 'mh_25snWYwTkU1xjPCcH592XVNzL894qSpF4yqnt8tABKGEVm6nSz', diff --git a/tooling/autorest/middleware-prepare.mjs b/tooling/autorest/middleware-prepare.mjs index c61a5adefa..1abd0b1fc1 100755 --- a/tooling/autorest/middleware-prepare.mjs +++ b/tooling/autorest/middleware-prepare.mjs @@ -12,7 +12,7 @@ const run = (getOutput, command, ...args) => { return stdout?.toString().trim(); }; -const version = '1.52.0'; +const version = '1.53.0'; const id = run(true, 'docker', 'create', `aeternity/ae_mdw:${version}`); const openapi = `/home/aeternity/node/lib/ae_mdw-${version}/priv/static/swagger/swagger_v2.yaml`; run(false, 'docker', 'cp', `${id}:${openapi}`, './tooling/autorest/middleware-openapi.yaml');