@fuel-ts/account 0.0.0-rc-1976-20240417074721 → 0.0.0-rc-2045-20240417092921
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.
Potentially problematic release.
This version of @fuel-ts/account might be problematic. Click here for more details.
- package/dist/account.d.ts.map +1 -1
- package/dist/index.global.js +45 -67
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +80 -100
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -62
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/coin-quantity.d.ts +2 -2
- package/dist/providers/coin-quantity.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +0 -7
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts +1 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/script-transaction-request.d.ts +1 -1
- package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +2 -5
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
- package/dist/test-utils.global.js +46 -71
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +80 -103
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +42 -65
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +15 -15
package/dist/account.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,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B,MAAM,EAAE,YAAY;IACpB,gBAAgB;IAChB,QAAQ,GAAE,YAAiB,GAC1B,OAAO,CAAC,mBAAmB,CAAC;IAyCzB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAOnD;;;;;OAKG;IACG,eAAe,CAAC,sBAAsB,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC;IAUtF;;;;;OAKG;IACG,eAAe,CACnB,sBAAsB,EAAE,sBAAsB,EAC9C,EAAE,sBAA6B,EAAE,cAAc,EAAE,GAAE,oBAAyB,GAC3E,OAAO,CAAC,mBAAmB,CAAC;IAgB/B;;;;;OAKG;IACG,mBAAmB,CACvB,sBAAsB,EAAE,sBAAsB,EAC9C,EAAE,sBAA6B,EAAE,GAAE,yBAA8B,GAChE,OAAO,CAAC,UAAU,CAAC;IAQtB,OAAO,CAAC,WAAW;CAyBpB"}
|
package/dist/index.global.js
CHANGED
@@ -28952,7 +28952,7 @@ spurious results.`);
|
|
28952
28952
|
// ../versions/dist/index.mjs
|
28953
28953
|
function getBuiltinVersions() {
|
28954
28954
|
return {
|
28955
|
-
FORC: "0.
|
28955
|
+
FORC: "0.53.0",
|
28956
28956
|
FUEL_CORE: "0.22.1",
|
28957
28957
|
FUELS: "0.80.0"
|
28958
28958
|
};
|
@@ -31144,7 +31144,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31144
31144
|
toEvmAddress() {
|
31145
31145
|
const b256Address = toB256(this.bech32Address);
|
31146
31146
|
return {
|
31147
|
-
|
31147
|
+
bits: clearFirst12BytesFromB256(b256Address)
|
31148
31148
|
};
|
31149
31149
|
}
|
31150
31150
|
/**
|
@@ -31154,7 +31154,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31154
31154
|
*/
|
31155
31155
|
toAssetId() {
|
31156
31156
|
return {
|
31157
|
-
|
31157
|
+
bits: this.toB256()
|
31158
31158
|
};
|
31159
31159
|
}
|
31160
31160
|
/**
|
@@ -31272,6 +31272,10 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31272
31272
|
}
|
31273
31273
|
};
|
31274
31274
|
|
31275
|
+
// ../address/dist/configs.mjs
|
31276
|
+
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
31277
|
+
var BaseAssetId = ZeroBytes32;
|
31278
|
+
|
31275
31279
|
// ../math/dist/index.mjs
|
31276
31280
|
var import_bn = __toESM(require_bn(), 1);
|
31277
31281
|
var DEFAULT_PRECISION = 9;
|
@@ -31502,11 +31506,11 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31502
31506
|
let max2;
|
31503
31507
|
if (Array.isArray(coinQuantityLike)) {
|
31504
31508
|
amount = coinQuantityLike[0];
|
31505
|
-
assetId = coinQuantityLike[1];
|
31506
|
-
max2 = coinQuantityLike[2];
|
31509
|
+
assetId = coinQuantityLike[1] ?? BaseAssetId;
|
31510
|
+
max2 = coinQuantityLike[2] ?? void 0;
|
31507
31511
|
} else {
|
31508
31512
|
amount = coinQuantityLike.amount;
|
31509
|
-
assetId = coinQuantityLike.assetId;
|
31513
|
+
assetId = coinQuantityLike.assetId ?? BaseAssetId;
|
31510
31514
|
max2 = coinQuantityLike.max ?? void 0;
|
31511
31515
|
}
|
31512
31516
|
const bnAmount = bn(amount);
|
@@ -38870,9 +38874,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38870
38874
|
}
|
38871
38875
|
};
|
38872
38876
|
|
38873
|
-
// ../address/dist/configs.mjs
|
38874
|
-
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
38875
|
-
|
38876
38877
|
// src/providers/transaction-request/input.ts
|
38877
38878
|
var inputify = (value) => {
|
38878
38879
|
const { type: type3 } = value;
|
@@ -39549,8 +39550,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39549
39550
|
outputs = [];
|
39550
39551
|
/** List of witnesses */
|
39551
39552
|
witnesses = [];
|
39552
|
-
/** Base asset ID - should be fetched from the chain */
|
39553
|
-
baseAssetId;
|
39554
39553
|
/**
|
39555
39554
|
* Constructor for initializing a base transaction request.
|
39556
39555
|
*
|
@@ -39563,9 +39562,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39563
39562
|
witnessLimit,
|
39564
39563
|
inputs,
|
39565
39564
|
outputs,
|
39566
|
-
witnesses
|
39567
|
-
|
39568
|
-
}) {
|
39565
|
+
witnesses
|
39566
|
+
} = {}) {
|
39569
39567
|
this.gasPrice = bn(gasPrice);
|
39570
39568
|
this.maturity = maturity ?? 0;
|
39571
39569
|
this.witnessLimit = witnessLimit ? bn(witnessLimit) : void 0;
|
@@ -39573,7 +39571,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39573
39571
|
this.inputs = inputs ?? [];
|
39574
39572
|
this.outputs = outputs ?? [];
|
39575
39573
|
this.witnesses = witnesses ?? [];
|
39576
|
-
this.baseAssetId = baseAssetId;
|
39577
39574
|
}
|
39578
39575
|
static getPolicyMeta(req) {
|
39579
39576
|
let policyTypes = 0;
|
@@ -39797,9 +39794,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39797
39794
|
*
|
39798
39795
|
* @param message - Message resource.
|
39799
39796
|
* @param predicate - Predicate bytes.
|
39797
|
+
* @param predicateData - Predicate data bytes.
|
39800
39798
|
*/
|
39801
39799
|
addMessageInput(message, predicate) {
|
39802
39800
|
const { recipient, sender, amount } = message;
|
39801
|
+
const assetId = BaseAssetId;
|
39803
39802
|
let witnessIndex;
|
39804
39803
|
if (predicate) {
|
39805
39804
|
witnessIndex = 0;
|
@@ -39819,7 +39818,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39819
39818
|
predicate: predicate?.bytes
|
39820
39819
|
};
|
39821
39820
|
this.pushInput(input);
|
39822
|
-
this.addChangeOutput(recipient,
|
39821
|
+
this.addChangeOutput(recipient, assetId);
|
39823
39822
|
}
|
39824
39823
|
/**
|
39825
39824
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -39880,12 +39879,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39880
39879
|
* @param amount - Amount of coin.
|
39881
39880
|
* @param assetId - Asset ID of coin.
|
39882
39881
|
*/
|
39883
|
-
addCoinOutput(to, amount, assetId) {
|
39882
|
+
addCoinOutput(to, amount, assetId = BaseAssetId) {
|
39884
39883
|
this.pushOutput({
|
39885
39884
|
type: OutputType.Coin,
|
39886
39885
|
to: addressify(to).toB256(),
|
39887
39886
|
amount,
|
39888
|
-
assetId
|
39887
|
+
assetId
|
39889
39888
|
});
|
39890
39889
|
return this;
|
39891
39890
|
}
|
@@ -39912,7 +39911,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39912
39911
|
* @param to - Address of the owner.
|
39913
39912
|
* @param assetId - Asset ID of coin.
|
39914
39913
|
*/
|
39915
|
-
addChangeOutput(to, assetId) {
|
39914
|
+
addChangeOutput(to, assetId = BaseAssetId) {
|
39916
39915
|
const changeOutput = this.getChangeOutputs().find(
|
39917
39916
|
(output3) => hexlify(output3.assetId) === assetId
|
39918
39917
|
);
|
@@ -39920,7 +39919,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39920
39919
|
this.pushOutput({
|
39921
39920
|
type: OutputType.Change,
|
39922
39921
|
to: addressify(to).toB256(),
|
39923
|
-
assetId
|
39922
|
+
assetId
|
39924
39923
|
});
|
39925
39924
|
}
|
39926
39925
|
}
|
@@ -39996,7 +39995,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39996
39995
|
]);
|
39997
39996
|
}
|
39998
39997
|
};
|
39999
|
-
updateAssetInput(
|
39998
|
+
updateAssetInput(BaseAssetId, bn(1e11));
|
40000
39999
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
40001
40000
|
}
|
40002
40001
|
/**
|
@@ -40153,7 +40152,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40153
40152
|
*
|
40154
40153
|
* @param createTransactionRequestLike - The initial values for the instance
|
40155
40154
|
*/
|
40156
|
-
constructor({
|
40155
|
+
constructor({
|
40156
|
+
bytecodeWitnessIndex,
|
40157
|
+
salt,
|
40158
|
+
storageSlots,
|
40159
|
+
...rest
|
40160
|
+
} = {}) {
|
40157
40161
|
super(rest);
|
40158
40162
|
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
40159
40163
|
this.salt = hexlify(salt ?? ZeroBytes32);
|
@@ -40268,7 +40272,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40268
40272
|
*
|
40269
40273
|
* @param scriptTransactionRequestLike - The initial values for the instance.
|
40270
40274
|
*/
|
40271
|
-
constructor({ script, scriptData, gasLimit, ...rest }) {
|
40275
|
+
constructor({ script, scriptData, gasLimit, ...rest } = {}) {
|
40272
40276
|
super(rest);
|
40273
40277
|
this.gasLimit = bn(gasLimit);
|
40274
40278
|
this.script = arrayify(script ?? returnZeroScript.bytes);
|
@@ -41414,7 +41418,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41414
41418
|
gasPerByte: bn(feeParams.gasPerByte),
|
41415
41419
|
maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
|
41416
41420
|
chainId: bn(consensusParameters.chainId),
|
41417
|
-
baseAssetId: consensusParameters.baseAssetId,
|
41418
41421
|
gasCosts
|
41419
41422
|
},
|
41420
41423
|
gasCosts,
|
@@ -41657,17 +41660,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41657
41660
|
} = this.getChain();
|
41658
41661
|
return chainId.toNumber();
|
41659
41662
|
}
|
41660
|
-
/**
|
41661
|
-
* Returns the base asset ID
|
41662
|
-
*
|
41663
|
-
* @returns A promise that resolves to the base asset ID
|
41664
|
-
*/
|
41665
|
-
getBaseAssetId() {
|
41666
|
-
const {
|
41667
|
-
consensusParameters: { baseAssetId }
|
41668
|
-
} = this.getChain();
|
41669
|
-
return baseAssetId;
|
41670
|
-
}
|
41671
41663
|
/**
|
41672
41664
|
* Submits a transaction to the chain to be executed.
|
41673
41665
|
*
|
@@ -42724,9 +42716,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42724
42716
|
* @param assetId - The asset ID to check the balance for.
|
42725
42717
|
* @returns A promise that resolves to the balance amount.
|
42726
42718
|
*/
|
42727
|
-
async getBalance(assetId) {
|
42728
|
-
const
|
42729
|
-
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
42719
|
+
async getBalance(assetId = BaseAssetId) {
|
42720
|
+
const amount = await this.provider.getBalance(this.address, assetId);
|
42730
42721
|
return amount;
|
42731
42722
|
}
|
42732
42723
|
/**
|
@@ -42764,10 +42755,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42764
42755
|
* @returns A promise that resolves when the resources are added to the transaction.
|
42765
42756
|
*/
|
42766
42757
|
async fund(request, coinQuantities, fee) {
|
42767
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
42768
42758
|
const updatedQuantities = addAmountToAsset({
|
42769
42759
|
amount: bn(fee),
|
42770
|
-
assetId:
|
42760
|
+
assetId: BaseAssetId,
|
42771
42761
|
coinQuantities
|
42772
42762
|
});
|
42773
42763
|
const quantitiesDict = {};
|
@@ -42791,8 +42781,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42791
42781
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
42792
42782
|
cachedUtxos.push(input.id);
|
42793
42783
|
}
|
42794
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[
|
42795
|
-
quantitiesDict[
|
42784
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId]) {
|
42785
|
+
quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
|
42796
42786
|
cachedMessages.push(input.nonce);
|
42797
42787
|
}
|
42798
42788
|
}
|
@@ -42824,13 +42814,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42824
42814
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
42825
42815
|
* @returns A promise that resolves to the prepared transaction request.
|
42826
42816
|
*/
|
42827
|
-
async createTransfer(destination, amount, assetId, txParams = {}) {
|
42817
|
+
async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
42828
42818
|
const { minGasPrice } = this.provider.getGasConfig();
|
42829
|
-
const
|
42830
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42831
|
-
const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
|
42819
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
42832
42820
|
const request = new ScriptTransactionRequest(params);
|
42833
|
-
request.addCoinOutput(Address.fromAddressOrString(destination), amount,
|
42821
|
+
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
|
42834
42822
|
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
42835
42823
|
estimateTxDependencies: true,
|
42836
42824
|
resourcesOwner: this
|
@@ -42856,15 +42844,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42856
42844
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
42857
42845
|
* @returns A promise that resolves to the transaction response.
|
42858
42846
|
*/
|
42859
|
-
async transfer(destination, amount, assetId, txParams = {}) {
|
42847
|
+
async transfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
42860
42848
|
if (bn(amount).lte(0)) {
|
42861
42849
|
throw new FuelError(
|
42862
42850
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
42863
42851
|
"Transfer amount must be a positive number."
|
42864
42852
|
);
|
42865
42853
|
}
|
42866
|
-
const
|
42867
|
-
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
42854
|
+
const request = await this.createTransfer(destination, amount, assetId, txParams);
|
42868
42855
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
42869
42856
|
}
|
42870
42857
|
/**
|
@@ -42876,7 +42863,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42876
42863
|
* @param txParams - The optional transaction parameters.
|
42877
42864
|
* @returns A promise that resolves to the transaction response.
|
42878
42865
|
*/
|
42879
|
-
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
42866
|
+
async transferToContract(contractId, amount, assetId = BaseAssetId, txParams = {}) {
|
42880
42867
|
if (bn(amount).lte(0)) {
|
42881
42868
|
throw new FuelError(
|
42882
42869
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -42885,13 +42872,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42885
42872
|
}
|
42886
42873
|
const contractAddress = Address.fromAddressOrString(contractId);
|
42887
42874
|
const { minGasPrice } = this.provider.getGasConfig();
|
42888
|
-
const
|
42889
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42890
|
-
const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
|
42875
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
42891
42876
|
const { script, scriptData } = await assembleTransferToContractScript({
|
42892
42877
|
hexlifiedContractId: contractAddress.toB256(),
|
42893
42878
|
amountToTransfer: bn(amount),
|
42894
|
-
assetId
|
42879
|
+
assetId
|
42895
42880
|
});
|
42896
42881
|
const request = new ScriptTransactionRequest({
|
42897
42882
|
...params,
|
@@ -42901,7 +42886,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42901
42886
|
request.addContractInputAndOutput(contractAddress);
|
42902
42887
|
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
42903
42888
|
request,
|
42904
|
-
[{ amount: bn(amount), assetId: String(
|
42889
|
+
[{ amount: bn(amount), assetId: String(assetId) }]
|
42905
42890
|
);
|
42906
42891
|
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
42907
42892
|
this.validateGas({
|
@@ -42923,7 +42908,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42923
42908
|
*/
|
42924
42909
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
42925
42910
|
const { minGasPrice } = this.provider.getGasConfig();
|
42926
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
42927
42911
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
42928
42912
|
const recipientDataArray = arrayify(
|
42929
42913
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -42936,14 +42920,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42936
42920
|
...recipientDataArray,
|
42937
42921
|
...amountDataArray
|
42938
42922
|
]);
|
42939
|
-
const params = {
|
42940
|
-
script,
|
42941
|
-
gasPrice: minGasPrice,
|
42942
|
-
baseAssetId,
|
42943
|
-
...txParams
|
42944
|
-
};
|
42923
|
+
const params = { script, gasPrice: minGasPrice, ...txParams };
|
42945
42924
|
const request = new ScriptTransactionRequest(params);
|
42946
|
-
const forwardingQuantities = [{ amount: bn(amount), assetId:
|
42925
|
+
const forwardingQuantities = [{ amount: bn(amount), assetId: BaseAssetId }];
|
42947
42926
|
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
42948
42927
|
request,
|
42949
42928
|
forwardingQuantities
|
@@ -47906,9 +47885,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47906
47885
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
47907
47886
|
* @returns A promise that resolves to the prepared transaction request.
|
47908
47887
|
*/
|
47909
|
-
async createTransfer(destination, amount, assetId, txParams = {}) {
|
47910
|
-
const
|
47911
|
-
const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
47888
|
+
async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
47889
|
+
const request = await super.createTransfer(destination, amount, assetId, txParams);
|
47912
47890
|
return this.populateTransactionPredicateData(request);
|
47913
47891
|
}
|
47914
47892
|
/**
|