genlayer-js 0.18.10 → 0.18.12
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/dist/chains/index.cjs +2 -2
- package/dist/chains/index.js +1 -1
- package/dist/{chunk-PPBY3UXF.cjs → chunk-5TKVNHAO.cjs} +1118 -305
- package/dist/{chunk-WZNF2WK4.js → chunk-NOFMB7RP.js} +1118 -305
- package/dist/{index-D9ONjYgl.d.cts → index-DsN7LGHA.d.cts} +1615 -459
- package/dist/{index-ZDqJWXj0.d.ts → index-sw3NAvBf.d.ts} +1615 -459
- package/dist/index.cjs +58 -58
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +28 -28
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +11 -1
- package/.eslintignore +0 -2
- package/.eslintrc.cjs +0 -59
- package/.github/pull_request_template.md +0 -43
- package/.github/workflows/publish.yml +0 -41
- package/.github/workflows/test.yml +0 -33
- package/.prettierignore +0 -19
- package/.prettierrc +0 -12
- package/.release-it.json +0 -64
- package/CHANGELOG.md +0 -304
- package/CLAUDE.md +0 -66
- package/CONTRIBUTING.md +0 -87
- package/renovate.json +0 -20
- package/src/abi/calldata/consts.ts +0 -14
- package/src/abi/calldata/decoder.ts +0 -86
- package/src/abi/calldata/encoder.ts +0 -178
- package/src/abi/calldata/index.ts +0 -3
- package/src/abi/calldata/string.ts +0 -83
- package/src/abi/index.ts +0 -6
- package/src/abi/staking.ts +0 -687
- package/src/abi/transactions.ts +0 -11
- package/src/accounts/IAccountActions.ts +0 -5
- package/src/accounts/account.ts +0 -9
- package/src/accounts/actions.ts +0 -34
- package/src/chains/actions.ts +0 -40
- package/src/chains/index.ts +0 -4
- package/src/chains/localnet.ts +0 -4016
- package/src/chains/studionet.ts +0 -4017
- package/src/chains/testnetAsimov.ts +0 -4013
- package/src/client/client.ts +0 -139
- package/src/config/snapID.ts +0 -4
- package/src/config/transactions.ts +0 -9
- package/src/contracts/actions.ts +0 -387
- package/src/global.d.ts +0 -9
- package/src/index.ts +0 -12
- package/src/staking/actions.ts +0 -691
- package/src/staking/index.ts +0 -2
- package/src/staking/utils.ts +0 -22
- package/src/transactions/ITransactionActions.ts +0 -15
- package/src/transactions/actions.ts +0 -113
- package/src/transactions/decoders.ts +0 -275
- package/src/types/accounts.ts +0 -1
- package/src/types/calldata.ts +0 -31
- package/src/types/chains.ts +0 -22
- package/src/types/clients.ts +0 -106
- package/src/types/contracts.ts +0 -32
- package/src/types/index.ts +0 -9
- package/src/types/metamaskClientResult.ts +0 -5
- package/src/types/network.ts +0 -1
- package/src/types/snapSource.ts +0 -1
- package/src/types/staking.ts +0 -225
- package/src/types/transactions.ts +0 -312
- package/src/utils/async.ts +0 -3
- package/src/utils/jsonifier.ts +0 -119
- package/src/wallet/actions.ts +0 -10
- package/src/wallet/connect.ts +0 -67
- package/src/wallet/metamaskClient.ts +0 -50
- package/tests/client.test-d.ts +0 -67
- package/tests/client.test.ts +0 -197
- package/tests/smoke.test.ts +0 -59
- package/tests/transactions.test.ts +0 -142
- package/tsconfig.json +0 -119
- package/tsconfig.vitest-temp.json +0 -41
- package/vitest.config.ts +0 -18
package/src/types/staking.ts
DELETED
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
import {Address} from "./accounts";
|
|
2
|
-
import {GetContractReturnType, PublicClient, Client, Transport, Chain, Account, Address as ViemAddress} from "viem";
|
|
3
|
-
import {STAKING_ABI} from "@/abi/staking";
|
|
4
|
-
|
|
5
|
-
type WalletClientWithAccount = Client<Transport, Chain, Account>;
|
|
6
|
-
|
|
7
|
-
type StakingKeyedClient = {
|
|
8
|
-
public: PublicClient;
|
|
9
|
-
wallet: WalletClientWithAccount;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export type StakingContract = GetContractReturnType<
|
|
13
|
-
typeof STAKING_ABI,
|
|
14
|
-
StakingKeyedClient,
|
|
15
|
-
ViemAddress
|
|
16
|
-
>;
|
|
17
|
-
|
|
18
|
-
export interface ValidatorView {
|
|
19
|
-
left: Address;
|
|
20
|
-
right: Address;
|
|
21
|
-
parent: Address;
|
|
22
|
-
eBanned: bigint;
|
|
23
|
-
ePrimed: bigint;
|
|
24
|
-
vStake: bigint;
|
|
25
|
-
vShares: bigint;
|
|
26
|
-
dStake: bigint;
|
|
27
|
-
dShares: bigint;
|
|
28
|
-
vDeposit: bigint;
|
|
29
|
-
vWithdrawal: bigint;
|
|
30
|
-
live: boolean;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface ValidatorIdentity {
|
|
34
|
-
moniker: string;
|
|
35
|
-
logoUri: string;
|
|
36
|
-
website: string;
|
|
37
|
-
description: string;
|
|
38
|
-
email: string;
|
|
39
|
-
twitter: string;
|
|
40
|
-
telegram: string;
|
|
41
|
-
github: string;
|
|
42
|
-
extraCid: string;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface ValidatorInfo {
|
|
46
|
-
address: Address;
|
|
47
|
-
owner: Address;
|
|
48
|
-
operator: Address;
|
|
49
|
-
vStake: string;
|
|
50
|
-
vStakeRaw: bigint;
|
|
51
|
-
vShares: bigint;
|
|
52
|
-
dStake: string;
|
|
53
|
-
dStakeRaw: bigint;
|
|
54
|
-
dShares: bigint;
|
|
55
|
-
vDeposit: string;
|
|
56
|
-
vDepositRaw: bigint;
|
|
57
|
-
vWithdrawal: string;
|
|
58
|
-
vWithdrawalRaw: bigint;
|
|
59
|
-
ePrimed: bigint;
|
|
60
|
-
live: boolean;
|
|
61
|
-
banned: boolean;
|
|
62
|
-
bannedEpoch?: bigint;
|
|
63
|
-
needsPriming: boolean;
|
|
64
|
-
identity?: ValidatorIdentity;
|
|
65
|
-
pendingDeposits: PendingDeposit[];
|
|
66
|
-
pendingWithdrawals: PendingWithdrawal[];
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export interface WithdrawalCommit {
|
|
70
|
-
input: bigint;
|
|
71
|
-
output: bigint;
|
|
72
|
-
epoch: bigint;
|
|
73
|
-
linkToNextCommit: bigint;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export interface PendingDeposit {
|
|
77
|
-
epoch: bigint;
|
|
78
|
-
stake: string;
|
|
79
|
-
stakeRaw: bigint;
|
|
80
|
-
shares: bigint;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export interface PendingWithdrawal {
|
|
84
|
-
epoch: bigint;
|
|
85
|
-
shares: bigint;
|
|
86
|
-
stake: string;
|
|
87
|
-
stakeRaw: bigint;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export interface BannedValidatorInfo {
|
|
91
|
-
validator: Address;
|
|
92
|
-
untilEpoch: bigint;
|
|
93
|
-
permanentlyBanned: boolean;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export interface StakeInfo {
|
|
97
|
-
delegator: Address;
|
|
98
|
-
validator: Address;
|
|
99
|
-
shares: bigint;
|
|
100
|
-
stake: string;
|
|
101
|
-
stakeRaw: bigint;
|
|
102
|
-
pendingDeposits: PendingDeposit[];
|
|
103
|
-
pendingWithdrawals: PendingWithdrawal[];
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export interface EpochData {
|
|
107
|
-
start: bigint;
|
|
108
|
-
end: bigint;
|
|
109
|
-
inflation: bigint;
|
|
110
|
-
weight: bigint;
|
|
111
|
-
weightDeposit: bigint;
|
|
112
|
-
weightWithdrawal: bigint;
|
|
113
|
-
vcount: bigint;
|
|
114
|
-
claimed: bigint;
|
|
115
|
-
stakeDeposit: bigint;
|
|
116
|
-
stakeWithdrawal: bigint;
|
|
117
|
-
slashed: bigint;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export interface EpochInfo {
|
|
121
|
-
currentEpoch: bigint;
|
|
122
|
-
lastFinalizedEpoch: bigint;
|
|
123
|
-
validatorMinStake: string;
|
|
124
|
-
validatorMinStakeRaw: bigint;
|
|
125
|
-
delegatorMinStake: string;
|
|
126
|
-
delegatorMinStakeRaw: bigint;
|
|
127
|
-
activeValidatorsCount: bigint;
|
|
128
|
-
epochMinDuration: bigint;
|
|
129
|
-
nextEpochEstimate: Date | null;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export interface StakingTransactionResult {
|
|
133
|
-
transactionHash: `0x${string}`;
|
|
134
|
-
blockNumber: bigint;
|
|
135
|
-
gasUsed: bigint;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export interface ValidatorJoinResult extends StakingTransactionResult {
|
|
139
|
-
validatorWallet: Address;
|
|
140
|
-
operator: Address;
|
|
141
|
-
amount: string;
|
|
142
|
-
amountRaw: bigint;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export interface DelegatorJoinResult extends StakingTransactionResult {
|
|
146
|
-
validator: Address;
|
|
147
|
-
delegator: Address;
|
|
148
|
-
amount: string;
|
|
149
|
-
amountRaw: bigint;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export interface ValidatorJoinOptions {
|
|
153
|
-
amount: bigint | string;
|
|
154
|
-
operator?: Address;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export interface ValidatorDepositOptions {
|
|
158
|
-
amount: bigint | string;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
export interface ValidatorExitOptions {
|
|
162
|
-
shares: bigint | string;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
export interface ValidatorClaimOptions {
|
|
166
|
-
validator?: Address;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
export interface ValidatorPrimeOptions {
|
|
170
|
-
validator: Address;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
export interface SetOperatorOptions {
|
|
174
|
-
validator: Address;
|
|
175
|
-
operator: Address;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
export interface SetIdentityOptions {
|
|
179
|
-
validator: Address;
|
|
180
|
-
moniker: string;
|
|
181
|
-
logoUri?: string;
|
|
182
|
-
website?: string;
|
|
183
|
-
description?: string;
|
|
184
|
-
email?: string;
|
|
185
|
-
twitter?: string;
|
|
186
|
-
telegram?: string;
|
|
187
|
-
github?: string;
|
|
188
|
-
extraCid?: string;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
export interface DelegatorJoinOptions {
|
|
192
|
-
validator: Address;
|
|
193
|
-
amount: bigint | string;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
export interface DelegatorExitOptions {
|
|
197
|
-
validator: Address;
|
|
198
|
-
shares: bigint | string;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
export interface DelegatorClaimOptions {
|
|
202
|
-
validator: Address;
|
|
203
|
-
delegator?: Address;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
export interface StakingActions {
|
|
207
|
-
validatorJoin: (options: ValidatorJoinOptions) => Promise<ValidatorJoinResult>;
|
|
208
|
-
validatorDeposit: (options: ValidatorDepositOptions) => Promise<StakingTransactionResult>;
|
|
209
|
-
validatorExit: (options: ValidatorExitOptions) => Promise<StakingTransactionResult>;
|
|
210
|
-
validatorClaim: (options?: ValidatorClaimOptions) => Promise<StakingTransactionResult & {claimedAmount: bigint}>;
|
|
211
|
-
delegatorJoin: (options: DelegatorJoinOptions) => Promise<DelegatorJoinResult>;
|
|
212
|
-
delegatorExit: (options: DelegatorExitOptions) => Promise<StakingTransactionResult>;
|
|
213
|
-
delegatorClaim: (options: DelegatorClaimOptions) => Promise<StakingTransactionResult>;
|
|
214
|
-
isValidator: (address: Address) => Promise<boolean>;
|
|
215
|
-
getValidatorInfo: (validator: Address) => Promise<ValidatorInfo>;
|
|
216
|
-
getStakeInfo: (delegator: Address, validator: Address) => Promise<StakeInfo>;
|
|
217
|
-
getEpochInfo: () => Promise<EpochInfo>;
|
|
218
|
-
getEpochData: (epochNumber: bigint) => Promise<EpochData>;
|
|
219
|
-
getActiveValidators: () => Promise<Address[]>;
|
|
220
|
-
getActiveValidatorsCount: () => Promise<bigint>;
|
|
221
|
-
getSlashingAddress: () => Promise<Address>;
|
|
222
|
-
getStakingContract: () => StakingContract;
|
|
223
|
-
parseStakingAmount: (amount: string | bigint) => bigint;
|
|
224
|
-
formatStakingAmount: (amount: bigint) => string;
|
|
225
|
-
}
|
|
@@ -1,312 +0,0 @@
|
|
|
1
|
-
import {Hex} from "viem";
|
|
2
|
-
import {Address} from "./accounts";
|
|
3
|
-
|
|
4
|
-
export type Hash = `0x${string}` & {length: 66};
|
|
5
|
-
export type TransactionHash = Hash;
|
|
6
|
-
|
|
7
|
-
export enum TransactionStatus {
|
|
8
|
-
UNINITIALIZED = "UNINITIALIZED",
|
|
9
|
-
PENDING = "PENDING",
|
|
10
|
-
PROPOSING = "PROPOSING",
|
|
11
|
-
COMMITTING = "COMMITTING",
|
|
12
|
-
REVEALING = "REVEALING",
|
|
13
|
-
ACCEPTED = "ACCEPTED",
|
|
14
|
-
UNDETERMINED = "UNDETERMINED",
|
|
15
|
-
FINALIZED = "FINALIZED",
|
|
16
|
-
CANCELED = "CANCELED",
|
|
17
|
-
APPEAL_REVEALING = "APPEAL_REVEALING",
|
|
18
|
-
APPEAL_COMMITTING = "APPEAL_COMMITTING",
|
|
19
|
-
READY_TO_FINALIZE = "READY_TO_FINALIZE",
|
|
20
|
-
VALIDATORS_TIMEOUT = "VALIDATORS_TIMEOUT",
|
|
21
|
-
LEADER_TIMEOUT = "LEADER_TIMEOUT",
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export enum TransactionResult {
|
|
25
|
-
SUCCESS = "SUCCESS",
|
|
26
|
-
FAILURE = "FAILURE",
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export enum TransactionResult {
|
|
30
|
-
IDLE = "IDLE",
|
|
31
|
-
AGREE = "AGREE",
|
|
32
|
-
DISAGREE = "DISAGREE",
|
|
33
|
-
TIMEOUT = "TIMEOUT",
|
|
34
|
-
DETERMINISTIC_VIOLATION = "DETERMINISTIC_VIOLATION",
|
|
35
|
-
NO_MAJORITY = "NO_MAJORITY",
|
|
36
|
-
MAJORITY_AGREE = "MAJORITY_AGREE",
|
|
37
|
-
MAJORITY_DISAGREE = "MAJORITY_DISAGREE",
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export const transactionsStatusNumberToName = {
|
|
41
|
-
"0": TransactionStatus.UNINITIALIZED,
|
|
42
|
-
"1": TransactionStatus.PENDING,
|
|
43
|
-
"2": TransactionStatus.PROPOSING,
|
|
44
|
-
"3": TransactionStatus.COMMITTING,
|
|
45
|
-
"4": TransactionStatus.REVEALING,
|
|
46
|
-
"5": TransactionStatus.ACCEPTED,
|
|
47
|
-
"6": TransactionStatus.UNDETERMINED,
|
|
48
|
-
"7": TransactionStatus.FINALIZED,
|
|
49
|
-
"8": TransactionStatus.CANCELED,
|
|
50
|
-
"9": TransactionStatus.APPEAL_REVEALING,
|
|
51
|
-
"10": TransactionStatus.APPEAL_COMMITTING,
|
|
52
|
-
"11": TransactionStatus.READY_TO_FINALIZE,
|
|
53
|
-
"12": TransactionStatus.VALIDATORS_TIMEOUT,
|
|
54
|
-
"13": TransactionStatus.LEADER_TIMEOUT,
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export const transactionsStatusNameToNumber = {
|
|
58
|
-
[TransactionStatus.UNINITIALIZED]: "0",
|
|
59
|
-
[TransactionStatus.PENDING]: "1",
|
|
60
|
-
[TransactionStatus.PROPOSING]: "2",
|
|
61
|
-
[TransactionStatus.COMMITTING]: "3",
|
|
62
|
-
[TransactionStatus.REVEALING]: "4",
|
|
63
|
-
[TransactionStatus.ACCEPTED]: "5",
|
|
64
|
-
[TransactionStatus.UNDETERMINED]: "6",
|
|
65
|
-
[TransactionStatus.FINALIZED]: "7",
|
|
66
|
-
[TransactionStatus.CANCELED]: "8",
|
|
67
|
-
[TransactionStatus.APPEAL_REVEALING]: "9",
|
|
68
|
-
[TransactionStatus.APPEAL_COMMITTING]: "10",
|
|
69
|
-
[TransactionStatus.READY_TO_FINALIZE]: "11",
|
|
70
|
-
[TransactionStatus.VALIDATORS_TIMEOUT]: "12",
|
|
71
|
-
[TransactionStatus.LEADER_TIMEOUT]: "13",
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
export const DECIDED_STATES = [
|
|
75
|
-
TransactionStatus.ACCEPTED,
|
|
76
|
-
TransactionStatus.UNDETERMINED,
|
|
77
|
-
TransactionStatus.LEADER_TIMEOUT,
|
|
78
|
-
TransactionStatus.VALIDATORS_TIMEOUT,
|
|
79
|
-
TransactionStatus.CANCELED,
|
|
80
|
-
TransactionStatus.FINALIZED
|
|
81
|
-
];
|
|
82
|
-
|
|
83
|
-
export function isDecidedState(status: string): boolean {
|
|
84
|
-
return DECIDED_STATES.some(state =>
|
|
85
|
-
transactionsStatusNameToNumber[state] === status
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export const transactionResultNumberToName = {
|
|
90
|
-
"0": TransactionResult.IDLE,
|
|
91
|
-
"1": TransactionResult.AGREE,
|
|
92
|
-
"2": TransactionResult.DISAGREE,
|
|
93
|
-
"3": TransactionResult.TIMEOUT,
|
|
94
|
-
"4": TransactionResult.DETERMINISTIC_VIOLATION,
|
|
95
|
-
"5": TransactionResult.NO_MAJORITY,
|
|
96
|
-
"6": TransactionResult.MAJORITY_AGREE,
|
|
97
|
-
"7": TransactionResult.MAJORITY_DISAGREE,
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
export const TransactionResultNameToNumber = {
|
|
101
|
-
[TransactionResult.IDLE]: "0",
|
|
102
|
-
[TransactionResult.AGREE]: "1",
|
|
103
|
-
[TransactionResult.DISAGREE]: "2",
|
|
104
|
-
[TransactionResult.TIMEOUT]: "3",
|
|
105
|
-
[TransactionResult.DETERMINISTIC_VIOLATION]: "4",
|
|
106
|
-
[TransactionResult.NO_MAJORITY]: "5",
|
|
107
|
-
[TransactionResult.MAJORITY_AGREE]: "6",
|
|
108
|
-
[TransactionResult.MAJORITY_DISAGREE]: "7",
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
export enum VoteType {
|
|
112
|
-
NOT_VOTED = "NOT_VOTED",
|
|
113
|
-
AGREE = "AGREE",
|
|
114
|
-
DISAGREE = "DISAGREE",
|
|
115
|
-
TIMEOUT = "TIMEOUT",
|
|
116
|
-
DETERMINISTIC_VIOLATION = "DETERMINISTIC_VIOLATION",
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export const voteTypeNumberToName = {
|
|
120
|
-
"0": VoteType.NOT_VOTED,
|
|
121
|
-
"1": VoteType.AGREE,
|
|
122
|
-
"2": VoteType.DISAGREE,
|
|
123
|
-
"3": VoteType.TIMEOUT,
|
|
124
|
-
"4": VoteType.DETERMINISTIC_VIOLATION,
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
export const voteTypeNameToNumber = {
|
|
128
|
-
[VoteType.NOT_VOTED]: "0",
|
|
129
|
-
[VoteType.AGREE]: "1",
|
|
130
|
-
[VoteType.DISAGREE]: "2",
|
|
131
|
-
[VoteType.TIMEOUT]: "3",
|
|
132
|
-
[VoteType.DETERMINISTIC_VIOLATION]: "4",
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
export type TransactionType = "deploy" | "call";
|
|
136
|
-
|
|
137
|
-
export enum TransactionHashVariant {
|
|
138
|
-
LATEST_FINAL = "latest-final",
|
|
139
|
-
LATEST_NONFINAL = "latest-nonfinal",
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
export type DecodedDeployData = {
|
|
143
|
-
code?: Hex;
|
|
144
|
-
constructorArgs?: any; // Type this more strictly if possible
|
|
145
|
-
leaderOnly?: boolean;
|
|
146
|
-
type?: TransactionType;
|
|
147
|
-
contractAddress?: Address;
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
export type DecodedCallData = {
|
|
151
|
-
callData?: any; // Type this more strictly if possible
|
|
152
|
-
leaderOnly?: boolean;
|
|
153
|
-
type: TransactionType;
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
export interface LeaderReceipt {
|
|
157
|
-
calldata: string;
|
|
158
|
-
class_name: string;
|
|
159
|
-
contract_state: string;
|
|
160
|
-
eq_outputs: Record<string, unknown>;
|
|
161
|
-
error: string | null;
|
|
162
|
-
execution_result: string;
|
|
163
|
-
gas_used: number;
|
|
164
|
-
mode: string;
|
|
165
|
-
node_config: Record<string, unknown>;
|
|
166
|
-
pending_transactions: unknown[];
|
|
167
|
-
vote: string;
|
|
168
|
-
result: string;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// TODO: make localnet compatible with testnet and unify the types
|
|
172
|
-
export type GenLayerTransaction = {
|
|
173
|
-
// currentTimestamp: testnet
|
|
174
|
-
currentTimestamp?: string;
|
|
175
|
-
|
|
176
|
-
// from_address: localnet // sender: testnet
|
|
177
|
-
from_address?: Address;
|
|
178
|
-
sender?: Address;
|
|
179
|
-
|
|
180
|
-
// to_address: localnet // recipient: testnet
|
|
181
|
-
to_address?: Address;
|
|
182
|
-
recipient?: Address;
|
|
183
|
-
|
|
184
|
-
// numOfInitialValidators: testnet
|
|
185
|
-
numOfInitialValidators?: string;
|
|
186
|
-
|
|
187
|
-
// txSlot: testnet
|
|
188
|
-
txSlot?: string;
|
|
189
|
-
|
|
190
|
-
// createdTimestamp: testnet
|
|
191
|
-
createdTimestamp?: string;
|
|
192
|
-
|
|
193
|
-
// lastVoteTimestamp: testnet
|
|
194
|
-
lastVoteTimestamp?: string;
|
|
195
|
-
|
|
196
|
-
// randomSeed: testnet
|
|
197
|
-
randomSeed?: Hash;
|
|
198
|
-
|
|
199
|
-
// result: testnet
|
|
200
|
-
result?: number;
|
|
201
|
-
resultName?: TransactionResult;
|
|
202
|
-
|
|
203
|
-
// data: localnet // txData: testnet
|
|
204
|
-
data?: Record<string, unknown>;
|
|
205
|
-
txData?: Hex;
|
|
206
|
-
txDataDecoded?: DecodedDeployData | DecodedCallData;
|
|
207
|
-
// txReceipt: testnet
|
|
208
|
-
txReceipt?: Hash;
|
|
209
|
-
|
|
210
|
-
// messages: testnet
|
|
211
|
-
messages?: unknown[];
|
|
212
|
-
|
|
213
|
-
// queueType: testnet
|
|
214
|
-
queueType?: number;
|
|
215
|
-
|
|
216
|
-
// queuePosition: testnet
|
|
217
|
-
queuePosition?: string;
|
|
218
|
-
|
|
219
|
-
// activator: testnet
|
|
220
|
-
activator?: Address;
|
|
221
|
-
|
|
222
|
-
// lastLeader: testnet
|
|
223
|
-
lastLeader?: Address;
|
|
224
|
-
|
|
225
|
-
// status: localnet: TransactionStatus // status: testnet: number
|
|
226
|
-
status?: TransactionStatus | number;
|
|
227
|
-
statusName?: TransactionStatus;
|
|
228
|
-
|
|
229
|
-
// hash: localnet // txId: testnet// hash: localnet // txId: testnet
|
|
230
|
-
hash?: TransactionHash;
|
|
231
|
-
txId?: TransactionHash;
|
|
232
|
-
|
|
233
|
-
// readStateBlockRange: testnet
|
|
234
|
-
readStateBlockRange?: {
|
|
235
|
-
activationBlock: string;
|
|
236
|
-
processingBlock: string;
|
|
237
|
-
proposalBlock: string;
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
// numOfRounds: testnet
|
|
241
|
-
numOfRounds?: string;
|
|
242
|
-
|
|
243
|
-
// lastRound: testnet
|
|
244
|
-
lastRound?: {
|
|
245
|
-
round: string;
|
|
246
|
-
leaderIndex: string;
|
|
247
|
-
votesCommitted: string;
|
|
248
|
-
votesRevealed: string;
|
|
249
|
-
appealBond: string;
|
|
250
|
-
rotationsLeft: string;
|
|
251
|
-
result: number;
|
|
252
|
-
roundValidators: Address[];
|
|
253
|
-
validatorVotesHash: Hash[];
|
|
254
|
-
validatorVotes: number[];
|
|
255
|
-
validatorVotesName: VoteType[];
|
|
256
|
-
};
|
|
257
|
-
|
|
258
|
-
// consensus_data: localnet // leader_receipt: testnet
|
|
259
|
-
consensus_data?: {
|
|
260
|
-
final: boolean;
|
|
261
|
-
leader_receipt?: LeaderReceipt[];
|
|
262
|
-
validators?: Record<string, unknown>[];
|
|
263
|
-
votes?: Record<string, string>;
|
|
264
|
-
};
|
|
265
|
-
nonce?: number;
|
|
266
|
-
value?: number;
|
|
267
|
-
type?: number;
|
|
268
|
-
gaslimit?: bigint;
|
|
269
|
-
created_at?: Date;
|
|
270
|
-
r?: number;
|
|
271
|
-
s?: number;
|
|
272
|
-
v?: number;
|
|
273
|
-
};
|
|
274
|
-
|
|
275
|
-
export type GenLayerRawTransaction = {
|
|
276
|
-
currentTimestamp: bigint;
|
|
277
|
-
sender: Address;
|
|
278
|
-
recipient: Address;
|
|
279
|
-
numOfInitialValidators: bigint;
|
|
280
|
-
txSlot: bigint;
|
|
281
|
-
createdTimestamp: bigint;
|
|
282
|
-
lastVoteTimestamp: bigint;
|
|
283
|
-
randomSeed: Hash;
|
|
284
|
-
result: number;
|
|
285
|
-
txData: Hex | undefined | null;
|
|
286
|
-
txReceipt: Hash;
|
|
287
|
-
messages: unknown[];
|
|
288
|
-
queueType: number;
|
|
289
|
-
queuePosition: bigint;
|
|
290
|
-
activator: Address;
|
|
291
|
-
lastLeader: Address;
|
|
292
|
-
status: number;
|
|
293
|
-
txId: Hash;
|
|
294
|
-
readStateBlockRange: {
|
|
295
|
-
activationBlock: bigint;
|
|
296
|
-
processingBlock: bigint;
|
|
297
|
-
proposalBlock: bigint;
|
|
298
|
-
};
|
|
299
|
-
numOfRounds: bigint;
|
|
300
|
-
lastRound: {
|
|
301
|
-
round: bigint;
|
|
302
|
-
leaderIndex: bigint;
|
|
303
|
-
votesCommitted: bigint;
|
|
304
|
-
votesRevealed: bigint;
|
|
305
|
-
appealBond: bigint;
|
|
306
|
-
rotationsLeft: bigint;
|
|
307
|
-
result: number;
|
|
308
|
-
roundValidators: Address[];
|
|
309
|
-
validatorVotesHash: Hash[];
|
|
310
|
-
validatorVotes: number[];
|
|
311
|
-
};
|
|
312
|
-
};
|
package/src/utils/async.ts
DELETED
package/src/utils/jsonifier.ts
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import {calldata} from "@/abi";
|
|
2
|
-
import type {CalldataEncodable} from "@/types/calldata";
|
|
3
|
-
import {CalldataAddress} from "@/types/calldata";
|
|
4
|
-
import {toHex} from "viem";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export function b64ToArray(b64: string): Uint8Array {
|
|
8
|
-
return Uint8Array.from(atob(b64 as string), (c) => c.charCodeAt(0));
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function calldataToUserFriendlyJson(cd: Uint8Array): any {
|
|
12
|
-
return {
|
|
13
|
-
raw: Array.from(cd),
|
|
14
|
-
readable: calldata.toString(calldata.decode(cd)),
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const RESULT_CODES = new Map([
|
|
19
|
-
[0, 'return'],
|
|
20
|
-
[1, 'rollback'],
|
|
21
|
-
[2, 'contract_error'],
|
|
22
|
-
[3, 'error'],
|
|
23
|
-
[4, 'none'],
|
|
24
|
-
[5, 'no_leaders'],
|
|
25
|
-
]);
|
|
26
|
-
|
|
27
|
-
export function resultToUserFriendlyJson(cd64: string): any {
|
|
28
|
-
const raw = b64ToArray(cd64);
|
|
29
|
-
|
|
30
|
-
const code = RESULT_CODES.get(raw[0]);
|
|
31
|
-
let status: string;
|
|
32
|
-
let payload: string | null = null;
|
|
33
|
-
|
|
34
|
-
if (code === undefined) {
|
|
35
|
-
status = '<unknown>';
|
|
36
|
-
} else {
|
|
37
|
-
status = code;
|
|
38
|
-
if ([1, 2].includes(raw[0])) {
|
|
39
|
-
payload = new TextDecoder('utf-8').decode(raw.slice(1));
|
|
40
|
-
} else if (raw[0] == 0) {
|
|
41
|
-
payload = calldataToUserFriendlyJson(raw.slice(1));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
raw: cd64,
|
|
47
|
-
status,
|
|
48
|
-
payload,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// Deeply converts CalldataEncodable values into JSON-serializable structures.
|
|
53
|
-
// Rules:
|
|
54
|
-
// - bigint: to number if safe, otherwise to decimal string
|
|
55
|
-
// - Uint8Array: to 0x-prefixed hex string
|
|
56
|
-
// - CalldataAddress: to 0x-prefixed hex string
|
|
57
|
-
// - Map: to Array<[key, value]> preserving order
|
|
58
|
-
// - Arrays and plain objects: converted recursively
|
|
59
|
-
export function toJsonSafeDeep<T extends CalldataEncodable>(value: T): any {
|
|
60
|
-
return _toJsonSafeDeep(value, new WeakSet());
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function _toJsonSafeDeep(value: CalldataEncodable, seen: WeakSet<object>): any {
|
|
64
|
-
if (value === null || value === undefined) {
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const primitiveType = typeof value;
|
|
69
|
-
if (primitiveType === "string" || primitiveType === "boolean" || primitiveType === "number") {
|
|
70
|
-
return value;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (primitiveType === "bigint") {
|
|
74
|
-
const big = value as bigint;
|
|
75
|
-
const abs = big < 0n ? -big : big;
|
|
76
|
-
const maxSafe = 9007199254740991n; // Number.MAX_SAFE_INTEGER
|
|
77
|
-
return abs <= maxSafe ? Number(big) : big.toString();
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Objects and structured values
|
|
81
|
-
if (typeof value === "object") {
|
|
82
|
-
if (seen.has(value as object)) {
|
|
83
|
-
// Prevent potential cycles; represent as null
|
|
84
|
-
return null;
|
|
85
|
-
}
|
|
86
|
-
seen.add(value as object);
|
|
87
|
-
|
|
88
|
-
if (value instanceof Uint8Array) {
|
|
89
|
-
return toHex(value);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (value instanceof Array) {
|
|
93
|
-
return value.map((v) => _toJsonSafeDeep(v as CalldataEncodable, seen));
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (value instanceof Map) {
|
|
97
|
-
const obj: Record<string, any> = {};
|
|
98
|
-
for (const [k, v] of value.entries()) {
|
|
99
|
-
obj[k] = _toJsonSafeDeep(v as CalldataEncodable, seen);
|
|
100
|
-
}
|
|
101
|
-
return obj;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (value instanceof CalldataAddress) {
|
|
105
|
-
return toHex(value.bytes);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (Object.getPrototypeOf(value) === Object.prototype) {
|
|
109
|
-
const obj: Record<string, any> = {};
|
|
110
|
-
for (const [k, v] of Object.entries(value)) {
|
|
111
|
-
obj[k] = _toJsonSafeDeep(v as CalldataEncodable, seen);
|
|
112
|
-
}
|
|
113
|
-
return obj;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// Fallback: return as-is (shouldn't normally reach here)
|
|
118
|
-
return value as any;
|
|
119
|
-
}
|
package/src/wallet/actions.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import {connect} from "./connect";
|
|
2
|
-
import {GenLayerClient, GenLayerChain, Network, SnapSource} from "@/types";
|
|
3
|
-
import {metamaskClient} from "@/wallet/metamaskClient";
|
|
4
|
-
|
|
5
|
-
export function walletActions(client: GenLayerClient<GenLayerChain>) {
|
|
6
|
-
return {
|
|
7
|
-
connect: (network: Network, snapSource: SnapSource) => connect(client, network, snapSource),
|
|
8
|
-
metamaskClient: (snapSource: SnapSource = "npm") => metamaskClient(snapSource),
|
|
9
|
-
};
|
|
10
|
-
}
|