genlayer-js 0.9.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.
- package/CHANGELOG.md +2 -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 +3 -3
- package/dist/chains-BYSCF33g.d.cts +18 -0
- package/dist/chains-BYSCF33g.d.ts +18 -0
- package/dist/chunk-7YZQQWJZ.js +4056 -0
- package/dist/chunk-AZSICIZ3.cjs +132 -0
- package/dist/chunk-FPFZLPXI.cjs +4056 -0
- package/dist/chunk-RS7NCSOQ.js +132 -0
- package/dist/index-BM9hOtGg.d.cts +13 -0
- package/dist/index-C7Colsnk.d.ts +13 -0
- package/dist/index-DvSbRKD5.d.ts +370 -0
- package/dist/index-kDM_9wW1.d.cts +370 -0
- package/dist/index.cjs +315 -130
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +306 -121
- package/dist/types/index.cjs +18 -2
- package/dist/types/index.d.cts +3 -3
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.js +19 -3
- package/package.json +2 -2
- package/src/accounts/IAccountActions.ts +2 -2
- package/src/accounts/actions.ts +10 -4
- package/src/chains/actions.ts +5 -5
- package/src/chains/index.ts +1 -1
- package/src/chains/localnet.ts +4 -3
- package/src/chains/testnet.ts +4015 -0
- package/src/client/client.ts +64 -21
- package/src/contracts/actions.ts +185 -137
- package/src/transactions/actions.ts +145 -21
- package/src/types/accounts.ts +1 -2
- package/src/types/chains.ts +8 -2
- package/src/types/clients.ts +14 -13
- package/src/types/transactions.ts +249 -8
- package/src/wallet/actions.ts +4 -4
- package/src/wallet/connect.ts +12 -14
- package/tests/client.test.ts +105 -45
- package/dist/chains-C5PI_Nr_.d.cts +0 -13
- package/dist/chains-C5PI_Nr_.d.ts +0 -13
- package/dist/chunk-I6HC44KD.cjs +0 -72
- package/dist/chunk-K72OSU5N.js +0 -28
- package/dist/chunk-WEXFFND6.js +0 -72
- package/dist/chunk-YDFRDDP5.cjs +0 -28
- package/dist/index-B8E0qiOq.d.cts +0 -13
- package/dist/index-BCbofn6t.d.cts +0 -188
- package/dist/index-Ctmshvtv.d.ts +0 -188
- package/dist/index-ZoW0HQ_m.d.ts +0 -13
- package/src/chains/simulator.ts +0 -30
package/tests/client.test.ts
CHANGED
|
@@ -6,6 +6,13 @@ import {createAccount, generatePrivateKey} from "../src/accounts/account";
|
|
|
6
6
|
import {vi} from "vitest";
|
|
7
7
|
import {TransactionStatus} from "../src/types/transactions";
|
|
8
8
|
|
|
9
|
+
// Setup fetch mock
|
|
10
|
+
const mockFetch = vi.fn();
|
|
11
|
+
vi.stubGlobal("fetch", mockFetch);
|
|
12
|
+
|
|
13
|
+
// Store for gen_call parameters received by mockFetch
|
|
14
|
+
let lastGenCallParams: any = null;
|
|
15
|
+
|
|
9
16
|
describe("Client Creation", () => {
|
|
10
17
|
it("should create a client for the localnet", () => {
|
|
11
18
|
const client = createClient({chain: localnet});
|
|
@@ -15,6 +22,65 @@ describe("Client Creation", () => {
|
|
|
15
22
|
});
|
|
16
23
|
|
|
17
24
|
describe("Client Overrides", () => {
|
|
25
|
+
beforeEach(() => {
|
|
26
|
+
mockFetch.mockReset();
|
|
27
|
+
lastGenCallParams = null; // Reset for each test
|
|
28
|
+
|
|
29
|
+
mockFetch.mockImplementation(async (url, options) => {
|
|
30
|
+
let body = {};
|
|
31
|
+
const bodyString = typeof options?.body === "string" ? options.body : null;
|
|
32
|
+
|
|
33
|
+
if (bodyString) {
|
|
34
|
+
try {
|
|
35
|
+
body = JSON.parse(bodyString);
|
|
36
|
+
} catch (e) {
|
|
37
|
+
console.error("[TESTS] mockFetch: Failed to parse bodyString:", bodyString, "Error:", e);
|
|
38
|
+
// Return a generic error if body parsing fails
|
|
39
|
+
return {
|
|
40
|
+
ok: false,
|
|
41
|
+
status: 500,
|
|
42
|
+
json: async () => ({error: {message: "mockFetch body parse error"}}),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const method = (body as any).method;
|
|
48
|
+
// console.log(`[TESTS] mockFetch called: URL=${url}, Method=${method}, Body=`, body); // Optional: keep for debugging
|
|
49
|
+
|
|
50
|
+
if (method === "sim_getConsensusContract") {
|
|
51
|
+
// console.log("[TESTS] mockFetch: Handling sim_getConsensusContract");
|
|
52
|
+
return {
|
|
53
|
+
ok: true,
|
|
54
|
+
json: async () => ({
|
|
55
|
+
result: {
|
|
56
|
+
address: "0x0000000000000000000000000000000000000001",
|
|
57
|
+
abi: [],
|
|
58
|
+
},
|
|
59
|
+
}),
|
|
60
|
+
};
|
|
61
|
+
} else if (method === "gen_call") {
|
|
62
|
+
// console.log("[TESTS] mockFetch: Handling gen_call");
|
|
63
|
+
lastGenCallParams = (body as any).params; // Store the params for gen_call
|
|
64
|
+
return {
|
|
65
|
+
ok: true,
|
|
66
|
+
json: async () => ({result: "0"}),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
console.warn(`[TESTS] mockFetch: Unhandled method - URL=${url}, Method=${method}, Body=`, body);
|
|
71
|
+
return {
|
|
72
|
+
ok: false,
|
|
73
|
+
status: 404, // Not Found for unhandled methods
|
|
74
|
+
json: async () => ({error: {message: `Unexpected fetch mock call to method: ${method}`}}),
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
afterEach(() => {
|
|
80
|
+
// Restore any spies if they weren't restored in tests
|
|
81
|
+
vi.restoreAllMocks();
|
|
82
|
+
});
|
|
83
|
+
|
|
18
84
|
it("should default to client account if no account is provided", async () => {
|
|
19
85
|
const account = createAccount(generatePrivateKey());
|
|
20
86
|
const client = createClient({
|
|
@@ -22,41 +88,37 @@ describe("Client Overrides", () => {
|
|
|
22
88
|
account: account,
|
|
23
89
|
});
|
|
24
90
|
|
|
25
|
-
//
|
|
26
|
-
vi.spyOn(client, "request").mockResolvedValue("0x00");
|
|
91
|
+
// const requestSpy = vi.spyOn(client, "request"); // Removed spy
|
|
27
92
|
|
|
28
93
|
const contractAddress = "0x1234567890123456789012345678901234567890";
|
|
29
94
|
await client.readContract({
|
|
30
95
|
address: contractAddress as Address,
|
|
31
96
|
functionName: "testFunction",
|
|
32
97
|
args: ["arg1", "arg2"],
|
|
33
|
-
stateStatus: TransactionStatus.ACCEPTED,
|
|
98
|
+
stateStatus: TransactionStatus.ACCEPTED, // Kept as is, matches type, ignored by current gen_call impl.
|
|
34
99
|
});
|
|
35
100
|
|
|
36
|
-
expect(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
],
|
|
46
|
-
});
|
|
101
|
+
expect(lastGenCallParams).toEqual([
|
|
102
|
+
{
|
|
103
|
+
type: "read",
|
|
104
|
+
to: contractAddress,
|
|
105
|
+
from: account.address,
|
|
106
|
+
data: expect.any(String), // The data is complex, checking type is often sufficient
|
|
107
|
+
transaction_hash_variant: "latest-final",
|
|
108
|
+
},
|
|
109
|
+
]);
|
|
47
110
|
});
|
|
48
111
|
|
|
49
112
|
it("should override client account if account is provided", async () => {
|
|
50
|
-
const
|
|
113
|
+
const clientInternalAccount = createAccount(generatePrivateKey()); // Renamed for clarity
|
|
51
114
|
const client = createClient({
|
|
52
115
|
chain: localnet,
|
|
53
|
-
account,
|
|
116
|
+
account: clientInternalAccount,
|
|
54
117
|
});
|
|
55
118
|
|
|
56
119
|
const overrideAccount = createAccount(generatePrivateKey());
|
|
57
120
|
|
|
58
|
-
//
|
|
59
|
-
vi.spyOn(client, "request").mockResolvedValue("0x00");
|
|
121
|
+
// const requestSpy = vi.spyOn(client, "request"); // Removed spy
|
|
60
122
|
|
|
61
123
|
const contractAddress = "0x1234567890123456789012345678901234567890";
|
|
62
124
|
await client.readContract({
|
|
@@ -67,45 +129,43 @@ describe("Client Overrides", () => {
|
|
|
67
129
|
stateStatus: TransactionStatus.ACCEPTED,
|
|
68
130
|
});
|
|
69
131
|
|
|
70
|
-
expect(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
],
|
|
80
|
-
});
|
|
132
|
+
expect(lastGenCallParams).toEqual([
|
|
133
|
+
{
|
|
134
|
+
type: "read",
|
|
135
|
+
to: contractAddress,
|
|
136
|
+
from: overrideAccount.address,
|
|
137
|
+
data: expect.any(String),
|
|
138
|
+
transaction_hash_variant: "latest-final",
|
|
139
|
+
},
|
|
140
|
+
]);
|
|
81
141
|
});
|
|
82
|
-
|
|
83
|
-
|
|
142
|
+
|
|
143
|
+
it("should use client account if account is an address string and no override", async () => {
|
|
144
|
+
// Clarified title
|
|
145
|
+
const accountAddressString = "0x65e03a3e916CF1dC92d3C8E8186a89CfAB0D2bc2";
|
|
84
146
|
const client = createClient({
|
|
85
147
|
chain: localnet,
|
|
86
|
-
account,
|
|
148
|
+
account: accountAddressString, // Client's account is an address string
|
|
87
149
|
});
|
|
88
150
|
|
|
89
|
-
//
|
|
90
|
-
vi.spyOn(client, "request").mockResolvedValue("0x00");
|
|
151
|
+
// const requestSpy = vi.spyOn(client, "request"); // Removed spy
|
|
91
152
|
|
|
92
153
|
const contractAddress = "0x1234567890123456789012345678901234567890";
|
|
93
154
|
await client.readContract({
|
|
94
155
|
address: contractAddress as Address,
|
|
95
156
|
functionName: "testFunction",
|
|
96
157
|
args: ["arg1", "arg2"],
|
|
158
|
+
// No stateStatus, no account override in this specific call to readContract
|
|
97
159
|
});
|
|
98
160
|
|
|
99
|
-
expect(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
],
|
|
109
|
-
});
|
|
161
|
+
expect(lastGenCallParams).toEqual([
|
|
162
|
+
{
|
|
163
|
+
type: "read",
|
|
164
|
+
to: contractAddress,
|
|
165
|
+
from: accountAddressString, // Expecting the address string directly
|
|
166
|
+
data: expect.any(String),
|
|
167
|
+
transaction_hash_variant: "latest-final",
|
|
168
|
+
},
|
|
169
|
+
]);
|
|
110
170
|
});
|
|
111
171
|
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Chain } from 'viem';
|
|
2
|
-
|
|
3
|
-
type SimulatorChain = Chain & {
|
|
4
|
-
consensusMainContract: {
|
|
5
|
-
address: string;
|
|
6
|
-
abi: any[];
|
|
7
|
-
bytecode: string;
|
|
8
|
-
} | null;
|
|
9
|
-
defaultNumberOfInitialValidators: number;
|
|
10
|
-
defaultConsensusMaxRotations: number;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export type { SimulatorChain as S };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Chain } from 'viem';
|
|
2
|
-
|
|
3
|
-
type SimulatorChain = Chain & {
|
|
4
|
-
consensusMainContract: {
|
|
5
|
-
address: string;
|
|
6
|
-
abi: any[];
|
|
7
|
-
bytecode: string;
|
|
8
|
-
} | null;
|
|
9
|
-
defaultNumberOfInitialValidators: number;
|
|
10
|
-
defaultConsensusMaxRotations: number;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export type { SimulatorChain as S };
|
package/dist/chunk-I6HC44KD.cjs
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _chunk75ZPJI57cjs = require('./chunk-75ZPJI57.cjs');
|
|
4
|
-
|
|
5
|
-
// src/chains/index.ts
|
|
6
|
-
var chains_exports = {};
|
|
7
|
-
_chunk75ZPJI57cjs.__export.call(void 0, chains_exports, {
|
|
8
|
-
localnet: () => localnet,
|
|
9
|
-
simulator: () => simulator
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
// src/chains/localnet.ts
|
|
13
|
-
var _viem = require('viem');
|
|
14
|
-
var SIMULATOR_JSON_RPC_URL = "http://127.0.0.1:4000/api";
|
|
15
|
-
var localnet = _viem.defineChain.call(void 0, {
|
|
16
|
-
id: 61999,
|
|
17
|
-
name: "Genlayer Localnet",
|
|
18
|
-
rpcUrls: {
|
|
19
|
-
default: {
|
|
20
|
-
http: [SIMULATOR_JSON_RPC_URL]
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
nativeCurrency: {
|
|
24
|
-
name: "GEN Token",
|
|
25
|
-
symbol: "GEN",
|
|
26
|
-
decimals: 18
|
|
27
|
-
},
|
|
28
|
-
blockExplorers: {
|
|
29
|
-
default: {
|
|
30
|
-
name: "GenLayer Explorer",
|
|
31
|
-
url: SIMULATOR_JSON_RPC_URL
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
testnet: true,
|
|
35
|
-
consensusMainContract: null,
|
|
36
|
-
defaultNumberOfInitialValidators: 5,
|
|
37
|
-
defaultConsensusMaxRotations: 3
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
// src/chains/simulator.ts
|
|
41
|
-
|
|
42
|
-
var SIMULATOR_JSON_RPC_URL2 = "http://127.0.0.1:4000/api";
|
|
43
|
-
var simulator = _viem.defineChain.call(void 0, {
|
|
44
|
-
id: 61999,
|
|
45
|
-
name: "GenLayer Simulator",
|
|
46
|
-
rpcUrls: {
|
|
47
|
-
default: {
|
|
48
|
-
http: [SIMULATOR_JSON_RPC_URL2]
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
nativeCurrency: {
|
|
52
|
-
name: "GEN Token",
|
|
53
|
-
symbol: "GEN",
|
|
54
|
-
decimals: 18
|
|
55
|
-
},
|
|
56
|
-
blockExplorers: {
|
|
57
|
-
default: {
|
|
58
|
-
name: "GenLayer Explorer",
|
|
59
|
-
url: SIMULATOR_JSON_RPC_URL2
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
testnet: true,
|
|
63
|
-
consensusMainContract: null,
|
|
64
|
-
defaultNumberOfInitialValidators: 5,
|
|
65
|
-
defaultConsensusMaxRotations: 3
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
exports.localnet = localnet; exports.simulator = simulator; exports.chains_exports = chains_exports;
|
package/dist/chunk-K72OSU5N.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// src/types/calldata.ts
|
|
2
|
-
var CalldataAddress = class {
|
|
3
|
-
bytes;
|
|
4
|
-
constructor(addr) {
|
|
5
|
-
if (addr.length != 20) {
|
|
6
|
-
throw new Error(`invalid address length ${addr}`);
|
|
7
|
-
}
|
|
8
|
-
this.bytes = addr;
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
// src/types/transactions.ts
|
|
13
|
-
var TransactionStatus = /* @__PURE__ */ ((TransactionStatus2) => {
|
|
14
|
-
TransactionStatus2["PENDING"] = "PENDING";
|
|
15
|
-
TransactionStatus2["CANCELED"] = "CANCELED";
|
|
16
|
-
TransactionStatus2["PROPOSING"] = "PROPOSING";
|
|
17
|
-
TransactionStatus2["COMMITTING"] = "COMMITTING";
|
|
18
|
-
TransactionStatus2["REVEALING"] = "REVEALING";
|
|
19
|
-
TransactionStatus2["ACCEPTED"] = "ACCEPTED";
|
|
20
|
-
TransactionStatus2["FINALIZED"] = "FINALIZED";
|
|
21
|
-
TransactionStatus2["UNDETERMINED"] = "UNDETERMINED";
|
|
22
|
-
return TransactionStatus2;
|
|
23
|
-
})(TransactionStatus || {});
|
|
24
|
-
|
|
25
|
-
export {
|
|
26
|
-
CalldataAddress,
|
|
27
|
-
TransactionStatus
|
|
28
|
-
};
|
package/dist/chunk-WEXFFND6.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__export
|
|
3
|
-
} from "./chunk-MLKGABMK.js";
|
|
4
|
-
|
|
5
|
-
// src/chains/index.ts
|
|
6
|
-
var chains_exports = {};
|
|
7
|
-
__export(chains_exports, {
|
|
8
|
-
localnet: () => localnet,
|
|
9
|
-
simulator: () => simulator
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
// src/chains/localnet.ts
|
|
13
|
-
import { defineChain } from "viem";
|
|
14
|
-
var SIMULATOR_JSON_RPC_URL = "http://127.0.0.1:4000/api";
|
|
15
|
-
var localnet = defineChain({
|
|
16
|
-
id: 61999,
|
|
17
|
-
name: "Genlayer Localnet",
|
|
18
|
-
rpcUrls: {
|
|
19
|
-
default: {
|
|
20
|
-
http: [SIMULATOR_JSON_RPC_URL]
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
nativeCurrency: {
|
|
24
|
-
name: "GEN Token",
|
|
25
|
-
symbol: "GEN",
|
|
26
|
-
decimals: 18
|
|
27
|
-
},
|
|
28
|
-
blockExplorers: {
|
|
29
|
-
default: {
|
|
30
|
-
name: "GenLayer Explorer",
|
|
31
|
-
url: SIMULATOR_JSON_RPC_URL
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
testnet: true,
|
|
35
|
-
consensusMainContract: null,
|
|
36
|
-
defaultNumberOfInitialValidators: 5,
|
|
37
|
-
defaultConsensusMaxRotations: 3
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
// src/chains/simulator.ts
|
|
41
|
-
import { defineChain as defineChain2 } from "viem";
|
|
42
|
-
var SIMULATOR_JSON_RPC_URL2 = "http://127.0.0.1:4000/api";
|
|
43
|
-
var simulator = defineChain2({
|
|
44
|
-
id: 61999,
|
|
45
|
-
name: "GenLayer Simulator",
|
|
46
|
-
rpcUrls: {
|
|
47
|
-
default: {
|
|
48
|
-
http: [SIMULATOR_JSON_RPC_URL2]
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
nativeCurrency: {
|
|
52
|
-
name: "GEN Token",
|
|
53
|
-
symbol: "GEN",
|
|
54
|
-
decimals: 18
|
|
55
|
-
},
|
|
56
|
-
blockExplorers: {
|
|
57
|
-
default: {
|
|
58
|
-
name: "GenLayer Explorer",
|
|
59
|
-
url: SIMULATOR_JSON_RPC_URL2
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
testnet: true,
|
|
63
|
-
consensusMainContract: null,
|
|
64
|
-
defaultNumberOfInitialValidators: 5,
|
|
65
|
-
defaultConsensusMaxRotations: 3
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
export {
|
|
69
|
-
localnet,
|
|
70
|
-
simulator,
|
|
71
|
-
chains_exports
|
|
72
|
-
};
|
package/dist/chunk-YDFRDDP5.cjs
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/types/calldata.ts
|
|
2
|
-
var CalldataAddress = class {
|
|
3
|
-
|
|
4
|
-
constructor(addr) {
|
|
5
|
-
if (addr.length != 20) {
|
|
6
|
-
throw new Error(`invalid address length ${addr}`);
|
|
7
|
-
}
|
|
8
|
-
this.bytes = addr;
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
// src/types/transactions.ts
|
|
13
|
-
var TransactionStatus = /* @__PURE__ */ ((TransactionStatus2) => {
|
|
14
|
-
TransactionStatus2["PENDING"] = "PENDING";
|
|
15
|
-
TransactionStatus2["CANCELED"] = "CANCELED";
|
|
16
|
-
TransactionStatus2["PROPOSING"] = "PROPOSING";
|
|
17
|
-
TransactionStatus2["COMMITTING"] = "COMMITTING";
|
|
18
|
-
TransactionStatus2["REVEALING"] = "REVEALING";
|
|
19
|
-
TransactionStatus2["ACCEPTED"] = "ACCEPTED";
|
|
20
|
-
TransactionStatus2["FINALIZED"] = "FINALIZED";
|
|
21
|
-
TransactionStatus2["UNDETERMINED"] = "UNDETERMINED";
|
|
22
|
-
return TransactionStatus2;
|
|
23
|
-
})(TransactionStatus || {});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
exports.CalldataAddress = CalldataAddress; exports.TransactionStatus = TransactionStatus;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { S as SimulatorChain } from './chains-C5PI_Nr_.cjs';
|
|
2
|
-
|
|
3
|
-
declare const localnet: SimulatorChain;
|
|
4
|
-
|
|
5
|
-
declare const simulator: SimulatorChain;
|
|
6
|
-
|
|
7
|
-
declare const index_localnet: typeof localnet;
|
|
8
|
-
declare const index_simulator: typeof simulator;
|
|
9
|
-
declare namespace index {
|
|
10
|
-
export { index_localnet as localnet, index_simulator as simulator };
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export { index as i, localnet as l, simulator as s };
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import { S as SimulatorChain } from './chains-C5PI_Nr_.cjs';
|
|
2
|
-
import { Client, Transport, WalletActions, PublicActions, Account } from 'viem';
|
|
3
|
-
|
|
4
|
-
type Address = `0x${string}` & {
|
|
5
|
-
length: 42;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
declare class CalldataAddress {
|
|
9
|
-
bytes: Uint8Array;
|
|
10
|
-
constructor(addr: Uint8Array);
|
|
11
|
-
}
|
|
12
|
-
type CalldataEncodable = null | boolean | CalldataAddress | number | bigint | string | Uint8Array | Array<CalldataEncodable> | Map<string, CalldataEncodable> | {
|
|
13
|
-
[key: string]: CalldataEncodable;
|
|
14
|
-
};
|
|
15
|
-
type MethodDescription = {
|
|
16
|
-
method: string;
|
|
17
|
-
args: Array<CalldataEncodable>;
|
|
18
|
-
};
|
|
19
|
-
type TransactionDataElement$1 = string | number | bigint | boolean | Uint8Array;
|
|
20
|
-
|
|
21
|
-
type TransactionHash = `0x${string}` & {
|
|
22
|
-
length: 66;
|
|
23
|
-
};
|
|
24
|
-
declare enum TransactionStatus {
|
|
25
|
-
PENDING = "PENDING",
|
|
26
|
-
CANCELED = "CANCELED",
|
|
27
|
-
PROPOSING = "PROPOSING",
|
|
28
|
-
COMMITTING = "COMMITTING",
|
|
29
|
-
REVEALING = "REVEALING",
|
|
30
|
-
ACCEPTED = "ACCEPTED",
|
|
31
|
-
FINALIZED = "FINALIZED",
|
|
32
|
-
UNDETERMINED = "UNDETERMINED"
|
|
33
|
-
}
|
|
34
|
-
type GenLayerTransaction = {
|
|
35
|
-
hash: TransactionHash;
|
|
36
|
-
status: TransactionStatus;
|
|
37
|
-
from_address?: string;
|
|
38
|
-
to_address?: string;
|
|
39
|
-
data?: Record<string, unknown>;
|
|
40
|
-
consensus_data?: {
|
|
41
|
-
final: boolean;
|
|
42
|
-
leader_receipt?: {
|
|
43
|
-
calldata: string;
|
|
44
|
-
class_name: string;
|
|
45
|
-
contract_state: string;
|
|
46
|
-
eq_outputs: Record<string, unknown>;
|
|
47
|
-
error: string | null;
|
|
48
|
-
execution_result: string;
|
|
49
|
-
gas_used: number;
|
|
50
|
-
mode: string;
|
|
51
|
-
node_config: Record<string, unknown>;
|
|
52
|
-
pending_transactions: unknown[];
|
|
53
|
-
vote: string;
|
|
54
|
-
result: string;
|
|
55
|
-
};
|
|
56
|
-
validators?: Record<string, unknown>[];
|
|
57
|
-
votes?: Record<string, string>;
|
|
58
|
-
};
|
|
59
|
-
nonce?: number;
|
|
60
|
-
value?: number;
|
|
61
|
-
type?: number;
|
|
62
|
-
gaslimit?: bigint;
|
|
63
|
-
created_at?: Date;
|
|
64
|
-
r?: number;
|
|
65
|
-
s?: number;
|
|
66
|
-
v?: number;
|
|
67
|
-
};
|
|
68
|
-
type TransactionDataElement = string | number | bigint | boolean | Uint8Array;
|
|
69
|
-
|
|
70
|
-
type ContractParamsArraySchemaElement = ContractParamsSchema | {
|
|
71
|
-
$rep: ContractParamsSchema;
|
|
72
|
-
};
|
|
73
|
-
type ContractParamsSchema = "null" | "bool" | "int" | "address" | "string" | "bytes" | "any" | "array" | "dict" | {
|
|
74
|
-
$or: ContractParamsSchema[];
|
|
75
|
-
} | {
|
|
76
|
-
$dict: ContractParamsSchema;
|
|
77
|
-
} | {
|
|
78
|
-
[key: string]: ContractParamsSchema;
|
|
79
|
-
} | ContractParamsArraySchemaElement[];
|
|
80
|
-
interface ContractMethodBase {
|
|
81
|
-
params: [string, ContractParamsSchema][];
|
|
82
|
-
kwparams: {
|
|
83
|
-
[key: string]: ContractParamsSchema;
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
interface ContractMethod extends ContractMethodBase {
|
|
87
|
-
ret: ContractParamsSchema;
|
|
88
|
-
readonly: boolean;
|
|
89
|
-
}
|
|
90
|
-
type ContractSchema = {
|
|
91
|
-
ctor: ContractMethodBase;
|
|
92
|
-
methods: ContractMethod[];
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
type Network = 'localnet' | 'testnet' | 'mainnet';
|
|
96
|
-
|
|
97
|
-
type SnapSource = 'npm' | 'local';
|
|
98
|
-
|
|
99
|
-
type MetaMaskClientResult = {
|
|
100
|
-
isFlask: boolean;
|
|
101
|
-
installedSnaps: Record<string, any>;
|
|
102
|
-
isGenLayerSnapInstalled: boolean;
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
type GenLayerMethod = {
|
|
106
|
-
method: "sim_fundAccount";
|
|
107
|
-
params: [address: string, amount: number];
|
|
108
|
-
} | {
|
|
109
|
-
method: "eth_getTransactionByHash";
|
|
110
|
-
params: [hash: TransactionHash];
|
|
111
|
-
} | {
|
|
112
|
-
method: "eth_call";
|
|
113
|
-
params: [requestParams: any, blockNumberOrHash: string];
|
|
114
|
-
} | {
|
|
115
|
-
method: "eth_sendRawTransaction";
|
|
116
|
-
params: [signedTransaction: string];
|
|
117
|
-
} | {
|
|
118
|
-
method: "gen_getContractSchema";
|
|
119
|
-
params: [address: string];
|
|
120
|
-
} | {
|
|
121
|
-
method: "gen_getContractSchemaForCode";
|
|
122
|
-
params: [contractCode: string];
|
|
123
|
-
} | {
|
|
124
|
-
method: "sim_getTransactionsForAddress";
|
|
125
|
-
params: [address: string, filter?: "all" | "from" | "to"];
|
|
126
|
-
} | {
|
|
127
|
-
method: "eth_getTransactionCount";
|
|
128
|
-
params: [address: string, block: string];
|
|
129
|
-
};
|
|
130
|
-
type GenLayerClient<TSimulatorChain extends SimulatorChain> = Omit<Client<Transport, TSimulatorChain>, "transport" | "getTransaction" | "readContract"> & Omit<WalletActions<TSimulatorChain>, "deployContract" | "writeContract"> & Omit<PublicActions<Transport, TSimulatorChain>, "readContract" | "getTransaction" | "waitForTransactionReceipt"> & {
|
|
131
|
-
request: Client<Transport, TSimulatorChain>["request"] & {
|
|
132
|
-
<TMethod extends GenLayerMethod>(args: Extract<GenLayerMethod, {
|
|
133
|
-
method: TMethod["method"];
|
|
134
|
-
}>): Promise<unknown>;
|
|
135
|
-
};
|
|
136
|
-
readContract: <RawReturn extends boolean | undefined>(args: {
|
|
137
|
-
account?: Account;
|
|
138
|
-
address: Address;
|
|
139
|
-
functionName: string;
|
|
140
|
-
stateStatus?: TransactionStatus;
|
|
141
|
-
args?: CalldataEncodable[];
|
|
142
|
-
kwargs?: Map<string, CalldataEncodable> | {
|
|
143
|
-
[key: string]: CalldataEncodable;
|
|
144
|
-
};
|
|
145
|
-
rawReturn?: RawReturn;
|
|
146
|
-
}) => Promise<RawReturn extends true ? `0x${string}` : CalldataEncodable>;
|
|
147
|
-
writeContract: (args: {
|
|
148
|
-
account?: Account;
|
|
149
|
-
address: Address;
|
|
150
|
-
functionName: string;
|
|
151
|
-
args?: CalldataEncodable[];
|
|
152
|
-
kwargs?: Map<string, CalldataEncodable> | {
|
|
153
|
-
[key: string]: CalldataEncodable;
|
|
154
|
-
};
|
|
155
|
-
value: bigint;
|
|
156
|
-
leaderOnly?: boolean;
|
|
157
|
-
consensusMaxRotations?: number;
|
|
158
|
-
}) => Promise<any>;
|
|
159
|
-
deployContract: (args: {
|
|
160
|
-
account?: Account;
|
|
161
|
-
code: string | Uint8Array;
|
|
162
|
-
args?: CalldataEncodable[];
|
|
163
|
-
kwargs?: Map<string, CalldataEncodable> | {
|
|
164
|
-
[key: string]: CalldataEncodable;
|
|
165
|
-
};
|
|
166
|
-
leaderOnly?: boolean;
|
|
167
|
-
consensusMaxRotations?: number;
|
|
168
|
-
}) => Promise<`0x${string}`>;
|
|
169
|
-
getTransaction: (args: {
|
|
170
|
-
hash: TransactionHash;
|
|
171
|
-
}) => Promise<GenLayerTransaction>;
|
|
172
|
-
getCurrentNonce: (args: {
|
|
173
|
-
address: string;
|
|
174
|
-
}) => Promise<number>;
|
|
175
|
-
waitForTransactionReceipt: (args: {
|
|
176
|
-
hash: TransactionHash;
|
|
177
|
-
status?: TransactionStatus;
|
|
178
|
-
interval?: number;
|
|
179
|
-
retries?: number;
|
|
180
|
-
}) => Promise<GenLayerTransaction>;
|
|
181
|
-
getContractSchema: (address: string) => Promise<ContractSchema>;
|
|
182
|
-
getContractSchemaForCode: (contractCode: string | Uint8Array) => Promise<ContractSchema>;
|
|
183
|
-
initializeConsensusSmartContract: (forceReset?: boolean) => Promise<void>;
|
|
184
|
-
connect: (network?: Network, snapSource?: SnapSource) => Promise<void>;
|
|
185
|
-
metamaskClient: (snapSource?: SnapSource) => Promise<MetaMaskClientResult>;
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
export { type Address as A, type CalldataEncodable as C, type GenLayerClient as G, type MethodDescription as M, type Network as N, type SnapSource as S, type TransactionDataElement$1 as T, CalldataAddress as a, type GenLayerMethod as b, type ContractParamsArraySchemaElement as c, type ContractParamsSchema as d, type ContractMethodBase as e, type ContractMethod as f, type ContractSchema as g, type TransactionHash as h, TransactionStatus as i, type GenLayerTransaction as j, type TransactionDataElement as k };
|