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