diff --git a/packages/bns/src/index.ts b/packages/bns/src/index.ts index d53073939..cb8d4c5ca 100644 --- a/packages/bns/src/index.ts +++ b/packages/bns/src/index.ts @@ -1,43 +1,38 @@ -import { IntegerType, utf8ToBytes } from '@stacks/common'; +import { ChainID, IntegerType, utf8ToBytes } from '@stacks/common'; +import { StacksNetwork } from '@stacks/network'; import { - AnchorMode, - bufferCV, - callReadOnlyFunction, + AddressVersion, ClarityType, ClarityValue, + FungibleConditionCode, + NonFungibleConditionCode, + PostCondition, + ResponseErrorCV, + StacksTransaction, + UnsignedContractCallOptions, + bufferCV, + bufferCVFromString, + callReadOnlyFunction, + createNonFungiblePostCondition, + createSTXPostCondition, + createStacksPublicKey, cvToString, getAddressFromPrivateKey, getCVTypeString, hash160, makeRandomPrivKey, makeUnsignedContractCall, - privateKeyToString, - ResponseErrorCV, - StacksTransaction, - standardPrincipalCV, - uintCV, - someCV, noneCV, - UnsignedContractCallOptions, - PostCondition, - createSTXPostCondition, - createStacksPublicKey, - publicKeyToAddress, - FungibleConditionCode, - AddressVersion, - createNonFungiblePostCondition, - NonFungibleConditionCode, parseAssetInfoString, + privateKeyToString, + publicKeyToAddress, + someCV, + standardPrincipalCV, tupleCV, - bufferCVFromString, + uintCV, } from '@stacks/transactions'; - -import { StacksNetwork } from '@stacks/network'; - import { decodeFQN, getZonefileHash } from './utils'; -import { ChainID } from '@stacks/common'; - export const BNS_CONTRACT_NAME = 'bns'; export const enum BnsContractAddress { @@ -97,7 +92,6 @@ async function makeBnsContractCall(options: BnsContractCallOptions): Promise { fetchMock.resetMocks(); jest.resetModules(); @@ -350,7 +344,6 @@ test('preorderNamespace', async () => { validateWithAbi: false, publicKey, network, - anchorMode: AnchorMode.Any, postConditions: [burnSTXPostCondition], }; @@ -444,7 +437,6 @@ test('revealNamespace', async () => { validateWithAbi: false, publicKey, network, - anchorMode: AnchorMode.Any, }; expect(makeUnsignedContractCall).toHaveBeenCalledTimes(1); @@ -492,7 +484,6 @@ test('importName', async () => { publicKey, network, validateWithAbi: false, - anchorMode: AnchorMode.Any, }; expect(makeUnsignedContractCall).toHaveBeenCalledTimes(1); @@ -529,7 +520,6 @@ test('readyNamespace', async () => { publicKey, network, validateWithAbi: false, - anchorMode: AnchorMode.Any, }; expect(makeUnsignedContractCall).toHaveBeenCalledTimes(1); @@ -577,7 +567,6 @@ test('preorderName', async () => { publicKey, network, validateWithAbi: false, - anchorMode: AnchorMode.Any, postConditions: [burnSTXPostCondition], }; @@ -626,7 +615,6 @@ test('registerName', async () => { publicKey, network, validateWithAbi: false, - anchorMode: AnchorMode.Any, }; expect(makeUnsignedContractCall).toHaveBeenCalledTimes(1); @@ -671,7 +659,6 @@ test('updateName', async () => { publicKey, network, validateWithAbi: false, - anchorMode: AnchorMode.Any, }; expect(makeUnsignedContractCall).toHaveBeenCalledTimes(1); @@ -738,7 +725,6 @@ test('transferName', async () => { publicKey, network, validateWithAbi: false, - anchorMode: AnchorMode.Any, postConditions: [nameTransferPostConditionOne, nameTransferPostConditionTwo], }; @@ -806,7 +792,6 @@ test('transferName optionalArguments', async () => { publicKey, network, validateWithAbi: false, - anchorMode: AnchorMode.Any, postConditions: [nameTransferPostConditionOne, nameTransferPostConditionTwo], }; @@ -846,7 +831,6 @@ test('revokeName', async () => { publicKey, network, validateWithAbi: false, - anchorMode: AnchorMode.Any, }; expect(makeUnsignedContractCall).toHaveBeenCalledTimes(1); @@ -901,7 +885,6 @@ test('renewName', async () => { publicKey, network, validateWithAbi: false, - anchorMode: AnchorMode.Any, postConditions: [burnSTXPostCondition], }; @@ -957,7 +940,6 @@ test('renewName optionalArguments', async () => { publicKey, network, validateWithAbi: false, - anchorMode: AnchorMode.Any, postConditions: [burnSTXPostCondition], }; diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index 5f542b27f..e977c7cbf 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -12,14 +12,14 @@ import { wordlist } from '@scure/bip39/wordlists/english'; import { buildPreorderNameTx, buildRegisterNameTx } from '@stacks/bns'; import { StacksMainnet, StacksTestnet } from '@stacks/network'; import { - AnchorMode, broadcastTransaction, callReadOnlyFunction, + Cl, ClarityAbi, ClarityValue, ContractCallPayload, - SignedContractDeployOptions, createStacksPrivateKey, + cvToJSON, cvToString, estimateContractDeploy, estimateContractFunctionCall, @@ -34,6 +34,7 @@ import { publicKeyToString, ReadOnlyFunctionOptions, SignedContractCallOptions, + SignedContractDeployOptions, SignedTokenTransferOptions, signWithKey, StacksTransaction, @@ -41,8 +42,6 @@ import { TransactionVersion, TxBroadcastResult, validateContractCall, - Cl, - cvToJSON, } from '@stacks/transactions'; import express from 'express'; import { prompt } from 'inquirer'; @@ -75,10 +74,10 @@ import { import { checkArgs, + CLI_ARGS, CLIOptAsBool, CLIOptAsString, CLIOptAsStringArray, - CLI_ARGS, DEFAULT_CONFIG_PATH, DEFAULT_CONFIG_TESTNET_PATH, getCLIOpts, @@ -92,7 +91,7 @@ import { import { decryptBackupPhrase, encryptBackupPhrase } from './encrypt'; -import { CLINetworkAdapter, CLI_NETWORK_OPTS, getNetwork, NameInfoType } from './network'; +import { CLI_NETWORK_OPTS, CLINetworkAdapter, getNetwork, NameInfoType } from './network'; import { gaiaAuth, gaiaConnect, gaiaUploadProfileAll, getGaiaAddressFromProfile } from './data'; @@ -715,7 +714,6 @@ async function sendTokens(network: CLINetworkAdapter, args: string[]): Promise { validateWithAbi: true, network, senderKey: privateKey, - anchorMode: AnchorMode.Any, }; expect(fetchMock.mock.calls[0][0]).toEqual(network.getPoxInfoUrl()); @@ -359,7 +357,6 @@ test('delegate stx', async () => { validateWithAbi: true, network, senderKey: privateKey, - anchorMode: AnchorMode.Any, }; expect(fetchMock.mock.calls[0][0]).toEqual(network.getPoxInfoUrl()); @@ -423,7 +420,6 @@ test('delegate stx with empty optional parameters', async () => { validateWithAbi: true, network, senderKey: privateKey, - anchorMode: AnchorMode.Any, }; expect(fetchMock.mock.calls[0][0]).toEqual(network.getPoxInfoUrl()); @@ -507,7 +503,6 @@ test('delegate stack stx with one delegator', async () => { validateWithAbi: true, network, senderKey: privateKey, - anchorMode: AnchorMode.Any, }; expect(fetchMock.mock.calls[0][0]).toEqual(network.getPoxInfoUrl()); @@ -593,7 +588,6 @@ test('delegate stack stx with set nonce', async () => { network, senderKey: privateKey, nonce, - anchorMode: AnchorMode.Any, }; expect(fetchMock.mock.calls[0][0]).toEqual(network.getPoxInfoUrl()); @@ -656,7 +650,6 @@ test('delegator commit', async () => { validateWithAbi: true, network, senderKey: privateKey, - anchorMode: AnchorMode.Any, }; expect(fetchMock.mock.calls[0][0]).toEqual(network.getPoxInfoUrl()); @@ -705,7 +698,6 @@ test('revoke delegate stx', async () => { validateWithAbi: true, network, senderKey: privateKey, - anchorMode: AnchorMode.Any, }; expect(fetchMock.mock.calls[0][0]).toEqual(network.getPoxInfoUrl()); diff --git a/packages/transactions/README.md b/packages/transactions/README.md index c2cfa64d4..82d4a2ed2 100644 --- a/packages/transactions/README.md +++ b/packages/transactions/README.md @@ -34,7 +34,7 @@ const privateKey = createStacksPrivateKey(key); ## STX Token Transfer Transaction ```typescript -import { makeSTXTokenTransfer, broadcastTransaction, AnchorMode } from '@stacks/transactions'; +import { makeSTXTokenTransfer, broadcastTransaction } from '@stacks/transactions'; const txOptions = { recipient: 'SP3FGQ8Z7JY9BWYZ5WM53E0M9NK7WHJF0691NZ159', @@ -44,7 +44,6 @@ const txOptions = { memo: 'test memo', nonce: 0n, // set a nonce manually if you don't want builder to fetch from a Stacks node fee: 200n, // set a tx fee if you don't want the builder to estimate - anchorMode: AnchorMode.Any, }; const transaction = await makeSTXTokenTransfer(txOptions); @@ -61,7 +60,7 @@ const txId = broadcastResponse.txid; ## Smart Contract Deploy Transaction ```typescript -import { makeContractDeploy, broadcastTransaction, AnchorMode } from '@stacks/transactions'; +import { makeContractDeploy, broadcastTransaction } from '@stacks/transactions'; import { StacksTestnet, StacksMainnet } from '@stacks/network'; import { readFileSync } from 'fs'; @@ -73,7 +72,6 @@ const txOptions = { codeBody: readFileSync('/path/to/contract.clar').toString(), senderKey: 'b244296d5907de9864c0b0d51f98a13c52890be0404e83f273144cd5b9960eed01', network, - anchorMode: AnchorMode.Any, }; const transaction = await makeContractDeploy(txOptions); @@ -88,7 +86,6 @@ const txId = broadcastResponse.txid; import { makeContractCall, broadcastTransaction, - AnchorMode, FungibleConditionCode, makeStandardSTXPostCondition, bufferCVFromString, @@ -116,7 +113,6 @@ const txOptions = { validateWithAbi: true, network, postConditions, - anchorMode: AnchorMode.Any, }; const transaction = await makeContractCall(txOptions); @@ -141,7 +137,7 @@ To generate a sponsored transaction, first create and sign the transaction as th ```typescript import { bytesToHex } from '@stacks/common'; -import { makeContractCall, BufferCV, AnchorMode, bufferCVFromString } from '@stacks/transactions'; +import { makeContractCall, BufferCV, bufferCVFromString } from '@stacks/transactions'; const txOptions = { contractAddress: 'SPBMRFRPPGCDE3F384WCJPK8PQJGZ8K9QKK7F59X', @@ -152,7 +148,6 @@ const txOptions = { senderKey: 'b244296d5907de9864c0b0d51f98a13c52890be0404e83f273144cd5b9960eed01', validateWithAbi: true, sponsored: true, - anchorMode: AnchorMode.Any, }; const transaction = await makeContractCall(txOptions); @@ -206,7 +201,6 @@ import { TransactionSigner, standardPrincipalCV, BytesReader, - AnchorMode, } from '@stacks/transactions'; const recipient = standardPrincipalCV('SP3FGQ8...'); @@ -233,7 +227,6 @@ const transaction = await makeUnsignedSTXTokenTransfer({ memo, numSignatures: 2, // number of signature required publicKeys: pubKeyStrings, // public key string array with >= numSignatures elements - anchorMode: AnchorMode.Any, }); const serializedTx = transaction.serialize(); diff --git a/packages/transactions/src/builders.ts b/packages/transactions/src/builders.ts index 24219d19d..1a9480b9e 100644 --- a/packages/transactions/src/builders.ts +++ b/packages/transactions/src/builders.ts @@ -21,7 +21,6 @@ import { ClarityValue, deserializeCV, NoneCV, PrincipalCV, serializeCV } from '. import { AddressHashMode, AddressVersion, - AnchorMode, FungibleConditionCode, NonFungibleConditionCode, PayloadType, @@ -32,7 +31,7 @@ import { RECOVERABLE_ECDSA_SIG_LENGTH_BYTES, StacksMessageType, ClarityVersion, - AnchorModeName, + AnchorMode, } from './constants'; import { ClarityAbi, validateContractCall } from './contract-abi'; import { NoEstimateAvailableError } from './errors'; @@ -601,9 +600,6 @@ export interface TokenTransferOptions { nonce?: IntegerType; /** the network that the transaction will ultimately be broadcast to */ network?: StacksNetworkName | StacksNetwork; - /** the transaction anchorMode, which specifies whether it should be - * included in an anchor block or a microblock */ - anchorMode: AnchorModeName | AnchorMode; /** an arbitrary string to include in the transaction, must be less than 34 bytes */ memo?: string; /** set to true if another account is sponsoring the transaction (covering the transaction fee) */ @@ -689,7 +685,7 @@ export async function makeUnsignedSTXTokenTransfer( payload, undefined, // no post conditions on STX transfers (see SIP-005) undefined, // no post conditions on STX transfers (see SIP-005) - options.anchorMode, + AnchorMode.Any, network.chainId ); @@ -769,9 +765,6 @@ export interface BaseContractDeployOptions { nonce?: IntegerType; /** the network that the transaction will ultimately be broadcast to */ network?: StacksNetworkName | StacksNetwork; - /** the transaction anchorMode, which specifies whether it should be - * included in an anchor block or a microblock */ - anchorMode: AnchorModeName | AnchorMode; /** the post condition mode, specifying whether or not post-conditions must fully cover all * transfered assets */ postConditionMode?: PostConditionMode; @@ -965,7 +958,7 @@ export async function makeUnsignedContractDeploy( payload, lpPostConditions, options.postConditionMode, - options.anchorMode, + AnchorMode.Any, network.chainId ); @@ -1003,9 +996,6 @@ export interface ContractCallOptions { nonce?: IntegerType; /** the Stacks blockchain network that will ultimately be used to broadcast this transaction */ network?: StacksNetworkName | StacksNetwork; - /** the transaction anchorMode, which specifies whether it should be - * included in an anchor block or a microblock */ - anchorMode: AnchorModeName | AnchorMode; /** the post condition mode, specifying whether or not post-conditions must fully cover all * transfered assets */ postConditionMode?: PostConditionMode; @@ -1172,7 +1162,7 @@ export async function makeUnsignedContractCall( payload, lpPostConditions, options.postConditionMode, - options.anchorMode, + AnchorMode.Any, network.chainId ); diff --git a/packages/transactions/src/constants.ts b/packages/transactions/src/constants.ts index 3df866834..50702b63b 100644 --- a/packages/transactions/src/constants.ts +++ b/packages/transactions/src/constants.ts @@ -79,6 +79,7 @@ export enum ClarityVersion { * * For more information about the kinds of Stacks blocks and the various * AnchorModes, check out {@link https://github.com/stacksgov/sips/blob/main/sips/sip-001/sip-001-burn-election.md SIP 001} and + * @deprecated `AnchorMode` is not needed in Stacks since the Nakamoto update. * {@link https://github.com/stacksgov/sips/blob/main/sips/sip-005/sip-005-blocks-and-transactions.md SIP 005} */ export enum AnchorMode { @@ -90,7 +91,9 @@ export enum AnchorMode { Any = 0x03, } +/** @deprecated `AnchorMode` is not needed in Stacks since the Nakamoto update. */ export const AnchorModeNames = ['onChainOnly', 'offChainOnly', 'any'] as const; +/** @deprecated `AnchorMode` is not needed in Stacks since the Nakamoto update. */ export type AnchorModeName = (typeof AnchorModeNames)[number]; const AnchorModeMap = { diff --git a/packages/transactions/src/transaction.ts b/packages/transactions/src/transaction.ts index 68d1ccbc5..60998042e 100644 --- a/packages/transactions/src/transaction.ts +++ b/packages/transactions/src/transaction.ts @@ -28,7 +28,6 @@ import { AuthType, ChainID, DEFAULT_CHAIN_ID, - PayloadType, PostConditionMode, PubKeyEncoding, StacksMessageType, @@ -73,25 +72,7 @@ export class StacksTransaction { this.postConditionMode = postConditionMode ?? PostConditionMode.Deny; this.postConditions = postConditions ?? createLPList([]); - if (anchorMode) { - this.anchorMode = anchorModeFromNameOrValue(anchorMode); - } else { - switch (payload.payloadType) { - case PayloadType.Coinbase: - case PayloadType.CoinbaseToAltRecipient: - case PayloadType.NakamotoCoinbase: - case PayloadType.PoisonMicroblock: - case PayloadType.TenureChange: - this.anchorMode = AnchorMode.OnChainOnly; - break; - case PayloadType.ContractCall: - case PayloadType.SmartContract: - case PayloadType.VersionedSmartContract: - case PayloadType.TokenTransfer: - this.anchorMode = AnchorMode.Any; - break; - } - } + this.anchorMode = anchorModeFromNameOrValue(anchorMode ?? AnchorMode.Any); } signBegin() { diff --git a/packages/transactions/tests/builder.test.ts b/packages/transactions/tests/builder.test.ts index 2920cd26a..fbe81313f 100644 --- a/packages/transactions/tests/builder.test.ts +++ b/packages/transactions/tests/builder.test.ts @@ -64,8 +64,6 @@ import { principalCV } from '../src/clarity/types/principalCV'; import { createMessageSignature } from '../src/common'; import { AddressHashMode, - AnchorMode, - AnchorModeName, AuthType, ClarityVersion, DEFAULT_CORE_NODE_API_URL, @@ -133,45 +131,6 @@ test('API key middleware - get nonce', async () => { expect(callHeaders.get('x-api-key')).toBe(apiKey); }); -const anchorModeNameCases: [AnchorModeName | AnchorMode, AnchorMode | null][] = [ - ['onChainOnly', AnchorMode.OnChainOnly], - ['offChainOnly', AnchorMode.OffChainOnly], - ['any', AnchorMode.Any], - [AnchorMode.OnChainOnly, AnchorMode.OnChainOnly], - [AnchorMode.OffChainOnly, AnchorMode.OffChainOnly], - [AnchorMode.Any, AnchorMode.Any], - ['invalid' as AnchorModeName, null], - [0x20 as AnchorMode, null], -]; - -test.each(anchorModeNameCases)( - 'Build transaction with AnchorMode name %p', - async (anchorModeName, anchorModeValue) => { - const recipient = standardPrincipalCV('SP3FGQ8Z7JY9BWYZ5WM53E0M9NK7WHJF0691NZ159'); - const amount = 12345; - const fee = 0; - const nonce = 0; - const senderKey = 'edf9aee84d9b7abc145504dde6726c64f369d37ee34ded868fabd876c26570bc01'; - const memo = 'test memo'; - const txOptions: SignedTokenTransferOptions = { - recipient, - amount, - senderKey, - fee, - nonce, - memo, - anchorMode: anchorModeName, - }; - if (anchorModeValue === null) { - expect.assertions(1); - await expect(makeSTXTokenTransfer(txOptions)).rejects.toThrow(/Invalid anchor mode/); - } else { - const transaction = await makeSTXTokenTransfer(txOptions); - expect(transaction.anchorMode).toBe(anchorModeValue); - } - } -); - test('Make STX token transfer with set tx fee', async () => { const recipient = standardPrincipalCV('SP3FGQ8Z7JY9BWYZ5WM53E0M9NK7WHJF0691NZ159'); const amount = 12345; @@ -187,7 +146,6 @@ test('Make STX token transfer with set tx fee', async () => { fee, nonce, memo, - anchorMode: AnchorMode.Any, }); expect(() => transaction.verifyOrigin()).not.toThrow(); @@ -245,7 +203,6 @@ test('Make STX token transfer with fee estimate', async () => { nonce, senderKey, memo, - anchorMode: AnchorMode.Any, }); expect(() => transaction.verifyOrigin()).not.toThrow(); @@ -280,7 +237,6 @@ test('Make STX token transfer with testnet', async () => { nonce, network: new StacksTestnet(), memo: memo, - anchorMode: AnchorMode.Any, }); expect(() => transaction.verifyOrigin()).not.toThrow(); @@ -304,7 +260,6 @@ test('Make STX token transfer with testnet string name', async () => { nonce: 0, network: 'testnet', memo: 'test memo', - anchorMode: AnchorMode.Any, }); expect(() => transaction.verifyOrigin()).not.toThrow(); @@ -328,7 +283,6 @@ test('Throws making STX token transder with invalid network name', async () => { nonce: 0, network: 'invalidnet', memo: 'test memo', - anchorMode: AnchorMode.Any, }; await expect( @@ -356,7 +310,6 @@ test("STX token transfers don't take post conditions", async () => { nonce, memo, postConditions, - anchorMode: AnchorMode.Any, } as SignedTokenTransferOptions); const serialized = transaction.serialize(); @@ -396,7 +349,6 @@ test('Make Multi-Sig STX token transfer', async () => { memo: memo, numSignatures: 2, publicKeys: pubKeyStrings, - anchorMode: AnchorMode.Any, }); const signer = new TransactionSigner(transaction); signer.signOrigin(privKeys[0]); @@ -472,7 +424,6 @@ test('Should deserialize partially signed multi-Sig STX token transfer', async ( memo: memo, numSignatures: 2, publicKeys: pubKeyStrings, - anchorMode: AnchorMode.Any, }); const serializedTx = transaction.serialize(); @@ -550,7 +501,6 @@ test('Should throw error if multisig transaction is oversigned', async () => { memo: memo, numSignatures: 2, publicKeys: pubKeyStrings, - anchorMode: AnchorMode.Any, }); const signer = new TransactionSigner(transaction); @@ -595,7 +545,6 @@ test('Make Multi-Sig STX token transfer with two transaction signers', async () memo: memo, numSignatures: 2, publicKeys: pubKeyStrings, - anchorMode: AnchorMode.Any, }); const serializedTxUnsigned = transaction.serialize(); @@ -697,7 +646,6 @@ test('addSignature to an unsigned transaction', async () => { fee, nonce, publicKey, - anchorMode: AnchorMode.Any, }); const nullSignature = (unsignedTx.auth.spendingCondition as any).signature.data; @@ -729,7 +677,6 @@ test('Make versioned smart contract deploy', async () => { fee, nonce, network: new StacksTestnet(), - anchorMode: AnchorMode.Any, clarityVersion: ClarityVersion.Clarity2, }); expect(() => transaction.verifyOrigin()).not.toThrow(); @@ -756,7 +703,6 @@ test('Make smart contract deploy (defaults to versioned smart contract, as of 2. fee, nonce, network: new StacksTestnet(), - anchorMode: AnchorMode.Any, }); expect(() => transaction.verifyOrigin()).not.toThrow(); @@ -776,7 +722,6 @@ test('Make smart contract deploy with network string name (defaults to versioned fee: 0, nonce: 0, network: 'testnet', - anchorMode: AnchorMode.Any, }); expect(() => transaction.verifyOrigin()).not.toThrow(); @@ -804,7 +749,6 @@ test('Make smart contract deploy unsigned', async () => { fee, nonce, network: new StacksTestnet(), - anchorMode: AnchorMode.Any, }); const serializedTx = transaction.serialize(); @@ -842,7 +786,6 @@ test('make a multi-sig contract deploy', async () => { fee, nonce, network: new StacksTestnet(), - anchorMode: AnchorMode.Any, }); expect(() => transaction.verifyOrigin()).not.toThrow(); expect(transaction.auth.spendingCondition!.signer).toEqual( @@ -866,7 +809,6 @@ test('Make smart contract deploy signed', async () => { fee, nonce, network: new StacksTestnet(), - anchorMode: AnchorMode.Any, }); expect(() => transaction.verifyOrigin()).not.toThrow(); @@ -899,7 +841,6 @@ test('Make contract-call', async () => { fee, nonce: 1, network: new StacksTestnet(), - anchorMode: AnchorMode.Any, }); expect(() => transaction.verifyOrigin()).not.toThrow(); @@ -924,7 +865,6 @@ test('Make contract-call with network string', async () => { fee: 0, nonce: 1, network: 'testnet', - anchorMode: AnchorMode.Any, }); expect(() => transaction.verifyOrigin()).not.toThrow(); @@ -996,7 +936,6 @@ test('Make contract-call with post conditions', async () => { network: new StacksTestnet(), postConditions, postConditionMode: PostConditionMode.Deny, - anchorMode: AnchorMode.Any, }); expect(() => transaction.verifyOrigin()).not.toThrow(); @@ -1041,7 +980,6 @@ test('Make contract-call with post condition allow mode', async () => { nonce: 1, network: new StacksTestnet(), postConditionMode: PostConditionMode.Allow, - anchorMode: AnchorMode.Any, }); expect(() => transaction.verifyOrigin()).not.toThrow(); @@ -1074,7 +1012,6 @@ test('addSignature to an unsigned contract call transaction', async () => { nonce: 1, network: new StacksTestnet(), postConditionMode: PostConditionMode.Allow, - anchorMode: AnchorMode.Any, }); const nullSignature = (unsignedTx.auth.spendingCondition as any).signature.data; @@ -1119,7 +1056,6 @@ test('make a multi-sig contract call', async () => { nonce: 1, network: new StacksTestnet(), postConditionMode: PostConditionMode.Allow, - anchorMode: AnchorMode.Any, }); expect(() => transaction.verifyOrigin()).not.toThrow(); @@ -1144,7 +1080,6 @@ test('Estimate transaction transfer fee', async () => { fee, nonce, memo, - anchorMode: AnchorMode.Any, }); const serialized = transaction.serialize(); @@ -1233,7 +1168,6 @@ test('Estimate transaction fee fallback', async () => { contractName: 'pox-2', functionName: 'delegate-stx', functionArgs: [uintCV(100_000), principalCV(poolAddress), noneCV(), noneCV()], - anchorMode: AnchorMode.OnChainOnly, nonce: 1, network, }); @@ -1303,7 +1237,6 @@ test('Single-sig transaction byte length must include signature', async () => { nonce, memo: memo, publicKey: publicKey, - anchorMode: AnchorMode.Any, }); // Due to empty message signature space will be allocated for signature @@ -1354,7 +1287,6 @@ test('Multi-sig transaction byte length must include the required signatures', a memo: memo, numSignatures: 3, publicKeys: pubKeyStrings, - anchorMode: AnchorMode.Any, }); // Total length without signatures @@ -1417,7 +1349,6 @@ test('Make STX token transfer with fetch account nonce', async () => { fee, memo, network, - anchorMode: AnchorMode.Any, }); expect(fetchMock.mock.calls.length).toEqual(2); @@ -1450,7 +1381,6 @@ test('Make sponsored STX token transfer', async () => { nonce, memo: memo, sponsored: true, - anchorMode: AnchorMode.Any, }); const preSponsorSerialized = bytesToHex(transaction.serialize()); @@ -1575,7 +1505,6 @@ test('Make sponsored STX token transfer with sponsor fee estimate', async () => nonce, memo: memo, sponsored: true, - anchorMode: AnchorMode.Any, }); const sponsorOptions = { @@ -1661,7 +1590,6 @@ test('Make sponsored STX token transfer with set tx fee', async () => { nonce, network, sponsored: true, - anchorMode: AnchorMode.Any, }); const sponsorOptions = { @@ -1716,7 +1644,6 @@ test('Make sponsored contract deploy with sponsor fee estimate', async () => { nonce, network, sponsored: true, - anchorMode: AnchorMode.Any, }); const sponsorOptions = { @@ -1777,7 +1704,6 @@ test('Make sponsored contract call with sponsor nonce fetch', async () => { nonce, network, sponsored: true, - anchorMode: AnchorMode.Any, }); const sponsorOptions = { @@ -1829,7 +1755,6 @@ test('Transaction broadcast success', async () => { fee, nonce, memo, - anchorMode: AnchorMode.Any, }); fetchMock.mockOnce('success'); @@ -1851,7 +1776,6 @@ test('Transaction broadcast success with string network name', async () => { fee: 0, nonce: 0, memo: 'test memo', - anchorMode: AnchorMode.Any, }); fetchMock.mockOnce('success'); @@ -1873,7 +1797,6 @@ test('Transaction broadcast success with network detection', async () => { fee: 0, nonce: 0, memo: 'test memo', - anchorMode: AnchorMode.Any, }); fetchMock.mockOnce('success'); @@ -1904,7 +1827,6 @@ test('Transaction broadcast with attachment', async () => { fee, nonce, memo, - anchorMode: AnchorMode.Any, }); fetchMock.mockOnce('success'); @@ -1939,7 +1861,6 @@ test('Transaction broadcast returns error', async () => { fee, nonce, memo, - anchorMode: AnchorMode.Any, }); const rejection = { @@ -1978,7 +1899,6 @@ test('Transaction broadcast fails', async () => { fee, nonce, memo, - anchorMode: AnchorMode.Any, }); fetchMock.mockOnce('test', { status: 400 }); @@ -2011,7 +1931,6 @@ test('Make contract-call with network ABI validation', async () => { network: new StacksTestnet(), validateWithAbi: true, postConditionMode: PostConditionMode.Allow, - anchorMode: AnchorMode.Any, }); expect(fetchMock.mock.calls.length).toEqual(1); @@ -2039,7 +1958,6 @@ test('Make contract-call with provided ABI validation', async () => { nonce: 1, validateWithAbi: abi, postConditionMode: PostConditionMode.Allow, - anchorMode: AnchorMode.Any, }); }); @@ -2069,7 +1987,6 @@ test('Make contract-call with network ABI validation failure', async () => { network: 'testnet', validateWithAbi: true, postConditionMode: PostConditionMode.Allow, - anchorMode: AnchorMode.Any, }); } catch (e) { error = e; @@ -2197,7 +2114,6 @@ test('StacksTransaction serialize/deserialize equality with an empty memo', asyn nonce: 0n, memo: '', // empty memo network: new StacksMainnet(), - anchorMode: AnchorMode.Any, senderKey: 'edf9aee84d9b7abc145504dde6726c64f369d37ee34ded868fabd876c26570bc01', }; const tx = await makeSTXTokenTransfer(options); @@ -2216,7 +2132,6 @@ test('StacksTransaction serialize/deserialize equality with a memo', async () => nonce: 0n, memo: 'Memento Mori', network: new StacksMainnet(), - anchorMode: AnchorMode.Any, senderKey: 'edf9aee84d9b7abc145504dde6726c64f369d37ee34ded868fabd876c26570bc01', }; const tx = await makeSTXTokenTransfer(options); @@ -2235,7 +2150,6 @@ test('StacksTransaction serialize/deserialize equality with a memo ending in a z nonce: 0n, memo: bytesToUtf8(hexToBytes('0')), // null character network: new StacksMainnet(), - anchorMode: AnchorMode.Any, senderKey: 'edf9aee84d9b7abc145504dde6726c64f369d37ee34ded868fabd876c26570bc01', }; const tx = await makeSTXTokenTransfer(options); diff --git a/packages/transactions/tests/fetchUtil.test.ts b/packages/transactions/tests/fetchUtil.test.ts index d2702be1c..86da74ba3 100644 --- a/packages/transactions/tests/fetchUtil.test.ts +++ b/packages/transactions/tests/fetchUtil.test.ts @@ -1,7 +1,6 @@ import { createApiKeyMiddleware, createFetchFn, StacksTestnet } from '@stacks/network'; import fetchMock from 'jest-fetch-mock'; import { broadcastTransaction, makeSTXTokenTransfer } from '../src/builders'; -import { AnchorMode } from '../src/constants'; test('fetchFn is used in network requests', async () => { const apiKey = 'MY_KEY'; @@ -16,7 +15,6 @@ test('fetchFn is used in network requests', async () => { nonce: 0, senderKey: 'edf9aee84d9b7abc145504dde6726c64f369d37ee34ded868fabd876c26570bc01', memo: 'test memo', - anchorMode: AnchorMode.Any, }); fetchMock.mockOnce('success');