@fuel-ts/account 0.0.0-rc-1976-20240417161625 → 0.0.0-rc-2037-20240417202046
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 +124 -100
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +280 -241
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +159 -126
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +11 -2
- 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/coin.d.ts +2 -1
- package/dist/providers/coin.d.ts.map +1 -1
- package/dist/providers/message.d.ts +1 -0
- package/dist/providers/message.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/helpers.d.ts +10 -0
- package/dist/providers/transaction-request/helpers.d.ts.map +1 -0
- package/dist/providers/transaction-request/index.d.ts +1 -0
- package/dist/providers/transaction-request/index.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 +6 -25
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/test-utils/index.d.ts +1 -0
- package/dist/test-utils/index.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils/resources.d.ts +4 -0
- package/dist/test-utils/resources.d.ts.map +1 -0
- package/dist/test-utils/seedTestWallet.d.ts +1 -1
- package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
- package/dist/test-utils/transactionRequest.d.ts +5 -0
- package/dist/test-utils/transactionRequest.d.ts.map +1 -0
- package/dist/test-utils.global.js +104 -105
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +253 -238
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +141 -129
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts +2 -2
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/package.json +15 -15
@@ -32486,8 +32486,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32486
32486
|
fee_params: {
|
32487
32487
|
gas_price_factor: 92,
|
32488
32488
|
gas_per_byte: 4
|
32489
|
-
}
|
32490
|
-
base_asset_id: "0x0000000000000000000000000000000000000000000000000000000000000000"
|
32489
|
+
}
|
32491
32490
|
},
|
32492
32491
|
gas_costs: {
|
32493
32492
|
add: 1,
|
@@ -34756,6 +34755,10 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34756
34755
|
}
|
34757
34756
|
};
|
34758
34757
|
|
34758
|
+
// ../address/dist/configs.mjs
|
34759
|
+
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
34760
|
+
var BaseAssetId = ZeroBytes32;
|
34761
|
+
|
34759
34762
|
// ../math/dist/index.mjs
|
34760
34763
|
var import_bn = __toESM(require_bn(), 1);
|
34761
34764
|
var DEFAULT_PRECISION = 9;
|
@@ -34986,11 +34989,11 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34986
34989
|
let max2;
|
34987
34990
|
if (Array.isArray(coinQuantityLike)) {
|
34988
34991
|
amount = coinQuantityLike[0];
|
34989
|
-
assetId = coinQuantityLike[1];
|
34990
|
-
max2 = coinQuantityLike[2];
|
34992
|
+
assetId = coinQuantityLike[1] ?? BaseAssetId;
|
34993
|
+
max2 = coinQuantityLike[2] ?? void 0;
|
34991
34994
|
} else {
|
34992
34995
|
amount = coinQuantityLike.amount;
|
34993
|
-
assetId = coinQuantityLike.assetId;
|
34996
|
+
assetId = coinQuantityLike.assetId ?? BaseAssetId;
|
34994
34997
|
max2 = coinQuantityLike.max ?? void 0;
|
34995
34998
|
}
|
34996
34999
|
const bnAmount = bn(amount);
|
@@ -42336,9 +42339,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42336
42339
|
}
|
42337
42340
|
};
|
42338
42341
|
|
42339
|
-
// ../address/dist/configs.mjs
|
42340
|
-
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
42341
|
-
|
42342
42342
|
// src/providers/transaction-request/input.ts
|
42343
42343
|
var inputify = (value) => {
|
42344
42344
|
const { type: type3 } = value;
|
@@ -42914,6 +42914,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42914
42914
|
name = "NoWitnessAtIndexError";
|
42915
42915
|
};
|
42916
42916
|
|
42917
|
+
// src/providers/transaction-request/helpers.ts
|
42918
|
+
var isRequestInputCoin = (input) => input.type === InputType.Coin;
|
42919
|
+
var isRequestInputMessage = (input) => input.type === InputType.Message;
|
42920
|
+
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
42921
|
+
|
42917
42922
|
// src/providers/transaction-request/witness.ts
|
42918
42923
|
var witnessify = (value) => {
|
42919
42924
|
const data = arrayify(value);
|
@@ -42939,8 +42944,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42939
42944
|
outputs = [];
|
42940
42945
|
/** List of witnesses */
|
42941
42946
|
witnesses = [];
|
42942
|
-
/** Base asset ID - should be fetched from the chain */
|
42943
|
-
baseAssetId;
|
42944
42947
|
/**
|
42945
42948
|
* Constructor for initializing a base transaction request.
|
42946
42949
|
*
|
@@ -42953,9 +42956,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42953
42956
|
witnessLimit,
|
42954
42957
|
inputs,
|
42955
42958
|
outputs,
|
42956
|
-
witnesses
|
42957
|
-
|
42958
|
-
}) {
|
42959
|
+
witnesses
|
42960
|
+
} = {}) {
|
42959
42961
|
this.gasPrice = bn(gasPrice);
|
42960
42962
|
this.maturity = maturity ?? 0;
|
42961
42963
|
this.witnessLimit = witnessLimit ? bn(witnessLimit) : void 0;
|
@@ -42963,7 +42965,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42963
42965
|
this.inputs = inputs ?? [];
|
42964
42966
|
this.outputs = outputs ?? [];
|
42965
42967
|
this.witnesses = witnesses ?? [];
|
42966
|
-
this.baseAssetId = baseAssetId;
|
42967
42968
|
}
|
42968
42969
|
static getPolicyMeta(req) {
|
42969
42970
|
let policyTypes = 0;
|
@@ -43157,8 +43158,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43157
43158
|
* @param predicate - Predicate bytes.
|
43158
43159
|
* @param predicateData - Predicate data bytes.
|
43159
43160
|
*/
|
43160
|
-
addCoinInput(coin
|
43161
|
-
const { assetId, owner, amount } = coin;
|
43161
|
+
addCoinInput(coin) {
|
43162
|
+
const { assetId, owner, amount, id, predicate } = coin;
|
43162
43163
|
let witnessIndex;
|
43163
43164
|
if (predicate) {
|
43164
43165
|
witnessIndex = 0;
|
@@ -43169,14 +43170,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43169
43170
|
}
|
43170
43171
|
}
|
43171
43172
|
const input = {
|
43172
|
-
|
43173
|
+
id,
|
43173
43174
|
type: InputType.Coin,
|
43174
43175
|
owner: owner.toB256(),
|
43175
43176
|
amount,
|
43176
43177
|
assetId,
|
43177
43178
|
txPointer: "0x00000000000000000000000000000000",
|
43178
43179
|
witnessIndex,
|
43179
|
-
predicate
|
43180
|
+
predicate
|
43180
43181
|
};
|
43181
43182
|
this.pushInput(input);
|
43182
43183
|
this.addChangeOutput(owner, assetId);
|
@@ -43187,9 +43188,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43187
43188
|
*
|
43188
43189
|
* @param message - Message resource.
|
43189
43190
|
* @param predicate - Predicate bytes.
|
43191
|
+
* @param predicateData - Predicate data bytes.
|
43190
43192
|
*/
|
43191
|
-
addMessageInput(message
|
43192
|
-
const { recipient, sender, amount } = message;
|
43193
|
+
addMessageInput(message) {
|
43194
|
+
const { recipient, sender, amount, predicate, nonce } = message;
|
43195
|
+
const assetId = BaseAssetId;
|
43193
43196
|
let witnessIndex;
|
43194
43197
|
if (predicate) {
|
43195
43198
|
witnessIndex = 0;
|
@@ -43200,16 +43203,16 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43200
43203
|
}
|
43201
43204
|
}
|
43202
43205
|
const input = {
|
43203
|
-
|
43206
|
+
nonce,
|
43204
43207
|
type: InputType.Message,
|
43205
43208
|
sender: sender.toB256(),
|
43206
43209
|
recipient: recipient.toB256(),
|
43207
43210
|
amount,
|
43208
43211
|
witnessIndex,
|
43209
|
-
predicate
|
43212
|
+
predicate
|
43210
43213
|
};
|
43211
43214
|
this.pushInput(input);
|
43212
|
-
this.addChangeOutput(recipient,
|
43215
|
+
this.addChangeOutput(recipient, assetId);
|
43213
43216
|
}
|
43214
43217
|
/**
|
43215
43218
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -43237,32 +43240,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43237
43240
|
resources.forEach((resource) => this.addResource(resource));
|
43238
43241
|
return this;
|
43239
43242
|
}
|
43240
|
-
/**
|
43241
|
-
* Adds multiple resources to the transaction by adding coin/message inputs and change
|
43242
|
-
* outputs from the related assetIds.
|
43243
|
-
*
|
43244
|
-
* @param resources - The resources to add.
|
43245
|
-
* @returns This transaction.
|
43246
|
-
*/
|
43247
|
-
addPredicateResource(resource, predicate) {
|
43248
|
-
if (isCoin(resource)) {
|
43249
|
-
this.addCoinInput(resource, predicate);
|
43250
|
-
} else {
|
43251
|
-
this.addMessageInput(resource, predicate);
|
43252
|
-
}
|
43253
|
-
return this;
|
43254
|
-
}
|
43255
|
-
/**
|
43256
|
-
* Adds multiple predicate coin/message inputs to the transaction and change outputs
|
43257
|
-
* from the related assetIds.
|
43258
|
-
*
|
43259
|
-
* @param resources - The resources to add.
|
43260
|
-
* @returns This transaction.
|
43261
|
-
*/
|
43262
|
-
addPredicateResources(resources, predicate) {
|
43263
|
-
resources.forEach((resource) => this.addPredicateResource(resource, predicate));
|
43264
|
-
return this;
|
43265
|
-
}
|
43266
43243
|
/**
|
43267
43244
|
* Adds a coin output to the transaction.
|
43268
43245
|
*
|
@@ -43270,12 +43247,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43270
43247
|
* @param amount - Amount of coin.
|
43271
43248
|
* @param assetId - Asset ID of coin.
|
43272
43249
|
*/
|
43273
|
-
addCoinOutput(to, amount, assetId) {
|
43250
|
+
addCoinOutput(to, amount, assetId = BaseAssetId) {
|
43274
43251
|
this.pushOutput({
|
43275
43252
|
type: OutputType.Coin,
|
43276
43253
|
to: addressify(to).toB256(),
|
43277
43254
|
amount,
|
43278
|
-
assetId
|
43255
|
+
assetId
|
43279
43256
|
});
|
43280
43257
|
return this;
|
43281
43258
|
}
|
@@ -43302,7 +43279,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43302
43279
|
* @param to - Address of the owner.
|
43303
43280
|
* @param assetId - Asset ID of coin.
|
43304
43281
|
*/
|
43305
|
-
addChangeOutput(to, assetId) {
|
43282
|
+
addChangeOutput(to, assetId = BaseAssetId) {
|
43306
43283
|
const changeOutput = this.getChangeOutputs().find(
|
43307
43284
|
(output3) => hexlify(output3.assetId) === assetId
|
43308
43285
|
);
|
@@ -43310,7 +43287,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43310
43287
|
this.pushOutput({
|
43311
43288
|
type: OutputType.Change,
|
43312
43289
|
to: addressify(to).toB256(),
|
43313
|
-
assetId
|
43290
|
+
assetId
|
43314
43291
|
});
|
43315
43292
|
}
|
43316
43293
|
}
|
@@ -43386,7 +43363,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43386
43363
|
]);
|
43387
43364
|
}
|
43388
43365
|
};
|
43389
|
-
updateAssetInput(
|
43366
|
+
updateAssetInput(BaseAssetId, bn(1e11));
|
43390
43367
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
43391
43368
|
}
|
43392
43369
|
/**
|
@@ -43411,6 +43388,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43411
43388
|
toJSON() {
|
43412
43389
|
return normalizeJSON(this);
|
43413
43390
|
}
|
43391
|
+
removeWitness(index) {
|
43392
|
+
this.witnesses.splice(index, 1);
|
43393
|
+
this.adjustWitnessIndexes(index);
|
43394
|
+
}
|
43414
43395
|
updatePredicateInputs(inputs) {
|
43415
43396
|
this.inputs.forEach((i) => {
|
43416
43397
|
let correspondingInput;
|
@@ -43433,6 +43414,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43433
43414
|
}
|
43434
43415
|
});
|
43435
43416
|
}
|
43417
|
+
adjustWitnessIndexes(removedIndex) {
|
43418
|
+
this.inputs.filter(isRequestInputResource).forEach((input) => {
|
43419
|
+
if (input.witnessIndex > removedIndex) {
|
43420
|
+
input.witnessIndex -= 1;
|
43421
|
+
}
|
43422
|
+
});
|
43423
|
+
}
|
43436
43424
|
};
|
43437
43425
|
|
43438
43426
|
// src/providers/transaction-request/hash-transaction.ts
|
@@ -43543,7 +43531,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43543
43531
|
*
|
43544
43532
|
* @param createTransactionRequestLike - The initial values for the instance
|
43545
43533
|
*/
|
43546
|
-
constructor({
|
43534
|
+
constructor({
|
43535
|
+
bytecodeWitnessIndex,
|
43536
|
+
salt,
|
43537
|
+
storageSlots,
|
43538
|
+
...rest
|
43539
|
+
} = {}) {
|
43547
43540
|
super(rest);
|
43548
43541
|
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
43549
43542
|
this.salt = hexlify(salt ?? ZeroBytes32);
|
@@ -43658,7 +43651,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43658
43651
|
*
|
43659
43652
|
* @param scriptTransactionRequestLike - The initial values for the instance.
|
43660
43653
|
*/
|
43661
|
-
constructor({ script, scriptData, gasLimit, ...rest }) {
|
43654
|
+
constructor({ script, scriptData, gasLimit, ...rest } = {}) {
|
43662
43655
|
super(rest);
|
43663
43656
|
this.gasLimit = bn(gasLimit);
|
43664
43657
|
this.script = arrayify(script ?? returnZeroScript.bytes);
|
@@ -44757,7 +44750,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44757
44750
|
gasPerByte: bn(feeParams.gasPerByte),
|
44758
44751
|
maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
|
44759
44752
|
chainId: bn(consensusParameters.chainId),
|
44760
|
-
baseAssetId: consensusParameters.baseAssetId,
|
44761
44753
|
gasCosts
|
44762
44754
|
},
|
44763
44755
|
gasCosts,
|
@@ -45000,17 +44992,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45000
44992
|
} = this.getChain();
|
45001
44993
|
return chainId.toNumber();
|
45002
44994
|
}
|
45003
|
-
/**
|
45004
|
-
* Returns the base asset ID
|
45005
|
-
*
|
45006
|
-
* @returns A promise that resolves to the base asset ID
|
45007
|
-
*/
|
45008
|
-
getBaseAssetId() {
|
45009
|
-
const {
|
45010
|
-
consensusParameters: { baseAssetId }
|
45011
|
-
} = this.getChain();
|
45012
|
-
return baseAssetId;
|
45013
|
-
}
|
45014
44995
|
/**
|
45015
44996
|
* Submits a transaction to the chain to be executed.
|
45016
44997
|
*
|
@@ -45899,9 +45880,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45899
45880
|
* @param assetId - The asset ID to check the balance for.
|
45900
45881
|
* @returns A promise that resolves to the balance amount.
|
45901
45882
|
*/
|
45902
|
-
async getBalance(assetId) {
|
45903
|
-
const
|
45904
|
-
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
45883
|
+
async getBalance(assetId = BaseAssetId) {
|
45884
|
+
const amount = await this.provider.getBalance(this.address, assetId);
|
45905
45885
|
return amount;
|
45906
45886
|
}
|
45907
45887
|
/**
|
@@ -45939,10 +45919,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45939
45919
|
* @returns A promise that resolves when the resources are added to the transaction.
|
45940
45920
|
*/
|
45941
45921
|
async fund(request, coinQuantities, fee) {
|
45942
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
45943
45922
|
const updatedQuantities = addAmountToAsset({
|
45944
45923
|
amount: bn(fee),
|
45945
|
-
assetId:
|
45924
|
+
assetId: BaseAssetId,
|
45946
45925
|
coinQuantities
|
45947
45926
|
});
|
45948
45927
|
const quantitiesDict = {};
|
@@ -45966,8 +45945,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45966
45945
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
45967
45946
|
cachedUtxos.push(input.id);
|
45968
45947
|
}
|
45969
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[
|
45970
|
-
quantitiesDict[
|
45948
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId]) {
|
45949
|
+
quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
|
45971
45950
|
cachedMessages.push(input.nonce);
|
45972
45951
|
}
|
45973
45952
|
}
|
@@ -45999,13 +45978,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45999
45978
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
46000
45979
|
* @returns A promise that resolves to the prepared transaction request.
|
46001
45980
|
*/
|
46002
|
-
async createTransfer(destination, amount, assetId, txParams = {}) {
|
45981
|
+
async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
46003
45982
|
const { minGasPrice } = this.provider.getGasConfig();
|
46004
|
-
const
|
46005
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
46006
|
-
const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
|
45983
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
46007
45984
|
const request = new ScriptTransactionRequest(params);
|
46008
|
-
request.addCoinOutput(Address.fromAddressOrString(destination), amount,
|
45985
|
+
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
|
46009
45986
|
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
46010
45987
|
estimateTxDependencies: true,
|
46011
45988
|
resourcesOwner: this
|
@@ -46031,15 +46008,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46031
46008
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
46032
46009
|
* @returns A promise that resolves to the transaction response.
|
46033
46010
|
*/
|
46034
|
-
async transfer(destination, amount, assetId, txParams = {}) {
|
46011
|
+
async transfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
46035
46012
|
if (bn(amount).lte(0)) {
|
46036
46013
|
throw new FuelError(
|
46037
46014
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
46038
46015
|
"Transfer amount must be a positive number."
|
46039
46016
|
);
|
46040
46017
|
}
|
46041
|
-
const
|
46042
|
-
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
46018
|
+
const request = await this.createTransfer(destination, amount, assetId, txParams);
|
46043
46019
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
46044
46020
|
}
|
46045
46021
|
/**
|
@@ -46051,7 +46027,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46051
46027
|
* @param txParams - The optional transaction parameters.
|
46052
46028
|
* @returns A promise that resolves to the transaction response.
|
46053
46029
|
*/
|
46054
|
-
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
46030
|
+
async transferToContract(contractId, amount, assetId = BaseAssetId, txParams = {}) {
|
46055
46031
|
if (bn(amount).lte(0)) {
|
46056
46032
|
throw new FuelError(
|
46057
46033
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -46060,13 +46036,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46060
46036
|
}
|
46061
46037
|
const contractAddress = Address.fromAddressOrString(contractId);
|
46062
46038
|
const { minGasPrice } = this.provider.getGasConfig();
|
46063
|
-
const
|
46064
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
46065
|
-
const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
|
46039
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
46066
46040
|
const { script, scriptData } = await assembleTransferToContractScript({
|
46067
46041
|
hexlifiedContractId: contractAddress.toB256(),
|
46068
46042
|
amountToTransfer: bn(amount),
|
46069
|
-
assetId
|
46043
|
+
assetId
|
46070
46044
|
});
|
46071
46045
|
const request = new ScriptTransactionRequest({
|
46072
46046
|
...params,
|
@@ -46076,7 +46050,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46076
46050
|
request.addContractInputAndOutput(contractAddress);
|
46077
46051
|
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
46078
46052
|
request,
|
46079
|
-
[{ amount: bn(amount), assetId: String(
|
46053
|
+
[{ amount: bn(amount), assetId: String(assetId) }]
|
46080
46054
|
);
|
46081
46055
|
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
46082
46056
|
this.validateGas({
|
@@ -46098,7 +46072,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46098
46072
|
*/
|
46099
46073
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
46100
46074
|
const { minGasPrice } = this.provider.getGasConfig();
|
46101
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
46102
46075
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
46103
46076
|
const recipientDataArray = arrayify(
|
46104
46077
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -46111,14 +46084,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46111
46084
|
...recipientDataArray,
|
46112
46085
|
...amountDataArray
|
46113
46086
|
]);
|
46114
|
-
const params = {
|
46115
|
-
script,
|
46116
|
-
gasPrice: minGasPrice,
|
46117
|
-
baseAssetId,
|
46118
|
-
...txParams
|
46119
|
-
};
|
46087
|
+
const params = { script, gasPrice: minGasPrice, ...txParams };
|
46120
46088
|
const request = new ScriptTransactionRequest(params);
|
46121
|
-
const forwardingQuantities = [{ amount: bn(amount), assetId:
|
46089
|
+
const forwardingQuantities = [{ amount: bn(amount), assetId: BaseAssetId }];
|
46122
46090
|
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
46123
46091
|
request,
|
46124
46092
|
forwardingQuantities
|
@@ -50543,21 +50511,26 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
50543
50511
|
__publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
|
50544
50512
|
|
50545
50513
|
// src/test-utils/seedTestWallet.ts
|
50546
|
-
var seedTestWallet = async (wallet, quantities) => {
|
50514
|
+
var seedTestWallet = async (wallet, quantities, utxosAmount = 1) => {
|
50515
|
+
const toFundAccounts = Array.isArray(wallet) ? wallet : [wallet];
|
50547
50516
|
const genesisWallet = new WalletUnlocked(
|
50548
50517
|
process.env.GENESIS_SECRET || randomBytes22(32),
|
50549
|
-
|
50518
|
+
toFundAccounts[0].provider
|
50550
50519
|
);
|
50551
50520
|
const resources = await genesisWallet.getResourcesToSpend(quantities);
|
50552
50521
|
const { minGasPrice } = genesisWallet.provider.getGasConfig();
|
50553
|
-
const baseAssetId = genesisWallet.provider.getBaseAssetId();
|
50554
50522
|
const request = new ScriptTransactionRequest({
|
50555
|
-
baseAssetId,
|
50556
50523
|
gasLimit: 1e4,
|
50557
50524
|
gasPrice: minGasPrice
|
50558
50525
|
});
|
50559
50526
|
request.addResources(resources);
|
50560
|
-
quantities.map(coinQuantityfy).forEach(
|
50527
|
+
quantities.map(coinQuantityfy).forEach(
|
50528
|
+
({ amount, assetId }) => toFundAccounts.forEach(({ address }) => {
|
50529
|
+
for (let i = 0; i < utxosAmount; i++) {
|
50530
|
+
request.addCoinOutput(address, amount.div(utxosAmount), assetId);
|
50531
|
+
}
|
50532
|
+
})
|
50533
|
+
);
|
50561
50534
|
await genesisWallet.sendTransaction(request, { awaitExecution: true });
|
50562
50535
|
};
|
50563
50536
|
|
@@ -50682,7 +50655,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
50682
50655
|
{
|
50683
50656
|
owner: signer.address.toHexString(),
|
50684
50657
|
amount: toHex(1e9),
|
50685
|
-
asset_id:
|
50658
|
+
asset_id: BaseAssetId
|
50686
50659
|
}
|
50687
50660
|
]
|
50688
50661
|
}
|
@@ -50748,10 +50721,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
50748
50721
|
})
|
50749
50722
|
);
|
50750
50723
|
var generateWallets = async (count, provider) => {
|
50751
|
-
const baseAssetId = provider.getBaseAssetId();
|
50752
50724
|
const wallets = [];
|
50753
50725
|
for (let i = 0; i < count; i += 1) {
|
50754
|
-
const wallet = await generateTestWallet(provider, [[1e3,
|
50726
|
+
const wallet = await generateTestWallet(provider, [[1e3, BaseAssetId]]);
|
50755
50727
|
wallets.push(wallet);
|
50756
50728
|
}
|
50757
50729
|
return wallets;
|
@@ -50768,6 +50740,33 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
50768
50740
|
};
|
50769
50741
|
return { wallets, stop: cleanup, provider };
|
50770
50742
|
};
|
50743
|
+
|
50744
|
+
// src/test-utils/transactionRequest.ts
|
50745
|
+
var generateFakeRequestInputCoin = (partial = {}) => ({
|
50746
|
+
id: hexlify(randomBytes22(UTXO_ID_LEN)),
|
50747
|
+
type: InputType.Coin,
|
50748
|
+
owner: getRandomB256(),
|
50749
|
+
amount: bn(100),
|
50750
|
+
assetId: ZeroBytes32,
|
50751
|
+
txPointer: "0x00000000000000000000000000000000",
|
50752
|
+
witnessIndex: 0,
|
50753
|
+
...partial
|
50754
|
+
});
|
50755
|
+
var generateFakeRequestInputMessage = (partial = {}) => ({
|
50756
|
+
nonce: getRandomB256(),
|
50757
|
+
type: InputType.Message,
|
50758
|
+
sender: getRandomB256(),
|
50759
|
+
recipient: getRandomB256(),
|
50760
|
+
amount: bn(100),
|
50761
|
+
witnessIndex: 0,
|
50762
|
+
...partial
|
50763
|
+
});
|
50764
|
+
var generateFakeRequestInputContract = (partial = {}) => ({
|
50765
|
+
contractId: getRandomB256(),
|
50766
|
+
type: InputType.Contract,
|
50767
|
+
txPointer: "0x00000000000000000000000000000000",
|
50768
|
+
...partial
|
50769
|
+
});
|
50771
50770
|
})();
|
50772
50771
|
/*! Bundled license information:
|
50773
50772
|
|