@proto-kit/protocol 0.1.1-develop.457 → 0.1.1-develop.651
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/blockmodules/AccountStateModule.d.ts.map +1 -1
- package/dist/blockmodules/AccountStateModule.js +10 -3
- package/dist/blockmodules/BlockHeightHook.d.ts +3 -3
- package/dist/blockmodules/BlockHeightHook.d.ts.map +1 -1
- package/dist/blockmodules/BlockHeightHook.js +5 -4
- package/dist/blockmodules/LastStateRootBlockHook.d.ts +8 -0
- package/dist/blockmodules/LastStateRootBlockHook.d.ts.map +1 -0
- package/dist/blockmodules/LastStateRootBlockHook.js +15 -0
- package/dist/blockmodules/NoopBlockHook.d.ts +6 -4
- package/dist/blockmodules/NoopBlockHook.d.ts.map +1 -1
- package/dist/blockmodules/NoopBlockHook.js +4 -4
- package/dist/blockmodules/NoopSettlementHook.d.ts +6 -0
- package/dist/blockmodules/NoopSettlementHook.d.ts.map +1 -0
- package/dist/blockmodules/NoopSettlementHook.js +18 -0
- package/dist/hooks/AccountStateHook.d.ts.map +1 -1
- package/dist/hooks/AccountStateHook.js +17 -5
- package/dist/hooks/BlockHeightHook.d.ts +3 -3
- package/dist/hooks/BlockHeightHook.d.ts.map +1 -1
- package/dist/hooks/BlockHeightHook.js +5 -4
- package/dist/hooks/LastStateRootBlockHook.d.ts +8 -0
- package/dist/hooks/LastStateRootBlockHook.d.ts.map +1 -0
- package/dist/hooks/LastStateRootBlockHook.js +15 -0
- package/dist/hooks/NoopBlockHook.d.ts +6 -4
- package/dist/hooks/NoopBlockHook.d.ts.map +1 -1
- package/dist/hooks/NoopBlockHook.js +4 -4
- package/dist/hooks/NoopSettlementHook.d.ts +6 -0
- package/dist/hooks/NoopSettlementHook.d.ts.map +1 -0
- package/dist/hooks/NoopSettlementHook.js +18 -0
- package/dist/index.d.ts +24 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -6
- package/dist/model/MethodPublicOutput.d.ts +8 -0
- package/dist/model/MethodPublicOutput.d.ts.map +1 -1
- package/dist/model/MethodPublicOutput.js +1 -0
- package/dist/model/Option.d.ts +3 -2
- package/dist/model/Option.d.ts.map +1 -1
- package/dist/model/Option.js +5 -0
- package/dist/model/RuntimeLike.d.ts +11 -0
- package/dist/model/RuntimeLike.d.ts.map +1 -0
- package/dist/model/RuntimeLike.js +1 -0
- package/dist/model/StateTransition.d.ts +6 -5
- package/dist/model/StateTransition.d.ts.map +1 -1
- package/dist/model/StateTransition.js +3 -0
- package/dist/model/StateTransitionReduction.d.ts +3 -0
- package/dist/model/StateTransitionReduction.d.ts.map +1 -0
- package/dist/model/StateTransitionReduction.js +26 -0
- package/dist/model/network/NetworkState.d.ts +40 -0
- package/dist/model/network/NetworkState.d.ts.map +1 -1
- package/dist/model/network/NetworkState.js +14 -2
- package/dist/model/transaction/RuntimeTransaction.d.ts +45 -20
- package/dist/model/transaction/RuntimeTransaction.d.ts.map +1 -1
- package/dist/model/transaction/RuntimeTransaction.js +68 -11
- package/dist/model/transaction/SignedTransaction.d.ts +71 -0
- package/dist/model/transaction/SignedTransaction.d.ts.map +1 -0
- package/dist/model/transaction/SignedTransaction.js +33 -0
- package/dist/model/transaction/ValueOption.d.ts +119 -0
- package/dist/model/transaction/ValueOption.d.ts.map +1 -0
- package/dist/model/transaction/ValueOption.js +24 -0
- package/dist/protocol/Protocol.d.ts +13 -16
- package/dist/protocol/Protocol.d.ts.map +1 -1
- package/dist/protocol/Protocol.js +26 -39
- package/dist/protocol/ProtocolModule.d.ts.map +1 -1
- package/dist/protocol/ProtocolModule.js +1 -1
- package/dist/protocol/ProvableBlockHook.d.ts +2 -10
- package/dist/protocol/ProvableBlockHook.d.ts.map +1 -1
- package/dist/protocol/ProvableBlockHook.js +1 -1
- package/dist/protocol/ProvableTransactionHook.d.ts +1 -1
- package/dist/protocol/ProvableTransactionHook.d.ts.map +1 -1
- package/dist/protocol/TransitioningProtocolModule.d.ts +3 -2
- package/dist/protocol/TransitioningProtocolModule.d.ts.map +1 -1
- package/dist/protocol/TransitioningProtocolModule.js +3 -2
- package/dist/prover/block/BlockProvable.d.ts +106 -28
- package/dist/prover/block/BlockProvable.d.ts.map +1 -1
- package/dist/prover/block/BlockProvable.js +23 -5
- package/dist/prover/block/BlockProver.d.ts +29 -8
- package/dist/prover/block/BlockProver.d.ts.map +1 -1
- package/dist/prover/block/BlockProver.js +244 -78
- package/dist/prover/block/accummulators/BlockHashMerkleTree.d.ts +45 -0
- package/dist/prover/block/accummulators/BlockHashMerkleTree.d.ts.map +1 -0
- package/dist/prover/block/accummulators/BlockHashMerkleTree.js +16 -0
- package/dist/prover/statetransition/StateTransitionProver.d.ts +3 -2
- package/dist/prover/statetransition/StateTransitionProver.d.ts.map +1 -1
- package/dist/prover/statetransition/StateTransitionProver.js +1 -0
- package/dist/settlement/ContractModule.d.ts +15 -0
- package/dist/settlement/ContractModule.d.ts.map +1 -0
- package/dist/settlement/ContractModule.js +11 -0
- package/dist/settlement/ProvableSettlementHook.d.ts +26 -0
- package/dist/settlement/ProvableSettlementHook.d.ts.map +1 -0
- package/dist/settlement/ProvableSettlementHook.js +3 -0
- package/dist/settlement/SettlementContract.d.ts +230 -0
- package/dist/settlement/SettlementContract.d.ts.map +1 -0
- package/dist/settlement/SettlementContract.js +346 -0
- package/dist/settlement/SettlementContractModule.d.ts +39 -0
- package/dist/settlement/SettlementContractModule.d.ts.map +1 -0
- package/dist/settlement/SettlementContractModule.js +68 -0
- package/dist/settlement/contracts/DispatchContractProtocolModule.d.ts +12 -0
- package/dist/settlement/contracts/DispatchContractProtocolModule.d.ts.map +1 -0
- package/dist/settlement/contracts/DispatchContractProtocolModule.js +36 -0
- package/dist/settlement/contracts/DispatchSmartContract.d.ts +22 -0
- package/dist/settlement/contracts/DispatchSmartContract.d.ts.map +1 -0
- package/dist/settlement/contracts/DispatchSmartContract.js +110 -0
- package/dist/settlement/contracts/SettlementContractProtocolModule.d.ts +19 -0
- package/dist/settlement/contracts/SettlementContractProtocolModule.d.ts.map +1 -0
- package/dist/settlement/contracts/SettlementContractProtocolModule.js +44 -0
- package/dist/settlement/contracts/SettlementSmartContract.d.ts +41 -0
- package/dist/settlement/contracts/SettlementSmartContract.d.ts.map +1 -0
- package/dist/settlement/contracts/SettlementSmartContract.js +235 -0
- package/dist/settlement/messages/Deposit.d.ts +39 -0
- package/dist/settlement/messages/Deposit.d.ts.map +1 -0
- package/dist/settlement/messages/Deposit.js +6 -0
- package/dist/settlement/messages/OutgoingMessageArgument.d.ts +109 -0
- package/dist/settlement/messages/OutgoingMessageArgument.d.ts.map +1 -0
- package/dist/settlement/messages/OutgoingMessageArgument.js +32 -0
- package/dist/settlement/messages/Withdrawal.d.ts +40 -0
- package/dist/settlement/messages/Withdrawal.d.ts.map +1 -0
- package/dist/settlement/messages/Withdrawal.js +13 -0
- package/dist/settlement/modularity/ProvableSettlementHook.d.ts +24 -0
- package/dist/settlement/modularity/ProvableSettlementHook.d.ts.map +1 -0
- package/dist/settlement/modularity/ProvableSettlementHook.js +3 -0
- package/dist/settlement/modules/NetworkStateSettlementModule.d.ts +11 -0
- package/dist/settlement/modules/NetworkStateSettlementModule.d.ts.map +1 -0
- package/dist/settlement/modules/NetworkStateSettlementModule.js +12 -0
- package/dist/state/State.d.ts.map +1 -1
- package/dist/state/State.js +2 -1
- package/dist/state/assert/assert.d.ts.map +1 -1
- package/dist/state/assert/assert.js +8 -5
- package/dist/state/context/RuntimeMethodExecutionContext.d.ts +75 -1
- package/dist/state/context/RuntimeMethodExecutionContext.d.ts.map +1 -1
- package/dist/state/context/RuntimeMethodExecutionContext.js +21 -2
- package/dist/utils/MinaPrefixedProvableHashList.d.ts +24 -0
- package/dist/utils/MinaPrefixedProvableHashList.d.ts.map +1 -0
- package/dist/utils/MinaPrefixedProvableHashList.js +51 -0
- package/dist/utils/PrefixedProvableHashList.d.ts +2 -2
- package/dist/utils/PrefixedProvableHashList.d.ts.map +1 -1
- package/dist/utils/ProvableHashList.d.ts +3 -3
- package/dist/utils/ProvableHashList.d.ts.map +1 -1
- package/dist/utils/ProvableReductionHashList.d.ts +14 -0
- package/dist/utils/ProvableReductionHashList.d.ts.map +1 -0
- package/dist/utils/ProvableReductionHashList.js +50 -0
- package/dist/utils/StateTransitionReductionList.d.ts +11 -0
- package/dist/utils/StateTransitionReductionList.d.ts.map +1 -0
- package/dist/utils/StateTransitionReductionList.js +60 -0
- package/package.json +2 -2
- package/src/hooks/AccountStateHook.ts +46 -0
- package/src/hooks/BlockHeightHook.ts +18 -0
- package/src/hooks/LastStateRootBlockHook.ts +26 -0
- package/src/hooks/NoopBlockHook.ts +20 -0
- package/src/hooks/NoopSettlementHook.ts +20 -0
- package/src/hooks/SequenceStateTransactionModule.ts +25 -0
- package/src/index.ts +24 -6
- package/src/model/MethodPublicOutput.ts +3 -2
- package/src/model/Option.ts +16 -0
- package/src/model/RuntimeLike.ts +12 -0
- package/src/model/StateTransition.ts +10 -2
- package/src/model/network/NetworkState.ts +15 -3
- package/src/model/transaction/RuntimeTransaction.ts +90 -16
- package/src/model/transaction/SignedTransaction.ts +54 -0
- package/src/model/transaction/ValueOption.ts +28 -0
- package/src/protocol/Protocol.ts +60 -67
- package/src/protocol/ProtocolModule.ts +3 -2
- package/src/protocol/ProvableBlockHook.ts +10 -13
- package/src/protocol/ProvableTransactionHook.ts +2 -1
- package/src/protocol/TransitioningProtocolModule.ts +3 -2
- package/src/prover/block/BlockProvable.ts +39 -6
- package/src/prover/block/BlockProver.ts +484 -142
- package/src/prover/block/accummulators/BlockHashMerkleTree.ts +16 -0
- package/src/prover/statetransition/StateTransitionProver.ts +4 -2
- package/src/settlement/ContractModule.ts +24 -0
- package/src/settlement/SettlementContractModule.ts +127 -0
- package/src/settlement/contracts/DispatchContractProtocolModule.ts +39 -0
- package/src/settlement/contracts/DispatchSmartContract.ts +135 -0
- package/src/settlement/contracts/SettlementContractProtocolModule.ts +65 -0
- package/src/settlement/contracts/SettlementSmartContract.ts +329 -0
- package/src/settlement/messages/Deposit.ts +6 -0
- package/src/settlement/messages/OutgoingMessageArgument.ts +41 -0
- package/src/settlement/messages/Withdrawal.ts +14 -0
- package/src/settlement/modularity/ProvableSettlementHook.ts +34 -0
- package/src/settlement/modules/NetworkStateSettlementModule.ts +39 -0
- package/src/state/State.ts +2 -1
- package/src/state/assert/assert.ts +8 -6
- package/src/state/context/RuntimeMethodExecutionContext.ts +22 -2
- package/src/utils/MinaPrefixedProvableHashList.ts +72 -0
- package/src/utils/PrefixedProvableHashList.ts +2 -2
- package/src/utils/ProvableHashList.ts +3 -3
- package/src/utils/ProvableReductionHashList.ts +68 -0
- package/src/utils/StateTransitionReductionList.ts +88 -0
- package/test/BlockProver.test.ts +4 -5
- package/test/Protocol.test.ts +15 -10
- package/test/settlement/SettlementContract.test.ts +45 -0
- package/test/utils/ProvableReductionHashList.test.ts +114 -0
- package/src/blockmodules/AccountStateModule.ts +0 -33
- package/src/blockmodules/BlockHeightHook.ts +0 -21
- package/src/blockmodules/NoopBlockHook.ts +0 -16
- package/src/model/transaction/ProtocolTransaction.ts +0 -25
- package/src/prover/block/BlockTransactionPosition.ts +0 -34
- /package/src/{blockmodules → hooks}/NoopTransactionHook.ts +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Field } from "o1js";
|
|
1
|
+
import { Field, ProvablePure } from "o1js";
|
|
2
2
|
import { Option, ProvableOption } from "./Option";
|
|
3
3
|
declare const ProvableStateTransition_base: (new (value: {
|
|
4
4
|
path: import("o1js/dist/node/lib/field").Field;
|
|
@@ -10,7 +10,7 @@ declare const ProvableStateTransition_base: (new (value: {
|
|
|
10
10
|
to: ProvableOption;
|
|
11
11
|
}) & {
|
|
12
12
|
_isStruct: true;
|
|
13
|
-
} &
|
|
13
|
+
} & ProvablePure<{
|
|
14
14
|
path: import("o1js/dist/node/lib/field").Field;
|
|
15
15
|
from: ProvableOption;
|
|
16
16
|
to: ProvableOption;
|
|
@@ -68,12 +68,12 @@ export declare class ProvableStateTransition extends ProvableStateTransition_bas
|
|
|
68
68
|
*/
|
|
69
69
|
export declare class StateTransition<Value> {
|
|
70
70
|
path: Field;
|
|
71
|
-
fromValue: Option<
|
|
71
|
+
fromValue: Option<Value>;
|
|
72
72
|
toValue: Option<Field> | Option<Value>;
|
|
73
73
|
static from<Value>(path: Field, fromValue: Option<Value>): StateTransition<Value>;
|
|
74
74
|
static fromTo<Value>(path: Field, fromValue: Option<Value>, toValue: Option<Value>): StateTransition<Value>;
|
|
75
|
-
constructor(path: Field, fromValue: Option<
|
|
76
|
-
get from(): Option<
|
|
75
|
+
constructor(path: Field, fromValue: Option<Value>, toValue: Option<Field> | Option<Value>);
|
|
76
|
+
get from(): Option<Value>;
|
|
77
77
|
get to(): Option<import("o1js/dist/node/lib/field").Field> | Option<Value>;
|
|
78
78
|
/**
|
|
79
79
|
* Converts a StateTransition to a ProvableStateTransition,
|
|
@@ -93,6 +93,7 @@ export declare class StateTransition<Value> {
|
|
|
93
93
|
value: string[];
|
|
94
94
|
};
|
|
95
95
|
};
|
|
96
|
+
toConstant(): StateTransition<Value>;
|
|
96
97
|
}
|
|
97
98
|
export {};
|
|
98
99
|
//# sourceMappingURL=StateTransition.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StateTransition.d.ts","sourceRoot":"","sources":["../../src/model/StateTransition.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"StateTransition.d.ts","sourceRoot":"","sources":["../../src/model/StateTransition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,EAAE,YAAY,EAAU,MAAM,MAAM,CAAC;AAEzD,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAElD;;;;GAIG;AACH,qBAAa,uBAAwB,SAAQ,4BAQ3C;WACc,KAAK,IAAI,uBAAuB;CAO/C;AAED;;;GAGG;AACH,qBAAa,eAAe,CAAC,KAAK;IAcvB,IAAI,EAAE,KAAK;IACX,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC;WAfjC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC;WAIjD,MAAM,CAAC,KAAK,EACxB,IAAI,EAAE,KAAK,EACX,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,EACxB,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC;gBAMf,IAAI,EAAE,KAAK,EACX,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,EACxB,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC;IAG/C,IAAW,IAAI,kBAId;IAED,IAAW,EAAE,qEAEZ;IAED;;;OAGG;IACI,UAAU,IAAI,uBAAuB;IAQrC,MAAM;;;;;;;;;;;;;IAQN,UAAU,IAAI,eAAe,CAAC,KAAK,CAAC;CAO5C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StateTransitionReduction.d.ts","sourceRoot":"","sources":["../../src/model/StateTransitionReduction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,eAAe,CAAC,OAAO,CAAC,EAAE,GACtC,eAAe,CAAC,OAAO,CAAC,EAAE,CA0B5B"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { StateTransition } from "./StateTransition";
|
|
2
|
+
export function reduceStateTransitions(transitions) {
|
|
3
|
+
const reduced = [];
|
|
4
|
+
for (const st of transitions) {
|
|
5
|
+
if (reduced.length === 0) {
|
|
6
|
+
reduced.push(st);
|
|
7
|
+
continue;
|
|
8
|
+
}
|
|
9
|
+
const last = reduced.at(-1);
|
|
10
|
+
if (last.path.equals(st.path).toBoolean()) {
|
|
11
|
+
if (st.toValue.isSome.toBoolean()) {
|
|
12
|
+
reduced.pop();
|
|
13
|
+
reduced.push(new StateTransition(st.path, last.fromValue, st.toValue));
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
// Do nothing, because we discard that ST
|
|
17
|
+
// { from: 5, to: 10 }, { from: 10, to: none }
|
|
18
|
+
// cancel the 2nd
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
reduced.push(st);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return reduced;
|
|
26
|
+
}
|
|
@@ -27,34 +27,74 @@ declare const CurrentBlock_base: (new (value: {
|
|
|
27
27
|
};
|
|
28
28
|
export declare class CurrentBlock extends CurrentBlock_base {
|
|
29
29
|
}
|
|
30
|
+
declare const PreviousBlock_base: (new (value: {
|
|
31
|
+
rootHash: import("o1js/dist/node/lib/field").Field;
|
|
32
|
+
}) => {
|
|
33
|
+
rootHash: import("o1js/dist/node/lib/field").Field;
|
|
34
|
+
}) & {
|
|
35
|
+
_isStruct: true;
|
|
36
|
+
} & import("o1js/dist/node/snarky").ProvablePure<{
|
|
37
|
+
rootHash: import("o1js/dist/node/lib/field").Field;
|
|
38
|
+
}> & {
|
|
39
|
+
toInput: (x: {
|
|
40
|
+
rootHash: import("o1js/dist/node/lib/field").Field;
|
|
41
|
+
}) => {
|
|
42
|
+
fields?: import("o1js/dist/node/lib/field").Field[] | undefined;
|
|
43
|
+
packed?: [import("o1js/dist/node/lib/field").Field, number][] | undefined;
|
|
44
|
+
};
|
|
45
|
+
toJSON: (x: {
|
|
46
|
+
rootHash: import("o1js/dist/node/lib/field").Field;
|
|
47
|
+
}) => {
|
|
48
|
+
rootHash: string;
|
|
49
|
+
};
|
|
50
|
+
fromJSON: (x: {
|
|
51
|
+
rootHash: string;
|
|
52
|
+
}) => {
|
|
53
|
+
rootHash: import("o1js/dist/node/lib/field").Field;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
export declare class PreviousBlock extends PreviousBlock_base {
|
|
57
|
+
}
|
|
30
58
|
declare const NetworkState_base: (new (value: {
|
|
31
59
|
block: CurrentBlock;
|
|
60
|
+
previous: PreviousBlock;
|
|
32
61
|
}) => {
|
|
33
62
|
block: CurrentBlock;
|
|
63
|
+
previous: PreviousBlock;
|
|
34
64
|
}) & {
|
|
35
65
|
_isStruct: true;
|
|
36
66
|
} & import("o1js/dist/node/snarky").ProvablePure<{
|
|
37
67
|
block: CurrentBlock;
|
|
68
|
+
previous: PreviousBlock;
|
|
38
69
|
}> & {
|
|
39
70
|
toInput: (x: {
|
|
40
71
|
block: CurrentBlock;
|
|
72
|
+
previous: PreviousBlock;
|
|
41
73
|
}) => {
|
|
42
74
|
fields?: import("o1js/dist/node/lib/field").Field[] | undefined;
|
|
43
75
|
packed?: [import("o1js/dist/node/lib/field").Field, number][] | undefined;
|
|
44
76
|
};
|
|
45
77
|
toJSON: (x: {
|
|
46
78
|
block: CurrentBlock;
|
|
79
|
+
previous: PreviousBlock;
|
|
47
80
|
}) => {
|
|
48
81
|
block: {
|
|
49
82
|
height: string;
|
|
50
83
|
};
|
|
84
|
+
previous: {
|
|
85
|
+
rootHash: string;
|
|
86
|
+
};
|
|
51
87
|
};
|
|
52
88
|
fromJSON: (x: {
|
|
53
89
|
block: {
|
|
54
90
|
height: string;
|
|
55
91
|
};
|
|
92
|
+
previous: {
|
|
93
|
+
rootHash: string;
|
|
94
|
+
};
|
|
56
95
|
}) => {
|
|
57
96
|
block: CurrentBlock;
|
|
97
|
+
previous: PreviousBlock;
|
|
58
98
|
};
|
|
59
99
|
};
|
|
60
100
|
export declare class NetworkState extends NetworkState_base {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NetworkState.d.ts","sourceRoot":"","sources":["../../../src/model/network/NetworkState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAoB,MAAM,EAAE,MAAM,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"NetworkState.d.ts","sourceRoot":"","sources":["../../../src/model/network/NetworkState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAoB,MAAM,EAAE,MAAM,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGvD,qBAAa,YAAa,SAAQ,iBAEhC;CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEL,qBAAa,aAAc,SAAQ,kBAEjC;CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEL,qBAAa,YAAa,SAAQ,iBAGhC;IACO,IAAI,IAAI,KAAK;WAON,KAAK;CAUpB"}
|
|
@@ -1,19 +1,31 @@
|
|
|
1
|
-
import { Poseidon, Struct, UInt64 } from "o1js";
|
|
1
|
+
import { Field, Poseidon, Struct, UInt64 } from "o1js";
|
|
2
|
+
import { RollupMerkleTree } from "@proto-kit/common";
|
|
2
3
|
export class CurrentBlock extends Struct({
|
|
3
4
|
height: UInt64,
|
|
4
5
|
}) {
|
|
5
6
|
}
|
|
7
|
+
export class PreviousBlock extends Struct({
|
|
8
|
+
rootHash: Field,
|
|
9
|
+
}) {
|
|
10
|
+
}
|
|
6
11
|
export class NetworkState extends Struct({
|
|
7
12
|
block: CurrentBlock,
|
|
13
|
+
previous: PreviousBlock,
|
|
8
14
|
}) {
|
|
9
15
|
hash() {
|
|
10
|
-
return Poseidon.hash(
|
|
16
|
+
return Poseidon.hash([
|
|
17
|
+
...CurrentBlock.toFields(this.block),
|
|
18
|
+
...PreviousBlock.toFields(this.previous),
|
|
19
|
+
]);
|
|
11
20
|
}
|
|
12
21
|
static empty() {
|
|
13
22
|
return new NetworkState({
|
|
14
23
|
block: {
|
|
15
24
|
height: UInt64.zero,
|
|
16
25
|
},
|
|
26
|
+
previous: {
|
|
27
|
+
rootHash: Field(RollupMerkleTree.EMPTY_ROOT)
|
|
28
|
+
}
|
|
17
29
|
});
|
|
18
30
|
}
|
|
19
31
|
}
|
|
@@ -1,53 +1,65 @@
|
|
|
1
|
-
import { Field, PublicKey, UInt64 } from "o1js";
|
|
2
|
-
import {
|
|
1
|
+
import { Bool, Field, Provable, PublicKey, UInt64 } from "o1js";
|
|
2
|
+
import { PublicKeyOption, UInt64Option } from "./ValueOption";
|
|
3
3
|
declare const RuntimeTransaction_base: (new (value: {
|
|
4
4
|
methodId: import("o1js/dist/node/lib/field").Field;
|
|
5
|
-
nonce: UInt64;
|
|
6
|
-
sender: PublicKey;
|
|
7
5
|
argsHash: import("o1js/dist/node/lib/field").Field;
|
|
6
|
+
nonce: UInt64Option;
|
|
7
|
+
sender: PublicKeyOption;
|
|
8
8
|
}) => {
|
|
9
9
|
methodId: import("o1js/dist/node/lib/field").Field;
|
|
10
|
-
nonce: UInt64;
|
|
11
|
-
sender: PublicKey;
|
|
12
10
|
argsHash: import("o1js/dist/node/lib/field").Field;
|
|
11
|
+
nonce: UInt64Option;
|
|
12
|
+
sender: PublicKeyOption;
|
|
13
13
|
}) & {
|
|
14
14
|
_isStruct: true;
|
|
15
|
-
} &
|
|
15
|
+
} & Provable<{
|
|
16
16
|
methodId: import("o1js/dist/node/lib/field").Field;
|
|
17
|
-
nonce: UInt64;
|
|
18
|
-
sender: PublicKey;
|
|
19
17
|
argsHash: import("o1js/dist/node/lib/field").Field;
|
|
18
|
+
nonce: UInt64Option;
|
|
19
|
+
sender: PublicKeyOption;
|
|
20
20
|
}> & {
|
|
21
21
|
toInput: (x: {
|
|
22
22
|
methodId: import("o1js/dist/node/lib/field").Field;
|
|
23
|
-
nonce: UInt64;
|
|
24
|
-
sender: PublicKey;
|
|
25
23
|
argsHash: import("o1js/dist/node/lib/field").Field;
|
|
24
|
+
nonce: UInt64Option;
|
|
25
|
+
sender: PublicKeyOption;
|
|
26
26
|
}) => {
|
|
27
27
|
fields?: import("o1js/dist/node/lib/field").Field[] | undefined;
|
|
28
28
|
packed?: [import("o1js/dist/node/lib/field").Field, number][] | undefined;
|
|
29
29
|
};
|
|
30
30
|
toJSON: (x: {
|
|
31
31
|
methodId: import("o1js/dist/node/lib/field").Field;
|
|
32
|
-
nonce: UInt64;
|
|
33
|
-
sender: PublicKey;
|
|
34
32
|
argsHash: import("o1js/dist/node/lib/field").Field;
|
|
33
|
+
nonce: UInt64Option;
|
|
34
|
+
sender: PublicKeyOption;
|
|
35
35
|
}) => {
|
|
36
36
|
methodId: string;
|
|
37
|
-
nonce: string;
|
|
38
|
-
sender: string;
|
|
39
37
|
argsHash: string;
|
|
38
|
+
nonce: {
|
|
39
|
+
isSome: boolean;
|
|
40
|
+
value: any;
|
|
41
|
+
};
|
|
42
|
+
sender: {
|
|
43
|
+
isSome: boolean;
|
|
44
|
+
value: any;
|
|
45
|
+
};
|
|
40
46
|
};
|
|
41
47
|
fromJSON: (x: {
|
|
42
48
|
methodId: string;
|
|
43
|
-
nonce: string;
|
|
44
|
-
sender: string;
|
|
45
49
|
argsHash: string;
|
|
50
|
+
nonce: {
|
|
51
|
+
isSome: boolean;
|
|
52
|
+
value: any;
|
|
53
|
+
};
|
|
54
|
+
sender: {
|
|
55
|
+
isSome: boolean;
|
|
56
|
+
value: any;
|
|
57
|
+
};
|
|
46
58
|
}) => {
|
|
47
59
|
methodId: import("o1js/dist/node/lib/field").Field;
|
|
48
|
-
nonce: UInt64;
|
|
49
|
-
sender: PublicKey;
|
|
50
60
|
argsHash: import("o1js/dist/node/lib/field").Field;
|
|
61
|
+
nonce: UInt64Option;
|
|
62
|
+
sender: PublicKeyOption;
|
|
51
63
|
};
|
|
52
64
|
};
|
|
53
65
|
/**
|
|
@@ -56,7 +68,20 @@ declare const RuntimeTransaction_base: (new (value: {
|
|
|
56
68
|
* For example, we don't want to expose the signature or args as fields.
|
|
57
69
|
*/
|
|
58
70
|
export declare class RuntimeTransaction extends RuntimeTransaction_base {
|
|
59
|
-
static
|
|
71
|
+
static fromTransaction(input: {
|
|
72
|
+
methodId: Field;
|
|
73
|
+
argsHash: Field;
|
|
74
|
+
nonce: UInt64;
|
|
75
|
+
sender: PublicKey;
|
|
76
|
+
}): RuntimeTransaction;
|
|
77
|
+
static fromMessage({ methodId, argsHash, }: {
|
|
78
|
+
methodId: Field;
|
|
79
|
+
argsHash: Field;
|
|
80
|
+
}): RuntimeTransaction;
|
|
81
|
+
static dummyTransaction(): RuntimeTransaction;
|
|
82
|
+
assertTransactionType(isMessage: Bool): void;
|
|
83
|
+
hashData(): Field[];
|
|
84
|
+
static fromHashData(fields: Field[]): RuntimeTransaction;
|
|
60
85
|
hash(): Field;
|
|
61
86
|
}
|
|
62
87
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RuntimeTransaction.d.ts","sourceRoot":"","sources":["../../../src/model/transaction/RuntimeTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"RuntimeTransaction.d.ts","sourceRoot":"","sources":["../../../src/model/transaction/RuntimeTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,KAAK,EAEL,QAAQ,EACR,SAAS,EAET,MAAM,EACP,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAG9D;;;;GAIG;AACH,qBAAa,kBAAmB,SAAQ,uBAKtC;WACc,eAAe,CAAC,KAAK,EAAE;QACnC,QAAQ,EAAE,KAAK,CAAC;QAChB,QAAQ,EAAE,KAAK,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,SAAS,CAAC;KACnB;WASa,WAAW,CAAC,EACxB,QAAQ,EACR,QAAQ,GACT,EAAE;QACD,QAAQ,EAAE,KAAK,CAAC;QAChB,QAAQ,EAAE,KAAK,CAAC;KACjB;WASa,gBAAgB,IAAI,kBAAkB;IAe7C,qBAAqB,CAAC,SAAS,EAAE,IAAI;IAerC,QAAQ,IAAI,KAAK,EAAE;WASZ,YAAY,CAAC,MAAM,EAAE,KAAK,EAAE;IAiBnC,IAAI,IAAI,KAAK;CAGrB"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { Field, Poseidon, PublicKey, Struct, UInt64 } from "o1js";
|
|
1
|
+
import { Bool, Field, Poseidon, PublicKey, Struct, UInt64, } from "o1js";
|
|
2
|
+
import { PublicKeyOption, UInt64Option } from "./ValueOption";
|
|
3
|
+
import { EMPTY_PUBLICKEY, EMPTY_PUBLICKEY_X } from "@proto-kit/common";
|
|
2
4
|
/**
|
|
3
5
|
* This struct is used to expose transaction information to the runtime method
|
|
4
6
|
* execution. This class has not all data included in transactions on purpose.
|
|
@@ -6,24 +8,79 @@ import { Field, Poseidon, PublicKey, Struct, UInt64 } from "o1js";
|
|
|
6
8
|
*/
|
|
7
9
|
export class RuntimeTransaction extends Struct({
|
|
8
10
|
methodId: Field,
|
|
9
|
-
nonce: UInt64,
|
|
10
|
-
sender: PublicKey,
|
|
11
11
|
argsHash: Field,
|
|
12
|
+
nonce: UInt64Option,
|
|
13
|
+
sender: PublicKeyOption,
|
|
12
14
|
}) {
|
|
13
|
-
static
|
|
15
|
+
static fromTransaction(input) {
|
|
16
|
+
return new RuntimeTransaction({
|
|
17
|
+
methodId: input.methodId,
|
|
18
|
+
argsHash: input.argsHash,
|
|
19
|
+
nonce: UInt64Option.fromValue(input.nonce),
|
|
20
|
+
sender: PublicKeyOption.fromValue(input.sender),
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
static fromMessage({ methodId, argsHash, }) {
|
|
14
24
|
return new RuntimeTransaction({
|
|
15
25
|
methodId,
|
|
16
|
-
nonce,
|
|
17
|
-
sender,
|
|
18
26
|
argsHash,
|
|
27
|
+
nonce: UInt64Option.none(UInt64.zero),
|
|
28
|
+
sender: PublicKeyOption.none(EMPTY_PUBLICKEY),
|
|
19
29
|
});
|
|
20
30
|
}
|
|
21
|
-
|
|
22
|
-
return
|
|
31
|
+
static dummyTransaction() {
|
|
32
|
+
return new RuntimeTransaction({
|
|
33
|
+
methodId: Field(0),
|
|
34
|
+
nonce: new UInt64Option({
|
|
35
|
+
isSome: Bool(true),
|
|
36
|
+
value: UInt64.zero,
|
|
37
|
+
}),
|
|
38
|
+
sender: new PublicKeyOption({
|
|
39
|
+
isSome: Bool(true),
|
|
40
|
+
value: EMPTY_PUBLICKEY,
|
|
41
|
+
}),
|
|
42
|
+
argsHash: Field(0),
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
assertTransactionType(isMessage) {
|
|
46
|
+
const isTransaction = isMessage.not();
|
|
47
|
+
// isSome has to be true when it is a transaction, otherwise false
|
|
48
|
+
this.nonce.isSome
|
|
49
|
+
.equals(isTransaction)
|
|
50
|
+
.assertTrue("Nonce is not right option isSome for type");
|
|
51
|
+
this.sender.isSome
|
|
52
|
+
.equals(isTransaction)
|
|
53
|
+
.assertTrue("Sender is not right option isSome for type");
|
|
54
|
+
this.sender.value.x
|
|
55
|
+
.equals(EMPTY_PUBLICKEY_X)
|
|
56
|
+
.equals(isMessage)
|
|
57
|
+
.assertTrue("Transaction sender is not set to dummy");
|
|
58
|
+
}
|
|
59
|
+
hashData() {
|
|
60
|
+
return [
|
|
23
61
|
this.methodId,
|
|
24
|
-
...this.sender.toFields(),
|
|
25
|
-
...this.nonce.toFields(),
|
|
62
|
+
...this.sender.value.toFields(),
|
|
63
|
+
...this.nonce.value.toFields(),
|
|
26
64
|
this.argsHash,
|
|
27
|
-
]
|
|
65
|
+
];
|
|
66
|
+
}
|
|
67
|
+
static fromHashData(fields) {
|
|
68
|
+
// sender is 2nd and the first element is x (2nd isOdd)
|
|
69
|
+
const isMessage = fields[1].equals(EMPTY_PUBLICKEY_X);
|
|
70
|
+
return new RuntimeTransaction({
|
|
71
|
+
methodId: fields[0],
|
|
72
|
+
sender: new PublicKeyOption({
|
|
73
|
+
isSome: isMessage.not(),
|
|
74
|
+
value: PublicKey.fromFields([fields[1], fields[2]]),
|
|
75
|
+
}),
|
|
76
|
+
nonce: new UInt64Option({
|
|
77
|
+
isSome: isMessage.not(),
|
|
78
|
+
value: UInt64.fromFields([fields[3]]),
|
|
79
|
+
}),
|
|
80
|
+
argsHash: fields[4],
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
hash() {
|
|
84
|
+
return Poseidon.hash(this.hashData());
|
|
28
85
|
}
|
|
29
86
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Bool, Field, Signature, UInt64 } from "o1js";
|
|
2
|
+
import { RuntimeTransaction } from "./RuntimeTransaction";
|
|
3
|
+
declare const SignedTransaction_base: (new (value: {
|
|
4
|
+
transaction: RuntimeTransaction;
|
|
5
|
+
signature: Signature;
|
|
6
|
+
}) => {
|
|
7
|
+
transaction: RuntimeTransaction;
|
|
8
|
+
signature: Signature;
|
|
9
|
+
}) & {
|
|
10
|
+
_isStruct: true;
|
|
11
|
+
} & import("o1js/dist/node/lib/provable").Provable<{
|
|
12
|
+
transaction: RuntimeTransaction;
|
|
13
|
+
signature: Signature;
|
|
14
|
+
}> & {
|
|
15
|
+
toInput: (x: {
|
|
16
|
+
transaction: RuntimeTransaction;
|
|
17
|
+
signature: Signature;
|
|
18
|
+
}) => {
|
|
19
|
+
fields?: import("o1js/dist/node/lib/field").Field[] | undefined;
|
|
20
|
+
packed?: [import("o1js/dist/node/lib/field").Field, number][] | undefined;
|
|
21
|
+
};
|
|
22
|
+
toJSON: (x: {
|
|
23
|
+
transaction: RuntimeTransaction;
|
|
24
|
+
signature: Signature;
|
|
25
|
+
}) => {
|
|
26
|
+
transaction: {
|
|
27
|
+
methodId: string;
|
|
28
|
+
argsHash: string;
|
|
29
|
+
nonce: {
|
|
30
|
+
isSome: boolean;
|
|
31
|
+
value: any;
|
|
32
|
+
};
|
|
33
|
+
sender: {
|
|
34
|
+
isSome: boolean;
|
|
35
|
+
value: any;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
signature: any;
|
|
39
|
+
};
|
|
40
|
+
fromJSON: (x: {
|
|
41
|
+
transaction: {
|
|
42
|
+
methodId: string;
|
|
43
|
+
argsHash: string;
|
|
44
|
+
nonce: {
|
|
45
|
+
isSome: boolean;
|
|
46
|
+
value: any;
|
|
47
|
+
};
|
|
48
|
+
sender: {
|
|
49
|
+
isSome: boolean;
|
|
50
|
+
value: any;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
signature: any;
|
|
54
|
+
}) => {
|
|
55
|
+
transaction: RuntimeTransaction;
|
|
56
|
+
signature: Signature;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
export declare class SignedTransaction extends SignedTransaction_base {
|
|
60
|
+
static getSignatureData(args: {
|
|
61
|
+
methodId: Field;
|
|
62
|
+
nonce: UInt64;
|
|
63
|
+
argsHash: Field;
|
|
64
|
+
}): Field[];
|
|
65
|
+
static dummy(): SignedTransaction;
|
|
66
|
+
hash(): Field;
|
|
67
|
+
getSignatureData(): Field[];
|
|
68
|
+
validateSignature(): Bool;
|
|
69
|
+
}
|
|
70
|
+
export {};
|
|
71
|
+
//# sourceMappingURL=SignedTransaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SignedTransaction.d.ts","sourceRoot":"","sources":["../../../src/model/transaction/SignedTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,KAAK,EAEL,SAAS,EAET,MAAM,EACP,MAAM,MAAM,CAAC;AAEd,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE1D,qBAAa,iBAAkB,SAAQ,sBAGrC;WACc,gBAAgB,CAAC,IAAI,EAAE;QACnC,QAAQ,EAAE,KAAK,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,KAAK,CAAC;KACjB,GAAG,KAAK,EAAE;WAIG,KAAK,IAAI,iBAAiB;IAWjC,IAAI,IAAI,KAAK;IAIb,gBAAgB,IAAI,KAAK,EAAE;IAS3B,iBAAiB,IAAI,IAAI;CAMjC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Field, Scalar, Signature, Struct, } from "o1js";
|
|
2
|
+
import { RuntimeTransaction } from "./RuntimeTransaction";
|
|
3
|
+
export class SignedTransaction extends Struct({
|
|
4
|
+
transaction: RuntimeTransaction,
|
|
5
|
+
signature: Signature,
|
|
6
|
+
}) {
|
|
7
|
+
static getSignatureData(args) {
|
|
8
|
+
return [args.methodId, ...args.nonce.value.toFields(), args.argsHash];
|
|
9
|
+
}
|
|
10
|
+
static dummy() {
|
|
11
|
+
return new SignedTransaction({
|
|
12
|
+
transaction: RuntimeTransaction.dummyTransaction(),
|
|
13
|
+
signature: Signature.fromObject({
|
|
14
|
+
s: Scalar.from(0),
|
|
15
|
+
r: Field(0),
|
|
16
|
+
}),
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
hash() {
|
|
20
|
+
return this.transaction.hash();
|
|
21
|
+
}
|
|
22
|
+
getSignatureData() {
|
|
23
|
+
const { methodId, argsHash, nonce } = this.transaction;
|
|
24
|
+
return SignedTransaction.getSignatureData({
|
|
25
|
+
nonce: nonce.value,
|
|
26
|
+
methodId,
|
|
27
|
+
argsHash,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
validateSignature() {
|
|
31
|
+
return this.signature.verify(this.transaction.sender.value, this.getSignatureData());
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { PublicKey, UInt64 } from "o1js";
|
|
2
|
+
declare const UInt64Option_base: {
|
|
3
|
+
new (value: {
|
|
4
|
+
isSome: import("o1js/dist/node/lib/bool").Bool;
|
|
5
|
+
value: UInt64;
|
|
6
|
+
}): {
|
|
7
|
+
isSome: import("o1js/dist/node/lib/bool").Bool;
|
|
8
|
+
value: UInt64;
|
|
9
|
+
};
|
|
10
|
+
fromValue(value: UInt64): {
|
|
11
|
+
isSome: import("o1js/dist/node/lib/bool").Bool;
|
|
12
|
+
value: UInt64;
|
|
13
|
+
};
|
|
14
|
+
none(value: UInt64): {
|
|
15
|
+
isSome: import("o1js/dist/node/lib/bool").Bool;
|
|
16
|
+
value: UInt64;
|
|
17
|
+
};
|
|
18
|
+
_isStruct: true;
|
|
19
|
+
toFields: (value: {
|
|
20
|
+
isSome: import("o1js/dist/node/lib/bool").Bool;
|
|
21
|
+
value: UInt64;
|
|
22
|
+
}) => import("o1js/dist/node/lib/field").Field[];
|
|
23
|
+
toAuxiliary: (value?: {
|
|
24
|
+
isSome: import("o1js/dist/node/lib/bool").Bool;
|
|
25
|
+
value: UInt64;
|
|
26
|
+
} | undefined) => any[];
|
|
27
|
+
fromFields: (fields: import("o1js/dist/node/lib/field").Field[], aux: any[]) => {
|
|
28
|
+
isSome: import("o1js/dist/node/lib/bool").Bool;
|
|
29
|
+
value: UInt64;
|
|
30
|
+
};
|
|
31
|
+
sizeInFields(): number;
|
|
32
|
+
check: (value: {
|
|
33
|
+
isSome: import("o1js/dist/node/lib/bool").Bool;
|
|
34
|
+
value: UInt64;
|
|
35
|
+
}) => void;
|
|
36
|
+
toInput: (x: {
|
|
37
|
+
isSome: import("o1js/dist/node/lib/bool").Bool;
|
|
38
|
+
value: UInt64;
|
|
39
|
+
}) => {
|
|
40
|
+
fields?: import("o1js/dist/node/lib/field").Field[] | undefined;
|
|
41
|
+
packed?: [import("o1js/dist/node/lib/field").Field, number][] | undefined;
|
|
42
|
+
};
|
|
43
|
+
toJSON: (x: {
|
|
44
|
+
isSome: import("o1js/dist/node/lib/bool").Bool;
|
|
45
|
+
value: UInt64;
|
|
46
|
+
}) => {
|
|
47
|
+
isSome: boolean;
|
|
48
|
+
value: any;
|
|
49
|
+
};
|
|
50
|
+
fromJSON: (x: {
|
|
51
|
+
isSome: boolean;
|
|
52
|
+
value: any;
|
|
53
|
+
}) => {
|
|
54
|
+
isSome: import("o1js/dist/node/lib/bool").Bool;
|
|
55
|
+
value: UInt64;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
export declare class UInt64Option extends UInt64Option_base {
|
|
59
|
+
}
|
|
60
|
+
declare const PublicKeyOption_base: {
|
|
61
|
+
new (value: {
|
|
62
|
+
isSome: import("o1js/dist/node/lib/bool").Bool;
|
|
63
|
+
value: PublicKey;
|
|
64
|
+
}): {
|
|
65
|
+
isSome: import("o1js/dist/node/lib/bool").Bool;
|
|
66
|
+
value: PublicKey;
|
|
67
|
+
};
|
|
68
|
+
fromValue(value: PublicKey): {
|
|
69
|
+
isSome: import("o1js/dist/node/lib/bool").Bool;
|
|
70
|
+
value: PublicKey;
|
|
71
|
+
};
|
|
72
|
+
none(value: PublicKey): {
|
|
73
|
+
isSome: import("o1js/dist/node/lib/bool").Bool;
|
|
74
|
+
value: PublicKey;
|
|
75
|
+
};
|
|
76
|
+
_isStruct: true;
|
|
77
|
+
toFields: (value: {
|
|
78
|
+
isSome: import("o1js/dist/node/lib/bool").Bool;
|
|
79
|
+
value: PublicKey;
|
|
80
|
+
}) => import("o1js/dist/node/lib/field").Field[];
|
|
81
|
+
toAuxiliary: (value?: {
|
|
82
|
+
isSome: import("o1js/dist/node/lib/bool").Bool;
|
|
83
|
+
value: PublicKey;
|
|
84
|
+
} | undefined) => any[];
|
|
85
|
+
fromFields: (fields: import("o1js/dist/node/lib/field").Field[], aux: any[]) => {
|
|
86
|
+
isSome: import("o1js/dist/node/lib/bool").Bool;
|
|
87
|
+
value: PublicKey;
|
|
88
|
+
};
|
|
89
|
+
sizeInFields(): number;
|
|
90
|
+
check: (value: {
|
|
91
|
+
isSome: import("o1js/dist/node/lib/bool").Bool;
|
|
92
|
+
value: PublicKey;
|
|
93
|
+
}) => void;
|
|
94
|
+
toInput: (x: {
|
|
95
|
+
isSome: import("o1js/dist/node/lib/bool").Bool;
|
|
96
|
+
value: PublicKey;
|
|
97
|
+
}) => {
|
|
98
|
+
fields?: import("o1js/dist/node/lib/field").Field[] | undefined;
|
|
99
|
+
packed?: [import("o1js/dist/node/lib/field").Field, number][] | undefined;
|
|
100
|
+
};
|
|
101
|
+
toJSON: (x: {
|
|
102
|
+
isSome: import("o1js/dist/node/lib/bool").Bool;
|
|
103
|
+
value: PublicKey;
|
|
104
|
+
}) => {
|
|
105
|
+
isSome: boolean;
|
|
106
|
+
value: any;
|
|
107
|
+
};
|
|
108
|
+
fromJSON: (x: {
|
|
109
|
+
isSome: boolean;
|
|
110
|
+
value: any;
|
|
111
|
+
}) => {
|
|
112
|
+
isSome: import("o1js/dist/node/lib/bool").Bool;
|
|
113
|
+
value: PublicKey;
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
export declare class PublicKeyOption extends PublicKeyOption_base {
|
|
117
|
+
}
|
|
118
|
+
export {};
|
|
119
|
+
//# sourceMappingURL=ValueOption.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValueOption.d.ts","sourceRoot":"","sources":["../../../src/model/transaction/ValueOption.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,SAAS,EAAU,MAAM,EAAE,MAAM,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBzE,qBAAa,YAAa,SAAQ,iBAAoC;CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEzE,qBAAa,eAAgB,SAAQ,oBAEpC;CAAG"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Bool, PublicKey, Struct, UInt64 } from "o1js";
|
|
2
|
+
function genericOptionFactory(valueType) {
|
|
3
|
+
return class Generic extends Struct({
|
|
4
|
+
isSome: Bool,
|
|
5
|
+
value: valueType,
|
|
6
|
+
}) {
|
|
7
|
+
static fromValue(value) {
|
|
8
|
+
return new Generic({
|
|
9
|
+
isSome: Bool(true),
|
|
10
|
+
value,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
static none(value) {
|
|
14
|
+
return new Generic({
|
|
15
|
+
isSome: Bool(false),
|
|
16
|
+
value,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export class UInt64Option extends genericOptionFactory(UInt64) {
|
|
22
|
+
}
|
|
23
|
+
export class PublicKeyOption extends genericOptionFactory(PublicKey) {
|
|
24
|
+
}
|