@monolythium/core-sdk 0.3.12 → 0.3.13
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.cjs +209 -56
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +62 -1
- package/dist/index.d.ts +62 -1
- package/dist/index.js +209 -57
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1822,9 +1822,16 @@ var TESTNET_69420 = {
|
|
|
1822
1822
|
network: "testnet-69420",
|
|
1823
1823
|
display_name: "Monolythium Testnet",
|
|
1824
1824
|
description: "Public Monolythium testnet. Testnet state may reset without notice; do not store value on this network.",
|
|
1825
|
-
genesis_hash: "
|
|
1826
|
-
binary_sha: "
|
|
1825
|
+
genesis_hash: "0xe67cf82131fc63e335ce61afeae53299283eaa3a692830a618911aa840245031",
|
|
1826
|
+
binary_sha: "e4697f9b",
|
|
1827
1827
|
rpc: [
|
|
1828
|
+
{
|
|
1829
|
+
url: "http://178.105.12.9:8545",
|
|
1830
|
+
provider: "monolythium-foundation",
|
|
1831
|
+
region: "fsn1",
|
|
1832
|
+
tier: "official",
|
|
1833
|
+
notes: "operator-1"
|
|
1834
|
+
},
|
|
1828
1835
|
{
|
|
1829
1836
|
url: "http://178.105.15.216:8545",
|
|
1830
1837
|
provider: "monolythium-foundation",
|
|
@@ -1866,9 +1873,107 @@ var TESTNET_69420 = {
|
|
|
1866
1873
|
region: "sin",
|
|
1867
1874
|
tier: "official",
|
|
1868
1875
|
notes: "operator-7; APAC"
|
|
1876
|
+
},
|
|
1877
|
+
{
|
|
1878
|
+
url: "http://142.132.180.99:8545",
|
|
1879
|
+
provider: "monolythium-foundation",
|
|
1880
|
+
region: "fsn1",
|
|
1881
|
+
tier: "official",
|
|
1882
|
+
notes: "operator-8"
|
|
1883
|
+
},
|
|
1884
|
+
{
|
|
1885
|
+
url: "http://162.55.54.198:8545",
|
|
1886
|
+
provider: "monolythium-foundation",
|
|
1887
|
+
region: "nbg1",
|
|
1888
|
+
tier: "official",
|
|
1889
|
+
notes: "operator-9"
|
|
1890
|
+
},
|
|
1891
|
+
{
|
|
1892
|
+
url: "http://95.217.156.190:8545",
|
|
1893
|
+
provider: "monolythium-foundation",
|
|
1894
|
+
region: "hel1",
|
|
1895
|
+
tier: "official",
|
|
1896
|
+
notes: "operator-10"
|
|
1897
|
+
},
|
|
1898
|
+
{
|
|
1899
|
+
url: "http://5.223.65.201:8545",
|
|
1900
|
+
provider: "monolythium-foundation",
|
|
1901
|
+
region: "sin",
|
|
1902
|
+
tier: "official",
|
|
1903
|
+
notes: "operator-11; APAC"
|
|
1904
|
+
},
|
|
1905
|
+
{
|
|
1906
|
+
url: "http://128.140.125.5:8545",
|
|
1907
|
+
provider: "monolythium-foundation",
|
|
1908
|
+
region: "fsn1",
|
|
1909
|
+
tier: "official",
|
|
1910
|
+
notes: "operator-12"
|
|
1911
|
+
},
|
|
1912
|
+
{
|
|
1913
|
+
url: "http://178.105.45.210:8545",
|
|
1914
|
+
provider: "monolythium-foundation",
|
|
1915
|
+
region: "nbg1",
|
|
1916
|
+
tier: "official",
|
|
1917
|
+
notes: "relay-1"
|
|
1918
|
+
},
|
|
1919
|
+
{
|
|
1920
|
+
url: "http://65.21.252.34:8545",
|
|
1921
|
+
provider: "monolythium-foundation",
|
|
1922
|
+
region: "hel1",
|
|
1923
|
+
tier: "official",
|
|
1924
|
+
notes: "relay-2"
|
|
1869
1925
|
}
|
|
1870
1926
|
],
|
|
1871
|
-
p2p: [
|
|
1927
|
+
p2p: [
|
|
1928
|
+
{
|
|
1929
|
+
multiaddr: "/ip4/178.105.12.9/tcp/29898/p2p/12D3KooWPv4ctqZX9faHicr8dJifyBwrpPA4oBev7w2WZStejMKa",
|
|
1930
|
+
region: "fsn1"
|
|
1931
|
+
},
|
|
1932
|
+
{
|
|
1933
|
+
multiaddr: "/ip4/178.105.15.216/tcp/29898/p2p/12D3KooWFZqKgAbve2dsAm9kKomychF4dyhtJYHL13mzh3D62d1r",
|
|
1934
|
+
region: "fsn1"
|
|
1935
|
+
},
|
|
1936
|
+
{
|
|
1937
|
+
multiaddr: "/ip4/178.104.233.182/tcp/29898/p2p/12D3KooWMG1tbP4hcvqdPP8QmnnPjaJCs4M1GUskzAJsL15ZFcVX",
|
|
1938
|
+
region: "nbg1"
|
|
1939
|
+
},
|
|
1940
|
+
{
|
|
1941
|
+
multiaddr: "/ip4/65.108.94.1/tcp/29898/p2p/12D3KooWR5cz3fR4YkDDoPmQ6Qe7fmsXA7zo5AqdHY5Enmk5bKyT",
|
|
1942
|
+
region: "hel1"
|
|
1943
|
+
},
|
|
1944
|
+
{
|
|
1945
|
+
multiaddr: "/ip4/95.216.154.155/tcp/29898/p2p/12D3KooWFJHH3zgAaPtSBXPkCEKeGNCWQTn1QYcm4YCr5VFT3GbC",
|
|
1946
|
+
region: "hel1"
|
|
1947
|
+
},
|
|
1948
|
+
{
|
|
1949
|
+
multiaddr: "/ip4/87.99.145.48/tcp/29898/p2p/12D3KooWSDQdjgoiEbvsLErphM52u8tETdBtgyr4mbHQC5pT6HQz",
|
|
1950
|
+
region: "ash"
|
|
1951
|
+
},
|
|
1952
|
+
{
|
|
1953
|
+
multiaddr: "/ip4/5.223.85.76/tcp/29898/p2p/12D3KooWKHgMQnBtSfZqUknJdhGK8niKKbLXy81ifHV2khRgAYFX",
|
|
1954
|
+
region: "sin"
|
|
1955
|
+
},
|
|
1956
|
+
{
|
|
1957
|
+
multiaddr: "/ip4/142.132.180.99/tcp/29898/p2p/12D3KooWBx29V8iNQL22jk2CSVbvhodtXy4uTXVG7AgobxNcUuyP",
|
|
1958
|
+
region: "fsn1"
|
|
1959
|
+
},
|
|
1960
|
+
{
|
|
1961
|
+
multiaddr: "/ip4/162.55.54.198/tcp/29898/p2p/12D3KooWJK2w6xzRFJMHWMxVuXpBHZE7PtDNGahEp9rq86AuhNRk",
|
|
1962
|
+
region: "nbg1"
|
|
1963
|
+
},
|
|
1964
|
+
{
|
|
1965
|
+
multiaddr: "/ip4/95.217.156.190/tcp/29898/p2p/12D3KooWLD8kzKHPVexZv2pMTvpjcEPTVZxr5qMxCeVB2QR6NNa6",
|
|
1966
|
+
region: "hel1"
|
|
1967
|
+
},
|
|
1968
|
+
{
|
|
1969
|
+
multiaddr: "/ip4/5.223.65.201/tcp/29898/p2p/12D3KooWAHC1cCiVsyVqrg4ofS2EQmu6Pv6G9Rc1t5btmoW6YicJ",
|
|
1970
|
+
region: "sin"
|
|
1971
|
+
},
|
|
1972
|
+
{
|
|
1973
|
+
multiaddr: "/ip4/128.140.125.5/tcp/29898/p2p/12D3KooWNAc4EWkWWprKvqoF5aiq1ByqsLQjSN7r9ZTwYgGW365r",
|
|
1974
|
+
region: "fsn1"
|
|
1975
|
+
}
|
|
1976
|
+
]
|
|
1872
1977
|
};
|
|
1873
1978
|
var CHAIN_REGISTRY = {
|
|
1874
1979
|
"testnet-69420": TESTNET_69420
|
|
@@ -3982,6 +4087,83 @@ function parseNullableString(value, label) {
|
|
|
3982
4087
|
return value;
|
|
3983
4088
|
}
|
|
3984
4089
|
|
|
4090
|
+
// src/tx-fee.ts
|
|
4091
|
+
var REGISTRY_DEFAULT_EXECUTION_UNIT_LIMIT = 250000n;
|
|
4092
|
+
var TRANSFER_DEFAULT_EXECUTION_UNIT_LIMIT = 100000n;
|
|
4093
|
+
var MIN_EXECUTION_UNIT_PRICE_LYTHOSHI = 2000n;
|
|
4094
|
+
var EXECUTION_UNIT_PRICE_SAFETY_MULTIPLIER = 3n;
|
|
4095
|
+
function asBigint(value, label) {
|
|
4096
|
+
try {
|
|
4097
|
+
return typeof value === "bigint" ? value : BigInt(value);
|
|
4098
|
+
} catch {
|
|
4099
|
+
throw new Error(`${label} is not an integer: ${String(value)}`);
|
|
4100
|
+
}
|
|
4101
|
+
}
|
|
4102
|
+
function clampPriorityTip(priorityTipLythoshi, maxExecutionUnitPriceLythoshi) {
|
|
4103
|
+
const tip = asBigint(priorityTipLythoshi, "priorityTipLythoshi");
|
|
4104
|
+
const cap = asBigint(maxExecutionUnitPriceLythoshi, "maxExecutionUnitPriceLythoshi");
|
|
4105
|
+
if (tip < 0n) throw new Error("priorityTipLythoshi must be non-negative");
|
|
4106
|
+
return tip > cap ? cap : tip;
|
|
4107
|
+
}
|
|
4108
|
+
async function resolveMaxExecutionUnitPrice(client, options = {}) {
|
|
4109
|
+
const floor = options.minPriceLythoshi ?? MIN_EXECUTION_UNIT_PRICE_LYTHOSHI;
|
|
4110
|
+
const multiplier = options.safetyMultiplier ?? EXECUTION_UNIT_PRICE_SAFETY_MULTIPLIER;
|
|
4111
|
+
const quote = await client.lythExecutionUnitPrice();
|
|
4112
|
+
let unitPrice;
|
|
4113
|
+
try {
|
|
4114
|
+
unitPrice = BigInt(quote.executionUnitPriceLythoshi);
|
|
4115
|
+
} catch {
|
|
4116
|
+
throw SdkError.malformed(
|
|
4117
|
+
`lyth_executionUnitPrice returned a non-integer executionUnitPriceLythoshi: ${quote.executionUnitPriceLythoshi}`
|
|
4118
|
+
);
|
|
4119
|
+
}
|
|
4120
|
+
const base = unitPrice > floor ? unitPrice : floor;
|
|
4121
|
+
return base * multiplier;
|
|
4122
|
+
}
|
|
4123
|
+
async function resolveExecutionFee(client, options = {}) {
|
|
4124
|
+
const maxFeePerGas = await resolveMaxExecutionUnitPrice(client, {
|
|
4125
|
+
minPriceLythoshi: options.minPriceLythoshi,
|
|
4126
|
+
safetyMultiplier: options.safetyMultiplier
|
|
4127
|
+
});
|
|
4128
|
+
const tip = options.priorityTipLythoshi === void 0 ? maxFeePerGas : clampPriorityTip(options.priorityTipLythoshi, maxFeePerGas);
|
|
4129
|
+
return {
|
|
4130
|
+
maxFeePerGas,
|
|
4131
|
+
maxPriorityFeePerGas: tip,
|
|
4132
|
+
gasLimit: options.executionUnitLimit ?? TRANSFER_DEFAULT_EXECUTION_UNIT_LIMIT
|
|
4133
|
+
};
|
|
4134
|
+
}
|
|
4135
|
+
async function resolveRegistryExecutionFee(client, options = {}) {
|
|
4136
|
+
return resolveExecutionFee(client, {
|
|
4137
|
+
...options,
|
|
4138
|
+
executionUnitLimit: options.executionUnitLimit ?? REGISTRY_DEFAULT_EXECUTION_UNIT_LIMIT
|
|
4139
|
+
});
|
|
4140
|
+
}
|
|
4141
|
+
function feeFieldToBigint(value, field2) {
|
|
4142
|
+
if (typeof value !== "string" || !/^\d+$/.test(value.trim())) {
|
|
4143
|
+
throw SdkError.malformed(`${field2} is not an integer: ${String(value)}`);
|
|
4144
|
+
}
|
|
4145
|
+
try {
|
|
4146
|
+
return BigInt(value.trim());
|
|
4147
|
+
} catch {
|
|
4148
|
+
throw SdkError.malformed(`${field2} is not an integer: ${String(value)}`);
|
|
4149
|
+
}
|
|
4150
|
+
}
|
|
4151
|
+
function transactionFeeExposure(fee) {
|
|
4152
|
+
const basePrice = feeFieldToBigint(
|
|
4153
|
+
fee.base_price_per_cycle_lythoshi,
|
|
4154
|
+
"fee.base_price_per_cycle_lythoshi"
|
|
4155
|
+
);
|
|
4156
|
+
const priorityTip = feeFieldToBigint(
|
|
4157
|
+
fee.priority_tip_lythoshi,
|
|
4158
|
+
"fee.priority_tip_lythoshi"
|
|
4159
|
+
);
|
|
4160
|
+
feeFieldToBigint(fee.total_lythoshi, "fee.total_lythoshi");
|
|
4161
|
+
return {
|
|
4162
|
+
feeLythoshi: fee.total_lythoshi,
|
|
4163
|
+
effectiveGasPricePerUnit: (basePrice + priorityTip).toString()
|
|
4164
|
+
};
|
|
4165
|
+
}
|
|
4166
|
+
|
|
3985
4167
|
// src/api.ts
|
|
3986
4168
|
var SDK_VERSION2 = "0.1.0";
|
|
3987
4169
|
function apiEndpointFromRpcEndpoint(endpoint) {
|
|
@@ -4057,7 +4239,13 @@ var ApiClient = class {
|
|
|
4057
4239
|
};
|
|
4058
4240
|
}
|
|
4059
4241
|
async transaction(hash) {
|
|
4060
|
-
|
|
4242
|
+
const response = await this.get(
|
|
4243
|
+
`/transactions/${encodePathSegment(hash)}`
|
|
4244
|
+
);
|
|
4245
|
+
return {
|
|
4246
|
+
...response,
|
|
4247
|
+
data: enrichTransactionDataWithFee(response.data)
|
|
4248
|
+
};
|
|
4061
4249
|
}
|
|
4062
4250
|
async transactionReceipt(hash) {
|
|
4063
4251
|
return this.get(`/transactions/${encodePathSegment(hash)}/receipt`);
|
|
@@ -4286,6 +4474,22 @@ var ApiClient = class {
|
|
|
4286
4474
|
return parsed;
|
|
4287
4475
|
}
|
|
4288
4476
|
};
|
|
4477
|
+
function enrichTransactionDataWithFee(data) {
|
|
4478
|
+
const exposure = transactionFeeExposure(data.transaction.fee);
|
|
4479
|
+
return {
|
|
4480
|
+
...data,
|
|
4481
|
+
transaction: {
|
|
4482
|
+
...data.transaction,
|
|
4483
|
+
feeLythoshi: exposure.feeLythoshi,
|
|
4484
|
+
effectiveGasPricePerUnit: exposure.effectiveGasPricePerUnit
|
|
4485
|
+
},
|
|
4486
|
+
receipt: data.receipt == null ? data.receipt : {
|
|
4487
|
+
...data.receipt,
|
|
4488
|
+
feeLythoshi: exposure.feeLythoshi,
|
|
4489
|
+
effectiveGasPricePerUnit: exposure.effectiveGasPricePerUnit
|
|
4490
|
+
}
|
|
4491
|
+
};
|
|
4492
|
+
}
|
|
4289
4493
|
function parseApiError(value) {
|
|
4290
4494
|
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
4291
4495
|
const error = value["error"];
|
|
@@ -6668,58 +6872,6 @@ function assertWholeNumber(field2, value) {
|
|
|
6668
6872
|
throw new Error(`${field2} must be a whole number`);
|
|
6669
6873
|
}
|
|
6670
6874
|
}
|
|
6671
|
-
|
|
6672
|
-
// src/tx-fee.ts
|
|
6673
|
-
var REGISTRY_DEFAULT_EXECUTION_UNIT_LIMIT = 250000n;
|
|
6674
|
-
var TRANSFER_DEFAULT_EXECUTION_UNIT_LIMIT = 100000n;
|
|
6675
|
-
var MIN_EXECUTION_UNIT_PRICE_LYTHOSHI = 2000n;
|
|
6676
|
-
var EXECUTION_UNIT_PRICE_SAFETY_MULTIPLIER = 3n;
|
|
6677
|
-
function asBigint(value, label) {
|
|
6678
|
-
try {
|
|
6679
|
-
return typeof value === "bigint" ? value : BigInt(value);
|
|
6680
|
-
} catch {
|
|
6681
|
-
throw new Error(`${label} is not an integer: ${String(value)}`);
|
|
6682
|
-
}
|
|
6683
|
-
}
|
|
6684
|
-
function clampPriorityTip(priorityTipLythoshi, maxExecutionUnitPriceLythoshi) {
|
|
6685
|
-
const tip = asBigint(priorityTipLythoshi, "priorityTipLythoshi");
|
|
6686
|
-
const cap = asBigint(maxExecutionUnitPriceLythoshi, "maxExecutionUnitPriceLythoshi");
|
|
6687
|
-
if (tip < 0n) throw new Error("priorityTipLythoshi must be non-negative");
|
|
6688
|
-
return tip > cap ? cap : tip;
|
|
6689
|
-
}
|
|
6690
|
-
async function resolveMaxExecutionUnitPrice(client, options = {}) {
|
|
6691
|
-
const floor = options.minPriceLythoshi ?? MIN_EXECUTION_UNIT_PRICE_LYTHOSHI;
|
|
6692
|
-
const multiplier = options.safetyMultiplier ?? EXECUTION_UNIT_PRICE_SAFETY_MULTIPLIER;
|
|
6693
|
-
const quote = await client.lythExecutionUnitPrice();
|
|
6694
|
-
let unitPrice;
|
|
6695
|
-
try {
|
|
6696
|
-
unitPrice = BigInt(quote.executionUnitPriceLythoshi);
|
|
6697
|
-
} catch {
|
|
6698
|
-
throw SdkError.malformed(
|
|
6699
|
-
`lyth_executionUnitPrice returned a non-integer executionUnitPriceLythoshi: ${quote.executionUnitPriceLythoshi}`
|
|
6700
|
-
);
|
|
6701
|
-
}
|
|
6702
|
-
const base = unitPrice > floor ? unitPrice : floor;
|
|
6703
|
-
return base * multiplier;
|
|
6704
|
-
}
|
|
6705
|
-
async function resolveExecutionFee(client, options = {}) {
|
|
6706
|
-
const maxFeePerGas = await resolveMaxExecutionUnitPrice(client, {
|
|
6707
|
-
minPriceLythoshi: options.minPriceLythoshi,
|
|
6708
|
-
safetyMultiplier: options.safetyMultiplier
|
|
6709
|
-
});
|
|
6710
|
-
const tip = options.priorityTipLythoshi === void 0 ? maxFeePerGas : clampPriorityTip(options.priorityTipLythoshi, maxFeePerGas);
|
|
6711
|
-
return {
|
|
6712
|
-
maxFeePerGas,
|
|
6713
|
-
maxPriorityFeePerGas: tip,
|
|
6714
|
-
gasLimit: options.executionUnitLimit ?? TRANSFER_DEFAULT_EXECUTION_UNIT_LIMIT
|
|
6715
|
-
};
|
|
6716
|
-
}
|
|
6717
|
-
async function resolveRegistryExecutionFee(client, options = {}) {
|
|
6718
|
-
return resolveExecutionFee(client, {
|
|
6719
|
-
...options,
|
|
6720
|
-
executionUnitLimit: options.executionUnitLimit ?? REGISTRY_DEFAULT_EXECUTION_UNIT_LIMIT
|
|
6721
|
-
});
|
|
6722
|
-
}
|
|
6723
6875
|
var ORACLE_EVENT_SIGS = {
|
|
6724
6876
|
oracleRoundFinalized: "OracleRoundFinalized(bytes32,uint64,uint256,uint64,uint32)",
|
|
6725
6877
|
observationSubmitted: "ObservationSubmitted(bytes32,uint64,address,uint256,uint64)",
|
|
@@ -9310,6 +9462,7 @@ exports.submitMrvCallNativeTx = submitMrvCallNativeTx;
|
|
|
9310
9462
|
exports.submitMrvDeployNativeTx = submitMrvDeployNativeTx;
|
|
9311
9463
|
exports.submitMrvDeployPayloadNativeTx = submitMrvDeployPayloadNativeTx;
|
|
9312
9464
|
exports.submitSighash = submitSighash;
|
|
9465
|
+
exports.transactionFeeExposure = transactionFeeExposure;
|
|
9313
9466
|
exports.typedBech32ToAddress = typedBech32ToAddress;
|
|
9314
9467
|
exports.validateAddress = validateAddress;
|
|
9315
9468
|
exports.validateBridgeRouteCatalogue = validateBridgeRouteCatalogue;
|