@canton-network/core-token-standard 0.19.1 → 0.21.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.
@@ -3218,3008 +3218,6 @@ function requireTypes$1 () {
3218
3218
  return types;
3219
3219
  }
3220
3220
 
3221
- var ledger = {};
3222
-
3223
- var browserPonyfill = {exports: {}};
3224
-
3225
- var hasRequiredBrowserPonyfill;
3226
-
3227
- function requireBrowserPonyfill () {
3228
- if (hasRequiredBrowserPonyfill) return browserPonyfill.exports;
3229
- hasRequiredBrowserPonyfill = 1;
3230
- (function (module, exports$1) {
3231
- // Save global object in a variable
3232
- var __global__ =
3233
- (typeof globalThis !== 'undefined' && globalThis) ||
3234
- (typeof self !== 'undefined' && self) ||
3235
- (typeof commonjsGlobal !== 'undefined' && commonjsGlobal);
3236
- // Create an object that extends from __global__ without the fetch function
3237
- var __globalThis__ = (function () {
3238
- function F() {
3239
- this.fetch = false;
3240
- this.DOMException = __global__.DOMException;
3241
- }
3242
- F.prototype = __global__; // Needed for feature detection on whatwg-fetch's code
3243
- return new F();
3244
- })();
3245
- // Wraps whatwg-fetch with a function scope to hijack the global object
3246
- // "globalThis" that's going to be patched
3247
- (function(globalThis) {
3248
-
3249
- ((function (exports$1) {
3250
-
3251
- /* eslint-disable no-prototype-builtins */
3252
- var g =
3253
- (typeof globalThis !== 'undefined' && globalThis) ||
3254
- (typeof self !== 'undefined' && self) ||
3255
- // eslint-disable-next-line no-undef
3256
- (typeof commonjsGlobal !== 'undefined' && commonjsGlobal) ||
3257
- {};
3258
-
3259
- var support = {
3260
- searchParams: 'URLSearchParams' in g,
3261
- iterable: 'Symbol' in g && 'iterator' in Symbol,
3262
- blob:
3263
- 'FileReader' in g &&
3264
- 'Blob' in g &&
3265
- (function() {
3266
- try {
3267
- new Blob();
3268
- return true
3269
- } catch (e) {
3270
- return false
3271
- }
3272
- })(),
3273
- formData: 'FormData' in g,
3274
- arrayBuffer: 'ArrayBuffer' in g
3275
- };
3276
-
3277
- function isDataView(obj) {
3278
- return obj && DataView.prototype.isPrototypeOf(obj)
3279
- }
3280
-
3281
- if (support.arrayBuffer) {
3282
- var viewClasses = [
3283
- '[object Int8Array]',
3284
- '[object Uint8Array]',
3285
- '[object Uint8ClampedArray]',
3286
- '[object Int16Array]',
3287
- '[object Uint16Array]',
3288
- '[object Int32Array]',
3289
- '[object Uint32Array]',
3290
- '[object Float32Array]',
3291
- '[object Float64Array]'
3292
- ];
3293
-
3294
- var isArrayBufferView =
3295
- ArrayBuffer.isView ||
3296
- function(obj) {
3297
- return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1
3298
- };
3299
- }
3300
-
3301
- function normalizeName(name) {
3302
- if (typeof name !== 'string') {
3303
- name = String(name);
3304
- }
3305
- if (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name) || name === '') {
3306
- throw new TypeError('Invalid character in header field name: "' + name + '"')
3307
- }
3308
- return name.toLowerCase()
3309
- }
3310
-
3311
- function normalizeValue(value) {
3312
- if (typeof value !== 'string') {
3313
- value = String(value);
3314
- }
3315
- return value
3316
- }
3317
-
3318
- // Build a destructive iterator for the value list
3319
- function iteratorFor(items) {
3320
- var iterator = {
3321
- next: function() {
3322
- var value = items.shift();
3323
- return {done: value === undefined, value: value}
3324
- }
3325
- };
3326
-
3327
- if (support.iterable) {
3328
- iterator[Symbol.iterator] = function() {
3329
- return iterator
3330
- };
3331
- }
3332
-
3333
- return iterator
3334
- }
3335
-
3336
- function Headers(headers) {
3337
- this.map = {};
3338
-
3339
- if (headers instanceof Headers) {
3340
- headers.forEach(function(value, name) {
3341
- this.append(name, value);
3342
- }, this);
3343
- } else if (Array.isArray(headers)) {
3344
- headers.forEach(function(header) {
3345
- if (header.length != 2) {
3346
- throw new TypeError('Headers constructor: expected name/value pair to be length 2, found' + header.length)
3347
- }
3348
- this.append(header[0], header[1]);
3349
- }, this);
3350
- } else if (headers) {
3351
- Object.getOwnPropertyNames(headers).forEach(function(name) {
3352
- this.append(name, headers[name]);
3353
- }, this);
3354
- }
3355
- }
3356
-
3357
- Headers.prototype.append = function(name, value) {
3358
- name = normalizeName(name);
3359
- value = normalizeValue(value);
3360
- var oldValue = this.map[name];
3361
- this.map[name] = oldValue ? oldValue + ', ' + value : value;
3362
- };
3363
-
3364
- Headers.prototype['delete'] = function(name) {
3365
- delete this.map[normalizeName(name)];
3366
- };
3367
-
3368
- Headers.prototype.get = function(name) {
3369
- name = normalizeName(name);
3370
- return this.has(name) ? this.map[name] : null
3371
- };
3372
-
3373
- Headers.prototype.has = function(name) {
3374
- return this.map.hasOwnProperty(normalizeName(name))
3375
- };
3376
-
3377
- Headers.prototype.set = function(name, value) {
3378
- this.map[normalizeName(name)] = normalizeValue(value);
3379
- };
3380
-
3381
- Headers.prototype.forEach = function(callback, thisArg) {
3382
- for (var name in this.map) {
3383
- if (this.map.hasOwnProperty(name)) {
3384
- callback.call(thisArg, this.map[name], name, this);
3385
- }
3386
- }
3387
- };
3388
-
3389
- Headers.prototype.keys = function() {
3390
- var items = [];
3391
- this.forEach(function(value, name) {
3392
- items.push(name);
3393
- });
3394
- return iteratorFor(items)
3395
- };
3396
-
3397
- Headers.prototype.values = function() {
3398
- var items = [];
3399
- this.forEach(function(value) {
3400
- items.push(value);
3401
- });
3402
- return iteratorFor(items)
3403
- };
3404
-
3405
- Headers.prototype.entries = function() {
3406
- var items = [];
3407
- this.forEach(function(value, name) {
3408
- items.push([name, value]);
3409
- });
3410
- return iteratorFor(items)
3411
- };
3412
-
3413
- if (support.iterable) {
3414
- Headers.prototype[Symbol.iterator] = Headers.prototype.entries;
3415
- }
3416
-
3417
- function consumed(body) {
3418
- if (body._noBody) return
3419
- if (body.bodyUsed) {
3420
- return Promise.reject(new TypeError('Already read'))
3421
- }
3422
- body.bodyUsed = true;
3423
- }
3424
-
3425
- function fileReaderReady(reader) {
3426
- return new Promise(function(resolve, reject) {
3427
- reader.onload = function() {
3428
- resolve(reader.result);
3429
- };
3430
- reader.onerror = function() {
3431
- reject(reader.error);
3432
- };
3433
- })
3434
- }
3435
-
3436
- function readBlobAsArrayBuffer(blob) {
3437
- var reader = new FileReader();
3438
- var promise = fileReaderReady(reader);
3439
- reader.readAsArrayBuffer(blob);
3440
- return promise
3441
- }
3442
-
3443
- function readBlobAsText(blob) {
3444
- var reader = new FileReader();
3445
- var promise = fileReaderReady(reader);
3446
- var match = /charset=([A-Za-z0-9_-]+)/.exec(blob.type);
3447
- var encoding = match ? match[1] : 'utf-8';
3448
- reader.readAsText(blob, encoding);
3449
- return promise
3450
- }
3451
-
3452
- function readArrayBufferAsText(buf) {
3453
- var view = new Uint8Array(buf);
3454
- var chars = new Array(view.length);
3455
-
3456
- for (var i = 0; i < view.length; i++) {
3457
- chars[i] = String.fromCharCode(view[i]);
3458
- }
3459
- return chars.join('')
3460
- }
3461
-
3462
- function bufferClone(buf) {
3463
- if (buf.slice) {
3464
- return buf.slice(0)
3465
- } else {
3466
- var view = new Uint8Array(buf.byteLength);
3467
- view.set(new Uint8Array(buf));
3468
- return view.buffer
3469
- }
3470
- }
3471
-
3472
- function Body() {
3473
- this.bodyUsed = false;
3474
-
3475
- this._initBody = function(body) {
3476
- /*
3477
- fetch-mock wraps the Response object in an ES6 Proxy to
3478
- provide useful test harness features such as flush. However, on
3479
- ES5 browsers without fetch or Proxy support pollyfills must be used;
3480
- the proxy-pollyfill is unable to proxy an attribute unless it exists
3481
- on the object before the Proxy is created. This change ensures
3482
- Response.bodyUsed exists on the instance, while maintaining the
3483
- semantic of setting Request.bodyUsed in the constructor before
3484
- _initBody is called.
3485
- */
3486
- // eslint-disable-next-line no-self-assign
3487
- this.bodyUsed = this.bodyUsed;
3488
- this._bodyInit = body;
3489
- if (!body) {
3490
- this._noBody = true;
3491
- this._bodyText = '';
3492
- } else if (typeof body === 'string') {
3493
- this._bodyText = body;
3494
- } else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
3495
- this._bodyBlob = body;
3496
- } else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
3497
- this._bodyFormData = body;
3498
- } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
3499
- this._bodyText = body.toString();
3500
- } else if (support.arrayBuffer && support.blob && isDataView(body)) {
3501
- this._bodyArrayBuffer = bufferClone(body.buffer);
3502
- // IE 10-11 can't handle a DataView body.
3503
- this._bodyInit = new Blob([this._bodyArrayBuffer]);
3504
- } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
3505
- this._bodyArrayBuffer = bufferClone(body);
3506
- } else {
3507
- this._bodyText = body = Object.prototype.toString.call(body);
3508
- }
3509
-
3510
- if (!this.headers.get('content-type')) {
3511
- if (typeof body === 'string') {
3512
- this.headers.set('content-type', 'text/plain;charset=UTF-8');
3513
- } else if (this._bodyBlob && this._bodyBlob.type) {
3514
- this.headers.set('content-type', this._bodyBlob.type);
3515
- } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
3516
- this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
3517
- }
3518
- }
3519
- };
3520
-
3521
- if (support.blob) {
3522
- this.blob = function() {
3523
- var rejected = consumed(this);
3524
- if (rejected) {
3525
- return rejected
3526
- }
3527
-
3528
- if (this._bodyBlob) {
3529
- return Promise.resolve(this._bodyBlob)
3530
- } else if (this._bodyArrayBuffer) {
3531
- return Promise.resolve(new Blob([this._bodyArrayBuffer]))
3532
- } else if (this._bodyFormData) {
3533
- throw new Error('could not read FormData body as blob')
3534
- } else {
3535
- return Promise.resolve(new Blob([this._bodyText]))
3536
- }
3537
- };
3538
- }
3539
-
3540
- this.arrayBuffer = function() {
3541
- if (this._bodyArrayBuffer) {
3542
- var isConsumed = consumed(this);
3543
- if (isConsumed) {
3544
- return isConsumed
3545
- } else if (ArrayBuffer.isView(this._bodyArrayBuffer)) {
3546
- return Promise.resolve(
3547
- this._bodyArrayBuffer.buffer.slice(
3548
- this._bodyArrayBuffer.byteOffset,
3549
- this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength
3550
- )
3551
- )
3552
- } else {
3553
- return Promise.resolve(this._bodyArrayBuffer)
3554
- }
3555
- } else if (support.blob) {
3556
- return this.blob().then(readBlobAsArrayBuffer)
3557
- } else {
3558
- throw new Error('could not read as ArrayBuffer')
3559
- }
3560
- };
3561
-
3562
- this.text = function() {
3563
- var rejected = consumed(this);
3564
- if (rejected) {
3565
- return rejected
3566
- }
3567
-
3568
- if (this._bodyBlob) {
3569
- return readBlobAsText(this._bodyBlob)
3570
- } else if (this._bodyArrayBuffer) {
3571
- return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer))
3572
- } else if (this._bodyFormData) {
3573
- throw new Error('could not read FormData body as text')
3574
- } else {
3575
- return Promise.resolve(this._bodyText)
3576
- }
3577
- };
3578
-
3579
- if (support.formData) {
3580
- this.formData = function() {
3581
- return this.text().then(decode)
3582
- };
3583
- }
3584
-
3585
- this.json = function() {
3586
- return this.text().then(JSON.parse)
3587
- };
3588
-
3589
- return this
3590
- }
3591
-
3592
- // HTTP methods whose capitalization should be normalized
3593
- var methods = ['CONNECT', 'DELETE', 'GET', 'HEAD', 'OPTIONS', 'PATCH', 'POST', 'PUT', 'TRACE'];
3594
-
3595
- function normalizeMethod(method) {
3596
- var upcased = method.toUpperCase();
3597
- return methods.indexOf(upcased) > -1 ? upcased : method
3598
- }
3599
-
3600
- function Request(input, options) {
3601
- if (!(this instanceof Request)) {
3602
- throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.')
3603
- }
3604
-
3605
- options = options || {};
3606
- var body = options.body;
3607
-
3608
- if (input instanceof Request) {
3609
- if (input.bodyUsed) {
3610
- throw new TypeError('Already read')
3611
- }
3612
- this.url = input.url;
3613
- this.credentials = input.credentials;
3614
- if (!options.headers) {
3615
- this.headers = new Headers(input.headers);
3616
- }
3617
- this.method = input.method;
3618
- this.mode = input.mode;
3619
- this.signal = input.signal;
3620
- if (!body && input._bodyInit != null) {
3621
- body = input._bodyInit;
3622
- input.bodyUsed = true;
3623
- }
3624
- } else {
3625
- this.url = String(input);
3626
- }
3627
-
3628
- this.credentials = options.credentials || this.credentials || 'same-origin';
3629
- if (options.headers || !this.headers) {
3630
- this.headers = new Headers(options.headers);
3631
- }
3632
- this.method = normalizeMethod(options.method || this.method || 'GET');
3633
- this.mode = options.mode || this.mode || null;
3634
- this.signal = options.signal || this.signal || (function () {
3635
- if ('AbortController' in g) {
3636
- var ctrl = new AbortController();
3637
- return ctrl.signal;
3638
- }
3639
- }());
3640
- this.referrer = null;
3641
-
3642
- if ((this.method === 'GET' || this.method === 'HEAD') && body) {
3643
- throw new TypeError('Body not allowed for GET or HEAD requests')
3644
- }
3645
- this._initBody(body);
3646
-
3647
- if (this.method === 'GET' || this.method === 'HEAD') {
3648
- if (options.cache === 'no-store' || options.cache === 'no-cache') {
3649
- // Search for a '_' parameter in the query string
3650
- var reParamSearch = /([?&])_=[^&]*/;
3651
- if (reParamSearch.test(this.url)) {
3652
- // If it already exists then set the value with the current time
3653
- this.url = this.url.replace(reParamSearch, '$1_=' + new Date().getTime());
3654
- } else {
3655
- // Otherwise add a new '_' parameter to the end with the current time
3656
- var reQueryString = /\?/;
3657
- this.url += (reQueryString.test(this.url) ? '&' : '?') + '_=' + new Date().getTime();
3658
- }
3659
- }
3660
- }
3661
- }
3662
-
3663
- Request.prototype.clone = function() {
3664
- return new Request(this, {body: this._bodyInit})
3665
- };
3666
-
3667
- function decode(body) {
3668
- var form = new FormData();
3669
- body
3670
- .trim()
3671
- .split('&')
3672
- .forEach(function(bytes) {
3673
- if (bytes) {
3674
- var split = bytes.split('=');
3675
- var name = split.shift().replace(/\+/g, ' ');
3676
- var value = split.join('=').replace(/\+/g, ' ');
3677
- form.append(decodeURIComponent(name), decodeURIComponent(value));
3678
- }
3679
- });
3680
- return form
3681
- }
3682
-
3683
- function parseHeaders(rawHeaders) {
3684
- var headers = new Headers();
3685
- // Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space
3686
- // https://tools.ietf.org/html/rfc7230#section-3.2
3687
- var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' ');
3688
- // Avoiding split via regex to work around a common IE11 bug with the core-js 3.6.0 regex polyfill
3689
- // https://github.com/github/fetch/issues/748
3690
- // https://github.com/zloirock/core-js/issues/751
3691
- preProcessedHeaders
3692
- .split('\r')
3693
- .map(function(header) {
3694
- return header.indexOf('\n') === 0 ? header.substr(1, header.length) : header
3695
- })
3696
- .forEach(function(line) {
3697
- var parts = line.split(':');
3698
- var key = parts.shift().trim();
3699
- if (key) {
3700
- var value = parts.join(':').trim();
3701
- try {
3702
- headers.append(key, value);
3703
- } catch (error) {
3704
- console.warn('Response ' + error.message);
3705
- }
3706
- }
3707
- });
3708
- return headers
3709
- }
3710
-
3711
- Body.call(Request.prototype);
3712
-
3713
- function Response(bodyInit, options) {
3714
- if (!(this instanceof Response)) {
3715
- throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.')
3716
- }
3717
- if (!options) {
3718
- options = {};
3719
- }
3720
-
3721
- this.type = 'default';
3722
- this.status = options.status === undefined ? 200 : options.status;
3723
- if (this.status < 200 || this.status > 599) {
3724
- throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].")
3725
- }
3726
- this.ok = this.status >= 200 && this.status < 300;
3727
- this.statusText = options.statusText === undefined ? '' : '' + options.statusText;
3728
- this.headers = new Headers(options.headers);
3729
- this.url = options.url || '';
3730
- this._initBody(bodyInit);
3731
- }
3732
-
3733
- Body.call(Response.prototype);
3734
-
3735
- Response.prototype.clone = function() {
3736
- return new Response(this._bodyInit, {
3737
- status: this.status,
3738
- statusText: this.statusText,
3739
- headers: new Headers(this.headers),
3740
- url: this.url
3741
- })
3742
- };
3743
-
3744
- Response.error = function() {
3745
- var response = new Response(null, {status: 200, statusText: ''});
3746
- response.ok = false;
3747
- response.status = 0;
3748
- response.type = 'error';
3749
- return response
3750
- };
3751
-
3752
- var redirectStatuses = [301, 302, 303, 307, 308];
3753
-
3754
- Response.redirect = function(url, status) {
3755
- if (redirectStatuses.indexOf(status) === -1) {
3756
- throw new RangeError('Invalid status code')
3757
- }
3758
-
3759
- return new Response(null, {status: status, headers: {location: url}})
3760
- };
3761
-
3762
- exports$1.DOMException = g.DOMException;
3763
- try {
3764
- new exports$1.DOMException();
3765
- } catch (err) {
3766
- exports$1.DOMException = function(message, name) {
3767
- this.message = message;
3768
- this.name = name;
3769
- var error = Error(message);
3770
- this.stack = error.stack;
3771
- };
3772
- exports$1.DOMException.prototype = Object.create(Error.prototype);
3773
- exports$1.DOMException.prototype.constructor = exports$1.DOMException;
3774
- }
3775
-
3776
- function fetch(input, init) {
3777
- return new Promise(function(resolve, reject) {
3778
- var request = new Request(input, init);
3779
-
3780
- if (request.signal && request.signal.aborted) {
3781
- return reject(new exports$1.DOMException('Aborted', 'AbortError'))
3782
- }
3783
-
3784
- var xhr = new XMLHttpRequest();
3785
-
3786
- function abortXhr() {
3787
- xhr.abort();
3788
- }
3789
-
3790
- xhr.onload = function() {
3791
- var options = {
3792
- statusText: xhr.statusText,
3793
- headers: parseHeaders(xhr.getAllResponseHeaders() || '')
3794
- };
3795
- // This check if specifically for when a user fetches a file locally from the file system
3796
- // Only if the status is out of a normal range
3797
- if (request.url.indexOf('file://') === 0 && (xhr.status < 200 || xhr.status > 599)) {
3798
- options.status = 200;
3799
- } else {
3800
- options.status = xhr.status;
3801
- }
3802
- options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL');
3803
- var body = 'response' in xhr ? xhr.response : xhr.responseText;
3804
- setTimeout(function() {
3805
- resolve(new Response(body, options));
3806
- }, 0);
3807
- };
3808
-
3809
- xhr.onerror = function() {
3810
- setTimeout(function() {
3811
- reject(new TypeError('Network request failed'));
3812
- }, 0);
3813
- };
3814
-
3815
- xhr.ontimeout = function() {
3816
- setTimeout(function() {
3817
- reject(new TypeError('Network request timed out'));
3818
- }, 0);
3819
- };
3820
-
3821
- xhr.onabort = function() {
3822
- setTimeout(function() {
3823
- reject(new exports$1.DOMException('Aborted', 'AbortError'));
3824
- }, 0);
3825
- };
3826
-
3827
- function fixUrl(url) {
3828
- try {
3829
- return url === '' && g.location.href ? g.location.href : url
3830
- } catch (e) {
3831
- return url
3832
- }
3833
- }
3834
-
3835
- xhr.open(request.method, fixUrl(request.url), true);
3836
-
3837
- if (request.credentials === 'include') {
3838
- xhr.withCredentials = true;
3839
- } else if (request.credentials === 'omit') {
3840
- xhr.withCredentials = false;
3841
- }
3842
-
3843
- if ('responseType' in xhr) {
3844
- if (support.blob) {
3845
- xhr.responseType = 'blob';
3846
- } else if (
3847
- support.arrayBuffer
3848
- ) {
3849
- xhr.responseType = 'arraybuffer';
3850
- }
3851
- }
3852
-
3853
- if (init && typeof init.headers === 'object' && !(init.headers instanceof Headers || (g.Headers && init.headers instanceof g.Headers))) {
3854
- var names = [];
3855
- Object.getOwnPropertyNames(init.headers).forEach(function(name) {
3856
- names.push(normalizeName(name));
3857
- xhr.setRequestHeader(name, normalizeValue(init.headers[name]));
3858
- });
3859
- request.headers.forEach(function(value, name) {
3860
- if (names.indexOf(name) === -1) {
3861
- xhr.setRequestHeader(name, value);
3862
- }
3863
- });
3864
- } else {
3865
- request.headers.forEach(function(value, name) {
3866
- xhr.setRequestHeader(name, value);
3867
- });
3868
- }
3869
-
3870
- if (request.signal) {
3871
- request.signal.addEventListener('abort', abortXhr);
3872
-
3873
- xhr.onreadystatechange = function() {
3874
- // DONE (success or failure)
3875
- if (xhr.readyState === 4) {
3876
- request.signal.removeEventListener('abort', abortXhr);
3877
- }
3878
- };
3879
- }
3880
-
3881
- xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit);
3882
- })
3883
- }
3884
-
3885
- fetch.polyfill = true;
3886
-
3887
- if (!g.fetch) {
3888
- g.fetch = fetch;
3889
- g.Headers = Headers;
3890
- g.Request = Request;
3891
- g.Response = Response;
3892
- }
3893
-
3894
- exports$1.Headers = Headers;
3895
- exports$1.Request = Request;
3896
- exports$1.Response = Response;
3897
- exports$1.fetch = fetch;
3898
-
3899
- Object.defineProperty(exports$1, '__esModule', { value: true });
3900
-
3901
- return exports$1;
3902
-
3903
- }))({});
3904
- })(__globalThis__);
3905
- // This is a ponyfill, so...
3906
- __globalThis__.fetch.ponyfill = true;
3907
- delete __globalThis__.fetch.polyfill;
3908
- // Choose between native implementation (__global__) or custom implementation (__globalThis__)
3909
- var ctx = __global__.fetch ? __global__ : __globalThis__;
3910
- exports$1 = ctx.fetch; // To enable: import fetch from 'cross-fetch'
3911
- exports$1.default = ctx.fetch; // For TypeScript consumers without esModuleInterop.
3912
- exports$1.fetch = ctx.fetch; // To enable: import {fetch} from 'cross-fetch'
3913
- exports$1.Headers = ctx.Headers;
3914
- exports$1.Request = ctx.Request;
3915
- exports$1.Response = ctx.Response;
3916
- module.exports = exports$1;
3917
- } (browserPonyfill, browserPonyfill.exports));
3918
- return browserPonyfill.exports;
3919
- }
3920
-
3921
- var events = {exports: {}};
3922
-
3923
- var hasRequiredEvents;
3924
-
3925
- function requireEvents () {
3926
- if (hasRequiredEvents) return events.exports;
3927
- hasRequiredEvents = 1;
3928
-
3929
- var R = typeof Reflect === 'object' ? Reflect : null;
3930
- var ReflectApply = R && typeof R.apply === 'function'
3931
- ? R.apply
3932
- : function ReflectApply(target, receiver, args) {
3933
- return Function.prototype.apply.call(target, receiver, args);
3934
- };
3935
-
3936
- var ReflectOwnKeys;
3937
- if (R && typeof R.ownKeys === 'function') {
3938
- ReflectOwnKeys = R.ownKeys;
3939
- } else if (Object.getOwnPropertySymbols) {
3940
- ReflectOwnKeys = function ReflectOwnKeys(target) {
3941
- return Object.getOwnPropertyNames(target)
3942
- .concat(Object.getOwnPropertySymbols(target));
3943
- };
3944
- } else {
3945
- ReflectOwnKeys = function ReflectOwnKeys(target) {
3946
- return Object.getOwnPropertyNames(target);
3947
- };
3948
- }
3949
-
3950
- function ProcessEmitWarning(warning) {
3951
- if (console && console.warn) console.warn(warning);
3952
- }
3953
-
3954
- var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {
3955
- return value !== value;
3956
- };
3957
-
3958
- function EventEmitter() {
3959
- EventEmitter.init.call(this);
3960
- }
3961
- events.exports = EventEmitter;
3962
- events.exports.once = once;
3963
-
3964
- // Backwards-compat with node 0.10.x
3965
- EventEmitter.EventEmitter = EventEmitter;
3966
-
3967
- EventEmitter.prototype._events = undefined;
3968
- EventEmitter.prototype._eventsCount = 0;
3969
- EventEmitter.prototype._maxListeners = undefined;
3970
-
3971
- // By default EventEmitters will print a warning if more than 10 listeners are
3972
- // added to it. This is a useful default which helps finding memory leaks.
3973
- var defaultMaxListeners = 10;
3974
-
3975
- function checkListener(listener) {
3976
- if (typeof listener !== 'function') {
3977
- throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
3978
- }
3979
- }
3980
-
3981
- Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
3982
- enumerable: true,
3983
- get: function() {
3984
- return defaultMaxListeners;
3985
- },
3986
- set: function(arg) {
3987
- if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {
3988
- throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.');
3989
- }
3990
- defaultMaxListeners = arg;
3991
- }
3992
- });
3993
-
3994
- EventEmitter.init = function() {
3995
-
3996
- if (this._events === undefined ||
3997
- this._events === Object.getPrototypeOf(this)._events) {
3998
- this._events = Object.create(null);
3999
- this._eventsCount = 0;
4000
- }
4001
-
4002
- this._maxListeners = this._maxListeners || undefined;
4003
- };
4004
-
4005
- // Obviously not all Emitters should be limited to 10. This function allows
4006
- // that to be increased. Set to zero for unlimited.
4007
- EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
4008
- if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {
4009
- throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.');
4010
- }
4011
- this._maxListeners = n;
4012
- return this;
4013
- };
4014
-
4015
- function _getMaxListeners(that) {
4016
- if (that._maxListeners === undefined)
4017
- return EventEmitter.defaultMaxListeners;
4018
- return that._maxListeners;
4019
- }
4020
-
4021
- EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
4022
- return _getMaxListeners(this);
4023
- };
4024
-
4025
- EventEmitter.prototype.emit = function emit(type) {
4026
- var args = [];
4027
- for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);
4028
- var doError = (type === 'error');
4029
-
4030
- var events = this._events;
4031
- if (events !== undefined)
4032
- doError = (doError && events.error === undefined);
4033
- else if (!doError)
4034
- return false;
4035
-
4036
- // If there is no 'error' event listener then throw.
4037
- if (doError) {
4038
- var er;
4039
- if (args.length > 0)
4040
- er = args[0];
4041
- if (er instanceof Error) {
4042
- // Note: The comments on the `throw` lines are intentional, they show
4043
- // up in Node's output if this results in an unhandled exception.
4044
- throw er; // Unhandled 'error' event
4045
- }
4046
- // At least give some kind of context to the user
4047
- var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));
4048
- err.context = er;
4049
- throw err; // Unhandled 'error' event
4050
- }
4051
-
4052
- var handler = events[type];
4053
-
4054
- if (handler === undefined)
4055
- return false;
4056
-
4057
- if (typeof handler === 'function') {
4058
- ReflectApply(handler, this, args);
4059
- } else {
4060
- var len = handler.length;
4061
- var listeners = arrayClone(handler, len);
4062
- for (var i = 0; i < len; ++i)
4063
- ReflectApply(listeners[i], this, args);
4064
- }
4065
-
4066
- return true;
4067
- };
4068
-
4069
- function _addListener(target, type, listener, prepend) {
4070
- var m;
4071
- var events;
4072
- var existing;
4073
-
4074
- checkListener(listener);
4075
-
4076
- events = target._events;
4077
- if (events === undefined) {
4078
- events = target._events = Object.create(null);
4079
- target._eventsCount = 0;
4080
- } else {
4081
- // To avoid recursion in the case that type === "newListener"! Before
4082
- // adding it to the listeners, first emit "newListener".
4083
- if (events.newListener !== undefined) {
4084
- target.emit('newListener', type,
4085
- listener.listener ? listener.listener : listener);
4086
-
4087
- // Re-assign `events` because a newListener handler could have caused the
4088
- // this._events to be assigned to a new object
4089
- events = target._events;
4090
- }
4091
- existing = events[type];
4092
- }
4093
-
4094
- if (existing === undefined) {
4095
- // Optimize the case of one listener. Don't need the extra array object.
4096
- existing = events[type] = listener;
4097
- ++target._eventsCount;
4098
- } else {
4099
- if (typeof existing === 'function') {
4100
- // Adding the second element, need to change to array.
4101
- existing = events[type] =
4102
- prepend ? [listener, existing] : [existing, listener];
4103
- // If we've already got an array, just append.
4104
- } else if (prepend) {
4105
- existing.unshift(listener);
4106
- } else {
4107
- existing.push(listener);
4108
- }
4109
-
4110
- // Check for listener leak
4111
- m = _getMaxListeners(target);
4112
- if (m > 0 && existing.length > m && !existing.warned) {
4113
- existing.warned = true;
4114
- // No error code for this since it is a Warning
4115
- // eslint-disable-next-line no-restricted-syntax
4116
- var w = new Error('Possible EventEmitter memory leak detected. ' +
4117
- existing.length + ' ' + String(type) + ' listeners ' +
4118
- 'added. Use emitter.setMaxListeners() to ' +
4119
- 'increase limit');
4120
- w.name = 'MaxListenersExceededWarning';
4121
- w.emitter = target;
4122
- w.type = type;
4123
- w.count = existing.length;
4124
- ProcessEmitWarning(w);
4125
- }
4126
- }
4127
-
4128
- return target;
4129
- }
4130
-
4131
- EventEmitter.prototype.addListener = function addListener(type, listener) {
4132
- return _addListener(this, type, listener, false);
4133
- };
4134
-
4135
- EventEmitter.prototype.on = EventEmitter.prototype.addListener;
4136
-
4137
- EventEmitter.prototype.prependListener =
4138
- function prependListener(type, listener) {
4139
- return _addListener(this, type, listener, true);
4140
- };
4141
-
4142
- function onceWrapper() {
4143
- if (!this.fired) {
4144
- this.target.removeListener(this.type, this.wrapFn);
4145
- this.fired = true;
4146
- if (arguments.length === 0)
4147
- return this.listener.call(this.target);
4148
- return this.listener.apply(this.target, arguments);
4149
- }
4150
- }
4151
-
4152
- function _onceWrap(target, type, listener) {
4153
- var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
4154
- var wrapped = onceWrapper.bind(state);
4155
- wrapped.listener = listener;
4156
- state.wrapFn = wrapped;
4157
- return wrapped;
4158
- }
4159
-
4160
- EventEmitter.prototype.once = function once(type, listener) {
4161
- checkListener(listener);
4162
- this.on(type, _onceWrap(this, type, listener));
4163
- return this;
4164
- };
4165
-
4166
- EventEmitter.prototype.prependOnceListener =
4167
- function prependOnceListener(type, listener) {
4168
- checkListener(listener);
4169
- this.prependListener(type, _onceWrap(this, type, listener));
4170
- return this;
4171
- };
4172
-
4173
- // Emits a 'removeListener' event if and only if the listener was removed.
4174
- EventEmitter.prototype.removeListener =
4175
- function removeListener(type, listener) {
4176
- var list, events, position, i, originalListener;
4177
-
4178
- checkListener(listener);
4179
-
4180
- events = this._events;
4181
- if (events === undefined)
4182
- return this;
4183
-
4184
- list = events[type];
4185
- if (list === undefined)
4186
- return this;
4187
-
4188
- if (list === listener || list.listener === listener) {
4189
- if (--this._eventsCount === 0)
4190
- this._events = Object.create(null);
4191
- else {
4192
- delete events[type];
4193
- if (events.removeListener)
4194
- this.emit('removeListener', type, list.listener || listener);
4195
- }
4196
- } else if (typeof list !== 'function') {
4197
- position = -1;
4198
-
4199
- for (i = list.length - 1; i >= 0; i--) {
4200
- if (list[i] === listener || list[i].listener === listener) {
4201
- originalListener = list[i].listener;
4202
- position = i;
4203
- break;
4204
- }
4205
- }
4206
-
4207
- if (position < 0)
4208
- return this;
4209
-
4210
- if (position === 0)
4211
- list.shift();
4212
- else {
4213
- spliceOne(list, position);
4214
- }
4215
-
4216
- if (list.length === 1)
4217
- events[type] = list[0];
4218
-
4219
- if (events.removeListener !== undefined)
4220
- this.emit('removeListener', type, originalListener || listener);
4221
- }
4222
-
4223
- return this;
4224
- };
4225
-
4226
- EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
4227
-
4228
- EventEmitter.prototype.removeAllListeners =
4229
- function removeAllListeners(type) {
4230
- var listeners, events, i;
4231
-
4232
- events = this._events;
4233
- if (events === undefined)
4234
- return this;
4235
-
4236
- // not listening for removeListener, no need to emit
4237
- if (events.removeListener === undefined) {
4238
- if (arguments.length === 0) {
4239
- this._events = Object.create(null);
4240
- this._eventsCount = 0;
4241
- } else if (events[type] !== undefined) {
4242
- if (--this._eventsCount === 0)
4243
- this._events = Object.create(null);
4244
- else
4245
- delete events[type];
4246
- }
4247
- return this;
4248
- }
4249
-
4250
- // emit removeListener for all listeners on all events
4251
- if (arguments.length === 0) {
4252
- var keys = Object.keys(events);
4253
- var key;
4254
- for (i = 0; i < keys.length; ++i) {
4255
- key = keys[i];
4256
- if (key === 'removeListener') continue;
4257
- this.removeAllListeners(key);
4258
- }
4259
- this.removeAllListeners('removeListener');
4260
- this._events = Object.create(null);
4261
- this._eventsCount = 0;
4262
- return this;
4263
- }
4264
-
4265
- listeners = events[type];
4266
-
4267
- if (typeof listeners === 'function') {
4268
- this.removeListener(type, listeners);
4269
- } else if (listeners !== undefined) {
4270
- // LIFO order
4271
- for (i = listeners.length - 1; i >= 0; i--) {
4272
- this.removeListener(type, listeners[i]);
4273
- }
4274
- }
4275
-
4276
- return this;
4277
- };
4278
-
4279
- function _listeners(target, type, unwrap) {
4280
- var events = target._events;
4281
-
4282
- if (events === undefined)
4283
- return [];
4284
-
4285
- var evlistener = events[type];
4286
- if (evlistener === undefined)
4287
- return [];
4288
-
4289
- if (typeof evlistener === 'function')
4290
- return unwrap ? [evlistener.listener || evlistener] : [evlistener];
4291
-
4292
- return unwrap ?
4293
- unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
4294
- }
4295
-
4296
- EventEmitter.prototype.listeners = function listeners(type) {
4297
- return _listeners(this, type, true);
4298
- };
4299
-
4300
- EventEmitter.prototype.rawListeners = function rawListeners(type) {
4301
- return _listeners(this, type, false);
4302
- };
4303
-
4304
- EventEmitter.listenerCount = function(emitter, type) {
4305
- if (typeof emitter.listenerCount === 'function') {
4306
- return emitter.listenerCount(type);
4307
- } else {
4308
- return listenerCount.call(emitter, type);
4309
- }
4310
- };
4311
-
4312
- EventEmitter.prototype.listenerCount = listenerCount;
4313
- function listenerCount(type) {
4314
- var events = this._events;
4315
-
4316
- if (events !== undefined) {
4317
- var evlistener = events[type];
4318
-
4319
- if (typeof evlistener === 'function') {
4320
- return 1;
4321
- } else if (evlistener !== undefined) {
4322
- return evlistener.length;
4323
- }
4324
- }
4325
-
4326
- return 0;
4327
- }
4328
-
4329
- EventEmitter.prototype.eventNames = function eventNames() {
4330
- return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];
4331
- };
4332
-
4333
- function arrayClone(arr, n) {
4334
- var copy = new Array(n);
4335
- for (var i = 0; i < n; ++i)
4336
- copy[i] = arr[i];
4337
- return copy;
4338
- }
4339
-
4340
- function spliceOne(list, index) {
4341
- for (; index + 1 < list.length; index++)
4342
- list[index] = list[index + 1];
4343
- list.pop();
4344
- }
4345
-
4346
- function unwrapListeners(arr) {
4347
- var ret = new Array(arr.length);
4348
- for (var i = 0; i < ret.length; ++i) {
4349
- ret[i] = arr[i].listener || arr[i];
4350
- }
4351
- return ret;
4352
- }
4353
-
4354
- function once(emitter, name) {
4355
- return new Promise(function (resolve, reject) {
4356
- function errorListener(err) {
4357
- emitter.removeListener(name, resolver);
4358
- reject(err);
4359
- }
4360
-
4361
- function resolver() {
4362
- if (typeof emitter.removeListener === 'function') {
4363
- emitter.removeListener('error', errorListener);
4364
- }
4365
- resolve([].slice.call(arguments));
4366
- }
4367
- eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });
4368
- if (name !== 'error') {
4369
- addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });
4370
- }
4371
- });
4372
- }
4373
-
4374
- function addErrorHandlerIfEventEmitter(emitter, handler, flags) {
4375
- if (typeof emitter.on === 'function') {
4376
- eventTargetAgnosticAddListener(emitter, 'error', handler, flags);
4377
- }
4378
- }
4379
-
4380
- function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
4381
- if (typeof emitter.on === 'function') {
4382
- if (flags.once) {
4383
- emitter.once(name, listener);
4384
- } else {
4385
- emitter.on(name, listener);
4386
- }
4387
- } else if (typeof emitter.addEventListener === 'function') {
4388
- // EventTarget does not have `error` event semantics like Node
4389
- // EventEmitters, we do not listen for `error` events here.
4390
- emitter.addEventListener(name, function wrapListener(arg) {
4391
- // IE does not have builtin `{ once: true }` support so we
4392
- // have to do it manually.
4393
- if (flags.once) {
4394
- emitter.removeEventListener(name, wrapListener);
4395
- }
4396
- listener(arg);
4397
- });
4398
- } else {
4399
- throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter);
4400
- }
4401
- }
4402
- return events.exports;
4403
- }
4404
-
4405
- var browser;
4406
- var hasRequiredBrowser;
4407
-
4408
- function requireBrowser () {
4409
- if (hasRequiredBrowser) return browser;
4410
- hasRequiredBrowser = 1;
4411
- // https://github.com/maxogden/websocket-stream/blob/48dc3ddf943e5ada668c31ccd94e9186f02fafbd/ws-fallback.js
4412
-
4413
- var ws = null;
4414
-
4415
- if (typeof WebSocket !== 'undefined') {
4416
- ws = WebSocket;
4417
- } else if (typeof MozWebSocket !== 'undefined') {
4418
- ws = MozWebSocket;
4419
- } else if (typeof commonjsGlobal !== 'undefined') {
4420
- ws = commonjsGlobal.WebSocket || commonjsGlobal.MozWebSocket;
4421
- } else if (typeof window !== 'undefined') {
4422
- ws = window.WebSocket || window.MozWebSocket;
4423
- } else if (typeof self !== 'undefined') {
4424
- ws = self.WebSocket || self.MozWebSocket;
4425
- }
4426
-
4427
- browser = ws;
4428
- return browser;
4429
- }
4430
-
4431
- var hasRequiredLedger;
4432
-
4433
- function requireLedger () {
4434
- if (hasRequiredLedger) return ledger;
4435
- hasRequiredLedger = 1;
4436
- var __extends = (ledger && ledger.__extends) || (function () {
4437
- var extendStatics = function (d, b) {
4438
- extendStatics = Object.setPrototypeOf ||
4439
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
4440
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
4441
- return extendStatics(d, b);
4442
- };
4443
- return function (d, b) {
4444
- if (typeof b !== "function" && b !== null)
4445
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
4446
- extendStatics(d, b);
4447
- function __() { this.constructor = d; }
4448
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
4449
- };
4450
- })();
4451
- var __assign = (ledger && ledger.__assign) || function () {
4452
- __assign = Object.assign || function(t) {
4453
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4454
- s = arguments[i];
4455
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
4456
- t[p] = s[p];
4457
- }
4458
- return t;
4459
- };
4460
- return __assign.apply(this, arguments);
4461
- };
4462
- var __createBinding = (ledger && ledger.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4463
- if (k2 === undefined) k2 = k;
4464
- var desc = Object.getOwnPropertyDescriptor(m, k);
4465
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
4466
- desc = { enumerable: true, get: function() { return m[k]; } };
4467
- }
4468
- Object.defineProperty(o, k2, desc);
4469
- }) : (function(o, m, k, k2) {
4470
- if (k2 === undefined) k2 = k;
4471
- o[k2] = m[k];
4472
- }));
4473
- var __setModuleDefault = (ledger && ledger.__setModuleDefault) || (Object.create ? (function(o, v) {
4474
- Object.defineProperty(o, "default", { enumerable: true, value: v });
4475
- }) : function(o, v) {
4476
- o["default"] = v;
4477
- });
4478
- var __importStar = (ledger && ledger.__importStar) || (function () {
4479
- var ownKeys = function(o) {
4480
- ownKeys = Object.getOwnPropertyNames || function (o) {
4481
- var ar = [];
4482
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
4483
- return ar;
4484
- };
4485
- return ownKeys(o);
4486
- };
4487
- return function (mod) {
4488
- if (mod && mod.__esModule) return mod;
4489
- var result = {};
4490
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
4491
- __setModuleDefault(result, mod);
4492
- return result;
4493
- };
4494
- })();
4495
- var __awaiter = (ledger && ledger.__awaiter) || function (thisArg, _arguments, P, generator) {
4496
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4497
- return new (P || (P = Promise))(function (resolve, reject) {
4498
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
4499
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
4500
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
4501
- step((generator = generator.apply(thisArg, _arguments || [])).next());
4502
- });
4503
- };
4504
- var __generator = (ledger && ledger.__generator) || function (thisArg, body) {
4505
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
4506
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
4507
- function verb(n) { return function (v) { return step([n, v]); }; }
4508
- function step(op) {
4509
- if (f) throw new TypeError("Generator is already executing.");
4510
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
4511
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
4512
- if (y = 0, t) op = [op[0] & 2, t.value];
4513
- switch (op[0]) {
4514
- case 0: case 1: t = op; break;
4515
- case 4: _.label++; return { value: op[1], done: false };
4516
- case 5: _.label++; y = op[1]; op = [0]; continue;
4517
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
4518
- default:
4519
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
4520
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
4521
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
4522
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
4523
- if (t[2]) _.ops.pop();
4524
- _.trys.pop(); continue;
4525
- }
4526
- op = body.call(thisArg, _);
4527
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
4528
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
4529
- }
4530
- };
4531
- var __importDefault = (ledger && ledger.__importDefault) || function (mod) {
4532
- return (mod && mod.__esModule) ? mod : { "default": mod };
4533
- };
4534
- Object.defineProperty(ledger, "__esModule", { value: true });
4535
- ledger.Ledger = ledger.WsState = ledger.UserRightHelper = void 0;
4536
- ledger.assert = assert;
4537
- // Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
4538
- // SPDX-License-Identifier: Apache-2.0
4539
- var types_1 = requireTypes$1();
4540
- var jtv = __importStar(require$$0);
4541
- var cross_fetch_1 = __importDefault(requireBrowserPonyfill());
4542
- var events_1 = requireEvents();
4543
- var isomorphic_ws_1 = __importDefault(requireBrowser());
4544
- var lodash_1 = __importStar(require$$1);
4545
- var partyInfoDecoder = jtv.object({
4546
- identifier: jtv.string(),
4547
- isLocal: jtv.boolean(),
4548
- });
4549
- var userDecoder = jtv.object({
4550
- userId: jtv.string(),
4551
- primaryParty: jtv.optional(jtv.string()),
4552
- });
4553
- var UserRightHelper = /** @class */ (function () {
4554
- function UserRightHelper() {
4555
- }
4556
- UserRightHelper.canActAs = function (party) {
4557
- return { type: "CanActAs", party: party };
4558
- };
4559
- UserRightHelper.canReadAs = function (party) {
4560
- return { type: "CanReadAs", party: party };
4561
- };
4562
- UserRightHelper.participantAdmin = {
4563
- type: "ParticipantAdmin",
4564
- };
4565
- return UserRightHelper;
4566
- }());
4567
- ledger.UserRightHelper = UserRightHelper;
4568
- var userRightDecoder = jtv.oneOf(jtv.object({
4569
- type: jtv.constant("CanActAs"),
4570
- party: jtv.string(),
4571
- }), jtv.object({
4572
- type: jtv.constant("CanReadAs"),
4573
- party: jtv.string(),
4574
- }), jtv.object({
4575
- type: jtv.constant("ParticipantAdmin"),
4576
- }));
4577
- var decode = function (decoder, data) {
4578
- return jtv.Result.withException(decoder.run(data));
4579
- };
4580
- function lookupTemplateOrUnknownInterface(templateId) {
4581
- try {
4582
- return (0, types_1.lookupTemplate)(templateId);
4583
- }
4584
- catch (e) {
4585
- if (e instanceof Error)
4586
- return {
4587
- templateId: templateId,
4588
- sdkVersion: "3.3.0-snapshot.20250528.13806.0.v3cd439fb",
4589
- // there is no way to properly decode in this case, so we
4590
- // discard the data instead. #15042
4591
- decoder: jtv.succeed({}),
4592
- keyDecoder: jtv.succeed(undefined),
4593
- };
4594
- else
4595
- throw e;
4596
- }
4597
- }
4598
- var decodeTemplateId = function () {
4599
- return jtv.string();
4600
- };
4601
- /**
4602
- * Decoder for a [[CreateEvent]].
4603
- */
4604
- var decodeCreateEvent = function (template) {
4605
- return jtv.object({
4606
- templateId: decodeTemplateId(),
4607
- contractId: (0, types_1.ContractId)(template).decoder,
4608
- signatories: (0, types_1.List)(types_1.Party).decoder,
4609
- observers: (0, types_1.List)(types_1.Party).decoder,
4610
- key: template.keyDecoder,
4611
- payload: template.decoder,
4612
- });
4613
- };
4614
- /**
4615
- * Decoder for a [[CreateEvent]] of unknown contract template.
4616
- */
4617
- var decodeCreateEventUnknown = jtv
4618
- .valueAt(["templateId"], jtv.string())
4619
- .andThen(function (templateId) {
4620
- return decodeCreateEvent(lookupTemplateOrUnknownInterface(templateId));
4621
- });
4622
- /**
4623
- * Decoder for an [[ArchiveEvent]].
4624
- */
4625
- var decodeArchiveEvent = function (template) {
4626
- return jtv.object({
4627
- templateId: decodeTemplateId(),
4628
- contractId: (0, types_1.ContractId)(template).decoder,
4629
- });
4630
- };
4631
- /**
4632
- * Decoder for an [[ArchiveEvent]] of unknown contract template.
4633
- */
4634
- var decodeArchiveEventUnknown = jtv
4635
- .valueAt(["templateId"], jtv.string())
4636
- .andThen(function (templateId) {
4637
- return decodeArchiveEvent(lookupTemplateOrUnknownInterface(templateId));
4638
- });
4639
- /**
4640
- * Decoder for an [[Event]].
4641
- */
4642
- var decodeEvent = function (template) {
4643
- return jtv.oneOf(jtv.object({
4644
- created: decodeCreateEvent(template),
4645
- matchedQueries: jtv.array(jtv.number()),
4646
- }), jtv.object({ created: decodeCreateEvent(template) }), jtv.object({ archived: decodeArchiveEvent(template) }));
4647
- };
4648
- /**
4649
- * Decoder for an [[Event]] with unknown contract template.
4650
- */
4651
- var decodeEventUnknown = jtv.oneOf(jtv.object({
4652
- created: decodeCreateEventUnknown,
4653
- matchedQueries: jtv.array(jtv.number()),
4654
- }), jtv.object({ created: decodeCreateEventUnknown }), jtv.object({ archived: decodeArchiveEventUnknown }));
4655
- /**
4656
- * @internal
4657
- */
4658
- function stripPackage(templateId) {
4659
- return templateId.split(":").slice(1).join(":");
4660
- }
4661
- /**
4662
- * @internal
4663
- */
4664
- function decodeArchiveResponse(template, archiveMethod,
4665
- // eslint-disable-next-line @typescript-eslint/ban-types
4666
- archiveCommand) {
4667
- return __awaiter(this, void 0, void 0, function () {
4668
- var _a, events;
4669
- return __generator(this, function (_c) {
4670
- switch (_c.label) {
4671
- case 0: return [4 /*yield*/, archiveCommand()];
4672
- case 1:
4673
- _a = _c.sent(), _a[0], events = _a[1];
4674
- if (events.length === 1 &&
4675
- "archived" in events[0] &&
4676
- stripPackage(events[0].archived.templateId) ===
4677
- stripPackage(template.templateId)) {
4678
- return [2 /*return*/, events[0].archived];
4679
- }
4680
- else {
4681
- throw Error("Ledger.".concat(archiveMethod, " is expected to cause one archive event for template ").concat(template.templateId, " but caused ").concat(JSON.stringify(events), "."));
4682
- }
4683
- }
4684
- });
4685
- });
4686
- }
4687
- /**
4688
- * @internal
4689
- */
4690
- function isRecordWith(field, x) {
4691
- return typeof x === "object" && x !== null && field in x;
4692
- }
4693
- /**
4694
- *
4695
- * @internal
4696
- */
4697
- function isCreateWithMatchedQueries(event) {
4698
- return isRecordWith("created", event);
4699
- }
4700
- /** @internal
4701
- * exported for testing only
4702
- */
4703
- function assert(b, m) {
4704
- if (!b) {
4705
- throw m;
4706
- }
4707
- }
4708
- // TODO(MH): Support comparison queries.
4709
- /** @internal
4710
- *
4711
- * Official documentation (docs/source/json-api/search-query-language.rst)
4712
- * currently explicitly forbids the use of lists, textmaps and genmaps in
4713
- * queries. As long as that restriction stays, there is no need for any kind of
4714
- * encoding here.
4715
- */
4716
- function encodeQuery(_template, query) {
4717
- return query;
4718
- }
4719
- /**
4720
- * @internal
4721
- */
4722
- var decodeLedgerResponse = jtv.object({
4723
- status: jtv.number(),
4724
- result: jtv.unknownJson(),
4725
- warnings: jtv.optional(jtv.unknownJson()),
4726
- });
4727
- /**
4728
- * @internal
4729
- */
4730
- var decodeLedgerError = jtv.object({
4731
- status: jtv.number(),
4732
- errors: jtv.array(jtv.string()),
4733
- warnings: jtv.optional(jtv.unknownJson()),
4734
- });
4735
- var StreamEventEmitter = /** @class */ (function (_super) {
4736
- __extends(StreamEventEmitter, _super);
4737
- function StreamEventEmitter(_a) {
4738
- var beforeClosing = _a.beforeClosing;
4739
- var _this = _super.call(this) || this;
4740
- _this.beforeClosing = beforeClosing;
4741
- return _this;
4742
- }
4743
- StreamEventEmitter.prototype.close = function () {
4744
- this.beforeClosing();
4745
- this.emit("close", { code: 4000, reason: "called .close()" });
4746
- this.removeAllListeners();
4747
- };
4748
- return StreamEventEmitter;
4749
- }(events_1.EventEmitter));
4750
- var NoOffsetReceivedYet = Symbol("NoOffsetReceivedYet");
4751
- var NullOffsetReceived = Symbol("NullOffsetReceived");
4752
- function append(map, key, value) {
4753
- var _a;
4754
- if (map.has(key)) {
4755
- (_a = map.get(key)) === null || _a === void 0 ? void 0 : _a.push(value);
4756
- }
4757
- else {
4758
- map.set(key, [value]);
4759
- }
4760
- }
4761
- /**
4762
- * @deprecated All usages of this function should be replaced by just
4763
- * iterating over the iterator. For this to happen, the TS
4764
- * compiler requires the --downlevelIteration flag, which
4765
- * however does not play nicely with Jest when running the
4766
- * tests.
4767
- *
4768
- * TODO Moving the compilation target to ES6 probably would solve this, investigate.
4769
- */
4770
- function materialize(iterator) {
4771
- return Array.from(iterator);
4772
- }
4773
- var WsState;
4774
- (function (WsState) {
4775
- WsState[WsState["Connecting"] = 0] = "Connecting";
4776
- WsState[WsState["Open"] = 1] = "Open";
4777
- WsState[WsState["Closing"] = 2] = "Closing";
4778
- WsState[WsState["Closed"] = 3] = "Closed";
4779
- })(WsState || (ledger.WsState = WsState = {}));
4780
- /**
4781
- * @internal
4782
- *
4783
- * A special handler for stream requests to the /v1/stream/query endpoint.
4784
- * The query endpoint supports providing offsets on a per-query basis.
4785
- * This class leverages this feature by multiplexing virtual streaming requests to a single web socket.
4786
- */
4787
- var QueryStreamsManager = /** @class */ (function () {
4788
- function QueryStreamsManager(_a) {
4789
- var token = _a.token, wsBaseUrl = _a.wsBaseUrl, reconnectThreshold = _a.reconnectThreshold;
4790
- // Mutable state BEGIN
4791
- // Ongoing streaming queries that will be the downstream consumers of web socket messages
4792
- this.queries = new Set();
4793
- // Lookup tables used to route events to the relevant consumers:
4794
- // - consumers for create events can be looked up based on their match index
4795
- // - store the offset by which a match indexes needs to be shifted before the event is passed to the consumer
4796
- // - archive events can be lookup up by template identifier
4797
- // - this causes the consumer to observe what is known as "phantom archives", which are known and documented
4798
- this.matchIndexLookupTable = [];
4799
- this.templateIdsLookupTable = {};
4800
- // Accumulates each query in a flattened form to be sent as a single request to the JSON API
4801
- this.request = [];
4802
- // to track changes on web socket queries
4803
- this.wsQueriesChange = false;
4804
- this.protocols = ["jwt.token." + token, "daml.ws.auth"];
4805
- this.url = wsBaseUrl + QueryStreamsManager.ENDPOINT;
4806
- this.reconnectThresholdMs = reconnectThreshold;
4807
- }
4808
- QueryStreamsManager.toRequest = function (query) {
4809
- var request = query.queries.length == 0
4810
- ? [{ templateIds: [query.template.templateId] }]
4811
- : query.queries.map(function (q) { return ({
4812
- templateIds: [query.template.templateId],
4813
- query: encodeQuery(query.template, q),
4814
- }); });
4815
- if (typeof query.offset === "string") {
4816
- for (var _i = 0, request_1 = request; _i < request_1.length; _i++) {
4817
- var r = request_1[_i];
4818
- r.offset = query.offset;
4819
- }
4820
- }
4821
- return request;
4822
- };
4823
- QueryStreamsManager.prototype.resetAllState = function () {
4824
- // close ws if defined
4825
- if (this.ws !== undefined) {
4826
- this.ws.close();
4827
- }
4828
- this.queries.clear();
4829
- this.matchIndexLookupTable = [];
4830
- this.templateIdsLookupTable = {};
4831
- this.request = [];
4832
- this.ws = undefined;
4833
- this.wsLiveSince = undefined;
4834
- this.wsQueriesChange = false;
4835
- };
4836
- QueryStreamsManager.prototype.handleQueriesChange = function () {
4837
- //eslint-disable-next-line @typescript-eslint/no-this-alias
4838
- var manager = this; // stable self-reference for callbacks
4839
- if (manager.queries.size > 0) {
4840
- if (manager.ws !== undefined) {
4841
- //set the queries change flag to true, this should eventually get reset once the ws is closed.
4842
- manager.wsQueriesChange = true;
4843
- manager.wsLiveSince = undefined;
4844
- manager.ws.close();
4845
- manager.ws = undefined;
4846
- }
4847
- var ws = new isomorphic_ws_1.default(manager.url, manager.protocols);
4848
- var onWsMessage_1 = function (ws) {
4849
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
4850
- return function (_a) {
4851
- var data = _a.data;
4852
- if (ws.readyState === WsState.Open) {
4853
- var json = JSON.parse(data.toString());
4854
- if (isRecordWith("events", json)) {
4855
- var events = jtv.Result.withException(jtv.array(decodeEventUnknown).run(json.events));
4856
- var multiplexer = new Map();
4857
- for (var _i = 0, events_2 = events; _i < events_2.length; _i++) {
4858
- var event_1 = events_2[_i];
4859
- if (isCreateWithMatchedQueries(event_1)) {
4860
- var consumersToMatchedQueries = new Map();
4861
- for (var _b = 0, _c = event_1.matchedQueries; _b < _c.length; _b++) {
4862
- var matchIndex = _c[_b];
4863
- var _d = manager.matchIndexLookupTable[matchIndex], consumer = _d[0], matchIndexOffset = _d[1];
4864
- append(consumersToMatchedQueries, consumer, matchIndexOffset);
4865
- }
4866
- for (var _e = 0, _f = materialize(consumersToMatchedQueries.entries()); _e < _f.length; _e++) {
4867
- var _g = _f[_e], consumer = _g[0], matchedQueries = _g[1];
4868
- // Create a new copy of the event for each consumer to freely mangle the matched queries and avoid sharing mutable state
4869
- append(multiplexer, consumer, __assign(__assign({}, event_1), { matchedQueries: matchedQueries }));
4870
- }
4871
- }
4872
- else if ("archived" in event_1) {
4873
- var consumers = manager.templateIdsLookupTable[event_1.archived.templateId];
4874
- for (var _h = 0, _j = materialize(consumers.values()); _h < _j.length; _h++) {
4875
- var consumer = _j[_h];
4876
- // Create a new copy of the event for each consumer to avoid sharing mutable state
4877
- append(multiplexer, consumer, __assign({}, event_1));
4878
- }
4879
- }
4880
- else {
4881
- console.error("".concat(event_1, " unknown event type received, expected created with matchedQueries or archived"), json);
4882
- }
4883
- }
4884
- for (var _k = 0, _m = materialize(multiplexer.entries()); _k < _m.length; _k++) {
4885
- var _o = _m[_k], consumer = _o[0], events_4 = _o[1];
4886
- for (var _p = 0, events_3 = events_4; _p < events_3.length; _p++) {
4887
- var event_2 = events_3[_p];
4888
- if (isCreateWithMatchedQueries(event_2)) {
4889
- consumer.state.set(event_2.created.contractId, event_2.created);
4890
- }
4891
- else if ("archived" in event_2) {
4892
- consumer.state.delete(event_2.archived.contractId);
4893
- }
4894
- }
4895
- consumer.stream.emit("change", Array.from(consumer.state.values()), events_4);
4896
- }
4897
- if (isRecordWith("offset", json)) {
4898
- var offset = jtv.Result.withException(jtv.oneOf(jtv.constant(null), jtv.string()).run(json.offset));
4899
- if (manager.wsLiveSince === undefined) {
4900
- //on receiving the first offset event we consider the web socket to be live.
4901
- manager.wsLiveSince = Date.now();
4902
- }
4903
- for (var _q = 0, _r = materialize(manager.queries.values()); _q < _r.length; _q++) {
4904
- var consumer = _r[_q];
4905
- if (!(typeof consumer.offset === "string")) {
4906
- // Rebuilding the state array from scratch to make sure mutable state is not shared between the 'change' and 'live' event
4907
- consumer.stream.emit("live", Array.from(consumer.state.values()));
4908
- }
4909
- if (typeof offset === "string") {
4910
- consumer.offset = offset;
4911
- }
4912
- else {
4913
- consumer.offset = NullOffsetReceived;
4914
- }
4915
- }
4916
- }
4917
- }
4918
- else if (isRecordWith("warnings", json)) {
4919
- for (var _s = 0, _u = materialize(manager.queries.values()); _s < _u.length; _s++) {
4920
- var query = _u[_s];
4921
- console.warn("".concat(query.caller, " warnings"), json);
4922
- }
4923
- }
4924
- else if (isRecordWith("errors", json)) {
4925
- for (var _v = 0, _w = materialize(manager.queries.values()); _v < _w.length; _v++) {
4926
- var query = _w[_v];
4927
- console.warn("".concat(query.caller, " errors"), json);
4928
- }
4929
- }
4930
- else {
4931
- for (var _x = 0, _y = materialize(manager.queries.values()); _x < _y.length; _x++) {
4932
- var query = _y[_x];
4933
- console.error("".concat(query.caller, " unknown message"), json);
4934
- }
4935
- }
4936
- }
4937
- };
4938
- };
4939
- var onWsOpen_1 = function () {
4940
- var _a;
4941
- // only make a new websocket request if we have registered queries
4942
- if (manager.queries.size > 0) {
4943
- var newRequests = [];
4944
- var newMatchIndexLookupTable = [];
4945
- for (var _i = 0, _b = materialize(manager.queries.values()); _i < _b.length; _i++) {
4946
- var query = _b[_i];
4947
- var request = QueryStreamsManager.toRequest(query);
4948
- // Add entries to the lookup table for create events
4949
- var matchIndexOffset = newMatchIndexLookupTable.length;
4950
- var matchIndexLookupTableEntries = new Array(request.length).fill([query, matchIndexOffset]);
4951
- newMatchIndexLookupTable = newMatchIndexLookupTable.concat(matchIndexLookupTableEntries);
4952
- // Add entries to the lookup table for archive events
4953
- for (var _c = 0, request_2 = request; _c < request_2.length; _c++) {
4954
- var templateIds = request_2[_c].templateIds;
4955
- for (var _d = 0, templateIds_1 = templateIds; _d < templateIds_1.length; _d++) {
4956
- var templateId = templateIds_1[_d];
4957
- manager.templateIdsLookupTable[templateId] =
4958
- manager.templateIdsLookupTable[templateId] || new Set();
4959
- manager.templateIdsLookupTable[templateId].add(query);
4960
- }
4961
- }
4962
- //since we go through all queries on the manager, we should be safely able to rebuild the whole request
4963
- newRequests = newRequests.concat(request);
4964
- }
4965
- manager.request = newRequests;
4966
- manager.matchIndexLookupTable = newMatchIndexLookupTable;
4967
- (_a = manager.ws) === null || _a === void 0 ? void 0 : _a.send(JSON.stringify(Array.from(manager.request.values())));
4968
- }
4969
- };
4970
- var onWsClose_1 = function () {
4971
- //if not a web socket queries change then we need to initiate reconnect logic.
4972
- if (!manager.wsQueriesChange) {
4973
- // The web socket has been closed due to an error
4974
- // If the conditions are met, attempt to reconnect and/or inform downstream consumers
4975
- var now = Date.now();
4976
- if (manager.wsLiveSince !== undefined &&
4977
- now - manager.wsLiveSince >= manager.reconnectThresholdMs) {
4978
- console.log("Reconnecting ws, previously liveSince: ".concat(manager.wsLiveSince, " and reconnectThresholdMs: ").concat(manager.reconnectThresholdMs));
4979
- manager.wsLiveSince = undefined;
4980
- var ws_1 = new isomorphic_ws_1.default(manager.url, manager.protocols);
4981
- ws_1.addEventListener("open", onWsOpen_1);
4982
- ws_1.addEventListener("message", onWsMessage_1(ws_1));
4983
- ws_1.addEventListener("close", onWsClose_1);
4984
- manager.ws = ws_1;
4985
- }
4986
- else {
4987
- // ws has closed too quickly / never managed to connect: we give up
4988
- for (var _i = 0, _a = materialize(manager.queries.values()); _i < _a.length; _i++) {
4989
- var consumer = _a[_i];
4990
- consumer.stream.emit("close", {
4991
- code: 4001,
4992
- reason: "ws connection failed",
4993
- });
4994
- consumer.stream.removeAllListeners();
4995
- }
4996
- manager.resetAllState();
4997
- }
4998
- }
4999
- else {
5000
- //this was triggered due to queries change , reset the flag
5001
- manager.wsQueriesChange = false;
5002
- }
5003
- };
5004
- // Purposefully ignoring 'error' events; they are always followed by a 'close' event, which needs to be handled anyway
5005
- ws.addEventListener("open", onWsOpen_1);
5006
- ws.addEventListener("message", onWsMessage_1(ws));
5007
- ws.addEventListener("close", onWsClose_1);
5008
- //eslint-disable-next-line @typescript-eslint/no-this-alias
5009
- manager.ws = ws;
5010
- }
5011
- };
5012
- QueryStreamsManager.prototype.streamSubmit = function (template, queries, caller) {
5013
- //eslint-disable-next-line @typescript-eslint/no-this-alias
5014
- var manager = this;
5015
- var query = {
5016
- template: template,
5017
- queries: queries,
5018
- stream: new StreamEventEmitter({
5019
- beforeClosing: function () {
5020
- manager.queries.delete(query);
5021
- // if no more queries then just let it go
5022
- if (manager.queries.size > 0) {
5023
- manager.handleQueriesChange();
5024
- }
5025
- },
5026
- }),
5027
- state: new Map(),
5028
- offset: NoOffsetReceivedYet,
5029
- caller: caller,
5030
- };
5031
- manager.queries.add(query);
5032
- manager.handleQueriesChange();
5033
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
5034
- var on = function (type, listener) {
5035
- var _a, _b;
5036
- if (((_a = manager.ws) === null || _a === void 0 ? void 0 : _a.readyState) === WsState.Open ||
5037
- ((_b = manager.ws) === null || _b === void 0 ? void 0 : _b.readyState) === WsState.Connecting) {
5038
- query.stream.on(type, listener);
5039
- }
5040
- else {
5041
- console.error("Trying to add a listener to a closed stream.");
5042
- }
5043
- };
5044
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
5045
- var off = function (type, listener) {
5046
- var _a, _b;
5047
- if (((_a = manager.ws) === null || _a === void 0 ? void 0 : _a.readyState) === WsState.Open ||
5048
- ((_b = manager.ws) === null || _b === void 0 ? void 0 : _b.readyState) === WsState.Connecting) {
5049
- query.stream.off(type, listener);
5050
- }
5051
- else {
5052
- console.error("Trying to remove a listener from a closed stream.");
5053
- }
5054
- };
5055
- var close = function () {
5056
- query.stream.close();
5057
- };
5058
- return { on: on, off: off, close: close };
5059
- };
5060
- QueryStreamsManager.ENDPOINT = "v1/stream/query";
5061
- return QueryStreamsManager;
5062
- }());
5063
- /**
5064
- * An object of type `Ledger` represents a handle to a Daml ledger.
5065
- */
5066
- var Ledger = /** @class */ (function () {
5067
- /**
5068
- * Construct a new `Ledger` object. See [[LedgerOptions]] for the constructor arguments.
5069
- */
5070
- function Ledger(_a) {
5071
- var token = _a.token, httpBaseUrl = _a.httpBaseUrl, wsBaseUrl = _a.wsBaseUrl, _b = _a.reconnectThreshold, reconnectThreshold = _b === void 0 ? 30000 : _b, _c = _a.multiplexQueryStreams, multiplexQueryStreams = _c === void 0 ? false : _c;
5072
- if (!httpBaseUrl) {
5073
- httpBaseUrl = "".concat(window.location.protocol, "//").concat(window.location.host, "/");
5074
- }
5075
- if (!(httpBaseUrl.startsWith("http://") || httpBaseUrl.startsWith("https://"))) {
5076
- throw Error("Ledger: httpBaseUrl must start with 'http://' or 'https://'. (".concat(httpBaseUrl, ")"));
5077
- }
5078
- if (!httpBaseUrl.endsWith("/")) {
5079
- throw Error("Ledger: httpBaseUrl must end with '/'. (".concat(httpBaseUrl, ")"));
5080
- }
5081
- if (!wsBaseUrl) {
5082
- wsBaseUrl = "ws" + httpBaseUrl.slice(4);
5083
- }
5084
- if (!(wsBaseUrl.startsWith("ws://") || wsBaseUrl.startsWith("wss://"))) {
5085
- throw Error("Ledger: wsBaseUrl must start with 'ws://' or 'wss://'. (".concat(wsBaseUrl, ")"));
5086
- }
5087
- if (!wsBaseUrl.endsWith("/")) {
5088
- throw Error("Ledger: wsBaseUrl must end with '/'. (".concat(wsBaseUrl, ")"));
5089
- }
5090
- this.token = token;
5091
- this.httpBaseUrl = httpBaseUrl;
5092
- this.wsBaseUrl = wsBaseUrl;
5093
- this.reconnectThreshold = reconnectThreshold;
5094
- this.multiplexQueryStreams = multiplexQueryStreams;
5095
- this.queryStreamsManager = new QueryStreamsManager({
5096
- token: token,
5097
- wsBaseUrl: wsBaseUrl,
5098
- reconnectThreshold: reconnectThreshold,
5099
- });
5100
- }
5101
- /**
5102
- * @internal
5103
- */
5104
- Ledger.prototype.auth = function () {
5105
- return { Authorization: "Bearer " + this.token };
5106
- };
5107
- /**
5108
- * @internal
5109
- */
5110
- Ledger.prototype.throwOnError = function (r) {
5111
- return __awaiter(this, void 0, void 0, function () {
5112
- var json;
5113
- return __generator(this, function (_a) {
5114
- switch (_a.label) {
5115
- case 0:
5116
- if (!!r.ok) return [3 /*break*/, 2];
5117
- return [4 /*yield*/, r.json()];
5118
- case 1:
5119
- json = _a.sent();
5120
- console.log(json);
5121
- throw decode(decodeLedgerError, json);
5122
- case 2: return [2 /*return*/];
5123
- }
5124
- });
5125
- });
5126
- };
5127
- /**
5128
- * @internal
5129
- *
5130
- * Internal function to submit a command to the JSON API.
5131
- */
5132
- Ledger.prototype.submit = function (endpoint_1, payload_1) {
5133
- return __awaiter(this, arguments, void 0, function (endpoint, payload, method) {
5134
- var httpResponse, json, ledgerResponse;
5135
- if (method === void 0) { method = "post"; }
5136
- return __generator(this, function (_a) {
5137
- switch (_a.label) {
5138
- case 0: return [4 /*yield*/, (0, cross_fetch_1.default)(this.httpBaseUrl + endpoint, {
5139
- body: JSON.stringify(payload),
5140
- headers: __assign(__assign({}, this.auth()), { "Content-type": "application/json" }),
5141
- method: method,
5142
- })];
5143
- case 1:
5144
- httpResponse = _a.sent();
5145
- return [4 /*yield*/, this.throwOnError(httpResponse)];
5146
- case 2:
5147
- _a.sent();
5148
- return [4 /*yield*/, httpResponse.json()];
5149
- case 3:
5150
- json = _a.sent();
5151
- ledgerResponse = jtv.Result.withException(decodeLedgerResponse.run(json));
5152
- if (!(ledgerResponse.status >= 200 && ledgerResponse.status <= 299)) {
5153
- console.log("Request to ".concat(endpoint, " returned status ").concat(ledgerResponse.status, " with response body: ").concat(JSON.stringify(json), "."));
5154
- throw decode(decodeLedgerError, json);
5155
- }
5156
- if (ledgerResponse.warnings) {
5157
- console.warn(ledgerResponse.warnings);
5158
- }
5159
- return [2 /*return*/, ledgerResponse.result];
5160
- }
5161
- });
5162
- });
5163
- };
5164
- /***
5165
- * Internal
5166
- *
5167
- * Retrieve the readiness status from the JSON API.
5168
- */
5169
- Ledger.prototype.checkIfReady = function () {
5170
- return __awaiter(this, void 0, void 0, function () {
5171
- var endpoint, httpResponse, text, json, ledgerResponse;
5172
- return __generator(this, function (_a) {
5173
- switch (_a.label) {
5174
- case 0:
5175
- endpoint = "readyz";
5176
- return [4 /*yield*/, (0, cross_fetch_1.default)(this.httpBaseUrl + endpoint, {
5177
- headers: __assign(__assign({}, this.auth()), { "Content-type": "application/json" }),
5178
- method: "get",
5179
- })];
5180
- case 1:
5181
- httpResponse = _a.sent();
5182
- return [4 /*yield*/, this.throwOnError(httpResponse)];
5183
- case 2:
5184
- _a.sent();
5185
- return [4 /*yield*/, httpResponse.text()];
5186
- case 3:
5187
- text = _a.sent();
5188
- if (!text.includes("readyz check passed")) return [3 /*break*/, 4];
5189
- return [2 /*return*/, httpResponse];
5190
- case 4:
5191
- if (!text.includes("readyz check failed")) return [3 /*break*/, 5];
5192
- throw decode(decodeLedgerError, httpResponse);
5193
- case 5: return [4 /*yield*/, httpResponse.json()];
5194
- case 6:
5195
- json = _a.sent();
5196
- ledgerResponse = jtv.Result.withException(decodeLedgerResponse.run(json));
5197
- if (!(ledgerResponse.status >= 200 && ledgerResponse.status <= 299)) {
5198
- console.log("Request to ".concat(endpoint, " returned status ").concat(ledgerResponse.status, " with response body: ").concat(JSON.stringify(json), "."));
5199
- throw decode(decodeLedgerError, json);
5200
- }
5201
- if (ledgerResponse.warnings) {
5202
- console.warn(ledgerResponse.warnings);
5203
- }
5204
- return [2 /*return*/, ledgerResponse.result];
5205
- }
5206
- });
5207
- });
5208
- };
5209
- /***
5210
- * Retrieve the readiness status from the JSON API with retries every 1s.
5211
- */
5212
- Ledger.prototype.ready = function (maxAttempts) {
5213
- return __awaiter(this, void 0, void 0, function () {
5214
- var execute, delay;
5215
- var _this = this;
5216
- return __generator(this, function (_a) {
5217
- execute = function (attempt) { return __awaiter(_this, void 0, void 0, function () {
5218
- var err_1;
5219
- return __generator(this, function (_a) {
5220
- switch (_a.label) {
5221
- case 0:
5222
- _a.trys.push([0, 2, , 3]);
5223
- return [4 /*yield*/, this.checkIfReady()];
5224
- case 1: return [2 /*return*/, _a.sent()];
5225
- case 2:
5226
- err_1 = _a.sent();
5227
- if (attempt <= maxAttempts) {
5228
- return [2 /*return*/, delay(function () { return execute(attempt + 1); }, 1000)];
5229
- }
5230
- else {
5231
- throw err_1;
5232
- }
5233
- case 3: return [2 /*return*/];
5234
- }
5235
- });
5236
- }); };
5237
- delay = function (fn, ms) { return __awaiter(_this, void 0, void 0, function () {
5238
- return __generator(this, function (_a) {
5239
- return [2 /*return*/, new Promise(function (resolve) { return setTimeout(function () { return resolve(fn()); }, ms); })];
5240
- });
5241
- }); };
5242
- return [2 /*return*/, execute(1)];
5243
- });
5244
- });
5245
- };
5246
- /**
5247
- * Retrieve contracts for a given template.
5248
- *
5249
- * When no `query` argument is given, all contracts visible to the submitting party are returned.
5250
- * When a `query` argument is given, only those contracts matching the query are returned. See
5251
- * https://docs.daml.com/json-api/search-query-language.html for a description of the query
5252
- * language.
5253
- *
5254
- * @param template The contract template of the contracts to be matched against.
5255
- * @param query The contract query for the contracts to be matched against.
5256
- *
5257
- * @typeparam T The contract template type.
5258
- * @typeparam K The contract key type.
5259
- * @typeparam I The contract id type.
5260
- *
5261
- */
5262
- Ledger.prototype.query = function (template, query) {
5263
- return __awaiter(this, void 0, void 0, function () {
5264
- var payload, json;
5265
- return __generator(this, function (_a) {
5266
- switch (_a.label) {
5267
- case 0:
5268
- payload = {
5269
- templateIds: [template.templateId],
5270
- query: encodeQuery(template, query),
5271
- };
5272
- return [4 /*yield*/, this.submit("v1/query", payload)];
5273
- case 1:
5274
- json = _a.sent();
5275
- return [2 /*return*/, jtv.Result.withException(jtv.array(decodeCreateEvent(template)).run(json))];
5276
- }
5277
- });
5278
- });
5279
- };
5280
- /**
5281
- * Fetch a contract identified by its contract ID.
5282
- *
5283
- * @param template The template of the contract to be fetched.
5284
- * @param contractId The contract id of the contract to be fetched.
5285
- *
5286
- * @typeparam T The contract template type.
5287
- * @typeparam K The contract key type.
5288
- * @typeparam I The contract id type.
5289
- *
5290
- */
5291
- Ledger.prototype.fetch = function (template, contractId) {
5292
- return __awaiter(this, void 0, void 0, function () {
5293
- var payload, json;
5294
- return __generator(this, function (_a) {
5295
- switch (_a.label) {
5296
- case 0:
5297
- payload = {
5298
- templateId: template.templateId,
5299
- contractId: (0, types_1.ContractId)(template).encode(contractId),
5300
- };
5301
- return [4 /*yield*/, this.submit("v1/fetch", payload)];
5302
- case 1:
5303
- json = _a.sent();
5304
- return [2 /*return*/, jtv.Result.withException(jtv.oneOf(jtv.constant(null), decodeCreateEvent(template)).run(json))];
5305
- }
5306
- });
5307
- });
5308
- };
5309
- /**
5310
- * Fetch a contract identified by its contract key.
5311
- *
5312
- * Same as [[fetch]], but the contract to be fetched is identified by its contract key instead of
5313
- * its contract id.
5314
- *
5315
- * @param template The template of the contract to be fetched.
5316
- * @param key The contract key of the contract to be fetched.
5317
- *
5318
- * @typeparam T The contract template type.
5319
- * @typeparam K The contract key type.
5320
- * @typeparam I The contract id type.
5321
- */
5322
- Ledger.prototype.fetchByKey = function (template, key) {
5323
- return __awaiter(this, void 0, void 0, function () {
5324
- var payload, json;
5325
- return __generator(this, function (_a) {
5326
- switch (_a.label) {
5327
- case 0:
5328
- if (key === undefined) {
5329
- throw Error("Cannot lookup by key on template ".concat(template.templateId, " because it does not define a key."));
5330
- }
5331
- payload = {
5332
- templateId: template.templateId,
5333
- key: template.keyEncode(key),
5334
- };
5335
- return [4 /*yield*/, this.submit("v1/fetch", payload)];
5336
- case 1:
5337
- json = _a.sent();
5338
- return [2 /*return*/, jtv.Result.withException(jtv.oneOf(jtv.constant(null), decodeCreateEvent(template)).run(json))];
5339
- }
5340
- });
5341
- });
5342
- };
5343
- /**
5344
- * Create a contract for a given template.
5345
- *
5346
- * @param template The template of the contract to be created.
5347
- * @param payload The template arguments for the contract to be created.
5348
- * @param meta Optional meta fields to specify additional data on a command submission.
5349
- *
5350
- * @typeparam T The contract template type.
5351
- * @typeparam K The contract key type.
5352
- * @typeparam I The contract id type.
5353
- *
5354
- */
5355
- Ledger.prototype.create = function (template, payload, meta) {
5356
- return __awaiter(this, void 0, void 0, function () {
5357
- var command, json;
5358
- return __generator(this, function (_a) {
5359
- switch (_a.label) {
5360
- case 0:
5361
- command = {
5362
- templateId: template.templateId,
5363
- payload: template.encode(payload),
5364
- meta: meta,
5365
- };
5366
- return [4 /*yield*/, this.submit("v1/create", command)];
5367
- case 1:
5368
- json = _a.sent();
5369
- return [2 /*return*/, jtv.Result.withException(decodeCreateEvent(template).run(json))];
5370
- }
5371
- });
5372
- });
5373
- };
5374
- /**
5375
- * Exercise a choice on a contract identified by its contract ID.
5376
- *
5377
- * @param choice The choice to exercise.
5378
- * @param contractId The contract id of the contract to exercise.
5379
- * @param argument The choice arguments.
5380
- * @param meta Optional meta fields to specify additional data on a command submission.
5381
- *
5382
- * @typeparam T The contract template type.
5383
- * @typeparam C The type of the contract choice.
5384
- * @typeparam R The return type of the choice.
5385
- *
5386
- * @returns The return value of the choice together with a list of
5387
- * [[event]]'s that were created as a result of exercising the choice.
5388
- */
5389
- Ledger.prototype.exercise = function (choice, contractId, argument, meta) {
5390
- return __awaiter(this, void 0, void 0, function () {
5391
- var payload, json, responseDecoder, _a, exerciseResult, events;
5392
- return __generator(this, function (_b) {
5393
- switch (_b.label) {
5394
- case 0:
5395
- payload = {
5396
- templateId: choice.template().templateId,
5397
- contractId: (0, types_1.ContractId)(choice.template()).encode(contractId),
5398
- choice: choice.choiceName,
5399
- argument: choice.argumentEncode(argument),
5400
- meta: meta,
5401
- };
5402
- return [4 /*yield*/, this.submit("v1/exercise", payload)];
5403
- case 1:
5404
- json = _b.sent();
5405
- responseDecoder = jtv.object({
5406
- exerciseResult: choice.resultDecoder,
5407
- events: jtv.array(decodeEventUnknown),
5408
- });
5409
- _a = jtv.Result.withException(responseDecoder.run(json)), exerciseResult = _a.exerciseResult, events = _a.events;
5410
- return [2 /*return*/, [exerciseResult, events]];
5411
- }
5412
- });
5413
- });
5414
- };
5415
- /**
5416
- * Exercse a choice on a newly-created contract, in a single transaction.
5417
- *
5418
- * @param choice The choice to exercise.
5419
- * @param payload The template arguments for the newly-created contract.
5420
- * @param argument The choice arguments.
5421
- * @param meta Optional meta fields to specify additional data on a command submission.
5422
- *
5423
- * @typeparam T The contract template type.
5424
- * @typeparam C The type of the contract choice.
5425
- * @typeparam R The return type of the choice.
5426
- *
5427
- * @returns The return value of the choice together with a list of
5428
- * [[event]]'s that includes the creation event for the created contract as
5429
- * well as all the events that were created as a result of exercising the
5430
- * choice, including the archive event for the created contract if the choice
5431
- * is consuming (or otherwise archives it as part of its execution).
5432
- *
5433
- */
5434
- Ledger.prototype.createAndExercise = function (choice, payload, argument, meta) {
5435
- return __awaiter(this, void 0, void 0, function () {
5436
- var command, json, responseDecoder, _a, exerciseResult, events;
5437
- return __generator(this, function (_b) {
5438
- switch (_b.label) {
5439
- case 0:
5440
- command = {
5441
- templateId: choice.template().templateId,
5442
- payload: choice.template().encode(payload),
5443
- choice: choice.choiceName,
5444
- argument: choice.argumentEncode(argument),
5445
- meta: meta,
5446
- };
5447
- return [4 /*yield*/, this.submit("v1/create-and-exercise", command)];
5448
- case 1:
5449
- json = _b.sent();
5450
- responseDecoder = jtv.object({
5451
- exerciseResult: choice.resultDecoder,
5452
- events: jtv.array(decodeEventUnknown),
5453
- });
5454
- _a = jtv.Result.withException(responseDecoder.run(json)), exerciseResult = _a.exerciseResult, events = _a.events;
5455
- return [2 /*return*/, [exerciseResult, events]];
5456
- }
5457
- });
5458
- });
5459
- };
5460
- /**
5461
- * Exercise a choice on a contract identified by its contract key.
5462
- *
5463
- * Same as [[exercise]], but the contract is identified by its contract key instead of its
5464
- * contract id.
5465
- *
5466
- * @param choice The choice to exercise.
5467
- * @param key The contract key of the contract to exercise.
5468
- * @param argument The choice arguments.
5469
- * @param meta Optional meta fields to specify additional data on a command submission.
5470
- *
5471
- * @typeparam T The contract template type.
5472
- * @typeparam C The type of the contract choice.
5473
- * @typeparam R The return type of the choice.
5474
- * @typeparam K The type of the contract key.
5475
- *
5476
- * @returns The return value of the choice together with a list of [[event]]'s that where created
5477
- * as a result of exercising the choice.
5478
- */
5479
- Ledger.prototype.exerciseByKey = function (choice, key, argument, meta) {
5480
- return __awaiter(this, void 0, void 0, function () {
5481
- var payload, json, responseDecoder, _a, exerciseResult, events;
5482
- return __generator(this, function (_b) {
5483
- switch (_b.label) {
5484
- case 0:
5485
- if (key === undefined) {
5486
- throw Error("Cannot exercise by key on template ".concat(choice.template().templateId, " because it does not define a key."));
5487
- }
5488
- payload = {
5489
- templateId: choice.template().templateId,
5490
- key: choice.template().keyEncode(key),
5491
- choice: choice.choiceName,
5492
- argument: choice.argumentEncode(argument),
5493
- meta: meta,
5494
- };
5495
- return [4 /*yield*/, this.submit("v1/exercise", payload)];
5496
- case 1:
5497
- json = _b.sent();
5498
- responseDecoder = jtv.object({
5499
- exerciseResult: choice.resultDecoder,
5500
- events: jtv.array(decodeEventUnknown),
5501
- });
5502
- _a = jtv.Result.withException(responseDecoder.run(json)), exerciseResult = _a.exerciseResult, events = _a.events;
5503
- return [2 /*return*/, [exerciseResult, events]];
5504
- }
5505
- });
5506
- });
5507
- };
5508
- /**
5509
- * Archive a contract identified by its contract ID.
5510
- *
5511
- * @param template The template of the contract to archive.
5512
- * @param contractId The contract id of the contract to archive.
5513
- * @param meta Optional meta fields to specify additional data on a command submission.
5514
- *
5515
- * @typeparam T The contract template type.
5516
- * @typeparam K The contract key type.
5517
- * @typeparam I The contract id type.
5518
- *
5519
- */
5520
- Ledger.prototype.archive = function (template, contractId, meta) {
5521
- return __awaiter(this, void 0, void 0, function () {
5522
- var _this = this;
5523
- return __generator(this, function (_a) {
5524
- return [2 /*return*/, decodeArchiveResponse(template, "archive", function () {
5525
- return _this.exercise(template.Archive, contractId, {}, meta);
5526
- })];
5527
- });
5528
- });
5529
- };
5530
- /**
5531
- * Archive a contract identified by its contract key.
5532
- * Same as [[archive]], but the contract to be archived is identified by its contract key.
5533
- *
5534
- * @param template The template of the contract to be archived.
5535
- * @param key The contract key of the contract to be archived.
5536
- * @param meta Optional meta fields to specify additional data on a command submission.
5537
- *
5538
- * @typeparam T The contract template type.
5539
- * @typeparam K The contract key type.
5540
- * @typeparam I The contract id type.
5541
- *
5542
- */
5543
- Ledger.prototype.archiveByKey = function (template, key, meta) {
5544
- return __awaiter(this, void 0, void 0, function () {
5545
- var _this = this;
5546
- return __generator(this, function (_a) {
5547
- return [2 /*return*/, decodeArchiveResponse(template, "archiveByKey", function () {
5548
- return _this.exerciseByKey(template.Archive, key, {}, meta);
5549
- })];
5550
- });
5551
- });
5552
- };
5553
- /**
5554
- * @internal
5555
- *
5556
- * Internal command to submit a request to a streaming endpoint of the
5557
- * JSON API. Returns a stream consisting of accumulated state together with
5558
- * the events that produced the latest state change. The `change` function
5559
- * must be an operation of the monoid `Event<T, K, I>[]` on the set `State`,
5560
- * i.e., for all `s: State` and `x, y: Event<T, K, I>[]` we
5561
- * must have the structural equalities
5562
- * ```
5563
- * change(s, []) == s
5564
- * change(s, x.concat(y)) == change(change(s, x), y)
5565
- * ```
5566
- * Also, `change` must never change its arguments.
5567
- */
5568
- Ledger.prototype.streamSubmit = function (callerName, template, endpoint, request, reconnectRequest, init, change) {
5569
- var _this = this;
5570
- var protocols = ["jwt.token." + this.token, "daml.ws.auth"];
5571
- var ws = new isomorphic_ws_1.default(this.wsBaseUrl + endpoint, protocols);
5572
- var isLiveSince = undefined;
5573
- var lastOffset = undefined;
5574
- var state = init;
5575
- var isReconnecting = false;
5576
- var streamClosed = false;
5577
- var emitter = new events_1.EventEmitter();
5578
- var onWsOpen = function () {
5579
- if (isReconnecting) {
5580
- // the JSON API server can't handle null offsets, even though it sends them out under
5581
- // special conditions when there are no transactions yet. Not sending the `offset` message
5582
- // will start the stream from the very beginning of the transaction log.
5583
- if (lastOffset !== null)
5584
- ws.send(JSON.stringify({ offset: lastOffset }));
5585
- ws.send(JSON.stringify(reconnectRequest()));
5586
- }
5587
- else {
5588
- ws.send(JSON.stringify(request));
5589
- }
5590
- };
5591
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
5592
- var onWsMessage = function (event) {
5593
- var json = JSON.parse(event.data.toString());
5594
- if (isRecordWith("events", json)) {
5595
- var events = jtv.Result.withException(jtv.array(decodeEvent(template)).run(json.events));
5596
- if (events.length > 0) {
5597
- state = change(state, events);
5598
- emitter.emit("change", state, events);
5599
- }
5600
- if (isRecordWith("offset", json)) {
5601
- lastOffset = jtv.Result.withException(jtv.oneOf(jtv.constant(null), jtv.string()).run(json.offset));
5602
- if (isLiveSince === undefined) {
5603
- isLiveSince = Date.now();
5604
- emitter.emit("live", state);
5605
- }
5606
- }
5607
- }
5608
- else if (isRecordWith("warnings", json)) {
5609
- console.warn("".concat(callerName, " warnings"), json);
5610
- }
5611
- else if (isRecordWith("errors", json)) {
5612
- console.error("".concat(callerName, " errors"), json);
5613
- }
5614
- else {
5615
- console.error("".concat(callerName, " unknown message"), json);
5616
- }
5617
- };
5618
- var closeStream = function (status) {
5619
- streamClosed = true;
5620
- emitter.emit("close", status);
5621
- emitter.removeAllListeners();
5622
- };
5623
- var onWsClose = function () {
5624
- if (streamClosed === false) {
5625
- var now = new Date().getTime();
5626
- // we want to try and keep the stream open, so we try to reconnect
5627
- // the underlying ws
5628
- if (lastOffset !== undefined &&
5629
- isLiveSince !== undefined &&
5630
- now - isLiveSince >= _this.reconnectThreshold) {
5631
- isLiveSince = undefined;
5632
- isReconnecting = true;
5633
- ws = new isomorphic_ws_1.default(_this.wsBaseUrl + endpoint, protocols);
5634
- ws.addEventListener("open", onWsOpen);
5635
- ws.addEventListener("message", onWsMessage);
5636
- ws.addEventListener("close", onWsClose);
5637
- }
5638
- else {
5639
- // ws has closed too quickly / never managed to connect: we give up
5640
- closeStream({ code: 4001, reason: "ws connection failed" });
5641
- }
5642
- } // no else: if the stream is closed we don't need to keep a ws
5643
- };
5644
- ws.addEventListener("open", onWsOpen);
5645
- ws.addEventListener("message", onWsMessage);
5646
- // NOTE(MH): We ignore the 'error' event since it is always followed by a
5647
- // 'close' event, which we need to handle anyway.
5648
- ws.addEventListener("close", onWsClose);
5649
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
5650
- var on = function (type, listener) {
5651
- if (streamClosed === false) {
5652
- void emitter.on(type, listener);
5653
- }
5654
- else {
5655
- console.error("Trying to add a listener to a closed stream.");
5656
- }
5657
- };
5658
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
5659
- var off = function (type, listener) {
5660
- if (streamClosed === false) {
5661
- void emitter.off(type, listener);
5662
- }
5663
- else {
5664
- console.error("Trying to remove a listener from a closed stream.");
5665
- }
5666
- };
5667
- var close = function () {
5668
- // Note: ws.close will trigger the onClose handlers of the WebSocket
5669
- // (here onWsClose), but they execute as a separate event after the
5670
- // current event in the JS event loop, i.e. in particular after the call
5671
- // to closeStream and thus, in this case, the onWsClose handler will see
5672
- // streamClosed as true.
5673
- ws.close();
5674
- closeStream({ code: 4000, reason: "called .close()" });
5675
- };
5676
- return { on: on, off: off, close: close };
5677
- };
5678
- /**
5679
- * Retrieve a consolidated stream of events for a given template and query.
5680
- *
5681
- * The accumulated state is the current set of active contracts matching the query. When no
5682
- * `query` argument is given, all events visible to the submitting party are returned. When a
5683
- * `query` argument is given, only those create events matching the query are returned. See
5684
- * https://docs.daml.com/json-api/search-query-language.html for a description of the query
5685
- * language.
5686
- *
5687
- * @deprecated Prefer `streamQueries`.
5688
- *
5689
- * @param template The contract template to match contracts against.
5690
- * @param query The query to match contracts agains.
5691
- *
5692
- * @typeparam T The contract template type.
5693
- * @typeparam K The contract key type.
5694
- * @typeparam I The contract id type.
5695
- *
5696
- */
5697
- Ledger.prototype.streamQuery = function (template, query) {
5698
- if (query === undefined) {
5699
- return this.streamQueryCommon(template, [], "Ledger.streamQuery");
5700
- }
5701
- else {
5702
- return this.streamQueryCommon(template, [query], "Ledger.streamQuery");
5703
- }
5704
- };
5705
- /**
5706
- * @internal
5707
- *
5708
- */
5709
- Ledger.prototype.streamQueryCommon = function (template, queries, name) {
5710
- if (this.multiplexQueryStreams) {
5711
- return this.queryStreamsManager.streamSubmit(template, queries, name);
5712
- }
5713
- else {
5714
- var request_3 = queries.length == 0
5715
- ? [{ templateIds: [template.templateId] }]
5716
- : queries.map(function (q) { return ({
5717
- templateIds: [template.templateId],
5718
- query: encodeQuery(template, q),
5719
- }); });
5720
- var reconnectRequest = function () { return request_3; };
5721
- var change = function (contracts, events) {
5722
- var archiveEvents = new Set();
5723
- var createEvents = [];
5724
- for (var _i = 0, events_5 = events; _i < events_5.length; _i++) {
5725
- var event_3 = events_5[_i];
5726
- if ("created" in event_3) {
5727
- createEvents.push(event_3.created);
5728
- }
5729
- else if ("archived" in event_3) {
5730
- archiveEvents.add(event_3.archived.contractId);
5731
- }
5732
- }
5733
- return contracts
5734
- .concat(createEvents)
5735
- .filter(function (contract) { return !archiveEvents.has(contract.contractId); });
5736
- };
5737
- return this.streamSubmit(name, template, "v1/stream/query", request_3, reconnectRequest, [], change);
5738
- }
5739
- };
5740
- /**
5741
- * Retrieve a consolidated stream of events for a given template and queries.
5742
- *
5743
- * If the given list is empty, the accumulated state is the set of all active
5744
- * contracts for the given template. Otherwise, the accumulated state is the
5745
- * set of all contracts that match at least one of the given queries.
5746
- *
5747
- * See https://docs.daml.com/json-api/search-query-language.html for a
5748
- * description of the query language.
5749
- *
5750
- * @param template The contract template to match contracts against.
5751
- * @param queries A query to match contracts against.
5752
- *
5753
- * @typeparam T The contract template type.
5754
- * @typeparam K The contract key type.
5755
- * @typeparam I The contract id type.
5756
- */
5757
- Ledger.prototype.streamQueries = function (template, queries) {
5758
- return this.streamQueryCommon(template, queries, "Ledger.streamQueries");
5759
- };
5760
- /**
5761
- * Retrieve a consolidated stream of events for a given template and contract key.
5762
- *
5763
- * The accumulated state is either the current active contract for the given
5764
- * key, or null if there is no active contract for the given key.
5765
- *
5766
- * @deprecated Prefer `streamFetchByKeys`.
5767
- *
5768
- * @typeparam T The contract template type.
5769
- * @typeparam K The contract key type.
5770
- * @typeparam I The contract id type.
5771
- *
5772
- */
5773
- Ledger.prototype.streamFetchByKey = function (template, key) {
5774
- // Note: this implementation is deliberately not unified with that of
5775
- // `streamFetchByKeys`, because doing so would add the requirement that the
5776
- // given key be in output format, whereas existing implementation supports
5777
- // input format.
5778
- var lastContractId = null;
5779
- var request = [
5780
- { templateId: template.templateId, key: template.keyEncode(key) },
5781
- ];
5782
- var reconnectRequest = function () { return [
5783
- __assign(__assign({}, request[0]), { contractIdAtOffset: lastContractId && (0, types_1.ContractId)(template).encode(lastContractId) }),
5784
- ]; };
5785
- var change = function (contract, events) {
5786
- for (var _i = 0, events_6 = events; _i < events_6.length; _i++) {
5787
- var event_4 = events_6[_i];
5788
- if ("created" in event_4) {
5789
- contract = event_4.created;
5790
- }
5791
- else {
5792
- // i.e. 'archived' event
5793
- if (contract && contract.contractId === event_4.archived.contractId) {
5794
- contract = null;
5795
- }
5796
- }
5797
- }
5798
- lastContractId = contract ? contract.contractId : null;
5799
- return contract;
5800
- };
5801
- return this.streamSubmit("Ledger.streamFetchByKey", template, "v1/stream/fetch", request, reconnectRequest, null, change);
5802
- };
5803
- /**
5804
- * @internal
5805
- *
5806
- * Returns the same API as [[streamSubmit]] but does not, in fact, establish
5807
- * any socket connection. Instead, this is a stream that always has the given
5808
- * value as its accumulated state.
5809
- */
5810
- Ledger.prototype.constantStream = function (value) {
5811
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
5812
- function on(type, listener) {
5813
- if (type === "live") {
5814
- listener(value);
5815
- }
5816
- if (type === "change") {
5817
- listener(value, []);
5818
- }
5819
- }
5820
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function
5821
- function off(_t, _l) { }
5822
- // eslint-disable-next-line @typescript-eslint/no-empty-function
5823
- return { on: on, off: off, close: function () { } };
5824
- };
5825
- /**
5826
- * Retrieve a consolidated stream of events for a list of keys and a single
5827
- * template.
5828
- *
5829
- * The accumulated state is an array of the same length as the given list of
5830
- * keys, with positional correspondence. Each element in the array represents
5831
- * the current contract for the given key, or is explicitly null if there is
5832
- * currently no active contract matching that key.
5833
- *
5834
- * Note: the given `key` objects will be compared for (deep) equality with
5835
- * the values returned by the API. As such, they have to be given in the
5836
- * "output" format of the API, including the values of
5837
- * `encodeDecimalAsString` and `encodeInt64AsString`. See [the JSON API docs
5838
- * for details](https://docs.daml.com/json-api/lf-value-specification.html).
5839
- *
5840
- * @typeparam T The contract template type.
5841
- * @typeparam K The contract key type.
5842
- * @typeparam I The contract id type.
5843
- */
5844
- Ledger.prototype.streamFetchByKeys = function (template, keys) {
5845
- // We support zero-length key so clients can more easily manage a dynamic
5846
- // list, without having to special-case 0-length on their side.
5847
- if (keys.length == 0) {
5848
- return this.constantStream([]);
5849
- }
5850
- var lastContractIds = Array(keys.length).fill(null);
5851
- var keysCopy = lodash_1.default.cloneDeep(keys);
5852
- var initState = Array(keys.length).fill(null);
5853
- var request = keys.map(function (k) { return ({
5854
- templateId: template.templateId,
5855
- key: template.keyEncode(k),
5856
- }); });
5857
- var reconnectRequest = function () {
5858
- return request.map(function (r, idx) {
5859
- var lastId = lastContractIds[idx];
5860
- return __assign(__assign({}, r), { contractIdAtOffset: lastId && (0, types_1.ContractId)(template).encode(lastId) });
5861
- });
5862
- };
5863
- var change = function (state, events) {
5864
- var newState = Array.from(state);
5865
- var _loop_1 = function (event_5) {
5866
- if ("created" in event_5) {
5867
- var k_1 = event_5.created.key;
5868
- keysCopy.forEach(function (requestKey, idx) {
5869
- if (lodash_1.default.isEqual(requestKey, k_1)) {
5870
- newState[idx] = event_5.created;
5871
- }
5872
- });
5873
- }
5874
- else {
5875
- // i.e. 'archived' in event
5876
- var id_1 = event_5.archived.contractId;
5877
- newState.forEach(function (contract, idx) {
5878
- if (contract && contract.contractId === id_1) {
5879
- newState[idx] = null;
5880
- }
5881
- });
5882
- }
5883
- };
5884
- for (var _i = 0, events_7 = events; _i < events_7.length; _i++) {
5885
- var event_5 = events_7[_i];
5886
- _loop_1(event_5);
5887
- }
5888
- newState.forEach(function (c, idx) {
5889
- lastContractIds[idx] = c ? c.contractId : null;
5890
- });
5891
- return newState;
5892
- };
5893
- return this.streamSubmit("streamFetchByKeys", template, "v1/stream/fetch", request, reconnectRequest, initState, change);
5894
- };
5895
- /**
5896
- * Fetch parties by identifier.
5897
- *
5898
- * @param parties An array of Party identifiers.
5899
- *
5900
- * @returns An array of the same length, where each element corresponds to
5901
- * the same-index element of the given parties, ans is either a PartyInfo
5902
- * object if the party exists or null if it does not.
5903
- *
5904
- */
5905
- Ledger.prototype.getParties = function (parties) {
5906
- return __awaiter(this, void 0, void 0, function () {
5907
- var json, resp, mapping, _i, resp_1, p, ret, idx;
5908
- return __generator(this, function (_a) {
5909
- switch (_a.label) {
5910
- case 0:
5911
- if (parties.length === 0) {
5912
- return [2 /*return*/, []];
5913
- }
5914
- return [4 /*yield*/, this.submit("v1/parties", parties)];
5915
- case 1:
5916
- json = _a.sent();
5917
- resp = decode(jtv.array(partyInfoDecoder), json);
5918
- mapping = {};
5919
- for (_i = 0, resp_1 = resp; _i < resp_1.length; _i++) {
5920
- p = resp_1[_i];
5921
- mapping[p.identifier] = p;
5922
- }
5923
- ret = Array(parties.length).fill(null);
5924
- for (idx = 0; idx < parties.length; idx++) {
5925
- ret[idx] = mapping[parties[idx]] || null;
5926
- }
5927
- return [2 /*return*/, ret];
5928
- }
5929
- });
5930
- });
5931
- };
5932
- /**
5933
- * Fetch all parties on the ledger.
5934
- *
5935
- * @returns All parties on the ledger, in no particular order.
5936
- *
5937
- */
5938
- Ledger.prototype.listKnownParties = function () {
5939
- return __awaiter(this, void 0, void 0, function () {
5940
- var json;
5941
- return __generator(this, function (_a) {
5942
- switch (_a.label) {
5943
- case 0: return [4 /*yield*/, this.submit("v1/parties", undefined, "get")];
5944
- case 1:
5945
- json = _a.sent();
5946
- return [2 /*return*/, decode(jtv.array(partyInfoDecoder), json)];
5947
- }
5948
- });
5949
- });
5950
- };
5951
- /**
5952
- * Get the current user details obtained by the currently used JWT.
5953
- *
5954
- * @param userId The user id
5955
- *
5956
- * @returns User details
5957
- *
5958
- */
5959
- Ledger.prototype.getUser = function (userId) {
5960
- return __awaiter(this, void 0, void 0, function () {
5961
- var json, _a;
5962
- return __generator(this, function (_b) {
5963
- switch (_b.label) {
5964
- case 0:
5965
- if (!(0, lodash_1.isUndefined)(userId)) return [3 /*break*/, 2];
5966
- return [4 /*yield*/, this.submit("v1/user", undefined, "get")];
5967
- case 1:
5968
- _a = _b.sent();
5969
- return [3 /*break*/, 4];
5970
- case 2: return [4 /*yield*/, this.submit("v1/user", { userId: userId }, "post")];
5971
- case 3:
5972
- _a = _b.sent();
5973
- _b.label = 4;
5974
- case 4:
5975
- json = _a;
5976
- return [2 /*return*/, decode(userDecoder, json)];
5977
- }
5978
- });
5979
- });
5980
- };
5981
- /**
5982
- * Lists the users on the ledger
5983
- *
5984
- * @returns user list
5985
- *
5986
- */
5987
- Ledger.prototype.listUsers = function () {
5988
- return __awaiter(this, void 0, void 0, function () {
5989
- var json;
5990
- return __generator(this, function (_a) {
5991
- switch (_a.label) {
5992
- case 0: return [4 /*yield*/, this.submit("v1/users", undefined, "get")];
5993
- case 1:
5994
- json = _a.sent();
5995
- return [2 /*return*/, decode(jtv.array(userDecoder), json)];
5996
- }
5997
- });
5998
- });
5999
- };
6000
- /**
6001
- * Lists the rights associated with the given user id
6002
- *
6003
- * @param userId, if empty then the user id will obtained by the currently used JWT.
6004
- *
6005
- * @returns list of user rights
6006
- */
6007
- Ledger.prototype.listUserRights = function (userId) {
6008
- return __awaiter(this, void 0, void 0, function () {
6009
- var json, _a;
6010
- return __generator(this, function (_b) {
6011
- switch (_b.label) {
6012
- case 0:
6013
- if (!(0, lodash_1.isUndefined)(userId)) return [3 /*break*/, 2];
6014
- return [4 /*yield*/, this.submit("v1/user/rights", undefined, "get")];
6015
- case 1:
6016
- _a = _b.sent();
6017
- return [3 /*break*/, 4];
6018
- case 2: return [4 /*yield*/, this.submit("v1/user/rights", { userId: userId })];
6019
- case 3:
6020
- _a = _b.sent();
6021
- _b.label = 4;
6022
- case 4:
6023
- json = _a;
6024
- return [2 /*return*/, decode(jtv.array(userRightDecoder), json)];
6025
- }
6026
- });
6027
- });
6028
- };
6029
- /**
6030
- * Grants rights to a user
6031
- *
6032
- * @param userId The user to which rights shall be granted
6033
- *
6034
- * @param rights The rights which shall be granted
6035
- *
6036
- * @returns The rights which actually were granted (if a right was already granted, then it will not be in the return list)
6037
- */
6038
- Ledger.prototype.grantUserRights = function (userId, rights) {
6039
- return __awaiter(this, void 0, void 0, function () {
6040
- var json;
6041
- return __generator(this, function (_a) {
6042
- switch (_a.label) {
6043
- case 0: return [4 /*yield*/, this.submit("v1/user/rights/grant", {
6044
- userId: userId,
6045
- rights: rights,
6046
- })];
6047
- case 1:
6048
- json = _a.sent();
6049
- return [2 /*return*/, decode(jtv.array(userRightDecoder), json)];
6050
- }
6051
- });
6052
- });
6053
- };
6054
- /**
6055
- * Revokes rights from a user
6056
- *
6057
- * @param userId The user from which rights shall be revoked
6058
- *
6059
- * @param rights The rights which shall be revoked
6060
- *
6061
- * @returns The rights which actually were revoked (if a right was already revoked, then it will not be in the return list)
6062
- */
6063
- Ledger.prototype.revokeUserRights = function (userId, rights) {
6064
- return __awaiter(this, void 0, void 0, function () {
6065
- var json;
6066
- return __generator(this, function (_a) {
6067
- switch (_a.label) {
6068
- case 0: return [4 /*yield*/, this.submit("v1/user/rights/revoke", {
6069
- userId: userId,
6070
- rights: rights,
6071
- })];
6072
- case 1:
6073
- json = _a.sent();
6074
- return [2 /*return*/, decode(jtv.array(userRightDecoder), json)];
6075
- }
6076
- });
6077
- });
6078
- };
6079
- /**
6080
- * Creates a user
6081
- *
6082
- * @param userId The user ID
6083
- * @param rights The initial rights the user should have
6084
- * @param primaryParty The primary party the user should have
6085
- *
6086
- */
6087
- Ledger.prototype.createUser = function (userId, rights, primaryParty) {
6088
- return __awaiter(this, void 0, void 0, function () {
6089
- return __generator(this, function (_a) {
6090
- switch (_a.label) {
6091
- case 0: return [4 /*yield*/, this.submit("v1/user/create", {
6092
- userId: userId,
6093
- rights: rights,
6094
- primaryParty: primaryParty,
6095
- })];
6096
- case 1:
6097
- _a.sent();
6098
- return [2 /*return*/];
6099
- }
6100
- });
6101
- });
6102
- };
6103
- /**
6104
- * Deletes a user
6105
- *
6106
- * @param userId The user ID
6107
- * @param rights The initial rights the user should have
6108
- * @param primaryParty The primary party the user should have
6109
- *
6110
- */
6111
- Ledger.prototype.deleteUser = function (userId) {
6112
- return __awaiter(this, void 0, void 0, function () {
6113
- return __generator(this, function (_a) {
6114
- switch (_a.label) {
6115
- case 0: return [4 /*yield*/, this.submit("v1/user/delete", { userId: userId })];
6116
- case 1:
6117
- _a.sent();
6118
- return [2 /*return*/];
6119
- }
6120
- });
6121
- });
6122
- };
6123
- /**
6124
- * Allocate a new party.
6125
- *
6126
- * @param partyOpt Parameters for party allocation.
6127
- *
6128
- * @returns PartyInfo for the newly created party.
6129
- *
6130
- */
6131
- Ledger.prototype.allocateParty = function (partyOpt) {
6132
- return __awaiter(this, void 0, void 0, function () {
6133
- var json;
6134
- return __generator(this, function (_a) {
6135
- switch (_a.label) {
6136
- case 0: return [4 /*yield*/, this.submit("v1/parties/allocate", partyOpt)];
6137
- case 1:
6138
- json = _a.sent();
6139
- return [2 /*return*/, decode(partyInfoDecoder, json)];
6140
- }
6141
- });
6142
- });
6143
- };
6144
- /**
6145
- * Fetch a list of all package IDs from the ledger.
6146
- *
6147
- * @returns List of package IDs.
6148
- *
6149
- */
6150
- Ledger.prototype.listPackages = function () {
6151
- return __awaiter(this, void 0, void 0, function () {
6152
- var json;
6153
- return __generator(this, function (_a) {
6154
- switch (_a.label) {
6155
- case 0: return [4 /*yield*/, this.submit("v1/packages", undefined, "get")];
6156
- case 1:
6157
- json = _a.sent();
6158
- return [2 /*return*/, decode(jtv.array(jtv.string()), json)];
6159
- }
6160
- });
6161
- });
6162
- };
6163
- /**
6164
- * Fetch a binary package.
6165
- *
6166
- * @returns The content of the package as a raw ArrayBuffer.
6167
- *
6168
- */
6169
- Ledger.prototype.getPackage = function (id) {
6170
- return __awaiter(this, void 0, void 0, function () {
6171
- var httpResponse;
6172
- return __generator(this, function (_a) {
6173
- switch (_a.label) {
6174
- case 0: return [4 /*yield*/, (0, cross_fetch_1.default)(this.httpBaseUrl + "v1/packages/" + id, {
6175
- headers: this.auth(),
6176
- method: "get",
6177
- })];
6178
- case 1:
6179
- httpResponse = _a.sent();
6180
- return [4 /*yield*/, this.throwOnError(httpResponse)];
6181
- case 2:
6182
- _a.sent();
6183
- return [4 /*yield*/, httpResponse.arrayBuffer()];
6184
- case 3: return [2 /*return*/, _a.sent()];
6185
- }
6186
- });
6187
- });
6188
- };
6189
- /**
6190
- * Upload a binary archive. Note that this requires admin privileges.
6191
- *
6192
- * @returns No return value on success; throws on error.
6193
- *
6194
- */
6195
- Ledger.prototype.uploadDarFile = function (abuf) {
6196
- return __awaiter(this, void 0, void 0, function () {
6197
- var httpResponse;
6198
- return __generator(this, function (_a) {
6199
- switch (_a.label) {
6200
- case 0: return [4 /*yield*/, (0, cross_fetch_1.default)(this.httpBaseUrl + "v1/packages", {
6201
- body: abuf,
6202
- headers: __assign(__assign({}, this.auth()), { "Content-type": "application/octet-stream" }),
6203
- method: "post",
6204
- })];
6205
- case 1:
6206
- httpResponse = _a.sent();
6207
- return [4 /*yield*/, this.throwOnError(httpResponse)];
6208
- case 2:
6209
- _a.sent();
6210
- return [2 /*return*/];
6211
- }
6212
- });
6213
- });
6214
- };
6215
- return Ledger;
6216
- }());
6217
- ledger.Ledger = Ledger;
6218
- ledger.default = Ledger;
6219
-
6220
- return ledger;
6221
- }
6222
-
6223
3221
  var lib$1 = {};
