@proto-kit/module 0.1.1-develop.190 → 0.1.1-develop.211
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/method/MethodParameterDecoder.d.ts.map +1 -1
- package/dist/method/MethodParameterDecoder.js +1 -1
- package/dist/method/RuntimeMethodExecutionContext.d.ts +2 -2
- package/dist/method/RuntimeMethodExecutionContext.d.ts.map +1 -1
- package/dist/module/src/factories/MethodIdFactory.d.ts +9 -0
- package/dist/module/src/factories/MethodIdFactory.d.ts.map +1 -0
- package/dist/module/src/factories/MethodIdFactory.js +36 -0
- package/dist/module/src/index.d.ts +11 -0
- package/dist/module/src/index.d.ts.map +1 -0
- package/dist/module/src/index.js +10 -0
- package/dist/module/src/method/MethodParameterDecoder.d.ts +22 -0
- package/dist/module/src/method/MethodParameterDecoder.d.ts.map +1 -0
- package/dist/module/src/method/MethodParameterDecoder.js +33 -0
- package/dist/module/src/method/runtimeMethod.d.ts +19 -0
- package/dist/module/src/method/runtimeMethod.d.ts.map +1 -0
- package/dist/module/src/method/runtimeMethod.js +123 -0
- package/dist/module/src/module/decorator.d.ts +8 -0
- package/dist/module/src/module/decorator.d.ts.map +1 -0
- package/dist/module/src/module/decorator.js +15 -0
- package/dist/module/src/runtime/MethodIdResolver.d.ts +18 -0
- package/dist/module/src/runtime/MethodIdResolver.d.ts.map +1 -0
- package/dist/module/src/runtime/MethodIdResolver.js +50 -0
- package/dist/module/src/runtime/Runtime.d.ts +72 -0
- package/dist/module/src/runtime/Runtime.d.ts.map +1 -0
- package/dist/module/src/runtime/Runtime.js +184 -0
- package/dist/module/src/runtime/RuntimeModule.d.ts +35 -0
- package/dist/module/src/runtime/RuntimeModule.d.ts.map +1 -0
- package/dist/module/src/runtime/RuntimeModule.js +56 -0
- package/dist/module/src/state/InMemoryStateService.d.ts +11 -0
- package/dist/module/src/state/InMemoryStateService.d.ts.map +1 -0
- package/dist/module/src/state/InMemoryStateService.js +21 -0
- package/dist/module/src/state/decorator.d.ts +7 -0
- package/dist/module/src/state/decorator.d.ts.map +1 -0
- package/dist/module/src/state/decorator.js +42 -0
- package/dist/protocol/src/model/Option.d.ts +98 -0
- package/dist/protocol/src/model/Option.d.ts.map +1 -0
- package/dist/protocol/src/model/Option.js +98 -0
- package/dist/protocol/src/model/StateTransition.d.ts +96 -0
- package/dist/protocol/src/model/StateTransition.d.ts.map +1 -0
- package/dist/protocol/src/model/StateTransition.js +65 -0
- package/dist/protocol/src/model/network/NetworkState.d.ts +64 -0
- package/dist/protocol/src/model/network/NetworkState.d.ts.map +1 -0
- package/dist/protocol/src/model/network/NetworkState.js +12 -0
- package/dist/protocol/src/model/transaction/ProtocolTransaction.d.ts +70 -0
- package/dist/protocol/src/model/transaction/ProtocolTransaction.d.ts.map +1 -0
- package/dist/protocol/src/model/transaction/ProtocolTransaction.js +18 -0
- package/dist/protocol/src/model/transaction/RuntimeTransaction.d.ts +63 -0
- package/dist/protocol/src/model/transaction/RuntimeTransaction.d.ts.map +1 -0
- package/dist/protocol/src/model/transaction/RuntimeTransaction.js +29 -0
- package/dist/protocol/src/state/assert/assert.d.ts +12 -0
- package/dist/protocol/src/state/assert/assert.d.ts.map +1 -0
- package/dist/protocol/src/state/assert/assert.js +23 -0
- package/dist/protocol/src/state/context/RuntimeMethodExecutionContext.d.ts +60 -0
- package/dist/protocol/src/state/context/RuntimeMethodExecutionContext.d.ts.map +1 -0
- package/dist/protocol/src/state/context/RuntimeMethodExecutionContext.js +105 -0
- package/dist/state/StateMap.d.ts +3 -3
- package/dist/state/StateMap.d.ts.map +1 -1
- package/package.json +3 -4
- package/src/index.ts +2 -5
- package/src/method/MethodParameterDecoder.ts +3 -1
- package/src/method/runtimeMethod.ts +1 -2
- package/src/runtime/Runtime.ts +12 -10
- package/src/runtime/RuntimeModule.ts +5 -4
- package/src/state/InMemoryStateService.ts +1 -5
- package/src/state/decorator.ts +2 -4
- package/test/Runtime.test.ts +2 -2
- package/test/modules/Admin.ts +1 -1
- package/test/modules/Balances.test.ts +13 -8
- package/test/modules/Balances.ts +7 -3
- package/test/modules/State.test.ts +88 -0
- package/test/modules/methodId.test.ts +0 -1
- package/test/transaction.test.ts +1 -1
- package/src/method/RuntimeMethodExecutionContext.ts +0 -111
- package/src/method/assert.test.ts +0 -49
- package/src/method/assert.ts +0 -27
- package/src/state/State.ts +0 -154
- package/src/state/StateMap.ts +0 -69
- package/src/state/StateServiceProvider.ts +0 -24
package/src/state/StateMap.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import type { Field, FlexibleProvablePure } from "snarkyjs";
|
|
2
|
-
import { Path, type Option } from "@proto-kit/protocol";
|
|
3
|
-
import { Mixin } from "ts-mixer";
|
|
4
|
-
|
|
5
|
-
import { State, WithRuntime, WithPath } from "./State.js";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Map-like wrapper for state
|
|
9
|
-
*/
|
|
10
|
-
// eslint-disable-next-line new-cap
|
|
11
|
-
export class StateMap<KeyType, ValueType> extends Mixin(WithPath, WithRuntime) {
|
|
12
|
-
/**
|
|
13
|
-
* Create a new state map with the given key and value types
|
|
14
|
-
*
|
|
15
|
-
* @param keyType - Type to be used as a key
|
|
16
|
-
* @param valueType - Type to be stored as a value
|
|
17
|
-
* @returns State map with provided key and value types.
|
|
18
|
-
*/
|
|
19
|
-
public static from<KeyType, ValueType>(
|
|
20
|
-
keyType: FlexibleProvablePure<KeyType>,
|
|
21
|
-
valueType: FlexibleProvablePure<ValueType>
|
|
22
|
-
) {
|
|
23
|
-
return new StateMap<KeyType, ValueType>(keyType, valueType);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
public constructor(
|
|
27
|
-
public keyType: FlexibleProvablePure<KeyType>,
|
|
28
|
-
public valueType: FlexibleProvablePure<ValueType>
|
|
29
|
-
) {
|
|
30
|
-
super();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
public getPath(key: KeyType): Field {
|
|
34
|
-
this.hasPathOrFail();
|
|
35
|
-
return Path.fromKey(this.path, this.keyType, key);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Obtains a value for the provided key in the current state map.
|
|
40
|
-
*
|
|
41
|
-
* @param key - Key to obtain the state for
|
|
42
|
-
* @returns Value for the provided key.
|
|
43
|
-
*/
|
|
44
|
-
public get(key: KeyType): Option<ValueType> {
|
|
45
|
-
const state = State.from(this.valueType);
|
|
46
|
-
this.hasPathOrFail();
|
|
47
|
-
this.hasRuntimeOrFail();
|
|
48
|
-
|
|
49
|
-
state.path = this.getPath(key);
|
|
50
|
-
state.runtime = this.runtime;
|
|
51
|
-
return state.get();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Sets a value for the given key in the current state map.
|
|
56
|
-
*
|
|
57
|
-
* @param key - Key to store the value under
|
|
58
|
-
* @param value - Value to be stored under the given key
|
|
59
|
-
*/
|
|
60
|
-
public set(key: KeyType, value: ValueType) {
|
|
61
|
-
const state = State.from(this.valueType);
|
|
62
|
-
this.hasPathOrFail();
|
|
63
|
-
this.hasRuntimeOrFail();
|
|
64
|
-
|
|
65
|
-
state.path = Path.fromKey(this.path, this.keyType, key);
|
|
66
|
-
state.runtime = this.runtime;
|
|
67
|
-
state.set(value);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { inject, injectable } from "tsyringe";
|
|
2
|
-
|
|
3
|
-
import { StateService } from "./InMemoryStateService";
|
|
4
|
-
|
|
5
|
-
@injectable()
|
|
6
|
-
export class StateServiceProvider {
|
|
7
|
-
private readonly defaultStateService: StateService = this.currentStateService;
|
|
8
|
-
|
|
9
|
-
public constructor(
|
|
10
|
-
@inject("StateService") private currentStateService: StateService
|
|
11
|
-
) {}
|
|
12
|
-
|
|
13
|
-
public get stateService(): StateService {
|
|
14
|
-
return this.currentStateService;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
public setCurrentStateService(service: StateService) {
|
|
18
|
-
this.currentStateService = service;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
public resetToDefault() {
|
|
22
|
-
this.currentStateService = this.defaultStateService;
|
|
23
|
-
}
|
|
24
|
-
}
|