Skip to content

Commit 335f678

Browse files
-
1 parent 279c730 commit 335f678

3 files changed

Lines changed: 30 additions & 11 deletions

File tree

src/ao/messaging/DryRunFIFO.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { DryRun, DryRunResult, MessageInput } from "@permaweb/aoconnect/dist/lib/dryrun";
1+
import {
2+
DryRun,
3+
DryRunResult,
4+
MessageInput,
5+
} from "@permaweb/aoconnect/dist/lib/dryrun";
26
import { connect } from "@permaweb/aoconnect";
37

48
interface DryRunQueueItem {
@@ -15,9 +19,10 @@ export class DryRunFIFO {
1519
constructor(CUs: string[], delay = 500) {
1620
this.#queue = [];
1721
this.#running = false;
18-
this.#availableDryRuns = new DryRunList(CUs.map(
19-
(CU_URL) => connect({ MODE: "legacy", CU_URL }).dryrun
20-
), delay);
22+
this.#availableDryRuns = new DryRunList(
23+
CUs.map((CU_URL) => connect({ MODE: "legacy", CU_URL }).dryrun),
24+
delay,
25+
);
2126
}
2227

2328
put(msg: MessageInput) {

src/ao/messaging/getData.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { DryRun, DryRunResult, MessageInput } from "@permaweb/aoconnect/dist/lib/dryrun";
1+
import {
2+
DryRun,
3+
DryRunResult,
4+
MessageInput,
5+
} from "@permaweb/aoconnect/dist/lib/dryrun";
26
import { connectToAO, Services } from "../utils/connect";
37
import { dryRunAwait } from "../utils/dryRunAwait";
48
import { connect } from "@permaweb/aoconnect";
@@ -44,9 +48,9 @@ export async function getData(
4448
tags: convertedMessageTags,
4549
Owner: messageTags.Owner || "1234",
4650
};
47-
const { Messages, Spawns, Output, Error } = LiquidOps.dryRunFifo ?
48-
await LiquidOps.dryRunFifo.put(msg) :
49-
await dryrun(msg);
51+
const { Messages, Spawns, Output, Error } = LiquidOps.dryRunFifo
52+
? await LiquidOps.dryRunFifo.put(msg)
53+
: await dryrun(msg);
5054

5155
return {
5256
Messages,

tests.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import LiquidOps from "./src";
1+
import LiquidOps, { DryRunFIFO } from "./src";
22
import { ownerToAddress } from "./tests/testsHelpers/arweaveUtils";
33
import { createDataItemSigner } from "@permaweb/aoconnect";
44
import { formatGlobalPosition } from "./src/ao/utils/formatGlobalPosition";
@@ -9,6 +9,16 @@ if (!process.env.JWK) {
99

1010
const JWK: any = JSON.parse(process.env.JWK);
1111
const signer = createDataItemSigner(JWK);
12+
13+
LiquidOps.dryRunFifo = new DryRunFIFO([
14+
"https://cu1.ao-testnet.xyz",
15+
"https://cu24.ao-testnet.xyz",
16+
"https://cu-af.dataos.so",
17+
"https://cu.perplex.finance",
18+
"https://cu.arweave.asia",
19+
"https://cu.ardrive.io",
20+
]);
21+
1222
const client = new LiquidOps(signer);
1323

1424
const walletAddress = await ownerToAddress(JWK.n);
@@ -80,9 +90,9 @@ const walletAddress = await ownerToAddress(JWK.n);
8090

8191
//--------------------------------------------------------------------------------------------------------------- liquidations
8292

83-
// const getLiquidationsMap = await client.getLiquidationsMap();
93+
const getLiquidationsMap = await client.getLiquidationsMap();
8494

85-
// console.log(getLiquidationsMap);
95+
console.log(getLiquidationsMap);
8696

8797
//-------------------------------
8898

0 commit comments

Comments
 (0)