-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #164 from palladians/feat/general-types
chore: improve mina-core api and create new pallad-core package
- Loading branch information
Showing
134 changed files
with
1,338 additions
and
371 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Mina } from '@palladxyz/mina-core' | ||
|
||
import { constructTransaction } from './buildMinaTx' | ||
|
||
export type constructTxArgs = { | ||
transaction: Mina.TransactionBody | ||
transactionKind: Mina.TransactionKind | ||
} | ||
|
||
export function constructTx(args: constructTxArgs) { | ||
return constructTransaction(args.transaction, args.transactionKind) | ||
} |
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 +1,2 @@ | ||
export * from './build-tx' | ||
export * from './buildMinaTx' |
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
packages/mina-core/src/Mina/types/Fields.ts → packages/mina-core/src/Mina/Fields.ts
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
2 changes: 1 addition & 1 deletion
2
packages/mina-core/src/Mina/types/Message.ts → packages/mina-core/src/Mina/Message.ts
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
2 changes: 1 addition & 1 deletion
2
packages/mina-core/src/Mina/types/ZkApp.ts → packages/mina-core/src/Mina/ZkApp.ts
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 +1,10 @@ | ||
export * from './types' | ||
export * from './Account' | ||
export * from './Address' | ||
export * from './Block' | ||
export * from './Fields' | ||
export * from './Message' | ||
export * from './Networks' | ||
export * from './Nullifier' | ||
export * from './Pagination' | ||
export * from './Transaction' | ||
export * from './ZkApp' |
This file was deleted.
Oops, something went wrong.
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
File renamed without changes.
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
File renamed without changes.
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,7 +1,7 @@ | ||
export * from './AccountInfoProvider' | ||
export * from './ChainHistoryProvider' | ||
export * from './account-info-provider' | ||
export * from './chain-history-provider' | ||
export * from './daemon-status-provider' | ||
export * from './Provider' | ||
export * from './TxStatusProvider' | ||
export * from './TxSubmitProvider' | ||
export * from './tx-status-provider' | ||
export * from './tx-submit-provider' | ||
export * from './UnifiedProvider' |
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...e/src/Providers/TxSubmitProvider/types.ts → ...src/Providers/tx-submit-provider/types.ts
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,5 +1,5 @@ | ||
export * as Mina from './Mina' | ||
// TODO: Examine why it fails with TS4023 once this line is removed. | ||
export * as BorrowedTypes from './borrowed-types' | ||
export * as Mina from './Mina' | ||
export * from './Providers' | ||
export * from './types' | ||
// TODO: Examine why it fails with TS4023 once this line is removed. | ||
export { TransactionKind } from './Mina/Transaction' |
This file was deleted.
Oops, something went wrong.
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,82 @@ | ||
# @palladxyz/mina-core | ||
|
||
@palladxyz/mina-core is a TypeScript package designed for interacting with the Mina Protocol. It provides interfaces for retrieving account information, processing transaction history, submitting transactions, and provider health checks. The package also includes the core types that represent the main data structures of the Mina Protocol. | ||
|
||
## Installation | ||
|
||
Install the package via npm: | ||
|
||
```bash | ||
npm install @palladxyz/mina-core | ||
``` | ||
|
||
## Usage | ||
|
||
### AccountInfoProvider | ||
|
||
The `AccountInfoProvider` interface is used to fetch account information based on a public key. | ||
|
||
```ts | ||
import { AccountInfoProvider } from '@palladxyz/mina-core' | ||
|
||
async function getAccountInfo(provider: AccountInfoProvider) { | ||
const accountInfo = await provider.getAccountInfo({ publicKey: '...' }) | ||
console.log(accountInfo) | ||
} | ||
``` | ||
|
||
### ChainHistoryProvider | ||
|
||
The `ChainHistoryProvider` interface provides methods to fetch transactions either by addresses or by hashes. | ||
|
||
```ts | ||
import { ChainHistoryProvider } from '@palladxyz/mina-core' | ||
|
||
async function getTransactionsByAddresses(provider: ChainHistoryProvider) { | ||
const transactions = await provider.transactionsByAddresses({ | ||
addresses: ['...'] | ||
}) | ||
console.log(transactions) | ||
} | ||
|
||
async function getTransactionsByHashes(provider: ChainHistoryProvider) { | ||
const transactions = await provider.transactionsByHashes({ ids: ['...'] }) | ||
console.log(transactions) | ||
} | ||
``` | ||
|
||
### TxSubmitProvider | ||
|
||
The `TxSubmitProvider` interface allows you to submit signed transactions to the network. | ||
|
||
```ts | ||
import { TxSubmitProvider } from '@palladxyz/mina-core' | ||
|
||
async function submitTx(provider: TxSubmitProvider) { | ||
const signedTx = // Prepare your signed transaction here | ||
await provider.submitTx({ signedTransaction: signedTx }) | ||
} | ||
``` | ||
|
||
### Provider | ||
|
||
All provider types extend the base Provider interface, which provides a health check method to verify if the provider is operational. | ||
|
||
```ts | ||
import { Provider } from '@palladxyz/mina-core' | ||
|
||
async function checkHealth(provider: Provider) { | ||
const healthCheckResponse = await provider.healthCheck() | ||
console.log( | ||
healthCheckResponse.ok ? 'Provider is healthy' : 'Provider is down' | ||
) | ||
} | ||
``` | ||
|
||
### Mina Core Types | ||
|
||
This package also includes TypeScript definitions for some of the core data structures of the Mina Protocol, which can be found under `./src/Mina/types`. | ||
|
||
### Disclaimer | ||
|
||
This package is still under development. Use it at your own risk and ensure to test thoroughly in your applications. Contributions and suggestions are welcomed! |
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,34 @@ | ||
{ | ||
"name": "@palladxyz/pallad-core", | ||
"version": "0.0.1", | ||
"type": "module", | ||
"description": "Core Pallad Package", | ||
"module": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"exports": { | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/index.js" | ||
} | ||
}, | ||
"scripts": { | ||
"build": "tsup", | ||
"dev": "tsup --watch", | ||
"test:unit": "vitest run", | ||
"cleanup": "rimraf node_modules dist .turbo" | ||
}, | ||
"dependencies": { | ||
"@palladxyz/mina-core": "^0.0.1", | ||
"@palladxyz/key-management": "^0.0.1", | ||
"@palladxyz/util": "^0.0.1", | ||
"bs58check": "^3.0.1", | ||
"buffer": "^6.0.3", | ||
"mina-signer": "^2.1.1", | ||
"viem": "^2.9.16" | ||
}, | ||
"devDependencies": { | ||
"@palladxyz/common": "^1.0.0", | ||
"@types/mocha": "^10.0.6", | ||
"@types/secp256k1": "^4.0.6" | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
packages/pallad-core/src/Mina/Providers/account-info-provider/index.ts
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 @@ | ||
export * from './types' |
Oops, something went wrong.