diff --git a/lib/from-layout.ts b/lib/from-layout.ts index 14327c57..40eee41b 100644 --- a/lib/from-layout.ts +++ b/lib/from-layout.ts @@ -21,6 +21,7 @@ type GenericTypeMap< PublicKey, AuthRequired, TokenId + // MayUseToken > = { Field: Field; Bool: Bool; @@ -30,6 +31,7 @@ type GenericTypeMap< PublicKey: PublicKey; AuthRequired: AuthRequired; TokenId: TokenId; + // MayUseToken: MayUseToken; }; type AnyTypeMap = GenericTypeMap; diff --git a/mina-transaction/derived-leaves.ts b/mina-transaction/derived-leaves.ts index 2de1b693..e39e4e27 100644 --- a/mina-transaction/derived-leaves.ts +++ b/mina-transaction/derived-leaves.ts @@ -57,6 +57,13 @@ function derivedLeafTypes({ }), Bool ), + MayUseToken: createMayUseToken( + provable({ + parentsOwnToken: Bool, + inheritFromParent: Bool, + }), + Bool + ), ZkappUri: createZkappUri(Field, HashHelpers, packToFields), }; } @@ -95,6 +102,13 @@ function derivedLeafTypesSignable({ }), Bool ), + MayUseToken: createMayUseToken( + signable({ + parentsOwnToken: Bool, + inheritFromParent: Bool, + }), + Bool + ), ZkappUri: createZkappUri(Field, HashHelpers, packToFields), }; } @@ -234,3 +248,36 @@ function createZkappUri( Field, }); } + +type MayUseToken = { + parentsOwnToken: Bool; + inheritFromParent: Bool; +}; + +function createMayUseToken< + Field, + Bool, + Base extends GenericSignable, MayUseToken, Field> +>(base: Base, Bool: GenericSignableBool) { + return { + ...(base as Omit), + empty(): MayUseToken { + return { + parentsOwnToken: Bool(false), + inheritFromParent: Bool(false), + }; + }, + toJSON(x: MayUseToken): Json.MayUseToken { + return { + parentsOwnToken: Bool.toJSON(x.parentsOwnToken), + inheritFromParent: Bool.toJSON(x.inheritFromParent), + }; + }, + fromJSON(json: Json.MayUseToken): MayUseToken { + return { + parentsOwnToken: Bool.fromJSON(json.parentsOwnToken), + inheritFromParent: Bool.fromJSON(json.inheritFromParent), + }; + }, + }; +} diff --git a/mina-transaction/transaction-leaves-bigint.ts b/mina-transaction/transaction-leaves-bigint.ts index 88aa1c3b..3e363817 100644 --- a/mina-transaction/transaction-leaves-bigint.ts +++ b/mina-transaction/transaction-leaves-bigint.ts @@ -15,7 +15,17 @@ import { } from '../../mina-signer/src/poseidon-bigint.js'; import { mocks, protocolVersions } from '../crypto/constants.js'; -export { PublicKey, Field, Bool, AuthRequired, UInt64, UInt32, Sign, TokenId }; +export { + PublicKey, + Field, + Bool, + AuthRequired, + UInt64, + UInt32, + Sign, + TokenId, + MayUseToken, +}; export { Events, @@ -34,12 +44,16 @@ type AuthRequired = { signatureNecessary: Bool; signatureSufficient: Bool; }; +type MayUseToken = { + parentsOwnToken: Bool; + inheritFromParent: Bool; +}; type TokenId = Field; type StateHash = Field; type TokenSymbol = { symbol: string; field: Field }; type ZkappUri = { data: string; hash: Field }; -const { TokenId, StateHash, TokenSymbol, AuthRequired, ZkappUri } = +const { TokenId, StateHash, TokenSymbol, AuthRequired, ZkappUri, MayUseToken } = derivedLeafTypesSignable({ Field, Bool, HashHelpers, packToFields }); type Event = Field[]; diff --git a/mina-transaction/transaction-leaves-json.ts b/mina-transaction/transaction-leaves-json.ts index 0a85971c..328f94fb 100644 --- a/mina-transaction/transaction-leaves-json.ts +++ b/mina-transaction/transaction-leaves-json.ts @@ -1,4 +1,14 @@ -export { PublicKey, Field, Bool, AuthRequired, UInt64, UInt32, Sign, TokenId }; +export { + PublicKey, + Field, + Bool, + AuthRequired, + UInt64, + UInt32, + Sign, + TokenId, + MayUseToken, +}; type Field = string; type Bool = boolean; @@ -8,3 +18,7 @@ type PublicKey = string; type Sign = 'Positive' | 'Negative'; type AuthRequired = 'Signature' | 'Proof' | 'Either' | 'None' | 'Impossible'; type TokenId = Field; +type MayUseToken = { + parentsOwnToken: Bool; + inheritFromParent: Bool; +}; diff --git a/mina-transaction/transaction-leaves.ts b/mina-transaction/transaction-leaves.ts index 004cd9c9..fc429373 100644 --- a/mina-transaction/transaction-leaves.ts +++ b/mina-transaction/transaction-leaves.ts @@ -12,7 +12,17 @@ import { import { provable } from '../../lib/provable/types/provable-derivers.js'; import { mocks, protocolVersions } from '../crypto/constants.js'; -export { PublicKey, Field, Bool, AuthRequired, UInt64, UInt32, Sign, TokenId }; +export { + PublicKey, + Field, + Bool, + AuthRequired, + UInt64, + UInt32, + Sign, + TokenId, + MayUseToken, +}; export { Events, @@ -31,12 +41,16 @@ type AuthRequired = { signatureNecessary: Bool; signatureSufficient: Bool; }; +type MayUseToken = { + parentsOwnToken: Bool; + inheritFromParent: Bool; +}; type TokenId = Field; type StateHash = Field; type TokenSymbol = { symbol: string; field: Field }; type ZkappUri = { data: string; hash: Field }; -const { TokenId, StateHash, TokenSymbol, AuthRequired, ZkappUri } = +const { TokenId, StateHash, TokenSymbol, AuthRequired, ZkappUri, MayUseToken } = derivedLeafTypes({ Field, Bool, HashHelpers, packToFields }); type Event = Field[]; diff --git a/scripts/build-o1js-node-artifacts.sh b/scripts/build-o1js-node-artifacts.sh index c8dec2fe..0e5dc474 100755 --- a/scripts/build-o1js-node-artifacts.sh +++ b/scripts/build-o1js-node-artifacts.sh @@ -9,7 +9,7 @@ KIMCHI_BINDINGS="$MINA_PATH/src/lib/crypto/kimchi_bindings" [ -d node_modules ] || npm i -export DUNE_USE_DEFAULT_LINKER="y" +# export DUNE_USE_DEFAULT_LINKER="y" if [ -f "$BUILD_PATH/o1js_node.bc.js" ]; then echo "found o1js_node.bc.js"