opnet 1.8.1-rc.8 → 1.8.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/.github/workflows/ci.yml +11 -10
- package/CHANGELOG.md +45 -0
- package/browser/_version.d.ts +1 -1
- package/browser/abi/shared/interfaces/motoswap/INativeSwapContract.d.ts +2 -1
- package/browser/bitcoin/interfaces/IUTXO.d.ts +1 -0
- package/browser/contracts/CallResult.d.ts +1 -0
- package/browser/contracts/Contract.d.ts +1 -0
- package/browser/index.js +163 -131
- package/browser/protobuf.js +1889 -395
- package/browser/providers/AbstractRpcProvider.d.ts +3 -3
- package/browser/providers/websocket/ProtobufLoader.d.ts +1 -1
- package/browser/vendors.js +293 -201
- package/build/_version.d.ts +1 -1
- package/build/_version.js +1 -1
- package/build/abi/shared/interfaces/motoswap/INativeSwapContract.d.ts +2 -1
- package/build/abi/shared/json/motoswap/NATIVE_SWAP_ABI.js +10 -0
- package/build/bitcoin/UTXOs.js +1 -0
- package/build/bitcoin/interfaces/IUTXO.d.ts +1 -0
- package/build/contracts/CallResult.d.ts +1 -0
- package/build/contracts/CallResult.js +11 -1
- package/build/contracts/Contract.d.ts +1 -0
- package/build/contracts/Contract.js +8 -1
- package/build/mempool/decoders/MempoolDeploymentTransactionData.js +1 -1
- package/build/mempool/decoders/MempoolOPNetTransactionData.js +12 -7
- package/build/providers/AbstractRpcProvider.d.ts +3 -3
- package/build/providers/AbstractRpcProvider.js +6 -3
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/src/_version.ts +1 -1
- package/src/abi/shared/interfaces/motoswap/INativeSwapContract.ts +4 -0
- package/src/abi/shared/json/motoswap/NATIVE_SWAP_ABI.ts +14 -0
- package/src/bitcoin/UTXOs.ts +1 -17
- package/src/bitcoin/interfaces/IUTXO.ts +2 -0
- package/src/contracts/CallResult.ts +24 -1
- package/src/contracts/Contract.ts +12 -7
- package/src/mempool/decoders/MempoolDeploymentTransactionData.ts +1 -1
- package/src/mempool/decoders/MempoolOPNetTransactionData.ts +15 -9
- package/src/providers/AbstractRpcProvider.ts +13 -21
- package/src/shims/protobuf-browser.js +1 -2
- package/vite.config.browser.ts +2 -1
package/.github/workflows/ci.yml
CHANGED
|
@@ -70,10 +70,21 @@ jobs:
|
|
|
70
70
|
with:
|
|
71
71
|
fetch-depth: 0
|
|
72
72
|
|
|
73
|
+
- name: Determine if prerelease
|
|
74
|
+
id: prerelease
|
|
75
|
+
run: |
|
|
76
|
+
VERSION="${{ github.ref_name }}"
|
|
77
|
+
if [[ "$VERSION" == *"-alpha"* ]] || [[ "$VERSION" == *"-beta"* ]] || [[ "$VERSION" == *"-rc"* ]]; then
|
|
78
|
+
echo "is_prerelease=true" >> $GITHUB_OUTPUT
|
|
79
|
+
else
|
|
80
|
+
echo "is_prerelease=false" >> $GITHUB_OUTPUT
|
|
81
|
+
fi
|
|
82
|
+
|
|
73
83
|
- name: Generate changelog
|
|
74
84
|
id: changelog
|
|
75
85
|
uses: mikepenz/release-changelog-builder-action@v6
|
|
76
86
|
with:
|
|
87
|
+
ignorePreReleases: ${{ steps.prerelease.outputs.is_prerelease == 'false' }}
|
|
77
88
|
configurationJson: |
|
|
78
89
|
{
|
|
79
90
|
"categories": [
|
|
@@ -171,16 +182,6 @@ jobs:
|
|
|
171
182
|
git diff --staged --quiet || git commit -m "docs: update CHANGELOG.md for ${{ github.ref_name }}"
|
|
172
183
|
git push origin HEAD:main || echo "No changes to push or push failed"
|
|
173
184
|
|
|
174
|
-
- name: Determine if prerelease
|
|
175
|
-
id: prerelease
|
|
176
|
-
run: |
|
|
177
|
-
VERSION="${{ github.ref_name }}"
|
|
178
|
-
if [[ "$VERSION" == *"-alpha"* ]] || [[ "$VERSION" == *"-beta"* ]] || [[ "$VERSION" == *"-rc"* ]]; then
|
|
179
|
-
echo "is_prerelease=true" >> $GITHUB_OUTPUT
|
|
180
|
-
else
|
|
181
|
-
echo "is_prerelease=false" >> $GITHUB_OUTPUT
|
|
182
|
-
fi
|
|
183
|
-
|
|
184
185
|
- name: Create GitHub Release
|
|
185
186
|
uses: softprops/action-gh-release@v2
|
|
186
187
|
with:
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,50 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [v1.8.1-rc.17] - 2026-02-27
|
|
4
|
+
|
|
5
|
+
- No changes
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## [v1.8.1-rc.16] - 2026-02-27
|
|
9
|
+
|
|
10
|
+
- No changes
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## [v1.8.1-rc.15] - 2026-02-26
|
|
14
|
+
|
|
15
|
+
- No changes
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## [v1.8.1-rc.14] - 2026-02-25
|
|
19
|
+
|
|
20
|
+
- No changes
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## [v1.8.1-rc.12] - 2026-02-25
|
|
24
|
+
|
|
25
|
+
- No changes
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## [v1.8.1-rc.11] - 2026-02-24
|
|
29
|
+
|
|
30
|
+
- No changes
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## [v1.8.1-rc.10] - 2026-02-24
|
|
34
|
+
|
|
35
|
+
- No changes
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
## [v1.8.1-rc.9] - 2026-02-23
|
|
39
|
+
|
|
40
|
+
- No changes
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
## [v1.8.1-rc.8] - 2026-02-22
|
|
44
|
+
|
|
45
|
+
- No changes
|
|
46
|
+
|
|
47
|
+
|
|
3
48
|
## [v1.8.1-rc.7] - 2026-02-20
|
|
4
49
|
|
|
5
50
|
- No changes
|
package/browser/_version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.8.1
|
|
1
|
+
export declare const version = "1.8.1";
|
|
@@ -160,7 +160,7 @@ export type OnOP20ReceivedResult = CallResult<{
|
|
|
160
160
|
selector: Uint8Array;
|
|
161
161
|
}, []>;
|
|
162
162
|
export interface INativeSwapContract extends IOP_NETContract {
|
|
163
|
-
reserve(token: Address, maximumAmountIn: bigint, minimumAmountOut: bigint, activationDelay: number): Promise<ReserveNativeSwap>;
|
|
163
|
+
reserve(token: Address, maximumAmountIn: bigint, minimumAmountOut: bigint, activationDelay: number, sender: Uint8Array): Promise<ReserveNativeSwap>;
|
|
164
164
|
listLiquidity(token: Address, receiver: Uint8Array, receiverStr: string, amountIn: bigint, priority: boolean): Promise<ListLiquidity>;
|
|
165
165
|
cancelListing(token: Address): Promise<CancelListing>;
|
|
166
166
|
withdrawListing(token: Address): Promise<WithdrawListing>;
|
|
@@ -185,4 +185,5 @@ export interface INativeSwapContract extends IOP_NETContract {
|
|
|
185
185
|
getStakingContractAddress(): Promise<StakingAddressResult>;
|
|
186
186
|
getFeesAddress(): Promise<FeesAddressResult>;
|
|
187
187
|
getPoolInfo(token: Address): Promise<GetPoolInfoNativeSwap>;
|
|
188
|
+
update(address: Address, calldata: Uint8Array): Promise<CallResult>;
|
|
188
189
|
}
|
|
@@ -33,6 +33,7 @@ export interface TransactionParameters {
|
|
|
33
33
|
readonly linkMLDSAPublicKeyToAddress?: boolean;
|
|
34
34
|
readonly revealMLDSAPublicKey?: boolean;
|
|
35
35
|
readonly challenge?: ChallengeSolution;
|
|
36
|
+
readonly subtractExtraUTXOFromAmountRequired?: boolean;
|
|
36
37
|
}
|
|
37
38
|
export interface UTXOTrackingInfo {
|
|
38
39
|
readonly csvUTXOs: UTXO[];
|
|
@@ -39,6 +39,7 @@ export declare abstract class IBaseContract<T extends BaseContractProperties> im
|
|
|
39
39
|
setAccessList(accessList: IAccessList): void;
|
|
40
40
|
setSimulatedHeight(height: bigint | undefined): void;
|
|
41
41
|
protected getFunction(name: symbol | string): CallResult | undefined | string | number | symbol | Address | Network | (() => Promise<BlockGasParameters>) | ((functionName: string, args: unknown[]) => Uint8Array);
|
|
42
|
+
private getAddressOrThrow;
|
|
42
43
|
private defineInternalFunctions;
|
|
43
44
|
private getSelector;
|
|
44
45
|
private encodeFunctionData;
|
package/browser/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { d as decompile, f as fromHex, A as Address, b as fromBase64, N as NetEvent, B as BinaryWriter, c as BinaryReader, e as AddressTypes, h as AddressVerificator, t as toHex, C as ChallengeSolution, r as regtest, o as opnetTestnet, i as testnet, j as bitcoin, T as TransactionFactory, k as BufferHelper, l as AddressMap, m as toBase64, p as pLimit, n as process$1, L as Logger, q as Long, s as abiTypeToSelectorString, u as ABICoder, v as isAbiTuple, w as isAbiStruct, x as ABIDataTypes, y as BigNumber, z as fromBech32, P as P2MR_MS, D as P2TR_MS } from './vendors.js';
|
|
2
2
|
import { p as protobuf } from './protobuf.js';
|
|
3
3
|
|
|
4
|
-
const version = "1.8.1
|
|
4
|
+
const version = "1.8.1";
|
|
5
5
|
|
|
6
6
|
var OPNetTransactionTypes = /* @__PURE__ */ ((OPNetTransactionTypes2) => {
|
|
7
7
|
OPNetTransactionTypes2["Generic"] = "Generic";
|
|
@@ -1167,7 +1167,8 @@ class CallResult {
|
|
|
1167
1167
|
anchor: interactionParams.anchor || false,
|
|
1168
1168
|
txVersion: interactionParams.txVersion || 2,
|
|
1169
1169
|
linkMLDSAPublicKeyToAddress: interactionParams.linkMLDSAPublicKeyToAddress ?? true,
|
|
1170
|
-
revealMLDSAPublicKey: interactionParams.revealMLDSAPublicKey ?? false
|
|
1170
|
+
revealMLDSAPublicKey: interactionParams.revealMLDSAPublicKey ?? false,
|
|
1171
|
+
subtractExtraUTXOFromAmountRequired: interactionParams.subtractExtraUTXOFromAmountRequired ?? false
|
|
1171
1172
|
};
|
|
1172
1173
|
const params = interactionParams.signer !== null ? {
|
|
1173
1174
|
...sharedParams,
|
|
@@ -1531,10 +1532,20 @@ class CallResult {
|
|
|
1531
1532
|
throwIfUTXOsLimitReached: interactionParams.throwIfUTXOsLimitReached,
|
|
1532
1533
|
csvAddress: !interactionParams.p2wda && !interactionParams.dontUseCSVUtxos ? this.csvAddress?.address : void 0
|
|
1533
1534
|
};
|
|
1534
|
-
|
|
1535
|
+
let utxos = await this.#provider.utxoManager.getUTXOsForAmount(utxoSetting);
|
|
1535
1536
|
if (!utxos) {
|
|
1536
1537
|
throw new Error("No UTXOs found");
|
|
1537
1538
|
}
|
|
1539
|
+
if (interactionParams.extraInputs && interactionParams.extraInputs.length > 0) {
|
|
1540
|
+
utxos = utxos.filter((utxo) => {
|
|
1541
|
+
if (!interactionParams.extraInputs) {
|
|
1542
|
+
throw new Error("extraInputs should be defined here");
|
|
1543
|
+
}
|
|
1544
|
+
return !interactionParams.extraInputs.some(
|
|
1545
|
+
(extra) => extra.transactionId === utxo.transactionId && extra.outputIndex === utxo.outputIndex
|
|
1546
|
+
);
|
|
1547
|
+
});
|
|
1548
|
+
}
|
|
1538
1549
|
if (this.csvAddress) {
|
|
1539
1550
|
const csvUtxos = utxos.filter((u) => u.isCSV === true);
|
|
1540
1551
|
if (csvUtxos.length > 0) {
|
|
@@ -1738,6 +1749,125 @@ class SubmittedEpoch {
|
|
|
1738
1749
|
}
|
|
1739
1750
|
}
|
|
1740
1751
|
|
|
1752
|
+
class MempoolTransactionData {
|
|
1753
|
+
/** Internal transaction identifier (txid). */
|
|
1754
|
+
id;
|
|
1755
|
+
/** Timestamp of when the transaction was first seen. */
|
|
1756
|
+
firstSeen;
|
|
1757
|
+
/** Block height at which the transaction was observed. */
|
|
1758
|
+
blockHeight;
|
|
1759
|
+
/** The OPNet transaction type. */
|
|
1760
|
+
transactionType;
|
|
1761
|
+
/** Whether the transaction was submitted as a PSBT. */
|
|
1762
|
+
psbt;
|
|
1763
|
+
/** The transaction inputs. */
|
|
1764
|
+
inputs;
|
|
1765
|
+
/** The transaction outputs. */
|
|
1766
|
+
outputs;
|
|
1767
|
+
/** The full raw transaction as a hex string. */
|
|
1768
|
+
raw;
|
|
1769
|
+
constructor(data) {
|
|
1770
|
+
this.id = data.id;
|
|
1771
|
+
this.firstSeen = new Date(data.firstSeen);
|
|
1772
|
+
this.blockHeight = BigInt(data.blockHeight);
|
|
1773
|
+
this.transactionType = data.transactionType;
|
|
1774
|
+
this.psbt = data.psbt;
|
|
1775
|
+
this.inputs = data.inputs;
|
|
1776
|
+
this.outputs = data.outputs;
|
|
1777
|
+
this.raw = data.raw;
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
|
|
1781
|
+
class MempoolOPNetTransactionData extends MempoolTransactionData {
|
|
1782
|
+
/** Theoretical gas limit for OPNet execution. */
|
|
1783
|
+
theoreticalGasLimit;
|
|
1784
|
+
/** Priority fee attached to the transaction. */
|
|
1785
|
+
priorityFee;
|
|
1786
|
+
/** The sender address (p2tr format). */
|
|
1787
|
+
from;
|
|
1788
|
+
/** The target contract address (p2op format). */
|
|
1789
|
+
contractAddress;
|
|
1790
|
+
/** Decoded calldata. */
|
|
1791
|
+
calldata;
|
|
1792
|
+
constructor(data) {
|
|
1793
|
+
super(data);
|
|
1794
|
+
if (data.theoreticalGasLimit === void 0) {
|
|
1795
|
+
throw new Error("Missing theoreticalGasLimit field in OPNet transaction mempool data.");
|
|
1796
|
+
}
|
|
1797
|
+
if (data.calldata === void 0) {
|
|
1798
|
+
throw new Error("Missing calldata field in OPNet transaction mempool data.");
|
|
1799
|
+
}
|
|
1800
|
+
if (data.from === void 0) {
|
|
1801
|
+
throw new Error("Missing from field in OPNet transaction mempool data.");
|
|
1802
|
+
}
|
|
1803
|
+
if (data.contractAddress === void 0) {
|
|
1804
|
+
throw new Error("Missing contractAddress field in OPNet transaction mempool data.");
|
|
1805
|
+
}
|
|
1806
|
+
this.theoreticalGasLimit = BigInt(data.theoreticalGasLimit);
|
|
1807
|
+
this.priorityFee = BigInt(data.priorityFee || "0x00");
|
|
1808
|
+
this.from = data.from;
|
|
1809
|
+
this.contractAddress = data.contractAddress;
|
|
1810
|
+
const calldataHex = data.calldata.startsWith("0x") ? data.calldata.slice(2) : data.calldata;
|
|
1811
|
+
this.calldata = fromHex(calldataHex);
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
|
|
1815
|
+
class MempoolDeploymentTransactionData extends MempoolOPNetTransactionData {
|
|
1816
|
+
/** Decoded contract bytecode. */
|
|
1817
|
+
bytecode;
|
|
1818
|
+
constructor(data) {
|
|
1819
|
+
super(data);
|
|
1820
|
+
if (data.bytecode === void 0) {
|
|
1821
|
+
throw new Error("Bytecode is required for deployment transactions.");
|
|
1822
|
+
}
|
|
1823
|
+
const bytecodeHex = data.bytecode.startsWith("0x") ? data.bytecode.slice(2) : data.bytecode;
|
|
1824
|
+
this.bytecode = fromHex(bytecodeHex);
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
|
|
1828
|
+
class MempoolGenericTransactionData extends MempoolTransactionData {
|
|
1829
|
+
constructor(data) {
|
|
1830
|
+
super(data);
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
|
|
1834
|
+
class MempoolInteractionTransactionData extends MempoolOPNetTransactionData {
|
|
1835
|
+
constructor(data) {
|
|
1836
|
+
super(data);
|
|
1837
|
+
}
|
|
1838
|
+
}
|
|
1839
|
+
|
|
1840
|
+
class MempoolTransactionParser {
|
|
1841
|
+
static parseTransactions(transactions) {
|
|
1842
|
+
if (!transactions) {
|
|
1843
|
+
return [];
|
|
1844
|
+
}
|
|
1845
|
+
const result = [];
|
|
1846
|
+
for (const tx of transactions) {
|
|
1847
|
+
if (!tx) throw new Error("Something went wrong while parsing mempool transactions");
|
|
1848
|
+
result.push(this.parseTransaction(tx));
|
|
1849
|
+
}
|
|
1850
|
+
return result;
|
|
1851
|
+
}
|
|
1852
|
+
static parseTransaction(data) {
|
|
1853
|
+
if (!data) throw new Error("Mempool transaction data is required");
|
|
1854
|
+
switch (data.transactionType) {
|
|
1855
|
+
case OPNetTransactionTypes.Generic:
|
|
1856
|
+
return new MempoolGenericTransactionData(data);
|
|
1857
|
+
case OPNetTransactionTypes.Interaction:
|
|
1858
|
+
return new MempoolInteractionTransactionData(
|
|
1859
|
+
data
|
|
1860
|
+
);
|
|
1861
|
+
case OPNetTransactionTypes.Deployment:
|
|
1862
|
+
return new MempoolDeploymentTransactionData(
|
|
1863
|
+
data
|
|
1864
|
+
);
|
|
1865
|
+
default:
|
|
1866
|
+
throw new Error(`Unknown mempool transaction type: ${data.transactionType}`);
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
}
|
|
1870
|
+
|
|
1741
1871
|
class StoredValue {
|
|
1742
1872
|
pointer;
|
|
1743
1873
|
value;
|
|
@@ -1791,6 +1921,7 @@ class UTXO {
|
|
|
1791
1921
|
this.value = BigInt(iUTXO.value);
|
|
1792
1922
|
this.scriptPubKey = iUTXO.scriptPubKey;
|
|
1793
1923
|
this.nonWitnessUtxoBase64 = iUTXO.raw;
|
|
1924
|
+
this.witnessScript = iUTXO.witnessScript;
|
|
1794
1925
|
if (iUTXO.raw) {
|
|
1795
1926
|
const raw = iUTXO.raw;
|
|
1796
1927
|
let cached;
|
|
@@ -1806,22 +1937,6 @@ class UTXO {
|
|
|
1806
1937
|
});
|
|
1807
1938
|
}
|
|
1808
1939
|
}
|
|
1809
|
-
/*public toJSON(): Record<string, unknown> {
|
|
1810
|
-
return {
|
|
1811
|
-
transactionId: this.transactionId,
|
|
1812
|
-
outputIndex: this.outputIndex,
|
|
1813
|
-
value: this.value.toString(),
|
|
1814
|
-
scriptPubKey: this.scriptPubKey,
|
|
1815
|
-
nonWitnessUtxo: this.nonWitnessUtxoBase64,
|
|
1816
|
-
witnessScript: this.witnessScript,
|
|
1817
|
-
redeemScript: this.redeemScript,
|
|
1818
|
-
isCSV: this.isCSV,
|
|
1819
|
-
};
|
|
1820
|
-
}
|
|
1821
|
-
|
|
1822
|
-
public [Symbol.for('nodejs.util.inspect.custom')](): Record<string, unknown> {
|
|
1823
|
-
return this.toJSON();
|
|
1824
|
-
}*/
|
|
1825
1940
|
}
|
|
1826
1941
|
|
|
1827
1942
|
var JSONRpcMethods = /* @__PURE__ */ ((JSONRpcMethods2) => {
|
|
@@ -2305,116 +2420,6 @@ class UTXOsManager {
|
|
|
2305
2420
|
}
|
|
2306
2421
|
}
|
|
2307
2422
|
|
|
2308
|
-
class MempoolTransactionData {
|
|
2309
|
-
/** Internal transaction identifier (txid). */
|
|
2310
|
-
id;
|
|
2311
|
-
/** Timestamp of when the transaction was first seen. */
|
|
2312
|
-
firstSeen;
|
|
2313
|
-
/** Block height at which the transaction was observed. */
|
|
2314
|
-
blockHeight;
|
|
2315
|
-
/** The OPNet transaction type. */
|
|
2316
|
-
transactionType;
|
|
2317
|
-
/** Whether the transaction was submitted as a PSBT. */
|
|
2318
|
-
psbt;
|
|
2319
|
-
/** The transaction inputs. */
|
|
2320
|
-
inputs;
|
|
2321
|
-
/** The transaction outputs. */
|
|
2322
|
-
outputs;
|
|
2323
|
-
/** The full raw transaction as a hex string. */
|
|
2324
|
-
raw;
|
|
2325
|
-
constructor(data) {
|
|
2326
|
-
this.id = data.id;
|
|
2327
|
-
this.firstSeen = new Date(data.firstSeen);
|
|
2328
|
-
this.blockHeight = BigInt(data.blockHeight);
|
|
2329
|
-
this.transactionType = data.transactionType;
|
|
2330
|
-
this.psbt = data.psbt;
|
|
2331
|
-
this.inputs = data.inputs;
|
|
2332
|
-
this.outputs = data.outputs;
|
|
2333
|
-
this.raw = data.raw;
|
|
2334
|
-
}
|
|
2335
|
-
}
|
|
2336
|
-
|
|
2337
|
-
class MempoolOPNetTransactionData extends MempoolTransactionData {
|
|
2338
|
-
/** Theoretical gas limit for OPNet execution. */
|
|
2339
|
-
theoreticalGasLimit;
|
|
2340
|
-
/** Priority fee attached to the transaction. */
|
|
2341
|
-
priorityFee;
|
|
2342
|
-
/** The sender address (p2tr format). */
|
|
2343
|
-
from;
|
|
2344
|
-
/** The target contract address (p2op format). */
|
|
2345
|
-
contractAddress;
|
|
2346
|
-
/** Decoded calldata. */
|
|
2347
|
-
calldata;
|
|
2348
|
-
constructor(data) {
|
|
2349
|
-
super(data);
|
|
2350
|
-
if (!data.theoreticalGasLimit || !data.priorityFee || !data.from || !data.contractAddress || !data.calldata) {
|
|
2351
|
-
throw new Error("Missing required OPNet transaction fields in mempool data.");
|
|
2352
|
-
}
|
|
2353
|
-
this.theoreticalGasLimit = BigInt(data.theoreticalGasLimit);
|
|
2354
|
-
this.priorityFee = BigInt(data.priorityFee);
|
|
2355
|
-
this.from = data.from;
|
|
2356
|
-
this.contractAddress = data.contractAddress;
|
|
2357
|
-
const calldataHex = data.calldata.startsWith("0x") ? data.calldata.slice(2) : data.calldata;
|
|
2358
|
-
this.calldata = fromHex(calldataHex);
|
|
2359
|
-
}
|
|
2360
|
-
}
|
|
2361
|
-
|
|
2362
|
-
class MempoolDeploymentTransactionData extends MempoolOPNetTransactionData {
|
|
2363
|
-
/** Decoded contract bytecode. */
|
|
2364
|
-
bytecode;
|
|
2365
|
-
constructor(data) {
|
|
2366
|
-
super(data);
|
|
2367
|
-
if (!data.bytecode) {
|
|
2368
|
-
throw new Error("Bytecode is required for deployment transactions.");
|
|
2369
|
-
}
|
|
2370
|
-
const bytecodeHex = data.bytecode.startsWith("0x") ? data.bytecode.slice(2) : data.bytecode;
|
|
2371
|
-
this.bytecode = fromHex(bytecodeHex);
|
|
2372
|
-
}
|
|
2373
|
-
}
|
|
2374
|
-
|
|
2375
|
-
class MempoolGenericTransactionData extends MempoolTransactionData {
|
|
2376
|
-
constructor(data) {
|
|
2377
|
-
super(data);
|
|
2378
|
-
}
|
|
2379
|
-
}
|
|
2380
|
-
|
|
2381
|
-
class MempoolInteractionTransactionData extends MempoolOPNetTransactionData {
|
|
2382
|
-
constructor(data) {
|
|
2383
|
-
super(data);
|
|
2384
|
-
}
|
|
2385
|
-
}
|
|
2386
|
-
|
|
2387
|
-
class MempoolTransactionParser {
|
|
2388
|
-
static parseTransactions(transactions) {
|
|
2389
|
-
if (!transactions) {
|
|
2390
|
-
return [];
|
|
2391
|
-
}
|
|
2392
|
-
const result = [];
|
|
2393
|
-
for (const tx of transactions) {
|
|
2394
|
-
if (!tx) throw new Error("Something went wrong while parsing mempool transactions");
|
|
2395
|
-
result.push(this.parseTransaction(tx));
|
|
2396
|
-
}
|
|
2397
|
-
return result;
|
|
2398
|
-
}
|
|
2399
|
-
static parseTransaction(data) {
|
|
2400
|
-
if (!data) throw new Error("Mempool transaction data is required");
|
|
2401
|
-
switch (data.transactionType) {
|
|
2402
|
-
case OPNetTransactionTypes.Generic:
|
|
2403
|
-
return new MempoolGenericTransactionData(data);
|
|
2404
|
-
case OPNetTransactionTypes.Interaction:
|
|
2405
|
-
return new MempoolInteractionTransactionData(
|
|
2406
|
-
data
|
|
2407
|
-
);
|
|
2408
|
-
case OPNetTransactionTypes.Deployment:
|
|
2409
|
-
return new MempoolDeploymentTransactionData(
|
|
2410
|
-
data
|
|
2411
|
-
);
|
|
2412
|
-
default:
|
|
2413
|
-
throw new Error(`Unknown mempool transaction type: ${data.transactionType}`);
|
|
2414
|
-
}
|
|
2415
|
-
}
|
|
2416
|
-
}
|
|
2417
|
-
|
|
2418
2423
|
class AbstractRpcProvider {
|
|
2419
2424
|
constructor(network) {
|
|
2420
2425
|
this.network = network;
|
|
@@ -4313,6 +4318,13 @@ class OPNetError extends Error {
|
|
|
4313
4318
|
}
|
|
4314
4319
|
}
|
|
4315
4320
|
|
|
4321
|
+
protobuf.Reader;
|
|
4322
|
+
protobuf.Writer;
|
|
4323
|
+
protobuf.util;
|
|
4324
|
+
protobuf.roots;
|
|
4325
|
+
protobuf.configure;
|
|
4326
|
+
protobuf.rpc;
|
|
4327
|
+
|
|
4316
4328
|
let cachedRoot = null;
|
|
4317
4329
|
async function loadProtobufSchema(baseUrl) {
|
|
4318
4330
|
if (cachedRoot) {
|
|
@@ -5503,7 +5515,7 @@ class IBaseContract {
|
|
|
5503
5515
|
get contractAddress() {
|
|
5504
5516
|
if (typeof this.address === "string") {
|
|
5505
5517
|
if (!this._rlAddress) {
|
|
5506
|
-
this._rlAddress = this.
|
|
5518
|
+
this._rlAddress = this.getAddressOrThrow(this.address, true);
|
|
5507
5519
|
}
|
|
5508
5520
|
return this._rlAddress;
|
|
5509
5521
|
}
|
|
@@ -5600,6 +5612,13 @@ class IBaseContract {
|
|
|
5600
5612
|
const key = name;
|
|
5601
5613
|
return this[key];
|
|
5602
5614
|
}
|
|
5615
|
+
async getAddressOrThrow(address, isContract) {
|
|
5616
|
+
const info = await this.provider.getPublicKeyInfo(address, isContract);
|
|
5617
|
+
if (!info) {
|
|
5618
|
+
throw new Error(`Address ${address} not found on the network.`);
|
|
5619
|
+
}
|
|
5620
|
+
return info;
|
|
5621
|
+
}
|
|
5603
5622
|
/**
|
|
5604
5623
|
* Defines the internal functions of the contract. These functions are generated for the ABI provided.
|
|
5605
5624
|
* @private
|
|
@@ -8422,7 +8441,8 @@ const NativeSwapAbi = [
|
|
|
8422
8441
|
{ name: "token", type: ABIDataTypes.ADDRESS },
|
|
8423
8442
|
{ name: "maximumAmountIn", type: ABIDataTypes.UINT64 },
|
|
8424
8443
|
{ name: "minimumAmountOut", type: ABIDataTypes.UINT256 },
|
|
8425
|
-
{ name: "activationDelay", type: ABIDataTypes.UINT8 }
|
|
8444
|
+
{ name: "activationDelay", type: ABIDataTypes.UINT8 },
|
|
8445
|
+
{ name: "sender", type: ABIDataTypes.BYTES }
|
|
8426
8446
|
],
|
|
8427
8447
|
outputs: [],
|
|
8428
8448
|
type: BitcoinAbiTypes.Function
|
|
@@ -8437,6 +8457,18 @@ const NativeSwapAbi = [
|
|
|
8437
8457
|
type: BitcoinAbiTypes.Function
|
|
8438
8458
|
},
|
|
8439
8459
|
//=================================================
|
|
8460
|
+
// UPDATE
|
|
8461
|
+
//=================================================
|
|
8462
|
+
{
|
|
8463
|
+
name: "update",
|
|
8464
|
+
inputs: [
|
|
8465
|
+
{ name: "address", type: ABIDataTypes.ADDRESS },
|
|
8466
|
+
{ name: "calldata", type: ABIDataTypes.BYTES }
|
|
8467
|
+
],
|
|
8468
|
+
outputs: [],
|
|
8469
|
+
type: BitcoinAbiTypes.Function
|
|
8470
|
+
},
|
|
8471
|
+
//=================================================
|
|
8440
8472
|
// LIST LIQUIDITY
|
|
8441
8473
|
//=================================================
|
|
8442
8474
|
{
|