@solana/kit 5.0.1-canary-20251119225544 → 5.1.0-canary-20251204151413
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/index.browser.cjs +7 -0
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.mjs +1 -0
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.development.js +947 -25
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.mjs +1 -0
- package/dist/index.native.mjs.map +1 -1
- package/dist/index.node.cjs +7 -0
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs +1 -0
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.production.min.js +691 -644
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +21 -20
|
@@ -159,6 +159,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
159
159
|
var SOLANA_ERROR__OFFCHAIN_MESSAGE__UNEXPECTED_VERSION = 5607014;
|
|
160
160
|
var SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATORIES_MUST_BE_SORTED = 5607015;
|
|
161
161
|
var SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATORIES_MUST_BE_UNIQUE = 5607016;
|
|
162
|
+
var SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATURE_VERIFICATION_FAILURE = 5607017;
|
|
162
163
|
var SOLANA_ERROR__TRANSACTION__INVOKED_PROGRAMS_CANNOT_PAY_FEES = 5663e3;
|
|
163
164
|
var SOLANA_ERROR__TRANSACTION__INVOKED_PROGRAMS_MUST_NOT_BE_WRITABLE = 5663001;
|
|
164
165
|
var SOLANA_ERROR__TRANSACTION__EXPECTED_BLOCKHASH_LIFETIME = 5663002;
|
|
@@ -427,6 +428,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
427
428
|
[SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATORIES_MUST_BE_SORTED]: "The signatories of this offchain message must be listed in lexicographical order",
|
|
428
429
|
[SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATORIES_MUST_BE_UNIQUE]: "An address must be listed no more than once among the signatories of an offchain message",
|
|
429
430
|
[SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATURES_MISSING]: "Offchain message is missing signatures for addresses: $addresses.",
|
|
431
|
+
[SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATURE_VERIFICATION_FAILURE]: "Offchain message signature verification failed. Signature mismatch for required signatories [$signatoriesWithInvalidSignatures]. Missing signatures for signatories [$signatoriesWithMissingSignatures]",
|
|
430
432
|
[SOLANA_ERROR__OFFCHAIN_MESSAGE__RESTRICTED_ASCII_BODY_CHARACTER_OUT_OF_RANGE]: "The message body provided contains characters whose codes fall outside the allowed range. In order to ensure clear-signing compatiblity with hardware wallets, the message may only contain line feeds and characters in the range [\\x20-\\x7e].",
|
|
431
433
|
[SOLANA_ERROR__OFFCHAIN_MESSAGE__UNEXPECTED_VERSION]: "Expected offchain message version $expectedVersion. Got $actualVersion.",
|
|
432
434
|
[SOLANA_ERROR__OFFCHAIN_MESSAGE__VERSION_NUMBER_NOT_SUPPORTED]: "This version of Kit does not support decoding offchain messages with version $unsupportedVersion. The current max supported version is 0.",
|
|
@@ -917,8 +919,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
917
919
|
var fixBytes = (bytes, length) => padBytes(bytes.length <= length ? bytes : bytes.slice(0, length), length);
|
|
918
920
|
function containsBytes(data, bytes, offset) {
|
|
919
921
|
const slice = offset === 0 && data.length === bytes.length ? data : data.slice(offset, offset + bytes.length);
|
|
920
|
-
|
|
921
|
-
|
|
922
|
+
return bytesEqual(slice, bytes);
|
|
923
|
+
}
|
|
924
|
+
function bytesEqual(bytes1, bytes2) {
|
|
925
|
+
return bytes1.length === bytes2.length && bytes1.every((value, index) => value === bytes2[index]);
|
|
922
926
|
}
|
|
923
927
|
function getEncodedSize(value, encoder) {
|
|
924
928
|
return "fixedSize" in encoder ? encoder.fixedSize : encoder.getSizeFromValue(value);
|
|
@@ -992,7 +996,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
992
996
|
};
|
|
993
997
|
}
|
|
994
998
|
function addEncoderSentinel(encoder, sentinel) {
|
|
995
|
-
const write = (value, bytes, offset) => {
|
|
999
|
+
const write = ((value, bytes, offset) => {
|
|
996
1000
|
const encoderBytes = encoder.encode(value);
|
|
997
1001
|
if (findSentinelIndex(encoderBytes, sentinel) >= 0) {
|
|
998
1002
|
throw new SolanaError(SOLANA_ERROR__CODECS__ENCODED_BYTES_MUST_NOT_INCLUDE_SENTINEL, {
|
|
@@ -1007,7 +1011,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1007
1011
|
bytes.set(sentinel, offset);
|
|
1008
1012
|
offset += sentinel.length;
|
|
1009
1013
|
return offset;
|
|
1010
|
-
};
|
|
1014
|
+
});
|
|
1011
1015
|
if (isFixedSize(encoder)) {
|
|
1012
1016
|
return createEncoder({ ...encoder, fixedSize: encoder.fixedSize + sentinel.length, write });
|
|
1013
1017
|
}
|
|
@@ -1019,7 +1023,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1019
1023
|
});
|
|
1020
1024
|
}
|
|
1021
1025
|
function addDecoderSentinel(decoder, sentinel) {
|
|
1022
|
-
const read = (bytes, offset) => {
|
|
1026
|
+
const read = ((bytes, offset) => {
|
|
1023
1027
|
const candidateBytes = offset === 0 ? bytes : bytes.slice(offset);
|
|
1024
1028
|
const sentinelIndex = findSentinelIndex(candidateBytes, sentinel);
|
|
1025
1029
|
if (sentinelIndex === -1) {
|
|
@@ -1032,7 +1036,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1032
1036
|
}
|
|
1033
1037
|
const preSentinelBytes = candidateBytes.slice(0, sentinelIndex);
|
|
1034
1038
|
return [decoder.decode(preSentinelBytes), offset + preSentinelBytes.length + sentinel.length];
|
|
1035
|
-
};
|
|
1039
|
+
});
|
|
1036
1040
|
if (isFixedSize(decoder)) {
|
|
1037
1041
|
return createDecoder({ ...decoder, fixedSize: decoder.fixedSize + sentinel.length, read });
|
|
1038
1042
|
}
|
|
@@ -1082,12 +1086,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1082
1086
|
}
|
|
1083
1087
|
function addEncoderSizePrefix(encoder, prefix) {
|
|
1084
1088
|
var _a, _b;
|
|
1085
|
-
const write = (value, bytes, offset) => {
|
|
1089
|
+
const write = ((value, bytes, offset) => {
|
|
1086
1090
|
const encoderBytes = encoder.encode(value);
|
|
1087
1091
|
offset = prefix.write(encoderBytes.length, bytes, offset);
|
|
1088
1092
|
bytes.set(encoderBytes, offset);
|
|
1089
1093
|
return offset + encoderBytes.length;
|
|
1090
|
-
};
|
|
1094
|
+
});
|
|
1091
1095
|
if (isFixedSize(prefix) && isFixedSize(encoder)) {
|
|
1092
1096
|
return createEncoder({ ...encoder, fixedSize: prefix.fixedSize + encoder.fixedSize, write });
|
|
1093
1097
|
}
|
|
@@ -1106,7 +1110,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1106
1110
|
}
|
|
1107
1111
|
function addDecoderSizePrefix(decoder, prefix) {
|
|
1108
1112
|
var _a, _b;
|
|
1109
|
-
const read = (bytes, offset) => {
|
|
1113
|
+
const read = ((bytes, offset) => {
|
|
1110
1114
|
const [bigintSize, decoderOffset] = prefix.read(bytes, offset);
|
|
1111
1115
|
const size = Number(bigintSize);
|
|
1112
1116
|
offset = decoderOffset;
|
|
@@ -1115,7 +1119,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1115
1119
|
}
|
|
1116
1120
|
assertByteArrayHasEnoughBytesForCodec("addDecoderSizePrefix", size, bytes);
|
|
1117
1121
|
return [decoder.decode(bytes), offset + size];
|
|
1118
|
-
};
|
|
1122
|
+
});
|
|
1119
1123
|
if (isFixedSize(prefix) && isFixedSize(decoder)) {
|
|
1120
1124
|
return createDecoder({ ...decoder, fixedSize: prefix.fixedSize + decoder.fixedSize, read });
|
|
1121
1125
|
}
|
|
@@ -2028,7 +2032,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2028
2032
|
});
|
|
2029
2033
|
}
|
|
2030
2034
|
const programAddressBytes = encode(programAddress);
|
|
2031
|
-
if (programAddressBytes.length >= PDA_MARKER_BYTES.length && programAddressBytes.slice(-PDA_MARKER_BYTES.length)
|
|
2035
|
+
if (programAddressBytes.length >= PDA_MARKER_BYTES.length && bytesEqual(programAddressBytes.slice(-PDA_MARKER_BYTES.length), new Uint8Array(PDA_MARKER_BYTES))) {
|
|
2032
2036
|
throw new SolanaError(SOLANA_ERROR__ADDRESSES__PDA_ENDS_WITH_PDA_MARKER);
|
|
2033
2037
|
}
|
|
2034
2038
|
const addressBytesBuffer = await crypto.subtle.digest(
|
|
@@ -3166,10 +3170,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
3166
3170
|
var IS_SIGNER_BITMASK = 2;
|
|
3167
3171
|
var IS_WRITABLE_BITMASK = 1;
|
|
3168
3172
|
function downgradeRoleToNonSigner(role) {
|
|
3169
|
-
return role &
|
|
3173
|
+
return role & ~IS_SIGNER_BITMASK;
|
|
3170
3174
|
}
|
|
3171
3175
|
function downgradeRoleToReadonly(role) {
|
|
3172
|
-
return role &
|
|
3176
|
+
return role & ~IS_WRITABLE_BITMASK;
|
|
3173
3177
|
}
|
|
3174
3178
|
function isSignerRole(role) {
|
|
3175
3179
|
return role >= 2;
|
|
@@ -4623,9 +4627,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
4623
4627
|
const transactionSignature = base58Decoder.decode(signatureBytes2);
|
|
4624
4628
|
return transactionSignature;
|
|
4625
4629
|
}
|
|
4626
|
-
function uint8ArraysEqual(arr1, arr2) {
|
|
4627
|
-
return arr1.length === arr2.length && arr1.every((value, index) => value === arr2[index]);
|
|
4628
|
-
}
|
|
4629
4630
|
async function partiallySignTransaction(keyPairs, transaction) {
|
|
4630
4631
|
let newSignatures;
|
|
4631
4632
|
let unexpectedSigners;
|
|
@@ -4642,7 +4643,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
4642
4643
|
return;
|
|
4643
4644
|
}
|
|
4644
4645
|
const newSignature = await signBytes(keyPair.privateKey, transaction.messageBytes);
|
|
4645
|
-
if (existingSignature !== null &&
|
|
4646
|
+
if (existingSignature !== null && bytesEqual(newSignature, existingSignature)) {
|
|
4646
4647
|
return;
|
|
4647
4648
|
}
|
|
4648
4649
|
newSignatures || (newSignatures = {});
|
|
@@ -4935,7 +4936,19 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
4935
4936
|
return Object.freeze({
|
|
4936
4937
|
kind: "single",
|
|
4937
4938
|
message: transactionMessage,
|
|
4938
|
-
status: Object.freeze({
|
|
4939
|
+
status: Object.freeze({
|
|
4940
|
+
context: context != null ? context : {},
|
|
4941
|
+
kind: "successful",
|
|
4942
|
+
signature: getSignatureFromTransaction(transaction),
|
|
4943
|
+
transaction
|
|
4944
|
+
})
|
|
4945
|
+
});
|
|
4946
|
+
}
|
|
4947
|
+
function successfulSingleTransactionPlanResultFromSignature(transactionMessage, signature2, context) {
|
|
4948
|
+
return Object.freeze({
|
|
4949
|
+
kind: "single",
|
|
4950
|
+
message: transactionMessage,
|
|
4951
|
+
status: Object.freeze({ context: context != null ? context : {}, kind: "successful", signature: signature2 })
|
|
4939
4952
|
});
|
|
4940
4953
|
}
|
|
4941
4954
|
function failedSingleTransactionPlanResult(transactionMessage, error) {
|
|
@@ -4952,6 +4965,48 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
4952
4965
|
status: Object.freeze({ kind: "canceled" })
|
|
4953
4966
|
});
|
|
4954
4967
|
}
|
|
4968
|
+
function flattenTransactionPlanResult(result) {
|
|
4969
|
+
const transactionPlanResults = [];
|
|
4970
|
+
function traverse3(result2) {
|
|
4971
|
+
if (result2.kind === "single") {
|
|
4972
|
+
transactionPlanResults.push(result2);
|
|
4973
|
+
} else {
|
|
4974
|
+
for (const subResult of result2.plans) {
|
|
4975
|
+
traverse3(subResult);
|
|
4976
|
+
}
|
|
4977
|
+
}
|
|
4978
|
+
}
|
|
4979
|
+
traverse3(result);
|
|
4980
|
+
return transactionPlanResults;
|
|
4981
|
+
}
|
|
4982
|
+
function summarizeTransactionPlanResult(result) {
|
|
4983
|
+
const successfulTransactions = [];
|
|
4984
|
+
const failedTransactions = [];
|
|
4985
|
+
const canceledTransactions = [];
|
|
4986
|
+
const flattenedResults = flattenTransactionPlanResult(result);
|
|
4987
|
+
for (const singleResult of flattenedResults) {
|
|
4988
|
+
switch (singleResult.status.kind) {
|
|
4989
|
+
case "successful": {
|
|
4990
|
+
successfulTransactions.push(singleResult);
|
|
4991
|
+
break;
|
|
4992
|
+
}
|
|
4993
|
+
case "failed": {
|
|
4994
|
+
failedTransactions.push(singleResult);
|
|
4995
|
+
break;
|
|
4996
|
+
}
|
|
4997
|
+
case "canceled": {
|
|
4998
|
+
canceledTransactions.push(singleResult);
|
|
4999
|
+
break;
|
|
5000
|
+
}
|
|
5001
|
+
}
|
|
5002
|
+
}
|
|
5003
|
+
return Object.freeze({
|
|
5004
|
+
canceledTransactions,
|
|
5005
|
+
failedTransactions,
|
|
5006
|
+
successful: failedTransactions.length === 0 && canceledTransactions.length === 0,
|
|
5007
|
+
successfulTransactions
|
|
5008
|
+
});
|
|
5009
|
+
}
|
|
4955
5010
|
function createTransactionPlanExecutor(config) {
|
|
4956
5011
|
return async (plan, { abortSignal } = {}) => {
|
|
4957
5012
|
var _a, _b;
|
|
@@ -5014,7 +5069,15 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
5014
5069
|
context.executeTransactionMessage(transactionPlan.message, { abortSignal: context.abortSignal }),
|
|
5015
5070
|
context.abortSignal
|
|
5016
5071
|
);
|
|
5017
|
-
|
|
5072
|
+
if ("transaction" in result) {
|
|
5073
|
+
return successfulSingleTransactionPlanResult(transactionPlan.message, result.transaction, result.context);
|
|
5074
|
+
} else {
|
|
5075
|
+
return successfulSingleTransactionPlanResultFromSignature(
|
|
5076
|
+
transactionPlan.message,
|
|
5077
|
+
result.signature,
|
|
5078
|
+
result.context
|
|
5079
|
+
);
|
|
5080
|
+
}
|
|
5018
5081
|
} catch (error) {
|
|
5019
5082
|
context.canceled = true;
|
|
5020
5083
|
return failedSingleTransactionPlanResult(transactionPlan.message, error);
|
|
@@ -5058,7 +5121,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
5058
5121
|
const plan = await traverse2(instructionPlan, {
|
|
5059
5122
|
abortSignal,
|
|
5060
5123
|
createTransactionMessage: config.createTransactionMessage,
|
|
5061
|
-
onTransactionMessageUpdated: (_a = config.onTransactionMessageUpdated) != null ? _a : (msg) => msg,
|
|
5124
|
+
onTransactionMessageUpdated: (_a = config.onTransactionMessageUpdated) != null ? _a : ((msg) => msg),
|
|
5062
5125
|
parent: null,
|
|
5063
5126
|
parentCandidates: []
|
|
5064
5127
|
});
|
|
@@ -5290,6 +5353,764 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
5290
5353
|
}
|
|
5291
5354
|
}
|
|
5292
5355
|
|
|
5356
|
+
// ../offchain-messages/dist/index.browser.mjs
|
|
5357
|
+
function isOffchainMessageApplicationDomain(putativeApplicationDomain) {
|
|
5358
|
+
return isAddress(putativeApplicationDomain);
|
|
5359
|
+
}
|
|
5360
|
+
function assertIsOffchainMessageApplicationDomain(putativeApplicationDomain) {
|
|
5361
|
+
try {
|
|
5362
|
+
assertIsAddress(putativeApplicationDomain);
|
|
5363
|
+
} catch (error) {
|
|
5364
|
+
if (isSolanaError(error, SOLANA_ERROR__ADDRESSES__STRING_LENGTH_OUT_OF_RANGE)) {
|
|
5365
|
+
throw new SolanaError(
|
|
5366
|
+
SOLANA_ERROR__OFFCHAIN_MESSAGE__APPLICATION_DOMAIN_STRING_LENGTH_OUT_OF_RANGE,
|
|
5367
|
+
error.context
|
|
5368
|
+
);
|
|
5369
|
+
}
|
|
5370
|
+
if (isSolanaError(error, SOLANA_ERROR__ADDRESSES__INVALID_BYTE_LENGTH)) {
|
|
5371
|
+
throw new SolanaError(
|
|
5372
|
+
SOLANA_ERROR__OFFCHAIN_MESSAGE__INVALID_APPLICATION_DOMAIN_BYTE_LENGTH,
|
|
5373
|
+
error.context
|
|
5374
|
+
);
|
|
5375
|
+
}
|
|
5376
|
+
throw error;
|
|
5377
|
+
}
|
|
5378
|
+
}
|
|
5379
|
+
function offchainMessageApplicationDomain(putativeApplicationDomain) {
|
|
5380
|
+
assertIsOffchainMessageApplicationDomain(putativeApplicationDomain);
|
|
5381
|
+
return putativeApplicationDomain;
|
|
5382
|
+
}
|
|
5383
|
+
function getOffchainMessageApplicationDomainEncoder() {
|
|
5384
|
+
return transformEncoder(
|
|
5385
|
+
getAddressEncoder(),
|
|
5386
|
+
(putativeApplicationDomain) => offchainMessageApplicationDomain(putativeApplicationDomain)
|
|
5387
|
+
);
|
|
5388
|
+
}
|
|
5389
|
+
function getOffchainMessageApplicationDomainDecoder() {
|
|
5390
|
+
return getAddressDecoder();
|
|
5391
|
+
}
|
|
5392
|
+
function getOffchainMessageApplicationDomainCodec() {
|
|
5393
|
+
return combineCodec(getOffchainMessageApplicationDomainEncoder(), getOffchainMessageApplicationDomainDecoder());
|
|
5394
|
+
}
|
|
5395
|
+
var OFFCHAIN_MESSAGE_SIGNING_DOMAIN_BYTES = new Uint8Array([
|
|
5396
|
+
255,
|
|
5397
|
+
115,
|
|
5398
|
+
111,
|
|
5399
|
+
108,
|
|
5400
|
+
97,
|
|
5401
|
+
110,
|
|
5402
|
+
97,
|
|
5403
|
+
32,
|
|
5404
|
+
111,
|
|
5405
|
+
102,
|
|
5406
|
+
102,
|
|
5407
|
+
99,
|
|
5408
|
+
104,
|
|
5409
|
+
97,
|
|
5410
|
+
105,
|
|
5411
|
+
110
|
|
5412
|
+
]);
|
|
5413
|
+
function getOffchainMessageSigningDomainDecoder() {
|
|
5414
|
+
return getConstantDecoder(OFFCHAIN_MESSAGE_SIGNING_DOMAIN_BYTES);
|
|
5415
|
+
}
|
|
5416
|
+
function getOffchainMessageSigningDomainEncoder() {
|
|
5417
|
+
return getConstantEncoder(OFFCHAIN_MESSAGE_SIGNING_DOMAIN_BYTES);
|
|
5418
|
+
}
|
|
5419
|
+
function getSigningDomainPrefixedDecoder(...fields) {
|
|
5420
|
+
return getHiddenPrefixDecoder(getStructDecoder(fields), [getOffchainMessageSigningDomainDecoder()]);
|
|
5421
|
+
}
|
|
5422
|
+
function getSigningDomainPrefixedEncoder(...fields) {
|
|
5423
|
+
return getHiddenPrefixEncoder(getStructEncoder(fields), [getOffchainMessageSigningDomainEncoder()]);
|
|
5424
|
+
}
|
|
5425
|
+
function getVersionTransformer(fixedVersion) {
|
|
5426
|
+
return (version) => {
|
|
5427
|
+
if (version > 1) {
|
|
5428
|
+
throw new SolanaError(SOLANA_ERROR__OFFCHAIN_MESSAGE__VERSION_NUMBER_NOT_SUPPORTED, {
|
|
5429
|
+
unsupportedVersion: version
|
|
5430
|
+
});
|
|
5431
|
+
}
|
|
5432
|
+
if (fixedVersion != null && version !== fixedVersion) {
|
|
5433
|
+
throw new SolanaError(SOLANA_ERROR__OFFCHAIN_MESSAGE__UNEXPECTED_VERSION, {
|
|
5434
|
+
actualVersion: version,
|
|
5435
|
+
expectedVersion: fixedVersion
|
|
5436
|
+
});
|
|
5437
|
+
}
|
|
5438
|
+
return version;
|
|
5439
|
+
};
|
|
5440
|
+
}
|
|
5441
|
+
function createOffchainMessagePreambleDecoder(version, ...fields) {
|
|
5442
|
+
return getSigningDomainPrefixedDecoder(
|
|
5443
|
+
["version", transformDecoder(getU8Decoder(), getVersionTransformer(version))],
|
|
5444
|
+
...fields
|
|
5445
|
+
);
|
|
5446
|
+
}
|
|
5447
|
+
function createOffchainMessagePreambleEncoder(version, ...fields) {
|
|
5448
|
+
return getSigningDomainPrefixedEncoder(
|
|
5449
|
+
["version", transformEncoder(getU8Encoder(), getVersionTransformer(version))],
|
|
5450
|
+
...fields
|
|
5451
|
+
);
|
|
5452
|
+
}
|
|
5453
|
+
function decodeRequiredSignatoryAddresses(bytes) {
|
|
5454
|
+
const { version, bytesAfterVersion } = getSigningDomainPrefixedDecoder(
|
|
5455
|
+
["version", transformDecoder(getU8Decoder(), getVersionTransformer())],
|
|
5456
|
+
["bytesAfterVersion", getBytesDecoder()]
|
|
5457
|
+
).decode(bytes);
|
|
5458
|
+
return offsetDecoder(
|
|
5459
|
+
transformDecoder(getArrayDecoder(getAddressDecoder(), { size: getU8Decoder() }), (signatoryAddresses) => {
|
|
5460
|
+
if (signatoryAddresses.length === 0) {
|
|
5461
|
+
throw new SolanaError(SOLANA_ERROR__OFFCHAIN_MESSAGE__NUM_REQUIRED_SIGNERS_CANNOT_BE_ZERO);
|
|
5462
|
+
}
|
|
5463
|
+
return signatoryAddresses;
|
|
5464
|
+
}),
|
|
5465
|
+
{
|
|
5466
|
+
preOffset: ({ preOffset }) => preOffset + (version === 0 ? 32 + 1 : 0)
|
|
5467
|
+
}
|
|
5468
|
+
).decode(bytesAfterVersion);
|
|
5469
|
+
}
|
|
5470
|
+
function getSignatoriesComparator() {
|
|
5471
|
+
return (x, y) => {
|
|
5472
|
+
if (x.length !== y.length) {
|
|
5473
|
+
return x.length < y.length ? -1 : 1;
|
|
5474
|
+
}
|
|
5475
|
+
for (let ii = 0; ii < x.length; ii++) {
|
|
5476
|
+
if (x[ii] === y[ii]) {
|
|
5477
|
+
continue;
|
|
5478
|
+
} else {
|
|
5479
|
+
return x[ii] < y[ii] ? -1 : 1;
|
|
5480
|
+
}
|
|
5481
|
+
}
|
|
5482
|
+
return 0;
|
|
5483
|
+
};
|
|
5484
|
+
}
|
|
5485
|
+
function getSignaturesToEncode2(signaturesMap) {
|
|
5486
|
+
const signatures = Object.values(signaturesMap);
|
|
5487
|
+
if (signatures.length === 0) {
|
|
5488
|
+
throw new SolanaError(SOLANA_ERROR__OFFCHAIN_MESSAGE__NUM_ENVELOPE_SIGNATURES_CANNOT_BE_ZERO);
|
|
5489
|
+
}
|
|
5490
|
+
return signatures.map((signature2) => {
|
|
5491
|
+
if (!signature2) {
|
|
5492
|
+
return new Uint8Array(64).fill(0);
|
|
5493
|
+
}
|
|
5494
|
+
return signature2;
|
|
5495
|
+
});
|
|
5496
|
+
}
|
|
5497
|
+
function getSignaturesEncoder2() {
|
|
5498
|
+
return transformEncoder(
|
|
5499
|
+
getArrayEncoder(fixEncoderSize(getBytesEncoder(), 64), { size: getU8Encoder() }),
|
|
5500
|
+
getSignaturesToEncode2
|
|
5501
|
+
);
|
|
5502
|
+
}
|
|
5503
|
+
function getOffchainMessageEnvelopeEncoder() {
|
|
5504
|
+
return transformEncoder(
|
|
5505
|
+
getStructEncoder([
|
|
5506
|
+
["signatures", getSignaturesEncoder2()],
|
|
5507
|
+
["content", getBytesEncoder()]
|
|
5508
|
+
]),
|
|
5509
|
+
(envelope) => {
|
|
5510
|
+
const signaturesMapAddresses = Object.keys(envelope.signatures).map(address);
|
|
5511
|
+
if (signaturesMapAddresses.length === 0) {
|
|
5512
|
+
throw new SolanaError(SOLANA_ERROR__OFFCHAIN_MESSAGE__NUM_ENVELOPE_SIGNATURES_CANNOT_BE_ZERO);
|
|
5513
|
+
}
|
|
5514
|
+
const signatoryAddresses = decodeAndValidateRequiredSignatoryAddresses(envelope.content);
|
|
5515
|
+
const missingRequiredSigners = [];
|
|
5516
|
+
const unexpectedSigners = [];
|
|
5517
|
+
for (const address2 of signatoryAddresses) {
|
|
5518
|
+
if (!signaturesMapAddresses.includes(address2)) {
|
|
5519
|
+
missingRequiredSigners.push(address2);
|
|
5520
|
+
}
|
|
5521
|
+
}
|
|
5522
|
+
for (const address2 of signaturesMapAddresses) {
|
|
5523
|
+
if (!signatoryAddresses.includes(address2)) {
|
|
5524
|
+
unexpectedSigners.push(address2);
|
|
5525
|
+
}
|
|
5526
|
+
}
|
|
5527
|
+
if (missingRequiredSigners.length || unexpectedSigners.length) {
|
|
5528
|
+
throw new SolanaError(SOLANA_ERROR__OFFCHAIN_MESSAGE__ENVELOPE_SIGNERS_MISMATCH, {
|
|
5529
|
+
missingRequiredSigners,
|
|
5530
|
+
unexpectedSigners
|
|
5531
|
+
});
|
|
5532
|
+
}
|
|
5533
|
+
const orderedSignatureMap = {};
|
|
5534
|
+
for (const address2 of signatoryAddresses) {
|
|
5535
|
+
orderedSignatureMap[address2] = envelope.signatures[address2];
|
|
5536
|
+
}
|
|
5537
|
+
return {
|
|
5538
|
+
...envelope,
|
|
5539
|
+
signatures: orderedSignatureMap
|
|
5540
|
+
};
|
|
5541
|
+
}
|
|
5542
|
+
);
|
|
5543
|
+
}
|
|
5544
|
+
function getOffchainMessageEnvelopeDecoder() {
|
|
5545
|
+
return transformDecoder(
|
|
5546
|
+
getStructDecoder([
|
|
5547
|
+
["signatures", getArrayDecoder(fixDecoderSize(getBytesDecoder(), 64), { size: getU8Decoder() })],
|
|
5548
|
+
["content", getBytesDecoder()]
|
|
5549
|
+
]),
|
|
5550
|
+
decodePartiallyDecodedOffchainMessageEnvelope
|
|
5551
|
+
);
|
|
5552
|
+
}
|
|
5553
|
+
function getOffchainMessageEnvelopeCodec() {
|
|
5554
|
+
return combineCodec(getOffchainMessageEnvelopeEncoder(), getOffchainMessageEnvelopeDecoder());
|
|
5555
|
+
}
|
|
5556
|
+
function decodePartiallyDecodedOffchainMessageEnvelope(offchainMessageEnvelope) {
|
|
5557
|
+
const { content, signatures } = offchainMessageEnvelope;
|
|
5558
|
+
if (signatures.length === 0) {
|
|
5559
|
+
throw new SolanaError(SOLANA_ERROR__OFFCHAIN_MESSAGE__NUM_ENVELOPE_SIGNATURES_CANNOT_BE_ZERO);
|
|
5560
|
+
}
|
|
5561
|
+
const signatoryAddresses = decodeAndValidateRequiredSignatoryAddresses(content);
|
|
5562
|
+
if (signatoryAddresses.length !== signatures.length) {
|
|
5563
|
+
throw new SolanaError(SOLANA_ERROR__OFFCHAIN_MESSAGE__NUM_SIGNATURES_MISMATCH, {
|
|
5564
|
+
numRequiredSignatures: signatoryAddresses.length,
|
|
5565
|
+
signatoryAddresses,
|
|
5566
|
+
signaturesLength: signatures.length
|
|
5567
|
+
});
|
|
5568
|
+
}
|
|
5569
|
+
const signaturesMap = {};
|
|
5570
|
+
signatoryAddresses.forEach((address2, index) => {
|
|
5571
|
+
const signatureForAddress = signatures[index];
|
|
5572
|
+
if (signatureForAddress.every((b) => b === 0)) {
|
|
5573
|
+
signaturesMap[address2] = null;
|
|
5574
|
+
} else {
|
|
5575
|
+
signaturesMap[address2] = signatureForAddress;
|
|
5576
|
+
}
|
|
5577
|
+
});
|
|
5578
|
+
return Object.freeze({
|
|
5579
|
+
content,
|
|
5580
|
+
signatures: Object.freeze(signaturesMap)
|
|
5581
|
+
});
|
|
5582
|
+
}
|
|
5583
|
+
function decodeAndValidateRequiredSignatoryAddresses(bytes) {
|
|
5584
|
+
const signatoryAddresses = decodeRequiredSignatoryAddresses(bytes);
|
|
5585
|
+
if (signatoryAddresses.length === 0) {
|
|
5586
|
+
throw new SolanaError(SOLANA_ERROR__OFFCHAIN_MESSAGE__NUM_REQUIRED_SIGNERS_CANNOT_BE_ZERO);
|
|
5587
|
+
}
|
|
5588
|
+
return signatoryAddresses;
|
|
5589
|
+
}
|
|
5590
|
+
var MAX_BODY_BYTES = (
|
|
5591
|
+
// Largest 16-bit unsigned integer
|
|
5592
|
+
65535
|
|
5593
|
+
);
|
|
5594
|
+
var MAX_BODY_BYTES_HARDWARE_WALLET_SIGNABLE = (
|
|
5595
|
+
// Space remaining in the mininum IPv6 MTU after network header overhead
|
|
5596
|
+
1232
|
|
5597
|
+
);
|
|
5598
|
+
var OffchainMessageContentFormat = /* @__PURE__ */ ((OffchainMessageContentFormat3) => {
|
|
5599
|
+
OffchainMessageContentFormat3[OffchainMessageContentFormat3["RESTRICTED_ASCII_1232_BYTES_MAX"] = 0] = "RESTRICTED_ASCII_1232_BYTES_MAX";
|
|
5600
|
+
OffchainMessageContentFormat3[OffchainMessageContentFormat3["UTF8_1232_BYTES_MAX"] = 1] = "UTF8_1232_BYTES_MAX";
|
|
5601
|
+
OffchainMessageContentFormat3[OffchainMessageContentFormat3["UTF8_65535_BYTES_MAX"] = 2] = "UTF8_65535_BYTES_MAX";
|
|
5602
|
+
return OffchainMessageContentFormat3;
|
|
5603
|
+
})(OffchainMessageContentFormat || {});
|
|
5604
|
+
function assertIsOffchainMessageContentRestrictedAsciiOf1232BytesMax(putativeContent) {
|
|
5605
|
+
if (putativeContent.format !== 0) {
|
|
5606
|
+
throw new SolanaError(SOLANA_ERROR__OFFCHAIN_MESSAGE__MESSAGE_FORMAT_MISMATCH, {
|
|
5607
|
+
actualMessageFormat: putativeContent.format,
|
|
5608
|
+
expectedMessageFormat: 0
|
|
5609
|
+
/* RESTRICTED_ASCII_1232_BYTES_MAX */
|
|
5610
|
+
});
|
|
5611
|
+
}
|
|
5612
|
+
if (putativeContent.text.length === 0) {
|
|
5613
|
+
throw new SolanaError(SOLANA_ERROR__OFFCHAIN_MESSAGE__MESSAGE_MUST_BE_NON_EMPTY);
|
|
5614
|
+
}
|
|
5615
|
+
if (isTextRestrictedAscii(putativeContent.text) === false) {
|
|
5616
|
+
throw new SolanaError(SOLANA_ERROR__OFFCHAIN_MESSAGE__RESTRICTED_ASCII_BODY_CHARACTER_OUT_OF_RANGE);
|
|
5617
|
+
}
|
|
5618
|
+
const length = getUtf8Encoder().getSizeFromValue(putativeContent.text);
|
|
5619
|
+
if (length > MAX_BODY_BYTES_HARDWARE_WALLET_SIGNABLE) {
|
|
5620
|
+
throw new SolanaError(SOLANA_ERROR__OFFCHAIN_MESSAGE__MAXIMUM_LENGTH_EXCEEDED, {
|
|
5621
|
+
actualBytes: length,
|
|
5622
|
+
maxBytes: MAX_BODY_BYTES_HARDWARE_WALLET_SIGNABLE
|
|
5623
|
+
});
|
|
5624
|
+
}
|
|
5625
|
+
}
|
|
5626
|
+
function isOffchainMessageContentRestrictedAsciiOf1232BytesMax(putativeContent) {
|
|
5627
|
+
if (putativeContent.format !== 0 || putativeContent.text.length === 0 || isTextRestrictedAscii(putativeContent.text) === false) {
|
|
5628
|
+
return false;
|
|
5629
|
+
}
|
|
5630
|
+
const length = getUtf8Encoder().getSizeFromValue(putativeContent.text);
|
|
5631
|
+
return length <= MAX_BODY_BYTES_HARDWARE_WALLET_SIGNABLE;
|
|
5632
|
+
}
|
|
5633
|
+
function offchainMessageContentRestrictedAsciiOf1232BytesMax(text) {
|
|
5634
|
+
const putativeContent = Object.freeze({
|
|
5635
|
+
format: 0,
|
|
5636
|
+
text
|
|
5637
|
+
});
|
|
5638
|
+
assertIsOffchainMessageContentRestrictedAsciiOf1232BytesMax(putativeContent);
|
|
5639
|
+
return putativeContent;
|
|
5640
|
+
}
|
|
5641
|
+
function assertIsOffchainMessageContentUtf8Of1232BytesMax(putativeContent) {
|
|
5642
|
+
if (putativeContent.text.length === 0) {
|
|
5643
|
+
throw new SolanaError(SOLANA_ERROR__OFFCHAIN_MESSAGE__MESSAGE_MUST_BE_NON_EMPTY);
|
|
5644
|
+
}
|
|
5645
|
+
if (putativeContent.format !== 1) {
|
|
5646
|
+
throw new SolanaError(SOLANA_ERROR__OFFCHAIN_MESSAGE__MESSAGE_FORMAT_MISMATCH, {
|
|
5647
|
+
actualMessageFormat: putativeContent.format,
|
|
5648
|
+
expectedMessageFormat: 1
|
|
5649
|
+
/* UTF8_1232_BYTES_MAX */
|
|
5650
|
+
});
|
|
5651
|
+
}
|
|
5652
|
+
const length = getUtf8Encoder().getSizeFromValue(putativeContent.text);
|
|
5653
|
+
if (length > MAX_BODY_BYTES_HARDWARE_WALLET_SIGNABLE) {
|
|
5654
|
+
throw new SolanaError(SOLANA_ERROR__OFFCHAIN_MESSAGE__MAXIMUM_LENGTH_EXCEEDED, {
|
|
5655
|
+
actualBytes: length,
|
|
5656
|
+
maxBytes: MAX_BODY_BYTES_HARDWARE_WALLET_SIGNABLE
|
|
5657
|
+
});
|
|
5658
|
+
}
|
|
5659
|
+
}
|
|
5660
|
+
function isOffchainMessageContentUtf8Of1232BytesMax(putativeContent) {
|
|
5661
|
+
if (putativeContent.format !== 1 || putativeContent.text.length === 0) {
|
|
5662
|
+
return false;
|
|
5663
|
+
}
|
|
5664
|
+
const length = getUtf8Encoder().getSizeFromValue(putativeContent.text);
|
|
5665
|
+
return length <= MAX_BODY_BYTES_HARDWARE_WALLET_SIGNABLE;
|
|
5666
|
+
}
|
|
5667
|
+
function offchainMessageContentUtf8Of1232BytesMax(text) {
|
|
5668
|
+
const putativeContent = Object.freeze({
|
|
5669
|
+
format: 1,
|
|
5670
|
+
text
|
|
5671
|
+
});
|
|
5672
|
+
assertIsOffchainMessageContentUtf8Of1232BytesMax(putativeContent);
|
|
5673
|
+
return putativeContent;
|
|
5674
|
+
}
|
|
5675
|
+
function assertIsOffchainMessageContentUtf8Of65535BytesMax(putativeContent) {
|
|
5676
|
+
if (putativeContent.format !== 2) {
|
|
5677
|
+
throw new SolanaError(SOLANA_ERROR__OFFCHAIN_MESSAGE__MESSAGE_FORMAT_MISMATCH, {
|
|
5678
|
+
actualMessageFormat: putativeContent.format,
|
|
5679
|
+
expectedMessageFormat: 2
|
|
5680
|
+
/* UTF8_65535_BYTES_MAX */
|
|
5681
|
+
});
|
|
5682
|
+
}
|
|
5683
|
+
if (putativeContent.text.length === 0) {
|
|
5684
|
+
throw new SolanaError(SOLANA_ERROR__OFFCHAIN_MESSAGE__MESSAGE_MUST_BE_NON_EMPTY);
|
|
5685
|
+
}
|
|
5686
|
+
const length = getUtf8Encoder().getSizeFromValue(putativeContent.text);
|
|
5687
|
+
if (length > MAX_BODY_BYTES) {
|
|
5688
|
+
throw new SolanaError(SOLANA_ERROR__OFFCHAIN_MESSAGE__MAXIMUM_LENGTH_EXCEEDED, {
|
|
5689
|
+
actualBytes: length,
|
|
5690
|
+
maxBytes: MAX_BODY_BYTES
|
|
5691
|
+
});
|
|
5692
|
+
}
|
|
5693
|
+
}
|
|
5694
|
+
function isOffchainMessageContentUtf8Of65535BytesMax(putativeContent) {
|
|
5695
|
+
if (putativeContent.format !== 2 || putativeContent.text.length === 0) {
|
|
5696
|
+
return false;
|
|
5697
|
+
}
|
|
5698
|
+
const length = getUtf8Encoder().getSizeFromValue(putativeContent.text);
|
|
5699
|
+
return length <= MAX_BODY_BYTES;
|
|
5700
|
+
}
|
|
5701
|
+
function offchainMessageContentUtf8Of65535BytesMax(text) {
|
|
5702
|
+
const putativeContent = Object.freeze({
|
|
5703
|
+
format: 2,
|
|
5704
|
+
text
|
|
5705
|
+
});
|
|
5706
|
+
assertIsOffchainMessageContentUtf8Of65535BytesMax(putativeContent);
|
|
5707
|
+
return putativeContent;
|
|
5708
|
+
}
|
|
5709
|
+
function isTextRestrictedAscii(putativeRestrictedAsciiString) {
|
|
5710
|
+
return /^[\x20-\x7e]+$/.test(putativeRestrictedAsciiString);
|
|
5711
|
+
}
|
|
5712
|
+
function assertIsOffchainMessageRestrictedAsciiOf1232BytesMax(putativeMessage) {
|
|
5713
|
+
assertIsOffchainMessageContentRestrictedAsciiOf1232BytesMax(putativeMessage.content);
|
|
5714
|
+
}
|
|
5715
|
+
function assertIsOffchainMessageUtf8Of1232BytesMax(putativeMessage) {
|
|
5716
|
+
assertIsOffchainMessageContentUtf8Of1232BytesMax(putativeMessage.content);
|
|
5717
|
+
}
|
|
5718
|
+
function assertIsOffchainMessageUtf8Of65535BytesMax(putativeMessage) {
|
|
5719
|
+
assertIsOffchainMessageContentUtf8Of65535BytesMax(putativeMessage.content);
|
|
5720
|
+
}
|
|
5721
|
+
function getOffchainMessageContentFormatDecoder() {
|
|
5722
|
+
return getEnumDecoder(OffchainMessageContentFormat, {
|
|
5723
|
+
useValuesAsDiscriminators: true
|
|
5724
|
+
});
|
|
5725
|
+
}
|
|
5726
|
+
function getOffchainMessageContentFormatEncoder() {
|
|
5727
|
+
return getEnumEncoder(OffchainMessageContentFormat, {
|
|
5728
|
+
useValuesAsDiscriminators: true
|
|
5729
|
+
});
|
|
5730
|
+
}
|
|
5731
|
+
function getOffchainMessageV0PreambleDecoder() {
|
|
5732
|
+
return createOffchainMessagePreambleDecoder(
|
|
5733
|
+
/* version */
|
|
5734
|
+
0,
|
|
5735
|
+
["applicationDomain", getOffchainMessageApplicationDomainDecoder()],
|
|
5736
|
+
["messageFormat", getOffchainMessageContentFormatDecoder()],
|
|
5737
|
+
[
|
|
5738
|
+
"requiredSignatories",
|
|
5739
|
+
transformDecoder(getArrayDecoder(getAddressDecoder(), { size: getU8Decoder() }), (signatoryAddresses) => {
|
|
5740
|
+
if (signatoryAddresses.length === 0) {
|
|
5741
|
+
throw new SolanaError(SOLANA_ERROR__OFFCHAIN_MESSAGE__NUM_REQUIRED_SIGNERS_CANNOT_BE_ZERO);
|
|
5742
|
+
}
|
|
5743
|
+
return signatoryAddresses.map((address2) => Object.freeze({ address: address2 }));
|
|
5744
|
+
})
|
|
5745
|
+
],
|
|
5746
|
+
["messageLength", getU16Decoder()]
|
|
5747
|
+
);
|
|
5748
|
+
}
|
|
5749
|
+
function getOffchainMessageV0PreambleEncoder() {
|
|
5750
|
+
return createOffchainMessagePreambleEncoder(
|
|
5751
|
+
/* version */
|
|
5752
|
+
0,
|
|
5753
|
+
["applicationDomain", getOffchainMessageApplicationDomainEncoder()],
|
|
5754
|
+
["messageFormat", getOffchainMessageContentFormatEncoder()],
|
|
5755
|
+
[
|
|
5756
|
+
"requiredSignatories",
|
|
5757
|
+
transformEncoder(
|
|
5758
|
+
getArrayEncoder(getAddressEncoder(), { size: getU8Encoder() }),
|
|
5759
|
+
(signatoryAddresses) => {
|
|
5760
|
+
if (signatoryAddresses.length === 0) {
|
|
5761
|
+
throw new SolanaError(SOLANA_ERROR__OFFCHAIN_MESSAGE__NUM_REQUIRED_SIGNERS_CANNOT_BE_ZERO);
|
|
5762
|
+
}
|
|
5763
|
+
return signatoryAddresses.map(({ address: address2 }) => address2);
|
|
5764
|
+
}
|
|
5765
|
+
)
|
|
5766
|
+
],
|
|
5767
|
+
["messageLength", getU16Encoder()]
|
|
5768
|
+
);
|
|
5769
|
+
}
|
|
5770
|
+
function getOffchainMessageV0Decoder() {
|
|
5771
|
+
return transformDecoder(
|
|
5772
|
+
getTupleDecoder([getOffchainMessageV0PreambleDecoder(), getUtf8Decoder()]),
|
|
5773
|
+
([{ messageLength, messageFormat, requiredSignatories, ...preambleRest }, text]) => {
|
|
5774
|
+
const actualLength = getUtf8Encoder().getSizeFromValue(text);
|
|
5775
|
+
if (messageLength !== actualLength) {
|
|
5776
|
+
throw new SolanaError(SOLANA_ERROR__OFFCHAIN_MESSAGE__MESSAGE_LENGTH_MISMATCH, {
|
|
5777
|
+
actualLength,
|
|
5778
|
+
specifiedLength: messageLength
|
|
5779
|
+
});
|
|
5780
|
+
}
|
|
5781
|
+
const offchainMessage = Object.freeze({
|
|
5782
|
+
...preambleRest,
|
|
5783
|
+
content: Object.freeze({
|
|
5784
|
+
format: messageFormat,
|
|
5785
|
+
text
|
|
5786
|
+
}),
|
|
5787
|
+
requiredSignatories: Object.freeze(requiredSignatories)
|
|
5788
|
+
});
|
|
5789
|
+
switch (messageFormat) {
|
|
5790
|
+
case 0: {
|
|
5791
|
+
assertIsOffchainMessageRestrictedAsciiOf1232BytesMax(offchainMessage);
|
|
5792
|
+
return offchainMessage;
|
|
5793
|
+
}
|
|
5794
|
+
case 1: {
|
|
5795
|
+
assertIsOffchainMessageUtf8Of1232BytesMax(offchainMessage);
|
|
5796
|
+
return offchainMessage;
|
|
5797
|
+
}
|
|
5798
|
+
case 2: {
|
|
5799
|
+
assertIsOffchainMessageUtf8Of65535BytesMax(offchainMessage);
|
|
5800
|
+
return offchainMessage;
|
|
5801
|
+
}
|
|
5802
|
+
default: {
|
|
5803
|
+
throw new SolanaError(SOLANA_ERROR__INVARIANT_VIOLATION__SWITCH_MUST_BE_EXHAUSTIVE, {
|
|
5804
|
+
unexpectedValue: messageFormat
|
|
5805
|
+
});
|
|
5806
|
+
}
|
|
5807
|
+
}
|
|
5808
|
+
}
|
|
5809
|
+
);
|
|
5810
|
+
}
|
|
5811
|
+
function getOffchainMessageV0Encoder() {
|
|
5812
|
+
return transformEncoder(
|
|
5813
|
+
getTupleEncoder([getOffchainMessageV0PreambleEncoder(), getUtf8Encoder()]),
|
|
5814
|
+
(offchainMessage) => {
|
|
5815
|
+
const { content, ...preamble } = offchainMessage;
|
|
5816
|
+
switch (offchainMessage.content.format) {
|
|
5817
|
+
case 0: {
|
|
5818
|
+
assertIsOffchainMessageRestrictedAsciiOf1232BytesMax(offchainMessage);
|
|
5819
|
+
break;
|
|
5820
|
+
}
|
|
5821
|
+
case 1: {
|
|
5822
|
+
assertIsOffchainMessageUtf8Of1232BytesMax(offchainMessage);
|
|
5823
|
+
break;
|
|
5824
|
+
}
|
|
5825
|
+
case 2: {
|
|
5826
|
+
assertIsOffchainMessageUtf8Of65535BytesMax(offchainMessage);
|
|
5827
|
+
break;
|
|
5828
|
+
}
|
|
5829
|
+
default: {
|
|
5830
|
+
throw new SolanaError(SOLANA_ERROR__INVARIANT_VIOLATION__SWITCH_MUST_BE_EXHAUSTIVE, {
|
|
5831
|
+
unexpectedValue: offchainMessage.content
|
|
5832
|
+
});
|
|
5833
|
+
}
|
|
5834
|
+
}
|
|
5835
|
+
const messageLength = getUtf8Encoder().getSizeFromValue(content.text);
|
|
5836
|
+
const compiledPreamble = {
|
|
5837
|
+
...preamble,
|
|
5838
|
+
messageFormat: content.format,
|
|
5839
|
+
messageLength
|
|
5840
|
+
};
|
|
5841
|
+
return [compiledPreamble, content.text];
|
|
5842
|
+
}
|
|
5843
|
+
);
|
|
5844
|
+
}
|
|
5845
|
+
function getOffchainMessageV0Codec() {
|
|
5846
|
+
return combineCodec(getOffchainMessageV0Encoder(), getOffchainMessageV0Decoder());
|
|
5847
|
+
}
|
|
5848
|
+
function getOffchainMessageV1PreambleDecoder() {
|
|
5849
|
+
return createOffchainMessagePreambleDecoder(
|
|
5850
|
+
/* version */
|
|
5851
|
+
1,
|
|
5852
|
+
[
|
|
5853
|
+
"requiredSignatories",
|
|
5854
|
+
transformDecoder(
|
|
5855
|
+
getArrayDecoder(fixDecoderSize(getBytesDecoder(), 32), { size: getU8Decoder() }),
|
|
5856
|
+
(signatoryAddressesBytes) => {
|
|
5857
|
+
if (signatoryAddressesBytes.length === 0) {
|
|
5858
|
+
throw new SolanaError(SOLANA_ERROR__OFFCHAIN_MESSAGE__NUM_REQUIRED_SIGNERS_CANNOT_BE_ZERO);
|
|
5859
|
+
}
|
|
5860
|
+
const comparator = getSignatoriesComparator();
|
|
5861
|
+
for (let ii = 0; ii < signatoryAddressesBytes.length - 1; ii++) {
|
|
5862
|
+
switch (comparator(signatoryAddressesBytes[ii], signatoryAddressesBytes[ii + 1])) {
|
|
5863
|
+
case 0:
|
|
5864
|
+
throw new SolanaError(SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATORIES_MUST_BE_UNIQUE);
|
|
5865
|
+
case 1:
|
|
5866
|
+
throw new SolanaError(SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATORIES_MUST_BE_SORTED);
|
|
5867
|
+
}
|
|
5868
|
+
}
|
|
5869
|
+
const addressDecoder = getAddressDecoder();
|
|
5870
|
+
return signatoryAddressesBytes.map(
|
|
5871
|
+
(addressBytes) => Object.freeze({
|
|
5872
|
+
address: addressDecoder.decode(addressBytes)
|
|
5873
|
+
})
|
|
5874
|
+
);
|
|
5875
|
+
}
|
|
5876
|
+
)
|
|
5877
|
+
]
|
|
5878
|
+
);
|
|
5879
|
+
}
|
|
5880
|
+
function getOffchainMessageV1PreambleEncoder() {
|
|
5881
|
+
return createOffchainMessagePreambleEncoder(
|
|
5882
|
+
/* version */
|
|
5883
|
+
1,
|
|
5884
|
+
[
|
|
5885
|
+
"requiredSignatories",
|
|
5886
|
+
transformEncoder(
|
|
5887
|
+
transformEncoder(
|
|
5888
|
+
getArrayEncoder(getBytesEncoder(), { size: getU8Encoder() }),
|
|
5889
|
+
(signatoryAddressesBytes) => {
|
|
5890
|
+
return signatoryAddressesBytes.toSorted(getSignatoriesComparator());
|
|
5891
|
+
}
|
|
5892
|
+
),
|
|
5893
|
+
(signatoryAddresses) => {
|
|
5894
|
+
if (signatoryAddresses.length === 0) {
|
|
5895
|
+
throw new SolanaError(SOLANA_ERROR__OFFCHAIN_MESSAGE__NUM_REQUIRED_SIGNERS_CANNOT_BE_ZERO);
|
|
5896
|
+
}
|
|
5897
|
+
const seenSignatories = /* @__PURE__ */ new Set();
|
|
5898
|
+
for (const { address: address2 } of signatoryAddresses) {
|
|
5899
|
+
if (seenSignatories.has(address2)) {
|
|
5900
|
+
throw new SolanaError(SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATORIES_MUST_BE_UNIQUE);
|
|
5901
|
+
}
|
|
5902
|
+
seenSignatories.add(address2);
|
|
5903
|
+
}
|
|
5904
|
+
const addressEncoder = getAddressEncoder();
|
|
5905
|
+
return signatoryAddresses.map(({ address: address2 }) => addressEncoder.encode(address2));
|
|
5906
|
+
}
|
|
5907
|
+
)
|
|
5908
|
+
]
|
|
5909
|
+
);
|
|
5910
|
+
}
|
|
5911
|
+
function getOffchainMessageV1Decoder() {
|
|
5912
|
+
return transformDecoder(
|
|
5913
|
+
getTupleDecoder([getOffchainMessageV1PreambleDecoder(), getUtf8Decoder()]),
|
|
5914
|
+
([{ requiredSignatories, ...preambleRest }, text]) => {
|
|
5915
|
+
if (text.length === 0) {
|
|
5916
|
+
throw new SolanaError(SOLANA_ERROR__OFFCHAIN_MESSAGE__MESSAGE_MUST_BE_NON_EMPTY);
|
|
5917
|
+
}
|
|
5918
|
+
return Object.freeze({
|
|
5919
|
+
...preambleRest,
|
|
5920
|
+
content: text,
|
|
5921
|
+
requiredSignatories: Object.freeze(requiredSignatories)
|
|
5922
|
+
});
|
|
5923
|
+
}
|
|
5924
|
+
);
|
|
5925
|
+
}
|
|
5926
|
+
function getOffchainMessageV1Encoder() {
|
|
5927
|
+
return transformEncoder(
|
|
5928
|
+
getTupleEncoder([getOffchainMessageV1PreambleEncoder(), getUtf8Encoder()]),
|
|
5929
|
+
(offchainMessage) => {
|
|
5930
|
+
const { content, ...compiledPreamble } = offchainMessage;
|
|
5931
|
+
if (content.length === 0) {
|
|
5932
|
+
throw new SolanaError(SOLANA_ERROR__OFFCHAIN_MESSAGE__MESSAGE_MUST_BE_NON_EMPTY);
|
|
5933
|
+
}
|
|
5934
|
+
return [compiledPreamble, content];
|
|
5935
|
+
}
|
|
5936
|
+
);
|
|
5937
|
+
}
|
|
5938
|
+
function getOffchainMessageV1Codec() {
|
|
5939
|
+
return combineCodec(getOffchainMessageV1Encoder(), getOffchainMessageV1Decoder());
|
|
5940
|
+
}
|
|
5941
|
+
function getOffchainMessageDecoder() {
|
|
5942
|
+
return createDecoder({
|
|
5943
|
+
read(bytes, offset) {
|
|
5944
|
+
const version = getHiddenPrefixDecoder(getU8Decoder(), [
|
|
5945
|
+
// Discard the signing domain
|
|
5946
|
+
getOffchainMessageSigningDomainDecoder()
|
|
5947
|
+
]).decode(bytes, offset);
|
|
5948
|
+
switch (version) {
|
|
5949
|
+
case 0:
|
|
5950
|
+
return getOffchainMessageV0Decoder().read(bytes, offset);
|
|
5951
|
+
case 1:
|
|
5952
|
+
return getOffchainMessageV1Decoder().read(bytes, offset);
|
|
5953
|
+
default:
|
|
5954
|
+
throw new SolanaError(SOLANA_ERROR__OFFCHAIN_MESSAGE__VERSION_NUMBER_NOT_SUPPORTED, {
|
|
5955
|
+
unsupportedVersion: version
|
|
5956
|
+
});
|
|
5957
|
+
}
|
|
5958
|
+
}
|
|
5959
|
+
});
|
|
5960
|
+
}
|
|
5961
|
+
function getOffchainMessageEncoder() {
|
|
5962
|
+
return createEncoder({
|
|
5963
|
+
getSizeFromValue: (offchainMessage) => {
|
|
5964
|
+
const { version } = offchainMessage;
|
|
5965
|
+
switch (version) {
|
|
5966
|
+
case 0:
|
|
5967
|
+
return getOffchainMessageV0Encoder().getSizeFromValue(offchainMessage);
|
|
5968
|
+
case 1:
|
|
5969
|
+
return getOffchainMessageV1Encoder().getSizeFromValue(offchainMessage);
|
|
5970
|
+
default:
|
|
5971
|
+
throw new SolanaError(SOLANA_ERROR__OFFCHAIN_MESSAGE__VERSION_NUMBER_NOT_SUPPORTED, {
|
|
5972
|
+
unsupportedVersion: version
|
|
5973
|
+
});
|
|
5974
|
+
}
|
|
5975
|
+
},
|
|
5976
|
+
write: (offchainMessage, bytes, offset) => {
|
|
5977
|
+
const { version } = offchainMessage;
|
|
5978
|
+
switch (version) {
|
|
5979
|
+
case 0:
|
|
5980
|
+
return getOffchainMessageV0Encoder().write(offchainMessage, bytes, offset);
|
|
5981
|
+
case 1:
|
|
5982
|
+
return getOffchainMessageV1Encoder().write(offchainMessage, bytes, offset);
|
|
5983
|
+
default:
|
|
5984
|
+
throw new SolanaError(SOLANA_ERROR__OFFCHAIN_MESSAGE__VERSION_NUMBER_NOT_SUPPORTED, {
|
|
5985
|
+
unsupportedVersion: version
|
|
5986
|
+
});
|
|
5987
|
+
}
|
|
5988
|
+
}
|
|
5989
|
+
});
|
|
5990
|
+
}
|
|
5991
|
+
function getOffchainMessageCodec() {
|
|
5992
|
+
return combineCodec(getOffchainMessageEncoder(), getOffchainMessageDecoder());
|
|
5993
|
+
}
|
|
5994
|
+
function compileOffchainMessageEnvelopeUsingEncoder(offchainMessage, encoder) {
|
|
5995
|
+
const offchainMessageBytes = encoder.encode(offchainMessage);
|
|
5996
|
+
const signatures = {};
|
|
5997
|
+
for (const { address: address2 } of offchainMessage.requiredSignatories) {
|
|
5998
|
+
signatures[address2] = null;
|
|
5999
|
+
}
|
|
6000
|
+
return Object.freeze({
|
|
6001
|
+
content: offchainMessageBytes,
|
|
6002
|
+
signatures: Object.freeze(signatures)
|
|
6003
|
+
});
|
|
6004
|
+
}
|
|
6005
|
+
function compileOffchainMessageV0Envelope(offchainMessage) {
|
|
6006
|
+
return compileOffchainMessageEnvelopeUsingEncoder(offchainMessage, getOffchainMessageV0Encoder());
|
|
6007
|
+
}
|
|
6008
|
+
function compileOffchainMessageV1Envelope(offchainMessage) {
|
|
6009
|
+
return compileOffchainMessageEnvelopeUsingEncoder(offchainMessage, getOffchainMessageV1Encoder());
|
|
6010
|
+
}
|
|
6011
|
+
function compileOffchainMessageEnvelope(offchainMessage) {
|
|
6012
|
+
const { version } = offchainMessage;
|
|
6013
|
+
switch (version) {
|
|
6014
|
+
case 0:
|
|
6015
|
+
return compileOffchainMessageV0Envelope(offchainMessage);
|
|
6016
|
+
case 1:
|
|
6017
|
+
return compileOffchainMessageV1Envelope(offchainMessage);
|
|
6018
|
+
default:
|
|
6019
|
+
throw new SolanaError(SOLANA_ERROR__INVARIANT_VIOLATION__SWITCH_MUST_BE_EXHAUSTIVE, {
|
|
6020
|
+
unexpectedValue: version
|
|
6021
|
+
});
|
|
6022
|
+
}
|
|
6023
|
+
}
|
|
6024
|
+
async function partiallySignOffchainMessageEnvelope(keyPairs, offchainMessageEnvelope) {
|
|
6025
|
+
let newSignatures;
|
|
6026
|
+
let unexpectedSigners;
|
|
6027
|
+
const requiredSignatoryAddresses = decodeRequiredSignatoryAddresses(offchainMessageEnvelope.content);
|
|
6028
|
+
await Promise.all(
|
|
6029
|
+
keyPairs.map(async (keyPair) => {
|
|
6030
|
+
const address2 = await getAddressFromPublicKey(keyPair.publicKey);
|
|
6031
|
+
if (!requiredSignatoryAddresses.includes(address2)) {
|
|
6032
|
+
unexpectedSigners || (unexpectedSigners = /* @__PURE__ */ new Set());
|
|
6033
|
+
unexpectedSigners.add(address2);
|
|
6034
|
+
return;
|
|
6035
|
+
}
|
|
6036
|
+
if (unexpectedSigners) {
|
|
6037
|
+
return;
|
|
6038
|
+
}
|
|
6039
|
+
const existingSignature = offchainMessageEnvelope.signatures[address2];
|
|
6040
|
+
const newSignature = await signBytes(keyPair.privateKey, offchainMessageEnvelope.content);
|
|
6041
|
+
if (existingSignature != null && bytesEqual(newSignature, existingSignature)) {
|
|
6042
|
+
return;
|
|
6043
|
+
}
|
|
6044
|
+
newSignatures || (newSignatures = {});
|
|
6045
|
+
newSignatures[address2] = newSignature;
|
|
6046
|
+
})
|
|
6047
|
+
);
|
|
6048
|
+
if (unexpectedSigners && unexpectedSigners.size > 0) {
|
|
6049
|
+
throw new SolanaError(SOLANA_ERROR__OFFCHAIN_MESSAGE__ADDRESSES_CANNOT_SIGN_OFFCHAIN_MESSAGE, {
|
|
6050
|
+
expectedAddresses: requiredSignatoryAddresses,
|
|
6051
|
+
unexpectedAddresses: [...unexpectedSigners]
|
|
6052
|
+
});
|
|
6053
|
+
}
|
|
6054
|
+
if (!newSignatures) {
|
|
6055
|
+
return offchainMessageEnvelope;
|
|
6056
|
+
}
|
|
6057
|
+
return Object.freeze({
|
|
6058
|
+
...offchainMessageEnvelope,
|
|
6059
|
+
signatures: Object.freeze({
|
|
6060
|
+
...offchainMessageEnvelope.signatures,
|
|
6061
|
+
...newSignatures
|
|
6062
|
+
})
|
|
6063
|
+
});
|
|
6064
|
+
}
|
|
6065
|
+
async function signOffchainMessageEnvelope(keyPairs, offchainMessageEnvelope) {
|
|
6066
|
+
const out = await partiallySignOffchainMessageEnvelope(keyPairs, offchainMessageEnvelope);
|
|
6067
|
+
assertIsFullySignedOffchainMessageEnvelope(out);
|
|
6068
|
+
Object.freeze(out);
|
|
6069
|
+
return out;
|
|
6070
|
+
}
|
|
6071
|
+
function isFullySignedOffchainMessageEnvelope(offchainMessage) {
|
|
6072
|
+
return Object.entries(offchainMessage.signatures).every(([_, signatureBytes2]) => !!signatureBytes2);
|
|
6073
|
+
}
|
|
6074
|
+
function assertIsFullySignedOffchainMessageEnvelope(offchainMessage) {
|
|
6075
|
+
const missingSigs = [];
|
|
6076
|
+
Object.entries(offchainMessage.signatures).forEach(([address2, signatureBytes2]) => {
|
|
6077
|
+
if (!signatureBytes2) {
|
|
6078
|
+
missingSigs.push(address2);
|
|
6079
|
+
}
|
|
6080
|
+
});
|
|
6081
|
+
if (missingSigs.length > 0) {
|
|
6082
|
+
throw new SolanaError(SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATURES_MISSING, {
|
|
6083
|
+
addresses: missingSigs
|
|
6084
|
+
});
|
|
6085
|
+
}
|
|
6086
|
+
}
|
|
6087
|
+
async function verifyOffchainMessageEnvelope(offchainMessageEnvelope) {
|
|
6088
|
+
let errorContext;
|
|
6089
|
+
const requiredSignatories = decodeRequiredSignatoryAddresses(offchainMessageEnvelope.content);
|
|
6090
|
+
await Promise.all(
|
|
6091
|
+
requiredSignatories.map(async (address2) => {
|
|
6092
|
+
const signature2 = offchainMessageEnvelope.signatures[address2];
|
|
6093
|
+
if (signature2 == null) {
|
|
6094
|
+
errorContext || (errorContext = {});
|
|
6095
|
+
errorContext.signatoriesWithMissingSignatures || (errorContext.signatoriesWithMissingSignatures = []);
|
|
6096
|
+
errorContext.signatoriesWithMissingSignatures.push(address2);
|
|
6097
|
+
} else {
|
|
6098
|
+
const publicKey = await getPublicKeyFromAddress(address2);
|
|
6099
|
+
if (await verifySignature(publicKey, signature2, offchainMessageEnvelope.content)) {
|
|
6100
|
+
return true;
|
|
6101
|
+
} else {
|
|
6102
|
+
errorContext || (errorContext = {});
|
|
6103
|
+
errorContext.signatoriesWithInvalidSignatures || (errorContext.signatoriesWithInvalidSignatures = []);
|
|
6104
|
+
errorContext.signatoriesWithInvalidSignatures.push(address2);
|
|
6105
|
+
}
|
|
6106
|
+
}
|
|
6107
|
+
})
|
|
6108
|
+
);
|
|
6109
|
+
if (errorContext) {
|
|
6110
|
+
throw new SolanaError(SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATURE_VERIFICATION_FAILURE, errorContext);
|
|
6111
|
+
}
|
|
6112
|
+
}
|
|
6113
|
+
|
|
5293
6114
|
// ../programs/dist/index.browser.mjs
|
|
5294
6115
|
function isProgramError(error, transactionMessage, programAddress, code) {
|
|
5295
6116
|
var _a;
|
|
@@ -6244,7 +7065,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
6244
7065
|
...config.headers ? normalizeHeaders2(config.headers) : void 0,
|
|
6245
7066
|
...{
|
|
6246
7067
|
// Keep these headers lowercase so they will override any user-supplied headers above.
|
|
6247
|
-
"solana-client": `js/${"5.0
|
|
7068
|
+
"solana-client": `js/${"5.1.0-canary-20251204151413"}`
|
|
6248
7069
|
}
|
|
6249
7070
|
}
|
|
6250
7071
|
}),
|
|
@@ -7232,7 +8053,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
7232
8053
|
);
|
|
7233
8054
|
}
|
|
7234
8055
|
const { intervalMs, ...rest } = config;
|
|
7235
|
-
const createDefaultRpcSubscriptionsChannel = ({ abortSignal }) => {
|
|
8056
|
+
const createDefaultRpcSubscriptionsChannel = (({ abortSignal }) => {
|
|
7236
8057
|
var _a2;
|
|
7237
8058
|
return createWebSocketChannel({
|
|
7238
8059
|
...rest,
|
|
@@ -7248,7 +8069,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
7248
8069
|
intervalMs: intervalMs != null ? intervalMs : 5e3
|
|
7249
8070
|
})
|
|
7250
8071
|
);
|
|
7251
|
-
};
|
|
8072
|
+
});
|
|
7252
8073
|
return getChannelPoolingChannelCreator(createDefaultRpcSubscriptionsChannel, {
|
|
7253
8074
|
maxSubscriptionsPerChannel: (_a = config.maxSubscriptionsPerChannel) != null ? _a : (
|
|
7254
8075
|
/**
|
|
@@ -7326,10 +8147,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
7326
8147
|
);
|
|
7327
8148
|
}
|
|
7328
8149
|
function createRpcSubscriptionsTransportFromChannelCreator(createChannel) {
|
|
7329
|
-
return async ({ execute, signal }) => {
|
|
8150
|
+
return (async ({ execute, signal }) => {
|
|
7330
8151
|
const channel = await createChannel({ abortSignal: signal });
|
|
7331
8152
|
return await execute({ channel, signal });
|
|
7332
|
-
};
|
|
8153
|
+
});
|
|
7333
8154
|
}
|
|
7334
8155
|
function createSolanaRpcSubscriptionsImpl(clusterUrl, config) {
|
|
7335
8156
|
const transport = createDefaultRpcSubscriptionsTransport({
|
|
@@ -7531,6 +8352,60 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
7531
8352
|
};
|
|
7532
8353
|
return Object.freeze(out);
|
|
7533
8354
|
}
|
|
8355
|
+
function getSignersFromOffchainMessage({
|
|
8356
|
+
requiredSignatories
|
|
8357
|
+
}) {
|
|
8358
|
+
const messageSigners = requiredSignatories.filter(isMessageSigner);
|
|
8359
|
+
return deduplicateSigners(messageSigners);
|
|
8360
|
+
}
|
|
8361
|
+
async function partiallySignOffchainMessageWithSigners(offchainMessage, config) {
|
|
8362
|
+
const { partialSigners, modifyingSigners } = categorizeMessageSigners(
|
|
8363
|
+
getSignersFromOffchainMessage(offchainMessage)
|
|
8364
|
+
);
|
|
8365
|
+
return await signModifyingAndPartialMessageSigners(offchainMessage, modifyingSigners, partialSigners, config);
|
|
8366
|
+
}
|
|
8367
|
+
async function signOffchainMessageWithSigners(offchainMessage, config) {
|
|
8368
|
+
const signedOffchainMessageEnvelope = await partiallySignOffchainMessageWithSigners(offchainMessage, config);
|
|
8369
|
+
assertIsFullySignedOffchainMessageEnvelope(signedOffchainMessageEnvelope);
|
|
8370
|
+
return signedOffchainMessageEnvelope;
|
|
8371
|
+
}
|
|
8372
|
+
function categorizeMessageSigners(signers) {
|
|
8373
|
+
const modifyingSigners = identifyMessageModifyingSigners(signers);
|
|
8374
|
+
const partialSigners = signers.filter(isMessagePartialSigner).filter((signer) => !modifyingSigners.includes(signer));
|
|
8375
|
+
return Object.freeze({ modifyingSigners, partialSigners });
|
|
8376
|
+
}
|
|
8377
|
+
function identifyMessageModifyingSigners(signers) {
|
|
8378
|
+
const modifyingSigners = signers.filter(isMessageModifyingSigner);
|
|
8379
|
+
if (modifyingSigners.length === 0) return [];
|
|
8380
|
+
const nonPartialSigners = modifyingSigners.filter((signer) => !isMessagePartialSigner(signer));
|
|
8381
|
+
if (nonPartialSigners.length > 0) return nonPartialSigners;
|
|
8382
|
+
return [modifyingSigners[0]];
|
|
8383
|
+
}
|
|
8384
|
+
async function signModifyingAndPartialMessageSigners(offchainMessage, modifyingSigners = [], partialSigners = [], config) {
|
|
8385
|
+
var _a, _b;
|
|
8386
|
+
const offchainMessageEnvelope = compileOffchainMessageEnvelope(offchainMessage);
|
|
8387
|
+
const modifiedOffchainMessage = await modifyingSigners.reduce(async (offchainMessageEnvelope2, modifyingSigner) => {
|
|
8388
|
+
var _a2;
|
|
8389
|
+
(_a2 = config == null ? void 0 : config.abortSignal) == null ? void 0 : _a2.throwIfAborted();
|
|
8390
|
+
const [message] = await modifyingSigner.modifyAndSignMessages([await offchainMessageEnvelope2], config);
|
|
8391
|
+
return Object.freeze(message);
|
|
8392
|
+
}, Promise.resolve(offchainMessageEnvelope));
|
|
8393
|
+
(_a = config == null ? void 0 : config.abortSignal) == null ? void 0 : _a.throwIfAborted();
|
|
8394
|
+
const signatureDictionaries = await Promise.all(
|
|
8395
|
+
partialSigners.map(async (partialSigner) => {
|
|
8396
|
+
const [signatures] = await partialSigner.signMessages([modifiedOffchainMessage], config);
|
|
8397
|
+
return signatures;
|
|
8398
|
+
})
|
|
8399
|
+
);
|
|
8400
|
+
return Object.freeze({
|
|
8401
|
+
...modifiedOffchainMessage,
|
|
8402
|
+
signatures: Object.freeze(
|
|
8403
|
+
signatureDictionaries.reduce((signatures, signatureDictionary) => {
|
|
8404
|
+
return { ...signatures, ...signatureDictionary };
|
|
8405
|
+
}, (_b = modifiedOffchainMessage.signatures) != null ? _b : {})
|
|
8406
|
+
)
|
|
8407
|
+
});
|
|
8408
|
+
}
|
|
7534
8409
|
function isTransactionMessageWithSingleSendingSigner(transaction) {
|
|
7535
8410
|
try {
|
|
7536
8411
|
assertIsTransactionMessageWithSingleSendingSigner(transaction);
|
|
@@ -8157,6 +9032,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
8157
9032
|
exports.DEFAULT_RPC_SUBSCRIPTIONS_CONFIG = DEFAULT_RPC_SUBSCRIPTIONS_CONFIG;
|
|
8158
9033
|
exports.Endian = Endian;
|
|
8159
9034
|
exports.MAX_SUPPORTED_TRANSACTION_VERSION = MAX_SUPPORTED_TRANSACTION_VERSION;
|
|
9035
|
+
exports.OffchainMessageContentFormat = OffchainMessageContentFormat;
|
|
8160
9036
|
exports.SOLANA_ERROR__ACCOUNTS__ACCOUNT_NOT_FOUND = SOLANA_ERROR__ACCOUNTS__ACCOUNT_NOT_FOUND;
|
|
8161
9037
|
exports.SOLANA_ERROR__ACCOUNTS__EXPECTED_ALL_ACCOUNTS_TO_BE_DECODED = SOLANA_ERROR__ACCOUNTS__EXPECTED_ALL_ACCOUNTS_TO_BE_DECODED;
|
|
8162
9038
|
exports.SOLANA_ERROR__ACCOUNTS__EXPECTED_DECODED_ACCOUNT = SOLANA_ERROR__ACCOUNTS__EXPECTED_DECODED_ACCOUNT;
|
|
@@ -8321,6 +9197,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
8321
9197
|
exports.SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATORIES_MUST_BE_SORTED = SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATORIES_MUST_BE_SORTED;
|
|
8322
9198
|
exports.SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATORIES_MUST_BE_UNIQUE = SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATORIES_MUST_BE_UNIQUE;
|
|
8323
9199
|
exports.SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATURES_MISSING = SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATURES_MISSING;
|
|
9200
|
+
exports.SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATURE_VERIFICATION_FAILURE = SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATURE_VERIFICATION_FAILURE;
|
|
8324
9201
|
exports.SOLANA_ERROR__OFFCHAIN_MESSAGE__UNEXPECTED_VERSION = SOLANA_ERROR__OFFCHAIN_MESSAGE__UNEXPECTED_VERSION;
|
|
8325
9202
|
exports.SOLANA_ERROR__OFFCHAIN_MESSAGE__VERSION_NUMBER_NOT_SUPPORTED = SOLANA_ERROR__OFFCHAIN_MESSAGE__VERSION_NUMBER_NOT_SUPPORTED;
|
|
8326
9203
|
exports.SOLANA_ERROR__RPC_SUBSCRIPTIONS__CANNOT_CREATE_SUBSCRIPTION_PLAN = SOLANA_ERROR__RPC_SUBSCRIPTIONS__CANNOT_CREATE_SUBSCRIPTION_PLAN;
|
|
@@ -8439,6 +9316,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
8439
9316
|
exports.assertIsAddress = assertIsAddress;
|
|
8440
9317
|
exports.assertIsBlockhash = assertIsBlockhash;
|
|
8441
9318
|
exports.assertIsFixedSize = assertIsFixedSize;
|
|
9319
|
+
exports.assertIsFullySignedOffchainMessageEnvelope = assertIsFullySignedOffchainMessageEnvelope;
|
|
8442
9320
|
exports.assertIsFullySignedTransaction = assertIsFullySignedTransaction;
|
|
8443
9321
|
exports.assertIsInstructionForProgram = assertIsInstructionForProgram;
|
|
8444
9322
|
exports.assertIsInstructionWithAccounts = assertIsInstructionWithAccounts;
|
|
@@ -8449,6 +9327,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
8449
9327
|
exports.assertIsMessagePartialSigner = assertIsMessagePartialSigner;
|
|
8450
9328
|
exports.assertIsMessageSigner = assertIsMessageSigner;
|
|
8451
9329
|
exports.assertIsOffCurveAddress = assertIsOffCurveAddress;
|
|
9330
|
+
exports.assertIsOffchainMessageApplicationDomain = assertIsOffchainMessageApplicationDomain;
|
|
9331
|
+
exports.assertIsOffchainMessageContentRestrictedAsciiOf1232BytesMax = assertIsOffchainMessageContentRestrictedAsciiOf1232BytesMax;
|
|
9332
|
+
exports.assertIsOffchainMessageContentUtf8Of1232BytesMax = assertIsOffchainMessageContentUtf8Of1232BytesMax;
|
|
9333
|
+
exports.assertIsOffchainMessageContentUtf8Of65535BytesMax = assertIsOffchainMessageContentUtf8Of65535BytesMax;
|
|
9334
|
+
exports.assertIsOffchainMessageRestrictedAsciiOf1232BytesMax = assertIsOffchainMessageRestrictedAsciiOf1232BytesMax;
|
|
9335
|
+
exports.assertIsOffchainMessageUtf8Of1232BytesMax = assertIsOffchainMessageUtf8Of1232BytesMax;
|
|
9336
|
+
exports.assertIsOffchainMessageUtf8Of65535BytesMax = assertIsOffchainMessageUtf8Of65535BytesMax;
|
|
8452
9337
|
exports.assertIsProgramDerivedAddress = assertIsProgramDerivedAddress;
|
|
8453
9338
|
exports.assertIsSendableTransaction = assertIsSendableTransaction;
|
|
8454
9339
|
exports.assertIsSignature = assertIsSignature;
|
|
@@ -8472,9 +9357,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
8472
9357
|
exports.assertValidBaseString = assertValidBaseString;
|
|
8473
9358
|
exports.assertValidNumberOfItemsForCodec = assertValidNumberOfItemsForCodec;
|
|
8474
9359
|
exports.blockhash = blockhash;
|
|
9360
|
+
exports.bytesEqual = bytesEqual;
|
|
8475
9361
|
exports.canceledSingleTransactionPlanResult = canceledSingleTransactionPlanResult;
|
|
8476
9362
|
exports.combineCodec = combineCodec;
|
|
8477
9363
|
exports.commitmentComparator = commitmentComparator;
|
|
9364
|
+
exports.compileOffchainMessageEnvelope = compileOffchainMessageEnvelope;
|
|
9365
|
+
exports.compileOffchainMessageV0Envelope = compileOffchainMessageV0Envelope;
|
|
9366
|
+
exports.compileOffchainMessageV1Envelope = compileOffchainMessageV1Envelope;
|
|
8478
9367
|
exports.compileTransaction = compileTransaction;
|
|
8479
9368
|
exports.compileTransactionMessage = compileTransactionMessage;
|
|
8480
9369
|
exports.compressTransactionMessageUsingAddressLookupTables = compressTransactionMessageUsingAddressLookupTables;
|
|
@@ -8530,6 +9419,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
8530
9419
|
exports.fixCodecSize = fixCodecSize;
|
|
8531
9420
|
exports.fixDecoderSize = fixDecoderSize;
|
|
8532
9421
|
exports.fixEncoderSize = fixEncoderSize;
|
|
9422
|
+
exports.flattenTransactionPlanResult = flattenTransactionPlanResult;
|
|
8533
9423
|
exports.generateKeyPair = generateKeyPair;
|
|
8534
9424
|
exports.generateKeyPairSigner = generateKeyPairSigner;
|
|
8535
9425
|
exports.getAddressCodec = getAddressCodec;
|
|
@@ -8631,6 +9521,21 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
8631
9521
|
exports.getNullableCodec = getNullableCodec;
|
|
8632
9522
|
exports.getNullableDecoder = getNullableDecoder;
|
|
8633
9523
|
exports.getNullableEncoder = getNullableEncoder;
|
|
9524
|
+
exports.getOffchainMessageApplicationDomainCodec = getOffchainMessageApplicationDomainCodec;
|
|
9525
|
+
exports.getOffchainMessageApplicationDomainDecoder = getOffchainMessageApplicationDomainDecoder;
|
|
9526
|
+
exports.getOffchainMessageApplicationDomainEncoder = getOffchainMessageApplicationDomainEncoder;
|
|
9527
|
+
exports.getOffchainMessageCodec = getOffchainMessageCodec;
|
|
9528
|
+
exports.getOffchainMessageDecoder = getOffchainMessageDecoder;
|
|
9529
|
+
exports.getOffchainMessageEncoder = getOffchainMessageEncoder;
|
|
9530
|
+
exports.getOffchainMessageEnvelopeCodec = getOffchainMessageEnvelopeCodec;
|
|
9531
|
+
exports.getOffchainMessageEnvelopeDecoder = getOffchainMessageEnvelopeDecoder;
|
|
9532
|
+
exports.getOffchainMessageEnvelopeEncoder = getOffchainMessageEnvelopeEncoder;
|
|
9533
|
+
exports.getOffchainMessageV0Codec = getOffchainMessageV0Codec;
|
|
9534
|
+
exports.getOffchainMessageV0Decoder = getOffchainMessageV0Decoder;
|
|
9535
|
+
exports.getOffchainMessageV0Encoder = getOffchainMessageV0Encoder;
|
|
9536
|
+
exports.getOffchainMessageV1Codec = getOffchainMessageV1Codec;
|
|
9537
|
+
exports.getOffchainMessageV1Decoder = getOffchainMessageV1Decoder;
|
|
9538
|
+
exports.getOffchainMessageV1Encoder = getOffchainMessageV1Encoder;
|
|
8634
9539
|
exports.getOptionCodec = getOptionCodec;
|
|
8635
9540
|
exports.getOptionDecoder = getOptionDecoder;
|
|
8636
9541
|
exports.getOptionEncoder = getOptionEncoder;
|
|
@@ -8650,6 +9555,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
8650
9555
|
exports.getShortU16Encoder = getShortU16Encoder;
|
|
8651
9556
|
exports.getSignatureFromTransaction = getSignatureFromTransaction;
|
|
8652
9557
|
exports.getSignersFromInstruction = getSignersFromInstruction;
|
|
9558
|
+
exports.getSignersFromOffchainMessage = getSignersFromOffchainMessage;
|
|
8653
9559
|
exports.getSignersFromTransactionMessage = getSignersFromTransactionMessage;
|
|
8654
9560
|
exports.getSolanaErrorFromInstructionError = getSolanaErrorFromInstructionError;
|
|
8655
9561
|
exports.getSolanaErrorFromJsonRpcError = getSolanaErrorFromJsonRpcError;
|
|
@@ -8697,6 +9603,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
8697
9603
|
exports.isAdvanceNonceAccountInstruction = isAdvanceNonceAccountInstruction;
|
|
8698
9604
|
exports.isBlockhash = isBlockhash;
|
|
8699
9605
|
exports.isFixedSize = isFixedSize;
|
|
9606
|
+
exports.isFullySignedOffchainMessageEnvelope = isFullySignedOffchainMessageEnvelope;
|
|
8700
9607
|
exports.isFullySignedTransaction = isFullySignedTransaction;
|
|
8701
9608
|
exports.isInstructionForProgram = isInstructionForProgram;
|
|
8702
9609
|
exports.isInstructionWithAccounts = isInstructionWithAccounts;
|
|
@@ -8709,6 +9616,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
8709
9616
|
exports.isMessageSigner = isMessageSigner;
|
|
8710
9617
|
exports.isNone = isNone;
|
|
8711
9618
|
exports.isOffCurveAddress = isOffCurveAddress;
|
|
9619
|
+
exports.isOffchainMessageApplicationDomain = isOffchainMessageApplicationDomain;
|
|
9620
|
+
exports.isOffchainMessageContentRestrictedAsciiOf1232BytesMax = isOffchainMessageContentRestrictedAsciiOf1232BytesMax;
|
|
9621
|
+
exports.isOffchainMessageContentUtf8Of1232BytesMax = isOffchainMessageContentUtf8Of1232BytesMax;
|
|
9622
|
+
exports.isOffchainMessageContentUtf8Of65535BytesMax = isOffchainMessageContentUtf8Of65535BytesMax;
|
|
8712
9623
|
exports.isOption = isOption;
|
|
8713
9624
|
exports.isProgramDerivedAddress = isProgramDerivedAddress;
|
|
8714
9625
|
exports.isProgramError = isProgramError;
|
|
@@ -8743,6 +9654,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
8743
9654
|
exports.nonDivisibleSequentialTransactionPlanResult = nonDivisibleSequentialTransactionPlanResult;
|
|
8744
9655
|
exports.none = none;
|
|
8745
9656
|
exports.offCurveAddress = offCurveAddress;
|
|
9657
|
+
exports.offchainMessageApplicationDomain = offchainMessageApplicationDomain;
|
|
9658
|
+
exports.offchainMessageContentRestrictedAsciiOf1232BytesMax = offchainMessageContentRestrictedAsciiOf1232BytesMax;
|
|
9659
|
+
exports.offchainMessageContentUtf8Of1232BytesMax = offchainMessageContentUtf8Of1232BytesMax;
|
|
9660
|
+
exports.offchainMessageContentUtf8Of65535BytesMax = offchainMessageContentUtf8Of65535BytesMax;
|
|
8746
9661
|
exports.offsetCodec = offsetCodec;
|
|
8747
9662
|
exports.offsetDecoder = offsetDecoder;
|
|
8748
9663
|
exports.offsetEncoder = offsetEncoder;
|
|
@@ -8760,6 +9675,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
8760
9675
|
exports.parseBase58RpcAccount = parseBase58RpcAccount;
|
|
8761
9676
|
exports.parseBase64RpcAccount = parseBase64RpcAccount;
|
|
8762
9677
|
exports.parseJsonRpcAccount = parseJsonRpcAccount;
|
|
9678
|
+
exports.partiallySignOffchainMessageEnvelope = partiallySignOffchainMessageEnvelope;
|
|
9679
|
+
exports.partiallySignOffchainMessageWithSigners = partiallySignOffchainMessageWithSigners;
|
|
8763
9680
|
exports.partiallySignTransaction = partiallySignTransaction;
|
|
8764
9681
|
exports.partiallySignTransactionMessageWithSigners = partiallySignTransactionMessageWithSigners;
|
|
8765
9682
|
exports.pipe = pipe;
|
|
@@ -8785,6 +9702,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
8785
9702
|
exports.setTransactionMessageLifetimeUsingDurableNonce = setTransactionMessageLifetimeUsingDurableNonce;
|
|
8786
9703
|
exports.signAndSendTransactionMessageWithSigners = signAndSendTransactionMessageWithSigners;
|
|
8787
9704
|
exports.signBytes = signBytes;
|
|
9705
|
+
exports.signOffchainMessageEnvelope = signOffchainMessageEnvelope;
|
|
9706
|
+
exports.signOffchainMessageWithSigners = signOffchainMessageWithSigners;
|
|
8788
9707
|
exports.signTransaction = signTransaction;
|
|
8789
9708
|
exports.signTransactionMessageWithSigners = signTransactionMessageWithSigners;
|
|
8790
9709
|
exports.signature = signature;
|
|
@@ -8795,6 +9714,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
8795
9714
|
exports.stringifiedBigInt = stringifiedBigInt;
|
|
8796
9715
|
exports.stringifiedNumber = stringifiedNumber;
|
|
8797
9716
|
exports.successfulSingleTransactionPlanResult = successfulSingleTransactionPlanResult;
|
|
9717
|
+
exports.successfulSingleTransactionPlanResultFromSignature = successfulSingleTransactionPlanResultFromSignature;
|
|
9718
|
+
exports.summarizeTransactionPlanResult = summarizeTransactionPlanResult;
|
|
8798
9719
|
exports.testnet = testnet;
|
|
8799
9720
|
exports.transformChannelInboundMessages = transformChannelInboundMessages;
|
|
8800
9721
|
exports.transformChannelOutboundMessages = transformChannelOutboundMessages;
|
|
@@ -8806,6 +9727,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
8806
9727
|
exports.unwrapOptionRecursively = unwrapOptionRecursively;
|
|
8807
9728
|
exports.upgradeRoleToSigner = upgradeRoleToSigner;
|
|
8808
9729
|
exports.upgradeRoleToWritable = upgradeRoleToWritable;
|
|
9730
|
+
exports.verifyOffchainMessageEnvelope = verifyOffchainMessageEnvelope;
|
|
8809
9731
|
exports.verifySignature = verifySignature;
|
|
8810
9732
|
exports.wrapNullable = wrapNullable;
|
|
8811
9733
|
|