@debridge-finance/solana-utils 4.2.1 → 4.3.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/dist/browser/index.js +216 -129
- package/dist/browser/index.js.map +1 -1
- package/dist/cjs/accounts.js +62 -27
- package/dist/cjs/accounts.js.map +1 -1
- package/dist/cjs/constants.js +3 -3
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/crypto.js +7 -1
- package/dist/cjs/crypto.js.map +1 -1
- package/dist/cjs/helpers.js +75 -64
- package/dist/cjs/helpers.js.map +1 -1
- package/dist/cjs/index.js +2 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/interfaces.js.map +1 -1
- package/dist/cjs/programs.js +9 -0
- package/dist/cjs/programs.js.map +1 -0
- package/dist/cjs/solidityPack.js +10 -8
- package/dist/cjs/solidityPack.js.map +1 -1
- package/dist/cjs/spl.js +31 -16
- package/dist/cjs/spl.js.map +1 -1
- package/dist/esm/accounts.js +59 -24
- package/dist/esm/accounts.js.map +1 -1
- package/dist/esm/constants.js +2 -2
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/crypto.js +8 -2
- package/dist/esm/crypto.js.map +1 -1
- package/dist/esm/helpers.js +81 -68
- package/dist/esm/helpers.js.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/interfaces.js.map +1 -1
- package/dist/esm/programs.js +6 -0
- package/dist/esm/programs.js.map +1 -0
- package/dist/esm/solidityPack.js +10 -8
- package/dist/esm/solidityPack.js.map +1 -1
- package/dist/esm/spl.js +33 -18
- package/dist/esm/spl.js.map +1 -1
- package/dist/types/accounts.d.ts +2 -2
- package/dist/types/accounts.d.ts.map +1 -1
- package/dist/types/constants.d.ts +2 -2
- package/dist/types/crypto.d.ts.map +1 -1
- package/dist/types/helpers.d.ts +4 -5
- package/dist/types/helpers.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/interfaces.d.ts.map +1 -1
- package/dist/types/programs.d.ts +6 -0
- package/dist/types/programs.d.ts.map +1 -0
- package/dist/types/solidityPack.d.ts.map +1 -1
- package/dist/types/spl.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/browser/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Transaction,
|
|
1
|
+
import { Transaction, MessageV0, VersionedTransaction, PublicKey, TransactionInstruction, SystemProgram } from '@solana/web3.js';
|
|
2
2
|
|
|
3
3
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
4
4
|
|
|
@@ -6427,7 +6427,7 @@ const MAX_TX_SIZE = 1232;
|
|
|
6427
6427
|
const FAKE_BLOCKHASH = "1".repeat(32);
|
|
6428
6428
|
const DEPLOY_INFO_PREFIX = 2;
|
|
6429
6429
|
const SUBMISSION_PREFIX = 1;
|
|
6430
|
-
const deBridge$
|
|
6430
|
+
const deBridge$2 = {
|
|
6431
6431
|
Seeds: {
|
|
6432
6432
|
STATE: "DEBRIDGE_STATE",
|
|
6433
6433
|
BRIDGE: "BRIDGE",
|
|
@@ -6469,7 +6469,7 @@ const deBridgeSettings$1 = {
|
|
|
6469
6469
|
SEND_BRIDGE_MAP: "WRAPPER_TOKEN",
|
|
6470
6470
|
},
|
|
6471
6471
|
};
|
|
6472
|
-
const
|
|
6472
|
+
const dlnSrc$1 = {
|
|
6473
6473
|
Seeds: {
|
|
6474
6474
|
STATE: "STATE",
|
|
6475
6475
|
NONCE: "NONCE",
|
|
@@ -6480,7 +6480,7 @@ const pmmSrc = {
|
|
|
6480
6480
|
FEE_LEDGER: "FEE LEDGER",
|
|
6481
6481
|
},
|
|
6482
6482
|
};
|
|
6483
|
-
const
|
|
6483
|
+
const dlnDst$1 = {
|
|
6484
6484
|
Seeds: {
|
|
6485
6485
|
AUTHORIZED_SRC_CONTRACT: "AUTHORIZED_SRC_CONTRACT",
|
|
6486
6486
|
AUTHORIZED_DST_NATIVE_SENDER: "AUTHORIZED_DST_NATIVE_SENDER",
|
|
@@ -6497,10 +6497,10 @@ var constants = /*#__PURE__*/Object.freeze({
|
|
|
6497
6497
|
FAKE_BLOCKHASH: FAKE_BLOCKHASH,
|
|
6498
6498
|
DEPLOY_INFO_PREFIX: DEPLOY_INFO_PREFIX,
|
|
6499
6499
|
SUBMISSION_PREFIX: SUBMISSION_PREFIX,
|
|
6500
|
-
deBridge: deBridge$
|
|
6500
|
+
deBridge: deBridge$2,
|
|
6501
6501
|
deBridgeSettings: deBridgeSettings$1,
|
|
6502
|
-
|
|
6503
|
-
|
|
6502
|
+
dlnSrc: dlnSrc$1,
|
|
6503
|
+
dlnDst: dlnDst$1
|
|
6504
6504
|
});
|
|
6505
6505
|
|
|
6506
6506
|
function getAccountInfo(connection, account, commitment = "confirmed") {
|
|
@@ -6527,7 +6527,10 @@ function hexToBuffer(data, align) {
|
|
|
6527
6527
|
data = data.length % 2 ? "0" + data : data; // append leading zero if data is not aligned, eg "fff" => "0f ff"
|
|
6528
6528
|
align = align || 0;
|
|
6529
6529
|
if (align && bufferLen < align) {
|
|
6530
|
-
return buffer.Buffer.concat([
|
|
6530
|
+
return buffer.Buffer.concat([
|
|
6531
|
+
buffer.Buffer.from(Uint8Array.from({ length: align - bufferLen }).fill(0)),
|
|
6532
|
+
buffer.Buffer.from(data, "hex"),
|
|
6533
|
+
]);
|
|
6531
6534
|
}
|
|
6532
6535
|
return buffer.Buffer.from(data, "hex");
|
|
6533
6536
|
}
|
|
@@ -6550,11 +6553,15 @@ function sleep(milliSeconds) {
|
|
|
6550
6553
|
function getTransactionSize(transaction, feePayer) {
|
|
6551
6554
|
const clonedTransaction = new Transaction({
|
|
6552
6555
|
lastValidBlockHeight: 1234,
|
|
6553
|
-
feePayer: (transaction === null || transaction === void 0 ? void 0 : transaction.feePayer) ||
|
|
6556
|
+
feePayer: (transaction === null || transaction === void 0 ? void 0 : transaction.feePayer) ||
|
|
6557
|
+
feePayer ||
|
|
6558
|
+
transaction.instructions[0].programId,
|
|
6554
6559
|
blockhash: "CSymwgTNX1j3E4qhKfJAUE41nBWEwXufoYryPbkde5RR", // fake blockhash
|
|
6555
6560
|
}).add(transaction);
|
|
6556
6561
|
const serializedMessage = clonedTransaction.serializeMessage();
|
|
6557
|
-
const uniqueSigners = new Set(clonedTransaction.instructions.flatMap((ix) => ix.keys
|
|
6562
|
+
const uniqueSigners = new Set(clonedTransaction.instructions.flatMap((ix) => ix.keys
|
|
6563
|
+
.filter((meta) => meta.isSigner)
|
|
6564
|
+
.map((meta) => meta.pubkey.toBase58())));
|
|
6558
6565
|
// message length + signatures length (1 byte) + signatures count * signature size (64)
|
|
6559
6566
|
return serializedMessage.length + uniqueSigners.size * 64 + 1;
|
|
6560
6567
|
}
|
|
@@ -6581,7 +6588,9 @@ class Wallet {
|
|
|
6581
6588
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6582
6589
|
const promises = [];
|
|
6583
6590
|
for (const [id, tx] of txs.entries()) {
|
|
6584
|
-
promises.push(this.signTransaction(tx, additionalSigners && additionalSigners.length > id
|
|
6591
|
+
promises.push(this.signTransaction(tx, additionalSigners && additionalSigners.length > id
|
|
6592
|
+
? additionalSigners[id]
|
|
6593
|
+
: []));
|
|
6585
6594
|
}
|
|
6586
6595
|
return Promise.all(promises);
|
|
6587
6596
|
});
|
|
@@ -6590,7 +6599,9 @@ class Wallet {
|
|
|
6590
6599
|
function sendWithRetries(connection, serialized, lastValidBlockHeight, timesToSend = 5, blockhashCommitment = "finalized") {
|
|
6591
6600
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6592
6601
|
const txId = yield connection.sendRawTransaction(serialized, {
|
|
6593
|
-
skipPreflight: false,
|
|
6602
|
+
skipPreflight: false,
|
|
6603
|
+
preflightCommitment: blockhashCommitment,
|
|
6604
|
+
maxRetries: 3,
|
|
6594
6605
|
});
|
|
6595
6606
|
let blockheight = yield connection.getBlockHeight();
|
|
6596
6607
|
let sent = 1;
|
|
@@ -6598,7 +6609,7 @@ function sendWithRetries(connection, serialized, lastValidBlockHeight, timesToSe
|
|
|
6598
6609
|
yield connection.sendRawTransaction(serialized, {
|
|
6599
6610
|
skipPreflight: true,
|
|
6600
6611
|
preflightCommitment: blockhashCommitment,
|
|
6601
|
-
maxRetries:
|
|
6612
|
+
maxRetries: 5,
|
|
6602
6613
|
});
|
|
6603
6614
|
yield sleep(300);
|
|
6604
6615
|
blockheight = yield connection.getBlockHeight();
|
|
@@ -6628,6 +6639,44 @@ function setBlockhash(transaction, blockhash) {
|
|
|
6628
6639
|
transaction.recentBlockhash = blockhash;
|
|
6629
6640
|
}
|
|
6630
6641
|
}
|
|
6642
|
+
function simulateTx(connection, tx, commitment, feePayer, convertToV0, alreadySigned) {
|
|
6643
|
+
var _a;
|
|
6644
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6645
|
+
let convert = convertToV0 && !alreadySigned;
|
|
6646
|
+
let txCopy = isVersionedTx(tx)
|
|
6647
|
+
? new VersionedTransaction(tx.message, tx.signatures)
|
|
6648
|
+
: new Transaction(tx);
|
|
6649
|
+
if (convert) {
|
|
6650
|
+
if (isVersionedTx(txCopy)) {
|
|
6651
|
+
txCopy.message.recentBlockhash = FAKE_BLOCKHASH;
|
|
6652
|
+
txCopy = tx;
|
|
6653
|
+
}
|
|
6654
|
+
else {
|
|
6655
|
+
txCopy = new VersionedTransaction(MessageV0.compile({
|
|
6656
|
+
addressLookupTableAccounts: [],
|
|
6657
|
+
instructions: txCopy.instructions,
|
|
6658
|
+
recentBlockhash: FAKE_BLOCKHASH,
|
|
6659
|
+
payerKey: feePayer,
|
|
6660
|
+
}));
|
|
6661
|
+
}
|
|
6662
|
+
}
|
|
6663
|
+
let result;
|
|
6664
|
+
if (isVersionedTx(txCopy)) {
|
|
6665
|
+
result = yield connection.simulateTransaction(txCopy, {
|
|
6666
|
+
commitment,
|
|
6667
|
+
sigVerify: alreadySigned,
|
|
6668
|
+
replaceRecentBlockhash: !alreadySigned,
|
|
6669
|
+
});
|
|
6670
|
+
}
|
|
6671
|
+
else {
|
|
6672
|
+
txCopy.recentBlockhash = FAKE_BLOCKHASH;
|
|
6673
|
+
result = yield connection.simulateTransaction(txCopy.compileMessage());
|
|
6674
|
+
}
|
|
6675
|
+
if (result.value.err !== null) {
|
|
6676
|
+
throw new Error(`Tx simulation Error! Transaction message dump: ${buffer.Buffer.from(txCopy.serialize()).toString("base64")}\n Error: ${JSON.stringify(result.value.err)}, logs:\n ${(_a = result.value.logs) === null || _a === void 0 ? void 0 : _a.join("\n")}`);
|
|
6677
|
+
}
|
|
6678
|
+
});
|
|
6679
|
+
}
|
|
6631
6680
|
/**
|
|
6632
6681
|
*
|
|
6633
6682
|
* @param connection rpc connection
|
|
@@ -6637,11 +6686,13 @@ function setBlockhash(transaction, blockhash) {
|
|
|
6637
6686
|
* @returns
|
|
6638
6687
|
*/
|
|
6639
6688
|
function sendAll(connection, wallet, transactions, options) {
|
|
6640
|
-
var _a, _b
|
|
6689
|
+
var _a, _b;
|
|
6641
6690
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6642
|
-
const
|
|
6691
|
+
const skipSign = (options === null || options === void 0 ? void 0 : options.skipSign) === undefined ? false : options.skipSign;
|
|
6692
|
+
const blockhashCommitment = (options === null || options === void 0 ? void 0 : options.blockhashCommitment) === undefined
|
|
6693
|
+
? (_a = connection.commitment) !== null && _a !== void 0 ? _a : "confirmed"
|
|
6694
|
+
: options.blockhashCommitment;
|
|
6643
6695
|
const convertIntoTxV0 = (options === null || options === void 0 ? void 0 : options.convertIntoTxV0) === undefined ? true : options.convertIntoTxV0;
|
|
6644
|
-
(options === null || options === void 0 ? void 0 : options.debug) === undefined ? false : options.debug;
|
|
6645
6696
|
const skipPreflight = (options === null || options === void 0 ? void 0 : options.skipPreflight) === undefined ? false : options.skipPreflight;
|
|
6646
6697
|
const rpcCalls = (options === null || options === void 0 ? void 0 : options.rpcCalls) === undefined ? 3 : options.rpcCalls;
|
|
6647
6698
|
if (!Array.isArray(transactions))
|
|
@@ -6651,39 +6702,17 @@ function sendAll(connection, wallet, transactions, options) {
|
|
|
6651
6702
|
}
|
|
6652
6703
|
let txIds = [];
|
|
6653
6704
|
if ((options === null || options === void 0 ? void 0 : options.waitBetweenSend) === undefined || options.waitBetweenSend === 0) {
|
|
6654
|
-
|
|
6655
|
-
|
|
6656
|
-
|
|
6657
|
-
if (isVersionedTx(tx)) {
|
|
6658
|
-
tx.message.recentBlockhash = FAKE_BLOCKHASH;
|
|
6659
|
-
txV0 = tx;
|
|
6660
|
-
}
|
|
6661
|
-
else {
|
|
6662
|
-
tx.recentBlockhash = FAKE_BLOCKHASH;
|
|
6663
|
-
tx.feePayer = wallet.publicKey;
|
|
6664
|
-
txV0 = new VersionedTransaction(MessageV0.compile({
|
|
6665
|
-
addressLookupTableAccounts: [],
|
|
6666
|
-
instructions: tx.instructions,
|
|
6667
|
-
recentBlockhash: FAKE_BLOCKHASH,
|
|
6668
|
-
payerKey: tx.feePayer,
|
|
6669
|
-
}));
|
|
6670
|
-
}
|
|
6671
|
-
if (!skipPreflight) {
|
|
6672
|
-
const simulationResult = yield connection.simulateTransaction(txV0, {
|
|
6673
|
-
sigVerify: false,
|
|
6674
|
-
replaceRecentBlockhash: true,
|
|
6675
|
-
commitment: blockhashCommitment,
|
|
6676
|
-
});
|
|
6677
|
-
if (simulationResult.value.err !== null) {
|
|
6678
|
-
throw new Error(`Tx simulation Error! Transaction message dump: ${buffer.Buffer.from(txV0.serialize()).toString("base64")}\n Error: ${JSON.stringify(simulationResult.value.err)}, logs:\n ${(_d = simulationResult.value.logs) === null || _d === void 0 ? void 0 : _d.join("\n")}`);
|
|
6679
|
-
}
|
|
6680
|
-
}
|
|
6681
|
-
})));
|
|
6705
|
+
if (!skipPreflight) {
|
|
6706
|
+
yield Promise.all(transactions.map((tx) => simulateTx(connection, tx, blockhashCommitment, wallet.publicKey, convertIntoTxV0, skipSign)));
|
|
6707
|
+
}
|
|
6682
6708
|
const { blockhash, lastValidBlockHeight } = yield connection.getLatestBlockhash({ commitment: blockhashCommitment });
|
|
6683
|
-
|
|
6684
|
-
|
|
6685
|
-
|
|
6686
|
-
|
|
6709
|
+
let signed = transactions;
|
|
6710
|
+
if (!skipSign) {
|
|
6711
|
+
// set real blockhash
|
|
6712
|
+
transactions.map((tx) => setBlockhash(tx, blockhash));
|
|
6713
|
+
// sign after setting correct blockhashes
|
|
6714
|
+
signed = yield wallet.signAllTransactions(transactions, options === null || options === void 0 ? void 0 : options.signers);
|
|
6715
|
+
}
|
|
6687
6716
|
txIds = yield Promise.all(signed.map((signedTx) => {
|
|
6688
6717
|
var _a;
|
|
6689
6718
|
const serialized = buffer.Buffer.from(signedTx.serialize());
|
|
@@ -6694,35 +6723,19 @@ function sendAll(connection, wallet, transactions, options) {
|
|
|
6694
6723
|
else {
|
|
6695
6724
|
for (let i = 0; i < transactions.length; i++) {
|
|
6696
6725
|
const tx = transactions[i];
|
|
6697
|
-
const { blockhash, lastValidBlockHeight } = yield connection.getLatestBlockhash({
|
|
6698
|
-
|
|
6699
|
-
|
|
6700
|
-
|
|
6701
|
-
|
|
6702
|
-
|
|
6703
|
-
|
|
6704
|
-
|
|
6705
|
-
tx.feePayer = wallet.publicKey;
|
|
6706
|
-
txV0 = new VersionedTransaction(MessageV0.compile({
|
|
6707
|
-
addressLookupTableAccounts: [],
|
|
6708
|
-
instructions: tx.instructions,
|
|
6709
|
-
recentBlockhash: blockhash,
|
|
6710
|
-
payerKey: tx.feePayer,
|
|
6711
|
-
}));
|
|
6712
|
-
}
|
|
6713
|
-
const signed = yield wallet.signTransaction(tx, (options === null || options === void 0 ? void 0 : options.signers) && (options === null || options === void 0 ? void 0 : options.signers.length) > i ? options.signers[i] : undefined);
|
|
6726
|
+
const { blockhash, lastValidBlockHeight } = yield connection.getLatestBlockhash({
|
|
6727
|
+
commitment: blockhashCommitment,
|
|
6728
|
+
});
|
|
6729
|
+
const signed = skipSign
|
|
6730
|
+
? tx
|
|
6731
|
+
: yield wallet.signTransaction(tx, (options === null || options === void 0 ? void 0 : options.signers) && (options === null || options === void 0 ? void 0 : options.signers.length) > i
|
|
6732
|
+
? options.signers[i]
|
|
6733
|
+
: undefined);
|
|
6714
6734
|
if (!skipPreflight) {
|
|
6715
|
-
|
|
6716
|
-
sigVerify: false,
|
|
6717
|
-
replaceRecentBlockhash: true,
|
|
6718
|
-
commitment: "confirmed",
|
|
6719
|
-
});
|
|
6720
|
-
if (simulationResult.value.err !== null) {
|
|
6721
|
-
throw new Error(`Tx simulation Error! Transaction message dump: ${buffer.Buffer.from(txV0.serialize()).toString("base64")}\n Error: ${JSON.stringify(simulationResult.value.err)}, logs:\n ${(_b = simulationResult.value.logs) === null || _b === void 0 ? void 0 : _b.join("\n")}`);
|
|
6722
|
-
}
|
|
6735
|
+
yield simulateTx(connection, tx, blockhashCommitment, wallet.publicKey, convertIntoTxV0, skipSign);
|
|
6723
6736
|
}
|
|
6724
6737
|
const serialized = buffer.Buffer.from(signed.serialize());
|
|
6725
|
-
(
|
|
6738
|
+
(_b = options === null || options === void 0 ? void 0 : options.logger) === null || _b === void 0 ? void 0 : _b.call(options, `Sending tx: ${serialized.toString("base64")}`);
|
|
6726
6739
|
txIds.push(yield sendWithRetries(connection, serialized, lastValidBlockHeight, rpcCalls, blockhashCommitment));
|
|
6727
6740
|
yield sleep(options.waitBetweenSend);
|
|
6728
6741
|
}
|
|
@@ -6755,8 +6768,8 @@ var interfaces = /*#__PURE__*/Object.freeze({
|
|
|
6755
6768
|
* All functions are copied from ethers. This is optimization to reduce dependencies
|
|
6756
6769
|
*/
|
|
6757
6770
|
function concat(items) {
|
|
6758
|
-
const objects = items.map(item => arrayify(item));
|
|
6759
|
-
const length = objects.reduce((accum, item) =>
|
|
6771
|
+
const objects = items.map((item) => arrayify(item));
|
|
6772
|
+
const length = objects.reduce((accum, item) => accum + item.length, 0);
|
|
6760
6773
|
const result = new Uint8Array(length);
|
|
6761
6774
|
objects.reduce((offset, object) => {
|
|
6762
6775
|
result.set(object, offset);
|
|
@@ -6765,7 +6778,7 @@ function concat(items) {
|
|
|
6765
6778
|
return result;
|
|
6766
6779
|
}
|
|
6767
6780
|
function arrayify(value) {
|
|
6768
|
-
if (typeof
|
|
6781
|
+
if (typeof value === "number") {
|
|
6769
6782
|
const numValue = value;
|
|
6770
6783
|
const result = [];
|
|
6771
6784
|
while (value) {
|
|
@@ -6780,7 +6793,7 @@ function arrayify(value) {
|
|
|
6780
6793
|
if (BN.isBN(value)) {
|
|
6781
6794
|
value = `0x${value.toString("hex")}`;
|
|
6782
6795
|
}
|
|
6783
|
-
if (typeof
|
|
6796
|
+
if (typeof value === "string" && value.startsWith("0x")) {
|
|
6784
6797
|
return hexToBuffer(value);
|
|
6785
6798
|
}
|
|
6786
6799
|
if (Array.isArray(value) || ArrayBuffer.isView(value)) {
|
|
@@ -6830,7 +6843,7 @@ const zeroPad = (value, length) => {
|
|
|
6830
6843
|
result.set(bufValue, length - bufValue.length);
|
|
6831
6844
|
return result;
|
|
6832
6845
|
};
|
|
6833
|
-
const isHexString = (data) => typeof
|
|
6846
|
+
const isHexString = (data) => typeof data === "string" && data.startsWith("0x");
|
|
6834
6847
|
const _pack = (type, value, isArray) => {
|
|
6835
6848
|
const regexBytes = new RegExp("^bytes([0-9]+)$");
|
|
6836
6849
|
const regexNumber = new RegExp("^(u?int)([0-9]*)$");
|
|
@@ -6847,7 +6860,7 @@ const _pack = (type, value, isArray) => {
|
|
|
6847
6860
|
case "bytes":
|
|
6848
6861
|
return arrayify(value);
|
|
6849
6862
|
case "bool":
|
|
6850
|
-
value =
|
|
6863
|
+
value = value ? "0x01" : "0x00";
|
|
6851
6864
|
if (isArray) {
|
|
6852
6865
|
return zeroPad(value, 32);
|
|
6853
6866
|
}
|
|
@@ -6857,7 +6870,10 @@ const _pack = (type, value, isArray) => {
|
|
|
6857
6870
|
if (match) {
|
|
6858
6871
|
//let signed = (match[1] === "int")
|
|
6859
6872
|
let size = parseInt(match[2] || "256");
|
|
6860
|
-
if ((match[2] && String(size) !== match[2]) ||
|
|
6873
|
+
if ((match[2] && String(size) !== match[2]) ||
|
|
6874
|
+
size % 8 !== 0 ||
|
|
6875
|
+
size === 0 ||
|
|
6876
|
+
size > 256) {
|
|
6861
6877
|
throw new Error("invalid number type");
|
|
6862
6878
|
}
|
|
6863
6879
|
if (isArray) {
|
|
@@ -6931,7 +6947,13 @@ function normalizeChainId(chainId) {
|
|
|
6931
6947
|
function hashDeployInfo(params) {
|
|
6932
6948
|
const nameHash = solidityKeccak256(["string"], [params.tokenName]);
|
|
6933
6949
|
const symbolHash = solidityKeccak256(["string"], [params.tokenSymbol]);
|
|
6934
|
-
const deployInfoHash = solidityKeccak256(["uint256", "uint256", "uint256", "uint256", "uint8"], [
|
|
6950
|
+
const deployInfoHash = solidityKeccak256(["uint256", "uint256", "uint256", "uint256", "uint8"], [
|
|
6951
|
+
DEPLOY_INFO_PREFIX,
|
|
6952
|
+
params.debridgeId,
|
|
6953
|
+
nameHash,
|
|
6954
|
+
symbolHash,
|
|
6955
|
+
params.decimals,
|
|
6956
|
+
]);
|
|
6935
6957
|
return deployInfoHash;
|
|
6936
6958
|
}
|
|
6937
6959
|
/**
|
|
@@ -7034,49 +7056,84 @@ function findAssociatedTokenAddressSync(wallet, tokenMint, tokenProgramId = TOKE
|
|
|
7034
7056
|
return PublicKey.findProgramAddressSync([wallet.toBytes(), tokenProgramId.toBytes(), tokenMint.toBytes()], associatedTokenProramId);
|
|
7035
7057
|
}
|
|
7036
7058
|
function getTokenMetadataAddress(tokenMint, tokenMetedataProgramId) {
|
|
7037
|
-
return PublicKey.findProgramAddressSync([
|
|
7059
|
+
return PublicKey.findProgramAddressSync([
|
|
7060
|
+
buffer.Buffer.from("metadata"),
|
|
7061
|
+
tokenMetedataProgramId.toBytes(),
|
|
7062
|
+
tokenMint.toBytes(),
|
|
7063
|
+
], tokenMetedataProgramId);
|
|
7038
7064
|
}
|
|
7039
|
-
const deBridge = {
|
|
7040
|
-
getClaimMarkerAddress: (DEBRIDGE_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(deBridge$
|
|
7065
|
+
const deBridge$1 = {
|
|
7066
|
+
getClaimMarkerAddress: (DEBRIDGE_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(deBridge$2.Seeds.CLAIM_MARKER)], DEBRIDGE_PROGRAM_ID),
|
|
7041
7067
|
getExternalCallStorageAddress: (submissionId, executorPubkey, sourceChainId, DEBRIDGE_PROGRAM_ID) => PublicKey.findProgramAddressSync([
|
|
7042
|
-
buffer.Buffer.from(deBridge$
|
|
7068
|
+
buffer.Buffer.from(deBridge$2.Seeds.EXTERNAL_CALL_STORAGE),
|
|
7043
7069
|
submissionId,
|
|
7044
7070
|
new PublicKey(executorPubkey).toBytes(),
|
|
7045
7071
|
normalizeChainId(sourceChainId),
|
|
7046
7072
|
], DEBRIDGE_PROGRAM_ID),
|
|
7047
|
-
getExternalCallMetaAddress: (externalCallStorage, DEBRIDGE_PROGRAM_ID) => PublicKey.findProgramAddressSync([
|
|
7048
|
-
|
|
7049
|
-
|
|
7050
|
-
|
|
7051
|
-
|
|
7073
|
+
getExternalCallMetaAddress: (externalCallStorage, DEBRIDGE_PROGRAM_ID) => PublicKey.findProgramAddressSync([
|
|
7074
|
+
buffer.Buffer.from(deBridge$2.Seeds.EXTERNAL_CALL_META),
|
|
7075
|
+
new PublicKey(externalCallStorage).toBytes(),
|
|
7076
|
+
], DEBRIDGE_PROGRAM_ID),
|
|
7077
|
+
getNonceAddress: (DEBRIDGE_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(deBridge$2.Seeds.NONCE)], DEBRIDGE_PROGRAM_ID),
|
|
7078
|
+
getSubmissionAddress: (submissionId, DEBRIDGE_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(deBridge$2.Seeds.SUBMISSION), submissionId], DEBRIDGE_PROGRAM_ID),
|
|
7079
|
+
getSubmissionAuthAddress: (submissionAddress, DEBRIDGE_PROGRAM_ID) => PublicKey.findProgramAddressSync([
|
|
7080
|
+
buffer.Buffer.from(deBridge$2.Seeds.SUBMISSION_AUTH),
|
|
7081
|
+
new PublicKey(submissionAddress).toBytes(),
|
|
7082
|
+
], DEBRIDGE_PROGRAM_ID),
|
|
7083
|
+
getMintAuthorityAddress: (bridge, DEBRIDGE_PROGRAM_ID) => PublicKey.findProgramAddressSync([
|
|
7084
|
+
buffer.Buffer.from(deBridge$2.Seeds.BRIDGE_MINTER),
|
|
7085
|
+
new PublicKey(bridge).toBytes(),
|
|
7086
|
+
], DEBRIDGE_PROGRAM_ID),
|
|
7052
7087
|
};
|
|
7053
7088
|
const deBridgeSettings = {
|
|
7054
7089
|
getTokenMetadataMasterAddress: (SETTINGS_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(deBridgeSettings$1.Seeds.TOKEN_METADATA)], SETTINGS_PROGRAM_ID),
|
|
7055
7090
|
getTokenMintAddress: (debridgeId, SETTINGS_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(deBridgeSettings$1.Seeds.WRAPPER_TOKEN), debridgeId], SETTINGS_PROGRAM_ID),
|
|
7056
7091
|
getStateAddress: (SETTINGS_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(deBridgeSettings$1.Seeds.STATE)], SETTINGS_PROGRAM_ID),
|
|
7057
|
-
getConfirmationsStorageAddress: (message, SETTINGS_PROGRAM_ID) => PublicKey.findProgramAddressSync([
|
|
7058
|
-
|
|
7059
|
-
|
|
7060
|
-
|
|
7061
|
-
|
|
7092
|
+
getConfirmationsStorageAddress: (message, SETTINGS_PROGRAM_ID) => PublicKey.findProgramAddressSync([
|
|
7093
|
+
buffer.Buffer.from(deBridgeSettings$1.Seeds.CONFIRMATION_STORAGE),
|
|
7094
|
+
message,
|
|
7095
|
+
], SETTINGS_PROGRAM_ID),
|
|
7096
|
+
getBridgeFeeAddress: (bridge, chainId, SETTINGS_PROGRAM_ID) => PublicKey.findProgramAddressSync([
|
|
7097
|
+
buffer.Buffer.from(deBridgeSettings$1.Seeds.BRIDGE_FEE_INFO),
|
|
7098
|
+
bridge.toBytes(),
|
|
7099
|
+
normalizeChainId(chainId),
|
|
7100
|
+
], SETTINGS_PROGRAM_ID),
|
|
7101
|
+
getChainSupportInfoAddress: (chainId, SETTINGS_PROGRAM_ID) => PublicKey.findProgramAddressSync([
|
|
7102
|
+
buffer.Buffer.from(deBridgeSettings$1.Seeds.CHAIN_SUPPORT_INFO),
|
|
7103
|
+
normalizeChainId(chainId),
|
|
7104
|
+
], SETTINGS_PROGRAM_ID),
|
|
7105
|
+
getDiscountInfoAddress: (user, SETTINGS_PROGRAM_ID) => PublicKey.findProgramAddressSync([
|
|
7106
|
+
buffer.Buffer.from(deBridgeSettings$1.Seeds.DISCOUNT_INFO),
|
|
7107
|
+
user.toBytes(),
|
|
7108
|
+
], SETTINGS_PROGRAM_ID),
|
|
7109
|
+
getBridgeAddress: (tokenMint, SETTINGS_PROGRAM_ID) => PublicKey.findProgramAddressSync([
|
|
7110
|
+
buffer.Buffer.from(deBridgeSettings$1.Seeds.BRIDGE),
|
|
7111
|
+
tokenMint.toBytes(),
|
|
7112
|
+
], SETTINGS_PROGRAM_ID),
|
|
7062
7113
|
getBridgeMapAddress: (bridgeId, SETTINGS_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(deBridgeSettings$1.Seeds.SEND_BRIDGE_MAP), bridgeId], SETTINGS_PROGRAM_ID),
|
|
7063
7114
|
getNoDiscountAddress: (SETTINGS_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(deBridgeSettings$1.Seeds.NO_DISCOUNT)], SETTINGS_PROGRAM_ID),
|
|
7064
7115
|
getNoBridgeFeeAddress: (SETTINGS_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(deBridgeSettings$1.Seeds.NO_BRIDGE_FEE_INFO)], SETTINGS_PROGRAM_ID),
|
|
7065
7116
|
};
|
|
7066
|
-
const
|
|
7067
|
-
getStateAccount: (PMM_SRC_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(
|
|
7068
|
-
getNonceAccount: (maker, PMM_SRC_PROGRAM_ID) => PublicKey.findProgramAddressSync([
|
|
7069
|
-
|
|
7070
|
-
|
|
7071
|
-
|
|
7072
|
-
|
|
7073
|
-
|
|
7117
|
+
const DlnSrc = {
|
|
7118
|
+
getStateAccount: (PMM_SRC_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(dlnSrc$1.Seeds.STATE)], PMM_SRC_PROGRAM_ID),
|
|
7119
|
+
getNonceAccount: (maker, PMM_SRC_PROGRAM_ID) => PublicKey.findProgramAddressSync([
|
|
7120
|
+
buffer.Buffer.from(dlnSrc$1.Seeds.NONCE),
|
|
7121
|
+
isBuffer(maker) ? maker : maker.toBuffer(),
|
|
7122
|
+
], PMM_SRC_PROGRAM_ID),
|
|
7123
|
+
getGiveOrderStateAccount: (orderId, PMM_SRC_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(dlnSrc$1.Seeds.ORDER_STATE), orderId], PMM_SRC_PROGRAM_ID),
|
|
7124
|
+
getAuthorizedNativeSenderAddress: (chainId, PMM_SRC_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(dlnSrc$1.Seeds.AUTHORIZED_NATIVE_SENDER), chainId], PMM_SRC_PROGRAM_ID),
|
|
7125
|
+
getGiveOrderWalletAddress: (orderId, PMM_SRC_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(dlnSrc$1.Seeds.GIVE_ORDER_WALLET), orderId], PMM_SRC_PROGRAM_ID),
|
|
7126
|
+
getFeeLedgerWalletAddress: (tokenMint, PMM_SRC_PROGRAM_ID) => PublicKey.findProgramAddressSync([
|
|
7127
|
+
buffer.Buffer.from(dlnSrc$1.Seeds.FEE_LEDGER_WALLET),
|
|
7128
|
+
tokenMint.toBuffer(),
|
|
7129
|
+
], PMM_SRC_PROGRAM_ID),
|
|
7130
|
+
getFeeLedgerAddress: (PMM_SRC_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(dlnSrc$1.Seeds.FEE_LEDGER)], PMM_SRC_PROGRAM_ID),
|
|
7074
7131
|
};
|
|
7075
|
-
const
|
|
7076
|
-
getAuthorizedSrcContractAddress: (chainId, PMM_DST_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(
|
|
7077
|
-
getAuthorizedDstNativeSenderAddress: (PMM_DST_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(
|
|
7078
|
-
getTakeOrderStateAddress: (orderId, PMM_DST_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(
|
|
7079
|
-
getTakePatchAddress: (orderId, PMM_DST_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(
|
|
7132
|
+
const DlnDst = {
|
|
7133
|
+
getAuthorizedSrcContractAddress: (chainId, PMM_DST_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(dlnDst$1.Seeds.AUTHORIZED_SRC_CONTRACT), chainId], PMM_DST_PROGRAM_ID),
|
|
7134
|
+
getAuthorizedDstNativeSenderAddress: (PMM_DST_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(dlnDst$1.Seeds.AUTHORIZED_DST_NATIVE_SENDER)], PMM_DST_PROGRAM_ID),
|
|
7135
|
+
getTakeOrderStateAddress: (orderId, PMM_DST_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(dlnDst$1.Seeds.ORDER_STATE), orderId], PMM_DST_PROGRAM_ID),
|
|
7136
|
+
getTakePatchAddress: (orderId, PMM_DST_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(dlnDst$1.Seeds.TAKE_PATCH), orderId], PMM_DST_PROGRAM_ID),
|
|
7080
7137
|
};
|
|
7081
7138
|
function wrapFn(fn, arg) {
|
|
7082
7139
|
return (...args) => fn(...args, arg);
|
|
@@ -7102,9 +7159,9 @@ class ResolverContainer2 {
|
|
|
7102
7159
|
this.methods = methods;
|
|
7103
7160
|
}
|
|
7104
7161
|
}
|
|
7105
|
-
const DeBridgeResolver = (programId, settingsProgramId) => new ResolverContainer2(new Resolver(programId, deBridge), new Resolver(settingsProgramId, deBridgeSettings));
|
|
7106
|
-
const
|
|
7107
|
-
const
|
|
7162
|
+
const DeBridgeResolver = (programId, settingsProgramId) => new ResolverContainer2(new Resolver(programId, deBridge$1), new Resolver(settingsProgramId, deBridgeSettings));
|
|
7163
|
+
const dlnSrcResolver = (programId) => new Resolver(programId, DlnSrc);
|
|
7164
|
+
const dlnDstResolver = (programId) => new Resolver(programId, DlnDst);
|
|
7108
7165
|
|
|
7109
7166
|
var Layout$1 = {};
|
|
7110
7167
|
|
|
@@ -9497,17 +9554,17 @@ var AccountState;
|
|
|
9497
9554
|
AccountState[AccountState["Frozen"] = 2] = "Frozen";
|
|
9498
9555
|
})(AccountState || (AccountState = {}));
|
|
9499
9556
|
const AccountLayout = struct([
|
|
9500
|
-
publicKey(
|
|
9501
|
-
publicKey(
|
|
9502
|
-
u64(
|
|
9503
|
-
u32(
|
|
9504
|
-
publicKey(
|
|
9505
|
-
u8(
|
|
9506
|
-
u32(
|
|
9507
|
-
u64(
|
|
9508
|
-
u64(
|
|
9509
|
-
u32(
|
|
9510
|
-
publicKey(
|
|
9557
|
+
publicKey("mint"),
|
|
9558
|
+
publicKey("owner"),
|
|
9559
|
+
u64("amount"),
|
|
9560
|
+
u32("delegateOption"),
|
|
9561
|
+
publicKey("delegate"),
|
|
9562
|
+
u8("state"),
|
|
9563
|
+
u32("isNativeOption"),
|
|
9564
|
+
u64("isNative"),
|
|
9565
|
+
u64("delegatedAmount"),
|
|
9566
|
+
u32("closeAuthorityOption"),
|
|
9567
|
+
publicKey("closeAuthority"),
|
|
9511
9568
|
]);
|
|
9512
9569
|
var AccountType;
|
|
9513
9570
|
(function (AccountType) {
|
|
@@ -9526,7 +9583,11 @@ var AccountType;
|
|
|
9526
9583
|
function getTokenInfo(connection, tokenAddress) {
|
|
9527
9584
|
return __awaiter(this, void 0, void 0, function* () {
|
|
9528
9585
|
const tokenMetaProgramId = new PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s");
|
|
9529
|
-
const findMetaplexMetadataPda = (tokenMint) => PublicKey.findProgramAddressSync([
|
|
9586
|
+
const findMetaplexMetadataPda = (tokenMint) => PublicKey.findProgramAddressSync([
|
|
9587
|
+
buffer.Buffer.from("metadata", "utf-8"),
|
|
9588
|
+
tokenMetaProgramId.toBuffer(),
|
|
9589
|
+
tokenMint.toBuffer(),
|
|
9590
|
+
], tokenMetaProgramId)[0];
|
|
9530
9591
|
const decodeMetaplexMetadataPartial = (data) => {
|
|
9531
9592
|
const rawName = data.subarray(65 + 4, 65 + 36); // omit first 4 bytes, size is already hardcoded
|
|
9532
9593
|
const rawSymbol = data.subarray(101 + 4, 115); // omit first 4 bytes, size is already hardcoded
|
|
@@ -9538,8 +9599,13 @@ function getTokenInfo(connection, tokenAddress) {
|
|
|
9538
9599
|
};
|
|
9539
9600
|
};
|
|
9540
9601
|
const pda = findMetaplexMetadataPda(tokenAddress);
|
|
9541
|
-
const [tokenAccount, pdaAccount] = yield connection.getMultipleAccountsInfo([
|
|
9542
|
-
|
|
9602
|
+
const [tokenAccount, pdaAccount] = yield connection.getMultipleAccountsInfo([
|
|
9603
|
+
tokenAddress,
|
|
9604
|
+
pda,
|
|
9605
|
+
]);
|
|
9606
|
+
if (tokenAccount === null ||
|
|
9607
|
+
pdaAccount === null ||
|
|
9608
|
+
(pdaAccount === null || pdaAccount === void 0 ? void 0 : pdaAccount.lamports) === 0) {
|
|
9543
9609
|
return null;
|
|
9544
9610
|
}
|
|
9545
9611
|
// parse token account
|
|
@@ -9636,7 +9702,9 @@ function getAccountWithType(connection, account) {
|
|
|
9636
9702
|
if (!accountData)
|
|
9637
9703
|
return [null, AccountType.NotExists];
|
|
9638
9704
|
if (accountData.owner.equals(TOKEN_PROGRAM_ID)) {
|
|
9639
|
-
return isWalletCorrectATA(account, accountData.data)
|
|
9705
|
+
return isWalletCorrectATA(account, accountData.data)
|
|
9706
|
+
? [accountData, AccountType.CorrectATA]
|
|
9707
|
+
: [accountData, AccountType.Token];
|
|
9640
9708
|
}
|
|
9641
9709
|
if (accountData.owner.equals(SystemProgram.programId))
|
|
9642
9710
|
return [accountData, AccountType.System];
|
|
@@ -9737,7 +9805,11 @@ function buildReplenishWsolBalanceTransaction(amount, transferFrom, transferTo)
|
|
|
9737
9805
|
transferFrom = new PublicKey(transferFrom);
|
|
9738
9806
|
transferTo = new PublicKey(transferTo);
|
|
9739
9807
|
const tx = new Transaction();
|
|
9740
|
-
tx.add(SystemProgram.transfer({
|
|
9808
|
+
tx.add(SystemProgram.transfer({
|
|
9809
|
+
fromPubkey: transferFrom,
|
|
9810
|
+
toPubkey: transferTo,
|
|
9811
|
+
lamports: new BN(amount).toNumber(),
|
|
9812
|
+
}));
|
|
9741
9813
|
tx.add(
|
|
9742
9814
|
// sync native
|
|
9743
9815
|
new TransactionInstruction({
|
|
@@ -9809,5 +9881,20 @@ var spl = /*#__PURE__*/Object.freeze({
|
|
|
9809
9881
|
checkIfAssociatedWalletExists: checkIfAssociatedWalletExists
|
|
9810
9882
|
});
|
|
9811
9883
|
|
|
9812
|
-
|
|
9884
|
+
const deBridge = "DEbrdGj3HsRsAzx6uH4MKyREKxVAfBydijLUF3ygsFfh";
|
|
9885
|
+
const settings = "DeSetTwWhjZq6Pz9Kfdo1KoS5NqtsM6G8ERbX4SSCSft";
|
|
9886
|
+
const dlnSrc = "src5qyZHqTqecJV4aY6Cb6zDZLMDzrDKKezs22MPHr4";
|
|
9887
|
+
const dlnDst = "dst5MGcFPoBeREFAA5E3tU5ij8m5uVYwkzkSAbsLbNo";
|
|
9888
|
+
const dlnExecutor = "exe59FS5cojZkPJVDFDV8RnXCC7wd6yoBjsUtqH7Zai";
|
|
9889
|
+
|
|
9890
|
+
var programs = /*#__PURE__*/Object.freeze({
|
|
9891
|
+
__proto__: null,
|
|
9892
|
+
deBridge: deBridge,
|
|
9893
|
+
settings: settings,
|
|
9894
|
+
dlnSrc: dlnSrc,
|
|
9895
|
+
dlnDst: dlnDst,
|
|
9896
|
+
dlnExecutor: dlnExecutor
|
|
9897
|
+
});
|
|
9898
|
+
|
|
9899
|
+
export { ASSOCIATED_TOKEN_PROGRAM_ID, DeBridgeResolver, TOKEN_METADATA_PROGRAM_ID, TOKEN_PROGRAM_ID, WRAPPED_SOL_MINT, constants, crypto, dlnDstResolver, dlnSrcResolver, findAssociatedTokenAddress, findAssociatedTokenAddressSync, getTokenMetadataAddress, helpers, interfaces, programs, spl };
|
|
9813
9900
|
//# sourceMappingURL=index.js.map
|