Create separate record files

This commit is contained in:
Shreerang Kale 2025-07-25 13:32:00 +05:30
parent 6b07676684
commit aae48cdef4
6 changed files with 32 additions and 43 deletions

3
.gitignore vendored
View File

@ -43,3 +43,6 @@ yarn-error.log*
# typescript
*.tsbuildinfo
# Reveal file out dir
out

6
deploy/alnt-pricing.yml Normal file
View File

@ -0,0 +1,6 @@
record:
type: PricingRecord
for: "alnt"
amount: "0.000386"
currency: "USD"
version: 1.0.0

View File

@ -1,6 +0,0 @@
record:
type: PricingRecord
for: ""
amount: ""
currency: ""
version: 1.0.0

View File

@ -17,12 +17,6 @@
# Builds image cerc/laconic-registry-cli:latest
```
- Make the CLI script executable:
```bash
chmod +x laconic-cli.sh
```
- Configure `userKey` in the [registry CLI config](./config.yml):
NOTE: User key should be of the account that owns the `laconic` authority
@ -37,24 +31,14 @@ NOTE: Publishing record requires a bond with enough funds, if you don't have a b
### Publish Record for Cost of alnt
- Update `for`, `cost` and `currency` fields in [pricing.yml](./pricing.yml) file:
```bash
...
for: "alnt"
amount: "0.000385802"
currency: "USD"
...
```
- Amount calculation:
- Cost of 1 deployment is `12960` in terms of `alnt` or `5` in terms of `USD`
- Hence, cost of 1 `alnt` comes out be `0.000385802 USD` rounded off to 6 decimals
- alnt price calculation (reference: <https://store.laconic.com>):
- Cost of 1 deployment is `12960` in terms of `alnt` or `5` in terms of `USD`
- Hence, cost of 1 `alnt` comes out be `0.000386 USD` rounded off to 6 decimals
- Publish the record:
```bash
./laconic-cli.sh record publish --filename pricing.yml --bond-id <bond-id>
./laconic-cli.sh record publish --filename alnt-pricing.yml --bond-id <bond-id>
```
- Get record info:
@ -65,20 +49,10 @@ NOTE: Publishing record requires a bond with enough funds, if you don't have a b
### Publish Record for Cost of Deployment
- Update `for`, `cost` and `currency` fields in [pricing.yml](./pricing.yml) file:
```bash
...
for: "webapp-deployment"
amount: "12960"
currency: "alnt"
...
```
- Publish the record:
```bash
./laconic-cli.sh record publish --filename pricing.yml --bond-id <bond-id>
./laconic-cli.sh record publish --filename webapp-deployment-pricing.yml --bond-id <bond-id>
```
- Get record info:
@ -89,7 +63,9 @@ NOTE: Publishing record requires a bond with enough funds, if you don't have a b
## Set Record Name
NOTE: To set record name an authority with an authority bond is required, if you don't have an authority check [steps to reserve a new authority](#reserve-a-new-authority-optional)
NOTE: To set record name an authority is required, if you don't have an authority check [steps to reserve a new authority](#reserve-a-new-authority-optional)
These record names should be under `laconic` authority
- Set record name for cost of alnt record
@ -158,12 +134,18 @@ Below steps are used to reserve `laconic` authority
Reveal file: /app/deploy/out/bafyreiay2rccax64yn4ljhvzvm3jkbebvzheyucuma5jlbpzpzd5i5gjuy.json
```
- The commit phase lasts for 1 minute after reserving the authority so please commit the auction bid within this time period
- Reveal bid:
```bash
./laconic-cli.sh auction bid reveal <auction-id> /app/deploy/out/bafyreiay2rccax64yn4ljhvzvm3jkbebvzheyucuma5jlbpzpzd5i5gjuy.json
```
- The reveal phase starts as soon as commit phase ends and lasts for 1 minute so please reveal the bid within this time period
- To use this published authority for setting record names, authority bond is also required
### Set Authority Bond
- Set authority bond after winning auction:

View File

@ -0,0 +1,6 @@
record:
type: PricingRecord
for: "webapp-deployment"
amount: "12960"
currency: "alnt"
version: 1.0.0

View File

@ -7,9 +7,7 @@ assert(process.env.NEXT_PUBLIC_DEPLOYMENT_COST_LRN, 'DEPLOYMENT_COST_LRN is requ
assert(process.env.NEXT_PUBLIC_ALNT_COST_LRN, 'ALNT_COST_LRN is required');
const DEPLOYMENT_COST_LRN = process.env.NEXT_PUBLIC_DEPLOYMENT_COST_LRN;
const DEPLOYMENT = 'webapp-deployment';
const ALNT_COST_LRN = process.env.NEXT_PUBLIC_ALNT_COST_LRN;
const ALNT = 'alnt';
export const createApplicationDeploymentRequest = async (
url: string,
@ -76,9 +74,9 @@ export const getCostOfDeployment = async (): Promise<number> => {
console.log('resolvedRecords:', resolvedRecords);
// Find the ALNT price record (USD per ALNT)
const alntPriceRecord = resolvedRecords.find(record => record.for === ALNT);
const alntPriceRecord = resolvedRecords[0];
// Find the deployment cost record (ALNT cost for webapp-deployment)
const deploymentCostRecord = resolvedRecords.find(record => record.for === DEPLOYMENT);
const deploymentCostRecord = resolvedRecords[1];
if (!alntPriceRecord || !deploymentCostRecord) {
throw new Error('Required pricing records not found');
@ -92,5 +90,5 @@ export const getCostOfDeployment = async (): Promise<number> => {
const deploymentCostUsd = deploymentCostAlnt * alntPriceUsd;
// Return with 6 decimal precision
return parseFloat(deploymentCostUsd.toFixed(6));
return parseFloat(deploymentCostUsd.toFixed(2));
}