Skip to content

Commit

Permalink
add contracts2
Browse files Browse the repository at this point in the history
  • Loading branch information
Anmol1696 committed Oct 2, 2024
1 parent a1aeb81 commit dcf5447
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 6 deletions.
28 changes: 28 additions & 0 deletions contracts/bundle1.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions contracts/bundle1.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions contracts/bundle2.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions contracts/bundle2.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions src/contract1/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ interface MyState {

export function reset(state: MyState) {
const newValue = 0;
state.set('value', 0);
state.value = 0;
return newValue
}
export function inc(state: MyState, {x}) {
const oldValue = state.get('value') ?? 0;
const oldValue = state.value ?? 0;
const newValue = oldValue + x;
state.set('value', newValue);
state.value = newValue;
return newValue
}
export function dec(state: MyState, {x}) {
const oldValue = state.get('value') ?? 0;
const oldValue = state.value ?? 0;
const newValue = oldValue - x;
state.set('value', newValue);
state.value = newValue;
return newValue
}

export function read(state: MyState) {
return state.get('value');
return state.value;
}
25 changes: 25 additions & 0 deletions src/contract2/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
interface MyState {
value: number;
}

export function reset(state: MyState) {
const newValue = 0;
state.value = 0;
return newValue
}
export function inc(state: MyState, {x}) {
const oldValue = state.value ?? 0;
const newValue = oldValue + x;
state.value = newValue;
return newValue
}
export function dec(state: MyState, {x}) {
const oldValue = state.value ?? 0;
const newValue = oldValue - x;
state.value = newValue;
return newValue
}

export function read(state: MyState) {
return state.value;
}

0 comments on commit dcf5447

Please sign in to comment.