-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ownable undernames): added support for under_ant resolution, min…
…ting, and purchase of undernames with multitoken configuration, as well as reservation support
- Loading branch information
1 parent
df933a8
commit 8ddbe48
Showing
25 changed files
with
4,646 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/** | ||
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc. All Rights Reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const { build } = require('esbuild'); | ||
const replace = require('replace-in-file'); | ||
const Ajv = require('ajv'); | ||
const standaloneCode = require('ajv/dist/standalone').default; | ||
const contracts = ['contract-undername-leasing.ts']; | ||
const { | ||
balanceSchema, | ||
removeControllerSchema, | ||
setControllerSchema, | ||
setNameSchema, | ||
setTickerSchema, | ||
setRecordSchema, | ||
removeRecordSchema, | ||
transferSchema, | ||
evolveSchema, | ||
mintSchema, | ||
setMintingPairSchema, | ||
buyRecordSchema, | ||
setReservedRecordsSchema, | ||
removeReservedRecordsSchema, | ||
} = require('./schemas'); | ||
|
||
// build our validation source code | ||
const ajv = new Ajv({ | ||
schemas: [ | ||
balanceSchema, | ||
removeControllerSchema, | ||
setControllerSchema, | ||
setNameSchema, | ||
setTickerSchema, | ||
setRecordSchema, | ||
removeRecordSchema, | ||
transferSchema, | ||
evolveSchema, | ||
mintSchema, | ||
setMintingPairSchema, | ||
buyRecordSchema, | ||
setReservedRecordsSchema, | ||
removeReservedRecordsSchema, | ||
], | ||
code: { source: true, esm: true }, | ||
}); | ||
|
||
const moduleCode = standaloneCode(ajv, { | ||
validateSetRecord: '#/definitions/setRecord', | ||
validateRemoveRecord: '#/definitions/removeRecord', | ||
validateSetController: '#/definitions/setController', | ||
validateRemoveController: '#/definitions/removeController', | ||
validateSetName: '#/definitions/setName', | ||
validateSetTicker: '#/definitions/setTicker', | ||
validateBalance: '#/definitions/balance', | ||
validateTransferTokens: '#/definitions/transfer', | ||
validateEvolve: '#/definitions/evolve', | ||
validateMint: '#/definitions/mint', | ||
validateSetMintingPair: '#/definitions/setMintingPair', | ||
validateBuyRecord: '#/definitions/buyRecord', | ||
validateSetReservedRecords: '#/definitions/setReservedRecords', | ||
validateRemoveReservedRecords: '#/definitions/removeReservedRecords', | ||
}); | ||
|
||
// Now you can write the module code to file | ||
fs.writeFileSync(path.join(__dirname, '/src/validations-undername-leasing.js'), moduleCode); | ||
|
||
build({ | ||
entryPoints: contracts.map((source) => { | ||
return `./src/${source}`; | ||
}), | ||
outdir: './dist', | ||
minify: false, | ||
bundle: true, | ||
format: 'iife', | ||
packages: 'external', | ||
tsconfig: './tsconfig.json', | ||
}) | ||
.catch(() => process.exit(1)) | ||
// note: SmartWeave SDK currently does not support files in IIFE bundle format, so we need to remove the "iife" part ;-) | ||
// update: it does since 0.4.31, but because viewblock.io is still incompatibile with this version, leaving as is for now. | ||
.finally(() => { | ||
const files = contracts.map((source) => { | ||
return `./dist${source}`.replace('.ts', '.js'); | ||
}); | ||
replace.sync({ | ||
files: files, | ||
from: [/\(\(\) => {/g, /}\)\(\);/g], | ||
to: '', | ||
countMatches: true, | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
{ | ||
"ticker": "ANT-OWNABLE-UNDERNAMES", | ||
"name": "Arweave Name Token v0.0.0", | ||
"owner": "", | ||
"controllers": [], | ||
"fees": { | ||
"1": 5000000, | ||
"2": 500000, | ||
"3": 100000, | ||
"4": 25000, | ||
"5": 10000, | ||
"6": 5000, | ||
"7": 2500, | ||
"8": 1500, | ||
"9": 1250, | ||
"10": 1250, | ||
"11": 1250, | ||
"12": 1250, | ||
"13": 1000, | ||
"14": 1000, | ||
"15": 1000, | ||
"16": 1000, | ||
"17": 1000, | ||
"18": 1000, | ||
"19": 1000, | ||
"20": 1000, | ||
"21": 1000, | ||
"22": 1000, | ||
"23": 1000, | ||
"24": 1000, | ||
"25": 1000, | ||
"26": 1000, | ||
"27": 1000, | ||
"28": 1000, | ||
"29": 1000, | ||
"30": 1000, | ||
"31": 1000, | ||
"32": 1000, | ||
"33": 1000, | ||
"34": 1000, | ||
"35": 1000, | ||
"36": 1000, | ||
"37": 1000, | ||
"38": 1000, | ||
"39": 1000, | ||
"40": 1000, | ||
"41": 1000, | ||
"42": 1000, | ||
"43": 1000, | ||
"44": 1000, | ||
"45": 1000, | ||
"46": 1000, | ||
"47": 1000, | ||
"48": 1000, | ||
"49": 1000, | ||
"50": 1000, | ||
"51": 1000, | ||
"52": 1000, | ||
"53": 1000, | ||
"54": 1000, | ||
"55": 1000, | ||
"56": 1000, | ||
"57": 1000, | ||
"58": 1000, | ||
"59": 1000, | ||
"60": 1000, | ||
"61": 1000 | ||
}, | ||
"reserved": { | ||
"subDomains": [], | ||
"pattern": "" | ||
}, | ||
"records": { | ||
"@": { | ||
"transactionId": "", | ||
"ttlSeconds": 900 | ||
} | ||
}, | ||
"balances": { | ||
"": 0 | ||
}, | ||
"totalSupply": 0, | ||
"supportedTokens": { | ||
"AR": { | ||
"conversionRate": 1 | ||
} | ||
}, | ||
"evolve": null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc. All Rights Reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
const buyRecordSchema = { | ||
$id: '#/definitions/buyRecord', | ||
type: 'object', | ||
properties: { | ||
function: { | ||
type: 'string', | ||
const: 'buyRecord', | ||
}, | ||
subDomain: { | ||
type: 'string', | ||
pattern: '^([a-zA-Z0-9][a-zA-Z0-9-_]{0,59}[a-zA-Z0-9]|[a-zA-Z0-9]{1}|@)$', | ||
}, | ||
contractTxId: { | ||
type: 'string', | ||
pattern: '^(atomic|[a-zA-Z0-9-_]{43})$' | ||
} | ||
}, | ||
required: ['subDomain', 'contractTxId'], | ||
additionalProperties: false, | ||
}; | ||
|
||
module.exports = { | ||
buyRecordSchema, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc. All Rights Reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
const mintSchema = { | ||
$id: '#/definitions/mint', | ||
type: 'object', | ||
properties: { | ||
function: { | ||
type: 'string', | ||
const: 'mint', | ||
}, | ||
type: { | ||
type: 'string', | ||
}, | ||
tokenId: { | ||
type: 'string', | ||
pattern:'^[a-zA-Z0-9_-]{43}$' | ||
} | ||
}, | ||
required: ['type', 'tokenId'], | ||
additionalProperties: false, | ||
}; | ||
|
||
module.exports = { | ||
mintSchema, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc. All Rights Reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
const removeReservedRecordsSchema = { | ||
$id: '#/definitions/removeReservedRecords', | ||
type: 'object', | ||
properties: { | ||
function: { | ||
type: 'string', | ||
const: 'removeReservedRecords', | ||
}, | ||
subDomains: { | ||
type: 'array', | ||
items: { | ||
type: 'string', | ||
pattern: '^([a-zA-Z0-9][a-zA-Z0-9-_]{0,59}[a-zA-Z0-9]|[a-zA-Z0-9]{1})$' | ||
}, | ||
}, | ||
}, | ||
required: ['subDomains'], | ||
additionalProperties: false, | ||
}; | ||
|
||
module.exports = { | ||
removeReservedRecordsSchema, | ||
}; |
Oops, something went wrong.