Skip to content

Commit

Permalink
Remove version argument from constructor in tests and update contract…
Browse files Browse the repository at this point in the history
… initialization
  • Loading branch information
Ben-Rey committed Oct 11, 2024
1 parent 66da6f8 commit c0cc1f0
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ const metadataKey1 = 'version';
const metadataValue1 = '1.0.0';
const metadataKey2 = 'serve';
const metadataValue2 = '0';
const version = '1';

describe('Upload files', () => {
beforeEach(() => {
resetStorage();
setDeployContext(user);
constructor(new Args().add(version).serialize());
constructor(new Args().serialize());
});

test('upload some files', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ const fileData1: StaticArray<u8> = [1, 2, 3, 4];
const metadataKey1 = 'version';
const metadataValue1 = '1.0.0';
const metadata1 = new Metadata(metadataKey1, metadataValue1);
const version = '1';

describe('File Metadata', () => {
beforeEach(() => {
resetStorage();
setDeployContext(user);
constructor(new Args().add(version).serialize());
constructor(new Args().serialize());
});

test('Edit file metadata', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ const metadataKey1 = 'version';
const metadataValue1 = '1.0.0';

const metadata1 = new Metadata(metadataKey1, metadataValue1);
const version = '1';

describe('Upload files', () => {
beforeEach(() => {
resetStorage();
setDeployContext(user);
constructor(new Args().add(version).serialize());
constructor(new Args().serialize());
});

test('Edit global metadata', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ const metadataKey1 = 'version';
const metadataValue1 = '1.0.0';
const metadataKey2 = 'serve';
const metadataValue2 = '0';
const version = '1';

describe('Upload files', () => {
beforeEach(() => {
resetStorage();
setDeployContext(user);
constructor(new Args().add(version).serialize());
constructor(new Args().serialize());
});

test('Remove some files', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ const metadataKey1 = 'version';
const metadataValue1 = '1.0.0';
const metadataKey2 = 'serve';
const metadataValue2 = '0';
const version = '1';

describe('Upload files', () => {
beforeEach(() => {
resetStorage();
setDeployContext(user);
constructor(new Args().add(version).serialize());
constructor(new Args().serialize());
});

test('upload some files', () => {
Expand Down
7 changes: 4 additions & 3 deletions smart-contract/assembly/contracts/deweb-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,16 @@ import { _fileInit } from './internals/fileInit';
import { FileInit } from './serializable/FileInit';
import { DEWEB_VERSION_TAG } from './internals/storageKeys/tags';

const DEWEB_VERSION = '1';

/**
* Initializes the smart contract.
* Sets the contract deployer as the owner.
*/
export function constructor(binaryArgs: StaticArray<u8>): void {
export function constructor(_: StaticArray<u8>): void {
if (!Context.isDeployingContract()) return;

const version = new Args(binaryArgs).next<string>().expect('Invalid version');
Storage.set(DEWEB_VERSION_TAG, stringToBytes(version));
Storage.set(DEWEB_VERSION_TAG, stringToBytes(DEWEB_VERSION));

_setOwner(Context.caller().toString());
}
Expand Down

0 comments on commit c0cc1f0

Please sign in to comment.