@xyo-network/xl1-protocol-sdk 1.16.11 → 1.16.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/neutral/index.mjs +20 -19
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/provider/XyoGatewayRunner.d.ts +2 -0
- package/dist/neutral/provider/XyoGatewayRunner.d.ts.map +1 -1
- package/dist/neutral/simple/gateway/SimpleXyoGatewayRunner.d.ts +2 -0
- package/dist/neutral/simple/gateway/SimpleXyoGatewayRunner.d.ts.map +1 -1
- package/dist/neutral/transaction/confirmSubmittedTransaction.d.ts +4 -5
- package/dist/neutral/transaction/confirmSubmittedTransaction.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/provider/XyoGatewayRunner.ts +3 -0
- package/src/simple/gateway/SimpleXyoGatewayRunner.ts +10 -1
- package/src/transaction/confirmSubmittedTransaction.ts +8 -11
package/dist/neutral/index.mjs
CHANGED
|
@@ -1621,7 +1621,7 @@ var SimpleXyoGateway = class {
|
|
|
1621
1621
|
|
|
1622
1622
|
// src/simple/gateway/SimpleXyoGatewayRunner.ts
|
|
1623
1623
|
import { assertEx as assertEx12, BigIntToJsonZod, isDefined as isDefined10 } from "@xylabs/sdk-js";
|
|
1624
|
-
import { PayloadBuilder as
|
|
1624
|
+
import { PayloadBuilder as PayloadBuilder9 } from "@xyo-network/payload-builder";
|
|
1625
1625
|
import { TransferSchema as TransferSchema2 } from "@xyo-network/xl1-protocol";
|
|
1626
1626
|
|
|
1627
1627
|
// src/transaction/buildTransaction.ts
|
|
@@ -1715,24 +1715,22 @@ __name(buildUnsignedTransaction, "buildUnsignedTransaction");
|
|
|
1715
1715
|
|
|
1716
1716
|
// src/transaction/confirmSubmittedTransaction.ts
|
|
1717
1717
|
import { delay, isDefined as isDefined9 } from "@xylabs/sdk-js";
|
|
1718
|
-
import { PayloadBuilder as PayloadBuilder7 } from "@xyo-network/payload-builder";
|
|
1719
1718
|
var DEFAULT_CONFIRMATION_ATTEMPTS = 20;
|
|
1720
1719
|
var DEFAULT_DELAY_BETWEEN_ATTEMPTS = 1e3;
|
|
1721
|
-
var confirmSubmittedTransaction = /* @__PURE__ */ __name(async (viewer,
|
|
1720
|
+
var confirmSubmittedTransaction = /* @__PURE__ */ __name(async (viewer, txHash, options) => {
|
|
1722
1721
|
const { attempts: maxAttempts = DEFAULT_CONFIRMATION_ATTEMPTS, delay: attemptDelay = DEFAULT_DELAY_BETWEEN_ATTEMPTS } = options ?? {};
|
|
1723
|
-
|
|
1724
|
-
options?.logger?.log("\u{1F680} confirming transaction:", txBWHash, "\n");
|
|
1722
|
+
options?.logger?.log("\u{1F680} confirming transaction:", txHash, "\n");
|
|
1725
1723
|
let attempts = 0;
|
|
1726
1724
|
while (true) {
|
|
1727
|
-
const tx = await viewer.transactionByHash(
|
|
1725
|
+
const tx = await viewer.transactionByHash(txHash) ?? void 0;
|
|
1728
1726
|
if (isDefined9(tx)) {
|
|
1729
|
-
options?.logger?.log("\u2705 Transaction confirmed:",
|
|
1727
|
+
options?.logger?.log("\u2705 Transaction confirmed:", txHash, "\n");
|
|
1730
1728
|
return tx;
|
|
1731
1729
|
} else {
|
|
1732
1730
|
attempts++;
|
|
1733
1731
|
if (attempts > maxAttempts) {
|
|
1734
1732
|
options?.logger?.error(`\u26A0\uFE0F Transaction not confirmed after ${maxAttempts} attempts`);
|
|
1735
|
-
throw new Error(`Transaction ${
|
|
1733
|
+
throw new Error(`Transaction ${txHash} not confirmed after ${maxAttempts} attempts`);
|
|
1736
1734
|
} else {
|
|
1737
1735
|
options?.logger?.log(`\u{1F504} Transaction not confirmed yet, attempt ${attempts}. Retrying...`, "\n");
|
|
1738
1736
|
await delay(attemptDelay);
|
|
@@ -1805,11 +1803,11 @@ var hydrateElevatedTransaction = /* @__PURE__ */ __name(async (context, hash) =>
|
|
|
1805
1803
|
}, "hydrateElevatedTransaction");
|
|
1806
1804
|
|
|
1807
1805
|
// src/transaction/primitives/transactionBlockByteCount.ts
|
|
1808
|
-
import { PayloadBuilder as
|
|
1806
|
+
import { PayloadBuilder as PayloadBuilder7 } from "@xyo-network/payload-builder";
|
|
1809
1807
|
function transactionBlockByteCount([transaction, payloads]) {
|
|
1810
|
-
const cleanTransaction =
|
|
1808
|
+
const cleanTransaction = PayloadBuilder7.omitStorageMeta(transaction);
|
|
1811
1809
|
const transactionBytes = JSON.stringify(cleanTransaction).length;
|
|
1812
|
-
const cleanPayloads =
|
|
1810
|
+
const cleanPayloads = PayloadBuilder7.omitStorageMeta(payloads);
|
|
1813
1811
|
return cleanPayloads.reduce((acc, payload) => acc + JSON.stringify(payload).length, 0) + transactionBytes;
|
|
1814
1812
|
}
|
|
1815
1813
|
__name(transactionBlockByteCount, "transactionBlockByteCount");
|
|
@@ -1896,7 +1894,7 @@ var extractElevatedHashes = /* @__PURE__ */ __name((tx) => {
|
|
|
1896
1894
|
|
|
1897
1895
|
// src/transaction/signTransaction.ts
|
|
1898
1896
|
import { assertEx as assertEx11, hexFromArrayBuffer, toArrayBuffer } from "@xylabs/sdk-js";
|
|
1899
|
-
import { PayloadBuilder as
|
|
1897
|
+
import { PayloadBuilder as PayloadBuilder8 } from "@xyo-network/payload-builder";
|
|
1900
1898
|
async function signTransaction(tx, account) {
|
|
1901
1899
|
assertEx11(tx.from === account.address, () => "Signer address does not match transaction from address");
|
|
1902
1900
|
const signedTx = structuredClone(tx);
|
|
@@ -1906,7 +1904,7 @@ async function signTransaction(tx, account) {
|
|
|
1906
1904
|
signedTx.previous_hashes = [
|
|
1907
1905
|
account.previousHash ?? null
|
|
1908
1906
|
];
|
|
1909
|
-
const hash = await
|
|
1907
|
+
const hash = await PayloadBuilder8.dataHash(signedTx);
|
|
1910
1908
|
const hashBytes = toArrayBuffer(hash);
|
|
1911
1909
|
const [signature] = await account.sign(hashBytes);
|
|
1912
1910
|
signedTx.$signatures = [
|
|
@@ -1967,6 +1965,9 @@ var SimpleXyoGatewayRunner = class {
|
|
|
1967
1965
|
signedTx
|
|
1968
1966
|
];
|
|
1969
1967
|
}
|
|
1968
|
+
async confirmSubmittedTransaction(txHash, options) {
|
|
1969
|
+
return await confirmSubmittedTransaction(assertEx12(this.connectionInstance.viewer, () => "Connection viewer is undefined"), txHash, options);
|
|
1970
|
+
}
|
|
1970
1971
|
/** @deprecated use connectionInstance instead */
|
|
1971
1972
|
connection() {
|
|
1972
1973
|
return this.connectionInstance;
|
|
@@ -1985,7 +1986,7 @@ var SimpleXyoGatewayRunner = class {
|
|
|
1985
1986
|
address,
|
|
1986
1987
|
BigIntToJsonZod.parse(amount)
|
|
1987
1988
|
]));
|
|
1988
|
-
const transfer = new
|
|
1989
|
+
const transfer = new PayloadBuilder9({
|
|
1989
1990
|
schema: TransferSchema2
|
|
1990
1991
|
}).fields({
|
|
1991
1992
|
from,
|
|
@@ -2178,7 +2179,7 @@ var MemoryPermissionsStore = class {
|
|
|
2178
2179
|
|
|
2179
2180
|
// src/simple/runner/SimpleXyoRunner.ts
|
|
2180
2181
|
import { MemoryArchivist } from "@xyo-network/archivist-memory";
|
|
2181
|
-
import { PayloadBuilder as
|
|
2182
|
+
import { PayloadBuilder as PayloadBuilder10 } from "@xyo-network/payload-builder";
|
|
2182
2183
|
var SimpleXyoRunner = class {
|
|
2183
2184
|
static {
|
|
2184
2185
|
__name(this, "SimpleXyoRunner");
|
|
@@ -2190,7 +2191,7 @@ var SimpleXyoRunner = class {
|
|
|
2190
2191
|
async broadcastTransaction(transaction) {
|
|
2191
2192
|
const archivist = await this.getMempoolArchivist();
|
|
2192
2193
|
await archivist.insert(flattenHydratedTransaction(transaction));
|
|
2193
|
-
return await
|
|
2194
|
+
return await PayloadBuilder10.hash(transaction[0]);
|
|
2194
2195
|
}
|
|
2195
2196
|
async getMempoolArchivist() {
|
|
2196
2197
|
if (!this._mempoolArchivist) {
|
|
@@ -2203,7 +2204,7 @@ var SimpleXyoRunner = class {
|
|
|
2203
2204
|
};
|
|
2204
2205
|
|
|
2205
2206
|
// src/simple/signer/SimpleXyoSigner.ts
|
|
2206
|
-
import { PayloadBuilder as
|
|
2207
|
+
import { PayloadBuilder as PayloadBuilder11 } from "@xyo-network/payload-builder";
|
|
2207
2208
|
var SimpleXyoSigner = class {
|
|
2208
2209
|
static {
|
|
2209
2210
|
__name(this, "SimpleXyoSigner");
|
|
@@ -2223,8 +2224,8 @@ var SimpleXyoSigner = class {
|
|
|
2223
2224
|
async signTransaction(tx) {
|
|
2224
2225
|
const txBW = await signTransaction(tx[0], this._account);
|
|
2225
2226
|
return [
|
|
2226
|
-
await
|
|
2227
|
-
await
|
|
2227
|
+
await PayloadBuilder11.addStorageMeta(txBW),
|
|
2228
|
+
await PayloadBuilder11.addStorageMeta(tx[1])
|
|
2228
2229
|
];
|
|
2229
2230
|
}
|
|
2230
2231
|
};
|