@intent-engine/client 0.1.22 → 0.1.26
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/src/budget.d.ts +6 -4
- package/dist/src/budget.js +24 -9
- package/dist/src/budget.js.map +1 -1
- package/dist/src/client-errors.d.ts +28 -0
- package/dist/src/client-errors.js +55 -0
- package/dist/src/client-errors.js.map +1 -0
- package/dist/src/client-intents.d.ts +12 -0
- package/dist/src/client-intents.js +133 -0
- package/dist/src/client-intents.js.map +1 -0
- package/dist/src/client-reads.d.ts +7 -0
- package/dist/src/client-reads.js +61 -0
- package/dist/src/client-reads.js.map +1 -0
- package/dist/src/client-settle.d.ts +2 -0
- package/dist/src/client-settle.js +84 -0
- package/dist/src/client-settle.js.map +1 -0
- package/dist/src/client-types.d.ts +145 -0
- package/dist/src/client-types.js +9 -0
- package/dist/src/client-types.js.map +1 -0
- package/dist/src/client-watch.d.ts +4 -0
- package/dist/src/client-watch.js +97 -0
- package/dist/src/client-watch.js.map +1 -0
- package/dist/src/client.d.ts +4 -126
- package/dist/src/client.js +20 -299
- package/dist/src/client.js.map +1 -1
- package/dist/src/confirmation.d.ts +11 -0
- package/dist/src/confirmation.js +94 -0
- package/dist/src/confirmation.js.map +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/intent-notifications.d.ts +13 -0
- package/dist/src/intent-notifications.js +106 -0
- package/dist/src/intent-notifications.js.map +1 -0
- package/dist/src/job-deliveries.d.ts +40 -0
- package/dist/src/job-deliveries.js +92 -0
- package/dist/src/job-deliveries.js.map +1 -0
- package/dist/src/job-memos.d.ts +16 -0
- package/dist/src/job-memos.js +51 -0
- package/dist/src/job-memos.js.map +1 -0
- package/dist/src/job-origins.d.ts +30 -0
- package/dist/src/job-origins.js +53 -0
- package/dist/src/job-origins.js.map +1 -0
- package/dist/src/job-proofs.d.ts +17 -0
- package/dist/src/job-proofs.js +54 -0
- package/dist/src/job-proofs.js.map +1 -0
- package/dist/src/job-scan.d.ts +20 -0
- package/dist/src/job-scan.js +70 -0
- package/dist/src/job-scan.js.map +1 -0
- package/dist/src/job-specs.d.ts +40 -0
- package/dist/src/job-specs.js +107 -0
- package/dist/src/job-specs.js.map +1 -0
- package/dist/src/jobs.d.ts +6 -0
- package/dist/src/jobs.js +7 -0
- package/dist/src/jobs.js.map +1 -0
- package/dist/src/memoized-transport.d.ts +4 -0
- package/dist/src/memoized-transport.js +66 -0
- package/dist/src/memoized-transport.js.map +1 -0
- package/dist/src/rpc-retry.d.ts +16 -0
- package/dist/src/rpc-retry.js +62 -0
- package/dist/src/rpc-retry.js.map +1 -0
- package/dist/src/rpc-shapes.d.ts +230 -0
- package/dist/src/rpc-shapes.js +2 -0
- package/dist/src/rpc-shapes.js.map +1 -0
- package/dist/src/rpc-transport.d.ts +6 -0
- package/dist/src/rpc-transport.js +236 -0
- package/dist/src/rpc-transport.js.map +1 -0
- package/dist/src/svm.d.ts +1 -1
- package/dist/src/svm.js +89 -21
- package/dist/src/svm.js.map +1 -1
- package/dist/src/transaction-keys.d.ts +6 -0
- package/dist/src/transaction-keys.js +19 -0
- package/dist/src/transaction-keys.js.map +1 -0
- package/dist/src/transport.d.ts +7 -221
- package/dist/src/transport.js +6 -464
- package/dist/src/transport.js.map +1 -1
- package/package.json +16 -5
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { parseSpecMemo, remainingOf, SPEC_MEMO_PREFIX } from "@intent-engine/core";
|
|
3
|
+
import { createdIn, hex, openProofEscrows, proofAt } from "./job-proofs.js";
|
|
4
|
+
import { MEMOS_PER_TRANSACTION, scan } from "./job-scan.js";
|
|
5
|
+
import { TRANSACTION_FETCHES } from "./transport.js";
|
|
6
|
+
export const SPEC_SCAN = 10;
|
|
7
|
+
export const MAINNET_GENESIS_HASH = "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d";
|
|
8
|
+
export const DEVNET_GENESIS_HASH = "EtWTRABZaYq6iMfeYKouRu166VU2xqa1wcaWoxPkrZBG";
|
|
9
|
+
export const TESTNET_GENESIS_HASH = "4uhcVJyU9pJkvQyS88uRDiswHXSCkY3zQawwpjk2NsfY";
|
|
10
|
+
export const PUBLIC_GENESIS_HASHES = new Set([MAINNET_GENESIS_HASH, DEVNET_GENESIS_HASH, TESTNET_GENESIS_HASH]);
|
|
11
|
+
export const MAX_SPEC_BYTES = 1_048_576;
|
|
12
|
+
export const SPEC_TIMEOUT_MS = 10_000;
|
|
13
|
+
export const PLAIN_HTTP_ON_PUBLIC = "is a plain http url, which a public cluster may not use";
|
|
14
|
+
export async function plainHttpOnPublic(transport, url) {
|
|
15
|
+
let protocol;
|
|
16
|
+
try {
|
|
17
|
+
protocol = new URL(url).protocol;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
return protocol === "http:" && PUBLIC_GENESIS_HASHES.has(await transport.genesisHash());
|
|
23
|
+
}
|
|
24
|
+
export class SpecUnreadable extends Error {
|
|
25
|
+
url;
|
|
26
|
+
constructor(url, reason) {
|
|
27
|
+
super(`the spec at ${url} ${reason}`);
|
|
28
|
+
this.name = "SpecUnreadable";
|
|
29
|
+
this.url = url;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export async function specUrlOf(transport, intent, createdAt) {
|
|
33
|
+
const floor = createdAt ?? (await proofAt(transport, intent))?.intent.createdAt ?? null;
|
|
34
|
+
const created = (transaction) => !transaction.failed && createdIn(transaction.emitted, intent);
|
|
35
|
+
const { transactions } = await scan(transport, intent, { floor, memo: SPEC_MEMO_PREFIX, until: created });
|
|
36
|
+
const tx = transactions.find(created);
|
|
37
|
+
if (tx === undefined) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
const urls = new Set((tx.memos ?? [])
|
|
41
|
+
.slice(0, MEMOS_PER_TRANSACTION)
|
|
42
|
+
.map(parseSpecMemo)
|
|
43
|
+
.flatMap((memo) => (memo === null ? [] : [memo.url])));
|
|
44
|
+
return urls.size === 1 ? ([...urls][0] ?? null) : null;
|
|
45
|
+
}
|
|
46
|
+
export async function jobsOf(transport, attestor) {
|
|
47
|
+
const proofs = await openProofEscrows(transport, attestor);
|
|
48
|
+
const urls = [];
|
|
49
|
+
for (let at = 0; at < proofs.length; at += TRANSACTION_FETCHES) {
|
|
50
|
+
urls.push(...(await Promise.all(proofs.slice(at, at + TRANSACTION_FETCHES).map(({ address, intent }) => specUrlOf(transport, address, intent.createdAt)))));
|
|
51
|
+
}
|
|
52
|
+
return proofs.map(({ address, intent, params }, i) => ({
|
|
53
|
+
intent: address,
|
|
54
|
+
owner: intent.owner,
|
|
55
|
+
nonce: intent.nonce,
|
|
56
|
+
attestor: params.attestor,
|
|
57
|
+
specHash: hex(params.specHash),
|
|
58
|
+
specUrl: urls[i] ?? null,
|
|
59
|
+
sells: remainingOf(intent),
|
|
60
|
+
judgeFee: params.judgeFee,
|
|
61
|
+
inputMint: intent.inputMint,
|
|
62
|
+
expiresAt: intent.expiresAt,
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
async function discarded(response) {
|
|
66
|
+
await response.body?.cancel().catch(() => undefined);
|
|
67
|
+
}
|
|
68
|
+
async function bounded(response, url) {
|
|
69
|
+
if (!response.ok) {
|
|
70
|
+
await discarded(response);
|
|
71
|
+
throw new SpecUnreadable(url, `answered ${response.status}`);
|
|
72
|
+
}
|
|
73
|
+
const declared = Number(response.headers.get("content-length") ?? "0");
|
|
74
|
+
if (declared > MAX_SPEC_BYTES) {
|
|
75
|
+
await discarded(response);
|
|
76
|
+
throw new SpecUnreadable(url, `is larger than ${MAX_SPEC_BYTES} bytes`);
|
|
77
|
+
}
|
|
78
|
+
const reader = response.body?.getReader();
|
|
79
|
+
const chunks = [];
|
|
80
|
+
let size = 0;
|
|
81
|
+
for (let next = await reader?.read(); next !== undefined && next.done !== true; next = await reader?.read()) {
|
|
82
|
+
size += next.value.length;
|
|
83
|
+
if (size > MAX_SPEC_BYTES) {
|
|
84
|
+
await reader?.cancel();
|
|
85
|
+
throw new SpecUnreadable(url, `is larger than ${MAX_SPEC_BYTES} bytes`);
|
|
86
|
+
}
|
|
87
|
+
chunks.push(next.value);
|
|
88
|
+
}
|
|
89
|
+
return Buffer.concat(chunks);
|
|
90
|
+
}
|
|
91
|
+
export async function readSpec(transport, get, intent) {
|
|
92
|
+
const proof = await proofAt(transport, intent);
|
|
93
|
+
if (proof === null) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
const url = await specUrlOf(transport, intent, proof.intent.createdAt);
|
|
97
|
+
if (url === null) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
if (await plainHttpOnPublic(transport, url)) {
|
|
101
|
+
throw new SpecUnreadable(url, PLAIN_HTTP_ON_PUBLIC);
|
|
102
|
+
}
|
|
103
|
+
const bytes = await bounded(await get(url, { redirect: "error", signal: AbortSignal.timeout(SPEC_TIMEOUT_MS) }), url);
|
|
104
|
+
const sha256 = createHash("sha256").update(bytes).digest("hex");
|
|
105
|
+
return { url, text: new TextDecoder().decode(bytes), sha256, matches: sha256 === hex(proof.params.specHash) };
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=job-specs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"job-specs.js","sourceRoot":"","sources":["../../src/job-specs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACnF,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAA0B,m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,CAAC;IAC/C,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACvE,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,MAAM,iBAAiB,CAAC,SAAS,EAAE,GAAG,CAAC,EAAE,CAAC;QAC5C,MAAM,IAAI,cAAc,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC;IACtD,CAAC;IACD,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,MAAM,GAAG,CAAC,GAAG,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC;IACtH,MAAM,MAAM,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAChE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;AAChH,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { DELIVERY_PAGES, DELIVERY_SCAN, MEMOS_PER_TRANSACTION, type Scan, scan, type ScanOptions, SIGNATURE_PAGE, transactionAt, } from "./job-scan.js";
|
|
2
|
+
export { createdAtOf, creationSlotOf, historyCovers, intentAt, JOBS_LIMIT, openProofEscrows } from "./job-proofs.js";
|
|
3
|
+
export { DEVNET_GENESIS_HASH, type Job, jobsOf, MAINNET_GENESIS_HASH, MAX_SPEC_BYTES, PLAIN_HTTP_ON_PUBLIC, plainHttpOnPublic, PUBLIC_GENESIS_HASHES, readSpec, type Spec, type SpecFetch, SPEC_SCAN, SPEC_TIMEOUT_MS, SpecUnreadable, specUrlOf, TESTNET_GENESIS_HASH, } from "./job-specs.js";
|
|
4
|
+
export { type FollowUp, followUpInstructions, followUpMemo, followUpOf, memoInstruction, memosSignedBy, parseFollowUpMemo, recordedDelivery, RELEASE_MARK, } from "./job-memos.js";
|
|
5
|
+
export { type Announcement, announcements, type DeliverInput, deliveriesOf, type Delivery, deliveryInstructions, deliveryRecord, type DeliveryRecord, firstDelivery, NotDeliverable, } from "./job-deliveries.js";
|
|
6
|
+
export { creationProof, type EngineCall, engineCalls, escrowOrigin, type EscrowOrigin, type EscrowProof, type Lifecycle, lifecycleDeliveries, originDeliveries, } from "./job-origins.js";
|
package/dist/src/jobs.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { DELIVERY_PAGES, DELIVERY_SCAN, MEMOS_PER_TRANSACTION, scan, SIGNATURE_PAGE, transactionAt, } from "./job-scan.js";
|
|
2
|
+
export { createdAtOf, creationSlotOf, historyCovers, intentAt, JOBS_LIMIT, openProofEscrows } from "./job-proofs.js";
|
|
3
|
+
export { DEVNET_GENESIS_HASH, jobsOf, MAINNET_GENESIS_HASH, MAX_SPEC_BYTES, PLAIN_HTTP_ON_PUBLIC, plainHttpOnPublic, PUBLIC_GENESIS_HASHES, readSpec, SPEC_SCAN, SPEC_TIMEOUT_MS, SpecUnreadable, specUrlOf, TESTNET_GENESIS_HASH, } from "./job-specs.js";
|
|
4
|
+
export { followUpInstructions, followUpMemo, followUpOf, memoInstruction, memosSignedBy, parseFollowUpMemo, recordedDelivery, RELEASE_MARK, } from "./job-memos.js";
|
|
5
|
+
export { announcements, deliveriesOf, deliveryInstructions, deliveryRecord, firstDelivery, NotDeliverable, } from "./job-deliveries.js";
|
|
6
|
+
export { creationProof, engineCalls, escrowOrigin, lifecycleDeliveries, originDeliveries, } from "./job-origins.js";
|
|
7
|
+
//# sourceMappingURL=jobs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jobs.js","sourceRoot":"","sources":["../../src/jobs.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,aAAa,EACb,qBAAqB,EAErB,IAAI,EAEJ,cAAc,EACd,aAAa,GACd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,QAAQ,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACrH,OAAO,EACL,mBAAmB,EAEnB,MAAM,EACN,oBAAoB,EACpB,cAAc,EACd,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,QAAQ,EAGR,SAAS,EACT,eAAe,EACf,cAAc,EACd,SAAS,EACT,oBAAoB,GACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAEL,oBAAoB,EACpB,YAAY,EACZ,UAAU,EACV,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAEL,aAAa,EAEb,YAAY,EAEZ,oBAAoB,EACpB,cAAc,EAEd,aAAa,EACb,cAAc,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,aAAa,EAEb,WAAW,EACX,YAAY,EAIZ,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export function boundMembers(inner) {
|
|
2
|
+
const members = {};
|
|
3
|
+
for (let at = inner; at !== null && at !== Object.prototype; at = Object.getPrototypeOf(at)) {
|
|
4
|
+
for (const key of Reflect.ownKeys(at)) {
|
|
5
|
+
if (key === "constructor" || Object.prototype.hasOwnProperty.call(members, key)) {
|
|
6
|
+
continue;
|
|
7
|
+
}
|
|
8
|
+
const value = Reflect.get(inner, key);
|
|
9
|
+
members[key] = typeof value === "function" ? value.bind(inner) : value;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return members;
|
|
13
|
+
}
|
|
14
|
+
const MEMOIZED = Symbol("memoized");
|
|
15
|
+
const UNDERLYING = Symbol("underlying");
|
|
16
|
+
export const unmemoized = (transport) => transport[UNDERLYING] ?? transport;
|
|
17
|
+
export function memoized(inner) {
|
|
18
|
+
if (inner[MEMOIZED] === true) {
|
|
19
|
+
return inner;
|
|
20
|
+
}
|
|
21
|
+
const members = boundMembers(inner);
|
|
22
|
+
const seen = new Map();
|
|
23
|
+
const keep = (address, pending) => {
|
|
24
|
+
seen.set(address, pending);
|
|
25
|
+
pending.catch(() => {
|
|
26
|
+
if (seen.get(address) === pending) {
|
|
27
|
+
seen.delete(address);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return pending;
|
|
31
|
+
};
|
|
32
|
+
const getAccount = (address) => seen.get(address) ?? keep(address, members.getAccount(address));
|
|
33
|
+
const warm = async (addresses) => {
|
|
34
|
+
const missing = [...new Set(addresses)].filter((address) => !seen.has(address));
|
|
35
|
+
if (missing.length === 0) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const fetched = members.getAccounts(missing);
|
|
39
|
+
missing.forEach((address, i) => keep(address, fetched.then((views) => views[i] ?? null)));
|
|
40
|
+
await fetched;
|
|
41
|
+
};
|
|
42
|
+
const writing = (write) => async (...args) => {
|
|
43
|
+
try {
|
|
44
|
+
return await write(...args);
|
|
45
|
+
}
|
|
46
|
+
finally {
|
|
47
|
+
seen.clear();
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
return {
|
|
51
|
+
...members,
|
|
52
|
+
[MEMOIZED]: true,
|
|
53
|
+
[UNDERLYING]: inner,
|
|
54
|
+
getAccount,
|
|
55
|
+
send: writing(members.send),
|
|
56
|
+
sendWire: writing(members.sendWire),
|
|
57
|
+
submitWire: writing(members.submitWire),
|
|
58
|
+
airdrop: writing(members.airdrop),
|
|
59
|
+
getAccounts: async (addresses) => {
|
|
60
|
+
await warm(addresses);
|
|
61
|
+
return Promise.all(addresses.map(getAccount));
|
|
62
|
+
},
|
|
63
|
+
warm,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=memoized-transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memoized-transport.js","sourceRoot":"","sources":["../../src/memoized-transport.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,YAAY,CAAmB,KAAQ;IACrD,MAAM,OAAO,GAAiC,EAAE,CAAC;IACjD,KAAK,IAAI,EAAE,GAAkB,KAAK,EAAE,EAAE,KAAK,IAAI,IAAI,EAAE,KAAK,MAAM,CAAC,SAAS,EAAE,EAAE,GAAG,MAAM,CAAC,cAAc,CAAC,EAAE,CAAkB,EAAE,CAAC;QAC5H,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC;YACtC,IAAI,GAAG,KAAK,aAAa,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC;gBAChF,SAAS;YACX,CAAC;YACD,MAAM,KAAK,GAAY,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YAC/C,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QACzE,CAAC;IACH,CAAC;IACD,OAAO,OAAY,CAAC;AACtB,CAAC;AAED,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;AACpC,MAAM,UAAU,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;AAExC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,SAAoB,EAAa,EAAE,CAC3D,SAA0C,CAAC,UAAU,CAAC,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AC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;QAC1F,MAAM,OAAO,CAAC;IAChB,CAAC,CAAC;IACF,MAAM,OAAO,GACX,CAAyB,KAAiC,EAAE,EAAE,CAC9D,KAAK,EAAE,GAAG,IAAO,EAAc,EAAE;QAC/B,IAAI,CAAC;YACH,OAAO,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;QAC9B,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,CAAC;IACH,CAAC,CAAC;IACJ,OAAO;QACL,GAAG,OAAO;QACV,CAAC,QAAQ,CAAC,EAAE,IAAI;QAChB,CAAC,UAAU,CAAC,EAAE,KAAK;QACnB,UAAU;QACV,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;QAC3B,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC;QACnC,UAAU,EAAE,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC;QACvC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC;QACjC,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE;YAC/B,MAAM,IAAI,CAAC,SAAS,CAAC,CAAC;YACtB,OAAO,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;QAChD,CAAC;QACD,IAAI;KACQ,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const POLL_MS = 500;
|
|
2
|
+
export declare const sleep: (ms: number) => Promise<void>;
|
|
3
|
+
export declare const RATE_LIMIT_ATTEMPTS = 6;
|
|
4
|
+
export declare function rateLimited(error: unknown): boolean;
|
|
5
|
+
export declare const MIN_CONTEXT_SLOT_NOT_REACHED = -32016;
|
|
6
|
+
export declare function behindMinSlot(error: unknown): boolean;
|
|
7
|
+
export declare function patiently<T>(call: () => Promise<T>, wait?: (ms: number) => Promise<void>): Promise<T>;
|
|
8
|
+
export declare class Charged extends Error {
|
|
9
|
+
constructor(message: string);
|
|
10
|
+
}
|
|
11
|
+
export declare class FailedOnChain extends Charged {
|
|
12
|
+
}
|
|
13
|
+
export declare class BlockhashExpired extends Error {
|
|
14
|
+
constructor(message: string);
|
|
15
|
+
}
|
|
16
|
+
export declare const neverLanded: (error: unknown) => boolean;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { isSolanaError, SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR } from "@solana/kit";
|
|
2
|
+
export const POLL_MS = 500;
|
|
3
|
+
export const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
4
|
+
export const RATE_LIMIT_ATTEMPTS = 6;
|
|
5
|
+
const CAUSE_DEPTH = 8;
|
|
6
|
+
function causes(error) {
|
|
7
|
+
const chain = [];
|
|
8
|
+
for (let link = error; link instanceof Error && chain.length < CAUSE_DEPTH; link = link.cause) {
|
|
9
|
+
chain.push(link);
|
|
10
|
+
}
|
|
11
|
+
return chain;
|
|
12
|
+
}
|
|
13
|
+
const said = (chain, text) => chain.some((link) => !isSolanaError(link) && text.test(link.message));
|
|
14
|
+
export function rateLimited(error) {
|
|
15
|
+
if (!(error instanceof Error) || error instanceof Charged) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
const chain = causes(error);
|
|
19
|
+
for (const link of chain) {
|
|
20
|
+
if (isSolanaError(link, SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR)) {
|
|
21
|
+
return link.context.statusCode === 429;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return said(chain, /\b429\b/);
|
|
25
|
+
}
|
|
26
|
+
export const MIN_CONTEXT_SLOT_NOT_REACHED = -32016;
|
|
27
|
+
export function behindMinSlot(error) {
|
|
28
|
+
if (!(error instanceof Error) || error instanceof Charged) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
const chain = causes(error);
|
|
32
|
+
return chain.some((link) => isSolanaError(link, MIN_CONTEXT_SLOT_NOT_REACHED)) || said(chain, /-32016\b|minimum context slot/i);
|
|
33
|
+
}
|
|
34
|
+
export async function patiently(call, wait = sleep) {
|
|
35
|
+
for (let attempt = 1;; attempt++) {
|
|
36
|
+
try {
|
|
37
|
+
return await call();
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
if (!(rateLimited(error) || behindMinSlot(error)) || attempt >= RATE_LIMIT_ATTEMPTS) {
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
await wait(POLL_MS * 2 ** attempt);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export class Charged extends Error {
|
|
48
|
+
constructor(message) {
|
|
49
|
+
super(message);
|
|
50
|
+
this.name = "Charged";
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export class FailedOnChain extends Charged {
|
|
54
|
+
}
|
|
55
|
+
export class BlockhashExpired extends Error {
|
|
56
|
+
constructor(message) {
|
|
57
|
+
super(message);
|
|
58
|
+
this.name = "BlockhashExpired";
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export const neverLanded = (error) => error instanceof FailedOnChain || error instanceof BlockhashExpired;
|
|
62
|
+
//# sourceMappingURL=rpc-retry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc-retry.js","sourceRoot":"","sources":["../../src/rpc-retry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,uCAAuC,EAAE,MAAM,aAAa,CAAC;AAErF,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,CAAC;AAE3B,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,UA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AE,CAAC,KAAK,YAAY,aAAa,IAAI,KAAK,YAAY,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import type { Address, Base64EncodedWireTransaction, Blockhash, Instruction, Signature, TransactionSigner } from "@solana/kit";
|
|
2
|
+
export type AccountView = {
|
|
3
|
+
owner: Address;
|
|
4
|
+
data: Uint8Array;
|
|
5
|
+
lamports: bigint;
|
|
6
|
+
executable?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type ProgramAccount = {
|
|
9
|
+
address: Address;
|
|
10
|
+
data: Uint8Array;
|
|
11
|
+
};
|
|
12
|
+
export type TokenHolding = {
|
|
13
|
+
account: Address;
|
|
14
|
+
mint: Address;
|
|
15
|
+
owner?: Address;
|
|
16
|
+
};
|
|
17
|
+
export type EngineTransaction = {
|
|
18
|
+
signature: string;
|
|
19
|
+
slot: bigint;
|
|
20
|
+
blockTime: bigint | null;
|
|
21
|
+
failed: boolean;
|
|
22
|
+
emitted: Uint8Array[];
|
|
23
|
+
emittedAccounts?: Address[][];
|
|
24
|
+
memos?: string[];
|
|
25
|
+
memoSigners?: Address[][];
|
|
26
|
+
feePayer?: Address;
|
|
27
|
+
called?: Uint8Array[];
|
|
28
|
+
calledAccounts?: Address[][];
|
|
29
|
+
tokens?: TokenHolding[];
|
|
30
|
+
unread?: true;
|
|
31
|
+
};
|
|
32
|
+
export type ListedSignature = {
|
|
33
|
+
signature: string;
|
|
34
|
+
slot: bigint;
|
|
35
|
+
blockTime: bigint | null;
|
|
36
|
+
failed: boolean;
|
|
37
|
+
memo: string | null;
|
|
38
|
+
};
|
|
39
|
+
export type Latest = {
|
|
40
|
+
blockhash: Blockhash;
|
|
41
|
+
lastValidBlockHeight: bigint;
|
|
42
|
+
};
|
|
43
|
+
export type IntentRead = {
|
|
44
|
+
minContextSlot?: bigint;
|
|
45
|
+
onSlot?: (slot: bigint) => void;
|
|
46
|
+
};
|
|
47
|
+
export type LookupTables = Readonly<Record<Address, Address[]>>;
|
|
48
|
+
export type Simulation = {
|
|
49
|
+
err: string | null;
|
|
50
|
+
logs: string[];
|
|
51
|
+
unitsConsumed: bigint | null;
|
|
52
|
+
accounts: (Uint8Array | null)[];
|
|
53
|
+
};
|
|
54
|
+
export interface Transport {
|
|
55
|
+
getAccount(address: Address): Promise<AccountView | null>;
|
|
56
|
+
getAccounts(addresses: readonly Address[]): Promise<(AccountView | null)[]>;
|
|
57
|
+
warm?(addresses: readonly Address[]): Promise<void>;
|
|
58
|
+
send(instructions: readonly Instruction[], payer: TransactionSigner): Promise<string>;
|
|
59
|
+
latestBlockhash(): Promise<Latest>;
|
|
60
|
+
sendWire(wire: Base64EncodedWireTransaction, latest: Latest): Promise<string>;
|
|
61
|
+
submitWire(wire: Base64EncodedWireTransaction): Promise<string>;
|
|
62
|
+
simulate(wire: Base64EncodedWireTransaction, watch?: readonly Address[]): Promise<Simulation>;
|
|
63
|
+
genesisHash(): Promise<string>;
|
|
64
|
+
intents(owner?: Address, read?: IntentRead): Promise<ProgramAccount[]>;
|
|
65
|
+
engineTransactions(limit: number, of?: Address, memo?: string): Promise<EngineTransaction[]>;
|
|
66
|
+
signaturesOf?(of: Address, limit: number, before?: string): Promise<ListedSignature[]>;
|
|
67
|
+
transactionsOf?(listed: readonly ListedSignature[]): Promise<EngineTransaction[]>;
|
|
68
|
+
transactionOf?(signature: string): Promise<EngineTransaction | null>;
|
|
69
|
+
firstAvailableSlot?(): Promise<bigint>;
|
|
70
|
+
recentFees(accounts: readonly Address[]): Promise<bigint[]>;
|
|
71
|
+
budget(instructions: readonly Instruction[], feePayer: Address, tables?: LookupTables): Promise<Instruction[]>;
|
|
72
|
+
airdrop(address: Address, lamports: bigint): Promise<string>;
|
|
73
|
+
}
|
|
74
|
+
export type Pending<T> = {
|
|
75
|
+
send(): Promise<T>;
|
|
76
|
+
};
|
|
77
|
+
export type RawAccount = {
|
|
78
|
+
owner: Address;
|
|
79
|
+
data: readonly [string, string];
|
|
80
|
+
lamports: bigint;
|
|
81
|
+
executable: boolean;
|
|
82
|
+
};
|
|
83
|
+
export type AtLeast = {
|
|
84
|
+
minContextSlot?: bigint;
|
|
85
|
+
};
|
|
86
|
+
export type ProgramEntry = {
|
|
87
|
+
pubkey: Address;
|
|
88
|
+
account: {
|
|
89
|
+
data: readonly [string, string];
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
export type Status = {
|
|
93
|
+
err: unknown;
|
|
94
|
+
confirmationStatus: string | null;
|
|
95
|
+
slot?: bigint;
|
|
96
|
+
};
|
|
97
|
+
export type RpcLike = {
|
|
98
|
+
getMultipleAccounts(addresses: Address[], config: {
|
|
99
|
+
encoding: "base64";
|
|
100
|
+
} & AtLeast): Pending<{
|
|
101
|
+
value: (RawAccount | null)[];
|
|
102
|
+
}>;
|
|
103
|
+
getAccountInfo(address: Address, config: {
|
|
104
|
+
encoding: "base64";
|
|
105
|
+
} & AtLeast): Pending<{
|
|
106
|
+
value: {
|
|
107
|
+
owner: Address;
|
|
108
|
+
data: readonly [string, string];
|
|
109
|
+
lamports: bigint;
|
|
110
|
+
executable: boolean;
|
|
111
|
+
} | null;
|
|
112
|
+
}>;
|
|
113
|
+
getLatestBlockhash(): Pending<{
|
|
114
|
+
value: {
|
|
115
|
+
blockhash: Blockhash;
|
|
116
|
+
lastValidBlockHeight: bigint;
|
|
117
|
+
};
|
|
118
|
+
}>;
|
|
119
|
+
sendTransaction(wire: Base64EncodedWireTransaction, config: {
|
|
120
|
+
encoding: "base64";
|
|
121
|
+
skipPreflight?: boolean;
|
|
122
|
+
}): Pending<Signature>;
|
|
123
|
+
simulateTransaction(wire: Base64EncodedWireTransaction, config: {
|
|
124
|
+
encoding: "base64";
|
|
125
|
+
sigVerify: false;
|
|
126
|
+
replaceRecentBlockhash: true;
|
|
127
|
+
accounts?: {
|
|
128
|
+
addresses: Address[];
|
|
129
|
+
encoding: "base64";
|
|
130
|
+
};
|
|
131
|
+
}): Pending<{
|
|
132
|
+
value: {
|
|
133
|
+
err: unknown;
|
|
134
|
+
logs: readonly string[] | null;
|
|
135
|
+
unitsConsumed?: bigint | undefined;
|
|
136
|
+
accounts?: readonly ({
|
|
137
|
+
data: readonly [string, string];
|
|
138
|
+
} | null)[] | null;
|
|
139
|
+
};
|
|
140
|
+
}>;
|
|
141
|
+
getSignatureStatuses(signatures: Signature[], config?: {
|
|
142
|
+
searchTransactionHistory: boolean;
|
|
143
|
+
}): Pending<{
|
|
144
|
+
context: {
|
|
145
|
+
slot: bigint;
|
|
146
|
+
};
|
|
147
|
+
value: readonly (Status | null)[];
|
|
148
|
+
}>;
|
|
149
|
+
getEpochInfo(): Pending<{
|
|
150
|
+
blockHeight: bigint;
|
|
151
|
+
absoluteSlot: bigint;
|
|
152
|
+
}>;
|
|
153
|
+
getFirstAvailableBlock?(): Pending<bigint>;
|
|
154
|
+
requestAirdrop(address: Address, lamports: bigint): Pending<Signature>;
|
|
155
|
+
getRecentPrioritizationFees(addresses: readonly Address[]): Pending<readonly {
|
|
156
|
+
prioritizationFee: bigint;
|
|
157
|
+
}[]>;
|
|
158
|
+
getGenesisHash(): Pending<string>;
|
|
159
|
+
getProgramAccounts(program: Address, config: {
|
|
160
|
+
encoding: "base64";
|
|
161
|
+
commitment: "confirmed";
|
|
162
|
+
filters: readonly ({
|
|
163
|
+
dataSize: bigint;
|
|
164
|
+
} | {
|
|
165
|
+
memcmp: {
|
|
166
|
+
offset: bigint;
|
|
167
|
+
bytes: string;
|
|
168
|
+
encoding: "base58";
|
|
169
|
+
};
|
|
170
|
+
})[];
|
|
171
|
+
withContext?: true;
|
|
172
|
+
} & AtLeast): Pending<readonly ProgramEntry[] | {
|
|
173
|
+
context: {
|
|
174
|
+
slot: bigint;
|
|
175
|
+
};
|
|
176
|
+
value: readonly ProgramEntry[];
|
|
177
|
+
}>;
|
|
178
|
+
getSignaturesForAddress(address: Address, config: {
|
|
179
|
+
limit: number;
|
|
180
|
+
before?: Signature;
|
|
181
|
+
} & AtLeast): Pending<readonly {
|
|
182
|
+
signature: Signature;
|
|
183
|
+
slot: bigint;
|
|
184
|
+
blockTime: bigint | null;
|
|
185
|
+
err: unknown;
|
|
186
|
+
memo?: string | null;
|
|
187
|
+
}[]>;
|
|
188
|
+
getTransaction(signature: Signature, config: {
|
|
189
|
+
encoding: "json";
|
|
190
|
+
maxSupportedTransactionVersion: 0;
|
|
191
|
+
commitment: "confirmed";
|
|
192
|
+
}): Pending<{
|
|
193
|
+
slot?: bigint;
|
|
194
|
+
blockTime?: bigint | null;
|
|
195
|
+
transaction: {
|
|
196
|
+
message: {
|
|
197
|
+
accountKeys: readonly Address[];
|
|
198
|
+
header?: {
|
|
199
|
+
numRequiredSignatures: number;
|
|
200
|
+
};
|
|
201
|
+
instructions?: readonly {
|
|
202
|
+
programIdIndex: number;
|
|
203
|
+
accounts?: readonly number[];
|
|
204
|
+
data: string;
|
|
205
|
+
}[];
|
|
206
|
+
};
|
|
207
|
+
};
|
|
208
|
+
meta: {
|
|
209
|
+
err?: unknown;
|
|
210
|
+
loadedAddresses?: {
|
|
211
|
+
writable: readonly Address[];
|
|
212
|
+
readonly: readonly Address[];
|
|
213
|
+
};
|
|
214
|
+
innerInstructions?: readonly {
|
|
215
|
+
instructions: readonly {
|
|
216
|
+
programIdIndex: number;
|
|
217
|
+
accounts?: readonly number[];
|
|
218
|
+
data: string;
|
|
219
|
+
}[];
|
|
220
|
+
}[] | null;
|
|
221
|
+
preTokenBalances?: readonly TokenBalance[] | null;
|
|
222
|
+
postTokenBalances?: readonly TokenBalance[] | null;
|
|
223
|
+
} | null;
|
|
224
|
+
} | null>;
|
|
225
|
+
};
|
|
226
|
+
export type TokenBalance = {
|
|
227
|
+
accountIndex: number;
|
|
228
|
+
mint: string;
|
|
229
|
+
owner?: string;
|
|
230
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc-shapes.js","sourceRoot":"","sources":["../../src/rpc-shapes.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type SignatureWatch } from "./confirmation.js";
|
|
2
|
+
import type { RpcLike, Transport } from "./rpc-shapes.js";
|
|
3
|
+
export declare const MULTIPLE_ACCOUNTS_LIMIT = 100;
|
|
4
|
+
export declare const TRANSACTION_FETCHES = 4;
|
|
5
|
+
export declare const KEPT_TRANSACTIONS = 256;
|
|
6
|
+
export declare function rpcTransport(rpc: RpcLike, wait?: (ms: number) => Promise<void>, watch?: SignatureWatch): Transport;
|