Skip to content

Commit

Permalink
feat!: remove optional anchor mode from transaction options
Browse files Browse the repository at this point in the history
  • Loading branch information
janniks committed Mar 11, 2024
1 parent 2af8f23 commit 89eb6ea
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 223 deletions.
46 changes: 20 additions & 26 deletions packages/bns/src/index.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -97,7 +92,6 @@ async function makeBnsContractCall(options: BnsContractCallOptions): Promise<Sta
publicKey: options.publicKey,
validateWithAbi: false,
network: options.network,
anchorMode: AnchorMode.Any,
postConditions: options.postConditions,
};

Expand Down
54 changes: 18 additions & 36 deletions packages/bns/tests/bns.test.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,31 @@
import fetchMock from 'jest-fetch-mock';

import { ChainID, utf8ToBytes } from '@stacks/common';
import { StacksNetwork, StacksTestnet } from '@stacks/network';
import {
responseOkCV,
responseErrorCV,
trueCV,
falseCV,
uintCV,
AddressVersion,
FungibleConditionCode,
NonFungibleConditionCode,
bufferCV,
hash160,
standardPrincipalCV,
noneCV,
AnchorMode,
someCV,
bufferCVFromString,
createNonFungiblePostCondition,
createSTXPostCondition,
publicKeyToAddress,
createStacksPublicKey,
FungibleConditionCode,
AddressVersion,
createNonFungiblePostCondition,
NonFungibleConditionCode,
falseCV,
hash160,
noneCV,
parseAssetInfoString,
publicKeyToAddress,
responseErrorCV,
responseOkCV,
someCV,
standardPrincipalCV,
trueCV,
tupleCV,
bufferCVFromString,
uintCV,
} from '@stacks/transactions';

import { StacksNetwork, StacksTestnet } from '@stacks/network';

import fetchMock from 'jest-fetch-mock';
import { BNS_CONTRACT_NAME, BnsContractAddress, PriceFunction } from '../src';

import { decodeFQN, getZonefileHash } from '../src/utils';

import { ChainID, utf8ToBytes } from '@stacks/common';

