Skip to content

Commit

Permalink
Merge branch 'main' into add-tag-constant-manager
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben-Rey authored Sep 25, 2024
2 parents 212fda2 + 69bb9f4 commit 887a5e0
Show file tree
Hide file tree
Showing 12 changed files with 249 additions and 2,094 deletions.
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
}
30 changes: 10 additions & 20 deletions asconfig.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
{
"targets": {
"debug": {
"outFile": "build/debug.wasm",
"textFile": "build/debug.wat",
"sourceMap": true,
"debug": true
},
"release": {
"outFile": "build/release.wasm",
"textFile": "build/release.wat",
"sourceMap": true,
"optimizeLevel": 3,
"shrinkLevel": 0,
"converge": false,
"noAssert": false
"targets": {
"release": {
"sourceMap": true,
"optimizeLevel": 3,
"shrinkLevel": 3,
"converge": true,
"noAssert": false,
"exportRuntime": true,
"bindings": false
}
}
},
"options": {
"bindings": "esm",
"transform": ["@massalabs/as-transformer"]
}
}
3 changes: 0 additions & 3 deletions assembly/__tests__/env-account.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { Address } from '../std';
import { changeCallStack, resetStorage } from '../vm-mock/storage';
import { Args, bytesToString, stringToBytes } from '@massalabs/as-types';
import { env } from '../env/index';

describe('Testing mocked account related functions', () => {
Expand Down
8 changes: 7 additions & 1 deletion assembly/__tests__/env-helpers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { env } from '../env';
import { Address } from '../std';
import { addAddressToLedger } from '../vm-mock';
import { addAddressToLedger, mockCurrentSlot } from '../vm-mock';

const testAddress = new Address(
'AU12E6N5BFAdC2wyiBV6VJjqkWhpz1kLVp2XpbRdSnL1mKjCWT6oR',
Expand All @@ -17,6 +17,12 @@ describe('Testing env coins related functions', () => {
expect(env.currentThread()).toBe(1);
});

test('current slot', () => {
mockCurrentSlot(1234, 8);
expect(env.currentPeriod()).toBe(1234);
expect(env.currentThread()).toBe(8);
});

test('setBytecode', () => {
env.setBytecode(new StaticArray(0));
const byteCode = env.getBytecode().toString();
Expand Down
4 changes: 2 additions & 2 deletions assembly/__tests__/env-opdatastore.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { env } from '../env/index';

import { changeCallStack, resetStorage } from '../vm-mock/storage';
import { Args, bytesToString, stringToBytes } from '@massalabs/as-types';
import { resetStorage } from '../vm-mock/storage';
import { stringToBytes } from '@massalabs/as-types';

describe('Testing mocked Operation Datastore', () => {
beforeAll(() => {
Expand Down
2 changes: 1 addition & 1 deletion assembly/security/accessControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import { Address, Storage } from '../std/index';
* return [];
* }
*
* export function superSensite(_: StaticArray<u8>): StaticArray<u8> {
* export function superSensible(_: StaticArray<u8>): StaticArray<u8> {
* controller.mustHavePermission(ADMIN, Context.caller());
* return stringToBytes('Super sensitive data');
* }
Expand Down
3 changes: 3 additions & 0 deletions assembly/vm-mock/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,6 @@ export declare function mockSetChainId(value: number): void;
*/
@external("massa", "assembly_script_set_origin_operation_id")
export declare function mockOriginOperationId(opId: string): void;

@external("massa", "assembly_script_set_slot")
export declare function mockCurrentSlot(period: u64, thread: u8): void;
2 changes: 1 addition & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
// export {env};

// massa std functionalities
export * from "./assembly/index";
export * from './assembly/index';
Loading

0 comments on commit 887a5e0

Please sign in to comment.