diff --git a/.gitignore b/.gitignore index 1ec5286..e6d23e2 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,6 @@ yarn-error.log* # typescript *.tsbuildinfo + +# Reveal file out dir +out \ No newline at end of file diff --git a/deploy/alnt-pricing.yml b/deploy/alnt-pricing.yml new file mode 100644 index 0000000..e3529e1 --- /dev/null +++ b/deploy/alnt-pricing.yml @@ -0,0 +1,6 @@ +record: + type: PricingRecord + for: "alnt" + amount: "0.000386" + currency: "USD" + version: 1.0.0 diff --git a/deploy/pricing.yml b/deploy/pricing.yml deleted file mode 100644 index 8fe991e..0000000 --- a/deploy/pricing.yml +++ /dev/null @@ -1,6 +0,0 @@ -record: - type: PricingRecord - for: "" - amount: "" - currency: "" - version: 1.0.0 diff --git a/deploy/publish-pricing.md b/deploy/publish-pricing.md index 79b077a..680ddb9 100644 --- a/deploy/publish-pricing.md +++ b/deploy/publish-pricing.md @@ -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: ): + - 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 + ./laconic-cli.sh record publish --filename alnt-pricing.yml --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 + ./laconic-cli.sh record publish --filename webapp-deployment-pricing.yml --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 /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: diff --git a/deploy/webapp-deployment-pricing.yml b/deploy/webapp-deployment-pricing.yml new file mode 100644 index 0000000..abfc3a6 --- /dev/null +++ b/deploy/webapp-deployment-pricing.yml @@ -0,0 +1,6 @@ +record: + type: PricingRecord + for: "webapp-deployment" + amount: "12960" + currency: "alnt" + version: 1.0.0 diff --git a/src/services/registry.ts b/src/services/registry.ts index 8a9c226..cf0206b 100644 --- a/src/services/registry.ts +++ b/src/services/registry.ts @@ -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 => { 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 => { const deploymentCostUsd = deploymentCostAlnt * alntPriceUsd; // Return with 6 decimal precision - return parseFloat(deploymentCostUsd.toFixed(6)); + return parseFloat(deploymentCostUsd.toFixed(2)); }