-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(minajs): improve tx send and add value utils
- Loading branch information
Showing
37 changed files
with
505 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
import { z } from "zod"; | ||
|
||
// Helper schemas | ||
const PublicKey = z.string(); | ||
const Signature = z.string(); | ||
const Field = z.string(); | ||
const TokenId = z.string(); | ||
const UInt32 = z.number().int(); | ||
const UInt64 = z.number().int(); | ||
const BooleanSchema = z.boolean(); | ||
const AuthRequired = z.enum([ | ||
"None", | ||
"Proof", | ||
"Signature", | ||
"Either", | ||
"Impossible", | ||
]); | ||
const Sign = z.enum(["Positive", "Negative"]); | ||
const Memo = z.string(); | ||
const ZkappProof = z.string(); | ||
|
||
// Complex nested schemas | ||
const VerificationKeyWithHashInput = z.object({ | ||
data: z.string(), | ||
hash: Field, | ||
}); | ||
|
||
const PermissionsInput = z.object({ | ||
editState: AuthRequired, | ||
access: AuthRequired, | ||
send: AuthRequired, | ||
receive: AuthRequired, | ||
setDelegate: AuthRequired, | ||
setPermissions: AuthRequired, | ||
setVerificationKey: z.object({ | ||
auth: AuthRequired, | ||
txnVersion: UInt32, | ||
}), | ||
setZkappUri: AuthRequired, | ||
editActionState: AuthRequired, | ||
setTokenSymbol: AuthRequired, | ||
incrementNonce: AuthRequired, | ||
setVotingFor: AuthRequired, | ||
setTiming: AuthRequired, | ||
}); | ||
|
||
const TimingInput = z.object({ | ||
initialMinimumBalance: UInt64, | ||
cliffTime: UInt32, | ||
cliffAmount: UInt64, | ||
vestingPeriod: UInt32, | ||
vestingIncrement: UInt64, | ||
}); | ||
|
||
const AccountUpdateModificationInput = z.object({ | ||
appState: z.array(Field).optional(), | ||
delegate: PublicKey.optional(), | ||
verificationKey: VerificationKeyWithHashInput.optional(), | ||
permissions: PermissionsInput.optional(), | ||
zkappUri: z.string().optional(), | ||
tokenSymbol: z.string().optional(), | ||
timing: TimingInput.optional(), | ||
votingFor: Field.optional(), | ||
}); | ||
|
||
const BalanceChangeInput = z.object({ | ||
magnitude: UInt64, | ||
sgn: Sign, | ||
}); | ||
|
||
const CurrencyAmountIntervalInput = z.object({ | ||
lower: UInt64, | ||
upper: UInt64, | ||
}); | ||
|
||
const LengthIntervalInput = z.object({ | ||
lower: UInt32, | ||
upper: UInt32, | ||
}); | ||
|
||
const GlobalSlotSinceGenesisIntervalInput = z.object({ | ||
lower: UInt32, | ||
upper: UInt32, | ||
}); | ||
|
||
const EpochLedgerPreconditionInput = z.object({ | ||
hash: Field.optional(), | ||
totalCurrency: CurrencyAmountIntervalInput.optional(), | ||
}); | ||
|
||
const EpochDataPreconditionInput = z.object({ | ||
ledger: EpochLedgerPreconditionInput, | ||
seed: Field.optional(), | ||
startCheckpoint: Field.optional(), | ||
lockCheckpoint: Field.optional(), | ||
epochLength: LengthIntervalInput.optional(), | ||
}); | ||
|
||
const NetworkPreconditionInput = z.object({ | ||
snarkedLedgerHash: Field.optional(), | ||
blockchainLength: LengthIntervalInput.optional(), | ||
minWindowDensity: LengthIntervalInput.optional(), | ||
totalCurrency: CurrencyAmountIntervalInput.optional(), | ||
globalSlotSinceGenesis: GlobalSlotSinceGenesisIntervalInput.optional(), | ||
stakingEpochData: EpochDataPreconditionInput, | ||
nextEpochData: EpochDataPreconditionInput, | ||
}); | ||
|
||
const AccountPreconditionInput = z.object({ | ||
balance: CurrencyAmountIntervalInput.optional(), | ||
nonce: LengthIntervalInput.optional(), | ||
receiptChainHash: Field.optional(), | ||
delegate: PublicKey.optional(), | ||
state: z.array(Field), | ||
actionState: Field.optional(), | ||
provedState: BooleanSchema.optional(), | ||
isNew: BooleanSchema.optional(), | ||
}); | ||
|
||
const PreconditionsInput = z.object({ | ||
network: NetworkPreconditionInput, | ||
account: AccountPreconditionInput, | ||
validWhile: GlobalSlotSinceGenesisIntervalInput.optional(), | ||
}); | ||
|
||
const MayUseTokenInput = z.object({ | ||
parentsOwnToken: BooleanSchema, | ||
inheritFromParent: BooleanSchema, | ||
}); | ||
|
||
const AuthorizationKindStructuredInput = z.object({ | ||
isSigned: BooleanSchema, | ||
isProved: BooleanSchema, | ||
verificationKeyHash: Field, | ||
}); | ||
|
||
const AccountUpdateBodyInput = z.object({ | ||
publicKey: PublicKey, | ||
tokenId: TokenId, | ||
update: AccountUpdateModificationInput, | ||
balanceChange: BalanceChangeInput, | ||
incrementNonce: BooleanSchema, | ||
events: z.array(z.array(Field)), | ||
actions: z.array(z.array(Field)), | ||
callData: Field, | ||
callDepth: z.number().int(), | ||
preconditions: PreconditionsInput, | ||
useFullCommitment: BooleanSchema, | ||
implicitAccountCreationFee: BooleanSchema, | ||
mayUseToken: MayUseTokenInput, | ||
authorizationKind: AuthorizationKindStructuredInput, | ||
}); | ||
|
||
const ControlInput = z.object({ | ||
proof: ZkappProof.optional(), | ||
signature: Signature.optional(), | ||
}); | ||
|
||
const ZkappAccountUpdateInput = z.object({ | ||
body: AccountUpdateBodyInput, | ||
authorization: ControlInput, | ||
}); | ||
|
||
const FeePayerBodyInput = z.object({ | ||
publicKey: PublicKey, | ||
fee: UInt64, | ||
validUntil: UInt32.optional(), | ||
nonce: UInt32, | ||
}); | ||
|
||
const ZkappFeePayerInput = z.object({ | ||
body: FeePayerBodyInput, | ||
authorization: Signature, | ||
}); | ||
|
||
const ZkappCommandInput = z.object({ | ||
feePayer: ZkappFeePayerInput, | ||
accountUpdates: z.array(ZkappAccountUpdateInput), | ||
memo: Memo, | ||
}); | ||
|
||
export const SendZkappInput = z.object({ | ||
zkappCommand: ZkappCommandInput, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import sharedConfig from "../shared/tsup.config"; | ||
import sharedConfig from "../utils/tsup.config"; | ||
|
||
export default sharedConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import sharedConfig from "../shared/tsup.config"; | ||
import sharedConfig from "../utils/tsup.config"; | ||
|
||
export default sharedConfig; |
Oops, something went wrong.