genlayer-js 1.0.0 → 1.1.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/dist/{index-B-qwdW-z.d.ts → index-C3Ul1Rte.d.ts} +8 -2
- package/dist/{index-axkCvELR.d.cts → index-Cf770kyK.d.cts} +8 -2
- package/dist/index.cjs +35 -15
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +35 -15
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -2784,13 +2784,19 @@ type GenLayerMethod = {
|
|
|
2784
2784
|
params: [signedTransaction: string];
|
|
2785
2785
|
} | {
|
|
2786
2786
|
method: "gen_getContractSchema";
|
|
2787
|
-
params: [address: Address]
|
|
2787
|
+
params: [address: Address] | [{
|
|
2788
|
+
address: Address;
|
|
2789
|
+
}] | [{
|
|
2790
|
+
code: string;
|
|
2791
|
+
}];
|
|
2788
2792
|
} | {
|
|
2789
2793
|
method: "gen_getContractSchemaForCode";
|
|
2790
2794
|
params: [contractCode: string];
|
|
2791
2795
|
} | {
|
|
2792
2796
|
method: "gen_getContractCode";
|
|
2793
|
-
params: [address: Address]
|
|
2797
|
+
params: [address: Address] | [{
|
|
2798
|
+
address: Address;
|
|
2799
|
+
}];
|
|
2794
2800
|
} | {
|
|
2795
2801
|
method: "sim_getTransactionsForAddress";
|
|
2796
2802
|
params: [address: Address, filter?: "all" | "from" | "to"];
|
|
@@ -2784,13 +2784,19 @@ type GenLayerMethod = {
|
|
|
2784
2784
|
params: [signedTransaction: string];
|
|
2785
2785
|
} | {
|
|
2786
2786
|
method: "gen_getContractSchema";
|
|
2787
|
-
params: [address: Address]
|
|
2787
|
+
params: [address: Address] | [{
|
|
2788
|
+
address: Address;
|
|
2789
|
+
}] | [{
|
|
2790
|
+
code: string;
|
|
2791
|
+
}];
|
|
2788
2792
|
} | {
|
|
2789
2793
|
method: "gen_getContractSchemaForCode";
|
|
2790
2794
|
params: [contractCode: string];
|
|
2791
2795
|
} | {
|
|
2792
2796
|
method: "gen_getContractCode";
|
|
2793
|
-
params: [address: Address]
|
|
2797
|
+
params: [address: Address] | [{
|
|
2798
|
+
address: Address;
|
|
2799
|
+
}];
|
|
2794
2800
|
} | {
|
|
2795
2801
|
method: "sim_getTransactionsForAddress";
|
|
2796
2802
|
params: [address: Address, filter?: "all" | "from" | "to"];
|
package/dist/index.cjs
CHANGED
|
@@ -430,6 +430,13 @@ var transactions = transactions_exports;
|
|
|
430
430
|
function b64ToArray(b64) {
|
|
431
431
|
return Uint8Array.from(atob(b64), (c) => c.charCodeAt(0));
|
|
432
432
|
}
|
|
433
|
+
function arrayToB64(bytes) {
|
|
434
|
+
let binary = "";
|
|
435
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
436
|
+
binary += String.fromCharCode(bytes[i]);
|
|
437
|
+
}
|
|
438
|
+
return btoa(binary);
|
|
439
|
+
}
|
|
433
440
|
function calldataToUserFriendlyJson(cd) {
|
|
434
441
|
return {
|
|
435
442
|
raw: Array.from(cd),
|
|
@@ -530,37 +537,49 @@ function extractGenCallResult(result) {
|
|
|
530
537
|
}
|
|
531
538
|
var contractActions = (client, publicClient) => {
|
|
532
539
|
return {
|
|
533
|
-
/** Retrieves the source code of a deployed contract.
|
|
540
|
+
/** Retrieves the source code of a deployed contract. */
|
|
534
541
|
getContractCode: async (address) => {
|
|
535
|
-
|
|
536
|
-
throw new Error(`getContractCode is only available on Studio networks (current chain: ${client.chain.name})`);
|
|
537
|
-
}
|
|
542
|
+
const params = client.chain.isStudio ? [address] : [{ address }];
|
|
538
543
|
const result = await client.request({
|
|
539
544
|
method: "gen_getContractCode",
|
|
540
|
-
params
|
|
545
|
+
params
|
|
541
546
|
});
|
|
542
547
|
const codeBytes = b64ToArray(result);
|
|
543
548
|
return new TextDecoder().decode(codeBytes);
|
|
544
549
|
},
|
|
545
|
-
/** Gets the schema (methods and constructor) of a deployed contract.
|
|
550
|
+
/** Gets the schema (methods and constructor) of a deployed contract. */
|
|
546
551
|
getContractSchema: async (address) => {
|
|
547
|
-
if (
|
|
548
|
-
|
|
552
|
+
if (client.chain.isStudio) {
|
|
553
|
+
const schema2 = await client.request({
|
|
554
|
+
method: "gen_getContractSchema",
|
|
555
|
+
params: [address]
|
|
556
|
+
});
|
|
557
|
+
return schema2;
|
|
549
558
|
}
|
|
559
|
+
const codeB64 = await client.request({
|
|
560
|
+
method: "gen_getContractCode",
|
|
561
|
+
params: [{ address }]
|
|
562
|
+
});
|
|
550
563
|
const schema = await client.request({
|
|
551
564
|
method: "gen_getContractSchema",
|
|
552
|
-
params: [
|
|
565
|
+
params: [{ code: codeB64 }]
|
|
553
566
|
});
|
|
554
567
|
return schema;
|
|
555
568
|
},
|
|
556
|
-
/** Generates a schema for contract code without deploying it.
|
|
569
|
+
/** Generates a schema for contract code without deploying it. */
|
|
557
570
|
getContractSchemaForCode: async (contractCode) => {
|
|
558
|
-
if (
|
|
559
|
-
|
|
571
|
+
if (client.chain.isStudio) {
|
|
572
|
+
const schema2 = await client.request({
|
|
573
|
+
method: "gen_getContractSchemaForCode",
|
|
574
|
+
params: [_viem.toHex.call(void 0, contractCode)]
|
|
575
|
+
});
|
|
576
|
+
return schema2;
|
|
560
577
|
}
|
|
578
|
+
const bytes = typeof contractCode === "string" ? new TextEncoder().encode(contractCode) : contractCode;
|
|
579
|
+
const codeB64 = arrayToB64(bytes);
|
|
561
580
|
const schema = await client.request({
|
|
562
|
-
method: "
|
|
563
|
-
params: [
|
|
581
|
+
method: "gen_getContractSchema",
|
|
582
|
+
params: [{ code: codeB64 }]
|
|
564
583
|
});
|
|
565
584
|
return schema;
|
|
566
585
|
},
|
|
@@ -924,10 +943,11 @@ var _encodeAddTransactionData = ({
|
|
|
924
943
|
functionName: "addTransaction",
|
|
925
944
|
args: addTransactionArgs
|
|
926
945
|
});
|
|
946
|
+
const validUntil = BigInt(Math.floor(Date.now() / 1e3) + 3600);
|
|
927
947
|
const encodedDataV6 = _viem.encodeFunctionData.call(void 0, {
|
|
928
948
|
abi: ADD_TRANSACTION_ABI_V6,
|
|
929
949
|
functionName: "addTransaction",
|
|
930
|
-
args: [...addTransactionArgs,
|
|
950
|
+
args: [...addTransactionArgs, validUntil]
|
|
931
951
|
});
|
|
932
952
|
if (getAddTransactionInputCount(_optionalChain([client, 'access', _42 => _42.chain, 'access', _43 => _43.consensusMainContract, 'optionalAccess', _44 => _44.abi])) >= 6) {
|
|
933
953
|
return {
|
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-D6DgvIVA.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-Cf770kyK.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-D6DgvIVA.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-C3Ul1Rte.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
|
@@ -430,6 +430,13 @@ import { toHex as toHex2 } from "viem";
|
|
|
430
430
|
function b64ToArray(b64) {
|
|
431
431
|
return Uint8Array.from(atob(b64), (c) => c.charCodeAt(0));
|
|
432
432
|
}
|
|
433
|
+
function arrayToB64(bytes) {
|
|
434
|
+
let binary = "";
|
|
435
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
436
|
+
binary += String.fromCharCode(bytes[i]);
|
|
437
|
+
}
|
|
438
|
+
return btoa(binary);
|
|
439
|
+
}
|
|
433
440
|
function calldataToUserFriendlyJson(cd) {
|
|
434
441
|
return {
|
|
435
442
|
raw: Array.from(cd),
|
|
@@ -530,37 +537,49 @@ function extractGenCallResult(result) {
|
|
|
530
537
|
}
|
|
531
538
|
var contractActions = (client, publicClient) => {
|
|
532
539
|
return {
|
|
533
|
-
/** Retrieves the source code of a deployed contract.
|
|
540
|
+
/** Retrieves the source code of a deployed contract. */
|
|
534
541
|
getContractCode: async (address) => {
|
|
535
|
-
|
|
536
|
-
throw new Error(`getContractCode is only available on Studio networks (current chain: ${client.chain.name})`);
|
|
537
|
-
}
|
|
542
|
+
const params = client.chain.isStudio ? [address] : [{ address }];
|
|
538
543
|
const result = await client.request({
|
|
539
544
|
method: "gen_getContractCode",
|
|
540
|
-
params
|
|
545
|
+
params
|
|
541
546
|
});
|
|
542
547
|
const codeBytes = b64ToArray(result);
|
|
543
548
|
return new TextDecoder().decode(codeBytes);
|
|
544
549
|
},
|
|
545
|
-
/** Gets the schema (methods and constructor) of a deployed contract.
|
|
550
|
+
/** Gets the schema (methods and constructor) of a deployed contract. */
|
|
546
551
|
getContractSchema: async (address) => {
|
|
547
|
-
if (
|
|
548
|
-
|
|
552
|
+
if (client.chain.isStudio) {
|
|
553
|
+
const schema2 = await client.request({
|
|
554
|
+
method: "gen_getContractSchema",
|
|
555
|
+
params: [address]
|
|
556
|
+
});
|
|
557
|
+
return schema2;
|
|
549
558
|
}
|
|
559
|
+
const codeB64 = await client.request({
|
|
560
|
+
method: "gen_getContractCode",
|
|
561
|
+
params: [{ address }]
|
|
562
|
+
});
|
|
550
563
|
const schema = await client.request({
|
|
551
564
|
method: "gen_getContractSchema",
|
|
552
|
-
params: [
|
|
565
|
+
params: [{ code: codeB64 }]
|
|
553
566
|
});
|
|
554
567
|
return schema;
|
|
555
568
|
},
|
|
556
|
-
/** Generates a schema for contract code without deploying it.
|
|
569
|
+
/** Generates a schema for contract code without deploying it. */
|
|
557
570
|
getContractSchemaForCode: async (contractCode) => {
|
|
558
|
-
if (
|
|
559
|
-
|
|
571
|
+
if (client.chain.isStudio) {
|
|
572
|
+
const schema2 = await client.request({
|
|
573
|
+
method: "gen_getContractSchemaForCode",
|
|
574
|
+
params: [toHex3(contractCode)]
|
|
575
|
+
});
|
|
576
|
+
return schema2;
|
|
560
577
|
}
|
|
578
|
+
const bytes = typeof contractCode === "string" ? new TextEncoder().encode(contractCode) : contractCode;
|
|
579
|
+
const codeB64 = arrayToB64(bytes);
|
|
561
580
|
const schema = await client.request({
|
|
562
|
-
method: "
|
|
563
|
-
params: [
|
|
581
|
+
method: "gen_getContractSchema",
|
|
582
|
+
params: [{ code: codeB64 }]
|
|
564
583
|
});
|
|
565
584
|
return schema;
|
|
566
585
|
},
|
|
@@ -924,10 +943,11 @@ var _encodeAddTransactionData = ({
|
|
|
924
943
|
functionName: "addTransaction",
|
|
925
944
|
args: addTransactionArgs
|
|
926
945
|
});
|
|
946
|
+
const validUntil = BigInt(Math.floor(Date.now() / 1e3) + 3600);
|
|
927
947
|
const encodedDataV6 = encodeFunctionData({
|
|
928
948
|
abi: ADD_TRANSACTION_ABI_V6,
|
|
929
949
|
functionName: "addTransaction",
|
|
930
|
-
args: [...addTransactionArgs,
|
|
950
|
+
args: [...addTransactionArgs, validUntil]
|
|
931
951
|
});
|
|
932
952
|
if (getAddTransactionInputCount(client.chain.consensusMainContract?.abi) >= 6) {
|
|
933
953
|
return {
|
package/dist/types/index.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { Account, Address } from 'viem';
|
|
2
|
-
export { O 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, z as DebugTraceResult, a as DecodedCallData, D as DecodedDeployData, a7 as DelegatorClaimOptions, a6 as DelegatorExitOptions, a5 as DelegatorJoinOptions, Z as DelegatorJoinResult, R as EpochData, U as EpochInfo, E as ExecutionResult, 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, K as PendingWithdrawal, a4 as SetIdentityOptions, a3 as SetOperatorOptions, A as SnapSource, Q as StakeInfo, a8 as StakingActions, B as StakingContract, X as StakingTransactionResult, k as TransactionHash, y as TransactionHashVariant, m as TransactionResult, r as TransactionResultNameToNumber, l as TransactionStatus, x as TransactionType, a1 as ValidatorClaimOptions, $ as ValidatorDepositOptions, a0 as ValidatorExitOptions, I as ValidatorIdentity, J as ValidatorInfo, _ as ValidatorJoinOptions, Y as ValidatorJoinResult, a2 as ValidatorPrimeOptions, F as ValidatorView, u as VoteType, W as WithdrawalCommit, s as executionResultNumberToName, p as isDecidedState, q as transactionResultNumberToName, n as transactionsStatusNameToNumber, t as transactionsStatusNumberToName, w as voteTypeNameToNumber, v as voteTypeNumberToName } from '../index-
|
|
2
|
+
export { O 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, z as DebugTraceResult, a as DecodedCallData, D as DecodedDeployData, a7 as DelegatorClaimOptions, a6 as DelegatorExitOptions, a5 as DelegatorJoinOptions, Z as DelegatorJoinResult, R as EpochData, U as EpochInfo, E as ExecutionResult, 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, K as PendingWithdrawal, a4 as SetIdentityOptions, a3 as SetOperatorOptions, A as SnapSource, Q as StakeInfo, a8 as StakingActions, B as StakingContract, X as StakingTransactionResult, k as TransactionHash, y as TransactionHashVariant, m as TransactionResult, r as TransactionResultNameToNumber, l as TransactionStatus, x as TransactionType, a1 as ValidatorClaimOptions, $ as ValidatorDepositOptions, a0 as ValidatorExitOptions, I as ValidatorIdentity, J as ValidatorInfo, _ as ValidatorJoinOptions, Y as ValidatorJoinResult, a2 as ValidatorPrimeOptions, F as ValidatorView, u as VoteType, W as WithdrawalCommit, s as executionResultNumberToName, p as isDecidedState, q as transactionResultNumberToName, n as transactionsStatusNameToNumber, t as transactionsStatusNumberToName, w as voteTypeNameToNumber, v as voteTypeNumberToName } from '../index-Cf770kyK.cjs';
|
|
3
3
|
export { G as GenLayerChain } from '../chains-D6DgvIVA.cjs';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { Account, Address } from 'viem';
|
|
2
|
-
export { O 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, z as DebugTraceResult, a as DecodedCallData, D as DecodedDeployData, a7 as DelegatorClaimOptions, a6 as DelegatorExitOptions, a5 as DelegatorJoinOptions, Z as DelegatorJoinResult, R as EpochData, U as EpochInfo, E as ExecutionResult, 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, K as PendingWithdrawal, a4 as SetIdentityOptions, a3 as SetOperatorOptions, A as SnapSource, Q as StakeInfo, a8 as StakingActions, B as StakingContract, X as StakingTransactionResult, k as TransactionHash, y as TransactionHashVariant, m as TransactionResult, r as TransactionResultNameToNumber, l as TransactionStatus, x as TransactionType, a1 as ValidatorClaimOptions, $ as ValidatorDepositOptions, a0 as ValidatorExitOptions, I as ValidatorIdentity, J as ValidatorInfo, _ as ValidatorJoinOptions, Y as ValidatorJoinResult, a2 as ValidatorPrimeOptions, F as ValidatorView, u as VoteType, W as WithdrawalCommit, s as executionResultNumberToName, p as isDecidedState, q as transactionResultNumberToName, n as transactionsStatusNameToNumber, t as transactionsStatusNumberToName, w as voteTypeNameToNumber, v as voteTypeNumberToName } from '../index-
|
|
2
|
+
export { O 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, z as DebugTraceResult, a as DecodedCallData, D as DecodedDeployData, a7 as DelegatorClaimOptions, a6 as DelegatorExitOptions, a5 as DelegatorJoinOptions, Z as DelegatorJoinResult, R as EpochData, U as EpochInfo, E as ExecutionResult, 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, K as PendingWithdrawal, a4 as SetIdentityOptions, a3 as SetOperatorOptions, A as SnapSource, Q as StakeInfo, a8 as StakingActions, B as StakingContract, X as StakingTransactionResult, k as TransactionHash, y as TransactionHashVariant, m as TransactionResult, r as TransactionResultNameToNumber, l as TransactionStatus, x as TransactionType, a1 as ValidatorClaimOptions, $ as ValidatorDepositOptions, a0 as ValidatorExitOptions, I as ValidatorIdentity, J as ValidatorInfo, _ as ValidatorJoinOptions, Y as ValidatorJoinResult, a2 as ValidatorPrimeOptions, F as ValidatorView, u as VoteType, W as WithdrawalCommit, s as executionResultNumberToName, p as isDecidedState, q as transactionResultNumberToName, n as transactionsStatusNameToNumber, t as transactionsStatusNumberToName, w as voteTypeNameToNumber, v as voteTypeNumberToName } from '../index-C3Ul1Rte.js';
|
|
3
3
|
export { G as GenLayerChain } from '../chains-D6DgvIVA.js';
|