-
-
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(connect): add wallet interface docs
- Loading branch information
Showing
14 changed files
with
190 additions
and
112 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
# Wallet Interface [Make your zkApp compatible with Mina wallets.] | ||
|
||
To make your zkApp compatible with Mina wallets, we've created a strongly typed interface for `window.mina` and injected providers found by [Provider Discovery](/connect/provider-discovery). | ||
|
||
## Queries | ||
|
||
### mina_accounts | ||
|
||
```ts twoslash | ||
import { createStore } from '@mina-js/connect' | ||
|
||
const store = createStore() | ||
const { provider } = store.getProviders()[0] | ||
const { result } = await provider.request<'mina_accounts'>({ method: 'mina_accounts' }) | ||
``` | ||
|
||
### mina_chainId | ||
|
||
```ts twoslash | ||
import { createStore } from '@mina-js/connect' | ||
|
||
const store = createStore() | ||
const { provider } = store.getProviders()[0] | ||
const { result } = await provider.request<'mina_chainId'>({ method: 'mina_chainId' }) | ||
``` | ||
|
||
### mina_getBalance | ||
|
||
```ts twoslash | ||
import { createStore } from '@mina-js/connect' | ||
|
||
const store = createStore() | ||
const { provider } = store.getProviders()[0] | ||
const { result } = await provider.request<'mina_getBalance'>({ method: 'mina_getBalance' }) | ||
``` | ||
|
||
### mina_chainInformation | ||
|
||
```ts twoslash | ||
import { createStore } from '@mina-js/connect' | ||
|
||
const store = createStore() | ||
const { provider } = store.getProviders()[0] | ||
const { result } = await provider.request<'mina_chainInformation'>({ method: 'mina_chainInformation' }) | ||
``` | ||
|
||
## Commands | ||
|
||
### mina_sign | ||
|
||
```ts twoslash | ||
import { createStore } from '@mina-js/connect' | ||
|
||
const store = createStore() | ||
const { provider } = store.getProviders()[0] | ||
const { result } = await provider.request<'mina_sign'>({ method: 'mina_sign', params: ['My message'] }) | ||
``` | ||
|
||
### mina_signTransaction | ||
|
||
```ts twoslash | ||
import { createStore } from '@mina-js/connect' | ||
|
||
const store = createStore() | ||
const { provider } = store.getProviders()[0] | ||
const { result } = await provider.request<'mina_signTransaction'>({ | ||
method: 'mina_signTransaction', | ||
params: [{ | ||
// You should probably get the right nonce from Klesia for that. | ||
nonce: 1n, | ||
from: "B62qmWKtvNQTtUqo1LxfEEDLyWMg59cp6U7c4uDC7aqgaCEijSc3Hx5", | ||
to: "B62qmWKtvNQTtUqo1LxfEEDLyWMg59cp6U7c4uDC7aqgaCEijSc3Hx5", | ||
amount: 3000000000n, | ||
fee: 100000000n, | ||
}] | ||
}) | ||
``` | ||
|
||
### mina_signFields | ||
|
||
```ts twoslash | ||
import { createStore } from '@mina-js/connect' | ||
|
||
const store = createStore() | ||
const { provider } = store.getProviders()[0] | ||
const { result } = await provider.request<'mina_signFields'>({ | ||
method: 'mina_signFields', | ||
params: [[1n, 2n, 3n]] | ||
}) | ||
``` | ||
|
||
### mina_createNullifier | ||
|
||
```ts twoslash | ||
import { createStore } from '@mina-js/connect' | ||
|
||
const store = createStore() | ||
const { provider } = store.getProviders()[0] | ||
const { result } = await provider.request<'mina_createNullifier'>({ | ||
method: 'mina_createNullifier', | ||
params: [[1n, 2n, 3n]] | ||
}) | ||
``` |
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,26 @@ | ||
import { FieldSchema, TransactionPayload } from "@mina-js/shared"; | ||
import { z } from "zod"; | ||
|
||
export const SignFieldsParamsSchema = z | ||
.object({ | ||
fields: z.array(FieldSchema), | ||
}) | ||
.strict(); | ||
|
||
export const SignMessageParamsSchema = z | ||
.object({ | ||
message: z.string(), | ||
}) | ||
.strict(); | ||
|
||
export const CreateNullifierParamsSchema = z | ||
.object({ | ||
message: z.array(FieldSchema), | ||
}) | ||
.strict(); | ||
|
||
export const SignTransactionParamsSchema = z | ||
.object({ | ||
transaction: TransactionPayload, | ||
}) | ||
.strict(); |
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
Oops, something went wrong.