@stacks/bns
Advanced tools
Comparing version 6.14.1-pr.44 to 6.14.1-pr.64
@@ -1,4 +0,4 @@ | ||
import { IntegerType } from '@stacks/common'; | ||
import { IntegerType, PublicKey } from '@stacks/common'; | ||
import { StacksNetwork } from '@stacks/network'; | ||
import { ClarityValue, PostConditionWire, StacksTransaction } from '@stacks/transactions'; | ||
import { ClarityValue, PostCondition, StacksTransaction } from '@stacks/transactions'; | ||
export declare const BNS_CONTRACT_NAME = "bns"; | ||
@@ -30,5 +30,5 @@ export interface PriceFunction { | ||
functionArgs: ClarityValue[]; | ||
publicKey: string; | ||
publicKey: PublicKey; | ||
network: StacksNetwork; | ||
postConditions?: PostConditionWire[]; | ||
postConditions?: PostCondition[]; | ||
} | ||
@@ -93,3 +93,3 @@ export interface BnsReadOnlyOptions { | ||
stxToBurn: IntegerType; | ||
publicKey: string; | ||
publicKey: PublicKey; | ||
network: StacksNetwork; | ||
@@ -102,3 +102,3 @@ } | ||
zonefile: string; | ||
publicKey: string; | ||
publicKey: PublicKey; | ||
network: StacksNetwork; | ||
@@ -105,0 +105,0 @@ } |
@@ -1,3 +0,3 @@ | ||
import { utf8ToBytes } from '@stacks/common'; | ||
import { ClarityType, FungibleConditionCode, NonFungibleConditionCode, bufferCV, bufferCVFromString, callReadOnlyFunction, createNonFungiblePostCondition, createSTXPostCondition, cvToString, getAddressFromPrivateKey, getCVTypeString, hash160, makeRandomPrivKey, makeUnsignedContractCall, noneCV, parseAssetString, publicKeyToAddress, someCV, standardPrincipalCV, tupleCV, uintCV, } from '@stacks/transactions'; | ||
import { intToBigInt, utf8ToBytes } from '@stacks/common'; | ||
import { ClarityType, bufferCV, bufferCVFromString, cvToString, fetchCallReadOnlyFunction, getAddressFromPrivateKey, getCVTypeString, hash160, makeRandomPrivKey, makeUnsignedContractCall, noneCV, publicKeyToAddress, someCV, standardPrincipalCV, tupleCV, uintCV, } from '@stacks/transactions'; | ||
import { decodeFQN, getZonefileHash } from './utils'; | ||
@@ -19,3 +19,3 @@ export const BNS_CONTRACT_NAME = 'bns'; | ||
async function callReadOnlyBnsFunction(options) { | ||
return callReadOnlyFunction({ | ||
return fetchCallReadOnlyFunction({ | ||
contractAddress: options.network.bootAddress, | ||
@@ -63,3 +63,3 @@ contractName: BNS_CONTRACT_NAME, | ||
if (responseCV.value.type === ClarityType.Int || responseCV.value.type === ClarityType.UInt) { | ||
return responseCV.value.value; | ||
return BigInt(responseCV.value.value); | ||
} | ||
@@ -94,3 +94,3 @@ else { | ||
if (responseCV.value.type === ClarityType.Int || responseCV.value.type === ClarityType.UInt) { | ||
return responseCV.value.value; | ||
return BigInt(responseCV.value.value); | ||
} | ||
@@ -111,3 +111,8 @@ else { | ||
const hashedSaltedNamespace = hash160(saltedNamespaceBytes); | ||
const burnSTXPostCondition = createSTXPostCondition(publicKeyToAddress(network.addressVersion.singleSig, publicKey), FungibleConditionCode.Equal, stxToBurn); | ||
const burnSTXPostCondition = { | ||
type: 'stx-postcondition', | ||
address: publicKeyToAddress(network.addressVersion.singleSig, publicKey), | ||
condition: 'eq', | ||
amount: intToBigInt(stxToBurn), | ||
}; | ||
return makeBnsContractCall({ | ||
@@ -187,3 +192,8 @@ functionName: bnsFunctionName, | ||
const hashedSaltedName = hash160(saltedNamesBytes); | ||
const burnSTXPostCondition = createSTXPostCondition(publicKeyToAddress(network.addressVersion.singleSig, publicKey), FungibleConditionCode.Equal, stxToBurn); | ||
const burnSTXPostCondition = { | ||
type: 'stx-postcondition', | ||
address: publicKeyToAddress(network.addressVersion.singleSig, publicKey), | ||
condition: 'eq', | ||
amount: intToBigInt(stxToBurn), | ||
}; | ||
return makeBnsContractCall({ | ||
@@ -242,10 +252,22 @@ functionName: bnsFunctionName, | ||
]; | ||
const postConditionSender = createNonFungiblePostCondition(publicKeyToAddress(network.addressVersion.singleSig, publicKey), NonFungibleConditionCode.Sends, parseAssetString(`${network.bootAddress}.bns::names`), tupleCV({ | ||
name: bufferCVFromString(name), | ||
namespace: bufferCVFromString(namespace), | ||
})); | ||
const postConditionReceiver = createNonFungiblePostCondition(newOwnerAddress, NonFungibleConditionCode.DoesNotSend, parseAssetString(`${network.bootAddress}.bns::names`), tupleCV({ | ||
name: bufferCVFromString(name), | ||
namespace: bufferCVFromString(namespace), | ||
})); | ||
const postConditionSender = { | ||
type: 'nft-postcondition', | ||
address: publicKeyToAddress(network.addressVersion.singleSig, publicKey), | ||
condition: 'sent', | ||
asset: `${network.bootAddress}.bns::names`, | ||
assetId: tupleCV({ | ||
name: bufferCVFromString(name), | ||
namespace: bufferCVFromString(namespace), | ||
}), | ||
}; | ||
const postConditionReceiver = { | ||
type: 'nft-postcondition', | ||
address: newOwnerAddress, | ||
condition: 'not-sent', | ||
asset: `${network.bootAddress}.bns::names`, | ||
assetId: tupleCV({ | ||
name: bufferCVFromString(name), | ||
namespace: bufferCVFromString(namespace), | ||
}), | ||
}; | ||
return makeBnsContractCall({ | ||
@@ -285,3 +307,8 @@ functionName: bnsFunctionName, | ||
]; | ||
const burnSTXPostCondition = createSTXPostCondition(publicKeyToAddress(network.addressVersion.singleSig, publicKey), FungibleConditionCode.Equal, stxToBurn); | ||
const burnSTXPostCondition = { | ||
type: 'stx-postcondition', | ||
address: publicKeyToAddress(network.addressVersion.singleSig, publicKey), | ||
condition: 'eq', | ||
amount: intToBigInt(stxToBurn), | ||
}; | ||
return makeBnsContractCall({ | ||
@@ -288,0 +315,0 @@ functionName: bnsFunctionName, |
@@ -1,4 +0,4 @@ | ||
import { IntegerType } from '@stacks/common'; | ||
import { IntegerType, PublicKey } from '@stacks/common'; | ||
import { StacksNetwork } from '@stacks/network'; | ||
import { ClarityValue, PostConditionWire, StacksTransaction } from '@stacks/transactions'; | ||
import { ClarityValue, PostCondition, StacksTransaction } from '@stacks/transactions'; | ||
export declare const BNS_CONTRACT_NAME = "bns"; | ||
@@ -30,5 +30,5 @@ export interface PriceFunction { | ||
functionArgs: ClarityValue[]; | ||
publicKey: string; | ||
publicKey: PublicKey; | ||
network: StacksNetwork; | ||
postConditions?: PostConditionWire[]; | ||
postConditions?: PostCondition[]; | ||
} | ||
@@ -93,3 +93,3 @@ export interface BnsReadOnlyOptions { | ||
stxToBurn: IntegerType; | ||
publicKey: string; | ||
publicKey: PublicKey; | ||
network: StacksNetwork; | ||
@@ -102,3 +102,3 @@ } | ||
zonefile: string; | ||
publicKey: string; | ||
publicKey: PublicKey; | ||
network: StacksNetwork; | ||
@@ -105,0 +105,0 @@ } |
@@ -22,3 +22,3 @@ "use strict"; | ||
async function callReadOnlyBnsFunction(options) { | ||
return (0, transactions_1.callReadOnlyFunction)({ | ||
return (0, transactions_1.fetchCallReadOnlyFunction)({ | ||
contractAddress: options.network.bootAddress, | ||
@@ -67,3 +67,3 @@ contractName: exports.BNS_CONTRACT_NAME, | ||
if (responseCV.value.type === transactions_1.ClarityType.Int || responseCV.value.type === transactions_1.ClarityType.UInt) { | ||
return responseCV.value.value; | ||
return BigInt(responseCV.value.value); | ||
} | ||
@@ -99,3 +99,3 @@ else { | ||
if (responseCV.value.type === transactions_1.ClarityType.Int || responseCV.value.type === transactions_1.ClarityType.UInt) { | ||
return responseCV.value.value; | ||
return BigInt(responseCV.value.value); | ||
} | ||
@@ -117,3 +117,8 @@ else { | ||
const hashedSaltedNamespace = (0, transactions_1.hash160)(saltedNamespaceBytes); | ||
const burnSTXPostCondition = (0, transactions_1.createSTXPostCondition)((0, transactions_1.publicKeyToAddress)(network.addressVersion.singleSig, publicKey), transactions_1.FungibleConditionCode.Equal, stxToBurn); | ||
const burnSTXPostCondition = { | ||
type: 'stx-postcondition', | ||
address: (0, transactions_1.publicKeyToAddress)(network.addressVersion.singleSig, publicKey), | ||
condition: 'eq', | ||
amount: (0, common_1.intToBigInt)(stxToBurn), | ||
}; | ||
return makeBnsContractCall({ | ||
@@ -197,3 +202,8 @@ functionName: bnsFunctionName, | ||
const hashedSaltedName = (0, transactions_1.hash160)(saltedNamesBytes); | ||
const burnSTXPostCondition = (0, transactions_1.createSTXPostCondition)((0, transactions_1.publicKeyToAddress)(network.addressVersion.singleSig, publicKey), transactions_1.FungibleConditionCode.Equal, stxToBurn); | ||
const burnSTXPostCondition = { | ||
type: 'stx-postcondition', | ||
address: (0, transactions_1.publicKeyToAddress)(network.addressVersion.singleSig, publicKey), | ||
condition: 'eq', | ||
amount: (0, common_1.intToBigInt)(stxToBurn), | ||
}; | ||
return makeBnsContractCall({ | ||
@@ -255,10 +265,22 @@ functionName: bnsFunctionName, | ||
]; | ||
const postConditionSender = (0, transactions_1.createNonFungiblePostCondition)((0, transactions_1.publicKeyToAddress)(network.addressVersion.singleSig, publicKey), transactions_1.NonFungibleConditionCode.Sends, (0, transactions_1.parseAssetString)(`${network.bootAddress}.bns::names`), (0, transactions_1.tupleCV)({ | ||
name: (0, transactions_1.bufferCVFromString)(name), | ||
namespace: (0, transactions_1.bufferCVFromString)(namespace), | ||
})); | ||
const postConditionReceiver = (0, transactions_1.createNonFungiblePostCondition)(newOwnerAddress, transactions_1.NonFungibleConditionCode.DoesNotSend, (0, transactions_1.parseAssetString)(`${network.bootAddress}.bns::names`), (0, transactions_1.tupleCV)({ | ||
name: (0, transactions_1.bufferCVFromString)(name), | ||
namespace: (0, transactions_1.bufferCVFromString)(namespace), | ||
})); | ||
const postConditionSender = { | ||
type: 'nft-postcondition', | ||
address: (0, transactions_1.publicKeyToAddress)(network.addressVersion.singleSig, publicKey), | ||
condition: 'sent', | ||
asset: `${network.bootAddress}.bns::names`, | ||
assetId: (0, transactions_1.tupleCV)({ | ||
name: (0, transactions_1.bufferCVFromString)(name), | ||
namespace: (0, transactions_1.bufferCVFromString)(namespace), | ||
}), | ||
}; | ||
const postConditionReceiver = { | ||
type: 'nft-postcondition', | ||
address: newOwnerAddress, | ||
condition: 'not-sent', | ||
asset: `${network.bootAddress}.bns::names`, | ||
assetId: (0, transactions_1.tupleCV)({ | ||
name: (0, transactions_1.bufferCVFromString)(name), | ||
namespace: (0, transactions_1.bufferCVFromString)(namespace), | ||
}), | ||
}; | ||
return makeBnsContractCall({ | ||
@@ -300,3 +322,8 @@ functionName: bnsFunctionName, | ||
]; | ||
const burnSTXPostCondition = (0, transactions_1.createSTXPostCondition)((0, transactions_1.publicKeyToAddress)(network.addressVersion.singleSig, publicKey), transactions_1.FungibleConditionCode.Equal, stxToBurn); | ||
const burnSTXPostCondition = { | ||
type: 'stx-postcondition', | ||
address: (0, transactions_1.publicKeyToAddress)(network.addressVersion.singleSig, publicKey), | ||
condition: 'eq', | ||
amount: (0, common_1.intToBigInt)(stxToBurn), | ||
}; | ||
return makeBnsContractCall({ | ||
@@ -303,0 +330,0 @@ functionName: bnsFunctionName, |
{ | ||
"name": "@stacks/bns", | ||
"version": "6.14.1-pr.44+08a1cf37", | ||
"version": "6.14.1-pr.64+bbe6c9a4", | ||
"description": "Library for working with the Stacks Blockchain Naming System BNS.", | ||
@@ -23,5 +23,5 @@ "license": "MIT", | ||
"dependencies": { | ||
"@stacks/common": "^6.14.1-pr.44+08a1cf37", | ||
"@stacks/network": "^6.14.1-pr.44+08a1cf37", | ||
"@stacks/transactions": "^6.14.1-pr.44+08a1cf37" | ||
"@stacks/common": "^6.14.1-pr.64+bbe6c9a4", | ||
"@stacks/network": "^6.14.1-pr.64+bbe6c9a4", | ||
"@stacks/transactions": "^6.14.1-pr.64+bbe6c9a4" | ||
}, | ||
@@ -57,3 +57,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "08a1cf370cc436ac37b859da38786a30646defe1" | ||
"gitHead": "bbe6c9a41ac22d4d98a997634b964408357fa1de" | ||
} |
@@ -1,2 +0,2 @@ | ||
import { ApiParam, IntegerType, utf8ToBytes } from '@stacks/common'; | ||
import { ApiParam, IntegerType, PublicKey, intToBigInt, utf8ToBytes } from '@stacks/common'; | ||
import { StacksNetwork } from '@stacks/network'; | ||
@@ -6,14 +6,12 @@ import { | ||
ClarityValue, | ||
FungibleConditionCode, | ||
NonFungibleConditionCode, | ||
PostConditionWire, | ||
NonFungiblePostCondition, | ||
PostCondition, | ||
ResponseErrorCV, | ||
StacksTransaction, | ||
StxPostCondition, | ||
UnsignedContractCallOptions, | ||
bufferCV, | ||
bufferCVFromString, | ||
callReadOnlyFunction, | ||
createNonFungiblePostCondition, | ||
createSTXPostCondition, | ||
cvToString, | ||
fetchCallReadOnlyFunction, | ||
getAddressFromPrivateKey, | ||
@@ -25,3 +23,2 @@ getCVTypeString, | ||
noneCV, | ||
parseAssetString, | ||
publicKeyToAddress, | ||
@@ -63,5 +60,5 @@ someCV, | ||
functionArgs: ClarityValue[]; | ||
publicKey: string; | ||
publicKey: PublicKey; | ||
network: StacksNetwork; | ||
postConditions?: PostConditionWire[]; | ||
postConditions?: PostCondition[]; | ||
} | ||
@@ -94,3 +91,3 @@ | ||
): Promise<ClarityValue> { | ||
return callReadOnlyFunction({ | ||
return fetchCallReadOnlyFunction({ | ||
contractAddress: options.network.bootAddress, | ||
@@ -193,3 +190,3 @@ contractName: BNS_CONTRACT_NAME, | ||
if (responseCV.value.type === ClarityType.Int || responseCV.value.type === ClarityType.UInt) { | ||
return responseCV.value.value; | ||
return BigInt(responseCV.value.value); | ||
} else { | ||
@@ -249,3 +246,3 @@ throw new Error('Response did not contain a number'); | ||
if (responseCV.value.type === ClarityType.Int || responseCV.value.type === ClarityType.UInt) { | ||
return responseCV.value.value; | ||
return BigInt(responseCV.value.value); | ||
} else { | ||
@@ -299,7 +296,8 @@ throw new Error('Response did not contain a number'); | ||
const burnSTXPostCondition = createSTXPostCondition( | ||
publicKeyToAddress(network.addressVersion.singleSig, publicKey), | ||
FungibleConditionCode.Equal, | ||
stxToBurn | ||
); | ||
const burnSTXPostCondition: StxPostCondition = { | ||
type: 'stx-postcondition', | ||
address: publicKeyToAddress(network.addressVersion.singleSig, publicKey), | ||
condition: 'eq', | ||
amount: intToBigInt(stxToBurn), | ||
}; | ||
@@ -492,3 +490,3 @@ return makeBnsContractCall({ | ||
/** the private key to sign the transaction */ | ||
publicKey: string; | ||
publicKey: PublicKey; | ||
/** the Stacks blockchain network to use */ | ||
@@ -524,7 +522,8 @@ network: StacksNetwork; | ||
const burnSTXPostCondition = createSTXPostCondition( | ||
publicKeyToAddress(network.addressVersion.singleSig, publicKey), | ||
FungibleConditionCode.Equal, | ||
stxToBurn | ||
); | ||
const burnSTXPostCondition: StxPostCondition = { | ||
type: 'stx-postcondition', | ||
address: publicKeyToAddress(network.addressVersion.singleSig, publicKey), | ||
condition: 'eq', | ||
amount: intToBigInt(stxToBurn), | ||
}; | ||
@@ -554,3 +553,3 @@ return makeBnsContractCall({ | ||
zonefile: string; | ||
publicKey: string; | ||
publicKey: PublicKey; | ||
network: StacksNetwork; | ||
@@ -695,20 +694,22 @@ } | ||
]; | ||
const postConditionSender = createNonFungiblePostCondition( | ||
publicKeyToAddress(network.addressVersion.singleSig, publicKey), | ||
NonFungibleConditionCode.Sends, | ||
parseAssetString(`${network.bootAddress}.bns::names`), | ||
tupleCV({ | ||
const postConditionSender: NonFungiblePostCondition = { | ||
type: 'nft-postcondition', | ||
address: publicKeyToAddress(network.addressVersion.singleSig, publicKey), | ||
condition: 'sent', | ||
asset: `${network.bootAddress}.bns::names`, | ||
assetId: tupleCV({ | ||
name: bufferCVFromString(name), | ||
namespace: bufferCVFromString(namespace), | ||
}) | ||
); | ||
const postConditionReceiver = createNonFungiblePostCondition( | ||
newOwnerAddress, | ||
NonFungibleConditionCode.DoesNotSend, | ||
parseAssetString(`${network.bootAddress}.bns::names`), | ||
tupleCV({ | ||
}), | ||
}; | ||
const postConditionReceiver: NonFungiblePostCondition = { | ||
type: 'nft-postcondition', | ||
address: newOwnerAddress, | ||
condition: 'not-sent', | ||
asset: `${network.bootAddress}.bns::names`, | ||
assetId: tupleCV({ | ||
name: bufferCVFromString(name), | ||
namespace: bufferCVFromString(namespace), | ||
}) | ||
); | ||
}), | ||
}; | ||
@@ -816,7 +817,8 @@ return makeBnsContractCall({ | ||
]; | ||
const burnSTXPostCondition = createSTXPostCondition( | ||
publicKeyToAddress(network.addressVersion.singleSig, publicKey), | ||
FungibleConditionCode.Equal, | ||
stxToBurn | ||
); | ||
const burnSTXPostCondition: StxPostCondition = { | ||
type: 'stx-postcondition', | ||
address: publicKeyToAddress(network.addressVersion.singleSig, publicKey), | ||
condition: 'eq', | ||
amount: intToBigInt(stxToBurn), | ||
}; | ||
@@ -823,0 +825,0 @@ return makeBnsContractCall({ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
720114
2141