@notabene/javascript-sdk 2.16.0 → 2.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/cjs/notabene.cjs +1 -1
- package/dist/cjs/notabene.d.ts +37 -5
- package/dist/cjs/package.json +1 -1
- package/dist/esm/notabene.d.ts +37 -5
- package/dist/esm/notabene.js +1 -1
- package/dist/esm/package.json +1 -1
- package/dist/notabene.d.ts +37 -5
- package/dist/notabene.js +1 -1
- package/package.json +1 -1
- package/src/ivms/v2Types.ts +1 -2
- package/src/notabene.ts +2 -0
- package/src/responseTransformer/transformer.ts +1 -3
- package/src/types.ts +47 -8
- package/src/utils/arbitraries.ts +44 -7
package/dist/cjs/notabene.d.ts
CHANGED
|
@@ -272,7 +272,6 @@ declare type BeneficiaryFields = {
|
|
|
272
272
|
|
|
273
273
|
declare type BeneficiaryV2 = {
|
|
274
274
|
beneficiaryPerson: PersonV2[];
|
|
275
|
-
customerIdentification?: string;
|
|
276
275
|
};
|
|
277
276
|
|
|
278
277
|
/**
|
|
@@ -879,7 +878,7 @@ export declare interface DepositRequest extends DepositRequestFields, ComponentR
|
|
|
879
878
|
declare type DepositRequestFields = {
|
|
880
879
|
destination: BlockchainAddress | CAIP10;
|
|
881
880
|
asset: TransactionAsset;
|
|
882
|
-
amountDecimal: number;
|
|
881
|
+
amountDecimal: string | number;
|
|
883
882
|
travelAddress?: TravelAddress;
|
|
884
883
|
cryptoCredential?: CryptoCredential;
|
|
885
884
|
};
|
|
@@ -2107,6 +2106,7 @@ declare type NaturalPersonNationalIdentifierTypeCode = Omit<NationalIdentifierTy
|
|
|
2107
2106
|
|
|
2108
2107
|
declare type NaturalPersonV2 = Omit<NaturalPerson_2, 'name'> & {
|
|
2109
2108
|
name: NaturalPersonNameV2;
|
|
2109
|
+
customerIdentification?: string;
|
|
2110
2110
|
};
|
|
2111
2111
|
|
|
2112
2112
|
/**
|
|
@@ -2450,7 +2450,6 @@ declare type OriginatorFields = {
|
|
|
2450
2450
|
|
|
2451
2451
|
declare type OriginatorV2 = {
|
|
2452
2452
|
originatorPerson: PersonV2[];
|
|
2453
|
-
customerIdentification?: string;
|
|
2454
2453
|
};
|
|
2455
2454
|
|
|
2456
2455
|
/**
|
|
@@ -3220,7 +3219,7 @@ export declare interface Transaction extends ComponentRequest {
|
|
|
3220
3219
|
agent: Agent;
|
|
3221
3220
|
counterparty: Counterparty;
|
|
3222
3221
|
asset: TransactionAsset;
|
|
3223
|
-
amountDecimal: number;
|
|
3222
|
+
amountDecimal: string | number;
|
|
3224
3223
|
proof?: OwnershipProof;
|
|
3225
3224
|
assetPrice?: {
|
|
3226
3225
|
price: number;
|
|
@@ -3517,13 +3516,37 @@ export declare interface VASP extends Agent {
|
|
|
3517
3516
|
}
|
|
3518
3517
|
|
|
3519
3518
|
/**
|
|
3520
|
-
* Options
|
|
3519
|
+
* Options controlling which VASPs are listed and searchable in the picker.
|
|
3520
|
+
*
|
|
3521
|
+
* Two mutually exclusive variants:
|
|
3522
|
+
*
|
|
3523
|
+
* - **V1** — `addUnknown`, `onlyActive`, `searchable` (filters by {@link VASPSearchControl} status).
|
|
3524
|
+
* - **V2** — `addUnknown`, `onlyActive`, `showTrustStatus` (filters by {@link VASPTrustStatus}).
|
|
3525
|
+
*
|
|
3526
|
+
* `searchable` (V1-only) cannot be combined with `showTrustStatus` (V2-only);
|
|
3527
|
+
* TypeScript will reject the mix at compile time. `addUnknown` and `onlyActive` are valid in both variants.
|
|
3528
|
+
*
|
|
3529
|
+
* @example V1
|
|
3530
|
+
* ```ts
|
|
3531
|
+
* { addUnknown: true, onlyActive: true, searchable: [VASPSearchControl.ALLOWED] }
|
|
3532
|
+
* ```
|
|
3533
|
+
*
|
|
3534
|
+
* @example V2
|
|
3535
|
+
* ```ts
|
|
3536
|
+
* { addUnknown: true, onlyActive: true, showTrustStatus: ['TRUSTED', 'NEW'] }
|
|
3537
|
+
* ```
|
|
3538
|
+
*
|
|
3521
3539
|
* @public
|
|
3522
3540
|
*/
|
|
3523
3541
|
export declare type VASPOptions = {
|
|
3524
3542
|
addUnknown?: boolean;
|
|
3525
3543
|
onlyActive?: boolean;
|
|
3526
3544
|
searchable?: VASPSearchControl[];
|
|
3545
|
+
} | {
|
|
3546
|
+
searchable?: undefined;
|
|
3547
|
+
addUnknown?: boolean;
|
|
3548
|
+
onlyActive?: boolean;
|
|
3549
|
+
showTrustStatus?: VASPTrustStatus[];
|
|
3527
3550
|
};
|
|
3528
3551
|
|
|
3529
3552
|
/**
|
|
@@ -3539,6 +3562,15 @@ export declare enum VASPSearchControl {
|
|
|
3539
3562
|
PENDING = "pending"
|
|
3540
3563
|
}
|
|
3541
3564
|
|
|
3565
|
+
/**
|
|
3566
|
+
* Trust status assigned to a VASP in the Notabene network.
|
|
3567
|
+
*
|
|
3568
|
+
* Used by {@link VASPOptions.showTrustStatus} to filter which VASPs are listed in the picker.
|
|
3569
|
+
*
|
|
3570
|
+
* @public
|
|
3571
|
+
*/
|
|
3572
|
+
export declare type VASPTrustStatus = 'TRUSTED' | 'NEW' | 'FLAGGED' | 'BANNED';
|
|
3573
|
+
|
|
3542
3574
|
/**
|
|
3543
3575
|
* A wallet agent acting on behalf of the counterparty
|
|
3544
3576
|
* @public
|
package/dist/cjs/package.json
CHANGED
package/dist/esm/notabene.d.ts
CHANGED
|
@@ -272,7 +272,6 @@ declare type BeneficiaryFields = {
|
|
|
272
272
|
|
|
273
273
|
declare type BeneficiaryV2 = {
|
|
274
274
|
beneficiaryPerson: PersonV2[];
|
|
275
|
-
customerIdentification?: string;
|
|
276
275
|
};
|
|
277
276
|
|
|
278
277
|
/**
|
|
@@ -879,7 +878,7 @@ export declare interface DepositRequest extends DepositRequestFields, ComponentR
|
|
|
879
878
|
declare type DepositRequestFields = {
|
|
880
879
|
destination: BlockchainAddress | CAIP10;
|
|
881
880
|
asset: TransactionAsset;
|
|
882
|
-
amountDecimal: number;
|
|
881
|
+
amountDecimal: string | number;
|
|
883
882
|
travelAddress?: TravelAddress;
|
|
884
883
|
cryptoCredential?: CryptoCredential;
|
|
885
884
|
};
|
|
@@ -2107,6 +2106,7 @@ declare type NaturalPersonNationalIdentifierTypeCode = Omit<NationalIdentifierTy
|
|
|
2107
2106
|
|
|
2108
2107
|
declare type NaturalPersonV2 = Omit<NaturalPerson_2, 'name'> & {
|
|
2109
2108
|
name: NaturalPersonNameV2;
|
|
2109
|
+
customerIdentification?: string;
|
|
2110
2110
|
};
|
|
2111
2111
|
|
|
2112
2112
|
/**
|
|
@@ -2450,7 +2450,6 @@ declare type OriginatorFields = {
|
|
|
2450
2450
|
|
|
2451
2451
|
declare type OriginatorV2 = {
|
|
2452
2452
|
originatorPerson: PersonV2[];
|
|
2453
|
-
customerIdentification?: string;
|
|
2454
2453
|
};
|
|
2455
2454
|
|
|
2456
2455
|
/**
|
|
@@ -3220,7 +3219,7 @@ export declare interface Transaction extends ComponentRequest {
|
|
|
3220
3219
|
agent: Agent;
|
|
3221
3220
|
counterparty: Counterparty;
|
|
3222
3221
|
asset: TransactionAsset;
|
|
3223
|
-
amountDecimal: number;
|
|
3222
|
+
amountDecimal: string | number;
|
|
3224
3223
|
proof?: OwnershipProof;
|
|
3225
3224
|
assetPrice?: {
|
|
3226
3225
|
price: number;
|
|
@@ -3517,13 +3516,37 @@ export declare interface VASP extends Agent {
|
|
|
3517
3516
|
}
|
|
3518
3517
|
|
|
3519
3518
|
/**
|
|
3520
|
-
* Options
|
|
3519
|
+
* Options controlling which VASPs are listed and searchable in the picker.
|
|
3520
|
+
*
|
|
3521
|
+
* Two mutually exclusive variants:
|
|
3522
|
+
*
|
|
3523
|
+
* - **V1** — `addUnknown`, `onlyActive`, `searchable` (filters by {@link VASPSearchControl} status).
|
|
3524
|
+
* - **V2** — `addUnknown`, `onlyActive`, `showTrustStatus` (filters by {@link VASPTrustStatus}).
|
|
3525
|
+
*
|
|
3526
|
+
* `searchable` (V1-only) cannot be combined with `showTrustStatus` (V2-only);
|
|
3527
|
+
* TypeScript will reject the mix at compile time. `addUnknown` and `onlyActive` are valid in both variants.
|
|
3528
|
+
*
|
|
3529
|
+
* @example V1
|
|
3530
|
+
* ```ts
|
|
3531
|
+
* { addUnknown: true, onlyActive: true, searchable: [VASPSearchControl.ALLOWED] }
|
|
3532
|
+
* ```
|
|
3533
|
+
*
|
|
3534
|
+
* @example V2
|
|
3535
|
+
* ```ts
|
|
3536
|
+
* { addUnknown: true, onlyActive: true, showTrustStatus: ['TRUSTED', 'NEW'] }
|
|
3537
|
+
* ```
|
|
3538
|
+
*
|
|
3521
3539
|
* @public
|
|
3522
3540
|
*/
|
|
3523
3541
|
export declare type VASPOptions = {
|
|
3524
3542
|
addUnknown?: boolean;
|
|
3525
3543
|
onlyActive?: boolean;
|
|
3526
3544
|
searchable?: VASPSearchControl[];
|
|
3545
|
+
} | {
|
|
3546
|
+
searchable?: undefined;
|
|
3547
|
+
addUnknown?: boolean;
|
|
3548
|
+
onlyActive?: boolean;
|
|
3549
|
+
showTrustStatus?: VASPTrustStatus[];
|
|
3527
3550
|
};
|
|
3528
3551
|
|
|
3529
3552
|
/**
|
|
@@ -3539,6 +3562,15 @@ export declare enum VASPSearchControl {
|
|
|
3539
3562
|
PENDING = "pending"
|
|
3540
3563
|
}
|
|
3541
3564
|
|
|
3565
|
+
/**
|
|
3566
|
+
* Trust status assigned to a VASP in the Notabene network.
|
|
3567
|
+
*
|
|
3568
|
+
* Used by {@link VASPOptions.showTrustStatus} to filter which VASPs are listed in the picker.
|
|
3569
|
+
*
|
|
3570
|
+
* @public
|
|
3571
|
+
*/
|
|
3572
|
+
export declare type VASPTrustStatus = 'TRUSTED' | 'NEW' | 'FLAGGED' | 'BANNED';
|
|
3573
|
+
|
|
3542
3574
|
/**
|
|
3543
3575
|
* A wallet agent acting on behalf of the counterparty
|
|
3544
3576
|
* @public
|
package/dist/esm/notabene.js
CHANGED
|
@@ -12223,7 +12223,7 @@ function _c(e) {
|
|
|
12223
12223
|
account: n == null ? void 0 : n.account,
|
|
12224
12224
|
proof: m,
|
|
12225
12225
|
asset: (n == null ? void 0 : n.asset) || (typeof l.transactionAsset == "string" ? l.transactionAsset : (h = l.transactionAsset) == null ? void 0 : h.caip19) || "",
|
|
12226
|
-
amountDecimal: (n == null ? void 0 : n.amountDecimal)
|
|
12226
|
+
amountDecimal: (n == null ? void 0 : n.amountDecimal) ?? l.transactionAmount ?? 0,
|
|
12227
12227
|
customer: n == null ? void 0 : n.customer
|
|
12228
12228
|
};
|
|
12229
12229
|
return mc(s, l, d);
|
package/dist/esm/package.json
CHANGED
package/dist/notabene.d.ts
CHANGED
|
@@ -272,7 +272,6 @@ declare type BeneficiaryFields = {
|
|
|
272
272
|
|
|
273
273
|
declare type BeneficiaryV2 = {
|
|
274
274
|
beneficiaryPerson: PersonV2[];
|
|
275
|
-
customerIdentification?: string;
|
|
276
275
|
};
|
|
277
276
|
|
|
278
277
|
/**
|
|
@@ -879,7 +878,7 @@ export declare interface DepositRequest extends DepositRequestFields, ComponentR
|
|
|
879
878
|
declare type DepositRequestFields = {
|
|
880
879
|
destination: BlockchainAddress | CAIP10;
|
|
881
880
|
asset: TransactionAsset;
|
|
882
|
-
amountDecimal: number;
|
|
881
|
+
amountDecimal: string | number;
|
|
883
882
|
travelAddress?: TravelAddress;
|
|
884
883
|
cryptoCredential?: CryptoCredential;
|
|
885
884
|
};
|
|
@@ -2107,6 +2106,7 @@ declare type NaturalPersonNationalIdentifierTypeCode = Omit<NationalIdentifierTy
|
|
|
2107
2106
|
|
|
2108
2107
|
declare type NaturalPersonV2 = Omit<NaturalPerson_2, 'name'> & {
|
|
2109
2108
|
name: NaturalPersonNameV2;
|
|
2109
|
+
customerIdentification?: string;
|
|
2110
2110
|
};
|
|
2111
2111
|
|
|
2112
2112
|
/**
|
|
@@ -2450,7 +2450,6 @@ declare type OriginatorFields = {
|
|
|
2450
2450
|
|
|
2451
2451
|
declare type OriginatorV2 = {
|
|
2452
2452
|
originatorPerson: PersonV2[];
|
|
2453
|
-
customerIdentification?: string;
|
|
2454
2453
|
};
|
|
2455
2454
|
|
|
2456
2455
|
/**
|
|
@@ -3220,7 +3219,7 @@ export declare interface Transaction extends ComponentRequest {
|
|
|
3220
3219
|
agent: Agent;
|
|
3221
3220
|
counterparty: Counterparty;
|
|
3222
3221
|
asset: TransactionAsset;
|
|
3223
|
-
amountDecimal: number;
|
|
3222
|
+
amountDecimal: string | number;
|
|
3224
3223
|
proof?: OwnershipProof;
|
|
3225
3224
|
assetPrice?: {
|
|
3226
3225
|
price: number;
|
|
@@ -3517,13 +3516,37 @@ export declare interface VASP extends Agent {
|
|
|
3517
3516
|
}
|
|
3518
3517
|
|
|
3519
3518
|
/**
|
|
3520
|
-
* Options
|
|
3519
|
+
* Options controlling which VASPs are listed and searchable in the picker.
|
|
3520
|
+
*
|
|
3521
|
+
* Two mutually exclusive variants:
|
|
3522
|
+
*
|
|
3523
|
+
* - **V1** — `addUnknown`, `onlyActive`, `searchable` (filters by {@link VASPSearchControl} status).
|
|
3524
|
+
* - **V2** — `addUnknown`, `onlyActive`, `showTrustStatus` (filters by {@link VASPTrustStatus}).
|
|
3525
|
+
*
|
|
3526
|
+
* `searchable` (V1-only) cannot be combined with `showTrustStatus` (V2-only);
|
|
3527
|
+
* TypeScript will reject the mix at compile time. `addUnknown` and `onlyActive` are valid in both variants.
|
|
3528
|
+
*
|
|
3529
|
+
* @example V1
|
|
3530
|
+
* ```ts
|
|
3531
|
+
* { addUnknown: true, onlyActive: true, searchable: [VASPSearchControl.ALLOWED] }
|
|
3532
|
+
* ```
|
|
3533
|
+
*
|
|
3534
|
+
* @example V2
|
|
3535
|
+
* ```ts
|
|
3536
|
+
* { addUnknown: true, onlyActive: true, showTrustStatus: ['TRUSTED', 'NEW'] }
|
|
3537
|
+
* ```
|
|
3538
|
+
*
|
|
3521
3539
|
* @public
|
|
3522
3540
|
*/
|
|
3523
3541
|
export declare type VASPOptions = {
|
|
3524
3542
|
addUnknown?: boolean;
|
|
3525
3543
|
onlyActive?: boolean;
|
|
3526
3544
|
searchable?: VASPSearchControl[];
|
|
3545
|
+
} | {
|
|
3546
|
+
searchable?: undefined;
|
|
3547
|
+
addUnknown?: boolean;
|
|
3548
|
+
onlyActive?: boolean;
|
|
3549
|
+
showTrustStatus?: VASPTrustStatus[];
|
|
3527
3550
|
};
|
|
3528
3551
|
|
|
3529
3552
|
/**
|
|
@@ -3539,6 +3562,15 @@ export declare enum VASPSearchControl {
|
|
|
3539
3562
|
PENDING = "pending"
|
|
3540
3563
|
}
|
|
3541
3564
|
|
|
3565
|
+
/**
|
|
3566
|
+
* Trust status assigned to a VASP in the Notabene network.
|
|
3567
|
+
*
|
|
3568
|
+
* Used by {@link VASPOptions.showTrustStatus} to filter which VASPs are listed in the picker.
|
|
3569
|
+
*
|
|
3570
|
+
* @public
|
|
3571
|
+
*/
|
|
3572
|
+
export declare type VASPTrustStatus = 'TRUSTED' | 'NEW' | 'FLAGGED' | 'BANNED';
|
|
3573
|
+
|
|
3542
3574
|
/**
|
|
3543
3575
|
* A wallet agent acting on behalf of the counterparty
|
|
3544
3576
|
* @public
|
package/dist/notabene.js
CHANGED
|
@@ -12223,7 +12223,7 @@ function _c(e) {
|
|
|
12223
12223
|
account: n == null ? void 0 : n.account,
|
|
12224
12224
|
proof: m,
|
|
12225
12225
|
asset: (n == null ? void 0 : n.asset) || (typeof l.transactionAsset == "string" ? l.transactionAsset : (h = l.transactionAsset) == null ? void 0 : h.caip19) || "",
|
|
12226
|
-
amountDecimal: (n == null ? void 0 : n.amountDecimal)
|
|
12226
|
+
amountDecimal: (n == null ? void 0 : n.amountDecimal) ?? l.transactionAmount ?? 0,
|
|
12227
12227
|
customer: n == null ? void 0 : n.customer
|
|
12228
12228
|
};
|
|
12229
12229
|
return mc(s, l, d);
|
package/package.json
CHANGED
package/src/ivms/v2Types.ts
CHANGED
|
@@ -7,12 +7,10 @@ import type {
|
|
|
7
7
|
|
|
8
8
|
export type OriginatorV2 = {
|
|
9
9
|
originatorPerson: PersonV2[];
|
|
10
|
-
customerIdentification?: string;
|
|
11
10
|
};
|
|
12
11
|
|
|
13
12
|
export type BeneficiaryV2 = {
|
|
14
13
|
beneficiaryPerson: PersonV2[];
|
|
15
|
-
customerIdentification?: string;
|
|
16
14
|
};
|
|
17
15
|
|
|
18
16
|
export type NaturalPersonNameIDV2 = {
|
|
@@ -27,6 +25,7 @@ export type NaturalPersonNameV2 = Omit<NaturalPersonName, 'nameIdentifier'> & {
|
|
|
27
25
|
|
|
28
26
|
export type NaturalPersonV2 = Omit<NaturalPerson, 'name'> & {
|
|
29
27
|
name: NaturalPersonNameV2;
|
|
28
|
+
customerIdentification?: string;
|
|
30
29
|
};
|
|
31
30
|
|
|
32
31
|
export type PersonV2 = Omit<Person, 'naturalPerson'> & {
|
package/src/notabene.ts
CHANGED
|
@@ -63,6 +63,7 @@ import type {
|
|
|
63
63
|
ValidationError,
|
|
64
64
|
VASP,
|
|
65
65
|
VASPOptions,
|
|
66
|
+
VASPTrustStatus,
|
|
66
67
|
Wallet,
|
|
67
68
|
Withdrawal,
|
|
68
69
|
} from './types';
|
|
@@ -189,6 +190,7 @@ export type {
|
|
|
189
190
|
ValidationError,
|
|
190
191
|
VASP,
|
|
191
192
|
VASPOptions,
|
|
193
|
+
VASPTrustStatus,
|
|
192
194
|
Wallet,
|
|
193
195
|
Withdrawal,
|
|
194
196
|
};
|
|
@@ -191,9 +191,7 @@ export function componentResponseToV1TxCreateRequest(
|
|
|
191
191
|
? txCreate.transactionAsset
|
|
192
192
|
: txCreate.transactionAsset?.caip19) ||
|
|
193
193
|
'',
|
|
194
|
-
amountDecimal:
|
|
195
|
-
value?.amountDecimal ||
|
|
196
|
-
(txCreate.transactionAmount ? parseFloat(txCreate.transactionAmount) : 0),
|
|
194
|
+
amountDecimal: value?.amountDecimal ?? txCreate.transactionAmount ?? 0,
|
|
197
195
|
customer: value?.customer,
|
|
198
196
|
} as Withdrawal;
|
|
199
197
|
|
package/src/types.ts
CHANGED
|
@@ -516,7 +516,7 @@ type BeneficiaryFields = {
|
|
|
516
516
|
type DepositRequestFields = {
|
|
517
517
|
destination: BlockchainAddress | CAIP10;
|
|
518
518
|
asset: TransactionAsset;
|
|
519
|
-
amountDecimal: number;
|
|
519
|
+
amountDecimal: string | number;
|
|
520
520
|
travelAddress?: TravelAddress;
|
|
521
521
|
cryptoCredential?: CryptoCredential;
|
|
522
522
|
};
|
|
@@ -572,7 +572,7 @@ export interface Transaction extends ComponentRequest {
|
|
|
572
572
|
agent: Agent;
|
|
573
573
|
counterparty: Counterparty;
|
|
574
574
|
asset: TransactionAsset;
|
|
575
|
-
amountDecimal: number;
|
|
575
|
+
amountDecimal: string | number;
|
|
576
576
|
proof?: OwnershipProof;
|
|
577
577
|
assetPrice?: {
|
|
578
578
|
price: number;
|
|
@@ -789,14 +789,53 @@ export enum VASPSearchControl {
|
|
|
789
789
|
}
|
|
790
790
|
|
|
791
791
|
/**
|
|
792
|
-
*
|
|
792
|
+
* Trust status assigned to a VASP in the Notabene network.
|
|
793
|
+
*
|
|
794
|
+
* Used by {@link VASPOptions.showTrustStatus} to filter which VASPs are listed in the picker.
|
|
795
|
+
*
|
|
793
796
|
* @public
|
|
794
797
|
*/
|
|
795
|
-
export type
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
798
|
+
export type VASPTrustStatus = 'TRUSTED' | 'NEW' | 'FLAGGED' | 'BANNED';
|
|
799
|
+
|
|
800
|
+
/**
|
|
801
|
+
* Options controlling which VASPs are listed and searchable in the picker.
|
|
802
|
+
*
|
|
803
|
+
* Two mutually exclusive variants:
|
|
804
|
+
*
|
|
805
|
+
* - **V1** — `addUnknown`, `onlyActive`, `searchable` (filters by {@link VASPSearchControl} status).
|
|
806
|
+
* - **V2** — `addUnknown`, `onlyActive`, `showTrustStatus` (filters by {@link VASPTrustStatus}).
|
|
807
|
+
*
|
|
808
|
+
* `searchable` (V1-only) cannot be combined with `showTrustStatus` (V2-only);
|
|
809
|
+
* TypeScript will reject the mix at compile time. `addUnknown` and `onlyActive` are valid in both variants.
|
|
810
|
+
*
|
|
811
|
+
* @example V1
|
|
812
|
+
* ```ts
|
|
813
|
+
* { addUnknown: true, onlyActive: true, searchable: [VASPSearchControl.ALLOWED] }
|
|
814
|
+
* ```
|
|
815
|
+
*
|
|
816
|
+
* @example V2
|
|
817
|
+
* ```ts
|
|
818
|
+
* { addUnknown: true, onlyActive: true, showTrustStatus: ['TRUSTED', 'NEW'] }
|
|
819
|
+
* ```
|
|
820
|
+
*
|
|
821
|
+
* @public
|
|
822
|
+
*/
|
|
823
|
+
export type VASPOptions =
|
|
824
|
+
// V1 vasps options
|
|
825
|
+
| {
|
|
826
|
+
addUnknown?: boolean;
|
|
827
|
+
onlyActive?: boolean;
|
|
828
|
+
searchable?: VASPSearchControl[]; // If array left empty all VASPs will be searchable
|
|
829
|
+
}
|
|
830
|
+
// V2 vasps options
|
|
831
|
+
| {
|
|
832
|
+
// Typing `searchable` as `undefined` (rather than omitting it) makes TS reject
|
|
833
|
+
// mixing V1 and V2 options, e.g. { searchable: [...], showTrustStatus: [...] }.
|
|
834
|
+
searchable?: undefined;
|
|
835
|
+
addUnknown?: boolean;
|
|
836
|
+
onlyActive?: boolean;
|
|
837
|
+
showTrustStatus?: VASPTrustStatus[];
|
|
838
|
+
};
|
|
800
839
|
|
|
801
840
|
/**
|
|
802
841
|
* Available methods for identity verification
|
package/src/utils/arbitraries.ts
CHANGED
|
@@ -24,6 +24,7 @@ import type {
|
|
|
24
24
|
TransactionOptions,
|
|
25
25
|
TravelAddress,
|
|
26
26
|
VASPOptions,
|
|
27
|
+
VASPTrustStatus,
|
|
27
28
|
Withdrawal,
|
|
28
29
|
} from '../types';
|
|
29
30
|
import {
|
|
@@ -31,6 +32,7 @@ import {
|
|
|
31
32
|
PersonType,
|
|
32
33
|
ProofTypes,
|
|
33
34
|
ValidationSections,
|
|
35
|
+
VASPSearchControl,
|
|
34
36
|
} from '../types';
|
|
35
37
|
import {
|
|
36
38
|
CAIP10_MATCHER,
|
|
@@ -91,6 +93,18 @@ export const arbitraryAgent = (): fc.Arbitrary<Agent> =>
|
|
|
91
93
|
verified: fc.boolean(),
|
|
92
94
|
});
|
|
93
95
|
|
|
96
|
+
// Generates decimal strings with 18+ fractional digits to test precision beyond float64
|
|
97
|
+
const arbitraryHighPrecisionDecimal = (): fc.Arbitrary<string> =>
|
|
98
|
+
fc
|
|
99
|
+
.tuple(
|
|
100
|
+
fc.integer({ min: 0, max: 999999 }),
|
|
101
|
+
fc.stringMatching(/^\d{18,24}$/),
|
|
102
|
+
)
|
|
103
|
+
.map(([integer, fractional]) => `${integer}.${fractional}`);
|
|
104
|
+
|
|
105
|
+
const arbitraryAmountDecimal = (): fc.Arbitrary<string | number> =>
|
|
106
|
+
fc.oneof(fc.float({ min: 0, noNaN: true }), arbitraryHighPrecisionDecimal());
|
|
107
|
+
|
|
94
108
|
export const arbitraryCounterparty = (): fc.Arbitrary<Counterparty> =>
|
|
95
109
|
arbitraryNaturalPerson(); // For simplicity we'll just use NaturalPerson
|
|
96
110
|
|
|
@@ -99,7 +113,7 @@ export const arbitraryWithdrawal = (): fc.Arbitrary<Withdrawal> =>
|
|
|
99
113
|
agent: arbitraryAgent(),
|
|
100
114
|
counterparty: arbitraryCounterparty(),
|
|
101
115
|
asset: arbitraryTransactionAsset(),
|
|
102
|
-
amountDecimal:
|
|
116
|
+
amountDecimal: arbitraryAmountDecimal(),
|
|
103
117
|
destination: fc.oneof(arbitraryBlockchainAddress(), arbitraryCAIP10()),
|
|
104
118
|
});
|
|
105
119
|
|
|
@@ -149,7 +163,7 @@ export const arbitraryDepositRequest = (): fc.Arbitrary<DepositRequest> =>
|
|
|
149
163
|
agent: arbitraryAgent(),
|
|
150
164
|
counterparty: arbitraryCounterparty(),
|
|
151
165
|
asset: arbitraryTransactionAsset(),
|
|
152
|
-
amountDecimal:
|
|
166
|
+
amountDecimal: arbitraryAmountDecimal(),
|
|
153
167
|
destination: fc.oneof(arbitraryBlockchainAddress(), arbitraryCAIP10()),
|
|
154
168
|
travelAddress: fc.option(arbitraryTravelAddress()),
|
|
155
169
|
cryptoCredential: fc.option(arbitraryCryptoCredential()),
|
|
@@ -194,10 +208,33 @@ export const arbitraryFieldTypes = (): fc.Arbitrary<FieldTypes> =>
|
|
|
194
208
|
});
|
|
195
209
|
|
|
196
210
|
export const arbitraryVASPOptions = (): fc.Arbitrary<VASPOptions> =>
|
|
197
|
-
fc.
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
211
|
+
fc.oneof(
|
|
212
|
+
fc.record({
|
|
213
|
+
addUnknown: fc.option(fc.boolean(), { nil: undefined }),
|
|
214
|
+
onlyActive: fc.option(fc.boolean(), { nil: undefined }),
|
|
215
|
+
searchable: fc.option(
|
|
216
|
+
fc.array(
|
|
217
|
+
fc.constantFrom(VASPSearchControl.ALLOWED, VASPSearchControl.PENDING),
|
|
218
|
+
),
|
|
219
|
+
{ nil: undefined },
|
|
220
|
+
),
|
|
221
|
+
}),
|
|
222
|
+
fc.record({
|
|
223
|
+
addUnknown: fc.option(fc.boolean(), { nil: undefined }),
|
|
224
|
+
onlyActive: fc.option(fc.boolean(), { nil: undefined }),
|
|
225
|
+
showTrustStatus: fc.option(
|
|
226
|
+
fc.array(
|
|
227
|
+
fc.constantFrom<VASPTrustStatus>(
|
|
228
|
+
'TRUSTED',
|
|
229
|
+
'NEW',
|
|
230
|
+
'FLAGGED',
|
|
231
|
+
'BANNED',
|
|
232
|
+
),
|
|
233
|
+
),
|
|
234
|
+
{ nil: undefined },
|
|
235
|
+
),
|
|
236
|
+
}),
|
|
237
|
+
);
|
|
201
238
|
|
|
202
239
|
export const arbitraryTransactionOptions =
|
|
203
240
|
(): fc.Arbitrary<TransactionOptions> =>
|
|
@@ -249,7 +286,7 @@ export const arbitraryDeposit = (): fc.Arbitrary<Deposit> =>
|
|
|
249
286
|
agent: arbitraryAgent(),
|
|
250
287
|
counterparty: arbitraryCounterparty(),
|
|
251
288
|
asset: arbitraryTransactionAsset(),
|
|
252
|
-
amountDecimal:
|
|
289
|
+
amountDecimal: arbitraryAmountDecimal(),
|
|
253
290
|
origin: fc.oneof(arbitraryBlockchainAddress(), arbitraryCAIP10()),
|
|
254
291
|
source: fc.oneof(arbitraryBlockchainAddress(), arbitraryCAIP10()),
|
|
255
292
|
});
|