Skip to content

Commit 384ad85

Browse files
committed
Don't hardcode network ID in Core classes
1 parent 877e63d commit 384ad85

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

integration_tests/Transaction.spec.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,12 @@ test("AssetTransferTransaction fromJSON", async () => {
5454
.createMintTransaction({ recipient: addressA });
5555
await sendTransactions({ transactions: [mintTx] });
5656
const firstAsset = await sdk.rpc.chain.getAsset(mintTx.hash(), 0);
57-
58-
const transferTx = await firstAsset.createTransferTransaction({
59-
recipients: [
60-
{
61-
address: addressB,
62-
amount: 100
63-
}
64-
]
57+
const transferTx = await sdk.core.createAssetTransferTransaction();
58+
transferTx.addInputs(firstAsset);
59+
transferTx.addOutputs({
60+
assetType: firstAsset.assetType,
61+
recipient: addressB,
62+
amount: 100
6563
});
6664
sdk.key.signTransactionInput(transferTx, 0);
6765
const { parcelHash } = await sendTransactions({

src/core/Asset.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,16 @@ export class Asset {
9696
});
9797
}
9898

99-
public createTransferTransaction(
100-
params: {
101-
recipients: Array<{
102-
address: AssetTransferAddress | string;
103-
amount: number;
104-
}>;
105-
nonce?: number;
106-
networkId?: NetworkId;
107-
} = { recipients: [] }
108-
): AssetTransferTransaction {
99+
public createTransferTransaction(params: {
100+
recipients?: Array<{
101+
address: AssetTransferAddress | string;
102+
amount: number;
103+
}>;
104+
nonce?: number;
105+
networkId: NetworkId;
106+
}): AssetTransferTransaction {
109107
const { outPoint, assetType } = this;
110-
const { recipients, nonce = 0, networkId = "tc" } = params;
108+
const { recipients = [], nonce = 0, networkId } = params;
111109

112110
return new AssetTransferTransaction({
113111
burns: [],

0 commit comments

Comments
 (0)