Skip to content

Commit

Permalink
fix(tags): use ans-116 format for all tags
Browse files Browse the repository at this point in the history
  • Loading branch information
dtfiedler committed Jun 24, 2024
1 parent feeb8e2 commit a50e556
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 35 deletions.
6 changes: 3 additions & 3 deletions src/arns.lua
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ end

function arns.getTokenCost(intendedAction)
local tokenCost = 0
if intendedAction.intent == "BuyRecord" then
if intendedAction.intent == "Buy-Record" then
local purchaseType = intendedAction.purchaseType
local years = intendedAction.years
local name = intendedAction.name
Expand All @@ -316,7 +316,7 @@ function arns.getTokenCost(intendedAction)
assert(type(name) == "string", "Name is required and must be a string.")
local baseFee = demand.getFees()[#name]
tokenCost = arns.calculateRegistrationFee(purchaseType, baseFee, years, demand.getDemandFactor())
elseif intendedAction.intent == "ExtendLease" then
elseif intendedAction.intent == "Extend-Lease" then
local name = intendedAction.name
local years = intendedAction.years
assert(type(name) == "string", "Name is required and must be a string.")
Expand All @@ -331,7 +331,7 @@ function arns.getTokenCost(intendedAction)
local years = intendedAction.years
local baseFee = demand.getFees()[#intendedAction.name]
tokenCost = arns.calculateExtensionFee(baseFee, years, demand.getDemandFactor())
elseif intendedAction.intent == "IncreaseUndernameLimit" then
elseif intendedAction.intent == "Increase-Undername-Limit" then
local name = intendedAction.name
local qty = intendedAction.quantity
local currentTimestamp = intendedAction.currentTimestamp
Expand Down
47 changes: 24 additions & 23 deletions src/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,39 +33,40 @@ local ActionMap = {
Transfer = "Transfer",
Balance = "Balance",
Balances = "Balances",
DemandFactor = "DemandFactor",
DemandFactor = "Demand-Factor",
-- EPOCH READ APIS
Epochs = "Epochs",
Epoch = "Epoch",
PrescribedObservers = "EpochPrescribedObservers",
PrescribedNames = "EpochPrescribedNames",
Observations = "EpochObservations",
Distributions = "EpochDistributions",
PrescribedObservers = "Epoch-Prescribed-Observers",
PrescribedNames = "Epoch-Prescribed-Names",
Observations = "Epoch-Observations",
Distributions = "Epoch-Distributions",
-- hypenated for all of these
-- NAME REGISTRY READ APIS
Record = "Record",
Records = "Records",
ReservedNames = "ReservedNames",
ReservedName = "ReservedName",
TokenCost = "TokenCost",
ReservedNames = "Reserved-Names",
ReservedName = "Reserved-Name",
TokenCost = "Token-Cost",
-- GATEWAY REGISTRY READ APIS
Gateway = "Gateway",
Gateways = "Gateways",
-- writes
CreateVault = "CreateVault",
VaultedTransfer = "VaultedTransfer",
ExtendVault = "ExtendVault",
IncreaseVault = "IncreaseVault",
BuyRecord = "BuyRecord",
ExtendLease = "ExtendLease",
IncreaseUndernameLimit = "IncreaseUndernameLimit",
JoinNetwork = "JoinNetwork",
LeaveNetwork = "LeaveNetwork",
IncreaseOperatorStake = "IncreaseOperatorStake",
DecreaseOperatorStake = "DecreaseOperatorStake",
UpdateGatewaySettings = "UpdateGatewaySettings",
SaveObservations = "SaveObservations",
DelegateStake = "DelegateStake",
DecreaseDelegateStake = "DecreaseDelegateStake",
CreateVault = "Create-Vault",
VaultedTransfer = "Vaulted-Transfer",
ExtendVault = "Extend-Vault",
IncreaseVault = "Increase-Vault",
BuyRecord = "Buy-Record",
ExtendLease = "Extend-Lease",
IncreaseUndernameLimit = "Increase-Undername-Limit",
JoinNetwork = "Join-Network",
LeaveNetwork = "Leave-Network",
IncreaseOperatorStake = "Increase-Operator-Stake",
DecreaseOperatorStake = "Decrease-Operator-Stake",
UpdateGatewaySettings = "Update-Gateway-Settings",
SaveObservations = "Save-Observations",
DelegateStake = "Delegate-Stake",
DecreaseDelegateStake = "Decrease-Delegate-Stake",
}

-- Write handlers
Expand Down
18 changes: 9 additions & 9 deletions test/arns.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('ArNS', async () => {
it('should increase the undernames', async () => {
const buyUndernameResult = await handle({
Tags: [
{ name: 'Action', value: 'BuyRecord' },
{ name: 'Action', value: 'Buy-Record' },
{ name: 'Name', value: 'test-name' },
{ name: 'PurchaseType', value: 'lease' },
{ name: 'Years', value: '1' },
Expand All @@ -34,7 +34,7 @@ describe('ArNS', async () => {
const increaseUndernameResult = await handle(
{
Tags: [
{ name: 'Action', value: 'IncreaseUndernameLimit' },
{ name: 'Action', value: 'Increase-Undername-Limit' },
{ name: 'Name', value: 'test-name' },
{ name: 'Quantity', value: '1' },
],
Expand All @@ -58,8 +58,8 @@ describe('ArNS', async () => {
it('should get the costs buy record correctly', async () => {
const result = await handle({
Tags: [
{ name: 'Action', value: 'TokenCost' },
{ name: 'Intent', value: 'BuyRecord' },
{ name: 'Action', value: 'Token-Cost' },
{ name: 'Intent', value: 'Buy-Record' },
{ name: 'Name', value: 'test-name' },
{ name: 'PurchaseType', value: 'lease' },
{ name: 'Years', value: '1' },
Expand All @@ -73,7 +73,7 @@ describe('ArNS', async () => {
it('should get the costs increase undername correctly', async () => {
const buyUndernameResult = await handle({
Tags: [
{ name: 'Action', value: 'BuyRecord' },
{ name: 'Action', value: 'Buy-Record' },
{ name: 'Name', value: 'test-name' },
{ name: 'PurchaseType', value: 'lease' },
{ name: 'Years', value: '1' },
Expand All @@ -83,8 +83,8 @@ describe('ArNS', async () => {
const result = await handle(
{
Tags: [
{ name: 'Action', value: 'TokenCost' },
{ name: 'Intent', value: 'IncreaseUndernameLimit' },
{ name: 'Action', value: 'Token-Cost' },
{ name: 'Intent', value: 'Increase-Undername-Limit' },
{ name: 'Name', value: 'test-name' },
{ name: 'Quantity', value: '1' },
],
Expand All @@ -99,7 +99,7 @@ describe('ArNS', async () => {
it('should get the cost of increasing a lease correctly', async () => {
const buyUndernameResult = await handle({
Tags: [
{ name: 'Action', value: 'BuyRecord' },
{ name: 'Action', value: 'Buy-Record' },
{ name: 'Name', value: 'test-name' },
{ name: 'PurchaseType', value: 'lease' },
{ name: 'Years', value: '1' },
Expand All @@ -119,7 +119,7 @@ describe('ArNS', async () => {
const extendResult = await handle(
{
Tags: [
{ name: 'Action', value: 'ExtendLease' },
{ name: 'Action', value: 'Extend-Lease' },
{ name: 'Name', value: 'test-name' },
{ name: 'Years', value: '1' },
],
Expand Down

0 comments on commit a50e556

Please sign in to comment.