Skip to content

Commit

Permalink
Merge pull request #113 from azero-id/feat/add-renewal-feature
Browse files Browse the repository at this point in the history
Add renewal functionality
  • Loading branch information
realnimish authored Aug 1, 2024
2 parents 5164793 + cc53717 commit fa112c2
Show file tree
Hide file tree
Showing 11 changed files with 806 additions and 559 deletions.
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"author": "AZERO.ID <[email protected]> (https://azero.id)",
"type": "module",
"engines": {
"node": "20",
"pnpm": "9"
"node": "20"
},
"packageManager": "[email protected]",
"scripts": {
"test": "bash test-all.sh",
"build": "bash build-all.sh",
Expand All @@ -23,24 +23,24 @@
},
"devDependencies": {
"@faker-js/faker": "^8.3.1",
"@polkadot/api": "^12.2.1",
"@polkadot/api-contract": "^12.2.1",
"@polkadot/api": "^12.2.3",
"@polkadot/api-contract": "^12.2.3",
"@polkadot/keyring": "^13.0.2",
"@polkadot/types": "^12.2.1",
"@polkadot/types": "^12.2.3",
"@polkadot/util": "^13.0.2",
"@polkadot/util-crypto": "^13.0.2",
"@scio-labs/use-inkathon": "0.10.0",
"@types/node": "^20.10.0",
"@typescript-eslint/eslint-plugin": "^7.16.0",
"@typescript-eslint/parser": "^7.16.0",
"@scio-labs/use-inkathon": "0.11.0",
"@types/node": "^20.14.13",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"bn.js": "^5.2.1",
"cli-progress": "^3.12.0",
"csv": "^6.3.5",
"csv": "^6.3.10",
"dotenv": "^16.3.1",
"eslint": "^8.54.0",
"eslint-config-prettier": "^9.0.0",
"prettier": "^3.1.0",
"tsx": "^4.5.0",
"typescript": "^5.3.2"
"typescript": "^5.5.4"
}
}
755 changes: 303 additions & 452 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { writeContractAddresses } from './utils/writeContractAddresses'
* - `CHAIN`: Chain ID (optional, defaults to `development`)
* - `ADMIN`: Address of contract admin (optional, defaults to caller)
* - `RESERVATIONS`: Path to .csv file with reserved names & addresses
* - `NEW_CONFIG`: If set, use new default price (10 AZERO) & max registration duration (200 years)
*
* Example usage:
* - `CHAIN=alephzero-testnet ADMIN=5fei… RESERVATIONS=reserved-names.csv pnpm run deploy`
Expand All @@ -27,8 +28,15 @@ const main = async () => {
const chainId = initParams.chain.network

// Deploy all contracts
const useNewConfig = ['true', true, '1', 1].includes(process.env.NEW_CONFIG || '')
const feeCalculator = await deployFeeCalculator(
initParams,
useNewConfig && {
maxRegistrationDuration: 200,
commonPrice: initParams.toBNWithDecimals(10),
},
)
const nameChecker = await deployNameChecker(initParams)
const feeCalculator = await deployFeeCalculator(initParams)
const tlds = chainId === alephzero.network ? ['azero', 'a0'] : ['tzero']
const tld = tlds[0]
const baseUri =
Expand Down
17 changes: 11 additions & 6 deletions scripts/deploy/deployFeeCalculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,16 @@ export const deployFeeCalculator: DeployFn<FeeCalculatorArgs> = async (
customArgs,
)
const { abi, wasm } = await getDeploymentData('azns_fee_calculator')
const nonce = await api.rpc.system.accountNextIndex(account.address)

return await deployContract(api, account, abi, wasm, 'new', [
args.admin,
args.maxRegistrationDuration,
args.commonPrice,
args.pricePoints,
])
return await deployContract(
api,
account,
abi,
wasm,
'new',
[args.admin, args.maxRegistrationDuration, args.commonPrice, args.pricePoints],
undefined,
{ nonce },
)
}
22 changes: 16 additions & 6 deletions scripts/deploy/deployNameChecker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,21 @@ export const deployNameChecker: DeployFn<NameCheckerArgs> = async (
customArgs,
)
const { abi, wasm } = await getDeploymentData('azns_name_checker')
const nonce = await api.rpc.system.accountNextIndex(account.address)

return await deployContract(api, account, abi, wasm, 'new', [
args.admin,
args.allowedLength,
args.allowedUnicodeRanges,
args.disallowedUnicodeRangesForEdges,
])
return await deployContract(
api,
account,
abi,
wasm,
'new',
[
args.admin,
args.allowedLength,
args.allowedUnicodeRanges,
args.disallowedUnicodeRangesForEdges,
],
undefined,
{ nonce },
)
}
18 changes: 11 additions & 7 deletions scripts/deploy/deployRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ export const deployRegistry: DeployFn<RegistryArgs> = async ({ api, account }, c
customArgs,
)
const { abi, wasm } = await getDeploymentData('azns_registry')
const nonce = await api.rpc.system.accountNextIndex(account.address)

return await deployContract(api, account, abi, wasm, 'new', [
args.admin,
args.nameCheckerAddress,
args.feeCalculatorAddress,
args.tld,
args.baseUri,
])
return await deployContract(
api,
account,
abi,
wasm,
'new',
[args.admin, args.nameCheckerAddress, args.feeCalculatorAddress, args.tld, args.baseUri],
undefined,
{ nonce },
)
}
3 changes: 2 additions & 1 deletion scripts/deploy/deployRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ export const deployRouter: DeployFn<RouterArgs> = async ({ api, account }, custo
customArgs,
)
const { abi, wasm } = await getDeploymentData('azns_router')
const nonce = await api.rpc.system.accountNextIndex(account.address)

return await deployContract(api, account, abi, wasm, 'new', [args.admin])
return await deployContract(api, account, abi, wasm, 'new', [args.admin], undefined, { nonce })
}

/**
Expand Down
2 changes: 1 addition & 1 deletion scripts/testContractStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ const main = async () => {
*/
const registerDomain = async (api, account, contract, domainPrice, domainName) => {
try {
await contractTx(api, account, contract, 'register', { value: domainPrice }, [
await contractTx(api, account, contract, 'register_v2', { value: domainPrice }, [
domainName,
1,
null,
Expand Down
2 changes: 1 addition & 1 deletion src/azns_fee_calculator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "azns_fee_calculator"
version = "1.0.0"
version = "1.1.0"
authors = ["AZERO.ID <[email protected]>"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion src/azns_registry/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "azns_registry"
version = "1.0.0"
version = "1.1.0"
authors = ["AZERO.ID <[email protected]>"]
edition = "2021"
publish = false
Expand Down
Loading

0 comments on commit fa112c2

Please sign in to comment.