mirror of
https://github.com/alexgo-io/stacks.js.git
synced 2026-05-07 04:49:59 +08:00
refactor: export method directly
This commit is contained in:
@@ -5,6 +5,8 @@ import { IntCV, UIntCV, intCV, uintCV } from './types/intCV';
|
||||
import { BufferCV, bufferCV, bufferCVFromString } from './types/bufferCV';
|
||||
import { OptionalCV, NoneCV, SomeCV, noneCV, someCV, optionalCVOf } from './types/optionalCV';
|
||||
|
||||
// todo: reduce manual re-exporting
|
||||
|
||||
import {
|
||||
ResponseCV,
|
||||
ResponseOkCV,
|
||||
@@ -23,6 +25,7 @@ import {
|
||||
PrincipalCV,
|
||||
contractPrincipalCVFromStandard,
|
||||
principalCV,
|
||||
principalToString,
|
||||
} from './types/principalCV';
|
||||
|
||||
import { ListCV, listCV } from './types/listCV';
|
||||
@@ -94,4 +97,4 @@ export {
|
||||
export { serializeCV, deserializeCV };
|
||||
|
||||
// toString
|
||||
export { cvToString, cvToJSON, cvToValue };
|
||||
export { cvToString, cvToJSON, cvToValue, principalToString };
|
||||
|
||||
@@ -15,7 +15,7 @@ interface ContractPrincipalCV {
|
||||
readonly address: Address;
|
||||
readonly contractName: LengthPrefixedString;
|
||||
}
|
||||
|
||||
/** Returns a string in the format `address` or `address.contract-name` from a principal (standard or contract) */
|
||||
function principalToString(principal: PrincipalCV): string {
|
||||
if (principal.type === ClarityType.PrincipalStandard) {
|
||||
return addressToString(principal.address);
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
import { utf8ToBytes } from '@stacks/common';
|
||||
import {
|
||||
contractPrincipalCV,
|
||||
falseCV,
|
||||
principalToString,
|
||||
standardPrincipalCV,
|
||||
trueCV,
|
||||
} from '../src/clarity';
|
||||
import { ClarityVersion, StacksMessageType } from '../src/constants';
|
||||
import {
|
||||
CoinbasePayload,
|
||||
CoinbasePayloadToAltRecipient,
|
||||
@@ -10,15 +19,8 @@ import {
|
||||
TokenTransferPayload,
|
||||
VersionedSmartContractPayload,
|
||||
} from '../src/payload';
|
||||
|
||||
import { serializeDeserialize } from './macros';
|
||||
|
||||
import { contractPrincipalCV, falseCV, standardPrincipalCV, trueCV } from '../src/clarity';
|
||||
|
||||
import { utf8ToBytes } from '@stacks/common';
|
||||
import { principalToString } from '../src/clarity/types/principalCV';
|
||||
import { ClarityVersion, StacksMessageType } from '../src/constants';
|
||||
|
||||
test('STX token transfer payload serialization and deserialization', () => {
|
||||
const recipient = standardPrincipalCV('SP3FGQ8Z7JY9BWYZ5WM53E0M9NK7WHJF0691NZ159');
|
||||
const amount = 2500000;
|
||||
|
||||
Reference in New Issue
Block a user