mirror of
https://github.com/alexgo-io/stacks.js.git
synced 2026-01-12 17:52:41 +08:00
fix: remove post-conditions from stx transfer
This commit is contained in:
@@ -532,11 +532,6 @@ export interface TokenTransferOptions {
|
||||
anchorMode: AnchorModeName | AnchorMode;
|
||||
/** an arbitrary string to include in the transaction, must be less than 34 bytes */
|
||||
memo?: string;
|
||||
/** the post condition mode, specifying whether or not post-conditions must fully cover all
|
||||
* transfered assets */
|
||||
postConditionMode?: PostConditionMode;
|
||||
/** a list of post conditions to add to the transaction */
|
||||
postConditions?: PostCondition[];
|
||||
/** set to true if another account is sponsoring the transaction (covering the transaction fee) */
|
||||
sponsored?: boolean;
|
||||
}
|
||||
@@ -576,7 +571,6 @@ export async function makeUnsignedSTXTokenTransfer(
|
||||
fee: BigInt(0),
|
||||
nonce: BigInt(0),
|
||||
network: new StacksMainnet(),
|
||||
postConditionMode: PostConditionMode.Deny,
|
||||
memo: '',
|
||||
sponsored: false,
|
||||
};
|
||||
@@ -615,20 +609,12 @@ export async function makeUnsignedSTXTokenTransfer(
|
||||
|
||||
const network = StacksNetwork.fromNameOrNetwork(options.network);
|
||||
|
||||
const postConditions: PostCondition[] = [];
|
||||
if (options.postConditions && options.postConditions.length > 0) {
|
||||
options.postConditions.forEach(postCondition => {
|
||||
postConditions.push(postCondition);
|
||||
});
|
||||
}
|
||||
const lpPostConditions = createLPList(postConditions);
|
||||
|
||||
const transaction = new StacksTransaction(
|
||||
network.version,
|
||||
authorization,
|
||||
payload,
|
||||
lpPostConditions,
|
||||
options.postConditionMode,
|
||||
undefined, // no post conditions on STX transfers (see SIP-005)
|
||||
undefined, // no post conditions on STX transfers (see SIP-005)
|
||||
options.anchorMode,
|
||||
network.chainId
|
||||
);
|
||||
|
||||
@@ -329,7 +329,7 @@ test('Throws making STX token transder with invalid network name', async () => {
|
||||
).rejects.toThrow(Error);
|
||||
});
|
||||
|
||||
test('Make STX token transfer with post conditions', async () => {
|
||||
test("STX token transfers don't take post conditions", async () => {
|
||||
const recipientAddress = 'SP3FGQ8Z7JY9BWYZ5WM53E0M9NK7WHJF0691NZ159';
|
||||
const amount = 12345;
|
||||
const fee = 0;
|
||||
@@ -350,18 +350,15 @@ test('Make STX token transfer with post conditions', async () => {
|
||||
memo,
|
||||
postConditions,
|
||||
anchorMode: AnchorMode.Any,
|
||||
});
|
||||
} as SignedTokenTransferOptions);
|
||||
|
||||
const serialized = bytesToHex(transaction.serialize());
|
||||
const serialized = transaction.serialize();
|
||||
|
||||
const tx =
|
||||
'0000000001040015c31b8c1c11c515e244b75806bac48d1399c77500000000000000000000000000000000' +
|
||||
'0001601ceb46ef6988c8b226c80fef4051de6acf344dc67a9421d3e734a72ae310104b061e69cee5d9ee7a' +
|
||||
'6e1cef17f23b07d7fe4db5fcdb83de0d5f08043a06a36a030200000001000216df0ba3e79792be7be5e50a' +
|
||||
'370289accfc8c9e03203000000000000d431000516df0ba3e79792be7be5e50a370289accfc8c9e0320000' +
|
||||
'00000000303974657374206d656d6f00000000000000000000000000000000000000000000000000';
|
||||
const bytesReader = new BytesReader(serialized);
|
||||
const deserializedTx = deserializeTransaction(bytesReader);
|
||||
|
||||
expect(serialized).toBe(tx);
|
||||
expect(deserializedTx.postConditions.values).toHaveLength(0);
|
||||
expect(deserializedTx.postConditionMode).toBe(PostConditionMode.Deny);
|
||||
});
|
||||
|
||||
test('Make Multi-Sig STX token transfer', async () => {
|
||||
|
||||
Reference in New Issue
Block a user