@fuel-ts/account 0.0.0-rc-1832-20240403171523 → 0.0.0-rc-1976-20240403225009
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
@@ -31274,10 +31274,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31274
31274
|
}
|
31275
31275
|
};
|
31276
31276
|
|
31277
|
-
// ../address/dist/configs.mjs
|
31278
|
-
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
31279
|
-
var BaseAssetId = ZeroBytes32;
|
31280
|
-
|
31281
31277
|
// ../math/dist/index.mjs
|
31282
31278
|
var import_bn = __toESM(require_bn(), 1);
|
31283
31279
|
var DEFAULT_PRECISION = 9;
|
@@ -31508,11 +31504,11 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31508
31504
|
let max2;
|
31509
31505
|
if (Array.isArray(coinQuantityLike)) {
|
31510
31506
|
amount = coinQuantityLike[0];
|
31511
|
-
assetId = coinQuantityLike[1]
|
31512
|
-
max2 = coinQuantityLike[2]
|
31507
|
+
assetId = coinQuantityLike[1];
|
31508
|
+
max2 = coinQuantityLike[2];
|
31513
31509
|
} else {
|
31514
31510
|
amount = coinQuantityLike.amount;
|
31515
|
-
assetId = coinQuantityLike.assetId
|
31511
|
+
assetId = coinQuantityLike.assetId;
|
31516
31512
|
max2 = coinQuantityLike.max ?? void 0;
|
31517
31513
|
}
|
31518
31514
|
const bnAmount = bn(amount);
|
@@ -31918,6 +31914,9 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31918
31914
|
__privateAdd2(this, _getPaddedData);
|
31919
31915
|
}
|
31920
31916
|
encode(value) {
|
31917
|
+
if (!Array.isArray(value)) {
|
31918
|
+
throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
|
31919
|
+
}
|
31921
31920
|
const parts = [];
|
31922
31921
|
const pointer = new BigNumberCoder("u64").encode(BASE_VECTOR_OFFSET);
|
31923
31922
|
const data = __privateMethod2(this, _getPaddedData, getPaddedData_fn).call(this, value);
|
@@ -31944,7 +31943,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31944
31943
|
};
|
31945
31944
|
_getPaddedData = /* @__PURE__ */ new WeakSet();
|
31946
31945
|
getPaddedData_fn = function(value) {
|
31947
|
-
const data =
|
31946
|
+
const data = [Uint8Array.from(value)];
|
31948
31947
|
const paddingLength = (WORD_SIZE - value.length % WORD_SIZE) % WORD_SIZE;
|
31949
31948
|
if (paddingLength) {
|
31950
31949
|
data.push(new Uint8Array(paddingLength));
|
@@ -31967,7 +31966,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31967
31966
|
(max2, coder) => Math.max(max2, coder.encodedLength),
|
31968
31967
|
0
|
31969
31968
|
);
|
31970
|
-
super(
|
31969
|
+
super("enum", `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
|
31971
31970
|
this.name = name;
|
31972
31971
|
this.coders = coders;
|
31973
31972
|
this.#caseIndexCoder = caseIndexCoder;
|
@@ -32037,7 +32036,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32037
32036
|
return { None: [] };
|
32038
32037
|
}
|
32039
32038
|
decode(data, offset) {
|
32040
|
-
if (data.length < this.encodedLength) {
|
32039
|
+
if (data.length < this.encodedLength - 1) {
|
32041
32040
|
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid option data size.`);
|
32042
32041
|
}
|
32043
32042
|
const [decoded, newOffset] = super.decode(data, offset);
|
@@ -32620,8 +32619,11 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32620
32619
|
super("struct", "struct Bytes", WORD_SIZE);
|
32621
32620
|
}
|
32622
32621
|
encode(value) {
|
32623
|
-
|
32624
|
-
|
32622
|
+
if (!Array.isArray(value)) {
|
32623
|
+
throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
|
32624
|
+
}
|
32625
|
+
const bytes3 = new Uint8Array(value);
|
32626
|
+
const lengthBytes = new BigNumberCoder("u64").encode(value.length);
|
32625
32627
|
return new Uint8Array([...lengthBytes, ...bytes3]);
|
32626
32628
|
}
|
32627
32629
|
decode(data, offset) {
|
@@ -32654,7 +32656,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32654
32656
|
(max2, coder) => Math.max(max2, coder.encodedLength),
|
32655
32657
|
0
|
32656
32658
|
);
|
32657
|
-
super(
|
32659
|
+
super("enum", `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
|
32658
32660
|
this.name = name;
|
32659
32661
|
this.coders = coders;
|
32660
32662
|
this.#caseIndexCoder = caseIndexCoder;
|
@@ -32752,28 +32754,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32752
32754
|
return [toNumber2(bytes3), offset + this.length];
|
32753
32755
|
}
|
32754
32756
|
};
|
32755
|
-
var OptionCoder2 = class extends EnumCoder2 {
|
32756
|
-
encode(value) {
|
32757
|
-
const result = super.encode(this.toSwayOption(value));
|
32758
|
-
return result;
|
32759
|
-
}
|
32760
|
-
toSwayOption(input) {
|
32761
|
-
if (input !== void 0) {
|
32762
|
-
return { Some: input };
|
32763
|
-
}
|
32764
|
-
return { None: [] };
|
32765
|
-
}
|
32766
|
-
decode(data, offset) {
|
32767
|
-
const [decoded, newOffset] = super.decode(data, offset);
|
32768
|
-
return [this.toOption(decoded), newOffset];
|
32769
|
-
}
|
32770
|
-
toOption(output3) {
|
32771
|
-
if (output3 && "Some" in output3) {
|
32772
|
-
return output3.Some;
|
32773
|
-
}
|
32774
|
-
return void 0;
|
32775
|
-
}
|
32776
|
-
};
|
32777
32757
|
var RawSliceCoder2 = class extends Coder {
|
32778
32758
|
constructor() {
|
32779
32759
|
super("raw untyped slice", "raw untyped slice", WORD_SIZE);
|
@@ -32827,30 +32807,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32827
32807
|
}
|
32828
32808
|
};
|
32829
32809
|
__publicField4(StdStringCoder2, "memorySize", 1);
|
32830
|
-
var StrSliceCoder = class extends Coder {
|
32831
|
-
constructor() {
|
32832
|
-
super("strSlice", "str", WORD_SIZE);
|
32833
|
-
}
|
32834
|
-
encode(value) {
|
32835
|
-
const bytes3 = toUtf8Bytes(value);
|
32836
|
-
const lengthBytes = new BigNumberCoder("u64").encode(value.length);
|
32837
|
-
return new Uint8Array([...lengthBytes, ...bytes3]);
|
32838
|
-
}
|
32839
|
-
decode(data, offset) {
|
32840
|
-
if (data.length < this.encodedLength) {
|
32841
|
-
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string slice data size.`);
|
32842
|
-
}
|
32843
|
-
const offsetAndLength = offset + WORD_SIZE;
|
32844
|
-
const lengthBytes = data.slice(offset, offsetAndLength);
|
32845
|
-
const length = bn(new BigNumberCoder("u64").decode(lengthBytes, 0)[0]).toNumber();
|
32846
|
-
const bytes3 = data.slice(offsetAndLength, offsetAndLength + length);
|
32847
|
-
if (bytes3.length !== length) {
|
32848
|
-
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string slice byte data size.`);
|
32849
|
-
}
|
32850
|
-
return [toUtf8String(bytes3), offsetAndLength + length];
|
32851
|
-
}
|
32852
|
-
};
|
32853
|
-
__publicField4(StrSliceCoder, "memorySize", 1);
|
32854
32810
|
var StringCoder2 = class extends Coder {
|
32855
32811
|
constructor(length) {
|
32856
32812
|
super("string", `str[${length}]`, length);
|
@@ -32889,7 +32845,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32889
32845
|
Object.keys(this.coders).map((fieldName) => {
|
32890
32846
|
const fieldCoder = this.coders[fieldName];
|
32891
32847
|
const fieldValue = value[fieldName];
|
32892
|
-
if (!(fieldCoder instanceof
|
32848
|
+
if (!(fieldCoder instanceof OptionCoder) && fieldValue == null) {
|
32893
32849
|
throw new FuelError(
|
32894
32850
|
ErrorCode.ENCODE_ERROR,
|
32895
32851
|
`Invalid ${this.type}. Field "${fieldName}" not present.`
|
@@ -32997,8 +32953,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32997
32953
|
return new ByteCoder2();
|
32998
32954
|
case STD_STRING_CODER_TYPE:
|
32999
32955
|
return new StdStringCoder2();
|
33000
|
-
case STR_SLICE_CODER_TYPE:
|
33001
|
-
return new StrSliceCoder();
|
33002
32956
|
default:
|
33003
32957
|
break;
|
33004
32958
|
}
|
@@ -33043,7 +32997,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33043
32997
|
const coders = getCoders(components, { getCoder: getCoder2 });
|
33044
32998
|
const isOptionEnum = resolvedAbiType.type === OPTION_CODER_TYPE;
|
33045
32999
|
if (isOptionEnum) {
|
33046
|
-
return new
|
33000
|
+
return new OptionCoder(enumMatch.name, coders);
|
33047
33001
|
}
|
33048
33002
|
return new EnumCoder2(enumMatch.name, coders);
|
33049
33003
|
}
|
@@ -33054,6 +33008,12 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33054
33008
|
);
|
33055
33009
|
return new TupleCoder2(coders);
|
33056
33010
|
}
|
33011
|
+
if (resolvedAbiType.type === STR_SLICE_CODER_TYPE) {
|
33012
|
+
throw new FuelError(
|
33013
|
+
ErrorCode.INVALID_DATA,
|
33014
|
+
"String slices can not be decoded from logs. Convert the slice to `str[N]` with `__to_str_array`"
|
33015
|
+
);
|
33016
|
+
}
|
33057
33017
|
throw new FuelError(
|
33058
33018
|
ErrorCode.CODER_NOT_FOUND,
|
33059
33019
|
`Coder not found: ${JSON.stringify(resolvedAbiType)}.`
|
@@ -33089,8 +33049,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33089
33049
|
var FunctionFragment = class {
|
33090
33050
|
signature;
|
33091
33051
|
selector;
|
33092
|
-
selectorBytes;
|
33093
|
-
encoding;
|
33094
33052
|
name;
|
33095
33053
|
jsonFn;
|
33096
33054
|
attributes;
|
@@ -33103,8 +33061,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33103
33061
|
this.name = name;
|
33104
33062
|
this.signature = FunctionFragment.getSignature(this.jsonAbi, this.jsonFn);
|
33105
33063
|
this.selector = FunctionFragment.getFunctionSelector(this.signature);
|
33106
|
-
this.selectorBytes = new StdStringCoder2().encode(name);
|
33107
|
-
this.encoding = this.jsonAbi.encoding ?? ENCODING_V0;
|
33108
33064
|
this.isInputDataPointer = this.#isInputDataPointer();
|
33109
33065
|
this.outputMetadata = {
|
33110
33066
|
isHeapType: this.#isOutputDataHeap(),
|
@@ -33158,14 +33114,11 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33158
33114
|
}
|
33159
33115
|
const coders = nonEmptyInputs.map(
|
33160
33116
|
(t) => AbiCoder.getCoder(this.jsonAbi, t, {
|
33161
|
-
isRightPadded: nonEmptyInputs.length > 1
|
33162
|
-
encoding: this.encoding
|
33117
|
+
isRightPadded: nonEmptyInputs.length > 1
|
33163
33118
|
})
|
33164
33119
|
);
|
33165
|
-
|
33166
|
-
|
33167
|
-
}
|
33168
|
-
const results = new TupleCoder(coders).encode(shallowCopyValues);
|
33120
|
+
const coder = new TupleCoder(coders);
|
33121
|
+
const results = coder.encode(shallowCopyValues);
|
33169
33122
|
return unpackDynamicData(results, offset, results.byteLength);
|
33170
33123
|
}
|
33171
33124
|
static verifyArgsAndInputsAlign(args, inputs, abi) {
|
@@ -33212,7 +33165,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33212
33165
|
}
|
33213
33166
|
const result = nonEmptyInputs.reduce(
|
33214
33167
|
(obj, input) => {
|
33215
|
-
const coder = AbiCoder.getCoder(this.jsonAbi, input
|
33168
|
+
const coder = AbiCoder.getCoder(this.jsonAbi, input);
|
33216
33169
|
const [decodedValue, decodedValueByteSize] = coder.decode(bytes3, obj.offset);
|
33217
33170
|
return {
|
33218
33171
|
decoded: [...obj.decoded, decodedValue],
|
@@ -33232,9 +33185,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33232
33185
|
return [void 0, 0];
|
33233
33186
|
}
|
33234
33187
|
const bytes3 = arrayify(data);
|
33235
|
-
const coder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output
|
33236
|
-
encoding: this.encoding
|
33237
|
-
});
|
33188
|
+
const coder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output);
|
33238
33189
|
return coder.decode(bytes3, 0);
|
33239
33190
|
}
|
33240
33191
|
};
|
@@ -33302,8 +33253,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33302
33253
|
}
|
33303
33254
|
);
|
33304
33255
|
return AbiCoder.encode(this.jsonAbi, configurable.configurableType, value, {
|
33305
|
-
isRightPadded: true
|
33306
|
-
encoding: this.jsonAbi.encoding
|
33256
|
+
isRightPadded: true
|
33307
33257
|
});
|
33308
33258
|
}
|
33309
33259
|
getTypeById(typeId) {
|
@@ -38874,6 +38824,9 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38874
38824
|
}
|
38875
38825
|
};
|
38876
38826
|
|
38827
|
+
// ../address/dist/configs.mjs
|
38828
|
+
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
38829
|
+
|
38877
38830
|
// src/providers/transaction-request/input.ts
|
38878
38831
|
var inputify = (value) => {
|
38879
38832
|
const { type: type3 } = value;
|
@@ -39429,6 +39382,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39429
39382
|
outputs = [];
|
39430
39383
|
/** List of witnesses */
|
39431
39384
|
witnesses = [];
|
39385
|
+
/** Base asset ID - should be fetched from the chain */
|
39386
|
+
baseAssetId = ZeroBytes32;
|
39432
39387
|
/**
|
39433
39388
|
* Constructor for initializing a base transaction request.
|
39434
39389
|
*
|
@@ -39441,7 +39396,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39441
39396
|
witnessLimit,
|
39442
39397
|
inputs,
|
39443
39398
|
outputs,
|
39444
|
-
witnesses
|
39399
|
+
witnesses,
|
39400
|
+
baseAssetId
|
39445
39401
|
} = {}) {
|
39446
39402
|
this.gasPrice = bn(gasPrice);
|
39447
39403
|
this.maturity = maturity ?? 0;
|
@@ -39450,6 +39406,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39450
39406
|
this.inputs = inputs ?? [];
|
39451
39407
|
this.outputs = outputs ?? [];
|
39452
39408
|
this.witnesses = witnesses ?? [];
|
39409
|
+
this.baseAssetId = baseAssetId ?? ZeroBytes32;
|
39453
39410
|
}
|
39454
39411
|
static getPolicyMeta(req) {
|
39455
39412
|
let policyTypes = 0;
|
@@ -39674,11 +39631,9 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39674
39631
|
*
|
39675
39632
|
* @param message - Message resource.
|
39676
39633
|
* @param predicate - Predicate bytes.
|
39677
|
-
* @param predicateData - Predicate data bytes.
|
39678
39634
|
*/
|
39679
39635
|
addMessageInput(message, predicate) {
|
39680
39636
|
const { recipient, sender, amount } = message;
|
39681
|
-
const assetId = BaseAssetId;
|
39682
39637
|
let witnessIndex;
|
39683
39638
|
if (predicate) {
|
39684
39639
|
witnessIndex = 0;
|
@@ -39699,7 +39654,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39699
39654
|
predicateData: predicate?.predicateDataBytes
|
39700
39655
|
};
|
39701
39656
|
this.pushInput(input);
|
39702
|
-
this.addChangeOutput(recipient,
|
39657
|
+
this.addChangeOutput(recipient, this.baseAssetId);
|
39703
39658
|
}
|
39704
39659
|
/**
|
39705
39660
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -39760,12 +39715,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39760
39715
|
* @param amount - Amount of coin.
|
39761
39716
|
* @param assetId - Asset ID of coin.
|
39762
39717
|
*/
|
39763
|
-
addCoinOutput(to, amount, assetId
|
39718
|
+
addCoinOutput(to, amount, assetId) {
|
39764
39719
|
this.pushOutput({
|
39765
39720
|
type: OutputType.Coin,
|
39766
39721
|
to: addressify(to).toB256(),
|
39767
39722
|
amount,
|
39768
|
-
assetId
|
39723
|
+
assetId: assetId ?? this.baseAssetId
|
39769
39724
|
});
|
39770
39725
|
return this;
|
39771
39726
|
}
|
@@ -39792,7 +39747,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39792
39747
|
* @param to - Address of the owner.
|
39793
39748
|
* @param assetId - Asset ID of coin.
|
39794
39749
|
*/
|
39795
|
-
addChangeOutput(to, assetId
|
39750
|
+
addChangeOutput(to, assetId) {
|
39796
39751
|
const changeOutput = this.getChangeOutputs().find(
|
39797
39752
|
(output3) => hexlify(output3.assetId) === assetId
|
39798
39753
|
);
|
@@ -39800,7 +39755,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39800
39755
|
this.pushOutput({
|
39801
39756
|
type: OutputType.Change,
|
39802
39757
|
to: addressify(to).toB256(),
|
39803
|
-
assetId
|
39758
|
+
assetId: assetId ?? this.baseAssetId
|
39804
39759
|
});
|
39805
39760
|
}
|
39806
39761
|
}
|
@@ -39882,7 +39837,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39882
39837
|
]);
|
39883
39838
|
}
|
39884
39839
|
};
|
39885
|
-
updateAssetInput(
|
39840
|
+
updateAssetInput(this.baseAssetId, bn(1e11));
|
39886
39841
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
39887
39842
|
}
|
39888
39843
|
/**
|
@@ -41300,6 +41255,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
41300
41255
|
gasPerByte: bn(feeParams.gasPerByte),
|
41301
41256
|
maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
|
41302
41257
|
chainId: bn(consensusParameters.chainId),
|
41258
|
+
baseAssetId: consensusParameters.baseAssetId,
|
41303
41259
|
gasCosts
|
41304
41260
|
},
|
41305
41261
|
gasCosts,
|
@@ -41542,6 +41498,17 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
41542
41498
|
} = this.getChain();
|
41543
41499
|
return chainId.toNumber();
|
41544
41500
|
}
|
41501
|
+
/**
|
41502
|
+
* Returns the base asset ID
|
41503
|
+
*
|
41504
|
+
* @returns A promise that resolves to the base asset ID
|
41505
|
+
*/
|
41506
|
+
getBaseAssetId() {
|
41507
|
+
const {
|
41508
|
+
consensusParameters: { baseAssetId }
|
41509
|
+
} = this.getChain();
|
41510
|
+
return baseAssetId;
|
41511
|
+
}
|
41545
41512
|
/**
|
41546
41513
|
* Submits a transaction to the chain to be executed.
|
41547
41514
|
*
|
@@ -42571,8 +42538,9 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42571
42538
|
* @param assetId - The asset ID to check the balance for.
|
42572
42539
|
* @returns A promise that resolves to the balance amount.
|
42573
42540
|
*/
|
42574
|
-
async getBalance(assetId
|
42575
|
-
const
|
42541
|
+
async getBalance(assetId) {
|
42542
|
+
const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
|
42543
|
+
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
42576
42544
|
return amount;
|
42577
42545
|
}
|
42578
42546
|
/**
|
@@ -42610,9 +42578,10 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42610
42578
|
* @returns A promise that resolves when the resources are added to the transaction.
|
42611
42579
|
*/
|
42612
42580
|
async fund(request, coinQuantities, fee) {
|
42581
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42613
42582
|
const updatedQuantities = addAmountToAsset({
|
42614
42583
|
amount: bn(fee),
|
42615
|
-
assetId:
|
42584
|
+
assetId: baseAssetId,
|
42616
42585
|
coinQuantities
|
42617
42586
|
});
|
42618
42587
|
const quantitiesDict = {};
|
@@ -42636,8 +42605,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42636
42605
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
42637
42606
|
cachedUtxos.push(input.id);
|
42638
42607
|
}
|
42639
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[
|
42640
|
-
quantitiesDict[
|
42608
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
|
42609
|
+
quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
|
42641
42610
|
cachedMessages.push(input.nonce);
|
42642
42611
|
}
|
42643
42612
|
}
|
@@ -42669,11 +42638,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42669
42638
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
42670
42639
|
* @returns A promise that resolves to the prepared transaction request.
|
42671
42640
|
*/
|
42672
|
-
async createTransfer(destination, amount, assetId
|
42641
|
+
async createTransfer(destination, amount, assetId, txParams = {}) {
|
42673
42642
|
const { minGasPrice } = this.provider.getGasConfig();
|
42643
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42674
42644
|
const params = { gasPrice: minGasPrice, ...txParams };
|
42675
42645
|
const request = new ScriptTransactionRequest(params);
|
42676
|
-
request.addCoinOutput(Address.fromAddressOrString(destination), amount,
|
42646
|
+
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetIdToTransfer);
|
42677
42647
|
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
42678
42648
|
estimateTxDependencies: true,
|
42679
42649
|
resourcesOwner: this
|
@@ -42699,14 +42669,15 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42699
42669
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
42700
42670
|
* @returns A promise that resolves to the transaction response.
|
42701
42671
|
*/
|
42702
|
-
async transfer(destination, amount, assetId
|
42672
|
+
async transfer(destination, amount, assetId, txParams = {}) {
|
42703
42673
|
if (bn(amount).lte(0)) {
|
42704
42674
|
throw new FuelError(
|
42705
42675
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
42706
42676
|
"Transfer amount must be a positive number."
|
42707
42677
|
);
|
42708
42678
|
}
|
42709
|
-
const
|
42679
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42680
|
+
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
42710
42681
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
42711
42682
|
}
|
42712
42683
|
/**
|
@@ -42718,7 +42689,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42718
42689
|
* @param txParams - The optional transaction parameters.
|
42719
42690
|
* @returns A promise that resolves to the transaction response.
|
42720
42691
|
*/
|
42721
|
-
async transferToContract(contractId, amount, assetId
|
42692
|
+
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
42722
42693
|
if (bn(amount).lte(0)) {
|
42723
42694
|
throw new FuelError(
|
42724
42695
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -42727,11 +42698,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42727
42698
|
}
|
42728
42699
|
const contractAddress = Address.fromAddressOrString(contractId);
|
42729
42700
|
const { minGasPrice } = this.provider.getGasConfig();
|
42701
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42730
42702
|
const params = { gasPrice: minGasPrice, ...txParams };
|
42731
42703
|
const { script, scriptData } = await assembleTransferToContractScript({
|
42732
42704
|
hexlifiedContractId: contractAddress.toB256(),
|
42733
42705
|
amountToTransfer: bn(amount),
|
42734
|
-
assetId
|
42706
|
+
assetId: assetIdToTransfer
|
42735
42707
|
});
|
42736
42708
|
const request = new ScriptTransactionRequest({
|
42737
42709
|
...params,
|
@@ -42741,7 +42713,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42741
42713
|
request.addContractInputAndOutput(contractAddress);
|
42742
42714
|
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
42743
42715
|
request,
|
42744
|
-
[{ amount: bn(amount), assetId: String(
|
42716
|
+
[{ amount: bn(amount), assetId: String(assetIdToTransfer) }]
|
42745
42717
|
);
|
42746
42718
|
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
42747
42719
|
this.validateGas({
|
@@ -42763,6 +42735,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42763
42735
|
*/
|
42764
42736
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
42765
42737
|
const { minGasPrice } = this.provider.getGasConfig();
|
42738
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42766
42739
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
42767
42740
|
const recipientDataArray = arrayify(
|
42768
42741
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -42777,7 +42750,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42777
42750
|
]);
|
42778
42751
|
const params = { script, gasPrice: minGasPrice, ...txParams };
|
42779
42752
|
const request = new ScriptTransactionRequest(params);
|
42780
|
-
const forwardingQuantities = [{ amount: bn(amount), assetId:
|
42753
|
+
const forwardingQuantities = [{ amount: bn(amount), assetId: baseAssetId }];
|
42781
42754
|
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
42782
42755
|
request,
|
42783
42756
|
forwardingQuantities
|
@@ -47741,8 +47714,9 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
47741
47714
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
47742
47715
|
* @returns A promise that resolves to the prepared transaction request.
|
47743
47716
|
*/
|
47744
|
-
async createTransfer(destination, amount, assetId
|
47745
|
-
const
|
47717
|
+
async createTransfer(destination, amount, assetId, txParams = {}) {
|
47718
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
47719
|
+
const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
47746
47720
|
return this.populateTransactionPredicateData(request);
|
47747
47721
|
}
|
47748
47722
|
/**
|