genlayer-js 0.8.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/chains/index.cjs +2 -2
  3. package/dist/chains/index.d.cts +2 -2
  4. package/dist/chains/index.d.ts +2 -2
  5. package/dist/chains/index.js +3 -3
  6. package/dist/chains-BYSCF33g.d.cts +18 -0
  7. package/dist/chains-BYSCF33g.d.ts +18 -0
  8. package/dist/chunk-7YZQQWJZ.js +4056 -0
  9. package/dist/chunk-AZSICIZ3.cjs +132 -0
  10. package/dist/chunk-FPFZLPXI.cjs +4056 -0
  11. package/dist/chunk-RS7NCSOQ.js +132 -0
  12. package/dist/index-BM9hOtGg.d.cts +13 -0
  13. package/dist/index-C7Colsnk.d.ts +13 -0
  14. package/dist/index-DvSbRKD5.d.ts +370 -0
  15. package/dist/index-kDM_9wW1.d.cts +370 -0
  16. package/dist/index.cjs +393 -134
  17. package/dist/index.d.cts +6 -6
  18. package/dist/index.d.ts +6 -6
  19. package/dist/index.js +385 -126
  20. package/dist/types/index.cjs +18 -2
  21. package/dist/types/index.d.cts +3 -3
  22. package/dist/types/index.d.ts +3 -3
  23. package/dist/types/index.js +19 -3
  24. package/package.json +2 -2
  25. package/src/accounts/IAccountActions.ts +2 -2
  26. package/src/accounts/actions.ts +10 -4
  27. package/src/chains/actions.ts +5 -5
  28. package/src/chains/index.ts +1 -1
  29. package/src/chains/localnet.ts +4 -3
  30. package/src/chains/testnet.ts +4015 -0
  31. package/src/client/client.ts +64 -21
  32. package/src/contracts/actions.ts +185 -137
  33. package/src/transactions/actions.ts +173 -8
  34. package/src/types/accounts.ts +1 -2
  35. package/src/types/chains.ts +8 -2
  36. package/src/types/clients.ts +14 -13
  37. package/src/types/transactions.ts +250 -8
  38. package/src/utils/jsonifier.ts +47 -0
  39. package/src/wallet/actions.ts +4 -4
  40. package/src/wallet/connect.ts +12 -14
  41. package/tests/client.test.ts +105 -45
  42. package/dist/chains-C5PI_Nr_.d.cts +0 -13
  43. package/dist/chains-C5PI_Nr_.d.ts +0 -13
  44. package/dist/chunk-I6HC44KD.cjs +0 -72
  45. package/dist/chunk-K72OSU5N.js +0 -28
  46. package/dist/chunk-WEXFFND6.js +0 -72
  47. package/dist/chunk-YDFRDDP5.cjs +0 -28
  48. package/dist/index-B8E0qiOq.d.cts +0 -13
  49. package/dist/index-BfeTR7rO.d.cts +0 -187
  50. package/dist/index-CODAJePj.d.ts +0 -187
  51. package/dist/index-ZoW0HQ_m.d.ts +0 -13
  52. package/src/chains/simulator.ts +0 -30
@@ -1,3 +1,3 @@
1
- export { A as Address, a as CalldataAddress, C as CalldataEncodable, f as ContractMethod, e as ContractMethodBase, c as ContractParamsArraySchemaElement, d as ContractParamsSchema, g as ContractSchema, G as GenLayerClient, b as GenLayerMethod, j as GenLayerTransaction, M as MethodDescription, N as Network, S as SnapSource, k as TransactionDataElement, h as TransactionHash, i as TransactionStatus } from '../index-CODAJePj.js';
2
- export { S as SimulatorChain } from '../chains-C5PI_Nr_.js';
3
- export { Account } from 'viem';
1
+ export { Account, Address } from 'viem';
2
+ export { a as CalldataAddress, C as CalldataEncodable, f as ContractMethod, e as ContractMethodBase, c as ContractParamsArraySchemaElement, d as ContractParamsSchema, g as ContractSchema, p as DecodedCallData, D as DecodedDeployData, G as GenLayerClient, b as GenLayerMethod, r as GenLayerRawTransaction, q as GenLayerTransaction, H as Hash, M as MethodDescription, N as Network, S as SnapSource, h as TransactionHash, j as TransactionResult, m as TransactionResultNameToNumber, i as TransactionStatus, o as TransactionType, V as VoteType, l as transactionResultNumberToName, k as transactionsStatusNameToNumber, t as transactionsStatusNumberToName, n as voteTypeNameToNumber, v as voteTypeNumberToName } from '../index-DvSbRKD5.js';
3
+ export { G as GenLayerChain } from '../chains-BYSCF33g.js';
@@ -1,9 +1,25 @@
1
1
  import {
2
2
  CalldataAddress,
3
- TransactionStatus
4
- } from "../chunk-K72OSU5N.js";
3
+ TransactionResult,
4
+ TransactionResultNameToNumber,
5
+ TransactionStatus,
6
+ VoteType,
7
+ transactionResultNumberToName,
8
+ transactionsStatusNameToNumber,
9
+ transactionsStatusNumberToName,
10
+ voteTypeNameToNumber,
11
+ voteTypeNumberToName
12
+ } from "../chunk-RS7NCSOQ.js";
5
13
  import "../chunk-MLKGABMK.js";
