@monolythium/core-sdk 0.3.11 → 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 CHANGED
@@ -1822,16 +1822,158 @@ 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: "0xad64b785debc17aef3fb4a8d944c2c7c9156394bb08d5ab576ec85782732f897",
1826
- binary_sha: "058c883",
1825
+ genesis_hash: "0xe67cf82131fc63e335ce61afeae53299283eaa3a692830a618911aa840245031",
1826
+ binary_sha: "e4697f9b",
1827
1827
  rpc: [
1828
1828
  {
1829
- url: "https://rpc.monolythium.com",
1830
- provider: "monolythium",
1831
- tier: "official"
1829
+ url: "http://178.105.12.9:8545",
1830
+ provider: "monolythium-foundation",
1831
+ region: "fsn1",
1832
+ tier: "official",
1833
+ notes: "operator-1"
1834
+ },
1835
+ {
1836
+ url: "http://178.105.15.216:8545",
1837
+ provider: "monolythium-foundation",
1838
+ region: "fsn1",
1839
+ tier: "official",
1840
+ notes: "operator-2; primary foundation seed"
1841
+ },
1842
+ {
1843
+ url: "http://178.104.233.182:8545",
1844
+ provider: "monolythium-foundation",
1845
+ region: "nbg1",
1846
+ tier: "official",
1847
+ notes: "operator-3"
1848
+ },
1849
+ {
1850
+ url: "http://65.108.94.1:8545",
1851
+ provider: "monolythium-foundation",
1852
+ region: "hel1",
1853
+ tier: "official",
1854
+ notes: "operator-4"
1855
+ },
1856
+ {
1857
+ url: "http://95.216.154.155:8545",
1858
+ provider: "monolythium-foundation",
1859
+ region: "hel1",
1860
+ tier: "official",
1861
+ notes: "operator-5"
1862
+ },
1863
+ {
1864
+ url: "http://87.99.145.48:8545",
1865
+ provider: "monolythium-foundation",
1866
+ region: "ash",
1867
+ tier: "official",
1868
+ notes: "operator-6; US east"
1869
+ },
1870
+ {
1871
+ url: "http://5.223.85.76:8545",
1872
+ provider: "monolythium-foundation",
1873
+ region: "sin",
1874
+ tier: "official",
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"
1832
1925
  }
1833
1926
  ],
1834
- 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
+ ]
1835
1977
  };