6224
3222
 
6225
3223
  var DA$1 = {};
@@ -6241,8 +3239,6 @@ function requireModule$7 () {
6241
3239
  var jtv = require$$0;
6242
3240
  /* eslint-disable-next-line no-unused-vars */
6243
3241
  var damlTypes = requireTypes$1();
6244
- /* eslint-disable-next-line no-unused-vars */
6245
- requireLedger();
6246
3242
 
6247
3243
  exports$1.Archive = {
6248
3244
  decoder: damlTypes.lazyMemo(function () {
@@ -6339,8 +3335,6 @@ function requireModule$6 () {
6339
3335
  var jtv = require$$0;
6340
3336
  /* eslint-disable-next-line no-unused-vars */
6341
3337
  var damlTypes = requireTypes$1();
6342
- /* eslint-disable-next-line no-unused-vars */
6343
- requireLedger();
6344
3338
 
6345
3339
  exports$1.RelTime = {
6346
3340
  decoder: damlTypes.lazyMemo(function () {
@@ -6427,14 +3421,13 @@ function requireModule$5 () {
6427
3421
  var jtv = require$$0;
6428
3422
  /* eslint-disable-next-line no-unused-vars */
6429
3423
  var damlTypes = requireTypes$1();
6430
- /* eslint-disable-next-line no-unused-vars */
6431
- requireLedger();
6432
3424
 
6433
3425
  var pkg9e70a8b3510d617f8a136213f33d6a903a10ca0eeec76bb06ba55d1ed9680f69 = requireLib$2();
6434
3426
  var pkgb70db8369e1c461d5c70f1c86f526a29e9776c655e6ffc2560f95b05ccb8b946 = requireLib$1();
6435
3427
 
6436
3428
  exports$1.AnyContract = damlTypes.assembleInterface(
6437
- 'a132be8b23c8515da6c828dd97519a73d9c8b1aa6f9cddd3c7acc206e4b41f8c:Splice.Api.Token.MetadataV1:AnyContract',
3429
+ '#token-standard-models:Splice.Api.Token.MetadataV1:AnyContract',
3430
+ '3c373f302ebb5531459ceca3b6f0409365d119767ffe2026a04e6bd750dae10d:Splice.Api.Token.MetadataV1:AnyContract',
6438
3431
  function () {
6439
3432
  return exports$1.AnyContractView
6440
3433
  },
@@ -6663,8 +3656,6 @@ function requireModule$4 () {
6663
3656
  var jtv = require$$0;
6664
3657
  /* eslint-disable-next-line no-unused-vars */
6665
3658
  var damlTypes = requireTypes$1();
6666
- /* eslint-disable-next-line no-unused-vars */
6667
- requireLedger();
6668
3659
 
6669
3660
  var pkg9e70a8b3510d617f8a136213f33d6a903a10ca0eeec76bb06ba55d1ed9680f69 = requireLib$2();
6670
3661
  var pkgb70db8369e1c461d5c70f1c86f526a29e9776c655e6ffc2560f95b05ccb8b946 = requireLib$1();
@@ -6672,7 +3663,8 @@ function requireModule$4 () {
6672
3663
  var Splice_Api_Token_MetadataV1 = requireModule$5();
6673
3664
 
6674
3665
  exports$1.Holding = damlTypes.assembleInterface(
6675
- 'a132be8b23c8515da6c828dd97519a73d9c8b1aa6f9cddd3c7acc206e4b41f8c:Splice.Api.Token.HoldingV1:Holding',
3666
+ '#token-standard-models:Splice.Api.Token.HoldingV1:Holding',
3667
+ '3c373f302ebb5531459ceca3b6f0409365d119767ffe2026a04e6bd750dae10d:Splice.Api.Token.HoldingV1:Holding',
6676
3668
  function () {
6677
3669
  return exports$1.HoldingView
6678
3670
  },
@@ -6794,8 +3786,6 @@ function requireModule$3 () {
6794
3786
  var jtv = require$$0;
6795
3787
  /* eslint-disable-next-line no-unused-vars */
6796
3788
  var damlTypes = requireTypes$1();
6797
- /* eslint-disable-next-line no-unused-vars */
6798
- requireLedger();
6799
3789
 
6800
3790
  var pkg9e70a8b3510d617f8a136213f33d6a903a10ca0eeec76bb06ba55d1ed9680f69 = requireLib$2();
6801
3791
 
@@ -6803,7 +3793,8 @@ function requireModule$3 () {
6803
3793
  var Splice_Api_Token_MetadataV1 = requireModule$5();
6804
3794
 
6805
3795
  exports$1.Allocation = damlTypes.assembleInterface(
6806
- 'a132be8b23c8515da6c828dd97519a73d9c8b1aa6f9cddd3c7acc206e4b41f8c:Splice.Api.Token.AllocationV1:Allocation',
3796
+ '#token-standard-models:Splice.Api.Token.AllocationV1:Allocation',
3797
+ '3c373f302ebb5531459ceca3b6f0409365d119767ffe2026a04e6bd750dae10d:Splice.Api.Token.AllocationV1:Allocation',
6807
3798
  function () {
6808
3799
  return exports$1.AllocationView
6809
3800
  },
@@ -7124,8 +4115,6 @@ function requireModule$2 () {
7124
4115
  var jtv = require$$0;
7125
4116
  /* eslint-disable-next-line no-unused-vars */
7126
4117
  var damlTypes = requireTypes$1();
7127
- /* eslint-disable-next-line no-unused-vars */
7128
- requireLedger();
7129
4118
 
7130
4119
  var pkg9e70a8b3510d617f8a136213f33d6a903a10ca0eeec76bb06ba55d1ed9680f69 = requireLib$2();
7131
4120
 
@@ -7134,7 +4123,8 @@ function requireModule$2 () {
7134
4123
  var Splice_Api_Token_MetadataV1 = requireModule$5();
7135
4124
 
7136
4125
  exports$1.AllocationFactory = damlTypes.assembleInterface(
7137
- 'a132be8b23c8515da6c828dd97519a73d9c8b1aa6f9cddd3c7acc206e4b41f8c:Splice.Api.Token.AllocationInstructionV1:AllocationFactory',
4126
+ '#token-standard-models:Splice.Api.Token.AllocationInstructionV1:AllocationFactory',
4127
+ '3c373f302ebb5531459ceca3b6f0409365d119767ffe2026a04e6bd750dae10d:Splice.Api.Token.AllocationInstructionV1:AllocationFactory',
7138
4128
  function () {
7139
4129
  return exports$1.AllocationFactoryView
7140
4130
  },
@@ -7200,7 +4190,8 @@ function requireModule$2 () {
7200
4190
  );
7201
4191
 
7202
4192
  exports$1.AllocationInstruction = damlTypes.assembleInterface(
7203
- 'a132be8b23c8515da6c828dd97519a73d9c8b1aa6f9cddd3c7acc206e4b41f8c:Splice.Api.Token.AllocationInstructionV1:AllocationInstruction',
4193
+ '#token-standard-models:Splice.Api.Token.AllocationInstructionV1:AllocationInstruction',
4194
+ '3c373f302ebb5531459ceca3b6f0409365d119767ffe2026a04e6bd750dae10d:Splice.Api.Token.AllocationInstructionV1:AllocationInstruction',
7204
4195
  function () {
7205
4196
  return exports$1.AllocationInstructionView
7206
4197
  },
@@ -7541,8 +4532,6 @@ function requireModule$1 () {
7541
4532
  var jtv = require$$0;
7542
4533
  /* eslint-disable-next-line no-unused-vars */
7543
4534
  var damlTypes = requireTypes$1();
7544
- /* eslint-disable-next-line no-unused-vars */
7545
- requireLedger();
7546
4535
 
7547
4536
  var pkg9e70a8b3510d617f8a136213f33d6a903a10ca0eeec76bb06ba55d1ed9680f69 = requireLib$2();
7548
4537
 
@@ -7550,7 +4539,8 @@ function requireModule$1 () {
7550
4539
  var Splice_Api_Token_MetadataV1 = requireModule$5();
7551
4540
 
7552
4541
  exports$1.AllocationRequest = damlTypes.assembleInterface(
7553
- 'a132be8b23c8515da6c828dd97519a73d9c8b1aa6f9cddd3c7acc206e4b41f8c:Splice.Api.Token.AllocationRequestV1:AllocationRequest',
4542
+ '#token-standard-models:Splice.Api.Token.AllocationRequestV1:AllocationRequest',
4543
+ '3c373f302ebb5531459ceca3b6f0409365d119767ffe2026a04e6bd750dae10d:Splice.Api.Token.AllocationRequestV1:AllocationRequest',
7554
4544
  function () {
7555
4545
  return exports$1.AllocationRequestView
7556
4546
  },
@@ -7768,8 +4758,6 @@ function requireModule () {
7768
4758
  var jtv = require$$0;
7769
4759
  /* eslint-disable-next-line no-unused-vars */
7770
4760
  var damlTypes = requireTypes$1();
7771
- /* eslint-disable-next-line no-unused-vars */
7772
- requireLedger();
7773
4761
 
7774
4762
  var pkg9e70a8b3510d617f8a136213f33d6a903a10ca0eeec76bb06ba55d1ed9680f69 = requireLib$2();
7775
4763
 
@@ -7777,7 +4765,8 @@ function requireModule () {
7777
4765
  var Splice_Api_Token_MetadataV1 = requireModule$5();
7778
4766
 
7779
4767
  exports$1.TransferFactory = damlTypes.assembleInterface(
7780
- 'a132be8b23c8515da6c828dd97519a73d9c8b1aa6f9cddd3c7acc206e4b41f8c:Splice.Api.Token.TransferInstructionV1:TransferFactory',
4768
+ '#token-standard-models:Splice.Api.Token.TransferInstructionV1:TransferFactory',
4769
+ '3c373f302ebb5531459ceca3b6f0409365d119767ffe2026a04e6bd750dae10d:Splice.Api.Token.TransferInstructionV1:TransferFactory',
7781
4770
  function () {
7782
4771
  return exports$1.TransferFactoryView
7783
4772
  },
@@ -7843,7 +4832,8 @@ function requireModule () {
7843
4832
  );
7844
4833
 
7845
4834
  exports$1.TransferInstruction = damlTypes.assembleInterface(
7846
- 'a132be8b23c8515da6c828dd97519a73d9c8b1aa6f9cddd3c7acc206e4b41f8c:Splice.Api.Token.TransferInstructionV1:TransferInstruction',
4835
+ '#token-standard-models:Splice.Api.Token.TransferInstructionV1:TransferInstruction',
4836
+ '3c373f302ebb5531459ceca3b6f0409365d119767ffe2026a04e6bd750dae10d:Splice.Api.Token.TransferInstructionV1:TransferInstruction',
7847
4837
  function () {
7848
4838
  return exports$1.TransferInstructionView
7849
4839
  },
@@ -8355,7 +5345,7 @@ function requireLib () {
8355
5345
  var Splice = requireSplice();
8356
5346
  exports$1.Splice = Splice;
8357
5347
  exports$1.packageId =
8358
- 'a132be8b23c8515da6c828dd97519a73d9c8b1aa6f9cddd3c7acc206e4b41f8c';
5348
+ '3c373f302ebb5531459ceca3b6f0409365d119767ffe2026a04e6bd750dae10d';
8359
5349
  } (lib$2));
8360
5350
  return lib$2;
8361
5351
  }