6
14
  export {
7
15
  CalldataAddress,
8
- TransactionStatus
16
+ TransactionResult,
17
+ TransactionResultNameToNumber,
18
+ TransactionStatus,
19
+ VoteType,
20
+ transactionResultNumberToName,
21
+ transactionsStatusNameToNumber,
22
+ transactionsStatusNumberToName,
23
+ voteTypeNameToNumber,
24
+ voteTypeNumberToName
9
25
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "genlayer-js",
3
3
  "type": "module",
4
- "version": "0.8.0",
4
+ "version": "0.9.1",
5
5
  "description": "GenLayer JavaScript SDK",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -50,6 +50,6 @@
50
50
  "dependencies": {
51
51
  "eslint-plugin-import": "^2.30.0",
52
52
  "typescript-parsec": "^0.3.4",
53
- "viem": "^2.21.7"
53
+ "viem": "^2.29.0"
54
54
  }
55
55
  }
@@ -1,5 +1,5 @@
1
- import {TransactionHash} from "@/types";
1
+ import {Address, TransactionHash} from "@/types";
2
2
 
3
3
  export type IAccountActions = {
4
- fundAccount: ({address, amount}: {address: string; amount: number}) => Promise<TransactionHash>;
4
+ fundAccount: ({address, amount}: {address: Address; amount: number}) => Promise<TransactionHash>;
5
5
  };
@@ -1,9 +1,9 @@
1
- import {GenLayerClient, TransactionHash, SimulatorChain} from "../types";
1
+ import {GenLayerClient, TransactionHash, GenLayerChain, Address} from "../types";
2
2
  import {localnet} from "../chains";
3
3
 
4
- export function accountActions(client: GenLayerClient<SimulatorChain>) {
4
+ export function accountActions(client: GenLayerClient<GenLayerChain>) {
5
5
  return {
6
- fundAccount: async ({address, amount}: {address: string; amount: number}): Promise<TransactionHash> => {
6
+ fundAccount: async ({address, amount}: {address: Address; amount: number}): Promise<TransactionHash> => {
7
7
  if (client.chain?.id !== localnet.id) {
8
8
  throw new Error("Client is not connected to the localnet");
9
9
  }
@@ -13,7 +13,13 @@ export function accountActions(client: GenLayerClient<SimulatorChain>) {
13
13
  params: [address, amount],
14
14
  }) as Promise<TransactionHash>;
15
15
  },
16
- getCurrentNonce: async ({address, block = 'latest'}: {address: string, block?: string}): Promise<number> => {
16
+ getCurrentNonce: async ({
17
+ address,
18
+ block = "latest",
19
+ }: {
20
+ address: Address;
21
+ block?: string;
22
+ }): Promise<number> => {
17
23
  const addressToUse = address || client.account?.address;
18
24
 
19
25
  if (!addressToUse) {
@@ -1,11 +1,11 @@
1
- import {GenLayerClient, SimulatorChain} from "@/types";
2
- import {simulator} from "@/chains";
1
+ import {GenLayerClient, GenLayerChain} from "@/types";
2
+ import {testnet} from "./testnet";
3
3
 
4
- export function chainActions(client: GenLayerClient<SimulatorChain>) {
4
+ export function chainActions(client: GenLayerClient<GenLayerChain>) {
5
5
  return {
6
6
  initializeConsensusSmartContract: async (forceReset: boolean = false): Promise<void> => {
7
- if (client.chain?.id !== simulator.id) {
8
- throw new Error("Client is not connected to the simulator");
7
+ if (client.chain?.id !== testnet.id) {
8
+ return;
9
9
  }
10
10
 
11
11
  if (
@@ -1,3 +1,3 @@
1
1
  // src/chains/index.ts
2
2
  export {localnet} from "./localnet";
3
- export {simulator} from "./simulator";
3
+ export {testnet} from "./testnet";
@@ -1,10 +1,10 @@
1
1
  import {defineChain} from "viem";
2
- import {SimulatorChain} from "@/types";
2
+ import {GenLayerChain} from "@/types";
3
3
 
4
4
  // chains/localnet.ts
5
5
  const SIMULATOR_JSON_RPC_URL = "http://127.0.0.1:4000/api";
6
6
 
7
- export const localnet: SimulatorChain = defineChain({
7
+ export const localnet: GenLayerChain = defineChain({
8
8
  id: 61_999,
9
9
  name: "Genlayer Localnet",
10
10
  rpcUrls: {
@@ -25,6 +25,7 @@ export const localnet: SimulatorChain = defineChain({
25
25
  },
26
26
  testnet: true,
27
27
  consensusMainContract: null,
28
+ consensusDataContract: null,
28
29
  defaultNumberOfInitialValidators: 5,
29
30
  defaultConsensusMaxRotations: 3,
30
- });
31
+ });