1836
1978
  var CHAIN_REGISTRY = {
1837
1979
  "testnet-69420": TESTNET_69420
@@ -3945,6 +4087,83 @@ function parseNullableString(value, label) {
3945
4087
  return value;
3946
4088
  }
3947
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
+
3948
4167
  // src/api.ts
3949
4168
  var SDK_VERSION2 = "0.1.0";
3950
4169
  function apiEndpointFromRpcEndpoint(endpoint) {
@@ -4020,7 +4239,13 @@ var ApiClient = class {
4020
4239
  };
4021
4240
  }
4022
4241
  async transaction(hash) {
4023
- return this.get(`/transactions/${encodePathSegment(hash)}`);
4242
+ const response = await this.get(
4243
+ `/transactions/${encodePathSegment(hash)}`
4244
+ );
4245
+ return {
4246
+ ...response,
4247
+ data: enrichTransactionDataWithFee(response.data)
4248
+ };
4024
4249
  }
4025
4250
  async transactionReceipt(hash) {
4026
4251
  return this.get(`/transactions/${encodePathSegment(hash)}/receipt`);
@@ -4249,6 +4474,22 @@ var ApiClient = class {
4249
4474
  return parsed;
4250
4475
  }
4251
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
+ }
4252
4493
  function parseApiError(value) {
4253
4494
  if (!value || typeof value !== "object" || Array.isArray(value)) return null;
4254
4495
  const error = value["error"];
@@ -6631,58 +6872,6 @@ function assertWholeNumber(field2, value) {
6631
6872
  throw new Error(`${field2} must be a whole number`);
6632
6873
  }
6633
6874
  }
6634
-
6635
- // src/tx-fee.ts
6636
- var REGISTRY_DEFAULT_EXECUTION_UNIT_LIMIT = 250000n;
6637
- var TRANSFER_DEFAULT_EXECUTION_UNIT_LIMIT = 100000n;
6638
- var MIN_EXECUTION_UNIT_PRICE_LYTHOSHI = 2000n;
6639
- var EXECUTION_UNIT_PRICE_SAFETY_MULTIPLIER = 3n;
6640
- function asBigint(value, label) {
6641
- try {
6642
- return typeof value === "bigint" ? value : BigInt(value);
6643
- } catch {
6644
- throw new Error(`${label} is not an integer: ${String(value)}`);
6645
- }
6646
- }
6647
- function clampPriorityTip(priorityTipLythoshi, maxExecutionUnitPriceLythoshi) {
6648
- const tip = asBigint(priorityTipLythoshi, "priorityTipLythoshi");
6649
- const cap = asBigint(maxExecutionUnitPriceLythoshi, "maxExecutionUnitPriceLythoshi");
6650
- if (tip < 0n) throw new Error("priorityTipLythoshi must be non-negative");
6651
- return tip > cap ? cap : tip;
6652
- }
6653
- async function resolveMaxExecutionUnitPrice(client, options = {}) {
6654
- const floor = options.minPriceLythoshi ?? MIN_EXECUTION_UNIT_PRICE_LYTHOSHI;
6655
- const multiplier = options.safetyMultiplier ?? EXECUTION_UNIT_PRICE_SAFETY_MULTIPLIER;
6656
- const quote = await client.lythExecutionUnitPrice();
6657
- let unitPrice;
6658
- try {
6659
- unitPrice = BigInt(quote.executionUnitPriceLythoshi);
6660
- } catch {
6661
- throw SdkError.malformed(
6662
- `lyth_executionUnitPrice returned a non-integer executionUnitPriceLythoshi: ${quote.executionUnitPriceLythoshi}`
6663
- );
6664
- }
6665
- const base = unitPrice > floor ? unitPrice : floor;
6666
- return base * multiplier;
6667
- }
6668
- async function resolveExecutionFee(client, options = {}) {
6669
- const maxFeePerGas = await resolveMaxExecutionUnitPrice(client, {
6670
- minPriceLythoshi: options.minPriceLythoshi,
6671
- safetyMultiplier: options.safetyMultiplier
6672
- });
6673
- const tip = options.priorityTipLythoshi === void 0 ? maxFeePerGas : clampPriorityTip(options.priorityTipLythoshi, maxFeePerGas);
6674
- return {
6675
- maxFeePerGas,
6676
- maxPriorityFeePerGas: tip,
6677
- gasLimit: options.executionUnitLimit ?? TRANSFER_DEFAULT_EXECUTION_UNIT_LIMIT
6678
- };
6679
- }
6680
- async function resolveRegistryExecutionFee(client, options = {}) {
6681
- return resolveExecutionFee(client, {
6682
- ...options,
6683
- executionUnitLimit: options.executionUnitLimit ?? REGISTRY_DEFAULT_EXECUTION_UNIT_LIMIT
6684
- });
6685
- }
6686
6875
  var ORACLE_EVENT_SIGS = {
6687
6876
  oracleRoundFinalized: "OracleRoundFinalized(bytes32,uint64,uint256,uint64,uint32)",
6688
6877
  observationSubmitted: "ObservationSubmitted(bytes32,uint64,address,uint256,uint64)",
@@ -9273,6 +9462,7 @@ exports.submitMrvCallNativeTx = submitMrvCallNativeTx;
9273
9462
  exports.submitMrvDeployNativeTx = submitMrvDeployNativeTx;
9274
9463
  exports.submitMrvDeployPayloadNativeTx = submitMrvDeployPayloadNativeTx;
9275
9464
  exports.submitSighash = submitSighash;
9465
+ exports.transactionFeeExposure = transactionFeeExposure;
9276
9466
  exports.typedBech32ToAddress = typedBech32ToAddress;
9277
9467
  exports.validateAddress = validateAddress;
9278
9468
  exports.validateBridgeRouteCatalogue = validateBridgeRouteCatalogue;