@across-protocol/sdk 4.3.25 → 4.3.27
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 +2 -2
- package/dist/cjs/arch/svm/SpokeUtils.js +17 -20
- package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/index.d.ts +1 -0
- package/dist/cjs/arch/svm/index.js +1 -0
- package/dist/cjs/arch/svm/index.js.map +1 -1
- package/dist/cjs/arch/svm/provider.d.ts +1 -0
- package/dist/cjs/arch/svm/provider.js +2 -1
- package/dist/cjs/arch/svm/provider.js.map +1 -1
- package/dist/cjs/clients/HubPoolClient.js +1 -1
- package/dist/cjs/clients/HubPoolClient.js.map +1 -1
- package/dist/cjs/providers/solana/retryRpcFactory.js +12 -2
- package/dist/cjs/providers/solana/retryRpcFactory.js.map +1 -1
- package/dist/esm/arch/svm/SpokeUtils.d.ts +4 -2
- package/dist/esm/arch/svm/SpokeUtils.js +20 -20
- package/dist/esm/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/index.d.ts +1 -0
- package/dist/esm/arch/svm/index.js +1 -0
- package/dist/esm/arch/svm/index.js.map +1 -1
- package/dist/esm/arch/svm/provider.d.ts +1 -0
- package/dist/esm/arch/svm/provider.js +3 -0
- package/dist/esm/arch/svm/provider.js.map +1 -1
- package/dist/esm/clients/HubPoolClient.js +1 -1
- package/dist/esm/clients/HubPoolClient.js.map +1 -1
- package/dist/esm/providers/solana/retryRpcFactory.js +12 -4
- package/dist/esm/providers/solana/retryRpcFactory.js.map +1 -1
- package/dist/types/arch/svm/SpokeUtils.d.ts +4 -2
- package/dist/types/arch/svm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/index.d.ts +1 -0
- package/dist/types/arch/svm/index.d.ts.map +1 -1
- package/dist/types/arch/svm/provider.d.ts +1 -0
- package/dist/types/arch/svm/provider.d.ts.map +1 -1
- package/dist/types/providers/solana/retryRpcFactory.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/arch/svm/SpokeUtils.ts +19 -17
- package/src/arch/svm/index.ts +1 -0
- package/src/arch/svm/provider.ts +5 -0
- package/src/clients/HubPoolClient.ts +1 -1
- package/src/providers/solana/retryRpcFactory.ts +14 -4
|
@@ -3,5 +3,6 @@ export { isSolanaError } from "@solana/kit";
|
|
|
3
3
|
* SVM RPC provider error codes
|
|
4
4
|
* See https://www.quicknode.com/docs/solana/error-references
|
|
5
5
|
*/
|
|
6
|
+
export declare const SVM_BLOCK_NOT_AVAILABLE = -32004;
|
|
6
7
|
export declare const SVM_NO_BLOCK_AT_SLOT = -32007;
|
|
7
8
|
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../../src/arch/svm/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C;;;GAGG;
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../../src/arch/svm/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C;;;GAGG;AAGH,eAAO,MAAM,uBAAuB,SAAS,CAAC;AAG9C,eAAO,MAAM,oBAAoB,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retryRpcFactory.d.ts","sourceRoot":"","sources":["../../../../src/providers/solana/retryRpcFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"retryRpcFactory.d.ts","sourceRoot":"","sources":["../../../../src/providers/solana/retryRpcFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAItE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAIjC,qBAAa,qBAAsB,SAAQ,uBAAuB;IAO9D,QAAQ,CAAC,OAAO,EAAE,MAAM;IACxB,QAAQ,CAAC,iBAAiB,EAAE,MAAM;IANpC,SAAS,CAAC,oBAAoB,EAAE,YAAY,CAAC;IAE7C,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;gBAGd,OAAO,EAAE,MAAM,EACf,iBAAiB,EAAE,MAAM,EAClC,GAAG,4BAA4B,EAAE,qBAAqB,CAAC,OAAO,2BAA2B,CAAC;IAuBrF,eAAe,IAAI,YAAY;IAMtC;;;;;OAKG;YACW,QAAQ;IAoCtB;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;CAc5B"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@across-protocol/sdk",
|
|
3
3
|
"author": "UMA Team",
|
|
4
|
-
"version": "4.3.
|
|
4
|
+
"version": "4.3.27",
|
|
5
5
|
"license": "AGPL-3.0",
|
|
6
6
|
"homepage": "https://docs.across.to/reference/sdk",
|
|
7
7
|
"files": [
|
|
@@ -106,8 +106,8 @@
|
|
|
106
106
|
},
|
|
107
107
|
"dependencies": {
|
|
108
108
|
"@across-protocol/across-token": "^1.0.0",
|
|
109
|
-
"@across-protocol/constants": "^3.1.
|
|
110
|
-
"@across-protocol/contracts": "^4.1.
|
|
109
|
+
"@across-protocol/constants": "^3.1.71",
|
|
110
|
+
"@across-protocol/contracts": "^4.1.1",
|
|
111
111
|
"@coral-xyz/anchor": "^0.30.1",
|
|
112
112
|
"@eth-optimism/sdk": "^3.3.1",
|
|
113
113
|
"@ethersproject/bignumber": "^5.7.0",
|
|
@@ -103,11 +103,14 @@ export async function getTimestampForSlot(provider: SVMProvider, slotNumber: big
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
const { __code: code } = err.context;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
const slot = slotNumber.toString();
|
|
107
|
+
switch (err.context.__code) {
|
|
108
|
+
case SVM_NO_BLOCK_AT_SLOT:
|
|
109
|
+
return undefined;
|
|
109
110
|
|
|
110
|
-
|
|
111
|
+
default:
|
|
112
|
+
throw new Error(`Unhandled SVM getBlockTime() error for slot ${slot}: ${code}`, { cause: err });
|
|
113
|
+
}
|
|
111
114
|
}
|
|
112
115
|
|
|
113
116
|
const timestamp = Number(_timestamp);
|
|
@@ -1183,12 +1186,14 @@ export async function getAccountMetasForTokenlessMessage(
|
|
|
1183
1186
|
* @param message The CCTP message.
|
|
1184
1187
|
* @param hubChainId The chain ID of the hub.
|
|
1185
1188
|
* @param tokenMessengerMinter The token messenger minter address.
|
|
1189
|
+
* @param recipientAta The ATA of the recipient address.
|
|
1186
1190
|
* @returns The account metas for a deposit message.
|
|
1187
1191
|
*/
|
|
1188
1192
|
async function getAccountMetasForDepositMessage(
|
|
1189
1193
|
message: AttestedCCTPMessage,
|
|
1190
1194
|
hubChainId: number,
|
|
1191
|
-
tokenMessengerMinter: Address
|
|
1195
|
+
tokenMessengerMinter: Address,
|
|
1196
|
+
recipientAta: SvmAddress
|
|
1192
1197
|
): Promise<IAccountMeta<string>[]> {
|
|
1193
1198
|
const l1Usdc = EvmAddress.from(TOKEN_SYMBOLS_MAP.USDC.addresses[hubChainId]);
|
|
1194
1199
|
const l2Usdc = SvmAddress.from(
|
|
@@ -1220,14 +1225,6 @@ async function getAccountMetasForDepositMessage(
|
|
|
1220
1225
|
seeds: ["custody", bs58.decode(l2Usdc.toBase58())],
|
|
1221
1226
|
});
|
|
1222
1227
|
|
|
1223
|
-
const state = await getStatePda(SvmSpokeClient.SVM_SPOKE_PROGRAM_ADDRESS);
|
|
1224
|
-
const tokenProgram = TOKEN_PROGRAM_ADDRESS;
|
|
1225
|
-
const vault = await getAssociatedTokenAddress(
|
|
1226
|
-
SvmAddress.from(state),
|
|
1227
|
-
SvmAddress.from(l2Usdc.toBase58()),
|
|
1228
|
-
tokenProgram
|
|
1229
|
-
);
|
|
1230
|
-
|
|
1231
1228
|
// Define accounts dependent on deposit information.
|
|
1232
1229
|
const [tokenPairPda] = await getProgramDerivedAddress({
|
|
1233
1230
|
programAddress: tokenMessengerMinter,
|
|
@@ -1249,7 +1246,7 @@ async function getAccountMetasForDepositMessage(
|
|
|
1249
1246
|
{ address: tokenMinterPda, role: AccountRole.WRITABLE },
|
|
1250
1247
|
{ address: localTokenPda, role: AccountRole.WRITABLE },
|
|
1251
1248
|
{ address: tokenPairPda, role: AccountRole.READONLY },
|
|
1252
|
-
{ address:
|
|
1249
|
+
{ address: toAddress(recipientAta), role: AccountRole.WRITABLE },
|
|
1253
1250
|
{ address: custodyTokenAccountPda, role: AccountRole.WRITABLE },
|
|
1254
1251
|
{ address: TOKEN_PROGRAM_ADDRESS, role: AccountRole.READONLY },
|
|
1255
1252
|
{ address: tokenMessengerEventAuthorityPda, role: AccountRole.READONLY },
|
|
@@ -1263,13 +1260,15 @@ async function getAccountMetasForDepositMessage(
|
|
|
1263
1260
|
* @param signer The signer of the transaction.
|
|
1264
1261
|
* @param message The CCTP message.
|
|
1265
1262
|
* @param hubChainId The chain ID of the hub.
|
|
1263
|
+
* @param recipientAta The ATA of the recipient address (used for token finalizations only).
|
|
1266
1264
|
* @returns The CCTP v1 receive message transaction.
|
|
1267
1265
|
*/
|
|
1268
1266
|
export async function getCCTPV1ReceiveMessageTx(
|
|
1269
1267
|
solanaClient: SVMProvider,
|
|
1270
1268
|
signer: KeyPairSigner,
|
|
1271
1269
|
message: AttestedCCTPMessage,
|
|
1272
|
-
hubChainId: number
|
|
1270
|
+
hubChainId: number,
|
|
1271
|
+
recipientAta: SvmAddress
|
|
1273
1272
|
) {
|
|
1274
1273
|
const [messageTransmitterPda] = await getProgramDerivedAddress({
|
|
1275
1274
|
programAddress: MessageTransmitterClient.MESSAGE_TRANSMITTER_PROGRAM_ADDRESS,
|
|
@@ -1298,7 +1297,8 @@ export async function getCCTPV1ReceiveMessageTx(
|
|
|
1298
1297
|
? await getAccountMetasForDepositMessage(
|
|
1299
1298
|
message,
|
|
1300
1299
|
hubChainId,
|
|
1301
|
-
TokenMessengerMinterClient.TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS
|
|
1300
|
+
TokenMessengerMinterClient.TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS,
|
|
1301
|
+
recipientAta
|
|
1302
1302
|
)
|
|
1303
1303
|
: await getAccountMetasForTokenlessMessage(solanaClient, signer, message.messageBytes);
|
|
1304
1304
|
|
|
@@ -1329,6 +1329,7 @@ export async function getCCTPV1ReceiveMessageTx(
|
|
|
1329
1329
|
* @param solanaClient The Solana client.
|
|
1330
1330
|
* @param attestedMessages The CCTP messages to Solana.
|
|
1331
1331
|
* @param signer A base signer to be converted into a Solana signer.
|
|
1332
|
+
* @param recipientAta The ATA of the recipient address (used for token finalizations only).
|
|
1332
1333
|
* @param simulate Whether to simulate the transaction.
|
|
1333
1334
|
* @param hubChainId The chain ID of the hub.
|
|
1334
1335
|
* @returns A list of executed transaction signatures.
|
|
@@ -1338,11 +1339,12 @@ export function finalizeCCTPV1Messages(
|
|
|
1338
1339
|
solanaClient: SVMProvider,
|
|
1339
1340
|
attestedMessages: AttestedCCTPMessage[],
|
|
1340
1341
|
signer: KeyPairSigner,
|
|
1342
|
+
recipientAta: SvmAddress,
|
|
1341
1343
|
simulate = false,
|
|
1342
1344
|
hubChainId = 1
|
|
1343
1345
|
): Promise<string[]> {
|
|
1344
1346
|
return mapAsync(attestedMessages, async (message) => {
|
|
1345
|
-
const receiveMessageIx = await getCCTPV1ReceiveMessageTx(solanaClient, signer, message, hubChainId);
|
|
1347
|
+
const receiveMessageIx = await getCCTPV1ReceiveMessageTx(solanaClient, signer, message, hubChainId, recipientAta);
|
|
1346
1348
|
|
|
1347
1349
|
if (simulate) {
|
|
1348
1350
|
const result = await solanaClient
|
package/src/arch/svm/index.ts
CHANGED
package/src/arch/svm/provider.ts
CHANGED
|
@@ -4,4 +4,9 @@ export { isSolanaError } from "@solana/kit";
|
|
|
4
4
|
* SVM RPC provider error codes
|
|
5
5
|
* See https://www.quicknode.com/docs/solana/error-references
|
|
6
6
|
*/
|
|
7
|
+
|
|
8
|
+
// Timeout; recommended to retry.
|
|
9
|
+
export const SVM_BLOCK_NOT_AVAILABLE = -32004;
|
|
10
|
+
|
|
11
|
+
// No block produced for slot.
|
|
7
12
|
export const SVM_NO_BLOCK_AT_SLOT = -32007;
|
|
@@ -1157,7 +1157,7 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
1157
1157
|
this.eventSearchConfig.to = undefined; // Caller can re-set on subsequent updates if necessary.
|
|
1158
1158
|
|
|
1159
1159
|
this.isUpdated = true;
|
|
1160
|
-
this.logger.debug({ at: "HubPoolClient::update", message: "HubPool client updated!", searchEndBlock });
|
|
1160
|
+
this.logger.debug({ at: "HubPoolClient::update", message: "HubPool client updated!", searchEndBlock, currentTime });
|
|
1161
1161
|
}
|
|
1162
1162
|
|
|
1163
1163
|
// Returns end block for `chainId` in ProposedRootBundle.bundleBlockEvalNumbers. Looks up chainId
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { RpcTransport } from "@solana/kit";
|
|
2
2
|
import { SolanaClusterRpcFactory } from "./baseRpcFactories";
|
|
3
3
|
import { RateLimitedSolanaRpcFactory } from "./rateLimitedRpcFactory";
|
|
4
|
+
import { isSolanaError, SVM_NO_BLOCK_AT_SLOT } from "../../arch/svm";
|
|
4
5
|
import { delay } from "../../utils";
|
|
5
6
|
import { getOriginFromURL } from "../../utils/NetworkUtils";
|
|
6
7
|
import { Logger } from "winston";
|
|
@@ -93,9 +94,18 @@ export class RetrySolanaRpcFactory extends SolanaClusterRpcFactory {
|
|
|
93
94
|
* @param error Error object from the RPC call
|
|
94
95
|
* @returns True if the request should be aborted immediately, otherwise false
|
|
95
96
|
*/
|
|
96
|
-
private shouldFailImmediate(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
private shouldFailImmediate(method: string, error: unknown): boolean {
|
|
98
|
+
if (!isSolanaError(error)) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const { __code: code } = error.context;
|
|
103
|
+
switch (method) {
|
|
104
|
+
case "getBlockTime":
|
|
105
|
+
return code === SVM_NO_BLOCK_AT_SLOT;
|
|
106
|
+
|
|
107
|
+
default:
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
100
110
|
}
|
|
101
111
|
}
|