Skip to content

Commit

Permalink
fix: validate with abi, hash zonfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
reedrosenbluth committed Apr 7, 2021
1 parent 02e7ed7 commit bccd9b5
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions packages/bns/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async function makeBNSContractCall(options: BNSContractCallOptions): Promise<Res
contractName: BNS_CONTRACT_NAME,
functionName: options.functionName,
functionArgs: options.functionArgs,
validateWithAbi: false,
validateWithAbi: true,
senderKey: options.senderKey,
network: options.network,
};
Expand Down Expand Up @@ -312,7 +312,7 @@ export interface RevealNamespaceOptions {
namespace: string,
salt: string,
priceFunction: PriceFunction,
lifeTime: BN,
lifetime: BN,
namespaceImportAddress: string,
privateKey: string,
network?: StacksNetwork
Expand All @@ -332,7 +332,7 @@ export async function revealNamespace({
namespace,
salt,
priceFunction,
lifeTime,
lifetime,
namespaceImportAddress,
privateKey,
network
Expand Down Expand Up @@ -365,7 +365,7 @@ export async function revealNamespace({
uintCVFromBN(priceFunction.b16),
uintCVFromBN(priceFunction.nonAlphaDiscount),
uintCVFromBN(priceFunction.noVowelDiscount),
uintCVFromBN(lifeTime),
uintCVFromBN(lifetime),
standardPrincipalCV(namespaceImportAddress),
],
senderKey: privateKey,
Expand Down Expand Up @@ -589,7 +589,7 @@ export async function registerName({
*
* @param {String} fullyQualifiedName - the fully qualified name to update including the
* namespace (myName.id)
* @param {String} zonefileHash - the zonefile hash to register with the name
* @param {String} zonefile - the zonefile to register with the name
* @param {String} privateKey - the private key to sign the transaction
* @param {StacksNetwork} network - the Stacks blockchain network to register on
*/
Expand Down Expand Up @@ -643,15 +643,15 @@ export async function updateName({
* @param {String} fullyQualifiedName - the fully qualified name to transfer including the
* namespace (myName.id)
* @param {String} newOwnerAddress - the recipient address of the name transfer
* @param {String} zonefileHash - the optional zonefile hash to register with the name
* @param {String} zonefile - the optional zonefile to register with the name
* @param {String} privateKey - the private key to sign the transaction
* @param {StacksNetwork} network - the Stacks blockchain network to register on
*/
export interface TransferNameOptions {
fullyQualifiedName: string,
newOwnerAddress: string,
privateKey: string,
zonefileHash?: string,
zonefile?: string,
network?: StacksNetwork
}

Expand All @@ -668,8 +668,8 @@ export interface TransferNameOptions {
export async function transferName({
fullyQualifiedName,
newOwnerAddress,
zonefile,
privateKey,
zonefileHash,
network
}: TransferNameOptions): Promise<Result> {
const bnsFunctionName = 'name-transfer';
Expand All @@ -685,15 +685,16 @@ export async function transferName({
bufferCVFromString(newOwnerAddress)
];

if (zonefileHash) {
functionArgs.push(bufferCVFromString(zonefileHash));
if (zonefile) {
functionArgs.push(bufferCV(getZonefileHash(zonefile)));
}

return makeBNSContractCall({
functionName: bnsFunctionName,
functionArgs,
senderKey: privateKey,
network: txNetwork
network: txNetwork,
attachment: zonefile ? Buffer.from(zonefile) : undefined
});
}

Expand Down Expand Up @@ -777,9 +778,9 @@ export interface RenewNameOptions {
export async function renewName({
fullyQualifiedName,
stxToBurn,
privateKey,
newOwnerAddress,
zonefile,
privateKey,
network
}: RenewNameOptions): Promise<Result> {
const bnsFunctionName = 'name-renewal';
Expand Down

0 comments on commit bccd9b5

Please sign in to comment.