@across-protocol/sdk 4.3.114-alpha.0 → 4.3.114-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/arch/svm/SpokeUtils.d.ts +14 -14
- package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/types.d.ts +2 -1
- package/dist/cjs/arch/svm/types.js.map +1 -1
- package/dist/cjs/arch/svm/utils.d.ts +3 -3
- package/dist/cjs/arch/svm/utils.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.d.ts +3 -3
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/esm/arch/svm/SpokeUtils.d.ts +14 -14
- package/dist/esm/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/types.d.ts +6 -1
- package/dist/esm/arch/svm/types.js.map +1 -1
- package/dist/esm/arch/svm/utils.d.ts +3 -3
- package/dist/esm/arch/svm/utils.js +1 -1
- package/dist/esm/arch/svm/utils.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.d.ts +3 -3
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/types/arch/svm/SpokeUtils.d.ts +14 -14
- package/dist/types/arch/svm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/types.d.ts +6 -1
- package/dist/types/arch/svm/types.d.ts.map +1 -1
- package/dist/types/arch/svm/utils.d.ts +3 -3
- package/dist/types/arch/svm/utils.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts +3 -3
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/arch/svm/SpokeUtils.ts +13 -16
- package/src/arch/svm/types.ts +11 -0
- package/src/arch/svm/utils.ts +9 -5
- package/src/relayFeeCalculator/chain-queries/svmQuery.ts +4 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TransactionSigner
|
|
2
|
-
import { SVMProvider } from "../../arch/svm";
|
|
1
|
+
import { TransactionSigner } from "@solana/kit";
|
|
2
|
+
import { SVMProvider, SolanaTransaction } from "../../arch/svm";
|
|
3
3
|
import { RelayData } from "../../interfaces";
|
|
4
4
|
import { Address, BigNumber, BigNumberish, SvmAddress, TransactionCostEstimate } from "../../utils";
|
|
5
5
|
import { Logger, QueryInterface } from "../relayFeeCalculator";
|
|
@@ -75,7 +75,7 @@ export declare class SvmQuery implements QueryInterface {
|
|
|
75
75
|
destinationChainId: number;
|
|
76
76
|
recipient: SvmAddress;
|
|
77
77
|
outputToken: SvmAddress;
|
|
78
|
-
}, signer: TransactionSigner, repaymentChainId: number, repaymentAddress: Address): Promise<
|
|
78
|
+
}, signer: TransactionSigner, repaymentChainId: number, repaymentAddress: Address): Promise<SolanaTransaction>;
|
|
79
79
|
/**
|
|
80
80
|
* Retrieves the current price of a token
|
|
81
81
|
* @param tokenSymbol A valid [CoinGecko-ID](https://api.coingecko.com/api/v3/coins/list)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"svmQuery.d.ts","sourceRoot":"","sources":["../../../../src/relayFeeCalculator/chain-queries/svmQuery.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,
|
|
1
|
+
{"version":3,"file":"svmQuery.d.ts","sourceRoot":"","sources":["../../../../src/relayFeeCalculator/chain-queries/svmQuery.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EASlB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,WAAW,EASX,iBAAiB,EAClB,MAAM,gBAAgB,CAAC;AAKxB,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,uBAAuB,EAAkB,MAAM,aAAa,CAAC;AACpH,OAAO,EAAE,MAAM,EAAE,cAAc,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ACH,2BAA2B,CAAC,OAAO,EAAE,SAAS,GAAG,SAAS;IAI1D;;;;;OAKG;cACa,cAAc,CAC5B,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,WAAW,GAAG,aAAa,CAAC,GAAG;QACxD,kBAAkB,EAAE,MAAM,CAAC;QAC3B,SAAS,EAAE,UAAU,CAAC;QACtB,WAAW,EAAE,UAAU,CAAC;KACzB,EACD,MAAM,EAAE,iBAAiB,EACzB,gBAAgB,EAAE,MAAM,EACxB,gBAAgB,EAAE,OAAO,GACxB,OAAO,CAAC,iBAAiB,CAAC;IAI7B;;;;OAIG;IACG,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAUzD;;;;OAIG;IACH,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM;IAMvC,oBAAoB,CACxB,SAAS,EAAE,SAAS,GAAG;QACrB,kBAAkB,EAAE,MAAM,CAAC;QAC3B,SAAS,EAAE,UAAU,CAAC;QACtB,WAAW,EAAE,UAAU,CAAC;QACxB,gBAAgB,EAAE,UAAU,CAAC;KAC9B,EACD,OAAO,EAAE,UAAU,EACnB,gBAAgB,EAAE,MAAM,EACxB,gBAAgB,EAAE,UAAU,GAC3B,OAAO,CAAC,MAAM,CAAC;CAiEnB"}
|
package/package.json
CHANGED
|
@@ -37,9 +37,6 @@ import {
|
|
|
37
37
|
type WritableAccount,
|
|
38
38
|
type ReadonlyAccount,
|
|
39
39
|
type Commitment,
|
|
40
|
-
type TransactionMessage,
|
|
41
|
-
type TransactionMessageWithBlockhashLifetime,
|
|
42
|
-
type TransactionMessageWithFeePayer,
|
|
43
40
|
} from "@solana/kit";
|
|
44
41
|
import assert from "assert";
|
|
45
42
|
import winston from "winston";
|
|
@@ -90,7 +87,7 @@ import {
|
|
|
90
87
|
} from "./";
|
|
91
88
|
import { SvmCpiEventsClient } from "./eventsClient";
|
|
92
89
|
import { SVM_LONG_TERM_STORAGE_SLOT_SKIPPED, SVM_SLOT_SKIPPED, isSolanaError } from "./provider";
|
|
93
|
-
import { AttestedCCTPMessage, SVMEventNames, SVMProvider, LatestBlockhash } from "./types";
|
|
90
|
+
import { AttestedCCTPMessage, SVMEventNames, SVMProvider, LatestBlockhash, SolanaTransaction } from "./types";
|
|
94
91
|
import {
|
|
95
92
|
getEmergencyDeleteRootBundleRootBundleId,
|
|
96
93
|
getNearestSlotTime,
|
|
@@ -580,7 +577,7 @@ export async function getFillRelayTx(
|
|
|
580
577
|
signer: TransactionSigner,
|
|
581
578
|
repaymentChainId: number,
|
|
582
579
|
repaymentAddress: SdkAddress
|
|
583
|
-
): Promise<
|
|
580
|
+
): Promise<SolanaTransaction> {
|
|
584
581
|
const svmRelayData = toSvmRelayData(relayData);
|
|
585
582
|
|
|
586
583
|
assert(
|
|
@@ -675,7 +672,7 @@ export async function getIPFillRelayTx(
|
|
|
675
672
|
signer: TransactionSigner,
|
|
676
673
|
repaymentChainId: number,
|
|
677
674
|
repaymentAddress: SdkAddress
|
|
678
|
-
): Promise<
|
|
675
|
+
): Promise<SolanaTransaction> {
|
|
679
676
|
const program = toAddress(spokePoolAddr);
|
|
680
677
|
const _relayDataHash = getRelayDataHash(
|
|
681
678
|
{ ...relayData, messageHash: getMessageHash(relayData.message) },
|
|
@@ -766,7 +763,7 @@ export const createFillInstruction = async (
|
|
|
766
763
|
tokenDecimals: number,
|
|
767
764
|
createRecipientAta: boolean = false,
|
|
768
765
|
remainingAccounts: (WritableAccount | ReadonlyAccount)[] = []
|
|
769
|
-
): Promise<
|
|
766
|
+
): Promise<SolanaTransaction> => {
|
|
770
767
|
const mintInfo = await getMintInfo(solanaClient, fillInput.mint);
|
|
771
768
|
const approveIx = getApproveCheckedInstruction(
|
|
772
769
|
{
|
|
@@ -834,7 +831,7 @@ export const createDepositInstruction = async (
|
|
|
834
831
|
depositInput: SvmSpokeClient.DepositInput,
|
|
835
832
|
tokenDecimals: number,
|
|
836
833
|
createVaultAtaIfNeeded: boolean = true
|
|
837
|
-
): Promise<
|
|
834
|
+
): Promise<SolanaTransaction> => {
|
|
838
835
|
const getCreateAssociatedTokenIdempotentIx = () =>
|
|
839
836
|
getCreateAssociatedTokenIdempotentInstruction({
|
|
840
837
|
payer: signer,
|
|
@@ -879,7 +876,7 @@ export const createRequestSlowFillInstruction = async (
|
|
|
879
876
|
signer: TransactionSigner,
|
|
880
877
|
solanaClient: SVMProvider,
|
|
881
878
|
requestSlowFillInput: SvmSpokeClient.RequestSlowFillInput
|
|
882
|
-
): Promise<
|
|
879
|
+
): Promise<SolanaTransaction> => {
|
|
883
880
|
const requestSlowFillIx = SvmSpokeClient.getRequestSlowFillInstruction(requestSlowFillInput);
|
|
884
881
|
|
|
885
882
|
return pipe(await createDefaultTransaction(solanaClient, signer), (tx) =>
|
|
@@ -904,7 +901,7 @@ export async function getSlowFillRequestTx(
|
|
|
904
901
|
outputToken: SvmAddress;
|
|
905
902
|
},
|
|
906
903
|
signer: TransactionSigner
|
|
907
|
-
): Promise<
|
|
904
|
+
): Promise<SolanaTransaction> {
|
|
908
905
|
const program = toAddress(spokePoolAddr);
|
|
909
906
|
const messageHash = getMessageHash(relayData.message);
|
|
910
907
|
const relayDataHash = getRelayDataHash({ ...relayData, messageHash }, relayData.destinationChainId);
|
|
@@ -941,7 +938,7 @@ export const createCloseFillPdaInstruction = async (
|
|
|
941
938
|
signer: TransactionSigner,
|
|
942
939
|
solanaClient: SVMProvider,
|
|
943
940
|
fillStatusPda: Address
|
|
944
|
-
): Promise<
|
|
941
|
+
): Promise<SolanaTransaction> => {
|
|
945
942
|
const closeFillPdaIx = SvmSpokeClient.getCloseFillPdaInstruction({
|
|
946
943
|
signer,
|
|
947
944
|
state: await getStatePda(SvmSpokeClient.SVM_SPOKE_PROGRAM_ADDRESS),
|
|
@@ -957,7 +954,7 @@ export const createReceiveMessageInstruction = async (
|
|
|
957
954
|
solanaClient: SVMProvider,
|
|
958
955
|
input: MessageTransmitterClient.ReceiveMessageInput,
|
|
959
956
|
remainingAccounts: AccountMeta<string>[]
|
|
960
|
-
): Promise<
|
|
957
|
+
): Promise<SolanaTransaction> => {
|
|
961
958
|
const receiveMessageIx = MessageTransmitterClient.getReceiveMessageInstruction(input);
|
|
962
959
|
(receiveMessageIx.accounts as AccountMeta<string>[]).push(...remainingAccounts);
|
|
963
960
|
return pipe(await createDefaultTransaction(solanaClient, signer), (tx) =>
|
|
@@ -1095,7 +1092,7 @@ export async function getIPForFillRelayTxs(
|
|
|
1095
1092
|
repaymentAddress: SdkAddress,
|
|
1096
1093
|
signer: TransactionSigner<string>,
|
|
1097
1094
|
provider: SVMProvider
|
|
1098
|
-
): Promise<Array<
|
|
1095
|
+
): Promise<Array<SolanaTransaction>> {
|
|
1099
1096
|
const ixs = await getFillRelayViaInstructionParamsInstructions(
|
|
1100
1097
|
toAddress(spokePool),
|
|
1101
1098
|
relayData,
|
|
@@ -1456,7 +1453,7 @@ export async function getCCTPDepositAccounts(
|
|
|
1456
1453
|
* @returns Object containing a boolean if the input deposit requires a multipart fill, false otherwise and
|
|
1457
1454
|
* the number of bytes in the serialized transaction.
|
|
1458
1455
|
*/
|
|
1459
|
-
export function isSVMFillTooLarge(fillRelayTx:
|
|
1456
|
+
export function isSVMFillTooLarge(fillRelayTx: SolanaTransaction): {
|
|
1460
1457
|
tooLarge: boolean;
|
|
1461
1458
|
sizeBytes: number;
|
|
1462
1459
|
} {
|
|
@@ -1484,7 +1481,7 @@ export function base64StrToByteSize(base64TxString: string): number {
|
|
|
1484
1481
|
* @param fillTx The compilable fill relay transaction.
|
|
1485
1482
|
* @returns The number of bytes in the serialized fillRelay transaction.
|
|
1486
1483
|
*/
|
|
1487
|
-
export function calculateFillSizeBytes(fillTx:
|
|
1484
|
+
export function calculateFillSizeBytes(fillTx: SolanaTransaction): number {
|
|
1488
1485
|
const signedTransaction = compileTransaction(fillTx);
|
|
1489
1486
|
const serializedTx = getBase64EncodedWireTransaction(signedTransaction);
|
|
1490
1487
|
return base64StrToByteSize(serializedTx);
|
|
@@ -1578,7 +1575,7 @@ export async function getCCTPV1ReceiveMessageTx(
|
|
|
1578
1575
|
message: AttestedCCTPMessage,
|
|
1579
1576
|
hubChainId: number,
|
|
1580
1577
|
recipientAta: SvmAddress
|
|
1581
|
-
): Promise<
|
|
1578
|
+
): Promise<SolanaTransaction> {
|
|
1582
1579
|
const [messageTransmitterPda] = await getProgramDerivedAddress({
|
|
1583
1580
|
programAddress: MessageTransmitterClient.MESSAGE_TRANSMITTER_PROGRAM_ADDRESS,
|
|
1584
1581
|
seeds: ["message_transmitter"],
|
package/src/arch/svm/types.ts
CHANGED
|
@@ -10,8 +10,19 @@ import {
|
|
|
10
10
|
SolanaRpcApiFromTransport,
|
|
11
11
|
UnixTimestamp,
|
|
12
12
|
type Blockhash,
|
|
13
|
+
type TransactionMessage,
|
|
14
|
+
type TransactionMessageWithBlockhashLifetime,
|
|
15
|
+
type TransactionMessageWithFeePayer,
|
|
13
16
|
} from "@solana/kit";
|
|
14
17
|
|
|
18
|
+
/**
|
|
19
|
+
* A Solana transaction message ready to be signed and sent.
|
|
20
|
+
* Includes fee payer and blockhash lifetime information.
|
|
21
|
+
*/
|
|
22
|
+
export type SolanaTransaction = TransactionMessage &
|
|
23
|
+
TransactionMessageWithBlockhashLifetime &
|
|
24
|
+
TransactionMessageWithFeePayer;
|
|
25
|
+
|
|
15
26
|
export type EventData =
|
|
16
27
|
| SvmSpokeClient.BridgedToHubPool
|
|
17
28
|
| SvmSpokeClient.TokensBridged
|
package/src/arch/svm/utils.ts
CHANGED
|
@@ -18,9 +18,6 @@ import {
|
|
|
18
18
|
setTransactionMessageLifetimeUsingBlockhash,
|
|
19
19
|
signTransactionMessageWithSigners,
|
|
20
20
|
type Commitment,
|
|
21
|
-
type TransactionMessage,
|
|
22
|
-
type TransactionMessageWithBlockhashLifetime,
|
|
23
|
-
type TransactionMessageWithFeePayer,
|
|
24
21
|
type TransactionSigner,
|
|
25
22
|
} from "@solana/kit";
|
|
26
23
|
import assert from "assert";
|
|
@@ -29,7 +26,14 @@ import { ethers } from "ethers";
|
|
|
29
26
|
import { FillType, RelayData, RelayDataWithMessageHash } from "../../interfaces";
|
|
30
27
|
import { BigNumber, Address as SdkAddress, biMin, getMessageHash, isDefined, isUint8Array } from "../../utils";
|
|
31
28
|
import { getTimestampForSlot, getSlot, getRelayDataHash } from "./SpokeUtils";
|
|
32
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
AttestedCCTPMessage,
|
|
31
|
+
EventName,
|
|
32
|
+
SVMEventNames,
|
|
33
|
+
SVMProvider,
|
|
34
|
+
LatestBlockhash,
|
|
35
|
+
SolanaTransaction,
|
|
36
|
+
} from "./types";
|
|
33
37
|
import winston from "winston";
|
|
34
38
|
/**
|
|
35
39
|
* Basic void TransactionSigner type
|
|
@@ -414,7 +418,7 @@ export const createDefaultTransaction = async (
|
|
|
414
418
|
rpcClient: SVMProvider,
|
|
415
419
|
signer: TransactionSigner,
|
|
416
420
|
latestBlockhash?: LatestBlockhash
|
|
417
|
-
): Promise<
|
|
421
|
+
): Promise<SolanaTransaction> => {
|
|
418
422
|
latestBlockhash = isDefined(latestBlockhash) ? latestBlockhash : (await rpcClient.getLatestBlockhash().send()).value;
|
|
419
423
|
return pipe(
|
|
420
424
|
createTransactionMessage({ version: 0 }),
|
|
@@ -8,9 +8,7 @@ import {
|
|
|
8
8
|
appendTransactionMessageInstruction,
|
|
9
9
|
compileTransaction,
|
|
10
10
|
getBase64EncodedWireTransaction,
|
|
11
|
-
type
|
|
12
|
-
type TransactionMessageWithBlockhashLifetime,
|
|
13
|
-
type TransactionMessageWithFeePayer,
|
|
11
|
+
type Instruction,
|
|
14
12
|
} from "@solana/kit";
|
|
15
13
|
import {
|
|
16
14
|
SVMProvider,
|
|
@@ -22,6 +20,7 @@ import {
|
|
|
22
20
|
createDefaultTransaction,
|
|
23
21
|
getAssociatedTokenAddress,
|
|
24
22
|
isSVMFillTooLarge,
|
|
23
|
+
SolanaTransaction,
|
|
25
24
|
} from "../../arch/svm";
|
|
26
25
|
import { JitoInterface } from "../../providers/solana";
|
|
27
26
|
import { Coingecko } from "../../coingecko";
|
|
@@ -224,7 +223,7 @@ export class SvmQuery implements QueryInterface {
|
|
|
224
223
|
signer: TransactionSigner,
|
|
225
224
|
repaymentChainId: number,
|
|
226
225
|
repaymentAddress: Address
|
|
227
|
-
): Promise<
|
|
226
|
+
): Promise<SolanaTransaction> {
|
|
228
227
|
return await getFillRelayTx(this.spokePool, this.provider, relayData, signer, repaymentChainId, repaymentAddress);
|
|
229
228
|
}
|
|
230
229
|
|
|
@@ -290,7 +289,7 @@ export class SvmQuery implements QueryInterface {
|
|
|
290
289
|
const computeUnitLimitIx = getSetComputeUnitLimitInstruction({ units: 10_000_000 });
|
|
291
290
|
const fillRelayTx = pipe(_fillRelayTx, (tx) => appendTransactionMessageInstruction(computeUnitLimitIx, tx));
|
|
292
291
|
|
|
293
|
-
const instructionParamsTxs = await mapAsync(instructionParamsIxs, async (ix) => {
|
|
292
|
+
const instructionParamsTxs = await mapAsync(instructionParamsIxs, async (ix: Instruction) => {
|
|
294
293
|
return pipe(await createDefaultTransaction(provider, voidSigner), (tx) =>
|
|
295
294
|
appendTransactionMessageInstruction(ix, tx)
|
|
296
295
|
);
|