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