@across-protocol/contracts 3.0.17 → 3.0.19
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/README.md +2 -0
- package/artifacts/build-info/9cb910e5bb5dd730cd01af84a0fb0466.json +1 -0
- package/artifacts/contracts/Ink_SpokePool.sol/Ink_SpokePool.dbg.json +4 -0
- package/artifacts/contracts/Ink_SpokePool.sol/Ink_SpokePool.json +2316 -0
- package/contracts/Ink_SpokePool.sol +72 -0
- package/dist/deploy/consts.js +8 -2
- package/dist/deployments/deployments.json +7 -1
- package/dist/hardhat.config.js +17 -0
- package/dist/scripts/svm/addressToPublicKey.d.ts +1 -0
- package/dist/scripts/svm/addressToPublicKey.js +20 -0
- package/dist/scripts/svm/bridgeLiabilityToHubPool.d.ts +25 -0
- package/dist/scripts/svm/bridgeLiabilityToHubPool.js +221 -0
- package/dist/scripts/svm/closeRelayerPdas.js +8 -9
- package/dist/scripts/svm/enableRoute.js +7 -1
- package/dist/scripts/svm/executeRebalanceToHubPool.d.ts +29 -0
- package/dist/scripts/svm/executeRebalanceToHubPool.js +345 -0
- package/dist/scripts/svm/executeRebalanceToSpokePool.d.ts +1 -0
- package/dist/scripts/svm/executeRebalanceToSpokePool.js +240 -0
- package/dist/scripts/svm/fakeFillWithRandomDistribution.js +6 -7
- package/dist/scripts/svm/initialize.js +2 -2
- package/dist/scripts/svm/proposeRebalanceToHubPool.d.ts +27 -0
- package/dist/scripts/svm/proposeRebalanceToHubPool.js +117 -0
- package/dist/scripts/svm/proposeRebalanceToSpokePool.d.ts +1 -0
- package/dist/scripts/svm/proposeRebalanceToSpokePool.js +97 -0
- package/dist/scripts/svm/publicKeyToAddress.d.ts +1 -0
- package/dist/scripts/svm/publicKeyToAddress.js +20 -0
- package/dist/scripts/svm/queryDeposits.js +3 -2
- package/dist/scripts/svm/queryFills.js +12 -14
- package/dist/scripts/svm/queryRoute.js +7 -1
- package/dist/scripts/svm/queryState.js +1 -0
- package/dist/scripts/svm/remoteHubPoolPauseDeposits.d.ts +1 -0
- package/dist/scripts/svm/remoteHubPoolPauseDeposits.js +191 -0
- package/dist/scripts/svm/remoteHubPoolSetDepositRoute.js +16 -29
- package/dist/scripts/svm/remotePauseDeposits.js +21 -27
- package/dist/scripts/svm/simpleDeposit.js +7 -1
- package/dist/scripts/svm/simpleFakeRelayerRepayment.js +3 -3
- package/dist/scripts/svm/simpleFill.js +6 -6
- package/dist/scripts/svm/utils/constants.d.ts +4 -0
- package/dist/scripts/svm/utils/constants.js +8 -1
- package/dist/scripts/svm/utils/helpers.d.ts +33 -0
- package/dist/scripts/svm/utils/helpers.js +60 -1
- package/dist/scripts/svm/utils/poolRebalanceTree.d.ts +22 -0
- package/dist/scripts/svm/utils/poolRebalanceTree.js +20 -0
- package/dist/src/svm/coders.d.ts +37 -0
- package/dist/src/svm/coders.js +250 -0
- package/dist/src/svm/conversionUtils.d.ts +22 -0
- package/dist/src/svm/conversionUtils.js +73 -0
- package/dist/src/svm/index.d.ts +6 -0
- package/dist/src/svm/index.js +22 -0
- package/dist/src/svm/instructionParamsUtils.d.ts +31 -0
- package/dist/src/svm/instructionParamsUtils.js +128 -0
- package/dist/src/svm/relayHashUtils.d.ts +30 -0
- package/dist/src/svm/relayHashUtils.js +209 -0
- package/dist/src/svm/solanaProgramUtils.d.ts +38 -0
- package/dist/src/svm/solanaProgramUtils.js +147 -0
- package/dist/src/svm/transactionUtils.d.ts +8 -0
- package/dist/src/svm/transactionUtils.js +55 -0
- package/dist/src/types/svm.d.ts +118 -0
- package/dist/src/types/svm.js +2 -0
- package/dist/target/types/svm_spoke.d.ts +47 -42
- package/dist/tasks/enableL1TokenAcrossEcosystem.js +3 -33
- package/dist/tasks/types.d.ts +2 -0
- package/dist/tasks/types.js +2 -0
- package/dist/tasks/utils.d.ts +12 -0
- package/dist/tasks/utils.js +34 -0
- package/dist/test/svm/MulticallHandler.js +2 -2
- package/dist/test/svm/SvmSpoke.Bundle.js +59 -60
- package/dist/test/svm/SvmSpoke.Deposit.js +23 -31
- package/dist/test/svm/SvmSpoke.Fill.AcrossPlus.js +16 -18
- package/dist/test/svm/SvmSpoke.Fill.js +38 -40
- package/dist/test/svm/SvmSpoke.HandleReceiveMessage.js +2 -2
- package/dist/test/svm/SvmSpoke.Ownership.js +11 -17
- package/dist/test/svm/SvmSpoke.RefundClaims.js +12 -11
- package/dist/test/svm/SvmSpoke.Routes.js +11 -7
- package/dist/test/svm/SvmSpoke.SlowFill.AcrossPlus.js +72 -16
- package/dist/test/svm/SvmSpoke.SlowFill.js +33 -28
- package/dist/test/svm/SvmSpoke.TokenBridge.js +15 -17
- package/dist/test/svm/SvmSpoke.common.d.ts +1 -49
- package/dist/test/svm/SvmSpoke.common.js +6 -5
- package/dist/test/svm/cctpHelpers.js +2 -2
- package/dist/test/svm/utils.d.ts +5 -67
- package/dist/test/svm/utils.js +10 -220
- package/dist/typechain/contracts/Ink_SpokePool.d.ts +1251 -0
- package/dist/typechain/contracts/Ink_SpokePool.js +2 -0
- package/dist/typechain/contracts/index.d.ts +1 -0
- package/dist/typechain/factories/contracts/Ink_SpokePool__factory.d.ts +1833 -0
- package/dist/typechain/factories/contracts/Ink_SpokePool__factory.js +2347 -0
- package/dist/typechain/factories/contracts/index.d.ts +1 -0
- package/dist/typechain/factories/contracts/index.js +3 -1
- package/dist/typechain/hardhat.d.ts +9 -0
- package/dist/typechain/index.d.ts +2 -0
- package/dist/typechain/index.js +5 -3
- package/package.json +2 -2
- package/dist/src/SvmUtils.d.ts +0 -50
- package/dist/src/SvmUtils.js +0 -415
|
@@ -27,6 +27,7 @@ export { Base_SpokePool__factory } from "./Base_SpokePool__factory";
|
|
|
27
27
|
export { Boba_SpokePool__factory } from "./Boba_SpokePool__factory";
|
|
28
28
|
export { Ethereum_SpokePool__factory } from "./Ethereum_SpokePool__factory";
|
|
29
29
|
export { HubPool__factory } from "./HubPool__factory";
|
|
30
|
+
export { Ink_SpokePool__factory } from "./Ink_SpokePool__factory";
|
|
30
31
|
export { Linea_SpokePool__factory } from "./Linea_SpokePool__factory";
|
|
31
32
|
export { Lisk_SpokePool__factory } from "./Lisk_SpokePool__factory";
|
|
32
33
|
export { Lockable__factory } from "./Lockable__factory";
|
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.Zora_SpokePool__factory = exports.WorldChain_SpokePool__factory = exports.Succinct_SpokePool__factory = exports.SpokePoolVerifier__factory = exports.SpokePoolV3Periphery__factory = exports.SpokePool__factory = exports.Redstone_SpokePool__factory = exports.PermissionSplitterProxy__factory = exports.Mode_SpokePool__factory = exports.LpTokenFactory__factory = exports.Lockable__factory = exports.Lisk_SpokePool__factory = exports.Linea_SpokePool__factory = exports.HubPool__factory = exports.Ethereum_SpokePool__factory = exports.Boba_SpokePool__factory = exports.Base_SpokePool__factory = exports.Arbitrum_SpokePool__factory = exports.AlephZero_SpokePool__factory = exports.AcrossConfigStore__factory = exports.upgradeable = exports.test = exports.permit2Order = exports.merkleDistributor = exports.libraries = exports.interfaces = exports.handlers = exports.external = exports.erc7683 = exports.erc1155 = exports.chainAdapters = exports.zkSyncSpokePoolSol = exports.swapAndBridgeSol = exports.scrollSpokePoolSol = exports.polygonSpokePoolSol = exports.polygonZkEvmSpokePoolSol = exports.polygonTokenBridgerSol = exports.ovmSpokePoolSol = exports.optimismSpokePoolSol = exports.bondTokenSol = exports.blastSpokePoolSol = exports.blastDaiRetrieverSol = void 0;
|
|
26
|
+
exports.Zora_SpokePool__factory = exports.WorldChain_SpokePool__factory = exports.Succinct_SpokePool__factory = exports.SpokePoolVerifier__factory = exports.SpokePoolV3Periphery__factory = exports.SpokePool__factory = exports.Redstone_SpokePool__factory = exports.PermissionSplitterProxy__factory = exports.Mode_SpokePool__factory = exports.LpTokenFactory__factory = exports.Lockable__factory = exports.Lisk_SpokePool__factory = exports.Linea_SpokePool__factory = exports.Ink_SpokePool__factory = exports.HubPool__factory = exports.Ethereum_SpokePool__factory = exports.Boba_SpokePool__factory = exports.Base_SpokePool__factory = exports.Arbitrum_SpokePool__factory = exports.AlephZero_SpokePool__factory = exports.AcrossConfigStore__factory = exports.upgradeable = exports.test = exports.permit2Order = exports.merkleDistributor = exports.libraries = exports.interfaces = exports.handlers = exports.external = exports.erc7683 = exports.erc1155 = exports.chainAdapters = exports.zkSyncSpokePoolSol = exports.swapAndBridgeSol = exports.scrollSpokePoolSol = exports.polygonSpokePoolSol = exports.polygonZkEvmSpokePoolSol = exports.polygonTokenBridgerSol = exports.ovmSpokePoolSol = exports.optimismSpokePoolSol = exports.bondTokenSol = exports.blastSpokePoolSol = exports.blastDaiRetrieverSol = void 0;
|
|
27
27
|
/* Autogenerated file. Do not edit manually. */
|
|
28
28
|
/* tslint:disable */
|
|
29
29
|
/* eslint-disable */
|
|
@@ -63,6 +63,8 @@ var Ethereum_SpokePool__factory_1 = require("./Ethereum_SpokePool__factory");
|
|
|
63
63
|
Object.defineProperty(exports, "Ethereum_SpokePool__factory", { enumerable: true, get: function () { return Ethereum_SpokePool__factory_1.Ethereum_SpokePool__factory; } });
|
|
64
64
|
var HubPool__factory_1 = require("./HubPool__factory");
|
|
65
65
|
Object.defineProperty(exports, "HubPool__factory", { enumerable: true, get: function () { return HubPool__factory_1.HubPool__factory; } });
|
|
66
|
+
var Ink_SpokePool__factory_1 = require("./Ink_SpokePool__factory");
|
|
67
|
+
Object.defineProperty(exports, "Ink_SpokePool__factory", { enumerable: true, get: function () { return Ink_SpokePool__factory_1.Ink_SpokePool__factory; } });
|
|
66
68
|
var Linea_SpokePool__factory_1 = require("./Linea_SpokePool__factory");
|
|
67
69
|
Object.defineProperty(exports, "Linea_SpokePool__factory", { enumerable: true, get: function () { return Linea_SpokePool__factory_1.Linea_SpokePool__factory; } });
|
|
68
70
|
var Lisk_SpokePool__factory_1 = require("./Lisk_SpokePool__factory");
|
|
@@ -604,6 +604,10 @@ declare module "hardhat/types/runtime" {
|
|
|
604
604
|
name: "HubPool",
|
|
605
605
|
signerOrOptions?: ethers.Signer | FactoryOptions
|
|
606
606
|
): Promise<Contracts.HubPool__factory>;
|
|
607
|
+
getContractFactory(
|
|
608
|
+
name: "Ink_SpokePool",
|
|
609
|
+
signerOrOptions?: ethers.Signer | FactoryOptions
|
|
610
|
+
): Promise<Contracts.Ink_SpokePool__factory>;
|
|
607
611
|
getContractFactory(
|
|
608
612
|
name: "ArbitrumCustomGasTokenInbox",
|
|
609
613
|
signerOrOptions?: ethers.Signer | FactoryOptions
|
|
@@ -1649,6 +1653,11 @@ declare module "hardhat/types/runtime" {
|
|
|
1649
1653
|
address: string,
|
|
1650
1654
|
signer?: ethers.Signer
|
|
1651
1655
|
): Promise<Contracts.HubPool>;
|
|
1656
|
+
getContractAt(
|
|
1657
|
+
name: "Ink_SpokePool",
|
|
1658
|
+
address: string,
|
|
1659
|
+
signer?: ethers.Signer
|
|
1660
|
+
): Promise<Contracts.Ink_SpokePool>;
|
|
1652
1661
|
getContractAt(
|
|
1653
1662
|
name: "ArbitrumCustomGasTokenInbox",
|
|
1654
1663
|
address: string,
|
|
@@ -301,6 +301,8 @@ export type { MulticallHandler } from "./contracts/handlers/MulticallHandler";
|
|
|
301
301
|
export { MulticallHandler__factory } from "./factories/contracts/handlers/MulticallHandler__factory";
|
|
302
302
|
export type { HubPool } from "./contracts/HubPool";
|
|
303
303
|
export { HubPool__factory } from "./factories/contracts/HubPool__factory";
|
|
304
|
+
export type { Ink_SpokePool } from "./contracts/Ink_SpokePool";
|
|
305
|
+
export { Ink_SpokePool__factory } from "./factories/contracts/Ink_SpokePool__factory";
|
|
304
306
|
export type { ArbitrumCustomGasTokenInbox } from "./contracts/interfaces/ArbitrumBridge.sol/ArbitrumCustomGasTokenInbox";
|
|
305
307
|
export { ArbitrumCustomGasTokenInbox__factory } from "./factories/contracts/interfaces/ArbitrumBridge.sol/ArbitrumCustomGasTokenInbox__factory";
|
|
306
308
|
export type { ArbitrumERC20Bridge } from "./contracts/interfaces/ArbitrumBridge.sol/ArbitrumERC20Bridge";
|
package/dist/typechain/index.js
CHANGED
|
@@ -25,9 +25,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.IScrollMessenger__factory = exports.IL2GatewayRouter__factory = exports.IL2ETHGateway__factory = exports.IL2ERC20Gateway__factory = exports.IL2GasPriceOracle__factory = exports.IL1ScrollMessenger__factory = exports.IL1GatewayRouter__factory = exports.IL1ETHGateway__factory = exports.IL1ERC20Gateway__factory = exports.IERC165__factory = exports.ERC165__factory = exports.IERC20__factory = exports.IERC20Permit__factory = exports.IERC20Metadata__factory = exports.ERC20__factory = exports.IERC1155Receiver__factory = exports.IERC1155__factory = exports.IERC1155MetadataURI__factory = exports.ERC1155__factory = exports.TransparentUpgradeableProxy__factory = exports.ITransparentUpgradeableProxy__factory = exports.ProxyAdmin__factory = exports.Proxy__factory = exports.ERC1967Upgrade__factory = exports.ERC1967Proxy__factory = exports.UpgradeableBeacon__factory = exports.IBeacon__factory = exports.BeaconProxy__factory = exports.IERC1967__factory = exports.IERC1271__factory = exports.IERC1822Proxiable__factory = exports.Ownable__factory = exports.IAccessControl__factory = exports.AccessControl__factory = exports.ICrossDomainMessengerUpgradeable__factory = exports.ContextUpgradeable__factory = exports.IERC20Upgradeable__factory = exports.IERC20PermitUpgradeable__factory = exports.ReentrancyGuardUpgradeable__factory = exports.UUPSUpgradeable__factory = exports.Initializable__factory = exports.ERC1967UpgradeUpgradeable__factory = exports.IBeaconUpgradeable__factory = exports.IERC1967Upgradeable__factory = exports.IERC1822ProxiableUpgradeable__factory = exports.OwnableUpgradeable__factory = exports.ICrossDomainMessenger__factory = exports.IL1StandardBridge__factory = exports.IL1ERC20Bridge__factory = exports.factories = void 0;
|
|
27
27
|
exports.WithdrawalHelperBase__factory = exports.Ovm_WithdrawalHelper__factory = exports.IOvm_SpokePool__factory = exports.Arbitrum_WithdrawalHelper__factory = exports.ForwarderInterface__factory = exports.AdapterInterface__factory = exports.ForwarderBase__factory = exports.Ethereum_RescueAdapter__factory = exports.Ethereum_Adapter__factory = exports.DonationBox__factory = exports.CrossDomainEnabled__factory = exports.Boba_Adapter__factory = exports.Blast_RescueAdapter__factory = exports.Blast_Adapter__factory = exports.Base_Adapter__factory = exports.Arbitrum_SendTokensAdapter__factory = exports.Arbitrum_RescueAdapter__factory = exports.Arbitrum_Forwarder__factory = exports.FunderInterface__factory = exports.Arbitrum_CustomGasToken_Adapter__factory = exports.Arbitrum_Adapter__factory = exports.ExtendedHubPoolInterface__factory = exports.BondToken__factory = exports.Boba_SpokePool__factory = exports.IUSDBL2Bridge__factory = exports.IERC20Rebasing__factory = exports.IBlast__factory = exports.Blast_SpokePool__factory = exports.USDYieldManager__factory = exports.Blast_DaiRetriever__factory = exports.Base_SpokePool__factory = exports.Arbitrum_SpokePool__factory = exports.AlephZero_SpokePool__factory = exports.AcrossConfigStore__factory = exports.SkinnyOptimisticOracleInterface__factory = exports.OptimisticOracleInterface__factory = exports.MerkleDistributorInterface__factory = exports.MerkleDistributor__factory = exports.StoreInterface__factory = exports.IdentifierWhitelistInterface__factory = exports.FinderInterface__factory = exports.OracleInterfaces__factory = exports.OptimisticOracleConstraints__factory = exports.ExpandedIERC20__factory = exports.AddressWhitelistInterface__factory = exports.Timer__factory = exports.Testable__factory = exports.MultiRole__factory = exports.MultiCaller__factory = exports.ExpandedERC20__factory = void 0;
|
|
28
|
-
exports.
|
|
29
|
-
exports.
|
|
30
|
-
exports.Zora_SpokePool__factory = exports.ZkSync_SpokePool__factory = exports.IL2ETH__factory = exports.WorldChain_SpokePool__factory = exports.MultiCallerUpgradeable__factory = exports.EIP712CrossChainUpgradeable__factory = exports.TelepathyBroadcasterMock__factory = exports.RootChainManagerMock__factory = exports.PolygonRegistryMock__factory = exports.PolygonERC20PredicateMock__factory = exports.PolygonERC20Mock__factory = exports.FxStateSenderMock__factory = exports.DepositManagerMock__factory = exports.PolygonERC20Test__factory = exports.MockBridgeHub__factory = exports.MockSpokePoolV2__factory = exports.MockSpokePool__factory = exports.MockOptimism_SpokePool__factory = exports.MockHubPool__factory = exports.MockERC1271__factory = exports.MockCaller__factory = exports.MockBlastUsdYieldManager__factory = void 0;
|
|
28
|
+
exports.ArbitrumERC20Bridge__factory = exports.ArbitrumCustomGasTokenInbox__factory = exports.Ink_SpokePool__factory = exports.HubPool__factory = exports.MulticallHandler__factory = exports.WETH9__factory = exports.Multicall3__factory = exports.WETH9Interface__factory = exports.ITelepathyHandler__factory = exports.ITelepathyBroadcaster__factory = exports.IUSDCBridge__factory = exports.ITokenBridge__factory = exports.IMessageService__factory = exports.IPolygonZkEVMBridge__factory = exports.IPermit2__factory = exports.IOpUSDCBridgeAdapter__factory = exports.IERC20Auth__factory = exports.ITokenMinter__factory = exports.ITokenMessenger__factory = exports.Ethereum_SpokePool__factory = exports.ERC7683OrderDepositorExternal__factory = exports.ERC7683OrderDepositor__factory = exports.IOriginSettler__factory = exports.IDestinationSettler__factory = exports.MintableERC1155__factory = exports.Zora_Adapter__factory = exports.ZkSyncInterface__factory = exports.ZkSync_Adapter__factory = exports.ZkBridgeLike__factory = exports.LimitBypassProxy__factory = exports.ZkStack_CustomGasToken_Adapter__factory = exports.ZkStack_Adapter__factory = exports.Succinct_Adapter__factory = exports.Scroll_Adapter__factory = exports.Router_Adapter__factory = exports.Redstone_Adapter__factory = exports.PolygonZkEVM_Adapter__factory = exports.Polygon_Adapter__factory = exports.IRootChainManager__factory = exports.IFxStateSender__factory = exports.DepositManager__factory = exports.Ovm_Forwarder__factory = exports.SynthetixBridgeToOptimism__factory = exports.Optimism_Adapter__factory = exports.OP_Adapter__factory = exports.Mode_Adapter__factory = exports.Mock_Bridge__factory = exports.Mock_Adapter__factory = exports.Lisk_Adapter__factory = exports.Linea_Adapter__factory = void 0;
|
|
29
|
+
exports.MockBedrockL1StandardBridge__factory = exports.MockBedrockCrossDomainMessenger__factory = exports.MerkleLibTest__factory = exports.L2GatewayRouter__factory = exports.Inbox__factory = exports.ArbitrumMockErc20GatewayRouter__factory = exports.AcrossMessageHandlerMock__factory = exports.UniversalSwapAndBridge__factory = exports.SwapAndBridgeBase__factory = exports.SwapAndBridge__factory = exports.Succinct_SpokePool__factory = exports.SpokePoolVerifier__factory = exports.SpokePoolV3Periphery__factory = exports.SpokePool__factory = exports.Scroll_SpokePool__factory = exports.IL2GatewayRouterExtended__factory = exports.Redstone_SpokePool__factory = exports.PolygonZkEVM_SpokePool__factory = exports.IBridgeMessageReceiver__factory = exports.PolygonTokenBridger__factory = exports.PolygonRegistry__factory = exports.PolygonIERC20Upgradeable__factory = exports.PolygonERC20Predicate__factory = exports.MaticToken__factory = exports.Polygon_SpokePool__factory = exports.IFxMessageProcessor__factory = exports.Permit2OrderLib__factory = exports.Permit2Depositor__factory = exports.PermissionSplitterProxy__factory = exports.Ovm_SpokePool__factory = exports.IL2ERC20Bridge__factory = exports.SynthetixBridgeToBase__factory = exports.Optimism_SpokePool__factory = exports.Mode_SpokePool__factory = exports.AcrossMerkleDistributor__factory = exports.LpTokenFactory__factory = exports.Lockable__factory = exports.Lisk_SpokePool__factory = exports.Linea_SpokePool__factory = exports.CircleDomainIds__factory = exports.CircleCCTPAdapter__factory = exports.BridgeHubInterface__factory = exports.V3SpokePoolInterface__factory = exports.AcrossMessageHandler__factory = exports.SpokePoolInterface__factory = exports.LpTokenFactoryInterface__factory = exports.HubPoolInterface__factory = exports.ArbitrumL2ERC20GatewayLike__factory = exports.ArbitrumL1ERC20GatewayLike__factory = exports.ArbitrumInboxLike__factory = void 0;
|
|
30
|
+
exports.Zora_SpokePool__factory = exports.ZkSync_SpokePool__factory = exports.IL2ETH__factory = exports.WorldChain_SpokePool__factory = exports.MultiCallerUpgradeable__factory = exports.EIP712CrossChainUpgradeable__factory = exports.TelepathyBroadcasterMock__factory = exports.RootChainManagerMock__factory = exports.PolygonRegistryMock__factory = exports.PolygonERC20PredicateMock__factory = exports.PolygonERC20Mock__factory = exports.FxStateSenderMock__factory = exports.DepositManagerMock__factory = exports.PolygonERC20Test__factory = exports.MockBridgeHub__factory = exports.MockSpokePoolV2__factory = exports.MockSpokePool__factory = exports.MockOptimism_SpokePool__factory = exports.MockHubPool__factory = exports.MockERC1271__factory = exports.MockCaller__factory = exports.MockBlastUsdYieldManager__factory = exports.MockBedrockL2StandardBridge__factory = void 0;
|
|
31
31
|
exports.factories = __importStar(require("./factories"));
|
|
32
32
|
var IL1ERC20Bridge__factory_1 = require("./factories/@eth-optimism/contracts/L1/messaging/IL1ERC20Bridge__factory");
|
|
33
33
|
Object.defineProperty(exports, "IL1ERC20Bridge__factory", { enumerable: true, get: function () { return IL1ERC20Bridge__factory_1.IL1ERC20Bridge__factory; } });
|
|
@@ -321,6 +321,8 @@ var MulticallHandler__factory_1 = require("./factories/contracts/handlers/Multic
|
|
|
321
321
|
Object.defineProperty(exports, "MulticallHandler__factory", { enumerable: true, get: function () { return MulticallHandler__factory_1.MulticallHandler__factory; } });
|
|
322
322
|
var HubPool__factory_1 = require("./factories/contracts/HubPool__factory");
|
|
323
323
|
Object.defineProperty(exports, "HubPool__factory", { enumerable: true, get: function () { return HubPool__factory_1.HubPool__factory; } });
|
|
324
|
+
var Ink_SpokePool__factory_1 = require("./factories/contracts/Ink_SpokePool__factory");
|
|
325
|
+
Object.defineProperty(exports, "Ink_SpokePool__factory", { enumerable: true, get: function () { return Ink_SpokePool__factory_1.Ink_SpokePool__factory; } });
|
|
324
326
|
var ArbitrumCustomGasTokenInbox__factory_1 = require("./factories/contracts/interfaces/ArbitrumBridge.sol/ArbitrumCustomGasTokenInbox__factory");
|
|
325
327
|
Object.defineProperty(exports, "ArbitrumCustomGasTokenInbox__factory", { enumerable: true, get: function () { return ArbitrumCustomGasTokenInbox__factory_1.ArbitrumCustomGasTokenInbox__factory; } });
|
|
326
328
|
var ArbitrumERC20Bridge__factory_1 = require("./factories/contracts/interfaces/ArbitrumBridge.sol/ArbitrumERC20Bridge__factory");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@across-protocol/contracts",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.19",
|
|
4
4
|
"author": "UMA Team",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"pre-commit-hook": "sh scripts/preCommitHook.sh"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@across-protocol/constants": "^3.1.
|
|
42
|
+
"@across-protocol/constants": "^3.1.24",
|
|
43
43
|
"@coral-xyz/anchor": "^0.30.1",
|
|
44
44
|
"@defi-wonderland/smock": "^2.3.4",
|
|
45
45
|
"@eth-optimism/contracts": "^0.5.40",
|
package/dist/src/SvmUtils.d.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { Program, BN, BorshAccountsCoder, Idl, web3 } from "@coral-xyz/anchor";
|
|
2
|
-
import { PublicKey, Connection, Finality, SignaturesForAddressOptions, TransactionInstruction, Message, Keypair } from "@solana/web3.js";
|
|
3
|
-
export declare function findProgramAddress(label: string, program: PublicKey, extraSeeds?: string[]): {
|
|
4
|
-
publicKey: web3.PublicKey;
|
|
5
|
-
bump: number;
|
|
6
|
-
};
|
|
7
|
-
export declare function readEvents<IDL extends Idl = Idl>(connection: Connection, txSignature: string, programs: Program<IDL>[], commitment?: Finality): Promise<any[]>;
|
|
8
|
-
export declare function getEvent(events: any[], program: PublicKey, eventName: string): any;
|
|
9
|
-
export declare function readProgramEvents(connection: Connection, program: Program<any>, options?: SignaturesForAddressOptions, finality?: Finality): Promise<any[]>;
|
|
10
|
-
export declare function subscribeToCpiEventsForProgram(connection: Connection, program: Program<any>, callback: (events: any[]) => void): Promise<number>;
|
|
11
|
-
export declare const evmAddressToPublicKey: (address: string) => PublicKey;
|
|
12
|
-
export declare function calculateRelayHashUint8Array(relayData: any, chainId: BN): Uint8Array;
|
|
13
|
-
export declare const readUInt256BE: (buffer: Buffer) => BigInt;
|
|
14
|
-
export declare class LargeAccountsCoder<A extends string = string> extends BorshAccountsCoder<A> {
|
|
15
|
-
private getAccountLayouts;
|
|
16
|
-
encode<T = any>(accountName: A, account: T): Promise<Buffer>;
|
|
17
|
-
}
|
|
18
|
-
export declare class MulticallHandlerCoder {
|
|
19
|
-
readonly compiledMessage: Message;
|
|
20
|
-
private readonly layout;
|
|
21
|
-
constructor(instructions: TransactionInstruction[], payerKey?: PublicKey);
|
|
22
|
-
private static coderArg;
|
|
23
|
-
private static coderTypes;
|
|
24
|
-
get readOnlyLen(): number;
|
|
25
|
-
get compiledKeyMetas(): {
|
|
26
|
-
pubkey: web3.PublicKey;
|
|
27
|
-
isSigner: boolean;
|
|
28
|
-
isWritable: boolean;
|
|
29
|
-
}[];
|
|
30
|
-
encode(): Buffer;
|
|
31
|
-
}
|
|
32
|
-
type AcrossPlusMessage = {
|
|
33
|
-
handler: PublicKey;
|
|
34
|
-
readOnlyLen: number;
|
|
35
|
-
valueAmount: BN;
|
|
36
|
-
accounts: PublicKey[];
|
|
37
|
-
handlerMessage: Buffer;
|
|
38
|
-
};
|
|
39
|
-
export declare class AcrossPlusMessageCoder {
|
|
40
|
-
private acrossPlusMessage;
|
|
41
|
-
constructor(acrossPlusMessage: AcrossPlusMessage);
|
|
42
|
-
private static coderArg;
|
|
43
|
-
private static coderTypes;
|
|
44
|
-
encode(): Buffer;
|
|
45
|
-
}
|
|
46
|
-
export declare function sendTransactionWithLookupTable(connection: Connection, instructions: TransactionInstruction[], sender: Keypair): Promise<{
|
|
47
|
-
txSignature: string;
|
|
48
|
-
lookupTableAddress: PublicKey;
|
|
49
|
-
}>;
|
|
50
|
-
export {};
|
package/dist/src/SvmUtils.js
DELETED
|
@@ -1,415 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.AcrossPlusMessageCoder = exports.MulticallHandlerCoder = exports.LargeAccountsCoder = exports.readUInt256BE = exports.evmAddressToPublicKey = void 0;
|
|
30
|
-
exports.findProgramAddress = findProgramAddress;
|
|
31
|
-
exports.readEvents = readEvents;
|
|
32
|
-
exports.getEvent = getEvent;
|
|
33
|
-
exports.readProgramEvents = readProgramEvents;
|
|
34
|
-
exports.subscribeToCpiEventsForProgram = subscribeToCpiEventsForProgram;
|
|
35
|
-
exports.calculateRelayHashUint8Array = calculateRelayHashUint8Array;
|
|
36
|
-
exports.sendTransactionWithLookupTable = sendTransactionWithLookupTable;
|
|
37
|
-
//TODO: we will need to move this to a better location and integrate it more directly with other utils & files in time.
|
|
38
|
-
// eslint-disable-next-line node/no-extraneous-import
|
|
39
|
-
const borsh = __importStar(require("@coral-xyz/borsh"));
|
|
40
|
-
const bs58_1 = __importDefault(require("bs58"));
|
|
41
|
-
const anchor_1 = require("@coral-xyz/anchor");
|
|
42
|
-
const idl_1 = require("@coral-xyz/anchor/dist/cjs/coder/borsh/idl");
|
|
43
|
-
const ethers_1 = require("ethers");
|
|
44
|
-
const web3_js_1 = require("@solana/web3.js");
|
|
45
|
-
function findProgramAddress(label, program, extraSeeds) {
|
|
46
|
-
const seeds = [Buffer.from(anchor_1.utils.bytes.utf8.encode(label))];
|
|
47
|
-
if (extraSeeds) {
|
|
48
|
-
for (const extraSeed of extraSeeds) {
|
|
49
|
-
if (typeof extraSeed === "string") {
|
|
50
|
-
seeds.push(Buffer.from(anchor_1.utils.bytes.utf8.encode(extraSeed)));
|
|
51
|
-
}
|
|
52
|
-
else if (Array.isArray(extraSeed)) {
|
|
53
|
-
seeds.push(Buffer.from(extraSeed));
|
|
54
|
-
}
|
|
55
|
-
else if (Buffer.isBuffer(extraSeed)) {
|
|
56
|
-
seeds.push(extraSeed);
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
seeds.push(extraSeed.toBuffer());
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
const res = web3_js_1.PublicKey.findProgramAddressSync(seeds, program);
|
|
64
|
-
return { publicKey: res[0], bump: res[1] };
|
|
65
|
-
}
|
|
66
|
-
async function readEvents(connection, txSignature, programs, commitment = "confirmed") {
|
|
67
|
-
const txResult = await connection.getTransaction(txSignature, {
|
|
68
|
-
commitment,
|
|
69
|
-
maxSupportedTransactionVersion: 0,
|
|
70
|
-
});
|
|
71
|
-
let eventAuthorities = new Map();
|
|
72
|
-
for (const program of programs) {
|
|
73
|
-
eventAuthorities.set(program.programId.toString(), findProgramAddress("__event_authority", program.programId).publicKey.toString());
|
|
74
|
-
}
|
|
75
|
-
let events = [];
|
|
76
|
-
// TODO: Add support for version 0 transactions.
|
|
77
|
-
if (!txResult || txResult.transaction.message.version !== "legacy")
|
|
78
|
-
return events;
|
|
79
|
-
for (const ixBlock of txResult.meta?.innerInstructions ?? []) {
|
|
80
|
-
for (const ix of ixBlock.instructions) {
|
|
81
|
-
for (const program of programs) {
|
|
82
|
-
const programStr = program.programId.toString();
|
|
83
|
-
if (ix.accounts.length === 1 &&
|
|
84
|
-
txResult.transaction.message.accountKeys[ix.programIdIndex].toString() === programStr &&
|
|
85
|
-
txResult.transaction.message.accountKeys[ix.accounts[0]].toString() ===
|
|
86
|
-
eventAuthorities.get(programStr)) {
|
|
87
|
-
const ixData = anchor_1.utils.bytes.bs58.decode(ix.data);
|
|
88
|
-
const eventData = anchor_1.utils.bytes.base64.encode(Buffer.from(new Uint8Array(ixData).slice(8)));
|
|
89
|
-
const event = program.coder.events.decode(eventData);
|
|
90
|
-
events.push({
|
|
91
|
-
program: program.programId,
|
|
92
|
-
data: event?.data,
|
|
93
|
-
name: event?.name,
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return events;
|
|
100
|
-
}
|
|
101
|
-
function getEvent(events, program, eventName) {
|
|
102
|
-
for (const event of events) {
|
|
103
|
-
if (event.name === eventName && program.toString() === event.program.toString()) {
|
|
104
|
-
return event.data;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
throw new Error("Event " + eventName + " not found");
|
|
108
|
-
}
|
|
109
|
-
async function readProgramEvents(connection, program, options, finality = "confirmed") {
|
|
110
|
-
let events = [];
|
|
111
|
-
const pastSignatures = await connection.getSignaturesForAddress(program.programId, options, finality);
|
|
112
|
-
for (const signature of pastSignatures) {
|
|
113
|
-
events.push(...(await readEvents(connection, signature.signature, [program], finality)));
|
|
114
|
-
}
|
|
115
|
-
return events;
|
|
116
|
-
}
|
|
117
|
-
async function subscribeToCpiEventsForProgram(connection, program, callback) {
|
|
118
|
-
const subscriptionId = connection.onLogs(new web3_js_1.PublicKey(findProgramAddress("__event_authority", program.programId).publicKey.toString()), async (logs) => {
|
|
119
|
-
callback(await readEvents(connection, logs.signature, [program], "confirmed"));
|
|
120
|
-
}, "confirmed");
|
|
121
|
-
return subscriptionId;
|
|
122
|
-
}
|
|
123
|
-
const evmAddressToPublicKey = (address) => {
|
|
124
|
-
const bytes32Address = `0x000000000000000000000000${address.replace("0x", "")}`;
|
|
125
|
-
return new web3_js_1.PublicKey(ethers_1.ethers.utils.arrayify(bytes32Address));
|
|
126
|
-
};
|
|
127
|
-
exports.evmAddressToPublicKey = evmAddressToPublicKey;
|
|
128
|
-
// TODO: we are inconsistant with where we are placing some utils. we have some stuff here, some stuff that we might
|
|
129
|
-
// want to re-use within the test directory. more over, when moving things into the canonical across repo, we should
|
|
130
|
-
// re-use the test utils there.
|
|
131
|
-
function calculateRelayHashUint8Array(relayData, chainId) {
|
|
132
|
-
const messageBuffer = Buffer.alloc(4);
|
|
133
|
-
messageBuffer.writeUInt32LE(relayData.message.length, 0);
|
|
134
|
-
const contentToHash = Buffer.concat([
|
|
135
|
-
relayData.depositor.toBuffer(),
|
|
136
|
-
relayData.recipient.toBuffer(),
|
|
137
|
-
relayData.exclusiveRelayer.toBuffer(),
|
|
138
|
-
relayData.inputToken.toBuffer(),
|
|
139
|
-
relayData.outputToken.toBuffer(),
|
|
140
|
-
relayData.inputAmount.toArrayLike(Buffer, "le", 8),
|
|
141
|
-
relayData.outputAmount.toArrayLike(Buffer, "le", 8),
|
|
142
|
-
relayData.originChainId.toArrayLike(Buffer, "le", 8),
|
|
143
|
-
Buffer.from(relayData.depositId),
|
|
144
|
-
new anchor_1.BN(relayData.fillDeadline).toArrayLike(Buffer, "le", 4),
|
|
145
|
-
new anchor_1.BN(relayData.exclusivityDeadline).toArrayLike(Buffer, "le", 4),
|
|
146
|
-
messageBuffer,
|
|
147
|
-
relayData.message,
|
|
148
|
-
chainId.toArrayLike(Buffer, "le", 8),
|
|
149
|
-
]);
|
|
150
|
-
const relayHash = ethers_1.ethers.utils.keccak256(contentToHash);
|
|
151
|
-
const relayHashBuffer = Buffer.from(relayHash.slice(2), "hex");
|
|
152
|
-
return new Uint8Array(relayHashBuffer);
|
|
153
|
-
}
|
|
154
|
-
const readUInt256BE = (buffer) => {
|
|
155
|
-
let result = BigInt(0);
|
|
156
|
-
for (let i = 0; i < buffer.length; i++) {
|
|
157
|
-
result = (result << BigInt(8)) + BigInt(buffer[i]);
|
|
158
|
-
}
|
|
159
|
-
return result;
|
|
160
|
-
};
|
|
161
|
-
exports.readUInt256BE = readUInt256BE;
|
|
162
|
-
// This is extended Anchor accounts coder to handle large account data that is required when passing instruction
|
|
163
|
-
// parameters from prefilled data account. Base implementation restricts the buffer to only 1000 bytes.
|
|
164
|
-
class LargeAccountsCoder extends anchor_1.BorshAccountsCoder {
|
|
165
|
-
// Getter to access the private accountLayouts property from base class.
|
|
166
|
-
getAccountLayouts() {
|
|
167
|
-
return this.accountLayouts;
|
|
168
|
-
}
|
|
169
|
-
async encode(accountName, account) {
|
|
170
|
-
const buffer = Buffer.alloc(10240); // We don't currently need anything above instruction data account reallocation limit.
|
|
171
|
-
const layout = this.getAccountLayouts().get(accountName);
|
|
172
|
-
if (!layout) {
|
|
173
|
-
throw new Error(`Unknown account: ${accountName}`);
|
|
174
|
-
}
|
|
175
|
-
const len = layout.encode(account, buffer);
|
|
176
|
-
const accountData = buffer.slice(0, len);
|
|
177
|
-
const discriminator = this.accountDiscriminator(accountName);
|
|
178
|
-
return Buffer.concat([discriminator, accountData]);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
exports.LargeAccountsCoder = LargeAccountsCoder;
|
|
182
|
-
// Modified version of CompiledKeys to handle compilation of unsigned transactions. Original implementation is here:
|
|
183
|
-
// https://github.com/solana-labs/solana-web3.js/blob/v1.95.3/src/message/compiled-keys.ts
|
|
184
|
-
class UnsignedCompiledKeys {
|
|
185
|
-
constructor(keyModeMap, payer) {
|
|
186
|
-
this.keyModeMap = keyModeMap;
|
|
187
|
-
this.payer = payer;
|
|
188
|
-
}
|
|
189
|
-
static compileUnsigned(instructions, payer) {
|
|
190
|
-
const keyModeMap = new Map();
|
|
191
|
-
const getOrInsertDefault = (pubkey) => {
|
|
192
|
-
const address = pubkey.toBase58();
|
|
193
|
-
let keyMode = keyModeMap.get(address);
|
|
194
|
-
if (keyMode === undefined) {
|
|
195
|
-
keyMode = {
|
|
196
|
-
isWritable: false,
|
|
197
|
-
};
|
|
198
|
-
keyModeMap.set(address, keyMode);
|
|
199
|
-
}
|
|
200
|
-
return keyMode;
|
|
201
|
-
};
|
|
202
|
-
if (payer !== undefined) {
|
|
203
|
-
const payerKeyMode = getOrInsertDefault(payer);
|
|
204
|
-
payerKeyMode.isWritable = true;
|
|
205
|
-
}
|
|
206
|
-
for (const ix of instructions) {
|
|
207
|
-
getOrInsertDefault(ix.programId);
|
|
208
|
-
for (const accountMeta of ix.keys) {
|
|
209
|
-
const keyMode = getOrInsertDefault(accountMeta.pubkey);
|
|
210
|
-
keyMode.isWritable ||= accountMeta.isWritable;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
return new UnsignedCompiledKeys(keyModeMap, payer);
|
|
214
|
-
}
|
|
215
|
-
getMessageComponents() {
|
|
216
|
-
const mapEntries = [...this.keyModeMap.entries()];
|
|
217
|
-
if (mapEntries.length > 256)
|
|
218
|
-
throw new Error("Max static account keys length exceeded");
|
|
219
|
-
const writableNonSigners = mapEntries.filter(([, mode]) => mode.isWritable);
|
|
220
|
-
const readonlyNonSigners = mapEntries.filter(([, mode]) => !mode.isWritable);
|
|
221
|
-
const header = {
|
|
222
|
-
numRequiredSignatures: 0,
|
|
223
|
-
numReadonlySignedAccounts: 0,
|
|
224
|
-
numReadonlyUnsignedAccounts: readonlyNonSigners.length,
|
|
225
|
-
};
|
|
226
|
-
const staticAccountKeys = [
|
|
227
|
-
...writableNonSigners.map(([address]) => new web3_js_1.PublicKey(address)),
|
|
228
|
-
...readonlyNonSigners.map(([address]) => new web3_js_1.PublicKey(address)),
|
|
229
|
-
];
|
|
230
|
-
return [header, staticAccountKeys];
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
// Extended version of legacy Message to handle compilation of unsigned transactions. Base implementation is here:
|
|
234
|
-
// https://github.com/solana-labs/solana-web3.js/blob/v1.95.3/src/message/legacy.ts
|
|
235
|
-
class UnsignedMessage extends web3_js_1.Message {
|
|
236
|
-
static compileUnsigned(instructions, payer) {
|
|
237
|
-
const compiledKeys = UnsignedCompiledKeys.compileUnsigned(instructions, payer);
|
|
238
|
-
const [header, staticAccountKeys] = compiledKeys.getMessageComponents();
|
|
239
|
-
const accountKeys = new web3_js_1.MessageAccountKeys(staticAccountKeys);
|
|
240
|
-
const compiledInstructions = accountKeys.compileInstructions(instructions).map((ix) => ({
|
|
241
|
-
programIdIndex: ix.programIdIndex,
|
|
242
|
-
accounts: ix.accountKeyIndexes,
|
|
243
|
-
data: bs58_1.default.encode(ix.data),
|
|
244
|
-
}));
|
|
245
|
-
return new web3_js_1.Message({
|
|
246
|
-
header,
|
|
247
|
-
accountKeys: staticAccountKeys,
|
|
248
|
-
recentBlockhash: "", // Not used as we are not signing the transaction.
|
|
249
|
-
instructions: compiledInstructions,
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
// Helper to encode message compiled transactions for Across+ multicall handler.
|
|
254
|
-
class MulticallHandlerCoder {
|
|
255
|
-
constructor(instructions, payerKey) {
|
|
256
|
-
// Compile transaction message and keys.
|
|
257
|
-
this.compiledMessage = UnsignedMessage.compileUnsigned(instructions, payerKey);
|
|
258
|
-
// Setup the layout for the encoder.
|
|
259
|
-
const fieldLayouts = [idl_1.IdlCoder.fieldLayout(MulticallHandlerCoder.coderArg, MulticallHandlerCoder.coderTypes)];
|
|
260
|
-
this.layout = borsh.struct(fieldLayouts);
|
|
261
|
-
}
|
|
262
|
-
get readOnlyLen() {
|
|
263
|
-
return (this.compiledMessage.header.numReadonlySignedAccounts + this.compiledMessage.header.numReadonlyUnsignedAccounts);
|
|
264
|
-
}
|
|
265
|
-
get compiledKeyMetas() {
|
|
266
|
-
return this.compiledMessage.accountKeys.map((key, index) => {
|
|
267
|
-
return {
|
|
268
|
-
pubkey: key,
|
|
269
|
-
isSigner: this.compiledMessage.isAccountSigner(index),
|
|
270
|
-
isWritable: this.compiledMessage.isAccountWritable(index),
|
|
271
|
-
};
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
encode() {
|
|
275
|
-
const buffer = Buffer.alloc(1280);
|
|
276
|
-
const len = this.layout.encode({ compiledIxs: this.compiledMessage.compiledInstructions }, buffer);
|
|
277
|
-
return buffer.slice(0, len);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
exports.MulticallHandlerCoder = MulticallHandlerCoder;
|
|
281
|
-
MulticallHandlerCoder.coderArg = {
|
|
282
|
-
name: "compiledIxs",
|
|
283
|
-
type: {
|
|
284
|
-
vec: {
|
|
285
|
-
defined: {
|
|
286
|
-
name: "compiledIx",
|
|
287
|
-
},
|
|
288
|
-
},
|
|
289
|
-
},
|
|
290
|
-
};
|
|
291
|
-
MulticallHandlerCoder.coderTypes = [
|
|
292
|
-
{
|
|
293
|
-
name: "compiledIx",
|
|
294
|
-
type: {
|
|
295
|
-
kind: "struct",
|
|
296
|
-
fields: [
|
|
297
|
-
{
|
|
298
|
-
name: "programIdIndex",
|
|
299
|
-
type: "u8",
|
|
300
|
-
},
|
|
301
|
-
{
|
|
302
|
-
name: "accountKeyIndexes",
|
|
303
|
-
type: {
|
|
304
|
-
vec: "u8",
|
|
305
|
-
},
|
|
306
|
-
},
|
|
307
|
-
{
|
|
308
|
-
name: "data",
|
|
309
|
-
type: "bytes",
|
|
310
|
-
},
|
|
311
|
-
],
|
|
312
|
-
},
|
|
313
|
-
},
|
|
314
|
-
];
|
|
315
|
-
class AcrossPlusMessageCoder {
|
|
316
|
-
constructor(acrossPlusMessage) {
|
|
317
|
-
this.acrossPlusMessage = acrossPlusMessage;
|
|
318
|
-
}
|
|
319
|
-
encode() {
|
|
320
|
-
const fieldLayouts = [idl_1.IdlCoder.fieldLayout(AcrossPlusMessageCoder.coderArg, AcrossPlusMessageCoder.coderTypes)];
|
|
321
|
-
const layout = borsh.struct(fieldLayouts);
|
|
322
|
-
const buffer = Buffer.alloc(12800);
|
|
323
|
-
const len = layout.encode({ message: this.acrossPlusMessage }, buffer);
|
|
324
|
-
return buffer.slice(0, len);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
exports.AcrossPlusMessageCoder = AcrossPlusMessageCoder;
|
|
328
|
-
AcrossPlusMessageCoder.coderArg = {
|
|
329
|
-
name: "message",
|
|
330
|
-
type: {
|
|
331
|
-
defined: {
|
|
332
|
-
name: "acrossPlusMessage",
|
|
333
|
-
},
|
|
334
|
-
},
|
|
335
|
-
};
|
|
336
|
-
AcrossPlusMessageCoder.coderTypes = [
|
|
337
|
-
{
|
|
338
|
-
name: "acrossPlusMessage",
|
|
339
|
-
type: {
|
|
340
|
-
kind: "struct",
|
|
341
|
-
fields: [
|
|
342
|
-
{
|
|
343
|
-
name: "handler",
|
|
344
|
-
type: "pubkey",
|
|
345
|
-
},
|
|
346
|
-
{
|
|
347
|
-
name: "readOnlyLen",
|
|
348
|
-
type: "u8",
|
|
349
|
-
},
|
|
350
|
-
{
|
|
351
|
-
name: "valueAmount",
|
|
352
|
-
type: "u64",
|
|
353
|
-
},
|
|
354
|
-
{
|
|
355
|
-
name: "accounts",
|
|
356
|
-
type: {
|
|
357
|
-
vec: "pubkey",
|
|
358
|
-
},
|
|
359
|
-
},
|
|
360
|
-
{
|
|
361
|
-
name: "handlerMessage",
|
|
362
|
-
type: "bytes",
|
|
363
|
-
},
|
|
364
|
-
],
|
|
365
|
-
},
|
|
366
|
-
},
|
|
367
|
-
];
|
|
368
|
-
// Helper to send instructions using Address Lookup Table (ALT) for large number of accounts.
|
|
369
|
-
async function sendTransactionWithLookupTable(connection, instructions, sender) {
|
|
370
|
-
// Maximum number of accounts that can be added to Address Lookup Table (ALT) in a single transaction.
|
|
371
|
-
const maxExtendedAccounts = 30;
|
|
372
|
-
// Consolidate addresses from all instructions into a single array for the ALT.
|
|
373
|
-
const lookupAddresses = Array.from(new Set(instructions.flatMap((instruction) => [
|
|
374
|
-
instruction.programId,
|
|
375
|
-
...instruction.keys.map((accountMeta) => accountMeta.pubkey),
|
|
376
|
-
])));
|
|
377
|
-
// Create instructions for creating and extending the ALT.
|
|
378
|
-
const [lookupTableInstruction, lookupTableAddress] = await web3_js_1.AddressLookupTableProgram.createLookupTable({
|
|
379
|
-
authority: sender.publicKey,
|
|
380
|
-
payer: sender.publicKey,
|
|
381
|
-
recentSlot: await connection.getSlot(),
|
|
382
|
-
});
|
|
383
|
-
// Submit the ALT creation transaction
|
|
384
|
-
await anchor_1.web3.sendAndConfirmTransaction(connection, new anchor_1.web3.Transaction().add(lookupTableInstruction), [sender], {
|
|
385
|
-
skipPreflight: true, // Avoids recent slot mismatch in simulation.
|
|
386
|
-
});
|
|
387
|
-
// Extend the ALT with all accounts making sure not to exceed the maximum number of accounts per transaction.
|
|
388
|
-
for (let i = 0; i < lookupAddresses.length; i += maxExtendedAccounts) {
|
|
389
|
-
const extendInstruction = web3_js_1.AddressLookupTableProgram.extendLookupTable({
|
|
390
|
-
lookupTable: lookupTableAddress,
|
|
391
|
-
authority: sender.publicKey,
|
|
392
|
-
payer: sender.publicKey,
|
|
393
|
-
addresses: lookupAddresses.slice(i, i + maxExtendedAccounts),
|
|
394
|
-
});
|
|
395
|
-
await anchor_1.web3.sendAndConfirmTransaction(connection, new anchor_1.web3.Transaction().add(extendInstruction), [sender], {
|
|
396
|
-
skipPreflight: true, // Avoids recent slot mismatch in simulation.
|
|
397
|
-
});
|
|
398
|
-
}
|
|
399
|
-
// Avoids invalid ALT index as ALT might not be active yet on the following tx.
|
|
400
|
-
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
401
|
-
// Fetch the AddressLookupTableAccount
|
|
402
|
-
const lookupTableAccount = (await connection.getAddressLookupTable(lookupTableAddress)).value;
|
|
403
|
-
if (lookupTableAccount === null)
|
|
404
|
-
throw new Error("AddressLookupTableAccount not fetched");
|
|
405
|
-
// Create the versioned transaction
|
|
406
|
-
const versionedTx = new web3_js_1.VersionedTransaction(new web3_js_1.TransactionMessage({
|
|
407
|
-
payerKey: sender.publicKey,
|
|
408
|
-
recentBlockhash: (await connection.getLatestBlockhash()).blockhash,
|
|
409
|
-
instructions,
|
|
410
|
-
}).compileToV0Message([lookupTableAccount]));
|
|
411
|
-
// Sign and submit the versioned transaction.
|
|
412
|
-
versionedTx.sign([sender]);
|
|
413
|
-
const txSignature = await connection.sendTransaction(versionedTx);
|
|
414
|
-
return { txSignature, lookupTableAddress };
|
|
415
|
-
}
|