@fuel-ts/account 0.0.0-rc-1832-20240404073329 → 0.0.0-rc-1976-20240404073406
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 +77 -103
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +80 -62
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +49 -31
- 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 +7 -0
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +5 -2
- 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.global.js +79 -104
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +81 -62
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +50 -31
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +16 -16
@@ -32483,7 +32483,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32483
32483
|
fee_params: {
|
32484
32484
|
gas_price_factor: 92,
|
32485
32485
|
gas_per_byte: 4
|
32486
|
-
}
|
32486
|
+
},
|
32487
|
+
base_asset_id: "0x0000000000000000000000000000000000000000000000000000000000000000"
|
32487
32488
|
},
|
32488
32489
|
gas_costs: {
|
32489
32490
|
add: 1,
|
@@ -34752,10 +34753,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34752
34753
|
}
|
34753
34754
|
};
|
34754
34755
|
|
34755
|
-
// ../address/dist/configs.mjs
|
34756
|
-
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
34757
|
-
var BaseAssetId = ZeroBytes32;
|
34758
|
-
|
34759
34756
|
// ../math/dist/index.mjs
|
34760
34757
|
var import_bn = __toESM(require_bn(), 1);
|
34761
34758
|
var DEFAULT_PRECISION = 9;
|
@@ -34986,11 +34983,11 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34986
34983
|
let max2;
|
34987
34984
|
if (Array.isArray(coinQuantityLike)) {
|
34988
34985
|
amount = coinQuantityLike[0];
|
34989
|
-
assetId = coinQuantityLike[1]
|
34990
|
-
max2 = coinQuantityLike[2]
|
34986
|
+
assetId = coinQuantityLike[1];
|
34987
|
+
max2 = coinQuantityLike[2];
|
34991
34988
|
} else {
|
34992
34989
|
amount = coinQuantityLike.amount;
|
34993
|
-
assetId = coinQuantityLike.assetId
|
34990
|
+
assetId = coinQuantityLike.assetId;
|
34994
34991
|
max2 = coinQuantityLike.max ?? void 0;
|
34995
34992
|
}
|
34996
34993
|
const bnAmount = bn(amount);
|
@@ -35378,6 +35375,9 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
35378
35375
|
__privateAdd2(this, _getPaddedData);
|
35379
35376
|
}
|
35380
35377
|
encode(value) {
|
35378
|
+
if (!Array.isArray(value)) {
|
35379
|
+
throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
|
35380
|
+
}
|
35381
35381
|
const parts = [];
|
35382
35382
|
const pointer = new BigNumberCoder("u64").encode(BASE_VECTOR_OFFSET);
|
35383
35383
|
const data = __privateMethod2(this, _getPaddedData, getPaddedData_fn).call(this, value);
|
@@ -35404,7 +35404,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
35404
35404
|
};
|
35405
35405
|
_getPaddedData = /* @__PURE__ */ new WeakSet();
|
35406
35406
|
getPaddedData_fn = function(value) {
|
35407
|
-
const data =
|
35407
|
+
const data = [Uint8Array.from(value)];
|
35408
35408
|
const paddingLength = (WORD_SIZE - value.length % WORD_SIZE) % WORD_SIZE;
|
35409
35409
|
if (paddingLength) {
|
35410
35410
|
data.push(new Uint8Array(paddingLength));
|
@@ -35427,7 +35427,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
35427
35427
|
(max2, coder) => Math.max(max2, coder.encodedLength),
|
35428
35428
|
0
|
35429
35429
|
);
|
35430
|
-
super(
|
35430
|
+
super("enum", `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
|
35431
35431
|
this.name = name;
|
35432
35432
|
this.coders = coders;
|
35433
35433
|
this.#caseIndexCoder = caseIndexCoder;
|
@@ -35497,7 +35497,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
35497
35497
|
return { None: [] };
|
35498
35498
|
}
|
35499
35499
|
decode(data, offset) {
|
35500
|
-
if (data.length < this.encodedLength) {
|
35500
|
+
if (data.length < this.encodedLength - 1) {
|
35501
35501
|
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid option data size.`);
|
35502
35502
|
}
|
35503
35503
|
const [decoded, newOffset] = super.decode(data, offset);
|
@@ -36080,8 +36080,11 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36080
36080
|
super("struct", "struct Bytes", WORD_SIZE);
|
36081
36081
|
}
|
36082
36082
|
encode(value) {
|
36083
|
-
|
36084
|
-
|
36083
|
+
if (!Array.isArray(value)) {
|
36084
|
+
throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
|
36085
|
+
}
|
36086
|
+
const bytes3 = new Uint8Array(value);
|
36087
|
+
const lengthBytes = new BigNumberCoder("u64").encode(value.length);
|
36085
36088
|
return new Uint8Array([...lengthBytes, ...bytes3]);
|
36086
36089
|
}
|
36087
36090
|
decode(data, offset) {
|
@@ -36114,7 +36117,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36114
36117
|
(max2, coder) => Math.max(max2, coder.encodedLength),
|
36115
36118
|
0
|
36116
36119
|
);
|
36117
|
-
super(
|
36120
|
+
super("enum", `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
|
36118
36121
|
this.name = name;
|
36119
36122
|
this.coders = coders;
|
36120
36123
|
this.#caseIndexCoder = caseIndexCoder;
|
@@ -36212,28 +36215,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36212
36215
|
return [toNumber2(bytes3), offset + this.length];
|
36213
36216
|
}
|
36214
36217
|
};
|
36215
|
-
var OptionCoder2 = class extends EnumCoder2 {
|
36216
|
-
encode(value) {
|
36217
|
-
const result = super.encode(this.toSwayOption(value));
|
36218
|
-
return result;
|
36219
|
-
}
|
36220
|
-
toSwayOption(input) {
|
36221
|
-
if (input !== void 0) {
|
36222
|
-
return { Some: input };
|
36223
|
-
}
|
36224
|
-
return { None: [] };
|
36225
|
-
}
|
36226
|
-
decode(data, offset) {
|
36227
|
-
const [decoded, newOffset] = super.decode(data, offset);
|
36228
|
-
return [this.toOption(decoded), newOffset];
|
36229
|
-
}
|
36230
|
-
toOption(output3) {
|
36231
|
-
if (output3 && "Some" in output3) {
|
36232
|
-
return output3.Some;
|
36233
|
-
}
|
36234
|
-
return void 0;
|
36235
|
-
}
|
36236
|
-
};
|
36237
36218
|
var RawSliceCoder2 = class extends Coder {
|
36238
36219
|
constructor() {
|
36239
36220
|
super("raw untyped slice", "raw untyped slice", WORD_SIZE);
|
@@ -36287,30 +36268,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36287
36268
|
}
|
36288
36269
|
};
|
36289
36270
|
__publicField4(StdStringCoder2, "memorySize", 1);
|
36290
|
-
var StrSliceCoder = class extends Coder {
|
36291
|
-
constructor() {
|
36292
|
-
super("strSlice", "str", WORD_SIZE);
|
36293
|
-
}
|
36294
|
-
encode(value) {
|
36295
|
-
const bytes3 = toUtf8Bytes(value);
|
36296
|
-
const lengthBytes = new BigNumberCoder("u64").encode(value.length);
|
36297
|
-
return new Uint8Array([...lengthBytes, ...bytes3]);
|
36298
|
-
}
|
36299
|
-
decode(data, offset) {
|
36300
|
-
if (data.length < this.encodedLength) {
|
36301
|
-
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string slice data size.`);
|
36302
|
-
}
|
36303
|
-
const offsetAndLength = offset + WORD_SIZE;
|
36304
|
-
const lengthBytes = data.slice(offset, offsetAndLength);
|
36305
|
-
const length = bn(new BigNumberCoder("u64").decode(lengthBytes, 0)[0]).toNumber();
|
36306
|
-
const bytes3 = data.slice(offsetAndLength, offsetAndLength + length);
|
36307
|
-
if (bytes3.length !== length) {
|
36308
|
-
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string slice byte data size.`);
|
36309
|
-
}
|
36310
|
-
return [toUtf8String(bytes3), offsetAndLength + length];
|
36311
|
-
}
|
36312
|
-
};
|
36313
|
-
__publicField4(StrSliceCoder, "memorySize", 1);
|
36314
36271
|
var StringCoder2 = class extends Coder {
|
36315
36272
|
constructor(length) {
|
36316
36273
|
super("string", `str[${length}]`, length);
|
@@ -36349,7 +36306,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36349
36306
|
Object.keys(this.coders).map((fieldName) => {
|
36350
36307
|
const fieldCoder = this.coders[fieldName];
|
36351
36308
|
const fieldValue = value[fieldName];
|
36352
|
-
if (!(fieldCoder instanceof
|
36309
|
+
if (!(fieldCoder instanceof OptionCoder) && fieldValue == null) {
|
36353
36310
|
throw new FuelError(
|
36354
36311
|
ErrorCode.ENCODE_ERROR,
|
36355
36312
|
`Invalid ${this.type}. Field "${fieldName}" not present.`
|
@@ -36457,8 +36414,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36457
36414
|
return new ByteCoder2();
|
36458
36415
|
case STD_STRING_CODER_TYPE:
|
36459
36416
|
return new StdStringCoder2();
|
36460
|
-
case STR_SLICE_CODER_TYPE:
|
36461
|
-
return new StrSliceCoder();
|
36462
36417
|
default:
|
36463
36418
|
break;
|
36464
36419
|
}
|
@@ -36503,7 +36458,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36503
36458
|
const coders = getCoders(components, { getCoder: getCoder2 });
|
36504
36459
|
const isOptionEnum = resolvedAbiType.type === OPTION_CODER_TYPE;
|
36505
36460
|
if (isOptionEnum) {
|
36506
|
-
return new
|
36461
|
+
return new OptionCoder(enumMatch.name, coders);
|
36507
36462
|
}
|
36508
36463
|
return new EnumCoder2(enumMatch.name, coders);
|
36509
36464
|
}
|
@@ -36514,6 +36469,12 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36514
36469
|
);
|
36515
36470
|
return new TupleCoder2(coders);
|
36516
36471
|
}
|
36472
|
+
if (resolvedAbiType.type === STR_SLICE_CODER_TYPE) {
|
36473
|
+
throw new FuelError(
|
36474
|
+
ErrorCode.INVALID_DATA,
|
36475
|
+
"String slices can not be decoded from logs. Convert the slice to `str[N]` with `__to_str_array`"
|
36476
|
+
);
|
36477
|
+
}
|
36517
36478
|
throw new FuelError(
|
36518
36479
|
ErrorCode.CODER_NOT_FOUND,
|
36519
36480
|
`Coder not found: ${JSON.stringify(resolvedAbiType)}.`
|
@@ -36549,8 +36510,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36549
36510
|
var FunctionFragment = class {
|
36550
36511
|
signature;
|
36551
36512
|
selector;
|
36552
|
-
selectorBytes;
|
36553
|
-
encoding;
|
36554
36513
|
name;
|
36555
36514
|
jsonFn;
|
36556
36515
|
attributes;
|
@@ -36563,8 +36522,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36563
36522
|
this.name = name;
|
36564
36523
|
this.signature = FunctionFragment.getSignature(this.jsonAbi, this.jsonFn);
|
36565
36524
|
this.selector = FunctionFragment.getFunctionSelector(this.signature);
|
36566
|
-
this.selectorBytes = new StdStringCoder2().encode(name);
|
36567
|
-
this.encoding = this.jsonAbi.encoding ?? ENCODING_V0;
|
36568
36525
|
this.isInputDataPointer = this.#isInputDataPointer();
|
36569
36526
|
this.outputMetadata = {
|
36570
36527
|
isHeapType: this.#isOutputDataHeap(),
|
@@ -36618,14 +36575,11 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36618
36575
|
}
|
36619
36576
|
const coders = nonEmptyInputs.map(
|
36620
36577
|
(t) => AbiCoder.getCoder(this.jsonAbi, t, {
|
36621
|
-
isRightPadded: nonEmptyInputs.length > 1
|
36622
|
-
encoding: this.encoding
|
36578
|
+
isRightPadded: nonEmptyInputs.length > 1
|
36623
36579
|
})
|
36624
36580
|
);
|
36625
|
-
|
36626
|
-
|
36627
|
-
}
|
36628
|
-
const results = new TupleCoder(coders).encode(shallowCopyValues);
|
36581
|
+
const coder = new TupleCoder(coders);
|
36582
|
+
const results = coder.encode(shallowCopyValues);
|
36629
36583
|
return unpackDynamicData(results, offset, results.byteLength);
|
36630
36584
|
}
|
36631
36585
|
static verifyArgsAndInputsAlign(args, inputs, abi) {
|
@@ -36672,7 +36626,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36672
36626
|
}
|
36673
36627
|
const result = nonEmptyInputs.reduce(
|
36674
36628
|
(obj, input) => {
|
36675
|
-
const coder = AbiCoder.getCoder(this.jsonAbi, input
|
36629
|
+
const coder = AbiCoder.getCoder(this.jsonAbi, input);
|
36676
36630
|
const [decodedValue, decodedValueByteSize] = coder.decode(bytes3, obj.offset);
|
36677
36631
|
return {
|
36678
36632
|
decoded: [...obj.decoded, decodedValue],
|
@@ -36692,9 +36646,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36692
36646
|
return [void 0, 0];
|
36693
36647
|
}
|
36694
36648
|
const bytes3 = arrayify(data);
|
36695
|
-
const coder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output
|
36696
|
-
encoding: this.encoding
|
36697
|
-
});
|
36649
|
+
const coder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output);
|
36698
36650
|
return coder.decode(bytes3, 0);
|
36699
36651
|
}
|
36700
36652
|
};
|
@@ -36756,8 +36708,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36756
36708
|
}
|
36757
36709
|
);
|
36758
36710
|
return AbiCoder.encode(this.jsonAbi, configurable.configurableType, value, {
|
36759
|
-
isRightPadded: true
|
36760
|
-
encoding: this.jsonAbi.encoding
|
36711
|
+
isRightPadded: true
|
36761
36712
|
});
|
36762
36713
|
}
|
36763
36714
|
getTypeById(typeId) {
|
@@ -42328,6 +42279,9 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42328
42279
|
}
|
42329
42280
|
};
|
42330
42281
|
|
42282
|
+
// ../address/dist/configs.mjs
|
42283
|
+
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
42284
|
+
|
42331
42285
|
// src/providers/transaction-request/input.ts
|
42332
42286
|
var inputify = (value) => {
|
42333
42287
|
const { type: type3 } = value;
|
@@ -42807,6 +42761,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42807
42761
|
outputs = [];
|
42808
42762
|
/** List of witnesses */
|
42809
42763
|
witnesses = [];
|
42764
|
+
/** Base asset ID - should be fetched from the chain */
|
42765
|
+
baseAssetId = ZeroBytes32;
|
42810
42766
|
/**
|
42811
42767
|
* Constructor for initializing a base transaction request.
|
42812
42768
|
*
|
@@ -42819,7 +42775,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42819
42775
|
witnessLimit,
|
42820
42776
|
inputs,
|
42821
42777
|
outputs,
|
42822
|
-
witnesses
|
42778
|
+
witnesses,
|
42779
|
+
baseAssetId
|
42823
42780
|
} = {}) {
|
42824
42781
|
this.gasPrice = bn(gasPrice);
|
42825
42782
|
this.maturity = maturity ?? 0;
|
@@ -42828,6 +42785,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42828
42785
|
this.inputs = inputs ?? [];
|
42829
42786
|
this.outputs = outputs ?? [];
|
42830
42787
|
this.witnesses = witnesses ?? [];
|
42788
|
+
this.baseAssetId = baseAssetId ?? ZeroBytes32;
|
42831
42789
|
}
|
42832
42790
|
static getPolicyMeta(req) {
|
42833
42791
|
let policyTypes = 0;
|
@@ -43052,11 +43010,9 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43052
43010
|
*
|
43053
43011
|
* @param message - Message resource.
|
43054
43012
|
* @param predicate - Predicate bytes.
|
43055
|
-
* @param predicateData - Predicate data bytes.
|
43056
43013
|
*/
|
43057
43014
|
addMessageInput(message, predicate) {
|
43058
43015
|
const { recipient, sender, amount } = message;
|
43059
|
-
const assetId = BaseAssetId;
|
43060
43016
|
let witnessIndex;
|
43061
43017
|
if (predicate) {
|
43062
43018
|
witnessIndex = 0;
|
@@ -43077,7 +43033,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43077
43033
|
predicateData: predicate?.predicateDataBytes
|
43078
43034
|
};
|
43079
43035
|
this.pushInput(input);
|
43080
|
-
this.addChangeOutput(recipient,
|
43036
|
+
this.addChangeOutput(recipient, this.baseAssetId);
|
43081
43037
|
}
|
43082
43038
|
/**
|
43083
43039
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -43138,12 +43094,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43138
43094
|
* @param amount - Amount of coin.
|
43139
43095
|
* @param assetId - Asset ID of coin.
|
43140
43096
|
*/
|
43141
|
-
addCoinOutput(to, amount, assetId
|
43097
|
+
addCoinOutput(to, amount, assetId) {
|
43142
43098
|
this.pushOutput({
|
43143
43099
|
type: OutputType.Coin,
|
43144
43100
|
to: addressify(to).toB256(),
|
43145
43101
|
amount,
|
43146
|
-
assetId
|
43102
|
+
assetId: assetId ?? this.baseAssetId
|
43147
43103
|
});
|
43148
43104
|
return this;
|
43149
43105
|
}
|
@@ -43170,7 +43126,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43170
43126
|
* @param to - Address of the owner.
|
43171
43127
|
* @param assetId - Asset ID of coin.
|
43172
43128
|
*/
|
43173
|
-
addChangeOutput(to, assetId
|
43129
|
+
addChangeOutput(to, assetId) {
|
43174
43130
|
const changeOutput = this.getChangeOutputs().find(
|
43175
43131
|
(output3) => hexlify(output3.assetId) === assetId
|
43176
43132
|
);
|
@@ -43178,7 +43134,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43178
43134
|
this.pushOutput({
|
43179
43135
|
type: OutputType.Change,
|
43180
43136
|
to: addressify(to).toB256(),
|
43181
|
-
assetId
|
43137
|
+
assetId: assetId ?? this.baseAssetId
|
43182
43138
|
});
|
43183
43139
|
}
|
43184
43140
|
}
|
@@ -43260,7 +43216,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43260
43216
|
]);
|
43261
43217
|
}
|
43262
43218
|
};
|
43263
|
-
updateAssetInput(
|
43219
|
+
updateAssetInput(this.baseAssetId, bn(1e11));
|
43264
43220
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
43265
43221
|
}
|
43266
43222
|
/**
|
@@ -44631,6 +44587,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44631
44587
|
gasPerByte: bn(feeParams.gasPerByte),
|
44632
44588
|
maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
|
44633
44589
|
chainId: bn(consensusParameters.chainId),
|
44590
|
+
baseAssetId: consensusParameters.baseAssetId,
|
44634
44591
|
gasCosts
|
44635
44592
|
},
|
44636
44593
|
gasCosts,
|
@@ -44873,6 +44830,17 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44873
44830
|
} = this.getChain();
|
44874
44831
|
return chainId.toNumber();
|
44875
44832
|
}
|
44833
|
+
/**
|
44834
|
+
* Returns the base asset ID
|
44835
|
+
*
|
44836
|
+
* @returns A promise that resolves to the base asset ID
|
44837
|
+
*/
|
44838
|
+
getBaseAssetId() {
|
44839
|
+
const {
|
44840
|
+
consensusParameters: { baseAssetId }
|
44841
|
+
} = this.getChain();
|
44842
|
+
return baseAssetId;
|
44843
|
+
}
|
44876
44844
|
/**
|
44877
44845
|
* Submits a transaction to the chain to be executed.
|
44878
44846
|
*
|
@@ -45734,8 +45702,9 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45734
45702
|
* @param assetId - The asset ID to check the balance for.
|
45735
45703
|
* @returns A promise that resolves to the balance amount.
|
45736
45704
|
*/
|
45737
|
-
async getBalance(assetId
|
45738
|
-
const
|
45705
|
+
async getBalance(assetId) {
|
45706
|
+
const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
|
45707
|
+
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
45739
45708
|
return amount;
|
45740
45709
|
}
|
45741
45710
|
/**
|
@@ -45773,9 +45742,10 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45773
45742
|
* @returns A promise that resolves when the resources are added to the transaction.
|
45774
45743
|
*/
|
45775
45744
|
async fund(request, coinQuantities, fee) {
|
45745
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
45776
45746
|
const updatedQuantities = addAmountToAsset({
|
45777
45747
|
amount: bn(fee),
|
45778
|
-
assetId:
|
45748
|
+
assetId: baseAssetId,
|
45779
45749
|
coinQuantities
|
45780
45750
|
});
|
45781
45751
|
const quantitiesDict = {};
|
@@ -45799,8 +45769,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45799
45769
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
45800
45770
|
cachedUtxos.push(input.id);
|
45801
45771
|
}
|
45802
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[
|
45803
|
-
quantitiesDict[
|
45772
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
|
45773
|
+
quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
|
45804
45774
|
cachedMessages.push(input.nonce);
|
45805
45775
|
}
|
45806
45776
|
}
|
@@ -45832,11 +45802,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45832
45802
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
45833
45803
|
* @returns A promise that resolves to the prepared transaction request.
|
45834
45804
|
*/
|
45835
|
-
async createTransfer(destination, amount, assetId
|
45805
|
+
async createTransfer(destination, amount, assetId, txParams = {}) {
|
45836
45806
|
const { minGasPrice } = this.provider.getGasConfig();
|
45807
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
45837
45808
|
const params = { gasPrice: minGasPrice, ...txParams };
|
45838
45809
|
const request = new ScriptTransactionRequest(params);
|
45839
|
-
request.addCoinOutput(Address.fromAddressOrString(destination), amount,
|
45810
|
+
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetIdToTransfer);
|
45840
45811
|
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
45841
45812
|
estimateTxDependencies: true,
|
45842
45813
|
resourcesOwner: this
|
@@ -45862,14 +45833,15 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45862
45833
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
45863
45834
|
* @returns A promise that resolves to the transaction response.
|
45864
45835
|
*/
|
45865
|
-
async transfer(destination, amount, assetId
|
45836
|
+
async transfer(destination, amount, assetId, txParams = {}) {
|
45866
45837
|
if (bn(amount).lte(0)) {
|
45867
45838
|
throw new FuelError(
|
45868
45839
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
45869
45840
|
"Transfer amount must be a positive number."
|
45870
45841
|
);
|
45871
45842
|
}
|
45872
|
-
const
|
45843
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
45844
|
+
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
45873
45845
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
45874
45846
|
}
|
45875
45847
|
/**
|
@@ -45881,7 +45853,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45881
45853
|
* @param txParams - The optional transaction parameters.
|
45882
45854
|
* @returns A promise that resolves to the transaction response.
|
45883
45855
|
*/
|
45884
|
-
async transferToContract(contractId, amount, assetId
|
45856
|
+
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
45885
45857
|
if (bn(amount).lte(0)) {
|
45886
45858
|
throw new FuelError(
|
45887
45859
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -45890,11 +45862,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45890
45862
|
}
|
45891
45863
|
const contractAddress = Address.fromAddressOrString(contractId);
|
45892
45864
|
const { minGasPrice } = this.provider.getGasConfig();
|
45865
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
45893
45866
|
const params = { gasPrice: minGasPrice, ...txParams };
|
45894
45867
|
const { script, scriptData } = await assembleTransferToContractScript({
|
45895
45868
|
hexlifiedContractId: contractAddress.toB256(),
|
45896
45869
|
amountToTransfer: bn(amount),
|
45897
|
-
assetId
|
45870
|
+
assetId: assetIdToTransfer
|
45898
45871
|
});
|
45899
45872
|
const request = new ScriptTransactionRequest({
|
45900
45873
|
...params,
|
@@ -45904,7 +45877,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45904
45877
|
request.addContractInputAndOutput(contractAddress);
|
45905
45878
|
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
45906
45879
|
request,
|
45907
|
-
[{ amount: bn(amount), assetId: String(
|
45880
|
+
[{ amount: bn(amount), assetId: String(assetIdToTransfer) }]
|
45908
45881
|
);
|
45909
45882
|
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
45910
45883
|
this.validateGas({
|
@@ -45926,6 +45899,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45926
45899
|
*/
|
45927
45900
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
45928
45901
|
const { minGasPrice } = this.provider.getGasConfig();
|
45902
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
45929
45903
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
45930
45904
|
const recipientDataArray = arrayify(
|
45931
45905
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -45940,7 +45914,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45940
45914
|
]);
|
45941
45915
|
const params = { script, gasPrice: minGasPrice, ...txParams };
|
45942
45916
|
const request = new ScriptTransactionRequest(params);
|
45943
|
-
const forwardingQuantities = [{ amount: bn(amount), assetId:
|
45917
|
+
const forwardingQuantities = [{ amount: bn(amount), assetId: baseAssetId }];
|
45944
45918
|
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
45945
45919
|
request,
|
45946
45920
|
forwardingQuantities
|
@@ -50502,7 +50476,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
50502
50476
|
{
|
50503
50477
|
owner: signer.address.toHexString(),
|
50504
50478
|
amount: toHex(1e9),
|
50505
|
-
asset_id:
|
50479
|
+
asset_id: defaultChainConfig?.consensus_parameters?.base_asset_id ?? ZeroBytes32
|
50506
50480
|
}
|
50507
50481
|
]
|
50508
50482
|
}
|
@@ -50568,9 +50542,10 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
50568
50542
|
})
|
50569
50543
|
);
|
50570
50544
|
var generateWallets = async (count, provider) => {
|
50545
|
+
const baseAssetId = provider.getBaseAssetId();
|
50571
50546
|
const wallets = [];
|
50572
50547
|
for (let i = 0; i < count; i += 1) {
|
50573
|
-
const wallet = await generateTestWallet(provider, [[1e3,
|
50548
|
+
const wallet = await generateTestWallet(provider, [[1e3, baseAssetId]]);
|
50574
50549
|
wallets.push(wallet);
|
50575
50550
|
}
|
50576
50551
|
return wallets;
|