@anywalletkit/protocol-swap2-stargate 0.0.0-stage → 0.1.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/LICENSE +202 -0
- package/README.md +502 -2
- package/dist/abi.cjs +91 -0
- package/dist/abi.cjs.map +1 -0
- package/dist/abi.d.cts +810 -0
- package/dist/abi.d.ts +810 -0
- package/dist/abi.js +13 -0
- package/dist/abi.js.map +1 -0
- package/dist/amounts.cjs +73 -0
- package/dist/amounts.cjs.map +1 -0
- package/dist/amounts.d.cts +21 -0
- package/dist/amounts.d.ts +21 -0
- package/dist/amounts.js +15 -0
- package/dist/amounts.js.map +1 -0
- package/dist/bus-Cdw8iwOv.d.cts +59 -0
- package/dist/bus-vAWqTAkq.d.ts +59 -0
- package/dist/bus.cjs +237 -0
- package/dist/bus.cjs.map +1 -0
- package/dist/bus.d.cts +4 -0
- package/dist/bus.d.ts +4 -0
- package/dist/bus.js +22 -0
- package/dist/bus.js.map +1 -0
- package/dist/chunk-3NTMZUAU.js +128 -0
- package/dist/chunk-3NTMZUAU.js.map +1 -0
- package/dist/chunk-4HU46QF2.js +256 -0
- package/dist/chunk-4HU46QF2.js.map +1 -0
- package/dist/chunk-4IDDRIE2.js +125 -0
- package/dist/chunk-4IDDRIE2.js.map +1 -0
- package/dist/chunk-EANM3EI3.js +71 -0
- package/dist/chunk-EANM3EI3.js.map +1 -0
- package/dist/chunk-ERC6LKMN.js +87 -0
- package/dist/chunk-ERC6LKMN.js.map +1 -0
- package/dist/chunk-FLAXDJPE.js +24 -0
- package/dist/chunk-FLAXDJPE.js.map +1 -0
- package/dist/chunk-N54YIG6T.js +33 -0
- package/dist/chunk-N54YIG6T.js.map +1 -0
- package/dist/chunk-OUGUX3JK.js +53 -0
- package/dist/chunk-OUGUX3JK.js.map +1 -0
- package/dist/chunk-PJXDMVW3.js +909 -0
- package/dist/chunk-PJXDMVW3.js.map +1 -0
- package/dist/chunk-QNVTQEOV.js +72 -0
- package/dist/chunk-QNVTQEOV.js.map +1 -0
- package/dist/chunk-UDJL7BUP.js +249 -0
- package/dist/chunk-UDJL7BUP.js.map +1 -0
- package/dist/chunk-YHHV3XHY.js +139 -0
- package/dist/chunk-YHHV3XHY.js.map +1 -0
- package/dist/compose-dex.cjs +148 -0
- package/dist/compose-dex.cjs.map +1 -0
- package/dist/compose-dex.d.cts +113 -0
- package/dist/compose-dex.d.ts +113 -0
- package/dist/compose-dex.js +25 -0
- package/dist/compose-dex.js.map +1 -0
- package/dist/compose-route.cjs +1019 -0
- package/dist/compose-route.cjs.map +1 -0
- package/dist/compose-route.d.cts +93 -0
- package/dist/compose-route.d.ts +93 -0
- package/dist/compose-route.js +45 -0
- package/dist/compose-route.js.map +1 -0
- package/dist/compose.cjs +287 -0
- package/dist/compose.cjs.map +1 -0
- package/dist/compose.d.cts +293 -0
- package/dist/compose.d.ts +293 -0
- package/dist/compose.js +30 -0
- package/dist/compose.js.map +1 -0
- package/dist/deployments.cjs +350 -0
- package/dist/deployments.cjs.map +1 -0
- package/dist/deployments.d.cts +12 -0
- package/dist/deployments.d.ts +12 -0
- package/dist/deployments.js +11 -0
- package/dist/deployments.js.map +1 -0
- package/dist/index.cjs +1862 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +23 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +46 -0
- package/dist/index.js.map +1 -0
- package/dist/native-drop.cjs +117 -0
- package/dist/native-drop.cjs.map +1 -0
- package/dist/native-drop.d.cts +13 -0
- package/dist/native-drop.d.ts +13 -0
- package/dist/native-drop.js +11 -0
- package/dist/native-drop.js.map +1 -0
- package/dist/pins.cjs +1618 -0
- package/dist/pins.cjs.map +1 -0
- package/dist/pins.d.cts +39 -0
- package/dist/pins.d.ts +39 -0
- package/dist/pins.js +21 -0
- package/dist/pins.js.map +1 -0
- package/dist/protocol.cjs +1851 -0
- package/dist/protocol.cjs.map +1 -0
- package/dist/protocol.d.cts +24 -0
- package/dist/protocol.d.ts +24 -0
- package/dist/protocol.js +18 -0
- package/dist/protocol.js.map +1 -0
- package/dist/provider.cjs +1833 -0
- package/dist/provider.cjs.map +1 -0
- package/dist/provider.d.cts +30 -0
- package/dist/provider.d.ts +30 -0
- package/dist/provider.js +17 -0
- package/dist/provider.js.map +1 -0
- package/dist/quote-r1bA8XbO.d.cts +102 -0
- package/dist/quote-t7UJSxbU.d.ts +102 -0
- package/dist/quote.cjs +618 -0
- package/dist/quote.cjs.map +1 -0
- package/dist/quote.d.cts +3 -0
- package/dist/quote.d.ts +3 -0
- package/dist/quote.js +16 -0
- package/dist/quote.js.map +1 -0
- package/dist/registry.cjs +100 -0
- package/dist/registry.cjs.map +1 -0
- package/dist/registry.d.cts +42 -0
- package/dist/registry.d.ts +42 -0
- package/dist/registry.js +8 -0
- package/dist/registry.js.map +1 -0
- package/dist/tracking.cjs +1143 -0
- package/dist/tracking.cjs.map +1 -0
- package/dist/tracking.d.cts +57 -0
- package/dist/tracking.d.ts +57 -0
- package/dist/tracking.js +23 -0
- package/dist/tracking.js.map +1 -0
- package/package.json +134 -3
package/dist/abi.js
ADDED
package/dist/abi.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/amounts.cjs
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/amounts.ts
|
|
21
|
+
var amounts_exports = {};
|
|
22
|
+
__export(amounts_exports, {
|
|
23
|
+
conversionRate: () => conversionRate,
|
|
24
|
+
destinationAmount: () => destinationAmount,
|
|
25
|
+
sourceMinimum: () => sourceMinimum,
|
|
26
|
+
splitFeeDetails: () => splitFeeDetails,
|
|
27
|
+
splitSourceAmount: () => splitSourceAmount
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(amounts_exports);
|
|
30
|
+
var UINT64_MAX = (1n << 64n) - 1n;
|
|
31
|
+
var UINT256_MAX = (1n << 256n) - 1n;
|
|
32
|
+
function uint256(amount) {
|
|
33
|
+
if (typeof amount !== "bigint" || amount < 0n || amount > UINT256_MAX) throw new RangeError("stargate: amount must be uint256 bigint");
|
|
34
|
+
}
|
|
35
|
+
function conversionRate(localDecimals, sharedDecimals) {
|
|
36
|
+
if (!Number.isInteger(localDecimals) || !Number.isInteger(sharedDecimals) || sharedDecimals < 0 || localDecimals < sharedDecimals || localDecimals > 255 || localDecimals - sharedDecimals > 77) {
|
|
37
|
+
throw new RangeError("stargate: invalid local/shared decimals");
|
|
38
|
+
}
|
|
39
|
+
return 10n ** BigInt(localDecimals - sharedDecimals);
|
|
40
|
+
}
|
|
41
|
+
function splitSourceAmount(amountLD, localDecimals, sharedDecimals) {
|
|
42
|
+
uint256(amountLD);
|
|
43
|
+
const rate = conversionRate(localDecimals, sharedDecimals);
|
|
44
|
+
const amountSD = amountLD / rate;
|
|
45
|
+
if (amountSD > UINT64_MAX) throw new RangeError("stargate: shared amount exceeds uint64");
|
|
46
|
+
return { amountSD, sentLD: amountSD * rate, dustLD: amountLD % rate };
|
|
47
|
+
}
|
|
48
|
+
function destinationAmount(receivedSourceLD, sourceDecimals, destinationDecimals, sharedDecimals) {
|
|
49
|
+
const { amountSD, dustLD } = splitSourceAmount(receivedSourceLD, sourceDecimals, sharedDecimals);
|
|
50
|
+
if (dustLD !== 0n) throw new RangeError("stargate: quote receipt is not shared-decimal aligned");
|
|
51
|
+
const amount = amountSD * conversionRate(destinationDecimals, sharedDecimals);
|
|
52
|
+
uint256(amount);
|
|
53
|
+
return amount;
|
|
54
|
+
}
|
|
55
|
+
function sourceMinimum(minDestinationLD, sourceDecimals, destinationDecimals, sharedDecimals) {
|
|
56
|
+
uint256(minDestinationLD);
|
|
57
|
+
const destinationRate = conversionRate(destinationDecimals, sharedDecimals);
|
|
58
|
+
const minimumSD = (minDestinationLD + destinationRate - 1n) / destinationRate;
|
|
59
|
+
if (minimumSD > UINT64_MAX) throw new RangeError("stargate: minimum exceeds uint64 shared amount");
|
|
60
|
+
const minimumLD = minimumSD * conversionRate(sourceDecimals, sharedDecimals);
|
|
61
|
+
uint256(minimumLD);
|
|
62
|
+
return minimumLD;
|
|
63
|
+
}
|
|
64
|
+
function splitFeeDetails(details) {
|
|
65
|
+
let feeLD = 0n, rewardLD = 0n;
|
|
66
|
+
for (const { feeAmountLD } of details) {
|
|
67
|
+
if (typeof feeAmountLD !== "bigint" || feeAmountLD < -(1n << 255n) || feeAmountLD >= 1n << 255n) throw new RangeError("stargate: fee must be int256 bigint");
|
|
68
|
+
if (feeAmountLD < 0n) feeLD -= feeAmountLD;
|
|
69
|
+
else rewardLD += feeAmountLD;
|
|
70
|
+
}
|
|
71
|
+
return { feeLD, rewardLD };
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=amounts.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/amounts.ts"],"sourcesContent":["const UINT64_MAX = (1n << 64n) - 1n;\nconst UINT256_MAX = (1n << 256n) - 1n;\n\nfunction uint256(amount: bigint): void {\n if (typeof amount !== \"bigint\" || amount < 0n || amount > UINT256_MAX) throw new RangeError(\"stargate: amount must be uint256 bigint\");\n}\n\n/** Stargate converts through a uint64 shared-decimal amount. */\nexport function conversionRate(localDecimals: number, sharedDecimals: number): bigint {\n if (!Number.isInteger(localDecimals) || !Number.isInteger(sharedDecimals) || sharedDecimals < 0 || localDecimals < sharedDecimals || localDecimals > 255 || localDecimals - sharedDecimals > 77) {\n throw new RangeError(\"stargate: invalid local/shared decimals\");\n }\n return 10n ** BigInt(localDecimals - sharedDecimals);\n}\n\n/** Source amount that can be represented on the wire; dust is not silently added to the output. */\nexport function splitSourceAmount(amountLD: bigint, localDecimals: number, sharedDecimals: number): {amountSD: bigint; sentLD: bigint; dustLD: bigint} {\n uint256(amountLD);\n const rate = conversionRate(localDecimals, sharedDecimals);\n const amountSD = amountLD / rate;\n if (amountSD > UINT64_MAX) throw new RangeError(\"stargate: shared amount exceeds uint64\");\n return {amountSD, sentLD: amountSD * rate, dustLD: amountLD % rate};\n}\n\n/** quoteOFT's received amount uses SOURCE local decimals, not destination decimals. */\nexport function destinationAmount(receivedSourceLD: bigint, sourceDecimals: number, destinationDecimals: number, sharedDecimals: number): bigint {\n const {amountSD, dustLD} = splitSourceAmount(receivedSourceLD, sourceDecimals, sharedDecimals);\n if (dustLD !== 0n) throw new RangeError(\"stargate: quote receipt is not shared-decimal aligned\");\n const amount = amountSD * conversionRate(destinationDecimals, sharedDecimals);\n uint256(amount);\n return amount;\n}\n\n/** Round the caller's destination floor UP, then encode it in source local units. */\nexport function sourceMinimum(minDestinationLD: bigint, sourceDecimals: number, destinationDecimals: number, sharedDecimals: number): bigint {\n uint256(minDestinationLD);\n const destinationRate = conversionRate(destinationDecimals, sharedDecimals);\n const minimumSD = (minDestinationLD + destinationRate - 1n) / destinationRate;\n if (minimumSD > UINT64_MAX) throw new RangeError(\"stargate: minimum exceeds uint64 shared amount\");\n const minimumLD = minimumSD * conversionRate(sourceDecimals, sharedDecimals);\n uint256(minimumLD);\n return minimumLD;\n}\n\n/** Stargate fee details are negative for charges, positive for rewards. Both use source local units. */\nexport function splitFeeDetails(details: readonly {feeAmountLD: bigint}[]): {feeLD: bigint; rewardLD: bigint} {\n let feeLD = 0n, rewardLD = 0n;\n for (const {feeAmountLD} of details) {\n if (typeof feeAmountLD !== \"bigint\" || feeAmountLD < -(1n << 255n) || feeAmountLD >= (1n << 255n)) throw new RangeError(\"stargate: fee must be int256 bigint\");\n if (feeAmountLD < 0n) feeLD -= feeAmountLD;\n else rewardLD += feeAmountLD;\n }\n return {feeLD, rewardLD};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAM,cAAc,MAAM,OAAO;AACjC,IAAM,eAAe,MAAM,QAAQ;AAEnC,SAAS,QAAQ,QAAsB;AACrC,MAAI,OAAO,WAAW,YAAY,SAAS,MAAM,SAAS,YAAa,OAAM,IAAI,WAAW,yCAAyC;AACvI;AAGO,SAAS,eAAe,eAAuB,gBAAgC;AACpF,MAAI,CAAC,OAAO,UAAU,aAAa,KAAK,CAAC,OAAO,UAAU,cAAc,KAAK,iBAAiB,KAAK,gBAAgB,kBAAkB,gBAAgB,OAAO,gBAAgB,iBAAiB,IAAI;AAC/L,UAAM,IAAI,WAAW,yCAAyC;AAAA,EAChE;AACA,SAAO,OAAO,OAAO,gBAAgB,cAAc;AACrD;AAGO,SAAS,kBAAkB,UAAkB,eAAuB,gBAA4E;AACrJ,UAAQ,QAAQ;AAChB,QAAM,OAAO,eAAe,eAAe,cAAc;AACzD,QAAM,WAAW,WAAW;AAC5B,MAAI,WAAW,WAAY,OAAM,IAAI,WAAW,wCAAwC;AACxF,SAAO,EAAC,UAAU,QAAQ,WAAW,MAAM,QAAQ,WAAW,KAAI;AACpE;AAGO,SAAS,kBAAkB,kBAA0B,gBAAwB,qBAA6B,gBAAgC;AAC/I,QAAM,EAAC,UAAU,OAAM,IAAI,kBAAkB,kBAAkB,gBAAgB,cAAc;AAC7F,MAAI,WAAW,GAAI,OAAM,IAAI,WAAW,uDAAuD;AAC/F,QAAM,SAAS,WAAW,eAAe,qBAAqB,cAAc;AAC5E,UAAQ,MAAM;AACd,SAAO;AACT;AAGO,SAAS,cAAc,kBAA0B,gBAAwB,qBAA6B,gBAAgC;AAC3I,UAAQ,gBAAgB;AACxB,QAAM,kBAAkB,eAAe,qBAAqB,cAAc;AAC1E,QAAM,aAAa,mBAAmB,kBAAkB,MAAM;AAC9D,MAAI,YAAY,WAAY,OAAM,IAAI,WAAW,gDAAgD;AACjG,QAAM,YAAY,YAAY,eAAe,gBAAgB,cAAc;AAC3E,UAAQ,SAAS;AACjB,SAAO;AACT;AAGO,SAAS,gBAAgB,SAA8E;AAC5G,MAAI,QAAQ,IAAI,WAAW;AAC3B,aAAW,EAAC,YAAW,KAAK,SAAS;AACnC,QAAI,OAAO,gBAAgB,YAAY,cAAc,EAAE,MAAM,SAAS,eAAgB,MAAM,KAAO,OAAM,IAAI,WAAW,qCAAqC;AAC7J,QAAI,cAAc,GAAI,UAAS;AAAA,QAC1B,aAAY;AAAA,EACnB;AACA,SAAO,EAAC,OAAO,SAAQ;AACzB;","names":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Stargate converts through a uint64 shared-decimal amount. */
|
|
2
|
+
declare function conversionRate(localDecimals: number, sharedDecimals: number): bigint;
|
|
3
|
+
/** Source amount that can be represented on the wire; dust is not silently added to the output. */
|
|
4
|
+
declare function splitSourceAmount(amountLD: bigint, localDecimals: number, sharedDecimals: number): {
|
|
5
|
+
amountSD: bigint;
|
|
6
|
+
sentLD: bigint;
|
|
7
|
+
dustLD: bigint;
|
|
8
|
+
};
|
|
9
|
+
/** quoteOFT's received amount uses SOURCE local decimals, not destination decimals. */
|
|
10
|
+
declare function destinationAmount(receivedSourceLD: bigint, sourceDecimals: number, destinationDecimals: number, sharedDecimals: number): bigint;
|
|
11
|
+
/** Round the caller's destination floor UP, then encode it in source local units. */
|
|
12
|
+
declare function sourceMinimum(minDestinationLD: bigint, sourceDecimals: number, destinationDecimals: number, sharedDecimals: number): bigint;
|
|
13
|
+
/** Stargate fee details are negative for charges, positive for rewards. Both use source local units. */
|
|
14
|
+
declare function splitFeeDetails(details: readonly {
|
|
15
|
+
feeAmountLD: bigint;
|
|
16
|
+
}[]): {
|
|
17
|
+
feeLD: bigint;
|
|
18
|
+
rewardLD: bigint;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { conversionRate, destinationAmount, sourceMinimum, splitFeeDetails, splitSourceAmount };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Stargate converts through a uint64 shared-decimal amount. */
|
|
2
|
+
declare function conversionRate(localDecimals: number, sharedDecimals: number): bigint;
|
|
3
|
+
/** Source amount that can be represented on the wire; dust is not silently added to the output. */
|
|
4
|
+
declare function splitSourceAmount(amountLD: bigint, localDecimals: number, sharedDecimals: number): {
|
|
5
|
+
amountSD: bigint;
|
|
6
|
+
sentLD: bigint;
|
|
7
|
+
dustLD: bigint;
|
|
8
|
+
};
|
|
9
|
+
/** quoteOFT's received amount uses SOURCE local decimals, not destination decimals. */
|
|
10
|
+
declare function destinationAmount(receivedSourceLD: bigint, sourceDecimals: number, destinationDecimals: number, sharedDecimals: number): bigint;
|
|
11
|
+
/** Round the caller's destination floor UP, then encode it in source local units. */
|
|
12
|
+
declare function sourceMinimum(minDestinationLD: bigint, sourceDecimals: number, destinationDecimals: number, sharedDecimals: number): bigint;
|
|
13
|
+
/** Stargate fee details are negative for charges, positive for rewards. Both use source local units. */
|
|
14
|
+
declare function splitFeeDetails(details: readonly {
|
|
15
|
+
feeAmountLD: bigint;
|
|
16
|
+
}[]): {
|
|
17
|
+
feeLD: bigint;
|
|
18
|
+
rewardLD: bigint;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { conversionRate, destinationAmount, sourceMinimum, splitFeeDetails, splitSourceAmount };
|
package/dist/amounts.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
conversionRate,
|
|
3
|
+
destinationAmount,
|
|
4
|
+
sourceMinimum,
|
|
5
|
+
splitFeeDetails,
|
|
6
|
+
splitSourceAmount
|
|
7
|
+
} from "./chunk-OUGUX3JK.js";
|
|
8
|
+
export {
|
|
9
|
+
conversionRate,
|
|
10
|
+
destinationAmount,
|
|
11
|
+
sourceMinimum,
|
|
12
|
+
splitFeeDetails,
|
|
13
|
+
splitSourceAmount
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=amounts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Address, Hex, TransactionReceipt } from 'viem';
|
|
2
|
+
import { S as StargateMode } from './quote-r1bA8XbO.cjs';
|
|
3
|
+
import { StargateDeployment } from './registry.cjs';
|
|
4
|
+
|
|
5
|
+
interface StargateIntent {
|
|
6
|
+
source: StargateDeployment;
|
|
7
|
+
destination: StargateDeployment;
|
|
8
|
+
mode: StargateMode;
|
|
9
|
+
sender: Address;
|
|
10
|
+
recipient: Address;
|
|
11
|
+
amount: bigint;
|
|
12
|
+
minimum: bigint;
|
|
13
|
+
nativeDrop: bigint;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface StargateBusPassenger {
|
|
17
|
+
assetId: bigint;
|
|
18
|
+
receiver: Hex;
|
|
19
|
+
amountSD: bigint;
|
|
20
|
+
nativeDrop: boolean;
|
|
21
|
+
bytes: Hex;
|
|
22
|
+
}
|
|
23
|
+
interface StargateBusTicket {
|
|
24
|
+
intent: StargateIntent;
|
|
25
|
+
ticketId: bigint;
|
|
26
|
+
passenger: Hex;
|
|
27
|
+
amount: bigint;
|
|
28
|
+
sourceHash: Hex;
|
|
29
|
+
sourceBlock: bigint;
|
|
30
|
+
}
|
|
31
|
+
interface StargateBusProof extends StargateBusTicket {
|
|
32
|
+
guid: Hex;
|
|
33
|
+
driveHash: Hex;
|
|
34
|
+
nonce: bigint;
|
|
35
|
+
message: Hex;
|
|
36
|
+
seat: number;
|
|
37
|
+
passengers: readonly StargateBusPassenger[];
|
|
38
|
+
nativeDropAmount: bigint;
|
|
39
|
+
totalNativeDrops: bigint;
|
|
40
|
+
}
|
|
41
|
+
declare function decodeBusPassenger(bytes: Hex): StargateBusPassenger;
|
|
42
|
+
/** A uint72 ticket is not a LayerZero GUID, even if it fits a JS number today. */
|
|
43
|
+
declare function stargateBusTicket(i: StargateIntent, receipt: TransactionReceipt): StargateBusTicket;
|
|
44
|
+
/** Authenticate a driven range AND the exact passenger bytes at this ticket's seat. */
|
|
45
|
+
declare function stargateBusProof(ticket: StargateBusTicket, receipt: TransactionReceipt): StargateBusProof;
|
|
46
|
+
/**
|
|
47
|
+
* OFTReceived has no seat index. Match the complete ordered payout/cache sequence
|
|
48
|
+
* for this asset, so two identical passengers cannot claim each other's payment.
|
|
49
|
+
*/
|
|
50
|
+
declare function stargateBusPayout(p: StargateBusProof, receipt: TransactionReceipt): "paid" | "cached" | null;
|
|
51
|
+
/** Native-drop events omit GUID: require one authenticated delivery to this OApp in the receipt. */
|
|
52
|
+
declare function stargateBusNativeDrop(p: StargateBusProof, receipt: TransactionReceipt): boolean;
|
|
53
|
+
declare function busPassengerPrefix(rows: readonly {
|
|
54
|
+
ticketId: bigint;
|
|
55
|
+
passenger: Hex;
|
|
56
|
+
}[], first: bigint, count: number, previousHash: Hex, expectedHash: Hex, ticket: StargateBusTicket): Hex;
|
|
57
|
+
declare function busDriveData(dstEid: number, passengers: Hex): Hex;
|
|
58
|
+
|
|
59
|
+
export { type StargateIntent as S, type StargateBusTicket as a, type StargateBusPassenger as b, type StargateBusProof as c, busDriveData as d, busPassengerPrefix as e, decodeBusPassenger as f, stargateBusPayout as g, stargateBusProof as h, stargateBusTicket as i, stargateBusNativeDrop as s };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Address, Hex, TransactionReceipt } from 'viem';
|
|
2
|
+
import { S as StargateMode } from './quote-t7UJSxbU.js';
|
|
3
|
+
import { StargateDeployment } from './registry.js';
|
|
4
|
+
|
|
5
|
+
interface StargateIntent {
|
|
6
|
+
source: StargateDeployment;
|
|
7
|
+
destination: StargateDeployment;
|
|
8
|
+
mode: StargateMode;
|
|
9
|
+
sender: Address;
|
|
10
|
+
recipient: Address;
|
|
11
|
+
amount: bigint;
|
|
12
|
+
minimum: bigint;
|
|
13
|
+
nativeDrop: bigint;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface StargateBusPassenger {
|
|
17
|
+
assetId: bigint;
|
|
18
|
+
receiver: Hex;
|
|
19
|
+
amountSD: bigint;
|
|
20
|
+
nativeDrop: boolean;
|
|
21
|
+
bytes: Hex;
|
|
22
|
+
}
|
|
23
|
+
interface StargateBusTicket {
|
|
24
|
+
intent: StargateIntent;
|
|
25
|
+
ticketId: bigint;
|
|
26
|
+
passenger: Hex;
|
|
27
|
+
amount: bigint;
|
|
28
|
+
sourceHash: Hex;
|
|
29
|
+
sourceBlock: bigint;
|
|
30
|
+
}
|
|
31
|
+
interface StargateBusProof extends StargateBusTicket {
|
|
32
|
+
guid: Hex;
|
|
33
|
+
driveHash: Hex;
|
|
34
|
+
nonce: bigint;
|
|
35
|
+
message: Hex;
|
|
36
|
+
seat: number;
|
|
37
|
+
passengers: readonly StargateBusPassenger[];
|
|
38
|
+
nativeDropAmount: bigint;
|
|
39
|
+
totalNativeDrops: bigint;
|
|
40
|
+
}
|
|
41
|
+
declare function decodeBusPassenger(bytes: Hex): StargateBusPassenger;
|
|
42
|
+
/** A uint72 ticket is not a LayerZero GUID, even if it fits a JS number today. */
|
|
43
|
+
declare function stargateBusTicket(i: StargateIntent, receipt: TransactionReceipt): StargateBusTicket;
|
|
44
|
+
/** Authenticate a driven range AND the exact passenger bytes at this ticket's seat. */
|
|
45
|
+
declare function stargateBusProof(ticket: StargateBusTicket, receipt: TransactionReceipt): StargateBusProof;
|
|
46
|
+
/**
|
|
47
|
+
* OFTReceived has no seat index. Match the complete ordered payout/cache sequence
|
|
48
|
+
* for this asset, so two identical passengers cannot claim each other's payment.
|
|
49
|
+
*/
|
|
50
|
+
declare function stargateBusPayout(p: StargateBusProof, receipt: TransactionReceipt): "paid" | "cached" | null;
|
|
51
|
+
/** Native-drop events omit GUID: require one authenticated delivery to this OApp in the receipt. */
|
|
52
|
+
declare function stargateBusNativeDrop(p: StargateBusProof, receipt: TransactionReceipt): boolean;
|
|
53
|
+
declare function busPassengerPrefix(rows: readonly {
|
|
54
|
+
ticketId: bigint;
|
|
55
|
+
passenger: Hex;
|
|
56
|
+
}[], first: bigint, count: number, previousHash: Hex, expectedHash: Hex, ticket: StargateBusTicket): Hex;
|
|
57
|
+
declare function busDriveData(dstEid: number, passengers: Hex): Hex;
|
|
58
|
+
|
|
59
|
+
export { type StargateIntent as S, type StargateBusTicket as a, type StargateBusPassenger as b, type StargateBusProof as c, busDriveData as d, busPassengerPrefix as e, decodeBusPassenger as f, stargateBusPayout as g, stargateBusProof as h, stargateBusTicket as i, stargateBusNativeDrop as s };
|
package/dist/bus.cjs
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/bus.ts
|
|
21
|
+
var bus_exports = {};
|
|
22
|
+
__export(bus_exports, {
|
|
23
|
+
busDriveData: () => busDriveData,
|
|
24
|
+
busPassengerPrefix: () => busPassengerPrefix,
|
|
25
|
+
decodeBusPassenger: () => decodeBusPassenger,
|
|
26
|
+
stargateBusNativeDrop: () => stargateBusNativeDrop,
|
|
27
|
+
stargateBusPayout: () => stargateBusPayout,
|
|
28
|
+
stargateBusProof: () => stargateBusProof,
|
|
29
|
+
stargateBusTicket: () => stargateBusTicket
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(bus_exports);
|
|
32
|
+
var import_viem3 = require("viem");
|
|
33
|
+
|
|
34
|
+
// src/abi.ts
|
|
35
|
+
var import_viem = require("viem");
|
|
36
|
+
var EXECUTOR_ABI = (0, import_viem.parseAbi)([
|
|
37
|
+
"struct Origin { uint32 srcEid; bytes32 sender; uint64 nonce; }",
|
|
38
|
+
"struct NativeDropParams { address receiver; uint256 amount; }",
|
|
39
|
+
"function endpoint() view returns (address)",
|
|
40
|
+
"function localEid() view returns (uint32)",
|
|
41
|
+
"event NativeDropApplied(Origin origin, uint32 dstEid, address oapp, NativeDropParams[] params, bool[] success)"
|
|
42
|
+
]);
|
|
43
|
+
var ENDPOINT_ABI = (0, import_viem.parseAbi)([
|
|
44
|
+
"struct Origin { uint32 srcEid; bytes32 sender; uint64 nonce; }",
|
|
45
|
+
"function inboundPayloadHash(address receiver, uint32 srcEid, bytes32 sender, uint64 nonce) view returns (bytes32)",
|
|
46
|
+
"function lzReceive(Origin origin, address receiver, bytes32 guid, bytes message, bytes extraData) payable",
|
|
47
|
+
"event PacketSent(bytes encodedPayload, bytes options, address sendLibrary)",
|
|
48
|
+
"event PacketDelivered(Origin origin, address receiver)"
|
|
49
|
+
]);
|
|
50
|
+
var STARGATE_ABI = (0, import_viem.parseAbi)([
|
|
51
|
+
"struct SendParam { uint32 dstEid; bytes32 to; uint256 amountLD; uint256 minAmountLD; bytes extraOptions; bytes composeMsg; bytes oftCmd; }",
|
|
52
|
+
"struct MessagingFee { uint256 nativeFee; uint256 lzTokenFee; }",
|
|
53
|
+
"struct MessagingReceipt { bytes32 guid; uint64 nonce; MessagingFee fee; }",
|
|
54
|
+
"struct OFTLimit { uint256 minAmountLD; uint256 maxAmountLD; }",
|
|
55
|
+
"struct OFTFeeDetail { int256 feeAmountLD; string description; }",
|
|
56
|
+
"struct OFTReceipt { uint256 amountSentLD; uint256 amountReceivedLD; }",
|
|
57
|
+
"struct Ticket { uint72 ticketId; bytes passengerBytes; }",
|
|
58
|
+
"struct AddressConfig { address feeLib; address planner; address treasurer; address tokenMessaging; address creditMessaging; address lzToken; }",
|
|
59
|
+
"function token() view returns (address)",
|
|
60
|
+
"function sharedDecimals() view returns (uint8)",
|
|
61
|
+
"function approvalRequired() pure returns (bool)",
|
|
62
|
+
"function localEid() view returns (uint32)",
|
|
63
|
+
"function endpoint() view returns (address)",
|
|
64
|
+
"function status() view returns (uint8)",
|
|
65
|
+
"function stargateType() pure returns (uint8)",
|
|
66
|
+
"function paths(uint32 eid) view returns (uint64 credit)",
|
|
67
|
+
"function getAddressConfig() view returns (AddressConfig)",
|
|
68
|
+
"function quoteOFT(SendParam s) view returns (OFTLimit limit, OFTFeeDetail[] oftFeeDetails, OFTReceipt receipt)",
|
|
69
|
+
"function quoteSend(SendParam s, bool payInLzToken) view returns (MessagingFee fee)",
|
|
70
|
+
"function send(SendParam s, MessagingFee fee, address refundAddress) payable returns (MessagingReceipt msgReceipt, OFTReceipt oftReceipt)",
|
|
71
|
+
"function sendToken(SendParam s, MessagingFee fee, address refundAddress) payable returns (MessagingReceipt msgReceipt, OFTReceipt oftReceipt, Ticket ticket)",
|
|
72
|
+
"function unreceivedTokens(bytes32 guid, uint8 index) view returns (bytes32)",
|
|
73
|
+
"function retryReceiveToken(bytes32 guid, uint8 index, uint32 srcEid, address receiver, uint256 amountLD, bytes composeMsg)",
|
|
74
|
+
"event OFTSent(bytes32 indexed guid, uint32 dstEid, address indexed fromAddress, uint256 amountSentLD, uint256 amountReceivedLD)",
|
|
75
|
+
"event OFTReceived(bytes32 indexed guid, uint32 srcEid, address indexed toAddress, uint256 amountReceivedLD)",
|
|
76
|
+
"event UnreceivedTokenCached(bytes32 guid, uint8 index, uint32 srcEid, address receiver, uint256 amountLD, bytes composeMsg)"
|
|
77
|
+
]);
|
|
78
|
+
var TOKEN_MESSAGING_ABI = (0, import_viem.parseAbi)([
|
|
79
|
+
"error Bus_InvalidFare(bool nativeDrop)",
|
|
80
|
+
"struct MessagingFee { uint256 nativeFee; uint256 lzTokenFee; }",
|
|
81
|
+
"struct MessagingReceipt { bytes32 guid; uint64 nonce; MessagingFee fee; }",
|
|
82
|
+
"function assetIds(address stargateImpl) view returns (uint16)",
|
|
83
|
+
"function stargateImpls(uint16 assetId) view returns (address)",
|
|
84
|
+
"function peers(uint32 eid) view returns (bytes32)",
|
|
85
|
+
"function endpoint() view returns (address)",
|
|
86
|
+
"function nativeDropAmounts(uint32 eid) view returns (uint128)",
|
|
87
|
+
"function queueCapacity() view returns (uint16)",
|
|
88
|
+
"function busQueues(uint32 eid) view returns (uint8 maxNumPassengers, uint80 busFare, uint80 busAndNativeDropFare, uint16 qLength, uint72 nextTicketId)",
|
|
89
|
+
"function getPassengerHash(uint32 eid, uint16 index) view returns (bytes32)",
|
|
90
|
+
"function quoteDriveBus(uint32 dstEid, bytes passengers) view returns (MessagingFee fee)",
|
|
91
|
+
"function driveBus(uint32 dstEid, bytes passengers) payable returns (MessagingReceipt receipt)",
|
|
92
|
+
"event BusRode(uint32 dstEid, uint72 ticketId, uint80 fare, bytes passenger)",
|
|
93
|
+
"event BusDriven(uint32 dstEid, uint72 startTicketId, uint8 numPassengers, bytes32 guid)",
|
|
94
|
+
"event NativeDropApplied(address receiver, uint128 amount)",
|
|
95
|
+
"event NativeDropFailed(address receiver, uint128 amount)"
|
|
96
|
+
]);
|
|
97
|
+
|
|
98
|
+
// src/amounts.ts
|
|
99
|
+
var UINT64_MAX = (1n << 64n) - 1n;
|
|
100
|
+
var UINT256_MAX = (1n << 256n) - 1n;
|
|
101
|
+
function uint256(amount) {
|
|
102
|
+
if (typeof amount !== "bigint" || amount < 0n || amount > UINT256_MAX) throw new RangeError("stargate: amount must be uint256 bigint");
|
|
103
|
+
}
|
|
104
|
+
function conversionRate(localDecimals, sharedDecimals) {
|
|
105
|
+
if (!Number.isInteger(localDecimals) || !Number.isInteger(sharedDecimals) || sharedDecimals < 0 || localDecimals < sharedDecimals || localDecimals > 255 || localDecimals - sharedDecimals > 77) {
|
|
106
|
+
throw new RangeError("stargate: invalid local/shared decimals");
|
|
107
|
+
}
|
|
108
|
+
return 10n ** BigInt(localDecimals - sharedDecimals);
|
|
109
|
+
}
|
|
110
|
+
function splitSourceAmount(amountLD, localDecimals, sharedDecimals) {
|
|
111
|
+
uint256(amountLD);
|
|
112
|
+
const rate = conversionRate(localDecimals, sharedDecimals);
|
|
113
|
+
const amountSD = amountLD / rate;
|
|
114
|
+
if (amountSD > UINT64_MAX) throw new RangeError("stargate: shared amount exceeds uint64");
|
|
115
|
+
return { amountSD, sentLD: amountSD * rate, dustLD: amountLD % rate };
|
|
116
|
+
}
|
|
117
|
+
function destinationAmount(receivedSourceLD, sourceDecimals, destinationDecimals, sharedDecimals) {
|
|
118
|
+
const { amountSD, dustLD } = splitSourceAmount(receivedSourceLD, sourceDecimals, sharedDecimals);
|
|
119
|
+
if (dustLD !== 0n) throw new RangeError("stargate: quote receipt is not shared-decimal aligned");
|
|
120
|
+
const amount = amountSD * conversionRate(destinationDecimals, sharedDecimals);
|
|
121
|
+
uint256(amount);
|
|
122
|
+
return amount;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// src/rpc.ts
|
|
126
|
+
var import_viem2 = require("viem");
|
|
127
|
+
var StargateReadError = class extends Error {
|
|
128
|
+
constructor(message) {
|
|
129
|
+
super(`stargate: ${message}`);
|
|
130
|
+
this.name = "StargateReadError";
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
var auxiliaryAbi = (0, import_viem2.parseAbi)(["function decimals() view returns (uint8)", "function eid() view returns (uint32)"]);
|
|
134
|
+
var sameAddress = (a, b) => a.toLowerCase() === b.toLowerCase();
|
|
135
|
+
function assertStargate(condition, message) {
|
|
136
|
+
if (!condition) throw new StargateReadError(message);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// src/bus.ts
|
|
140
|
+
var ZERO_HASH = `0x${"00".repeat(32)}`;
|
|
141
|
+
var byteLength = (hex) => (hex.length - 2) / 2;
|
|
142
|
+
function decodeBusPassenger(bytes) {
|
|
143
|
+
assertStargate(/^0x[0-9a-f]{86}$/i.test(bytes), "invalid Bus passenger bytes");
|
|
144
|
+
const flag = (0, import_viem3.slice)(bytes, 42, 43);
|
|
145
|
+
assertStargate(flag === "0x00" || flag === "0x01", "invalid Bus native-drop flag");
|
|
146
|
+
return { assetId: BigInt((0, import_viem3.slice)(bytes, 0, 2)), receiver: (0, import_viem3.slice)(bytes, 2, 34), amountSD: BigInt((0, import_viem3.slice)(bytes, 34, 42)), nativeDrop: flag === "0x01", bytes };
|
|
147
|
+
}
|
|
148
|
+
function stargateBusTicket(i, receipt) {
|
|
149
|
+
assertStargate(i.mode === "bus" && receipt.status === "success", "not a successful Bus source receipt");
|
|
150
|
+
const sent = (0, import_viem3.parseEventLogs)({ abi: STARGATE_ABI, eventName: "OFTSent", logs: receipt.logs.filter((l) => sameAddress(l.address, i.source.address)), strict: true }).filter((l) => l.args.guid === ZERO_HASH && l.args.dstEid === i.destination.eid && sameAddress(l.args.fromAddress, i.sender));
|
|
151
|
+
assertStargate(sent.length === 1, "missing or ambiguous Bus send");
|
|
152
|
+
const a = sent[0].args;
|
|
153
|
+
assertStargate(a.amountSentLD === splitSourceAmount(i.amount, i.source.localDecimals, i.source.sharedDecimals).sentLD, "Bus source amount mismatch");
|
|
154
|
+
const amount = destinationAmount(a.amountReceivedLD, i.source.localDecimals, i.destination.localDecimals, i.source.sharedDecimals);
|
|
155
|
+
assertStargate(amount >= i.minimum, "Bus output below minimum");
|
|
156
|
+
const passenger = (0, import_viem3.encodePacked)(["uint16", "bytes32", "uint64", "bool"], [i.source.assetId, (0, import_viem3.pad)(i.recipient, { size: 32 }), a.amountReceivedLD / conversionRate(i.source.localDecimals, i.source.sharedDecimals), i.nativeDrop > 0n]);
|
|
157
|
+
const rides = (0, import_viem3.parseEventLogs)({ abi: TOKEN_MESSAGING_ABI, eventName: "BusRode", logs: receipt.logs.filter((l) => sameAddress(l.address, i.source.tokenMessaging)), strict: true }).filter((l) => l.args.dstEid === i.destination.eid && sameAddress(l.args.passenger, passenger));
|
|
158
|
+
assertStargate(rides.length === 1, "missing or ambiguous Bus ticket");
|
|
159
|
+
return { intent: i, ticketId: rides[0].args.ticketId, passenger, amount, sourceHash: receipt.transactionHash, sourceBlock: receipt.blockNumber };
|
|
160
|
+
}
|
|
161
|
+
function stargateBusProof(ticket, receipt) {
|
|
162
|
+
const i = ticket.intent;
|
|
163
|
+
assertStargate(receipt.status === "success" && receipt.blockNumber >= ticket.sourceBlock, "invalid Bus drive receipt");
|
|
164
|
+
const drives = (0, import_viem3.parseEventLogs)({ abi: TOKEN_MESSAGING_ABI, eventName: "BusDriven", logs: receipt.logs.filter((l) => sameAddress(l.address, i.source.tokenMessaging)), strict: true }).filter((l) => l.args.dstEid === i.destination.eid && l.args.startTicketId <= ticket.ticketId && ticket.ticketId < l.args.startTicketId + BigInt(l.args.numPassengers));
|
|
165
|
+
assertStargate(drives.length === 1, "ticket not uniquely covered by BusDriven");
|
|
166
|
+
const drive = drives[0].args;
|
|
167
|
+
assertStargate(drive.guid !== ZERO_HASH, "Bus drive has no GUID");
|
|
168
|
+
const packets = (0, import_viem3.parseEventLogs)({ abi: ENDPOINT_ABI, eventName: "PacketSent", logs: receipt.logs.filter((l) => sameAddress(l.address, i.source.endpoint)), strict: true }).filter((l) => byteLength(l.args.encodedPayload) >= 113 && sameAddress((0, import_viem3.slice)(l.args.encodedPayload, 81, 113), drive.guid));
|
|
169
|
+
assertStargate(packets.length === 1, "missing Bus endpoint packet");
|
|
170
|
+
const packet = packets[0].args.encodedPayload;
|
|
171
|
+
assertStargate((0, import_viem3.slice)(packet, 0, 1) === "0x01" && BigInt((0, import_viem3.slice)(packet, 9, 13)) === BigInt(i.source.eid) && BigInt((0, import_viem3.slice)(packet, 45, 49)) === BigInt(i.destination.eid) && sameAddress((0, import_viem3.slice)(packet, 13, 45), (0, import_viem3.pad)(i.source.tokenMessaging, { size: 32 })) && sameAddress((0, import_viem3.slice)(packet, 49, 81), (0, import_viem3.pad)(i.destination.tokenMessaging, { size: 32 })), "Bus packet pathway mismatch");
|
|
172
|
+
const message = (0, import_viem3.slice)(packet, 113);
|
|
173
|
+
assertStargate(byteLength(message) === 33 + drive.numPassengers * 43 && (0, import_viem3.slice)(message, 0, 1) === "0x02" && drive.numPassengers > 0, "Bus message size/type mismatch");
|
|
174
|
+
const passengers = Array.from({ length: drive.numPassengers }, (_, index) => decodeBusPassenger((0, import_viem3.slice)(message, 33 + index * 43, 33 + (index + 1) * 43)));
|
|
175
|
+
const seat = passengers.findIndex((_, index) => drive.startTicketId + BigInt(index) === ticket.ticketId);
|
|
176
|
+
assertStargate(seat >= 0 && sameAddress(passengers[seat].bytes, ticket.passenger), "ticket passenger differs from driven message");
|
|
177
|
+
const totalNativeDrops = BigInt((0, import_viem3.slice)(message, 1, 17)), nativeDropAmount = BigInt((0, import_viem3.slice)(message, 17, 33));
|
|
178
|
+
assertStargate(totalNativeDrops === BigInt(passengers.filter((p) => p.nativeDrop).length), "Bus native drop count mismatch");
|
|
179
|
+
return { ...ticket, guid: drive.guid, driveHash: receipt.transactionHash, nonce: BigInt((0, import_viem3.slice)(packet, 1, 9)), message, seat, passengers, totalNativeDrops, nativeDropAmount };
|
|
180
|
+
}
|
|
181
|
+
function stargateBusPayout(p, receipt) {
|
|
182
|
+
if (receipt.status !== "success") return null;
|
|
183
|
+
const i = p.intent;
|
|
184
|
+
const events = (0, import_viem3.parseEventLogs)({ abi: STARGATE_ABI, logs: receipt.logs.filter((l) => sameAddress(l.address, i.destination.address)), strict: true }).filter((l) => (l.eventName === "OFTReceived" || l.eventName === "UnreceivedTokenCached") && sameAddress(l.args.guid, p.guid));
|
|
185
|
+
const expected = p.passengers.flatMap((passenger, seat) => passenger.assetId === BigInt(i.source.assetId) ? [{ passenger, seat }] : []);
|
|
186
|
+
if (events.length !== expected.length) return null;
|
|
187
|
+
let result = null;
|
|
188
|
+
for (let index = 0; index < expected.length; index++) {
|
|
189
|
+
const { passenger, seat } = expected[index], event = events[index];
|
|
190
|
+
const amount = passenger.amountSD * conversionRate(i.destination.localDecimals, i.destination.sharedDecimals);
|
|
191
|
+
if (event.eventName === "OFTReceived") {
|
|
192
|
+
if (event.args.srcEid !== i.source.eid || !sameAddress((0, import_viem3.pad)(event.args.toAddress, { size: 32 }), passenger.receiver) || event.args.amountReceivedLD !== amount) return null;
|
|
193
|
+
if (seat === p.seat) result = "paid";
|
|
194
|
+
} else if (event.eventName === "UnreceivedTokenCached") {
|
|
195
|
+
if (event.args.index !== seat || event.args.srcEid !== i.source.eid || !sameAddress((0, import_viem3.pad)(event.args.receiver, { size: 32 }), passenger.receiver) || event.args.amountLD !== amount || event.args.composeMsg !== "0x") return null;
|
|
196
|
+
if (seat === p.seat) result = "cached";
|
|
197
|
+
} else return null;
|
|
198
|
+
}
|
|
199
|
+
return result;
|
|
200
|
+
}
|
|
201
|
+
function stargateBusNativeDrop(p, receipt) {
|
|
202
|
+
if (receipt.status !== "success" || !p.passengers[p.seat]?.nativeDrop || p.nativeDropAmount === 0n) return false;
|
|
203
|
+
const i = p.intent;
|
|
204
|
+
const deliveries = (0, import_viem3.parseEventLogs)({ abi: ENDPOINT_ABI, eventName: "PacketDelivered", logs: receipt.logs.filter((l) => sameAddress(l.address, i.destination.endpoint)), strict: true }).filter((l) => sameAddress(l.args.receiver, i.destination.tokenMessaging));
|
|
205
|
+
if (deliveries.length !== 1) return false;
|
|
206
|
+
const origin = deliveries[0].args.origin;
|
|
207
|
+
if (origin.nonce !== p.nonce || origin.srcEid !== i.source.eid || !sameAddress(origin.sender, (0, import_viem3.pad)(i.source.tokenMessaging, { size: 32 }))) return false;
|
|
208
|
+
const drops = (0, import_viem3.parseEventLogs)({ abi: TOKEN_MESSAGING_ABI, logs: receipt.logs.filter((l) => sameAddress(l.address, i.destination.tokenMessaging)), strict: true }).filter((l) => l.eventName === "NativeDropApplied" || l.eventName === "NativeDropFailed");
|
|
209
|
+
const expected = p.passengers.flatMap((passenger, seat) => passenger.nativeDrop ? [{ passenger, seat }] : []);
|
|
210
|
+
if (drops.length !== expected.length) return false;
|
|
211
|
+
let paid = false;
|
|
212
|
+
for (let index = 0; index < expected.length; index++) {
|
|
213
|
+
const event = drops[index], target = expected[index];
|
|
214
|
+
if (!sameAddress((0, import_viem3.pad)(event.args.receiver, { size: 32 }), target.passenger.receiver) || event.args.amount !== p.nativeDropAmount || event.logIndex >= deliveries[0].logIndex) return false;
|
|
215
|
+
if (target.seat === p.seat) paid = event.eventName === "NativeDropApplied";
|
|
216
|
+
}
|
|
217
|
+
return paid;
|
|
218
|
+
}
|
|
219
|
+
function busPassengerPrefix(rows, first, count, previousHash, expectedHash, ticket) {
|
|
220
|
+
assertStargate(Number.isInteger(count) && count >= 1 && count <= 255 && ticket.ticketId >= first && ticket.ticketId < first + BigInt(count), "drive prefix does not include this ticket");
|
|
221
|
+
const selected = Array.from({ length: count }, (_, index) => {
|
|
222
|
+
const matches = rows.filter((row2) => row2.ticketId === first + BigInt(index));
|
|
223
|
+
assertStargate(matches.length === 1, "missing or duplicate queued passenger");
|
|
224
|
+
const row = matches[0];
|
|
225
|
+
decodeBusPassenger(row.passenger);
|
|
226
|
+
if (row.ticketId === ticket.ticketId) assertStargate(sameAddress(row.passenger, ticket.passenger), "queued passenger differs from source receipt");
|
|
227
|
+
return row.passenger;
|
|
228
|
+
});
|
|
229
|
+
let current = previousHash;
|
|
230
|
+
for (const passenger of selected) current = (0, import_viem3.keccak256)((0, import_viem3.concatHex)([current, passenger]));
|
|
231
|
+
assertStargate(sameAddress(current, expectedHash), "queued passenger hash chain mismatch");
|
|
232
|
+
return (0, import_viem3.concatHex)(selected);
|
|
233
|
+
}
|
|
234
|
+
function busDriveData(dstEid, passengers) {
|
|
235
|
+
return (0, import_viem3.encodeFunctionData)({ abi: TOKEN_MESSAGING_ABI, functionName: "driveBus", args: [dstEid, passengers] });
|
|
236
|
+
}
|
|
237
|
+
//# sourceMappingURL=bus.cjs.map
|
package/dist/bus.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/bus.ts","../src/abi.ts","../src/amounts.ts","../src/rpc.ts"],"sourcesContent":["import {concatHex, encodeFunctionData, encodePacked, keccak256, pad, parseEventLogs, slice, type Hex, type TransactionReceipt} from \"viem\";\nimport {ENDPOINT_ABI, STARGATE_ABI, TOKEN_MESSAGING_ABI} from \"./abi.js\";\nimport {conversionRate, destinationAmount, splitSourceAmount} from \"./amounts.js\";\nimport type {StargateIntent} from \"./intent.js\";\nimport {assertStargate, sameAddress} from \"./rpc.js\";\n\nconst ZERO_HASH = `0x${\"00\".repeat(32)}`;\nconst byteLength = (hex: Hex) => (hex.length - 2) / 2;\nexport interface StargateBusPassenger {assetId: bigint; receiver: Hex; amountSD: bigint; nativeDrop: boolean; bytes: Hex}\nexport interface StargateBusTicket {\n intent: StargateIntent;\n ticketId: bigint;\n passenger: Hex;\n amount: bigint;\n sourceHash: Hex;\n sourceBlock: bigint;\n}\nexport interface StargateBusProof extends StargateBusTicket {\n guid: Hex;\n driveHash: Hex;\n nonce: bigint;\n message: Hex;\n seat: number;\n passengers: readonly StargateBusPassenger[];\n nativeDropAmount: bigint;\n totalNativeDrops: bigint;\n}\n\nexport function decodeBusPassenger(bytes: Hex): StargateBusPassenger {\n assertStargate(/^0x[0-9a-f]{86}$/i.test(bytes), \"invalid Bus passenger bytes\");\n const flag = slice(bytes, 42, 43);\n assertStargate(flag === \"0x00\" || flag === \"0x01\", \"invalid Bus native-drop flag\");\n return {assetId: BigInt(slice(bytes, 0, 2)), receiver: slice(bytes, 2, 34), amountSD: BigInt(slice(bytes, 34, 42)), nativeDrop: flag === \"0x01\", bytes};\n}\n\n/** A uint72 ticket is not a LayerZero GUID, even if it fits a JS number today. */\nexport function stargateBusTicket(i: StargateIntent, receipt: TransactionReceipt): StargateBusTicket {\n assertStargate(i.mode === \"bus\" && receipt.status === \"success\", \"not a successful Bus source receipt\");\n const sent = parseEventLogs({abi: STARGATE_ABI, eventName: \"OFTSent\", logs: receipt.logs.filter((l) => sameAddress(l.address, i.source.address)), strict: true})\n .filter((l) => l.args.guid === ZERO_HASH && l.args.dstEid === i.destination.eid && sameAddress(l.args.fromAddress, i.sender));\n assertStargate(sent.length === 1, \"missing or ambiguous Bus send\");\n const a = sent[0]!.args;\n assertStargate(a.amountSentLD === splitSourceAmount(i.amount, i.source.localDecimals, i.source.sharedDecimals).sentLD, \"Bus source amount mismatch\");\n const amount = destinationAmount(a.amountReceivedLD, i.source.localDecimals, i.destination.localDecimals, i.source.sharedDecimals);\n assertStargate(amount >= i.minimum, \"Bus output below minimum\");\n const passenger = encodePacked([\"uint16\", \"bytes32\", \"uint64\", \"bool\"], [i.source.assetId, pad(i.recipient, {size: 32}), a.amountReceivedLD / conversionRate(i.source.localDecimals, i.source.sharedDecimals), i.nativeDrop > 0n]);\n const rides = parseEventLogs({abi: TOKEN_MESSAGING_ABI, eventName: \"BusRode\", logs: receipt.logs.filter((l) => sameAddress(l.address, i.source.tokenMessaging)), strict: true})\n .filter((l) => l.args.dstEid === i.destination.eid && sameAddress(l.args.passenger, passenger));\n assertStargate(rides.length === 1, \"missing or ambiguous Bus ticket\");\n return {intent: i, ticketId: rides[0]!.args.ticketId, passenger, amount, sourceHash: receipt.transactionHash, sourceBlock: receipt.blockNumber};\n}\n\n/** Authenticate a driven range AND the exact passenger bytes at this ticket's seat. */\nexport function stargateBusProof(ticket: StargateBusTicket, receipt: TransactionReceipt): StargateBusProof {\n const i = ticket.intent;\n assertStargate(receipt.status === \"success\" && receipt.blockNumber >= ticket.sourceBlock, \"invalid Bus drive receipt\");\n const drives = parseEventLogs({abi: TOKEN_MESSAGING_ABI, eventName: \"BusDriven\", logs: receipt.logs.filter((l) => sameAddress(l.address, i.source.tokenMessaging)), strict: true})\n .filter((l) => l.args.dstEid === i.destination.eid && l.args.startTicketId <= ticket.ticketId && ticket.ticketId < l.args.startTicketId + BigInt(l.args.numPassengers));\n assertStargate(drives.length === 1, \"ticket not uniquely covered by BusDriven\");\n const drive = drives[0]!.args;\n assertStargate(drive.guid !== ZERO_HASH, \"Bus drive has no GUID\");\n const packets = parseEventLogs({abi: ENDPOINT_ABI, eventName: \"PacketSent\", logs: receipt.logs.filter((l) => sameAddress(l.address, i.source.endpoint)), strict: true})\n .filter((l) => byteLength(l.args.encodedPayload) >= 113 && sameAddress(slice(l.args.encodedPayload, 81, 113), drive.guid));\n assertStargate(packets.length === 1, \"missing Bus endpoint packet\");\n const packet = packets[0]!.args.encodedPayload;\n assertStargate(slice(packet, 0, 1) === \"0x01\" && BigInt(slice(packet, 9, 13)) === BigInt(i.source.eid) && BigInt(slice(packet, 45, 49)) === BigInt(i.destination.eid) && sameAddress(slice(packet, 13, 45), pad(i.source.tokenMessaging, {size: 32})) && sameAddress(slice(packet, 49, 81), pad(i.destination.tokenMessaging, {size: 32})), \"Bus packet pathway mismatch\");\n const message = slice(packet, 113);\n assertStargate(byteLength(message) === 33 + drive.numPassengers * 43 && slice(message, 0, 1) === \"0x02\" && drive.numPassengers > 0, \"Bus message size/type mismatch\");\n const passengers = Array.from({length: drive.numPassengers}, (_, index) => decodeBusPassenger(slice(message, 33 + index * 43, 33 + (index + 1) * 43)));\n const seat = passengers.findIndex((_, index) => drive.startTicketId + BigInt(index) === ticket.ticketId);\n assertStargate(seat >= 0 && sameAddress(passengers[seat]!.bytes, ticket.passenger), \"ticket passenger differs from driven message\");\n const totalNativeDrops = BigInt(slice(message, 1, 17)), nativeDropAmount = BigInt(slice(message, 17, 33));\n assertStargate(totalNativeDrops === BigInt(passengers.filter((p) => p.nativeDrop).length), \"Bus native drop count mismatch\");\n return {...ticket, guid: drive.guid, driveHash: receipt.transactionHash, nonce: BigInt(slice(packet, 1, 9)), message, seat, passengers, totalNativeDrops, nativeDropAmount};\n}\n\n/**\n * OFTReceived has no seat index. Match the complete ordered payout/cache sequence\n * for this asset, so two identical passengers cannot claim each other's payment.\n */\nexport function stargateBusPayout(p: StargateBusProof, receipt: TransactionReceipt): \"paid\" | \"cached\" | null {\n if (receipt.status !== \"success\") return null;\n const i = p.intent;\n const events = parseEventLogs({abi: STARGATE_ABI, logs: receipt.logs.filter((l) => sameAddress(l.address, i.destination.address)), strict: true})\n .filter((l) => (l.eventName === \"OFTReceived\" || l.eventName === \"UnreceivedTokenCached\") && sameAddress(l.args.guid, p.guid));\n const expected = p.passengers.flatMap((passenger, seat) => passenger.assetId === BigInt(i.source.assetId) ? [{passenger, seat}] : []);\n if (events.length !== expected.length) return null;\n let result: \"paid\" | \"cached\" | null = null;\n for (let index = 0; index < expected.length; index++) {\n const {passenger, seat} = expected[index]!, event = events[index]!;\n const amount = passenger.amountSD * conversionRate(i.destination.localDecimals, i.destination.sharedDecimals);\n if (event.eventName === \"OFTReceived\") {\n if (event.args.srcEid !== i.source.eid || !sameAddress(pad(event.args.toAddress, {size: 32}), passenger.receiver) || event.args.amountReceivedLD !== amount) return null;\n if (seat === p.seat) result = \"paid\";\n } else if (event.eventName === \"UnreceivedTokenCached\") {\n if (event.args.index !== seat || event.args.srcEid !== i.source.eid || !sameAddress(pad(event.args.receiver, {size: 32}), passenger.receiver) || event.args.amountLD !== amount || event.args.composeMsg !== \"0x\") return null;\n if (seat === p.seat) result = \"cached\";\n } else return null;\n }\n return result;\n}\n\n/** Native-drop events omit GUID: require one authenticated delivery to this OApp in the receipt. */\nexport function stargateBusNativeDrop(p: StargateBusProof, receipt: TransactionReceipt): boolean {\n if (receipt.status !== \"success\" || !p.passengers[p.seat]?.nativeDrop || p.nativeDropAmount === 0n) return false;\n const i = p.intent;\n const deliveries = parseEventLogs({abi: ENDPOINT_ABI, eventName: \"PacketDelivered\", logs: receipt.logs.filter((l) => sameAddress(l.address, i.destination.endpoint)), strict: true})\n .filter((l) => sameAddress(l.args.receiver, i.destination.tokenMessaging));\n if (deliveries.length !== 1) return false;\n const origin = deliveries[0]!.args.origin;\n if (origin.nonce !== p.nonce || origin.srcEid !== i.source.eid || !sameAddress(origin.sender, pad(i.source.tokenMessaging, {size: 32}))) return false;\n const drops = parseEventLogs({abi: TOKEN_MESSAGING_ABI, logs: receipt.logs.filter((l) => sameAddress(l.address, i.destination.tokenMessaging)), strict: true})\n .filter((l) => l.eventName === \"NativeDropApplied\" || l.eventName === \"NativeDropFailed\");\n const expected = p.passengers.flatMap((passenger, seat) => passenger.nativeDrop ? [{passenger, seat}] : []);\n if (drops.length !== expected.length) return false;\n let paid = false;\n for (let index = 0; index < expected.length; index++) {\n const event = drops[index]!, target = expected[index]!;\n if (!sameAddress(pad(event.args.receiver, {size: 32}), target.passenger.receiver) || event.args.amount !== p.nativeDropAmount || event.logIndex! >= deliveries[0]!.logIndex!) return false;\n if (target.seat === p.seat) paid = event.eventName === \"NativeDropApplied\";\n }\n return paid;\n}\n\nexport function busPassengerPrefix(rows: readonly {ticketId: bigint; passenger: Hex}[], first: bigint, count: number, previousHash: Hex, expectedHash: Hex, ticket: StargateBusTicket): Hex {\n assertStargate(Number.isInteger(count) && count >= 1 && count <= 255 && ticket.ticketId >= first && ticket.ticketId < first + BigInt(count), \"drive prefix does not include this ticket\");\n const selected = Array.from({length: count}, (_, index) => {\n const matches = rows.filter((row) => row.ticketId === first + BigInt(index));\n assertStargate(matches.length === 1, \"missing or duplicate queued passenger\");\n const row = matches[0]!;\n decodeBusPassenger(row.passenger);\n if (row.ticketId === ticket.ticketId) assertStargate(sameAddress(row.passenger, ticket.passenger), \"queued passenger differs from source receipt\");\n return row.passenger;\n });\n let current = previousHash;\n for (const passenger of selected) current = keccak256(concatHex([current, passenger]));\n assertStargate(sameAddress(current, expectedHash), \"queued passenger hash chain mismatch\");\n return concatHex(selected);\n}\n\nexport function busDriveData(dstEid: number, passengers: Hex): Hex {\n return encodeFunctionData({abi: TOKEN_MESSAGING_ABI, functionName: \"driveBus\", args: [dstEid, passengers]});\n}\n","import {parseAbi} from \"viem\";\n\n// LayerZero-v2 592625b9e5967643853476445ffe0e777360b906: historical Executor/IExecutor.\nexport const EXECUTOR_ABI = parseAbi([\n \"struct Origin { uint32 srcEid; bytes32 sender; uint64 nonce; }\",\n \"struct NativeDropParams { address receiver; uint256 amount; }\",\n \"function endpoint() view returns (address)\",\n \"function localEid() view returns (uint32)\",\n \"event NativeDropApplied(Origin origin, uint32 dstEid, address oapp, NativeDropParams[] params, bool[] success)\",\n]);\n\nexport const ENDPOINT_ABI = parseAbi([\n \"struct Origin { uint32 srcEid; bytes32 sender; uint64 nonce; }\",\n \"function inboundPayloadHash(address receiver, uint32 srcEid, bytes32 sender, uint64 nonce) view returns (bytes32)\",\n \"function lzReceive(Origin origin, address receiver, bytes32 guid, bytes message, bytes extraData) payable\",\n \"event PacketSent(bytes encodedPayload, bytes options, address sendLibrary)\",\n \"event PacketDelivered(Origin origin, address receiver)\",\n]);\n\n// SDK-322: checked against pinned upstream deployment ABI by abi.test.ts.\n// Provenance: tests/fixtures/upstream.json. This is an interface, not a deployment allowlist.\nexport const STARGATE_ABI = parseAbi([\n \"struct SendParam { uint32 dstEid; bytes32 to; uint256 amountLD; uint256 minAmountLD; bytes extraOptions; bytes composeMsg; bytes oftCmd; }\",\n \"struct MessagingFee { uint256 nativeFee; uint256 lzTokenFee; }\",\n \"struct MessagingReceipt { bytes32 guid; uint64 nonce; MessagingFee fee; }\",\n \"struct OFTLimit { uint256 minAmountLD; uint256 maxAmountLD; }\",\n \"struct OFTFeeDetail { int256 feeAmountLD; string description; }\",\n \"struct OFTReceipt { uint256 amountSentLD; uint256 amountReceivedLD; }\",\n \"struct Ticket { uint72 ticketId; bytes passengerBytes; }\",\n \"struct AddressConfig { address feeLib; address planner; address treasurer; address tokenMessaging; address creditMessaging; address lzToken; }\",\n \"function token() view returns (address)\",\n \"function sharedDecimals() view returns (uint8)\",\n \"function approvalRequired() pure returns (bool)\",\n \"function localEid() view returns (uint32)\",\n \"function endpoint() view returns (address)\",\n \"function status() view returns (uint8)\",\n \"function stargateType() pure returns (uint8)\",\n \"function paths(uint32 eid) view returns (uint64 credit)\",\n \"function getAddressConfig() view returns (AddressConfig)\",\n \"function quoteOFT(SendParam s) view returns (OFTLimit limit, OFTFeeDetail[] oftFeeDetails, OFTReceipt receipt)\",\n \"function quoteSend(SendParam s, bool payInLzToken) view returns (MessagingFee fee)\",\n \"function send(SendParam s, MessagingFee fee, address refundAddress) payable returns (MessagingReceipt msgReceipt, OFTReceipt oftReceipt)\",\n \"function sendToken(SendParam s, MessagingFee fee, address refundAddress) payable returns (MessagingReceipt msgReceipt, OFTReceipt oftReceipt, Ticket ticket)\",\n \"function unreceivedTokens(bytes32 guid, uint8 index) view returns (bytes32)\",\n \"function retryReceiveToken(bytes32 guid, uint8 index, uint32 srcEid, address receiver, uint256 amountLD, bytes composeMsg)\",\n \"event OFTSent(bytes32 indexed guid, uint32 dstEid, address indexed fromAddress, uint256 amountSentLD, uint256 amountReceivedLD)\",\n \"event OFTReceived(bytes32 indexed guid, uint32 srcEid, address indexed toAddress, uint256 amountReceivedLD)\",\n \"event UnreceivedTokenCached(bytes32 guid, uint8 index, uint32 srcEid, address receiver, uint256 amountLD, bytes composeMsg)\",\n]);\n\nexport const TOKEN_MESSAGING_ABI = parseAbi([\n \"error Bus_InvalidFare(bool nativeDrop)\",\n \"struct MessagingFee { uint256 nativeFee; uint256 lzTokenFee; }\",\n \"struct MessagingReceipt { bytes32 guid; uint64 nonce; MessagingFee fee; }\",\n \"function assetIds(address stargateImpl) view returns (uint16)\",\n \"function stargateImpls(uint16 assetId) view returns (address)\",\n \"function peers(uint32 eid) view returns (bytes32)\",\n \"function endpoint() view returns (address)\",\n \"function nativeDropAmounts(uint32 eid) view returns (uint128)\",\n \"function queueCapacity() view returns (uint16)\",\n \"function busQueues(uint32 eid) view returns (uint8 maxNumPassengers, uint80 busFare, uint80 busAndNativeDropFare, uint16 qLength, uint72 nextTicketId)\",\n \"function getPassengerHash(uint32 eid, uint16 index) view returns (bytes32)\",\n \"function quoteDriveBus(uint32 dstEid, bytes passengers) view returns (MessagingFee fee)\",\n \"function driveBus(uint32 dstEid, bytes passengers) payable returns (MessagingReceipt receipt)\",\n \"event BusRode(uint32 dstEid, uint72 ticketId, uint80 fare, bytes passenger)\",\n \"event BusDriven(uint32 dstEid, uint72 startTicketId, uint8 numPassengers, bytes32 guid)\",\n \"event NativeDropApplied(address receiver, uint128 amount)\",\n \"event NativeDropFailed(address receiver, uint128 amount)\",\n]);\n","const UINT64_MAX = (1n << 64n) - 1n;\nconst UINT256_MAX = (1n << 256n) - 1n;\n\nfunction uint256(amount: bigint): void {\n if (typeof amount !== \"bigint\" || amount < 0n || amount > UINT256_MAX) throw new RangeError(\"stargate: amount must be uint256 bigint\");\n}\n\n/** Stargate converts through a uint64 shared-decimal amount. */\nexport function conversionRate(localDecimals: number, sharedDecimals: number): bigint {\n if (!Number.isInteger(localDecimals) || !Number.isInteger(sharedDecimals) || sharedDecimals < 0 || localDecimals < sharedDecimals || localDecimals > 255 || localDecimals - sharedDecimals > 77) {\n throw new RangeError(\"stargate: invalid local/shared decimals\");\n }\n return 10n ** BigInt(localDecimals - sharedDecimals);\n}\n\n/** Source amount that can be represented on the wire; dust is not silently added to the output. */\nexport function splitSourceAmount(amountLD: bigint, localDecimals: number, sharedDecimals: number): {amountSD: bigint; sentLD: bigint; dustLD: bigint} {\n uint256(amountLD);\n const rate = conversionRate(localDecimals, sharedDecimals);\n const amountSD = amountLD / rate;\n if (amountSD > UINT64_MAX) throw new RangeError(\"stargate: shared amount exceeds uint64\");\n return {amountSD, sentLD: amountSD * rate, dustLD: amountLD % rate};\n}\n\n/** quoteOFT's received amount uses SOURCE local decimals, not destination decimals. */\nexport function destinationAmount(receivedSourceLD: bigint, sourceDecimals: number, destinationDecimals: number, sharedDecimals: number): bigint {\n const {amountSD, dustLD} = splitSourceAmount(receivedSourceLD, sourceDecimals, sharedDecimals);\n if (dustLD !== 0n) throw new RangeError(\"stargate: quote receipt is not shared-decimal aligned\");\n const amount = amountSD * conversionRate(destinationDecimals, sharedDecimals);\n uint256(amount);\n return amount;\n}\n\n/** Round the caller's destination floor UP, then encode it in source local units. */\nexport function sourceMinimum(minDestinationLD: bigint, sourceDecimals: number, destinationDecimals: number, sharedDecimals: number): bigint {\n uint256(minDestinationLD);\n const destinationRate = conversionRate(destinationDecimals, sharedDecimals);\n const minimumSD = (minDestinationLD + destinationRate - 1n) / destinationRate;\n if (minimumSD > UINT64_MAX) throw new RangeError(\"stargate: minimum exceeds uint64 shared amount\");\n const minimumLD = minimumSD * conversionRate(sourceDecimals, sharedDecimals);\n uint256(minimumLD);\n return minimumLD;\n}\n\n/** Stargate fee details are negative for charges, positive for rewards. Both use source local units. */\nexport function splitFeeDetails(details: readonly {feeAmountLD: bigint}[]): {feeLD: bigint; rewardLD: bigint} {\n let feeLD = 0n, rewardLD = 0n;\n for (const {feeAmountLD} of details) {\n if (typeof feeAmountLD !== \"bigint\" || feeAmountLD < -(1n << 255n) || feeAmountLD >= (1n << 255n)) throw new RangeError(\"stargate: fee must be int256 bigint\");\n if (feeAmountLD < 0n) feeLD -= feeAmountLD;\n else rewardLD += feeAmountLD;\n }\n return {feeLD, rewardLD};\n}\n","import {createPublicClient, fallback, http, pad, parseAbi, type Address, type Hex, type PublicClient} from \"viem\";\nimport {STARGATE_ABI, TOKEN_MESSAGING_ABI} from \"./abi.js\";\nimport type {StargateDeployment} from \"./registry.js\";\n\nexport class StargateReadError extends Error {\n constructor(message: string) { super(`stargate: ${message}`); this.name = \"StargateReadError\"; }\n}\n\nexport interface StargateRpcConfig {\n /** Both source and destination RPCs are required. URLs are never included in errors. */\n rpcUrls: Readonly<Record<string, string | readonly string[]>>;\n fetchImpl?: typeof fetch;\n}\nexport interface StargateBlock {readonly number: bigint; readonly hash: Hex; readonly timestamp: bigint}\nexport interface StargateRpc {\n has(chain: string): boolean;\n client(chain: string, signal?: AbortSignal): PublicClient;\n snapshot(client: PublicClient, chainId: number): Promise<StargateBlock>;\n verify(client: PublicClient, deployment: StargateDeployment, peer: StargateDeployment, block: StargateBlock): Promise<void>;\n unchanged(client: PublicClient, block: StargateBlock): Promise<void>;\n}\nconst auxiliaryAbi = parseAbi([\"function decimals() view returns (uint8)\", \"function eid() view returns (uint32)\"]);\nexport const sameAddress = (a: string, b: string): boolean => a.toLowerCase() === b.toLowerCase();\nexport function assertStargate(condition: unknown, message: string): asserts condition {\n if (!condition) throw new StargateReadError(message);\n}\nexport function assertNotAborted(signal?: AbortSignal): void {\n if (signal?.aborted) throw new StargateReadError(\"request cancelled\");\n}\n\n/** No mutable deployment/peer/paused-state cache: every quote verifies a fresh snapshot. */\nexport function stargateRpc(config: StargateRpcConfig): StargateRpc {\n const urls = new Map(Object.entries(config.rpcUrls).map(([chain, value]) => {\n const list = typeof value === \"string\" ? [value] : [...value];\n assertStargate(list.length && list.every((url) => /^https?:\\/\\//.test(url)), \"invalid RPC configuration\");\n return [chain, list] as const;\n }));\n function client(chain: string, signal?: AbortSignal): PublicClient {\n const list = urls.get(chain);\n assertStargate(list, `no RPC configured for ${chain}`);\n assertNotAborted(signal);\n const transport = (url: string) => http(url, {timeout: 12_000, retryCount: 0, ...(config.fetchImpl ? {fetchFn: config.fetchImpl} : {}), ...(signal ? {fetchOptions: {signal}} : {})});\n return createPublicClient({transport: list.length === 1 ? transport(list[0]!) : fallback(list.map(transport), {retryCount: 0}), ccipRead: false});\n }\n type Client = ReturnType<typeof client>;\n async function snapshot(c: Client, chainId: number): Promise<StargateBlock> {\n const [actual, block] = await Promise.all([c.getChainId(), c.getBlock({blockTag: \"latest\"})]);\n assertStargate(actual === chainId, \"RPC chain id mismatch\");\n assertStargate(block.hash && block.number !== null, \"RPC returned an unmined block\");\n // Stale nodes must not turn old fees/credits into a new, apparently fresh quote.\n const now = BigInt(Math.floor(Date.now() / 1000));\n assertStargate(block.timestamp >= now - 300n && block.timestamp <= now + 60n, \"RPC block is stale or in the future\");\n return Object.freeze({number: block.number, hash: block.hash, timestamp: block.timestamp});\n }\n async function verify(c: Client, d: StargateDeployment, peer: StargateDeployment, block: StargateBlock): Promise<void> {\n const at = {blockNumber: block.number};\n const pool = {address: d.address, abi: STARGATE_ABI, ...at};\n const messaging = {address: d.tokenMessaging, abi: TOKEN_MESSAGING_ABI, ...at};\n const [token, shared, approval, eid, endpoint, status, kind, roles, assetId, implementation, messagingEndpoint, remotePeer, endpointEid, decimals] = await Promise.all([\n c.readContract({...pool, functionName: \"token\"}),\n c.readContract({...pool, functionName: \"sharedDecimals\"}),\n c.readContract({...pool, functionName: \"approvalRequired\"}),\n c.readContract({...pool, functionName: \"localEid\"}),\n c.readContract({...pool, functionName: \"endpoint\"}),\n c.readContract({...pool, functionName: \"status\"}),\n c.readContract({...pool, functionName: \"stargateType\"}),\n c.readContract({...pool, functionName: \"getAddressConfig\"}),\n c.readContract({...messaging, functionName: \"assetIds\", args: [d.address]}),\n c.readContract({...messaging, functionName: \"stargateImpls\", args: [d.assetId]}),\n c.readContract({...messaging, functionName: \"endpoint\"}),\n c.readContract({...messaging, functionName: \"peers\", args: [peer.eid]}),\n c.readContract({address: d.endpoint, abi: auxiliaryAbi, functionName: \"eid\", ...at}),\n d.kind === \"native\" ? Promise.resolve(d.localDecimals) : c.readContract({address: d.token, abi: auxiliaryAbi, functionName: \"decimals\", ...at}),\n ]);\n assertStargate(sameAddress(token, d.token) && shared === d.sharedDecimals && decimals === d.localDecimals && approval === d.approvalRequired && eid === d.eid && endpointEid === d.eid && sameAddress(endpoint, d.endpoint) && sameAddress(messagingEndpoint, d.endpoint) && sameAddress(roles.tokenMessaging, d.tokenMessaging) && assetId === d.assetId && sameAddress(implementation, d.address) && kind === (d.kind === \"oft\" ? 1 : 0), `deployment identity changed on ${d.chain}`);\n assertStargate(status === 1, `deployment is not active on ${d.chain}`);\n assertStargate(sameAddress(remotePeer, pad(peer.tokenMessaging, {size: 32})), `messaging peer mismatch on ${d.chain}`);\n }\n async function unchanged(c: Client, block: StargateBlock): Promise<void> {\n assertStargate((await c.getBlock({blockNumber: block.number})).hash === block.hash, \"block changed during quote\");\n }\n return {has: (chain: string) => urls.has(chain), client, snapshot, verify, unchanged};\n}\n\n/** Never propagate viem errors: they can contain credential-bearing URLs and request bodies. */\nexport function safeReadError(error: unknown): StargateReadError {\n return error instanceof StargateReadError ? error : new StargateReadError(\"RPC read, quote or decoding failed\");\n}\n\nexport function nonzeroAddress(value: string): value is Address {\n return /^0x[0-9a-fA-F]{40}$/.test(value) && !/^0x0{40}$/.test(value);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,eAAoI;;;ACApI,kBAAuB;AAGhB,IAAM,mBAAe,sBAAS;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAEM,IAAM,mBAAe,sBAAS;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAIM,IAAM,mBAAe,sBAAS;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;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K,SAAS,KAAK,SAAS,OAAO,OAAO,YAAY,SAAS,OAAO,WAAW,QAAQ,OAAO,KAAK,GAAG,2CAA2C;AACxL,QAAM,WAAW,MAAM,KAAK,EAAC,QAAQ,MAAK,GAAG,CAAC,GAAG,UAAU;AACzD,UAAM,UAAU,KAAK,OAAO,CAACC,SAAQA,KAAI,aAAa,QAAQ,OAAO,KAAK,CAAC;AAC3E,mBAAe,QAAQ,WAAW,GAAG,uCAAuC;AAC5E,UAAM,MAAM,QAAQ,CAAC;AACrB,uBAAmB,IAAI,SAAS;AAChC,QAAI,IAAI,aAAa,OAAO,SAAU,gBAAe,YAAY,IAAI,WAAW,OAAO,SAAS,GAAG,8CAA8C;AACjJ,WAAO,IAAI;AAAA,EACb,CAAC;AACD,MAAI,UAAU;AACd,aAAW,aAAa,SAAU,eAAU,4BAAU,wBAAU,CAAC,SAAS,SAAS,CAAC,CAAC;AACrF,iBAAe,YAAY,SAAS,YAAY,GAAG,sCAAsC;AACzF,aAAO,wBAAU,QAAQ;AAC3B;AAEO,SAAS,aAAa,QAAgB,YAAsB;AACjE,aAAO,iCAAmB,EAAC,KAAK,qBAAqB,cAAc,YAAY,MAAM,CAAC,QAAQ,UAAU,EAAC,CAAC;AAC5G;","names":["import_viem","import_viem","row"]}
|
package/dist/bus.d.cts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import 'viem';
|
|
2
|
+
export { b as StargateBusPassenger, c as StargateBusProof, a as StargateBusTicket, d as busDriveData, e as busPassengerPrefix, f as decodeBusPassenger, s as stargateBusNativeDrop, g as stargateBusPayout, h as stargateBusProof, i as stargateBusTicket } from './bus-Cdw8iwOv.cjs';
|
|
3
|
+
import './quote-r1bA8XbO.cjs';
|
|
4
|
+
import './registry.cjs';
|
package/dist/bus.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import 'viem';
|
|
2
|
+
export { b as StargateBusPassenger, c as StargateBusProof, a as StargateBusTicket, d as busDriveData, e as busPassengerPrefix, f as decodeBusPassenger, s as stargateBusNativeDrop, g as stargateBusPayout, h as stargateBusProof, i as stargateBusTicket } from './bus-vAWqTAkq.js';
|
|
3
|
+
import './quote-t7UJSxbU.js';
|
|
4
|
+
import './registry.js';
|