beforeEach(() => {
fetchMock.resetMocks();
jest.resetModules();
Expand Down Expand Up @@ -350,7 +344,6 @@ test('preorderNamespace', async () => {
validateWithAbi: false,
publicKey,
network,
anchorMode: AnchorMode.Any,
postConditions: [burnSTXPostCondition],
};

Expand Down Expand Up @@ -444,7 +437,6 @@ test('revealNamespace', async () => {
validateWithAbi: false,
publicKey,
network,
anchorMode: AnchorMode.Any,
};

expect(makeUnsignedContractCall).toHaveBeenCalledTimes(1);
Expand Down Expand Up @@ -492,7 +484,6 @@ test('importName', async () => {
publicKey,
network,
validateWithAbi: false,
anchorMode: AnchorMode.Any,
};

expect(makeUnsignedContractCall).toHaveBeenCalledTimes(1);
Expand Down Expand Up @@ -529,7 +520,6 @@ test('readyNamespace', async () => {
publicKey,
network,
validateWithAbi: false,
anchorMode: AnchorMode.Any,
};

expect(makeUnsignedContractCall).toHaveBeenCalledTimes(1);
Expand Down Expand Up @@ -577,7 +567,6 @@ test('preorderName', async () => {
publicKey,
network,
validateWithAbi: false,
anchorMode: AnchorMode.Any,
postConditions: [burnSTXPostCondition],
};

Expand Down Expand Up @@ -626,7 +615,6 @@ test('registerName', async () => {
publicKey,
network,
validateWithAbi: false,
anchorMode: AnchorMode.Any,
};

expect(makeUnsignedContractCall).toHaveBeenCalledTimes(1);
Expand Down Expand Up @@ -671,7 +659,6 @@ test('updateName', async () => {
publicKey,
network,
validateWithAbi: false,
anchorMode: AnchorMode.Any,
};

expect(makeUnsignedContractCall).toHaveBeenCalledTimes(1);
Expand Down Expand Up @@ -738,7 +725,6 @@ test('transferName', async () => {
publicKey,
network,
validateWithAbi: false,
anchorMode: AnchorMode.Any,
postConditions: [nameTransferPostConditionOne, nameTransferPostConditionTwo],
};

Expand Down Expand Up @@ -806,7 +792,6 @@ test('transferName optionalArguments', async () => {
publicKey,
network,
validateWithAbi: false,
anchorMode: AnchorMode.Any,
postConditions: [nameTransferPostConditionOne, nameTransferPostConditionTwo],
};

Expand Down Expand Up @@ -846,7 +831,6 @@ test('revokeName', async () => {
publicKey,
network,
validateWithAbi: false,
anchorMode: AnchorMode.Any,
};

expect(makeUnsignedContractCall).toHaveBeenCalledTimes(1);
Expand Down Expand Up @@ -901,7 +885,6 @@ test('renewName', async () => {
publicKey,
network,
validateWithAbi: false,
anchorMode: AnchorMode.Any,
postConditions: [burnSTXPostCondition],
};

Expand Down Expand Up @@ -957,7 +940,6 @@ test('renewName optionalArguments', async () => {
publicKey,
network,
validateWithAbi: false,
anchorMode: AnchorMode.Any,
postConditions: [burnSTXPostCondition],
};

Expand Down
14 changes: 5 additions & 9 deletions packages/cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -34,15 +34,14 @@ import {
publicKeyToString,
ReadOnlyFunctionOptions,
SignedContractCallOptions,
SignedContractDeployOptions,
SignedTokenTransferOptions,
signWithKey,
StacksTransaction,
TransactionSigner,
TransactionVersion,
TxBroadcastResult,
validateContractCall,
Cl,
cvToJSON,
} from '@stacks/transactions';
import express from 'express';
import { prompt } from 'inquirer';
Expand Down Expand Up @@ -75,10 +74,10 @@ import {

import {
checkArgs,
CLI_ARGS,
CLIOptAsBool,
CLIOptAsString,
CLIOptAsStringArray,
CLI_ARGS,
DEFAULT_CONFIG_PATH,
DEFAULT_CONFIG_TESTNET_PATH,
getCLIOpts,
Expand All @@ -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';

Expand Down Expand Up @@ -715,7 +714,6 @@ async function sendTokens(network: CLINetworkAdapter, args: string[]): Promise<s
nonce,
memo,
network: txNetwork,
anchorMode: AnchorMode.Any,
};

const tx: StacksTransaction = await makeSTXTokenTransfer(options);
Expand Down Expand Up @@ -776,7 +774,6 @@ async function contractDeploy(network: CLINetworkAdapter, args: string[]): Promi
nonce,
network: txNetwork,
postConditionMode: PostConditionMode.Allow,
anchorMode: AnchorMode.Any,
};

const tx = await makeContractDeploy(options);
Expand Down Expand Up @@ -858,7 +855,6 @@ async function contractFunctionCall(network: CLINetworkAdapter, args: string[]):
nonce,
network: txNetwork,
postConditionMode: PostConditionMode.Allow,
anchorMode: AnchorMode.Any,
};

return makeContractCall(options);
Expand Down
12 changes: 0 additions & 12 deletions packages/stacking/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
BurnchainRewardsTotal,
} from '@stacks/stacks-blockchain-api-types';
import {
AnchorMode,
BufferCV,
ClarityType,
ClarityValue,
Expand Down Expand Up @@ -1023,7 +1022,6 @@ export class StackingClient {
functionArgs: [uintCV(amountMicroStx), address, uintCV(burnBlockHeight), uintCV(cycles)],
validateWithAbi: true,
network: this.network,
anchorMode: AnchorMode.Any,
};
return callOptions;
}
Expand All @@ -1046,7 +1044,6 @@ export class StackingClient {
functionArgs: [uintCV(extendCycles), address],
validateWithAbi: true,
network: this.network,
anchorMode: AnchorMode.Any,
};
return callOptions;
}
Expand All @@ -1060,7 +1057,6 @@ export class StackingClient {
functionArgs: [uintCV(increaseBy)],
validateWithAbi: true,
network: this.network,
anchorMode: AnchorMode.Any,
};
return callOptions;
}
Expand Down Expand Up @@ -1092,7 +1088,6 @@ export class StackingClient {
],
validateWithAbi: true,
network: this.network,
anchorMode: AnchorMode.Any,
};
return callOptions;
}
Expand Down Expand Up @@ -1127,7 +1122,6 @@ export class StackingClient {
],
validateWithAbi: true,
network: this.network,
anchorMode: AnchorMode.Any,
};

return callOptions;
Expand All @@ -1153,7 +1147,6 @@ export class StackingClient {
functionArgs: [principalCV(stacker), address, uintCV(extendCount)],
validateWithAbi: true,
network: this.network,
anchorMode: AnchorMode.Any,
};

return callOptions;
Expand All @@ -1179,7 +1172,6 @@ export class StackingClient {
functionArgs: [principalCV(stacker), address, uintCV(increaseBy)],
validateWithAbi: true,
network: this.network,
anchorMode: AnchorMode.Any,
};

return callOptions;
Expand All @@ -1203,7 +1195,6 @@ export class StackingClient {
functionArgs: [address, uintCV(rewardCycle)],
validateWithAbi: true,
network: this.network,
anchorMode: AnchorMode.Any,
};
return callOptions;
}
Expand All @@ -1228,7 +1219,6 @@ export class StackingClient {
functionArgs: [address, uintCV(rewardCycle), uintCV(rewardCycleIndex)],
validateWithAbi: true,
network: this.network,
anchorMode: AnchorMode.Any,
};
return callOptions;
}
Expand All @@ -1251,7 +1241,6 @@ export class StackingClient {
functionArgs: [address, uintCV(rewardCycle)],
validateWithAbi: true,
network: this.network,
anchorMode: AnchorMode.Any,
};
return callOptions;
}
Expand All @@ -1265,7 +1254,6 @@ export class StackingClient {
functionArgs: [],
validateWithAbi: true,
network: this.network,
anchorMode: AnchorMode.Any,
};
return callOptions;
}
Expand Down
Loading

0 comments on commit 89eb6ea

Please sign in to comment.