@solana/web3.js 1.24.2 → 1.28.0
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/lib/index.browser.esm.js +724 -30
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +167 -8
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +75 -2
- package/lib/index.esm.js +167 -9
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +730 -37
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +4 -4
- package/lib/index.iife.min.js.map +1 -1
- package/module.flow.js +104 -3
- package/package.json +8 -5
- package/src/connection.ts +76 -5
- package/src/ed25519-program.ts +140 -0
- package/src/index.ts +1 -0
- package/src/message.ts +27 -0
- package/src/publickey.ts +8 -2
- package/src/transaction.ts +10 -6
package/lib/index.iife.js
CHANGED
|
@@ -18,6 +18,10 @@ var solanaWeb3 = (function (exports) {
|
|
|
18
18
|
|
|
19
19
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
20
20
|
|
|
21
|
+
function getDefaultExportFromCjs (x) {
|
|
22
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
23
|
+
}
|
|
24
|
+
|
|
21
25
|
function getAugmentedNamespace(n) {
|
|
22
26
|
if (n.__esModule) return n;
|
|
23
27
|
var a = Object.defineProperty({}, '__esModule', {value: true});
|
|
@@ -8327,7 +8331,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
8327
8331
|
|
|
8328
8332
|
var bs58$1 = bs58;
|
|
8329
8333
|
|
|
8330
|
-
var browser$
|
|
8334
|
+
var browser$1 = {};
|
|
8331
8335
|
|
|
8332
8336
|
/* eslint-env browser */
|
|
8333
8337
|
|
|
@@ -8378,10 +8382,10 @@ var solanaWeb3 = (function (exports) {
|
|
|
8378
8382
|
return options.outputFormat === 'hex' ? bufferToHex(hash) : hash;
|
|
8379
8383
|
};
|
|
8380
8384
|
|
|
8381
|
-
browser$
|
|
8382
|
-
var sha256 = browser$
|
|
8383
|
-
browser$
|
|
8384
|
-
browser$
|
|
8385
|
+
browser$1.sha1 = create$1('SHA-1');
|
|
8386
|
+
var sha256 = browser$1.sha256 = create$1('SHA-256');
|
|
8387
|
+
browser$1.sha384 = create$1('SHA-384');
|
|
8388
|
+
browser$1.sha512 = create$1('SHA-512');
|
|
8385
8389
|
|
|
8386
8390
|
var lib$1 = {};
|
|
8387
8391
|
|
|
@@ -9462,6 +9466,9 @@ var solanaWeb3 = (function (exports) {
|
|
|
9462
9466
|
*/
|
|
9463
9467
|
|
|
9464
9468
|
const MAX_SEED_LENGTH = 32;
|
|
9469
|
+
/**
|
|
9470
|
+
* Value to be converted into public key
|
|
9471
|
+
*/
|
|
9465
9472
|
|
|
9466
9473
|
function isPublicKeyData(value) {
|
|
9467
9474
|
return value._bn !== undefined;
|
|
@@ -11937,7 +11944,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
11937
11944
|
*
|
|
11938
11945
|
* @augments {Layout}
|
|
11939
11946
|
*/
|
|
11940
|
-
var Blob = /** @class */ (function (_super) {
|
|
11947
|
+
var Blob$1 = /** @class */ (function (_super) {
|
|
11941
11948
|
__extends(Blob, _super);
|
|
11942
11949
|
function Blob(length, property) {
|
|
11943
11950
|
var _this = this;
|
|
@@ -12004,7 +12011,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
12004
12011
|
};
|
|
12005
12012
|
return Blob;
|
|
12006
12013
|
}(Layout));
|
|
12007
|
-
Layout$1.Blob = Blob;
|
|
12014
|
+
Layout$1.Blob = Blob$1;
|
|
12008
12015
|
/**
|
|
12009
12016
|
* Contain a `NUL`-terminated UTF8 string.
|
|
12010
12017
|
*
|
|
@@ -12312,7 +12319,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
12312
12319
|
/** Factory for {@link UnionLayoutDiscriminator} values. */
|
|
12313
12320
|
Layout$1.unionLayoutDiscriminator = (function (layout, property) { return new UnionLayoutDiscriminator(layout, property); });
|
|
12314
12321
|
/** Factory for {@link Blob} values. */
|
|
12315
|
-
var blob = Layout$1.blob = (function (length, property) { return new Blob(length, property); });
|
|
12322
|
+
var blob = Layout$1.blob = (function (length, property) { return new Blob$1(length, property); });
|
|
12316
12323
|
/** Factory for {@link CString} values. */
|
|
12317
12324
|
Layout$1.cstr = (function (property) { return new CString(property); });
|
|
12318
12325
|
/** Factory for {@link UTF8} values. */
|
|
@@ -12435,16 +12442,35 @@ var solanaWeb3 = (function (exports) {
|
|
|
12435
12442
|
|
|
12436
12443
|
_defineProperty(this, "instructions", void 0);
|
|
12437
12444
|
|
|
12445
|
+
_defineProperty(this, "indexToProgramIds", new Map());
|
|
12446
|
+
|
|
12438
12447
|
this.header = args.header;
|
|
12439
12448
|
this.accountKeys = args.accountKeys.map(account => new PublicKey(account));
|
|
12440
12449
|
this.recentBlockhash = args.recentBlockhash;
|
|
12441
12450
|
this.instructions = args.instructions;
|
|
12451
|
+
this.instructions.forEach(ix => this.indexToProgramIds.set(ix.programIdIndex, this.accountKeys[ix.programIdIndex]));
|
|
12452
|
+
}
|
|
12453
|
+
|
|
12454
|
+
isAccountSigner(index) {
|
|
12455
|
+
return index < this.header.numRequiredSignatures;
|
|
12442
12456
|
}
|
|
12443
12457
|
|
|
12444
12458
|
isAccountWritable(index) {
|
|
12445
12459
|
return index < this.header.numRequiredSignatures - this.header.numReadonlySignedAccounts || index >= this.header.numRequiredSignatures && index < this.accountKeys.length - this.header.numReadonlyUnsignedAccounts;
|
|
12446
12460
|
}
|
|
12447
12461
|
|
|
12462
|
+
isProgramId(index) {
|
|
12463
|
+
return this.indexToProgramIds.has(index);
|
|
12464
|
+
}
|
|
12465
|
+
|
|
12466
|
+
programIds() {
|
|
12467
|
+
return [...this.indexToProgramIds.values()];
|
|
12468
|
+
}
|
|
12469
|
+
|
|
12470
|
+
nonProgramIds() {
|
|
12471
|
+
return this.accountKeys.filter((_, index) => !this.isProgramId(index));
|
|
12472
|
+
}
|
|
12473
|
+
|
|
12448
12474
|
serialize() {
|
|
12449
12475
|
const numKeys = this.accountKeys.length;
|
|
12450
12476
|
let keyCount = [];
|
|
@@ -13159,7 +13185,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
13159
13185
|
*/
|
|
13160
13186
|
|
|
13161
13187
|
|
|
13162
|
-
static populate(message, signatures) {
|
|
13188
|
+
static populate(message, signatures = []) {
|
|
13163
13189
|
const transaction = new Transaction();
|
|
13164
13190
|
transaction.recentBlockhash = message.recentBlockhash;
|
|
13165
13191
|
|
|
@@ -13179,7 +13205,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
13179
13205
|
const pubkey = message.accountKeys[account];
|
|
13180
13206
|
return {
|
|
13181
13207
|
pubkey,
|
|
13182
|
-
isSigner: transaction.signatures.some(keyObj => keyObj.publicKey.toString() === pubkey.toString()),
|
|
13208
|
+
isSigner: transaction.signatures.some(keyObj => keyObj.publicKey.toString() === pubkey.toString()) || message.isAccountSigner(account),
|
|
13183
13209
|
isWritable: message.isAccountWritable(account)
|
|
13184
13210
|
};
|
|
13185
13211
|
});
|
|
@@ -14241,36 +14267,566 @@ var solanaWeb3 = (function (exports) {
|
|
|
14241
14267
|
|
|
14242
14268
|
}
|
|
14243
14269
|
|
|
14244
|
-
var
|
|
14270
|
+
var browserPonyfill = {exports: {}};
|
|
14245
14271
|
|
|
14246
14272
|
(function (module, exports) {
|
|
14273
|
+
var global = typeof self !== 'undefined' ? self : commonjsGlobal;
|
|
14274
|
+
var __self__ = (function () {
|
|
14275
|
+
function F() {
|
|
14276
|
+
this.fetch = false;
|
|
14277
|
+
this.DOMException = global.DOMException;
|
|
14278
|
+
}
|
|
14279
|
+
F.prototype = global;
|
|
14280
|
+
return new F();
|
|
14281
|
+
})();
|
|
14282
|
+
(function(self) {
|
|
14247
14283
|
|
|
14248
|
-
|
|
14249
|
-
|
|
14250
|
-
|
|
14251
|
-
|
|
14252
|
-
|
|
14253
|
-
|
|
14254
|
-
|
|
14255
|
-
|
|
14256
|
-
|
|
14257
|
-
|
|
14284
|
+
((function (exports) {
|
|
14285
|
+
|
|
14286
|
+
var support = {
|
|
14287
|
+
searchParams: 'URLSearchParams' in self,
|
|
14288
|
+
iterable: 'Symbol' in self && 'iterator' in Symbol,
|
|
14289
|
+
blob:
|
|
14290
|
+
'FileReader' in self &&
|
|
14291
|
+
'Blob' in self &&
|
|
14292
|
+
(function() {
|
|
14293
|
+
try {
|
|
14294
|
+
new Blob();
|
|
14295
|
+
return true
|
|
14296
|
+
} catch (e) {
|
|
14297
|
+
return false
|
|
14298
|
+
}
|
|
14299
|
+
})(),
|
|
14300
|
+
formData: 'FormData' in self,
|
|
14301
|
+
arrayBuffer: 'ArrayBuffer' in self
|
|
14302
|
+
};
|
|
14258
14303
|
|
|
14259
|
-
|
|
14304
|
+
function isDataView(obj) {
|
|
14305
|
+
return obj && DataView.prototype.isPrototypeOf(obj)
|
|
14306
|
+
}
|
|
14307
|
+
|
|
14308
|
+
if (support.arrayBuffer) {
|
|
14309
|
+
var viewClasses = [
|
|
14310
|
+
'[object Int8Array]',
|
|
14311
|
+
'[object Uint8Array]',
|
|
14312
|
+
'[object Uint8ClampedArray]',
|
|
14313
|
+
'[object Int16Array]',
|
|
14314
|
+
'[object Uint16Array]',
|
|
14315
|
+
'[object Int32Array]',
|
|
14316
|
+
'[object Uint32Array]',
|
|
14317
|
+
'[object Float32Array]',
|
|
14318
|
+
'[object Float64Array]'
|
|
14319
|
+
];
|
|
14260
14320
|
|
|
14261
|
-
|
|
14321
|
+
var isArrayBufferView =
|
|
14322
|
+
ArrayBuffer.isView ||
|
|
14323
|
+
function(obj) {
|
|
14324
|
+
return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1
|
|
14325
|
+
};
|
|
14326
|
+
}
|
|
14262
14327
|
|
|
14263
|
-
|
|
14264
|
-
|
|
14265
|
-
|
|
14266
|
-
|
|
14328
|
+
function normalizeName(name) {
|
|
14329
|
+
if (typeof name !== 'string') {
|
|
14330
|
+
name = String(name);
|
|
14331
|
+
}
|
|
14332
|
+
if (/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(name)) {
|
|
14333
|
+
throw new TypeError('Invalid character in header field name')
|
|
14334
|
+
}
|
|
14335
|
+
return name.toLowerCase()
|
|
14336
|
+
}
|
|
14267
14337
|
|
|
14268
|
-
|
|
14269
|
-
|
|
14270
|
-
|
|
14271
|
-
|
|
14338
|
+
function normalizeValue(value) {
|
|
14339
|
+
if (typeof value !== 'string') {
|
|
14340
|
+
value = String(value);
|
|
14341
|
+
}
|
|
14342
|
+
return value
|
|
14343
|
+
}
|
|
14344
|
+
|
|
14345
|
+
// Build a destructive iterator for the value list
|
|
14346
|
+
function iteratorFor(items) {
|
|
14347
|
+
var iterator = {
|
|
14348
|
+
next: function() {
|
|
14349
|
+
var value = items.shift();
|
|
14350
|
+
return {done: value === undefined, value: value}
|
|
14351
|
+
}
|
|
14352
|
+
};
|
|
14353
|
+
|
|
14354
|
+
if (support.iterable) {
|
|
14355
|
+
iterator[Symbol.iterator] = function() {
|
|
14356
|
+
return iterator
|
|
14357
|
+
};
|
|
14358
|
+
}
|
|
14272
14359
|
|
|
14273
|
-
|
|
14360
|
+
return iterator
|
|
14361
|
+
}
|
|
14362
|
+
|
|
14363
|
+
function Headers(headers) {
|
|
14364
|
+
this.map = {};
|
|
14365
|
+
|
|
14366
|
+
if (headers instanceof Headers) {
|
|
14367
|
+
headers.forEach(function(value, name) {
|
|
14368
|
+
this.append(name, value);
|
|
14369
|
+
}, this);
|
|
14370
|
+
} else if (Array.isArray(headers)) {
|
|
14371
|
+
headers.forEach(function(header) {
|
|
14372
|
+
this.append(header[0], header[1]);
|
|
14373
|
+
}, this);
|
|
14374
|
+
} else if (headers) {
|
|
14375
|
+
Object.getOwnPropertyNames(headers).forEach(function(name) {
|
|
14376
|
+
this.append(name, headers[name]);
|
|
14377
|
+
}, this);
|
|
14378
|
+
}
|
|
14379
|
+
}
|
|
14380
|
+
|
|
14381
|
+
Headers.prototype.append = function(name, value) {
|
|
14382
|
+
name = normalizeName(name);
|
|
14383
|
+
value = normalizeValue(value);
|
|
14384
|
+
var oldValue = this.map[name];
|
|
14385
|
+
this.map[name] = oldValue ? oldValue + ', ' + value : value;
|
|
14386
|
+
};
|
|
14387
|
+
|
|
14388
|
+
Headers.prototype['delete'] = function(name) {
|
|
14389
|
+
delete this.map[normalizeName(name)];
|
|
14390
|
+
};
|
|
14391
|
+
|
|
14392
|
+
Headers.prototype.get = function(name) {
|
|
14393
|
+
name = normalizeName(name);
|
|
14394
|
+
return this.has(name) ? this.map[name] : null
|
|
14395
|
+
};
|
|
14396
|
+
|
|
14397
|
+
Headers.prototype.has = function(name) {
|
|
14398
|
+
return this.map.hasOwnProperty(normalizeName(name))
|
|
14399
|
+
};
|
|
14400
|
+
|
|
14401
|
+
Headers.prototype.set = function(name, value) {
|
|
14402
|
+
this.map[normalizeName(name)] = normalizeValue(value);
|
|
14403
|
+
};
|
|
14404
|
+
|
|
14405
|
+
Headers.prototype.forEach = function(callback, thisArg) {
|
|
14406
|
+
for (var name in this.map) {
|
|
14407
|
+
if (this.map.hasOwnProperty(name)) {
|
|
14408
|
+
callback.call(thisArg, this.map[name], name, this);
|
|
14409
|
+
}
|
|
14410
|
+
}
|
|
14411
|
+
};
|
|
14412
|
+
|
|
14413
|
+
Headers.prototype.keys = function() {
|
|
14414
|
+
var items = [];
|
|
14415
|
+
this.forEach(function(value, name) {
|
|
14416
|
+
items.push(name);
|
|
14417
|
+
});
|
|
14418
|
+
return iteratorFor(items)
|
|
14419
|
+
};
|
|
14420
|
+
|
|
14421
|
+
Headers.prototype.values = function() {
|
|
14422
|
+
var items = [];
|
|
14423
|
+
this.forEach(function(value) {
|
|
14424
|
+
items.push(value);
|
|
14425
|
+
});
|
|
14426
|
+
return iteratorFor(items)
|
|
14427
|
+
};
|
|
14428
|
+
|
|
14429
|
+
Headers.prototype.entries = function() {
|
|
14430
|
+
var items = [];
|
|
14431
|
+
this.forEach(function(value, name) {
|
|
14432
|
+
items.push([name, value]);
|
|
14433
|
+
});
|
|
14434
|
+
return iteratorFor(items)
|
|
14435
|
+
};
|
|
14436
|
+
|
|
14437
|
+
if (support.iterable) {
|
|
14438
|
+
Headers.prototype[Symbol.iterator] = Headers.prototype.entries;
|
|
14439
|
+
}
|
|
14440
|
+
|
|
14441
|
+
function consumed(body) {
|
|
14442
|
+
if (body.bodyUsed) {
|
|
14443
|
+
return Promise.reject(new TypeError('Already read'))
|
|
14444
|
+
}
|
|
14445
|
+
body.bodyUsed = true;
|
|
14446
|
+
}
|
|
14447
|
+
|
|
14448
|
+
function fileReaderReady(reader) {
|
|
14449
|
+
return new Promise(function(resolve, reject) {
|
|
14450
|
+
reader.onload = function() {
|
|
14451
|
+
resolve(reader.result);
|
|
14452
|
+
};
|
|
14453
|
+
reader.onerror = function() {
|
|
14454
|
+
reject(reader.error);
|
|
14455
|
+
};
|
|
14456
|
+
})
|
|
14457
|
+
}
|
|
14458
|
+
|
|
14459
|
+
function readBlobAsArrayBuffer(blob) {
|
|
14460
|
+
var reader = new FileReader();
|
|
14461
|
+
var promise = fileReaderReady(reader);
|
|
14462
|
+
reader.readAsArrayBuffer(blob);
|
|
14463
|
+
return promise
|
|
14464
|
+
}
|
|
14465
|
+
|
|
14466
|
+
function readBlobAsText(blob) {
|
|
14467
|
+
var reader = new FileReader();
|
|
14468
|
+
var promise = fileReaderReady(reader);
|
|
14469
|
+
reader.readAsText(blob);
|
|
14470
|
+
return promise
|
|
14471
|
+
}
|
|
14472
|
+
|
|
14473
|
+
function readArrayBufferAsText(buf) {
|
|
14474
|
+
var view = new Uint8Array(buf);
|
|
14475
|
+
var chars = new Array(view.length);
|
|
14476
|
+
|
|
14477
|
+
for (var i = 0; i < view.length; i++) {
|
|
14478
|
+
chars[i] = String.fromCharCode(view[i]);
|
|
14479
|
+
}
|
|
14480
|
+
return chars.join('')
|
|
14481
|
+
}
|
|
14482
|
+
|
|
14483
|
+
function bufferClone(buf) {
|
|
14484
|
+
if (buf.slice) {
|
|
14485
|
+
return buf.slice(0)
|
|
14486
|
+
} else {
|
|
14487
|
+
var view = new Uint8Array(buf.byteLength);
|
|
14488
|
+
view.set(new Uint8Array(buf));
|
|
14489
|
+
return view.buffer
|
|
14490
|
+
}
|
|
14491
|
+
}
|
|
14492
|
+
|
|
14493
|
+
function Body() {
|
|
14494
|
+
this.bodyUsed = false;
|
|
14495
|
+
|
|
14496
|
+
this._initBody = function(body) {
|
|
14497
|
+
this._bodyInit = body;
|
|
14498
|
+
if (!body) {
|
|
14499
|
+
this._bodyText = '';
|
|
14500
|
+
} else if (typeof body === 'string') {
|
|
14501
|
+
this._bodyText = body;
|
|
14502
|
+
} else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
|
|
14503
|
+
this._bodyBlob = body;
|
|
14504
|
+
} else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
|
|
14505
|
+
this._bodyFormData = body;
|
|
14506
|
+
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
|
|
14507
|
+
this._bodyText = body.toString();
|
|
14508
|
+
} else if (support.arrayBuffer && support.blob && isDataView(body)) {
|
|
14509
|
+
this._bodyArrayBuffer = bufferClone(body.buffer);
|
|
14510
|
+
// IE 10-11 can't handle a DataView body.
|
|
14511
|
+
this._bodyInit = new Blob([this._bodyArrayBuffer]);
|
|
14512
|
+
} else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
|
|
14513
|
+
this._bodyArrayBuffer = bufferClone(body);
|
|
14514
|
+
} else {
|
|
14515
|
+
this._bodyText = body = Object.prototype.toString.call(body);
|
|
14516
|
+
}
|
|
14517
|
+
|
|
14518
|
+
if (!this.headers.get('content-type')) {
|
|
14519
|
+
if (typeof body === 'string') {
|
|
14520
|
+
this.headers.set('content-type', 'text/plain;charset=UTF-8');
|
|
14521
|
+
} else if (this._bodyBlob && this._bodyBlob.type) {
|
|
14522
|
+
this.headers.set('content-type', this._bodyBlob.type);
|
|
14523
|
+
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
|
|
14524
|
+
this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
|
|
14525
|
+
}
|
|
14526
|
+
}
|
|
14527
|
+
};
|
|
14528
|
+
|
|
14529
|
+
if (support.blob) {
|
|
14530
|
+
this.blob = function() {
|
|
14531
|
+
var rejected = consumed(this);
|
|
14532
|
+
if (rejected) {
|
|
14533
|
+
return rejected
|
|
14534
|
+
}
|
|
14535
|
+
|
|
14536
|
+
if (this._bodyBlob) {
|
|
14537
|
+
return Promise.resolve(this._bodyBlob)
|
|
14538
|
+
} else if (this._bodyArrayBuffer) {
|
|
14539
|
+
return Promise.resolve(new Blob([this._bodyArrayBuffer]))
|
|
14540
|
+
} else if (this._bodyFormData) {
|
|
14541
|
+
throw new Error('could not read FormData body as blob')
|
|
14542
|
+
} else {
|
|
14543
|
+
return Promise.resolve(new Blob([this._bodyText]))
|
|
14544
|
+
}
|
|
14545
|
+
};
|
|
14546
|
+
|
|
14547
|
+
this.arrayBuffer = function() {
|
|
14548
|
+
if (this._bodyArrayBuffer) {
|
|
14549
|
+
return consumed(this) || Promise.resolve(this._bodyArrayBuffer)
|
|
14550
|
+
} else {
|
|
14551
|
+
return this.blob().then(readBlobAsArrayBuffer)
|
|
14552
|
+
}
|
|
14553
|
+
};
|
|
14554
|
+
}
|
|
14555
|
+
|
|
14556
|
+
this.text = function() {
|
|
14557
|
+
var rejected = consumed(this);
|
|
14558
|
+
if (rejected) {
|
|
14559
|
+
return rejected
|
|
14560
|
+
}
|
|
14561
|
+
|
|
14562
|
+
if (this._bodyBlob) {
|
|
14563
|
+
return readBlobAsText(this._bodyBlob)
|
|
14564
|
+
} else if (this._bodyArrayBuffer) {
|
|
14565
|
+
return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer))
|
|
14566
|
+
} else if (this._bodyFormData) {
|
|
14567
|
+
throw new Error('could not read FormData body as text')
|
|
14568
|
+
} else {
|
|
14569
|
+
return Promise.resolve(this._bodyText)
|
|
14570
|
+
}
|
|
14571
|
+
};
|
|
14572
|
+
|
|
14573
|
+
if (support.formData) {
|
|
14574
|
+
this.formData = function() {
|
|
14575
|
+
return this.text().then(decode)
|
|
14576
|
+
};
|
|
14577
|
+
}
|
|
14578
|
+
|
|
14579
|
+
this.json = function() {
|
|
14580
|
+
return this.text().then(JSON.parse)
|
|
14581
|
+
};
|
|
14582
|
+
|
|
14583
|
+
return this
|
|
14584
|
+
}
|
|
14585
|
+
|
|
14586
|
+
// HTTP methods whose capitalization should be normalized
|
|
14587
|
+
var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT'];
|
|
14588
|
+
|
|
14589
|
+
function normalizeMethod(method) {
|
|
14590
|
+
var upcased = method.toUpperCase();
|
|
14591
|
+
return methods.indexOf(upcased) > -1 ? upcased : method
|
|
14592
|
+
}
|
|
14593
|
+
|
|
14594
|
+
function Request(input, options) {
|
|
14595
|
+
options = options || {};
|
|
14596
|
+
var body = options.body;
|
|
14597
|
+
|
|
14598
|
+
if (input instanceof Request) {
|
|
14599
|
+
if (input.bodyUsed) {
|
|
14600
|
+
throw new TypeError('Already read')
|
|
14601
|
+
}
|
|
14602
|
+
this.url = input.url;
|
|
14603
|
+
this.credentials = input.credentials;
|
|
14604
|
+
if (!options.headers) {
|
|
14605
|
+
this.headers = new Headers(input.headers);
|
|
14606
|
+
}
|
|
14607
|
+
this.method = input.method;
|
|
14608
|
+
this.mode = input.mode;
|
|
14609
|
+
this.signal = input.signal;
|
|
14610
|
+
if (!body && input._bodyInit != null) {
|
|
14611
|
+
body = input._bodyInit;
|
|
14612
|
+
input.bodyUsed = true;
|
|
14613
|
+
}
|
|
14614
|
+
} else {
|
|
14615
|
+
this.url = String(input);
|
|
14616
|
+
}
|
|
14617
|
+
|
|
14618
|
+
this.credentials = options.credentials || this.credentials || 'same-origin';
|
|
14619
|
+
if (options.headers || !this.headers) {
|
|
14620
|
+
this.headers = new Headers(options.headers);
|
|
14621
|
+
}
|
|
14622
|
+
this.method = normalizeMethod(options.method || this.method || 'GET');
|
|
14623
|
+
this.mode = options.mode || this.mode || null;
|
|
14624
|
+
this.signal = options.signal || this.signal;
|
|
14625
|
+
this.referrer = null;
|
|
14626
|
+
|
|
14627
|
+
if ((this.method === 'GET' || this.method === 'HEAD') && body) {
|
|
14628
|
+
throw new TypeError('Body not allowed for GET or HEAD requests')
|
|
14629
|
+
}
|
|
14630
|
+
this._initBody(body);
|
|
14631
|
+
}
|
|
14632
|
+
|
|
14633
|
+
Request.prototype.clone = function() {
|
|
14634
|
+
return new Request(this, {body: this._bodyInit})
|
|
14635
|
+
};
|
|
14636
|
+
|
|
14637
|
+
function decode(body) {
|
|
14638
|
+
var form = new FormData();
|
|
14639
|
+
body
|
|
14640
|
+
.trim()
|
|
14641
|
+
.split('&')
|
|
14642
|
+
.forEach(function(bytes) {
|
|
14643
|
+
if (bytes) {
|
|
14644
|
+
var split = bytes.split('=');
|
|
14645
|
+
var name = split.shift().replace(/\+/g, ' ');
|
|
14646
|
+
var value = split.join('=').replace(/\+/g, ' ');
|
|
14647
|
+
form.append(decodeURIComponent(name), decodeURIComponent(value));
|
|
14648
|
+
}
|
|
14649
|
+
});
|
|
14650
|
+
return form
|
|
14651
|
+
}
|
|
14652
|
+
|
|
14653
|
+
function parseHeaders(rawHeaders) {
|
|
14654
|
+
var headers = new Headers();
|
|
14655
|
+
// Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space
|
|
14656
|
+
// https://tools.ietf.org/html/rfc7230#section-3.2
|
|
14657
|
+
var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' ');
|
|
14658
|
+
preProcessedHeaders.split(/\r?\n/).forEach(function(line) {
|
|
14659
|
+
var parts = line.split(':');
|
|
14660
|
+
var key = parts.shift().trim();
|
|
14661
|
+
if (key) {
|
|
14662
|
+
var value = parts.join(':').trim();
|
|
14663
|
+
headers.append(key, value);
|
|
14664
|
+
}
|
|
14665
|
+
});
|
|
14666
|
+
return headers
|
|
14667
|
+
}
|
|
14668
|
+
|
|
14669
|
+
Body.call(Request.prototype);
|
|
14670
|
+
|
|
14671
|
+
function Response(bodyInit, options) {
|
|
14672
|
+
if (!options) {
|
|
14673
|
+
options = {};
|
|
14674
|
+
}
|
|
14675
|
+
|
|
14676
|
+
this.type = 'default';
|
|
14677
|
+
this.status = options.status === undefined ? 200 : options.status;
|
|
14678
|
+
this.ok = this.status >= 200 && this.status < 300;
|
|
14679
|
+
this.statusText = 'statusText' in options ? options.statusText : 'OK';
|
|
14680
|
+
this.headers = new Headers(options.headers);
|
|
14681
|
+
this.url = options.url || '';
|
|
14682
|
+
this._initBody(bodyInit);
|
|
14683
|
+
}
|
|
14684
|
+
|
|
14685
|
+
Body.call(Response.prototype);
|
|
14686
|
+
|
|
14687
|
+
Response.prototype.clone = function() {
|
|
14688
|
+
return new Response(this._bodyInit, {
|
|
14689
|
+
status: this.status,
|
|
14690
|
+
statusText: this.statusText,
|
|
14691
|
+
headers: new Headers(this.headers),
|
|
14692
|
+
url: this.url
|
|
14693
|
+
})
|
|
14694
|
+
};
|
|
14695
|
+
|
|
14696
|
+
Response.error = function() {
|
|
14697
|
+
var response = new Response(null, {status: 0, statusText: ''});
|
|
14698
|
+
response.type = 'error';
|
|
14699
|
+
return response
|
|
14700
|
+
};
|
|
14701
|
+
|
|
14702
|
+
var redirectStatuses = [301, 302, 303, 307, 308];
|
|
14703
|
+
|
|
14704
|
+
Response.redirect = function(url, status) {
|
|
14705
|
+
if (redirectStatuses.indexOf(status) === -1) {
|
|
14706
|
+
throw new RangeError('Invalid status code')
|
|
14707
|
+
}
|
|
14708
|
+
|
|
14709
|
+
return new Response(null, {status: status, headers: {location: url}})
|
|
14710
|
+
};
|
|
14711
|
+
|
|
14712
|
+
exports.DOMException = self.DOMException;
|
|
14713
|
+
try {
|
|
14714
|
+
new exports.DOMException();
|
|
14715
|
+
} catch (err) {
|
|
14716
|
+
exports.DOMException = function(message, name) {
|
|
14717
|
+
this.message = message;
|
|
14718
|
+
this.name = name;
|
|
14719
|
+
var error = Error(message);
|
|
14720
|
+
this.stack = error.stack;
|
|
14721
|
+
};
|
|
14722
|
+
exports.DOMException.prototype = Object.create(Error.prototype);
|
|
14723
|
+
exports.DOMException.prototype.constructor = exports.DOMException;
|
|
14724
|
+
}
|
|
14725
|
+
|
|
14726
|
+
function fetch(input, init) {
|
|
14727
|
+
return new Promise(function(resolve, reject) {
|
|
14728
|
+
var request = new Request(input, init);
|
|
14729
|
+
|
|
14730
|
+
if (request.signal && request.signal.aborted) {
|
|
14731
|
+
return reject(new exports.DOMException('Aborted', 'AbortError'))
|
|
14732
|
+
}
|
|
14733
|
+
|
|
14734
|
+
var xhr = new XMLHttpRequest();
|
|
14735
|
+
|
|
14736
|
+
function abortXhr() {
|
|
14737
|
+
xhr.abort();
|
|
14738
|
+
}
|
|
14739
|
+
|
|
14740
|
+
xhr.onload = function() {
|
|
14741
|
+
var options = {
|
|
14742
|
+
status: xhr.status,
|
|
14743
|
+
statusText: xhr.statusText,
|
|
14744
|
+
headers: parseHeaders(xhr.getAllResponseHeaders() || '')
|
|
14745
|
+
};
|
|
14746
|
+
options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL');
|
|
14747
|
+
var body = 'response' in xhr ? xhr.response : xhr.responseText;
|
|
14748
|
+
resolve(new Response(body, options));
|
|
14749
|
+
};
|
|
14750
|
+
|
|
14751
|
+
xhr.onerror = function() {
|
|
14752
|
+
reject(new TypeError('Network request failed'));
|
|
14753
|
+
};
|
|
14754
|
+
|
|
14755
|
+
xhr.ontimeout = function() {
|
|
14756
|
+
reject(new TypeError('Network request failed'));
|
|
14757
|
+
};
|
|
14758
|
+
|
|
14759
|
+
xhr.onabort = function() {
|
|
14760
|
+
reject(new exports.DOMException('Aborted', 'AbortError'));
|
|
14761
|
+
};
|
|
14762
|
+
|
|
14763
|
+
xhr.open(request.method, request.url, true);
|
|
14764
|
+
|
|
14765
|
+
if (request.credentials === 'include') {
|
|
14766
|
+
xhr.withCredentials = true;
|
|
14767
|
+
} else if (request.credentials === 'omit') {
|
|
14768
|
+
xhr.withCredentials = false;
|
|
14769
|
+
}
|
|
14770
|
+
|
|
14771
|
+
if ('responseType' in xhr && support.blob) {
|
|
14772
|
+
xhr.responseType = 'blob';
|
|
14773
|
+
}
|
|
14774
|
+
|
|
14775
|
+
request.headers.forEach(function(value, name) {
|
|
14776
|
+
xhr.setRequestHeader(name, value);
|
|
14777
|
+
});
|
|
14778
|
+
|
|
14779
|
+
if (request.signal) {
|
|
14780
|
+
request.signal.addEventListener('abort', abortXhr);
|
|
14781
|
+
|
|
14782
|
+
xhr.onreadystatechange = function() {
|
|
14783
|
+
// DONE (success or failure)
|
|
14784
|
+
if (xhr.readyState === 4) {
|
|
14785
|
+
request.signal.removeEventListener('abort', abortXhr);
|
|
14786
|
+
}
|
|
14787
|
+
};
|
|
14788
|
+
}
|
|
14789
|
+
|
|
14790
|
+
xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit);
|
|
14791
|
+
})
|
|
14792
|
+
}
|
|
14793
|
+
|
|
14794
|
+
fetch.polyfill = true;
|
|
14795
|
+
|
|
14796
|
+
if (!self.fetch) {
|
|
14797
|
+
self.fetch = fetch;
|
|
14798
|
+
self.Headers = Headers;
|
|
14799
|
+
self.Request = Request;
|
|
14800
|
+
self.Response = Response;
|
|
14801
|
+
}
|
|
14802
|
+
|
|
14803
|
+
exports.Headers = Headers;
|
|
14804
|
+
exports.Request = Request;
|
|
14805
|
+
exports.Response = Response;
|
|
14806
|
+
exports.fetch = fetch;
|
|
14807
|
+
|
|
14808
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14809
|
+
|
|
14810
|
+
return exports;
|
|
14811
|
+
|
|
14812
|
+
})({}));
|
|
14813
|
+
})(__self__);
|
|
14814
|
+
__self__.fetch.ponyfill = true;
|
|
14815
|
+
// Remove "polyfill" property added by whatwg-fetch
|
|
14816
|
+
delete __self__.fetch.polyfill;
|
|
14817
|
+
// Choose between native implementation (global) or custom implementation (__self__)
|
|
14818
|
+
// var ctx = global.fetch ? global : __self__;
|
|
14819
|
+
var ctx = __self__; // this line disable service worker support temporarily
|
|
14820
|
+
exports = ctx.fetch; // To enable: import fetch from 'cross-fetch'
|
|
14821
|
+
exports.default = ctx.fetch; // For TypeScript consumers without esModuleInterop.
|
|
14822
|
+
exports.fetch = ctx.fetch; // To enable: import {fetch} from 'cross-fetch'
|
|
14823
|
+
exports.Headers = ctx.Headers;
|
|
14824
|
+
exports.Request = ctx.Request;
|
|
14825
|
+
exports.Response = ctx.Response;
|
|
14826
|
+
module.exports = exports;
|
|
14827
|
+
}(browserPonyfill, browserPonyfill.exports));
|
|
14828
|
+
|
|
14829
|
+
var fetch = /*@__PURE__*/getDefaultExportFromCjs(browserPonyfill.exports);
|
|
14274
14830
|
|
|
14275
14831
|
/**
|
|
14276
14832
|
* A `StructFailure` represents a single specific failure in validation.
|
|
@@ -17706,7 +18262,15 @@ var solanaWeb3 = (function (exports) {
|
|
|
17706
18262
|
});
|
|
17707
18263
|
const SimulatedTransactionResponseStruct = jsonRpcResultAndContext(type({
|
|
17708
18264
|
err: nullable(union([type({}), string()])),
|
|
17709
|
-
logs: nullable(array(string()))
|
|
18265
|
+
logs: nullable(array(string())),
|
|
18266
|
+
accounts: optional(nullable(array(type({
|
|
18267
|
+
executable: boolean(),
|
|
18268
|
+
owner: string(),
|
|
18269
|
+
lamports: number(),
|
|
18270
|
+
data: array(string()),
|
|
18271
|
+
rentEpoch: optional(number())
|
|
18272
|
+
})))),
|
|
18273
|
+
unitsConsumed: optional(number())
|
|
17710
18274
|
}));
|
|
17711
18275
|
|
|
17712
18276
|
function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware, disableRetryOnRateLimit) {
|
|
@@ -18432,6 +18996,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
18432
18996
|
|
|
18433
18997
|
/** @internal */
|
|
18434
18998
|
|
|
18999
|
+
/** @internal */
|
|
19000
|
+
|
|
18435
19001
|
/**
|
|
18436
19002
|
* Establish a JSON RPC connection
|
|
18437
19003
|
*
|
|
@@ -18441,6 +19007,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
18441
19007
|
constructor(endpoint, commitmentOrConfig) {
|
|
18442
19008
|
_defineProperty(this, "_commitment", void 0);
|
|
18443
19009
|
|
|
19010
|
+
_defineProperty(this, "_confirmTransactionInitialTimeout", void 0);
|
|
19011
|
+
|
|
18444
19012
|
_defineProperty(this, "_rpcEndpoint", void 0);
|
|
18445
19013
|
|
|
18446
19014
|
_defineProperty(this, "_rpcWsEndpoint", void 0);
|
|
@@ -18509,6 +19077,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
18509
19077
|
this._commitment = commitmentOrConfig;
|
|
18510
19078
|
} else if (commitmentOrConfig) {
|
|
18511
19079
|
this._commitment = commitmentOrConfig.commitment;
|
|
19080
|
+
this._confirmTransactionInitialTimeout = commitmentOrConfig.confirmTransactionInitialTimeout;
|
|
18512
19081
|
wsEndpoint = commitmentOrConfig.wsEndpoint;
|
|
18513
19082
|
httpHeaders = commitmentOrConfig.httpHeaders;
|
|
18514
19083
|
fetchMiddleware = commitmentOrConfig.fetchMiddleware;
|
|
@@ -18968,7 +19537,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
18968
19537
|
reject(err);
|
|
18969
19538
|
}
|
|
18970
19539
|
});
|
|
18971
|
-
let timeoutMs = 60 * 1000;
|
|
19540
|
+
let timeoutMs = this._confirmTransactionInitialTimeout || 60 * 1000;
|
|
18972
19541
|
|
|
18973
19542
|
switch (subscriptionCommitment) {
|
|
18974
19543
|
case 'processed':
|
|
@@ -18977,7 +19546,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
18977
19546
|
case 'confirmed':
|
|
18978
19547
|
case 'singleGossip':
|
|
18979
19548
|
{
|
|
18980
|
-
timeoutMs = 30 * 1000;
|
|
19549
|
+
timeoutMs = this._confirmTransactionInitialTimeout || 30 * 1000;
|
|
18981
19550
|
break;
|
|
18982
19551
|
}
|
|
18983
19552
|
}
|
|
@@ -19349,6 +19918,21 @@ var solanaWeb3 = (function (exports) {
|
|
|
19349
19918
|
|
|
19350
19919
|
return res.result;
|
|
19351
19920
|
}
|
|
19921
|
+
/**
|
|
19922
|
+
* Fetch the genesis hash
|
|
19923
|
+
*/
|
|
19924
|
+
|
|
19925
|
+
|
|
19926
|
+
async getGenesisHash() {
|
|
19927
|
+
const unsafeRes = await this._rpcRequest('getGenesisHash', []);
|
|
19928
|
+
const res = create(unsafeRes, jsonRpcResult(string()));
|
|
19929
|
+
|
|
19930
|
+
if ('error' in res) {
|
|
19931
|
+
throw new Error('failed to get genesis hash: ' + res.error.message);
|
|
19932
|
+
}
|
|
19933
|
+
|
|
19934
|
+
return res.result;
|
|
19935
|
+
}
|
|
19352
19936
|
/**
|
|
19353
19937
|
* Fetch a processed block from the cluster.
|
|
19354
19938
|
*/
|
|
@@ -19749,7 +20333,15 @@ var solanaWeb3 = (function (exports) {
|
|
|
19749
20333
|
*/
|
|
19750
20334
|
|
|
19751
20335
|
|
|
19752
|
-
async simulateTransaction(
|
|
20336
|
+
async simulateTransaction(transactionOrMessage, signers, includeAccounts) {
|
|
20337
|
+
let transaction;
|
|
20338
|
+
|
|
20339
|
+
if (transactionOrMessage instanceof Transaction) {
|
|
20340
|
+
transaction = transactionOrMessage;
|
|
20341
|
+
} else {
|
|
20342
|
+
transaction = Transaction.populate(transactionOrMessage);
|
|
20343
|
+
}
|
|
20344
|
+
|
|
19753
20345
|
if (transaction.nonceInfo && signers) {
|
|
19754
20346
|
transaction.sign(...signers);
|
|
19755
20347
|
} else {
|
|
@@ -19782,7 +20374,9 @@ var solanaWeb3 = (function (exports) {
|
|
|
19782
20374
|
}
|
|
19783
20375
|
}
|
|
19784
20376
|
|
|
19785
|
-
const
|
|
20377
|
+
const message = transaction._compile();
|
|
20378
|
+
|
|
20379
|
+
const signData = message.serialize();
|
|
19786
20380
|
|
|
19787
20381
|
const wireTransaction = transaction._serialize(signData);
|
|
19788
20382
|
|
|
@@ -19792,6 +20386,14 @@ var solanaWeb3 = (function (exports) {
|
|
|
19792
20386
|
commitment: this.commitment
|
|
19793
20387
|
};
|
|
19794
20388
|
|
|
20389
|
+
if (includeAccounts) {
|
|
20390
|
+
const addresses = (Array.isArray(includeAccounts) ? includeAccounts : message.nonProgramIds()).map(key => key.toBase58());
|
|
20391
|
+
config['accounts'] = {
|
|
20392
|
+
encoding: 'base64',
|
|
20393
|
+
addresses
|
|
20394
|
+
};
|
|
20395
|
+
}
|
|
20396
|
+
|
|
19795
20397
|
if (signers) {
|
|
19796
20398
|
config.sigVerify = true;
|
|
19797
20399
|
}
|
|
@@ -20672,6 +21274,96 @@ var solanaWeb3 = (function (exports) {
|
|
|
20672
21274
|
|
|
20673
21275
|
}
|
|
20674
21276
|
|
|
21277
|
+
const PRIVATE_KEY_BYTES$1 = 64;
|
|
21278
|
+
const PUBLIC_KEY_BYTES$1 = 32;
|
|
21279
|
+
const SIGNATURE_BYTES = 64;
|
|
21280
|
+
/**
|
|
21281
|
+
* Params for creating an ed25519 instruction using a public key
|
|
21282
|
+
*/
|
|
21283
|
+
|
|
21284
|
+
const ED25519_INSTRUCTION_LAYOUT = struct([u8('numSignatures'), u8('padding'), u16('signatureOffset'), u16('signatureInstructionIndex'), u16('publicKeyOffset'), u16('publicKeyInstructionIndex'), u16('messageDataOffset'), u16('messageDataSize'), u16('messageInstructionIndex')]);
|
|
21285
|
+
class Ed25519Program {
|
|
21286
|
+
/**
|
|
21287
|
+
* @internal
|
|
21288
|
+
*/
|
|
21289
|
+
constructor() {}
|
|
21290
|
+
/**
|
|
21291
|
+
* Public key that identifies the ed25519 program
|
|
21292
|
+
*/
|
|
21293
|
+
|
|
21294
|
+
|
|
21295
|
+
/**
|
|
21296
|
+
* Create an ed25519 instruction with a public key and signature. The
|
|
21297
|
+
* public key must be a buffer that is 32 bytes long, and the signature
|
|
21298
|
+
* must be a buffer of 64 bytes.
|
|
21299
|
+
*/
|
|
21300
|
+
static createInstructionWithPublicKey(params) {
|
|
21301
|
+
const {
|
|
21302
|
+
publicKey,
|
|
21303
|
+
message,
|
|
21304
|
+
signature,
|
|
21305
|
+
instructionIndex
|
|
21306
|
+
} = params;
|
|
21307
|
+
assert$i(publicKey.length === PUBLIC_KEY_BYTES$1, `Public Key must be ${PUBLIC_KEY_BYTES$1} bytes but received ${publicKey.length} bytes`);
|
|
21308
|
+
assert$i(signature.length === SIGNATURE_BYTES, `Signature must be ${SIGNATURE_BYTES} bytes but received ${signature.length} bytes`);
|
|
21309
|
+
const publicKeyOffset = ED25519_INSTRUCTION_LAYOUT.span;
|
|
21310
|
+
const signatureOffset = publicKeyOffset + publicKey.length;
|
|
21311
|
+
const messageDataOffset = signatureOffset + signature.length;
|
|
21312
|
+
const numSignatures = 1;
|
|
21313
|
+
const instructionData = buffer.Buffer.alloc(messageDataOffset + message.length);
|
|
21314
|
+
ED25519_INSTRUCTION_LAYOUT.encode({
|
|
21315
|
+
numSignatures,
|
|
21316
|
+
padding: 0,
|
|
21317
|
+
signatureOffset,
|
|
21318
|
+
signatureInstructionIndex: instructionIndex,
|
|
21319
|
+
publicKeyOffset,
|
|
21320
|
+
publicKeyInstructionIndex: instructionIndex,
|
|
21321
|
+
messageDataOffset,
|
|
21322
|
+
messageDataSize: message.length,
|
|
21323
|
+
messageInstructionIndex: instructionIndex
|
|
21324
|
+
}, instructionData);
|
|
21325
|
+
instructionData.fill(publicKey, publicKeyOffset);
|
|
21326
|
+
instructionData.fill(signature, signatureOffset);
|
|
21327
|
+
instructionData.fill(message, messageDataOffset);
|
|
21328
|
+
return new TransactionInstruction({
|
|
21329
|
+
keys: [],
|
|
21330
|
+
programId: Ed25519Program.programId,
|
|
21331
|
+
data: instructionData
|
|
21332
|
+
});
|
|
21333
|
+
}
|
|
21334
|
+
/**
|
|
21335
|
+
* Create an ed25519 instruction with a private key. The private key
|
|
21336
|
+
* must be a buffer that is 64 bytes long.
|
|
21337
|
+
*/
|
|
21338
|
+
|
|
21339
|
+
|
|
21340
|
+
static createInstructionWithPrivateKey(params) {
|
|
21341
|
+
const {
|
|
21342
|
+
privateKey,
|
|
21343
|
+
message,
|
|
21344
|
+
instructionIndex
|
|
21345
|
+
} = params;
|
|
21346
|
+
assert$i(privateKey.length === PRIVATE_KEY_BYTES$1, `Private key must be ${PRIVATE_KEY_BYTES$1} bytes but received ${privateKey.length} bytes`);
|
|
21347
|
+
|
|
21348
|
+
try {
|
|
21349
|
+
const keypair = Keypair.fromSecretKey(privateKey);
|
|
21350
|
+
const publicKey = keypair.publicKey.toBytes();
|
|
21351
|
+
const signature = nacl.sign.detached(message, keypair.secretKey);
|
|
21352
|
+
return this.createInstructionWithPublicKey({
|
|
21353
|
+
publicKey,
|
|
21354
|
+
message,
|
|
21355
|
+
signature,
|
|
21356
|
+
instructionIndex
|
|
21357
|
+
});
|
|
21358
|
+
} catch (error) {
|
|
21359
|
+
throw new Error(`Error creating instruction; ${error}`);
|
|
21360
|
+
}
|
|
21361
|
+
}
|
|
21362
|
+
|
|
21363
|
+
}
|
|
21364
|
+
|
|
21365
|
+
_defineProperty(Ed25519Program, "programId", new PublicKey('Ed25519SigVerify111111111111111111111111111'));
|
|
21366
|
+
|
|
20675
21367
|
/**
|
|
20676
21368
|
* Address of the stake config account which configures the rate
|
|
20677
21369
|
* of stake warmup and cooldown as well as the slashing penalty.
|
|
@@ -28679,6 +29371,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
28679
29371
|
exports.BPF_LOADER_PROGRAM_ID = BPF_LOADER_PROGRAM_ID;
|
|
28680
29372
|
exports.BpfLoader = BpfLoader;
|
|
28681
29373
|
exports.Connection = Connection;
|
|
29374
|
+
exports.Ed25519Program = Ed25519Program;
|
|
28682
29375
|
exports.Enum = Enum;
|
|
28683
29376
|
exports.EpochSchedule = EpochSchedule;
|
|
28684
29377
|
exports.FeeCalculatorLayout = FeeCalculatorLayout;
|