@debridge-finance/solana-utils 4.5.3 → 4.5.5
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 +33 -11
- package/dist/browser/index.js.map +1 -1
- package/dist/cjs/crypto.js +29 -8
- package/dist/cjs/crypto.js.map +1 -1
- package/dist/esm/crypto.js +33 -11
- package/dist/esm/crypto.js.map +1 -1
- package/dist/types/crypto.d.ts +9 -7
- package/dist/types/crypto.d.ts.map +1 -1
- package/package.json +2 -1
package/dist/browser/index.js
CHANGED
|
@@ -6943,16 +6943,42 @@ function hashExternalCallBytes(data) {
|
|
|
6943
6943
|
}
|
|
6944
6944
|
return hexToBuffer(solidityKeccak256(["bytes"], [data ? data : buffer.Buffer.from([])]), 32);
|
|
6945
6945
|
}
|
|
6946
|
+
function isSendHashedFlagSet(packedFlags) {
|
|
6947
|
+
const SEND_HASHED_DATA_FLAG_BIT_NUMBER = BigInt(3);
|
|
6948
|
+
const result = (packedFlags >> SEND_HASHED_DATA_FLAG_BIT_NUMBER) & BigInt(1);
|
|
6949
|
+
return result === BigInt(1);
|
|
6950
|
+
}
|
|
6951
|
+
function getShortcutFromAutoParams(params) {
|
|
6952
|
+
var _a, _b, _c;
|
|
6953
|
+
const shortcut = (_a = params.autoParams) === null || _a === void 0 ? void 0 : _a.shortcut;
|
|
6954
|
+
if (shortcut) {
|
|
6955
|
+
return isBuffer(shortcut) ? shortcut : hexToBuffer(shortcut);
|
|
6956
|
+
}
|
|
6957
|
+
else {
|
|
6958
|
+
const flags = BigInt(new BN(((_b = params.autoParams) === null || _b === void 0 ? void 0 : _b.flags) || 0).toNumber());
|
|
6959
|
+
const data = (_c = params.autoParams) === null || _c === void 0 ? void 0 : _c.data;
|
|
6960
|
+
if (!data)
|
|
6961
|
+
return hashExternalCallBytes(data);
|
|
6962
|
+
if (isSendHashedFlagSet(flags)) {
|
|
6963
|
+
const result = isBuffer(data) ? data : hexToBuffer(data);
|
|
6964
|
+
if (result.length !== 32) {
|
|
6965
|
+
throw new Error(`Incorrect autoParams.data length for SEND_HASHED_DATA_FLAG`);
|
|
6966
|
+
}
|
|
6967
|
+
return result;
|
|
6968
|
+
}
|
|
6969
|
+
return hashExternalCallBytes(data);
|
|
6970
|
+
}
|
|
6971
|
+
}
|
|
6946
6972
|
/**
|
|
6947
6973
|
* Hashes submission for provided data
|
|
6948
6974
|
* @param params data to hash
|
|
6949
6975
|
* @returns submissionId from provided params
|
|
6950
6976
|
*/
|
|
6951
6977
|
function hashSubmissionIdRaw(params) {
|
|
6952
|
-
var _a, _b
|
|
6978
|
+
var _a, _b;
|
|
6953
6979
|
let packParams = [
|
|
6954
6980
|
"uint256", // submission prefix
|
|
6955
|
-
"
|
|
6981
|
+
"bytes32", // bridge_id
|
|
6956
6982
|
"uint256", // source_chain_id
|
|
6957
6983
|
"uint256", // target_chain_id
|
|
6958
6984
|
"uint256", // amount
|
|
@@ -6964,7 +6990,7 @@ function hashSubmissionIdRaw(params) {
|
|
|
6964
6990
|
: typeof params.receiver === "string"
|
|
6965
6991
|
? params.receiver.startsWith("0x")
|
|
6966
6992
|
? hexToBuffer(params.receiver)
|
|
6967
|
-
: new PublicKey(params.receiver)
|
|
6993
|
+
: new PublicKey(params.receiver).toBuffer()
|
|
6968
6994
|
: new PublicKey(params.receiver).toBuffer();
|
|
6969
6995
|
let packData = [
|
|
6970
6996
|
SUBMISSION_PREFIX,
|
|
@@ -6979,21 +7005,17 @@ function hashSubmissionIdRaw(params) {
|
|
|
6979
7005
|
packParams = packParams.concat([
|
|
6980
7006
|
"uint256", // execution fee
|
|
6981
7007
|
"uint256", // flag
|
|
6982
|
-
"
|
|
7008
|
+
"bytes32", // fallback hash
|
|
6983
7009
|
"uint256", // ext call data hash
|
|
6984
7010
|
"uint256", // native sender hash
|
|
6985
7011
|
]);
|
|
6986
|
-
const shortcut = (
|
|
6987
|
-
? isBuffer(params.autoParams.shortcut)
|
|
6988
|
-
? params.autoParams.shortcut
|
|
6989
|
-
: hexToBuffer(params.autoParams.shortcut)
|
|
6990
|
-
: hashExternalCallBytes((_b = params === null || params === void 0 ? void 0 : params.autoParams) === null || _b === void 0 ? void 0 : _b.data);
|
|
7012
|
+
const shortcut = getShortcutFromAutoParams(params);
|
|
6991
7013
|
const fallback = params.autoParams.fallbackAddress.startsWith("0x")
|
|
6992
7014
|
? hexToBuffer(params.autoParams.fallbackAddress)
|
|
6993
7015
|
: new PublicKey(params.autoParams.fallbackAddress).toBuffer();
|
|
6994
7016
|
packData = packData.concat([
|
|
6995
|
-
new BN(((
|
|
6996
|
-
new BN(((
|
|
7017
|
+
new BN(((_a = params === null || params === void 0 ? void 0 : params.autoParams) === null || _a === void 0 ? void 0 : _a.executionFee) || 0).toArray("be", 32),
|
|
7018
|
+
new BN(((_b = params.autoParams) === null || _b === void 0 ? void 0 : _b.flags) || 0).toArray("be", 32),
|
|
6997
7019
|
hashExternalCallBytes(fallback),
|
|
6998
7020
|
shortcut,
|
|
6999
7021
|
hashExternalCallBytes(params.autoParams.nativeSender),
|