@debridge-finance/solana-utils 4.4.2 → 4.5.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 +544 -46
- package/dist/browser/index.js.map +1 -1
- package/dist/cjs/accounts.js +72 -19
- 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 +9 -0
- package/dist/cjs/crypto.js.map +1 -1
- package/dist/cjs/helpers.js +1 -26
- 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/spl.js +5 -1
- package/dist/cjs/spl.js.map +1 -1
- package/dist/cjs/transaction.js +91 -0
- package/dist/cjs/transaction.js.map +1 -0
- package/dist/esm/accounts.js +69 -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 +9 -0
- package/dist/esm/crypto.js.map +1 -1
- package/dist/esm/helpers.js +1 -25
- 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/spl.js +5 -1
- package/dist/esm/spl.js.map +1 -1
- package/dist/esm/transaction.js +83 -0
- package/dist/esm/transaction.js.map +1 -0
- package/dist/types/accounts.d.ts +18 -12
- 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 +0 -7
- 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/spl.d.ts +2 -1
- package/dist/types/spl.d.ts.map +1 -1
- package/dist/types/transaction.d.ts +26 -0
- package/dist/types/transaction.d.ts.map +1 -0
- package/package.json +3 -2
package/dist/browser/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { VersionedTransaction, Transaction,
|
|
1
|
+
import { MessageV0, VersionedTransaction, Transaction, PublicKey, TransactionInstruction, SystemProgram, Keypair } 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
|
|
|
@@ -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
|
|
|
@@ -6544,30 +6545,6 @@ function sleep(milliSeconds) {
|
|
|
6544
6545
|
});
|
|
6545
6546
|
});
|
|
6546
6547
|
}
|
|
6547
|
-
/**
|
|
6548
|
-
* Serializes transaction and returns serialized size
|
|
6549
|
-
* @param transaction tx to get length
|
|
6550
|
-
* @param feePayer optional fee payer
|
|
6551
|
-
* @returns transaction size
|
|
6552
|
-
*/
|
|
6553
|
-
function getTransactionSize(tx) {
|
|
6554
|
-
try {
|
|
6555
|
-
if (isVersionedTx(tx)) {
|
|
6556
|
-
const txCopy = new VersionedTransaction(tx.message);
|
|
6557
|
-
txCopy.message.recentBlockhash = FAKE_BLOCKHASH;
|
|
6558
|
-
return txCopy.serialize().length;
|
|
6559
|
-
}
|
|
6560
|
-
else {
|
|
6561
|
-
const txCopy = new Transaction(tx);
|
|
6562
|
-
txCopy.feePayer = Keypair.generate().publicKey;
|
|
6563
|
-
txCopy.recentBlockhash = FAKE_BLOCKHASH;
|
|
6564
|
-
return tx.serialize({ verifySignatures: false }).length;
|
|
6565
|
-
}
|
|
6566
|
-
}
|
|
6567
|
-
catch (e) {
|
|
6568
|
-
return null;
|
|
6569
|
-
}
|
|
6570
|
-
}
|
|
6571
6548
|
function isVersionedTx(arg) {
|
|
6572
6549
|
return "version" in arg;
|
|
6573
6550
|
}
|
|
@@ -6736,7 +6713,6 @@ var helpers = /*#__PURE__*/Object.freeze({
|
|
|
6736
6713
|
hexToBuffer: hexToBuffer,
|
|
6737
6714
|
bufferToHex: bufferToHex,
|
|
6738
6715
|
sleep: sleep,
|
|
6739
|
-
getTransactionSize: getTransactionSize,
|
|
6740
6716
|
Wallet: Wallet,
|
|
6741
6717
|
sendAll: sendAll
|
|
6742
6718
|
});
|
|
@@ -6954,6 +6930,15 @@ function hashDebridgeId(nativeChainId, nativeTokenAddress) {
|
|
|
6954
6930
|
return bridgeId;
|
|
6955
6931
|
}
|
|
6956
6932
|
function hashExternalCallBytes(data) {
|
|
6933
|
+
if (data === undefined || (data === null || data === void 0 ? void 0 : data.length) === 0) {
|
|
6934
|
+
// precomputed "empty" hash
|
|
6935
|
+
return buffer.Buffer.from([
|
|
6936
|
+
197, 210, 70, 1, 134, 247, 35, 60,
|
|
6937
|
+
146, 126, 125, 178, 220, 199, 3, 192,
|
|
6938
|
+
229, 0, 182, 83, 202, 130, 39, 59,
|
|
6939
|
+
123, 250, 216, 4, 93, 133, 164, 112
|
|
6940
|
+
]);
|
|
6941
|
+
}
|
|
6957
6942
|
return hexToBuffer(solidityKeccak256(["bytes"], [data ? data : buffer.Buffer.from([])]), 32);
|
|
6958
6943
|
}
|
|
6959
6944
|
/**
|
|
@@ -7028,6 +7013,390 @@ var crypto = /*#__PURE__*/Object.freeze({
|
|
|
7028
7013
|
hashSubmissionIdRaw: hashSubmissionIdRaw
|
|
7029
7014
|
});
|
|
7030
7015
|
|
|
7016
|
+
var microMemoize = {exports: {}};
|
|
7017
|
+
|
|
7018
|
+
(function (module, exports) {
|
|
7019
|
+
(function (global, factory) {
|
|
7020
|
+
module.exports = factory() ;
|
|
7021
|
+
})(commonjsGlobal, (function () {
|
|
7022
|
+
/**
|
|
7023
|
+
* @constant DEFAULT_OPTIONS_KEYS the default options keys
|
|
7024
|
+
*/
|
|
7025
|
+
var DEFAULT_OPTIONS_KEYS = {
|
|
7026
|
+
isEqual: true,
|
|
7027
|
+
isMatchingKey: true,
|
|
7028
|
+
isPromise: true,
|
|
7029
|
+
maxSize: true,
|
|
7030
|
+
onCacheAdd: true,
|
|
7031
|
+
onCacheChange: true,
|
|
7032
|
+
onCacheHit: true,
|
|
7033
|
+
transformKey: true,
|
|
7034
|
+
};
|
|
7035
|
+
/**
|
|
7036
|
+
* @function slice
|
|
7037
|
+
*
|
|
7038
|
+
* @description
|
|
7039
|
+
* slice.call() pre-bound
|
|
7040
|
+
*/
|
|
7041
|
+
var slice = Array.prototype.slice;
|
|
7042
|
+
/**
|
|
7043
|
+
* @function cloneArray
|
|
7044
|
+
*
|
|
7045
|
+
* @description
|
|
7046
|
+
* clone the array-like object and return the new array
|
|
7047
|
+
*
|
|
7048
|
+
* @param arrayLike the array-like object to clone
|
|
7049
|
+
* @returns the clone as an array
|
|
7050
|
+
*/
|
|
7051
|
+
function cloneArray(arrayLike) {
|
|
7052
|
+
var length = arrayLike.length;
|
|
7053
|
+
if (!length) {
|
|
7054
|
+
return [];
|
|
7055
|
+
}
|
|
7056
|
+
if (length === 1) {
|
|
7057
|
+
return [arrayLike[0]];
|
|
7058
|
+
}
|
|
7059
|
+
if (length === 2) {
|
|
7060
|
+
return [arrayLike[0], arrayLike[1]];
|
|
7061
|
+
}
|
|
7062
|
+
if (length === 3) {
|
|
7063
|
+
return [arrayLike[0], arrayLike[1], arrayLike[2]];
|
|
7064
|
+
}
|
|
7065
|
+
return slice.call(arrayLike, 0);
|
|
7066
|
+
}
|
|
7067
|
+
/**
|
|
7068
|
+
* @function getCustomOptions
|
|
7069
|
+
*
|
|
7070
|
+
* @description
|
|
7071
|
+
* get the custom options on the object passed
|
|
7072
|
+
*
|
|
7073
|
+
* @param options the memoization options passed
|
|
7074
|
+
* @returns the custom options passed
|
|
7075
|
+
*/
|
|
7076
|
+
function getCustomOptions(options) {
|
|
7077
|
+
var customOptions = {};
|
|
7078
|
+
/* eslint-disable no-restricted-syntax */
|
|
7079
|
+
for (var key in options) {
|
|
7080
|
+
if (!DEFAULT_OPTIONS_KEYS[key]) {
|
|
7081
|
+
customOptions[key] = options[key];
|
|
7082
|
+
}
|
|
7083
|
+
}
|
|
7084
|
+
/* eslint-enable */
|
|
7085
|
+
return customOptions;
|
|
7086
|
+
}
|
|
7087
|
+
/**
|
|
7088
|
+
* @function isMemoized
|
|
7089
|
+
*
|
|
7090
|
+
* @description
|
|
7091
|
+
* is the function passed already memoized
|
|
7092
|
+
*
|
|
7093
|
+
* @param fn the function to test
|
|
7094
|
+
* @returns is the function already memoized
|
|
7095
|
+
*/
|
|
7096
|
+
function isMemoized(fn) {
|
|
7097
|
+
return typeof fn === 'function' && fn.isMemoized;
|
|
7098
|
+
}
|
|
7099
|
+
/**
|
|
7100
|
+
* @function isSameValueZero
|
|
7101
|
+
*
|
|
7102
|
+
* @description
|
|
7103
|
+
* are the objects equal based on SameValueZero equality
|
|
7104
|
+
*
|
|
7105
|
+
* @param object1 the first object to compare
|
|
7106
|
+
* @param object2 the second object to compare
|
|
7107
|
+
* @returns are the two objects equal
|
|
7108
|
+
*/
|
|
7109
|
+
function isSameValueZero(object1, object2) {
|
|
7110
|
+
// eslint-disable-next-line no-self-compare
|
|
7111
|
+
return object1 === object2 || (object1 !== object1 && object2 !== object2);
|
|
7112
|
+
}
|
|
7113
|
+
/**
|
|
7114
|
+
* @function mergeOptions
|
|
7115
|
+
*
|
|
7116
|
+
* @description
|
|
7117
|
+
* merge the options into the target
|
|
7118
|
+
*
|
|
7119
|
+
* @param existingOptions the options provided
|
|
7120
|
+
* @param newOptions the options to include
|
|
7121
|
+
* @returns the merged options
|
|
7122
|
+
*/
|
|
7123
|
+
function mergeOptions(existingOptions, newOptions) {
|
|
7124
|
+
var target = {};
|
|
7125
|
+
/* eslint-disable no-restricted-syntax */
|
|
7126
|
+
for (var key in existingOptions) {
|
|
7127
|
+
target[key] = existingOptions[key];
|
|
7128
|
+
}
|
|
7129
|
+
for (var key in newOptions) {
|
|
7130
|
+
target[key] = newOptions[key];
|
|
7131
|
+
}
|
|
7132
|
+
/* eslint-enable */
|
|
7133
|
+
return target;
|
|
7134
|
+
}
|
|
7135
|
+
|
|
7136
|
+
// utils
|
|
7137
|
+
var Cache = /** @class */ (function () {
|
|
7138
|
+
function Cache(options) {
|
|
7139
|
+
this.keys = [];
|
|
7140
|
+
this.values = [];
|
|
7141
|
+
this.options = options;
|
|
7142
|
+
var isMatchingKeyFunction = typeof options.isMatchingKey === 'function';
|
|
7143
|
+
if (isMatchingKeyFunction) {
|
|
7144
|
+
this.getKeyIndex = this._getKeyIndexFromMatchingKey;
|
|
7145
|
+
}
|
|
7146
|
+
else if (options.maxSize > 1) {
|
|
7147
|
+
this.getKeyIndex = this._getKeyIndexForMany;
|
|
7148
|
+
}
|
|
7149
|
+
else {
|
|
7150
|
+
this.getKeyIndex = this._getKeyIndexForSingle;
|
|
7151
|
+
}
|
|
7152
|
+
this.canTransformKey = typeof options.transformKey === 'function';
|
|
7153
|
+
this.shouldCloneArguments = this.canTransformKey || isMatchingKeyFunction;
|
|
7154
|
+
this.shouldUpdateOnAdd = typeof options.onCacheAdd === 'function';
|
|
7155
|
+
this.shouldUpdateOnChange = typeof options.onCacheChange === 'function';
|
|
7156
|
+
this.shouldUpdateOnHit = typeof options.onCacheHit === 'function';
|
|
7157
|
+
}
|
|
7158
|
+
Object.defineProperty(Cache.prototype, "size", {
|
|
7159
|
+
/**
|
|
7160
|
+
* The number of cached [key,value] results.
|
|
7161
|
+
*/
|
|
7162
|
+
get: function () {
|
|
7163
|
+
return this.keys.length;
|
|
7164
|
+
},
|
|
7165
|
+
enumerable: false,
|
|
7166
|
+
configurable: true
|
|
7167
|
+
});
|
|
7168
|
+
Object.defineProperty(Cache.prototype, "snapshot", {
|
|
7169
|
+
/**
|
|
7170
|
+
* A copy of the cache at a moment in time. This is useful
|
|
7171
|
+
* to compare changes over time, since the cache mutates
|
|
7172
|
+
* internally for performance reasons.
|
|
7173
|
+
*/
|
|
7174
|
+
get: function () {
|
|
7175
|
+
return {
|
|
7176
|
+
keys: cloneArray(this.keys),
|
|
7177
|
+
size: this.size,
|
|
7178
|
+
values: cloneArray(this.values),
|
|
7179
|
+
};
|
|
7180
|
+
},
|
|
7181
|
+
enumerable: false,
|
|
7182
|
+
configurable: true
|
|
7183
|
+
});
|
|
7184
|
+
/**
|
|
7185
|
+
* Gets the matching key index when a custom key matcher is used.
|
|
7186
|
+
*/
|
|
7187
|
+
Cache.prototype._getKeyIndexFromMatchingKey = function (keyToMatch) {
|
|
7188
|
+
var _a = this.options, isMatchingKey = _a.isMatchingKey, maxSize = _a.maxSize;
|
|
7189
|
+
var keys = this.keys;
|
|
7190
|
+
var keysLength = keys.length;
|
|
7191
|
+
if (!keysLength) {
|
|
7192
|
+
return -1;
|
|
7193
|
+
}
|
|
7194
|
+
if (isMatchingKey(keys[0], keyToMatch)) {
|
|
7195
|
+
return 0;
|
|
7196
|
+
}
|
|
7197
|
+
if (maxSize > 1) {
|
|
7198
|
+
for (var index = 1; index < keysLength; index++) {
|
|
7199
|
+
if (isMatchingKey(keys[index], keyToMatch)) {
|
|
7200
|
+
return index;
|
|
7201
|
+
}
|
|
7202
|
+
}
|
|
7203
|
+
}
|
|
7204
|
+
return -1;
|
|
7205
|
+
};
|
|
7206
|
+
/**
|
|
7207
|
+
* Gets the matching key index when multiple keys are used.
|
|
7208
|
+
*/
|
|
7209
|
+
Cache.prototype._getKeyIndexForMany = function (keyToMatch) {
|
|
7210
|
+
var isEqual = this.options.isEqual;
|
|
7211
|
+
var keys = this.keys;
|
|
7212
|
+
var keysLength = keys.length;
|
|
7213
|
+
if (!keysLength) {
|
|
7214
|
+
return -1;
|
|
7215
|
+
}
|
|
7216
|
+
if (keysLength === 1) {
|
|
7217
|
+
return this._getKeyIndexForSingle(keyToMatch);
|
|
7218
|
+
}
|
|
7219
|
+
var keyLength = keyToMatch.length;
|
|
7220
|
+
var existingKey;
|
|
7221
|
+
var argIndex;
|
|
7222
|
+
if (keyLength > 1) {
|
|
7223
|
+
for (var index = 0; index < keysLength; index++) {
|
|
7224
|
+
existingKey = keys[index];
|
|
7225
|
+
if (existingKey.length === keyLength) {
|
|
7226
|
+
argIndex = 0;
|
|
7227
|
+
for (; argIndex < keyLength; argIndex++) {
|
|
7228
|
+
if (!isEqual(existingKey[argIndex], keyToMatch[argIndex])) {
|
|
7229
|
+
break;
|
|
7230
|
+
}
|
|
7231
|
+
}
|
|
7232
|
+
if (argIndex === keyLength) {
|
|
7233
|
+
return index;
|
|
7234
|
+
}
|
|
7235
|
+
}
|
|
7236
|
+
}
|
|
7237
|
+
}
|
|
7238
|
+
else {
|
|
7239
|
+
for (var index = 0; index < keysLength; index++) {
|
|
7240
|
+
existingKey = keys[index];
|
|
7241
|
+
if (existingKey.length === keyLength &&
|
|
7242
|
+
isEqual(existingKey[0], keyToMatch[0])) {
|
|
7243
|
+
return index;
|
|
7244
|
+
}
|
|
7245
|
+
}
|
|
7246
|
+
}
|
|
7247
|
+
return -1;
|
|
7248
|
+
};
|
|
7249
|
+
/**
|
|
7250
|
+
* Gets the matching key index when a single key is used.
|
|
7251
|
+
*/
|
|
7252
|
+
Cache.prototype._getKeyIndexForSingle = function (keyToMatch) {
|
|
7253
|
+
var keys = this.keys;
|
|
7254
|
+
if (!keys.length) {
|
|
7255
|
+
return -1;
|
|
7256
|
+
}
|
|
7257
|
+
var existingKey = keys[0];
|
|
7258
|
+
var length = existingKey.length;
|
|
7259
|
+
if (keyToMatch.length !== length) {
|
|
7260
|
+
return -1;
|
|
7261
|
+
}
|
|
7262
|
+
var isEqual = this.options.isEqual;
|
|
7263
|
+
if (length > 1) {
|
|
7264
|
+
for (var index = 0; index < length; index++) {
|
|
7265
|
+
if (!isEqual(existingKey[index], keyToMatch[index])) {
|
|
7266
|
+
return -1;
|
|
7267
|
+
}
|
|
7268
|
+
}
|
|
7269
|
+
return 0;
|
|
7270
|
+
}
|
|
7271
|
+
return isEqual(existingKey[0], keyToMatch[0]) ? 0 : -1;
|
|
7272
|
+
};
|
|
7273
|
+
/**
|
|
7274
|
+
* Order the array based on a Least-Recently-Used basis.
|
|
7275
|
+
*/
|
|
7276
|
+
Cache.prototype.orderByLru = function (key, value, startingIndex) {
|
|
7277
|
+
var keys = this.keys;
|
|
7278
|
+
var values = this.values;
|
|
7279
|
+
var currentLength = keys.length;
|
|
7280
|
+
var index = startingIndex;
|
|
7281
|
+
while (index--) {
|
|
7282
|
+
keys[index + 1] = keys[index];
|
|
7283
|
+
values[index + 1] = values[index];
|
|
7284
|
+
}
|
|
7285
|
+
keys[0] = key;
|
|
7286
|
+
values[0] = value;
|
|
7287
|
+
var maxSize = this.options.maxSize;
|
|
7288
|
+
if (currentLength === maxSize && startingIndex === currentLength) {
|
|
7289
|
+
keys.pop();
|
|
7290
|
+
values.pop();
|
|
7291
|
+
}
|
|
7292
|
+
else if (startingIndex >= maxSize) {
|
|
7293
|
+
// eslint-disable-next-line no-multi-assign
|
|
7294
|
+
keys.length = values.length = maxSize;
|
|
7295
|
+
}
|
|
7296
|
+
};
|
|
7297
|
+
/**
|
|
7298
|
+
* Update the promise method to auto-remove from cache if rejected, and
|
|
7299
|
+
* if resolved then fire cache hit / changed.
|
|
7300
|
+
*/
|
|
7301
|
+
Cache.prototype.updateAsyncCache = function (memoized) {
|
|
7302
|
+
var _this = this;
|
|
7303
|
+
var _a = this.options, onCacheChange = _a.onCacheChange, onCacheHit = _a.onCacheHit;
|
|
7304
|
+
var firstKey = this.keys[0];
|
|
7305
|
+
var firstValue = this.values[0];
|
|
7306
|
+
this.values[0] = firstValue.then(function (value) {
|
|
7307
|
+
if (_this.shouldUpdateOnHit) {
|
|
7308
|
+
onCacheHit(_this, _this.options, memoized);
|
|
7309
|
+
}
|
|
7310
|
+
if (_this.shouldUpdateOnChange) {
|
|
7311
|
+
onCacheChange(_this, _this.options, memoized);
|
|
7312
|
+
}
|
|
7313
|
+
return value;
|
|
7314
|
+
}, function (error) {
|
|
7315
|
+
var keyIndex = _this.getKeyIndex(firstKey);
|
|
7316
|
+
if (keyIndex !== -1) {
|
|
7317
|
+
_this.keys.splice(keyIndex, 1);
|
|
7318
|
+
_this.values.splice(keyIndex, 1);
|
|
7319
|
+
}
|
|
7320
|
+
throw error;
|
|
7321
|
+
});
|
|
7322
|
+
};
|
|
7323
|
+
return Cache;
|
|
7324
|
+
}());
|
|
7325
|
+
|
|
7326
|
+
function createMemoizedFunction(fn, options) {
|
|
7327
|
+
if (options === void 0) { options = {}; }
|
|
7328
|
+
if (isMemoized(fn)) {
|
|
7329
|
+
return createMemoizedFunction(fn.fn, mergeOptions(fn.options, options));
|
|
7330
|
+
}
|
|
7331
|
+
if (typeof fn !== 'function') {
|
|
7332
|
+
throw new TypeError('You must pass a function to `memoize`.');
|
|
7333
|
+
}
|
|
7334
|
+
var _a = options.isEqual, isEqual = _a === void 0 ? isSameValueZero : _a, isMatchingKey = options.isMatchingKey, _b = options.isPromise, isPromise = _b === void 0 ? false : _b, _c = options.maxSize, maxSize = _c === void 0 ? 1 : _c, onCacheAdd = options.onCacheAdd, onCacheChange = options.onCacheChange, onCacheHit = options.onCacheHit, transformKey = options.transformKey;
|
|
7335
|
+
var normalizedOptions = mergeOptions({
|
|
7336
|
+
isEqual: isEqual,
|
|
7337
|
+
isMatchingKey: isMatchingKey,
|
|
7338
|
+
isPromise: isPromise,
|
|
7339
|
+
maxSize: maxSize,
|
|
7340
|
+
onCacheAdd: onCacheAdd,
|
|
7341
|
+
onCacheChange: onCacheChange,
|
|
7342
|
+
onCacheHit: onCacheHit,
|
|
7343
|
+
transformKey: transformKey,
|
|
7344
|
+
}, getCustomOptions(options));
|
|
7345
|
+
var cache = new Cache(normalizedOptions);
|
|
7346
|
+
var keys = cache.keys, values = cache.values, canTransformKey = cache.canTransformKey, shouldCloneArguments = cache.shouldCloneArguments, shouldUpdateOnAdd = cache.shouldUpdateOnAdd, shouldUpdateOnChange = cache.shouldUpdateOnChange, shouldUpdateOnHit = cache.shouldUpdateOnHit;
|
|
7347
|
+
var memoized = function () {
|
|
7348
|
+
var key = shouldCloneArguments
|
|
7349
|
+
? cloneArray(arguments)
|
|
7350
|
+
: arguments;
|
|
7351
|
+
if (canTransformKey) {
|
|
7352
|
+
key = transformKey(key);
|
|
7353
|
+
}
|
|
7354
|
+
var keyIndex = keys.length ? cache.getKeyIndex(key) : -1;
|
|
7355
|
+
if (keyIndex !== -1) {
|
|
7356
|
+
if (shouldUpdateOnHit) {
|
|
7357
|
+
onCacheHit(cache, normalizedOptions, memoized);
|
|
7358
|
+
}
|
|
7359
|
+
if (keyIndex) {
|
|
7360
|
+
cache.orderByLru(keys[keyIndex], values[keyIndex], keyIndex);
|
|
7361
|
+
if (shouldUpdateOnChange) {
|
|
7362
|
+
onCacheChange(cache, normalizedOptions, memoized);
|
|
7363
|
+
}
|
|
7364
|
+
}
|
|
7365
|
+
}
|
|
7366
|
+
else {
|
|
7367
|
+
var newValue = fn.apply(this, arguments);
|
|
7368
|
+
var newKey = shouldCloneArguments
|
|
7369
|
+
? key
|
|
7370
|
+
: cloneArray(arguments);
|
|
7371
|
+
cache.orderByLru(newKey, newValue, keys.length);
|
|
7372
|
+
if (isPromise) {
|
|
7373
|
+
cache.updateAsyncCache(memoized);
|
|
7374
|
+
}
|
|
7375
|
+
if (shouldUpdateOnAdd) {
|
|
7376
|
+
onCacheAdd(cache, normalizedOptions, memoized);
|
|
7377
|
+
}
|
|
7378
|
+
if (shouldUpdateOnChange) {
|
|
7379
|
+
onCacheChange(cache, normalizedOptions, memoized);
|
|
7380
|
+
}
|
|
7381
|
+
}
|
|
7382
|
+
return values[0];
|
|
7383
|
+
};
|
|
7384
|
+
memoized.cache = cache;
|
|
7385
|
+
memoized.fn = fn;
|
|
7386
|
+
memoized.isMemoized = true;
|
|
7387
|
+
memoized.options = normalizedOptions;
|
|
7388
|
+
return memoized;
|
|
7389
|
+
}
|
|
7390
|
+
|
|
7391
|
+
return createMemoizedFunction;
|
|
7392
|
+
|
|
7393
|
+
}));
|
|
7394
|
+
|
|
7395
|
+
} (microMemoize));
|
|
7396
|
+
|
|
7397
|
+
var memoize = microMemoize.exports;
|
|
7398
|
+
|
|
7399
|
+
const TOKEN_2022_PROGRAM_ID = new PublicKey("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb");
|
|
7031
7400
|
const TOKEN_METADATA_PROGRAM_ID = new PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s");
|
|
7032
7401
|
const TOKEN_PROGRAM_ID = new PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
|
|
7033
7402
|
const ASSOCIATED_TOKEN_PROGRAM_ID = new PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");
|
|
@@ -7101,35 +7470,43 @@ const deBridgeSettings = {
|
|
|
7101
7470
|
getNoBridgeFeeAddress: (SETTINGS_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(deBridgeSettings$1.Seeds.NO_BRIDGE_FEE_INFO)], SETTINGS_PROGRAM_ID),
|
|
7102
7471
|
};
|
|
7103
7472
|
const DlnSrc = {
|
|
7104
|
-
getStateAccount: (
|
|
7105
|
-
getNonceAccount: (maker,
|
|
7473
|
+
getStateAccount: (DLN_SRC_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(dlnSrc$1.Seeds.STATE)], DLN_SRC_PROGRAM_ID),
|
|
7474
|
+
getNonceAccount: (maker, DLN_SRC_PROGRAM_ID) => PublicKey.findProgramAddressSync([
|
|
7106
7475
|
buffer.Buffer.from(dlnSrc$1.Seeds.NONCE),
|
|
7107
7476
|
isBuffer(maker) ? maker : maker.toBuffer(),
|
|
7108
|
-
],
|
|
7109
|
-
getGiveOrderStateAccount: (orderId,
|
|
7110
|
-
getAuthorizedNativeSenderAddress: (chainId,
|
|
7111
|
-
getGiveOrderWalletAddress: (orderId,
|
|
7112
|
-
getFeeLedgerWalletAddress: (tokenMint,
|
|
7477
|
+
], DLN_SRC_PROGRAM_ID),
|
|
7478
|
+
getGiveOrderStateAccount: (orderId, DLN_SRC_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(dlnSrc$1.Seeds.ORDER_STATE), orderId], DLN_SRC_PROGRAM_ID),
|
|
7479
|
+
getAuthorizedNativeSenderAddress: (chainId, DLN_SRC_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(dlnSrc$1.Seeds.AUTHORIZED_NATIVE_SENDER), chainId], DLN_SRC_PROGRAM_ID),
|
|
7480
|
+
getGiveOrderWalletAddress: (orderId, DLN_SRC_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(dlnSrc$1.Seeds.GIVE_ORDER_WALLET), orderId], DLN_SRC_PROGRAM_ID),
|
|
7481
|
+
getFeeLedgerWalletAddress: (tokenMint, DLN_SRC_PROGRAM_ID) => PublicKey.findProgramAddressSync([
|
|
7113
7482
|
buffer.Buffer.from(dlnSrc$1.Seeds.FEE_LEDGER_WALLET),
|
|
7114
7483
|
tokenMint.toBuffer(),
|
|
7115
|
-
],
|
|
7116
|
-
getFeeLedgerAddress: (
|
|
7484
|
+
], DLN_SRC_PROGRAM_ID),
|
|
7485
|
+
getFeeLedgerAddress: (DLN_SRC_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(dlnSrc$1.Seeds.FEE_LEDGER)], DLN_SRC_PROGRAM_ID),
|
|
7117
7486
|
};
|
|
7118
7487
|
const DlnDst = {
|
|
7119
|
-
|
|
7120
|
-
|
|
7121
|
-
|
|
7122
|
-
|
|
7488
|
+
getStateAddress: (DLN_DST_PROGRAM_ID) => {
|
|
7489
|
+
PublicKey.findProgramAddressSync([buffer.Buffer.from(dlnDst$1.Seeds.STATE)], DLN_DST_PROGRAM_ID);
|
|
7490
|
+
},
|
|
7491
|
+
getAuthorizedSrcContractAddress: (chainId, DLN_DST_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(dlnDst$1.Seeds.AUTHORIZED_SRC_CONTRACT), chainId], DLN_DST_PROGRAM_ID),
|
|
7492
|
+
getAuthorizedDstNativeSenderAddress: (DLN_DST_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(dlnDst$1.Seeds.AUTHORIZED_DST_NATIVE_SENDER)], DLN_DST_PROGRAM_ID),
|
|
7493
|
+
getTakeOrderStateAddress: (orderId, DLN_DST_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(dlnDst$1.Seeds.ORDER_STATE), orderId], DLN_DST_PROGRAM_ID),
|
|
7494
|
+
getTakePatchAddress: (orderId, DLN_DST_PROGRAM_ID) => PublicKey.findProgramAddressSync([buffer.Buffer.from(dlnDst$1.Seeds.TAKE_PATCH), orderId], DLN_DST_PROGRAM_ID),
|
|
7123
7495
|
};
|
|
7124
7496
|
function wrapFn(fn, arg) {
|
|
7125
7497
|
return (...args) => fn(...args, arg);
|
|
7126
7498
|
}
|
|
7127
7499
|
class Resolver {
|
|
7128
|
-
constructor(programId, obj) {
|
|
7500
|
+
constructor(programId, obj, memoizeList) {
|
|
7129
7501
|
this.programId = new PublicKey(programId);
|
|
7130
7502
|
let methods = {};
|
|
7131
7503
|
for (let [fnName, fn] of Object.entries(obj)) {
|
|
7132
|
-
|
|
7504
|
+
if (fnName in memoizeList) {
|
|
7505
|
+
methods[fnName] = memoize(wrapFn(fn, this.programId), Object.assign({}, memoizeList[fnName]));
|
|
7506
|
+
}
|
|
7507
|
+
else {
|
|
7508
|
+
methods[fnName] = wrapFn(fn, this.programId);
|
|
7509
|
+
}
|
|
7133
7510
|
}
|
|
7134
7511
|
this.methods = methods;
|
|
7135
7512
|
}
|
|
@@ -7145,9 +7522,42 @@ class ResolverContainer2 {
|
|
|
7145
7522
|
this.methods = methods;
|
|
7146
7523
|
}
|
|
7147
7524
|
}
|
|
7148
|
-
const DeBridgeResolver = (programId, settingsProgramId) =>
|
|
7149
|
-
const
|
|
7150
|
-
|
|
7525
|
+
const DeBridgeResolver = (programId, settingsProgramId) => {
|
|
7526
|
+
const deBridgeMemoizeList = {
|
|
7527
|
+
"getClaimMarkerAddress": {},
|
|
7528
|
+
"getNonceAddress": {},
|
|
7529
|
+
"getMintAuthorityAddress": { maxSize: 20 }
|
|
7530
|
+
};
|
|
7531
|
+
const settingsMemoizeList = {
|
|
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": {},
|
|
7541
|
+
};
|
|
7542
|
+
return new ResolverContainer2(new Resolver(programId, deBridge$1, deBridgeMemoizeList), new Resolver(settingsProgramId, deBridgeSettings, settingsMemoizeList));
|
|
7543
|
+
};
|
|
7544
|
+
const dlnSrcResolver = (programId) => {
|
|
7545
|
+
const dlnMemoizeList = {
|
|
7546
|
+
"getStateAccount": {},
|
|
7547
|
+
"getAuthorizedNativeSenderAddress": { maxSize: 10 },
|
|
7548
|
+
"getFeeLedgerAddress": {},
|
|
7549
|
+
"getFeeLedgerWalletAddress": { maxSize: 10 }
|
|
7550
|
+
};
|
|
7551
|
+
return new Resolver(programId, DlnSrc, dlnMemoizeList);
|
|
7552
|
+
};
|
|
7553
|
+
const dlnDstResolver = (programId) => {
|
|
7554
|
+
const dstMemoizeList = {
|
|
7555
|
+
"getAuthorizedSrcContractAddress": { maxSize: 10 },
|
|
7556
|
+
"getAuthorizedDstNativeSenderAddress": {},
|
|
7557
|
+
"getStateAddress": {},
|
|
7558
|
+
};
|
|
7559
|
+
return new Resolver(programId, DlnDst, dstMemoizeList);
|
|
7560
|
+
};
|
|
7151
7561
|
|
|
7152
7562
|
var Layout$1 = {};
|
|
7153
7563
|
|
|
@@ -9660,7 +10070,11 @@ function createAssociatedWalletInstruction(tokenMint, associatedAccount, owner,
|
|
|
9660
10070
|
],
|
|
9661
10071
|
});
|
|
9662
10072
|
}
|
|
9663
|
-
function parseSplAccount(
|
|
10073
|
+
function parseSplAccount(dataOrInfo) {
|
|
10074
|
+
if (dataOrInfo === null) {
|
|
10075
|
+
return null;
|
|
10076
|
+
}
|
|
10077
|
+
const data = 'executable' in dataOrInfo ? dataOrInfo.data : dataOrInfo;
|
|
9664
10078
|
try {
|
|
9665
10079
|
return AccountLayout.decode(data);
|
|
9666
10080
|
}
|
|
@@ -9882,5 +10296,89 @@ var programs = /*#__PURE__*/Object.freeze({
|
|
|
9882
10296
|
dlnExecutor: dlnExecutor
|
|
9883
10297
|
});
|
|
9884
10298
|
|
|
9885
|
-
|
|
10299
|
+
function simulateTransaction(connection, tx, simulateConfig) {
|
|
10300
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
10301
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
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));
|
|
10303
|
+
const accountsToFetch = addressesToGetDiffFor.length > 0 ? yield connection.getMultipleAccountsInfo(addressesToGetDiffFor) : [];
|
|
10304
|
+
const result = yield connection.simulateTransaction(tx, simulateConfig);
|
|
10305
|
+
const diffMap = new Map();
|
|
10306
|
+
for (const [idx, simulatedAccountInfo] of ((_c = result.value.accounts) !== null && _c !== void 0 ? _c : []).entries()) {
|
|
10307
|
+
const accountAddress = addressesToGetDiffFor[idx];
|
|
10308
|
+
const oldAccountData = (_d = accountsToFetch.at(idx)) !== null && _d !== void 0 ? _d : null;
|
|
10309
|
+
const oldParsedMaybeSpl = (oldAccountData === null || oldAccountData === void 0 ? void 0 : oldAccountData.owner.equals(TOKEN_PROGRAM_ID)) ? parseSplAccount(oldAccountData) : null;
|
|
10310
|
+
const oldSolValue = (_e = oldAccountData === null || oldAccountData === void 0 ? void 0 : oldAccountData.lamports) !== null && _e !== void 0 ? _e : 0;
|
|
10311
|
+
const newSolValue = (_f = simulatedAccountInfo === null || simulatedAccountInfo === void 0 ? void 0 : simulatedAccountInfo.lamports) !== null && _f !== void 0 ? _f : 0;
|
|
10312
|
+
const solDiff = oldSolValue === newSolValue ? null : {
|
|
10313
|
+
before: oldSolValue,
|
|
10314
|
+
after: newSolValue,
|
|
10315
|
+
};
|
|
10316
|
+
let newParsedMaybeSpl = null;
|
|
10317
|
+
if (simulatedAccountInfo) {
|
|
10318
|
+
const [rawData, encoding] = simulatedAccountInfo.data;
|
|
10319
|
+
if (encoding !== "base64")
|
|
10320
|
+
throw new Error("Expected bs64 account data");
|
|
10321
|
+
const artificialAccountInfo = Object.assign(Object.assign({}, simulatedAccountInfo), { owner: new PublicKey(simulatedAccountInfo.owner), data: Buffer.from(rawData, "base64") });
|
|
10322
|
+
newParsedMaybeSpl = artificialAccountInfo.owner.equals(TOKEN_PROGRAM_ID) ? parseSplAccount(artificialAccountInfo) : null;
|
|
10323
|
+
}
|
|
10324
|
+
let splDiff = null;
|
|
10325
|
+
// old state is spl token account OR new state is spl token account
|
|
10326
|
+
if (oldParsedMaybeSpl !== null || newParsedMaybeSpl !== null) {
|
|
10327
|
+
if (oldParsedMaybeSpl !== newParsedMaybeSpl) {
|
|
10328
|
+
const token = (newParsedMaybeSpl === null || newParsedMaybeSpl === void 0 ? void 0 : newParsedMaybeSpl.mint) || (oldParsedMaybeSpl === null || oldParsedMaybeSpl === void 0 ? void 0 : oldParsedMaybeSpl.mint);
|
|
10329
|
+
if (token === undefined)
|
|
10330
|
+
throw new Error("Failed to get token from the spl token account");
|
|
10331
|
+
const owner = (newParsedMaybeSpl === null || newParsedMaybeSpl === void 0 ? void 0 : newParsedMaybeSpl.owner) || (oldParsedMaybeSpl === null || oldParsedMaybeSpl === void 0 ? void 0 : oldParsedMaybeSpl.owner);
|
|
10332
|
+
if (owner === undefined)
|
|
10333
|
+
throw new Error("Failed to get owner from the spl token account");
|
|
10334
|
+
splDiff = {
|
|
10335
|
+
before: (_g = oldParsedMaybeSpl === null || oldParsedMaybeSpl === void 0 ? void 0 : oldParsedMaybeSpl.amount) !== null && _g !== void 0 ? _g : BigInt(0),
|
|
10336
|
+
after: (_h = newParsedMaybeSpl === null || newParsedMaybeSpl === void 0 ? void 0 : newParsedMaybeSpl.amount) !== null && _h !== void 0 ? _h : BigInt(0),
|
|
10337
|
+
token,
|
|
10338
|
+
owner,
|
|
10339
|
+
};
|
|
10340
|
+
}
|
|
10341
|
+
}
|
|
10342
|
+
if (splDiff !== null || solDiff !== null) {
|
|
10343
|
+
diffMap.set(accountAddress.toBase58(), {
|
|
10344
|
+
native: solDiff,
|
|
10345
|
+
spl: splDiff,
|
|
10346
|
+
});
|
|
10347
|
+
}
|
|
10348
|
+
}
|
|
10349
|
+
return Object.assign(Object.assign({}, result.value), { diff: diffMap });
|
|
10350
|
+
});
|
|
10351
|
+
}
|
|
10352
|
+
/**
|
|
10353
|
+
* Serializes transaction and returns serialized size
|
|
10354
|
+
* @param transaction tx to get length
|
|
10355
|
+
* @param feePayer optional fee payer
|
|
10356
|
+
* @returns transaction size
|
|
10357
|
+
*/
|
|
10358
|
+
function getTransactionSize(tx) {
|
|
10359
|
+
try {
|
|
10360
|
+
if ("version" in tx) {
|
|
10361
|
+
const txCopy = new VersionedTransaction(tx.message);
|
|
10362
|
+
txCopy.message.recentBlockhash = FAKE_BLOCKHASH;
|
|
10363
|
+
return txCopy.serialize().length;
|
|
10364
|
+
}
|
|
10365
|
+
else {
|
|
10366
|
+
const txCopy = new Transaction(tx);
|
|
10367
|
+
txCopy.feePayer = Keypair.generate().publicKey;
|
|
10368
|
+
txCopy.recentBlockhash = FAKE_BLOCKHASH;
|
|
10369
|
+
return tx.serialize({ verifySignatures: false }).length;
|
|
10370
|
+
}
|
|
10371
|
+
}
|
|
10372
|
+
catch (e) {
|
|
10373
|
+
return null;
|
|
10374
|
+
}
|
|
10375
|
+
}
|
|
10376
|
+
|
|
10377
|
+
var transaction = /*#__PURE__*/Object.freeze({
|
|
10378
|
+
__proto__: null,
|
|
10379
|
+
simulateTransaction: simulateTransaction,
|
|
10380
|
+
getTransactionSize: getTransactionSize
|
|
10381
|
+
});
|
|
10382
|
+
|
|
10383
|
+
export { ASSOCIATED_TOKEN_PROGRAM_ID, DeBridgeResolver, TOKEN_2022_PROGRAM_ID, TOKEN_METADATA_PROGRAM_ID, TOKEN_PROGRAM_ID, WRAPPED_SOL_MINT, constants, crypto, dlnDstResolver, dlnSrcResolver, findAssociatedTokenAddress, findAssociatedTokenAddressSync, getTokenMetadataAddress, helpers, interfaces, programs, spl, transaction as txs };
|
|
9886
10384
|
//# sourceMappingURL=index.js.map
|