@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
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,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AAItD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EACV,sBAAsB,EACtB,UAAU,EACV,kBAAk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AAsB,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
@@ -31269,6 +31269,10 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31269
31269
|
}
|
31270
31270
|
};
|
31271
31271
|
|
31272
|
+
// ../address/dist/configs.mjs
|
31273
|
+
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
31274
|
+
var BaseAssetId = ZeroBytes32;
|
31275
|
+
|
31272
31276
|
// ../math/dist/index.mjs
|
31273
31277
|
var import_bn = __toESM(require_bn(), 1);
|
31274
31278
|
var DEFAULT_PRECISION = 9;
|
@@ -31499,11 +31503,11 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31499
31503
|
let max2;
|
31500
31504
|
if (Array.isArray(coinQuantityLike)) {
|
31501
31505
|
amount = coinQuantityLike[0];
|
31502
|
-
assetId = coinQuantityLike[1];
|
31503
|
-
max2 = coinQuantityLike[2];
|
31506
|
+
assetId = coinQuantityLike[1] ?? BaseAssetId;
|
31507
|
+
max2 = coinQuantityLike[2] ?? void 0;
|
31504
31508
|
} else {
|
31505
31509
|
amount = coinQuantityLike.amount;
|
31506
|
-
assetId = coinQuantityLike.assetId;
|
31510
|
+
assetId = coinQuantityLike.assetId ?? BaseAssetId;
|
31507
31511
|
max2 = coinQuantityLike.max ?? void 0;
|
31508
31512
|
}
|
31509
31513
|
const bnAmount = bn(amount);
|
@@ -31909,9 +31913,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31909
31913
|
__privateAdd2(this, _getPaddedData);
|
31910
31914
|
}
|
31911
31915
|
encode(value) {
|
31912
|
-
if (!Array.isArray(value)) {
|
31913
|
-
throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
|
31914
|
-
}
|
31915
31916
|
const parts = [];
|
31916
31917
|
const pointer = new BigNumberCoder("u64").encode(BASE_VECTOR_OFFSET);
|
31917
31918
|
const data = __privateMethod2(this, _getPaddedData, getPaddedData_fn).call(this, value);
|
@@ -31938,7 +31939,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31938
31939
|
};
|
31939
31940
|
_getPaddedData = /* @__PURE__ */ new WeakSet();
|
31940
31941
|
getPaddedData_fn = function(value) {
|
31941
|
-
const data = [Uint8Array
|
31942
|
+
const data = value instanceof Uint8Array ? [value] : [new Uint8Array(value)];
|
31942
31943
|
const paddingLength = (WORD_SIZE - value.length % WORD_SIZE) % WORD_SIZE;
|
31943
31944
|
if (paddingLength) {
|
31944
31945
|
data.push(new Uint8Array(paddingLength));
|
@@ -31961,7 +31962,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31961
31962
|
(max2, coder) => Math.max(max2, coder.encodedLength),
|
31962
31963
|
0
|
31963
31964
|
);
|
31964
|
-
super(
|
31965
|
+
super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
|
31965
31966
|
this.name = name;
|
31966
31967
|
this.coders = coders;
|
31967
31968
|
this.#caseIndexCoder = caseIndexCoder;
|
@@ -32031,7 +32032,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32031
32032
|
return { None: [] };
|
32032
32033
|
}
|
32033
32034
|
decode(data, offset) {
|
32034
|
-
if (data.length < this.encodedLength
|
32035
|
+
if (data.length < this.encodedLength) {
|
32035
32036
|
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid option data size.`);
|
32036
32037
|
}
|
32037
32038
|
const [decoded, newOffset] = super.decode(data, offset);
|
@@ -32614,11 +32615,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32614
32615
|
super("struct", "struct Bytes", WORD_SIZE);
|
32615
32616
|
}
|
32616
32617
|
encode(value) {
|
32617
|
-
|
32618
|
-
|
32619
|
-
}
|
32620
|
-
const bytes3 = new Uint8Array(value);
|
32621
|
-
const lengthBytes = new BigNumberCoder("u64").encode(value.length);
|
32618
|
+
const bytes3 = value instanceof Uint8Array ? value : new Uint8Array(value);
|
32619
|
+
const lengthBytes = new BigNumberCoder("u64").encode(bytes3.length);
|
32622
32620
|
return new Uint8Array([...lengthBytes, ...bytes3]);
|
32623
32621
|
}
|
32624
32622
|
decode(data, offset) {
|
@@ -32651,7 +32649,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32651
32649
|
(max2, coder) => Math.max(max2, coder.encodedLength),
|
32652
32650
|
0
|
32653
32651
|
);
|
32654
|
-
super(
|
32652
|
+
super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
|
32655
32653
|
this.name = name;
|
32656
32654
|
this.coders = coders;
|
32657
32655
|
this.#caseIndexCoder = caseIndexCoder;
|
@@ -32749,6 +32747,28 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32749
32747
|
return [toNumber2(bytes3), offset + this.length];
|
32750
32748
|
}
|
32751
32749
|
};
|
32750
|
+
var OptionCoder2 = class extends EnumCoder2 {
|
32751
|
+
encode(value) {
|
32752
|
+
const result = super.encode(this.toSwayOption(value));
|
32753
|
+
return result;
|
32754
|
+
}
|
32755
|
+
toSwayOption(input) {
|
32756
|
+
if (input !== void 0) {
|
32757
|
+
return { Some: input };
|
32758
|
+
}
|
32759
|
+
return { None: [] };
|
32760
|
+
}
|
32761
|
+
decode(data, offset) {
|
32762
|
+
const [decoded, newOffset] = super.decode(data, offset);
|
32763
|
+
return [this.toOption(decoded), newOffset];
|
32764
|
+
}
|
32765
|
+
toOption(output3) {
|
32766
|
+
if (output3 && "Some" in output3) {
|
32767
|
+
return output3.Some;
|
32768
|
+
}
|
32769
|
+
return void 0;
|
32770
|
+
}
|
32771
|
+
};
|
32752
32772
|
var RawSliceCoder2 = class extends Coder {
|
32753
32773
|
constructor() {
|
32754
32774
|
super("raw untyped slice", "raw untyped slice", WORD_SIZE);
|
@@ -32802,6 +32822,30 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32802
32822
|
}
|
32803
32823
|
};
|
32804
32824
|
__publicField4(StdStringCoder2, "memorySize", 1);
|
32825
|
+
var StrSliceCoder = class extends Coder {
|
32826
|
+
constructor() {
|
32827
|
+
super("strSlice", "str", WORD_SIZE);
|
32828
|
+
}
|
32829
|
+
encode(value) {
|
32830
|
+
const bytes3 = toUtf8Bytes(value);
|
32831
|
+
const lengthBytes = new BigNumberCoder("u64").encode(value.length);
|
32832
|
+
return new Uint8Array([...lengthBytes, ...bytes3]);
|
32833
|
+
}
|
32834
|
+
decode(data, offset) {
|
32835
|
+
if (data.length < this.encodedLength) {
|
32836
|
+
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string slice data size.`);
|
32837
|
+
}
|
32838
|
+
const offsetAndLength = offset + WORD_SIZE;
|
32839
|
+
const lengthBytes = data.slice(offset, offsetAndLength);
|
32840
|
+
const length = bn(new BigNumberCoder("u64").decode(lengthBytes, 0)[0]).toNumber();
|
32841
|
+
const bytes3 = data.slice(offsetAndLength, offsetAndLength + length);
|
32842
|
+
if (bytes3.length !== length) {
|
32843
|
+
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string slice byte data size.`);
|
32844
|
+
}
|
32845
|
+
return [toUtf8String(bytes3), offsetAndLength + length];
|
32846
|
+
}
|
32847
|
+
};
|
32848
|
+
__publicField4(StrSliceCoder, "memorySize", 1);
|
32805
32849
|
var StringCoder2 = class extends Coder {
|
32806
32850
|
constructor(length) {
|
32807
32851
|
super("string", `str[${length}]`, length);
|
@@ -32840,7 +32884,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32840
32884
|
Object.keys(this.coders).map((fieldName) => {
|
32841
32885
|
const fieldCoder = this.coders[fieldName];
|
32842
32886
|
const fieldValue = value[fieldName];
|
32843
|
-
if (!(fieldCoder instanceof
|
32887
|
+
if (!(fieldCoder instanceof OptionCoder2) && fieldValue == null) {
|
32844
32888
|
throw new FuelError(
|
32845
32889
|
ErrorCode.ENCODE_ERROR,
|
32846
32890
|
`Invalid ${this.type}. Field "${fieldName}" not present.`
|
@@ -32948,6 +32992,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32948
32992
|
return new ByteCoder2();
|
32949
32993
|
case STD_STRING_CODER_TYPE:
|
32950
32994
|
return new StdStringCoder2();
|
32995
|
+
case STR_SLICE_CODER_TYPE:
|
32996
|
+
return new StrSliceCoder();
|
32951
32997
|
default:
|
32952
32998
|
break;
|
32953
32999
|
}
|
@@ -32992,7 +33038,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32992
33038
|
const coders = getCoders(components, { getCoder: getCoder2 });
|
32993
33039
|
const isOptionEnum = resolvedAbiType.type === OPTION_CODER_TYPE;
|
32994
33040
|
if (isOptionEnum) {
|
32995
|
-
return new
|
33041
|
+
return new OptionCoder2(enumMatch.name, coders);
|
32996
33042
|
}
|
32997
33043
|
return new EnumCoder2(enumMatch.name, coders);
|
32998
33044
|
}
|
@@ -33003,12 +33049,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33003
33049
|
);
|
33004
33050
|
return new TupleCoder2(coders);
|
33005
33051
|
}
|
33006
|
-
if (resolvedAbiType.type === STR_SLICE_CODER_TYPE) {
|
33007
|
-
throw new FuelError(
|
33008
|
-
ErrorCode.INVALID_DATA,
|
33009
|
-
"String slices can not be decoded from logs. Convert the slice to `str[N]` with `__to_str_array`"
|
33010
|
-
);
|
33011
|
-
}
|
33012
33052
|
throw new FuelError(
|
33013
33053
|
ErrorCode.CODER_NOT_FOUND,
|
33014
33054
|
`Coder not found: ${JSON.stringify(resolvedAbiType)}.`
|
@@ -33044,6 +33084,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33044
33084
|
var FunctionFragment = class {
|
33045
33085
|
signature;
|
33046
33086
|
selector;
|
33087
|
+
selectorBytes;
|
33088
|
+
encoding;
|
33047
33089
|
name;
|
33048
33090
|
jsonFn;
|
33049
33091
|
attributes;
|
@@ -33056,6 +33098,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33056
33098
|
this.name = name;
|
33057
33099
|
this.signature = FunctionFragment.getSignature(this.jsonAbi, this.jsonFn);
|
33058
33100
|
this.selector = FunctionFragment.getFunctionSelector(this.signature);
|
33101
|
+
this.selectorBytes = new StdStringCoder2().encode(name);
|
33102
|
+
this.encoding = this.jsonAbi.encoding ?? ENCODING_V0;
|
33059
33103
|
this.isInputDataPointer = this.#isInputDataPointer();
|
33060
33104
|
this.outputMetadata = {
|
33061
33105
|
isHeapType: this.#isOutputDataHeap(),
|
@@ -33109,11 +33153,14 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33109
33153
|
}
|
33110
33154
|
const coders = nonEmptyInputs.map(
|
33111
33155
|
(t) => AbiCoder.getCoder(this.jsonAbi, t, {
|
33112
|
-
isRightPadded: nonEmptyInputs.length > 1
|
33156
|
+
isRightPadded: nonEmptyInputs.length > 1,
|
33157
|
+
encoding: this.encoding
|
33113
33158
|
})
|
33114
33159
|
);
|
33115
|
-
|
33116
|
-
|
33160
|
+
if (this.encoding === ENCODING_V1) {
|
33161
|
+
return new TupleCoder2(coders).encode(shallowCopyValues);
|
33162
|
+
}
|
33163
|
+
const results = new TupleCoder(coders).encode(shallowCopyValues);
|
33117
33164
|
return unpackDynamicData(results, offset, results.byteLength);
|
33118
33165
|
}
|
33119
33166
|
static verifyArgsAndInputsAlign(args, inputs, abi) {
|
@@ -33160,7 +33207,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33160
33207
|
}
|
33161
33208
|
const result = nonEmptyInputs.reduce(
|
33162
33209
|
(obj, input) => {
|
33163
|
-
const coder = AbiCoder.getCoder(this.jsonAbi, input);
|
33210
|
+
const coder = AbiCoder.getCoder(this.jsonAbi, input, { encoding: this.encoding });
|
33164
33211
|
const [decodedValue, decodedValueByteSize] = coder.decode(bytes3, obj.offset);
|
33165
33212
|
return {
|
33166
33213
|
decoded: [...obj.decoded, decodedValue],
|
@@ -33180,7 +33227,9 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33180
33227
|
return [void 0, 0];
|
33181
33228
|
}
|
33182
33229
|
const bytes3 = arrayify(data);
|
33183
|
-
const coder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output
|
33230
|
+
const coder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output, {
|
33231
|
+
encoding: this.encoding
|
33232
|
+
});
|
33184
33233
|
return coder.decode(bytes3, 0);
|
33185
33234
|
}
|
33186
33235
|
};
|
@@ -33242,7 +33291,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33242
33291
|
}
|
33243
33292
|
);
|
33244
33293
|
return AbiCoder.encode(this.jsonAbi, configurable.configurableType, value, {
|
33245
|
-
isRightPadded: true
|
33294
|
+
isRightPadded: true,
|
33295
|
+
encoding: this.jsonAbi.encoding
|
33246
33296
|
});
|
33247
33297
|
}
|
33248
33298
|
getTypeById(typeId) {
|
@@ -38813,9 +38863,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38813
38863
|
}
|
38814
38864
|
};
|
38815
38865
|
|
38816
|
-
// ../address/dist/configs.mjs
|
38817
|
-
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
38818
|
-
|
38819
38866
|
// src/providers/transaction-request/input.ts
|
38820
38867
|
var inputify = (value) => {
|
38821
38868
|
const { type: type3 } = value;
|
@@ -39371,8 +39418,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39371
39418
|
outputs = [];
|
39372
39419
|
/** List of witnesses */
|
39373
39420
|
witnesses = [];
|
39374
|
-
/** Base asset ID - should be fetched from the chain */
|
39375
|
-
baseAssetId = ZeroBytes32;
|
39376
39421
|
/**
|
39377
39422
|
* Constructor for initializing a base transaction request.
|
39378
39423
|
*
|
@@ -39385,8 +39430,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39385
39430
|
witnessLimit,
|
39386
39431
|
inputs,
|
39387
39432
|
outputs,
|
39388
|
-
witnesses
|
39389
|
-
baseAssetId
|
39433
|
+
witnesses
|
39390
39434
|
} = {}) {
|
39391
39435
|
this.gasPrice = bn(gasPrice);
|
39392
39436
|
this.maturity = maturity ?? 0;
|
@@ -39395,7 +39439,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39395
39439
|
this.inputs = inputs ?? [];
|
39396
39440
|
this.outputs = outputs ?? [];
|
39397
39441
|
this.witnesses = witnesses ?? [];
|
39398
|
-
this.baseAssetId = baseAssetId ?? ZeroBytes32;
|
39399
39442
|
}
|
39400
39443
|
static getPolicyMeta(req) {
|
39401
39444
|
let policyTypes = 0;
|
@@ -39620,9 +39663,11 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39620
39663
|
*
|
39621
39664
|
* @param message - Message resource.
|
39622
39665
|
* @param predicate - Predicate bytes.
|
39666
|
+
* @param predicateData - Predicate data bytes.
|
39623
39667
|
*/
|
39624
39668
|
addMessageInput(message, predicate) {
|
39625
39669
|
const { recipient, sender, amount } = message;
|
39670
|
+
const assetId = BaseAssetId;
|
39626
39671
|
let witnessIndex;
|
39627
39672
|
if (predicate) {
|
39628
39673
|
witnessIndex = 0;
|
@@ -39643,7 +39688,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39643
39688
|
predicateData: predicate?.predicateDataBytes
|
39644
39689
|
};
|
39645
39690
|
this.pushInput(input);
|
39646
|
-
this.addChangeOutput(recipient,
|
39691
|
+
this.addChangeOutput(recipient, assetId);
|
39647
39692
|
}
|
39648
39693
|
/**
|
39649
39694
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -39704,12 +39749,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39704
39749
|
* @param amount - Amount of coin.
|
39705
39750
|
* @param assetId - Asset ID of coin.
|
39706
39751
|
*/
|
39707
|
-
addCoinOutput(to, amount, assetId) {
|
39752
|
+
addCoinOutput(to, amount, assetId = BaseAssetId) {
|
39708
39753
|
this.pushOutput({
|
39709
39754
|
type: OutputType.Coin,
|
39710
39755
|
to: addressify(to).toB256(),
|
39711
39756
|
amount,
|
39712
|
-
assetId
|
39757
|
+
assetId
|
39713
39758
|
});
|
39714
39759
|
return this;
|
39715
39760
|
}
|
@@ -39736,7 +39781,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39736
39781
|
* @param to - Address of the owner.
|
39737
39782
|
* @param assetId - Asset ID of coin.
|
39738
39783
|
*/
|
39739
|
-
addChangeOutput(to, assetId) {
|
39784
|
+
addChangeOutput(to, assetId = BaseAssetId) {
|
39740
39785
|
const changeOutput = this.getChangeOutputs().find(
|
39741
39786
|
(output3) => hexlify(output3.assetId) === assetId
|
39742
39787
|
);
|
@@ -39744,7 +39789,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39744
39789
|
this.pushOutput({
|
39745
39790
|
type: OutputType.Change,
|
39746
39791
|
to: addressify(to).toB256(),
|
39747
|
-
assetId
|
39792
|
+
assetId
|
39748
39793
|
});
|
39749
39794
|
}
|
39750
39795
|
}
|
@@ -39826,7 +39871,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39826
39871
|
]);
|
39827
39872
|
}
|
39828
39873
|
};
|
39829
|
-
updateAssetInput(
|
39874
|
+
updateAssetInput(BaseAssetId, bn(1e11));
|
39830
39875
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
39831
39876
|
}
|
39832
39877
|
/**
|
@@ -41244,7 +41289,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
41244
41289
|
gasPerByte: bn(feeParams.gasPerByte),
|
41245
41290
|
maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
|
41246
41291
|
chainId: bn(consensusParameters.chainId),
|
41247
|
-
baseAssetId: consensusParameters.baseAssetId,
|
41248
41292
|
gasCosts
|
41249
41293
|
},
|
41250
41294
|
gasCosts,
|
@@ -41487,17 +41531,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
41487
41531
|
} = this.getChain();
|
41488
41532
|
return chainId.toNumber();
|
41489
41533
|
}
|
41490
|
-
/**
|
41491
|
-
* Returns the base asset ID
|
41492
|
-
*
|
41493
|
-
* @returns A promise that resolves to the base asset ID
|
41494
|
-
*/
|
41495
|
-
getBaseAssetId() {
|
41496
|
-
const {
|
41497
|
-
consensusParameters: { baseAssetId }
|
41498
|
-
} = this.getChain();
|
41499
|
-
return baseAssetId;
|
41500
|
-
}
|
41501
41534
|
/**
|
41502
41535
|
* Submits a transaction to the chain to be executed.
|
41503
41536
|
*
|
@@ -42527,9 +42560,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42527
42560
|
* @param assetId - The asset ID to check the balance for.
|
42528
42561
|
* @returns A promise that resolves to the balance amount.
|
42529
42562
|
*/
|
42530
|
-
async getBalance(assetId) {
|
42531
|
-
const
|
42532
|
-
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
42563
|
+
async getBalance(assetId = BaseAssetId) {
|
42564
|
+
const amount = await this.provider.getBalance(this.address, assetId);
|
42533
42565
|
return amount;
|
42534
42566
|
}
|
42535
42567
|
/**
|
@@ -42567,10 +42599,9 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42567
42599
|
* @returns A promise that resolves when the resources are added to the transaction.
|
42568
42600
|
*/
|
42569
42601
|
async fund(request, coinQuantities, fee) {
|
42570
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
42571
42602
|
const updatedQuantities = addAmountToAsset({
|
42572
42603
|
amount: bn(fee),
|
42573
|
-
assetId:
|
42604
|
+
assetId: BaseAssetId,
|
42574
42605
|
coinQuantities
|
42575
42606
|
});
|
42576
42607
|
const quantitiesDict = {};
|
@@ -42594,8 +42625,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42594
42625
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
42595
42626
|
cachedUtxos.push(input.id);
|
42596
42627
|
}
|
42597
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[
|
42598
|
-
quantitiesDict[
|
42628
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId]) {
|
42629
|
+
quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
|
42599
42630
|
cachedMessages.push(input.nonce);
|
42600
42631
|
}
|
42601
42632
|
}
|
@@ -42627,12 +42658,11 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42627
42658
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
42628
42659
|
* @returns A promise that resolves to the prepared transaction request.
|
42629
42660
|
*/
|
42630
|
-
async createTransfer(destination, amount, assetId, txParams = {}) {
|
42661
|
+
async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
42631
42662
|
const { minGasPrice } = this.provider.getGasConfig();
|
42632
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42633
42663
|
const params = { gasPrice: minGasPrice, ...txParams };
|
42634
42664
|
const request = new ScriptTransactionRequest(params);
|
42635
|
-
request.addCoinOutput(Address.fromAddressOrString(destination), amount,
|
42665
|
+
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
|
42636
42666
|
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
42637
42667
|
estimateTxDependencies: true,
|
42638
42668
|
resourcesOwner: this
|
@@ -42658,15 +42688,14 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42658
42688
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
42659
42689
|
* @returns A promise that resolves to the transaction response.
|
42660
42690
|
*/
|
42661
|
-
async transfer(destination, amount, assetId, txParams = {}) {
|
42691
|
+
async transfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
42662
42692
|
if (bn(amount).lte(0)) {
|
42663
42693
|
throw new FuelError(
|
42664
42694
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
42665
42695
|
"Transfer amount must be a positive number."
|
42666
42696
|
);
|
42667
42697
|
}
|
42668
|
-
const
|
42669
|
-
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
42698
|
+
const request = await this.createTransfer(destination, amount, assetId, txParams);
|
42670
42699
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
42671
42700
|
}
|
42672
42701
|
/**
|
@@ -42678,7 +42707,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42678
42707
|
* @param txParams - The optional transaction parameters.
|
42679
42708
|
* @returns A promise that resolves to the transaction response.
|
42680
42709
|
*/
|
42681
|
-
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
42710
|
+
async transferToContract(contractId, amount, assetId = BaseAssetId, txParams = {}) {
|
42682
42711
|
if (bn(amount).lte(0)) {
|
42683
42712
|
throw new FuelError(
|
42684
42713
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -42687,12 +42716,11 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42687
42716
|
}
|
42688
42717
|
const contractAddress = Address.fromAddressOrString(contractId);
|
42689
42718
|
const { minGasPrice } = this.provider.getGasConfig();
|
42690
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42691
42719
|
const params = { gasPrice: minGasPrice, ...txParams };
|
42692
42720
|
const { script, scriptData } = await assembleTransferToContractScript({
|
42693
42721
|
hexlifiedContractId: contractAddress.toB256(),
|
42694
42722
|
amountToTransfer: bn(amount),
|
42695
|
-
assetId
|
42723
|
+
assetId
|
42696
42724
|
});
|
42697
42725
|
const request = new ScriptTransactionRequest({
|
42698
42726
|
...params,
|
@@ -42702,7 +42730,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42702
42730
|
request.addContractInputAndOutput(contractAddress);
|
42703
42731
|
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
42704
42732
|
request,
|
42705
|
-
[{ amount: bn(amount), assetId: String(
|
42733
|
+
[{ amount: bn(amount), assetId: String(assetId) }]
|
42706
42734
|
);
|
42707
42735
|
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
42708
42736
|
this.validateGas({
|
@@ -42724,7 +42752,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42724
42752
|
*/
|
42725
42753
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
42726
42754
|
const { minGasPrice } = this.provider.getGasConfig();
|
42727
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
42728
42755
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
42729
42756
|
const recipientDataArray = arrayify(
|
42730
42757
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -42739,7 +42766,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42739
42766
|
]);
|
42740
42767
|
const params = { script, gasPrice: minGasPrice, ...txParams };
|
42741
42768
|
const request = new ScriptTransactionRequest(params);
|
42742
|
-
const forwardingQuantities = [{ amount: bn(amount), assetId:
|
42769
|
+
const forwardingQuantities = [{ amount: bn(amount), assetId: BaseAssetId }];
|
42743
42770
|
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
42744
42771
|
request,
|
42745
42772
|
forwardingQuantities
|
@@ -47703,9 +47730,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
47703
47730
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
47704
47731
|
* @returns A promise that resolves to the prepared transaction request.
|
47705
47732
|
*/
|
47706
|
-
async createTransfer(destination, amount, assetId, txParams = {}) {
|
47707
|
-
const
|
47708
|
-
const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
47733
|
+
async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
47734
|
+
const request = await super.createTransfer(destination, amount, assetId, txParams);
|
47709
47735
|
return this.populateTransactionPredicateData(request);
|
47710
47736
|
}
|
47711
47737
|
/**
|