genlayer-js 0.19.5 → 0.20.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/LICENSE +1 -1
- package/README.md +3 -3
- package/dist/{index-CbVqYeWa.d.ts → index-DmoVRP1E.d.ts} +9 -0
- package/dist/{index-CYszVbTS.d.cts → index-TroH9NJL.d.cts} +9 -0
- package/dist/index.cjs +30 -0
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +30 -0
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://opensource.org/license/mit/)
|
|
4
4
|
[](https://discord.gg/VpfmXEMN66)
|
|
5
|
-
[](https://x.com/GenLayer)
|
|
6
|
+
[](https://star-history.com/#genlayerlabs/genlayer-js)
|
|
7
7
|
|
|
8
8
|
## 👀 About
|
|
9
9
|
|
|
@@ -174,7 +174,7 @@ For detailed information on how to use GenLayerJS SDK, please refer to our [docu
|
|
|
174
174
|
|
|
175
175
|
## Contributing
|
|
176
176
|
|
|
177
|
-
We welcome contributions to GenLayerJS SDK! Whether it's new features, improved infrastructure, or better documentation, your input is valuable. Please read our [CONTRIBUTING](https://github.com/
|
|
177
|
+
We welcome contributions to GenLayerJS SDK! Whether it's new features, improved infrastructure, or better documentation, your input is valuable. Please read our [CONTRIBUTING](https://github.com/genlayerlabs/genlayer-js/blob/main/CONTRIBUTING.md) guide for guidelines on how to submit your contributions.
|
|
178
178
|
|
|
179
179
|
## License
|
|
180
180
|
|
|
@@ -2753,6 +2753,9 @@ type GenLayerMethod = {
|
|
|
2753
2753
|
} | {
|
|
2754
2754
|
method: "gen_call";
|
|
2755
2755
|
params: [requestParams: any];
|
|
2756
|
+
} | {
|
|
2757
|
+
method: "sim_cancelTransaction";
|
|
2758
|
+
params: [hash: TransactionHash, signature?: string, adminKey?: string];
|
|
2756
2759
|
};
|
|
2757
2760
|
type GenLayerClient<TGenLayerChain extends GenLayerChain> = Omit<Client<Transport, TGenLayerChain>, "getTransaction" | "readContract"> & Omit<WalletActions<TGenLayerChain>, "deployContract" | "writeContract"> & Omit<PublicActions<Transport, TGenLayerChain>, "readContract" | "getTransaction" | "waitForTransactionReceipt"> & {
|
|
2758
2761
|
request: Client<Transport, TGenLayerChain>["request"] & {
|
|
@@ -2830,6 +2833,12 @@ type GenLayerClient<TGenLayerChain extends GenLayerChain> = Omit<Client<Transpor
|
|
|
2830
2833
|
initializeConsensusSmartContract: (forceReset?: boolean) => Promise<void>;
|
|
2831
2834
|
connect: (network?: Network, snapSource?: SnapSource) => Promise<void>;
|
|
2832
2835
|
metamaskClient: (snapSource?: SnapSource) => Promise<MetaMaskClientResult>;
|
|
2836
|
+
cancelTransaction: (args: {
|
|
2837
|
+
hash: TransactionHash;
|
|
2838
|
+
}) => Promise<{
|
|
2839
|
+
transaction_hash: string;
|
|
2840
|
+
status: string;
|
|
2841
|
+
}>;
|
|
2833
2842
|
appealTransaction: (args: {
|
|
2834
2843
|
account?: Account;
|
|
2835
2844
|
txId: `0x${string}`;
|
|
@@ -2753,6 +2753,9 @@ type GenLayerMethod = {
|
|
|
2753
2753
|
} | {
|
|
2754
2754
|
method: "gen_call";
|
|
2755
2755
|
params: [requestParams: any];
|
|
2756
|
+
} | {
|
|
2757
|
+
method: "sim_cancelTransaction";
|
|
2758
|
+
params: [hash: TransactionHash, signature?: string, adminKey?: string];
|
|
2756
2759
|
};
|
|
2757
2760
|
type GenLayerClient<TGenLayerChain extends GenLayerChain> = Omit<Client<Transport, TGenLayerChain>, "getTransaction" | "readContract"> & Omit<WalletActions<TGenLayerChain>, "deployContract" | "writeContract"> & Omit<PublicActions<Transport, TGenLayerChain>, "readContract" | "getTransaction" | "waitForTransactionReceipt"> & {
|
|
2758
2761
|
request: Client<Transport, TGenLayerChain>["request"] & {
|
|
@@ -2830,6 +2833,12 @@ type GenLayerClient<TGenLayerChain extends GenLayerChain> = Omit<Client<Transpor
|
|
|
2830
2833
|
initializeConsensusSmartContract: (forceReset?: boolean) => Promise<void>;
|
|
2831
2834
|
connect: (network?: Network, snapSource?: SnapSource) => Promise<void>;
|
|
2832
2835
|
metamaskClient: (snapSource?: SnapSource) => Promise<MetaMaskClientResult>;
|
|
2836
|
+
cancelTransaction: (args: {
|
|
2837
|
+
hash: TransactionHash;
|
|
2838
|
+
}) => Promise<{
|
|
2839
|
+
transaction_hash: string;
|
|
2840
|
+
status: string;
|
|
2841
|
+
}>;
|
|
2833
2842
|
appealTransaction: (args: {
|
|
2834
2843
|
account?: Account;
|
|
2835
2844
|
txId: `0x${string}`;
|
package/dist/index.cjs
CHANGED
|
@@ -921,6 +921,9 @@ async function sleep(ms) {
|
|
|
921
921
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
922
922
|
}
|
|
923
923
|
|
|
924
|
+
// src/transactions/actions.ts
|
|
925
|
+
|
|
926
|
+
|
|
924
927
|
// src/transactions/decoders.ts
|
|
925
928
|
|
|
926
929
|
var FIELDS_TO_REMOVE = [
|
|
@@ -1218,6 +1221,33 @@ var transactionActions = (client, publicClient) => ({
|
|
|
1218
1221
|
});
|
|
1219
1222
|
return decodeTransaction(transaction);
|
|
1220
1223
|
},
|
|
1224
|
+
cancelTransaction: async ({ hash }) => {
|
|
1225
|
+
if (!client.chain.isStudio) {
|
|
1226
|
+
throw new Error("cancelTransaction is only available on studio-based chains (localnet/studionet)");
|
|
1227
|
+
}
|
|
1228
|
+
if (!client.account) {
|
|
1229
|
+
throw new Error("No account set. Configure the client with an account to cancel transactions.");
|
|
1230
|
+
}
|
|
1231
|
+
const messageHash = _viem.keccak256.call(void 0, _viem.concat.call(void 0, [_viem.stringToBytes.call(void 0, "cancel_transaction"), _viem.toBytes.call(void 0, hash)]));
|
|
1232
|
+
let signature;
|
|
1233
|
+
if (typeof client.account === "object" && "signMessage" in client.account) {
|
|
1234
|
+
signature = await client.account.signMessage({ message: { raw: messageHash } });
|
|
1235
|
+
} else {
|
|
1236
|
+
const provider = typeof window !== "undefined" ? window.ethereum : void 0;
|
|
1237
|
+
if (!provider) {
|
|
1238
|
+
throw new Error("No provider available for signing. Use a private key account or ensure a wallet is connected.");
|
|
1239
|
+
}
|
|
1240
|
+
const address = typeof client.account === "string" ? client.account : client.account.address;
|
|
1241
|
+
signature = await provider.request({
|
|
1242
|
+
method: "personal_sign",
|
|
1243
|
+
params: [messageHash, address]
|
|
1244
|
+
});
|
|
1245
|
+
}
|
|
1246
|
+
return client.request({
|
|
1247
|
+
method: "sim_cancelTransaction",
|
|
1248
|
+
params: [hash, signature]
|
|
1249
|
+
});
|
|
1250
|
+
},
|
|
1221
1251
|
estimateTransactionGas: async (transactionParams) => {
|
|
1222
1252
|
const formattedParams = {
|
|
1223
1253
|
from: transactionParams.from || _optionalChain([client, 'access', _48 => _48.account, 'optionalAccess', _49 => _49.address]),
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as viem from 'viem';
|
|
2
2
|
import { Account, Address, Hex } from 'viem';
|
|
3
3
|
import { G as GenLayerChain } from './chains-B7B7UXdn.cjs';
|
|
4
|
-
import { G as GenLayerClient, D as DecodedDeployData, a as DecodedCallData, b as GenLayerRawTransaction, c as GenLayerTransaction, C as CalldataEncodable, T as TransactionDataElement, S as STAKING_ABI, V as VALIDATOR_WALLET_ABI, d as ContractSchema } from './index-
|
|
4
|
+
import { G as GenLayerClient, D as DecodedDeployData, a as DecodedCallData, b as GenLayerRawTransaction, c as GenLayerTransaction, C as CalldataEncodable, T as TransactionDataElement, S as STAKING_ABI, V as VALIDATOR_WALLET_ABI, d as ContractSchema } from './index-TroH9NJL.cjs';
|
|
5
5
|
import * as abitype from 'abitype';
|
|
6
6
|
import * as viem__types_types_authorization from 'viem/_types/types/authorization';
|
|
7
7
|
import * as viem_accounts from 'viem/accounts';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as viem from 'viem';
|
|
2
2
|
import { Account, Address, Hex } from 'viem';
|
|
3
3
|
import { G as GenLayerChain } from './chains-B7B7UXdn.js';
|
|
4
|
-
import { G as GenLayerClient, D as DecodedDeployData, a as DecodedCallData, b as GenLayerRawTransaction, c as GenLayerTransaction, C as CalldataEncodable, T as TransactionDataElement, S as STAKING_ABI, V as VALIDATOR_WALLET_ABI, d as ContractSchema } from './index-
|
|
4
|
+
import { G as GenLayerClient, D as DecodedDeployData, a as DecodedCallData, b as GenLayerRawTransaction, c as GenLayerTransaction, C as CalldataEncodable, T as TransactionDataElement, S as STAKING_ABI, V as VALIDATOR_WALLET_ABI, d as ContractSchema } from './index-DmoVRP1E.js';
|
|
5
5
|
import * as abitype from 'abitype';
|
|
6
6
|
import * as viem__types_types_authorization from 'viem/_types/types/authorization';
|
|
7
7
|
import * as viem_accounts from 'viem/accounts';
|
package/dist/index.js
CHANGED
|
@@ -921,6 +921,9 @@ async function sleep(ms) {
|
|
|
921
921
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
922
922
|
}
|
|
923
923
|
|
|
924
|
+
// src/transactions/actions.ts
|
|
925
|
+
import { keccak256, concat, stringToBytes, toBytes } from "viem";
|
|
926
|
+
|
|
924
927
|
// src/transactions/decoders.ts
|
|
925
928
|
import { fromRlp, fromHex as fromHex2 } from "viem";
|
|
926
929
|
var FIELDS_TO_REMOVE = [
|
|
@@ -1218,6 +1221,33 @@ var transactionActions = (client, publicClient) => ({
|
|
|
1218
1221
|
});
|
|
1219
1222
|
return decodeTransaction(transaction);
|
|
1220
1223
|
},
|
|
1224
|
+
cancelTransaction: async ({ hash }) => {
|
|
1225
|
+
if (!client.chain.isStudio) {
|
|
1226
|
+
throw new Error("cancelTransaction is only available on studio-based chains (localnet/studionet)");
|
|
1227
|
+
}
|
|
1228
|
+
if (!client.account) {
|
|
1229
|
+
throw new Error("No account set. Configure the client with an account to cancel transactions.");
|
|
1230
|
+
}
|
|
1231
|
+
const messageHash = keccak256(concat([stringToBytes("cancel_transaction"), toBytes(hash)]));
|
|
1232
|
+
let signature;
|
|
1233
|
+
if (typeof client.account === "object" && "signMessage" in client.account) {
|
|
1234
|
+
signature = await client.account.signMessage({ message: { raw: messageHash } });
|
|
1235
|
+
} else {
|
|
1236
|
+
const provider = typeof window !== "undefined" ? window.ethereum : void 0;
|
|
1237
|
+
if (!provider) {
|
|
1238
|
+
throw new Error("No provider available for signing. Use a private key account or ensure a wallet is connected.");
|
|
1239
|
+
}
|
|
1240
|
+
const address = typeof client.account === "string" ? client.account : client.account.address;
|
|
1241
|
+
signature = await provider.request({
|
|
1242
|
+
method: "personal_sign",
|
|
1243
|
+
params: [messageHash, address]
|
|
1244
|
+
});
|
|
1245
|
+
}
|
|
1246
|
+
return client.request({
|
|
1247
|
+
method: "sim_cancelTransaction",
|
|
1248
|
+
params: [hash, signature]
|
|
1249
|
+
});
|
|
1250
|
+
},
|
|
1221
1251
|
estimateTransactionGas: async (transactionParams) => {
|
|
1222
1252
|
const formattedParams = {
|
|
1223
1253
|
from: transactionParams.from || client.account?.address,
|
package/dist/types/index.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { Account, Address } from 'viem';
|
|
2
|
-
export { I as BannedValidatorInfo, e as CalldataAddress, C as CalldataEncodable, j as ContractMethod, i as ContractMethodBase, g as ContractParamsArraySchemaElement, h as ContractParamsSchema, d as ContractSchema, o as DECIDED_STATES, a as DecodedCallData, D as DecodedDeployData, a4 as DelegatorClaimOptions, a3 as DelegatorExitOptions, a2 as DelegatorJoinOptions, U as DelegatorJoinResult, K as EpochData, O as EpochInfo, G as GenLayerClient, f as GenLayerMethod, b as GenLayerRawTransaction, c as GenLayerTransaction, H as Hash, L as LeaderReceipt, M as MethodDescription, N as Network, P as PendingDeposit, F as PendingWithdrawal, a1 as SetIdentityOptions, a0 as SetOperatorOptions, y as SnapSource, J as StakeInfo, a5 as StakingActions, z as StakingContract, Q as StakingTransactionResult, k as TransactionHash, x as TransactionHashVariant, m as TransactionResult, r as TransactionResultNameToNumber, l as TransactionStatus, w as TransactionType, _ as ValidatorClaimOptions, Y as ValidatorDepositOptions, Z as ValidatorExitOptions, B as ValidatorIdentity, E as ValidatorInfo, X as ValidatorJoinOptions, R as ValidatorJoinResult, $ as ValidatorPrimeOptions, A as ValidatorView, s as VoteType, W as WithdrawalCommit, p as isDecidedState, q as transactionResultNumberToName, n as transactionsStatusNameToNumber, t as transactionsStatusNumberToName, u as voteTypeNameToNumber, v as voteTypeNumberToName } from '../index-
|
|
2
|
+
export { I as BannedValidatorInfo, e as CalldataAddress, C as CalldataEncodable, j as ContractMethod, i as ContractMethodBase, g as ContractParamsArraySchemaElement, h as ContractParamsSchema, d as ContractSchema, o as DECIDED_STATES, a as DecodedCallData, D as DecodedDeployData, a4 as DelegatorClaimOptions, a3 as DelegatorExitOptions, a2 as DelegatorJoinOptions, U as DelegatorJoinResult, K as EpochData, O as EpochInfo, G as GenLayerClient, f as GenLayerMethod, b as GenLayerRawTransaction, c as GenLayerTransaction, H as Hash, L as LeaderReceipt, M as MethodDescription, N as Network, P as PendingDeposit, F as PendingWithdrawal, a1 as SetIdentityOptions, a0 as SetOperatorOptions, y as SnapSource, J as StakeInfo, a5 as StakingActions, z as StakingContract, Q as StakingTransactionResult, k as TransactionHash, x as TransactionHashVariant, m as TransactionResult, r as TransactionResultNameToNumber, l as TransactionStatus, w as TransactionType, _ as ValidatorClaimOptions, Y as ValidatorDepositOptions, Z as ValidatorExitOptions, B as ValidatorIdentity, E as ValidatorInfo, X as ValidatorJoinOptions, R as ValidatorJoinResult, $ as ValidatorPrimeOptions, A as ValidatorView, s as VoteType, W as WithdrawalCommit, p as isDecidedState, q as transactionResultNumberToName, n as transactionsStatusNameToNumber, t as transactionsStatusNumberToName, u as voteTypeNameToNumber, v as voteTypeNumberToName } from '../index-TroH9NJL.cjs';
|
|
3
3
|
export { G as GenLayerChain } from '../chains-B7B7UXdn.cjs';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { Account, Address } from 'viem';
|
|
2
|
-
export { I as BannedValidatorInfo, e as CalldataAddress, C as CalldataEncodable, j as ContractMethod, i as ContractMethodBase, g as ContractParamsArraySchemaElement, h as ContractParamsSchema, d as ContractSchema, o as DECIDED_STATES, a as DecodedCallData, D as DecodedDeployData, a4 as DelegatorClaimOptions, a3 as DelegatorExitOptions, a2 as DelegatorJoinOptions, U as DelegatorJoinResult, K as EpochData, O as EpochInfo, G as GenLayerClient, f as GenLayerMethod, b as GenLayerRawTransaction, c as GenLayerTransaction, H as Hash, L as LeaderReceipt, M as MethodDescription, N as Network, P as PendingDeposit, F as PendingWithdrawal, a1 as SetIdentityOptions, a0 as SetOperatorOptions, y as SnapSource, J as StakeInfo, a5 as StakingActions, z as StakingContract, Q as StakingTransactionResult, k as TransactionHash, x as TransactionHashVariant, m as TransactionResult, r as TransactionResultNameToNumber, l as TransactionStatus, w as TransactionType, _ as ValidatorClaimOptions, Y as ValidatorDepositOptions, Z as ValidatorExitOptions, B as ValidatorIdentity, E as ValidatorInfo, X as ValidatorJoinOptions, R as ValidatorJoinResult, $ as ValidatorPrimeOptions, A as ValidatorView, s as VoteType, W as WithdrawalCommit, p as isDecidedState, q as transactionResultNumberToName, n as transactionsStatusNameToNumber, t as transactionsStatusNumberToName, u as voteTypeNameToNumber, v as voteTypeNumberToName } from '../index-
|
|
2
|
+
export { I as BannedValidatorInfo, e as CalldataAddress, C as CalldataEncodable, j as ContractMethod, i as ContractMethodBase, g as ContractParamsArraySchemaElement, h as ContractParamsSchema, d as ContractSchema, o as DECIDED_STATES, a as DecodedCallData, D as DecodedDeployData, a4 as DelegatorClaimOptions, a3 as DelegatorExitOptions, a2 as DelegatorJoinOptions, U as DelegatorJoinResult, K as EpochData, O as EpochInfo, G as GenLayerClient, f as GenLayerMethod, b as GenLayerRawTransaction, c as GenLayerTransaction, H as Hash, L as LeaderReceipt, M as MethodDescription, N as Network, P as PendingDeposit, F as PendingWithdrawal, a1 as SetIdentityOptions, a0 as SetOperatorOptions, y as SnapSource, J as StakeInfo, a5 as StakingActions, z as StakingContract, Q as StakingTransactionResult, k as TransactionHash, x as TransactionHashVariant, m as TransactionResult, r as TransactionResultNameToNumber, l as TransactionStatus, w as TransactionType, _ as ValidatorClaimOptions, Y as ValidatorDepositOptions, Z as ValidatorExitOptions, B as ValidatorIdentity, E as ValidatorInfo, X as ValidatorJoinOptions, R as ValidatorJoinResult, $ as ValidatorPrimeOptions, A as ValidatorView, s as VoteType, W as WithdrawalCommit, p as isDecidedState, q as transactionResultNumberToName, n as transactionsStatusNameToNumber, t as transactionsStatusNumberToName, u as voteTypeNameToNumber, v as voteTypeNumberToName } from '../index-DmoVRP1E.js';
|
|
3
3
|
export { G as GenLayerChain } from '../chains-B7B7UXdn.js';
|