From dcf54478cb8b288038f82c8c40c7df5738807fba Mon Sep 17 00:00:00 2001 From: Anmol1696 Date: Wed, 2 Oct 2024 15:04:57 +0400 Subject: [PATCH] add contracts2 --- contracts/bundle1.js | 28 ++++++++++++++++++++++++++++ contracts/bundle1.js.map | 7 +++++++ contracts/bundle2.js | 28 ++++++++++++++++++++++++++++ contracts/bundle2.js.map | 7 +++++++ src/contract1/index.ts | 12 ++++++------ src/contract2/index.ts | 25 +++++++++++++++++++++++++ 6 files changed, 101 insertions(+), 6 deletions(-) create mode 100644 contracts/bundle1.js create mode 100644 contracts/bundle1.js.map create mode 100644 contracts/bundle2.js create mode 100644 contracts/bundle2.js.map create mode 100644 src/contract2/index.ts diff --git a/contracts/bundle1.js b/contracts/bundle1.js new file mode 100644 index 0000000..9bd7512 --- /dev/null +++ b/contracts/bundle1.js @@ -0,0 +1,28 @@ +// src/contract1/index.ts +function reset(state) { + const newValue = 0; + state.value = 0; + return newValue; +} +function inc(state, { x }) { + const oldValue = state.value ?? 0; + const newValue = oldValue + x; + state.value = newValue; + return newValue; +} +function dec(state, { x }) { + const oldValue = state.value ?? 0; + const newValue = oldValue - x; + state.value = newValue; + return newValue; +} +function read(state) { + return state.value; +} +export { + dec, + inc, + read, + reset +}; +//# sourceMappingURL=bundle1.js.map diff --git a/contracts/bundle1.js.map b/contracts/bundle1.js.map new file mode 100644 index 0000000..e304678 --- /dev/null +++ b/contracts/bundle1.js.map @@ -0,0 +1,7 @@ +{ + "version": 3, + "sources": ["../src/contract1/index.ts"], + "sourcesContent": ["interface MyState {\n value: number;\n}\n\nexport function reset(state: MyState) {\n const newValue = 0;\n state.value = 0;\n return newValue\n}\nexport function inc(state: MyState, {x}) {\n const oldValue = state.value ?? 0;\n const newValue = oldValue + x;\n state.value = newValue;\n return newValue\n}\nexport function dec(state: MyState, {x}) {\n const oldValue = state.value ?? 0;\n const newValue = oldValue - x;\n state.value = newValue;\n return newValue\n}\n\nexport function read(state: MyState) {\n return state.value;\n}\n"], + "mappings": ";AAIO,SAAS,MAAM,OAAgB;AACpC,QAAM,WAAW;AACjB,QAAM,QAAQ;AACd,SAAO;AACT;AACO,SAAS,IAAI,OAAgB,EAAC,EAAC,GAAG;AACvC,QAAM,WAAW,MAAM,SAAS;AAChC,QAAM,WAAW,WAAW;AAC5B,QAAM,QAAQ;AACd,SAAO;AACT;AACO,SAAS,IAAI,OAAgB,EAAC,EAAC,GAAG;AACvC,QAAM,WAAW,MAAM,SAAS;AAChC,QAAM,WAAW,WAAW;AAC5B,QAAM,QAAQ;AACd,SAAO;AACT;AAEO,SAAS,KAAK,OAAgB;AACnC,SAAO,MAAM;AACf;", + "names": [] +} diff --git a/contracts/bundle2.js b/contracts/bundle2.js new file mode 100644 index 0000000..d9ac006 --- /dev/null +++ b/contracts/bundle2.js @@ -0,0 +1,28 @@ +// src/contract2/index.ts +function reset(state) { + const newValue = 0; + state.value = 0; + return newValue; +} +function inc(state, { x }) { + const oldValue = state.value ?? 0; + const newValue = oldValue + x; + state.value = newValue; + return newValue; +} +function dec(state, { x }) { + const oldValue = state.value ?? 0; + const newValue = oldValue - x; + state.value = newValue; + return newValue; +} +function read(state) { + return state.value; +} +export { + dec, + inc, + read, + reset +}; +//# sourceMappingURL=bundle2.js.map diff --git a/contracts/bundle2.js.map b/contracts/bundle2.js.map new file mode 100644 index 0000000..6f956c4 --- /dev/null +++ b/contracts/bundle2.js.map @@ -0,0 +1,7 @@ +{ + "version": 3, + "sources": ["../src/contract2/index.ts"], + "sourcesContent": ["interface MyState {\n value: number;\n}\n\nexport function reset(state: MyState) {\n const newValue = 0;\n state.value = 0;\n return newValue\n}\nexport function inc(state: MyState, {x}) {\n const oldValue = state.value ?? 0;\n const newValue = oldValue + x;\n state.value = newValue;\n return newValue\n}\nexport function dec(state: MyState, {x}) {\n const oldValue = state.value ?? 0;\n const newValue = oldValue - x;\n state.value = newValue;\n return newValue\n}\n\nexport function read(state: MyState) {\n return state.value;\n}\n"], + "mappings": ";AAIO,SAAS,MAAM,OAAgB;AACpC,QAAM,WAAW;AACjB,QAAM,QAAQ;AACd,SAAO;AACT;AACO,SAAS,IAAI,OAAgB,EAAC,EAAC,GAAG;AACvC,QAAM,WAAW,MAAM,SAAS;AAChC,QAAM,WAAW,WAAW;AAC5B,QAAM,QAAQ;AACd,SAAO;AACT;AACO,SAAS,IAAI,OAAgB,EAAC,EAAC,GAAG;AACvC,QAAM,WAAW,MAAM,SAAS;AAChC,QAAM,WAAW,WAAW;AAC5B,QAAM,QAAQ;AACd,SAAO;AACT;AAEO,SAAS,KAAK,OAAgB;AACnC,SAAO,MAAM;AACf;", + "names": [] +} diff --git a/src/contract1/index.ts b/src/contract1/index.ts index 6487811..599cbad 100644 --- a/src/contract1/index.ts +++ b/src/contract1/index.ts @@ -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; } diff --git a/src/contract2/index.ts b/src/contract2/index.ts new file mode 100644 index 0000000..599cbad --- /dev/null +++ b/src/contract2/index.ts @@ -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; +}