@debridge-finance/solana-utils 4.5.0 → 4.5.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/browser/index.js +50 -37
- package/dist/browser/index.js.map +1 -1
- package/dist/cjs/accounts.js +20 -18
- package/dist/cjs/accounts.js.map +1 -1
- package/dist/cjs/constants.js +1 -0
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/crypto.js +2 -4
- package/dist/cjs/crypto.js.map +1 -1
- package/dist/cjs/helpers.js +6 -2
- package/dist/cjs/helpers.js.map +1 -1
- package/dist/cjs/spl.js +1 -1
- package/dist/cjs/spl.js.map +1 -1
- package/dist/cjs/transaction.js +20 -12
- package/dist/cjs/transaction.js.map +1 -1
- package/dist/esm/accounts.js +20 -18
- package/dist/esm/accounts.js.map +1 -1
- package/dist/esm/constants.js +1 -0
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/crypto.js +2 -4
- package/dist/esm/crypto.js.map +1 -1
- package/dist/esm/helpers.js +6 -2
- package/dist/esm/helpers.js.map +1 -1
- package/dist/esm/spl.js +1 -1
- package/dist/esm/spl.js.map +1 -1
- package/dist/esm/transaction.js +21 -13
- package/dist/esm/transaction.js.map +1 -1
- package/dist/types/accounts.d.ts +1 -0
- package/dist/types/accounts.d.ts.map +1 -1
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/crypto.d.ts.map +1 -1
- package/dist/types/helpers.d.ts.map +1 -1
- package/dist/types/spl.d.ts.map +1 -1
- package/dist/types/transaction.d.ts +5 -5
- package/dist/types/transaction.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -6486,6 +6486,7 @@ const dlnDst$1 = {
|
|
|
6486
6486
|
AUTHORIZED_DST_NATIVE_SENDER: "AUTHORIZED_DST_NATIVE_SENDER",
|
|
6487
6487
|
ORDER_STATE: "TAKE_ORDER_STATE",
|
|
6488
6488
|
TAKE_PATCH: "TAKE_ORDER_PATCH",
|
|
6489
|
+
STATE: "STATE",
|
|
6489
6490
|
},
|
|
6490
6491
|
};
|
|
6491
6492
|
|
|
@@ -6663,7 +6664,9 @@ function sendAll(connection, wallet, transactions, options) {
|
|
|
6663
6664
|
if (!skipPreflight) {
|
|
6664
6665
|
yield Promise.all(transactions.map((tx) => simulateTx(connection, tx, simulationCommitment, wallet.publicKey, convertIntoTxV0, skipSign)));
|
|
6665
6666
|
}
|
|
6666
|
-
const blockhashResponse = yield connection.getLatestBlockhashAndContext({
|
|
6667
|
+
const blockhashResponse = yield connection.getLatestBlockhashAndContext({
|
|
6668
|
+
commitment: blockhashCommitment,
|
|
6669
|
+
});
|
|
6667
6670
|
let signed = transactions;
|
|
6668
6671
|
if (!skipSign) {
|
|
6669
6672
|
// set real blockhash
|
|
@@ -6678,7 +6681,9 @@ function sendAll(connection, wallet, transactions, options) {
|
|
|
6678
6681
|
return connection.sendEncodedTransaction(serialized, {
|
|
6679
6682
|
preflightCommitment: simulationCommitment,
|
|
6680
6683
|
skipPreflight: false,
|
|
6681
|
-
minContextSlot: useMinContextSlot
|
|
6684
|
+
minContextSlot: useMinContextSlot
|
|
6685
|
+
? blockhashResponse.context.slot + 1
|
|
6686
|
+
: undefined,
|
|
6682
6687
|
});
|
|
6683
6688
|
}));
|
|
6684
6689
|
}
|
|
@@ -6932,10 +6937,8 @@ function hashExternalCallBytes(data) {
|
|
|
6932
6937
|
if (data === undefined || (data === null || data === void 0 ? void 0 : data.length) === 0) {
|
|
6933
6938
|
// precomputed "empty" hash
|
|
6934
6939
|
return buffer.Buffer.from([
|
|
6935
|
-
197, 210, 70, 1, 134, 247, 35, 60,
|
|
6936
|
-
|
|
6937
|
-
229, 0, 182, 83, 202, 130, 39, 59,
|
|
6938
|
-
123, 250, 216, 4, 93, 133, 164, 112
|
|
6940
|
+
197, 210, 70, 1, 134, 247, 35, 60, 146, 126, 125, 178, 220, 199, 3, 192,
|
|
6941
|
+
229, 0, 182, 83, 202, 130, 39, 59, 123, 250, 216, 4, 93, 133, 164, 112,
|
|
6939
6942
|
]);
|
|
6940
6943
|
}
|
|
6941
6944
|
return hexToBuffer(solidityKeccak256(["bytes"], [data ? data : buffer.Buffer.from([])]), 32);
|
|
@@ -7484,6 +7487,7 @@ const DlnSrc = {
|
|
|
7484
7487
|
getFeeLedgerAddress: (DLN_SRC_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(dlnSrc$1.Seeds.FEE_LEDGER)], DLN_SRC_PROGRAM_ID),
|
|
7485
7488
|
};
|
|
7486
7489
|
const DlnDst = {
|
|
7490
|
+
getStateAddress: (DLN_DST_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(dlnDst$1.Seeds.STATE)], DLN_DST_PROGRAM_ID),
|
|
7487
7491
|
getAuthorizedSrcContractAddress: (chainId, DLN_DST_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(dlnDst$1.Seeds.AUTHORIZED_SRC_CONTRACT), chainId], DLN_DST_PROGRAM_ID),
|
|
7488
7492
|
getAuthorizedDstNativeSenderAddress: (DLN_DST_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(dlnDst$1.Seeds.AUTHORIZED_DST_NATIVE_SENDER)], DLN_DST_PROGRAM_ID),
|
|
7489
7493
|
getTakeOrderStateAddress: (orderId, DLN_DST_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(dlnDst$1.Seeds.ORDER_STATE), orderId], DLN_DST_PROGRAM_ID),
|
|
@@ -7520,36 +7524,37 @@ class ResolverContainer2 {
|
|
|
7520
7524
|
}
|
|
7521
7525
|
const DeBridgeResolver = (programId, settingsProgramId) => {
|
|
7522
7526
|
const deBridgeMemoizeList = {
|
|
7523
|
-
|
|
7524
|
-
|
|
7525
|
-
|
|
7527
|
+
getClaimMarkerAddress: {},
|
|
7528
|
+
getNonceAddress: {},
|
|
7529
|
+
getMintAuthorityAddress: { maxSize: 20 },
|
|
7526
7530
|
};
|
|
7527
7531
|
const settingsMemoizeList = {
|
|
7528
|
-
|
|
7529
|
-
|
|
7530
|
-
|
|
7531
|
-
|
|
7532
|
-
|
|
7533
|
-
|
|
7534
|
-
|
|
7535
|
-
|
|
7536
|
-
|
|
7532
|
+
getTokenMetadataMasterAddress: {},
|
|
7533
|
+
getTokenMintAddress: { maxSize: 5 },
|
|
7534
|
+
getStateAddress: {},
|
|
7535
|
+
getBridgeFeeAddress: { maxSize: 40 },
|
|
7536
|
+
getChainSupportInfoAddress: { maxSize: 10 },
|
|
7537
|
+
getBridgeAddress: { maxSize: 10 },
|
|
7538
|
+
getBridgeMapAddress: { maxSize: 10 },
|
|
7539
|
+
getNoBridgeFeeAddress: {},
|
|
7540
|
+
getNoDiscountAddress: {},
|
|
7537
7541
|
};
|
|
7538
7542
|
return new ResolverContainer2(new Resolver(programId, deBridge$1, deBridgeMemoizeList), new Resolver(settingsProgramId, deBridgeSettings, settingsMemoizeList));
|
|
7539
7543
|
};
|
|
7540
7544
|
const dlnSrcResolver = (programId) => {
|
|
7541
7545
|
const dlnMemoizeList = {
|
|
7542
|
-
|
|
7543
|
-
|
|
7544
|
-
|
|
7545
|
-
|
|
7546
|
+
getStateAccount: {},
|
|
7547
|
+
getAuthorizedNativeSenderAddress: { maxSize: 10 },
|
|
7548
|
+
getFeeLedgerAddress: {},
|
|
7549
|
+
getFeeLedgerWalletAddress: { maxSize: 10 },
|
|
7546
7550
|
};
|
|
7547
7551
|
return new Resolver(programId, DlnSrc, dlnMemoizeList);
|
|
7548
7552
|
};
|
|
7549
7553
|
const dlnDstResolver = (programId) => {
|
|
7550
7554
|
const dstMemoizeList = {
|
|
7551
|
-
|
|
7552
|
-
|
|
7555
|
+
getAuthorizedSrcContractAddress: { maxSize: 10 },
|
|
7556
|
+
getAuthorizedDstNativeSenderAddress: {},
|
|
7557
|
+
getStateAddress: {},
|
|
7553
7558
|
};
|
|
7554
7559
|
return new Resolver(programId, DlnDst, dstMemoizeList);
|
|
7555
7560
|
};
|
|
@@ -10069,7 +10074,7 @@ function parseSplAccount(dataOrInfo) {
|
|
|
10069
10074
|
if (dataOrInfo === null) {
|
|
10070
10075
|
return null;
|
|
10071
10076
|
}
|
|
10072
|
-
const data =
|
|
10077
|
+
const data = "executable" in dataOrInfo ? dataOrInfo.data : dataOrInfo;
|
|
10073
10078
|
try {
|
|
10074
10079
|
return AccountLayout.decode(data);
|
|
10075
10080
|
}
|
|
@@ -10295,26 +10300,34 @@ function simulateTransaction(connection, tx, simulateConfig) {
|
|
|
10295
10300
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
10296
10301
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10297
10302
|
const addressesToGetDiffFor = ((_b = (_a = simulateConfig.accounts) === null || _a === void 0 ? void 0 : _a.addresses) !== null && _b !== void 0 ? _b : []).map((a) => new PublicKey(a));
|
|
10298
|
-
const accountsToFetch = addressesToGetDiffFor.length > 0
|
|
10303
|
+
const accountsToFetch = addressesToGetDiffFor.length > 0
|
|
10304
|
+
? yield connection.getMultipleAccountsInfo(addressesToGetDiffFor)
|
|
10305
|
+
: [];
|
|
10299
10306
|
const result = yield connection.simulateTransaction(tx, simulateConfig);
|
|
10300
10307
|
const diffMap = new Map();
|
|
10301
10308
|
for (const [idx, simulatedAccountInfo] of ((_c = result.value.accounts) !== null && _c !== void 0 ? _c : []).entries()) {
|
|
10302
10309
|
const accountAddress = addressesToGetDiffFor[idx];
|
|
10303
10310
|
const oldAccountData = (_d = accountsToFetch.at(idx)) !== null && _d !== void 0 ? _d : null;
|
|
10304
|
-
const oldParsedMaybeSpl = (oldAccountData === null || oldAccountData === void 0 ? void 0 : oldAccountData.owner.equals(TOKEN_PROGRAM_ID))
|
|
10311
|
+
const oldParsedMaybeSpl = (oldAccountData === null || oldAccountData === void 0 ? void 0 : oldAccountData.owner.equals(TOKEN_PROGRAM_ID))
|
|
10312
|
+
? parseSplAccount(oldAccountData)
|
|
10313
|
+
: null;
|
|
10305
10314
|
const oldSolValue = (_e = oldAccountData === null || oldAccountData === void 0 ? void 0 : oldAccountData.lamports) !== null && _e !== void 0 ? _e : 0;
|
|
10306
10315
|
const newSolValue = (_f = simulatedAccountInfo === null || simulatedAccountInfo === void 0 ? void 0 : simulatedAccountInfo.lamports) !== null && _f !== void 0 ? _f : 0;
|
|
10307
|
-
const solDiff = oldSolValue === newSolValue
|
|
10308
|
-
|
|
10309
|
-
|
|
10310
|
-
|
|
10316
|
+
const solDiff = oldSolValue === newSolValue
|
|
10317
|
+
? null
|
|
10318
|
+
: {
|
|
10319
|
+
before: oldSolValue,
|
|
10320
|
+
after: newSolValue,
|
|
10321
|
+
};
|
|
10311
10322
|
let newParsedMaybeSpl = null;
|
|
10312
10323
|
if (simulatedAccountInfo) {
|
|
10313
10324
|
const [rawData, encoding] = simulatedAccountInfo.data;
|
|
10314
10325
|
if (encoding !== "base64")
|
|
10315
10326
|
throw new Error("Expected bs64 account data");
|
|
10316
10327
|
const artificialAccountInfo = Object.assign(Object.assign({}, simulatedAccountInfo), { owner: new PublicKey(simulatedAccountInfo.owner), data: Buffer.from(rawData, "base64") });
|
|
10317
|
-
newParsedMaybeSpl = artificialAccountInfo.owner.equals(TOKEN_PROGRAM_ID)
|
|
10328
|
+
newParsedMaybeSpl = artificialAccountInfo.owner.equals(TOKEN_PROGRAM_ID)
|
|
10329
|
+
? parseSplAccount(artificialAccountInfo)
|
|
10330
|
+
: null;
|
|
10318
10331
|
}
|
|
10319
10332
|
let splDiff = null;
|
|
10320
10333
|
// old state is spl token account OR new state is spl token account
|
|
@@ -10345,11 +10358,11 @@ function simulateTransaction(connection, tx, simulateConfig) {
|
|
|
10345
10358
|
});
|
|
10346
10359
|
}
|
|
10347
10360
|
/**
|
|
10348
|
-
|
|
10349
|
-
|
|
10350
|
-
|
|
10351
|
-
|
|
10352
|
-
|
|
10361
|
+
* Serializes transaction and returns serialized size
|
|
10362
|
+
* @param transaction tx to get length
|
|
10363
|
+
* @param feePayer optional fee payer
|
|
10364
|
+
* @returns transaction size
|
|
10365
|
+
*/
|
|
10353
10366
|
function getTransactionSize(tx) {
|
|
10354
10367
|
try {
|
|
10355
10368
|
if ("version" in tx) {
|