genlayer-js 0.3.0 → 0.3.2
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/CHANGELOG.md +4 -0
- package/dist/{clients-CJ820ePR.d.ts → clients-ByaMqS8n.d.ts} +12 -8
- package/dist/{clients-BamlAEcy.d.cts → clients-DiSeCTYZ.d.cts} +12 -8
- package/dist/index.cjs +7 -9
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +7 -9
- package/dist/types/index.cjs +1 -5
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js +0 -4
- package/package.json +1 -1
- package/src/accounts/actions.ts +8 -2
- package/src/client/client.ts +5 -11
- package/src/contracts/actions.ts +6 -8
- package/src/transactions/actions.ts +2 -6
- package/src/types/accounts.ts +1 -1
- package/src/types/clients.ts +39 -29
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Transport,
|
|
1
|
+
import { Client, Transport, PublicActions, Account } from 'viem';
|
|
2
2
|
import { S as SimulatorChain } from './chains-CtZJFz4Q.js';
|
|
3
3
|
|
|
4
4
|
type Address$1 = `0x${string}` & {
|
|
@@ -74,27 +74,27 @@ type GenLayerMethod = {
|
|
|
74
74
|
method: "eth_getTransactionCount";
|
|
75
75
|
params: [address: string];
|
|
76
76
|
};
|
|
77
|
-
type GenLayerClient<
|
|
78
|
-
request: Client<
|
|
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
79
|
<TMethod extends GenLayerMethod>(args: Extract<GenLayerMethod, {
|
|
80
80
|
method: TMethod["method"];
|
|
81
81
|
}>): Promise<unknown>;
|
|
82
82
|
};
|
|
83
83
|
readContract: (args: {
|
|
84
|
-
account
|
|
84
|
+
account?: Account;
|
|
85
85
|
address: Address$1;
|
|
86
86
|
functionName: string;
|
|
87
|
-
args:
|
|
87
|
+
args: CalldataEncodable[];
|
|
88
88
|
}) => Promise<any>;
|
|
89
89
|
writeContract: (args: {
|
|
90
|
-
account
|
|
90
|
+
account?: Account;
|
|
91
91
|
address: Address$1;
|
|
92
92
|
functionName: string;
|
|
93
|
-
args:
|
|
93
|
+
args: CalldataEncodable[];
|
|
94
94
|
value: bigint;
|
|
95
95
|
}) => Promise<any>;
|
|
96
96
|
deployContract: (args: {
|
|
97
|
-
account
|
|
97
|
+
account?: Account;
|
|
98
98
|
code: string;
|
|
99
99
|
args: CalldataEncodable[];
|
|
100
100
|
}) => Promise<any>;
|
|
@@ -104,6 +104,10 @@ type GenLayerClient<TTransport extends Transport, TSimulatorChain extends Simula
|
|
|
104
104
|
getCurrentNonce: (args: {
|
|
105
105
|
address: string;
|
|
106
106
|
}) => Promise<number>;
|
|
107
|
+
waitForTransactionReceipt: (args: {
|
|
108
|
+
hash: TransactionHash;
|
|
109
|
+
status?: TransactionStatus;
|
|
110
|
+
}) => Promise<GenLayerTransaction>;
|
|
107
111
|
};
|
|
108
112
|
|
|
109
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,4 +1,4 @@
|
|
|
1
|
-
import { Transport,
|
|
1
|
+
import { Client, Transport, PublicActions, Account } from 'viem';
|
|
2
2
|
import { S as SimulatorChain } from './chains-CtZJFz4Q.cjs';
|
|
3
3
|
|
|
4
4
|
type Address$1 = `0x${string}` & {
|
|
@@ -74,27 +74,27 @@ type GenLayerMethod = {
|
|
|
74
74
|
method: "eth_getTransactionCount";
|
|
75
75
|
params: [address: string];
|
|
76
76
|
};
|
|
77
|
-
type GenLayerClient<
|
|
78
|
-
request: Client<
|
|
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
79
|
<TMethod extends GenLayerMethod>(args: Extract<GenLayerMethod, {
|
|
80
80
|
method: TMethod["method"];
|
|
81
81
|
}>): Promise<unknown>;
|
|
82
82
|
};
|
|
83
83
|
readContract: (args: {
|
|
84
|
-
account
|
|
84
|
+
account?: Account;
|
|
85
85
|
address: Address$1;
|
|
86
86
|
functionName: string;
|
|
87
|
-
args:
|
|
87
|
+
args: CalldataEncodable[];
|
|
88
88
|
}) => Promise<any>;
|
|
89
89
|
writeContract: (args: {
|
|
90
|
-
account
|
|
90
|
+
account?: Account;
|
|
91
91
|
address: Address$1;
|
|
92
92
|
functionName: string;
|
|
93
|
-
args:
|
|
93
|
+
args: CalldataEncodable[];
|
|
94
94
|
value: bigint;
|
|
95
95
|
}) => Promise<any>;
|
|
96
96
|
deployContract: (args: {
|
|
97
|
-
account
|
|
97
|
+
account?: Account;
|
|
98
98
|
code: string;
|
|
99
99
|
args: CalldataEncodable[];
|
|
100
100
|
}) => Promise<any>;
|
|
@@ -104,6 +104,10 @@ type GenLayerClient<TTransport extends Transport, TSimulatorChain extends Simula
|
|
|
104
104
|
getCurrentNonce: (args: {
|
|
105
105
|
address: string;
|
|
106
106
|
}) => Promise<number>;
|
|
107
|
+
waitForTransactionReceipt: (args: {
|
|
108
|
+
hash: TransactionHash;
|
|
109
|
+
status?: TransactionStatus;
|
|
110
|
+
}) => Promise<GenLayerTransaction>;
|
|
107
111
|
};
|
|
108
112
|
|
|
109
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 };
|
package/dist/index.cjs
CHANGED
|
@@ -23,9 +23,13 @@ function accountActions(client) {
|
|
|
23
23
|
});
|
|
24
24
|
},
|
|
25
25
|
getCurrentNonce: async ({ address }) => {
|
|
26
|
+
const addressToUse = address || _optionalChain([client, 'access', _3 => _3.account, 'optionalAccess', _4 => _4.address]);
|
|
27
|
+
if (!addressToUse) {
|
|
28
|
+
throw new Error("No address provided and no account is connected");
|
|
29
|
+
}
|
|
26
30
|
return client.request({
|
|
27
31
|
method: "eth_getTransactionCount",
|
|
28
|
-
params: [
|
|
32
|
+
params: [addressToUse]
|
|
29
33
|
});
|
|
30
34
|
}
|
|
31
35
|
};
|
|
@@ -318,14 +322,8 @@ var createClient = (config = { chain: _chunkBAGFDCQEcjs.simulator }) => {
|
|
|
318
322
|
chain: chainConfig,
|
|
319
323
|
transport: _viem.http.call(void 0, rpcUrl),
|
|
320
324
|
...config.account ? { account: config.account } : {}
|
|
321
|
-
}).extend(_viem.publicActions).extend((client) => accountActions(client)).extend(
|
|
322
|
-
|
|
323
|
-
).extend(
|
|
324
|
-
(client) => contractActions(client)
|
|
325
|
-
);
|
|
326
|
-
const genLayerClient = overrideContractActions(
|
|
327
|
-
baseClient
|
|
328
|
-
);
|
|
325
|
+
}).extend(_viem.publicActions).extend((client) => accountActions(client)).extend((client) => transactionActions(client)).extend((client) => contractActions(client));
|
|
326
|
+
const genLayerClient = overrideContractActions(baseClient);
|
|
329
327
|
return genLayerClient;
|
|
330
328
|
};
|
|
331
329
|
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as viem from 'viem';
|
|
2
|
-
import {
|
|
2
|
+
import { Account } from 'viem';
|
|
3
3
|
import { S as SimulatorChain } from './chains-CtZJFz4Q.cjs';
|
|
4
|
-
import { G as GenLayerClient } from './clients-
|
|
4
|
+
import { G as GenLayerClient } from './clients-DiSeCTYZ.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';
|
|
@@ -31,7 +31,7 @@ interface ClientConfig {
|
|
|
31
31
|
endpoint?: string;
|
|
32
32
|
account?: Account;
|
|
33
33
|
}
|
|
34
|
-
declare const createClient: (config?: ClientConfig) => GenLayerClient<
|
|
34
|
+
declare const createClient: (config?: ClientConfig) => GenLayerClient<SimulatorChain>;
|
|
35
35
|
|
|
36
36
|
declare const generatePrivateKey: () => `0x${string}`;
|
|
37
37
|
declare const createAccount: (accountPrivateKey?: `0x${string}`) => {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as viem from 'viem';
|
|
2
|
-
import {
|
|
2
|
+
import { Account } from 'viem';
|
|
3
3
|
import { S as SimulatorChain } from './chains-CtZJFz4Q.js';
|
|
4
|
-
import { G as GenLayerClient } from './clients-
|
|
4
|
+
import { G as GenLayerClient } from './clients-ByaMqS8n.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';
|
|
@@ -31,7 +31,7 @@ interface ClientConfig {
|
|
|
31
31
|
endpoint?: string;
|
|
32
32
|
account?: Account;
|
|
33
33
|
}
|
|
34
|
-
declare const createClient: (config?: ClientConfig) => GenLayerClient<
|
|
34
|
+
declare const createClient: (config?: ClientConfig) => GenLayerClient<SimulatorChain>;
|
|
35
35
|
|
|
36
36
|
declare const generatePrivateKey: () => `0x${string}`;
|
|
37
37
|
declare const createAccount: (accountPrivateKey?: `0x${string}`) => {
|
package/dist/index.js
CHANGED
|
@@ -23,9 +23,13 @@ function accountActions(client) {
|
|
|
23
23
|
});
|
|
24
24
|
},
|
|
25
25
|
getCurrentNonce: async ({ address }) => {
|
|
26
|
+
const addressToUse = address || client.account?.address;
|
|
27
|
+
if (!addressToUse) {
|
|
28
|
+
throw new Error("No address provided and no account is connected");
|
|
29
|
+
}
|
|
26
30
|
return client.request({
|
|
27
31
|
method: "eth_getTransactionCount",
|
|
28
|
-
params: [
|
|
32
|
+
params: [addressToUse]
|
|
29
33
|
});
|
|
30
34
|
}
|
|
31
35
|
};
|
|
@@ -318,14 +322,8 @@ var createClient = (config = { chain: simulator }) => {
|
|
|
318
322
|
chain: chainConfig,
|
|
319
323
|
transport: http(rpcUrl),
|
|
320
324
|
...config.account ? { account: config.account } : {}
|
|
321
|
-
}).extend(publicActions).extend((client) => accountActions(client)).extend(
|
|
322
|
-
|
|
323
|
-
).extend(
|
|
324
|
-
(client) => contractActions(client)
|
|
325
|
-
);
|
|
326
|
-
const genLayerClient = overrideContractActions(
|
|
327
|
-
baseClient
|
|
328
|
-
);
|
|
325
|
+
}).extend(publicActions).extend((client) => accountActions(client)).extend((client) => transactionActions(client)).extend((client) => contractActions(client));
|
|
326
|
+
const genLayerClient = overrideContractActions(baseClient);
|
|
329
327
|
return genLayerClient;
|
|
330
328
|
};
|
|
331
329
|
|
package/dist/types/index.cjs
CHANGED
|
@@ -3,9 +3,5 @@
|
|
|
3
3
|
var _chunkYI62SDKVcjs = require('../chunk-YI62SDKV.cjs');
|
|
4
4
|
require('../chunk-75ZPJI57.cjs');
|
|
5
5
|
|
|
6
|
-
// src/types/accounts.ts
|
|
7
|
-
var _viem = require('viem');
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
exports.Account = _viem.Account; exports.TransactionStatus = _chunkYI62SDKVcjs.TransactionStatus;
|
|
7
|
+
exports.TransactionStatus = _chunkYI62SDKVcjs.TransactionStatus;
|
package/dist/types/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as Address, C as CalldataEncodable, G as GenLayerClient, a as GenLayerMethod, d as GenLayerTransaction, M as MethodDescription, T as TransactionData, e as TransactionDataElement, b as TransactionHash, c as TransactionStatus } from '../clients-
|
|
1
|
+
export { A as Address, C as CalldataEncodable, G as GenLayerClient, a as GenLayerMethod, d as GenLayerTransaction, M as MethodDescription, T as TransactionData, e as TransactionDataElement, b as TransactionHash, c as TransactionStatus } from '../clients-DiSeCTYZ.cjs';
|
|
2
2
|
export { S as SimulatorChain } from '../chains-CtZJFz4Q.cjs';
|
|
3
3
|
export { Account } from 'viem';
|
|
4
4
|
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as Address, C as CalldataEncodable, G as GenLayerClient, a as GenLayerMethod, d as GenLayerTransaction, M as MethodDescription, T as TransactionData, e as TransactionDataElement, b as TransactionHash, c as TransactionStatus } from '../clients-
|
|
1
|
+
export { A as Address, C as CalldataEncodable, G as GenLayerClient, a as GenLayerMethod, d as GenLayerTransaction, M as MethodDescription, T as TransactionData, e as TransactionDataElement, b as TransactionHash, c as TransactionStatus } from '../clients-ByaMqS8n.js';
|
|
2
2
|
export { S as SimulatorChain } from '../chains-CtZJFz4Q.js';
|
|
3
3
|
export { Account } from 'viem';
|
|
4
4
|
|
package/dist/types/index.js
CHANGED
package/package.json
CHANGED
package/src/accounts/actions.ts
CHANGED
|
@@ -6,7 +6,7 @@ export function accountActions<
|
|
|
6
6
|
transport extends Transport = Transport,
|
|
7
7
|
chain extends SimulatorChain | undefined = SimulatorChain | undefined,
|
|
8
8
|
account extends Account | undefined = Account | undefined,
|
|
9
|
-
>(client: GenLayerClient<
|
|
9
|
+
>(client: GenLayerClient<SimulatorChain>) {
|
|
10
10
|
return {
|
|
11
11
|
fundAccount: async ({address, amount}: {address: string; amount: number}): Promise<TransactionHash> => {
|
|
12
12
|
if (client.chain?.id !== simulator.id) {
|
|
@@ -19,9 +19,15 @@ export function accountActions<
|
|
|
19
19
|
}) as Promise<TransactionHash>;
|
|
20
20
|
},
|
|
21
21
|
getCurrentNonce: async ({address}: {address: string}): Promise<number> => {
|
|
22
|
+
const addressToUse = address || client.account?.address;
|
|
23
|
+
|
|
24
|
+
if (!addressToUse) {
|
|
25
|
+
throw new Error("No address provided and no account is connected");
|
|
26
|
+
}
|
|
27
|
+
|
|
22
28
|
return client.request({
|
|
23
29
|
method: "eth_getTransactionCount",
|
|
24
|
-
params: [
|
|
30
|
+
params: [addressToUse],
|
|
25
31
|
}) as Promise<number>;
|
|
26
32
|
},
|
|
27
33
|
};
|
package/src/client/client.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {Account, createClient as createViemClient, http, publicActions
|
|
1
|
+
import {Account, createClient as createViemClient, http, publicActions} from "viem";
|
|
2
2
|
import {simulator} from "../chains/simulator";
|
|
3
3
|
import {accountActions} from "../accounts/actions";
|
|
4
4
|
import {contractActions, overrideContractActions} from "../contracts/actions";
|
|
@@ -31,17 +31,11 @@ export const createClient = (config: ClientConfig = {chain: simulator}) => {
|
|
|
31
31
|
...(config.account ? {account: config.account} : {}),
|
|
32
32
|
})
|
|
33
33
|
.extend(publicActions)
|
|
34
|
-
.extend(client => accountActions(client as unknown as GenLayerClient<
|
|
35
|
-
.extend(client =>
|
|
36
|
-
|
|
37
|
-
)
|
|
38
|
-
.extend(client =>
|
|
39
|
-
contractActions(client as unknown as GenLayerClient<Transport, SimulatorChain, Account>),
|
|
40
|
-
);
|
|
34
|
+
.extend(client => accountActions(client as unknown as GenLayerClient<SimulatorChain>))
|
|
35
|
+
.extend(client => transactionActions(client as unknown as GenLayerClient<SimulatorChain>))
|
|
36
|
+
.extend(client => contractActions(client as unknown as GenLayerClient<SimulatorChain>));
|
|
41
37
|
|
|
42
|
-
const genLayerClient = overrideContractActions(
|
|
43
|
-
baseClient as unknown as GenLayerClient<Transport, SimulatorChain, Account>,
|
|
44
|
-
);
|
|
38
|
+
const genLayerClient = overrideContractActions(baseClient as unknown as GenLayerClient<SimulatorChain>);
|
|
45
39
|
|
|
46
40
|
return genLayerClient;
|
|
47
41
|
};
|
package/src/contracts/actions.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {Transport, Account, Address} from "viem";
|
|
2
|
-
|
|
3
1
|
import {encode, serialize, encodeAndSerialize} from "@/abi/calldata/encoder";
|
|
4
|
-
import {ContractSchema, SimulatorChain, GenLayerClient, CalldataEncodable} from "@/types";
|
|
2
|
+
import {Account, ContractSchema, SimulatorChain, GenLayerClient, CalldataEncodable, Address} from "@/types";
|
|
5
3
|
|
|
6
|
-
export const contractActions = (client: GenLayerClient<
|
|
4
|
+
export const contractActions = (client: GenLayerClient<SimulatorChain>) => {
|
|
7
5
|
return {
|
|
8
6
|
getContractSchema: async (address: string): Promise<ContractSchema> => {
|
|
9
7
|
const schema = (await client.request({
|
|
@@ -22,9 +20,9 @@ export const contractActions = (client: GenLayerClient<Transport, SimulatorChain
|
|
|
22
20
|
};
|
|
23
21
|
};
|
|
24
22
|
|
|
25
|
-
export const overrideContractActions = (client: GenLayerClient<
|
|
23
|
+
export const overrideContractActions = (client: GenLayerClient<SimulatorChain>) => {
|
|
26
24
|
client.readContract = async (args: {
|
|
27
|
-
account
|
|
25
|
+
account?: Account;
|
|
28
26
|
address: Address;
|
|
29
27
|
functionName: string;
|
|
30
28
|
args: CalldataEncodable[];
|
|
@@ -45,7 +43,7 @@ export const overrideContractActions = (client: GenLayerClient<Transport, Simula
|
|
|
45
43
|
};
|
|
46
44
|
|
|
47
45
|
client.writeContract = async (args: {
|
|
48
|
-
account
|
|
46
|
+
account?: Account;
|
|
49
47
|
address: Address;
|
|
50
48
|
functionName: string;
|
|
51
49
|
args: CalldataEncodable[];
|
|
@@ -81,7 +79,7 @@ export const overrideContractActions = (client: GenLayerClient<Transport, Simula
|
|
|
81
79
|
return result;
|
|
82
80
|
};
|
|
83
81
|
|
|
84
|
-
client.deployContract = async (args: {account
|
|
82
|
+
client.deployContract = async (args: {account?: Account; code: string; args: CalldataEncodable[]}) => {
|
|
85
83
|
const {account, code, args: constructorArgs} = args;
|
|
86
84
|
const data = [code, encode({args: constructorArgs})];
|
|
87
85
|
const serializedData = serialize(data);
|
|
@@ -2,13 +2,9 @@ import {GenLayerClient} from "../types/clients";
|
|
|
2
2
|
import {TransactionHash, TransactionStatus, GenLayerTransaction} from "../types/transactions";
|
|
3
3
|
import {transactionsConfig} from "../config/transactions";
|
|
4
4
|
import {sleep} from "../utils/async";
|
|
5
|
-
import {ITransactionActions} from "./ITransactionActions";
|
|
6
|
-
import {Account, Transport} from "viem";
|
|
7
5
|
import {SimulatorChain} from "@/types";
|
|
8
6
|
|
|
9
|
-
export const transactionActions = (
|
|
10
|
-
client: GenLayerClient<Transport, SimulatorChain, Account>,
|
|
11
|
-
): ITransactionActions => ({
|
|
7
|
+
export const transactionActions = (client: GenLayerClient<SimulatorChain>) => ({
|
|
12
8
|
waitForTransactionReceipt: async ({
|
|
13
9
|
hash,
|
|
14
10
|
status = TransactionStatus.FINALIZED,
|
|
@@ -20,7 +16,7 @@ export const transactionActions = (
|
|
|
20
16
|
interval?: number;
|
|
21
17
|
retries?: number;
|
|
22
18
|
}): Promise<GenLayerTransaction> => {
|
|
23
|
-
const transaction =
|
|
19
|
+
const transaction = await client.getTransaction({hash});
|
|
24
20
|
|
|
25
21
|
if (!transaction) {
|
|
26
22
|
throw new Error("Transaction not found");
|
package/src/types/accounts.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {Account} from "viem";
|
|
1
|
+
export type {Account} from "viem";
|
|
2
2
|
export type Address = `0x${string}` & {length: 42};
|
package/src/types/clients.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {GenLayerTransaction, TransactionHash} from "./transactions";
|
|
1
|
+
import {Transport, Client, PublicActions} from "viem";
|
|
2
|
+
import {GenLayerTransaction, TransactionHash, TransactionStatus} from "./transactions";
|
|
3
3
|
import {SimulatorChain} from "./chains";
|
|
4
|
-
import {Address} from "./accounts";
|
|
4
|
+
import {Address, Account} from "./accounts";
|
|
5
5
|
import {CalldataEncodable} from "./calldata";
|
|
6
6
|
|
|
7
7
|
export type GenLayerMethod =
|
|
@@ -13,30 +13,40 @@ export type GenLayerMethod =
|
|
|
13
13
|
| {method: "gen_getContractSchemaForCode"; params: [contractCode: string]}
|
|
14
14
|
| {method: "eth_getTransactionCount"; params: [address: string]};
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
/*
|
|
17
|
+
Take all the properties from PublicActions<Transport, TSimulatorChain>
|
|
18
|
+
Remove the transport, readContract, and getTransaction properties
|
|
19
|
+
The resulting type will have everything from PublicActions EXCEPT those
|
|
20
|
+
two properties which are added later
|
|
21
|
+
*/
|
|
22
|
+
export type GenLayerClient<TSimulatorChain extends SimulatorChain> = Omit<
|
|
23
|
+
Client<Transport, TSimulatorChain>,
|
|
24
|
+
"transport" | "getTransaction" | "readContract"
|
|
25
|
+
> &
|
|
26
|
+
Omit<PublicActions<Transport, TSimulatorChain>, "readContract" | "getTransaction"> & {
|
|
27
|
+
request: Client<Transport, TSimulatorChain>["request"] & {
|
|
28
|
+
<TMethod extends GenLayerMethod>(
|
|
29
|
+
args: Extract<GenLayerMethod, {method: TMethod["method"]}>,
|
|
30
|
+
): Promise<unknown>;
|
|
31
|
+
};
|
|
32
|
+
readContract: (args: {
|
|
33
|
+
account?: Account;
|
|
34
|
+
address: Address;
|
|
35
|
+
functionName: string;
|
|
36
|
+
args: CalldataEncodable[];
|
|
37
|
+
}) => Promise<any>;
|
|
38
|
+
writeContract: (args: {
|
|
39
|
+
account?: Account;
|
|
40
|
+
address: Address;
|
|
41
|
+
functionName: string;
|
|
42
|
+
args: CalldataEncodable[];
|
|
43
|
+
value: bigint;
|
|
44
|
+
}) => Promise<any>;
|
|
45
|
+
deployContract: (args: {account?: Account; code: string; args: CalldataEncodable[]}) => Promise<any>;
|
|
46
|
+
getTransaction: (args: {hash: TransactionHash}) => Promise<GenLayerTransaction>;
|
|
47
|
+
getCurrentNonce: (args: {address: string}) => Promise<number>;
|
|
48
|
+
waitForTransactionReceipt: (args: {
|
|
49
|
+
hash: TransactionHash;
|
|
50
|
+
status?: TransactionStatus;
|
|
51
|
+
}) => Promise<GenLayerTransaction>;
|
|
25
52
|
};
|
|
26
|
-
readContract: (args: {
|
|
27
|
-
account: Account;
|
|
28
|
-
address: Address;
|
|
29
|
-
functionName: string;
|
|
30
|
-
args: any[];
|
|
31
|
-
}) => Promise<any>;
|
|
32
|
-
writeContract: (args: {
|
|
33
|
-
account: Account;
|
|
34
|
-
address: Address;
|
|
35
|
-
functionName: string;
|
|
36
|
-
args: any[];
|
|
37
|
-
value: bigint;
|
|
38
|
-
}) => Promise<any>;
|
|
39
|
-
deployContract: (args: {account: Account; code: string; args: CalldataEncodable[]}) => Promise<any>;
|
|
40
|
-
getTransaction: (args: {hash: TransactionHash}) => Promise<GenLayerTransaction>;
|
|
41
|
-
getCurrentNonce: (args: {address: string}) => Promise<number>;
|
|
42
|
-
};
|