genlayer-js 0.3.3 → 0.4.0
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.
- package/{.eslintrc.js → .eslintrc.cjs} +1 -0
- package/.github/workflows/test.yml +33 -0
- package/CHANGELOG.md +14 -0
- package/dist/chains/index.cjs +2 -2
- package/dist/chains/index.d.cts +2 -2
- package/dist/chains/index.d.ts +2 -2
- package/dist/chains/index.js +1 -1
- package/dist/{chains-CtZJFz4Q.d.cts → chains-BV4Glo-M.d.cts} +1 -2
- package/dist/{chains-CtZJFz4Q.d.ts → chains-BV4Glo-M.d.ts} +1 -2
- package/dist/{chunk-D7VZGQ4K.js → chunk-3TYB36DW.js} +1 -1
- package/dist/{chunk-BAGFDCQE.cjs → chunk-IINRDYKF.cjs} +1 -1
- package/dist/{index-vHLY9ggt.d.ts → index-B5TpaPQ6.d.ts} +1 -1
- package/dist/{index-DLN-2YXE.d.cts → index-SfwloK-R.d.cts} +1 -1
- package/dist/index.cjs +6 -6
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/types/index.d.cts +117 -3
- package/dist/types/index.d.ts +117 -3
- package/package.json +3 -3
- package/src/abi/calldata/encoder.ts +1 -1
- package/src/abi/index.ts +0 -1
- package/src/accounts/IAccountActions.ts +1 -6
- package/src/accounts/actions.ts +1 -6
- package/src/chains/simulator.ts +1 -1
- package/src/transactions/ITransactionActions.ts +1 -6
- package/src/types/chains.ts +1 -1
- package/src/types/clients.ts +4 -0
- package/tests/client.test-d.ts +39 -0
- package/tests/client.test.ts +68 -0
- package/vitest.config.ts +7 -1
- package/dist/clients-ByaMqS8n.d.ts +0 -113
- package/dist/clients-DiSeCTYZ.d.cts +0 -113
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
name: Run Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
pull_request:
|
|
8
|
+
branches:
|
|
9
|
+
- main
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
test:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
|
|
15
|
+
steps:
|
|
16
|
+
- name: Checkout code
|
|
17
|
+
uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- name: Setup Node.js
|
|
20
|
+
uses: actions/setup-node@v4
|
|
21
|
+
with:
|
|
22
|
+
node-version: 22
|
|
23
|
+
cache: npm
|
|
24
|
+
|
|
25
|
+
- name: Install dependencies
|
|
26
|
+
run: npm ci
|
|
27
|
+
|
|
28
|
+
- name: Run tests
|
|
29
|
+
run: npm test
|
|
30
|
+
timeout-minutes: 5
|
|
31
|
+
|
|
32
|
+
- name: Run linting
|
|
33
|
+
run: npm run lint
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
+
## 0.4.0 (2024-11-14)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add contract schema methods ([#26](https://github.com/yeagerai/genlayer-js/issues/26)) ([7dc726f](https://github.com/yeagerai/genlayer-js/commit/7dc726fa4fc8769feaec07a50149956d7c2a2035))
|
|
9
|
+
|
|
10
|
+
## 0.3.4 (2024-11-14)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* allow accounts to be nullable in `readContract` and add `sim_getTransactionsForAddress` method ([#16](https://github.com/yeagerai/genlayer-js/issues/16)) ([ea4bb6c](https://github.com/yeagerai/genlayer-js/commit/ea4bb6cb53809f6c17a3794ed35aede979bd89e5))
|
|
16
|
+
|
|
3
17
|
## 0.3.3 (2024-11-11)
|
|
4
18
|
|
|
5
19
|
## 0.3.2 (2024-11-06)
|
package/dist/chains/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkIINRDYKFcjs = require('../chunk-IINRDYKF.cjs');
|
|
4
4
|
require('../chunk-75ZPJI57.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
exports.simulator =
|
|
7
|
+
exports.simulator = _chunkIINRDYKFcjs.simulator;
|
package/dist/chains/index.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { s as simulator } from '../index-
|
|
2
|
-
import '../chains-
|
|
1
|
+
export { s as simulator } from '../index-SfwloK-R.cjs';
|
|
2
|
+
import '../chains-BV4Glo-M.cjs';
|
|
3
3
|
import 'viem';
|
package/dist/chains/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { s as simulator } from '../index-
|
|
2
|
-
import '../chains-
|
|
1
|
+
export { s as simulator } from '../index-B5TpaPQ6.js';
|
|
2
|
+
import '../chains-BV4Glo-M.js';
|
|
3
3
|
import 'viem';
|
package/dist/chains/index.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkIINRDYKFcjs = require('./chunk-IINRDYKF.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
var _chunkYI62SDKVcjs = require('./chunk-YI62SDKV.cjs');
|
|
@@ -14,7 +14,7 @@ var _viem = require('viem');
|
|
|
14
14
|
function accountActions(client) {
|
|
15
15
|
return {
|
|
16
16
|
fundAccount: async ({ address, amount }) => {
|
|
17
|
-
if (_optionalChain([client, 'access', _ => _.chain, 'optionalAccess', _2 => _2.id]) !==
|
|
17
|
+
if (_optionalChain([client, 'access', _ => _.chain, 'optionalAccess', _2 => _2.id]) !== _chunkIINRDYKFcjs.simulator.id) {
|
|
18
18
|
throw new Error("Client is not connected to the simulator");
|
|
19
19
|
}
|
|
20
20
|
return client.request({
|
|
@@ -102,7 +102,7 @@ function encodeMap(to, arr) {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
encodeNumWithType(to, BigInt(newEntries.length), TYPE_MAP);
|
|
105
|
-
for (const [
|
|
105
|
+
for (const [, k, v] of newEntries) {
|
|
106
106
|
writeNum(to, BigInt(k.length));
|
|
107
107
|
for (const c of k) {
|
|
108
108
|
to.push(c);
|
|
@@ -315,8 +315,8 @@ var transactionActions = (client) => ({
|
|
|
315
315
|
});
|
|
316
316
|
|
|
317
317
|
// src/client/client.ts
|
|
318
|
-
var createClient = (config = { chain:
|
|
319
|
-
const chainConfig = config.chain ||
|
|
318
|
+
var createClient = (config = { chain: _chunkIINRDYKFcjs.simulator }) => {
|
|
319
|
+
const chainConfig = config.chain || _chunkIINRDYKFcjs.simulator;
|
|
320
320
|
const rpcUrl = config.endpoint || chainConfig.rpcUrls.default.http[0];
|
|
321
321
|
const baseClient = _viem.createClient.call(void 0, {
|
|
322
322
|
chain: chainConfig,
|
|
@@ -340,4 +340,4 @@ var createAccount = (accountPrivateKey) => {
|
|
|
340
340
|
|
|
341
341
|
|
|
342
342
|
|
|
343
|
-
exports.chains =
|
|
343
|
+
exports.chains = _chunkIINRDYKFcjs.chains_exports; exports.createAccount = createAccount; exports.createClient = createClient; exports.generatePrivateKey = generatePrivateKey;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as viem from 'viem';
|
|
2
2
|
import { Account } from 'viem';
|
|
3
|
-
import { S as SimulatorChain } from './chains-
|
|
4
|
-
import {
|
|
3
|
+
import { S as SimulatorChain } from './chains-BV4Glo-M.cjs';
|
|
4
|
+
import { GenLayerClient } from './types/index.cjs';
|
|
5
5
|
import * as abitype from 'abitype';
|
|
6
6
|
import * as viem__types_experimental_eip7702_types_authorization from 'viem/_types/experimental/eip7702/types/authorization';
|
|
7
7
|
import * as viem_accounts from 'viem/accounts';
|
|
8
|
-
export { i as chains } from './index-
|
|
8
|
+
export { i as chains } from './index-SfwloK-R.cjs';
|
|
9
9
|
|
|
10
10
|
interface ClientConfig {
|
|
11
11
|
chain?: {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as viem from 'viem';
|
|
2
2
|
import { Account } from 'viem';
|
|
3
|
-
import { S as SimulatorChain } from './chains-
|
|
4
|
-
import {
|
|
3
|
+
import { S as SimulatorChain } from './chains-BV4Glo-M.js';
|
|
4
|
+
import { GenLayerClient } from './types/index.js';
|
|
5
5
|
import * as abitype from 'abitype';
|
|
6
6
|
import * as viem__types_experimental_eip7702_types_authorization from 'viem/_types/experimental/eip7702/types/authorization';
|
|
7
7
|
import * as viem_accounts from 'viem/accounts';
|
|
8
|
-
export { i as chains } from './index-
|
|
8
|
+
export { i as chains } from './index-B5TpaPQ6.js';
|
|
9
9
|
|
|
10
10
|
interface ClientConfig {
|
|
11
11
|
chain?: {
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
chains_exports,
|
|
3
3
|
simulator
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-3TYB36DW.js";
|
|
5
5
|
import {
|
|
6
6
|
Address
|
|
7
7
|
} from "./chunk-M7SA3INM.js";
|
|
@@ -102,7 +102,7 @@ function encodeMap(to, arr) {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
encodeNumWithType(to, BigInt(newEntries.length), TYPE_MAP);
|
|
105
|
-
for (const [
|
|
105
|
+
for (const [, k, v] of newEntries) {
|
|
106
106
|
writeNum(to, BigInt(k.length));
|
|
107
107
|
for (const c of k) {
|
|
108
108
|
to.push(c);
|
package/dist/types/index.d.cts
CHANGED
|
@@ -1,7 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { S as SimulatorChain } from '../chains-BV4Glo-M.cjs';
|
|
2
|
+
import { Client, Transport, PublicActions, Account } from 'viem';
|
|
3
3
|
export { Account } from 'viem';
|
|
4
4
|
|
|
5
|
+
type Address$1 = `0x${string}` & {
|
|
6
|
+
length: 42;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
declare class Address {
|
|
10
|
+
bytes: Uint8Array;
|
|
11
|
+
constructor(addr: Uint8Array);
|
|
12
|
+
}
|
|
13
|
+
type CalldataEncodable = null | boolean | Address | number | bigint | string | Uint8Array | Address | Array<CalldataEncodable> | Map<string, CalldataEncodable> | {
|
|
14
|
+
[key: string]: CalldataEncodable;
|
|
15
|
+
};
|
|
16
|
+
type MethodDescription = {
|
|
17
|
+
method: string;
|
|
18
|
+
args: Array<CalldataEncodable>;
|
|
19
|
+
};
|
|
20
|
+
type TransactionData = {
|
|
21
|
+
method: string;
|
|
22
|
+
args: CalldataEncodable[];
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
type TransactionHash = `0x${string}` & {
|
|
26
|
+
length: 66;
|
|
27
|
+
};
|
|
28
|
+
declare enum TransactionStatus {
|
|
29
|
+
PENDING = "PENDING",
|
|
30
|
+
CANCELED = "CANCELED",
|
|
31
|
+
PROPOSING = "PROPOSING",
|
|
32
|
+
COMMITTING = "COMMITTING",
|
|
33
|
+
REVEALING = "REVEALING",
|
|
34
|
+
ACCEPTED = "ACCEPTED",
|
|
35
|
+
FINALIZED = "FINALIZED",
|
|
36
|
+
UNDETERMINED = "UNDETERMINED"
|
|
37
|
+
}
|
|
38
|
+
type GenLayerTransaction = {
|
|
39
|
+
hash: TransactionHash;
|
|
40
|
+
status: TransactionStatus;
|
|
41
|
+
from_address?: string;
|
|
42
|
+
to_address?: string;
|
|
43
|
+
data?: Record<string, unknown>;
|
|
44
|
+
consensus_data?: Record<string, unknown>;
|
|
45
|
+
nonce?: number;
|
|
46
|
+
value?: number;
|
|
47
|
+
type?: number;
|
|
48
|
+
gaslimit?: bigint;
|
|
49
|
+
created_at?: Date;
|
|
50
|
+
r?: number;
|
|
51
|
+
s?: number;
|
|
52
|
+
v?: number;
|
|
53
|
+
};
|
|
54
|
+
type TransactionDataElement = string | number | bigint | boolean | Uint8Array;
|
|
55
|
+
|
|
5
56
|
type ContractSchema = {
|
|
6
57
|
abi: Array<{
|
|
7
58
|
inputs?: Array<{
|
|
@@ -18,4 +69,67 @@ type ContractSchema = {
|
|
|
18
69
|
class: string;
|
|
19
70
|
};
|
|
20
71
|
|
|
21
|
-
|
|
72
|
+
type GenLayerMethod = {
|
|
73
|
+
method: "sim_fundAccount";
|
|
74
|
+
params: [address: string, amount: number];
|
|
75
|
+
} | {
|
|
76
|
+
method: "eth_getTransactionByHash";
|
|
77
|
+
params: [hash: TransactionHash];
|
|
78
|
+
} | {
|
|
79
|
+
method: "eth_call";
|
|
80
|
+
params: [requestParams: any, blockNumberOrHash: string];
|
|
81
|
+
} | {
|
|
82
|
+
method: "eth_sedRawTransaction";
|
|
83
|
+
params: [signedTransaction: string];
|
|
84
|
+
} | {
|
|
85
|
+
method: "gen_getContractSchema";
|
|
86
|
+
params: [address: string];
|
|
87
|
+
} | {
|
|
88
|
+
method: "gen_getContractSchemaForCode";
|
|
89
|
+
params: [contractCode: string];
|
|
90
|
+
} | {
|
|
91
|
+
method: "sim_getTransactionsForAddress";
|
|
92
|
+
params: [address: string, filter?: "all" | "from" | "to"];
|
|
93
|
+
} | {
|
|
94
|
+
method: "eth_getTransactionCount";
|
|
95
|
+
params: [address: string];
|
|
96
|
+
};
|
|
97
|
+
type GenLayerClient<TSimulatorChain extends SimulatorChain> = Omit<Client<Transport, TSimulatorChain>, "transport" | "getTransaction" | "readContract"> & Omit<PublicActions<Transport, TSimulatorChain>, "readContract" | "getTransaction"> & {
|
|
98
|
+
request: Client<Transport, TSimulatorChain>["request"] & {
|
|
99
|
+
<TMethod extends GenLayerMethod>(args: Extract<GenLayerMethod, {
|
|
100
|
+
method: TMethod["method"];
|
|
101
|
+
}>): Promise<unknown>;
|
|
102
|
+
};
|
|
103
|
+
readContract: (args: {
|
|
104
|
+
account?: Account;
|
|
105
|
+
address: Address$1;
|
|
106
|
+
functionName: string;
|
|
107
|
+
args: CalldataEncodable[];
|
|
108
|
+
}) => Promise<any>;
|
|
109
|
+
writeContract: (args: {
|
|
110
|
+
account?: Account;
|
|
111
|
+
address: Address$1;
|
|
112
|
+
functionName: string;
|
|
113
|
+
args: CalldataEncodable[];
|
|
114
|
+
value: bigint;
|
|
115
|
+
}) => Promise<any>;
|
|
116
|
+
deployContract: (args: {
|
|
117
|
+
account?: Account;
|
|
118
|
+
code: string;
|
|
119
|
+
args: CalldataEncodable[];
|
|
120
|
+
}) => Promise<any>;
|
|
121
|
+
getTransaction: (args: {
|
|
122
|
+
hash: TransactionHash;
|
|
123
|
+
}) => Promise<GenLayerTransaction>;
|
|
124
|
+
getCurrentNonce: (args: {
|
|
125
|
+
address: string;
|
|
126
|
+
}) => Promise<number>;
|
|
127
|
+
waitForTransactionReceipt: (args: {
|
|
128
|
+
hash: TransactionHash;
|
|
129
|
+
status?: TransactionStatus;
|
|
130
|
+
}) => Promise<GenLayerTransaction>;
|
|
131
|
+
getContractSchema: (address: string) => Promise<ContractSchema>;
|
|
132
|
+
getContractSchemaForCode: (contractCode: string) => Promise<ContractSchema>;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export { type Address$1 as Address, type CalldataEncodable, type ContractSchema, type GenLayerClient, type GenLayerMethod, type GenLayerTransaction, type MethodDescription, SimulatorChain, type TransactionData, type TransactionDataElement, type TransactionHash, TransactionStatus };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,7 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { S as SimulatorChain } from '../chains-BV4Glo-M.js';
|
|
2
|
+
import { Client, Transport, PublicActions, Account } from 'viem';
|
|
3
3
|
export { Account } from 'viem';
|
|
4
4
|
|
|
5
|
+
type Address$1 = `0x${string}` & {
|
|
6
|
+
length: 42;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
declare class Address {
|
|
10
|
+
bytes: Uint8Array;
|
|
11
|
+
constructor(addr: Uint8Array);
|
|
12
|
+
}
|
|
13
|
+
type CalldataEncodable = null | boolean | Address | number | bigint | string | Uint8Array | Address | Array<CalldataEncodable> | Map<string, CalldataEncodable> | {
|
|
14
|
+
[key: string]: CalldataEncodable;
|
|
15
|
+
};
|
|
16
|
+
type MethodDescription = {
|
|
17
|
+
method: string;
|
|
18
|
+
args: Array<CalldataEncodable>;
|
|
19
|
+
};
|
|
20
|
+
type TransactionData = {
|
|
21
|
+
method: string;
|
|
22
|
+
args: CalldataEncodable[];
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
type TransactionHash = `0x${string}` & {
|
|
26
|
+
length: 66;
|
|
27
|
+
};
|
|
28
|
+
declare enum TransactionStatus {
|
|
29
|
+
PENDING = "PENDING",
|
|
30
|
+
CANCELED = "CANCELED",
|
|
31
|
+
PROPOSING = "PROPOSING",
|
|
32
|
+
COMMITTING = "COMMITTING",
|
|
33
|
+
REVEALING = "REVEALING",
|
|
34
|
+
ACCEPTED = "ACCEPTED",
|
|
35
|
+
FINALIZED = "FINALIZED",
|
|
36
|
+
UNDETERMINED = "UNDETERMINED"
|
|
37
|
+
}
|
|
38
|
+
type GenLayerTransaction = {
|
|
39
|
+
hash: TransactionHash;
|
|
40
|
+
status: TransactionStatus;
|
|
41
|
+
from_address?: string;
|
|
42
|
+
to_address?: string;
|
|
43
|
+
data?: Record<string, unknown>;
|
|
44
|
+
consensus_data?: Record<string, unknown>;
|
|
45
|
+
nonce?: number;
|
|
46
|
+
value?: number;
|
|
47
|
+
type?: number;
|
|
48
|
+
gaslimit?: bigint;
|
|
49
|
+
created_at?: Date;
|
|
50
|
+
r?: number;
|
|
51
|
+
s?: number;
|
|
52
|
+
v?: number;
|
|
53
|
+
};
|
|
54
|
+
type TransactionDataElement = string | number | bigint | boolean | Uint8Array;
|
|
55
|
+
|
|
5
56
|
type ContractSchema = {
|
|
6
57
|
abi: Array<{
|
|
7
58
|
inputs?: Array<{
|
|
@@ -18,4 +69,67 @@ type ContractSchema = {
|
|
|
18
69
|
class: string;
|
|
19
70
|
};
|
|
20
71
|
|
|
21
|
-
|
|
72
|
+
type GenLayerMethod = {
|
|
73
|
+
method: "sim_fundAccount";
|
|
74
|
+
params: [address: string, amount: number];
|
|
75
|
+
} | {
|
|
76
|
+
method: "eth_getTransactionByHash";
|
|
77
|
+
params: [hash: TransactionHash];
|
|
78
|
+
} | {
|
|
79
|
+
method: "eth_call";
|
|
80
|
+
params: [requestParams: any, blockNumberOrHash: string];
|
|
81
|
+
} | {
|
|
82
|
+
method: "eth_sedRawTransaction";
|
|
83
|
+
params: [signedTransaction: string];
|
|
84
|
+
} | {
|
|
85
|
+
method: "gen_getContractSchema";
|
|
86
|
+
params: [address: string];
|
|
87
|
+
} | {
|
|
88
|
+
method: "gen_getContractSchemaForCode";
|
|
89
|
+
params: [contractCode: string];
|
|
90
|
+
} | {
|
|
91
|
+
method: "sim_getTransactionsForAddress";
|
|
92
|
+
params: [address: string, filter?: "all" | "from" | "to"];
|
|
93
|
+
} | {
|
|
94
|
+
method: "eth_getTransactionCount";
|
|
95
|
+
params: [address: string];
|
|
96
|
+
};
|
|
97
|
+
type GenLayerClient<TSimulatorChain extends SimulatorChain> = Omit<Client<Transport, TSimulatorChain>, "transport" | "getTransaction" | "readContract"> & Omit<PublicActions<Transport, TSimulatorChain>, "readContract" | "getTransaction"> & {
|
|
98
|
+
request: Client<Transport, TSimulatorChain>["request"] & {
|
|
99
|
+
<TMethod extends GenLayerMethod>(args: Extract<GenLayerMethod, {
|
|
100
|
+
method: TMethod["method"];
|
|
101
|
+
}>): Promise<unknown>;
|
|
102
|
+
};
|
|
103
|
+
readContract: (args: {
|
|
104
|
+
account?: Account;
|
|
105
|
+
address: Address$1;
|
|
106
|
+
functionName: string;
|
|
107
|
+
args: CalldataEncodable[];
|
|
108
|
+
}) => Promise<any>;
|
|
109
|
+
writeContract: (args: {
|
|
110
|
+
account?: Account;
|
|
111
|
+
address: Address$1;
|
|
112
|
+
functionName: string;
|
|
113
|
+
args: CalldataEncodable[];
|
|
114
|
+
value: bigint;
|
|
115
|
+
}) => Promise<any>;
|
|
116
|
+
deployContract: (args: {
|
|
117
|
+
account?: Account;
|
|
118
|
+
code: string;
|
|
119
|
+
args: CalldataEncodable[];
|
|
120
|
+
}) => Promise<any>;
|
|
121
|
+
getTransaction: (args: {
|
|
122
|
+
hash: TransactionHash;
|
|
123
|
+
}) => Promise<GenLayerTransaction>;
|
|
124
|
+
getCurrentNonce: (args: {
|
|
125
|
+
address: string;
|
|
126
|
+
}) => Promise<number>;
|
|
127
|
+
waitForTransactionReceipt: (args: {
|
|
128
|
+
hash: TransactionHash;
|
|
129
|
+
status?: TransactionStatus;
|
|
130
|
+
}) => Promise<GenLayerTransaction>;
|
|
131
|
+
getContractSchema: (address: string) => Promise<ContractSchema>;
|
|
132
|
+
getContractSchemaForCode: (contractCode: string) => Promise<ContractSchema>;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export { type Address$1 as Address, type CalldataEncodable, type ContractSchema, type GenLayerClient, type GenLayerMethod, type GenLayerTransaction, type MethodDescription, SimulatorChain, type TransactionData, type TransactionDataElement, type TransactionHash, TransactionStatus };
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "genlayer-js",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.0",
|
|
5
5
|
"description": "GenLayer JavaScript SDK",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"build": "tsup src/index.ts src/chains/index.ts src/types/index.ts --format cjs,esm --dts --splitting --out-dir dist --no-treeshake",
|
|
10
10
|
"build:watch": "tsup src/index.ts src/chains/index.ts src/types/index.ts --format cjs,esm --dts --splitting --out-dir dist --no-treeshake --watch",
|
|
11
|
-
"test": "vitest",
|
|
11
|
+
"test": "vitest --typecheck",
|
|
12
12
|
"test:watch": "vitest --watch",
|
|
13
|
-
"lint": "eslint . --ext .ts",
|
|
13
|
+
"lint": "eslint . --fix --ext .ts",
|
|
14
14
|
"release": "release-it --ci"
|
|
15
15
|
},
|
|
16
16
|
"exports": {
|
|
@@ -77,7 +77,7 @@ function encodeMap(to: number[], arr: Iterable<[string, CalldataEncodable]>) {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
encodeNumWithType(to, BigInt(newEntries.length), TYPE_MAP);
|
|
80
|
-
for (const [
|
|
80
|
+
for (const [, k, v] of newEntries) {
|
|
81
81
|
writeNum(to, BigInt(k.length));
|
|
82
82
|
for (const c of k) {
|
|
83
83
|
to.push(c);
|
package/src/abi/index.ts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import {TransactionHash} from "@/types";
|
|
2
|
-
import {Account, Chain, Transport} from "viem";
|
|
3
2
|
|
|
4
|
-
export type IAccountActions
|
|
5
|
-
transport extends Transport = Transport,
|
|
6
|
-
chain extends Chain | undefined = Chain | undefined,
|
|
7
|
-
account extends Account | undefined = Account | undefined,
|
|
8
|
-
> = {
|
|
3
|
+
export type IAccountActions = {
|
|
9
4
|
fundAccount: ({address, amount}: {address: string; amount: number}) => Promise<TransactionHash>;
|
|
10
5
|
};
|
package/src/accounts/actions.ts
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import {GenLayerClient, TransactionHash, SimulatorChain} from "../types";
|
|
2
2
|
import {simulator} from "../chains";
|
|
3
|
-
import {Account, Transport} from "viem";
|
|
4
3
|
|
|
5
|
-
export function accountActions<
|
|
6
|
-
transport extends Transport = Transport,
|
|
7
|
-
chain extends SimulatorChain | undefined = SimulatorChain | undefined,
|
|
8
|
-
account extends Account | undefined = Account | undefined,
|
|
9
|
-
>(client: GenLayerClient<SimulatorChain>) {
|
|
4
|
+
export function accountActions(client: GenLayerClient<SimulatorChain>) {
|
|
10
5
|
return {
|
|
11
6
|
fundAccount: async ({address, amount}: {address: string; amount: number}): Promise<TransactionHash> => {
|
|
12
7
|
if (client.chain?.id !== simulator.id) {
|
package/src/chains/simulator.ts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import {Account, Chain, Transport} from "viem";
|
|
2
1
|
import {TransactionHash, TransactionStatus, GenLayerTransaction} from "@/types";
|
|
3
2
|
|
|
4
|
-
export type ITransactionActions
|
|
5
|
-
transport extends Transport = Transport,
|
|
6
|
-
chain extends Chain | undefined = Chain | undefined,
|
|
7
|
-
account extends Account | undefined = Account | undefined,
|
|
8
|
-
> = {
|
|
3
|
+
export type ITransactionActions = {
|
|
9
4
|
waitForTransactionReceipt: ({
|
|
10
5
|
hash,
|
|
11
6
|
status,
|
package/src/types/chains.ts
CHANGED
package/src/types/clients.ts
CHANGED
|
@@ -3,6 +3,7 @@ import {GenLayerTransaction, TransactionHash, TransactionStatus} from "./transac
|
|
|
3
3
|
import {SimulatorChain} from "./chains";
|
|
4
4
|
import {Address, Account} from "./accounts";
|
|
5
5
|
import {CalldataEncodable} from "./calldata";
|
|
6
|
+
import {ContractSchema} from "./contracts";
|
|
6
7
|
|
|
7
8
|
export type GenLayerMethod =
|
|
8
9
|
| {method: "sim_fundAccount"; params: [address: string, amount: number]}
|
|
@@ -11,6 +12,7 @@ export type GenLayerMethod =
|
|
|
11
12
|
| {method: "eth_sedRawTransaction"; params: [signedTransaction: string]}
|
|
12
13
|
| {method: "gen_getContractSchema"; params: [address: string]}
|
|
13
14
|
| {method: "gen_getContractSchemaForCode"; params: [contractCode: string]}
|
|
15
|
+
| {method: "sim_getTransactionsForAddress"; params: [address: string, filter?: "all" | "from" | "to"]}
|
|
14
16
|
| {method: "eth_getTransactionCount"; params: [address: string]};
|
|
15
17
|
|
|
16
18
|
/*
|
|
@@ -49,4 +51,6 @@ export type GenLayerClient<TSimulatorChain extends SimulatorChain> = Omit<
|
|
|
49
51
|
hash: TransactionHash;
|
|
50
52
|
status?: TransactionStatus;
|
|
51
53
|
}) => Promise<GenLayerTransaction>;
|
|
54
|
+
getContractSchema: (address: string) => Promise<ContractSchema>;
|
|
55
|
+
getContractSchemaForCode: (contractCode: string) => Promise<ContractSchema>;
|
|
52
56
|
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {createClient} from "../src/client/client";
|
|
2
|
+
import {simulator} from "../src/chains/simulator";
|
|
3
|
+
import {createAccount, generatePrivateKey} from "../src/accounts/account";
|
|
4
|
+
|
|
5
|
+
test("type checks", () => {
|
|
6
|
+
const client = createClient({
|
|
7
|
+
chain: simulator,
|
|
8
|
+
account: createAccount(generatePrivateKey()),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const exampleAddress = "0x1234567890123456789012345678901234567890";
|
|
12
|
+
|
|
13
|
+
// This should fail type checking - "whatever" is not a valid filter
|
|
14
|
+
// @ts-expect-error "whatever" is not a valid filter type
|
|
15
|
+
void client.request({
|
|
16
|
+
method: "sim_getTransactionsForAddress",
|
|
17
|
+
params: [exampleAddress, "whatever"],
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// This should pass type checking - "all", "to" and "from" are valid filters
|
|
21
|
+
void client.request({
|
|
22
|
+
method: "sim_getTransactionsForAddress",
|
|
23
|
+
params: [exampleAddress, "all"],
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
void client.request({
|
|
27
|
+
method: "sim_getTransactionsForAddress",
|
|
28
|
+
params: [exampleAddress, "to"],
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
void client.request({
|
|
32
|
+
method: "sim_getTransactionsForAddress",
|
|
33
|
+
params: [exampleAddress, "from"],
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
void client.getContractSchema(exampleAddress);
|
|
37
|
+
|
|
38
|
+
void client.getContractSchemaForCode("class SomeContract...");
|
|
39
|
+
});
|
package/tests/client.test.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
// tests/client.test.ts
|
|
2
2
|
import {createClient} from "../src/client/client";
|
|
3
3
|
import {simulator} from "../src/chains/simulator";
|
|
4
|
+
import {Address} from "../src/types/accounts";
|
|
5
|
+
import {createAccount, generatePrivateKey} from "../src/accounts/account";
|
|
6
|
+
import {vi} from "vitest";
|
|
4
7
|
|
|
5
8
|
describe("Client Creation", () => {
|
|
6
9
|
it("should create a client for the simulator", () => {
|
|
@@ -9,3 +12,68 @@ describe("Client Creation", () => {
|
|
|
9
12
|
expect(client.chain).toBe(simulator);
|
|
10
13
|
});
|
|
11
14
|
});
|
|
15
|
+
|
|
16
|
+
describe("Client Overrides", () => {
|
|
17
|
+
it("should default to client account if no account is provided", async () => {
|
|
18
|
+
const account = createAccount(generatePrivateKey());
|
|
19
|
+
const client = createClient({
|
|
20
|
+
chain: simulator,
|
|
21
|
+
account,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// Mock the client.request method
|
|
25
|
+
vi.spyOn(client, "request").mockResolvedValue(undefined);
|
|
26
|
+
|
|
27
|
+
const contractAddress = "0x1234567890123456789012345678901234567890";
|
|
28
|
+
await client.readContract({
|
|
29
|
+
address: contractAddress as Address,
|
|
30
|
+
functionName: "testFunction",
|
|
31
|
+
args: ["arg1", "arg2"],
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
expect(client.request).toHaveBeenCalledWith({
|
|
35
|
+
method: "eth_call",
|
|
36
|
+
params: [
|
|
37
|
+
{
|
|
38
|
+
to: contractAddress,
|
|
39
|
+
from: account.address,
|
|
40
|
+
data: expect.any(String),
|
|
41
|
+
},
|
|
42
|
+
"latest",
|
|
43
|
+
],
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("should override client account if account is provided", async () => {
|
|
48
|
+
const account = createAccount(generatePrivateKey());
|
|
49
|
+
const client = createClient({
|
|
50
|
+
chain: simulator,
|
|
51
|
+
account,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const overrideAccount = createAccount(generatePrivateKey());
|
|
55
|
+
|
|
56
|
+
// Mock the client.request method
|
|
57
|
+
vi.spyOn(client, "request").mockResolvedValue(undefined);
|
|
58
|
+
|
|
59
|
+
const contractAddress = "0x1234567890123456789012345678901234567890";
|
|
60
|
+
await client.readContract({
|
|
61
|
+
account: overrideAccount,
|
|
62
|
+
address: contractAddress as Address,
|
|
63
|
+
functionName: "testFunction",
|
|
64
|
+
args: ["arg1", "arg2"],
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
expect(client.request).toHaveBeenCalledWith({
|
|
68
|
+
method: "eth_call",
|
|
69
|
+
params: [
|
|
70
|
+
{
|
|
71
|
+
to: contractAddress,
|
|
72
|
+
from: overrideAccount.address,
|
|
73
|
+
data: expect.any(String),
|
|
74
|
+
},
|
|
75
|
+
"latest",
|
|
76
|
+
],
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
});
|
package/vitest.config.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {defineConfig} from "vitest/config";
|
|
2
|
+
import path from "path";
|
|
2
3
|
|
|
3
4
|
export default defineConfig({
|
|
4
5
|
test: {
|
|
@@ -9,4 +10,9 @@ export default defineConfig({
|
|
|
9
10
|
exclude: ["node_modules/"],
|
|
10
11
|
},
|
|
11
12
|
},
|
|
13
|
+
resolve: {
|
|
14
|
+
alias: {
|
|
15
|
+
"@": path.resolve(__dirname, "./src"),
|
|
16
|
+
},
|
|
17
|
+
},
|
|
12
18
|
});
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { Client, Transport, PublicActions, Account } from 'viem';
|
|
2
|
-
import { S as SimulatorChain } from './chains-CtZJFz4Q.js';
|
|
3
|
-
|
|
4
|
-
type Address$1 = `0x${string}` & {
|
|
5
|
-
length: 42;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
declare class Address {
|
|
9
|
-
bytes: Uint8Array;
|
|
10
|
-
constructor(addr: Uint8Array);
|
|
11
|
-
}
|
|
12
|
-
type CalldataEncodable = null | boolean | Address | number | bigint | string | Uint8Array | Address | Array<CalldataEncodable> | Map<string, CalldataEncodable> | {
|
|
13
|
-
[key: string]: CalldataEncodable;
|
|
14
|
-
};
|
|
15
|
-
type MethodDescription = {
|
|
16
|
-
method: string;
|
|
17
|
-
args: Array<CalldataEncodable>;
|
|
18
|
-
};
|
|
19
|
-
type TransactionData = {
|
|
20
|
-
method: string;
|
|
21
|
-
args: CalldataEncodable[];
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
type TransactionHash = `0x${string}` & {
|
|
25
|
-
length: 66;
|
|
26
|
-
};
|
|
27
|
-
declare enum TransactionStatus {
|
|
28
|
-
PENDING = "PENDING",
|
|
29
|
-
CANCELED = "CANCELED",
|
|
30
|
-
PROPOSING = "PROPOSING",
|
|
31
|
-
COMMITTING = "COMMITTING",
|
|
32
|
-
REVEALING = "REVEALING",
|
|
33
|
-
ACCEPTED = "ACCEPTED",
|
|
34
|
-
FINALIZED = "FINALIZED",
|
|
35
|
-
UNDETERMINED = "UNDETERMINED"
|
|
36
|
-
}
|
|
37
|
-
type GenLayerTransaction = {
|
|
38
|
-
hash: TransactionHash;
|
|
39
|
-
status: TransactionStatus;
|
|
40
|
-
from_address?: string;
|
|
41
|
-
to_address?: string;
|
|
42
|
-
data?: Record<string, unknown>;
|
|
43
|
-
consensus_data?: Record<string, unknown>;
|
|
44
|
-
nonce?: number;
|
|
45
|
-
value?: number;
|
|
46
|
-
type?: number;
|
|
47
|
-
gaslimit?: bigint;
|
|
48
|
-
created_at?: Date;
|
|
49
|
-
r?: number;
|
|
50
|
-
s?: number;
|
|
51
|
-
v?: number;
|
|
52
|
-
};
|
|
53
|
-
type TransactionDataElement = string | number | bigint | boolean | Uint8Array;
|
|
54
|
-
|
|
55
|
-
type GenLayerMethod = {
|
|
56
|
-
method: "sim_fundAccount";
|
|
57
|
-
params: [address: string, amount: number];
|
|
58
|
-
} | {
|
|
59
|
-
method: "eth_getTransactionByHash";
|
|
60
|
-
params: [hash: TransactionHash];
|
|
61
|
-
} | {
|
|
62
|
-
method: "eth_call";
|
|
63
|
-
params: [requestParams: any, blockNumberOrHash: string];
|
|
64
|
-
} | {
|
|
65
|
-
method: "eth_sedRawTransaction";
|
|
66
|
-
params: [signedTransaction: string];
|
|
67
|
-
} | {
|
|
68
|
-
method: "gen_getContractSchema";
|
|
69
|
-
params: [address: string];
|
|
70
|
-
} | {
|
|
71
|
-
method: "gen_getContractSchemaForCode";
|
|
72
|
-
params: [contractCode: string];
|
|
73
|
-
} | {
|
|
74
|
-
method: "eth_getTransactionCount";
|
|
75
|
-
params: [address: string];
|
|
76
|
-
};
|
|
77
|
-
type GenLayerClient<TSimulatorChain extends SimulatorChain> = Omit<Client<Transport, TSimulatorChain>, "transport" | "getTransaction" | "readContract"> & Omit<PublicActions<Transport, TSimulatorChain>, "readContract" | "getTransaction"> & {
|
|
78
|
-
request: Client<Transport, TSimulatorChain>["request"] & {
|
|
79
|
-
<TMethod extends GenLayerMethod>(args: Extract<GenLayerMethod, {
|
|
80
|
-
method: TMethod["method"];
|
|
81
|
-
}>): Promise<unknown>;
|
|
82
|
-
};
|
|
83
|
-
readContract: (args: {
|
|
84
|
-
account?: Account;
|
|
85
|
-
address: Address$1;
|
|
86
|
-
functionName: string;
|
|
87
|
-
args: CalldataEncodable[];
|
|
88
|
-
}) => Promise<any>;
|
|
89
|
-
writeContract: (args: {
|
|
90
|
-
account?: Account;
|
|
91
|
-
address: Address$1;
|
|
92
|
-
functionName: string;
|
|
93
|
-
args: CalldataEncodable[];
|
|
94
|
-
value: bigint;
|
|
95
|
-
}) => Promise<any>;
|
|
96
|
-
deployContract: (args: {
|
|
97
|
-
account?: Account;
|
|
98
|
-
code: string;
|
|
99
|
-
args: CalldataEncodable[];
|
|
100
|
-
}) => Promise<any>;
|
|
101
|
-
getTransaction: (args: {
|
|
102
|
-
hash: TransactionHash;
|
|
103
|
-
}) => Promise<GenLayerTransaction>;
|
|
104
|
-
getCurrentNonce: (args: {
|
|
105
|
-
address: string;
|
|
106
|
-
}) => Promise<number>;
|
|
107
|
-
waitForTransactionReceipt: (args: {
|
|
108
|
-
hash: TransactionHash;
|
|
109
|
-
status?: TransactionStatus;
|
|
110
|
-
}) => Promise<GenLayerTransaction>;
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
export { type Address$1 as A, type CalldataEncodable as C, type GenLayerClient as G, type MethodDescription as M, type TransactionData as T, type GenLayerMethod as a, type TransactionHash as b, TransactionStatus as c, type GenLayerTransaction as d, type TransactionDataElement as e };
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { Client, Transport, PublicActions, Account } from 'viem';
|
|
2
|
-
import { S as SimulatorChain } from './chains-CtZJFz4Q.cjs';
|
|
3
|
-
|
|
4
|
-
type Address$1 = `0x${string}` & {
|
|
5
|
-
length: 42;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
declare class Address {
|
|
9
|
-
bytes: Uint8Array;
|
|
10
|
-
constructor(addr: Uint8Array);
|
|
11
|
-
}
|
|
12
|
-
type CalldataEncodable = null | boolean | Address | number | bigint | string | Uint8Array | Address | Array<CalldataEncodable> | Map<string, CalldataEncodable> | {
|
|
13
|
-
[key: string]: CalldataEncodable;
|
|
14
|
-
};
|
|
15
|
-
type MethodDescription = {
|
|
16
|
-
method: string;
|
|
17
|
-
args: Array<CalldataEncodable>;
|
|
18
|
-
};
|
|
19
|
-
type TransactionData = {
|
|
20
|
-
method: string;
|
|
21
|
-
args: CalldataEncodable[];
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
type TransactionHash = `0x${string}` & {
|
|
25
|
-
length: 66;
|
|
26
|
-
};
|
|
27
|
-
declare enum TransactionStatus {
|
|
28
|
-
PENDING = "PENDING",
|
|
29
|
-
CANCELED = "CANCELED",
|
|
30
|
-
PROPOSING = "PROPOSING",
|
|
31
|
-
COMMITTING = "COMMITTING",
|
|
32
|
-
REVEALING = "REVEALING",
|
|
33
|
-
ACCEPTED = "ACCEPTED",
|
|
34
|
-
FINALIZED = "FINALIZED",
|
|
35
|
-
UNDETERMINED = "UNDETERMINED"
|
|
36
|
-
}
|
|
37
|
-
type GenLayerTransaction = {
|
|
38
|
-
hash: TransactionHash;
|
|
39
|
-
status: TransactionStatus;
|
|
40
|
-
from_address?: string;
|
|
41
|
-
to_address?: string;
|
|
42
|
-
data?: Record<string, unknown>;
|
|
43
|
-
consensus_data?: Record<string, unknown>;
|
|
44
|
-
nonce?: number;
|
|
45
|
-
value?: number;
|
|
46
|
-
type?: number;
|
|
47
|
-
gaslimit?: bigint;
|
|
48
|
-
created_at?: Date;
|
|
49
|
-
r?: number;
|
|
50
|
-
s?: number;
|
|
51
|
-
v?: number;
|
|
52
|
-
};
|
|
53
|
-
type TransactionDataElement = string | number | bigint | boolean | Uint8Array;
|
|
54
|
-
|
|
55
|
-
type GenLayerMethod = {
|
|
56
|
-
method: "sim_fundAccount";
|
|
57
|
-
params: [address: string, amount: number];
|
|
58
|
-
} | {
|
|
59
|
-
method: "eth_getTransactionByHash";
|
|
60
|
-
params: [hash: TransactionHash];
|
|
61
|
-
} | {
|
|
62
|
-
method: "eth_call";
|
|
63
|
-
params: [requestParams: any, blockNumberOrHash: string];
|
|
64
|
-
} | {
|
|
65
|
-
method: "eth_sedRawTransaction";
|
|
66
|
-
params: [signedTransaction: string];
|
|
67
|
-
} | {
|
|
68
|
-
method: "gen_getContractSchema";
|
|
69
|
-
params: [address: string];
|
|
70
|
-
} | {
|
|
71
|
-
method: "gen_getContractSchemaForCode";
|
|
72
|
-
params: [contractCode: string];
|
|
73
|
-
} | {
|
|
74
|
-
method: "eth_getTransactionCount";
|
|
75
|
-
params: [address: string];
|
|
76
|
-
};
|
|
77
|
-
type GenLayerClient<TSimulatorChain extends SimulatorChain> = Omit<Client<Transport, TSimulatorChain>, "transport" | "getTransaction" | "readContract"> & Omit<PublicActions<Transport, TSimulatorChain>, "readContract" | "getTransaction"> & {
|
|
78
|
-
request: Client<Transport, TSimulatorChain>["request"] & {
|
|
79
|
-
<TMethod extends GenLayerMethod>(args: Extract<GenLayerMethod, {
|
|
80
|
-
method: TMethod["method"];
|
|
81
|
-
}>): Promise<unknown>;
|
|
82
|
-
};
|
|
83
|
-
readContract: (args: {
|
|
84
|
-
account?: Account;
|
|
85
|
-
address: Address$1;
|
|
86
|
-
functionName: string;
|
|
87
|
-
args: CalldataEncodable[];
|
|
88
|
-
}) => Promise<any>;
|
|
89
|
-
writeContract: (args: {
|
|
90
|
-
account?: Account;
|
|
91
|
-
address: Address$1;
|
|
92
|
-
functionName: string;
|
|
93
|
-
args: CalldataEncodable[];
|
|
94
|
-
value: bigint;
|
|
95
|
-
}) => Promise<any>;
|
|
96
|
-
deployContract: (args: {
|
|
97
|
-
account?: Account;
|
|
98
|
-
code: string;
|
|
99
|
-
args: CalldataEncodable[];
|
|
100
|
-
}) => Promise<any>;
|
|
101
|
-
getTransaction: (args: {
|
|
102
|
-
hash: TransactionHash;
|
|
103
|
-
}) => Promise<GenLayerTransaction>;
|
|
104
|
-
getCurrentNonce: (args: {
|
|
105
|
-
address: string;
|
|
106
|
-
}) => Promise<number>;
|
|
107
|
-
waitForTransactionReceipt: (args: {
|
|
108
|
-
hash: TransactionHash;
|
|
109
|
-
status?: TransactionStatus;
|
|
110
|
-
}) => Promise<GenLayerTransaction>;
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
export { type Address$1 as A, type CalldataEncodable as C, type GenLayerClient as G, type MethodDescription as M, type TransactionData as T, type GenLayerMethod as a, type TransactionHash as b, TransactionStatus as c, type GenLayerTransaction as d, type TransactionDataElement as e };
|