genlayer-js 0.20.2 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/chains/index.cjs +4 -2
- package/dist/chains/index.d.cts +1 -1
- package/dist/chains/index.d.ts +1 -1
- package/dist/chains/index.js +5 -3
- package/dist/{chunk-NOFMB7RP.js → chunk-5KRGDGMO.js} +3357 -1
- package/dist/{chunk-5TKVNHAO.cjs → chunk-TCAQ6AVF.cjs} +3358 -2
- package/dist/{index-DmoVRP1E.d.ts → index-B3hpL2wZ.d.ts} +2 -1
- package/dist/{index-BVDASTaU.d.cts → index-DjR-MFPr.d.cts} +5 -2
- package/dist/{index-TroH9NJL.d.cts → index-DxwfPDf6.d.cts} +2 -1
- package/dist/{index-ucNO2REF.d.ts → index-HRqj9M3K.d.ts} +5 -2
- package/dist/index.cjs +41 -74
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +14 -47
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +2 -1
|
@@ -279,7 +279,7 @@ type ContractSchema = {
|
|
|
279
279
|
methods: Record<string, ContractMethod>;
|
|
280
280
|
};
|
|
281
281
|
|
|
282
|
-
type Network = "localnet" | "studionet" | "testnetAsimov" | "mainnet";
|
|
282
|
+
type Network = "localnet" | "studionet" | "testnetAsimov" | "testnetBradbury" | "mainnet";
|
|
283
283
|
|
|
284
284
|
type SnapSource = 'npm' | 'local';
|
|
285
285
|
|
|
@@ -2830,6 +2830,7 @@ type GenLayerClient<TGenLayerChain extends GenLayerChain> = Omit<Client<Transpor
|
|
|
2830
2830
|
getContractSchema: (address: Address) => Promise<ContractSchema>;
|
|
2831
2831
|
getContractSchemaForCode: (contractCode: string | Uint8Array) => Promise<ContractSchema>;
|
|
2832
2832
|
getContractCode: (address: Address) => Promise<string>;
|
|
2833
|
+
/** @deprecated This method is deprecated. The consensus contract is now resolved from the static chain definition. */
|
|
2833
2834
|
initializeConsensusSmartContract: (forceReset?: boolean) => Promise<void>;
|
|
2834
2835
|
connect: (network?: Network, snapSource?: SnapSource) => Promise<void>;
|
|
2835
2836
|
metamaskClient: (snapSource?: SnapSource) => Promise<MetaMaskClientResult>;
|
|
@@ -6,11 +6,14 @@ declare const studionet: GenLayerChain;
|
|
|
6
6
|
|
|
7
7
|
declare const testnetAsimov: GenLayerChain;
|
|
8
8
|
|
|
9
|
+
declare const testnetBradbury: GenLayerChain;
|
|
10
|
+
|
|
9
11
|
declare const index_localnet: typeof localnet;
|
|
10
12
|
declare const index_studionet: typeof studionet;
|
|
11
13
|
declare const index_testnetAsimov: typeof testnetAsimov;
|
|
14
|
+
declare const index_testnetBradbury: typeof testnetBradbury;
|
|
12
15
|
declare namespace index {
|
|
13
|
-
export { index_localnet as localnet, index_studionet as studionet, index_testnetAsimov as testnetAsimov };
|
|
16
|
+
export { index_localnet as localnet, index_studionet as studionet, index_testnetAsimov as testnetAsimov, index_testnetBradbury as testnetBradbury };
|
|
14
17
|
}
|
|
15
18
|
|
|
16
|
-
export { index as i, localnet as l, studionet as s, testnetAsimov as t };
|
|
19
|
+
export { testnetBradbury as a, index as i, localnet as l, studionet as s, testnetAsimov as t };
|
|
@@ -279,7 +279,7 @@ type ContractSchema = {
|
|
|
279
279
|
methods: Record<string, ContractMethod>;
|
|
280
280
|
};
|
|
281
281
|
|
|
282
|
-
type Network = "localnet" | "studionet" | "testnetAsimov" | "mainnet";
|
|
282
|
+
type Network = "localnet" | "studionet" | "testnetAsimov" | "testnetBradbury" | "mainnet";
|
|
283
283
|
|
|
284
284
|
type SnapSource = 'npm' | 'local';
|
|
285
285
|
|
|
@@ -2830,6 +2830,7 @@ type GenLayerClient<TGenLayerChain extends GenLayerChain> = Omit<Client<Transpor
|
|
|
2830
2830
|
getContractSchema: (address: Address) => Promise<ContractSchema>;
|
|
2831
2831
|
getContractSchemaForCode: (contractCode: string | Uint8Array) => Promise<ContractSchema>;
|
|
2832
2832
|
getContractCode: (address: Address) => Promise<string>;
|
|
2833
|
+
/** @deprecated This method is deprecated. The consensus contract is now resolved from the static chain definition. */
|
|
2833
2834
|
initializeConsensusSmartContract: (forceReset?: boolean) => Promise<void>;
|
|
2834
2835
|
connect: (network?: Network, snapSource?: SnapSource) => Promise<void>;
|
|
2835
2836
|
metamaskClient: (snapSource?: SnapSource) => Promise<MetaMaskClientResult>;
|
|
@@ -6,11 +6,14 @@ declare const studionet: GenLayerChain;
|
|
|
6
6
|
|
|
7
7
|
declare const testnetAsimov: GenLayerChain;
|
|
8
8
|
|
|
9
|
+
declare const testnetBradbury: GenLayerChain;
|
|
10
|
+
|
|
9
11
|
declare const index_localnet: typeof localnet;
|
|
10
12
|
declare const index_studionet: typeof studionet;
|
|
11
13
|
declare const index_testnetAsimov: typeof testnetAsimov;
|
|
14
|
+
declare const index_testnetBradbury: typeof testnetBradbury;
|
|
12
15
|
declare namespace index {
|
|
13
|
-
export { index_localnet as localnet, index_studionet as studionet, index_testnetAsimov as testnetAsimov };
|
|
16
|
+
export { index_localnet as localnet, index_studionet as studionet, index_testnetAsimov as testnetAsimov, index_testnetBradbury as testnetBradbury };
|
|
14
17
|
}
|
|
15
18
|
|
|
16
|
-
export { index as i, localnet as l, studionet as s, testnetAsimov as t };
|
|
19
|
+
export { testnetBradbury as a, index as i, localnet as l, studionet as s, testnetAsimov as t };
|
package/dist/index.cjs
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
var _chunkTCAQ6AVFcjs = require('./chunk-TCAQ6AVF.cjs');
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
|
|
@@ -31,7 +32,7 @@ var _viem = require('viem');
|
|
|
31
32
|
function accountActions(client) {
|
|
32
33
|
return {
|
|
33
34
|
fundAccount: async ({ address, amount }) => {
|
|
34
|
-
if (_optionalChain([client, 'access', _ => _.chain, 'optionalAccess', _2 => _2.id]) !==
|
|
35
|
+
if (_optionalChain([client, 'access', _ => _.chain, 'optionalAccess', _2 => _2.id]) !== _chunkTCAQ6AVFcjs.localnet.id) {
|
|
35
36
|
throw new Error("Client is not connected to the localnet");
|
|
36
37
|
}
|
|
37
38
|
return client.request({
|
|
@@ -415,8 +416,8 @@ function serialize(data) {
|
|
|
415
416
|
// src/abi/index.ts
|
|
416
417
|
var abi_exports = {};
|
|
417
418
|
_chunk75ZPJI57cjs.__export.call(void 0, abi_exports, {
|
|
418
|
-
STAKING_ABI: () =>
|
|
419
|
-
VALIDATOR_WALLET_ABI: () =>
|
|
419
|
+
STAKING_ABI: () => _chunkTCAQ6AVFcjs.STAKING_ABI,
|
|
420
|
+
VALIDATOR_WALLET_ABI: () => _chunkTCAQ6AVFcjs.VALIDATOR_WALLET_ABI,
|
|
420
421
|
calldata: () => calldata,
|
|
421
422
|
transactions: () => transactions
|
|
422
423
|
});
|
|
@@ -516,7 +517,7 @@ function _toJsonSafeDeep(value, seen) {
|
|
|
516
517
|
var contractActions = (client, publicClient) => {
|
|
517
518
|
return {
|
|
518
519
|
getContractCode: async (address) => {
|
|
519
|
-
if (client.chain.id !==
|
|
520
|
+
if (client.chain.id !== _chunkTCAQ6AVFcjs.localnet.id) {
|
|
520
521
|
throw new Error("Getting contract code is not supported on this network");
|
|
521
522
|
}
|
|
522
523
|
const result = await client.request({
|
|
@@ -527,7 +528,7 @@ var contractActions = (client, publicClient) => {
|
|
|
527
528
|
return new TextDecoder().decode(codeBytes);
|
|
528
529
|
},
|
|
529
530
|
getContractSchema: async (address) => {
|
|
530
|
-
if (client.chain.id !==
|
|
531
|
+
if (client.chain.id !== _chunkTCAQ6AVFcjs.localnet.id) {
|
|
531
532
|
throw new Error("Contract schema is not supported on this network");
|
|
532
533
|
}
|
|
533
534
|
const schema = await client.request({
|
|
@@ -537,7 +538,7 @@ var contractActions = (client, publicClient) => {
|
|
|
537
538
|
return schema;
|
|
538
539
|
},
|
|
539
540
|
getContractSchemaForCode: async (contractCode) => {
|
|
540
|
-
if (client.chain.id !==
|
|
541
|
+
if (client.chain.id !== _chunkTCAQ6AVFcjs.localnet.id) {
|
|
541
542
|
throw new Error("Contract schema is not supported on this network");
|
|
542
543
|
}
|
|
543
544
|
const schema = await client.request({
|
|
@@ -624,7 +625,6 @@ var contractActions = (client, publicClient) => {
|
|
|
624
625
|
leaderOnly = false,
|
|
625
626
|
consensusMaxRotations = client.chain.defaultConsensusMaxRotations
|
|
626
627
|
} = args;
|
|
627
|
-
await client.initializeConsensusSmartContract();
|
|
628
628
|
const data = [encode(makeCalldataObject(functionName, callArgs, kwargs)), leaderOnly];
|
|
629
629
|
const serializedData = serialize(data);
|
|
630
630
|
const senderAccount = account || client.account;
|
|
@@ -653,7 +653,6 @@ var contractActions = (client, publicClient) => {
|
|
|
653
653
|
leaderOnly = false,
|
|
654
654
|
consensusMaxRotations = client.chain.defaultConsensusMaxRotations
|
|
655
655
|
} = args;
|
|
656
|
-
await client.initializeConsensusSmartContract();
|
|
657
656
|
const data = [
|
|
658
657
|
code,
|
|
659
658
|
encode(makeCalldataObject(void 0, constructorArgs, kwargs)),
|
|
@@ -1179,7 +1178,7 @@ var receiptActions = (client, publicClient) => ({
|
|
|
1179
1178
|
const requestedStatus = _chunkW4V73RPNcjs.transactionsStatusNameToNumber[status];
|
|
1180
1179
|
if (transactionStatusString === requestedStatus || status === "ACCEPTED" /* ACCEPTED */ && _chunkW4V73RPNcjs.isDecidedState.call(void 0, transactionStatusString)) {
|
|
1181
1180
|
let finalTransaction = transaction;
|
|
1182
|
-
if (client.chain.id ===
|
|
1181
|
+
if (client.chain.id === _chunkTCAQ6AVFcjs.localnet.id) {
|
|
1183
1182
|
finalTransaction = decodeLocalnetTransaction(transaction);
|
|
1184
1183
|
}
|
|
1185
1184
|
if (!fullTransaction) {
|
|
@@ -1271,9 +1270,10 @@ var snapID = {
|
|
|
1271
1270
|
|
|
1272
1271
|
// src/wallet/connect.ts
|
|
1273
1272
|
var networks = {
|
|
1274
|
-
localnet:
|
|
1275
|
-
studionet:
|
|
1276
|
-
testnetAsimov:
|
|
1273
|
+
localnet: _chunkTCAQ6AVFcjs.localnet,
|
|
1274
|
+
studionet: _chunkTCAQ6AVFcjs.studionet,
|
|
1275
|
+
testnetAsimov: _chunkTCAQ6AVFcjs.testnetAsimov,
|
|
1276
|
+
testnetBradbury: _chunkTCAQ6AVFcjs.testnetBradbury
|
|
1277
1277
|
};
|
|
1278
1278
|
var connect = async (client, network = "studionet", snapSource = "npm") => {
|
|
1279
1279
|
if (!window.ethereum) {
|
|
@@ -1389,7 +1389,7 @@ function formatStakingAmount(amount) {
|
|
|
1389
1389
|
// src/staking/actions.ts
|
|
1390
1390
|
var FALLBACK_GAS = 1000000n;
|
|
1391
1391
|
var GAS_BUFFER_MULTIPLIER = 2n;
|
|
1392
|
-
var COMBINED_ERROR_ABI = [...
|
|
1392
|
+
var COMBINED_ERROR_ABI = [..._chunkTCAQ6AVFcjs.STAKING_ABI, ..._chunkTCAQ6AVFcjs.VALIDATOR_WALLET_ABI];
|
|
1393
1393
|
function extractRevertReason(err) {
|
|
1394
1394
|
if (err instanceof _viem.BaseError) {
|
|
1395
1395
|
const rawError = err.walk((e) => e instanceof _viem.RawContractError);
|
|
@@ -1521,7 +1521,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1521
1521
|
const address = getStakingAddress();
|
|
1522
1522
|
return _viem.getContract.call(void 0, {
|
|
1523
1523
|
address,
|
|
1524
|
-
abi:
|
|
1524
|
+
abi: _chunkTCAQ6AVFcjs.STAKING_ABI,
|
|
1525
1525
|
client: { public: publicClient, wallet: client }
|
|
1526
1526
|
});
|
|
1527
1527
|
};
|
|
@@ -1529,7 +1529,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1529
1529
|
const address = getStakingAddress();
|
|
1530
1530
|
return _viem.getContract.call(void 0, {
|
|
1531
1531
|
address,
|
|
1532
|
-
abi:
|
|
1532
|
+
abi: _chunkTCAQ6AVFcjs.STAKING_ABI,
|
|
1533
1533
|
client: publicClient
|
|
1534
1534
|
});
|
|
1535
1535
|
};
|
|
@@ -1538,11 +1538,11 @@ var stakingActions = (client, publicClient) => {
|
|
|
1538
1538
|
const amount = parseStakingAmount(options.amount);
|
|
1539
1539
|
const stakingAddress = getStakingAddress();
|
|
1540
1540
|
const data = options.operator ? _viem.encodeFunctionData.call(void 0, {
|
|
1541
|
-
abi:
|
|
1541
|
+
abi: _chunkTCAQ6AVFcjs.STAKING_ABI,
|
|
1542
1542
|
functionName: "validatorJoin",
|
|
1543
1543
|
args: [options.operator]
|
|
1544
1544
|
}) : _viem.encodeFunctionData.call(void 0, {
|
|
1545
|
-
abi:
|
|
1545
|
+
abi: _chunkTCAQ6AVFcjs.STAKING_ABI,
|
|
1546
1546
|
functionName: "validatorJoin"
|
|
1547
1547
|
});
|
|
1548
1548
|
const result = await executeWrite({ to: stakingAddress, data, value: amount });
|
|
@@ -1551,7 +1551,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1551
1551
|
let eventFound = false;
|
|
1552
1552
|
for (const log of receipt.logs) {
|
|
1553
1553
|
try {
|
|
1554
|
-
const decoded = _viem.decodeEventLog.call(void 0, { abi:
|
|
1554
|
+
const decoded = _viem.decodeEventLog.call(void 0, { abi: _chunkTCAQ6AVFcjs.STAKING_ABI, data: log.data, topics: log.topics });
|
|
1555
1555
|
if (decoded.eventName === "ValidatorJoin") {
|
|
1556
1556
|
validatorWallet = decoded.args.validator;
|
|
1557
1557
|
eventFound = true;
|
|
@@ -1578,7 +1578,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1578
1578
|
validatorDeposit: async (options) => {
|
|
1579
1579
|
const amount = parseStakingAmount(options.amount);
|
|
1580
1580
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1581
|
-
abi:
|
|
1581
|
+
abi: _chunkTCAQ6AVFcjs.STAKING_ABI,
|
|
1582
1582
|
functionName: "validatorDeposit"
|
|
1583
1583
|
});
|
|
1584
1584
|
return executeWrite({ to: getStakingAddress(), data, value: amount });
|
|
@@ -1586,7 +1586,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1586
1586
|
validatorExit: async (options) => {
|
|
1587
1587
|
const shares = typeof options.shares === "string" ? BigInt(options.shares) : options.shares;
|
|
1588
1588
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1589
|
-
abi:
|
|
1589
|
+
abi: _chunkTCAQ6AVFcjs.STAKING_ABI,
|
|
1590
1590
|
functionName: "validatorExit",
|
|
1591
1591
|
args: [shares]
|
|
1592
1592
|
});
|
|
@@ -1598,7 +1598,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1598
1598
|
}
|
|
1599
1599
|
const validatorAddress = _optionalChain([options, 'optionalAccess', _65 => _65.validator]) || client.account.address;
|
|
1600
1600
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1601
|
-
abi:
|
|
1601
|
+
abi: _chunkTCAQ6AVFcjs.STAKING_ABI,
|
|
1602
1602
|
functionName: "validatorClaim",
|
|
1603
1603
|
args: [validatorAddress]
|
|
1604
1604
|
});
|
|
@@ -1607,7 +1607,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1607
1607
|
},
|
|
1608
1608
|
validatorPrime: async (options) => {
|
|
1609
1609
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1610
|
-
abi:
|
|
1610
|
+
abi: _chunkTCAQ6AVFcjs.STAKING_ABI,
|
|
1611
1611
|
functionName: "validatorPrime",
|
|
1612
1612
|
args: [options.validator]
|
|
1613
1613
|
});
|
|
@@ -1615,7 +1615,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1615
1615
|
},
|
|
1616
1616
|
setOperator: async (options) => {
|
|
1617
1617
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1618
|
-
abi:
|
|
1618
|
+
abi: _chunkTCAQ6AVFcjs.VALIDATOR_WALLET_ABI,
|
|
1619
1619
|
functionName: "setOperator",
|
|
1620
1620
|
args: [options.operator]
|
|
1621
1621
|
});
|
|
@@ -1631,7 +1631,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1631
1631
|
}
|
|
1632
1632
|
}
|
|
1633
1633
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1634
|
-
abi:
|
|
1634
|
+
abi: _chunkTCAQ6AVFcjs.VALIDATOR_WALLET_ABI,
|
|
1635
1635
|
functionName: "setIdentity",
|
|
1636
1636
|
args: [
|
|
1637
1637
|
options.moniker,
|
|
@@ -1650,7 +1650,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1650
1650
|
delegatorJoin: async (options) => {
|
|
1651
1651
|
const amount = parseStakingAmount(options.amount);
|
|
1652
1652
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1653
|
-
abi:
|
|
1653
|
+
abi: _chunkTCAQ6AVFcjs.STAKING_ABI,
|
|
1654
1654
|
functionName: "delegatorJoin",
|
|
1655
1655
|
args: [options.validator]
|
|
1656
1656
|
});
|
|
@@ -1666,7 +1666,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1666
1666
|
delegatorExit: async (options) => {
|
|
1667
1667
|
const shares = typeof options.shares === "string" ? BigInt(options.shares) : options.shares;
|
|
1668
1668
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1669
|
-
abi:
|
|
1669
|
+
abi: _chunkTCAQ6AVFcjs.STAKING_ABI,
|
|
1670
1670
|
functionName: "delegatorExit",
|
|
1671
1671
|
args: [options.validator, shares]
|
|
1672
1672
|
});
|
|
@@ -1678,7 +1678,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1678
1678
|
}
|
|
1679
1679
|
const delegatorAddress = options.delegator || client.account.address;
|
|
1680
1680
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1681
|
-
abi:
|
|
1681
|
+
abi: _chunkTCAQ6AVFcjs.STAKING_ABI,
|
|
1682
1682
|
functionName: "delegatorClaim",
|
|
1683
1683
|
args: [delegatorAddress, options.validator]
|
|
1684
1684
|
});
|
|
@@ -1696,7 +1696,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1696
1696
|
}
|
|
1697
1697
|
const walletContract = _viem.getContract.call(void 0, {
|
|
1698
1698
|
address: validator,
|
|
1699
|
-
abi:
|
|
1699
|
+
abi: _chunkTCAQ6AVFcjs.VALIDATOR_WALLET_ABI,
|
|
1700
1700
|
client: publicClient
|
|
1701
1701
|
});
|
|
1702
1702
|
const [view, owner, operator, identityRaw, currentEpoch] = await Promise.all([
|
|
@@ -1934,46 +1934,16 @@ var stakingActions = (client, publicClient) => {
|
|
|
1934
1934
|
};
|
|
1935
1935
|
|
|
1936
1936
|
// src/chains/actions.ts
|
|
1937
|
-
function chainActions(
|
|
1937
|
+
function chainActions(_client) {
|
|
1938
1938
|
return {
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
}
|
|
1948
|
-
try {
|
|
1949
|
-
const contractsResponse = await fetch(client.chain.rpcUrls.default.http[0], {
|
|
1950
|
-
method: "POST",
|
|
1951
|
-
headers: {
|
|
1952
|
-
"Content-Type": "application/json"
|
|
1953
|
-
},
|
|
1954
|
-
body: JSON.stringify({
|
|
1955
|
-
jsonrpc: "2.0",
|
|
1956
|
-
id: Date.now(),
|
|
1957
|
-
method: "sim_getConsensusContract",
|
|
1958
|
-
params: ["ConsensusMain"]
|
|
1959
|
-
})
|
|
1960
|
-
});
|
|
1961
|
-
if (!contractsResponse.ok) {
|
|
1962
|
-
throw new Error("Failed to fetch ConsensusMain contract");
|
|
1963
|
-
}
|
|
1964
|
-
const consensusMainContract = await contractsResponse.json();
|
|
1965
|
-
if (_optionalChain([consensusMainContract, 'optionalAccess', _78 => _78.error]) || !_optionalChain([consensusMainContract, 'optionalAccess', _79 => _79.result, 'optionalAccess', _80 => _80.address]) || !_optionalChain([consensusMainContract, 'optionalAccess', _81 => _81.result, 'optionalAccess', _82 => _82.abi])) {
|
|
1966
|
-
throw new Error("ConsensusMain response did not include a valid contract");
|
|
1967
|
-
}
|
|
1968
|
-
client.chain.consensusMainContract = consensusMainContract.result;
|
|
1969
|
-
client.chain.__consensusAbiFetchedFromRpc = true;
|
|
1970
|
-
} catch (error) {
|
|
1971
|
-
if (hasStaticConsensusContract) {
|
|
1972
|
-
client.chain.__consensusAbiFetchedFromRpc = false;
|
|
1973
|
-
return;
|
|
1974
|
-
}
|
|
1975
|
-
throw error;
|
|
1976
|
-
}
|
|
1939
|
+
/**
|
|
1940
|
+
* @deprecated This method is deprecated and will be removed in a future release.
|
|
1941
|
+
* The consensus contract is now resolved from the static chain definition.
|
|
1942
|
+
*/
|
|
1943
|
+
initializeConsensusSmartContract: async (_forceReset = false) => {
|
|
1944
|
+
console.warn(
|
|
1945
|
+
"[genlayer-js] initializeConsensusSmartContract() is deprecated and will be removed in a future release. The consensus contract is now resolved from the static chain definition."
|
|
1946
|
+
);
|
|
1977
1947
|
}
|
|
1978
1948
|
};
|
|
1979
1949
|
}
|
|
@@ -2021,8 +1991,8 @@ var getCustomTransportConfig = (config, chainConfig) => {
|
|
|
2021
1991
|
}
|
|
2022
1992
|
};
|
|
2023
1993
|
};
|
|
2024
|
-
var createClient = (config = { chain:
|
|
2025
|
-
const chainConfig = config.chain ||
|
|
1994
|
+
var createClient = (config = { chain: _chunkTCAQ6AVFcjs.localnet }) => {
|
|
1995
|
+
const chainConfig = config.chain || _chunkTCAQ6AVFcjs.localnet;
|
|
2026
1996
|
if (config.endpoint) {
|
|
2027
1997
|
chainConfig.rpcUrls.default.http = [config.endpoint];
|
|
2028
1998
|
}
|
|
@@ -2054,9 +2024,6 @@ var createClient = (config = { chain: _chunk5TKVNHAOcjs.localnet }) => {
|
|
|
2054
2024
|
...clientWithReceiptActions,
|
|
2055
2025
|
...stakingActions(clientWithReceiptActions, publicClient)
|
|
2056
2026
|
};
|
|
2057
|
-
finalClient.initializeConsensusSmartContract().catch((error) => {
|
|
2058
|
-
console.error("Failed to initialize consensus smart contract:", error);
|
|
2059
|
-
});
|
|
2060
2027
|
return finalClient;
|
|
2061
2028
|
};
|
|
2062
2029
|
var createPublicClient = (chainConfig, customTransport) => {
|
|
@@ -2162,4 +2129,4 @@ function validateValueAgainstType(value, type) {
|
|
|
2162
2129
|
|
|
2163
2130
|
|
|
2164
2131
|
|
|
2165
|
-
exports.abi = abi_exports; exports.buildGenVmPositionalArgs = buildGenVmPositionalArgs; exports.chains =
|
|
2132
|
+
exports.abi = abi_exports; exports.buildGenVmPositionalArgs = buildGenVmPositionalArgs; exports.chains = _chunkTCAQ6AVFcjs.chains_exports; exports.createAccount = createAccount; exports.createClient = createClient; exports.decodeInputData = decodeInputData; exports.decodeLocalnetTransaction = decodeLocalnetTransaction; exports.decodeTransaction = decodeTransaction; exports.formatStakingAmount = formatStakingAmount; exports.generatePrivateKey = generatePrivateKey; exports.parseStakingAmount = parseStakingAmount; exports.simplifyTransactionReceipt = simplifyTransactionReceipt;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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-DxwfPDf6.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';
|
|
8
|
-
export { i as chains } from './index-
|
|
8
|
+
export { i as chains } from './index-DjR-MFPr.cjs';
|
|
9
9
|
|
|
10
10
|
interface ClientConfig {
|
|
11
11
|
chain?: {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as viem from 'viem';
|
|
2
2
|
import { Account, 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-B3hpL2wZ.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';
|
|
8
|
-
export { i as chains } from './index-
|
|
8
|
+
export { i as chains } from './index-HRqj9M3K.js';
|
|
9
9
|
|
|
10
10
|
interface ClientConfig {
|
|
11
11
|
chain?: {
|
package/dist/index.js
CHANGED
|
@@ -4,8 +4,9 @@ import {
|
|
|
4
4
|
chains_exports,
|
|
5
5
|
localnet,
|
|
6
6
|
studionet,
|
|
7
|
-
testnetAsimov
|
|
8
|
-
|
|
7
|
+
testnetAsimov,
|
|
8
|
+
testnetBradbury
|
|
9
|
+
} from "./chunk-5KRGDGMO.js";
|
|
9
10
|
import {
|
|
10
11
|
CalldataAddress,
|
|
11
12
|
isDecidedState,
|
|
@@ -624,7 +625,6 @@ var contractActions = (client, publicClient) => {
|
|
|
624
625
|
leaderOnly = false,
|
|
625
626
|
consensusMaxRotations = client.chain.defaultConsensusMaxRotations
|
|
626
627
|
} = args;
|
|
627
|
-
await client.initializeConsensusSmartContract();
|
|
628
628
|
const data = [encode(makeCalldataObject(functionName, callArgs, kwargs)), leaderOnly];
|
|
629
629
|
const serializedData = serialize(data);
|
|
630
630
|
const senderAccount = account || client.account;
|
|
@@ -653,7 +653,6 @@ var contractActions = (client, publicClient) => {
|
|
|
653
653
|
leaderOnly = false,
|
|
654
654
|
consensusMaxRotations = client.chain.defaultConsensusMaxRotations
|
|
655
655
|
} = args;
|
|
656
|
-
await client.initializeConsensusSmartContract();
|
|
657
656
|
const data = [
|
|
658
657
|
code,
|
|
659
658
|
encode(makeCalldataObject(void 0, constructorArgs, kwargs)),
|
|
@@ -1273,7 +1272,8 @@ var snapID = {
|
|
|
1273
1272
|
var networks = {
|
|
1274
1273
|
localnet,
|
|
1275
1274
|
studionet,
|
|
1276
|
-
testnetAsimov
|
|
1275
|
+
testnetAsimov,
|
|
1276
|
+
testnetBradbury
|
|
1277
1277
|
};
|
|
1278
1278
|
var connect = async (client, network = "studionet", snapSource = "npm") => {
|
|
1279
1279
|
if (!window.ethereum) {
|
|
@@ -1934,46 +1934,16 @@ var stakingActions = (client, publicClient) => {
|
|
|
1934
1934
|
};
|
|
1935
1935
|
|
|
1936
1936
|
// src/chains/actions.ts
|
|
1937
|
-
function chainActions(
|
|
1937
|
+
function chainActions(_client) {
|
|
1938
1938
|
return {
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
}
|
|
1948
|
-
try {
|
|
1949
|
-
const contractsResponse = await fetch(client.chain.rpcUrls.default.http[0], {
|
|
1950
|
-
method: "POST",
|
|
1951
|
-
headers: {
|
|
1952
|
-
"Content-Type": "application/json"
|
|
1953
|
-
},
|
|
1954
|
-
body: JSON.stringify({
|
|
1955
|
-
jsonrpc: "2.0",
|
|
1956
|
-
id: Date.now(),
|
|
1957
|
-
method: "sim_getConsensusContract",
|
|
1958
|
-
params: ["ConsensusMain"]
|
|
1959
|
-
})
|
|
1960
|
-
});
|
|
1961
|
-
if (!contractsResponse.ok) {
|
|
1962
|
-
throw new Error("Failed to fetch ConsensusMain contract");
|
|
1963
|
-
}
|
|
1964
|
-
const consensusMainContract = await contractsResponse.json();
|
|
1965
|
-
if (consensusMainContract?.error || !consensusMainContract?.result?.address || !consensusMainContract?.result?.abi) {
|
|
1966
|
-
throw new Error("ConsensusMain response did not include a valid contract");
|
|
1967
|
-
}
|
|
1968
|
-
client.chain.consensusMainContract = consensusMainContract.result;
|
|
1969
|
-
client.chain.__consensusAbiFetchedFromRpc = true;
|
|
1970
|
-
} catch (error) {
|
|
1971
|
-
if (hasStaticConsensusContract) {
|
|
1972
|
-
client.chain.__consensusAbiFetchedFromRpc = false;
|
|
1973
|
-
return;
|
|
1974
|
-
}
|
|
1975
|
-
throw error;
|
|
1976
|
-
}
|
|
1939
|
+
/**
|
|
1940
|
+
* @deprecated This method is deprecated and will be removed in a future release.
|
|
1941
|
+
* The consensus contract is now resolved from the static chain definition.
|
|
1942
|
+
*/
|
|
1943
|
+
initializeConsensusSmartContract: async (_forceReset = false) => {
|
|
1944
|
+
console.warn(
|
|
1945
|
+
"[genlayer-js] initializeConsensusSmartContract() is deprecated and will be removed in a future release. The consensus contract is now resolved from the static chain definition."
|
|
1946
|
+
);
|
|
1977
1947
|
}
|
|
1978
1948
|
};
|
|
1979
1949
|
}
|
|
@@ -2054,9 +2024,6 @@ var createClient = (config = { chain: localnet }) => {
|
|
|
2054
2024
|
...clientWithReceiptActions,
|
|
2055
2025
|
...stakingActions(clientWithReceiptActions, publicClient)
|
|
2056
2026
|
};
|
|
2057
|
-
finalClient.initializeConsensusSmartContract().catch((error) => {
|
|
2058
|
-
console.error("Failed to initialize consensus smart contract:", error);
|
|
2059
|
-
});
|
|
2060
2027
|
return finalClient;
|
|
2061
2028
|
};
|
|
2062
2029
|
var createPublicClient = (chainConfig, customTransport) => {
|
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-DxwfPDf6.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-B3hpL2wZ.js';
|
|
3
3
|
export { G as GenLayerChain } from '../chains-B7B7UXdn.js';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "genlayer-js",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.21.0",
|
|
5
5
|
"description": "GenLayer JavaScript SDK",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"@types/node": "^22.5.5",
|
|
47
47
|
"@typescript-eslint/eslint-plugin": "^8.5.0",
|
|
48
48
|
"@typescript-eslint/parser": "^8.5.0",
|
|
49
|
+
"@vitest/coverage-v8": "^2.1.1",
|
|
49
50
|
"cross-env": "^7.0.3",
|
|
50
51
|
"eslint": "^8.57.0",
|
|
51
52
|
"eslint-config-prettier": "^9.1.0",
|