Skip to content

Commit 5842fa3

Browse files
committed
chore(web connector): rename network getter methods
1 parent fdb1786 commit 5842fa3

File tree

13 files changed

+58
-60
lines changed

13 files changed

+58
-60
lines changed

apps/docs/src/components/test-zkapp.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const TestZkApp = () => {
2121
});
2222
const [results, setResults] = useObjectState({
2323
mina_accounts: "",
24-
mina_chainId: "",
24+
mina_networkId: "",
2525
mina_getBalance: "",
2626
mina_sign: "",
2727
mina_signFields: "",
@@ -45,12 +45,12 @@ export const TestZkApp = () => {
4545
});
4646
setResults(() => ({ mina_accounts: JSON.stringify(result) }));
4747
};
48-
const fetchChainId = async () => {
48+
const fetchNetworkId = async () => {
4949
if (!provider) return;
5050
const { result } = await provider.request({
51-
method: "mina_chainId",
51+
method: "mina_networkId",
5252
});
53-
setResults(() => ({ mina_chainId: result }));
53+
setResults(() => ({ mina_networkId: result }));
5454
};
5555
const fetchBalance = async () => {
5656
if (!provider) return;
@@ -201,18 +201,18 @@ export const TestZkApp = () => {
201201
Request Accounts
202202
</button>
203203
</div>
204-
<label>mina_chainId</label>
204+
<label>mina_networkId</label>
205205
<div className="flex justify-between items-center gap-4">
206206
<input
207-
value={results.mina_chainId}
207+
value={results.mina_networkId}
208208
className="input input-bordered flex-1"
209209
/>
210210
<button
211211
type="button"
212212
className="btn btn-primary"
213-
onClick={fetchChainId}
213+
onClick={fetchNetworkId}
214214
>
215-
Get Chain ID
215+
Get Network ID
216216
</button>
217217
</div>
218218
<label>mina_getBalance</label>

apps/docs/src/pages/connect/wallet-client.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ const client = createWalletClient({ account, network: "devnet" });
110110
const transactionCount = await client.getTransactionCount();
111111
```
112112

113-
### Get chain ID
113+
### Get network ID
114114

115-
Query the chain ID of the network.
115+
Query the network ID of the network.
116116

117117
```ts twoslash
118118
import { toAccount } from "@mina-js/accounts";
@@ -121,7 +121,7 @@ import { createWalletClient } from '@mina-js/connect'
121121
const account = toAccount('B62qmWKtvNQTtUqo1LxfEEDLyWMg59cp6U7c4uDC7aqgaCEijSc3Hx5');
122122
const client = createWalletClient({ account, network: "devnet" });
123123

124-
const chainId = await client.getChainId();
124+
const networkId = await client.getNetworkId();
125125
```
126126

127127
## Wallet commands

apps/docs/src/pages/connect/wallet-interface.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ const { provider } = store.getProviders()[0]
2828
const { result } = await provider.request<'mina_requestAccounts'>({ method: 'mina_requestAccounts' })
2929
```
3030

31-
### mina_chainId
31+
### mina_networkId
3232

33-
Get the chain ID. It's a string that represents the current network. Values are `mina:mainnet` or `mina:testnet`.
33+
Get the network ID. It's a string that represents the current network. Values are `mina:mainnet` or `mina:testnet`.
3434

3535
```ts twoslash
3636
import { createStore } from '@mina-js/connect'
3737

3838
const store = createStore()
3939
const { provider } = store.getProviders()[0]
40-
const { result } = await provider.request<'mina_chainId'>({ method: 'mina_chainId' })
40+
const { result } = await provider.request<'mina_networkId'>({ method: 'mina_networkId' })
4141
```
4242

4343
### mina_getBalance
@@ -52,16 +52,16 @@ const { provider } = store.getProviders()[0]
5252
const { result } = await provider.request<'mina_getBalance'>({ method: 'mina_getBalance' })
5353
```
5454

55-
### mina_chainInformation
55+
### mina_requestNetwork
5656

57-
Get chain information. Similar to `mina_chainId`, but more detailed. It returns current network's RPC url, name, and slug (chain ID).
57+
Get network information. Similar to `mina_networkId`, but more detailed. It returns current network's RPC url, name, and slug (network ID).
5858

5959
```ts twoslash
6060
import { createStore } from '@mina-js/connect'
6161

6262
const store = createStore()
6363
const { provider } = store.getProviders()[0]
64-
const { result } = await provider.request<'mina_chainInformation'>({ method: 'mina_chainInformation' })
64+
const { result } = await provider.request<'mina_requestNetwork'>({ method: 'mina_requestNetwork' })
6565
```
6666

6767
### mina_getState

apps/docs/src/pages/klesia/rpc.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ Not supported on Zeko.
6262

6363
---
6464

65-
### mina_chainId
65+
### mina_networkId
6666

67-
Returns the currently configured chain ID.
67+
Returns the currently configured network ID.
6868

6969
---
7070

apps/klesia/src/index.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ describe("Mina Devnet RPC", () => {
3535
expect(result.length).toBeGreaterThan(0);
3636
});
3737

38-
it("returns result for mina_chainId", async () => {
38+
it("returns result for mina_networkId", async () => {
3939
const response = await request({
40-
json: { method: "mina_chainId" },
40+
json: { method: "mina_networkId" },
4141
});
4242
const { result } = (await response.json()) as { result: string };
4343
expect(result.length).toBeGreaterThan(0);

apps/klesia/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ export const klesiaRpcRoute = api.openapi(rpcRoute, async ({ req, json }) => {
103103
const result = await mina.blockHash();
104104
return json(buildResponse({ result }), 200);
105105
})
106-
.with({ method: KlesiaRpcMethod.enum.mina_chainId }, async () => {
107-
const result = await mina.chainId();
106+
.with({ method: KlesiaRpcMethod.enum.mina_networkId }, async () => {
107+
const result = await mina.networkId();
108108
return json(buildResponse({ result }), 200);
109109
})
110110
.with(

apps/klesia/src/methods/mina.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ it("should return block hash", async () => {
1818
expect(result.length).toBeGreaterThan(0);
1919
});
2020

21-
it("should return chain id", async () => {
22-
const result = await mina.chainId();
21+
it("should return network id", async () => {
22+
const result = await mina.networkId();
2323
expect(result.length).toBeGreaterThan(0);
2424
});
2525

apps/klesia/src/methods/mina.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,17 @@ const blockHash = async () => {
6868
return data.daemonStatus.stateHash;
6969
};
7070

71-
const chainId = async () => {
71+
const networkId = async () => {
7272
const client = getNodeClient();
7373
const { data } = await client.query(
7474
gql`
7575
query {
76-
daemonStatus {
77-
chainId
78-
}
76+
networkID
7977
}
8078
`,
8179
{},
8280
);
83-
return data.daemonStatus.chainId;
81+
return data.networkID;
8482
};
8583

8684
const sendTransaction = async ({
@@ -177,7 +175,7 @@ export const mina = {
177175
getTransactionCount,
178176
getBalance,
179177
blockHash,
180-
chainId,
178+
networkId,
181179
sendTransaction,
182180
getAccount,
183181
};

packages/connect/src/__snapshots__/client.spec.ts.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ exports[`matches snapshot of local source 1`] = `
55
"createNullifier": [Function: AsyncFunction],
66
"getAccounts": [Function: AsyncFunction],
77
"getBalance": [Function: AsyncFunction],
8-
"getChainId": [Function: AsyncFunction],
8+
"getNetworkId": [Function: AsyncFunction],
99
"getTransactionCount": [Function: AsyncFunction],
1010
"prepareTransactionRequest": [Function: AsyncFunction],
1111
"signFields": [Function: AsyncFunction],
@@ -19,7 +19,7 @@ exports[`matches snapshot of json-rpc source 1`] = `
1919
"createNullifier": [Function: AsyncFunction],
2020
"getAccounts": [Function: AsyncFunction],
2121
"getBalance": [Function: AsyncFunction],
22-
"getChainId": [Function: AsyncFunction],
22+
"getNetworkId": [Function: AsyncFunction],
2323
"getTransactionCount": [Function: AsyncFunction],
2424
"prepareTransactionRequest": [Function: AsyncFunction],
2525
"signFields": [Function: AsyncFunction],
@@ -33,7 +33,7 @@ exports[`matches snapshot of local source 2`] = `
3333
"createNullifier": [Function: AsyncFunction],
3434
"getAccounts": [Function: AsyncFunction],
3535
"getBalance": [Function: AsyncFunction],
36-
"getChainId": [Function: AsyncFunction],
36+
"getNetworkId": [Function: AsyncFunction],
3737
"getTransactionCount": [Function: AsyncFunction],
3838
"prepareTransactionRequest": [Function: AsyncFunction],
3939
"signFields": [Function: AsyncFunction],
@@ -47,7 +47,7 @@ exports[`matches snapshot of json-rpc source 2`] = `
4747
"createNullifier": [Function: AsyncFunction],
4848
"getAccounts": [Function: AsyncFunction],
4949
"getBalance": [Function: AsyncFunction],
50-
"getChainId": [Function: AsyncFunction],
50+
"getNetworkId": [Function: AsyncFunction],
5151
"getTransactionCount": [Function: AsyncFunction],
5252
"prepareTransactionRequest": [Function: AsyncFunction],
5353
"signFields": [Function: AsyncFunction],

packages/connect/src/client.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ describe("json-rpc source", () => {
5353
expect(BigInt(transactionCount)).toBeGreaterThanOrEqual(0);
5454
});
5555

56-
it("returns chain id", async () => {
56+
it("returns network id", async () => {
5757
const account = toAccount(PUBLIC_KEY);
5858
const client = createWalletClient({
5959
account,
6060
network: "devnet",
6161
providerSource: "klesia",
6262
});
63-
const chainId = await client.getChainId();
64-
expect(chainId.length).toBeGreaterThan(0);
63+
const networkId = await client.getNetworkId();
64+
expect(networkId.length).toBeGreaterThan(0);
6565
});
6666
});
6767

0 commit comments

Comments
 (0)